@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.
package/dist/standalone.min.js
CHANGED
|
@@ -5116,7 +5116,7 @@ ${c.join(`
|
|
|
5116
5116
|
${_}polygon: ${m.polygon.vertices}
|
|
5117
5117
|
`:c+=`
|
|
5118
5118
|
`,m.children.length>0&&u.push(m.children)}return c}};e.exports=s}}),tbn=gt({"node_modules/@jscad/modeling/src/operations/booleans/trees/Tree.js"(n,e){var t=Z1n(),i=ebn(),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}}),rge=gt({"node_modules/@jscad/modeling/src/operations/booleans/trees/index.js"(n,e){e.exports={Tree:tbn()}}}),nbn=gt({"node_modules/@jscad/modeling/src/operations/booleans/intersectGeom3Sub.js"(n,e){var t=qa(),i=ige(),{Tree:r}=rge(),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}}),Pet=gt({"node_modules/@jscad/modeling/src/operations/booleans/intersectGeom3.js"(n,e){var t=Na(),i=bL(),r=nbn(),o=(...s)=>{s=t(s);let a=s.shift();return s.forEach(c=>{a=r(a,c)}),a=i(a),a};e.exports=o}}),ibn=gt({"node_modules/@jscad/modeling/src/operations/booleans/intersectGeom2.js"(n,e){var t=Na(),i=qa(),r=WM(),o=tge(),s=nge(),a=Pet(),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}}),rbn=gt({"node_modules/@jscad/modeling/src/operations/booleans/intersect.js"(n,e){var t=Na(),i=xL(),r=Ya(),o=qa(),s=ibn(),a=Pet(),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}}),obn=gt({"node_modules/@jscad/modeling/src/operations/booleans/scissionGeom3.js"(n,e){var t=Ko(),i=WM(),r=qa(),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,S)=>{w.vertices.forEach(I=>{s(p,t.snap(m,I,u),S)})});const _=d.map(w=>{let S=[];return w.vertices.forEach(I=>{S=S.concat(a(p,t.snap(m,I,u)))}),{e:1,d:o(S)}});p.clear();let y=0;const x=_.length;for(let w=0;w<x;w++){const S=_[w];if(S.e>0){const I=new Array(h);I[w]=!0;do y=0,I.forEach((A,R)=>{const M=_[R];if(M.e>0){M.e=-1;for(let k=0;k<M.d.length;k++)I[M.d[k]]=!0;y++}});while(y>0);S.indexes=I}}const b=[];for(let w=0;w<x;w++)if(_[w].indexes){const S=[];_[w].indexes.forEach((I,A)=>S.push(d[A])),b.push(r.create(S))}return b};e.exports=c}}),sbn=gt({"node_modules/@jscad/modeling/src/operations/booleans/scission.js"(n,e){var t=Na(),i=qa(),r=obn(),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}}),abn=gt({"node_modules/@jscad/modeling/src/operations/booleans/subtractGeom3Sub.js"(n,e){var t=qa(),i=ige(),{Tree:r}=rge(),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}}),Ret=gt({"node_modules/@jscad/modeling/src/operations/booleans/subtractGeom3.js"(n,e){var t=Na(),i=bL(),r=abn(),o=(...s)=>{s=t(s);let a=s.shift();return s.forEach(c=>{a=r(a,c)}),a=i(a),a};e.exports=o}}),cbn=gt({"node_modules/@jscad/modeling/src/operations/booleans/subtractGeom2.js"(n,e){var t=Na(),i=qa(),r=WM(),o=tge(),s=nge(),a=Ret(),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}}),lbn=gt({"node_modules/@jscad/modeling/src/operations/booleans/subtract.js"(n,e){var t=Na(),i=xL(),r=Ya(),o=qa(),s=cbn(),a=Ret(),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}}),Iet=gt({"node_modules/@jscad/modeling/src/operations/booleans/unionGeom3Sub.js"(n,e){var t=qa(),i=ige(),{Tree:r}=rge(),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}}),Net=gt({"node_modules/@jscad/modeling/src/operations/booleans/unionGeom3.js"(n,e){var t=Na(),i=bL(),r=Iet(),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}}),ket=gt({"node_modules/@jscad/modeling/src/operations/booleans/unionGeom2.js"(n,e){var t=Na(),i=qa(),r=WM(),o=tge(),s=nge(),a=Net(),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}}),oge=gt({"node_modules/@jscad/modeling/src/operations/booleans/union.js"(n,e){var t=Na(),i=xL(),r=Ya(),o=qa(),s=ket(),a=Net(),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}}),vL=gt({"node_modules/@jscad/modeling/src/operations/booleans/index.js"(n,e){e.exports={intersect:rbn(),scission:sbn(),subtract:lbn(),union:oge()}}}),CV=gt({"node_modules/@jscad/modeling/src/operations/expansions/offsetFromPoints.js"(n,e){var{EPS:t,TAU:i}=mu(),r=set(),o=Wye(),s=wc(),a=EV(),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 y=l.closed?a(u):1;y===0&&(y=1);const x=y>0&&h>=0||y<0&&h<0;h=Math.abs(h);let b=null,w=[];const S=[],I=s.create(),A=u.length;for(let R=0;R<A;R++){const M=(R+1)%A,k=u[R],C=u[M];x?s.subtract(I,k,C):s.subtract(I,C,k),s.normal(I,I),s.normalize(I,I),s.scale(I,I,h);const U=s.add(s.create(),k,I),O=s.add(s.create(),C,I),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):S.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 R=w[0],M=w[1],k=r(b[0],b[1],R,M);if(k)w[0]=k,w.pop();else{const C=u[0],U=[R,M];S.push({c:C,s0:b,s1:U})}}if(p==="edge"){const R=new Map;w.forEach((C,U)=>R.set(C,U));const M=o.create(),k=o.create();S.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=R.get(O);w[H]=U,w[(H+1)%w.length]=void 0}else{const O=C.s1[0],H=R.get(O);w[H]=void 0}}),w=w.filter(C=>C!==void 0)}if(p==="round"){let R=Math.floor(_/4);const M=s.create();S.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){R=Math.floor(_*(Math.abs(C)/i));const U=C/R,O=s.angle(s.subtract(M,k.s0[1],k.c)),H=[];for(let Y=1;Y<R;Y++){const X=O+U*Y,K=s.fromAngleRadians(s.create(),X);s.scale(K,K,h),s.add(K,K,k.c),H.push(K)}if(H.length>0){const Y=k.s0[1];let X=w.findIndex(K=>s.equals(Y,K));X=(X+1)%w.length,w.splice(X,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}}),ubn=gt({"node_modules/@jscad/modeling/src/operations/expansions/expandGeom2.js"(n,e){var t=Ya(),i=CV(),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}}),dbn=gt({"node_modules/@jscad/modeling/src/operations/expansions/extrudePolygon.js"(n,e){var t=Df(),i=Ko(),r=qa(),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}}),hbn=gt({"node_modules/@jscad/modeling/src/operations/expansions/expandShell.js"(n,e){var{EPS:t,TAU:i}=mu(),r=Df(),o=Ko(),s=Cet(),a=qa(),c=Gl(),l=xet(),u=bL(),d=Iet(),h=dbn(),p=(x,b,w)=>{const S=b.toString();if(x.has(S))x.get(S)[1].push(w);else{const I=[b,[w]];x.set(S,I)}},m=(x,b,w)=>{const S=b[0].toString(),I=b[1].toString(),A=S<I?`${S},${I}`:`${I},${S}`;if(x.has(A))x.get(A)[1].push(w);else{const R=[b,[w]];x.set(A,R)}},_=(x,b)=>{x.findIndex(S=>S===b)<0&&x.push(b)},y=(x,b)=>{const w={delta:1,segments:12},{delta:S,segments:I}=Object.assign({},w,x);let A=a.create();const R=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*S),X=c.transform(r.fromTranslation(r.create(),o.scale(o.create(),Y,-.5)),O),K=h(Y,X);A=d(A,K);const J=O.vertices;for(let le=0;le<J.length;le++){p(R,J[le],c.plane(O));const he=(le+1)%J.length,ve=[J[le],J[he]];m(M,ve,c.plane(O))}}),M.forEach(O=>{const H=O[0],Y=O[1],X=H[0],K=H[1],J=o.subtract(o.create(),K,X);o.normalize(J,J);const le=Y[0],he=o.cross(o.create(),le,J);let ve=[];for(let Ae=0;Ae<I;Ae++)_(ve,Ae*i/I);for(let Ae=0,se=Y.length;Ae<se;Ae++){const Se=Y[Ae],xe=o.dot(he,Se),Ve=o.dot(le,Se);let tt=Math.atan2(xe,Ve);tt<0&&(tt+=i),_(ve,tt),tt=Math.atan2(-xe,-Ve),tt<0&&(tt+=i),_(ve,tt)}ve=ve.sort(s);const oe=ve.length;let ae,de;const Te=[],Ce=[],Oe=[];for(let Ae=-1;Ae<oe;Ae++){const se=ve[Ae<0?Ae+oe:Ae],Se=Math.sin(se),xe=Math.cos(se);o.scale(k,le,xe*S),o.scale(C,he,Se*S),o.add(k,k,C);const Ve=o.add(o.create(),X,k),tt=o.add(o.create(),K,k);let ct=!1;if(Ae>=0&&o.distance(Ve,ae)<t&&(ct=!0),!ct){if(Ae>=0){Te.push(Ve),Ce.push(tt);const Me=[de,tt,Ve,ae],Qe=c.create(Me);Oe.push(Qe)}ae=Ve,de=tt}}Ce.reverse(),Oe.push(c.create(Te)),Oe.push(c.create(Ce));const $e=a.create(Oe);A=d(A,$e)}),R.forEach(O=>{const H=O[0],Y=O[1],X=Y[0];let K=null,J=0;for(let oe=1;oe<Y.length;oe++){const ae=Y[oe],de=o.cross(k,X,ae),Te=o.length(de);Te>.05&&Te>J&&(J=Te,K=ae)}K||(K=o.orthogonal(k,X));const le=o.cross(k,X,K);o.normalize(le,le);const he=o.cross(C,le,X),ve=l({center:[H[0],H[1],H[2]],radius:S,segments:I,axes:[X,le,he]});A=d(A,ve)}),u(A)};e.exports=y}}),pbn=gt({"node_modules/@jscad/modeling/src/operations/expansions/expandGeom3.js"(n,e){var t=qa(),i=oge(),r=hbn(),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}}),fbn=gt({"node_modules/@jscad/modeling/src/operations/expansions/expandPath2.js"(n,e){var t=EV(),i=wc(),r=Ya(),o=Qp(),s=CV(),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))),y=r.toSides(r.fromPoints(o.toPoints(m)));return _.push(...y),r.create(_)},c=(u,d,h,p)=>{const{points:m,external:_,internal:y}=u,x=Math.floor(d/2),b=[],w=[];if(h==="round"&&x>0){const I=Math.PI/x,A=m[m.length-1],R=i.angle(i.subtract(i.create(),_[_.length-1],A)),M=m[0],k=i.angle(i.subtract(i.create(),y[0],M));for(let C=1;C<x;C++){let U=R+I*C,O=i.fromAngleRadians(i.create(),U);i.scale(O,O,p),i.add(O,O,A),b.push(O),U=k+I*C,O=i.fromAngleRadians(i.create(),U),i.scale(O,O,p),i.add(O,O,M),w.push(O)}}const S=[];return S.push(..._,...b,...y.reverse(),...w),r.fromPoints(S)},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 y=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:y},x),internal:s({delta:-p,corners:m,segments:_,closed:y},x)};return d.isClosed?a(b):c(b,_,m,p)};e.exports=l}}),sge=gt({"node_modules/@jscad/modeling/src/operations/expansions/expand.js"(n,e){var t=Na(),i=Ya(),r=qa(),o=Qp(),s=ubn(),a=pbn(),c=fbn(),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}}),mbn=gt({"node_modules/@jscad/modeling/src/operations/expansions/offsetGeom2.js"(n,e){var t=Ya(),i=Vye(),r=CV(),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((_,y)=>_.concat(t.toSides(t.fromPoints(y))),[]);return t.create(m)};e.exports=o}}),_bn=gt({"node_modules/@jscad/modeling/src/operations/expansions/offsetPath2.js"(n,e){var t=Qp(),i=CV(),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}}),ybn=gt({"node_modules/@jscad/modeling/src/operations/expansions/offset.js"(n,e){var t=Na(),i=Ya(),r=Qp(),o=mbn(),s=_bn(),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}}),wL=gt({"node_modules/@jscad/modeling/src/operations/expansions/index.js"(n,e){e.exports={expand:sge(),offset:ybn()}}}),AV=gt({"node_modules/@jscad/modeling/src/operations/extrusions/extrudeLinearGeom2.js"(n,e){var t=Df(),i=Ko(),r=Ya(),o=uI(),s=MV(),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),y=r.toSides(l);if(y.length===0)throw new Error("the given geometry cannot be empty");const x=o.fromSides(y);_[2]<0&&o.reverse(x,x);const b=t.create(),w=(S,I,A)=>{const R=I/p*h,M=i.scale(i.create(),_,I/p);return t.multiply(b,t.fromZRotation(b,R),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}}),gbn=gt({"node_modules/@jscad/modeling/src/operations/extrusions/extrudeLinearPath2.js"(n,e){var t=Ya(),i=Qp(),r=AV(),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}}),xbn=gt({"node_modules/@jscad/modeling/src/operations/extrusions/extrudeLinear.js"(n,e){var t=Na(),i=Ya(),r=Qp(),o=AV(),s=gbn(),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(y=>r.isA(y)?s(c,y):i.isA(y)?o(c,y):y);return _.length===1?_[0]:_};e.exports=a}}),bbn=gt({"node_modules/@jscad/modeling/src/operations/extrusions/extrudeRectangularPath2.js"(n,e){var t=Qp(),i=sge(),r=AV(),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}}),vbn=gt({"node_modules/@jscad/modeling/src/operations/extrusions/extrudeRectangularGeom2.js"(n,e){var{area:t}=mL(),i=Ya(),r=Qp(),o=sge(),s=AV(),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)),[]),y=i.create(_);return s(c,y)};e.exports=a}}),wbn=gt({"node_modules/@jscad/modeling/src/operations/extrusions/extrudeRectangular.js"(n,e){var t=Na(),i=Ya(),r=Qp(),o=bbn(),s=vbn(),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}}),Sbn=gt({"node_modules/@jscad/modeling/src/operations/extrusions/extrudeHelical.js"(n,e){var{TAU:t}=mu(),i=uI(),r=Df(),o=MV(),s=Ya(),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 S=Math.round(p/t*Math.abs(d)),I=S>=2?S:2,A=r.create();let R;const M=(k,C,U)=>{const O=m+d/I*C,H=h/I*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))),R=r.create(),r.multiply(R,r.fromZRotation(r.create(),O),A),i.transform(R,U)};return o({numberOfSlices:I+1,callback:M},w)};e.exports=a}}),Ebn=gt({"node_modules/@jscad/modeling/src/operations/extrusions/project.js"(n,e){var t=Na(),i=Xye(),r=pT(),o=Df(),s=Ya(),a=qa(),c=Gl(),l=WM(),u=ket(),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 y=l(m),x=y*y*Math.sqrt(3)/4;if(y===0)return s.create();const b=a.toPolygons(m);let w=[];for(let I=0;I<b.length;I++){const A=b[I].vertices.map(k=>r.projectionOfPoint(_,k)),R=c.create(A),M=c.plane(R);i(_,M)&&(c.measureArea(R)<x||w.push(R))}if(!i(_,[0,0,1])){const I=o.fromVectorRotation(o.create(),_,[0,0,1]);w=w.map(A=>c.transform(I,A))}w=w.sort((I,A)=>c.measureArea(A)-c.measureArea(I));const S=w.map(I=>s.fromPoints(I.vertices));return u(S)},h=(p,...m)=>{const _={axis:[0,0,1],origin:[0,0,0]},{axis:y,origin:x}=Object.assign({},_,p);if(m=t(m),m.length===0)throw new Error("wrong number of arguments");p={axis:y,origin:x};const b=m.map(w=>a.isA(w)?d(p,w):w);return b.length===1?b[0]:b};e.exports=h}}),v4=gt({"node_modules/@jscad/modeling/src/operations/extrusions/index.js"(n,e){e.exports={extrudeFromSlices:MV(),extrudeLinear:xbn(),extrudeRectangular:wbn(),extrudeRotate:Eet(),extrudeHelical:Sbn(),project:Ebn(),slice:uI()}}}),age=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}}),cge=gt({"node_modules/@jscad/modeling/src/operations/hulls/toUniquePoints.js"(n,e){var t=Ya(),i=qa(),r=Qp(),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}}),Tbn=gt({"node_modules/@jscad/modeling/src/operations/hulls/hullPath2.js"(n,e){var t=Na(),i=Qp(),r=age(),o=cge(),s=(...a)=>{a=t(a);const c=o(a),l=r(c);return i.fromPoints({closed:!0},l)};e.exports=s}}),Mbn=gt({"node_modules/@jscad/modeling/src/operations/hulls/hullGeom2.js"(n,e){var t=Na(),i=Ya(),r=age(),o=cge(),s=(...a)=>{a=t(a);const c=o(a),l=r(c);return l.length<3?i.create():i.fromPoints(l)};e.exports=s}}),Oet=gt({"node_modules/@jscad/modeling/src/operations/hulls/hullPoints3.js"(n,e){var t=Gl(),i=IJe(),r=o=>i(o,{skipTriangulation:!0}).map(c=>{const l=c.map(u=>o[u]);return t.create(l)});e.exports=r}}),Cbn=gt({"node_modules/@jscad/modeling/src/operations/hulls/hullGeom3.js"(n,e){var t=Na(),i=qa(),r=cge(),o=Oet(),s=(...a)=>{a=t(a);const c=r(a);return c.length===0?i.create():i.create(o(c))};e.exports=s}}),Let=gt({"node_modules/@jscad/modeling/src/operations/hulls/hull.js"(n,e){var t=Na(),i=xL(),r=Ya(),o=qa(),s=Qp(),a=Tbn(),c=Mbn(),l=Cbn(),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}}),Abn=gt({"node_modules/@jscad/modeling/src/operations/hulls/hullChain.js"(n,e){var t=Na(),i=oge(),r=Let(),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}}),Pbn=gt({"node_modules/@jscad/modeling/src/operations/hulls/index.js"(n,e){e.exports={hull:Let(),hullChain:Abn(),hullPoints2:age(),hullPoints3:Oet()}}}),Det=gt({"node_modules/@jscad/modeling/src/operations/modifiers/snapPolygons.js"(n,e){var t=Ko(),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}}),Rbn=gt({"node_modules/@jscad/modeling/src/operations/modifiers/mergePolygons.js"(n,e){var t=Xye(),i=Ko(),r=Gl(),o=x=>{const b=r.toPoints(x),w=[];for(let S=0;S<b.length;S++){const I=(S+1)%b.length,A={v1:b[S],v2:b[I]};w.push(A)}for(let S=0;S<w.length;S++){const I=(S+1)%b.length;w[S].next=w[I],w[I].prev=w[S]}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 S=x.prev.v1,I=x.prev.v2,A=b.next.v2;const R=h(S,I,A,w);S=b.prev.v1,I=b.prev.v2,A=x.next.v2;const M=h(S,I,A,w);return[R,M]},u=i.create(),d=i.create(),h=(x,b,w,S)=>{const I=i.subtract(u,b,x),A=i.subtract(d,w,b);return i.cross(I,I,A),i.dot(I,S)},p=x=>{let b;const w=[];for(;x.next;){const S=x.next;w.push(x.v1),x.v1=null,x.v2=null,x.next=null,x.prev=null,x=S}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(),S=new Map;for(;w.length>0;){const A=w.shift(),R=o(A);for(let M=0;M<R.length;M++){const k=R[M],C=c(S,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(S,C),C.v1=null,C.v2=null,C.next=null,C.prev=null;const Y=(X,K,J)=>{const le={v1:J.v1,v2:K.v2,next:K.next,prev:J.prev};J.prev.next=le,K.next.prev=le,a(X,K),K.v1=null,K.v2=null,K.next=null,K.prev=null,a(X,J),J.v1=null,J.v2=null,J.next=null,J.prev=null};U[0]===0&&Y(S,O,O.prev),U[1]===0&&Y(S,H,H.prev)}}else k.next&&s(S,k)}}const I=[];return S.forEach(A=>{const R=p(A);R&&I.push(R)}),S.clear(),I},_=(x,b)=>Math.abs(x[3]-b[3])<15e-8?t(x,b):!1,y=(x,b)=>{const w=[];b.forEach(I=>{const A=w.find(R=>_(R[0],r.plane(I)));A?A[1].push(I):w.push([r.plane(I),[I]])});let S=[];return w.forEach(I=>{const A=I[1],R=m(A);S=S.concat(R)}),S};e.exports=y}}),Ibn=gt({"node_modules/@jscad/modeling/src/operations/modifiers/insertTjunctions.js"(n,e){var t=mu(),i=Ko(),r=Gl(),o=l=>`${l}`,s=(l,u,d,h,p,m)=>{const _=o(h),y=o(p),x=`${_}/${y}`,b=`${y}/${_}`;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(y)?d.get(y).push(x):d.set(y,[x]),x},a=(l,u,d,h,p,m)=>{const _=o(h),y=o(p),x=`${_}/${y}`;let b=-1;const w=l.get(x);for(let S=0;S<w.length;S++){const I=w[S];let A=o(I.vertex0);if(A===_&&(A=o(I.vertex1),A===y&&!(m!==null&&I.polygonindex!==m))){b=S;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(y).indexOf(x),d.get(y).splice(b,1),d.get(y).length===0&&d.delete(y)},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 y=0;y<p;y++){let x=y+1;x===p&&(x=0);const b=h.vertices[x],w=o(b),S=`${_}/${w}`,I=`${w}/${_}`;if(u.has(I)){const A=u.get(I);A.splice(-1,1),A.length===0&&u.delete(I)}else{const A={vertex0:m,vertex1:b,polygonindex:d};u.has(S)?u.get(S).push(A):u.set(S,[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[_,y]of u)p.set(_,!0),y.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 y of u.keys())p.set(y,!0);let _=!1;for(;;){const y=Array.from(p.keys());if(y.length===0)break;const x=y[0];let b=!0;if(u.has(x)){const S=u.get(x)[0];for(let I=0;I<2;I++){const A=I===0?S.vertex0:S.vertex1,R=I===0?S.vertex1:S.vertex0,M=o(A),k=o(R);let C=[];I===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=I===0?H.vertex0:H.vertex1;if(I===0?H.vertex1:H.vertex0,o(Y)===k){a(u,d,h,A,R,null),a(u,d,h,R,A,null),b=!1,I=2,_=!0;break}else{const K=A,J=R,le=Y,he=i.subtract(i.create(),le,K),ve=i.dot(i.subtract(i.create(),J,K),he)/i.dot(he,he);if(ve>0&&ve<1){const oe=i.scale(i.create(),he,ve);if(i.add(oe,oe,K),i.squaredDistance(oe,J)<t.EPS*t.EPS){const de=H.polygonindex,Te=m[de],Ce=o(H.vertex1);let Oe=-1;for(let xe=0;xe<Te.vertices.length;xe++)if(o(Te.vertices[xe])===Ce){Oe=xe;break}const $e=Te.vertices.slice(0);$e.splice(Oe,0,R);const Ae=r.create($e);m[de]=Ae,a(u,d,h,H.vertex0,H.vertex1,de);const se=s(u,d,h,H.vertex0,R,de),Se=s(u,d,h,R,H.vertex1,de);se!==null&&p.set(se,!0),Se!==null&&p.set(Se,!0),b=!1,I=2,_=!0;break}}}}}}b&&p.delete(x)}if(!_)break}l=m}return u.clear(),l};e.exports=c}}),Nbn=gt({"node_modules/@jscad/modeling/src/operations/modifiers/triangulatePolygons.js"(n,e){var t=Ko(),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}}),kbn=gt({"node_modules/@jscad/modeling/src/operations/modifiers/generalize.js"(n,e){var t=Na(),i=WM(),r=Ya(),o=qa(),s=Qp(),a=Det(),c=Rbn(),l=Ibn(),u=Nbn(),d=(_,y)=>y,h=(_,y)=>y,p=(_,y)=>{const x={snap:!1,simplify:!1,triangulate:!1},{snap:b,simplify:w,triangulate:S}=Object.assign({},x,_),I=i(y);let A=o.toPolygons(y);b&&(A=a(I,A)),w&&(A=c(I,A)),S&&(A=l(A),A=u(I,A));const R=Object.assign({},y);return R.polygons=A,R},m=(_,...y)=>{if(y=t(y),y.length===0)throw new Error("wrong number of arguments");const x=y.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}}),Obn=gt({"node_modules/@jscad/modeling/src/operations/modifiers/snap.js"(n,e){var t=Na(),i=wc(),r=Ya(),o=qa(),s=Qp(),a=WM(),c=Det(),l=p=>{const m=a(p),y=s.toPoints(p).map(x=>i.snap(i.create(),x,m));return s.create(y)},u=p=>{const m=a(p);let y=r.toSides(p).map(x=>[i.snap(i.create(),x[0],m),i.snap(i.create(),x[1],m)]);return y=y.filter(x=>!i.equals(x[0],x[1])),r.create(y)},d=p=>{const m=a(p),_=o.toPolygons(p),y=c(m,_);return o.create(y)},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}}),Lbn=gt({"node_modules/@jscad/modeling/src/operations/modifiers/index.js"(n,e){e.exports={generalize:kbn(),snap:Obn(),retessellate:bL()}}}),Dbn=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}}),zbn=gt({"node_modules/@jscad/modeling/src/operations/transforms/align.js"(n,e){var t=Na(),i=Dbn(),r=Kye(),{translate:o}=b4(),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(y=>y==null).length){const y=r(d);m=a(m,p,y)}return _?d=c(d,p,m):d=d.map(y=>c(y,p,m)),d.length===1?d[0]:d};e.exports=l}}),PV=gt({"node_modules/@jscad/modeling/src/operations/transforms/center.js"(n,e){var t=Na(),i=Ya(),r=qa(),o=Qp(),s=g4(),{translate:a}=b4(),c=(p,m)=>{const _={axes:[!0,!0,!0],relativeTo:[0,0,0]},{axes:y,relativeTo:x}=Object.assign({},_,p),b=s(m),w=[0,0,0];return y[0]&&(w[0]=x[0]-(b[0][0]+(b[1][0]-b[0][0])/2)),y[1]&&(w[1]=x[1]-(b[0][1]+(b[1][1]-b[0][1])/2)),y[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:y,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:y,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}}}),RV=gt({"node_modules/@jscad/modeling/src/operations/transforms/scale.js"(n,e){var t=Na(),i=Df(),r=Ya(),o=qa(),s=Qp(),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}}}),$bn=gt({"node_modules/@jscad/modeling/src/operations/transforms/transform.js"(n,e){var t=Na(),i=Ya(),r=qa(),o=Qp(),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}}),w4=gt({"node_modules/@jscad/modeling/src/operations/transforms/index.js"(n,e){e.exports={align:zbn(),center:PV().center,centerX:PV().centerX,centerY:PV().centerY,centerZ:PV().centerZ,mirror:yL().mirror,mirrorX:yL().mirrorX,mirrorY:yL().mirrorY,mirrorZ:yL().mirrorZ,rotate:gL().rotate,rotateX:gL().rotateX,rotateY:gL().rotateY,rotateZ:gL().rotateZ,scale:RV().scale,scaleX:RV().scaleX,scaleY:RV().scaleY,scaleZ:RV().scaleZ,transform:$bn(),translate:b4().translate,translateX:b4().translateX,translateY:b4().translateY,translateZ:b4().translateZ}}}),IV=gt({"node_modules/@jscad/modeling/src/index.js"(n,e){e.exports={colors:y4(),curves:Oxn(),geometries:Gye(),maths:o1n(),measurements:p1n(),primitives:W5(),text:ege(),utils:Aet(),booleans:vL(),expansions:wL(),extrusions:v4(),hulls:Pbn(),modifiers:Lbn(),transforms:w4()}}}),Fbn=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 y=p>=m*1.5;return Math.round(h/m)+" "+_+(y?"s":"")}}}),Ubn=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=Fbn(),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,y,x;function b(...w){if(!b.enabled)return;const S=b,I=Number(new Date),A=I-(m||I);S.diff=A,S.prev=m,S.curr=I,m=I,w[0]=o.coerce(w[0]),typeof w[0]!="string"&&w.unshift("%O");let R=0;w[0]=w[0].replace(/%([a-zA-Z%])/g,(k,C)=>{if(k==="%%")return"%";R++;const U=o.formatters[C];if(typeof U=="function"){const O=w[R];k=U.call(S,O),w.splice(R,1),R--}return k}),o.formatArgs.call(S,w),(S.log||o.log).apply(S,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?_:(y!==o.namespaces&&(y=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,y=0,x=-1,b=0;for(;_<p.length;)if(y<m.length&&(m[y]===p[_]||m[y]==="*"))m[y]==="*"?(x=y,b=_,y++):(_++,y++);else if(x!==-1)y=x+1,b++,_=b;else return!1;for(;y<m.length&&m[y]==="*";)y++;return y===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}}),Bbn=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 Dye<"u"&&"env"in Dye&&(c=Dye.env.DEBUG),c}function s(){try{return localStorage}catch{}}e.exports=Ubn()(n);var{formatters:a}=e.exports;a.j=function(c){try{return JSON.stringify(c)}catch(l){return"[UnexpectedJSONParseError]: "+l.message}}}}),zet=ce.createContext(null),yb=()=>{const n=ce.useContext(zet);if(!n)throw new Error("useThree must be used within a ThreeProvider");return n},dI=(n,e=[])=>{const{addFrameListener:t,removeFrameListener:i}=yb();So.useEffect(()=>(t(n),()=>i(n)),[t,i,...e])},$et=ce.createContext(null),jbn=()=>{const n=ce.useContext($et);if(!n)throw new Error("useHover must be used within a HoverProvider");return n},Hbn=({children:n})=>{const{camera:e,renderer:t}=yb(),[i,r]=ce.useState([]),o=ce.useMemo(()=>new zun,[]),s=ce.useMemo(()=>new Fo,[]),a=ce.useRef(i);a.current=i;const c=ce.useRef(null),l=ce.useCallback(m=>{r(_=>[..._,m])},[]),u=ce.useCallback(m=>{if(c.current){let _=!1,y=c.current.object;for(;y;){if(y===m){_=!0;break}y=y.parent}_&&(c.current.onUnhover(),c.current=null)}r(_=>_.filter(y=>y.object!==m))},[]),d=ce.useCallback(m=>{let _=m;for(;_;){const y=a.current.find(x=>x.object===_);if(y)return y;_=_.parent}},[]),h=ce.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 y=a.current.map(b=>b.object);if(y.length===0){c.current&&(c.current.onUnhover(),c.current=null);return}const x=o.intersectObjects(y,!0);if(x.length>0){const b=x[0],w=d(b.object);if(w){const S={mousePosition:[b.point.x,b.point.y,b.point.z]};c.current!==w?(c.current?.onUnhover(),w.onHover(S),c.current=w):w.onHover(S)}else c.current&&(c.current.onUnhover(),c.current=null)}else c.current&&(c.current.onUnhover(),c.current=null)},[e,t,o,s,d]);ce.useEffect(()=>{const m=t.domElement;return m.addEventListener("mousemove",h),()=>{m.removeEventListener("mousemove",h)}},[t,h]);const p=ce.useMemo(()=>({addHoverable:l,removeHoverable:u}),[l,u]);return re.jsx($et.Provider,{value:p,children:n})},Vbn=({children:n,object:e,onHover:t,onUnhover:i,isHovered:r})=>{const{addHoverable:o,removeHoverable:s}=jbn();return ce.useEffect(()=>e?(o({object:e,onHover:t,onUnhover:i}),()=>{s(e)}):void 0,[e,t,i,o,s]),re.jsx(re.Fragment,{children:n})},SL=Vbn;function Gbn(n){return n.replace(/(DEF|USE)\s+([^\s]+)/g,(e,t,i)=>`${t} ${i.replace(/-/g,"_")}`)}async function Ybn(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 Xdn().parse(Gbn(t),n)}typeof window<"u"&&!window.TSCIRCUIT_OBJ_LOADER_CACHE&&(window.TSCIRCUIT_OBJ_LOADER_CACHE=new Map);function qbn(n){const[e,t]=ce.useState(null);return ce.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 Ybn(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 ihn;if(u?.length){const h=u.join(`
|
|
5119
|
-
`).replace(/d 0\./g,"d 1."),p=l.replace(/newmtl[\s\S]*?endmtl/g,"").replace(/^mtllib.*/gm,""),m=new Gdn;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 Xbn({url:n,position:e,rotation:t,onHover:i,onUnhover:r,isHovered:o,scale:s}){const a=qbn(n),{rootObject:c}=yb(),l=ce.useMemo(()=>a&&!(a instanceof Error)?a:new Ra(new eE(.5,.5,.5),new Zb({transparent:!0,color:"red",opacity:.25})),[a]);if(ce.useEffect(()=>{if(!(!c||!l))return c.add(l),()=>{c.remove(l)}},[c,l]),ce.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 re.jsx(SL,{isHovered:o,onHover:i,onUnhover:r,object:l})}var Fet=new WeakMap,Wbn=()=>{const n=new l_;return n.name="fallback-environment-map",n.mapping=Zj,n},Kbn=n=>{if(!n)return null;const e=n,t=Fet.get(e);if(t)return t;let i;if(n instanceof Dle){const r=new Ile(n);i=r.fromScene(adn(),.04).texture,r.dispose()}else i=Wbn();return Fet.set(e,i),i},Uet=1.25;function Zbn({gltfUrl:n,position:e,rotation:t,onHover:i,onUnhover:r,isHovered:o,scale:s}){const{renderer:a,rootObject:c}=yb(),[l,u]=ce.useState(null);return ce.useEffect(()=>{if(!n)return;const d=new ldn;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]),ce.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]),ce.useEffect(()=>{if(!(!c||!l))return c.add(l),()=>{c.remove(l)}},[c,l]),ce.useEffect(()=>{if(!l||!a)return;const d=Kbn(a);if(!d)return;const h=[],p=m=>{m instanceof Zb&&(h.push({material:m,envMap:m.envMap??null,envMapIntensity:m.envMapIntensity??1}),m.envMap||(m.envMap=d),(typeof m.envMapIntensity!="number"||m.envMapIntensity<Uet)&&(m.envMapIntensity=Uet),m.needsUpdate=!0)};return l.traverse(m=>{if(!(m instanceof Ra))return;const _=m.material;Array.isArray(_)?_.forEach(p):_&&p(_)}),()=>{h.forEach(({material:m,envMap:_,envMapIntensity:y})=>{m.envMap=_,m.envMapIntensity=y,m.needsUpdate=!0})}},[l,a]),ce.useEffect(()=>{l&&l.traverse(d=>{d instanceof Ra&&d.material instanceof Zb&&(o?(d.material.emissive.setHex(255),d.material.emissiveIntensity=.2):d.material.emissiveIntensity=0)})},[o,l]),l?re.jsx(SL,{isHovered:o,onHover:i,onUnhover:r,object:l}):null}var Qbn=vc(hJe()),Jbn=vc(IV()),Bet={in:25.4,inch:25.4,mil:.0254,mm:1,m:1e3,cm:10,ft:304.8,feet:304.8},xh=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 Bet)return t*Bet[e];throw new Error(`Unsupported unit: ${e}`)},EL=xh,jet={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}}},lge=new Set;for(const[n,e]of Object.entries(jet)){lge.add(n);for(const t of Object.keys(e.variants))lge.add(t)}function evn(n){for(const[e,t]of Object.entries(jet))if(n in t.variants)return{baseUnit:t.baseUnit,conversionFactor:t.variants[n]};return{baseUnit:n,conversionFactor:1}}var Het={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 iE(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}=iE(n.x),l=iE(n.x),u=iE(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 Het&&!lge.has(i)){const a=Het[i];return{parsedUnit:null,unitOfValue:null,value:Number.parseFloat(r)*a}}const{baseUnit:o,conversionFactor:s}=evn(i);return{parsedUnit:i,unitOfValue:o,value:s*Number.parseFloat(r)}}var uge=N().or(Ie()).transform(n=>iE(n).value),Vet=N().or(Ie()).transform(n=>iE(n).value).transform(n=>Number.parseFloat(n.toPrecision(12))),tvn=N().or(Ie()).transform(n=>iE(n).value),hI=N().or(Ie()).transform(n=>iE(n).value),_t=N().or(Ie()).transform(n=>iE(n).value),dge=N().or(Ie()).transform(n=>iE(n).value),fi=_t;N().or(Ie()).transform(n=>iE(n).value);var hge=N().or(Ie()).transform(n=>iE(n).value),pI=hge,nvn=N().datetime(),uS=N().or(Ie()).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)),ivn=Ie().or(N().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"),Ls=Ee({x:fi,y:fi}),pge=Ee({x:fi,y:fi,z:fi}),Get=Ee({width:Ie(),height:Ie()}),rvn=n=>{const e="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";return Array.from({length:n},()=>e[Math.floor(Math.random()*e.length)]).join("")},Yi=n=>N().optional().default(()=>`${n}_${rvn(10)}`),NV=Xt(["top_left","top_center","top_right","center_left","center","center_right","bottom_left","bottom_center","bottom_right"]),ovn=Xt(["jlcpcb","macrofab","pcbway","digikey","mouser","lcsc"]),jx=Ee({type:me("source_component"),ftype:N().optional(),source_component_id:N(),name:N(),manufacturer_part_number:N().optional(),supplier_part_numbers:os(ovn,ut(N())).optional(),display_value:N().optional(),are_pins_interchangeable:Je().optional(),internally_connected_source_port_ids:ut(ut(N())).optional(),source_group_id:N().optional(),subcircuit_id:N().optional()}),Yet=jx.extend({ftype:me("simple_capacitor"),capacitance:Vet,max_voltage_rating:hI.optional(),display_capacitance:N().optional(),max_decoupling_trace_length:fi.optional()}),qet=jx.extend({ftype:me("simple_resistor"),resistance:uge,display_resistance:N().optional()}),fge=jx.extend({ftype:me("simple_diode")}),Xet=fge.extend({ftype:me("simple_led"),color:N().optional(),wavelength:N().optional()}),svn=jx.extend({ftype:me("simple_ground")}),Wet=jx.extend({ftype:me("simple_chip")}),Ket=jx.extend({ftype:me("simple_power_source"),voltage:hI}),avn=jx.extend({ftype:me("simple_fuse"),current_rating_amps:Ie().describe("Nominal current in amps the fuse is rated for"),voltage_rating_volts:Ie().describe("Voltage rating in volts, e.g. ±5V would be 5")}),Zet=jx.extend({ftype:me("simple_battery"),capacity:ivn}),Qet=jx.extend({ftype:me("simple_inductor"),inductance:tvn,max_current_rating:Ie().optional()}),Jet=jx.extend({ftype:me("simple_push_button")}),ett=jx.extend({ftype:me("simple_potentiometer"),max_resistance:uge}),cvn=jx.extend({ftype:me("simple_crystal"),frequency:Ie().describe("Frequency in Hz"),load_capacitance:Ie().optional().describe("Load capacitance in pF")}),ttt=jx.extend({ftype:me("simple_pin_header"),pin_count:Ie(),gender:Xt(["male","female"]).optional().default("male")}),ntt=jx.extend({ftype:me("simple_pinout")}),itt=jx.extend({ftype:me("simple_resonator"),load_capacitance:Vet,equivalent_series_resistance:uge.optional(),frequency:dge}),rtt=jx.extend({ftype:me("simple_transistor"),transistor_type:Xt(["npn","pnp"])}),ott=jx.extend({ftype:me("simple_test_point"),footprint_variant:Xt(["pad","through_hole"]).optional(),pad_shape:Xt(["rect","circle"]).optional(),pad_diameter:Bn([Ie(),N()]).optional(),hole_diameter:Bn([Ie(),N()]).optional(),width:Bn([Ie(),N()]).optional(),height:Bn([Ie(),N()]).optional()}),stt=jx.extend({ftype:me("simple_mosfet"),channel_type:Xt(["n","p"]),mosfet_mode:Xt(["enhancement","depletion"])}),att=jx.extend({ftype:me("simple_switch")}),ctt=Ee({type:me("source_project_metadata"),name:N().optional(),software_used_string:N().optional(),project_url:N().optional(),created_at:nvn.optional()}),lvn=Ee({type:me("source_missing_property_error"),source_missing_property_error_id:Yi("source_missing_property_error"),source_component_id:N(),property_name:N(),subcircuit_id:N().optional(),error_type:me("source_missing_property_error").default("source_missing_property_error"),message:N()}).describe("The source code is missing a property"),uvn=Ee({type:me("source_failed_to_create_component_error"),source_failed_to_create_component_error_id:Yi("source_failed_to_create_component_error"),error_type:me("source_failed_to_create_component_error").default("source_failed_to_create_component_error"),component_name:N().optional(),subcircuit_id:N().optional(),parent_source_component_id:N().optional(),message:N(),pcb_center:Ee({x:Ie().optional(),y:Ie().optional()}).optional(),schematic_center:Ee({x:Ie().optional(),y:Ie().optional()}).optional()}).describe("Error emitted when a component fails to be constructed"),ltt=Ee({type:me("source_trace_not_connected_error"),source_trace_not_connected_error_id:Yi("source_trace_not_connected_error"),error_type:me("source_trace_not_connected_error").default("source_trace_not_connected_error"),message:N(),subcircuit_id:N().optional(),source_group_id:N().optional(),source_trace_id:N().optional(),connected_source_port_ids:ut(N()).optional(),selectors_not_found:ut(N()).optional()}).describe("Occurs when a source trace selector does not match any ports"),dvn=Ee({type:me("source_property_ignored_warning"),source_property_ignored_warning_id:Yi("source_property_ignored_warning"),source_component_id:N(),property_name:N(),subcircuit_id:N().optional(),error_type:me("source_property_ignored_warning").default("source_property_ignored_warning"),message:N()}).describe("The source property was ignored"),utt=Ee({type:me("source_pin_missing_trace_warning"),source_pin_missing_trace_warning_id:Yi("source_pin_missing_trace_warning"),warning_type:me("source_pin_missing_trace_warning").default("source_pin_missing_trace_warning"),message:N(),source_component_id:N(),source_port_id:N(),subcircuit_id:N().optional()}).describe("Warning emitted when a source component pin is missing a trace connection"),hvn=Bn([qet,Yet,fge,Xet,svn,Wet,Ket,Zet,Qet,Jet,ett,cvn,ttt,ntt,itt,att,rtt,ott,stt,avn,ctt,lvn,uvn,ltt,dvn,utt]),pvn=Ee({type:me("source_port"),pin_number:Ie().optional(),port_hints:ut(N()).optional(),name:N(),source_port_id:N(),source_component_id:N().optional(),source_group_id:N().optional(),subcircuit_id:N().optional(),subcircuit_connectivity_map_key:N().optional()}),fvn=Ee({type:me("source_trace"),source_trace_id:N(),connected_source_port_ids:ut(N()),connected_source_net_ids:ut(N()),subcircuit_id:N().optional(),subcircuit_connectivity_map_key:N().optional(),max_length:Ie().optional(),min_trace_thickness:Ie().optional(),display_name:N().optional()}),mvn=Ee({type:me("source_group"),source_group_id:N(),subcircuit_id:N().optional(),parent_subcircuit_id:N().optional(),parent_source_group_id:N().optional(),is_subcircuit:Je().optional(),show_as_schematic_box:Je().optional(),name:N().optional(),was_automatically_named:Je().optional()}),_vn=Ee({type:me("source_net"),source_net_id:N(),name:N(),member_source_group_ids:ut(N()),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:Ie().optional(),subcircuit_id:N().optional(),subcircuit_connectivity_map_key:N().optional()}),yvn=Ee({type:me("source_board"),source_board_id:N(),source_group_id:N(),title:N().optional()}).describe("Defines a board in the source domain"),gvn=Ee({type:me("source_pcb_ground_plane"),source_pcb_ground_plane_id:N(),source_group_id:N(),source_net_id:N(),subcircuit_id:N().optional()}).describe("Defines a ground plane in the source domain"),xvn=["top","bottom","inner1","inner2","inner3","inner4","inner5","inner6"],dtt=Xt(xvn),Kd=dtt.or(Ee({name:dtt})).transform(n=>typeof n=="string"?n:n.name),fT=Xt(["top","bottom"]),bvn=Ee({type:me("source_manually_placed_via"),source_manually_placed_via_id:N(),source_group_id:N(),source_net_id:N(),subcircuit_id:N().optional(),source_trace_id:N().optional()}).describe("Defines a via that is manually placed in the source domain"),vvn=Ee({type:me("unknown_error_finding_part"),unknown_error_finding_part_id:Yi("unknown_error_finding_part"),error_type:me("unknown_error_finding_part").default("unknown_error_finding_part"),message:N(),source_component_id:N().optional(),subcircuit_id:N().optional()}).describe("Error emitted when an unexpected error occurs while finding a part"),wvn=Ee({type:me("schematic_box"),schematic_component_id:N().optional(),width:fi,height:fi,is_dashed:Je().default(!1),x:fi,y:fi,subcircuit_id:N().optional()}).describe("Draws a box on the schematic"),Svn=Ee({type:me("schematic_path"),schematic_component_id:N(),fill_color:Xt(["red","blue"]).optional(),is_filled:Je().optional(),points:ut(Ls),subcircuit_id:N().optional()}),Evn=os(Ee({left_margin:_t.optional(),right_margin:_t.optional(),top_margin:_t.optional(),bottom_margin:_t.optional()})),Tvn=Ee({left_size:Ie(),right_size:Ie(),top_size:Ie().optional(),bottom_size:Ie().optional()}),Mvn=Ee({left_side:Ee({pins:ut(Ie()),direction:Xt(["top-to-bottom","bottom-to-top"]).optional()}).optional(),right_side:Ee({pins:ut(Ie()),direction:Xt(["top-to-bottom","bottom-to-top"]).optional()}).optional(),top_side:Ee({pins:ut(Ie()),direction:Xt(["left-to-right","right-to-left"]).optional()}).optional(),bottom_side:Ee({pins:ut(Ie()),direction:Xt(["left-to-right","right-to-left"]).optional()}).optional()}),Cvn=Bn([Tvn,Mvn]),Avn=Ee({type:me("schematic_component"),size:Get,center:Ls,source_component_id:N().optional(),schematic_component_id:N(),pin_spacing:_t.optional(),pin_styles:Evn.optional(),box_width:_t.optional(),symbol_name:N().optional(),port_arrangement:Cvn.optional(),port_labels:os(N()).optional(),symbol_display_value:N().optional(),subcircuit_id:N().optional(),schematic_group_id:N().optional(),is_schematic_group:Je().optional(),source_group_id:N().optional(),is_box_with_pins:Je().optional().default(!0)}),Pvn=Ee({type:me("schematic_line"),schematic_line_id:Yi("schematic_line"),schematic_component_id:N(),x1:fi,y1:fi,x2:fi,y2:fi,stroke_width:fi.nullable().optional(),color:N().default("#000000"),is_dashed:Je().default(!1),subcircuit_id:N().optional()}).describe("Draws a styled line on the schematic"),Rvn=Ee({type:me("schematic_rect"),schematic_rect_id:Yi("schematic_rect"),schematic_component_id:N(),center:Ls,width:fi,height:fi,rotation:uS.default(0),stroke_width:fi.nullable().optional(),color:N().default("#000000"),is_filled:Je().default(!1),fill_color:N().optional(),is_dashed:Je().default(!1),subcircuit_id:N().optional()}).describe("Draws a styled rectangle on the schematic"),Ivn=Ee({type:me("schematic_circle"),schematic_circle_id:Yi("schematic_circle"),schematic_component_id:N(),center:Ls,radius:fi,stroke_width:fi.nullable().optional(),color:N().default("#000000"),is_filled:Je().default(!1),fill_color:N().optional(),is_dashed:Je().default(!1),subcircuit_id:N().optional()}).describe("Draws a styled circle on the schematic"),Nvn=Ee({type:me("schematic_arc"),schematic_arc_id:Yi("schematic_arc"),schematic_component_id:N(),center:Ls,radius:fi,start_angle_degrees:uS,end_angle_degrees:uS,direction:Xt(["clockwise","counterclockwise"]).default("counterclockwise"),stroke_width:fi.nullable().optional(),color:N().default("#000000"),is_dashed:Je().default(!1),subcircuit_id:N().optional()}).describe("Draws a styled arc on the schematic"),kvn=Ee({type:me("schematic_trace"),schematic_trace_id:N(),source_trace_id:N().optional(),junctions:ut(Ee({x:Ie(),y:Ie()})),edges:ut(Ee({from:Ee({x:Ie(),y:Ie()}),to:Ee({x:Ie(),y:Ie()}),is_crossing:Je().optional(),from_schematic_port_id:N().optional(),to_schematic_port_id:N().optional()})),subcircuit_id:N().optional(),subcircuit_connectivity_map_key:N().optional()}),Ovn=Xt(["center","left","right","top","bottom"]),Lvn=Ee({type:me("schematic_text"),schematic_component_id:N().optional(),schematic_text_id:N(),text:N(),font_size:Ie().default(.18),position:Ee({x:fi,y:fi}),rotation:Ie().default(0),anchor:Bn([Ovn.describe("legacy"),NV]).default("center"),color:N().default("#000000"),subcircuit_id:N().optional()}),Dvn=Ee({type:me("schematic_port"),schematic_port_id:N(),source_port_id:N(),schematic_component_id:N().optional(),center:Ls,facing_direction:Xt(["up","down","left","right"]).optional(),distance_from_component_edge:Ie().optional(),side_of_component:Xt(["top","bottom","left","right"]).optional(),true_ccw_index:Ie().optional(),pin_number:Ie().optional(),display_pin_label:N().optional(),subcircuit_id:N().optional(),is_connected:Je().optional(),has_input_arrow:Je().optional(),has_output_arrow:Je().optional()}).describe("Defines a port on a schematic component"),zvn=Ee({type:me("schematic_net_label"),schematic_net_label_id:Yi("schematic_net_label"),schematic_trace_id:N().optional(),source_trace_id:N().optional(),source_net_id:N(),center:Ls,anchor_position:Ls.optional(),anchor_side:Xt(["top","bottom","left","right"]),text:N(),symbol_name:N().optional(),is_movable:Je().optional(),subcircuit_id:N().optional()}),$vn=Ee({type:me("schematic_error"),schematic_error_id:N(),error_type:me("schematic_port_not_found").default("schematic_port_not_found"),message:N(),subcircuit_id:N().optional()}).describe("Defines a schematic error on the schematic"),Fvn=Ee({type:me("schematic_layout_error"),schematic_layout_error_id:Yi("schematic_layout_error"),error_type:me("schematic_layout_error").default("schematic_layout_error"),message:N(),source_group_id:N(),schematic_group_id:N(),subcircuit_id:N().optional()}).describe("Error emitted when schematic layout fails for a group"),mge=Ee({type:me("schematic_debug_object"),label:N().optional(),subcircuit_id:N().optional()}),Uvn=mge.extend({shape:me("rect"),center:Ls,size:Get}),Bvn=mge.extend({shape:me("line"),start:Ls,end:Ls}),jvn=mge.extend({shape:me("point"),center:Ls}),Hvn=gm("shape",[Uvn,Bvn,jvn]),Vvn=Ee({type:me("schematic_voltage_probe"),schematic_voltage_probe_id:N(),position:Ls,schematic_trace_id:N(),voltage:hI.optional(),subcircuit_id:N().optional()}).describe("Defines a voltage probe measurement point on a schematic trace"),Gvn=Ee({type:me("schematic_manual_edit_conflict_warning"),schematic_manual_edit_conflict_warning_id:Yi("schematic_manual_edit_conflict_warning"),warning_type:me("schematic_manual_edit_conflict_warning").default("schematic_manual_edit_conflict_warning"),message:N(),schematic_component_id:N(),schematic_group_id:N().optional(),subcircuit_id:N().optional(),source_component_id:N()}).describe("Warning emitted when a component has both manual placement and explicit schX/schY coordinates"),Yvn=Ee({type:me("schematic_group"),schematic_group_id:Yi("schematic_group"),source_group_id:N(),is_subcircuit:Je().optional(),subcircuit_id:N().optional(),width:_t,height:_t,center:Ls,schematic_component_ids:ut(N()),show_as_schematic_box:Je().optional(),name:N().optional(),description:N().optional()}).describe("Defines a group of components on the schematic"),qvn=Ee({type:me("schematic_table"),schematic_table_id:Yi("schematic_table"),anchor_position:Ls,column_widths:ut(fi),row_heights:ut(fi),cell_padding:fi.optional(),border_width:fi.optional(),subcircuit_id:N().optional(),schematic_component_id:N().optional(),anchor:NV.optional()}).describe("Defines a table on the schematic"),Xvn=Ee({type:me("schematic_table_cell"),schematic_table_cell_id:Yi("schematic_table_cell"),schematic_table_id:N(),start_row_index:Ie(),end_row_index:Ie(),start_column_index:Ie(),end_column_index:Ie(),text:N().optional(),center:Ls,width:fi,height:fi,horizontal_align:Xt(["left","center","right"]).optional(),vertical_align:Xt(["top","middle","bottom"]).optional(),font_size:fi.optional(),subcircuit_id:N().optional()}).describe("Defines a cell within a schematic_table"),Wvn=Ee({type:me("schematic_sheet"),schematic_sheet_id:Yi("schematic_sheet"),name:N().optional(),subcircuit_id:N().optional()}).describe("Defines a schematic sheet or page that components can be placed on"),Kvn=Ee({x:fi,y:fi,bulge:Ie().optional()}),htt=Ee({vertices:ut(Kvn)}),Zvn=Ee({outer_ring:htt,inner_rings:ut(htt).default([])}),Qvn=Ee({x:fi,y:fi,via:Je().optional(),via_to_layer:Kd.optional()});ut(Qvn);var Jvn=Ee({x:fi,y:fi,via:Je().optional(),to_layer:Kd.optional(),trace_width:fi.optional()}),ewn=Ee({type:me("pcb_component"),pcb_component_id:Yi("pcb_component"),source_component_id:N(),center:Ls,layer:Kd,rotation:uS,width:_t,height:_t,do_not_place:Je().optional(),subcircuit_id:N().optional(),pcb_group_id:N().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"),ptt=Ee({type:me("pcb_hole"),pcb_hole_id:Yi("pcb_hole"),pcb_group_id:N().optional(),subcircuit_id:N().optional(),hole_shape:Xt(["circle","square"]),hole_diameter:Ie(),x:fi,y:fi});ptt.describe("Defines a circular or square hole on the PCB");var ftt=Ee({type:me("pcb_hole"),pcb_hole_id:Yi("pcb_hole"),pcb_group_id:N().optional(),subcircuit_id:N().optional(),hole_shape:me("oval"),hole_width:Ie(),hole_height:Ie(),x:fi,y:fi});ftt.describe("Defines an oval hole on the PCB");var mtt=Ee({type:me("pcb_hole"),pcb_hole_id:Yi("pcb_hole"),pcb_group_id:N().optional(),subcircuit_id:N().optional(),hole_shape:me("pill"),hole_width:Ie(),hole_height:Ie(),x:fi,y:fi});mtt.describe("Defines a pill-shaped hole on the PCB");var _tt=Ee({type:me("pcb_hole"),pcb_hole_id:Yi("pcb_hole"),pcb_group_id:N().optional(),subcircuit_id:N().optional(),hole_shape:me("rotated_pill"),hole_width:Ie(),hole_height:Ie(),x:fi,y:fi,ccw_rotation:uS});_tt.describe("Defines a rotated pill-shaped hole on the PCB");var twn=ptt.or(ftt).or(mtt).or(_tt),nwn=Ee({type:me("pcb_plated_hole"),shape:me("circle"),pcb_group_id:N().optional(),subcircuit_id:N().optional(),outer_diameter:Ie(),hole_diameter:Ie(),x:fi,y:fi,layers:ut(Kd),port_hints:ut(N()).optional(),pcb_component_id:N().optional(),pcb_port_id:N().optional(),pcb_plated_hole_id:Yi("pcb_plated_hole")}),iwn=Ee({type:me("pcb_plated_hole"),shape:Xt(["oval","pill"]),pcb_group_id:N().optional(),subcircuit_id:N().optional(),outer_width:Ie(),outer_height:Ie(),hole_width:Ie(),hole_height:Ie(),x:fi,y:fi,ccw_rotation:uS,layers:ut(Kd),port_hints:ut(N()).optional(),pcb_component_id:N().optional(),pcb_port_id:N().optional(),pcb_plated_hole_id:Yi("pcb_plated_hole")}),rwn=Ee({type:me("pcb_plated_hole"),shape:me("circular_hole_with_rect_pad"),pcb_group_id:N().optional(),subcircuit_id:N().optional(),hole_shape:me("circle"),pad_shape:me("rect"),hole_diameter:Ie(),rect_pad_width:Ie(),rect_pad_height:Ie(),rect_border_radius:Ie().optional(),hole_offset_x:fi.default(0),hole_offset_y:fi.default(0),x:fi,y:fi,layers:ut(Kd),port_hints:ut(N()).optional(),pcb_component_id:N().optional(),pcb_port_id:N().optional(),pcb_plated_hole_id:Yi("pcb_plated_hole")}),own=Ee({type:me("pcb_plated_hole"),shape:me("pill_hole_with_rect_pad"),pcb_group_id:N().optional(),subcircuit_id:N().optional(),hole_shape:me("pill"),pad_shape:me("rect"),hole_width:Ie(),hole_height:Ie(),rect_pad_width:Ie(),rect_pad_height:Ie(),rect_border_radius:Ie().optional(),hole_offset_x:fi.default(0),hole_offset_y:fi.default(0),x:fi,y:fi,layers:ut(Kd),port_hints:ut(N()).optional(),pcb_component_id:N().optional(),pcb_port_id:N().optional(),pcb_plated_hole_id:Yi("pcb_plated_hole")}),swn=Ee({type:me("pcb_plated_hole"),shape:me("rotated_pill_hole_with_rect_pad"),pcb_group_id:N().optional(),subcircuit_id:N().optional(),hole_shape:me("rotated_pill"),pad_shape:me("rect"),hole_width:Ie(),hole_height:Ie(),hole_ccw_rotation:uS,rect_pad_width:Ie(),rect_pad_height:Ie(),rect_border_radius:Ie().optional(),rect_ccw_rotation:uS,hole_offset_x:fi.default(0),hole_offset_y:fi.default(0),x:fi,y:fi,layers:ut(Kd),port_hints:ut(N()).optional(),pcb_component_id:N().optional(),pcb_port_id:N().optional(),pcb_plated_hole_id:Yi("pcb_plated_hole")}),awn=Bn([nwn,iwn,rwn,own,swn]),cwn=Ee({type:me("pcb_port"),pcb_port_id:Yi("pcb_port"),pcb_group_id:N().optional(),subcircuit_id:N().optional(),source_port_id:N(),pcb_component_id:N().optional(),x:fi,y:fi,layers:ut(Kd),is_board_pinout:Je().optional()}).describe("Defines a port on the PCB"),lwn=Ee({type:me("pcb_smtpad"),shape:me("circle"),pcb_smtpad_id:Yi("pcb_smtpad"),pcb_group_id:N().optional(),subcircuit_id:N().optional(),x:fi,y:fi,radius:Ie(),layer:Kd,port_hints:ut(N()).optional(),pcb_component_id:N().optional(),pcb_port_id:N().optional(),is_covered_with_solder_mask:Je().optional()}),uwn=Ee({type:me("pcb_smtpad"),shape:me("rect"),pcb_smtpad_id:Yi("pcb_smtpad"),pcb_group_id:N().optional(),subcircuit_id:N().optional(),x:fi,y:fi,width:Ie(),height:Ie(),rect_border_radius:Ie().optional(),corner_radius:Ie().optional(),layer:Kd,port_hints:ut(N()).optional(),pcb_component_id:N().optional(),pcb_port_id:N().optional(),is_covered_with_solder_mask:Je().optional()}),dwn=Ee({type:me("pcb_smtpad"),shape:me("rotated_rect"),pcb_smtpad_id:Yi("pcb_smtpad"),pcb_group_id:N().optional(),subcircuit_id:N().optional(),x:fi,y:fi,width:Ie(),height:Ie(),rect_border_radius:Ie().optional(),corner_radius:Ie().optional(),ccw_rotation:uS,layer:Kd,port_hints:ut(N()).optional(),pcb_component_id:N().optional(),pcb_port_id:N().optional(),is_covered_with_solder_mask:Je().optional()}),hwn=Ee({type:me("pcb_smtpad"),shape:me("pill"),pcb_smtpad_id:Yi("pcb_smtpad"),pcb_group_id:N().optional(),subcircuit_id:N().optional(),x:fi,y:fi,width:Ie(),height:Ie(),radius:Ie(),layer:Kd,port_hints:ut(N()).optional(),pcb_component_id:N().optional(),pcb_port_id:N().optional(),is_covered_with_solder_mask:Je().optional()}),pwn=Ee({type:me("pcb_smtpad"),shape:me("rotated_pill"),pcb_smtpad_id:Yi("pcb_smtpad"),pcb_group_id:N().optional(),subcircuit_id:N().optional(),x:fi,y:fi,width:Ie(),height:Ie(),radius:Ie(),ccw_rotation:uS,layer:Kd,port_hints:ut(N()).optional(),pcb_component_id:N().optional(),pcb_port_id:N().optional(),is_covered_with_solder_mask:Je().optional()}),fwn=Ee({type:me("pcb_smtpad"),shape:me("polygon"),pcb_smtpad_id:Yi("pcb_smtpad"),pcb_group_id:N().optional(),subcircuit_id:N().optional(),points:ut(Ls),layer:Kd,port_hints:ut(N()).optional(),pcb_component_id:N().optional(),pcb_port_id:N().optional(),is_covered_with_solder_mask:Je().optional()}),mwn=gm("shape",[lwn,uwn,dwn,pwn,hwn,fwn]).describe("Defines an SMT pad on the PCB"),_wn=Ee({type:me("pcb_solder_paste"),shape:me("circle"),pcb_solder_paste_id:Yi("pcb_solder_paste"),pcb_group_id:N().optional(),subcircuit_id:N().optional(),x:fi,y:fi,radius:Ie(),layer:Kd,pcb_component_id:N().optional(),pcb_smtpad_id:N().optional()}),ywn=Ee({type:me("pcb_solder_paste"),shape:me("rect"),pcb_solder_paste_id:Yi("pcb_solder_paste"),pcb_group_id:N().optional(),subcircuit_id:N().optional(),x:fi,y:fi,width:Ie(),height:Ie(),layer:Kd,pcb_component_id:N().optional(),pcb_smtpad_id:N().optional()}),gwn=Ee({type:me("pcb_solder_paste"),shape:me("pill"),pcb_solder_paste_id:Yi("pcb_solder_paste"),pcb_group_id:N().optional(),subcircuit_id:N().optional(),x:fi,y:fi,width:Ie(),height:Ie(),radius:Ie(),layer:Kd,pcb_component_id:N().optional(),pcb_smtpad_id:N().optional()}),xwn=Ee({type:me("pcb_solder_paste"),shape:me("rotated_rect"),pcb_solder_paste_id:Yi("pcb_solder_paste"),pcb_group_id:N().optional(),subcircuit_id:N().optional(),x:fi,y:fi,width:Ie(),height:Ie(),ccw_rotation:fi,layer:Kd,pcb_component_id:N().optional(),pcb_smtpad_id:N().optional()}),bwn=Ee({type:me("pcb_solder_paste"),shape:me("oval"),pcb_solder_paste_id:Yi("pcb_solder_paste"),pcb_group_id:N().optional(),subcircuit_id:N().optional(),x:fi,y:fi,width:Ie(),height:Ie(),layer:Kd,pcb_component_id:N().optional(),pcb_smtpad_id:N().optional()}),vwn=Bn([_wn,ywn,gwn,xwn,bwn]).describe("Defines solderpaste on the PCB"),wwn=Ee({type:me("pcb_text"),pcb_text_id:Yi("pcb_text"),pcb_group_id:N().optional(),subcircuit_id:N().optional(),text:N(),center:Ls,layer:Kd,width:_t,height:_t,lines:Ie(),align:Xt(["bottom-left"])}).describe("Defines text on the PCB"),Swn=Ee({route_type:me("wire"),x:fi,y:fi,width:fi,start_pcb_port_id:N().optional(),end_pcb_port_id:N().optional(),layer:Kd}),Ewn=Ee({route_type:me("via"),x:fi,y:fi,hole_diameter:fi.optional(),outer_diameter:fi.optional(),from_layer:N(),to_layer:N()}),Twn=Bn([Swn,Ewn]),Mwn=Ee({type:me("pcb_trace"),source_trace_id:N().optional(),pcb_component_id:N().optional(),pcb_trace_id:Yi("pcb_trace"),pcb_group_id:N().optional(),subcircuit_id:N().optional(),route_thickness_mode:Xt(["constant","interpolated"]).default("constant").optional(),route_order_index:Ie().optional(),should_round_corners:Je().optional(),trace_length:Ie().optional(),highlight_color:N().optional(),route:ut(Twn)}).describe("Defines a trace on the PCB"),Cwn=Ee({type:me("pcb_trace_error"),pcb_trace_error_id:Yi("pcb_trace_error"),error_type:me("pcb_trace_error").default("pcb_trace_error"),message:N(),center:Ls.optional(),pcb_trace_id:N(),source_trace_id:N(),pcb_component_ids:ut(N()),pcb_port_ids:ut(N()),subcircuit_id:N().optional()}).describe("Defines a trace error on the PCB"),Awn=Ee({type:me("pcb_trace_missing_error"),pcb_trace_missing_error_id:Yi("pcb_trace_missing_error"),error_type:me("pcb_trace_missing_error").default("pcb_trace_missing_error"),message:N(),center:Ls.optional(),source_trace_id:N(),pcb_component_ids:ut(N()),pcb_port_ids:ut(N()),subcircuit_id:N().optional()}).describe("Defines an error when a source trace has no corresponding PCB trace"),Pwn=Ee({type:me("pcb_port_not_matched_error"),pcb_error_id:Yi("pcb_error"),error_type:me("pcb_port_not_matched_error").default("pcb_port_not_matched_error"),message:N(),pcb_component_ids:ut(N()),subcircuit_id:N().optional()}).describe("Defines a trace error on the PCB where a port is not matched"),Rwn=Ee({type:me("pcb_port_not_connected_error"),pcb_port_not_connected_error_id:Yi("pcb_port_not_connected_error"),error_type:me("pcb_port_not_connected_error").default("pcb_port_not_connected_error"),message:N(),pcb_port_ids:ut(N()),pcb_component_ids:ut(N()),subcircuit_id:N().optional()}).describe("Defines an error when a pcb port is not connected to any trace"),Iwn=Ee({type:me("pcb_net"),pcb_net_id:Yi("pcb_net"),source_net_id:N().optional(),highlight_color:N().optional()}).describe("Defines a net on the PCB"),Nwn=Ee({type:me("pcb_via"),pcb_via_id:Yi("pcb_via"),pcb_group_id:N().optional(),subcircuit_id:N().optional(),x:fi,y:fi,outer_diameter:fi.default("0.6mm"),hole_diameter:fi.default("0.25mm"),from_layer:Kd.optional(),to_layer:Kd.optional(),layers:ut(Kd),pcb_trace_id:N().optional(),net_is_assignable:Je().optional(),net_assigned:Je().optional()}).describe("Defines a via on the PCB"),kwn=Ee({type:me("pcb_board"),pcb_board_id:Yi("pcb_board"),pcb_panel_id:N().optional(),is_subcircuit:Je().optional(),subcircuit_id:N().optional(),width:_t,height:_t,center:Ls,thickness:_t.optional().default(1.4),num_layers:Ie().optional().default(4),outline:ut(Ls).optional(),material:Xt(["fr4","fr1"]).default("fr4")}).describe("Defines the board outline of the PCB"),Own=Ee({type:me("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"),Lwn=Ee({type:me("pcb_placement_error"),pcb_placement_error_id:Yi("pcb_placement_error"),error_type:me("pcb_placement_error").default("pcb_placement_error"),message:N(),subcircuit_id:N().optional()}).describe("Defines a placement error on the PCB"),Dwn=Ee({type:me("pcb_trace_hint"),pcb_trace_hint_id:Yi("pcb_trace_hint"),pcb_port_id:N(),pcb_component_id:N(),route:ut(Jvn),subcircuit_id:N().optional()}).describe("A hint that can be used during generation of a PCB trace"),zwn=Ee({type:me("pcb_silkscreen_line"),pcb_silkscreen_line_id:Yi("pcb_silkscreen_line"),pcb_component_id:N(),pcb_group_id:N().optional(),subcircuit_id:N().optional(),stroke_width:fi.default("0.1mm"),x1:fi,y1:fi,x2:fi,y2:fi,layer:fT}).describe("Defines a silkscreen line on the PCB"),$wn=Ee({type:me("pcb_silkscreen_path"),pcb_silkscreen_path_id:Yi("pcb_silkscreen_path"),pcb_component_id:N(),pcb_group_id:N().optional(),subcircuit_id:N().optional(),layer:fT,route:ut(Ls),stroke_width:_t}).describe("Defines a silkscreen path on the PCB"),Fwn=Ee({type:me("pcb_silkscreen_text"),pcb_silkscreen_text_id:Yi("pcb_silkscreen_text"),pcb_group_id:N().optional(),subcircuit_id:N().optional(),font:me("tscircuit2024").default("tscircuit2024"),font_size:fi.default("0.2mm"),pcb_component_id:N(),text:N(),is_knockout:Je().default(!1).optional(),knockout_padding:Ee({left:_t,top:_t,bottom:_t,right:_t}).default({left:"0.2mm",top:"0.2mm",bottom:"0.2mm",right:"0.2mm"}).optional(),ccw_rotation:Ie().optional(),layer:Kd,is_mirrored:Je().default(!1).optional(),anchor_position:Ls.default({x:0,y:0}),anchor_alignment:NV.default("center")}).describe("Defines silkscreen text on the PCB"),Uwn=Ee({type:me("pcb_copper_text"),pcb_copper_text_id:Yi("pcb_copper_text"),pcb_group_id:N().optional(),subcircuit_id:N().optional(),font:me("tscircuit2024").default("tscircuit2024"),font_size:fi.default("0.2mm"),pcb_component_id:N(),text:N(),is_knockout:Je().default(!1).optional(),knockout_padding:Ee({left:_t,top:_t,bottom:_t,right:_t}).default({left:"0.2mm",top:"0.2mm",bottom:"0.2mm",right:"0.2mm"}).optional(),ccw_rotation:Ie().optional(),layer:Kd,is_mirrored:Je().default(!1).optional(),anchor_position:Ls.default({x:0,y:0}),anchor_alignment:NV.default("center")}).describe("Defines copper text on the PCB"),Bwn=Ee({type:me("pcb_silkscreen_rect"),pcb_silkscreen_rect_id:Yi("pcb_silkscreen_rect"),pcb_component_id:N(),pcb_group_id:N().optional(),subcircuit_id:N().optional(),center:Ls,width:_t,height:_t,layer:Kd,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"),jwn=Ee({type:me("pcb_silkscreen_circle"),pcb_silkscreen_circle_id:Yi("pcb_silkscreen_circle"),pcb_component_id:N(),pcb_group_id:N().optional(),subcircuit_id:N().optional(),center:Ls,radius:_t,layer:fT,stroke_width:_t.default("1mm")}).describe("Defines a silkscreen circle on the PCB"),Hwn=Ee({type:me("pcb_silkscreen_oval"),pcb_silkscreen_oval_id:Yi("pcb_silkscreen_oval"),pcb_component_id:N(),pcb_group_id:N().optional(),subcircuit_id:N().optional(),center:Ls,radius_x:fi,radius_y:fi,layer:fT}).describe("Defines a silkscreen oval on the PCB"),Vwn=Ee({type:me("pcb_fabrication_note_text"),pcb_fabrication_note_text_id:Yi("pcb_fabrication_note_text"),subcircuit_id:N().optional(),pcb_group_id:N().optional(),font:me("tscircuit2024").default("tscircuit2024"),font_size:fi.default("1mm"),pcb_component_id:N(),text:N(),layer:fT,anchor_position:Ls.default({x:0,y:0}),anchor_alignment:Xt(["center","top_left","top_right","bottom_left","bottom_right"]).default("center"),color:N().optional()}).describe("Defines a fabrication note in text on the PCB, useful for leaving notes for assemblers or fabricators"),Gwn=Ee({type:me("pcb_fabrication_note_path"),pcb_fabrication_note_path_id:Yi("pcb_fabrication_note_path"),pcb_component_id:N(),subcircuit_id:N().optional(),layer:Kd,route:ut(Ls),stroke_width:_t,color:N().optional()}).describe("Defines a fabrication path on the PCB for fabricators or assemblers"),Ywn=Ee({type:me("pcb_fabrication_note_rect"),pcb_fabrication_note_rect_id:Yi("pcb_fabrication_note_rect"),pcb_component_id:N(),pcb_group_id:N().optional(),subcircuit_id:N().optional(),center:Ls,width:_t,height:_t,layer:fT,stroke_width:_t.default("0.1mm"),corner_radius:_t.optional(),is_filled:Je().optional(),has_stroke:Je().optional(),is_stroke_dashed:Je().optional(),color:N().optional()}).describe("Defines a fabrication note rectangle on the PCB"),qwn=Ee({type:me("pcb_fabrication_note_dimension"),pcb_fabrication_note_dimension_id:Yi("pcb_fabrication_note_dimension"),pcb_component_id:N(),pcb_group_id:N().optional(),subcircuit_id:N().optional(),layer:fT,from:Ls,to:Ls,text:N().optional(),text_ccw_rotation:Ie().optional(),offset:_t.optional(),offset_distance:_t.optional(),offset_direction:Ee({x:Ie(),y:Ie()}).optional(),font:me("tscircuit2024").default("tscircuit2024"),font_size:_t.default("1mm"),color:N().optional(),arrow_size:_t.default("1mm")}).describe("Defines a measurement annotation within PCB fabrication notes"),Xwn=Ee({type:me("pcb_note_text"),pcb_note_text_id:Yi("pcb_note_text"),pcb_component_id:N().optional(),pcb_group_id:N().optional(),subcircuit_id:N().optional(),name:N().optional(),font:me("tscircuit2024").default("tscircuit2024"),font_size:fi.default("1mm"),text:N().optional(),anchor_position:Ls.default({x:0,y:0}),anchor_alignment:Xt(["center","top_left","top_right","bottom_left","bottom_right"]).default("center"),color:N().optional()}).describe("Defines a documentation note in text on the PCB"),Wwn=Ee({type:me("pcb_note_rect"),pcb_note_rect_id:Yi("pcb_note_rect"),pcb_component_id:N().optional(),pcb_group_id:N().optional(),subcircuit_id:N().optional(),name:N().optional(),text:N().optional(),center:Ls,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:N().optional()}).describe("Defines a rectangular documentation note on the PCB"),Kwn=Ee({type:me("pcb_note_path"),pcb_note_path_id:Yi("pcb_note_path"),pcb_component_id:N().optional(),pcb_group_id:N().optional(),subcircuit_id:N().optional(),name:N().optional(),text:N().optional(),route:ut(Ls),stroke_width:_t.default("0.1mm"),color:N().optional()}).describe("Defines a polyline documentation note on the PCB"),Zwn=Ee({type:me("pcb_note_line"),pcb_note_line_id:Yi("pcb_note_line"),pcb_component_id:N().optional(),pcb_group_id:N().optional(),subcircuit_id:N().optional(),name:N().optional(),text:N().optional(),x1:fi,y1:fi,x2:fi,y2:fi,stroke_width:fi.default("0.1mm"),color:N().optional(),is_dashed:Je().optional()}).describe("Defines a straight documentation note line on the PCB"),Qwn=Ee({type:me("pcb_note_dimension"),pcb_note_dimension_id:Yi("pcb_note_dimension"),pcb_component_id:N().optional(),pcb_group_id:N().optional(),subcircuit_id:N().optional(),name:N().optional(),from:Ls,to:Ls,text:N().optional(),text_ccw_rotation:Ie().optional(),offset_distance:_t.optional(),offset_direction:Ee({x:Ie(),y:Ie()}).optional(),font:me("tscircuit2024").default("tscircuit2024"),font_size:_t.default("1mm"),color:N().optional(),arrow_size:_t.default("1mm")}).describe("Defines a measurement annotation within PCB documentation notes"),Jwn=Ee({type:me("pcb_footprint_overlap_error"),pcb_error_id:Yi("pcb_error"),error_type:me("pcb_footprint_overlap_error").default("pcb_footprint_overlap_error"),message:N(),pcb_smtpad_ids:ut(N()).optional(),pcb_plated_hole_ids:ut(N()).optional(),pcb_hole_ids:ut(N()).optional(),pcb_keepout_ids:ut(N()).optional()}).describe("Error emitted when a pcb footprint overlaps with another element"),eSn=Ee({type:me("pcb_keepout"),shape:me("rect"),pcb_group_id:N().optional(),subcircuit_id:N().optional(),center:Ls,width:fi,height:fi,pcb_keepout_id:N(),layers:ut(N()),description:N().optional()}).or(Ee({type:me("pcb_keepout"),shape:me("circle"),pcb_group_id:N().optional(),subcircuit_id:N().optional(),center:Ls,radius:fi,pcb_keepout_id:N(),layers:ut(N()),description:N().optional()})),_ge=Ee({type:me("pcb_cutout"),pcb_cutout_id:Yi("pcb_cutout"),pcb_group_id:N().optional(),subcircuit_id:N().optional()}),tSn=_ge.extend({shape:me("rect"),center:Ls,width:_t,height:_t,rotation:uS.optional()}),nSn=_ge.extend({shape:me("circle"),center:Ls,radius:_t}),iSn=_ge.extend({shape:me("polygon"),points:ut(Ls)}),rSn=gm("shape",[tSn,nSn,iSn]).describe("Defines a cutout on the PCB, removing board material."),oSn=Ee({type:me("pcb_missing_footprint_error"),pcb_missing_footprint_error_id:Yi("pcb_missing_footprint_error"),pcb_group_id:N().optional(),subcircuit_id:N().optional(),error_type:me("pcb_missing_footprint_error").default("pcb_missing_footprint_error"),source_component_id:N(),message:N()}).describe("Defines a missing footprint error on the PCB"),sSn=Ee({type:me("external_footprint_load_error"),external_footprint_load_error_id:Yi("external_footprint_load_error"),pcb_component_id:N(),source_component_id:N(),pcb_group_id:N().optional(),subcircuit_id:N().optional(),footprinter_string:N().optional(),error_type:me("external_footprint_load_error").default("external_footprint_load_error"),message:N()}).describe("Defines an error when an external footprint fails to load"),aSn=Ee({type:me("circuit_json_footprint_load_error"),circuit_json_footprint_load_error_id:Yi("circuit_json_footprint_load_error"),pcb_component_id:N(),source_component_id:N(),pcb_group_id:N().optional(),subcircuit_id:N().optional(),error_type:me("circuit_json_footprint_load_error").default("circuit_json_footprint_load_error"),message:N(),circuit_json:ut(fl()).optional()}).describe("Defines an error when a circuit JSON footprint fails to load"),cSn=Ee({type:me("pcb_group"),pcb_group_id:Yi("pcb_group"),source_group_id:N(),is_subcircuit:Je().optional(),subcircuit_id:N().optional(),width:_t.optional(),height:_t.optional(),center:Ls,outline:ut(Ls).optional(),anchor_position:Ls.optional(),anchor_alignment:Xt(["center","top_left","top_right","bottom_left","bottom_right"]).optional(),pcb_component_ids:ut(N()),name:N().optional(),description:N().optional(),layout_mode:N().optional(),autorouter_configuration:Ee({trace_clearance:_t}).optional(),autorouter_used_string:N().optional()}).describe("Defines a group of components on the PCB"),lSn=Ee({type:me("pcb_autorouting_error"),pcb_error_id:Yi("pcb_autorouting_error"),error_type:me("pcb_autorouting_error").default("pcb_autorouting_error"),message:N(),subcircuit_id:N().optional()}).describe("The autorouting has failed to route a portion of the board"),uSn=Ee({type:me("pcb_manual_edit_conflict_warning"),pcb_manual_edit_conflict_warning_id:Yi("pcb_manual_edit_conflict_warning"),warning_type:me("pcb_manual_edit_conflict_warning").default("pcb_manual_edit_conflict_warning"),message:N(),pcb_component_id:N(),pcb_group_id:N().optional(),subcircuit_id:N().optional(),source_component_id:N()}).describe("Warning emitted when a component has both manual placement and explicit pcbX/pcbY coordinates"),dSn=Ee({type:me("pcb_breakout_point"),pcb_breakout_point_id:Yi("pcb_breakout_point"),pcb_group_id:N(),subcircuit_id:N().optional(),source_trace_id:N().optional(),source_port_id:N().optional(),source_net_id:N().optional(),x:fi,y:fi}).describe("Defines a routing target within a pcb_group for a source_trace or source_net"),hSn=Ee({type:me("pcb_ground_plane"),pcb_ground_plane_id:Yi("pcb_ground_plane"),source_pcb_ground_plane_id:N(),source_net_id:N(),pcb_group_id:N().optional(),subcircuit_id:N().optional()}).describe("Defines a ground plane on the PCB"),pSn=Ee({type:me("pcb_ground_plane_region"),pcb_ground_plane_region_id:Yi("pcb_ground_plane_region"),pcb_ground_plane_id:N(),pcb_group_id:N().optional(),subcircuit_id:N().optional(),layer:Kd,points:ut(Ls)}).describe("Defines a polygon region of a ground plane"),fSn=Ee({type:me("pcb_thermal_spoke"),pcb_thermal_spoke_id:Yi("pcb_thermal_spoke"),pcb_ground_plane_id:N(),shape:N(),spoke_count:Ie(),spoke_thickness:fi,spoke_inner_diameter:fi,spoke_outer_diameter:fi,pcb_plated_hole_id:N().optional(),subcircuit_id:N().optional()}).describe("Pattern for connecting a ground plane to a plated hole"),yge=Ee({type:me("pcb_copper_pour"),pcb_copper_pour_id:Yi("pcb_copper_pour"),pcb_group_id:N().optional(),subcircuit_id:N().optional(),layer:Kd,source_net_id:N().optional(),covered_with_solder_mask:Je().optional().default(!0)}),mSn=yge.extend({shape:me("rect"),center:Ls,width:_t,height:_t,rotation:uS.optional()}),_Sn=yge.extend({shape:me("brep"),brep_shape:Zvn}),ySn=yge.extend({shape:me("polygon"),points:ut(Ls)}),gSn=gm("shape",[mSn,_Sn,ySn]).describe("Defines a copper pour on the PCB."),xSn=Ee({type:me("pcb_component_outside_board_error"),pcb_component_outside_board_error_id:Yi("pcb_component_outside_board_error"),error_type:me("pcb_component_outside_board_error").default("pcb_component_outside_board_error"),message:N(),pcb_component_id:N(),pcb_board_id:N(),component_center:Ls,component_bounds:Ee({min_x:Ie(),max_x:Ie(),min_y:Ie(),max_y:Ie()}),subcircuit_id:N().optional(),source_component_id:N().optional()}).describe("Error emitted when a PCB component is placed outside the board boundaries"),bSn=Ee({type:me("pcb_component_invalid_layer_error"),pcb_component_invalid_layer_error_id:Yi("pcb_component_invalid_layer_error"),error_type:me("pcb_component_invalid_layer_error").default("pcb_component_invalid_layer_error"),message:N(),pcb_component_id:N().optional(),source_component_id:N(),layer:Kd,subcircuit_id:N().optional()}).describe("Error emitted when a component is placed on an invalid layer (components can only be on 'top' or 'bottom' layers)"),vSn=Ee({type:me("pcb_via_clearance_error"),pcb_error_id:Yi("pcb_error"),error_type:me("pcb_via_clearance_error").default("pcb_via_clearance_error"),message:N(),pcb_via_ids:ut(N()).min(2),minimum_clearance:fi.optional(),actual_clearance:fi.optional(),pcb_center:Ee({x:Ie().optional(),y:Ie().optional()}).optional(),subcircuit_id:N().optional()}).describe("Error emitted when vias are closer than the allowed clearance"),wSn=Ee({type:me("pcb_courtyard_rect"),pcb_courtyard_rect_id:Yi("pcb_courtyard_rect"),pcb_component_id:N(),pcb_group_id:N().optional(),subcircuit_id:N().optional(),center:Ls,width:_t,height:_t,layer:fT,color:N().optional()}).describe("Defines a courtyard rectangle on the PCB"),SSn=Ee({type:me("pcb_courtyard_outline"),pcb_courtyard_outline_id:Yi("pcb_courtyard_outline"),pcb_component_id:N(),pcb_group_id:N().optional(),subcircuit_id:N().optional(),layer:fT,outline:ut(Ls).min(2),stroke_width:_t.default("0.1mm"),is_closed:Je().optional(),is_stroke_dashed:Je().optional(),color:N().optional()}).describe("Defines a courtyard outline on the PCB"),ESn=Ee({type:me("pcb_courtyard_polygon"),pcb_courtyard_polygon_id:Yi("pcb_courtyard_polygon"),pcb_component_id:N(),pcb_group_id:N().optional(),subcircuit_id:N().optional(),layer:fT,points:ut(Ls).min(3),color:N().optional()}).describe("Defines a courtyard polygon on the PCB"),TSn=Ee({type:me("cad_component"),cad_component_id:N(),pcb_component_id:N(),source_component_id:N(),position:pge,rotation:pge.optional(),size:pge.optional(),layer:Kd.optional(),subcircuit_id:N().optional(),footprinter_string:N().optional(),model_obj_url:N().optional(),model_stl_url:N().optional(),model_3mf_url:N().optional(),model_gltf_url:N().optional(),model_glb_url:N().optional(),model_step_url:N().optional(),model_wrl_url:N().optional(),model_unit_to_mm_scale_factor:Ie().optional(),model_jscad:fl().optional()}).describe("Defines a component on the PCB"),MSn=Xt(["sinewave","square","triangle","sawtooth"]),CSn=Bn([N(),Ie()]).transform(n=>typeof n=="string"?n.endsWith("%")?parseFloat(n.slice(0,-1))/100:parseFloat(n):n).pipe(Ie().min(0,"Duty cycle must be non-negative").max(1,"Duty cycle cannot be greater than 100%")),ASn=Ee({type:me("simulation_voltage_source"),simulation_voltage_source_id:Yi("simulation_voltage_source"),is_dc_source:me(!0).optional().default(!0),positive_source_port_id:N().optional(),negative_source_port_id:N().optional(),positive_source_net_id:N().optional(),negative_source_net_id:N().optional(),voltage:hI}).describe("Defines a DC voltage source for simulation"),PSn=Ee({type:me("simulation_voltage_source"),simulation_voltage_source_id:Yi("simulation_voltage_source"),is_dc_source:me(!1),terminal1_source_port_id:N().optional(),terminal2_source_port_id:N().optional(),terminal1_source_net_id:N().optional(),terminal2_source_net_id:N().optional(),voltage:hI.optional(),frequency:dge.optional(),peak_to_peak_voltage:hI.optional(),wave_shape:MSn.optional(),phase:uS.optional(),duty_cycle:CSn.optional()}).describe("Defines an AC voltage source for simulation"),RSn=Bn([ASn,PSn]).describe("Defines a voltage source for simulation"),ISn=Bn([me("spice_dc_sweep"),me("spice_dc_operating_point"),me("spice_transient_analysis"),me("spice_ac_analysis")]),NSn=Ee({type:me("simulation_experiment"),simulation_experiment_id:Yi("simulation_experiment"),name:N(),experiment_type:ISn,time_per_step:hge.optional(),start_time_ms:pI.optional(),end_time_ms:pI.optional()}).describe("Defines a simulation experiment configuration"),kSn=Ee({type:me("simulation_transient_voltage_graph"),simulation_transient_voltage_graph_id:Yi("simulation_transient_voltage_graph"),simulation_experiment_id:N(),timestamps_ms:ut(Ie()).optional(),voltage_levels:ut(Ie()),schematic_voltage_probe_id:N().optional(),simulation_voltage_probe_id:N().optional(),subcircuit_connectivity_map_key:N().optional(),time_per_step:hge,start_time_ms:pI,end_time_ms:pI,name:N().optional()}).describe("Stores voltage measurements over time for a simulation"),OSn=Ee({type:me("simulation_switch"),simulation_switch_id:Yi("simulation_switch"),source_component_id:N().optional(),closes_at:pI.optional(),opens_at:pI.optional(),starts_closed:Je().optional(),switching_frequency:dge.optional()}).describe("Defines a switch for simulation timing control"),LSn=Ee({type:me("simulation_voltage_probe"),simulation_voltage_probe_id:Yi("simulation_voltage_probe"),source_port_id:N().optional(),source_net_id:N().optional(),name:N().optional(),subcircuit_id:N().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"}),DSn=Ee({type:me("simulation_unknown_experiment_error"),simulation_unknown_experiment_error_id:Yi("simulation_unknown_experiment_error"),error_type:me("simulation_unknown_experiment_error").default("simulation_unknown_experiment_error"),message:N(),simulation_experiment_id:N().optional(),subcircuit_id:N().optional()}).describe("An unknown error occurred during the simulation experiment.");Bn([fvn,pvn,hvn,_vn,mvn,Wet,Yet,fge,Xet,qet,Ket,Zet,Qet,ttt,ntt,itt,att,rtt,ott,stt,ett,Jet,gvn,bvn,yvn,ctt,ltt,utt,vvn,ewn,twn,oSn,sSn,aSn,uSn,awn,eSn,cwn,Iwn,wwn,Mwn,Nwn,mwn,vwn,kwn,Own,cSn,Dwn,zwn,$wn,Fwn,Uwn,Bwn,jwn,Hwn,Cwn,Awn,Lwn,Pwn,Rwn,vSn,Gwn,Vwn,Ywn,qwn,Xwn,Wwn,Kwn,Zwn,Qwn,lSn,Jwn,dSn,rSn,hSn,pSn,fSn,gSn,xSn,bSn,wSn,SSn,ESn,wvn,Lvn,Pvn,Rvn,Ivn,Nvn,Avn,Dvn,kvn,Svn,$vn,Fvn,zvn,Hvn,Vvn,Gvn,Yvn,Wvn,qvn,Xvn,TSn,RSn,NSn,kSn,OSn,LSn,DSn]);var zSn=Object.defineProperty,$Sn=(n,e)=>{for(var t in e)zSn(n,t,{get:e[t],enumerable:!0})},K5={};$Sn(K5,{axial:()=>$2n,bga:()=>KSn,breakoutheaders:()=>X2n,cap:()=>GSn,dfn:()=>x2n,diode:()=>VSn,dip:()=>BSn,electrolytic:()=>R5n,hc49:()=>K2n,jst:()=>e5n,led:()=>YSn,lqfp:()=>Y2n,m2host:()=>q5n,melf:()=>lTn,micromelf:()=>pTn,minimelf:()=>tTn,mlp:()=>r2n,ms012:()=>M2n,ms013:()=>A2n,msop:()=>u5n,pad:()=>Z2n,pinrow:()=>w2n,platedhole:()=>j5n,potentiometer:()=>C5n,pushbutton:()=>U2n,qfn:()=>n2n,qfp:()=>i2n,quad:()=>TL,res:()=>qSn,sma:()=>yTn,smb:()=>TTn,smbf:()=>N5n,smc:()=>PTn,smf:()=>vTn,smtpad:()=>U5n,sod110:()=>n5n,sod123:()=>O2n,sod123f:()=>kEn,sod123fl:()=>zEn,sod123w:()=>pEn,sod128:()=>GEn,sod323:()=>yEn,sod323f:()=>PEn,sod323fl:()=>_5n,sod323w:()=>h5n,sod523:()=>iEn,sod723:()=>BEn,sod80:()=>lEn,sod882:()=>TEn,sod882d:()=>oTn,sod923:()=>vEn,soic:()=>QSn,solderjumper:()=>v5n,son:()=>b5n,sop8:()=>aEn,sot:()=>V5n,sot223:()=>kTn,sot23:()=>h2n,sot23w:()=>jTn,sot25:()=>_2n,sot323:()=>D5n,sot363:()=>u2n,sot457:()=>E5n,sot563:()=>E2n,sot723:()=>R2n,sot89:()=>ZEn,ssop:()=>s2n,stampboard:()=>j2n,stampreceiver:()=>G2n,to220:()=>JEn,to92:()=>tEn,to92s:()=>XTn,tssop:()=>c2n,vssop:()=>a5n});var Uo=(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"}),ka=(n,e,t,i,r)=>({pcb_plated_hole_id:"",type:"pcb_plated_hole",shape:"circle",x:e,y:t,hole_diameter:xh(i),outer_diameter:xh(r),pcb_port_id:"",layers:["top","bottom"],port_hints:[n.toString()]}),ytt=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 KM(n){return typeof n=="string"?n.trim().toLowerCase().endsWith("mil")?parseFloat(n)*.0254:parseFloat(n):Number(n)}var kV=Bn([N(),Ie()]).transform(n=>KM(n)),FSn=n=>Ee({fn:N(),num_pins:Ie().optional().default(6),wide:Je().optional(),narrow:Je().optional(),w:kV.optional(),p:kV.default(n.p??"2.54mm"),id:kV.optional(),od:kV.optional()}).transform(e=>(!e.id&&!e.od?Math.abs(e.p-1.27)<.01?(e.id=KM("0.55mm"),e.od=KM("0.95mm")):(e.id=KM("1.0mm"),e.od=KM("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=KM("600mil"):e.narrow?e.w=KM("300mil"):e.w=KM(n.w??"300mil")),e)),USn=FSn({}),gtt=(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}},BSn=n=>{const e=USn.parse(n),t=[];for(let l=0;l<e.num_pins;l++){const{x:u,y:d}=gtt(e.num_pins,l+1,e.w,e.p??2.54);t.push(ka(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},...ytt.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}=gtt(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=Uo(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()]}),xtt=[{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}],jSn=Object.fromEntries(xtt.map(n=>[n.metric,n])),HSn=Object.fromEntries(xtt.map(n=>[n.imperial,n]));Ee({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 OV=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=EL(a)),typeof c=="string"&&(c=EL(c)),typeof t=="string"&&(t=EL(t)),typeof i=="string"&&(i=EL(i)),typeof r=="string"&&(r=EL(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=jSn[o]),s&&(u=HSn[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=Uo(0,h,.2);return e?[ka(1,-t/2,0,i,i*1/.8),ka(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]},VSn=n=>({circuitJson:OV(n),parameters:n}),GSn=n=>({circuitJson:OV(n),parameters:n}),YSn=n=>({circuitJson:OV(n),parameters:n}),qSn=n=>({circuitJson:OV(n),parameters:n}),btt=(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()]}),vtt="ABCDEFGHIJKLMNOPQRSTUVWXYZ",wtt=N().transform(n=>{const[e,t]=n.split(/[x ]/);return{x:parseFloat(e),y:parseFloat(t)}}).pipe(Ee({x:Ie(),y:Ie()})),XSn=N().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(N().or(Ie()))),WSn=Ee({fn:N(),num_pins:Ie().optional().default(64),grid:wtt.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:XSn.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=vtt.indexOf(r[1]),s=Number.parseInt(r[2])-1;return o*n.grid.x+s+1})),{...n,origin:e}}),KSn=n=>{const e=WSn.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(I=>typeof I=="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 I=Math.floor(Math.sqrt(h)),A=Math.floor((i.x-I)/2),R=Math.floor((i.y-I)/2);for(let M=R;M<R+I;M++)for(let k=A;k<A+I;k++)d.push(M*i.x+k+1)}l?.includes("topleft")&&d.push(1);const p=new Set(d);let m=0;for(let I=0;I<i.y;I++)for(let A=0;A<i.x;A++){const R=(A-(i.x-1)/2)*r,M=(I-(i.y-1)/2)*r;let k=A,C=I;switch(e.origin){case"bl":k=A,C=i.y-1-I;break;case"br":k=i.x-1-A,C=i.y-1-I;break;case"tr":k=i.x-1-A,C=I;break}let U=C*i.x+k+1;if(p.has(U)){m++;continue}U-=m;const O=[U,`${vtt[C]}${k+1}`];u.push(e.circularpads?btt(O,{x:R,y:M,radius:c/2}):zr(O,R,M,c,c))}const _=Uo(0,i.y*r/2,.2),y=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-y},{x:-b-y,y:-w},{x:-b,y:-w}];break;case"br":x=[{x:b,y:-w},{x:b,y:-w-y},{x:b+y,y:-w},{x:b,y:-w}];break;case"tr":x=[{x:b,y:w},{x:b,y:w+y},{x:b+y,y:w},{x:b,y:w}];break;case"tl":default:x=[{x:-b,y:w},{x:-b,y:w+y},{x:-b-y,y:w},{x:-b,y:w}];break}const S={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"pin1_marker",route:x,stroke_width:.05};return{circuitJson:[...u,_,S],parameters:e}},LV=(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()]}),rE=n=>Ee({fn:N(),num_pins:Ie().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)),ZSn=rE({}),gge=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}},QSn=n=>{const e=ZSn.parse(n);return{circuitJson:Z5(e),parameters:e}},Z5=n=>{const e=[];for(let a=0;a<n.num_pins;a++){const{x:c,y:l}=gge({num_pins:n.num_pins,pn:a+1,w:n.w,p:n.p,pl:n.pl,legsoutside:n.legsoutside});n.pillpads?e.push(LV(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=Uo(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},...ytt.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]},Stt=Xt(["leftside","topside","rightside","bottomside","toppin","bottompin","leftpin","rightpin"]),JSn=({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},xge=Ee({fn:N(),cc:Je().default(!0).optional(),ccw:Je().default(!0).optional(),startingpin:N().or(ut(Stt)).transform(n=>typeof n=="string"?n.slice(1,-1).split(","):n).pipe(ut(Stt)).optional(),num_pins:Ie().optional().default(64),w:_t.optional(),h:_t.optional(),p:_t.default(_t.parse("0.5mm")),pw:_t.optional(),pl:_t.optional(),thermalpad:Bn([me(!0),wtt]).optional(),legsoutside:Je().default(!1)}),bge=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},Ett=xge.transform(bge),e2n=["left","bottom","right","top"],t2n=n=>{const{pin_count:e,pn:t,w:i,h:r,p:o,pl:s,legsoutside:a}=n,c=e/4,l=e2n[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")}},TL=n=>{const e=Ett.parse(n),t=[],i=JSn(e),r=e.num_pins/4;for(let a=0;a<e.num_pins;a++){const{x:c,y:l,o:u}=t2n({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 y=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*y,m-=b*l*y}(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*y},{x:p,y:m},{x:p+.2*y*-c,y:m+.2},{x:p-.2*-c,y:m+.2*y}],type:"pcb_silkscreen_path",stroke_width:.1})}const s=Uo(0,e.h/2+(e.legsoutside?e.pl*1.2:.5),.3);return{circuitJson:[...t,...o,s],parameters:e}};xge.extend({}).transform(bge);var n2n=n=>(n.legsoutside=!1,TL(n)),i2n=n=>{n.legsoutside=!0;const e=Ett.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 TL(n)};xge.extend({}).transform(bge);var r2n=n=>(n.legsoutside=!1,n.thermalpad===void 0&&(n.thermalpad=!0),TL(n)),o2n=rE({w:"3.9mm",p:"1.27mm"}),s2n=n=>{const e=o2n.parse(n);return{circuitJson:Z5(e),parameters:e}},a2n=rE({w:"7.1mm",p:"0.65mm",pl:"1.35mm",pw:"0.40mm",legsoutside:!0}),c2n=n=>{const e=a2n.parse(n);return{circuitJson:Z5(e),parameters:e}},l2n=rE({}),u2n=n=>{const e=l2n.parse({fn:"sot363",num_pins:6,w:1.94,p:.65,pw:.3,pl:.7,legoutside:!0});return{circuitJson:Z5(e),parameters:e}},Ttt=Ee({fn:N(),num_pins:Ie().default(3),w:N().default("1.92mm"),h:N().default("2.74mm"),pl:N().default("0.8mm"),pw:N().default("0.764mm"),p:N().default("0.95mm"),string:N().optional()}),d2n=rE({p:"0.95mm",w:"1.6mm",legsoutside:!0}),h2n=n=>{const e=n.string?.match(/^sot23_(\d+)/),t=e?Number.parseInt(e[1],10):3;if(t===6||t===8){const r=d2n.parse({...n,num_pins:t});return{circuitJson:Z5(r),parameters:r}}const i=Ttt.parse({...n,num_pins:t});if(i.num_pins===3)return{circuitJson:f2n(i),parameters:i};if(i.num_pins===5)return{circuitJson:Ctt(i),parameters:i};throw new Error("Invalid number of pins")},p2n=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}},f2n=n=>{const e=[];for(let i=0;i<n.num_pins;i++){const{x:r,y:o}=p2n({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=Uo(0,Number.parseInt(n.h),.3);return[...e,t]},Mtt=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")},Ctt=n=>{const e=[];for(let d=1;d<=n.num_pins;d++){const{x:h,y:p}=Mtt({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=Uo(0,i+.3,.3),a=Mtt({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]},m2n=Ttt.extend({}),_2n=n=>{const e=m2n.parse({...n,num_pins:5});return{circuitJson:Ctt(e),parameters:e}},y2n=[{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}],g2n=rE({}),x2n=n=>{const e=g2n.parse(n),t=[];for(let d=0;d<e.num_pins;d++){const{x:h,y:p}=gge({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 y2n){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=Uo(0,o/2+.4,o/12);return{circuitJson:[...t,u,...s],parameters:e}},DV=(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:xh(i),hole_shape:"circle",pad_shape:"rect",rect_pad_width:xh(r),rect_pad_height:xh(o),pcb_port_id:"",layers:["top","bottom"],port_hints:[n.toString()]}),vge=({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 b2n({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 v2n=Ee({fn:N(),num_pins:Ie().optional().default(6),rows:Bn([N(),Ie()]).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=b2n(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"]})}),w2n=n=>{const e=v2n.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 y=[],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}},S=(M,k,C)=>{M===1&&!e.nosquareplating?y.push(DV(M,k,C,i,r,r)):y.push(ka(M,k,C,i,r));const{anchor_x:U,anchor_y:O}=w({xoff:k,yoff:C,od:r,anchorSide:a});h||(m?y.push(vge({fs:r/5,pn:M,anchor_x:U,anchor_y:O,textalign:_,orthogonal:l,verticallyinverted:c,layer:"bottom"})):y.push(vge({fs:r/5,pn:M,anchor_x:U,anchor_y:O,textalign:_,orthogonal:l,verticallyinverted:c,layer:"top"})),p&&y.push(vge({fs:r/5,pn:M,anchor_x:U,anchor_y:O,textalign:_,orthogonal:l,verticallyinverted:c,layer:"bottom"})))},I=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(I.has(O))throw new Error(`Overlap at ${O}`);I.add(O),S(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(I.has(Y))throw new Error(`Overlap at ${Y}`);I.add(Y),S(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 X=M+O*t,K=Y*b,J=`${X},${K}`;if(I.has(J))throw new Error(`Overlap at ${J}`);I.add(J),S(k++,X,K)}O++;for(let Y=O;Y<=H&&k<=s;Y++){const X=M+Y*t,K=U*b,J=`${X},${K}`;if(I.has(J))throw new Error(`Overlap at ${J}`);I.add(J),S(k++,X,K)}if(U--,O<=H){for(let Y=U;Y>=C&&k<=s;Y--){const X=M+H*t,K=Y*b,J=`${X},${K}`;if(I.has(J))throw new Error(`Overlap at ${J}`);I.add(J),S(k++,X,K)}H--}if(C<=U){for(let Y=H;Y>=O&&k<=s;Y--){const X=M+Y*t,K=C*b,J=`${X},${K}`;if(I.has(J))throw new Error(`Overlap at ${J}`);I.add(J),S(k++,X,K)}C++}}if(k-1<s)throw new Error(`Missing pins: assigned ${k-1}, expected ${s}`)}const R=Uo(0,t,.5);return{circuitJson:[...y,R],parameters:e}},S2n=rE({}),E2n=n=>{const e=S2n.parse({fn:"sot563",num_pins:6,w:1.94,p:.5,pw:.3,pl:.67,legoutside:!0});return{circuitJson:Z5(e),parameters:e}},T2n=rE({p:"1.27mm",w:"3.9mm",legsoutside:!0}),M2n=n=>{const e=T2n.parse({...n,num_pins:8});return{circuitJson:Z5(e),parameters:e}},C2n=rE({p:"1.27mm",w:"7.5mm",legsoutside:!0}),A2n=n=>{const e=C2n.parse({...n,num_pins:16});return{circuitJson:Z5(e),parameters:e}},P2n=Ee({fn:N(),num_pins:me(3).default(3),w:N().default("1.2mm"),h:N().default("1.2mm"),pl:N().default("0.3mm"),pw:N().default("0.32mm")}),R2n=n=>{const e=P2n.parse(n),t=N2n(e),i=Uo(.4,_t.parse(e.h),.2);return{circuitJson:[...t,i],parameters:e}},I2n=n=>{const{pn:e}=n;return e===1?{x:0,y:0}:e===2?{x:1,y:-.4}:{x:1,y:.4}},N2n=n=>{const e=[];for(let t=0;t<3;t++){const{x:i,y:r}=I2n({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},k2n=Ee({fn:N(),num_pins:me(2).default(2),w:N().default("2.36mm"),h:N().default("1.22mm"),pl:N().default("0.9mm"),pw:N().default("0.9mm"),p:N().default("4.19mm")}),O2n=n=>{const e=k2n.parse(n),t=Uo(0,_t.parse(e.h)/4+.4,.3);return{circuitJson:D2n(e).concat(t),parameters:e}},L2n=n=>{const{pn:e,p:t}=n;return e===1?{x:-t/2,y:0}:{x:t/2,y:0}},D2n=n=>{const e=[];for(let t=1;t<=n.num_pins;t++){const{x:i,y:r}=L2n({pn:t,p:Number.parseFloat(n.p)});e.push(zr(t,i,r,Number.parseFloat(n.pl),Number.parseFloat(n.pw)))}return e},z2n=Ee({fn:N(),p:_t.optional().default("2.54mm"),id:_t.optional().default("0.7mm"),od:_t.optional().default("1mm")}),$2n=n=>{const e=z2n.parse(n),{p:t,id:i,od:r}=e,o=[ka(1,-t/2,0,i,r),ka(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=Uo(0,t/4,.5);return{circuitJson:[...o,s,a],parameters:e}},zV=(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}),F2n=Ee({fn:me("pushbutton"),w:_t.default(4.5),h:_t.default(6.5),id:_t.default(1),od:_t.default(1.2)}),U2n=n=>{const e=F2n.parse(n),t=e.w,i=e.h,r=e.id,o=[ka(1,-t/2,i/2,r,r*1.5),ka(2,-t/2,-i/2,r,r*1.5),ka(3,t/2,-i/2,r,r*1.5),ka(4,t/2,i/2,r,r*1.5)],s=[zV([{x:-t/2,y:-i/2},{x:-t/2,y:i/2}]),zV([{x:t/2,y:-i/2},{x:t/2,y:i/2}]),zV([{x:-t/2,y:0},{x:-t/5,y:0},{x:t/5*1/Math.sqrt(2),y:i/8}]),zV([{x:t/2,y:0},{x:t/5,y:0}])],a=Uo(0,i/2+.4,.5);return{circuitJson:[...o,...s,a],parameters:e}},Att=Ee({fn:N(),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"))}),B2n=n=>{const e=Att.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},$V=(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},j2n=n=>{const e=Att.parse(n),t=e.h??B2n(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 y=0;y<e.right;y++){if(y===0&&!e.left&&!e.bottom&&!e.silkscreenlabels&&(s=$V(e.w/2-e.pl*1.4,_+y*e.p,"right")),i.push(zr(y+1+e.left+(e.bottom??0),e.w/2-e.pl/2,_+y*e.p,e.pl,e.pw)),e.silkscreenlabels){const x=y+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:_+y*e.p},text:b,font_size:.7,font:"tscircuit2024",anchor_alignment:"center"})}e.innerhole&&(r.push(ka(y+1+e.left+(e.bottom??0)+l,e.w/2,_+y*e.p,a,c)),r.push(ka(y+1+e.left+(e.bottom??0)+l*2,e.w/2-e.innerholeedgedistance,_+y*e.p,a,c)))}}if(e.left){const _=(e.left-1)/2*e.p;for(let y=0;y<e.left;y++){if(y===0&&!e.silkscreenlabels&&(s=$V(-e.w/2+e.pl*1.4,_-y*e.p,"left")),i.push(zr(y+1,-e.w/2+e.pl/2,_-y*e.p,e.pl,e.pw)),e.silkscreenlabels){const x=y+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:_-y*e.p},text:b,font_size:.7,font:"tscircuit2024",anchor_alignment:"center"})}e.innerhole&&(r.push(ka(y+1+l,-e.w/2,_-y*e.p,a,c)),r.push(ka(y+1+l*2,-e.w/2+e.innerholeedgedistance,_-y*e.p,a,c)))}}if(e.top){const _=(e.top-1)/2*e.p;for(let y=0;y<e.top;y++){if(y===0&&!e.left&&!e.bottom&&!e.right&&!e.silkscreenlabels&&(s=$V(_-y*e.p,t/2-e.pl*1.4,"top")),i.push(zr(y+1+e.left+e.right+(e.bottom??0),_-y*e.p,t/2-e.pl/2,e.pw,e.pl)),e.silkscreenlabels){const x=y+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:_-y*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(ka(y+1+e.left+e.right+(e.bottom??0)+l,_-y*e.p,t/2,a,c)),r.push(ka(y+1+e.left+e.right+(e.bottom??0)+l*2,_-y*e.p,t/2-e.innerholeedgedistance,a,c)))}}if(e.bottom){const _=-((e.bottom-1)/2)*e.p;for(let y=0;y<e.bottom;y++){if(y===0&&!e.left&&!e.silkscreenlabels&&(s=$V(_+y*e.p,-t/2+e.pl*1.4,"bottom")),i.push(zr(y+1+e.left,_+y*e.p,-t/2+e.pl/2,e.pw,e.pl)),e.silkscreenlabels){const x=y+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:_+y*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(ka(y+1+e.left+l,_+y*e.p,-t/2,a,c)),r.push(ka(y+1+e.left+l*2,_+y*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=Uo(0,t/1.8,t/25);return{circuitJson:[...i,...r,...o,p,...e.silkscreenlabels?[]:[h],m],parameters:e}},Ptt=Ee({fn:N(),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"))}),H2n=n=>{const e=Ptt.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},V2n=(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]},G2n=n=>{const e=Ptt.parse(n),t=e.h??H2n(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=V2n(-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(ka(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(ka(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(ka(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(ka(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=Uo(0,t/1.8,t/25);return{circuitJson:[...o,...i,...r,h,d,p],parameters:e}},Y2n=n=>(n.legsoutside=!0,TL(n)),Rtt=Ee({fn:N(),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"))}),q2n=n=>{const e=Rtt.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},FV=(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]},X2n=n=>{const e=Rtt.parse(n),t=e.h??q2n(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=FV(e.w/2+o*1.4,u+d*e.p,"right")),i.push(ka(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=FV(-e.w/2-o*1.4,u+d*e.p,"left")),i.push(ka(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=FV(u+d*e.p,t/2+o*1.4,"top")),i.push(ka(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=FV(u+d*e.p,-t/2-o*1.4,"bottom")),i.push(ka(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=Uo(0,t/1.7,t/25);return{circuitJson:[...i,c,l,a],parameters:e}},Itt=(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}}),W2n=Ee({fn:N(),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")}),K2n=n=>{const e=W2n.parse(n),{p:t,id:i,od:r,w:o,h:s}=e,a=s/2,c=[ka(1,-t/2,0,i,r),ka(2,t/2,0,i,r)],l=Itt(-o/2,0,a,"left"),u=Itt(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=Uo(0,t/4,.5);return{circuitJson:[...c,d,h],parameters:e}};Ee({w:_t,h:_t});var Z2n=n=>{const{w:e,h:t}=n,i=xh(e),r=xh(t);return{circuitJson:[zr(1,0,0,i,r),Uo(0,r/2+.5,.2)],parameters:n}},Q2n=Ee({fn:N(),num_pins:Bn([me(3),me(2)]).default(3),p:N().default("1.27mm"),id:N().default("0.72mm"),od:N().default("0.95mm"),w:N().default("4.5mm"),h:N().default("4.5mm"),inline:Je().default(!1),string:N().optional()}),J2n=(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}}),eEn=n=>{const{p:e,id:t,od:i,h:r}=n,o=Number.parseFloat(r)/2,s=Number.parseFloat(e);return[ka(1,-s,o-s,t,i),ka(2,s,o-s,t,i)]},tEn=n=>{const e=n.string?.match(/^to92_(\d+)/),t=e?Number.parseInt(e[1],10):3,i=Q2n.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?[ka(1,-d,u-d,o,s),ka(2,0,u-d,o,s),ka(3,d,u-d,o,s)]:[ka(1,0,u,o,s),ka(2,-d,u-d,o,s),ka(3,d,u-d,o,s)];else if(i.num_pins===2)h=eEn(i);else throw new Error("Invalid number of pins for TO-92");const p=Number.parseFloat(a)/2,m=J2n(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:""},y=Uo(0,u+1,.5);return{circuitJson:[...h,_,y],parameters:i}},nEn=Ee({fn:N(),num_pins:me(2).default(2),w:N().default("2.15mm"),h:N().default("1.20mm"),pl:N().default("0.5mm"),pw:N().default("0.6mm"),p:N().default("1.4mm")}),iEn=n=>{const e=nEn.parse(n),t=Uo(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:oEn(e).concat(i,t),parameters:e}},rEn=n=>{const{pn:e,p:t}=n;return e===1?{x:-t/2,y:0}:{x:t/2,y:0}},oEn=n=>{const e=[];for(let t=1;t<=n.num_pins;t++){const{x:i,y:r}=rEn({pn:t,p:Number.parseFloat(n.p)});e.push(zr(t,i,r,Number.parseFloat(n.pl),Number.parseFloat(n.pw)))}return e},sEn=rE({}),aEn=n=>{const e=sEn.parse(n),t=[];for(let s=0;s<e.num_pins;s++){const{x:a,y:c}=gge({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=Uo(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}},cEn=Ee({fn:N(),num_pins:me(2).default(2),w:N().default("5.0mm"),h:N().default("2.30mm"),pl:N().default("1.25mm"),pw:N().default("2mm"),p:N().default("3.75mm")}),lEn=n=>{const e=cEn.parse(n),t=Uo(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:dEn(e).concat(i,t),parameters:e}},uEn=n=>{const{pn:e,p:t}=n;return e===1?{x:-t/2,y:0}:{x:t/2,y:0}},dEn=n=>{const e=[];for(let t=1;t<=n.num_pins;t++){const{x:i,y:r}=uEn({pn:t,p:Number.parseFloat(n.p)});e.push(zr(t,i,r,Number.parseFloat(n.pl),Number.parseFloat(n.pw)))}return e},hEn=Ee({fn:N(),num_pins:me(2).default(2),w:N().default("4.4mm"),h:N().default("2.1mm"),pl:N().default("1.2mm"),pw:N().default("1.2mm"),p:N().default("2.9mm")}),pEn=n=>{const e=hEn.parse(n),t=Uo(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:mEn(e).concat(i,t),parameters:e}},fEn=n=>{const{pn:e,p:t}=n;return e===1?{x:-t/2,y:0}:{x:t/2,y:0}},mEn=n=>{const e=[];for(let t=1;t<=n.num_pins;t++){const{x:i,y:r}=fEn({pn:t,p:Number.parseFloat(n.p)});e.push(zr(t,i,r,Number.parseFloat(n.pl),Number.parseFloat(n.pw)))}return e},_En=Ee({fn:N(),num_pins:me(2).default(2),w:N().default("3.30mm"),h:N().default("1.80mm"),pl:N().default("0.60mm"),pw:N().default("0.45mm"),p:N().default("2.1mm")}),yEn=n=>{const e=_En.parse(n),t=Uo(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:xEn(e).concat(i,t),parameters:e}},gEn=n=>{const{pn:e,p:t}=n;return e===1?{x:-t/2,y:0}:{x:t/2,y:0}},xEn=n=>{const e=[];for(let t=1;t<=n.num_pins;t++){const{x:i,y:r}=gEn({pn:t,p:Number.parseFloat(n.p)});e.push(zr(t,i,r,Number.parseFloat(n.pl),Number.parseFloat(n.pw)))}return e},bEn=Ee({fn:N(),num_pins:me(2).default(2),w:N().default("1.4mm"),h:N().default("0.9mm"),pl:N().default("0.35mm"),pw:N().default("0.25mm"),p:N().default("1.2mm")}),vEn=n=>{const e=bEn.parse(n),t=Uo(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:SEn(e).concat(i,t),parameters:e}},wEn=n=>{const{pn:e,p:t}=n;return e===1?{x:-t/2,y:0}:{x:t/2,y:0}},SEn=n=>{const e=[];for(let t=1;t<=n.num_pins;t++){const{x:i,y:r}=wEn({pn:t,p:Number.parseFloat(n.p)});e.push(zr(t,i,r,Number.parseFloat(n.pl),Number.parseFloat(n.pw)))}return e},EEn=Ee({fn:N(),num_pins:me(2).default(2),w:N().default("1.3mm"),h:N().default("0.9mm"),pl:N().default("0.4mm"),pw:N().default("0.7mm"),p:N().default("0.7mm")}),TEn=n=>{const e=EEn.parse(n),t=Uo(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:CEn(e).concat(i,t),parameters:e}},MEn=n=>{const{pn:e,p:t}=n;return e===1?{x:-t/2,y:0}:{x:t/2,y:0}},CEn=n=>{const e=[];for(let t=1;t<=n.num_pins;t++){const{x:i,y:r}=MEn({pn:t,p:Number.parseFloat(n.p)});e.push(zr(t,i,r,Number.parseFloat(n.pl),Number.parseFloat(n.pw)))}return e},AEn=Ee({fn:N(),num_pins:me(2).default(2),w:N().default("3,05mm"),h:N().default("1.65mm"),pl:N().default("0.6mm"),pw:N().default("0.6mm"),pad_spacing:N().default("2.2mm")}),PEn=n=>{const e=AEn.parse(n),t=Uo(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:IEn(e).concat(i,t),parameters:e}},REn=n=>{const{pn:e,pad_spacing:t}=n;return e===1?{x:-t/2,y:0}:{x:t/2,y:0}},IEn=n=>{const e=[];for(let t=1;t<=n.num_pins;t++){const{x:i,y:r}=REn({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},NEn=Ee({fn:N(),num_pins:me(2).default(2),w:N().default("4.4mm"),h:N().default("2.1mm"),pl:N().default("1.2mm"),pw:N().default("1.2mm"),p:N().default("2.9mm")}),kEn=n=>{const e=NEn.parse(n),t=Uo(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:LEn(e).concat(i,t),parameters:e}},OEn=n=>{const{pn:e,p:t}=n;return e===1?{x:-t/2,y:0}:{x:t/2,y:0}},LEn=n=>{const e=[];for(let t=1;t<=n.num_pins;t++){const{x:i,y:r}=OEn({pn:t,p:Number.parseFloat(n.p)});e.push(zr(t,i,r,Number.parseFloat(n.pl),Number.parseFloat(n.pw)))}return e},DEn=Ee({fn:N(),num_pins:me(2).default(2),w:N().default("4.4mm"),h:N().default("2.1mm"),pl:N().default("0.91mm"),pw:N().default("1.22mm"),p:N().default("3.146mm")}),zEn=n=>{const e=DEn.parse(n),t=Uo(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:FEn(e).concat(i,t),parameters:e}},$En=n=>{const{pn:e,p:t}=n;return e===1?{x:-t/2,y:0}:{x:t/2,y:0}},FEn=n=>{const e=[];for(let t=1;t<=n.num_pins;t++){const{x:i,y:r}=$En({pn:t,p:Number.parseFloat(n.p)});e.push(zr(t,i,r,Number.parseFloat(n.pl),Number.parseFloat(n.pw)))}return e},UEn=Ee({fn:N(),num_pins:me(2).default(2),w:N().default("1.80mm"),h:N().default("1.00mm"),pl:N().default("0.66mm"),pw:N().default("0.5mm"),p:N().default("0.8mm")}),BEn=n=>{const e=UEn.parse(n),t=Uo(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:HEn(e).concat(i,t),parameters:e}},jEn=n=>{const{pn:e,p:t}=n;return e===1?{x:-t/2,y:0}:{x:t/2,y:0}},HEn=n=>{const e=[];for(let t=1;t<=n.num_pins;t++){const{x:i,y:r}=jEn({pn:t,p:Number.parseFloat(n.p)});e.push(zr(t,i,r,Number.parseFloat(n.pl),Number.parseFloat(n.pw)))}return e},VEn=Ee({fn:N(),num_pins:me(2).default(2),w:N().default("6.2mm"),h:N().default("3.4mm"),pl:N().default("1.4mm"),pw:N().default("2.1mm"),p:N().default("4.4mm")}),GEn=n=>{const e=VEn.parse(n),t=Uo(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:qEn(e).concat(i,t),parameters:e}},YEn=n=>{const{pn:e,p:t}=n;return e===1?{x:-t/2,y:0}:{x:t/2,y:0}},qEn=n=>{const e=[];for(let t=1;t<=n.num_pins;t++){const{x:i,y:r}=YEn({pn:t,p:Number.parseFloat(n.p)});e.push(zr(t,i,r,Number.parseFloat(n.pl),Number.parseFloat(n.pw)))}return e},XEn=Ee({fn:N(),num_pins:Bn([me(3),me(5)]).default(3),w:N().default("4.80mm"),h:N().default("4.80mm"),pl:N().default("1.3mm"),pw:N().default("0.9mm"),p:N().default("1.5mm"),string:N().optional()}),WEn=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=Uo(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]},KEn=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=Uo(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]},ZEn=n=>{const e=n.string?.match(/^sot89_(\d+)/),t=e?Number.parseInt(e[1],10):3,i=XEn.parse({...n,num_pins:t});if(i.num_pins===3)return{circuitJson:WEn(i),parameters:i};if(i.num_pins===5)return{circuitJson:KEn(i),parameters:i};throw new Error("Invalid number of pins for SOT89")},QEn=Ee({fn:N(),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:Ie().optional(),string:N().optional()}),JEn=n=>{const e=QEn.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},(I,A)=>{const R=c%2===0?(A-c/2+.5)*m:(A-Math.floor(c/2))*m;return ka(A+1,R,l,i,r)}),y={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:""}],S=Uo(0,s/2+.6,.5);return{circuitJson:[..._,y,b,...w,S],parameters:{...e,p:m}}},eTn=Ee({fn:N(),num_pins:me(2).default(2),w:N().default("5.40mm"),h:N().default("2.30mm"),pl:N().default("1.30mm"),pw:N().default("1.70mm"),p:N().default("3.5mm")}),tTn=n=>{const e=eTn.parse(n),t=Uo(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:iTn(e).concat(i,t),parameters:e}},nTn=n=>{const{pn:e,p:t}=n;return e===1?{x:-t/2,y:0}:{x:t/2,y:0}},iTn=n=>{const e=[];for(let t=1;t<=n.num_pins;t++){const{x:i,y:r}=nTn({pn:t,p:Number.parseFloat(n.p)});e.push(zr(t,i,r,Number.parseFloat(n.pl),Number.parseFloat(n.pw)))}return e},rTn=Ee({fn:N(),num_pins:me(2).default(2),w:N().default("1.90mm"),h:N().default("1.33mm"),pl:N().default("0.5mm"),pw:N().default("0.7mm"),p:N().default("0.8mm")}),oTn=n=>{const e=rTn.parse(n),t=Uo(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:aTn(e).concat(i,t),parameters:e}},sTn=n=>{const{pn:e,p:t}=n;return e===1?{x:-t/2,y:0}:{x:t/2,y:0}},aTn=n=>{const e=[];for(let t=1;t<=n.num_pins;t++){const{x:i,y:r}=sTn({pn:t,p:Number.parseFloat(n.p)});e.push(zr(t,i,r,Number.parseFloat(n.pl),Number.parseFloat(n.pw)))}return e},cTn=Ee({fn:N(),num_pins:me(2).default(2),w:N().default("7.0mm"),h:N().default("3.35mm"),pl:N().default("1.50mm"),pw:N().default("2.70mm"),p:N().default("4.8mm")}),lTn=n=>{const e=cTn.parse(n),t=Uo(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:dTn(e).concat(i,t),parameters:e}},uTn=n=>{const{pn:e,p:t}=n;return e===1?{x:-t/2,y:0}:{x:t/2,y:0}},dTn=n=>{const e=[];for(let t=1;t<=n.num_pins;t++){const{x:i,y:r}=uTn({pn:t,p:Number.parseFloat(n.p)});e.push(zr(t,i,r,Number.parseFloat(n.pl),Number.parseFloat(n.pw)))}return e},hTn=Ee({fn:N(),num_pins:me(2).default(2),w:N().default("3.0mm"),h:N().default("1.80mm"),pl:N().default("0.80mm"),pw:N().default("1.20mm"),p:N().default("1.6mm")}),pTn=n=>{const e=hTn.parse(n),t=Uo(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:mTn(e).concat(i,t),parameters:e}},fTn=n=>{const{pn:e,p:t}=n;return e===1?{x:-t/2,y:0}:{x:t/2,y:0}},mTn=n=>{const e=[];for(let t=1;t<=n.num_pins;t++){const{x:i,y:r}=fTn({pn:t,p:Number.parseFloat(n.p)});e.push(zr(t,i,r,Number.parseFloat(n.pl),Number.parseFloat(n.pw)))}return e},_Tn=Ee({fn:N(),num_pins:me(2).default(2),w:N().default("7.10mm"),h:N().default("3.40mm"),pl:N().default("2.45mm"),pw:N().default("1.80mm"),p:N().default("4.05mm")}),yTn=n=>{const e=_Tn.parse(n),t=Uo(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:xTn(e).concat(i,t),parameters:e}},gTn=n=>{const{pn:e,p:t}=n;return e===1?{x:-t/2,y:0}:{x:t/2,y:0}},xTn=n=>{const e=[];for(let t=1;t<=n.num_pins;t++){const{x:i,y:r}=gTn({pn:t,p:Number.parseFloat(n.p)});e.push(zr(t,i,r,Number.parseFloat(n.pl),Number.parseFloat(n.pw)))}return e},bTn=Ee({fn:N(),num_pins:me(2).default(2),w:N().default("4.80mm"),h:N().default("2.10mm"),pl:N().default("1.30mm"),pw:N().default("1.40mm"),p:N().default("2.9mm")}),vTn=n=>{const e=bTn.parse(n),t=Uo(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:STn(e).concat(i,t),parameters:e}},wTn=n=>{const{pn:e,p:t}=n;return e===1?{x:-t/2,y:0}:{x:t/2,y:0}},STn=n=>{const e=[];for(let t=1;t<=n.num_pins;t++){const{x:i,y:r}=wTn({pn:t,p:Number.parseFloat(n.p)});e.push(zr(t,i,r,Number.parseFloat(n.pl),Number.parseFloat(n.pw)))}return e},ETn=Ee({fn:N(),num_pins:me(2).default(2),w:N().default("7.30mm"),h:N().default("4.40mm"),pl:N().default("2.50mm"),pw:N().default("2.30mm"),p:N().default("4.30mm")}),TTn=n=>{const e=ETn.parse(n),t=Uo(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:CTn(e).concat(i,t),parameters:e}},MTn=n=>{const{pn:e,p:t}=n;return e===1?{x:-t/2,y:0}:{x:t/2,y:0}},CTn=n=>{const e=[];for(let t=1;t<=n.num_pins;t++){const{x:i,y:r}=MTn({pn:t,p:Number.parseFloat(n.p)});e.push(zr(t,i,r,Number.parseFloat(n.pl),Number.parseFloat(n.pw)))}return e},ATn=Ee({fn:N(),num_pins:me(2).default(2),w:N().default("10.70mm"),h:N().default("6.60mm"),pl:N().default("3.30mm"),pw:N().default("2.50mm"),p:N().default("6.80mm")}),PTn=n=>{const e=ATn.parse(n),t=Uo(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:ITn(e).concat(i,t),parameters:e}},RTn=n=>{const{pn:e,p:t}=n;return e===1?{x:-t/2,y:0}:{x:t/2,y:0}},ITn=n=>{const e=[];for(let t=1;t<=n.num_pins;t++){const{x:i,y:r}=RTn({pn:t,p:Number.parseFloat(n.p)});e.push(zr(t,i,r,Number.parseFloat(n.pl),Number.parseFloat(n.pw)))}return e},NTn=Ee({fn:N(),num_pins:Ie().default(4),w:N().default("8.50mm"),h:N().default("6.90mm"),pl:N().default("2mm"),pw:N().default("1.5mm"),p:N().default("2.30mm"),string:N().optional()}),kTn=n=>{const e=n.string?.match(/^sot223_(\d+)/),t=e?Number.parseInt(e[1],10):4;if(t===8){const r=DTn.parse({...n,num_pins:t});return{circuitJson:Z5(r),parameters:r}}const i=NTn.parse({...n,num_pins:t});if(i.num_pins===4)return{circuitJson:LTn(i),parameters:i};if(i.num_pins===5)return{circuitJson:$Tn(i),parameters:i};if(i.num_pins===6)return{circuitJson:UTn(i),parameters:i};throw new Error("Invalid number of pins")},OTn=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}},LTn=n=>{const e=[];for(let a=0;a<n.num_pins;a++){const{x:c,y:l}=OTn({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=Uo(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]},DTn=rE({p:"0.90mm",w:"2.8mm",legsoutside:!0}),zTn=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")},$Tn=n=>{const e=[];for(let a=1;a<=n.num_pins;a++){const{x:c,y:l}=zTn({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=Uo(0,0,.3);return[...e,r,o,s]},FTn=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")},UTn=n=>{const e=[];for(let a=1;a<=n.num_pins;a++){const{x:c,y:l}=FTn({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=Uo(0,0,.3);return[...e,r,o,s]},BTn=Ee({fn:N(),num_pins:Ie().default(3),w:N().default("3.40mm"),h:N().default("3.30mm"),pl:N().default("1mm"),pw:N().default("0.7mm"),p:N().default("1.2mm"),string:N().optional()}),jTn=n=>{const e=n.string?.match(/^sot23w_(\d+)/),t=e?Number.parseInt(e[1],3):3,i=BTn.parse({...n,num_pins:t});if(i.num_pins===3)return{circuitJson:VTn(i),parameters:i};throw new Error("Invalid number of pins")},HTn=n=>{const{pn:e,p:t}=n;return e===1?{x:-t,y:.95}:e===2?{x:-t,y:-.95}:{x:t,y:0}},VTn=n=>{const e=[];for(let a=0;a<n.num_pins;a++){const{x:c,y:l}=HTn({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=Uo(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]},GTn=Ee({fn:N(),num_pins:Bn([me(3),me(2)]).default(3),p:N().default("1.27mm"),id:N().default("0.72mm"),od:N().default("0.95mm"),w:N().default("2.5mm"),h:N().default("4.2mm"),string:N().optional()}),YTn=n=>{const{p:e,id:t,od:i,w:r,h:o}=n,s=Number.parseFloat(o)/2,a=Number.parseFloat(e);return[ka(1,-a,s-a,t,i),ka(2,0,s-a,t,i),ka(3,a,s-a,t,i)]},qTn=n=>{const{p:e,id:t,od:i,h:r}=n,o=Number.parseFloat(r)/2,s=Number.parseFloat(e);return[ka(1,-s,o-s,t,i),ka(2,s,o-s,t,i)]},XTn=n=>{const e=n.string?.match(/^to92s_(\d+)/),t=e?Number.parseInt(e[1],10):3,i=GTn.parse({...n,num_pins:t});let r=[];if(i.num_pins===3)r=YTn(i);else if(i.num_pins===2)r=qTn(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=Uo(0,o+1,.5);return{circuitJson:[...r,a,c],parameters:i}},WTn=Ee({fn:N(),p:_t.optional(),id:_t.optional(),pw:_t.optional(),pl:_t.optional(),w:_t.optional(),h:_t.optional(),sh:Bn([Je(),N(),Ie()]).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:N().optional()}),KTn={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 ZTn(n){return n.sh?"sh":(n.ph,"ph")}function QTn(n,e,t,i,r,o){const s=[];if(n==="ph"){const a=t/2;s.push(DV(1,-a,2,i,r,o)),s.push(DV(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 JTn(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 e5n=n=>{const e=WTn.parse(n),t=ZTn(e),i=KTn[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 y=parseInt(_[1],10);Number.isNaN(y)||(u=y)}else typeof e.sh=="number"&&(u=e.sh)}const d=QTn(t,u,r,o,s,a),h=JTn(t),p=Uo(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"}}},t5n=Ee({fn:N(),num_pins:me(2).default(2),w:N().default("3.30mm"),h:N().default("1.70mm"),pl:N().default("0.80mm"),pw:N().default("1mm"),p:N().default("1.90mm")}),n5n=n=>{const e=t5n.parse(n),t=Uo(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:r5n(e).concat(i,t),parameters:e}},i5n=n=>{const{pn:e,p:t}=n;return e===1?{x:-t/2,y:0}:{x:t/2,y:0}},r5n=n=>{const e=[];for(let t=1;t<=n.num_pins;t++){const{x:i,y:r}=i5n({pn:t,p:Number.parseFloat(n.p)});e.push(zr(t,i,r,Number.parseFloat(n.pl),Number.parseFloat(n.pw)))}return e},o5n=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"}}},s5n=Ee({fn:N(),num_pins:Bn([me(8),me(10)]).default(8),w:N().optional(),h:N().optional(),p:N().optional(),pl:N().optional(),pw:N().optional(),string:N().optional()}),a5n=n=>{const e=s5n.parse(n),t=o5n(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:S}=Ntt(e.num_pins,b+1,i,o),I=b<l?b+1:e.num_pins-(b-l);c.push(zr(I,w,S,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=Ntt(e.num_pins,1,u,o),_={x:m.x-.8,y:m.y},y={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=Uo(0,d/2+.5,.3);return{circuitJson:[...c,h,p,x,y],parameters:e}},Ntt=(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}},c5n=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"}}},l5n=Ee({fn:N(),num_pins:Bn([me(8),me(10),me(12),me(16)]).default(8),w:N().optional(),h:N().optional(),p:N().optional(),pl:N().optional(),pw:N().optional(),string:N().optional()}),ktt=(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}},u5n=n=>{const e=l5n.parse(n),t=c5n(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}=ktt(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=ktt(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"},y=Uo(0,u/2+.5,.3);return{circuitJson:[...c,d,h,y,_],parameters:e}},d5n=Ee({fn:N(),num_pins:me(2).default(2),w:N().default("3.8mm"),h:N().default("1.65mm"),pl:N().default("1.2mm"),pw:N().default("1.2mm"),pad_spacing:N().default("2.6mm")}),h5n=n=>{const e=d5n.parse(n),t=Uo(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:f5n(e).concat(i,t),parameters:e}},p5n=n=>{const{pn:e,pad_spacing:t}=n;return e===1?{x:-t/2,y:0}:{x:t/2,y:0}},f5n=n=>{const e=[];for(let t=1;t<=n.num_pins;t++){const{x:i,y:r}=p5n({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},m5n=Ee({fn:N(),num_pins:me(2).default(2),w:N().default("3.20mm"),h:N().default("1.65mm"),pl:N().default("0.8mm"),pw:N().default("0.9mm"),pad_spacing:N().default("2.1mm")}),_5n=n=>{const e=m5n.parse(n),t=Uo(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:g5n(e).concat(i,t),parameters:e}},y5n=n=>{const{pn:e,pad_spacing:t}=n;return e===1?{x:-t/2,y:0}:{x:t/2,y:0}},g5n=n=>{const e=[];for(let t=1;t<=n.num_pins;t++){const{x:i,y:r}=y5n({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},x5n=Ee({fn:N(),num_pins:Bn([me(6),me(8)]).default(8),w:N().default("3mm"),h:N().default("3mm"),p:N().default("0.5mm"),pl:N().default("0.52mm"),pw:N().default("0.35mm"),epw:N().default("1.40mm"),eph:N().default("1.60mm"),string:N().optional(),ep:Je().default(!1)}),b5n=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=x5n.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 S=0;S<i.num_pins;S++){const{x:I,y:A}=Ott(i.num_pins,S+1,r,s);d.push(zr(S+1,I,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:""},y=Ott(i.num_pins,1,h,s),x={x:y.x-.4,y:y.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=Uo(0,p/2+.5,.3);return{circuitJson:[...d,m,_,w,b],parameters:i}},Ott=(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}},v5n=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 S=0;S<e;S++)u.push(zr(S+1,S*s,0,a,c));let d=[];if(t){const S=t.split("").map(Number);if(S.length>1)for(let I=0;I<S.length-1;I++){const A=S[I],R=S[I+1];if(typeof A=="number"&&typeof R=="number"&&!isNaN(A)&&!isNaN(R)){const M=(A-1)*s,k=(R-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${R}}`,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,y={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=Uo(m,b,.4);return{circuitJson:[...u,...d,y,w],parameters:n}},Ltt={fn:me("sot457"),num_pins:me(6).default(6),pillh:N().default("0.45mm"),pillw:N().default("1.45mm"),pl:N(),pw:N(),p:N(),wave:Je().optional(),reflow:Je().optional()},w5n=Ee({...Ltt,h:N().default("2.5mm"),w:N().default("2.7mm"),pl:N().default("0.8mm"),pw:N().default("0.55mm"),p:N().default("0.95mm")}),S5n=Ee({...Ltt,h:N().default("3mm"),w:N().default("4mm"),pillr:N().default("0.225mm"),pl:N().default("1.45mm"),pw:N().default("1.5mm"),p:N().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)})),Q5=n=>Number.parseFloat(n.replace("mm","")),Dtt=({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},ztt=n=>{const e=[],t=Q5(n.p),i=Q5(n.pl),r=Q5(n.pw),o=Q5(n.w),s=Q5(n.h);if(n.wave){const m={1:({padWidth:_,padHeight:y})=>zr(1,-t,t,y,_),2:({padWidth:_,padHeight:y})=>zr(2,-t,-t,y,_),3:({padWidth:_,padHeight:y})=>LV(3,-t,0,Q5(n.pillw),Q5(n.pillh)),4:({padWidth:_,padHeight:y})=>LV(4,t,0,Q5(n.pillw),Q5(n.pillh)),5:({padWidth:_,padHeight:y})=>zr(5,t,t,y,_),6:({padWidth:_,padHeight:y})=>zr(6,t,-t,y,_)};for(let _=1;_<=n.num_pins;_++){const y=m[_];y&&e.push(y({padWidth:i,padHeight:r}))}}else for(let m=1;m<=n.num_pins;m++){const{x:_,y}=Dtt({pitch:t,width:o,pinNumber:m});e.push(zr(m,_,y,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=Uo(0,s+.5,.3),u=Dtt({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]},E5n=n=>{if(n.wave){const t=S5n.parse({...n,fn:"sot457"});return{circuitJson:ztt(t),parameters:t}}const e=w5n.parse(n);return{circuitJson:ztt(e),parameters:e}},T5n=Ee({fn:N(),num_pins:Bn([me(3),me(2)]).default(3),p:N().default("3.8mm"),id:N().default("1.25mm"),od:N().default("2.35mm"),ca:N().default("14mm").describe("Caliper axis (width or diameter of the potentiometer body or adjustment knob)"),w:N().default("5.35mm"),h:N().default("4mm"),string:N().optional()}),M5n=n=>{const{p:e,id:t,od:i,h:r,ca:o}=n,s=Number.parseFloat(r),a=Number.parseFloat(o);return[ka(1,0,a/4+.3,t,i),ka(2,s,0,t,i),ka(3,0,-a/4-.3,t,i)]},C5n=n=>{const e=n.string?.match(/^potentiometer_(\d+)/),t=e?Number.parseInt(e[1],10):3,i=T5n.parse({...n,num_pins:t});let r=[];i.num_pins===3&&(r=M5n(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=Uo(u,o+1,.5);return{circuitJson:[...r,c,l,d],parameters:i}},A5n=Ee({fn:N(),p:_t.optional().default("7.5mm"),id:_t.optional().default("1mm"),od:_t.optional().default("2mm"),d:_t.optional().default("10.5mm")}),P5n=(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}},R5n=n=>{const e=A5n.parse(n),{p:t,id:i,od:r,d:o}=e,s=[ka(1,-t/2,0,i,r),ka(2,t/2,0,i,r)],{topArc:a,bottomArc:c}=P5n(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:""},y={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=Uo(0,o/2+1,.5);return{circuitJson:[...s,l,u,d,_,y,x],parameters:e}},I5n=Ee({fn:N(),num_pins:me(2).default(2),w:N().default("6.5mm"),h:N().default("3mm"),pl:N().default("1.75mm"),pw:N().default("2.40mm"),p:N().default("4.75mm")}),N5n=n=>{const e=I5n.parse(n),t=Uo(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:O5n(e).concat(i,t),parameters:e}},k5n=n=>{const{pn:e,p:t}=n;return e===1?{x:-t/2,y:0}:{x:t/2,y:0}},O5n=n=>{const e=[];for(let t=1;t<=n.num_pins;t++){const{x:i,y:r}=k5n({pn:t,p:Number.parseFloat(n.p)});e.push(zr(t,i,r,Number.parseFloat(n.pl),Number.parseFloat(n.pw)))}return e},L5n=Ee({fn:N(),num_pins:Ie().default(3),w:N().default("2.45mm"),h:N().default("2.40mm"),pl:N().default("0.45mm"),pw:N().default("0.70mm"),p:N().default("1mm"),string:N().optional()}),D5n=n=>{const e=n.string?.match(/^sot323_(\d+)/),t=e?Number.parseInt(e[1],3):3,i=L5n.parse({...n,num_pins:t});if(i.num_pins===3)return{circuitJson:$5n(i),parameters:i};throw new Error("Invalid number of pins")},z5n=n=>{const{pn:e,p:t}=n;return e===1?{x:-t,y:.65}:e===2?{x:-t,y:-.65}:{x:t,y:0}},$5n=n=>{const e=[];for(let a=0;a<n.num_pins;a++){const{x:c,y:l}=z5n({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=Uo(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]},F5n=Ee({fn:N(),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:N().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=xh(n.r):n.pr!==void 0?t=xh(n.pr):n.radius!==void 0?t=xh(n.radius):n.d!==void 0?t=xh(n.d)/2:n.pd!==void 0?t=xh(n.pd)/2:n.diameter!==void 0?t=xh(n.diameter)/2:t=xh("1mm")/2:(n.w!==void 0?i=xh(n.w):n.pw!==void 0?i=xh(n.pw):n.width!==void 0?i=xh(n.width):n.s!==void 0?i=xh(n.s):n.size!==void 0?i=xh(n.size):i=xh("1mm"),n.h!==void 0?r=xh(n.h):n.ph!==void 0?r=xh(n.ph):n.height!==void 0?r=xh(n.height):e==="square"||e==="rect"?r=i:r=xh("1mm")),{fn:n.fn,shape:e,radius:t,width:i,height:r}}),U5n=n=>{const e=F5n.parse(n),{shape:t,radius:i,width:r,height:o}=e;let s,a;return t==="circle"?(s=btt(1,{x:0,y:0,radius:i}),a=i+.5):t==="pill"?(s=LV(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,Uo(0,a,.2)],parameters:e}},B5n=Ee({fn:N(),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=xh(n.d):n.hd!==void 0?e=xh(n.hd):n.r!==void 0?e=xh(n.r)*2:n.hr!==void 0?e=xh(n.hr)*2:e=xh("1mm");let t;return n.pd!==void 0?t=xh(n.pd):n.pr!==void 0?t=xh(n.pr)*2:t=e*(1.5/1),{fn:n.fn,d:e,pd:t,squarepad:n.squarepad??!1}}),j5n=n=>{const e=B5n.parse(n),{d:t,pd:i,squarepad:r}=e;return{circuitJson:[r?DV(1,0,0,t,i,i):ka(1,0,0,t,i),Uo(0,i/2+.5,.2)],parameters:e}},H5n=Ee({fn:N(),num_pins:me(6).default(6),h:N().default("1.6mm"),pl:N().default("1mm"),pw:N().default("0.7mm"),p:N().default("0.95mm")}),V5n=n=>{const e=H5n.parse(n);return{circuitJson:G5n(e),parameters:e}},$tt=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")},G5n=n=>{const e=[];for(let d=1;d<=n.num_pins;d++){const{x:h,y:p}=$tt({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=Uo(0,i+.3,.3),a=$tt({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]},Y5n=Ee({fn:N()}),q5n=n=>{const e=Y5n.parse(n),t=[],i=.5-.15,r=1.5,s=.5/2,a=75,c=-37/2;for(let R=0;R<a;R++){const M=R+1;if(M>=24&&M<=31)continue;const k=c-R*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,y=-1/0,x=1/0,b=-1/0;const w=(R,M,k=0,C=0)=>{_=Math.min(_,R-k/2),y=Math.max(y,R+k/2),x=Math.min(x,M-C/2),b=Math.max(b,M+C/2)};for(const R of t)w(R.x,R.y,R.width,R.height);w(h.center.x,h.center.y,h.width,h.height);for(const R of m.route)w(R.x,R.y);const S=(_+y)/2,I=(x+b)/2,A=R=>{typeof R.x=="number"&&(R.x-=S),typeof R.y=="number"&&(R.y-=I),R.center&&(R.center.x-=S,R.center.y-=I),Array.isArray(R.route)&&(R.route=R.route.map(M=>({x:M.x-S,y:M.y-I})))};for(const R of t)A(R);return A(h),A(m),{circuitJson:[...t,h,m],parameters:e}};function X5n(n){return n!=null}var W5n=(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,y=d-p/2,x=d+p/2;i=Math.min(i,m),r=Math.max(r,_),o=Math.min(o,y),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},K5n=n=>{let e=UV();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(X5n);for(const{fn:r,v:o}of i)e=e[r](o);return e.setString(n),e},Z5n=()=>Object.keys(K5),UV=()=>{const n=new Proxy({},{get:(e,t)=>{if(t==="soup"||t==="circuitJson"){if("fn"in e&&K5[e.fn])return()=>{const{circuitJson:i}=K5[e.fn](e);return W5n(i,e.origin)};if(!K5[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(!K5[e.fn])throw new Error(`Invalid footprint function, got "${e.fn}"${e.string?`, from string "${e.string}"`:""}`);return()=>K5[e.fn](e).parameters}return t==="getFootprintNames"?()=>Object.keys(K5):t==="params"?()=>e:t==="setString"?i=>(e.string=i,n):i=>(Object.keys(e).length===0?`${t}${i}`in K5?(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};UV.string=K5n,UV.getFootprintNames=Z5n;var Q5n=UV,Ftt=Symbol("Fragment");function wge(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 ea=Symbol("Cuboid"),Utt=Symbol("Cube"),J5=Symbol("Cylinder"),Btt=Symbol("Sphere"),Sge=Symbol("RoundedCuboid"),Qb=Symbol("Translate"),fI=Symbol("Rotate"),BV=Symbol("Union"),jV=Symbol("Subtract"),S4=Symbol("Hull"),mT=Symbol("Colorize"),ML=Symbol("Polygon"),CL=Symbol("ExtrudeLinear"),Ty=Ftt,Yn=(n,e,t)=>wge(n,e),Zd=(n,e,t)=>wge(n,e),mI=({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(mT,{color:"#555",children:Yn(Qb,{offset:n,children:Yn(Qb,{offset:{x:0,y:0,z:r},children:Zd(jV,{children:[Zd(BV,{children:[Zd(S4,{children:[Yn(Qb,{z:.005,children:Yn(ea,{size:[c,l,.01]})}),Yn(Qb,{z:o,children:Yn(ea,{size:[e,t,.01]})})]}),Zd(S4,{children:[Yn(Qb,{z:o,children:Yn(ea,{size:[e,t,.01]})}),Yn(Qb,{z:o+s,children:Yn(ea,{size:[c,l,.01]})})]})]}),Yn(Qb,{offset:{x:0,y:d,z:i},children:Yn(fI,{rotation:[0,0,0],children:Yn(J5,{radius:h,height:p})})})]})})})})},J5n=n=>Array.from({length:n},(e,t)=>t);function Ege(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),y=m.x+_.x,x=m.y+_.y,b=Math.sqrt(y*y+x*x);if(b/2>2*i)a(h,m,1),a(h,_,1),a(h,m,-1),a(h,_,-1);else{const S=1/b;a(h,{x:y*S,y:x*S},1),a(h,{x:y*S,y:x*S},-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 e3n=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}))},t3n=e3n([{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}]),jtt=5.47,HV=.5,n3n=({x:n,y:e,z:t})=>{const i=n>0;return Zd(Ty,{children:[Yn(Qb,{offset:{x:n+.25/2,y:e,z:t},children:Yn(fI,{rotation:["-90deg",0,"90deg"],children:Yn(CL,{height:.25,children:Yn(ML,{points:t3n.map(r=>[r.x,r.y])})})})}),Yn(Qb,{offset:{x:n,y:e+(i?1:-1),z:t},children:Yn(fI,{rotation:["-90deg","90deg",i?"180deg":"0deg"],children:Yn(CL,{height:2,children:Yn(ML,{points:Ege([[0,0],[-1,0],[-1,-1]],.25).map(r=>[r.x,r.y])})})})})]})},i3n=({numPins:n=8,pitch:e=2.54,bodyWidth:t=6.4})=>{const i=Math.floor(n/2),r=t+1;return Zd(Ty,{children:[J5n(n).map(o=>{const s=o%i,a=(Math.floor(o/i)-.5)*2;return Yn(n3n,{x:a*r/2,y:s*e-(i-1)/2*e,z:jtt/2+HV})}),Yn(mI,{width:t,length:i*e+.5,height:jtt-HV,heightAboveSurface:HV,center:{x:0,y:0,z:HV}})]})};function r3n(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 Nv=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,r3n(u,n)]),l=Ege(c,e);return Yn(mT,{color:"#fff",children:Yn(Qb,{offset:{z:0,y:0,x:0,...n.position},children:Yn(fI,{rotation:["90deg",0,s??0],children:Yn(Qb,{offset:{x:0,y:0,z:-t/2},children:Yn(CL,{height:t,children:Yn(ML,{points:l.map(u=>[u.x,u.y])})})})})})})},o3n=({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 Zd(Ty,{children:[Array.from({length:o}).map((l,u)=>Yn(Nv,{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(Nv,{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(mI,{center:{x:0,y:0,z:c/2},width:r-t-1,length:s,height:1.5})]})},Tge=1,Mge=.5,_I=.5,AL=.2,s3n=Tge-AL*2,Htt=({color:n="#333"})=>Zd(Ty,{children:[Yn(ea,{size:[s3n,Mge,_I],offset:[0,0,_I/2],color:n}),Yn(ea,{size:[AL,_I,Mge],offset:[Tge/2-AL/2,0,_I/2],color:"#ccc"}),Yn(ea,{size:[AL,_I,Mge],offset:[-Tge/2+AL/2,0,_I/2],color:"#ccc"})]}),Cge=1.6,a3n=Cge-.3*2,VV=.3,Age=.85,yI=.6,Vtt=({color:n="#333"})=>Zd(Ty,{children:[Yn(ea,{size:[a3n,Age,yI],offset:[0,0,yI/2],color:n}),Yn(ea,{size:[VV,Age,yI],offset:[Cge/2-VV/2,0,yI/2],color:"#ccc"}),Yn(ea,{size:[VV,Age,yI],offset:[-Cge/2+VV/2,0,yI/2],color:"#ccc"})]}),Pge=2,Rge=1.25,gI=.55,PL=.5,c3n=Pge-PL*2,Gtt=({color:n="#333"})=>Zd(Ty,{children:[Yn(ea,{size:[c3n,Rge,gI],offset:[0,0,gI/2],color:n}),Yn(ea,{size:[PL,Rge,gI],offset:[Pge/2-PL/2,0,gI/2],color:"#ccc"}),Yn(ea,{size:[PL,Rge,gI],offset:[-Pge/2+PL/2,0,gI/2],color:"#ccc"})]}),l3n=({pinCount:n,pitch:e,leadWidth:t,padContactLength:i,bodyWidth:r})=>{const o=n/4;e||(e=u3n(n,r)),i||(i=d3n(n)),t||(t=h3n(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 Zd(Ty,{children:[Array.from({length:o}).map((p,m)=>Yn(Nv,{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(Nv,{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(Nv,{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(Nv,{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(mI,{center:{x:0,y:0,z:d/2},width:r,length:s,height:1.5})]})},u3n=(n,e)=>{switch(n){case 44:case 64:return .8;case 52:return e===14?1:.65;case 208:return .5;default:return .5}},d3n=n=>{switch(n){case 44:case 52:case 64:return 2.25;case 208:return 1.65;default:return 1}},h3n=(n,e)=>{switch(n){case 44:case 64:return .5;case 52:return e===14?.45:.55;case 208:return .3;default:return .25}},p3n=({numberOfPins:n,pitch:e=2.54,longSidePinLength:t=6})=>{const o=n*e,s=3,a=-((n-1)/2)*e;return Zd(Ty,{children:[Yn(ea,{color:"#222",size:[o,.63*3,2],center:[0,0,2/2]}),Array.from({length:n},(c,l)=>Zd(Ty,{children:[Yn(mT,{color:"gold",children:Zd(S4,{children:[Yn(ea,{color:"gold",size:[.63,.63,s*.9],center:[a+l*e,0,2*.9+2/2]}),Yn(ea,{color:"gold",size:[.63/1.8,.63/1.8,s],center:[a+l*e,0,2+2/2]})]})}),Yn(mT,{color:"gold",children:Zd(S4,{children:[Yn(ea,{color:"gold",size:[.63,.63,t*.9],center:[a+l*e,0,-t/2*.9]}),Yn(ea,{color:"gold",size:[.63/1.8,.63/1.8,t],center:[a+l*e,0,-t/2]})]})})]}))]})},f3n=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")}},m3n=({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},_3n=({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=m3n({num_pins:n,cw:!0,ccw:!0}),u=[];for(let d=0;d<n;d++){const{x:h,y:p,o:m}=f3n({pin_count:n,pn:d+1,w:e,h:t,p:a,pl:s});let _=o,y=s;m==="vert"&&([_,y]=[y,_]);const x=l[d+1];u.push({pn:x,x:h,y:p,pw:_,pl:y})}return Zd(Ty,{children:[Yn(mT,{color:"grey",children:Yn(ea,{center:{x:0,y:0,z:i/2},size:[e,t,i]})}),u.map((d,h)=>Yn(ea,{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(ea,{center:{x:0,y:0,z:c/2},size:[r.width,r.length,c]})]})},y3n=_3n,g3n=()=>{const c=1.1999999999999997;return Zd(Ty,{children:[Yn(Nv,{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(Nv,{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(Nv,{position:{x:-2.8/2-c/4,y:0,z:.15/2},width:.4,thickness:.15,padContactLength:.5,bodyDistance:c,height:.95}),Yn(Nv,{position:{x:-2.8/2-c/4,y:-1,z:.15/2},width:.4,thickness:.15,padContactLength:.5,bodyDistance:c,height:.95}),Yn(Nv,{position:{x:-2.8/2-c/4,y:1,z:.15/2},width:.4,thickness:.15,padContactLength:.5,bodyDistance:c,height:.95}),Yn(mI,{center:{x:0,y:0,z:0},width:1.6,length:2.9,height:1.2})]})},x3n=g3n,Ige=.6,Nge=.3,xI=.33,RL=.1,b3n=Ige-RL*2,Ytt=({color:n="#333"})=>Zd(Ty,{children:[Yn(ea,{size:[b3n,Nge,xI],offset:[0,0,xI/2],color:n}),Yn(ea,{size:[RL,Nge,xI],offset:[Ige/2-RL/2,0,xI/2],color:"#ccc"}),Yn(ea,{size:[RL,Nge,xI],offset:[-Ige/2+RL/2,0,xI/2],color:"#ccc"})]}),kge=.4,Oge=.2,bI=.13,IL=.07,v3n=kge-IL*2,qtt=({color:n="#333"})=>Zd(Ty,{children:[Yn(ea,{size:[v3n,Oge,bI],offset:[0,0,bI/2],color:n}),Yn(ea,{size:[IL,Oge,bI],offset:[kge/2-IL/2,0,bI/2],color:"#ccc"}),Yn(ea,{size:[IL,Oge,bI],offset:[-kge/2+IL/2,0,bI/2],color:"#ccc"})]}),Lge=3.2,Dge=1.6,vI=.9,NL=.5,w3n=Lge-NL*2,Xtt=({color:n="#333"})=>Zd(Ty,{children:[Yn(ea,{size:[w3n,Dge,vI],offset:[0,0,vI/2],color:n}),Yn(ea,{size:[NL,Dge,vI],offset:[Lge/2-NL/2,0,vI/2],color:"#ccc"}),Yn(ea,{size:[NL,Dge,vI],offset:[-Lge/2+NL/2,0,vI/2],color:"#ccc"})]}),zge=3.2,$ge=2.5,wI=1,kL=.6,S3n=zge-kL*2,Wtt=({color:n="#333"})=>Zd(Ty,{children:[Yn(ea,{size:[S3n,$ge,wI],offset:[0,0,wI/2],color:n}),Yn(ea,{size:[kL,$ge,wI],offset:[zge/2-kL/2,0,wI/2],color:"#ccc"}),Yn(ea,{size:[kL,$ge,wI],offset:[-zge/2+kL/2,0,wI/2],color:"#ccc"})]}),Fge=5,Uge=2.5,SI=1.4,OL=.6,E3n=Fge-OL*2,Ktt=({color:n="#333"})=>Zd(Ty,{children:[Yn(ea,{size:[E3n,Uge,SI],offset:[0,0,SI/2],color:n}),Yn(ea,{size:[OL,Uge,SI],offset:[Fge/2-OL/2,0,SI/2],color:"#ccc"}),Yn(ea,{size:[OL,Uge,SI],offset:[-Fge/2+OL/2,0,SI/2],color:"#ccc"})]}),Bge=6.3,jge=3.2,EI=1.8,LL=.8,T3n=Bge-LL*2,Ztt=({color:n="#333"})=>Zd(Ty,{children:[Yn(ea,{size:[T3n,jge,EI],offset:[0,0,EI/2],color:n}),Yn(ea,{size:[LL,jge,EI],offset:[Bge/2-LL/2,0,EI/2],color:"#ccc"}),Yn(ea,{size:[LL,jge,EI],offset:[-Bge/2+LL/2,0,EI/2],color:"#ccc"})]}),M3n=({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(mT,{color:"#1a1a1a",children:Zd(jV,{children:[Yn(ea,{color:"#000",size:[c,s,a],center:[0,0,a/2]}),Array.from({length:n},(h,p)=>r?Yn(J5,{height:a+.1,radius:r/2,center:[u+p*e,0,a/2],color:"#222"},p):Yn(ea,{size:[l,l,a],center:[u+p*e,0,a/2]},p))]})});return Zd(Ty,{children:[d,Array.from({length:n},(h,p)=>Zd(mT,{color:"silver",children:[Zd(S4,{children:[Yn(ea,{color:"silver",size:[o,o,t*.9],center:[u+p*e,0,-t/2*.9]}),Yn(ea,{color:"silver",size:[o/1.8,o/1.8,t],center:[u+p*e,0,-t/2]})]}),Yn(ea,{color:"silver",size:[l,l,l*.5],center:[u+p*e,0,l/2*.5]})]},p))]})},C3n=({width:n,length:e,innerDiameter:t=1})=>{const i=n,r=e,o=n*.7,s=t/2.5;return Zd(Ty,{children:[Yn(Sge,{color:"#1a1a1f",center:[0,0,o/2],size:[r,r,o],roundRadius:.3}),Yn(Sge,{color:"#f2f2f2",center:[0,0,o+o*.1/2.5],size:[r,r,o*.1],roundRadius:.14}),Yn(J5,{color:"#1a1a1f",height:o*.8,radius:i/3,center:[0,0,o+o*.8/2]}),Yn(J5,{color:"#1a1a1f",height:o*.2,radius:t/2,center:[r/3,r/3,o+o*.1/2]}),Yn(J5,{color:"#1a1a1f",height:o*.2,radius:t/2,center:[-r/3,-r/3,o+o*.1/2]}),Yn(J5,{color:"#1a1a1f",height:o*.2,radius:t/2,center:[-r/3,r/3,o+o*.1/2]}),Yn(J5,{color:"#1a1a1f",height:o*.2,radius:t/2,center:[r/3,-r/3,o+o*.1/2]}),Yn(GV,{thickness:t/3,width:s,horizontalLength:r*.8,verticalLength:o/2,position:{x:-i/2,y:-r/2,z:-o*1.2}}),Yn(GV,{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(GV,{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(GV,{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}})]})},GV=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=Ege(a,e);return Yn(mT,{color:"#f2f2f2",children:Yn(Qb,{offset:{x:s?.x||0,y:s?.y||0,z:s?.z||0},children:Yn(fI,{rotation:[0,55,o],children:Yn(CL,{height:t,children:Yn(ML,{points:c.map(l=>[l.y,l.x])})})})})})},A3n=({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 Zd(Ty,{children:[Array.from({length:o}).map((p,m)=>Yn(Nv,{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(Nv,{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(mI,{center:{x:0,y:0,z:a/2},width:h,length:d,height:c})]})},P3n=({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,y=(_-l)/2,x=y*.5;return Zd(Ty,{children:[Array.from({length:d}).map((b,w)=>Yn(Nv,{position:{x:-_/2,y:h-w*a,z:p/2},width:c,thickness:p,padContactLength:x+.05,bodyDistance:y+.05,height:m})),Array.from({length:d}).map((b,w)=>Yn(Nv,{rotation:Math.PI,position:{x:_/2,y:h-w*a,z:p/2},width:c,thickness:p,padContactLength:x+.05,bodyDistance:y+.05,height:m})),Yn(mI,{center:{x:0,y:0,z:p/2},width:l,length:u,height:1})]})},R3n=()=>{const d=Yn(mT,{color:"#222",children:Zd(BV,{children:[Yn(Qb,{z:.15,children:Yn(ea,{size:[1.65,.8,.3]})}),Zd(S4,{children:[Yn(Qb,{z:.3,children:Yn(ea,{size:[1.65,.8,.01]})}),Yn(Qb,{z:.6,children:Yn(ea,{size:[1.45,.6000000000000001,.01]})})]})]})});return Zd(Ty,{children:[Yn(ea,{color:"#ccc",size:[.5,.6,.12],center:[-.725,0,.12/2]}),Yn(ea,{color:"#ccc",size:[.5,.6,.12],center:[.725,0,.12/2]}),d]})},I3n=({footprint:n})=>{const e=Q5n.string(n).json();switch(e.fn){case"dip":return Yn(i3n,{numPins:e.num_pins,pitch:e.p,bodyWidth:e.w});case"tssop":return Yn(o3n,{pinCount:e.num_pins,leadLength:e.pl,leadWidth:e.pw,pitch:e.p,bodyWidth:e.w});case"vssop":return Yn(P3n,{pinCount:e.num_pins,leadLength:e.pl,leadWidth:e.pw,pitch:e.p,bodyWidth:e.w,bodyLength:e.h});case"qfp":return Yn(l3n,{pinCount:e.num_pins,pitch:e.p,leadWidth:e.pw,padContactLength:e.pl,bodyWidth:e.w});case"qfn":return Yn(y3n,{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(p3n,{numberOfPins:e.num_pins,pitch:e.p});if(e.female)return Yn(M3n,{numberOfPins:e.num_pins,pitch:e.p});case"cap":switch(e.imperial){case"0402":return Yn(Htt,{color:"#856c4d"});case"0603":return Yn(Vtt,{color:"#856c4d"});case"0805":return Yn(Gtt,{color:"#856c4d"});case"0201":return Yn(Ytt,{color:"#856c4d"});case"01005":return Yn(qtt,{color:"#856c4d"});case"1206":return Yn(Xtt,{color:"#856c4d"});case"1210":return Yn(Wtt,{color:"#856c4d"});case"2010":return Yn(Ktt,{color:"#856c4d"});case"2512":return Yn(Ztt,{color:"#856c4d"})}case"sot235":return Yn(x3n,{});case"pushbutton":return Yn(C3n,{width:e.w,length:e.h,innerDiameter:e.id});case"soic":return Yn(A3n,{pinCount:e.num_pins,leadLength:e.pl,leadWidth:e.pw,pitch:e.p,bodyWidth:e.w});case"sod523":return Yn(R3n,{})}const t=n.match(/_color\(([^)]+)\)/),i=t?t[1]:void 0;switch(e.imperial){case"0402":return Yn(Htt,{color:i});case"0603":return Yn(Vtt,{color:i});case"0805":return Yn(Gtt,{color:i});case"0201":return Yn(Ytt,{color:i});case"01005":return Yn(qtt,{color:i});case"1206":return Yn(Xtt,{color:i});case"1210":return Yn(Wtt,{color:i});case"2010":return Yn(Ktt,{color:i});case"2512":return Yn(Ztt,{color:i})}return null},N3n=n=>n&&typeof n=="object"&&"type"in n,TI=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},k3n=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 _T(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=>_T(h,e,t));if(!N3n(n))return[];const{type:l,props:u,children:d}=n;if(l===Ftt)return(d??[]).flatMap(h=>_T(h,e,t));if(l===mT){const h=u?.color;return(d??[]).flatMap(p=>_T(p,h??e,t))}if(l===Qb){const h=k3n(u?.offset??{x:u?.x,y:u?.y,z:u?.z});return(d??[]).flatMap(m=>_T(m,e,t)).map(({geom:m,color:_})=>({geom:c.translate(h,m),color:_??e}))}if(l===fI){const h=Array.isArray(u?.rotation)?[TI(u.rotation[0]),TI(u.rotation[1]),TI(u.rotation[2])]:[TI(u?.x??0),TI(u?.y??0),TI(u?.z??0)];return(d??[]).flatMap(m=>_T(m,e,t)).map(({geom:m,color:_})=>({geom:c.rotateZ(h[2],c.rotateY(h[1],c.rotateX(h[0],m))),color:_}))}if(l===BV||l===jV||l===S4){const h=(d??[]).flatMap(m=>_T(m,e,t)).map(m=>m.geom);if(h.length===0)return[];let p;return l===BV?p=r.union(h):l===jV?p=r.subtract(h[0],h.slice(1)):p=o.hull(h),[{geom:p}]}if(l===ML){const h=u?.points??[];return[{geom:s.geom2.fromPoints(h),color:e??u?.color}]}if(l===CL){const h=(d??[]).flatMap(y=>_T(y,e,t)).map(y=>y.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 y of _.polygons)!y.plane||!y.vertices||y.vertices.length<3||y.vertices.reverse();return[{geom:_,color:e??u?.color}]}if(l===ea||l===Utt||l===J5||l===Btt||l===Sge){let h;if(l===ea){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===Utt){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===J5){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===Btt){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 _T(h,e,t)}return(d??[]).flatMap(h=>_T(h,e,t))}function O3n(n,e){return{geometries:_T(n,void 0,{jscad:e})}}function Qtt(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 Of;if(o.setAttribute("position",new xm(new Float32Array(e),3)),o.setIndex(t),i.length>0&&o.setAttribute("color",new xm(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 Of;if(i.setAttribute("position",new xm(new Float32Array(e),3)),t.length>0&&i.setAttribute("color",new xm(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 Of}function L3n(n,e){const t=wge(I3n,{footprint:n});return O3n(t,e)}var D3n=({jscadPlan:n,positionOffset:e,rotationOffset:t,onHover:i,onUnhover:r,isHovered:o,scale:s})=>{const{rootObject:a}=yb(),{threeGeom:c,material:l}=ce.useMemo(()=>{const d=(0,Qbn.executeJscadOperations)(Jbn.default,n);if(!d||!d.polygons&&!d.sides)return{threeGeom:null,material:null};const h=Qtt(d),p=new Zb({vertexColors:!0,side:Wg});return{threeGeom:h,material:p}},[n]),u=ce.useMemo(()=>c?new Ra(c,l):null,[c,l]);return ce.useEffect(()=>{if(!(!u||!a))return a.add(u),()=>{a.remove(u)}},[a,u]),ce.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]),ce.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?re.jsx(SL,{isHovered:o,onHover:i,onUnhover:r,object:u}):null},z3n=vc(IV()),$3n=({positionOffset:n,footprint:e,rotationOffset:t,onHover:i,onUnhover:r,isHovered:o,scale:s})=>{const{rootObject:a}=yb(),c=ce.useMemo(()=>{if(!e)return null;const{geometries:l}=L3n(e,z3n),u=new cS;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]},_=Qtt(m),y=new Zb({vertexColors:!0,side:Wg}),x=new Ra(_,y);u.add(x)}return u},[e]);return ce.useEffect(()=>{if(!(!c||!a))return a.add(c),()=>{a.remove(c)}},[a,c]),ce.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]),ce.useEffect(()=>{c&&c.traverse(l=>{l instanceof Ra&&l.material instanceof Zb&&(o?(l.material.emissive.setHex(255),l.material.emissiveIntensity=.2):l.material.emissiveIntensity=0)})},[o,c]),c?re.jsx(SL,{isHovered:o,onHover:i,onUnhover:r,object:c}):null},F3n=(...n)=>n,Jtt=({children:n,position:e,style:t})=>{const{camera:i,renderer:r}=yb(),o=ce.useRef(document.createElement("div")),[s,a]=ce.useState(null);return ce.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(mj.createPortal(n,o.current)),()=>{c.contains(o.current)&&c.removeChild(o.current)}},[r,n]),dI(()=>{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},ent={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},tnt=ce.createContext(void 0),U3n=({children:n})=>{const[e,t]=ce.useState(ent),i=ce.useCallback(a=>{t(c=>({...c,[a]:!c[a]}))},[]),r=ce.useCallback((a,c)=>{t(l=>({...l,[a]:c}))},[]),o=ce.useCallback(()=>{t(ent)},[]),s=ce.useMemo(()=>({visibility:e,toggleLayer:i,setLayerVisibility:r,resetToDefaults:o}),[e,i,r,o]);return re.jsx(tnt.Provider,{value:s,children:n})},DL=()=>{const n=ce.useContext(tnt);if(!n)throw new Error("useLayerVisibility must be used within a LayerVisibilityProvider");return n},nnt=({cad_component:n,circuitJson:e})=>{const[t,i]=ce.useState(!1),{visibility:r}=DL(),[o,s]=ce.useState(null),a=ce.useCallback(m=>{m?.mousePosition?(i(!0),s(m.mousePosition)):(i(!1),s(null))},[]),c=ce.useCallback(()=>{i(!1),s(null)},[]),l=ce.useMemo(()=>ms(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?F3n(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=re.jsx(Xbn,{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=re.jsx(Zbn,{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=re.jsx(D3n,{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=re.jsx($3n,{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?re.jsxs(re.Fragment,{children:[p,t&&o?re.jsx(Jtt,{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},int={version:"0.0.425"},E4=({children:n,parent:e,position:t,rotation:i,scale:r,color:o,fontSize:s,anchorX:a,anchorY:c,depthOffset:l})=>{const{rootObject:u}=yb(),d=ce.useMemo(()=>{const h=new ZHe;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 ce.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 oS(0,0,0));function B3n(n,e){const t=new Pv().setFromEuler(new oS(n.x,n.y,n.z)),i=new en(0,0,1);return i.applyQuaternion(t),i.multiplyScalar(e)}var j3n=({})=>{const{camera:n,scene:e}=yb();ce.useEffect(()=>{if(!e)return;const i=new eHe(16777215,Math.PI/2);return e.add(i),()=>{e.remove(i)}},[e]),dI(()=>{if(!n)return;const i=window.TSCI_MAIN_CAMERA_ROTATION,r=B3n(i,2);n.position.copy(r),n.lookAt(0,0,0)});const t=ce.useMemo(()=>{const i=new cS;i.rotation.fromArray([Math.PI/2,0,0]);const r=new Ra(new eE(1,1,1),new Zb({color:"white"}));i.add(r);const o=new j6(new Vln(new eE(1,1,1)),new a4({color:0,linewidth:2}));return i.add(o),i},[]);return ce.useEffect(()=>{if(e)return e.add(t),()=>{e.remove(t)}},[e,t]),re.jsxs(re.Fragment,{children:[re.jsx(E4,{parent:t,position:[0,0,.51],fontSize:.25,color:"black",children:"Front"}),re.jsx(E4,{parent:t,position:[0,0,-.51],fontSize:.25,color:"black",rotation:[0,Math.PI,0],children:"Back"}),re.jsx(E4,{parent:t,position:[.51,0,0],fontSize:.25,color:"black",rotation:[0,Math.PI/2,0],children:"Right"}),re.jsx(E4,{parent:t,position:[-.51,0,0],fontSize:.25,color:"black",rotation:[0,-Math.PI/2,0],children:"Left"}),re.jsx(E4,{parent:t,position:[0,.51,0],fontSize:.25,color:"black",rotation:[-Math.PI/2,0,0],children:"Top"}),re.jsx(E4,{parent:t,position:[0,-.51,0],fontSize:.25,color:"black",rotation:[Math.PI/2,0,0],children:"Bottom"})]})};function H3n(n){n.querySelectorAll("canvas").forEach(e=>e.remove())}var V3n=n=>{n.outputColorSpace=G2,n.toneMapping=RUe,n.toneMappingExposure=1},rnt=ce.forwardRef(({children:n,scene:e,camera:t,style:i},r)=>{const o=ce.useRef(null),[s,a]=ce.useState(null),c=ce.useRef([]),l=ce.useCallback(p=>{c.current.push(p)},[]),u=ce.useCallback(p=>{c.current=c.current.filter(m=>m!==p)},[]),d=ce.useMemo(()=>new Y9,[]);e?.up&&d.up.set(e.up.x,e.up.y,e.up.z);const h=ce.useRef(new Kp);return ce.useImperativeHandle(r,()=>h.current),ce.useEffect(()=>{if(!o.current)return;H3n(o.current);const p=new Dle({antialias:!0,alpha:!0});V3n(p),p.setSize(o.current.clientWidth,o.current.clientHeight),p.setPixelRatio(window.devicePixelRatio),o.current.appendChild(p.domElement);const m=new Kb(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 y=new Cun,x=()=>{const w=y.getElapsedTime(),S=y.getDelta();c.current.forEach(I=>I(w,S)),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]),re.jsx("div",{ref:o,style:{width:"100%",height:"100%",...i},children:s&&re.jsx(zet.Provider,{value:s,children:re.jsx(Hbn,{children:n})})})}),G3n=({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}=yb(),h=ce.useMemo(()=>!u||!d?null:new Jhn(u,d.domElement),[u,d]);return ce.useEffect(()=>{if(l)return l(h??null),()=>{l(null)}},[h,l]),ce.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]),ce.useEffect(()=>{if(!(!h||!t))return h.addEventListener("start",t),()=>{h.removeEventListener("start",t)}},[h,t]),ce.useEffect(()=>{if(h)return()=>{h.dispose()}},[h]),dI(()=>{h?.update()},[h]),null},Y3n=`
|
|
5119
|
+
`).replace(/d 0\./g,"d 1."),p=l.replace(/newmtl[\s\S]*?endmtl/g,"").replace(/^mtllib.*/gm,""),m=new Gdn;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 Xbn({url:n,position:e,rotation:t,onHover:i,onUnhover:r,isHovered:o,scale:s}){const a=qbn(n),{rootObject:c}=yb(),l=ce.useMemo(()=>a&&!(a instanceof Error)?a:new Ra(new eE(.5,.5,.5),new Zb({transparent:!0,color:"red",opacity:.25})),[a]);if(ce.useEffect(()=>{if(!(!c||!l))return c.add(l),()=>{c.remove(l)}},[c,l]),ce.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 re.jsx(SL,{isHovered:o,onHover:i,onUnhover:r,object:l})}var Fet=new WeakMap,Wbn=()=>{const n=new l_;return n.name="fallback-environment-map",n.mapping=Zj,n},Kbn=n=>{if(!n)return null;const e=n,t=Fet.get(e);if(t)return t;let i;if(n instanceof Dle){const r=new Ile(n);i=r.fromScene(adn(),.04).texture,r.dispose()}else i=Wbn();return Fet.set(e,i),i},Uet=1.25;function Zbn({gltfUrl:n,position:e,rotation:t,onHover:i,onUnhover:r,isHovered:o,scale:s}){const{renderer:a,rootObject:c}=yb(),[l,u]=ce.useState(null);return ce.useEffect(()=>{if(!n)return;const d=new ldn;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]),ce.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]),ce.useEffect(()=>{if(!(!c||!l))return c.add(l),()=>{c.remove(l)}},[c,l]),ce.useEffect(()=>{if(!l||!a)return;const d=Kbn(a);if(!d)return;const h=[],p=m=>{m instanceof Zb&&(h.push({material:m,envMap:m.envMap??null,envMapIntensity:m.envMapIntensity??1}),m.envMap||(m.envMap=d),(typeof m.envMapIntensity!="number"||m.envMapIntensity<Uet)&&(m.envMapIntensity=Uet),m.needsUpdate=!0)};return l.traverse(m=>{if(!(m instanceof Ra))return;const _=m.material;Array.isArray(_)?_.forEach(p):_&&p(_)}),()=>{h.forEach(({material:m,envMap:_,envMapIntensity:y})=>{m.envMap=_,m.envMapIntensity=y,m.needsUpdate=!0})}},[l,a]),ce.useEffect(()=>{l&&l.traverse(d=>{d instanceof Ra&&d.material instanceof Zb&&(o?(d.material.emissive.setHex(255),d.material.emissiveIntensity=.2):d.material.emissiveIntensity=0)})},[o,l]),l?re.jsx(SL,{isHovered:o,onHover:i,onUnhover:r,object:l}):null}var Qbn=vc(hJe()),Jbn=vc(IV()),Bet={in:25.4,inch:25.4,mil:.0254,mm:1,m:1e3,cm:10,ft:304.8,feet:304.8},xh=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 Bet)return t*Bet[e];throw new Error(`Unsupported unit: ${e}`)},EL=xh,jet={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}}},lge=new Set;for(const[n,e]of Object.entries(jet)){lge.add(n);for(const t of Object.keys(e.variants))lge.add(t)}function evn(n){for(const[e,t]of Object.entries(jet))if(n in t.variants)return{baseUnit:t.baseUnit,conversionFactor:t.variants[n]};return{baseUnit:n,conversionFactor:1}}var Het={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 iE(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}=iE(n.x),l=iE(n.x),u=iE(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 Het&&!lge.has(i)){const a=Het[i];return{parsedUnit:null,unitOfValue:null,value:Number.parseFloat(r)*a}}const{baseUnit:o,conversionFactor:s}=evn(i);return{parsedUnit:i,unitOfValue:o,value:s*Number.parseFloat(r)}}var uge=N().or(Ie()).transform(n=>iE(n).value),Vet=N().or(Ie()).transform(n=>iE(n).value).transform(n=>Number.parseFloat(n.toPrecision(12))),tvn=N().or(Ie()).transform(n=>iE(n).value),hI=N().or(Ie()).transform(n=>iE(n).value),_t=N().or(Ie()).transform(n=>iE(n).value),dge=N().or(Ie()).transform(n=>iE(n).value),fi=_t;N().or(Ie()).transform(n=>iE(n).value);var hge=N().or(Ie()).transform(n=>iE(n).value),pI=hge,nvn=N().datetime(),uS=N().or(Ie()).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)),ivn=Ie().or(N().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"),Ls=Ee({x:fi,y:fi}),pge=Ee({x:fi,y:fi,z:fi}),Get=Ee({width:Ie(),height:Ie()}),rvn=n=>{const e="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";return Array.from({length:n},()=>e[Math.floor(Math.random()*e.length)]).join("")},Yi=n=>N().optional().default(()=>`${n}_${rvn(10)}`),NV=Xt(["top_left","top_center","top_right","center_left","center","center_right","bottom_left","bottom_center","bottom_right"]),ovn=Xt(["jlcpcb","macrofab","pcbway","digikey","mouser","lcsc"]),jx=Ee({type:me("source_component"),ftype:N().optional(),source_component_id:N(),name:N(),manufacturer_part_number:N().optional(),supplier_part_numbers:os(ovn,ut(N())).optional(),display_value:N().optional(),are_pins_interchangeable:Je().optional(),internally_connected_source_port_ids:ut(ut(N())).optional(),source_group_id:N().optional(),subcircuit_id:N().optional()}),Yet=jx.extend({ftype:me("simple_capacitor"),capacitance:Vet,max_voltage_rating:hI.optional(),display_capacitance:N().optional(),max_decoupling_trace_length:fi.optional()}),qet=jx.extend({ftype:me("simple_resistor"),resistance:uge,display_resistance:N().optional()}),fge=jx.extend({ftype:me("simple_diode")}),Xet=fge.extend({ftype:me("simple_led"),color:N().optional(),wavelength:N().optional()}),svn=jx.extend({ftype:me("simple_ground")}),Wet=jx.extend({ftype:me("simple_chip")}),Ket=jx.extend({ftype:me("simple_power_source"),voltage:hI}),avn=jx.extend({ftype:me("simple_fuse"),current_rating_amps:Ie().describe("Nominal current in amps the fuse is rated for"),voltage_rating_volts:Ie().describe("Voltage rating in volts, e.g. ±5V would be 5")}),Zet=jx.extend({ftype:me("simple_battery"),capacity:ivn}),Qet=jx.extend({ftype:me("simple_inductor"),inductance:tvn,max_current_rating:Ie().optional()}),Jet=jx.extend({ftype:me("simple_push_button")}),ett=jx.extend({ftype:me("simple_potentiometer"),max_resistance:uge}),cvn=jx.extend({ftype:me("simple_crystal"),frequency:Ie().describe("Frequency in Hz"),load_capacitance:Ie().optional().describe("Load capacitance in pF")}),ttt=jx.extend({ftype:me("simple_pin_header"),pin_count:Ie(),gender:Xt(["male","female"]).optional().default("male")}),ntt=jx.extend({ftype:me("simple_pinout")}),itt=jx.extend({ftype:me("simple_resonator"),load_capacitance:Vet,equivalent_series_resistance:uge.optional(),frequency:dge}),rtt=jx.extend({ftype:me("simple_transistor"),transistor_type:Xt(["npn","pnp"])}),ott=jx.extend({ftype:me("simple_test_point"),footprint_variant:Xt(["pad","through_hole"]).optional(),pad_shape:Xt(["rect","circle"]).optional(),pad_diameter:Bn([Ie(),N()]).optional(),hole_diameter:Bn([Ie(),N()]).optional(),width:Bn([Ie(),N()]).optional(),height:Bn([Ie(),N()]).optional()}),stt=jx.extend({ftype:me("simple_mosfet"),channel_type:Xt(["n","p"]),mosfet_mode:Xt(["enhancement","depletion"])}),att=jx.extend({ftype:me("simple_switch")}),ctt=Ee({type:me("source_project_metadata"),name:N().optional(),software_used_string:N().optional(),project_url:N().optional(),created_at:nvn.optional()}),lvn=Ee({type:me("source_missing_property_error"),source_missing_property_error_id:Yi("source_missing_property_error"),source_component_id:N(),property_name:N(),subcircuit_id:N().optional(),error_type:me("source_missing_property_error").default("source_missing_property_error"),message:N()}).describe("The source code is missing a property"),uvn=Ee({type:me("source_failed_to_create_component_error"),source_failed_to_create_component_error_id:Yi("source_failed_to_create_component_error"),error_type:me("source_failed_to_create_component_error").default("source_failed_to_create_component_error"),component_name:N().optional(),subcircuit_id:N().optional(),parent_source_component_id:N().optional(),message:N(),pcb_center:Ee({x:Ie().optional(),y:Ie().optional()}).optional(),schematic_center:Ee({x:Ie().optional(),y:Ie().optional()}).optional()}).describe("Error emitted when a component fails to be constructed"),ltt=Ee({type:me("source_trace_not_connected_error"),source_trace_not_connected_error_id:Yi("source_trace_not_connected_error"),error_type:me("source_trace_not_connected_error").default("source_trace_not_connected_error"),message:N(),subcircuit_id:N().optional(),source_group_id:N().optional(),source_trace_id:N().optional(),connected_source_port_ids:ut(N()).optional(),selectors_not_found:ut(N()).optional()}).describe("Occurs when a source trace selector does not match any ports"),dvn=Ee({type:me("source_property_ignored_warning"),source_property_ignored_warning_id:Yi("source_property_ignored_warning"),source_component_id:N(),property_name:N(),subcircuit_id:N().optional(),error_type:me("source_property_ignored_warning").default("source_property_ignored_warning"),message:N()}).describe("The source property was ignored"),utt=Ee({type:me("source_pin_missing_trace_warning"),source_pin_missing_trace_warning_id:Yi("source_pin_missing_trace_warning"),warning_type:me("source_pin_missing_trace_warning").default("source_pin_missing_trace_warning"),message:N(),source_component_id:N(),source_port_id:N(),subcircuit_id:N().optional()}).describe("Warning emitted when a source component pin is missing a trace connection"),hvn=Bn([qet,Yet,fge,Xet,svn,Wet,Ket,Zet,Qet,Jet,ett,cvn,ttt,ntt,itt,att,rtt,ott,stt,avn,ctt,lvn,uvn,ltt,dvn,utt]),pvn=Ee({type:me("source_port"),pin_number:Ie().optional(),port_hints:ut(N()).optional(),name:N(),source_port_id:N(),source_component_id:N().optional(),source_group_id:N().optional(),subcircuit_id:N().optional(),subcircuit_connectivity_map_key:N().optional()}),fvn=Ee({type:me("source_trace"),source_trace_id:N(),connected_source_port_ids:ut(N()),connected_source_net_ids:ut(N()),subcircuit_id:N().optional(),subcircuit_connectivity_map_key:N().optional(),max_length:Ie().optional(),min_trace_thickness:Ie().optional(),display_name:N().optional()}),mvn=Ee({type:me("source_group"),source_group_id:N(),subcircuit_id:N().optional(),parent_subcircuit_id:N().optional(),parent_source_group_id:N().optional(),is_subcircuit:Je().optional(),show_as_schematic_box:Je().optional(),name:N().optional(),was_automatically_named:Je().optional()}),_vn=Ee({type:me("source_net"),source_net_id:N(),name:N(),member_source_group_ids:ut(N()),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:Ie().optional(),subcircuit_id:N().optional(),subcircuit_connectivity_map_key:N().optional()}),yvn=Ee({type:me("source_board"),source_board_id:N(),source_group_id:N(),title:N().optional()}).describe("Defines a board in the source domain"),gvn=Ee({type:me("source_pcb_ground_plane"),source_pcb_ground_plane_id:N(),source_group_id:N(),source_net_id:N(),subcircuit_id:N().optional()}).describe("Defines a ground plane in the source domain"),xvn=["top","bottom","inner1","inner2","inner3","inner4","inner5","inner6"],dtt=Xt(xvn),Kd=dtt.or(Ee({name:dtt})).transform(n=>typeof n=="string"?n:n.name),fT=Xt(["top","bottom"]),bvn=Ee({type:me("source_manually_placed_via"),source_manually_placed_via_id:N(),source_group_id:N(),source_net_id:N(),subcircuit_id:N().optional(),source_trace_id:N().optional()}).describe("Defines a via that is manually placed in the source domain"),vvn=Ee({type:me("unknown_error_finding_part"),unknown_error_finding_part_id:Yi("unknown_error_finding_part"),error_type:me("unknown_error_finding_part").default("unknown_error_finding_part"),message:N(),source_component_id:N().optional(),subcircuit_id:N().optional()}).describe("Error emitted when an unexpected error occurs while finding a part"),wvn=Ee({type:me("schematic_box"),schematic_component_id:N().optional(),width:fi,height:fi,is_dashed:Je().default(!1),x:fi,y:fi,subcircuit_id:N().optional()}).describe("Draws a box on the schematic"),Svn=Ee({type:me("schematic_path"),schematic_component_id:N(),fill_color:Xt(["red","blue"]).optional(),is_filled:Je().optional(),points:ut(Ls),subcircuit_id:N().optional()}),Evn=os(Ee({left_margin:_t.optional(),right_margin:_t.optional(),top_margin:_t.optional(),bottom_margin:_t.optional()})),Tvn=Ee({left_size:Ie(),right_size:Ie(),top_size:Ie().optional(),bottom_size:Ie().optional()}),Mvn=Ee({left_side:Ee({pins:ut(Ie()),direction:Xt(["top-to-bottom","bottom-to-top"]).optional()}).optional(),right_side:Ee({pins:ut(Ie()),direction:Xt(["top-to-bottom","bottom-to-top"]).optional()}).optional(),top_side:Ee({pins:ut(Ie()),direction:Xt(["left-to-right","right-to-left"]).optional()}).optional(),bottom_side:Ee({pins:ut(Ie()),direction:Xt(["left-to-right","right-to-left"]).optional()}).optional()}),Cvn=Bn([Tvn,Mvn]),Avn=Ee({type:me("schematic_component"),size:Get,center:Ls,source_component_id:N().optional(),schematic_component_id:N(),pin_spacing:_t.optional(),pin_styles:Evn.optional(),box_width:_t.optional(),symbol_name:N().optional(),port_arrangement:Cvn.optional(),port_labels:os(N()).optional(),symbol_display_value:N().optional(),subcircuit_id:N().optional(),schematic_group_id:N().optional(),is_schematic_group:Je().optional(),source_group_id:N().optional(),is_box_with_pins:Je().optional().default(!0)}),Pvn=Ee({type:me("schematic_line"),schematic_line_id:Yi("schematic_line"),schematic_component_id:N(),x1:fi,y1:fi,x2:fi,y2:fi,stroke_width:fi.nullable().optional(),color:N().default("#000000"),is_dashed:Je().default(!1),subcircuit_id:N().optional()}).describe("Draws a styled line on the schematic"),Rvn=Ee({type:me("schematic_rect"),schematic_rect_id:Yi("schematic_rect"),schematic_component_id:N(),center:Ls,width:fi,height:fi,rotation:uS.default(0),stroke_width:fi.nullable().optional(),color:N().default("#000000"),is_filled:Je().default(!1),fill_color:N().optional(),is_dashed:Je().default(!1),subcircuit_id:N().optional()}).describe("Draws a styled rectangle on the schematic"),Ivn=Ee({type:me("schematic_circle"),schematic_circle_id:Yi("schematic_circle"),schematic_component_id:N(),center:Ls,radius:fi,stroke_width:fi.nullable().optional(),color:N().default("#000000"),is_filled:Je().default(!1),fill_color:N().optional(),is_dashed:Je().default(!1),subcircuit_id:N().optional()}).describe("Draws a styled circle on the schematic"),Nvn=Ee({type:me("schematic_arc"),schematic_arc_id:Yi("schematic_arc"),schematic_component_id:N(),center:Ls,radius:fi,start_angle_degrees:uS,end_angle_degrees:uS,direction:Xt(["clockwise","counterclockwise"]).default("counterclockwise"),stroke_width:fi.nullable().optional(),color:N().default("#000000"),is_dashed:Je().default(!1),subcircuit_id:N().optional()}).describe("Draws a styled arc on the schematic"),kvn=Ee({type:me("schematic_trace"),schematic_trace_id:N(),source_trace_id:N().optional(),junctions:ut(Ee({x:Ie(),y:Ie()})),edges:ut(Ee({from:Ee({x:Ie(),y:Ie()}),to:Ee({x:Ie(),y:Ie()}),is_crossing:Je().optional(),from_schematic_port_id:N().optional(),to_schematic_port_id:N().optional()})),subcircuit_id:N().optional(),subcircuit_connectivity_map_key:N().optional()}),Ovn=Xt(["center","left","right","top","bottom"]),Lvn=Ee({type:me("schematic_text"),schematic_component_id:N().optional(),schematic_text_id:N(),text:N(),font_size:Ie().default(.18),position:Ee({x:fi,y:fi}),rotation:Ie().default(0),anchor:Bn([Ovn.describe("legacy"),NV]).default("center"),color:N().default("#000000"),subcircuit_id:N().optional()}),Dvn=Ee({type:me("schematic_port"),schematic_port_id:N(),source_port_id:N(),schematic_component_id:N().optional(),center:Ls,facing_direction:Xt(["up","down","left","right"]).optional(),distance_from_component_edge:Ie().optional(),side_of_component:Xt(["top","bottom","left","right"]).optional(),true_ccw_index:Ie().optional(),pin_number:Ie().optional(),display_pin_label:N().optional(),subcircuit_id:N().optional(),is_connected:Je().optional(),has_input_arrow:Je().optional(),has_output_arrow:Je().optional()}).describe("Defines a port on a schematic component"),zvn=Ee({type:me("schematic_net_label"),schematic_net_label_id:Yi("schematic_net_label"),schematic_trace_id:N().optional(),source_trace_id:N().optional(),source_net_id:N(),center:Ls,anchor_position:Ls.optional(),anchor_side:Xt(["top","bottom","left","right"]),text:N(),symbol_name:N().optional(),is_movable:Je().optional(),subcircuit_id:N().optional()}),$vn=Ee({type:me("schematic_error"),schematic_error_id:N(),error_type:me("schematic_port_not_found").default("schematic_port_not_found"),message:N(),subcircuit_id:N().optional()}).describe("Defines a schematic error on the schematic"),Fvn=Ee({type:me("schematic_layout_error"),schematic_layout_error_id:Yi("schematic_layout_error"),error_type:me("schematic_layout_error").default("schematic_layout_error"),message:N(),source_group_id:N(),schematic_group_id:N(),subcircuit_id:N().optional()}).describe("Error emitted when schematic layout fails for a group"),mge=Ee({type:me("schematic_debug_object"),label:N().optional(),subcircuit_id:N().optional()}),Uvn=mge.extend({shape:me("rect"),center:Ls,size:Get}),Bvn=mge.extend({shape:me("line"),start:Ls,end:Ls}),jvn=mge.extend({shape:me("point"),center:Ls}),Hvn=gm("shape",[Uvn,Bvn,jvn]),Vvn=Ee({type:me("schematic_voltage_probe"),schematic_voltage_probe_id:N(),position:Ls,schematic_trace_id:N(),voltage:hI.optional(),subcircuit_id:N().optional()}).describe("Defines a voltage probe measurement point on a schematic trace"),Gvn=Ee({type:me("schematic_manual_edit_conflict_warning"),schematic_manual_edit_conflict_warning_id:Yi("schematic_manual_edit_conflict_warning"),warning_type:me("schematic_manual_edit_conflict_warning").default("schematic_manual_edit_conflict_warning"),message:N(),schematic_component_id:N(),schematic_group_id:N().optional(),subcircuit_id:N().optional(),source_component_id:N()}).describe("Warning emitted when a component has both manual placement and explicit schX/schY coordinates"),Yvn=Ee({type:me("schematic_group"),schematic_group_id:Yi("schematic_group"),source_group_id:N(),is_subcircuit:Je().optional(),subcircuit_id:N().optional(),width:_t,height:_t,center:Ls,schematic_component_ids:ut(N()),show_as_schematic_box:Je().optional(),name:N().optional(),description:N().optional()}).describe("Defines a group of components on the schematic"),qvn=Ee({type:me("schematic_table"),schematic_table_id:Yi("schematic_table"),anchor_position:Ls,column_widths:ut(fi),row_heights:ut(fi),cell_padding:fi.optional(),border_width:fi.optional(),subcircuit_id:N().optional(),schematic_component_id:N().optional(),anchor:NV.optional()}).describe("Defines a table on the schematic"),Xvn=Ee({type:me("schematic_table_cell"),schematic_table_cell_id:Yi("schematic_table_cell"),schematic_table_id:N(),start_row_index:Ie(),end_row_index:Ie(),start_column_index:Ie(),end_column_index:Ie(),text:N().optional(),center:Ls,width:fi,height:fi,horizontal_align:Xt(["left","center","right"]).optional(),vertical_align:Xt(["top","middle","bottom"]).optional(),font_size:fi.optional(),subcircuit_id:N().optional()}).describe("Defines a cell within a schematic_table"),Wvn=Ee({type:me("schematic_sheet"),schematic_sheet_id:Yi("schematic_sheet"),name:N().optional(),subcircuit_id:N().optional()}).describe("Defines a schematic sheet or page that components can be placed on"),Kvn=Ee({x:fi,y:fi,bulge:Ie().optional()}),htt=Ee({vertices:ut(Kvn)}),Zvn=Ee({outer_ring:htt,inner_rings:ut(htt).default([])}),Qvn=Ee({x:fi,y:fi,via:Je().optional(),via_to_layer:Kd.optional()});ut(Qvn);var Jvn=Ee({x:fi,y:fi,via:Je().optional(),to_layer:Kd.optional(),trace_width:fi.optional()}),ewn=Ee({type:me("pcb_component"),pcb_component_id:Yi("pcb_component"),source_component_id:N(),center:Ls,layer:Kd,rotation:uS,width:_t,height:_t,do_not_place:Je().optional(),subcircuit_id:N().optional(),pcb_group_id:N().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"),ptt=Ee({type:me("pcb_hole"),pcb_hole_id:Yi("pcb_hole"),pcb_group_id:N().optional(),subcircuit_id:N().optional(),hole_shape:Xt(["circle","square"]),hole_diameter:Ie(),x:fi,y:fi});ptt.describe("Defines a circular or square hole on the PCB");var ftt=Ee({type:me("pcb_hole"),pcb_hole_id:Yi("pcb_hole"),pcb_group_id:N().optional(),subcircuit_id:N().optional(),hole_shape:me("oval"),hole_width:Ie(),hole_height:Ie(),x:fi,y:fi});ftt.describe("Defines an oval hole on the PCB");var mtt=Ee({type:me("pcb_hole"),pcb_hole_id:Yi("pcb_hole"),pcb_group_id:N().optional(),subcircuit_id:N().optional(),hole_shape:me("pill"),hole_width:Ie(),hole_height:Ie(),x:fi,y:fi});mtt.describe("Defines a pill-shaped hole on the PCB");var _tt=Ee({type:me("pcb_hole"),pcb_hole_id:Yi("pcb_hole"),pcb_group_id:N().optional(),subcircuit_id:N().optional(),hole_shape:me("rotated_pill"),hole_width:Ie(),hole_height:Ie(),x:fi,y:fi,ccw_rotation:uS});_tt.describe("Defines a rotated pill-shaped hole on the PCB");var twn=ptt.or(ftt).or(mtt).or(_tt),nwn=Ee({type:me("pcb_plated_hole"),shape:me("circle"),pcb_group_id:N().optional(),subcircuit_id:N().optional(),outer_diameter:Ie(),hole_diameter:Ie(),x:fi,y:fi,layers:ut(Kd),port_hints:ut(N()).optional(),pcb_component_id:N().optional(),pcb_port_id:N().optional(),pcb_plated_hole_id:Yi("pcb_plated_hole")}),iwn=Ee({type:me("pcb_plated_hole"),shape:Xt(["oval","pill"]),pcb_group_id:N().optional(),subcircuit_id:N().optional(),outer_width:Ie(),outer_height:Ie(),hole_width:Ie(),hole_height:Ie(),x:fi,y:fi,ccw_rotation:uS,layers:ut(Kd),port_hints:ut(N()).optional(),pcb_component_id:N().optional(),pcb_port_id:N().optional(),pcb_plated_hole_id:Yi("pcb_plated_hole")}),rwn=Ee({type:me("pcb_plated_hole"),shape:me("circular_hole_with_rect_pad"),pcb_group_id:N().optional(),subcircuit_id:N().optional(),hole_shape:me("circle"),pad_shape:me("rect"),hole_diameter:Ie(),rect_pad_width:Ie(),rect_pad_height:Ie(),rect_border_radius:Ie().optional(),hole_offset_x:fi.default(0),hole_offset_y:fi.default(0),x:fi,y:fi,layers:ut(Kd),port_hints:ut(N()).optional(),pcb_component_id:N().optional(),pcb_port_id:N().optional(),pcb_plated_hole_id:Yi("pcb_plated_hole")}),own=Ee({type:me("pcb_plated_hole"),shape:me("pill_hole_with_rect_pad"),pcb_group_id:N().optional(),subcircuit_id:N().optional(),hole_shape:me("pill"),pad_shape:me("rect"),hole_width:Ie(),hole_height:Ie(),rect_pad_width:Ie(),rect_pad_height:Ie(),rect_border_radius:Ie().optional(),hole_offset_x:fi.default(0),hole_offset_y:fi.default(0),x:fi,y:fi,layers:ut(Kd),port_hints:ut(N()).optional(),pcb_component_id:N().optional(),pcb_port_id:N().optional(),pcb_plated_hole_id:Yi("pcb_plated_hole")}),swn=Ee({type:me("pcb_plated_hole"),shape:me("rotated_pill_hole_with_rect_pad"),pcb_group_id:N().optional(),subcircuit_id:N().optional(),hole_shape:me("rotated_pill"),pad_shape:me("rect"),hole_width:Ie(),hole_height:Ie(),hole_ccw_rotation:uS,rect_pad_width:Ie(),rect_pad_height:Ie(),rect_border_radius:Ie().optional(),rect_ccw_rotation:uS,hole_offset_x:fi.default(0),hole_offset_y:fi.default(0),x:fi,y:fi,layers:ut(Kd),port_hints:ut(N()).optional(),pcb_component_id:N().optional(),pcb_port_id:N().optional(),pcb_plated_hole_id:Yi("pcb_plated_hole")}),awn=Bn([nwn,iwn,rwn,own,swn]),cwn=Ee({type:me("pcb_port"),pcb_port_id:Yi("pcb_port"),pcb_group_id:N().optional(),subcircuit_id:N().optional(),source_port_id:N(),pcb_component_id:N().optional(),x:fi,y:fi,layers:ut(Kd),is_board_pinout:Je().optional()}).describe("Defines a port on the PCB"),lwn=Ee({type:me("pcb_smtpad"),shape:me("circle"),pcb_smtpad_id:Yi("pcb_smtpad"),pcb_group_id:N().optional(),subcircuit_id:N().optional(),x:fi,y:fi,radius:Ie(),layer:Kd,port_hints:ut(N()).optional(),pcb_component_id:N().optional(),pcb_port_id:N().optional(),is_covered_with_solder_mask:Je().optional()}),uwn=Ee({type:me("pcb_smtpad"),shape:me("rect"),pcb_smtpad_id:Yi("pcb_smtpad"),pcb_group_id:N().optional(),subcircuit_id:N().optional(),x:fi,y:fi,width:Ie(),height:Ie(),rect_border_radius:Ie().optional(),corner_radius:Ie().optional(),layer:Kd,port_hints:ut(N()).optional(),pcb_component_id:N().optional(),pcb_port_id:N().optional(),is_covered_with_solder_mask:Je().optional()}),dwn=Ee({type:me("pcb_smtpad"),shape:me("rotated_rect"),pcb_smtpad_id:Yi("pcb_smtpad"),pcb_group_id:N().optional(),subcircuit_id:N().optional(),x:fi,y:fi,width:Ie(),height:Ie(),rect_border_radius:Ie().optional(),corner_radius:Ie().optional(),ccw_rotation:uS,layer:Kd,port_hints:ut(N()).optional(),pcb_component_id:N().optional(),pcb_port_id:N().optional(),is_covered_with_solder_mask:Je().optional()}),hwn=Ee({type:me("pcb_smtpad"),shape:me("pill"),pcb_smtpad_id:Yi("pcb_smtpad"),pcb_group_id:N().optional(),subcircuit_id:N().optional(),x:fi,y:fi,width:Ie(),height:Ie(),radius:Ie(),layer:Kd,port_hints:ut(N()).optional(),pcb_component_id:N().optional(),pcb_port_id:N().optional(),is_covered_with_solder_mask:Je().optional()}),pwn=Ee({type:me("pcb_smtpad"),shape:me("rotated_pill"),pcb_smtpad_id:Yi("pcb_smtpad"),pcb_group_id:N().optional(),subcircuit_id:N().optional(),x:fi,y:fi,width:Ie(),height:Ie(),radius:Ie(),ccw_rotation:uS,layer:Kd,port_hints:ut(N()).optional(),pcb_component_id:N().optional(),pcb_port_id:N().optional(),is_covered_with_solder_mask:Je().optional()}),fwn=Ee({type:me("pcb_smtpad"),shape:me("polygon"),pcb_smtpad_id:Yi("pcb_smtpad"),pcb_group_id:N().optional(),subcircuit_id:N().optional(),points:ut(Ls),layer:Kd,port_hints:ut(N()).optional(),pcb_component_id:N().optional(),pcb_port_id:N().optional(),is_covered_with_solder_mask:Je().optional()}),mwn=gm("shape",[lwn,uwn,dwn,pwn,hwn,fwn]).describe("Defines an SMT pad on the PCB"),_wn=Ee({type:me("pcb_solder_paste"),shape:me("circle"),pcb_solder_paste_id:Yi("pcb_solder_paste"),pcb_group_id:N().optional(),subcircuit_id:N().optional(),x:fi,y:fi,radius:Ie(),layer:Kd,pcb_component_id:N().optional(),pcb_smtpad_id:N().optional()}),ywn=Ee({type:me("pcb_solder_paste"),shape:me("rect"),pcb_solder_paste_id:Yi("pcb_solder_paste"),pcb_group_id:N().optional(),subcircuit_id:N().optional(),x:fi,y:fi,width:Ie(),height:Ie(),layer:Kd,pcb_component_id:N().optional(),pcb_smtpad_id:N().optional()}),gwn=Ee({type:me("pcb_solder_paste"),shape:me("pill"),pcb_solder_paste_id:Yi("pcb_solder_paste"),pcb_group_id:N().optional(),subcircuit_id:N().optional(),x:fi,y:fi,width:Ie(),height:Ie(),radius:Ie(),layer:Kd,pcb_component_id:N().optional(),pcb_smtpad_id:N().optional()}),xwn=Ee({type:me("pcb_solder_paste"),shape:me("rotated_rect"),pcb_solder_paste_id:Yi("pcb_solder_paste"),pcb_group_id:N().optional(),subcircuit_id:N().optional(),x:fi,y:fi,width:Ie(),height:Ie(),ccw_rotation:fi,layer:Kd,pcb_component_id:N().optional(),pcb_smtpad_id:N().optional()}),bwn=Ee({type:me("pcb_solder_paste"),shape:me("oval"),pcb_solder_paste_id:Yi("pcb_solder_paste"),pcb_group_id:N().optional(),subcircuit_id:N().optional(),x:fi,y:fi,width:Ie(),height:Ie(),layer:Kd,pcb_component_id:N().optional(),pcb_smtpad_id:N().optional()}),vwn=Bn([_wn,ywn,gwn,xwn,bwn]).describe("Defines solderpaste on the PCB"),wwn=Ee({type:me("pcb_text"),pcb_text_id:Yi("pcb_text"),pcb_group_id:N().optional(),subcircuit_id:N().optional(),text:N(),center:Ls,layer:Kd,width:_t,height:_t,lines:Ie(),align:Xt(["bottom-left"])}).describe("Defines text on the PCB"),Swn=Ee({route_type:me("wire"),x:fi,y:fi,width:fi,start_pcb_port_id:N().optional(),end_pcb_port_id:N().optional(),layer:Kd}),Ewn=Ee({route_type:me("via"),x:fi,y:fi,hole_diameter:fi.optional(),outer_diameter:fi.optional(),from_layer:N(),to_layer:N()}),Twn=Bn([Swn,Ewn]),Mwn=Ee({type:me("pcb_trace"),source_trace_id:N().optional(),pcb_component_id:N().optional(),pcb_trace_id:Yi("pcb_trace"),pcb_group_id:N().optional(),subcircuit_id:N().optional(),route_thickness_mode:Xt(["constant","interpolated"]).default("constant").optional(),route_order_index:Ie().optional(),should_round_corners:Je().optional(),trace_length:Ie().optional(),highlight_color:N().optional(),route:ut(Twn)}).describe("Defines a trace on the PCB"),Cwn=Ee({type:me("pcb_trace_error"),pcb_trace_error_id:Yi("pcb_trace_error"),error_type:me("pcb_trace_error").default("pcb_trace_error"),message:N(),center:Ls.optional(),pcb_trace_id:N(),source_trace_id:N(),pcb_component_ids:ut(N()),pcb_port_ids:ut(N()),subcircuit_id:N().optional()}).describe("Defines a trace error on the PCB"),Awn=Ee({type:me("pcb_trace_missing_error"),pcb_trace_missing_error_id:Yi("pcb_trace_missing_error"),error_type:me("pcb_trace_missing_error").default("pcb_trace_missing_error"),message:N(),center:Ls.optional(),source_trace_id:N(),pcb_component_ids:ut(N()),pcb_port_ids:ut(N()),subcircuit_id:N().optional()}).describe("Defines an error when a source trace has no corresponding PCB trace"),Pwn=Ee({type:me("pcb_port_not_matched_error"),pcb_error_id:Yi("pcb_error"),error_type:me("pcb_port_not_matched_error").default("pcb_port_not_matched_error"),message:N(),pcb_component_ids:ut(N()),subcircuit_id:N().optional()}).describe("Defines a trace error on the PCB where a port is not matched"),Rwn=Ee({type:me("pcb_port_not_connected_error"),pcb_port_not_connected_error_id:Yi("pcb_port_not_connected_error"),error_type:me("pcb_port_not_connected_error").default("pcb_port_not_connected_error"),message:N(),pcb_port_ids:ut(N()),pcb_component_ids:ut(N()),subcircuit_id:N().optional()}).describe("Defines an error when a pcb port is not connected to any trace"),Iwn=Ee({type:me("pcb_net"),pcb_net_id:Yi("pcb_net"),source_net_id:N().optional(),highlight_color:N().optional()}).describe("Defines a net on the PCB"),Nwn=Ee({type:me("pcb_via"),pcb_via_id:Yi("pcb_via"),pcb_group_id:N().optional(),subcircuit_id:N().optional(),x:fi,y:fi,outer_diameter:fi.default("0.6mm"),hole_diameter:fi.default("0.25mm"),from_layer:Kd.optional(),to_layer:Kd.optional(),layers:ut(Kd),pcb_trace_id:N().optional(),net_is_assignable:Je().optional(),net_assigned:Je().optional()}).describe("Defines a via on the PCB"),kwn=Ee({type:me("pcb_board"),pcb_board_id:Yi("pcb_board"),pcb_panel_id:N().optional(),is_subcircuit:Je().optional(),subcircuit_id:N().optional(),width:_t,height:_t,center:Ls,thickness:_t.optional().default(1.4),num_layers:Ie().optional().default(4),outline:ut(Ls).optional(),material:Xt(["fr4","fr1"]).default("fr4")}).describe("Defines the board outline of the PCB"),Own=Ee({type:me("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"),Lwn=Ee({type:me("pcb_placement_error"),pcb_placement_error_id:Yi("pcb_placement_error"),error_type:me("pcb_placement_error").default("pcb_placement_error"),message:N(),subcircuit_id:N().optional()}).describe("Defines a placement error on the PCB"),Dwn=Ee({type:me("pcb_trace_hint"),pcb_trace_hint_id:Yi("pcb_trace_hint"),pcb_port_id:N(),pcb_component_id:N(),route:ut(Jvn),subcircuit_id:N().optional()}).describe("A hint that can be used during generation of a PCB trace"),zwn=Ee({type:me("pcb_silkscreen_line"),pcb_silkscreen_line_id:Yi("pcb_silkscreen_line"),pcb_component_id:N(),pcb_group_id:N().optional(),subcircuit_id:N().optional(),stroke_width:fi.default("0.1mm"),x1:fi,y1:fi,x2:fi,y2:fi,layer:fT}).describe("Defines a silkscreen line on the PCB"),$wn=Ee({type:me("pcb_silkscreen_path"),pcb_silkscreen_path_id:Yi("pcb_silkscreen_path"),pcb_component_id:N(),pcb_group_id:N().optional(),subcircuit_id:N().optional(),layer:fT,route:ut(Ls),stroke_width:_t}).describe("Defines a silkscreen path on the PCB"),Fwn=Ee({type:me("pcb_silkscreen_text"),pcb_silkscreen_text_id:Yi("pcb_silkscreen_text"),pcb_group_id:N().optional(),subcircuit_id:N().optional(),font:me("tscircuit2024").default("tscircuit2024"),font_size:fi.default("0.2mm"),pcb_component_id:N(),text:N(),is_knockout:Je().default(!1).optional(),knockout_padding:Ee({left:_t,top:_t,bottom:_t,right:_t}).default({left:"0.2mm",top:"0.2mm",bottom:"0.2mm",right:"0.2mm"}).optional(),ccw_rotation:Ie().optional(),layer:Kd,is_mirrored:Je().default(!1).optional(),anchor_position:Ls.default({x:0,y:0}),anchor_alignment:NV.default("center")}).describe("Defines silkscreen text on the PCB"),Uwn=Ee({type:me("pcb_copper_text"),pcb_copper_text_id:Yi("pcb_copper_text"),pcb_group_id:N().optional(),subcircuit_id:N().optional(),font:me("tscircuit2024").default("tscircuit2024"),font_size:fi.default("0.2mm"),pcb_component_id:N(),text:N(),is_knockout:Je().default(!1).optional(),knockout_padding:Ee({left:_t,top:_t,bottom:_t,right:_t}).default({left:"0.2mm",top:"0.2mm",bottom:"0.2mm",right:"0.2mm"}).optional(),ccw_rotation:Ie().optional(),layer:Kd,is_mirrored:Je().default(!1).optional(),anchor_position:Ls.default({x:0,y:0}),anchor_alignment:NV.default("center")}).describe("Defines copper text on the PCB"),Bwn=Ee({type:me("pcb_silkscreen_rect"),pcb_silkscreen_rect_id:Yi("pcb_silkscreen_rect"),pcb_component_id:N(),pcb_group_id:N().optional(),subcircuit_id:N().optional(),center:Ls,width:_t,height:_t,layer:Kd,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"),jwn=Ee({type:me("pcb_silkscreen_circle"),pcb_silkscreen_circle_id:Yi("pcb_silkscreen_circle"),pcb_component_id:N(),pcb_group_id:N().optional(),subcircuit_id:N().optional(),center:Ls,radius:_t,layer:fT,stroke_width:_t.default("1mm")}).describe("Defines a silkscreen circle on the PCB"),Hwn=Ee({type:me("pcb_silkscreen_oval"),pcb_silkscreen_oval_id:Yi("pcb_silkscreen_oval"),pcb_component_id:N(),pcb_group_id:N().optional(),subcircuit_id:N().optional(),center:Ls,radius_x:fi,radius_y:fi,layer:fT}).describe("Defines a silkscreen oval on the PCB"),Vwn=Ee({type:me("pcb_fabrication_note_text"),pcb_fabrication_note_text_id:Yi("pcb_fabrication_note_text"),subcircuit_id:N().optional(),pcb_group_id:N().optional(),font:me("tscircuit2024").default("tscircuit2024"),font_size:fi.default("1mm"),pcb_component_id:N(),text:N(),layer:fT,anchor_position:Ls.default({x:0,y:0}),anchor_alignment:Xt(["center","top_left","top_right","bottom_left","bottom_right"]).default("center"),color:N().optional()}).describe("Defines a fabrication note in text on the PCB, useful for leaving notes for assemblers or fabricators"),Gwn=Ee({type:me("pcb_fabrication_note_path"),pcb_fabrication_note_path_id:Yi("pcb_fabrication_note_path"),pcb_component_id:N(),subcircuit_id:N().optional(),layer:Kd,route:ut(Ls),stroke_width:_t,color:N().optional()}).describe("Defines a fabrication path on the PCB for fabricators or assemblers"),Ywn=Ee({type:me("pcb_fabrication_note_rect"),pcb_fabrication_note_rect_id:Yi("pcb_fabrication_note_rect"),pcb_component_id:N(),pcb_group_id:N().optional(),subcircuit_id:N().optional(),center:Ls,width:_t,height:_t,layer:fT,stroke_width:_t.default("0.1mm"),corner_radius:_t.optional(),is_filled:Je().optional(),has_stroke:Je().optional(),is_stroke_dashed:Je().optional(),color:N().optional()}).describe("Defines a fabrication note rectangle on the PCB"),qwn=Ee({type:me("pcb_fabrication_note_dimension"),pcb_fabrication_note_dimension_id:Yi("pcb_fabrication_note_dimension"),pcb_component_id:N(),pcb_group_id:N().optional(),subcircuit_id:N().optional(),layer:fT,from:Ls,to:Ls,text:N().optional(),text_ccw_rotation:Ie().optional(),offset:_t.optional(),offset_distance:_t.optional(),offset_direction:Ee({x:Ie(),y:Ie()}).optional(),font:me("tscircuit2024").default("tscircuit2024"),font_size:_t.default("1mm"),color:N().optional(),arrow_size:_t.default("1mm")}).describe("Defines a measurement annotation within PCB fabrication notes"),Xwn=Ee({type:me("pcb_note_text"),pcb_note_text_id:Yi("pcb_note_text"),pcb_component_id:N().optional(),pcb_group_id:N().optional(),subcircuit_id:N().optional(),name:N().optional(),font:me("tscircuit2024").default("tscircuit2024"),font_size:fi.default("1mm"),text:N().optional(),anchor_position:Ls.default({x:0,y:0}),anchor_alignment:Xt(["center","top_left","top_right","bottom_left","bottom_right"]).default("center"),color:N().optional()}).describe("Defines a documentation note in text on the PCB"),Wwn=Ee({type:me("pcb_note_rect"),pcb_note_rect_id:Yi("pcb_note_rect"),pcb_component_id:N().optional(),pcb_group_id:N().optional(),subcircuit_id:N().optional(),name:N().optional(),text:N().optional(),center:Ls,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:N().optional()}).describe("Defines a rectangular documentation note on the PCB"),Kwn=Ee({type:me("pcb_note_path"),pcb_note_path_id:Yi("pcb_note_path"),pcb_component_id:N().optional(),pcb_group_id:N().optional(),subcircuit_id:N().optional(),name:N().optional(),text:N().optional(),route:ut(Ls),stroke_width:_t.default("0.1mm"),color:N().optional()}).describe("Defines a polyline documentation note on the PCB"),Zwn=Ee({type:me("pcb_note_line"),pcb_note_line_id:Yi("pcb_note_line"),pcb_component_id:N().optional(),pcb_group_id:N().optional(),subcircuit_id:N().optional(),name:N().optional(),text:N().optional(),x1:fi,y1:fi,x2:fi,y2:fi,stroke_width:fi.default("0.1mm"),color:N().optional(),is_dashed:Je().optional()}).describe("Defines a straight documentation note line on the PCB"),Qwn=Ee({type:me("pcb_note_dimension"),pcb_note_dimension_id:Yi("pcb_note_dimension"),pcb_component_id:N().optional(),pcb_group_id:N().optional(),subcircuit_id:N().optional(),name:N().optional(),from:Ls,to:Ls,text:N().optional(),text_ccw_rotation:Ie().optional(),offset_distance:_t.optional(),offset_direction:Ee({x:Ie(),y:Ie()}).optional(),font:me("tscircuit2024").default("tscircuit2024"),font_size:_t.default("1mm"),color:N().optional(),arrow_size:_t.default("1mm")}).describe("Defines a measurement annotation within PCB documentation notes"),Jwn=Ee({type:me("pcb_footprint_overlap_error"),pcb_error_id:Yi("pcb_error"),error_type:me("pcb_footprint_overlap_error").default("pcb_footprint_overlap_error"),message:N(),pcb_smtpad_ids:ut(N()).optional(),pcb_plated_hole_ids:ut(N()).optional(),pcb_hole_ids:ut(N()).optional(),pcb_keepout_ids:ut(N()).optional()}).describe("Error emitted when a pcb footprint overlaps with another element"),eSn=Ee({type:me("pcb_keepout"),shape:me("rect"),pcb_group_id:N().optional(),subcircuit_id:N().optional(),center:Ls,width:fi,height:fi,pcb_keepout_id:N(),layers:ut(N()),description:N().optional()}).or(Ee({type:me("pcb_keepout"),shape:me("circle"),pcb_group_id:N().optional(),subcircuit_id:N().optional(),center:Ls,radius:fi,pcb_keepout_id:N(),layers:ut(N()),description:N().optional()})),_ge=Ee({type:me("pcb_cutout"),pcb_cutout_id:Yi("pcb_cutout"),pcb_group_id:N().optional(),subcircuit_id:N().optional()}),tSn=_ge.extend({shape:me("rect"),center:Ls,width:_t,height:_t,rotation:uS.optional()}),nSn=_ge.extend({shape:me("circle"),center:Ls,radius:_t}),iSn=_ge.extend({shape:me("polygon"),points:ut(Ls)}),rSn=gm("shape",[tSn,nSn,iSn]).describe("Defines a cutout on the PCB, removing board material."),oSn=Ee({type:me("pcb_missing_footprint_error"),pcb_missing_footprint_error_id:Yi("pcb_missing_footprint_error"),pcb_group_id:N().optional(),subcircuit_id:N().optional(),error_type:me("pcb_missing_footprint_error").default("pcb_missing_footprint_error"),source_component_id:N(),message:N()}).describe("Defines a missing footprint error on the PCB"),sSn=Ee({type:me("external_footprint_load_error"),external_footprint_load_error_id:Yi("external_footprint_load_error"),pcb_component_id:N(),source_component_id:N(),pcb_group_id:N().optional(),subcircuit_id:N().optional(),footprinter_string:N().optional(),error_type:me("external_footprint_load_error").default("external_footprint_load_error"),message:N()}).describe("Defines an error when an external footprint fails to load"),aSn=Ee({type:me("circuit_json_footprint_load_error"),circuit_json_footprint_load_error_id:Yi("circuit_json_footprint_load_error"),pcb_component_id:N(),source_component_id:N(),pcb_group_id:N().optional(),subcircuit_id:N().optional(),error_type:me("circuit_json_footprint_load_error").default("circuit_json_footprint_load_error"),message:N(),circuit_json:ut(fl()).optional()}).describe("Defines an error when a circuit JSON footprint fails to load"),cSn=Ee({type:me("pcb_group"),pcb_group_id:Yi("pcb_group"),source_group_id:N(),is_subcircuit:Je().optional(),subcircuit_id:N().optional(),width:_t.optional(),height:_t.optional(),center:Ls,outline:ut(Ls).optional(),anchor_position:Ls.optional(),anchor_alignment:Xt(["center","top_left","top_right","bottom_left","bottom_right"]).optional(),pcb_component_ids:ut(N()),name:N().optional(),description:N().optional(),layout_mode:N().optional(),autorouter_configuration:Ee({trace_clearance:_t}).optional(),autorouter_used_string:N().optional()}).describe("Defines a group of components on the PCB"),lSn=Ee({type:me("pcb_autorouting_error"),pcb_error_id:Yi("pcb_autorouting_error"),error_type:me("pcb_autorouting_error").default("pcb_autorouting_error"),message:N(),subcircuit_id:N().optional()}).describe("The autorouting has failed to route a portion of the board"),uSn=Ee({type:me("pcb_manual_edit_conflict_warning"),pcb_manual_edit_conflict_warning_id:Yi("pcb_manual_edit_conflict_warning"),warning_type:me("pcb_manual_edit_conflict_warning").default("pcb_manual_edit_conflict_warning"),message:N(),pcb_component_id:N(),pcb_group_id:N().optional(),subcircuit_id:N().optional(),source_component_id:N()}).describe("Warning emitted when a component has both manual placement and explicit pcbX/pcbY coordinates"),dSn=Ee({type:me("pcb_breakout_point"),pcb_breakout_point_id:Yi("pcb_breakout_point"),pcb_group_id:N(),subcircuit_id:N().optional(),source_trace_id:N().optional(),source_port_id:N().optional(),source_net_id:N().optional(),x:fi,y:fi}).describe("Defines a routing target within a pcb_group for a source_trace or source_net"),hSn=Ee({type:me("pcb_ground_plane"),pcb_ground_plane_id:Yi("pcb_ground_plane"),source_pcb_ground_plane_id:N(),source_net_id:N(),pcb_group_id:N().optional(),subcircuit_id:N().optional()}).describe("Defines a ground plane on the PCB"),pSn=Ee({type:me("pcb_ground_plane_region"),pcb_ground_plane_region_id:Yi("pcb_ground_plane_region"),pcb_ground_plane_id:N(),pcb_group_id:N().optional(),subcircuit_id:N().optional(),layer:Kd,points:ut(Ls)}).describe("Defines a polygon region of a ground plane"),fSn=Ee({type:me("pcb_thermal_spoke"),pcb_thermal_spoke_id:Yi("pcb_thermal_spoke"),pcb_ground_plane_id:N(),shape:N(),spoke_count:Ie(),spoke_thickness:fi,spoke_inner_diameter:fi,spoke_outer_diameter:fi,pcb_plated_hole_id:N().optional(),subcircuit_id:N().optional()}).describe("Pattern for connecting a ground plane to a plated hole"),yge=Ee({type:me("pcb_copper_pour"),pcb_copper_pour_id:Yi("pcb_copper_pour"),pcb_group_id:N().optional(),subcircuit_id:N().optional(),layer:Kd,source_net_id:N().optional(),covered_with_solder_mask:Je().optional().default(!0)}),mSn=yge.extend({shape:me("rect"),center:Ls,width:_t,height:_t,rotation:uS.optional()}),_Sn=yge.extend({shape:me("brep"),brep_shape:Zvn}),ySn=yge.extend({shape:me("polygon"),points:ut(Ls)}),gSn=gm("shape",[mSn,_Sn,ySn]).describe("Defines a copper pour on the PCB."),xSn=Ee({type:me("pcb_component_outside_board_error"),pcb_component_outside_board_error_id:Yi("pcb_component_outside_board_error"),error_type:me("pcb_component_outside_board_error").default("pcb_component_outside_board_error"),message:N(),pcb_component_id:N(),pcb_board_id:N(),component_center:Ls,component_bounds:Ee({min_x:Ie(),max_x:Ie(),min_y:Ie(),max_y:Ie()}),subcircuit_id:N().optional(),source_component_id:N().optional()}).describe("Error emitted when a PCB component is placed outside the board boundaries"),bSn=Ee({type:me("pcb_component_invalid_layer_error"),pcb_component_invalid_layer_error_id:Yi("pcb_component_invalid_layer_error"),error_type:me("pcb_component_invalid_layer_error").default("pcb_component_invalid_layer_error"),message:N(),pcb_component_id:N().optional(),source_component_id:N(),layer:Kd,subcircuit_id:N().optional()}).describe("Error emitted when a component is placed on an invalid layer (components can only be on 'top' or 'bottom' layers)"),vSn=Ee({type:me("pcb_via_clearance_error"),pcb_error_id:Yi("pcb_error"),error_type:me("pcb_via_clearance_error").default("pcb_via_clearance_error"),message:N(),pcb_via_ids:ut(N()).min(2),minimum_clearance:fi.optional(),actual_clearance:fi.optional(),pcb_center:Ee({x:Ie().optional(),y:Ie().optional()}).optional(),subcircuit_id:N().optional()}).describe("Error emitted when vias are closer than the allowed clearance"),wSn=Ee({type:me("pcb_courtyard_rect"),pcb_courtyard_rect_id:Yi("pcb_courtyard_rect"),pcb_component_id:N(),pcb_group_id:N().optional(),subcircuit_id:N().optional(),center:Ls,width:_t,height:_t,layer:fT,color:N().optional()}).describe("Defines a courtyard rectangle on the PCB"),SSn=Ee({type:me("pcb_courtyard_outline"),pcb_courtyard_outline_id:Yi("pcb_courtyard_outline"),pcb_component_id:N(),pcb_group_id:N().optional(),subcircuit_id:N().optional(),layer:fT,outline:ut(Ls).min(2),stroke_width:_t.default("0.1mm"),is_closed:Je().optional(),is_stroke_dashed:Je().optional(),color:N().optional()}).describe("Defines a courtyard outline on the PCB"),ESn=Ee({type:me("pcb_courtyard_polygon"),pcb_courtyard_polygon_id:Yi("pcb_courtyard_polygon"),pcb_component_id:N(),pcb_group_id:N().optional(),subcircuit_id:N().optional(),layer:fT,points:ut(Ls).min(3),color:N().optional()}).describe("Defines a courtyard polygon on the PCB"),TSn=Ee({type:me("cad_component"),cad_component_id:N(),pcb_component_id:N(),source_component_id:N(),position:pge,rotation:pge.optional(),size:pge.optional(),layer:Kd.optional(),subcircuit_id:N().optional(),footprinter_string:N().optional(),model_obj_url:N().optional(),model_stl_url:N().optional(),model_3mf_url:N().optional(),model_gltf_url:N().optional(),model_glb_url:N().optional(),model_step_url:N().optional(),model_wrl_url:N().optional(),model_unit_to_mm_scale_factor:Ie().optional(),model_jscad:fl().optional()}).describe("Defines a component on the PCB"),MSn=Xt(["sinewave","square","triangle","sawtooth"]),CSn=Bn([N(),Ie()]).transform(n=>typeof n=="string"?n.endsWith("%")?parseFloat(n.slice(0,-1))/100:parseFloat(n):n).pipe(Ie().min(0,"Duty cycle must be non-negative").max(1,"Duty cycle cannot be greater than 100%")),ASn=Ee({type:me("simulation_voltage_source"),simulation_voltage_source_id:Yi("simulation_voltage_source"),is_dc_source:me(!0).optional().default(!0),positive_source_port_id:N().optional(),negative_source_port_id:N().optional(),positive_source_net_id:N().optional(),negative_source_net_id:N().optional(),voltage:hI}).describe("Defines a DC voltage source for simulation"),PSn=Ee({type:me("simulation_voltage_source"),simulation_voltage_source_id:Yi("simulation_voltage_source"),is_dc_source:me(!1),terminal1_source_port_id:N().optional(),terminal2_source_port_id:N().optional(),terminal1_source_net_id:N().optional(),terminal2_source_net_id:N().optional(),voltage:hI.optional(),frequency:dge.optional(),peak_to_peak_voltage:hI.optional(),wave_shape:MSn.optional(),phase:uS.optional(),duty_cycle:CSn.optional()}).describe("Defines an AC voltage source for simulation"),RSn=Bn([ASn,PSn]).describe("Defines a voltage source for simulation"),ISn=Bn([me("spice_dc_sweep"),me("spice_dc_operating_point"),me("spice_transient_analysis"),me("spice_ac_analysis")]),NSn=Ee({type:me("simulation_experiment"),simulation_experiment_id:Yi("simulation_experiment"),name:N(),experiment_type:ISn,time_per_step:hge.optional(),start_time_ms:pI.optional(),end_time_ms:pI.optional()}).describe("Defines a simulation experiment configuration"),kSn=Ee({type:me("simulation_transient_voltage_graph"),simulation_transient_voltage_graph_id:Yi("simulation_transient_voltage_graph"),simulation_experiment_id:N(),timestamps_ms:ut(Ie()).optional(),voltage_levels:ut(Ie()),schematic_voltage_probe_id:N().optional(),simulation_voltage_probe_id:N().optional(),subcircuit_connectivity_map_key:N().optional(),time_per_step:hge,start_time_ms:pI,end_time_ms:pI,name:N().optional()}).describe("Stores voltage measurements over time for a simulation"),OSn=Ee({type:me("simulation_switch"),simulation_switch_id:Yi("simulation_switch"),source_component_id:N().optional(),closes_at:pI.optional(),opens_at:pI.optional(),starts_closed:Je().optional(),switching_frequency:dge.optional()}).describe("Defines a switch for simulation timing control"),LSn=Ee({type:me("simulation_voltage_probe"),simulation_voltage_probe_id:Yi("simulation_voltage_probe"),source_port_id:N().optional(),source_net_id:N().optional(),name:N().optional(),subcircuit_id:N().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"}),DSn=Ee({type:me("simulation_unknown_experiment_error"),simulation_unknown_experiment_error_id:Yi("simulation_unknown_experiment_error"),error_type:me("simulation_unknown_experiment_error").default("simulation_unknown_experiment_error"),message:N(),simulation_experiment_id:N().optional(),subcircuit_id:N().optional()}).describe("An unknown error occurred during the simulation experiment.");Bn([fvn,pvn,hvn,_vn,mvn,Wet,Yet,fge,Xet,qet,Ket,Zet,Qet,ttt,ntt,itt,att,rtt,ott,stt,ett,Jet,gvn,bvn,yvn,ctt,ltt,utt,vvn,ewn,twn,oSn,sSn,aSn,uSn,awn,eSn,cwn,Iwn,wwn,Mwn,Nwn,mwn,vwn,kwn,Own,cSn,Dwn,zwn,$wn,Fwn,Uwn,Bwn,jwn,Hwn,Cwn,Awn,Lwn,Pwn,Rwn,vSn,Gwn,Vwn,Ywn,qwn,Xwn,Wwn,Kwn,Zwn,Qwn,lSn,Jwn,dSn,rSn,hSn,pSn,fSn,gSn,xSn,bSn,wSn,SSn,ESn,wvn,Lvn,Pvn,Rvn,Ivn,Nvn,Avn,Dvn,kvn,Svn,$vn,Fvn,zvn,Hvn,Vvn,Gvn,Yvn,Wvn,qvn,Xvn,TSn,RSn,NSn,kSn,OSn,LSn,DSn]);var zSn=Object.defineProperty,$Sn=(n,e)=>{for(var t in e)zSn(n,t,{get:e[t],enumerable:!0})},K5={};$Sn(K5,{axial:()=>$2n,bga:()=>KSn,breakoutheaders:()=>X2n,cap:()=>GSn,dfn:()=>x2n,diode:()=>VSn,dip:()=>BSn,electrolytic:()=>R5n,hc49:()=>K2n,jst:()=>e5n,led:()=>YSn,lqfp:()=>Y2n,m2host:()=>q5n,melf:()=>lTn,micromelf:()=>pTn,minimelf:()=>tTn,mlp:()=>r2n,ms012:()=>M2n,ms013:()=>A2n,msop:()=>u5n,pad:()=>Z2n,pinrow:()=>w2n,platedhole:()=>j5n,potentiometer:()=>C5n,pushbutton:()=>U2n,qfn:()=>n2n,qfp:()=>i2n,quad:()=>TL,res:()=>qSn,sma:()=>yTn,smb:()=>TTn,smbf:()=>N5n,smc:()=>PTn,smf:()=>vTn,smtpad:()=>U5n,sod110:()=>n5n,sod123:()=>O2n,sod123f:()=>kEn,sod123fl:()=>zEn,sod123w:()=>pEn,sod128:()=>GEn,sod323:()=>yEn,sod323f:()=>PEn,sod323fl:()=>_5n,sod323w:()=>h5n,sod523:()=>iEn,sod723:()=>BEn,sod80:()=>lEn,sod882:()=>TEn,sod882d:()=>oTn,sod923:()=>vEn,soic:()=>QSn,solderjumper:()=>v5n,son:()=>b5n,sop8:()=>aEn,sot:()=>V5n,sot223:()=>kTn,sot23:()=>h2n,sot23w:()=>jTn,sot25:()=>_2n,sot323:()=>D5n,sot363:()=>u2n,sot457:()=>E5n,sot563:()=>E2n,sot723:()=>R2n,sot89:()=>ZEn,ssop:()=>s2n,stampboard:()=>j2n,stampreceiver:()=>G2n,to220:()=>JEn,to92:()=>tEn,to92s:()=>XTn,tssop:()=>c2n,vssop:()=>a5n});var Uo=(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"}),ka=(n,e,t,i,r)=>({pcb_plated_hole_id:"",type:"pcb_plated_hole",shape:"circle",x:e,y:t,hole_diameter:xh(i),outer_diameter:xh(r),pcb_port_id:"",layers:["top","bottom"],port_hints:[n.toString()]}),ytt=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 KM(n){return typeof n=="string"?n.trim().toLowerCase().endsWith("mil")?parseFloat(n)*.0254:parseFloat(n):Number(n)}var kV=Bn([N(),Ie()]).transform(n=>KM(n)),FSn=n=>Ee({fn:N(),num_pins:Ie().optional().default(6),wide:Je().optional(),narrow:Je().optional(),w:kV.optional(),p:kV.default(n.p??"2.54mm"),id:kV.optional(),od:kV.optional()}).transform(e=>(!e.id&&!e.od?Math.abs(e.p-1.27)<.01?(e.id=KM("0.55mm"),e.od=KM("0.95mm")):(e.id=KM("1.0mm"),e.od=KM("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=KM("600mil"):e.narrow?e.w=KM("300mil"):e.w=KM(n.w??"300mil")),e)),USn=FSn({}),gtt=(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}},BSn=n=>{const e=USn.parse(n),t=[];for(let l=0;l<e.num_pins;l++){const{x:u,y:d}=gtt(e.num_pins,l+1,e.w,e.p??2.54);t.push(ka(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},...ytt.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}=gtt(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=Uo(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()]}),xtt=[{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}],jSn=Object.fromEntries(xtt.map(n=>[n.metric,n])),HSn=Object.fromEntries(xtt.map(n=>[n.imperial,n]));Ee({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 OV=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=EL(a)),typeof c=="string"&&(c=EL(c)),typeof t=="string"&&(t=EL(t)),typeof i=="string"&&(i=EL(i)),typeof r=="string"&&(r=EL(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=jSn[o]),s&&(u=HSn[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=Uo(0,h,.2);return e?[ka(1,-t/2,0,i,i*1/.8),ka(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]},VSn=n=>({circuitJson:OV(n),parameters:n}),GSn=n=>({circuitJson:OV(n),parameters:n}),YSn=n=>({circuitJson:OV(n),parameters:n}),qSn=n=>({circuitJson:OV(n),parameters:n}),btt=(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()]}),vtt="ABCDEFGHIJKLMNOPQRSTUVWXYZ",wtt=N().transform(n=>{const[e,t]=n.split(/[x ]/);return{x:parseFloat(e),y:parseFloat(t)}}).pipe(Ee({x:Ie(),y:Ie()})),XSn=N().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(N().or(Ie()))),WSn=Ee({fn:N(),num_pins:Ie().optional().default(64),grid:wtt.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:XSn.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=vtt.indexOf(r[1]),s=Number.parseInt(r[2])-1;return o*n.grid.x+s+1})),{...n,origin:e}}),KSn=n=>{const e=WSn.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(I=>typeof I=="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 I=Math.floor(Math.sqrt(h)),A=Math.floor((i.x-I)/2),R=Math.floor((i.y-I)/2);for(let M=R;M<R+I;M++)for(let k=A;k<A+I;k++)d.push(M*i.x+k+1)}l?.includes("topleft")&&d.push(1);const p=new Set(d);let m=0;for(let I=0;I<i.y;I++)for(let A=0;A<i.x;A++){const R=(A-(i.x-1)/2)*r,M=(I-(i.y-1)/2)*r;let k=A,C=I;switch(e.origin){case"bl":k=A,C=i.y-1-I;break;case"br":k=i.x-1-A,C=i.y-1-I;break;case"tr":k=i.x-1-A,C=I;break}let U=C*i.x+k+1;if(p.has(U)){m++;continue}U-=m;const O=[U,`${vtt[C]}${k+1}`];u.push(e.circularpads?btt(O,{x:R,y:M,radius:c/2}):zr(O,R,M,c,c))}const _=Uo(0,i.y*r/2,.2),y=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-y},{x:-b-y,y:-w},{x:-b,y:-w}];break;case"br":x=[{x:b,y:-w},{x:b,y:-w-y},{x:b+y,y:-w},{x:b,y:-w}];break;case"tr":x=[{x:b,y:w},{x:b,y:w+y},{x:b+y,y:w},{x:b,y:w}];break;case"tl":default:x=[{x:-b,y:w},{x:-b,y:w+y},{x:-b-y,y:w},{x:-b,y:w}];break}const S={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"pin1_marker",route:x,stroke_width:.05};return{circuitJson:[...u,_,S],parameters:e}},LV=(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()]}),rE=n=>Ee({fn:N(),num_pins:Ie().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)),ZSn=rE({}),gge=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}},QSn=n=>{const e=ZSn.parse(n);return{circuitJson:Z5(e),parameters:e}},Z5=n=>{const e=[];for(let a=0;a<n.num_pins;a++){const{x:c,y:l}=gge({num_pins:n.num_pins,pn:a+1,w:n.w,p:n.p,pl:n.pl,legsoutside:n.legsoutside});n.pillpads?e.push(LV(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=Uo(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},...ytt.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]},Stt=Xt(["leftside","topside","rightside","bottomside","toppin","bottompin","leftpin","rightpin"]),JSn=({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},xge=Ee({fn:N(),cc:Je().default(!0).optional(),ccw:Je().default(!0).optional(),startingpin:N().or(ut(Stt)).transform(n=>typeof n=="string"?n.slice(1,-1).split(","):n).pipe(ut(Stt)).optional(),num_pins:Ie().optional().default(64),w:_t.optional(),h:_t.optional(),p:_t.default(_t.parse("0.5mm")),pw:_t.optional(),pl:_t.optional(),thermalpad:Bn([me(!0),wtt]).optional(),legsoutside:Je().default(!1)}),bge=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},Ett=xge.transform(bge),e2n=["left","bottom","right","top"],t2n=n=>{const{pin_count:e,pn:t,w:i,h:r,p:o,pl:s,legsoutside:a}=n,c=e/4,l=e2n[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")}},TL=n=>{const e=Ett.parse(n),t=[],i=JSn(e),r=e.num_pins/4;for(let a=0;a<e.num_pins;a++){const{x:c,y:l,o:u}=t2n({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 y=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*y,m-=b*l*y}(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*y},{x:p,y:m},{x:p+.2*y*-c,y:m+.2},{x:p-.2*-c,y:m+.2*y}],type:"pcb_silkscreen_path",stroke_width:.1})}const s=Uo(0,e.h/2+(e.legsoutside?e.pl*1.2:.5),.3);return{circuitJson:[...t,...o,s],parameters:e}};xge.extend({}).transform(bge);var n2n=n=>(n.legsoutside=!1,TL(n)),i2n=n=>{n.legsoutside=!0;const e=Ett.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 TL(n)};xge.extend({}).transform(bge);var r2n=n=>(n.legsoutside=!1,n.thermalpad===void 0&&(n.thermalpad=!0),TL(n)),o2n=rE({w:"3.9mm",p:"1.27mm"}),s2n=n=>{const e=o2n.parse(n);return{circuitJson:Z5(e),parameters:e}},a2n=rE({w:"7.1mm",p:"0.65mm",pl:"1.35mm",pw:"0.40mm",legsoutside:!0}),c2n=n=>{const e=a2n.parse(n);return{circuitJson:Z5(e),parameters:e}},l2n=rE({}),u2n=n=>{const e=l2n.parse({fn:"sot363",num_pins:6,w:1.94,p:.65,pw:.3,pl:.7,legoutside:!0});return{circuitJson:Z5(e),parameters:e}},Ttt=Ee({fn:N(),num_pins:Ie().default(3),w:N().default("1.92mm"),h:N().default("2.74mm"),pl:N().default("0.8mm"),pw:N().default("0.764mm"),p:N().default("0.95mm"),string:N().optional()}),d2n=rE({p:"0.95mm",w:"1.6mm",legsoutside:!0}),h2n=n=>{const e=n.string?.match(/^sot23_(\d+)/),t=e?Number.parseInt(e[1],10):3;if(t===6||t===8){const r=d2n.parse({...n,num_pins:t});return{circuitJson:Z5(r),parameters:r}}const i=Ttt.parse({...n,num_pins:t});if(i.num_pins===3)return{circuitJson:f2n(i),parameters:i};if(i.num_pins===5)return{circuitJson:Ctt(i),parameters:i};throw new Error("Invalid number of pins")},p2n=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}},f2n=n=>{const e=[];for(let i=0;i<n.num_pins;i++){const{x:r,y:o}=p2n({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=Uo(0,Number.parseInt(n.h),.3);return[...e,t]},Mtt=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")},Ctt=n=>{const e=[];for(let d=1;d<=n.num_pins;d++){const{x:h,y:p}=Mtt({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=Uo(0,i+.3,.3),a=Mtt({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]},m2n=Ttt.extend({}),_2n=n=>{const e=m2n.parse({...n,num_pins:5});return{circuitJson:Ctt(e),parameters:e}},y2n=[{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}],g2n=rE({}),x2n=n=>{const e=g2n.parse(n),t=[];for(let d=0;d<e.num_pins;d++){const{x:h,y:p}=gge({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 y2n){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=Uo(0,o/2+.4,o/12);return{circuitJson:[...t,u,...s],parameters:e}},DV=(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:xh(i),hole_shape:"circle",pad_shape:"rect",rect_pad_width:xh(r),rect_pad_height:xh(o),pcb_port_id:"",layers:["top","bottom"],port_hints:[n.toString()]}),vge=({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 b2n({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 v2n=Ee({fn:N(),num_pins:Ie().optional().default(6),rows:Bn([N(),Ie()]).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=b2n(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"]})}),w2n=n=>{const e=v2n.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 y=[],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}},S=(M,k,C)=>{M===1&&!e.nosquareplating?y.push(DV(M,k,C,i,r,r)):y.push(ka(M,k,C,i,r));const{anchor_x:U,anchor_y:O}=w({xoff:k,yoff:C,od:r,anchorSide:a});h||(m?y.push(vge({fs:r/5,pn:M,anchor_x:U,anchor_y:O,textalign:_,orthogonal:l,verticallyinverted:c,layer:"bottom"})):y.push(vge({fs:r/5,pn:M,anchor_x:U,anchor_y:O,textalign:_,orthogonal:l,verticallyinverted:c,layer:"top"})),p&&y.push(vge({fs:r/5,pn:M,anchor_x:U,anchor_y:O,textalign:_,orthogonal:l,verticallyinverted:c,layer:"bottom"})))},I=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(I.has(O))throw new Error(`Overlap at ${O}`);I.add(O),S(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(I.has(Y))throw new Error(`Overlap at ${Y}`);I.add(Y),S(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 X=M+O*t,K=Y*b,J=`${X},${K}`;if(I.has(J))throw new Error(`Overlap at ${J}`);I.add(J),S(k++,X,K)}O++;for(let Y=O;Y<=H&&k<=s;Y++){const X=M+Y*t,K=U*b,J=`${X},${K}`;if(I.has(J))throw new Error(`Overlap at ${J}`);I.add(J),S(k++,X,K)}if(U--,O<=H){for(let Y=U;Y>=C&&k<=s;Y--){const X=M+H*t,K=Y*b,J=`${X},${K}`;if(I.has(J))throw new Error(`Overlap at ${J}`);I.add(J),S(k++,X,K)}H--}if(C<=U){for(let Y=H;Y>=O&&k<=s;Y--){const X=M+Y*t,K=C*b,J=`${X},${K}`;if(I.has(J))throw new Error(`Overlap at ${J}`);I.add(J),S(k++,X,K)}C++}}if(k-1<s)throw new Error(`Missing pins: assigned ${k-1}, expected ${s}`)}const R=Uo(0,t,.5);return{circuitJson:[...y,R],parameters:e}},S2n=rE({}),E2n=n=>{const e=S2n.parse({fn:"sot563",num_pins:6,w:1.94,p:.5,pw:.3,pl:.67,legoutside:!0});return{circuitJson:Z5(e),parameters:e}},T2n=rE({p:"1.27mm",w:"3.9mm",legsoutside:!0}),M2n=n=>{const e=T2n.parse({...n,num_pins:8});return{circuitJson:Z5(e),parameters:e}},C2n=rE({p:"1.27mm",w:"7.5mm",legsoutside:!0}),A2n=n=>{const e=C2n.parse({...n,num_pins:16});return{circuitJson:Z5(e),parameters:e}},P2n=Ee({fn:N(),num_pins:me(3).default(3),w:N().default("1.2mm"),h:N().default("1.2mm"),pl:N().default("0.3mm"),pw:N().default("0.32mm")}),R2n=n=>{const e=P2n.parse(n),t=N2n(e),i=Uo(.4,_t.parse(e.h),.2);return{circuitJson:[...t,i],parameters:e}},I2n=n=>{const{pn:e}=n;return e===1?{x:0,y:0}:e===2?{x:1,y:-.4}:{x:1,y:.4}},N2n=n=>{const e=[];for(let t=0;t<3;t++){const{x:i,y:r}=I2n({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},k2n=Ee({fn:N(),num_pins:me(2).default(2),w:N().default("2.36mm"),h:N().default("1.22mm"),pl:N().default("0.9mm"),pw:N().default("0.9mm"),p:N().default("4.19mm")}),O2n=n=>{const e=k2n.parse(n),t=Uo(0,_t.parse(e.h)/4+.4,.3);return{circuitJson:D2n(e).concat(t),parameters:e}},L2n=n=>{const{pn:e,p:t}=n;return e===1?{x:-t/2,y:0}:{x:t/2,y:0}},D2n=n=>{const e=[];for(let t=1;t<=n.num_pins;t++){const{x:i,y:r}=L2n({pn:t,p:Number.parseFloat(n.p)});e.push(zr(t,i,r,Number.parseFloat(n.pl),Number.parseFloat(n.pw)))}return e},z2n=Ee({fn:N(),p:_t.optional().default("2.54mm"),id:_t.optional().default("0.7mm"),od:_t.optional().default("1mm")}),$2n=n=>{const e=z2n.parse(n),{p:t,id:i,od:r}=e,o=[ka(1,-t/2,0,i,r),ka(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=Uo(0,t/4,.5);return{circuitJson:[...o,s,a],parameters:e}},zV=(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}),F2n=Ee({fn:me("pushbutton"),w:_t.default(4.5),h:_t.default(6.5),id:_t.default(1),od:_t.default(1.2)}),U2n=n=>{const e=F2n.parse(n),t=e.w,i=e.h,r=e.id,o=[ka(1,-t/2,i/2,r,r*1.5),ka(2,-t/2,-i/2,r,r*1.5),ka(3,t/2,-i/2,r,r*1.5),ka(4,t/2,i/2,r,r*1.5)],s=[zV([{x:-t/2,y:-i/2},{x:-t/2,y:i/2}]),zV([{x:t/2,y:-i/2},{x:t/2,y:i/2}]),zV([{x:-t/2,y:0},{x:-t/5,y:0},{x:t/5*1/Math.sqrt(2),y:i/8}]),zV([{x:t/2,y:0},{x:t/5,y:0}])],a=Uo(0,i/2+.4,.5);return{circuitJson:[...o,...s,a],parameters:e}},Att=Ee({fn:N(),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"))}),B2n=n=>{const e=Att.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},$V=(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},j2n=n=>{const e=Att.parse(n),t=e.h??B2n(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 y=0;y<e.right;y++){if(y===0&&!e.left&&!e.bottom&&!e.silkscreenlabels&&(s=$V(e.w/2-e.pl*1.4,_+y*e.p,"right")),i.push(zr(y+1+e.left+(e.bottom??0),e.w/2-e.pl/2,_+y*e.p,e.pl,e.pw)),e.silkscreenlabels){const x=y+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:_+y*e.p},text:b,font_size:.7,font:"tscircuit2024",anchor_alignment:"center"})}e.innerhole&&(r.push(ka(y+1+e.left+(e.bottom??0)+l,e.w/2,_+y*e.p,a,c)),r.push(ka(y+1+e.left+(e.bottom??0)+l*2,e.w/2-e.innerholeedgedistance,_+y*e.p,a,c)))}}if(e.left){const _=(e.left-1)/2*e.p;for(let y=0;y<e.left;y++){if(y===0&&!e.silkscreenlabels&&(s=$V(-e.w/2+e.pl*1.4,_-y*e.p,"left")),i.push(zr(y+1,-e.w/2+e.pl/2,_-y*e.p,e.pl,e.pw)),e.silkscreenlabels){const x=y+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:_-y*e.p},text:b,font_size:.7,font:"tscircuit2024",anchor_alignment:"center"})}e.innerhole&&(r.push(ka(y+1+l,-e.w/2,_-y*e.p,a,c)),r.push(ka(y+1+l*2,-e.w/2+e.innerholeedgedistance,_-y*e.p,a,c)))}}if(e.top){const _=(e.top-1)/2*e.p;for(let y=0;y<e.top;y++){if(y===0&&!e.left&&!e.bottom&&!e.right&&!e.silkscreenlabels&&(s=$V(_-y*e.p,t/2-e.pl*1.4,"top")),i.push(zr(y+1+e.left+e.right+(e.bottom??0),_-y*e.p,t/2-e.pl/2,e.pw,e.pl)),e.silkscreenlabels){const x=y+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:_-y*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(ka(y+1+e.left+e.right+(e.bottom??0)+l,_-y*e.p,t/2,a,c)),r.push(ka(y+1+e.left+e.right+(e.bottom??0)+l*2,_-y*e.p,t/2-e.innerholeedgedistance,a,c)))}}if(e.bottom){const _=-((e.bottom-1)/2)*e.p;for(let y=0;y<e.bottom;y++){if(y===0&&!e.left&&!e.silkscreenlabels&&(s=$V(_+y*e.p,-t/2+e.pl*1.4,"bottom")),i.push(zr(y+1+e.left,_+y*e.p,-t/2+e.pl/2,e.pw,e.pl)),e.silkscreenlabels){const x=y+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:_+y*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(ka(y+1+e.left+l,_+y*e.p,-t/2,a,c)),r.push(ka(y+1+e.left+l*2,_+y*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=Uo(0,t/1.8,t/25);return{circuitJson:[...i,...r,...o,p,...e.silkscreenlabels?[]:[h],m],parameters:e}},Ptt=Ee({fn:N(),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"))}),H2n=n=>{const e=Ptt.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},V2n=(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]},G2n=n=>{const e=Ptt.parse(n),t=e.h??H2n(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=V2n(-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(ka(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(ka(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(ka(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(ka(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=Uo(0,t/1.8,t/25);return{circuitJson:[...o,...i,...r,h,d,p],parameters:e}},Y2n=n=>(n.legsoutside=!0,TL(n)),Rtt=Ee({fn:N(),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"))}),q2n=n=>{const e=Rtt.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},FV=(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]},X2n=n=>{const e=Rtt.parse(n),t=e.h??q2n(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=FV(e.w/2+o*1.4,u+d*e.p,"right")),i.push(ka(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=FV(-e.w/2-o*1.4,u+d*e.p,"left")),i.push(ka(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=FV(u+d*e.p,t/2+o*1.4,"top")),i.push(ka(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=FV(u+d*e.p,-t/2-o*1.4,"bottom")),i.push(ka(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=Uo(0,t/1.7,t/25);return{circuitJson:[...i,c,l,a],parameters:e}},Itt=(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}}),W2n=Ee({fn:N(),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")}),K2n=n=>{const e=W2n.parse(n),{p:t,id:i,od:r,w:o,h:s}=e,a=s/2,c=[ka(1,-t/2,0,i,r),ka(2,t/2,0,i,r)],l=Itt(-o/2,0,a,"left"),u=Itt(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=Uo(0,t/4,.5);return{circuitJson:[...c,d,h],parameters:e}};Ee({w:_t,h:_t});var Z2n=n=>{const{w:e,h:t}=n,i=xh(e),r=xh(t);return{circuitJson:[zr(1,0,0,i,r),Uo(0,r/2+.5,.2)],parameters:n}},Q2n=Ee({fn:N(),num_pins:Bn([me(3),me(2)]).default(3),p:N().default("1.27mm"),id:N().default("0.72mm"),od:N().default("0.95mm"),w:N().default("4.5mm"),h:N().default("4.5mm"),inline:Je().default(!1),string:N().optional()}),J2n=(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}}),eEn=n=>{const{p:e,id:t,od:i,h:r}=n,o=Number.parseFloat(r)/2,s=Number.parseFloat(e);return[ka(1,-s,o-s,t,i),ka(2,s,o-s,t,i)]},tEn=n=>{const e=n.string?.match(/^to92_(\d+)/),t=e?Number.parseInt(e[1],10):3,i=Q2n.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?[ka(1,-d,u-d,o,s),ka(2,0,u-d,o,s),ka(3,d,u-d,o,s)]:[ka(1,0,u,o,s),ka(2,-d,u-d,o,s),ka(3,d,u-d,o,s)];else if(i.num_pins===2)h=eEn(i);else throw new Error("Invalid number of pins for TO-92");const p=Number.parseFloat(a)/2,m=J2n(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:""},y=Uo(0,u+1,.5);return{circuitJson:[...h,_,y],parameters:i}},nEn=Ee({fn:N(),num_pins:me(2).default(2),w:N().default("2.15mm"),h:N().default("1.20mm"),pl:N().default("0.5mm"),pw:N().default("0.6mm"),p:N().default("1.4mm")}),iEn=n=>{const e=nEn.parse(n),t=Uo(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:oEn(e).concat(i,t),parameters:e}},rEn=n=>{const{pn:e,p:t}=n;return e===1?{x:-t/2,y:0}:{x:t/2,y:0}},oEn=n=>{const e=[];for(let t=1;t<=n.num_pins;t++){const{x:i,y:r}=rEn({pn:t,p:Number.parseFloat(n.p)});e.push(zr(t,i,r,Number.parseFloat(n.pl),Number.parseFloat(n.pw)))}return e},sEn=rE({}),aEn=n=>{const e=sEn.parse(n),t=[];for(let s=0;s<e.num_pins;s++){const{x:a,y:c}=gge({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=Uo(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}},cEn=Ee({fn:N(),num_pins:me(2).default(2),w:N().default("5.0mm"),h:N().default("2.30mm"),pl:N().default("1.25mm"),pw:N().default("2mm"),p:N().default("3.75mm")}),lEn=n=>{const e=cEn.parse(n),t=Uo(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:dEn(e).concat(i,t),parameters:e}},uEn=n=>{const{pn:e,p:t}=n;return e===1?{x:-t/2,y:0}:{x:t/2,y:0}},dEn=n=>{const e=[];for(let t=1;t<=n.num_pins;t++){const{x:i,y:r}=uEn({pn:t,p:Number.parseFloat(n.p)});e.push(zr(t,i,r,Number.parseFloat(n.pl),Number.parseFloat(n.pw)))}return e},hEn=Ee({fn:N(),num_pins:me(2).default(2),w:N().default("4.4mm"),h:N().default("2.1mm"),pl:N().default("1.2mm"),pw:N().default("1.2mm"),p:N().default("2.9mm")}),pEn=n=>{const e=hEn.parse(n),t=Uo(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:mEn(e).concat(i,t),parameters:e}},fEn=n=>{const{pn:e,p:t}=n;return e===1?{x:-t/2,y:0}:{x:t/2,y:0}},mEn=n=>{const e=[];for(let t=1;t<=n.num_pins;t++){const{x:i,y:r}=fEn({pn:t,p:Number.parseFloat(n.p)});e.push(zr(t,i,r,Number.parseFloat(n.pl),Number.parseFloat(n.pw)))}return e},_En=Ee({fn:N(),num_pins:me(2).default(2),w:N().default("3.30mm"),h:N().default("1.80mm"),pl:N().default("0.60mm"),pw:N().default("0.45mm"),p:N().default("2.1mm")}),yEn=n=>{const e=_En.parse(n),t=Uo(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:xEn(e).concat(i,t),parameters:e}},gEn=n=>{const{pn:e,p:t}=n;return e===1?{x:-t/2,y:0}:{x:t/2,y:0}},xEn=n=>{const e=[];for(let t=1;t<=n.num_pins;t++){const{x:i,y:r}=gEn({pn:t,p:Number.parseFloat(n.p)});e.push(zr(t,i,r,Number.parseFloat(n.pl),Number.parseFloat(n.pw)))}return e},bEn=Ee({fn:N(),num_pins:me(2).default(2),w:N().default("1.4mm"),h:N().default("0.9mm"),pl:N().default("0.35mm"),pw:N().default("0.25mm"),p:N().default("1.2mm")}),vEn=n=>{const e=bEn.parse(n),t=Uo(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:SEn(e).concat(i,t),parameters:e}},wEn=n=>{const{pn:e,p:t}=n;return e===1?{x:-t/2,y:0}:{x:t/2,y:0}},SEn=n=>{const e=[];for(let t=1;t<=n.num_pins;t++){const{x:i,y:r}=wEn({pn:t,p:Number.parseFloat(n.p)});e.push(zr(t,i,r,Number.parseFloat(n.pl),Number.parseFloat(n.pw)))}return e},EEn=Ee({fn:N(),num_pins:me(2).default(2),w:N().default("1.3mm"),h:N().default("0.9mm"),pl:N().default("0.4mm"),pw:N().default("0.7mm"),p:N().default("0.7mm")}),TEn=n=>{const e=EEn.parse(n),t=Uo(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:CEn(e).concat(i,t),parameters:e}},MEn=n=>{const{pn:e,p:t}=n;return e===1?{x:-t/2,y:0}:{x:t/2,y:0}},CEn=n=>{const e=[];for(let t=1;t<=n.num_pins;t++){const{x:i,y:r}=MEn({pn:t,p:Number.parseFloat(n.p)});e.push(zr(t,i,r,Number.parseFloat(n.pl),Number.parseFloat(n.pw)))}return e},AEn=Ee({fn:N(),num_pins:me(2).default(2),w:N().default("3,05mm"),h:N().default("1.65mm"),pl:N().default("0.6mm"),pw:N().default("0.6mm"),pad_spacing:N().default("2.2mm")}),PEn=n=>{const e=AEn.parse(n),t=Uo(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:IEn(e).concat(i,t),parameters:e}},REn=n=>{const{pn:e,pad_spacing:t}=n;return e===1?{x:-t/2,y:0}:{x:t/2,y:0}},IEn=n=>{const e=[];for(let t=1;t<=n.num_pins;t++){const{x:i,y:r}=REn({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},NEn=Ee({fn:N(),num_pins:me(2).default(2),w:N().default("4.4mm"),h:N().default("2.1mm"),pl:N().default("1.2mm"),pw:N().default("1.2mm"),p:N().default("2.9mm")}),kEn=n=>{const e=NEn.parse(n),t=Uo(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:LEn(e).concat(i,t),parameters:e}},OEn=n=>{const{pn:e,p:t}=n;return e===1?{x:-t/2,y:0}:{x:t/2,y:0}},LEn=n=>{const e=[];for(let t=1;t<=n.num_pins;t++){const{x:i,y:r}=OEn({pn:t,p:Number.parseFloat(n.p)});e.push(zr(t,i,r,Number.parseFloat(n.pl),Number.parseFloat(n.pw)))}return e},DEn=Ee({fn:N(),num_pins:me(2).default(2),w:N().default("4.4mm"),h:N().default("2.1mm"),pl:N().default("0.91mm"),pw:N().default("1.22mm"),p:N().default("3.146mm")}),zEn=n=>{const e=DEn.parse(n),t=Uo(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:FEn(e).concat(i,t),parameters:e}},$En=n=>{const{pn:e,p:t}=n;return e===1?{x:-t/2,y:0}:{x:t/2,y:0}},FEn=n=>{const e=[];for(let t=1;t<=n.num_pins;t++){const{x:i,y:r}=$En({pn:t,p:Number.parseFloat(n.p)});e.push(zr(t,i,r,Number.parseFloat(n.pl),Number.parseFloat(n.pw)))}return e},UEn=Ee({fn:N(),num_pins:me(2).default(2),w:N().default("1.80mm"),h:N().default("1.00mm"),pl:N().default("0.66mm"),pw:N().default("0.5mm"),p:N().default("0.8mm")}),BEn=n=>{const e=UEn.parse(n),t=Uo(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:HEn(e).concat(i,t),parameters:e}},jEn=n=>{const{pn:e,p:t}=n;return e===1?{x:-t/2,y:0}:{x:t/2,y:0}},HEn=n=>{const e=[];for(let t=1;t<=n.num_pins;t++){const{x:i,y:r}=jEn({pn:t,p:Number.parseFloat(n.p)});e.push(zr(t,i,r,Number.parseFloat(n.pl),Number.parseFloat(n.pw)))}return e},VEn=Ee({fn:N(),num_pins:me(2).default(2),w:N().default("6.2mm"),h:N().default("3.4mm"),pl:N().default("1.4mm"),pw:N().default("2.1mm"),p:N().default("4.4mm")}),GEn=n=>{const e=VEn.parse(n),t=Uo(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:qEn(e).concat(i,t),parameters:e}},YEn=n=>{const{pn:e,p:t}=n;return e===1?{x:-t/2,y:0}:{x:t/2,y:0}},qEn=n=>{const e=[];for(let t=1;t<=n.num_pins;t++){const{x:i,y:r}=YEn({pn:t,p:Number.parseFloat(n.p)});e.push(zr(t,i,r,Number.parseFloat(n.pl),Number.parseFloat(n.pw)))}return e},XEn=Ee({fn:N(),num_pins:Bn([me(3),me(5)]).default(3),w:N().default("4.80mm"),h:N().default("4.80mm"),pl:N().default("1.3mm"),pw:N().default("0.9mm"),p:N().default("1.5mm"),string:N().optional()}),WEn=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=Uo(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]},KEn=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=Uo(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]},ZEn=n=>{const e=n.string?.match(/^sot89_(\d+)/),t=e?Number.parseInt(e[1],10):3,i=XEn.parse({...n,num_pins:t});if(i.num_pins===3)return{circuitJson:WEn(i),parameters:i};if(i.num_pins===5)return{circuitJson:KEn(i),parameters:i};throw new Error("Invalid number of pins for SOT89")},QEn=Ee({fn:N(),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:Ie().optional(),string:N().optional()}),JEn=n=>{const e=QEn.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},(I,A)=>{const R=c%2===0?(A-c/2+.5)*m:(A-Math.floor(c/2))*m;return ka(A+1,R,l,i,r)}),y={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:""}],S=Uo(0,s/2+.6,.5);return{circuitJson:[..._,y,b,...w,S],parameters:{...e,p:m}}},eTn=Ee({fn:N(),num_pins:me(2).default(2),w:N().default("5.40mm"),h:N().default("2.30mm"),pl:N().default("1.30mm"),pw:N().default("1.70mm"),p:N().default("3.5mm")}),tTn=n=>{const e=eTn.parse(n),t=Uo(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:iTn(e).concat(i,t),parameters:e}},nTn=n=>{const{pn:e,p:t}=n;return e===1?{x:-t/2,y:0}:{x:t/2,y:0}},iTn=n=>{const e=[];for(let t=1;t<=n.num_pins;t++){const{x:i,y:r}=nTn({pn:t,p:Number.parseFloat(n.p)});e.push(zr(t,i,r,Number.parseFloat(n.pl),Number.parseFloat(n.pw)))}return e},rTn=Ee({fn:N(),num_pins:me(2).default(2),w:N().default("1.90mm"),h:N().default("1.33mm"),pl:N().default("0.5mm"),pw:N().default("0.7mm"),p:N().default("0.8mm")}),oTn=n=>{const e=rTn.parse(n),t=Uo(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:aTn(e).concat(i,t),parameters:e}},sTn=n=>{const{pn:e,p:t}=n;return e===1?{x:-t/2,y:0}:{x:t/2,y:0}},aTn=n=>{const e=[];for(let t=1;t<=n.num_pins;t++){const{x:i,y:r}=sTn({pn:t,p:Number.parseFloat(n.p)});e.push(zr(t,i,r,Number.parseFloat(n.pl),Number.parseFloat(n.pw)))}return e},cTn=Ee({fn:N(),num_pins:me(2).default(2),w:N().default("7.0mm"),h:N().default("3.35mm"),pl:N().default("1.50mm"),pw:N().default("2.70mm"),p:N().default("4.8mm")}),lTn=n=>{const e=cTn.parse(n),t=Uo(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:dTn(e).concat(i,t),parameters:e}},uTn=n=>{const{pn:e,p:t}=n;return e===1?{x:-t/2,y:0}:{x:t/2,y:0}},dTn=n=>{const e=[];for(let t=1;t<=n.num_pins;t++){const{x:i,y:r}=uTn({pn:t,p:Number.parseFloat(n.p)});e.push(zr(t,i,r,Number.parseFloat(n.pl),Number.parseFloat(n.pw)))}return e},hTn=Ee({fn:N(),num_pins:me(2).default(2),w:N().default("3.0mm"),h:N().default("1.80mm"),pl:N().default("0.80mm"),pw:N().default("1.20mm"),p:N().default("1.6mm")}),pTn=n=>{const e=hTn.parse(n),t=Uo(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:mTn(e).concat(i,t),parameters:e}},fTn=n=>{const{pn:e,p:t}=n;return e===1?{x:-t/2,y:0}:{x:t/2,y:0}},mTn=n=>{const e=[];for(let t=1;t<=n.num_pins;t++){const{x:i,y:r}=fTn({pn:t,p:Number.parseFloat(n.p)});e.push(zr(t,i,r,Number.parseFloat(n.pl),Number.parseFloat(n.pw)))}return e},_Tn=Ee({fn:N(),num_pins:me(2).default(2),w:N().default("7.10mm"),h:N().default("3.40mm"),pl:N().default("2.45mm"),pw:N().default("1.80mm"),p:N().default("4.05mm")}),yTn=n=>{const e=_Tn.parse(n),t=Uo(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:xTn(e).concat(i,t),parameters:e}},gTn=n=>{const{pn:e,p:t}=n;return e===1?{x:-t/2,y:0}:{x:t/2,y:0}},xTn=n=>{const e=[];for(let t=1;t<=n.num_pins;t++){const{x:i,y:r}=gTn({pn:t,p:Number.parseFloat(n.p)});e.push(zr(t,i,r,Number.parseFloat(n.pl),Number.parseFloat(n.pw)))}return e},bTn=Ee({fn:N(),num_pins:me(2).default(2),w:N().default("4.80mm"),h:N().default("2.10mm"),pl:N().default("1.30mm"),pw:N().default("1.40mm"),p:N().default("2.9mm")}),vTn=n=>{const e=bTn.parse(n),t=Uo(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:STn(e).concat(i,t),parameters:e}},wTn=n=>{const{pn:e,p:t}=n;return e===1?{x:-t/2,y:0}:{x:t/2,y:0}},STn=n=>{const e=[];for(let t=1;t<=n.num_pins;t++){const{x:i,y:r}=wTn({pn:t,p:Number.parseFloat(n.p)});e.push(zr(t,i,r,Number.parseFloat(n.pl),Number.parseFloat(n.pw)))}return e},ETn=Ee({fn:N(),num_pins:me(2).default(2),w:N().default("7.30mm"),h:N().default("4.40mm"),pl:N().default("2.50mm"),pw:N().default("2.30mm"),p:N().default("4.30mm")}),TTn=n=>{const e=ETn.parse(n),t=Uo(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:CTn(e).concat(i,t),parameters:e}},MTn=n=>{const{pn:e,p:t}=n;return e===1?{x:-t/2,y:0}:{x:t/2,y:0}},CTn=n=>{const e=[];for(let t=1;t<=n.num_pins;t++){const{x:i,y:r}=MTn({pn:t,p:Number.parseFloat(n.p)});e.push(zr(t,i,r,Number.parseFloat(n.pl),Number.parseFloat(n.pw)))}return e},ATn=Ee({fn:N(),num_pins:me(2).default(2),w:N().default("10.70mm"),h:N().default("6.60mm"),pl:N().default("3.30mm"),pw:N().default("2.50mm"),p:N().default("6.80mm")}),PTn=n=>{const e=ATn.parse(n),t=Uo(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:ITn(e).concat(i,t),parameters:e}},RTn=n=>{const{pn:e,p:t}=n;return e===1?{x:-t/2,y:0}:{x:t/2,y:0}},ITn=n=>{const e=[];for(let t=1;t<=n.num_pins;t++){const{x:i,y:r}=RTn({pn:t,p:Number.parseFloat(n.p)});e.push(zr(t,i,r,Number.parseFloat(n.pl),Number.parseFloat(n.pw)))}return e},NTn=Ee({fn:N(),num_pins:Ie().default(4),w:N().default("8.50mm"),h:N().default("6.90mm"),pl:N().default("2mm"),pw:N().default("1.5mm"),p:N().default("2.30mm"),string:N().optional()}),kTn=n=>{const e=n.string?.match(/^sot223_(\d+)/),t=e?Number.parseInt(e[1],10):4;if(t===8){const r=DTn.parse({...n,num_pins:t});return{circuitJson:Z5(r),parameters:r}}const i=NTn.parse({...n,num_pins:t});if(i.num_pins===4)return{circuitJson:LTn(i),parameters:i};if(i.num_pins===5)return{circuitJson:$Tn(i),parameters:i};if(i.num_pins===6)return{circuitJson:UTn(i),parameters:i};throw new Error("Invalid number of pins")},OTn=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}},LTn=n=>{const e=[];for(let a=0;a<n.num_pins;a++){const{x:c,y:l}=OTn({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=Uo(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]},DTn=rE({p:"0.90mm",w:"2.8mm",legsoutside:!0}),zTn=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")},$Tn=n=>{const e=[];for(let a=1;a<=n.num_pins;a++){const{x:c,y:l}=zTn({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=Uo(0,0,.3);return[...e,r,o,s]},FTn=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")},UTn=n=>{const e=[];for(let a=1;a<=n.num_pins;a++){const{x:c,y:l}=FTn({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=Uo(0,0,.3);return[...e,r,o,s]},BTn=Ee({fn:N(),num_pins:Ie().default(3),w:N().default("3.40mm"),h:N().default("3.30mm"),pl:N().default("1mm"),pw:N().default("0.7mm"),p:N().default("1.2mm"),string:N().optional()}),jTn=n=>{const e=n.string?.match(/^sot23w_(\d+)/),t=e?Number.parseInt(e[1],3):3,i=BTn.parse({...n,num_pins:t});if(i.num_pins===3)return{circuitJson:VTn(i),parameters:i};throw new Error("Invalid number of pins")},HTn=n=>{const{pn:e,p:t}=n;return e===1?{x:-t,y:.95}:e===2?{x:-t,y:-.95}:{x:t,y:0}},VTn=n=>{const e=[];for(let a=0;a<n.num_pins;a++){const{x:c,y:l}=HTn({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=Uo(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]},GTn=Ee({fn:N(),num_pins:Bn([me(3),me(2)]).default(3),p:N().default("1.27mm"),id:N().default("0.72mm"),od:N().default("0.95mm"),w:N().default("2.5mm"),h:N().default("4.2mm"),string:N().optional()}),YTn=n=>{const{p:e,id:t,od:i,w:r,h:o}=n,s=Number.parseFloat(o)/2,a=Number.parseFloat(e);return[ka(1,-a,s-a,t,i),ka(2,0,s-a,t,i),ka(3,a,s-a,t,i)]},qTn=n=>{const{p:e,id:t,od:i,h:r}=n,o=Number.parseFloat(r)/2,s=Number.parseFloat(e);return[ka(1,-s,o-s,t,i),ka(2,s,o-s,t,i)]},XTn=n=>{const e=n.string?.match(/^to92s_(\d+)/),t=e?Number.parseInt(e[1],10):3,i=GTn.parse({...n,num_pins:t});let r=[];if(i.num_pins===3)r=YTn(i);else if(i.num_pins===2)r=qTn(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=Uo(0,o+1,.5);return{circuitJson:[...r,a,c],parameters:i}},WTn=Ee({fn:N(),p:_t.optional(),id:_t.optional(),pw:_t.optional(),pl:_t.optional(),w:_t.optional(),h:_t.optional(),sh:Bn([Je(),N(),Ie()]).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:N().optional()}),KTn={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 ZTn(n){return n.sh?"sh":(n.ph,"ph")}function QTn(n,e,t,i,r,o){const s=[];if(n==="ph"){const a=t/2;s.push(DV(1,-a,2,i,r,o)),s.push(DV(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 JTn(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 e5n=n=>{const e=WTn.parse(n),t=ZTn(e),i=KTn[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 y=parseInt(_[1],10);Number.isNaN(y)||(u=y)}else typeof e.sh=="number"&&(u=e.sh)}const d=QTn(t,u,r,o,s,a),h=JTn(t),p=Uo(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"}}},t5n=Ee({fn:N(),num_pins:me(2).default(2),w:N().default("3.30mm"),h:N().default("1.70mm"),pl:N().default("0.80mm"),pw:N().default("1mm"),p:N().default("1.90mm")}),n5n=n=>{const e=t5n.parse(n),t=Uo(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:r5n(e).concat(i,t),parameters:e}},i5n=n=>{const{pn:e,p:t}=n;return e===1?{x:-t/2,y:0}:{x:t/2,y:0}},r5n=n=>{const e=[];for(let t=1;t<=n.num_pins;t++){const{x:i,y:r}=i5n({pn:t,p:Number.parseFloat(n.p)});e.push(zr(t,i,r,Number.parseFloat(n.pl),Number.parseFloat(n.pw)))}return e},o5n=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"}}},s5n=Ee({fn:N(),num_pins:Bn([me(8),me(10)]).default(8),w:N().optional(),h:N().optional(),p:N().optional(),pl:N().optional(),pw:N().optional(),string:N().optional()}),a5n=n=>{const e=s5n.parse(n),t=o5n(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:S}=Ntt(e.num_pins,b+1,i,o),I=b<l?b+1:e.num_pins-(b-l);c.push(zr(I,w,S,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=Ntt(e.num_pins,1,u,o),_={x:m.x-.8,y:m.y},y={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=Uo(0,d/2+.5,.3);return{circuitJson:[...c,h,p,x,y],parameters:e}},Ntt=(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}},c5n=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"}}},l5n=Ee({fn:N(),num_pins:Bn([me(8),me(10),me(12),me(16)]).default(8),w:N().optional(),h:N().optional(),p:N().optional(),pl:N().optional(),pw:N().optional(),string:N().optional()}),ktt=(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}},u5n=n=>{const e=l5n.parse(n),t=c5n(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}=ktt(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=ktt(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"},y=Uo(0,u/2+.5,.3);return{circuitJson:[...c,d,h,y,_],parameters:e}},d5n=Ee({fn:N(),num_pins:me(2).default(2),w:N().default("3.8mm"),h:N().default("1.65mm"),pl:N().default("1.2mm"),pw:N().default("1.2mm"),pad_spacing:N().default("2.6mm")}),h5n=n=>{const e=d5n.parse(n),t=Uo(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:f5n(e).concat(i,t),parameters:e}},p5n=n=>{const{pn:e,pad_spacing:t}=n;return e===1?{x:-t/2,y:0}:{x:t/2,y:0}},f5n=n=>{const e=[];for(let t=1;t<=n.num_pins;t++){const{x:i,y:r}=p5n({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},m5n=Ee({fn:N(),num_pins:me(2).default(2),w:N().default("3.20mm"),h:N().default("1.65mm"),pl:N().default("0.8mm"),pw:N().default("0.9mm"),pad_spacing:N().default("2.1mm")}),_5n=n=>{const e=m5n.parse(n),t=Uo(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:g5n(e).concat(i,t),parameters:e}},y5n=n=>{const{pn:e,pad_spacing:t}=n;return e===1?{x:-t/2,y:0}:{x:t/2,y:0}},g5n=n=>{const e=[];for(let t=1;t<=n.num_pins;t++){const{x:i,y:r}=y5n({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},x5n=Ee({fn:N(),num_pins:Bn([me(6),me(8)]).default(8),w:N().default("3mm"),h:N().default("3mm"),p:N().default("0.5mm"),pl:N().default("0.52mm"),pw:N().default("0.35mm"),epw:N().default("1.40mm"),eph:N().default("1.60mm"),string:N().optional(),ep:Je().default(!1)}),b5n=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=x5n.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 S=0;S<i.num_pins;S++){const{x:I,y:A}=Ott(i.num_pins,S+1,r,s);d.push(zr(S+1,I,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:""},y=Ott(i.num_pins,1,h,s),x={x:y.x-.4,y:y.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=Uo(0,p/2+.5,.3);return{circuitJson:[...d,m,_,w,b],parameters:i}},Ott=(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}},v5n=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 S=0;S<e;S++)u.push(zr(S+1,S*s,0,a,c));let d=[];if(t){const S=t.split("").map(Number);if(S.length>1)for(let I=0;I<S.length-1;I++){const A=S[I],R=S[I+1];if(typeof A=="number"&&typeof R=="number"&&!isNaN(A)&&!isNaN(R)){const M=(A-1)*s,k=(R-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${R}}`,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,y={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=Uo(m,b,.4);return{circuitJson:[...u,...d,y,w],parameters:n}},Ltt={fn:me("sot457"),num_pins:me(6).default(6),pillh:N().default("0.45mm"),pillw:N().default("1.45mm"),pl:N(),pw:N(),p:N(),wave:Je().optional(),reflow:Je().optional()},w5n=Ee({...Ltt,h:N().default("2.5mm"),w:N().default("2.7mm"),pl:N().default("0.8mm"),pw:N().default("0.55mm"),p:N().default("0.95mm")}),S5n=Ee({...Ltt,h:N().default("3mm"),w:N().default("4mm"),pillr:N().default("0.225mm"),pl:N().default("1.45mm"),pw:N().default("1.5mm"),p:N().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)})),Q5=n=>Number.parseFloat(n.replace("mm","")),Dtt=({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},ztt=n=>{const e=[],t=Q5(n.p),i=Q5(n.pl),r=Q5(n.pw),o=Q5(n.w),s=Q5(n.h);if(n.wave){const m={1:({padWidth:_,padHeight:y})=>zr(1,-t,t,y,_),2:({padWidth:_,padHeight:y})=>zr(2,-t,-t,y,_),3:({padWidth:_,padHeight:y})=>LV(3,-t,0,Q5(n.pillw),Q5(n.pillh)),4:({padWidth:_,padHeight:y})=>LV(4,t,0,Q5(n.pillw),Q5(n.pillh)),5:({padWidth:_,padHeight:y})=>zr(5,t,t,y,_),6:({padWidth:_,padHeight:y})=>zr(6,t,-t,y,_)};for(let _=1;_<=n.num_pins;_++){const y=m[_];y&&e.push(y({padWidth:i,padHeight:r}))}}else for(let m=1;m<=n.num_pins;m++){const{x:_,y}=Dtt({pitch:t,width:o,pinNumber:m});e.push(zr(m,_,y,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=Uo(0,s+.5,.3),u=Dtt({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]},E5n=n=>{if(n.wave){const t=S5n.parse({...n,fn:"sot457"});return{circuitJson:ztt(t),parameters:t}}const e=w5n.parse(n);return{circuitJson:ztt(e),parameters:e}},T5n=Ee({fn:N(),num_pins:Bn([me(3),me(2)]).default(3),p:N().default("3.8mm"),id:N().default("1.25mm"),od:N().default("2.35mm"),ca:N().default("14mm").describe("Caliper axis (width or diameter of the potentiometer body or adjustment knob)"),w:N().default("5.35mm"),h:N().default("4mm"),string:N().optional()}),M5n=n=>{const{p:e,id:t,od:i,h:r,ca:o}=n,s=Number.parseFloat(r),a=Number.parseFloat(o);return[ka(1,0,a/4+.3,t,i),ka(2,s,0,t,i),ka(3,0,-a/4-.3,t,i)]},C5n=n=>{const e=n.string?.match(/^potentiometer_(\d+)/),t=e?Number.parseInt(e[1],10):3,i=T5n.parse({...n,num_pins:t});let r=[];i.num_pins===3&&(r=M5n(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=Uo(u,o+1,.5);return{circuitJson:[...r,c,l,d],parameters:i}},A5n=Ee({fn:N(),p:_t.optional().default("7.5mm"),id:_t.optional().default("1mm"),od:_t.optional().default("2mm"),d:_t.optional().default("10.5mm")}),P5n=(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}},R5n=n=>{const e=A5n.parse(n),{p:t,id:i,od:r,d:o}=e,s=[ka(1,-t/2,0,i,r),ka(2,t/2,0,i,r)],{topArc:a,bottomArc:c}=P5n(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:""},y={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=Uo(0,o/2+1,.5);return{circuitJson:[...s,l,u,d,_,y,x],parameters:e}},I5n=Ee({fn:N(),num_pins:me(2).default(2),w:N().default("6.5mm"),h:N().default("3mm"),pl:N().default("1.75mm"),pw:N().default("2.40mm"),p:N().default("4.75mm")}),N5n=n=>{const e=I5n.parse(n),t=Uo(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:O5n(e).concat(i,t),parameters:e}},k5n=n=>{const{pn:e,p:t}=n;return e===1?{x:-t/2,y:0}:{x:t/2,y:0}},O5n=n=>{const e=[];for(let t=1;t<=n.num_pins;t++){const{x:i,y:r}=k5n({pn:t,p:Number.parseFloat(n.p)});e.push(zr(t,i,r,Number.parseFloat(n.pl),Number.parseFloat(n.pw)))}return e},L5n=Ee({fn:N(),num_pins:Ie().default(3),w:N().default("2.45mm"),h:N().default("2.40mm"),pl:N().default("0.45mm"),pw:N().default("0.70mm"),p:N().default("1mm"),string:N().optional()}),D5n=n=>{const e=n.string?.match(/^sot323_(\d+)/),t=e?Number.parseInt(e[1],3):3,i=L5n.parse({...n,num_pins:t});if(i.num_pins===3)return{circuitJson:$5n(i),parameters:i};throw new Error("Invalid number of pins")},z5n=n=>{const{pn:e,p:t}=n;return e===1?{x:-t,y:.65}:e===2?{x:-t,y:-.65}:{x:t,y:0}},$5n=n=>{const e=[];for(let a=0;a<n.num_pins;a++){const{x:c,y:l}=z5n({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=Uo(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]},F5n=Ee({fn:N(),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:N().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=xh(n.r):n.pr!==void 0?t=xh(n.pr):n.radius!==void 0?t=xh(n.radius):n.d!==void 0?t=xh(n.d)/2:n.pd!==void 0?t=xh(n.pd)/2:n.diameter!==void 0?t=xh(n.diameter)/2:t=xh("1mm")/2:(n.w!==void 0?i=xh(n.w):n.pw!==void 0?i=xh(n.pw):n.width!==void 0?i=xh(n.width):n.s!==void 0?i=xh(n.s):n.size!==void 0?i=xh(n.size):i=xh("1mm"),n.h!==void 0?r=xh(n.h):n.ph!==void 0?r=xh(n.ph):n.height!==void 0?r=xh(n.height):e==="square"||e==="rect"?r=i:r=xh("1mm")),{fn:n.fn,shape:e,radius:t,width:i,height:r}}),U5n=n=>{const e=F5n.parse(n),{shape:t,radius:i,width:r,height:o}=e;let s,a;return t==="circle"?(s=btt(1,{x:0,y:0,radius:i}),a=i+.5):t==="pill"?(s=LV(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,Uo(0,a,.2)],parameters:e}},B5n=Ee({fn:N(),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=xh(n.d):n.hd!==void 0?e=xh(n.hd):n.r!==void 0?e=xh(n.r)*2:n.hr!==void 0?e=xh(n.hr)*2:e=xh("1mm");let t;return n.pd!==void 0?t=xh(n.pd):n.pr!==void 0?t=xh(n.pr)*2:t=e*(1.5/1),{fn:n.fn,d:e,pd:t,squarepad:n.squarepad??!1}}),j5n=n=>{const e=B5n.parse(n),{d:t,pd:i,squarepad:r}=e;return{circuitJson:[r?DV(1,0,0,t,i,i):ka(1,0,0,t,i),Uo(0,i/2+.5,.2)],parameters:e}},H5n=Ee({fn:N(),num_pins:me(6).default(6),h:N().default("1.6mm"),pl:N().default("1mm"),pw:N().default("0.7mm"),p:N().default("0.95mm")}),V5n=n=>{const e=H5n.parse(n);return{circuitJson:G5n(e),parameters:e}},$tt=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")},G5n=n=>{const e=[];for(let d=1;d<=n.num_pins;d++){const{x:h,y:p}=$tt({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=Uo(0,i+.3,.3),a=$tt({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]},Y5n=Ee({fn:N()}),q5n=n=>{const e=Y5n.parse(n),t=[],i=.5-.15,r=1.5,s=.5/2,a=75,c=-37/2;for(let R=0;R<a;R++){const M=R+1;if(M>=24&&M<=31)continue;const k=c-R*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,y=-1/0,x=1/0,b=-1/0;const w=(R,M,k=0,C=0)=>{_=Math.min(_,R-k/2),y=Math.max(y,R+k/2),x=Math.min(x,M-C/2),b=Math.max(b,M+C/2)};for(const R of t)w(R.x,R.y,R.width,R.height);w(h.center.x,h.center.y,h.width,h.height);for(const R of m.route)w(R.x,R.y);const S=(_+y)/2,I=(x+b)/2,A=R=>{typeof R.x=="number"&&(R.x-=S),typeof R.y=="number"&&(R.y-=I),R.center&&(R.center.x-=S,R.center.y-=I),Array.isArray(R.route)&&(R.route=R.route.map(M=>({x:M.x-S,y:M.y-I})))};for(const R of t)A(R);return A(h),A(m),{circuitJson:[...t,h,m],parameters:e}};function X5n(n){return n!=null}var W5n=(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,y=d-p/2,x=d+p/2;i=Math.min(i,m),r=Math.max(r,_),o=Math.min(o,y),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},K5n=n=>{let e=UV();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(X5n);for(const{fn:r,v:o}of i)e=e[r](o);return e.setString(n),e},Z5n=()=>Object.keys(K5),UV=()=>{const n=new Proxy({},{get:(e,t)=>{if(t==="soup"||t==="circuitJson"){if("fn"in e&&K5[e.fn])return()=>{const{circuitJson:i}=K5[e.fn](e);return W5n(i,e.origin)};if(!K5[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(!K5[e.fn])throw new Error(`Invalid footprint function, got "${e.fn}"${e.string?`, from string "${e.string}"`:""}`);return()=>K5[e.fn](e).parameters}return t==="getFootprintNames"?()=>Object.keys(K5):t==="params"?()=>e:t==="setString"?i=>(e.string=i,n):i=>(Object.keys(e).length===0?`${t}${i}`in K5?(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};UV.string=K5n,UV.getFootprintNames=Z5n;var Q5n=UV,Ftt=Symbol("Fragment");function wge(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 ea=Symbol("Cuboid"),Utt=Symbol("Cube"),J5=Symbol("Cylinder"),Btt=Symbol("Sphere"),Sge=Symbol("RoundedCuboid"),Qb=Symbol("Translate"),fI=Symbol("Rotate"),BV=Symbol("Union"),jV=Symbol("Subtract"),S4=Symbol("Hull"),mT=Symbol("Colorize"),ML=Symbol("Polygon"),CL=Symbol("ExtrudeLinear"),Ty=Ftt,Yn=(n,e,t)=>wge(n,e),Zd=(n,e,t)=>wge(n,e),mI=({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(mT,{color:"#555",children:Yn(Qb,{offset:n,children:Yn(Qb,{offset:{x:0,y:0,z:r},children:Zd(jV,{children:[Zd(BV,{children:[Zd(S4,{children:[Yn(Qb,{z:.005,children:Yn(ea,{size:[c,l,.01]})}),Yn(Qb,{z:o,children:Yn(ea,{size:[e,t,.01]})})]}),Zd(S4,{children:[Yn(Qb,{z:o,children:Yn(ea,{size:[e,t,.01]})}),Yn(Qb,{z:o+s,children:Yn(ea,{size:[c,l,.01]})})]})]}),Yn(Qb,{offset:{x:0,y:d,z:i},children:Yn(fI,{rotation:[0,0,0],children:Yn(J5,{radius:h,height:p})})})]})})})})},J5n=n=>Array.from({length:n},(e,t)=>t);function Ege(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),y=m.x+_.x,x=m.y+_.y,b=Math.sqrt(y*y+x*x);if(b/2>2*i)a(h,m,1),a(h,_,1),a(h,m,-1),a(h,_,-1);else{const S=1/b;a(h,{x:y*S,y:x*S},1),a(h,{x:y*S,y:x*S},-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 e3n=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}))},t3n=e3n([{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}]),jtt=5.47,HV=.5,n3n=({x:n,y:e,z:t})=>{const i=n>0;return Zd(Ty,{children:[Yn(Qb,{offset:{x:n+.25/2,y:e,z:t},children:Yn(fI,{rotation:["-90deg",0,"90deg"],children:Yn(CL,{height:.25,children:Yn(ML,{points:t3n.map(r=>[r.x,r.y])})})})}),Yn(Qb,{offset:{x:n,y:e+(i?1:-1),z:t},children:Yn(fI,{rotation:["-90deg","90deg",i?"180deg":"0deg"],children:Yn(CL,{height:2,children:Yn(ML,{points:Ege([[0,0],[-1,0],[-1,-1]],.25).map(r=>[r.x,r.y])})})})})]})},i3n=({numPins:n=8,pitch:e=2.54,bodyWidth:t=6.4})=>{const i=Math.floor(n/2),r=t+1;return Zd(Ty,{children:[J5n(n).map(o=>{const s=o%i,a=(Math.floor(o/i)-.5)*2;return Yn(n3n,{x:a*r/2,y:s*e-(i-1)/2*e,z:jtt/2+HV})}),Yn(mI,{width:t,length:i*e+.5,height:jtt-HV,heightAboveSurface:HV,center:{x:0,y:0,z:HV}})]})};function r3n(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 Nv=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,r3n(u,n)]),l=Ege(c,e);return Yn(mT,{color:"#fff",children:Yn(Qb,{offset:{z:0,y:0,x:0,...n.position},children:Yn(fI,{rotation:["90deg",0,s??0],children:Yn(Qb,{offset:{x:0,y:0,z:-t/2},children:Yn(CL,{height:t,children:Yn(ML,{points:l.map(u=>[u.x,u.y])})})})})})})},o3n=({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 Zd(Ty,{children:[Array.from({length:o}).map((l,u)=>Yn(Nv,{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(Nv,{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(mI,{center:{x:0,y:0,z:c/2},width:r-t-1,length:s,height:1.5})]})},Tge=1,Mge=.5,_I=.5,AL=.2,s3n=Tge-AL*2,Htt=({color:n="#333"})=>Zd(Ty,{children:[Yn(ea,{size:[s3n,Mge,_I],offset:[0,0,_I/2],color:n}),Yn(ea,{size:[AL,_I,Mge],offset:[Tge/2-AL/2,0,_I/2],color:"#ccc"}),Yn(ea,{size:[AL,_I,Mge],offset:[-Tge/2+AL/2,0,_I/2],color:"#ccc"})]}),Cge=1.6,a3n=Cge-.3*2,VV=.3,Age=.85,yI=.6,Vtt=({color:n="#333"})=>Zd(Ty,{children:[Yn(ea,{size:[a3n,Age,yI],offset:[0,0,yI/2],color:n}),Yn(ea,{size:[VV,Age,yI],offset:[Cge/2-VV/2,0,yI/2],color:"#ccc"}),Yn(ea,{size:[VV,Age,yI],offset:[-Cge/2+VV/2,0,yI/2],color:"#ccc"})]}),Pge=2,Rge=1.25,gI=.55,PL=.5,c3n=Pge-PL*2,Gtt=({color:n="#333"})=>Zd(Ty,{children:[Yn(ea,{size:[c3n,Rge,gI],offset:[0,0,gI/2],color:n}),Yn(ea,{size:[PL,Rge,gI],offset:[Pge/2-PL/2,0,gI/2],color:"#ccc"}),Yn(ea,{size:[PL,Rge,gI],offset:[-Pge/2+PL/2,0,gI/2],color:"#ccc"})]}),l3n=({pinCount:n,pitch:e,leadWidth:t,padContactLength:i,bodyWidth:r})=>{const o=n/4;e||(e=u3n(n,r)),i||(i=d3n(n)),t||(t=h3n(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 Zd(Ty,{children:[Array.from({length:o}).map((p,m)=>Yn(Nv,{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(Nv,{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(Nv,{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(Nv,{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(mI,{center:{x:0,y:0,z:d/2},width:r,length:s,height:1.5})]})},u3n=(n,e)=>{switch(n){case 44:case 64:return .8;case 52:return e===14?1:.65;case 208:return .5;default:return .5}},d3n=n=>{switch(n){case 44:case 52:case 64:return 2.25;case 208:return 1.65;default:return 1}},h3n=(n,e)=>{switch(n){case 44:case 64:return .5;case 52:return e===14?.45:.55;case 208:return .3;default:return .25}},p3n=({numberOfPins:n,pitch:e=2.54,longSidePinLength:t=6})=>{const o=n*e,s=3,a=-((n-1)/2)*e;return Zd(Ty,{children:[Yn(ea,{color:"#222",size:[o,.63*3,2],center:[0,0,2/2]}),Array.from({length:n},(c,l)=>Zd(Ty,{children:[Yn(mT,{color:"gold",children:Zd(S4,{children:[Yn(ea,{color:"gold",size:[.63,.63,s*.9],center:[a+l*e,0,2*.9+2/2]}),Yn(ea,{color:"gold",size:[.63/1.8,.63/1.8,s],center:[a+l*e,0,2+2/2]})]})}),Yn(mT,{color:"gold",children:Zd(S4,{children:[Yn(ea,{color:"gold",size:[.63,.63,t*.9],center:[a+l*e,0,-t/2*.9]}),Yn(ea,{color:"gold",size:[.63/1.8,.63/1.8,t],center:[a+l*e,0,-t/2]})]})})]}))]})},f3n=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")}},m3n=({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},_3n=({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=m3n({num_pins:n,cw:!0,ccw:!0}),u=[];for(let d=0;d<n;d++){const{x:h,y:p,o:m}=f3n({pin_count:n,pn:d+1,w:e,h:t,p:a,pl:s});let _=o,y=s;m==="vert"&&([_,y]=[y,_]);const x=l[d+1];u.push({pn:x,x:h,y:p,pw:_,pl:y})}return Zd(Ty,{children:[Yn(mT,{color:"grey",children:Yn(ea,{center:{x:0,y:0,z:i/2},size:[e,t,i]})}),u.map((d,h)=>Yn(ea,{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(ea,{center:{x:0,y:0,z:c/2},size:[r.width,r.length,c]})]})},y3n=_3n,g3n=()=>{const c=1.1999999999999997;return Zd(Ty,{children:[Yn(Nv,{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(Nv,{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(Nv,{position:{x:-2.8/2-c/4,y:0,z:.15/2},width:.4,thickness:.15,padContactLength:.5,bodyDistance:c,height:.95}),Yn(Nv,{position:{x:-2.8/2-c/4,y:-1,z:.15/2},width:.4,thickness:.15,padContactLength:.5,bodyDistance:c,height:.95}),Yn(Nv,{position:{x:-2.8/2-c/4,y:1,z:.15/2},width:.4,thickness:.15,padContactLength:.5,bodyDistance:c,height:.95}),Yn(mI,{center:{x:0,y:0,z:0},width:1.6,length:2.9,height:1.2})]})},x3n=g3n,Ige=.6,Nge=.3,xI=.33,RL=.1,b3n=Ige-RL*2,Ytt=({color:n="#333"})=>Zd(Ty,{children:[Yn(ea,{size:[b3n,Nge,xI],offset:[0,0,xI/2],color:n}),Yn(ea,{size:[RL,Nge,xI],offset:[Ige/2-RL/2,0,xI/2],color:"#ccc"}),Yn(ea,{size:[RL,Nge,xI],offset:[-Ige/2+RL/2,0,xI/2],color:"#ccc"})]}),kge=.4,Oge=.2,bI=.13,IL=.07,v3n=kge-IL*2,qtt=({color:n="#333"})=>Zd(Ty,{children:[Yn(ea,{size:[v3n,Oge,bI],offset:[0,0,bI/2],color:n}),Yn(ea,{size:[IL,Oge,bI],offset:[kge/2-IL/2,0,bI/2],color:"#ccc"}),Yn(ea,{size:[IL,Oge,bI],offset:[-kge/2+IL/2,0,bI/2],color:"#ccc"})]}),Lge=3.2,Dge=1.6,vI=.9,NL=.5,w3n=Lge-NL*2,Xtt=({color:n="#333"})=>Zd(Ty,{children:[Yn(ea,{size:[w3n,Dge,vI],offset:[0,0,vI/2],color:n}),Yn(ea,{size:[NL,Dge,vI],offset:[Lge/2-NL/2,0,vI/2],color:"#ccc"}),Yn(ea,{size:[NL,Dge,vI],offset:[-Lge/2+NL/2,0,vI/2],color:"#ccc"})]}),zge=3.2,$ge=2.5,wI=1,kL=.6,S3n=zge-kL*2,Wtt=({color:n="#333"})=>Zd(Ty,{children:[Yn(ea,{size:[S3n,$ge,wI],offset:[0,0,wI/2],color:n}),Yn(ea,{size:[kL,$ge,wI],offset:[zge/2-kL/2,0,wI/2],color:"#ccc"}),Yn(ea,{size:[kL,$ge,wI],offset:[-zge/2+kL/2,0,wI/2],color:"#ccc"})]}),Fge=5,Uge=2.5,SI=1.4,OL=.6,E3n=Fge-OL*2,Ktt=({color:n="#333"})=>Zd(Ty,{children:[Yn(ea,{size:[E3n,Uge,SI],offset:[0,0,SI/2],color:n}),Yn(ea,{size:[OL,Uge,SI],offset:[Fge/2-OL/2,0,SI/2],color:"#ccc"}),Yn(ea,{size:[OL,Uge,SI],offset:[-Fge/2+OL/2,0,SI/2],color:"#ccc"})]}),Bge=6.3,jge=3.2,EI=1.8,LL=.8,T3n=Bge-LL*2,Ztt=({color:n="#333"})=>Zd(Ty,{children:[Yn(ea,{size:[T3n,jge,EI],offset:[0,0,EI/2],color:n}),Yn(ea,{size:[LL,jge,EI],offset:[Bge/2-LL/2,0,EI/2],color:"#ccc"}),Yn(ea,{size:[LL,jge,EI],offset:[-Bge/2+LL/2,0,EI/2],color:"#ccc"})]}),M3n=({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(mT,{color:"#1a1a1a",children:Zd(jV,{children:[Yn(ea,{color:"#000",size:[c,s,a],center:[0,0,a/2]}),Array.from({length:n},(h,p)=>r?Yn(J5,{height:a+.1,radius:r/2,center:[u+p*e,0,a/2],color:"#222"},p):Yn(ea,{size:[l,l,a],center:[u+p*e,0,a/2]},p))]})});return Zd(Ty,{children:[d,Array.from({length:n},(h,p)=>Zd(mT,{color:"silver",children:[Zd(S4,{children:[Yn(ea,{color:"silver",size:[o,o,t*.9],center:[u+p*e,0,-t/2*.9]}),Yn(ea,{color:"silver",size:[o/1.8,o/1.8,t],center:[u+p*e,0,-t/2]})]}),Yn(ea,{color:"silver",size:[l,l,l*.5],center:[u+p*e,0,l/2*.5]})]},p))]})},C3n=({width:n,length:e,innerDiameter:t=1})=>{const i=n,r=e,o=n*.7,s=t/2.5;return Zd(Ty,{children:[Yn(Sge,{color:"#1a1a1f",center:[0,0,o/2],size:[r,r,o],roundRadius:.3}),Yn(Sge,{color:"#f2f2f2",center:[0,0,o+o*.1/2.5],size:[r,r,o*.1],roundRadius:.14}),Yn(J5,{color:"#1a1a1f",height:o*.8,radius:i/3,center:[0,0,o+o*.8/2]}),Yn(J5,{color:"#1a1a1f",height:o*.2,radius:t/2,center:[r/3,r/3,o+o*.1/2]}),Yn(J5,{color:"#1a1a1f",height:o*.2,radius:t/2,center:[-r/3,-r/3,o+o*.1/2]}),Yn(J5,{color:"#1a1a1f",height:o*.2,radius:t/2,center:[-r/3,r/3,o+o*.1/2]}),Yn(J5,{color:"#1a1a1f",height:o*.2,radius:t/2,center:[r/3,-r/3,o+o*.1/2]}),Yn(GV,{thickness:t/3,width:s,horizontalLength:r*.8,verticalLength:o/2,position:{x:-i/2,y:-r/2,z:-o*1.2}}),Yn(GV,{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(GV,{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(GV,{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}})]})},GV=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=Ege(a,e);return Yn(mT,{color:"#f2f2f2",children:Yn(Qb,{offset:{x:s?.x||0,y:s?.y||0,z:s?.z||0},children:Yn(fI,{rotation:[0,55,o],children:Yn(CL,{height:t,children:Yn(ML,{points:c.map(l=>[l.y,l.x])})})})})})},A3n=({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 Zd(Ty,{children:[Array.from({length:o}).map((p,m)=>Yn(Nv,{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(Nv,{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(mI,{center:{x:0,y:0,z:a/2},width:h,length:d,height:c})]})},P3n=({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,y=(_-l)/2,x=y*.5;return Zd(Ty,{children:[Array.from({length:d}).map((b,w)=>Yn(Nv,{position:{x:-_/2,y:h-w*a,z:p/2},width:c,thickness:p,padContactLength:x+.05,bodyDistance:y+.05,height:m})),Array.from({length:d}).map((b,w)=>Yn(Nv,{rotation:Math.PI,position:{x:_/2,y:h-w*a,z:p/2},width:c,thickness:p,padContactLength:x+.05,bodyDistance:y+.05,height:m})),Yn(mI,{center:{x:0,y:0,z:p/2},width:l,length:u,height:1})]})},R3n=()=>{const d=Yn(mT,{color:"#222",children:Zd(BV,{children:[Yn(Qb,{z:.15,children:Yn(ea,{size:[1.65,.8,.3]})}),Zd(S4,{children:[Yn(Qb,{z:.3,children:Yn(ea,{size:[1.65,.8,.01]})}),Yn(Qb,{z:.6,children:Yn(ea,{size:[1.45,.6000000000000001,.01]})})]})]})});return Zd(Ty,{children:[Yn(ea,{color:"#ccc",size:[.5,.6,.12],center:[-.725,0,.12/2]}),Yn(ea,{color:"#ccc",size:[.5,.6,.12],center:[.725,0,.12/2]}),d]})},I3n=({footprint:n})=>{const e=Q5n.string(n).json();switch(e.fn){case"dip":return Yn(i3n,{numPins:e.num_pins,pitch:e.p,bodyWidth:e.w});case"tssop":return Yn(o3n,{pinCount:e.num_pins,leadLength:e.pl,leadWidth:e.pw,pitch:e.p,bodyWidth:e.w});case"vssop":return Yn(P3n,{pinCount:e.num_pins,leadLength:e.pl,leadWidth:e.pw,pitch:e.p,bodyWidth:e.w,bodyLength:e.h});case"qfp":return Yn(l3n,{pinCount:e.num_pins,pitch:e.p,leadWidth:e.pw,padContactLength:e.pl,bodyWidth:e.w});case"qfn":return Yn(y3n,{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(p3n,{numberOfPins:e.num_pins,pitch:e.p});if(e.female)return Yn(M3n,{numberOfPins:e.num_pins,pitch:e.p});case"cap":switch(e.imperial){case"0402":return Yn(Htt,{color:"#856c4d"});case"0603":return Yn(Vtt,{color:"#856c4d"});case"0805":return Yn(Gtt,{color:"#856c4d"});case"0201":return Yn(Ytt,{color:"#856c4d"});case"01005":return Yn(qtt,{color:"#856c4d"});case"1206":return Yn(Xtt,{color:"#856c4d"});case"1210":return Yn(Wtt,{color:"#856c4d"});case"2010":return Yn(Ktt,{color:"#856c4d"});case"2512":return Yn(Ztt,{color:"#856c4d"})}case"sot235":return Yn(x3n,{});case"pushbutton":return Yn(C3n,{width:e.w,length:e.h,innerDiameter:e.id});case"soic":return Yn(A3n,{pinCount:e.num_pins,leadLength:e.pl,leadWidth:e.pw,pitch:e.p,bodyWidth:e.w});case"sod523":return Yn(R3n,{})}const t=n.match(/_color\(([^)]+)\)/),i=t?t[1]:void 0;switch(e.imperial){case"0402":return Yn(Htt,{color:i});case"0603":return Yn(Vtt,{color:i});case"0805":return Yn(Gtt,{color:i});case"0201":return Yn(Ytt,{color:i});case"01005":return Yn(qtt,{color:i});case"1206":return Yn(Xtt,{color:i});case"1210":return Yn(Wtt,{color:i});case"2010":return Yn(Ktt,{color:i});case"2512":return Yn(Ztt,{color:i})}return null},N3n=n=>n&&typeof n=="object"&&"type"in n,TI=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},k3n=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 _T(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=>_T(h,e,t));if(!N3n(n))return[];const{type:l,props:u,children:d}=n;if(l===Ftt)return(d??[]).flatMap(h=>_T(h,e,t));if(l===mT){const h=u?.color;return(d??[]).flatMap(p=>_T(p,h??e,t))}if(l===Qb){const h=k3n(u?.offset??{x:u?.x,y:u?.y,z:u?.z});return(d??[]).flatMap(m=>_T(m,e,t)).map(({geom:m,color:_})=>({geom:c.translate(h,m),color:_??e}))}if(l===fI){const h=Array.isArray(u?.rotation)?[TI(u.rotation[0]),TI(u.rotation[1]),TI(u.rotation[2])]:[TI(u?.x??0),TI(u?.y??0),TI(u?.z??0)];return(d??[]).flatMap(m=>_T(m,e,t)).map(({geom:m,color:_})=>({geom:c.rotateZ(h[2],c.rotateY(h[1],c.rotateX(h[0],m))),color:_}))}if(l===BV||l===jV||l===S4){const h=(d??[]).flatMap(m=>_T(m,e,t)).map(m=>m.geom);if(h.length===0)return[];let p;return l===BV?p=r.union(h):l===jV?p=r.subtract(h[0],h.slice(1)):p=o.hull(h),[{geom:p}]}if(l===ML){const h=u?.points??[];return[{geom:s.geom2.fromPoints(h),color:e??u?.color}]}if(l===CL){const h=(d??[]).flatMap(y=>_T(y,e,t)).map(y=>y.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 y of _.polygons)!y.plane||!y.vertices||y.vertices.length<3||y.vertices.reverse();return[{geom:_,color:e??u?.color}]}if(l===ea||l===Utt||l===J5||l===Btt||l===Sge){let h;if(l===ea){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===Utt){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===J5){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===Btt){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 _T(h,e,t)}return(d??[]).flatMap(h=>_T(h,e,t))}function O3n(n,e){return{geometries:_T(n,void 0,{jscad:e})}}function Qtt(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 Of;if(o.setAttribute("position",new xm(new Float32Array(e),3)),o.setIndex(t),i.length>0&&o.setAttribute("color",new xm(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 Of;if(i.setAttribute("position",new xm(new Float32Array(e),3)),t.length>0&&i.setAttribute("color",new xm(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 Of}function L3n(n,e){const t=wge(I3n,{footprint:n});return O3n(t,e)}var D3n=({jscadPlan:n,positionOffset:e,rotationOffset:t,onHover:i,onUnhover:r,isHovered:o,scale:s})=>{const{rootObject:a}=yb(),{threeGeom:c,material:l}=ce.useMemo(()=>{const d=(0,Qbn.executeJscadOperations)(Jbn.default,n);if(!d||!d.polygons&&!d.sides)return{threeGeom:null,material:null};const h=Qtt(d),p=new Zb({vertexColors:!0,side:Wg});return{threeGeom:h,material:p}},[n]),u=ce.useMemo(()=>c?new Ra(c,l):null,[c,l]);return ce.useEffect(()=>{if(!(!u||!a))return a.add(u),()=>{a.remove(u)}},[a,u]),ce.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]),ce.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?re.jsx(SL,{isHovered:o,onHover:i,onUnhover:r,object:u}):null},z3n=vc(IV()),$3n=({positionOffset:n,footprint:e,rotationOffset:t,onHover:i,onUnhover:r,isHovered:o,scale:s})=>{const{rootObject:a}=yb(),c=ce.useMemo(()=>{if(!e)return null;const{geometries:l}=L3n(e,z3n),u=new cS;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]},_=Qtt(m),y=new Zb({vertexColors:!0,side:Wg}),x=new Ra(_,y);u.add(x)}return u},[e]);return ce.useEffect(()=>{if(!(!c||!a))return a.add(c),()=>{a.remove(c)}},[a,c]),ce.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]),ce.useEffect(()=>{c&&c.traverse(l=>{l instanceof Ra&&l.material instanceof Zb&&(o?(l.material.emissive.setHex(255),l.material.emissiveIntensity=.2):l.material.emissiveIntensity=0)})},[o,c]),c?re.jsx(SL,{isHovered:o,onHover:i,onUnhover:r,object:c}):null},F3n=(...n)=>n,Jtt=({children:n,position:e,style:t})=>{const{camera:i,renderer:r}=yb(),o=ce.useRef(document.createElement("div")),[s,a]=ce.useState(null);return ce.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(mj.createPortal(n,o.current)),()=>{c.contains(o.current)&&c.removeChild(o.current)}},[r,n]),dI(()=>{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},ent={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},tnt=ce.createContext(void 0),U3n=({children:n})=>{const[e,t]=ce.useState(ent),i=ce.useCallback(a=>{t(c=>({...c,[a]:!c[a]}))},[]),r=ce.useCallback((a,c)=>{t(l=>({...l,[a]:c}))},[]),o=ce.useCallback(()=>{t(ent)},[]),s=ce.useMemo(()=>({visibility:e,toggleLayer:i,setLayerVisibility:r,resetToDefaults:o}),[e,i,r,o]);return re.jsx(tnt.Provider,{value:s,children:n})},DL=()=>{const n=ce.useContext(tnt);if(!n)throw new Error("useLayerVisibility must be used within a LayerVisibilityProvider");return n},nnt=({cad_component:n,circuitJson:e})=>{const[t,i]=ce.useState(!1),{visibility:r}=DL(),[o,s]=ce.useState(null),a=ce.useCallback(m=>{m?.mousePosition?(i(!0),s(m.mousePosition)):(i(!1),s(null))},[]),c=ce.useCallback(()=>{i(!1),s(null)},[]),l=ce.useMemo(()=>ms(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?F3n(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=re.jsx(Xbn,{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=re.jsx(Zbn,{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=re.jsx(D3n,{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=re.jsx($3n,{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?re.jsxs(re.Fragment,{children:[p,t&&o?re.jsx(Jtt,{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},int={version:"0.0.426"},E4=({children:n,parent:e,position:t,rotation:i,scale:r,color:o,fontSize:s,anchorX:a,anchorY:c,depthOffset:l})=>{const{rootObject:u}=yb(),d=ce.useMemo(()=>{const h=new ZHe;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 ce.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 oS(0,0,0));function B3n(n,e){const t=new Pv().setFromEuler(new oS(n.x,n.y,n.z)),i=new en(0,0,1);return i.applyQuaternion(t),i.multiplyScalar(e)}var j3n=({})=>{const{camera:n,scene:e}=yb();ce.useEffect(()=>{if(!e)return;const i=new eHe(16777215,Math.PI/2);return e.add(i),()=>{e.remove(i)}},[e]),dI(()=>{if(!n)return;const i=window.TSCI_MAIN_CAMERA_ROTATION,r=B3n(i,2);n.position.copy(r),n.lookAt(0,0,0)});const t=ce.useMemo(()=>{const i=new cS;i.rotation.fromArray([Math.PI/2,0,0]);const r=new Ra(new eE(1,1,1),new Zb({color:"white"}));i.add(r);const o=new j6(new Vln(new eE(1,1,1)),new a4({color:0,linewidth:2}));return i.add(o),i},[]);return ce.useEffect(()=>{if(e)return e.add(t),()=>{e.remove(t)}},[e,t]),re.jsxs(re.Fragment,{children:[re.jsx(E4,{parent:t,position:[0,0,.51],fontSize:.25,color:"black",children:"Front"}),re.jsx(E4,{parent:t,position:[0,0,-.51],fontSize:.25,color:"black",rotation:[0,Math.PI,0],children:"Back"}),re.jsx(E4,{parent:t,position:[.51,0,0],fontSize:.25,color:"black",rotation:[0,Math.PI/2,0],children:"Right"}),re.jsx(E4,{parent:t,position:[-.51,0,0],fontSize:.25,color:"black",rotation:[0,-Math.PI/2,0],children:"Left"}),re.jsx(E4,{parent:t,position:[0,.51,0],fontSize:.25,color:"black",rotation:[-Math.PI/2,0,0],children:"Top"}),re.jsx(E4,{parent:t,position:[0,-.51,0],fontSize:.25,color:"black",rotation:[Math.PI/2,0,0],children:"Bottom"})]})};function H3n(n){n.querySelectorAll("canvas").forEach(e=>e.remove())}var V3n=n=>{n.outputColorSpace=G2,n.toneMapping=RUe,n.toneMappingExposure=1},rnt=ce.forwardRef(({children:n,scene:e,camera:t,style:i},r)=>{const o=ce.useRef(null),[s,a]=ce.useState(null),c=ce.useRef([]),l=ce.useCallback(p=>{c.current.push(p)},[]),u=ce.useCallback(p=>{c.current=c.current.filter(m=>m!==p)},[]),d=ce.useMemo(()=>new Y9,[]);e?.up&&d.up.set(e.up.x,e.up.y,e.up.z);const h=ce.useRef(new Kp);return ce.useImperativeHandle(r,()=>h.current),ce.useEffect(()=>{if(!o.current)return;H3n(o.current);const p=new Dle({antialias:!0,alpha:!0});V3n(p),p.setSize(o.current.clientWidth,o.current.clientHeight),p.setPixelRatio(window.devicePixelRatio),o.current.appendChild(p.domElement);const m=new Kb(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 y=new Cun,x=()=>{const w=y.getElapsedTime(),S=y.getDelta();c.current.forEach(I=>I(w,S)),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]),re.jsx("div",{ref:o,style:{width:"100%",height:"100%",...i},children:s&&re.jsx(zet.Provider,{value:s,children:re.jsx(Hbn,{children:n})})})}),G3n=({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}=yb(),h=ce.useMemo(()=>!u||!d?null:new Jhn(u,d.domElement),[u,d]);return ce.useEffect(()=>{if(l)return l(h??null),()=>{l(null)}},[h,l]),ce.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]),ce.useEffect(()=>{if(!(!h||!t))return h.addEventListener("start",t),()=>{h.removeEventListener("start",t)}},[h,t]),ce.useEffect(()=>{if(h)return()=>{h.dispose()}},[h]),dI(()=>{h?.update()},[h]),null},Y3n=`
|
|
5120
5120
|
varying vec3 worldPosition;
|
|
5121
5121
|
void main() {
|
|
5122
5122
|
worldPosition = (modelMatrix * vec4(position, 1.0)).xyz;
|
|
@@ -5150,12 +5150,12 @@ ${c.join(`
|
|
|
5150
5150
|
gl_FragColor = vec4(color, max(g1, g2) * a);
|
|
5151
5151
|
if (gl_FragColor.a <= 0.0) discard;
|
|
5152
5152
|
}
|
|
5153
|
-
`,X3n=({rotation:n,infiniteGrid:e,cellSize:t=1,sectionSize:i=10})=>{const{scene:r,camera:o}=yb(),s=1e3,a=ce.useMemo(()=>{const c=new cT(s,s);c.rotateX(-Math.PI/2);const l=new aT({vertexShader:Y3n,fragmentShader:q3n,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:Wg}),u=new Ra(c,l);return n&&u.rotation.fromArray(n),u},[s,t,i,n]);return dI(()=>{e&&a.position.set(o.position.x,o.position.y,0)}),ce.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},W3n=()=>{const{scene:n}=yb(),e=ce.useMemo(()=>new eHe(16777215,Math.PI/2),[]),t=ce.useMemo(()=>{const i=new nue(16777215,Math.PI/4);return i.position.set(-10,-10,10),i.decay=0,i},[]);return ce.useEffect(()=>{if(n)return n.add(e),n.add(t),()=>{n.remove(e),n.remove(t)}},[n,e,t]),null},K3n=n=>n<.5?4*n*n*n:1-Math.pow(-2*n+2,3)/2,Z3n=({defaultTarget:n,controlsRef:e,onReady:t})=>{const{camera:i}=yb(),r=ce.useRef(null),o=ce.useRef(new Pv),s=ce.useRef(new en),a=ce.useRef(new en),c=ce.useRef(new Pv),l=ce.useRef(new Pv),u=ce.useRef(new Kp),d=ce.useRef(new Kp),h=ce.useCallback(({position:p,target:m,up:_,durationMs:y=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(),S=new en(..._??[0,0,1]).normalize(),I=d.current;I.position.copy(b),I.up.copy(S),I.lookAt(w);const A=I.quaternion.clone(),R=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(R).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:y}},[i,e,n]);return ce.useEffect(()=>{if(!(!t||!i))return t({animateTo:h}),()=>{t(null)}},[h,i,t]),dI(()=>{if(!i||!r.current)return;const{fromPosition:p,toPosition:m,fromTarget:_,toTarget:y,toQuaternion:x,rollFrom:b,rollTo:w,startTime:S,duration:I}=r.current,A=performance.now()-S,R=I<=0?1:Math.min(A/I,1),M=K3n(R);i.position.lerpVectors(p,m,M);const k=s.current;k.copy(_).lerp(y,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(),R>=1&&(i.position.copy(m),i.quaternion.copy(x),i.up.set(0,0,1),i.updateMatrixWorld(),e.current?.target.copy(y),e.current?.update(),r.current=null)}),null},Q3n=({defaultTarget:n,initialCameraPosition:e,onCameraControllerReady:t})=>{const i=ce.useRef(null),r=ce.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=ce.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=ce.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=ce.useCallback(l=>{i.current=l},[]);return{cameraAnimatorProps:ce.useMemo(()=>({defaultTarget:n,controlsRef:i,onReady:s}),[n,s]),handleControlsChange:a}},J3n=()=>{const{camera:n}=yb();return dI(()=>{n&&(window.TSCI_MAIN_CAMERA_ROTATION=n.rotation)}),null},ont=ce.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]=ce.useState(!i),d=ce.useMemo(()=>{if(!r)return 10;const y=r.width??0,x=r.height??0,w=Math.max(y,x)*1.5;return w>10?w:10},[r]),h=ce.useMemo(()=>{if(o)return[o.x,o.y,0]},[o]),p=ce.useMemo(()=>h?new en(h[0],h[1],h[2]):new en(0,0,0),[h]),{cameraAnimatorProps:m,handleControlsChange:_}=Q3n({defaultTarget:p,initialCameraPosition:e,onCameraControllerReady:a});return re.jsxs("div",{style:{position:"relative",width:"100%",height:"100%"},children:[re.jsx("div",{style:{position:"absolute",top:0,left:0,width:120,height:120},children:re.jsx(rnt,{camera:{up:[0,0,1],position:[1,1,1]},style:{zIndex:10},children:re.jsx(j3n,{})})}),re.jsxs(rnt,{ref:c,scene:{up:new en(0,0,1)},camera:{up:[0,0,1],position:e},children:[re.jsx(Z3n,{...m}),re.jsx(J3n,{}),l&&re.jsx(G3n,{autoRotate:!t,autoRotateSpeed:1,onStart:s,rotateSpeed:.5,panSpeed:.75,zoomSpeed:.5,enableDamping:!0,dampingFactor:.1,target:h,onControlsChange:_}),re.jsx(W3n,{}),re.jsx(X3n,{rotation:[Math.PI/2,0,0],infiniteGrid:!0,cellSize:3,sectionSize:d,args:[d,d]}),n]}),re.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:["@",int.version]}),i&&!l&&re.jsx("button",{type:"button",onClick:()=>u(!0),onKeyDown:y=>{(y.key==="Enter"||y.key===" ")&&u(!0)},style:{position:"absolute",inset:0,cursor:"pointer",zIndex:10,display:"flex",alignItems:"center",justifyContent:"center"},children:re.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"})})]})}),snt=n=>ce.useMemo(()=>{if(!n)return[];const e=new YJt;return e.add(n),e.render(),e.getCircuitJson()},[n]),eMn=n=>{const[e,t]=ce.useState([]),[i,r]=ce.useState(!0);return ce.useEffect(()=>{if(!n)return;(async()=>{r(!0);const a=(Array.isArray(n)?n:[n]).map(async(c,l)=>{const u=Z_n.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}},tMn=vc(W5()),nMn=vc(y4()),Yl=.01,kv={traces:.001,copper:.002},Qd={copper:[.9,.6,.2],fr4Green:[.04,.16,.08],fr4GreenSolderWithMask:[0/255,152/255,19/255],fr1Copper:[.8,.4,.2],fr1CopperSolderWithMask:[.9,.6,.2]},yT=.001,o2=32,YV=.035,qV=50,Hge={fr1:Qd.fr1Copper,fr4:Qd.fr4Green},XV={fr1:Qd.fr1CopperSolderWithMask,fr4:Qd.fr4GreenSolderWithMask},iMn=vc(v4()),rMn=vc(W5()),oMn=vc(w4()),sMn=vc(wL()),Vge=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},Gge=(n,e=1.2,t={})=>{const{xyOutset:i=0}=t,{outline:r}=n;let o=r.map(c=>[c.x,c.y]);Vge(o)&&(o=o.reverse());let s=(0,rMn.polygon)({points:o});i!==0&&(s=(0,sMn.expand)({delta:i,corners:"edge"},s));let a=(0,iMn.extrudeLinear)({height:e},s);return a=(0,oMn.translate)([0,0,-e/2],a),a},aMn=n=>{const e=ms(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=Gge({outline:e.outline},i):t=(0,tMn.cuboid)({size:[e.width,e.height,i],center:[e.center.x,e.center.y,0]});const r=Hge[e.material]??Qd.fr4Green;return[(0,nMn.colorize)(r,t)]},mw=vc(w4()),pp=vc(W5()),dS=vc(y4()),My=vc(vL()),P0=vc(W5()),zL=vc(y4()),Hx=vc(vL()),Yge=vc(v4()),qge=vc(w4());function MI(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 e3(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 T4=.02,Xge=64,WV=(n,e)=>e?(0,Hx.intersect)(e,n):n,KV=({width:n,height:e,thickness:t,center:i,borderRadius:r})=>{const o=MI(n,e,r);if(o<=0)return(0,P0.cuboid)({center:i,size:[n,e,t]});const s=(0,P0.roundedRectangle)({size:[n,e],roundRadius:o,segments:Xge}),a=(0,Yge.extrudeLinear)({height:t},s),c=i[2]-t/2;return(0,qge.translate)([i[0],i[1],c],a)},ant=(n,e,t={})=>{const{clipGeom:i}=t;n.shape||(n.shape="circle");const r=e.pcbThickness+2*T4+4*Yl,o=e.pcbThickness/2+kv.copper,s=-e.pcbThickness/2-kv.copper,a=o-s;if(n.shape==="circle"){const c=n.outer_diameter??Math.max(n.hole_diameter,0),l=a+.01,u=(0,P0.cylinder)({center:[n.x,n.y,0],radius:c/2,height:l}),d=WV(u,i),h=(0,P0.cylinder)({center:[n.x,n.y,0],radius:Math.max(n.hole_diameter/2,.01),height:r});return(0,zL.colorize)(Qd.copper,(0,Hx.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=e3(n),p=WV((0,Hx.union)(KV({width:u,height:d,thickness:T4,center:[n.x,n.y,o],borderRadius:h}),KV({width:u,height:d,thickness:T4,center:[n.x,n.y,s],borderRadius:h}),(()=>{const x=Math.max(a-T4*2,Yl),S=(o+s)/2,I=(0,P0.roundedRectangle)({size:[u,d],roundRadius:h||0,segments:Xge}),A=(0,Yge.extrudeLinear)({height:x},I);return(0,qge.translate)([n.x,n.y,S-x/2],A)})(),(0,P0.cylinder)({center:[n.x+(c||0),n.y+(l||0),0],radius:n.hole_diameter/2,height:a})),i),m=(0,P0.cylinder)({center:[n.x+(c||0),n.y+(l||0),0],radius:Math.max(n.hole_diameter/2-Yl,.01),height:r}),_=(0,P0.cylinder)({center:[n.x+(c||0),n.y+(l||0),0],radius:n.hole_diameter/2,height:a});let y=(0,Hx.union)((0,Hx.subtract)(p,_),_);return t.clipGeom?(y=(0,Hx.subtract)(y,m),y=(0,Hx.intersect)(y,t.clipGeom),(0,zL.colorize)(Qd.copper,y)):(0,zL.colorize)(Qd.copper,(0,Hx.subtract)(y,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,P0.cylinder)({center:[n.x,n.y,0],radius:U,height:C});const H=(0,P0.cuboid)({center:[n.x,n.y,0],size:c?[k,O,C]:[O,k,C]}),Y=(0,P0.cylinder)({center:c?[n.x,n.y-O/2,0]:[n.x-O/2,n.y,0],radius:U,height:C}),X=(0,P0.cylinder)({center:c?[n.x,n.y+O/2,0]:[n.x+O/2,n.y,0],radius:U,height:C});return(0,Hx.union)(H,Y,X)})(d,h,_),b=(0,P0.cuboid)({center:[n.x,n.y,0],size:c?[u-2*Yl,m,r]:[m,u-2*Yl,r]}),w=(0,P0.cylinder)({center:c?[n.x,n.y-m/2,0]:[n.x-m/2,n.y,0],radius:p-Yl,height:r}),S=(0,P0.cylinder)({center:c?[n.x,n.y+m/2,0]:[n.x+m/2,n.y,0],radius:p-Yl,height:r}),I=(0,Hx.union)(b,w,S),A=WV(x,i),R=I;return(0,zL.colorize)(Qd.copper,(0,Hx.subtract)(A,R))}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,y=n.rect_pad_height||h+.2,x=e3(n),b=.03,w=(0,Hx.union)((0,P0.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,P0.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,P0.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})),S=(0,Hx.union)((0,P0.cuboid)({center:[n.x+c,n.y+l,0],size:u?[h,m,r*1.1]:[m,h,r*1.1]}),(0,P0.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,P0.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})),I=KV({width:_,height:y,thickness:T4,center:[n.x,n.y,o],borderRadius:x}),A=KV({width:_,height:y,thickness:T4,center:[n.x,n.y,s],borderRadius:x}),R=(()=>{const Y=Math.max(a-T4*2,Yl),J=(o+s)/2,le=(0,P0.roundedRectangle)({size:[_,y],roundRadius:x||0,segments:Xge}),he=(0,Yge.extrudeLinear)({height:Y},le);return(0,qge.translate)([n.x,n.y,J-Y/2],he)})(),M=(0,Hx.subtract)(I,S),k=(0,Hx.subtract)(A,S),C=(0,Hx.subtract)(R,S),U=(0,Hx.union)((0,P0.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,P0.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,P0.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,Hx.subtract)(w,U),H=WV((0,Hx.union)(M,k,C,O),i);return(0,zL.colorize)(Qd.copper,H)}else throw new Error(`Unsupported plated hole shape: ${n.shape}`)},M4=vc(v4()),Wge=vc(wL()),cMn=vc(ege());function cnt(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 ZM(n,e=0){return{a:1,c:0,e:n,b:0,d:1,f:e}}function lnt(...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 lnt(o,...r)}}}function unt(...n){return lnt(...n)}var{cos:lMn,sin:uMn}=Math;function dnt(n,e,t){const i=lMn(n),r=uMn(n);return{a:i,c:-r,e:0,b:r,d:i,f:0}}function dMn(n,e){function t(){this.constructor=n}t.prototype=e.prototype,n.prototype=new t}function ZV(n,e,t,i){var r=Error.call(this,n);return Object.setPrototypeOf&&Object.setPrototypeOf(r,ZV.prototype),r.expected=e,r.found=t,r.location=i,r.name="SyntaxError",r}dMn(ZV,Error);function Kge(n,e,t){return t=t||" ",n.length>e?n:(e-=n.length,t+=t.repeat(e),n+t.slice(0,e))}ZV.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=Kge("",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+=`
|
|
5153
|
+
`,X3n=({rotation:n,infiniteGrid:e,cellSize:t=1,sectionSize:i=10})=>{const{scene:r,camera:o}=yb(),s=1e3,a=ce.useMemo(()=>{const c=new cT(s,s);c.rotateX(-Math.PI/2);const l=new aT({vertexShader:Y3n,fragmentShader:q3n,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:Wg}),u=new Ra(c,l);return n&&u.rotation.fromArray(n),u},[s,t,i,n]);return dI(()=>{e&&a.position.set(o.position.x,o.position.y,0)}),ce.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},W3n=()=>{const{scene:n}=yb(),e=ce.useMemo(()=>new eHe(16777215,Math.PI/2),[]),t=ce.useMemo(()=>{const i=new nue(16777215,Math.PI/4);return i.position.set(-10,-10,10),i.decay=0,i},[]);return ce.useEffect(()=>{if(n)return n.add(e),n.add(t),()=>{n.remove(e),n.remove(t)}},[n,e,t]),null},K3n=n=>n<.5?4*n*n*n:1-Math.pow(-2*n+2,3)/2,Z3n=({defaultTarget:n,controlsRef:e,onReady:t})=>{const{camera:i}=yb(),r=ce.useRef(null),o=ce.useRef(new Pv),s=ce.useRef(new en),a=ce.useRef(new en),c=ce.useRef(new Pv),l=ce.useRef(new Pv),u=ce.useRef(new Kp),d=ce.useRef(new Kp),h=ce.useCallback(({position:p,target:m,up:_,durationMs:y=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(),S=new en(..._??[0,0,1]).normalize(),I=d.current;I.position.copy(b),I.up.copy(S),I.lookAt(w);const A=I.quaternion.clone(),R=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(R).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:y}},[i,e,n]);return ce.useEffect(()=>{if(!(!t||!i))return t({animateTo:h}),()=>{t(null)}},[h,i,t]),dI(()=>{if(!i||!r.current)return;const{fromPosition:p,toPosition:m,fromTarget:_,toTarget:y,toQuaternion:x,rollFrom:b,rollTo:w,startTime:S,duration:I}=r.current,A=performance.now()-S,R=I<=0?1:Math.min(A/I,1),M=K3n(R);i.position.lerpVectors(p,m,M);const k=s.current;k.copy(_).lerp(y,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(),R>=1&&(i.position.copy(m),i.quaternion.copy(x),i.up.set(0,0,1),i.updateMatrixWorld(),e.current?.target.copy(y),e.current?.update(),r.current=null)}),null},Q3n=({defaultTarget:n,initialCameraPosition:e,onCameraControllerReady:t})=>{const i=ce.useRef(null),r=ce.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=ce.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=ce.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=ce.useCallback(l=>{i.current=l},[]);return{cameraAnimatorProps:ce.useMemo(()=>({defaultTarget:n,controlsRef:i,onReady:s}),[n,s]),handleControlsChange:a}},J3n=()=>{const{camera:n}=yb();return dI(()=>{n&&(window.TSCI_MAIN_CAMERA_ROTATION=n.rotation)}),null},ont=ce.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]=ce.useState(!i),d=ce.useMemo(()=>{if(!r)return 10;const y=r.width??0,x=r.height??0,w=Math.max(y,x)*1.5;return w>10?w:10},[r]),h=ce.useMemo(()=>{if(o)return[o.x,o.y,0]},[o]),p=ce.useMemo(()=>h?new en(h[0],h[1],h[2]):new en(0,0,0),[h]),{cameraAnimatorProps:m,handleControlsChange:_}=Q3n({defaultTarget:p,initialCameraPosition:e,onCameraControllerReady:a});return re.jsxs("div",{style:{position:"relative",width:"100%",height:"100%"},children:[re.jsx("div",{style:{position:"absolute",top:0,left:0,width:120,height:120},children:re.jsx(rnt,{camera:{up:[0,0,1],position:[1,1,1]},style:{zIndex:10},children:re.jsx(j3n,{})})}),re.jsxs(rnt,{ref:c,scene:{up:new en(0,0,1)},camera:{up:[0,0,1],position:e},children:[re.jsx(Z3n,{...m}),re.jsx(J3n,{}),l&&re.jsx(G3n,{autoRotate:!t,autoRotateSpeed:1,onStart:s,rotateSpeed:.5,panSpeed:.75,zoomSpeed:.5,enableDamping:!0,dampingFactor:.1,target:h,onControlsChange:_}),re.jsx(W3n,{}),re.jsx(X3n,{rotation:[Math.PI/2,0,0],infiniteGrid:!0,cellSize:3,sectionSize:d,args:[d,d]}),n]}),re.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:["@",int.version]}),i&&!l&&re.jsx("button",{type:"button",onClick:()=>u(!0),onKeyDown:y=>{(y.key==="Enter"||y.key===" ")&&u(!0)},style:{position:"absolute",inset:0,cursor:"pointer",zIndex:10,display:"flex",alignItems:"center",justifyContent:"center"},children:re.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"})})]})}),snt=n=>ce.useMemo(()=>{if(!n)return[];const e=new YJt;return e.add(n),e.render(),e.getCircuitJson()},[n]),eMn=n=>{const[e,t]=ce.useState([]),[i,r]=ce.useState(!0);return ce.useEffect(()=>{if(!n)return;(async()=>{r(!0);const a=(Array.isArray(n)?n:[n]).map(async(c,l)=>{const u=Z_n.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}},tMn=vc(W5()),nMn=vc(y4()),Yl=.01,kv={traces:.001,copper:.002},Qd={copper:[.9,.6,.2],fr4Green:[.04,.16,.08],fr4GreenSolderWithMask:[0/255,152/255,19/255],fr1Copper:[.8,.4,.2],fr1CopperSolderWithMask:[.9,.6,.2]},yT=.001,o2=32,YV=.035,qV=50,Hge={fr1:Qd.fr1Copper,fr4:Qd.fr4Green},XV={fr1:Qd.fr1CopperSolderWithMask,fr4:Qd.fr4GreenSolderWithMask},iMn=vc(v4()),rMn=vc(W5()),oMn=vc(w4()),sMn=vc(wL()),Vge=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},Gge=(n,e=1.2,t={})=>{const{xyOutset:i=0}=t,{outline:r}=n;let o=r.map(c=>[c.x,c.y]);Vge(o)&&(o=o.reverse());let s=(0,rMn.polygon)({points:o});i!==0&&(s=(0,sMn.expand)({delta:i,corners:"edge"},s));let a=(0,iMn.extrudeLinear)({height:e},s);return a=(0,oMn.translate)([0,0,-e/2],a),a},aMn=n=>{const e=ms(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=Gge({outline:e.outline},i):t=(0,tMn.cuboid)({size:[e.width,e.height,i],center:[e.center.x,e.center.y,0]});const r=Hge[e.material]??Qd.fr4Green;return[(0,nMn.colorize)(r,t)]},mw=vc(w4()),pp=vc(W5()),dS=vc(y4()),My=vc(vL()),P0=vc(W5()),zL=vc(y4()),Hx=vc(vL()),Yge=vc(v4()),qge=vc(w4());function MI(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 e3(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 T4=.02,Xge=64,WV=(n,e)=>e?(0,Hx.intersect)(e,n):n,KV=({width:n,height:e,thickness:t,center:i,borderRadius:r})=>{const o=MI(n,e,r);if(o<=0)return(0,P0.cuboid)({center:i,size:[n,e,t]});const s=(0,P0.roundedRectangle)({size:[n,e],roundRadius:o,segments:Xge}),a=(0,Yge.extrudeLinear)({height:t},s),c=i[2]-t/2;return(0,qge.translate)([i[0],i[1],c],a)},ant=(n,e,t={})=>{const{clipGeom:i}=t;n.shape||(n.shape="circle");const r=e.pcbThickness+2*T4+4*Yl,o=e.pcbThickness/2+kv.copper,s=-e.pcbThickness/2-kv.copper,a=o-s;if(n.shape==="circle"){const c=n.outer_diameter??Math.max(n.hole_diameter,0),l=a+.01,u=(0,P0.cylinder)({center:[n.x,n.y,0],radius:c/2,height:l}),d=WV(u,i),h=(0,P0.cylinder)({center:[n.x,n.y,0],radius:Math.max(n.hole_diameter/2,.01),height:r});return(0,zL.colorize)(Qd.copper,(0,Hx.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=e3(n),p=WV((0,Hx.union)(KV({width:u,height:d,thickness:T4,center:[n.x,n.y,o],borderRadius:h}),KV({width:u,height:d,thickness:T4,center:[n.x,n.y,s],borderRadius:h}),(()=>{const x=Math.max(a-T4*2,Yl),S=(o+s)/2,I=(0,P0.roundedRectangle)({size:[u,d],roundRadius:h||0,segments:Xge}),A=(0,Yge.extrudeLinear)({height:x},I);return(0,qge.translate)([n.x,n.y,S-x/2],A)})(),(0,P0.cylinder)({center:[n.x+(c||0),n.y+(l||0),0],radius:n.hole_diameter/2,height:a})),i),m=(0,P0.cylinder)({center:[n.x+(c||0),n.y+(l||0),0],radius:Math.max(n.hole_diameter/2-Yl,.01),height:r}),_=(0,P0.cylinder)({center:[n.x+(c||0),n.y+(l||0),0],radius:n.hole_diameter/2,height:a});let y=(0,Hx.union)((0,Hx.subtract)(p,_),_);return t.clipGeom?(y=(0,Hx.subtract)(y,m),y=(0,Hx.intersect)(y,t.clipGeom),(0,zL.colorize)(Qd.copper,y)):(0,zL.colorize)(Qd.copper,(0,Hx.subtract)(y,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,P0.cylinder)({center:[n.x,n.y,0],radius:U,height:C});const H=(0,P0.cuboid)({center:[n.x,n.y,0],size:c?[k,O,C]:[O,k,C]}),Y=(0,P0.cylinder)({center:c?[n.x,n.y-O/2,0]:[n.x-O/2,n.y,0],radius:U,height:C}),X=(0,P0.cylinder)({center:c?[n.x,n.y+O/2,0]:[n.x+O/2,n.y,0],radius:U,height:C});return(0,Hx.union)(H,Y,X)})(d,h,_),b=(0,P0.cuboid)({center:[n.x,n.y,0],size:c?[u-2*Yl,m,r]:[m,u-2*Yl,r]}),w=(0,P0.cylinder)({center:c?[n.x,n.y-m/2,0]:[n.x-m/2,n.y,0],radius:p-Yl,height:r}),S=(0,P0.cylinder)({center:c?[n.x,n.y+m/2,0]:[n.x+m/2,n.y,0],radius:p-Yl,height:r}),I=(0,Hx.union)(b,w,S),A=WV(x,i),R=I;return(0,zL.colorize)(Qd.copper,(0,Hx.subtract)(A,R))}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,y=n.rect_pad_height||h+.2,x=e3(n),b=.03,w=(0,Hx.union)((0,P0.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,P0.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,P0.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})),S=(0,Hx.union)((0,P0.cuboid)({center:[n.x+c,n.y+l,0],size:u?[h,m,r*1.1]:[m,h,r*1.1]}),(0,P0.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,P0.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})),I=KV({width:_,height:y,thickness:T4,center:[n.x,n.y,o],borderRadius:x}),A=KV({width:_,height:y,thickness:T4,center:[n.x,n.y,s],borderRadius:x}),R=(()=>{const Y=Math.max(a-T4*2,Yl),J=(o+s)/2,le=(0,P0.roundedRectangle)({size:[_,y],roundRadius:x||0,segments:Xge}),he=(0,Yge.extrudeLinear)({height:Y},le);return(0,qge.translate)([n.x,n.y,J-Y/2],he)})(),M=(0,Hx.subtract)(I,S),k=(0,Hx.subtract)(A,S),C=(0,Hx.subtract)(R,S),U=(0,Hx.union)((0,P0.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,P0.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,P0.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,Hx.subtract)(w,U),H=WV((0,Hx.union)(M,k,C,O),i);return(0,zL.colorize)(Qd.copper,H)}else throw new Error(`Unsupported plated hole shape: ${n.shape}`)},M4=vc(v4()),Wge=vc(wL()),cMn=vc(ege());function cnt(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 ZM(n,e=0){return{a:1,c:0,e:n,b:0,d:1,f:e}}function lnt(...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 lnt(o,...r)}}}function unt(...n){return lnt(...n)}var{cos:lMn,sin:uMn}=Math;function dnt(n,e,t){const i=lMn(n),r=uMn(n);return{a:i,c:-r,e:0,b:r,d:i,f:0}}function dMn(n,e){function t(){this.constructor=n}t.prototype=e.prototype,n.prototype=new t}function ZV(n,e,t,i){var r=Error.call(this,n);return Object.setPrototypeOf&&Object.setPrototypeOf(r,ZV.prototype),r.expected=e,r.found=t,r.location=i,r.name="SyntaxError",r}dMn(ZV,Error);function Kge(n,e,t){return t=t||" ",n.length>e?n:(e-=n.length,t+=t.repeat(e),n+t.slice(0,e))}ZV.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=Kge("",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+=`
|
|
5154
5154
|
--> `+s+`
|
|
5155
5155
|
`+c+` |
|
|
5156
5156
|
`+o.line+" | "+l+`
|
|
5157
5157
|
`+c+" | "+Kge("",r.column-1," ")+Kge("",d,"^")}else e+=`
|
|
5158
|
-
at `+s}return e},ZV.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 hMn(n){const e=(0,cMn.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(ZM(o,s),{a:-1,b:0,c:0,d:1,e:0,f:0},ZM(-o,-s)),t=-t),t){const d=t*Math.PI/180;l.push(ZM(o,s),dnt(d),ZM(-o,-s))}let u=e;if(l.length>0){const d=unt(...l);u=e.map(h=>h.map(([p,m])=>{const{x:_,y}=cnt(d,{x:p,y:m});return[_,y]}))}return{textOutlines:u,xOffset:a,yOffset:c}}var pMn=vc(W5()),fMn=vc(wL()),mMn=vc(v4()),_Mn=vc(w4()),yMn=vc(y4()),hnt=25.4,gMn=hnt/1e3,xMn=/^\s*(-?\d*(?:\.\d+)?)(?:\s*(mm|mil|inch|in|"))?\s*$/i;function bMn(n){if(!n)return;const e=n.trim().toLowerCase();return e==='"'||e==="inch"?"in":e}function Vx(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(xMn);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(bMn(r)){case"mil":return o*gMn;case"in":return o*hnt;case"mm":case void 0:return o;default:return o}}function gT(n,e){const t=Vx(n);return t===void 0?e:t}function vMn(n,e){if(n.route.length<2)return;const t=n.route.map(l=>[Vx(l.x)??0,Vx(l.y)??0]),i=(0,pMn.line)(t),r=gT(n.stroke_width,.1),o=(0,fMn.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,_Mn.translate)([0,0,a],(0,mMn.extrudeLinear)({height:.012},o));return c=(0,yMn.colorize)([1,1,1],c),c}var wMn=vc(W5()),SMn=vc(wL()),EMn=vc(v4()),TMn=vc(w4()),MMn=vc(y4());function CMn(n,e){const t=Vx(n.x1)??0,i=Vx(n.y1)??0,r=Vx(n.x2)??0,o=Vx(n.y2)??0;if(t===r&&i===o)return;const s=[[t,i],[r,o]],a=(0,wMn.line)(s),c=gT(n.stroke_width,.1),l=(0,SMn.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,TMn.translate)([0,0,d],(0,EMn.extrudeLinear)({height:.012},l));return h=(0,MMn.colorize)([1,1,1],h),h}var AMn=vc(W5()),PMn=vc(v4()),RMn=vc(w4()),IMn=vc(y4()),pnt=vc(vL()),NMn=64;function kMn(n,e){const t=gT(n.width,0),i=gT(n.height,0);if(t<=0||i<=0)return;const r=Vx(n.center?.x)??0,o=Vx(n.center?.y)??0,s=e3(n),a=MI(t,i,typeof s=="string"?Vx(s):s),c=(x,b,w)=>(0,PMn.extrudeLinear)({height:.012},(0,AMn.roundedRectangle)({size:[x,b],roundRadius:w,segments:NMn})),l=n.is_filled??!0,u=n.has_stroke??!1,d=u?gT(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 S=MI(b,w,Math.max(a-d,0)),I=c(b,w,S);p=(0,pnt.subtract)(x,I)}else p=x}let m=h;if(p&&(m=m?(0,pnt.union)(m,p):p),!m)return;const _=n.layer==="bottom"?-1:1,y=_*e.pcbThickness/2+_*Yl*1.5;return m=(0,RMn.translate)([r,o,y],m),(0,IMn.colorize)([1,1,1],m)}var fnt=vc(W5()),OMn=vc(vL());function LMn(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),y=u[1]+m*l*Math.sign(t),x=Math.atan2(n[1]-y,n[0]-_),b=[],w=Math.max(2,Math.ceil(i*Math.abs(r)/(Math.PI*2)*4)),S=r/w;for(let I=1;I<w;I++){const A=x+S*I;b.push([_+c*Math.cos(A),y+c*Math.sin(A)])}return b}function mnt(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=LMn([o.x,o.y],[s.x,s.y],o.bulge,e);t.push(...a)}}return t}function _nt(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 DMn(n,e=16){let t=mnt(n.outer_ring,e);_nt(t)&&t.reverse();const i=(0,fnt.polygon)({points:t});if(!n.inner_rings||n.inner_rings.length===0)return i;const r=n.inner_rings.map(o=>{let s=mnt(o,e);return _nt(s)&&s.reverse(),(0,fnt.polygon)({points:s})});return r.length===0?i:(0,OMn.subtract)(i,r)}var zMn=64,$Mn=1,Zge=.05,ynt=(n,e,t,i)=>{const r=MI(n,e,i);if(r<=0)return(0,pp.cuboid)({center:[0,0,0],size:[n,e,t]});const o=(0,pp.roundedRectangle)({size:[n,e],roundRadius:r,segments:zMn}),s=(0,M4.extrudeLinear)({height:t},o);return(0,mw.translate)([0,0,-t/2],s)},gnt=["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"],FMn=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=ms(n).pcb_board.list()[0],this.plated_holes=ms(n).pcb_plated_hole.list(),this.holes=ms(n).pcb_hole.list(),this.pads=ms(n).pcb_smtpad.list(),this.traces=ms(n).pcb_trace.list(),this.pcb_vias=ms(n).pcb_via.list(),this.silkscreenTexts=ms(n).pcb_silkscreen_text.list(),this.silkscreenPaths=ms(n).pcb_silkscreen_path.list(),this.silkscreenLines=ms(n).pcb_silkscreen_line.list(),this.silkscreenRects=ms(n).pcb_silkscreen_rect.list(),this.pcb_cutouts=ms(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*$Mn;this.board.outline&&this.board.outline.length>0?(this.boardGeom=Gge({outline:this.board.outline},this.ctx.pcbThickness),this.boardClipGeom=Gge({outline:this.board.outline},n,{xyOutset:Zge})):(this.boardGeom=(0,pp.cuboid)({size:[this.board.width,this.board.height,this.ctx.pcbThickness],center:[this.board.center.x,this.board.center.y,0]}),this.boardClipGeom=(0,pp.cuboid)({size:[this.board.width+2*Zge,this.board.height+2*Zge,n],center:[this.board.center.x,this.board.center.y,0]})),this.state="processing_pads",this.currentIndex=0}goToNextState(){const n=gnt.indexOf(this.state);n!==-1&&(this.state=gnt[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,pp.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,mw.rotateZ)(o,e)}break;case"circle":e=(0,pp.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}Vge(i)&&(i=i.reverse());const r=(0,pp.polygon)({points:i});e=(0,M4.extrudeLinear)({height:t},r),e=(0,mw.translate)([0,0,-t/2],e);break}e&&(this.boardGeom=(0,My.subtract)(this.boardGeom,e))}processCopperPour(n){const e=n.layer==="bottom"?-1:1,t=e*this.ctx.pcbThickness/2+e*kv.copper;let i=null;if(n.shape==="rect"){let r=(0,pp.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,mw.rotateZ)(o,r)}i=(0,mw.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=DMn(r);i=(0,M4.extrudeLinear)({height:Yl},o),i=(0,mw.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}Vge(r)&&(r=r.reverse());const o=(0,pp.polygon)({points:r});i=(0,M4.extrudeLinear)({height:Yl},o),i=(0,mw.translate)([0,0,t],i)}if(i){this.boardClipGeom&&(i=(0,My.intersect)(this.boardClipGeom,i));const o=n.covered_with_solder_mask!==!1?XV[this.board.material]??Qd.fr4GreenSolderWithMask:Qd.copper,s=(0,dS.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,pp.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,pp.cylinder)({center:[n.x,n.y,0],radius:n.hole_diameter/2+Yl,height:this.ctx.pcbThickness*1.5}),e.dontCutBoard||(this.boardGeom=(0,My.subtract)(this.boardGeom,t)),this.padGeoms=this.padGeoms.map(r=>(0,dS.colorize)(Qd.copper,(0,My.subtract)(r,t)));const i=ant(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,My.union)((0,pp.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,pp.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,pp.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,My.union)((0,pp.cuboid)({center:[n.x,n.y,0],size:t?[r,s,this.ctx.pcbThickness*1.5]:[s,r,this.ctx.pcbThickness*1.5]}),(0,pp.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,pp.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,My.subtract)(this.boardGeom,a)),this.padGeoms=this.padGeoms.map(l=>(0,dS.colorize)(Qd.copper,(0,My.subtract)(l,a)));const c=ant(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,pp.cylinder)({center:[n.x,n.y,0],radius:n.hole_diameter/2+Yl,height:e});this.boardGeom=(0,My.subtract)(this.boardGeom,t),this.padGeoms=this.padGeoms.map(r=>(0,dS.colorize)(Qd.copper,(0,My.subtract)(r,t)));const i=(0,pp.cylinder)({center:[n.x,n.y,0],radius:n.hole_diameter/2+Yl/2,height:e});this.platedHoleGeoms=this.platedHoleGeoms.map(r=>(0,dS.colorize)(Qd.copper,(0,My.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,My.union)((0,pp.cuboid)({center:[n.x,n.y,0],size:[o,i,e]}),(0,pp.cylinder)({center:[n.x-o/2,n.y,0],radius:r,height:e}),(0,pp.cylinder)({center:[n.x+o/2,n.y,0],radius:r,height:e})):a=(0,My.union)((0,pp.cuboid)({center:[n.x,n.y,0],size:[t,o,e]}),(0,pp.cylinder)({center:[n.x,n.y-o/2,0],radius:r,height:e}),(0,pp.cylinder)({center:[n.x,n.y+o/2,0],radius:r,height:e})),s){const l=n.ccw_rotation*Math.PI/180;a=(0,mw.rotateZ)(l,a)}this.boardGeom=(0,My.subtract)(this.boardGeom,a),this.padGeoms=this.padGeoms.map(l=>(0,dS.colorize)(Qd.copper,(0,My.subtract)(l,a)));const c=(0,Wge.expand)({delta:-.02},a);this.platedHoleGeoms=this.platedHoleGeoms.map(l=>(0,dS.colorize)(Qd.copper,(0,My.subtract)(l,c)))}}processPad(n){const e=n.layer==="bottom"?-1:1,t=e*this.ctx.pcbThickness/2+e*kv.copper,i=e3(n);if(n.shape==="rect"){const r=ynt(n.width,n.height,Yl,i);let s=(0,mw.translate)([n.x,n.y,t],r);this.boardClipGeom&&(s=(0,My.intersect)(this.boardClipGeom,s)),s=(0,dS.colorize)(Qd.copper,s),this.padGeoms.push(s)}else if(n.shape==="rotated_rect"){let r=ynt(n.width,n.height,Yl,i);const o=n.ccw_rotation*Math.PI/180;r=(0,mw.rotateZ)(o,r);let a=(0,mw.translate)([n.x,n.y,t],r);this.boardClipGeom&&(a=(0,My.intersect)(this.boardClipGeom,a)),a=(0,dS.colorize)(Qd.copper,a),this.padGeoms.push(a)}else if(n.shape==="circle"){let r=(0,pp.cylinder)({center:[n.x,n.y,t],radius:n.radius,height:Yl});this.boardClipGeom&&(r=(0,My.intersect)(this.boardClipGeom,r)),r=(0,dS.colorize)(Qd.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*kv.traces,c=(0,pp.line)(t),l=(0,Wge.expand)({delta:r/2,corners:"round"},c);let u=(0,mw.translate)([0,0,a-Yl/2],(0,M4.extrudeLinear)({height:Yl},l));const d=t[0],h=t[t.length-1],p=this.getHoleToCut(d[0],d[1]);if(p){const y=(0,pp.cylinder)({center:[d[0],d[1],a],radius:p.diameter/2+Yl,height:Yl});u=(0,My.subtract)(u,y)}const m=this.getHoleToCut(h[0],h[1]);if(m){const y=(0,pp.cylinder)({center:[h[0],h[1],a],radius:m.diameter/2+Yl,height:Yl});u=(0,My.subtract)(u,y)}const _=XV[this.board.material]??Qd.fr4GreenSolderWithMask;this.boardClipGeom&&(u=(0,My.intersect)(this.boardClipGeom,u)),u=(0,dS.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}=hMn(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,pp.line)(o),a=n.font_size||.25,c=Math.min(Math.max(.01,a*.1),a*.05),l=(0,Wge.expand)({delta:c,corners:"round"},s);let u;n.layer==="bottom"?u=(0,mw.translate)([0,0,-this.ctx.pcbThickness/2-Yl],(0,M4.extrudeLinear)({height:.012},l)):u=(0,mw.translate)([0,0,this.ctx.pcbThickness/2+Yl],(0,M4.extrudeLinear)({height:.012},l)),u=(0,dS.colorize)([1,1,1],u),this.silkscreenTextGeoms.push(u)}}processSilkscreenPath(n){const e=vMn(n,this.ctx);e&&this.silkscreenPathGeoms.push(e)}processSilkscreenLine(n){const e=CMn(n,this.ctx);e&&this.silkscreenLineGeoms.push(e)}processSilkscreenRect(n){const e=kMn(n,this.ctx);e&&this.silkscreenRectGeoms.push(e)}finalize(){if(!this.boardGeom)return;const n=Hge[this.board.material]??Qd.fr4Green;this.boardGeom=(0,dS.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}},UMn=n=>{const[e,t]=ce.useState(null),i=ce.useRef(!1);return ce.useEffect(()=>{let r=!1;if(!n){t(null);return}if(!n.some(c=>c.type==="pcb_board")){t(null);return}const o=aMn(n);t(o);const s=new FMn(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},xnt=({error:n,cad_component:e})=>{const{rootObject:t}=yb(),[i,r]=ce.useState(!1),[o,s]=ce.useState(null),a=ce.useCallback(d=>{d?.mousePosition?(r(!0),s(d.mousePosition)):(r(!1),s(null))},[]),c=ce.useCallback(()=>{r(!1),s(null)},[]),l=ce.useMemo(()=>e?.position?[e.position.x,e.position.y,e.position.z].map(h=>Number.isNaN(h)?0:h):[0,0,0],[e]),u=ce.useMemo(()=>{const d=new cS;return d.position.fromArray(l),d},[l]);return ce.useEffect(()=>{if(t)return t.add(u),()=>{t.remove(u)}},[t,u]),re.jsxs(re.Fragment,{children:[re.jsxs(SL,{isHovered:i,onHover:a,onUnhover:c,object:u,children:[re.jsx(BMn,{parent:u}),re.jsx(E4,{parent:u,scale:[.1,.1,.1],color:"red",anchorX:"center",anchorY:"middle",depthOffset:-99999,children:`${n.toString().slice(0,50)}...`})]}),i&&o?re.jsx(Jtt,{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]})},BMn=({parent:n})=>{const e=ce.useMemo(()=>{const t=new Ra(new eE(.5,.5,.5),new Zb({depthTest:!1,transparent:!0,color:"red",opacity:.5}));return t.renderOrder=999999,t.rotation.fromArray([Math.PI/4,Math.PI/4,0]),t},[]);return ce.useEffect(()=>(n.add(e),()=>{n.remove(e)}),[n,e]),null};function jMn({stlUrl:n,stlData:e,mtlUrl:t,color:i,opacity:r=1}){const{rootObject:o}=yb(),[s,a]=ce.useState(null);ce.useEffect(()=>{const l=new Vdn;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=ce.useMemo(()=>{if(!s)return null;const l=new Zb({color:Array.isArray(i)?new Jr(i[0],i[1],i[2]):i,transparent:r!==1,opacity:r});return new Ra(s,l)},[s,i,r]);return ce.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 HMn({stlData:n,color:e,opacity:t=1,layerType:i}){const{visibility:r}=DL();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?re.jsx(jMn,{stlData:n,color:e,opacity:t}):null}var bnt=class extends So.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}},VMn=ce.forwardRef(({soup:n,circuitJson:e,children:t,autoRotateDisabled:i,clickToInteractEnabled:r,onUserInteraction:o,onCameraControllerReady:s},a)=>{const c=snt(t),l=ce.useMemo(()=>n??e??c,[n,e,c]),u=UMn(l),d=ce.useMemo(()=>{if(!l)return[5,5,5];try{const y=ms(l).pcb_board.list()[0];if(!y)return[5,5,5];const{width:x,height:b}=y;if(!x&&!b)return[5,5,5];const w=5,S=Math.max(x,w),I=Math.max(b,w),A=Math.max(S,I);return[A/2,A/2,A]}catch(y){return console.error(y),[5,5,5]}},[l]),h=ce.useMemo(()=>{if(l)try{const y=ms(l).pcb_board.list()[0];return y?{width:y.width??0,height:y.height??0}:void 0}catch(y){console.error(y);return}},[l]),p=ce.useMemo(()=>{if(l)try{const y=ms(l).pcb_board.list()[0];return!y||!y.center?void 0:{x:y.center.x,y:y.center.y}}catch(y){console.error(y);return}},[l]),{stls:m}=eMn(u),_=ms(l).cad_component.list();return re.jsxs(ont,{ref:a,autoRotateDisabled:i,initialCameraPosition:d,clickToInteractEnabled:r,boardDimensions:h,boardCenter:p,onUserInteraction:o,onCameraControllerReady:s,children:[m.map(({stlData:y,color:x,layerType:b},w)=>re.jsx(HMn,{stlData:y,color:x,opacity:w===0?.95:1,layerType:b},`board-${w}`)),_.map(y=>re.jsx(bnt,{fallback:({error:x})=>re.jsx(xnt,{cad_component:y,error:x}),children:re.jsx(nnt,{cad_component:y,circuitJson:l},y.cad_component_id)},y.cad_component_id))]})});function t3(n){const e=new Of;if(e.setAttribute("position",new Ja(n.vertProperties,3)),e.setIndex(new ble(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 vnt(n){return n&&n.route_type==="wire"&&typeof n.layer=="string"&&typeof n.width=="number"}function wnt({layer:n,circuitJson:e,boardData:t,traceColor:i,traceTextureResolution:r}){const o=ms(e).pcb_trace.list(),s=ms(e).pcb_via.list(),a=ms(e).pcb_plated_hole.list(),c=o.filter(m=>m.route.some(_=>vnt(_)&&_.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 y=0;for(const x of m.route){if(!vnt(x)||x.layer!==n){_||h.stroke(),_=!0;continue}const b=x.x,w=x.y;y=x.width*r,h.lineWidth=y;const S=(b-t.center.x+t.width/2)*r,I=(-(w-t.center.y)+t.height/2)*r;_?(h.moveTo(S,I),_=!1):h.lineTo(S,I)}_||h.stroke()}),h.globalCompositeOperation="destination-out",h.fillStyle="black",s.forEach(m=>{const _=(m.x-t.center.x+t.width/2)*r,y=(-(m.y-t.center.y)+t.height/2)*r,x=m.outer_diameter/2*r;h.beginPath(),h.arc(_,y,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,y=(-(m.y-t.center.y)+t.height/2)*r,x=m.outer_diameter/2*r;h.beginPath(),h.arc(_,y,x,0,2*Math.PI,!1),h.fill()}}),h.globalCompositeOperation="source-over";const p=new Uje(l);return p.generateMipmaps=!0,p.minFilter=e2,p.magFilter=E1,p.anisotropy=16,p.needsUpdate=!0,p}var GMn=vc(ege());function Snt({layer:n,circuitJson:e,boardData:t,silkscreenColor:i="rgb(255,255,255)",traceTextureResolution:r}){const o=ms(e).pcb_silkscreen_text.list(),s=ms(e).pcb_silkscreen_path.list(),a=ms(e).pcb_silkscreen_line.list(),c=ms(e).pcb_silkscreen_rect.list(),l=o.filter(S=>S.layer===n),u=s.filter(S=>S.layer===n),d=a.filter(S=>S.layer===n),h=c.filter(S=>S.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 y=p.getContext("2d");if(!y)return null;n==="bottom"&&(y.translate(0,_),y.scale(1,-1)),y.strokeStyle=i,y.fillStyle=i;const x=S=>(S-t.center.x+t.width/2)*r,b=S=>(-(S-t.center.y)+t.height/2)*r;d.forEach(S=>{const I=Vx(S.x1)??0,A=Vx(S.y1)??0,R=Vx(S.x2)??0,M=Vx(S.y2)??0;I===R&&A===M||(y.beginPath(),y.lineWidth=gT(S.stroke_width,.1)*r,y.lineCap="round",y.moveTo(x(I),b(A)),y.lineTo(x(R),b(M)),y.stroke())}),u.forEach(S=>{S.route.length<2||(y.beginPath(),y.lineWidth=gT(S.stroke_width,.1)*r,y.lineCap="round",y.lineJoin="round",S.route.forEach((I,A)=>{const R=x(Vx(I.x)??0),M=b(Vx(I.y)??0);A===0?y.moveTo(R,M):y.lineTo(R,M)}),y.stroke())}),h.forEach(S=>{const I=gT(S.width,0),A=gT(S.height,0);if(I<=0||A<=0)return;const R=Vx(S.center?.x)??0,M=Vx(S.center?.y)??0,k=x(R),C=b(M),U=e3(S),O=typeof U=="string"?Vx(U):U,H=MI(I,A,O);y.save(),y.translate(k,C);const Y=I/2*r,X=A/2*r,K=Math.min(H*r,Y,X),J=S.has_stroke??!1,le=S.is_filled??!0,he=S.is_stroke_dashed??!1,ve=J?gT(S.stroke_width,.1)*r:0;if(((ae,de,Te,Ce,Oe)=>{if(y.beginPath(),Oe<=0)y.rect(ae,de,Te,Ce);else{const $e=Oe,Ae=ae+Te,se=de+Ce;y.moveTo(ae+$e,de),y.lineTo(Ae-$e,de),y.quadraticCurveTo(Ae,de,Ae,de+$e),y.lineTo(Ae,se-$e),y.quadraticCurveTo(Ae,se,Ae-$e,se),y.lineTo(ae+$e,se),y.quadraticCurveTo(ae,se,ae,se-$e),y.lineTo(ae,de+$e),y.quadraticCurveTo(ae,de,ae+$e,de),y.closePath()}})(-Y,-X,Y*2,X*2,K),le&&y.fill(),J&&ve>0){if(y.lineWidth=ve,he){const ae=Math.max(ve*2,1);y.setLineDash([ae,ae])}y.stroke(),he&&y.setLineDash([])}y.restore()}),l.forEach(S=>{const I=S.font_size||.25,A=Math.min(Math.max(.01,I*.1),I*.05)*r;y.lineWidth=A,y.lineCap="butt",y.lineJoin="miter";const R=(0,GMn.vectorText)({height:I*.45,input:S.text}),M=[];R.forEach(he=>{he.length===29?(M.push(he.slice(0,15)),M.push(he.slice(14,29))):he.length===17?(M.push(he.slice(0,10)),M.push(he.slice(9,17))):M.push(he)});const k=M.flat(),C={minX:k.length>0?Math.min(...k.map(he=>he[0])):0,maxX:k.length>0?Math.max(...k.map(he=>he[0])):0,minY:k.length>0?Math.min(...k.map(he=>he[1])):0,maxY:k.length>0?Math.max(...k.map(he=>he[1])):0},U=(C.minX+C.maxX)/2,O=(C.minY+C.maxY)/2;let H=-U,Y=-O;const X=S.anchor_alignment||"center";X.includes("left")?H=-C.minX:X.includes("right")&&(H=-C.maxX),X.includes("top")?Y=-C.maxY:X.includes("bottom")&&(Y=-C.minY);const K=[];let J=S.ccw_rotation??0;if(S.layer==="bottom"&&(K.push(ZM(U,O),{a:-1,b:0,c:0,d:1,e:0,f:0},ZM(-U,-O)),J=-J),J){const he=J*Math.PI/180;K.push(ZM(U,O),dnt(he),ZM(-U,-O))}const le=K.length>0?unt(...K):void 0;M.forEach(he=>{y.beginPath(),he.forEach((ve,oe)=>{let ae={x:ve[0],y:ve[1]};le&&(ae=cnt(le,ae));const de=ae.x+H+S.anchor_position.x,Te=ae.y+Y+S.anchor_position.y,Ce=x(de),Oe=b(Te);oe===0?y.moveTo(Ce,Oe):y.lineTo(Ce,Oe)}),y.stroke()})});const w=new Uje(p);return w.generateMipmaps=!0,w.minFilter=e2,w.magFilter=E1,w.anisotropy=16,w.needsUpdate=!0,w}function Ent({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 Tnt({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 YMn=64;function xT({Manifold:n,width:e,height:t,thickness:i,borderRadius:r}){const o=MI(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,YMn,!0).translate([u,d,0]))}),n.union(s)}function qMn({Manifold:n,pad:e,padBaseThickness:t}){if(e.shape==="rect"){const i=e3(e);return xT({Manifold:n,width:e.width,height:e.height,thickness:t,borderRadius:i})}else if(e.shape==="rotated_rect"){const i=e3(e);let r=xT({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 XMn(n){return(n.shape==="circle"||n.hole_shape==="circle")&&typeof n.hole_diameter=="number"}function WMn(n){return(n.shape==="pill"||n.hole_shape==="pill")&&typeof n.hole_width=="number"&&typeof n.hole_height=="number"}function KMn(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 ZMn(n,e,t,i){const r=[],o=ms(e).pcb_hole.list(),s=(a,c,l)=>{const u=xT({Manifold:n,width:a,height:c,thickness:l,borderRadius:Math.min(a,c)/2});return i.push(u),u};return o.forEach(a=>{if(XMn(a)){const c=Ent({Manifold:n,x:a.x,y:a.y,diameter:a.hole_diameter,thickness:t,segments:o2});i.push(c),r.push(c)}else if(WMn(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(KMn(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 QV=new Jr(...Qd.copper),Mnt=.05;function QMn(n,e,t,i,r){const o=[],s=ms(e).pcb_plated_hole.list(),a=[],c=[],l=(d,h,p)=>{const m=xT({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=Tnt({Manifold:n,x:d.x,y:d.y,outerDiameter:d.hole_diameter*1.02,thickness:t,zOffset:yT,segments:o2});i.push(p),o.push(p);const m=t+2*yT,_=n.cylinder(m,d.outer_diameter/2,d.outer_diameter/2,o2,!0);i.push(_);const y=n.cylinder(m*1.05,d.hole_diameter/2,d.hole_diameter/2,o2,!0);i.push(y);const x=_.subtract(y);i.push(x);const b=x.translate([d.x,d.y,0]);i.push(b);let w=b;if(r){const I=n.intersection([b,r]);i.push(I),w=I}c.push(w);const S=t3(w.getMesh());a.push({key:`ph-${d.pcb_plated_hole_id||h}`,geometry:S,color:QV})}else if(d.shape==="pill"){const p=d.hole_width,m=d.hole_height,_=.4,y=d.outer_width??p+_,x=d.outer_height??m+_,b=p+2*yT,w=m+2*yT,S=t*1.2;let I=l(b,w,S);if(d.ccw_rotation){const Y=I.rotate([0,0,d.ccw_rotation]);i.push(Y),I=Y}const A=I.translate([d.x,d.y,0]);i.push(A),o.push(A);const R=t+2*yT,M=l(y,x,R),k=l(p,m,R*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=t3(O.getMesh());a.push({key:`ph-${d.pcb_plated_hole_id||h}`,geometry:H,color:QV})}else if(d.shape==="pill_hole_with_rect_pad"){const p=d.hole_width,m=d.hole_height,_=d.hole_offset_x||0,y=d.hole_offset_y||0,x=d.rect_pad_width,b=d.rect_pad_height,w=e3(d),S=YV,I=p+2*yT,A=m+2*yT,R=t*1.2,k=l(I,A,R).translate([_,y,0]).translate([d.x,d.y,0]);i.push(k),o.push(k);const C=xT({Manifold:n,width:x,height:b,thickness:t-2*S-2*kv.copper+.1,borderRadius:w});i.push(C);const U=xT({Manifold:n,width:x,height:b,thickness:S,borderRadius:w}).translate([0,0,t/2/2+kv.copper]),O=xT({Manifold:n,width:x,height:b,thickness:S,borderRadius:w}).translate([0,0,-t/2/2-kv.copper]);i.push(U,O);const H=l(p,m,t*1.02).translate([_,y,0]);i.push(H);const Y=n.union([C,U,O,H]);i.push(Y);const X=l(Math.max(p-2*Mnt,.01),Math.max(m-2*Mnt,.01),t*1.2).translate([_,y,0]);i.push(X);const K=Y.subtract(X);i.push(K);const J=K.translate([d.x,d.y,0]);i.push(J);let le=J;if(r){const ve=n.intersection([J,r]);i.push(ve),le=ve}c.push(le);const he=t3(le.getMesh());a.push({key:`ph-${d.pcb_plated_hole_id||h}`,geometry:he,color:QV})}else if(d.shape==="circular_hole_with_rect_pad"){const p=d.hole_offset_x||0,m=d.hole_offset_y||0,_=Ent({Manifold:n,x:d.x+p,y:d.y+m,diameter:d.hole_diameter,thickness:t,segments:o2});i.push(_),o.push(_);const y=d.rect_pad_width??d.hole_diameter,x=d.rect_pad_height??d.hole_diameter,b=e3(d),w=YV,S=d.hole_diameter/2,I=xT({Manifold:n,width:y,height:x,thickness:t-2*w-2*kv.copper+.1,borderRadius:b});i.push(I);const A=xT({Manifold:n,width:y,height:x,thickness:w,borderRadius:b}).translate([0,0,t/2/2+kv.copper]),R=xT({Manifold:n,width:y,height:x,thickness:w,borderRadius:b}).translate([0,0,-t/2/2-kv.copper]);i.push(A,R);const M=n.cylinder(t*1.02,S,S,o2,!0).translate([p,m,0]);i.push(M);const k=n.union([I,A,R,M]);i.push(k);const C=n.cylinder(t*1.2,Math.max(S-Yl,.01),Math.max(S-Yl,.01),o2,!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 X=n.intersection([O,r]);i.push(X),H=X}c.push(H);const Y=t3(H.getMesh());a.push({key:`ph-${d.pcb_plated_hole_id||h}`,geometry:Y,color:QV})}});let u;return c.length>0&&(u=n.union(c),i.push(u)),{platedHoleBoardDrills:o,platedHoleCopperGeoms:a,platedHoleSubtractOp:u}}function JMn({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 eCn=new Jr(...Qd.copper);function tCn(n,e,t,i,r){const o=[],s=ms(e).pcb_via.list(),a=[];return s.forEach((c,l)=>{if(typeof c.outer_diameter=="number"){const u=Tnt({Manifold:n,x:c.x,y:c.y,outerDiameter:c.outer_diameter,thickness:t,zOffset:yT,segments:o2});i.push(u),o.push(u)}if(typeof c.outer_diameter=="number"&&typeof c.hole_diameter=="number"){const u=JMn({Manifold:n,x:c.x,y:c.y,outerDiameter:c.outer_diameter,holeDiameter:c.hole_diameter,thickness:t,zOffset:yT,segments:o2});i.push(u);let d=u;if(r){const p=n.intersection([u,r]);i.push(p),d=p}const h=t3(d.getMesh());a.push({key:`via-${c.pcb_via_id||l}`,geometry:h,color:eCn})}}),{viaBoardDrills:o,viaCopperGeoms:a}}var nCn=new Jr(...Qd.copper);function iCn(n,e,t,i,r,o){const s=[];return ms(e).pcb_smtpad.list().forEach((c,l)=>{const u=YV,d=c.layer==="bottom"?-t/2-kv.copper:t/2+kv.copper;let h=qMn({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 y=n.intersection([m,o]);i.push(y),m=y}const _=t3(m.getMesh());s.push({key:`smt_pad-${c.layer||"top"}-${c.pcb_smtpad_id||l}`,geometry:_,color:nCn})}}),{smtPadGeoms:s}}var rCn=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 oCn(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]);rCn(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 Qge=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 sCn(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),y=u[1]+m*l*Math.sign(t),x=Math.atan2(n[1]-y,n[0]-_),b=[],w=Math.max(2,Math.ceil(i*Math.abs(r)/(Math.PI*2)*4)),S=r/w;for(let I=1;I<w;I++){const A=x+S*I;b.push([_+c*Math.cos(A),y+c*Math.sin(A)])}return b}function Cnt(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=sCn([o.x,o.y],[s.x,s.y],o.bulge,e);t.push(...a)}}return t}function aCn(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=YV,p=(u.layer==="bottom"?-1:1)*(i/2+d/2+yT);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]);Qge(_)&&(_=_.reverse());const y=e.ofPolygons([_]);r.push(y),m=n.extrude(y,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 y=Cnt(_.outer_ring,o2);Qge(y)&&(y=y.reverse());const x=[y];if(_.inner_rings){const w=_.inner_rings.map(S=>{let I=Cnt(S,o2);return Qge(I)||(I=I.reverse()),I});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 y=u.covered_with_solder_mask!==!1?XV[o]??Qd.fr4GreenSolderWithMask:Qd.copper,x=new Jr(...y),b=t3(m.getMesh());c.push({key:`coppour-${u.pcb_copper_pour_id}`,geometry:b,color:x})}}return{copperPourGeoms:c}}var cCn=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 lCn(n,e,t,i,r){const o=[],s=ms(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,o2,!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]);cCn(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 uCn=(n,e)=>{const[t,i]=ce.useState(null),[r,o]=ce.useState(null),[s,a]=ce.useState(null),[c,l]=ce.useState(null),[u,d]=ce.useState(!0),h=ce.useRef([]),p=ce.useMemo(()=>{const m=ms(e).pcb_board.list();return m.length===0?null:m[0]},[e]);return ce.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,y=S=>{if(!(!S||typeof S.delete!="function"))try{S.delete()}catch(I){(!(I instanceof Error)||!I.message?.includes("Manifold instance already deleted"))&&console.warn("Failed to delete Manifold instance",I)}};h.current.forEach(y),h.current=[];let x=null;const b={},w={};try{const S=p.thickness||1.6;a(S);const{boardOp:I,outlineCrossSection:A}=oCn(m,_,p,S,h.current);let R=I;const k=S+2*1;let C=null;const U=.01;if(A){let Oe=A;if(U>0){const Ae=A.offset(U);h.current.push(Ae),Oe=Ae}const $e=m.extrude(Oe,k,void 0,void 0,void 0,!0);h.current.push($e),C=$e}else{const Oe=(p.width||0)+2*U,$e=(p.height||0)+2*U,Ae=m.cube([Oe,$e,k],!0);h.current.push(Ae);const se=Ae.translate([p.center.x,p.center.y,0]);h.current.push(se),C=se}const O=[];let H=null;const{nonPlatedHoleBoardDrills:Y}=ZMn(m,e,S,h.current);O.push(...Y);const{platedHoleBoardDrills:X,platedHoleCopperGeoms:K,platedHoleSubtractOp:J}=QMn(m,e,S,h.current,C);O.push(...X),b.platedHoles=K;const{viaBoardDrills:le,viaCopperGeoms:he}=tCn(m,e,S,h.current,C);if(O.push(...le),b.vias=he,O.length>0){H=m.union(O),h.current.push(H);const Oe=J?m.union([H,J]):H;h.current.push(Oe);const $e=R.subtract(Oe);if(h.current.push($e),R=$e,J){const Ae=J.subtract(H);h.current.push(Ae);const se=Ae.getMesh(),Se=t3(se);b.platedHoles=[{key:"plated-holes-union",geometry:Se,color:new Jr(Qd.copper[0],Qd.copper[1],Qd.copper[2])}]}}const{cutoutOps:ve}=lCn(m,_,e,S,h.current);if(ve.length>0){const Oe=m.union(ve);h.current.push(Oe);const $e=R.subtract(Oe);h.current.push($e),R=$e}if(x=R,x){const Oe=x.getMesh(),$e=t3(Oe),Ae=Hge[p.material]??Qd.fr4Green;b.board={geometry:$e,color:new Jr(Ae[0],Ae[1],Ae[2]),material:p.material}}const{smtPadGeoms:oe}=iCn(m,e,S,h.current,H,C);b.smtPads=oe;const{copperPourGeoms:ae}=aCn(m,_,e,S,h.current,p.material,H,C);b.copperPours=ae,i(b);const de=XV[p.material]??Qd.fr4GreenSolderWithMask,Te=`rgb(${Math.round(de[0]*255)}, ${Math.round(de[1]*255)}, ${Math.round(de[2]*255)})`;w.topTrace=wnt({layer:"top",circuitJson:e,boardData:p,traceColor:Te,traceTextureResolution:qV}),w.bottomTrace=wnt({layer:"bottom",circuitJson:e,boardData:p,traceColor:Te,traceTextureResolution:qV});const Ce="rgb(255,255,255)";w.topSilkscreen=Snt({layer:"top",circuitJson:e,boardData:p,silkscreenColor:Ce,traceTextureResolution:qV}),w.bottomSilkscreen=Snt({layer:"bottom",circuitJson:e,boardData:p,silkscreenColor:Ce,traceTextureResolution:qV}),o(w)}catch(S){console.error("Error processing geometry with Manifold in hook:",S),l(S.message||"An unknown error occurred while processing geometry in hook."),i(null),o(null)}finally{d(!1)}return()=>{h.current.forEach(y),h.current=[]}},[n,e,p]),{geoms:t,textures:r,pcbThickness:s,error:c,isLoading:u,boardData:p}},dCn=Wg,hCn=({material:n,color:e,side:t=dCn})=>n==="fr4"?new tE({color:e,side:t,metalness:0,roughness:.8,specularIntensity:.2,ior:1.45,sheen:0,clearcoat:0,transparent:!1,opacity:1,flatShading:!0}):new Zb({color:e,side:t,flatShading:!0,metalness:.1,roughness:.8,transparent:!0,opacity:.9});function pCn(n){const e=[];if(!n)return e;if(n.board&&n.board.geometry){const i=new Ra(n.board.geometry,hCn({material:n.board.material,color:n.board.color,side:Wg}));i.name="board-geom",e.push(i)}const t=i=>{i&&i.forEach(r=>{const o=new Ra(r.geometry,new Zb({color:r.color,side:Wg,flatShading:!0}));o.name=r.key,e.push(o)})};return t(n.platedHoles),t(n.smtPads),t(n.vias),t(n.copperPours),e}function fCn(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 cT(e.width,e.height),m=new fw({map:l,transparent:!0,side:Wg,depthWrite:!1}),_=new Ra(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+kv.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-kv.traces,!0,"trace");a&&i.push(a);const c=r(n.bottomSilkscreen,-t/2-.017,!0,"silkscreen");return c&&i.push(c),i}var mCn=({geometryMeshes:n,textureMeshes:e})=>{const{rootObject:t}=yb(),{visibility:i}=DL();return ce.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},_Cn="https://cdn.jsdelivr.net/npm/manifold-3d@3.2.1",yCn=({circuitJson:n,autoRotateDisabled:e,clickToInteractEnabled:t,onUserInteraction:i,children:r,onCameraControllerReady:o})=>{const s=snt(r),a=ce.useMemo(()=>n??s,[n,s]),[c,l]=ce.useState(null),[u,d]=ce.useState(null);ce.useEffect(()=>{if(window.ManifoldModule&&typeof window.ManifoldModule=="object"&&window.ManifoldModule.setup){l(window.ManifoldModule);return}const M=async Y=>{try{const X=await Y();X.setup(),window.ManifoldModule=X,l(X)}catch(X){console.error("Failed to initialize Manifold:",X),d(`Failed to initialize Manifold: ${X instanceof Error?X.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 X="ManifoldModule not found on window after script load.";console.error(X),d(X)}};window.addEventListener(C,U,{once:!0});const O=document.createElement("script");O.type="module",O.innerHTML=`
|
|
5158
|
+
at `+s}return e},ZV.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 hMn(n){const e=(0,cMn.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(ZM(o,s),{a:-1,b:0,c:0,d:1,e:0,f:0},ZM(-o,-s)),t=-t),t){const d=t*Math.PI/180;l.push(ZM(o,s),dnt(d),ZM(-o,-s))}let u=e;if(l.length>0){const d=unt(...l);u=e.map(h=>h.map(([p,m])=>{const{x:_,y}=cnt(d,{x:p,y:m});return[_,y]}))}return{textOutlines:u,xOffset:a,yOffset:c}}var pMn=vc(W5()),fMn=vc(wL()),mMn=vc(v4()),_Mn=vc(w4()),yMn=vc(y4()),hnt=25.4,gMn=hnt/1e3,xMn=/^\s*(-?\d*(?:\.\d+)?)(?:\s*(mm|mil|inch|in|"))?\s*$/i;function bMn(n){if(!n)return;const e=n.trim().toLowerCase();return e==='"'||e==="inch"?"in":e}function Vx(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(xMn);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(bMn(r)){case"mil":return o*gMn;case"in":return o*hnt;case"mm":case void 0:return o;default:return o}}function gT(n,e){const t=Vx(n);return t===void 0?e:t}function vMn(n,e){if(n.route.length<2)return;const t=n.route.map(l=>[Vx(l.x)??0,Vx(l.y)??0]),i=(0,pMn.line)(t),r=gT(n.stroke_width,.1),o=(0,fMn.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,_Mn.translate)([0,0,a],(0,mMn.extrudeLinear)({height:.012},o));return c=(0,yMn.colorize)([1,1,1],c),c}var wMn=vc(W5()),SMn=vc(wL()),EMn=vc(v4()),TMn=vc(w4()),MMn=vc(y4());function CMn(n,e){const t=Vx(n.x1)??0,i=Vx(n.y1)??0,r=Vx(n.x2)??0,o=Vx(n.y2)??0;if(t===r&&i===o)return;const s=[[t,i],[r,o]],a=(0,wMn.line)(s),c=gT(n.stroke_width,.1),l=(0,SMn.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,TMn.translate)([0,0,d],(0,EMn.extrudeLinear)({height:.012},l));return h=(0,MMn.colorize)([1,1,1],h),h}var AMn=vc(W5()),PMn=vc(v4()),RMn=vc(w4()),IMn=vc(y4()),pnt=vc(vL()),NMn=64;function kMn(n,e){const t=gT(n.width,0),i=gT(n.height,0);if(t<=0||i<=0)return;const r=Vx(n.center?.x)??0,o=Vx(n.center?.y)??0,s=e3(n),a=MI(t,i,typeof s=="string"?Vx(s):s),c=(x,b,w)=>(0,PMn.extrudeLinear)({height:.012},(0,AMn.roundedRectangle)({size:[x,b],roundRadius:w,segments:NMn})),l=n.is_filled??!0,u=n.has_stroke??!1,d=u?gT(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 S=MI(b,w,Math.max(a-d,0)),I=c(b,w,S);p=(0,pnt.subtract)(x,I)}else p=x}let m=h;if(p&&(m=m?(0,pnt.union)(m,p):p),!m)return;const _=n.layer==="bottom"?-1:1,y=_*e.pcbThickness/2+_*Yl*1.5;return m=(0,RMn.translate)([r,o,y],m),(0,IMn.colorize)([1,1,1],m)}var fnt=vc(W5()),OMn=vc(vL());function LMn(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),y=u[1]+m*l*Math.sign(t),x=Math.atan2(n[1]-y,n[0]-_),b=[],w=Math.max(2,Math.ceil(i*Math.abs(r)/(Math.PI*2)*4)),S=r/w;for(let I=1;I<w;I++){const A=x+S*I;b.push([_+c*Math.cos(A),y+c*Math.sin(A)])}return b}function mnt(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=LMn([o.x,o.y],[s.x,s.y],o.bulge,e);t.push(...a)}}return t}function _nt(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 DMn(n,e=16){let t=mnt(n.outer_ring,e);_nt(t)&&t.reverse();const i=(0,fnt.polygon)({points:t});if(!n.inner_rings||n.inner_rings.length===0)return i;const r=n.inner_rings.map(o=>{let s=mnt(o,e);return _nt(s)&&s.reverse(),(0,fnt.polygon)({points:s})});return r.length===0?i:(0,OMn.subtract)(i,r)}var zMn=64,$Mn=1,Zge=.05,ynt=(n,e,t,i)=>{const r=MI(n,e,i);if(r<=0)return(0,pp.cuboid)({center:[0,0,0],size:[n,e,t]});const o=(0,pp.roundedRectangle)({size:[n,e],roundRadius:r,segments:zMn}),s=(0,M4.extrudeLinear)({height:t},o);return(0,mw.translate)([0,0,-t/2],s)},gnt=["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"],FMn=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=ms(n).pcb_board.list()[0],this.plated_holes=ms(n).pcb_plated_hole.list(),this.holes=ms(n).pcb_hole.list(),this.pads=ms(n).pcb_smtpad.list(),this.traces=ms(n).pcb_trace.list(),this.pcb_vias=ms(n).pcb_via.list(),this.silkscreenTexts=ms(n).pcb_silkscreen_text.list(),this.silkscreenPaths=ms(n).pcb_silkscreen_path.list(),this.silkscreenLines=ms(n).pcb_silkscreen_line.list(),this.silkscreenRects=ms(n).pcb_silkscreen_rect.list(),this.pcb_cutouts=ms(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*$Mn;this.board.outline&&this.board.outline.length>0?(this.boardGeom=Gge({outline:this.board.outline},this.ctx.pcbThickness),this.boardClipGeom=Gge({outline:this.board.outline},n,{xyOutset:Zge})):(this.boardGeom=(0,pp.cuboid)({size:[this.board.width,this.board.height,this.ctx.pcbThickness],center:[this.board.center.x,this.board.center.y,0]}),this.boardClipGeom=(0,pp.cuboid)({size:[this.board.width+2*Zge,this.board.height+2*Zge,n],center:[this.board.center.x,this.board.center.y,0]})),this.state="processing_pads",this.currentIndex=0}goToNextState(){const n=gnt.indexOf(this.state);n!==-1&&(this.state=gnt[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,pp.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,mw.rotateZ)(o,e)}break;case"circle":e=(0,pp.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}Vge(i)&&(i=i.reverse());const r=(0,pp.polygon)({points:i});e=(0,M4.extrudeLinear)({height:t},r),e=(0,mw.translate)([0,0,-t/2],e);break}e&&(this.boardGeom=(0,My.subtract)(this.boardGeom,e))}processCopperPour(n){const e=n.layer==="bottom"?-1:1,t=e*this.ctx.pcbThickness/2+e*kv.copper;let i=null;if(n.shape==="rect"){let r=(0,pp.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,mw.rotateZ)(o,r)}i=(0,mw.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=DMn(r);i=(0,M4.extrudeLinear)({height:Yl},o),i=(0,mw.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}Vge(r)&&(r=r.reverse());const o=(0,pp.polygon)({points:r});i=(0,M4.extrudeLinear)({height:Yl},o),i=(0,mw.translate)([0,0,t],i)}if(i){this.boardClipGeom&&(i=(0,My.intersect)(this.boardClipGeom,i));const o=n.covered_with_solder_mask!==!1?XV[this.board.material]??Qd.fr4GreenSolderWithMask:Qd.copper,s=(0,dS.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,pp.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,pp.cylinder)({center:[n.x,n.y,0],radius:n.hole_diameter/2+Yl,height:this.ctx.pcbThickness*1.5}),e.dontCutBoard||(this.boardGeom=(0,My.subtract)(this.boardGeom,t)),this.padGeoms=this.padGeoms.map(r=>(0,dS.colorize)(Qd.copper,(0,My.subtract)(r,t)));const i=ant(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,My.union)((0,pp.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,pp.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,pp.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,My.union)((0,pp.cuboid)({center:[n.x,n.y,0],size:t?[r,s,this.ctx.pcbThickness*1.5]:[s,r,this.ctx.pcbThickness*1.5]}),(0,pp.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,pp.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,My.subtract)(this.boardGeom,a)),this.padGeoms=this.padGeoms.map(l=>(0,dS.colorize)(Qd.copper,(0,My.subtract)(l,a)));const c=ant(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,pp.cylinder)({center:[n.x,n.y,0],radius:n.hole_diameter/2+Yl,height:e});this.boardGeom=(0,My.subtract)(this.boardGeom,t),this.padGeoms=this.padGeoms.map(r=>(0,dS.colorize)(Qd.copper,(0,My.subtract)(r,t)));const i=(0,pp.cylinder)({center:[n.x,n.y,0],radius:n.hole_diameter/2+Yl/2,height:e});this.platedHoleGeoms=this.platedHoleGeoms.map(r=>(0,dS.colorize)(Qd.copper,(0,My.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,My.union)((0,pp.cuboid)({center:[n.x,n.y,0],size:[o,i,e]}),(0,pp.cylinder)({center:[n.x-o/2,n.y,0],radius:r,height:e}),(0,pp.cylinder)({center:[n.x+o/2,n.y,0],radius:r,height:e})):a=(0,My.union)((0,pp.cuboid)({center:[n.x,n.y,0],size:[t,o,e]}),(0,pp.cylinder)({center:[n.x,n.y-o/2,0],radius:r,height:e}),(0,pp.cylinder)({center:[n.x,n.y+o/2,0],radius:r,height:e})),s){const l=n.ccw_rotation*Math.PI/180;a=(0,mw.rotateZ)(l,a)}this.boardGeom=(0,My.subtract)(this.boardGeom,a),this.padGeoms=this.padGeoms.map(l=>(0,dS.colorize)(Qd.copper,(0,My.subtract)(l,a)));const c=(0,Wge.expand)({delta:-.02},a);this.platedHoleGeoms=this.platedHoleGeoms.map(l=>(0,dS.colorize)(Qd.copper,(0,My.subtract)(l,c)))}}processPad(n){const e=n.layer==="bottom"?-1:1,t=e*this.ctx.pcbThickness/2+e*kv.copper,i=e3(n);if(n.shape==="rect"){const r=ynt(n.width,n.height,Yl,i);let s=(0,mw.translate)([n.x,n.y,t],r);this.boardClipGeom&&(s=(0,My.intersect)(this.boardClipGeom,s)),s=(0,dS.colorize)(Qd.copper,s),this.padGeoms.push(s)}else if(n.shape==="rotated_rect"){let r=ynt(n.width,n.height,Yl,i);const o=n.ccw_rotation*Math.PI/180;r=(0,mw.rotateZ)(o,r);let a=(0,mw.translate)([n.x,n.y,t],r);this.boardClipGeom&&(a=(0,My.intersect)(this.boardClipGeom,a)),a=(0,dS.colorize)(Qd.copper,a),this.padGeoms.push(a)}else if(n.shape==="circle"){let r=(0,pp.cylinder)({center:[n.x,n.y,t],radius:n.radius,height:Yl});this.boardClipGeom&&(r=(0,My.intersect)(this.boardClipGeom,r)),r=(0,dS.colorize)(Qd.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*kv.traces,c=(0,pp.line)(t),l=(0,Wge.expand)({delta:r/2,corners:"round"},c);let u=(0,mw.translate)([0,0,a-Yl/2],(0,M4.extrudeLinear)({height:Yl},l));const d=t[0],h=t[t.length-1],p=this.getHoleToCut(d[0],d[1]);if(p){const y=(0,pp.cylinder)({center:[d[0],d[1],a],radius:p.diameter/2+Yl,height:Yl});u=(0,My.subtract)(u,y)}const m=this.getHoleToCut(h[0],h[1]);if(m){const y=(0,pp.cylinder)({center:[h[0],h[1],a],radius:m.diameter/2+Yl,height:Yl});u=(0,My.subtract)(u,y)}const _=XV[this.board.material]??Qd.fr4GreenSolderWithMask;this.boardClipGeom&&(u=(0,My.intersect)(this.boardClipGeom,u)),u=(0,dS.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}=hMn(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,pp.line)(o),a=n.font_size||.25,c=Math.min(Math.max(.01,a*.1),a*.05),l=(0,Wge.expand)({delta:c,corners:"round"},s);let u;n.layer==="bottom"?u=(0,mw.translate)([0,0,-this.ctx.pcbThickness/2-Yl],(0,M4.extrudeLinear)({height:.012},l)):u=(0,mw.translate)([0,0,this.ctx.pcbThickness/2+Yl],(0,M4.extrudeLinear)({height:.012},l)),u=(0,dS.colorize)([1,1,1],u),this.silkscreenTextGeoms.push(u)}}processSilkscreenPath(n){const e=vMn(n,this.ctx);e&&this.silkscreenPathGeoms.push(e)}processSilkscreenLine(n){const e=CMn(n,this.ctx);e&&this.silkscreenLineGeoms.push(e)}processSilkscreenRect(n){const e=kMn(n,this.ctx);e&&this.silkscreenRectGeoms.push(e)}finalize(){if(!this.boardGeom)return;const n=Hge[this.board.material]??Qd.fr4Green;this.boardGeom=(0,dS.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}},UMn=n=>{const[e,t]=ce.useState(null),i=ce.useRef(!1);return ce.useEffect(()=>{let r=!1;if(!n){t(null);return}if(!n.some(c=>c.type==="pcb_board")){t(null);return}const o=aMn(n);t(o);const s=new FMn(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},xnt=({error:n,cad_component:e})=>{const{rootObject:t}=yb(),[i,r]=ce.useState(!1),[o,s]=ce.useState(null),a=ce.useCallback(d=>{d?.mousePosition?(r(!0),s(d.mousePosition)):(r(!1),s(null))},[]),c=ce.useCallback(()=>{r(!1),s(null)},[]),l=ce.useMemo(()=>e?.position?[e.position.x,e.position.y,e.position.z].map(h=>Number.isNaN(h)?0:h):[0,0,0],[e]),u=ce.useMemo(()=>{const d=new cS;return d.position.fromArray(l),d},[l]);return ce.useEffect(()=>{if(t)return t.add(u),()=>{t.remove(u)}},[t,u]),re.jsxs(re.Fragment,{children:[re.jsxs(SL,{isHovered:i,onHover:a,onUnhover:c,object:u,children:[re.jsx(BMn,{parent:u}),re.jsx(E4,{parent:u,scale:[.1,.1,.1],color:"red",anchorX:"center",anchorY:"middle",depthOffset:-99999,children:`${n.toString().slice(0,50)}...`})]}),i&&o?re.jsx(Jtt,{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]})},BMn=({parent:n})=>{const e=ce.useMemo(()=>{const t=new Ra(new eE(.5,.5,.5),new Zb({depthTest:!1,transparent:!0,color:"red",opacity:.5}));return t.renderOrder=999999,t.rotation.fromArray([Math.PI/4,Math.PI/4,0]),t},[]);return ce.useEffect(()=>(n.add(e),()=>{n.remove(e)}),[n,e]),null};function jMn({stlUrl:n,stlData:e,mtlUrl:t,color:i,opacity:r=1}){const{rootObject:o}=yb(),[s,a]=ce.useState(null);ce.useEffect(()=>{const l=new Vdn;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=ce.useMemo(()=>{if(!s)return null;const l=new Zb({color:Array.isArray(i)?new Jr(i[0],i[1],i[2]):i,transparent:r!==1,opacity:r});return new Ra(s,l)},[s,i,r]);return ce.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 HMn({stlData:n,color:e,opacity:t=1,layerType:i}){const{visibility:r}=DL();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?re.jsx(jMn,{stlData:n,color:e,opacity:t}):null}var bnt=class extends So.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}},VMn=ce.forwardRef(({soup:n,circuitJson:e,children:t,autoRotateDisabled:i,clickToInteractEnabled:r,onUserInteraction:o,onCameraControllerReady:s},a)=>{const c=snt(t),l=ce.useMemo(()=>n??e??c,[n,e,c]),u=UMn(l),d=ce.useMemo(()=>{if(!l)return[5,-5,5];try{const y=ms(l).pcb_board.list()[0];if(!y)return[5,-5,5];const{width:x,height:b}=y;if(!x&&!b)return[5,-5,5];const w=5,S=Math.max(x,w),I=Math.max(b,w),A=Math.max(S,I);return[A/2,-A/2,A]}catch(y){return console.error(y),[5,-5,5]}},[l]),h=ce.useMemo(()=>{if(l)try{const y=ms(l).pcb_board.list()[0];return y?{width:y.width??0,height:y.height??0}:void 0}catch(y){console.error(y);return}},[l]),p=ce.useMemo(()=>{if(l)try{const y=ms(l).pcb_board.list()[0];return!y||!y.center?void 0:{x:y.center.x,y:y.center.y}}catch(y){console.error(y);return}},[l]),{stls:m}=eMn(u),_=ms(l).cad_component.list();return re.jsxs(ont,{ref:a,autoRotateDisabled:i,initialCameraPosition:d,clickToInteractEnabled:r,boardDimensions:h,boardCenter:p,onUserInteraction:o,onCameraControllerReady:s,children:[m.map(({stlData:y,color:x,layerType:b},w)=>re.jsx(HMn,{stlData:y,color:x,opacity:w===0?.95:1,layerType:b},`board-${w}`)),_.map(y=>re.jsx(bnt,{fallback:({error:x})=>re.jsx(xnt,{cad_component:y,error:x}),children:re.jsx(nnt,{cad_component:y,circuitJson:l},y.cad_component_id)},y.cad_component_id))]})});function t3(n){const e=new Of;if(e.setAttribute("position",new Ja(n.vertProperties,3)),e.setIndex(new ble(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 vnt(n){return n&&n.route_type==="wire"&&typeof n.layer=="string"&&typeof n.width=="number"}function wnt({layer:n,circuitJson:e,boardData:t,traceColor:i,traceTextureResolution:r}){const o=ms(e).pcb_trace.list(),s=ms(e).pcb_via.list(),a=ms(e).pcb_plated_hole.list(),c=o.filter(m=>m.route.some(_=>vnt(_)&&_.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 y=0;for(const x of m.route){if(!vnt(x)||x.layer!==n){_||h.stroke(),_=!0;continue}const b=x.x,w=x.y;y=x.width*r,h.lineWidth=y;const S=(b-t.center.x+t.width/2)*r,I=(-(w-t.center.y)+t.height/2)*r;_?(h.moveTo(S,I),_=!1):h.lineTo(S,I)}_||h.stroke()}),h.globalCompositeOperation="destination-out",h.fillStyle="black",s.forEach(m=>{const _=(m.x-t.center.x+t.width/2)*r,y=(-(m.y-t.center.y)+t.height/2)*r,x=m.outer_diameter/2*r;h.beginPath(),h.arc(_,y,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,y=(-(m.y-t.center.y)+t.height/2)*r,x=m.outer_diameter/2*r;h.beginPath(),h.arc(_,y,x,0,2*Math.PI,!1),h.fill()}}),h.globalCompositeOperation="source-over";const p=new Uje(l);return p.generateMipmaps=!0,p.minFilter=e2,p.magFilter=E1,p.anisotropy=16,p.needsUpdate=!0,p}var GMn=vc(ege());function Snt({layer:n,circuitJson:e,boardData:t,silkscreenColor:i="rgb(255,255,255)",traceTextureResolution:r}){const o=ms(e).pcb_silkscreen_text.list(),s=ms(e).pcb_silkscreen_path.list(),a=ms(e).pcb_silkscreen_line.list(),c=ms(e).pcb_silkscreen_rect.list(),l=o.filter(S=>S.layer===n),u=s.filter(S=>S.layer===n),d=a.filter(S=>S.layer===n),h=c.filter(S=>S.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 y=p.getContext("2d");if(!y)return null;n==="bottom"&&(y.translate(0,_),y.scale(1,-1)),y.strokeStyle=i,y.fillStyle=i;const x=S=>(S-t.center.x+t.width/2)*r,b=S=>(-(S-t.center.y)+t.height/2)*r;d.forEach(S=>{const I=Vx(S.x1)??0,A=Vx(S.y1)??0,R=Vx(S.x2)??0,M=Vx(S.y2)??0;I===R&&A===M||(y.beginPath(),y.lineWidth=gT(S.stroke_width,.1)*r,y.lineCap="round",y.moveTo(x(I),b(A)),y.lineTo(x(R),b(M)),y.stroke())}),u.forEach(S=>{S.route.length<2||(y.beginPath(),y.lineWidth=gT(S.stroke_width,.1)*r,y.lineCap="round",y.lineJoin="round",S.route.forEach((I,A)=>{const R=x(Vx(I.x)??0),M=b(Vx(I.y)??0);A===0?y.moveTo(R,M):y.lineTo(R,M)}),y.stroke())}),h.forEach(S=>{const I=gT(S.width,0),A=gT(S.height,0);if(I<=0||A<=0)return;const R=Vx(S.center?.x)??0,M=Vx(S.center?.y)??0,k=x(R),C=b(M),U=e3(S),O=typeof U=="string"?Vx(U):U,H=MI(I,A,O);y.save(),y.translate(k,C);const Y=I/2*r,X=A/2*r,K=Math.min(H*r,Y,X),J=S.has_stroke??!1,le=S.is_filled??!0,he=S.is_stroke_dashed??!1,ve=J?gT(S.stroke_width,.1)*r:0;if(((ae,de,Te,Ce,Oe)=>{if(y.beginPath(),Oe<=0)y.rect(ae,de,Te,Ce);else{const $e=Oe,Ae=ae+Te,se=de+Ce;y.moveTo(ae+$e,de),y.lineTo(Ae-$e,de),y.quadraticCurveTo(Ae,de,Ae,de+$e),y.lineTo(Ae,se-$e),y.quadraticCurveTo(Ae,se,Ae-$e,se),y.lineTo(ae+$e,se),y.quadraticCurveTo(ae,se,ae,se-$e),y.lineTo(ae,de+$e),y.quadraticCurveTo(ae,de,ae+$e,de),y.closePath()}})(-Y,-X,Y*2,X*2,K),le&&y.fill(),J&&ve>0){if(y.lineWidth=ve,he){const ae=Math.max(ve*2,1);y.setLineDash([ae,ae])}y.stroke(),he&&y.setLineDash([])}y.restore()}),l.forEach(S=>{const I=S.font_size||.25,A=Math.min(Math.max(.01,I*.1),I*.05)*r;y.lineWidth=A,y.lineCap="butt",y.lineJoin="miter";const R=(0,GMn.vectorText)({height:I*.45,input:S.text}),M=[];R.forEach(he=>{he.length===29?(M.push(he.slice(0,15)),M.push(he.slice(14,29))):he.length===17?(M.push(he.slice(0,10)),M.push(he.slice(9,17))):M.push(he)});const k=M.flat(),C={minX:k.length>0?Math.min(...k.map(he=>he[0])):0,maxX:k.length>0?Math.max(...k.map(he=>he[0])):0,minY:k.length>0?Math.min(...k.map(he=>he[1])):0,maxY:k.length>0?Math.max(...k.map(he=>he[1])):0},U=(C.minX+C.maxX)/2,O=(C.minY+C.maxY)/2;let H=-U,Y=-O;const X=S.anchor_alignment||"center";X.includes("left")?H=-C.minX:X.includes("right")&&(H=-C.maxX),X.includes("top")?Y=-C.maxY:X.includes("bottom")&&(Y=-C.minY);const K=[];let J=S.ccw_rotation??0;if(S.layer==="bottom"&&(K.push(ZM(U,O),{a:-1,b:0,c:0,d:1,e:0,f:0},ZM(-U,-O)),J=-J),J){const he=J*Math.PI/180;K.push(ZM(U,O),dnt(he),ZM(-U,-O))}const le=K.length>0?unt(...K):void 0;M.forEach(he=>{y.beginPath(),he.forEach((ve,oe)=>{let ae={x:ve[0],y:ve[1]};le&&(ae=cnt(le,ae));const de=ae.x+H+S.anchor_position.x,Te=ae.y+Y+S.anchor_position.y,Ce=x(de),Oe=b(Te);oe===0?y.moveTo(Ce,Oe):y.lineTo(Ce,Oe)}),y.stroke()})});const w=new Uje(p);return w.generateMipmaps=!0,w.minFilter=e2,w.magFilter=E1,w.anisotropy=16,w.needsUpdate=!0,w}function Ent({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 Tnt({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 YMn=64;function xT({Manifold:n,width:e,height:t,thickness:i,borderRadius:r}){const o=MI(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,YMn,!0).translate([u,d,0]))}),n.union(s)}function qMn({Manifold:n,pad:e,padBaseThickness:t}){if(e.shape==="rect"){const i=e3(e);return xT({Manifold:n,width:e.width,height:e.height,thickness:t,borderRadius:i})}else if(e.shape==="rotated_rect"){const i=e3(e);let r=xT({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 XMn(n){return(n.shape==="circle"||n.hole_shape==="circle")&&typeof n.hole_diameter=="number"}function WMn(n){return(n.shape==="pill"||n.hole_shape==="pill")&&typeof n.hole_width=="number"&&typeof n.hole_height=="number"}function KMn(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 ZMn(n,e,t,i){const r=[],o=ms(e).pcb_hole.list(),s=(a,c,l)=>{const u=xT({Manifold:n,width:a,height:c,thickness:l,borderRadius:Math.min(a,c)/2});return i.push(u),u};return o.forEach(a=>{if(XMn(a)){const c=Ent({Manifold:n,x:a.x,y:a.y,diameter:a.hole_diameter,thickness:t,segments:o2});i.push(c),r.push(c)}else if(WMn(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(KMn(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 QV=new Jr(...Qd.copper),Mnt=.05;function QMn(n,e,t,i,r){const o=[],s=ms(e).pcb_plated_hole.list(),a=[],c=[],l=(d,h,p)=>{const m=xT({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=Tnt({Manifold:n,x:d.x,y:d.y,outerDiameter:d.hole_diameter*1.02,thickness:t,zOffset:yT,segments:o2});i.push(p),o.push(p);const m=t+2*yT,_=n.cylinder(m,d.outer_diameter/2,d.outer_diameter/2,o2,!0);i.push(_);const y=n.cylinder(m*1.05,d.hole_diameter/2,d.hole_diameter/2,o2,!0);i.push(y);const x=_.subtract(y);i.push(x);const b=x.translate([d.x,d.y,0]);i.push(b);let w=b;if(r){const I=n.intersection([b,r]);i.push(I),w=I}c.push(w);const S=t3(w.getMesh());a.push({key:`ph-${d.pcb_plated_hole_id||h}`,geometry:S,color:QV})}else if(d.shape==="pill"){const p=d.hole_width,m=d.hole_height,_=.4,y=d.outer_width??p+_,x=d.outer_height??m+_,b=p+2*yT,w=m+2*yT,S=t*1.2;let I=l(b,w,S);if(d.ccw_rotation){const Y=I.rotate([0,0,d.ccw_rotation]);i.push(Y),I=Y}const A=I.translate([d.x,d.y,0]);i.push(A),o.push(A);const R=t+2*yT,M=l(y,x,R),k=l(p,m,R*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=t3(O.getMesh());a.push({key:`ph-${d.pcb_plated_hole_id||h}`,geometry:H,color:QV})}else if(d.shape==="pill_hole_with_rect_pad"){const p=d.hole_width,m=d.hole_height,_=d.hole_offset_x||0,y=d.hole_offset_y||0,x=d.rect_pad_width,b=d.rect_pad_height,w=e3(d),S=YV,I=p+2*yT,A=m+2*yT,R=t*1.2,k=l(I,A,R).translate([_,y,0]).translate([d.x,d.y,0]);i.push(k),o.push(k);const C=xT({Manifold:n,width:x,height:b,thickness:t-2*S-2*kv.copper+.1,borderRadius:w});i.push(C);const U=xT({Manifold:n,width:x,height:b,thickness:S,borderRadius:w}).translate([0,0,t/2/2+kv.copper]),O=xT({Manifold:n,width:x,height:b,thickness:S,borderRadius:w}).translate([0,0,-t/2/2-kv.copper]);i.push(U,O);const H=l(p,m,t*1.02).translate([_,y,0]);i.push(H);const Y=n.union([C,U,O,H]);i.push(Y);const X=l(Math.max(p-2*Mnt,.01),Math.max(m-2*Mnt,.01),t*1.2).translate([_,y,0]);i.push(X);const K=Y.subtract(X);i.push(K);const J=K.translate([d.x,d.y,0]);i.push(J);let le=J;if(r){const ve=n.intersection([J,r]);i.push(ve),le=ve}c.push(le);const he=t3(le.getMesh());a.push({key:`ph-${d.pcb_plated_hole_id||h}`,geometry:he,color:QV})}else if(d.shape==="circular_hole_with_rect_pad"){const p=d.hole_offset_x||0,m=d.hole_offset_y||0,_=Ent({Manifold:n,x:d.x+p,y:d.y+m,diameter:d.hole_diameter,thickness:t,segments:o2});i.push(_),o.push(_);const y=d.rect_pad_width??d.hole_diameter,x=d.rect_pad_height??d.hole_diameter,b=e3(d),w=YV,S=d.hole_diameter/2,I=xT({Manifold:n,width:y,height:x,thickness:t-2*w-2*kv.copper+.1,borderRadius:b});i.push(I);const A=xT({Manifold:n,width:y,height:x,thickness:w,borderRadius:b}).translate([0,0,t/2/2+kv.copper]),R=xT({Manifold:n,width:y,height:x,thickness:w,borderRadius:b}).translate([0,0,-t/2/2-kv.copper]);i.push(A,R);const M=n.cylinder(t*1.02,S,S,o2,!0).translate([p,m,0]);i.push(M);const k=n.union([I,A,R,M]);i.push(k);const C=n.cylinder(t*1.2,Math.max(S-Yl,.01),Math.max(S-Yl,.01),o2,!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 X=n.intersection([O,r]);i.push(X),H=X}c.push(H);const Y=t3(H.getMesh());a.push({key:`ph-${d.pcb_plated_hole_id||h}`,geometry:Y,color:QV})}});let u;return c.length>0&&(u=n.union(c),i.push(u)),{platedHoleBoardDrills:o,platedHoleCopperGeoms:a,platedHoleSubtractOp:u}}function JMn({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 eCn=new Jr(...Qd.copper);function tCn(n,e,t,i,r){const o=[],s=ms(e).pcb_via.list(),a=[];return s.forEach((c,l)=>{if(typeof c.outer_diameter=="number"){const u=Tnt({Manifold:n,x:c.x,y:c.y,outerDiameter:c.outer_diameter,thickness:t,zOffset:yT,segments:o2});i.push(u),o.push(u)}if(typeof c.outer_diameter=="number"&&typeof c.hole_diameter=="number"){const u=JMn({Manifold:n,x:c.x,y:c.y,outerDiameter:c.outer_diameter,holeDiameter:c.hole_diameter,thickness:t,zOffset:yT,segments:o2});i.push(u);let d=u;if(r){const p=n.intersection([u,r]);i.push(p),d=p}const h=t3(d.getMesh());a.push({key:`via-${c.pcb_via_id||l}`,geometry:h,color:eCn})}}),{viaBoardDrills:o,viaCopperGeoms:a}}var nCn=new Jr(...Qd.copper);function iCn(n,e,t,i,r,o){const s=[];return ms(e).pcb_smtpad.list().forEach((c,l)=>{const u=YV,d=c.layer==="bottom"?-t/2-kv.copper:t/2+kv.copper;let h=qMn({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 y=n.intersection([m,o]);i.push(y),m=y}const _=t3(m.getMesh());s.push({key:`smt_pad-${c.layer||"top"}-${c.pcb_smtpad_id||l}`,geometry:_,color:nCn})}}),{smtPadGeoms:s}}var rCn=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 oCn(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]);rCn(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 Qge=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 sCn(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),y=u[1]+m*l*Math.sign(t),x=Math.atan2(n[1]-y,n[0]-_),b=[],w=Math.max(2,Math.ceil(i*Math.abs(r)/(Math.PI*2)*4)),S=r/w;for(let I=1;I<w;I++){const A=x+S*I;b.push([_+c*Math.cos(A),y+c*Math.sin(A)])}return b}function Cnt(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=sCn([o.x,o.y],[s.x,s.y],o.bulge,e);t.push(...a)}}return t}function aCn(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=YV,p=(u.layer==="bottom"?-1:1)*(i/2+d/2+yT);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]);Qge(_)&&(_=_.reverse());const y=e.ofPolygons([_]);r.push(y),m=n.extrude(y,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 y=Cnt(_.outer_ring,o2);Qge(y)&&(y=y.reverse());const x=[y];if(_.inner_rings){const w=_.inner_rings.map(S=>{let I=Cnt(S,o2);return Qge(I)||(I=I.reverse()),I});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 y=u.covered_with_solder_mask!==!1?XV[o]??Qd.fr4GreenSolderWithMask:Qd.copper,x=new Jr(...y),b=t3(m.getMesh());c.push({key:`coppour-${u.pcb_copper_pour_id}`,geometry:b,color:x})}}return{copperPourGeoms:c}}var cCn=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 lCn(n,e,t,i,r){const o=[],s=ms(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,o2,!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]);cCn(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 uCn=(n,e)=>{const[t,i]=ce.useState(null),[r,o]=ce.useState(null),[s,a]=ce.useState(null),[c,l]=ce.useState(null),[u,d]=ce.useState(!0),h=ce.useRef([]),p=ce.useMemo(()=>{const m=ms(e).pcb_board.list();return m.length===0?null:m[0]},[e]);return ce.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,y=S=>{if(!(!S||typeof S.delete!="function"))try{S.delete()}catch(I){(!(I instanceof Error)||!I.message?.includes("Manifold instance already deleted"))&&console.warn("Failed to delete Manifold instance",I)}};h.current.forEach(y),h.current=[];let x=null;const b={},w={};try{const S=p.thickness||1.6;a(S);const{boardOp:I,outlineCrossSection:A}=oCn(m,_,p,S,h.current);let R=I;const k=S+2*1;let C=null;const U=.01;if(A){let Oe=A;if(U>0){const Ae=A.offset(U);h.current.push(Ae),Oe=Ae}const $e=m.extrude(Oe,k,void 0,void 0,void 0,!0);h.current.push($e),C=$e}else{const Oe=(p.width||0)+2*U,$e=(p.height||0)+2*U,Ae=m.cube([Oe,$e,k],!0);h.current.push(Ae);const se=Ae.translate([p.center.x,p.center.y,0]);h.current.push(se),C=se}const O=[];let H=null;const{nonPlatedHoleBoardDrills:Y}=ZMn(m,e,S,h.current);O.push(...Y);const{platedHoleBoardDrills:X,platedHoleCopperGeoms:K,platedHoleSubtractOp:J}=QMn(m,e,S,h.current,C);O.push(...X),b.platedHoles=K;const{viaBoardDrills:le,viaCopperGeoms:he}=tCn(m,e,S,h.current,C);if(O.push(...le),b.vias=he,O.length>0){H=m.union(O),h.current.push(H);const Oe=J?m.union([H,J]):H;h.current.push(Oe);const $e=R.subtract(Oe);if(h.current.push($e),R=$e,J){const Ae=J.subtract(H);h.current.push(Ae);const se=Ae.getMesh(),Se=t3(se);b.platedHoles=[{key:"plated-holes-union",geometry:Se,color:new Jr(Qd.copper[0],Qd.copper[1],Qd.copper[2])}]}}const{cutoutOps:ve}=lCn(m,_,e,S,h.current);if(ve.length>0){const Oe=m.union(ve);h.current.push(Oe);const $e=R.subtract(Oe);h.current.push($e),R=$e}if(x=R,x){const Oe=x.getMesh(),$e=t3(Oe),Ae=Hge[p.material]??Qd.fr4Green;b.board={geometry:$e,color:new Jr(Ae[0],Ae[1],Ae[2]),material:p.material}}const{smtPadGeoms:oe}=iCn(m,e,S,h.current,H,C);b.smtPads=oe;const{copperPourGeoms:ae}=aCn(m,_,e,S,h.current,p.material,H,C);b.copperPours=ae,i(b);const de=XV[p.material]??Qd.fr4GreenSolderWithMask,Te=`rgb(${Math.round(de[0]*255)}, ${Math.round(de[1]*255)}, ${Math.round(de[2]*255)})`;w.topTrace=wnt({layer:"top",circuitJson:e,boardData:p,traceColor:Te,traceTextureResolution:qV}),w.bottomTrace=wnt({layer:"bottom",circuitJson:e,boardData:p,traceColor:Te,traceTextureResolution:qV});const Ce="rgb(255,255,255)";w.topSilkscreen=Snt({layer:"top",circuitJson:e,boardData:p,silkscreenColor:Ce,traceTextureResolution:qV}),w.bottomSilkscreen=Snt({layer:"bottom",circuitJson:e,boardData:p,silkscreenColor:Ce,traceTextureResolution:qV}),o(w)}catch(S){console.error("Error processing geometry with Manifold in hook:",S),l(S.message||"An unknown error occurred while processing geometry in hook."),i(null),o(null)}finally{d(!1)}return()=>{h.current.forEach(y),h.current=[]}},[n,e,p]),{geoms:t,textures:r,pcbThickness:s,error:c,isLoading:u,boardData:p}},dCn=Wg,hCn=({material:n,color:e,side:t=dCn})=>n==="fr4"?new tE({color:e,side:t,metalness:0,roughness:.8,specularIntensity:.2,ior:1.45,sheen:0,clearcoat:0,transparent:!1,opacity:1,flatShading:!0}):new Zb({color:e,side:t,flatShading:!0,metalness:.1,roughness:.8,transparent:!0,opacity:.9});function pCn(n){const e=[];if(!n)return e;if(n.board&&n.board.geometry){const i=new Ra(n.board.geometry,hCn({material:n.board.material,color:n.board.color,side:Wg}));i.name="board-geom",e.push(i)}const t=i=>{i&&i.forEach(r=>{const o=new Ra(r.geometry,new Zb({color:r.color,side:Wg,flatShading:!0}));o.name=r.key,e.push(o)})};return t(n.platedHoles),t(n.smtPads),t(n.vias),t(n.copperPours),e}function fCn(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 cT(e.width,e.height),m=new fw({map:l,transparent:!0,side:Wg,depthWrite:!1}),_=new Ra(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+kv.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-kv.traces,!0,"trace");a&&i.push(a);const c=r(n.bottomSilkscreen,-t/2-.017,!0,"silkscreen");return c&&i.push(c),i}var mCn=({geometryMeshes:n,textureMeshes:e})=>{const{rootObject:t}=yb(),{visibility:i}=DL();return ce.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},_Cn="https://cdn.jsdelivr.net/npm/manifold-3d@3.2.1",yCn=({circuitJson:n,autoRotateDisabled:e,clickToInteractEnabled:t,onUserInteraction:i,children:r,onCameraControllerReady:o})=>{const s=snt(r),a=ce.useMemo(()=>n??s,[n,s]),[c,l]=ce.useState(null),[u,d]=ce.useState(null);ce.useEffect(()=>{if(window.ManifoldModule&&typeof window.ManifoldModule=="object"&&window.ManifoldModule.setup){l(window.ManifoldModule);return}const M=async Y=>{try{const X=await Y();X.setup(),window.ManifoldModule=X,l(X)}catch(X){console.error("Failed to initialize Manifold:",X),d(`Failed to initialize Manifold: ${X instanceof Error?X.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 X="ManifoldModule not found on window after script load.";console.error(X),d(X)}};window.addEventListener(C,U,{once:!0});const O=document.createElement("script");O.type="module",O.innerHTML=`
|
|
5159
5159
|
try {
|
|
5160
5160
|
const { default: ManifoldModule } = await import('${_Cn}/manifold.js');
|
|
5161
5161
|
window.ManifoldModule = ManifoldModule;
|
|
@@ -5164,7 +5164,7 @@ try {
|
|
|
5164
5164
|
} finally {
|
|
5165
5165
|
window.dispatchEvent(new CustomEvent('${C}'));
|
|
5166
5166
|
}
|
|
5167
|
-
`.trim();const H=Y=>{const X="Failed to load Manifold loader script.";console.error(X,Y),d(X),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:y,boardData:x}=uCn(c,a),b=ce.useMemo(()=>pCn(h),[h]),w=ce.useMemo(()=>fCn(p,x,m),[p,x,m]),S=ce.useMemo(()=>ms(a).cad_component.list(),[a]),I=ce.useMemo(()=>{if(!x)return;const{width:M=0,height:k=0}=x;return{width:M,height:k}},[x]),A=ce.useMemo(()=>{if(!x)return;const{center:M}=x;if(M)return{x:M.x,y:M.y}},[x]),R=ce.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?re.jsxs("div",{style:{color:"red",padding:"1em",border:"1px solid red",margin:"1em"},children:["Error: ",u]}):c?_?re.jsxs("div",{style:{color:"red",padding:"1em",border:"1px solid red",margin:"1em"},children:["Error: ",_]}):y?re.jsx("div",{style:{padding:"1em"},children:"Processing board geometry..."}):re.jsxs(ont,{initialCameraPosition:R,autoRotateDisabled:e,clickToInteractEnabled:t,boardDimensions:I,boardCenter:A,onUserInteraction:i,onCameraControllerReady:o,children:[re.jsx(mCn,{geometryMeshes:b,textureMeshes:w}),S.map(M=>re.jsx(bnt,{fallback:({error:k})=>re.jsx(xnt,{cad_component:M,error:k}),children:re.jsx(nnt,{cad_component:M,circuitJson:a})},M.cad_component_id))]}):re.jsx("div",{style:{padding:"1em"},children:"Loading Manifold module..."})},gCn=yCn,xCn=({containerRef:n})=>{const[e,t]=ce.useState(!1),[i,r]=ce.useState({x:0,y:0}),o=ce.useRef(null),s=ce.useRef(null),a=ce.useRef(null),c=ce.useRef(!1),l=()=>{a.current!==null&&(clearTimeout(a.current),a.current=null)},u=ce.useCallback(y=>{y.preventDefault();const x=typeof y.clientX=="number"?y.clientX:0,b=typeof y.clientY=="number"?y.clientY:0;if(c.current){c.current=!1;return}if(!s.current)return;const{x:w,y:S}=s.current,I=Math.abs(x-w),A=Math.abs(b-S),R=10;if(I>R||A>R){s.current=null;return}r({x,y:b}),t(!0),s.current=null},[r,t]),d=ce.useCallback(y=>{if(y.touches.length===1){const x=y.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=ce.useCallback(y=>{if(!s.current||y.touches.length!==1)return;const x=y.touches[0];if(x){const b=Math.abs(x.clientX-s.current.x),w=Math.abs(x.clientY-s.current.y),S=10;(b>S||w>S)&&(s.current=null,l())}else s.current=null,l()},[]),p=ce.useCallback(()=>{l(),setTimeout(()=>{s.current&&(s.current=null)},0)},[]),m=ce.useCallback(y=>{const x=y.target;o.current&&!o.current.contains(x)&&t(!1)},[]);return ce.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:y=>{y.button===2?s.current={x:y.clientX,y:y.clientY}:s.current=null},onContextMenu:u,onTouchStart:d,onTouchMove:h,onTouchEnd:p},setMenuVisible:t}},bCn=()=>ce.useCallback(()=>{const n=window.__TSCIRCUIT_THREE_OBJECT;if(!n)return;new lHe().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 xd(n,e,{checkForDefaultPrevented:t=!0}={}){return function(r){if(n?.(r),t===!1||!r.defaultPrevented)return e?.(r)}}function Ant(n,e){if(typeof n=="function")return n(e);n!=null&&(n.current=e)}function JV(...n){return e=>{let t=!1;const i=n.map(r=>{const o=Ant(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():Ant(n[r],null)}}}}function _w(...n){return ce.useCallback(JV(...n),n)}function $L(n,e=[]){let t=[];function i(o,s){const a=ce.createContext(s),c=t.length;t=[...t,s];const l=d=>{const{scope:h,children:p,...m}=d,_=h?.[n]?.[c]||a,y=ce.useMemo(()=>m,Object.values(m));return re.jsx(_.Provider,{value:y,children:p})};l.displayName=o+"Provider";function u(d,h){const p=h?.[n]?.[c]||a,m=ce.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=>ce.createContext(s));return function(a){const c=a?.[n]||o;return ce.useMemo(()=>({[`__scope${n}`]:{...a,[n]:c}}),[a,c])}};return r.scopeName=n,[i,vCn(r,...e)]}function vCn(...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 ce.useMemo(()=>({[`__scope${e.scopeName}`]:s}),[s])}};return t.scopeName=e.scopeName,t}var QM=globalThis?.document?ce.useLayoutEffect:()=>{},wCn=Nz[" useInsertionEffect ".trim().toString()]||QM;function Jge({prop:n,defaultProp:e,onChange:t=()=>{},caller:i}){const[r,o,s]=SCn({defaultProp:e,onChange:t}),a=n!==void 0,c=a?n:r;{const u=ce.useRef(n!==void 0);ce.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=ce.useCallback(u=>{if(a){const d=ECn(u)?u(n):u;d!==n&&s.current?.(d)}else o(u)},[a,n,o,s]);return[c,l]}function SCn({defaultProp:n,onChange:e}){const[t,i]=ce.useState(n),r=ce.useRef(t),o=ce.useRef(e);return wCn(()=>{o.current=e},[e]),ce.useEffect(()=>{r.current!==t&&(o.current?.(t),r.current=t)},[t,r]),[t,i,o]}function ECn(n){return typeof n=="function"}function eG(n){const e=TCn(n),t=ce.forwardRef((i,r)=>{const{children:o,...s}=i,a=ce.Children.toArray(o),c=a.find(CCn);if(c){const l=c.props.children,u=a.map(d=>d===c?ce.Children.count(l)>1?ce.Children.only(null):ce.isValidElement(l)?l.props.children:null:d);return re.jsx(e,{...s,ref:r,children:ce.isValidElement(l)?ce.cloneElement(l,void 0,u):null})}return re.jsx(e,{...s,ref:r,children:o})});return t.displayName=`${n}.Slot`,t}function TCn(n){const e=ce.forwardRef((t,i)=>{const{children:r,...o}=t;if(ce.isValidElement(r)){const s=PCn(r),a=ACn(o,r.props);return r.type!==ce.Fragment&&(a.ref=i?JV(i,s):s),ce.cloneElement(r,a)}return ce.Children.count(r)>1?ce.Children.only(null):null});return e.displayName=`${n}.SlotClone`,e}var MCn=Symbol("radix.slottable");function CCn(n){return ce.isValidElement(n)&&typeof n.type=="function"&&"__radixId"in n.type&&n.type.__radixId===MCn}function ACn(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 PCn(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 RCn=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Ov=RCn.reduce((n,e)=>{const t=eG(`Primitive.${e}`),i=ce.forwardRef((r,o)=>{const{asChild:s,...a}=r,c=s?t:e;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),re.jsx(c,{...a,ref:o})});return i.displayName=`Primitive.${e}`,{...n,[e]:i}},{});function Pnt(n,e){n&&JO.flushSync(()=>n.dispatchEvent(e))}function Rnt(n){const e=n+"CollectionProvider",[t,i]=$L(e),[r,o]=t(e,{collectionRef:{current:null},itemMap:new Map}),s=_=>{const{scope:y,children:x}=_,b=So.useRef(null),w=So.useRef(new Map).current;return re.jsx(r,{scope:y,itemMap:w,collectionRef:b,children:x})};s.displayName=e;const a=n+"CollectionSlot",c=eG(a),l=So.forwardRef((_,y)=>{const{scope:x,children:b}=_,w=o(a,x),S=_w(y,w.collectionRef);return re.jsx(c,{ref:S,children:b})});l.displayName=a;const u=n+"CollectionItemSlot",d="data-radix-collection-item",h=eG(u),p=So.forwardRef((_,y)=>{const{scope:x,children:b,...w}=_,S=So.useRef(null),I=_w(y,S),A=o(u,x);return So.useEffect(()=>(A.itemMap.set(S,{ref:S,...w}),()=>void A.itemMap.delete(S))),re.jsx(h,{[d]:"",ref:I,children:b})});p.displayName=u;function m(_){const y=o(n+"CollectionConsumer",_);return So.useCallback(()=>{const b=y.collectionRef.current;if(!b)return[];const w=Array.from(b.querySelectorAll(`[${d}]`));return Array.from(y.itemMap.values()).sort((A,R)=>w.indexOf(A.ref.current)-w.indexOf(R.ref.current))},[y.collectionRef,y.itemMap])}return[{Provider:s,Slot:l,ItemSlot:p},m,i]}var ICn=ce.createContext(void 0);function Int(n){const e=ce.useContext(ICn);return n||e||"ltr"}function bT(n){const e=ce.useRef(n);return ce.useEffect(()=>{e.current=n}),ce.useMemo(()=>(...t)=>e.current?.(...t),[])}function NCn(n,e=globalThis?.document){const t=bT(n);ce.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 kCn="DismissableLayer",exe="dismissableLayer.update",OCn="dismissableLayer.pointerDownOutside",LCn="dismissableLayer.focusOutside",Nnt,knt=ce.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),Ont=ce.forwardRef((n,e)=>{const{disableOutsidePointerEvents:t=!1,onEscapeKeyDown:i,onPointerDownOutside:r,onFocusOutside:o,onInteractOutside:s,onDismiss:a,...c}=n,l=ce.useContext(knt),[u,d]=ce.useState(null),h=u?.ownerDocument??globalThis?.document,[,p]=ce.useState({}),m=_w(e,R=>d(R)),_=Array.from(l.layers),[y]=[...l.layersWithOutsidePointerEventsDisabled].slice(-1),x=_.indexOf(y),b=u?_.indexOf(u):-1,w=l.layersWithOutsidePointerEventsDisabled.size>0,S=b>=x,I=$Cn(R=>{const M=R.target,k=[...l.branches].some(C=>C.contains(M));!S||k||(r?.(R),s?.(R),R.defaultPrevented||a?.())},h),A=FCn(R=>{const M=R.target;[...l.branches].some(C=>C.contains(M))||(o?.(R),s?.(R),R.defaultPrevented||a?.())},h);return NCn(R=>{b===l.layers.size-1&&(i?.(R),!R.defaultPrevented&&a&&(R.preventDefault(),a()))},h),ce.useEffect(()=>{if(u)return t&&(l.layersWithOutsidePointerEventsDisabled.size===0&&(Nnt=h.body.style.pointerEvents,h.body.style.pointerEvents="none"),l.layersWithOutsidePointerEventsDisabled.add(u)),l.layers.add(u),Lnt(),()=>{t&&l.layersWithOutsidePointerEventsDisabled.size===1&&(h.body.style.pointerEvents=Nnt)}},[u,h,t,l]),ce.useEffect(()=>()=>{u&&(l.layers.delete(u),l.layersWithOutsidePointerEventsDisabled.delete(u),Lnt())},[u,l]),ce.useEffect(()=>{const R=()=>p({});return document.addEventListener(exe,R),()=>document.removeEventListener(exe,R)},[]),re.jsx(Ov.div,{...c,ref:m,style:{pointerEvents:w?S?"auto":"none":void 0,...n.style},onFocusCapture:xd(n.onFocusCapture,A.onFocusCapture),onBlurCapture:xd(n.onBlurCapture,A.onBlurCapture),onPointerDownCapture:xd(n.onPointerDownCapture,I.onPointerDownCapture)})});Ont.displayName=kCn;var DCn="DismissableLayerBranch",zCn=ce.forwardRef((n,e)=>{const t=ce.useContext(knt),i=ce.useRef(null),r=_w(e,i);return ce.useEffect(()=>{const o=i.current;if(o)return t.branches.add(o),()=>{t.branches.delete(o)}},[t.branches]),re.jsx(Ov.div,{...n,ref:r})});zCn.displayName=DCn;function $Cn(n,e=globalThis?.document){const t=bT(n),i=ce.useRef(!1),r=ce.useRef(()=>{});return ce.useEffect(()=>{const o=a=>{if(a.target&&!i.current){let c=function(){Dnt(OCn,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 FCn(n,e=globalThis?.document){const t=bT(n),i=ce.useRef(!1);return ce.useEffect(()=>{const r=o=>{o.target&&!i.current&&Dnt(LCn,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 Lnt(){const n=new CustomEvent(exe);document.dispatchEvent(n)}function Dnt(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?Pnt(r,o):r.dispatchEvent(o)}var txe=0;function UCn(){ce.useEffect(()=>{const n=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",n[0]??znt()),document.body.insertAdjacentElement("beforeend",n[1]??znt()),txe++,()=>{txe===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(e=>e.remove()),txe--}},[])}function znt(){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 nxe="focusScope.autoFocusOnMount",ixe="focusScope.autoFocusOnUnmount",$nt={bubbles:!1,cancelable:!0},BCn="FocusScope",Fnt=ce.forwardRef((n,e)=>{const{loop:t=!1,trapped:i=!1,onMountAutoFocus:r,onUnmountAutoFocus:o,...s}=n,[a,c]=ce.useState(null),l=bT(r),u=bT(o),d=ce.useRef(null),h=_w(e,_=>c(_)),p=ce.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;ce.useEffect(()=>{if(i){let _=function(w){if(p.paused||!a)return;const S=w.target;a.contains(S)?d.current=S:JM(d.current,{select:!0})},y=function(w){if(p.paused||!a)return;const S=w.relatedTarget;S!==null&&(a.contains(S)||JM(d.current,{select:!0}))},x=function(w){if(document.activeElement===document.body)for(const I of w)I.removedNodes.length>0&&JM(a)};document.addEventListener("focusin",_),document.addEventListener("focusout",y);const b=new MutationObserver(x);return a&&b.observe(a,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",_),document.removeEventListener("focusout",y),b.disconnect()}}},[i,a,p.paused]),ce.useEffect(()=>{if(a){jnt.add(p);const _=document.activeElement;if(!a.contains(_)){const x=new CustomEvent(nxe,$nt);a.addEventListener(nxe,l),a.dispatchEvent(x),x.defaultPrevented||(jCn(qCn(Unt(a)),{select:!0}),document.activeElement===_&&JM(a))}return()=>{a.removeEventListener(nxe,l),setTimeout(()=>{const x=new CustomEvent(ixe,$nt);a.addEventListener(ixe,u),a.dispatchEvent(x),x.defaultPrevented||JM(_??document.body,{select:!0}),a.removeEventListener(ixe,u),jnt.remove(p)},0)}}},[a,l,u,p]);const m=ce.useCallback(_=>{if(!t&&!i||p.paused)return;const y=_.key==="Tab"&&!_.altKey&&!_.ctrlKey&&!_.metaKey,x=document.activeElement;if(y&&x){const b=_.currentTarget,[w,S]=HCn(b);w&&S?!_.shiftKey&&x===S?(_.preventDefault(),t&&JM(w,{select:!0})):_.shiftKey&&x===w&&(_.preventDefault(),t&&JM(S,{select:!0})):x===b&&_.preventDefault()}},[t,i,p.paused]);return re.jsx(Ov.div,{tabIndex:-1,...s,ref:h,onKeyDown:m})});Fnt.displayName=BCn;function jCn(n,{select:e=!1}={}){const t=document.activeElement;for(const i of n)if(JM(i,{select:e}),document.activeElement!==t)return}function HCn(n){const e=Unt(n),t=Bnt(e,n),i=Bnt(e.reverse(),n);return[t,i]}function Unt(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 Bnt(n,e){for(const t of n)if(!VCn(t,{upTo:e}))return t}function VCn(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 GCn(n){return n instanceof HTMLInputElement&&"select"in n}function JM(n,{select:e=!1}={}){if(n&&n.focus){const t=document.activeElement;n.focus({preventScroll:!0}),n!==t&&GCn(n)&&e&&n.select()}}var jnt=YCn();function YCn(){let n=[];return{add(e){const t=n[0];e!==t&&t?.pause(),n=Hnt(n,e),n.unshift(e)},remove(e){n=Hnt(n,e),n[0]?.resume()}}}function Hnt(n,e){const t=[...n],i=t.indexOf(e);return i!==-1&&t.splice(i,1),t}function qCn(n){return n.filter(e=>e.tagName!=="A")}var XCn=Nz[" useId ".trim().toString()]||(()=>{}),WCn=0;function FL(n){const[e,t]=ce.useState(XCn());return QM(()=>{t(i=>i??String(WCn++))},[n]),e?`radix-${e}`:""}var KCn=["top","right","bottom","left"],eC=Math.min,hS=Math.max,tG=Math.round,nG=Math.floor,vT=n=>({x:n,y:n}),ZCn={left:"right",right:"left",bottom:"top",top:"bottom"},QCn={start:"end",end:"start"};function rxe(n,e,t){return hS(n,eC(e,t))}function n3(n,e){return typeof n=="function"?n(e):n}function i3(n){return n.split("-")[0]}function CI(n){return n.split("-")[1]}function oxe(n){return n==="x"?"y":"x"}function sxe(n){return n==="y"?"height":"width"}var JCn=new Set(["top","bottom"]);function wT(n){return JCn.has(i3(n))?"y":"x"}function axe(n){return oxe(wT(n))}function eAn(n,e,t){t===void 0&&(t=!1);const i=CI(n),r=axe(n),o=sxe(r);let s=r==="x"?i===(t?"end":"start")?"right":"left":i==="start"?"bottom":"top";return e.reference[o]>e.floating[o]&&(s=iG(s)),[s,iG(s)]}function tAn(n){const e=iG(n);return[cxe(n),e,cxe(e)]}function cxe(n){return n.replace(/start|end/g,e=>QCn[e])}var Vnt=["left","right"],Gnt=["right","left"],nAn=["top","bottom"],iAn=["bottom","top"];function rAn(n,e,t){switch(n){case"top":case"bottom":return t?e?Gnt:Vnt:e?Vnt:Gnt;case"left":case"right":return e?nAn:iAn;default:return[]}}function oAn(n,e,t,i){const r=CI(n);let o=rAn(i3(n),t==="start",i);return r&&(o=o.map(s=>s+"-"+r),e&&(o=o.concat(o.map(cxe)))),o}function iG(n){return n.replace(/left|right|bottom|top/g,e=>ZCn[e])}function sAn(n){return{top:0,right:0,bottom:0,left:0,...n}}function Ynt(n){return typeof n!="number"?sAn(n):{top:n,right:n,bottom:n,left:n}}function rG(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 qnt(n,e,t){let{reference:i,floating:r}=n;const o=wT(e),s=axe(e),a=sxe(s),c=i3(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(CI(e)){case"start":p[s]-=h*(t&&l?-1:1);break;case"end":p[s]+=h*(t&&l?-1:1);break}return p}var aAn=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}=qnt(l,i,c),h=i,p={},m=0;for(let _=0;_<a.length;_++){const{name:y,fn:x}=a[_],{x:b,y:w,data:S,reset:I}=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,[y]:{...p[y],...S}},I&&m<=50&&(m++,typeof I=="object"&&(I.placement&&(h=I.placement),I.rects&&(l=I.rects===!0?await s.getElementRects({reference:n,floating:e,strategy:r}):I.rects),{x:u,y:d}=qnt(l,h,c)),_=-1)}return{x:u,y:d,placement:h,strategy:r,middlewareData:p}};async function UL(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}=n3(e,n),m=Ynt(p),y=a[h?d==="floating"?"reference":"floating":d],x=rG(await o.getClippingRect({element:(t=await(o.isElement==null?void 0:o.isElement(y)))==null||t?y:y.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)),S=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},I=rG(o.convertOffsetParentRelativeRectToViewportRelativeRect?await o.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:b,offsetParent:w,strategy:c}):b);return{top:(x.top-I.top+m.top)/S.y,bottom:(I.bottom-x.bottom+m.bottom)/S.y,left:(x.left-I.left+m.left)/S.x,right:(I.right-x.right+m.right)/S.x}}var cAn=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}=n3(n,e)||{};if(l==null)return{};const d=Ynt(u),h={x:t,y:i},p=axe(r),m=sxe(p),_=await s.getDimensions(l),y=p==="y",x=y?"top":"left",b=y?"bottom":"right",w=y?"clientHeight":"clientWidth",S=o.reference[m]+o.reference[p]-h[p]-o.floating[m],I=h[p]-o.reference[p],A=await(s.getOffsetParent==null?void 0:s.getOffsetParent(l));let R=A?A[w]:0;(!R||!await(s.isElement==null?void 0:s.isElement(A)))&&(R=a.floating[w]||o.floating[m]);const M=S/2-I/2,k=R/2-_[m]/2-1,C=eC(d[x],k),U=eC(d[b],k),O=C,H=R-_[m]-U,Y=R/2-_[m]/2+M,X=rxe(O,Y,H),K=!c.arrow&&CI(r)!=null&&Y!==X&&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]:X,centerOffset:Y-X-J,...K&&{alignmentOffset:J}},reset:K}}}),lAn=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,...y}=n3(n,e);if((t=o.arrow)!=null&&t.alignmentOffset)return{};const x=i3(r),b=wT(a),w=i3(a)===a,S=await(c.isRTL==null?void 0:c.isRTL(l.floating)),I=h||(w||!_?[iG(a)]:tAn(a)),A=m!=="none";!h&&A&&I.push(...oAn(a,_,m,S));const R=[a,...I],M=await UL(e,y),k=[];let C=((i=o.flip)==null?void 0:i.overflows)||[];if(u&&k.push(M[x]),d){const Y=eAn(r,s,S);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,X=R[Y];if(X&&(!(d==="alignment"?b!==wT(X):!1)||C.every(le=>wT(le.placement)===b?le.overflows[0]>0:!0)))return{data:{index:Y,overflows:C},reset:{placement:X}};let K=(O=C.filter(J=>J.overflows[0]<=0).sort((J,le)=>J.overflows[1]-le.overflows[1])[0])==null?void 0:O.placement;if(!K)switch(p){case"bestFit":{var H;const J=(H=C.filter(le=>{if(A){const he=wT(le.placement);return he===b||he==="y"}return!0}).map(le=>[le.placement,le.overflows.filter(he=>he>0).reduce((he,ve)=>he+ve,0)]).sort((le,he)=>le[1]-he[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 Xnt(n,e){return{top:n.top-e.height,right:n.right-e.width,bottom:n.bottom-e.height,left:n.left-e.width}}function Wnt(n){return KCn.some(e=>n[e]>=0)}var uAn=function(n){return n===void 0&&(n={}),{name:"hide",options:n,async fn(e){const{rects:t}=e,{strategy:i="referenceHidden",...r}=n3(n,e);switch(i){case"referenceHidden":{const o=await UL(e,{...r,elementContext:"reference"}),s=Xnt(o,t.reference);return{data:{referenceHiddenOffsets:s,referenceHidden:Wnt(s)}}}case"escaped":{const o=await UL(e,{...r,altBoundary:!0}),s=Xnt(o,t.floating);return{data:{escapedOffsets:s,escaped:Wnt(s)}}}default:return{}}}}},Knt=new Set(["left","top"]);async function dAn(n,e){const{placement:t,platform:i,elements:r}=n,o=await(i.isRTL==null?void 0:i.isRTL(r.floating)),s=i3(t),a=CI(t),c=wT(t)==="y",l=Knt.has(s)?-1:1,u=o&&c?-1:1,d=n3(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 hAn=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 dAn(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}}}}},pAn=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:y=>{let{x,y:b}=y;return{x,y:b}}},...c}=n3(n,e),l={x:t,y:i},u=await UL(e,c),d=wT(i3(r)),h=oxe(d);let p=l[h],m=l[d];if(o){const y=h==="y"?"top":"left",x=h==="y"?"bottom":"right",b=p+u[y],w=p-u[x];p=rxe(b,p,w)}if(s){const y=d==="y"?"top":"left",x=d==="y"?"bottom":"right",b=m+u[y],w=m-u[x];m=rxe(b,m,w)}const _=a.fn({...e,[h]:p,[d]:m});return{..._,data:{x:_.x-t,y:_.y-i,enabled:{[h]:o,[d]:s}}}}}},fAn=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}=n3(n,e),u={x:t,y:i},d=wT(r),h=oxe(d);let p=u[h],m=u[d];const _=n3(a,e),y=typeof _=="number"?{mainAxis:_,crossAxis:0}:{mainAxis:0,crossAxis:0,..._};if(c){const w=h==="y"?"height":"width",S=o.reference[h]-o.floating[w]+y.mainAxis,I=o.reference[h]+o.reference[w]-y.mainAxis;p<S?p=S:p>I&&(p=I)}if(l){var x,b;const w=h==="y"?"width":"height",S=Knt.has(i3(r)),I=o.reference[d]-o.floating[w]+(S&&((x=s.offset)==null?void 0:x[d])||0)+(S?0:y.crossAxis),A=o.reference[d]+o.reference[w]+(S?0:((b=s.offset)==null?void 0:b[d])||0)-(S?y.crossAxis:0);m<I?m=I:m>A&&(m=A)}return{[h]:p,[d]:m}}}},mAn=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}=n3(n,e),u=await UL(e,l),d=i3(r),h=CI(r),p=wT(r)==="y",{width:m,height:_}=o.floating;let y,x;d==="top"||d==="bottom"?(y=d,x=h===(await(s.isRTL==null?void 0:s.isRTL(a.floating))?"start":"end")?"left":"right"):(x=d,y=h==="end"?"top":"bottom");const b=_-u.top-u.bottom,w=m-u.left-u.right,S=eC(_-u[y],b),I=eC(m-u[x],w),A=!e.middlewareData.shift;let R=S,M=I;if((t=e.middlewareData.shift)!=null&&t.enabled.x&&(M=w),(i=e.middlewareData.shift)!=null&&i.enabled.y&&(R=b),A&&!h){const C=hS(u.left,0),U=hS(u.right,0),O=hS(u.top,0),H=hS(u.bottom,0);p?M=m-2*(C!==0||U!==0?C+U:hS(u.left,u.right)):R=_-2*(O!==0||H!==0?O+H:hS(u.top,u.bottom))}await c({...e,availableWidth:M,availableHeight:R});const k=await s.getDimensions(a.floating);return m!==k.width||_!==k.height?{reset:{rects:!0}}:{}}}};function oG(){return typeof window<"u"}function AI(n){return Znt(n)?(n.nodeName||"").toLowerCase():"#document"}function pS(n){var e;return(n==null||(e=n.ownerDocument)==null?void 0:e.defaultView)||window}function ST(n){var e;return(e=(Znt(n)?n.ownerDocument:n.document)||window.document)==null?void 0:e.documentElement}function Znt(n){return oG()?n instanceof Node||n instanceof pS(n).Node:!1}function oE(n){return oG()?n instanceof Element||n instanceof pS(n).Element:!1}function ET(n){return oG()?n instanceof HTMLElement||n instanceof pS(n).HTMLElement:!1}function Qnt(n){return!oG()||typeof ShadowRoot>"u"?!1:n instanceof ShadowRoot||n instanceof pS(n).ShadowRoot}var _An=new Set(["inline","contents"]);function BL(n){const{overflow:e,overflowX:t,overflowY:i,display:r}=sE(n);return/auto|scroll|overlay|hidden|clip/.test(e+i+t)&&!_An.has(r)}var yAn=new Set(["table","td","th"]);function gAn(n){return yAn.has(AI(n))}var xAn=[":popover-open",":modal"];function sG(n){return xAn.some(e=>{try{return n.matches(e)}catch{return!1}})}var bAn=["transform","translate","scale","rotate","perspective"],vAn=["transform","translate","scale","rotate","perspective","filter"],wAn=["paint","layout","strict","content"];function lxe(n){const e=uxe(),t=oE(n)?sE(n):n;return bAn.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)||vAn.some(i=>(t.willChange||"").includes(i))||wAn.some(i=>(t.contain||"").includes(i))}function SAn(n){let e=tC(n);for(;ET(e)&&!PI(e);){if(lxe(e))return e;if(sG(e))return null;e=tC(e)}return null}function uxe(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}var EAn=new Set(["html","body","#document"]);function PI(n){return EAn.has(AI(n))}function sE(n){return pS(n).getComputedStyle(n)}function aG(n){return oE(n)?{scrollLeft:n.scrollLeft,scrollTop:n.scrollTop}:{scrollLeft:n.scrollX,scrollTop:n.scrollY}}function tC(n){if(AI(n)==="html")return n;const e=n.assignedSlot||n.parentNode||Qnt(n)&&n.host||ST(n);return Qnt(e)?e.host:e}function Jnt(n){const e=tC(n);return PI(e)?n.ownerDocument?n.ownerDocument.body:n.body:ET(e)&&BL(e)?e:Jnt(e)}function jL(n,e,t){var i;e===void 0&&(e=[]),t===void 0&&(t=!0);const r=Jnt(n),o=r===((i=n.ownerDocument)==null?void 0:i.body),s=pS(r);if(o){const a=dxe(s);return e.concat(s,s.visualViewport||[],BL(r)?r:[],a&&t?jL(a):[])}return e.concat(r,jL(r,[],t))}function dxe(n){return n.parent&&Object.getPrototypeOf(n.parent)?n.frameElement:null}function eit(n){const e=sE(n);let t=parseFloat(e.width)||0,i=parseFloat(e.height)||0;const r=ET(n),o=r?n.offsetWidth:t,s=r?n.offsetHeight:i,a=tG(t)!==o||tG(i)!==s;return a&&(t=o,i=s),{width:t,height:i,$:a}}function hxe(n){return oE(n)?n:n.contextElement}function RI(n){const e=hxe(n);if(!ET(e))return vT(1);const t=e.getBoundingClientRect(),{width:i,height:r,$:o}=eit(e);let s=(o?tG(t.width):t.width)/i,a=(o?tG(t.height):t.height)/r;return(!s||!Number.isFinite(s))&&(s=1),(!a||!Number.isFinite(a))&&(a=1),{x:s,y:a}}var TAn=vT(0);function tit(n){const e=pS(n);return!uxe()||!e.visualViewport?TAn:{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}}function MAn(n,e,t){return e===void 0&&(e=!1),!t||e&&t!==pS(n)?!1:e}function C4(n,e,t,i){e===void 0&&(e=!1),t===void 0&&(t=!1);const r=n.getBoundingClientRect(),o=hxe(n);let s=vT(1);e&&(i?oE(i)&&(s=RI(i)):s=RI(n));const a=MAn(o,t,i)?tit(o):vT(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=pS(o),p=i&&oE(i)?pS(i):i;let m=h,_=dxe(m);for(;_&&i&&p!==m;){const y=RI(_),x=_.getBoundingClientRect(),b=sE(_),w=x.left+(_.clientLeft+parseFloat(b.paddingLeft))*y.x,S=x.top+(_.clientTop+parseFloat(b.paddingTop))*y.y;c*=y.x,l*=y.y,u*=y.x,d*=y.y,c+=w,l+=S,m=pS(_),_=dxe(m)}}return rG({width:u,height:d,x:c,y:l})}function cG(n,e){const t=aG(n).scrollLeft;return e?e.left+t:C4(ST(n)).left+t}function nit(n,e){const t=n.getBoundingClientRect(),i=t.left+e.scrollLeft-cG(n,t),r=t.top+e.scrollTop;return{x:i,y:r}}function CAn(n){let{elements:e,rect:t,offsetParent:i,strategy:r}=n;const o=r==="fixed",s=ST(i),a=e?sG(e.floating):!1;if(i===s||a&&o)return t;let c={scrollLeft:0,scrollTop:0},l=vT(1);const u=vT(0),d=ET(i);if((d||!d&&!o)&&((AI(i)!=="body"||BL(s))&&(c=aG(i)),ET(i))){const p=C4(i);l=RI(i),u.x=p.x+i.clientLeft,u.y=p.y+i.clientTop}const h=s&&!d&&!o?nit(s,c):vT(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 AAn(n){return Array.from(n.getClientRects())}function PAn(n){const e=ST(n),t=aG(n),i=n.ownerDocument.body,r=hS(e.scrollWidth,e.clientWidth,i.scrollWidth,i.clientWidth),o=hS(e.scrollHeight,e.clientHeight,i.scrollHeight,i.clientHeight);let s=-t.scrollLeft+cG(n);const a=-t.scrollTop;return sE(i).direction==="rtl"&&(s+=hS(e.clientWidth,i.clientWidth)-r),{width:r,height:o,x:s,y:a}}var iit=25;function RAn(n,e){const t=pS(n),i=ST(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=uxe();(!u||u&&e==="fixed")&&(a=r.offsetLeft,c=r.offsetTop)}const l=cG(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<=iit&&(o-=m)}else l<=iit&&(o+=l);return{width:o,height:s,x:a,y:c}}var IAn=new Set(["absolute","fixed"]);function NAn(n,e){const t=C4(n,!0,e==="fixed"),i=t.top+n.clientTop,r=t.left+n.clientLeft,o=ET(n)?RI(n):vT(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 rit(n,e,t){let i;if(e==="viewport")i=RAn(n,t);else if(e==="document")i=PAn(ST(n));else if(oE(e))i=NAn(e,t);else{const r=tit(n);i={x:e.x-r.x,y:e.y-r.y,width:e.width,height:e.height}}return rG(i)}function oit(n,e){const t=tC(n);return t===e||!oE(t)||PI(t)?!1:sE(t).position==="fixed"||oit(t,e)}function kAn(n,e){const t=e.get(n);if(t)return t;let i=jL(n,[],!1).filter(a=>oE(a)&&AI(a)!=="body"),r=null;const o=sE(n).position==="fixed";let s=o?tC(n):n;for(;oE(s)&&!PI(s);){const a=sE(s),c=lxe(s);!c&&a.position==="fixed"&&(r=null),(o?!c&&!r:!c&&a.position==="static"&&!!r&&IAn.has(r.position)||BL(s)&&!c&&oit(n,s))?i=i.filter(u=>u!==s):r=a,s=tC(s)}return e.set(n,i),i}function OAn(n){let{element:e,boundary:t,rootBoundary:i,strategy:r}=n;const s=[...t==="clippingAncestors"?sG(e)?[]:kAn(e,this._c):[].concat(t),i],a=s[0],c=s.reduce((l,u)=>{const d=rit(e,u,r);return l.top=hS(d.top,l.top),l.right=eC(d.right,l.right),l.bottom=eC(d.bottom,l.bottom),l.left=hS(d.left,l.left),l},rit(e,a,r));return{width:c.right-c.left,height:c.bottom-c.top,x:c.left,y:c.top}}function LAn(n){const{width:e,height:t}=eit(n);return{width:e,height:t}}function DAn(n,e,t){const i=ET(e),r=ST(e),o=t==="fixed",s=C4(n,!0,o,e);let a={scrollLeft:0,scrollTop:0};const c=vT(0);function l(){c.x=cG(r)}if(i||!i&&!o)if((AI(e)!=="body"||BL(r))&&(a=aG(e)),i){const p=C4(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?nit(r,a):vT(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 pxe(n){return sE(n).position==="static"}function sit(n,e){if(!ET(n)||sE(n).position==="fixed")return null;if(e)return e(n);let t=n.offsetParent;return ST(n)===t&&(t=t.ownerDocument.body),t}function ait(n,e){const t=pS(n);if(sG(n))return t;if(!ET(n)){let r=tC(n);for(;r&&!PI(r);){if(oE(r)&&!pxe(r))return r;r=tC(r)}return t}let i=sit(n,e);for(;i&&gAn(i)&&pxe(i);)i=sit(i,e);return i&&PI(i)&&pxe(i)&&!lxe(i)?t:i||SAn(n)||t}var zAn=async function(n){const e=this.getOffsetParent||ait,t=this.getDimensions,i=await t(n.floating);return{reference:DAn(n.reference,await e(n.floating),n.strategy),floating:{x:0,y:0,width:i.width,height:i.height}}};function $An(n){return sE(n).direction==="rtl"}var FAn={convertOffsetParentRelativeRectToViewportRelativeRect:CAn,getDocumentElement:ST,getClippingRect:OAn,getOffsetParent:ait,getElementRects:zAn,getClientRects:AAn,getDimensions:LAn,getScale:RI,isElement:oE,isRTL:$An};function cit(n,e){return n.x===e.x&&n.y===e.y&&n.width===e.width&&n.height===e.height}function UAn(n,e){let t=null,i;const r=ST(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=nG(d),_=nG(r.clientWidth-(u+h)),y=nG(r.clientHeight-(d+p)),x=nG(u),w={rootMargin:-m+"px "+-_+"px "+-y+"px "+-x+"px",threshold:hS(0,eC(1,c))||1};let S=!0;function I(A){const R=A[0].intersectionRatio;if(R!==c){if(!S)return s();R?s(!1,R):i=setTimeout(()=>{s(!1,1e-7)},1e3)}R===1&&!cit(l,n.getBoundingClientRect())&&s(),S=!1}try{t=new IntersectionObserver(I,{...w,root:r.ownerDocument})}catch{t=new IntersectionObserver(I,w)}t.observe(n)}return s(!0),o}function BAn(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=hxe(n),u=r||o?[...l?jL(l):[],...jL(e)]:[];u.forEach(x=>{r&&x.addEventListener("scroll",t,{passive:!0}),o&&x.addEventListener("resize",t)});const d=l&&a?UAn(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?C4(n):null;c&&y();function y(){const x=C4(n);_&&!cit(_,x)&&t(),_=x,m=requestAnimationFrame(y)}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 jAn=hAn,HAn=pAn,VAn=lAn,GAn=mAn,YAn=uAn,lit=cAn,qAn=fAn,XAn=(n,e,t)=>{const i=new Map,r={platform:FAn,...t},o={...r.platform,_c:i};return aAn(n,e,{...r,platform:o})},WAn=typeof document<"u",KAn=function(){},lG=WAn?ce.useLayoutEffect:KAn;function uG(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(!uG(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)&&!uG(n[o],e[o]))return!1}return!0}return n!==n&&e!==e}function uit(n){return typeof window>"u"?1:(n.ownerDocument.defaultView||window).devicePixelRatio||1}function dit(n,e){const t=uit(n);return Math.round(e*t)/t}function fxe(n){const e=ce.useRef(n);return lG(()=>{e.current=n}),e}function ZAn(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]=ce.useState({x:0,y:0,strategy:t,placement:e,middlewareData:{},isPositioned:!1}),[h,p]=ce.useState(i);uG(h,i)||p(i);const[m,_]=ce.useState(null),[y,x]=ce.useState(null),b=ce.useCallback(le=>{le!==A.current&&(A.current=le,_(le))},[]),w=ce.useCallback(le=>{le!==R.current&&(R.current=le,x(le))},[]),S=o||m,I=s||y,A=ce.useRef(null),R=ce.useRef(null),M=ce.useRef(u),k=c!=null,C=fxe(c),U=fxe(r),O=fxe(l),H=ce.useCallback(()=>{if(!A.current||!R.current)return;const le={placement:e,strategy:t,middleware:h};U.current&&(le.platform=U.current),XAn(A.current,R.current,le).then(he=>{const ve={...he,isPositioned:O.current!==!1};Y.current&&!uG(M.current,ve)&&(M.current=ve,JO.flushSync(()=>{d(ve)}))})},[h,e,t,U,O]);lG(()=>{l===!1&&M.current.isPositioned&&(M.current.isPositioned=!1,d(le=>({...le,isPositioned:!1})))},[l]);const Y=ce.useRef(!1);lG(()=>(Y.current=!0,()=>{Y.current=!1}),[]),lG(()=>{if(S&&(A.current=S),I&&(R.current=I),S&&I){if(C.current)return C.current(S,I,H);H()}},[S,I,H,C,k]);const X=ce.useMemo(()=>({reference:A,floating:R,setReference:b,setFloating:w}),[b,w]),K=ce.useMemo(()=>({reference:S,floating:I}),[S,I]),J=ce.useMemo(()=>{const le={position:t,left:0,top:0};if(!K.floating)return le;const he=dit(K.floating,u.x),ve=dit(K.floating,u.y);return a?{...le,transform:"translate("+he+"px, "+ve+"px)",...uit(K.floating)>=1.5&&{willChange:"transform"}}:{position:t,left:he,top:ve}},[t,a,K.floating,u.x,u.y]);return ce.useMemo(()=>({...u,update:H,refs:X,elements:K,floatingStyles:J}),[u,H,X,K,J])}var QAn=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?lit({element:i.current,padding:r}).fn(t):{}:i?lit({element:i,padding:r}).fn(t):{}}}},JAn=(n,e)=>({...jAn(n),options:[n,e]}),e4n=(n,e)=>({...HAn(n),options:[n,e]}),t4n=(n,e)=>({...qAn(n),options:[n,e]}),n4n=(n,e)=>({...VAn(n),options:[n,e]}),i4n=(n,e)=>({...GAn(n),options:[n,e]}),r4n=(n,e)=>({...YAn(n),options:[n,e]}),o4n=(n,e)=>({...QAn(n),options:[n,e]}),s4n="Arrow",hit=ce.forwardRef((n,e)=>{const{children:t,width:i=10,height:r=5,...o}=n;return re.jsx(Ov.svg,{...o,ref:e,width:i,height:r,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:n.asChild?t:re.jsx("polygon",{points:"0,0 30,0 15,10"})})});hit.displayName=s4n;var a4n=hit;function c4n(n){const[e,t]=ce.useState(void 0);return QM(()=>{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 mxe="Popper",[pit,fit]=$L(mxe),[l4n,mit]=pit(mxe),_it=n=>{const{__scopePopper:e,children:t}=n,[i,r]=ce.useState(null);return re.jsx(l4n,{scope:e,anchor:i,onAnchorChange:r,children:t})};_it.displayName=mxe;var yit="PopperAnchor",git=ce.forwardRef((n,e)=>{const{__scopePopper:t,virtualRef:i,...r}=n,o=mit(yit,t),s=ce.useRef(null),a=_w(e,s),c=ce.useRef(null);return ce.useEffect(()=>{const l=c.current;c.current=i?.current||s.current,l!==c.current&&o.onAnchorChange(c.current)}),i?null:re.jsx(Ov.div,{...r,ref:a})});git.displayName=yit;var _xe="PopperContent",[u4n,d4n]=pit(_xe),xit=ce.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,y=mit(_xe,t),[x,b]=ce.useState(null),w=_w(e,$e=>b($e)),[S,I]=ce.useState(null),A=c4n(S),R=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(p4n),altBoundary:O},{refs:Y,floatingStyles:X,placement:K,isPositioned:J,middlewareData:le}=ZAn({strategy:"fixed",placement:k,whileElementsMounted:(...$e)=>BAn(...$e,{animationFrame:p==="always"}),elements:{reference:y.anchor},middleware:[JAn({mainAxis:r+M,alignmentAxis:s}),c&&e4n({mainAxis:!0,crossAxis:!1,limiter:d==="partial"?t4n():void 0,...H}),c&&n4n({...H}),i4n({...H,apply:({elements:$e,rects:Ae,availableWidth:se,availableHeight:Se})=>{const{width:xe,height:Ve}=Ae.reference,tt=$e.floating.style;tt.setProperty("--radix-popper-available-width",`${se}px`),tt.setProperty("--radix-popper-available-height",`${Se}px`),tt.setProperty("--radix-popper-anchor-width",`${xe}px`),tt.setProperty("--radix-popper-anchor-height",`${Ve}px`)}}),S&&o4n({element:S,padding:a}),f4n({arrowWidth:R,arrowHeight:M}),h&&r4n({strategy:"referenceHidden",...H})]}),[he,ve]=wit(K),oe=bT(m);QM(()=>{J&&oe?.()},[J,oe]);const ae=le.arrow?.x,de=le.arrow?.y,Te=le.arrow?.centerOffset!==0,[Ce,Oe]=ce.useState();return QM(()=>{x&&Oe(window.getComputedStyle(x).zIndex)},[x]),re.jsx("div",{ref:Y.setFloating,"data-radix-popper-content-wrapper":"",style:{...X,transform:J?X.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:Ce,"--radix-popper-transform-origin":[le.transformOrigin?.x,le.transformOrigin?.y].join(" "),...le.hide?.referenceHidden&&{visibility:"hidden",pointerEvents:"none"}},dir:n.dir,children:re.jsx(u4n,{scope:t,placedSide:he,onArrowChange:I,arrowX:ae,arrowY:de,shouldHideArrow:Te,children:re.jsx(Ov.div,{"data-side":he,"data-align":ve,..._,ref:w,style:{..._.style,animation:J?void 0:"none"}})})})});xit.displayName=_xe;var bit="PopperArrow",h4n={top:"bottom",right:"left",bottom:"top",left:"right"},vit=ce.forwardRef(function(e,t){const{__scopePopper:i,...r}=e,o=d4n(bit,i),s=h4n[o.placedSide];return re.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:re.jsx(a4n,{...r,ref:t,style:{...r.style,display:"block"}})})});vit.displayName=bit;function p4n(n){return n!==null}var f4n=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]=wit(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 wit(n){const[e,t="center"]=n.split("-");return[e,t]}var Sit=_it,m4n=git,_4n=xit,y4n=vit,g4n="Portal",Eit=ce.forwardRef((n,e)=>{const{container:t,...i}=n,[r,o]=ce.useState(!1);QM(()=>o(!0),[]);const s=t||r&&globalThis?.document?.body;return s?mj.createPortal(re.jsx(Ov.div,{...i,ref:e}),s):null});Eit.displayName=g4n;function x4n(n,e){return ce.useReducer((t,i)=>e[t][i]??t,n)}var HL=n=>{const{present:e,children:t}=n,i=b4n(e),r=typeof t=="function"?t({present:i.isPresent}):ce.Children.only(t),o=_w(i.ref,v4n(r));return typeof t=="function"||i.isPresent?ce.cloneElement(r,{ref:o}):null};HL.displayName="Presence";function b4n(n){const[e,t]=ce.useState(),i=ce.useRef(null),r=ce.useRef(n),o=ce.useRef("none"),s=n?"mounted":"unmounted",[a,c]=x4n(s,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return ce.useEffect(()=>{const l=dG(i.current);o.current=a==="mounted"?l:"none"},[a]),QM(()=>{const l=i.current,u=r.current;if(u!==n){const h=o.current,p=dG(l);n?c("MOUNT"):p==="none"||l?.display==="none"?c("UNMOUNT"):c(u&&h!==p?"ANIMATION_OUT":"UNMOUNT"),r.current=n}},[n,c]),QM(()=>{if(e){let l;const u=e.ownerDocument.defaultView??window,d=p=>{const _=dG(i.current).includes(CSS.escape(p.animationName));if(p.target===e&&_&&(c("ANIMATION_END"),!r.current)){const y=e.style.animationFillMode;e.style.animationFillMode="forwards",l=u.setTimeout(()=>{e.style.animationFillMode==="forwards"&&(e.style.animationFillMode=y)})}},h=p=>{p.target===e&&(o.current=dG(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:ce.useCallback(l=>{i.current=l?getComputedStyle(l):null,t(l)},[])}}function dG(n){return n?.animationName||"none"}function v4n(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 yxe="rovingFocusGroup.onEntryFocus",w4n={bubbles:!1,cancelable:!0},VL="RovingFocusGroup",[gxe,Tit,S4n]=Rnt(VL),[E4n,Mit]=$L(VL,[S4n]),[T4n,M4n]=E4n(VL),Cit=ce.forwardRef((n,e)=>re.jsx(gxe.Provider,{scope:n.__scopeRovingFocusGroup,children:re.jsx(gxe.Slot,{scope:n.__scopeRovingFocusGroup,children:re.jsx(C4n,{...n,ref:e})})}));Cit.displayName=VL;var C4n=ce.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=ce.useRef(null),p=_w(e,h),m=Int(o),[_,y]=Jge({prop:s,defaultProp:a??null,onChange:c,caller:VL}),[x,b]=ce.useState(!1),w=bT(l),S=Tit(t),I=ce.useRef(!1),[A,R]=ce.useState(0);return ce.useEffect(()=>{const M=h.current;if(M)return M.addEventListener(yxe,w),()=>M.removeEventListener(yxe,w)},[w]),re.jsx(T4n,{scope:t,orientation:i,dir:m,loop:r,currentTabStopId:_,onItemFocus:ce.useCallback(M=>y(M),[y]),onItemShiftTab:ce.useCallback(()=>b(!0),[]),onFocusableItemAdd:ce.useCallback(()=>R(M=>M+1),[]),onFocusableItemRemove:ce.useCallback(()=>R(M=>M-1),[]),children:re.jsx(Ov.div,{tabIndex:x||A===0?-1:0,"data-orientation":i,...d,ref:p,style:{outline:"none",...n.style},onMouseDown:xd(n.onMouseDown,()=>{I.current=!0}),onFocus:xd(n.onFocus,M=>{const k=!I.current;if(M.target===M.currentTarget&&k&&!x){const C=new CustomEvent(yxe,w4n);if(M.currentTarget.dispatchEvent(C),!C.defaultPrevented){const U=S().filter(K=>K.focusable),O=U.find(K=>K.active),H=U.find(K=>K.id===_),X=[O,H,...U].filter(Boolean).map(K=>K.ref.current);Rit(X,u)}}I.current=!1}),onBlur:xd(n.onBlur,()=>b(!1))})})}),Ait="RovingFocusGroupItem",Pit=ce.forwardRef((n,e)=>{const{__scopeRovingFocusGroup:t,focusable:i=!0,active:r=!1,tabStopId:o,children:s,...a}=n,c=FL(),l=o||c,u=M4n(Ait,t),d=u.currentTabStopId===l,h=Tit(t),{onFocusableItemAdd:p,onFocusableItemRemove:m,currentTabStopId:_}=u;return ce.useEffect(()=>{if(i)return p(),()=>m()},[i,p,m]),re.jsx(gxe.ItemSlot,{scope:t,id:l,focusable:i,active:r,children:re.jsx(Ov.span,{tabIndex:d?0:-1,"data-orientation":u.orientation,...a,ref:e,onMouseDown:xd(n.onMouseDown,y=>{i?u.onItemFocus(l):y.preventDefault()}),onFocus:xd(n.onFocus,()=>u.onItemFocus(l)),onKeyDown:xd(n.onKeyDown,y=>{if(y.key==="Tab"&&y.shiftKey){u.onItemShiftTab();return}if(y.target!==y.currentTarget)return;const x=R4n(y,u.orientation,u.dir);if(x!==void 0){if(y.metaKey||y.ctrlKey||y.altKey||y.shiftKey)return;y.preventDefault();let w=h().filter(S=>S.focusable).map(S=>S.ref.current);if(x==="last")w.reverse();else if(x==="prev"||x==="next"){x==="prev"&&w.reverse();const S=w.indexOf(y.currentTarget);w=u.loop?I4n(w,S+1):w.slice(S+1)}setTimeout(()=>Rit(w))}}),children:typeof s=="function"?s({isCurrentTabStop:d,hasTabStop:_!=null}):s})})});Pit.displayName=Ait;var A4n={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function P4n(n,e){return e!=="rtl"?n:n==="ArrowLeft"?"ArrowRight":n==="ArrowRight"?"ArrowLeft":n}function R4n(n,e,t){const i=P4n(n.key,t);if(!(e==="vertical"&&["ArrowLeft","ArrowRight"].includes(i))&&!(e==="horizontal"&&["ArrowUp","ArrowDown"].includes(i)))return A4n[i]}function Rit(n,e=!1){const t=document.activeElement;for(const i of n)if(i===t||(i.focus({preventScroll:e}),document.activeElement!==t))return}function I4n(n,e){return n.map((t,i)=>n[(e+i)%n.length])}var N4n=Cit,k4n=Pit,O4n=function(n){if(typeof document>"u")return null;var e=Array.isArray(n)?n[0]:n;return e.ownerDocument.body},II=new WeakMap,hG=new WeakMap,pG={},xxe=0,Iit=function(n){return n&&(n.host||Iit(n.parentNode))},L4n=function(n,e){return e.map(function(t){if(n.contains(t))return t;var i=Iit(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})},D4n=function(n,e,t,i){var r=L4n(e,Array.isArray(n)?n:[n]);pG[t]||(pG[t]=new WeakMap);var o=pG[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",_=(II.get(h)||0)+1,y=(o.get(h)||0)+1;II.set(h,_),o.set(h,y),s.push(h),_===1&&m&&hG.set(h,!0),y===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(),xxe++,function(){s.forEach(function(d){var h=II.get(d)-1,p=o.get(d)-1;II.set(d,h),o.set(d,p),h||(hG.has(d)||d.removeAttribute(i),hG.delete(d)),p||d.removeAttribute(t)}),xxe--,xxe||(II=new WeakMap,II=new WeakMap,hG=new WeakMap,pG={})}},z4n=function(n,e,t){t===void 0&&(t="data-aria-hidden");var i=Array.from(Array.isArray(n)?n:[n]),r=O4n(n);return r?(i.push.apply(i,Array.from(r.querySelectorAll("[aria-live], script"))),D4n(i,r,t,"aria-hidden")):function(){return null}},TT=function(){return TT=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},TT.apply(this,arguments)};function Nit(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 $4n(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 fG="right-scroll-bar-position",mG="width-before-scroll-bar",F4n="with-scroll-bars-hidden",U4n="--removed-body-scroll-bar-size";function bxe(n,e){return typeof n=="function"?n(e):n&&(n.current=e),n}function B4n(n,e){var t=ce.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 j4n=typeof window<"u"?ce.useLayoutEffect:ce.useEffect,kit=new WeakMap;function H4n(n,e){var t=B4n(null,function(i){return n.forEach(function(r){return bxe(r,i)})});return j4n(function(){var i=kit.get(t);if(i){var r=new Set(i),o=new Set(n),s=t.current;r.forEach(function(a){o.has(a)||bxe(a,null)}),o.forEach(function(a){r.has(a)||bxe(a,s)})}kit.set(t,n)},[n]),t}function V4n(n){return n}function G4n(n,e){e===void 0&&(e=V4n);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 Y4n(n){n===void 0&&(n={});var e=G4n(null);return e.options=TT({async:!0,ssr:!1},n),e}var Oit=function(n){var e=n.sideCar,t=Nit(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 ce.createElement(i,TT({},t))};Oit.isSideCarExport=!0;function q4n(n,e){return n.useMedium(e),Oit}var Lit=Y4n(),vxe=function(){},_G=ce.forwardRef(function(n,e){var t=ce.useRef(null),i=ce.useState({onScrollCapture:vxe,onWheelCapture:vxe,onTouchMoveCapture:vxe}),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,y=n.allowPinchZoom,x=n.as,b=x===void 0?"div":x,w=n.gapMode,S=Nit(n,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),I=h,A=H4n([t,e]),R=TT(TT({},S),r);return ce.createElement(ce.Fragment,null,u&&ce.createElement(I,{sideCar:Lit,removeScrollBar:l,shards:d,noRelative:p,noIsolation:m,inert:_,setCallbacks:o,allowPinchZoom:!!y,lockRef:t,gapMode:w}),s?ce.cloneElement(ce.Children.only(a),TT(TT({},R),{ref:A})):ce.createElement(b,TT({},R,{className:c,ref:A}),a))});_G.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},_G.classNames={fullWidth:mG,zeroRight:fG};var X4n=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function W4n(){if(!document)return null;var n=document.createElement("style");n.type="text/css";var e=X4n();return e&&n.setAttribute("nonce",e),n}function K4n(n,e){n.styleSheet?n.styleSheet.cssText=e:n.appendChild(document.createTextNode(e))}function Z4n(n){var e=document.head||document.getElementsByTagName("head")[0];e.appendChild(n)}var Q4n=function(){var n=0,e=null;return{add:function(t){n==0&&(e=W4n())&&(K4n(e,t),Z4n(e)),n++},remove:function(){n--,!n&&e&&(e.parentNode&&e.parentNode.removeChild(e),e=null)}}},J4n=function(){var n=Q4n();return function(e,t){ce.useEffect(function(){return n.add(e),function(){n.remove()}},[e&&t])}},Dit=function(){var n=J4n(),e=function(t){var i=t.styles,r=t.dynamic;return n(i,r),null};return e},ePn={left:0,top:0,right:0,gap:0},wxe=function(n){return parseInt(n||"",10)||0},tPn=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[wxe(t),wxe(i),wxe(r)]},nPn=function(n){if(n===void 0&&(n="margin"),typeof window>"u")return ePn;var e=tPn(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])}},iPn=Dit(),NI="data-scroll-locked",rPn=function(n,e,t,i){var r=n.left,o=n.top,s=n.right,a=n.gap;return t===void 0&&(t="margin"),`
|
|
5167
|
+
`.trim();const H=Y=>{const X="Failed to load Manifold loader script.";console.error(X,Y),d(X),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:y,boardData:x}=uCn(c,a),b=ce.useMemo(()=>pCn(h),[h]),w=ce.useMemo(()=>fCn(p,x,m),[p,x,m]),S=ce.useMemo(()=>ms(a).cad_component.list(),[a]),I=ce.useMemo(()=>{if(!x)return;const{width:M=0,height:k=0}=x;return{width:M,height:k}},[x]),A=ce.useMemo(()=>{if(!x)return;const{center:M}=x;if(M)return{x:M.x,y:M.y}},[x]),R=ce.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?re.jsxs("div",{style:{color:"red",padding:"1em",border:"1px solid red",margin:"1em"},children:["Error: ",u]}):c?_?re.jsxs("div",{style:{color:"red",padding:"1em",border:"1px solid red",margin:"1em"},children:["Error: ",_]}):y?re.jsx("div",{style:{padding:"1em"},children:"Processing board geometry..."}):re.jsxs(ont,{initialCameraPosition:R,autoRotateDisabled:e,clickToInteractEnabled:t,boardDimensions:I,boardCenter:A,onUserInteraction:i,onCameraControllerReady:o,children:[re.jsx(mCn,{geometryMeshes:b,textureMeshes:w}),S.map(M=>re.jsx(bnt,{fallback:({error:k})=>re.jsx(xnt,{cad_component:M,error:k}),children:re.jsx(nnt,{cad_component:M,circuitJson:a})},M.cad_component_id))]}):re.jsx("div",{style:{padding:"1em"},children:"Loading Manifold module..."})},gCn=yCn,xCn=({containerRef:n})=>{const[e,t]=ce.useState(!1),[i,r]=ce.useState({x:0,y:0}),o=ce.useRef(null),s=ce.useRef(null),a=ce.useRef(null),c=ce.useRef(!1),l=()=>{a.current!==null&&(clearTimeout(a.current),a.current=null)},u=ce.useCallback(y=>{y.preventDefault();const x=typeof y.clientX=="number"?y.clientX:0,b=typeof y.clientY=="number"?y.clientY:0;if(c.current){c.current=!1;return}if(!s.current)return;const{x:w,y:S}=s.current,I=Math.abs(x-w),A=Math.abs(b-S),R=10;if(I>R||A>R){s.current=null;return}r({x,y:b}),t(!0),s.current=null},[r,t]),d=ce.useCallback(y=>{if(y.touches.length===1){const x=y.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=ce.useCallback(y=>{if(!s.current||y.touches.length!==1)return;const x=y.touches[0];if(x){const b=Math.abs(x.clientX-s.current.x),w=Math.abs(x.clientY-s.current.y),S=10;(b>S||w>S)&&(s.current=null,l())}else s.current=null,l()},[]),p=ce.useCallback(()=>{l(),setTimeout(()=>{s.current&&(s.current=null)},0)},[]),m=ce.useCallback(y=>{const x=y.target;o.current&&!o.current.contains(x)&&t(!1)},[]);return ce.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:y=>{y.button===2?s.current={x:y.clientX,y:y.clientY}:s.current=null},onContextMenu:u,onTouchStart:d,onTouchMove:h,onTouchEnd:p},setMenuVisible:t}},bCn=()=>ce.useCallback(()=>{const n=window.__TSCIRCUIT_THREE_OBJECT;if(!n)return;new lHe().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 xd(n,e,{checkForDefaultPrevented:t=!0}={}){return function(r){if(n?.(r),t===!1||!r.defaultPrevented)return e?.(r)}}function Ant(n,e){if(typeof n=="function")return n(e);n!=null&&(n.current=e)}function JV(...n){return e=>{let t=!1;const i=n.map(r=>{const o=Ant(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():Ant(n[r],null)}}}}function _w(...n){return ce.useCallback(JV(...n),n)}function $L(n,e=[]){let t=[];function i(o,s){const a=ce.createContext(s),c=t.length;t=[...t,s];const l=d=>{const{scope:h,children:p,...m}=d,_=h?.[n]?.[c]||a,y=ce.useMemo(()=>m,Object.values(m));return re.jsx(_.Provider,{value:y,children:p})};l.displayName=o+"Provider";function u(d,h){const p=h?.[n]?.[c]||a,m=ce.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=>ce.createContext(s));return function(a){const c=a?.[n]||o;return ce.useMemo(()=>({[`__scope${n}`]:{...a,[n]:c}}),[a,c])}};return r.scopeName=n,[i,vCn(r,...e)]}function vCn(...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 ce.useMemo(()=>({[`__scope${e.scopeName}`]:s}),[s])}};return t.scopeName=e.scopeName,t}var QM=globalThis?.document?ce.useLayoutEffect:()=>{},wCn=Nz[" useInsertionEffect ".trim().toString()]||QM;function Jge({prop:n,defaultProp:e,onChange:t=()=>{},caller:i}){const[r,o,s]=SCn({defaultProp:e,onChange:t}),a=n!==void 0,c=a?n:r;{const u=ce.useRef(n!==void 0);ce.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=ce.useCallback(u=>{if(a){const d=ECn(u)?u(n):u;d!==n&&s.current?.(d)}else o(u)},[a,n,o,s]);return[c,l]}function SCn({defaultProp:n,onChange:e}){const[t,i]=ce.useState(n),r=ce.useRef(t),o=ce.useRef(e);return wCn(()=>{o.current=e},[e]),ce.useEffect(()=>{r.current!==t&&(o.current?.(t),r.current=t)},[t,r]),[t,i,o]}function ECn(n){return typeof n=="function"}function eG(n){const e=TCn(n),t=ce.forwardRef((i,r)=>{const{children:o,...s}=i,a=ce.Children.toArray(o),c=a.find(CCn);if(c){const l=c.props.children,u=a.map(d=>d===c?ce.Children.count(l)>1?ce.Children.only(null):ce.isValidElement(l)?l.props.children:null:d);return re.jsx(e,{...s,ref:r,children:ce.isValidElement(l)?ce.cloneElement(l,void 0,u):null})}return re.jsx(e,{...s,ref:r,children:o})});return t.displayName=`${n}.Slot`,t}function TCn(n){const e=ce.forwardRef((t,i)=>{const{children:r,...o}=t;if(ce.isValidElement(r)){const s=PCn(r),a=ACn(o,r.props);return r.type!==ce.Fragment&&(a.ref=i?JV(i,s):s),ce.cloneElement(r,a)}return ce.Children.count(r)>1?ce.Children.only(null):null});return e.displayName=`${n}.SlotClone`,e}var MCn=Symbol("radix.slottable");function CCn(n){return ce.isValidElement(n)&&typeof n.type=="function"&&"__radixId"in n.type&&n.type.__radixId===MCn}function ACn(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 PCn(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 RCn=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Ov=RCn.reduce((n,e)=>{const t=eG(`Primitive.${e}`),i=ce.forwardRef((r,o)=>{const{asChild:s,...a}=r,c=s?t:e;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),re.jsx(c,{...a,ref:o})});return i.displayName=`Primitive.${e}`,{...n,[e]:i}},{});function Pnt(n,e){n&&JO.flushSync(()=>n.dispatchEvent(e))}function Rnt(n){const e=n+"CollectionProvider",[t,i]=$L(e),[r,o]=t(e,{collectionRef:{current:null},itemMap:new Map}),s=_=>{const{scope:y,children:x}=_,b=So.useRef(null),w=So.useRef(new Map).current;return re.jsx(r,{scope:y,itemMap:w,collectionRef:b,children:x})};s.displayName=e;const a=n+"CollectionSlot",c=eG(a),l=So.forwardRef((_,y)=>{const{scope:x,children:b}=_,w=o(a,x),S=_w(y,w.collectionRef);return re.jsx(c,{ref:S,children:b})});l.displayName=a;const u=n+"CollectionItemSlot",d="data-radix-collection-item",h=eG(u),p=So.forwardRef((_,y)=>{const{scope:x,children:b,...w}=_,S=So.useRef(null),I=_w(y,S),A=o(u,x);return So.useEffect(()=>(A.itemMap.set(S,{ref:S,...w}),()=>void A.itemMap.delete(S))),re.jsx(h,{[d]:"",ref:I,children:b})});p.displayName=u;function m(_){const y=o(n+"CollectionConsumer",_);return So.useCallback(()=>{const b=y.collectionRef.current;if(!b)return[];const w=Array.from(b.querySelectorAll(`[${d}]`));return Array.from(y.itemMap.values()).sort((A,R)=>w.indexOf(A.ref.current)-w.indexOf(R.ref.current))},[y.collectionRef,y.itemMap])}return[{Provider:s,Slot:l,ItemSlot:p},m,i]}var ICn=ce.createContext(void 0);function Int(n){const e=ce.useContext(ICn);return n||e||"ltr"}function bT(n){const e=ce.useRef(n);return ce.useEffect(()=>{e.current=n}),ce.useMemo(()=>(...t)=>e.current?.(...t),[])}function NCn(n,e=globalThis?.document){const t=bT(n);ce.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 kCn="DismissableLayer",exe="dismissableLayer.update",OCn="dismissableLayer.pointerDownOutside",LCn="dismissableLayer.focusOutside",Nnt,knt=ce.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),Ont=ce.forwardRef((n,e)=>{const{disableOutsidePointerEvents:t=!1,onEscapeKeyDown:i,onPointerDownOutside:r,onFocusOutside:o,onInteractOutside:s,onDismiss:a,...c}=n,l=ce.useContext(knt),[u,d]=ce.useState(null),h=u?.ownerDocument??globalThis?.document,[,p]=ce.useState({}),m=_w(e,R=>d(R)),_=Array.from(l.layers),[y]=[...l.layersWithOutsidePointerEventsDisabled].slice(-1),x=_.indexOf(y),b=u?_.indexOf(u):-1,w=l.layersWithOutsidePointerEventsDisabled.size>0,S=b>=x,I=$Cn(R=>{const M=R.target,k=[...l.branches].some(C=>C.contains(M));!S||k||(r?.(R),s?.(R),R.defaultPrevented||a?.())},h),A=FCn(R=>{const M=R.target;[...l.branches].some(C=>C.contains(M))||(o?.(R),s?.(R),R.defaultPrevented||a?.())},h);return NCn(R=>{b===l.layers.size-1&&(i?.(R),!R.defaultPrevented&&a&&(R.preventDefault(),a()))},h),ce.useEffect(()=>{if(u)return t&&(l.layersWithOutsidePointerEventsDisabled.size===0&&(Nnt=h.body.style.pointerEvents,h.body.style.pointerEvents="none"),l.layersWithOutsidePointerEventsDisabled.add(u)),l.layers.add(u),Lnt(),()=>{t&&l.layersWithOutsidePointerEventsDisabled.size===1&&(h.body.style.pointerEvents=Nnt)}},[u,h,t,l]),ce.useEffect(()=>()=>{u&&(l.layers.delete(u),l.layersWithOutsidePointerEventsDisabled.delete(u),Lnt())},[u,l]),ce.useEffect(()=>{const R=()=>p({});return document.addEventListener(exe,R),()=>document.removeEventListener(exe,R)},[]),re.jsx(Ov.div,{...c,ref:m,style:{pointerEvents:w?S?"auto":"none":void 0,...n.style},onFocusCapture:xd(n.onFocusCapture,A.onFocusCapture),onBlurCapture:xd(n.onBlurCapture,A.onBlurCapture),onPointerDownCapture:xd(n.onPointerDownCapture,I.onPointerDownCapture)})});Ont.displayName=kCn;var DCn="DismissableLayerBranch",zCn=ce.forwardRef((n,e)=>{const t=ce.useContext(knt),i=ce.useRef(null),r=_w(e,i);return ce.useEffect(()=>{const o=i.current;if(o)return t.branches.add(o),()=>{t.branches.delete(o)}},[t.branches]),re.jsx(Ov.div,{...n,ref:r})});zCn.displayName=DCn;function $Cn(n,e=globalThis?.document){const t=bT(n),i=ce.useRef(!1),r=ce.useRef(()=>{});return ce.useEffect(()=>{const o=a=>{if(a.target&&!i.current){let c=function(){Dnt(OCn,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 FCn(n,e=globalThis?.document){const t=bT(n),i=ce.useRef(!1);return ce.useEffect(()=>{const r=o=>{o.target&&!i.current&&Dnt(LCn,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 Lnt(){const n=new CustomEvent(exe);document.dispatchEvent(n)}function Dnt(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?Pnt(r,o):r.dispatchEvent(o)}var txe=0;function UCn(){ce.useEffect(()=>{const n=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",n[0]??znt()),document.body.insertAdjacentElement("beforeend",n[1]??znt()),txe++,()=>{txe===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(e=>e.remove()),txe--}},[])}function znt(){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 nxe="focusScope.autoFocusOnMount",ixe="focusScope.autoFocusOnUnmount",$nt={bubbles:!1,cancelable:!0},BCn="FocusScope",Fnt=ce.forwardRef((n,e)=>{const{loop:t=!1,trapped:i=!1,onMountAutoFocus:r,onUnmountAutoFocus:o,...s}=n,[a,c]=ce.useState(null),l=bT(r),u=bT(o),d=ce.useRef(null),h=_w(e,_=>c(_)),p=ce.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;ce.useEffect(()=>{if(i){let _=function(w){if(p.paused||!a)return;const S=w.target;a.contains(S)?d.current=S:JM(d.current,{select:!0})},y=function(w){if(p.paused||!a)return;const S=w.relatedTarget;S!==null&&(a.contains(S)||JM(d.current,{select:!0}))},x=function(w){if(document.activeElement===document.body)for(const I of w)I.removedNodes.length>0&&JM(a)};document.addEventListener("focusin",_),document.addEventListener("focusout",y);const b=new MutationObserver(x);return a&&b.observe(a,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",_),document.removeEventListener("focusout",y),b.disconnect()}}},[i,a,p.paused]),ce.useEffect(()=>{if(a){jnt.add(p);const _=document.activeElement;if(!a.contains(_)){const x=new CustomEvent(nxe,$nt);a.addEventListener(nxe,l),a.dispatchEvent(x),x.defaultPrevented||(jCn(qCn(Unt(a)),{select:!0}),document.activeElement===_&&JM(a))}return()=>{a.removeEventListener(nxe,l),setTimeout(()=>{const x=new CustomEvent(ixe,$nt);a.addEventListener(ixe,u),a.dispatchEvent(x),x.defaultPrevented||JM(_??document.body,{select:!0}),a.removeEventListener(ixe,u),jnt.remove(p)},0)}}},[a,l,u,p]);const m=ce.useCallback(_=>{if(!t&&!i||p.paused)return;const y=_.key==="Tab"&&!_.altKey&&!_.ctrlKey&&!_.metaKey,x=document.activeElement;if(y&&x){const b=_.currentTarget,[w,S]=HCn(b);w&&S?!_.shiftKey&&x===S?(_.preventDefault(),t&&JM(w,{select:!0})):_.shiftKey&&x===w&&(_.preventDefault(),t&&JM(S,{select:!0})):x===b&&_.preventDefault()}},[t,i,p.paused]);return re.jsx(Ov.div,{tabIndex:-1,...s,ref:h,onKeyDown:m})});Fnt.displayName=BCn;function jCn(n,{select:e=!1}={}){const t=document.activeElement;for(const i of n)if(JM(i,{select:e}),document.activeElement!==t)return}function HCn(n){const e=Unt(n),t=Bnt(e,n),i=Bnt(e.reverse(),n);return[t,i]}function Unt(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 Bnt(n,e){for(const t of n)if(!VCn(t,{upTo:e}))return t}function VCn(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 GCn(n){return n instanceof HTMLInputElement&&"select"in n}function JM(n,{select:e=!1}={}){if(n&&n.focus){const t=document.activeElement;n.focus({preventScroll:!0}),n!==t&&GCn(n)&&e&&n.select()}}var jnt=YCn();function YCn(){let n=[];return{add(e){const t=n[0];e!==t&&t?.pause(),n=Hnt(n,e),n.unshift(e)},remove(e){n=Hnt(n,e),n[0]?.resume()}}}function Hnt(n,e){const t=[...n],i=t.indexOf(e);return i!==-1&&t.splice(i,1),t}function qCn(n){return n.filter(e=>e.tagName!=="A")}var XCn=Nz[" useId ".trim().toString()]||(()=>{}),WCn=0;function FL(n){const[e,t]=ce.useState(XCn());return QM(()=>{t(i=>i??String(WCn++))},[n]),e?`radix-${e}`:""}var KCn=["top","right","bottom","left"],eC=Math.min,hS=Math.max,tG=Math.round,nG=Math.floor,vT=n=>({x:n,y:n}),ZCn={left:"right",right:"left",bottom:"top",top:"bottom"},QCn={start:"end",end:"start"};function rxe(n,e,t){return hS(n,eC(e,t))}function n3(n,e){return typeof n=="function"?n(e):n}function i3(n){return n.split("-")[0]}function CI(n){return n.split("-")[1]}function oxe(n){return n==="x"?"y":"x"}function sxe(n){return n==="y"?"height":"width"}var JCn=new Set(["top","bottom"]);function wT(n){return JCn.has(i3(n))?"y":"x"}function axe(n){return oxe(wT(n))}function eAn(n,e,t){t===void 0&&(t=!1);const i=CI(n),r=axe(n),o=sxe(r);let s=r==="x"?i===(t?"end":"start")?"right":"left":i==="start"?"bottom":"top";return e.reference[o]>e.floating[o]&&(s=iG(s)),[s,iG(s)]}function tAn(n){const e=iG(n);return[cxe(n),e,cxe(e)]}function cxe(n){return n.replace(/start|end/g,e=>QCn[e])}var Vnt=["left","right"],Gnt=["right","left"],nAn=["top","bottom"],iAn=["bottom","top"];function rAn(n,e,t){switch(n){case"top":case"bottom":return t?e?Gnt:Vnt:e?Vnt:Gnt;case"left":case"right":return e?nAn:iAn;default:return[]}}function oAn(n,e,t,i){const r=CI(n);let o=rAn(i3(n),t==="start",i);return r&&(o=o.map(s=>s+"-"+r),e&&(o=o.concat(o.map(cxe)))),o}function iG(n){return n.replace(/left|right|bottom|top/g,e=>ZCn[e])}function sAn(n){return{top:0,right:0,bottom:0,left:0,...n}}function Ynt(n){return typeof n!="number"?sAn(n):{top:n,right:n,bottom:n,left:n}}function rG(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 qnt(n,e,t){let{reference:i,floating:r}=n;const o=wT(e),s=axe(e),a=sxe(s),c=i3(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(CI(e)){case"start":p[s]-=h*(t&&l?-1:1);break;case"end":p[s]+=h*(t&&l?-1:1);break}return p}var aAn=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}=qnt(l,i,c),h=i,p={},m=0;for(let _=0;_<a.length;_++){const{name:y,fn:x}=a[_],{x:b,y:w,data:S,reset:I}=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,[y]:{...p[y],...S}},I&&m<=50&&(m++,typeof I=="object"&&(I.placement&&(h=I.placement),I.rects&&(l=I.rects===!0?await s.getElementRects({reference:n,floating:e,strategy:r}):I.rects),{x:u,y:d}=qnt(l,h,c)),_=-1)}return{x:u,y:d,placement:h,strategy:r,middlewareData:p}};async function UL(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}=n3(e,n),m=Ynt(p),y=a[h?d==="floating"?"reference":"floating":d],x=rG(await o.getClippingRect({element:(t=await(o.isElement==null?void 0:o.isElement(y)))==null||t?y:y.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)),S=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},I=rG(o.convertOffsetParentRelativeRectToViewportRelativeRect?await o.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:b,offsetParent:w,strategy:c}):b);return{top:(x.top-I.top+m.top)/S.y,bottom:(I.bottom-x.bottom+m.bottom)/S.y,left:(x.left-I.left+m.left)/S.x,right:(I.right-x.right+m.right)/S.x}}var cAn=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}=n3(n,e)||{};if(l==null)return{};const d=Ynt(u),h={x:t,y:i},p=axe(r),m=sxe(p),_=await s.getDimensions(l),y=p==="y",x=y?"top":"left",b=y?"bottom":"right",w=y?"clientHeight":"clientWidth",S=o.reference[m]+o.reference[p]-h[p]-o.floating[m],I=h[p]-o.reference[p],A=await(s.getOffsetParent==null?void 0:s.getOffsetParent(l));let R=A?A[w]:0;(!R||!await(s.isElement==null?void 0:s.isElement(A)))&&(R=a.floating[w]||o.floating[m]);const M=S/2-I/2,k=R/2-_[m]/2-1,C=eC(d[x],k),U=eC(d[b],k),O=C,H=R-_[m]-U,Y=R/2-_[m]/2+M,X=rxe(O,Y,H),K=!c.arrow&&CI(r)!=null&&Y!==X&&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]:X,centerOffset:Y-X-J,...K&&{alignmentOffset:J}},reset:K}}}),lAn=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,...y}=n3(n,e);if((t=o.arrow)!=null&&t.alignmentOffset)return{};const x=i3(r),b=wT(a),w=i3(a)===a,S=await(c.isRTL==null?void 0:c.isRTL(l.floating)),I=h||(w||!_?[iG(a)]:tAn(a)),A=m!=="none";!h&&A&&I.push(...oAn(a,_,m,S));const R=[a,...I],M=await UL(e,y),k=[];let C=((i=o.flip)==null?void 0:i.overflows)||[];if(u&&k.push(M[x]),d){const Y=eAn(r,s,S);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,X=R[Y];if(X&&(!(d==="alignment"?b!==wT(X):!1)||C.every(le=>wT(le.placement)===b?le.overflows[0]>0:!0)))return{data:{index:Y,overflows:C},reset:{placement:X}};let K=(O=C.filter(J=>J.overflows[0]<=0).sort((J,le)=>J.overflows[1]-le.overflows[1])[0])==null?void 0:O.placement;if(!K)switch(p){case"bestFit":{var H;const J=(H=C.filter(le=>{if(A){const he=wT(le.placement);return he===b||he==="y"}return!0}).map(le=>[le.placement,le.overflows.filter(he=>he>0).reduce((he,ve)=>he+ve,0)]).sort((le,he)=>le[1]-he[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 Xnt(n,e){return{top:n.top-e.height,right:n.right-e.width,bottom:n.bottom-e.height,left:n.left-e.width}}function Wnt(n){return KCn.some(e=>n[e]>=0)}var uAn=function(n){return n===void 0&&(n={}),{name:"hide",options:n,async fn(e){const{rects:t}=e,{strategy:i="referenceHidden",...r}=n3(n,e);switch(i){case"referenceHidden":{const o=await UL(e,{...r,elementContext:"reference"}),s=Xnt(o,t.reference);return{data:{referenceHiddenOffsets:s,referenceHidden:Wnt(s)}}}case"escaped":{const o=await UL(e,{...r,altBoundary:!0}),s=Xnt(o,t.floating);return{data:{escapedOffsets:s,escaped:Wnt(s)}}}default:return{}}}}},Knt=new Set(["left","top"]);async function dAn(n,e){const{placement:t,platform:i,elements:r}=n,o=await(i.isRTL==null?void 0:i.isRTL(r.floating)),s=i3(t),a=CI(t),c=wT(t)==="y",l=Knt.has(s)?-1:1,u=o&&c?-1:1,d=n3(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 hAn=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 dAn(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}}}}},pAn=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:y=>{let{x,y:b}=y;return{x,y:b}}},...c}=n3(n,e),l={x:t,y:i},u=await UL(e,c),d=wT(i3(r)),h=oxe(d);let p=l[h],m=l[d];if(o){const y=h==="y"?"top":"left",x=h==="y"?"bottom":"right",b=p+u[y],w=p-u[x];p=rxe(b,p,w)}if(s){const y=d==="y"?"top":"left",x=d==="y"?"bottom":"right",b=m+u[y],w=m-u[x];m=rxe(b,m,w)}const _=a.fn({...e,[h]:p,[d]:m});return{..._,data:{x:_.x-t,y:_.y-i,enabled:{[h]:o,[d]:s}}}}}},fAn=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}=n3(n,e),u={x:t,y:i},d=wT(r),h=oxe(d);let p=u[h],m=u[d];const _=n3(a,e),y=typeof _=="number"?{mainAxis:_,crossAxis:0}:{mainAxis:0,crossAxis:0,..._};if(c){const w=h==="y"?"height":"width",S=o.reference[h]-o.floating[w]+y.mainAxis,I=o.reference[h]+o.reference[w]-y.mainAxis;p<S?p=S:p>I&&(p=I)}if(l){var x,b;const w=h==="y"?"width":"height",S=Knt.has(i3(r)),I=o.reference[d]-o.floating[w]+(S&&((x=s.offset)==null?void 0:x[d])||0)+(S?0:y.crossAxis),A=o.reference[d]+o.reference[w]+(S?0:((b=s.offset)==null?void 0:b[d])||0)-(S?y.crossAxis:0);m<I?m=I:m>A&&(m=A)}return{[h]:p,[d]:m}}}},mAn=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}=n3(n,e),u=await UL(e,l),d=i3(r),h=CI(r),p=wT(r)==="y",{width:m,height:_}=o.floating;let y,x;d==="top"||d==="bottom"?(y=d,x=h===(await(s.isRTL==null?void 0:s.isRTL(a.floating))?"start":"end")?"left":"right"):(x=d,y=h==="end"?"top":"bottom");const b=_-u.top-u.bottom,w=m-u.left-u.right,S=eC(_-u[y],b),I=eC(m-u[x],w),A=!e.middlewareData.shift;let R=S,M=I;if((t=e.middlewareData.shift)!=null&&t.enabled.x&&(M=w),(i=e.middlewareData.shift)!=null&&i.enabled.y&&(R=b),A&&!h){const C=hS(u.left,0),U=hS(u.right,0),O=hS(u.top,0),H=hS(u.bottom,0);p?M=m-2*(C!==0||U!==0?C+U:hS(u.left,u.right)):R=_-2*(O!==0||H!==0?O+H:hS(u.top,u.bottom))}await c({...e,availableWidth:M,availableHeight:R});const k=await s.getDimensions(a.floating);return m!==k.width||_!==k.height?{reset:{rects:!0}}:{}}}};function oG(){return typeof window<"u"}function AI(n){return Znt(n)?(n.nodeName||"").toLowerCase():"#document"}function pS(n){var e;return(n==null||(e=n.ownerDocument)==null?void 0:e.defaultView)||window}function ST(n){var e;return(e=(Znt(n)?n.ownerDocument:n.document)||window.document)==null?void 0:e.documentElement}function Znt(n){return oG()?n instanceof Node||n instanceof pS(n).Node:!1}function oE(n){return oG()?n instanceof Element||n instanceof pS(n).Element:!1}function ET(n){return oG()?n instanceof HTMLElement||n instanceof pS(n).HTMLElement:!1}function Qnt(n){return!oG()||typeof ShadowRoot>"u"?!1:n instanceof ShadowRoot||n instanceof pS(n).ShadowRoot}var _An=new Set(["inline","contents"]);function BL(n){const{overflow:e,overflowX:t,overflowY:i,display:r}=sE(n);return/auto|scroll|overlay|hidden|clip/.test(e+i+t)&&!_An.has(r)}var yAn=new Set(["table","td","th"]);function gAn(n){return yAn.has(AI(n))}var xAn=[":popover-open",":modal"];function sG(n){return xAn.some(e=>{try{return n.matches(e)}catch{return!1}})}var bAn=["transform","translate","scale","rotate","perspective"],vAn=["transform","translate","scale","rotate","perspective","filter"],wAn=["paint","layout","strict","content"];function lxe(n){const e=uxe(),t=oE(n)?sE(n):n;return bAn.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)||vAn.some(i=>(t.willChange||"").includes(i))||wAn.some(i=>(t.contain||"").includes(i))}function SAn(n){let e=tC(n);for(;ET(e)&&!PI(e);){if(lxe(e))return e;if(sG(e))return null;e=tC(e)}return null}function uxe(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}var EAn=new Set(["html","body","#document"]);function PI(n){return EAn.has(AI(n))}function sE(n){return pS(n).getComputedStyle(n)}function aG(n){return oE(n)?{scrollLeft:n.scrollLeft,scrollTop:n.scrollTop}:{scrollLeft:n.scrollX,scrollTop:n.scrollY}}function tC(n){if(AI(n)==="html")return n;const e=n.assignedSlot||n.parentNode||Qnt(n)&&n.host||ST(n);return Qnt(e)?e.host:e}function Jnt(n){const e=tC(n);return PI(e)?n.ownerDocument?n.ownerDocument.body:n.body:ET(e)&&BL(e)?e:Jnt(e)}function jL(n,e,t){var i;e===void 0&&(e=[]),t===void 0&&(t=!0);const r=Jnt(n),o=r===((i=n.ownerDocument)==null?void 0:i.body),s=pS(r);if(o){const a=dxe(s);return e.concat(s,s.visualViewport||[],BL(r)?r:[],a&&t?jL(a):[])}return e.concat(r,jL(r,[],t))}function dxe(n){return n.parent&&Object.getPrototypeOf(n.parent)?n.frameElement:null}function eit(n){const e=sE(n);let t=parseFloat(e.width)||0,i=parseFloat(e.height)||0;const r=ET(n),o=r?n.offsetWidth:t,s=r?n.offsetHeight:i,a=tG(t)!==o||tG(i)!==s;return a&&(t=o,i=s),{width:t,height:i,$:a}}function hxe(n){return oE(n)?n:n.contextElement}function RI(n){const e=hxe(n);if(!ET(e))return vT(1);const t=e.getBoundingClientRect(),{width:i,height:r,$:o}=eit(e);let s=(o?tG(t.width):t.width)/i,a=(o?tG(t.height):t.height)/r;return(!s||!Number.isFinite(s))&&(s=1),(!a||!Number.isFinite(a))&&(a=1),{x:s,y:a}}var TAn=vT(0);function tit(n){const e=pS(n);return!uxe()||!e.visualViewport?TAn:{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}}function MAn(n,e,t){return e===void 0&&(e=!1),!t||e&&t!==pS(n)?!1:e}function C4(n,e,t,i){e===void 0&&(e=!1),t===void 0&&(t=!1);const r=n.getBoundingClientRect(),o=hxe(n);let s=vT(1);e&&(i?oE(i)&&(s=RI(i)):s=RI(n));const a=MAn(o,t,i)?tit(o):vT(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=pS(o),p=i&&oE(i)?pS(i):i;let m=h,_=dxe(m);for(;_&&i&&p!==m;){const y=RI(_),x=_.getBoundingClientRect(),b=sE(_),w=x.left+(_.clientLeft+parseFloat(b.paddingLeft))*y.x,S=x.top+(_.clientTop+parseFloat(b.paddingTop))*y.y;c*=y.x,l*=y.y,u*=y.x,d*=y.y,c+=w,l+=S,m=pS(_),_=dxe(m)}}return rG({width:u,height:d,x:c,y:l})}function cG(n,e){const t=aG(n).scrollLeft;return e?e.left+t:C4(ST(n)).left+t}function nit(n,e){const t=n.getBoundingClientRect(),i=t.left+e.scrollLeft-cG(n,t),r=t.top+e.scrollTop;return{x:i,y:r}}function CAn(n){let{elements:e,rect:t,offsetParent:i,strategy:r}=n;const o=r==="fixed",s=ST(i),a=e?sG(e.floating):!1;if(i===s||a&&o)return t;let c={scrollLeft:0,scrollTop:0},l=vT(1);const u=vT(0),d=ET(i);if((d||!d&&!o)&&((AI(i)!=="body"||BL(s))&&(c=aG(i)),ET(i))){const p=C4(i);l=RI(i),u.x=p.x+i.clientLeft,u.y=p.y+i.clientTop}const h=s&&!d&&!o?nit(s,c):vT(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 AAn(n){return Array.from(n.getClientRects())}function PAn(n){const e=ST(n),t=aG(n),i=n.ownerDocument.body,r=hS(e.scrollWidth,e.clientWidth,i.scrollWidth,i.clientWidth),o=hS(e.scrollHeight,e.clientHeight,i.scrollHeight,i.clientHeight);let s=-t.scrollLeft+cG(n);const a=-t.scrollTop;return sE(i).direction==="rtl"&&(s+=hS(e.clientWidth,i.clientWidth)-r),{width:r,height:o,x:s,y:a}}var iit=25;function RAn(n,e){const t=pS(n),i=ST(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=uxe();(!u||u&&e==="fixed")&&(a=r.offsetLeft,c=r.offsetTop)}const l=cG(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<=iit&&(o-=m)}else l<=iit&&(o+=l);return{width:o,height:s,x:a,y:c}}var IAn=new Set(["absolute","fixed"]);function NAn(n,e){const t=C4(n,!0,e==="fixed"),i=t.top+n.clientTop,r=t.left+n.clientLeft,o=ET(n)?RI(n):vT(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 rit(n,e,t){let i;if(e==="viewport")i=RAn(n,t);else if(e==="document")i=PAn(ST(n));else if(oE(e))i=NAn(e,t);else{const r=tit(n);i={x:e.x-r.x,y:e.y-r.y,width:e.width,height:e.height}}return rG(i)}function oit(n,e){const t=tC(n);return t===e||!oE(t)||PI(t)?!1:sE(t).position==="fixed"||oit(t,e)}function kAn(n,e){const t=e.get(n);if(t)return t;let i=jL(n,[],!1).filter(a=>oE(a)&&AI(a)!=="body"),r=null;const o=sE(n).position==="fixed";let s=o?tC(n):n;for(;oE(s)&&!PI(s);){const a=sE(s),c=lxe(s);!c&&a.position==="fixed"&&(r=null),(o?!c&&!r:!c&&a.position==="static"&&!!r&&IAn.has(r.position)||BL(s)&&!c&&oit(n,s))?i=i.filter(u=>u!==s):r=a,s=tC(s)}return e.set(n,i),i}function OAn(n){let{element:e,boundary:t,rootBoundary:i,strategy:r}=n;const s=[...t==="clippingAncestors"?sG(e)?[]:kAn(e,this._c):[].concat(t),i],a=s[0],c=s.reduce((l,u)=>{const d=rit(e,u,r);return l.top=hS(d.top,l.top),l.right=eC(d.right,l.right),l.bottom=eC(d.bottom,l.bottom),l.left=hS(d.left,l.left),l},rit(e,a,r));return{width:c.right-c.left,height:c.bottom-c.top,x:c.left,y:c.top}}function LAn(n){const{width:e,height:t}=eit(n);return{width:e,height:t}}function DAn(n,e,t){const i=ET(e),r=ST(e),o=t==="fixed",s=C4(n,!0,o,e);let a={scrollLeft:0,scrollTop:0};const c=vT(0);function l(){c.x=cG(r)}if(i||!i&&!o)if((AI(e)!=="body"||BL(r))&&(a=aG(e)),i){const p=C4(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?nit(r,a):vT(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 pxe(n){return sE(n).position==="static"}function sit(n,e){if(!ET(n)||sE(n).position==="fixed")return null;if(e)return e(n);let t=n.offsetParent;return ST(n)===t&&(t=t.ownerDocument.body),t}function ait(n,e){const t=pS(n);if(sG(n))return t;if(!ET(n)){let r=tC(n);for(;r&&!PI(r);){if(oE(r)&&!pxe(r))return r;r=tC(r)}return t}let i=sit(n,e);for(;i&&gAn(i)&&pxe(i);)i=sit(i,e);return i&&PI(i)&&pxe(i)&&!lxe(i)?t:i||SAn(n)||t}var zAn=async function(n){const e=this.getOffsetParent||ait,t=this.getDimensions,i=await t(n.floating);return{reference:DAn(n.reference,await e(n.floating),n.strategy),floating:{x:0,y:0,width:i.width,height:i.height}}};function $An(n){return sE(n).direction==="rtl"}var FAn={convertOffsetParentRelativeRectToViewportRelativeRect:CAn,getDocumentElement:ST,getClippingRect:OAn,getOffsetParent:ait,getElementRects:zAn,getClientRects:AAn,getDimensions:LAn,getScale:RI,isElement:oE,isRTL:$An};function cit(n,e){return n.x===e.x&&n.y===e.y&&n.width===e.width&&n.height===e.height}function UAn(n,e){let t=null,i;const r=ST(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=nG(d),_=nG(r.clientWidth-(u+h)),y=nG(r.clientHeight-(d+p)),x=nG(u),w={rootMargin:-m+"px "+-_+"px "+-y+"px "+-x+"px",threshold:hS(0,eC(1,c))||1};let S=!0;function I(A){const R=A[0].intersectionRatio;if(R!==c){if(!S)return s();R?s(!1,R):i=setTimeout(()=>{s(!1,1e-7)},1e3)}R===1&&!cit(l,n.getBoundingClientRect())&&s(),S=!1}try{t=new IntersectionObserver(I,{...w,root:r.ownerDocument})}catch{t=new IntersectionObserver(I,w)}t.observe(n)}return s(!0),o}function BAn(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=hxe(n),u=r||o?[...l?jL(l):[],...jL(e)]:[];u.forEach(x=>{r&&x.addEventListener("scroll",t,{passive:!0}),o&&x.addEventListener("resize",t)});const d=l&&a?UAn(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?C4(n):null;c&&y();function y(){const x=C4(n);_&&!cit(_,x)&&t(),_=x,m=requestAnimationFrame(y)}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 jAn=hAn,HAn=pAn,VAn=lAn,GAn=mAn,YAn=uAn,lit=cAn,qAn=fAn,XAn=(n,e,t)=>{const i=new Map,r={platform:FAn,...t},o={...r.platform,_c:i};return aAn(n,e,{...r,platform:o})},WAn=typeof document<"u",KAn=function(){},lG=WAn?ce.useLayoutEffect:KAn;function uG(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(!uG(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)&&!uG(n[o],e[o]))return!1}return!0}return n!==n&&e!==e}function uit(n){return typeof window>"u"?1:(n.ownerDocument.defaultView||window).devicePixelRatio||1}function dit(n,e){const t=uit(n);return Math.round(e*t)/t}function fxe(n){const e=ce.useRef(n);return lG(()=>{e.current=n}),e}function ZAn(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]=ce.useState({x:0,y:0,strategy:t,placement:e,middlewareData:{},isPositioned:!1}),[h,p]=ce.useState(i);uG(h,i)||p(i);const[m,_]=ce.useState(null),[y,x]=ce.useState(null),b=ce.useCallback(le=>{le!==A.current&&(A.current=le,_(le))},[]),w=ce.useCallback(le=>{le!==R.current&&(R.current=le,x(le))},[]),S=o||m,I=s||y,A=ce.useRef(null),R=ce.useRef(null),M=ce.useRef(u),k=c!=null,C=fxe(c),U=fxe(r),O=fxe(l),H=ce.useCallback(()=>{if(!A.current||!R.current)return;const le={placement:e,strategy:t,middleware:h};U.current&&(le.platform=U.current),XAn(A.current,R.current,le).then(he=>{const ve={...he,isPositioned:O.current!==!1};Y.current&&!uG(M.current,ve)&&(M.current=ve,JO.flushSync(()=>{d(ve)}))})},[h,e,t,U,O]);lG(()=>{l===!1&&M.current.isPositioned&&(M.current.isPositioned=!1,d(le=>({...le,isPositioned:!1})))},[l]);const Y=ce.useRef(!1);lG(()=>(Y.current=!0,()=>{Y.current=!1}),[]),lG(()=>{if(S&&(A.current=S),I&&(R.current=I),S&&I){if(C.current)return C.current(S,I,H);H()}},[S,I,H,C,k]);const X=ce.useMemo(()=>({reference:A,floating:R,setReference:b,setFloating:w}),[b,w]),K=ce.useMemo(()=>({reference:S,floating:I}),[S,I]),J=ce.useMemo(()=>{const le={position:t,left:0,top:0};if(!K.floating)return le;const he=dit(K.floating,u.x),ve=dit(K.floating,u.y);return a?{...le,transform:"translate("+he+"px, "+ve+"px)",...uit(K.floating)>=1.5&&{willChange:"transform"}}:{position:t,left:he,top:ve}},[t,a,K.floating,u.x,u.y]);return ce.useMemo(()=>({...u,update:H,refs:X,elements:K,floatingStyles:J}),[u,H,X,K,J])}var QAn=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?lit({element:i.current,padding:r}).fn(t):{}:i?lit({element:i,padding:r}).fn(t):{}}}},JAn=(n,e)=>({...jAn(n),options:[n,e]}),e4n=(n,e)=>({...HAn(n),options:[n,e]}),t4n=(n,e)=>({...qAn(n),options:[n,e]}),n4n=(n,e)=>({...VAn(n),options:[n,e]}),i4n=(n,e)=>({...GAn(n),options:[n,e]}),r4n=(n,e)=>({...YAn(n),options:[n,e]}),o4n=(n,e)=>({...QAn(n),options:[n,e]}),s4n="Arrow",hit=ce.forwardRef((n,e)=>{const{children:t,width:i=10,height:r=5,...o}=n;return re.jsx(Ov.svg,{...o,ref:e,width:i,height:r,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:n.asChild?t:re.jsx("polygon",{points:"0,0 30,0 15,10"})})});hit.displayName=s4n;var a4n=hit;function c4n(n){const[e,t]=ce.useState(void 0);return QM(()=>{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 mxe="Popper",[pit,fit]=$L(mxe),[l4n,mit]=pit(mxe),_it=n=>{const{__scopePopper:e,children:t}=n,[i,r]=ce.useState(null);return re.jsx(l4n,{scope:e,anchor:i,onAnchorChange:r,children:t})};_it.displayName=mxe;var yit="PopperAnchor",git=ce.forwardRef((n,e)=>{const{__scopePopper:t,virtualRef:i,...r}=n,o=mit(yit,t),s=ce.useRef(null),a=_w(e,s),c=ce.useRef(null);return ce.useEffect(()=>{const l=c.current;c.current=i?.current||s.current,l!==c.current&&o.onAnchorChange(c.current)}),i?null:re.jsx(Ov.div,{...r,ref:a})});git.displayName=yit;var _xe="PopperContent",[u4n,d4n]=pit(_xe),xit=ce.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,y=mit(_xe,t),[x,b]=ce.useState(null),w=_w(e,$e=>b($e)),[S,I]=ce.useState(null),A=c4n(S),R=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(p4n),altBoundary:O},{refs:Y,floatingStyles:X,placement:K,isPositioned:J,middlewareData:le}=ZAn({strategy:"fixed",placement:k,whileElementsMounted:(...$e)=>BAn(...$e,{animationFrame:p==="always"}),elements:{reference:y.anchor},middleware:[JAn({mainAxis:r+M,alignmentAxis:s}),c&&e4n({mainAxis:!0,crossAxis:!1,limiter:d==="partial"?t4n():void 0,...H}),c&&n4n({...H}),i4n({...H,apply:({elements:$e,rects:Ae,availableWidth:se,availableHeight:Se})=>{const{width:xe,height:Ve}=Ae.reference,tt=$e.floating.style;tt.setProperty("--radix-popper-available-width",`${se}px`),tt.setProperty("--radix-popper-available-height",`${Se}px`),tt.setProperty("--radix-popper-anchor-width",`${xe}px`),tt.setProperty("--radix-popper-anchor-height",`${Ve}px`)}}),S&&o4n({element:S,padding:a}),f4n({arrowWidth:R,arrowHeight:M}),h&&r4n({strategy:"referenceHidden",...H})]}),[he,ve]=wit(K),oe=bT(m);QM(()=>{J&&oe?.()},[J,oe]);const ae=le.arrow?.x,de=le.arrow?.y,Te=le.arrow?.centerOffset!==0,[Ce,Oe]=ce.useState();return QM(()=>{x&&Oe(window.getComputedStyle(x).zIndex)},[x]),re.jsx("div",{ref:Y.setFloating,"data-radix-popper-content-wrapper":"",style:{...X,transform:J?X.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:Ce,"--radix-popper-transform-origin":[le.transformOrigin?.x,le.transformOrigin?.y].join(" "),...le.hide?.referenceHidden&&{visibility:"hidden",pointerEvents:"none"}},dir:n.dir,children:re.jsx(u4n,{scope:t,placedSide:he,onArrowChange:I,arrowX:ae,arrowY:de,shouldHideArrow:Te,children:re.jsx(Ov.div,{"data-side":he,"data-align":ve,..._,ref:w,style:{..._.style,animation:J?void 0:"none"}})})})});xit.displayName=_xe;var bit="PopperArrow",h4n={top:"bottom",right:"left",bottom:"top",left:"right"},vit=ce.forwardRef(function(e,t){const{__scopePopper:i,...r}=e,o=d4n(bit,i),s=h4n[o.placedSide];return re.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:re.jsx(a4n,{...r,ref:t,style:{...r.style,display:"block"}})})});vit.displayName=bit;function p4n(n){return n!==null}var f4n=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]=wit(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 wit(n){const[e,t="center"]=n.split("-");return[e,t]}var Sit=_it,m4n=git,_4n=xit,y4n=vit,g4n="Portal",Eit=ce.forwardRef((n,e)=>{const{container:t,...i}=n,[r,o]=ce.useState(!1);QM(()=>o(!0),[]);const s=t||r&&globalThis?.document?.body;return s?mj.createPortal(re.jsx(Ov.div,{...i,ref:e}),s):null});Eit.displayName=g4n;function x4n(n,e){return ce.useReducer((t,i)=>e[t][i]??t,n)}var HL=n=>{const{present:e,children:t}=n,i=b4n(e),r=typeof t=="function"?t({present:i.isPresent}):ce.Children.only(t),o=_w(i.ref,v4n(r));return typeof t=="function"||i.isPresent?ce.cloneElement(r,{ref:o}):null};HL.displayName="Presence";function b4n(n){const[e,t]=ce.useState(),i=ce.useRef(null),r=ce.useRef(n),o=ce.useRef("none"),s=n?"mounted":"unmounted",[a,c]=x4n(s,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return ce.useEffect(()=>{const l=dG(i.current);o.current=a==="mounted"?l:"none"},[a]),QM(()=>{const l=i.current,u=r.current;if(u!==n){const h=o.current,p=dG(l);n?c("MOUNT"):p==="none"||l?.display==="none"?c("UNMOUNT"):c(u&&h!==p?"ANIMATION_OUT":"UNMOUNT"),r.current=n}},[n,c]),QM(()=>{if(e){let l;const u=e.ownerDocument.defaultView??window,d=p=>{const _=dG(i.current).includes(CSS.escape(p.animationName));if(p.target===e&&_&&(c("ANIMATION_END"),!r.current)){const y=e.style.animationFillMode;e.style.animationFillMode="forwards",l=u.setTimeout(()=>{e.style.animationFillMode==="forwards"&&(e.style.animationFillMode=y)})}},h=p=>{p.target===e&&(o.current=dG(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:ce.useCallback(l=>{i.current=l?getComputedStyle(l):null,t(l)},[])}}function dG(n){return n?.animationName||"none"}function v4n(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 yxe="rovingFocusGroup.onEntryFocus",w4n={bubbles:!1,cancelable:!0},VL="RovingFocusGroup",[gxe,Tit,S4n]=Rnt(VL),[E4n,Mit]=$L(VL,[S4n]),[T4n,M4n]=E4n(VL),Cit=ce.forwardRef((n,e)=>re.jsx(gxe.Provider,{scope:n.__scopeRovingFocusGroup,children:re.jsx(gxe.Slot,{scope:n.__scopeRovingFocusGroup,children:re.jsx(C4n,{...n,ref:e})})}));Cit.displayName=VL;var C4n=ce.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=ce.useRef(null),p=_w(e,h),m=Int(o),[_,y]=Jge({prop:s,defaultProp:a??null,onChange:c,caller:VL}),[x,b]=ce.useState(!1),w=bT(l),S=Tit(t),I=ce.useRef(!1),[A,R]=ce.useState(0);return ce.useEffect(()=>{const M=h.current;if(M)return M.addEventListener(yxe,w),()=>M.removeEventListener(yxe,w)},[w]),re.jsx(T4n,{scope:t,orientation:i,dir:m,loop:r,currentTabStopId:_,onItemFocus:ce.useCallback(M=>y(M),[y]),onItemShiftTab:ce.useCallback(()=>b(!0),[]),onFocusableItemAdd:ce.useCallback(()=>R(M=>M+1),[]),onFocusableItemRemove:ce.useCallback(()=>R(M=>M-1),[]),children:re.jsx(Ov.div,{tabIndex:x||A===0?-1:0,"data-orientation":i,...d,ref:p,style:{outline:"none",...n.style},onMouseDown:xd(n.onMouseDown,()=>{I.current=!0}),onFocus:xd(n.onFocus,M=>{const k=!I.current;if(M.target===M.currentTarget&&k&&!x){const C=new CustomEvent(yxe,w4n);if(M.currentTarget.dispatchEvent(C),!C.defaultPrevented){const U=S().filter(K=>K.focusable),O=U.find(K=>K.active),H=U.find(K=>K.id===_),X=[O,H,...U].filter(Boolean).map(K=>K.ref.current);Rit(X,u)}}I.current=!1}),onBlur:xd(n.onBlur,()=>b(!1))})})}),Ait="RovingFocusGroupItem",Pit=ce.forwardRef((n,e)=>{const{__scopeRovingFocusGroup:t,focusable:i=!0,active:r=!1,tabStopId:o,children:s,...a}=n,c=FL(),l=o||c,u=M4n(Ait,t),d=u.currentTabStopId===l,h=Tit(t),{onFocusableItemAdd:p,onFocusableItemRemove:m,currentTabStopId:_}=u;return ce.useEffect(()=>{if(i)return p(),()=>m()},[i,p,m]),re.jsx(gxe.ItemSlot,{scope:t,id:l,focusable:i,active:r,children:re.jsx(Ov.span,{tabIndex:d?0:-1,"data-orientation":u.orientation,...a,ref:e,onMouseDown:xd(n.onMouseDown,y=>{i?u.onItemFocus(l):y.preventDefault()}),onFocus:xd(n.onFocus,()=>u.onItemFocus(l)),onKeyDown:xd(n.onKeyDown,y=>{if(y.key==="Tab"&&y.shiftKey){u.onItemShiftTab();return}if(y.target!==y.currentTarget)return;const x=R4n(y,u.orientation,u.dir);if(x!==void 0){if(y.metaKey||y.ctrlKey||y.altKey||y.shiftKey)return;y.preventDefault();let w=h().filter(S=>S.focusable).map(S=>S.ref.current);if(x==="last")w.reverse();else if(x==="prev"||x==="next"){x==="prev"&&w.reverse();const S=w.indexOf(y.currentTarget);w=u.loop?I4n(w,S+1):w.slice(S+1)}setTimeout(()=>Rit(w))}}),children:typeof s=="function"?s({isCurrentTabStop:d,hasTabStop:_!=null}):s})})});Pit.displayName=Ait;var A4n={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function P4n(n,e){return e!=="rtl"?n:n==="ArrowLeft"?"ArrowRight":n==="ArrowRight"?"ArrowLeft":n}function R4n(n,e,t){const i=P4n(n.key,t);if(!(e==="vertical"&&["ArrowLeft","ArrowRight"].includes(i))&&!(e==="horizontal"&&["ArrowUp","ArrowDown"].includes(i)))return A4n[i]}function Rit(n,e=!1){const t=document.activeElement;for(const i of n)if(i===t||(i.focus({preventScroll:e}),document.activeElement!==t))return}function I4n(n,e){return n.map((t,i)=>n[(e+i)%n.length])}var N4n=Cit,k4n=Pit,O4n=function(n){if(typeof document>"u")return null;var e=Array.isArray(n)?n[0]:n;return e.ownerDocument.body},II=new WeakMap,hG=new WeakMap,pG={},xxe=0,Iit=function(n){return n&&(n.host||Iit(n.parentNode))},L4n=function(n,e){return e.map(function(t){if(n.contains(t))return t;var i=Iit(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})},D4n=function(n,e,t,i){var r=L4n(e,Array.isArray(n)?n:[n]);pG[t]||(pG[t]=new WeakMap);var o=pG[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",_=(II.get(h)||0)+1,y=(o.get(h)||0)+1;II.set(h,_),o.set(h,y),s.push(h),_===1&&m&&hG.set(h,!0),y===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(),xxe++,function(){s.forEach(function(d){var h=II.get(d)-1,p=o.get(d)-1;II.set(d,h),o.set(d,p),h||(hG.has(d)||d.removeAttribute(i),hG.delete(d)),p||d.removeAttribute(t)}),xxe--,xxe||(II=new WeakMap,II=new WeakMap,hG=new WeakMap,pG={})}},z4n=function(n,e,t){t===void 0&&(t="data-aria-hidden");var i=Array.from(Array.isArray(n)?n:[n]),r=O4n(n);return r?(i.push.apply(i,Array.from(r.querySelectorAll("[aria-live], script"))),D4n(i,r,t,"aria-hidden")):function(){return null}},TT=function(){return TT=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},TT.apply(this,arguments)};function Nit(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 $4n(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 fG="right-scroll-bar-position",mG="width-before-scroll-bar",F4n="with-scroll-bars-hidden",U4n="--removed-body-scroll-bar-size";function bxe(n,e){return typeof n=="function"?n(e):n&&(n.current=e),n}function B4n(n,e){var t=ce.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 j4n=typeof window<"u"?ce.useLayoutEffect:ce.useEffect,kit=new WeakMap;function H4n(n,e){var t=B4n(null,function(i){return n.forEach(function(r){return bxe(r,i)})});return j4n(function(){var i=kit.get(t);if(i){var r=new Set(i),o=new Set(n),s=t.current;r.forEach(function(a){o.has(a)||bxe(a,null)}),o.forEach(function(a){r.has(a)||bxe(a,s)})}kit.set(t,n)},[n]),t}function V4n(n){return n}function G4n(n,e){e===void 0&&(e=V4n);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 Y4n(n){n===void 0&&(n={});var e=G4n(null);return e.options=TT({async:!0,ssr:!1},n),e}var Oit=function(n){var e=n.sideCar,t=Nit(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 ce.createElement(i,TT({},t))};Oit.isSideCarExport=!0;function q4n(n,e){return n.useMedium(e),Oit}var Lit=Y4n(),vxe=function(){},_G=ce.forwardRef(function(n,e){var t=ce.useRef(null),i=ce.useState({onScrollCapture:vxe,onWheelCapture:vxe,onTouchMoveCapture:vxe}),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,y=n.allowPinchZoom,x=n.as,b=x===void 0?"div":x,w=n.gapMode,S=Nit(n,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),I=h,A=H4n([t,e]),R=TT(TT({},S),r);return ce.createElement(ce.Fragment,null,u&&ce.createElement(I,{sideCar:Lit,removeScrollBar:l,shards:d,noRelative:p,noIsolation:m,inert:_,setCallbacks:o,allowPinchZoom:!!y,lockRef:t,gapMode:w}),s?ce.cloneElement(ce.Children.only(a),TT(TT({},R),{ref:A})):ce.createElement(b,TT({},R,{className:c,ref:A}),a))});_G.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},_G.classNames={fullWidth:mG,zeroRight:fG};var X4n=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function W4n(){if(!document)return null;var n=document.createElement("style");n.type="text/css";var e=X4n();return e&&n.setAttribute("nonce",e),n}function K4n(n,e){n.styleSheet?n.styleSheet.cssText=e:n.appendChild(document.createTextNode(e))}function Z4n(n){var e=document.head||document.getElementsByTagName("head")[0];e.appendChild(n)}var Q4n=function(){var n=0,e=null;return{add:function(t){n==0&&(e=W4n())&&(K4n(e,t),Z4n(e)),n++},remove:function(){n--,!n&&e&&(e.parentNode&&e.parentNode.removeChild(e),e=null)}}},J4n=function(){var n=Q4n();return function(e,t){ce.useEffect(function(){return n.add(e),function(){n.remove()}},[e&&t])}},Dit=function(){var n=J4n(),e=function(t){var i=t.styles,r=t.dynamic;return n(i,r),null};return e},ePn={left:0,top:0,right:0,gap:0},wxe=function(n){return parseInt(n||"",10)||0},tPn=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[wxe(t),wxe(i),wxe(r)]},nPn=function(n){if(n===void 0&&(n="margin"),typeof window>"u")return ePn;var e=tPn(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])}},iPn=Dit(),NI="data-scroll-locked",rPn=function(n,e,t,i){var r=n.left,o=n.top,s=n.right,a=n.gap;return t===void 0&&(t="margin"),`
|
|
5168
5168
|
.`.concat(F4n,` {
|
|
5169
5169
|
overflow: hidden `).concat(i,`;
|
|
5170
5170
|
padding-right: `).concat(a,"px ").concat(i,`;
|
|
@@ -5869,7 +5869,7 @@ $1`).replace(/>(\s*)(?=<!--\s*\/)/g,"> ")}}});function Vht(n,e,t){if(!e||!t)retu
|
|
|
5869
5869
|
* Copyright (c) 2013-2015, 2017, Jon Schlinkert.
|
|
5870
5870
|
* Released under the MIT License.
|
|
5871
5871
|
*)
|
|
5872
|
-
*/const Tjn=({containerClassName:n,...e})=>{const t=ce.useRef(null),[i,r]=ce.useState(620);return ce.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)}},[]),re.jsx("div",{ref:t,className:n||"rf-w-full rf-h-full",children:re.jsx(Ejn,{...e,height:i})})},Mjn='*,: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}',yq=()=>{ce.useEffect(()=>{if(document.querySelector('style[data-styles="tscircuit-runframe"]'))return;const e=document.createElement("style");e.setAttribute("data-styles","tscircuit-runframe"),e.textContent=Mjn,document.head.appendChild(e)},[])},Cjn=n=>{ce.useEffect(()=>(n?document.body.style.overflow="hidden":document.body.style.overflow="",()=>{document.body.style.overflow=""}),[n])};function aN(n,e){const[t,i]=ce.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 ce.useEffect(()=>{try{window.localStorage.setItem(n,JSON.stringify(t))}catch(r){console.error("Error writing to localStorage:",r)}},[n,t]),[t,i]}const lpt=n=>`hsl(${lw.indexOf(n)*137.5%360}, 70%, 50%)`,Ajn=({phaseTimings:n})=>{if(!n)return null;const e=Object.values(n).reduce((t,i)=>t+i,0);return re.jsxs("div",{className:"rf-space-y-2 rf-w-full rf-px-4",children:[re.jsx("div",{className:"rf-relative rf-h-8 rf-flex rf-rounded-sm",children:lw.map(t=>{const i=n[t]||0,r=i/e*100;return re.jsx("div",{className:"rf-group/bar rf-relative rf-overflow-visible",style:{width:`${r}%`,backgroundColor:lpt(t)},children:re.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)})}),re.jsxs("div",{className:"rf-text-xs rf-text-gray-500",children:["Total: ",e.toFixed(2),"ms"]})]})},Pjn=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)},Rjn=({renderLog:n,onRerunWithDebug:e})=>{const[t,i]=ce.useState("chronological"),[r,o]=ce.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 re.jsxs("div",{className:"rf-p-4 rf-bg-gray-100 rf-rounded-md",children:[re.jsx("div",{className:"rf-mb-4",children:"No render log, make sure this tab is open when you render"}),e&&re.jsxs("div",{className:"rf-flex rf-gap-2 rf-items-center",children:[re.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=>re.jsx("option",{value:l.value,children:l.label},l.value))}),re.jsx(R0,{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)=>lw.indexOf(l[0])-lw.indexOf(u[0])):a.sort((l,u)=>u[1]-l[1]);const c=a.reduce((l,[u,d])=>l+d,0);return re.jsxs("div",{className:"rf-bg-white",children:[re.jsxs("div",{className:"rf-flex rf-justify-between rf-items-center rf-mb-4",children:[re.jsx("div",{children:"Render Logs"}),re.jsxs("div",{className:"rf-flex rf-gap-4 rf-items-center",children:[e&&re.jsxs("div",{className:"rf-flex rf-gap-2 rf-items-center",children:[re.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=>re.jsx("option",{value:l.value,children:l.label},l.value))}),re.jsx(R0,{onClick:()=>e(r),size:"sm",className:"rf-text-xs",children:"Rerun Render with Debug"})]}),re.jsx("div",{className:"rf-flex rf-gap-2 rf-items-center",children:re.jsxs("select",{onChange:l=>{if(l.target.value){const u=n?.debugOutputs?.find(d=>d.name===l.target.value);if(u){const d=Pjn(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:[re.jsx("option",{value:"",children:"Download Debug Output"}),n?.debugOutputs?.map(l=>re.jsx("option",{value:l.name,children:l.name},l.name))]})}),re.jsxs("div",{className:"rf-flex rf-text-xs rf-items-center",children:[re.jsx("div",{className:"rf-mr-2",children:"Sort by:"}),re.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:[re.jsx("option",{value:"chronological",children:"Phase Order"}),re.jsx("option",{value:"longest",children:"Duration"})]})]})]})]}),re.jsx(Ajn,{phaseTimings:n.phaseTimings}),re.jsxs("table",{className:"rf-w-full rf-text-xs",children:[re.jsx("thead",{children:re.jsxs("tr",{children:[re.jsx("th",{className:"rf-text-left rf-p-2",children:"Phase Order"}),re.jsx("th",{className:"rf-text-left rf-p-2",children:"Phase"}),re.jsx("th",{className:"rf-text-left rf-p-2",children:"Duration (ms)"})]})}),re.jsx("tbody",{children:a.map(([l,u])=>re.jsxs("tr",{children:[re.jsx("td",{className:"rf-p-2",children:lw.indexOf(l)}),re.jsx("td",{className:"rf-p-2",children:l}),re.jsx("td",{className:"rf-p-2",children:re.jsx("div",{className:"rf-w-8",children:re.jsx("div",{className:"rf-h-2 rf-rounded-sm",style:{backgroundColor:lpt(l),width:`${u/c*100}%`}})})}),re.jsx("td",{className:"rf-p-2",children:re.jsxs("div",{className:"rf-flex w-full",children:[re.jsxs("span",{className:"rf-flex-grow",children:[u,"ms"]}),re.jsxs("span",{className:"rf-text-gray-500 rf-pr-2",children:[(u/c*100).toFixed(1),"%"]})]})})]},l))})]})]})},upt=({errorMessage:n,errorStack:e,circuitJsonErrors:t})=>{ce.useEffect(()=>{if(n){const i=new Error(n);e&&(i.stack=e);try{Yj.captureException(i)}catch{}}},[n,e]),ce.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{Yj.captureException(r,{error_type:i.type})}catch{}}},[t])},dpt="0.0.1208",Ijn={version:dpt},gq=Sze()(Eze(n=>({lastRunEvalVersion:void 0,setLastRunEvalVersion:e=>{n({lastRunEvalVersion:e})}}),{name:"runframe-runner-store"})),Njn=n=>{const[e,t]=ce.useState([]),[i,r]=ce.useState(null),[o,s]=ce.useState(""),[a,c]=aN("eval-version-selection",null),l=gq(p=>p.setLastRunEvalVersion),u=gq(p=>p.lastRunEvalVersion);return ce.useEffect(()=>{n&&fetch("https://data.jsdelivr.com/v1/package/npm/@tscircuit/eval").then(p=>p.json()).then(p=>{if(Array.isArray(p?.versions)){let m=[...p.versions];p.tags?.latest&&(r(p.tags.latest),m=m.filter(_=>_!==p.tags.latest)),t(m)}}).catch(()=>{})},[n]),ce.useEffect(()=>{n&&(a?(window.TSCIRCUIT_LATEST_EVAL_VERSION=a,l(a)):i&&(window.TSCIRCUIT_LATEST_EVAL_VERSION=i,l(i)))},[n,a,i]),{versions:ce.useMemo(()=>e.filter(p=>p.includes(o)).slice(0,50),[e,o]),latestVersion:i,lastRunEvalVersion:u,search:o,setSearch:s,selectVersion:p=>{c(p),s("")}}},kjn=({snippetNames:n,onSelect:e,onCancel:t,isOpen:i})=>{const[r,o]=ce.useState(""),[s,a]=ce.useState("");if(!i)return null;const c=n.filter(d=>d.toLowerCase().includes(s.toLowerCase())),l=s&&!n.includes(s),u=d=>{d.key==="Enter"&&(c.length===1?o(c[0]):l&&o(s))};return re.jsx("div",{className:"rf-fixed rf-inset-0 rf-bg-black rf-bg-opacity-50 rf-flex rf-items-center rf-justify-center rf-z-[100]",children:re.jsxs("div",{className:"rf-bg-white rf-rounded-lg rf-p-6 rf-w-96",children:[re.jsx("h2",{className:"rf-text-lg rf-font-semibold rf-mb-4",children:"Select Snippet"}),re.jsx("input",{type:"text",className:"rf-w-full rf-px-4 rf-py-2 rf-border rf-rounded rf-mb-4",placeholder:"Search snippets or new snippet name...",value:s,onChange:d=>a(d.target.value),onKeyDown:u}),re.jsxs("div",{className:"rf-h-60 rf-overflow-y-auto",children:[c.map(d=>re.jsx("button",{type:"button",className:`w-full text-left px-4 py-2 rounded hover:bg-gray-100 ${r===d?"bg-blue-50":""}`,onClick:()=>o(d),children:d},d)),l&&re.jsxs("button",{type:"button",className:`w-full text-left px-4 py-2 rounded hover:bg-gray-100 text-blue-500 ${r===s?"bg-blue-50":""}`,onClick:()=>o(s),children:['Create new "',s,'"']})]}),re.jsxs("div",{className:"rf-mt-4 rf-flex rf-justify-end rf-gap-2",children:[re.jsx("button",{type:"button",className:"rf-px-4 rf-py-2 rf-text-gray-600 rf-hover:text-gray-800",onClick:t,children:"Cancel"}),re.jsx("button",{type:"button",className:"rf-px-4 rf-py-2 rf-bg-blue-500 rf-text-white rf-rounded rf-hover:bg-blue-600 rf-disabled:opacity-50",onClick:()=>r&&e(r),disabled:!r,children:r===s?`Create "${r}"`:`Save to ${r}`})]})]})})},Ojn=n=>{const e=ce.useRef(null),t=ub(i=>i.recentEvents);ce.useEffect(()=>{if(t.length===0)return;const i=t[0];i.event_id!==e.current&&(n(i),e.current=i.event_id)},[t,n])};var xq="Dialog",[hpt,ppt]=eT(xq),[Ljn,hE]=hpt(xq),fpt=n=>{const{__scopeDialog:e,children:t,open:i,defaultOpen:r,onOpenChange:o,modal:s=!0}=n,a=ce.useRef(null),c=ce.useRef(null),[l,u]=jA({prop:i,defaultProp:r??!1,onChange:o,caller:xq});return re.jsx(Ljn,{scope:e,triggerRef:a,contentRef:c,contentId:Gb(),titleId:Gb(),descriptionId:Gb(),open:l,onOpenChange:u,onOpenToggle:ce.useCallback(()=>u(d=>!d),[u]),modal:s,children:t})};fpt.displayName=xq;var mpt="DialogTrigger",_pt=ce.forwardRef((n,e)=>{const{__scopeDialog:t,...i}=n,r=hE(mpt,t),o=H_(e,r.triggerRef);return re.jsx(uu.button,{type:"button","aria-haspopup":"dialog","aria-expanded":r.open,"aria-controls":r.contentId,"data-state":bve(r.open),...i,ref:o,onClick:ca(n.onClick,r.onOpenToggle)})});_pt.displayName=mpt;var gve="DialogPortal",[Djn,ypt]=hpt(gve,{forceMount:void 0}),gpt=n=>{const{__scopeDialog:e,forceMount:t,children:i,container:r}=n,o=hE(gve,e);return re.jsx(Djn,{scope:e,forceMount:t,children:ce.Children.map(i,s=>re.jsx(KS,{present:t||o.open,children:re.jsx(FG,{asChild:!0,container:r,children:s})}))})};gpt.displayName=gve;var bq="DialogOverlay",xpt=ce.forwardRef((n,e)=>{const t=ypt(bq,n.__scopeDialog),{forceMount:i=t.forceMount,...r}=n,o=hE(bq,n.__scopeDialog);return o.modal?re.jsx(KS,{present:i||o.open,children:re.jsx($jn,{...r,ref:e})}):null});xpt.displayName=bq;var zjn=BA("DialogOverlay.RemoveScroll"),$jn=ce.forwardRef((n,e)=>{const{__scopeDialog:t,...i}=n,r=hE(bq,t);return re.jsx(qG,{as:zjn,allowPinchZoom:!0,shards:[r.contentRef],children:re.jsx(uu.div,{"data-state":bve(r.open),...i,ref:e,style:{pointerEvents:"auto",...i.style}})})}),Q4="DialogContent",bpt=ce.forwardRef((n,e)=>{const t=ypt(Q4,n.__scopeDialog),{forceMount:i=t.forceMount,...r}=n,o=hE(Q4,n.__scopeDialog);return re.jsx(KS,{present:i||o.open,children:o.modal?re.jsx(Fjn,{...r,ref:e}):re.jsx(Ujn,{...r,ref:e})})});bpt.displayName=Q4;var Fjn=ce.forwardRef((n,e)=>{const t=hE(Q4,n.__scopeDialog),i=ce.useRef(null),r=H_(e,t.contentRef,i);return ce.useEffect(()=>{const o=i.current;if(o)return o1e(o)},[]),re.jsx(vpt,{...n,ref:r,trapFocus:t.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:ca(n.onCloseAutoFocus,o=>{o.preventDefault(),t.triggerRef.current?.focus()}),onPointerDownOutside:ca(n.onPointerDownOutside,o=>{const s=o.detail.originalEvent,a=s.button===0&&s.ctrlKey===!0;(s.button===2||a)&&o.preventDefault()}),onFocusOutside:ca(n.onFocusOutside,o=>o.preventDefault())})}),Ujn=ce.forwardRef((n,e)=>{const t=hE(Q4,n.__scopeDialog),i=ce.useRef(!1),r=ce.useRef(!1);return re.jsx(vpt,{...n,ref:e,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:o=>{n.onCloseAutoFocus?.(o),o.defaultPrevented||(i.current||t.triggerRef.current?.focus(),o.preventDefault()),i.current=!1,r.current=!1},onInteractOutside:o=>{n.onInteractOutside?.(o),o.defaultPrevented||(i.current=!0,o.detail.originalEvent.type==="pointerdown"&&(r.current=!0));const s=o.target;t.triggerRef.current?.contains(s)&&o.preventDefault(),o.detail.originalEvent.type==="focusin"&&r.current&&o.preventDefault()}})}),vpt=ce.forwardRef((n,e)=>{const{__scopeDialog:t,trapFocus:i,onOpenAutoFocus:r,onCloseAutoFocus:o,...s}=n,a=hE(Q4,t),c=ce.useRef(null),l=H_(e,c);return Uxe(),re.jsxs(re.Fragment,{children:[re.jsx(CG,{asChild:!0,loop:!0,trapped:i,onMountAutoFocus:r,onUnmountAutoFocus:o,children:re.jsx(MG,{role:"dialog",id:a.contentId,"aria-describedby":a.descriptionId,"aria-labelledby":a.titleId,"data-state":bve(a.open),...s,ref:l,onDismiss:()=>a.onOpenChange(!1)})}),re.jsxs(re.Fragment,{children:[re.jsx(jjn,{titleId:a.titleId}),re.jsx(Vjn,{contentRef:c,descriptionId:a.descriptionId})]})]})}),xve="DialogTitle",wpt=ce.forwardRef((n,e)=>{const{__scopeDialog:t,...i}=n,r=hE(xve,t);return re.jsx(uu.h2,{id:r.titleId,...i,ref:e})});wpt.displayName=xve;var Spt="DialogDescription",Ept=ce.forwardRef((n,e)=>{const{__scopeDialog:t,...i}=n,r=hE(Spt,t);return re.jsx(uu.p,{id:r.descriptionId,...i,ref:e})});Ept.displayName=Spt;var Tpt="DialogClose",Mpt=ce.forwardRef((n,e)=>{const{__scopeDialog:t,...i}=n,r=hE(Tpt,t);return re.jsx(uu.button,{type:"button",...i,ref:e,onClick:ca(n.onClick,()=>r.onOpenChange(!1))})});Mpt.displayName=Tpt;function bve(n){return n?"open":"closed"}var Cpt="DialogTitleWarning",[Bjn,Apt]=hen(Cpt,{contentName:Q4,titleName:xve,docsSlug:"dialog"}),jjn=({titleId:n})=>{const e=Apt(Cpt),t=`\`${e.contentName}\` requires a \`${e.titleName}\` for the component to be accessible for screen reader users.
|
|
5872
|
+
*/const Tjn=({containerClassName:n,...e})=>{const t=ce.useRef(null),[i,r]=ce.useState(620);return ce.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)}},[]),re.jsx("div",{ref:t,className:n||"rf-w-full rf-h-full",children:re.jsx(Ejn,{...e,height:i})})},Mjn='*,: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}',yq=()=>{ce.useEffect(()=>{if(document.querySelector('style[data-styles="tscircuit-runframe"]'))return;const e=document.createElement("style");e.setAttribute("data-styles","tscircuit-runframe"),e.textContent=Mjn,document.head.appendChild(e)},[])},Cjn=n=>{ce.useEffect(()=>(n?document.body.style.overflow="hidden":document.body.style.overflow="",()=>{document.body.style.overflow=""}),[n])};function aN(n,e){const[t,i]=ce.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 ce.useEffect(()=>{try{window.localStorage.setItem(n,JSON.stringify(t))}catch(r){console.error("Error writing to localStorage:",r)}},[n,t]),[t,i]}const lpt=n=>`hsl(${lw.indexOf(n)*137.5%360}, 70%, 50%)`,Ajn=({phaseTimings:n})=>{if(!n)return null;const e=Object.values(n).reduce((t,i)=>t+i,0);return re.jsxs("div",{className:"rf-space-y-2 rf-w-full rf-px-4",children:[re.jsx("div",{className:"rf-relative rf-h-8 rf-flex rf-rounded-sm",children:lw.map(t=>{const i=n[t]||0,r=i/e*100;return re.jsx("div",{className:"rf-group/bar rf-relative rf-overflow-visible",style:{width:`${r}%`,backgroundColor:lpt(t)},children:re.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)})}),re.jsxs("div",{className:"rf-text-xs rf-text-gray-500",children:["Total: ",e.toFixed(2),"ms"]})]})},Pjn=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)},Rjn=({renderLog:n,onRerunWithDebug:e})=>{const[t,i]=ce.useState("chronological"),[r,o]=ce.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 re.jsxs("div",{className:"rf-p-4 rf-bg-gray-100 rf-rounded-md",children:[re.jsx("div",{className:"rf-mb-4",children:"No render log, make sure this tab is open when you render"}),e&&re.jsxs("div",{className:"rf-flex rf-gap-2 rf-items-center",children:[re.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=>re.jsx("option",{value:l.value,children:l.label},l.value))}),re.jsx(R0,{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)=>lw.indexOf(l[0])-lw.indexOf(u[0])):a.sort((l,u)=>u[1]-l[1]);const c=a.reduce((l,[u,d])=>l+d,0);return re.jsxs("div",{className:"rf-bg-white",children:[re.jsxs("div",{className:"rf-flex rf-justify-between rf-items-center rf-mb-4",children:[re.jsx("div",{children:"Render Logs"}),re.jsxs("div",{className:"rf-flex rf-gap-4 rf-items-center",children:[e&&re.jsxs("div",{className:"rf-flex rf-gap-2 rf-items-center",children:[re.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=>re.jsx("option",{value:l.value,children:l.label},l.value))}),re.jsx(R0,{onClick:()=>e(r),size:"sm",className:"rf-text-xs",children:"Rerun Render with Debug"})]}),re.jsx("div",{className:"rf-flex rf-gap-2 rf-items-center",children:re.jsxs("select",{onChange:l=>{if(l.target.value){const u=n?.debugOutputs?.find(d=>d.name===l.target.value);if(u){const d=Pjn(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:[re.jsx("option",{value:"",children:"Download Debug Output"}),n?.debugOutputs?.map(l=>re.jsx("option",{value:l.name,children:l.name},l.name))]})}),re.jsxs("div",{className:"rf-flex rf-text-xs rf-items-center",children:[re.jsx("div",{className:"rf-mr-2",children:"Sort by:"}),re.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:[re.jsx("option",{value:"chronological",children:"Phase Order"}),re.jsx("option",{value:"longest",children:"Duration"})]})]})]})]}),re.jsx(Ajn,{phaseTimings:n.phaseTimings}),re.jsxs("table",{className:"rf-w-full rf-text-xs",children:[re.jsx("thead",{children:re.jsxs("tr",{children:[re.jsx("th",{className:"rf-text-left rf-p-2",children:"Phase Order"}),re.jsx("th",{className:"rf-text-left rf-p-2",children:"Phase"}),re.jsx("th",{className:"rf-text-left rf-p-2",children:"Duration (ms)"})]})}),re.jsx("tbody",{children:a.map(([l,u])=>re.jsxs("tr",{children:[re.jsx("td",{className:"rf-p-2",children:lw.indexOf(l)}),re.jsx("td",{className:"rf-p-2",children:l}),re.jsx("td",{className:"rf-p-2",children:re.jsx("div",{className:"rf-w-8",children:re.jsx("div",{className:"rf-h-2 rf-rounded-sm",style:{backgroundColor:lpt(l),width:`${u/c*100}%`}})})}),re.jsx("td",{className:"rf-p-2",children:re.jsxs("div",{className:"rf-flex w-full",children:[re.jsxs("span",{className:"rf-flex-grow",children:[u,"ms"]}),re.jsxs("span",{className:"rf-text-gray-500 rf-pr-2",children:[(u/c*100).toFixed(1),"%"]})]})})]},l))})]})]})},upt=({errorMessage:n,errorStack:e,circuitJsonErrors:t})=>{ce.useEffect(()=>{if(n){const i=new Error(n);e&&(i.stack=e);try{Yj.captureException(i)}catch{}}},[n,e]),ce.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{Yj.captureException(r,{error_type:i.type})}catch{}}},[t])},dpt="0.0.1210",Ijn={version:dpt},gq=Sze()(Eze(n=>({lastRunEvalVersion:void 0,setLastRunEvalVersion:e=>{n({lastRunEvalVersion:e})}}),{name:"runframe-runner-store"})),Njn=n=>{const[e,t]=ce.useState([]),[i,r]=ce.useState(null),[o,s]=ce.useState(""),[a,c]=aN("eval-version-selection",null),l=gq(p=>p.setLastRunEvalVersion),u=gq(p=>p.lastRunEvalVersion);return ce.useEffect(()=>{n&&fetch("https://data.jsdelivr.com/v1/package/npm/@tscircuit/eval").then(p=>p.json()).then(p=>{if(Array.isArray(p?.versions)){let m=[...p.versions];p.tags?.latest&&(r(p.tags.latest),m=m.filter(_=>_!==p.tags.latest)),t(m)}}).catch(()=>{})},[n]),ce.useEffect(()=>{n&&(a?(window.TSCIRCUIT_LATEST_EVAL_VERSION=a,l(a)):i&&(window.TSCIRCUIT_LATEST_EVAL_VERSION=i,l(i)))},[n,a,i]),{versions:ce.useMemo(()=>e.filter(p=>p.includes(o)).slice(0,50),[e,o]),latestVersion:i,lastRunEvalVersion:u,search:o,setSearch:s,selectVersion:p=>{c(p),s("")}}},kjn=({snippetNames:n,onSelect:e,onCancel:t,isOpen:i})=>{const[r,o]=ce.useState(""),[s,a]=ce.useState("");if(!i)return null;const c=n.filter(d=>d.toLowerCase().includes(s.toLowerCase())),l=s&&!n.includes(s),u=d=>{d.key==="Enter"&&(c.length===1?o(c[0]):l&&o(s))};return re.jsx("div",{className:"rf-fixed rf-inset-0 rf-bg-black rf-bg-opacity-50 rf-flex rf-items-center rf-justify-center rf-z-[100]",children:re.jsxs("div",{className:"rf-bg-white rf-rounded-lg rf-p-6 rf-w-96",children:[re.jsx("h2",{className:"rf-text-lg rf-font-semibold rf-mb-4",children:"Select Snippet"}),re.jsx("input",{type:"text",className:"rf-w-full rf-px-4 rf-py-2 rf-border rf-rounded rf-mb-4",placeholder:"Search snippets or new snippet name...",value:s,onChange:d=>a(d.target.value),onKeyDown:u}),re.jsxs("div",{className:"rf-h-60 rf-overflow-y-auto",children:[c.map(d=>re.jsx("button",{type:"button",className:`w-full text-left px-4 py-2 rounded hover:bg-gray-100 ${r===d?"bg-blue-50":""}`,onClick:()=>o(d),children:d},d)),l&&re.jsxs("button",{type:"button",className:`w-full text-left px-4 py-2 rounded hover:bg-gray-100 text-blue-500 ${r===s?"bg-blue-50":""}`,onClick:()=>o(s),children:['Create new "',s,'"']})]}),re.jsxs("div",{className:"rf-mt-4 rf-flex rf-justify-end rf-gap-2",children:[re.jsx("button",{type:"button",className:"rf-px-4 rf-py-2 rf-text-gray-600 rf-hover:text-gray-800",onClick:t,children:"Cancel"}),re.jsx("button",{type:"button",className:"rf-px-4 rf-py-2 rf-bg-blue-500 rf-text-white rf-rounded rf-hover:bg-blue-600 rf-disabled:opacity-50",onClick:()=>r&&e(r),disabled:!r,children:r===s?`Create "${r}"`:`Save to ${r}`})]})]})})},Ojn=n=>{const e=ce.useRef(null),t=ub(i=>i.recentEvents);ce.useEffect(()=>{if(t.length===0)return;const i=t[0];i.event_id!==e.current&&(n(i),e.current=i.event_id)},[t,n])};var xq="Dialog",[hpt,ppt]=eT(xq),[Ljn,hE]=hpt(xq),fpt=n=>{const{__scopeDialog:e,children:t,open:i,defaultOpen:r,onOpenChange:o,modal:s=!0}=n,a=ce.useRef(null),c=ce.useRef(null),[l,u]=jA({prop:i,defaultProp:r??!1,onChange:o,caller:xq});return re.jsx(Ljn,{scope:e,triggerRef:a,contentRef:c,contentId:Gb(),titleId:Gb(),descriptionId:Gb(),open:l,onOpenChange:u,onOpenToggle:ce.useCallback(()=>u(d=>!d),[u]),modal:s,children:t})};fpt.displayName=xq;var mpt="DialogTrigger",_pt=ce.forwardRef((n,e)=>{const{__scopeDialog:t,...i}=n,r=hE(mpt,t),o=H_(e,r.triggerRef);return re.jsx(uu.button,{type:"button","aria-haspopup":"dialog","aria-expanded":r.open,"aria-controls":r.contentId,"data-state":bve(r.open),...i,ref:o,onClick:ca(n.onClick,r.onOpenToggle)})});_pt.displayName=mpt;var gve="DialogPortal",[Djn,ypt]=hpt(gve,{forceMount:void 0}),gpt=n=>{const{__scopeDialog:e,forceMount:t,children:i,container:r}=n,o=hE(gve,e);return re.jsx(Djn,{scope:e,forceMount:t,children:ce.Children.map(i,s=>re.jsx(KS,{present:t||o.open,children:re.jsx(FG,{asChild:!0,container:r,children:s})}))})};gpt.displayName=gve;var bq="DialogOverlay",xpt=ce.forwardRef((n,e)=>{const t=ypt(bq,n.__scopeDialog),{forceMount:i=t.forceMount,...r}=n,o=hE(bq,n.__scopeDialog);return o.modal?re.jsx(KS,{present:i||o.open,children:re.jsx($jn,{...r,ref:e})}):null});xpt.displayName=bq;var zjn=BA("DialogOverlay.RemoveScroll"),$jn=ce.forwardRef((n,e)=>{const{__scopeDialog:t,...i}=n,r=hE(bq,t);return re.jsx(qG,{as:zjn,allowPinchZoom:!0,shards:[r.contentRef],children:re.jsx(uu.div,{"data-state":bve(r.open),...i,ref:e,style:{pointerEvents:"auto",...i.style}})})}),Q4="DialogContent",bpt=ce.forwardRef((n,e)=>{const t=ypt(Q4,n.__scopeDialog),{forceMount:i=t.forceMount,...r}=n,o=hE(Q4,n.__scopeDialog);return re.jsx(KS,{present:i||o.open,children:o.modal?re.jsx(Fjn,{...r,ref:e}):re.jsx(Ujn,{...r,ref:e})})});bpt.displayName=Q4;var Fjn=ce.forwardRef((n,e)=>{const t=hE(Q4,n.__scopeDialog),i=ce.useRef(null),r=H_(e,t.contentRef,i);return ce.useEffect(()=>{const o=i.current;if(o)return o1e(o)},[]),re.jsx(vpt,{...n,ref:r,trapFocus:t.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:ca(n.onCloseAutoFocus,o=>{o.preventDefault(),t.triggerRef.current?.focus()}),onPointerDownOutside:ca(n.onPointerDownOutside,o=>{const s=o.detail.originalEvent,a=s.button===0&&s.ctrlKey===!0;(s.button===2||a)&&o.preventDefault()}),onFocusOutside:ca(n.onFocusOutside,o=>o.preventDefault())})}),Ujn=ce.forwardRef((n,e)=>{const t=hE(Q4,n.__scopeDialog),i=ce.useRef(!1),r=ce.useRef(!1);return re.jsx(vpt,{...n,ref:e,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:o=>{n.onCloseAutoFocus?.(o),o.defaultPrevented||(i.current||t.triggerRef.current?.focus(),o.preventDefault()),i.current=!1,r.current=!1},onInteractOutside:o=>{n.onInteractOutside?.(o),o.defaultPrevented||(i.current=!0,o.detail.originalEvent.type==="pointerdown"&&(r.current=!0));const s=o.target;t.triggerRef.current?.contains(s)&&o.preventDefault(),o.detail.originalEvent.type==="focusin"&&r.current&&o.preventDefault()}})}),vpt=ce.forwardRef((n,e)=>{const{__scopeDialog:t,trapFocus:i,onOpenAutoFocus:r,onCloseAutoFocus:o,...s}=n,a=hE(Q4,t),c=ce.useRef(null),l=H_(e,c);return Uxe(),re.jsxs(re.Fragment,{children:[re.jsx(CG,{asChild:!0,loop:!0,trapped:i,onMountAutoFocus:r,onUnmountAutoFocus:o,children:re.jsx(MG,{role:"dialog",id:a.contentId,"aria-describedby":a.descriptionId,"aria-labelledby":a.titleId,"data-state":bve(a.open),...s,ref:l,onDismiss:()=>a.onOpenChange(!1)})}),re.jsxs(re.Fragment,{children:[re.jsx(jjn,{titleId:a.titleId}),re.jsx(Vjn,{contentRef:c,descriptionId:a.descriptionId})]})]})}),xve="DialogTitle",wpt=ce.forwardRef((n,e)=>{const{__scopeDialog:t,...i}=n,r=hE(xve,t);return re.jsx(uu.h2,{id:r.titleId,...i,ref:e})});wpt.displayName=xve;var Spt="DialogDescription",Ept=ce.forwardRef((n,e)=>{const{__scopeDialog:t,...i}=n,r=hE(Spt,t);return re.jsx(uu.p,{id:r.descriptionId,...i,ref:e})});Ept.displayName=Spt;var Tpt="DialogClose",Mpt=ce.forwardRef((n,e)=>{const{__scopeDialog:t,...i}=n,r=hE(Tpt,t);return re.jsx(uu.button,{type:"button",...i,ref:e,onClick:ca(n.onClick,()=>r.onOpenChange(!1))})});Mpt.displayName=Tpt;function bve(n){return n?"open":"closed"}var Cpt="DialogTitleWarning",[Bjn,Apt]=hen(Cpt,{contentName:Q4,titleName:xve,docsSlug:"dialog"}),jjn=({titleId:n})=>{const e=Apt(Cpt),t=`\`${e.contentName}\` requires a \`${e.titleName}\` for the component to be accessible for screen reader users.
|
|
5873
5873
|
|
|
5874
5874
|
If you want to hide the \`${e.titleName}\`, you can wrap it with our VisuallyHidden component.
|
|
5875
5875
|
|