@tscircuit/runframe 0.0.1209 → 0.0.1211

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -5080,7 +5080,7 @@ ${c.join(`
5080
5080
  ${_}polygon: ${m.polygon.vertices}
5081
5081
  `:c+=`
5082
5082
  `,m.children.length>0&&u.push(m.children)}return c}};e.exports=s}}),_gn=gt({"node_modules/@jscad/modeling/src/operations/booleans/trees/Tree.js"(n,e){var t=hgn(),i=mgn(),r=class{constructor(o){this.polygonTree=new i,this.rootnode=new t(null),o&&this.addPolygons(o)}invert(){this.polygonTree.invert(),this.rootnode.invert()}clipTo(o,s=!1){this.rootnode.clipTo(o,s)}allPolygons(){const o=[];return this.polygonTree.getPolygons(o),o}addPolygons(o){const s=new Array(o.length);for(let a=0;a<o.length;a++)s[a]=this.polygonTree.addChild(o[a]);this.rootnode.addPolygonTreeNodes(s)}clear(){this.polygonTree.clear()}toString(){return"Tree: "+this.polygonTree.toString("")}};e.exports=r}}),tye=gt({"node_modules/@jscad/modeling/src/operations/booleans/trees/index.js"(n,e){e.exports={Tree:_gn()}}}),ygn=gt({"node_modules/@jscad/modeling/src/operations/booleans/intersectGeom3Sub.js"(n,e){var t=Ya(),i=eye(),{Tree:r}=tye(),o=(s,a)=>{if(!i(s,a))return t.create();const c=new r(t.toPolygons(s)),l=new r(t.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 t.create(u)};e.exports=o}}),JQe=gt({"node_modules/@jscad/modeling/src/operations/booleans/intersectGeom3.js"(n,e){var t=Ra(),i=e8(),r=ygn(),o=(...s)=>{s=t(s);let a=s.shift();return s.forEach(c=>{a=r(a,c)}),a=i(a),a};e.exports=o}}),ggn=gt({"node_modules/@jscad/modeling/src/operations/booleans/intersectGeom2.js"(n,e){var t=Ra(),i=Ya(),r=UM(),o=Q_e(),s=J_e(),a=JQe(),c=(...l)=>{l=t(l);const u=l.map(p=>s({z0:-1,z1:1},p)),d=a(u),h=r(d);return o(h,i.toPolygons(d))};e.exports=c}}),xgn=gt({"node_modules/@jscad/modeling/src/operations/booleans/intersect.js"(n,e){var t=Ra(),i=J6(),r=Ga(),o=Ya(),s=ggn(),a=JQe(),c=(...l)=>{if(l=t(l),l.length===0)throw new Error("wrong number of arguments");if(!i(l))throw new Error("only intersect of the types are supported");const u=l[0];return r.isA(u)?s(l):o.isA(u)?a(l):u};e.exports=c}}),bgn=gt({"node_modules/@jscad/modeling/src/operations/booleans/scissionGeom3.js"(n,e){var t=Wo(),i=UM(),r=Ya(),o=l=>l.sort((u,d)=>u-d).filter((u,d,h)=>!d||u!==h[d-1]),s=(l,u,d)=>{const h=`${u}`,p=l.get(h);p===void 0?l.set(h,[d]):p.push(d)},a=(l,u)=>{const d=`${u}`;return l.get(d)},c=l=>{const u=i(l),d=r.toPolygons(l),h=d.length,p=new Map,m=t.create();d.forEach((w,E)=>{w.vertices.forEach(N=>{s(p,t.snap(m,N,u),E)})});const _=d.map(w=>{let E=[];return w.vertices.forEach(N=>{E=E.concat(a(p,t.snap(m,N,u)))}),{e:1,d:o(E)}});p.clear();let g=0;const x=_.length;for(let w=0;w<x;w++){const E=_[w];if(E.e>0){const N=new Array(h);N[w]=!0;do g=0,N.forEach((A,I)=>{const M=_[I];if(M.e>0){M.e=-1;for(let k=0;k<M.d.length;k++)N[M.d[k]]=!0;g++}});while(g>0);E.indexes=N}}const b=[];for(let w=0;w<x;w++)if(_[w].indexes){const E=[];_[w].indexes.forEach((N,A)=>E.push(d[A])),b.push(r.create(E))}return b};e.exports=c}}),vgn=gt({"node_modules/@jscad/modeling/src/operations/booleans/scission.js"(n,e){var t=Ra(),i=Ya(),r=bgn(),o=(...s)=>{if(s=t(s),s.length===0)throw new Error("wrong number of arguments");const a=s.map(c=>i.isA(c)?r(c):c);return a.length===1?a[0]:a};e.exports=o}}),wgn=gt({"node_modules/@jscad/modeling/src/operations/booleans/subtractGeom3Sub.js"(n,e){var t=Ya(),i=eye(),{Tree:r}=tye(),o=(s,a)=>{if(!i(s,a))return t.clone(s);const c=new r(t.toPolygons(s)),l=new r(t.toPolygons(a));c.invert(),c.clipTo(l),l.clipTo(c,!0),c.addPolygons(l.allPolygons()),c.invert();const u=c.allPolygons();return t.create(u)};e.exports=o}}),eJe=gt({"node_modules/@jscad/modeling/src/operations/booleans/subtractGeom3.js"(n,e){var t=Ra(),i=e8(),r=wgn(),o=(...s)=>{s=t(s);let a=s.shift();return s.forEach(c=>{a=r(a,c)}),a=i(a),a};e.exports=o}}),Sgn=gt({"node_modules/@jscad/modeling/src/operations/booleans/subtractGeom2.js"(n,e){var t=Ra(),i=Ya(),r=UM(),o=Q_e(),s=J_e(),a=eJe(),c=(...l)=>{l=t(l);const u=l.map(p=>s({z0:-1,z1:1},p)),d=a(u),h=r(d);return o(h,i.toPolygons(d))};e.exports=c}}),Egn=gt({"node_modules/@jscad/modeling/src/operations/booleans/subtract.js"(n,e){var t=Ra(),i=J6(),r=Ga(),o=Ya(),s=Sgn(),a=eJe(),c=(...l)=>{if(l=t(l),l.length===0)throw new Error("wrong number of arguments");if(!i(l))throw new Error("only subtract of the types are supported");const u=l[0];return r.isA(u)?s(l):o.isA(u)?a(l):u};e.exports=c}}),tJe=gt({"node_modules/@jscad/modeling/src/operations/booleans/unionGeom3Sub.js"(n,e){var t=Ya(),i=eye(),{Tree:r}=tye(),o=(a,c)=>{if(!i(a,c))return s(a,c);const l=new r(t.toPolygons(a)),u=new r(t.toPolygons(c));l.clipTo(u,!1),u.clipTo(l),u.invert(),u.clipTo(l),u.invert();const d=l.allPolygons().concat(u.allPolygons());return t.create(d)},s=(a,c)=>{let l=t.toPolygons(a);return l=l.concat(t.toPolygons(c)),t.create(l)};e.exports=o}}),nJe=gt({"node_modules/@jscad/modeling/src/operations/booleans/unionGeom3.js"(n,e){var t=Ra(),i=e8(),r=tJe(),o=(...s)=>{s=t(s);let a;for(a=1;a<s.length;a+=2)s.push(r(s[a-1],s[a]));let c=s[a-1];return c=i(c),c};e.exports=o}}),iJe=gt({"node_modules/@jscad/modeling/src/operations/booleans/unionGeom2.js"(n,e){var t=Ra(),i=Ya(),r=UM(),o=Q_e(),s=J_e(),a=nJe(),c=(...l)=>{l=t(l);const u=l.map(p=>s({z0:-1,z1:1},p)),d=a(u),h=r(d);return o(h,i.toPolygons(d))};e.exports=c}}),nye=gt({"node_modules/@jscad/modeling/src/operations/booleans/union.js"(n,e){var t=Ra(),i=J6(),r=Ga(),o=Ya(),s=iJe(),a=nJe(),c=(...l)=>{if(l=t(l),l.length===0)throw new Error("wrong number of arguments");if(!i(l))throw new Error("only unions of the same type are supported");const u=l[0];return r.isA(u)?s(l):o.isA(u)?a(l):u};e.exports=c}}),t8=gt({"node_modules/@jscad/modeling/src/operations/booleans/index.js"(n,e){e.exports={intersect:xgn(),scission:vgn(),subtract:Egn(),union:nye()}}}),KH=gt({"node_modules/@jscad/modeling/src/operations/expansions/offsetFromPoints.js"(n,e){var{EPS:t,TAU:i}=fu(),r=NQe(),o=Y_e(),s=wc(),a=qH(),c=(l,u)=>{const d={delta:1,corners:"edge",closed:!1,segments:16};let{delta:h,corners:p,closed:m,segments:_}=Object.assign({},d,l);if(Math.abs(h)<t)return u;let g=l.closed?a(u):1;g===0&&(g=1);const x=g>0&&h>=0||g<0&&h<0;h=Math.abs(h);let b=null,w=[];const E=[],N=s.create(),A=u.length;for(let I=0;I<A;I++){const M=(I+1)%A,k=u[I],C=u[M];x?s.subtract(N,k,C):s.subtract(N,C,k),s.normal(N,N),s.normalize(N,N),s.scale(N,N,h);const U=s.add(s.create(),k,N),O=s.add(s.create(),C,N),H=[U,O];if(b!=null&&(m||!m&&M!==0)){const Y=r(b[0],b[1],H[0],H[1]);Y?(w.pop(),H[0]=Y):E.push({c:k,s0:b,s1:H})}b=[U,O],!(M===0&&!m)&&(w.push(H[0]),w.push(H[1]))}if(m&&b!=null){const I=w[0],M=w[1],k=r(b[0],b[1],I,M);if(k)w[0]=k,w.pop();else{const C=u[0],U=[I,M];E.push({c:C,s0:b,s1:U})}}if(p==="edge"){const I=new Map;w.forEach((C,U)=>I.set(C,U));const M=o.create(),k=o.create();E.forEach(C=>{o.fromPoints(M,C.s0[0],C.s0[1]),o.fromPoints(k,C.s1[0],C.s1[1]);const U=o.intersectPointOfLines(M,k);if(Number.isFinite(U[0])&&Number.isFinite(U[1])){const O=C.s0[1],H=I.get(O);w[H]=U,w[(H+1)%w.length]=void 0}else{const O=C.s1[0],H=I.get(O);w[H]=void 0}}),w=w.filter(C=>C!==void 0)}if(p==="round"){let I=Math.floor(_/4);const M=s.create();E.forEach(k=>{let C=s.angle(s.subtract(M,k.s1[0],k.c));if(C-=s.angle(s.subtract(M,k.s0[1],k.c)),x&&C<0&&(C=C+Math.PI,C<0&&(C=C+Math.PI)),!x&&C>0&&(C=C-Math.PI,C>0&&(C=C-Math.PI)),C!==0){I=Math.floor(_*(Math.abs(C)/i));const U=C/I,O=s.angle(s.subtract(M,k.s0[1],k.c)),H=[];for(let Y=1;Y<I;Y++){const W=O+U*Y,K=s.fromAngleRadians(s.create(),W);s.scale(K,K,h),s.add(K,K,k.c),H.push(K)}if(H.length>0){const Y=k.s0[1];let W=w.findIndex(K=>s.equals(Y,K));W=(W+1)%w.length,w.splice(W,0,...H)}}else{const U=k.s1[0],O=w.findIndex(H=>s.equals(U,H));w.splice(O,1)}})}return w};e.exports=c}}),Tgn=gt({"node_modules/@jscad/modeling/src/operations/expansions/expandGeom2.js"(n,e){var t=Ga(),i=KH(),r=(o,s)=>{const a={delta:1,corners:"edge",segments:16},{delta:c,corners:l,segments:u}=Object.assign({},a,o);if(!(l==="edge"||l==="chamfer"||l==="round"))throw new Error('corners must be "edge", "chamfer", or "round"');const p=t.toOutlines(s).map(m=>(o={delta:c,corners:l,closed:!0,segments:u},i(o,m))).reduce((m,_)=>m.concat(t.toSides(t.fromPoints(_))),[]);return t.create(p)};e.exports=r}}),Mgn=gt({"node_modules/@jscad/modeling/src/operations/expansions/extrudePolygon.js"(n,e){var t=kf(),i=Wo(),r=Ya(),o=Gl(),s=(a,c)=>{i.dot(o.plane(c),a)>0&&(c=o.invert(c));const u=[c],d=o.transform(t.fromTranslation(t.create(),a),c),h=c.vertices.length;for(let p=0;p<h;p++){const m=p<h-1?p+1:0,_=o.create([c.vertices[p],d.vertices[p],d.vertices[m],c.vertices[m]]);u.push(_)}return u.push(o.invert(d)),r.create(u)};e.exports=s}}),Cgn=gt({"node_modules/@jscad/modeling/src/operations/expansions/expandShell.js"(n,e){var{EPS:t,TAU:i}=fu(),r=kf(),o=Wo(),s=ZQe(),a=Ya(),c=Gl(),l=VQe(),u=e8(),d=tJe(),h=Mgn(),p=(x,b,w)=>{const E=b.toString();if(x.has(E))x.get(E)[1].push(w);else{const N=[b,[w]];x.set(E,N)}},m=(x,b,w)=>{const E=b[0].toString(),N=b[1].toString(),A=E<N?`${E},${N}`:`${N},${E}`;if(x.has(A))x.get(A)[1].push(w);else{const I=[b,[w]];x.set(A,I)}},_=(x,b)=>{x.findIndex(E=>E===b)<0&&x.push(b)},g=(x,b)=>{const w={delta:1,segments:12},{delta:E,segments:N}=Object.assign({},w,x);let A=a.create();const I=new Map,M=new Map,k=o.create(),C=o.create();return a.toPolygons(b).forEach((O,H)=>{const Y=o.scale(o.create(),c.plane(O),2*E),W=c.transform(r.fromTranslation(r.create(),o.scale(o.create(),Y,-.5)),O),K=h(Y,W);A=d(A,K);const J=O.vertices;for(let se=0;se<J.length;se++){p(I,J[se],c.plane(O));const de=(se+1)%J.length,ve=[J[se],J[de]];m(M,ve,c.plane(O))}}),M.forEach(O=>{const H=O[0],Y=O[1],W=H[0],K=H[1],J=o.subtract(o.create(),K,W);o.normalize(J,J);const se=Y[0],de=o.cross(o.create(),se,J);let ve=[];for(let Re=0;Re<N;Re++)_(ve,Re*i/N);for(let Re=0,oe=Y.length;Re<oe;Re++){const Ee=Y[Re],be=o.dot(de,Ee),Ge=o.dot(se,Ee);let nt=Math.atan2(be,Ge);nt<0&&(nt+=i),_(ve,nt),nt=Math.atan2(-be,-Ge),nt<0&&(nt+=i),_(ve,nt)}ve=ve.sort(s);const re=ve.length;let ue,me;const Me=[],ke=[],ze=[];for(let Re=-1;Re<re;Re++){const oe=ve[Re<0?Re+re:Re],Ee=Math.sin(oe),be=Math.cos(oe);o.scale(k,se,be*E),o.scale(C,de,Ee*E),o.add(k,k,C);const Ge=o.add(o.create(),W,k),nt=o.add(o.create(),K,k);let ct=!1;if(Re>=0&&o.distance(Ge,ue)<t&&(ct=!0),!ct){if(Re>=0){Me.push(Ge),ke.push(nt);const Te=[me,nt,Ge,ue],Qe=c.create(Te);ze.push(Qe)}ue=Ge,me=nt}}ke.reverse(),ze.push(c.create(Me)),ze.push(c.create(ke));const Be=a.create(ze);A=d(A,Be)}),I.forEach(O=>{const H=O[0],Y=O[1],W=Y[0];let K=null,J=0;for(let re=1;re<Y.length;re++){const ue=Y[re],me=o.cross(k,W,ue),Me=o.length(me);Me>.05&&Me>J&&(J=Me,K=ue)}K||(K=o.orthogonal(k,W));const se=o.cross(k,W,K);o.normalize(se,se);const de=o.cross(C,se,W),ve=l({center:[H[0],H[1],H[2]],radius:E,segments:N,axes:[W,se,de]});A=d(A,ve)}),u(A)};e.exports=g}}),Agn=gt({"node_modules/@jscad/modeling/src/operations/expansions/expandGeom3.js"(n,e){var t=Ya(),i=nye(),r=Cgn(),o=(s,a)=>{const c={delta:1,corners:"round",segments:12},{delta:l,corners:u,segments:d}=Object.assign({},c,s);if(u!=="round")throw new Error('corners must be "round" for 3D geometries');if(t.toPolygons(a).length===0)throw new Error("the given geometry cannot be empty");s={delta:l,corners:u,segments:d};const p=r(s,a);return i(a,p)};e.exports=o}}),Pgn=gt({"node_modules/@jscad/modeling/src/operations/expansions/expandPath2.js"(n,e){var t=qH(),i=wc(),r=Ga(),o=Wp(),s=KH(),a=u=>{let{external:d,internal:h}=u;t(d)<0?d=d.reverse():h=h.reverse();const p=o.fromPoints({closed:!0},d),m=o.fromPoints({closed:!0},h),_=r.toSides(r.fromPoints(o.toPoints(p))),g=r.toSides(r.fromPoints(o.toPoints(m)));return _.push(...g),r.create(_)},c=(u,d,h,p)=>{const{points:m,external:_,internal:g}=u,x=Math.floor(d/2),b=[],w=[];if(h==="round"&&x>0){const N=Math.PI/x,A=m[m.length-1],I=i.angle(i.subtract(i.create(),_[_.length-1],A)),M=m[0],k=i.angle(i.subtract(i.create(),g[0],M));for(let C=1;C<x;C++){let U=I+N*C,O=i.fromAngleRadians(i.create(),U);i.scale(O,O,p),i.add(O,O,A),b.push(O),U=k+N*C,O=i.fromAngleRadians(i.create(),U),i.scale(O,O,p),i.add(O,O,M),w.push(O)}}const E=[];return E.push(..._,...b,...g.reverse(),...w),r.fromPoints(E)},l=(u,d)=>{u=Object.assign({},{delta:1,corners:"edge",segments:16},u);const{delta:p,corners:m,segments:_}=u;if(p<=0)throw new Error("the given delta must be positive for paths");if(!(m==="edge"||m==="chamfer"||m==="round"))throw new Error('corners must be "edge", "chamfer", or "round"');const g=d.isClosed,x=o.toPoints(d);if(x.length===0)throw new Error("the given geometry cannot be empty");const b={points:x,external:s({delta:p,corners:m,segments:_,closed:g},x),internal:s({delta:-p,corners:m,segments:_,closed:g},x)};return d.isClosed?a(b):c(b,_,m,p)};e.exports=l}}),iye=gt({"node_modules/@jscad/modeling/src/operations/expansions/expand.js"(n,e){var t=Ra(),i=Ga(),r=Ya(),o=Wp(),s=Tgn(),a=Agn(),c=Pgn(),l=(u,...d)=>{if(d=t(d),d.length===0)throw new Error("wrong number of arguments");const h=d.map(p=>o.isA(p)?c(u,p):i.isA(p)?s(u,p):r.isA(p)?a(u,p):p);return h.length===1?h[0]:h};e.exports=l}}),Rgn=gt({"node_modules/@jscad/modeling/src/operations/expansions/offsetGeom2.js"(n,e){var t=Ga(),i=B_e(),r=KH(),o=(s,a)=>{const c={delta:1,corners:"edge",segments:0},{delta:l,corners:u,segments:d}=Object.assign({},c,s);if(!(u==="edge"||u==="chamfer"||u==="round"))throw new Error('corners must be "edge", "chamfer", or "round"');const h=t.toOutlines(a),m=h.map(_=>(s={delta:h.reduce((b,w)=>b+i.arePointsInside(_,i.create(w)),0)%2===0?l:-l,corners:u,closed:!0,segments:d},r(s,_))).reduce((_,g)=>_.concat(t.toSides(t.fromPoints(g))),[]);return t.create(m)};e.exports=o}}),Ign=gt({"node_modules/@jscad/modeling/src/operations/expansions/offsetPath2.js"(n,e){var t=Wp(),i=KH(),r=(o,s)=>{const a={delta:1,corners:"edge",closed:s.isClosed,segments:16},{delta:c,corners:l,closed:u,segments:d}=Object.assign({},a,o);if(!(l==="edge"||l==="chamfer"||l==="round"))throw new Error('corners must be "edge", "chamfer", or "round"');o={delta:c,corners:l,closed:u,segments:d};const h=i(o,t.toPoints(s));return t.fromPoints({closed:u},h)};e.exports=r}}),Ngn=gt({"node_modules/@jscad/modeling/src/operations/expansions/offset.js"(n,e){var t=Ra(),i=Ga(),r=Wp(),o=Rgn(),s=Ign(),a=(c,...l)=>{if(l=t(l),l.length===0)throw new Error("wrong number of arguments");const u=l.map(d=>r.isA(d)?s(c,d):i.isA(d)?o(c,d):d);return u.length===1?u[0]:u};e.exports=a}}),n8=gt({"node_modules/@jscad/modeling/src/operations/expansions/index.js"(n,e){e.exports={expand:iye(),offset:Ngn()}}}),ZH=gt({"node_modules/@jscad/modeling/src/operations/extrusions/extrudeLinearGeom2.js"(n,e){var t=kf(),i=Wo(),r=Ga(),o=KR(),s=WH(),a=(c,l)=>{const u={offset:[0,0,1],twistAngle:0,twistSteps:12,repair:!0};let{offset:d,twistAngle:h,twistSteps:p,repair:m}=Object.assign({},u,c);if(p<1)throw new Error("twistSteps must be 1 or more");h===0&&(p=1);const _=i.clone(d),g=r.toSides(l);if(g.length===0)throw new Error("the given geometry cannot be empty");const x=o.fromSides(g);_[2]<0&&o.reverse(x,x);const b=t.create(),w=(E,N,A)=>{const I=N/p*h,M=i.scale(i.create(),_,N/p);return t.multiply(b,t.fromZRotation(b,I),t.fromTranslation(t.create(),M)),o.transform(b,A)};return c={numberOfSlices:p+1,capStart:!0,capEnd:!0,repair:m,callback:w},s(c,x)};e.exports=a}}),kgn=gt({"node_modules/@jscad/modeling/src/operations/extrusions/extrudeLinearPath2.js"(n,e){var t=Ga(),i=Wp(),r=ZH(),o=(s,a)=>{if(!a.isClosed)throw new Error("extruded path must be closed");const c=i.toPoints(a),l=t.fromPoints(c);return r(s,l)};e.exports=o}}),Ogn=gt({"node_modules/@jscad/modeling/src/operations/extrusions/extrudeLinear.js"(n,e){var t=Ra(),i=Ga(),r=Wp(),o=ZH(),s=kgn(),a=(c,...l)=>{const u={height:1,twistAngle:0,twistSteps:1,repair:!0},{height:d,twistAngle:h,twistSteps:p,repair:m}=Object.assign({},u,c);if(l=t(l),l.length===0)throw new Error("wrong number of arguments");c={offset:[0,0,d],twistAngle:h,twistSteps:p,repair:m};const _=l.map(g=>r.isA(g)?s(c,g):i.isA(g)?o(c,g):g);return _.length===1?_[0]:_};e.exports=a}}),Lgn=gt({"node_modules/@jscad/modeling/src/operations/extrusions/extrudeRectangularPath2.js"(n,e){var t=Wp(),i=iye(),r=ZH(),o=(s,a)=>{const c={size:1,height:1},{size:l,height:u}=Object.assign({},c,s);if(s.delta=l,s.offset=[0,0,u],t.toPoints(a).length===0)throw new Error("the given geometry cannot be empty");const h=i(s,a);return r(s,h)};e.exports=o}}),Dgn=gt({"node_modules/@jscad/modeling/src/operations/extrusions/extrudeRectangularGeom2.js"(n,e){var{area:t}=W6(),i=Ga(),r=Wp(),o=iye(),s=ZH(),a=(c,l)=>{const u={size:1,height:1},{size:d,height:h}=Object.assign({},u,c);c.delta=d,c.offset=[0,0,h];const p=i.toOutlines(l);if(p.length===0)throw new Error("the given geometry cannot be empty");const _=p.map(x=>(t(x)<0&&x.reverse(),o(c,r.fromPoints({closed:!0},x)))).reduce((x,b)=>x.concat(i.toSides(b)),[]),g=i.create(_);return s(c,g)};e.exports=a}}),zgn=gt({"node_modules/@jscad/modeling/src/operations/extrusions/extrudeRectangular.js"(n,e){var t=Ra(),i=Ga(),r=Wp(),o=Lgn(),s=Dgn(),a=(c,...l)=>{const u={size:1,height:1},{size:d,height:h}=Object.assign({},u,c);if(l=t(l),l.length===0)throw new Error("wrong number of arguments");if(d<=0)throw new Error("size must be positive");if(h<=0)throw new Error("height must be positive");const p=l.map(m=>r.isA(m)?o(c,m):i.isA(m)?s(c,m):m);return p.length===1?p[0]:p};e.exports=a}}),$gn=gt({"node_modules/@jscad/modeling/src/operations/extrusions/extrudeHelical.js"(n,e){var{TAU:t}=fu(),i=KR(),r=kf(),o=WH(),s=Ga(),a=(c,l)=>{const u={angle:t,startAngle:0,pitch:10,endOffset:0,segmentsPerRotation:32},{angle:d,endOffset:h,segmentsPerRotation:p,startAngle:m}=Object.assign({},u,c);let _;if(!c.pitch&&c.height?_=c.height/(d/t):_=c.pitch?c.pitch:u.pitch,p<3)throw new Error("The number of segments per rotation needs to be at least 3.");const x=s.toSides(l);if(x.length===0)throw new Error("the given geometry cannot be empty");const b=x.filter(k=>k[0][0]>=0);let w=i.fromSides(x);b.length===0&&(w=i.reverse(w));const E=Math.round(p/t*Math.abs(d)),N=E>=2?E:2,A=r.create();let I;const M=(k,C,U)=>{const O=m+d/N*C,H=h/N*C,Y=(O-m)/t*_;return r.multiply(A,r.fromTranslation(r.create(),[H,0,Y*Math.sign(d)]),r.fromXRotation(r.create(),-t/4*Math.sign(d))),I=r.create(),r.multiply(I,r.fromZRotation(r.create(),O),A),i.transform(I,U)};return o({numberOfSlices:N+1,callback:M},w)};e.exports=a}}),Fgn=gt({"node_modules/@jscad/modeling/src/operations/extrusions/project.js"(n,e){var t=Ra(),i=G_e(),r=iT(),o=kf(),s=Ga(),a=Ya(),c=Gl(),l=UM(),u=iJe(),d=(p,m)=>{const _=r.fromNormalAndPoint(r.create(),p.axis,p.origin);if(Number.isNaN(_[0])||Number.isNaN(_[1])||Number.isNaN(_[2])||Number.isNaN(_[3]))throw new Error("project: invalid axis or origin");const g=l(m),x=g*g*Math.sqrt(3)/4;if(g===0)return s.create();const b=a.toPolygons(m);let w=[];for(let N=0;N<b.length;N++){const A=b[N].vertices.map(k=>r.projectionOfPoint(_,k)),I=c.create(A),M=c.plane(I);i(_,M)&&(c.measureArea(I)<x||w.push(I))}if(!i(_,[0,0,1])){const N=o.fromVectorRotation(o.create(),_,[0,0,1]);w=w.map(A=>c.transform(N,A))}w=w.sort((N,A)=>c.measureArea(A)-c.measureArea(N));const E=w.map(N=>s.fromPoints(N.vertices));return u(E)},h=(p,...m)=>{const _={axis:[0,0,1],origin:[0,0,0]},{axis:g,origin:x}=Object.assign({},_,p);if(m=t(m),m.length===0)throw new Error("wrong number of arguments");p={axis:g,origin:x};const b=m.map(w=>a.isA(w)?d(p,w):w);return b.length===1?b[0]:b};e.exports=h}}),c4=gt({"node_modules/@jscad/modeling/src/operations/extrusions/index.js"(n,e){e.exports={extrudeFromSlices:WH(),extrudeLinear:Ogn(),extrudeRectangular:zgn(),extrudeRotate:XQe(),extrudeHelical:$gn(),project:Fgn(),slice:KR()}}}),rye=gt({"node_modules/@jscad/modeling/src/operations/hulls/hullPoints2.js"(n,e){var t=wc(),i=s=>{let a=t.fromValues(1/0,1/0);s.forEach(u=>{(u[1]<a[1]||u[1]===a[1]&&u[0]<a[0])&&(a=u)});const c=[];s.forEach(u=>{const d=o(u[1]-a[1],u[0]-a[0]),h=t.squaredDistance(u,a);c.push({point:u,angle:d,distSq:h})}),c.sort((u,d)=>u.angle!==d.angle?u.angle-d.angle:u.distSq-d.distSq);const l=[];return c.forEach(u=>{let d=l.length;for(;d>1&&r(l[d-2],l[d-1],u.point)<=Number.EPSILON;)l.pop(),d=l.length;l.push(u.point)}),l},r=(s,a,c)=>(a[0]-s[0])*(c[1]-s[1])-(a[1]-s[1])*(c[0]-s[0]),o=(s,a)=>s===0&&a===0?-1/0:-a/s;e.exports=i}}),oye=gt({"node_modules/@jscad/modeling/src/operations/hulls/toUniquePoints.js"(n,e){var t=Ga(),i=Ya(),r=Wp(),o=s=>{const a=new Set,c=[],l=u=>{const d=u.toString();a.has(d)||(c.push(u),a.add(d))};return s.forEach(u=>{t.isA(u)?t.toPoints(u).forEach(l):i.isA(u)?i.toPoints(u).forEach(d=>d.forEach(l)):r.isA(u)&&r.toPoints(u).forEach(l)}),c};e.exports=o}}),Ugn=gt({"node_modules/@jscad/modeling/src/operations/hulls/hullPath2.js"(n,e){var t=Ra(),i=Wp(),r=rye(),o=oye(),s=(...a)=>{a=t(a);const c=o(a),l=r(c);return i.fromPoints({closed:!0},l)};e.exports=s}}),Bgn=gt({"node_modules/@jscad/modeling/src/operations/hulls/hullGeom2.js"(n,e){var t=Ra(),i=Ga(),r=rye(),o=oye(),s=(...a)=>{a=t(a);const c=o(a),l=r(c);return l.length<3?i.create():i.fromPoints(l)};e.exports=s}}),rJe=gt({"node_modules/@jscad/modeling/src/operations/hulls/hullPoints3.js"(n,e){var t=Gl(),i=iQe(),r=o=>i(o,{skipTriangulation:!0}).map(c=>{const l=c.map(u=>o[u]);return t.create(l)});e.exports=r}}),jgn=gt({"node_modules/@jscad/modeling/src/operations/hulls/hullGeom3.js"(n,e){var t=Ra(),i=Ya(),r=oye(),o=rJe(),s=(...a)=>{a=t(a);const c=r(a);return c.length===0?i.create():i.create(o(c))};e.exports=s}}),oJe=gt({"node_modules/@jscad/modeling/src/operations/hulls/hull.js"(n,e){var t=Ra(),i=J6(),r=Ga(),o=Ya(),s=Wp(),a=Ugn(),c=Bgn(),l=jgn(),u=(...d)=>{if(d=t(d),d.length===0)throw new Error("wrong number of arguments");if(!i(d))throw new Error("only hulls of the same type are supported");const h=d[0];return s.isA(h)?a(d):r.isA(h)?c(d):o.isA(h)?l(d):h};e.exports=u}}),Hgn=gt({"node_modules/@jscad/modeling/src/operations/hulls/hullChain.js"(n,e){var t=Ra(),i=nye(),r=oJe(),o=(...s)=>{if(s=t(s),s.length<2)throw new Error("wrong number of arguments");const a=[];for(let c=1;c<s.length;c++)a.push(r(s[c-1],s[c]));return i(a)};e.exports=o}}),Vgn=gt({"node_modules/@jscad/modeling/src/operations/hulls/index.js"(n,e){e.exports={hull:oJe(),hullChain:Hgn(),hullPoints2:rye(),hullPoints3:rJe()}}}),sJe=gt({"node_modules/@jscad/modeling/src/operations/modifiers/snapPolygons.js"(n,e){var t=Wo(),i=Gl(),r=(s,a)=>{const c=Math.abs(i.measureArea(a));return Number.isFinite(c)&&c>s},o=(s,a)=>{let c=a.map(u=>{const d=u.vertices.map(m=>t.snap(t.create(),m,s)),h=[];for(let m=0;m<d.length;m++){const _=(m+1)%d.length;t.equals(d[m],d[_])||h.push(d[m])}const p=i.create(h);return u.color&&(p.color=u.color),p});const l=s*s*Math.sqrt(3)/4;return c=c.filter(u=>r(l,u)),c};e.exports=o}}),Ggn=gt({"node_modules/@jscad/modeling/src/operations/modifiers/mergePolygons.js"(n,e){var t=G_e(),i=Wo(),r=Gl(),o=x=>{const b=r.toPoints(x),w=[];for(let E=0;E<b.length;E++){const N=(E+1)%b.length,A={v1:b[E],v2:b[N]};w.push(A)}for(let E=0;E<w.length;E++){const N=(E+1)%b.length;w[E].next=w[N],w[N].prev=w[E]}return w},s=(x,b)=>{const w=`${b.v1}:${b.v2}`;x.set(w,b)},a=(x,b)=>{const w=`${b.v1}:${b.v2}`;x.delete(w)},c=(x,b)=>{const w=`${b.v2}:${b.v1}`;return x.get(w)},l=(x,b,w)=>{let E=x.prev.v1,N=x.prev.v2,A=b.next.v2;const I=h(E,N,A,w);E=b.prev.v1,N=b.prev.v2,A=x.next.v2;const M=h(E,N,A,w);return[I,M]},u=i.create(),d=i.create(),h=(x,b,w,E)=>{const N=i.subtract(u,b,x),A=i.subtract(d,w,b);return i.cross(N,N,A),i.dot(N,E)},p=x=>{let b;const w=[];for(;x.next;){const E=x.next;w.push(x.v1),x.v1=null,x.v2=null,x.next=null,x.prev=null,x=E}return w.length>0&&(b=r.create(w)),b},m=x=>{if(x.length<2)return x;const b=x[0].plane,w=x.slice(),E=new Map;for(;w.length>0;){const A=w.shift(),I=o(A);for(let M=0;M<I.length;M++){const k=I[M],C=c(E,k);if(C){const U=l(k,C,b);if(U[0]>=0&&U[1]>=0){const O=C.next,H=k.next;k.prev.next=C.next,k.next.prev=C.prev,C.prev.next=k.next,C.next.prev=k.prev,k.v1=null,k.v2=null,k.next=null,k.prev=null,a(E,C),C.v1=null,C.v2=null,C.next=null,C.prev=null;const Y=(W,K,J)=>{const se={v1:J.v1,v2:K.v2,next:K.next,prev:J.prev};J.prev.next=se,K.next.prev=se,a(W,K),K.v1=null,K.v2=null,K.next=null,K.prev=null,a(W,J),J.v1=null,J.v2=null,J.next=null,J.prev=null};U[0]===0&&Y(E,O,O.prev),U[1]===0&&Y(E,H,H.prev)}}else k.next&&s(E,k)}}const N=[];return E.forEach(A=>{const I=p(A);I&&N.push(I)}),E.clear(),N},_=(x,b)=>Math.abs(x[3]-b[3])<15e-8?t(x,b):!1,g=(x,b)=>{const w=[];b.forEach(N=>{const A=w.find(I=>_(I[0],r.plane(N)));A?A[1].push(N):w.push([r.plane(N),[N]])});let E=[];return w.forEach(N=>{const A=N[1],I=m(A);E=E.concat(I)}),E};e.exports=g}}),Ygn=gt({"node_modules/@jscad/modeling/src/operations/modifiers/insertTjunctions.js"(n,e){var t=fu(),i=Wo(),r=Gl(),o=l=>`${l}`,s=(l,u,d,h,p,m)=>{const _=o(h),g=o(p),x=`${_}/${g}`,b=`${g}/${_}`;if(l.has(b))return a(l,u,d,p,h,null),null;const w={vertex0:h,vertex1:p,polygonindex:m};return l.has(x)?l.get(x).push(w):l.set(x,[w]),u.has(_)?u.get(_).push(x):u.set(_,[x]),d.has(g)?d.get(g).push(x):d.set(g,[x]),x},a=(l,u,d,h,p,m)=>{const _=o(h),g=o(p),x=`${_}/${g}`;let b=-1;const w=l.get(x);for(let E=0;E<w.length;E++){const N=w[E];let A=o(N.vertex0);if(A===_&&(A=o(N.vertex1),A===g&&!(m!==null&&N.polygonindex!==m))){b=E;break}}w.splice(b,1),w.length===0&&l.delete(x),b=u.get(_).indexOf(x),u.get(_).splice(b,1),u.get(_).length===0&&u.delete(_),b=d.get(g).indexOf(x),d.get(g).splice(b,1),d.get(g).length===0&&d.delete(g)},c=l=>{const u=new Map;for(let d=0;d<l.length;d++){const h=l[d],p=h.vertices.length;if(p>=3){let m=h.vertices[0],_=o(m);for(let g=0;g<p;g++){let x=g+1;x===p&&(x=0);const b=h.vertices[x],w=o(b),E=`${_}/${w}`,N=`${w}/${_}`;if(u.has(N)){const A=u.get(N);A.splice(-1,1),A.length===0&&u.delete(N)}else{const A={vertex0:m,vertex1:b,polygonindex:d};u.has(E)?u.get(E).push(A):u.set(E,[A])}m=b,_=w}}else console.warn("warning: invalid polygon found during insertTjunctions")}if(u.size>0){const d=new Map,h=new Map,p=new Map;for(const[_,g]of u)p.set(_,!0),g.forEach(x=>{const b=o(x.vertex0),w=o(x.vertex1);d.has(b)?d.get(b).push(_):d.set(b,[_]),h.has(w)?h.get(w).push(_):h.set(w,[_])});const m=l.slice(0);for(;u.size!==0;){for(const g of u.keys())p.set(g,!0);let _=!1;for(;;){const g=Array.from(p.keys());if(g.length===0)break;const x=g[0];let b=!0;if(u.has(x)){const E=u.get(x)[0];for(let N=0;N<2;N++){const A=N===0?E.vertex0:E.vertex1,I=N===0?E.vertex1:E.vertex0,M=o(A),k=o(I);let C=[];N===0?h.has(M)&&(C=h.get(M)):d.has(M)&&(C=d.get(M));for(let U=0;U<C.length;U++){const O=C[U],H=u.get(O)[0],Y=N===0?H.vertex0:H.vertex1;if(N===0?H.vertex1:H.vertex0,o(Y)===k){a(u,d,h,A,I,null),a(u,d,h,I,A,null),b=!1,N=2,_=!0;break}else{const K=A,J=I,se=Y,de=i.subtract(i.create(),se,K),ve=i.dot(i.subtract(i.create(),J,K),de)/i.dot(de,de);if(ve>0&&ve<1){const re=i.scale(i.create(),de,ve);if(i.add(re,re,K),i.squaredDistance(re,J)<t.EPS*t.EPS){const me=H.polygonindex,Me=m[me],ke=o(H.vertex1);let ze=-1;for(let be=0;be<Me.vertices.length;be++)if(o(Me.vertices[be])===ke){ze=be;break}const Be=Me.vertices.slice(0);Be.splice(ze,0,I);const Re=r.create(Be);m[me]=Re,a(u,d,h,H.vertex0,H.vertex1,me);const oe=s(u,d,h,H.vertex0,I,me),Ee=s(u,d,h,I,H.vertex1,me);oe!==null&&p.set(oe,!0),Ee!==null&&p.set(Ee,!0),b=!1,N=2,_=!0;break}}}}}}b&&p.delete(x)}if(!_)break}l=m}return u.clear(),l};e.exports=c}}),qgn=gt({"node_modules/@jscad/modeling/src/operations/modifiers/triangulatePolygons.js"(n,e){var t=Wo(),i=Gl(),r=(s,a,c)=>{const l=a.vertices.length;if(l>3){if(l>4){const h=[0,0,0];a.vertices.forEach(p=>t.add(h,h,p)),t.snap(h,t.divide(h,h,[l,l,l]),s);for(let p=0;p<l;p++){const m=i.create([h,a.vertices[p],a.vertices[(p+1)%l]]);a.color&&(m.color=a.color),c.push(m)}return}const u=i.create([a.vertices[0],a.vertices[1],a.vertices[2]]),d=i.create([a.vertices[0],a.vertices[2],a.vertices[3]]);a.color&&(u.color=a.color,d.color=a.color),c.push(u,d);return}c.push(a)},o=(s,a)=>{const c=[];return a.forEach(l=>{r(s,l,c)}),c};e.exports=o}}),Xgn=gt({"node_modules/@jscad/modeling/src/operations/modifiers/generalize.js"(n,e){var t=Ra(),i=UM(),r=Ga(),o=Ya(),s=Wp(),a=sJe(),c=Ggn(),l=Ygn(),u=qgn(),d=(_,g)=>g,h=(_,g)=>g,p=(_,g)=>{const x={snap:!1,simplify:!1,triangulate:!1},{snap:b,simplify:w,triangulate:E}=Object.assign({},x,_),N=i(g);let A=o.toPolygons(g);b&&(A=a(N,A)),w&&(A=c(N,A)),E&&(A=l(A),A=u(N,A));const I=Object.assign({},g);return I.polygons=A,I},m=(_,...g)=>{if(g=t(g),g.length===0)throw new Error("wrong number of arguments");const x=g.map(b=>{if(s.isA(b))return d(_,b);if(r.isA(b))return h(_,b);if(o.isA(b))return p(_,b);throw new Error("invalid geometry")});return x.length===1?x[0]:x};e.exports=m}}),Wgn=gt({"node_modules/@jscad/modeling/src/operations/modifiers/snap.js"(n,e){var t=Ra(),i=wc(),r=Ga(),o=Ya(),s=Wp(),a=UM(),c=sJe(),l=p=>{const m=a(p),g=s.toPoints(p).map(x=>i.snap(i.create(),x,m));return s.create(g)},u=p=>{const m=a(p);let g=r.toSides(p).map(x=>[i.snap(i.create(),x[0],m),i.snap(i.create(),x[1],m)]);return g=g.filter(x=>!i.equals(x[0],x[1])),r.create(g)},d=p=>{const m=a(p),_=o.toPolygons(p),g=c(m,_);return o.create(g)},h=(...p)=>{if(p=t(p),p.length===0)throw new Error("wrong number of arguments");const m=p.map(_=>s.isA(_)?l(_):r.isA(_)?u(_):o.isA(_)?d(_):_);return m.length===1?m[0]:m};e.exports=h}}),Kgn=gt({"node_modules/@jscad/modeling/src/operations/modifiers/index.js"(n,e){e.exports={generalize:Xgn(),snap:Wgn(),retessellate:e8()}}}),Zgn=gt({"node_modules/@jscad/modeling/src/utils/padArrayToLength.js"(n,e){var t=(i,r,o)=>{for(i=i.slice();i.length<o;)i.push(r);return i};e.exports=t}}),Qgn=gt({"node_modules/@jscad/modeling/src/operations/transforms/align.js"(n,e){var t=Ra(),i=Zgn(),r=q_e(),{translate:o}=a4(),s=u=>{if(!Array.isArray(u.modes)||u.modes.length>3)throw new Error("align(): modes must be an array of length <= 3");if(u.modes=i(u.modes,"none",3),u.modes.filter(d=>["center","max","min","none"].includes(d)).length!==3)throw new Error('align(): all modes must be one of "center", "max" or "min"');if(!Array.isArray(u.relativeTo)||u.relativeTo.length>3)throw new Error("align(): relativeTo must be an array of length <= 3");if(u.relativeTo=i(u.relativeTo,0,3),u.relativeTo.filter(d=>Number.isFinite(d)||d==null).length!==3)throw new Error("align(): all relativeTo values must be a number, or null.");if(typeof u.grouped!="boolean")throw new Error("align(): grouped must be a boolean value.");return u},a=(u,d,h)=>{for(let p=0;p<3;p++)u[p]==null&&(d[p]==="center"?u[p]=(h[0][p]+h[1][p])/2:d[p]==="max"?u[p]=h[1][p]:d[p]==="min"&&(u[p]=h[0][p]));return u},c=(u,d,h)=>{const p=r(u),m=[0,0,0];for(let _=0;_<3;_++)d[_]==="center"?m[_]=h[_]-(p[0][_]+p[1][_])/2:d[_]==="max"?m[_]=h[_]-p[1][_]:d[_]==="min"&&(m[_]=h[_]-p[0][_]);return o(m,u)},l=(u,...d)=>{u=Object.assign({},{modes:["center","center","min"],relativeTo:[0,0,0],grouped:!1},u),u=s(u);let{modes:p,relativeTo:m,grouped:_}=u;if(d=t(d),d.length===0)throw new Error("align(): No geometries were provided to act upon");if(m.filter(g=>g==null).length){const g=r(d);m=a(m,p,g)}return _?d=c(d,p,m):d=d.map(g=>c(g,p,m)),d.length===1?d[0]:d};e.exports=l}}),QH=gt({"node_modules/@jscad/modeling/src/operations/transforms/center.js"(n,e){var t=Ra(),i=Ga(),r=Ya(),o=Wp(),s=o4(),{translate:a}=a4(),c=(p,m)=>{const _={axes:[!0,!0,!0],relativeTo:[0,0,0]},{axes:g,relativeTo:x}=Object.assign({},_,p),b=s(m),w=[0,0,0];return g[0]&&(w[0]=x[0]-(b[0][0]+(b[1][0]-b[0][0])/2)),g[1]&&(w[1]=x[1]-(b[0][1]+(b[1][1]-b[0][1])/2)),g[2]&&(w[2]=x[2]-(b[0][2]+(b[1][2]-b[0][2])/2)),a(w,m)},l=(p,...m)=>{const _={axes:[!0,!0,!0],relativeTo:[0,0,0]},{axes:g,relativeTo:x}=Object.assign({},_,p);if(m=t(m),m.length===0)throw new Error("wrong number of arguments");if(x.length!==3)throw new Error("relativeTo must be an array of length 3");p={axes:g,relativeTo:x};const b=m.map(w=>o.isA(w)||i.isA(w)||r.isA(w)?c(p,w):w);return b.length===1?b[0]:b},u=(...p)=>l({axes:[!0,!1,!1]},p),d=(...p)=>l({axes:[!1,!0,!1]},p),h=(...p)=>l({axes:[!1,!1,!0]},p);e.exports={center:l,centerX:u,centerY:d,centerZ:h}}}),JH=gt({"node_modules/@jscad/modeling/src/operations/transforms/scale.js"(n,e){var t=Ra(),i=kf(),r=Ga(),o=Ya(),s=Wp(),a=(d,...h)=>{if(!Array.isArray(d))throw new Error("factors must be an array");if(h=t(h),h.length===0)throw new Error("wrong number of arguments");for(d=d.slice();d.length<3;)d.push(1);if(d[0]<=0||d[1]<=0||d[2]<=0)throw new Error("factors must be positive");const p=i.fromScaling(i.create(),d),m=h.map(_=>s.isA(_)?s.transform(p,_):r.isA(_)?r.transform(p,_):o.isA(_)?o.transform(p,_):_);return m.length===1?m[0]:m},c=(d,...h)=>a([d,1,1],h),l=(d,...h)=>a([1,d,1],h),u=(d,...h)=>a([1,1,d],h);e.exports={scale:a,scaleX:c,scaleY:l,scaleZ:u}}}),Jgn=gt({"node_modules/@jscad/modeling/src/operations/transforms/transform.js"(n,e){var t=Ra(),i=Ga(),r=Ya(),o=Wp(),s=(a,...c)=>{if(c=t(c),c.length===0)throw new Error("wrong number of arguments");const l=c.map(u=>o.isA(u)?o.transform(a,u):i.isA(u)?i.transform(a,u):r.isA(u)?r.transform(a,u):u);return l.length===1?l[0]:l};e.exports=s}}),l4=gt({"node_modules/@jscad/modeling/src/operations/transforms/index.js"(n,e){e.exports={align:Qgn(),center:QH().center,centerX:QH().centerX,centerY:QH().centerY,centerZ:QH().centerZ,mirror:Z6().mirror,mirrorX:Z6().mirrorX,mirrorY:Z6().mirrorY,mirrorZ:Z6().mirrorZ,rotate:Q6().rotate,rotateX:Q6().rotateX,rotateY:Q6().rotateY,rotateZ:Q6().rotateZ,scale:JH().scale,scaleX:JH().scaleX,scaleY:JH().scaleY,scaleZ:JH().scaleZ,transform:Jgn(),translate:a4().translate,translateX:a4().translateX,translateY:a4().translateY,translateZ:a4().translateZ}}}),eV=gt({"node_modules/@jscad/modeling/src/index.js"(n,e){e.exports={colors:r4(),curves:W_n(),geometries:j_e(),maths:byn(),measurements:Ayn(),primitives:B5(),text:Z_e(),utils:QQe(),booleans:t8(),expansions:n8(),extrusions:c4(),hulls:Vgn(),modifiers:Kgn(),transforms:l4()}}}),exn=gt({"node_modules/ms/index.js"(n,e){var t=1e3,i=t*60,r=i*60,o=r*24,s=o*7,a=o*365.25;e.exports=function(h,p){p=p||{};var m=typeof h;if(m==="string"&&h.length>0)return c(h);if(m==="number"&&isFinite(h))return p.long?u(h):l(h);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(h))};function c(h){if(h=String(h),!(h.length>100)){var p=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(h);if(p){var m=parseFloat(p[1]),_=(p[2]||"ms").toLowerCase();switch(_){case"years":case"year":case"yrs":case"yr":case"y":return m*a;case"weeks":case"week":case"w":return m*s;case"days":case"day":case"d":return m*o;case"hours":case"hour":case"hrs":case"hr":case"h":return m*r;case"minutes":case"minute":case"mins":case"min":case"m":return m*i;case"seconds":case"second":case"secs":case"sec":case"s":return m*t;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return m;default:return}}}}function l(h){var p=Math.abs(h);return p>=o?Math.round(h/o)+"d":p>=r?Math.round(h/r)+"h":p>=i?Math.round(h/i)+"m":p>=t?Math.round(h/t)+"s":h+"ms"}function u(h){var p=Math.abs(h);return p>=o?d(h,p,o,"day"):p>=r?d(h,p,r,"hour"):p>=i?d(h,p,i,"minute"):p>=t?d(h,p,t,"second"):h+" ms"}function d(h,p,m,_){var g=p>=m*1.5;return Math.round(h/m)+" "+_+(g?"s":"")}}}),txn=gt({"node_modules/debug/src/common.js"(n,e){function t(i){o.debug=o,o.default=o,o.coerce=d,o.disable=l,o.enable=a,o.enabled=u,o.humanize=exn(),o.destroy=h,Object.keys(i).forEach(p=>{o[p]=i[p]}),o.names=[],o.skips=[],o.formatters={};function r(p){let m=0;for(let _=0;_<p.length;_++)m=(m<<5)-m+p.charCodeAt(_),m|=0;return o.colors[Math.abs(m)%o.colors.length]}o.selectColor=r;function o(p){let m,_=null,g,x;function b(...w){if(!b.enabled)return;const E=b,N=Number(new Date),A=N-(m||N);E.diff=A,E.prev=m,E.curr=N,m=N,w[0]=o.coerce(w[0]),typeof w[0]!="string"&&w.unshift("%O");let I=0;w[0]=w[0].replace(/%([a-zA-Z%])/g,(k,C)=>{if(k==="%%")return"%";I++;const U=o.formatters[C];if(typeof U=="function"){const O=w[I];k=U.call(E,O),w.splice(I,1),I--}return k}),o.formatArgs.call(E,w),(E.log||o.log).apply(E,w)}return b.namespace=p,b.useColors=o.useColors(),b.color=o.selectColor(p),b.extend=s,b.destroy=o.destroy,Object.defineProperty(b,"enabled",{enumerable:!0,configurable:!1,get:()=>_!==null?_:(g!==o.namespaces&&(g=o.namespaces,x=o.enabled(p)),x),set:w=>{_=w}}),typeof o.init=="function"&&o.init(b),b}function s(p,m){const _=o(this.namespace+(typeof m>"u"?":":m)+p);return _.log=this.log,_}function a(p){o.save(p),o.namespaces=p,o.names=[],o.skips=[];const m=(typeof p=="string"?p:"").trim().replace(/\s+/g,",").split(",").filter(Boolean);for(const _ of m)_[0]==="-"?o.skips.push(_.slice(1)):o.names.push(_)}function c(p,m){let _=0,g=0,x=-1,b=0;for(;_<p.length;)if(g<m.length&&(m[g]===p[_]||m[g]==="*"))m[g]==="*"?(x=g,b=_,g++):(_++,g++);else if(x!==-1)g=x+1,b++,_=b;else return!1;for(;g<m.length&&m[g]==="*";)g++;return g===m.length}function l(){const p=[...o.names,...o.skips.map(m=>"-"+m)].join(",");return o.enable(""),p}function u(p){for(const m of o.skips)if(c(p,m))return!1;for(const m of o.names)if(c(p,m))return!0;return!1}function d(p){return p instanceof Error?p.stack||p.message:p}function h(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}return o.enable(o.load()),o}e.exports=t}}),nxn=gt({"node_modules/debug/src/browser.js"(n,e){n.formatArgs=i,n.save=r,n.load=o,n.useColors=t,n.storage=s(),n.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`."))}})(),n.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 t(){if(typeof window<"u"&&window.process&&(window.process.type==="renderer"||window.process.__nwjs))return!0;if(typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;let c;return typeof document<"u"&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window<"u"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator<"u"&&navigator.userAgent&&(c=navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/))&&parseInt(c[1],10)>=31||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}function i(c){if(c[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+c[0]+(this.useColors?"%c ":" ")+"+"+e.exports.humanize(this.diff),!this.useColors)return;const l="color: "+this.color;c.splice(1,0,l,"color: inherit");let u=0,d=0;c[0].replace(/%[a-zA-Z%]/g,h=>{h!=="%%"&&(u++,h==="%c"&&(d=u))}),c.splice(d,0,l)}n.log=console.debug||console.log||(()=>{});function r(c){try{c?n.storage.setItem("debug",c):n.storage.removeItem("debug")}catch{}}function o(){let c;try{c=n.storage.getItem("debug")||n.storage.getItem("DEBUG")}catch{}return!c&&typeof k_e<"u"&&"env"in k_e&&(c=k_e.env.DEBUG),c}function s(){try{return localStorage}catch{}}e.exports=txn()(n);var{formatters:a}=e.exports;a.j=function(c){try{return JSON.stringify(c)}catch(l){return"[UnexpectedJSONParseError]: "+l.message}}}}),aJe=fe.createContext(null),_b=()=>{const n=fe.useContext(aJe);if(!n)throw new Error("useThree must be used within a ThreeProvider");return n},ZR=(n,e=[])=>{const{addFrameListener:t,removeFrameListener:i}=_b();wo.useEffect(()=>(t(n),()=>i(n)),[t,i,...e])},cJe=fe.createContext(null),ixn=()=>{const n=fe.useContext(cJe);if(!n)throw new Error("useHover must be used within a HoverProvider");return n},rxn=({children:n})=>{const{camera:e,renderer:t}=_b(),[i,r]=fe.useState([]),o=fe.useMemo(()=>new B8t,[]),s=fe.useMemo(()=>new zo,[]),a=fe.useRef(i);a.current=i;const c=fe.useRef(null),l=fe.useCallback(m=>{r(_=>[..._,m])},[]),u=fe.useCallback(m=>{if(c.current){let _=!1,g=c.current.object;for(;g;){if(g===m){_=!0;break}g=g.parent}_&&(c.current.onUnhover(),c.current=null)}r(_=>_.filter(g=>g.object!==m))},[]),d=fe.useCallback(m=>{let _=m;for(;_;){const g=a.current.find(x=>x.object===_);if(g)return g;_=_.parent}},[]),h=fe.useCallback(m=>{if(!t.domElement)return;const _=t.domElement.getBoundingClientRect();s.x=(m.clientX-_.left)/_.width*2-1,s.y=-((m.clientY-_.top)/_.height)*2+1,o.setFromCamera(s,e);const g=a.current.map(b=>b.object);if(g.length===0){c.current&&(c.current.onUnhover(),c.current=null);return}const x=o.intersectObjects(g,!0);if(x.length>0){const b=x[0],w=d(b.object);if(w){const E={mousePosition:[b.point.x,b.point.y,b.point.z]};c.current!==w?(c.current?.onUnhover(),w.onHover(E),c.current=w):w.onHover(E)}else c.current&&(c.current.onUnhover(),c.current=null)}else c.current&&(c.current.onUnhover(),c.current=null)},[e,t,o,s,d]);fe.useEffect(()=>{const m=t.domElement;return m.addEventListener("mousemove",h),()=>{m.removeEventListener("mousemove",h)}},[t,h]);const p=fe.useMemo(()=>({addHoverable:l,removeHoverable:u}),[l,u]);return ce.jsx(cJe.Provider,{value:p,children:n})},oxn=({children:n,object:e,onHover:t,onUnhover:i,isHovered:r})=>{const{addHoverable:o,removeHoverable:s}=ixn();return fe.useEffect(()=>e?(o({object:e,onHover:t,onUnhover:i}),()=>{s(e)}):void 0,[e,t,i,o,s]),ce.jsx(ce.Fragment,{children:n})},i8=oxn;function sxn(n){return n.replace(/(DEF|USE)\s+([^\s]+)/g,(e,t,i)=>`${t} ${i.replace(/-/g,"_")}`)}async function axn(n){const e=await fetch(n);if(!e.ok)throw new Error(`Failed to fetch "${n}": ${e.status} ${e.statusText}`);const t=await e.text();return new QLt().parse(sxn(t),n)}typeof window<"u"&&!window.TSCIRCUIT_OBJ_LOADER_CACHE&&(window.TSCIRCUIT_OBJ_LOADER_CACHE=new Map);function cxn(n){const[e,t]=fe.useState(null);return fe.useEffect(()=>{if(!n)return;const i=n.replace(/&cachebust_origin=$/,""),r=window.TSCIRCUIT_OBJ_LOADER_CACHE;let o=!1;async function s(){try{if(i.endsWith(".wrl"))return await axn(i);const c=await fetch(i);if(!c.ok)throw new Error(`Failed to fetch "${i}": ${c.status} ${c.statusText}`);const l=await c.text(),u=l.match(/newmtl[\s\S]*?endmtl/g),d=new aDt;if(u?.length){const h=u.join(`
5083
- `).replace(/d 0\./g,"d 1."),p=l.replace(/newmtl[\s\S]*?endmtl/g,"").replace(/^mtllib.*/gm,""),m=new WLt;m.setMaterialOptions({invertTrProperty:!0});const _=m.parse(h.replace(/Kd\s+([\d.]+)\s+([\d.]+)\s+([\d.]+)/g,"Kd $2 $2 $2"),"embedded.mtl");return d.setMaterials(_),d.parse(p)}return d.parse(l.replace(/^mtllib.*/gm,""))}catch(c){return c}}function a(){if(r.has(i)){const l=r.get(i);return l.result?Promise.resolve(l.result.clone()):l.promise.then(u=>u instanceof Error?u:u.clone())}const c=s().then(l=>(l instanceof Error||r.set(i,{...r.get(i),result:l}),l));return r.set(i,{promise:c,result:null}),c}return a().then(c=>{o||t(c)}).catch(c=>{console.error(c)}),()=>{o=!0}},[n]),e}function lxn({url:n,position:e,rotation:t,onHover:i,onUnhover:r,isHovered:o,scale:s}){const a=cxn(n),{rootObject:c}=_b(),l=fe.useMemo(()=>a&&!(a instanceof Error)?a:new Ma(new j2(.5,.5,.5),new Gb({transparent:!0,color:"red",opacity:.25})),[a]);if(fe.useEffect(()=>{if(!(!c||!l))return c.add(l),()=>{c.remove(l)}},[c,l]),fe.useEffect(()=>{l&&(e&&(Array.isArray(e)?l.position.fromArray(e):l.position.copy(e)),t&&(Array.isArray(t)?l.rotation.fromArray(t):l.rotation.copy(t)),s!==void 0&&l.scale.setScalar(s))},[l,Array.isArray(e)?e[0]:e?.x,Array.isArray(e)?e[1]:e?.y,Array.isArray(e)?e[2]:e?.z,Array.isArray(t)?t[0]:t?.x,Array.isArray(t)?t[1]:t?.y,Array.isArray(t)?t[2]:t?.z,s]),a instanceof Error)throw a;return ce.jsx(i8,{isHovered:o,onHover:i,onUnhover:r,object:l})}var lJe=new WeakMap,uxn=()=>{const n=new a_;return n.name="fallback-environment-map",n.mapping=r$,n},dxn=n=>{if(!n)return null;const e=n,t=lJe.get(e);if(t)return t;let i;if(n instanceof Zte){const r=new Yte(n);i=r.fromScene(dLt(),.04).texture,r.dispose()}else i=uxn();return lJe.set(e,i),i},uJe=1.25;function hxn({gltfUrl:n,position:e,rotation:t,onHover:i,onUnhover:r,isHovered:o,scale:s}){const{renderer:a,rootObject:c}=_b(),[l,u]=fe.useState(null);return fe.useEffect(()=>{if(!n)return;const d=new pLt;let h=!0;return d.load(n,p=>{h&&u(p.scene)},void 0,p=>{h&&console.error(`An error happened loading ${n}`,p)}),()=>{h=!1}},[n]),fe.useEffect(()=>{l&&(e&&l.position.fromArray(e),t&&l.rotation.fromArray(t),s!==void 0&&l.scale.setScalar(s))},[l,e?.[0],e?.[1],e?.[2],t?.[0],t?.[1],t?.[2],s]),fe.useEffect(()=>{if(!(!c||!l))return c.add(l),()=>{c.remove(l)}},[c,l]),fe.useEffect(()=>{if(!l||!a)return;const d=dxn(a);if(!d)return;const h=[],p=m=>{m instanceof Gb&&(h.push({material:m,envMap:m.envMap??null,envMapIntensity:m.envMapIntensity??1}),m.envMap||(m.envMap=d),(typeof m.envMapIntensity!="number"||m.envMapIntensity<uJe)&&(m.envMapIntensity=uJe),m.needsUpdate=!0)};return l.traverse(m=>{if(!(m instanceof Ma))return;const _=m.material;Array.isArray(_)?_.forEach(p):_&&p(_)}),()=>{h.forEach(({material:m,envMap:_,envMapIntensity:g})=>{m.envMap=_,m.envMapIntensity=g,m.needsUpdate=!0})}},[l,a]),fe.useEffect(()=>{l&&l.traverse(d=>{d instanceof Ma&&d.material instanceof Gb&&(o?(d.material.emissive.setHex(255),d.material.emissiveIntensity=.2):d.material.emissiveIntensity=0)})},[o,l]),l?ce.jsx(i8,{isHovered:o,onHover:i,onUnhover:r,object:l}):null}var pxn=vc($Ze()),fxn=vc(eV()),dJe={in:25.4,inch:25.4,mil:.0254,mm:1,m:1e3,cm:10,ft:304.8,feet:304.8},gh=n=>{let e=typeof n=="number"?"mm":n.replace(/^[^a-zA-Z]+/g,"").toLowerCase();e||(e="mm");const t=typeof n=="number"?n:Number.parseFloat(n.split(e)[0]);if(e in dJe)return t*dJe[e];throw new Error(`Unsupported unit: ${e}`)},r8=gh,hJe={Hz:{baseUnit:"Hz",variants:{MHz:1e6,kHz:1e3,Hz:1}},g:{baseUnit:"g",variants:{kg:1e3,g:1}},Ω:{baseUnit:"Ω",variants:{mΩ:.001,Ω:1,kΩ:1e3,KΩ:1e3,kohm:1e3,MΩ:1e6,GΩ:1e9,TΩ:1e12}},V:{baseUnit:"V",variants:{mV:.001,V:1,kV:1e3,KV:1e3,MV:1e6,GV:1e9,TV:1e12}},A:{baseUnit:"A",variants:{µA:1e-6,mA:.001,ma:.001,A:1,kA:1e3,MA:1e6}},F:{baseUnit:"F",variants:{pF:1e-12,nF:1e-9,µF:1e-6,uF:1e-6,mF:.001,F:1}},ml:{baseUnit:"ml",variants:{ml:1,mL:1,l:1e3,L:1e3}},deg:{baseUnit:"deg",variants:{rad:180/Math.PI}},ms:{baseUnit:"ms",variants:{fs:1e-12,ps:1e-9,ns:1e-6,us:.001,µs:.001,ms:1,s:1e3}},mm:{baseUnit:"mm",variants:{nm:1e-6,µm:.001,um:.001,mm:1,cm:10,dm:100,m:1e3,km:1e6,in:25.4,ft:304.8,IN:25.4,FT:304.8,yd:914.4,mi:1609344,mil:.0254}}},sye=new Set;for(const[n,e]of Object.entries(hJe)){sye.add(n);for(const t of Object.keys(e.variants))sye.add(t)}function mxn(n){for(const[e,t]of Object.entries(hJe))if(n in t.variants)return{baseUnit:t.baseUnit,conversionFactor:t.variants[n]};return{baseUnit:n,conversionFactor:1}}var pJe={tera:1e12,T:1e12,giga:1e9,G:1e9,mega:1e6,M:1e6,kilo:1e3,k:1e3,deci:.1,d:.1,centi:.01,c:.01,milli:.001,m:.001,micro:1e-6,u:1e-6,µ:1e-6,nano:1e-9,n:1e-9,pico:1e-12,p:1e-12};function q2(n){if(n==null)return{parsedUnit:null,unitOfValue:null,value:null};if(typeof n=="string"&&n.match(/^-?[\d\.]+$/))return{value:Number.parseFloat(n),parsedUnit:null,unitOfValue:null};if(typeof n=="number")return{value:n,parsedUnit:null,unitOfValue:null};if(typeof n=="object"&&"x"in n&&"y"in n){const{parsedUnit:a,unitOfValue:c}=q2(n.x),l=q2(n.x),u=q2(n.y);return l.value===null||u.value===null?{parsedUnit:null,unitOfValue:null,value:null}:{parsedUnit:a,unitOfValue:c,value:{x:l.value,y:u.value}}}const t=n.toString().split("").reverse().join("").match(/[^\d\s]+/)?.[0];if(!t)throw new Error(`Could not determine unit: "${n}"`);const i=t.split("").reverse().join(""),r=n.slice(0,-i.length);if(i in pJe&&!sye.has(i)){const a=pJe[i];return{parsedUnit:null,unitOfValue:null,value:Number.parseFloat(r)*a}}const{baseUnit:o,conversionFactor:s}=mxn(i);return{parsedUnit:i,unitOfValue:o,value:s*Number.parseFloat(r)}}var aye=R().or(Pe()).transform(n=>q2(n).value),fJe=R().or(Pe()).transform(n=>q2(n).value).transform(n=>Number.parseFloat(n.toPrecision(12))),_xn=R().or(Pe()).transform(n=>q2(n).value),QR=R().or(Pe()).transform(n=>q2(n).value),_t=R().or(Pe()).transform(n=>q2(n).value),cye=R().or(Pe()).transform(n=>q2(n).value),fi=_t;R().or(Pe()).transform(n=>q2(n).value);var lye=R().or(Pe()).transform(n=>q2(n).value),JR=lye,yxn=R().datetime(),iS=R().or(Pe()).transform(n=>typeof n=="number"?n:n.endsWith("deg")?Number.parseFloat(n.split("deg")[0]):n.endsWith("rad")?Number.parseFloat(n.split("rad")[0])*180/Math.PI:Number.parseFloat(n)),gxn=Pe().or(R().endsWith("mAh")).transform(n=>{if(typeof n=="string"){const e=n.replace("mAh",""),t=Number.parseFloat(e);if(Number.isNaN(t))throw new Error("Invalid capacity");return t}return n}).describe("Battery capacity in mAh"),Os=Se({x:fi,y:fi}),uye=Se({x:fi,y:fi,z:fi}),mJe=Se({width:Pe(),height:Pe()}),xxn=n=>{const e="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";return Array.from({length:n},()=>e[Math.floor(Math.random()*e.length)]).join("")},Yi=n=>R().optional().default(()=>`${n}_${xxn(10)}`),tV=Xt(["top_left","top_center","top_right","center_left","center","center_right","bottom_left","bottom_center","bottom_right"]),bxn=Xt(["jlcpcb","macrofab","pcbway","digikey","mouser","lcsc"]),Bx=Se({type:pe("source_component"),ftype:R().optional(),source_component_id:R(),name:R(),manufacturer_part_number:R().optional(),supplier_part_numbers:rs(bxn,ut(R())).optional(),display_value:R().optional(),are_pins_interchangeable:Je().optional(),internally_connected_source_port_ids:ut(ut(R())).optional(),source_group_id:R().optional(),subcircuit_id:R().optional()}),_Je=Bx.extend({ftype:pe("simple_capacitor"),capacitance:fJe,max_voltage_rating:QR.optional(),display_capacitance:R().optional(),max_decoupling_trace_length:fi.optional()}),yJe=Bx.extend({ftype:pe("simple_resistor"),resistance:aye,display_resistance:R().optional()}),dye=Bx.extend({ftype:pe("simple_diode")}),gJe=dye.extend({ftype:pe("simple_led"),color:R().optional(),wavelength:R().optional()}),vxn=Bx.extend({ftype:pe("simple_ground")}),xJe=Bx.extend({ftype:pe("simple_chip")}),bJe=Bx.extend({ftype:pe("simple_power_source"),voltage:QR}),wxn=Bx.extend({ftype:pe("simple_fuse"),current_rating_amps:Pe().describe("Nominal current in amps the fuse is rated for"),voltage_rating_volts:Pe().describe("Voltage rating in volts, e.g. ±5V would be 5")}),vJe=Bx.extend({ftype:pe("simple_battery"),capacity:gxn}),wJe=Bx.extend({ftype:pe("simple_inductor"),inductance:_xn,max_current_rating:Pe().optional()}),SJe=Bx.extend({ftype:pe("simple_push_button")}),EJe=Bx.extend({ftype:pe("simple_potentiometer"),max_resistance:aye}),Sxn=Bx.extend({ftype:pe("simple_crystal"),frequency:Pe().describe("Frequency in Hz"),load_capacitance:Pe().optional().describe("Load capacitance in pF")}),TJe=Bx.extend({ftype:pe("simple_pin_header"),pin_count:Pe(),gender:Xt(["male","female"]).optional().default("male")}),MJe=Bx.extend({ftype:pe("simple_pinout")}),CJe=Bx.extend({ftype:pe("simple_resonator"),load_capacitance:fJe,equivalent_series_resistance:aye.optional(),frequency:cye}),AJe=Bx.extend({ftype:pe("simple_transistor"),transistor_type:Xt(["npn","pnp"])}),PJe=Bx.extend({ftype:pe("simple_test_point"),footprint_variant:Xt(["pad","through_hole"]).optional(),pad_shape:Xt(["rect","circle"]).optional(),pad_diameter:Bn([Pe(),R()]).optional(),hole_diameter:Bn([Pe(),R()]).optional(),width:Bn([Pe(),R()]).optional(),height:Bn([Pe(),R()]).optional()}),RJe=Bx.extend({ftype:pe("simple_mosfet"),channel_type:Xt(["n","p"]),mosfet_mode:Xt(["enhancement","depletion"])}),IJe=Bx.extend({ftype:pe("simple_switch")}),NJe=Se({type:pe("source_project_metadata"),name:R().optional(),software_used_string:R().optional(),project_url:R().optional(),created_at:yxn.optional()}),Exn=Se({type:pe("source_missing_property_error"),source_missing_property_error_id:Yi("source_missing_property_error"),source_component_id:R(),property_name:R(),subcircuit_id:R().optional(),error_type:pe("source_missing_property_error").default("source_missing_property_error"),message:R()}).describe("The source code is missing a property"),Txn=Se({type:pe("source_failed_to_create_component_error"),source_failed_to_create_component_error_id:Yi("source_failed_to_create_component_error"),error_type:pe("source_failed_to_create_component_error").default("source_failed_to_create_component_error"),component_name:R().optional(),subcircuit_id:R().optional(),parent_source_component_id:R().optional(),message:R(),pcb_center:Se({x:Pe().optional(),y:Pe().optional()}).optional(),schematic_center:Se({x:Pe().optional(),y:Pe().optional()}).optional()}).describe("Error emitted when a component fails to be constructed"),kJe=Se({type:pe("source_trace_not_connected_error"),source_trace_not_connected_error_id:Yi("source_trace_not_connected_error"),error_type:pe("source_trace_not_connected_error").default("source_trace_not_connected_error"),message:R(),subcircuit_id:R().optional(),source_group_id:R().optional(),source_trace_id:R().optional(),connected_source_port_ids:ut(R()).optional(),selectors_not_found:ut(R()).optional()}).describe("Occurs when a source trace selector does not match any ports"),Mxn=Se({type:pe("source_property_ignored_warning"),source_property_ignored_warning_id:Yi("source_property_ignored_warning"),source_component_id:R(),property_name:R(),subcircuit_id:R().optional(),error_type:pe("source_property_ignored_warning").default("source_property_ignored_warning"),message:R()}).describe("The source property was ignored"),OJe=Se({type:pe("source_pin_missing_trace_warning"),source_pin_missing_trace_warning_id:Yi("source_pin_missing_trace_warning"),warning_type:pe("source_pin_missing_trace_warning").default("source_pin_missing_trace_warning"),message:R(),source_component_id:R(),source_port_id:R(),subcircuit_id:R().optional()}).describe("Warning emitted when a source component pin is missing a trace connection"),Cxn=Bn([yJe,_Je,dye,gJe,vxn,xJe,bJe,vJe,wJe,SJe,EJe,Sxn,TJe,MJe,CJe,IJe,AJe,PJe,RJe,wxn,NJe,Exn,Txn,kJe,Mxn,OJe]),Axn=Se({type:pe("source_port"),pin_number:Pe().optional(),port_hints:ut(R()).optional(),name:R(),source_port_id:R(),source_component_id:R().optional(),source_group_id:R().optional(),subcircuit_id:R().optional(),subcircuit_connectivity_map_key:R().optional()}),Pxn=Se({type:pe("source_trace"),source_trace_id:R(),connected_source_port_ids:ut(R()),connected_source_net_ids:ut(R()),subcircuit_id:R().optional(),subcircuit_connectivity_map_key:R().optional(),max_length:Pe().optional(),min_trace_thickness:Pe().optional(),display_name:R().optional()}),Rxn=Se({type:pe("source_group"),source_group_id:R(),subcircuit_id:R().optional(),parent_subcircuit_id:R().optional(),parent_source_group_id:R().optional(),is_subcircuit:Je().optional(),show_as_schematic_box:Je().optional(),name:R().optional(),was_automatically_named:Je().optional()}),Ixn=Se({type:pe("source_net"),source_net_id:R(),name:R(),member_source_group_ids:ut(R()),is_power:Je().optional(),is_ground:Je().optional(),is_digital_signal:Je().optional(),is_analog_signal:Je().optional(),is_positive_voltage_source:Je().optional(),trace_width:Pe().optional(),subcircuit_id:R().optional(),subcircuit_connectivity_map_key:R().optional()}),Nxn=Se({type:pe("source_board"),source_board_id:R(),source_group_id:R(),title:R().optional()}).describe("Defines a board in the source domain"),kxn=Se({type:pe("source_pcb_ground_plane"),source_pcb_ground_plane_id:R(),source_group_id:R(),source_net_id:R(),subcircuit_id:R().optional()}).describe("Defines a ground plane in the source domain"),Oxn=["top","bottom","inner1","inner2","inner3","inner4","inner5","inner6"],LJe=Xt(Oxn),Wd=LJe.or(Se({name:LJe})).transform(n=>typeof n=="string"?n:n.name),rT=Xt(["top","bottom"]),Lxn=Se({type:pe("source_manually_placed_via"),source_manually_placed_via_id:R(),source_group_id:R(),source_net_id:R(),subcircuit_id:R().optional(),source_trace_id:R().optional()}).describe("Defines a via that is manually placed in the source domain"),Dxn=Se({type:pe("unknown_error_finding_part"),unknown_error_finding_part_id:Yi("unknown_error_finding_part"),error_type:pe("unknown_error_finding_part").default("unknown_error_finding_part"),message:R(),source_component_id:R().optional(),subcircuit_id:R().optional()}).describe("Error emitted when an unexpected error occurs while finding a part"),zxn=Se({type:pe("schematic_box"),schematic_component_id:R().optional(),width:fi,height:fi,is_dashed:Je().default(!1),x:fi,y:fi,subcircuit_id:R().optional()}).describe("Draws a box on the schematic"),$xn=Se({type:pe("schematic_path"),schematic_component_id:R(),fill_color:Xt(["red","blue"]).optional(),is_filled:Je().optional(),points:ut(Os),subcircuit_id:R().optional()}),Fxn=rs(Se({left_margin:_t.optional(),right_margin:_t.optional(),top_margin:_t.optional(),bottom_margin:_t.optional()})),Uxn=Se({left_size:Pe(),right_size:Pe(),top_size:Pe().optional(),bottom_size:Pe().optional()}),Bxn=Se({left_side:Se({pins:ut(Pe()),direction:Xt(["top-to-bottom","bottom-to-top"]).optional()}).optional(),right_side:Se({pins:ut(Pe()),direction:Xt(["top-to-bottom","bottom-to-top"]).optional()}).optional(),top_side:Se({pins:ut(Pe()),direction:Xt(["left-to-right","right-to-left"]).optional()}).optional(),bottom_side:Se({pins:ut(Pe()),direction:Xt(["left-to-right","right-to-left"]).optional()}).optional()}),jxn=Bn([Uxn,Bxn]),Hxn=Se({type:pe("schematic_component"),size:mJe,center:Os,source_component_id:R().optional(),schematic_component_id:R(),pin_spacing:_t.optional(),pin_styles:Fxn.optional(),box_width:_t.optional(),symbol_name:R().optional(),port_arrangement:jxn.optional(),port_labels:rs(R()).optional(),symbol_display_value:R().optional(),subcircuit_id:R().optional(),schematic_group_id:R().optional(),is_schematic_group:Je().optional(),source_group_id:R().optional(),is_box_with_pins:Je().optional().default(!0)}),Vxn=Se({type:pe("schematic_line"),schematic_line_id:Yi("schematic_line"),schematic_component_id:R(),x1:fi,y1:fi,x2:fi,y2:fi,stroke_width:fi.nullable().optional(),color:R().default("#000000"),is_dashed:Je().default(!1),subcircuit_id:R().optional()}).describe("Draws a styled line on the schematic"),Gxn=Se({type:pe("schematic_rect"),schematic_rect_id:Yi("schematic_rect"),schematic_component_id:R(),center:Os,width:fi,height:fi,rotation:iS.default(0),stroke_width:fi.nullable().optional(),color:R().default("#000000"),is_filled:Je().default(!1),fill_color:R().optional(),is_dashed:Je().default(!1),subcircuit_id:R().optional()}).describe("Draws a styled rectangle on the schematic"),Yxn=Se({type:pe("schematic_circle"),schematic_circle_id:Yi("schematic_circle"),schematic_component_id:R(),center:Os,radius:fi,stroke_width:fi.nullable().optional(),color:R().default("#000000"),is_filled:Je().default(!1),fill_color:R().optional(),is_dashed:Je().default(!1),subcircuit_id:R().optional()}).describe("Draws a styled circle on the schematic"),qxn=Se({type:pe("schematic_arc"),schematic_arc_id:Yi("schematic_arc"),schematic_component_id:R(),center:Os,radius:fi,start_angle_degrees:iS,end_angle_degrees:iS,direction:Xt(["clockwise","counterclockwise"]).default("counterclockwise"),stroke_width:fi.nullable().optional(),color:R().default("#000000"),is_dashed:Je().default(!1),subcircuit_id:R().optional()}).describe("Draws a styled arc on the schematic"),Xxn=Se({type:pe("schematic_trace"),schematic_trace_id:R(),source_trace_id:R().optional(),junctions:ut(Se({x:Pe(),y:Pe()})),edges:ut(Se({from:Se({x:Pe(),y:Pe()}),to:Se({x:Pe(),y:Pe()}),is_crossing:Je().optional(),from_schematic_port_id:R().optional(),to_schematic_port_id:R().optional()})),subcircuit_id:R().optional(),subcircuit_connectivity_map_key:R().optional()}),Wxn=Xt(["center","left","right","top","bottom"]),Kxn=Se({type:pe("schematic_text"),schematic_component_id:R().optional(),schematic_text_id:R(),text:R(),font_size:Pe().default(.18),position:Se({x:fi,y:fi}),rotation:Pe().default(0),anchor:Bn([Wxn.describe("legacy"),tV]).default("center"),color:R().default("#000000"),subcircuit_id:R().optional()}),Zxn=Se({type:pe("schematic_port"),schematic_port_id:R(),source_port_id:R(),schematic_component_id:R().optional(),center:Os,facing_direction:Xt(["up","down","left","right"]).optional(),distance_from_component_edge:Pe().optional(),side_of_component:Xt(["top","bottom","left","right"]).optional(),true_ccw_index:Pe().optional(),pin_number:Pe().optional(),display_pin_label:R().optional(),subcircuit_id:R().optional(),is_connected:Je().optional(),has_input_arrow:Je().optional(),has_output_arrow:Je().optional()}).describe("Defines a port on a schematic component"),Qxn=Se({type:pe("schematic_net_label"),schematic_net_label_id:Yi("schematic_net_label"),schematic_trace_id:R().optional(),source_trace_id:R().optional(),source_net_id:R(),center:Os,anchor_position:Os.optional(),anchor_side:Xt(["top","bottom","left","right"]),text:R(),symbol_name:R().optional(),is_movable:Je().optional(),subcircuit_id:R().optional()}),Jxn=Se({type:pe("schematic_error"),schematic_error_id:R(),error_type:pe("schematic_port_not_found").default("schematic_port_not_found"),message:R(),subcircuit_id:R().optional()}).describe("Defines a schematic error on the schematic"),e1n=Se({type:pe("schematic_layout_error"),schematic_layout_error_id:Yi("schematic_layout_error"),error_type:pe("schematic_layout_error").default("schematic_layout_error"),message:R(),source_group_id:R(),schematic_group_id:R(),subcircuit_id:R().optional()}).describe("Error emitted when schematic layout fails for a group"),hye=Se({type:pe("schematic_debug_object"),label:R().optional(),subcircuit_id:R().optional()}),t1n=hye.extend({shape:pe("rect"),center:Os,size:mJe}),n1n=hye.extend({shape:pe("line"),start:Os,end:Os}),i1n=hye.extend({shape:pe("point"),center:Os}),r1n=_m("shape",[t1n,n1n,i1n]),o1n=Se({type:pe("schematic_voltage_probe"),schematic_voltage_probe_id:R(),position:Os,schematic_trace_id:R(),voltage:QR.optional(),subcircuit_id:R().optional()}).describe("Defines a voltage probe measurement point on a schematic trace"),s1n=Se({type:pe("schematic_manual_edit_conflict_warning"),schematic_manual_edit_conflict_warning_id:Yi("schematic_manual_edit_conflict_warning"),warning_type:pe("schematic_manual_edit_conflict_warning").default("schematic_manual_edit_conflict_warning"),message:R(),schematic_component_id:R(),schematic_group_id:R().optional(),subcircuit_id:R().optional(),source_component_id:R()}).describe("Warning emitted when a component has both manual placement and explicit schX/schY coordinates"),a1n=Se({type:pe("schematic_group"),schematic_group_id:Yi("schematic_group"),source_group_id:R(),is_subcircuit:Je().optional(),subcircuit_id:R().optional(),width:_t,height:_t,center:Os,schematic_component_ids:ut(R()),show_as_schematic_box:Je().optional(),name:R().optional(),description:R().optional()}).describe("Defines a group of components on the schematic"),c1n=Se({type:pe("schematic_table"),schematic_table_id:Yi("schematic_table"),anchor_position:Os,column_widths:ut(fi),row_heights:ut(fi),cell_padding:fi.optional(),border_width:fi.optional(),subcircuit_id:R().optional(),schematic_component_id:R().optional(),anchor:tV.optional()}).describe("Defines a table on the schematic"),l1n=Se({type:pe("schematic_table_cell"),schematic_table_cell_id:Yi("schematic_table_cell"),schematic_table_id:R(),start_row_index:Pe(),end_row_index:Pe(),start_column_index:Pe(),end_column_index:Pe(),text:R().optional(),center:Os,width:fi,height:fi,horizontal_align:Xt(["left","center","right"]).optional(),vertical_align:Xt(["top","middle","bottom"]).optional(),font_size:fi.optional(),subcircuit_id:R().optional()}).describe("Defines a cell within a schematic_table"),u1n=Se({type:pe("schematic_sheet"),schematic_sheet_id:Yi("schematic_sheet"),name:R().optional(),subcircuit_id:R().optional()}).describe("Defines a schematic sheet or page that components can be placed on"),d1n=Se({x:fi,y:fi,bulge:Pe().optional()}),DJe=Se({vertices:ut(d1n)}),h1n=Se({outer_ring:DJe,inner_rings:ut(DJe).default([])}),p1n=Se({x:fi,y:fi,via:Je().optional(),via_to_layer:Wd.optional()});ut(p1n);var f1n=Se({x:fi,y:fi,via:Je().optional(),to_layer:Wd.optional(),trace_width:fi.optional()}),m1n=Se({type:pe("pcb_component"),pcb_component_id:Yi("pcb_component"),source_component_id:R(),center:Os,layer:Wd,rotation:iS,width:_t,height:_t,do_not_place:Je().optional(),subcircuit_id:R().optional(),pcb_group_id:R().optional(),obstructs_within_bounds:Je().default(!0).describe("Does this component take up all the space within its bounds on a layer. This is generally true except for when separated pin headers are being represented by a single component (in which case, chips can be placed between the pin headers) or for tall modules where chips fit underneath")}).describe("Defines a component on the PCB"),zJe=Se({type:pe("pcb_hole"),pcb_hole_id:Yi("pcb_hole"),pcb_group_id:R().optional(),subcircuit_id:R().optional(),hole_shape:Xt(["circle","square"]),hole_diameter:Pe(),x:fi,y:fi});zJe.describe("Defines a circular or square hole on the PCB");var $Je=Se({type:pe("pcb_hole"),pcb_hole_id:Yi("pcb_hole"),pcb_group_id:R().optional(),subcircuit_id:R().optional(),hole_shape:pe("oval"),hole_width:Pe(),hole_height:Pe(),x:fi,y:fi});$Je.describe("Defines an oval hole on the PCB");var FJe=Se({type:pe("pcb_hole"),pcb_hole_id:Yi("pcb_hole"),pcb_group_id:R().optional(),subcircuit_id:R().optional(),hole_shape:pe("pill"),hole_width:Pe(),hole_height:Pe(),x:fi,y:fi});FJe.describe("Defines a pill-shaped hole on the PCB");var UJe=Se({type:pe("pcb_hole"),pcb_hole_id:Yi("pcb_hole"),pcb_group_id:R().optional(),subcircuit_id:R().optional(),hole_shape:pe("rotated_pill"),hole_width:Pe(),hole_height:Pe(),x:fi,y:fi,ccw_rotation:iS});UJe.describe("Defines a rotated pill-shaped hole on the PCB");var _1n=zJe.or($Je).or(FJe).or(UJe),y1n=Se({type:pe("pcb_plated_hole"),shape:pe("circle"),pcb_group_id:R().optional(),subcircuit_id:R().optional(),outer_diameter:Pe(),hole_diameter:Pe(),x:fi,y:fi,layers:ut(Wd),port_hints:ut(R()).optional(),pcb_component_id:R().optional(),pcb_port_id:R().optional(),pcb_plated_hole_id:Yi("pcb_plated_hole")}),g1n=Se({type:pe("pcb_plated_hole"),shape:Xt(["oval","pill"]),pcb_group_id:R().optional(),subcircuit_id:R().optional(),outer_width:Pe(),outer_height:Pe(),hole_width:Pe(),hole_height:Pe(),x:fi,y:fi,ccw_rotation:iS,layers:ut(Wd),port_hints:ut(R()).optional(),pcb_component_id:R().optional(),pcb_port_id:R().optional(),pcb_plated_hole_id:Yi("pcb_plated_hole")}),x1n=Se({type:pe("pcb_plated_hole"),shape:pe("circular_hole_with_rect_pad"),pcb_group_id:R().optional(),subcircuit_id:R().optional(),hole_shape:pe("circle"),pad_shape:pe("rect"),hole_diameter:Pe(),rect_pad_width:Pe(),rect_pad_height:Pe(),rect_border_radius:Pe().optional(),hole_offset_x:fi.default(0),hole_offset_y:fi.default(0),x:fi,y:fi,layers:ut(Wd),port_hints:ut(R()).optional(),pcb_component_id:R().optional(),pcb_port_id:R().optional(),pcb_plated_hole_id:Yi("pcb_plated_hole")}),b1n=Se({type:pe("pcb_plated_hole"),shape:pe("pill_hole_with_rect_pad"),pcb_group_id:R().optional(),subcircuit_id:R().optional(),hole_shape:pe("pill"),pad_shape:pe("rect"),hole_width:Pe(),hole_height:Pe(),rect_pad_width:Pe(),rect_pad_height:Pe(),rect_border_radius:Pe().optional(),hole_offset_x:fi.default(0),hole_offset_y:fi.default(0),x:fi,y:fi,layers:ut(Wd),port_hints:ut(R()).optional(),pcb_component_id:R().optional(),pcb_port_id:R().optional(),pcb_plated_hole_id:Yi("pcb_plated_hole")}),v1n=Se({type:pe("pcb_plated_hole"),shape:pe("rotated_pill_hole_with_rect_pad"),pcb_group_id:R().optional(),subcircuit_id:R().optional(),hole_shape:pe("rotated_pill"),pad_shape:pe("rect"),hole_width:Pe(),hole_height:Pe(),hole_ccw_rotation:iS,rect_pad_width:Pe(),rect_pad_height:Pe(),rect_border_radius:Pe().optional(),rect_ccw_rotation:iS,hole_offset_x:fi.default(0),hole_offset_y:fi.default(0),x:fi,y:fi,layers:ut(Wd),port_hints:ut(R()).optional(),pcb_component_id:R().optional(),pcb_port_id:R().optional(),pcb_plated_hole_id:Yi("pcb_plated_hole")}),w1n=Bn([y1n,g1n,x1n,b1n,v1n]),S1n=Se({type:pe("pcb_port"),pcb_port_id:Yi("pcb_port"),pcb_group_id:R().optional(),subcircuit_id:R().optional(),source_port_id:R(),pcb_component_id:R().optional(),x:fi,y:fi,layers:ut(Wd),is_board_pinout:Je().optional()}).describe("Defines a port on the PCB"),E1n=Se({type:pe("pcb_smtpad"),shape:pe("circle"),pcb_smtpad_id:Yi("pcb_smtpad"),pcb_group_id:R().optional(),subcircuit_id:R().optional(),x:fi,y:fi,radius:Pe(),layer:Wd,port_hints:ut(R()).optional(),pcb_component_id:R().optional(),pcb_port_id:R().optional(),is_covered_with_solder_mask:Je().optional()}),T1n=Se({type:pe("pcb_smtpad"),shape:pe("rect"),pcb_smtpad_id:Yi("pcb_smtpad"),pcb_group_id:R().optional(),subcircuit_id:R().optional(),x:fi,y:fi,width:Pe(),height:Pe(),rect_border_radius:Pe().optional(),corner_radius:Pe().optional(),layer:Wd,port_hints:ut(R()).optional(),pcb_component_id:R().optional(),pcb_port_id:R().optional(),is_covered_with_solder_mask:Je().optional()}),M1n=Se({type:pe("pcb_smtpad"),shape:pe("rotated_rect"),pcb_smtpad_id:Yi("pcb_smtpad"),pcb_group_id:R().optional(),subcircuit_id:R().optional(),x:fi,y:fi,width:Pe(),height:Pe(),rect_border_radius:Pe().optional(),corner_radius:Pe().optional(),ccw_rotation:iS,layer:Wd,port_hints:ut(R()).optional(),pcb_component_id:R().optional(),pcb_port_id:R().optional(),is_covered_with_solder_mask:Je().optional()}),C1n=Se({type:pe("pcb_smtpad"),shape:pe("pill"),pcb_smtpad_id:Yi("pcb_smtpad"),pcb_group_id:R().optional(),subcircuit_id:R().optional(),x:fi,y:fi,width:Pe(),height:Pe(),radius:Pe(),layer:Wd,port_hints:ut(R()).optional(),pcb_component_id:R().optional(),pcb_port_id:R().optional(),is_covered_with_solder_mask:Je().optional()}),A1n=Se({type:pe("pcb_smtpad"),shape:pe("rotated_pill"),pcb_smtpad_id:Yi("pcb_smtpad"),pcb_group_id:R().optional(),subcircuit_id:R().optional(),x:fi,y:fi,width:Pe(),height:Pe(),radius:Pe(),ccw_rotation:iS,layer:Wd,port_hints:ut(R()).optional(),pcb_component_id:R().optional(),pcb_port_id:R().optional(),is_covered_with_solder_mask:Je().optional()}),P1n=Se({type:pe("pcb_smtpad"),shape:pe("polygon"),pcb_smtpad_id:Yi("pcb_smtpad"),pcb_group_id:R().optional(),subcircuit_id:R().optional(),points:ut(Os),layer:Wd,port_hints:ut(R()).optional(),pcb_component_id:R().optional(),pcb_port_id:R().optional(),is_covered_with_solder_mask:Je().optional()}),R1n=_m("shape",[E1n,T1n,M1n,A1n,C1n,P1n]).describe("Defines an SMT pad on the PCB"),I1n=Se({type:pe("pcb_solder_paste"),shape:pe("circle"),pcb_solder_paste_id:Yi("pcb_solder_paste"),pcb_group_id:R().optional(),subcircuit_id:R().optional(),x:fi,y:fi,radius:Pe(),layer:Wd,pcb_component_id:R().optional(),pcb_smtpad_id:R().optional()}),N1n=Se({type:pe("pcb_solder_paste"),shape:pe("rect"),pcb_solder_paste_id:Yi("pcb_solder_paste"),pcb_group_id:R().optional(),subcircuit_id:R().optional(),x:fi,y:fi,width:Pe(),height:Pe(),layer:Wd,pcb_component_id:R().optional(),pcb_smtpad_id:R().optional()}),k1n=Se({type:pe("pcb_solder_paste"),shape:pe("pill"),pcb_solder_paste_id:Yi("pcb_solder_paste"),pcb_group_id:R().optional(),subcircuit_id:R().optional(),x:fi,y:fi,width:Pe(),height:Pe(),radius:Pe(),layer:Wd,pcb_component_id:R().optional(),pcb_smtpad_id:R().optional()}),O1n=Se({type:pe("pcb_solder_paste"),shape:pe("rotated_rect"),pcb_solder_paste_id:Yi("pcb_solder_paste"),pcb_group_id:R().optional(),subcircuit_id:R().optional(),x:fi,y:fi,width:Pe(),height:Pe(),ccw_rotation:fi,layer:Wd,pcb_component_id:R().optional(),pcb_smtpad_id:R().optional()}),L1n=Se({type:pe("pcb_solder_paste"),shape:pe("oval"),pcb_solder_paste_id:Yi("pcb_solder_paste"),pcb_group_id:R().optional(),subcircuit_id:R().optional(),x:fi,y:fi,width:Pe(),height:Pe(),layer:Wd,pcb_component_id:R().optional(),pcb_smtpad_id:R().optional()}),D1n=Bn([I1n,N1n,k1n,O1n,L1n]).describe("Defines solderpaste on the PCB"),z1n=Se({type:pe("pcb_text"),pcb_text_id:Yi("pcb_text"),pcb_group_id:R().optional(),subcircuit_id:R().optional(),text:R(),center:Os,layer:Wd,width:_t,height:_t,lines:Pe(),align:Xt(["bottom-left"])}).describe("Defines text on the PCB"),$1n=Se({route_type:pe("wire"),x:fi,y:fi,width:fi,start_pcb_port_id:R().optional(),end_pcb_port_id:R().optional(),layer:Wd}),F1n=Se({route_type:pe("via"),x:fi,y:fi,hole_diameter:fi.optional(),outer_diameter:fi.optional(),from_layer:R(),to_layer:R()}),U1n=Bn([$1n,F1n]),B1n=Se({type:pe("pcb_trace"),source_trace_id:R().optional(),pcb_component_id:R().optional(),pcb_trace_id:Yi("pcb_trace"),pcb_group_id:R().optional(),subcircuit_id:R().optional(),route_thickness_mode:Xt(["constant","interpolated"]).default("constant").optional(),route_order_index:Pe().optional(),should_round_corners:Je().optional(),trace_length:Pe().optional(),highlight_color:R().optional(),route:ut(U1n)}).describe("Defines a trace on the PCB"),j1n=Se({type:pe("pcb_trace_error"),pcb_trace_error_id:Yi("pcb_trace_error"),error_type:pe("pcb_trace_error").default("pcb_trace_error"),message:R(),center:Os.optional(),pcb_trace_id:R(),source_trace_id:R(),pcb_component_ids:ut(R()),pcb_port_ids:ut(R()),subcircuit_id:R().optional()}).describe("Defines a trace error on the PCB"),H1n=Se({type:pe("pcb_trace_missing_error"),pcb_trace_missing_error_id:Yi("pcb_trace_missing_error"),error_type:pe("pcb_trace_missing_error").default("pcb_trace_missing_error"),message:R(),center:Os.optional(),source_trace_id:R(),pcb_component_ids:ut(R()),pcb_port_ids:ut(R()),subcircuit_id:R().optional()}).describe("Defines an error when a source trace has no corresponding PCB trace"),V1n=Se({type:pe("pcb_port_not_matched_error"),pcb_error_id:Yi("pcb_error"),error_type:pe("pcb_port_not_matched_error").default("pcb_port_not_matched_error"),message:R(),pcb_component_ids:ut(R()),subcircuit_id:R().optional()}).describe("Defines a trace error on the PCB where a port is not matched"),G1n=Se({type:pe("pcb_port_not_connected_error"),pcb_port_not_connected_error_id:Yi("pcb_port_not_connected_error"),error_type:pe("pcb_port_not_connected_error").default("pcb_port_not_connected_error"),message:R(),pcb_port_ids:ut(R()),pcb_component_ids:ut(R()),subcircuit_id:R().optional()}).describe("Defines an error when a pcb port is not connected to any trace"),Y1n=Se({type:pe("pcb_net"),pcb_net_id:Yi("pcb_net"),source_net_id:R().optional(),highlight_color:R().optional()}).describe("Defines a net on the PCB"),q1n=Se({type:pe("pcb_via"),pcb_via_id:Yi("pcb_via"),pcb_group_id:R().optional(),subcircuit_id:R().optional(),x:fi,y:fi,outer_diameter:fi.default("0.6mm"),hole_diameter:fi.default("0.25mm"),from_layer:Wd.optional(),to_layer:Wd.optional(),layers:ut(Wd),pcb_trace_id:R().optional(),net_is_assignable:Je().optional(),net_assigned:Je().optional()}).describe("Defines a via on the PCB"),X1n=Se({type:pe("pcb_board"),pcb_board_id:Yi("pcb_board"),pcb_panel_id:R().optional(),is_subcircuit:Je().optional(),subcircuit_id:R().optional(),width:_t,height:_t,center:Os,thickness:_t.optional().default(1.4),num_layers:Pe().optional().default(4),outline:ut(Os).optional(),material:Xt(["fr4","fr1"]).default("fr4")}).describe("Defines the board outline of the PCB"),W1n=Se({type:pe("pcb_panel"),pcb_panel_id:Yi("pcb_panel"),width:_t,height:_t,covered_with_solder_mask:Je().optional().default(!0)}).describe("Defines a PCB panel that can contain multiple boards"),K1n=Se({type:pe("pcb_placement_error"),pcb_placement_error_id:Yi("pcb_placement_error"),error_type:pe("pcb_placement_error").default("pcb_placement_error"),message:R(),subcircuit_id:R().optional()}).describe("Defines a placement error on the PCB"),Z1n=Se({type:pe("pcb_trace_hint"),pcb_trace_hint_id:Yi("pcb_trace_hint"),pcb_port_id:R(),pcb_component_id:R(),route:ut(f1n),subcircuit_id:R().optional()}).describe("A hint that can be used during generation of a PCB trace"),Q1n=Se({type:pe("pcb_silkscreen_line"),pcb_silkscreen_line_id:Yi("pcb_silkscreen_line"),pcb_component_id:R(),pcb_group_id:R().optional(),subcircuit_id:R().optional(),stroke_width:fi.default("0.1mm"),x1:fi,y1:fi,x2:fi,y2:fi,layer:rT}).describe("Defines a silkscreen line on the PCB"),J1n=Se({type:pe("pcb_silkscreen_path"),pcb_silkscreen_path_id:Yi("pcb_silkscreen_path"),pcb_component_id:R(),pcb_group_id:R().optional(),subcircuit_id:R().optional(),layer:rT,route:ut(Os),stroke_width:_t}).describe("Defines a silkscreen path on the PCB"),ebn=Se({type:pe("pcb_silkscreen_text"),pcb_silkscreen_text_id:Yi("pcb_silkscreen_text"),pcb_group_id:R().optional(),subcircuit_id:R().optional(),font:pe("tscircuit2024").default("tscircuit2024"),font_size:fi.default("0.2mm"),pcb_component_id:R(),text:R(),is_knockout:Je().default(!1).optional(),knockout_padding:Se({left:_t,top:_t,bottom:_t,right:_t}).default({left:"0.2mm",top:"0.2mm",bottom:"0.2mm",right:"0.2mm"}).optional(),ccw_rotation:Pe().optional(),layer:Wd,is_mirrored:Je().default(!1).optional(),anchor_position:Os.default({x:0,y:0}),anchor_alignment:tV.default("center")}).describe("Defines silkscreen text on the PCB"),tbn=Se({type:pe("pcb_copper_text"),pcb_copper_text_id:Yi("pcb_copper_text"),pcb_group_id:R().optional(),subcircuit_id:R().optional(),font:pe("tscircuit2024").default("tscircuit2024"),font_size:fi.default("0.2mm"),pcb_component_id:R(),text:R(),is_knockout:Je().default(!1).optional(),knockout_padding:Se({left:_t,top:_t,bottom:_t,right:_t}).default({left:"0.2mm",top:"0.2mm",bottom:"0.2mm",right:"0.2mm"}).optional(),ccw_rotation:Pe().optional(),layer:Wd,is_mirrored:Je().default(!1).optional(),anchor_position:Os.default({x:0,y:0}),anchor_alignment:tV.default("center")}).describe("Defines copper text on the PCB"),nbn=Se({type:pe("pcb_silkscreen_rect"),pcb_silkscreen_rect_id:Yi("pcb_silkscreen_rect"),pcb_component_id:R(),pcb_group_id:R().optional(),subcircuit_id:R().optional(),center:Os,width:_t,height:_t,layer:Wd,stroke_width:_t.default("1mm"),corner_radius:_t.optional(),is_filled:Je().default(!0).optional(),has_stroke:Je().optional(),is_stroke_dashed:Je().optional()}).describe("Defines a silkscreen rect on the PCB"),ibn=Se({type:pe("pcb_silkscreen_circle"),pcb_silkscreen_circle_id:Yi("pcb_silkscreen_circle"),pcb_component_id:R(),pcb_group_id:R().optional(),subcircuit_id:R().optional(),center:Os,radius:_t,layer:rT,stroke_width:_t.default("1mm")}).describe("Defines a silkscreen circle on the PCB"),rbn=Se({type:pe("pcb_silkscreen_oval"),pcb_silkscreen_oval_id:Yi("pcb_silkscreen_oval"),pcb_component_id:R(),pcb_group_id:R().optional(),subcircuit_id:R().optional(),center:Os,radius_x:fi,radius_y:fi,layer:rT}).describe("Defines a silkscreen oval on the PCB"),obn=Se({type:pe("pcb_fabrication_note_text"),pcb_fabrication_note_text_id:Yi("pcb_fabrication_note_text"),subcircuit_id:R().optional(),pcb_group_id:R().optional(),font:pe("tscircuit2024").default("tscircuit2024"),font_size:fi.default("1mm"),pcb_component_id:R(),text:R(),layer:rT,anchor_position:Os.default({x:0,y:0}),anchor_alignment:Xt(["center","top_left","top_right","bottom_left","bottom_right"]).default("center"),color:R().optional()}).describe("Defines a fabrication note in text on the PCB, useful for leaving notes for assemblers or fabricators"),sbn=Se({type:pe("pcb_fabrication_note_path"),pcb_fabrication_note_path_id:Yi("pcb_fabrication_note_path"),pcb_component_id:R(),subcircuit_id:R().optional(),layer:Wd,route:ut(Os),stroke_width:_t,color:R().optional()}).describe("Defines a fabrication path on the PCB for fabricators or assemblers"),abn=Se({type:pe("pcb_fabrication_note_rect"),pcb_fabrication_note_rect_id:Yi("pcb_fabrication_note_rect"),pcb_component_id:R(),pcb_group_id:R().optional(),subcircuit_id:R().optional(),center:Os,width:_t,height:_t,layer:rT,stroke_width:_t.default("0.1mm"),corner_radius:_t.optional(),is_filled:Je().optional(),has_stroke:Je().optional(),is_stroke_dashed:Je().optional(),color:R().optional()}).describe("Defines a fabrication note rectangle on the PCB"),cbn=Se({type:pe("pcb_fabrication_note_dimension"),pcb_fabrication_note_dimension_id:Yi("pcb_fabrication_note_dimension"),pcb_component_id:R(),pcb_group_id:R().optional(),subcircuit_id:R().optional(),layer:rT,from:Os,to:Os,text:R().optional(),text_ccw_rotation:Pe().optional(),offset:_t.optional(),offset_distance:_t.optional(),offset_direction:Se({x:Pe(),y:Pe()}).optional(),font:pe("tscircuit2024").default("tscircuit2024"),font_size:_t.default("1mm"),color:R().optional(),arrow_size:_t.default("1mm")}).describe("Defines a measurement annotation within PCB fabrication notes"),lbn=Se({type:pe("pcb_note_text"),pcb_note_text_id:Yi("pcb_note_text"),pcb_component_id:R().optional(),pcb_group_id:R().optional(),subcircuit_id:R().optional(),name:R().optional(),font:pe("tscircuit2024").default("tscircuit2024"),font_size:fi.default("1mm"),text:R().optional(),anchor_position:Os.default({x:0,y:0}),anchor_alignment:Xt(["center","top_left","top_right","bottom_left","bottom_right"]).default("center"),color:R().optional()}).describe("Defines a documentation note in text on the PCB"),ubn=Se({type:pe("pcb_note_rect"),pcb_note_rect_id:Yi("pcb_note_rect"),pcb_component_id:R().optional(),pcb_group_id:R().optional(),subcircuit_id:R().optional(),name:R().optional(),text:R().optional(),center:Os,width:_t,height:_t,stroke_width:_t.default("0.1mm"),corner_radius:_t.optional(),is_filled:Je().optional(),has_stroke:Je().optional(),is_stroke_dashed:Je().optional(),color:R().optional()}).describe("Defines a rectangular documentation note on the PCB"),dbn=Se({type:pe("pcb_note_path"),pcb_note_path_id:Yi("pcb_note_path"),pcb_component_id:R().optional(),pcb_group_id:R().optional(),subcircuit_id:R().optional(),name:R().optional(),text:R().optional(),route:ut(Os),stroke_width:_t.default("0.1mm"),color:R().optional()}).describe("Defines a polyline documentation note on the PCB"),hbn=Se({type:pe("pcb_note_line"),pcb_note_line_id:Yi("pcb_note_line"),pcb_component_id:R().optional(),pcb_group_id:R().optional(),subcircuit_id:R().optional(),name:R().optional(),text:R().optional(),x1:fi,y1:fi,x2:fi,y2:fi,stroke_width:fi.default("0.1mm"),color:R().optional(),is_dashed:Je().optional()}).describe("Defines a straight documentation note line on the PCB"),pbn=Se({type:pe("pcb_note_dimension"),pcb_note_dimension_id:Yi("pcb_note_dimension"),pcb_component_id:R().optional(),pcb_group_id:R().optional(),subcircuit_id:R().optional(),name:R().optional(),from:Os,to:Os,text:R().optional(),text_ccw_rotation:Pe().optional(),offset_distance:_t.optional(),offset_direction:Se({x:Pe(),y:Pe()}).optional(),font:pe("tscircuit2024").default("tscircuit2024"),font_size:_t.default("1mm"),color:R().optional(),arrow_size:_t.default("1mm")}).describe("Defines a measurement annotation within PCB documentation notes"),fbn=Se({type:pe("pcb_footprint_overlap_error"),pcb_error_id:Yi("pcb_error"),error_type:pe("pcb_footprint_overlap_error").default("pcb_footprint_overlap_error"),message:R(),pcb_smtpad_ids:ut(R()).optional(),pcb_plated_hole_ids:ut(R()).optional(),pcb_hole_ids:ut(R()).optional(),pcb_keepout_ids:ut(R()).optional()}).describe("Error emitted when a pcb footprint overlaps with another element"),mbn=Se({type:pe("pcb_keepout"),shape:pe("rect"),pcb_group_id:R().optional(),subcircuit_id:R().optional(),center:Os,width:fi,height:fi,pcb_keepout_id:R(),layers:ut(R()),description:R().optional()}).or(Se({type:pe("pcb_keepout"),shape:pe("circle"),pcb_group_id:R().optional(),subcircuit_id:R().optional(),center:Os,radius:fi,pcb_keepout_id:R(),layers:ut(R()),description:R().optional()})),pye=Se({type:pe("pcb_cutout"),pcb_cutout_id:Yi("pcb_cutout"),pcb_group_id:R().optional(),subcircuit_id:R().optional()}),_bn=pye.extend({shape:pe("rect"),center:Os,width:_t,height:_t,rotation:iS.optional()}),ybn=pye.extend({shape:pe("circle"),center:Os,radius:_t}),gbn=pye.extend({shape:pe("polygon"),points:ut(Os)}),xbn=_m("shape",[_bn,ybn,gbn]).describe("Defines a cutout on the PCB, removing board material."),bbn=Se({type:pe("pcb_missing_footprint_error"),pcb_missing_footprint_error_id:Yi("pcb_missing_footprint_error"),pcb_group_id:R().optional(),subcircuit_id:R().optional(),error_type:pe("pcb_missing_footprint_error").default("pcb_missing_footprint_error"),source_component_id:R(),message:R()}).describe("Defines a missing footprint error on the PCB"),vbn=Se({type:pe("external_footprint_load_error"),external_footprint_load_error_id:Yi("external_footprint_load_error"),pcb_component_id:R(),source_component_id:R(),pcb_group_id:R().optional(),subcircuit_id:R().optional(),footprinter_string:R().optional(),error_type:pe("external_footprint_load_error").default("external_footprint_load_error"),message:R()}).describe("Defines an error when an external footprint fails to load"),wbn=Se({type:pe("circuit_json_footprint_load_error"),circuit_json_footprint_load_error_id:Yi("circuit_json_footprint_load_error"),pcb_component_id:R(),source_component_id:R(),pcb_group_id:R().optional(),subcircuit_id:R().optional(),error_type:pe("circuit_json_footprint_load_error").default("circuit_json_footprint_load_error"),message:R(),circuit_json:ut(fl()).optional()}).describe("Defines an error when a circuit JSON footprint fails to load"),Sbn=Se({type:pe("pcb_group"),pcb_group_id:Yi("pcb_group"),source_group_id:R(),is_subcircuit:Je().optional(),subcircuit_id:R().optional(),width:_t.optional(),height:_t.optional(),center:Os,outline:ut(Os).optional(),anchor_position:Os.optional(),anchor_alignment:Xt(["center","top_left","top_right","bottom_left","bottom_right"]).optional(),pcb_component_ids:ut(R()),name:R().optional(),description:R().optional(),layout_mode:R().optional(),autorouter_configuration:Se({trace_clearance:_t}).optional(),autorouter_used_string:R().optional()}).describe("Defines a group of components on the PCB"),Ebn=Se({type:pe("pcb_autorouting_error"),pcb_error_id:Yi("pcb_autorouting_error"),error_type:pe("pcb_autorouting_error").default("pcb_autorouting_error"),message:R(),subcircuit_id:R().optional()}).describe("The autorouting has failed to route a portion of the board"),Tbn=Se({type:pe("pcb_manual_edit_conflict_warning"),pcb_manual_edit_conflict_warning_id:Yi("pcb_manual_edit_conflict_warning"),warning_type:pe("pcb_manual_edit_conflict_warning").default("pcb_manual_edit_conflict_warning"),message:R(),pcb_component_id:R(),pcb_group_id:R().optional(),subcircuit_id:R().optional(),source_component_id:R()}).describe("Warning emitted when a component has both manual placement and explicit pcbX/pcbY coordinates"),Mbn=Se({type:pe("pcb_breakout_point"),pcb_breakout_point_id:Yi("pcb_breakout_point"),pcb_group_id:R(),subcircuit_id:R().optional(),source_trace_id:R().optional(),source_port_id:R().optional(),source_net_id:R().optional(),x:fi,y:fi}).describe("Defines a routing target within a pcb_group for a source_trace or source_net"),Cbn=Se({type:pe("pcb_ground_plane"),pcb_ground_plane_id:Yi("pcb_ground_plane"),source_pcb_ground_plane_id:R(),source_net_id:R(),pcb_group_id:R().optional(),subcircuit_id:R().optional()}).describe("Defines a ground plane on the PCB"),Abn=Se({type:pe("pcb_ground_plane_region"),pcb_ground_plane_region_id:Yi("pcb_ground_plane_region"),pcb_ground_plane_id:R(),pcb_group_id:R().optional(),subcircuit_id:R().optional(),layer:Wd,points:ut(Os)}).describe("Defines a polygon region of a ground plane"),Pbn=Se({type:pe("pcb_thermal_spoke"),pcb_thermal_spoke_id:Yi("pcb_thermal_spoke"),pcb_ground_plane_id:R(),shape:R(),spoke_count:Pe(),spoke_thickness:fi,spoke_inner_diameter:fi,spoke_outer_diameter:fi,pcb_plated_hole_id:R().optional(),subcircuit_id:R().optional()}).describe("Pattern for connecting a ground plane to a plated hole"),fye=Se({type:pe("pcb_copper_pour"),pcb_copper_pour_id:Yi("pcb_copper_pour"),pcb_group_id:R().optional(),subcircuit_id:R().optional(),layer:Wd,source_net_id:R().optional(),covered_with_solder_mask:Je().optional().default(!0)}),Rbn=fye.extend({shape:pe("rect"),center:Os,width:_t,height:_t,rotation:iS.optional()}),Ibn=fye.extend({shape:pe("brep"),brep_shape:h1n}),Nbn=fye.extend({shape:pe("polygon"),points:ut(Os)}),kbn=_m("shape",[Rbn,Ibn,Nbn]).describe("Defines a copper pour on the PCB."),Obn=Se({type:pe("pcb_component_outside_board_error"),pcb_component_outside_board_error_id:Yi("pcb_component_outside_board_error"),error_type:pe("pcb_component_outside_board_error").default("pcb_component_outside_board_error"),message:R(),pcb_component_id:R(),pcb_board_id:R(),component_center:Os,component_bounds:Se({min_x:Pe(),max_x:Pe(),min_y:Pe(),max_y:Pe()}),subcircuit_id:R().optional(),source_component_id:R().optional()}).describe("Error emitted when a PCB component is placed outside the board boundaries"),Lbn=Se({type:pe("pcb_component_invalid_layer_error"),pcb_component_invalid_layer_error_id:Yi("pcb_component_invalid_layer_error"),error_type:pe("pcb_component_invalid_layer_error").default("pcb_component_invalid_layer_error"),message:R(),pcb_component_id:R().optional(),source_component_id:R(),layer:Wd,subcircuit_id:R().optional()}).describe("Error emitted when a component is placed on an invalid layer (components can only be on 'top' or 'bottom' layers)"),Dbn=Se({type:pe("pcb_via_clearance_error"),pcb_error_id:Yi("pcb_error"),error_type:pe("pcb_via_clearance_error").default("pcb_via_clearance_error"),message:R(),pcb_via_ids:ut(R()).min(2),minimum_clearance:fi.optional(),actual_clearance:fi.optional(),pcb_center:Se({x:Pe().optional(),y:Pe().optional()}).optional(),subcircuit_id:R().optional()}).describe("Error emitted when vias are closer than the allowed clearance"),zbn=Se({type:pe("pcb_courtyard_rect"),pcb_courtyard_rect_id:Yi("pcb_courtyard_rect"),pcb_component_id:R(),pcb_group_id:R().optional(),subcircuit_id:R().optional(),center:Os,width:_t,height:_t,layer:rT,color:R().optional()}).describe("Defines a courtyard rectangle on the PCB"),$bn=Se({type:pe("pcb_courtyard_outline"),pcb_courtyard_outline_id:Yi("pcb_courtyard_outline"),pcb_component_id:R(),pcb_group_id:R().optional(),subcircuit_id:R().optional(),layer:rT,outline:ut(Os).min(2),stroke_width:_t.default("0.1mm"),is_closed:Je().optional(),is_stroke_dashed:Je().optional(),color:R().optional()}).describe("Defines a courtyard outline on the PCB"),Fbn=Se({type:pe("pcb_courtyard_polygon"),pcb_courtyard_polygon_id:Yi("pcb_courtyard_polygon"),pcb_component_id:R(),pcb_group_id:R().optional(),subcircuit_id:R().optional(),layer:rT,points:ut(Os).min(3),color:R().optional()}).describe("Defines a courtyard polygon on the PCB"),Ubn=Se({type:pe("cad_component"),cad_component_id:R(),pcb_component_id:R(),source_component_id:R(),position:uye,rotation:uye.optional(),size:uye.optional(),layer:Wd.optional(),subcircuit_id:R().optional(),footprinter_string:R().optional(),model_obj_url:R().optional(),model_stl_url:R().optional(),model_3mf_url:R().optional(),model_gltf_url:R().optional(),model_glb_url:R().optional(),model_step_url:R().optional(),model_wrl_url:R().optional(),model_unit_to_mm_scale_factor:Pe().optional(),model_jscad:fl().optional()}).describe("Defines a component on the PCB"),Bbn=Xt(["sinewave","square","triangle","sawtooth"]),jbn=Bn([R(),Pe()]).transform(n=>typeof n=="string"?n.endsWith("%")?parseFloat(n.slice(0,-1))/100:parseFloat(n):n).pipe(Pe().min(0,"Duty cycle must be non-negative").max(1,"Duty cycle cannot be greater than 100%")),Hbn=Se({type:pe("simulation_voltage_source"),simulation_voltage_source_id:Yi("simulation_voltage_source"),is_dc_source:pe(!0).optional().default(!0),positive_source_port_id:R().optional(),negative_source_port_id:R().optional(),positive_source_net_id:R().optional(),negative_source_net_id:R().optional(),voltage:QR}).describe("Defines a DC voltage source for simulation"),Vbn=Se({type:pe("simulation_voltage_source"),simulation_voltage_source_id:Yi("simulation_voltage_source"),is_dc_source:pe(!1),terminal1_source_port_id:R().optional(),terminal2_source_port_id:R().optional(),terminal1_source_net_id:R().optional(),terminal2_source_net_id:R().optional(),voltage:QR.optional(),frequency:cye.optional(),peak_to_peak_voltage:QR.optional(),wave_shape:Bbn.optional(),phase:iS.optional(),duty_cycle:jbn.optional()}).describe("Defines an AC voltage source for simulation"),Gbn=Bn([Hbn,Vbn]).describe("Defines a voltage source for simulation"),Ybn=Bn([pe("spice_dc_sweep"),pe("spice_dc_operating_point"),pe("spice_transient_analysis"),pe("spice_ac_analysis")]),qbn=Se({type:pe("simulation_experiment"),simulation_experiment_id:Yi("simulation_experiment"),name:R(),experiment_type:Ybn,time_per_step:lye.optional(),start_time_ms:JR.optional(),end_time_ms:JR.optional()}).describe("Defines a simulation experiment configuration"),Xbn=Se({type:pe("simulation_transient_voltage_graph"),simulation_transient_voltage_graph_id:Yi("simulation_transient_voltage_graph"),simulation_experiment_id:R(),timestamps_ms:ut(Pe()).optional(),voltage_levels:ut(Pe()),schematic_voltage_probe_id:R().optional(),simulation_voltage_probe_id:R().optional(),subcircuit_connectivity_map_key:R().optional(),time_per_step:lye,start_time_ms:JR,end_time_ms:JR,name:R().optional()}).describe("Stores voltage measurements over time for a simulation"),Wbn=Se({type:pe("simulation_switch"),simulation_switch_id:Yi("simulation_switch"),source_component_id:R().optional(),closes_at:JR.optional(),opens_at:JR.optional(),starts_closed:Je().optional(),switching_frequency:cye.optional()}).describe("Defines a switch for simulation timing control"),Kbn=Se({type:pe("simulation_voltage_probe"),simulation_voltage_probe_id:Yi("simulation_voltage_probe"),source_port_id:R().optional(),source_net_id:R().optional(),name:R().optional(),subcircuit_id:R().optional()}).describe("Defines a voltage probe for simulation, connected to a port or a net").refine(n=>!!n.source_port_id!=!!n.source_net_id,{message:"Exactly one of source_port_id or source_net_id must be provided to simulation_voltage_probe"}),Zbn=Se({type:pe("simulation_unknown_experiment_error"),simulation_unknown_experiment_error_id:Yi("simulation_unknown_experiment_error"),error_type:pe("simulation_unknown_experiment_error").default("simulation_unknown_experiment_error"),message:R(),simulation_experiment_id:R().optional(),subcircuit_id:R().optional()}).describe("An unknown error occurred during the simulation experiment.");Bn([Pxn,Axn,Cxn,Ixn,Rxn,xJe,_Je,dye,gJe,yJe,bJe,vJe,wJe,TJe,MJe,CJe,IJe,AJe,PJe,RJe,EJe,SJe,kxn,Lxn,Nxn,NJe,kJe,OJe,Dxn,m1n,_1n,bbn,vbn,wbn,Tbn,w1n,mbn,S1n,Y1n,z1n,B1n,q1n,R1n,D1n,X1n,W1n,Sbn,Z1n,Q1n,J1n,ebn,tbn,nbn,ibn,rbn,j1n,H1n,K1n,V1n,G1n,Dbn,sbn,obn,abn,cbn,lbn,ubn,dbn,hbn,pbn,Ebn,fbn,Mbn,xbn,Cbn,Abn,Pbn,kbn,Obn,Lbn,zbn,$bn,Fbn,zxn,Kxn,Vxn,Gxn,Yxn,qxn,Hxn,Zxn,Xxn,$xn,Jxn,e1n,Qxn,r1n,o1n,s1n,a1n,u1n,c1n,l1n,Ubn,Gbn,qbn,Xbn,Wbn,Kbn,Zbn]);var Qbn=Object.defineProperty,Jbn=(n,e)=>{for(var t in e)Qbn(n,t,{get:e[t],enumerable:!0})},j5={};Jbn(j5,{axial:()=>Jvn,bga:()=>dvn,breakoutheaders:()=>lwn,cap:()=>svn,dfn:()=>Ovn,diode:()=>ovn,dip:()=>nvn,electrolytic:()=>G2n,hc49:()=>dwn,jst:()=>m2n,led:()=>avn,lqfp:()=>awn,m2host:()=>cEn,melf:()=>ESn,micromelf:()=>ASn,minimelf:()=>_Sn,mlp:()=>xvn,ms012:()=>Bvn,ms013:()=>Hvn,msop:()=>T2n,pad:()=>hwn,pinrow:()=>zvn,platedhole:()=>iEn,potentiometer:()=>j2n,pushbutton:()=>twn,qfn:()=>yvn,qfp:()=>gvn,quad:()=>o8,res:()=>cvn,sma:()=>NSn,smb:()=>USn,smbf:()=>q2n,smc:()=>VSn,smf:()=>DSn,smtpad:()=>tEn,sod110:()=>y2n,sod123:()=>Wvn,sod123f:()=>Xwn,sod123fl:()=>Qwn,sod123w:()=>Awn,sod128:()=>sSn,sod323:()=>Nwn,sod323f:()=>Vwn,sod323fl:()=>I2n,sod323w:()=>C2n,sod523:()=>gwn,sod723:()=>nSn,sod80:()=>Ewn,sod882:()=>Uwn,sod882d:()=>bSn,sod923:()=>Dwn,soic:()=>pvn,solderjumper:()=>D2n,son:()=>L2n,sop8:()=>wwn,sot:()=>oEn,sot223:()=>XSn,sot23:()=>Cvn,sot23w:()=>i2n,sot25:()=>Ivn,sot323:()=>Z2n,sot363:()=>Tvn,sot457:()=>F2n,sot563:()=>Fvn,sot723:()=>Gvn,sot89:()=>hSn,ssop:()=>vvn,stampboard:()=>iwn,stampreceiver:()=>swn,to220:()=>fSn,to92:()=>_wn,to92s:()=>l2n,tssop:()=>Svn,vssop:()=>w2n});var Fo=(n,e,t)=>({type:"pcb_silkscreen_text",pcb_silkscreen_text_id:"silkscreen_text_1",font:"tscircuit2024",font_size:t,pcb_component_id:"pcb_component_1",text:"{REF}",layer:"top",anchor_position:{x:n,y:e},anchor_alignment:"center"}),Ia=(n,e,t,i,r)=>({pcb_plated_hole_id:"",type:"pcb_plated_hole",shape:"circle",x:e,y:t,hole_diameter:gh(i),outer_diameter:gh(r),pcb_port_id:"",layers:["top","bottom"],port_hints:[n.toString()]}),BJe=Array.from({length:9},(n,e)=>Math.cos(e/8*Math.PI-Math.PI)).map(n=>({x:n,y:-Math.sqrt(1-n**2)}));function BM(n){return typeof n=="string"?n.trim().toLowerCase().endsWith("mil")?parseFloat(n)*.0254:parseFloat(n):Number(n)}var nV=Bn([R(),Pe()]).transform(n=>BM(n)),evn=n=>Se({fn:R(),num_pins:Pe().optional().default(6),wide:Je().optional(),narrow:Je().optional(),w:nV.optional(),p:nV.default(n.p??"2.54mm"),id:nV.optional(),od:nV.optional()}).transform(e=>(!e.id&&!e.od?Math.abs(e.p-1.27)<.01?(e.id=BM("0.55mm"),e.od=BM("0.95mm")):(e.id=BM("1.0mm"),e.od=BM("1.5mm")):e.id?e.od||(e.od=e.id*(1.5/1)):e.id=e.od*(1/1.5),e.w||(e.wide?e.w=BM("600mil"):e.narrow?e.w=BM("300mil"):e.w=BM(n.w??"300mil")),e)),tvn=evn({}),jJe=(n,e,t,i)=>{const r=n/2,o=e<=r,s=r-1,a=i,c=a*s;return o?{x:-t/2,y:c/2-(e-1)*a}:{x:t/2,y:-c/2+(e-r-1)*a}},nvn=n=>{const e=tvn.parse(n),t=[];for(let l=0;l<e.num_pins;l++){const{x:u,y:d}=jJe(e.num_pins,l+1,e.w,e.p??2.54);t.push(Ia(l+1,u,d,e.id??"0.8mm",e.od??"1mm"))}(e.num_pins/2-1)*e.p+e.od;const r=e.w-e.od-1,o=(e.num_pins/2-1)*e.p+e.od+.4,s={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-r/2,y:-o/2},{x:-r/2,y:o/2},...BJe.map(({x:l,y:u})=>({x:l*r/6,y:u*r/6+o/2})),{x:r/2,y:o/2},{x:r/2,y:-o/2},{x:-r/2,y:-o/2}],type:"pcb_silkscreen_path",stroke_width:.1},a=[];for(let l=0;l<e.num_pins;l++){const u=l<e.num_pins/2,d=.6,{y:h}=jJe(e.num_pins,l+1,e.w,e.p??2.54),p=u?-e.w/2-e.od/2-d:e.w/2+e.od/2+d,m=h;a.push({type:"pcb_fabrication_note_text",pcb_fabrication_note_text_id:`pin_${l+1}`,layer:"top",pcb_component_id:`pin_${l+1}`,text:`{pin${l+1}}`,anchor_position:{x:p,y:m},font_size:.3,font:"tscircuit2024",anchor_alignment:"top_left"})}const c=Fo(0,o/2+.5,.4);return{circuitJson:[...t,s,c,...a],parameters:e}},zr=(n,e,t,i,r)=>({type:"pcb_smtpad",x:e,y:t,width:i,height:r,layer:"top",shape:"rect",pcb_smtpad_id:"",port_hints:Array.isArray(n)?n.map(o=>o.toString()):[n.toString()]}),HJe=[{imperial:"01005",metric:"0402",p_mm_min:.5,pw_mm_min:.4,ph_mm_min:.3,w_mm_min:.58,h_mm_min:.21},{imperial:"0504",metric:"1310",p_mm_min:1.1,pw_mm_min:.65,ph_mm_min:1.3,w_mm_min:.58,h_mm_min:.21},{imperial:"1812",metric:"4532",p_mm_min:4.275,pw_mm_min:1.125,ph_mm_min:3.4,w_mm_min:5.4,h_mm_min:3.4},{imperial:"0201",metric:"0603",p_mm_min:.66,pw_mm_min:.46,ph_mm_min:.4,w_mm_min:.9,h_mm_min:.3},{imperial:"0402",metric:"1005",p_mm_min:1.02,pw_mm_min:.54,ph_mm_min:.64,w_mm_min:1.56,h_mm_min:.64},{imperial:"0603",metric:"1608",p_mm_min:1.65,pw_mm_min:.8,ph_mm_min:.95,w_mm_min:2.45,h_mm_min:.95},{imperial:"0805",metric:"2012",p_mm_min:1.825,pw_mm_min:1.025,ph_mm_min:1.4,w_mm_min:2.8499999999999996,h_mm_min:1.4},{imperial:"1206",metric:"3216",p_mm_min:2.925,pw_mm_min:1.125,ph_mm_min:1.75,w_mm_min:4.05,h_mm_min:1.75},{imperial:"1210",metric:"3225",p_mm_min:2.925,pw_mm_min:1.125,ph_mm_min:2.65,w_mm_min:4.05,h_mm_min:2.65},{imperial:"2010",metric:"5025",p_mm_min:4.625,pw_mm_min:1.225,ph_mm_min:2.65,w_mm_min:5.85,h_mm_min:2.65},{imperial:"2512",metric:"6332",p_mm_min:5.925,pw_mm_min:1.225,ph_mm_min:3.35,w_mm_min:7.15,h_mm_min:3.35}],ivn=Object.fromEntries(HJe.map(n=>[n.metric,n])),rvn=Object.fromEntries(HJe.map(n=>[n.imperial,n]));Se({tht:Je(),p:_t.optional(),pw:_t.optional(),ph:_t.optional(),metric:fi.optional(),imperial:fi.optional(),w:_t.optional(),h:_t.optional(),textbottom:Je().optional()});var iV=n=>{let{tht:e,p:t,pw:i,ph:r,metric:o,imperial:s,w:a,h:c,textbottom:l}=n;if(typeof a=="string"&&(a=r8(a)),typeof c=="string"&&(c=r8(c)),typeof t=="string"&&(t=r8(t)),typeof i=="string"&&(i=r8(i)),typeof r=="string"&&(r=r8(r)),c!==void 0&&a!==void 0&&c>a)throw new Error("height cannot be greater than width (rotated footprint not yet implemented)");let u;if(o&&(u=ivn[o]),s&&(u=rvn[s]),u&&(a=u.w_mm_min,c=u.h_mm_min,t=u.p_mm_min,i=u.pw_mm_min,r=u.ph_mm_min),t===void 0||i===void 0||r===void 0)throw new Error("Could not determine required pad dimensions (p, pw, ph)");const d={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:t/2,y:r/2+.4},{x:-t/2-i/2-.2,y:r/2+.4},{x:-t/2-i/2-.2,y:-r/2-.4},{x:t/2,y:-r/2-.4}],stroke_width:.1,pcb_silkscreen_path_id:""},h=l?-r/2-.9:r/2+.9,p=Fo(0,h,.2);return e?[Ia(1,-t/2,0,i,i*1/.8),Ia(2,t/2,0,i,i*1/.8),d,p]:[zr(["1","left"],-t/2,0,i,r),zr(["2","right"],t/2,0,i,r),d,p]},ovn=n=>({circuitJson:iV(n),parameters:n}),svn=n=>({circuitJson:iV(n),parameters:n}),avn=n=>({circuitJson:iV(n),parameters:n}),cvn=n=>({circuitJson:iV(n),parameters:n}),VJe=(n,{x:e,y:t,radius:i})=>({type:"pcb_smtpad",x:e,y:t,radius:i,layer:"top",shape:"circle",pcb_smtpad_id:"",port_hints:Array.isArray(n)?n.map(r=>r.toString()):[n.toString()]}),GJe="ABCDEFGHIJKLMNOPQRSTUVWXYZ",YJe=R().transform(n=>{const[e,t]=n.split(/[x ]/);return{x:parseFloat(e),y:parseFloat(t)}}).pipe(Se({x:Pe(),y:Pe()})),lvn=R().or(ut(fl())).transform(n=>Array.isArray(n)?n:(n.startsWith("(")&&n.endsWith(")")&&(n=n.slice(1,-1)),n.split(",").map(e=>{const t=Number(e);return isNaN(t)?e:t}))).pipe(ut(R().or(Pe()))),uvn=Se({fn:R(),num_pins:Pe().optional().default(64),grid:YJe.optional(),p:fi.default("0.8mm"),w:_t.optional(),h:_t.optional(),ball:_t.optional().describe("ball diameter"),pad:_t.optional().describe("pad width/height"),circularpads:Je().optional().describe("use circular pads"),tlorigin:Je().optional(),blorigin:Je().optional(),trorigin:Je().optional(),brorigin:Je().optional(),missing:lvn.default([])}).transform(n=>{let e="tl";if(n.blorigin&&(e="bl"),n.trorigin&&(e="tr"),n.brorigin&&(e="br"),!n.grid){const i=Math.ceil(Math.sqrt(n.num_pins));n.grid={x:i,y:i}}return n.missing&&(n.missing=n.missing.map(i=>{if(typeof i=="number")return i;if(i==="center")return"center";if(i==="topleft")return"topleft";const r=i.match(/([A-Z]+)(\d+)/);if(!r)return i;const o=GJe.indexOf(r[1]),s=Number.parseInt(r[2])-1;return o*n.grid.x+s+1})),{...n,origin:e}}),dvn=n=>{const e=uvn.parse(n);let{num_pins:t,grid:i,p:r,w:o,h:s,ball:a,pad:c,missing:l}=e;a??=.75/1.27*r,c??=a*.8;const u=[],d=(l??[]).filter(N=>typeof N=="number"),h=i.x*i.y-t;if(l.length===0&&h>0&&(Math.sqrt(h)%1===0?l.push("center"):h===1&&l.push("topleft")),l?.includes("center")){const N=Math.floor(Math.sqrt(h)),A=Math.floor((i.x-N)/2),I=Math.floor((i.y-N)/2);for(let M=I;M<I+N;M++)for(let k=A;k<A+N;k++)d.push(M*i.x+k+1)}l?.includes("topleft")&&d.push(1);const p=new Set(d);let m=0;for(let N=0;N<i.y;N++)for(let A=0;A<i.x;A++){const I=(A-(i.x-1)/2)*r,M=(N-(i.y-1)/2)*r;let k=A,C=N;switch(e.origin){case"bl":k=A,C=i.y-1-N;break;case"br":k=i.x-1-A,C=i.y-1-N;break;case"tr":k=i.x-1-A,C=N;break}let U=C*i.x+k+1;if(p.has(U)){m++;continue}U-=m;const O=[U,`${GJe[C]}${k+1}`];u.push(e.circularpads?VJe(O,{x:I,y:M,radius:c/2}):zr(O,I,M,c,c))}const _=Fo(0,i.y*r/2,.2),g=r/6;let x;const b=i.x*r/2,w=i.y*r/2;switch(e.origin){case"bl":x=[{x:-b,y:-w},{x:-b,y:-w-g},{x:-b-g,y:-w},{x:-b,y:-w}];break;case"br":x=[{x:b,y:-w},{x:b,y:-w-g},{x:b+g,y:-w},{x:b,y:-w}];break;case"tr":x=[{x:b,y:w},{x:b,y:w+g},{x:b+g,y:w},{x:b,y:w}];break;case"tl":default:x=[{x:-b,y:w},{x:-b,y:w+g},{x:-b-g,y:w},{x:-b,y:w}];break}const E={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"pin1_marker",route:x,stroke_width:.05};return{circuitJson:[...u,_,E],parameters:e}},rV=(n,e,t,i,r)=>({type:"pcb_smtpad",x:e,y:t,width:i,height:r,radius:r/2,layer:"top",shape:"pill",pcb_smtpad_id:"",port_hints:Array.isArray(n)?n.map(o=>o.toString()):[n.toString()]}),X2=n=>Se({fn:R(),num_pins:Pe().optional().default(8),w:_t.default(_t.parse(n.w??"5.3mm")),p:_t.default(_t.parse(n.p??"1.27mm")),pw:_t.default(_t.parse(n.pw??"0.6mm")),pl:_t.default(_t.parse(n.pl??"1.0mm")),legsoutside:Je().optional().default(n.legsoutside??!1),pillpads:Je().optional().default(n.pillpads??!1)}).transform(e=>(!e.pw&&!e.pl?(e.pw=_t.parse("0.6mm"),e.pl=_t.parse("1.0mm")):e.pw?e.pl||(e.pl=e.pw*(1/.6)):e.pw=e.pl*(.6/1),e)),hvn=X2({}),mye=n=>{n.widthincludeslegs!==void 0&&(n.legsoutside=!n.widthincludeslegs);const{num_pins:e,pn:t,w:i,p:r,pl:o,legsoutside:s}=n,a=e/2,c=t<=a,l=a-1,u=r,d=u*l,h=s?o/2:-o/2;return c?{x:-i/2-h,y:d/2-(t-1)*u}:{x:i/2+h,y:-d/2+(t-a-1)*u}},pvn=n=>{const e=hvn.parse(n);return{circuitJson:H5(e),parameters:e}},H5=n=>{const e=[];for(let a=0;a<n.num_pins;a++){const{x:c,y:l}=mye({num_pins:n.num_pins,pn:a+1,w:n.w,p:n.p,pl:n.pl,legsoutside:n.legsoutside});n.pillpads?e.push(rV(a+1,c,l,n.pl,n.pw)):e.push(zr(a+1,c,l,n.pl,n.pw))}const t=Math.min(1,n.p/2),i=n.w-(n.legsoutside?0:n.pl*2)-.2,r=(n.num_pins/2-1)*n.p+n.pw+t,o=Fo(0,r/2+.4,r/12),s={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",stroke_width:.1,route:[{x:-i/2,y:-r/2},{x:-i/2,y:r/2},...BJe.map(({x:a,y:c})=>({x:a*i/6,y:c*i/6+r/2})),{x:i/2,y:r/2},{x:i/2,y:-r/2},{x:-i/2,y:-r/2}]};return[...e,s,o]},qJe=Xt(["leftside","topside","rightside","bottomside","toppin","bottompin","leftpin","rightpin"]),fvn=({num_pins:n,cw:e,ccw:t,startingpin:i})=>{const r=[],o=n/4;let s=1;const a={};for(const c of i??[])a[c]=!0;!a.leftside&&!a.topside&&!a.rightside&&!a.bottomside&&(a.leftside=!0),!a.bottompin&&!a.leftpin&&!a.rightpin&&!a.toppin&&(a.leftside?a.toppin=!0:a.topside?a.rightpin=!0:a.rightside?a.bottompin=!0:a.bottomside&&(a.leftpin=!0)),a.leftside&&a.toppin?s=1:a.leftside&&a.bottompin?s=o:a.bottomside&&a.leftpin?s=o+1:a.bottomside&&a.rightpin?s=o*2:a.rightside&&a.bottompin?s=o*2+1:a.rightside&&a.toppin?s=o*3:a.topside&&a.rightpin?s=o*3+1:a.topside&&a.leftpin&&(s=o*4),r.push(-1);for(let c=0;c<n;c++)r[s]=c+1,t||!e?(s++,s>n&&(s=1)):(s--,s<1&&(s=n));return r},_ye=Se({fn:R(),cc:Je().default(!0).optional(),ccw:Je().default(!0).optional(),startingpin:R().or(ut(qJe)).transform(n=>typeof n=="string"?n.slice(1,-1).split(","):n).pipe(ut(qJe)).optional(),num_pins:Pe().optional().default(64),w:_t.optional(),h:_t.optional(),p:_t.default(_t.parse("0.5mm")),pw:_t.optional(),pl:_t.optional(),thermalpad:Bn([pe(!0),YJe]).optional(),legsoutside:Je().default(!1)}),yye=n=>{n.w&&!n.h?n.h=n.w:!n.w&&n.h&&(n.w=n.h);const e=n.num_pins/4;if(!n.p&&!n.pw&&!n.pl&&n.w){const t=e+4;n.p=n.w/t}return!n.p&&n.w&&n.h&&n.pw&&n.pl&&(n.p=(n.w-n.pl*2)/(e-1)),!n.w&&!n.h&&n.p&&(n.w=n.p*(e+4),n.h=n.w),n.p&&!n.pw&&!n.pl?(n.pw=n.p/2,n.pl=n.p/2):n.pw?n.pl||(n.pl=n.pw*(1/.6)):n.pw=n.pl*(.6/1),n},XJe=_ye.transform(yye),mvn=["left","bottom","right","top"],_vn=n=>{const{pin_count:e,pn:t,w:i,h:r,p:o,pl:s,legsoutside:a}=n,c=e/4,l=mvn[Math.floor((t-1)/c)],u=(t-1)%c,d=o*(c-1),h=o*(c-1),p=a?s/2:-s/2;switch(l){case"left":return{x:-i/2-p,y:h/2-u*o,o:"vert"};case"bottom":return{x:-d/2+u*o,y:-r/2-p,o:"horz"};case"right":return{x:i/2+p,y:-h/2+u*o,o:"vert"};case"top":return{x:d/2-u*o,y:r/2+p,o:"horz"};default:throw new Error("Invalid pin number")}},o8=n=>{const e=XJe.parse(n),t=[],i=fvn(e),r=e.num_pins/4;for(let a=0;a<e.num_pins;a++){const{x:c,y:l,o:u}=_vn({pin_count:e.num_pins,pn:a+1,w:e.w,h:e.h,p:e.p??.5,pl:e.pl,legsoutside:e.legsoutside});let d=e.pw,h=e.pl;u==="vert"&&([d,h]=[h,d]);const p=i[a+1];t.push(zr(p,c,l,d,h))}if(e.thermalpad)if(typeof e.thermalpad=="boolean"){const a=e.p*(r-1)+e.pw,c=e.p*(r-1)+e.pw;t.push(zr(["thermalpad"],0,0,a,c))}else t.push(zr(["thermalpad"],0,0,e.thermalpad.x,e.thermalpad.y));const o=[];for(const[a,c,l]of[["top-left",-1,1],["bottom-left",-1,-1],["bottom-right",1,-1],["top-right",1,1]]){const u=e.w/2*c,d=e.h/2*l;let h="none",p=u,m=d;const _=e.pw*2;i[1]===1&&a==="top-left"?h="in1":i[r*4]===1&&a==="top-left"||i[r*3+1]===1&&a==="top-right"?h="in2":i[r*3]===1&&a==="top-right"||i[r]===1&&a==="bottom-left"?h="in1":i[r+1]===1&&a==="bottom-left"?h="in2":i[r*2]===1&&a==="bottom-right"?h="in1":i[r*2+1]===1&&a==="bottom-right"&&(h="in2");const g=h==="in1"?1:-1;if(e.legsoutside){const x=h==="in1"?e.pl/2:e.pw/2,b=h==="in1"?e.pw/2:e.pl/2;p+=x*c*g,m-=b*l*g}(h==="none"||e.legsoutside)&&o.push({layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:`pcb_silkscreen_path_${a}`,route:[{x:u-_*c,y:d},{x:u,y:d},{x:u,y:d-_*l}],type:"pcb_silkscreen_path",stroke_width:.1}),(h==="in1"||h==="in2")&&!e.legsoutside&&o.push({layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:`pcb_silkscreen_path_${a}_1`,route:[{x:u-_*c,y:d},{x:u-_*c/2,y:d}],type:"pcb_silkscreen_path",stroke_width:0},{layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:`pcb_silkscreen_path_${a}_2`,route:[{x:u,y:d-_*l/2},{x:u,y:d-_*l}],type:"pcb_silkscreen_path",stroke_width:.1}),(h==="in1"||h==="in2")&&o.push({layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:`pcb_silkscreen_path_${a}_3`,route:[{x:p-.2*-c,y:m+.2*g},{x:p,y:m},{x:p+.2*g*-c,y:m+.2},{x:p-.2*-c,y:m+.2*g}],type:"pcb_silkscreen_path",stroke_width:.1})}const s=Fo(0,e.h/2+(e.legsoutside?e.pl*1.2:.5),.3);return{circuitJson:[...t,...o,s],parameters:e}};_ye.extend({}).transform(yye);var yvn=n=>(n.legsoutside=!1,o8(n)),gvn=n=>{n.legsoutside=!0;const e=XJe.parse(n);if(!n.p)switch(n.num_pins){case 44:case 64:n.p=.8;break;case 52:n.w===14?n.p=1:n.p=.65;break;case 208:n.p=.5;break}if(!n.pl)switch(n.num_pins){case 44:case 52:case 64:n.pl=2.25;break;case 208:n.pl=1.65;break;default:n.pl=e.pl*4;break}if(!n.pw)switch(n.num_pins){case 44:case 64:n.pw=.5;break;case 52:n.w===14?n.pw=.45:n.pw=.55;break;case 208:n.pw=.3;break;default:n.pw=e.pw;break}return o8(n)};_ye.extend({}).transform(yye);var xvn=n=>(n.legsoutside=!1,n.thermalpad===void 0&&(n.thermalpad=!0),o8(n)),bvn=X2({w:"3.9mm",p:"1.27mm"}),vvn=n=>{const e=bvn.parse(n);return{circuitJson:H5(e),parameters:e}},wvn=X2({w:"7.1mm",p:"0.65mm",pl:"1.35mm",pw:"0.40mm",legsoutside:!0}),Svn=n=>{const e=wvn.parse(n);return{circuitJson:H5(e),parameters:e}},Evn=X2({}),Tvn=n=>{const e=Evn.parse({fn:"sot363",num_pins:6,w:1.94,p:.65,pw:.3,pl:.7,legoutside:!0});return{circuitJson:H5(e),parameters:e}},WJe=Se({fn:R(),num_pins:Pe().default(3),w:R().default("1.92mm"),h:R().default("2.74mm"),pl:R().default("0.8mm"),pw:R().default("0.764mm"),p:R().default("0.95mm"),string:R().optional()}),Mvn=X2({p:"0.95mm",w:"1.6mm",legsoutside:!0}),Cvn=n=>{const e=n.string?.match(/^sot23_(\d+)/),t=e?Number.parseInt(e[1],10):3;if(t===6||t===8){const r=Mvn.parse({...n,num_pins:t});return{circuitJson:H5(r),parameters:r}}const i=WJe.parse({...n,num_pins:t});if(i.num_pins===3)return{circuitJson:Pvn(i),parameters:i};if(i.num_pins===5)return{circuitJson:ZJe(i),parameters:i};throw new Error("Invalid number of pins")},Avn=n=>{const{pn:e}=n;return e===1?{x:-1.7,y:0}:e===2?{x:1.7,y:-.95}:{x:1.7,y:.95}},Pvn=n=>{const e=[];for(let i=0;i<n.num_pins;i++){const{x:r,y:o}=Avn({num_pins:n.num_pins,pn:i+1,w:Number.parseFloat(n.w),h:Number.parseFloat(n.h),pl:Number.parseFloat(n.pl)});e.push(zr(i+1,r,o,Number.parseFloat(n.pl),Number.parseFloat(n.pw)))}const t=Fo(0,Number.parseInt(n.h),.3);return[...e,t]},KJe=n=>{const{p:e,h:t,pn:i}=n;if(i===1)return{x:-t/2-.5,y:e};if(i===2)return{x:-t/2-.5,y:0};if(i===3)return{x:-t/2-.5,y:-e};if(i===4)return{x:t/2+.5,y:-e};if(i===5)return{x:t/2+.5,y:e};throw new Error("Invalid pin number")},ZJe=n=>{const e=[];for(let d=1;d<=n.num_pins;d++){const{x:h,y:p}=KJe({h:Number.parseFloat(n.h),p:Number.parseFloat(n.p),pn:d});e.push(zr(d,h,p,Number.parseFloat(n.pl),Number.parseFloat(n.pw)))}const t=(n.num_pins+1)/2*Number.parseFloat(n.p),i=Number.parseFloat(n.h),r={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-t/3,y:i/2+Number.parseFloat(n.p)/1.3},{x:t/3,y:i/2+Number.parseFloat(n.p)/1.3}],type:"pcb_silkscreen_path",stroke_width:.05},o={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_2",route:[{x:-t/3,y:-i/2-Number.parseFloat(n.p)/1.3},{x:t/3,y:-i/2-Number.parseFloat(n.p)/1.3}],type:"pcb_silkscreen_path",stroke_width:.05},s=Fo(0,i+.3,.3),a=KJe({h:Number.parseFloat(n.h),p:Number.parseFloat(n.p),pn:1});a.x=a.x-Number.parseFloat(n.pw)*1.5;const c=.7,l=.3,u={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"pin1_indicator",route:[{x:a.x+c/2,y:a.y},{x:a.x-c/2,y:a.y+l/2},{x:a.x-c/2,y:a.y-l/2},{x:a.x+c/2,y:a.y}],stroke_width:.05};return[...e,s,r,o,u]},Rvn=WJe.extend({}),Ivn=n=>{const e=Rvn.parse({...n,num_pins:5});return{circuitJson:ZJe(e),parameters:e}},Nvn=[{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}],kvn=X2({}),Ovn=n=>{const e=kvn.parse(n),t=[];for(let d=0;d<e.num_pins;d++){const{x:h,y:p}=mye({num_pins:e.num_pins,pn:d+1,w:e.w,p:e.p??1.27,pl:e.pl,widthincludeslegs:!0});t.push(zr(d+1,h,p,e.pl??"1mm",e.pw??"0.6mm"))}const i=Math.min(1,e.p/2),r=e.w+i,o=(e.num_pins/2-1)*e.p+e.pw+i,s=[];for(const d of Nvn){const{dx:h,dy:p}=d;s.push({layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"",route:[{x:h*r/2-h*e.p,y:p*o/2},{x:h*r/2,y:p*o/2},{x:h*r/2,y:p*o/2-p*e.p}],type:"pcb_silkscreen_path",stroke_width:.1})}const a=e.p/4,c=-r/2-a/2,l=o/2-e.p/2;s.push({layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"",type:"pcb_silkscreen_path",route:[{x:c,y:l},{x:c-a,y:l+a},{x:c-a,y:l-a},{x:c,y:l}],stroke_width:.1});const u=Fo(0,o/2+.4,o/12);return{circuitJson:[...t,u,...s],parameters:e}},oV=(n,e,t,i,r,o)=>({pcb_plated_hole_id:"",type:"pcb_plated_hole",shape:"circular_hole_with_rect_pad",x:e,y:t,hole_diameter:gh(i),hole_shape:"circle",pad_shape:"rect",rect_pad_width:gh(r),rect_pad_height:gh(o),pcb_port_id:"",layers:["top","bottom"],port_hints:[n.toString()]}),gye=({fs:n,pn:e,anchor_x:t,anchor_y:i,textalign:r="center",orthogonal:o=!1,verticallyinverted:s=!1,layer:a="top"})=>{let c=0;o&&s?c=270:s?c=180:o?c=90:c=0;let l="center";return r==="left"&&(s?l="center_right":l="center_left"),r==="right"&&(s?l="center_left":l="center_right"),a==="bottom"&&(l==="center_left"?l="center_right":l==="center_right"&&(l="center_left")),{type:"pcb_silkscreen_text",pcb_silkscreen_text_id:"silkscreen_text_1",font:"tscircuit2024",font_size:n,pcb_component_id:"pcb_component_1",text:`{PIN${e}}`,layer:a,anchor_position:{x:t,y:i},anchor_alignment:l,ccw_rotation:c}};function Lvn({pinlabeltextalignleft:n,pinlabeltextalignright:e,pinlabelorthogonal:t}){let i="top";return t?i="left":i="top",n&&(t?i="bottom":i="right"),e&&(t?i="top":i="left"),i}var Dvn=Se({fn:R(),num_pins:Pe().optional().default(6),rows:Bn([R(),Pe()]).transform(n=>Number(n)).optional().default(1).describe("number of rows"),p:_t.default("0.1in").describe("pitch"),id:_t.default("1.0mm").describe("inner diameter"),od:_t.default("1.5mm").describe("outer diameter"),male:Je().optional().describe("for male pin headers"),female:Je().optional().describe("for female pin headers"),pinlabeltextalignleft:Je().optional().default(!1),pinlabeltextaligncenter:Je().optional().default(!1),pinlabeltextalignright:Je().optional().default(!1),pinlabelverticallyinverted:Je().optional().default(!1),pinlabelorthogonal:Je().optional().default(!1),nosquareplating:Je().optional().default(!1).describe("do not use rectangular pad for pin 1"),nopinlabels:Je().optional().default(!1).describe("omit silkscreen pin labels"),doublesidedpinlabel:Je().optional().default(!1).describe("add silkscreen pins in top and bottom layers"),bottomsidepinlabel:Je().optional().default(!1).describe("place the silkscreen reference text on the bottom layer instead of top")}).transform(n=>{const e=Lvn(n);return{...n,pinlabelAnchorSide:e,male:n.male??!n.female,female:n.female??!1}}).superRefine((n,e)=>{n.male&&n.female&&e.addIssue({code:$i.custom,message:"'male' and 'female' cannot both be true; it should be male or female.",path:["male","female"]})}),zvn=n=>{const e=Dvn.parse(n),{p:t,id:i,od:r,rows:o,num_pins:s,pinlabelAnchorSide:a,pinlabelverticallyinverted:c,pinlabelorthogonal:l,pinlabeltextalignleft:u,pinlabeltextalignright:d,nopinlabels:h,doublesidedpinlabel:p,bottomsidepinlabel:m}=e;let _="center";u?_="left":d&&(_="right");const g=[],x=Math.ceil(s/o),b=-t,w=({xoff:M,yoff:k,od:C,anchorSide:U})=>{let O=0,H=0;const Y=C*.75;switch(U){case"right":O=Y;break;case"top":H=Y;break;case"bottom":H=-Y;break;case"left":O=-Y;break}return{anchor_x:M+O,anchor_y:k+H}},E=(M,k,C)=>{M===1&&!e.nosquareplating?g.push(oV(M,k,C,i,r,r)):g.push(Ia(M,k,C,i,r));const{anchor_x:U,anchor_y:O}=w({xoff:k,yoff:C,od:r,anchorSide:a});h||(m?g.push(gye({fs:r/5,pn:M,anchor_x:U,anchor_y:O,textalign:_,orthogonal:l,verticallyinverted:c,layer:"bottom"})):g.push(gye({fs:r/5,pn:M,anchor_x:U,anchor_y:O,textalign:_,orthogonal:l,verticallyinverted:c,layer:"top"})),p&&g.push(gye({fs:r/5,pn:M,anchor_x:U,anchor_y:O,textalign:_,orthogonal:l,verticallyinverted:c,layer:"bottom"})))},N=new Set,A=o>2&&x>2;if(o===1){const M=-((s-1)/2)*t;for(let k=0;k<s;k++){const C=k+1,U=M+k*t,O=`${U},0`;if(N.has(O))throw new Error(`Overlap at ${O}`);N.add(O),E(C,U,0)}}else if(A){const M=-((x-1)/2)*t;let k=1;for(let C=0;C<o&&k<=s;C++)for(let U=0;U<x&&k<=s;U++){const O=M+U*t,H=C*b,Y=`${O},${H}`;if(N.has(Y))throw new Error(`Overlap at ${Y}`);N.add(Y),E(k++,O,H)}}else{const M=-((x-1)/2)*t;let k=1,C=0,U=o-1,O=0,H=x-1;for(;k<=s&&C<=U&&O<=H;){for(let Y=C;Y<=U&&k<=s;Y++){const W=M+O*t,K=Y*b,J=`${W},${K}`;if(N.has(J))throw new Error(`Overlap at ${J}`);N.add(J),E(k++,W,K)}O++;for(let Y=O;Y<=H&&k<=s;Y++){const W=M+Y*t,K=U*b,J=`${W},${K}`;if(N.has(J))throw new Error(`Overlap at ${J}`);N.add(J),E(k++,W,K)}if(U--,O<=H){for(let Y=U;Y>=C&&k<=s;Y--){const W=M+H*t,K=Y*b,J=`${W},${K}`;if(N.has(J))throw new Error(`Overlap at ${J}`);N.add(J),E(k++,W,K)}H--}if(C<=U){for(let Y=H;Y>=O&&k<=s;Y--){const W=M+Y*t,K=C*b,J=`${W},${K}`;if(N.has(J))throw new Error(`Overlap at ${J}`);N.add(J),E(k++,W,K)}C++}}if(k-1<s)throw new Error(`Missing pins: assigned ${k-1}, expected ${s}`)}const I=Fo(0,t,.5);return{circuitJson:[...g,I],parameters:e}},$vn=X2({}),Fvn=n=>{const e=$vn.parse({fn:"sot563",num_pins:6,w:1.94,p:.5,pw:.3,pl:.67,legoutside:!0});return{circuitJson:H5(e),parameters:e}},Uvn=X2({p:"1.27mm",w:"3.9mm",legsoutside:!0}),Bvn=n=>{const e=Uvn.parse({...n,num_pins:8});return{circuitJson:H5(e),parameters:e}},jvn=X2({p:"1.27mm",w:"7.5mm",legsoutside:!0}),Hvn=n=>{const e=jvn.parse({...n,num_pins:16});return{circuitJson:H5(e),parameters:e}},Vvn=Se({fn:R(),num_pins:pe(3).default(3),w:R().default("1.2mm"),h:R().default("1.2mm"),pl:R().default("0.3mm"),pw:R().default("0.32mm")}),Gvn=n=>{const e=Vvn.parse(n),t=qvn(e),i=Fo(.4,_t.parse(e.h),.2);return{circuitJson:[...t,i],parameters:e}},Yvn=n=>{const{pn:e}=n;return e===1?{x:0,y:0}:e===2?{x:1,y:-.4}:{x:1,y:.4}},qvn=n=>{const e=[];for(let t=0;t<3;t++){const{x:i,y:r}=Yvn({num_pins:n.num_pins,pn:t+1,w:Number.parseFloat(n.w),h:Number.parseFloat(n.h),pl:Number.parseFloat(n.pl)});e.push(zr(t+1,i,r,Number.parseFloat(n.pl),t!==0?Number.parseFloat(n.pw):.42))}return e},Xvn=Se({fn:R(),num_pins:pe(2).default(2),w:R().default("2.36mm"),h:R().default("1.22mm"),pl:R().default("0.9mm"),pw:R().default("0.9mm"),p:R().default("4.19mm")}),Wvn=n=>{const e=Xvn.parse(n),t=Fo(0,_t.parse(e.h)/4+.4,.3);return{circuitJson:Zvn(e).concat(t),parameters:e}},Kvn=n=>{const{pn:e,p:t}=n;return e===1?{x:-t/2,y:0}:{x:t/2,y:0}},Zvn=n=>{const e=[];for(let t=1;t<=n.num_pins;t++){const{x:i,y:r}=Kvn({pn:t,p:Number.parseFloat(n.p)});e.push(zr(t,i,r,Number.parseFloat(n.pl),Number.parseFloat(n.pw)))}return e},Qvn=Se({fn:R(),p:_t.optional().default("2.54mm"),id:_t.optional().default("0.7mm"),od:_t.optional().default("1mm")}),Jvn=n=>{const e=Qvn.parse(n),{p:t,id:i,od:r}=e,o=[Ia(1,-t/2,0,i,r),Ia(2,t/2,0,i,r)],s={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-t/2+r+i/2,y:0},{x:t/2-r-i/2,y:0}],stroke_width:.1,pcb_silkscreen_path_id:""},a=Fo(0,t/4,.5);return{circuitJson:[...o,s,a],parameters:e}},sV=(n,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:n,stroke_width:e.stroke_width||.1}),ewn=Se({fn:pe("pushbutton"),w:_t.default(4.5),h:_t.default(6.5),id:_t.default(1),od:_t.default(1.2)}),twn=n=>{const e=ewn.parse(n),t=e.w,i=e.h,r=e.id,o=[Ia(1,-t/2,i/2,r,r*1.5),Ia(2,-t/2,-i/2,r,r*1.5),Ia(3,t/2,-i/2,r,r*1.5),Ia(4,t/2,i/2,r,r*1.5)],s=[sV([{x:-t/2,y:-i/2},{x:-t/2,y:i/2}]),sV([{x:t/2,y:-i/2},{x:t/2,y:i/2}]),sV([{x:-t/2,y:0},{x:-t/5,y:0},{x:t/5*1/Math.sqrt(2),y:i/8}]),sV([{x:t/2,y:0},{x:t/5,y:0}])],a=Fo(0,i/2+.4,.5);return{circuitJson:[...o,...s,a],parameters:e}},QJe=Se({fn:R(),w:_t.default("22.58mm"),h:_t.optional(),left:_t.optional().default(20),right:_t.optional().default(20),top:_t.optional().default(2),bottom:_t.optional().default(2),p:_t.default(_t.parse("2.54mm")),pw:_t.default(_t.parse("1.6mm")),pl:_t.default(_t.parse("2.4mm")),innerhole:Je().default(!1),innerholeedgedistance:_t.default(_t.parse("1.61mm")),silkscreenlabels:Je().default(!1),silkscreenlabelmargin:_t.default(_t.parse("0.1mm"))}),nwn=n=>{const e=QJe.parse(n);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},aV=(n,e,t)=>{let i=[];return t==="right"&&(i=[{x:n+1/2,y:e},{x:n-1/2,y:e+.6/2},{x:n-1/2,y:e-.6/2},{x:n+1/2,y:e}]),t==="left"&&(i=[{x:n-1/2,y:e},{x:n+1/2,y:e+.6/2},{x:n+1/2,y:e-.6/2},{x:n-1/2,y:e}]),t==="top"&&(i=[{x:n,y:e+1/2},{x:n-.6/2,y:e-1/2},{x:n+.6/2,y:e-1/2},{x:n,y:e+1/2}]),t==="bottom"&&(i=[{x:n,y:e-1/2},{x:n-.6/2,y:e+1/2},{x:n+.6/2,y:e+1/2},{x:n,y:e-1/2}]),i},iwn=n=>{const e=QJe.parse(n),t=e.h??nwn(e),i=[],r=[],o=[];let s=[];const a=1,c=a,l=e.left+e.right+(e.bottom??0)+(e.top??0),d=`pin${l}`.length*.7/2;if(e.right){const _=-((e.right-1)/2)*e.p;for(let g=0;g<e.right;g++){if(g===0&&!e.left&&!e.bottom&&!e.silkscreenlabels&&(s=aV(e.w/2-e.pl*1.4,_+g*e.p,"right")),i.push(zr(g+1+e.left+(e.bottom??0),e.w/2-e.pl/2,_+g*e.p,e.pl,e.pw)),e.silkscreenlabels){const x=g+1+e.left+(e.bottom??0),b=`pin${x}`;o.push({type:"pcb_silkscreen_text",pcb_silkscreen_text_id:`pin_${x}`,pcb_component_id:"1",layer:"top",anchor_position:{x:e.w/2-e.pl-(d+e.silkscreenlabelmargin),y:_+g*e.p},text:b,font_size:.7,font:"tscircuit2024",anchor_alignment:"center"})}e.innerhole&&(r.push(Ia(g+1+e.left+(e.bottom??0)+l,e.w/2,_+g*e.p,a,c)),r.push(Ia(g+1+e.left+(e.bottom??0)+l*2,e.w/2-e.innerholeedgedistance,_+g*e.p,a,c)))}}if(e.left){const _=(e.left-1)/2*e.p;for(let g=0;g<e.left;g++){if(g===0&&!e.silkscreenlabels&&(s=aV(-e.w/2+e.pl*1.4,_-g*e.p,"left")),i.push(zr(g+1,-e.w/2+e.pl/2,_-g*e.p,e.pl,e.pw)),e.silkscreenlabels){const x=g+1,b=`pin${x}`;o.push({type:"pcb_silkscreen_text",pcb_silkscreen_text_id:`pin_${x}`,pcb_component_id:"1",layer:"top",anchor_position:{x:-e.w/2+e.pl+(d+e.silkscreenlabelmargin),y:_-g*e.p},text:b,font_size:.7,font:"tscircuit2024",anchor_alignment:"center"})}e.innerhole&&(r.push(Ia(g+1+l,-e.w/2,_-g*e.p,a,c)),r.push(Ia(g+1+l*2,-e.w/2+e.innerholeedgedistance,_-g*e.p,a,c)))}}if(e.top){const _=(e.top-1)/2*e.p;for(let g=0;g<e.top;g++){if(g===0&&!e.left&&!e.bottom&&!e.right&&!e.silkscreenlabels&&(s=aV(_-g*e.p,t/2-e.pl*1.4,"top")),i.push(zr(g+1+e.left+e.right+(e.bottom??0),_-g*e.p,t/2-e.pl/2,e.pw,e.pl)),e.silkscreenlabels){const x=g+1+e.left+e.right+(e.bottom??0),b=`pin${x}`;o.push({type:"pcb_silkscreen_text",pcb_silkscreen_text_id:`pin_${x}`,pcb_component_id:"1",layer:"top",anchor_position:{x:_-g*e.p,y:t/2-e.pl-(d+e.silkscreenlabelmargin)},text:b,font_size:.7,font:"tscircuit2024",anchor_alignment:"center",ccw_rotation:270})}e.innerhole&&(r.push(Ia(g+1+e.left+e.right+(e.bottom??0)+l,_-g*e.p,t/2,a,c)),r.push(Ia(g+1+e.left+e.right+(e.bottom??0)+l*2,_-g*e.p,t/2-e.innerholeedgedistance,a,c)))}}if(e.bottom){const _=-((e.bottom-1)/2)*e.p;for(let g=0;g<e.bottom;g++){if(g===0&&!e.left&&!e.silkscreenlabels&&(s=aV(_+g*e.p,-t/2+e.pl*1.4,"bottom")),i.push(zr(g+1+e.left,_+g*e.p,-t/2+e.pl/2,e.pw,e.pl)),e.silkscreenlabels){const x=g+1+e.left,b=`pin${x}`;o.push({type:"pcb_silkscreen_text",pcb_silkscreen_text_id:`pin_${x}`,pcb_component_id:"1",layer:"top",anchor_position:{x:_+g*e.p,y:-t/2+e.pl+(d+e.silkscreenlabelmargin)},text:b,font_size:.7,font:"tscircuit2024",anchor_alignment:"center",ccw_rotation:90})}e.innerhole&&(r.push(Ia(g+1+e.left+l,_+g*e.p,-t/2,a,c)),r.push(Ia(g+1+e.left+l*2,_+g*e.p,-t/2+e.innerholeedgedistance,a,c)))}}const h={type:"pcb_silkscreen_path",pcb_silkscreen_path_id:"pcb_silkscreen_triangle_1",pcb_component_id:"2",route:s,stroke_width:.1,layer:"top"},p={type:"pcb_silkscreen_path",pcb_silkscreen_path_id:"pcb_silkscreen_path_1",pcb_component_id:"1",route:[{x:-e.w/2,y:t/2},{x:e.w/2,y:t/2},{x:e.w/2,y:-t/2},{x:-e.w/2,y:-t/2},{x:-e.w/2,y:t/2}],stroke_width:.1,layer:"top"},m=Fo(0,t/1.8,t/25);return{circuitJson:[...i,...r,...o,p,...e.silkscreenlabels?[]:[h],m],parameters:e}},JJe=Se({fn:R(),w:_t.default("22.58mm"),h:_t.optional(),left:_t.optional().default(20),right:_t.optional().default(20),top:_t.optional().default(2),bottom:_t.optional().default(2),p:_t.default(_t.parse("2.54mm")),pw:_t.default(_t.parse("1.6mm")),pl:_t.default(_t.parse("3.2mm")),innerhole:Je().default(!1),innerholeedgedistance:_t.default(_t.parse("1.61mm"))}),rwn=n=>{const e=JJe.parse(n);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},own=(n,e,t,i=1,r=.6)=>{const o=i/2,s=r/2;return{left:[{x:n+o,y:e},{x:n-o,y:e+s},{x:n-o,y:e-s},{x:n+o,y:e}],right:[{x:n-o,y:e},{x:n+o,y:e+s},{x:n+o,y:e-s},{x:n-o,y:e}],top:[{x:n,y:e-o},{x:n-s,y:e+o},{x:n+s,y:e+o},{x:n,y:e-o}],bottom:[{x:n,y:e+o},{x:n-s,y:e-o},{x:n+s,y:e-o},{x:n,y:e+o}]}[t]},swn=n=>{const e=JJe.parse(n),t=e.h??rwn(e),i=[],r=[],o=[],s=1,a=1.2,c=e.left+e.right+(e.bottom??0)+(e.top??0);let l=[],u=1;if(e.left){const m=(e.left-1)/2*e.p;for(let _=0;_<e.left;_++)_===0&&(l=own(-e.w/2-e.pl/2,m-_*e.p,"left")),i.push(zr(u,-e.w/2+e.pl/2,m-_*e.p,e.pl,e.pw)),r.push({type:"pcb_silkscreen_text",pcb_silkscreen_text_id:`pin_${u}`,pcb_component_id:"1",layer:"top",anchor_position:{x:-e.w/2+e.pl/2-4.5,y:m-_*e.p},text:`pin${u}`,font_size:.7,font:"tscircuit2024",anchor_alignment:"center"}),u++,e.innerhole&&o.push(Ia(u+c,-e.w/2+e.innerholeedgedistance,m-_*e.p,s,a))}if(e.bottom){const m=(e.bottom-1)/2*e.p;for(let _=e.bottom-1;_>=0;_--)i.push(zr(u,m-_*e.p,-t/2+e.pl/2,e.pw,e.pl)),r.push({type:"pcb_silkscreen_text",pcb_silkscreen_text_id:`pin_${u}`,pcb_component_id:"1",layer:"top",anchor_position:{x:m-_*e.p,y:-t/2+e.pl/2-3.2},text:`pin${u}`,font_size:.7,font:"tscircuit2024",anchor_alignment:"center"}),u++,e.innerhole&&o.push(Ia(u+c,m-_*e.p,-t/2+e.innerholeedgedistance,s,a))}if(e.right){const m=-((e.right-1)/2)*e.p;for(let _=0;_<e.right;_++)i.push(zr(u,e.w/2-e.pl/2,m+_*e.p,e.pl,e.pw)),r.push({type:"pcb_silkscreen_text",pcb_silkscreen_text_id:`pin_${u}`,pcb_component_id:"1",layer:"top",anchor_position:{x:e.w/2-e.pl/2+3.7,y:m+_*e.p},text:`pin${u}`,font_size:.7,font:"tscircuit2024",anchor_alignment:"center"}),u++,e.innerhole&&o.push(Ia(u+c,e.w/2-e.innerholeedgedistance,m+_*e.p,s,a))}if(e.top){const m=-((e.top-1)/2)*e.p;for(let _=e.top-1;_>=0;_--)i.push(zr(u,m+_*e.p,t/2-e.pl/2,e.pw,e.pl)),r.push({type:"pcb_silkscreen_text",pcb_silkscreen_text_id:`pin_${u}`,pcb_component_id:"1",layer:"top",anchor_position:{x:m+_*e.p,y:t/2-e.pl/2+3.2},text:`pin${u}`,font_size:.7,font:"tscircuit2024",anchor_alignment:"center"}),u++,e.innerhole&&o.push(Ia(u+c,m+_*e.p,t/2-e.innerholeedgedistance,s,a))}const d={type:"pcb_silkscreen_path",pcb_silkscreen_path_id:"1",pcb_component_id:"1",layer:"top",route:l,stroke_width:.1},h={type:"pcb_silkscreen_path",pcb_silkscreen_path_id:"pcb_silkscreen_path_1",pcb_component_id:"1",route:[{x:-e.w/2-e.pl/3,y:t/2+e.pl/3},{x:e.w/2+e.pl/3,y:t/2+e.pl/3},{x:e.w/2+e.pl/3,y:-t/2-e.pl/3},{x:-e.w/2-e.pl/3,y:-t/2-e.pl/3},{x:-e.w/2-e.pl/3,y:t/2+e.pl/3}],stroke_width:.1,layer:"top"},p=Fo(0,t/1.8,t/25);return{circuitJson:[...o,...i,...r,h,d,p],parameters:e}},awn=n=>(n.legsoutside=!0,o8(n)),eet=Se({fn:R(),w:_t.default("10mm"),h:_t.optional(),left:_t.optional().default(20),right:_t.optional().default(20),top:_t.optional().default(0),bottom:_t.optional().default(0),p:_t.default(_t.parse("2.54mm")),id:_t.optional().default(_t.parse("1mm")),od:_t.optional().default(_t.parse("1.5mm"))}),cwn=n=>{const e=eet.parse(n);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},cV=(n,e,t,i=1,r=.6)=>{const o=i/2,s=r/2;return{left:[{x:n+o,y:e},{x:n-o,y:e+s},{x:n-o,y:e-s},{x:n+o,y:e}],right:[{x:n-o,y:e},{x:n+o,y:e+s},{x:n+o,y:e-s},{x:n-o,y:e}],top:[{x:n,y:e-o},{x:n-s,y:e+o},{x:n+s,y:e+o},{x:n,y:e-o}],bottom:[{x:n,y:e+o},{x:n-s,y:e-o},{x:n+s,y:e-o},{x:n,y:e+o}]}[t]},lwn=n=>{const e=eet.parse(n),t=e.h??cwn(e),i=[],r=e.id,o=e.od;let s=[];if(e.right){const u=-((e.right-1)/2)*e.p;for(let d=0;d<e.right;d++)d===0&&!e.left&&!e.bottom&&(s=cV(e.w/2+o*1.4,u+d*e.p,"right")),i.push(Ia(d+1+e.left+(e.bottom??0),e.w/2,u+d*e.p,r,o))}if(e.left){const u=-((e.left-1)/2)*e.p;for(let d=0;d<e.left;d++)d===e.left-1&&(s=cV(-e.w/2-o*1.4,u+d*e.p,"left")),i.push(Ia(d+1,-e.w/2,u+d*e.p,r,o))}if(e.top){const u=-((e.top-1)/2)*e.p;for(let d=0;d<e.top;d++)d===e.top-1&&!e.left&&!e.bottom&&!e.right&&(s=cV(u+d*e.p,t/2+o*1.4,"top")),i.push(Ia(d+1+e.right+(e.bottom??0)+e.left,u+d*e.p,t/2,r,o))}if(e.bottom){const u=-((e.bottom-1)/2)*e.p;for(let d=0;d<e.bottom;d++)d===0&&!e.left&&(s=cV(u+d*e.p,-t/2-o*1.4,"bottom")),i.push(Ia(d+1+e.left,u+d*e.p,-t/2,r,o))}const a={type:"pcb_silkscreen_path",pcb_silkscreen_path_id:"1",pcb_component_id:"1",layer:"top",route:s,stroke_width:.1},c={type:"pcb_silkscreen_path",pcb_silkscreen_path_id:"pcb_silkscreen_path_1",pcb_component_id:"1",route:[{x:-e.w/2-o,y:t/2+o},{x:e.w/2+o,y:t/2+o},{x:e.w/2+o,y:-t/2-o},{x:-e.w/2-o,y:-t/2-o},{x:-e.w/2-o,y:t/2+o}],stroke_width:.1,layer:"top"},l=Fo(0,t/1.7,t/25);return{circuitJson:[...i,c,l,a],parameters:e}},tet=(n,e,t,i)=>Array.from({length:25},(r,o)=>{const s=o/24*Math.PI-Math.PI/2;return{x:n+(i==="right"?1:-1)*Math.cos(s)*t,y:e+Math.sin(s)*t}}),uwn=Se({fn:R(),p:_t.optional().default("4.88mm"),id:_t.optional().default("0.6mm"),od:_t.optional().default("1.2mm"),w:_t.optional().default("5.6mm"),h:_t.optional().default("3.5mm")}),dwn=n=>{const e=uwn.parse(n),{p:t,id:i,od:r,w:o,h:s}=e,a=s/2,c=[Ia(1,-t/2,0,i,r),Ia(2,t/2,0,i,r)],l=tet(-o/2,0,a,"left"),u=tet(o/2,0,a,"right"),d={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[...l,...l.slice(1).reverse(),{x:-o/2,y:-s/2},{x:o/2,y:-s/2},...u,{x:o/2,y:s/2},{x:-o/2,y:s/2}],stroke_width:.1,pcb_silkscreen_path_id:""},h=Fo(0,t/4,.5);return{circuitJson:[...c,d,h],parameters:e}};Se({w:_t,h:_t});var hwn=n=>{const{w:e,h:t}=n,i=gh(e),r=gh(t);return{circuitJson:[zr(1,0,0,i,r),Fo(0,r/2+.5,.2)],parameters:n}},pwn=Se({fn:R(),num_pins:Bn([pe(3),pe(2)]).default(3),p:R().default("1.27mm"),id:R().default("0.72mm"),od:R().default("0.95mm"),w:R().default("4.5mm"),h:R().default("4.5mm"),inline:Je().default(!1),string:R().optional()}),fwn=(n,e,t)=>Array.from({length:25},(i,r)=>{const o=r/24*Math.PI;return{x:n+Math.cos(o)*t,y:e+Math.sin(o)*t}}),mwn=n=>{const{p:e,id:t,od:i,h:r}=n,o=Number.parseFloat(r)/2,s=Number.parseFloat(e);return[Ia(1,-s,o-s,t,i),Ia(2,s,o-s,t,i)]},_wn=n=>{const e=n.string?.match(/^to92_(\d+)/),t=e?Number.parseInt(e[1],10):3,i=pwn.parse({...n,num_pins:t}),{p:r,id:o,od:s,w:a,h:c,inline:l}=i,u=Number.parseFloat(c)/2,d=Number.parseFloat(r);let h=[];if(i.num_pins===3)h=l?[Ia(1,-d,u-d,o,s),Ia(2,0,u-d,o,s),Ia(3,d,u-d,o,s)]:[Ia(1,0,u,o,s),Ia(2,-d,u-d,o,s),Ia(3,d,u-d,o,s)];else if(i.num_pins===2)h=mwn(i);else throw new Error("Invalid number of pins for TO-92");const p=Number.parseFloat(a)/2,m=fwn(0,u,p),_={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[...m,{x:-p,y:0},{x:p,y:0},m[0]],stroke_width:.1,pcb_silkscreen_path_id:""},g=Fo(0,u+1,.5);return{circuitJson:[...h,_,g],parameters:i}},ywn=Se({fn:R(),num_pins:pe(2).default(2),w:R().default("2.15mm"),h:R().default("1.20mm"),pl:R().default("0.5mm"),pw:R().default("0.6mm"),p:R().default("1.4mm")}),gwn=n=>{const e=ywn.parse(n),t=Fo(0,_t.parse(e.h),.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:_t.parse(e.p)/2,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2-.2,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2-.2,y:-_t.parse(e.h)/2},{x:_t.parse(e.p)/2,y:-_t.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:bwn(e).concat(i,t),parameters:e}},xwn=n=>{const{pn:e,p:t}=n;return e===1?{x:-t/2,y:0}:{x:t/2,y:0}},bwn=n=>{const e=[];for(let t=1;t<=n.num_pins;t++){const{x:i,y:r}=xwn({pn:t,p:Number.parseFloat(n.p)});e.push(zr(t,i,r,Number.parseFloat(n.pl),Number.parseFloat(n.pw)))}return e},vwn=X2({}),wwn=n=>{const e=vwn.parse(n),t=[];for(let s=0;s<e.num_pins;s++){const{x:a,y:c}=mye({num_pins:e.num_pins,pn:s+1,w:e.w,p:e.p??1.27,pl:e.pl,widthincludeslegs:!0});t.push(zr(s+1,a,c,e.pl??"1.5mm",e.pw??"0.6mm"))}const i=(e.num_pins/2-1)*e.p+e.pw,r=Fo(0,i/2-.5,i/12),o={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"",type:"pcb_silkscreen_path",route:[{x:-e.w/3,y:i/2+.2},{x:e.w/3,y:i/2+.2}],stroke_width:.1};return{circuitJson:[...t,r,o],parameters:e}},Swn=Se({fn:R(),num_pins:pe(2).default(2),w:R().default("5.0mm"),h:R().default("2.30mm"),pl:R().default("1.25mm"),pw:R().default("2mm"),p:R().default("3.75mm")}),Ewn=n=>{const e=Swn.parse(n),t=Fo(0,_t.parse(e.h)/2+1,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:_t.parse(e.p)/2+.5,y:_t.parse(e.h)/2+.5},{x:-_t.parse(e.w)/2-.5,y:_t.parse(e.h)/2+.5},{x:-_t.parse(e.w)/2-.5,y:-_t.parse(e.h)/2-.5},{x:_t.parse(e.p)/2+.5,y:-_t.parse(e.h)/2-.5}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:Mwn(e).concat(i,t),parameters:e}},Twn=n=>{const{pn:e,p:t}=n;return e===1?{x:-t/2,y:0}:{x:t/2,y:0}},Mwn=n=>{const e=[];for(let t=1;t<=n.num_pins;t++){const{x:i,y:r}=Twn({pn:t,p:Number.parseFloat(n.p)});e.push(zr(t,i,r,Number.parseFloat(n.pl),Number.parseFloat(n.pw)))}return e},Cwn=Se({fn:R(),num_pins:pe(2).default(2),w:R().default("4.4mm"),h:R().default("2.1mm"),pl:R().default("1.2mm"),pw:R().default("1.2mm"),p:R().default("2.9mm")}),Awn=n=>{const e=Cwn.parse(n),t=Fo(0,_t.parse(e.h)-.5,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:_t.parse(e.p)/2,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2-.2,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2-.2,y:-_t.parse(e.h)/2},{x:_t.parse(e.p)/2,y:-_t.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:Rwn(e).concat(i,t),parameters:e}},Pwn=n=>{const{pn:e,p:t}=n;return e===1?{x:-t/2,y:0}:{x:t/2,y:0}},Rwn=n=>{const e=[];for(let t=1;t<=n.num_pins;t++){const{x:i,y:r}=Pwn({pn:t,p:Number.parseFloat(n.p)});e.push(zr(t,i,r,Number.parseFloat(n.pl),Number.parseFloat(n.pw)))}return e},Iwn=Se({fn:R(),num_pins:pe(2).default(2),w:R().default("3.30mm"),h:R().default("1.80mm"),pl:R().default("0.60mm"),pw:R().default("0.45mm"),p:R().default("2.1mm")}),Nwn=n=>{const e=Iwn.parse(n),t=Fo(0,_t.parse(e.h)-.5,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:_t.parse(e.p)/2,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2,y:-_t.parse(e.h)/2},{x:_t.parse(e.p)/2,y:-_t.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:Own(e).concat(i,t),parameters:e}},kwn=n=>{const{pn:e,p:t}=n;return e===1?{x:-t/2,y:0}:{x:t/2,y:0}},Own=n=>{const e=[];for(let t=1;t<=n.num_pins;t++){const{x:i,y:r}=kwn({pn:t,p:Number.parseFloat(n.p)});e.push(zr(t,i,r,Number.parseFloat(n.pl),Number.parseFloat(n.pw)))}return e},Lwn=Se({fn:R(),num_pins:pe(2).default(2),w:R().default("1.4mm"),h:R().default("0.9mm"),pl:R().default("0.35mm"),pw:R().default("0.25mm"),p:R().default("1.2mm")}),Dwn=n=>{const e=Lwn.parse(n),t=Fo(0,_t.parse(e.h),.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:_t.parse(e.p)/2+.15,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2-.4,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2-.4,y:-_t.parse(e.h)/2},{x:_t.parse(e.p)/2+.15,y:-_t.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:$wn(e).concat(i,t),parameters:e}},zwn=n=>{const{pn:e,p:t}=n;return e===1?{x:-t/2,y:0}:{x:t/2,y:0}},$wn=n=>{const e=[];for(let t=1;t<=n.num_pins;t++){const{x:i,y:r}=zwn({pn:t,p:Number.parseFloat(n.p)});e.push(zr(t,i,r,Number.parseFloat(n.pl),Number.parseFloat(n.pw)))}return e},Fwn=Se({fn:R(),num_pins:pe(2).default(2),w:R().default("1.3mm"),h:R().default("0.9mm"),pl:R().default("0.4mm"),pw:R().default("0.7mm"),p:R().default("0.7mm")}),Uwn=n=>{const e=Fwn.parse(n),t=Fo(0,_t.parse(e.h)+.1,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:_t.parse(e.p)/2+.2,y:_t.parse(e.h)/2+.2},{x:-_t.parse(e.w)/2-.2,y:_t.parse(e.h)/2+.2},{x:-_t.parse(e.w)/2-.2,y:-_t.parse(e.h)/2-.2},{x:_t.parse(e.p)/2+.2,y:-_t.parse(e.h)/2-.2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:jwn(e).concat(i,t),parameters:e}},Bwn=n=>{const{pn:e,p:t}=n;return e===1?{x:-t/2,y:0}:{x:t/2,y:0}},jwn=n=>{const e=[];for(let t=1;t<=n.num_pins;t++){const{x:i,y:r}=Bwn({pn:t,p:Number.parseFloat(n.p)});e.push(zr(t,i,r,Number.parseFloat(n.pl),Number.parseFloat(n.pw)))}return e},Hwn=Se({fn:R(),num_pins:pe(2).default(2),w:R().default("3,05mm"),h:R().default("1.65mm"),pl:R().default("0.6mm"),pw:R().default("0.6mm"),pad_spacing:R().default("2.2mm")}),Vwn=n=>{const e=Hwn.parse(n),t=Fo(0,_t.parse(e.h),.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:_t.parse(e.pad_spacing)/2,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2-.2,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2-.2,y:-_t.parse(e.h)/2},{x:_t.parse(e.pad_spacing)/2,y:-_t.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:Ywn(e).concat(i,t),parameters:e}},Gwn=n=>{const{pn:e,pad_spacing:t}=n;return e===1?{x:-t/2,y:0}:{x:t/2,y:0}},Ywn=n=>{const e=[];for(let t=1;t<=n.num_pins;t++){const{x:i,y:r}=Gwn({pn:t,pad_spacing:Number.parseFloat(n.pad_spacing)});e.push(zr(t,i,r,Number.parseFloat(n.pl),Number.parseFloat(n.pw)))}return e},qwn=Se({fn:R(),num_pins:pe(2).default(2),w:R().default("4.4mm"),h:R().default("2.1mm"),pl:R().default("1.2mm"),pw:R().default("1.2mm"),p:R().default("2.9mm")}),Xwn=n=>{const e=qwn.parse(n),t=Fo(0,_t.parse(e.h),.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:_t.parse(e.p)/2,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2-.2,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2-.2,y:-_t.parse(e.h)/2},{x:_t.parse(e.p)/2,y:-_t.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:Kwn(e).concat(i,t),parameters:e}},Wwn=n=>{const{pn:e,p:t}=n;return e===1?{x:-t/2,y:0}:{x:t/2,y:0}},Kwn=n=>{const e=[];for(let t=1;t<=n.num_pins;t++){const{x:i,y:r}=Wwn({pn:t,p:Number.parseFloat(n.p)});e.push(zr(t,i,r,Number.parseFloat(n.pl),Number.parseFloat(n.pw)))}return e},Zwn=Se({fn:R(),num_pins:pe(2).default(2),w:R().default("4.4mm"),h:R().default("2.1mm"),pl:R().default("0.91mm"),pw:R().default("1.22mm"),p:R().default("3.146mm")}),Qwn=n=>{const e=Zwn.parse(n),t=Fo(0,_t.parse(e.h),.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:_t.parse(e.p)/2,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2-.2,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2-.2,y:-_t.parse(e.h)/2},{x:_t.parse(e.p)/2,y:-_t.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:eSn(e).concat(i,t),parameters:e}},Jwn=n=>{const{pn:e,p:t}=n;return e===1?{x:-t/2,y:0}:{x:t/2,y:0}},eSn=n=>{const e=[];for(let t=1;t<=n.num_pins;t++){const{x:i,y:r}=Jwn({pn:t,p:Number.parseFloat(n.p)});e.push(zr(t,i,r,Number.parseFloat(n.pl),Number.parseFloat(n.pw)))}return e},tSn=Se({fn:R(),num_pins:pe(2).default(2),w:R().default("1.80mm"),h:R().default("1.00mm"),pl:R().default("0.66mm"),pw:R().default("0.5mm"),p:R().default("0.8mm")}),nSn=n=>{const e=tSn.parse(n),t=Fo(0,_t.parse(e.h),.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:_t.parse(e.p)/2,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2-.1,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2-.1,y:-_t.parse(e.h)/2},{x:_t.parse(e.p)/2,y:-_t.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:rSn(e).concat(i,t),parameters:e}},iSn=n=>{const{pn:e,p:t}=n;return e===1?{x:-t/2,y:0}:{x:t/2,y:0}},rSn=n=>{const e=[];for(let t=1;t<=n.num_pins;t++){const{x:i,y:r}=iSn({pn:t,p:Number.parseFloat(n.p)});e.push(zr(t,i,r,Number.parseFloat(n.pl),Number.parseFloat(n.pw)))}return e},oSn=Se({fn:R(),num_pins:pe(2).default(2),w:R().default("6.2mm"),h:R().default("3.4mm"),pl:R().default("1.4mm"),pw:R().default("2.1mm"),p:R().default("4.4mm")}),sSn=n=>{const e=oSn.parse(n),t=Fo(0,_t.parse(e.h)/2+.4,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:_t.parse(e.p)/2,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2-.2,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2-.2,y:-_t.parse(e.h)/2},{x:_t.parse(e.p)/2,y:-_t.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:cSn(e).concat(i,t),parameters:e}},aSn=n=>{const{pn:e,p:t}=n;return e===1?{x:-t/2,y:0}:{x:t/2,y:0}},cSn=n=>{const e=[];for(let t=1;t<=n.num_pins;t++){const{x:i,y:r}=aSn({pn:t,p:Number.parseFloat(n.p)});e.push(zr(t,i,r,Number.parseFloat(n.pl),Number.parseFloat(n.pw)))}return e},lSn=Se({fn:R(),num_pins:Bn([pe(3),pe(5)]).default(3),w:R().default("4.80mm"),h:R().default("4.80mm"),pl:R().default("1.3mm"),pw:R().default("0.9mm"),p:R().default("1.5mm"),string:R().optional()}),uSn=n=>{const e=[],t=Number.parseFloat(n.p),i=Number.parseFloat(n.pw),r=Number.parseFloat(n.w),o=Number.parseFloat(n.pl);e.push(zr(1,-r/2,t,o,i),zr(2,-r/2+(1.5-1.3)/2,0,1.5,i),zr(3,-r/2,-t,o,i));const s=Fo(0,0,.3),a=Number.parseFloat(n.w)/2-1,c=Number.parseFloat(n.h)/2,l={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-a,y:c},{x:a,y:c},{x:a,y:c/2+.5}],type:"pcb_silkscreen_path",stroke_width:.1},u={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_2",route:[{x:-a,y:-c},{x:a,y:-c},{x:a,y:-c/2-.5}],type:"pcb_silkscreen_path",stroke_width:.1};return[...e,l,u,s]},dSn=n=>{const e=[];Number.parseFloat(n.p),Number.parseFloat(n.pw),Number.parseFloat(n.w),e.push(zr(1,-1.85,-1.5,1.5,.7),zr(2,-1.85,1.5,1.5,.7),zr(3,0,0,.8,2),zr(4,1.85,-1.5,1.5,.7),zr(5,1.85,1.5,1.5,.7));const t=Fo(0,Number.parseFloat(n.h)/2+.5,.3),i=Number.parseFloat(n.w)/2-1,r=Number.parseFloat(n.h)/2,o={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-i,y:r},{x:i,y:r}],type:"pcb_silkscreen_path",stroke_width:.1},s={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_2",route:[{x:-i,y:-r},{x:i,y:-r}],type:"pcb_silkscreen_path",stroke_width:.1};return[...e,o,s,t]},hSn=n=>{const e=n.string?.match(/^sot89_(\d+)/),t=e?Number.parseInt(e[1],10):3,i=lSn.parse({...n,num_pins:t});if(i.num_pins===3)return{circuitJson:uSn(i),parameters:i};if(i.num_pins===5)return{circuitJson:dSn(i),parameters:i};throw new Error("Invalid number of pins for SOT89")},pSn=Se({fn:R(),p:_t.optional().default("5.0mm"),id:_t.optional().default("1.0mm"),od:_t.optional().default("1.9mm"),w:_t.optional().default("13mm"),h:_t.optional().default("7mm"),num_pins:Pe().optional(),string:R().optional()}),fSn=n=>{const e=pSn.parse(n),{fn:t,id:i,od:r,w:o,h:s,string:a}=e,c=Number.parseInt(a?.split("_")[1]??"3"),l=-1,u=o/2,d=s/2,h=2.5,p=o*.4,m=Math.max(h,p/(c-1)),_=Array.from({length:c},(N,A)=>{const I=c%2===0?(A-c/2+.5)*m:(A-Math.floor(c/2))*m;return Ia(A+1,I,l,i,r)}),g={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-u,y:-d},{x:u,y:-d},{x:u,y:d},{x:-u,y:d},{x:-u,y:-d}],stroke_width:.1,pcb_silkscreen_path_id:""},x=-d+2*s/3,b={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-u,y:x},{x:u,y:x}],stroke_width:.1,pcb_silkscreen_path_id:""},w=[{type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-o/6,y:x},{x:-o/6,y:d}],stroke_width:.1,pcb_silkscreen_path_id:""},{type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:o/6,y:x},{x:o/6,y:d}],stroke_width:.1,pcb_silkscreen_path_id:""}],E=Fo(0,s/2+.6,.5);return{circuitJson:[..._,g,b,...w,E],parameters:{...e,p:m}}},mSn=Se({fn:R(),num_pins:pe(2).default(2),w:R().default("5.40mm"),h:R().default("2.30mm"),pl:R().default("1.30mm"),pw:R().default("1.70mm"),p:R().default("3.5mm")}),_Sn=n=>{const e=mSn.parse(n),t=Fo(0,_t.parse(e.h)/2+.4,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:_t.parse(e.p)/2,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2,y:-_t.parse(e.h)/2},{x:_t.parse(e.p)/2,y:-_t.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:gSn(e).concat(i,t),parameters:e}},ySn=n=>{const{pn:e,p:t}=n;return e===1?{x:-t/2,y:0}:{x:t/2,y:0}},gSn=n=>{const e=[];for(let t=1;t<=n.num_pins;t++){const{x:i,y:r}=ySn({pn:t,p:Number.parseFloat(n.p)});e.push(zr(t,i,r,Number.parseFloat(n.pl),Number.parseFloat(n.pw)))}return e},xSn=Se({fn:R(),num_pins:pe(2).default(2),w:R().default("1.90mm"),h:R().default("1.33mm"),pl:R().default("0.5mm"),pw:R().default("0.7mm"),p:R().default("0.8mm")}),bSn=n=>{const e=xSn.parse(n),t=Fo(0,_t.parse(e.h)+.1,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:_t.parse(e.p)/2+.1,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2,y:-_t.parse(e.h)/2},{x:_t.parse(e.p)/2+.1,y:-_t.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:wSn(e).concat(i,t),parameters:e}},vSn=n=>{const{pn:e,p:t}=n;return e===1?{x:-t/2,y:0}:{x:t/2,y:0}},wSn=n=>{const e=[];for(let t=1;t<=n.num_pins;t++){const{x:i,y:r}=vSn({pn:t,p:Number.parseFloat(n.p)});e.push(zr(t,i,r,Number.parseFloat(n.pl),Number.parseFloat(n.pw)))}return e},SSn=Se({fn:R(),num_pins:pe(2).default(2),w:R().default("7.0mm"),h:R().default("3.35mm"),pl:R().default("1.50mm"),pw:R().default("2.70mm"),p:R().default("4.8mm")}),ESn=n=>{const e=SSn.parse(n),t=Fo(0,_t.parse(e.h),.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:_t.parse(e.p)/2,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2,y:-_t.parse(e.h)/2},{x:_t.parse(e.p)/2,y:-_t.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:MSn(e).concat(i,t),parameters:e}},TSn=n=>{const{pn:e,p:t}=n;return e===1?{x:-t/2,y:0}:{x:t/2,y:0}},MSn=n=>{const e=[];for(let t=1;t<=n.num_pins;t++){const{x:i,y:r}=TSn({pn:t,p:Number.parseFloat(n.p)});e.push(zr(t,i,r,Number.parseFloat(n.pl),Number.parseFloat(n.pw)))}return e},CSn=Se({fn:R(),num_pins:pe(2).default(2),w:R().default("3.0mm"),h:R().default("1.80mm"),pl:R().default("0.80mm"),pw:R().default("1.20mm"),p:R().default("1.6mm")}),ASn=n=>{const e=CSn.parse(n),t=Fo(0,_t.parse(e.h),.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:_t.parse(e.p)/2,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2-.1,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2-.1,y:-_t.parse(e.h)/2},{x:_t.parse(e.p)/2,y:-_t.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:RSn(e).concat(i,t),parameters:e}},PSn=n=>{const{pn:e,p:t}=n;return e===1?{x:-t/2,y:0}:{x:t/2,y:0}},RSn=n=>{const e=[];for(let t=1;t<=n.num_pins;t++){const{x:i,y:r}=PSn({pn:t,p:Number.parseFloat(n.p)});e.push(zr(t,i,r,Number.parseFloat(n.pl),Number.parseFloat(n.pw)))}return e},ISn=Se({fn:R(),num_pins:pe(2).default(2),w:R().default("7.10mm"),h:R().default("3.40mm"),pl:R().default("2.45mm"),pw:R().default("1.80mm"),p:R().default("4.05mm")}),NSn=n=>{const e=ISn.parse(n),t=Fo(0,_t.parse(e.h)/2+.5,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:_t.parse(e.p)/2,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2-.5,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2-.5,y:-_t.parse(e.h)/2},{x:_t.parse(e.p)/2,y:-_t.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:OSn(e).concat(i,t),parameters:e}},kSn=n=>{const{pn:e,p:t}=n;return e===1?{x:-t/2,y:0}:{x:t/2,y:0}},OSn=n=>{const e=[];for(let t=1;t<=n.num_pins;t++){const{x:i,y:r}=kSn({pn:t,p:Number.parseFloat(n.p)});e.push(zr(t,i,r,Number.parseFloat(n.pl),Number.parseFloat(n.pw)))}return e},LSn=Se({fn:R(),num_pins:pe(2).default(2),w:R().default("4.80mm"),h:R().default("2.10mm"),pl:R().default("1.30mm"),pw:R().default("1.40mm"),p:R().default("2.9mm")}),DSn=n=>{const e=LSn.parse(n),t=Fo(0,_t.parse(e.h)-.5,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:_t.parse(e.p)/2,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2,y:-_t.parse(e.h)/2},{x:_t.parse(e.p)/2,y:-_t.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:$Sn(e).concat(i,t),parameters:e}},zSn=n=>{const{pn:e,p:t}=n;return e===1?{x:-t/2,y:0}:{x:t/2,y:0}},$Sn=n=>{const e=[];for(let t=1;t<=n.num_pins;t++){const{x:i,y:r}=zSn({pn:t,p:Number.parseFloat(n.p)});e.push(zr(t,i,r,Number.parseFloat(n.pl),Number.parseFloat(n.pw)))}return e},FSn=Se({fn:R(),num_pins:pe(2).default(2),w:R().default("7.30mm"),h:R().default("4.40mm"),pl:R().default("2.50mm"),pw:R().default("2.30mm"),p:R().default("4.30mm")}),USn=n=>{const e=FSn.parse(n),t=Fo(0,_t.parse(e.h)/2+.5,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:_t.parse(e.p)/2,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2-.1,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2-.1,y:-_t.parse(e.h)/2},{x:_t.parse(e.p)/2,y:-_t.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:jSn(e).concat(i,t),parameters:e}},BSn=n=>{const{pn:e,p:t}=n;return e===1?{x:-t/2,y:0}:{x:t/2,y:0}},jSn=n=>{const e=[];for(let t=1;t<=n.num_pins;t++){const{x:i,y:r}=BSn({pn:t,p:Number.parseFloat(n.p)});e.push(zr(t,i,r,Number.parseFloat(n.pl),Number.parseFloat(n.pw)))}return e},HSn=Se({fn:R(),num_pins:pe(2).default(2),w:R().default("10.70mm"),h:R().default("6.60mm"),pl:R().default("3.30mm"),pw:R().default("2.50mm"),p:R().default("6.80mm")}),VSn=n=>{const e=HSn.parse(n),t=Fo(0,3,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:_t.parse(e.p)/2,y:_t.parse(e.h)/2-.8},{x:-_t.parse(e.w)/2-.8,y:_t.parse(e.h)/2-.8},{x:-_t.parse(e.w)/2-.8,y:-_t.parse(e.h)/2+.8},{x:_t.parse(e.p)/2,y:-_t.parse(e.h)/2+.8}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:YSn(e).concat(i,t),parameters:e}},GSn=n=>{const{pn:e,p:t}=n;return e===1?{x:-t/2,y:0}:{x:t/2,y:0}},YSn=n=>{const e=[];for(let t=1;t<=n.num_pins;t++){const{x:i,y:r}=GSn({pn:t,p:Number.parseFloat(n.p)});e.push(zr(t,i,r,Number.parseFloat(n.pl),Number.parseFloat(n.pw)))}return e},qSn=Se({fn:R(),num_pins:Pe().default(4),w:R().default("8.50mm"),h:R().default("6.90mm"),pl:R().default("2mm"),pw:R().default("1.5mm"),p:R().default("2.30mm"),string:R().optional()}),XSn=n=>{const e=n.string?.match(/^sot223_(\d+)/),t=e?Number.parseInt(e[1],10):4;if(t===8){const r=ZSn.parse({...n,num_pins:t});return{circuitJson:H5(r),parameters:r}}const i=qSn.parse({...n,num_pins:t});if(i.num_pins===4)return{circuitJson:KSn(i),parameters:i};if(i.num_pins===5)return{circuitJson:JSn(i),parameters:i};if(i.num_pins===6)return{circuitJson:t2n(i),parameters:i};throw new Error("Invalid number of pins")},WSn=n=>{const{pn:e,w:t,p:i}=n;return e===1?{x:-t/2+1.1,y:i}:e===2?{x:-t/2+1.1,y:0}:e===3?{x:-t/2+1.1,y:-i}:{x:t/2-1.1,y:0}},KSn=n=>{const e=[];for(let a=0;a<n.num_pins;a++){const{x:c,y:l}=WSn({num_pins:n.num_pins,pn:a+1,w:Number.parseFloat(n.w),h:Number.parseFloat(n.h),pl:Number.parseFloat(n.pl),p:Number.parseFloat(n.p)}),u=a===3?3.8:Number.parseFloat(n.pw);e.push(zr(a+1,c,l,Number.parseFloat(n.pl),u))}const t=Fo(0,0,.3),i=Number.parseFloat(n.w)/2-2.4,r=Number.parseFloat(n.h)/2,o={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-i,y:r},{x:i,y:r},{x:i,y:r/2+.5}],type:"pcb_silkscreen_path",stroke_width:.1},s={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_2",route:[{x:-i,y:-r},{x:i,y:-r},{x:i,y:-r/2-.5}],type:"pcb_silkscreen_path",stroke_width:.1};return[...e,o,s,t]},ZSn=X2({p:"0.90mm",w:"2.8mm",legsoutside:!0}),QSn=n=>{const{p:e,pn:t,w:i}=n;if(t===1)return{x:-i/2+1.2,y:e/2+e};if(t===2)return{x:-i/2+1.2,y:e/2};if(t===3)return{x:-i/2+1.2,y:-e/2};if(t===4)return{x:-i/2+1.2,y:-e/2-e};if(t===5)return{x:i/2-1,y:0};throw new Error("Invalid pin number")},JSn=n=>{const e=[];for(let a=1;a<=n.num_pins;a++){const{x:c,y:l}=QSn({h:Number.parseFloat(n.h),p:1.5,pn:a,w:Number.parseFloat(n.w)});let u=Number.parseFloat(n.pw),d=Number.parseFloat(n.pl);a===5?(u=3.4,d=1.8):(u=1,d=2.2),e.push(zr(a,c,l,d,u))}const t=Number.parseFloat(n.w)/2-2.4,i=Number.parseFloat(n.h)/2,r={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-t,y:i},{x:t,y:i},{x:t,y:i/2+.5}],type:"pcb_silkscreen_path",stroke_width:.1},o={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_2",route:[{x:-t,y:-i},{x:t,y:-i},{x:t,y:-i/2-.5}],type:"pcb_silkscreen_path",stroke_width:.1},s=Fo(0,0,.3);return[...e,r,o,s]},e2n=n=>{const{p:e,pn:t,w:i}=n;if(t===1)return{x:-i/2+1.2,y:2*e};if(t===2)return{x:-i/2+1.2,y:e};if(t===3)return{x:-i/2+1.2,y:0};if(t===4)return{x:-i/2+1.2,y:-e};if(t===5)return{x:-i/2+1.2,y:-2*e};if(t===6)return{x:i/2-1.175,y:0};throw new Error("Invalid pin number")},t2n=n=>{const e=[];for(let a=1;a<=n.num_pins;a++){const{x:c,y:l}=e2n({h:Number.parseFloat(n.h),p:1.3,pn:a,w:8.7});let u=Number.parseFloat(n.pw),d=Number.parseFloat(n.pl);a===6?(u=3.4,d=2.15):(u=.6,d=2.2),e.push(zr(a,c,l,d,u))}const t=Number.parseFloat(n.w)/2-2.4,i=Number.parseFloat(n.h)/2,r={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-t,y:i},{x:t,y:i},{x:t,y:i/2+.5}],type:"pcb_silkscreen_path",stroke_width:.1},o={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_2",route:[{x:-t,y:-i},{x:t,y:-i},{x:t,y:-i/2-.5}],type:"pcb_silkscreen_path",stroke_width:.1},s=Fo(0,0,.3);return[...e,r,o,s]},n2n=Se({fn:R(),num_pins:Pe().default(3),w:R().default("3.40mm"),h:R().default("3.30mm"),pl:R().default("1mm"),pw:R().default("0.7mm"),p:R().default("1.2mm"),string:R().optional()}),i2n=n=>{const e=n.string?.match(/^sot23w_(\d+)/),t=e?Number.parseInt(e[1],3):3,i=n2n.parse({...n,num_pins:t});if(i.num_pins===3)return{circuitJson:o2n(i),parameters:i};throw new Error("Invalid number of pins")},r2n=n=>{const{pn:e,p:t}=n;return e===1?{x:-t,y:.95}:e===2?{x:-t,y:-.95}:{x:t,y:0}},o2n=n=>{const e=[];for(let a=0;a<n.num_pins;a++){const{x:c,y:l}=r2n({num_pins:n.num_pins,pn:a+1,w:Number.parseFloat(n.w),h:Number.parseFloat(n.h),pl:Number.parseFloat(n.pl),p:Number.parseFloat(n.p)});e.push(zr(a+1,c,l,Number.parseFloat(n.pl),Number.parseFloat(n.pw)))}const t=Fo(0,Number.parseInt(n.h)/2+1,.3),i=Number.parseFloat(n.w)/2-1,r=Number.parseFloat(n.h)/2,o={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-i,y:r},{x:i+.3,y:r},{x:i+.3,y:r/2}],type:"pcb_silkscreen_path",stroke_width:.1},s={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_2",route:[{x:-i,y:-r},{x:i+.3,y:-r},{x:i+.3,y:-r/2}],type:"pcb_silkscreen_path",stroke_width:.1};return[...e,o,s,t]},s2n=Se({fn:R(),num_pins:Bn([pe(3),pe(2)]).default(3),p:R().default("1.27mm"),id:R().default("0.72mm"),od:R().default("0.95mm"),w:R().default("2.5mm"),h:R().default("4.2mm"),string:R().optional()}),a2n=n=>{const{p:e,id:t,od:i,w:r,h:o}=n,s=Number.parseFloat(o)/2,a=Number.parseFloat(e);return[Ia(1,-a,s-a,t,i),Ia(2,0,s-a,t,i),Ia(3,a,s-a,t,i)]},c2n=n=>{const{p:e,id:t,od:i,h:r}=n,o=Number.parseFloat(r)/2,s=Number.parseFloat(e);return[Ia(1,-s,o-s,t,i),Ia(2,s,o-s,t,i)]},l2n=n=>{const e=n.string?.match(/^to92s_(\d+)/),t=e?Number.parseInt(e[1],10):3,i=s2n.parse({...n,num_pins:t});let r=[];if(i.num_pins===3)r=a2n(i);else if(i.num_pins===2)r=c2n(i);else throw new Error("Invalid number of pins for TO-92");const o=Number.parseFloat(i.h)/2,s=Number.parseFloat(i.p),a={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-o,y:o-s},{x:-1.9,y:0},{x:1.9,y:0},{x:o,y:o-s},{x:1.5,y:Number.parseFloat(i.h)/2+.5},{x:-1.5,y:Number.parseFloat(i.h)/2+.5},{x:-o,y:o-s}],stroke_width:.1,pcb_silkscreen_path_id:""},c=Fo(0,o+1,.5);return{circuitJson:[...r,a,c],parameters:i}},u2n=Se({fn:R(),p:_t.optional(),id:_t.optional(),pw:_t.optional(),pl:_t.optional(),w:_t.optional(),h:_t.optional(),sh:Bn([Je(),R(),Pe()]).optional().transform(n=>{if(typeof n=="string"){const e=Number(n);return Number.isNaN(e)?!0:e}return n}).describe('JST SH (Surface-mount) connector family. SH stands for "Super High-density".'),ph:Je().optional().describe('JST PH (Through-hole) connector family. PH stands for "Pin Header".'),string:R().optional()}),d2n={ph:{p:_t.parse("2.2mm"),id:_t.parse("0.70mm"),pw:_t.parse("1.20mm"),pl:_t.parse("1.20mm"),w:_t.parse("6mm"),h:_t.parse("5mm")},sh:{p:_t.parse("1mm"),pw:_t.parse("0.6mm"),pl:_t.parse("1.55mm"),w:_t.parse("5.8mm"),h:_t.parse("7.8mm")}};function h2n(n){return n.sh?"sh":(n.ph,"ph")}function p2n(n,e,t,i,r,o){const s=[];if(n==="ph"){const a=t/2;s.push(oV(1,-a,2,i,r,o)),s.push(oV(2,a,2,i,r,o))}else{const a=-((e-1)/2)*t;for(let l=0;l<e;l++){const u=a+l*t;console.log("x si",u),s.push(zr(l+1,u,-1.325,r,o))}const c=(e-1)/2*t+1.3;console.log("offset",c),s.push(zr(e+1,-c,1.22,1.2,1.8)),s.push(zr(e+2,c,1.22,1.2,1.8))}return s}function f2n(n,e,t){return n==="ph"?{type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-3,y:3},{x:3,y:3},{x:3,y:-2},{x:-3,y:-2},{x:-3,y:3}],stroke_width:.1,pcb_silkscreen_path_id:""}:{type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[],stroke_width:.1,pcb_silkscreen_path_id:""}}var m2n=n=>{const e=u2n.parse(n),t=h2n(e),i=d2n[t],r=e.p??i.p,o=e.id??i.id,s=e.pw??i.pw,a=e.pl??i.pl,c=e.w??i.w,l=e.h??i.h;let u=t==="sh"?4:2;if(t==="sh"){const _=(typeof n.string=="string"?n.string:"").match(/sh(\d+)/);if(_&&_[1]){const g=parseInt(_[1],10);Number.isNaN(g)||(u=g)}else typeof e.sh=="number"&&(u=e.sh)}const d=p2n(t,u,r,o,s,a),h=f2n(t),p=Fo(0,l/2+1,.5);return{circuitJson:[...d,h,p],parameters:{...e,p:r,id:o,pw:s,pl:a,w:c,h:l,num_pins:u,sh:t==="sh",ph:t==="ph"}}},_2n=Se({fn:R(),num_pins:pe(2).default(2),w:R().default("3.30mm"),h:R().default("1.70mm"),pl:R().default("0.80mm"),pw:R().default("1mm"),p:R().default("1.90mm")}),y2n=n=>{const e=_2n.parse(n),t=Fo(0,_t.parse(e.h)/2+.5,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:_t.parse(e.p)/2,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2,y:-_t.parse(e.h)/2},{x:_t.parse(e.p)/2,y:-_t.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:x2n(e).concat(i,t),parameters:e}},g2n=n=>{const{pn:e,p:t}=n;return e===1?{x:-t/2,y:0}:{x:t/2,y:0}},x2n=n=>{const e=[];for(let t=1;t<=n.num_pins;t++){const{x:i,y:r}=g2n({pn:t,p:Number.parseFloat(n.p)});e.push(zr(t,i,r,Number.parseFloat(n.pl),Number.parseFloat(n.pw)))}return e},b2n=n=>{switch(n){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"}}},v2n=Se({fn:R(),num_pins:Bn([pe(8),pe(10)]).default(8),w:R().optional(),h:R().optional(),p:R().optional(),pl:R().optional(),pw:R().optional(),string:R().optional()}),w2n=n=>{const e=v2n.parse(n),t=b2n(e.num_pins),i=_t.parse(e.w||t.w),r=_t.parse(e.h||t.h),o=_t.parse(e.p||t.p),s=_t.parse(e.pl||t.pl),a=_t.parse(e.pw||t.pw),c=[],l=e.num_pins/2;for(let b=0;b<e.num_pins;b++){const{x:w,y:E}=net(e.num_pins,b+1,i,o),N=b<l?b+1:e.num_pins-(b-l);c.push(zr(N,w,E,s,a))}const u=i,d=r,h={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-u/2,y:d/2},{x:u/2,y:d/2}],stroke_width:.05,pcb_silkscreen_path_id:""},p={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-u/2,y:-d/2},{x:u/2,y:-d/2}],stroke_width:.05,pcb_silkscreen_path_id:""},m=net(e.num_pins,1,u,o),_={x:m.x-.8,y:m.y},g={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"pin_marker_1",route:[{x:_.x-.4,y:_.y},{x:_.x-.7,y:_.y+.3},{x:_.x-.7,y:_.y-.3},{x:_.x-.4,y:_.y}],stroke_width:.05,pcb_silkscreen_path_id:"pin_marker_1"},x=Fo(0,d/2+.5,.3);return{circuitJson:[...c,h,p,x,g],parameters:e}},net=(n,e,t,i)=>{const r=n/2,o=(e-1)%r,s=e<=r?-1:1,a=(r-1)/2-o;return{x:s*_t.parse(n===8?"1.8mm":"2.2mm"),y:a*i}},S2n=n=>{switch(n){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"}}},E2n=Se({fn:R(),num_pins:Bn([pe(8),pe(10),pe(12),pe(16)]).default(8),w:R().optional(),h:R().optional(),p:R().optional(),pl:R().optional(),pw:R().optional(),string:R().optional()}),iet=(n,e,t,i)=>{const r=n/2,o=(e-1)%r,s=e<=r?-1:1,a=(r-1)/2-o;return{x:s*_t.parse("2mm"),y:a*i}},T2n=n=>{const e=E2n.parse(n),t=S2n(e.num_pins),i=_t.parse(e.w||t.w),r=_t.parse(e.h||t.h),o=_t.parse(e.p||t.p),s=_t.parse(e.pl||t.pl),a=_t.parse(e.pw||t.pw),c=[];for(let x=0;x<e.num_pins;x++){const{x:b,y:w}=iet(e.num_pins,x+1,i,o);c.push(zr(x+1,b,w,s,a))}const l=i,u=r,d={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-l/2,y:u/2},{x:l/2,y:u/2}],stroke_width:.05,pcb_silkscreen_path_id:""},h={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-l/2,y:-u/2},{x:l/2,y:-u/2}],stroke_width:.05,pcb_silkscreen_path_id:""},p=iet(e.num_pins,1,l,o),m={x:p.x-.8,y:p.y},_={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"pin_marker_1",route:[{x:m.x-.4,y:m.y},{x:m.x-.7,y:m.y+.3},{x:m.x-.7,y:m.y-.3},{x:m.x-.4,y:m.y}],stroke_width:.05,pcb_silkscreen_path_id:"pin_marker_1"},g=Fo(0,u/2+.5,.3);return{circuitJson:[...c,d,h,g,_],parameters:e}},M2n=Se({fn:R(),num_pins:pe(2).default(2),w:R().default("3.8mm"),h:R().default("1.65mm"),pl:R().default("1.2mm"),pw:R().default("1.2mm"),pad_spacing:R().default("2.6mm")}),C2n=n=>{const e=M2n.parse(n),t=Fo(0,_t.parse(e.h),.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:_t.parse(e.pad_spacing)/2,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2-.2,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2-.2,y:-_t.parse(e.h)/2},{x:_t.parse(e.pad_spacing)/2,y:-_t.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:P2n(e).concat(i,t),parameters:e}},A2n=n=>{const{pn:e,pad_spacing:t}=n;return e===1?{x:-t/2,y:0}:{x:t/2,y:0}},P2n=n=>{const e=[];for(let t=1;t<=n.num_pins;t++){const{x:i,y:r}=A2n({pn:t,pad_spacing:Number.parseFloat(n.pad_spacing)});e.push(zr(t,i,r,Number.parseFloat(n.pl),Number.parseFloat(n.pw)))}return e},R2n=Se({fn:R(),num_pins:pe(2).default(2),w:R().default("3.20mm"),h:R().default("1.65mm"),pl:R().default("0.8mm"),pw:R().default("0.9mm"),pad_spacing:R().default("2.1mm")}),I2n=n=>{const e=R2n.parse(n),t=Fo(0,_t.parse(e.h),.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:_t.parse(e.pad_spacing)/2,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2-.2,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2-.2,y:-_t.parse(e.h)/2},{x:_t.parse(e.pad_spacing)/2,y:-_t.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:k2n(e).concat(i,t),parameters:e}},N2n=n=>{const{pn:e,pad_spacing:t}=n;return e===1?{x:-t/2,y:0}:{x:t/2,y:0}},k2n=n=>{const e=[];for(let t=1;t<=n.num_pins;t++){const{x:i,y:r}=N2n({pn:t,pad_spacing:Number.parseFloat(n.pad_spacing)});e.push(zr(t,i,r,Number.parseFloat(n.pl),Number.parseFloat(n.pw)))}return e},O2n=Se({fn:R(),num_pins:Bn([pe(6),pe(8)]).default(8),w:R().default("3mm"),h:R().default("3mm"),p:R().default("0.5mm"),pl:R().default("0.52mm"),pw:R().default("0.35mm"),epw:R().default("1.40mm"),eph:R().default("1.60mm"),string:R().optional(),ep:Je().default(!1)}),L2n=n=>{n.string&&n.string.includes("_ep")&&(n.ep=!0);const e=n.string?.match(/^son_(\d+)/),t=e?Number.parseInt(e[1],10):n.num_pins||8,i=O2n.parse({...n,num_pins:t}),r=_t.parse(i.w),o=_t.parse(i.h),s=_t.parse(i.p),a=_t.parse(i.pl),c=_t.parse(i.pw),l=_t.parse(i.epw),u=_t.parse(i.eph),d=[];for(let E=0;E<i.num_pins;E++){const{x:N,y:A}=ret(i.num_pins,E+1,r,s);d.push(zr(E+1,N,A,a,c))}i.ep&&d.push(zr(i.num_pins+1,0,0,l,u));const h=r,p=o,m={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-h/2,y:p/2},{x:h/2,y:p/2}],stroke_width:.05,pcb_silkscreen_path_id:""},_={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-h/2,y:-p/2},{x:h/2,y:-p/2}],stroke_width:.05,pcb_silkscreen_path_id:""},g=ret(i.num_pins,1,h,s),x={x:g.x-.4,y:g.y},b={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"pin_marker_1",route:[{x:x.x-.4,y:x.y},{x:x.x-.7,y:x.y+.3},{x:x.x-.7,y:x.y-.3},{x:x.x-.4,y:x.y}],stroke_width:.05,pcb_silkscreen_path_id:"pin_marker_1"},w=Fo(0,p/2+.5,.3);return{circuitJson:[...d,m,_,w,b],parameters:i}},ret=(n,e,t,i)=>{const r=n/2,o=(e-1)%r,s=e<=r?-1:1,a=(r-1)/2-o;return{x:s*_t.parse("1.4mm"),y:a*i}},D2n=n=>{const{num_pins:e,bridged:t,p:i=2.54,pw:r=1.5,ph:o=1.5}=n,s=_t.parse(i),a=_t.parse(r),c=_t.parse(o),l=Math.min(c/4,.5),u=[];for(let E=0;E<e;E++)u.push(zr(E+1,E*s,0,a,c));let d=[];if(t){const E=t.split("").map(Number);if(E.length>1)for(let N=0;N<E.length-1;N++){const A=E[N],I=E[N+1];if(typeof A=="number"&&typeof I=="number"&&!isNaN(A)&&!isNaN(I)){const M=(A-1)*s,k=(I-1)*s,C=Math.sign(k-M),U=M+C*(a/2),O=k-C*(a/2);d.push({type:"pcb_trace",pcb_trace_id:"",route:[{start_pcb_port_id:`{PIN${A}}`,x:U,y:0,width:l,layer:"top",route_type:"wire"},{end_pcb_port_id:`{PIN${I}}`,x:O,y:0,width:l,layer:"top",route_type:"wire"}]})}}}const h=(e-1)*s+a+.7,p=c+1,m=(e-1)*s/2,_=0,g={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"outline",route:[{x:m-h/2,y:_-p/2},{x:m+h/2,y:_-p/2},{x:m+h/2,y:_+p/2},{x:m-h/2,y:_+p/2},{x:m-h/2,y:_-p/2}],stroke_width:.15},b=_+p/2+.6,w=Fo(m,b,.4);return{circuitJson:[...u,...d,g,w],parameters:n}},oet={fn:pe("sot457"),num_pins:pe(6).default(6),pillh:R().default("0.45mm"),pillw:R().default("1.45mm"),pl:R(),pw:R(),p:R(),wave:Je().optional(),reflow:Je().optional()},z2n=Se({...oet,h:R().default("2.5mm"),w:R().default("2.7mm"),pl:R().default("0.8mm"),pw:R().default("0.55mm"),p:R().default("0.95mm")}),$2n=Se({...oet,h:R().default("3mm"),w:R().default("4mm"),pillr:R().default("0.225mm"),pl:R().default("1.45mm"),pw:R().default("1.5mm"),p:R().default("1.475mm")}).transform(n=>({...n,wave:n.wave??(n.reflow===void 0?!0:!n.reflow),reflow:n.reflow??(n.wave===void 0?!1:!n.wave)})),V5=n=>Number.parseFloat(n.replace("mm","")),set=({pitch:n,width:e,pinNumber:t})=>{const o={1:{x:-e/2-.1,y:n},2:{x:-e/2-.1,y:0},3:{x:-e/2-.1,y:-n},4:{x:e/2+.1,y:-n},5:{x:e/2+.1,y:0},6:{x:e/2+.1,y:n}}[t];if(!o)throw new Error(`Invalid pin number: ${t}`);return o},aet=n=>{const e=[],t=V5(n.p),i=V5(n.pl),r=V5(n.pw),o=V5(n.w),s=V5(n.h);if(n.wave){const m={1:({padWidth:_,padHeight:g})=>zr(1,-t,t,g,_),2:({padWidth:_,padHeight:g})=>zr(2,-t,-t,g,_),3:({padWidth:_,padHeight:g})=>rV(3,-t,0,V5(n.pillw),V5(n.pillh)),4:({padWidth:_,padHeight:g})=>rV(4,t,0,V5(n.pillw),V5(n.pillh)),5:({padWidth:_,padHeight:g})=>zr(5,t,t,g,_),6:({padWidth:_,padHeight:g})=>zr(6,t,-t,g,_)};for(let _=1;_<=n.num_pins;_++){const g=m[_];g&&e.push(g({padWidth:i,padHeight:r}))}}else for(let m=1;m<=n.num_pins;m++){const{x:_,y:g}=set({pitch:t,width:o,pinNumber:m});e.push(zr(m,_,g,i,r))}const a={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-o/3,y:s/2+t/1.3},{x:o/3,y:s/2+t/1.3}],stroke_width:.05},c={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_2",route:[{x:-o/3,y:-s/2-t/1.3},{x:o/3,y:-s/2-t/1.3}],stroke_width:.05},l=Fo(0,s+.5,.3),u=set({pitch:t,width:o,pinNumber:1}),d=n.wave?1:.5,h=n.wave?.7:.3;u.x-=n.wave?r:r*1.7;const p={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"pin1_indicator",route:[{x:u.x+d/2,y:u.y},{x:u.x-d/2,y:u.y+h/2},{x:u.x-d/2,y:u.y-h/2},{x:u.x+d/2,y:u.y}],stroke_width:.05};return[l,a,c,p,...e]},F2n=n=>{if(n.wave){const t=$2n.parse({...n,fn:"sot457"});return{circuitJson:aet(t),parameters:t}}const e=z2n.parse(n);return{circuitJson:aet(e),parameters:e}},U2n=Se({fn:R(),num_pins:Bn([pe(3),pe(2)]).default(3),p:R().default("3.8mm"),id:R().default("1.25mm"),od:R().default("2.35mm"),ca:R().default("14mm").describe("Caliper axis (width or diameter of the potentiometer body or adjustment knob)"),w:R().default("5.35mm"),h:R().default("4mm"),string:R().optional()}),B2n=n=>{const{p:e,id:t,od:i,h:r,ca:o}=n,s=Number.parseFloat(r),a=Number.parseFloat(o);return[Ia(1,0,a/4+.3,t,i),Ia(2,s,0,t,i),Ia(3,0,-a/4-.3,t,i)]},j2n=n=>{const e=n.string?.match(/^potentiometer_(\d+)/),t=e?Number.parseInt(e[1],10):3,i=U2n.parse({...n,num_pins:t});let r=[];i.num_pins===3&&(r=B2n(i));const o=Number.parseFloat(i.ca)/2+.15,s=Number.parseFloat(i.w),a=Number.parseFloat(i.od)/2+.35,c={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:0,y:o-1.75},{x:0,y:o},{x:s,y:o},{x:s,y:a}],stroke_width:.1,pcb_silkscreen_path_id:""},l={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:s,y:-a},{x:s,y:-o},{x:0,y:-o},{x:0,y:-o+1.75}],stroke_width:.1,pcb_silkscreen_path_id:""},u=Number.parseFloat(i.w)/2,d=Fo(u,o+1,.5);return{circuitJson:[...r,c,l,d],parameters:i}},H2n=Se({fn:R(),p:_t.optional().default("7.5mm"),id:_t.optional().default("1mm"),od:_t.optional().default("2mm"),d:_t.optional().default("10.5mm")}),V2n=(n,e,t,i,r)=>{const o=[],s=[];for(let a=0;a<=50;a++){const c=a/50*Math.PI,l=n+Math.cos(c)*t,u=e+Math.sin(c)*t;l<n-i&&u>=e-r/2&&u<=e+r/2||o.push({x:l,y:u})}for(let a=0;a<=50;a++){const c=Math.PI+a/50*Math.PI,l=n+Math.cos(c)*t,u=e+Math.sin(c)*t;l<n-i&&u>=e-r/2&&u<=e+r/2||s.push({x:l,y:u})}return{topArc:o,bottomArc:s}},G2n=n=>{const e=H2n.parse(n),{p:t,id:i,od:r,d:o}=e,s=[Ia(1,-t/2,0,i,r),Ia(2,t/2,0,i,r)],{topArc:a,bottomArc:c}=V2n(0,0,o/2+.1,r/2,r),l={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:a,stroke_width:.1,pcb_silkscreen_path_id:""},u={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:c,stroke_width:.1,pcb_silkscreen_path_id:""},d={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:0,y:o/2+.1},{x:0,y:-(o/2+.1)}],stroke_width:.1,pcb_silkscreen_path_id:""},h=-(o/2+.5),p=r/2+1.5,m=.5,_={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:h-m,y:p},{x:h+m,y:p}],stroke_width:.1,pcb_silkscreen_path_id:""},g={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:h,y:p-m},{x:h,y:p+m}],stroke_width:.1,pcb_silkscreen_path_id:""},x=Fo(0,o/2+1,.5);return{circuitJson:[...s,l,u,d,_,g,x],parameters:e}},Y2n=Se({fn:R(),num_pins:pe(2).default(2),w:R().default("6.5mm"),h:R().default("3mm"),pl:R().default("1.75mm"),pw:R().default("2.40mm"),p:R().default("4.75mm")}),q2n=n=>{const e=Y2n.parse(n),t=Fo(0,_t.parse(e.h)-.5,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:_t.parse(e.p)/2,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2-.3,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2-.3,y:-_t.parse(e.h)/2},{x:_t.parse(e.p)/2,y:-_t.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:W2n(e).concat(i,t),parameters:e}},X2n=n=>{const{pn:e,p:t}=n;return e===1?{x:-t/2,y:0}:{x:t/2,y:0}},W2n=n=>{const e=[];for(let t=1;t<=n.num_pins;t++){const{x:i,y:r}=X2n({pn:t,p:Number.parseFloat(n.p)});e.push(zr(t,i,r,Number.parseFloat(n.pl),Number.parseFloat(n.pw)))}return e},K2n=Se({fn:R(),num_pins:Pe().default(3),w:R().default("2.45mm"),h:R().default("2.40mm"),pl:R().default("0.45mm"),pw:R().default("0.70mm"),p:R().default("1mm"),string:R().optional()}),Z2n=n=>{const e=n.string?.match(/^sot323_(\d+)/),t=e?Number.parseInt(e[1],3):3,i=K2n.parse({...n,num_pins:t});if(i.num_pins===3)return{circuitJson:J2n(i),parameters:i};throw new Error("Invalid number of pins")},Q2n=n=>{const{pn:e,p:t}=n;return e===1?{x:-t,y:.65}:e===2?{x:-t,y:-.65}:{x:t,y:0}},J2n=n=>{const e=[];for(let a=0;a<n.num_pins;a++){const{x:c,y:l}=Q2n({num_pins:n.num_pins,pn:a+1,w:Number.parseFloat(n.w),h:Number.parseFloat(n.h),pl:Number.parseFloat(n.pl),p:Number.parseFloat(n.p)});e.push(zr(a+1,c,l,Number.parseFloat(n.pl),Number.parseFloat(n.pw)))}const t=Fo(0,Number.parseInt(n.h)/2+1,.3),i=Number.parseFloat(n.w)/2-Number.parseFloat(n.pl),r=Number.parseFloat(n.h)/2,o={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-i,y:r+.3},{x:i,y:r+.3},{x:i,y:r/2}],type:"pcb_silkscreen_path",stroke_width:.1},s={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_2",route:[{x:-i,y:-r-.3},{x:i,y:-r-.3},{x:i,y:-r/2}],type:"pcb_silkscreen_path",stroke_width:.1};return[...e,o,s,t]},eEn=Se({fn:R(),circle:Je().optional(),rect:Je().optional(),square:Je().optional(),pill:Je().optional(),d:_t.optional(),pd:_t.optional(),diameter:_t.optional(),r:_t.optional(),pr:_t.optional(),radius:_t.optional(),w:_t.optional(),pw:_t.optional(),width:_t.optional(),h:_t.optional(),ph:_t.optional(),height:_t.optional(),s:_t.optional(),size:_t.optional(),string:R().optional()}).transform(n=>{let e="rect";n.circle&&(e="circle"),n.square&&(e="square"),n.rect&&(e="rect"),n.pill&&(e="pill");let t,i,r;return e==="circle"?n.r!==void 0?t=gh(n.r):n.pr!==void 0?t=gh(n.pr):n.radius!==void 0?t=gh(n.radius):n.d!==void 0?t=gh(n.d)/2:n.pd!==void 0?t=gh(n.pd)/2:n.diameter!==void 0?t=gh(n.diameter)/2:t=gh("1mm")/2:(n.w!==void 0?i=gh(n.w):n.pw!==void 0?i=gh(n.pw):n.width!==void 0?i=gh(n.width):n.s!==void 0?i=gh(n.s):n.size!==void 0?i=gh(n.size):i=gh("1mm"),n.h!==void 0?r=gh(n.h):n.ph!==void 0?r=gh(n.ph):n.height!==void 0?r=gh(n.height):e==="square"||e==="rect"?r=i:r=gh("1mm")),{fn:n.fn,shape:e,radius:t,width:i,height:r}}),tEn=n=>{const e=eEn.parse(n),{shape:t,radius:i,width:r,height:o}=e;let s,a;return t==="circle"?(s=VJe(1,{x:0,y:0,radius:i}),a=i+.5):t==="pill"?(s=rV(1,0,0,r,o),a=Math.max(r,o)/2+.5):(s=zr(1,0,0,r,o),a=o/2+.5),{circuitJson:[s,Fo(0,a,.2)],parameters:e}},nEn=Se({fn:R(),d:_t.optional(),hd:_t.optional(),r:_t.optional(),hr:_t.optional(),pd:_t.optional(),pr:_t.optional(),squarepad:Je().optional().default(!1)}).transform(n=>{let e;n.d!==void 0?e=gh(n.d):n.hd!==void 0?e=gh(n.hd):n.r!==void 0?e=gh(n.r)*2:n.hr!==void 0?e=gh(n.hr)*2:e=gh("1mm");let t;return n.pd!==void 0?t=gh(n.pd):n.pr!==void 0?t=gh(n.pr)*2:t=e*(1.5/1),{fn:n.fn,d:e,pd:t,squarepad:n.squarepad??!1}}),iEn=n=>{const e=nEn.parse(n),{d:t,pd:i,squarepad:r}=e;return{circuitJson:[r?oV(1,0,0,t,i,i):Ia(1,0,0,t,i),Fo(0,i/2+.5,.2)],parameters:e}},rEn=Se({fn:R(),num_pins:pe(6).default(6),h:R().default("1.6mm"),pl:R().default("1mm"),pw:R().default("0.7mm"),p:R().default("0.95mm")}),oEn=n=>{const e=rEn.parse(n);return{circuitJson:sEn(e),parameters:e}},cet=n=>{const{p:e,h:t,pn:i}=n;if(i===1)return{x:-t/2-.5,y:e};if(i===2)return{x:-t/2-.5,y:0};if(i===3)return{x:-t/2-.5,y:-e};if(i===4)return{x:t/2+.5,y:-e};if(i===5)return{x:t/2+.5,y:0};if(i===6)return{x:t/2+.5,y:e};throw new Error("Invalid pin number")},sEn=n=>{const e=[];for(let d=1;d<=n.num_pins;d++){const{x:h,y:p}=cet({h:Number.parseFloat(n.h),p:Number.parseFloat(n.p),pn:d});e.push(zr(d,h,p,Number.parseFloat(n.pl),Number.parseFloat(n.pw)))}const t=n.num_pins/2*Number.parseFloat(n.p),i=Number.parseFloat(n.h),r={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-t/3,y:i/2+Number.parseFloat(n.p)/1.3},{x:t/3,y:i/2+Number.parseFloat(n.p)/1.3}],type:"pcb_silkscreen_path",stroke_width:.05},o={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_2",route:[{x:-t/3,y:-i/2-Number.parseFloat(n.p)/1.3},{x:t/3,y:-i/2-Number.parseFloat(n.p)/1.3}],type:"pcb_silkscreen_path",stroke_width:.05},s=Fo(0,i+.3,.3),a=cet({h:Number.parseFloat(n.h),p:Number.parseFloat(n.p),pn:1});a.x=a.x-Number.parseFloat(n.pw)*1.5;const c=.7,l=.3,u={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"pin1_indicator",route:[{x:a.x+c/2,y:a.y},{x:a.x-c/2,y:a.y+l/2},{x:a.x-c/2,y:a.y-l/2},{x:a.x+c/2,y:a.y}],stroke_width:.05};return[...e,s,r,o,u]},aEn=Se({fn:R()}),cEn=n=>{const e=aEn.parse(n),t=[],i=.5-.15,r=1.5,s=.5/2,a=75,c=-37/2;for(let I=0;I<a;I++){const M=I+1;if(M>=24&&M<=31)continue;const k=c-I*s,C=M%2===0,U=r+(C?.25:0),H=.5-U/2,Y=zr(M,H,k,U,i);Y.layer=C?"bottom":"top",t.push(Y)}const l=46*.0254,u=137*.0254,d=261*.0254,h={type:"pcb_cutout",pcb_cutout_id:"",shape:"rect",center:{x:-u/2+r/2,y:c-d},width:u,height:l},p={x:-.5,y:c},m={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"};let _=1/0,g=-1/0,x=1/0,b=-1/0;const w=(I,M,k=0,C=0)=>{_=Math.min(_,I-k/2),g=Math.max(g,I+k/2),x=Math.min(x,M-C/2),b=Math.max(b,M+C/2)};for(const I of t)w(I.x,I.y,I.width,I.height);w(h.center.x,h.center.y,h.width,h.height);for(const I of m.route)w(I.x,I.y);const E=(_+g)/2,N=(x+b)/2,A=I=>{typeof I.x=="number"&&(I.x-=E),typeof I.y=="number"&&(I.y-=N),I.center&&(I.center.x-=E,I.center.y-=N),Array.isArray(I.route)&&(I.route=I.route.map(M=>({x:M.x-E,y:M.y-N})))};for(const I of t)A(I);return A(h),A(m),{circuitJson:[...t,h,m],parameters:e}};function lEn(n){return n!=null}var uEn=(n,e)=>{if(!e)return n;const t=n.filter(u=>u.type==="pcb_smtpad"||u.type==="pcb_plated_hole"||u.type==="pcb_thtpad");if(t.length===0)return n;let i=1/0,r=-1/0,o=1/0,s=-1/0;const a=(u,d,h=0,p=0)=>{const m=u-h/2,_=u+h/2,g=d-p/2,x=d+p/2;i=Math.min(i,m),r=Math.max(r,_),o=Math.min(o,g),s=Math.max(s,x)};for(const u of t)if(u.type==="pcb_smtpad"){const d=u.shape==="circle"?u.radius*2:u.width,h=u.shape==="circle"?u.radius*2:u.height;a(u.x,u.y,d,h)}else if(u.type==="pcb_plated_hole"){const d=u.outer_diameter??u.hole_diameter;a(u.x,u.y,d,d)}else if(u.type==="pcb_thtpad"){const d=u.diameter;a(u.x,u.y,d,d)}let c=0,l=0;switch(e){case"center":c=(i+r)/2,l=(o+s)/2;break;case"bottomleft":c=i,l=o;break;case"bottomcenter":case"centerbottom":c=(i+r)/2,l=o;break;case"topcenter":case"centertop":c=(i+r)/2,l=s;break;case"leftcenter":case"centerleft":c=i,l=(o+s)/2;break;case"rightcenter":case"centerright":c=r,l=(o+s)/2;break;case"pin1":const u=t.find(d=>d.port_hints?.[0]==="1")||t[0];c=u.x,l=u.y;break}if(c===0&&l===0)return n;for(const u of n){if(typeof u.x=="number"&&(u.x-=c),typeof u.y=="number"&&(u.y-=l),u.center&&typeof u.center.x=="number"&&(u.center.x-=c,u.center.y-=l),u.type==="pcb_silkscreen_path")for(const d of u.route)d.x-=c,d.y-=l;u.type==="pcb_silkscreen_text"&&u.anchor_position&&(u.anchor_position.x-=c,u.anchor_position.y-=l)}return n},dEn=n=>{let e=lV();const i=n.replace(/^((?:\d{4}|\d{5}))(?=$|_)/,"res$1").split(/_(?!metric)/).map(r=>{const o=r.match(/([a-z]+)([\(\d\.\+\?].*)?/);if(!o)return null;const[,s,a]=o;return!s||a?.includes("?")?null:{fn:s,v:a}}).filter(lEn);for(const{fn:r,v:o}of i)e=e[r](o);return e.setString(n),e},hEn=()=>Object.keys(j5),lV=()=>{const n=new Proxy({},{get:(e,t)=>{if(t==="soup"||t==="circuitJson"){if("fn"in e&&j5[e.fn])return()=>{const{circuitJson:i}=j5[e.fn](e);return uEn(i,e.origin)};if(!j5[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 "${t}"`)}}if(t==="json"){if(!j5[e.fn])throw new Error(`Invalid footprint function, got "${e.fn}"${e.string?`, from string "${e.string}"`:""}`);return()=>j5[e.fn](e).parameters}return t==="getFootprintNames"?()=>Object.keys(j5):t==="params"?()=>e:t==="setString"?i=>(e.string=i,n):i=>(Object.keys(e).length===0?`${t}${i}`in j5?(e[`${t}${i}`]=!0,e.fn=`${t}${i}`):(e[t]=!0,e.fn=t,t==="res"||t==="cap"?i&&(typeof i=="string"&&i.includes("_metric")?e.metric=i.split("_metric")[0]:e.imperial=i):e.num_pins=Number.isNaN(Number.parseFloat(i))?void 0:Number.parseFloat(i)):!i&&["w","h","p"].includes(t)||(e[t]=i??!0),n)}});return n};lV.string=dEn,lV.getFootprintNames=hEn;var pEn=lV,uet=Symbol("Fragment");function xye(n,e,...t){const i=t.length?t:e?.children!==void 0?[e.children]:[],r=[],o=(Array.isArray(i)?i:[i]).flat(1/0);for(const s of o)s==null||s===!1||(Array.isArray(s)?r.push(...s):r.push(s));return{type:n,props:(e&&e.children!==void 0?{...e,children:void 0}:e)||{},children:r}}var Js=Symbol("Cuboid"),det=Symbol("Cube"),G5=Symbol("Cylinder"),het=Symbol("Sphere"),bye=Symbol("RoundedCuboid"),Kb=Symbol("Translate"),eI=Symbol("Rotate"),uV=Symbol("Union"),dV=Symbol("Subtract"),u4=Symbol("Hull"),oT=Symbol("Colorize"),s8=Symbol("Polygon"),a8=Symbol("ExtrudeLinear"),Sy=uet,Yn=(n,e,t)=>xye(n,e),Kd=(n,e,t)=>xye(n,e),tI=({center:n,width:e,length:t,height:i,heightAboveSurface:r=.15})=>{const o=i*.5,s=i-o,a=Math.min(e,t)*.12,c=Math.max(e-a,e*.75),l=Math.max(t-a,t*.75),u=Math.min(e,t)*.12,d=t/2-u*.25,h=l/8,p=i/4;return Yn(oT,{color:"#555",children:Yn(Kb,{offset:n,children:Yn(Kb,{offset:{x:0,y:0,z:r},children:Kd(dV,{children:[Kd(uV,{children:[Kd(u4,{children:[Yn(Kb,{z:.005,children:Yn(Js,{size:[c,l,.01]})}),Yn(Kb,{z:o,children:Yn(Js,{size:[e,t,.01]})})]}),Kd(u4,{children:[Yn(Kb,{z:o,children:Yn(Js,{size:[e,t,.01]})}),Yn(Kb,{z:o+s,children:Yn(Js,{size:[c,l,.01]})})]})]}),Yn(Kb,{offset:{x:0,y:d,z:i},children:Yn(eI,{rotation:[0,0,0],children:Yn(G5,{radius:h,height:p})})})]})})})})},fEn=n=>Array.from({length:n},(e,t)=>t);function vye(n,e){if(n.length<2)throw new Error("Stroke must have at least two points");const t=Array.isArray(n[0])?n.map(([u,d])=>({x:u,y:d})):n,i=e/2,r=[],o=[];function s(u,d){const h=d.x-u.x,p=d.y-u.y,m=Math.sqrt(h*h+p*p);return{x:-p/m,y:h/m}}function a(u,d,h){const p={x:u.x+d.x*i*h,y:u.y+d.y*i*h};h>0?r.push(p):o.unshift(p)}const c=s(t[0],t[1]);a(t[0],c,1),a(t[0],c,-1);for(let u=1;u<t.length-1;u++){const d=t[u-1],h=t[u],p=t[u+1],m=s(d,h),_=s(h,p),g=m.x+_.x,x=m.y+_.y,b=Math.sqrt(g*g+x*x);if(b/2>2*i)a(h,m,1),a(h,_,1),a(h,m,-1),a(h,_,-1);else{const E=1/b;a(h,{x:g*E,y:x*E},1),a(h,{x:g*E,y:x*E},-1)}}const l=s(t[t.length-2],t[t.length-1]);return a(t[t.length-1],l,1),a(t[t.length-1],l,-1),[...r,...o]}var mEn=n=>{const e=Math.min(...n.map(a=>a.x)),t=Math.max(...n.map(a=>a.x)),i=Math.min(...n.map(a=>a.y)),s=5.47/(Math.max(...n.map(a=>a.y))-i);return n.map(a=>({x:(a.x-e-(t-e)/2)*s,y:(a.y-i)*s}))},_En=mEn([{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}]),pet=5.47,hV=.5,yEn=({x:n,y:e,z:t})=>{const i=n>0;return Kd(Sy,{children:[Yn(Kb,{offset:{x:n+.25/2,y:e,z:t},children:Yn(eI,{rotation:["-90deg",0,"90deg"],children:Yn(a8,{height:.25,children:Yn(s8,{points:_En.map(r=>[r.x,r.y])})})})}),Yn(Kb,{offset:{x:n,y:e+(i?1:-1),z:t},children:Yn(eI,{rotation:["-90deg","90deg",i?"180deg":"0deg"],children:Yn(a8,{height:2,children:Yn(s8,{points:vye([[0,0],[-1,0],[-1,-1]],.25).map(r=>[r.x,r.y])})})})})]})},gEn=({numPins:n=8,pitch:e=2.54,bodyWidth:t=6.4})=>{const i=Math.floor(n/2),r=t+1;return Kd(Sy,{children:[fEn(n).map(o=>{const s=o%i,a=(Math.floor(o/i)-.5)*2;return Yn(yEn,{x:a*r/2,y:s*e-(i-1)/2*e,z:pet/2+hV})}),Yn(tI,{width:t,length:i*e+.5,height:pet-hV,heightAboveSurface:hV,center:{x:0,y:0,z:hV}})]})};function xEn(n,{height:e,padContactLength:t,curveLength:i,bodyDistance:r,steepness:o=10}){i||(i=r*.3);let s=r-t-i;s<0&&(i+=s,s=0);const a=t*.75,c=t+i+(r-t-i)*.25;if(n<=a)return 0;if(n>=c)return e;const l=(n-a)/(c-a);return e/(1+Math.exp(-o*(l-.5)))}var Rv=n=>{const{thickness:e,width:t,padContactLength:i,bodyDistance:r,height:o,rotation:s}=n,a=15,c=Array.from({length:a}).map((u,d)=>d/(a-1)*r).map(u=>[u,xEn(u,n)]),l=vye(c,e);return Yn(oT,{color:"#fff",children:Yn(Kb,{offset:{z:0,y:0,x:0,...n.position},children:Yn(eI,{rotation:["90deg",0,s??0],children:Yn(Kb,{offset:{x:0,y:0,z:-t/2},children:Yn(a8,{height:t,children:Yn(s8,{points:l.map(u=>[u.x,u.y])})})})})})})},bEn=({pinCount:n,leadLength:e,leadWidth:t,pitch:i,bodyWidth:r})=>{const o=Math.ceil(n/2),s=i*n/2+t/2,a=(o-1)*i/2,c=.25;return Kd(Sy,{children:[Array.from({length:o}).map((l,u)=>Yn(Rv,{position:{x:-r/2-e,y:u*i-a,z:c/2},width:t,thickness:c,padContactLength:e,bodyDistance:e+1,height:.8})),Array.from({length:o}).map((l,u)=>Yn(Rv,{rotation:Math.PI,position:{x:r/2+e,y:u*i-a,z:c/2},width:t,thickness:c,padContactLength:e,bodyDistance:e+1,height:.8})),Yn(tI,{center:{x:0,y:0,z:c/2},width:r-t-1,length:s,height:1.5})]})},wye=1,Sye=.5,nI=.5,c8=.2,vEn=wye-c8*2,fet=({color:n="#333"})=>Kd(Sy,{children:[Yn(Js,{size:[vEn,Sye,nI],offset:[0,0,nI/2],color:n}),Yn(Js,{size:[c8,nI,Sye],offset:[wye/2-c8/2,0,nI/2],color:"#ccc"}),Yn(Js,{size:[c8,nI,Sye],offset:[-wye/2+c8/2,0,nI/2],color:"#ccc"})]}),Eye=1.6,wEn=Eye-.3*2,pV=.3,Tye=.85,iI=.6,met=({color:n="#333"})=>Kd(Sy,{children:[Yn(Js,{size:[wEn,Tye,iI],offset:[0,0,iI/2],color:n}),Yn(Js,{size:[pV,Tye,iI],offset:[Eye/2-pV/2,0,iI/2],color:"#ccc"}),Yn(Js,{size:[pV,Tye,iI],offset:[-Eye/2+pV/2,0,iI/2],color:"#ccc"})]}),Mye=2,Cye=1.25,rI=.55,l8=.5,SEn=Mye-l8*2,_et=({color:n="#333"})=>Kd(Sy,{children:[Yn(Js,{size:[SEn,Cye,rI],offset:[0,0,rI/2],color:n}),Yn(Js,{size:[l8,Cye,rI],offset:[Mye/2-l8/2,0,rI/2],color:"#ccc"}),Yn(Js,{size:[l8,Cye,rI],offset:[-Mye/2+l8/2,0,rI/2],color:"#ccc"})]}),EEn=({pinCount:n,pitch:e,leadWidth:t,padContactLength:i,bodyWidth:r})=>{const o=n/4;e||(e=TEn(n,r)),i||(i=MEn(n)),t||(t=CEn(n,r)),r||(r=e*(o+4));const s=r,a=(o-1)*e/2,c=s+2*i,l=c,u=.8,d=.15,h=(l-r)/2;return Kd(Sy,{children:[Array.from({length:o}).map((p,m)=>Yn(Rv,{position:{x:-l/2,y:m*e-a,z:d/2},width:t,thickness:d,padContactLength:i,bodyDistance:h,height:u})),Array.from({length:o}).map((p,m)=>Yn(Rv,{rotation:Math.PI,position:{x:l/2,y:m*e-a,z:d/2},width:t,thickness:d,padContactLength:i,bodyDistance:h,height:u})),Array.from({length:o}).map((p,m)=>Yn(Rv,{rotation:Math.PI/2,position:{x:m*e-a,y:-c/2,z:d/2},width:t,thickness:d,padContactLength:i,bodyDistance:h,height:u})),Array.from({length:o}).map((p,m)=>Yn(Rv,{rotation:-Math.PI/2,position:{x:m*e-a,y:c/2,z:d/2},width:t,thickness:d,padContactLength:i,bodyDistance:h,height:u})),Yn(tI,{center:{x:0,y:0,z:d/2},width:r,length:s,height:1.5})]})},TEn=(n,e)=>{switch(n){case 44:case 64:return .8;case 52:return e===14?1:.65;case 208:return .5;default:return .5}},MEn=n=>{switch(n){case 44:case 52:case 64:return 2.25;case 208:return 1.65;default:return 1}},CEn=(n,e)=>{switch(n){case 44:case 64:return .5;case 52:return e===14?.45:.55;case 208:return .3;default:return .25}},AEn=({numberOfPins:n,pitch:e=2.54,longSidePinLength:t=6})=>{const o=n*e,s=3,a=-((n-1)/2)*e;return Kd(Sy,{children:[Yn(Js,{color:"#222",size:[o,.63*3,2],center:[0,0,2/2]}),Array.from({length:n},(c,l)=>Kd(Sy,{children:[Yn(oT,{color:"gold",children:Kd(u4,{children:[Yn(Js,{color:"gold",size:[.63,.63,s*.9],center:[a+l*e,0,2*.9+2/2]}),Yn(Js,{color:"gold",size:[.63/1.8,.63/1.8,s],center:[a+l*e,0,2+2/2]})]})}),Yn(oT,{color:"gold",children:Kd(u4,{children:[Yn(Js,{color:"gold",size:[.63,.63,t*.9],center:[a+l*e,0,-t/2*.9]}),Yn(Js,{color:"gold",size:[.63/1.8,.63/1.8,t],center:[a+l*e,0,-t/2]})]})})]}))]})},PEn=n=>{const e=["left","bottom","right","top"],{pin_count:t,pn:i,w:r,h:o,p:s,pl:a}=n,c=t/4,l=e[Math.floor((i-1)/c)],u=(i-1)%c,d=s*(c-1),h=s*(c-1),p=-a/2;switch(l){case"left":return{x:-r/2-p,y:h/2-u*s,o:"vert"};case"bottom":return{x:-d/2+u*s,y:-o/2-p,o:"horz"};case"right":return{x:r/2+p,y:-h/2+u*s,o:"vert"};case"top":return{x:d/2-u*s,y:o/2+p,o:"horz"};default:throw new Error("Invalid pin number")}},REn=({num_pins:n,cw:e,ccw:t,startingpin:i})=>{const r=[],o=n/4;let s=1;const a={};for(const c of i??[])a[c]=!0;!a.leftside&&!a.topside&&!a.rightside&&!a.bottomside&&(a.leftside=!0),!a.bottompin&&!a.leftpin&&!a.rightpin&&!a.toppin&&(a.leftside?a.toppin=!0:a.topside?a.rightpin=!0:a.rightside?a.bottompin=!0:a.bottomside&&(a.leftpin=!0)),a.leftside&&a.toppin?s=1:a.leftside&&a.bottompin?s=o:a.bottomside&&a.leftpin?s=o+1:a.bottomside&&a.rightpin?s=o*2:a.rightside&&a.bottompin?s=o*2+1:a.rightside&&a.toppin?s=o*3:a.topside&&a.rightpin?s=o*3+1:a.topside&&a.leftpin&&(s=o*4),r.push(-1);for(let c=0;c<n;c++)r[s]=c+1,s++,s>n&&(s=1);return r},IEn=({num_pins:n=16,bodyWidth:e=9,bodyLength:t=9,bodyThickness:i=.8,thermalPadSize:r,padWidth:o=.25,padLength:s=.25,pitch:a=.5,thermalPadThickness:c=.05})=>{const l=REn({num_pins:n,cw:!0,ccw:!0}),u=[];for(let d=0;d<n;d++){const{x:h,y:p,o:m}=PEn({pin_count:n,pn:d+1,w:e,h:t,p:a,pl:s});let _=o,g=s;m==="vert"&&([_,g]=[g,_]);const x=l[d+1];u.push({pn:x,x:h,y:p,pw:_,pl:g})}return Kd(Sy,{children:[Yn(oT,{color:"grey",children:Yn(Js,{center:{x:0,y:0,z:i/2},size:[e,t,i]})}),u.map((d,h)=>Yn(Js,{center:{x:d.x,y:d.y,z:c/2},size:[d.pw,d.pl,c]})),r?.length!==void 0&&r?.width!==void 0&&Yn(Js,{center:{x:0,y:0,z:c/2},size:[r.width,r.length,c]})]})},NEn=IEn,kEn=()=>{const c=1.1999999999999997;return Kd(Sy,{children:[Yn(Rv,{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}),Yn(Rv,{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}),Yn(Rv,{position:{x:-2.8/2-c/4,y:0,z:.15/2},width:.4,thickness:.15,padContactLength:.5,bodyDistance:c,height:.95}),Yn(Rv,{position:{x:-2.8/2-c/4,y:-1,z:.15/2},width:.4,thickness:.15,padContactLength:.5,bodyDistance:c,height:.95}),Yn(Rv,{position:{x:-2.8/2-c/4,y:1,z:.15/2},width:.4,thickness:.15,padContactLength:.5,bodyDistance:c,height:.95}),Yn(tI,{center:{x:0,y:0,z:0},width:1.6,length:2.9,height:1.2})]})},OEn=kEn,Aye=.6,Pye=.3,oI=.33,u8=.1,LEn=Aye-u8*2,yet=({color:n="#333"})=>Kd(Sy,{children:[Yn(Js,{size:[LEn,Pye,oI],offset:[0,0,oI/2],color:n}),Yn(Js,{size:[u8,Pye,oI],offset:[Aye/2-u8/2,0,oI/2],color:"#ccc"}),Yn(Js,{size:[u8,Pye,oI],offset:[-Aye/2+u8/2,0,oI/2],color:"#ccc"})]}),Rye=.4,Iye=.2,sI=.13,d8=.07,DEn=Rye-d8*2,get=({color:n="#333"})=>Kd(Sy,{children:[Yn(Js,{size:[DEn,Iye,sI],offset:[0,0,sI/2],color:n}),Yn(Js,{size:[d8,Iye,sI],offset:[Rye/2-d8/2,0,sI/2],color:"#ccc"}),Yn(Js,{size:[d8,Iye,sI],offset:[-Rye/2+d8/2,0,sI/2],color:"#ccc"})]}),Nye=3.2,kye=1.6,aI=.9,h8=.5,zEn=Nye-h8*2,xet=({color:n="#333"})=>Kd(Sy,{children:[Yn(Js,{size:[zEn,kye,aI],offset:[0,0,aI/2],color:n}),Yn(Js,{size:[h8,kye,aI],offset:[Nye/2-h8/2,0,aI/2],color:"#ccc"}),Yn(Js,{size:[h8,kye,aI],offset:[-Nye/2+h8/2,0,aI/2],color:"#ccc"})]}),Oye=3.2,Lye=2.5,cI=1,p8=.6,$En=Oye-p8*2,bet=({color:n="#333"})=>Kd(Sy,{children:[Yn(Js,{size:[$En,Lye,cI],offset:[0,0,cI/2],color:n}),Yn(Js,{size:[p8,Lye,cI],offset:[Oye/2-p8/2,0,cI/2],color:"#ccc"}),Yn(Js,{size:[p8,Lye,cI],offset:[-Oye/2+p8/2,0,cI/2],color:"#ccc"})]}),Dye=5,zye=2.5,lI=1.4,f8=.6,FEn=Dye-f8*2,vet=({color:n="#333"})=>Kd(Sy,{children:[Yn(Js,{size:[FEn,zye,lI],offset:[0,0,lI/2],color:n}),Yn(Js,{size:[f8,zye,lI],offset:[Dye/2-f8/2,0,lI/2],color:"#ccc"}),Yn(Js,{size:[f8,zye,lI],offset:[-Dye/2+f8/2,0,lI/2],color:"#ccc"})]}),$ye=6.3,Fye=3.2,uI=1.8,m8=.8,UEn=$ye-m8*2,wet=({color:n="#333"})=>Kd(Sy,{children:[Yn(Js,{size:[UEn,Fye,uI],offset:[0,0,uI/2],color:n}),Yn(Js,{size:[m8,Fye,uI],offset:[$ye/2-m8/2,0,uI/2],color:"#ccc"}),Yn(Js,{size:[m8,Fye,uI],offset:[-$ye/2+m8/2,0,uI/2],color:"#ccc"})]}),BEn=({numberOfPins:n,pitch:e=2.54,legsLength:t=3,outerDiameter:i=.945,innerDiameter:r=.945})=>{const o=r/1.5,s=o*2+i,a=5,c=(n-1)*e+i+e/2,l=o*1.6,u=-((n-1)/2)*e,d=Yn(oT,{color:"#1a1a1a",children:Kd(dV,{children:[Yn(Js,{color:"#000",size:[c,s,a],center:[0,0,a/2]}),Array.from({length:n},(h,p)=>r?Yn(G5,{height:a+.1,radius:r/2,center:[u+p*e,0,a/2],color:"#222"},p):Yn(Js,{size:[l,l,a],center:[u+p*e,0,a/2]},p))]})});return Kd(Sy,{children:[d,Array.from({length:n},(h,p)=>Kd(oT,{color:"silver",children:[Kd(u4,{children:[Yn(Js,{color:"silver",size:[o,o,t*.9],center:[u+p*e,0,-t/2*.9]}),Yn(Js,{color:"silver",size:[o/1.8,o/1.8,t],center:[u+p*e,0,-t/2]})]}),Yn(Js,{color:"silver",size:[l,l,l*.5],center:[u+p*e,0,l/2*.5]})]},p))]})},jEn=({width:n,length:e,innerDiameter:t=1})=>{const i=n,r=e,o=n*.7,s=t/2.5;return Kd(Sy,{children:[Yn(bye,{color:"#1a1a1f",center:[0,0,o/2],size:[r,r,o],roundRadius:.3}),Yn(bye,{color:"#f2f2f2",center:[0,0,o+o*.1/2.5],size:[r,r,o*.1],roundRadius:.14}),Yn(G5,{color:"#1a1a1f",height:o*.8,radius:i/3,center:[0,0,o+o*.8/2]}),Yn(G5,{color:"#1a1a1f",height:o*.2,radius:t/2,center:[r/3,r/3,o+o*.1/2]}),Yn(G5,{color:"#1a1a1f",height:o*.2,radius:t/2,center:[-r/3,-r/3,o+o*.1/2]}),Yn(G5,{color:"#1a1a1f",height:o*.2,radius:t/2,center:[-r/3,r/3,o+o*.1/2]}),Yn(G5,{color:"#1a1a1f",height:o*.2,radius:t/2,center:[r/3,-r/3,o+o*.1/2]}),Yn(fV,{thickness:t/3,width:s,horizontalLength:r*.8,verticalLength:o/2,position:{x:-i/2,y:-r/2,z:-o*1.2}}),Yn(fV,{thickness:t/3,width:s,horizontalLength:r*.8,verticalLength:o/2,position:{x:-i/2,y:r/2,z:-o*1.2},rotation:Math.PI}),Yn(fV,{thickness:t/3,width:s,horizontalLength:r*.8,verticalLength:o/2,position:{x:i/2,y:r/2,z:-o*1.2},rotation:Math.PI}),Yn(fV,{thickness:t/3,width:s,horizontalLength:r*.8,verticalLength:o/2,position:{x:i/2+t/3.6,y:-r/2,z:-o*1.2}})]})},fV=n=>{const{thickness:e,width:t,horizontalLength:i,verticalLength:r,rotation:o=0,position:s}=n,a=[[0,i],[-r/3,i/3],[-r/5,i/4],[0,0]],c=vye(a,e);return Yn(oT,{color:"#f2f2f2",children:Yn(Kb,{offset:{x:s?.x||0,y:s?.y||0,z:s?.z||0},children:Yn(eI,{rotation:[0,55,o],children:Yn(a8,{height:t,children:Yn(s8,{points:c.map(l=>[l.y,l.x])})})})})})},HEn=({pinCount:n,leadLength:e,leadWidth:t,pitch:i,bodyWidth:r})=>{const o=Math.ceil(n/2),s=(o-1)*i/2,a=.25,c=1,l=.8,u=e*0,d=i*(o-1)+t+.2,h=r*.55;return Kd(Sy,{children:[Array.from({length:o}).map((p,m)=>Yn(Rv,{position:{x:-r/2-u,y:m*i-s,z:a/2},width:t,thickness:a,padContactLength:e/2,bodyDistance:e+.2,height:l})),Array.from({length:o}).map((p,m)=>Yn(Rv,{rotation:Math.PI,position:{x:r/2+u,y:m*i-s,z:a/2},width:t,thickness:a,padContactLength:e/2,bodyDistance:e+.2,height:l})),Yn(tI,{center:{x:0,y:0,z:a/2},width:h,length:d,height:c})]})},VEn=({pinCount:n,pitch:e,leadWidth:t,leadLength:i,bodyWidth:r,bodyLength:o})=>{const s=n===8?{pitch:.65,leadWidth:.3}:{pitch:.5,leadWidth:.225},a=isNaN(parseFloat(e))?s.pitch:parseFloat(e),c=isNaN(parseFloat(t))?s.leadWidth:parseFloat(t)*.8,l=isNaN(parseFloat(r))?2.6:parseFloat(r)*.8,u=isNaN(parseFloat(o))?2+Number(a)*1.4:parseFloat(o),d=n/2,h=(d-1)*a/2,p=.15,m=.8,_=4.5,g=(_-l)/2,x=g*.5;return Kd(Sy,{children:[Array.from({length:d}).map((b,w)=>Yn(Rv,{position:{x:-_/2,y:h-w*a,z:p/2},width:c,thickness:p,padContactLength:x+.05,bodyDistance:g+.05,height:m})),Array.from({length:d}).map((b,w)=>Yn(Rv,{rotation:Math.PI,position:{x:_/2,y:h-w*a,z:p/2},width:c,thickness:p,padContactLength:x+.05,bodyDistance:g+.05,height:m})),Yn(tI,{center:{x:0,y:0,z:p/2},width:l,length:u,height:1})]})},GEn=()=>{const d=Yn(oT,{color:"#222",children:Kd(uV,{children:[Yn(Kb,{z:.15,children:Yn(Js,{size:[1.65,.8,.3]})}),Kd(u4,{children:[Yn(Kb,{z:.3,children:Yn(Js,{size:[1.65,.8,.01]})}),Yn(Kb,{z:.6,children:Yn(Js,{size:[1.45,.6000000000000001,.01]})})]})]})});return Kd(Sy,{children:[Yn(Js,{color:"#ccc",size:[.5,.6,.12],center:[-.725,0,.12/2]}),Yn(Js,{color:"#ccc",size:[.5,.6,.12],center:[.725,0,.12/2]}),d]})},YEn=({footprint:n})=>{const e=pEn.string(n).json();switch(e.fn){case"dip":return Yn(gEn,{numPins:e.num_pins,pitch:e.p,bodyWidth:e.w});case"tssop":return Yn(bEn,{pinCount:e.num_pins,leadLength:e.pl,leadWidth:e.pw,pitch:e.p,bodyWidth:e.w});case"vssop":return Yn(VEn,{pinCount:e.num_pins,leadLength:e.pl,leadWidth:e.pw,pitch:e.p,bodyWidth:e.w,bodyLength:e.h});case"qfp":return Yn(EEn,{pinCount:e.num_pins,pitch:e.p,leadWidth:e.pw,padContactLength:e.pl,bodyWidth:e.w});case"qfn":return Yn(NEn,{num_pins:e.num_pins,bodyWidth:e.w,bodyLength:e.h,pitch:e.p,padLength:e.pl,padWidth:e.pw,thermalPadSize:{width:e.thermalpad.x,length:e.thermalpad.y}});case"pinrow":if(e.male)return Yn(AEn,{numberOfPins:e.num_pins,pitch:e.p});if(e.female)return Yn(BEn,{numberOfPins:e.num_pins,pitch:e.p});case"cap":switch(e.imperial){case"0402":return Yn(fet,{color:"#856c4d"});case"0603":return Yn(met,{color:"#856c4d"});case"0805":return Yn(_et,{color:"#856c4d"});case"0201":return Yn(yet,{color:"#856c4d"});case"01005":return Yn(get,{color:"#856c4d"});case"1206":return Yn(xet,{color:"#856c4d"});case"1210":return Yn(bet,{color:"#856c4d"});case"2010":return Yn(vet,{color:"#856c4d"});case"2512":return Yn(wet,{color:"#856c4d"})}case"sot235":return Yn(OEn,{});case"pushbutton":return Yn(jEn,{width:e.w,length:e.h,innerDiameter:e.id});case"soic":return Yn(HEn,{pinCount:e.num_pins,leadLength:e.pl,leadWidth:e.pw,pitch:e.p,bodyWidth:e.w});case"sod523":return Yn(GEn,{})}const t=n.match(/_color\(([^)]+)\)/),i=t?t[1]:void 0;switch(e.imperial){case"0402":return Yn(fet,{color:i});case"0603":return Yn(met,{color:i});case"0805":return Yn(_et,{color:i});case"0201":return Yn(yet,{color:i});case"01005":return Yn(get,{color:i});case"1206":return Yn(xet,{color:i});case"1210":return Yn(bet,{color:i});case"2010":return Yn(vet,{color:i});case"2512":return Yn(wet,{color:i})}return null},qEn=n=>n&&typeof n=="object"&&"type"in n,dI=n=>{if(typeof n=="number")return n;if(typeof n=="string"){const e=/^(-?\d+(?:\.\d+)?)\s*deg$/i.exec(n);if(e)return parseFloat(e[1])*Math.PI/180;const t=Number(n);if(!Number.isNaN(t))return t}return 0},XEn=n=>Array.isArray(n)?[Number(n[0])||0,Number(n[1])||0,Number(n[2])||0]:typeof n=="object"&&n?[Number(n.x)||0,Number(n.y)||0,Number(n.z)||0]:[0,0,0];function sT(n,e,t){const{jscad:{primitives:i,booleans:r,hulls:o,geometries:s,extrusions:a,transforms:c}}=t;if(n==null||n===!1)return[];if(Array.isArray(n))return n.flatMap(h=>sT(h,e,t));if(!qEn(n))return[];const{type:l,props:u,children:d}=n;if(l===uet)return(d??[]).flatMap(h=>sT(h,e,t));if(l===oT){const h=u?.color;return(d??[]).flatMap(p=>sT(p,h??e,t))}if(l===Kb){const h=XEn(u?.offset??{x:u?.x,y:u?.y,z:u?.z});return(d??[]).flatMap(m=>sT(m,e,t)).map(({geom:m,color:_})=>({geom:c.translate(h,m),color:_??e}))}if(l===eI){const h=Array.isArray(u?.rotation)?[dI(u.rotation[0]),dI(u.rotation[1]),dI(u.rotation[2])]:[dI(u?.x??0),dI(u?.y??0),dI(u?.z??0)];return(d??[]).flatMap(m=>sT(m,e,t)).map(({geom:m,color:_})=>({geom:c.rotateZ(h[2],c.rotateY(h[1],c.rotateX(h[0],m))),color:_}))}if(l===uV||l===dV||l===u4){const h=(d??[]).flatMap(m=>sT(m,e,t)).map(m=>m.geom);if(h.length===0)return[];let p;return l===uV?p=r.union(h):l===dV?p=r.subtract(h[0],h.slice(1)):p=o.hull(h),[{geom:p}]}if(l===s8){const h=u?.points??[];return[{geom:s.geom2.fromPoints(h),color:e??u?.color}]}if(l===a8){const h=(d??[]).flatMap(g=>sT(g,e,t)).map(g=>g.geom);if(h.length===0)return[];const p=h.length>1?r.union(h):h[0],m=u?.height??u?.h??1;let _=a.extrudeLinear({height:m},p);if(_.polygons)for(const g of _.polygons)!g.plane||!g.vertices||g.vertices.length<3||g.vertices.reverse();return[{geom:_,color:e??u?.color}]}if(l===Js||l===det||l===G5||l===het||l===bye){let h;if(l===Js){const p=u?.size??[1,1,1],m=u?.offset,_=u?.center??(m?[m[0],m[1],m[2]]:[0,0,0]);h=i.cuboid({size:p,center:_})}else if(l===det){const p=u?.size??1,m=u?.offset,_=u?.center??(m?[m[0],m[1],m[2]]:[0,0,0]);h=i.cube({size:p,center:_})}else if(l===G5){const p=u?.height??1,m=u?.radius??1,_=u?.center??[0,0,0];h=i.cylinder({height:p,radius:m,center:_})}else if(l===het){const p=u?.radius??1,m=u?.center??[0,0,0];h=i.sphere({radius:p,center:m})}else{const p=u?.size??[1,1,1],m=u?.roundRadius??.1,_=u?.center??[0,0,0];h=i.roundedCuboid({size:p,roundRadius:m,center:_})}return[{geom:h,color:e??u?.color}]}if(typeof l=="function"){const h=l(u??{});return sT(h,e,t)}return(d??[]).flatMap(h=>sT(h,e,t))}function WEn(n,e){return{geometries:sT(n,void 0,{jscad:e})}}function Eet(n){if(n.polygons){const e=[],t=[],i=[];let r=0;for(const s of n.polygons){for(const c of s.vertices)c.index=r,e.push(c[0],c[1],c[2]),n.color&&n.color.length>=3?i.push(n.color[0],n.color[1],n.color[2]):i.push(1,1,1),r++;const a=s.vertices[0].index;for(let c=2;c<s.vertices.length;c++){const l=s.vertices[c-1].index,u=s.vertices[c].index;t.push(a,l,u)}}const o=new Pf;if(o.setAttribute("position",new ym(new Float32Array(e),3)),o.setIndex(t),i.length>0&&o.setAttribute("color",new ym(new Float32Array(i),3)),n.transforms){const s=new Qa;s.fromArray(n.transforms),o.applyMatrix4(s)}return o.computeVertexNormals(),o}if(n.sides){const e=[],t=[];for(const r of n.sides)e.push(r[0][0],r[0][1],0),n.color&&n.color.length>=3?t.push(n.color[0],n.color[1],n.color[2]):t.push(1,1,1);const i=new Pf;if(i.setAttribute("position",new ym(new Float32Array(e),3)),t.length>0&&i.setAttribute("color",new ym(new Float32Array(t),3)),n.transforms){const r=new Qa;r.fromArray(n.transforms),i.applyMatrix4(r)}return i}return console.error("Invalid CSG object: neither polygons nor sides found"),new Pf}function KEn(n,e){const t=xye(YEn,{footprint:n});return WEn(t,e)}var ZEn=({jscadPlan:n,positionOffset:e,rotationOffset:t,onHover:i,onUnhover:r,isHovered:o,scale:s})=>{const{rootObject:a}=_b(),{threeGeom:c,material:l}=fe.useMemo(()=>{const d=(0,pxn.executeJscadOperations)(fxn.default,n);if(!d||!d.polygons&&!d.sides)return{threeGeom:null,material:null};const h=Eet(d),p=new Gb({vertexColors:!0,side:qg});return{threeGeom:h,material:p}},[n]),u=fe.useMemo(()=>c?new Ma(c,l):null,[c,l]);return fe.useEffect(()=>{if(!(!u||!a))return a.add(u),()=>{a.remove(u)}},[a,u]),fe.useEffect(()=>{u&&(e&&u.position.fromArray(e),t&&u.rotation.fromArray(t),s!==void 0&&u.scale.setScalar(s))},[u,e?.[0],e?.[1],e?.[2],t?.[0],t?.[1],t?.[2],s]),fe.useMemo(()=>{if(l)if(o){const d=new Jr(l.color.getHex());l.emissive.copy(d),l.emissive.setRGB(0,0,1),l.emissiveIntensity=.2}else l.emissiveIntensity=0},[o,l]),c?ce.jsx(i8,{isHovered:o,onHover:i,onUnhover:r,object:u}):null},QEn=vc(eV()),JEn=({positionOffset:n,footprint:e,rotationOffset:t,onHover:i,onUnhover:r,isHovered:o,scale:s})=>{const{rootObject:a}=_b(),c=fe.useMemo(()=>{if(!e)return null;const{geometries:l}=KEn(e,QEn),u=new Qw;for(const d of l.flat(1/0)){const h=d.geom;if(!h||!h.polygons&&!h.sides)continue;const p=new Jr(d.color);p.convertLinearToSRGB();const m={...h,color:[p.r,p.g,p.b]},_=Eet(m),g=new Gb({vertexColors:!0,side:qg}),x=new Ma(_,g);u.add(x)}return u},[e]);return fe.useEffect(()=>{if(!(!c||!a))return a.add(c),()=>{a.remove(c)}},[a,c]),fe.useEffect(()=>{c&&(n&&c.position.fromArray(n),t&&c.rotation.fromArray(t),s!==void 0&&c.scale.setScalar(s))},[c,n?.[0],n?.[1],n?.[2],t?.[0],t?.[1],t?.[2],s]),fe.useEffect(()=>{c&&c.traverse(l=>{l instanceof Ma&&l.material instanceof Gb&&(o?(l.material.emissive.setHex(255),l.material.emissiveIntensity=.2):l.material.emissiveIntensity=0)})},[o,c]),c?ce.jsx(i8,{isHovered:o,onHover:i,onUnhover:r,object:c}):null},eTn=(...n)=>n,Tet=({children:n,position:e,style:t})=>{const{camera:i,renderer:r}=_b(),o=fe.useRef(document.createElement("div")),[s,a]=fe.useState(null);return fe.useEffect(()=>{const c=r?.domElement.parentNode;if(c)return c.style.position!=="relative"&&c.style.position!=="absolute"&&(c.style.position="relative"),c.appendChild(o.current),a(rz.createPortal(n,o.current)),()=>{c.contains(o.current)&&c.removeChild(o.current)}},[r,n]),ZR(()=>{if(!i||!o.current||!r)return;const c=new en(...e);c.project(i);const l=r.domElement.getBoundingClientRect(),u=Math.round((c.x+1)/2*l.width),d=Math.round((-c.y+1)/2*l.height);o.current.style.position="absolute",o.current.style.left=`${u}px`,o.current.style.top=`${d}px`,o.current.style.pointerEvents="none",o.current.style.zIndex="1000",t&&Object.assign(o.current.style,t)},[i,r,e,t]),s},Met={boardBody:!0,topCopper:!0,bottomCopper:!0,adhesive:!1,solderPaste:!1,topSilkscreen:!0,bottomSilkscreen:!0,topMask:!0,bottomMask:!0,throughHoleModels:!0,smtModels:!0,virtualModels:!1,modelsNotInPosFile:!1,modelsMarkedDNP:!1,modelBoundingBoxes:!1,threedAxis:!1,backgroundStart:!0,backgroundEnd:!0},Cet=fe.createContext(void 0),tTn=({children:n})=>{const[e,t]=fe.useState(Met),i=fe.useCallback(a=>{t(c=>({...c,[a]:!c[a]}))},[]),r=fe.useCallback((a,c)=>{t(l=>({...l,[a]:c}))},[]),o=fe.useCallback(()=>{t(Met)},[]),s=fe.useMemo(()=>({visibility:e,toggleLayer:i,setLayerVisibility:r,resetToDefaults:o}),[e,i,r,o]);return ce.jsx(Cet.Provider,{value:s,children:n})},_8=()=>{const n=fe.useContext(Cet);if(!n)throw new Error("useLayerVisibility must be used within a LayerVisibilityProvider");return n},Aet=({cad_component:n,circuitJson:e})=>{const[t,i]=fe.useState(!1),{visibility:r}=_8(),[o,s]=fe.useState(null),a=fe.useCallback(m=>{m?.mousePosition?(i(!0),s(m.mousePosition)):(i(!1),s(null))},[]),c=fe.useCallback(()=>{i(!1),s(null)},[]),l=fe.useMemo(()=>fs(e).source_component.getUsing({source_component_id:n.source_component_id})?.name,[e,n.source_component_id]),u=n.model_obj_url??n.model_wrl_url??n.model_stl_url,d=n.model_glb_url??n.model_gltf_url,h=n.rotation?eTn(n.rotation.x*Math.PI/180,n.rotation.y*Math.PI/180,n.rotation.z*Math.PI/180):void 0;let p=null;return u?p=ce.jsx(lxn,{url:u,position:n.position?[n.position.x,n.position.y,n.position.z]:void 0,rotation:h,scale:n.model_unit_to_mm_scale_factor,onHover:a,onUnhover:c,isHovered:t},n.cad_component_id):d?p=ce.jsx(hxn,{gltfUrl:d,position:n.position?[n.position.x,n.position.y,n.position.z]:void 0,rotation:h,scale:n.model_unit_to_mm_scale_factor,onHover:a,onUnhover:c,isHovered:t},n.cad_component_id):n.model_jscad?p=ce.jsx(ZEn,{jscadPlan:n.model_jscad,rotationOffset:h,scale:n.model_unit_to_mm_scale_factor,onHover:a,onUnhover:c,isHovered:t},n.cad_component_id):n.footprinter_string&&(p=ce.jsx(JEn,{positionOffset:n.position?[n.position.x,n.position.y,n.position.z]:void 0,rotationOffset:h,footprint:n.footprinter_string,scale:n.model_unit_to_mm_scale_factor,onHover:a,onUnhover:c,isHovered:t})),r.smtModels?ce.jsxs(ce.Fragment,{children:[p,t&&o?ce.jsx(Tet,{position:o,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:l??"<unknown>"}):null]}):null},Pet={version:"0.0.425"},d4=({children:n,parent:e,position:t,rotation:i,scale:r,color:o,fontSize:s,anchorX:a,anchorY:c,depthOffset:l})=>{const{rootObject:u}=_b(),d=fe.useMemo(()=>{const h=new I6e;return h.text=n,t&&h.position.fromArray(t),i&&h.rotation.fromArray(i),r&&h.scale.fromArray(r),h.color=o||"white",h.fontSize=s||1,h.anchorX=a||"center",h.anchorY=c||"middle",h.depthOffset=l||0,h.font=null,h.sync(),h},[n,t,i,r,o,s,a,c,l]);return fe.useEffect(()=>{const h=e||u;if(!(!h||!d))return h.add(d),()=>{h.remove(d),d.dispose()}},[u,e,d]),null};typeof window<"u"&&(window.TSCI_MAIN_CAMERA_ROTATION=new Ww(0,0,0));function nTn(n,e){const t=new Mv().setFromEuler(new Ww(n.x,n.y,n.z)),i=new en(0,0,1);return i.applyQuaternion(t),i.multiplyScalar(e)}var iTn=({})=>{const{camera:n,scene:e}=_b();fe.useEffect(()=>{if(!e)return;const i=new OOe(16777215,Math.PI/2);return e.add(i),()=>{e.remove(i)}},[e]),ZR(()=>{if(!n)return;const i=window.TSCI_MAIN_CAMERA_ROTATION,r=nTn(i,2);n.position.copy(r),n.lookAt(0,0,0)});const t=fe.useMemo(()=>{const i=new Qw;i.rotation.fromArray([Math.PI/2,0,0]);const r=new Ma(new j2(1,1,1),new Gb({color:"white"}));i.add(r);const o=new PO(new X6t(new j2(1,1,1)),new RA({color:0,linewidth:2}));return i.add(o),i},[]);return fe.useEffect(()=>{if(e)return e.add(t),()=>{e.remove(t)}},[e,t]),ce.jsxs(ce.Fragment,{children:[ce.jsx(d4,{parent:t,position:[0,0,.51],fontSize:.25,color:"black",children:"Front"}),ce.jsx(d4,{parent:t,position:[0,0,-.51],fontSize:.25,color:"black",rotation:[0,Math.PI,0],children:"Back"}),ce.jsx(d4,{parent:t,position:[.51,0,0],fontSize:.25,color:"black",rotation:[0,Math.PI/2,0],children:"Right"}),ce.jsx(d4,{parent:t,position:[-.51,0,0],fontSize:.25,color:"black",rotation:[0,-Math.PI/2,0],children:"Left"}),ce.jsx(d4,{parent:t,position:[0,.51,0],fontSize:.25,color:"black",rotation:[-Math.PI/2,0,0],children:"Top"}),ce.jsx(d4,{parent:t,position:[0,-.51,0],fontSize:.25,color:"black",rotation:[Math.PI/2,0,0],children:"Bottom"})]})};function rTn(n){n.querySelectorAll("canvas").forEach(e=>e.remove())}var oTn=n=>{n.outputColorSpace=k2,n.toneMapping=uNe,n.toneMappingExposure=1},Ret=fe.forwardRef(({children:n,scene:e,camera:t,style:i},r)=>{const o=fe.useRef(null),[s,a]=fe.useState(null),c=fe.useRef([]),l=fe.useCallback(p=>{c.current.push(p)},[]),u=fe.useCallback(p=>{c.current=c.current.filter(m=>m!==p)},[]),d=fe.useMemo(()=>new H9,[]);e?.up&&d.up.set(e.up.x,e.up.y,e.up.z);const h=fe.useRef(new Yp);return fe.useImperativeHandle(r,()=>h.current),fe.useEffect(()=>{if(!o.current)return;rTn(o.current);const p=new Zte({antialias:!0,alpha:!0});oTn(p),p.setSize(o.current.clientWidth,o.current.clientHeight),p.setPixelRatio(window.devicePixelRatio),o.current.appendChild(p.domElement);const m=new Vb(75,o.current.clientWidth/o.current.clientHeight,.1,1e3);t?.up&&m.up.set(t.up[0],t.up[1],t.up[2]),t?.position&&m.position.set(t.position[0],t.position[1],t.position[2]),m.lookAt(0,0,0),d.add(h.current),window.__TSCIRCUIT_THREE_OBJECT=h.current,a({scene:d,camera:m,renderer:p,rootObject:h.current,addFrameListener:l,removeFrameListener:u});let _;const g=new I8t,x=()=>{const w=g.getElapsedTime(),E=g.getDelta();c.current.forEach(N=>N(w,E)),p.render(d,m),_=requestAnimationFrame(x)};x();const b=()=>{o.current&&(m.aspect=o.current.clientWidth/o.current.clientHeight,m.updateProjectionMatrix(),p.setSize(o.current.clientWidth,o.current.clientHeight))};return window.addEventListener("resize",b),()=>{window.removeEventListener("resize",b),cancelAnimationFrame(_),o.current&&p.domElement&&o.current.removeChild(p.domElement),p.dispose(),d.remove(h.current),window.__TSCIRCUIT_THREE_OBJECT===h.current&&(window.__TSCIRCUIT_THREE_OBJECT=void 0)}},[d,l,u]),ce.jsx("div",{ref:o,style:{width:"100%",height:"100%",...i},children:s&&ce.jsx(aJe.Provider,{value:s,children:ce.jsx(rxn,{children:n})})})}),sTn=({autoRotate:n,autoRotateSpeed:e,onStart:t,panSpeed:i,rotateSpeed:r,zoomSpeed:o,enableDamping:s,dampingFactor:a,target:c,onControlsChange:l})=>{const{camera:u,renderer:d}=_b(),h=fe.useMemo(()=>!u||!d?null:new i7t(u,d.domElement),[u,d]);return fe.useEffect(()=>{if(l)return l(h??null),()=>{l(null)}},[h,l]),fe.useEffect(()=>{h&&(h.autoRotate=n||!1,h.autoRotateSpeed=e||1,i!==void 0&&(h.panSpeed=i),r!==void 0&&(h.rotateSpeed=r),o!==void 0&&(h.zoomSpeed=o),s!==void 0&&(h.enableDamping=s),a!==void 0&&(h.dampingFactor=a),h.zoomToCursor=!0,c&&(h.target.set(c[0],c[1],c[2]),h.update()))},[h,n,e,i,r,o,s,a,c]),fe.useEffect(()=>{if(!(!h||!t))return h.addEventListener("start",t),()=>{h.removeEventListener("start",t)}},[h,t]),fe.useEffect(()=>{if(h)return()=>{h.dispose()}},[h]),ZR(()=>{h?.update()},[h]),null},aTn=`
5083
+ `).replace(/d 0\./g,"d 1."),p=l.replace(/newmtl[\s\S]*?endmtl/g,"").replace(/^mtllib.*/gm,""),m=new WLt;m.setMaterialOptions({invertTrProperty:!0});const _=m.parse(h.replace(/Kd\s+([\d.]+)\s+([\d.]+)\s+([\d.]+)/g,"Kd $2 $2 $2"),"embedded.mtl");return d.setMaterials(_),d.parse(p)}return d.parse(l.replace(/^mtllib.*/gm,""))}catch(c){return c}}function a(){if(r.has(i)){const l=r.get(i);return l.result?Promise.resolve(l.result.clone()):l.promise.then(u=>u instanceof Error?u:u.clone())}const c=s().then(l=>(l instanceof Error||r.set(i,{...r.get(i),result:l}),l));return r.set(i,{promise:c,result:null}),c}return a().then(c=>{o||t(c)}).catch(c=>{console.error(c)}),()=>{o=!0}},[n]),e}function lxn({url:n,position:e,rotation:t,onHover:i,onUnhover:r,isHovered:o,scale:s}){const a=cxn(n),{rootObject:c}=_b(),l=fe.useMemo(()=>a&&!(a instanceof Error)?a:new Ma(new j2(.5,.5,.5),new Gb({transparent:!0,color:"red",opacity:.25})),[a]);if(fe.useEffect(()=>{if(!(!c||!l))return c.add(l),()=>{c.remove(l)}},[c,l]),fe.useEffect(()=>{l&&(e&&(Array.isArray(e)?l.position.fromArray(e):l.position.copy(e)),t&&(Array.isArray(t)?l.rotation.fromArray(t):l.rotation.copy(t)),s!==void 0&&l.scale.setScalar(s))},[l,Array.isArray(e)?e[0]:e?.x,Array.isArray(e)?e[1]:e?.y,Array.isArray(e)?e[2]:e?.z,Array.isArray(t)?t[0]:t?.x,Array.isArray(t)?t[1]:t?.y,Array.isArray(t)?t[2]:t?.z,s]),a instanceof Error)throw a;return ce.jsx(i8,{isHovered:o,onHover:i,onUnhover:r,object:l})}var lJe=new WeakMap,uxn=()=>{const n=new a_;return n.name="fallback-environment-map",n.mapping=r$,n},dxn=n=>{if(!n)return null;const e=n,t=lJe.get(e);if(t)return t;let i;if(n instanceof Zte){const r=new Yte(n);i=r.fromScene(dLt(),.04).texture,r.dispose()}else i=uxn();return lJe.set(e,i),i},uJe=1.25;function hxn({gltfUrl:n,position:e,rotation:t,onHover:i,onUnhover:r,isHovered:o,scale:s}){const{renderer:a,rootObject:c}=_b(),[l,u]=fe.useState(null);return fe.useEffect(()=>{if(!n)return;const d=new pLt;let h=!0;return d.load(n,p=>{h&&u(p.scene)},void 0,p=>{h&&console.error(`An error happened loading ${n}`,p)}),()=>{h=!1}},[n]),fe.useEffect(()=>{l&&(e&&l.position.fromArray(e),t&&l.rotation.fromArray(t),s!==void 0&&l.scale.setScalar(s))},[l,e?.[0],e?.[1],e?.[2],t?.[0],t?.[1],t?.[2],s]),fe.useEffect(()=>{if(!(!c||!l))return c.add(l),()=>{c.remove(l)}},[c,l]),fe.useEffect(()=>{if(!l||!a)return;const d=dxn(a);if(!d)return;const h=[],p=m=>{m instanceof Gb&&(h.push({material:m,envMap:m.envMap??null,envMapIntensity:m.envMapIntensity??1}),m.envMap||(m.envMap=d),(typeof m.envMapIntensity!="number"||m.envMapIntensity<uJe)&&(m.envMapIntensity=uJe),m.needsUpdate=!0)};return l.traverse(m=>{if(!(m instanceof Ma))return;const _=m.material;Array.isArray(_)?_.forEach(p):_&&p(_)}),()=>{h.forEach(({material:m,envMap:_,envMapIntensity:g})=>{m.envMap=_,m.envMapIntensity=g,m.needsUpdate=!0})}},[l,a]),fe.useEffect(()=>{l&&l.traverse(d=>{d instanceof Ma&&d.material instanceof Gb&&(o?(d.material.emissive.setHex(255),d.material.emissiveIntensity=.2):d.material.emissiveIntensity=0)})},[o,l]),l?ce.jsx(i8,{isHovered:o,onHover:i,onUnhover:r,object:l}):null}var pxn=vc($Ze()),fxn=vc(eV()),dJe={in:25.4,inch:25.4,mil:.0254,mm:1,m:1e3,cm:10,ft:304.8,feet:304.8},gh=n=>{let e=typeof n=="number"?"mm":n.replace(/^[^a-zA-Z]+/g,"").toLowerCase();e||(e="mm");const t=typeof n=="number"?n:Number.parseFloat(n.split(e)[0]);if(e in dJe)return t*dJe[e];throw new Error(`Unsupported unit: ${e}`)},r8=gh,hJe={Hz:{baseUnit:"Hz",variants:{MHz:1e6,kHz:1e3,Hz:1}},g:{baseUnit:"g",variants:{kg:1e3,g:1}},Ω:{baseUnit:"Ω",variants:{mΩ:.001,Ω:1,kΩ:1e3,KΩ:1e3,kohm:1e3,MΩ:1e6,GΩ:1e9,TΩ:1e12}},V:{baseUnit:"V",variants:{mV:.001,V:1,kV:1e3,KV:1e3,MV:1e6,GV:1e9,TV:1e12}},A:{baseUnit:"A",variants:{µA:1e-6,mA:.001,ma:.001,A:1,kA:1e3,MA:1e6}},F:{baseUnit:"F",variants:{pF:1e-12,nF:1e-9,µF:1e-6,uF:1e-6,mF:.001,F:1}},ml:{baseUnit:"ml",variants:{ml:1,mL:1,l:1e3,L:1e3}},deg:{baseUnit:"deg",variants:{rad:180/Math.PI}},ms:{baseUnit:"ms",variants:{fs:1e-12,ps:1e-9,ns:1e-6,us:.001,µs:.001,ms:1,s:1e3}},mm:{baseUnit:"mm",variants:{nm:1e-6,µm:.001,um:.001,mm:1,cm:10,dm:100,m:1e3,km:1e6,in:25.4,ft:304.8,IN:25.4,FT:304.8,yd:914.4,mi:1609344,mil:.0254}}},sye=new Set;for(const[n,e]of Object.entries(hJe)){sye.add(n);for(const t of Object.keys(e.variants))sye.add(t)}function mxn(n){for(const[e,t]of Object.entries(hJe))if(n in t.variants)return{baseUnit:t.baseUnit,conversionFactor:t.variants[n]};return{baseUnit:n,conversionFactor:1}}var pJe={tera:1e12,T:1e12,giga:1e9,G:1e9,mega:1e6,M:1e6,kilo:1e3,k:1e3,deci:.1,d:.1,centi:.01,c:.01,milli:.001,m:.001,micro:1e-6,u:1e-6,µ:1e-6,nano:1e-9,n:1e-9,pico:1e-12,p:1e-12};function q2(n){if(n==null)return{parsedUnit:null,unitOfValue:null,value:null};if(typeof n=="string"&&n.match(/^-?[\d\.]+$/))return{value:Number.parseFloat(n),parsedUnit:null,unitOfValue:null};if(typeof n=="number")return{value:n,parsedUnit:null,unitOfValue:null};if(typeof n=="object"&&"x"in n&&"y"in n){const{parsedUnit:a,unitOfValue:c}=q2(n.x),l=q2(n.x),u=q2(n.y);return l.value===null||u.value===null?{parsedUnit:null,unitOfValue:null,value:null}:{parsedUnit:a,unitOfValue:c,value:{x:l.value,y:u.value}}}const t=n.toString().split("").reverse().join("").match(/[^\d\s]+/)?.[0];if(!t)throw new Error(`Could not determine unit: "${n}"`);const i=t.split("").reverse().join(""),r=n.slice(0,-i.length);if(i in pJe&&!sye.has(i)){const a=pJe[i];return{parsedUnit:null,unitOfValue:null,value:Number.parseFloat(r)*a}}const{baseUnit:o,conversionFactor:s}=mxn(i);return{parsedUnit:i,unitOfValue:o,value:s*Number.parseFloat(r)}}var aye=R().or(Pe()).transform(n=>q2(n).value),fJe=R().or(Pe()).transform(n=>q2(n).value).transform(n=>Number.parseFloat(n.toPrecision(12))),_xn=R().or(Pe()).transform(n=>q2(n).value),QR=R().or(Pe()).transform(n=>q2(n).value),_t=R().or(Pe()).transform(n=>q2(n).value),cye=R().or(Pe()).transform(n=>q2(n).value),fi=_t;R().or(Pe()).transform(n=>q2(n).value);var lye=R().or(Pe()).transform(n=>q2(n).value),JR=lye,yxn=R().datetime(),iS=R().or(Pe()).transform(n=>typeof n=="number"?n:n.endsWith("deg")?Number.parseFloat(n.split("deg")[0]):n.endsWith("rad")?Number.parseFloat(n.split("rad")[0])*180/Math.PI:Number.parseFloat(n)),gxn=Pe().or(R().endsWith("mAh")).transform(n=>{if(typeof n=="string"){const e=n.replace("mAh",""),t=Number.parseFloat(e);if(Number.isNaN(t))throw new Error("Invalid capacity");return t}return n}).describe("Battery capacity in mAh"),Os=Se({x:fi,y:fi}),uye=Se({x:fi,y:fi,z:fi}),mJe=Se({width:Pe(),height:Pe()}),xxn=n=>{const e="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";return Array.from({length:n},()=>e[Math.floor(Math.random()*e.length)]).join("")},Yi=n=>R().optional().default(()=>`${n}_${xxn(10)}`),tV=Xt(["top_left","top_center","top_right","center_left","center","center_right","bottom_left","bottom_center","bottom_right"]),bxn=Xt(["jlcpcb","macrofab","pcbway","digikey","mouser","lcsc"]),Bx=Se({type:pe("source_component"),ftype:R().optional(),source_component_id:R(),name:R(),manufacturer_part_number:R().optional(),supplier_part_numbers:rs(bxn,ut(R())).optional(),display_value:R().optional(),are_pins_interchangeable:Je().optional(),internally_connected_source_port_ids:ut(ut(R())).optional(),source_group_id:R().optional(),subcircuit_id:R().optional()}),_Je=Bx.extend({ftype:pe("simple_capacitor"),capacitance:fJe,max_voltage_rating:QR.optional(),display_capacitance:R().optional(),max_decoupling_trace_length:fi.optional()}),yJe=Bx.extend({ftype:pe("simple_resistor"),resistance:aye,display_resistance:R().optional()}),dye=Bx.extend({ftype:pe("simple_diode")}),gJe=dye.extend({ftype:pe("simple_led"),color:R().optional(),wavelength:R().optional()}),vxn=Bx.extend({ftype:pe("simple_ground")}),xJe=Bx.extend({ftype:pe("simple_chip")}),bJe=Bx.extend({ftype:pe("simple_power_source"),voltage:QR}),wxn=Bx.extend({ftype:pe("simple_fuse"),current_rating_amps:Pe().describe("Nominal current in amps the fuse is rated for"),voltage_rating_volts:Pe().describe("Voltage rating in volts, e.g. ±5V would be 5")}),vJe=Bx.extend({ftype:pe("simple_battery"),capacity:gxn}),wJe=Bx.extend({ftype:pe("simple_inductor"),inductance:_xn,max_current_rating:Pe().optional()}),SJe=Bx.extend({ftype:pe("simple_push_button")}),EJe=Bx.extend({ftype:pe("simple_potentiometer"),max_resistance:aye}),Sxn=Bx.extend({ftype:pe("simple_crystal"),frequency:Pe().describe("Frequency in Hz"),load_capacitance:Pe().optional().describe("Load capacitance in pF")}),TJe=Bx.extend({ftype:pe("simple_pin_header"),pin_count:Pe(),gender:Xt(["male","female"]).optional().default("male")}),MJe=Bx.extend({ftype:pe("simple_pinout")}),CJe=Bx.extend({ftype:pe("simple_resonator"),load_capacitance:fJe,equivalent_series_resistance:aye.optional(),frequency:cye}),AJe=Bx.extend({ftype:pe("simple_transistor"),transistor_type:Xt(["npn","pnp"])}),PJe=Bx.extend({ftype:pe("simple_test_point"),footprint_variant:Xt(["pad","through_hole"]).optional(),pad_shape:Xt(["rect","circle"]).optional(),pad_diameter:Bn([Pe(),R()]).optional(),hole_diameter:Bn([Pe(),R()]).optional(),width:Bn([Pe(),R()]).optional(),height:Bn([Pe(),R()]).optional()}),RJe=Bx.extend({ftype:pe("simple_mosfet"),channel_type:Xt(["n","p"]),mosfet_mode:Xt(["enhancement","depletion"])}),IJe=Bx.extend({ftype:pe("simple_switch")}),NJe=Se({type:pe("source_project_metadata"),name:R().optional(),software_used_string:R().optional(),project_url:R().optional(),created_at:yxn.optional()}),Exn=Se({type:pe("source_missing_property_error"),source_missing_property_error_id:Yi("source_missing_property_error"),source_component_id:R(),property_name:R(),subcircuit_id:R().optional(),error_type:pe("source_missing_property_error").default("source_missing_property_error"),message:R()}).describe("The source code is missing a property"),Txn=Se({type:pe("source_failed_to_create_component_error"),source_failed_to_create_component_error_id:Yi("source_failed_to_create_component_error"),error_type:pe("source_failed_to_create_component_error").default("source_failed_to_create_component_error"),component_name:R().optional(),subcircuit_id:R().optional(),parent_source_component_id:R().optional(),message:R(),pcb_center:Se({x:Pe().optional(),y:Pe().optional()}).optional(),schematic_center:Se({x:Pe().optional(),y:Pe().optional()}).optional()}).describe("Error emitted when a component fails to be constructed"),kJe=Se({type:pe("source_trace_not_connected_error"),source_trace_not_connected_error_id:Yi("source_trace_not_connected_error"),error_type:pe("source_trace_not_connected_error").default("source_trace_not_connected_error"),message:R(),subcircuit_id:R().optional(),source_group_id:R().optional(),source_trace_id:R().optional(),connected_source_port_ids:ut(R()).optional(),selectors_not_found:ut(R()).optional()}).describe("Occurs when a source trace selector does not match any ports"),Mxn=Se({type:pe("source_property_ignored_warning"),source_property_ignored_warning_id:Yi("source_property_ignored_warning"),source_component_id:R(),property_name:R(),subcircuit_id:R().optional(),error_type:pe("source_property_ignored_warning").default("source_property_ignored_warning"),message:R()}).describe("The source property was ignored"),OJe=Se({type:pe("source_pin_missing_trace_warning"),source_pin_missing_trace_warning_id:Yi("source_pin_missing_trace_warning"),warning_type:pe("source_pin_missing_trace_warning").default("source_pin_missing_trace_warning"),message:R(),source_component_id:R(),source_port_id:R(),subcircuit_id:R().optional()}).describe("Warning emitted when a source component pin is missing a trace connection"),Cxn=Bn([yJe,_Je,dye,gJe,vxn,xJe,bJe,vJe,wJe,SJe,EJe,Sxn,TJe,MJe,CJe,IJe,AJe,PJe,RJe,wxn,NJe,Exn,Txn,kJe,Mxn,OJe]),Axn=Se({type:pe("source_port"),pin_number:Pe().optional(),port_hints:ut(R()).optional(),name:R(),source_port_id:R(),source_component_id:R().optional(),source_group_id:R().optional(),subcircuit_id:R().optional(),subcircuit_connectivity_map_key:R().optional()}),Pxn=Se({type:pe("source_trace"),source_trace_id:R(),connected_source_port_ids:ut(R()),connected_source_net_ids:ut(R()),subcircuit_id:R().optional(),subcircuit_connectivity_map_key:R().optional(),max_length:Pe().optional(),min_trace_thickness:Pe().optional(),display_name:R().optional()}),Rxn=Se({type:pe("source_group"),source_group_id:R(),subcircuit_id:R().optional(),parent_subcircuit_id:R().optional(),parent_source_group_id:R().optional(),is_subcircuit:Je().optional(),show_as_schematic_box:Je().optional(),name:R().optional(),was_automatically_named:Je().optional()}),Ixn=Se({type:pe("source_net"),source_net_id:R(),name:R(),member_source_group_ids:ut(R()),is_power:Je().optional(),is_ground:Je().optional(),is_digital_signal:Je().optional(),is_analog_signal:Je().optional(),is_positive_voltage_source:Je().optional(),trace_width:Pe().optional(),subcircuit_id:R().optional(),subcircuit_connectivity_map_key:R().optional()}),Nxn=Se({type:pe("source_board"),source_board_id:R(),source_group_id:R(),title:R().optional()}).describe("Defines a board in the source domain"),kxn=Se({type:pe("source_pcb_ground_plane"),source_pcb_ground_plane_id:R(),source_group_id:R(),source_net_id:R(),subcircuit_id:R().optional()}).describe("Defines a ground plane in the source domain"),Oxn=["top","bottom","inner1","inner2","inner3","inner4","inner5","inner6"],LJe=Xt(Oxn),Wd=LJe.or(Se({name:LJe})).transform(n=>typeof n=="string"?n:n.name),rT=Xt(["top","bottom"]),Lxn=Se({type:pe("source_manually_placed_via"),source_manually_placed_via_id:R(),source_group_id:R(),source_net_id:R(),subcircuit_id:R().optional(),source_trace_id:R().optional()}).describe("Defines a via that is manually placed in the source domain"),Dxn=Se({type:pe("unknown_error_finding_part"),unknown_error_finding_part_id:Yi("unknown_error_finding_part"),error_type:pe("unknown_error_finding_part").default("unknown_error_finding_part"),message:R(),source_component_id:R().optional(),subcircuit_id:R().optional()}).describe("Error emitted when an unexpected error occurs while finding a part"),zxn=Se({type:pe("schematic_box"),schematic_component_id:R().optional(),width:fi,height:fi,is_dashed:Je().default(!1),x:fi,y:fi,subcircuit_id:R().optional()}).describe("Draws a box on the schematic"),$xn=Se({type:pe("schematic_path"),schematic_component_id:R(),fill_color:Xt(["red","blue"]).optional(),is_filled:Je().optional(),points:ut(Os),subcircuit_id:R().optional()}),Fxn=rs(Se({left_margin:_t.optional(),right_margin:_t.optional(),top_margin:_t.optional(),bottom_margin:_t.optional()})),Uxn=Se({left_size:Pe(),right_size:Pe(),top_size:Pe().optional(),bottom_size:Pe().optional()}),Bxn=Se({left_side:Se({pins:ut(Pe()),direction:Xt(["top-to-bottom","bottom-to-top"]).optional()}).optional(),right_side:Se({pins:ut(Pe()),direction:Xt(["top-to-bottom","bottom-to-top"]).optional()}).optional(),top_side:Se({pins:ut(Pe()),direction:Xt(["left-to-right","right-to-left"]).optional()}).optional(),bottom_side:Se({pins:ut(Pe()),direction:Xt(["left-to-right","right-to-left"]).optional()}).optional()}),jxn=Bn([Uxn,Bxn]),Hxn=Se({type:pe("schematic_component"),size:mJe,center:Os,source_component_id:R().optional(),schematic_component_id:R(),pin_spacing:_t.optional(),pin_styles:Fxn.optional(),box_width:_t.optional(),symbol_name:R().optional(),port_arrangement:jxn.optional(),port_labels:rs(R()).optional(),symbol_display_value:R().optional(),subcircuit_id:R().optional(),schematic_group_id:R().optional(),is_schematic_group:Je().optional(),source_group_id:R().optional(),is_box_with_pins:Je().optional().default(!0)}),Vxn=Se({type:pe("schematic_line"),schematic_line_id:Yi("schematic_line"),schematic_component_id:R(),x1:fi,y1:fi,x2:fi,y2:fi,stroke_width:fi.nullable().optional(),color:R().default("#000000"),is_dashed:Je().default(!1),subcircuit_id:R().optional()}).describe("Draws a styled line on the schematic"),Gxn=Se({type:pe("schematic_rect"),schematic_rect_id:Yi("schematic_rect"),schematic_component_id:R(),center:Os,width:fi,height:fi,rotation:iS.default(0),stroke_width:fi.nullable().optional(),color:R().default("#000000"),is_filled:Je().default(!1),fill_color:R().optional(),is_dashed:Je().default(!1),subcircuit_id:R().optional()}).describe("Draws a styled rectangle on the schematic"),Yxn=Se({type:pe("schematic_circle"),schematic_circle_id:Yi("schematic_circle"),schematic_component_id:R(),center:Os,radius:fi,stroke_width:fi.nullable().optional(),color:R().default("#000000"),is_filled:Je().default(!1),fill_color:R().optional(),is_dashed:Je().default(!1),subcircuit_id:R().optional()}).describe("Draws a styled circle on the schematic"),qxn=Se({type:pe("schematic_arc"),schematic_arc_id:Yi("schematic_arc"),schematic_component_id:R(),center:Os,radius:fi,start_angle_degrees:iS,end_angle_degrees:iS,direction:Xt(["clockwise","counterclockwise"]).default("counterclockwise"),stroke_width:fi.nullable().optional(),color:R().default("#000000"),is_dashed:Je().default(!1),subcircuit_id:R().optional()}).describe("Draws a styled arc on the schematic"),Xxn=Se({type:pe("schematic_trace"),schematic_trace_id:R(),source_trace_id:R().optional(),junctions:ut(Se({x:Pe(),y:Pe()})),edges:ut(Se({from:Se({x:Pe(),y:Pe()}),to:Se({x:Pe(),y:Pe()}),is_crossing:Je().optional(),from_schematic_port_id:R().optional(),to_schematic_port_id:R().optional()})),subcircuit_id:R().optional(),subcircuit_connectivity_map_key:R().optional()}),Wxn=Xt(["center","left","right","top","bottom"]),Kxn=Se({type:pe("schematic_text"),schematic_component_id:R().optional(),schematic_text_id:R(),text:R(),font_size:Pe().default(.18),position:Se({x:fi,y:fi}),rotation:Pe().default(0),anchor:Bn([Wxn.describe("legacy"),tV]).default("center"),color:R().default("#000000"),subcircuit_id:R().optional()}),Zxn=Se({type:pe("schematic_port"),schematic_port_id:R(),source_port_id:R(),schematic_component_id:R().optional(),center:Os,facing_direction:Xt(["up","down","left","right"]).optional(),distance_from_component_edge:Pe().optional(),side_of_component:Xt(["top","bottom","left","right"]).optional(),true_ccw_index:Pe().optional(),pin_number:Pe().optional(),display_pin_label:R().optional(),subcircuit_id:R().optional(),is_connected:Je().optional(),has_input_arrow:Je().optional(),has_output_arrow:Je().optional()}).describe("Defines a port on a schematic component"),Qxn=Se({type:pe("schematic_net_label"),schematic_net_label_id:Yi("schematic_net_label"),schematic_trace_id:R().optional(),source_trace_id:R().optional(),source_net_id:R(),center:Os,anchor_position:Os.optional(),anchor_side:Xt(["top","bottom","left","right"]),text:R(),symbol_name:R().optional(),is_movable:Je().optional(),subcircuit_id:R().optional()}),Jxn=Se({type:pe("schematic_error"),schematic_error_id:R(),error_type:pe("schematic_port_not_found").default("schematic_port_not_found"),message:R(),subcircuit_id:R().optional()}).describe("Defines a schematic error on the schematic"),e1n=Se({type:pe("schematic_layout_error"),schematic_layout_error_id:Yi("schematic_layout_error"),error_type:pe("schematic_layout_error").default("schematic_layout_error"),message:R(),source_group_id:R(),schematic_group_id:R(),subcircuit_id:R().optional()}).describe("Error emitted when schematic layout fails for a group"),hye=Se({type:pe("schematic_debug_object"),label:R().optional(),subcircuit_id:R().optional()}),t1n=hye.extend({shape:pe("rect"),center:Os,size:mJe}),n1n=hye.extend({shape:pe("line"),start:Os,end:Os}),i1n=hye.extend({shape:pe("point"),center:Os}),r1n=_m("shape",[t1n,n1n,i1n]),o1n=Se({type:pe("schematic_voltage_probe"),schematic_voltage_probe_id:R(),position:Os,schematic_trace_id:R(),voltage:QR.optional(),subcircuit_id:R().optional()}).describe("Defines a voltage probe measurement point on a schematic trace"),s1n=Se({type:pe("schematic_manual_edit_conflict_warning"),schematic_manual_edit_conflict_warning_id:Yi("schematic_manual_edit_conflict_warning"),warning_type:pe("schematic_manual_edit_conflict_warning").default("schematic_manual_edit_conflict_warning"),message:R(),schematic_component_id:R(),schematic_group_id:R().optional(),subcircuit_id:R().optional(),source_component_id:R()}).describe("Warning emitted when a component has both manual placement and explicit schX/schY coordinates"),a1n=Se({type:pe("schematic_group"),schematic_group_id:Yi("schematic_group"),source_group_id:R(),is_subcircuit:Je().optional(),subcircuit_id:R().optional(),width:_t,height:_t,center:Os,schematic_component_ids:ut(R()),show_as_schematic_box:Je().optional(),name:R().optional(),description:R().optional()}).describe("Defines a group of components on the schematic"),c1n=Se({type:pe("schematic_table"),schematic_table_id:Yi("schematic_table"),anchor_position:Os,column_widths:ut(fi),row_heights:ut(fi),cell_padding:fi.optional(),border_width:fi.optional(),subcircuit_id:R().optional(),schematic_component_id:R().optional(),anchor:tV.optional()}).describe("Defines a table on the schematic"),l1n=Se({type:pe("schematic_table_cell"),schematic_table_cell_id:Yi("schematic_table_cell"),schematic_table_id:R(),start_row_index:Pe(),end_row_index:Pe(),start_column_index:Pe(),end_column_index:Pe(),text:R().optional(),center:Os,width:fi,height:fi,horizontal_align:Xt(["left","center","right"]).optional(),vertical_align:Xt(["top","middle","bottom"]).optional(),font_size:fi.optional(),subcircuit_id:R().optional()}).describe("Defines a cell within a schematic_table"),u1n=Se({type:pe("schematic_sheet"),schematic_sheet_id:Yi("schematic_sheet"),name:R().optional(),subcircuit_id:R().optional()}).describe("Defines a schematic sheet or page that components can be placed on"),d1n=Se({x:fi,y:fi,bulge:Pe().optional()}),DJe=Se({vertices:ut(d1n)}),h1n=Se({outer_ring:DJe,inner_rings:ut(DJe).default([])}),p1n=Se({x:fi,y:fi,via:Je().optional(),via_to_layer:Wd.optional()});ut(p1n);var f1n=Se({x:fi,y:fi,via:Je().optional(),to_layer:Wd.optional(),trace_width:fi.optional()}),m1n=Se({type:pe("pcb_component"),pcb_component_id:Yi("pcb_component"),source_component_id:R(),center:Os,layer:Wd,rotation:iS,width:_t,height:_t,do_not_place:Je().optional(),subcircuit_id:R().optional(),pcb_group_id:R().optional(),obstructs_within_bounds:Je().default(!0).describe("Does this component take up all the space within its bounds on a layer. This is generally true except for when separated pin headers are being represented by a single component (in which case, chips can be placed between the pin headers) or for tall modules where chips fit underneath")}).describe("Defines a component on the PCB"),zJe=Se({type:pe("pcb_hole"),pcb_hole_id:Yi("pcb_hole"),pcb_group_id:R().optional(),subcircuit_id:R().optional(),hole_shape:Xt(["circle","square"]),hole_diameter:Pe(),x:fi,y:fi});zJe.describe("Defines a circular or square hole on the PCB");var $Je=Se({type:pe("pcb_hole"),pcb_hole_id:Yi("pcb_hole"),pcb_group_id:R().optional(),subcircuit_id:R().optional(),hole_shape:pe("oval"),hole_width:Pe(),hole_height:Pe(),x:fi,y:fi});$Je.describe("Defines an oval hole on the PCB");var FJe=Se({type:pe("pcb_hole"),pcb_hole_id:Yi("pcb_hole"),pcb_group_id:R().optional(),subcircuit_id:R().optional(),hole_shape:pe("pill"),hole_width:Pe(),hole_height:Pe(),x:fi,y:fi});FJe.describe("Defines a pill-shaped hole on the PCB");var UJe=Se({type:pe("pcb_hole"),pcb_hole_id:Yi("pcb_hole"),pcb_group_id:R().optional(),subcircuit_id:R().optional(),hole_shape:pe("rotated_pill"),hole_width:Pe(),hole_height:Pe(),x:fi,y:fi,ccw_rotation:iS});UJe.describe("Defines a rotated pill-shaped hole on the PCB");var _1n=zJe.or($Je).or(FJe).or(UJe),y1n=Se({type:pe("pcb_plated_hole"),shape:pe("circle"),pcb_group_id:R().optional(),subcircuit_id:R().optional(),outer_diameter:Pe(),hole_diameter:Pe(),x:fi,y:fi,layers:ut(Wd),port_hints:ut(R()).optional(),pcb_component_id:R().optional(),pcb_port_id:R().optional(),pcb_plated_hole_id:Yi("pcb_plated_hole")}),g1n=Se({type:pe("pcb_plated_hole"),shape:Xt(["oval","pill"]),pcb_group_id:R().optional(),subcircuit_id:R().optional(),outer_width:Pe(),outer_height:Pe(),hole_width:Pe(),hole_height:Pe(),x:fi,y:fi,ccw_rotation:iS,layers:ut(Wd),port_hints:ut(R()).optional(),pcb_component_id:R().optional(),pcb_port_id:R().optional(),pcb_plated_hole_id:Yi("pcb_plated_hole")}),x1n=Se({type:pe("pcb_plated_hole"),shape:pe("circular_hole_with_rect_pad"),pcb_group_id:R().optional(),subcircuit_id:R().optional(),hole_shape:pe("circle"),pad_shape:pe("rect"),hole_diameter:Pe(),rect_pad_width:Pe(),rect_pad_height:Pe(),rect_border_radius:Pe().optional(),hole_offset_x:fi.default(0),hole_offset_y:fi.default(0),x:fi,y:fi,layers:ut(Wd),port_hints:ut(R()).optional(),pcb_component_id:R().optional(),pcb_port_id:R().optional(),pcb_plated_hole_id:Yi("pcb_plated_hole")}),b1n=Se({type:pe("pcb_plated_hole"),shape:pe("pill_hole_with_rect_pad"),pcb_group_id:R().optional(),subcircuit_id:R().optional(),hole_shape:pe("pill"),pad_shape:pe("rect"),hole_width:Pe(),hole_height:Pe(),rect_pad_width:Pe(),rect_pad_height:Pe(),rect_border_radius:Pe().optional(),hole_offset_x:fi.default(0),hole_offset_y:fi.default(0),x:fi,y:fi,layers:ut(Wd),port_hints:ut(R()).optional(),pcb_component_id:R().optional(),pcb_port_id:R().optional(),pcb_plated_hole_id:Yi("pcb_plated_hole")}),v1n=Se({type:pe("pcb_plated_hole"),shape:pe("rotated_pill_hole_with_rect_pad"),pcb_group_id:R().optional(),subcircuit_id:R().optional(),hole_shape:pe("rotated_pill"),pad_shape:pe("rect"),hole_width:Pe(),hole_height:Pe(),hole_ccw_rotation:iS,rect_pad_width:Pe(),rect_pad_height:Pe(),rect_border_radius:Pe().optional(),rect_ccw_rotation:iS,hole_offset_x:fi.default(0),hole_offset_y:fi.default(0),x:fi,y:fi,layers:ut(Wd),port_hints:ut(R()).optional(),pcb_component_id:R().optional(),pcb_port_id:R().optional(),pcb_plated_hole_id:Yi("pcb_plated_hole")}),w1n=Bn([y1n,g1n,x1n,b1n,v1n]),S1n=Se({type:pe("pcb_port"),pcb_port_id:Yi("pcb_port"),pcb_group_id:R().optional(),subcircuit_id:R().optional(),source_port_id:R(),pcb_component_id:R().optional(),x:fi,y:fi,layers:ut(Wd),is_board_pinout:Je().optional()}).describe("Defines a port on the PCB"),E1n=Se({type:pe("pcb_smtpad"),shape:pe("circle"),pcb_smtpad_id:Yi("pcb_smtpad"),pcb_group_id:R().optional(),subcircuit_id:R().optional(),x:fi,y:fi,radius:Pe(),layer:Wd,port_hints:ut(R()).optional(),pcb_component_id:R().optional(),pcb_port_id:R().optional(),is_covered_with_solder_mask:Je().optional()}),T1n=Se({type:pe("pcb_smtpad"),shape:pe("rect"),pcb_smtpad_id:Yi("pcb_smtpad"),pcb_group_id:R().optional(),subcircuit_id:R().optional(),x:fi,y:fi,width:Pe(),height:Pe(),rect_border_radius:Pe().optional(),corner_radius:Pe().optional(),layer:Wd,port_hints:ut(R()).optional(),pcb_component_id:R().optional(),pcb_port_id:R().optional(),is_covered_with_solder_mask:Je().optional()}),M1n=Se({type:pe("pcb_smtpad"),shape:pe("rotated_rect"),pcb_smtpad_id:Yi("pcb_smtpad"),pcb_group_id:R().optional(),subcircuit_id:R().optional(),x:fi,y:fi,width:Pe(),height:Pe(),rect_border_radius:Pe().optional(),corner_radius:Pe().optional(),ccw_rotation:iS,layer:Wd,port_hints:ut(R()).optional(),pcb_component_id:R().optional(),pcb_port_id:R().optional(),is_covered_with_solder_mask:Je().optional()}),C1n=Se({type:pe("pcb_smtpad"),shape:pe("pill"),pcb_smtpad_id:Yi("pcb_smtpad"),pcb_group_id:R().optional(),subcircuit_id:R().optional(),x:fi,y:fi,width:Pe(),height:Pe(),radius:Pe(),layer:Wd,port_hints:ut(R()).optional(),pcb_component_id:R().optional(),pcb_port_id:R().optional(),is_covered_with_solder_mask:Je().optional()}),A1n=Se({type:pe("pcb_smtpad"),shape:pe("rotated_pill"),pcb_smtpad_id:Yi("pcb_smtpad"),pcb_group_id:R().optional(),subcircuit_id:R().optional(),x:fi,y:fi,width:Pe(),height:Pe(),radius:Pe(),ccw_rotation:iS,layer:Wd,port_hints:ut(R()).optional(),pcb_component_id:R().optional(),pcb_port_id:R().optional(),is_covered_with_solder_mask:Je().optional()}),P1n=Se({type:pe("pcb_smtpad"),shape:pe("polygon"),pcb_smtpad_id:Yi("pcb_smtpad"),pcb_group_id:R().optional(),subcircuit_id:R().optional(),points:ut(Os),layer:Wd,port_hints:ut(R()).optional(),pcb_component_id:R().optional(),pcb_port_id:R().optional(),is_covered_with_solder_mask:Je().optional()}),R1n=_m("shape",[E1n,T1n,M1n,A1n,C1n,P1n]).describe("Defines an SMT pad on the PCB"),I1n=Se({type:pe("pcb_solder_paste"),shape:pe("circle"),pcb_solder_paste_id:Yi("pcb_solder_paste"),pcb_group_id:R().optional(),subcircuit_id:R().optional(),x:fi,y:fi,radius:Pe(),layer:Wd,pcb_component_id:R().optional(),pcb_smtpad_id:R().optional()}),N1n=Se({type:pe("pcb_solder_paste"),shape:pe("rect"),pcb_solder_paste_id:Yi("pcb_solder_paste"),pcb_group_id:R().optional(),subcircuit_id:R().optional(),x:fi,y:fi,width:Pe(),height:Pe(),layer:Wd,pcb_component_id:R().optional(),pcb_smtpad_id:R().optional()}),k1n=Se({type:pe("pcb_solder_paste"),shape:pe("pill"),pcb_solder_paste_id:Yi("pcb_solder_paste"),pcb_group_id:R().optional(),subcircuit_id:R().optional(),x:fi,y:fi,width:Pe(),height:Pe(),radius:Pe(),layer:Wd,pcb_component_id:R().optional(),pcb_smtpad_id:R().optional()}),O1n=Se({type:pe("pcb_solder_paste"),shape:pe("rotated_rect"),pcb_solder_paste_id:Yi("pcb_solder_paste"),pcb_group_id:R().optional(),subcircuit_id:R().optional(),x:fi,y:fi,width:Pe(),height:Pe(),ccw_rotation:fi,layer:Wd,pcb_component_id:R().optional(),pcb_smtpad_id:R().optional()}),L1n=Se({type:pe("pcb_solder_paste"),shape:pe("oval"),pcb_solder_paste_id:Yi("pcb_solder_paste"),pcb_group_id:R().optional(),subcircuit_id:R().optional(),x:fi,y:fi,width:Pe(),height:Pe(),layer:Wd,pcb_component_id:R().optional(),pcb_smtpad_id:R().optional()}),D1n=Bn([I1n,N1n,k1n,O1n,L1n]).describe("Defines solderpaste on the PCB"),z1n=Se({type:pe("pcb_text"),pcb_text_id:Yi("pcb_text"),pcb_group_id:R().optional(),subcircuit_id:R().optional(),text:R(),center:Os,layer:Wd,width:_t,height:_t,lines:Pe(),align:Xt(["bottom-left"])}).describe("Defines text on the PCB"),$1n=Se({route_type:pe("wire"),x:fi,y:fi,width:fi,start_pcb_port_id:R().optional(),end_pcb_port_id:R().optional(),layer:Wd}),F1n=Se({route_type:pe("via"),x:fi,y:fi,hole_diameter:fi.optional(),outer_diameter:fi.optional(),from_layer:R(),to_layer:R()}),U1n=Bn([$1n,F1n]),B1n=Se({type:pe("pcb_trace"),source_trace_id:R().optional(),pcb_component_id:R().optional(),pcb_trace_id:Yi("pcb_trace"),pcb_group_id:R().optional(),subcircuit_id:R().optional(),route_thickness_mode:Xt(["constant","interpolated"]).default("constant").optional(),route_order_index:Pe().optional(),should_round_corners:Je().optional(),trace_length:Pe().optional(),highlight_color:R().optional(),route:ut(U1n)}).describe("Defines a trace on the PCB"),j1n=Se({type:pe("pcb_trace_error"),pcb_trace_error_id:Yi("pcb_trace_error"),error_type:pe("pcb_trace_error").default("pcb_trace_error"),message:R(),center:Os.optional(),pcb_trace_id:R(),source_trace_id:R(),pcb_component_ids:ut(R()),pcb_port_ids:ut(R()),subcircuit_id:R().optional()}).describe("Defines a trace error on the PCB"),H1n=Se({type:pe("pcb_trace_missing_error"),pcb_trace_missing_error_id:Yi("pcb_trace_missing_error"),error_type:pe("pcb_trace_missing_error").default("pcb_trace_missing_error"),message:R(),center:Os.optional(),source_trace_id:R(),pcb_component_ids:ut(R()),pcb_port_ids:ut(R()),subcircuit_id:R().optional()}).describe("Defines an error when a source trace has no corresponding PCB trace"),V1n=Se({type:pe("pcb_port_not_matched_error"),pcb_error_id:Yi("pcb_error"),error_type:pe("pcb_port_not_matched_error").default("pcb_port_not_matched_error"),message:R(),pcb_component_ids:ut(R()),subcircuit_id:R().optional()}).describe("Defines a trace error on the PCB where a port is not matched"),G1n=Se({type:pe("pcb_port_not_connected_error"),pcb_port_not_connected_error_id:Yi("pcb_port_not_connected_error"),error_type:pe("pcb_port_not_connected_error").default("pcb_port_not_connected_error"),message:R(),pcb_port_ids:ut(R()),pcb_component_ids:ut(R()),subcircuit_id:R().optional()}).describe("Defines an error when a pcb port is not connected to any trace"),Y1n=Se({type:pe("pcb_net"),pcb_net_id:Yi("pcb_net"),source_net_id:R().optional(),highlight_color:R().optional()}).describe("Defines a net on the PCB"),q1n=Se({type:pe("pcb_via"),pcb_via_id:Yi("pcb_via"),pcb_group_id:R().optional(),subcircuit_id:R().optional(),x:fi,y:fi,outer_diameter:fi.default("0.6mm"),hole_diameter:fi.default("0.25mm"),from_layer:Wd.optional(),to_layer:Wd.optional(),layers:ut(Wd),pcb_trace_id:R().optional(),net_is_assignable:Je().optional(),net_assigned:Je().optional()}).describe("Defines a via on the PCB"),X1n=Se({type:pe("pcb_board"),pcb_board_id:Yi("pcb_board"),pcb_panel_id:R().optional(),is_subcircuit:Je().optional(),subcircuit_id:R().optional(),width:_t,height:_t,center:Os,thickness:_t.optional().default(1.4),num_layers:Pe().optional().default(4),outline:ut(Os).optional(),material:Xt(["fr4","fr1"]).default("fr4")}).describe("Defines the board outline of the PCB"),W1n=Se({type:pe("pcb_panel"),pcb_panel_id:Yi("pcb_panel"),width:_t,height:_t,covered_with_solder_mask:Je().optional().default(!0)}).describe("Defines a PCB panel that can contain multiple boards"),K1n=Se({type:pe("pcb_placement_error"),pcb_placement_error_id:Yi("pcb_placement_error"),error_type:pe("pcb_placement_error").default("pcb_placement_error"),message:R(),subcircuit_id:R().optional()}).describe("Defines a placement error on the PCB"),Z1n=Se({type:pe("pcb_trace_hint"),pcb_trace_hint_id:Yi("pcb_trace_hint"),pcb_port_id:R(),pcb_component_id:R(),route:ut(f1n),subcircuit_id:R().optional()}).describe("A hint that can be used during generation of a PCB trace"),Q1n=Se({type:pe("pcb_silkscreen_line"),pcb_silkscreen_line_id:Yi("pcb_silkscreen_line"),pcb_component_id:R(),pcb_group_id:R().optional(),subcircuit_id:R().optional(),stroke_width:fi.default("0.1mm"),x1:fi,y1:fi,x2:fi,y2:fi,layer:rT}).describe("Defines a silkscreen line on the PCB"),J1n=Se({type:pe("pcb_silkscreen_path"),pcb_silkscreen_path_id:Yi("pcb_silkscreen_path"),pcb_component_id:R(),pcb_group_id:R().optional(),subcircuit_id:R().optional(),layer:rT,route:ut(Os),stroke_width:_t}).describe("Defines a silkscreen path on the PCB"),ebn=Se({type:pe("pcb_silkscreen_text"),pcb_silkscreen_text_id:Yi("pcb_silkscreen_text"),pcb_group_id:R().optional(),subcircuit_id:R().optional(),font:pe("tscircuit2024").default("tscircuit2024"),font_size:fi.default("0.2mm"),pcb_component_id:R(),text:R(),is_knockout:Je().default(!1).optional(),knockout_padding:Se({left:_t,top:_t,bottom:_t,right:_t}).default({left:"0.2mm",top:"0.2mm",bottom:"0.2mm",right:"0.2mm"}).optional(),ccw_rotation:Pe().optional(),layer:Wd,is_mirrored:Je().default(!1).optional(),anchor_position:Os.default({x:0,y:0}),anchor_alignment:tV.default("center")}).describe("Defines silkscreen text on the PCB"),tbn=Se({type:pe("pcb_copper_text"),pcb_copper_text_id:Yi("pcb_copper_text"),pcb_group_id:R().optional(),subcircuit_id:R().optional(),font:pe("tscircuit2024").default("tscircuit2024"),font_size:fi.default("0.2mm"),pcb_component_id:R(),text:R(),is_knockout:Je().default(!1).optional(),knockout_padding:Se({left:_t,top:_t,bottom:_t,right:_t}).default({left:"0.2mm",top:"0.2mm",bottom:"0.2mm",right:"0.2mm"}).optional(),ccw_rotation:Pe().optional(),layer:Wd,is_mirrored:Je().default(!1).optional(),anchor_position:Os.default({x:0,y:0}),anchor_alignment:tV.default("center")}).describe("Defines copper text on the PCB"),nbn=Se({type:pe("pcb_silkscreen_rect"),pcb_silkscreen_rect_id:Yi("pcb_silkscreen_rect"),pcb_component_id:R(),pcb_group_id:R().optional(),subcircuit_id:R().optional(),center:Os,width:_t,height:_t,layer:Wd,stroke_width:_t.default("1mm"),corner_radius:_t.optional(),is_filled:Je().default(!0).optional(),has_stroke:Je().optional(),is_stroke_dashed:Je().optional()}).describe("Defines a silkscreen rect on the PCB"),ibn=Se({type:pe("pcb_silkscreen_circle"),pcb_silkscreen_circle_id:Yi("pcb_silkscreen_circle"),pcb_component_id:R(),pcb_group_id:R().optional(),subcircuit_id:R().optional(),center:Os,radius:_t,layer:rT,stroke_width:_t.default("1mm")}).describe("Defines a silkscreen circle on the PCB"),rbn=Se({type:pe("pcb_silkscreen_oval"),pcb_silkscreen_oval_id:Yi("pcb_silkscreen_oval"),pcb_component_id:R(),pcb_group_id:R().optional(),subcircuit_id:R().optional(),center:Os,radius_x:fi,radius_y:fi,layer:rT}).describe("Defines a silkscreen oval on the PCB"),obn=Se({type:pe("pcb_fabrication_note_text"),pcb_fabrication_note_text_id:Yi("pcb_fabrication_note_text"),subcircuit_id:R().optional(),pcb_group_id:R().optional(),font:pe("tscircuit2024").default("tscircuit2024"),font_size:fi.default("1mm"),pcb_component_id:R(),text:R(),layer:rT,anchor_position:Os.default({x:0,y:0}),anchor_alignment:Xt(["center","top_left","top_right","bottom_left","bottom_right"]).default("center"),color:R().optional()}).describe("Defines a fabrication note in text on the PCB, useful for leaving notes for assemblers or fabricators"),sbn=Se({type:pe("pcb_fabrication_note_path"),pcb_fabrication_note_path_id:Yi("pcb_fabrication_note_path"),pcb_component_id:R(),subcircuit_id:R().optional(),layer:Wd,route:ut(Os),stroke_width:_t,color:R().optional()}).describe("Defines a fabrication path on the PCB for fabricators or assemblers"),abn=Se({type:pe("pcb_fabrication_note_rect"),pcb_fabrication_note_rect_id:Yi("pcb_fabrication_note_rect"),pcb_component_id:R(),pcb_group_id:R().optional(),subcircuit_id:R().optional(),center:Os,width:_t,height:_t,layer:rT,stroke_width:_t.default("0.1mm"),corner_radius:_t.optional(),is_filled:Je().optional(),has_stroke:Je().optional(),is_stroke_dashed:Je().optional(),color:R().optional()}).describe("Defines a fabrication note rectangle on the PCB"),cbn=Se({type:pe("pcb_fabrication_note_dimension"),pcb_fabrication_note_dimension_id:Yi("pcb_fabrication_note_dimension"),pcb_component_id:R(),pcb_group_id:R().optional(),subcircuit_id:R().optional(),layer:rT,from:Os,to:Os,text:R().optional(),text_ccw_rotation:Pe().optional(),offset:_t.optional(),offset_distance:_t.optional(),offset_direction:Se({x:Pe(),y:Pe()}).optional(),font:pe("tscircuit2024").default("tscircuit2024"),font_size:_t.default("1mm"),color:R().optional(),arrow_size:_t.default("1mm")}).describe("Defines a measurement annotation within PCB fabrication notes"),lbn=Se({type:pe("pcb_note_text"),pcb_note_text_id:Yi("pcb_note_text"),pcb_component_id:R().optional(),pcb_group_id:R().optional(),subcircuit_id:R().optional(),name:R().optional(),font:pe("tscircuit2024").default("tscircuit2024"),font_size:fi.default("1mm"),text:R().optional(),anchor_position:Os.default({x:0,y:0}),anchor_alignment:Xt(["center","top_left","top_right","bottom_left","bottom_right"]).default("center"),color:R().optional()}).describe("Defines a documentation note in text on the PCB"),ubn=Se({type:pe("pcb_note_rect"),pcb_note_rect_id:Yi("pcb_note_rect"),pcb_component_id:R().optional(),pcb_group_id:R().optional(),subcircuit_id:R().optional(),name:R().optional(),text:R().optional(),center:Os,width:_t,height:_t,stroke_width:_t.default("0.1mm"),corner_radius:_t.optional(),is_filled:Je().optional(),has_stroke:Je().optional(),is_stroke_dashed:Je().optional(),color:R().optional()}).describe("Defines a rectangular documentation note on the PCB"),dbn=Se({type:pe("pcb_note_path"),pcb_note_path_id:Yi("pcb_note_path"),pcb_component_id:R().optional(),pcb_group_id:R().optional(),subcircuit_id:R().optional(),name:R().optional(),text:R().optional(),route:ut(Os),stroke_width:_t.default("0.1mm"),color:R().optional()}).describe("Defines a polyline documentation note on the PCB"),hbn=Se({type:pe("pcb_note_line"),pcb_note_line_id:Yi("pcb_note_line"),pcb_component_id:R().optional(),pcb_group_id:R().optional(),subcircuit_id:R().optional(),name:R().optional(),text:R().optional(),x1:fi,y1:fi,x2:fi,y2:fi,stroke_width:fi.default("0.1mm"),color:R().optional(),is_dashed:Je().optional()}).describe("Defines a straight documentation note line on the PCB"),pbn=Se({type:pe("pcb_note_dimension"),pcb_note_dimension_id:Yi("pcb_note_dimension"),pcb_component_id:R().optional(),pcb_group_id:R().optional(),subcircuit_id:R().optional(),name:R().optional(),from:Os,to:Os,text:R().optional(),text_ccw_rotation:Pe().optional(),offset_distance:_t.optional(),offset_direction:Se({x:Pe(),y:Pe()}).optional(),font:pe("tscircuit2024").default("tscircuit2024"),font_size:_t.default("1mm"),color:R().optional(),arrow_size:_t.default("1mm")}).describe("Defines a measurement annotation within PCB documentation notes"),fbn=Se({type:pe("pcb_footprint_overlap_error"),pcb_error_id:Yi("pcb_error"),error_type:pe("pcb_footprint_overlap_error").default("pcb_footprint_overlap_error"),message:R(),pcb_smtpad_ids:ut(R()).optional(),pcb_plated_hole_ids:ut(R()).optional(),pcb_hole_ids:ut(R()).optional(),pcb_keepout_ids:ut(R()).optional()}).describe("Error emitted when a pcb footprint overlaps with another element"),mbn=Se({type:pe("pcb_keepout"),shape:pe("rect"),pcb_group_id:R().optional(),subcircuit_id:R().optional(),center:Os,width:fi,height:fi,pcb_keepout_id:R(),layers:ut(R()),description:R().optional()}).or(Se({type:pe("pcb_keepout"),shape:pe("circle"),pcb_group_id:R().optional(),subcircuit_id:R().optional(),center:Os,radius:fi,pcb_keepout_id:R(),layers:ut(R()),description:R().optional()})),pye=Se({type:pe("pcb_cutout"),pcb_cutout_id:Yi("pcb_cutout"),pcb_group_id:R().optional(),subcircuit_id:R().optional()}),_bn=pye.extend({shape:pe("rect"),center:Os,width:_t,height:_t,rotation:iS.optional()}),ybn=pye.extend({shape:pe("circle"),center:Os,radius:_t}),gbn=pye.extend({shape:pe("polygon"),points:ut(Os)}),xbn=_m("shape",[_bn,ybn,gbn]).describe("Defines a cutout on the PCB, removing board material."),bbn=Se({type:pe("pcb_missing_footprint_error"),pcb_missing_footprint_error_id:Yi("pcb_missing_footprint_error"),pcb_group_id:R().optional(),subcircuit_id:R().optional(),error_type:pe("pcb_missing_footprint_error").default("pcb_missing_footprint_error"),source_component_id:R(),message:R()}).describe("Defines a missing footprint error on the PCB"),vbn=Se({type:pe("external_footprint_load_error"),external_footprint_load_error_id:Yi("external_footprint_load_error"),pcb_component_id:R(),source_component_id:R(),pcb_group_id:R().optional(),subcircuit_id:R().optional(),footprinter_string:R().optional(),error_type:pe("external_footprint_load_error").default("external_footprint_load_error"),message:R()}).describe("Defines an error when an external footprint fails to load"),wbn=Se({type:pe("circuit_json_footprint_load_error"),circuit_json_footprint_load_error_id:Yi("circuit_json_footprint_load_error"),pcb_component_id:R(),source_component_id:R(),pcb_group_id:R().optional(),subcircuit_id:R().optional(),error_type:pe("circuit_json_footprint_load_error").default("circuit_json_footprint_load_error"),message:R(),circuit_json:ut(fl()).optional()}).describe("Defines an error when a circuit JSON footprint fails to load"),Sbn=Se({type:pe("pcb_group"),pcb_group_id:Yi("pcb_group"),source_group_id:R(),is_subcircuit:Je().optional(),subcircuit_id:R().optional(),width:_t.optional(),height:_t.optional(),center:Os,outline:ut(Os).optional(),anchor_position:Os.optional(),anchor_alignment:Xt(["center","top_left","top_right","bottom_left","bottom_right"]).optional(),pcb_component_ids:ut(R()),name:R().optional(),description:R().optional(),layout_mode:R().optional(),autorouter_configuration:Se({trace_clearance:_t}).optional(),autorouter_used_string:R().optional()}).describe("Defines a group of components on the PCB"),Ebn=Se({type:pe("pcb_autorouting_error"),pcb_error_id:Yi("pcb_autorouting_error"),error_type:pe("pcb_autorouting_error").default("pcb_autorouting_error"),message:R(),subcircuit_id:R().optional()}).describe("The autorouting has failed to route a portion of the board"),Tbn=Se({type:pe("pcb_manual_edit_conflict_warning"),pcb_manual_edit_conflict_warning_id:Yi("pcb_manual_edit_conflict_warning"),warning_type:pe("pcb_manual_edit_conflict_warning").default("pcb_manual_edit_conflict_warning"),message:R(),pcb_component_id:R(),pcb_group_id:R().optional(),subcircuit_id:R().optional(),source_component_id:R()}).describe("Warning emitted when a component has both manual placement and explicit pcbX/pcbY coordinates"),Mbn=Se({type:pe("pcb_breakout_point"),pcb_breakout_point_id:Yi("pcb_breakout_point"),pcb_group_id:R(),subcircuit_id:R().optional(),source_trace_id:R().optional(),source_port_id:R().optional(),source_net_id:R().optional(),x:fi,y:fi}).describe("Defines a routing target within a pcb_group for a source_trace or source_net"),Cbn=Se({type:pe("pcb_ground_plane"),pcb_ground_plane_id:Yi("pcb_ground_plane"),source_pcb_ground_plane_id:R(),source_net_id:R(),pcb_group_id:R().optional(),subcircuit_id:R().optional()}).describe("Defines a ground plane on the PCB"),Abn=Se({type:pe("pcb_ground_plane_region"),pcb_ground_plane_region_id:Yi("pcb_ground_plane_region"),pcb_ground_plane_id:R(),pcb_group_id:R().optional(),subcircuit_id:R().optional(),layer:Wd,points:ut(Os)}).describe("Defines a polygon region of a ground plane"),Pbn=Se({type:pe("pcb_thermal_spoke"),pcb_thermal_spoke_id:Yi("pcb_thermal_spoke"),pcb_ground_plane_id:R(),shape:R(),spoke_count:Pe(),spoke_thickness:fi,spoke_inner_diameter:fi,spoke_outer_diameter:fi,pcb_plated_hole_id:R().optional(),subcircuit_id:R().optional()}).describe("Pattern for connecting a ground plane to a plated hole"),fye=Se({type:pe("pcb_copper_pour"),pcb_copper_pour_id:Yi("pcb_copper_pour"),pcb_group_id:R().optional(),subcircuit_id:R().optional(),layer:Wd,source_net_id:R().optional(),covered_with_solder_mask:Je().optional().default(!0)}),Rbn=fye.extend({shape:pe("rect"),center:Os,width:_t,height:_t,rotation:iS.optional()}),Ibn=fye.extend({shape:pe("brep"),brep_shape:h1n}),Nbn=fye.extend({shape:pe("polygon"),points:ut(Os)}),kbn=_m("shape",[Rbn,Ibn,Nbn]).describe("Defines a copper pour on the PCB."),Obn=Se({type:pe("pcb_component_outside_board_error"),pcb_component_outside_board_error_id:Yi("pcb_component_outside_board_error"),error_type:pe("pcb_component_outside_board_error").default("pcb_component_outside_board_error"),message:R(),pcb_component_id:R(),pcb_board_id:R(),component_center:Os,component_bounds:Se({min_x:Pe(),max_x:Pe(),min_y:Pe(),max_y:Pe()}),subcircuit_id:R().optional(),source_component_id:R().optional()}).describe("Error emitted when a PCB component is placed outside the board boundaries"),Lbn=Se({type:pe("pcb_component_invalid_layer_error"),pcb_component_invalid_layer_error_id:Yi("pcb_component_invalid_layer_error"),error_type:pe("pcb_component_invalid_layer_error").default("pcb_component_invalid_layer_error"),message:R(),pcb_component_id:R().optional(),source_component_id:R(),layer:Wd,subcircuit_id:R().optional()}).describe("Error emitted when a component is placed on an invalid layer (components can only be on 'top' or 'bottom' layers)"),Dbn=Se({type:pe("pcb_via_clearance_error"),pcb_error_id:Yi("pcb_error"),error_type:pe("pcb_via_clearance_error").default("pcb_via_clearance_error"),message:R(),pcb_via_ids:ut(R()).min(2),minimum_clearance:fi.optional(),actual_clearance:fi.optional(),pcb_center:Se({x:Pe().optional(),y:Pe().optional()}).optional(),subcircuit_id:R().optional()}).describe("Error emitted when vias are closer than the allowed clearance"),zbn=Se({type:pe("pcb_courtyard_rect"),pcb_courtyard_rect_id:Yi("pcb_courtyard_rect"),pcb_component_id:R(),pcb_group_id:R().optional(),subcircuit_id:R().optional(),center:Os,width:_t,height:_t,layer:rT,color:R().optional()}).describe("Defines a courtyard rectangle on the PCB"),$bn=Se({type:pe("pcb_courtyard_outline"),pcb_courtyard_outline_id:Yi("pcb_courtyard_outline"),pcb_component_id:R(),pcb_group_id:R().optional(),subcircuit_id:R().optional(),layer:rT,outline:ut(Os).min(2),stroke_width:_t.default("0.1mm"),is_closed:Je().optional(),is_stroke_dashed:Je().optional(),color:R().optional()}).describe("Defines a courtyard outline on the PCB"),Fbn=Se({type:pe("pcb_courtyard_polygon"),pcb_courtyard_polygon_id:Yi("pcb_courtyard_polygon"),pcb_component_id:R(),pcb_group_id:R().optional(),subcircuit_id:R().optional(),layer:rT,points:ut(Os).min(3),color:R().optional()}).describe("Defines a courtyard polygon on the PCB"),Ubn=Se({type:pe("cad_component"),cad_component_id:R(),pcb_component_id:R(),source_component_id:R(),position:uye,rotation:uye.optional(),size:uye.optional(),layer:Wd.optional(),subcircuit_id:R().optional(),footprinter_string:R().optional(),model_obj_url:R().optional(),model_stl_url:R().optional(),model_3mf_url:R().optional(),model_gltf_url:R().optional(),model_glb_url:R().optional(),model_step_url:R().optional(),model_wrl_url:R().optional(),model_unit_to_mm_scale_factor:Pe().optional(),model_jscad:fl().optional()}).describe("Defines a component on the PCB"),Bbn=Xt(["sinewave","square","triangle","sawtooth"]),jbn=Bn([R(),Pe()]).transform(n=>typeof n=="string"?n.endsWith("%")?parseFloat(n.slice(0,-1))/100:parseFloat(n):n).pipe(Pe().min(0,"Duty cycle must be non-negative").max(1,"Duty cycle cannot be greater than 100%")),Hbn=Se({type:pe("simulation_voltage_source"),simulation_voltage_source_id:Yi("simulation_voltage_source"),is_dc_source:pe(!0).optional().default(!0),positive_source_port_id:R().optional(),negative_source_port_id:R().optional(),positive_source_net_id:R().optional(),negative_source_net_id:R().optional(),voltage:QR}).describe("Defines a DC voltage source for simulation"),Vbn=Se({type:pe("simulation_voltage_source"),simulation_voltage_source_id:Yi("simulation_voltage_source"),is_dc_source:pe(!1),terminal1_source_port_id:R().optional(),terminal2_source_port_id:R().optional(),terminal1_source_net_id:R().optional(),terminal2_source_net_id:R().optional(),voltage:QR.optional(),frequency:cye.optional(),peak_to_peak_voltage:QR.optional(),wave_shape:Bbn.optional(),phase:iS.optional(),duty_cycle:jbn.optional()}).describe("Defines an AC voltage source for simulation"),Gbn=Bn([Hbn,Vbn]).describe("Defines a voltage source for simulation"),Ybn=Bn([pe("spice_dc_sweep"),pe("spice_dc_operating_point"),pe("spice_transient_analysis"),pe("spice_ac_analysis")]),qbn=Se({type:pe("simulation_experiment"),simulation_experiment_id:Yi("simulation_experiment"),name:R(),experiment_type:Ybn,time_per_step:lye.optional(),start_time_ms:JR.optional(),end_time_ms:JR.optional()}).describe("Defines a simulation experiment configuration"),Xbn=Se({type:pe("simulation_transient_voltage_graph"),simulation_transient_voltage_graph_id:Yi("simulation_transient_voltage_graph"),simulation_experiment_id:R(),timestamps_ms:ut(Pe()).optional(),voltage_levels:ut(Pe()),schematic_voltage_probe_id:R().optional(),simulation_voltage_probe_id:R().optional(),subcircuit_connectivity_map_key:R().optional(),time_per_step:lye,start_time_ms:JR,end_time_ms:JR,name:R().optional()}).describe("Stores voltage measurements over time for a simulation"),Wbn=Se({type:pe("simulation_switch"),simulation_switch_id:Yi("simulation_switch"),source_component_id:R().optional(),closes_at:JR.optional(),opens_at:JR.optional(),starts_closed:Je().optional(),switching_frequency:cye.optional()}).describe("Defines a switch for simulation timing control"),Kbn=Se({type:pe("simulation_voltage_probe"),simulation_voltage_probe_id:Yi("simulation_voltage_probe"),source_port_id:R().optional(),source_net_id:R().optional(),name:R().optional(),subcircuit_id:R().optional()}).describe("Defines a voltage probe for simulation, connected to a port or a net").refine(n=>!!n.source_port_id!=!!n.source_net_id,{message:"Exactly one of source_port_id or source_net_id must be provided to simulation_voltage_probe"}),Zbn=Se({type:pe("simulation_unknown_experiment_error"),simulation_unknown_experiment_error_id:Yi("simulation_unknown_experiment_error"),error_type:pe("simulation_unknown_experiment_error").default("simulation_unknown_experiment_error"),message:R(),simulation_experiment_id:R().optional(),subcircuit_id:R().optional()}).describe("An unknown error occurred during the simulation experiment.");Bn([Pxn,Axn,Cxn,Ixn,Rxn,xJe,_Je,dye,gJe,yJe,bJe,vJe,wJe,TJe,MJe,CJe,IJe,AJe,PJe,RJe,EJe,SJe,kxn,Lxn,Nxn,NJe,kJe,OJe,Dxn,m1n,_1n,bbn,vbn,wbn,Tbn,w1n,mbn,S1n,Y1n,z1n,B1n,q1n,R1n,D1n,X1n,W1n,Sbn,Z1n,Q1n,J1n,ebn,tbn,nbn,ibn,rbn,j1n,H1n,K1n,V1n,G1n,Dbn,sbn,obn,abn,cbn,lbn,ubn,dbn,hbn,pbn,Ebn,fbn,Mbn,xbn,Cbn,Abn,Pbn,kbn,Obn,Lbn,zbn,$bn,Fbn,zxn,Kxn,Vxn,Gxn,Yxn,qxn,Hxn,Zxn,Xxn,$xn,Jxn,e1n,Qxn,r1n,o1n,s1n,a1n,u1n,c1n,l1n,Ubn,Gbn,qbn,Xbn,Wbn,Kbn,Zbn]);var Qbn=Object.defineProperty,Jbn=(n,e)=>{for(var t in e)Qbn(n,t,{get:e[t],enumerable:!0})},j5={};Jbn(j5,{axial:()=>Jvn,bga:()=>dvn,breakoutheaders:()=>lwn,cap:()=>svn,dfn:()=>Ovn,diode:()=>ovn,dip:()=>nvn,electrolytic:()=>G2n,hc49:()=>dwn,jst:()=>m2n,led:()=>avn,lqfp:()=>awn,m2host:()=>cEn,melf:()=>ESn,micromelf:()=>ASn,minimelf:()=>_Sn,mlp:()=>xvn,ms012:()=>Bvn,ms013:()=>Hvn,msop:()=>T2n,pad:()=>hwn,pinrow:()=>zvn,platedhole:()=>iEn,potentiometer:()=>j2n,pushbutton:()=>twn,qfn:()=>yvn,qfp:()=>gvn,quad:()=>o8,res:()=>cvn,sma:()=>NSn,smb:()=>USn,smbf:()=>q2n,smc:()=>VSn,smf:()=>DSn,smtpad:()=>tEn,sod110:()=>y2n,sod123:()=>Wvn,sod123f:()=>Xwn,sod123fl:()=>Qwn,sod123w:()=>Awn,sod128:()=>sSn,sod323:()=>Nwn,sod323f:()=>Vwn,sod323fl:()=>I2n,sod323w:()=>C2n,sod523:()=>gwn,sod723:()=>nSn,sod80:()=>Ewn,sod882:()=>Uwn,sod882d:()=>bSn,sod923:()=>Dwn,soic:()=>pvn,solderjumper:()=>D2n,son:()=>L2n,sop8:()=>wwn,sot:()=>oEn,sot223:()=>XSn,sot23:()=>Cvn,sot23w:()=>i2n,sot25:()=>Ivn,sot323:()=>Z2n,sot363:()=>Tvn,sot457:()=>F2n,sot563:()=>Fvn,sot723:()=>Gvn,sot89:()=>hSn,ssop:()=>vvn,stampboard:()=>iwn,stampreceiver:()=>swn,to220:()=>fSn,to92:()=>_wn,to92s:()=>l2n,tssop:()=>Svn,vssop:()=>w2n});var Fo=(n,e,t)=>({type:"pcb_silkscreen_text",pcb_silkscreen_text_id:"silkscreen_text_1",font:"tscircuit2024",font_size:t,pcb_component_id:"pcb_component_1",text:"{REF}",layer:"top",anchor_position:{x:n,y:e},anchor_alignment:"center"}),Ia=(n,e,t,i,r)=>({pcb_plated_hole_id:"",type:"pcb_plated_hole",shape:"circle",x:e,y:t,hole_diameter:gh(i),outer_diameter:gh(r),pcb_port_id:"",layers:["top","bottom"],port_hints:[n.toString()]}),BJe=Array.from({length:9},(n,e)=>Math.cos(e/8*Math.PI-Math.PI)).map(n=>({x:n,y:-Math.sqrt(1-n**2)}));function BM(n){return typeof n=="string"?n.trim().toLowerCase().endsWith("mil")?parseFloat(n)*.0254:parseFloat(n):Number(n)}var nV=Bn([R(),Pe()]).transform(n=>BM(n)),evn=n=>Se({fn:R(),num_pins:Pe().optional().default(6),wide:Je().optional(),narrow:Je().optional(),w:nV.optional(),p:nV.default(n.p??"2.54mm"),id:nV.optional(),od:nV.optional()}).transform(e=>(!e.id&&!e.od?Math.abs(e.p-1.27)<.01?(e.id=BM("0.55mm"),e.od=BM("0.95mm")):(e.id=BM("1.0mm"),e.od=BM("1.5mm")):e.id?e.od||(e.od=e.id*(1.5/1)):e.id=e.od*(1/1.5),e.w||(e.wide?e.w=BM("600mil"):e.narrow?e.w=BM("300mil"):e.w=BM(n.w??"300mil")),e)),tvn=evn({}),jJe=(n,e,t,i)=>{const r=n/2,o=e<=r,s=r-1,a=i,c=a*s;return o?{x:-t/2,y:c/2-(e-1)*a}:{x:t/2,y:-c/2+(e-r-1)*a}},nvn=n=>{const e=tvn.parse(n),t=[];for(let l=0;l<e.num_pins;l++){const{x:u,y:d}=jJe(e.num_pins,l+1,e.w,e.p??2.54);t.push(Ia(l+1,u,d,e.id??"0.8mm",e.od??"1mm"))}(e.num_pins/2-1)*e.p+e.od;const r=e.w-e.od-1,o=(e.num_pins/2-1)*e.p+e.od+.4,s={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-r/2,y:-o/2},{x:-r/2,y:o/2},...BJe.map(({x:l,y:u})=>({x:l*r/6,y:u*r/6+o/2})),{x:r/2,y:o/2},{x:r/2,y:-o/2},{x:-r/2,y:-o/2}],type:"pcb_silkscreen_path",stroke_width:.1},a=[];for(let l=0;l<e.num_pins;l++){const u=l<e.num_pins/2,d=.6,{y:h}=jJe(e.num_pins,l+1,e.w,e.p??2.54),p=u?-e.w/2-e.od/2-d:e.w/2+e.od/2+d,m=h;a.push({type:"pcb_fabrication_note_text",pcb_fabrication_note_text_id:`pin_${l+1}`,layer:"top",pcb_component_id:`pin_${l+1}`,text:`{pin${l+1}}`,anchor_position:{x:p,y:m},font_size:.3,font:"tscircuit2024",anchor_alignment:"top_left"})}const c=Fo(0,o/2+.5,.4);return{circuitJson:[...t,s,c,...a],parameters:e}},zr=(n,e,t,i,r)=>({type:"pcb_smtpad",x:e,y:t,width:i,height:r,layer:"top",shape:"rect",pcb_smtpad_id:"",port_hints:Array.isArray(n)?n.map(o=>o.toString()):[n.toString()]}),HJe=[{imperial:"01005",metric:"0402",p_mm_min:.5,pw_mm_min:.4,ph_mm_min:.3,w_mm_min:.58,h_mm_min:.21},{imperial:"0504",metric:"1310",p_mm_min:1.1,pw_mm_min:.65,ph_mm_min:1.3,w_mm_min:.58,h_mm_min:.21},{imperial:"1812",metric:"4532",p_mm_min:4.275,pw_mm_min:1.125,ph_mm_min:3.4,w_mm_min:5.4,h_mm_min:3.4},{imperial:"0201",metric:"0603",p_mm_min:.66,pw_mm_min:.46,ph_mm_min:.4,w_mm_min:.9,h_mm_min:.3},{imperial:"0402",metric:"1005",p_mm_min:1.02,pw_mm_min:.54,ph_mm_min:.64,w_mm_min:1.56,h_mm_min:.64},{imperial:"0603",metric:"1608",p_mm_min:1.65,pw_mm_min:.8,ph_mm_min:.95,w_mm_min:2.45,h_mm_min:.95},{imperial:"0805",metric:"2012",p_mm_min:1.825,pw_mm_min:1.025,ph_mm_min:1.4,w_mm_min:2.8499999999999996,h_mm_min:1.4},{imperial:"1206",metric:"3216",p_mm_min:2.925,pw_mm_min:1.125,ph_mm_min:1.75,w_mm_min:4.05,h_mm_min:1.75},{imperial:"1210",metric:"3225",p_mm_min:2.925,pw_mm_min:1.125,ph_mm_min:2.65,w_mm_min:4.05,h_mm_min:2.65},{imperial:"2010",metric:"5025",p_mm_min:4.625,pw_mm_min:1.225,ph_mm_min:2.65,w_mm_min:5.85,h_mm_min:2.65},{imperial:"2512",metric:"6332",p_mm_min:5.925,pw_mm_min:1.225,ph_mm_min:3.35,w_mm_min:7.15,h_mm_min:3.35}],ivn=Object.fromEntries(HJe.map(n=>[n.metric,n])),rvn=Object.fromEntries(HJe.map(n=>[n.imperial,n]));Se({tht:Je(),p:_t.optional(),pw:_t.optional(),ph:_t.optional(),metric:fi.optional(),imperial:fi.optional(),w:_t.optional(),h:_t.optional(),textbottom:Je().optional()});var iV=n=>{let{tht:e,p:t,pw:i,ph:r,metric:o,imperial:s,w:a,h:c,textbottom:l}=n;if(typeof a=="string"&&(a=r8(a)),typeof c=="string"&&(c=r8(c)),typeof t=="string"&&(t=r8(t)),typeof i=="string"&&(i=r8(i)),typeof r=="string"&&(r=r8(r)),c!==void 0&&a!==void 0&&c>a)throw new Error("height cannot be greater than width (rotated footprint not yet implemented)");let u;if(o&&(u=ivn[o]),s&&(u=rvn[s]),u&&(a=u.w_mm_min,c=u.h_mm_min,t=u.p_mm_min,i=u.pw_mm_min,r=u.ph_mm_min),t===void 0||i===void 0||r===void 0)throw new Error("Could not determine required pad dimensions (p, pw, ph)");const d={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:t/2,y:r/2+.4},{x:-t/2-i/2-.2,y:r/2+.4},{x:-t/2-i/2-.2,y:-r/2-.4},{x:t/2,y:-r/2-.4}],stroke_width:.1,pcb_silkscreen_path_id:""},h=l?-r/2-.9:r/2+.9,p=Fo(0,h,.2);return e?[Ia(1,-t/2,0,i,i*1/.8),Ia(2,t/2,0,i,i*1/.8),d,p]:[zr(["1","left"],-t/2,0,i,r),zr(["2","right"],t/2,0,i,r),d,p]},ovn=n=>({circuitJson:iV(n),parameters:n}),svn=n=>({circuitJson:iV(n),parameters:n}),avn=n=>({circuitJson:iV(n),parameters:n}),cvn=n=>({circuitJson:iV(n),parameters:n}),VJe=(n,{x:e,y:t,radius:i})=>({type:"pcb_smtpad",x:e,y:t,radius:i,layer:"top",shape:"circle",pcb_smtpad_id:"",port_hints:Array.isArray(n)?n.map(r=>r.toString()):[n.toString()]}),GJe="ABCDEFGHIJKLMNOPQRSTUVWXYZ",YJe=R().transform(n=>{const[e,t]=n.split(/[x ]/);return{x:parseFloat(e),y:parseFloat(t)}}).pipe(Se({x:Pe(),y:Pe()})),lvn=R().or(ut(fl())).transform(n=>Array.isArray(n)?n:(n.startsWith("(")&&n.endsWith(")")&&(n=n.slice(1,-1)),n.split(",").map(e=>{const t=Number(e);return isNaN(t)?e:t}))).pipe(ut(R().or(Pe()))),uvn=Se({fn:R(),num_pins:Pe().optional().default(64),grid:YJe.optional(),p:fi.default("0.8mm"),w:_t.optional(),h:_t.optional(),ball:_t.optional().describe("ball diameter"),pad:_t.optional().describe("pad width/height"),circularpads:Je().optional().describe("use circular pads"),tlorigin:Je().optional(),blorigin:Je().optional(),trorigin:Je().optional(),brorigin:Je().optional(),missing:lvn.default([])}).transform(n=>{let e="tl";if(n.blorigin&&(e="bl"),n.trorigin&&(e="tr"),n.brorigin&&(e="br"),!n.grid){const i=Math.ceil(Math.sqrt(n.num_pins));n.grid={x:i,y:i}}return n.missing&&(n.missing=n.missing.map(i=>{if(typeof i=="number")return i;if(i==="center")return"center";if(i==="topleft")return"topleft";const r=i.match(/([A-Z]+)(\d+)/);if(!r)return i;const o=GJe.indexOf(r[1]),s=Number.parseInt(r[2])-1;return o*n.grid.x+s+1})),{...n,origin:e}}),dvn=n=>{const e=uvn.parse(n);let{num_pins:t,grid:i,p:r,w:o,h:s,ball:a,pad:c,missing:l}=e;a??=.75/1.27*r,c??=a*.8;const u=[],d=(l??[]).filter(N=>typeof N=="number"),h=i.x*i.y-t;if(l.length===0&&h>0&&(Math.sqrt(h)%1===0?l.push("center"):h===1&&l.push("topleft")),l?.includes("center")){const N=Math.floor(Math.sqrt(h)),A=Math.floor((i.x-N)/2),I=Math.floor((i.y-N)/2);for(let M=I;M<I+N;M++)for(let k=A;k<A+N;k++)d.push(M*i.x+k+1)}l?.includes("topleft")&&d.push(1);const p=new Set(d);let m=0;for(let N=0;N<i.y;N++)for(let A=0;A<i.x;A++){const I=(A-(i.x-1)/2)*r,M=(N-(i.y-1)/2)*r;let k=A,C=N;switch(e.origin){case"bl":k=A,C=i.y-1-N;break;case"br":k=i.x-1-A,C=i.y-1-N;break;case"tr":k=i.x-1-A,C=N;break}let U=C*i.x+k+1;if(p.has(U)){m++;continue}U-=m;const O=[U,`${GJe[C]}${k+1}`];u.push(e.circularpads?VJe(O,{x:I,y:M,radius:c/2}):zr(O,I,M,c,c))}const _=Fo(0,i.y*r/2,.2),g=r/6;let x;const b=i.x*r/2,w=i.y*r/2;switch(e.origin){case"bl":x=[{x:-b,y:-w},{x:-b,y:-w-g},{x:-b-g,y:-w},{x:-b,y:-w}];break;case"br":x=[{x:b,y:-w},{x:b,y:-w-g},{x:b+g,y:-w},{x:b,y:-w}];break;case"tr":x=[{x:b,y:w},{x:b,y:w+g},{x:b+g,y:w},{x:b,y:w}];break;case"tl":default:x=[{x:-b,y:w},{x:-b,y:w+g},{x:-b-g,y:w},{x:-b,y:w}];break}const E={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"pin1_marker",route:x,stroke_width:.05};return{circuitJson:[...u,_,E],parameters:e}},rV=(n,e,t,i,r)=>({type:"pcb_smtpad",x:e,y:t,width:i,height:r,radius:r/2,layer:"top",shape:"pill",pcb_smtpad_id:"",port_hints:Array.isArray(n)?n.map(o=>o.toString()):[n.toString()]}),X2=n=>Se({fn:R(),num_pins:Pe().optional().default(8),w:_t.default(_t.parse(n.w??"5.3mm")),p:_t.default(_t.parse(n.p??"1.27mm")),pw:_t.default(_t.parse(n.pw??"0.6mm")),pl:_t.default(_t.parse(n.pl??"1.0mm")),legsoutside:Je().optional().default(n.legsoutside??!1),pillpads:Je().optional().default(n.pillpads??!1)}).transform(e=>(!e.pw&&!e.pl?(e.pw=_t.parse("0.6mm"),e.pl=_t.parse("1.0mm")):e.pw?e.pl||(e.pl=e.pw*(1/.6)):e.pw=e.pl*(.6/1),e)),hvn=X2({}),mye=n=>{n.widthincludeslegs!==void 0&&(n.legsoutside=!n.widthincludeslegs);const{num_pins:e,pn:t,w:i,p:r,pl:o,legsoutside:s}=n,a=e/2,c=t<=a,l=a-1,u=r,d=u*l,h=s?o/2:-o/2;return c?{x:-i/2-h,y:d/2-(t-1)*u}:{x:i/2+h,y:-d/2+(t-a-1)*u}},pvn=n=>{const e=hvn.parse(n);return{circuitJson:H5(e),parameters:e}},H5=n=>{const e=[];for(let a=0;a<n.num_pins;a++){const{x:c,y:l}=mye({num_pins:n.num_pins,pn:a+1,w:n.w,p:n.p,pl:n.pl,legsoutside:n.legsoutside});n.pillpads?e.push(rV(a+1,c,l,n.pl,n.pw)):e.push(zr(a+1,c,l,n.pl,n.pw))}const t=Math.min(1,n.p/2),i=n.w-(n.legsoutside?0:n.pl*2)-.2,r=(n.num_pins/2-1)*n.p+n.pw+t,o=Fo(0,r/2+.4,r/12),s={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",stroke_width:.1,route:[{x:-i/2,y:-r/2},{x:-i/2,y:r/2},...BJe.map(({x:a,y:c})=>({x:a*i/6,y:c*i/6+r/2})),{x:i/2,y:r/2},{x:i/2,y:-r/2},{x:-i/2,y:-r/2}]};return[...e,s,o]},qJe=Xt(["leftside","topside","rightside","bottomside","toppin","bottompin","leftpin","rightpin"]),fvn=({num_pins:n,cw:e,ccw:t,startingpin:i})=>{const r=[],o=n/4;let s=1;const a={};for(const c of i??[])a[c]=!0;!a.leftside&&!a.topside&&!a.rightside&&!a.bottomside&&(a.leftside=!0),!a.bottompin&&!a.leftpin&&!a.rightpin&&!a.toppin&&(a.leftside?a.toppin=!0:a.topside?a.rightpin=!0:a.rightside?a.bottompin=!0:a.bottomside&&(a.leftpin=!0)),a.leftside&&a.toppin?s=1:a.leftside&&a.bottompin?s=o:a.bottomside&&a.leftpin?s=o+1:a.bottomside&&a.rightpin?s=o*2:a.rightside&&a.bottompin?s=o*2+1:a.rightside&&a.toppin?s=o*3:a.topside&&a.rightpin?s=o*3+1:a.topside&&a.leftpin&&(s=o*4),r.push(-1);for(let c=0;c<n;c++)r[s]=c+1,t||!e?(s++,s>n&&(s=1)):(s--,s<1&&(s=n));return r},_ye=Se({fn:R(),cc:Je().default(!0).optional(),ccw:Je().default(!0).optional(),startingpin:R().or(ut(qJe)).transform(n=>typeof n=="string"?n.slice(1,-1).split(","):n).pipe(ut(qJe)).optional(),num_pins:Pe().optional().default(64),w:_t.optional(),h:_t.optional(),p:_t.default(_t.parse("0.5mm")),pw:_t.optional(),pl:_t.optional(),thermalpad:Bn([pe(!0),YJe]).optional(),legsoutside:Je().default(!1)}),yye=n=>{n.w&&!n.h?n.h=n.w:!n.w&&n.h&&(n.w=n.h);const e=n.num_pins/4;if(!n.p&&!n.pw&&!n.pl&&n.w){const t=e+4;n.p=n.w/t}return!n.p&&n.w&&n.h&&n.pw&&n.pl&&(n.p=(n.w-n.pl*2)/(e-1)),!n.w&&!n.h&&n.p&&(n.w=n.p*(e+4),n.h=n.w),n.p&&!n.pw&&!n.pl?(n.pw=n.p/2,n.pl=n.p/2):n.pw?n.pl||(n.pl=n.pw*(1/.6)):n.pw=n.pl*(.6/1),n},XJe=_ye.transform(yye),mvn=["left","bottom","right","top"],_vn=n=>{const{pin_count:e,pn:t,w:i,h:r,p:o,pl:s,legsoutside:a}=n,c=e/4,l=mvn[Math.floor((t-1)/c)],u=(t-1)%c,d=o*(c-1),h=o*(c-1),p=a?s/2:-s/2;switch(l){case"left":return{x:-i/2-p,y:h/2-u*o,o:"vert"};case"bottom":return{x:-d/2+u*o,y:-r/2-p,o:"horz"};case"right":return{x:i/2+p,y:-h/2+u*o,o:"vert"};case"top":return{x:d/2-u*o,y:r/2+p,o:"horz"};default:throw new Error("Invalid pin number")}},o8=n=>{const e=XJe.parse(n),t=[],i=fvn(e),r=e.num_pins/4;for(let a=0;a<e.num_pins;a++){const{x:c,y:l,o:u}=_vn({pin_count:e.num_pins,pn:a+1,w:e.w,h:e.h,p:e.p??.5,pl:e.pl,legsoutside:e.legsoutside});let d=e.pw,h=e.pl;u==="vert"&&([d,h]=[h,d]);const p=i[a+1];t.push(zr(p,c,l,d,h))}if(e.thermalpad)if(typeof e.thermalpad=="boolean"){const a=e.p*(r-1)+e.pw,c=e.p*(r-1)+e.pw;t.push(zr(["thermalpad"],0,0,a,c))}else t.push(zr(["thermalpad"],0,0,e.thermalpad.x,e.thermalpad.y));const o=[];for(const[a,c,l]of[["top-left",-1,1],["bottom-left",-1,-1],["bottom-right",1,-1],["top-right",1,1]]){const u=e.w/2*c,d=e.h/2*l;let h="none",p=u,m=d;const _=e.pw*2;i[1]===1&&a==="top-left"?h="in1":i[r*4]===1&&a==="top-left"||i[r*3+1]===1&&a==="top-right"?h="in2":i[r*3]===1&&a==="top-right"||i[r]===1&&a==="bottom-left"?h="in1":i[r+1]===1&&a==="bottom-left"?h="in2":i[r*2]===1&&a==="bottom-right"?h="in1":i[r*2+1]===1&&a==="bottom-right"&&(h="in2");const g=h==="in1"?1:-1;if(e.legsoutside){const x=h==="in1"?e.pl/2:e.pw/2,b=h==="in1"?e.pw/2:e.pl/2;p+=x*c*g,m-=b*l*g}(h==="none"||e.legsoutside)&&o.push({layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:`pcb_silkscreen_path_${a}`,route:[{x:u-_*c,y:d},{x:u,y:d},{x:u,y:d-_*l}],type:"pcb_silkscreen_path",stroke_width:.1}),(h==="in1"||h==="in2")&&!e.legsoutside&&o.push({layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:`pcb_silkscreen_path_${a}_1`,route:[{x:u-_*c,y:d},{x:u-_*c/2,y:d}],type:"pcb_silkscreen_path",stroke_width:0},{layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:`pcb_silkscreen_path_${a}_2`,route:[{x:u,y:d-_*l/2},{x:u,y:d-_*l}],type:"pcb_silkscreen_path",stroke_width:.1}),(h==="in1"||h==="in2")&&o.push({layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:`pcb_silkscreen_path_${a}_3`,route:[{x:p-.2*-c,y:m+.2*g},{x:p,y:m},{x:p+.2*g*-c,y:m+.2},{x:p-.2*-c,y:m+.2*g}],type:"pcb_silkscreen_path",stroke_width:.1})}const s=Fo(0,e.h/2+(e.legsoutside?e.pl*1.2:.5),.3);return{circuitJson:[...t,...o,s],parameters:e}};_ye.extend({}).transform(yye);var yvn=n=>(n.legsoutside=!1,o8(n)),gvn=n=>{n.legsoutside=!0;const e=XJe.parse(n);if(!n.p)switch(n.num_pins){case 44:case 64:n.p=.8;break;case 52:n.w===14?n.p=1:n.p=.65;break;case 208:n.p=.5;break}if(!n.pl)switch(n.num_pins){case 44:case 52:case 64:n.pl=2.25;break;case 208:n.pl=1.65;break;default:n.pl=e.pl*4;break}if(!n.pw)switch(n.num_pins){case 44:case 64:n.pw=.5;break;case 52:n.w===14?n.pw=.45:n.pw=.55;break;case 208:n.pw=.3;break;default:n.pw=e.pw;break}return o8(n)};_ye.extend({}).transform(yye);var xvn=n=>(n.legsoutside=!1,n.thermalpad===void 0&&(n.thermalpad=!0),o8(n)),bvn=X2({w:"3.9mm",p:"1.27mm"}),vvn=n=>{const e=bvn.parse(n);return{circuitJson:H5(e),parameters:e}},wvn=X2({w:"7.1mm",p:"0.65mm",pl:"1.35mm",pw:"0.40mm",legsoutside:!0}),Svn=n=>{const e=wvn.parse(n);return{circuitJson:H5(e),parameters:e}},Evn=X2({}),Tvn=n=>{const e=Evn.parse({fn:"sot363",num_pins:6,w:1.94,p:.65,pw:.3,pl:.7,legoutside:!0});return{circuitJson:H5(e),parameters:e}},WJe=Se({fn:R(),num_pins:Pe().default(3),w:R().default("1.92mm"),h:R().default("2.74mm"),pl:R().default("0.8mm"),pw:R().default("0.764mm"),p:R().default("0.95mm"),string:R().optional()}),Mvn=X2({p:"0.95mm",w:"1.6mm",legsoutside:!0}),Cvn=n=>{const e=n.string?.match(/^sot23_(\d+)/),t=e?Number.parseInt(e[1],10):3;if(t===6||t===8){const r=Mvn.parse({...n,num_pins:t});return{circuitJson:H5(r),parameters:r}}const i=WJe.parse({...n,num_pins:t});if(i.num_pins===3)return{circuitJson:Pvn(i),parameters:i};if(i.num_pins===5)return{circuitJson:ZJe(i),parameters:i};throw new Error("Invalid number of pins")},Avn=n=>{const{pn:e}=n;return e===1?{x:-1.7,y:0}:e===2?{x:1.7,y:-.95}:{x:1.7,y:.95}},Pvn=n=>{const e=[];for(let i=0;i<n.num_pins;i++){const{x:r,y:o}=Avn({num_pins:n.num_pins,pn:i+1,w:Number.parseFloat(n.w),h:Number.parseFloat(n.h),pl:Number.parseFloat(n.pl)});e.push(zr(i+1,r,o,Number.parseFloat(n.pl),Number.parseFloat(n.pw)))}const t=Fo(0,Number.parseInt(n.h),.3);return[...e,t]},KJe=n=>{const{p:e,h:t,pn:i}=n;if(i===1)return{x:-t/2-.5,y:e};if(i===2)return{x:-t/2-.5,y:0};if(i===3)return{x:-t/2-.5,y:-e};if(i===4)return{x:t/2+.5,y:-e};if(i===5)return{x:t/2+.5,y:e};throw new Error("Invalid pin number")},ZJe=n=>{const e=[];for(let d=1;d<=n.num_pins;d++){const{x:h,y:p}=KJe({h:Number.parseFloat(n.h),p:Number.parseFloat(n.p),pn:d});e.push(zr(d,h,p,Number.parseFloat(n.pl),Number.parseFloat(n.pw)))}const t=(n.num_pins+1)/2*Number.parseFloat(n.p),i=Number.parseFloat(n.h),r={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-t/3,y:i/2+Number.parseFloat(n.p)/1.3},{x:t/3,y:i/2+Number.parseFloat(n.p)/1.3}],type:"pcb_silkscreen_path",stroke_width:.05},o={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_2",route:[{x:-t/3,y:-i/2-Number.parseFloat(n.p)/1.3},{x:t/3,y:-i/2-Number.parseFloat(n.p)/1.3}],type:"pcb_silkscreen_path",stroke_width:.05},s=Fo(0,i+.3,.3),a=KJe({h:Number.parseFloat(n.h),p:Number.parseFloat(n.p),pn:1});a.x=a.x-Number.parseFloat(n.pw)*1.5;const c=.7,l=.3,u={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"pin1_indicator",route:[{x:a.x+c/2,y:a.y},{x:a.x-c/2,y:a.y+l/2},{x:a.x-c/2,y:a.y-l/2},{x:a.x+c/2,y:a.y}],stroke_width:.05};return[...e,s,r,o,u]},Rvn=WJe.extend({}),Ivn=n=>{const e=Rvn.parse({...n,num_pins:5});return{circuitJson:ZJe(e),parameters:e}},Nvn=[{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}],kvn=X2({}),Ovn=n=>{const e=kvn.parse(n),t=[];for(let d=0;d<e.num_pins;d++){const{x:h,y:p}=mye({num_pins:e.num_pins,pn:d+1,w:e.w,p:e.p??1.27,pl:e.pl,widthincludeslegs:!0});t.push(zr(d+1,h,p,e.pl??"1mm",e.pw??"0.6mm"))}const i=Math.min(1,e.p/2),r=e.w+i,o=(e.num_pins/2-1)*e.p+e.pw+i,s=[];for(const d of Nvn){const{dx:h,dy:p}=d;s.push({layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"",route:[{x:h*r/2-h*e.p,y:p*o/2},{x:h*r/2,y:p*o/2},{x:h*r/2,y:p*o/2-p*e.p}],type:"pcb_silkscreen_path",stroke_width:.1})}const a=e.p/4,c=-r/2-a/2,l=o/2-e.p/2;s.push({layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"",type:"pcb_silkscreen_path",route:[{x:c,y:l},{x:c-a,y:l+a},{x:c-a,y:l-a},{x:c,y:l}],stroke_width:.1});const u=Fo(0,o/2+.4,o/12);return{circuitJson:[...t,u,...s],parameters:e}},oV=(n,e,t,i,r,o)=>({pcb_plated_hole_id:"",type:"pcb_plated_hole",shape:"circular_hole_with_rect_pad",x:e,y:t,hole_diameter:gh(i),hole_shape:"circle",pad_shape:"rect",rect_pad_width:gh(r),rect_pad_height:gh(o),pcb_port_id:"",layers:["top","bottom"],port_hints:[n.toString()]}),gye=({fs:n,pn:e,anchor_x:t,anchor_y:i,textalign:r="center",orthogonal:o=!1,verticallyinverted:s=!1,layer:a="top"})=>{let c=0;o&&s?c=270:s?c=180:o?c=90:c=0;let l="center";return r==="left"&&(s?l="center_right":l="center_left"),r==="right"&&(s?l="center_left":l="center_right"),a==="bottom"&&(l==="center_left"?l="center_right":l==="center_right"&&(l="center_left")),{type:"pcb_silkscreen_text",pcb_silkscreen_text_id:"silkscreen_text_1",font:"tscircuit2024",font_size:n,pcb_component_id:"pcb_component_1",text:`{PIN${e}}`,layer:a,anchor_position:{x:t,y:i},anchor_alignment:l,ccw_rotation:c}};function Lvn({pinlabeltextalignleft:n,pinlabeltextalignright:e,pinlabelorthogonal:t}){let i="top";return t?i="left":i="top",n&&(t?i="bottom":i="right"),e&&(t?i="top":i="left"),i}var Dvn=Se({fn:R(),num_pins:Pe().optional().default(6),rows:Bn([R(),Pe()]).transform(n=>Number(n)).optional().default(1).describe("number of rows"),p:_t.default("0.1in").describe("pitch"),id:_t.default("1.0mm").describe("inner diameter"),od:_t.default("1.5mm").describe("outer diameter"),male:Je().optional().describe("for male pin headers"),female:Je().optional().describe("for female pin headers"),pinlabeltextalignleft:Je().optional().default(!1),pinlabeltextaligncenter:Je().optional().default(!1),pinlabeltextalignright:Je().optional().default(!1),pinlabelverticallyinverted:Je().optional().default(!1),pinlabelorthogonal:Je().optional().default(!1),nosquareplating:Je().optional().default(!1).describe("do not use rectangular pad for pin 1"),nopinlabels:Je().optional().default(!1).describe("omit silkscreen pin labels"),doublesidedpinlabel:Je().optional().default(!1).describe("add silkscreen pins in top and bottom layers"),bottomsidepinlabel:Je().optional().default(!1).describe("place the silkscreen reference text on the bottom layer instead of top")}).transform(n=>{const e=Lvn(n);return{...n,pinlabelAnchorSide:e,male:n.male??!n.female,female:n.female??!1}}).superRefine((n,e)=>{n.male&&n.female&&e.addIssue({code:$i.custom,message:"'male' and 'female' cannot both be true; it should be male or female.",path:["male","female"]})}),zvn=n=>{const e=Dvn.parse(n),{p:t,id:i,od:r,rows:o,num_pins:s,pinlabelAnchorSide:a,pinlabelverticallyinverted:c,pinlabelorthogonal:l,pinlabeltextalignleft:u,pinlabeltextalignright:d,nopinlabels:h,doublesidedpinlabel:p,bottomsidepinlabel:m}=e;let _="center";u?_="left":d&&(_="right");const g=[],x=Math.ceil(s/o),b=-t,w=({xoff:M,yoff:k,od:C,anchorSide:U})=>{let O=0,H=0;const Y=C*.75;switch(U){case"right":O=Y;break;case"top":H=Y;break;case"bottom":H=-Y;break;case"left":O=-Y;break}return{anchor_x:M+O,anchor_y:k+H}},E=(M,k,C)=>{M===1&&!e.nosquareplating?g.push(oV(M,k,C,i,r,r)):g.push(Ia(M,k,C,i,r));const{anchor_x:U,anchor_y:O}=w({xoff:k,yoff:C,od:r,anchorSide:a});h||(m?g.push(gye({fs:r/5,pn:M,anchor_x:U,anchor_y:O,textalign:_,orthogonal:l,verticallyinverted:c,layer:"bottom"})):g.push(gye({fs:r/5,pn:M,anchor_x:U,anchor_y:O,textalign:_,orthogonal:l,verticallyinverted:c,layer:"top"})),p&&g.push(gye({fs:r/5,pn:M,anchor_x:U,anchor_y:O,textalign:_,orthogonal:l,verticallyinverted:c,layer:"bottom"})))},N=new Set,A=o>2&&x>2;if(o===1){const M=-((s-1)/2)*t;for(let k=0;k<s;k++){const C=k+1,U=M+k*t,O=`${U},0`;if(N.has(O))throw new Error(`Overlap at ${O}`);N.add(O),E(C,U,0)}}else if(A){const M=-((x-1)/2)*t;let k=1;for(let C=0;C<o&&k<=s;C++)for(let U=0;U<x&&k<=s;U++){const O=M+U*t,H=C*b,Y=`${O},${H}`;if(N.has(Y))throw new Error(`Overlap at ${Y}`);N.add(Y),E(k++,O,H)}}else{const M=-((x-1)/2)*t;let k=1,C=0,U=o-1,O=0,H=x-1;for(;k<=s&&C<=U&&O<=H;){for(let Y=C;Y<=U&&k<=s;Y++){const W=M+O*t,K=Y*b,J=`${W},${K}`;if(N.has(J))throw new Error(`Overlap at ${J}`);N.add(J),E(k++,W,K)}O++;for(let Y=O;Y<=H&&k<=s;Y++){const W=M+Y*t,K=U*b,J=`${W},${K}`;if(N.has(J))throw new Error(`Overlap at ${J}`);N.add(J),E(k++,W,K)}if(U--,O<=H){for(let Y=U;Y>=C&&k<=s;Y--){const W=M+H*t,K=Y*b,J=`${W},${K}`;if(N.has(J))throw new Error(`Overlap at ${J}`);N.add(J),E(k++,W,K)}H--}if(C<=U){for(let Y=H;Y>=O&&k<=s;Y--){const W=M+Y*t,K=C*b,J=`${W},${K}`;if(N.has(J))throw new Error(`Overlap at ${J}`);N.add(J),E(k++,W,K)}C++}}if(k-1<s)throw new Error(`Missing pins: assigned ${k-1}, expected ${s}`)}const I=Fo(0,t,.5);return{circuitJson:[...g,I],parameters:e}},$vn=X2({}),Fvn=n=>{const e=$vn.parse({fn:"sot563",num_pins:6,w:1.94,p:.5,pw:.3,pl:.67,legoutside:!0});return{circuitJson:H5(e),parameters:e}},Uvn=X2({p:"1.27mm",w:"3.9mm",legsoutside:!0}),Bvn=n=>{const e=Uvn.parse({...n,num_pins:8});return{circuitJson:H5(e),parameters:e}},jvn=X2({p:"1.27mm",w:"7.5mm",legsoutside:!0}),Hvn=n=>{const e=jvn.parse({...n,num_pins:16});return{circuitJson:H5(e),parameters:e}},Vvn=Se({fn:R(),num_pins:pe(3).default(3),w:R().default("1.2mm"),h:R().default("1.2mm"),pl:R().default("0.3mm"),pw:R().default("0.32mm")}),Gvn=n=>{const e=Vvn.parse(n),t=qvn(e),i=Fo(.4,_t.parse(e.h),.2);return{circuitJson:[...t,i],parameters:e}},Yvn=n=>{const{pn:e}=n;return e===1?{x:0,y:0}:e===2?{x:1,y:-.4}:{x:1,y:.4}},qvn=n=>{const e=[];for(let t=0;t<3;t++){const{x:i,y:r}=Yvn({num_pins:n.num_pins,pn:t+1,w:Number.parseFloat(n.w),h:Number.parseFloat(n.h),pl:Number.parseFloat(n.pl)});e.push(zr(t+1,i,r,Number.parseFloat(n.pl),t!==0?Number.parseFloat(n.pw):.42))}return e},Xvn=Se({fn:R(),num_pins:pe(2).default(2),w:R().default("2.36mm"),h:R().default("1.22mm"),pl:R().default("0.9mm"),pw:R().default("0.9mm"),p:R().default("4.19mm")}),Wvn=n=>{const e=Xvn.parse(n),t=Fo(0,_t.parse(e.h)/4+.4,.3);return{circuitJson:Zvn(e).concat(t),parameters:e}},Kvn=n=>{const{pn:e,p:t}=n;return e===1?{x:-t/2,y:0}:{x:t/2,y:0}},Zvn=n=>{const e=[];for(let t=1;t<=n.num_pins;t++){const{x:i,y:r}=Kvn({pn:t,p:Number.parseFloat(n.p)});e.push(zr(t,i,r,Number.parseFloat(n.pl),Number.parseFloat(n.pw)))}return e},Qvn=Se({fn:R(),p:_t.optional().default("2.54mm"),id:_t.optional().default("0.7mm"),od:_t.optional().default("1mm")}),Jvn=n=>{const e=Qvn.parse(n),{p:t,id:i,od:r}=e,o=[Ia(1,-t/2,0,i,r),Ia(2,t/2,0,i,r)],s={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-t/2+r+i/2,y:0},{x:t/2-r-i/2,y:0}],stroke_width:.1,pcb_silkscreen_path_id:""},a=Fo(0,t/4,.5);return{circuitJson:[...o,s,a],parameters:e}},sV=(n,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:n,stroke_width:e.stroke_width||.1}),ewn=Se({fn:pe("pushbutton"),w:_t.default(4.5),h:_t.default(6.5),id:_t.default(1),od:_t.default(1.2)}),twn=n=>{const e=ewn.parse(n),t=e.w,i=e.h,r=e.id,o=[Ia(1,-t/2,i/2,r,r*1.5),Ia(2,-t/2,-i/2,r,r*1.5),Ia(3,t/2,-i/2,r,r*1.5),Ia(4,t/2,i/2,r,r*1.5)],s=[sV([{x:-t/2,y:-i/2},{x:-t/2,y:i/2}]),sV([{x:t/2,y:-i/2},{x:t/2,y:i/2}]),sV([{x:-t/2,y:0},{x:-t/5,y:0},{x:t/5*1/Math.sqrt(2),y:i/8}]),sV([{x:t/2,y:0},{x:t/5,y:0}])],a=Fo(0,i/2+.4,.5);return{circuitJson:[...o,...s,a],parameters:e}},QJe=Se({fn:R(),w:_t.default("22.58mm"),h:_t.optional(),left:_t.optional().default(20),right:_t.optional().default(20),top:_t.optional().default(2),bottom:_t.optional().default(2),p:_t.default(_t.parse("2.54mm")),pw:_t.default(_t.parse("1.6mm")),pl:_t.default(_t.parse("2.4mm")),innerhole:Je().default(!1),innerholeedgedistance:_t.default(_t.parse("1.61mm")),silkscreenlabels:Je().default(!1),silkscreenlabelmargin:_t.default(_t.parse("0.1mm"))}),nwn=n=>{const e=QJe.parse(n);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},aV=(n,e,t)=>{let i=[];return t==="right"&&(i=[{x:n+1/2,y:e},{x:n-1/2,y:e+.6/2},{x:n-1/2,y:e-.6/2},{x:n+1/2,y:e}]),t==="left"&&(i=[{x:n-1/2,y:e},{x:n+1/2,y:e+.6/2},{x:n+1/2,y:e-.6/2},{x:n-1/2,y:e}]),t==="top"&&(i=[{x:n,y:e+1/2},{x:n-.6/2,y:e-1/2},{x:n+.6/2,y:e-1/2},{x:n,y:e+1/2}]),t==="bottom"&&(i=[{x:n,y:e-1/2},{x:n-.6/2,y:e+1/2},{x:n+.6/2,y:e+1/2},{x:n,y:e-1/2}]),i},iwn=n=>{const e=QJe.parse(n),t=e.h??nwn(e),i=[],r=[],o=[];let s=[];const a=1,c=a,l=e.left+e.right+(e.bottom??0)+(e.top??0),d=`pin${l}`.length*.7/2;if(e.right){const _=-((e.right-1)/2)*e.p;for(let g=0;g<e.right;g++){if(g===0&&!e.left&&!e.bottom&&!e.silkscreenlabels&&(s=aV(e.w/2-e.pl*1.4,_+g*e.p,"right")),i.push(zr(g+1+e.left+(e.bottom??0),e.w/2-e.pl/2,_+g*e.p,e.pl,e.pw)),e.silkscreenlabels){const x=g+1+e.left+(e.bottom??0),b=`pin${x}`;o.push({type:"pcb_silkscreen_text",pcb_silkscreen_text_id:`pin_${x}`,pcb_component_id:"1",layer:"top",anchor_position:{x:e.w/2-e.pl-(d+e.silkscreenlabelmargin),y:_+g*e.p},text:b,font_size:.7,font:"tscircuit2024",anchor_alignment:"center"})}e.innerhole&&(r.push(Ia(g+1+e.left+(e.bottom??0)+l,e.w/2,_+g*e.p,a,c)),r.push(Ia(g+1+e.left+(e.bottom??0)+l*2,e.w/2-e.innerholeedgedistance,_+g*e.p,a,c)))}}if(e.left){const _=(e.left-1)/2*e.p;for(let g=0;g<e.left;g++){if(g===0&&!e.silkscreenlabels&&(s=aV(-e.w/2+e.pl*1.4,_-g*e.p,"left")),i.push(zr(g+1,-e.w/2+e.pl/2,_-g*e.p,e.pl,e.pw)),e.silkscreenlabels){const x=g+1,b=`pin${x}`;o.push({type:"pcb_silkscreen_text",pcb_silkscreen_text_id:`pin_${x}`,pcb_component_id:"1",layer:"top",anchor_position:{x:-e.w/2+e.pl+(d+e.silkscreenlabelmargin),y:_-g*e.p},text:b,font_size:.7,font:"tscircuit2024",anchor_alignment:"center"})}e.innerhole&&(r.push(Ia(g+1+l,-e.w/2,_-g*e.p,a,c)),r.push(Ia(g+1+l*2,-e.w/2+e.innerholeedgedistance,_-g*e.p,a,c)))}}if(e.top){const _=(e.top-1)/2*e.p;for(let g=0;g<e.top;g++){if(g===0&&!e.left&&!e.bottom&&!e.right&&!e.silkscreenlabels&&(s=aV(_-g*e.p,t/2-e.pl*1.4,"top")),i.push(zr(g+1+e.left+e.right+(e.bottom??0),_-g*e.p,t/2-e.pl/2,e.pw,e.pl)),e.silkscreenlabels){const x=g+1+e.left+e.right+(e.bottom??0),b=`pin${x}`;o.push({type:"pcb_silkscreen_text",pcb_silkscreen_text_id:`pin_${x}`,pcb_component_id:"1",layer:"top",anchor_position:{x:_-g*e.p,y:t/2-e.pl-(d+e.silkscreenlabelmargin)},text:b,font_size:.7,font:"tscircuit2024",anchor_alignment:"center",ccw_rotation:270})}e.innerhole&&(r.push(Ia(g+1+e.left+e.right+(e.bottom??0)+l,_-g*e.p,t/2,a,c)),r.push(Ia(g+1+e.left+e.right+(e.bottom??0)+l*2,_-g*e.p,t/2-e.innerholeedgedistance,a,c)))}}if(e.bottom){const _=-((e.bottom-1)/2)*e.p;for(let g=0;g<e.bottom;g++){if(g===0&&!e.left&&!e.silkscreenlabels&&(s=aV(_+g*e.p,-t/2+e.pl*1.4,"bottom")),i.push(zr(g+1+e.left,_+g*e.p,-t/2+e.pl/2,e.pw,e.pl)),e.silkscreenlabels){const x=g+1+e.left,b=`pin${x}`;o.push({type:"pcb_silkscreen_text",pcb_silkscreen_text_id:`pin_${x}`,pcb_component_id:"1",layer:"top",anchor_position:{x:_+g*e.p,y:-t/2+e.pl+(d+e.silkscreenlabelmargin)},text:b,font_size:.7,font:"tscircuit2024",anchor_alignment:"center",ccw_rotation:90})}e.innerhole&&(r.push(Ia(g+1+e.left+l,_+g*e.p,-t/2,a,c)),r.push(Ia(g+1+e.left+l*2,_+g*e.p,-t/2+e.innerholeedgedistance,a,c)))}}const h={type:"pcb_silkscreen_path",pcb_silkscreen_path_id:"pcb_silkscreen_triangle_1",pcb_component_id:"2",route:s,stroke_width:.1,layer:"top"},p={type:"pcb_silkscreen_path",pcb_silkscreen_path_id:"pcb_silkscreen_path_1",pcb_component_id:"1",route:[{x:-e.w/2,y:t/2},{x:e.w/2,y:t/2},{x:e.w/2,y:-t/2},{x:-e.w/2,y:-t/2},{x:-e.w/2,y:t/2}],stroke_width:.1,layer:"top"},m=Fo(0,t/1.8,t/25);return{circuitJson:[...i,...r,...o,p,...e.silkscreenlabels?[]:[h],m],parameters:e}},JJe=Se({fn:R(),w:_t.default("22.58mm"),h:_t.optional(),left:_t.optional().default(20),right:_t.optional().default(20),top:_t.optional().default(2),bottom:_t.optional().default(2),p:_t.default(_t.parse("2.54mm")),pw:_t.default(_t.parse("1.6mm")),pl:_t.default(_t.parse("3.2mm")),innerhole:Je().default(!1),innerholeedgedistance:_t.default(_t.parse("1.61mm"))}),rwn=n=>{const e=JJe.parse(n);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},own=(n,e,t,i=1,r=.6)=>{const o=i/2,s=r/2;return{left:[{x:n+o,y:e},{x:n-o,y:e+s},{x:n-o,y:e-s},{x:n+o,y:e}],right:[{x:n-o,y:e},{x:n+o,y:e+s},{x:n+o,y:e-s},{x:n-o,y:e}],top:[{x:n,y:e-o},{x:n-s,y:e+o},{x:n+s,y:e+o},{x:n,y:e-o}],bottom:[{x:n,y:e+o},{x:n-s,y:e-o},{x:n+s,y:e-o},{x:n,y:e+o}]}[t]},swn=n=>{const e=JJe.parse(n),t=e.h??rwn(e),i=[],r=[],o=[],s=1,a=1.2,c=e.left+e.right+(e.bottom??0)+(e.top??0);let l=[],u=1;if(e.left){const m=(e.left-1)/2*e.p;for(let _=0;_<e.left;_++)_===0&&(l=own(-e.w/2-e.pl/2,m-_*e.p,"left")),i.push(zr(u,-e.w/2+e.pl/2,m-_*e.p,e.pl,e.pw)),r.push({type:"pcb_silkscreen_text",pcb_silkscreen_text_id:`pin_${u}`,pcb_component_id:"1",layer:"top",anchor_position:{x:-e.w/2+e.pl/2-4.5,y:m-_*e.p},text:`pin${u}`,font_size:.7,font:"tscircuit2024",anchor_alignment:"center"}),u++,e.innerhole&&o.push(Ia(u+c,-e.w/2+e.innerholeedgedistance,m-_*e.p,s,a))}if(e.bottom){const m=(e.bottom-1)/2*e.p;for(let _=e.bottom-1;_>=0;_--)i.push(zr(u,m-_*e.p,-t/2+e.pl/2,e.pw,e.pl)),r.push({type:"pcb_silkscreen_text",pcb_silkscreen_text_id:`pin_${u}`,pcb_component_id:"1",layer:"top",anchor_position:{x:m-_*e.p,y:-t/2+e.pl/2-3.2},text:`pin${u}`,font_size:.7,font:"tscircuit2024",anchor_alignment:"center"}),u++,e.innerhole&&o.push(Ia(u+c,m-_*e.p,-t/2+e.innerholeedgedistance,s,a))}if(e.right){const m=-((e.right-1)/2)*e.p;for(let _=0;_<e.right;_++)i.push(zr(u,e.w/2-e.pl/2,m+_*e.p,e.pl,e.pw)),r.push({type:"pcb_silkscreen_text",pcb_silkscreen_text_id:`pin_${u}`,pcb_component_id:"1",layer:"top",anchor_position:{x:e.w/2-e.pl/2+3.7,y:m+_*e.p},text:`pin${u}`,font_size:.7,font:"tscircuit2024",anchor_alignment:"center"}),u++,e.innerhole&&o.push(Ia(u+c,e.w/2-e.innerholeedgedistance,m+_*e.p,s,a))}if(e.top){const m=-((e.top-1)/2)*e.p;for(let _=e.top-1;_>=0;_--)i.push(zr(u,m+_*e.p,t/2-e.pl/2,e.pw,e.pl)),r.push({type:"pcb_silkscreen_text",pcb_silkscreen_text_id:`pin_${u}`,pcb_component_id:"1",layer:"top",anchor_position:{x:m+_*e.p,y:t/2-e.pl/2+3.2},text:`pin${u}`,font_size:.7,font:"tscircuit2024",anchor_alignment:"center"}),u++,e.innerhole&&o.push(Ia(u+c,m+_*e.p,t/2-e.innerholeedgedistance,s,a))}const d={type:"pcb_silkscreen_path",pcb_silkscreen_path_id:"1",pcb_component_id:"1",layer:"top",route:l,stroke_width:.1},h={type:"pcb_silkscreen_path",pcb_silkscreen_path_id:"pcb_silkscreen_path_1",pcb_component_id:"1",route:[{x:-e.w/2-e.pl/3,y:t/2+e.pl/3},{x:e.w/2+e.pl/3,y:t/2+e.pl/3},{x:e.w/2+e.pl/3,y:-t/2-e.pl/3},{x:-e.w/2-e.pl/3,y:-t/2-e.pl/3},{x:-e.w/2-e.pl/3,y:t/2+e.pl/3}],stroke_width:.1,layer:"top"},p=Fo(0,t/1.8,t/25);return{circuitJson:[...o,...i,...r,h,d,p],parameters:e}},awn=n=>(n.legsoutside=!0,o8(n)),eet=Se({fn:R(),w:_t.default("10mm"),h:_t.optional(),left:_t.optional().default(20),right:_t.optional().default(20),top:_t.optional().default(0),bottom:_t.optional().default(0),p:_t.default(_t.parse("2.54mm")),id:_t.optional().default(_t.parse("1mm")),od:_t.optional().default(_t.parse("1.5mm"))}),cwn=n=>{const e=eet.parse(n);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},cV=(n,e,t,i=1,r=.6)=>{const o=i/2,s=r/2;return{left:[{x:n+o,y:e},{x:n-o,y:e+s},{x:n-o,y:e-s},{x:n+o,y:e}],right:[{x:n-o,y:e},{x:n+o,y:e+s},{x:n+o,y:e-s},{x:n-o,y:e}],top:[{x:n,y:e-o},{x:n-s,y:e+o},{x:n+s,y:e+o},{x:n,y:e-o}],bottom:[{x:n,y:e+o},{x:n-s,y:e-o},{x:n+s,y:e-o},{x:n,y:e+o}]}[t]},lwn=n=>{const e=eet.parse(n),t=e.h??cwn(e),i=[],r=e.id,o=e.od;let s=[];if(e.right){const u=-((e.right-1)/2)*e.p;for(let d=0;d<e.right;d++)d===0&&!e.left&&!e.bottom&&(s=cV(e.w/2+o*1.4,u+d*e.p,"right")),i.push(Ia(d+1+e.left+(e.bottom??0),e.w/2,u+d*e.p,r,o))}if(e.left){const u=-((e.left-1)/2)*e.p;for(let d=0;d<e.left;d++)d===e.left-1&&(s=cV(-e.w/2-o*1.4,u+d*e.p,"left")),i.push(Ia(d+1,-e.w/2,u+d*e.p,r,o))}if(e.top){const u=-((e.top-1)/2)*e.p;for(let d=0;d<e.top;d++)d===e.top-1&&!e.left&&!e.bottom&&!e.right&&(s=cV(u+d*e.p,t/2+o*1.4,"top")),i.push(Ia(d+1+e.right+(e.bottom??0)+e.left,u+d*e.p,t/2,r,o))}if(e.bottom){const u=-((e.bottom-1)/2)*e.p;for(let d=0;d<e.bottom;d++)d===0&&!e.left&&(s=cV(u+d*e.p,-t/2-o*1.4,"bottom")),i.push(Ia(d+1+e.left,u+d*e.p,-t/2,r,o))}const a={type:"pcb_silkscreen_path",pcb_silkscreen_path_id:"1",pcb_component_id:"1",layer:"top",route:s,stroke_width:.1},c={type:"pcb_silkscreen_path",pcb_silkscreen_path_id:"pcb_silkscreen_path_1",pcb_component_id:"1",route:[{x:-e.w/2-o,y:t/2+o},{x:e.w/2+o,y:t/2+o},{x:e.w/2+o,y:-t/2-o},{x:-e.w/2-o,y:-t/2-o},{x:-e.w/2-o,y:t/2+o}],stroke_width:.1,layer:"top"},l=Fo(0,t/1.7,t/25);return{circuitJson:[...i,c,l,a],parameters:e}},tet=(n,e,t,i)=>Array.from({length:25},(r,o)=>{const s=o/24*Math.PI-Math.PI/2;return{x:n+(i==="right"?1:-1)*Math.cos(s)*t,y:e+Math.sin(s)*t}}),uwn=Se({fn:R(),p:_t.optional().default("4.88mm"),id:_t.optional().default("0.6mm"),od:_t.optional().default("1.2mm"),w:_t.optional().default("5.6mm"),h:_t.optional().default("3.5mm")}),dwn=n=>{const e=uwn.parse(n),{p:t,id:i,od:r,w:o,h:s}=e,a=s/2,c=[Ia(1,-t/2,0,i,r),Ia(2,t/2,0,i,r)],l=tet(-o/2,0,a,"left"),u=tet(o/2,0,a,"right"),d={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[...l,...l.slice(1).reverse(),{x:-o/2,y:-s/2},{x:o/2,y:-s/2},...u,{x:o/2,y:s/2},{x:-o/2,y:s/2}],stroke_width:.1,pcb_silkscreen_path_id:""},h=Fo(0,t/4,.5);return{circuitJson:[...c,d,h],parameters:e}};Se({w:_t,h:_t});var hwn=n=>{const{w:e,h:t}=n,i=gh(e),r=gh(t);return{circuitJson:[zr(1,0,0,i,r),Fo(0,r/2+.5,.2)],parameters:n}},pwn=Se({fn:R(),num_pins:Bn([pe(3),pe(2)]).default(3),p:R().default("1.27mm"),id:R().default("0.72mm"),od:R().default("0.95mm"),w:R().default("4.5mm"),h:R().default("4.5mm"),inline:Je().default(!1),string:R().optional()}),fwn=(n,e,t)=>Array.from({length:25},(i,r)=>{const o=r/24*Math.PI;return{x:n+Math.cos(o)*t,y:e+Math.sin(o)*t}}),mwn=n=>{const{p:e,id:t,od:i,h:r}=n,o=Number.parseFloat(r)/2,s=Number.parseFloat(e);return[Ia(1,-s,o-s,t,i),Ia(2,s,o-s,t,i)]},_wn=n=>{const e=n.string?.match(/^to92_(\d+)/),t=e?Number.parseInt(e[1],10):3,i=pwn.parse({...n,num_pins:t}),{p:r,id:o,od:s,w:a,h:c,inline:l}=i,u=Number.parseFloat(c)/2,d=Number.parseFloat(r);let h=[];if(i.num_pins===3)h=l?[Ia(1,-d,u-d,o,s),Ia(2,0,u-d,o,s),Ia(3,d,u-d,o,s)]:[Ia(1,0,u,o,s),Ia(2,-d,u-d,o,s),Ia(3,d,u-d,o,s)];else if(i.num_pins===2)h=mwn(i);else throw new Error("Invalid number of pins for TO-92");const p=Number.parseFloat(a)/2,m=fwn(0,u,p),_={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[...m,{x:-p,y:0},{x:p,y:0},m[0]],stroke_width:.1,pcb_silkscreen_path_id:""},g=Fo(0,u+1,.5);return{circuitJson:[...h,_,g],parameters:i}},ywn=Se({fn:R(),num_pins:pe(2).default(2),w:R().default("2.15mm"),h:R().default("1.20mm"),pl:R().default("0.5mm"),pw:R().default("0.6mm"),p:R().default("1.4mm")}),gwn=n=>{const e=ywn.parse(n),t=Fo(0,_t.parse(e.h),.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:_t.parse(e.p)/2,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2-.2,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2-.2,y:-_t.parse(e.h)/2},{x:_t.parse(e.p)/2,y:-_t.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:bwn(e).concat(i,t),parameters:e}},xwn=n=>{const{pn:e,p:t}=n;return e===1?{x:-t/2,y:0}:{x:t/2,y:0}},bwn=n=>{const e=[];for(let t=1;t<=n.num_pins;t++){const{x:i,y:r}=xwn({pn:t,p:Number.parseFloat(n.p)});e.push(zr(t,i,r,Number.parseFloat(n.pl),Number.parseFloat(n.pw)))}return e},vwn=X2({}),wwn=n=>{const e=vwn.parse(n),t=[];for(let s=0;s<e.num_pins;s++){const{x:a,y:c}=mye({num_pins:e.num_pins,pn:s+1,w:e.w,p:e.p??1.27,pl:e.pl,widthincludeslegs:!0});t.push(zr(s+1,a,c,e.pl??"1.5mm",e.pw??"0.6mm"))}const i=(e.num_pins/2-1)*e.p+e.pw,r=Fo(0,i/2-.5,i/12),o={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"",type:"pcb_silkscreen_path",route:[{x:-e.w/3,y:i/2+.2},{x:e.w/3,y:i/2+.2}],stroke_width:.1};return{circuitJson:[...t,r,o],parameters:e}},Swn=Se({fn:R(),num_pins:pe(2).default(2),w:R().default("5.0mm"),h:R().default("2.30mm"),pl:R().default("1.25mm"),pw:R().default("2mm"),p:R().default("3.75mm")}),Ewn=n=>{const e=Swn.parse(n),t=Fo(0,_t.parse(e.h)/2+1,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:_t.parse(e.p)/2+.5,y:_t.parse(e.h)/2+.5},{x:-_t.parse(e.w)/2-.5,y:_t.parse(e.h)/2+.5},{x:-_t.parse(e.w)/2-.5,y:-_t.parse(e.h)/2-.5},{x:_t.parse(e.p)/2+.5,y:-_t.parse(e.h)/2-.5}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:Mwn(e).concat(i,t),parameters:e}},Twn=n=>{const{pn:e,p:t}=n;return e===1?{x:-t/2,y:0}:{x:t/2,y:0}},Mwn=n=>{const e=[];for(let t=1;t<=n.num_pins;t++){const{x:i,y:r}=Twn({pn:t,p:Number.parseFloat(n.p)});e.push(zr(t,i,r,Number.parseFloat(n.pl),Number.parseFloat(n.pw)))}return e},Cwn=Se({fn:R(),num_pins:pe(2).default(2),w:R().default("4.4mm"),h:R().default("2.1mm"),pl:R().default("1.2mm"),pw:R().default("1.2mm"),p:R().default("2.9mm")}),Awn=n=>{const e=Cwn.parse(n),t=Fo(0,_t.parse(e.h)-.5,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:_t.parse(e.p)/2,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2-.2,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2-.2,y:-_t.parse(e.h)/2},{x:_t.parse(e.p)/2,y:-_t.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:Rwn(e).concat(i,t),parameters:e}},Pwn=n=>{const{pn:e,p:t}=n;return e===1?{x:-t/2,y:0}:{x:t/2,y:0}},Rwn=n=>{const e=[];for(let t=1;t<=n.num_pins;t++){const{x:i,y:r}=Pwn({pn:t,p:Number.parseFloat(n.p)});e.push(zr(t,i,r,Number.parseFloat(n.pl),Number.parseFloat(n.pw)))}return e},Iwn=Se({fn:R(),num_pins:pe(2).default(2),w:R().default("3.30mm"),h:R().default("1.80mm"),pl:R().default("0.60mm"),pw:R().default("0.45mm"),p:R().default("2.1mm")}),Nwn=n=>{const e=Iwn.parse(n),t=Fo(0,_t.parse(e.h)-.5,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:_t.parse(e.p)/2,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2,y:-_t.parse(e.h)/2},{x:_t.parse(e.p)/2,y:-_t.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:Own(e).concat(i,t),parameters:e}},kwn=n=>{const{pn:e,p:t}=n;return e===1?{x:-t/2,y:0}:{x:t/2,y:0}},Own=n=>{const e=[];for(let t=1;t<=n.num_pins;t++){const{x:i,y:r}=kwn({pn:t,p:Number.parseFloat(n.p)});e.push(zr(t,i,r,Number.parseFloat(n.pl),Number.parseFloat(n.pw)))}return e},Lwn=Se({fn:R(),num_pins:pe(2).default(2),w:R().default("1.4mm"),h:R().default("0.9mm"),pl:R().default("0.35mm"),pw:R().default("0.25mm"),p:R().default("1.2mm")}),Dwn=n=>{const e=Lwn.parse(n),t=Fo(0,_t.parse(e.h),.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:_t.parse(e.p)/2+.15,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2-.4,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2-.4,y:-_t.parse(e.h)/2},{x:_t.parse(e.p)/2+.15,y:-_t.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:$wn(e).concat(i,t),parameters:e}},zwn=n=>{const{pn:e,p:t}=n;return e===1?{x:-t/2,y:0}:{x:t/2,y:0}},$wn=n=>{const e=[];for(let t=1;t<=n.num_pins;t++){const{x:i,y:r}=zwn({pn:t,p:Number.parseFloat(n.p)});e.push(zr(t,i,r,Number.parseFloat(n.pl),Number.parseFloat(n.pw)))}return e},Fwn=Se({fn:R(),num_pins:pe(2).default(2),w:R().default("1.3mm"),h:R().default("0.9mm"),pl:R().default("0.4mm"),pw:R().default("0.7mm"),p:R().default("0.7mm")}),Uwn=n=>{const e=Fwn.parse(n),t=Fo(0,_t.parse(e.h)+.1,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:_t.parse(e.p)/2+.2,y:_t.parse(e.h)/2+.2},{x:-_t.parse(e.w)/2-.2,y:_t.parse(e.h)/2+.2},{x:-_t.parse(e.w)/2-.2,y:-_t.parse(e.h)/2-.2},{x:_t.parse(e.p)/2+.2,y:-_t.parse(e.h)/2-.2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:jwn(e).concat(i,t),parameters:e}},Bwn=n=>{const{pn:e,p:t}=n;return e===1?{x:-t/2,y:0}:{x:t/2,y:0}},jwn=n=>{const e=[];for(let t=1;t<=n.num_pins;t++){const{x:i,y:r}=Bwn({pn:t,p:Number.parseFloat(n.p)});e.push(zr(t,i,r,Number.parseFloat(n.pl),Number.parseFloat(n.pw)))}return e},Hwn=Se({fn:R(),num_pins:pe(2).default(2),w:R().default("3,05mm"),h:R().default("1.65mm"),pl:R().default("0.6mm"),pw:R().default("0.6mm"),pad_spacing:R().default("2.2mm")}),Vwn=n=>{const e=Hwn.parse(n),t=Fo(0,_t.parse(e.h),.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:_t.parse(e.pad_spacing)/2,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2-.2,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2-.2,y:-_t.parse(e.h)/2},{x:_t.parse(e.pad_spacing)/2,y:-_t.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:Ywn(e).concat(i,t),parameters:e}},Gwn=n=>{const{pn:e,pad_spacing:t}=n;return e===1?{x:-t/2,y:0}:{x:t/2,y:0}},Ywn=n=>{const e=[];for(let t=1;t<=n.num_pins;t++){const{x:i,y:r}=Gwn({pn:t,pad_spacing:Number.parseFloat(n.pad_spacing)});e.push(zr(t,i,r,Number.parseFloat(n.pl),Number.parseFloat(n.pw)))}return e},qwn=Se({fn:R(),num_pins:pe(2).default(2),w:R().default("4.4mm"),h:R().default("2.1mm"),pl:R().default("1.2mm"),pw:R().default("1.2mm"),p:R().default("2.9mm")}),Xwn=n=>{const e=qwn.parse(n),t=Fo(0,_t.parse(e.h),.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:_t.parse(e.p)/2,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2-.2,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2-.2,y:-_t.parse(e.h)/2},{x:_t.parse(e.p)/2,y:-_t.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:Kwn(e).concat(i,t),parameters:e}},Wwn=n=>{const{pn:e,p:t}=n;return e===1?{x:-t/2,y:0}:{x:t/2,y:0}},Kwn=n=>{const e=[];for(let t=1;t<=n.num_pins;t++){const{x:i,y:r}=Wwn({pn:t,p:Number.parseFloat(n.p)});e.push(zr(t,i,r,Number.parseFloat(n.pl),Number.parseFloat(n.pw)))}return e},Zwn=Se({fn:R(),num_pins:pe(2).default(2),w:R().default("4.4mm"),h:R().default("2.1mm"),pl:R().default("0.91mm"),pw:R().default("1.22mm"),p:R().default("3.146mm")}),Qwn=n=>{const e=Zwn.parse(n),t=Fo(0,_t.parse(e.h),.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:_t.parse(e.p)/2,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2-.2,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2-.2,y:-_t.parse(e.h)/2},{x:_t.parse(e.p)/2,y:-_t.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:eSn(e).concat(i,t),parameters:e}},Jwn=n=>{const{pn:e,p:t}=n;return e===1?{x:-t/2,y:0}:{x:t/2,y:0}},eSn=n=>{const e=[];for(let t=1;t<=n.num_pins;t++){const{x:i,y:r}=Jwn({pn:t,p:Number.parseFloat(n.p)});e.push(zr(t,i,r,Number.parseFloat(n.pl),Number.parseFloat(n.pw)))}return e},tSn=Se({fn:R(),num_pins:pe(2).default(2),w:R().default("1.80mm"),h:R().default("1.00mm"),pl:R().default("0.66mm"),pw:R().default("0.5mm"),p:R().default("0.8mm")}),nSn=n=>{const e=tSn.parse(n),t=Fo(0,_t.parse(e.h),.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:_t.parse(e.p)/2,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2-.1,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2-.1,y:-_t.parse(e.h)/2},{x:_t.parse(e.p)/2,y:-_t.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:rSn(e).concat(i,t),parameters:e}},iSn=n=>{const{pn:e,p:t}=n;return e===1?{x:-t/2,y:0}:{x:t/2,y:0}},rSn=n=>{const e=[];for(let t=1;t<=n.num_pins;t++){const{x:i,y:r}=iSn({pn:t,p:Number.parseFloat(n.p)});e.push(zr(t,i,r,Number.parseFloat(n.pl),Number.parseFloat(n.pw)))}return e},oSn=Se({fn:R(),num_pins:pe(2).default(2),w:R().default("6.2mm"),h:R().default("3.4mm"),pl:R().default("1.4mm"),pw:R().default("2.1mm"),p:R().default("4.4mm")}),sSn=n=>{const e=oSn.parse(n),t=Fo(0,_t.parse(e.h)/2+.4,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:_t.parse(e.p)/2,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2-.2,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2-.2,y:-_t.parse(e.h)/2},{x:_t.parse(e.p)/2,y:-_t.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:cSn(e).concat(i,t),parameters:e}},aSn=n=>{const{pn:e,p:t}=n;return e===1?{x:-t/2,y:0}:{x:t/2,y:0}},cSn=n=>{const e=[];for(let t=1;t<=n.num_pins;t++){const{x:i,y:r}=aSn({pn:t,p:Number.parseFloat(n.p)});e.push(zr(t,i,r,Number.parseFloat(n.pl),Number.parseFloat(n.pw)))}return e},lSn=Se({fn:R(),num_pins:Bn([pe(3),pe(5)]).default(3),w:R().default("4.80mm"),h:R().default("4.80mm"),pl:R().default("1.3mm"),pw:R().default("0.9mm"),p:R().default("1.5mm"),string:R().optional()}),uSn=n=>{const e=[],t=Number.parseFloat(n.p),i=Number.parseFloat(n.pw),r=Number.parseFloat(n.w),o=Number.parseFloat(n.pl);e.push(zr(1,-r/2,t,o,i),zr(2,-r/2+(1.5-1.3)/2,0,1.5,i),zr(3,-r/2,-t,o,i));const s=Fo(0,0,.3),a=Number.parseFloat(n.w)/2-1,c=Number.parseFloat(n.h)/2,l={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-a,y:c},{x:a,y:c},{x:a,y:c/2+.5}],type:"pcb_silkscreen_path",stroke_width:.1},u={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_2",route:[{x:-a,y:-c},{x:a,y:-c},{x:a,y:-c/2-.5}],type:"pcb_silkscreen_path",stroke_width:.1};return[...e,l,u,s]},dSn=n=>{const e=[];Number.parseFloat(n.p),Number.parseFloat(n.pw),Number.parseFloat(n.w),e.push(zr(1,-1.85,-1.5,1.5,.7),zr(2,-1.85,1.5,1.5,.7),zr(3,0,0,.8,2),zr(4,1.85,-1.5,1.5,.7),zr(5,1.85,1.5,1.5,.7));const t=Fo(0,Number.parseFloat(n.h)/2+.5,.3),i=Number.parseFloat(n.w)/2-1,r=Number.parseFloat(n.h)/2,o={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-i,y:r},{x:i,y:r}],type:"pcb_silkscreen_path",stroke_width:.1},s={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_2",route:[{x:-i,y:-r},{x:i,y:-r}],type:"pcb_silkscreen_path",stroke_width:.1};return[...e,o,s,t]},hSn=n=>{const e=n.string?.match(/^sot89_(\d+)/),t=e?Number.parseInt(e[1],10):3,i=lSn.parse({...n,num_pins:t});if(i.num_pins===3)return{circuitJson:uSn(i),parameters:i};if(i.num_pins===5)return{circuitJson:dSn(i),parameters:i};throw new Error("Invalid number of pins for SOT89")},pSn=Se({fn:R(),p:_t.optional().default("5.0mm"),id:_t.optional().default("1.0mm"),od:_t.optional().default("1.9mm"),w:_t.optional().default("13mm"),h:_t.optional().default("7mm"),num_pins:Pe().optional(),string:R().optional()}),fSn=n=>{const e=pSn.parse(n),{fn:t,id:i,od:r,w:o,h:s,string:a}=e,c=Number.parseInt(a?.split("_")[1]??"3"),l=-1,u=o/2,d=s/2,h=2.5,p=o*.4,m=Math.max(h,p/(c-1)),_=Array.from({length:c},(N,A)=>{const I=c%2===0?(A-c/2+.5)*m:(A-Math.floor(c/2))*m;return Ia(A+1,I,l,i,r)}),g={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-u,y:-d},{x:u,y:-d},{x:u,y:d},{x:-u,y:d},{x:-u,y:-d}],stroke_width:.1,pcb_silkscreen_path_id:""},x=-d+2*s/3,b={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-u,y:x},{x:u,y:x}],stroke_width:.1,pcb_silkscreen_path_id:""},w=[{type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-o/6,y:x},{x:-o/6,y:d}],stroke_width:.1,pcb_silkscreen_path_id:""},{type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:o/6,y:x},{x:o/6,y:d}],stroke_width:.1,pcb_silkscreen_path_id:""}],E=Fo(0,s/2+.6,.5);return{circuitJson:[..._,g,b,...w,E],parameters:{...e,p:m}}},mSn=Se({fn:R(),num_pins:pe(2).default(2),w:R().default("5.40mm"),h:R().default("2.30mm"),pl:R().default("1.30mm"),pw:R().default("1.70mm"),p:R().default("3.5mm")}),_Sn=n=>{const e=mSn.parse(n),t=Fo(0,_t.parse(e.h)/2+.4,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:_t.parse(e.p)/2,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2,y:-_t.parse(e.h)/2},{x:_t.parse(e.p)/2,y:-_t.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:gSn(e).concat(i,t),parameters:e}},ySn=n=>{const{pn:e,p:t}=n;return e===1?{x:-t/2,y:0}:{x:t/2,y:0}},gSn=n=>{const e=[];for(let t=1;t<=n.num_pins;t++){const{x:i,y:r}=ySn({pn:t,p:Number.parseFloat(n.p)});e.push(zr(t,i,r,Number.parseFloat(n.pl),Number.parseFloat(n.pw)))}return e},xSn=Se({fn:R(),num_pins:pe(2).default(2),w:R().default("1.90mm"),h:R().default("1.33mm"),pl:R().default("0.5mm"),pw:R().default("0.7mm"),p:R().default("0.8mm")}),bSn=n=>{const e=xSn.parse(n),t=Fo(0,_t.parse(e.h)+.1,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:_t.parse(e.p)/2+.1,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2,y:-_t.parse(e.h)/2},{x:_t.parse(e.p)/2+.1,y:-_t.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:wSn(e).concat(i,t),parameters:e}},vSn=n=>{const{pn:e,p:t}=n;return e===1?{x:-t/2,y:0}:{x:t/2,y:0}},wSn=n=>{const e=[];for(let t=1;t<=n.num_pins;t++){const{x:i,y:r}=vSn({pn:t,p:Number.parseFloat(n.p)});e.push(zr(t,i,r,Number.parseFloat(n.pl),Number.parseFloat(n.pw)))}return e},SSn=Se({fn:R(),num_pins:pe(2).default(2),w:R().default("7.0mm"),h:R().default("3.35mm"),pl:R().default("1.50mm"),pw:R().default("2.70mm"),p:R().default("4.8mm")}),ESn=n=>{const e=SSn.parse(n),t=Fo(0,_t.parse(e.h),.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:_t.parse(e.p)/2,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2,y:-_t.parse(e.h)/2},{x:_t.parse(e.p)/2,y:-_t.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:MSn(e).concat(i,t),parameters:e}},TSn=n=>{const{pn:e,p:t}=n;return e===1?{x:-t/2,y:0}:{x:t/2,y:0}},MSn=n=>{const e=[];for(let t=1;t<=n.num_pins;t++){const{x:i,y:r}=TSn({pn:t,p:Number.parseFloat(n.p)});e.push(zr(t,i,r,Number.parseFloat(n.pl),Number.parseFloat(n.pw)))}return e},CSn=Se({fn:R(),num_pins:pe(2).default(2),w:R().default("3.0mm"),h:R().default("1.80mm"),pl:R().default("0.80mm"),pw:R().default("1.20mm"),p:R().default("1.6mm")}),ASn=n=>{const e=CSn.parse(n),t=Fo(0,_t.parse(e.h),.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:_t.parse(e.p)/2,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2-.1,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2-.1,y:-_t.parse(e.h)/2},{x:_t.parse(e.p)/2,y:-_t.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:RSn(e).concat(i,t),parameters:e}},PSn=n=>{const{pn:e,p:t}=n;return e===1?{x:-t/2,y:0}:{x:t/2,y:0}},RSn=n=>{const e=[];for(let t=1;t<=n.num_pins;t++){const{x:i,y:r}=PSn({pn:t,p:Number.parseFloat(n.p)});e.push(zr(t,i,r,Number.parseFloat(n.pl),Number.parseFloat(n.pw)))}return e},ISn=Se({fn:R(),num_pins:pe(2).default(2),w:R().default("7.10mm"),h:R().default("3.40mm"),pl:R().default("2.45mm"),pw:R().default("1.80mm"),p:R().default("4.05mm")}),NSn=n=>{const e=ISn.parse(n),t=Fo(0,_t.parse(e.h)/2+.5,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:_t.parse(e.p)/2,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2-.5,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2-.5,y:-_t.parse(e.h)/2},{x:_t.parse(e.p)/2,y:-_t.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:OSn(e).concat(i,t),parameters:e}},kSn=n=>{const{pn:e,p:t}=n;return e===1?{x:-t/2,y:0}:{x:t/2,y:0}},OSn=n=>{const e=[];for(let t=1;t<=n.num_pins;t++){const{x:i,y:r}=kSn({pn:t,p:Number.parseFloat(n.p)});e.push(zr(t,i,r,Number.parseFloat(n.pl),Number.parseFloat(n.pw)))}return e},LSn=Se({fn:R(),num_pins:pe(2).default(2),w:R().default("4.80mm"),h:R().default("2.10mm"),pl:R().default("1.30mm"),pw:R().default("1.40mm"),p:R().default("2.9mm")}),DSn=n=>{const e=LSn.parse(n),t=Fo(0,_t.parse(e.h)-.5,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:_t.parse(e.p)/2,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2,y:-_t.parse(e.h)/2},{x:_t.parse(e.p)/2,y:-_t.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:$Sn(e).concat(i,t),parameters:e}},zSn=n=>{const{pn:e,p:t}=n;return e===1?{x:-t/2,y:0}:{x:t/2,y:0}},$Sn=n=>{const e=[];for(let t=1;t<=n.num_pins;t++){const{x:i,y:r}=zSn({pn:t,p:Number.parseFloat(n.p)});e.push(zr(t,i,r,Number.parseFloat(n.pl),Number.parseFloat(n.pw)))}return e},FSn=Se({fn:R(),num_pins:pe(2).default(2),w:R().default("7.30mm"),h:R().default("4.40mm"),pl:R().default("2.50mm"),pw:R().default("2.30mm"),p:R().default("4.30mm")}),USn=n=>{const e=FSn.parse(n),t=Fo(0,_t.parse(e.h)/2+.5,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:_t.parse(e.p)/2,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2-.1,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2-.1,y:-_t.parse(e.h)/2},{x:_t.parse(e.p)/2,y:-_t.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:jSn(e).concat(i,t),parameters:e}},BSn=n=>{const{pn:e,p:t}=n;return e===1?{x:-t/2,y:0}:{x:t/2,y:0}},jSn=n=>{const e=[];for(let t=1;t<=n.num_pins;t++){const{x:i,y:r}=BSn({pn:t,p:Number.parseFloat(n.p)});e.push(zr(t,i,r,Number.parseFloat(n.pl),Number.parseFloat(n.pw)))}return e},HSn=Se({fn:R(),num_pins:pe(2).default(2),w:R().default("10.70mm"),h:R().default("6.60mm"),pl:R().default("3.30mm"),pw:R().default("2.50mm"),p:R().default("6.80mm")}),VSn=n=>{const e=HSn.parse(n),t=Fo(0,3,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:_t.parse(e.p)/2,y:_t.parse(e.h)/2-.8},{x:-_t.parse(e.w)/2-.8,y:_t.parse(e.h)/2-.8},{x:-_t.parse(e.w)/2-.8,y:-_t.parse(e.h)/2+.8},{x:_t.parse(e.p)/2,y:-_t.parse(e.h)/2+.8}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:YSn(e).concat(i,t),parameters:e}},GSn=n=>{const{pn:e,p:t}=n;return e===1?{x:-t/2,y:0}:{x:t/2,y:0}},YSn=n=>{const e=[];for(let t=1;t<=n.num_pins;t++){const{x:i,y:r}=GSn({pn:t,p:Number.parseFloat(n.p)});e.push(zr(t,i,r,Number.parseFloat(n.pl),Number.parseFloat(n.pw)))}return e},qSn=Se({fn:R(),num_pins:Pe().default(4),w:R().default("8.50mm"),h:R().default("6.90mm"),pl:R().default("2mm"),pw:R().default("1.5mm"),p:R().default("2.30mm"),string:R().optional()}),XSn=n=>{const e=n.string?.match(/^sot223_(\d+)/),t=e?Number.parseInt(e[1],10):4;if(t===8){const r=ZSn.parse({...n,num_pins:t});return{circuitJson:H5(r),parameters:r}}const i=qSn.parse({...n,num_pins:t});if(i.num_pins===4)return{circuitJson:KSn(i),parameters:i};if(i.num_pins===5)return{circuitJson:JSn(i),parameters:i};if(i.num_pins===6)return{circuitJson:t2n(i),parameters:i};throw new Error("Invalid number of pins")},WSn=n=>{const{pn:e,w:t,p:i}=n;return e===1?{x:-t/2+1.1,y:i}:e===2?{x:-t/2+1.1,y:0}:e===3?{x:-t/2+1.1,y:-i}:{x:t/2-1.1,y:0}},KSn=n=>{const e=[];for(let a=0;a<n.num_pins;a++){const{x:c,y:l}=WSn({num_pins:n.num_pins,pn:a+1,w:Number.parseFloat(n.w),h:Number.parseFloat(n.h),pl:Number.parseFloat(n.pl),p:Number.parseFloat(n.p)}),u=a===3?3.8:Number.parseFloat(n.pw);e.push(zr(a+1,c,l,Number.parseFloat(n.pl),u))}const t=Fo(0,0,.3),i=Number.parseFloat(n.w)/2-2.4,r=Number.parseFloat(n.h)/2,o={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-i,y:r},{x:i,y:r},{x:i,y:r/2+.5}],type:"pcb_silkscreen_path",stroke_width:.1},s={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_2",route:[{x:-i,y:-r},{x:i,y:-r},{x:i,y:-r/2-.5}],type:"pcb_silkscreen_path",stroke_width:.1};return[...e,o,s,t]},ZSn=X2({p:"0.90mm",w:"2.8mm",legsoutside:!0}),QSn=n=>{const{p:e,pn:t,w:i}=n;if(t===1)return{x:-i/2+1.2,y:e/2+e};if(t===2)return{x:-i/2+1.2,y:e/2};if(t===3)return{x:-i/2+1.2,y:-e/2};if(t===4)return{x:-i/2+1.2,y:-e/2-e};if(t===5)return{x:i/2-1,y:0};throw new Error("Invalid pin number")},JSn=n=>{const e=[];for(let a=1;a<=n.num_pins;a++){const{x:c,y:l}=QSn({h:Number.parseFloat(n.h),p:1.5,pn:a,w:Number.parseFloat(n.w)});let u=Number.parseFloat(n.pw),d=Number.parseFloat(n.pl);a===5?(u=3.4,d=1.8):(u=1,d=2.2),e.push(zr(a,c,l,d,u))}const t=Number.parseFloat(n.w)/2-2.4,i=Number.parseFloat(n.h)/2,r={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-t,y:i},{x:t,y:i},{x:t,y:i/2+.5}],type:"pcb_silkscreen_path",stroke_width:.1},o={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_2",route:[{x:-t,y:-i},{x:t,y:-i},{x:t,y:-i/2-.5}],type:"pcb_silkscreen_path",stroke_width:.1},s=Fo(0,0,.3);return[...e,r,o,s]},e2n=n=>{const{p:e,pn:t,w:i}=n;if(t===1)return{x:-i/2+1.2,y:2*e};if(t===2)return{x:-i/2+1.2,y:e};if(t===3)return{x:-i/2+1.2,y:0};if(t===4)return{x:-i/2+1.2,y:-e};if(t===5)return{x:-i/2+1.2,y:-2*e};if(t===6)return{x:i/2-1.175,y:0};throw new Error("Invalid pin number")},t2n=n=>{const e=[];for(let a=1;a<=n.num_pins;a++){const{x:c,y:l}=e2n({h:Number.parseFloat(n.h),p:1.3,pn:a,w:8.7});let u=Number.parseFloat(n.pw),d=Number.parseFloat(n.pl);a===6?(u=3.4,d=2.15):(u=.6,d=2.2),e.push(zr(a,c,l,d,u))}const t=Number.parseFloat(n.w)/2-2.4,i=Number.parseFloat(n.h)/2,r={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-t,y:i},{x:t,y:i},{x:t,y:i/2+.5}],type:"pcb_silkscreen_path",stroke_width:.1},o={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_2",route:[{x:-t,y:-i},{x:t,y:-i},{x:t,y:-i/2-.5}],type:"pcb_silkscreen_path",stroke_width:.1},s=Fo(0,0,.3);return[...e,r,o,s]},n2n=Se({fn:R(),num_pins:Pe().default(3),w:R().default("3.40mm"),h:R().default("3.30mm"),pl:R().default("1mm"),pw:R().default("0.7mm"),p:R().default("1.2mm"),string:R().optional()}),i2n=n=>{const e=n.string?.match(/^sot23w_(\d+)/),t=e?Number.parseInt(e[1],3):3,i=n2n.parse({...n,num_pins:t});if(i.num_pins===3)return{circuitJson:o2n(i),parameters:i};throw new Error("Invalid number of pins")},r2n=n=>{const{pn:e,p:t}=n;return e===1?{x:-t,y:.95}:e===2?{x:-t,y:-.95}:{x:t,y:0}},o2n=n=>{const e=[];for(let a=0;a<n.num_pins;a++){const{x:c,y:l}=r2n({num_pins:n.num_pins,pn:a+1,w:Number.parseFloat(n.w),h:Number.parseFloat(n.h),pl:Number.parseFloat(n.pl),p:Number.parseFloat(n.p)});e.push(zr(a+1,c,l,Number.parseFloat(n.pl),Number.parseFloat(n.pw)))}const t=Fo(0,Number.parseInt(n.h)/2+1,.3),i=Number.parseFloat(n.w)/2-1,r=Number.parseFloat(n.h)/2,o={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-i,y:r},{x:i+.3,y:r},{x:i+.3,y:r/2}],type:"pcb_silkscreen_path",stroke_width:.1},s={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_2",route:[{x:-i,y:-r},{x:i+.3,y:-r},{x:i+.3,y:-r/2}],type:"pcb_silkscreen_path",stroke_width:.1};return[...e,o,s,t]},s2n=Se({fn:R(),num_pins:Bn([pe(3),pe(2)]).default(3),p:R().default("1.27mm"),id:R().default("0.72mm"),od:R().default("0.95mm"),w:R().default("2.5mm"),h:R().default("4.2mm"),string:R().optional()}),a2n=n=>{const{p:e,id:t,od:i,w:r,h:o}=n,s=Number.parseFloat(o)/2,a=Number.parseFloat(e);return[Ia(1,-a,s-a,t,i),Ia(2,0,s-a,t,i),Ia(3,a,s-a,t,i)]},c2n=n=>{const{p:e,id:t,od:i,h:r}=n,o=Number.parseFloat(r)/2,s=Number.parseFloat(e);return[Ia(1,-s,o-s,t,i),Ia(2,s,o-s,t,i)]},l2n=n=>{const e=n.string?.match(/^to92s_(\d+)/),t=e?Number.parseInt(e[1],10):3,i=s2n.parse({...n,num_pins:t});let r=[];if(i.num_pins===3)r=a2n(i);else if(i.num_pins===2)r=c2n(i);else throw new Error("Invalid number of pins for TO-92");const o=Number.parseFloat(i.h)/2,s=Number.parseFloat(i.p),a={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-o,y:o-s},{x:-1.9,y:0},{x:1.9,y:0},{x:o,y:o-s},{x:1.5,y:Number.parseFloat(i.h)/2+.5},{x:-1.5,y:Number.parseFloat(i.h)/2+.5},{x:-o,y:o-s}],stroke_width:.1,pcb_silkscreen_path_id:""},c=Fo(0,o+1,.5);return{circuitJson:[...r,a,c],parameters:i}},u2n=Se({fn:R(),p:_t.optional(),id:_t.optional(),pw:_t.optional(),pl:_t.optional(),w:_t.optional(),h:_t.optional(),sh:Bn([Je(),R(),Pe()]).optional().transform(n=>{if(typeof n=="string"){const e=Number(n);return Number.isNaN(e)?!0:e}return n}).describe('JST SH (Surface-mount) connector family. SH stands for "Super High-density".'),ph:Je().optional().describe('JST PH (Through-hole) connector family. PH stands for "Pin Header".'),string:R().optional()}),d2n={ph:{p:_t.parse("2.2mm"),id:_t.parse("0.70mm"),pw:_t.parse("1.20mm"),pl:_t.parse("1.20mm"),w:_t.parse("6mm"),h:_t.parse("5mm")},sh:{p:_t.parse("1mm"),pw:_t.parse("0.6mm"),pl:_t.parse("1.55mm"),w:_t.parse("5.8mm"),h:_t.parse("7.8mm")}};function h2n(n){return n.sh?"sh":(n.ph,"ph")}function p2n(n,e,t,i,r,o){const s=[];if(n==="ph"){const a=t/2;s.push(oV(1,-a,2,i,r,o)),s.push(oV(2,a,2,i,r,o))}else{const a=-((e-1)/2)*t;for(let l=0;l<e;l++){const u=a+l*t;console.log("x si",u),s.push(zr(l+1,u,-1.325,r,o))}const c=(e-1)/2*t+1.3;console.log("offset",c),s.push(zr(e+1,-c,1.22,1.2,1.8)),s.push(zr(e+2,c,1.22,1.2,1.8))}return s}function f2n(n,e,t){return n==="ph"?{type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-3,y:3},{x:3,y:3},{x:3,y:-2},{x:-3,y:-2},{x:-3,y:3}],stroke_width:.1,pcb_silkscreen_path_id:""}:{type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[],stroke_width:.1,pcb_silkscreen_path_id:""}}var m2n=n=>{const e=u2n.parse(n),t=h2n(e),i=d2n[t],r=e.p??i.p,o=e.id??i.id,s=e.pw??i.pw,a=e.pl??i.pl,c=e.w??i.w,l=e.h??i.h;let u=t==="sh"?4:2;if(t==="sh"){const _=(typeof n.string=="string"?n.string:"").match(/sh(\d+)/);if(_&&_[1]){const g=parseInt(_[1],10);Number.isNaN(g)||(u=g)}else typeof e.sh=="number"&&(u=e.sh)}const d=p2n(t,u,r,o,s,a),h=f2n(t),p=Fo(0,l/2+1,.5);return{circuitJson:[...d,h,p],parameters:{...e,p:r,id:o,pw:s,pl:a,w:c,h:l,num_pins:u,sh:t==="sh",ph:t==="ph"}}},_2n=Se({fn:R(),num_pins:pe(2).default(2),w:R().default("3.30mm"),h:R().default("1.70mm"),pl:R().default("0.80mm"),pw:R().default("1mm"),p:R().default("1.90mm")}),y2n=n=>{const e=_2n.parse(n),t=Fo(0,_t.parse(e.h)/2+.5,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:_t.parse(e.p)/2,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2,y:-_t.parse(e.h)/2},{x:_t.parse(e.p)/2,y:-_t.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:x2n(e).concat(i,t),parameters:e}},g2n=n=>{const{pn:e,p:t}=n;return e===1?{x:-t/2,y:0}:{x:t/2,y:0}},x2n=n=>{const e=[];for(let t=1;t<=n.num_pins;t++){const{x:i,y:r}=g2n({pn:t,p:Number.parseFloat(n.p)});e.push(zr(t,i,r,Number.parseFloat(n.pl),Number.parseFloat(n.pw)))}return e},b2n=n=>{switch(n){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"}}},v2n=Se({fn:R(),num_pins:Bn([pe(8),pe(10)]).default(8),w:R().optional(),h:R().optional(),p:R().optional(),pl:R().optional(),pw:R().optional(),string:R().optional()}),w2n=n=>{const e=v2n.parse(n),t=b2n(e.num_pins),i=_t.parse(e.w||t.w),r=_t.parse(e.h||t.h),o=_t.parse(e.p||t.p),s=_t.parse(e.pl||t.pl),a=_t.parse(e.pw||t.pw),c=[],l=e.num_pins/2;for(let b=0;b<e.num_pins;b++){const{x:w,y:E}=net(e.num_pins,b+1,i,o),N=b<l?b+1:e.num_pins-(b-l);c.push(zr(N,w,E,s,a))}const u=i,d=r,h={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-u/2,y:d/2},{x:u/2,y:d/2}],stroke_width:.05,pcb_silkscreen_path_id:""},p={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-u/2,y:-d/2},{x:u/2,y:-d/2}],stroke_width:.05,pcb_silkscreen_path_id:""},m=net(e.num_pins,1,u,o),_={x:m.x-.8,y:m.y},g={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"pin_marker_1",route:[{x:_.x-.4,y:_.y},{x:_.x-.7,y:_.y+.3},{x:_.x-.7,y:_.y-.3},{x:_.x-.4,y:_.y}],stroke_width:.05,pcb_silkscreen_path_id:"pin_marker_1"},x=Fo(0,d/2+.5,.3);return{circuitJson:[...c,h,p,x,g],parameters:e}},net=(n,e,t,i)=>{const r=n/2,o=(e-1)%r,s=e<=r?-1:1,a=(r-1)/2-o;return{x:s*_t.parse(n===8?"1.8mm":"2.2mm"),y:a*i}},S2n=n=>{switch(n){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"}}},E2n=Se({fn:R(),num_pins:Bn([pe(8),pe(10),pe(12),pe(16)]).default(8),w:R().optional(),h:R().optional(),p:R().optional(),pl:R().optional(),pw:R().optional(),string:R().optional()}),iet=(n,e,t,i)=>{const r=n/2,o=(e-1)%r,s=e<=r?-1:1,a=(r-1)/2-o;return{x:s*_t.parse("2mm"),y:a*i}},T2n=n=>{const e=E2n.parse(n),t=S2n(e.num_pins),i=_t.parse(e.w||t.w),r=_t.parse(e.h||t.h),o=_t.parse(e.p||t.p),s=_t.parse(e.pl||t.pl),a=_t.parse(e.pw||t.pw),c=[];for(let x=0;x<e.num_pins;x++){const{x:b,y:w}=iet(e.num_pins,x+1,i,o);c.push(zr(x+1,b,w,s,a))}const l=i,u=r,d={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-l/2,y:u/2},{x:l/2,y:u/2}],stroke_width:.05,pcb_silkscreen_path_id:""},h={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-l/2,y:-u/2},{x:l/2,y:-u/2}],stroke_width:.05,pcb_silkscreen_path_id:""},p=iet(e.num_pins,1,l,o),m={x:p.x-.8,y:p.y},_={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"pin_marker_1",route:[{x:m.x-.4,y:m.y},{x:m.x-.7,y:m.y+.3},{x:m.x-.7,y:m.y-.3},{x:m.x-.4,y:m.y}],stroke_width:.05,pcb_silkscreen_path_id:"pin_marker_1"},g=Fo(0,u/2+.5,.3);return{circuitJson:[...c,d,h,g,_],parameters:e}},M2n=Se({fn:R(),num_pins:pe(2).default(2),w:R().default("3.8mm"),h:R().default("1.65mm"),pl:R().default("1.2mm"),pw:R().default("1.2mm"),pad_spacing:R().default("2.6mm")}),C2n=n=>{const e=M2n.parse(n),t=Fo(0,_t.parse(e.h),.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:_t.parse(e.pad_spacing)/2,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2-.2,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2-.2,y:-_t.parse(e.h)/2},{x:_t.parse(e.pad_spacing)/2,y:-_t.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:P2n(e).concat(i,t),parameters:e}},A2n=n=>{const{pn:e,pad_spacing:t}=n;return e===1?{x:-t/2,y:0}:{x:t/2,y:0}},P2n=n=>{const e=[];for(let t=1;t<=n.num_pins;t++){const{x:i,y:r}=A2n({pn:t,pad_spacing:Number.parseFloat(n.pad_spacing)});e.push(zr(t,i,r,Number.parseFloat(n.pl),Number.parseFloat(n.pw)))}return e},R2n=Se({fn:R(),num_pins:pe(2).default(2),w:R().default("3.20mm"),h:R().default("1.65mm"),pl:R().default("0.8mm"),pw:R().default("0.9mm"),pad_spacing:R().default("2.1mm")}),I2n=n=>{const e=R2n.parse(n),t=Fo(0,_t.parse(e.h),.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:_t.parse(e.pad_spacing)/2,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2-.2,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2-.2,y:-_t.parse(e.h)/2},{x:_t.parse(e.pad_spacing)/2,y:-_t.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:k2n(e).concat(i,t),parameters:e}},N2n=n=>{const{pn:e,pad_spacing:t}=n;return e===1?{x:-t/2,y:0}:{x:t/2,y:0}},k2n=n=>{const e=[];for(let t=1;t<=n.num_pins;t++){const{x:i,y:r}=N2n({pn:t,pad_spacing:Number.parseFloat(n.pad_spacing)});e.push(zr(t,i,r,Number.parseFloat(n.pl),Number.parseFloat(n.pw)))}return e},O2n=Se({fn:R(),num_pins:Bn([pe(6),pe(8)]).default(8),w:R().default("3mm"),h:R().default("3mm"),p:R().default("0.5mm"),pl:R().default("0.52mm"),pw:R().default("0.35mm"),epw:R().default("1.40mm"),eph:R().default("1.60mm"),string:R().optional(),ep:Je().default(!1)}),L2n=n=>{n.string&&n.string.includes("_ep")&&(n.ep=!0);const e=n.string?.match(/^son_(\d+)/),t=e?Number.parseInt(e[1],10):n.num_pins||8,i=O2n.parse({...n,num_pins:t}),r=_t.parse(i.w),o=_t.parse(i.h),s=_t.parse(i.p),a=_t.parse(i.pl),c=_t.parse(i.pw),l=_t.parse(i.epw),u=_t.parse(i.eph),d=[];for(let E=0;E<i.num_pins;E++){const{x:N,y:A}=ret(i.num_pins,E+1,r,s);d.push(zr(E+1,N,A,a,c))}i.ep&&d.push(zr(i.num_pins+1,0,0,l,u));const h=r,p=o,m={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-h/2,y:p/2},{x:h/2,y:p/2}],stroke_width:.05,pcb_silkscreen_path_id:""},_={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-h/2,y:-p/2},{x:h/2,y:-p/2}],stroke_width:.05,pcb_silkscreen_path_id:""},g=ret(i.num_pins,1,h,s),x={x:g.x-.4,y:g.y},b={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"pin_marker_1",route:[{x:x.x-.4,y:x.y},{x:x.x-.7,y:x.y+.3},{x:x.x-.7,y:x.y-.3},{x:x.x-.4,y:x.y}],stroke_width:.05,pcb_silkscreen_path_id:"pin_marker_1"},w=Fo(0,p/2+.5,.3);return{circuitJson:[...d,m,_,w,b],parameters:i}},ret=(n,e,t,i)=>{const r=n/2,o=(e-1)%r,s=e<=r?-1:1,a=(r-1)/2-o;return{x:s*_t.parse("1.4mm"),y:a*i}},D2n=n=>{const{num_pins:e,bridged:t,p:i=2.54,pw:r=1.5,ph:o=1.5}=n,s=_t.parse(i),a=_t.parse(r),c=_t.parse(o),l=Math.min(c/4,.5),u=[];for(let E=0;E<e;E++)u.push(zr(E+1,E*s,0,a,c));let d=[];if(t){const E=t.split("").map(Number);if(E.length>1)for(let N=0;N<E.length-1;N++){const A=E[N],I=E[N+1];if(typeof A=="number"&&typeof I=="number"&&!isNaN(A)&&!isNaN(I)){const M=(A-1)*s,k=(I-1)*s,C=Math.sign(k-M),U=M+C*(a/2),O=k-C*(a/2);d.push({type:"pcb_trace",pcb_trace_id:"",route:[{start_pcb_port_id:`{PIN${A}}`,x:U,y:0,width:l,layer:"top",route_type:"wire"},{end_pcb_port_id:`{PIN${I}}`,x:O,y:0,width:l,layer:"top",route_type:"wire"}]})}}}const h=(e-1)*s+a+.7,p=c+1,m=(e-1)*s/2,_=0,g={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"outline",route:[{x:m-h/2,y:_-p/2},{x:m+h/2,y:_-p/2},{x:m+h/2,y:_+p/2},{x:m-h/2,y:_+p/2},{x:m-h/2,y:_-p/2}],stroke_width:.15},b=_+p/2+.6,w=Fo(m,b,.4);return{circuitJson:[...u,...d,g,w],parameters:n}},oet={fn:pe("sot457"),num_pins:pe(6).default(6),pillh:R().default("0.45mm"),pillw:R().default("1.45mm"),pl:R(),pw:R(),p:R(),wave:Je().optional(),reflow:Je().optional()},z2n=Se({...oet,h:R().default("2.5mm"),w:R().default("2.7mm"),pl:R().default("0.8mm"),pw:R().default("0.55mm"),p:R().default("0.95mm")}),$2n=Se({...oet,h:R().default("3mm"),w:R().default("4mm"),pillr:R().default("0.225mm"),pl:R().default("1.45mm"),pw:R().default("1.5mm"),p:R().default("1.475mm")}).transform(n=>({...n,wave:n.wave??(n.reflow===void 0?!0:!n.reflow),reflow:n.reflow??(n.wave===void 0?!1:!n.wave)})),V5=n=>Number.parseFloat(n.replace("mm","")),set=({pitch:n,width:e,pinNumber:t})=>{const o={1:{x:-e/2-.1,y:n},2:{x:-e/2-.1,y:0},3:{x:-e/2-.1,y:-n},4:{x:e/2+.1,y:-n},5:{x:e/2+.1,y:0},6:{x:e/2+.1,y:n}}[t];if(!o)throw new Error(`Invalid pin number: ${t}`);return o},aet=n=>{const e=[],t=V5(n.p),i=V5(n.pl),r=V5(n.pw),o=V5(n.w),s=V5(n.h);if(n.wave){const m={1:({padWidth:_,padHeight:g})=>zr(1,-t,t,g,_),2:({padWidth:_,padHeight:g})=>zr(2,-t,-t,g,_),3:({padWidth:_,padHeight:g})=>rV(3,-t,0,V5(n.pillw),V5(n.pillh)),4:({padWidth:_,padHeight:g})=>rV(4,t,0,V5(n.pillw),V5(n.pillh)),5:({padWidth:_,padHeight:g})=>zr(5,t,t,g,_),6:({padWidth:_,padHeight:g})=>zr(6,t,-t,g,_)};for(let _=1;_<=n.num_pins;_++){const g=m[_];g&&e.push(g({padWidth:i,padHeight:r}))}}else for(let m=1;m<=n.num_pins;m++){const{x:_,y:g}=set({pitch:t,width:o,pinNumber:m});e.push(zr(m,_,g,i,r))}const a={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-o/3,y:s/2+t/1.3},{x:o/3,y:s/2+t/1.3}],stroke_width:.05},c={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_2",route:[{x:-o/3,y:-s/2-t/1.3},{x:o/3,y:-s/2-t/1.3}],stroke_width:.05},l=Fo(0,s+.5,.3),u=set({pitch:t,width:o,pinNumber:1}),d=n.wave?1:.5,h=n.wave?.7:.3;u.x-=n.wave?r:r*1.7;const p={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"pin1_indicator",route:[{x:u.x+d/2,y:u.y},{x:u.x-d/2,y:u.y+h/2},{x:u.x-d/2,y:u.y-h/2},{x:u.x+d/2,y:u.y}],stroke_width:.05};return[l,a,c,p,...e]},F2n=n=>{if(n.wave){const t=$2n.parse({...n,fn:"sot457"});return{circuitJson:aet(t),parameters:t}}const e=z2n.parse(n);return{circuitJson:aet(e),parameters:e}},U2n=Se({fn:R(),num_pins:Bn([pe(3),pe(2)]).default(3),p:R().default("3.8mm"),id:R().default("1.25mm"),od:R().default("2.35mm"),ca:R().default("14mm").describe("Caliper axis (width or diameter of the potentiometer body or adjustment knob)"),w:R().default("5.35mm"),h:R().default("4mm"),string:R().optional()}),B2n=n=>{const{p:e,id:t,od:i,h:r,ca:o}=n,s=Number.parseFloat(r),a=Number.parseFloat(o);return[Ia(1,0,a/4+.3,t,i),Ia(2,s,0,t,i),Ia(3,0,-a/4-.3,t,i)]},j2n=n=>{const e=n.string?.match(/^potentiometer_(\d+)/),t=e?Number.parseInt(e[1],10):3,i=U2n.parse({...n,num_pins:t});let r=[];i.num_pins===3&&(r=B2n(i));const o=Number.parseFloat(i.ca)/2+.15,s=Number.parseFloat(i.w),a=Number.parseFloat(i.od)/2+.35,c={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:0,y:o-1.75},{x:0,y:o},{x:s,y:o},{x:s,y:a}],stroke_width:.1,pcb_silkscreen_path_id:""},l={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:s,y:-a},{x:s,y:-o},{x:0,y:-o},{x:0,y:-o+1.75}],stroke_width:.1,pcb_silkscreen_path_id:""},u=Number.parseFloat(i.w)/2,d=Fo(u,o+1,.5);return{circuitJson:[...r,c,l,d],parameters:i}},H2n=Se({fn:R(),p:_t.optional().default("7.5mm"),id:_t.optional().default("1mm"),od:_t.optional().default("2mm"),d:_t.optional().default("10.5mm")}),V2n=(n,e,t,i,r)=>{const o=[],s=[];for(let a=0;a<=50;a++){const c=a/50*Math.PI,l=n+Math.cos(c)*t,u=e+Math.sin(c)*t;l<n-i&&u>=e-r/2&&u<=e+r/2||o.push({x:l,y:u})}for(let a=0;a<=50;a++){const c=Math.PI+a/50*Math.PI,l=n+Math.cos(c)*t,u=e+Math.sin(c)*t;l<n-i&&u>=e-r/2&&u<=e+r/2||s.push({x:l,y:u})}return{topArc:o,bottomArc:s}},G2n=n=>{const e=H2n.parse(n),{p:t,id:i,od:r,d:o}=e,s=[Ia(1,-t/2,0,i,r),Ia(2,t/2,0,i,r)],{topArc:a,bottomArc:c}=V2n(0,0,o/2+.1,r/2,r),l={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:a,stroke_width:.1,pcb_silkscreen_path_id:""},u={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:c,stroke_width:.1,pcb_silkscreen_path_id:""},d={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:0,y:o/2+.1},{x:0,y:-(o/2+.1)}],stroke_width:.1,pcb_silkscreen_path_id:""},h=-(o/2+.5),p=r/2+1.5,m=.5,_={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:h-m,y:p},{x:h+m,y:p}],stroke_width:.1,pcb_silkscreen_path_id:""},g={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:h,y:p-m},{x:h,y:p+m}],stroke_width:.1,pcb_silkscreen_path_id:""},x=Fo(0,o/2+1,.5);return{circuitJson:[...s,l,u,d,_,g,x],parameters:e}},Y2n=Se({fn:R(),num_pins:pe(2).default(2),w:R().default("6.5mm"),h:R().default("3mm"),pl:R().default("1.75mm"),pw:R().default("2.40mm"),p:R().default("4.75mm")}),q2n=n=>{const e=Y2n.parse(n),t=Fo(0,_t.parse(e.h)-.5,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:_t.parse(e.p)/2,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2-.3,y:_t.parse(e.h)/2},{x:-_t.parse(e.w)/2-.3,y:-_t.parse(e.h)/2},{x:_t.parse(e.p)/2,y:-_t.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:W2n(e).concat(i,t),parameters:e}},X2n=n=>{const{pn:e,p:t}=n;return e===1?{x:-t/2,y:0}:{x:t/2,y:0}},W2n=n=>{const e=[];for(let t=1;t<=n.num_pins;t++){const{x:i,y:r}=X2n({pn:t,p:Number.parseFloat(n.p)});e.push(zr(t,i,r,Number.parseFloat(n.pl),Number.parseFloat(n.pw)))}return e},K2n=Se({fn:R(),num_pins:Pe().default(3),w:R().default("2.45mm"),h:R().default("2.40mm"),pl:R().default("0.45mm"),pw:R().default("0.70mm"),p:R().default("1mm"),string:R().optional()}),Z2n=n=>{const e=n.string?.match(/^sot323_(\d+)/),t=e?Number.parseInt(e[1],3):3,i=K2n.parse({...n,num_pins:t});if(i.num_pins===3)return{circuitJson:J2n(i),parameters:i};throw new Error("Invalid number of pins")},Q2n=n=>{const{pn:e,p:t}=n;return e===1?{x:-t,y:.65}:e===2?{x:-t,y:-.65}:{x:t,y:0}},J2n=n=>{const e=[];for(let a=0;a<n.num_pins;a++){const{x:c,y:l}=Q2n({num_pins:n.num_pins,pn:a+1,w:Number.parseFloat(n.w),h:Number.parseFloat(n.h),pl:Number.parseFloat(n.pl),p:Number.parseFloat(n.p)});e.push(zr(a+1,c,l,Number.parseFloat(n.pl),Number.parseFloat(n.pw)))}const t=Fo(0,Number.parseInt(n.h)/2+1,.3),i=Number.parseFloat(n.w)/2-Number.parseFloat(n.pl),r=Number.parseFloat(n.h)/2,o={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-i,y:r+.3},{x:i,y:r+.3},{x:i,y:r/2}],type:"pcb_silkscreen_path",stroke_width:.1},s={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_2",route:[{x:-i,y:-r-.3},{x:i,y:-r-.3},{x:i,y:-r/2}],type:"pcb_silkscreen_path",stroke_width:.1};return[...e,o,s,t]},eEn=Se({fn:R(),circle:Je().optional(),rect:Je().optional(),square:Je().optional(),pill:Je().optional(),d:_t.optional(),pd:_t.optional(),diameter:_t.optional(),r:_t.optional(),pr:_t.optional(),radius:_t.optional(),w:_t.optional(),pw:_t.optional(),width:_t.optional(),h:_t.optional(),ph:_t.optional(),height:_t.optional(),s:_t.optional(),size:_t.optional(),string:R().optional()}).transform(n=>{let e="rect";n.circle&&(e="circle"),n.square&&(e="square"),n.rect&&(e="rect"),n.pill&&(e="pill");let t,i,r;return e==="circle"?n.r!==void 0?t=gh(n.r):n.pr!==void 0?t=gh(n.pr):n.radius!==void 0?t=gh(n.radius):n.d!==void 0?t=gh(n.d)/2:n.pd!==void 0?t=gh(n.pd)/2:n.diameter!==void 0?t=gh(n.diameter)/2:t=gh("1mm")/2:(n.w!==void 0?i=gh(n.w):n.pw!==void 0?i=gh(n.pw):n.width!==void 0?i=gh(n.width):n.s!==void 0?i=gh(n.s):n.size!==void 0?i=gh(n.size):i=gh("1mm"),n.h!==void 0?r=gh(n.h):n.ph!==void 0?r=gh(n.ph):n.height!==void 0?r=gh(n.height):e==="square"||e==="rect"?r=i:r=gh("1mm")),{fn:n.fn,shape:e,radius:t,width:i,height:r}}),tEn=n=>{const e=eEn.parse(n),{shape:t,radius:i,width:r,height:o}=e;let s,a;return t==="circle"?(s=VJe(1,{x:0,y:0,radius:i}),a=i+.5):t==="pill"?(s=rV(1,0,0,r,o),a=Math.max(r,o)/2+.5):(s=zr(1,0,0,r,o),a=o/2+.5),{circuitJson:[s,Fo(0,a,.2)],parameters:e}},nEn=Se({fn:R(),d:_t.optional(),hd:_t.optional(),r:_t.optional(),hr:_t.optional(),pd:_t.optional(),pr:_t.optional(),squarepad:Je().optional().default(!1)}).transform(n=>{let e;n.d!==void 0?e=gh(n.d):n.hd!==void 0?e=gh(n.hd):n.r!==void 0?e=gh(n.r)*2:n.hr!==void 0?e=gh(n.hr)*2:e=gh("1mm");let t;return n.pd!==void 0?t=gh(n.pd):n.pr!==void 0?t=gh(n.pr)*2:t=e*(1.5/1),{fn:n.fn,d:e,pd:t,squarepad:n.squarepad??!1}}),iEn=n=>{const e=nEn.parse(n),{d:t,pd:i,squarepad:r}=e;return{circuitJson:[r?oV(1,0,0,t,i,i):Ia(1,0,0,t,i),Fo(0,i/2+.5,.2)],parameters:e}},rEn=Se({fn:R(),num_pins:pe(6).default(6),h:R().default("1.6mm"),pl:R().default("1mm"),pw:R().default("0.7mm"),p:R().default("0.95mm")}),oEn=n=>{const e=rEn.parse(n);return{circuitJson:sEn(e),parameters:e}},cet=n=>{const{p:e,h:t,pn:i}=n;if(i===1)return{x:-t/2-.5,y:e};if(i===2)return{x:-t/2-.5,y:0};if(i===3)return{x:-t/2-.5,y:-e};if(i===4)return{x:t/2+.5,y:-e};if(i===5)return{x:t/2+.5,y:0};if(i===6)return{x:t/2+.5,y:e};throw new Error("Invalid pin number")},sEn=n=>{const e=[];for(let d=1;d<=n.num_pins;d++){const{x:h,y:p}=cet({h:Number.parseFloat(n.h),p:Number.parseFloat(n.p),pn:d});e.push(zr(d,h,p,Number.parseFloat(n.pl),Number.parseFloat(n.pw)))}const t=n.num_pins/2*Number.parseFloat(n.p),i=Number.parseFloat(n.h),r={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-t/3,y:i/2+Number.parseFloat(n.p)/1.3},{x:t/3,y:i/2+Number.parseFloat(n.p)/1.3}],type:"pcb_silkscreen_path",stroke_width:.05},o={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_2",route:[{x:-t/3,y:-i/2-Number.parseFloat(n.p)/1.3},{x:t/3,y:-i/2-Number.parseFloat(n.p)/1.3}],type:"pcb_silkscreen_path",stroke_width:.05},s=Fo(0,i+.3,.3),a=cet({h:Number.parseFloat(n.h),p:Number.parseFloat(n.p),pn:1});a.x=a.x-Number.parseFloat(n.pw)*1.5;const c=.7,l=.3,u={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"pin1_indicator",route:[{x:a.x+c/2,y:a.y},{x:a.x-c/2,y:a.y+l/2},{x:a.x-c/2,y:a.y-l/2},{x:a.x+c/2,y:a.y}],stroke_width:.05};return[...e,s,r,o,u]},aEn=Se({fn:R()}),cEn=n=>{const e=aEn.parse(n),t=[],i=.5-.15,r=1.5,s=.5/2,a=75,c=-37/2;for(let I=0;I<a;I++){const M=I+1;if(M>=24&&M<=31)continue;const k=c-I*s,C=M%2===0,U=r+(C?.25:0),H=.5-U/2,Y=zr(M,H,k,U,i);Y.layer=C?"bottom":"top",t.push(Y)}const l=46*.0254,u=137*.0254,d=261*.0254,h={type:"pcb_cutout",pcb_cutout_id:"",shape:"rect",center:{x:-u/2+r/2,y:c-d},width:u,height:l},p={x:-.5,y:c},m={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"};let _=1/0,g=-1/0,x=1/0,b=-1/0;const w=(I,M,k=0,C=0)=>{_=Math.min(_,I-k/2),g=Math.max(g,I+k/2),x=Math.min(x,M-C/2),b=Math.max(b,M+C/2)};for(const I of t)w(I.x,I.y,I.width,I.height);w(h.center.x,h.center.y,h.width,h.height);for(const I of m.route)w(I.x,I.y);const E=(_+g)/2,N=(x+b)/2,A=I=>{typeof I.x=="number"&&(I.x-=E),typeof I.y=="number"&&(I.y-=N),I.center&&(I.center.x-=E,I.center.y-=N),Array.isArray(I.route)&&(I.route=I.route.map(M=>({x:M.x-E,y:M.y-N})))};for(const I of t)A(I);return A(h),A(m),{circuitJson:[...t,h,m],parameters:e}};function lEn(n){return n!=null}var uEn=(n,e)=>{if(!e)return n;const t=n.filter(u=>u.type==="pcb_smtpad"||u.type==="pcb_plated_hole"||u.type==="pcb_thtpad");if(t.length===0)return n;let i=1/0,r=-1/0,o=1/0,s=-1/0;const a=(u,d,h=0,p=0)=>{const m=u-h/2,_=u+h/2,g=d-p/2,x=d+p/2;i=Math.min(i,m),r=Math.max(r,_),o=Math.min(o,g),s=Math.max(s,x)};for(const u of t)if(u.type==="pcb_smtpad"){const d=u.shape==="circle"?u.radius*2:u.width,h=u.shape==="circle"?u.radius*2:u.height;a(u.x,u.y,d,h)}else if(u.type==="pcb_plated_hole"){const d=u.outer_diameter??u.hole_diameter;a(u.x,u.y,d,d)}else if(u.type==="pcb_thtpad"){const d=u.diameter;a(u.x,u.y,d,d)}let c=0,l=0;switch(e){case"center":c=(i+r)/2,l=(o+s)/2;break;case"bottomleft":c=i,l=o;break;case"bottomcenter":case"centerbottom":c=(i+r)/2,l=o;break;case"topcenter":case"centertop":c=(i+r)/2,l=s;break;case"leftcenter":case"centerleft":c=i,l=(o+s)/2;break;case"rightcenter":case"centerright":c=r,l=(o+s)/2;break;case"pin1":const u=t.find(d=>d.port_hints?.[0]==="1")||t[0];c=u.x,l=u.y;break}if(c===0&&l===0)return n;for(const u of n){if(typeof u.x=="number"&&(u.x-=c),typeof u.y=="number"&&(u.y-=l),u.center&&typeof u.center.x=="number"&&(u.center.x-=c,u.center.y-=l),u.type==="pcb_silkscreen_path")for(const d of u.route)d.x-=c,d.y-=l;u.type==="pcb_silkscreen_text"&&u.anchor_position&&(u.anchor_position.x-=c,u.anchor_position.y-=l)}return n},dEn=n=>{let e=lV();const i=n.replace(/^((?:\d{4}|\d{5}))(?=$|_)/,"res$1").split(/_(?!metric)/).map(r=>{const o=r.match(/([a-z]+)([\(\d\.\+\?].*)?/);if(!o)return null;const[,s,a]=o;return!s||a?.includes("?")?null:{fn:s,v:a}}).filter(lEn);for(const{fn:r,v:o}of i)e=e[r](o);return e.setString(n),e},hEn=()=>Object.keys(j5),lV=()=>{const n=new Proxy({},{get:(e,t)=>{if(t==="soup"||t==="circuitJson"){if("fn"in e&&j5[e.fn])return()=>{const{circuitJson:i}=j5[e.fn](e);return uEn(i,e.origin)};if(!j5[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 "${t}"`)}}if(t==="json"){if(!j5[e.fn])throw new Error(`Invalid footprint function, got "${e.fn}"${e.string?`, from string "${e.string}"`:""}`);return()=>j5[e.fn](e).parameters}return t==="getFootprintNames"?()=>Object.keys(j5):t==="params"?()=>e:t==="setString"?i=>(e.string=i,n):i=>(Object.keys(e).length===0?`${t}${i}`in j5?(e[`${t}${i}`]=!0,e.fn=`${t}${i}`):(e[t]=!0,e.fn=t,t==="res"||t==="cap"?i&&(typeof i=="string"&&i.includes("_metric")?e.metric=i.split("_metric")[0]:e.imperial=i):e.num_pins=Number.isNaN(Number.parseFloat(i))?void 0:Number.parseFloat(i)):!i&&["w","h","p"].includes(t)||(e[t]=i??!0),n)}});return n};lV.string=dEn,lV.getFootprintNames=hEn;var pEn=lV,uet=Symbol("Fragment");function xye(n,e,...t){const i=t.length?t:e?.children!==void 0?[e.children]:[],r=[],o=(Array.isArray(i)?i:[i]).flat(1/0);for(const s of o)s==null||s===!1||(Array.isArray(s)?r.push(...s):r.push(s));return{type:n,props:(e&&e.children!==void 0?{...e,children:void 0}:e)||{},children:r}}var Js=Symbol("Cuboid"),det=Symbol("Cube"),G5=Symbol("Cylinder"),het=Symbol("Sphere"),bye=Symbol("RoundedCuboid"),Kb=Symbol("Translate"),eI=Symbol("Rotate"),uV=Symbol("Union"),dV=Symbol("Subtract"),u4=Symbol("Hull"),oT=Symbol("Colorize"),s8=Symbol("Polygon"),a8=Symbol("ExtrudeLinear"),Sy=uet,Yn=(n,e,t)=>xye(n,e),Kd=(n,e,t)=>xye(n,e),tI=({center:n,width:e,length:t,height:i,heightAboveSurface:r=.15})=>{const o=i*.5,s=i-o,a=Math.min(e,t)*.12,c=Math.max(e-a,e*.75),l=Math.max(t-a,t*.75),u=Math.min(e,t)*.12,d=t/2-u*.25,h=l/8,p=i/4;return Yn(oT,{color:"#555",children:Yn(Kb,{offset:n,children:Yn(Kb,{offset:{x:0,y:0,z:r},children:Kd(dV,{children:[Kd(uV,{children:[Kd(u4,{children:[Yn(Kb,{z:.005,children:Yn(Js,{size:[c,l,.01]})}),Yn(Kb,{z:o,children:Yn(Js,{size:[e,t,.01]})})]}),Kd(u4,{children:[Yn(Kb,{z:o,children:Yn(Js,{size:[e,t,.01]})}),Yn(Kb,{z:o+s,children:Yn(Js,{size:[c,l,.01]})})]})]}),Yn(Kb,{offset:{x:0,y:d,z:i},children:Yn(eI,{rotation:[0,0,0],children:Yn(G5,{radius:h,height:p})})})]})})})})},fEn=n=>Array.from({length:n},(e,t)=>t);function vye(n,e){if(n.length<2)throw new Error("Stroke must have at least two points");const t=Array.isArray(n[0])?n.map(([u,d])=>({x:u,y:d})):n,i=e/2,r=[],o=[];function s(u,d){const h=d.x-u.x,p=d.y-u.y,m=Math.sqrt(h*h+p*p);return{x:-p/m,y:h/m}}function a(u,d,h){const p={x:u.x+d.x*i*h,y:u.y+d.y*i*h};h>0?r.push(p):o.unshift(p)}const c=s(t[0],t[1]);a(t[0],c,1),a(t[0],c,-1);for(let u=1;u<t.length-1;u++){const d=t[u-1],h=t[u],p=t[u+1],m=s(d,h),_=s(h,p),g=m.x+_.x,x=m.y+_.y,b=Math.sqrt(g*g+x*x);if(b/2>2*i)a(h,m,1),a(h,_,1),a(h,m,-1),a(h,_,-1);else{const E=1/b;a(h,{x:g*E,y:x*E},1),a(h,{x:g*E,y:x*E},-1)}}const l=s(t[t.length-2],t[t.length-1]);return a(t[t.length-1],l,1),a(t[t.length-1],l,-1),[...r,...o]}var mEn=n=>{const e=Math.min(...n.map(a=>a.x)),t=Math.max(...n.map(a=>a.x)),i=Math.min(...n.map(a=>a.y)),s=5.47/(Math.max(...n.map(a=>a.y))-i);return n.map(a=>({x:(a.x-e-(t-e)/2)*s,y:(a.y-i)*s}))},_En=mEn([{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}]),pet=5.47,hV=.5,yEn=({x:n,y:e,z:t})=>{const i=n>0;return Kd(Sy,{children:[Yn(Kb,{offset:{x:n+.25/2,y:e,z:t},children:Yn(eI,{rotation:["-90deg",0,"90deg"],children:Yn(a8,{height:.25,children:Yn(s8,{points:_En.map(r=>[r.x,r.y])})})})}),Yn(Kb,{offset:{x:n,y:e+(i?1:-1),z:t},children:Yn(eI,{rotation:["-90deg","90deg",i?"180deg":"0deg"],children:Yn(a8,{height:2,children:Yn(s8,{points:vye([[0,0],[-1,0],[-1,-1]],.25).map(r=>[r.x,r.y])})})})})]})},gEn=({numPins:n=8,pitch:e=2.54,bodyWidth:t=6.4})=>{const i=Math.floor(n/2),r=t+1;return Kd(Sy,{children:[fEn(n).map(o=>{const s=o%i,a=(Math.floor(o/i)-.5)*2;return Yn(yEn,{x:a*r/2,y:s*e-(i-1)/2*e,z:pet/2+hV})}),Yn(tI,{width:t,length:i*e+.5,height:pet-hV,heightAboveSurface:hV,center:{x:0,y:0,z:hV}})]})};function xEn(n,{height:e,padContactLength:t,curveLength:i,bodyDistance:r,steepness:o=10}){i||(i=r*.3);let s=r-t-i;s<0&&(i+=s,s=0);const a=t*.75,c=t+i+(r-t-i)*.25;if(n<=a)return 0;if(n>=c)return e;const l=(n-a)/(c-a);return e/(1+Math.exp(-o*(l-.5)))}var Rv=n=>{const{thickness:e,width:t,padContactLength:i,bodyDistance:r,height:o,rotation:s}=n,a=15,c=Array.from({length:a}).map((u,d)=>d/(a-1)*r).map(u=>[u,xEn(u,n)]),l=vye(c,e);return Yn(oT,{color:"#fff",children:Yn(Kb,{offset:{z:0,y:0,x:0,...n.position},children:Yn(eI,{rotation:["90deg",0,s??0],children:Yn(Kb,{offset:{x:0,y:0,z:-t/2},children:Yn(a8,{height:t,children:Yn(s8,{points:l.map(u=>[u.x,u.y])})})})})})})},bEn=({pinCount:n,leadLength:e,leadWidth:t,pitch:i,bodyWidth:r})=>{const o=Math.ceil(n/2),s=i*n/2+t/2,a=(o-1)*i/2,c=.25;return Kd(Sy,{children:[Array.from({length:o}).map((l,u)=>Yn(Rv,{position:{x:-r/2-e,y:u*i-a,z:c/2},width:t,thickness:c,padContactLength:e,bodyDistance:e+1,height:.8})),Array.from({length:o}).map((l,u)=>Yn(Rv,{rotation:Math.PI,position:{x:r/2+e,y:u*i-a,z:c/2},width:t,thickness:c,padContactLength:e,bodyDistance:e+1,height:.8})),Yn(tI,{center:{x:0,y:0,z:c/2},width:r-t-1,length:s,height:1.5})]})},wye=1,Sye=.5,nI=.5,c8=.2,vEn=wye-c8*2,fet=({color:n="#333"})=>Kd(Sy,{children:[Yn(Js,{size:[vEn,Sye,nI],offset:[0,0,nI/2],color:n}),Yn(Js,{size:[c8,nI,Sye],offset:[wye/2-c8/2,0,nI/2],color:"#ccc"}),Yn(Js,{size:[c8,nI,Sye],offset:[-wye/2+c8/2,0,nI/2],color:"#ccc"})]}),Eye=1.6,wEn=Eye-.3*2,pV=.3,Tye=.85,iI=.6,met=({color:n="#333"})=>Kd(Sy,{children:[Yn(Js,{size:[wEn,Tye,iI],offset:[0,0,iI/2],color:n}),Yn(Js,{size:[pV,Tye,iI],offset:[Eye/2-pV/2,0,iI/2],color:"#ccc"}),Yn(Js,{size:[pV,Tye,iI],offset:[-Eye/2+pV/2,0,iI/2],color:"#ccc"})]}),Mye=2,Cye=1.25,rI=.55,l8=.5,SEn=Mye-l8*2,_et=({color:n="#333"})=>Kd(Sy,{children:[Yn(Js,{size:[SEn,Cye,rI],offset:[0,0,rI/2],color:n}),Yn(Js,{size:[l8,Cye,rI],offset:[Mye/2-l8/2,0,rI/2],color:"#ccc"}),Yn(Js,{size:[l8,Cye,rI],offset:[-Mye/2+l8/2,0,rI/2],color:"#ccc"})]}),EEn=({pinCount:n,pitch:e,leadWidth:t,padContactLength:i,bodyWidth:r})=>{const o=n/4;e||(e=TEn(n,r)),i||(i=MEn(n)),t||(t=CEn(n,r)),r||(r=e*(o+4));const s=r,a=(o-1)*e/2,c=s+2*i,l=c,u=.8,d=.15,h=(l-r)/2;return Kd(Sy,{children:[Array.from({length:o}).map((p,m)=>Yn(Rv,{position:{x:-l/2,y:m*e-a,z:d/2},width:t,thickness:d,padContactLength:i,bodyDistance:h,height:u})),Array.from({length:o}).map((p,m)=>Yn(Rv,{rotation:Math.PI,position:{x:l/2,y:m*e-a,z:d/2},width:t,thickness:d,padContactLength:i,bodyDistance:h,height:u})),Array.from({length:o}).map((p,m)=>Yn(Rv,{rotation:Math.PI/2,position:{x:m*e-a,y:-c/2,z:d/2},width:t,thickness:d,padContactLength:i,bodyDistance:h,height:u})),Array.from({length:o}).map((p,m)=>Yn(Rv,{rotation:-Math.PI/2,position:{x:m*e-a,y:c/2,z:d/2},width:t,thickness:d,padContactLength:i,bodyDistance:h,height:u})),Yn(tI,{center:{x:0,y:0,z:d/2},width:r,length:s,height:1.5})]})},TEn=(n,e)=>{switch(n){case 44:case 64:return .8;case 52:return e===14?1:.65;case 208:return .5;default:return .5}},MEn=n=>{switch(n){case 44:case 52:case 64:return 2.25;case 208:return 1.65;default:return 1}},CEn=(n,e)=>{switch(n){case 44:case 64:return .5;case 52:return e===14?.45:.55;case 208:return .3;default:return .25}},AEn=({numberOfPins:n,pitch:e=2.54,longSidePinLength:t=6})=>{const o=n*e,s=3,a=-((n-1)/2)*e;return Kd(Sy,{children:[Yn(Js,{color:"#222",size:[o,.63*3,2],center:[0,0,2/2]}),Array.from({length:n},(c,l)=>Kd(Sy,{children:[Yn(oT,{color:"gold",children:Kd(u4,{children:[Yn(Js,{color:"gold",size:[.63,.63,s*.9],center:[a+l*e,0,2*.9+2/2]}),Yn(Js,{color:"gold",size:[.63/1.8,.63/1.8,s],center:[a+l*e,0,2+2/2]})]})}),Yn(oT,{color:"gold",children:Kd(u4,{children:[Yn(Js,{color:"gold",size:[.63,.63,t*.9],center:[a+l*e,0,-t/2*.9]}),Yn(Js,{color:"gold",size:[.63/1.8,.63/1.8,t],center:[a+l*e,0,-t/2]})]})})]}))]})},PEn=n=>{const e=["left","bottom","right","top"],{pin_count:t,pn:i,w:r,h:o,p:s,pl:a}=n,c=t/4,l=e[Math.floor((i-1)/c)],u=(i-1)%c,d=s*(c-1),h=s*(c-1),p=-a/2;switch(l){case"left":return{x:-r/2-p,y:h/2-u*s,o:"vert"};case"bottom":return{x:-d/2+u*s,y:-o/2-p,o:"horz"};case"right":return{x:r/2+p,y:-h/2+u*s,o:"vert"};case"top":return{x:d/2-u*s,y:o/2+p,o:"horz"};default:throw new Error("Invalid pin number")}},REn=({num_pins:n,cw:e,ccw:t,startingpin:i})=>{const r=[],o=n/4;let s=1;const a={};for(const c of i??[])a[c]=!0;!a.leftside&&!a.topside&&!a.rightside&&!a.bottomside&&(a.leftside=!0),!a.bottompin&&!a.leftpin&&!a.rightpin&&!a.toppin&&(a.leftside?a.toppin=!0:a.topside?a.rightpin=!0:a.rightside?a.bottompin=!0:a.bottomside&&(a.leftpin=!0)),a.leftside&&a.toppin?s=1:a.leftside&&a.bottompin?s=o:a.bottomside&&a.leftpin?s=o+1:a.bottomside&&a.rightpin?s=o*2:a.rightside&&a.bottompin?s=o*2+1:a.rightside&&a.toppin?s=o*3:a.topside&&a.rightpin?s=o*3+1:a.topside&&a.leftpin&&(s=o*4),r.push(-1);for(let c=0;c<n;c++)r[s]=c+1,s++,s>n&&(s=1);return r},IEn=({num_pins:n=16,bodyWidth:e=9,bodyLength:t=9,bodyThickness:i=.8,thermalPadSize:r,padWidth:o=.25,padLength:s=.25,pitch:a=.5,thermalPadThickness:c=.05})=>{const l=REn({num_pins:n,cw:!0,ccw:!0}),u=[];for(let d=0;d<n;d++){const{x:h,y:p,o:m}=PEn({pin_count:n,pn:d+1,w:e,h:t,p:a,pl:s});let _=o,g=s;m==="vert"&&([_,g]=[g,_]);const x=l[d+1];u.push({pn:x,x:h,y:p,pw:_,pl:g})}return Kd(Sy,{children:[Yn(oT,{color:"grey",children:Yn(Js,{center:{x:0,y:0,z:i/2},size:[e,t,i]})}),u.map((d,h)=>Yn(Js,{center:{x:d.x,y:d.y,z:c/2},size:[d.pw,d.pl,c]})),r?.length!==void 0&&r?.width!==void 0&&Yn(Js,{center:{x:0,y:0,z:c/2},size:[r.width,r.length,c]})]})},NEn=IEn,kEn=()=>{const c=1.1999999999999997;return Kd(Sy,{children:[Yn(Rv,{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}),Yn(Rv,{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}),Yn(Rv,{position:{x:-2.8/2-c/4,y:0,z:.15/2},width:.4,thickness:.15,padContactLength:.5,bodyDistance:c,height:.95}),Yn(Rv,{position:{x:-2.8/2-c/4,y:-1,z:.15/2},width:.4,thickness:.15,padContactLength:.5,bodyDistance:c,height:.95}),Yn(Rv,{position:{x:-2.8/2-c/4,y:1,z:.15/2},width:.4,thickness:.15,padContactLength:.5,bodyDistance:c,height:.95}),Yn(tI,{center:{x:0,y:0,z:0},width:1.6,length:2.9,height:1.2})]})},OEn=kEn,Aye=.6,Pye=.3,oI=.33,u8=.1,LEn=Aye-u8*2,yet=({color:n="#333"})=>Kd(Sy,{children:[Yn(Js,{size:[LEn,Pye,oI],offset:[0,0,oI/2],color:n}),Yn(Js,{size:[u8,Pye,oI],offset:[Aye/2-u8/2,0,oI/2],color:"#ccc"}),Yn(Js,{size:[u8,Pye,oI],offset:[-Aye/2+u8/2,0,oI/2],color:"#ccc"})]}),Rye=.4,Iye=.2,sI=.13,d8=.07,DEn=Rye-d8*2,get=({color:n="#333"})=>Kd(Sy,{children:[Yn(Js,{size:[DEn,Iye,sI],offset:[0,0,sI/2],color:n}),Yn(Js,{size:[d8,Iye,sI],offset:[Rye/2-d8/2,0,sI/2],color:"#ccc"}),Yn(Js,{size:[d8,Iye,sI],offset:[-Rye/2+d8/2,0,sI/2],color:"#ccc"})]}),Nye=3.2,kye=1.6,aI=.9,h8=.5,zEn=Nye-h8*2,xet=({color:n="#333"})=>Kd(Sy,{children:[Yn(Js,{size:[zEn,kye,aI],offset:[0,0,aI/2],color:n}),Yn(Js,{size:[h8,kye,aI],offset:[Nye/2-h8/2,0,aI/2],color:"#ccc"}),Yn(Js,{size:[h8,kye,aI],offset:[-Nye/2+h8/2,0,aI/2],color:"#ccc"})]}),Oye=3.2,Lye=2.5,cI=1,p8=.6,$En=Oye-p8*2,bet=({color:n="#333"})=>Kd(Sy,{children:[Yn(Js,{size:[$En,Lye,cI],offset:[0,0,cI/2],color:n}),Yn(Js,{size:[p8,Lye,cI],offset:[Oye/2-p8/2,0,cI/2],color:"#ccc"}),Yn(Js,{size:[p8,Lye,cI],offset:[-Oye/2+p8/2,0,cI/2],color:"#ccc"})]}),Dye=5,zye=2.5,lI=1.4,f8=.6,FEn=Dye-f8*2,vet=({color:n="#333"})=>Kd(Sy,{children:[Yn(Js,{size:[FEn,zye,lI],offset:[0,0,lI/2],color:n}),Yn(Js,{size:[f8,zye,lI],offset:[Dye/2-f8/2,0,lI/2],color:"#ccc"}),Yn(Js,{size:[f8,zye,lI],offset:[-Dye/2+f8/2,0,lI/2],color:"#ccc"})]}),$ye=6.3,Fye=3.2,uI=1.8,m8=.8,UEn=$ye-m8*2,wet=({color:n="#333"})=>Kd(Sy,{children:[Yn(Js,{size:[UEn,Fye,uI],offset:[0,0,uI/2],color:n}),Yn(Js,{size:[m8,Fye,uI],offset:[$ye/2-m8/2,0,uI/2],color:"#ccc"}),Yn(Js,{size:[m8,Fye,uI],offset:[-$ye/2+m8/2,0,uI/2],color:"#ccc"})]}),BEn=({numberOfPins:n,pitch:e=2.54,legsLength:t=3,outerDiameter:i=.945,innerDiameter:r=.945})=>{const o=r/1.5,s=o*2+i,a=5,c=(n-1)*e+i+e/2,l=o*1.6,u=-((n-1)/2)*e,d=Yn(oT,{color:"#1a1a1a",children:Kd(dV,{children:[Yn(Js,{color:"#000",size:[c,s,a],center:[0,0,a/2]}),Array.from({length:n},(h,p)=>r?Yn(G5,{height:a+.1,radius:r/2,center:[u+p*e,0,a/2],color:"#222"},p):Yn(Js,{size:[l,l,a],center:[u+p*e,0,a/2]},p))]})});return Kd(Sy,{children:[d,Array.from({length:n},(h,p)=>Kd(oT,{color:"silver",children:[Kd(u4,{children:[Yn(Js,{color:"silver",size:[o,o,t*.9],center:[u+p*e,0,-t/2*.9]}),Yn(Js,{color:"silver",size:[o/1.8,o/1.8,t],center:[u+p*e,0,-t/2]})]}),Yn(Js,{color:"silver",size:[l,l,l*.5],center:[u+p*e,0,l/2*.5]})]},p))]})},jEn=({width:n,length:e,innerDiameter:t=1})=>{const i=n,r=e,o=n*.7,s=t/2.5;return Kd(Sy,{children:[Yn(bye,{color:"#1a1a1f",center:[0,0,o/2],size:[r,r,o],roundRadius:.3}),Yn(bye,{color:"#f2f2f2",center:[0,0,o+o*.1/2.5],size:[r,r,o*.1],roundRadius:.14}),Yn(G5,{color:"#1a1a1f",height:o*.8,radius:i/3,center:[0,0,o+o*.8/2]}),Yn(G5,{color:"#1a1a1f",height:o*.2,radius:t/2,center:[r/3,r/3,o+o*.1/2]}),Yn(G5,{color:"#1a1a1f",height:o*.2,radius:t/2,center:[-r/3,-r/3,o+o*.1/2]}),Yn(G5,{color:"#1a1a1f",height:o*.2,radius:t/2,center:[-r/3,r/3,o+o*.1/2]}),Yn(G5,{color:"#1a1a1f",height:o*.2,radius:t/2,center:[r/3,-r/3,o+o*.1/2]}),Yn(fV,{thickness:t/3,width:s,horizontalLength:r*.8,verticalLength:o/2,position:{x:-i/2,y:-r/2,z:-o*1.2}}),Yn(fV,{thickness:t/3,width:s,horizontalLength:r*.8,verticalLength:o/2,position:{x:-i/2,y:r/2,z:-o*1.2},rotation:Math.PI}),Yn(fV,{thickness:t/3,width:s,horizontalLength:r*.8,verticalLength:o/2,position:{x:i/2,y:r/2,z:-o*1.2},rotation:Math.PI}),Yn(fV,{thickness:t/3,width:s,horizontalLength:r*.8,verticalLength:o/2,position:{x:i/2+t/3.6,y:-r/2,z:-o*1.2}})]})},fV=n=>{const{thickness:e,width:t,horizontalLength:i,verticalLength:r,rotation:o=0,position:s}=n,a=[[0,i],[-r/3,i/3],[-r/5,i/4],[0,0]],c=vye(a,e);return Yn(oT,{color:"#f2f2f2",children:Yn(Kb,{offset:{x:s?.x||0,y:s?.y||0,z:s?.z||0},children:Yn(eI,{rotation:[0,55,o],children:Yn(a8,{height:t,children:Yn(s8,{points:c.map(l=>[l.y,l.x])})})})})})},HEn=({pinCount:n,leadLength:e,leadWidth:t,pitch:i,bodyWidth:r})=>{const o=Math.ceil(n/2),s=(o-1)*i/2,a=.25,c=1,l=.8,u=e*0,d=i*(o-1)+t+.2,h=r*.55;return Kd(Sy,{children:[Array.from({length:o}).map((p,m)=>Yn(Rv,{position:{x:-r/2-u,y:m*i-s,z:a/2},width:t,thickness:a,padContactLength:e/2,bodyDistance:e+.2,height:l})),Array.from({length:o}).map((p,m)=>Yn(Rv,{rotation:Math.PI,position:{x:r/2+u,y:m*i-s,z:a/2},width:t,thickness:a,padContactLength:e/2,bodyDistance:e+.2,height:l})),Yn(tI,{center:{x:0,y:0,z:a/2},width:h,length:d,height:c})]})},VEn=({pinCount:n,pitch:e,leadWidth:t,leadLength:i,bodyWidth:r,bodyLength:o})=>{const s=n===8?{pitch:.65,leadWidth:.3}:{pitch:.5,leadWidth:.225},a=isNaN(parseFloat(e))?s.pitch:parseFloat(e),c=isNaN(parseFloat(t))?s.leadWidth:parseFloat(t)*.8,l=isNaN(parseFloat(r))?2.6:parseFloat(r)*.8,u=isNaN(parseFloat(o))?2+Number(a)*1.4:parseFloat(o),d=n/2,h=(d-1)*a/2,p=.15,m=.8,_=4.5,g=(_-l)/2,x=g*.5;return Kd(Sy,{children:[Array.from({length:d}).map((b,w)=>Yn(Rv,{position:{x:-_/2,y:h-w*a,z:p/2},width:c,thickness:p,padContactLength:x+.05,bodyDistance:g+.05,height:m})),Array.from({length:d}).map((b,w)=>Yn(Rv,{rotation:Math.PI,position:{x:_/2,y:h-w*a,z:p/2},width:c,thickness:p,padContactLength:x+.05,bodyDistance:g+.05,height:m})),Yn(tI,{center:{x:0,y:0,z:p/2},width:l,length:u,height:1})]})},GEn=()=>{const d=Yn(oT,{color:"#222",children:Kd(uV,{children:[Yn(Kb,{z:.15,children:Yn(Js,{size:[1.65,.8,.3]})}),Kd(u4,{children:[Yn(Kb,{z:.3,children:Yn(Js,{size:[1.65,.8,.01]})}),Yn(Kb,{z:.6,children:Yn(Js,{size:[1.45,.6000000000000001,.01]})})]})]})});return Kd(Sy,{children:[Yn(Js,{color:"#ccc",size:[.5,.6,.12],center:[-.725,0,.12/2]}),Yn(Js,{color:"#ccc",size:[.5,.6,.12],center:[.725,0,.12/2]}),d]})},YEn=({footprint:n})=>{const e=pEn.string(n).json();switch(e.fn){case"dip":return Yn(gEn,{numPins:e.num_pins,pitch:e.p,bodyWidth:e.w});case"tssop":return Yn(bEn,{pinCount:e.num_pins,leadLength:e.pl,leadWidth:e.pw,pitch:e.p,bodyWidth:e.w});case"vssop":return Yn(VEn,{pinCount:e.num_pins,leadLength:e.pl,leadWidth:e.pw,pitch:e.p,bodyWidth:e.w,bodyLength:e.h});case"qfp":return Yn(EEn,{pinCount:e.num_pins,pitch:e.p,leadWidth:e.pw,padContactLength:e.pl,bodyWidth:e.w});case"qfn":return Yn(NEn,{num_pins:e.num_pins,bodyWidth:e.w,bodyLength:e.h,pitch:e.p,padLength:e.pl,padWidth:e.pw,thermalPadSize:{width:e.thermalpad.x,length:e.thermalpad.y}});case"pinrow":if(e.male)return Yn(AEn,{numberOfPins:e.num_pins,pitch:e.p});if(e.female)return Yn(BEn,{numberOfPins:e.num_pins,pitch:e.p});case"cap":switch(e.imperial){case"0402":return Yn(fet,{color:"#856c4d"});case"0603":return Yn(met,{color:"#856c4d"});case"0805":return Yn(_et,{color:"#856c4d"});case"0201":return Yn(yet,{color:"#856c4d"});case"01005":return Yn(get,{color:"#856c4d"});case"1206":return Yn(xet,{color:"#856c4d"});case"1210":return Yn(bet,{color:"#856c4d"});case"2010":return Yn(vet,{color:"#856c4d"});case"2512":return Yn(wet,{color:"#856c4d"})}case"sot235":return Yn(OEn,{});case"pushbutton":return Yn(jEn,{width:e.w,length:e.h,innerDiameter:e.id});case"soic":return Yn(HEn,{pinCount:e.num_pins,leadLength:e.pl,leadWidth:e.pw,pitch:e.p,bodyWidth:e.w});case"sod523":return Yn(GEn,{})}const t=n.match(/_color\(([^)]+)\)/),i=t?t[1]:void 0;switch(e.imperial){case"0402":return Yn(fet,{color:i});case"0603":return Yn(met,{color:i});case"0805":return Yn(_et,{color:i});case"0201":return Yn(yet,{color:i});case"01005":return Yn(get,{color:i});case"1206":return Yn(xet,{color:i});case"1210":return Yn(bet,{color:i});case"2010":return Yn(vet,{color:i});case"2512":return Yn(wet,{color:i})}return null},qEn=n=>n&&typeof n=="object"&&"type"in n,dI=n=>{if(typeof n=="number")return n;if(typeof n=="string"){const e=/^(-?\d+(?:\.\d+)?)\s*deg$/i.exec(n);if(e)return parseFloat(e[1])*Math.PI/180;const t=Number(n);if(!Number.isNaN(t))return t}return 0},XEn=n=>Array.isArray(n)?[Number(n[0])||0,Number(n[1])||0,Number(n[2])||0]:typeof n=="object"&&n?[Number(n.x)||0,Number(n.y)||0,Number(n.z)||0]:[0,0,0];function sT(n,e,t){const{jscad:{primitives:i,booleans:r,hulls:o,geometries:s,extrusions:a,transforms:c}}=t;if(n==null||n===!1)return[];if(Array.isArray(n))return n.flatMap(h=>sT(h,e,t));if(!qEn(n))return[];const{type:l,props:u,children:d}=n;if(l===uet)return(d??[]).flatMap(h=>sT(h,e,t));if(l===oT){const h=u?.color;return(d??[]).flatMap(p=>sT(p,h??e,t))}if(l===Kb){const h=XEn(u?.offset??{x:u?.x,y:u?.y,z:u?.z});return(d??[]).flatMap(m=>sT(m,e,t)).map(({geom:m,color:_})=>({geom:c.translate(h,m),color:_??e}))}if(l===eI){const h=Array.isArray(u?.rotation)?[dI(u.rotation[0]),dI(u.rotation[1]),dI(u.rotation[2])]:[dI(u?.x??0),dI(u?.y??0),dI(u?.z??0)];return(d??[]).flatMap(m=>sT(m,e,t)).map(({geom:m,color:_})=>({geom:c.rotateZ(h[2],c.rotateY(h[1],c.rotateX(h[0],m))),color:_}))}if(l===uV||l===dV||l===u4){const h=(d??[]).flatMap(m=>sT(m,e,t)).map(m=>m.geom);if(h.length===0)return[];let p;return l===uV?p=r.union(h):l===dV?p=r.subtract(h[0],h.slice(1)):p=o.hull(h),[{geom:p}]}if(l===s8){const h=u?.points??[];return[{geom:s.geom2.fromPoints(h),color:e??u?.color}]}if(l===a8){const h=(d??[]).flatMap(g=>sT(g,e,t)).map(g=>g.geom);if(h.length===0)return[];const p=h.length>1?r.union(h):h[0],m=u?.height??u?.h??1;let _=a.extrudeLinear({height:m},p);if(_.polygons)for(const g of _.polygons)!g.plane||!g.vertices||g.vertices.length<3||g.vertices.reverse();return[{geom:_,color:e??u?.color}]}if(l===Js||l===det||l===G5||l===het||l===bye){let h;if(l===Js){const p=u?.size??[1,1,1],m=u?.offset,_=u?.center??(m?[m[0],m[1],m[2]]:[0,0,0]);h=i.cuboid({size:p,center:_})}else if(l===det){const p=u?.size??1,m=u?.offset,_=u?.center??(m?[m[0],m[1],m[2]]:[0,0,0]);h=i.cube({size:p,center:_})}else if(l===G5){const p=u?.height??1,m=u?.radius??1,_=u?.center??[0,0,0];h=i.cylinder({height:p,radius:m,center:_})}else if(l===het){const p=u?.radius??1,m=u?.center??[0,0,0];h=i.sphere({radius:p,center:m})}else{const p=u?.size??[1,1,1],m=u?.roundRadius??.1,_=u?.center??[0,0,0];h=i.roundedCuboid({size:p,roundRadius:m,center:_})}return[{geom:h,color:e??u?.color}]}if(typeof l=="function"){const h=l(u??{});return sT(h,e,t)}return(d??[]).flatMap(h=>sT(h,e,t))}function WEn(n,e){return{geometries:sT(n,void 0,{jscad:e})}}function Eet(n){if(n.polygons){const e=[],t=[],i=[];let r=0;for(const s of n.polygons){for(const c of s.vertices)c.index=r,e.push(c[0],c[1],c[2]),n.color&&n.color.length>=3?i.push(n.color[0],n.color[1],n.color[2]):i.push(1,1,1),r++;const a=s.vertices[0].index;for(let c=2;c<s.vertices.length;c++){const l=s.vertices[c-1].index,u=s.vertices[c].index;t.push(a,l,u)}}const o=new Pf;if(o.setAttribute("position",new ym(new Float32Array(e),3)),o.setIndex(t),i.length>0&&o.setAttribute("color",new ym(new Float32Array(i),3)),n.transforms){const s=new Qa;s.fromArray(n.transforms),o.applyMatrix4(s)}return o.computeVertexNormals(),o}if(n.sides){const e=[],t=[];for(const r of n.sides)e.push(r[0][0],r[0][1],0),n.color&&n.color.length>=3?t.push(n.color[0],n.color[1],n.color[2]):t.push(1,1,1);const i=new Pf;if(i.setAttribute("position",new ym(new Float32Array(e),3)),t.length>0&&i.setAttribute("color",new ym(new Float32Array(t),3)),n.transforms){const r=new Qa;r.fromArray(n.transforms),i.applyMatrix4(r)}return i}return console.error("Invalid CSG object: neither polygons nor sides found"),new Pf}function KEn(n,e){const t=xye(YEn,{footprint:n});return WEn(t,e)}var ZEn=({jscadPlan:n,positionOffset:e,rotationOffset:t,onHover:i,onUnhover:r,isHovered:o,scale:s})=>{const{rootObject:a}=_b(),{threeGeom:c,material:l}=fe.useMemo(()=>{const d=(0,pxn.executeJscadOperations)(fxn.default,n);if(!d||!d.polygons&&!d.sides)return{threeGeom:null,material:null};const h=Eet(d),p=new Gb({vertexColors:!0,side:qg});return{threeGeom:h,material:p}},[n]),u=fe.useMemo(()=>c?new Ma(c,l):null,[c,l]);return fe.useEffect(()=>{if(!(!u||!a))return a.add(u),()=>{a.remove(u)}},[a,u]),fe.useEffect(()=>{u&&(e&&u.position.fromArray(e),t&&u.rotation.fromArray(t),s!==void 0&&u.scale.setScalar(s))},[u,e?.[0],e?.[1],e?.[2],t?.[0],t?.[1],t?.[2],s]),fe.useMemo(()=>{if(l)if(o){const d=new Jr(l.color.getHex());l.emissive.copy(d),l.emissive.setRGB(0,0,1),l.emissiveIntensity=.2}else l.emissiveIntensity=0},[o,l]),c?ce.jsx(i8,{isHovered:o,onHover:i,onUnhover:r,object:u}):null},QEn=vc(eV()),JEn=({positionOffset:n,footprint:e,rotationOffset:t,onHover:i,onUnhover:r,isHovered:o,scale:s})=>{const{rootObject:a}=_b(),c=fe.useMemo(()=>{if(!e)return null;const{geometries:l}=KEn(e,QEn),u=new Qw;for(const d of l.flat(1/0)){const h=d.geom;if(!h||!h.polygons&&!h.sides)continue;const p=new Jr(d.color);p.convertLinearToSRGB();const m={...h,color:[p.r,p.g,p.b]},_=Eet(m),g=new Gb({vertexColors:!0,side:qg}),x=new Ma(_,g);u.add(x)}return u},[e]);return fe.useEffect(()=>{if(!(!c||!a))return a.add(c),()=>{a.remove(c)}},[a,c]),fe.useEffect(()=>{c&&(n&&c.position.fromArray(n),t&&c.rotation.fromArray(t),s!==void 0&&c.scale.setScalar(s))},[c,n?.[0],n?.[1],n?.[2],t?.[0],t?.[1],t?.[2],s]),fe.useEffect(()=>{c&&c.traverse(l=>{l instanceof Ma&&l.material instanceof Gb&&(o?(l.material.emissive.setHex(255),l.material.emissiveIntensity=.2):l.material.emissiveIntensity=0)})},[o,c]),c?ce.jsx(i8,{isHovered:o,onHover:i,onUnhover:r,object:c}):null},eTn=(...n)=>n,Tet=({children:n,position:e,style:t})=>{const{camera:i,renderer:r}=_b(),o=fe.useRef(document.createElement("div")),[s,a]=fe.useState(null);return fe.useEffect(()=>{const c=r?.domElement.parentNode;if(c)return c.style.position!=="relative"&&c.style.position!=="absolute"&&(c.style.position="relative"),c.appendChild(o.current),a(rz.createPortal(n,o.current)),()=>{c.contains(o.current)&&c.removeChild(o.current)}},[r,n]),ZR(()=>{if(!i||!o.current||!r)return;const c=new en(...e);c.project(i);const l=r.domElement.getBoundingClientRect(),u=Math.round((c.x+1)/2*l.width),d=Math.round((-c.y+1)/2*l.height);o.current.style.position="absolute",o.current.style.left=`${u}px`,o.current.style.top=`${d}px`,o.current.style.pointerEvents="none",o.current.style.zIndex="1000",t&&Object.assign(o.current.style,t)},[i,r,e,t]),s},Met={boardBody:!0,topCopper:!0,bottomCopper:!0,adhesive:!1,solderPaste:!1,topSilkscreen:!0,bottomSilkscreen:!0,topMask:!0,bottomMask:!0,throughHoleModels:!0,smtModels:!0,virtualModels:!1,modelsNotInPosFile:!1,modelsMarkedDNP:!1,modelBoundingBoxes:!1,threedAxis:!1,backgroundStart:!0,backgroundEnd:!0},Cet=fe.createContext(void 0),tTn=({children:n})=>{const[e,t]=fe.useState(Met),i=fe.useCallback(a=>{t(c=>({...c,[a]:!c[a]}))},[]),r=fe.useCallback((a,c)=>{t(l=>({...l,[a]:c}))},[]),o=fe.useCallback(()=>{t(Met)},[]),s=fe.useMemo(()=>({visibility:e,toggleLayer:i,setLayerVisibility:r,resetToDefaults:o}),[e,i,r,o]);return ce.jsx(Cet.Provider,{value:s,children:n})},_8=()=>{const n=fe.useContext(Cet);if(!n)throw new Error("useLayerVisibility must be used within a LayerVisibilityProvider");return n},Aet=({cad_component:n,circuitJson:e})=>{const[t,i]=fe.useState(!1),{visibility:r}=_8(),[o,s]=fe.useState(null),a=fe.useCallback(m=>{m?.mousePosition?(i(!0),s(m.mousePosition)):(i(!1),s(null))},[]),c=fe.useCallback(()=>{i(!1),s(null)},[]),l=fe.useMemo(()=>fs(e).source_component.getUsing({source_component_id:n.source_component_id})?.name,[e,n.source_component_id]),u=n.model_obj_url??n.model_wrl_url??n.model_stl_url,d=n.model_glb_url??n.model_gltf_url,h=n.rotation?eTn(n.rotation.x*Math.PI/180,n.rotation.y*Math.PI/180,n.rotation.z*Math.PI/180):void 0;let p=null;return u?p=ce.jsx(lxn,{url:u,position:n.position?[n.position.x,n.position.y,n.position.z]:void 0,rotation:h,scale:n.model_unit_to_mm_scale_factor,onHover:a,onUnhover:c,isHovered:t},n.cad_component_id):d?p=ce.jsx(hxn,{gltfUrl:d,position:n.position?[n.position.x,n.position.y,n.position.z]:void 0,rotation:h,scale:n.model_unit_to_mm_scale_factor,onHover:a,onUnhover:c,isHovered:t},n.cad_component_id):n.model_jscad?p=ce.jsx(ZEn,{jscadPlan:n.model_jscad,rotationOffset:h,scale:n.model_unit_to_mm_scale_factor,onHover:a,onUnhover:c,isHovered:t},n.cad_component_id):n.footprinter_string&&(p=ce.jsx(JEn,{positionOffset:n.position?[n.position.x,n.position.y,n.position.z]:void 0,rotationOffset:h,footprint:n.footprinter_string,scale:n.model_unit_to_mm_scale_factor,onHover:a,onUnhover:c,isHovered:t})),r.smtModels?ce.jsxs(ce.Fragment,{children:[p,t&&o?ce.jsx(Tet,{position:o,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:l??"<unknown>"}):null]}):null},Pet={version:"0.0.426"},d4=({children:n,parent:e,position:t,rotation:i,scale:r,color:o,fontSize:s,anchorX:a,anchorY:c,depthOffset:l})=>{const{rootObject:u}=_b(),d=fe.useMemo(()=>{const h=new I6e;return h.text=n,t&&h.position.fromArray(t),i&&h.rotation.fromArray(i),r&&h.scale.fromArray(r),h.color=o||"white",h.fontSize=s||1,h.anchorX=a||"center",h.anchorY=c||"middle",h.depthOffset=l||0,h.font=null,h.sync(),h},[n,t,i,r,o,s,a,c,l]);return fe.useEffect(()=>{const h=e||u;if(!(!h||!d))return h.add(d),()=>{h.remove(d),d.dispose()}},[u,e,d]),null};typeof window<"u"&&(window.TSCI_MAIN_CAMERA_ROTATION=new Ww(0,0,0));function nTn(n,e){const t=new Mv().setFromEuler(new Ww(n.x,n.y,n.z)),i=new en(0,0,1);return i.applyQuaternion(t),i.multiplyScalar(e)}var iTn=({})=>{const{camera:n,scene:e}=_b();fe.useEffect(()=>{if(!e)return;const i=new OOe(16777215,Math.PI/2);return e.add(i),()=>{e.remove(i)}},[e]),ZR(()=>{if(!n)return;const i=window.TSCI_MAIN_CAMERA_ROTATION,r=nTn(i,2);n.position.copy(r),n.lookAt(0,0,0)});const t=fe.useMemo(()=>{const i=new Qw;i.rotation.fromArray([Math.PI/2,0,0]);const r=new Ma(new j2(1,1,1),new Gb({color:"white"}));i.add(r);const o=new PO(new X6t(new j2(1,1,1)),new RA({color:0,linewidth:2}));return i.add(o),i},[]);return fe.useEffect(()=>{if(e)return e.add(t),()=>{e.remove(t)}},[e,t]),ce.jsxs(ce.Fragment,{children:[ce.jsx(d4,{parent:t,position:[0,0,.51],fontSize:.25,color:"black",children:"Front"}),ce.jsx(d4,{parent:t,position:[0,0,-.51],fontSize:.25,color:"black",rotation:[0,Math.PI,0],children:"Back"}),ce.jsx(d4,{parent:t,position:[.51,0,0],fontSize:.25,color:"black",rotation:[0,Math.PI/2,0],children:"Right"}),ce.jsx(d4,{parent:t,position:[-.51,0,0],fontSize:.25,color:"black",rotation:[0,-Math.PI/2,0],children:"Left"}),ce.jsx(d4,{parent:t,position:[0,.51,0],fontSize:.25,color:"black",rotation:[-Math.PI/2,0,0],children:"Top"}),ce.jsx(d4,{parent:t,position:[0,-.51,0],fontSize:.25,color:"black",rotation:[Math.PI/2,0,0],children:"Bottom"})]})};function rTn(n){n.querySelectorAll("canvas").forEach(e=>e.remove())}var oTn=n=>{n.outputColorSpace=k2,n.toneMapping=uNe,n.toneMappingExposure=1},Ret=fe.forwardRef(({children:n,scene:e,camera:t,style:i},r)=>{const o=fe.useRef(null),[s,a]=fe.useState(null),c=fe.useRef([]),l=fe.useCallback(p=>{c.current.push(p)},[]),u=fe.useCallback(p=>{c.current=c.current.filter(m=>m!==p)},[]),d=fe.useMemo(()=>new H9,[]);e?.up&&d.up.set(e.up.x,e.up.y,e.up.z);const h=fe.useRef(new Yp);return fe.useImperativeHandle(r,()=>h.current),fe.useEffect(()=>{if(!o.current)return;rTn(o.current);const p=new Zte({antialias:!0,alpha:!0});oTn(p),p.setSize(o.current.clientWidth,o.current.clientHeight),p.setPixelRatio(window.devicePixelRatio),o.current.appendChild(p.domElement);const m=new Vb(75,o.current.clientWidth/o.current.clientHeight,.1,1e3);t?.up&&m.up.set(t.up[0],t.up[1],t.up[2]),t?.position&&m.position.set(t.position[0],t.position[1],t.position[2]),m.lookAt(0,0,0),d.add(h.current),window.__TSCIRCUIT_THREE_OBJECT=h.current,a({scene:d,camera:m,renderer:p,rootObject:h.current,addFrameListener:l,removeFrameListener:u});let _;const g=new I8t,x=()=>{const w=g.getElapsedTime(),E=g.getDelta();c.current.forEach(N=>N(w,E)),p.render(d,m),_=requestAnimationFrame(x)};x();const b=()=>{o.current&&(m.aspect=o.current.clientWidth/o.current.clientHeight,m.updateProjectionMatrix(),p.setSize(o.current.clientWidth,o.current.clientHeight))};return window.addEventListener("resize",b),()=>{window.removeEventListener("resize",b),cancelAnimationFrame(_),o.current&&p.domElement&&o.current.removeChild(p.domElement),p.dispose(),d.remove(h.current),window.__TSCIRCUIT_THREE_OBJECT===h.current&&(window.__TSCIRCUIT_THREE_OBJECT=void 0)}},[d,l,u]),ce.jsx("div",{ref:o,style:{width:"100%",height:"100%",...i},children:s&&ce.jsx(aJe.Provider,{value:s,children:ce.jsx(rxn,{children:n})})})}),sTn=({autoRotate:n,autoRotateSpeed:e,onStart:t,panSpeed:i,rotateSpeed:r,zoomSpeed:o,enableDamping:s,dampingFactor:a,target:c,onControlsChange:l})=>{const{camera:u,renderer:d}=_b(),h=fe.useMemo(()=>!u||!d?null:new i7t(u,d.domElement),[u,d]);return fe.useEffect(()=>{if(l)return l(h??null),()=>{l(null)}},[h,l]),fe.useEffect(()=>{h&&(h.autoRotate=n||!1,h.autoRotateSpeed=e||1,i!==void 0&&(h.panSpeed=i),r!==void 0&&(h.rotateSpeed=r),o!==void 0&&(h.zoomSpeed=o),s!==void 0&&(h.enableDamping=s),a!==void 0&&(h.dampingFactor=a),h.zoomToCursor=!0,c&&(h.target.set(c[0],c[1],c[2]),h.update()))},[h,n,e,i,r,o,s,a,c]),fe.useEffect(()=>{if(!(!h||!t))return h.addEventListener("start",t),()=>{h.removeEventListener("start",t)}},[h,t]),fe.useEffect(()=>{if(h)return()=>{h.dispose()}},[h]),ZR(()=>{h?.update()},[h]),null},aTn=`
5084
5084
  varying vec3 worldPosition;
5085
5085
  void main() {
5086
5086
  worldPosition = (modelMatrix * vec4(position, 1.0)).xyz;
@@ -5114,12 +5114,12 @@ ${c.join(`
5114
5114
  gl_FragColor = vec4(color, max(g1, g2) * a);
5115
5115
  if (gl_FragColor.a <= 0.0) discard;
5116
5116
  }
5117
- `,lTn=({rotation:n,infiniteGrid:e,cellSize:t=1,sectionSize:i=10})=>{const{scene:r,camera:o}=_b(),s=1e3,a=fe.useMemo(()=>{const c=new BE(s,s);c.rotateX(-Math.PI/2);const l=new UE({vertexShader:aTn,fragmentShader:cTn,uniforms:{cellSize:{value:t},sectionSize:{value:i},gridColor:{value:new Jr(15658734)},sectionColor:{value:new Jr(13421823)},fadeDistance:{value:100},fadeStrength:{value:1.5}},transparent:!0,side:qg}),u=new Ma(c,l);return n&&u.rotation.fromArray(n),u},[s,t,i,n]);return ZR(()=>{e&&a.position.set(o.position.x,o.position.y,0)}),fe.useEffect(()=>{if(!(!r||!a))return r.add(a),()=>{r.remove(a),a.geometry.dispose(),Array.isArray(a.material)?a.material.forEach(c=>c.dispose()):a.material.dispose()}},[r,a]),null},uTn=()=>{const{scene:n}=_b(),e=fe.useMemo(()=>new OOe(16777215,Math.PI/2),[]),t=fe.useMemo(()=>{const i=new yne(16777215,Math.PI/4);return i.position.set(-10,-10,10),i.decay=0,i},[]);return fe.useEffect(()=>{if(n)return n.add(e),n.add(t),()=>{n.remove(e),n.remove(t)}},[n,e,t]),null},dTn=n=>n<.5?4*n*n*n:1-Math.pow(-2*n+2,3)/2,hTn=({defaultTarget:n,controlsRef:e,onReady:t})=>{const{camera:i}=_b(),r=fe.useRef(null),o=fe.useRef(new Mv),s=fe.useRef(new en),a=fe.useRef(new en),c=fe.useRef(new Mv),l=fe.useRef(new Mv),u=fe.useRef(new Yp),d=fe.useRef(new Yp),h=fe.useCallback(({position:p,target:m,up:_,durationMs:g=600})=>{if(!i)return;const x=e.current?.target??n,b=new en(p[0],p[1],p[2]),w=m?new en(m[0],m[1],m[2]):n.clone(),E=new en(..._??[0,0,1]).normalize(),N=d.current;N.position.copy(b),N.up.copy(E),N.lookAt(w);const A=N.quaternion.clone(),I=i.quaternion.clone(),M=i.position.clone(),k=x.clone(),C=u.current;C.up.set(0,0,1),C.position.copy(M),C.lookAt(k);const U=C.quaternion.clone();C.up.set(0,0,1),C.position.copy(b),C.lookAt(w);const O=C.quaternion.clone(),H=U.clone().invert().multiply(I).normalize(),Y=O.clone().invert().multiply(A).normalize();r.current={fromPosition:M,toPosition:b,fromTarget:k,toTarget:w,toQuaternion:A,rollFrom:H,rollTo:Y,startTime:performance.now(),duration:g}},[i,e,n]);return fe.useEffect(()=>{if(!(!t||!i))return t({animateTo:h}),()=>{t(null)}},[h,i,t]),ZR(()=>{if(!i||!r.current)return;const{fromPosition:p,toPosition:m,fromTarget:_,toTarget:g,toQuaternion:x,rollFrom:b,rollTo:w,startTime:E,duration:N}=r.current,A=performance.now()-E,I=N<=0?1:Math.min(A/N,1),M=dTn(I);i.position.lerpVectors(p,m,M);const k=s.current;k.copy(_).lerp(g,M);const C=u.current;C.up.set(0,0,1),C.position.copy(i.position),C.lookAt(k);const U=o.current;U.copy(C.quaternion);const O=c.current;O.copy(b);const H=l.current;H.copy(w),b.dot(w)<0&&(H.x*=-1,H.y*=-1,H.z*=-1,H.w*=-1),H.normalize(),O.slerp(H,M),i.quaternion.copy(U).multiply(O).normalize();const Y=a.current;Y.set(0,1,0).applyQuaternion(i.quaternion).normalize(),i.up.copy(Y),e.current?.target.copy(k),i.updateMatrixWorld(),e.current?.update(),I>=1&&(i.position.copy(m),i.quaternion.copy(x),i.up.set(0,0,1),i.updateMatrixWorld(),e.current?.target.copy(g),e.current?.update(),r.current=null)}),null},pTn=({defaultTarget:n,initialCameraPosition:e,onCameraControllerReady:t})=>{const i=fe.useRef(null),r=fe.useMemo(()=>{const[l,u,d]=e??[5,5,5],h=Math.hypot(l-n.x,u-n.y,d-n.z);return h>0?h:5},[e,n]),o=fe.useCallback(l=>{const u=[n.x,n.y,n.z],d=r,h=d*.3;switch(l){case"Top Centered":{const p=d/Math.sqrt(2);return{position:[n.x,n.y-p,n.z+p],target:u,up:[0,0,1]}}case"Top Down":return{position:[n.x,n.y,n.z+d],target:u,up:[0,0,1]};case"Top Left Corner":return{position:[n.x-d*.6,n.y-d*.6,n.z+d*.6],target:u,up:[0,0,1]};case"Top Right Corner":return{position:[n.x+d*.6,n.y-d*.6,n.z+d*.6],target:u,up:[0,0,1]};case"Left Sideview":return{position:[n.x-d,n.y,n.z+h],target:u,up:[0,0,1]};case"Right Sideview":return{position:[n.x+d,n.y,n.z+h],target:u,up:[0,0,1]};case"Front":return{position:[n.x,n.y-d,n.z+h],target:u,up:[0,0,1]};case"Custom":default:return null}},[r,n]),s=fe.useCallback(l=>{if(!t)return;if(!l){t(null);return}const u={animateTo:l.animateTo,animateToPreset:d=>{if(d==="Custom")return;const h=o(d);h&&l.animateTo(h)}};t(u)},[o,t]),a=fe.useCallback(l=>{i.current=l},[]);return{cameraAnimatorProps:fe.useMemo(()=>({defaultTarget:n,controlsRef:i,onReady:s}),[n,s]),handleControlsChange:a}},fTn=()=>{const{camera:n}=_b();return ZR(()=>{n&&(window.TSCI_MAIN_CAMERA_ROTATION=n.rotation)}),null},Iet=fe.forwardRef(({children:n,initialCameraPosition:e=[5,5,5],autoRotateDisabled:t,clickToInteractEnabled:i=!1,boardDimensions:r,boardCenter:o,onUserInteraction:s,onCameraControllerReady:a},c)=>{const[l,u]=fe.useState(!i),d=fe.useMemo(()=>{if(!r)return 10;const g=r.width??0,x=r.height??0,w=Math.max(g,x)*1.5;return w>10?w:10},[r]),h=fe.useMemo(()=>{if(o)return[o.x,o.y,0]},[o]),p=fe.useMemo(()=>h?new en(h[0],h[1],h[2]):new en(0,0,0),[h]),{cameraAnimatorProps:m,handleControlsChange:_}=pTn({defaultTarget:p,initialCameraPosition:e,onCameraControllerReady:a});return ce.jsxs("div",{style:{position:"relative",width:"100%",height:"100%"},children:[ce.jsx("div",{style:{position:"absolute",top:0,left:0,width:120,height:120},children:ce.jsx(Ret,{camera:{up:[0,0,1],position:[1,1,1]},style:{zIndex:10},children:ce.jsx(iTn,{})})}),ce.jsxs(Ret,{ref:c,scene:{up:new en(0,0,1)},camera:{up:[0,0,1],position:e},children:[ce.jsx(hTn,{...m}),ce.jsx(fTn,{}),l&&ce.jsx(sTn,{autoRotate:!t,autoRotateSpeed:1,onStart:s,rotateSpeed:.5,panSpeed:.75,zoomSpeed:.5,enableDamping:!0,dampingFactor:.1,target:h,onControlsChange:_}),ce.jsx(uTn,{}),ce.jsx(lTn,{rotation:[Math.PI/2,0,0],infiniteGrid:!0,cellSize:3,sectionSize:d,args:[d,d]}),n]}),ce.jsxs("div",{style:{position:"absolute",right:24,bottom:24,fontFamily:"sans-serif",color:"white",WebkitTextStroke:"0.5px rgba(0, 0, 0, 0.5)",fontSize:11},children:["@",Pet.version]}),i&&!l&&ce.jsx("button",{type:"button",onClick:()=>u(!0),onKeyDown:g=>{(g.key==="Enter"||g.key===" ")&&u(!0)},style:{position:"absolute",inset:0,cursor:"pointer",zIndex:10,display:"flex",alignItems:"center",justifyContent:"center"},children:ce.jsx("div",{style:{backgroundColor:"rgba(0, 0, 0, 0.8)",color:"white",padding:"12px 24px",borderRadius:"8px",fontSize:"16px",fontFamily:"sans-serif",pointerEvents:"none"},children:"Click to Interact"})})]})}),Net=n=>fe.useMemo(()=>{if(!n)return[];const e=new fun;return e.add(n),e.render(),e.getCircuitJson()},[n]),mTn=n=>{const[e,t]=fe.useState([]),[i,r]=fe.useState(!0);return fe.useEffect(()=>{if(!n)return;(async()=>{r(!0);const a=(Array.isArray(n)?n:[n]).map(async(c,l)=>{const u=hmn.serialize({binary:!0},[c]),h=await new Blob(u).arrayBuffer(),m=c.layerType||(l===0?"board":void 0);return{stlData:h,color:c.color,layerType:m}});try{const c=await Promise.all(a);t(c)}catch(c){console.error("Error generating STLs:",c),t([])}finally{r(!1)}})()},[n]),{stls:e,loading:i}},_Tn=vc(B5()),yTn=vc(r4()),Yl=.01,Iv={traces:.001,copper:.002},Zd={copper:[.9,.6,.2],fr4Green:[.04,.16,.08],fr4GreenSolderWithMask:[0/255,152/255,19/255],fr1Copper:[.8,.4,.2],fr1CopperSolderWithMask:[.9,.6,.2]},aT=.001,ZS=32,mV=.035,_V=50,Uye={fr1:Zd.fr1Copper,fr4:Zd.fr4Green},yV={fr1:Zd.fr1CopperSolderWithMask,fr4:Zd.fr4GreenSolderWithMask},gTn=vc(c4()),xTn=vc(B5()),bTn=vc(l4()),vTn=vc(n8()),Bye=n=>{let e=0;for(let i=0;i<n.length;i++){const r=(i+1)%n.length;e+=n[i][0]*n[r][1],e-=n[r][0]*n[i][1]}return e/2<=0},jye=(n,e=1.2,t={})=>{const{xyOutset:i=0}=t,{outline:r}=n;let o=r.map(c=>[c.x,c.y]);Bye(o)&&(o=o.reverse());let s=(0,xTn.polygon)({points:o});i!==0&&(s=(0,vTn.expand)({delta:i,corners:"edge"},s));let a=(0,gTn.extrudeLinear)({height:e},s);return a=(0,bTn.translate)([0,0,-e/2],a),a},wTn=n=>{const e=fs(n).pcb_board.list()[0];if(!e)return console.warn("No pcb_board found for simplified geometry"),[];let t;const i=1.2;e.outline&&e.outline.length>0?t=jye({outline:e.outline},i):t=(0,_Tn.cuboid)({size:[e.width,e.height,i],center:[e.center.x,e.center.y,0]});const r=Uye[e.material]??Zd.fr4Green;return[(0,yTn.colorize)(r,t)]},uw=vc(l4()),dp=vc(B5()),rS=vc(r4()),Ey=vc(t8()),A0=vc(B5()),y8=vc(r4()),jx=vc(t8()),Hye=vc(c4()),Vye=vc(l4());function hI(n,e,t){if(typeof t!="number"||!Number.isFinite(t)||t<=0)return 0;const i=n/2,r=e/2;return Math.max(0,Math.min(t,i,r))}function Y5(n){if(!(!n||typeof n!="object"))return n.corner_radius??n.cornerRadius??n.rect_pad_border_radius??n.rectPadBorderRadius??n.rect_border_radius??n.rectBorderRadius??void 0}var h4=.02,Gye=64,gV=(n,e)=>e?(0,jx.intersect)(e,n):n,xV=({width:n,height:e,thickness:t,center:i,borderRadius:r})=>{const o=hI(n,e,r);if(o<=0)return(0,A0.cuboid)({center:i,size:[n,e,t]});const s=(0,A0.roundedRectangle)({size:[n,e],roundRadius:o,segments:Gye}),a=(0,Hye.extrudeLinear)({height:t},s),c=i[2]-t/2;return(0,Vye.translate)([i[0],i[1],c],a)},ket=(n,e,t={})=>{const{clipGeom:i}=t;n.shape||(n.shape="circle");const r=e.pcbThickness+2*h4+4*Yl,o=e.pcbThickness/2+Iv.copper,s=-e.pcbThickness/2-Iv.copper,a=o-s;if(n.shape==="circle"){const c=n.outer_diameter??Math.max(n.hole_diameter,0),l=a+.01,u=(0,A0.cylinder)({center:[n.x,n.y,0],radius:c/2,height:l}),d=gV(u,i),h=(0,A0.cylinder)({center:[n.x,n.y,0],radius:Math.max(n.hole_diameter/2,.01),height:r});return(0,y8.colorize)(Zd.copper,(0,jx.subtract)(d,h))}if(n.shape==="circular_hole_with_rect_pad"){const c=n.hole_offset_x||0,l=n.hole_offset_y||0,u=n.rect_pad_width||n.hole_diameter,d=n.rect_pad_height||n.hole_diameter,h=Y5(n),p=gV((0,jx.union)(xV({width:u,height:d,thickness:h4,center:[n.x,n.y,o],borderRadius:h}),xV({width:u,height:d,thickness:h4,center:[n.x,n.y,s],borderRadius:h}),(()=>{const x=Math.max(a-h4*2,Yl),E=(o+s)/2,N=(0,A0.roundedRectangle)({size:[u,d],roundRadius:h||0,segments:Gye}),A=(0,Hye.extrudeLinear)({height:x},N);return(0,Vye.translate)([n.x,n.y,E-x/2],A)})(),(0,A0.cylinder)({center:[n.x+(c||0),n.y+(l||0),0],radius:n.hole_diameter/2,height:a})),i),m=(0,A0.cylinder)({center:[n.x+(c||0),n.y+(l||0),0],radius:Math.max(n.hole_diameter/2-Yl,.01),height:r}),_=(0,A0.cylinder)({center:[n.x+(c||0),n.y+(l||0),0],radius:n.hole_diameter/2,height:a});let g=(0,jx.union)((0,jx.subtract)(p,_),_);return t.clipGeom?(g=(0,jx.subtract)(g,m),g=(0,jx.intersect)(g,t.clipGeom),(0,y8.colorize)(Zd.copper,g)):(0,y8.colorize)(Zd.copper,(0,jx.subtract)(g,m))}if(n.shape==="pill"){const c=n.hole_height>n.hole_width,l=c?n.hole_height:n.hole_width,u=c?n.hole_width:n.hole_height,d=c?n.outer_height||u+.2:n.outer_width||l+.2,h=c?n.outer_width||l+.2:n.outer_height||u+.2,p=u/2,m=Math.abs(l-u),_=a+.01,x=((M,k,C)=>{const U=k/2,O=Math.abs(M-k);if(O<=1e-6)return(0,A0.cylinder)({center:[n.x,n.y,0],radius:U,height:C});const H=(0,A0.cuboid)({center:[n.x,n.y,0],size:c?[k,O,C]:[O,k,C]}),Y=(0,A0.cylinder)({center:c?[n.x,n.y-O/2,0]:[n.x-O/2,n.y,0],radius:U,height:C}),W=(0,A0.cylinder)({center:c?[n.x,n.y+O/2,0]:[n.x+O/2,n.y,0],radius:U,height:C});return(0,jx.union)(H,Y,W)})(d,h,_),b=(0,A0.cuboid)({center:[n.x,n.y,0],size:c?[u-2*Yl,m,r]:[m,u-2*Yl,r]}),w=(0,A0.cylinder)({center:c?[n.x,n.y-m/2,0]:[n.x-m/2,n.y,0],radius:p-Yl,height:r}),E=(0,A0.cylinder)({center:c?[n.x,n.y+m/2,0]:[n.x+m/2,n.y,0],radius:p-Yl,height:r}),N=(0,jx.union)(b,w,E),A=gV(x,i),I=N;return(0,y8.colorize)(Zd.copper,(0,jx.subtract)(A,I))}if(n.shape==="pill_hole_with_rect_pad"){const c=n.hole_offset_x||0,l=n.hole_offset_y||0,u=n.hole_height>n.hole_width,d=u?n.hole_height:n.hole_width,h=u?n.hole_width:n.hole_height,p=h/2,m=Math.abs(d-h),_=n.rect_pad_width||d+.2,g=n.rect_pad_height||h+.2,x=Y5(n),b=.03,w=(0,jx.union)((0,A0.cuboid)({center:[n.x+c,n.y+l,0],size:u?[h+2*b,m+2*b,a]:[m+2*b,h+2*b,a]}),(0,A0.cylinder)({center:u?[n.x+c,n.y+l-m/2,0]:[n.x+c-m/2,n.y+l,0],radius:p+b,height:a}),(0,A0.cylinder)({center:u?[n.x+c,n.y+l+m/2,0]:[n.x+c+m/2,n.y+l,0],radius:p+b,height:a})),E=(0,jx.union)((0,A0.cuboid)({center:[n.x+c,n.y+l,0],size:u?[h,m,r*1.1]:[m,h,r*1.1]}),(0,A0.cylinder)({center:u?[n.x+c,n.y+l-m/2,0]:[n.x+c-m/2,n.y+l,0],radius:p,height:r*1.1}),(0,A0.cylinder)({center:u?[n.x+c,n.y+l+m/2,0]:[n.x+c+m/2,n.y+l,0],radius:p,height:r*1.1})),N=xV({width:_,height:g,thickness:h4,center:[n.x,n.y,o],borderRadius:x}),A=xV({width:_,height:g,thickness:h4,center:[n.x,n.y,s],borderRadius:x}),I=(()=>{const Y=Math.max(a-h4*2,Yl),J=(o+s)/2,se=(0,A0.roundedRectangle)({size:[_,g],roundRadius:x||0,segments:Gye}),de=(0,Hye.extrudeLinear)({height:Y},se);return(0,Vye.translate)([n.x,n.y,J-Y/2],de)})(),M=(0,jx.subtract)(N,E),k=(0,jx.subtract)(A,E),C=(0,jx.subtract)(I,E),U=(0,jx.union)((0,A0.cuboid)({center:[n.x+c,n.y+l,0],size:u?[h-2*Yl,m-2*Yl,r*1.1]:[m-2*Yl,h-2*Yl,r*1.1]}),(0,A0.cylinder)({center:u?[n.x+c,n.y+l-m/2,0]:[n.x+c-m/2,n.y+l,0],radius:p-Yl,height:r*1.1}),(0,A0.cylinder)({center:u?[n.x+c,n.y+l+m/2,0]:[n.x+c+m/2,n.y+l,0],radius:p-Yl,height:r*1.1})),O=(0,jx.subtract)(w,U),H=gV((0,jx.union)(M,k,C,O),i);return(0,y8.colorize)(Zd.copper,H)}else throw new Error(`Unsupported plated hole shape: ${n.shape}`)},p4=vc(c4()),Yye=vc(n8()),STn=vc(Z_e());function Oet(n,e){return Array.isArray(e)?[n.a*e[0]+n.c*e[1]+n.e,n.b*e[0]+n.d*e[1]+n.f]:{x:n.a*e.x+n.c*e.y+n.e,y:n.b*e.x+n.d*e.y+n.f}}function jM(n,e=0){return{a:1,c:0,e:n,b:0,d:1,f:e}}function Let(...n){n=Array.isArray(n[0])?n[0]:n;const e=(t,i)=>({a:t.a*i.a+t.c*i.b,c:t.a*i.c+t.c*i.d,e:t.a*i.e+t.c*i.f+t.e,b:t.b*i.a+t.d*i.b,d:t.b*i.c+t.d*i.d,f:t.b*i.e+t.d*i.f+t.f});switch(n.length){case 0:throw new Error("no matrices provided");case 1:return n[0];case 2:return e(n[0],n[1]);default:{const[t,i,...r]=n,o=e(t,i);return Let(o,...r)}}}function Det(...n){return Let(...n)}var{cos:ETn,sin:TTn}=Math;function zet(n,e,t){const i=ETn(n),r=TTn(n);return{a:i,c:-r,e:0,b:r,d:i,f:0}}function MTn(n,e){function t(){this.constructor=n}t.prototype=e.prototype,n.prototype=new t}function bV(n,e,t,i){var r=Error.call(this,n);return Object.setPrototypeOf&&Object.setPrototypeOf(r,bV.prototype),r.expected=e,r.found=t,r.location=i,r.name="SyntaxError",r}MTn(bV,Error);function qye(n,e,t){return t=t||" ",n.length>e?n:(e-=n.length,t+=t.repeat(e),n+t.slice(0,e))}bV.prototype.format=function(n){var e="Error: "+this.message;if(this.location){var t=null,i;for(i=0;i<n.length;i++)if(n[i].source===this.location.source){t=n[i].text.split(/\r\n|\n|\r/g);break}var r=this.location.start,o=this.location.source&&typeof this.location.source.offset=="function"?this.location.source.offset(r):r,s=this.location.source+":"+o.line+":"+o.column;if(t){var a=this.location.end,c=qye("",o.line.toString().length," "),l=t[r.line-1],u=r.line===a.line?a.column:l.length+1,d=u-r.column||1;e+=`
5117
+ `,lTn=({rotation:n,infiniteGrid:e,cellSize:t=1,sectionSize:i=10})=>{const{scene:r,camera:o}=_b(),s=1e3,a=fe.useMemo(()=>{const c=new BE(s,s);c.rotateX(-Math.PI/2);const l=new UE({vertexShader:aTn,fragmentShader:cTn,uniforms:{cellSize:{value:t},sectionSize:{value:i},gridColor:{value:new Jr(15658734)},sectionColor:{value:new Jr(13421823)},fadeDistance:{value:100},fadeStrength:{value:1.5}},transparent:!0,side:qg}),u=new Ma(c,l);return n&&u.rotation.fromArray(n),u},[s,t,i,n]);return ZR(()=>{e&&a.position.set(o.position.x,o.position.y,0)}),fe.useEffect(()=>{if(!(!r||!a))return r.add(a),()=>{r.remove(a),a.geometry.dispose(),Array.isArray(a.material)?a.material.forEach(c=>c.dispose()):a.material.dispose()}},[r,a]),null},uTn=()=>{const{scene:n}=_b(),e=fe.useMemo(()=>new OOe(16777215,Math.PI/2),[]),t=fe.useMemo(()=>{const i=new yne(16777215,Math.PI/4);return i.position.set(-10,-10,10),i.decay=0,i},[]);return fe.useEffect(()=>{if(n)return n.add(e),n.add(t),()=>{n.remove(e),n.remove(t)}},[n,e,t]),null},dTn=n=>n<.5?4*n*n*n:1-Math.pow(-2*n+2,3)/2,hTn=({defaultTarget:n,controlsRef:e,onReady:t})=>{const{camera:i}=_b(),r=fe.useRef(null),o=fe.useRef(new Mv),s=fe.useRef(new en),a=fe.useRef(new en),c=fe.useRef(new Mv),l=fe.useRef(new Mv),u=fe.useRef(new Yp),d=fe.useRef(new Yp),h=fe.useCallback(({position:p,target:m,up:_,durationMs:g=600})=>{if(!i)return;const x=e.current?.target??n,b=new en(p[0],p[1],p[2]),w=m?new en(m[0],m[1],m[2]):n.clone(),E=new en(..._??[0,0,1]).normalize(),N=d.current;N.position.copy(b),N.up.copy(E),N.lookAt(w);const A=N.quaternion.clone(),I=i.quaternion.clone(),M=i.position.clone(),k=x.clone(),C=u.current;C.up.set(0,0,1),C.position.copy(M),C.lookAt(k);const U=C.quaternion.clone();C.up.set(0,0,1),C.position.copy(b),C.lookAt(w);const O=C.quaternion.clone(),H=U.clone().invert().multiply(I).normalize(),Y=O.clone().invert().multiply(A).normalize();r.current={fromPosition:M,toPosition:b,fromTarget:k,toTarget:w,toQuaternion:A,rollFrom:H,rollTo:Y,startTime:performance.now(),duration:g}},[i,e,n]);return fe.useEffect(()=>{if(!(!t||!i))return t({animateTo:h}),()=>{t(null)}},[h,i,t]),ZR(()=>{if(!i||!r.current)return;const{fromPosition:p,toPosition:m,fromTarget:_,toTarget:g,toQuaternion:x,rollFrom:b,rollTo:w,startTime:E,duration:N}=r.current,A=performance.now()-E,I=N<=0?1:Math.min(A/N,1),M=dTn(I);i.position.lerpVectors(p,m,M);const k=s.current;k.copy(_).lerp(g,M);const C=u.current;C.up.set(0,0,1),C.position.copy(i.position),C.lookAt(k);const U=o.current;U.copy(C.quaternion);const O=c.current;O.copy(b);const H=l.current;H.copy(w),b.dot(w)<0&&(H.x*=-1,H.y*=-1,H.z*=-1,H.w*=-1),H.normalize(),O.slerp(H,M),i.quaternion.copy(U).multiply(O).normalize();const Y=a.current;Y.set(0,1,0).applyQuaternion(i.quaternion).normalize(),i.up.copy(Y),e.current?.target.copy(k),i.updateMatrixWorld(),e.current?.update(),I>=1&&(i.position.copy(m),i.quaternion.copy(x),i.up.set(0,0,1),i.updateMatrixWorld(),e.current?.target.copy(g),e.current?.update(),r.current=null)}),null},pTn=({defaultTarget:n,initialCameraPosition:e,onCameraControllerReady:t})=>{const i=fe.useRef(null),r=fe.useMemo(()=>{const[l,u,d]=e??[5,-5,5],h=Math.hypot(l-n.x,u-n.y,d-n.z);return h>0?h:5},[e,n]),o=fe.useCallback(l=>{const u=[n.x,n.y,n.z],d=r,h=d*.3;switch(l){case"Top Centered":{const p=d/Math.sqrt(2);return{position:[n.x,n.y-p,n.z+p],target:u,up:[0,0,1]}}case"Top Down":return{position:[n.x,n.y,n.z+d],target:u,up:[0,0,1]};case"Top Left Corner":return{position:[n.x-d*.6,n.y-d*.6,n.z+d*.6],target:u,up:[0,0,1]};case"Top Right Corner":return{position:[n.x+d*.6,n.y-d*.6,n.z+d*.6],target:u,up:[0,0,1]};case"Left Sideview":return{position:[n.x-d,n.y,n.z+h],target:u,up:[0,0,1]};case"Right Sideview":return{position:[n.x+d,n.y,n.z+h],target:u,up:[0,0,1]};case"Front":return{position:[n.x,n.y-d,n.z+h],target:u,up:[0,0,1]};case"Custom":default:return null}},[r,n]),s=fe.useCallback(l=>{if(!t)return;if(!l){t(null);return}const u={animateTo:l.animateTo,animateToPreset:d=>{if(d==="Custom")return;const h=o(d);h&&l.animateTo(h)}};t(u)},[o,t]),a=fe.useCallback(l=>{i.current=l},[]);return{cameraAnimatorProps:fe.useMemo(()=>({defaultTarget:n,controlsRef:i,onReady:s}),[n,s]),handleControlsChange:a}},fTn=()=>{const{camera:n}=_b();return ZR(()=>{n&&(window.TSCI_MAIN_CAMERA_ROTATION=n.rotation)}),null},Iet=fe.forwardRef(({children:n,initialCameraPosition:e=[5,-5,5],autoRotateDisabled:t,clickToInteractEnabled:i=!1,boardDimensions:r,boardCenter:o,onUserInteraction:s,onCameraControllerReady:a},c)=>{const[l,u]=fe.useState(!i),d=fe.useMemo(()=>{if(!r)return 10;const g=r.width??0,x=r.height??0,w=Math.max(g,x)*1.5;return w>10?w:10},[r]),h=fe.useMemo(()=>{if(o)return[o.x,o.y,0]},[o]),p=fe.useMemo(()=>h?new en(h[0],h[1],h[2]):new en(0,0,0),[h]),{cameraAnimatorProps:m,handleControlsChange:_}=pTn({defaultTarget:p,initialCameraPosition:e,onCameraControllerReady:a});return ce.jsxs("div",{style:{position:"relative",width:"100%",height:"100%"},children:[ce.jsx("div",{style:{position:"absolute",top:0,left:0,width:120,height:120},children:ce.jsx(Ret,{camera:{up:[0,0,1],position:[1,1,1]},style:{zIndex:10},children:ce.jsx(iTn,{})})}),ce.jsxs(Ret,{ref:c,scene:{up:new en(0,0,1)},camera:{up:[0,0,1],position:e},children:[ce.jsx(hTn,{...m}),ce.jsx(fTn,{}),l&&ce.jsx(sTn,{autoRotate:!t,autoRotateSpeed:1,onStart:s,rotateSpeed:.5,panSpeed:.75,zoomSpeed:.5,enableDamping:!0,dampingFactor:.1,target:h,onControlsChange:_}),ce.jsx(uTn,{}),ce.jsx(lTn,{rotation:[Math.PI/2,0,0],infiniteGrid:!0,cellSize:3,sectionSize:d,args:[d,d]}),n]}),ce.jsxs("div",{style:{position:"absolute",right:24,bottom:24,fontFamily:"sans-serif",color:"white",WebkitTextStroke:"0.5px rgba(0, 0, 0, 0.5)",fontSize:11},children:["@",Pet.version]}),i&&!l&&ce.jsx("button",{type:"button",onClick:()=>u(!0),onKeyDown:g=>{(g.key==="Enter"||g.key===" ")&&u(!0)},style:{position:"absolute",inset:0,cursor:"pointer",zIndex:10,display:"flex",alignItems:"center",justifyContent:"center"},children:ce.jsx("div",{style:{backgroundColor:"rgba(0, 0, 0, 0.8)",color:"white",padding:"12px 24px",borderRadius:"8px",fontSize:"16px",fontFamily:"sans-serif",pointerEvents:"none"},children:"Click to Interact"})})]})}),Net=n=>fe.useMemo(()=>{if(!n)return[];const e=new fun;return e.add(n),e.render(),e.getCircuitJson()},[n]),mTn=n=>{const[e,t]=fe.useState([]),[i,r]=fe.useState(!0);return fe.useEffect(()=>{if(!n)return;(async()=>{r(!0);const a=(Array.isArray(n)?n:[n]).map(async(c,l)=>{const u=hmn.serialize({binary:!0},[c]),h=await new Blob(u).arrayBuffer(),m=c.layerType||(l===0?"board":void 0);return{stlData:h,color:c.color,layerType:m}});try{const c=await Promise.all(a);t(c)}catch(c){console.error("Error generating STLs:",c),t([])}finally{r(!1)}})()},[n]),{stls:e,loading:i}},_Tn=vc(B5()),yTn=vc(r4()),Yl=.01,Iv={traces:.001,copper:.002},Zd={copper:[.9,.6,.2],fr4Green:[.04,.16,.08],fr4GreenSolderWithMask:[0/255,152/255,19/255],fr1Copper:[.8,.4,.2],fr1CopperSolderWithMask:[.9,.6,.2]},aT=.001,ZS=32,mV=.035,_V=50,Uye={fr1:Zd.fr1Copper,fr4:Zd.fr4Green},yV={fr1:Zd.fr1CopperSolderWithMask,fr4:Zd.fr4GreenSolderWithMask},gTn=vc(c4()),xTn=vc(B5()),bTn=vc(l4()),vTn=vc(n8()),Bye=n=>{let e=0;for(let i=0;i<n.length;i++){const r=(i+1)%n.length;e+=n[i][0]*n[r][1],e-=n[r][0]*n[i][1]}return e/2<=0},jye=(n,e=1.2,t={})=>{const{xyOutset:i=0}=t,{outline:r}=n;let o=r.map(c=>[c.x,c.y]);Bye(o)&&(o=o.reverse());let s=(0,xTn.polygon)({points:o});i!==0&&(s=(0,vTn.expand)({delta:i,corners:"edge"},s));let a=(0,gTn.extrudeLinear)({height:e},s);return a=(0,bTn.translate)([0,0,-e/2],a),a},wTn=n=>{const e=fs(n).pcb_board.list()[0];if(!e)return console.warn("No pcb_board found for simplified geometry"),[];let t;const i=1.2;e.outline&&e.outline.length>0?t=jye({outline:e.outline},i):t=(0,_Tn.cuboid)({size:[e.width,e.height,i],center:[e.center.x,e.center.y,0]});const r=Uye[e.material]??Zd.fr4Green;return[(0,yTn.colorize)(r,t)]},uw=vc(l4()),dp=vc(B5()),rS=vc(r4()),Ey=vc(t8()),A0=vc(B5()),y8=vc(r4()),jx=vc(t8()),Hye=vc(c4()),Vye=vc(l4());function hI(n,e,t){if(typeof t!="number"||!Number.isFinite(t)||t<=0)return 0;const i=n/2,r=e/2;return Math.max(0,Math.min(t,i,r))}function Y5(n){if(!(!n||typeof n!="object"))return n.corner_radius??n.cornerRadius??n.rect_pad_border_radius??n.rectPadBorderRadius??n.rect_border_radius??n.rectBorderRadius??void 0}var h4=.02,Gye=64,gV=(n,e)=>e?(0,jx.intersect)(e,n):n,xV=({width:n,height:e,thickness:t,center:i,borderRadius:r})=>{const o=hI(n,e,r);if(o<=0)return(0,A0.cuboid)({center:i,size:[n,e,t]});const s=(0,A0.roundedRectangle)({size:[n,e],roundRadius:o,segments:Gye}),a=(0,Hye.extrudeLinear)({height:t},s),c=i[2]-t/2;return(0,Vye.translate)([i[0],i[1],c],a)},ket=(n,e,t={})=>{const{clipGeom:i}=t;n.shape||(n.shape="circle");const r=e.pcbThickness+2*h4+4*Yl,o=e.pcbThickness/2+Iv.copper,s=-e.pcbThickness/2-Iv.copper,a=o-s;if(n.shape==="circle"){const c=n.outer_diameter??Math.max(n.hole_diameter,0),l=a+.01,u=(0,A0.cylinder)({center:[n.x,n.y,0],radius:c/2,height:l}),d=gV(u,i),h=(0,A0.cylinder)({center:[n.x,n.y,0],radius:Math.max(n.hole_diameter/2,.01),height:r});return(0,y8.colorize)(Zd.copper,(0,jx.subtract)(d,h))}if(n.shape==="circular_hole_with_rect_pad"){const c=n.hole_offset_x||0,l=n.hole_offset_y||0,u=n.rect_pad_width||n.hole_diameter,d=n.rect_pad_height||n.hole_diameter,h=Y5(n),p=gV((0,jx.union)(xV({width:u,height:d,thickness:h4,center:[n.x,n.y,o],borderRadius:h}),xV({width:u,height:d,thickness:h4,center:[n.x,n.y,s],borderRadius:h}),(()=>{const x=Math.max(a-h4*2,Yl),E=(o+s)/2,N=(0,A0.roundedRectangle)({size:[u,d],roundRadius:h||0,segments:Gye}),A=(0,Hye.extrudeLinear)({height:x},N);return(0,Vye.translate)([n.x,n.y,E-x/2],A)})(),(0,A0.cylinder)({center:[n.x+(c||0),n.y+(l||0),0],radius:n.hole_diameter/2,height:a})),i),m=(0,A0.cylinder)({center:[n.x+(c||0),n.y+(l||0),0],radius:Math.max(n.hole_diameter/2-Yl,.01),height:r}),_=(0,A0.cylinder)({center:[n.x+(c||0),n.y+(l||0),0],radius:n.hole_diameter/2,height:a});let g=(0,jx.union)((0,jx.subtract)(p,_),_);return t.clipGeom?(g=(0,jx.subtract)(g,m),g=(0,jx.intersect)(g,t.clipGeom),(0,y8.colorize)(Zd.copper,g)):(0,y8.colorize)(Zd.copper,(0,jx.subtract)(g,m))}if(n.shape==="pill"){const c=n.hole_height>n.hole_width,l=c?n.hole_height:n.hole_width,u=c?n.hole_width:n.hole_height,d=c?n.outer_height||u+.2:n.outer_width||l+.2,h=c?n.outer_width||l+.2:n.outer_height||u+.2,p=u/2,m=Math.abs(l-u),_=a+.01,x=((M,k,C)=>{const U=k/2,O=Math.abs(M-k);if(O<=1e-6)return(0,A0.cylinder)({center:[n.x,n.y,0],radius:U,height:C});const H=(0,A0.cuboid)({center:[n.x,n.y,0],size:c?[k,O,C]:[O,k,C]}),Y=(0,A0.cylinder)({center:c?[n.x,n.y-O/2,0]:[n.x-O/2,n.y,0],radius:U,height:C}),W=(0,A0.cylinder)({center:c?[n.x,n.y+O/2,0]:[n.x+O/2,n.y,0],radius:U,height:C});return(0,jx.union)(H,Y,W)})(d,h,_),b=(0,A0.cuboid)({center:[n.x,n.y,0],size:c?[u-2*Yl,m,r]:[m,u-2*Yl,r]}),w=(0,A0.cylinder)({center:c?[n.x,n.y-m/2,0]:[n.x-m/2,n.y,0],radius:p-Yl,height:r}),E=(0,A0.cylinder)({center:c?[n.x,n.y+m/2,0]:[n.x+m/2,n.y,0],radius:p-Yl,height:r}),N=(0,jx.union)(b,w,E),A=gV(x,i),I=N;return(0,y8.colorize)(Zd.copper,(0,jx.subtract)(A,I))}if(n.shape==="pill_hole_with_rect_pad"){const c=n.hole_offset_x||0,l=n.hole_offset_y||0,u=n.hole_height>n.hole_width,d=u?n.hole_height:n.hole_width,h=u?n.hole_width:n.hole_height,p=h/2,m=Math.abs(d-h),_=n.rect_pad_width||d+.2,g=n.rect_pad_height||h+.2,x=Y5(n),b=.03,w=(0,jx.union)((0,A0.cuboid)({center:[n.x+c,n.y+l,0],size:u?[h+2*b,m+2*b,a]:[m+2*b,h+2*b,a]}),(0,A0.cylinder)({center:u?[n.x+c,n.y+l-m/2,0]:[n.x+c-m/2,n.y+l,0],radius:p+b,height:a}),(0,A0.cylinder)({center:u?[n.x+c,n.y+l+m/2,0]:[n.x+c+m/2,n.y+l,0],radius:p+b,height:a})),E=(0,jx.union)((0,A0.cuboid)({center:[n.x+c,n.y+l,0],size:u?[h,m,r*1.1]:[m,h,r*1.1]}),(0,A0.cylinder)({center:u?[n.x+c,n.y+l-m/2,0]:[n.x+c-m/2,n.y+l,0],radius:p,height:r*1.1}),(0,A0.cylinder)({center:u?[n.x+c,n.y+l+m/2,0]:[n.x+c+m/2,n.y+l,0],radius:p,height:r*1.1})),N=xV({width:_,height:g,thickness:h4,center:[n.x,n.y,o],borderRadius:x}),A=xV({width:_,height:g,thickness:h4,center:[n.x,n.y,s],borderRadius:x}),I=(()=>{const Y=Math.max(a-h4*2,Yl),J=(o+s)/2,se=(0,A0.roundedRectangle)({size:[_,g],roundRadius:x||0,segments:Gye}),de=(0,Hye.extrudeLinear)({height:Y},se);return(0,Vye.translate)([n.x,n.y,J-Y/2],de)})(),M=(0,jx.subtract)(N,E),k=(0,jx.subtract)(A,E),C=(0,jx.subtract)(I,E),U=(0,jx.union)((0,A0.cuboid)({center:[n.x+c,n.y+l,0],size:u?[h-2*Yl,m-2*Yl,r*1.1]:[m-2*Yl,h-2*Yl,r*1.1]}),(0,A0.cylinder)({center:u?[n.x+c,n.y+l-m/2,0]:[n.x+c-m/2,n.y+l,0],radius:p-Yl,height:r*1.1}),(0,A0.cylinder)({center:u?[n.x+c,n.y+l+m/2,0]:[n.x+c+m/2,n.y+l,0],radius:p-Yl,height:r*1.1})),O=(0,jx.subtract)(w,U),H=gV((0,jx.union)(M,k,C,O),i);return(0,y8.colorize)(Zd.copper,H)}else throw new Error(`Unsupported plated hole shape: ${n.shape}`)},p4=vc(c4()),Yye=vc(n8()),STn=vc(Z_e());function Oet(n,e){return Array.isArray(e)?[n.a*e[0]+n.c*e[1]+n.e,n.b*e[0]+n.d*e[1]+n.f]:{x:n.a*e.x+n.c*e.y+n.e,y:n.b*e.x+n.d*e.y+n.f}}function jM(n,e=0){return{a:1,c:0,e:n,b:0,d:1,f:e}}function Let(...n){n=Array.isArray(n[0])?n[0]:n;const e=(t,i)=>({a:t.a*i.a+t.c*i.b,c:t.a*i.c+t.c*i.d,e:t.a*i.e+t.c*i.f+t.e,b:t.b*i.a+t.d*i.b,d:t.b*i.c+t.d*i.d,f:t.b*i.e+t.d*i.f+t.f});switch(n.length){case 0:throw new Error("no matrices provided");case 1:return n[0];case 2:return e(n[0],n[1]);default:{const[t,i,...r]=n,o=e(t,i);return Let(o,...r)}}}function Det(...n){return Let(...n)}var{cos:ETn,sin:TTn}=Math;function zet(n,e,t){const i=ETn(n),r=TTn(n);return{a:i,c:-r,e:0,b:r,d:i,f:0}}function MTn(n,e){function t(){this.constructor=n}t.prototype=e.prototype,n.prototype=new t}function bV(n,e,t,i){var r=Error.call(this,n);return Object.setPrototypeOf&&Object.setPrototypeOf(r,bV.prototype),r.expected=e,r.found=t,r.location=i,r.name="SyntaxError",r}MTn(bV,Error);function qye(n,e,t){return t=t||" ",n.length>e?n:(e-=n.length,t+=t.repeat(e),n+t.slice(0,e))}bV.prototype.format=function(n){var e="Error: "+this.message;if(this.location){var t=null,i;for(i=0;i<n.length;i++)if(n[i].source===this.location.source){t=n[i].text.split(/\r\n|\n|\r/g);break}var r=this.location.start,o=this.location.source&&typeof this.location.source.offset=="function"?this.location.source.offset(r):r,s=this.location.source+":"+o.line+":"+o.column;if(t){var a=this.location.end,c=qye("",o.line.toString().length," "),l=t[r.line-1],u=r.line===a.line?a.column:l.length+1,d=u-r.column||1;e+=`
5118
5118
  --> `+s+`
5119
5119
  `+c+` |
5120
5120
  `+o.line+" | "+l+`
5121
5121
  `+c+" | "+qye("",r.column-1," ")+qye("",d,"^")}else e+=`
5122
- at `+s}return e},bV.buildMessage=function(n,e){var t={literal:function(l){return'"'+r(l.text)+'"'},class:function(l){var u=l.parts.map(function(d){return Array.isArray(d)?o(d[0])+"-"+o(d[1]):o(d)});return"["+(l.inverted?"^":"")+u.join("")+"]"},any:function(){return"any character"},end:function(){return"end of input"},other:function(l){return l.description}};function i(l){return l.charCodeAt(0).toString(16).toUpperCase()}function r(l){return l.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,function(u){return"\\x0"+i(u)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(u){return"\\x"+i(u)})}function o(l){return l.replace(/\\/g,"\\\\").replace(/\]/g,"\\]").replace(/\^/g,"\\^").replace(/-/g,"\\-").replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,function(u){return"\\x0"+i(u)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(u){return"\\x"+i(u)})}function s(l){return t[l.type](l)}function a(l){var u=l.map(s),d,h;if(u.sort(),u.length>0){for(d=1,h=1;d<u.length;d++)u[d-1]!==u[d]&&(u[h]=u[d],h++);u.length=h}switch(u.length){case 1:return u[0];case 2:return u[0]+" or "+u[1];default:return u.slice(0,-1).join(", ")+", or "+u[u.length-1]}}function c(l){return l?'"'+r(l)+'"':"end of input"}return"Expected "+a(n)+" but "+c(e)+" found."};function CTn(n){const e=(0,STn.vectorText)({height:n.font_size*.45,input:n.text});let t=n.ccw_rotation??0;e.forEach(d=>{d.length===29?(e.splice(e.indexOf(d),1,d.slice(0,15)),e.splice(e.indexOf(d),0,d.slice(14,29))):d.length===17&&(e.splice(e.indexOf(d),1,d.slice(0,10)),e.splice(e.indexOf(d),0,d.slice(9,17)))});const i=e.flatMap(d=>d),r={minX:Math.min(...i.map(d=>d[0])),maxX:Math.max(...i.map(d=>d[0])),minY:Math.min(...i.map(d=>d[1])),maxY:Math.max(...i.map(d=>d[1]))},o=(r.minX+r.maxX)/2,s=(r.minY+r.maxY)/2;let a=-o,c=-s;n.anchor_alignment?.includes("right")?a=-r.maxX:n.anchor_alignment?.includes("left")&&(a=-r.minX),n.anchor_alignment?.includes("top")?c=-r.maxY:n.anchor_alignment?.includes("bottom")&&(c=-r.minY);const l=[];if(n.layer==="bottom"&&(l.push(jM(o,s),{a:-1,b:0,c:0,d:1,e:0,f:0},jM(-o,-s)),t=-t),t){const d=t*Math.PI/180;l.push(jM(o,s),zet(d),jM(-o,-s))}let u=e;if(l.length>0){const d=Det(...l);u=e.map(h=>h.map(([p,m])=>{const{x:_,y:g}=Oet(d,{x:p,y:m});return[_,g]}))}return{textOutlines:u,xOffset:a,yOffset:c}}var ATn=vc(B5()),PTn=vc(n8()),RTn=vc(c4()),ITn=vc(l4()),NTn=vc(r4()),$et=25.4,kTn=$et/1e3,OTn=/^\s*(-?\d*(?:\.\d+)?)(?:\s*(mm|mil|inch|in|"))?\s*$/i;function LTn(n){if(!n)return;const e=n.trim().toLowerCase();return e==='"'||e==="inch"?"in":e}function Hx(n){if(n==null)return;if(typeof n=="number")return Number.isFinite(n)?n:void 0;if(typeof n!="string")return;const e=n.trim();if(e.length===0)return;const t=e.match(OTn);if(!t){const a=Number.parseFloat(e);return Number.isFinite(a)?a:void 0}const[,i,r]=t,o=Number.parseFloat(i||"0");if(!Number.isFinite(o))return;switch(LTn(r)){case"mil":return o*kTn;case"in":return o*$et;case"mm":case void 0:return o;default:return o}}function cT(n,e){const t=Hx(n);return t===void 0?e:t}function DTn(n,e){if(n.route.length<2)return;const t=n.route.map(l=>[Hx(l.x)??0,Hx(l.y)??0]),i=(0,ATn.line)(t),r=cT(n.stroke_width,.1),o=(0,PTn.expand)({delta:r/2,corners:"round"},i),s=n.layer==="bottom"?-1:1,a=s*e.pcbThickness/2+s*Yl*1.5;let c=(0,ITn.translate)([0,0,a],(0,RTn.extrudeLinear)({height:.012},o));return c=(0,NTn.colorize)([1,1,1],c),c}var zTn=vc(B5()),$Tn=vc(n8()),FTn=vc(c4()),UTn=vc(l4()),BTn=vc(r4());function jTn(n,e){const t=Hx(n.x1)??0,i=Hx(n.y1)??0,r=Hx(n.x2)??0,o=Hx(n.y2)??0;if(t===r&&i===o)return;const s=[[t,i],[r,o]],a=(0,zTn.line)(s),c=cT(n.stroke_width,.1),l=(0,$Tn.expand)({delta:c/2,corners:"round"},a),u=n.layer==="bottom"?-1:1,d=u*e.pcbThickness/2+u*Yl*1.5;let h=(0,UTn.translate)([0,0,d],(0,FTn.extrudeLinear)({height:.012},l));return h=(0,BTn.colorize)([1,1,1],h),h}var HTn=vc(B5()),VTn=vc(c4()),GTn=vc(l4()),YTn=vc(r4()),Fet=vc(t8()),qTn=64;function XTn(n,e){const t=cT(n.width,0),i=cT(n.height,0);if(t<=0||i<=0)return;const r=Hx(n.center?.x)??0,o=Hx(n.center?.y)??0,s=Y5(n),a=hI(t,i,typeof s=="string"?Hx(s):s),c=(x,b,w)=>(0,VTn.extrudeLinear)({height:.012},(0,HTn.roundedRectangle)({size:[x,b],roundRadius:w,segments:qTn})),l=n.is_filled??!0,u=n.has_stroke??!1,d=u?cT(n.stroke_width,.1):0;let h;l&&(h=c(t,i,a));let p;if(u&&d>0){const x=c(t,i,a),b=t-d*2,w=i-d*2;if(b>0&&w>0){const E=hI(b,w,Math.max(a-d,0)),N=c(b,w,E);p=(0,Fet.subtract)(x,N)}else p=x}let m=h;if(p&&(m=m?(0,Fet.union)(m,p):p),!m)return;const _=n.layer==="bottom"?-1:1,g=_*e.pcbThickness/2+_*Yl*1.5;return m=(0,GTn.translate)([r,o,g],m),(0,YTn.colorize)([1,1,1],m)}var Uet=vc(B5()),WTn=vc(t8());function KTn(n,e,t,i){if(!t||Math.abs(t)<1e-9)return[];const r=4*Math.atan(t),o=e[0]-n[0],s=e[1]-n[1],a=Math.sqrt(o*o+s*s);if(a<1e-9)return[];const c=Math.abs(a/(2*Math.sin(r/2))),l=Math.sqrt(Math.max(0,c*c-a/2*(a/2))),u=[(n[0]+e[0])/2,(n[1]+e[1])/2],d=o/a,p=-(s/a),m=d,_=u[0]+p*l*Math.sign(t),g=u[1]+m*l*Math.sign(t),x=Math.atan2(n[1]-g,n[0]-_),b=[],w=Math.max(2,Math.ceil(i*Math.abs(r)/(Math.PI*2)*4)),E=r/w;for(let N=1;N<w;N++){const A=x+E*N;b.push([_+c*Math.cos(A),g+c*Math.sin(A)])}return b}function Bet(n,e){const t=[],i=n.vertices;for(let r=0;r<i.length;r++){const o=i[r],s=i[(r+1)%i.length];if(t.push([o.x,o.y]),o.bulge){const a=KTn([o.x,o.y],[s.x,s.y],o.bulge,e);t.push(...a)}}return t}function jet(n){let e=0;for(let t=0;t<n.length;t++){const i=(t+1)%n.length;e+=n[t][0]*n[i][1],e-=n[i][0]*n[t][1]}return e/2<=0}function ZTn(n,e=16){let t=Bet(n.outer_ring,e);jet(t)&&t.reverse();const i=(0,Uet.polygon)({points:t});if(!n.inner_rings||n.inner_rings.length===0)return i;const r=n.inner_rings.map(o=>{let s=Bet(o,e);return jet(s)&&s.reverse(),(0,Uet.polygon)({points:s})});return r.length===0?i:(0,WTn.subtract)(i,r)}var QTn=64,JTn=1,Xye=.05,Het=(n,e,t,i)=>{const r=hI(n,e,i);if(r<=0)return(0,dp.cuboid)({center:[0,0,0],size:[n,e,t]});const o=(0,dp.roundedRectangle)({size:[n,e],roundRadius:r,segments:QTn}),s=(0,p4.extrudeLinear)({height:t},o);return(0,uw.translate)([0,0,-t/2],s)},Vet=["initializing","processing_pads","processing_copper_pours","processing_plated_holes","processing_holes","processing_cutouts","processing_traces","processing_vias","processing_silkscreen_text","processing_silkscreen_lines","processing_silkscreen_rects","processing_silkscreen_paths","finalizing","done"],e5n=class{circuitJson;board;plated_holes;holes;pads;traces;pcb_vias;silkscreenTexts;silkscreenPaths;silkscreenLines;silkscreenRects;pcb_cutouts;pcb_copper_pours;boardGeom=null;platedHoleGeoms=[];holeGeoms=[];padGeoms=[];traceGeoms=[];viaGeoms=[];silkscreenTextGeoms=[];silkscreenPathGeoms=[];silkscreenLineGeoms=[];silkscreenRectGeoms=[];copperPourGeoms=[];boardClipGeom=null;state="initializing";currentIndex=0;ctx;onCompleteCallback;finalGeoms=[];getHoleToCut(n,e){const t=Yl/10;for(const i of this.pcb_vias)if(Math.abs(i.x-n)<t&&Math.abs(i.y-e)<t&&i.hole_diameter)return{diameter:i.hole_diameter};for(const i of this.plated_holes)if(i.shape==="circle"&&Math.abs(i.x-n)<t&&Math.abs(i.y-e)<t&&i.hole_diameter)return{diameter:i.hole_diameter};return null}constructor(n,e){this.circuitJson=n,this.onCompleteCallback=e,this.board=fs(n).pcb_board.list()[0],this.plated_holes=fs(n).pcb_plated_hole.list(),this.holes=fs(n).pcb_hole.list(),this.pads=fs(n).pcb_smtpad.list(),this.traces=fs(n).pcb_trace.list(),this.pcb_vias=fs(n).pcb_via.list(),this.silkscreenTexts=fs(n).pcb_silkscreen_text.list(),this.silkscreenPaths=fs(n).pcb_silkscreen_path.list(),this.silkscreenLines=fs(n).pcb_silkscreen_line.list(),this.silkscreenRects=fs(n).pcb_silkscreen_rect.list(),this.pcb_cutouts=fs(n).pcb_cutout.list(),this.pcb_copper_pours=n.filter(t=>t.type==="pcb_copper_pour"),this.ctx={pcbThickness:this.board.thickness??1.2},this.initializeBoard()}initializeBoard(){const n=this.ctx.pcbThickness+2*JTn;this.board.outline&&this.board.outline.length>0?(this.boardGeom=jye({outline:this.board.outline},this.ctx.pcbThickness),this.boardClipGeom=jye({outline:this.board.outline},n,{xyOutset:Xye})):(this.boardGeom=(0,dp.cuboid)({size:[this.board.width,this.board.height,this.ctx.pcbThickness],center:[this.board.center.x,this.board.center.y,0]}),this.boardClipGeom=(0,dp.cuboid)({size:[this.board.width+2*Xye,this.board.height+2*Xye,n],center:[this.board.center.x,this.board.center.y,0]})),this.state="processing_pads",this.currentIndex=0}goToNextState(){const n=Vet.indexOf(this.state);n!==-1&&(this.state=Vet[n+1],this.currentIndex=0)}step(n=1){if(this.state==="done"||!this.boardGeom)return!0;for(let e=0;e<n&&this.state!=="done";e++)switch(this.state){case"processing_plated_holes":this.currentIndex<this.plated_holes.length?(this.processPlatedHole(this.plated_holes[this.currentIndex]),this.currentIndex++):this.goToNextState();break;case"processing_holes":this.currentIndex<this.holes.length?(this.processHole(this.holes[this.currentIndex]),this.currentIndex++):this.goToNextState();break;case"processing_pads":this.currentIndex<this.pads.length?(this.processPad(this.pads[this.currentIndex]),this.currentIndex++):this.goToNextState();break;case"processing_traces":this.currentIndex<this.traces.length?(this.processTrace(this.traces[this.currentIndex]),this.currentIndex++):this.goToNextState();break;case"processing_vias":this.currentIndex<this.pcb_vias.length?(this.processVia(this.pcb_vias[this.currentIndex]),this.currentIndex++):this.goToNextState();break;case"processing_silkscreen_text":this.currentIndex<this.silkscreenTexts.length?(this.processSilkscreenText(this.silkscreenTexts[this.currentIndex]),this.currentIndex++):this.goToNextState();break;case"processing_silkscreen_lines":this.currentIndex<this.silkscreenLines.length?(this.processSilkscreenLine(this.silkscreenLines[this.currentIndex]),this.currentIndex++):this.goToNextState();break;case"processing_silkscreen_rects":this.currentIndex<this.silkscreenRects.length?(this.processSilkscreenRect(this.silkscreenRects[this.currentIndex]),this.currentIndex++):this.goToNextState();break;case"processing_silkscreen_paths":this.currentIndex<this.silkscreenPaths.length?(this.processSilkscreenPath(this.silkscreenPaths[this.currentIndex]),this.currentIndex++):this.goToNextState();break;case"processing_cutouts":this.currentIndex<this.pcb_cutouts.length?(this.processCutout(this.pcb_cutouts[this.currentIndex]),this.currentIndex++):this.goToNextState();break;case"processing_copper_pours":this.currentIndex<this.pcb_copper_pours.length?(this.processCopperPour(this.pcb_copper_pours[this.currentIndex]),this.currentIndex++):this.goToNextState();break;case"finalizing":this.finalize(),this.state="done";break}return this.state==="done"}processCutout(n){if(!this.boardGeom)return;let e=null;const t=this.ctx.pcbThickness*1.5;switch(n.shape){case"rect":if(e=(0,dp.cuboid)({center:[n.center.x,n.center.y,0],size:[n.width,n.height,t]}),n.rotation){const o=n.rotation*Math.PI/180;e=(0,uw.rotateZ)(o,e)}break;case"circle":e=(0,dp.cylinder)({center:[n.center.x,n.center.y,0],radius:n.radius,height:t});break;case"polygon":let i=n.points.map(o=>[o.x,o.y]);if(i.length<3){console.warn(`PCB Cutout [${n.pcb_cutout_id}] polygon has fewer than 3 points, skipping.`);break}Bye(i)&&(i=i.reverse());const r=(0,dp.polygon)({points:i});e=(0,p4.extrudeLinear)({height:t},r),e=(0,uw.translate)([0,0,-t/2],e);break}e&&(this.boardGeom=(0,Ey.subtract)(this.boardGeom,e))}processCopperPour(n){const e=n.layer==="bottom"?-1:1,t=e*this.ctx.pcbThickness/2+e*Iv.copper;let i=null;if(n.shape==="rect"){let r=(0,dp.cuboid)({center:[0,0,0],size:[n.width,n.height,Yl]});if("rotation"in n&&n.rotation){const o=n.rotation*Math.PI/180;r=(0,uw.rotateZ)(o,r)}i=(0,uw.translate)([n.center.x,n.center.y,t],r)}else if(n.shape==="brep"){const r=n.brep_shape;if(r&&r.outer_ring){const o=ZTn(r);i=(0,p4.extrudeLinear)({height:Yl},o),i=(0,uw.translate)([0,0,t],i)}}else if(n.shape==="polygon"){let r=n.points.map(s=>[s.x,s.y]);if(r.length<3){console.warn(`PCB Copper Pour [${n.pcb_copper_pour_id}] polygon has fewer than 3 points, skipping.`);return}Bye(r)&&(r=r.reverse());const o=(0,dp.polygon)({points:r});i=(0,p4.extrudeLinear)({height:Yl},o),i=(0,uw.translate)([0,0,t],i)}if(i){this.boardClipGeom&&(i=(0,Ey.intersect)(this.boardClipGeom,i));const o=n.covered_with_solder_mask!==!1?yV[this.board.material]??Zd.fr4GreenSolderWithMask:Zd.copper,s=(0,rS.colorize)(o,i);this.copperPourGeoms.push(s)}}processPlatedHole(n,e={}){if(this.boardGeom){if(n.shape==="circle"||n.shape==="circular_hole_with_rect_pad"){let t=null;n.shape==="circular_hole_with_rect_pad"?t=(0,dp.cylinder)({center:[n.x+(n.hole_offset_x||0),n.y+(n.hole_offset_y||0),0],radius:n.hole_diameter/2+Yl,height:this.ctx.pcbThickness*1.5}):t=(0,dp.cylinder)({center:[n.x,n.y,0],radius:n.hole_diameter/2+Yl,height:this.ctx.pcbThickness*1.5}),e.dontCutBoard||(this.boardGeom=(0,Ey.subtract)(this.boardGeom,t)),this.padGeoms=this.padGeoms.map(r=>(0,rS.colorize)(Zd.copper,(0,Ey.subtract)(r,t)));const i=ket(n,this.ctx,{clipGeom:this.boardClipGeom});this.platedHoleGeoms.push(i)}else if(n.shape==="pill"||n.shape==="pill_hole_with_rect_pad"){const t=n.hole_height>n.hole_width,i=t?n.hole_height:n.hole_width,r=t?n.hole_width:n.hole_height,o=r/2,s=Math.abs(i-r);let a;n.shape==="pill_hole_with_rect_pad"?a=(0,Ey.union)((0,dp.cuboid)({center:[n.x+(n.hole_offset_x||0),n.y+(n.hole_offset_y||0),0],size:t?[r,s,this.ctx.pcbThickness*1.5]:[s,r,this.ctx.pcbThickness*1.5]}),(0,dp.cylinder)({center:t?[n.x+(n.hole_offset_x||0),n.y+(n.hole_offset_y||0)-s/2,0]:[n.x+(n.hole_offset_x||0)-s/2,n.y+(n.hole_offset_y||0),0],radius:o,height:this.ctx.pcbThickness*1.5}),(0,dp.cylinder)({center:t?[n.x+(n.hole_offset_x||0),n.y+(n.hole_offset_y||0)+s/2,0]:[n.x+(n.hole_offset_x||0)+s/2,n.y+(n.hole_offset_y||0),0],radius:o,height:this.ctx.pcbThickness*1.5})):a=(0,Ey.union)((0,dp.cuboid)({center:[n.x,n.y,0],size:t?[r,s,this.ctx.pcbThickness*1.5]:[s,r,this.ctx.pcbThickness*1.5]}),(0,dp.cylinder)({center:t?[n.x,n.y-s/2,0]:[n.x-s/2,n.y,0],radius:o,height:this.ctx.pcbThickness*1.5}),(0,dp.cylinder)({center:t?[n.x,n.y+s/2,0]:[n.x+s/2,n.y,0],radius:o,height:this.ctx.pcbThickness*1.5})),e.dontCutBoard||(this.boardGeom=(0,Ey.subtract)(this.boardGeom,a)),this.padGeoms=this.padGeoms.map(l=>(0,rS.colorize)(Zd.copper,(0,Ey.subtract)(l,a)));const c=ket(n,this.ctx,{clipGeom:this.boardClipGeom});this.platedHoleGeoms.push(c)}}}processHole(n){if(!this.boardGeom)return;const e=this.ctx.pcbThickness*1.5;if(n.hole_shape==="round"||n.hole_shape==="circle"){const t=(0,dp.cylinder)({center:[n.x,n.y,0],radius:n.hole_diameter/2+Yl,height:e});this.boardGeom=(0,Ey.subtract)(this.boardGeom,t),this.padGeoms=this.padGeoms.map(r=>(0,rS.colorize)(Zd.copper,(0,Ey.subtract)(r,t)));const i=(0,dp.cylinder)({center:[n.x,n.y,0],radius:n.hole_diameter/2+Yl/2,height:e});this.platedHoleGeoms=this.platedHoleGeoms.map(r=>(0,rS.colorize)(Zd.copper,(0,Ey.subtract)(r,i)))}else if(n.hole_shape==="pill"||n.hole_shape==="rotated_pill"){const t=n.hole_width,i=n.hole_height,r=Math.min(t,i)/2,o=Math.abs(t-i),s=n.hole_shape==="rotated_pill";let a;if(t>i?a=(0,Ey.union)((0,dp.cuboid)({center:[n.x,n.y,0],size:[o,i,e]}),(0,dp.cylinder)({center:[n.x-o/2,n.y,0],radius:r,height:e}),(0,dp.cylinder)({center:[n.x+o/2,n.y,0],radius:r,height:e})):a=(0,Ey.union)((0,dp.cuboid)({center:[n.x,n.y,0],size:[t,o,e]}),(0,dp.cylinder)({center:[n.x,n.y-o/2,0],radius:r,height:e}),(0,dp.cylinder)({center:[n.x,n.y+o/2,0],radius:r,height:e})),s){const l=n.ccw_rotation*Math.PI/180;a=(0,uw.rotateZ)(l,a)}this.boardGeom=(0,Ey.subtract)(this.boardGeom,a),this.padGeoms=this.padGeoms.map(l=>(0,rS.colorize)(Zd.copper,(0,Ey.subtract)(l,a)));const c=(0,Yye.expand)({delta:-.02},a);this.platedHoleGeoms=this.platedHoleGeoms.map(l=>(0,rS.colorize)(Zd.copper,(0,Ey.subtract)(l,c)))}}processPad(n){const e=n.layer==="bottom"?-1:1,t=e*this.ctx.pcbThickness/2+e*Iv.copper,i=Y5(n);if(n.shape==="rect"){const r=Het(n.width,n.height,Yl,i);let s=(0,uw.translate)([n.x,n.y,t],r);this.boardClipGeom&&(s=(0,Ey.intersect)(this.boardClipGeom,s)),s=(0,rS.colorize)(Zd.copper,s),this.padGeoms.push(s)}else if(n.shape==="rotated_rect"){let r=Het(n.width,n.height,Yl,i);const o=n.ccw_rotation*Math.PI/180;r=(0,uw.rotateZ)(o,r);let a=(0,uw.translate)([n.x,n.y,t],r);this.boardClipGeom&&(a=(0,Ey.intersect)(this.boardClipGeom,a)),a=(0,rS.colorize)(Zd.copper,a),this.padGeoms.push(a)}else if(n.shape==="circle"){let r=(0,dp.cylinder)({center:[n.x,n.y,t],radius:n.radius,height:Yl});this.boardClipGeom&&(r=(0,Ey.intersect)(this.boardClipGeom,r)),r=(0,rS.colorize)(Zd.copper,r),this.padGeoms.push(r)}}processTrace(n){const{route:e}=n;if(e.length<2)return;let t=[],i=null,r=.1;const o=()=>{if(t.length>=2&&i){const s=i==="bottom"?-1:1,a=s*this.ctx.pcbThickness/2+s*Iv.traces,c=(0,dp.line)(t),l=(0,Yye.expand)({delta:r/2,corners:"round"},c);let u=(0,uw.translate)([0,0,a-Yl/2],(0,p4.extrudeLinear)({height:Yl},l));const d=t[0],h=t[t.length-1],p=this.getHoleToCut(d[0],d[1]);if(p){const g=(0,dp.cylinder)({center:[d[0],d[1],a],radius:p.diameter/2+Yl,height:Yl});u=(0,Ey.subtract)(u,g)}const m=this.getHoleToCut(h[0],h[1]);if(m){const g=(0,dp.cylinder)({center:[h[0],h[1],a],radius:m.diameter/2+Yl,height:Yl});u=(0,Ey.subtract)(u,g)}const _=yV[this.board.material]??Zd.fr4GreenSolderWithMask;this.boardClipGeom&&(u=(0,Ey.intersect)(this.boardClipGeom,u)),u=(0,rS.colorize)(_,u),this.traceGeoms.push(u)}t=[],i=null};for(let s=0;s<e.length;s++){const a=e[s];if(a.route_type==="wire")i===null?(i=a.layer,r=a.width,t.push([a.x,a.y])):a.layer===i?t.push([a.x,a.y]):(t.push([a.x,a.y]),o(),i=a.layer,r=a.width,e[s-1]?t.push([a.x,a.y]):t.push([a.x,a.y]));else if(a.route_type==="via"){t.push([a.x,a.y]),o();const c=e[s+1];c&&c.route_type==="wire"&&(i=c.layer,r=c.width,t.push([a.x,a.y]))}}o()}processVia(n){this.processPlatedHole({x:n.x,y:n.y,hole_diameter:n.hole_diameter,outer_diameter:n.outer_diameter,shape:"circle",layers:["top","bottom"],type:"pcb_plated_hole",pcb_plated_hole_id:`via_${n.pcb_via_id}`},{dontCutBoard:!0})}processSilkscreenText(n){const{textOutlines:e,xOffset:t,yOffset:i}=CTn(n);for(const r of e){const o=r.map(d=>[d[0]+t+n.anchor_position.x,d[1]+i+n.anchor_position.y]),s=(0,dp.line)(o),a=n.font_size||.25,c=Math.min(Math.max(.01,a*.1),a*.05),l=(0,Yye.expand)({delta:c,corners:"round"},s);let u;n.layer==="bottom"?u=(0,uw.translate)([0,0,-this.ctx.pcbThickness/2-Yl],(0,p4.extrudeLinear)({height:.012},l)):u=(0,uw.translate)([0,0,this.ctx.pcbThickness/2+Yl],(0,p4.extrudeLinear)({height:.012},l)),u=(0,rS.colorize)([1,1,1],u),this.silkscreenTextGeoms.push(u)}}processSilkscreenPath(n){const e=DTn(n,this.ctx);e&&this.silkscreenPathGeoms.push(e)}processSilkscreenLine(n){const e=jTn(n,this.ctx);e&&this.silkscreenLineGeoms.push(e)}processSilkscreenRect(n){const e=XTn(n,this.ctx);e&&this.silkscreenRectGeoms.push(e)}finalize(){if(!this.boardGeom)return;const n=Uye[this.board.material]??Zd.fr4Green;this.boardGeom=(0,rS.colorize)(n,this.boardGeom),this.finalGeoms=[this.boardGeom,...this.platedHoleGeoms,...this.padGeoms,...this.traceGeoms,...this.viaGeoms,...this.copperPourGeoms,...this.silkscreenTextGeoms,...this.silkscreenLineGeoms,...this.silkscreenRectGeoms,...this.silkscreenPathGeoms],this.onCompleteCallback&&this.onCompleteCallback(this.finalGeoms)}getGeoms(){return this.finalGeoms}},t5n=n=>{const[e,t]=fe.useState(null),i=fe.useRef(!1);return fe.useEffect(()=>{let r=!1;if(!n){t(null);return}if(!n.some(c=>c.type==="pcb_board")){t(null);return}const o=wTn(n);t(o);const s=new e5n(n,c=>{});return(async()=>{if(!i.current){i.current=!0;try{let c=!1;for(;!c&&!r;)c=s.step(1),c||await new Promise(l=>setTimeout(l,0));r||t(s.getGeoms())}catch(c){console.error("Error during board geometry building:",c)}finally{i.current=!1}}})(),()=>{r=!0}},[n]),e},Get=({error:n,cad_component:e})=>{const{rootObject:t}=_b(),[i,r]=fe.useState(!1),[o,s]=fe.useState(null),a=fe.useCallback(d=>{d?.mousePosition?(r(!0),s(d.mousePosition)):(r(!1),s(null))},[]),c=fe.useCallback(()=>{r(!1),s(null)},[]),l=fe.useMemo(()=>e?.position?[e.position.x,e.position.y,e.position.z].map(h=>Number.isNaN(h)?0:h):[0,0,0],[e]),u=fe.useMemo(()=>{const d=new Qw;return d.position.fromArray(l),d},[l]);return fe.useEffect(()=>{if(t)return t.add(u),()=>{t.remove(u)}},[t,u]),ce.jsxs(ce.Fragment,{children:[ce.jsxs(i8,{isHovered:i,onHover:a,onUnhover:c,object:u,children:[ce.jsx(n5n,{parent:u}),ce.jsx(d4,{parent:u,scale:[.1,.1,.1],color:"red",anchorX:"center",anchorY:"middle",depthOffset:-99999,children:`${n.toString().slice(0,50)}...`})]}),i&&o?ce.jsx(Tet,{position:o,style:{fontFamily:"sans-serif",transform:"translate3d(-1rem, 0rem, 0)",backgroundColor:"white",padding:"6px",borderRadius:"4px",color:"red",pointerEvents:"none",userSelect:"none",WebkitUserSelect:"none",MozUserSelect:"none",msUserSelect:"none"},children:n.toString()}):null]})},n5n=({parent:n})=>{const e=fe.useMemo(()=>{const t=new Ma(new j2(.5,.5,.5),new Gb({depthTest:!1,transparent:!0,color:"red",opacity:.5}));return t.renderOrder=999999,t.rotation.fromArray([Math.PI/4,Math.PI/4,0]),t},[]);return fe.useEffect(()=>(n.add(e),()=>{n.remove(e)}),[n,e]),null};function i5n({stlUrl:n,stlData:e,mtlUrl:t,color:i,opacity:r=1}){const{rootObject:o}=_b(),[s,a]=fe.useState(null);fe.useEffect(()=>{const l=new XLt;if(e){try{const u=l.parse(e);a(u)}catch(u){console.error("Failed to parse STL data",u),a(null)}return}n&&l.load(n,u=>{a(u)})},[n,e]);const c=fe.useMemo(()=>{if(!s)return null;const l=new Gb({color:Array.isArray(i)?new Jr(i[0],i[1],i[2]):i,transparent:r!==1,opacity:r});return new Ma(s,l)},[s,i,r]);return fe.useEffect(()=>{if(!(!o||!c))return o.add(c),()=>{o.remove(c),c.geometry.dispose(),Array.isArray(c.material)?c.material.forEach(l=>l.dispose()):c.material.dispose()}},[o,c]),null}function r5n({stlData:n,color:e,opacity:t=1,layerType:i}){const{visibility:r}=_8();let o=!0;return i==="board"?o=r.boardBody:i==="top-copper"?o=r.topCopper:i==="bottom-copper"?o=r.bottomCopper:i==="top-silkscreen"?o=r.topSilkscreen:i==="bottom-silkscreen"&&(o=r.bottomSilkscreen),o?ce.jsx(i5n,{stlData:n,color:e,opacity:t}):null}var Yet=class extends wo.Component{constructor(n){super(n),this.state={hasError:!1,error:null}}static getDerivedStateFromError(n){return{hasError:!0,error:n}}render(){return this.state.hasError&&this.state.error?this.props.fallback({error:this.state.error}):this.props.children}},o5n=fe.forwardRef(({soup:n,circuitJson:e,children:t,autoRotateDisabled:i,clickToInteractEnabled:r,onUserInteraction:o,onCameraControllerReady:s},a)=>{const c=Net(t),l=fe.useMemo(()=>n??e??c,[n,e,c]),u=t5n(l),d=fe.useMemo(()=>{if(!l)return[5,5,5];try{const g=fs(l).pcb_board.list()[0];if(!g)return[5,5,5];const{width:x,height:b}=g;if(!x&&!b)return[5,5,5];const w=5,E=Math.max(x,w),N=Math.max(b,w),A=Math.max(E,N);return[A/2,A/2,A]}catch(g){return console.error(g),[5,5,5]}},[l]),h=fe.useMemo(()=>{if(l)try{const g=fs(l).pcb_board.list()[0];return g?{width:g.width??0,height:g.height??0}:void 0}catch(g){console.error(g);return}},[l]),p=fe.useMemo(()=>{if(l)try{const g=fs(l).pcb_board.list()[0];return!g||!g.center?void 0:{x:g.center.x,y:g.center.y}}catch(g){console.error(g);return}},[l]),{stls:m}=mTn(u),_=fs(l).cad_component.list();return ce.jsxs(Iet,{ref:a,autoRotateDisabled:i,initialCameraPosition:d,clickToInteractEnabled:r,boardDimensions:h,boardCenter:p,onUserInteraction:o,onCameraControllerReady:s,children:[m.map(({stlData:g,color:x,layerType:b},w)=>ce.jsx(r5n,{stlData:g,color:x,opacity:w===0?.95:1,layerType:b},`board-${w}`)),_.map(g=>ce.jsx(Yet,{fallback:({error:x})=>ce.jsx(Get,{cad_component:g,error:x}),children:ce.jsx(Aet,{cad_component:g,circuitJson:l},g.cad_component_id)},g.cad_component_id))]})});function q5(n){const e=new Pf;if(e.setAttribute("position",new Ja(n.vertProperties,3)),e.setIndex(new Lte(n.triVerts,1)),n.runIndex&&n.runIndex.length>1&&n.runOriginalID)for(let t=0;t<n.runIndex.length-1;t++){const i=n.runIndex[t],r=n.runIndex[t+1]-i;e.addGroup(i,r,0)}else e.addGroup(0,n.triVerts.length,0);return e}function qet(n){return n&&n.route_type==="wire"&&typeof n.layer=="string"&&typeof n.width=="number"}function Xet({layer:n,circuitJson:e,boardData:t,traceColor:i,traceTextureResolution:r}){const o=fs(e).pcb_trace.list(),s=fs(e).pcb_via.list(),a=fs(e).pcb_plated_hole.list(),c=o.filter(m=>m.route.some(_=>qet(_)&&_.layer===n));if(c.length===0)return null;const l=document.createElement("canvas"),u=Math.floor(t.width*r),d=Math.floor(t.height*r);l.width=u,l.height=d;const h=l.getContext("2d");if(!h)return null;n==="bottom"&&(h.translate(0,d),h.scale(1,-1)),c.forEach(m=>{let _=!0;h.beginPath(),h.strokeStyle=i,h.lineCap="round",h.lineJoin="round";let g=0;for(const x of m.route){if(!qet(x)||x.layer!==n){_||h.stroke(),_=!0;continue}const b=x.x,w=x.y;g=x.width*r,h.lineWidth=g;const E=(b-t.center.x+t.width/2)*r,N=(-(w-t.center.y)+t.height/2)*r;_?(h.moveTo(E,N),_=!1):h.lineTo(E,N)}_||h.stroke()}),h.globalCompositeOperation="destination-out",h.fillStyle="black",s.forEach(m=>{const _=(m.x-t.center.x+t.width/2)*r,g=(-(m.y-t.center.y)+t.height/2)*r,x=m.outer_diameter/2*r;h.beginPath(),h.arc(_,g,x,0,2*Math.PI,!1),h.fill()}),a.forEach(m=>{if(m.layers.includes(n)&&m.shape==="circle"){const _=(m.x-t.center.x+t.width/2)*r,g=(-(m.y-t.center.y)+t.height/2)*r,x=m.outer_diameter/2*r;h.beginPath(),h.arc(_,g,x,0,2*Math.PI,!1),h.fill()}}),h.globalCompositeOperation="source-over";const p=new bOe(l);return p.generateMipmaps=!0,p.minFilter=FS,p.magFilter=v1,p.anisotropy=16,p.needsUpdate=!0,p}var s5n=vc(Z_e());function Wet({layer:n,circuitJson:e,boardData:t,silkscreenColor:i="rgb(255,255,255)",traceTextureResolution:r}){const o=fs(e).pcb_silkscreen_text.list(),s=fs(e).pcb_silkscreen_path.list(),a=fs(e).pcb_silkscreen_line.list(),c=fs(e).pcb_silkscreen_rect.list(),l=o.filter(E=>E.layer===n),u=s.filter(E=>E.layer===n),d=a.filter(E=>E.layer===n),h=c.filter(E=>E.layer===n);if(l.length===0&&u.length===0&&d.length===0&&h.length===0)return null;const p=document.createElement("canvas"),m=Math.floor(t.width*r),_=Math.floor(t.height*r);p.width=m,p.height=_;const g=p.getContext("2d");if(!g)return null;n==="bottom"&&(g.translate(0,_),g.scale(1,-1)),g.strokeStyle=i,g.fillStyle=i;const x=E=>(E-t.center.x+t.width/2)*r,b=E=>(-(E-t.center.y)+t.height/2)*r;d.forEach(E=>{const N=Hx(E.x1)??0,A=Hx(E.y1)??0,I=Hx(E.x2)??0,M=Hx(E.y2)??0;N===I&&A===M||(g.beginPath(),g.lineWidth=cT(E.stroke_width,.1)*r,g.lineCap="round",g.moveTo(x(N),b(A)),g.lineTo(x(I),b(M)),g.stroke())}),u.forEach(E=>{E.route.length<2||(g.beginPath(),g.lineWidth=cT(E.stroke_width,.1)*r,g.lineCap="round",g.lineJoin="round",E.route.forEach((N,A)=>{const I=x(Hx(N.x)??0),M=b(Hx(N.y)??0);A===0?g.moveTo(I,M):g.lineTo(I,M)}),g.stroke())}),h.forEach(E=>{const N=cT(E.width,0),A=cT(E.height,0);if(N<=0||A<=0)return;const I=Hx(E.center?.x)??0,M=Hx(E.center?.y)??0,k=x(I),C=b(M),U=Y5(E),O=typeof U=="string"?Hx(U):U,H=hI(N,A,O);g.save(),g.translate(k,C);const Y=N/2*r,W=A/2*r,K=Math.min(H*r,Y,W),J=E.has_stroke??!1,se=E.is_filled??!0,de=E.is_stroke_dashed??!1,ve=J?cT(E.stroke_width,.1)*r:0;if(((ue,me,Me,ke,ze)=>{if(g.beginPath(),ze<=0)g.rect(ue,me,Me,ke);else{const Be=ze,Re=ue+Me,oe=me+ke;g.moveTo(ue+Be,me),g.lineTo(Re-Be,me),g.quadraticCurveTo(Re,me,Re,me+Be),g.lineTo(Re,oe-Be),g.quadraticCurveTo(Re,oe,Re-Be,oe),g.lineTo(ue+Be,oe),g.quadraticCurveTo(ue,oe,ue,oe-Be),g.lineTo(ue,me+Be),g.quadraticCurveTo(ue,me,ue+Be,me),g.closePath()}})(-Y,-W,Y*2,W*2,K),se&&g.fill(),J&&ve>0){if(g.lineWidth=ve,de){const ue=Math.max(ve*2,1);g.setLineDash([ue,ue])}g.stroke(),de&&g.setLineDash([])}g.restore()}),l.forEach(E=>{const N=E.font_size||.25,A=Math.min(Math.max(.01,N*.1),N*.05)*r;g.lineWidth=A,g.lineCap="butt",g.lineJoin="miter";const I=(0,s5n.vectorText)({height:N*.45,input:E.text}),M=[];I.forEach(de=>{de.length===29?(M.push(de.slice(0,15)),M.push(de.slice(14,29))):de.length===17?(M.push(de.slice(0,10)),M.push(de.slice(9,17))):M.push(de)});const k=M.flat(),C={minX:k.length>0?Math.min(...k.map(de=>de[0])):0,maxX:k.length>0?Math.max(...k.map(de=>de[0])):0,minY:k.length>0?Math.min(...k.map(de=>de[1])):0,maxY:k.length>0?Math.max(...k.map(de=>de[1])):0},U=(C.minX+C.maxX)/2,O=(C.minY+C.maxY)/2;let H=-U,Y=-O;const W=E.anchor_alignment||"center";W.includes("left")?H=-C.minX:W.includes("right")&&(H=-C.maxX),W.includes("top")?Y=-C.maxY:W.includes("bottom")&&(Y=-C.minY);const K=[];let J=E.ccw_rotation??0;if(E.layer==="bottom"&&(K.push(jM(U,O),{a:-1,b:0,c:0,d:1,e:0,f:0},jM(-U,-O)),J=-J),J){const de=J*Math.PI/180;K.push(jM(U,O),zet(de),jM(-U,-O))}const se=K.length>0?Det(...K):void 0;M.forEach(de=>{g.beginPath(),de.forEach((ve,re)=>{let ue={x:ve[0],y:ve[1]};se&&(ue=Oet(se,ue));const me=ue.x+H+E.anchor_position.x,Me=ue.y+Y+E.anchor_position.y,ke=x(me),ze=b(Me);re===0?g.moveTo(ke,ze):g.lineTo(ke,ze)}),g.stroke()})});const w=new bOe(p);return w.generateMipmaps=!0,w.minFilter=FS,w.magFilter=v1,w.anisotropy=16,w.needsUpdate=!0,w}function Ket({Manifold:n,x:e,y:t,diameter:i,thickness:r,segments:o=32}){return n.cylinder(r*1.2,i/2,i/2,o,!0).translate([e,t,0])}function Zet({Manifold:n,x:e,y:t,outerDiameter:i,thickness:r,zOffset:o=.001,segments:s=32}){const a=i/2+o;return n.cylinder(r*1.2,a,a,s,!0).translate([e,t,0])}var a5n=64;function lT({Manifold:n,width:e,height:t,thickness:i,borderRadius:r}){const o=hI(e,t,r);if(o<=0)return n.cube([e,t,i],!0);const s=[],a=e-2*o,c=t-2*o;return a>0&&s.push(n.cube([a,t,i],!0)),c>0&&s.push(n.cube([e,c,i],!0)),[[e/2-o,t/2-o],[-e/2+o,t/2-o],[-e/2+o,-t/2+o],[e/2-o,-t/2+o]].forEach(([u,d])=>{s.push(n.cylinder(i,o,o,a5n,!0).translate([u,d,0]))}),n.union(s)}function c5n({Manifold:n,pad:e,padBaseThickness:t}){if(e.shape==="rect"){const i=Y5(e);return lT({Manifold:n,width:e.width,height:e.height,thickness:t,borderRadius:i})}else if(e.shape==="rotated_rect"){const i=Y5(e);let r=lT({Manifold:n,width:e.width,height:e.height,thickness:t,borderRadius:i});const o=e.ccw_rotation??0;return o&&(r=r.rotate([0,0,o])),r}else if(e.shape==="circle"&&e.radius)return n.cylinder(t,e.radius,-1,32,!0);return null}function l5n(n){return(n.shape==="circle"||n.hole_shape==="circle")&&typeof n.hole_diameter=="number"}function u5n(n){return(n.shape==="pill"||n.hole_shape==="pill")&&typeof n.hole_width=="number"&&typeof n.hole_height=="number"}function d5n(n){return(n.shape==="rotated_pill"||n.hole_shape==="rotated_pill")&&typeof n.hole_width=="number"&&typeof n.hole_height=="number"&&typeof n.ccw_rotation=="number"}function h5n(n,e,t,i){const r=[],o=fs(e).pcb_hole.list(),s=(a,c,l)=>{const u=lT({Manifold:n,width:a,height:c,thickness:l,borderRadius:Math.min(a,c)/2});return i.push(u),u};return o.forEach(a=>{if(l5n(a)){const c=Ket({Manifold:n,x:a.x,y:a.y,diameter:a.hole_diameter,thickness:t,segments:ZS});i.push(c),r.push(c)}else if(u5n(a)){const c=a.hole_width,l=a.hole_height,u=t*1.2,h=s(c,l,u).translate([a.x,a.y,0]);i.push(h),r.push(h)}else if(d5n(a)){const c=a.hole_width,l=a.hole_height,u=t*1.2;let d=s(c,l,u);const h=d.rotate([0,0,a.ccw_rotation]);i.push(h),d=h;const p=d.translate([a.x,a.y,0]);i.push(p),r.push(p)}}),{nonPlatedHoleBoardDrills:r}}var vV=new Jr(...Zd.copper),Qet=.05;function p5n(n,e,t,i,r){const o=[],s=fs(e).pcb_plated_hole.list(),a=[],c=[],l=(d,h,p)=>{const m=lT({Manifold:n,width:d,height:h,thickness:p,borderRadius:Math.min(d,h)/2});return i.push(m),m};s.forEach((d,h)=>{if(d.shape==="circle"){const p=Zet({Manifold:n,x:d.x,y:d.y,outerDiameter:d.hole_diameter*1.02,thickness:t,zOffset:aT,segments:ZS});i.push(p),o.push(p);const m=t+2*aT,_=n.cylinder(m,d.outer_diameter/2,d.outer_diameter/2,ZS,!0);i.push(_);const g=n.cylinder(m*1.05,d.hole_diameter/2,d.hole_diameter/2,ZS,!0);i.push(g);const x=_.subtract(g);i.push(x);const b=x.translate([d.x,d.y,0]);i.push(b);let w=b;if(r){const N=n.intersection([b,r]);i.push(N),w=N}c.push(w);const E=q5(w.getMesh());a.push({key:`ph-${d.pcb_plated_hole_id||h}`,geometry:E,color:vV})}else if(d.shape==="pill"){const p=d.hole_width,m=d.hole_height,_=.4,g=d.outer_width??p+_,x=d.outer_height??m+_,b=p+2*aT,w=m+2*aT,E=t*1.2;let N=l(b,w,E);if(d.ccw_rotation){const Y=N.rotate([0,0,d.ccw_rotation]);i.push(Y),N=Y}const A=N.translate([d.x,d.y,0]);i.push(A),o.push(A);const I=t+2*aT,M=l(g,x,I),k=l(p,m,I*1.05);let C=M.subtract(k);if(i.push(C),d.ccw_rotation){const Y=C.rotate([0,0,d.ccw_rotation]);i.push(Y),C=Y}const U=C.translate([d.x,d.y,0]);i.push(U);let O=U;if(r){const Y=n.intersection([U,r]);i.push(Y),O=Y}c.push(O);const H=q5(O.getMesh());a.push({key:`ph-${d.pcb_plated_hole_id||h}`,geometry:H,color:vV})}else if(d.shape==="pill_hole_with_rect_pad"){const p=d.hole_width,m=d.hole_height,_=d.hole_offset_x||0,g=d.hole_offset_y||0,x=d.rect_pad_width,b=d.rect_pad_height,w=Y5(d),E=mV,N=p+2*aT,A=m+2*aT,I=t*1.2,k=l(N,A,I).translate([_,g,0]).translate([d.x,d.y,0]);i.push(k),o.push(k);const C=lT({Manifold:n,width:x,height:b,thickness:t-2*E-2*Iv.copper+.1,borderRadius:w});i.push(C);const U=lT({Manifold:n,width:x,height:b,thickness:E,borderRadius:w}).translate([0,0,t/2/2+Iv.copper]),O=lT({Manifold:n,width:x,height:b,thickness:E,borderRadius:w}).translate([0,0,-t/2/2-Iv.copper]);i.push(U,O);const H=l(p,m,t*1.02).translate([_,g,0]);i.push(H);const Y=n.union([C,U,O,H]);i.push(Y);const W=l(Math.max(p-2*Qet,.01),Math.max(m-2*Qet,.01),t*1.2).translate([_,g,0]);i.push(W);const K=Y.subtract(W);i.push(K);const J=K.translate([d.x,d.y,0]);i.push(J);let se=J;if(r){const ve=n.intersection([J,r]);i.push(ve),se=ve}c.push(se);const de=q5(se.getMesh());a.push({key:`ph-${d.pcb_plated_hole_id||h}`,geometry:de,color:vV})}else if(d.shape==="circular_hole_with_rect_pad"){const p=d.hole_offset_x||0,m=d.hole_offset_y||0,_=Ket({Manifold:n,x:d.x+p,y:d.y+m,diameter:d.hole_diameter,thickness:t,segments:ZS});i.push(_),o.push(_);const g=d.rect_pad_width??d.hole_diameter,x=d.rect_pad_height??d.hole_diameter,b=Y5(d),w=mV,E=d.hole_diameter/2,N=lT({Manifold:n,width:g,height:x,thickness:t-2*w-2*Iv.copper+.1,borderRadius:b});i.push(N);const A=lT({Manifold:n,width:g,height:x,thickness:w,borderRadius:b}).translate([0,0,t/2/2+Iv.copper]),I=lT({Manifold:n,width:g,height:x,thickness:w,borderRadius:b}).translate([0,0,-t/2/2-Iv.copper]);i.push(A,I);const M=n.cylinder(t*1.02,E,E,ZS,!0).translate([p,m,0]);i.push(M);const k=n.union([N,A,I,M]);i.push(k);const C=n.cylinder(t*1.2,Math.max(E-Yl,.01),Math.max(E-Yl,.01),ZS,!0).translate([p,m,0]);i.push(C);const U=k.subtract(C);i.push(U);const O=U.translate([d.x,d.y,0]);i.push(O);let H=O;if(r){const W=n.intersection([O,r]);i.push(W),H=W}c.push(H);const Y=q5(H.getMesh());a.push({key:`ph-${d.pcb_plated_hole_id||h}`,geometry:Y,color:vV})}});let u;return c.length>0&&(u=n.union(c),i.push(u)),{platedHoleBoardDrills:o,platedHoleCopperGeoms:a,platedHoleSubtractOp:u}}function f5n({Manifold:n,x:e,y:t,outerDiameter:i,holeDiameter:r,thickness:o,zOffset:s=.001,segments:a=32}){const c=o+2*s;let l=n.cylinder(c,i/2,-1,a,!0);const u=n.cylinder(c*1.05,r/2,-1,a,!0);return l.subtract(u).translate([e,t,0])}var m5n=new Jr(...Zd.copper);function _5n(n,e,t,i,r){const o=[],s=fs(e).pcb_via.list(),a=[];return s.forEach((c,l)=>{if(typeof c.outer_diameter=="number"){const u=Zet({Manifold:n,x:c.x,y:c.y,outerDiameter:c.outer_diameter,thickness:t,zOffset:aT,segments:ZS});i.push(u),o.push(u)}if(typeof c.outer_diameter=="number"&&typeof c.hole_diameter=="number"){const u=f5n({Manifold:n,x:c.x,y:c.y,outerDiameter:c.outer_diameter,holeDiameter:c.hole_diameter,thickness:t,zOffset:aT,segments:ZS});i.push(u);let d=u;if(r){const p=n.intersection([u,r]);i.push(p),d=p}const h=q5(d.getMesh());a.push({key:`via-${c.pcb_via_id||l}`,geometry:h,color:m5n})}}),{viaBoardDrills:o,viaCopperGeoms:a}}var y5n=new Jr(...Zd.copper);function g5n(n,e,t,i,r,o){const s=[];return fs(e).pcb_smtpad.list().forEach((c,l)=>{const u=mV,d=c.layer==="bottom"?-t/2-Iv.copper:t/2+Iv.copper;let h=c5n({Manifold:n,pad:c,padBaseThickness:u});if(h){i.push(h);const p=h.translate([c.x,c.y,d]);i.push(p);let m=p;if(r&&(m=p.subtract(r),i.push(m)),o){const g=n.intersection([m,o]);i.push(g),m=g}const _=q5(m.getMesh());s.push({key:`smt_pad-${c.layer||"top"}-${c.pcb_smtpad_id||l}`,geometry:_,color:y5n})}}),{smtPadGeoms:s}}var x5n=n=>{let e=0;for(let i=0;i<n.length;i++){const r=(i+1)%n.length;n[i]&&n[r]&&(e+=n[i][0]*n[r][1],e-=n[r][0]*n[i][1])}return e/2<=0};function b5n(n,e,t,i,r){let o,s=null;if(t.outline&&t.outline.length>=3){let a=t.outline.map(l=>[l.x,l.y]);x5n(a)&&(a=a.reverse());const c=e.ofPolygons([a]);r.push(c),s=c,o=n.extrude(c,i,void 0,void 0,void 0,!0),r.push(o)}else t.outline&&t.outline.length>0&&console.warn("Board outline has fewer than 3 points, falling back to rectangular board."),o=n.cube([t.width,t.height,i],!0),r.push(o),o=o.translate([t.center.x,t.center.y,0]),r.push(o);return{boardOp:o,outlineCrossSection:s}}var Wye=n=>{let e=0;for(let i=0;i<n.length;i++){const r=(i+1)%n.length;n[i]&&n[r]&&(e+=n[i][0]*n[r][1],e-=n[r][0]*n[i][1])}return e/2<=0};function v5n(n,e,t,i){if(!t||Math.abs(t)<1e-9)return[];const r=4*Math.atan(t),o=e[0]-n[0],s=e[1]-n[1],a=Math.sqrt(o*o+s*s);if(a<1e-9)return[];const c=Math.abs(a/(2*Math.sin(r/2))),l=Math.sqrt(Math.max(0,c*c-a/2*(a/2))),u=[(n[0]+e[0])/2,(n[1]+e[1])/2],d=o/a,p=-(s/a),m=d,_=u[0]+p*l*Math.sign(t),g=u[1]+m*l*Math.sign(t),x=Math.atan2(n[1]-g,n[0]-_),b=[],w=Math.max(2,Math.ceil(i*Math.abs(r)/(Math.PI*2)*4)),E=r/w;for(let N=1;N<w;N++){const A=x+E*N;b.push([_+c*Math.cos(A),g+c*Math.sin(A)])}return b}function Jet(n,e){const t=[],i=n.vertices;for(let r=0;r<i.length;r++){const o=i[r],s=i[(r+1)%i.length];if(t.push([o.x,o.y]),o.bulge){const a=v5n([o.x,o.y],[s.x,s.y],o.bulge,e);t.push(...a)}}return t}function w5n(n,e,t,i,r,o,s,a){const c=[],l=t.filter(u=>u.type==="pcb_copper_pour");for(const u of l){const d=mV,p=(u.layer==="bottom"?-1:1)*(i/2+d/2+aT);let m;if(u.shape==="rect"){if(m=n.cube([u.width,u.height,d],!0),r.push(m),u.rotation){const _=m.rotate([0,0,u.rotation]);r.push(_),m=_}m=m.translate([u.center.x,u.center.y,p]),r.push(m)}else if(u.shape==="polygon"){if(u.points.length<3)continue;let _=u.points.map(x=>[x.x,x.y]);Wye(_)&&(_=_.reverse());const g=e.ofPolygons([_]);r.push(g),m=n.extrude(g,d,0,0,[1,1],!0).translate([0,0,p]),r.push(m)}else if(u.shape==="brep"){const _=u.brep_shape;if(!_||!_.outer_ring)continue;let g=Jet(_.outer_ring,ZS);Wye(g)&&(g=g.reverse());const x=[g];if(_.inner_rings){const w=_.inner_rings.map(E=>{let N=Jet(E,ZS);return Wye(N)||(N=N.reverse()),N});x.push(...w)}const b=e.ofPolygons(x);r.push(b),m=n.extrude(b,d,0,0,[1,1],!0).translate([0,0,p]),r.push(m)}if(m){if(s){const w=m.subtract(s);r.push(w),m=w}if(a){const w=n.intersection([m,a]);r.push(w),m=w}const g=u.covered_with_solder_mask!==!1?yV[o]??Zd.fr4GreenSolderWithMask:Zd.copper,x=new Jr(...g),b=q5(m.getMesh());c.push({key:`coppour-${u.pcb_copper_pour_id}`,geometry:b,color:x})}}return{copperPourGeoms:c}}var S5n=n=>{let e=0;for(let i=0;i<n.length;i++){const r=(i+1)%n.length;n[i]&&n[r]&&(e+=n[i][0]*n[r][1],e-=n[r][0]*n[i][1])}return e/2<=0};function E5n(n,e,t,i,r){const o=[],s=fs(t).pcb_cutout.list();for(const a of s){let c;const l=i*1.5;switch(a.shape){case"rect":if(c=n.cube([a.width,a.height,l],!0),r.push(c),a.rotation){a.rotation*Math.PI/180;const h=c.rotate([0,0,a.rotation]);r.push(h),c=h}c=c.translate([a.center.x,a.center.y,0]),r.push(c);break;case"circle":c=n.cylinder(l,a.radius,-1,ZS,!0),r.push(c),c=c.translate([a.center.x,a.center.y,0]),r.push(c);break;case"polygon":if(a.points.length<3){console.warn(`PCB Cutout [${a.pcb_cutout_id}] polygon has fewer than 3 points, skipping.`);continue}let u=a.points.map(h=>[h.x,h.y]);S5n(u)&&(u=u.reverse());const d=e.ofPolygons([u]);r.push(d),c=n.extrude(d,l,0,0,[1,1],!0),r.push(c);break;default:console.warn(`Unsupported cutout shape: ${a.shape} for cutout ${a.pcb_cutout_id}`);continue}c&&o.push(c)}return{cutoutOps:o}}var T5n=(n,e)=>{const[t,i]=fe.useState(null),[r,o]=fe.useState(null),[s,a]=fe.useState(null),[c,l]=fe.useState(null),[u,d]=fe.useState(!0),h=fe.useRef([]),p=fe.useMemo(()=>{const m=fs(e).pcb_board.list();return m.length===0?null:m[0]},[e]);return fe.useEffect(()=>{if(!n||!p){i(null),o(null),a(null),d(!1);return}if((p.width===0||!p.width)&&(p.height===0||!p.height)&&(!p.outline||p.outline.length<3)){i({platedHoles:[],smtPads:[],vias:[]}),o({}),a(p.thickness??0),d(!1);return}d(!0),l(null);const m=n.Manifold,_=n.CrossSection,g=E=>{if(!(!E||typeof E.delete!="function"))try{E.delete()}catch(N){(!(N instanceof Error)||!N.message?.includes("Manifold instance already deleted"))&&console.warn("Failed to delete Manifold instance",N)}};h.current.forEach(g),h.current=[];let x=null;const b={},w={};try{const E=p.thickness||1.6;a(E);const{boardOp:N,outlineCrossSection:A}=b5n(m,_,p,E,h.current);let I=N;const k=E+2*1;let C=null;const U=.01;if(A){let ze=A;if(U>0){const Re=A.offset(U);h.current.push(Re),ze=Re}const Be=m.extrude(ze,k,void 0,void 0,void 0,!0);h.current.push(Be),C=Be}else{const ze=(p.width||0)+2*U,Be=(p.height||0)+2*U,Re=m.cube([ze,Be,k],!0);h.current.push(Re);const oe=Re.translate([p.center.x,p.center.y,0]);h.current.push(oe),C=oe}const O=[];let H=null;const{nonPlatedHoleBoardDrills:Y}=h5n(m,e,E,h.current);O.push(...Y);const{platedHoleBoardDrills:W,platedHoleCopperGeoms:K,platedHoleSubtractOp:J}=p5n(m,e,E,h.current,C);O.push(...W),b.platedHoles=K;const{viaBoardDrills:se,viaCopperGeoms:de}=_5n(m,e,E,h.current,C);if(O.push(...se),b.vias=de,O.length>0){H=m.union(O),h.current.push(H);const ze=J?m.union([H,J]):H;h.current.push(ze);const Be=I.subtract(ze);if(h.current.push(Be),I=Be,J){const Re=J.subtract(H);h.current.push(Re);const oe=Re.getMesh(),Ee=q5(oe);b.platedHoles=[{key:"plated-holes-union",geometry:Ee,color:new Jr(Zd.copper[0],Zd.copper[1],Zd.copper[2])}]}}const{cutoutOps:ve}=E5n(m,_,e,E,h.current);if(ve.length>0){const ze=m.union(ve);h.current.push(ze);const Be=I.subtract(ze);h.current.push(Be),I=Be}if(x=I,x){const ze=x.getMesh(),Be=q5(ze),Re=Uye[p.material]??Zd.fr4Green;b.board={geometry:Be,color:new Jr(Re[0],Re[1],Re[2]),material:p.material}}const{smtPadGeoms:re}=g5n(m,e,E,h.current,H,C);b.smtPads=re;const{copperPourGeoms:ue}=w5n(m,_,e,E,h.current,p.material,H,C);b.copperPours=ue,i(b);const me=yV[p.material]??Zd.fr4GreenSolderWithMask,Me=`rgb(${Math.round(me[0]*255)}, ${Math.round(me[1]*255)}, ${Math.round(me[2]*255)})`;w.topTrace=Xet({layer:"top",circuitJson:e,boardData:p,traceColor:Me,traceTextureResolution:_V}),w.bottomTrace=Xet({layer:"bottom",circuitJson:e,boardData:p,traceColor:Me,traceTextureResolution:_V});const ke="rgb(255,255,255)";w.topSilkscreen=Wet({layer:"top",circuitJson:e,boardData:p,silkscreenColor:ke,traceTextureResolution:_V}),w.bottomSilkscreen=Wet({layer:"bottom",circuitJson:e,boardData:p,silkscreenColor:ke,traceTextureResolution:_V}),o(w)}catch(E){console.error("Error processing geometry with Manifold in hook:",E),l(E.message||"An unknown error occurred while processing geometry in hook."),i(null),o(null)}finally{d(!1)}return()=>{h.current.forEach(g),h.current=[]}},[n,e,p]),{geoms:t,textures:r,pcbThickness:s,error:c,isLoading:u,boardData:p}},M5n=qg,C5n=({material:n,color:e,side:t=M5n})=>n==="fr4"?new H2({color:e,side:t,metalness:0,roughness:.8,specularIntensity:.2,ior:1.45,sheen:0,clearcoat:0,transparent:!1,opacity:1,flatShading:!0}):new Gb({color:e,side:t,flatShading:!0,metalness:.1,roughness:.8,transparent:!0,opacity:.9});function A5n(n){const e=[];if(!n)return e;if(n.board&&n.board.geometry){const i=new Ma(n.board.geometry,C5n({material:n.board.material,color:n.board.color,side:qg}));i.name="board-geom",e.push(i)}const t=i=>{i&&i.forEach(r=>{const o=new Ma(r.geometry,new Gb({color:r.color,side:qg,flatShading:!0}));o.name=r.key,e.push(o)})};return t(n.platedHoles),t(n.smtPads),t(n.vias),t(n.copperPours),e}function P5n(n,e,t){const i=[];if(!n||!e||t===null)return i;const r=(l,u,d,h)=>{if(!l)return null;const p=new BE(e.width,e.height),m=new sw({map:l,transparent:!0,side:qg,depthWrite:!1}),_=new Ma(p,m);return _.position.set(e.center.x,e.center.y,u),d&&_.rotation.set(Math.PI,0,0),_.name=`${d?"bottom":"top"}-${h}-texture-plane`,_},o=r(n.topTrace,t/2+Iv.traces,!1,"trace");o&&i.push(o);const s=r(n.topSilkscreen,t/2+.017,!1,"silkscreen");s&&i.push(s);const a=r(n.bottomTrace,-t/2-Iv.traces,!0,"trace");a&&i.push(a);const c=r(n.bottomSilkscreen,-t/2-.017,!0,"silkscreen");return c&&i.push(c),i}var R5n=({geometryMeshes:n,textureMeshes:e})=>{const{rootObject:t}=_b(),{visibility:i}=_8();return fe.useEffect(()=>{if(t)return n.forEach(r=>{let o=!0;r.name==="board-geom"?o=i.boardBody:r.name.includes("smt_pad")?r.name.includes("smt_pad-top")?o=i.topCopper:r.name.includes("smt_pad-bottom")?o=i.bottomCopper:o=i.topCopper||i.bottomCopper:(r.name.includes("plated_hole")||r.name.includes("via")||r.name.includes("copper_pour"))&&(o=i.topCopper||i.bottomCopper),o&&t.add(r)}),e.forEach(r=>{let o=!0;r.name.includes("top-trace")?o=i.topCopper:r.name.includes("bottom-trace")?o=i.bottomCopper:r.name.includes("top-silkscreen")?o=i.topSilkscreen:r.name.includes("bottom-silkscreen")&&(o=i.bottomSilkscreen),o&&t.add(r)}),()=>{n.forEach(r=>{r.parent===t&&t.remove(r)}),e.forEach(r=>{r.parent===t&&t.remove(r)})}},[t,n,e,i]),null},I5n="https://cdn.jsdelivr.net/npm/manifold-3d@3.2.1",N5n=({circuitJson:n,autoRotateDisabled:e,clickToInteractEnabled:t,onUserInteraction:i,children:r,onCameraControllerReady:o})=>{const s=Net(r),a=fe.useMemo(()=>n??s,[n,s]),[c,l]=fe.useState(null),[u,d]=fe.useState(null);fe.useEffect(()=>{if(window.ManifoldModule&&typeof window.ManifoldModule=="object"&&window.ManifoldModule.setup){l(window.ManifoldModule);return}const M=async Y=>{try{const W=await Y();W.setup(),window.ManifoldModule=W,l(W)}catch(W){console.error("Failed to initialize Manifold:",W),d(`Failed to initialize Manifold: ${W instanceof Error?W.message:"Unknown error"}`)}},k=window.ManifoldModule??window.MANIFOLD??window.MANIFOLD_MODULE;if(k){window.ManifoldModule=k,M(window.ManifoldModule);return}const C="manifoldLoaded",U=()=>{const Y=window.ManifoldModule??window.MANIFOLD??window.MANIFOLD_MODULE;if(Y)window.ManifoldModule=Y,M(window.ManifoldModule);else{const W="ManifoldModule not found on window after script load.";console.error(W),d(W)}};window.addEventListener(C,U,{once:!0});const O=document.createElement("script");O.type="module",O.innerHTML=`
5122
+ at `+s}return e},bV.buildMessage=function(n,e){var t={literal:function(l){return'"'+r(l.text)+'"'},class:function(l){var u=l.parts.map(function(d){return Array.isArray(d)?o(d[0])+"-"+o(d[1]):o(d)});return"["+(l.inverted?"^":"")+u.join("")+"]"},any:function(){return"any character"},end:function(){return"end of input"},other:function(l){return l.description}};function i(l){return l.charCodeAt(0).toString(16).toUpperCase()}function r(l){return l.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,function(u){return"\\x0"+i(u)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(u){return"\\x"+i(u)})}function o(l){return l.replace(/\\/g,"\\\\").replace(/\]/g,"\\]").replace(/\^/g,"\\^").replace(/-/g,"\\-").replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,function(u){return"\\x0"+i(u)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(u){return"\\x"+i(u)})}function s(l){return t[l.type](l)}function a(l){var u=l.map(s),d,h;if(u.sort(),u.length>0){for(d=1,h=1;d<u.length;d++)u[d-1]!==u[d]&&(u[h]=u[d],h++);u.length=h}switch(u.length){case 1:return u[0];case 2:return u[0]+" or "+u[1];default:return u.slice(0,-1).join(", ")+", or "+u[u.length-1]}}function c(l){return l?'"'+r(l)+'"':"end of input"}return"Expected "+a(n)+" but "+c(e)+" found."};function CTn(n){const e=(0,STn.vectorText)({height:n.font_size*.45,input:n.text});let t=n.ccw_rotation??0;e.forEach(d=>{d.length===29?(e.splice(e.indexOf(d),1,d.slice(0,15)),e.splice(e.indexOf(d),0,d.slice(14,29))):d.length===17&&(e.splice(e.indexOf(d),1,d.slice(0,10)),e.splice(e.indexOf(d),0,d.slice(9,17)))});const i=e.flatMap(d=>d),r={minX:Math.min(...i.map(d=>d[0])),maxX:Math.max(...i.map(d=>d[0])),minY:Math.min(...i.map(d=>d[1])),maxY:Math.max(...i.map(d=>d[1]))},o=(r.minX+r.maxX)/2,s=(r.minY+r.maxY)/2;let a=-o,c=-s;n.anchor_alignment?.includes("right")?a=-r.maxX:n.anchor_alignment?.includes("left")&&(a=-r.minX),n.anchor_alignment?.includes("top")?c=-r.maxY:n.anchor_alignment?.includes("bottom")&&(c=-r.minY);const l=[];if(n.layer==="bottom"&&(l.push(jM(o,s),{a:-1,b:0,c:0,d:1,e:0,f:0},jM(-o,-s)),t=-t),t){const d=t*Math.PI/180;l.push(jM(o,s),zet(d),jM(-o,-s))}let u=e;if(l.length>0){const d=Det(...l);u=e.map(h=>h.map(([p,m])=>{const{x:_,y:g}=Oet(d,{x:p,y:m});return[_,g]}))}return{textOutlines:u,xOffset:a,yOffset:c}}var ATn=vc(B5()),PTn=vc(n8()),RTn=vc(c4()),ITn=vc(l4()),NTn=vc(r4()),$et=25.4,kTn=$et/1e3,OTn=/^\s*(-?\d*(?:\.\d+)?)(?:\s*(mm|mil|inch|in|"))?\s*$/i;function LTn(n){if(!n)return;const e=n.trim().toLowerCase();return e==='"'||e==="inch"?"in":e}function Hx(n){if(n==null)return;if(typeof n=="number")return Number.isFinite(n)?n:void 0;if(typeof n!="string")return;const e=n.trim();if(e.length===0)return;const t=e.match(OTn);if(!t){const a=Number.parseFloat(e);return Number.isFinite(a)?a:void 0}const[,i,r]=t,o=Number.parseFloat(i||"0");if(!Number.isFinite(o))return;switch(LTn(r)){case"mil":return o*kTn;case"in":return o*$et;case"mm":case void 0:return o;default:return o}}function cT(n,e){const t=Hx(n);return t===void 0?e:t}function DTn(n,e){if(n.route.length<2)return;const t=n.route.map(l=>[Hx(l.x)??0,Hx(l.y)??0]),i=(0,ATn.line)(t),r=cT(n.stroke_width,.1),o=(0,PTn.expand)({delta:r/2,corners:"round"},i),s=n.layer==="bottom"?-1:1,a=s*e.pcbThickness/2+s*Yl*1.5;let c=(0,ITn.translate)([0,0,a],(0,RTn.extrudeLinear)({height:.012},o));return c=(0,NTn.colorize)([1,1,1],c),c}var zTn=vc(B5()),$Tn=vc(n8()),FTn=vc(c4()),UTn=vc(l4()),BTn=vc(r4());function jTn(n,e){const t=Hx(n.x1)??0,i=Hx(n.y1)??0,r=Hx(n.x2)??0,o=Hx(n.y2)??0;if(t===r&&i===o)return;const s=[[t,i],[r,o]],a=(0,zTn.line)(s),c=cT(n.stroke_width,.1),l=(0,$Tn.expand)({delta:c/2,corners:"round"},a),u=n.layer==="bottom"?-1:1,d=u*e.pcbThickness/2+u*Yl*1.5;let h=(0,UTn.translate)([0,0,d],(0,FTn.extrudeLinear)({height:.012},l));return h=(0,BTn.colorize)([1,1,1],h),h}var HTn=vc(B5()),VTn=vc(c4()),GTn=vc(l4()),YTn=vc(r4()),Fet=vc(t8()),qTn=64;function XTn(n,e){const t=cT(n.width,0),i=cT(n.height,0);if(t<=0||i<=0)return;const r=Hx(n.center?.x)??0,o=Hx(n.center?.y)??0,s=Y5(n),a=hI(t,i,typeof s=="string"?Hx(s):s),c=(x,b,w)=>(0,VTn.extrudeLinear)({height:.012},(0,HTn.roundedRectangle)({size:[x,b],roundRadius:w,segments:qTn})),l=n.is_filled??!0,u=n.has_stroke??!1,d=u?cT(n.stroke_width,.1):0;let h;l&&(h=c(t,i,a));let p;if(u&&d>0){const x=c(t,i,a),b=t-d*2,w=i-d*2;if(b>0&&w>0){const E=hI(b,w,Math.max(a-d,0)),N=c(b,w,E);p=(0,Fet.subtract)(x,N)}else p=x}let m=h;if(p&&(m=m?(0,Fet.union)(m,p):p),!m)return;const _=n.layer==="bottom"?-1:1,g=_*e.pcbThickness/2+_*Yl*1.5;return m=(0,GTn.translate)([r,o,g],m),(0,YTn.colorize)([1,1,1],m)}var Uet=vc(B5()),WTn=vc(t8());function KTn(n,e,t,i){if(!t||Math.abs(t)<1e-9)return[];const r=4*Math.atan(t),o=e[0]-n[0],s=e[1]-n[1],a=Math.sqrt(o*o+s*s);if(a<1e-9)return[];const c=Math.abs(a/(2*Math.sin(r/2))),l=Math.sqrt(Math.max(0,c*c-a/2*(a/2))),u=[(n[0]+e[0])/2,(n[1]+e[1])/2],d=o/a,p=-(s/a),m=d,_=u[0]+p*l*Math.sign(t),g=u[1]+m*l*Math.sign(t),x=Math.atan2(n[1]-g,n[0]-_),b=[],w=Math.max(2,Math.ceil(i*Math.abs(r)/(Math.PI*2)*4)),E=r/w;for(let N=1;N<w;N++){const A=x+E*N;b.push([_+c*Math.cos(A),g+c*Math.sin(A)])}return b}function Bet(n,e){const t=[],i=n.vertices;for(let r=0;r<i.length;r++){const o=i[r],s=i[(r+1)%i.length];if(t.push([o.x,o.y]),o.bulge){const a=KTn([o.x,o.y],[s.x,s.y],o.bulge,e);t.push(...a)}}return t}function jet(n){let e=0;for(let t=0;t<n.length;t++){const i=(t+1)%n.length;e+=n[t][0]*n[i][1],e-=n[i][0]*n[t][1]}return e/2<=0}function ZTn(n,e=16){let t=Bet(n.outer_ring,e);jet(t)&&t.reverse();const i=(0,Uet.polygon)({points:t});if(!n.inner_rings||n.inner_rings.length===0)return i;const r=n.inner_rings.map(o=>{let s=Bet(o,e);return jet(s)&&s.reverse(),(0,Uet.polygon)({points:s})});return r.length===0?i:(0,WTn.subtract)(i,r)}var QTn=64,JTn=1,Xye=.05,Het=(n,e,t,i)=>{const r=hI(n,e,i);if(r<=0)return(0,dp.cuboid)({center:[0,0,0],size:[n,e,t]});const o=(0,dp.roundedRectangle)({size:[n,e],roundRadius:r,segments:QTn}),s=(0,p4.extrudeLinear)({height:t},o);return(0,uw.translate)([0,0,-t/2],s)},Vet=["initializing","processing_pads","processing_copper_pours","processing_plated_holes","processing_holes","processing_cutouts","processing_traces","processing_vias","processing_silkscreen_text","processing_silkscreen_lines","processing_silkscreen_rects","processing_silkscreen_paths","finalizing","done"],e5n=class{circuitJson;board;plated_holes;holes;pads;traces;pcb_vias;silkscreenTexts;silkscreenPaths;silkscreenLines;silkscreenRects;pcb_cutouts;pcb_copper_pours;boardGeom=null;platedHoleGeoms=[];holeGeoms=[];padGeoms=[];traceGeoms=[];viaGeoms=[];silkscreenTextGeoms=[];silkscreenPathGeoms=[];silkscreenLineGeoms=[];silkscreenRectGeoms=[];copperPourGeoms=[];boardClipGeom=null;state="initializing";currentIndex=0;ctx;onCompleteCallback;finalGeoms=[];getHoleToCut(n,e){const t=Yl/10;for(const i of this.pcb_vias)if(Math.abs(i.x-n)<t&&Math.abs(i.y-e)<t&&i.hole_diameter)return{diameter:i.hole_diameter};for(const i of this.plated_holes)if(i.shape==="circle"&&Math.abs(i.x-n)<t&&Math.abs(i.y-e)<t&&i.hole_diameter)return{diameter:i.hole_diameter};return null}constructor(n,e){this.circuitJson=n,this.onCompleteCallback=e,this.board=fs(n).pcb_board.list()[0],this.plated_holes=fs(n).pcb_plated_hole.list(),this.holes=fs(n).pcb_hole.list(),this.pads=fs(n).pcb_smtpad.list(),this.traces=fs(n).pcb_trace.list(),this.pcb_vias=fs(n).pcb_via.list(),this.silkscreenTexts=fs(n).pcb_silkscreen_text.list(),this.silkscreenPaths=fs(n).pcb_silkscreen_path.list(),this.silkscreenLines=fs(n).pcb_silkscreen_line.list(),this.silkscreenRects=fs(n).pcb_silkscreen_rect.list(),this.pcb_cutouts=fs(n).pcb_cutout.list(),this.pcb_copper_pours=n.filter(t=>t.type==="pcb_copper_pour"),this.ctx={pcbThickness:this.board.thickness??1.2},this.initializeBoard()}initializeBoard(){const n=this.ctx.pcbThickness+2*JTn;this.board.outline&&this.board.outline.length>0?(this.boardGeom=jye({outline:this.board.outline},this.ctx.pcbThickness),this.boardClipGeom=jye({outline:this.board.outline},n,{xyOutset:Xye})):(this.boardGeom=(0,dp.cuboid)({size:[this.board.width,this.board.height,this.ctx.pcbThickness],center:[this.board.center.x,this.board.center.y,0]}),this.boardClipGeom=(0,dp.cuboid)({size:[this.board.width+2*Xye,this.board.height+2*Xye,n],center:[this.board.center.x,this.board.center.y,0]})),this.state="processing_pads",this.currentIndex=0}goToNextState(){const n=Vet.indexOf(this.state);n!==-1&&(this.state=Vet[n+1],this.currentIndex=0)}step(n=1){if(this.state==="done"||!this.boardGeom)return!0;for(let e=0;e<n&&this.state!=="done";e++)switch(this.state){case"processing_plated_holes":this.currentIndex<this.plated_holes.length?(this.processPlatedHole(this.plated_holes[this.currentIndex]),this.currentIndex++):this.goToNextState();break;case"processing_holes":this.currentIndex<this.holes.length?(this.processHole(this.holes[this.currentIndex]),this.currentIndex++):this.goToNextState();break;case"processing_pads":this.currentIndex<this.pads.length?(this.processPad(this.pads[this.currentIndex]),this.currentIndex++):this.goToNextState();break;case"processing_traces":this.currentIndex<this.traces.length?(this.processTrace(this.traces[this.currentIndex]),this.currentIndex++):this.goToNextState();break;case"processing_vias":this.currentIndex<this.pcb_vias.length?(this.processVia(this.pcb_vias[this.currentIndex]),this.currentIndex++):this.goToNextState();break;case"processing_silkscreen_text":this.currentIndex<this.silkscreenTexts.length?(this.processSilkscreenText(this.silkscreenTexts[this.currentIndex]),this.currentIndex++):this.goToNextState();break;case"processing_silkscreen_lines":this.currentIndex<this.silkscreenLines.length?(this.processSilkscreenLine(this.silkscreenLines[this.currentIndex]),this.currentIndex++):this.goToNextState();break;case"processing_silkscreen_rects":this.currentIndex<this.silkscreenRects.length?(this.processSilkscreenRect(this.silkscreenRects[this.currentIndex]),this.currentIndex++):this.goToNextState();break;case"processing_silkscreen_paths":this.currentIndex<this.silkscreenPaths.length?(this.processSilkscreenPath(this.silkscreenPaths[this.currentIndex]),this.currentIndex++):this.goToNextState();break;case"processing_cutouts":this.currentIndex<this.pcb_cutouts.length?(this.processCutout(this.pcb_cutouts[this.currentIndex]),this.currentIndex++):this.goToNextState();break;case"processing_copper_pours":this.currentIndex<this.pcb_copper_pours.length?(this.processCopperPour(this.pcb_copper_pours[this.currentIndex]),this.currentIndex++):this.goToNextState();break;case"finalizing":this.finalize(),this.state="done";break}return this.state==="done"}processCutout(n){if(!this.boardGeom)return;let e=null;const t=this.ctx.pcbThickness*1.5;switch(n.shape){case"rect":if(e=(0,dp.cuboid)({center:[n.center.x,n.center.y,0],size:[n.width,n.height,t]}),n.rotation){const o=n.rotation*Math.PI/180;e=(0,uw.rotateZ)(o,e)}break;case"circle":e=(0,dp.cylinder)({center:[n.center.x,n.center.y,0],radius:n.radius,height:t});break;case"polygon":let i=n.points.map(o=>[o.x,o.y]);if(i.length<3){console.warn(`PCB Cutout [${n.pcb_cutout_id}] polygon has fewer than 3 points, skipping.`);break}Bye(i)&&(i=i.reverse());const r=(0,dp.polygon)({points:i});e=(0,p4.extrudeLinear)({height:t},r),e=(0,uw.translate)([0,0,-t/2],e);break}e&&(this.boardGeom=(0,Ey.subtract)(this.boardGeom,e))}processCopperPour(n){const e=n.layer==="bottom"?-1:1,t=e*this.ctx.pcbThickness/2+e*Iv.copper;let i=null;if(n.shape==="rect"){let r=(0,dp.cuboid)({center:[0,0,0],size:[n.width,n.height,Yl]});if("rotation"in n&&n.rotation){const o=n.rotation*Math.PI/180;r=(0,uw.rotateZ)(o,r)}i=(0,uw.translate)([n.center.x,n.center.y,t],r)}else if(n.shape==="brep"){const r=n.brep_shape;if(r&&r.outer_ring){const o=ZTn(r);i=(0,p4.extrudeLinear)({height:Yl},o),i=(0,uw.translate)([0,0,t],i)}}else if(n.shape==="polygon"){let r=n.points.map(s=>[s.x,s.y]);if(r.length<3){console.warn(`PCB Copper Pour [${n.pcb_copper_pour_id}] polygon has fewer than 3 points, skipping.`);return}Bye(r)&&(r=r.reverse());const o=(0,dp.polygon)({points:r});i=(0,p4.extrudeLinear)({height:Yl},o),i=(0,uw.translate)([0,0,t],i)}if(i){this.boardClipGeom&&(i=(0,Ey.intersect)(this.boardClipGeom,i));const o=n.covered_with_solder_mask!==!1?yV[this.board.material]??Zd.fr4GreenSolderWithMask:Zd.copper,s=(0,rS.colorize)(o,i);this.copperPourGeoms.push(s)}}processPlatedHole(n,e={}){if(this.boardGeom){if(n.shape==="circle"||n.shape==="circular_hole_with_rect_pad"){let t=null;n.shape==="circular_hole_with_rect_pad"?t=(0,dp.cylinder)({center:[n.x+(n.hole_offset_x||0),n.y+(n.hole_offset_y||0),0],radius:n.hole_diameter/2+Yl,height:this.ctx.pcbThickness*1.5}):t=(0,dp.cylinder)({center:[n.x,n.y,0],radius:n.hole_diameter/2+Yl,height:this.ctx.pcbThickness*1.5}),e.dontCutBoard||(this.boardGeom=(0,Ey.subtract)(this.boardGeom,t)),this.padGeoms=this.padGeoms.map(r=>(0,rS.colorize)(Zd.copper,(0,Ey.subtract)(r,t)));const i=ket(n,this.ctx,{clipGeom:this.boardClipGeom});this.platedHoleGeoms.push(i)}else if(n.shape==="pill"||n.shape==="pill_hole_with_rect_pad"){const t=n.hole_height>n.hole_width,i=t?n.hole_height:n.hole_width,r=t?n.hole_width:n.hole_height,o=r/2,s=Math.abs(i-r);let a;n.shape==="pill_hole_with_rect_pad"?a=(0,Ey.union)((0,dp.cuboid)({center:[n.x+(n.hole_offset_x||0),n.y+(n.hole_offset_y||0),0],size:t?[r,s,this.ctx.pcbThickness*1.5]:[s,r,this.ctx.pcbThickness*1.5]}),(0,dp.cylinder)({center:t?[n.x+(n.hole_offset_x||0),n.y+(n.hole_offset_y||0)-s/2,0]:[n.x+(n.hole_offset_x||0)-s/2,n.y+(n.hole_offset_y||0),0],radius:o,height:this.ctx.pcbThickness*1.5}),(0,dp.cylinder)({center:t?[n.x+(n.hole_offset_x||0),n.y+(n.hole_offset_y||0)+s/2,0]:[n.x+(n.hole_offset_x||0)+s/2,n.y+(n.hole_offset_y||0),0],radius:o,height:this.ctx.pcbThickness*1.5})):a=(0,Ey.union)((0,dp.cuboid)({center:[n.x,n.y,0],size:t?[r,s,this.ctx.pcbThickness*1.5]:[s,r,this.ctx.pcbThickness*1.5]}),(0,dp.cylinder)({center:t?[n.x,n.y-s/2,0]:[n.x-s/2,n.y,0],radius:o,height:this.ctx.pcbThickness*1.5}),(0,dp.cylinder)({center:t?[n.x,n.y+s/2,0]:[n.x+s/2,n.y,0],radius:o,height:this.ctx.pcbThickness*1.5})),e.dontCutBoard||(this.boardGeom=(0,Ey.subtract)(this.boardGeom,a)),this.padGeoms=this.padGeoms.map(l=>(0,rS.colorize)(Zd.copper,(0,Ey.subtract)(l,a)));const c=ket(n,this.ctx,{clipGeom:this.boardClipGeom});this.platedHoleGeoms.push(c)}}}processHole(n){if(!this.boardGeom)return;const e=this.ctx.pcbThickness*1.5;if(n.hole_shape==="round"||n.hole_shape==="circle"){const t=(0,dp.cylinder)({center:[n.x,n.y,0],radius:n.hole_diameter/2+Yl,height:e});this.boardGeom=(0,Ey.subtract)(this.boardGeom,t),this.padGeoms=this.padGeoms.map(r=>(0,rS.colorize)(Zd.copper,(0,Ey.subtract)(r,t)));const i=(0,dp.cylinder)({center:[n.x,n.y,0],radius:n.hole_diameter/2+Yl/2,height:e});this.platedHoleGeoms=this.platedHoleGeoms.map(r=>(0,rS.colorize)(Zd.copper,(0,Ey.subtract)(r,i)))}else if(n.hole_shape==="pill"||n.hole_shape==="rotated_pill"){const t=n.hole_width,i=n.hole_height,r=Math.min(t,i)/2,o=Math.abs(t-i),s=n.hole_shape==="rotated_pill";let a;if(t>i?a=(0,Ey.union)((0,dp.cuboid)({center:[n.x,n.y,0],size:[o,i,e]}),(0,dp.cylinder)({center:[n.x-o/2,n.y,0],radius:r,height:e}),(0,dp.cylinder)({center:[n.x+o/2,n.y,0],radius:r,height:e})):a=(0,Ey.union)((0,dp.cuboid)({center:[n.x,n.y,0],size:[t,o,e]}),(0,dp.cylinder)({center:[n.x,n.y-o/2,0],radius:r,height:e}),(0,dp.cylinder)({center:[n.x,n.y+o/2,0],radius:r,height:e})),s){const l=n.ccw_rotation*Math.PI/180;a=(0,uw.rotateZ)(l,a)}this.boardGeom=(0,Ey.subtract)(this.boardGeom,a),this.padGeoms=this.padGeoms.map(l=>(0,rS.colorize)(Zd.copper,(0,Ey.subtract)(l,a)));const c=(0,Yye.expand)({delta:-.02},a);this.platedHoleGeoms=this.platedHoleGeoms.map(l=>(0,rS.colorize)(Zd.copper,(0,Ey.subtract)(l,c)))}}processPad(n){const e=n.layer==="bottom"?-1:1,t=e*this.ctx.pcbThickness/2+e*Iv.copper,i=Y5(n);if(n.shape==="rect"){const r=Het(n.width,n.height,Yl,i);let s=(0,uw.translate)([n.x,n.y,t],r);this.boardClipGeom&&(s=(0,Ey.intersect)(this.boardClipGeom,s)),s=(0,rS.colorize)(Zd.copper,s),this.padGeoms.push(s)}else if(n.shape==="rotated_rect"){let r=Het(n.width,n.height,Yl,i);const o=n.ccw_rotation*Math.PI/180;r=(0,uw.rotateZ)(o,r);let a=(0,uw.translate)([n.x,n.y,t],r);this.boardClipGeom&&(a=(0,Ey.intersect)(this.boardClipGeom,a)),a=(0,rS.colorize)(Zd.copper,a),this.padGeoms.push(a)}else if(n.shape==="circle"){let r=(0,dp.cylinder)({center:[n.x,n.y,t],radius:n.radius,height:Yl});this.boardClipGeom&&(r=(0,Ey.intersect)(this.boardClipGeom,r)),r=(0,rS.colorize)(Zd.copper,r),this.padGeoms.push(r)}}processTrace(n){const{route:e}=n;if(e.length<2)return;let t=[],i=null,r=.1;const o=()=>{if(t.length>=2&&i){const s=i==="bottom"?-1:1,a=s*this.ctx.pcbThickness/2+s*Iv.traces,c=(0,dp.line)(t),l=(0,Yye.expand)({delta:r/2,corners:"round"},c);let u=(0,uw.translate)([0,0,a-Yl/2],(0,p4.extrudeLinear)({height:Yl},l));const d=t[0],h=t[t.length-1],p=this.getHoleToCut(d[0],d[1]);if(p){const g=(0,dp.cylinder)({center:[d[0],d[1],a],radius:p.diameter/2+Yl,height:Yl});u=(0,Ey.subtract)(u,g)}const m=this.getHoleToCut(h[0],h[1]);if(m){const g=(0,dp.cylinder)({center:[h[0],h[1],a],radius:m.diameter/2+Yl,height:Yl});u=(0,Ey.subtract)(u,g)}const _=yV[this.board.material]??Zd.fr4GreenSolderWithMask;this.boardClipGeom&&(u=(0,Ey.intersect)(this.boardClipGeom,u)),u=(0,rS.colorize)(_,u),this.traceGeoms.push(u)}t=[],i=null};for(let s=0;s<e.length;s++){const a=e[s];if(a.route_type==="wire")i===null?(i=a.layer,r=a.width,t.push([a.x,a.y])):a.layer===i?t.push([a.x,a.y]):(t.push([a.x,a.y]),o(),i=a.layer,r=a.width,e[s-1]?t.push([a.x,a.y]):t.push([a.x,a.y]));else if(a.route_type==="via"){t.push([a.x,a.y]),o();const c=e[s+1];c&&c.route_type==="wire"&&(i=c.layer,r=c.width,t.push([a.x,a.y]))}}o()}processVia(n){this.processPlatedHole({x:n.x,y:n.y,hole_diameter:n.hole_diameter,outer_diameter:n.outer_diameter,shape:"circle",layers:["top","bottom"],type:"pcb_plated_hole",pcb_plated_hole_id:`via_${n.pcb_via_id}`},{dontCutBoard:!0})}processSilkscreenText(n){const{textOutlines:e,xOffset:t,yOffset:i}=CTn(n);for(const r of e){const o=r.map(d=>[d[0]+t+n.anchor_position.x,d[1]+i+n.anchor_position.y]),s=(0,dp.line)(o),a=n.font_size||.25,c=Math.min(Math.max(.01,a*.1),a*.05),l=(0,Yye.expand)({delta:c,corners:"round"},s);let u;n.layer==="bottom"?u=(0,uw.translate)([0,0,-this.ctx.pcbThickness/2-Yl],(0,p4.extrudeLinear)({height:.012},l)):u=(0,uw.translate)([0,0,this.ctx.pcbThickness/2+Yl],(0,p4.extrudeLinear)({height:.012},l)),u=(0,rS.colorize)([1,1,1],u),this.silkscreenTextGeoms.push(u)}}processSilkscreenPath(n){const e=DTn(n,this.ctx);e&&this.silkscreenPathGeoms.push(e)}processSilkscreenLine(n){const e=jTn(n,this.ctx);e&&this.silkscreenLineGeoms.push(e)}processSilkscreenRect(n){const e=XTn(n,this.ctx);e&&this.silkscreenRectGeoms.push(e)}finalize(){if(!this.boardGeom)return;const n=Uye[this.board.material]??Zd.fr4Green;this.boardGeom=(0,rS.colorize)(n,this.boardGeom),this.finalGeoms=[this.boardGeom,...this.platedHoleGeoms,...this.padGeoms,...this.traceGeoms,...this.viaGeoms,...this.copperPourGeoms,...this.silkscreenTextGeoms,...this.silkscreenLineGeoms,...this.silkscreenRectGeoms,...this.silkscreenPathGeoms],this.onCompleteCallback&&this.onCompleteCallback(this.finalGeoms)}getGeoms(){return this.finalGeoms}},t5n=n=>{const[e,t]=fe.useState(null),i=fe.useRef(!1);return fe.useEffect(()=>{let r=!1;if(!n){t(null);return}if(!n.some(c=>c.type==="pcb_board")){t(null);return}const o=wTn(n);t(o);const s=new e5n(n,c=>{});return(async()=>{if(!i.current){i.current=!0;try{let c=!1;for(;!c&&!r;)c=s.step(1),c||await new Promise(l=>setTimeout(l,0));r||t(s.getGeoms())}catch(c){console.error("Error during board geometry building:",c)}finally{i.current=!1}}})(),()=>{r=!0}},[n]),e},Get=({error:n,cad_component:e})=>{const{rootObject:t}=_b(),[i,r]=fe.useState(!1),[o,s]=fe.useState(null),a=fe.useCallback(d=>{d?.mousePosition?(r(!0),s(d.mousePosition)):(r(!1),s(null))},[]),c=fe.useCallback(()=>{r(!1),s(null)},[]),l=fe.useMemo(()=>e?.position?[e.position.x,e.position.y,e.position.z].map(h=>Number.isNaN(h)?0:h):[0,0,0],[e]),u=fe.useMemo(()=>{const d=new Qw;return d.position.fromArray(l),d},[l]);return fe.useEffect(()=>{if(t)return t.add(u),()=>{t.remove(u)}},[t,u]),ce.jsxs(ce.Fragment,{children:[ce.jsxs(i8,{isHovered:i,onHover:a,onUnhover:c,object:u,children:[ce.jsx(n5n,{parent:u}),ce.jsx(d4,{parent:u,scale:[.1,.1,.1],color:"red",anchorX:"center",anchorY:"middle",depthOffset:-99999,children:`${n.toString().slice(0,50)}...`})]}),i&&o?ce.jsx(Tet,{position:o,style:{fontFamily:"sans-serif",transform:"translate3d(-1rem, 0rem, 0)",backgroundColor:"white",padding:"6px",borderRadius:"4px",color:"red",pointerEvents:"none",userSelect:"none",WebkitUserSelect:"none",MozUserSelect:"none",msUserSelect:"none"},children:n.toString()}):null]})},n5n=({parent:n})=>{const e=fe.useMemo(()=>{const t=new Ma(new j2(.5,.5,.5),new Gb({depthTest:!1,transparent:!0,color:"red",opacity:.5}));return t.renderOrder=999999,t.rotation.fromArray([Math.PI/4,Math.PI/4,0]),t},[]);return fe.useEffect(()=>(n.add(e),()=>{n.remove(e)}),[n,e]),null};function i5n({stlUrl:n,stlData:e,mtlUrl:t,color:i,opacity:r=1}){const{rootObject:o}=_b(),[s,a]=fe.useState(null);fe.useEffect(()=>{const l=new XLt;if(e){try{const u=l.parse(e);a(u)}catch(u){console.error("Failed to parse STL data",u),a(null)}return}n&&l.load(n,u=>{a(u)})},[n,e]);const c=fe.useMemo(()=>{if(!s)return null;const l=new Gb({color:Array.isArray(i)?new Jr(i[0],i[1],i[2]):i,transparent:r!==1,opacity:r});return new Ma(s,l)},[s,i,r]);return fe.useEffect(()=>{if(!(!o||!c))return o.add(c),()=>{o.remove(c),c.geometry.dispose(),Array.isArray(c.material)?c.material.forEach(l=>l.dispose()):c.material.dispose()}},[o,c]),null}function r5n({stlData:n,color:e,opacity:t=1,layerType:i}){const{visibility:r}=_8();let o=!0;return i==="board"?o=r.boardBody:i==="top-copper"?o=r.topCopper:i==="bottom-copper"?o=r.bottomCopper:i==="top-silkscreen"?o=r.topSilkscreen:i==="bottom-silkscreen"&&(o=r.bottomSilkscreen),o?ce.jsx(i5n,{stlData:n,color:e,opacity:t}):null}var Yet=class extends wo.Component{constructor(n){super(n),this.state={hasError:!1,error:null}}static getDerivedStateFromError(n){return{hasError:!0,error:n}}render(){return this.state.hasError&&this.state.error?this.props.fallback({error:this.state.error}):this.props.children}},o5n=fe.forwardRef(({soup:n,circuitJson:e,children:t,autoRotateDisabled:i,clickToInteractEnabled:r,onUserInteraction:o,onCameraControllerReady:s},a)=>{const c=Net(t),l=fe.useMemo(()=>n??e??c,[n,e,c]),u=t5n(l),d=fe.useMemo(()=>{if(!l)return[5,-5,5];try{const g=fs(l).pcb_board.list()[0];if(!g)return[5,-5,5];const{width:x,height:b}=g;if(!x&&!b)return[5,-5,5];const w=5,E=Math.max(x,w),N=Math.max(b,w),A=Math.max(E,N);return[A/2,-A/2,A]}catch(g){return console.error(g),[5,-5,5]}},[l]),h=fe.useMemo(()=>{if(l)try{const g=fs(l).pcb_board.list()[0];return g?{width:g.width??0,height:g.height??0}:void 0}catch(g){console.error(g);return}},[l]),p=fe.useMemo(()=>{if(l)try{const g=fs(l).pcb_board.list()[0];return!g||!g.center?void 0:{x:g.center.x,y:g.center.y}}catch(g){console.error(g);return}},[l]),{stls:m}=mTn(u),_=fs(l).cad_component.list();return ce.jsxs(Iet,{ref:a,autoRotateDisabled:i,initialCameraPosition:d,clickToInteractEnabled:r,boardDimensions:h,boardCenter:p,onUserInteraction:o,onCameraControllerReady:s,children:[m.map(({stlData:g,color:x,layerType:b},w)=>ce.jsx(r5n,{stlData:g,color:x,opacity:w===0?.95:1,layerType:b},`board-${w}`)),_.map(g=>ce.jsx(Yet,{fallback:({error:x})=>ce.jsx(Get,{cad_component:g,error:x}),children:ce.jsx(Aet,{cad_component:g,circuitJson:l},g.cad_component_id)},g.cad_component_id))]})});function q5(n){const e=new Pf;if(e.setAttribute("position",new Ja(n.vertProperties,3)),e.setIndex(new Lte(n.triVerts,1)),n.runIndex&&n.runIndex.length>1&&n.runOriginalID)for(let t=0;t<n.runIndex.length-1;t++){const i=n.runIndex[t],r=n.runIndex[t+1]-i;e.addGroup(i,r,0)}else e.addGroup(0,n.triVerts.length,0);return e}function qet(n){return n&&n.route_type==="wire"&&typeof n.layer=="string"&&typeof n.width=="number"}function Xet({layer:n,circuitJson:e,boardData:t,traceColor:i,traceTextureResolution:r}){const o=fs(e).pcb_trace.list(),s=fs(e).pcb_via.list(),a=fs(e).pcb_plated_hole.list(),c=o.filter(m=>m.route.some(_=>qet(_)&&_.layer===n));if(c.length===0)return null;const l=document.createElement("canvas"),u=Math.floor(t.width*r),d=Math.floor(t.height*r);l.width=u,l.height=d;const h=l.getContext("2d");if(!h)return null;n==="bottom"&&(h.translate(0,d),h.scale(1,-1)),c.forEach(m=>{let _=!0;h.beginPath(),h.strokeStyle=i,h.lineCap="round",h.lineJoin="round";let g=0;for(const x of m.route){if(!qet(x)||x.layer!==n){_||h.stroke(),_=!0;continue}const b=x.x,w=x.y;g=x.width*r,h.lineWidth=g;const E=(b-t.center.x+t.width/2)*r,N=(-(w-t.center.y)+t.height/2)*r;_?(h.moveTo(E,N),_=!1):h.lineTo(E,N)}_||h.stroke()}),h.globalCompositeOperation="destination-out",h.fillStyle="black",s.forEach(m=>{const _=(m.x-t.center.x+t.width/2)*r,g=(-(m.y-t.center.y)+t.height/2)*r,x=m.outer_diameter/2*r;h.beginPath(),h.arc(_,g,x,0,2*Math.PI,!1),h.fill()}),a.forEach(m=>{if(m.layers.includes(n)&&m.shape==="circle"){const _=(m.x-t.center.x+t.width/2)*r,g=(-(m.y-t.center.y)+t.height/2)*r,x=m.outer_diameter/2*r;h.beginPath(),h.arc(_,g,x,0,2*Math.PI,!1),h.fill()}}),h.globalCompositeOperation="source-over";const p=new bOe(l);return p.generateMipmaps=!0,p.minFilter=FS,p.magFilter=v1,p.anisotropy=16,p.needsUpdate=!0,p}var s5n=vc(Z_e());function Wet({layer:n,circuitJson:e,boardData:t,silkscreenColor:i="rgb(255,255,255)",traceTextureResolution:r}){const o=fs(e).pcb_silkscreen_text.list(),s=fs(e).pcb_silkscreen_path.list(),a=fs(e).pcb_silkscreen_line.list(),c=fs(e).pcb_silkscreen_rect.list(),l=o.filter(E=>E.layer===n),u=s.filter(E=>E.layer===n),d=a.filter(E=>E.layer===n),h=c.filter(E=>E.layer===n);if(l.length===0&&u.length===0&&d.length===0&&h.length===0)return null;const p=document.createElement("canvas"),m=Math.floor(t.width*r),_=Math.floor(t.height*r);p.width=m,p.height=_;const g=p.getContext("2d");if(!g)return null;n==="bottom"&&(g.translate(0,_),g.scale(1,-1)),g.strokeStyle=i,g.fillStyle=i;const x=E=>(E-t.center.x+t.width/2)*r,b=E=>(-(E-t.center.y)+t.height/2)*r;d.forEach(E=>{const N=Hx(E.x1)??0,A=Hx(E.y1)??0,I=Hx(E.x2)??0,M=Hx(E.y2)??0;N===I&&A===M||(g.beginPath(),g.lineWidth=cT(E.stroke_width,.1)*r,g.lineCap="round",g.moveTo(x(N),b(A)),g.lineTo(x(I),b(M)),g.stroke())}),u.forEach(E=>{E.route.length<2||(g.beginPath(),g.lineWidth=cT(E.stroke_width,.1)*r,g.lineCap="round",g.lineJoin="round",E.route.forEach((N,A)=>{const I=x(Hx(N.x)??0),M=b(Hx(N.y)??0);A===0?g.moveTo(I,M):g.lineTo(I,M)}),g.stroke())}),h.forEach(E=>{const N=cT(E.width,0),A=cT(E.height,0);if(N<=0||A<=0)return;const I=Hx(E.center?.x)??0,M=Hx(E.center?.y)??0,k=x(I),C=b(M),U=Y5(E),O=typeof U=="string"?Hx(U):U,H=hI(N,A,O);g.save(),g.translate(k,C);const Y=N/2*r,W=A/2*r,K=Math.min(H*r,Y,W),J=E.has_stroke??!1,se=E.is_filled??!0,de=E.is_stroke_dashed??!1,ve=J?cT(E.stroke_width,.1)*r:0;if(((ue,me,Me,ke,ze)=>{if(g.beginPath(),ze<=0)g.rect(ue,me,Me,ke);else{const Be=ze,Re=ue+Me,oe=me+ke;g.moveTo(ue+Be,me),g.lineTo(Re-Be,me),g.quadraticCurveTo(Re,me,Re,me+Be),g.lineTo(Re,oe-Be),g.quadraticCurveTo(Re,oe,Re-Be,oe),g.lineTo(ue+Be,oe),g.quadraticCurveTo(ue,oe,ue,oe-Be),g.lineTo(ue,me+Be),g.quadraticCurveTo(ue,me,ue+Be,me),g.closePath()}})(-Y,-W,Y*2,W*2,K),se&&g.fill(),J&&ve>0){if(g.lineWidth=ve,de){const ue=Math.max(ve*2,1);g.setLineDash([ue,ue])}g.stroke(),de&&g.setLineDash([])}g.restore()}),l.forEach(E=>{const N=E.font_size||.25,A=Math.min(Math.max(.01,N*.1),N*.05)*r;g.lineWidth=A,g.lineCap="butt",g.lineJoin="miter";const I=(0,s5n.vectorText)({height:N*.45,input:E.text}),M=[];I.forEach(de=>{de.length===29?(M.push(de.slice(0,15)),M.push(de.slice(14,29))):de.length===17?(M.push(de.slice(0,10)),M.push(de.slice(9,17))):M.push(de)});const k=M.flat(),C={minX:k.length>0?Math.min(...k.map(de=>de[0])):0,maxX:k.length>0?Math.max(...k.map(de=>de[0])):0,minY:k.length>0?Math.min(...k.map(de=>de[1])):0,maxY:k.length>0?Math.max(...k.map(de=>de[1])):0},U=(C.minX+C.maxX)/2,O=(C.minY+C.maxY)/2;let H=-U,Y=-O;const W=E.anchor_alignment||"center";W.includes("left")?H=-C.minX:W.includes("right")&&(H=-C.maxX),W.includes("top")?Y=-C.maxY:W.includes("bottom")&&(Y=-C.minY);const K=[];let J=E.ccw_rotation??0;if(E.layer==="bottom"&&(K.push(jM(U,O),{a:-1,b:0,c:0,d:1,e:0,f:0},jM(-U,-O)),J=-J),J){const de=J*Math.PI/180;K.push(jM(U,O),zet(de),jM(-U,-O))}const se=K.length>0?Det(...K):void 0;M.forEach(de=>{g.beginPath(),de.forEach((ve,re)=>{let ue={x:ve[0],y:ve[1]};se&&(ue=Oet(se,ue));const me=ue.x+H+E.anchor_position.x,Me=ue.y+Y+E.anchor_position.y,ke=x(me),ze=b(Me);re===0?g.moveTo(ke,ze):g.lineTo(ke,ze)}),g.stroke()})});const w=new bOe(p);return w.generateMipmaps=!0,w.minFilter=FS,w.magFilter=v1,w.anisotropy=16,w.needsUpdate=!0,w}function Ket({Manifold:n,x:e,y:t,diameter:i,thickness:r,segments:o=32}){return n.cylinder(r*1.2,i/2,i/2,o,!0).translate([e,t,0])}function Zet({Manifold:n,x:e,y:t,outerDiameter:i,thickness:r,zOffset:o=.001,segments:s=32}){const a=i/2+o;return n.cylinder(r*1.2,a,a,s,!0).translate([e,t,0])}var a5n=64;function lT({Manifold:n,width:e,height:t,thickness:i,borderRadius:r}){const o=hI(e,t,r);if(o<=0)return n.cube([e,t,i],!0);const s=[],a=e-2*o,c=t-2*o;return a>0&&s.push(n.cube([a,t,i],!0)),c>0&&s.push(n.cube([e,c,i],!0)),[[e/2-o,t/2-o],[-e/2+o,t/2-o],[-e/2+o,-t/2+o],[e/2-o,-t/2+o]].forEach(([u,d])=>{s.push(n.cylinder(i,o,o,a5n,!0).translate([u,d,0]))}),n.union(s)}function c5n({Manifold:n,pad:e,padBaseThickness:t}){if(e.shape==="rect"){const i=Y5(e);return lT({Manifold:n,width:e.width,height:e.height,thickness:t,borderRadius:i})}else if(e.shape==="rotated_rect"){const i=Y5(e);let r=lT({Manifold:n,width:e.width,height:e.height,thickness:t,borderRadius:i});const o=e.ccw_rotation??0;return o&&(r=r.rotate([0,0,o])),r}else if(e.shape==="circle"&&e.radius)return n.cylinder(t,e.radius,-1,32,!0);return null}function l5n(n){return(n.shape==="circle"||n.hole_shape==="circle")&&typeof n.hole_diameter=="number"}function u5n(n){return(n.shape==="pill"||n.hole_shape==="pill")&&typeof n.hole_width=="number"&&typeof n.hole_height=="number"}function d5n(n){return(n.shape==="rotated_pill"||n.hole_shape==="rotated_pill")&&typeof n.hole_width=="number"&&typeof n.hole_height=="number"&&typeof n.ccw_rotation=="number"}function h5n(n,e,t,i){const r=[],o=fs(e).pcb_hole.list(),s=(a,c,l)=>{const u=lT({Manifold:n,width:a,height:c,thickness:l,borderRadius:Math.min(a,c)/2});return i.push(u),u};return o.forEach(a=>{if(l5n(a)){const c=Ket({Manifold:n,x:a.x,y:a.y,diameter:a.hole_diameter,thickness:t,segments:ZS});i.push(c),r.push(c)}else if(u5n(a)){const c=a.hole_width,l=a.hole_height,u=t*1.2,h=s(c,l,u).translate([a.x,a.y,0]);i.push(h),r.push(h)}else if(d5n(a)){const c=a.hole_width,l=a.hole_height,u=t*1.2;let d=s(c,l,u);const h=d.rotate([0,0,a.ccw_rotation]);i.push(h),d=h;const p=d.translate([a.x,a.y,0]);i.push(p),r.push(p)}}),{nonPlatedHoleBoardDrills:r}}var vV=new Jr(...Zd.copper),Qet=.05;function p5n(n,e,t,i,r){const o=[],s=fs(e).pcb_plated_hole.list(),a=[],c=[],l=(d,h,p)=>{const m=lT({Manifold:n,width:d,height:h,thickness:p,borderRadius:Math.min(d,h)/2});return i.push(m),m};s.forEach((d,h)=>{if(d.shape==="circle"){const p=Zet({Manifold:n,x:d.x,y:d.y,outerDiameter:d.hole_diameter*1.02,thickness:t,zOffset:aT,segments:ZS});i.push(p),o.push(p);const m=t+2*aT,_=n.cylinder(m,d.outer_diameter/2,d.outer_diameter/2,ZS,!0);i.push(_);const g=n.cylinder(m*1.05,d.hole_diameter/2,d.hole_diameter/2,ZS,!0);i.push(g);const x=_.subtract(g);i.push(x);const b=x.translate([d.x,d.y,0]);i.push(b);let w=b;if(r){const N=n.intersection([b,r]);i.push(N),w=N}c.push(w);const E=q5(w.getMesh());a.push({key:`ph-${d.pcb_plated_hole_id||h}`,geometry:E,color:vV})}else if(d.shape==="pill"){const p=d.hole_width,m=d.hole_height,_=.4,g=d.outer_width??p+_,x=d.outer_height??m+_,b=p+2*aT,w=m+2*aT,E=t*1.2;let N=l(b,w,E);if(d.ccw_rotation){const Y=N.rotate([0,0,d.ccw_rotation]);i.push(Y),N=Y}const A=N.translate([d.x,d.y,0]);i.push(A),o.push(A);const I=t+2*aT,M=l(g,x,I),k=l(p,m,I*1.05);let C=M.subtract(k);if(i.push(C),d.ccw_rotation){const Y=C.rotate([0,0,d.ccw_rotation]);i.push(Y),C=Y}const U=C.translate([d.x,d.y,0]);i.push(U);let O=U;if(r){const Y=n.intersection([U,r]);i.push(Y),O=Y}c.push(O);const H=q5(O.getMesh());a.push({key:`ph-${d.pcb_plated_hole_id||h}`,geometry:H,color:vV})}else if(d.shape==="pill_hole_with_rect_pad"){const p=d.hole_width,m=d.hole_height,_=d.hole_offset_x||0,g=d.hole_offset_y||0,x=d.rect_pad_width,b=d.rect_pad_height,w=Y5(d),E=mV,N=p+2*aT,A=m+2*aT,I=t*1.2,k=l(N,A,I).translate([_,g,0]).translate([d.x,d.y,0]);i.push(k),o.push(k);const C=lT({Manifold:n,width:x,height:b,thickness:t-2*E-2*Iv.copper+.1,borderRadius:w});i.push(C);const U=lT({Manifold:n,width:x,height:b,thickness:E,borderRadius:w}).translate([0,0,t/2/2+Iv.copper]),O=lT({Manifold:n,width:x,height:b,thickness:E,borderRadius:w}).translate([0,0,-t/2/2-Iv.copper]);i.push(U,O);const H=l(p,m,t*1.02).translate([_,g,0]);i.push(H);const Y=n.union([C,U,O,H]);i.push(Y);const W=l(Math.max(p-2*Qet,.01),Math.max(m-2*Qet,.01),t*1.2).translate([_,g,0]);i.push(W);const K=Y.subtract(W);i.push(K);const J=K.translate([d.x,d.y,0]);i.push(J);let se=J;if(r){const ve=n.intersection([J,r]);i.push(ve),se=ve}c.push(se);const de=q5(se.getMesh());a.push({key:`ph-${d.pcb_plated_hole_id||h}`,geometry:de,color:vV})}else if(d.shape==="circular_hole_with_rect_pad"){const p=d.hole_offset_x||0,m=d.hole_offset_y||0,_=Ket({Manifold:n,x:d.x+p,y:d.y+m,diameter:d.hole_diameter,thickness:t,segments:ZS});i.push(_),o.push(_);const g=d.rect_pad_width??d.hole_diameter,x=d.rect_pad_height??d.hole_diameter,b=Y5(d),w=mV,E=d.hole_diameter/2,N=lT({Manifold:n,width:g,height:x,thickness:t-2*w-2*Iv.copper+.1,borderRadius:b});i.push(N);const A=lT({Manifold:n,width:g,height:x,thickness:w,borderRadius:b}).translate([0,0,t/2/2+Iv.copper]),I=lT({Manifold:n,width:g,height:x,thickness:w,borderRadius:b}).translate([0,0,-t/2/2-Iv.copper]);i.push(A,I);const M=n.cylinder(t*1.02,E,E,ZS,!0).translate([p,m,0]);i.push(M);const k=n.union([N,A,I,M]);i.push(k);const C=n.cylinder(t*1.2,Math.max(E-Yl,.01),Math.max(E-Yl,.01),ZS,!0).translate([p,m,0]);i.push(C);const U=k.subtract(C);i.push(U);const O=U.translate([d.x,d.y,0]);i.push(O);let H=O;if(r){const W=n.intersection([O,r]);i.push(W),H=W}c.push(H);const Y=q5(H.getMesh());a.push({key:`ph-${d.pcb_plated_hole_id||h}`,geometry:Y,color:vV})}});let u;return c.length>0&&(u=n.union(c),i.push(u)),{platedHoleBoardDrills:o,platedHoleCopperGeoms:a,platedHoleSubtractOp:u}}function f5n({Manifold:n,x:e,y:t,outerDiameter:i,holeDiameter:r,thickness:o,zOffset:s=.001,segments:a=32}){const c=o+2*s;let l=n.cylinder(c,i/2,-1,a,!0);const u=n.cylinder(c*1.05,r/2,-1,a,!0);return l.subtract(u).translate([e,t,0])}var m5n=new Jr(...Zd.copper);function _5n(n,e,t,i,r){const o=[],s=fs(e).pcb_via.list(),a=[];return s.forEach((c,l)=>{if(typeof c.outer_diameter=="number"){const u=Zet({Manifold:n,x:c.x,y:c.y,outerDiameter:c.outer_diameter,thickness:t,zOffset:aT,segments:ZS});i.push(u),o.push(u)}if(typeof c.outer_diameter=="number"&&typeof c.hole_diameter=="number"){const u=f5n({Manifold:n,x:c.x,y:c.y,outerDiameter:c.outer_diameter,holeDiameter:c.hole_diameter,thickness:t,zOffset:aT,segments:ZS});i.push(u);let d=u;if(r){const p=n.intersection([u,r]);i.push(p),d=p}const h=q5(d.getMesh());a.push({key:`via-${c.pcb_via_id||l}`,geometry:h,color:m5n})}}),{viaBoardDrills:o,viaCopperGeoms:a}}var y5n=new Jr(...Zd.copper);function g5n(n,e,t,i,r,o){const s=[];return fs(e).pcb_smtpad.list().forEach((c,l)=>{const u=mV,d=c.layer==="bottom"?-t/2-Iv.copper:t/2+Iv.copper;let h=c5n({Manifold:n,pad:c,padBaseThickness:u});if(h){i.push(h);const p=h.translate([c.x,c.y,d]);i.push(p);let m=p;if(r&&(m=p.subtract(r),i.push(m)),o){const g=n.intersection([m,o]);i.push(g),m=g}const _=q5(m.getMesh());s.push({key:`smt_pad-${c.layer||"top"}-${c.pcb_smtpad_id||l}`,geometry:_,color:y5n})}}),{smtPadGeoms:s}}var x5n=n=>{let e=0;for(let i=0;i<n.length;i++){const r=(i+1)%n.length;n[i]&&n[r]&&(e+=n[i][0]*n[r][1],e-=n[r][0]*n[i][1])}return e/2<=0};function b5n(n,e,t,i,r){let o,s=null;if(t.outline&&t.outline.length>=3){let a=t.outline.map(l=>[l.x,l.y]);x5n(a)&&(a=a.reverse());const c=e.ofPolygons([a]);r.push(c),s=c,o=n.extrude(c,i,void 0,void 0,void 0,!0),r.push(o)}else t.outline&&t.outline.length>0&&console.warn("Board outline has fewer than 3 points, falling back to rectangular board."),o=n.cube([t.width,t.height,i],!0),r.push(o),o=o.translate([t.center.x,t.center.y,0]),r.push(o);return{boardOp:o,outlineCrossSection:s}}var Wye=n=>{let e=0;for(let i=0;i<n.length;i++){const r=(i+1)%n.length;n[i]&&n[r]&&(e+=n[i][0]*n[r][1],e-=n[r][0]*n[i][1])}return e/2<=0};function v5n(n,e,t,i){if(!t||Math.abs(t)<1e-9)return[];const r=4*Math.atan(t),o=e[0]-n[0],s=e[1]-n[1],a=Math.sqrt(o*o+s*s);if(a<1e-9)return[];const c=Math.abs(a/(2*Math.sin(r/2))),l=Math.sqrt(Math.max(0,c*c-a/2*(a/2))),u=[(n[0]+e[0])/2,(n[1]+e[1])/2],d=o/a,p=-(s/a),m=d,_=u[0]+p*l*Math.sign(t),g=u[1]+m*l*Math.sign(t),x=Math.atan2(n[1]-g,n[0]-_),b=[],w=Math.max(2,Math.ceil(i*Math.abs(r)/(Math.PI*2)*4)),E=r/w;for(let N=1;N<w;N++){const A=x+E*N;b.push([_+c*Math.cos(A),g+c*Math.sin(A)])}return b}function Jet(n,e){const t=[],i=n.vertices;for(let r=0;r<i.length;r++){const o=i[r],s=i[(r+1)%i.length];if(t.push([o.x,o.y]),o.bulge){const a=v5n([o.x,o.y],[s.x,s.y],o.bulge,e);t.push(...a)}}return t}function w5n(n,e,t,i,r,o,s,a){const c=[],l=t.filter(u=>u.type==="pcb_copper_pour");for(const u of l){const d=mV,p=(u.layer==="bottom"?-1:1)*(i/2+d/2+aT);let m;if(u.shape==="rect"){if(m=n.cube([u.width,u.height,d],!0),r.push(m),u.rotation){const _=m.rotate([0,0,u.rotation]);r.push(_),m=_}m=m.translate([u.center.x,u.center.y,p]),r.push(m)}else if(u.shape==="polygon"){if(u.points.length<3)continue;let _=u.points.map(x=>[x.x,x.y]);Wye(_)&&(_=_.reverse());const g=e.ofPolygons([_]);r.push(g),m=n.extrude(g,d,0,0,[1,1],!0).translate([0,0,p]),r.push(m)}else if(u.shape==="brep"){const _=u.brep_shape;if(!_||!_.outer_ring)continue;let g=Jet(_.outer_ring,ZS);Wye(g)&&(g=g.reverse());const x=[g];if(_.inner_rings){const w=_.inner_rings.map(E=>{let N=Jet(E,ZS);return Wye(N)||(N=N.reverse()),N});x.push(...w)}const b=e.ofPolygons(x);r.push(b),m=n.extrude(b,d,0,0,[1,1],!0).translate([0,0,p]),r.push(m)}if(m){if(s){const w=m.subtract(s);r.push(w),m=w}if(a){const w=n.intersection([m,a]);r.push(w),m=w}const g=u.covered_with_solder_mask!==!1?yV[o]??Zd.fr4GreenSolderWithMask:Zd.copper,x=new Jr(...g),b=q5(m.getMesh());c.push({key:`coppour-${u.pcb_copper_pour_id}`,geometry:b,color:x})}}return{copperPourGeoms:c}}var S5n=n=>{let e=0;for(let i=0;i<n.length;i++){const r=(i+1)%n.length;n[i]&&n[r]&&(e+=n[i][0]*n[r][1],e-=n[r][0]*n[i][1])}return e/2<=0};function E5n(n,e,t,i,r){const o=[],s=fs(t).pcb_cutout.list();for(const a of s){let c;const l=i*1.5;switch(a.shape){case"rect":if(c=n.cube([a.width,a.height,l],!0),r.push(c),a.rotation){a.rotation*Math.PI/180;const h=c.rotate([0,0,a.rotation]);r.push(h),c=h}c=c.translate([a.center.x,a.center.y,0]),r.push(c);break;case"circle":c=n.cylinder(l,a.radius,-1,ZS,!0),r.push(c),c=c.translate([a.center.x,a.center.y,0]),r.push(c);break;case"polygon":if(a.points.length<3){console.warn(`PCB Cutout [${a.pcb_cutout_id}] polygon has fewer than 3 points, skipping.`);continue}let u=a.points.map(h=>[h.x,h.y]);S5n(u)&&(u=u.reverse());const d=e.ofPolygons([u]);r.push(d),c=n.extrude(d,l,0,0,[1,1],!0),r.push(c);break;default:console.warn(`Unsupported cutout shape: ${a.shape} for cutout ${a.pcb_cutout_id}`);continue}c&&o.push(c)}return{cutoutOps:o}}var T5n=(n,e)=>{const[t,i]=fe.useState(null),[r,o]=fe.useState(null),[s,a]=fe.useState(null),[c,l]=fe.useState(null),[u,d]=fe.useState(!0),h=fe.useRef([]),p=fe.useMemo(()=>{const m=fs(e).pcb_board.list();return m.length===0?null:m[0]},[e]);return fe.useEffect(()=>{if(!n||!p){i(null),o(null),a(null),d(!1);return}if((p.width===0||!p.width)&&(p.height===0||!p.height)&&(!p.outline||p.outline.length<3)){i({platedHoles:[],smtPads:[],vias:[]}),o({}),a(p.thickness??0),d(!1);return}d(!0),l(null);const m=n.Manifold,_=n.CrossSection,g=E=>{if(!(!E||typeof E.delete!="function"))try{E.delete()}catch(N){(!(N instanceof Error)||!N.message?.includes("Manifold instance already deleted"))&&console.warn("Failed to delete Manifold instance",N)}};h.current.forEach(g),h.current=[];let x=null;const b={},w={};try{const E=p.thickness||1.6;a(E);const{boardOp:N,outlineCrossSection:A}=b5n(m,_,p,E,h.current);let I=N;const k=E+2*1;let C=null;const U=.01;if(A){let ze=A;if(U>0){const Re=A.offset(U);h.current.push(Re),ze=Re}const Be=m.extrude(ze,k,void 0,void 0,void 0,!0);h.current.push(Be),C=Be}else{const ze=(p.width||0)+2*U,Be=(p.height||0)+2*U,Re=m.cube([ze,Be,k],!0);h.current.push(Re);const oe=Re.translate([p.center.x,p.center.y,0]);h.current.push(oe),C=oe}const O=[];let H=null;const{nonPlatedHoleBoardDrills:Y}=h5n(m,e,E,h.current);O.push(...Y);const{platedHoleBoardDrills:W,platedHoleCopperGeoms:K,platedHoleSubtractOp:J}=p5n(m,e,E,h.current,C);O.push(...W),b.platedHoles=K;const{viaBoardDrills:se,viaCopperGeoms:de}=_5n(m,e,E,h.current,C);if(O.push(...se),b.vias=de,O.length>0){H=m.union(O),h.current.push(H);const ze=J?m.union([H,J]):H;h.current.push(ze);const Be=I.subtract(ze);if(h.current.push(Be),I=Be,J){const Re=J.subtract(H);h.current.push(Re);const oe=Re.getMesh(),Ee=q5(oe);b.platedHoles=[{key:"plated-holes-union",geometry:Ee,color:new Jr(Zd.copper[0],Zd.copper[1],Zd.copper[2])}]}}const{cutoutOps:ve}=E5n(m,_,e,E,h.current);if(ve.length>0){const ze=m.union(ve);h.current.push(ze);const Be=I.subtract(ze);h.current.push(Be),I=Be}if(x=I,x){const ze=x.getMesh(),Be=q5(ze),Re=Uye[p.material]??Zd.fr4Green;b.board={geometry:Be,color:new Jr(Re[0],Re[1],Re[2]),material:p.material}}const{smtPadGeoms:re}=g5n(m,e,E,h.current,H,C);b.smtPads=re;const{copperPourGeoms:ue}=w5n(m,_,e,E,h.current,p.material,H,C);b.copperPours=ue,i(b);const me=yV[p.material]??Zd.fr4GreenSolderWithMask,Me=`rgb(${Math.round(me[0]*255)}, ${Math.round(me[1]*255)}, ${Math.round(me[2]*255)})`;w.topTrace=Xet({layer:"top",circuitJson:e,boardData:p,traceColor:Me,traceTextureResolution:_V}),w.bottomTrace=Xet({layer:"bottom",circuitJson:e,boardData:p,traceColor:Me,traceTextureResolution:_V});const ke="rgb(255,255,255)";w.topSilkscreen=Wet({layer:"top",circuitJson:e,boardData:p,silkscreenColor:ke,traceTextureResolution:_V}),w.bottomSilkscreen=Wet({layer:"bottom",circuitJson:e,boardData:p,silkscreenColor:ke,traceTextureResolution:_V}),o(w)}catch(E){console.error("Error processing geometry with Manifold in hook:",E),l(E.message||"An unknown error occurred while processing geometry in hook."),i(null),o(null)}finally{d(!1)}return()=>{h.current.forEach(g),h.current=[]}},[n,e,p]),{geoms:t,textures:r,pcbThickness:s,error:c,isLoading:u,boardData:p}},M5n=qg,C5n=({material:n,color:e,side:t=M5n})=>n==="fr4"?new H2({color:e,side:t,metalness:0,roughness:.8,specularIntensity:.2,ior:1.45,sheen:0,clearcoat:0,transparent:!1,opacity:1,flatShading:!0}):new Gb({color:e,side:t,flatShading:!0,metalness:.1,roughness:.8,transparent:!0,opacity:.9});function A5n(n){const e=[];if(!n)return e;if(n.board&&n.board.geometry){const i=new Ma(n.board.geometry,C5n({material:n.board.material,color:n.board.color,side:qg}));i.name="board-geom",e.push(i)}const t=i=>{i&&i.forEach(r=>{const o=new Ma(r.geometry,new Gb({color:r.color,side:qg,flatShading:!0}));o.name=r.key,e.push(o)})};return t(n.platedHoles),t(n.smtPads),t(n.vias),t(n.copperPours),e}function P5n(n,e,t){const i=[];if(!n||!e||t===null)return i;const r=(l,u,d,h)=>{if(!l)return null;const p=new BE(e.width,e.height),m=new sw({map:l,transparent:!0,side:qg,depthWrite:!1}),_=new Ma(p,m);return _.position.set(e.center.x,e.center.y,u),d&&_.rotation.set(Math.PI,0,0),_.name=`${d?"bottom":"top"}-${h}-texture-plane`,_},o=r(n.topTrace,t/2+Iv.traces,!1,"trace");o&&i.push(o);const s=r(n.topSilkscreen,t/2+.017,!1,"silkscreen");s&&i.push(s);const a=r(n.bottomTrace,-t/2-Iv.traces,!0,"trace");a&&i.push(a);const c=r(n.bottomSilkscreen,-t/2-.017,!0,"silkscreen");return c&&i.push(c),i}var R5n=({geometryMeshes:n,textureMeshes:e})=>{const{rootObject:t}=_b(),{visibility:i}=_8();return fe.useEffect(()=>{if(t)return n.forEach(r=>{let o=!0;r.name==="board-geom"?o=i.boardBody:r.name.includes("smt_pad")?r.name.includes("smt_pad-top")?o=i.topCopper:r.name.includes("smt_pad-bottom")?o=i.bottomCopper:o=i.topCopper||i.bottomCopper:(r.name.includes("plated_hole")||r.name.includes("via")||r.name.includes("copper_pour"))&&(o=i.topCopper||i.bottomCopper),o&&t.add(r)}),e.forEach(r=>{let o=!0;r.name.includes("top-trace")?o=i.topCopper:r.name.includes("bottom-trace")?o=i.bottomCopper:r.name.includes("top-silkscreen")?o=i.topSilkscreen:r.name.includes("bottom-silkscreen")&&(o=i.bottomSilkscreen),o&&t.add(r)}),()=>{n.forEach(r=>{r.parent===t&&t.remove(r)}),e.forEach(r=>{r.parent===t&&t.remove(r)})}},[t,n,e,i]),null},I5n="https://cdn.jsdelivr.net/npm/manifold-3d@3.2.1",N5n=({circuitJson:n,autoRotateDisabled:e,clickToInteractEnabled:t,onUserInteraction:i,children:r,onCameraControllerReady:o})=>{const s=Net(r),a=fe.useMemo(()=>n??s,[n,s]),[c,l]=fe.useState(null),[u,d]=fe.useState(null);fe.useEffect(()=>{if(window.ManifoldModule&&typeof window.ManifoldModule=="object"&&window.ManifoldModule.setup){l(window.ManifoldModule);return}const M=async Y=>{try{const W=await Y();W.setup(),window.ManifoldModule=W,l(W)}catch(W){console.error("Failed to initialize Manifold:",W),d(`Failed to initialize Manifold: ${W instanceof Error?W.message:"Unknown error"}`)}},k=window.ManifoldModule??window.MANIFOLD??window.MANIFOLD_MODULE;if(k){window.ManifoldModule=k,M(window.ManifoldModule);return}const C="manifoldLoaded",U=()=>{const Y=window.ManifoldModule??window.MANIFOLD??window.MANIFOLD_MODULE;if(Y)window.ManifoldModule=Y,M(window.ManifoldModule);else{const W="ManifoldModule not found on window after script load.";console.error(W),d(W)}};window.addEventListener(C,U,{once:!0});const O=document.createElement("script");O.type="module",O.innerHTML=`
5123
5123
  try {
5124
5124
  const { default: ManifoldModule } = await import('${I5n}/manifold.js');
5125
5125
  window.ManifoldModule = ManifoldModule;
@@ -5128,7 +5128,7 @@ try {
5128
5128
  } finally {
5129
5129
  window.dispatchEvent(new CustomEvent('${C}'));
5130
5130
  }
5131
- `.trim();const H=Y=>{const W="Failed to load Manifold loader script.";console.error(W,Y),d(W),window.removeEventListener(C,U)};return O.addEventListener("error",H),document.body.appendChild(O),()=>{window.removeEventListener(C,U),O.removeEventListener("error",H)}},[]);const{geoms:h,textures:p,pcbThickness:m,error:_,isLoading:g,boardData:x}=T5n(c,a),b=fe.useMemo(()=>A5n(h),[h]),w=fe.useMemo(()=>P5n(p,x,m),[p,x,m]),E=fe.useMemo(()=>fs(a).cad_component.list(),[a]),N=fe.useMemo(()=>{if(!x)return;const{width:M=0,height:k=0}=x;return{width:M,height:k}},[x]),A=fe.useMemo(()=>{if(!x)return;const{center:M}=x;if(M)return{x:M.x,y:M.y}},[x]),I=fe.useMemo(()=>{if(!x)return[5,5,5];const{width:M=0,height:k=0}=x,C=Math.max(M,1),U=Math.max(k,1),O=Math.max(C,U,5);return[O*.75,O*.75,O*.75]},[x]);return u?ce.jsxs("div",{style:{color:"red",padding:"1em",border:"1px solid red",margin:"1em"},children:["Error: ",u]}):c?_?ce.jsxs("div",{style:{color:"red",padding:"1em",border:"1px solid red",margin:"1em"},children:["Error: ",_]}):g?ce.jsx("div",{style:{padding:"1em"},children:"Processing board geometry..."}):ce.jsxs(Iet,{initialCameraPosition:I,autoRotateDisabled:e,clickToInteractEnabled:t,boardDimensions:N,boardCenter:A,onUserInteraction:i,onCameraControllerReady:o,children:[ce.jsx(R5n,{geometryMeshes:b,textureMeshes:w}),E.map(M=>ce.jsx(Yet,{fallback:({error:k})=>ce.jsx(Get,{cad_component:M,error:k}),children:ce.jsx(Aet,{cad_component:M,circuitJson:a})},M.cad_component_id))]}):ce.jsx("div",{style:{padding:"1em"},children:"Loading Manifold module..."})},k5n=N5n,O5n=({containerRef:n})=>{const[e,t]=fe.useState(!1),[i,r]=fe.useState({x:0,y:0}),o=fe.useRef(null),s=fe.useRef(null),a=fe.useRef(null),c=fe.useRef(!1),l=()=>{a.current!==null&&(clearTimeout(a.current),a.current=null)},u=fe.useCallback(g=>{g.preventDefault();const x=typeof g.clientX=="number"?g.clientX:0,b=typeof g.clientY=="number"?g.clientY:0;if(c.current){c.current=!1;return}if(!s.current)return;const{x:w,y:E}=s.current,N=Math.abs(x-w),A=Math.abs(b-E),I=10;if(N>I||A>I){s.current=null;return}r({x,y:b}),t(!0),s.current=null},[r,t]),d=fe.useCallback(g=>{if(g.touches.length===1){const x=g.touches[0];x?(s.current={x:x.clientX,y:x.clientY},l(),a.current=window.setTimeout(()=>{if(s.current){if(n.current){const b=n.current.getBoundingClientRect();r({x:b.left+b.width/2,y:b.top+b.height/2}),t(!0),c.current=!0}s.current=null}},600)):s.current=null}else s.current=null,l()},[n]),h=fe.useCallback(g=>{if(!s.current||g.touches.length!==1)return;const x=g.touches[0];if(x){const b=Math.abs(x.clientX-s.current.x),w=Math.abs(x.clientY-s.current.y),E=10;(b>E||w>E)&&(s.current=null,l())}else s.current=null,l()},[]),p=fe.useCallback(()=>{l(),setTimeout(()=>{s.current&&(s.current=null)},0)},[]),m=fe.useCallback(g=>{const x=g.target;o.current&&!o.current.contains(x)&&t(!1)},[]);return fe.useEffect(()=>{if(e)return document.addEventListener("mousedown",m),document.addEventListener("touchstart",m),()=>{document.removeEventListener("mousedown",m),document.removeEventListener("touchstart",m)}},[e,m]),{menuVisible:e,menuPos:i,menuRef:o,contextMenuEventHandlers:{onMouseDown:g=>{g.button===2?s.current={x:g.clientX,y:g.clientY}:s.current=null},onContextMenu:u,onTouchStart:d,onTouchMove:h,onTouchEnd:p},setMenuVisible:t}},L5n=()=>fe.useCallback(()=>{const n=window.__TSCIRCUIT_THREE_OBJECT;if(!n)return;new HOe().parse(n,t=>{const i=new Blob([t instanceof ArrayBuffer?t:JSON.stringify(t)],{type:"model/gltf+json"}),r=URL.createObjectURL(i),o=document.createElement("a");o.href=r,o.download="scene.gltf",o.click(),URL.revokeObjectURL(r)},t=>{console.error("Failed to export GLTF",t)})},[]);function gd(n,e,{checkForDefaultPrevented:t=!0}={}){return function(r){if(n?.(r),t===!1||!r.defaultPrevented)return e?.(r)}}function ett(n,e){if(typeof n=="function")return n(e);n!=null&&(n.current=e)}function wV(...n){return e=>{let t=!1;const i=n.map(r=>{const o=ett(r,e);return!t&&typeof o=="function"&&(t=!0),o});if(t)return()=>{for(let r=0;r<i.length;r++){const o=i[r];typeof o=="function"?o():ett(n[r],null)}}}}function dw(...n){return fe.useCallback(wV(...n),n)}function g8(n,e=[]){let t=[];function i(o,s){const a=fe.createContext(s),c=t.length;t=[...t,s];const l=d=>{const{scope:h,children:p,...m}=d,_=h?.[n]?.[c]||a,g=fe.useMemo(()=>m,Object.values(m));return ce.jsx(_.Provider,{value:g,children:p})};l.displayName=o+"Provider";function u(d,h){const p=h?.[n]?.[c]||a,m=fe.useContext(p);if(m)return m;if(s!==void 0)return s;throw new Error(`\`${d}\` must be used within \`${o}\``)}return[l,u]}const r=()=>{const o=t.map(s=>fe.createContext(s));return function(a){const c=a?.[n]||o;return fe.useMemo(()=>({[`__scope${n}`]:{...a,[n]:c}}),[a,c])}};return r.scopeName=n,[i,D5n(r,...e)]}function D5n(...n){const e=n[0];if(n.length===1)return e;const t=()=>{const i=n.map(r=>({useScope:r(),scopeName:r.scopeName}));return function(o){const s=i.reduce((a,{useScope:c,scopeName:l})=>{const d=c(o)[`__scope${l}`];return{...a,...d}},{});return fe.useMemo(()=>({[`__scope${e.scopeName}`]:s}),[s])}};return t.scopeName=e.scopeName,t}var HM=globalThis?.document?fe.useLayoutEffect:()=>{},z5n=nz[" useInsertionEffect ".trim().toString()]||HM;function Kye({prop:n,defaultProp:e,onChange:t=()=>{},caller:i}){const[r,o,s]=$5n({defaultProp:e,onChange:t}),a=n!==void 0,c=a?n:r;{const u=fe.useRef(n!==void 0);fe.useEffect(()=>{const d=u.current;d!==a&&console.warn(`${i} is changing from ${d?"controlled":"uncontrolled"} to ${a?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),u.current=a},[a,i])}const l=fe.useCallback(u=>{if(a){const d=F5n(u)?u(n):u;d!==n&&s.current?.(d)}else o(u)},[a,n,o,s]);return[c,l]}function $5n({defaultProp:n,onChange:e}){const[t,i]=fe.useState(n),r=fe.useRef(t),o=fe.useRef(e);return z5n(()=>{o.current=e},[e]),fe.useEffect(()=>{r.current!==t&&(o.current?.(t),r.current=t)},[t,r]),[t,i,o]}function F5n(n){return typeof n=="function"}function SV(n){const e=U5n(n),t=fe.forwardRef((i,r)=>{const{children:o,...s}=i,a=fe.Children.toArray(o),c=a.find(j5n);if(c){const l=c.props.children,u=a.map(d=>d===c?fe.Children.count(l)>1?fe.Children.only(null):fe.isValidElement(l)?l.props.children:null:d);return ce.jsx(e,{...s,ref:r,children:fe.isValidElement(l)?fe.cloneElement(l,void 0,u):null})}return ce.jsx(e,{...s,ref:r,children:o})});return t.displayName=`${n}.Slot`,t}function U5n(n){const e=fe.forwardRef((t,i)=>{const{children:r,...o}=t;if(fe.isValidElement(r)){const s=V5n(r),a=H5n(o,r.props);return r.type!==fe.Fragment&&(a.ref=i?wV(i,s):s),fe.cloneElement(r,a)}return fe.Children.count(r)>1?fe.Children.only(null):null});return e.displayName=`${n}.SlotClone`,e}var B5n=Symbol("radix.slottable");function j5n(n){return fe.isValidElement(n)&&typeof n.type=="function"&&"__radixId"in n.type&&n.type.__radixId===B5n}function H5n(n,e){const t={...e};for(const i in e){const r=n[i],o=e[i];/^on[A-Z]/.test(i)?r&&o?t[i]=(...a)=>{const c=o(...a);return r(...a),c}:r&&(t[i]=r):i==="style"?t[i]={...r,...o}:i==="className"&&(t[i]=[r,o].filter(Boolean).join(" "))}return{...n,...t}}function V5n(n){let e=Object.getOwnPropertyDescriptor(n.props,"ref")?.get,t=e&&"isReactWarning"in e&&e.isReactWarning;return t?n.ref:(e=Object.getOwnPropertyDescriptor(n,"ref")?.get,t=e&&"isReactWarning"in e&&e.isReactWarning,t?n.props.ref:n.props.ref||n.ref)}var G5n=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Nv=G5n.reduce((n,e)=>{const t=SV(`Primitive.${e}`),i=fe.forwardRef((r,o)=>{const{asChild:s,...a}=r,c=s?t:e;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),ce.jsx(c,{...a,ref:o})});return i.displayName=`Primitive.${e}`,{...n,[e]:i}},{});function ttt(n,e){n&&Ak.flushSync(()=>n.dispatchEvent(e))}function ntt(n){const e=n+"CollectionProvider",[t,i]=g8(e),[r,o]=t(e,{collectionRef:{current:null},itemMap:new Map}),s=_=>{const{scope:g,children:x}=_,b=wo.useRef(null),w=wo.useRef(new Map).current;return ce.jsx(r,{scope:g,itemMap:w,collectionRef:b,children:x})};s.displayName=e;const a=n+"CollectionSlot",c=SV(a),l=wo.forwardRef((_,g)=>{const{scope:x,children:b}=_,w=o(a,x),E=dw(g,w.collectionRef);return ce.jsx(c,{ref:E,children:b})});l.displayName=a;const u=n+"CollectionItemSlot",d="data-radix-collection-item",h=SV(u),p=wo.forwardRef((_,g)=>{const{scope:x,children:b,...w}=_,E=wo.useRef(null),N=dw(g,E),A=o(u,x);return wo.useEffect(()=>(A.itemMap.set(E,{ref:E,...w}),()=>void A.itemMap.delete(E))),ce.jsx(h,{[d]:"",ref:N,children:b})});p.displayName=u;function m(_){const g=o(n+"CollectionConsumer",_);return wo.useCallback(()=>{const b=g.collectionRef.current;if(!b)return[];const w=Array.from(b.querySelectorAll(`[${d}]`));return Array.from(g.itemMap.values()).sort((A,I)=>w.indexOf(A.ref.current)-w.indexOf(I.ref.current))},[g.collectionRef,g.itemMap])}return[{Provider:s,Slot:l,ItemSlot:p},m,i]}var Y5n=fe.createContext(void 0);function itt(n){const e=fe.useContext(Y5n);return n||e||"ltr"}function uT(n){const e=fe.useRef(n);return fe.useEffect(()=>{e.current=n}),fe.useMemo(()=>(...t)=>e.current?.(...t),[])}function q5n(n,e=globalThis?.document){const t=uT(n);fe.useEffect(()=>{const i=r=>{r.key==="Escape"&&t(r)};return e.addEventListener("keydown",i,{capture:!0}),()=>e.removeEventListener("keydown",i,{capture:!0})},[t,e])}var X5n="DismissableLayer",Zye="dismissableLayer.update",W5n="dismissableLayer.pointerDownOutside",K5n="dismissableLayer.focusOutside",rtt,ott=fe.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),stt=fe.forwardRef((n,e)=>{const{disableOutsidePointerEvents:t=!1,onEscapeKeyDown:i,onPointerDownOutside:r,onFocusOutside:o,onInteractOutside:s,onDismiss:a,...c}=n,l=fe.useContext(ott),[u,d]=fe.useState(null),h=u?.ownerDocument??globalThis?.document,[,p]=fe.useState({}),m=dw(e,I=>d(I)),_=Array.from(l.layers),[g]=[...l.layersWithOutsidePointerEventsDisabled].slice(-1),x=_.indexOf(g),b=u?_.indexOf(u):-1,w=l.layersWithOutsidePointerEventsDisabled.size>0,E=b>=x,N=J5n(I=>{const M=I.target,k=[...l.branches].some(C=>C.contains(M));!E||k||(r?.(I),s?.(I),I.defaultPrevented||a?.())},h),A=e3n(I=>{const M=I.target;[...l.branches].some(C=>C.contains(M))||(o?.(I),s?.(I),I.defaultPrevented||a?.())},h);return q5n(I=>{b===l.layers.size-1&&(i?.(I),!I.defaultPrevented&&a&&(I.preventDefault(),a()))},h),fe.useEffect(()=>{if(u)return t&&(l.layersWithOutsidePointerEventsDisabled.size===0&&(rtt=h.body.style.pointerEvents,h.body.style.pointerEvents="none"),l.layersWithOutsidePointerEventsDisabled.add(u)),l.layers.add(u),att(),()=>{t&&l.layersWithOutsidePointerEventsDisabled.size===1&&(h.body.style.pointerEvents=rtt)}},[u,h,t,l]),fe.useEffect(()=>()=>{u&&(l.layers.delete(u),l.layersWithOutsidePointerEventsDisabled.delete(u),att())},[u,l]),fe.useEffect(()=>{const I=()=>p({});return document.addEventListener(Zye,I),()=>document.removeEventListener(Zye,I)},[]),ce.jsx(Nv.div,{...c,ref:m,style:{pointerEvents:w?E?"auto":"none":void 0,...n.style},onFocusCapture:gd(n.onFocusCapture,A.onFocusCapture),onBlurCapture:gd(n.onBlurCapture,A.onBlurCapture),onPointerDownCapture:gd(n.onPointerDownCapture,N.onPointerDownCapture)})});stt.displayName=X5n;var Z5n="DismissableLayerBranch",Q5n=fe.forwardRef((n,e)=>{const t=fe.useContext(ott),i=fe.useRef(null),r=dw(e,i);return fe.useEffect(()=>{const o=i.current;if(o)return t.branches.add(o),()=>{t.branches.delete(o)}},[t.branches]),ce.jsx(Nv.div,{...n,ref:r})});Q5n.displayName=Z5n;function J5n(n,e=globalThis?.document){const t=uT(n),i=fe.useRef(!1),r=fe.useRef(()=>{});return fe.useEffect(()=>{const o=a=>{if(a.target&&!i.current){let c=function(){ctt(W5n,t,l,{discrete:!0})};const l={originalEvent:a};a.pointerType==="touch"?(e.removeEventListener("click",r.current),r.current=c,e.addEventListener("click",r.current,{once:!0})):c()}else e.removeEventListener("click",r.current);i.current=!1},s=window.setTimeout(()=>{e.addEventListener("pointerdown",o)},0);return()=>{window.clearTimeout(s),e.removeEventListener("pointerdown",o),e.removeEventListener("click",r.current)}},[e,t]),{onPointerDownCapture:()=>i.current=!0}}function e3n(n,e=globalThis?.document){const t=uT(n),i=fe.useRef(!1);return fe.useEffect(()=>{const r=o=>{o.target&&!i.current&&ctt(K5n,t,{originalEvent:o},{discrete:!1})};return e.addEventListener("focusin",r),()=>e.removeEventListener("focusin",r)},[e,t]),{onFocusCapture:()=>i.current=!0,onBlurCapture:()=>i.current=!1}}function att(){const n=new CustomEvent(Zye);document.dispatchEvent(n)}function ctt(n,e,t,{discrete:i}){const r=t.originalEvent.target,o=new CustomEvent(n,{bubbles:!1,cancelable:!0,detail:t});e&&r.addEventListener(n,e,{once:!0}),i?ttt(r,o):r.dispatchEvent(o)}var Qye=0;function t3n(){fe.useEffect(()=>{const n=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",n[0]??ltt()),document.body.insertAdjacentElement("beforeend",n[1]??ltt()),Qye++,()=>{Qye===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(e=>e.remove()),Qye--}},[])}function ltt(){const n=document.createElement("span");return n.setAttribute("data-radix-focus-guard",""),n.tabIndex=0,n.style.outline="none",n.style.opacity="0",n.style.position="fixed",n.style.pointerEvents="none",n}var Jye="focusScope.autoFocusOnMount",ege="focusScope.autoFocusOnUnmount",utt={bubbles:!1,cancelable:!0},n3n="FocusScope",dtt=fe.forwardRef((n,e)=>{const{loop:t=!1,trapped:i=!1,onMountAutoFocus:r,onUnmountAutoFocus:o,...s}=n,[a,c]=fe.useState(null),l=uT(r),u=uT(o),d=fe.useRef(null),h=dw(e,_=>c(_)),p=fe.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;fe.useEffect(()=>{if(i){let _=function(w){if(p.paused||!a)return;const E=w.target;a.contains(E)?d.current=E:VM(d.current,{select:!0})},g=function(w){if(p.paused||!a)return;const E=w.relatedTarget;E!==null&&(a.contains(E)||VM(d.current,{select:!0}))},x=function(w){if(document.activeElement===document.body)for(const N of w)N.removedNodes.length>0&&VM(a)};document.addEventListener("focusin",_),document.addEventListener("focusout",g);const b=new MutationObserver(x);return a&&b.observe(a,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",_),document.removeEventListener("focusout",g),b.disconnect()}}},[i,a,p.paused]),fe.useEffect(()=>{if(a){ftt.add(p);const _=document.activeElement;if(!a.contains(_)){const x=new CustomEvent(Jye,utt);a.addEventListener(Jye,l),a.dispatchEvent(x),x.defaultPrevented||(i3n(c3n(htt(a)),{select:!0}),document.activeElement===_&&VM(a))}return()=>{a.removeEventListener(Jye,l),setTimeout(()=>{const x=new CustomEvent(ege,utt);a.addEventListener(ege,u),a.dispatchEvent(x),x.defaultPrevented||VM(_??document.body,{select:!0}),a.removeEventListener(ege,u),ftt.remove(p)},0)}}},[a,l,u,p]);const m=fe.useCallback(_=>{if(!t&&!i||p.paused)return;const g=_.key==="Tab"&&!_.altKey&&!_.ctrlKey&&!_.metaKey,x=document.activeElement;if(g&&x){const b=_.currentTarget,[w,E]=r3n(b);w&&E?!_.shiftKey&&x===E?(_.preventDefault(),t&&VM(w,{select:!0})):_.shiftKey&&x===w&&(_.preventDefault(),t&&VM(E,{select:!0})):x===b&&_.preventDefault()}},[t,i,p.paused]);return ce.jsx(Nv.div,{tabIndex:-1,...s,ref:h,onKeyDown:m})});dtt.displayName=n3n;function i3n(n,{select:e=!1}={}){const t=document.activeElement;for(const i of n)if(VM(i,{select:e}),document.activeElement!==t)return}function r3n(n){const e=htt(n),t=ptt(e,n),i=ptt(e.reverse(),n);return[t,i]}function htt(n){const e=[],t=document.createTreeWalker(n,NodeFilter.SHOW_ELEMENT,{acceptNode:i=>{const r=i.tagName==="INPUT"&&i.type==="hidden";return i.disabled||i.hidden||r?NodeFilter.FILTER_SKIP:i.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;t.nextNode();)e.push(t.currentNode);return e}function ptt(n,e){for(const t of n)if(!o3n(t,{upTo:e}))return t}function o3n(n,{upTo:e}){if(getComputedStyle(n).visibility==="hidden")return!0;for(;n;){if(e!==void 0&&n===e)return!1;if(getComputedStyle(n).display==="none")return!0;n=n.parentElement}return!1}function s3n(n){return n instanceof HTMLInputElement&&"select"in n}function VM(n,{select:e=!1}={}){if(n&&n.focus){const t=document.activeElement;n.focus({preventScroll:!0}),n!==t&&s3n(n)&&e&&n.select()}}var ftt=a3n();function a3n(){let n=[];return{add(e){const t=n[0];e!==t&&t?.pause(),n=mtt(n,e),n.unshift(e)},remove(e){n=mtt(n,e),n[0]?.resume()}}}function mtt(n,e){const t=[...n],i=t.indexOf(e);return i!==-1&&t.splice(i,1),t}function c3n(n){return n.filter(e=>e.tagName!=="A")}var l3n=nz[" useId ".trim().toString()]||(()=>{}),u3n=0;function x8(n){const[e,t]=fe.useState(l3n());return HM(()=>{t(i=>i??String(u3n++))},[n]),e?`radix-${e}`:""}var d3n=["top","right","bottom","left"],GM=Math.min,oS=Math.max,EV=Math.round,TV=Math.floor,dT=n=>({x:n,y:n}),h3n={left:"right",right:"left",bottom:"top",top:"bottom"},p3n={start:"end",end:"start"};function tge(n,e,t){return oS(n,GM(e,t))}function X5(n,e){return typeof n=="function"?n(e):n}function W5(n){return n.split("-")[0]}function pI(n){return n.split("-")[1]}function nge(n){return n==="x"?"y":"x"}function ige(n){return n==="y"?"height":"width"}var f3n=new Set(["top","bottom"]);function hT(n){return f3n.has(W5(n))?"y":"x"}function rge(n){return nge(hT(n))}function m3n(n,e,t){t===void 0&&(t=!1);const i=pI(n),r=rge(n),o=ige(r);let s=r==="x"?i===(t?"end":"start")?"right":"left":i==="start"?"bottom":"top";return e.reference[o]>e.floating[o]&&(s=MV(s)),[s,MV(s)]}function _3n(n){const e=MV(n);return[oge(n),e,oge(e)]}function oge(n){return n.replace(/start|end/g,e=>p3n[e])}var _tt=["left","right"],ytt=["right","left"],y3n=["top","bottom"],g3n=["bottom","top"];function x3n(n,e,t){switch(n){case"top":case"bottom":return t?e?ytt:_tt:e?_tt:ytt;case"left":case"right":return e?y3n:g3n;default:return[]}}function b3n(n,e,t,i){const r=pI(n);let o=x3n(W5(n),t==="start",i);return r&&(o=o.map(s=>s+"-"+r),e&&(o=o.concat(o.map(oge)))),o}function MV(n){return n.replace(/left|right|bottom|top/g,e=>h3n[e])}function v3n(n){return{top:0,right:0,bottom:0,left:0,...n}}function gtt(n){return typeof n!="number"?v3n(n):{top:n,right:n,bottom:n,left:n}}function CV(n){const{x:e,y:t,width:i,height:r}=n;return{width:i,height:r,top:t,left:e,right:e+i,bottom:t+r,x:e,y:t}}function xtt(n,e,t){let{reference:i,floating:r}=n;const o=hT(e),s=rge(e),a=ige(s),c=W5(e),l=o==="y",u=i.x+i.width/2-r.width/2,d=i.y+i.height/2-r.height/2,h=i[a]/2-r[a]/2;let p;switch(c){case"top":p={x:u,y:i.y-r.height};break;case"bottom":p={x:u,y:i.y+i.height};break;case"right":p={x:i.x+i.width,y:d};break;case"left":p={x:i.x-r.width,y:d};break;default:p={x:i.x,y:i.y}}switch(pI(e)){case"start":p[s]-=h*(t&&l?-1:1);break;case"end":p[s]+=h*(t&&l?-1:1);break}return p}var w3n=async(n,e,t)=>{const{placement:i="bottom",strategy:r="absolute",middleware:o=[],platform:s}=t,a=o.filter(Boolean),c=await(s.isRTL==null?void 0:s.isRTL(e));let l=await s.getElementRects({reference:n,floating:e,strategy:r}),{x:u,y:d}=xtt(l,i,c),h=i,p={},m=0;for(let _=0;_<a.length;_++){const{name:g,fn:x}=a[_],{x:b,y:w,data:E,reset:N}=await x({x:u,y:d,initialPlacement:i,placement:h,strategy:r,middlewareData:p,rects:l,platform:s,elements:{reference:n,floating:e}});u=b??u,d=w??d,p={...p,[g]:{...p[g],...E}},N&&m<=50&&(m++,typeof N=="object"&&(N.placement&&(h=N.placement),N.rects&&(l=N.rects===!0?await s.getElementRects({reference:n,floating:e,strategy:r}):N.rects),{x:u,y:d}=xtt(l,h,c)),_=-1)}return{x:u,y:d,placement:h,strategy:r,middlewareData:p}};async function b8(n,e){var t;e===void 0&&(e={});const{x:i,y:r,platform:o,rects:s,elements:a,strategy:c}=n,{boundary:l="clippingAncestors",rootBoundary:u="viewport",elementContext:d="floating",altBoundary:h=!1,padding:p=0}=X5(e,n),m=gtt(p),g=a[h?d==="floating"?"reference":"floating":d],x=CV(await o.getClippingRect({element:(t=await(o.isElement==null?void 0:o.isElement(g)))==null||t?g:g.contextElement||await(o.getDocumentElement==null?void 0:o.getDocumentElement(a.floating)),boundary:l,rootBoundary:u,strategy:c})),b=d==="floating"?{x:i,y:r,width:s.floating.width,height:s.floating.height}:s.reference,w=await(o.getOffsetParent==null?void 0:o.getOffsetParent(a.floating)),E=await(o.isElement==null?void 0:o.isElement(w))?await(o.getScale==null?void 0:o.getScale(w))||{x:1,y:1}:{x:1,y:1},N=CV(o.convertOffsetParentRelativeRectToViewportRelativeRect?await o.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:b,offsetParent:w,strategy:c}):b);return{top:(x.top-N.top+m.top)/E.y,bottom:(N.bottom-x.bottom+m.bottom)/E.y,left:(x.left-N.left+m.left)/E.x,right:(N.right-x.right+m.right)/E.x}}var S3n=n=>({name:"arrow",options:n,async fn(e){const{x:t,y:i,placement:r,rects:o,platform:s,elements:a,middlewareData:c}=e,{element:l,padding:u=0}=X5(n,e)||{};if(l==null)return{};const d=gtt(u),h={x:t,y:i},p=rge(r),m=ige(p),_=await s.getDimensions(l),g=p==="y",x=g?"top":"left",b=g?"bottom":"right",w=g?"clientHeight":"clientWidth",E=o.reference[m]+o.reference[p]-h[p]-o.floating[m],N=h[p]-o.reference[p],A=await(s.getOffsetParent==null?void 0:s.getOffsetParent(l));let I=A?A[w]:0;(!I||!await(s.isElement==null?void 0:s.isElement(A)))&&(I=a.floating[w]||o.floating[m]);const M=E/2-N/2,k=I/2-_[m]/2-1,C=GM(d[x],k),U=GM(d[b],k),O=C,H=I-_[m]-U,Y=I/2-_[m]/2+M,W=tge(O,Y,H),K=!c.arrow&&pI(r)!=null&&Y!==W&&o.reference[m]/2-(Y<O?C:U)-_[m]/2<0,J=K?Y<O?Y-O:Y-H:0;return{[p]:h[p]+J,data:{[p]:W,centerOffset:Y-W-J,...K&&{alignmentOffset:J}},reset:K}}}),E3n=function(n){return n===void 0&&(n={}),{name:"flip",options:n,async fn(e){var t,i;const{placement:r,middlewareData:o,rects:s,initialPlacement:a,platform:c,elements:l}=e,{mainAxis:u=!0,crossAxis:d=!0,fallbackPlacements:h,fallbackStrategy:p="bestFit",fallbackAxisSideDirection:m="none",flipAlignment:_=!0,...g}=X5(n,e);if((t=o.arrow)!=null&&t.alignmentOffset)return{};const x=W5(r),b=hT(a),w=W5(a)===a,E=await(c.isRTL==null?void 0:c.isRTL(l.floating)),N=h||(w||!_?[MV(a)]:_3n(a)),A=m!=="none";!h&&A&&N.push(...b3n(a,_,m,E));const I=[a,...N],M=await b8(e,g),k=[];let C=((i=o.flip)==null?void 0:i.overflows)||[];if(u&&k.push(M[x]),d){const Y=m3n(r,s,E);k.push(M[Y[0]],M[Y[1]])}if(C=[...C,{placement:r,overflows:k}],!k.every(Y=>Y<=0)){var U,O;const Y=(((U=o.flip)==null?void 0:U.index)||0)+1,W=I[Y];if(W&&(!(d==="alignment"?b!==hT(W):!1)||C.every(se=>hT(se.placement)===b?se.overflows[0]>0:!0)))return{data:{index:Y,overflows:C},reset:{placement:W}};let K=(O=C.filter(J=>J.overflows[0]<=0).sort((J,se)=>J.overflows[1]-se.overflows[1])[0])==null?void 0:O.placement;if(!K)switch(p){case"bestFit":{var H;const J=(H=C.filter(se=>{if(A){const de=hT(se.placement);return de===b||de==="y"}return!0}).map(se=>[se.placement,se.overflows.filter(de=>de>0).reduce((de,ve)=>de+ve,0)]).sort((se,de)=>se[1]-de[1])[0])==null?void 0:H[0];J&&(K=J);break}case"initialPlacement":K=a;break}if(r!==K)return{reset:{placement:K}}}return{}}}};function btt(n,e){return{top:n.top-e.height,right:n.right-e.width,bottom:n.bottom-e.height,left:n.left-e.width}}function vtt(n){return d3n.some(e=>n[e]>=0)}var T3n=function(n){return n===void 0&&(n={}),{name:"hide",options:n,async fn(e){const{rects:t}=e,{strategy:i="referenceHidden",...r}=X5(n,e);switch(i){case"referenceHidden":{const o=await b8(e,{...r,elementContext:"reference"}),s=btt(o,t.reference);return{data:{referenceHiddenOffsets:s,referenceHidden:vtt(s)}}}case"escaped":{const o=await b8(e,{...r,altBoundary:!0}),s=btt(o,t.floating);return{data:{escapedOffsets:s,escaped:vtt(s)}}}default:return{}}}}},wtt=new Set(["left","top"]);async function M3n(n,e){const{placement:t,platform:i,elements:r}=n,o=await(i.isRTL==null?void 0:i.isRTL(r.floating)),s=W5(t),a=pI(t),c=hT(t)==="y",l=wtt.has(s)?-1:1,u=o&&c?-1:1,d=X5(e,n);let{mainAxis:h,crossAxis:p,alignmentAxis:m}=typeof d=="number"?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.alignmentAxis};return a&&typeof m=="number"&&(p=a==="end"?m*-1:m),c?{x:p*u,y:h*l}:{x:h*l,y:p*u}}var C3n=function(n){return n===void 0&&(n=0),{name:"offset",options:n,async fn(e){var t,i;const{x:r,y:o,placement:s,middlewareData:a}=e,c=await M3n(e,n);return s===((t=a.offset)==null?void 0:t.placement)&&(i=a.arrow)!=null&&i.alignmentOffset?{}:{x:r+c.x,y:o+c.y,data:{...c,placement:s}}}}},A3n=function(n){return n===void 0&&(n={}),{name:"shift",options:n,async fn(e){const{x:t,y:i,placement:r}=e,{mainAxis:o=!0,crossAxis:s=!1,limiter:a={fn:g=>{let{x,y:b}=g;return{x,y:b}}},...c}=X5(n,e),l={x:t,y:i},u=await b8(e,c),d=hT(W5(r)),h=nge(d);let p=l[h],m=l[d];if(o){const g=h==="y"?"top":"left",x=h==="y"?"bottom":"right",b=p+u[g],w=p-u[x];p=tge(b,p,w)}if(s){const g=d==="y"?"top":"left",x=d==="y"?"bottom":"right",b=m+u[g],w=m-u[x];m=tge(b,m,w)}const _=a.fn({...e,[h]:p,[d]:m});return{..._,data:{x:_.x-t,y:_.y-i,enabled:{[h]:o,[d]:s}}}}}},P3n=function(n){return n===void 0&&(n={}),{options:n,fn(e){const{x:t,y:i,placement:r,rects:o,middlewareData:s}=e,{offset:a=0,mainAxis:c=!0,crossAxis:l=!0}=X5(n,e),u={x:t,y:i},d=hT(r),h=nge(d);let p=u[h],m=u[d];const _=X5(a,e),g=typeof _=="number"?{mainAxis:_,crossAxis:0}:{mainAxis:0,crossAxis:0,..._};if(c){const w=h==="y"?"height":"width",E=o.reference[h]-o.floating[w]+g.mainAxis,N=o.reference[h]+o.reference[w]-g.mainAxis;p<E?p=E:p>N&&(p=N)}if(l){var x,b;const w=h==="y"?"width":"height",E=wtt.has(W5(r)),N=o.reference[d]-o.floating[w]+(E&&((x=s.offset)==null?void 0:x[d])||0)+(E?0:g.crossAxis),A=o.reference[d]+o.reference[w]+(E?0:((b=s.offset)==null?void 0:b[d])||0)-(E?g.crossAxis:0);m<N?m=N:m>A&&(m=A)}return{[h]:p,[d]:m}}}},R3n=function(n){return n===void 0&&(n={}),{name:"size",options:n,async fn(e){var t,i;const{placement:r,rects:o,platform:s,elements:a}=e,{apply:c=()=>{},...l}=X5(n,e),u=await b8(e,l),d=W5(r),h=pI(r),p=hT(r)==="y",{width:m,height:_}=o.floating;let g,x;d==="top"||d==="bottom"?(g=d,x=h===(await(s.isRTL==null?void 0:s.isRTL(a.floating))?"start":"end")?"left":"right"):(x=d,g=h==="end"?"top":"bottom");const b=_-u.top-u.bottom,w=m-u.left-u.right,E=GM(_-u[g],b),N=GM(m-u[x],w),A=!e.middlewareData.shift;let I=E,M=N;if((t=e.middlewareData.shift)!=null&&t.enabled.x&&(M=w),(i=e.middlewareData.shift)!=null&&i.enabled.y&&(I=b),A&&!h){const C=oS(u.left,0),U=oS(u.right,0),O=oS(u.top,0),H=oS(u.bottom,0);p?M=m-2*(C!==0||U!==0?C+U:oS(u.left,u.right)):I=_-2*(O!==0||H!==0?O+H:oS(u.top,u.bottom))}await c({...e,availableWidth:M,availableHeight:I});const k=await s.getDimensions(a.floating);return m!==k.width||_!==k.height?{reset:{rects:!0}}:{}}}};function AV(){return typeof window<"u"}function fI(n){return Stt(n)?(n.nodeName||"").toLowerCase():"#document"}function sS(n){var e;return(n==null||(e=n.ownerDocument)==null?void 0:e.defaultView)||window}function pT(n){var e;return(e=(Stt(n)?n.ownerDocument:n.document)||window.document)==null?void 0:e.documentElement}function Stt(n){return AV()?n instanceof Node||n instanceof sS(n).Node:!1}function W2(n){return AV()?n instanceof Element||n instanceof sS(n).Element:!1}function fT(n){return AV()?n instanceof HTMLElement||n instanceof sS(n).HTMLElement:!1}function Ett(n){return!AV()||typeof ShadowRoot>"u"?!1:n instanceof ShadowRoot||n instanceof sS(n).ShadowRoot}var I3n=new Set(["inline","contents"]);function v8(n){const{overflow:e,overflowX:t,overflowY:i,display:r}=K2(n);return/auto|scroll|overlay|hidden|clip/.test(e+i+t)&&!I3n.has(r)}var N3n=new Set(["table","td","th"]);function k3n(n){return N3n.has(fI(n))}var O3n=[":popover-open",":modal"];function PV(n){return O3n.some(e=>{try{return n.matches(e)}catch{return!1}})}var L3n=["transform","translate","scale","rotate","perspective"],D3n=["transform","translate","scale","rotate","perspective","filter"],z3n=["paint","layout","strict","content"];function sge(n){const e=age(),t=W2(n)?K2(n):n;return L3n.some(i=>t[i]?t[i]!=="none":!1)||(t.containerType?t.containerType!=="normal":!1)||!e&&(t.backdropFilter?t.backdropFilter!=="none":!1)||!e&&(t.filter?t.filter!=="none":!1)||D3n.some(i=>(t.willChange||"").includes(i))||z3n.some(i=>(t.contain||"").includes(i))}function $3n(n){let e=YM(n);for(;fT(e)&&!mI(e);){if(sge(e))return e;if(PV(e))return null;e=YM(e)}return null}function age(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}var F3n=new Set(["html","body","#document"]);function mI(n){return F3n.has(fI(n))}function K2(n){return sS(n).getComputedStyle(n)}function RV(n){return W2(n)?{scrollLeft:n.scrollLeft,scrollTop:n.scrollTop}:{scrollLeft:n.scrollX,scrollTop:n.scrollY}}function YM(n){if(fI(n)==="html")return n;const e=n.assignedSlot||n.parentNode||Ett(n)&&n.host||pT(n);return Ett(e)?e.host:e}function Ttt(n){const e=YM(n);return mI(e)?n.ownerDocument?n.ownerDocument.body:n.body:fT(e)&&v8(e)?e:Ttt(e)}function w8(n,e,t){var i;e===void 0&&(e=[]),t===void 0&&(t=!0);const r=Ttt(n),o=r===((i=n.ownerDocument)==null?void 0:i.body),s=sS(r);if(o){const a=cge(s);return e.concat(s,s.visualViewport||[],v8(r)?r:[],a&&t?w8(a):[])}return e.concat(r,w8(r,[],t))}function cge(n){return n.parent&&Object.getPrototypeOf(n.parent)?n.frameElement:null}function Mtt(n){const e=K2(n);let t=parseFloat(e.width)||0,i=parseFloat(e.height)||0;const r=fT(n),o=r?n.offsetWidth:t,s=r?n.offsetHeight:i,a=EV(t)!==o||EV(i)!==s;return a&&(t=o,i=s),{width:t,height:i,$:a}}function lge(n){return W2(n)?n:n.contextElement}function _I(n){const e=lge(n);if(!fT(e))return dT(1);const t=e.getBoundingClientRect(),{width:i,height:r,$:o}=Mtt(e);let s=(o?EV(t.width):t.width)/i,a=(o?EV(t.height):t.height)/r;return(!s||!Number.isFinite(s))&&(s=1),(!a||!Number.isFinite(a))&&(a=1),{x:s,y:a}}var U3n=dT(0);function Ctt(n){const e=sS(n);return!age()||!e.visualViewport?U3n:{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}}function B3n(n,e,t){return e===void 0&&(e=!1),!t||e&&t!==sS(n)?!1:e}function f4(n,e,t,i){e===void 0&&(e=!1),t===void 0&&(t=!1);const r=n.getBoundingClientRect(),o=lge(n);let s=dT(1);e&&(i?W2(i)&&(s=_I(i)):s=_I(n));const a=B3n(o,t,i)?Ctt(o):dT(0);let c=(r.left+a.x)/s.x,l=(r.top+a.y)/s.y,u=r.width/s.x,d=r.height/s.y;if(o){const h=sS(o),p=i&&W2(i)?sS(i):i;let m=h,_=cge(m);for(;_&&i&&p!==m;){const g=_I(_),x=_.getBoundingClientRect(),b=K2(_),w=x.left+(_.clientLeft+parseFloat(b.paddingLeft))*g.x,E=x.top+(_.clientTop+parseFloat(b.paddingTop))*g.y;c*=g.x,l*=g.y,u*=g.x,d*=g.y,c+=w,l+=E,m=sS(_),_=cge(m)}}return CV({width:u,height:d,x:c,y:l})}function IV(n,e){const t=RV(n).scrollLeft;return e?e.left+t:f4(pT(n)).left+t}function Att(n,e){const t=n.getBoundingClientRect(),i=t.left+e.scrollLeft-IV(n,t),r=t.top+e.scrollTop;return{x:i,y:r}}function j3n(n){let{elements:e,rect:t,offsetParent:i,strategy:r}=n;const o=r==="fixed",s=pT(i),a=e?PV(e.floating):!1;if(i===s||a&&o)return t;let c={scrollLeft:0,scrollTop:0},l=dT(1);const u=dT(0),d=fT(i);if((d||!d&&!o)&&((fI(i)!=="body"||v8(s))&&(c=RV(i)),fT(i))){const p=f4(i);l=_I(i),u.x=p.x+i.clientLeft,u.y=p.y+i.clientTop}const h=s&&!d&&!o?Att(s,c):dT(0);return{width:t.width*l.x,height:t.height*l.y,x:t.x*l.x-c.scrollLeft*l.x+u.x+h.x,y:t.y*l.y-c.scrollTop*l.y+u.y+h.y}}function H3n(n){return Array.from(n.getClientRects())}function V3n(n){const e=pT(n),t=RV(n),i=n.ownerDocument.body,r=oS(e.scrollWidth,e.clientWidth,i.scrollWidth,i.clientWidth),o=oS(e.scrollHeight,e.clientHeight,i.scrollHeight,i.clientHeight);let s=-t.scrollLeft+IV(n);const a=-t.scrollTop;return K2(i).direction==="rtl"&&(s+=oS(e.clientWidth,i.clientWidth)-r),{width:r,height:o,x:s,y:a}}var Ptt=25;function G3n(n,e){const t=sS(n),i=pT(n),r=t.visualViewport;let o=i.clientWidth,s=i.clientHeight,a=0,c=0;if(r){o=r.width,s=r.height;const u=age();(!u||u&&e==="fixed")&&(a=r.offsetLeft,c=r.offsetTop)}const l=IV(i);if(l<=0){const u=i.ownerDocument,d=u.body,h=getComputedStyle(d),p=u.compatMode==="CSS1Compat"&&parseFloat(h.marginLeft)+parseFloat(h.marginRight)||0,m=Math.abs(i.clientWidth-d.clientWidth-p);m<=Ptt&&(o-=m)}else l<=Ptt&&(o+=l);return{width:o,height:s,x:a,y:c}}var Y3n=new Set(["absolute","fixed"]);function q3n(n,e){const t=f4(n,!0,e==="fixed"),i=t.top+n.clientTop,r=t.left+n.clientLeft,o=fT(n)?_I(n):dT(1),s=n.clientWidth*o.x,a=n.clientHeight*o.y,c=r*o.x,l=i*o.y;return{width:s,height:a,x:c,y:l}}function Rtt(n,e,t){let i;if(e==="viewport")i=G3n(n,t);else if(e==="document")i=V3n(pT(n));else if(W2(e))i=q3n(e,t);else{const r=Ctt(n);i={x:e.x-r.x,y:e.y-r.y,width:e.width,height:e.height}}return CV(i)}function Itt(n,e){const t=YM(n);return t===e||!W2(t)||mI(t)?!1:K2(t).position==="fixed"||Itt(t,e)}function X3n(n,e){const t=e.get(n);if(t)return t;let i=w8(n,[],!1).filter(a=>W2(a)&&fI(a)!=="body"),r=null;const o=K2(n).position==="fixed";let s=o?YM(n):n;for(;W2(s)&&!mI(s);){const a=K2(s),c=sge(s);!c&&a.position==="fixed"&&(r=null),(o?!c&&!r:!c&&a.position==="static"&&!!r&&Y3n.has(r.position)||v8(s)&&!c&&Itt(n,s))?i=i.filter(u=>u!==s):r=a,s=YM(s)}return e.set(n,i),i}function W3n(n){let{element:e,boundary:t,rootBoundary:i,strategy:r}=n;const s=[...t==="clippingAncestors"?PV(e)?[]:X3n(e,this._c):[].concat(t),i],a=s[0],c=s.reduce((l,u)=>{const d=Rtt(e,u,r);return l.top=oS(d.top,l.top),l.right=GM(d.right,l.right),l.bottom=GM(d.bottom,l.bottom),l.left=oS(d.left,l.left),l},Rtt(e,a,r));return{width:c.right-c.left,height:c.bottom-c.top,x:c.left,y:c.top}}function K3n(n){const{width:e,height:t}=Mtt(n);return{width:e,height:t}}function Z3n(n,e,t){const i=fT(e),r=pT(e),o=t==="fixed",s=f4(n,!0,o,e);let a={scrollLeft:0,scrollTop:0};const c=dT(0);function l(){c.x=IV(r)}if(i||!i&&!o)if((fI(e)!=="body"||v8(r))&&(a=RV(e)),i){const p=f4(e,!0,o,e);c.x=p.x+e.clientLeft,c.y=p.y+e.clientTop}else r&&l();o&&!i&&r&&l();const u=r&&!i&&!o?Att(r,a):dT(0),d=s.left+a.scrollLeft-c.x-u.x,h=s.top+a.scrollTop-c.y-u.y;return{x:d,y:h,width:s.width,height:s.height}}function uge(n){return K2(n).position==="static"}function Ntt(n,e){if(!fT(n)||K2(n).position==="fixed")return null;if(e)return e(n);let t=n.offsetParent;return pT(n)===t&&(t=t.ownerDocument.body),t}function ktt(n,e){const t=sS(n);if(PV(n))return t;if(!fT(n)){let r=YM(n);for(;r&&!mI(r);){if(W2(r)&&!uge(r))return r;r=YM(r)}return t}let i=Ntt(n,e);for(;i&&k3n(i)&&uge(i);)i=Ntt(i,e);return i&&mI(i)&&uge(i)&&!sge(i)?t:i||$3n(n)||t}var Q3n=async function(n){const e=this.getOffsetParent||ktt,t=this.getDimensions,i=await t(n.floating);return{reference:Z3n(n.reference,await e(n.floating),n.strategy),floating:{x:0,y:0,width:i.width,height:i.height}}};function J3n(n){return K2(n).direction==="rtl"}var eMn={convertOffsetParentRelativeRectToViewportRelativeRect:j3n,getDocumentElement:pT,getClippingRect:W3n,getOffsetParent:ktt,getElementRects:Q3n,getClientRects:H3n,getDimensions:K3n,getScale:_I,isElement:W2,isRTL:J3n};function Ott(n,e){return n.x===e.x&&n.y===e.y&&n.width===e.width&&n.height===e.height}function tMn(n,e){let t=null,i;const r=pT(n);function o(){var a;clearTimeout(i),(a=t)==null||a.disconnect(),t=null}function s(a,c){a===void 0&&(a=!1),c===void 0&&(c=1),o();const l=n.getBoundingClientRect(),{left:u,top:d,width:h,height:p}=l;if(a||e(),!h||!p)return;const m=TV(d),_=TV(r.clientWidth-(u+h)),g=TV(r.clientHeight-(d+p)),x=TV(u),w={rootMargin:-m+"px "+-_+"px "+-g+"px "+-x+"px",threshold:oS(0,GM(1,c))||1};let E=!0;function N(A){const I=A[0].intersectionRatio;if(I!==c){if(!E)return s();I?s(!1,I):i=setTimeout(()=>{s(!1,1e-7)},1e3)}I===1&&!Ott(l,n.getBoundingClientRect())&&s(),E=!1}try{t=new IntersectionObserver(N,{...w,root:r.ownerDocument})}catch{t=new IntersectionObserver(N,w)}t.observe(n)}return s(!0),o}function nMn(n,e,t,i){i===void 0&&(i={});const{ancestorScroll:r=!0,ancestorResize:o=!0,elementResize:s=typeof ResizeObserver=="function",layoutShift:a=typeof IntersectionObserver=="function",animationFrame:c=!1}=i,l=lge(n),u=r||o?[...l?w8(l):[],...w8(e)]:[];u.forEach(x=>{r&&x.addEventListener("scroll",t,{passive:!0}),o&&x.addEventListener("resize",t)});const d=l&&a?tMn(l,t):null;let h=-1,p=null;s&&(p=new ResizeObserver(x=>{let[b]=x;b&&b.target===l&&p&&(p.unobserve(e),cancelAnimationFrame(h),h=requestAnimationFrame(()=>{var w;(w=p)==null||w.observe(e)})),t()}),l&&!c&&p.observe(l),p.observe(e));let m,_=c?f4(n):null;c&&g();function g(){const x=f4(n);_&&!Ott(_,x)&&t(),_=x,m=requestAnimationFrame(g)}return t(),()=>{var x;u.forEach(b=>{r&&b.removeEventListener("scroll",t),o&&b.removeEventListener("resize",t)}),d?.(),(x=p)==null||x.disconnect(),p=null,c&&cancelAnimationFrame(m)}}var iMn=C3n,rMn=A3n,oMn=E3n,sMn=R3n,aMn=T3n,Ltt=S3n,cMn=P3n,lMn=(n,e,t)=>{const i=new Map,r={platform:eMn,...t},o={...r.platform,_c:i};return w3n(n,e,{...r,platform:o})},uMn=typeof document<"u",dMn=function(){},NV=uMn?fe.useLayoutEffect:dMn;function kV(n,e){if(n===e)return!0;if(typeof n!=typeof e)return!1;if(typeof n=="function"&&n.toString()===e.toString())return!0;let t,i,r;if(n&&e&&typeof n=="object"){if(Array.isArray(n)){if(t=n.length,t!==e.length)return!1;for(i=t;i--!==0;)if(!kV(n[i],e[i]))return!1;return!0}if(r=Object.keys(n),t=r.length,t!==Object.keys(e).length)return!1;for(i=t;i--!==0;)if(!{}.hasOwnProperty.call(e,r[i]))return!1;for(i=t;i--!==0;){const o=r[i];if(!(o==="_owner"&&n.$$typeof)&&!kV(n[o],e[o]))return!1}return!0}return n!==n&&e!==e}function Dtt(n){return typeof window>"u"?1:(n.ownerDocument.defaultView||window).devicePixelRatio||1}function ztt(n,e){const t=Dtt(n);return Math.round(e*t)/t}function dge(n){const e=fe.useRef(n);return NV(()=>{e.current=n}),e}function hMn(n){n===void 0&&(n={});const{placement:e="bottom",strategy:t="absolute",middleware:i=[],platform:r,elements:{reference:o,floating:s}={},transform:a=!0,whileElementsMounted:c,open:l}=n,[u,d]=fe.useState({x:0,y:0,strategy:t,placement:e,middlewareData:{},isPositioned:!1}),[h,p]=fe.useState(i);kV(h,i)||p(i);const[m,_]=fe.useState(null),[g,x]=fe.useState(null),b=fe.useCallback(se=>{se!==A.current&&(A.current=se,_(se))},[]),w=fe.useCallback(se=>{se!==I.current&&(I.current=se,x(se))},[]),E=o||m,N=s||g,A=fe.useRef(null),I=fe.useRef(null),M=fe.useRef(u),k=c!=null,C=dge(c),U=dge(r),O=dge(l),H=fe.useCallback(()=>{if(!A.current||!I.current)return;const se={placement:e,strategy:t,middleware:h};U.current&&(se.platform=U.current),lMn(A.current,I.current,se).then(de=>{const ve={...de,isPositioned:O.current!==!1};Y.current&&!kV(M.current,ve)&&(M.current=ve,Ak.flushSync(()=>{d(ve)}))})},[h,e,t,U,O]);NV(()=>{l===!1&&M.current.isPositioned&&(M.current.isPositioned=!1,d(se=>({...se,isPositioned:!1})))},[l]);const Y=fe.useRef(!1);NV(()=>(Y.current=!0,()=>{Y.current=!1}),[]),NV(()=>{if(E&&(A.current=E),N&&(I.current=N),E&&N){if(C.current)return C.current(E,N,H);H()}},[E,N,H,C,k]);const W=fe.useMemo(()=>({reference:A,floating:I,setReference:b,setFloating:w}),[b,w]),K=fe.useMemo(()=>({reference:E,floating:N}),[E,N]),J=fe.useMemo(()=>{const se={position:t,left:0,top:0};if(!K.floating)return se;const de=ztt(K.floating,u.x),ve=ztt(K.floating,u.y);return a?{...se,transform:"translate("+de+"px, "+ve+"px)",...Dtt(K.floating)>=1.5&&{willChange:"transform"}}:{position:t,left:de,top:ve}},[t,a,K.floating,u.x,u.y]);return fe.useMemo(()=>({...u,update:H,refs:W,elements:K,floatingStyles:J}),[u,H,W,K,J])}var pMn=n=>{function e(t){return{}.hasOwnProperty.call(t,"current")}return{name:"arrow",options:n,fn(t){const{element:i,padding:r}=typeof n=="function"?n(t):n;return i&&e(i)?i.current!=null?Ltt({element:i.current,padding:r}).fn(t):{}:i?Ltt({element:i,padding:r}).fn(t):{}}}},fMn=(n,e)=>({...iMn(n),options:[n,e]}),mMn=(n,e)=>({...rMn(n),options:[n,e]}),_Mn=(n,e)=>({...cMn(n),options:[n,e]}),yMn=(n,e)=>({...oMn(n),options:[n,e]}),gMn=(n,e)=>({...sMn(n),options:[n,e]}),xMn=(n,e)=>({...aMn(n),options:[n,e]}),bMn=(n,e)=>({...pMn(n),options:[n,e]}),vMn="Arrow",$tt=fe.forwardRef((n,e)=>{const{children:t,width:i=10,height:r=5,...o}=n;return ce.jsx(Nv.svg,{...o,ref:e,width:i,height:r,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:n.asChild?t:ce.jsx("polygon",{points:"0,0 30,0 15,10"})})});$tt.displayName=vMn;var wMn=$tt;function SMn(n){const[e,t]=fe.useState(void 0);return HM(()=>{if(n){t({width:n.offsetWidth,height:n.offsetHeight});const i=new ResizeObserver(r=>{if(!Array.isArray(r)||!r.length)return;const o=r[0];let s,a;if("borderBoxSize"in o){const c=o.borderBoxSize,l=Array.isArray(c)?c[0]:c;s=l.inlineSize,a=l.blockSize}else s=n.offsetWidth,a=n.offsetHeight;t({width:s,height:a})});return i.observe(n,{box:"border-box"}),()=>i.unobserve(n)}else t(void 0)},[n]),e}var hge="Popper",[Ftt,Utt]=g8(hge),[EMn,Btt]=Ftt(hge),jtt=n=>{const{__scopePopper:e,children:t}=n,[i,r]=fe.useState(null);return ce.jsx(EMn,{scope:e,anchor:i,onAnchorChange:r,children:t})};jtt.displayName=hge;var Htt="PopperAnchor",Vtt=fe.forwardRef((n,e)=>{const{__scopePopper:t,virtualRef:i,...r}=n,o=Btt(Htt,t),s=fe.useRef(null),a=dw(e,s),c=fe.useRef(null);return fe.useEffect(()=>{const l=c.current;c.current=i?.current||s.current,l!==c.current&&o.onAnchorChange(c.current)}),i?null:ce.jsx(Nv.div,{...r,ref:a})});Vtt.displayName=Htt;var pge="PopperContent",[TMn,MMn]=Ftt(pge),Gtt=fe.forwardRef((n,e)=>{const{__scopePopper:t,side:i="bottom",sideOffset:r=0,align:o="center",alignOffset:s=0,arrowPadding:a=0,avoidCollisions:c=!0,collisionBoundary:l=[],collisionPadding:u=0,sticky:d="partial",hideWhenDetached:h=!1,updatePositionStrategy:p="optimized",onPlaced:m,..._}=n,g=Btt(pge,t),[x,b]=fe.useState(null),w=dw(e,Be=>b(Be)),[E,N]=fe.useState(null),A=SMn(E),I=A?.width??0,M=A?.height??0,k=i+(o!=="center"?"-"+o:""),C=typeof u=="number"?u:{top:0,right:0,bottom:0,left:0,...u},U=Array.isArray(l)?l:[l],O=U.length>0,H={padding:C,boundary:U.filter(AMn),altBoundary:O},{refs:Y,floatingStyles:W,placement:K,isPositioned:J,middlewareData:se}=hMn({strategy:"fixed",placement:k,whileElementsMounted:(...Be)=>nMn(...Be,{animationFrame:p==="always"}),elements:{reference:g.anchor},middleware:[fMn({mainAxis:r+M,alignmentAxis:s}),c&&mMn({mainAxis:!0,crossAxis:!1,limiter:d==="partial"?_Mn():void 0,...H}),c&&yMn({...H}),gMn({...H,apply:({elements:Be,rects:Re,availableWidth:oe,availableHeight:Ee})=>{const{width:be,height:Ge}=Re.reference,nt=Be.floating.style;nt.setProperty("--radix-popper-available-width",`${oe}px`),nt.setProperty("--radix-popper-available-height",`${Ee}px`),nt.setProperty("--radix-popper-anchor-width",`${be}px`),nt.setProperty("--radix-popper-anchor-height",`${Ge}px`)}}),E&&bMn({element:E,padding:a}),PMn({arrowWidth:I,arrowHeight:M}),h&&xMn({strategy:"referenceHidden",...H})]}),[de,ve]=Xtt(K),re=uT(m);HM(()=>{J&&re?.()},[J,re]);const ue=se.arrow?.x,me=se.arrow?.y,Me=se.arrow?.centerOffset!==0,[ke,ze]=fe.useState();return HM(()=>{x&&ze(window.getComputedStyle(x).zIndex)},[x]),ce.jsx("div",{ref:Y.setFloating,"data-radix-popper-content-wrapper":"",style:{...W,transform:J?W.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:ke,"--radix-popper-transform-origin":[se.transformOrigin?.x,se.transformOrigin?.y].join(" "),...se.hide?.referenceHidden&&{visibility:"hidden",pointerEvents:"none"}},dir:n.dir,children:ce.jsx(TMn,{scope:t,placedSide:de,onArrowChange:N,arrowX:ue,arrowY:me,shouldHideArrow:Me,children:ce.jsx(Nv.div,{"data-side":de,"data-align":ve,..._,ref:w,style:{..._.style,animation:J?void 0:"none"}})})})});Gtt.displayName=pge;var Ytt="PopperArrow",CMn={top:"bottom",right:"left",bottom:"top",left:"right"},qtt=fe.forwardRef(function(e,t){const{__scopePopper:i,...r}=e,o=MMn(Ytt,i),s=CMn[o.placedSide];return ce.jsx("span",{ref:o.onArrowChange,style:{position:"absolute",left:o.arrowX,top:o.arrowY,[s]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[o.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[o.placedSide],visibility:o.shouldHideArrow?"hidden":void 0},children:ce.jsx(wMn,{...r,ref:t,style:{...r.style,display:"block"}})})});qtt.displayName=Ytt;function AMn(n){return n!==null}var PMn=n=>({name:"transformOrigin",options:n,fn(e){const{placement:t,rects:i,middlewareData:r}=e,s=r.arrow?.centerOffset!==0,a=s?0:n.arrowWidth,c=s?0:n.arrowHeight,[l,u]=Xtt(t),d={start:"0%",center:"50%",end:"100%"}[u],h=(r.arrow?.x??0)+a/2,p=(r.arrow?.y??0)+c/2;let m="",_="";return l==="bottom"?(m=s?d:`${h}px`,_=`${-c}px`):l==="top"?(m=s?d:`${h}px`,_=`${i.floating.height+c}px`):l==="right"?(m=`${-c}px`,_=s?d:`${p}px`):l==="left"&&(m=`${i.floating.width+c}px`,_=s?d:`${p}px`),{data:{x:m,y:_}}}});function Xtt(n){const[e,t="center"]=n.split("-");return[e,t]}var Wtt=jtt,RMn=Vtt,IMn=Gtt,NMn=qtt,kMn="Portal",Ktt=fe.forwardRef((n,e)=>{const{container:t,...i}=n,[r,o]=fe.useState(!1);HM(()=>o(!0),[]);const s=t||r&&globalThis?.document?.body;return s?rz.createPortal(ce.jsx(Nv.div,{...i,ref:e}),s):null});Ktt.displayName=kMn;function OMn(n,e){return fe.useReducer((t,i)=>e[t][i]??t,n)}var S8=n=>{const{present:e,children:t}=n,i=LMn(e),r=typeof t=="function"?t({present:i.isPresent}):fe.Children.only(t),o=dw(i.ref,DMn(r));return typeof t=="function"||i.isPresent?fe.cloneElement(r,{ref:o}):null};S8.displayName="Presence";function LMn(n){const[e,t]=fe.useState(),i=fe.useRef(null),r=fe.useRef(n),o=fe.useRef("none"),s=n?"mounted":"unmounted",[a,c]=OMn(s,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return fe.useEffect(()=>{const l=OV(i.current);o.current=a==="mounted"?l:"none"},[a]),HM(()=>{const l=i.current,u=r.current;if(u!==n){const h=o.current,p=OV(l);n?c("MOUNT"):p==="none"||l?.display==="none"?c("UNMOUNT"):c(u&&h!==p?"ANIMATION_OUT":"UNMOUNT"),r.current=n}},[n,c]),HM(()=>{if(e){let l;const u=e.ownerDocument.defaultView??window,d=p=>{const _=OV(i.current).includes(CSS.escape(p.animationName));if(p.target===e&&_&&(c("ANIMATION_END"),!r.current)){const g=e.style.animationFillMode;e.style.animationFillMode="forwards",l=u.setTimeout(()=>{e.style.animationFillMode==="forwards"&&(e.style.animationFillMode=g)})}},h=p=>{p.target===e&&(o.current=OV(i.current))};return e.addEventListener("animationstart",h),e.addEventListener("animationcancel",d),e.addEventListener("animationend",d),()=>{u.clearTimeout(l),e.removeEventListener("animationstart",h),e.removeEventListener("animationcancel",d),e.removeEventListener("animationend",d)}}else c("ANIMATION_END")},[e,c]),{isPresent:["mounted","unmountSuspended"].includes(a),ref:fe.useCallback(l=>{i.current=l?getComputedStyle(l):null,t(l)},[])}}function OV(n){return n?.animationName||"none"}function DMn(n){let e=Object.getOwnPropertyDescriptor(n.props,"ref")?.get,t=e&&"isReactWarning"in e&&e.isReactWarning;return t?n.ref:(e=Object.getOwnPropertyDescriptor(n,"ref")?.get,t=e&&"isReactWarning"in e&&e.isReactWarning,t?n.props.ref:n.props.ref||n.ref)}var fge="rovingFocusGroup.onEntryFocus",zMn={bubbles:!1,cancelable:!0},E8="RovingFocusGroup",[mge,Ztt,$Mn]=ntt(E8),[FMn,Qtt]=g8(E8,[$Mn]),[UMn,BMn]=FMn(E8),Jtt=fe.forwardRef((n,e)=>ce.jsx(mge.Provider,{scope:n.__scopeRovingFocusGroup,children:ce.jsx(mge.Slot,{scope:n.__scopeRovingFocusGroup,children:ce.jsx(jMn,{...n,ref:e})})}));Jtt.displayName=E8;var jMn=fe.forwardRef((n,e)=>{const{__scopeRovingFocusGroup:t,orientation:i,loop:r=!1,dir:o,currentTabStopId:s,defaultCurrentTabStopId:a,onCurrentTabStopIdChange:c,onEntryFocus:l,preventScrollOnEntryFocus:u=!1,...d}=n,h=fe.useRef(null),p=dw(e,h),m=itt(o),[_,g]=Kye({prop:s,defaultProp:a??null,onChange:c,caller:E8}),[x,b]=fe.useState(!1),w=uT(l),E=Ztt(t),N=fe.useRef(!1),[A,I]=fe.useState(0);return fe.useEffect(()=>{const M=h.current;if(M)return M.addEventListener(fge,w),()=>M.removeEventListener(fge,w)},[w]),ce.jsx(UMn,{scope:t,orientation:i,dir:m,loop:r,currentTabStopId:_,onItemFocus:fe.useCallback(M=>g(M),[g]),onItemShiftTab:fe.useCallback(()=>b(!0),[]),onFocusableItemAdd:fe.useCallback(()=>I(M=>M+1),[]),onFocusableItemRemove:fe.useCallback(()=>I(M=>M-1),[]),children:ce.jsx(Nv.div,{tabIndex:x||A===0?-1:0,"data-orientation":i,...d,ref:p,style:{outline:"none",...n.style},onMouseDown:gd(n.onMouseDown,()=>{N.current=!0}),onFocus:gd(n.onFocus,M=>{const k=!N.current;if(M.target===M.currentTarget&&k&&!x){const C=new CustomEvent(fge,zMn);if(M.currentTarget.dispatchEvent(C),!C.defaultPrevented){const U=E().filter(K=>K.focusable),O=U.find(K=>K.active),H=U.find(K=>K.id===_),W=[O,H,...U].filter(Boolean).map(K=>K.ref.current);nnt(W,u)}}N.current=!1}),onBlur:gd(n.onBlur,()=>b(!1))})})}),ent="RovingFocusGroupItem",tnt=fe.forwardRef((n,e)=>{const{__scopeRovingFocusGroup:t,focusable:i=!0,active:r=!1,tabStopId:o,children:s,...a}=n,c=x8(),l=o||c,u=BMn(ent,t),d=u.currentTabStopId===l,h=Ztt(t),{onFocusableItemAdd:p,onFocusableItemRemove:m,currentTabStopId:_}=u;return fe.useEffect(()=>{if(i)return p(),()=>m()},[i,p,m]),ce.jsx(mge.ItemSlot,{scope:t,id:l,focusable:i,active:r,children:ce.jsx(Nv.span,{tabIndex:d?0:-1,"data-orientation":u.orientation,...a,ref:e,onMouseDown:gd(n.onMouseDown,g=>{i?u.onItemFocus(l):g.preventDefault()}),onFocus:gd(n.onFocus,()=>u.onItemFocus(l)),onKeyDown:gd(n.onKeyDown,g=>{if(g.key==="Tab"&&g.shiftKey){u.onItemShiftTab();return}if(g.target!==g.currentTarget)return;const x=GMn(g,u.orientation,u.dir);if(x!==void 0){if(g.metaKey||g.ctrlKey||g.altKey||g.shiftKey)return;g.preventDefault();let w=h().filter(E=>E.focusable).map(E=>E.ref.current);if(x==="last")w.reverse();else if(x==="prev"||x==="next"){x==="prev"&&w.reverse();const E=w.indexOf(g.currentTarget);w=u.loop?YMn(w,E+1):w.slice(E+1)}setTimeout(()=>nnt(w))}}),children:typeof s=="function"?s({isCurrentTabStop:d,hasTabStop:_!=null}):s})})});tnt.displayName=ent;var HMn={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function VMn(n,e){return e!=="rtl"?n:n==="ArrowLeft"?"ArrowRight":n==="ArrowRight"?"ArrowLeft":n}function GMn(n,e,t){const i=VMn(n.key,t);if(!(e==="vertical"&&["ArrowLeft","ArrowRight"].includes(i))&&!(e==="horizontal"&&["ArrowUp","ArrowDown"].includes(i)))return HMn[i]}function nnt(n,e=!1){const t=document.activeElement;for(const i of n)if(i===t||(i.focus({preventScroll:e}),document.activeElement!==t))return}function YMn(n,e){return n.map((t,i)=>n[(e+i)%n.length])}var qMn=Jtt,XMn=tnt,WMn=function(n){if(typeof document>"u")return null;var e=Array.isArray(n)?n[0]:n;return e.ownerDocument.body},yI=new WeakMap,LV=new WeakMap,DV={},_ge=0,int=function(n){return n&&(n.host||int(n.parentNode))},KMn=function(n,e){return e.map(function(t){if(n.contains(t))return t;var i=int(t);return i&&n.contains(i)?i:(console.error("aria-hidden",t,"in not contained inside",n,". Doing nothing"),null)}).filter(function(t){return!!t})},ZMn=function(n,e,t,i){var r=KMn(e,Array.isArray(n)?n:[n]);DV[t]||(DV[t]=new WeakMap);var o=DV[t],s=[],a=new Set,c=new Set(r),l=function(d){!d||a.has(d)||(a.add(d),l(d.parentNode))};r.forEach(l);var u=function(d){!d||c.has(d)||Array.prototype.forEach.call(d.children,function(h){if(a.has(h))u(h);else try{var p=h.getAttribute(i),m=p!==null&&p!=="false",_=(yI.get(h)||0)+1,g=(o.get(h)||0)+1;yI.set(h,_),o.set(h,g),s.push(h),_===1&&m&&LV.set(h,!0),g===1&&h.setAttribute(t,"true"),m||h.setAttribute(i,"true")}catch(x){console.error("aria-hidden: cannot operate on ",h,x)}})};return u(e),a.clear(),_ge++,function(){s.forEach(function(d){var h=yI.get(d)-1,p=o.get(d)-1;yI.set(d,h),o.set(d,p),h||(LV.has(d)||d.removeAttribute(i),LV.delete(d)),p||d.removeAttribute(t)}),_ge--,_ge||(yI=new WeakMap,yI=new WeakMap,LV=new WeakMap,DV={})}},QMn=function(n,e,t){t===void 0&&(t="data-aria-hidden");var i=Array.from(Array.isArray(n)?n:[n]),r=WMn(n);return r?(i.push.apply(i,Array.from(r.querySelectorAll("[aria-live], script"))),ZMn(i,r,t,"aria-hidden")):function(){return null}},mT=function(){return mT=Object.assign||function(e){for(var t,i=1,r=arguments.length;i<r;i++){t=arguments[i];for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o])}return e},mT.apply(this,arguments)};function rnt(n,e){var t={};for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&e.indexOf(i)<0&&(t[i]=n[i]);if(n!=null&&typeof Object.getOwnPropertySymbols=="function")for(var r=0,i=Object.getOwnPropertySymbols(n);r<i.length;r++)e.indexOf(i[r])<0&&Object.prototype.propertyIsEnumerable.call(n,i[r])&&(t[i[r]]=n[i[r]]);return t}function JMn(n,e,t){for(var i=0,r=e.length,o;i<r;i++)(o||!(i in e))&&(o||(o=Array.prototype.slice.call(e,0,i)),o[i]=e[i]);return n.concat(o||Array.prototype.slice.call(e))}var zV="right-scroll-bar-position",$V="width-before-scroll-bar",eCn="with-scroll-bars-hidden",tCn="--removed-body-scroll-bar-size";function yge(n,e){return typeof n=="function"?n(e):n&&(n.current=e),n}function nCn(n,e){var t=fe.useState(function(){return{value:n,callback:e,facade:{get current(){return t.value},set current(i){var r=t.value;r!==i&&(t.value=i,t.callback(i,r))}}}})[0];return t.callback=e,t.facade}var iCn=typeof window<"u"?fe.useLayoutEffect:fe.useEffect,ont=new WeakMap;function rCn(n,e){var t=nCn(null,function(i){return n.forEach(function(r){return yge(r,i)})});return iCn(function(){var i=ont.get(t);if(i){var r=new Set(i),o=new Set(n),s=t.current;r.forEach(function(a){o.has(a)||yge(a,null)}),o.forEach(function(a){r.has(a)||yge(a,s)})}ont.set(t,n)},[n]),t}function oCn(n){return n}function sCn(n,e){e===void 0&&(e=oCn);var t=[],i=!1,r={read:function(){if(i)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return t.length?t[t.length-1]:n},useMedium:function(o){var s=e(o,i);return t.push(s),function(){t=t.filter(function(a){return a!==s})}},assignSyncMedium:function(o){for(i=!0;t.length;){var s=t;t=[],s.forEach(o)}t={push:function(a){return o(a)},filter:function(){return t}}},assignMedium:function(o){i=!0;var s=[];if(t.length){var a=t;t=[],a.forEach(o),s=t}var c=function(){var u=s;s=[],u.forEach(o)},l=function(){return Promise.resolve().then(c)};l(),t={push:function(u){s.push(u),l()},filter:function(u){return s=s.filter(u),t}}}};return r}function aCn(n){n===void 0&&(n={});var e=sCn(null);return e.options=mT({async:!0,ssr:!1},n),e}var snt=function(n){var e=n.sideCar,t=rnt(n,["sideCar"]);if(!e)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var i=e.read();if(!i)throw new Error("Sidecar medium not found");return fe.createElement(i,mT({},t))};snt.isSideCarExport=!0;function cCn(n,e){return n.useMedium(e),snt}var ant=aCn(),gge=function(){},FV=fe.forwardRef(function(n,e){var t=fe.useRef(null),i=fe.useState({onScrollCapture:gge,onWheelCapture:gge,onTouchMoveCapture:gge}),r=i[0],o=i[1],s=n.forwardProps,a=n.children,c=n.className,l=n.removeScrollBar,u=n.enabled,d=n.shards,h=n.sideCar,p=n.noRelative,m=n.noIsolation,_=n.inert,g=n.allowPinchZoom,x=n.as,b=x===void 0?"div":x,w=n.gapMode,E=rnt(n,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),N=h,A=rCn([t,e]),I=mT(mT({},E),r);return fe.createElement(fe.Fragment,null,u&&fe.createElement(N,{sideCar:ant,removeScrollBar:l,shards:d,noRelative:p,noIsolation:m,inert:_,setCallbacks:o,allowPinchZoom:!!g,lockRef:t,gapMode:w}),s?fe.cloneElement(fe.Children.only(a),mT(mT({},I),{ref:A})):fe.createElement(b,mT({},I,{className:c,ref:A}),a))});FV.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},FV.classNames={fullWidth:$V,zeroRight:zV};var lCn=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function uCn(){if(!document)return null;var n=document.createElement("style");n.type="text/css";var e=lCn();return e&&n.setAttribute("nonce",e),n}function dCn(n,e){n.styleSheet?n.styleSheet.cssText=e:n.appendChild(document.createTextNode(e))}function hCn(n){var e=document.head||document.getElementsByTagName("head")[0];e.appendChild(n)}var pCn=function(){var n=0,e=null;return{add:function(t){n==0&&(e=uCn())&&(dCn(e,t),hCn(e)),n++},remove:function(){n--,!n&&e&&(e.parentNode&&e.parentNode.removeChild(e),e=null)}}},fCn=function(){var n=pCn();return function(e,t){fe.useEffect(function(){return n.add(e),function(){n.remove()}},[e&&t])}},cnt=function(){var n=fCn(),e=function(t){var i=t.styles,r=t.dynamic;return n(i,r),null};return e},mCn={left:0,top:0,right:0,gap:0},xge=function(n){return parseInt(n||"",10)||0},_Cn=function(n){var e=window.getComputedStyle(document.body),t=e[n==="padding"?"paddingLeft":"marginLeft"],i=e[n==="padding"?"paddingTop":"marginTop"],r=e[n==="padding"?"paddingRight":"marginRight"];return[xge(t),xge(i),xge(r)]},yCn=function(n){if(n===void 0&&(n="margin"),typeof window>"u")return mCn;var e=_Cn(n),t=document.documentElement.clientWidth,i=window.innerWidth;return{left:e[0],top:e[1],right:e[2],gap:Math.max(0,i-t+e[2]-e[0])}},gCn=cnt(),gI="data-scroll-locked",xCn=function(n,e,t,i){var r=n.left,o=n.top,s=n.right,a=n.gap;return t===void 0&&(t="margin"),`
5131
+ `.trim();const H=Y=>{const W="Failed to load Manifold loader script.";console.error(W,Y),d(W),window.removeEventListener(C,U)};return O.addEventListener("error",H),document.body.appendChild(O),()=>{window.removeEventListener(C,U),O.removeEventListener("error",H)}},[]);const{geoms:h,textures:p,pcbThickness:m,error:_,isLoading:g,boardData:x}=T5n(c,a),b=fe.useMemo(()=>A5n(h),[h]),w=fe.useMemo(()=>P5n(p,x,m),[p,x,m]),E=fe.useMemo(()=>fs(a).cad_component.list(),[a]),N=fe.useMemo(()=>{if(!x)return;const{width:M=0,height:k=0}=x;return{width:M,height:k}},[x]),A=fe.useMemo(()=>{if(!x)return;const{center:M}=x;if(M)return{x:M.x,y:M.y}},[x]),I=fe.useMemo(()=>{if(!x)return[5,-5,5];const{width:M=0,height:k=0}=x,C=Math.max(M,1),U=Math.max(k,1),O=Math.max(C,U,5);return[O*.75,-O*.75,O*.75]},[x]);return u?ce.jsxs("div",{style:{color:"red",padding:"1em",border:"1px solid red",margin:"1em"},children:["Error: ",u]}):c?_?ce.jsxs("div",{style:{color:"red",padding:"1em",border:"1px solid red",margin:"1em"},children:["Error: ",_]}):g?ce.jsx("div",{style:{padding:"1em"},children:"Processing board geometry..."}):ce.jsxs(Iet,{initialCameraPosition:I,autoRotateDisabled:e,clickToInteractEnabled:t,boardDimensions:N,boardCenter:A,onUserInteraction:i,onCameraControllerReady:o,children:[ce.jsx(R5n,{geometryMeshes:b,textureMeshes:w}),E.map(M=>ce.jsx(Yet,{fallback:({error:k})=>ce.jsx(Get,{cad_component:M,error:k}),children:ce.jsx(Aet,{cad_component:M,circuitJson:a})},M.cad_component_id))]}):ce.jsx("div",{style:{padding:"1em"},children:"Loading Manifold module..."})},k5n=N5n,O5n=({containerRef:n})=>{const[e,t]=fe.useState(!1),[i,r]=fe.useState({x:0,y:0}),o=fe.useRef(null),s=fe.useRef(null),a=fe.useRef(null),c=fe.useRef(!1),l=()=>{a.current!==null&&(clearTimeout(a.current),a.current=null)},u=fe.useCallback(g=>{g.preventDefault();const x=typeof g.clientX=="number"?g.clientX:0,b=typeof g.clientY=="number"?g.clientY:0;if(c.current){c.current=!1;return}if(!s.current)return;const{x:w,y:E}=s.current,N=Math.abs(x-w),A=Math.abs(b-E),I=10;if(N>I||A>I){s.current=null;return}r({x,y:b}),t(!0),s.current=null},[r,t]),d=fe.useCallback(g=>{if(g.touches.length===1){const x=g.touches[0];x?(s.current={x:x.clientX,y:x.clientY},l(),a.current=window.setTimeout(()=>{if(s.current){if(n.current){const b=n.current.getBoundingClientRect();r({x:b.left+b.width/2,y:b.top+b.height/2}),t(!0),c.current=!0}s.current=null}},600)):s.current=null}else s.current=null,l()},[n]),h=fe.useCallback(g=>{if(!s.current||g.touches.length!==1)return;const x=g.touches[0];if(x){const b=Math.abs(x.clientX-s.current.x),w=Math.abs(x.clientY-s.current.y),E=10;(b>E||w>E)&&(s.current=null,l())}else s.current=null,l()},[]),p=fe.useCallback(()=>{l(),setTimeout(()=>{s.current&&(s.current=null)},0)},[]),m=fe.useCallback(g=>{const x=g.target;o.current&&!o.current.contains(x)&&t(!1)},[]);return fe.useEffect(()=>{if(e)return document.addEventListener("mousedown",m),document.addEventListener("touchstart",m),()=>{document.removeEventListener("mousedown",m),document.removeEventListener("touchstart",m)}},[e,m]),{menuVisible:e,menuPos:i,menuRef:o,contextMenuEventHandlers:{onMouseDown:g=>{g.button===2?s.current={x:g.clientX,y:g.clientY}:s.current=null},onContextMenu:u,onTouchStart:d,onTouchMove:h,onTouchEnd:p},setMenuVisible:t}},L5n=()=>fe.useCallback(()=>{const n=window.__TSCIRCUIT_THREE_OBJECT;if(!n)return;new HOe().parse(n,t=>{const i=new Blob([t instanceof ArrayBuffer?t:JSON.stringify(t)],{type:"model/gltf+json"}),r=URL.createObjectURL(i),o=document.createElement("a");o.href=r,o.download="scene.gltf",o.click(),URL.revokeObjectURL(r)},t=>{console.error("Failed to export GLTF",t)})},[]);function gd(n,e,{checkForDefaultPrevented:t=!0}={}){return function(r){if(n?.(r),t===!1||!r.defaultPrevented)return e?.(r)}}function ett(n,e){if(typeof n=="function")return n(e);n!=null&&(n.current=e)}function wV(...n){return e=>{let t=!1;const i=n.map(r=>{const o=ett(r,e);return!t&&typeof o=="function"&&(t=!0),o});if(t)return()=>{for(let r=0;r<i.length;r++){const o=i[r];typeof o=="function"?o():ett(n[r],null)}}}}function dw(...n){return fe.useCallback(wV(...n),n)}function g8(n,e=[]){let t=[];function i(o,s){const a=fe.createContext(s),c=t.length;t=[...t,s];const l=d=>{const{scope:h,children:p,...m}=d,_=h?.[n]?.[c]||a,g=fe.useMemo(()=>m,Object.values(m));return ce.jsx(_.Provider,{value:g,children:p})};l.displayName=o+"Provider";function u(d,h){const p=h?.[n]?.[c]||a,m=fe.useContext(p);if(m)return m;if(s!==void 0)return s;throw new Error(`\`${d}\` must be used within \`${o}\``)}return[l,u]}const r=()=>{const o=t.map(s=>fe.createContext(s));return function(a){const c=a?.[n]||o;return fe.useMemo(()=>({[`__scope${n}`]:{...a,[n]:c}}),[a,c])}};return r.scopeName=n,[i,D5n(r,...e)]}function D5n(...n){const e=n[0];if(n.length===1)return e;const t=()=>{const i=n.map(r=>({useScope:r(),scopeName:r.scopeName}));return function(o){const s=i.reduce((a,{useScope:c,scopeName:l})=>{const d=c(o)[`__scope${l}`];return{...a,...d}},{});return fe.useMemo(()=>({[`__scope${e.scopeName}`]:s}),[s])}};return t.scopeName=e.scopeName,t}var HM=globalThis?.document?fe.useLayoutEffect:()=>{},z5n=nz[" useInsertionEffect ".trim().toString()]||HM;function Kye({prop:n,defaultProp:e,onChange:t=()=>{},caller:i}){const[r,o,s]=$5n({defaultProp:e,onChange:t}),a=n!==void 0,c=a?n:r;{const u=fe.useRef(n!==void 0);fe.useEffect(()=>{const d=u.current;d!==a&&console.warn(`${i} is changing from ${d?"controlled":"uncontrolled"} to ${a?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),u.current=a},[a,i])}const l=fe.useCallback(u=>{if(a){const d=F5n(u)?u(n):u;d!==n&&s.current?.(d)}else o(u)},[a,n,o,s]);return[c,l]}function $5n({defaultProp:n,onChange:e}){const[t,i]=fe.useState(n),r=fe.useRef(t),o=fe.useRef(e);return z5n(()=>{o.current=e},[e]),fe.useEffect(()=>{r.current!==t&&(o.current?.(t),r.current=t)},[t,r]),[t,i,o]}function F5n(n){return typeof n=="function"}function SV(n){const e=U5n(n),t=fe.forwardRef((i,r)=>{const{children:o,...s}=i,a=fe.Children.toArray(o),c=a.find(j5n);if(c){const l=c.props.children,u=a.map(d=>d===c?fe.Children.count(l)>1?fe.Children.only(null):fe.isValidElement(l)?l.props.children:null:d);return ce.jsx(e,{...s,ref:r,children:fe.isValidElement(l)?fe.cloneElement(l,void 0,u):null})}return ce.jsx(e,{...s,ref:r,children:o})});return t.displayName=`${n}.Slot`,t}function U5n(n){const e=fe.forwardRef((t,i)=>{const{children:r,...o}=t;if(fe.isValidElement(r)){const s=V5n(r),a=H5n(o,r.props);return r.type!==fe.Fragment&&(a.ref=i?wV(i,s):s),fe.cloneElement(r,a)}return fe.Children.count(r)>1?fe.Children.only(null):null});return e.displayName=`${n}.SlotClone`,e}var B5n=Symbol("radix.slottable");function j5n(n){return fe.isValidElement(n)&&typeof n.type=="function"&&"__radixId"in n.type&&n.type.__radixId===B5n}function H5n(n,e){const t={...e};for(const i in e){const r=n[i],o=e[i];/^on[A-Z]/.test(i)?r&&o?t[i]=(...a)=>{const c=o(...a);return r(...a),c}:r&&(t[i]=r):i==="style"?t[i]={...r,...o}:i==="className"&&(t[i]=[r,o].filter(Boolean).join(" "))}return{...n,...t}}function V5n(n){let e=Object.getOwnPropertyDescriptor(n.props,"ref")?.get,t=e&&"isReactWarning"in e&&e.isReactWarning;return t?n.ref:(e=Object.getOwnPropertyDescriptor(n,"ref")?.get,t=e&&"isReactWarning"in e&&e.isReactWarning,t?n.props.ref:n.props.ref||n.ref)}var G5n=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Nv=G5n.reduce((n,e)=>{const t=SV(`Primitive.${e}`),i=fe.forwardRef((r,o)=>{const{asChild:s,...a}=r,c=s?t:e;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),ce.jsx(c,{...a,ref:o})});return i.displayName=`Primitive.${e}`,{...n,[e]:i}},{});function ttt(n,e){n&&Ak.flushSync(()=>n.dispatchEvent(e))}function ntt(n){const e=n+"CollectionProvider",[t,i]=g8(e),[r,o]=t(e,{collectionRef:{current:null},itemMap:new Map}),s=_=>{const{scope:g,children:x}=_,b=wo.useRef(null),w=wo.useRef(new Map).current;return ce.jsx(r,{scope:g,itemMap:w,collectionRef:b,children:x})};s.displayName=e;const a=n+"CollectionSlot",c=SV(a),l=wo.forwardRef((_,g)=>{const{scope:x,children:b}=_,w=o(a,x),E=dw(g,w.collectionRef);return ce.jsx(c,{ref:E,children:b})});l.displayName=a;const u=n+"CollectionItemSlot",d="data-radix-collection-item",h=SV(u),p=wo.forwardRef((_,g)=>{const{scope:x,children:b,...w}=_,E=wo.useRef(null),N=dw(g,E),A=o(u,x);return wo.useEffect(()=>(A.itemMap.set(E,{ref:E,...w}),()=>void A.itemMap.delete(E))),ce.jsx(h,{[d]:"",ref:N,children:b})});p.displayName=u;function m(_){const g=o(n+"CollectionConsumer",_);return wo.useCallback(()=>{const b=g.collectionRef.current;if(!b)return[];const w=Array.from(b.querySelectorAll(`[${d}]`));return Array.from(g.itemMap.values()).sort((A,I)=>w.indexOf(A.ref.current)-w.indexOf(I.ref.current))},[g.collectionRef,g.itemMap])}return[{Provider:s,Slot:l,ItemSlot:p},m,i]}var Y5n=fe.createContext(void 0);function itt(n){const e=fe.useContext(Y5n);return n||e||"ltr"}function uT(n){const e=fe.useRef(n);return fe.useEffect(()=>{e.current=n}),fe.useMemo(()=>(...t)=>e.current?.(...t),[])}function q5n(n,e=globalThis?.document){const t=uT(n);fe.useEffect(()=>{const i=r=>{r.key==="Escape"&&t(r)};return e.addEventListener("keydown",i,{capture:!0}),()=>e.removeEventListener("keydown",i,{capture:!0})},[t,e])}var X5n="DismissableLayer",Zye="dismissableLayer.update",W5n="dismissableLayer.pointerDownOutside",K5n="dismissableLayer.focusOutside",rtt,ott=fe.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),stt=fe.forwardRef((n,e)=>{const{disableOutsidePointerEvents:t=!1,onEscapeKeyDown:i,onPointerDownOutside:r,onFocusOutside:o,onInteractOutside:s,onDismiss:a,...c}=n,l=fe.useContext(ott),[u,d]=fe.useState(null),h=u?.ownerDocument??globalThis?.document,[,p]=fe.useState({}),m=dw(e,I=>d(I)),_=Array.from(l.layers),[g]=[...l.layersWithOutsidePointerEventsDisabled].slice(-1),x=_.indexOf(g),b=u?_.indexOf(u):-1,w=l.layersWithOutsidePointerEventsDisabled.size>0,E=b>=x,N=J5n(I=>{const M=I.target,k=[...l.branches].some(C=>C.contains(M));!E||k||(r?.(I),s?.(I),I.defaultPrevented||a?.())},h),A=e3n(I=>{const M=I.target;[...l.branches].some(C=>C.contains(M))||(o?.(I),s?.(I),I.defaultPrevented||a?.())},h);return q5n(I=>{b===l.layers.size-1&&(i?.(I),!I.defaultPrevented&&a&&(I.preventDefault(),a()))},h),fe.useEffect(()=>{if(u)return t&&(l.layersWithOutsidePointerEventsDisabled.size===0&&(rtt=h.body.style.pointerEvents,h.body.style.pointerEvents="none"),l.layersWithOutsidePointerEventsDisabled.add(u)),l.layers.add(u),att(),()=>{t&&l.layersWithOutsidePointerEventsDisabled.size===1&&(h.body.style.pointerEvents=rtt)}},[u,h,t,l]),fe.useEffect(()=>()=>{u&&(l.layers.delete(u),l.layersWithOutsidePointerEventsDisabled.delete(u),att())},[u,l]),fe.useEffect(()=>{const I=()=>p({});return document.addEventListener(Zye,I),()=>document.removeEventListener(Zye,I)},[]),ce.jsx(Nv.div,{...c,ref:m,style:{pointerEvents:w?E?"auto":"none":void 0,...n.style},onFocusCapture:gd(n.onFocusCapture,A.onFocusCapture),onBlurCapture:gd(n.onBlurCapture,A.onBlurCapture),onPointerDownCapture:gd(n.onPointerDownCapture,N.onPointerDownCapture)})});stt.displayName=X5n;var Z5n="DismissableLayerBranch",Q5n=fe.forwardRef((n,e)=>{const t=fe.useContext(ott),i=fe.useRef(null),r=dw(e,i);return fe.useEffect(()=>{const o=i.current;if(o)return t.branches.add(o),()=>{t.branches.delete(o)}},[t.branches]),ce.jsx(Nv.div,{...n,ref:r})});Q5n.displayName=Z5n;function J5n(n,e=globalThis?.document){const t=uT(n),i=fe.useRef(!1),r=fe.useRef(()=>{});return fe.useEffect(()=>{const o=a=>{if(a.target&&!i.current){let c=function(){ctt(W5n,t,l,{discrete:!0})};const l={originalEvent:a};a.pointerType==="touch"?(e.removeEventListener("click",r.current),r.current=c,e.addEventListener("click",r.current,{once:!0})):c()}else e.removeEventListener("click",r.current);i.current=!1},s=window.setTimeout(()=>{e.addEventListener("pointerdown",o)},0);return()=>{window.clearTimeout(s),e.removeEventListener("pointerdown",o),e.removeEventListener("click",r.current)}},[e,t]),{onPointerDownCapture:()=>i.current=!0}}function e3n(n,e=globalThis?.document){const t=uT(n),i=fe.useRef(!1);return fe.useEffect(()=>{const r=o=>{o.target&&!i.current&&ctt(K5n,t,{originalEvent:o},{discrete:!1})};return e.addEventListener("focusin",r),()=>e.removeEventListener("focusin",r)},[e,t]),{onFocusCapture:()=>i.current=!0,onBlurCapture:()=>i.current=!1}}function att(){const n=new CustomEvent(Zye);document.dispatchEvent(n)}function ctt(n,e,t,{discrete:i}){const r=t.originalEvent.target,o=new CustomEvent(n,{bubbles:!1,cancelable:!0,detail:t});e&&r.addEventListener(n,e,{once:!0}),i?ttt(r,o):r.dispatchEvent(o)}var Qye=0;function t3n(){fe.useEffect(()=>{const n=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",n[0]??ltt()),document.body.insertAdjacentElement("beforeend",n[1]??ltt()),Qye++,()=>{Qye===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(e=>e.remove()),Qye--}},[])}function ltt(){const n=document.createElement("span");return n.setAttribute("data-radix-focus-guard",""),n.tabIndex=0,n.style.outline="none",n.style.opacity="0",n.style.position="fixed",n.style.pointerEvents="none",n}var Jye="focusScope.autoFocusOnMount",ege="focusScope.autoFocusOnUnmount",utt={bubbles:!1,cancelable:!0},n3n="FocusScope",dtt=fe.forwardRef((n,e)=>{const{loop:t=!1,trapped:i=!1,onMountAutoFocus:r,onUnmountAutoFocus:o,...s}=n,[a,c]=fe.useState(null),l=uT(r),u=uT(o),d=fe.useRef(null),h=dw(e,_=>c(_)),p=fe.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;fe.useEffect(()=>{if(i){let _=function(w){if(p.paused||!a)return;const E=w.target;a.contains(E)?d.current=E:VM(d.current,{select:!0})},g=function(w){if(p.paused||!a)return;const E=w.relatedTarget;E!==null&&(a.contains(E)||VM(d.current,{select:!0}))},x=function(w){if(document.activeElement===document.body)for(const N of w)N.removedNodes.length>0&&VM(a)};document.addEventListener("focusin",_),document.addEventListener("focusout",g);const b=new MutationObserver(x);return a&&b.observe(a,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",_),document.removeEventListener("focusout",g),b.disconnect()}}},[i,a,p.paused]),fe.useEffect(()=>{if(a){ftt.add(p);const _=document.activeElement;if(!a.contains(_)){const x=new CustomEvent(Jye,utt);a.addEventListener(Jye,l),a.dispatchEvent(x),x.defaultPrevented||(i3n(c3n(htt(a)),{select:!0}),document.activeElement===_&&VM(a))}return()=>{a.removeEventListener(Jye,l),setTimeout(()=>{const x=new CustomEvent(ege,utt);a.addEventListener(ege,u),a.dispatchEvent(x),x.defaultPrevented||VM(_??document.body,{select:!0}),a.removeEventListener(ege,u),ftt.remove(p)},0)}}},[a,l,u,p]);const m=fe.useCallback(_=>{if(!t&&!i||p.paused)return;const g=_.key==="Tab"&&!_.altKey&&!_.ctrlKey&&!_.metaKey,x=document.activeElement;if(g&&x){const b=_.currentTarget,[w,E]=r3n(b);w&&E?!_.shiftKey&&x===E?(_.preventDefault(),t&&VM(w,{select:!0})):_.shiftKey&&x===w&&(_.preventDefault(),t&&VM(E,{select:!0})):x===b&&_.preventDefault()}},[t,i,p.paused]);return ce.jsx(Nv.div,{tabIndex:-1,...s,ref:h,onKeyDown:m})});dtt.displayName=n3n;function i3n(n,{select:e=!1}={}){const t=document.activeElement;for(const i of n)if(VM(i,{select:e}),document.activeElement!==t)return}function r3n(n){const e=htt(n),t=ptt(e,n),i=ptt(e.reverse(),n);return[t,i]}function htt(n){const e=[],t=document.createTreeWalker(n,NodeFilter.SHOW_ELEMENT,{acceptNode:i=>{const r=i.tagName==="INPUT"&&i.type==="hidden";return i.disabled||i.hidden||r?NodeFilter.FILTER_SKIP:i.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;t.nextNode();)e.push(t.currentNode);return e}function ptt(n,e){for(const t of n)if(!o3n(t,{upTo:e}))return t}function o3n(n,{upTo:e}){if(getComputedStyle(n).visibility==="hidden")return!0;for(;n;){if(e!==void 0&&n===e)return!1;if(getComputedStyle(n).display==="none")return!0;n=n.parentElement}return!1}function s3n(n){return n instanceof HTMLInputElement&&"select"in n}function VM(n,{select:e=!1}={}){if(n&&n.focus){const t=document.activeElement;n.focus({preventScroll:!0}),n!==t&&s3n(n)&&e&&n.select()}}var ftt=a3n();function a3n(){let n=[];return{add(e){const t=n[0];e!==t&&t?.pause(),n=mtt(n,e),n.unshift(e)},remove(e){n=mtt(n,e),n[0]?.resume()}}}function mtt(n,e){const t=[...n],i=t.indexOf(e);return i!==-1&&t.splice(i,1),t}function c3n(n){return n.filter(e=>e.tagName!=="A")}var l3n=nz[" useId ".trim().toString()]||(()=>{}),u3n=0;function x8(n){const[e,t]=fe.useState(l3n());return HM(()=>{t(i=>i??String(u3n++))},[n]),e?`radix-${e}`:""}var d3n=["top","right","bottom","left"],GM=Math.min,oS=Math.max,EV=Math.round,TV=Math.floor,dT=n=>({x:n,y:n}),h3n={left:"right",right:"left",bottom:"top",top:"bottom"},p3n={start:"end",end:"start"};function tge(n,e,t){return oS(n,GM(e,t))}function X5(n,e){return typeof n=="function"?n(e):n}function W5(n){return n.split("-")[0]}function pI(n){return n.split("-")[1]}function nge(n){return n==="x"?"y":"x"}function ige(n){return n==="y"?"height":"width"}var f3n=new Set(["top","bottom"]);function hT(n){return f3n.has(W5(n))?"y":"x"}function rge(n){return nge(hT(n))}function m3n(n,e,t){t===void 0&&(t=!1);const i=pI(n),r=rge(n),o=ige(r);let s=r==="x"?i===(t?"end":"start")?"right":"left":i==="start"?"bottom":"top";return e.reference[o]>e.floating[o]&&(s=MV(s)),[s,MV(s)]}function _3n(n){const e=MV(n);return[oge(n),e,oge(e)]}function oge(n){return n.replace(/start|end/g,e=>p3n[e])}var _tt=["left","right"],ytt=["right","left"],y3n=["top","bottom"],g3n=["bottom","top"];function x3n(n,e,t){switch(n){case"top":case"bottom":return t?e?ytt:_tt:e?_tt:ytt;case"left":case"right":return e?y3n:g3n;default:return[]}}function b3n(n,e,t,i){const r=pI(n);let o=x3n(W5(n),t==="start",i);return r&&(o=o.map(s=>s+"-"+r),e&&(o=o.concat(o.map(oge)))),o}function MV(n){return n.replace(/left|right|bottom|top/g,e=>h3n[e])}function v3n(n){return{top:0,right:0,bottom:0,left:0,...n}}function gtt(n){return typeof n!="number"?v3n(n):{top:n,right:n,bottom:n,left:n}}function CV(n){const{x:e,y:t,width:i,height:r}=n;return{width:i,height:r,top:t,left:e,right:e+i,bottom:t+r,x:e,y:t}}function xtt(n,e,t){let{reference:i,floating:r}=n;const o=hT(e),s=rge(e),a=ige(s),c=W5(e),l=o==="y",u=i.x+i.width/2-r.width/2,d=i.y+i.height/2-r.height/2,h=i[a]/2-r[a]/2;let p;switch(c){case"top":p={x:u,y:i.y-r.height};break;case"bottom":p={x:u,y:i.y+i.height};break;case"right":p={x:i.x+i.width,y:d};break;case"left":p={x:i.x-r.width,y:d};break;default:p={x:i.x,y:i.y}}switch(pI(e)){case"start":p[s]-=h*(t&&l?-1:1);break;case"end":p[s]+=h*(t&&l?-1:1);break}return p}var w3n=async(n,e,t)=>{const{placement:i="bottom",strategy:r="absolute",middleware:o=[],platform:s}=t,a=o.filter(Boolean),c=await(s.isRTL==null?void 0:s.isRTL(e));let l=await s.getElementRects({reference:n,floating:e,strategy:r}),{x:u,y:d}=xtt(l,i,c),h=i,p={},m=0;for(let _=0;_<a.length;_++){const{name:g,fn:x}=a[_],{x:b,y:w,data:E,reset:N}=await x({x:u,y:d,initialPlacement:i,placement:h,strategy:r,middlewareData:p,rects:l,platform:s,elements:{reference:n,floating:e}});u=b??u,d=w??d,p={...p,[g]:{...p[g],...E}},N&&m<=50&&(m++,typeof N=="object"&&(N.placement&&(h=N.placement),N.rects&&(l=N.rects===!0?await s.getElementRects({reference:n,floating:e,strategy:r}):N.rects),{x:u,y:d}=xtt(l,h,c)),_=-1)}return{x:u,y:d,placement:h,strategy:r,middlewareData:p}};async function b8(n,e){var t;e===void 0&&(e={});const{x:i,y:r,platform:o,rects:s,elements:a,strategy:c}=n,{boundary:l="clippingAncestors",rootBoundary:u="viewport",elementContext:d="floating",altBoundary:h=!1,padding:p=0}=X5(e,n),m=gtt(p),g=a[h?d==="floating"?"reference":"floating":d],x=CV(await o.getClippingRect({element:(t=await(o.isElement==null?void 0:o.isElement(g)))==null||t?g:g.contextElement||await(o.getDocumentElement==null?void 0:o.getDocumentElement(a.floating)),boundary:l,rootBoundary:u,strategy:c})),b=d==="floating"?{x:i,y:r,width:s.floating.width,height:s.floating.height}:s.reference,w=await(o.getOffsetParent==null?void 0:o.getOffsetParent(a.floating)),E=await(o.isElement==null?void 0:o.isElement(w))?await(o.getScale==null?void 0:o.getScale(w))||{x:1,y:1}:{x:1,y:1},N=CV(o.convertOffsetParentRelativeRectToViewportRelativeRect?await o.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:b,offsetParent:w,strategy:c}):b);return{top:(x.top-N.top+m.top)/E.y,bottom:(N.bottom-x.bottom+m.bottom)/E.y,left:(x.left-N.left+m.left)/E.x,right:(N.right-x.right+m.right)/E.x}}var S3n=n=>({name:"arrow",options:n,async fn(e){const{x:t,y:i,placement:r,rects:o,platform:s,elements:a,middlewareData:c}=e,{element:l,padding:u=0}=X5(n,e)||{};if(l==null)return{};const d=gtt(u),h={x:t,y:i},p=rge(r),m=ige(p),_=await s.getDimensions(l),g=p==="y",x=g?"top":"left",b=g?"bottom":"right",w=g?"clientHeight":"clientWidth",E=o.reference[m]+o.reference[p]-h[p]-o.floating[m],N=h[p]-o.reference[p],A=await(s.getOffsetParent==null?void 0:s.getOffsetParent(l));let I=A?A[w]:0;(!I||!await(s.isElement==null?void 0:s.isElement(A)))&&(I=a.floating[w]||o.floating[m]);const M=E/2-N/2,k=I/2-_[m]/2-1,C=GM(d[x],k),U=GM(d[b],k),O=C,H=I-_[m]-U,Y=I/2-_[m]/2+M,W=tge(O,Y,H),K=!c.arrow&&pI(r)!=null&&Y!==W&&o.reference[m]/2-(Y<O?C:U)-_[m]/2<0,J=K?Y<O?Y-O:Y-H:0;return{[p]:h[p]+J,data:{[p]:W,centerOffset:Y-W-J,...K&&{alignmentOffset:J}},reset:K}}}),E3n=function(n){return n===void 0&&(n={}),{name:"flip",options:n,async fn(e){var t,i;const{placement:r,middlewareData:o,rects:s,initialPlacement:a,platform:c,elements:l}=e,{mainAxis:u=!0,crossAxis:d=!0,fallbackPlacements:h,fallbackStrategy:p="bestFit",fallbackAxisSideDirection:m="none",flipAlignment:_=!0,...g}=X5(n,e);if((t=o.arrow)!=null&&t.alignmentOffset)return{};const x=W5(r),b=hT(a),w=W5(a)===a,E=await(c.isRTL==null?void 0:c.isRTL(l.floating)),N=h||(w||!_?[MV(a)]:_3n(a)),A=m!=="none";!h&&A&&N.push(...b3n(a,_,m,E));const I=[a,...N],M=await b8(e,g),k=[];let C=((i=o.flip)==null?void 0:i.overflows)||[];if(u&&k.push(M[x]),d){const Y=m3n(r,s,E);k.push(M[Y[0]],M[Y[1]])}if(C=[...C,{placement:r,overflows:k}],!k.every(Y=>Y<=0)){var U,O;const Y=(((U=o.flip)==null?void 0:U.index)||0)+1,W=I[Y];if(W&&(!(d==="alignment"?b!==hT(W):!1)||C.every(se=>hT(se.placement)===b?se.overflows[0]>0:!0)))return{data:{index:Y,overflows:C},reset:{placement:W}};let K=(O=C.filter(J=>J.overflows[0]<=0).sort((J,se)=>J.overflows[1]-se.overflows[1])[0])==null?void 0:O.placement;if(!K)switch(p){case"bestFit":{var H;const J=(H=C.filter(se=>{if(A){const de=hT(se.placement);return de===b||de==="y"}return!0}).map(se=>[se.placement,se.overflows.filter(de=>de>0).reduce((de,ve)=>de+ve,0)]).sort((se,de)=>se[1]-de[1])[0])==null?void 0:H[0];J&&(K=J);break}case"initialPlacement":K=a;break}if(r!==K)return{reset:{placement:K}}}return{}}}};function btt(n,e){return{top:n.top-e.height,right:n.right-e.width,bottom:n.bottom-e.height,left:n.left-e.width}}function vtt(n){return d3n.some(e=>n[e]>=0)}var T3n=function(n){return n===void 0&&(n={}),{name:"hide",options:n,async fn(e){const{rects:t}=e,{strategy:i="referenceHidden",...r}=X5(n,e);switch(i){case"referenceHidden":{const o=await b8(e,{...r,elementContext:"reference"}),s=btt(o,t.reference);return{data:{referenceHiddenOffsets:s,referenceHidden:vtt(s)}}}case"escaped":{const o=await b8(e,{...r,altBoundary:!0}),s=btt(o,t.floating);return{data:{escapedOffsets:s,escaped:vtt(s)}}}default:return{}}}}},wtt=new Set(["left","top"]);async function M3n(n,e){const{placement:t,platform:i,elements:r}=n,o=await(i.isRTL==null?void 0:i.isRTL(r.floating)),s=W5(t),a=pI(t),c=hT(t)==="y",l=wtt.has(s)?-1:1,u=o&&c?-1:1,d=X5(e,n);let{mainAxis:h,crossAxis:p,alignmentAxis:m}=typeof d=="number"?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.alignmentAxis};return a&&typeof m=="number"&&(p=a==="end"?m*-1:m),c?{x:p*u,y:h*l}:{x:h*l,y:p*u}}var C3n=function(n){return n===void 0&&(n=0),{name:"offset",options:n,async fn(e){var t,i;const{x:r,y:o,placement:s,middlewareData:a}=e,c=await M3n(e,n);return s===((t=a.offset)==null?void 0:t.placement)&&(i=a.arrow)!=null&&i.alignmentOffset?{}:{x:r+c.x,y:o+c.y,data:{...c,placement:s}}}}},A3n=function(n){return n===void 0&&(n={}),{name:"shift",options:n,async fn(e){const{x:t,y:i,placement:r}=e,{mainAxis:o=!0,crossAxis:s=!1,limiter:a={fn:g=>{let{x,y:b}=g;return{x,y:b}}},...c}=X5(n,e),l={x:t,y:i},u=await b8(e,c),d=hT(W5(r)),h=nge(d);let p=l[h],m=l[d];if(o){const g=h==="y"?"top":"left",x=h==="y"?"bottom":"right",b=p+u[g],w=p-u[x];p=tge(b,p,w)}if(s){const g=d==="y"?"top":"left",x=d==="y"?"bottom":"right",b=m+u[g],w=m-u[x];m=tge(b,m,w)}const _=a.fn({...e,[h]:p,[d]:m});return{..._,data:{x:_.x-t,y:_.y-i,enabled:{[h]:o,[d]:s}}}}}},P3n=function(n){return n===void 0&&(n={}),{options:n,fn(e){const{x:t,y:i,placement:r,rects:o,middlewareData:s}=e,{offset:a=0,mainAxis:c=!0,crossAxis:l=!0}=X5(n,e),u={x:t,y:i},d=hT(r),h=nge(d);let p=u[h],m=u[d];const _=X5(a,e),g=typeof _=="number"?{mainAxis:_,crossAxis:0}:{mainAxis:0,crossAxis:0,..._};if(c){const w=h==="y"?"height":"width",E=o.reference[h]-o.floating[w]+g.mainAxis,N=o.reference[h]+o.reference[w]-g.mainAxis;p<E?p=E:p>N&&(p=N)}if(l){var x,b;const w=h==="y"?"width":"height",E=wtt.has(W5(r)),N=o.reference[d]-o.floating[w]+(E&&((x=s.offset)==null?void 0:x[d])||0)+(E?0:g.crossAxis),A=o.reference[d]+o.reference[w]+(E?0:((b=s.offset)==null?void 0:b[d])||0)-(E?g.crossAxis:0);m<N?m=N:m>A&&(m=A)}return{[h]:p,[d]:m}}}},R3n=function(n){return n===void 0&&(n={}),{name:"size",options:n,async fn(e){var t,i;const{placement:r,rects:o,platform:s,elements:a}=e,{apply:c=()=>{},...l}=X5(n,e),u=await b8(e,l),d=W5(r),h=pI(r),p=hT(r)==="y",{width:m,height:_}=o.floating;let g,x;d==="top"||d==="bottom"?(g=d,x=h===(await(s.isRTL==null?void 0:s.isRTL(a.floating))?"start":"end")?"left":"right"):(x=d,g=h==="end"?"top":"bottom");const b=_-u.top-u.bottom,w=m-u.left-u.right,E=GM(_-u[g],b),N=GM(m-u[x],w),A=!e.middlewareData.shift;let I=E,M=N;if((t=e.middlewareData.shift)!=null&&t.enabled.x&&(M=w),(i=e.middlewareData.shift)!=null&&i.enabled.y&&(I=b),A&&!h){const C=oS(u.left,0),U=oS(u.right,0),O=oS(u.top,0),H=oS(u.bottom,0);p?M=m-2*(C!==0||U!==0?C+U:oS(u.left,u.right)):I=_-2*(O!==0||H!==0?O+H:oS(u.top,u.bottom))}await c({...e,availableWidth:M,availableHeight:I});const k=await s.getDimensions(a.floating);return m!==k.width||_!==k.height?{reset:{rects:!0}}:{}}}};function AV(){return typeof window<"u"}function fI(n){return Stt(n)?(n.nodeName||"").toLowerCase():"#document"}function sS(n){var e;return(n==null||(e=n.ownerDocument)==null?void 0:e.defaultView)||window}function pT(n){var e;return(e=(Stt(n)?n.ownerDocument:n.document)||window.document)==null?void 0:e.documentElement}function Stt(n){return AV()?n instanceof Node||n instanceof sS(n).Node:!1}function W2(n){return AV()?n instanceof Element||n instanceof sS(n).Element:!1}function fT(n){return AV()?n instanceof HTMLElement||n instanceof sS(n).HTMLElement:!1}function Ett(n){return!AV()||typeof ShadowRoot>"u"?!1:n instanceof ShadowRoot||n instanceof sS(n).ShadowRoot}var I3n=new Set(["inline","contents"]);function v8(n){const{overflow:e,overflowX:t,overflowY:i,display:r}=K2(n);return/auto|scroll|overlay|hidden|clip/.test(e+i+t)&&!I3n.has(r)}var N3n=new Set(["table","td","th"]);function k3n(n){return N3n.has(fI(n))}var O3n=[":popover-open",":modal"];function PV(n){return O3n.some(e=>{try{return n.matches(e)}catch{return!1}})}var L3n=["transform","translate","scale","rotate","perspective"],D3n=["transform","translate","scale","rotate","perspective","filter"],z3n=["paint","layout","strict","content"];function sge(n){const e=age(),t=W2(n)?K2(n):n;return L3n.some(i=>t[i]?t[i]!=="none":!1)||(t.containerType?t.containerType!=="normal":!1)||!e&&(t.backdropFilter?t.backdropFilter!=="none":!1)||!e&&(t.filter?t.filter!=="none":!1)||D3n.some(i=>(t.willChange||"").includes(i))||z3n.some(i=>(t.contain||"").includes(i))}function $3n(n){let e=YM(n);for(;fT(e)&&!mI(e);){if(sge(e))return e;if(PV(e))return null;e=YM(e)}return null}function age(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}var F3n=new Set(["html","body","#document"]);function mI(n){return F3n.has(fI(n))}function K2(n){return sS(n).getComputedStyle(n)}function RV(n){return W2(n)?{scrollLeft:n.scrollLeft,scrollTop:n.scrollTop}:{scrollLeft:n.scrollX,scrollTop:n.scrollY}}function YM(n){if(fI(n)==="html")return n;const e=n.assignedSlot||n.parentNode||Ett(n)&&n.host||pT(n);return Ett(e)?e.host:e}function Ttt(n){const e=YM(n);return mI(e)?n.ownerDocument?n.ownerDocument.body:n.body:fT(e)&&v8(e)?e:Ttt(e)}function w8(n,e,t){var i;e===void 0&&(e=[]),t===void 0&&(t=!0);const r=Ttt(n),o=r===((i=n.ownerDocument)==null?void 0:i.body),s=sS(r);if(o){const a=cge(s);return e.concat(s,s.visualViewport||[],v8(r)?r:[],a&&t?w8(a):[])}return e.concat(r,w8(r,[],t))}function cge(n){return n.parent&&Object.getPrototypeOf(n.parent)?n.frameElement:null}function Mtt(n){const e=K2(n);let t=parseFloat(e.width)||0,i=parseFloat(e.height)||0;const r=fT(n),o=r?n.offsetWidth:t,s=r?n.offsetHeight:i,a=EV(t)!==o||EV(i)!==s;return a&&(t=o,i=s),{width:t,height:i,$:a}}function lge(n){return W2(n)?n:n.contextElement}function _I(n){const e=lge(n);if(!fT(e))return dT(1);const t=e.getBoundingClientRect(),{width:i,height:r,$:o}=Mtt(e);let s=(o?EV(t.width):t.width)/i,a=(o?EV(t.height):t.height)/r;return(!s||!Number.isFinite(s))&&(s=1),(!a||!Number.isFinite(a))&&(a=1),{x:s,y:a}}var U3n=dT(0);function Ctt(n){const e=sS(n);return!age()||!e.visualViewport?U3n:{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}}function B3n(n,e,t){return e===void 0&&(e=!1),!t||e&&t!==sS(n)?!1:e}function f4(n,e,t,i){e===void 0&&(e=!1),t===void 0&&(t=!1);const r=n.getBoundingClientRect(),o=lge(n);let s=dT(1);e&&(i?W2(i)&&(s=_I(i)):s=_I(n));const a=B3n(o,t,i)?Ctt(o):dT(0);let c=(r.left+a.x)/s.x,l=(r.top+a.y)/s.y,u=r.width/s.x,d=r.height/s.y;if(o){const h=sS(o),p=i&&W2(i)?sS(i):i;let m=h,_=cge(m);for(;_&&i&&p!==m;){const g=_I(_),x=_.getBoundingClientRect(),b=K2(_),w=x.left+(_.clientLeft+parseFloat(b.paddingLeft))*g.x,E=x.top+(_.clientTop+parseFloat(b.paddingTop))*g.y;c*=g.x,l*=g.y,u*=g.x,d*=g.y,c+=w,l+=E,m=sS(_),_=cge(m)}}return CV({width:u,height:d,x:c,y:l})}function IV(n,e){const t=RV(n).scrollLeft;return e?e.left+t:f4(pT(n)).left+t}function Att(n,e){const t=n.getBoundingClientRect(),i=t.left+e.scrollLeft-IV(n,t),r=t.top+e.scrollTop;return{x:i,y:r}}function j3n(n){let{elements:e,rect:t,offsetParent:i,strategy:r}=n;const o=r==="fixed",s=pT(i),a=e?PV(e.floating):!1;if(i===s||a&&o)return t;let c={scrollLeft:0,scrollTop:0},l=dT(1);const u=dT(0),d=fT(i);if((d||!d&&!o)&&((fI(i)!=="body"||v8(s))&&(c=RV(i)),fT(i))){const p=f4(i);l=_I(i),u.x=p.x+i.clientLeft,u.y=p.y+i.clientTop}const h=s&&!d&&!o?Att(s,c):dT(0);return{width:t.width*l.x,height:t.height*l.y,x:t.x*l.x-c.scrollLeft*l.x+u.x+h.x,y:t.y*l.y-c.scrollTop*l.y+u.y+h.y}}function H3n(n){return Array.from(n.getClientRects())}function V3n(n){const e=pT(n),t=RV(n),i=n.ownerDocument.body,r=oS(e.scrollWidth,e.clientWidth,i.scrollWidth,i.clientWidth),o=oS(e.scrollHeight,e.clientHeight,i.scrollHeight,i.clientHeight);let s=-t.scrollLeft+IV(n);const a=-t.scrollTop;return K2(i).direction==="rtl"&&(s+=oS(e.clientWidth,i.clientWidth)-r),{width:r,height:o,x:s,y:a}}var Ptt=25;function G3n(n,e){const t=sS(n),i=pT(n),r=t.visualViewport;let o=i.clientWidth,s=i.clientHeight,a=0,c=0;if(r){o=r.width,s=r.height;const u=age();(!u||u&&e==="fixed")&&(a=r.offsetLeft,c=r.offsetTop)}const l=IV(i);if(l<=0){const u=i.ownerDocument,d=u.body,h=getComputedStyle(d),p=u.compatMode==="CSS1Compat"&&parseFloat(h.marginLeft)+parseFloat(h.marginRight)||0,m=Math.abs(i.clientWidth-d.clientWidth-p);m<=Ptt&&(o-=m)}else l<=Ptt&&(o+=l);return{width:o,height:s,x:a,y:c}}var Y3n=new Set(["absolute","fixed"]);function q3n(n,e){const t=f4(n,!0,e==="fixed"),i=t.top+n.clientTop,r=t.left+n.clientLeft,o=fT(n)?_I(n):dT(1),s=n.clientWidth*o.x,a=n.clientHeight*o.y,c=r*o.x,l=i*o.y;return{width:s,height:a,x:c,y:l}}function Rtt(n,e,t){let i;if(e==="viewport")i=G3n(n,t);else if(e==="document")i=V3n(pT(n));else if(W2(e))i=q3n(e,t);else{const r=Ctt(n);i={x:e.x-r.x,y:e.y-r.y,width:e.width,height:e.height}}return CV(i)}function Itt(n,e){const t=YM(n);return t===e||!W2(t)||mI(t)?!1:K2(t).position==="fixed"||Itt(t,e)}function X3n(n,e){const t=e.get(n);if(t)return t;let i=w8(n,[],!1).filter(a=>W2(a)&&fI(a)!=="body"),r=null;const o=K2(n).position==="fixed";let s=o?YM(n):n;for(;W2(s)&&!mI(s);){const a=K2(s),c=sge(s);!c&&a.position==="fixed"&&(r=null),(o?!c&&!r:!c&&a.position==="static"&&!!r&&Y3n.has(r.position)||v8(s)&&!c&&Itt(n,s))?i=i.filter(u=>u!==s):r=a,s=YM(s)}return e.set(n,i),i}function W3n(n){let{element:e,boundary:t,rootBoundary:i,strategy:r}=n;const s=[...t==="clippingAncestors"?PV(e)?[]:X3n(e,this._c):[].concat(t),i],a=s[0],c=s.reduce((l,u)=>{const d=Rtt(e,u,r);return l.top=oS(d.top,l.top),l.right=GM(d.right,l.right),l.bottom=GM(d.bottom,l.bottom),l.left=oS(d.left,l.left),l},Rtt(e,a,r));return{width:c.right-c.left,height:c.bottom-c.top,x:c.left,y:c.top}}function K3n(n){const{width:e,height:t}=Mtt(n);return{width:e,height:t}}function Z3n(n,e,t){const i=fT(e),r=pT(e),o=t==="fixed",s=f4(n,!0,o,e);let a={scrollLeft:0,scrollTop:0};const c=dT(0);function l(){c.x=IV(r)}if(i||!i&&!o)if((fI(e)!=="body"||v8(r))&&(a=RV(e)),i){const p=f4(e,!0,o,e);c.x=p.x+e.clientLeft,c.y=p.y+e.clientTop}else r&&l();o&&!i&&r&&l();const u=r&&!i&&!o?Att(r,a):dT(0),d=s.left+a.scrollLeft-c.x-u.x,h=s.top+a.scrollTop-c.y-u.y;return{x:d,y:h,width:s.width,height:s.height}}function uge(n){return K2(n).position==="static"}function Ntt(n,e){if(!fT(n)||K2(n).position==="fixed")return null;if(e)return e(n);let t=n.offsetParent;return pT(n)===t&&(t=t.ownerDocument.body),t}function ktt(n,e){const t=sS(n);if(PV(n))return t;if(!fT(n)){let r=YM(n);for(;r&&!mI(r);){if(W2(r)&&!uge(r))return r;r=YM(r)}return t}let i=Ntt(n,e);for(;i&&k3n(i)&&uge(i);)i=Ntt(i,e);return i&&mI(i)&&uge(i)&&!sge(i)?t:i||$3n(n)||t}var Q3n=async function(n){const e=this.getOffsetParent||ktt,t=this.getDimensions,i=await t(n.floating);return{reference:Z3n(n.reference,await e(n.floating),n.strategy),floating:{x:0,y:0,width:i.width,height:i.height}}};function J3n(n){return K2(n).direction==="rtl"}var eMn={convertOffsetParentRelativeRectToViewportRelativeRect:j3n,getDocumentElement:pT,getClippingRect:W3n,getOffsetParent:ktt,getElementRects:Q3n,getClientRects:H3n,getDimensions:K3n,getScale:_I,isElement:W2,isRTL:J3n};function Ott(n,e){return n.x===e.x&&n.y===e.y&&n.width===e.width&&n.height===e.height}function tMn(n,e){let t=null,i;const r=pT(n);function o(){var a;clearTimeout(i),(a=t)==null||a.disconnect(),t=null}function s(a,c){a===void 0&&(a=!1),c===void 0&&(c=1),o();const l=n.getBoundingClientRect(),{left:u,top:d,width:h,height:p}=l;if(a||e(),!h||!p)return;const m=TV(d),_=TV(r.clientWidth-(u+h)),g=TV(r.clientHeight-(d+p)),x=TV(u),w={rootMargin:-m+"px "+-_+"px "+-g+"px "+-x+"px",threshold:oS(0,GM(1,c))||1};let E=!0;function N(A){const I=A[0].intersectionRatio;if(I!==c){if(!E)return s();I?s(!1,I):i=setTimeout(()=>{s(!1,1e-7)},1e3)}I===1&&!Ott(l,n.getBoundingClientRect())&&s(),E=!1}try{t=new IntersectionObserver(N,{...w,root:r.ownerDocument})}catch{t=new IntersectionObserver(N,w)}t.observe(n)}return s(!0),o}function nMn(n,e,t,i){i===void 0&&(i={});const{ancestorScroll:r=!0,ancestorResize:o=!0,elementResize:s=typeof ResizeObserver=="function",layoutShift:a=typeof IntersectionObserver=="function",animationFrame:c=!1}=i,l=lge(n),u=r||o?[...l?w8(l):[],...w8(e)]:[];u.forEach(x=>{r&&x.addEventListener("scroll",t,{passive:!0}),o&&x.addEventListener("resize",t)});const d=l&&a?tMn(l,t):null;let h=-1,p=null;s&&(p=new ResizeObserver(x=>{let[b]=x;b&&b.target===l&&p&&(p.unobserve(e),cancelAnimationFrame(h),h=requestAnimationFrame(()=>{var w;(w=p)==null||w.observe(e)})),t()}),l&&!c&&p.observe(l),p.observe(e));let m,_=c?f4(n):null;c&&g();function g(){const x=f4(n);_&&!Ott(_,x)&&t(),_=x,m=requestAnimationFrame(g)}return t(),()=>{var x;u.forEach(b=>{r&&b.removeEventListener("scroll",t),o&&b.removeEventListener("resize",t)}),d?.(),(x=p)==null||x.disconnect(),p=null,c&&cancelAnimationFrame(m)}}var iMn=C3n,rMn=A3n,oMn=E3n,sMn=R3n,aMn=T3n,Ltt=S3n,cMn=P3n,lMn=(n,e,t)=>{const i=new Map,r={platform:eMn,...t},o={...r.platform,_c:i};return w3n(n,e,{...r,platform:o})},uMn=typeof document<"u",dMn=function(){},NV=uMn?fe.useLayoutEffect:dMn;function kV(n,e){if(n===e)return!0;if(typeof n!=typeof e)return!1;if(typeof n=="function"&&n.toString()===e.toString())return!0;let t,i,r;if(n&&e&&typeof n=="object"){if(Array.isArray(n)){if(t=n.length,t!==e.length)return!1;for(i=t;i--!==0;)if(!kV(n[i],e[i]))return!1;return!0}if(r=Object.keys(n),t=r.length,t!==Object.keys(e).length)return!1;for(i=t;i--!==0;)if(!{}.hasOwnProperty.call(e,r[i]))return!1;for(i=t;i--!==0;){const o=r[i];if(!(o==="_owner"&&n.$$typeof)&&!kV(n[o],e[o]))return!1}return!0}return n!==n&&e!==e}function Dtt(n){return typeof window>"u"?1:(n.ownerDocument.defaultView||window).devicePixelRatio||1}function ztt(n,e){const t=Dtt(n);return Math.round(e*t)/t}function dge(n){const e=fe.useRef(n);return NV(()=>{e.current=n}),e}function hMn(n){n===void 0&&(n={});const{placement:e="bottom",strategy:t="absolute",middleware:i=[],platform:r,elements:{reference:o,floating:s}={},transform:a=!0,whileElementsMounted:c,open:l}=n,[u,d]=fe.useState({x:0,y:0,strategy:t,placement:e,middlewareData:{},isPositioned:!1}),[h,p]=fe.useState(i);kV(h,i)||p(i);const[m,_]=fe.useState(null),[g,x]=fe.useState(null),b=fe.useCallback(se=>{se!==A.current&&(A.current=se,_(se))},[]),w=fe.useCallback(se=>{se!==I.current&&(I.current=se,x(se))},[]),E=o||m,N=s||g,A=fe.useRef(null),I=fe.useRef(null),M=fe.useRef(u),k=c!=null,C=dge(c),U=dge(r),O=dge(l),H=fe.useCallback(()=>{if(!A.current||!I.current)return;const se={placement:e,strategy:t,middleware:h};U.current&&(se.platform=U.current),lMn(A.current,I.current,se).then(de=>{const ve={...de,isPositioned:O.current!==!1};Y.current&&!kV(M.current,ve)&&(M.current=ve,Ak.flushSync(()=>{d(ve)}))})},[h,e,t,U,O]);NV(()=>{l===!1&&M.current.isPositioned&&(M.current.isPositioned=!1,d(se=>({...se,isPositioned:!1})))},[l]);const Y=fe.useRef(!1);NV(()=>(Y.current=!0,()=>{Y.current=!1}),[]),NV(()=>{if(E&&(A.current=E),N&&(I.current=N),E&&N){if(C.current)return C.current(E,N,H);H()}},[E,N,H,C,k]);const W=fe.useMemo(()=>({reference:A,floating:I,setReference:b,setFloating:w}),[b,w]),K=fe.useMemo(()=>({reference:E,floating:N}),[E,N]),J=fe.useMemo(()=>{const se={position:t,left:0,top:0};if(!K.floating)return se;const de=ztt(K.floating,u.x),ve=ztt(K.floating,u.y);return a?{...se,transform:"translate("+de+"px, "+ve+"px)",...Dtt(K.floating)>=1.5&&{willChange:"transform"}}:{position:t,left:de,top:ve}},[t,a,K.floating,u.x,u.y]);return fe.useMemo(()=>({...u,update:H,refs:W,elements:K,floatingStyles:J}),[u,H,W,K,J])}var pMn=n=>{function e(t){return{}.hasOwnProperty.call(t,"current")}return{name:"arrow",options:n,fn(t){const{element:i,padding:r}=typeof n=="function"?n(t):n;return i&&e(i)?i.current!=null?Ltt({element:i.current,padding:r}).fn(t):{}:i?Ltt({element:i,padding:r}).fn(t):{}}}},fMn=(n,e)=>({...iMn(n),options:[n,e]}),mMn=(n,e)=>({...rMn(n),options:[n,e]}),_Mn=(n,e)=>({...cMn(n),options:[n,e]}),yMn=(n,e)=>({...oMn(n),options:[n,e]}),gMn=(n,e)=>({...sMn(n),options:[n,e]}),xMn=(n,e)=>({...aMn(n),options:[n,e]}),bMn=(n,e)=>({...pMn(n),options:[n,e]}),vMn="Arrow",$tt=fe.forwardRef((n,e)=>{const{children:t,width:i=10,height:r=5,...o}=n;return ce.jsx(Nv.svg,{...o,ref:e,width:i,height:r,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:n.asChild?t:ce.jsx("polygon",{points:"0,0 30,0 15,10"})})});$tt.displayName=vMn;var wMn=$tt;function SMn(n){const[e,t]=fe.useState(void 0);return HM(()=>{if(n){t({width:n.offsetWidth,height:n.offsetHeight});const i=new ResizeObserver(r=>{if(!Array.isArray(r)||!r.length)return;const o=r[0];let s,a;if("borderBoxSize"in o){const c=o.borderBoxSize,l=Array.isArray(c)?c[0]:c;s=l.inlineSize,a=l.blockSize}else s=n.offsetWidth,a=n.offsetHeight;t({width:s,height:a})});return i.observe(n,{box:"border-box"}),()=>i.unobserve(n)}else t(void 0)},[n]),e}var hge="Popper",[Ftt,Utt]=g8(hge),[EMn,Btt]=Ftt(hge),jtt=n=>{const{__scopePopper:e,children:t}=n,[i,r]=fe.useState(null);return ce.jsx(EMn,{scope:e,anchor:i,onAnchorChange:r,children:t})};jtt.displayName=hge;var Htt="PopperAnchor",Vtt=fe.forwardRef((n,e)=>{const{__scopePopper:t,virtualRef:i,...r}=n,o=Btt(Htt,t),s=fe.useRef(null),a=dw(e,s),c=fe.useRef(null);return fe.useEffect(()=>{const l=c.current;c.current=i?.current||s.current,l!==c.current&&o.onAnchorChange(c.current)}),i?null:ce.jsx(Nv.div,{...r,ref:a})});Vtt.displayName=Htt;var pge="PopperContent",[TMn,MMn]=Ftt(pge),Gtt=fe.forwardRef((n,e)=>{const{__scopePopper:t,side:i="bottom",sideOffset:r=0,align:o="center",alignOffset:s=0,arrowPadding:a=0,avoidCollisions:c=!0,collisionBoundary:l=[],collisionPadding:u=0,sticky:d="partial",hideWhenDetached:h=!1,updatePositionStrategy:p="optimized",onPlaced:m,..._}=n,g=Btt(pge,t),[x,b]=fe.useState(null),w=dw(e,Be=>b(Be)),[E,N]=fe.useState(null),A=SMn(E),I=A?.width??0,M=A?.height??0,k=i+(o!=="center"?"-"+o:""),C=typeof u=="number"?u:{top:0,right:0,bottom:0,left:0,...u},U=Array.isArray(l)?l:[l],O=U.length>0,H={padding:C,boundary:U.filter(AMn),altBoundary:O},{refs:Y,floatingStyles:W,placement:K,isPositioned:J,middlewareData:se}=hMn({strategy:"fixed",placement:k,whileElementsMounted:(...Be)=>nMn(...Be,{animationFrame:p==="always"}),elements:{reference:g.anchor},middleware:[fMn({mainAxis:r+M,alignmentAxis:s}),c&&mMn({mainAxis:!0,crossAxis:!1,limiter:d==="partial"?_Mn():void 0,...H}),c&&yMn({...H}),gMn({...H,apply:({elements:Be,rects:Re,availableWidth:oe,availableHeight:Ee})=>{const{width:be,height:Ge}=Re.reference,nt=Be.floating.style;nt.setProperty("--radix-popper-available-width",`${oe}px`),nt.setProperty("--radix-popper-available-height",`${Ee}px`),nt.setProperty("--radix-popper-anchor-width",`${be}px`),nt.setProperty("--radix-popper-anchor-height",`${Ge}px`)}}),E&&bMn({element:E,padding:a}),PMn({arrowWidth:I,arrowHeight:M}),h&&xMn({strategy:"referenceHidden",...H})]}),[de,ve]=Xtt(K),re=uT(m);HM(()=>{J&&re?.()},[J,re]);const ue=se.arrow?.x,me=se.arrow?.y,Me=se.arrow?.centerOffset!==0,[ke,ze]=fe.useState();return HM(()=>{x&&ze(window.getComputedStyle(x).zIndex)},[x]),ce.jsx("div",{ref:Y.setFloating,"data-radix-popper-content-wrapper":"",style:{...W,transform:J?W.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:ke,"--radix-popper-transform-origin":[se.transformOrigin?.x,se.transformOrigin?.y].join(" "),...se.hide?.referenceHidden&&{visibility:"hidden",pointerEvents:"none"}},dir:n.dir,children:ce.jsx(TMn,{scope:t,placedSide:de,onArrowChange:N,arrowX:ue,arrowY:me,shouldHideArrow:Me,children:ce.jsx(Nv.div,{"data-side":de,"data-align":ve,..._,ref:w,style:{..._.style,animation:J?void 0:"none"}})})})});Gtt.displayName=pge;var Ytt="PopperArrow",CMn={top:"bottom",right:"left",bottom:"top",left:"right"},qtt=fe.forwardRef(function(e,t){const{__scopePopper:i,...r}=e,o=MMn(Ytt,i),s=CMn[o.placedSide];return ce.jsx("span",{ref:o.onArrowChange,style:{position:"absolute",left:o.arrowX,top:o.arrowY,[s]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[o.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[o.placedSide],visibility:o.shouldHideArrow?"hidden":void 0},children:ce.jsx(wMn,{...r,ref:t,style:{...r.style,display:"block"}})})});qtt.displayName=Ytt;function AMn(n){return n!==null}var PMn=n=>({name:"transformOrigin",options:n,fn(e){const{placement:t,rects:i,middlewareData:r}=e,s=r.arrow?.centerOffset!==0,a=s?0:n.arrowWidth,c=s?0:n.arrowHeight,[l,u]=Xtt(t),d={start:"0%",center:"50%",end:"100%"}[u],h=(r.arrow?.x??0)+a/2,p=(r.arrow?.y??0)+c/2;let m="",_="";return l==="bottom"?(m=s?d:`${h}px`,_=`${-c}px`):l==="top"?(m=s?d:`${h}px`,_=`${i.floating.height+c}px`):l==="right"?(m=`${-c}px`,_=s?d:`${p}px`):l==="left"&&(m=`${i.floating.width+c}px`,_=s?d:`${p}px`),{data:{x:m,y:_}}}});function Xtt(n){const[e,t="center"]=n.split("-");return[e,t]}var Wtt=jtt,RMn=Vtt,IMn=Gtt,NMn=qtt,kMn="Portal",Ktt=fe.forwardRef((n,e)=>{const{container:t,...i}=n,[r,o]=fe.useState(!1);HM(()=>o(!0),[]);const s=t||r&&globalThis?.document?.body;return s?rz.createPortal(ce.jsx(Nv.div,{...i,ref:e}),s):null});Ktt.displayName=kMn;function OMn(n,e){return fe.useReducer((t,i)=>e[t][i]??t,n)}var S8=n=>{const{present:e,children:t}=n,i=LMn(e),r=typeof t=="function"?t({present:i.isPresent}):fe.Children.only(t),o=dw(i.ref,DMn(r));return typeof t=="function"||i.isPresent?fe.cloneElement(r,{ref:o}):null};S8.displayName="Presence";function LMn(n){const[e,t]=fe.useState(),i=fe.useRef(null),r=fe.useRef(n),o=fe.useRef("none"),s=n?"mounted":"unmounted",[a,c]=OMn(s,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return fe.useEffect(()=>{const l=OV(i.current);o.current=a==="mounted"?l:"none"},[a]),HM(()=>{const l=i.current,u=r.current;if(u!==n){const h=o.current,p=OV(l);n?c("MOUNT"):p==="none"||l?.display==="none"?c("UNMOUNT"):c(u&&h!==p?"ANIMATION_OUT":"UNMOUNT"),r.current=n}},[n,c]),HM(()=>{if(e){let l;const u=e.ownerDocument.defaultView??window,d=p=>{const _=OV(i.current).includes(CSS.escape(p.animationName));if(p.target===e&&_&&(c("ANIMATION_END"),!r.current)){const g=e.style.animationFillMode;e.style.animationFillMode="forwards",l=u.setTimeout(()=>{e.style.animationFillMode==="forwards"&&(e.style.animationFillMode=g)})}},h=p=>{p.target===e&&(o.current=OV(i.current))};return e.addEventListener("animationstart",h),e.addEventListener("animationcancel",d),e.addEventListener("animationend",d),()=>{u.clearTimeout(l),e.removeEventListener("animationstart",h),e.removeEventListener("animationcancel",d),e.removeEventListener("animationend",d)}}else c("ANIMATION_END")},[e,c]),{isPresent:["mounted","unmountSuspended"].includes(a),ref:fe.useCallback(l=>{i.current=l?getComputedStyle(l):null,t(l)},[])}}function OV(n){return n?.animationName||"none"}function DMn(n){let e=Object.getOwnPropertyDescriptor(n.props,"ref")?.get,t=e&&"isReactWarning"in e&&e.isReactWarning;return t?n.ref:(e=Object.getOwnPropertyDescriptor(n,"ref")?.get,t=e&&"isReactWarning"in e&&e.isReactWarning,t?n.props.ref:n.props.ref||n.ref)}var fge="rovingFocusGroup.onEntryFocus",zMn={bubbles:!1,cancelable:!0},E8="RovingFocusGroup",[mge,Ztt,$Mn]=ntt(E8),[FMn,Qtt]=g8(E8,[$Mn]),[UMn,BMn]=FMn(E8),Jtt=fe.forwardRef((n,e)=>ce.jsx(mge.Provider,{scope:n.__scopeRovingFocusGroup,children:ce.jsx(mge.Slot,{scope:n.__scopeRovingFocusGroup,children:ce.jsx(jMn,{...n,ref:e})})}));Jtt.displayName=E8;var jMn=fe.forwardRef((n,e)=>{const{__scopeRovingFocusGroup:t,orientation:i,loop:r=!1,dir:o,currentTabStopId:s,defaultCurrentTabStopId:a,onCurrentTabStopIdChange:c,onEntryFocus:l,preventScrollOnEntryFocus:u=!1,...d}=n,h=fe.useRef(null),p=dw(e,h),m=itt(o),[_,g]=Kye({prop:s,defaultProp:a??null,onChange:c,caller:E8}),[x,b]=fe.useState(!1),w=uT(l),E=Ztt(t),N=fe.useRef(!1),[A,I]=fe.useState(0);return fe.useEffect(()=>{const M=h.current;if(M)return M.addEventListener(fge,w),()=>M.removeEventListener(fge,w)},[w]),ce.jsx(UMn,{scope:t,orientation:i,dir:m,loop:r,currentTabStopId:_,onItemFocus:fe.useCallback(M=>g(M),[g]),onItemShiftTab:fe.useCallback(()=>b(!0),[]),onFocusableItemAdd:fe.useCallback(()=>I(M=>M+1),[]),onFocusableItemRemove:fe.useCallback(()=>I(M=>M-1),[]),children:ce.jsx(Nv.div,{tabIndex:x||A===0?-1:0,"data-orientation":i,...d,ref:p,style:{outline:"none",...n.style},onMouseDown:gd(n.onMouseDown,()=>{N.current=!0}),onFocus:gd(n.onFocus,M=>{const k=!N.current;if(M.target===M.currentTarget&&k&&!x){const C=new CustomEvent(fge,zMn);if(M.currentTarget.dispatchEvent(C),!C.defaultPrevented){const U=E().filter(K=>K.focusable),O=U.find(K=>K.active),H=U.find(K=>K.id===_),W=[O,H,...U].filter(Boolean).map(K=>K.ref.current);nnt(W,u)}}N.current=!1}),onBlur:gd(n.onBlur,()=>b(!1))})})}),ent="RovingFocusGroupItem",tnt=fe.forwardRef((n,e)=>{const{__scopeRovingFocusGroup:t,focusable:i=!0,active:r=!1,tabStopId:o,children:s,...a}=n,c=x8(),l=o||c,u=BMn(ent,t),d=u.currentTabStopId===l,h=Ztt(t),{onFocusableItemAdd:p,onFocusableItemRemove:m,currentTabStopId:_}=u;return fe.useEffect(()=>{if(i)return p(),()=>m()},[i,p,m]),ce.jsx(mge.ItemSlot,{scope:t,id:l,focusable:i,active:r,children:ce.jsx(Nv.span,{tabIndex:d?0:-1,"data-orientation":u.orientation,...a,ref:e,onMouseDown:gd(n.onMouseDown,g=>{i?u.onItemFocus(l):g.preventDefault()}),onFocus:gd(n.onFocus,()=>u.onItemFocus(l)),onKeyDown:gd(n.onKeyDown,g=>{if(g.key==="Tab"&&g.shiftKey){u.onItemShiftTab();return}if(g.target!==g.currentTarget)return;const x=GMn(g,u.orientation,u.dir);if(x!==void 0){if(g.metaKey||g.ctrlKey||g.altKey||g.shiftKey)return;g.preventDefault();let w=h().filter(E=>E.focusable).map(E=>E.ref.current);if(x==="last")w.reverse();else if(x==="prev"||x==="next"){x==="prev"&&w.reverse();const E=w.indexOf(g.currentTarget);w=u.loop?YMn(w,E+1):w.slice(E+1)}setTimeout(()=>nnt(w))}}),children:typeof s=="function"?s({isCurrentTabStop:d,hasTabStop:_!=null}):s})})});tnt.displayName=ent;var HMn={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function VMn(n,e){return e!=="rtl"?n:n==="ArrowLeft"?"ArrowRight":n==="ArrowRight"?"ArrowLeft":n}function GMn(n,e,t){const i=VMn(n.key,t);if(!(e==="vertical"&&["ArrowLeft","ArrowRight"].includes(i))&&!(e==="horizontal"&&["ArrowUp","ArrowDown"].includes(i)))return HMn[i]}function nnt(n,e=!1){const t=document.activeElement;for(const i of n)if(i===t||(i.focus({preventScroll:e}),document.activeElement!==t))return}function YMn(n,e){return n.map((t,i)=>n[(e+i)%n.length])}var qMn=Jtt,XMn=tnt,WMn=function(n){if(typeof document>"u")return null;var e=Array.isArray(n)?n[0]:n;return e.ownerDocument.body},yI=new WeakMap,LV=new WeakMap,DV={},_ge=0,int=function(n){return n&&(n.host||int(n.parentNode))},KMn=function(n,e){return e.map(function(t){if(n.contains(t))return t;var i=int(t);return i&&n.contains(i)?i:(console.error("aria-hidden",t,"in not contained inside",n,". Doing nothing"),null)}).filter(function(t){return!!t})},ZMn=function(n,e,t,i){var r=KMn(e,Array.isArray(n)?n:[n]);DV[t]||(DV[t]=new WeakMap);var o=DV[t],s=[],a=new Set,c=new Set(r),l=function(d){!d||a.has(d)||(a.add(d),l(d.parentNode))};r.forEach(l);var u=function(d){!d||c.has(d)||Array.prototype.forEach.call(d.children,function(h){if(a.has(h))u(h);else try{var p=h.getAttribute(i),m=p!==null&&p!=="false",_=(yI.get(h)||0)+1,g=(o.get(h)||0)+1;yI.set(h,_),o.set(h,g),s.push(h),_===1&&m&&LV.set(h,!0),g===1&&h.setAttribute(t,"true"),m||h.setAttribute(i,"true")}catch(x){console.error("aria-hidden: cannot operate on ",h,x)}})};return u(e),a.clear(),_ge++,function(){s.forEach(function(d){var h=yI.get(d)-1,p=o.get(d)-1;yI.set(d,h),o.set(d,p),h||(LV.has(d)||d.removeAttribute(i),LV.delete(d)),p||d.removeAttribute(t)}),_ge--,_ge||(yI=new WeakMap,yI=new WeakMap,LV=new WeakMap,DV={})}},QMn=function(n,e,t){t===void 0&&(t="data-aria-hidden");var i=Array.from(Array.isArray(n)?n:[n]),r=WMn(n);return r?(i.push.apply(i,Array.from(r.querySelectorAll("[aria-live], script"))),ZMn(i,r,t,"aria-hidden")):function(){return null}},mT=function(){return mT=Object.assign||function(e){for(var t,i=1,r=arguments.length;i<r;i++){t=arguments[i];for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o])}return e},mT.apply(this,arguments)};function rnt(n,e){var t={};for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&e.indexOf(i)<0&&(t[i]=n[i]);if(n!=null&&typeof Object.getOwnPropertySymbols=="function")for(var r=0,i=Object.getOwnPropertySymbols(n);r<i.length;r++)e.indexOf(i[r])<0&&Object.prototype.propertyIsEnumerable.call(n,i[r])&&(t[i[r]]=n[i[r]]);return t}function JMn(n,e,t){for(var i=0,r=e.length,o;i<r;i++)(o||!(i in e))&&(o||(o=Array.prototype.slice.call(e,0,i)),o[i]=e[i]);return n.concat(o||Array.prototype.slice.call(e))}var zV="right-scroll-bar-position",$V="width-before-scroll-bar",eCn="with-scroll-bars-hidden",tCn="--removed-body-scroll-bar-size";function yge(n,e){return typeof n=="function"?n(e):n&&(n.current=e),n}function nCn(n,e){var t=fe.useState(function(){return{value:n,callback:e,facade:{get current(){return t.value},set current(i){var r=t.value;r!==i&&(t.value=i,t.callback(i,r))}}}})[0];return t.callback=e,t.facade}var iCn=typeof window<"u"?fe.useLayoutEffect:fe.useEffect,ont=new WeakMap;function rCn(n,e){var t=nCn(null,function(i){return n.forEach(function(r){return yge(r,i)})});return iCn(function(){var i=ont.get(t);if(i){var r=new Set(i),o=new Set(n),s=t.current;r.forEach(function(a){o.has(a)||yge(a,null)}),o.forEach(function(a){r.has(a)||yge(a,s)})}ont.set(t,n)},[n]),t}function oCn(n){return n}function sCn(n,e){e===void 0&&(e=oCn);var t=[],i=!1,r={read:function(){if(i)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return t.length?t[t.length-1]:n},useMedium:function(o){var s=e(o,i);return t.push(s),function(){t=t.filter(function(a){return a!==s})}},assignSyncMedium:function(o){for(i=!0;t.length;){var s=t;t=[],s.forEach(o)}t={push:function(a){return o(a)},filter:function(){return t}}},assignMedium:function(o){i=!0;var s=[];if(t.length){var a=t;t=[],a.forEach(o),s=t}var c=function(){var u=s;s=[],u.forEach(o)},l=function(){return Promise.resolve().then(c)};l(),t={push:function(u){s.push(u),l()},filter:function(u){return s=s.filter(u),t}}}};return r}function aCn(n){n===void 0&&(n={});var e=sCn(null);return e.options=mT({async:!0,ssr:!1},n),e}var snt=function(n){var e=n.sideCar,t=rnt(n,["sideCar"]);if(!e)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var i=e.read();if(!i)throw new Error("Sidecar medium not found");return fe.createElement(i,mT({},t))};snt.isSideCarExport=!0;function cCn(n,e){return n.useMedium(e),snt}var ant=aCn(),gge=function(){},FV=fe.forwardRef(function(n,e){var t=fe.useRef(null),i=fe.useState({onScrollCapture:gge,onWheelCapture:gge,onTouchMoveCapture:gge}),r=i[0],o=i[1],s=n.forwardProps,a=n.children,c=n.className,l=n.removeScrollBar,u=n.enabled,d=n.shards,h=n.sideCar,p=n.noRelative,m=n.noIsolation,_=n.inert,g=n.allowPinchZoom,x=n.as,b=x===void 0?"div":x,w=n.gapMode,E=rnt(n,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),N=h,A=rCn([t,e]),I=mT(mT({},E),r);return fe.createElement(fe.Fragment,null,u&&fe.createElement(N,{sideCar:ant,removeScrollBar:l,shards:d,noRelative:p,noIsolation:m,inert:_,setCallbacks:o,allowPinchZoom:!!g,lockRef:t,gapMode:w}),s?fe.cloneElement(fe.Children.only(a),mT(mT({},I),{ref:A})):fe.createElement(b,mT({},I,{className:c,ref:A}),a))});FV.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},FV.classNames={fullWidth:$V,zeroRight:zV};var lCn=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function uCn(){if(!document)return null;var n=document.createElement("style");n.type="text/css";var e=lCn();return e&&n.setAttribute("nonce",e),n}function dCn(n,e){n.styleSheet?n.styleSheet.cssText=e:n.appendChild(document.createTextNode(e))}function hCn(n){var e=document.head||document.getElementsByTagName("head")[0];e.appendChild(n)}var pCn=function(){var n=0,e=null;return{add:function(t){n==0&&(e=uCn())&&(dCn(e,t),hCn(e)),n++},remove:function(){n--,!n&&e&&(e.parentNode&&e.parentNode.removeChild(e),e=null)}}},fCn=function(){var n=pCn();return function(e,t){fe.useEffect(function(){return n.add(e),function(){n.remove()}},[e&&t])}},cnt=function(){var n=fCn(),e=function(t){var i=t.styles,r=t.dynamic;return n(i,r),null};return e},mCn={left:0,top:0,right:0,gap:0},xge=function(n){return parseInt(n||"",10)||0},_Cn=function(n){var e=window.getComputedStyle(document.body),t=e[n==="padding"?"paddingLeft":"marginLeft"],i=e[n==="padding"?"paddingTop":"marginTop"],r=e[n==="padding"?"paddingRight":"marginRight"];return[xge(t),xge(i),xge(r)]},yCn=function(n){if(n===void 0&&(n="margin"),typeof window>"u")return mCn;var e=_Cn(n),t=document.documentElement.clientWidth,i=window.innerWidth;return{left:e[0],top:e[1],right:e[2],gap:Math.max(0,i-t+e[2]-e[0])}},gCn=cnt(),gI="data-scroll-locked",xCn=function(n,e,t,i){var r=n.left,o=n.top,s=n.right,a=n.gap;return t===void 0&&(t="margin"),`
5132
5132
  .`.concat(eCn,` {
5133
5133
  overflow: hidden `).concat(i,`;
5134
5134
  padding-right: `).concat(a,"px ").concat(i,`;
@@ -5810,7 +5810,7 @@ $1`).replace(/>(\s*)(?=<!--\s*\/)/g,"> ")}}});function Idt(n,e,t){if(!e||!t)retu
5810
5810
  * Copyright (c) 2013-2015, 2017, Jon Schlinkert.
5811
5811
  * Released under the MIT License.
5812
5812
  *)
5813
- */const YFn=({containerClassName:n,...e})=>{const t=fe.useRef(null),[i,r]=fe.useState(620);return fe.useLayoutEffect(()=>{const o=()=>{if(t.current){const a=t.current.clientHeight,c=window.innerHeight;r(Math.min(Math.max(a,620),c))}};o();const s=new ResizeObserver(o);return t.current&&s.observe(t.current),window.addEventListener("resize",o),()=>{s.disconnect(),window.removeEventListener("resize",o)}},[]),ce.jsx("div",{ref:t,className:n||"rf-w-full rf-h-full",children:ce.jsx(GFn,{...e,height:i})})},qFn='*,:after,:before{--tw-border-spacing-x:0;--tw-border-spacing-y:0;--tw-translate-x:0;--tw-translate-y:0;--tw-rotate:0;--tw-skew-x:0;--tw-skew-y:0;--tw-scale-x:1;--tw-scale-y:1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness:proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:rgba(59,130,246,.5);--tw-ring-offset-shadow:0 0 #0000;--tw-ring-shadow:0 0 #0000;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }::backdrop{--tw-border-spacing-x:0;--tw-border-spacing-y:0;--tw-translate-x:0;--tw-translate-y:0;--tw-rotate:0;--tw-skew-x:0;--tw-skew-y:0;--tw-scale-x:1;--tw-scale-y:1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness:proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:rgba(59,130,246,.5);--tw-ring-offset-shadow:0 0 #0000;--tw-ring-shadow:0 0 #0000;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }/*! tailwindcss v3.4.18 | MIT License | https://tailwindcss.com*/*,:after,:before{border:0 solid #e5e7eb;box-sizing:border-box}:after,:before{--tw-content:""}:host,html{line-height:1.5;-webkit-text-size-adjust:100%;font-family:ui-sans-serif,system-ui,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;font-feature-settings:normal;font-variation-settings:normal;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-tap-highlight-color:transparent}body{line-height:inherit;margin:0}hr{border-top-width:1px;color:inherit;height:0}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,pre,samp{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace;font-feature-settings:normal;font-size:1em;font-variation-settings:normal}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}table{border-collapse:collapse;border-color:inherit;text-indent:0}button,input,optgroup,select,textarea{color:inherit;font-family:inherit;font-feature-settings:inherit;font-size:100%;font-variation-settings:inherit;font-weight:inherit;letter-spacing:inherit;line-height:inherit;margin:0;padding:0}button,select{text-transform:none}button,input:where([type=button]),input:where([type=reset]),input:where([type=submit]){-webkit-appearance:button;background-color:transparent;background-image:none}:-moz-focusring{outline:auto}:-moz-ui-invalid{box-shadow:none}progress{vertical-align:baseline}::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}summary{display:list-item}blockquote,dd,dl,figure,h1,h2,h3,h4,h5,h6,hr,p,pre{margin:0}fieldset{margin:0}fieldset,legend{padding:0}menu,ol,ul{list-style:none;margin:0;padding:0}dialog{padding:0}textarea{resize:vertical}input::-moz-placeholder,textarea::-moz-placeholder{color:#9ca3af;opacity:1}input::placeholder,textarea::placeholder{color:#9ca3af;opacity:1}[role=button],button{cursor:pointer}:disabled{cursor:default}audio,canvas,embed,iframe,img,object,svg,video{display:block;vertical-align:middle}img,video{height:auto;max-width:100%}[hidden]:where(:not([hidden=until-found])){display:none}:root{--radius:0.5rem}.rf-pointer-events-none{pointer-events:none}.rf-invisible{visibility:hidden}.rf-fixed{position:fixed}.rf-absolute{position:absolute}.rf-relative{position:relative}.rf-inset-0{inset:0}.-rf-left-2{left:-.5rem}.-rf-right-10{right:-2.5rem}.-rf-right-2{right:-.5rem}.-rf-right-4{right:-1rem}.-rf-right-6{right:-1.5rem}.-rf-right-7{right:-1.75rem}.-rf-right-8{right:-2rem}.-rf-right-9{right:-2.25rem}.rf-bottom-full{bottom:100%}.rf-left-0{left:0}.rf-left-1{left:.25rem}.rf-left-1\\/2{left:50%}.rf-left-2{left:.5rem}.rf-left-\\[50\\%\\]{left:50%}.rf-right-0{right:0}.rf-right-1{right:.25rem}.rf-right-4{right:1rem}.rf-right-\\[4px\\]{right:4px}.rf-top-0{top:0}.rf-top-1{top:.25rem}.rf-top-2{top:.5rem}.rf-top-2\\.5{top:.625rem}.rf-top-\\[50\\%\\]{top:50%}.rf-top-\\[6px\\]{top:6px}.\\!rf-z-\\[101\\]{z-index:101!important}.\\!rf-z-\\[200\\]{z-index:200!important}.rf-z-10{z-index:10}.rf-z-50{z-index:50}.rf-z-\\[100\\]{z-index:100}.rf-z-\\[101\\]{z-index:101}.rf-order-1{order:1}.rf-order-2{order:2}.rf-order-3{order:3}.rf-m-1{margin:.25rem}.rf-m-6{margin:1.5rem}.-rf-mx-1,.rf--mx-1{margin-left:-.25rem;margin-right:-.25rem}.rf-mx-1{margin-left:.25rem;margin-right:.25rem}.rf-mx-2{margin-left:.5rem;margin-right:.5rem}.rf-mx-4{margin-left:1rem;margin-right:1rem}.rf-mx-auto{margin-left:auto;margin-right:auto}.rf-my-1{margin-bottom:.25rem;margin-top:.25rem}.rf-my-12{margin-bottom:3rem;margin-top:3rem}.rf-my-4{margin-bottom:1rem;margin-top:1rem}.rf-my-auto{margin-bottom:auto;margin-top:auto}.rf-mb-1{margin-bottom:.25rem}.rf-mb-12{margin-bottom:3rem}.rf-mb-2{margin-bottom:.5rem}.rf-mb-3{margin-bottom:.75rem}.rf-mb-4{margin-bottom:1rem}.rf-mb-6{margin-bottom:1.5rem}.rf-mb-8{margin-bottom:2rem}.rf-ml-1{margin-left:.25rem}.rf-ml-2{margin-left:.5rem}.rf-ml-6{margin-left:1.5rem}.rf-ml-auto{margin-left:auto}.rf-mr-1{margin-right:.25rem}.rf-mr-2{margin-right:.5rem}.rf-mr-4{margin-right:1rem}.rf-mt-0{margin-top:0}.rf-mt-0\\.5{margin-top:.125rem}.rf-mt-1{margin-top:.25rem}.rf-mt-2{margin-top:.5rem}.rf-mt-3{margin-top:.75rem}.rf-mt-4{margin-top:1rem}.rf-mt-5{margin-top:1.25rem}.rf-mt-auto{margin-top:auto}.rf-block{display:block}.rf-inline-block{display:inline-block}.rf-inline{display:inline}.rf-flex{display:flex}.rf-inline-flex{display:inline-flex}.rf-grid{display:grid}.rf-hidden{display:none}.rf-aspect-square{aspect-ratio:1/1}.rf-aspect-video{aspect-ratio:16/9}.rf-size-14{height:3.5rem;width:3.5rem}.rf-size-4{height:1rem;width:1rem}.\\!rf-h-2{height:.5rem!important}.\\!rf-h-2\\.5{height:.625rem!important}.\\!rf-h-3{height:.75rem!important}.\\!rf-h-full{height:100%!important}.rf-h-1{height:.25rem}.rf-h-10{height:2.5rem}.rf-h-12{height:3rem}.rf-h-2{height:.5rem}.rf-h-2\\.5{height:.625rem}.rf-h-20{height:5rem}.rf-h-24{height:6rem}.rf-h-3{height:.75rem}.rf-h-3\\.5{height:.875rem}.rf-h-4{height:1rem}.rf-h-5{height:1.25rem}.rf-h-6{height:1.5rem}.rf-h-60{height:15rem}.rf-h-64{height:16rem}.rf-h-7{height:1.75rem}.rf-h-8{height:2rem}.rf-h-9{height:2.25rem}.rf-h-\\[400px\\]{height:400px}.rf-h-\\[calc\\(100vh-52px\\)\\]{height:calc(100vh - 52px)}.rf-h-\\[var\\(--radix-select-trigger-height\\)\\]{height:var(--radix-select-trigger-height)}.rf-h-auto{height:auto}.rf-h-fit{height:-moz-fit-content;height:fit-content}.rf-h-full{height:100%}.rf-h-px{height:1px}.rf-h-screen{height:100vh}.\\!rf-max-h-\\[40vh\\]{max-height:40vh!important}.rf-max-h-32{max-height:8rem}.rf-max-h-96{max-height:24rem}.rf-max-h-\\[200px\\]{max-height:200px}.rf-max-h-\\[300px\\]{max-height:300px}.rf-max-h-\\[70vh\\]{max-height:70vh}.rf-max-h-\\[90vh\\]{max-height:90vh}.rf-max-h-full{max-height:100%}.rf-min-h-0{min-height:0}.rf-min-h-\\[100px\\]{min-height:100px}.rf-min-h-\\[200px\\]{min-height:200px}.rf-min-h-\\[300px\\]{min-height:300px}.rf-min-h-\\[620px\\]{min-height:620px}.rf-min-h-\\[calc\\(100vh-240px\\)\\]{min-height:calc(100vh - 240px)}.\\!rf-w-2{width:.5rem!important}.\\!rf-w-2\\.5{width:.625rem!important}.rf-w-1{width:.25rem}.rf-w-1\\/2{width:50%}.rf-w-11{width:2.75rem}.rf-w-11\\/12{width:91.666667%}.rf-w-12{width:3rem}.rf-w-16{width:4rem}.rf-w-2{width:.5rem}.rf-w-2\\.5{width:.625rem}.rf-w-20{width:5rem}.rf-w-24{width:6rem}.rf-w-28{width:7rem}.rf-w-3{width:.75rem}.rf-w-3\\.5{width:.875rem}.rf-w-32{width:8rem}.rf-w-4{width:1rem}.rf-w-40{width:10rem}.rf-w-48{width:12rem}.rf-w-5{width:1.25rem}.rf-w-6{width:1.5rem}.rf-w-64{width:16rem}.rf-w-72{width:18rem}.rf-w-8{width:2rem}.rf-w-80{width:20rem}.rf-w-9{width:2.25rem}.rf-w-96{width:24rem}.rf-w-fit{width:-moz-fit-content;width:fit-content}.rf-w-full{width:100%}.rf-w-screen{width:100vw}.rf-min-w-0{min-width:0}.rf-min-w-10{min-width:2.5rem}.rf-min-w-16{min-width:4rem}.rf-min-w-32{min-width:8rem}.rf-min-w-80{min-width:20rem}.rf-min-w-96{min-width:24rem}.rf-min-w-\\[148px\\]{min-width:148px}.rf-min-w-\\[600px\\]{min-width:600px}.rf-min-w-\\[8rem\\]{min-width:8rem}.rf-min-w-\\[var\\(--radix-select-trigger-width\\)\\]{min-width:var(--radix-select-trigger-width)}.\\!rf-max-w-\\[660px\\]{max-width:660px!important}.rf-max-w-2xl{max-width:42rem}.rf-max-w-3xl{max-width:48rem}.rf-max-w-4xl{max-width:56rem}.rf-max-w-5xl{max-width:64rem}.rf-max-w-64{max-width:16rem}.rf-max-w-96{max-width:24rem}.rf-max-w-\\[1000px\\]{max-width:1000px}.rf-max-w-\\[150px\\]{max-width:150px}.rf-max-w-\\[200px\\]{max-width:200px}.rf-max-w-\\[40\\%\\]{max-width:40%}.rf-max-w-\\[600px\\]{max-width:600px}.rf-max-w-full{max-width:100%}.rf-max-w-lg{max-width:32rem}.rf-max-w-md{max-width:28rem}.rf-max-w-none{max-width:none}.rf-max-w-xl{max-width:36rem}.rf-max-w-xs{max-width:20rem}.rf-flex-1{flex:1 1 0%}.rf-flex-shrink-0,.rf-shrink-0{flex-shrink:0}.rf-flex-grow{flex-grow:1}.rf-table-auto{table-layout:auto}.rf-origin-\\[--radix-popover-content-transform-origin\\]{transform-origin:var(--radix-popover-content-transform-origin)}.-rf-translate-x-1{--tw-translate-x:-0.25rem}.-rf-translate-x-1,.-rf-translate-x-1\\/2{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.-rf-translate-x-1\\/2{--tw-translate-x:-50%}.-rf-translate-y-1{--tw-translate-y:-0.25rem}.-rf-translate-y-1,.rf--translate-x-1{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.rf--translate-x-1{--tw-translate-x:-0.25rem}.rf--translate-x-1\\/2{--tw-translate-x:-50%}.rf--translate-x-1\\/2,.rf--translate-y-1{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.rf--translate-y-1{--tw-translate-y:-0.25rem}.rf-translate-x-\\[-50\\%\\]{--tw-translate-x:-50%}.rf-translate-x-\\[-50\\%\\],.rf-translate-y-\\[-50\\%\\]{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.rf-translate-y-\\[-50\\%\\]{--tw-translate-y:-50%}.rf-rotate-90{--tw-rotate:90deg}.rf-rotate-90,.rf-transform{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}@keyframes rf-pulse{50%{opacity:.5}}.rf-animate-pulse{animation:rf-pulse 2s cubic-bezier(.4,0,.6,1) infinite}@keyframes rf-spin{to{transform:rotate(1turn)}}.rf-animate-spin{animation:rf-spin 1s linear infinite}.rf-cursor-default{cursor:default}.rf-cursor-not-allowed{cursor:not-allowed}.rf-cursor-pointer{cursor:pointer}.rf-select-none{-webkit-user-select:none;-moz-user-select:none;user-select:none}.rf-grid-cols-1{grid-template-columns:repeat(1,minmax(0,1fr))}.rf-grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.rf-grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.rf-flex-row{flex-direction:row}.rf-flex-col{flex-direction:column}.rf-flex-col-reverse{flex-direction:column-reverse}.rf-flex-wrap{flex-wrap:wrap}.rf-place-items-center{place-items:center}.rf-items-start{align-items:flex-start}.rf-items-end{align-items:flex-end}.rf-items-center{align-items:center}.rf-items-baseline{align-items:baseline}.rf-items-stretch{align-items:stretch}.rf-justify-end{justify-content:flex-end}.rf-justify-center{justify-content:center}.rf-justify-between{justify-content:space-between}.rf-gap-0{gap:0}.rf-gap-1{gap:.25rem}.rf-gap-2{gap:.5rem}.rf-gap-3{gap:.75rem}.rf-gap-4{gap:1rem}.rf-gap-5{gap:1.25rem}.rf-gap-6{gap:1.5rem}.rf-gap-8{gap:2rem}.rf-space-x-2>:not([hidden])~:not([hidden]){--tw-space-x-reverse:0;margin-left:calc(.5rem*(1 - var(--tw-space-x-reverse)));margin-right:calc(.5rem*var(--tw-space-x-reverse))}.rf-space-y-1>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-bottom:calc(.25rem*var(--tw-space-y-reverse));margin-top:calc(.25rem*(1 - var(--tw-space-y-reverse)))}.rf-space-y-2>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-bottom:calc(.5rem*var(--tw-space-y-reverse));margin-top:calc(.5rem*(1 - var(--tw-space-y-reverse)))}.rf-space-y-3>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-bottom:calc(.75rem*var(--tw-space-y-reverse));margin-top:calc(.75rem*(1 - var(--tw-space-y-reverse)))}.rf-space-y-4>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-bottom:calc(1rem*var(--tw-space-y-reverse));margin-top:calc(1rem*(1 - var(--tw-space-y-reverse)))}.rf-space-y-6>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-bottom:calc(1.5rem*var(--tw-space-y-reverse));margin-top:calc(1.5rem*(1 - var(--tw-space-y-reverse)))}.rf-divide-y>:not([hidden])~:not([hidden]){--tw-divide-y-reverse:0;border-bottom-width:calc(1px*var(--tw-divide-y-reverse));border-top-width:calc(1px*(1 - var(--tw-divide-y-reverse)))}.rf-overflow-auto{overflow:auto}.\\!rf-overflow-hidden{overflow:hidden!important}.rf-overflow-hidden{overflow:hidden}.rf-overflow-visible{overflow:visible}.rf-overflow-x-auto{overflow-x:auto}.\\!rf-overflow-y-auto{overflow-y:auto!important}.rf-overflow-y-auto{overflow-y:auto}.rf-overflow-x-hidden{overflow-x:hidden}.rf-overflow-x-clip{overflow-x:clip}.rf-truncate{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.rf-whitespace-normal{white-space:normal}.rf-whitespace-nowrap{white-space:nowrap}.rf-whitespace-pre-wrap{white-space:pre-wrap}.rf-break-words{overflow-wrap:break-word}.rf-break-all{word-break:break-all}.rf-rounded{border-radius:.25rem}.rf-rounded-2xl{border-radius:1rem}.rf-rounded-full{border-radius:9999px}.rf-rounded-lg{border-radius:var(--radius)}.rf-rounded-md{border-radius:calc(var(--radius) - 2px)}.rf-rounded-sm{border-radius:calc(var(--radius) - 4px)}.rf-rounded-xl{border-radius:.75rem}.rf-border{border-width:1px}.rf-border-2{border-width:2px}.rf-border-b{border-bottom-width:1px}.rf-border-l-2{border-left-width:2px}.rf-border-l-4{border-left-width:4px}.rf-border-t{border-top-width:1px}.rf-border-none{border-style:none}.rf-border-blue-200{--tw-border-opacity:1;border-color:rgb(191 219 254/var(--tw-border-opacity,1))}.rf-border-blue-300{--tw-border-opacity:1;border-color:rgb(147 197 253/var(--tw-border-opacity,1))}.rf-border-blue-400{--tw-border-opacity:1;border-color:rgb(96 165 250/var(--tw-border-opacity,1))}.rf-border-blue-500{--tw-border-opacity:1;border-color:rgb(59 130 246/var(--tw-border-opacity,1))}.rf-border-blue-600{--tw-border-opacity:1;border-color:rgb(37 99 235/var(--tw-border-opacity,1))}.rf-border-gray-200{--tw-border-opacity:1;border-color:rgb(229 231 235/var(--tw-border-opacity,1))}.rf-border-gray-300{--tw-border-opacity:1;border-color:rgb(209 213 219/var(--tw-border-opacity,1))}.rf-border-green-200{--tw-border-opacity:1;border-color:rgb(187 247 208/var(--tw-border-opacity,1))}.rf-border-green-400{--tw-border-opacity:1;border-color:rgb(74 222 128/var(--tw-border-opacity,1))}.rf-border-input{border-color:hsl(var(--input))}.rf-border-neutral-200{--tw-border-opacity:1;border-color:rgb(229 229 229/var(--tw-border-opacity,1))}.rf-border-orange-100{--tw-border-opacity:1;border-color:rgb(255 237 213/var(--tw-border-opacity,1))}.rf-border-orange-200{--tw-border-opacity:1;border-color:rgb(254 215 170/var(--tw-border-opacity,1))}.rf-border-orange-500{--tw-border-opacity:1;border-color:rgb(249 115 22/var(--tw-border-opacity,1))}.rf-border-primary{border-color:hsl(var(--primary))}.rf-border-red-100{--tw-border-opacity:1;border-color:rgb(254 226 226/var(--tw-border-opacity,1))}.rf-border-red-200{--tw-border-opacity:1;border-color:rgb(254 202 202/var(--tw-border-opacity,1))}.rf-border-red-400{--tw-border-opacity:1;border-color:rgb(248 113 113/var(--tw-border-opacity,1))}.rf-border-red-500{--tw-border-opacity:1;border-color:rgb(239 68 68/var(--tw-border-opacity,1))}.rf-border-red-600{--tw-border-opacity:1;border-color:rgb(220 38 38/var(--tw-border-opacity,1))}.rf-border-zinc-200{--tw-border-opacity:1;border-color:rgb(228 228 231/var(--tw-border-opacity,1))}.rf-border-zinc-900{--tw-border-opacity:1;border-color:rgb(24 24 27/var(--tw-border-opacity,1))}.rf-bg-amber-50{--tw-bg-opacity:1;background-color:rgb(255 251 235/var(--tw-bg-opacity,1))}.rf-bg-amber-50\\/30{background-color:rgba(255,251,235,.3)}.rf-bg-background{background-color:hsl(var(--background))}.rf-bg-black{--tw-bg-opacity:1;background-color:rgb(0 0 0/var(--tw-bg-opacity,1))}.rf-bg-black\\/80{background-color:rgba(0,0,0,.8)}.rf-bg-blue-100{--tw-bg-opacity:1;background-color:rgb(219 234 254/var(--tw-bg-opacity,1))}.rf-bg-blue-50{--tw-bg-opacity:1;background-color:rgb(239 246 255/var(--tw-bg-opacity,1))}.rf-bg-blue-50\\/30{background-color:rgba(239,246,255,.3)}.rf-bg-blue-500{--tw-bg-opacity:1;background-color:rgb(59 130 246/var(--tw-bg-opacity,1))}.rf-bg-blue-600{--tw-bg-opacity:1;background-color:rgb(37 99 235/var(--tw-bg-opacity,1))}.rf-bg-gray-100{--tw-bg-opacity:1;background-color:rgb(243 244 246/var(--tw-bg-opacity,1))}.rf-bg-gray-200{--tw-bg-opacity:1;background-color:rgb(229 231 235/var(--tw-bg-opacity,1))}.rf-bg-gray-300{--tw-bg-opacity:1;background-color:rgb(209 213 219/var(--tw-bg-opacity,1))}.rf-bg-gray-400{--tw-bg-opacity:1;background-color:rgb(156 163 175/var(--tw-bg-opacity,1))}.rf-bg-gray-50{--tw-bg-opacity:1;background-color:rgb(249 250 251/var(--tw-bg-opacity,1))}.rf-bg-gray-500{--tw-bg-opacity:1;background-color:rgb(107 114 128/var(--tw-bg-opacity,1))}.rf-bg-gray-700{--tw-bg-opacity:1;background-color:rgb(55 65 81/var(--tw-bg-opacity,1))}.rf-bg-gray-800{--tw-bg-opacity:1;background-color:rgb(31 41 55/var(--tw-bg-opacity,1))}.rf-bg-gray-900{--tw-bg-opacity:1;background-color:rgb(17 24 39/var(--tw-bg-opacity,1))}.rf-bg-green-100{--tw-bg-opacity:1;background-color:rgb(220 252 231/var(--tw-bg-opacity,1))}.rf-bg-green-50{--tw-bg-opacity:1;background-color:rgb(240 253 244/var(--tw-bg-opacity,1))}.rf-bg-muted{background-color:hsl(var(--muted))}.rf-bg-neutral-100{--tw-bg-opacity:1;background-color:rgb(245 245 245/var(--tw-bg-opacity,1))}.rf-bg-neutral-50{--tw-bg-opacity:1;background-color:rgb(250 250 250/var(--tw-bg-opacity,1))}.rf-bg-neutral-800{--tw-bg-opacity:1;background-color:rgb(38 38 38/var(--tw-bg-opacity,1))}.rf-bg-neutral-900{--tw-bg-opacity:1;background-color:rgb(23 23 23/var(--tw-bg-opacity,1))}.rf-bg-orange-400{--tw-bg-opacity:1;background-color:rgb(251 146 60/var(--tw-bg-opacity,1))}.rf-bg-orange-50{--tw-bg-opacity:1;background-color:rgb(255 247 237/var(--tw-bg-opacity,1))}.rf-bg-orange-50\\/50{background-color:rgba(255,247,237,.5)}.rf-bg-orange-500{--tw-bg-opacity:1;background-color:rgb(249 115 22/var(--tw-bg-opacity,1))}.rf-bg-popover{background-color:hsl(var(--popover))}.rf-bg-red-100{--tw-bg-opacity:1;background-color:rgb(254 226 226/var(--tw-bg-opacity,1))}.rf-bg-red-50{--tw-bg-opacity:1;background-color:rgb(254 242 242/var(--tw-bg-opacity,1))}.rf-bg-red-50\\/50{background-color:hsla(0,86%,97%,.5)}.rf-bg-red-500{--tw-bg-opacity:1;background-color:rgb(239 68 68/var(--tw-bg-opacity,1))}.rf-bg-red-600{--tw-bg-opacity:1;background-color:rgb(220 38 38/var(--tw-bg-opacity,1))}.rf-bg-red-900{--tw-bg-opacity:1;background-color:rgb(127 29 29/var(--tw-bg-opacity,1))}.rf-bg-slate-50{--tw-bg-opacity:1;background-color:rgb(248 250 252/var(--tw-bg-opacity,1))}.rf-bg-transparent{background-color:transparent}.rf-bg-white{--tw-bg-opacity:1;background-color:rgb(255 255 255/var(--tw-bg-opacity,1))}.rf-bg-yellow-100{--tw-bg-opacity:1;background-color:rgb(254 249 195/var(--tw-bg-opacity,1))}.rf-bg-zinc-100{--tw-bg-opacity:1;background-color:rgb(244 244 245/var(--tw-bg-opacity,1))}.rf-bg-zinc-200{--tw-bg-opacity:1;background-color:rgb(228 228 231/var(--tw-bg-opacity,1))}.rf-bg-zinc-50{--tw-bg-opacity:1;background-color:rgb(250 250 250/var(--tw-bg-opacity,1))}.rf-bg-zinc-800{--tw-bg-opacity:1;background-color:rgb(39 39 42/var(--tw-bg-opacity,1))}.rf-bg-zinc-900{--tw-bg-opacity:1;background-color:rgb(24 24 27/var(--tw-bg-opacity,1))}.rf-bg-opacity-50{--tw-bg-opacity:0.5}.rf-fill-amber-500{fill:#f59e0b}.rf-fill-current{fill:currentColor}.rf-object-contain{-o-object-fit:contain;object-fit:contain}.rf-object-cover{-o-object-fit:cover;object-fit:cover}.\\!rf-p-0{padding:0!important}.rf-p-0{padding:0}.rf-p-1{padding:.25rem}.rf-p-2{padding:.5rem}.rf-p-3{padding:.75rem}.rf-p-4{padding:1rem}.rf-p-5{padding:1.25rem}.rf-p-6{padding:1.5rem}.rf-p-8{padding:2rem}.rf-px-1{padding-left:.25rem;padding-right:.25rem}.rf-px-2{padding-left:.5rem;padding-right:.5rem}.rf-px-3{padding-left:.75rem;padding-right:.75rem}.rf-px-4{padding-left:1rem;padding-right:1rem}.rf-px-6{padding-left:1.5rem;padding-right:1.5rem}.rf-px-8{padding-left:2rem;padding-right:2rem}.rf-py-0{padding-bottom:0;padding-top:0}.rf-py-0\\.5{padding-bottom:.125rem;padding-top:.125rem}.rf-py-1{padding-bottom:.25rem;padding-top:.25rem}.rf-py-1\\.5{padding-bottom:.375rem;padding-top:.375rem}.rf-py-10{padding-bottom:2.5rem;padding-top:2.5rem}.rf-py-12{padding-bottom:3rem;padding-top:3rem}.rf-py-2{padding-bottom:.5rem;padding-top:.5rem}.rf-py-3{padding-bottom:.75rem;padding-top:.75rem}.rf-py-4{padding-bottom:1rem;padding-top:1rem}.rf-py-6{padding-bottom:1.5rem;padding-top:1.5rem}.rf-py-8{padding-bottom:2rem;padding-top:2rem}.rf-pb-0{padding-bottom:0}.rf-pb-1{padding-bottom:.25rem}.rf-pb-2{padding-bottom:.5rem}.rf-pb-3{padding-bottom:.75rem}.rf-pb-4{padding-bottom:1rem}.rf-pb-px{padding-bottom:1px}.rf-pl-10{padding-left:2.5rem}.rf-pl-11{padding-left:2.75rem}.rf-pl-12{padding-left:3rem}.rf-pl-2{padding-left:.5rem}.rf-pl-4{padding-left:1rem}.rf-pl-8{padding-left:2rem}.rf-pr-2{padding-right:.5rem}.rf-pt-0{padding-top:0}.rf-pt-1{padding-top:.25rem}.rf-pt-2{padding-top:.5rem}.rf-pt-4{padding-top:1rem}.rf-text-left{text-align:left}.rf-text-center{text-align:center}.rf-text-right{text-align:right}.rf-font-mono{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace}.rf-text-2xl{font-size:1.5rem;line-height:2rem}.rf-text-3xl{font-size:1.875rem;line-height:2.25rem}.rf-text-\\[8px\\]{font-size:8px}.rf-text-base{font-size:1rem;line-height:1.5rem}.rf-text-lg{font-size:1.125rem;line-height:1.75rem}.rf-text-sm{font-size:.875rem;line-height:1.25rem}.rf-text-xl{font-size:1.25rem;line-height:1.75rem}.rf-text-xs{font-size:.75rem;line-height:1rem}.\\!rf-font-normal{font-weight:400!important}.rf-font-bold{font-weight:700}.rf-font-medium{font-weight:500}.rf-font-semibold{font-weight:600}.rf-uppercase{text-transform:uppercase}.rf-capitalize{text-transform:capitalize}.rf-tabular-nums{--tw-numeric-spacing:tabular-nums;font-variant-numeric:var(--tw-ordinal) var(--tw-slashed-zero) var(--tw-numeric-figure) var(--tw-numeric-spacing) var(--tw-numeric-fraction)}.rf-leading-5{line-height:1.25rem}.rf-leading-\\[0\\.95rem\\]{line-height:.95rem}.rf-leading-\\[1rem\\]{line-height:1rem}.rf-leading-none{line-height:1}.rf-leading-relaxed{line-height:1.625}.rf-leading-tight{line-height:1.25}.rf-tracking-wide{letter-spacing:.025em}.rf-tracking-widest{letter-spacing:.1em}.rf-text-amber-500{--tw-text-opacity:1;color:rgb(245 158 11/var(--tw-text-opacity,1))}.rf-text-black{--tw-text-opacity:1;color:rgb(0 0 0/var(--tw-text-opacity,1))}.rf-text-blue-500{--tw-text-opacity:1;color:rgb(59 130 246/var(--tw-text-opacity,1))}.rf-text-blue-600{--tw-text-opacity:1;color:rgb(37 99 235/var(--tw-text-opacity,1))}.rf-text-blue-700{--tw-text-opacity:1;color:rgb(29 78 216/var(--tw-text-opacity,1))}.rf-text-blue-800{--tw-text-opacity:1;color:rgb(30 64 175/var(--tw-text-opacity,1))}.rf-text-blue-900{--tw-text-opacity:1;color:rgb(30 58 138/var(--tw-text-opacity,1))}.rf-text-current{color:currentColor}.rf-text-gray-300{--tw-text-opacity:1;color:rgb(209 213 219/var(--tw-text-opacity,1))}.rf-text-gray-400{--tw-text-opacity:1;color:rgb(156 163 175/var(--tw-text-opacity,1))}.rf-text-gray-500{--tw-text-opacity:1;color:rgb(107 114 128/var(--tw-text-opacity,1))}.rf-text-gray-600{--tw-text-opacity:1;color:rgb(75 85 99/var(--tw-text-opacity,1))}.rf-text-gray-700{--tw-text-opacity:1;color:rgb(55 65 81/var(--tw-text-opacity,1))}.rf-text-gray-800{--tw-text-opacity:1;color:rgb(31 41 55/var(--tw-text-opacity,1))}.rf-text-gray-900{--tw-text-opacity:1;color:rgb(17 24 39/var(--tw-text-opacity,1))}.rf-text-green-500{--tw-text-opacity:1;color:rgb(34 197 94/var(--tw-text-opacity,1))}.rf-text-green-600{--tw-text-opacity:1;color:rgb(22 163 74/var(--tw-text-opacity,1))}.rf-text-green-700{--tw-text-opacity:1;color:rgb(21 128 61/var(--tw-text-opacity,1))}.rf-text-green-800{--tw-text-opacity:1;color:rgb(22 101 52/var(--tw-text-opacity,1))}.rf-text-green-900{--tw-text-opacity:1;color:rgb(20 83 45/var(--tw-text-opacity,1))}.rf-text-muted-foreground{color:hsl(var(--muted-foreground))}.rf-text-neutral-50{--tw-text-opacity:1;color:rgb(250 250 250/var(--tw-text-opacity,1))}.rf-text-neutral-500{--tw-text-opacity:1;color:rgb(115 115 115/var(--tw-text-opacity,1))}.rf-text-neutral-900{--tw-text-opacity:1;color:rgb(23 23 23/var(--tw-text-opacity,1))}.rf-text-neutral-950{--tw-text-opacity:1;color:rgb(10 10 10/var(--tw-text-opacity,1))}.rf-text-orange-400{--tw-text-opacity:1;color:rgb(251 146 60/var(--tw-text-opacity,1))}.rf-text-orange-500{--tw-text-opacity:1;color:rgb(249 115 22/var(--tw-text-opacity,1))}.rf-text-orange-600{--tw-text-opacity:1;color:rgb(234 88 12/var(--tw-text-opacity,1))}.rf-text-orange-700{--tw-text-opacity:1;color:rgb(194 65 12/var(--tw-text-opacity,1))}.rf-text-orange-800{--tw-text-opacity:1;color:rgb(154 52 18/var(--tw-text-opacity,1))}.rf-text-popover-foreground{color:hsl(var(--popover-foreground))}.rf-text-red-200{--tw-text-opacity:1;color:rgb(254 202 202/var(--tw-text-opacity,1))}.rf-text-red-300{--tw-text-opacity:1;color:rgb(252 165 165/var(--tw-text-opacity,1))}.rf-text-red-400{--tw-text-opacity:1;color:rgb(248 113 113/var(--tw-text-opacity,1))}.rf-text-red-500{--tw-text-opacity:1;color:rgb(239 68 68/var(--tw-text-opacity,1))}.rf-text-red-600{--tw-text-opacity:1;color:rgb(220 38 38/var(--tw-text-opacity,1))}.rf-text-red-700{--tw-text-opacity:1;color:rgb(185 28 28/var(--tw-text-opacity,1))}.rf-text-red-800{--tw-text-opacity:1;color:rgb(153 27 27/var(--tw-text-opacity,1))}.rf-text-red-900{--tw-text-opacity:1;color:rgb(127 29 29/var(--tw-text-opacity,1))}.rf-text-slate-400{--tw-text-opacity:1;color:rgb(148 163 184/var(--tw-text-opacity,1))}.rf-text-slate-500{--tw-text-opacity:1;color:rgb(100 116 139/var(--tw-text-opacity,1))}.rf-text-slate-600{--tw-text-opacity:1;color:rgb(71 85 105/var(--tw-text-opacity,1))}.rf-text-slate-800{--tw-text-opacity:1;color:rgb(30 41 59/var(--tw-text-opacity,1))}.rf-text-white{--tw-text-opacity:1;color:rgb(255 255 255/var(--tw-text-opacity,1))}.rf-text-yellow-400{--tw-text-opacity:1;color:rgb(250 204 21/var(--tw-text-opacity,1))}.rf-text-yellow-500{--tw-text-opacity:1;color:rgb(234 179 8/var(--tw-text-opacity,1))}.rf-text-yellow-600{--tw-text-opacity:1;color:rgb(202 138 4/var(--tw-text-opacity,1))}.rf-text-yellow-900{--tw-text-opacity:1;color:rgb(113 63 18/var(--tw-text-opacity,1))}.rf-text-zinc-200{--tw-text-opacity:1;color:rgb(228 228 231/var(--tw-text-opacity,1))}.rf-text-zinc-300{--tw-text-opacity:1;color:rgb(212 212 216/var(--tw-text-opacity,1))}.rf-text-zinc-400{--tw-text-opacity:1;color:rgb(161 161 170/var(--tw-text-opacity,1))}.rf-text-zinc-50{--tw-text-opacity:1;color:rgb(250 250 250/var(--tw-text-opacity,1))}.rf-text-zinc-500{--tw-text-opacity:1;color:rgb(113 113 122/var(--tw-text-opacity,1))}.rf-text-zinc-900{--tw-text-opacity:1;color:rgb(24 24 27/var(--tw-text-opacity,1))}.rf-text-zinc-950{--tw-text-opacity:1;color:rgb(9 9 11/var(--tw-text-opacity,1))}.rf-underline{text-decoration-line:underline}.rf-line-through{text-decoration-line:line-through}.rf-underline-offset-4{text-underline-offset:4px}.rf-opacity-0{opacity:0}.rf-opacity-100{opacity:1}.rf-opacity-25{opacity:.25}.rf-opacity-30{opacity:.3}.rf-opacity-50{opacity:.5}.rf-opacity-60{opacity:.6}.rf-opacity-70{opacity:.7}.rf-opacity-75{opacity:.75}.rf-shadow{--tw-shadow:0 1px 3px 0 rgba(0,0,0,.1),0 1px 2px -1px rgba(0,0,0,.1);--tw-shadow-colored:0 1px 3px 0 var(--tw-shadow-color),0 1px 2px -1px var(--tw-shadow-color)}.rf-shadow,.rf-shadow-lg{box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}.rf-shadow-lg{--tw-shadow:0 10px 15px -3px rgba(0,0,0,.1),0 4px 6px -4px rgba(0,0,0,.1);--tw-shadow-colored:0 10px 15px -3px var(--tw-shadow-color),0 4px 6px -4px var(--tw-shadow-color)}.rf-shadow-md{--tw-shadow:0 4px 6px -1px rgba(0,0,0,.1),0 2px 4px -2px rgba(0,0,0,.1);--tw-shadow-colored:0 4px 6px -1px var(--tw-shadow-color),0 2px 4px -2px var(--tw-shadow-color)}.rf-shadow-md,.rf-shadow-sm{box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}.rf-shadow-sm{--tw-shadow:0 1px 2px 0 rgba(0,0,0,.05);--tw-shadow-colored:0 1px 2px 0 var(--tw-shadow-color)}.rf-outline-none{outline:2px solid transparent;outline-offset:2px}.rf-ring-2{--tw-ring-offset-shadow:var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow:var(--tw-ring-inset) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow,0 0 #0000)}.rf-ring-blue-500{--tw-ring-opacity:1;--tw-ring-color:rgb(59 130 246/var(--tw-ring-opacity,1))}.rf-ring-primary{--tw-ring-color:hsl(var(--primary))}.rf-ring-offset-background{--tw-ring-offset-color:hsl(var(--background))}.rf-ring-offset-white{--tw-ring-offset-color:#fff}.rf-transition{transition-duration:.15s;transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,backdrop-filter;transition-timing-function:cubic-bezier(.4,0,.2,1)}.rf-transition-all{transition-duration:.15s;transition-property:all;transition-timing-function:cubic-bezier(.4,0,.2,1)}.rf-transition-colors{transition-duration:.15s;transition-property:color,background-color,border-color,text-decoration-color,fill,stroke;transition-timing-function:cubic-bezier(.4,0,.2,1)}.rf-transition-opacity{transition-duration:.15s;transition-property:opacity;transition-timing-function:cubic-bezier(.4,0,.2,1)}.rf-transition-transform{transition-duration:.15s;transition-property:transform;transition-timing-function:cubic-bezier(.4,0,.2,1)}.rf-duration-200{transition-duration:.2s}.rf-ease-in-out{transition-timing-function:cubic-bezier(.4,0,.2,1)}@keyframes enter{0%{opacity:var(--tw-enter-opacity,1);transform:translate3d(var(--tw-enter-translate-x,0),var(--tw-enter-translate-y,0),0) scale3d(var(--tw-enter-scale,1),var(--tw-enter-scale,1),var(--tw-enter-scale,1)) rotate(var(--tw-enter-rotate,0))}}@keyframes exit{to{opacity:var(--tw-exit-opacity,1);transform:translate3d(var(--tw-exit-translate-x,0),var(--tw-exit-translate-y,0),0) scale3d(var(--tw-exit-scale,1),var(--tw-exit-scale,1),var(--tw-exit-scale,1)) rotate(var(--tw-exit-rotate,0))}}.rf-slide-in-from-left-1{--tw-enter-translate-x:-0.25rem}.rf-slide-out-to-left-1{--tw-exit-translate-x:-0.25rem}.rf-duration-200{animation-duration:.2s}.rf-ease-in-out{animation-timing-function:cubic-bezier(.4,0,.2,1)}.file\\:rf-border-0::file-selector-button{border-width:0}.file\\:rf-bg-transparent::file-selector-button{background-color:transparent}.file\\:rf-text-sm::file-selector-button{font-size:.875rem;line-height:1.25rem}.file\\:rf-font-medium::file-selector-button{font-weight:500}.placeholder\\:rf-text-zinc-500::-moz-placeholder{--tw-text-opacity:1;color:rgb(113 113 122/var(--tw-text-opacity,1))}.placeholder\\:rf-text-zinc-500::placeholder{--tw-text-opacity:1;color:rgb(113 113 122/var(--tw-text-opacity,1))}.hover\\:rf-border-blue-300:hover{--tw-border-opacity:1;border-color:rgb(147 197 253/var(--tw-border-opacity,1))}.hover\\:rf-border-blue-500:hover{--tw-border-opacity:1;border-color:rgb(59 130 246/var(--tw-border-opacity,1))}.hover\\:\\!rf-bg-transparent:hover{background-color:transparent!important}.hover\\:rf-bg-blue-700:hover{--tw-bg-opacity:1;background-color:rgb(29 78 216/var(--tw-bg-opacity,1))}.hover\\:rf-bg-orange-100:hover{--tw-bg-opacity:1;background-color:rgb(255 237 213/var(--tw-bg-opacity,1))}.hover\\:rf-bg-red-100:hover{--tw-bg-opacity:1;background-color:rgb(254 226 226/var(--tw-bg-opacity,1))}.hover\\:rf-bg-red-500\\/90:hover{background-color:rgba(239,68,68,.9)}.hover\\:rf-bg-slate-200:hover{--tw-bg-opacity:1;background-color:rgb(226 232 240/var(--tw-bg-opacity,1))}.hover\\:rf-bg-zinc-100:hover{--tw-bg-opacity:1;background-color:rgb(244 244 245/var(--tw-bg-opacity,1))}.hover\\:rf-bg-zinc-100\\/80:hover{background-color:hsla(240,5%,96%,.8)}.hover\\:rf-bg-zinc-900\\/90:hover{background-color:rgba(24,24,27,.9)}.hover\\:rf-text-blue-800:hover{--tw-text-opacity:1;color:rgb(30 64 175/var(--tw-text-opacity,1))}.hover\\:rf-text-red-400:hover{--tw-text-opacity:1;color:rgb(248 113 113/var(--tw-text-opacity,1))}.hover\\:rf-text-slate-800:hover{--tw-text-opacity:1;color:rgb(30 41 59/var(--tw-text-opacity,1))}.hover\\:rf-text-slate-900:hover{--tw-text-opacity:1;color:rgb(15 23 42/var(--tw-text-opacity,1))}.hover\\:rf-text-zinc-900:hover{--tw-text-opacity:1;color:rgb(24 24 27/var(--tw-text-opacity,1))}.hover\\:rf-underline:hover{text-decoration-line:underline}.focus\\:rf-bg-gray-100:focus{--tw-bg-opacity:1;background-color:rgb(243 244 246/var(--tw-bg-opacity,1))}.focus\\:rf-bg-zinc-100:focus{--tw-bg-opacity:1;background-color:rgb(244 244 245/var(--tw-bg-opacity,1))}.focus\\:rf-text-gray-900:focus{--tw-text-opacity:1;color:rgb(17 24 39/var(--tw-text-opacity,1))}.focus\\:rf-text-zinc-900:focus{--tw-text-opacity:1;color:rgb(24 24 27/var(--tw-text-opacity,1))}.focus\\:rf-outline-none:focus{outline:2px solid transparent;outline-offset:2px}.focus\\:rf-ring-2:focus{--tw-ring-offset-shadow:var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow:var(--tw-ring-inset) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow,0 0 #0000)}.focus\\:rf-ring-blue-500:focus{--tw-ring-opacity:1;--tw-ring-color:rgb(59 130 246/var(--tw-ring-opacity,1))}.focus\\:rf-ring-ring:focus{--tw-ring-color:hsl(var(--ring))}.focus\\:rf-ring-offset-2:focus{--tw-ring-offset-width:2px}.focus-visible\\:rf-outline-none:focus-visible{outline:2px solid transparent;outline-offset:2px}.focus-visible\\:rf-ring-1:focus-visible{--tw-ring-offset-shadow:var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow:var(--tw-ring-inset) 0 0 0 calc(1px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow,0 0 #0000)}.focus-visible\\:rf-ring-2:focus-visible{--tw-ring-offset-shadow:var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow:var(--tw-ring-inset) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow,0 0 #0000)}.focus-visible\\:rf-ring-zinc-950:focus-visible{--tw-ring-opacity:1;--tw-ring-color:rgb(9 9 11/var(--tw-ring-opacity,1))}.focus-visible\\:rf-ring-offset-2:focus-visible{--tw-ring-offset-width:2px}.disabled\\:rf-pointer-events-none:disabled{pointer-events:none}.disabled\\:rf-cursor-not-allowed:disabled{cursor:not-allowed}.disabled\\:rf-opacity-50:disabled{opacity:.5}.rf-group:hover .group-hover\\:rf-opacity-100,.rf-group\\/bar:hover .group-hover\\/bar\\:rf-opacity-100{opacity:1}.data-\\[disabled\\=true\\]\\:rf-pointer-events-none[data-disabled=true],.data-\\[disabled\\]\\:rf-pointer-events-none[data-disabled]{pointer-events:none}.data-\\[side\\=bottom\\]\\:rf-translate-y-1[data-side=bottom]{--tw-translate-y:0.25rem}.data-\\[side\\=bottom\\]\\:rf-translate-y-1[data-side=bottom],.data-\\[side\\=left\\]\\:-rf-translate-x-1[data-side=left]{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.data-\\[side\\=left\\]\\:-rf-translate-x-1[data-side=left]{--tw-translate-x:-0.25rem}.data-\\[side\\=right\\]\\:rf-translate-x-1[data-side=right]{--tw-translate-x:0.25rem}.data-\\[side\\=right\\]\\:rf-translate-x-1[data-side=right],.data-\\[side\\=top\\]\\:-rf-translate-y-1[data-side=top]{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.data-\\[side\\=top\\]\\:-rf-translate-y-1[data-side=top]{--tw-translate-y:-0.25rem}.data-\\[selected\\=true\\]\\:rf-bg-zinc-100[data-selected=true]{--tw-bg-opacity:1;background-color:rgb(244 244 245/var(--tw-bg-opacity,1))}.data-\\[state\\=active\\]\\:rf-bg-white[data-state=active]{--tw-bg-opacity:1;background-color:rgb(255 255 255/var(--tw-bg-opacity,1))}.data-\\[state\\=checked\\]\\:rf-bg-zinc-900[data-state=checked]{--tw-bg-opacity:1;background-color:rgb(24 24 27/var(--tw-bg-opacity,1))}.data-\\[state\\=open\\]\\:rf-bg-zinc-100[data-state=open]{--tw-bg-opacity:1;background-color:rgb(244 244 245/var(--tw-bg-opacity,1))}.data-\\[selected\\=true\\]\\:rf-text-zinc-900[data-selected=true]{--tw-text-opacity:1;color:rgb(24 24 27/var(--tw-text-opacity,1))}.data-\\[state\\=active\\]\\:rf-text-zinc-950[data-state=active]{--tw-text-opacity:1;color:rgb(9 9 11/var(--tw-text-opacity,1))}.data-\\[state\\=checked\\]\\:rf-text-zinc-50[data-state=checked]{--tw-text-opacity:1;color:rgb(250 250 250/var(--tw-text-opacity,1))}.data-\\[disabled\\=true\\]\\:rf-opacity-50[data-disabled=true],.data-\\[disabled\\]\\:rf-opacity-50[data-disabled]{opacity:.5}.data-\\[state\\=active\\]\\:rf-shadow[data-state=active]{--tw-shadow:0 1px 3px 0 rgba(0,0,0,.1),0 1px 2px -1px rgba(0,0,0,.1);--tw-shadow-colored:0 1px 3px 0 var(--tw-shadow-color),0 1px 2px -1px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}.data-\\[state\\=open\\]\\:rf-animate-in[data-state=open]{animation-duration:.15s;animation-name:enter;--tw-enter-opacity:initial;--tw-enter-scale:initial;--tw-enter-rotate:initial;--tw-enter-translate-x:initial;--tw-enter-translate-y:initial}.data-\\[state\\=closed\\]\\:rf-animate-out[data-state=closed]{animation-duration:.15s;animation-name:exit;--tw-exit-opacity:initial;--tw-exit-scale:initial;--tw-exit-rotate:initial;--tw-exit-translate-x:initial;--tw-exit-translate-y:initial}.data-\\[state\\=closed\\]\\:rf-fade-out-0[data-state=closed]{--tw-exit-opacity:0}.data-\\[state\\=open\\]\\:rf-fade-in-0[data-state=open]{--tw-enter-opacity:0}.data-\\[state\\=closed\\]\\:rf-zoom-out-95[data-state=closed]{--tw-exit-scale:.95}.data-\\[state\\=open\\]\\:rf-zoom-in-95[data-state=open]{--tw-enter-scale:.95}.data-\\[side\\=bottom\\]\\:rf-slide-in-from-top-2[data-side=bottom]{--tw-enter-translate-y:-0.5rem}.data-\\[side\\=left\\]\\:rf-slide-in-from-right-2[data-side=left]{--tw-enter-translate-x:0.5rem}.data-\\[side\\=right\\]\\:rf-slide-in-from-left-2[data-side=right]{--tw-enter-translate-x:-0.5rem}.data-\\[side\\=top\\]\\:rf-slide-in-from-bottom-2[data-side=top]{--tw-enter-translate-y:0.5rem}.data-\\[state\\=closed\\]\\:rf-slide-out-to-left-1\\/2[data-state=closed]{--tw-exit-translate-x:-50%}.data-\\[state\\=closed\\]\\:rf-slide-out-to-top-\\[48\\%\\][data-state=closed]{--tw-exit-translate-y:-48%}.data-\\[state\\=open\\]\\:rf-slide-in-from-left-1\\/2[data-state=open]{--tw-enter-translate-x:-50%}.data-\\[state\\=open\\]\\:rf-slide-in-from-top-\\[48\\%\\][data-state=open]{--tw-enter-translate-y:-48%}.dark\\:rf-border-zinc-50:is(.rf-dark *){--tw-border-opacity:1;border-color:rgb(250 250 250/var(--tw-border-opacity,1))}.dark\\:rf-border-zinc-800:is(.rf-dark *){--tw-border-opacity:1;border-color:rgb(39 39 42/var(--tw-border-opacity,1))}.dark\\:rf-bg-gray-700:is(.rf-dark *){--tw-bg-opacity:1;background-color:rgb(55 65 81/var(--tw-bg-opacity,1))}.dark\\:rf-bg-gray-800:is(.rf-dark *){--tw-bg-opacity:1;background-color:rgb(31 41 55/var(--tw-bg-opacity,1))}.dark\\:rf-bg-red-900:is(.rf-dark *){--tw-bg-opacity:1;background-color:rgb(127 29 29/var(--tw-bg-opacity,1))}.dark\\:rf-bg-zinc-50:is(.rf-dark *){--tw-bg-opacity:1;background-color:rgb(250 250 250/var(--tw-bg-opacity,1))}.dark\\:rf-bg-zinc-800:is(.rf-dark *){--tw-bg-opacity:1;background-color:rgb(39 39 42/var(--tw-bg-opacity,1))}.dark\\:rf-bg-zinc-950:is(.rf-dark *){--tw-bg-opacity:1;background-color:rgb(9 9 11/var(--tw-bg-opacity,1))}.dark\\:rf-text-gray-500:is(.rf-dark *){--tw-text-opacity:1;color:rgb(107 114 128/var(--tw-text-opacity,1))}.dark\\:rf-text-zinc-400:is(.rf-dark *){--tw-text-opacity:1;color:rgb(161 161 170/var(--tw-text-opacity,1))}.dark\\:rf-text-zinc-50:is(.rf-dark *){--tw-text-opacity:1;color:rgb(250 250 250/var(--tw-text-opacity,1))}.dark\\:rf-text-zinc-900:is(.rf-dark *){--tw-text-opacity:1;color:rgb(24 24 27/var(--tw-text-opacity,1))}.dark\\:rf-placeholder-zinc-400:is(.rf-dark *)::-moz-placeholder{--tw-placeholder-opacity:1;color:rgb(161 161 170/var(--tw-placeholder-opacity,1))}.dark\\:rf-placeholder-zinc-400:is(.rf-dark *)::placeholder{--tw-placeholder-opacity:1;color:rgb(161 161 170/var(--tw-placeholder-opacity,1))}.dark\\:rf-ring-offset-zinc-950:is(.rf-dark *){--tw-ring-offset-color:#09090b}.dark\\:placeholder\\:rf-text-zinc-400:is(.rf-dark *)::-moz-placeholder{--tw-text-opacity:1;color:rgb(161 161 170/var(--tw-text-opacity,1))}.dark\\:placeholder\\:rf-text-zinc-400:is(.rf-dark *)::placeholder{--tw-text-opacity:1;color:rgb(161 161 170/var(--tw-text-opacity,1))}.dark\\:hover\\:rf-bg-red-900\\/90:hover:is(.rf-dark *){background-color:rgba(127,29,29,.9)}.dark\\:hover\\:rf-bg-zinc-50\\/90:hover:is(.rf-dark *){background-color:hsla(0,0%,98%,.9)}.dark\\:hover\\:rf-bg-zinc-800:hover:is(.rf-dark *){--tw-bg-opacity:1;background-color:rgb(39 39 42/var(--tw-bg-opacity,1))}.dark\\:hover\\:rf-bg-zinc-800\\/80:hover:is(.rf-dark *){background-color:rgba(39,39,42,.8)}.dark\\:hover\\:rf-text-zinc-50:hover:is(.rf-dark *){--tw-text-opacity:1;color:rgb(250 250 250/var(--tw-text-opacity,1))}.dark\\:focus\\:rf-bg-zinc-800:focus:is(.rf-dark *){--tw-bg-opacity:1;background-color:rgb(39 39 42/var(--tw-bg-opacity,1))}.dark\\:focus\\:rf-text-zinc-50:focus:is(.rf-dark *){--tw-text-opacity:1;color:rgb(250 250 250/var(--tw-text-opacity,1))}.dark\\:focus-visible\\:rf-ring-zinc-300:focus-visible:is(.rf-dark *){--tw-ring-opacity:1;--tw-ring-color:rgb(212 212 216/var(--tw-ring-opacity,1))}.dark\\:data-\\[selected\\=true\\]\\:rf-bg-zinc-800[data-selected=true]:is(.rf-dark *){--tw-bg-opacity:1;background-color:rgb(39 39 42/var(--tw-bg-opacity,1))}.dark\\:data-\\[state\\=active\\]\\:rf-bg-zinc-950[data-state=active]:is(.rf-dark *){--tw-bg-opacity:1;background-color:rgb(9 9 11/var(--tw-bg-opacity,1))}.dark\\:data-\\[state\\=checked\\]\\:rf-bg-zinc-50[data-state=checked]:is(.rf-dark *){--tw-bg-opacity:1;background-color:rgb(250 250 250/var(--tw-bg-opacity,1))}.dark\\:data-\\[state\\=open\\]\\:rf-bg-zinc-800[data-state=open]:is(.rf-dark *){--tw-bg-opacity:1;background-color:rgb(39 39 42/var(--tw-bg-opacity,1))}.dark\\:data-\\[selected\\=true\\]\\:rf-text-zinc-50[data-selected=true]:is(.rf-dark *){--tw-text-opacity:1;color:rgb(250 250 250/var(--tw-text-opacity,1))}.dark\\:data-\\[state\\=active\\]\\:rf-text-zinc-50[data-state=active]:is(.rf-dark *){--tw-text-opacity:1;color:rgb(250 250 250/var(--tw-text-opacity,1))}.dark\\:data-\\[state\\=checked\\]\\:rf-text-zinc-900[data-state=checked]:is(.rf-dark *){--tw-text-opacity:1;color:rgb(24 24 27/var(--tw-text-opacity,1))}@media (min-width:640px){.sm\\:rf-order-1{order:1}.sm\\:rf-order-2{order:2}.sm\\:rf-mt-0{margin-top:0}.sm\\:rf-block{display:block}.sm\\:rf-inline{display:inline}.sm\\:rf-grid{display:grid}.sm\\:rf-hidden{display:none}.sm\\:rf-w-auto{width:auto}.sm\\:rf-grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.sm\\:rf-grid-cols-\\[1fr_auto\\]{grid-template-columns:1fr auto}.sm\\:rf-flex-row{flex-direction:row}.sm\\:rf-items-center{align-items:center}.sm\\:rf-justify-end{justify-content:flex-end}.sm\\:rf-gap-3{gap:.75rem}.sm\\:rf-space-x-2>:not([hidden])~:not([hidden]){--tw-space-x-reverse:0;margin-left:calc(.5rem*(1 - var(--tw-space-x-reverse)));margin-right:calc(.5rem*var(--tw-space-x-reverse))}.sm\\:rf-justify-self-end{justify-self:end}.sm\\:rf-rounded-lg{border-radius:var(--radius)}.sm\\:rf-px-4{padding-left:1rem;padding-right:1rem}.sm\\:rf-text-left{text-align:left}.sm\\:rf-text-right{text-align:right}.sm\\:rf-text-sm{font-size:.875rem;line-height:1.25rem}.sm\\:rf-text-xl{font-size:1.25rem;line-height:1.75rem}}@media (min-width:768px){.md\\:rf-grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}}.\\[\\&\\>span\\]\\:rf-line-clamp-1>span{display:-webkit-box;overflow:hidden;-webkit-box-orient:vertical;-webkit-line-clamp:1}.\\[\\&\\>svg\\]\\:rf-size-4>svg{height:1rem;width:1rem}.\\[\\&\\>svg\\]\\:rf-shrink-0>svg{flex-shrink:0}.\\[\\&\\>svg\\]\\:rf-text-red-300>svg{--tw-text-opacity:1;color:rgb(252 165 165/var(--tw-text-opacity,1))}.\\[\\&\\>svg\\]\\:hover\\:rf-text-red-400:hover>svg{--tw-text-opacity:1;color:rgb(248 113 113/var(--tw-text-opacity,1))}.\\[\\&_\\[cmdk-group-heading\\]\\]\\:rf-px-2 [cmdk-group-heading]{padding-left:.5rem;padding-right:.5rem}.\\[\\&_\\[cmdk-group-heading\\]\\]\\:rf-py-1\\.5 [cmdk-group-heading]{padding-bottom:.375rem;padding-top:.375rem}.\\[\\&_\\[cmdk-group-heading\\]\\]\\:rf-text-xs [cmdk-group-heading]{font-size:.75rem;line-height:1rem}.\\[\\&_\\[cmdk-group-heading\\]\\]\\:rf-font-medium [cmdk-group-heading]{font-weight:500}.\\[\\&_\\[cmdk-group-heading\\]\\]\\:rf-text-zinc-500 [cmdk-group-heading]{--tw-text-opacity:1;color:rgb(113 113 122/var(--tw-text-opacity,1))}.dark\\:\\[\\&_\\[cmdk-group-heading\\]\\]\\:rf-text-zinc-400 [cmdk-group-heading]:is(.rf-dark *){--tw-text-opacity:1;color:rgb(161 161 170/var(--tw-text-opacity,1))}.\\[\\&_\\[cmdk-group\\]\\:not\\(\\[hidden\\]\\)_\\~\\[cmdk-group\\]\\]\\:rf-pt-0 [cmdk-group]:not([hidden])~[cmdk-group]{padding-top:0}.\\[\\&_\\[cmdk-group\\]\\]\\:rf-px-2 [cmdk-group]{padding-left:.5rem;padding-right:.5rem}.\\[\\&_\\[cmdk-input-wrapper\\]_svg\\]\\:rf-h-5 [cmdk-input-wrapper] svg{height:1.25rem}.\\[\\&_\\[cmdk-input-wrapper\\]_svg\\]\\:rf-w-5 [cmdk-input-wrapper] svg{width:1.25rem}.\\[\\&_\\[cmdk-input\\]\\]\\:rf-h-12 [cmdk-input]{height:3rem}.\\[\\&_\\[cmdk-item\\]\\]\\:rf-px-2 [cmdk-item]{padding-left:.5rem;padding-right:.5rem}.\\[\\&_\\[cmdk-item\\]\\]\\:rf-py-3 [cmdk-item]{padding-bottom:.75rem;padding-top:.75rem}.\\[\\&_\\[cmdk-item\\]_svg\\]\\:rf-h-5 [cmdk-item] svg{height:1.25rem}.\\[\\&_\\[cmdk-item\\]_svg\\]\\:rf-w-5 [cmdk-item] svg{width:1.25rem}.\\[\\&_svg\\]\\:rf-pointer-events-none svg{pointer-events:none}.\\[\\&_svg\\]\\:rf-size-4 svg{height:1rem;width:1rem}.\\[\\&_svg\\]\\:rf-shrink-0 svg{flex-shrink:0}',Kdt=()=>{fe.useEffect(()=>{if(document.querySelector('style[data-styles="tscircuit-runframe"]'))return;const e=document.createElement("style");e.setAttribute("data-styles","tscircuit-runframe"),e.textContent=qFn,document.head.appendChild(e)},[])},XFn=n=>{fe.useEffect(()=>(n?document.body.style.overflow="hidden":document.body.style.overflow="",()=>{document.body.style.overflow=""}),[n])};function Zdt(n,e){const[t,i]=fe.useState(()=>{try{const r=window.localStorage.getItem(n);return r?JSON.parse(r):e}catch(r){return console.error("Error reading from localStorage:",r),e}});return fe.useEffect(()=>{try{window.localStorage.setItem(n,JSON.stringify(t))}catch(r){console.error("Error writing to localStorage:",r)}},[n,t]),[t,i]}const Qdt=n=>`hsl(${KS.indexOf(n)*137.5%360}, 70%, 50%)`,WFn=({phaseTimings:n})=>{if(!n)return null;const e=Object.values(n).reduce((t,i)=>t+i,0);return ce.jsxs("div",{className:"rf-space-y-2 rf-w-full rf-px-4",children:[ce.jsx("div",{className:"rf-relative rf-h-8 rf-flex rf-rounded-sm",children:KS.map(t=>{const i=n[t]||0,r=i/e*100;return ce.jsx("div",{className:"rf-group/bar rf-relative rf-overflow-visible",style:{width:`${r}%`,backgroundColor:Qdt(t)},children:ce.jsxs("div",{className:"rf-opacity-0 group-hover/bar:rf-opacity-100 rf-transition-opacity rf-absolute rf-bottom-full rf-left-1/2 rf-transform -rf-translate-x-1/2 rf-mb-2 rf-px-2 rf-py-1 rf-text-xs rf-whitespace-nowrap rf-rounded rf-bg-gray-900 rf-text-white rf-pointer-events-none",children:[t,": ",i.toFixed(1),"ms"]})},t)})}),ce.jsxs("div",{className:"rf-text-xs rf-text-gray-500",children:["Total: ",e.toFixed(2),"ms"]})]})},KFn=n=>{if(n instanceof Blob)return n;if(n==null)return"";if(typeof n=="string")return n;if(typeof n=="object")try{return JSON.stringify(n,null,2)}catch{return String(n)}return String(n)},ZFn=({renderLog:n,onRerunWithDebug:e})=>{const[t,i]=fe.useState("chronological"),[r,o]=fe.useState(""),s=[{value:"",label:"None"},{value:"DEBUG=Group_doInitialSchematicTraceRender",label:"DEBUG=Group_doInitialSchematicTraceRender"},{value:"DEBUG=Group_doInitialSchematicLayoutMatchpack",label:"DEBUG=Group_doInitialSchematicLayoutMatchpack"},{value:"DEBUG=Group_doInitialPcbLayoutPack",label:"DEBUG=Group_doInitialPcbLayoutPack"}];if(!n)return ce.jsxs("div",{className:"rf-p-4 rf-bg-gray-100 rf-rounded-md",children:[ce.jsx("div",{className:"rf-mb-4",children:"No render log, make sure this tab is open when you render"}),e&&ce.jsxs("div",{className:"rf-flex rf-gap-2 rf-items-center",children:[ce.jsx("select",{value:r,onChange:l=>o(l.target.value),className:"rf-px-3 rf-py-1 rf-border rf-rounded rf-text-xs rf-bg-white",children:s.map(l=>ce.jsx("option",{value:l.value,children:l.label},l.value))}),ce.jsx(H_,{onClick:()=>e(r),size:"sm",className:"rf-text-xs",children:"Rerun Render with Debug"})]})]});const a=Object.entries(n?.phaseTimings??{});t==="chronological"?a.sort((l,u)=>KS.indexOf(l[0])-KS.indexOf(u[0])):a.sort((l,u)=>u[1]-l[1]);const c=a.reduce((l,[u,d])=>l+d,0);return ce.jsxs("div",{className:"rf-bg-white",children:[ce.jsxs("div",{className:"rf-flex rf-justify-between rf-items-center rf-mb-4",children:[ce.jsx("div",{children:"Render Logs"}),ce.jsxs("div",{className:"rf-flex rf-gap-4 rf-items-center",children:[e&&ce.jsxs("div",{className:"rf-flex rf-gap-2 rf-items-center",children:[ce.jsx("select",{value:r,onChange:l=>o(l.target.value),className:"rf-px-3 rf-py-1 rf-border rf-rounded rf-text-xs rf-bg-white",children:s.map(l=>ce.jsx("option",{value:l.value,children:l.label},l.value))}),ce.jsx(H_,{onClick:()=>e(r),size:"sm",className:"rf-text-xs",children:"Rerun Render with Debug"})]}),ce.jsx("div",{className:"rf-flex rf-gap-2 rf-items-center",children:ce.jsxs("select",{onChange:l=>{if(l.target.value){const u=n?.debugOutputs?.find(d=>d.name===l.target.value);if(u){const d=KFn(u.content),h=d instanceof Blob?d:new Blob([d],{type:"text/plain"}),p=URL.createObjectURL(h),m=document.createElement("a");m.href=p,m.download=`debug-${u.name}.txt`,document.body.appendChild(m),m.click(),document.body.removeChild(m),URL.revokeObjectURL(p)}l.target.value=""}},disabled:!n?.debugOutputs||n.debugOutputs.length===0,className:"rf-px-3 rf-py-1 rf-border rf-rounded rf-text-xs rf-bg-white disabled:rf-opacity-50 disabled:rf-cursor-not-allowed",children:[ce.jsx("option",{value:"",children:"Download Debug Output"}),n?.debugOutputs?.map(l=>ce.jsx("option",{value:l.name,children:l.name},l.name))]})}),ce.jsxs("div",{className:"rf-flex rf-text-xs rf-items-center",children:[ce.jsx("div",{className:"rf-mr-2",children:"Sort by:"}),ce.jsxs("select",{value:t,onChange:l=>i(l.target.value),className:"rf-px-2 rf-py-1 rf-border rf-rounded rf-text-xs",children:[ce.jsx("option",{value:"chronological",children:"Phase Order"}),ce.jsx("option",{value:"longest",children:"Duration"})]})]})]})]}),ce.jsx(WFn,{phaseTimings:n.phaseTimings}),ce.jsxs("table",{className:"rf-w-full rf-text-xs",children:[ce.jsx("thead",{children:ce.jsxs("tr",{children:[ce.jsx("th",{className:"rf-text-left rf-p-2",children:"Phase Order"}),ce.jsx("th",{className:"rf-text-left rf-p-2",children:"Phase"}),ce.jsx("th",{className:"rf-text-left rf-p-2",children:"Duration (ms)"})]})}),ce.jsx("tbody",{children:a.map(([l,u])=>ce.jsxs("tr",{children:[ce.jsx("td",{className:"rf-p-2",children:KS.indexOf(l)}),ce.jsx("td",{className:"rf-p-2",children:l}),ce.jsx("td",{className:"rf-p-2",children:ce.jsx("div",{className:"rf-w-8",children:ce.jsx("div",{className:"rf-h-2 rf-rounded-sm",style:{backgroundColor:Qdt(l),width:`${u/c*100}%`}})})}),ce.jsx("td",{className:"rf-p-2",children:ce.jsxs("div",{className:"rf-flex w-full",children:[ce.jsxs("span",{className:"rf-flex-grow",children:[u,"ms"]}),ce.jsxs("span",{className:"rf-text-gray-500 rf-pr-2",children:[(u/c*100).toFixed(1),"%"]})]})})]},l))})]})]})},Jdt=({errorMessage:n,errorStack:e,circuitJsonErrors:t})=>{fe.useEffect(()=>{if(n){const i=new Error(n);e&&(i.stack=e);try{Lz.captureException(i)}catch{}}},[n,e]),fe.useEffect(()=>{if(t&&t.length>0)for(const i of t){const r=new Error(i.message||"Circuit JSON Error");i.stack&&(r.stack=i.stack);try{Lz.captureException(r,{error_type:i.type})}catch{}}},[t])},eht="0.0.1208",QFn={version:eht},bbe={BASE_URL:"/",DEV:!1,MODE:"production",PROD:!0,SSR:!1},vbe=new Map,LY=n=>{const e=vbe.get(n);return e?Object.fromEntries(Object.entries(e.stores).map(([t,i])=>[t,i.getState()])):{}},JFn=(n,e,t)=>{if(n===void 0)return{type:"untracked",connection:e.connect(t)};const i=vbe.get(t.name);if(i)return{type:"tracked",store:n,...i};const r={connection:e.connect(t),stores:{}};return vbe.set(t.name,r),{type:"tracked",store:n,...r}},tht=(n,e={})=>(t,i,r)=>{const{enabled:o,anonymousActionType:s,store:a,...c}=e;let l;try{l=(o??(bbe?"production":void 0)!=="production")&&window.__REDUX_DEVTOOLS_EXTENSION__}catch{}if(!l)return(bbe?"production":void 0)!=="production"&&o&&console.warn("[zustand devtools middleware] Please install/enable Redux devtools extension"),n(t,i,r);const{connection:u,...d}=JFn(a,l,c);let h=!0;r.setState=(_,g,x)=>{const b=t(_,g);if(!h)return b;const w=x===void 0?{type:s||"anonymous"}:typeof x=="string"?{type:x}:x;return a===void 0?(u?.send(w,i()),b):(u?.send({...w,type:`${a}/${w.type}`},{...LY(c.name),[a]:r.getState()}),b)};const p=(..._)=>{const g=h;h=!1,t(..._),h=g},m=n(r.setState,i,r);if(d.type==="untracked"?u?.init(m):(d.stores[d.store]=r,u?.init(Object.fromEntries(Object.entries(d.stores).map(([_,g])=>[_,_===d.store?m:g.getState()])))),r.dispatchFromDevtools&&typeof r.dispatch=="function"){let _=!1;const g=r.dispatch;r.dispatch=(...x)=>{(bbe?"production":void 0)!=="production"&&x[0].type==="__setState"&&!_&&(console.warn('[zustand devtools middleware] "__setState" action type is reserved to set state from the devtools. Avoid using it.'),_=!0),g(...x)}}return u.subscribe(_=>{var g;switch(_.type){case"ACTION":if(typeof _.payload!="string"){console.error("[zustand devtools middleware] Unsupported action format");return}return wbe(_.payload,x=>{if(x.type==="__setState"){if(a===void 0){p(x.state);return}Object.keys(x.state).length!==1&&console.error(`
5813
+ */const YFn=({containerClassName:n,...e})=>{const t=fe.useRef(null),[i,r]=fe.useState(620);return fe.useLayoutEffect(()=>{const o=()=>{if(t.current){const a=t.current.clientHeight,c=window.innerHeight;r(Math.min(Math.max(a,620),c))}};o();const s=new ResizeObserver(o);return t.current&&s.observe(t.current),window.addEventListener("resize",o),()=>{s.disconnect(),window.removeEventListener("resize",o)}},[]),ce.jsx("div",{ref:t,className:n||"rf-w-full rf-h-full",children:ce.jsx(GFn,{...e,height:i})})},qFn='*,:after,:before{--tw-border-spacing-x:0;--tw-border-spacing-y:0;--tw-translate-x:0;--tw-translate-y:0;--tw-rotate:0;--tw-skew-x:0;--tw-skew-y:0;--tw-scale-x:1;--tw-scale-y:1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness:proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:rgba(59,130,246,.5);--tw-ring-offset-shadow:0 0 #0000;--tw-ring-shadow:0 0 #0000;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }::backdrop{--tw-border-spacing-x:0;--tw-border-spacing-y:0;--tw-translate-x:0;--tw-translate-y:0;--tw-rotate:0;--tw-skew-x:0;--tw-skew-y:0;--tw-scale-x:1;--tw-scale-y:1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness:proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:rgba(59,130,246,.5);--tw-ring-offset-shadow:0 0 #0000;--tw-ring-shadow:0 0 #0000;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }/*! tailwindcss v3.4.18 | MIT License | https://tailwindcss.com*/*,:after,:before{border:0 solid #e5e7eb;box-sizing:border-box}:after,:before{--tw-content:""}:host,html{line-height:1.5;-webkit-text-size-adjust:100%;font-family:ui-sans-serif,system-ui,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;font-feature-settings:normal;font-variation-settings:normal;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-tap-highlight-color:transparent}body{line-height:inherit;margin:0}hr{border-top-width:1px;color:inherit;height:0}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,pre,samp{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace;font-feature-settings:normal;font-size:1em;font-variation-settings:normal}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}table{border-collapse:collapse;border-color:inherit;text-indent:0}button,input,optgroup,select,textarea{color:inherit;font-family:inherit;font-feature-settings:inherit;font-size:100%;font-variation-settings:inherit;font-weight:inherit;letter-spacing:inherit;line-height:inherit;margin:0;padding:0}button,select{text-transform:none}button,input:where([type=button]),input:where([type=reset]),input:where([type=submit]){-webkit-appearance:button;background-color:transparent;background-image:none}:-moz-focusring{outline:auto}:-moz-ui-invalid{box-shadow:none}progress{vertical-align:baseline}::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}summary{display:list-item}blockquote,dd,dl,figure,h1,h2,h3,h4,h5,h6,hr,p,pre{margin:0}fieldset{margin:0}fieldset,legend{padding:0}menu,ol,ul{list-style:none;margin:0;padding:0}dialog{padding:0}textarea{resize:vertical}input::-moz-placeholder,textarea::-moz-placeholder{color:#9ca3af;opacity:1}input::placeholder,textarea::placeholder{color:#9ca3af;opacity:1}[role=button],button{cursor:pointer}:disabled{cursor:default}audio,canvas,embed,iframe,img,object,svg,video{display:block;vertical-align:middle}img,video{height:auto;max-width:100%}[hidden]:where(:not([hidden=until-found])){display:none}:root{--radius:0.5rem}.rf-pointer-events-none{pointer-events:none}.rf-invisible{visibility:hidden}.rf-fixed{position:fixed}.rf-absolute{position:absolute}.rf-relative{position:relative}.rf-inset-0{inset:0}.-rf-left-2{left:-.5rem}.-rf-right-10{right:-2.5rem}.-rf-right-2{right:-.5rem}.-rf-right-4{right:-1rem}.-rf-right-6{right:-1.5rem}.-rf-right-7{right:-1.75rem}.-rf-right-8{right:-2rem}.-rf-right-9{right:-2.25rem}.rf-bottom-full{bottom:100%}.rf-left-0{left:0}.rf-left-1{left:.25rem}.rf-left-1\\/2{left:50%}.rf-left-2{left:.5rem}.rf-left-\\[50\\%\\]{left:50%}.rf-right-0{right:0}.rf-right-1{right:.25rem}.rf-right-4{right:1rem}.rf-right-\\[4px\\]{right:4px}.rf-top-0{top:0}.rf-top-1{top:.25rem}.rf-top-2{top:.5rem}.rf-top-2\\.5{top:.625rem}.rf-top-\\[50\\%\\]{top:50%}.rf-top-\\[6px\\]{top:6px}.\\!rf-z-\\[101\\]{z-index:101!important}.\\!rf-z-\\[200\\]{z-index:200!important}.rf-z-10{z-index:10}.rf-z-50{z-index:50}.rf-z-\\[100\\]{z-index:100}.rf-z-\\[101\\]{z-index:101}.rf-order-1{order:1}.rf-order-2{order:2}.rf-order-3{order:3}.rf-m-1{margin:.25rem}.rf-m-6{margin:1.5rem}.-rf-mx-1,.rf--mx-1{margin-left:-.25rem;margin-right:-.25rem}.rf-mx-1{margin-left:.25rem;margin-right:.25rem}.rf-mx-2{margin-left:.5rem;margin-right:.5rem}.rf-mx-4{margin-left:1rem;margin-right:1rem}.rf-mx-auto{margin-left:auto;margin-right:auto}.rf-my-1{margin-bottom:.25rem;margin-top:.25rem}.rf-my-12{margin-bottom:3rem;margin-top:3rem}.rf-my-4{margin-bottom:1rem;margin-top:1rem}.rf-my-auto{margin-bottom:auto;margin-top:auto}.rf-mb-1{margin-bottom:.25rem}.rf-mb-12{margin-bottom:3rem}.rf-mb-2{margin-bottom:.5rem}.rf-mb-3{margin-bottom:.75rem}.rf-mb-4{margin-bottom:1rem}.rf-mb-6{margin-bottom:1.5rem}.rf-mb-8{margin-bottom:2rem}.rf-ml-1{margin-left:.25rem}.rf-ml-2{margin-left:.5rem}.rf-ml-6{margin-left:1.5rem}.rf-ml-auto{margin-left:auto}.rf-mr-1{margin-right:.25rem}.rf-mr-2{margin-right:.5rem}.rf-mr-4{margin-right:1rem}.rf-mt-0{margin-top:0}.rf-mt-0\\.5{margin-top:.125rem}.rf-mt-1{margin-top:.25rem}.rf-mt-2{margin-top:.5rem}.rf-mt-3{margin-top:.75rem}.rf-mt-4{margin-top:1rem}.rf-mt-5{margin-top:1.25rem}.rf-mt-auto{margin-top:auto}.rf-block{display:block}.rf-inline-block{display:inline-block}.rf-inline{display:inline}.rf-flex{display:flex}.rf-inline-flex{display:inline-flex}.rf-grid{display:grid}.rf-hidden{display:none}.rf-aspect-square{aspect-ratio:1/1}.rf-aspect-video{aspect-ratio:16/9}.rf-size-14{height:3.5rem;width:3.5rem}.rf-size-4{height:1rem;width:1rem}.\\!rf-h-2{height:.5rem!important}.\\!rf-h-2\\.5{height:.625rem!important}.\\!rf-h-3{height:.75rem!important}.\\!rf-h-full{height:100%!important}.rf-h-1{height:.25rem}.rf-h-10{height:2.5rem}.rf-h-12{height:3rem}.rf-h-2{height:.5rem}.rf-h-2\\.5{height:.625rem}.rf-h-20{height:5rem}.rf-h-24{height:6rem}.rf-h-3{height:.75rem}.rf-h-3\\.5{height:.875rem}.rf-h-4{height:1rem}.rf-h-5{height:1.25rem}.rf-h-6{height:1.5rem}.rf-h-60{height:15rem}.rf-h-64{height:16rem}.rf-h-7{height:1.75rem}.rf-h-8{height:2rem}.rf-h-9{height:2.25rem}.rf-h-\\[400px\\]{height:400px}.rf-h-\\[calc\\(100vh-52px\\)\\]{height:calc(100vh - 52px)}.rf-h-\\[var\\(--radix-select-trigger-height\\)\\]{height:var(--radix-select-trigger-height)}.rf-h-auto{height:auto}.rf-h-fit{height:-moz-fit-content;height:fit-content}.rf-h-full{height:100%}.rf-h-px{height:1px}.rf-h-screen{height:100vh}.\\!rf-max-h-\\[40vh\\]{max-height:40vh!important}.rf-max-h-32{max-height:8rem}.rf-max-h-96{max-height:24rem}.rf-max-h-\\[200px\\]{max-height:200px}.rf-max-h-\\[300px\\]{max-height:300px}.rf-max-h-\\[70vh\\]{max-height:70vh}.rf-max-h-\\[90vh\\]{max-height:90vh}.rf-max-h-full{max-height:100%}.rf-min-h-0{min-height:0}.rf-min-h-\\[100px\\]{min-height:100px}.rf-min-h-\\[200px\\]{min-height:200px}.rf-min-h-\\[300px\\]{min-height:300px}.rf-min-h-\\[620px\\]{min-height:620px}.rf-min-h-\\[calc\\(100vh-240px\\)\\]{min-height:calc(100vh - 240px)}.\\!rf-w-2{width:.5rem!important}.\\!rf-w-2\\.5{width:.625rem!important}.rf-w-1{width:.25rem}.rf-w-1\\/2{width:50%}.rf-w-11{width:2.75rem}.rf-w-11\\/12{width:91.666667%}.rf-w-12{width:3rem}.rf-w-16{width:4rem}.rf-w-2{width:.5rem}.rf-w-2\\.5{width:.625rem}.rf-w-20{width:5rem}.rf-w-24{width:6rem}.rf-w-28{width:7rem}.rf-w-3{width:.75rem}.rf-w-3\\.5{width:.875rem}.rf-w-32{width:8rem}.rf-w-4{width:1rem}.rf-w-40{width:10rem}.rf-w-48{width:12rem}.rf-w-5{width:1.25rem}.rf-w-6{width:1.5rem}.rf-w-64{width:16rem}.rf-w-72{width:18rem}.rf-w-8{width:2rem}.rf-w-80{width:20rem}.rf-w-9{width:2.25rem}.rf-w-96{width:24rem}.rf-w-fit{width:-moz-fit-content;width:fit-content}.rf-w-full{width:100%}.rf-w-screen{width:100vw}.rf-min-w-0{min-width:0}.rf-min-w-10{min-width:2.5rem}.rf-min-w-16{min-width:4rem}.rf-min-w-32{min-width:8rem}.rf-min-w-80{min-width:20rem}.rf-min-w-96{min-width:24rem}.rf-min-w-\\[148px\\]{min-width:148px}.rf-min-w-\\[600px\\]{min-width:600px}.rf-min-w-\\[8rem\\]{min-width:8rem}.rf-min-w-\\[var\\(--radix-select-trigger-width\\)\\]{min-width:var(--radix-select-trigger-width)}.\\!rf-max-w-\\[660px\\]{max-width:660px!important}.rf-max-w-2xl{max-width:42rem}.rf-max-w-3xl{max-width:48rem}.rf-max-w-4xl{max-width:56rem}.rf-max-w-5xl{max-width:64rem}.rf-max-w-64{max-width:16rem}.rf-max-w-96{max-width:24rem}.rf-max-w-\\[1000px\\]{max-width:1000px}.rf-max-w-\\[150px\\]{max-width:150px}.rf-max-w-\\[200px\\]{max-width:200px}.rf-max-w-\\[40\\%\\]{max-width:40%}.rf-max-w-\\[600px\\]{max-width:600px}.rf-max-w-full{max-width:100%}.rf-max-w-lg{max-width:32rem}.rf-max-w-md{max-width:28rem}.rf-max-w-none{max-width:none}.rf-max-w-xl{max-width:36rem}.rf-max-w-xs{max-width:20rem}.rf-flex-1{flex:1 1 0%}.rf-flex-shrink-0,.rf-shrink-0{flex-shrink:0}.rf-flex-grow{flex-grow:1}.rf-table-auto{table-layout:auto}.rf-origin-\\[--radix-popover-content-transform-origin\\]{transform-origin:var(--radix-popover-content-transform-origin)}.-rf-translate-x-1{--tw-translate-x:-0.25rem}.-rf-translate-x-1,.-rf-translate-x-1\\/2{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.-rf-translate-x-1\\/2{--tw-translate-x:-50%}.-rf-translate-y-1{--tw-translate-y:-0.25rem}.-rf-translate-y-1,.rf--translate-x-1{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.rf--translate-x-1{--tw-translate-x:-0.25rem}.rf--translate-x-1\\/2{--tw-translate-x:-50%}.rf--translate-x-1\\/2,.rf--translate-y-1{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.rf--translate-y-1{--tw-translate-y:-0.25rem}.rf-translate-x-\\[-50\\%\\]{--tw-translate-x:-50%}.rf-translate-x-\\[-50\\%\\],.rf-translate-y-\\[-50\\%\\]{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.rf-translate-y-\\[-50\\%\\]{--tw-translate-y:-50%}.rf-rotate-90{--tw-rotate:90deg}.rf-rotate-90,.rf-transform{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}@keyframes rf-pulse{50%{opacity:.5}}.rf-animate-pulse{animation:rf-pulse 2s cubic-bezier(.4,0,.6,1) infinite}@keyframes rf-spin{to{transform:rotate(1turn)}}.rf-animate-spin{animation:rf-spin 1s linear infinite}.rf-cursor-default{cursor:default}.rf-cursor-not-allowed{cursor:not-allowed}.rf-cursor-pointer{cursor:pointer}.rf-select-none{-webkit-user-select:none;-moz-user-select:none;user-select:none}.rf-grid-cols-1{grid-template-columns:repeat(1,minmax(0,1fr))}.rf-grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.rf-grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.rf-flex-row{flex-direction:row}.rf-flex-col{flex-direction:column}.rf-flex-col-reverse{flex-direction:column-reverse}.rf-flex-wrap{flex-wrap:wrap}.rf-place-items-center{place-items:center}.rf-items-start{align-items:flex-start}.rf-items-end{align-items:flex-end}.rf-items-center{align-items:center}.rf-items-baseline{align-items:baseline}.rf-items-stretch{align-items:stretch}.rf-justify-end{justify-content:flex-end}.rf-justify-center{justify-content:center}.rf-justify-between{justify-content:space-between}.rf-gap-0{gap:0}.rf-gap-1{gap:.25rem}.rf-gap-2{gap:.5rem}.rf-gap-3{gap:.75rem}.rf-gap-4{gap:1rem}.rf-gap-5{gap:1.25rem}.rf-gap-6{gap:1.5rem}.rf-gap-8{gap:2rem}.rf-space-x-2>:not([hidden])~:not([hidden]){--tw-space-x-reverse:0;margin-left:calc(.5rem*(1 - var(--tw-space-x-reverse)));margin-right:calc(.5rem*var(--tw-space-x-reverse))}.rf-space-y-1>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-bottom:calc(.25rem*var(--tw-space-y-reverse));margin-top:calc(.25rem*(1 - var(--tw-space-y-reverse)))}.rf-space-y-2>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-bottom:calc(.5rem*var(--tw-space-y-reverse));margin-top:calc(.5rem*(1 - var(--tw-space-y-reverse)))}.rf-space-y-3>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-bottom:calc(.75rem*var(--tw-space-y-reverse));margin-top:calc(.75rem*(1 - var(--tw-space-y-reverse)))}.rf-space-y-4>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-bottom:calc(1rem*var(--tw-space-y-reverse));margin-top:calc(1rem*(1 - var(--tw-space-y-reverse)))}.rf-space-y-6>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-bottom:calc(1.5rem*var(--tw-space-y-reverse));margin-top:calc(1.5rem*(1 - var(--tw-space-y-reverse)))}.rf-divide-y>:not([hidden])~:not([hidden]){--tw-divide-y-reverse:0;border-bottom-width:calc(1px*var(--tw-divide-y-reverse));border-top-width:calc(1px*(1 - var(--tw-divide-y-reverse)))}.rf-overflow-auto{overflow:auto}.\\!rf-overflow-hidden{overflow:hidden!important}.rf-overflow-hidden{overflow:hidden}.rf-overflow-visible{overflow:visible}.rf-overflow-x-auto{overflow-x:auto}.\\!rf-overflow-y-auto{overflow-y:auto!important}.rf-overflow-y-auto{overflow-y:auto}.rf-overflow-x-hidden{overflow-x:hidden}.rf-overflow-x-clip{overflow-x:clip}.rf-truncate{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.rf-whitespace-normal{white-space:normal}.rf-whitespace-nowrap{white-space:nowrap}.rf-whitespace-pre-wrap{white-space:pre-wrap}.rf-break-words{overflow-wrap:break-word}.rf-break-all{word-break:break-all}.rf-rounded{border-radius:.25rem}.rf-rounded-2xl{border-radius:1rem}.rf-rounded-full{border-radius:9999px}.rf-rounded-lg{border-radius:var(--radius)}.rf-rounded-md{border-radius:calc(var(--radius) - 2px)}.rf-rounded-sm{border-radius:calc(var(--radius) - 4px)}.rf-rounded-xl{border-radius:.75rem}.rf-border{border-width:1px}.rf-border-2{border-width:2px}.rf-border-b{border-bottom-width:1px}.rf-border-l-2{border-left-width:2px}.rf-border-l-4{border-left-width:4px}.rf-border-t{border-top-width:1px}.rf-border-none{border-style:none}.rf-border-blue-200{--tw-border-opacity:1;border-color:rgb(191 219 254/var(--tw-border-opacity,1))}.rf-border-blue-300{--tw-border-opacity:1;border-color:rgb(147 197 253/var(--tw-border-opacity,1))}.rf-border-blue-400{--tw-border-opacity:1;border-color:rgb(96 165 250/var(--tw-border-opacity,1))}.rf-border-blue-500{--tw-border-opacity:1;border-color:rgb(59 130 246/var(--tw-border-opacity,1))}.rf-border-blue-600{--tw-border-opacity:1;border-color:rgb(37 99 235/var(--tw-border-opacity,1))}.rf-border-gray-200{--tw-border-opacity:1;border-color:rgb(229 231 235/var(--tw-border-opacity,1))}.rf-border-gray-300{--tw-border-opacity:1;border-color:rgb(209 213 219/var(--tw-border-opacity,1))}.rf-border-green-200{--tw-border-opacity:1;border-color:rgb(187 247 208/var(--tw-border-opacity,1))}.rf-border-green-400{--tw-border-opacity:1;border-color:rgb(74 222 128/var(--tw-border-opacity,1))}.rf-border-input{border-color:hsl(var(--input))}.rf-border-neutral-200{--tw-border-opacity:1;border-color:rgb(229 229 229/var(--tw-border-opacity,1))}.rf-border-orange-100{--tw-border-opacity:1;border-color:rgb(255 237 213/var(--tw-border-opacity,1))}.rf-border-orange-200{--tw-border-opacity:1;border-color:rgb(254 215 170/var(--tw-border-opacity,1))}.rf-border-orange-500{--tw-border-opacity:1;border-color:rgb(249 115 22/var(--tw-border-opacity,1))}.rf-border-primary{border-color:hsl(var(--primary))}.rf-border-red-100{--tw-border-opacity:1;border-color:rgb(254 226 226/var(--tw-border-opacity,1))}.rf-border-red-200{--tw-border-opacity:1;border-color:rgb(254 202 202/var(--tw-border-opacity,1))}.rf-border-red-400{--tw-border-opacity:1;border-color:rgb(248 113 113/var(--tw-border-opacity,1))}.rf-border-red-500{--tw-border-opacity:1;border-color:rgb(239 68 68/var(--tw-border-opacity,1))}.rf-border-red-600{--tw-border-opacity:1;border-color:rgb(220 38 38/var(--tw-border-opacity,1))}.rf-border-zinc-200{--tw-border-opacity:1;border-color:rgb(228 228 231/var(--tw-border-opacity,1))}.rf-border-zinc-900{--tw-border-opacity:1;border-color:rgb(24 24 27/var(--tw-border-opacity,1))}.rf-bg-amber-50{--tw-bg-opacity:1;background-color:rgb(255 251 235/var(--tw-bg-opacity,1))}.rf-bg-amber-50\\/30{background-color:rgba(255,251,235,.3)}.rf-bg-background{background-color:hsl(var(--background))}.rf-bg-black{--tw-bg-opacity:1;background-color:rgb(0 0 0/var(--tw-bg-opacity,1))}.rf-bg-black\\/80{background-color:rgba(0,0,0,.8)}.rf-bg-blue-100{--tw-bg-opacity:1;background-color:rgb(219 234 254/var(--tw-bg-opacity,1))}.rf-bg-blue-50{--tw-bg-opacity:1;background-color:rgb(239 246 255/var(--tw-bg-opacity,1))}.rf-bg-blue-50\\/30{background-color:rgba(239,246,255,.3)}.rf-bg-blue-500{--tw-bg-opacity:1;background-color:rgb(59 130 246/var(--tw-bg-opacity,1))}.rf-bg-blue-600{--tw-bg-opacity:1;background-color:rgb(37 99 235/var(--tw-bg-opacity,1))}.rf-bg-gray-100{--tw-bg-opacity:1;background-color:rgb(243 244 246/var(--tw-bg-opacity,1))}.rf-bg-gray-200{--tw-bg-opacity:1;background-color:rgb(229 231 235/var(--tw-bg-opacity,1))}.rf-bg-gray-300{--tw-bg-opacity:1;background-color:rgb(209 213 219/var(--tw-bg-opacity,1))}.rf-bg-gray-400{--tw-bg-opacity:1;background-color:rgb(156 163 175/var(--tw-bg-opacity,1))}.rf-bg-gray-50{--tw-bg-opacity:1;background-color:rgb(249 250 251/var(--tw-bg-opacity,1))}.rf-bg-gray-500{--tw-bg-opacity:1;background-color:rgb(107 114 128/var(--tw-bg-opacity,1))}.rf-bg-gray-700{--tw-bg-opacity:1;background-color:rgb(55 65 81/var(--tw-bg-opacity,1))}.rf-bg-gray-800{--tw-bg-opacity:1;background-color:rgb(31 41 55/var(--tw-bg-opacity,1))}.rf-bg-gray-900{--tw-bg-opacity:1;background-color:rgb(17 24 39/var(--tw-bg-opacity,1))}.rf-bg-green-100{--tw-bg-opacity:1;background-color:rgb(220 252 231/var(--tw-bg-opacity,1))}.rf-bg-green-50{--tw-bg-opacity:1;background-color:rgb(240 253 244/var(--tw-bg-opacity,1))}.rf-bg-muted{background-color:hsl(var(--muted))}.rf-bg-neutral-100{--tw-bg-opacity:1;background-color:rgb(245 245 245/var(--tw-bg-opacity,1))}.rf-bg-neutral-50{--tw-bg-opacity:1;background-color:rgb(250 250 250/var(--tw-bg-opacity,1))}.rf-bg-neutral-800{--tw-bg-opacity:1;background-color:rgb(38 38 38/var(--tw-bg-opacity,1))}.rf-bg-neutral-900{--tw-bg-opacity:1;background-color:rgb(23 23 23/var(--tw-bg-opacity,1))}.rf-bg-orange-400{--tw-bg-opacity:1;background-color:rgb(251 146 60/var(--tw-bg-opacity,1))}.rf-bg-orange-50{--tw-bg-opacity:1;background-color:rgb(255 247 237/var(--tw-bg-opacity,1))}.rf-bg-orange-50\\/50{background-color:rgba(255,247,237,.5)}.rf-bg-orange-500{--tw-bg-opacity:1;background-color:rgb(249 115 22/var(--tw-bg-opacity,1))}.rf-bg-popover{background-color:hsl(var(--popover))}.rf-bg-red-100{--tw-bg-opacity:1;background-color:rgb(254 226 226/var(--tw-bg-opacity,1))}.rf-bg-red-50{--tw-bg-opacity:1;background-color:rgb(254 242 242/var(--tw-bg-opacity,1))}.rf-bg-red-50\\/50{background-color:hsla(0,86%,97%,.5)}.rf-bg-red-500{--tw-bg-opacity:1;background-color:rgb(239 68 68/var(--tw-bg-opacity,1))}.rf-bg-red-600{--tw-bg-opacity:1;background-color:rgb(220 38 38/var(--tw-bg-opacity,1))}.rf-bg-red-900{--tw-bg-opacity:1;background-color:rgb(127 29 29/var(--tw-bg-opacity,1))}.rf-bg-slate-50{--tw-bg-opacity:1;background-color:rgb(248 250 252/var(--tw-bg-opacity,1))}.rf-bg-transparent{background-color:transparent}.rf-bg-white{--tw-bg-opacity:1;background-color:rgb(255 255 255/var(--tw-bg-opacity,1))}.rf-bg-yellow-100{--tw-bg-opacity:1;background-color:rgb(254 249 195/var(--tw-bg-opacity,1))}.rf-bg-zinc-100{--tw-bg-opacity:1;background-color:rgb(244 244 245/var(--tw-bg-opacity,1))}.rf-bg-zinc-200{--tw-bg-opacity:1;background-color:rgb(228 228 231/var(--tw-bg-opacity,1))}.rf-bg-zinc-50{--tw-bg-opacity:1;background-color:rgb(250 250 250/var(--tw-bg-opacity,1))}.rf-bg-zinc-800{--tw-bg-opacity:1;background-color:rgb(39 39 42/var(--tw-bg-opacity,1))}.rf-bg-zinc-900{--tw-bg-opacity:1;background-color:rgb(24 24 27/var(--tw-bg-opacity,1))}.rf-bg-opacity-50{--tw-bg-opacity:0.5}.rf-fill-amber-500{fill:#f59e0b}.rf-fill-current{fill:currentColor}.rf-object-contain{-o-object-fit:contain;object-fit:contain}.rf-object-cover{-o-object-fit:cover;object-fit:cover}.\\!rf-p-0{padding:0!important}.rf-p-0{padding:0}.rf-p-1{padding:.25rem}.rf-p-2{padding:.5rem}.rf-p-3{padding:.75rem}.rf-p-4{padding:1rem}.rf-p-5{padding:1.25rem}.rf-p-6{padding:1.5rem}.rf-p-8{padding:2rem}.rf-px-1{padding-left:.25rem;padding-right:.25rem}.rf-px-2{padding-left:.5rem;padding-right:.5rem}.rf-px-3{padding-left:.75rem;padding-right:.75rem}.rf-px-4{padding-left:1rem;padding-right:1rem}.rf-px-6{padding-left:1.5rem;padding-right:1.5rem}.rf-px-8{padding-left:2rem;padding-right:2rem}.rf-py-0{padding-bottom:0;padding-top:0}.rf-py-0\\.5{padding-bottom:.125rem;padding-top:.125rem}.rf-py-1{padding-bottom:.25rem;padding-top:.25rem}.rf-py-1\\.5{padding-bottom:.375rem;padding-top:.375rem}.rf-py-10{padding-bottom:2.5rem;padding-top:2.5rem}.rf-py-12{padding-bottom:3rem;padding-top:3rem}.rf-py-2{padding-bottom:.5rem;padding-top:.5rem}.rf-py-3{padding-bottom:.75rem;padding-top:.75rem}.rf-py-4{padding-bottom:1rem;padding-top:1rem}.rf-py-6{padding-bottom:1.5rem;padding-top:1.5rem}.rf-py-8{padding-bottom:2rem;padding-top:2rem}.rf-pb-0{padding-bottom:0}.rf-pb-1{padding-bottom:.25rem}.rf-pb-2{padding-bottom:.5rem}.rf-pb-3{padding-bottom:.75rem}.rf-pb-4{padding-bottom:1rem}.rf-pb-px{padding-bottom:1px}.rf-pl-10{padding-left:2.5rem}.rf-pl-11{padding-left:2.75rem}.rf-pl-12{padding-left:3rem}.rf-pl-2{padding-left:.5rem}.rf-pl-4{padding-left:1rem}.rf-pl-8{padding-left:2rem}.rf-pr-2{padding-right:.5rem}.rf-pt-0{padding-top:0}.rf-pt-1{padding-top:.25rem}.rf-pt-2{padding-top:.5rem}.rf-pt-4{padding-top:1rem}.rf-text-left{text-align:left}.rf-text-center{text-align:center}.rf-text-right{text-align:right}.rf-font-mono{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace}.rf-text-2xl{font-size:1.5rem;line-height:2rem}.rf-text-3xl{font-size:1.875rem;line-height:2.25rem}.rf-text-\\[8px\\]{font-size:8px}.rf-text-base{font-size:1rem;line-height:1.5rem}.rf-text-lg{font-size:1.125rem;line-height:1.75rem}.rf-text-sm{font-size:.875rem;line-height:1.25rem}.rf-text-xl{font-size:1.25rem;line-height:1.75rem}.rf-text-xs{font-size:.75rem;line-height:1rem}.\\!rf-font-normal{font-weight:400!important}.rf-font-bold{font-weight:700}.rf-font-medium{font-weight:500}.rf-font-semibold{font-weight:600}.rf-uppercase{text-transform:uppercase}.rf-capitalize{text-transform:capitalize}.rf-tabular-nums{--tw-numeric-spacing:tabular-nums;font-variant-numeric:var(--tw-ordinal) var(--tw-slashed-zero) var(--tw-numeric-figure) var(--tw-numeric-spacing) var(--tw-numeric-fraction)}.rf-leading-5{line-height:1.25rem}.rf-leading-\\[0\\.95rem\\]{line-height:.95rem}.rf-leading-\\[1rem\\]{line-height:1rem}.rf-leading-none{line-height:1}.rf-leading-relaxed{line-height:1.625}.rf-leading-tight{line-height:1.25}.rf-tracking-wide{letter-spacing:.025em}.rf-tracking-widest{letter-spacing:.1em}.rf-text-amber-500{--tw-text-opacity:1;color:rgb(245 158 11/var(--tw-text-opacity,1))}.rf-text-black{--tw-text-opacity:1;color:rgb(0 0 0/var(--tw-text-opacity,1))}.rf-text-blue-500{--tw-text-opacity:1;color:rgb(59 130 246/var(--tw-text-opacity,1))}.rf-text-blue-600{--tw-text-opacity:1;color:rgb(37 99 235/var(--tw-text-opacity,1))}.rf-text-blue-700{--tw-text-opacity:1;color:rgb(29 78 216/var(--tw-text-opacity,1))}.rf-text-blue-800{--tw-text-opacity:1;color:rgb(30 64 175/var(--tw-text-opacity,1))}.rf-text-blue-900{--tw-text-opacity:1;color:rgb(30 58 138/var(--tw-text-opacity,1))}.rf-text-current{color:currentColor}.rf-text-gray-300{--tw-text-opacity:1;color:rgb(209 213 219/var(--tw-text-opacity,1))}.rf-text-gray-400{--tw-text-opacity:1;color:rgb(156 163 175/var(--tw-text-opacity,1))}.rf-text-gray-500{--tw-text-opacity:1;color:rgb(107 114 128/var(--tw-text-opacity,1))}.rf-text-gray-600{--tw-text-opacity:1;color:rgb(75 85 99/var(--tw-text-opacity,1))}.rf-text-gray-700{--tw-text-opacity:1;color:rgb(55 65 81/var(--tw-text-opacity,1))}.rf-text-gray-800{--tw-text-opacity:1;color:rgb(31 41 55/var(--tw-text-opacity,1))}.rf-text-gray-900{--tw-text-opacity:1;color:rgb(17 24 39/var(--tw-text-opacity,1))}.rf-text-green-500{--tw-text-opacity:1;color:rgb(34 197 94/var(--tw-text-opacity,1))}.rf-text-green-600{--tw-text-opacity:1;color:rgb(22 163 74/var(--tw-text-opacity,1))}.rf-text-green-700{--tw-text-opacity:1;color:rgb(21 128 61/var(--tw-text-opacity,1))}.rf-text-green-800{--tw-text-opacity:1;color:rgb(22 101 52/var(--tw-text-opacity,1))}.rf-text-green-900{--tw-text-opacity:1;color:rgb(20 83 45/var(--tw-text-opacity,1))}.rf-text-muted-foreground{color:hsl(var(--muted-foreground))}.rf-text-neutral-50{--tw-text-opacity:1;color:rgb(250 250 250/var(--tw-text-opacity,1))}.rf-text-neutral-500{--tw-text-opacity:1;color:rgb(115 115 115/var(--tw-text-opacity,1))}.rf-text-neutral-900{--tw-text-opacity:1;color:rgb(23 23 23/var(--tw-text-opacity,1))}.rf-text-neutral-950{--tw-text-opacity:1;color:rgb(10 10 10/var(--tw-text-opacity,1))}.rf-text-orange-400{--tw-text-opacity:1;color:rgb(251 146 60/var(--tw-text-opacity,1))}.rf-text-orange-500{--tw-text-opacity:1;color:rgb(249 115 22/var(--tw-text-opacity,1))}.rf-text-orange-600{--tw-text-opacity:1;color:rgb(234 88 12/var(--tw-text-opacity,1))}.rf-text-orange-700{--tw-text-opacity:1;color:rgb(194 65 12/var(--tw-text-opacity,1))}.rf-text-orange-800{--tw-text-opacity:1;color:rgb(154 52 18/var(--tw-text-opacity,1))}.rf-text-popover-foreground{color:hsl(var(--popover-foreground))}.rf-text-red-200{--tw-text-opacity:1;color:rgb(254 202 202/var(--tw-text-opacity,1))}.rf-text-red-300{--tw-text-opacity:1;color:rgb(252 165 165/var(--tw-text-opacity,1))}.rf-text-red-400{--tw-text-opacity:1;color:rgb(248 113 113/var(--tw-text-opacity,1))}.rf-text-red-500{--tw-text-opacity:1;color:rgb(239 68 68/var(--tw-text-opacity,1))}.rf-text-red-600{--tw-text-opacity:1;color:rgb(220 38 38/var(--tw-text-opacity,1))}.rf-text-red-700{--tw-text-opacity:1;color:rgb(185 28 28/var(--tw-text-opacity,1))}.rf-text-red-800{--tw-text-opacity:1;color:rgb(153 27 27/var(--tw-text-opacity,1))}.rf-text-red-900{--tw-text-opacity:1;color:rgb(127 29 29/var(--tw-text-opacity,1))}.rf-text-slate-400{--tw-text-opacity:1;color:rgb(148 163 184/var(--tw-text-opacity,1))}.rf-text-slate-500{--tw-text-opacity:1;color:rgb(100 116 139/var(--tw-text-opacity,1))}.rf-text-slate-600{--tw-text-opacity:1;color:rgb(71 85 105/var(--tw-text-opacity,1))}.rf-text-slate-800{--tw-text-opacity:1;color:rgb(30 41 59/var(--tw-text-opacity,1))}.rf-text-white{--tw-text-opacity:1;color:rgb(255 255 255/var(--tw-text-opacity,1))}.rf-text-yellow-400{--tw-text-opacity:1;color:rgb(250 204 21/var(--tw-text-opacity,1))}.rf-text-yellow-500{--tw-text-opacity:1;color:rgb(234 179 8/var(--tw-text-opacity,1))}.rf-text-yellow-600{--tw-text-opacity:1;color:rgb(202 138 4/var(--tw-text-opacity,1))}.rf-text-yellow-900{--tw-text-opacity:1;color:rgb(113 63 18/var(--tw-text-opacity,1))}.rf-text-zinc-200{--tw-text-opacity:1;color:rgb(228 228 231/var(--tw-text-opacity,1))}.rf-text-zinc-300{--tw-text-opacity:1;color:rgb(212 212 216/var(--tw-text-opacity,1))}.rf-text-zinc-400{--tw-text-opacity:1;color:rgb(161 161 170/var(--tw-text-opacity,1))}.rf-text-zinc-50{--tw-text-opacity:1;color:rgb(250 250 250/var(--tw-text-opacity,1))}.rf-text-zinc-500{--tw-text-opacity:1;color:rgb(113 113 122/var(--tw-text-opacity,1))}.rf-text-zinc-900{--tw-text-opacity:1;color:rgb(24 24 27/var(--tw-text-opacity,1))}.rf-text-zinc-950{--tw-text-opacity:1;color:rgb(9 9 11/var(--tw-text-opacity,1))}.rf-underline{text-decoration-line:underline}.rf-line-through{text-decoration-line:line-through}.rf-underline-offset-4{text-underline-offset:4px}.rf-opacity-0{opacity:0}.rf-opacity-100{opacity:1}.rf-opacity-25{opacity:.25}.rf-opacity-30{opacity:.3}.rf-opacity-50{opacity:.5}.rf-opacity-60{opacity:.6}.rf-opacity-70{opacity:.7}.rf-opacity-75{opacity:.75}.rf-shadow{--tw-shadow:0 1px 3px 0 rgba(0,0,0,.1),0 1px 2px -1px rgba(0,0,0,.1);--tw-shadow-colored:0 1px 3px 0 var(--tw-shadow-color),0 1px 2px -1px var(--tw-shadow-color)}.rf-shadow,.rf-shadow-lg{box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}.rf-shadow-lg{--tw-shadow:0 10px 15px -3px rgba(0,0,0,.1),0 4px 6px -4px rgba(0,0,0,.1);--tw-shadow-colored:0 10px 15px -3px var(--tw-shadow-color),0 4px 6px -4px var(--tw-shadow-color)}.rf-shadow-md{--tw-shadow:0 4px 6px -1px rgba(0,0,0,.1),0 2px 4px -2px rgba(0,0,0,.1);--tw-shadow-colored:0 4px 6px -1px var(--tw-shadow-color),0 2px 4px -2px var(--tw-shadow-color)}.rf-shadow-md,.rf-shadow-sm{box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}.rf-shadow-sm{--tw-shadow:0 1px 2px 0 rgba(0,0,0,.05);--tw-shadow-colored:0 1px 2px 0 var(--tw-shadow-color)}.rf-outline-none{outline:2px solid transparent;outline-offset:2px}.rf-ring-2{--tw-ring-offset-shadow:var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow:var(--tw-ring-inset) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow,0 0 #0000)}.rf-ring-blue-500{--tw-ring-opacity:1;--tw-ring-color:rgb(59 130 246/var(--tw-ring-opacity,1))}.rf-ring-primary{--tw-ring-color:hsl(var(--primary))}.rf-ring-offset-background{--tw-ring-offset-color:hsl(var(--background))}.rf-ring-offset-white{--tw-ring-offset-color:#fff}.rf-transition{transition-duration:.15s;transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,backdrop-filter;transition-timing-function:cubic-bezier(.4,0,.2,1)}.rf-transition-all{transition-duration:.15s;transition-property:all;transition-timing-function:cubic-bezier(.4,0,.2,1)}.rf-transition-colors{transition-duration:.15s;transition-property:color,background-color,border-color,text-decoration-color,fill,stroke;transition-timing-function:cubic-bezier(.4,0,.2,1)}.rf-transition-opacity{transition-duration:.15s;transition-property:opacity;transition-timing-function:cubic-bezier(.4,0,.2,1)}.rf-transition-transform{transition-duration:.15s;transition-property:transform;transition-timing-function:cubic-bezier(.4,0,.2,1)}.rf-duration-200{transition-duration:.2s}.rf-ease-in-out{transition-timing-function:cubic-bezier(.4,0,.2,1)}@keyframes enter{0%{opacity:var(--tw-enter-opacity,1);transform:translate3d(var(--tw-enter-translate-x,0),var(--tw-enter-translate-y,0),0) scale3d(var(--tw-enter-scale,1),var(--tw-enter-scale,1),var(--tw-enter-scale,1)) rotate(var(--tw-enter-rotate,0))}}@keyframes exit{to{opacity:var(--tw-exit-opacity,1);transform:translate3d(var(--tw-exit-translate-x,0),var(--tw-exit-translate-y,0),0) scale3d(var(--tw-exit-scale,1),var(--tw-exit-scale,1),var(--tw-exit-scale,1)) rotate(var(--tw-exit-rotate,0))}}.rf-slide-in-from-left-1{--tw-enter-translate-x:-0.25rem}.rf-slide-out-to-left-1{--tw-exit-translate-x:-0.25rem}.rf-duration-200{animation-duration:.2s}.rf-ease-in-out{animation-timing-function:cubic-bezier(.4,0,.2,1)}.file\\:rf-border-0::file-selector-button{border-width:0}.file\\:rf-bg-transparent::file-selector-button{background-color:transparent}.file\\:rf-text-sm::file-selector-button{font-size:.875rem;line-height:1.25rem}.file\\:rf-font-medium::file-selector-button{font-weight:500}.placeholder\\:rf-text-zinc-500::-moz-placeholder{--tw-text-opacity:1;color:rgb(113 113 122/var(--tw-text-opacity,1))}.placeholder\\:rf-text-zinc-500::placeholder{--tw-text-opacity:1;color:rgb(113 113 122/var(--tw-text-opacity,1))}.hover\\:rf-border-blue-300:hover{--tw-border-opacity:1;border-color:rgb(147 197 253/var(--tw-border-opacity,1))}.hover\\:rf-border-blue-500:hover{--tw-border-opacity:1;border-color:rgb(59 130 246/var(--tw-border-opacity,1))}.hover\\:\\!rf-bg-transparent:hover{background-color:transparent!important}.hover\\:rf-bg-blue-700:hover{--tw-bg-opacity:1;background-color:rgb(29 78 216/var(--tw-bg-opacity,1))}.hover\\:rf-bg-orange-100:hover{--tw-bg-opacity:1;background-color:rgb(255 237 213/var(--tw-bg-opacity,1))}.hover\\:rf-bg-red-100:hover{--tw-bg-opacity:1;background-color:rgb(254 226 226/var(--tw-bg-opacity,1))}.hover\\:rf-bg-red-500\\/90:hover{background-color:rgba(239,68,68,.9)}.hover\\:rf-bg-slate-200:hover{--tw-bg-opacity:1;background-color:rgb(226 232 240/var(--tw-bg-opacity,1))}.hover\\:rf-bg-zinc-100:hover{--tw-bg-opacity:1;background-color:rgb(244 244 245/var(--tw-bg-opacity,1))}.hover\\:rf-bg-zinc-100\\/80:hover{background-color:hsla(240,5%,96%,.8)}.hover\\:rf-bg-zinc-900\\/90:hover{background-color:rgba(24,24,27,.9)}.hover\\:rf-text-blue-800:hover{--tw-text-opacity:1;color:rgb(30 64 175/var(--tw-text-opacity,1))}.hover\\:rf-text-red-400:hover{--tw-text-opacity:1;color:rgb(248 113 113/var(--tw-text-opacity,1))}.hover\\:rf-text-slate-800:hover{--tw-text-opacity:1;color:rgb(30 41 59/var(--tw-text-opacity,1))}.hover\\:rf-text-slate-900:hover{--tw-text-opacity:1;color:rgb(15 23 42/var(--tw-text-opacity,1))}.hover\\:rf-text-zinc-900:hover{--tw-text-opacity:1;color:rgb(24 24 27/var(--tw-text-opacity,1))}.hover\\:rf-underline:hover{text-decoration-line:underline}.focus\\:rf-bg-gray-100:focus{--tw-bg-opacity:1;background-color:rgb(243 244 246/var(--tw-bg-opacity,1))}.focus\\:rf-bg-zinc-100:focus{--tw-bg-opacity:1;background-color:rgb(244 244 245/var(--tw-bg-opacity,1))}.focus\\:rf-text-gray-900:focus{--tw-text-opacity:1;color:rgb(17 24 39/var(--tw-text-opacity,1))}.focus\\:rf-text-zinc-900:focus{--tw-text-opacity:1;color:rgb(24 24 27/var(--tw-text-opacity,1))}.focus\\:rf-outline-none:focus{outline:2px solid transparent;outline-offset:2px}.focus\\:rf-ring-2:focus{--tw-ring-offset-shadow:var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow:var(--tw-ring-inset) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow,0 0 #0000)}.focus\\:rf-ring-blue-500:focus{--tw-ring-opacity:1;--tw-ring-color:rgb(59 130 246/var(--tw-ring-opacity,1))}.focus\\:rf-ring-ring:focus{--tw-ring-color:hsl(var(--ring))}.focus\\:rf-ring-offset-2:focus{--tw-ring-offset-width:2px}.focus-visible\\:rf-outline-none:focus-visible{outline:2px solid transparent;outline-offset:2px}.focus-visible\\:rf-ring-1:focus-visible{--tw-ring-offset-shadow:var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow:var(--tw-ring-inset) 0 0 0 calc(1px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow,0 0 #0000)}.focus-visible\\:rf-ring-2:focus-visible{--tw-ring-offset-shadow:var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow:var(--tw-ring-inset) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow,0 0 #0000)}.focus-visible\\:rf-ring-zinc-950:focus-visible{--tw-ring-opacity:1;--tw-ring-color:rgb(9 9 11/var(--tw-ring-opacity,1))}.focus-visible\\:rf-ring-offset-2:focus-visible{--tw-ring-offset-width:2px}.disabled\\:rf-pointer-events-none:disabled{pointer-events:none}.disabled\\:rf-cursor-not-allowed:disabled{cursor:not-allowed}.disabled\\:rf-opacity-50:disabled{opacity:.5}.rf-group:hover .group-hover\\:rf-opacity-100,.rf-group\\/bar:hover .group-hover\\/bar\\:rf-opacity-100{opacity:1}.data-\\[disabled\\=true\\]\\:rf-pointer-events-none[data-disabled=true],.data-\\[disabled\\]\\:rf-pointer-events-none[data-disabled]{pointer-events:none}.data-\\[side\\=bottom\\]\\:rf-translate-y-1[data-side=bottom]{--tw-translate-y:0.25rem}.data-\\[side\\=bottom\\]\\:rf-translate-y-1[data-side=bottom],.data-\\[side\\=left\\]\\:-rf-translate-x-1[data-side=left]{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.data-\\[side\\=left\\]\\:-rf-translate-x-1[data-side=left]{--tw-translate-x:-0.25rem}.data-\\[side\\=right\\]\\:rf-translate-x-1[data-side=right]{--tw-translate-x:0.25rem}.data-\\[side\\=right\\]\\:rf-translate-x-1[data-side=right],.data-\\[side\\=top\\]\\:-rf-translate-y-1[data-side=top]{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.data-\\[side\\=top\\]\\:-rf-translate-y-1[data-side=top]{--tw-translate-y:-0.25rem}.data-\\[selected\\=true\\]\\:rf-bg-zinc-100[data-selected=true]{--tw-bg-opacity:1;background-color:rgb(244 244 245/var(--tw-bg-opacity,1))}.data-\\[state\\=active\\]\\:rf-bg-white[data-state=active]{--tw-bg-opacity:1;background-color:rgb(255 255 255/var(--tw-bg-opacity,1))}.data-\\[state\\=checked\\]\\:rf-bg-zinc-900[data-state=checked]{--tw-bg-opacity:1;background-color:rgb(24 24 27/var(--tw-bg-opacity,1))}.data-\\[state\\=open\\]\\:rf-bg-zinc-100[data-state=open]{--tw-bg-opacity:1;background-color:rgb(244 244 245/var(--tw-bg-opacity,1))}.data-\\[selected\\=true\\]\\:rf-text-zinc-900[data-selected=true]{--tw-text-opacity:1;color:rgb(24 24 27/var(--tw-text-opacity,1))}.data-\\[state\\=active\\]\\:rf-text-zinc-950[data-state=active]{--tw-text-opacity:1;color:rgb(9 9 11/var(--tw-text-opacity,1))}.data-\\[state\\=checked\\]\\:rf-text-zinc-50[data-state=checked]{--tw-text-opacity:1;color:rgb(250 250 250/var(--tw-text-opacity,1))}.data-\\[disabled\\=true\\]\\:rf-opacity-50[data-disabled=true],.data-\\[disabled\\]\\:rf-opacity-50[data-disabled]{opacity:.5}.data-\\[state\\=active\\]\\:rf-shadow[data-state=active]{--tw-shadow:0 1px 3px 0 rgba(0,0,0,.1),0 1px 2px -1px rgba(0,0,0,.1);--tw-shadow-colored:0 1px 3px 0 var(--tw-shadow-color),0 1px 2px -1px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}.data-\\[state\\=open\\]\\:rf-animate-in[data-state=open]{animation-duration:.15s;animation-name:enter;--tw-enter-opacity:initial;--tw-enter-scale:initial;--tw-enter-rotate:initial;--tw-enter-translate-x:initial;--tw-enter-translate-y:initial}.data-\\[state\\=closed\\]\\:rf-animate-out[data-state=closed]{animation-duration:.15s;animation-name:exit;--tw-exit-opacity:initial;--tw-exit-scale:initial;--tw-exit-rotate:initial;--tw-exit-translate-x:initial;--tw-exit-translate-y:initial}.data-\\[state\\=closed\\]\\:rf-fade-out-0[data-state=closed]{--tw-exit-opacity:0}.data-\\[state\\=open\\]\\:rf-fade-in-0[data-state=open]{--tw-enter-opacity:0}.data-\\[state\\=closed\\]\\:rf-zoom-out-95[data-state=closed]{--tw-exit-scale:.95}.data-\\[state\\=open\\]\\:rf-zoom-in-95[data-state=open]{--tw-enter-scale:.95}.data-\\[side\\=bottom\\]\\:rf-slide-in-from-top-2[data-side=bottom]{--tw-enter-translate-y:-0.5rem}.data-\\[side\\=left\\]\\:rf-slide-in-from-right-2[data-side=left]{--tw-enter-translate-x:0.5rem}.data-\\[side\\=right\\]\\:rf-slide-in-from-left-2[data-side=right]{--tw-enter-translate-x:-0.5rem}.data-\\[side\\=top\\]\\:rf-slide-in-from-bottom-2[data-side=top]{--tw-enter-translate-y:0.5rem}.data-\\[state\\=closed\\]\\:rf-slide-out-to-left-1\\/2[data-state=closed]{--tw-exit-translate-x:-50%}.data-\\[state\\=closed\\]\\:rf-slide-out-to-top-\\[48\\%\\][data-state=closed]{--tw-exit-translate-y:-48%}.data-\\[state\\=open\\]\\:rf-slide-in-from-left-1\\/2[data-state=open]{--tw-enter-translate-x:-50%}.data-\\[state\\=open\\]\\:rf-slide-in-from-top-\\[48\\%\\][data-state=open]{--tw-enter-translate-y:-48%}.dark\\:rf-border-zinc-50:is(.rf-dark *){--tw-border-opacity:1;border-color:rgb(250 250 250/var(--tw-border-opacity,1))}.dark\\:rf-border-zinc-800:is(.rf-dark *){--tw-border-opacity:1;border-color:rgb(39 39 42/var(--tw-border-opacity,1))}.dark\\:rf-bg-gray-700:is(.rf-dark *){--tw-bg-opacity:1;background-color:rgb(55 65 81/var(--tw-bg-opacity,1))}.dark\\:rf-bg-gray-800:is(.rf-dark *){--tw-bg-opacity:1;background-color:rgb(31 41 55/var(--tw-bg-opacity,1))}.dark\\:rf-bg-red-900:is(.rf-dark *){--tw-bg-opacity:1;background-color:rgb(127 29 29/var(--tw-bg-opacity,1))}.dark\\:rf-bg-zinc-50:is(.rf-dark *){--tw-bg-opacity:1;background-color:rgb(250 250 250/var(--tw-bg-opacity,1))}.dark\\:rf-bg-zinc-800:is(.rf-dark *){--tw-bg-opacity:1;background-color:rgb(39 39 42/var(--tw-bg-opacity,1))}.dark\\:rf-bg-zinc-950:is(.rf-dark *){--tw-bg-opacity:1;background-color:rgb(9 9 11/var(--tw-bg-opacity,1))}.dark\\:rf-text-gray-500:is(.rf-dark *){--tw-text-opacity:1;color:rgb(107 114 128/var(--tw-text-opacity,1))}.dark\\:rf-text-zinc-400:is(.rf-dark *){--tw-text-opacity:1;color:rgb(161 161 170/var(--tw-text-opacity,1))}.dark\\:rf-text-zinc-50:is(.rf-dark *){--tw-text-opacity:1;color:rgb(250 250 250/var(--tw-text-opacity,1))}.dark\\:rf-text-zinc-900:is(.rf-dark *){--tw-text-opacity:1;color:rgb(24 24 27/var(--tw-text-opacity,1))}.dark\\:rf-placeholder-zinc-400:is(.rf-dark *)::-moz-placeholder{--tw-placeholder-opacity:1;color:rgb(161 161 170/var(--tw-placeholder-opacity,1))}.dark\\:rf-placeholder-zinc-400:is(.rf-dark *)::placeholder{--tw-placeholder-opacity:1;color:rgb(161 161 170/var(--tw-placeholder-opacity,1))}.dark\\:rf-ring-offset-zinc-950:is(.rf-dark *){--tw-ring-offset-color:#09090b}.dark\\:placeholder\\:rf-text-zinc-400:is(.rf-dark *)::-moz-placeholder{--tw-text-opacity:1;color:rgb(161 161 170/var(--tw-text-opacity,1))}.dark\\:placeholder\\:rf-text-zinc-400:is(.rf-dark *)::placeholder{--tw-text-opacity:1;color:rgb(161 161 170/var(--tw-text-opacity,1))}.dark\\:hover\\:rf-bg-red-900\\/90:hover:is(.rf-dark *){background-color:rgba(127,29,29,.9)}.dark\\:hover\\:rf-bg-zinc-50\\/90:hover:is(.rf-dark *){background-color:hsla(0,0%,98%,.9)}.dark\\:hover\\:rf-bg-zinc-800:hover:is(.rf-dark *){--tw-bg-opacity:1;background-color:rgb(39 39 42/var(--tw-bg-opacity,1))}.dark\\:hover\\:rf-bg-zinc-800\\/80:hover:is(.rf-dark *){background-color:rgba(39,39,42,.8)}.dark\\:hover\\:rf-text-zinc-50:hover:is(.rf-dark *){--tw-text-opacity:1;color:rgb(250 250 250/var(--tw-text-opacity,1))}.dark\\:focus\\:rf-bg-zinc-800:focus:is(.rf-dark *){--tw-bg-opacity:1;background-color:rgb(39 39 42/var(--tw-bg-opacity,1))}.dark\\:focus\\:rf-text-zinc-50:focus:is(.rf-dark *){--tw-text-opacity:1;color:rgb(250 250 250/var(--tw-text-opacity,1))}.dark\\:focus-visible\\:rf-ring-zinc-300:focus-visible:is(.rf-dark *){--tw-ring-opacity:1;--tw-ring-color:rgb(212 212 216/var(--tw-ring-opacity,1))}.dark\\:data-\\[selected\\=true\\]\\:rf-bg-zinc-800[data-selected=true]:is(.rf-dark *){--tw-bg-opacity:1;background-color:rgb(39 39 42/var(--tw-bg-opacity,1))}.dark\\:data-\\[state\\=active\\]\\:rf-bg-zinc-950[data-state=active]:is(.rf-dark *){--tw-bg-opacity:1;background-color:rgb(9 9 11/var(--tw-bg-opacity,1))}.dark\\:data-\\[state\\=checked\\]\\:rf-bg-zinc-50[data-state=checked]:is(.rf-dark *){--tw-bg-opacity:1;background-color:rgb(250 250 250/var(--tw-bg-opacity,1))}.dark\\:data-\\[state\\=open\\]\\:rf-bg-zinc-800[data-state=open]:is(.rf-dark *){--tw-bg-opacity:1;background-color:rgb(39 39 42/var(--tw-bg-opacity,1))}.dark\\:data-\\[selected\\=true\\]\\:rf-text-zinc-50[data-selected=true]:is(.rf-dark *){--tw-text-opacity:1;color:rgb(250 250 250/var(--tw-text-opacity,1))}.dark\\:data-\\[state\\=active\\]\\:rf-text-zinc-50[data-state=active]:is(.rf-dark *){--tw-text-opacity:1;color:rgb(250 250 250/var(--tw-text-opacity,1))}.dark\\:data-\\[state\\=checked\\]\\:rf-text-zinc-900[data-state=checked]:is(.rf-dark *){--tw-text-opacity:1;color:rgb(24 24 27/var(--tw-text-opacity,1))}@media (min-width:640px){.sm\\:rf-order-1{order:1}.sm\\:rf-order-2{order:2}.sm\\:rf-mt-0{margin-top:0}.sm\\:rf-block{display:block}.sm\\:rf-inline{display:inline}.sm\\:rf-grid{display:grid}.sm\\:rf-hidden{display:none}.sm\\:rf-w-auto{width:auto}.sm\\:rf-grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.sm\\:rf-grid-cols-\\[1fr_auto\\]{grid-template-columns:1fr auto}.sm\\:rf-flex-row{flex-direction:row}.sm\\:rf-items-center{align-items:center}.sm\\:rf-justify-end{justify-content:flex-end}.sm\\:rf-gap-3{gap:.75rem}.sm\\:rf-space-x-2>:not([hidden])~:not([hidden]){--tw-space-x-reverse:0;margin-left:calc(.5rem*(1 - var(--tw-space-x-reverse)));margin-right:calc(.5rem*var(--tw-space-x-reverse))}.sm\\:rf-justify-self-end{justify-self:end}.sm\\:rf-rounded-lg{border-radius:var(--radius)}.sm\\:rf-px-4{padding-left:1rem;padding-right:1rem}.sm\\:rf-text-left{text-align:left}.sm\\:rf-text-right{text-align:right}.sm\\:rf-text-sm{font-size:.875rem;line-height:1.25rem}.sm\\:rf-text-xl{font-size:1.25rem;line-height:1.75rem}}@media (min-width:768px){.md\\:rf-grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}}.\\[\\&\\>span\\]\\:rf-line-clamp-1>span{display:-webkit-box;overflow:hidden;-webkit-box-orient:vertical;-webkit-line-clamp:1}.\\[\\&\\>svg\\]\\:rf-size-4>svg{height:1rem;width:1rem}.\\[\\&\\>svg\\]\\:rf-shrink-0>svg{flex-shrink:0}.\\[\\&\\>svg\\]\\:rf-text-red-300>svg{--tw-text-opacity:1;color:rgb(252 165 165/var(--tw-text-opacity,1))}.\\[\\&\\>svg\\]\\:hover\\:rf-text-red-400:hover>svg{--tw-text-opacity:1;color:rgb(248 113 113/var(--tw-text-opacity,1))}.\\[\\&_\\[cmdk-group-heading\\]\\]\\:rf-px-2 [cmdk-group-heading]{padding-left:.5rem;padding-right:.5rem}.\\[\\&_\\[cmdk-group-heading\\]\\]\\:rf-py-1\\.5 [cmdk-group-heading]{padding-bottom:.375rem;padding-top:.375rem}.\\[\\&_\\[cmdk-group-heading\\]\\]\\:rf-text-xs [cmdk-group-heading]{font-size:.75rem;line-height:1rem}.\\[\\&_\\[cmdk-group-heading\\]\\]\\:rf-font-medium [cmdk-group-heading]{font-weight:500}.\\[\\&_\\[cmdk-group-heading\\]\\]\\:rf-text-zinc-500 [cmdk-group-heading]{--tw-text-opacity:1;color:rgb(113 113 122/var(--tw-text-opacity,1))}.dark\\:\\[\\&_\\[cmdk-group-heading\\]\\]\\:rf-text-zinc-400 [cmdk-group-heading]:is(.rf-dark *){--tw-text-opacity:1;color:rgb(161 161 170/var(--tw-text-opacity,1))}.\\[\\&_\\[cmdk-group\\]\\:not\\(\\[hidden\\]\\)_\\~\\[cmdk-group\\]\\]\\:rf-pt-0 [cmdk-group]:not([hidden])~[cmdk-group]{padding-top:0}.\\[\\&_\\[cmdk-group\\]\\]\\:rf-px-2 [cmdk-group]{padding-left:.5rem;padding-right:.5rem}.\\[\\&_\\[cmdk-input-wrapper\\]_svg\\]\\:rf-h-5 [cmdk-input-wrapper] svg{height:1.25rem}.\\[\\&_\\[cmdk-input-wrapper\\]_svg\\]\\:rf-w-5 [cmdk-input-wrapper] svg{width:1.25rem}.\\[\\&_\\[cmdk-input\\]\\]\\:rf-h-12 [cmdk-input]{height:3rem}.\\[\\&_\\[cmdk-item\\]\\]\\:rf-px-2 [cmdk-item]{padding-left:.5rem;padding-right:.5rem}.\\[\\&_\\[cmdk-item\\]\\]\\:rf-py-3 [cmdk-item]{padding-bottom:.75rem;padding-top:.75rem}.\\[\\&_\\[cmdk-item\\]_svg\\]\\:rf-h-5 [cmdk-item] svg{height:1.25rem}.\\[\\&_\\[cmdk-item\\]_svg\\]\\:rf-w-5 [cmdk-item] svg{width:1.25rem}.\\[\\&_svg\\]\\:rf-pointer-events-none svg{pointer-events:none}.\\[\\&_svg\\]\\:rf-size-4 svg{height:1rem;width:1rem}.\\[\\&_svg\\]\\:rf-shrink-0 svg{flex-shrink:0}',Kdt=()=>{fe.useEffect(()=>{if(document.querySelector('style[data-styles="tscircuit-runframe"]'))return;const e=document.createElement("style");e.setAttribute("data-styles","tscircuit-runframe"),e.textContent=qFn,document.head.appendChild(e)},[])},XFn=n=>{fe.useEffect(()=>(n?document.body.style.overflow="hidden":document.body.style.overflow="",()=>{document.body.style.overflow=""}),[n])};function Zdt(n,e){const[t,i]=fe.useState(()=>{try{const r=window.localStorage.getItem(n);return r?JSON.parse(r):e}catch(r){return console.error("Error reading from localStorage:",r),e}});return fe.useEffect(()=>{try{window.localStorage.setItem(n,JSON.stringify(t))}catch(r){console.error("Error writing to localStorage:",r)}},[n,t]),[t,i]}const Qdt=n=>`hsl(${KS.indexOf(n)*137.5%360}, 70%, 50%)`,WFn=({phaseTimings:n})=>{if(!n)return null;const e=Object.values(n).reduce((t,i)=>t+i,0);return ce.jsxs("div",{className:"rf-space-y-2 rf-w-full rf-px-4",children:[ce.jsx("div",{className:"rf-relative rf-h-8 rf-flex rf-rounded-sm",children:KS.map(t=>{const i=n[t]||0,r=i/e*100;return ce.jsx("div",{className:"rf-group/bar rf-relative rf-overflow-visible",style:{width:`${r}%`,backgroundColor:Qdt(t)},children:ce.jsxs("div",{className:"rf-opacity-0 group-hover/bar:rf-opacity-100 rf-transition-opacity rf-absolute rf-bottom-full rf-left-1/2 rf-transform -rf-translate-x-1/2 rf-mb-2 rf-px-2 rf-py-1 rf-text-xs rf-whitespace-nowrap rf-rounded rf-bg-gray-900 rf-text-white rf-pointer-events-none",children:[t,": ",i.toFixed(1),"ms"]})},t)})}),ce.jsxs("div",{className:"rf-text-xs rf-text-gray-500",children:["Total: ",e.toFixed(2),"ms"]})]})},KFn=n=>{if(n instanceof Blob)return n;if(n==null)return"";if(typeof n=="string")return n;if(typeof n=="object")try{return JSON.stringify(n,null,2)}catch{return String(n)}return String(n)},ZFn=({renderLog:n,onRerunWithDebug:e})=>{const[t,i]=fe.useState("chronological"),[r,o]=fe.useState(""),s=[{value:"",label:"None"},{value:"DEBUG=Group_doInitialSchematicTraceRender",label:"DEBUG=Group_doInitialSchematicTraceRender"},{value:"DEBUG=Group_doInitialSchematicLayoutMatchpack",label:"DEBUG=Group_doInitialSchematicLayoutMatchpack"},{value:"DEBUG=Group_doInitialPcbLayoutPack",label:"DEBUG=Group_doInitialPcbLayoutPack"}];if(!n)return ce.jsxs("div",{className:"rf-p-4 rf-bg-gray-100 rf-rounded-md",children:[ce.jsx("div",{className:"rf-mb-4",children:"No render log, make sure this tab is open when you render"}),e&&ce.jsxs("div",{className:"rf-flex rf-gap-2 rf-items-center",children:[ce.jsx("select",{value:r,onChange:l=>o(l.target.value),className:"rf-px-3 rf-py-1 rf-border rf-rounded rf-text-xs rf-bg-white",children:s.map(l=>ce.jsx("option",{value:l.value,children:l.label},l.value))}),ce.jsx(H_,{onClick:()=>e(r),size:"sm",className:"rf-text-xs",children:"Rerun Render with Debug"})]})]});const a=Object.entries(n?.phaseTimings??{});t==="chronological"?a.sort((l,u)=>KS.indexOf(l[0])-KS.indexOf(u[0])):a.sort((l,u)=>u[1]-l[1]);const c=a.reduce((l,[u,d])=>l+d,0);return ce.jsxs("div",{className:"rf-bg-white",children:[ce.jsxs("div",{className:"rf-flex rf-justify-between rf-items-center rf-mb-4",children:[ce.jsx("div",{children:"Render Logs"}),ce.jsxs("div",{className:"rf-flex rf-gap-4 rf-items-center",children:[e&&ce.jsxs("div",{className:"rf-flex rf-gap-2 rf-items-center",children:[ce.jsx("select",{value:r,onChange:l=>o(l.target.value),className:"rf-px-3 rf-py-1 rf-border rf-rounded rf-text-xs rf-bg-white",children:s.map(l=>ce.jsx("option",{value:l.value,children:l.label},l.value))}),ce.jsx(H_,{onClick:()=>e(r),size:"sm",className:"rf-text-xs",children:"Rerun Render with Debug"})]}),ce.jsx("div",{className:"rf-flex rf-gap-2 rf-items-center",children:ce.jsxs("select",{onChange:l=>{if(l.target.value){const u=n?.debugOutputs?.find(d=>d.name===l.target.value);if(u){const d=KFn(u.content),h=d instanceof Blob?d:new Blob([d],{type:"text/plain"}),p=URL.createObjectURL(h),m=document.createElement("a");m.href=p,m.download=`debug-${u.name}.txt`,document.body.appendChild(m),m.click(),document.body.removeChild(m),URL.revokeObjectURL(p)}l.target.value=""}},disabled:!n?.debugOutputs||n.debugOutputs.length===0,className:"rf-px-3 rf-py-1 rf-border rf-rounded rf-text-xs rf-bg-white disabled:rf-opacity-50 disabled:rf-cursor-not-allowed",children:[ce.jsx("option",{value:"",children:"Download Debug Output"}),n?.debugOutputs?.map(l=>ce.jsx("option",{value:l.name,children:l.name},l.name))]})}),ce.jsxs("div",{className:"rf-flex rf-text-xs rf-items-center",children:[ce.jsx("div",{className:"rf-mr-2",children:"Sort by:"}),ce.jsxs("select",{value:t,onChange:l=>i(l.target.value),className:"rf-px-2 rf-py-1 rf-border rf-rounded rf-text-xs",children:[ce.jsx("option",{value:"chronological",children:"Phase Order"}),ce.jsx("option",{value:"longest",children:"Duration"})]})]})]})]}),ce.jsx(WFn,{phaseTimings:n.phaseTimings}),ce.jsxs("table",{className:"rf-w-full rf-text-xs",children:[ce.jsx("thead",{children:ce.jsxs("tr",{children:[ce.jsx("th",{className:"rf-text-left rf-p-2",children:"Phase Order"}),ce.jsx("th",{className:"rf-text-left rf-p-2",children:"Phase"}),ce.jsx("th",{className:"rf-text-left rf-p-2",children:"Duration (ms)"})]})}),ce.jsx("tbody",{children:a.map(([l,u])=>ce.jsxs("tr",{children:[ce.jsx("td",{className:"rf-p-2",children:KS.indexOf(l)}),ce.jsx("td",{className:"rf-p-2",children:l}),ce.jsx("td",{className:"rf-p-2",children:ce.jsx("div",{className:"rf-w-8",children:ce.jsx("div",{className:"rf-h-2 rf-rounded-sm",style:{backgroundColor:Qdt(l),width:`${u/c*100}%`}})})}),ce.jsx("td",{className:"rf-p-2",children:ce.jsxs("div",{className:"rf-flex w-full",children:[ce.jsxs("span",{className:"rf-flex-grow",children:[u,"ms"]}),ce.jsxs("span",{className:"rf-text-gray-500 rf-pr-2",children:[(u/c*100).toFixed(1),"%"]})]})})]},l))})]})]})},Jdt=({errorMessage:n,errorStack:e,circuitJsonErrors:t})=>{fe.useEffect(()=>{if(n){const i=new Error(n);e&&(i.stack=e);try{Lz.captureException(i)}catch{}}},[n,e]),fe.useEffect(()=>{if(t&&t.length>0)for(const i of t){const r=new Error(i.message||"Circuit JSON Error");i.stack&&(r.stack=i.stack);try{Lz.captureException(r,{error_type:i.type})}catch{}}},[t])},eht="0.0.1210",QFn={version:eht},bbe={BASE_URL:"/",DEV:!1,MODE:"production",PROD:!0,SSR:!1},vbe=new Map,LY=n=>{const e=vbe.get(n);return e?Object.fromEntries(Object.entries(e.stores).map(([t,i])=>[t,i.getState()])):{}},JFn=(n,e,t)=>{if(n===void 0)return{type:"untracked",connection:e.connect(t)};const i=vbe.get(t.name);if(i)return{type:"tracked",store:n,...i};const r={connection:e.connect(t),stores:{}};return vbe.set(t.name,r),{type:"tracked",store:n,...r}},tht=(n,e={})=>(t,i,r)=>{const{enabled:o,anonymousActionType:s,store:a,...c}=e;let l;try{l=(o??(bbe?"production":void 0)!=="production")&&window.__REDUX_DEVTOOLS_EXTENSION__}catch{}if(!l)return(bbe?"production":void 0)!=="production"&&o&&console.warn("[zustand devtools middleware] Please install/enable Redux devtools extension"),n(t,i,r);const{connection:u,...d}=JFn(a,l,c);let h=!0;r.setState=(_,g,x)=>{const b=t(_,g);if(!h)return b;const w=x===void 0?{type:s||"anonymous"}:typeof x=="string"?{type:x}:x;return a===void 0?(u?.send(w,i()),b):(u?.send({...w,type:`${a}/${w.type}`},{...LY(c.name),[a]:r.getState()}),b)};const p=(..._)=>{const g=h;h=!1,t(..._),h=g},m=n(r.setState,i,r);if(d.type==="untracked"?u?.init(m):(d.stores[d.store]=r,u?.init(Object.fromEntries(Object.entries(d.stores).map(([_,g])=>[_,_===d.store?m:g.getState()])))),r.dispatchFromDevtools&&typeof r.dispatch=="function"){let _=!1;const g=r.dispatch;r.dispatch=(...x)=>{(bbe?"production":void 0)!=="production"&&x[0].type==="__setState"&&!_&&(console.warn('[zustand devtools middleware] "__setState" action type is reserved to set state from the devtools. Avoid using it.'),_=!0),g(...x)}}return u.subscribe(_=>{var g;switch(_.type){case"ACTION":if(typeof _.payload!="string"){console.error("[zustand devtools middleware] Unsupported action format");return}return wbe(_.payload,x=>{if(x.type==="__setState"){if(a===void 0){p(x.state);return}Object.keys(x.state).length!==1&&console.error(`
5814
5814
  [zustand devtools middleware] Unsupported __setState action format.
5815
5815
  When using 'store' option in devtools(), the 'state' should have only one key, which is a value of 'store' that was passed in devtools(),
5816
5816
  and value of this only key should be a state object. Example: { "type": "__setState", "state": { "abc123Store": { "foo": "bar" } } }