@tscircuit/runframe 0.0.2465 → 0.0.2467
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
|
@@ -5471,7 +5471,7 @@ ${A.join(`
|
|
|
5471
5471
|
${_}polygon: ${d.polygon.vertices}
|
|
5472
5472
|
`:A+=`
|
|
5473
5473
|
`,d.children.length>0&&l.push(d.children)}return A}};e.exports=s}}),D4o=At({"node_modules/@jscad/modeling/src/operations/booleans/trees/Tree.js"(t,e){var n=B4o(),o=b4o(),i=class{constructor(r){this.polygonTree=new o,this.rootnode=new n(null),r&&this.addPolygons(r)}invert(){this.polygonTree.invert(),this.rootnode.invert()}clipTo(r,s=!1){this.rootnode.clipTo(r,s)}allPolygons(){const r=[];return this.polygonTree.getPolygons(r),r}addPolygons(r){const s=new Array(r.length);for(let a=0;a<r.length;a++)s[a]=this.polygonTree.addChild(r[a]);this.rootnode.addPolygonTreeNodes(s)}clear(){this.polygonTree.clear()}toString(){return"Tree: "+this.polygonTree.toString("")}};e.exports=i}}),VMe=At({"node_modules/@jscad/modeling/src/operations/booleans/trees/index.js"(t,e){e.exports={Tree:D4o()}}}),v4o=At({"node_modules/@jscad/modeling/src/operations/booleans/intersectGeom3Sub.js"(t,e){var n=Gs(),o=zMe(),{Tree:i}=VMe(),r=(s,a)=>{if(!o(s,a))return n.create();const A=new i(n.toPolygons(s)),c=new i(n.toPolygons(a));A.invert(),c.clipTo(A),c.invert(),A.clipTo(c),c.clipTo(A),A.addPolygons(c.allPolygons()),A.invert();const l=A.allPolygons();return n.create(l)};e.exports=r}}),_6t=At({"node_modules/@jscad/modeling/src/operations/booleans/intersectGeom3.js"(t,e){var n=Is(),o=GU(),i=v4o(),r=(...s)=>{s=n(s);let a=s.shift();return s.forEach(A=>{a=i(a,A)}),a=o(a),a};e.exports=r}}),P4o=At({"node_modules/@jscad/modeling/src/operations/booleans/intersectGeom2.js"(t,e){var n=Is(),o=Gs(),i=NP(),r=UMe(),s=YMe(),a=_6t(),A=(...c)=>{c=n(c);const l=c.map(h=>s({z0:-1,z1:1},h)),g=a(l),u=i(g);return r(u,o.toPolygons(g))};e.exports=A}}),w4o=At({"node_modules/@jscad/modeling/src/operations/booleans/intersect.js"(t,e){var n=Is(),o=HU(),i=Js(),r=Gs(),s=P4o(),a=_6t(),A=(...c)=>{if(c=n(c),c.length===0)throw new Error("wrong number of arguments");if(!o(c))throw new Error("only intersect of the types are supported");const l=c[0];return i.isA(l)?s(c):r.isA(l)?a(c):l};e.exports=A}}),JMe=At({"node_modules/@jscad/modeling/src/operations/hulls/hullPoints3.js"(t,e){var n=Za(),o=C3t(),i=r=>o(r,{skipTriangulation:!0}).map(A=>{const c=A.map(l=>r[l]);return n.create(c)});e.exports=i}}),m6t=At({"node_modules/@jscad/modeling/src/operations/booleans/unionGeom3Sub.js"(t,e){var n=Gs(),o=zMe(),{Tree:i}=VMe(),r=(a,A)=>{if(!o(a,A))return s(a,A);const c=new i(n.toPolygons(a)),l=new i(n.toPolygons(A));c.clipTo(l,!1),l.clipTo(c),l.invert(),l.clipTo(c),l.invert();const g=c.allPolygons().concat(l.allPolygons());return n.create(g)},s=(a,A)=>{let c=n.toPolygons(a);return c=c.concat(n.toPolygons(A)),n.create(c)};e.exports=r}}),qMe=At({"node_modules/@jscad/modeling/src/operations/booleans/unionGeom3.js"(t,e){var n=Is(),o=GU(),i=m6t(),r=(...s)=>{s=n(s);let a;for(a=1;a<s.length;a+=2)s.push(i(s[a-1],s[a]));let A=s[a-1];return A=o(A),A};e.exports=r}}),p6t=At({"node_modules/@jscad/modeling/src/operations/minkowski/minkowskiSum.js"(t,e){var n=Is(),o=Gs(),i=Za(),r=JMe(),s=qMe(),a=(...h)=>{if(h=n(h),h.length!==2)throw new Error("minkowskiSum requires exactly two geometries");const[d,_]=h;if(!o.isA(d)||!o.isA(_))throw new Error("minkowskiSum requires geom3 geometries");const m=o.isConvex(d),p=o.isConvex(_);if(m&&p)return g(d,_);if(!m&&p)return A(d,_);if(m&&!p)return A(_,d);throw new Error("minkowskiSum of two non-convex geometries is not yet supported")},A=(h,d)=>{const _=c(h);if(_.length===0)return o.create();const m=_.map(p=>g(p,d));return m.length===1?m[0]:s(m)},c=h=>{const d=o.toPolygons(h);if(d.length===0)return[];const _=[];for(let m=0;m<d.length;m++){const p=d[m],I=p.vertices;let f=0,C=0,y=0;for(let M=0;M<I.length;M++)f+=I[M][0],C+=I[M][1],y+=I[M][2];f/=I.length,C/=I.length,y/=I.length;const E=i.plane(p),B=E[0],Q=E[1],b=E[2],D=.1,R=[f-B*D,C-Q*D,y-b*D];for(let M=1;M<I.length-1;M++){const L=I[0],G=I[M],O=I[M+1],U=l(R,L,G,O);_.push(o.create(U))}}return _},l=(h,d,_,m)=>[i.create([h,_,d]),i.create([h,d,m]),i.create([d,_,m]),i.create([_,h,m])],g=(h,d)=>{const _=u(h),m=u(d);if(_.length===0||m.length===0)return o.create();const p=[];for(let f=0;f<_.length;f++){const C=_[f];for(let y=0;y<m.length;y++){const E=m[y];p.push([C[0]+E[0],C[1]+E[1],C[2]+E[2]])}}const I=r(p);return o.create(I)},u=h=>{const d=new Set,_=[],m=o.toPolygons(h);for(let p=0;p<m.length;p++){const I=m[p].vertices;for(let f=0;f<I.length;f++){const C=I[f],y=`${C[0]},${C[1]},${C[2]}`;d.has(y)||(d.add(y),_.push(C))}}return _};e.exports=a}}),M4o=At({"node_modules/@jscad/modeling/src/operations/booleans/scissionGeom3.js"(t,e){var n=Ar(),o=NP(),i=Gs(),r=c=>c.sort((l,g)=>l-g).filter((l,g,u)=>!g||l!==u[g-1]),s=(c,l,g)=>{const u=`${l}`,h=c.get(u);h===void 0?c.set(u,[g]):h.push(g)},a=(c,l)=>{const g=`${l}`;return c.get(g)},A=c=>{const l=o(c),g=i.toPolygons(c),u=g.length,h=new Map,d=n.create();g.forEach((f,C)=>{f.vertices.forEach(y=>{s(h,n.snap(d,y,l),C)})});const _=g.map(f=>{let C=[];return f.vertices.forEach(y=>{C=C.concat(a(h,n.snap(d,y,l)))}),{e:1,d:r(C)}});h.clear();let m=0;const p=_.length;for(let f=0;f<p;f++){const C=_[f];if(C.e>0){const y=new Array(u);y[f]=!0;do m=0,y.forEach((E,B)=>{const Q=_[B];if(Q.e>0){Q.e=-1;for(let b=0;b<Q.d.length;b++)y[Q.d[b]]=!0;m++}});while(m>0);C.indexes=y}}const I=[];for(let f=0;f<p;f++)if(_[f].indexes){const C=[];_[f].indexes.forEach((y,E)=>C.push(g[E])),I.push(i.create(C))}return I};e.exports=A}}),N4o=At({"node_modules/@jscad/modeling/src/operations/booleans/scission.js"(t,e){var n=Is(),o=Gs(),i=M4o(),r=(...s)=>{if(s=n(s),s.length===0)throw new Error("wrong number of arguments");const a=s.map(A=>o.isA(A)?i(A):A);return a.length===1?a[0]:a};e.exports=r}}),R4o=At({"node_modules/@jscad/modeling/src/operations/booleans/subtractGeom3Sub.js"(t,e){var n=Gs(),o=zMe(),{Tree:i}=VMe(),r=(s,a)=>{if(!o(s,a))return n.clone(s);const A=new i(n.toPolygons(s)),c=new i(n.toPolygons(a));A.invert(),A.clipTo(c),c.clipTo(A,!0),A.addPolygons(c.allPolygons()),A.invert();const l=A.allPolygons();return n.create(l)};e.exports=r}}),I6t=At({"node_modules/@jscad/modeling/src/operations/booleans/subtractGeom3.js"(t,e){var n=Is(),o=GU(),i=R4o(),r=(...s)=>{s=n(s);let a=s.shift();return s.forEach(A=>{a=i(a,A)}),a=o(a),a};e.exports=r}}),T4o=At({"node_modules/@jscad/modeling/src/operations/booleans/subtractGeom2.js"(t,e){var n=Is(),o=Gs(),i=NP(),r=UMe(),s=YMe(),a=I6t(),A=(...c)=>{c=n(c);const l=c.map(h=>s({z0:-1,z1:1},h)),g=a(l),u=i(g);return r(u,o.toPolygons(g))};e.exports=A}}),k4o=At({"node_modules/@jscad/modeling/src/operations/booleans/subtract.js"(t,e){var n=Is(),o=HU(),i=Js(),r=Gs(),s=T4o(),a=I6t(),A=(...c)=>{if(c=n(c),c.length===0)throw new Error("wrong number of arguments");if(!o(c))throw new Error("only subtract of the types are supported");const l=c[0];return i.isA(l)?s(c):r.isA(l)?a(c):l};e.exports=A}}),f6t=At({"node_modules/@jscad/modeling/src/operations/booleans/unionGeom2.js"(t,e){var n=Is(),o=Gs(),i=NP(),r=UMe(),s=YMe(),a=qMe(),A=(...c)=>{c=n(c);const l=c.map(h=>s({z0:-1,z1:1},h)),g=a(l),u=i(g);return r(u,o.toPolygons(g))};e.exports=A}}),WMe=At({"node_modules/@jscad/modeling/src/operations/booleans/union.js"(t,e){var n=Is(),o=HU(),i=Js(),r=Gs(),s=f6t(),a=qMe(),A=(...c)=>{if(c=n(c),c.length===0)throw new Error("wrong number of arguments");if(!o(c))throw new Error("only unions of the same type are supported");const l=c[0];return i.isA(l)?s(c):r.isA(l)?a(c):l};e.exports=A}}),OU=At({"node_modules/@jscad/modeling/src/operations/booleans/index.js"(t,e){e.exports={intersect:w4o(),minkowski:p6t(),scission:N4o(),subtract:k4o(),union:WMe()}}}),Yie=At({"node_modules/@jscad/modeling/src/operations/expansions/offsetFromPoints.js"(t,e){var{EPS:n,TAU:o}=hA(),i=q3t(),r=LMe(),s=Ia(),a=Oie(),A=(c,l)=>{const g={delta:1,corners:"edge",closed:!1,segments:16};let{delta:u,corners:h,closed:d,segments:_}=Object.assign({},g,c);if(Math.abs(u)<n)return l;let m=c.closed?a(l):1;m===0&&(m=1);const p=m>0&&u>=0||m<0&&u<0;u=Math.abs(u);let I=null,f=[];const C=[],y=s.create(),E=l.length;for(let B=0;B<E;B++){const Q=(B+1)%E,b=l[B],D=l[Q];p?s.subtract(y,b,D):s.subtract(y,D,b),s.normal(y,y),s.normalize(y,y),s.scale(y,y,u);const R=s.add(s.create(),b,y),M=s.add(s.create(),D,y),L=[R,M];if(I!=null&&(d||!d&&Q!==0)){const G=i(I[0],I[1],L[0],L[1]);G?(f.pop(),L[0]=G):C.push({c:b,s0:I,s1:L})}I=[R,M],!(Q===0&&!d)&&(f.push(L[0]),f.push(L[1]))}if(d&&I!=null){const B=f[0],Q=f[1],b=i(I[0],I[1],B,Q);if(b)f[0]=b,f.pop();else{const D=l[0],R=[B,Q];C.push({c:D,s0:I,s1:R})}}if(h==="edge"){const B=new Map;f.forEach((D,R)=>B.set(D,R));const Q=r.create(),b=r.create();C.forEach(D=>{r.fromPoints(Q,D.s0[0],D.s0[1]),r.fromPoints(b,D.s1[0],D.s1[1]);const R=r.intersectPointOfLines(Q,b);if(Number.isFinite(R[0])&&Number.isFinite(R[1])){const M=D.s0[1],L=B.get(M);f[L]=R,f[(L+1)%f.length]=void 0}else{const M=D.s1[0],L=B.get(M);f[L]=void 0}}),f=f.filter(D=>D!==void 0)}if(h==="round"){let B=Math.floor(_/4);const Q=s.create();C.forEach(b=>{let D=s.angle(s.subtract(Q,b.s1[0],b.c));if(D-=s.angle(s.subtract(Q,b.s0[1],b.c)),p&&D<0&&(D=D+Math.PI,D<0&&(D=D+Math.PI)),!p&&D>0&&(D=D-Math.PI,D>0&&(D=D-Math.PI)),D!==0){B=Math.floor(_*(Math.abs(D)/o));const R=D/B,M=s.angle(s.subtract(Q,b.s0[1],b.c)),L=[];for(let G=1;G<B;G++){const O=M+R*G,U=s.fromAngleRadians(s.create(),O);s.scale(U,U,u),s.add(U,U,b.c),L.push(U)}if(L.length>0){const G=b.s0[1];let O=f.findIndex(U=>s.equals(G,U));O=(O+1)%f.length,f.splice(O,0,...L)}}else{const R=b.s1[0],M=f.findIndex(L=>s.equals(R,L));f.splice(M,1)}})}return f};e.exports=A}}),F4o=At({"node_modules/@jscad/modeling/src/operations/expansions/expandGeom2.js"(t,e){var n=Js(),o=Yie(),i=(r,s)=>{const a={delta:1,corners:"edge",segments:16},{delta:A,corners:c,segments:l}=Object.assign({},a,r);if(!(c==="edge"||c==="chamfer"||c==="round"))throw new Error('corners must be "edge", "chamfer", or "round"');const h=n.toOutlines(s).map(d=>(r={delta:A,corners:c,closed:!0,segments:l},o(r,d))).reduce((d,_)=>d.concat(n.toSides(n.fromPoints(_))),[]);return n.create(h)};e.exports=i}}),L4o=At({"node_modules/@jscad/modeling/src/operations/expansions/extrudePolygon.js"(t,e){var n=yg(),o=Ar(),i=Gs(),r=Za(),s=(a,A)=>{o.dot(r.plane(A),a)>0&&(A=r.invert(A));const l=[A],g=r.transform(n.fromTranslation(n.create(),a),A),u=A.vertices.length;for(let h=0;h<u;h++){const d=h<u-1?h+1:0,_=r.create([A.vertices[h],g.vertices[h],g.vertices[d],A.vertices[d]]);l.push(_)}return l.push(r.invert(g)),i.create(l)};e.exports=s}}),H4o=At({"node_modules/@jscad/modeling/src/operations/expansions/expandShell.js"(t,e){var{EPS:n,TAU:o}=hA(),i=yg(),r=Ar(),s=d6t(),a=Gs(),A=Za(),c=s6t(),l=GU(),g=m6t(),u=L4o(),h=(p,I,f)=>{const C=I.toString();if(p.has(C))p.get(C)[1].push(f);else{const y=[I,[f]];p.set(C,y)}},d=(p,I,f)=>{const C=I[0].toString(),y=I[1].toString(),E=C<y?`${C},${y}`:`${y},${C}`;if(p.has(E))p.get(E)[1].push(f);else{const B=[I,[f]];p.set(E,B)}},_=(p,I)=>{p.findIndex(C=>C===I)<0&&p.push(I)},m=(p,I)=>{const f={delta:1,segments:12},{delta:C,segments:y}=Object.assign({},f,p);let E=a.create();const B=new Map,Q=new Map,b=r.create(),D=r.create();return a.toPolygons(I).forEach((M,L)=>{const G=r.scale(r.create(),A.plane(M),2*C),O=A.transform(i.fromTranslation(i.create(),r.scale(r.create(),G,-.5)),M),U=u(G,O);E=g(E,U);const W=M.vertices;for(let j=0;j<W.length;j++){h(B,W[j],A.plane(M));const te=(j+1)%W.length,ie=[W[j],W[te]];d(Q,ie,A.plane(M))}}),Q.forEach(M=>{const L=M[0],G=M[1],O=L[0],U=L[1],W=r.subtract(r.create(),U,O);r.normalize(W,W);const j=G[0],te=r.cross(r.create(),j,W);let ie=[];for(let xe=0;xe<y;xe++)_(ie,xe*o/y);for(let xe=0,de=G.length;xe<de;xe++){const Ee=G[xe],he=r.dot(te,Ee),ve=r.dot(j,Ee);let Re=Math.atan2(he,ve);Re<0&&(Re+=o),_(ie,Re),Re=Math.atan2(-he,-ve),Re<0&&(Re+=o),_(ie,Re)}ie=ie.sort(s);const $=ie.length;let Z,se;const ae=[],ce=[],fe=[];for(let xe=-1;xe<$;xe++){const de=ie[xe<0?xe+$:xe],Ee=Math.sin(de),he=Math.cos(de);r.scale(b,j,he*C),r.scale(D,te,Ee*C),r.add(b,b,D);const ve=r.add(r.create(),O,b),Re=r.add(r.create(),U,b);let ze=!1;if(xe>=0&&r.distance(ve,Z)<n&&(ze=!0),!ze){if(xe>=0){ae.push(ve),ce.push(Re);const Ie=[se,Re,ve,Z],We=A.create(Ie);fe.push(We)}Z=ve,se=Re}}ce.reverse(),fe.push(A.create(ae)),fe.push(A.create(ce));const Ce=a.create(fe);E=g(E,Ce)}),B.forEach(M=>{const L=M[0],G=M[1],O=G[0];let U=null,W=0;for(let $=1;$<G.length;$++){const Z=G[$],se=r.cross(b,O,Z),ae=r.length(se);ae>.05&&ae>W&&(W=ae,U=Z)}U||(U=r.orthogonal(b,O));const j=r.cross(b,O,U);r.normalize(j,j);const te=r.cross(D,j,O),ie=c({center:[L[0],L[1],L[2]],radius:C,segments:y,axes:[O,j,te]});E=g(E,ie)}),l(E)};e.exports=m}}),G4o=At({"node_modules/@jscad/modeling/src/operations/expansions/expandGeom3.js"(t,e){var n=Gs(),o=WMe(),i=H4o(),r=(s,a)=>{const A={delta:1,corners:"round",segments:12},{delta:c,corners:l,segments:g}=Object.assign({},A,s);if(l!=="round")throw new Error('corners must be "round" for 3D geometries');if(n.toPolygons(a).length===0)throw new Error("the given geometry cannot be empty");s={delta:c,corners:l,segments:g};const h=i(s,a);return o(a,h)};e.exports=r}}),O4o=At({"node_modules/@jscad/modeling/src/operations/expansions/expandPath2.js"(t,e){var n=Oie(),o=Ia(),i=Js(),r=ql(),s=Yie(),a=l=>{let{external:g,internal:u}=l;n(g)<0?g=g.reverse():u=u.reverse();const h=r.fromPoints({closed:!0},g),d=r.fromPoints({closed:!0},u),_=i.toSides(i.fromPoints(r.toPoints(h))),m=i.toSides(i.fromPoints(r.toPoints(d)));return _.push(...m),i.create(_)},A=(l,g,u,h)=>{const{points:d,external:_,internal:m}=l,p=Math.floor(g/2),I=[],f=[];if(u==="round"&&p>0){const y=Math.PI/p,E=d[d.length-1],B=o.angle(o.subtract(o.create(),_[_.length-1],E)),Q=d[0],b=o.angle(o.subtract(o.create(),m[0],Q));for(let D=1;D<p;D++){let R=B+y*D,M=o.fromAngleRadians(o.create(),R);o.scale(M,M,h),o.add(M,M,E),I.push(M),R=b+y*D,M=o.fromAngleRadians(o.create(),R),o.scale(M,M,h),o.add(M,M,Q),f.push(M)}}const C=[];return C.push(..._,...I,...m.reverse(),...f),i.fromPoints(C)},c=(l,g)=>{l=Object.assign({},{delta:1,corners:"edge",segments:16},l);const{delta:h,corners:d,segments:_}=l;if(h<=0)throw new Error("the given delta must be positive for paths");if(!(d==="edge"||d==="chamfer"||d==="round"))throw new Error('corners must be "edge", "chamfer", or "round"');const m=g.isClosed,p=r.toPoints(g);if(p.length===0)throw new Error("the given geometry cannot be empty");const I={points:p,external:s({delta:h,corners:d,segments:_,closed:m},p),internal:s({delta:-h,corners:d,segments:_,closed:m},p)};return g.isClosed?a(I):A(I,_,d,h)};e.exports=c}}),jMe=At({"node_modules/@jscad/modeling/src/operations/expansions/expand.js"(t,e){var n=Is(),o=Js(),i=Gs(),r=ql(),s=F4o(),a=G4o(),A=O4o(),c=(l,...g)=>{if(g=n(g),g.length===0)throw new Error("wrong number of arguments");const u=g.map(h=>r.isA(h)?A(l,h):o.isA(h)?s(l,h):i.isA(h)?a(l,h):h);return u.length===1?u[0]:u};e.exports=c}}),K4o=At({"node_modules/@jscad/modeling/src/operations/expansions/offsetGeom2.js"(t,e){var n=Js(),o=NMe(),i=Yie(),r=(s,a)=>{const A={delta:1,corners:"edge",segments:0},{delta:c,corners:l,segments:g}=Object.assign({},A,s);if(!(l==="edge"||l==="chamfer"||l==="round"))throw new Error('corners must be "edge", "chamfer", or "round"');const u=n.toOutlines(a),d=u.map(_=>(s={delta:u.reduce((I,f)=>I+o.arePointsInside(_,o.create(f)),0)%2===0?c:-c,corners:l,closed:!0,segments:g},i(s,_))).reduce((_,m)=>_.concat(n.toSides(n.fromPoints(m))),[]);return n.create(d)};e.exports=r}}),U4o=At({"node_modules/@jscad/modeling/src/operations/expansions/offsetPath2.js"(t,e){var n=ql(),o=Yie(),i=(r,s)=>{const a={delta:1,corners:"edge",closed:s.isClosed,segments:16},{delta:A,corners:c,closed:l,segments:g}=Object.assign({},a,r);if(!(c==="edge"||c==="chamfer"||c==="round"))throw new Error('corners must be "edge", "chamfer", or "round"');r={delta:A,corners:c,closed:l,segments:g};const u=o(r,n.toPoints(s));return n.fromPoints({closed:l},u)};e.exports=i}}),Y4o=At({"node_modules/@jscad/modeling/src/operations/expansions/offset.js"(t,e){var n=Is(),o=Js(),i=ql(),r=K4o(),s=U4o(),a=(A,...c)=>{if(c=n(c),c.length===0)throw new Error("wrong number of arguments");const l=c.map(g=>i.isA(g)?s(A,g):o.isA(g)?r(A,g):g);return l.length===1?l[0]:l};e.exports=a}}),C6t=At({"node_modules/@jscad/modeling/src/operations/expansions/index.js"(t,e){e.exports={expand:jMe(),offset:Y4o()}}}),zie=At({"node_modules/@jscad/modeling/src/operations/extrusions/extrudeLinearGeom2.js"(t,e){var n=yg(),o=Ar(),i=Js(),r=VT(),s=Uie(),a=(A,c)=>{const l={offset:[0,0,1],twistAngle:0,twistSteps:12,repair:!0};let{offset:g,twistAngle:u,twistSteps:h,repair:d}=Object.assign({},l,A);if(h<1)throw new Error("twistSteps must be 1 or more");u===0&&(h=1);const _=o.clone(g),m=i.toSides(c);if(m.length===0)throw new Error("the given geometry cannot be empty");const p=r.fromSides(m);_[2]<0&&r.reverse(p,p);const I=n.create(),f=(C,y,E)=>{const B=y/h*u,Q=o.scale(o.create(),_,y/h);return n.multiply(I,n.fromZRotation(I,B),n.fromTranslation(n.create(),Q)),r.transform(I,E)};return A={numberOfSlices:h+1,capStart:!0,capEnd:!0,repair:d,callback:f},s(A,p)};e.exports=a}}),z4o=At({"node_modules/@jscad/modeling/src/operations/extrusions/extrudeLinearPath2.js"(t,e){var n=Js(),o=ql(),i=zie(),r=(s,a)=>{if(!a.isClosed)throw new Error("extruded path must be closed");const A=o.toPoints(a),c=n.fromPoints(A);return i(s,c)};e.exports=r}}),V4o=At({"node_modules/@jscad/modeling/src/operations/extrusions/extrudeLinear.js"(t,e){var n=Is(),o=Js(),i=ql(),r=zie(),s=z4o(),a=(A,...c)=>{const l={height:1,twistAngle:0,twistSteps:1,repair:!0},{height:g,twistAngle:u,twistSteps:h,repair:d}=Object.assign({},l,A);if(c=n(c),c.length===0)throw new Error("wrong number of arguments");A={offset:[0,0,g],twistAngle:u,twistSteps:h,repair:d};const _=c.map(m=>i.isA(m)?s(A,m):o.isA(m)?r(A,m):m);return _.length===1?_[0]:_};e.exports=a}}),J4o=At({"node_modules/@jscad/modeling/src/operations/extrusions/extrudeRectangularPath2.js"(t,e){var n=ql(),o=jMe(),i=zie(),r=(s,a)=>{const A={size:1,height:1},{size:c,height:l}=Object.assign({},A,s);if(s.delta=c,s.offset=[0,0,l],n.toPoints(a).length===0)throw new Error("the given geometry cannot be empty");const u=o(s,a);return i(s,u)};e.exports=r}}),q4o=At({"node_modules/@jscad/modeling/src/operations/extrusions/extrudeRectangularGeom2.js"(t,e){var{area:n}=TU(),o=Js(),i=ql(),r=jMe(),s=zie(),a=(A,c)=>{const l={size:1,height:1},{size:g,height:u}=Object.assign({},l,A);A.delta=g,A.offset=[0,0,u];const h=o.toOutlines(c);if(h.length===0)throw new Error("the given geometry cannot be empty");const _=h.map(p=>(n(p)<0&&p.reverse(),r(A,i.fromPoints({closed:!0},p)))).reduce((p,I)=>p.concat(o.toSides(I)),[]),m=o.create(_);return s(A,m)};e.exports=a}}),W4o=At({"node_modules/@jscad/modeling/src/operations/extrusions/extrudeRectangular.js"(t,e){var n=Is(),o=Js(),i=ql(),r=J4o(),s=q4o(),a=(A,...c)=>{const l={size:1,height:1},{size:g,height:u}=Object.assign({},l,A);if(c=n(c),c.length===0)throw new Error("wrong number of arguments");if(g<=0)throw new Error("size must be positive");if(u<=0)throw new Error("height must be positive");const h=c.map(d=>i.isA(d)?r(A,d):o.isA(d)?s(A,d):d);return h.length===1?h[0]:h};e.exports=a}}),j4o=At({"node_modules/@jscad/modeling/src/operations/extrusions/extrudeHelical.js"(t,e){var{TAU:n}=hA(),o=yg(),i=Js(),r=Uie(),s=VT(),a=(A,c)=>{const l={angle:n,startAngle:0,pitch:10,height:0,endOffset:0,segmentsPerRotation:32};let{angle:g,startAngle:u,pitch:h,height:d,endOffset:_,segmentsPerRotation:m}=Object.assign({},l,A);if(d!=0&&(h=d/(g/n)),m<3)throw new Error("The number of segments per rotation needs to be at least 3.");const I=i.toSides(c);if(I.length===0)throw new Error("The given geometry cannot be empty");const f=I.filter(D=>D[0][0]>=0);let C=s.fromSides(I);f.length===0&&(C=s.reverse(C));const y=Math.round(m/n*Math.abs(g)),E=y>=2?y:2,B=o.create(),Q=o.create(),b=(D,R,M)=>{const L=u+g/E*R,G=_/E*R,O=(L-u)/n*h;return o.multiply(B,o.fromTranslation(o.create(),[G,0,O*Math.sign(g)]),o.fromXRotation(o.create(),-n/4*Math.sign(g))),o.multiply(Q,o.fromZRotation(o.create(),L),B),s.transform(Q,M)};return r({numberOfSlices:E+1,callback:b},C)};e.exports=a}}),X4o=At({"node_modules/@jscad/modeling/src/operations/extrusions/project.js"(t,e){var n=Is(),o=FMe(),i=jS(),r=yg(),s=Js(),a=Gs(),A=Za(),c=NP(),l=f6t(),g=(h,d)=>{const _=i.fromNormalAndPoint(i.create(),h.axis,h.origin);if(Number.isNaN(_[0])||Number.isNaN(_[1])||Number.isNaN(_[2])||Number.isNaN(_[3]))throw new Error("project: invalid axis or origin");const m=c(d),p=m*m*Math.sqrt(3)/4;if(m===0)return s.create();const I=a.toPolygons(d);let f=[];for(let y=0;y<I.length;y++){const E=I[y].vertices.map(b=>i.projectionOfPoint(_,b)),B=A.create(E),Q=A.plane(B);o(_,Q)&&(A.measureArea(B)<p||f.push(B))}if(!o(_,[0,0,1])){const y=r.fromVectorRotation(r.create(),_,[0,0,1]);f=f.map(E=>A.transform(y,E))}f=f.sort((y,E)=>A.measureArea(E)-A.measureArea(y));const C=f.map(y=>s.fromPoints(y.vertices));return l(C)},u=(h,...d)=>{const _={axis:[0,0,1],origin:[0,0,0]},{axis:m,origin:p}=Object.assign({},_,h);if(d=n(d),d.length===0)throw new Error("wrong number of arguments");h={axis:m,origin:p};const I=d.map(f=>a.isA(f)?g(h,f):f);return I.length===1?I[0]:I};e.exports=u}}),KU=At({"node_modules/@jscad/modeling/src/operations/extrusions/index.js"(t,e){e.exports={extrudeFromSlices:Uie(),extrudeLinear:V4o(),extrudeRectangular:W4o(),extrudeRotate:l6t(),extrudeHelical:j4o(),project:X4o(),slice:VT()}}}),XMe=At({"node_modules/@jscad/modeling/src/operations/hulls/hullPoints2.js"(t,e){var n=Ia(),o=s=>{let a=n.fromValues(1/0,1/0);s.forEach(l=>{(l[1]<a[1]||l[1]===a[1]&&l[0]<a[0])&&(a=l)});const A=[];s.forEach(l=>{const g=r(l[1]-a[1],l[0]-a[0]),u=n.squaredDistance(l,a);A.push({point:l,angle:g,distSq:u})}),A.sort((l,g)=>l.angle!==g.angle?l.angle-g.angle:l.distSq-g.distSq);const c=[];return A.forEach(l=>{let g=c.length;for(;g>1&&i(c[g-2],c[g-1],l.point)<=Number.EPSILON;)c.pop(),g=c.length;c.push(l.point)}),c},i=(s,a,A)=>(a[0]-s[0])*(A[1]-s[1])-(a[1]-s[1])*(A[0]-s[0]),r=(s,a)=>s===0&&a===0?-1/0:-a/s;e.exports=o}}),$Me=At({"node_modules/@jscad/modeling/src/operations/hulls/toUniquePoints.js"(t,e){var n=Js(),o=Gs(),i=ql(),r=s=>{const a=new Set,A=[],c=l=>{const g=l.toString();a.has(g)||(A.push(l),a.add(g))};return s.forEach(l=>{n.isA(l)?n.toPoints(l).forEach(c):o.isA(l)?o.toPoints(l).forEach(g=>g.forEach(c)):i.isA(l)&&i.toPoints(l).forEach(c)}),A};e.exports=r}}),$4o=At({"node_modules/@jscad/modeling/src/operations/hulls/hullPath2.js"(t,e){var n=Is(),o=ql(),i=XMe(),r=$Me(),s=(...a)=>{a=n(a);const A=r(a),c=i(A);return o.fromPoints({closed:!0},c)};e.exports=s}}),Z4o=At({"node_modules/@jscad/modeling/src/operations/hulls/hullGeom2.js"(t,e){var n=Is(),o=Js(),i=XMe(),r=$Me(),s=(...a)=>{a=n(a);const A=r(a),c=i(A);return c.length<3?o.create():o.fromPoints(c)};e.exports=s}}),e5o=At({"node_modules/@jscad/modeling/src/operations/hulls/hullGeom3.js"(t,e){var n=Is(),o=Gs(),i=$Me(),r=JMe(),s=(...a)=>{a=n(a);const A=i(a);return A.length===0?o.create():o.create(r(A))};e.exports=s}}),y6t=At({"node_modules/@jscad/modeling/src/operations/hulls/hull.js"(t,e){var n=Is(),o=HU(),i=Js(),r=Gs(),s=ql(),a=$4o(),A=Z4o(),c=e5o(),l=(...g)=>{if(g=n(g),g.length===0)throw new Error("wrong number of arguments");if(!o(g))throw new Error("only hulls of the same type are supported");const u=g[0];return s.isA(u)?a(g):i.isA(u)?A(g):r.isA(u)?c(g):u};e.exports=l}}),t5o=At({"node_modules/@jscad/modeling/src/operations/hulls/hullChain.js"(t,e){var n=Is(),o=WMe(),i=y6t(),r=(...s)=>{if(s=n(s),s.length<2)throw new Error("wrong number of arguments");const a=[];for(let A=1;A<s.length;A++)a.push(i(s[A-1],s[A]));return o(a)};e.exports=r}}),n5o=At({"node_modules/@jscad/modeling/src/operations/hulls/index.js"(t,e){e.exports={hull:y6t(),hullChain:t5o(),hullPoints2:XMe(),hullPoints3:JMe()}}}),o5o=At({"node_modules/@jscad/modeling/src/operations/minkowski/index.js"(t,e){e.exports={minkowskiSum:p6t()}}}),E6t=At({"node_modules/@jscad/modeling/src/operations/modifiers/snapPolygons.js"(t,e){var n=Ar(),o=Za(),i=(s,a)=>{const A=Math.abs(o.measureArea(a));return Number.isFinite(A)&&A>s},r=(s,a)=>{let A=a.map(l=>{const g=l.vertices.map(d=>n.snap(n.create(),d,s)),u=[];for(let d=0;d<g.length;d++){const _=(d+1)%g.length;n.equals(g[d],g[_])||u.push(g[d])}const h=o.create(u);return l.color&&(h.color=l.color),h});const c=s*s*Math.sqrt(3)/4;return A=A.filter(l=>i(c,l)),A};e.exports=r}}),i5o=At({"node_modules/@jscad/modeling/src/operations/modifiers/mergePolygons.js"(t,e){var n=FMe(),o=Ar(),i=Za(),r=p=>{const I=i.toPoints(p),f=[];for(let C=0;C<I.length;C++){const y=(C+1)%I.length,E={v1:I[C],v2:I[y]};f.push(E)}for(let C=0;C<f.length;C++){const y=(C+1)%I.length;f[C].next=f[y],f[y].prev=f[C]}return f},s=(p,I)=>{const f=`${I.v1}:${I.v2}`;p.set(f,I)},a=(p,I)=>{const f=`${I.v1}:${I.v2}`;p.delete(f)},A=(p,I)=>{const f=`${I.v2}:${I.v1}`;return p.get(f)},c=(p,I,f)=>{let C=p.prev.v1,y=p.prev.v2,E=I.next.v2;const B=u(C,y,E,f);C=I.prev.v1,y=I.prev.v2,E=p.next.v2;const Q=u(C,y,E,f);return[B,Q]},l=o.create(),g=o.create(),u=(p,I,f,C)=>{const y=o.subtract(l,I,p),E=o.subtract(g,f,I);return o.cross(y,y,E),o.dot(y,C)},h=p=>{let I;const f=[];for(;p.next;){const C=p.next;f.push(p.v1),p.v1=null,p.v2=null,p.next=null,p.prev=null,p=C}return f.length>0&&(I=i.create(f)),I},d=p=>{if(p.length<2)return p;const I=p[0].plane,f=p.slice(),C=new Map;for(;f.length>0;){const E=f.shift(),B=r(E);for(let Q=0;Q<B.length;Q++){const b=B[Q],D=A(C,b);if(D){const R=c(b,D,I);if(R[0]>=0&&R[1]>=0){const M=D.next,L=b.next;b.prev.next=D.next,b.next.prev=D.prev,D.prev.next=b.next,D.next.prev=b.prev,b.v1=null,b.v2=null,b.next=null,b.prev=null,a(C,D),D.v1=null,D.v2=null,D.next=null,D.prev=null;const G=(O,U,W)=>{const j={v1:W.v1,v2:U.v2,next:U.next,prev:W.prev};W.prev.next=j,U.next.prev=j,a(O,U),U.v1=null,U.v2=null,U.next=null,U.prev=null,a(O,W),W.v1=null,W.v2=null,W.next=null,W.prev=null};R[0]===0&&G(C,M,M.prev),R[1]===0&&G(C,L,L.prev)}}else b.next&&s(C,b)}}const y=[];return C.forEach(E=>{const B=h(E);B&&y.push(B)}),C.clear(),y},_=(p,I)=>Math.abs(p[3]-I[3])<15e-8?n(p,I):!1,m=(p,I)=>{const f=[];I.forEach(y=>{const E=f.find(B=>_(B[0],i.plane(y)));E?E[1].push(y):f.push([i.plane(y),[y]])});let C=[];return f.forEach(y=>{const E=y[1],B=d(E);C=C.concat(B)}),C};e.exports=m}}),r5o=At({"node_modules/@jscad/modeling/src/operations/modifiers/insertTjunctions.js"(t,e){var n=hA(),o=Ar(),i=Za(),r=c=>`${c}`,s=(c,l,g,u,h,d)=>{const _=r(u),m=r(h),p=`${_}/${m}`,I=`${m}/${_}`;if(c.has(I))return a(c,l,g,h,u,null),null;const f={vertex0:u,vertex1:h,polygonindex:d};return c.has(p)?c.get(p).push(f):c.set(p,[f]),l.has(_)?l.get(_).push(p):l.set(_,[p]),g.has(m)?g.get(m).push(p):g.set(m,[p]),p},a=(c,l,g,u,h,d)=>{const _=r(u),m=r(h),p=`${_}/${m}`;let I=-1;const f=c.get(p);for(let C=0;C<f.length;C++){const y=f[C];let E=r(y.vertex0);if(E===_&&(E=r(y.vertex1),E===m&&!(d!==null&&y.polygonindex!==d))){I=C;break}}f.splice(I,1),f.length===0&&c.delete(p),I=l.get(_).indexOf(p),l.get(_).splice(I,1),l.get(_).length===0&&l.delete(_),I=g.get(m).indexOf(p),g.get(m).splice(I,1),g.get(m).length===0&&g.delete(m)},A=c=>{const l=new Map;for(let g=0;g<c.length;g++){const u=c[g],h=u.vertices.length;if(h>=3){let d=u.vertices[0],_=r(d);for(let m=0;m<h;m++){let p=m+1;p===h&&(p=0);const I=u.vertices[p],f=r(I),C=`${_}/${f}`,y=`${f}/${_}`;if(l.has(y)){const E=l.get(y);E.splice(-1,1),E.length===0&&l.delete(y)}else{const E={vertex0:d,vertex1:I,polygonindex:g};l.has(C)?l.get(C).push(E):l.set(C,[E])}d=I,_=f}}else console.warn("warning: invalid polygon found during insertTjunctions")}if(l.size>0){const g=new Map,u=new Map,h=new Map;for(const[_,m]of l)h.set(_,!0),m.forEach(p=>{const I=r(p.vertex0),f=r(p.vertex1);g.has(I)?g.get(I).push(_):g.set(I,[_]),u.has(f)?u.get(f).push(_):u.set(f,[_])});const d=c.slice(0);for(;l.size!==0;){for(const m of l.keys())h.set(m,!0);let _=!1;for(;;){const m=Array.from(h.keys());if(m.length===0)break;const p=m[0];let I=!0;if(l.has(p)){const C=l.get(p)[0];for(let y=0;y<2;y++){const E=y===0?C.vertex0:C.vertex1,B=y===0?C.vertex1:C.vertex0,Q=r(E),b=r(B);let D=[];y===0?u.has(Q)&&(D=u.get(Q)):g.has(Q)&&(D=g.get(Q));for(let R=0;R<D.length;R++){const M=D[R],L=l.get(M)[0],G=y===0?L.vertex0:L.vertex1;if(y===0?L.vertex1:L.vertex0,r(G)===b){a(l,g,u,E,B,null),a(l,g,u,B,E,null),I=!1,y=2,_=!0;break}else{const U=E,W=B,j=G,te=o.subtract(o.create(),j,U),ie=o.dot(o.subtract(o.create(),W,U),te)/o.dot(te,te);if(ie>0&&ie<1){const $=o.scale(o.create(),te,ie);if(o.add($,$,U),o.squaredDistance($,W)<n.EPS*n.EPS){const se=L.polygonindex,ae=d[se],ce=r(L.vertex1);let fe=-1;for(let he=0;he<ae.vertices.length;he++)if(r(ae.vertices[he])===ce){fe=he;break}const Ce=ae.vertices.slice(0);Ce.splice(fe,0,B);const xe=i.create(Ce);d[se]=xe,a(l,g,u,L.vertex0,L.vertex1,se);const de=s(l,g,u,L.vertex0,B,se),Ee=s(l,g,u,B,L.vertex1,se);de!==null&&h.set(de,!0),Ee!==null&&h.set(Ee,!0),I=!1,y=2,_=!0;break}}}}}}I&&h.delete(p)}if(!_)break}c=d}return l.clear(),c};e.exports=A}}),s5o=At({"node_modules/@jscad/modeling/src/operations/modifiers/triangulatePolygons.js"(t,e){var n=Ar(),o=Za(),i=(s,a,A)=>{const c=a.vertices.length;if(c>3){if(c>4){const u=[0,0,0];a.vertices.forEach(h=>n.add(u,u,h)),n.snap(u,n.divide(u,u,[c,c,c]),s);for(let h=0;h<c;h++){const d=o.create([u,a.vertices[h],a.vertices[(h+1)%c]]);a.color&&(d.color=a.color),A.push(d)}return}const l=o.create([a.vertices[0],a.vertices[1],a.vertices[2]]),g=o.create([a.vertices[0],a.vertices[2],a.vertices[3]]);a.color&&(l.color=a.color,g.color=a.color),A.push(l,g);return}A.push(a)},r=(s,a)=>{const A=[];return a.forEach(c=>{i(s,c,A)}),A};e.exports=r}}),a5o=At({"node_modules/@jscad/modeling/src/operations/modifiers/generalize.js"(t,e){var n=Is(),o=NP(),i=Js(),r=Gs(),s=ql(),a=E6t(),A=i5o(),c=r5o(),l=s5o(),g=(_,m)=>m,u=(_,m)=>m,h=(_,m)=>{const p={snap:!1,simplify:!1,triangulate:!1},{snap:I,simplify:f,triangulate:C}=Object.assign({},p,_),y=o(m);let E=r.toPolygons(m);I&&(E=a(y,E)),f&&(E=A(y,E)),C&&(E=c(E),E=l(y,E));const B=Object.assign({},m);return B.polygons=E,B},d=(_,...m)=>{if(m=n(m),m.length===0)throw new Error("wrong number of arguments");const p=m.map(I=>{if(s.isA(I))return g(_,I);if(i.isA(I))return u(_,I);if(r.isA(I))return h(_,I);throw new Error("invalid geometry")});return p.length===1?p[0]:p};e.exports=d}}),A5o=At({"node_modules/@jscad/modeling/src/operations/modifiers/snap.js"(t,e){var n=Is(),o=Ia(),i=Js(),r=Gs(),s=ql(),a=NP(),A=E6t(),c=h=>{const d=a(h),m=s.toPoints(h).map(p=>o.snap(o.create(),p,d));return s.create(m)},l=h=>{const d=a(h);let m=i.toSides(h).map(p=>[o.snap(o.create(),p[0],d),o.snap(o.create(),p[1],d)]);return m=m.filter(p=>!o.equals(p[0],p[1])),i.create(m)},g=h=>{const d=a(h),_=r.toPolygons(h),m=A(d,_);return r.create(m)},u=(...h)=>{if(h=n(h),h.length===0)throw new Error("wrong number of arguments");const d=h.map(_=>s.isA(_)?c(_):i.isA(_)?l(_):r.isA(_)?g(_):_);return d.length===1?d[0]:d};e.exports=u}}),c5o=At({"node_modules/@jscad/modeling/src/operations/modifiers/index.js"(t,e){e.exports={generalize:a5o(),snap:A5o(),retessellate:GU()}}}),l5o=At({"node_modules/@jscad/modeling/src/utils/padArrayToLength.js"(t,e){var n=(o,i,r)=>{for(o=o.slice();o.length<r;)o.push(i);return o};e.exports=n}}),g5o=At({"node_modules/@jscad/modeling/src/operations/transforms/align.js"(t,e){var n=Is(),o=l5o(),i=HMe(),{translate:r}=Q6(),s=l=>{if(!Array.isArray(l.modes)||l.modes.length>3)throw new Error("align(): modes must be an array of length <= 3");if(l.modes=o(l.modes,"none",3),l.modes.filter(g=>["center","max","min","none"].includes(g)).length!==3)throw new Error('align(): all modes must be one of "center", "max" or "min"');if(!Array.isArray(l.relativeTo)||l.relativeTo.length>3)throw new Error("align(): relativeTo must be an array of length <= 3");if(l.relativeTo=o(l.relativeTo,0,3),l.relativeTo.filter(g=>Number.isFinite(g)||g==null).length!==3)throw new Error("align(): all relativeTo values must be a number, or null.");if(typeof l.grouped!="boolean")throw new Error("align(): grouped must be a boolean value.");return l},a=(l,g,u)=>{for(let h=0;h<3;h++)l[h]==null&&(g[h]==="center"?l[h]=(u[0][h]+u[1][h])/2:g[h]==="max"?l[h]=u[1][h]:g[h]==="min"&&(l[h]=u[0][h]));return l},A=(l,g,u)=>{const h=i(l),d=[0,0,0];for(let _=0;_<3;_++)g[_]==="center"?d[_]=u[_]-(h[0][_]+h[1][_])/2:g[_]==="max"?d[_]=u[_]-h[1][_]:g[_]==="min"&&(d[_]=u[_]-h[0][_]);return r(d,l)},c=(l,...g)=>{l=Object.assign({},{modes:["center","center","min"],relativeTo:[0,0,0],grouped:!1},l),l=s(l);let{modes:h,relativeTo:d,grouped:_}=l;if(g=n(g),g.length===0)throw new Error("align(): No geometries were provided to act upon");if(d.filter(m=>m==null).length){const m=i(g);d=a(d,h,m)}return _?g=A(g,h,d):g=g.map(m=>A(m,h,d)),g.length===1?g[0]:g};e.exports=c}}),Vie=At({"node_modules/@jscad/modeling/src/operations/transforms/center.js"(t,e){var n=Is(),o=Js(),i=Gs(),r=ql(),s=x6(),{translate:a}=Q6(),A=(h,d)=>{const _={axes:[!0,!0,!0],relativeTo:[0,0,0]},{axes:m,relativeTo:p}=Object.assign({},_,h),I=s(d),f=[0,0,0];return m[0]&&(f[0]=p[0]-(I[0][0]+(I[1][0]-I[0][0])/2)),m[1]&&(f[1]=p[1]-(I[0][1]+(I[1][1]-I[0][1])/2)),m[2]&&(f[2]=p[2]-(I[0][2]+(I[1][2]-I[0][2])/2)),a(f,d)},c=(h,...d)=>{const _={axes:[!0,!0,!0],relativeTo:[0,0,0]},{axes:m,relativeTo:p}=Object.assign({},_,h);if(d=n(d),d.length===0)throw new Error("wrong number of arguments");if(p.length!==3)throw new Error("relativeTo must be an array of length 3");h={axes:m,relativeTo:p};const I=d.map(f=>r.isA(f)||o.isA(f)||i.isA(f)?A(h,f):f);return I.length===1?I[0]:I},l=(...h)=>c({axes:[!0,!1,!1]},h),g=(...h)=>c({axes:[!1,!0,!1]},h),u=(...h)=>c({axes:[!1,!1,!0]},h);e.exports={center:c,centerX:l,centerY:g,centerZ:u}}}),Jie=At({"node_modules/@jscad/modeling/src/operations/transforms/scale.js"(t,e){var n=Is(),o=yg(),i=Js(),r=Gs(),s=ql(),a=(g,...u)=>{if(!Array.isArray(g))throw new Error("factors must be an array");if(u=n(u),u.length===0)throw new Error("wrong number of arguments");for(g=g.slice();g.length<3;)g.push(1);if(g[0]<=0||g[1]<=0||g[2]<=0)throw new Error("factors must be positive");const h=o.fromScaling(o.create(),g),d=u.map(_=>s.isA(_)?s.transform(h,_):i.isA(_)?i.transform(h,_):r.isA(_)?r.transform(h,_):_);return d.length===1?d[0]:d},A=(g,...u)=>a([g,1,1],u),c=(g,...u)=>a([1,g,1],u),l=(g,...u)=>a([1,1,g],u);e.exports={scale:a,scaleX:A,scaleY:c,scaleZ:l}}}),u5o=At({"node_modules/@jscad/modeling/src/operations/transforms/transform.js"(t,e){var n=Is(),o=Js(),i=Gs(),r=ql(),s=(a,...A)=>{if(A=n(A),A.length===0)throw new Error("wrong number of arguments");const c=A.map(l=>r.isA(l)?r.transform(a,l):o.isA(l)?o.transform(a,l):i.isA(l)?i.transform(a,l):l);return c.length===1?c[0]:c};e.exports=s}}),b6=At({"node_modules/@jscad/modeling/src/operations/transforms/index.js"(t,e){e.exports={align:g5o(),center:Vie().center,centerX:Vie().centerX,centerY:Vie().centerY,centerZ:Vie().centerZ,mirror:FU().mirror,mirrorX:FU().mirrorX,mirrorY:FU().mirrorY,mirrorZ:FU().mirrorZ,rotate:LU().rotate,rotateX:LU().rotateX,rotateY:LU().rotateY,rotateZ:LU().rotateZ,scale:Jie().scale,scaleX:Jie().scaleX,scaleY:Jie().scaleY,scaleZ:Jie().scaleZ,transform:u5o(),translate:Q6().translate,translateX:Q6().translateX,translateY:Q6().translateY,translateZ:Q6().translateZ}}}),qie=At({"node_modules/@jscad/modeling/src/index.js"(t,e){e.exports={colors:Gie(),curves:sbo(),geometries:RMe(),maths:wbo(),measurements:Hbo(),primitives:S6(),text:p4o(),utils:h6t(),booleans:OU(),expansions:C6t(),extrusions:KU(),hulls:n5o(),minkowski:o5o(),modifiers:c5o(),transforms:b6()}}}),x6t=At({"node_modules/jscad-planner/dist/index.cjs"(t,e){var n=Object.defineProperty,o=Object.getOwnPropertyDescriptor,i=Object.getOwnPropertyNames,r=Object.prototype.hasOwnProperty,s=(u,h)=>{for(var d in h)n(u,d,{get:h[d],enumerable:!0})},a=(u,h,d,_)=>{if(h&&typeof h=="object"||typeof h=="function")for(let m of i(h))!r.call(u,m)&&m!==d&&n(u,m,{get:()=>h[m],enumerable:!(_=o(h,m))||_.enumerable});return u},A=u=>a(n({},"__esModule",{value:!0}),u),c={};s(c,{executeJscadOperations:()=>g,jscadPlanner:()=>l}),e.exports=A(c);var l={booleans:{intersect:(...u)=>({type:"intersect",shapes:u}),subtract:(...u)=>({type:"subtract",shapes:u}),union:(...u)=>({type:"union",shapes:u})},hulls:{hull:(...u)=>({type:"hull",shapes:u.flat()}),hullChain:(...u)=>({type:"hullChain",shapes:u.flat()})},colors:{colorize:(u,h)=>({type:"colorize",color:u,shape:h})},primitives:{cube:u=>({type:"cube",...u}),sphere:u=>({type:"sphere",...u}),cylinder:u=>({type:"cylinder",...u}),polygon:u=>({type:"polygon",...u}),cuboid:u=>({type:"cuboid",...u}),roundedCuboid:u=>({type:"roundedCuboid",...u})},transforms:{rotate:(u,h)=>({type:"rotate",angles:u,shape:h}),scale:(u,h)=>({type:"scale",factors:u,shape:h}),translate:(u,h)=>({type:"translate",vector:u,shape:h})},extrusions:{extrudeLinear:(u,h)=>({type:"extrudeLinear",options:u,shape:h}),extrudeRotate:(u,h)=>({type:"extrudeRotate",options:u,shape:h})},maths:{vec2:{create:(u,h)=>[u,h],fromValues:(u,h)=>[u,h]},vec3:{create:(u,h,d)=>[u,h,d],fromValues:(u,h,d)=>[u,h,d]}},geometries:{geom2:{create:u=>({type:"createGeom2",points:u})},geom3:{create:u=>({type:"createGeom3",polygons:u})},path2:{create:u=>({type:"createPath2",points:u})}},measurements:{measureBoundingBox:u=>({type:"measureBoundingBox",shape:u}),measureArea:u=>({type:"measureArea",shape:u}),measureVolume:u=>({type:"measureVolume",shape:u})},utils:{degToRad:u=>u*Math.PI/180,radToDeg:u=>u*180/Math.PI}},g=(u,h)=>{if(Array.isArray(h)&&h.length===1)return g(u,h[0]);if(Array.isArray(h))throw new Error("executeJscadOperations currently doesn't support Array<JscadOperation>, try adding a root union or or executing each element individually");const d=p=>g(u,p),{type:_,...m}=h;switch(_){case"intersect":return u.booleans.intersect(...h.shapes.map(d));case"subtract":return u.booleans.subtract(...h.shapes.map(d));case"union":return u.booleans.union(...h.shapes.map(d));case"hull":return u.hulls.hull(...h.shapes.map(d));case"hullChain":return u.hulls.hullChain(...h.shapes.map(d));case"colorize":return u.colors.colorize(h.color,d(h.shape));case"cube":return u.primitives.cube(m);case"sphere":return u.primitives.sphere(m);case"cylinder":return u.primitives.cylinder(m);case"polygon":return u.primitives.polygon(m);case"cuboid":return u.primitives.cuboid(m);case"roundedCuboid":return u.primitives.roundedCuboid(m);case"rotate":return u.transforms.rotate(h.angles,d(h.shape));case"scale":return u.transforms.scale(h.factors,d(h.shape));case"translate":return u.transforms.translate(h.vector,d(h.shape));case"extrudeLinear":return u.extrusions.extrudeLinear(h.options,d(h.shape));case"extrudeRotate":return u.extrusions.extrudeRotate(h.options,d(h.shape));case"createGeom2":return u.geometries.geom2.create(h.points);case"createGeom3":return u.geometries.geom3.create(h.polygons);case"createPath2":return u.geometries.path2.create(h.points);case"measureBoundingBox":return u.measurements.measureBoundingBox(d(h.shape));case"measureArea":return u.measurements.measureArea(d(h.shape));case"measureVolume":return u.measurements.measureVolume(d(h.shape));case"degToRad":return u.utils.degToRad(h.degrees);case"radToDeg":return u.utils.radToDeg(h.radians);default:throw h.type===void 0?new Error(`Operation type is undefined. This usually means the operation object is malformed or not properly initialized. Operation: ${JSON.stringify(h,null,2).slice(0,200)}...`):new Error(`Unsupported operation type: ${h.type}. Operation: ${JSON.stringify(h,null,2)}`)}}}}),d5o=At({"node_modules/ms/index.js"(t,e){var n=1e3,o=n*60,i=o*60,r=i*24,s=r*7,a=r*365.25;e.exports=function(u,h){h=h||{};var d=typeof u;if(d==="string"&&u.length>0)return A(u);if(d==="number"&&isFinite(u))return h.long?l(u):c(u);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(u))};function A(u){if(u=String(u),!(u.length>100)){var h=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(u);if(h){var d=parseFloat(h[1]),_=(h[2]||"ms").toLowerCase();switch(_){case"years":case"year":case"yrs":case"yr":case"y":return d*a;case"weeks":case"week":case"w":return d*s;case"days":case"day":case"d":return d*r;case"hours":case"hour":case"hrs":case"hr":case"h":return d*i;case"minutes":case"minute":case"mins":case"min":case"m":return d*o;case"seconds":case"second":case"secs":case"sec":case"s":return d*n;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return d;default:return}}}}function c(u){var h=Math.abs(u);return h>=r?Math.round(u/r)+"d":h>=i?Math.round(u/i)+"h":h>=o?Math.round(u/o)+"m":h>=n?Math.round(u/n)+"s":u+"ms"}function l(u){var h=Math.abs(u);return h>=r?g(u,h,r,"day"):h>=i?g(u,h,i,"hour"):h>=o?g(u,h,o,"minute"):h>=n?g(u,h,n,"second"):u+" ms"}function g(u,h,d,_){var m=h>=d*1.5;return Math.round(u/d)+" "+_+(m?"s":"")}}}),h5o=At({"node_modules/debug/src/common.js"(t,e){function n(o){r.debug=r,r.default=r,r.coerce=g,r.disable=c,r.enable=a,r.enabled=l,r.humanize=d5o(),r.destroy=u,Object.keys(o).forEach(h=>{r[h]=o[h]}),r.names=[],r.skips=[],r.formatters={};function i(h){let d=0;for(let _=0;_<h.length;_++)d=(d<<5)-d+h.charCodeAt(_),d|=0;return r.colors[Math.abs(d)%r.colors.length]}r.selectColor=i;function r(h){let d,_=null,m,p;function I(...f){if(!I.enabled)return;const C=I,y=Number(new Date),E=y-(d||y);C.diff=E,C.prev=d,C.curr=y,d=y,f[0]=r.coerce(f[0]),typeof f[0]!="string"&&f.unshift("%O");let B=0;f[0]=f[0].replace(/%([a-zA-Z%])/g,(b,D)=>{if(b==="%%")return"%";B++;const R=r.formatters[D];if(typeof R=="function"){const M=f[B];b=R.call(C,M),f.splice(B,1),B--}return b}),r.formatArgs.call(C,f),(C.log||r.log).apply(C,f)}return I.namespace=h,I.useColors=r.useColors(),I.color=r.selectColor(h),I.extend=s,I.destroy=r.destroy,Object.defineProperty(I,"enabled",{enumerable:!0,configurable:!1,get:()=>_!==null?_:(m!==r.namespaces&&(m=r.namespaces,p=r.enabled(h)),p),set:f=>{_=f}}),typeof r.init=="function"&&r.init(I),I}function s(h,d){const _=r(this.namespace+(typeof d>"u"?":":d)+h);return _.log=this.log,_}function a(h){r.save(h),r.namespaces=h,r.names=[],r.skips=[];const d=(typeof h=="string"?h:"").trim().replace(/\s+/g,",").split(",").filter(Boolean);for(const _ of d)_[0]==="-"?r.skips.push(_.slice(1)):r.names.push(_)}function A(h,d){let _=0,m=0,p=-1,I=0;for(;_<h.length;)if(m<d.length&&(d[m]===h[_]||d[m]==="*"))d[m]==="*"?(p=m,I=_,m++):(_++,m++);else if(p!==-1)m=p+1,I++,_=I;else return!1;for(;m<d.length&&d[m]==="*";)m++;return m===d.length}function c(){const h=[...r.names,...r.skips.map(d=>"-"+d)].join(",");return r.enable(""),h}function l(h){for(const d of r.skips)if(A(h,d))return!1;for(const d of r.names)if(A(h,d))return!0;return!1}function g(h){return h instanceof Error?h.stack||h.message:h}function u(){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 r.enable(r.load()),r}e.exports=n}}),_5o=At({"node_modules/debug/src/browser.js"(t,e){t.formatArgs=o,t.save=i,t.load=r,t.useColors=n,t.storage=s(),t.destroy=(()=>{let A=!1;return()=>{A||(A=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),t.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"];function n(){if(typeof window<"u"&&window.process&&(window.process.type==="renderer"||window.process.__nwjs))return!0;if(typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;let A;return typeof document<"u"&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window<"u"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator<"u"&&navigator.userAgent&&(A=navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/))&&parseInt(A[1],10)>=31||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}function o(A){if(A[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+A[0]+(this.useColors?"%c ":" ")+"+"+e.exports.humanize(this.diff),!this.useColors)return;const c="color: "+this.color;A.splice(1,0,c,"color: inherit");let l=0,g=0;A[0].replace(/%[a-zA-Z%]/g,u=>{u!=="%%"&&(l++,u==="%c"&&(g=l))}),A.splice(g,0,c)}t.log=console.debug||console.log||(()=>{});function i(A){try{A?t.storage.setItem("debug",A):t.storage.removeItem("debug")}catch{}}function r(){let A;try{A=t.storage.getItem("debug")||t.storage.getItem("DEBUG")}catch{}return!A&&typeof BMe<"u"&&"env"in BMe&&(A=BMe.env.DEBUG),A}function s(){try{return localStorage}catch{}}e.exports=h5o()(t);var{formatters:a}=e.exports;a.j=function(A){try{return JSON.stringify(A)}catch(c){return"[UnexpectedJSONParseError]: "+c.message}}}}),ZMe=["translucent","opaque","hidden"],m5o=t=>ZMe[(ZMe.indexOf(t)+1)%ZMe.length],B6t={boardBody:!0,topCopper:!0,bottomCopper:!0,keepout:!0,adhesive:!1,solderPaste:!1,topSilkscreen:!0,bottomSilkscreen:!0,topMask:!0,bottomMask:!0,throughHoleModels:!0,smtModels:!0,translucentModels:!0,modelsNotInPosFile:!1,modelsMarkedDNP:!1,modelBoundingBoxes:!1,threedAxis:!1,pcbNotes:!1,backgroundStart:!0,backgroundEnd:!0,enclosure:"translucent"},Q6t=X.createContext(void 0),p5o=({children:t})=>{const[e,n]=X.useState(B6t),o=X.useCallback((s,a)=>{n(A=>({...A,[s]:a}))},[]),i=X.useCallback(()=>{n(B6t)},[]),r=X.useMemo(()=>({visibility:e,setLayerVisibility:o,resetToDefaults:i}),[e,o,i]);return Y.jsx(Q6t.Provider,{value:r,children:t})},D6=()=>{const t=X.useContext(Q6t);if(!t)throw new Error("useLayerVisibility must be used within a LayerVisibilityProvider");return t},e3e=1.2;function S6t(t){return X.useMemo(()=>{if(!t)return e3e;try{return Hi(t).pcb_board.list()[0]?.thickness??e3e}catch{return e3e}},[t])}var b6t=X.createContext(null),MI=()=>{const t=X.useContext(b6t);if(!t)throw new Error("useThree must be used within a ThreeProvider");return t},UU=(t,e=[])=>{const{addFrameListener:n,removeFrameListener:o}=MI();Xr.useEffect(()=>(n(t),()=>o(t)),[n,o,...e])},YU={clickToInteractOverlay:100,htmlElements:95,orientationCube:95,contextMenu:90,appearanceMenu:91},D6t=({children:t,position:e,style:n})=>{const{camera:o,renderer:i}=MI(),r=X.useRef(document.createElement("div")),[s,a]=X.useState(null);return X.useEffect(()=>{const A=i?.domElement.parentNode;if(A)return A.style.position!=="relative"&&A.style.position!=="absolute"&&(A.style.position="relative"),A.appendChild(r.current),a(fIt.createPortal(t,r.current)),()=>{A.contains(r.current)&&A.removeChild(r.current)}},[i,t]),UU(()=>{if(!o||!r.current||!i)return;const A=new Dt(...e);A.project(o);const c=i.domElement.getBoundingClientRect(),l=Math.round((A.x+1)/2*c.width),g=Math.round((-A.y+1)/2*c.height);r.current.style.position="absolute",r.current.style.left=`${l}px`,r.current.style.top=`${g}px`,r.current.style.pointerEvents="none",r.current.style.zIndex=YU.htmlElements.toString(),n&&Object.assign(r.current.style,n)},[o,i,e,n]),s},v6t={in:25.4,inch:25.4,mil:.0254,mm:1,m:1e3,cm:10,ft:304.8,feet:304.8},Oa=t=>{let e=typeof t=="number"?"mm":t.replace(/^[^a-zA-Z]+/g,"").toLowerCase();e||(e="mm");const n=typeof t=="number"?t:Number.parseFloat(t.split(e)[0]);if(e in v6t)return n*v6t[e];throw new Error(`Unsupported unit: ${e}`)},yd=Oa,I5o=Object.defineProperty,f5o=(t,e)=>{for(var n in e)I5o(t,n,{get:e[n],enumerable:!0})},a5={};f5o(a5,{axial:()=>jDo,bga:()=>$5o,breakoutheaders:()=>cvo,cap:()=>b5o,dfn:()=>PDo,diode:()=>S5o,dip:()=>E5o,electrolytic:()=>rMo,hc49:()=>uvo,jst:()=>Ewo,led:()=>D5o,lqfp:()=>avo,m2host:()=>DMo,melf:()=>PPo,micromelf:()=>RPo,minimelf:()=>EPo,mlp:()=>aDo,mountedpcbmodule:()=>PMo,ms012:()=>FDo,ms013:()=>HDo,msop:()=>Mwo,pad:()=>dvo,pinrow:()=>MDo,platedhole:()=>IMo,potentiometer:()=>nMo,pushbutton:()=>tvo,qfn:()=>iDo,qfp:()=>sDo,quad:()=>qT,radial:()=>ZDo,res:()=>W5o,sma:()=>LPo,smb:()=>VPo,smbf:()=>aMo,smc:()=>jPo,smf:()=>KPo,smtpad:()=>mMo,sod110:()=>Bwo,sod123:()=>VDo,sod123f:()=>Wvo,sod123fl:()=>Zvo,sod123w:()=>vvo,sod128:()=>aPo,sod323:()=>Nvo,sod323f:()=>zvo,sod323fl:()=>Lwo,sod323w:()=>Rwo,sod523:()=>fvo,sod723:()=>oPo,sod80:()=>Qvo,sod882:()=>Ovo,sod882d:()=>SPo,sod923:()=>Fvo,soic:()=>eDo,solderjumper:()=>Jwo,son:()=>Kwo,sop8:()=>xvo,sot:()=>CMo,sot223:()=>ewo,sot23:()=>xDo,sot23w:()=>cwo,sot25:()=>bDo,sot323:()=>uMo,sot343:()=>BMo,sot363:()=>mDo,sot457:()=>jwo,sot563:()=>TDo,sot723:()=>ODo,sot886:()=>fDo,sot89:()=>pPo,sot963:()=>Zwo,ssop:()=>lDo,stampboard:()=>ovo,stampreceiver:()=>svo,to220:()=>q6t,to220f:()=>CPo,to92:()=>pvo,to92l:()=>RMo,to92s:()=>_wo,tqfp:()=>rDo,tssop:()=>dDo,vson:()=>Ywo,vssop:()=>vwo});var mi=(t,e,n)=>({type:"pcb_silkscreen_text",pcb_silkscreen_text_id:"silkscreen_text_1",font:"tscircuit2024",font_size:n,pcb_component_id:"pcb_component_1",text:"{REF}",layer:"top",anchor_position:{x:t,y:e},anchor_alignment:"center"}),ui=Ze({norefdes:Fe().optional().describe("disable reference designator label"),invert:Fe().optional().describe("hint to invert the orientation of the 3D model"),faceup:Fe().optional().describe("The male pin header should face upwards, out of the top layer"),nosilkscreen:Fe().optional().describe("omit all silkscreen elements from the footprint")}),qs=(t,e,n,o,i)=>({pcb_plated_hole_id:"",type:"pcb_plated_hole",shape:"circle",x:e,y:n,hole_diameter:Oa(o),outer_diameter:Oa(i),pcb_port_id:"",layers:["top","bottom"],port_hints:[t.toString()]}),vy=t=>{const{pn:e,x:n,y:o,holeDiameter:i,rectPadWidth:r,rectPadHeight:s,holeOffsetX:a=0,holeOffsetY:A=0,rectBorderRadius:c}=t;return{pcb_plated_hole_id:"",type:"pcb_plated_hole",shape:"circular_hole_with_rect_pad",x:n,y:o,hole_diameter:Oa(i),hole_shape:"circle",pad_shape:"rect",rect_pad_width:Oa(r),rect_pad_height:Oa(s),...c!==void 0&&{rect_border_radius:c},pcb_port_id:"",layers:["top","bottom"],port_hints:[e.toString()],hole_offset_x:a,hole_offset_y:A}},Wie=Array.from({length:9},(t,e)=>Math.cos(e/8*Math.PI-Math.PI)).map(t=>({x:t,y:-Math.sqrt(1-t**2)})),n1=t=>{if(t.length<2)throw new Error("Rect union outline requires at least two bounds");for(const c of t)if(c.minX>=c.maxX||c.minY>=c.maxY)throw new Error("Each rectangle bound must have min < max on both axes");for(let c=1;c<t.length;c++){const l=t[c-1],g=t[c];if(g.minX<l.minX||g.maxX>l.maxX||g.minY>l.minY||g.maxY<l.maxY)throw new Error("Bounds must be ordered outer-to-inner with tighter X and larger Y span")}const e=()=>{const c=[];let l=t.length-1;for(c.push({x:t[l].minX,y:t[l].maxY});l>0;){const g=t[l],u=t[l-1];c.push({x:g.minX,y:u.maxY}),c.push({x:u.minX,y:u.maxY}),l-=1}return c},n=()=>{const c=[];let l=t.length-1;for(c.push({x:t[l].maxX,y:t[l].maxY});l>0;){const g=t[l],u=t[l-1];c.push({x:g.maxX,y:u.maxY}),c.push({x:u.maxX,y:u.maxY}),l-=1}return c},o=()=>{const c=[];let l=t.length-1;for(c.push({x:t[l].maxX,y:t[l].minY});l>0;){const g=t[l],u=t[l-1];c.push({x:g.maxX,y:u.minY}),c.push({x:u.maxX,y:u.minY}),l-=1}return c},i=()=>{const c=[];let l=t.length-1;for(c.push({x:t[l].minX,y:t[l].minY});l>0;){const g=t[l],u=t[l-1];c.push({x:g.minX,y:u.minY}),c.push({x:u.minX,y:u.minY}),l-=1}return c},r=e(),s=n(),a=o(),A=i();return[...r.reverse(),...s,...a.reverse(),...A]};function RP(t){return typeof t=="string"?t.trim().toLowerCase().endsWith("mil")?parseFloat(t)*.0254:parseFloat(t):Number(t)}var jie=Rn([F(),Ue()]).transform(t=>RP(t)),C5o=t=>ui.extend({fn:F(),num_pins:Ue().optional().default(6),wide:Fe().optional(),narrow:Fe().optional(),w:jie.optional(),p:jie.default(t.p??"2.54mm"),id:jie.optional(),od:jie.optional(),nosquareplating:Fe().optional().default(!1).describe("do not use rectangular pad for pin 1")}).transform(e=>(!e.id&&!e.od?Math.abs(e.p-1.27)<.01?(e.id=RP("0.55mm"),e.od=RP("0.95mm")):(e.id=RP("0.8mm"),e.od=RP("1.6mm")):e.id?e.od||(e.od=e.id*(1.5/1)):e.id=e.od*(1/1.5),e.w||(e.wide?e.w=RP("600mil"):e.narrow?e.w=RP("300mil"):e.w=RP(t.w??"300mil")),e)),y5o=C5o({}),P6t=(t,e,n,o,i)=>{const r=t/2,s=e<=r,a=r-1,A=o,c=A*a;return s?{x:-n/2,y:c/2-(e-1)*A}:{x:n/2,y:-c/2+(e-r-1)*A}},E5o=t=>{const e=y5o.parse(t),n=[];for(let p=0;p<e.num_pins;p++){const{x:I,y:f}=P6t(e.num_pins,p+1,e.w,e.p??2.54,e.nosquareplating);if(p===0&&!e.nosquareplating){n.push(vy({pn:p+1,x:I,y:f,holeDiameter:e.id??"0.8mm",rectPadWidth:e.od??"1mm",rectPadHeight:e.od??"1mm"}));continue}n.push(qs(p+1,I,f,e.id??"0.8mm",e.od??"1mm"))}const o=(e.num_pins/2-1)*e.p+e.od,r=e.w-e.od-1,s=(e.num_pins/2-1)*e.p+e.od+.4,a={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-r/2,y:-s/2},{x:-r/2,y:s/2},...Wie.map(({x:p,y:I})=>({x:p*r/6,y:I*r/6+s/2})),{x:r/2,y:s/2},{x:r/2,y:-s/2},{x:-r/2,y:-s/2}],type:"pcb_silkscreen_path",stroke_width:.1},A=[];for(let p=0;p<e.num_pins;p++){const I=p<e.num_pins/2,f=.6,{y:C}=P6t(e.num_pins,p+1,e.w,e.p??2.54,e.nosquareplating),y=I?-e.w/2-e.od/2-f:e.w/2+e.od/2+f,E=C;A.push({type:"pcb_fabrication_note_text",pcb_fabrication_note_text_id:`pin_${p+1}`,layer:"top",pcb_component_id:`pin_${p+1}`,text:`{pin${p+1}}`,anchor_position:{x:y,y:E},font_size:.3,font:"tscircuit2024",anchor_alignment:"top_left"})}const c=mi(0,s/2+.5,.4),l=e.w+e.od,g=o,u=l/2+.25,h=u,d=g/2+.72,_=d,m={type:"pcb_courtyard_outline",pcb_courtyard_outline_id:"",pcb_component_id:"",outline:n1([{minX:-u,maxX:u,minY:-_,maxY:_},{minX:-h,maxX:h,minY:-d,maxY:d}]),layer:"top"};return{circuitJson:[...n,a,c,...A,m],parameters:e}},Go=(t,e,n,o,i,r)=>({type:"pcb_smtpad",x:e,y:n,width:o,height:i,layer:"top",shape:"rect",...r!==void 0&&{corner_radius:r},pcb_smtpad_id:"",port_hints:Array.isArray(t)?t.map(s=>s.toString()):[t.toString()]}),w6t=[{imperial:"01005",metric:"0402",p_mm_min:.5,pw_mm_min:.4,ph_mm_min:.3,w_mm_min:.58,h_mm_min:.21,courtyard_width_mm:1.2,courtyard_height_mm:.6},{imperial:"0504",metric:"1310",p_mm_min:1.1,pw_mm_min:.65,ph_mm_min:1.3,w_mm_min:.58,h_mm_min:.21},{imperial:"1812",metric:"4532",p_mm_min:4.275,pw_mm_min:1.125,ph_mm_min:3.4,w_mm_min:5.4,h_mm_min:3.4,courtyard_width_mm:5.9,courtyard_height_mm:3.9,nonpolarizedSilkscreen:{line_half_length_mm:1.386252,line_y_mm:1.71,stroke_width_mm:.12}},{imperial:"0201",metric:"0603",p_mm_min:.66,pw_mm_min:.46,ph_mm_min:.4,w_mm_min:.9,h_mm_min:.3,courtyard_width_mm:1.4,courtyard_height_mm:.7},{imperial:"0402",metric:"1005",p_mm_min:1.02,pw_mm_min:.54,ph_mm_min:.64,w_mm_min:1.56,h_mm_min:.64,courtyard_width_mm:1.86,courtyard_height_mm:.94,nonpolarizedSilkscreen:{line_half_length_mm:.153641,line_y_mm:.38,stroke_width_mm:.12}},{imperial:"0603",metric:"1608",p_mm_min:1.65,pw_mm_min:.8,ph_mm_min:.95,w_mm_min:2.45,h_mm_min:.95,courtyard_width_mm:2.96,courtyard_height_mm:1.46,nonpolarizedSilkscreen:{line_half_length_mm:.237258,line_y_mm:.5225,stroke_width_mm:.12}},{imperial:"0805",metric:"2012",p_mm_min:1.825,pw_mm_min:1.025,ph_mm_min:1.4,w_mm_min:2.8499999999999996,h_mm_min:1.4,courtyard_width_mm:3.36,courtyard_height_mm:1.9,nonpolarizedSilkscreen:{line_half_length_mm:.227064,line_y_mm:.735,stroke_width_mm:.12}},{imperial:"1206",metric:"3216",p_mm_min:2.925,pw_mm_min:1.125,ph_mm_min:1.75,w_mm_min:4.05,h_mm_min:1.75,courtyard_width_mm:4.56,courtyard_height_mm:2.26,nonpolarizedSilkscreen:{line_half_length_mm:.727064,line_y_mm:.91,stroke_width_mm:.12}},{imperial:"1210",metric:"3225",p_mm_min:2.925,pw_mm_min:1.125,ph_mm_min:2.65,w_mm_min:4.05,h_mm_min:2.65,courtyard_width_mm:4.56,courtyard_height_mm:3.16,nonpolarizedSilkscreen:{line_half_length_mm:.723737,line_y_mm:1.355,stroke_width_mm:.12}},{imperial:"2010",metric:"5025",p_mm_min:4.625,pw_mm_min:1.225,ph_mm_min:2.65,w_mm_min:5.85,h_mm_min:2.65,courtyard_width_mm:6.36,courtyard_height_mm:3.16,nonpolarizedSilkscreen:{line_half_length_mm:1.527064,line_y_mm:1.36,stroke_width_mm:.12}},{imperial:"2512",metric:"6332",p_mm_min:5.925,pw_mm_min:1.225,ph_mm_min:3.35,w_mm_min:7.15,h_mm_min:3.35,courtyard_width_mm:7.66,courtyard_height_mm:3.86,nonpolarizedSilkscreen:{line_half_length_mm:2.177064,line_y_mm:1.71,stroke_width_mm:.12}}],x5o=Object.fromEntries(w6t.map(t=>[t.metric,t])),B5o=Object.fromEntries(w6t.map(t=>[t.imperial,t])),Q5o=(t,e)=>({type:"pcb_courtyard_rect",pcb_courtyard_rect_id:"",pcb_component_id:"",center:{x:0,y:0},width:t,height:e,layer:"top"});ui.extend({fn:F().optional(),string:F().optional(),tht:Fe(),p:le.optional(),pw:le.optional(),ph:le.optional(),metric:it.optional(),imperial:it.optional(),w:le.optional(),h:le.optional(),nonpolarized:Fe().optional(),textbottom:Fe().optional(),roundedPads:Fe().optional()});var Xie=t=>{let{fn:e,tht:n,p:o,pw:i,ph:r,metric:s,imperial:a,w:A,h:c,nonpolarized:l,textbottom:g,roundedPads:u,string:h}=t;if(typeof A=="string"&&(A=yd(A)),typeof c=="string"&&(c=yd(c)),typeof o=="string"&&(o=yd(o)),typeof i=="string"&&(i=yd(i)),typeof r=="string"&&(r=yd(r)),c!==void 0&&A!==void 0&&c>A)throw new Error("height cannot be greater than width (rotated footprint not yet implemented)");let d;if(s&&(d=x5o[s]),a&&(d=B5o[a]),d&&(A=d.w_mm_min,c=d.h_mm_min,o=d.p_mm_min,i=d.pw_mm_min,r=d.ph_mm_min),o===void 0||i===void 0||r===void 0)throw new Error("Could not determine required pad dimensions (p, pw, ph)");let _=[];const m=e==="res"&&(l===!0||typeof h!="string"||/^res(?:\d{4}|\d{5})(?:_|$)/i.test(h))?d?.nonpolarizedSilkscreen:void 0;if(m?.stroke_width_mm){const{line_half_length_mm:y=0,line_y_mm:E=0,stroke_width_mm:B}=m;_=[{type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-y,y:E},{x:y,y:E}],stroke_width:B,pcb_silkscreen_path_id:""},{type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-y,y:-E},{x:y,y:-E}],stroke_width:B,pcb_silkscreen_path_id:""}]}else _=[{type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:o/2,y:r/2+.4},{x:-o/2-i/2-.2,y:r/2+.4},{x:-o/2-i/2-.2,y:-r/2-.4},{x:o/2,y:-r/2-.4}],stroke_width:.1,pcb_silkscreen_path_id:""}];const p=g?-r/2-.9:r/2+.9,I=mi(0,p,.2),f=d?.courtyard_width_mm&&d.courtyard_height_mm?Q5o(d.courtyard_width_mm,d.courtyard_height_mm):null,C=u?Math.min(.125,Math.min(i,r)/8):void 0;return n?[qs(1,-o/2,0,i,i*1/.8),qs(2,o/2,0,i,i*1/.8),..._,I,...f?[f]:[]]:[Go(["1","left"],-o/2,0,i,r,C),Go(["2","right"],o/2,0,i,r,C),..._,I,...f?[f]:[]]},S5o=t=>({circuitJson:Xie({...t,roundedPads:!0}),parameters:t}),b5o=t=>({circuitJson:Xie(t),parameters:t}),D5o=t=>({circuitJson:Xie(t).map(n=>n.type!=="pcb_silkscreen_path"?n:{...n,route:n.route.map(o=>({...o,x:-o.x}))}),parameters:t}),JT=t=>{const{padSpacing:e,padWidth:n,padHeight:o,padPitch:i,numRows:r,textbottom:s,courtyardOutline:a}=t,A=[],c=(r-1)*(i/2);for(let D=0;D<r;D++)A.push(c-D*i);const l=[];A.forEach((D,R)=>{l.push(Go(R+1,-e/2,D,n,o))}),A.slice().reverse().forEach((D,R)=>{l.push(Go(R+r+1,e/2,D,n,o))});const g=Math.max(...A)+o/2+.4,u=Math.min(...A)-o/2-.4,h=-e/2-n/2-.4,d=e/2+n/2+.4,_={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:d*.5,y:g},{x:h*.5,y:g}],stroke_width:.12,pcb_silkscreen_path_id:"silkscreen_top"},m={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:d*.5,y:u},{x:h*.5,y:u}],stroke_width:.12,pcb_silkscreen_path_id:"silkscreen_bottom"},p=-e/2,I=Math.max(...A),f=.2,C=p-n/2-.1,y=I+o/2+.1,E={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"pin1_marker",route:[{x:C,y},{x:C-f,y},{x:C,y:y+f},{x:C,y}],stroke_width:.1},B=s?u-.9:g+.9,Q=mi(0,B,.2),b=a?{type:"pcb_courtyard_outline",pcb_courtyard_outline_id:"",pcb_component_id:"",layer:"top",outline:a}:null;return[...l,_,m,E,Q,...b?[b]:[]]},v5o=ui.extend({pw:le.default("0.5mm"),ph:le.default("0.4mm"),p:le.default("0.7mm"),textbottom:Fe().optional(),convex:Fe().optional(),concave:Fe().optional()}),P5o=1,w5o=t=>{const e=v5o.parse(t);if(e.concave===!0)return[];const n=yd(e.pw),o=yd(e.ph),i=yd(e.p);return JT({padSpacing:P5o,padWidth:n,padHeight:o,padPitch:i,numRows:2,textbottom:e.textbottom,convex:e.convex,concave:e.concave,courtyardOutline:[{x:-1,y:.95},{x:-1,y:-.95},{x:1,y:-.95},{x:1,y:.95}]})},M5o=ui.extend({pw:le.default("0.5mm"),ph:le.default("0.32mm"),p:le.default("0.5mm"),textbottom:Fe().optional(),convex:Fe().optional(),concave:Fe().optional()}),N5o=1,R5o=t=>{const e=M5o.parse(t),n=yd(e.pw),o=yd(e.ph),i=yd(e.p);return JT({padSpacing:N5o,padWidth:n,padHeight:o,padPitch:i,numRows:4,textbottom:e.textbottom,convex:e.convex,concave:e.concave,courtyardOutline:[{x:-1,y:1.25},{x:-1,y:-1.25},{x:1,y:-1.25},{x:1,y:1.25}]})},T5o=ui.extend({pw:le.default("0.9mm"),ph:le.default("0.4mm"),p:le.default("0.8mm"),textbottom:Fe().optional(),convex:Fe().optional(),concave:Fe().optional()}),k5o=1.7,F5o=t=>{const e=T5o.parse(t),n=yd(e.pw),o=yd(e.ph),i=yd(e.p);return JT({padSpacing:k5o,padWidth:n,padHeight:o,padPitch:i,numRows:2,textbottom:e.textbottom,convex:e.convex,concave:e.concave,courtyardOutline:[{x:-1.55,y:1.05},{x:-1.55,y:-1.05},{x:1.55,y:-1.05},{x:1.55,y:1.05}]})},L5o=ui.extend({pw:le.default("0.9mm"),ph:le.default("0.4mm"),p:le.default("0.8mm"),textbottom:Fe().optional(),convex:Fe().optional(),concave:Fe().optional()}),H5o=1.7,G5o=t=>{const e=L5o.parse(t),n=yd(e.pw),o=yd(e.ph),i=yd(e.p);return JT({padSpacing:H5o,padWidth:n,padHeight:o,padPitch:i,numRows:4,textbottom:e.textbottom,convex:e.convex,concave:e.concave,courtyardOutline:[{x:-1.55,y:1.88},{x:-1.55,y:-1.87},{x:1.55,y:-1.87},{x:1.55,y:1.88}]})},O5o=ui.extend({pw:le.default("0.7mm"),ph:le.default("0.64mm"),p:le.default("0.94mm"),textbottom:Fe().optional(),convex:Fe().optional(),concave:Fe().optional()}),K5o=1.4,U5o=t=>{const e=O5o.parse(t),n=yd(e.pw),o=yd(e.ph),i=yd(e.p);return JT({padSpacing:K5o,padWidth:n,padHeight:o,padPitch:i,numRows:2,textbottom:e.textbottom,convex:e.convex,concave:e.concave,courtyardOutline:[{x:-1.3,y:1.05},{x:-1.3,y:-1.05},{x:1.3,y:-1.05},{x:1.3,y:1.05}]})},Y5o=ui.extend({pw:le.default("0.9mm"),ph:le.default("0.9mm"),p:le.default("1.34mm"),textbottom:Fe().optional(),convex:Fe().optional(),concave:Fe().optional()}),z5o=3,V5o=t=>{const e=Y5o.parse(t),n=yd(e.pw),o=yd(e.ph),i=yd(e.p);return JT({padSpacing:z5o,padWidth:n,padHeight:o,padPitch:i,numRows:4,textbottom:e.textbottom,convex:e.convex,concave:e.concave,courtyardOutline:[{x:-2.21,y:2.85},{x:-2.21,y:-2.85},{x:2.2,y:-2.85},{x:2.2,y:2.85}]})},J5o=t=>{const e=t.array??t.x;if(typeof e=="number")return Number.isNaN(e)?void 0:e;if(typeof e=="string"){const n=Number.parseInt(e,10);return Number.isNaN(n)?void 0:n}if(typeof t.imperial=="string"){const o=t.imperial.match(/x(2|4)$/)?.[1];if(o)return Number.parseInt(o,10)}},q5o=t=>t?(typeof t=="number"?`${t}`:t).split(/[_x]/)[0]:void 0,W5o=t=>{const e=J5o(t),n=q5o(t.imperial);return e===2&&n==="0402"?{circuitJson:w5o(t),parameters:t}:e===4&&n==="0402"?{circuitJson:R5o(t),parameters:t}:e===2&&n==="0603"?{circuitJson:F5o(t),parameters:t}:e===4&&n==="0603"?{circuitJson:G5o(t),parameters:t}:e===2&&n==="0606"?{circuitJson:U5o(t),parameters:t}:e===4&&n==="1206"?{circuitJson:V5o(t),parameters:t}:{circuitJson:Xie(t),parameters:t}},M6t=(t,{x:e,y:n,radius:o})=>({type:"pcb_smtpad",x:e,y:n,radius:o,layer:"top",shape:"circle",pcb_smtpad_id:"",port_hints:Array.isArray(t)?t.map(i=>i.toString()):[t.toString()]}),N6t="ABCDEFGHIJKLMNOPQRSTUVWXYZ",$ie=F().transform(t=>{const[e,n]=t.split(/[x ]/);return{x:parseFloat(e??""),y:parseFloat(n??"")}}).pipe(Ze({x:Ue(),y:Ue()})),j5o=F().or(Qt(Hg())).transform(t=>Array.isArray(t)?t:(t.startsWith("(")&&t.endsWith(")")&&(t=t.slice(1,-1)),t.split(",").map(e=>{const n=Number(e);return isNaN(n)?e:n}))).pipe(Qt(F().or(Ue()))),X5o=ui.extend({fn:F(),num_pins:Ue().optional().default(64),grid:$ie.optional(),p:it.default("0.8mm"),w:le.optional(),h:le.optional(),ball:le.optional().describe("ball diameter"),pad:le.optional().describe("pad width/height"),circularpads:Fe().optional().describe("use circular pads"),tlorigin:Fe().optional(),blorigin:Fe().optional(),trorigin:Fe().optional(),brorigin:Fe().optional(),missing:j5o.default([])}).transform(t=>{let e="tl";if(t.blorigin&&(e="bl"),t.trorigin&&(e="tr"),t.brorigin&&(e="br"),!t.grid){const o=Math.ceil(Math.sqrt(t.num_pins));t.grid={x:o,y:o}}return t.missing&&(t.missing=t.missing.map(o=>{if(typeof o=="number")return o;if(o==="center")return"center";if(o==="topleft")return"topleft";const i=o.match(/([A-Z]+)(\d+)/);if(!i)return o;const r=N6t.indexOf(i[1]),s=Number.parseInt(i[2])-1;return r*t.grid.x+s+1})),{...t,origin:e}}),$5o=t=>{const e=X5o.parse(t);let{num_pins:n,grid:o,p:i,w:r,h:s,ball:a,pad:A,missing:c}=e;a??=.75/1.27*i,A??=a*.8;const l=[],g=(c??[]).filter(j=>typeof j=="number"),u=o.x*o.y-n;if(c.length===0&&u>0&&(Math.sqrt(u)%1===0?c.push("center"):u===1&&c.push("topleft")),c?.includes("center")){const j=Math.floor(Math.sqrt(u)),te=Math.floor((o.x-j)/2),ie=Math.floor((o.y-j)/2);for(let $=ie;$<ie+j;$++)for(let Z=te;Z<te+j;Z++)g.push($*o.x+Z+1)}c?.includes("topleft")&&g.push(1);const h=new Set(g);let d=0;for(let j=0;j<o.y;j++)for(let te=0;te<o.x;te++){const ie=(te-(o.x-1)/2)*i,$=(j-(o.y-1)/2)*i;let Z=te,se=j;switch(e.origin){case"bl":Z=te,se=o.y-1-j;break;case"br":Z=o.x-1-te,se=o.y-1-j;break;case"tr":Z=o.x-1-te,se=j;break}let ae=se*o.x+Z+1;if(h.has(ae)){d++;continue}ae-=d;const ce=[ae,`${N6t[se]}${Z+1}`];l.push(e.circularpads?M6t(ce,{x:ie,y:$,radius:A/2}):Go(ce,ie,$,A,A))}const _=mi(0,o.y*i/2,.2),m=i/6;let p;const I=o.x*i/2,f=o.y*i/2;switch(e.origin){case"bl":p=[{x:-I,y:-f},{x:-I,y:-f-m},{x:-I-m,y:-f},{x:-I,y:-f}];break;case"br":p=[{x:I,y:-f},{x:I,y:-f-m},{x:I+m,y:-f},{x:I,y:-f}];break;case"tr":p=[{x:I,y:f},{x:I,y:f+m},{x:I+m,y:f},{x:I,y:f}];break;default:p=[{x:-I,y:f},{x:-I,y:f+m},{x:-I-m,y:f},{x:-I,y:f}];break}const C={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"pin1_marker",route:p,stroke_width:.05},y=(o.x-1)*i+A,E=(o.y-1)*i+A,B=r??y,Q=s??E,b=Math.max(y/2,B/2),D=Math.max(E/2,Q/2),R=1.715,M=1.765,L=b+R,G=L,O=D+M,U=O,W={type:"pcb_courtyard_outline",pcb_courtyard_outline_id:"",pcb_component_id:"",outline:n1([{minX:-L,maxX:L,minY:-U,maxY:U},{minX:-G,maxX:G,minY:-O,maxY:O}]),layer:"top"};return{circuitJson:[...l,_,C,W],parameters:e}},Zie=(t,e,n,o,i)=>({type:"pcb_smtpad",x:e,y:n,width:o,height:i,radius:i/2,layer:"top",shape:"pill",pcb_smtpad_id:"",port_hints:Array.isArray(t)?t.map(r=>r.toString()):[t.toString()]}),v6=t=>ui.extend({fn:F(),num_pins:Ue().optional().default(8),w:le.default(le.parse(t.w??"5.3mm")),p:le.default(le.parse(t.p??"1.27mm")),pw:le.default(le.parse(t.pw??"0.6mm")),pl:le.default(le.parse(t.pl??"1.0mm")),legsoutside:Fe().optional().default(t.legsoutside??!1),pillpads:Fe().optional().default(t.pillpads??!1),silkscreen_stroke_width:Ue().optional().default(.1)}).transform(e=>(!e.pw&&!e.pl?(e.pw=le.parse("0.6mm"),e.pl=le.parse("1.0mm")):e.pw?e.pl||(e.pl=e.pw*(1/.6)):e.pw=e.pl*(.6/1),e)),Z5o=v6({}),t3e=t=>{t.widthincludeslegs!==void 0&&(t.legsoutside=!t.widthincludeslegs);const{num_pins:e,pn:n,w:o,p:i,pl:r,legsoutside:s}=t,a=e/2,A=n<=a,c=a-1,l=i,g=l*c,u=s?r/2:-r/2;return A?{x:-o/2-u,y:g/2-(n-1)*l}:{x:o/2+u,y:-g/2+(n-a-1)*l}},eDo=t=>{const e=Z5o.parse(t);return{circuitJson:zU(e),parameters:e}},zU=t=>{const e=[];let n=0,o=0;for(let m=0;m<t.num_pins;m++){const{x:p,y:I}=t3e({num_pins:t.num_pins,pn:m+1,w:t.w,p:t.p,pl:t.pl,legsoutside:t.legsoutside});n=Math.max(n,Math.abs(p)+t.pl/2),o=Math.max(o,Math.abs(I)+t.pw/2),t.pillpads?e.push(Zie(m+1,p,I,t.pl,t.pw)):e.push(Go(m+1,p,I,t.pl,t.pw))}const i=Math.min(1,t.p/2),r=t.w-(t.legsoutside?0:t.pl*2)-.2,s=(t.num_pins/2-1)*t.p+t.pw+i,a=mi(0,s/2+.4,s/12),A={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",stroke_width:t.silkscreen_stroke_width??.1,route:[{x:-r/2,y:-s/2},{x:-r/2,y:s/2},...Wie.map(({x:m,y:p})=>({x:m*r/6,y:p*r/6+s/2})),{x:r/2,y:s/2},{x:r/2,y:-s/2},{x:-r/2,y:-s/2}]},c=t.w/2,l=s/2,g=Math.max(n,c)+.25,u=Math.min(o,l)+.25,h=Math.min(n,c)+.25,d=Math.max(o,l)+.25,_={type:"pcb_courtyard_outline",pcb_courtyard_outline_id:"",pcb_component_id:"",layer:"top",outline:n1([{minX:-g,maxX:g,minY:-u,maxY:u},{minX:-h,maxX:h,minY:-d,maxY:d}])};return[...e,A,a,_]},R6t=qt(["leftside","topside","rightside","bottomside","toppin","bottompin","leftpin","rightpin"]),tDo=({num_pins:t,cw:e,ccw:n,startingpin:o})=>{const i=[],r=t/4;let s=1;const a={};for(const A of o??[])a[A]=!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=r:a.bottomside&&a.leftpin?s=r+1:a.bottomside&&a.rightpin?s=r*2:a.rightside&&a.bottompin?s=r*2+1:a.rightside&&a.toppin?s=r*3:a.topside&&a.rightpin?s=r*3+1:a.topside&&a.leftpin&&(s=r*4),i.push(-1);for(let A=0;A<t;A++)i[s]=A+1,n||!e?(s++,s>t&&(s=1)):(s--,s<1&&(s=t));return i},n3e=ui.extend({fn:F(),cc:Fe().default(!0).optional(),ccw:Fe().default(!0).optional(),startingpin:F().or(Qt(R6t)).transform(t=>typeof t=="string"?t.slice(1,-1).split(","):t).pipe(Qt(R6t)).optional(),num_pins:Ue().optional().default(64),w:le.optional(),h:le.optional(),p:le.default(le.parse("0.5mm")),pw:le.optional(),pl:le.optional(),thermalpad:Rn([De(!0),$ie]).optional(),legsoutside:Fe().default(!1)}),o3e=t=>{t.w&&!t.h?t.h=t.w:!t.w&&t.h&&(t.w=t.h);const e=t.num_pins/4;if(!t.p&&!t.pw&&!t.pl&&t.w){const n=e+4;t.p=t.w/n}return!t.p&&t.w&&t.h&&t.pw&&t.pl&&(t.p=(t.w-t.pl*2)/(e-1)),!t.w&&!t.h&&t.p&&(t.w=t.p*(e+4),t.h=t.w),t.p&&!t.pw&&!t.pl?(t.pw=t.p/2,t.pl=t.p/2):t.pw?t.pl||(t.pl=t.pw*(1/.6)):t.pw=t.pl*(.6/1),t},T6t=n3e.transform(o3e),nDo=["left","bottom","right","top"],oDo=t=>{const{pin_count:e,pn:n,w:o,h:i,p:r,pl:s,legsoutside:a}=t,A=e/4,c=nDo[Math.floor((n-1)/A)],l=(n-1)%A,g=r*(A-1),u=r*(A-1),h=a?s/2:-s/2;switch(c){case"left":return{x:-o/2-h+.1,y:u/2-l*r,o:"vert"};case"bottom":return{x:-g/2+l*r,y:-i/2-h+.1,o:"horz"};case"right":return{x:o/2+h-.1,y:-u/2+l*r,o:"vert"};case"top":return{x:g/2-l*r,y:i/2+h-.1,o:"horz"};default:throw new Error("Invalid pin number")}},qT=t=>{const e=T6t.parse(t),n=[];let o=0,i=0;const r=tDo(e),s=e.num_pins/4;for(let f=0;f<e.num_pins;f++){const{x:C,y,o:E}=oDo({pin_count:e.num_pins,pn:f+1,w:e.w,h:e.h,p:e.p??.5,pl:e.pl,legsoutside:e.legsoutside});let B=e.pw,Q=e.pl;E==="vert"&&([B,Q]=[Q,B]);const b=r[f+1];o=Math.max(o,Math.abs(C)+B/2),i=Math.max(i,Math.abs(y)+Q/2),n.push(Go(b,C,y,B,Q))}if(e.thermalpad)if(typeof e.thermalpad=="boolean"){const f=e.p*(s-1)+e.pw,C=e.p*(s-1)+e.pw;o=Math.max(o,f/2),i=Math.max(i,C/2),n.push(Go(["thermalpad"],0,0,f,C))}else o=Math.max(o,e.thermalpad.x/2),i=Math.max(i,e.thermalpad.y/2),n.push(Go(["thermalpad"],0,0,e.thermalpad.x,e.thermalpad.y));const a=[];for(const[f,C,y]of[["top-left",-1,1],["bottom-left",-1,-1],["bottom-right",1,-1],["top-right",1,1]]){const E=e.w/2*C,B=e.h/2*y;let Q="none",b=E,D=B;const R=e.pw*2;r[1]===1&&f==="top-left"?Q="in1":r[s*4]===1&&f==="top-left"||r[s*3+1]===1&&f==="top-right"?Q="in2":r[s*3]===1&&f==="top-right"||r[s]===1&&f==="bottom-left"?Q="in1":r[s+1]===1&&f==="bottom-left"?Q="in2":r[s*2]===1&&f==="bottom-right"?Q="in1":r[s*2+1]===1&&f==="bottom-right"&&(Q="in2");const M=Q==="in1"?1:-1;if(e.legsoutside){const L=Q==="in1"?e.pl/2:e.pw/2,G=Q==="in1"?e.pw/2:e.pl/2;b+=L*C*M,D-=G*y*M}(Q==="none"||e.legsoutside)&&a.push({layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:`pcb_silkscreen_path_${f}`,route:[{x:E-R*C,y:B},{x:E,y:B},{x:E,y:B-R*y}],type:"pcb_silkscreen_path",stroke_width:.1}),(Q==="in1"||Q==="in2")&&!e.legsoutside&&a.push({layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:`pcb_silkscreen_path_${f}_1`,route:[{x:E-R*C,y:B},{x:E-R*C/2,y:B}],type:"pcb_silkscreen_path",stroke_width:0},{layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:`pcb_silkscreen_path_${f}_2`,route:[{x:E,y:B-R*y/2},{x:E,y:B-R*y}],type:"pcb_silkscreen_path",stroke_width:.1}),(Q==="in1"||Q==="in2")&&a.push({layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:`pcb_silkscreen_path_${f}_3`,route:[{x:b-.2*-C,y:D+.2*M},{x:b,y:D},{x:b+.2*M*-C,y:D+.2},{x:b-.2*-C,y:D+.2*M}],type:"pcb_silkscreen_path",stroke_width:.1})}const A=mi(0,e.h/2+(e.legsoutside?e.pl*1.2:.5),.3),c=f=>Math.ceil(f/.05)*.05,l=(s-1)*e.p+e.pw,g=(s-1)*e.p+e.pw,u=l/2+.25,h=g/2+.25,d=e.w/2+.25,_=e.h/2+.25,m=Math.max(d,c(o+.25)),p=Math.max(_,c(i+.25)),I={type:"pcb_courtyard_outline",pcb_courtyard_outline_id:"",pcb_component_id:"",layer:"top",outline:n1([{minX:-m,maxX:m,minY:-h,maxY:h},{minX:-d,maxX:d,minY:-_,maxY:_},{minX:-u,maxX:u,minY:-p,maxY:p}])};return{circuitJson:[...n,...a,A,I],parameters:e}};n3e.extend({}).transform(o3e);var iDo=t=>(t.legsoutside=!1,t.pl||(t.pl=.875),t.pw||(t.pw=.25),qT(t)),rDo=t=>{if(t.legsoutside=!0,!t.p)switch(t.num_pins){case 32:t.p=.8;break;case 44:case 48:t.p=.5;break;case 64:case 80:case 100:t.p=.5;break;case 144:t.p=.5;break}if(!t.pl)switch(t.num_pins){case 32:case 44:case 48:case 64:case 80:case 100:t.pl=1.475;break;case 144:t.pl=1.6;break}if(!t.pw)switch(t.num_pins){case 32:t.pw=.55;break;case 44:case 48:case 64:case 80:case 100:t.pw=.3;break;case 144:t.pw=.25;break}return qT(t)},sDo=t=>{t.legsoutside=!0;const e=T6t.parse(t);if(!t.p)switch(t.num_pins){case 44:case 64:t.p=.8;break;case 52:t.w===14?t.p=1:t.p=.65;break;case 208:t.p=.5;break}if(!t.pl)switch(t.num_pins){case 44:case 52:case 64:t.pl=2.25;break;case 208:t.pl=1.65;break;default:t.pl=e.pl*4;break}if(!t.pw)switch(t.num_pins){case 44:case 64:t.pw=.5;break;case 52:t.w===14?t.pw=.45:t.pw=.55;break;case 208:t.pw=.3;break;default:t.pw=e.pw;break}return qT(t)};n3e.extend({}).transform(o3e);var aDo=t=>(t.legsoutside=!1,t.thermalpad===void 0&&(t.thermalpad=!0),qT(t)),ADo=ui.extend({fn:F(),num_pins:Ue().optional().default(8),w:le.default(le.parse("3.9mm")),p:le.default(le.parse("1.27mm")),pw:le.optional(),pl:le.optional(),legsoutside:Fe().optional().default(!1),silkscreen_stroke_width:Ue().optional().default(.1)}).transform(t=>(t.pw==null&&t.pl==null?(t.pw=le.parse("0.51mm"),t.pl=le.parse("1.1mm")):t.pw==null?t.pw=t.pl*(.51/1.1):t.pl==null&&(t.pl=t.pw*(1.1/.51)),t)),cDo=t=>{const{num_pins:e,pn:n,w:o,p:i}=t,r=e/2,s=n<=r,a=r-1,A=i,c=A*a,l=o+le.parse("0.2mm"),g=(s?-1:1)*(l/2);return s?{x:g,y:c/2-(n-1)*A}:{x:g,y:-c/2+(n-r-1)*A}},lDo=t=>{const e=ADo.parse(t),n=[];for(let m=0;m<e.num_pins;m++){const{x:p,y:I}=cDo({num_pins:e.num_pins,pn:m+1,w:e.w,p:e.p,pl:e.pl,legsoutside:e.legsoutside});n.push(Go(m+1,p,I,e.pl,e.pw))}const o=Math.min(1,e.p/2),i=e.w-(e.legsoutside?0:e.pl)-.2,r=(e.num_pins/2-1)*e.p+e.pw+o,s=mi(0,r/2+.4,r/12),a={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",stroke_width:e.silkscreen_stroke_width??.1,route:[{x:-i/2,y:-r/2},{x:-i/2,y:r/2},...Wie.map(({x:m,y:p})=>({x:m*i/6,y:p*i/6+r/2})),{x:i/2,y:r/2},{x:i/2,y:-r/2},{x:-i/2,y:-r/2}]},A=(e.num_pins/2-1)*e.p+e.pw,c=e.legsoutside?e.w/2+e.pl:(e.w+.2)/2+e.pl/2,l=A/2,g=c+.25,u=g,h=l+.445,d=h,_={type:"pcb_courtyard_outline",pcb_courtyard_outline_id:"",pcb_component_id:"",outline:n1([{minX:-g,maxX:g,minY:-d,maxY:d},{minX:-u,maxX:u,minY:-h,maxY:h}]),layer:"top"};return{circuitJson:[...n,a,s,_],parameters:e}},gDo=ui.extend({fn:F(),num_pins:Ue().optional().default(8),w:le.default(le.parse("3.0mm")),p:le.default(le.parse("0.5mm")),pw:le.default(le.parse("0.30mm")),pl:le.default(le.parse("1.45mm")),legsoutside:Fe().optional().default(!0),silkscreen_stroke_width:Ue().optional().default(.1)}),uDo=t=>{const{num_pins:e,pn:n,w:o,p:i,pl:r,legsoutside:s}=t,a=e/2,A=n<=a,c=a-1,l=i*c,g=s?r/2:-r/2;return A?{x:-o/2-g,y:l/2-(n-1)*i}:{x:o/2+g,y:-l/2+(n-a-1)*i}},dDo=t=>{const e={...t},n=e.p,o=typeof n=="string"||typeof n=="number"?le.parse(n):void 0,i=o!=null&&o<=le.parse("0.5mm"),r=gDo.parse(e),s=[],a=i?r.w-le.parse("0.15mm"):r.w;for(let C=0;C<r.num_pins;C++){const{x:y,y:E}=uDo({num_pins:r.num_pins,pn:C+1,w:a,p:r.p,pl:r.pl,legsoutside:r.legsoutside});s.push(Go(C+1,y,E,r.pl,r.pw))}const A=Math.min(1,r.p/2),c=r.w-(r.legsoutside?0:r.pl*2)-.2,l=(r.num_pins/2-1)*r.p+r.pw+A,g=mi(0,l/2+.4,l/12),u={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",stroke_width:r.silkscreen_stroke_width??.1,route:[{x:-c/2,y:-l/2},{x:-c/2,y:l/2},...Wie.map(({x:C,y})=>({x:C*c/6,y:y*c/6+l/2})),{x:c/2,y:l/2},{x:c/2,y:-l/2},{x:-c/2,y:-l/2}]},h=(r.num_pins/2-1)*r.p+r.pw,d=r.w/2+(r.legsoutside?r.pl:0),_=r.w/2+.25,m=d+.18,p=h/2+.25,I=p+.35,f={type:"pcb_courtyard_outline",pcb_courtyard_outline_id:"",pcb_component_id:"",layer:"top",outline:n1([{minX:-m,maxX:m,minY:-p,maxY:p},{minX:-_,maxX:_,minY:-I,maxY:I}])};return{circuitJson:[...s,u,g,f],parameters:r}},hDo=[{x:-1.45,y:.93},{x:-.73,y:.93},{x:-.73,y:1.1},{x:.73,y:1.1},{x:.73,y:.93},{x:1.45,y:.93},{x:1.45,y:-.93},{x:.73,y:-.93},{x:.73,y:-1.1},{x:-.73,y:-1.1},{x:-.73,y:-.93},{x:-1.45,y:-.93}],_Do=ui.extend({fn:F(),num_pins:De(6).default(6),w:F().default("3.1mm"),h:F().default("2.0mm"),p:F().default("0.65mm"),pl:F().default("1.03mm"),pw:F().default("0.35mm"),string:F().optional()}),mDo=t=>{const e=_Do.parse({...t,fn:"sot363"}),n=le.parse(e.w),o=le.parse(e.h),i=le.parse(e.p),r=le.parse(e.pl),s=le.parse(e.pw),a=[];for(let d=0;d<6;d++){const{x:_,y:m}=k6t(d+1,n,i);a.push(Go(d+1,_,m,r,s))}const A={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-n/4,y:o/2+.1},{x:n/4,y:o/2+.1}],stroke_width:.05,pcb_silkscreen_path_id:""},c={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-n/4,y:-o/2-.1},{x:n/4,y:-o/2-.1}],stroke_width:.05,pcb_silkscreen_path_id:""},l=k6t(1,n,i),g={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"pin_marker_1",route:[{x:l.x-r/2-.3,y:l.y},{x:l.x-r/2-.45,y:l.y+.15},{x:l.x-r/2-.45,y:l.y-.15},{x:l.x-r/2-.3,y:l.y}],stroke_width:.05,pcb_silkscreen_path_id:"pin_marker_1"},u=mi(0,o/2+.4,.25),h={type:"pcb_courtyard_outline",pcb_courtyard_outline_id:"",pcb_component_id:"",outline:hDo,layer:"top"};return{circuitJson:[...a,A,c,u,g,h],parameters:e}},k6t=(t,e,n,o)=>t<=3?{x:-.84,y:n-(t-1)*n}:{x:.84,y:-n+(t-4)*n},pDo=[{x:-.75,y:1},{x:-.75,y:-1},{x:.75,y:-1},{x:.75,y:1}],IDo=ui.extend({fn:F(),num_pins:De(6).default(6),w:F().default("1.01mm"),h:F().default("1.45mm"),p:F().default("0.5mm"),pl:F().default("0.33mm"),pw:F().default("0.27mm"),string:F().optional()}),fDo=t=>{const e=IDo.parse({...t,fn:"sot886"}),n=le.parse(e.w),o=le.parse(e.h),i=le.parse(e.p),r=le.parse(e.pl),s=le.parse(e.pw),a=[];for(let d=0;d<6;d++){const{x:_,y:m}=F6t(d+1,n,i,r);a.push(Go(d+1,_,m,r,s))}const A={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-n/2,y:o/2},{x:n/2,y:o/2}],stroke_width:.05,pcb_silkscreen_path_id:""},c={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-n/2,y:-o/2},{x:n/2,y:-o/2}],stroke_width:.05,pcb_silkscreen_path_id:""},l=F6t(1,n,i,r),g={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"pin_marker_1",route:[{x:l.x-r/2-.3,y:l.y},{x:l.x-r/2-.45,y:l.y+.15},{x:l.x-r/2-.45,y:l.y-.15},{x:l.x-r/2-.3,y:l.y}],stroke_width:.05,pcb_silkscreen_path_id:"pin_marker_1"},u=mi(0,o/2+.4,.25),h={type:"pcb_courtyard_outline",pcb_courtyard_outline_id:"",pcb_component_id:"",outline:pDo,layer:"top"};return{circuitJson:[...a,A,c,u,g,h],parameters:e}},F6t=(t,e,n,o)=>{const i=e/2-o/2;return t<=3?{x:-i,y:n-(t-1)*n}:{x:i,y:-n+(t-4)*n}},CDo=[{x:-2.05,y:1.5},{x:-1.05,y:1.5},{x:-1.05,y:1.7},{x:1.05,y:1.7},{x:1.05,y:.55},{x:2.05,y:.55},{x:2.05,y:-.55},{x:1.05,y:-.55},{x:1.05,y:-1.7},{x:-1.05,y:-1.7},{x:-1.05,y:-1.5},{x:-2.05,y:-1.5},{x:-2.05,y:-.39},{x:-1.05,y:-.39},{x:-1.05,y:.39},{x:-2.05,y:.39}],yDo=[{x:-2.05,y:1.5},{x:-1.05,y:1.5},{x:-1.05,y:1.7},{x:1.05,y:1.7},{x:1.05,y:1.5},{x:2.05,y:1.5},{x:2.05,y:.39},{x:1.05,y:.39},{x:1.05,y:-.39},{x:2.05,y:-.39},{x:2.05,y:-1.5},{x:1.05,y:-1.5},{x:1.05,y:-1.7},{x:-1.05,y:-1.7},{x:-1.05,y:-1.5},{x:-2.05,y:-1.5}],L6t=ui.extend({fn:F(),num_pins:Ue().default(3),w:F().default("1.92mm"),h:F().default("2.74mm"),pl:F().default("1.325mm"),pw:F().default("0.6mm"),p:F().default("0.95mm"),string:F().optional()}),EDo=v6({p:"0.95mm",w:"1.6mm",legsoutside:!0}),xDo=t=>{const e=t.string?.match(/^sot23_(\d+)/),n=e?Number.parseInt(e[1],10):3;if(n===6||n===8){const i=EDo.parse({...t,num_pins:n});return{circuitJson:zU(i),parameters:i}}const o=L6t.parse({...t,num_pins:n});if(o.num_pins===3)return{circuitJson:QDo(o),parameters:o};if(o.num_pins===5)return{circuitJson:G6t(o),parameters:o};throw new Error("Invalid number of pins")},BDo=t=>{const{pn:e,p:n}=t;return e===1?{x:-1.1375,y:n}:e===2?{x:-1.1375,y:-n}:{x:1.1375,y:0}},QDo=t=>{const e=[];for(let i=0;i<t.num_pins;i++){const{x:r,y:s}=BDo({num_pins:t.num_pins,pn:i+1,w:Number.parseFloat(t.w),h:Number.parseFloat(t.h),pl:Number.parseFloat(t.pl),p:Number.parseFloat(t.p)});e.push(Go(i+1,r,s,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}const n=mi(0,Number.parseInt(t.h),.3),o={type:"pcb_courtyard_outline",pcb_courtyard_outline_id:"",pcb_component_id:"",outline:CDo,layer:"top"};return[...e,n,o]},H6t=t=>{const{p:e,h:n,pn:o}=t;if(o===1)return{x:-1.1375,y:e};if(o===2)return{x:-1.1375,y:0};if(o===3)return{x:-1.1375,y:-e};if(o===4)return{x:1.1375,y:-e};if(o===5)return{x:1.1375,y:e};throw new Error("Invalid pin number")},G6t=t=>{const e=[];for(let u=1;u<=t.num_pins;u++){const{x:h,y:d}=H6t({h:Number.parseFloat(t.h),p:Number.parseFloat(t.p),pn:u});e.push(Go(u,h,d,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}const n=(t.num_pins+1)/2*Number.parseFloat(t.p),o=Number.parseFloat(t.h),i={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-n/3,y:o/2+Number.parseFloat(t.p)/1.3},{x:n/3,y:o/2+Number.parseFloat(t.p)/1.3}],type:"pcb_silkscreen_path",stroke_width:.05},r={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_2",route:[{x:-n/3,y:-o/2-Number.parseFloat(t.p)/1.3},{x:n/3,y:-o/2-Number.parseFloat(t.p)/1.3}],type:"pcb_silkscreen_path",stroke_width:.05},s=mi(0,o+.3,.3),a=H6t({h:Number.parseFloat(t.h),p:Number.parseFloat(t.p),pn:1});a.x=a.x-Number.parseFloat(t.pw)*1.5;const A=.3,c=.4,l={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"pin1_indicator",route:[{x:a.x+A/2,y:a.y},{x:a.x-A/2,y:a.y+c/2},{x:a.x-A/2,y:a.y-c/2},{x:a.x+A/2,y:a.y}],stroke_width:.05},g={type:"pcb_courtyard_outline",pcb_courtyard_outline_id:"",pcb_component_id:"",outline:yDo,layer:"top"};return[...e,s,i,r,l,g]},SDo=L6t.extend({}),bDo=t=>{const e=SDo.parse({...t,num_pins:5});return{circuitJson:G6t(e),parameters:e}},DDo=[{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}],vDo=v6({}),PDo=t=>{const e=vDo.parse(t),n=[];for(let m=0;m<e.num_pins;m++){const{x:p,y:I}=t3e({num_pins:e.num_pins,pn:m+1,w:e.w,p:e.p??1.27,pl:e.pl,widthincludeslegs:!0});n.push(Go(m+1,p,I,e.pl??"1mm",e.pw??"0.6mm"))}const o=Math.min(1,e.p/2),i=e.w+o,r=(e.num_pins/2-1)*e.p+e.pw+o,s=[];for(const m of DDo){const{dx:p,dy:I}=m;s.push({layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"",route:[{x:p*i/2-p*e.p,y:I*r/2},{x:p*i/2,y:I*r/2},{x:p*i/2,y:I*r/2-I*e.p}],type:"pcb_silkscreen_path",stroke_width:.1})}const a=e.p/4,A=-i/2-a/2,c=r/2-e.p/2;s.push({layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"",type:"pcb_silkscreen_path",route:[{x:A,y:c},{x:A-a,y:c+a},{x:A-a,y:c-a},{x:A,y:c}],stroke_width:.1});const l=mi(0,r/2+.4,r/12),g=m=>Math.ceil(m/.05)*.05,u=(e.num_pins/2-1)*e.p+e.pw,h=g(e.w/2+.25),d=g(u/2+.45),_={type:"pcb_courtyard_rect",pcb_courtyard_rect_id:"",pcb_component_id:"",center:{x:0,y:0},width:h*2,height:d*2,layer:"top"};return{circuitJson:[...n,l,...s,_],parameters:e}},P6=({fs:t,pn:e,anchor_x:n,anchor_y:o,textalign:i="center",orthogonal:r=!1,verticallyinverted:s=!1,layer:a="top"})=>{let A=0;r&&s?A=270:s?A=180:r?A=90:A=0;let c="center";return i==="left"&&(s?c="center_right":c="center_left"),i==="right"&&(s?c="center_left":c="center_right"),a==="bottom"&&(c==="center_left"?c="center_right":c==="center_right"&&(c="center_left")),{type:"pcb_silkscreen_text",pcb_silkscreen_text_id:"silkscreen_text_1",font:"tscircuit2024",font_size:t,pcb_component_id:"pcb_component_1",text:`{PIN${e}}`,layer:a,anchor_position:{x:n,y:o},anchor_alignment:c,ccw_rotation:A}};function O6t({pinlabeltextalignleft:t,pinlabeltextalignright:e,pinlabelorthogonal:n}){let o="top";return n?o="left":o="top",t&&(n?o="bottom":o="right"),e&&(n?o="top":o="left"),o}var wDo=ui.extend({fn:F(),num_pins:Ue().optional().default(6),rows:Rn([F(),Ue()]).transform(t=>Number(t)).optional().default(1).describe("number of rows"),p:le.default("0.1in").describe("pitch"),id:le.default("1.0mm").describe("inner diameter"),od:le.default("1.5mm").describe("outer diameter"),male:Fe().optional().describe("for male pin headers"),female:Fe().optional().describe("for female pin headers"),smd:Fe().optional().describe("surface mount device"),surfacemount:Fe().optional().describe("surface mount device (verbose)"),rightangle:Fe().optional().describe("right angle"),pw:le.optional().default("1.0mm").describe("pad width for SMD"),pl:le.optional().default("2.0mm").describe("pad length for SMD"),pinlabeltextalignleft:Fe().optional().default(!1),pinlabeltextaligncenter:Fe().optional().default(!1),pinlabeltextalignright:Fe().optional().default(!1),pinlabelverticallyinverted:Fe().optional().default(!1),pinlabelorthogonal:Fe().optional().default(!1),nosquareplating:Fe().optional().default(!1).describe("do not use rectangular pad for pin 1"),nopinlabels:Fe().optional().default(!1).describe("omit silkscreen pin labels"),doublesidedpinlabel:Fe().optional().default(!1).describe("add silkscreen pins in top and bottom layers"),bottomsidepinlabel:Fe().optional().default(!1).describe("place the silkscreen reference text on the bottom layer instead of top")}).transform(t=>{const e=O6t(t);return{...t,pinlabelAnchorSide:e,male:t.male??!t.female,female:t.female??!1,smd:t.smd??t.surfacemount??!1,rightangle:t.rightangle??!1}}).superRefine((t,e)=>{t.male&&t.female&&e.addIssue({code:Nn.custom,message:"'male' and 'female' cannot both be true; it should be male or female.",path:["male","female"]})}),MDo=t=>{const e=wDo.parse(t),{p:n,id:o,od:i,rows:r,num_pins:s,pinlabelAnchorSide:a,pinlabelverticallyinverted:A,pinlabelorthogonal:c,pinlabeltextalignleft:l,pinlabeltextalignright:g,nopinlabels:u,doublesidedpinlabel:h,bottomsidepinlabel:d}=e;let _="center";l?_="left":g&&(_="right");const m=[],p=Math.ceil(s/r),I=(r-1)*n,f=I/2,C=-n,y=({xoff:ie,yoff:$,od:Z,anchorSide:se,smd:ae,pw:ce,pl:fe})=>{let Ce=0,xe=0;if(ae){const de=Z/5;switch(se){case"right":Ce=ce/2+de;break;case"top":xe=fe/2+de;break;case"bottom":xe=-(fe/2+de);break;case"left":Ce=-(ce/2+de);break}}else{const de=Z*.75;switch(se){case"right":Ce=de;break;case"top":xe=de;break;case"bottom":xe=-de;break;case"left":Ce=-de;break}}return{anchor_x:ie+Ce,anchor_y:$+xe}},E=(ie,$,Z)=>{e.smd?m.push(Go(ie,$,Z,e.pw,e.pl)):ie===1&&!e.nosquareplating?m.push(vy({pn:ie,x:$,y:Z,holeDiameter:o,rectPadWidth:i,rectPadHeight:i})):m.push(qs(ie,$,Z,o,i));const{anchor_x:se,anchor_y:ae}=y({xoff:$,yoff:Z,od:i,anchorSide:a,smd:e.smd,pw:e.pw,pl:e.pl});u||(d?m.push(P6({fs:i/5,pn:ie,anchor_x:se,anchor_y:ae,textalign:_,orthogonal:c,verticallyinverted:A,layer:"bottom"})):m.push(P6({fs:i/5,pn:ie,anchor_x:se,anchor_y:ae,textalign:_,orthogonal:c,verticallyinverted:A,layer:"top"})),h&&m.push(P6({fs:i/5,pn:ie,anchor_x:se,anchor_y:ae,textalign:_,orthogonal:c,verticallyinverted:A,layer:"bottom"})))},B=new Set,Q=r>2&&p>2;if(r===1){const ie=-((s-1)/2)*n;for(let $=0;$<s;$++){const Z=$+1,se=ie+$*n,ae=`${se},0`;if(B.has(ae))throw new Error(`Overlap at ${ae}`);B.add(ae),E(Z,se,0)}}else if(Q){const ie=-((p-1)/2)*n;let $=1;for(let Z=0;Z<r&&$<=s;Z++)for(let se=0;se<p&&$<=s;se++){const ae=ie+se*n,ce=f+Z*C,fe=`${ae},${ce}`;if(B.has(fe))throw new Error(`Overlap at ${fe}`);B.add(fe),E($++,ae,ce)}}else{const ie=-((p-1)/2)*n;let $=1,Z=0,se=r-1,ae=0,ce=p-1;for(;$<=s&&Z<=se&&ae<=ce;){for(let fe=Z;fe<=se&&$<=s;fe++){const Ce=ie+ae*n,xe=f+fe*C,de=`${Ce},${xe}`;if(B.has(de))throw new Error(`Overlap at ${de}`);B.add(de),E($++,Ce,xe)}ae++;for(let fe=ae;fe<=ce&&$<=s;fe++){const Ce=ie+fe*n,xe=f+se*C,de=`${Ce},${xe}`;if(B.has(de))throw new Error(`Overlap at ${de}`);B.add(de),E($++,Ce,xe)}if(se--,ae<=ce){for(let fe=se;fe>=Z&&$<=s;fe--){const Ce=ie+ce*n,xe=f+fe*C,de=`${Ce},${xe}`;if(B.has(de))throw new Error(`Overlap at ${de}`);B.add(de),E($++,Ce,xe)}ce--}if(Z<=se){for(let fe=ce;fe>=ae&&$<=s;fe--){const Ce=ie+fe*n,xe=f+Z*C,de=`${Ce},${xe}`;if(B.has(de))throw new Error(`Overlap at ${de}`);B.add(de),E($++,Ce,xe)}Z++}}if($-1<s)throw new Error(`Missing pins: assigned ${$-1}, expected ${s}`)}const b=mi(0,I/2+n,.5),D=e.smd?e.pw/2:i/2,R=e.smd?e.pl/2:i/2,M=(p-1)*n,L=M/2+D,G=I/2+R,O=M/2+n/2,U=I/2+n/2,W=Math.max(L+.25,O+.5),j=Math.max(G+.25,U+.5),te={type:"pcb_courtyard_rect",pcb_courtyard_rect_id:"",pcb_component_id:"",center:{x:0,y:0},width:2*W,height:2*j,layer:"top"};return{circuitJson:[...m,b,te],parameters:e}},NDo=[{x:-1.2,y:.83},{x:-.75,y:.83},{x:-.75,y:.95},{x:.75,y:.95},{x:.75,y:.83},{x:1.2,y:.83},{x:1.2,y:-.83},{x:.75,y:-.83},{x:.75,y:-.95},{x:-.75,y:-.95},{x:-.75,y:-.83},{x:-1.2,y:-.83}],RDo=ui.extend({fn:F(),num_pins:De(6).default(6),w:F().default("2.1mm"),h:F().default("2.45mm"),p:F().default("0.5mm"),pl:F().default("0.675mm"),pw:F().default("0.35mm"),string:F().optional()}),TDo=t=>{const e=RDo.parse({...t,fn:"sot563"}),n=le.parse(e.w),o=le.parse(e.h),i=le.parse(e.p),r=le.parse(e.pl),s=le.parse(e.pw),a=[];for(let d=0;d<6;d++){const{x:_,y:m}=K6t(d+1,n,i,r);a.push(Go(d+1,_,m,r,s))}const A={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-n/2,y:o/2},{x:n/2,y:o/2}],stroke_width:.05,pcb_silkscreen_path_id:""},c={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-n/2,y:-o/2},{x:n/2,y:-o/2}],stroke_width:.05,pcb_silkscreen_path_id:""},l=K6t(1,n,i,r),g={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"pin_marker_1",route:[{x:l.x-r/2-.3,y:l.y},{x:l.x-r/2-.45,y:l.y+.15},{x:l.x-r/2-.45,y:l.y-.15},{x:l.x-r/2-.3,y:l.y}],stroke_width:.05,pcb_silkscreen_path_id:"pin_marker_1"},u=mi(0,o/2+.4,.25),h={type:"pcb_courtyard_outline",pcb_courtyard_outline_id:"",pcb_component_id:"",outline:NDo,layer:"top"};return{circuitJson:[...a,A,c,u,g,h],parameters:e}},K6t=(t,e,n,o)=>{const i=e/2-o/2;return t<=3?{x:-i,y:n-(t-1)*n}:{x:i,y:-n+(t-4)*n}},kDo=v6({p:"1.27mm",w:"3.9mm",legsoutside:!0}),FDo=t=>{const e=kDo.parse({...t,num_pins:8});return{circuitJson:zU(e),parameters:e}},LDo=v6({p:"1.27mm",w:"7.5mm",legsoutside:!0}),HDo=t=>{const e=LDo.parse({...t,num_pins:16});return{circuitJson:zU(e),parameters:e}},GDo=ui.extend({fn:F(),num_pins:De(3).default(3),w:F().default("1.2mm"),h:F().default("1.2mm"),pw:F().default("0.40mm"),pl:F().default("0.45mm"),p:F().default("0.575mm")}),ODo=t=>{const e=GDo.parse(t),n=UDo(e),o=mi(0,le.parse(e.h),.2),i=1.8,r=1.8,s={type:"pcb_courtyard_outline",pcb_courtyard_outline_id:"",pcb_component_id:"",outline:[{x:-i/2,y:r/2},{x:i/2,y:r/2},{x:i/2,y:-r/2},{x:-i/2,y:-r/2}],layer:"top"};return{circuitJson:[...n,o,s],parameters:e}},KDo=t=>{const{pn:e,p:n}=t;return e===1?{x:n,y:0}:e===2?{x:-n,y:-.4}:{x:-n,y:.4}},UDo=t=>{const e=[];for(let n=0;n<3;n++){const{x:o,y:i}=KDo({num_pins:t.num_pins,pn:n+1,w:Number.parseFloat(t.w),h:Number.parseFloat(t.h),pl:Number.parseFloat(t.pl),p:Number.parseFloat(t.p)});e.push(Go(n+1,o,i,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return e},Vf=t=>{const e=t.p??t.pad_spacing;if(e===void 0||t.pl===void 0||t.pw===void 0)throw new Error("Diode fabrication note requires p or pad_spacing, pl, and pw");const n=le.parse(e),o=le.parse(t.pl),i=le.parse(t.pw);return YDo({minX:-n/2-o/2,maxX:n/2+o/2,minY:-i/2,maxY:i/2})},YDo=t=>{const e=[],n=t.maxX-t.minX,o=t.maxY-t.minY,i=(t.minX+t.maxX)/2,r=(t.minY+t.maxY)/2,s=o*.28,a=s*2,A=n*.2,l=Math.min(A,a*1.25),g=i-l/2,u=i+l/2,h=l*.18,d=g+h,_=u-h,m=Math.max(Math.min(n,o)*.035,.01),p=Math.max(Math.min(n,o)*.25,.1);return e.push({type:"pcb_fabrication_note_path",pcb_fabrication_note_path_id:"diode_fabrication_note_anode_leg",pcb_component_id:"",layer:"top",stroke_width:m,route:[{x:g,y:r},{x:d,y:r}]},{type:"pcb_fabrication_note_path",pcb_fabrication_note_path_id:"diode_fabrication_note_triangle",pcb_component_id:"",layer:"top",stroke_width:m,route:[{x:d,y:r+s},{x:_,y:r},{x:d,y:r-s},{x:d,y:r+s}]},{type:"pcb_fabrication_note_path",pcb_fabrication_note_path_id:"diode_fabrication_note_cathode",pcb_component_id:"",layer:"top",stroke_width:m,route:[{x:_,y:r+s},{x:_,y:r-s}]},{type:"pcb_fabrication_note_path",pcb_fabrication_note_path_id:"diode_fabrication_note_cathode_leg",pcb_component_id:"",layer:"top",stroke_width:m,route:[{x:_,y:r},{x:u,y:r}]},{type:"pcb_fabrication_note_text",pcb_fabrication_note_text_id:"diode_fabrication_note_positive",pcb_component_id:"",layer:"top",font:"tscircuit2024",font_size:p,text:"+",anchor_position:{x:t.minX+n*.125,y:r},anchor_alignment:"center"},{type:"pcb_fabrication_note_text",pcb_fabrication_note_text_id:"diode_fabrication_note_negative",pcb_component_id:"",layer:"top",font:"tscircuit2024",font_size:p,text:"-",anchor_position:{x:t.maxX-n*.125,y:r},anchor_alignment:"center"}),e},zDo=ui.extend({fn:F(),num_pins:De(2).default(2),w:F().default("2.36mm"),h:F().default("1.22mm"),pl:F().default("0.9mm"),pw:F().default("1.2mm"),p:F().default("3.30mm")}),VDo=t=>{const e=zDo.parse(t),n=le.parse(e.h),o=mi(0,n/4+.4,.3),s={type:"pcb_courtyard_rect",pcb_courtyard_rect_id:"",pcb_component_id:"",center:{x:0,y:0},width:4.7,height:2.3,layer:"top"};return{circuitJson:qDo(e).concat(...Vf(e),o,s),parameters:e}},JDo=t=>{const{pn:e,p:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},qDo=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:o,y:i}=JDo({pn:n,p:Number.parseFloat(t.p)});e.push(Go(n,o,i,Number.parseFloat(t.pl),Number.parseFloat(t.pw),.1125))}return e},WDo=ui.extend({fn:F(),p:le.optional().default("2.54mm"),id:le.optional().default("0.7mm"),od:le.optional().default("1.4mm")}),jDo=t=>{const e=WDo.parse(t),{p:n,id:o,od:i}=e,r=[qs(1,-n/2,0,o,i),qs(2,n/2,0,o,i)],s={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-n/2+i+o/2,y:0},{x:n/2-i-o/2,y:0}],stroke_width:.1,pcb_silkscreen_path_id:""},a=mi(0,1.5,.5),A=-n/2,c=n/2,l=i/2,g=i/2,u=A-l-.35,h=c+l+.26,d=g+.35,_=u,m=h,p=d,I={type:"pcb_courtyard_outline",pcb_courtyard_outline_id:"",pcb_component_id:"",outline:n1([{minX:u,maxX:h,minY:-p,maxY:p},{minX:_,maxX:m,minY:-d,maxY:d}]),layer:"top"};return{circuitJson:[...r,s,a,I],parameters:e}},XDo=(t,e,n,o,i,r=.1)=>{const s=[],a=[],A=Math.max(1,Math.ceil(Math.PI*n/r)),c=Math.PI/A;for(let l=0;l<=A;l++){const g=l*c,u=t+Math.cos(g)*n,h=e+Math.sin(g)*n;u<t-o&&h>=e-i/2&&h<=e+i/2||s.push({x:u,y:h})}for(let l=0;l<=A;l++){const g=Math.PI+l*c,u=t+Math.cos(g)*n,h=e+Math.sin(g)*n;u<t-o&&h>=e-i/2&&h<=e+i/2||a.push({x:u,y:h})}return{topArc:s,bottomArc:a}},$Do=ui.extend({fn:F(),p:le.optional().default("5mm"),id:le.optional().default("0.8mm"),od:le.optional().default("1.6mm"),ceramic:Fe().optional(),electrolytic:Fe().optional(),polarized:Fe().optional()}),ZDo=t=>{const e=$Do.parse(t),{p:n,id:o,od:i}=e;o===.8&&i===1.6&&(e.id=n===5?.8:n*.25,e.od=n===5?1.6:n*.5);const r=[qs(1,-n/2,0,e.id,e.od),qs(2,n/2,0,e.id,e.od)],s=n+.1,{topArc:a,bottomArc:A}=XDo(0,0,s,e.od/2,e.od),c=.02*n,l={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:a,stroke_width:c,pcb_silkscreen_path_id:""},g={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:A,stroke_width:c,pcb_silkscreen_path_id:""},u={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:0,y:s},{x:0,y:-s}],stroke_width:c,pcb_silkscreen_path_id:""},h=.1*n,d=-(n+h+.04*n),_=s-h-.08*n,m={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:d-h,y:_},{x:d+h,y:_}],stroke_width:c,pcb_silkscreen_path_id:""},p={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:d,y:_-h},{x:d,y:_+h}],stroke_width:c,pcb_silkscreen_path_id:""},I=mi(0,s+.12*n,.1*n),f=[...r,l,g,u,I];(e.electrolytic===!0||e.polarized===!0)&&f.push(m,p);const y=n+.25,E={type:"pcb_courtyard_circle",pcb_courtyard_circle_id:"",pcb_component_id:"",center:{x:0,y:0},radius:y,layer:"top"};return f.push(E),{circuitJson:f,parameters:e}},w6=(t,e={})=>({type:"pcb_silkscreen_path",layer:e.layer||"top",pcb_component_id:e.pcb_component_id||"",pcb_silkscreen_path_id:e.pcb_silkscreen_path_id||"",route:t,stroke_width:e.stroke_width||.1}),evo=ui.extend({fn:De("pushbutton"),w:le.default(4.5),h:le.default(6.5),id:le.default(1),od:le.default(1.2)}),tvo=t=>{const e=evo.parse(t),n=e.w,o=e.h,i=e.id,r=[qs(1,-n/2,o/2,i,i*1.5),qs(2,-n/2,-o/2,i,i*1.5),qs(3,n/2,-o/2,i,i*1.5),qs(4,n/2,o/2,i,i*1.5)],s=[w6([{x:-n/2,y:-o/2},{x:-n/2,y:o/2}]),w6([{x:n/2,y:-o/2},{x:n/2,y:o/2}]),w6([{x:-n/2,y:0},{x:-n/5,y:0},{x:n/5*1/Math.sqrt(2),y:o/8}]),w6([{x:n/2,y:0},{x:n/5,y:0}])],a=mi(0,o/2+.4,.5),A=i*1.5/2,c=n,l=o,g=c/2+A,u=l/2+A,h=g+.5,d=u+.5,_={type:"pcb_courtyard_rect",pcb_courtyard_rect_id:"",pcb_component_id:"",center:{x:0,y:0},width:2*h,height:2*d,layer:"top"};return{circuitJson:[...r,...s,a,_],parameters:e}},U6t=ui.extend({fn:F(),w:le.default("22.58mm"),h:le.optional(),left:le.optional().default(20),right:le.optional().default(20),top:le.optional().default(2),bottom:le.optional().default(2),p:le.default(le.parse("2.54mm")),pw:le.default(le.parse("1.6mm")),pl:le.default(le.parse("2.4mm")),innerhole:Fe().default(!1),innerholeedgedistance:le.default(le.parse("1.61mm")),silkscreenlabels:Fe().default(!1),silkscreenlabelmargin:le.default(le.parse("0.1mm"))}),nvo=t=>{const e=U6t.parse(t);return e.left&&e.right?Math.max(e.left,e.right)*e.p:e.left?e.left*e.p:e.right?e.right*e.p:51},ere=(t,e,n)=>{let o=[];return n==="right"&&(o=[{x:t+1/2,y:e},{x:t-1/2,y:e+.6/2},{x:t-1/2,y:e-.6/2},{x:t+1/2,y:e}]),n==="left"&&(o=[{x:t-1/2,y:e},{x:t+1/2,y:e+.6/2},{x:t+1/2,y:e-.6/2},{x:t-1/2,y:e}]),n==="top"&&(o=[{x:t,y:e+1/2},{x:t-.6/2,y:e-1/2},{x:t+.6/2,y:e-1/2},{x:t,y:e+1/2}]),n==="bottom"&&(o=[{x:t,y:e-1/2},{x:t-.6/2,y:e+1/2},{x:t+.6/2,y:e+1/2},{x:t,y:e-1/2}]),o},ovo=t=>{const e=U6t.parse(t),n=e.h??nvo(e),o=[],i=[],r=[];let s=[];const a=1,A=a,c=e.left+e.right+(e.bottom??0)+(e.top??0),g=`pin${c}`.length*.7/2;if(e.right){const _=-((e.right-1)/2)*e.p;for(let m=0;m<e.right;m++){if(m===0&&!e.left&&!e.bottom&&!e.silkscreenlabels&&(s=ere(e.w/2-e.pl*1.4,_+m*e.p,"right")),o.push(Go(m+1+e.left+(e.bottom??0),e.w/2-e.pl/2,_+m*e.p,e.pl,e.pw)),e.silkscreenlabels){const p=m+1+e.left+(e.bottom??0),I=`pin${p}`;r.push({type:"pcb_silkscreen_text",pcb_silkscreen_text_id:`pin_${p}`,pcb_component_id:"1",layer:"top",anchor_position:{x:e.w/2-e.pl-(g+e.silkscreenlabelmargin),y:_+m*e.p},text:I,font_size:.7,font:"tscircuit2024",anchor_alignment:"center"})}e.innerhole&&(i.push(qs(m+1+e.left+(e.bottom??0)+c,e.w/2,_+m*e.p,a,A)),i.push(qs(m+1+e.left+(e.bottom??0)+c*2,e.w/2-e.innerholeedgedistance,_+m*e.p,a,A)))}}if(e.left){const _=(e.left-1)/2*e.p;for(let m=0;m<e.left;m++){if(m===0&&!e.silkscreenlabels&&(s=ere(-e.w/2+e.pl*1.4,_-m*e.p,"left")),o.push(Go(m+1,-e.w/2+e.pl/2,_-m*e.p,e.pl,e.pw)),e.silkscreenlabels){const p=m+1,I=`pin${p}`;r.push({type:"pcb_silkscreen_text",pcb_silkscreen_text_id:`pin_${p}`,pcb_component_id:"1",layer:"top",anchor_position:{x:-e.w/2+e.pl+(g+e.silkscreenlabelmargin),y:_-m*e.p},text:I,font_size:.7,font:"tscircuit2024",anchor_alignment:"center"})}e.innerhole&&(i.push(qs(m+1+c,-e.w/2,_-m*e.p,a,A)),i.push(qs(m+1+c*2,-e.w/2+e.innerholeedgedistance,_-m*e.p,a,A)))}}if(e.top){const _=(e.top-1)/2*e.p;for(let m=0;m<e.top;m++){if(m===0&&!e.left&&!e.bottom&&!e.right&&!e.silkscreenlabels&&(s=ere(_-m*e.p,n/2-e.pl*1.4,"top")),o.push(Go(m+1+e.left+e.right+(e.bottom??0),_-m*e.p,n/2-e.pl/2,e.pw,e.pl)),e.silkscreenlabels){const p=m+1+e.left+e.right+(e.bottom??0),I=`pin${p}`;r.push({type:"pcb_silkscreen_text",pcb_silkscreen_text_id:`pin_${p}`,pcb_component_id:"1",layer:"top",anchor_position:{x:_-m*e.p,y:n/2-e.pl-(g+e.silkscreenlabelmargin)},text:I,font_size:.7,font:"tscircuit2024",anchor_alignment:"center",ccw_rotation:270})}e.innerhole&&(i.push(qs(m+1+e.left+e.right+(e.bottom??0)+c,_-m*e.p,n/2,a,A)),i.push(qs(m+1+e.left+e.right+(e.bottom??0)+c*2,_-m*e.p,n/2-e.innerholeedgedistance,a,A)))}}if(e.bottom){const _=-((e.bottom-1)/2)*e.p;for(let m=0;m<e.bottom;m++){if(m===0&&!e.left&&!e.silkscreenlabels&&(s=ere(_+m*e.p,-n/2+e.pl*1.4,"bottom")),o.push(Go(m+1+e.left,_+m*e.p,-n/2+e.pl/2,e.pw,e.pl)),e.silkscreenlabels){const p=m+1+e.left,I=`pin${p}`;r.push({type:"pcb_silkscreen_text",pcb_silkscreen_text_id:`pin_${p}`,pcb_component_id:"1",layer:"top",anchor_position:{x:_+m*e.p,y:-n/2+e.pl+(g+e.silkscreenlabelmargin)},text:I,font_size:.7,font:"tscircuit2024",anchor_alignment:"center",ccw_rotation:90})}e.innerhole&&(i.push(qs(m+1+e.left+c,_+m*e.p,-n/2,a,A)),i.push(qs(m+1+e.left+c*2,_+m*e.p,-n/2+e.innerholeedgedistance,a,A)))}}const u={type:"pcb_silkscreen_path",pcb_silkscreen_path_id:"pcb_silkscreen_triangle_1",pcb_component_id:"2",route:s,stroke_width:.1,layer:"top"},h={type:"pcb_silkscreen_path",pcb_silkscreen_path_id:"pcb_silkscreen_path_1",pcb_component_id:"1",route:[{x:-e.w/2,y:n/2},{x:e.w/2,y:n/2},{x:e.w/2,y:-n/2},{x:-e.w/2,y:-n/2},{x:-e.w/2,y:n/2}],stroke_width:.1,layer:"top"},d=mi(0,n/1.8,n/25);return{circuitJson:[...o,...i,...r,h,...e.silkscreenlabels?[]:[u],d],parameters:e}},Y6t=ui.extend({fn:F(),w:le.default("22.58mm"),h:le.optional(),left:le.optional().default(20),right:le.optional().default(20),top:le.optional().default(2),bottom:le.optional().default(2),p:le.default(le.parse("2.54mm")),pw:le.default(le.parse("1.6mm")),pl:le.default(le.parse("3.2mm")),innerhole:Fe().default(!1),innerholeedgedistance:le.default(le.parse("1.61mm"))}),ivo=t=>{const e=Y6t.parse(t);return e.left&&e.right?Math.max(e.left,e.right)*e.p:e.left?e.left*e.p:e.right?e.right*e.p:51},rvo=(t,e,n,o=1,i=.6)=>{const r=o/2,s=i/2;return{left:[{x:t+r,y:e},{x:t-r,y:e+s},{x:t-r,y:e-s},{x:t+r,y:e}],right:[{x:t-r,y:e},{x:t+r,y:e+s},{x:t+r,y:e-s},{x:t-r,y:e}],top:[{x:t,y:e-r},{x:t-s,y:e+r},{x:t+s,y:e+r},{x:t,y:e-r}],bottom:[{x:t,y:e+r},{x:t-s,y:e-r},{x:t+s,y:e-r},{x:t,y:e+r}]}[n]},svo=t=>{const e=Y6t.parse(t),n=e.h??ivo(e),o=[],i=[],r=[],s=1,a=1.2,A=e.left+e.right+(e.bottom??0)+(e.top??0);let c=[],l=1;if(e.left){const d=(e.left-1)/2*e.p;for(let _=0;_<e.left;_++)_===0&&(c=rvo(-e.w/2-e.pl/2,d-_*e.p,"left")),o.push(Go(l,-e.w/2+e.pl/2,d-_*e.p,e.pl,e.pw)),i.push({type:"pcb_silkscreen_text",pcb_silkscreen_text_id:`pin_${l}`,pcb_component_id:"1",layer:"top",anchor_position:{x:-e.w/2+e.pl/2-4.5,y:d-_*e.p},text:`pin${l}`,font_size:.7,font:"tscircuit2024",anchor_alignment:"center"}),l++,e.innerhole&&r.push(qs(l+A,-e.w/2+e.innerholeedgedistance,d-_*e.p,s,a))}if(e.bottom){const d=(e.bottom-1)/2*e.p;for(let _=e.bottom-1;_>=0;_--)o.push(Go(l,d-_*e.p,-n/2+e.pl/2,e.pw,e.pl)),i.push({type:"pcb_silkscreen_text",pcb_silkscreen_text_id:`pin_${l}`,pcb_component_id:"1",layer:"top",anchor_position:{x:d-_*e.p,y:-n/2+e.pl/2-3.2},text:`pin${l}`,font_size:.7,font:"tscircuit2024",anchor_alignment:"center"}),l++,e.innerhole&&r.push(qs(l+A,d-_*e.p,-n/2+e.innerholeedgedistance,s,a))}if(e.right){const d=-((e.right-1)/2)*e.p;for(let _=0;_<e.right;_++)o.push(Go(l,e.w/2-e.pl/2,d+_*e.p,e.pl,e.pw)),i.push({type:"pcb_silkscreen_text",pcb_silkscreen_text_id:`pin_${l}`,pcb_component_id:"1",layer:"top",anchor_position:{x:e.w/2-e.pl/2+3.7,y:d+_*e.p},text:`pin${l}`,font_size:.7,font:"tscircuit2024",anchor_alignment:"center"}),l++,e.innerhole&&r.push(qs(l+A,e.w/2-e.innerholeedgedistance,d+_*e.p,s,a))}if(e.top){const d=-((e.top-1)/2)*e.p;for(let _=e.top-1;_>=0;_--)o.push(Go(l,d+_*e.p,n/2-e.pl/2,e.pw,e.pl)),i.push({type:"pcb_silkscreen_text",pcb_silkscreen_text_id:`pin_${l}`,pcb_component_id:"1",layer:"top",anchor_position:{x:d+_*e.p,y:n/2-e.pl/2+3.2},text:`pin${l}`,font_size:.7,font:"tscircuit2024",anchor_alignment:"center"}),l++,e.innerhole&&r.push(qs(l+A,d+_*e.p,n/2-e.innerholeedgedistance,s,a))}const g={type:"pcb_silkscreen_path",pcb_silkscreen_path_id:"1",pcb_component_id:"1",layer:"top",route:c,stroke_width:.1},u={type:"pcb_silkscreen_path",pcb_silkscreen_path_id:"pcb_silkscreen_path_1",pcb_component_id:"1",route:[{x:-e.w/2-e.pl/3,y:n/2+e.pl/3},{x:e.w/2+e.pl/3,y:n/2+e.pl/3},{x:e.w/2+e.pl/3,y:-n/2-e.pl/3},{x:-e.w/2-e.pl/3,y:-n/2-e.pl/3},{x:-e.w/2-e.pl/3,y:n/2+e.pl/3}],stroke_width:.1,layer:"top"},h=mi(0,n/1.8,n/25);return{circuitJson:[...r,...o,...i,u,g,h],parameters:e}},avo=t=>(t.legsoutside=!0,t.pl||(t.pl=1.5),t.pw||(t.pw=.3),qT(t)),z6t=ui.extend({fn:F(),w:le.default("10mm"),h:le.optional(),left:le.optional().default(20),right:le.optional().default(20),top:le.optional().default(0),bottom:le.optional().default(0),p:le.default(le.parse("2.54mm")),id:le.optional().default(le.parse("1mm")),od:le.optional().default(le.parse("1.5mm"))}),Avo=t=>{const e=z6t.parse(t);return e.left&&e.right?Math.max(e.left,e.right)*e.p:e.left?e.left*e.p:e.right?e.right*e.p:51},tre=(t,e,n,o=1,i=.6)=>{const r=o/2,s=i/2;return{left:[{x:t+r,y:e},{x:t-r,y:e+s},{x:t-r,y:e-s},{x:t+r,y:e}],right:[{x:t-r,y:e},{x:t+r,y:e+s},{x:t+r,y:e-s},{x:t-r,y:e}],top:[{x:t,y:e-r},{x:t-s,y:e+r},{x:t+s,y:e+r},{x:t,y:e-r}],bottom:[{x:t,y:e+r},{x:t-s,y:e-r},{x:t+s,y:e-r},{x:t,y:e+r}]}[n]},cvo=t=>{const e=z6t.parse(t),n=e.h??Avo(e),o=[],i=e.id,r=e.od;let s=[];if(e.right){const l=-((e.right-1)/2)*e.p;for(let g=0;g<e.right;g++)g===0&&!e.left&&!e.bottom&&(s=tre(e.w/2+r*1.4,l+g*e.p,"right")),o.push(qs(g+1+e.left+(e.bottom??0),e.w/2,l+g*e.p,i,r))}if(e.left){const l=-((e.left-1)/2)*e.p;for(let g=0;g<e.left;g++)g===e.left-1&&(s=tre(-e.w/2-r*1.4,l+g*e.p,"left")),o.push(qs(g+1,-e.w/2,l+g*e.p,i,r))}if(e.top){const l=-((e.top-1)/2)*e.p;for(let g=0;g<e.top;g++)g===e.top-1&&!e.left&&!e.bottom&&!e.right&&(s=tre(l+g*e.p,n/2+r*1.4,"top")),o.push(qs(g+1+e.right+(e.bottom??0)+e.left,l+g*e.p,n/2,i,r))}if(e.bottom){const l=-((e.bottom-1)/2)*e.p;for(let g=0;g<e.bottom;g++)g===0&&!e.left&&(s=tre(l+g*e.p,-n/2-r*1.4,"bottom")),o.push(qs(g+1+e.left,l+g*e.p,-n/2,i,r))}const a={type:"pcb_silkscreen_path",pcb_silkscreen_path_id:"1",pcb_component_id:"1",layer:"top",route:s,stroke_width:.1},A={type:"pcb_silkscreen_path",pcb_silkscreen_path_id:"pcb_silkscreen_path_1",pcb_component_id:"1",route:[{x:-e.w/2-r,y:n/2+r},{x:e.w/2+r,y:n/2+r},{x:e.w/2+r,y:-n/2-r},{x:-e.w/2-r,y:-n/2-r},{x:-e.w/2-r,y:n/2+r}],stroke_width:.1,layer:"top"},c=mi(0,n/1.7,n/25);return{circuitJson:[...o,A,c,a],parameters:e}},lvo=t=>{const{centerX:e,centerY:n,straightHalfLength:o,radius:i,arcSegmentCount:r=9,orientation:s="horizontal"}=t;if(o<0)throw new Error("Capsule straightHalfLength must be non-negative");if(i<=0)throw new Error("Capsule radius must be positive");if(r<2)throw new Error("Capsule arcSegmentCount must be at least 2");if(s==="horizontal"){const g=e-o,u=e+o,h=Array.from({length:r+1},(_,m)=>{const p=Math.PI/2-m*Math.PI/r;return{x:u+Math.cos(p)*i,y:n+Math.sin(p)*i}}),d=Array.from({length:r+1},(_,m)=>{const p=-Math.PI/2+m*Math.PI/r;return{x:g-Math.cos(p)*i,y:n+Math.sin(p)*i}});return[{x:g,y:n+i},{x:u,y:n+i},...h.slice(1,-1),{x:u,y:n-i},{x:g,y:n-i},...d.slice(1,-1)]}const a=n-o,A=n+o,c=Array.from({length:r+1},(g,u)=>{const h=Math.PI-u*Math.PI/r;return{x:e+Math.cos(h)*i,y:A+Math.sin(h)*i}}),l=Array.from({length:r+1},(g,u)=>{const h=u*Math.PI/r;return{x:e+Math.cos(h)*i,y:a-Math.sin(h)*i}});return[{x:e-i,y:a},{x:e-i,y:A},...c.slice(1,-1),{x:e+i,y:A},{x:e+i,y:a},...l.slice(1,-1)]},V6t=(t,e,n,o)=>Array.from({length:25},(i,r)=>{const s=r/24*Math.PI-Math.PI/2;return{x:t+(o==="right"?1:-1)*Math.cos(s)*n,y:e+Math.sin(s)*n}}),gvo=ui.extend({fn:F(),p:le.optional().default("4.88mm"),id:le.optional().default("0.8mm"),od:le.optional().default("1.5mm"),w:le.optional().default("5.6mm"),h:le.optional().default("3.5mm")}),uvo=t=>{const e=gvo.parse(t),{p:n,id:o,od:i,w:r,h:s}=e,a=s/2,A=[qs(1,-n/2,0,o,i),qs(2,n/2,0,o,i)],c=V6t(-r/2,0,a,"left"),l=V6t(r/2,0,a,"right"),g={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[...c,...c.slice(1).reverse(),{x:-r/2,y:-s/2},{x:r/2,y:-s/2},...l,{x:r/2,y:s/2},{x:-r/2,y:s/2}],stroke_width:.1,pcb_silkscreen_path_id:""},u=mi(0,n/4,.5),d=n/2+i/2,_=Math.max(s/2+.25,r/2+.03),m={type:"pcb_courtyard_outline",pcb_courtyard_outline_id:"",pcb_component_id:"",outline:lvo({centerX:0,centerY:0,straightHalfLength:d,radius:_,arcSegmentCount:9}),layer:"top"};return{circuitJson:[...A,g,u,m],parameters:e}};ui.extend({w:le,h:le});var dvo=t=>{const{w:e,h:n}=t,o=Oa(e),i=Oa(n);return{circuitJson:[Go(1,0,0,o,i),mi(0,i/2+.5,.2)],parameters:t}},TP=(t,e,n,o,i,r)=>({pcb_plated_hole_id:"",type:"pcb_plated_hole",shape:"pill",x:e,y:n,outer_width:Oa(i),outer_height:Oa(r),hole_width:Oa(o),hole_height:Oa(o),pcb_port_id:"",layers:["top","bottom"],port_hints:[t.toString()],ccw_rotation:0}),hvo=[{x:-2.73,y:3.71},{x:-2.73,y:-1.03},{x:2.73,y:-1.03},{x:2.73,y:3.71}],_vo=ui.extend({fn:F(),num_pins:Rn([De(3),De(2)]).default(3),p:F().default("1.27mm"),id:F().default("0.72mm"),od:F().default("0.95mm"),w:F().default("4.5mm"),h:F().default("4.5mm"),inline:Fe().default(!1),string:F().optional()}),mvo=(t,e,n)=>Array.from({length:25},(o,i)=>{const r=i/24*Math.PI;return{x:t+Math.cos(r)*n,y:e+Math.sin(r)*n}}),pvo=t=>{const e=t.string?.match(/^to92_(\d+)/),n=e?Number.parseInt(e[1],10):3,o=_vo.parse({...t,num_pins:n}),{p:i,id:r,od:s,w:a,h:A,inline:c}=o,l=Number.parseFloat(A)/2,g=Number.parseFloat(i),u=Number.parseFloat(r),h=Number.parseFloat(s),d=h,_=h*(1.5/1.05);let m=[];if(o.num_pins===3)c?m=[vy({pn:1,x:-g,y:l-g,holeDiameter:u,rectPadWidth:h,rectPadHeight:_}),TP(2,0,l-g,u,d,_),TP(3,g,l-g,u,d,_)]:m=[vy({pn:1,x:-g,y:l-g,holeDiameter:u,rectPadWidth:h,rectPadHeight:h}),qs(2,0,l,u,h),qs(3,g,l-g,u,h)];else if(o.num_pins===2)m=[vy({pn:1,x:-g,y:l-g,holeDiameter:u,rectPadWidth:d,rectPadHeight:_}),TP(2,g,l-g,u,d,_)];else throw new Error("Invalid number of pins for TO-92");const p=Number.parseFloat(a)/2,I=mvo(0,l,p),f={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[...I,{x:-p,y:0},{x:p,y:0},I[0]],stroke_width:.1,pcb_silkscreen_path_id:""},C=mi(0,l+1,.5),y={type:"pcb_courtyard_outline",pcb_courtyard_outline_id:"",pcb_component_id:"",outline:hvo,layer:"top"};return{circuitJson:[...m,f,C,y],parameters:o}},Ivo=ui.extend({fn:F(),num_pins:De(2).default(2),w:F().default("2.15mm"),h:F().default("0.7mm"),pl:F().default("0.6mm"),pw:F().default("0.7mm"),p:F().default("1.4mm")}),fvo=t=>{const e=Ivo.parse(t),n=mi(0,le.parse(e.h),.3),o={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:le.parse(e.p)/2,y:le.parse(e.h)/2+.2},{x:-le.parse(e.w)/2-.2,y:le.parse(e.h)/2+.2},{x:-le.parse(e.w)/2-.2,y:-le.parse(e.h)/2-.2},{x:le.parse(e.p)/2,y:-le.parse(e.h)/2-.2}],stroke_width:.1,pcb_silkscreen_path_id:""},s={type:"pcb_courtyard_rect",pcb_courtyard_rect_id:"",pcb_component_id:"",center:{x:0,y:0},width:2.5,height:1.4,layer:"top"};return{circuitJson:yvo(e).concat(...Vf(e),o,n,s),parameters:e}},Cvo=t=>{const{pn:e,p:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},yvo=t=>{const e=[],n=le.parse(t.p),o=le.parse(t.pl),i=le.parse(t.pw),r=.075;for(let s=1;s<=t.num_pins;s++){const{x:a,y:A}=Cvo({pn:s,p:n});e.push(Go(s,a,A,o,i,r))}return e},Evo=v6({w:"7.05mm",p:"1.27mm",pw:"0.65mm",pl:"1.975mm"}),xvo=t=>{const e=Evo.parse(t),n=[];for(let u=0;u<e.num_pins;u++){const{x:h,y:d}=t3e({num_pins:e.num_pins,pn:u+1,w:e.w,p:e.p??1.27,pl:e.pl,widthincludeslegs:!0});n.push(Go(u+1,h,d,e.pl??"1.5mm",e.pw??"0.6mm"))}const o=(e.num_pins/2-1)*e.p+e.pw,i=mi(0,o/2+1,o/12),r={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"",type:"pcb_silkscreen_path",route:[{x:-e.w/3,y:o/2+.4},{x:e.w/3,y:o/2+.4}],stroke_width:.1},s=(e.num_pins/2-1)*e.p+e.pw,a=e.w/2-1.395,A=e.w/2+.255,c=s/2+.25,l=s/2+.5,g={type:"pcb_courtyard_outline",pcb_courtyard_outline_id:"",pcb_component_id:"",layer:"top",outline:n1([{minX:-A,maxX:A,minY:-c,maxY:c},{minX:-a,maxX:a,minY:-l,maxY:l}])};return{circuitJson:[...n,i,r,g],parameters:e}},Bvo=ui.extend({fn:F(),num_pins:De(2).default(2),w:F().default("5.0mm"),h:F().default("2.30mm"),pl:F().default("1.25mm"),pw:F().default("2mm"),p:F().default("3.75mm")}),Qvo=t=>{const e=Bvo.parse(t),n=mi(0,le.parse(e.h)/2+1,.3),o={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:le.parse(e.p)/2+.5,y:le.parse(e.h)/2+.5},{x:-le.parse(e.w)/2-.5,y:le.parse(e.h)/2+.5},{x:-le.parse(e.w)/2-.5,y:-le.parse(e.h)/2-.5},{x:le.parse(e.p)/2+.5,y:-le.parse(e.h)/2-.5}],stroke_width:.1,pcb_silkscreen_path_id:""},s={type:"pcb_courtyard_rect",pcb_courtyard_rect_id:"",pcb_component_id:"",center:{x:0,y:0},width:5.1,height:2.8,layer:"top"};return{circuitJson:bvo(e).concat(...Vf(e),o,n,s),parameters:e}},Svo=t=>{const{pn:e,p:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},bvo=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:o,y:i}=Svo({pn:n,p:Number.parseFloat(t.p)});e.push(Go(n,o,i,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return e},Dvo=ui.extend({fn:F(),num_pins:De(2).default(2),w:F().default("4.4mm"),h:F().default("1.7mm"),pl:F().default("1.2mm"),pw:F().default("1.2mm"),p:F().default("2.8mm")}),vvo=t=>{const e=Dvo.parse(t),n=mi(0,le.parse(e.h)-.5,.3),o={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:le.parse(e.p)/2,y:le.parse(e.h)/2},{x:-le.parse(e.w)/2-.2,y:le.parse(e.h)/2},{x:-le.parse(e.w)/2-.2,y:-le.parse(e.h)/2},{x:le.parse(e.p)/2,y:-le.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""},s={type:"pcb_courtyard_rect",pcb_courtyard_rect_id:"",pcb_component_id:"",center:{x:0,y:0},width:4.5,height:2.2,layer:"top"};return{circuitJson:wvo(e).concat(...Vf(e),o,n,s),parameters:e}},Pvo=t=>{const{pn:e,p:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},wvo=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:o,y:i}=Pvo({pn:n,p:Number.parseFloat(t.p)});e.push(Go(n,o,i,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return e},Mvo=ui.extend({fn:F(),num_pins:De(2).default(2),w:F().default("3.30mm"),h:F().default("1.80mm"),pl:F().default("0.60mm"),pw:F().default("0.45mm"),p:F().default("2.1mm")}),Nvo=t=>{const e=Mvo.parse(t),n=mi(0,le.parse(e.h)-.5,.3),o={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:le.parse(e.p)/2,y:le.parse(e.h)/2},{x:-le.parse(e.w)/2,y:le.parse(e.h)/2},{x:-le.parse(e.w)/2,y:-le.parse(e.h)/2},{x:le.parse(e.p)/2,y:-le.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""},s={type:"pcb_courtyard_rect",pcb_courtyard_rect_id:"",pcb_component_id:"",center:{x:0,y:0},width:3.2,height:1.9,layer:"top"};return{circuitJson:Tvo(e).concat(...Vf(e),o,n,s),parameters:e}},Rvo=t=>{const{pn:e,p:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},Tvo=t=>{const e=[],n=le.parse(t.p),o=le.parse(t.pl),i=le.parse(t.pw),r=.05625;for(let s=1;s<=t.num_pins;s++){const{x:a,y:A}=Rvo({pn:s,p:n});e.push(Go(s,a,A,o,i,r))}return e},kvo=ui.extend({fn:F(),num_pins:De(2).default(2),w:F().default("1.4mm"),h:F().default("0.9mm"),pl:F().default("0.36mm"),pw:F().default("0.25mm"),p:F().default("0.85mm")}),Fvo=t=>{const e=kvo.parse(t),n=le.parse(e.w),o=le.parse(e.h),i=le.parse(e.pl),r=le.parse(e.pw),s=le.parse(e.p),a=mi(0,o,.3),A={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:s/2+.15,y:o/2},{x:-n/2-.15,y:o/2},{x:-n/2-.15,y:-o/2},{x:s/2+.15,y:-o/2}],stroke_width:.1,pcb_silkscreen_path_id:""},c=s+i,l=r,g=n/2,u=o/2,h=c/2,d=l/2,_=Math.max(g,h),m=Math.max(u,d),p=Math.min(g,h),I=Math.min(u,d),f=_+.05,C=p-.055,y=m,E=I+.155,B={type:"pcb_courtyard_outline",pcb_courtyard_outline_id:"",pcb_component_id:"",outline:n1([{minX:-f,maxX:f,minY:-E,maxY:E},{minX:-C,maxX:C,minY:-y,maxY:y}]),layer:"top"};return{circuitJson:Hvo(e).concat(...Vf(e),A,a,B),parameters:e}},Lvo=t=>{const{pn:e,p:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},Hvo=t=>{const e=[],n=le.parse(t.p),o=le.parse(t.pl),i=le.parse(t.pw),r=.03125;for(let s=1;s<=t.num_pins;s++){const{x:a,y:A}=Lvo({pn:s,p:n});e.push(Go(s,a,A,o,i,r))}return e},Gvo=ui.extend({fn:F(),num_pins:De(2).default(2),w:F().default("1.3mm"),h:F().default("0.9mm"),pl:F().default("0.4mm"),pw:F().default("0.7mm"),p:F().default("0.7mm")}),Ovo=t=>{const e=Gvo.parse(t),n=mi(0,le.parse(e.h)+.1,.3),o={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:le.parse(e.p)/2+.2,y:le.parse(e.h)/2+.2},{x:-le.parse(e.w)/2-.2,y:le.parse(e.h)/2+.2},{x:-le.parse(e.w)/2-.2,y:-le.parse(e.h)/2-.2},{x:le.parse(e.p)/2+.2,y:-le.parse(e.h)/2-.2}],stroke_width:.1,pcb_silkscreen_path_id:""},s={type:"pcb_courtyard_rect",pcb_courtyard_rect_id:"",pcb_component_id:"",center:{x:0,y:0},width:1.6,height:1.2,layer:"top"};return{circuitJson:Uvo(e).concat(...Vf(e),o,n,s),parameters:e}},Kvo=t=>{const{pn:e,p:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},Uvo=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:o,y:i}=Kvo({pn:n,p:Number.parseFloat(t.p)});e.push(Go(n,o,i,Number.parseFloat(t.pl),Number.parseFloat(t.pw),.025))}return e},Yvo=ui.extend({fn:F(),num_pins:De(2).default(2),w:F().default("3.05mm"),h:F().default("1.4mm"),pl:F().default("0.5mm"),pw:F().default("0.5mm"),pad_spacing:F().default("2.2mm")}),zvo=t=>{const e=Yvo.parse(t),n=mi(0,le.parse(e.h),.3),o={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:le.parse(e.pad_spacing)/2,y:le.parse(e.h)/2},{x:-le.parse(e.w)/2-.2,y:le.parse(e.h)/2},{x:-le.parse(e.w)/2-.2,y:-le.parse(e.h)/2},{x:le.parse(e.pad_spacing)/2,y:-le.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""},s={type:"pcb_courtyard_rect",pcb_courtyard_rect_id:"",pcb_component_id:"",center:{x:0,y:0},width:3.2,height:1.9,layer:"top"};return{circuitJson:Jvo(e).concat(...Vf(e),o,n,s),parameters:e}},Vvo=t=>{const{pn:e,pad_spacing:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},Jvo=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:o,y:i}=Vvo({pn:n,pad_spacing:Number.parseFloat(t.pad_spacing)});e.push(Go(n,o,i,Number.parseFloat(t.pl),Number.parseFloat(t.pw),.0625))}return e},qvo=ui.extend({fn:F(),num_pins:De(2).default(2),w:F().default("4.4mm"),h:F().default("2.1mm"),pl:F().default("1.10mm"),pw:F().default("1.10mm"),p:F().default("2.8mm")}),Wvo=t=>{const e=qvo.parse(t),n=mi(0,le.parse(e.h),.3),o={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:le.parse(e.p)/2,y:le.parse(e.h)/2},{x:-le.parse(e.w)/2-.2,y:le.parse(e.h)/2},{x:-le.parse(e.w)/2-.2,y:-le.parse(e.h)/2},{x:le.parse(e.p)/2,y:-le.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""},s={type:"pcb_courtyard_rect",pcb_courtyard_rect_id:"",pcb_component_id:"",center:{x:0,y:0},width:4.4,height:2.3,layer:"top"};return{circuitJson:Xvo(e).concat(...Vf(e),o,n,s),parameters:e}},jvo=t=>{const{pn:e,p:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},Xvo=t=>{const e=[],n=le.parse(t.p),o=le.parse(t.pl),i=le.parse(t.pw),r=.125;for(let s=1;s<=t.num_pins;s++){const{x:a,y:A}=jvo({pn:s,p:n});e.push(Go(s,a,A,o,i,r))}return e},$vo=ui.extend({fn:F(),num_pins:De(2).default(2),w:F().default("4.4mm"),h:F().default("2.1mm"),pl:F().default("0.91mm"),pw:F().default("1.22mm"),p:F().default("3.146mm")}),Zvo=t=>{const e=$vo.parse(t),n=mi(0,le.parse(e.h),.3),o={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:le.parse(e.p)/2,y:le.parse(e.h)/2},{x:-le.parse(e.w)/2-.2,y:le.parse(e.h)/2},{x:-le.parse(e.w)/2-.2,y:-le.parse(e.h)/2},{x:le.parse(e.p)/2,y:-le.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""},s={type:"pcb_courtyard_rect",pcb_courtyard_rect_id:"",pcb_component_id:"",center:{x:0,y:0},width:4.9,height:2.7,layer:"top"};return{circuitJson:tPo(e).concat(...Vf(e),o,n,s),parameters:e}},ePo=t=>{const{pn:e,p:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},tPo=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:o,y:i}=ePo({pn:n,p:Number.parseFloat(t.p)});e.push(Go(n,o,i,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return e},nPo=ui.extend({fn:F(),num_pins:De(2).default(2),w:F().default("1.80mm"),h:F().default("1.00mm"),pl:F().default("0.66mm"),pw:F().default("0.5mm"),p:F().default("0.8mm")}),oPo=t=>{const e=nPo.parse(t),n=mi(0,le.parse(e.h),.3),o={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:le.parse(e.p)/2,y:le.parse(e.h)/2},{x:-le.parse(e.w)/2-.1,y:le.parse(e.h)/2},{x:-le.parse(e.w)/2-.1,y:-le.parse(e.h)/2},{x:le.parse(e.p)/2,y:-le.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""},s={type:"pcb_courtyard_rect",pcb_courtyard_rect_id:"",pcb_component_id:"",center:{x:0,y:0},width:2.3,height:1.5,layer:"top"};return{circuitJson:rPo(e).concat(...Vf(e),o,n,s),parameters:e}},iPo=t=>{const{pn:e,p:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},rPo=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:o,y:i}=iPo({pn:n,p:Number.parseFloat(t.p)});e.push(Go(n,o,i,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return e},sPo=ui.extend({fn:F(),num_pins:De(2).default(2),w:F().default("6.2mm"),h:F().default("3.4mm"),pl:F().default("1.4mm"),pw:F().default("2.1mm"),p:F().default("4.4mm")}),aPo=t=>{const e=sPo.parse(t),n=mi(0,le.parse(e.h)/2+.4,.3),o={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:le.parse(e.p)/2,y:le.parse(e.h)/2},{x:-le.parse(e.w)/2-.2,y:le.parse(e.h)/2},{x:-le.parse(e.w)/2-.2,y:-le.parse(e.h)/2},{x:le.parse(e.p)/2,y:-le.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""},s={type:"pcb_courtyard_rect",pcb_courtyard_rect_id:"",pcb_component_id:"",center:{x:0,y:0},width:6.3,height:3,layer:"top"};return{circuitJson:cPo(e).concat(...Vf(e),o,n,s),parameters:e}},APo=t=>{const{pn:e,p:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},cPo=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:o,y:i}=APo({pn:n,p:Number.parseFloat(t.p)});e.push(Go(n,o,i,Number.parseFloat(t.pl),Number.parseFloat(t.pw),.125))}return e},J6t=(t,e)=>({type:"pcb_smtpad",points:e,layer:"top",shape:"polygon",pcb_smtpad_id:"",port_hints:Array.isArray(t)?t.map(n=>n.toString()):[t.toString()]}),lPo=[{x:-2.85,y:-2.5},{x:-2.85,y:2.5},{x:2.25,y:2.5},{x:2.25,y:-2.5}],gPo=[{x:-2.85,y:-2.5},{x:-2.85,y:2.5},{x:2.85,y:2.5},{x:2.85,y:-2.5}],uPo=[{x:.9,y:.5},{x:2.6,y:.5},{x:2.6,y:-.5},{x:.9,y:-.5},{x:.4,y:-1},{x:-.4,y:-1},{x:-.9,y:-.5},{x:-2.6,y:-.5},{x:-2.6,y:.5},{x:-.9,y:.5},{x:-.4,y:1},{x:.4,y:1}],dPo=[{x:2,y:-.8665},{x:-1.125,y:-.8665},{x:-1.125,y:-.45},{x:-2.6,y:-.45},{x:-2.6,y:.45},{x:-1.125,y:.45},{x:-1.125,y:.8665},{x:2,y:.8665}],hPo=ui.extend({fn:F(),num_pins:Rn([De(3),De(5)]).default(3),w:F().default("4.20mm"),h:F().default("4.80mm"),pl:F().default("1.3mm"),pw:F().default("0.9mm"),p:F().default("1.5mm"),string:F().optional()}),_Po=t=>{const e=Number.parseFloat(t.p),n=Number.parseFloat(t.pw),o=Number.parseFloat(t.w),i=Number.parseFloat(t.pl),r=-o/2+.15,s=o/2-1,a=Number.parseFloat(t.h)/2,A=[Go(1,r,e,i,n),J6t(2,dPo),Go(3,r,-e,i,n)],c=mi(0,a+.5,.3),l={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-s,y:a},{x:s,y:a},{x:s,y:a/2+.5}],type:"pcb_silkscreen_path",stroke_width:.1},g={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_2",route:[{x:-s,y:-a},{x:s,y:-a},{x:s,y:-a/2-.5}],type:"pcb_silkscreen_path",stroke_width:.1},u={type:"pcb_courtyard_outline",pcb_courtyard_outline_id:"",pcb_component_id:"",outline:lPo,layer:"top"};return[...A,l,g,c,u]},mPo=t=>{const e=[Go(1,-1.85,-1.5,1.5,.7),Go(2,-1.85,1.5,1.5,.7),J6t(3,uPo),Go(4,1.85,-1.5,1.5,.7),Go(5,1.85,1.5,1.5,.7)],n=Number.parseFloat(t.w)/2-1,o=Number.parseFloat(t.h)/2,i=mi(0,o+.5,.3),r={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-n,y:o},{x:n,y:o}],type:"pcb_silkscreen_path",stroke_width:.1},s={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_2",route:[{x:-n,y:-o},{x:n,y:-o}],type:"pcb_silkscreen_path",stroke_width:.1},a={type:"pcb_courtyard_outline",pcb_courtyard_outline_id:"",pcb_component_id:"",outline:gPo,layer:"top"};return[...e,r,s,i,a]},pPo=t=>{const e=t.string?.match(/^sot89_(\d+)/),n=e?Number.parseInt(e[1],10):3,o=hPo.parse({...t,num_pins:n});if(o.num_pins===3)return{circuitJson:_Po(o),parameters:o};if(o.num_pins===5)return{circuitJson:mPo(o),parameters:o};throw new Error("Invalid number of pins for SOT89")},IPo=ui.extend({fn:F(),p:le.optional().default("5.0mm"),id:le.optional().default("1.0mm"),od:le.optional().default("1.9mm"),w:le.optional().default("13mm"),h:le.optional().default("7mm"),num_pins:Ue().optional(),string:F().optional()}),q6t=t=>{const e=IPo.parse(t),{id:n,od:o,w:i,h:r,string:s}=e,a=e.num_pins??Number.parseInt(s?.match(/^to220(?:_|-)(\d+)/i)?.[1]??"3"),A=-1,c=i/2,l=r/2,g=2.5,u=i*.4,h=Math.max(g,u/(a-1)),d=Array.from({length:a},(O,U)=>{const W=a%2===0?(U-a/2+.5)*h:(U-Math.floor(a/2))*h;return qs(U+1,W,A,n,o)}),_={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-c,y:-l},{x:c,y:-l},{x:c,y:l},{x:-c,y:l},{x:-c,y:-l}],stroke_width:.1,pcb_silkscreen_path_id:""},m=-l+2*r/3,p={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-c,y:m},{x:c,y:m}],stroke_width:.1,pcb_silkscreen_path_id:""},I=[{type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-i/6,y:m},{x:-i/6,y:l}],stroke_width:.1,pcb_silkscreen_path_id:""},{type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:i/6,y:m},{x:i/6,y:l}],stroke_width:.1,pcb_silkscreen_path_id:""}],f=mi(0,r/2+.6,.5),C=Math.max(...d.map(O=>Math.abs(O.x)))+o/2,y=A+o/2,E=A-o/2,B=Math.max(C+.25,c-o*.59),Q=l-o*.63,b=E-(o/2+.01),D=-B,R=B,M=Math.min(b,E-.25),L=Math.max(Q,y+.25),G={type:"pcb_courtyard_rect",pcb_courtyard_rect_id:"",pcb_component_id:"",center:{x:(D+R)/2,y:(M+L)/2},width:R-D,height:L-M,layer:"top"};return{circuitJson:[...d,_,p,...I,f,G],parameters:{...e,p:h}}},i3e=2.54,fPo=ui.extend({fn:F(),id:le.optional().default("1.2mm"),od:le.optional().default("1.905mm"),ph:le.optional().default("2mm"),w:le.optional().default("13mm"),h:le.optional().default("7mm"),num_pins:Ue().optional(),string:F().optional()}),CPo=t=>{const e=fPo.parse(t),n=e.num_pins??Number.parseInt(e.string?.match(/^to220f(?:_|-)(\d+)/i)?.[1]??"3"),o=q6t({...e,fn:"to220",string:e.string?.replace(/^to220f/i,"to220"),num_pins:n}),i=-1,r=Array.from({length:n},(a,A)=>{const c=n%2===0?(A-n/2+.5)*i3e:(A-Math.floor(n/2))*i3e;return A===0?vy({pn:1,x:c,y:i,holeDiameter:e.id,rectPadWidth:e.od,rectPadHeight:e.ph}):TP(A+1,c,i,Oa(e.id),Oa(e.od),Oa(e.ph))}),s=o.circuitJson.filter(a=>a.type!=="pcb_plated_hole");return{circuitJson:[...r,...s],parameters:{...e,p:i3e,num_pins:n}}},yPo=ui.extend({fn:F(),num_pins:De(2).default(2),w:F().default("5.40mm"),h:F().default("2.30mm"),pl:F().default("1.30mm"),pw:F().default("1.70mm"),p:F().default("3.5mm")}),EPo=t=>{const e=yPo.parse(t),n=mi(0,le.parse(e.h)/2+.4,.3),o={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:le.parse(e.p)/2,y:le.parse(e.h)/2},{x:-le.parse(e.w)/2,y:le.parse(e.h)/2},{x:-le.parse(e.w)/2,y:-le.parse(e.h)/2},{x:le.parse(e.p)/2,y:-le.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""},s={type:"pcb_courtyard_rect",pcb_courtyard_rect_id:"",pcb_component_id:"",center:{x:0,y:0},width:5.3,height:2.2,layer:"top"};return{circuitJson:BPo(e).concat(o,n,s),parameters:e}},xPo=t=>{const{pn:e,p:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},BPo=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:o,y:i}=xPo({pn:n,p:Number.parseFloat(t.p)});e.push(Go(n,o,i,Number.parseFloat(t.pl),Number.parseFloat(t.pw),.125))}return e},QPo=ui.extend({fn:F(),num_pins:De(2).default(2),w:F().default("1.90mm"),h:F().default("1.33mm"),pl:F().default("0.5mm"),pw:F().default("0.7mm"),p:F().default("0.8mm")}),SPo=t=>{const e=QPo.parse(t),n=mi(0,le.parse(e.h)+.1,.3),o={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:le.parse(e.p)/2+.1,y:le.parse(e.h)/2},{x:-le.parse(e.w)/2,y:le.parse(e.h)/2},{x:-le.parse(e.w)/2,y:-le.parse(e.h)/2},{x:le.parse(e.p)/2+.1,y:-le.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""},s={type:"pcb_courtyard_rect",pcb_courtyard_rect_id:"",pcb_component_id:"",center:{x:0,y:0},width:1.8,height:1.2,layer:"top"};return{circuitJson:DPo(e).concat(...Vf(e),o,n,s),parameters:e}},bPo=t=>{const{pn:e,p:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},DPo=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:o,y:i}=bPo({pn:n,p:Number.parseFloat(t.p)});e.push(Go(n,o,i,Number.parseFloat(t.pl),Number.parseFloat(t.pw),.0625))}return e},vPo=ui.extend({fn:F(),num_pins:De(2).default(2),w:F().default("7.0mm"),h:F().default("3.35mm"),pl:F().default("1.50mm"),pw:F().default("2.70mm"),p:F().default("4.8mm")}),PPo=t=>{const e=vPo.parse(t),n=mi(0,le.parse(e.h),.3),o={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:le.parse(e.p)/2,y:le.parse(e.h)/2},{x:-le.parse(e.w)/2,y:le.parse(e.h)/2},{x:-le.parse(e.w)/2,y:-le.parse(e.h)/2},{x:le.parse(e.p)/2,y:-le.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""},s={type:"pcb_courtyard_rect",pcb_courtyard_rect_id:"",pcb_component_id:"",center:{x:0,y:0},width:6.8,height:3.2,layer:"top"};return{circuitJson:MPo(e).concat(o,n,s),parameters:e}},wPo=t=>{const{pn:e,p:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},MPo=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:o,y:i}=wPo({pn:n,p:Number.parseFloat(t.p)});e.push(Go(n,o,i,Number.parseFloat(t.pl),Number.parseFloat(t.pw),.125))}return e},NPo=ui.extend({fn:F(),num_pins:De(2).default(2),w:F().default("3.0mm"),h:F().default("1.80mm"),pl:F().default("0.80mm"),pw:F().default("1.20mm"),p:F().default("1.6mm")}),RPo=t=>{const e=NPo.parse(t),n=mi(0,le.parse(e.h),.3),o={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:le.parse(e.p)/2,y:le.parse(e.h)/2},{x:-le.parse(e.w)/2-.1,y:le.parse(e.h)/2},{x:-le.parse(e.w)/2-.1,y:-le.parse(e.h)/2},{x:le.parse(e.p)/2,y:-le.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""},s={type:"pcb_courtyard_rect",pcb_courtyard_rect_id:"",pcb_component_id:"",center:{x:0,y:0},width:2.9,height:1.7,layer:"top"};return{circuitJson:kPo(e).concat(o,n,s),parameters:e}},TPo=t=>{const{pn:e,p:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},kPo=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:o,y:i}=TPo({pn:n,p:Number.parseFloat(t.p)});e.push(Go(n,o,i,Number.parseFloat(t.pl),Number.parseFloat(t.pw),.1))}return e},FPo=ui.extend({fn:F(),num_pins:De(2).default(2),w:F().default("7.10mm"),h:F().default("3.40mm"),pl:F().default("2.50mm"),pw:F().default("1.80mm"),p:F().default("4.00mm")}),LPo=t=>{const e=FPo.parse(t),n=mi(0,le.parse(e.h)/2+.5,.3),o={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:le.parse(e.p)/2,y:le.parse(e.h)/2},{x:-le.parse(e.w)/2-.5,y:le.parse(e.h)/2},{x:-le.parse(e.w)/2-.5,y:-le.parse(e.h)/2},{x:le.parse(e.p)/2,y:-le.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""},s={type:"pcb_courtyard_rect",pcb_courtyard_rect_id:"",pcb_component_id:"",center:{x:0,y:0},width:7,height:3.5,layer:"top"};return{circuitJson:GPo(e).concat(o,n,s),parameters:e}},HPo=t=>{const{pn:e,p:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},GPo=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:o,y:i}=HPo({pn:n,p:Number.parseFloat(t.p)});e.push(Go(n,o,i,Number.parseFloat(t.pl),Number.parseFloat(t.pw),.125))}return e},OPo=ui.extend({fn:F(),num_pins:De(2).default(2),w:F().default("4.80mm"),h:F().default("2.10mm"),pl:F().default("1.30mm"),pw:F().default("1.40mm"),p:F().default("2.9mm")}),KPo=t=>{const e=OPo.parse(t),n=mi(0,le.parse(e.h)-.5,.3),o={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:le.parse(e.p)/2,y:le.parse(e.h)/2},{x:-le.parse(e.w)/2,y:le.parse(e.h)/2},{x:-le.parse(e.w)/2,y:-le.parse(e.h)/2},{x:le.parse(e.p)/2,y:-le.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""},s={type:"pcb_courtyard_rect",pcb_courtyard_rect_id:"",pcb_component_id:"",center:{x:0,y:0},width:4.7,height:2.3,layer:"top"};return{circuitJson:YPo(e).concat(o,n,s),parameters:e}},UPo=t=>{const{pn:e,p:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},YPo=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:o,y:i}=UPo({pn:n,p:Number.parseFloat(t.p)});e.push(Go(n,o,i,Number.parseFloat(t.pl),Number.parseFloat(t.pw),.125))}return e},zPo=ui.extend({fn:F(),num_pins:De(2).default(2),w:F().default("7.30mm"),h:F().default("4.40mm"),pl:F().default("2.50mm"),pw:F().default("2.30mm"),p:F().default("4.30mm")}),VPo=t=>{const e=zPo.parse(t),n=mi(0,le.parse(e.h)/2+.5,.3),o={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:le.parse(e.p)/2,y:le.parse(e.h)/2},{x:-le.parse(e.w)/2-.1,y:le.parse(e.h)/2},{x:-le.parse(e.w)/2-.1,y:-le.parse(e.h)/2},{x:le.parse(e.p)/2,y:-le.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""},s={type:"pcb_courtyard_rect",pcb_courtyard_rect_id:"",pcb_component_id:"",center:{x:0,y:0},width:7.3,height:4.5,layer:"top"};return{circuitJson:qPo(e).concat(o,n,s),parameters:e}},JPo=t=>{const{pn:e,p:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},qPo=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:o,y:i}=JPo({pn:n,p:Number.parseFloat(t.p)});e.push(Go(n,o,i,Number.parseFloat(t.pl),Number.parseFloat(t.pw),.125))}return e},WPo=ui.extend({fn:F(),num_pins:De(2).default(2),w:F().default("10.70mm"),h:F().default("6.60mm"),pl:F().default("2.50mm"),pw:F().default("3.30mm"),p:F().default("6.80mm")}),jPo=t=>{const e=WPo.parse(t),n=mi(0,3,.3),o={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:le.parse(e.p)/2,y:le.parse(e.h)/2-.8},{x:-le.parse(e.w)/2-.8,y:le.parse(e.h)/2-.8},{x:-le.parse(e.w)/2-.8,y:-le.parse(e.h)/2+.8},{x:le.parse(e.p)/2,y:-le.parse(e.h)/2+.8}],stroke_width:.1,pcb_silkscreen_path_id:""},s={type:"pcb_courtyard_rect",pcb_courtyard_rect_id:"",pcb_component_id:"",center:{x:0,y:0},width:9.8,height:6.7,layer:"top"};return{circuitJson:$Po(e).concat(o,n,s),parameters:e}},XPo=t=>{const{pn:e,p:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},$Po=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:o,y:i}=XPo({pn:n,p:Number.parseFloat(t.p)});e.push(Go(n,o,i,Number.parseFloat(t.pl),Number.parseFloat(t.pw),.125))}return e},ZPo=ui.extend({fn:F(),num_pins:Ue().default(4),w:F().default("8.50mm"),h:F().default("6.90mm"),pl:F().default("2mm"),pw:F().default("1.5mm"),p:F().default("2.30mm"),string:F().optional()}),ewo=t=>{const e=t.string?.match(/^sot223_(\d+)/),n=e?Number.parseInt(e[1],10):4;if(n===8){const i=owo.parse({...t,num_pins:n});return{circuitJson:zU(i),parameters:i}}const o=ZPo.parse({...t,num_pins:n});if(o.num_pins===4)return{circuitJson:nwo(o),parameters:o};if(o.num_pins===5)return{circuitJson:rwo(o),parameters:o};if(o.num_pins===6)return{circuitJson:awo(o),parameters:o};throw new Error("Invalid number of pins")},two=t=>{const{pn:e,w:n,p:o}=t;return e===1?{x:-n/2+1.1,y:o}:e===2?{x:-n/2+1.1,y:0}:e===3?{x:-n/2+1.1,y:-o}:{x:n/2-1.1,y:0}},nwo=t=>{const e=[];let n=0,o=0;for(let d=0;d<t.num_pins;d++){const{x:_,y:m}=two({num_pins:t.num_pins,pn:d+1,w:Number.parseFloat(t.w),h:Number.parseFloat(t.h),pl:Number.parseFloat(t.pl),p:Number.parseFloat(t.p)}),p=d===3?3.8:Number.parseFloat(t.pw),I=Number.parseFloat(t.pl);n=Math.max(n,Math.abs(_)+I/2),o=Math.max(o,Math.abs(m)+p/2),e.push(Go(d+1,_,m,I,p))}const i=mi(0,0,.3),r=Number.parseFloat(t.w)/2-2.4,s=Number.parseFloat(t.h)/2,a={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-r,y:s},{x:r,y:s},{x:r,y:s/2+.5}],type:"pcb_silkscreen_path",stroke_width:.1},A={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_2",route:[{x:-r,y:-s},{x:r,y:-s},{x:r,y:-s/2-.5}],type:"pcb_silkscreen_path",stroke_width:.1},c=Number.parseFloat(t.w)/2,l=Number.parseFloat(t.h)/2,g=Math.max(n+.25,c+.15),u=Math.max(o+.25,l+.15),h={type:"pcb_courtyard_rect",pcb_courtyard_rect_id:"",pcb_component_id:"",center:{x:0,y:0},width:2*g,height:2*u,layer:"top"};return[...e,a,A,i,h]},owo=v6({p:"0.90mm",w:"2.8mm",legsoutside:!0}),iwo=t=>{const{p:e,pn:n,w:o}=t;if(n===1)return{x:-o/2+1.2,y:e/2+e};if(n===2)return{x:-o/2+1.2,y:e/2};if(n===3)return{x:-o/2+1.2,y:-e/2};if(n===4)return{x:-o/2+1.2,y:-e/2-e};if(n===5)return{x:o/2-1,y:0};throw new Error("Invalid pin number")},rwo=t=>{const e=[];let n=0,o=0;for(let d=1;d<=t.num_pins;d++){const{x:_,y:m}=iwo({h:Number.parseFloat(t.h),p:1.5,pn:d,w:Number.parseFloat(t.w)});let p=Number.parseFloat(t.pw),I=Number.parseFloat(t.pl);d===5?(p=3.4,I=1.8):(p=1,I=2.2),n=Math.max(n,Math.abs(_)+I/2),o=Math.max(o,Math.abs(m)+p/2),e.push(Go(d,_,m,I,p))}const i=Number.parseFloat(t.w)/2-2.4,r=Number.parseFloat(t.h)/2,s={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},a={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},A=mi(0,0,.3),c=Number.parseFloat(t.w)/2,l=Number.parseFloat(t.h)/2,g=Math.max(n+.25,c+.15),u=Math.max(o+.25,l+.15),h={type:"pcb_courtyard_rect",pcb_courtyard_rect_id:"",pcb_component_id:"",center:{x:0,y:0},width:2*g,height:2*u,layer:"top"};return[...e,s,a,A,h]},swo=t=>{const{p:e,pn:n,w:o}=t;if(n===1)return{x:-o/2+1.2,y:2*e};if(n===2)return{x:-o/2+1.2,y:e};if(n===3)return{x:-o/2+1.2,y:0};if(n===4)return{x:-o/2+1.2,y:-e};if(n===5)return{x:-o/2+1.2,y:-2*e};if(n===6)return{x:o/2-1.175,y:0};throw new Error("Invalid pin number")},awo=t=>{const e=[];let n=0,o=0;for(let d=1;d<=t.num_pins;d++){const{x:_,y:m}=swo({h:Number.parseFloat(t.h),p:1.3,pn:d,w:8.7});let p=Number.parseFloat(t.pw),I=Number.parseFloat(t.pl);d===6?(p=3.4,I=2.15):(p=.6,I=2.2),n=Math.max(n,Math.abs(_)+I/2),o=Math.max(o,Math.abs(m)+p/2),e.push(Go(d,_,m,I,p))}const i=Number.parseFloat(t.w)/2-2.4,r=Number.parseFloat(t.h)/2,s={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},a={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},A=mi(0,0,.3),c=Number.parseFloat(t.w)/2,l=Number.parseFloat(t.h)/2,g=Math.max(n+.25,c+.15),u=Math.max(o+.25,l+.15),h={type:"pcb_courtyard_rect",pcb_courtyard_rect_id:"",pcb_component_id:"",center:{x:0,y:0},width:2*g,height:2*u,layer:"top"};return[...e,s,a,A,h]},Awo=ui.extend({fn:F(),num_pins:Ue().default(3),w:F().default("3.40mm"),h:F().default("3.30mm"),pl:F().default("1mm"),pw:F().default("0.7mm"),p:F().default("1.2mm"),string:F().optional()}),cwo=t=>{const e=t.string?.match(/^sot23w_(\d+)/),n=e?Number.parseInt(e[1],3):3,o=Awo.parse({...t,num_pins:n});if(o.num_pins===3)return{circuitJson:gwo(o),parameters:o};throw new Error("Invalid number of pins")},lwo=t=>{const{pn:e,p:n}=t;return e===1?{x:-n,y:.95}:e===2?{x:-n,y:-.95}:{x:n,y:0}},gwo=t=>{const e=[];for(let p=0;p<t.num_pins;p++){const{x:I,y:f}=lwo({num_pins:t.num_pins,pn:p+1,w:Number.parseFloat(t.w),h:Number.parseFloat(t.h),pl:Number.parseFloat(t.pl),p:Number.parseFloat(t.p)});e.push(Go(p+1,I,f,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}const n=mi(0,Number.parseInt(t.h)/2+1,.3),o=Number.parseFloat(t.w)/2-1,i=Number.parseFloat(t.h)/2,r={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-o,y:i},{x:o+.3,y:i},{x:o+.3,y:i/2}],type:"pcb_silkscreen_path",stroke_width:.1},s={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_2",route:[{x:-o,y:-i},{x:o+.3,y:-i},{x:o+.3,y:-i/2}],type:"pcb_silkscreen_path",stroke_width:.1},a=Number.parseFloat(t.p),A=Number.parseFloat(t.pl),c=Number.parseFloat(t.pw),l=Number.parseFloat(t.h),g=a+A/2,u=.95+c/2,h=l/2,d=g+.25,_=Math.max(u+.25,h+.09),m={type:"pcb_courtyard_rect",pcb_courtyard_rect_id:"",pcb_component_id:"",center:{x:0,y:0},width:2*d,height:2*_,layer:"top"};return[...e,r,s,n,m]},uwo=ui.extend({fn:F(),num_pins:Rn([De(3),De(2)]).default(3),p:F().default("1.27mm"),id:F().default("0.72mm"),od:F().default("0.95mm"),w:F().default("2.5mm"),h:F().default("4.2mm"),string:F().optional()}),dwo=t=>{const{p:e,id:n,od:o,w:i,h:r}=t,s=Number.parseFloat(r)/2,a=Number.parseFloat(e);return[qs(1,-a,s-a,n,o),qs(2,0,s-a,n,o),qs(3,a,s-a,n,o)]},hwo=t=>{const{p:e,id:n,od:o,h:i}=t,r=Number.parseFloat(i)/2,s=Number.parseFloat(e),a=Number.parseFloat(n),A=Number.parseFloat(o),c=A*(1.5/1.05);return[vy({pn:1,x:-s,y:r-s,holeDiameter:a,rectPadWidth:A,rectPadHeight:c}),TP(2,s,r-s,a,A,c)]},_wo=t=>{const e=t.string?.match(/^to92s_(\d+)/),n=e?Number.parseInt(e[1],10):3,o=uwo.parse({...t,num_pins:n});let i=[];if(o.num_pins===3)i=dwo(o);else if(o.num_pins===2)i=hwo(o);else throw new Error("Invalid number of pins for TO-92");const r=Number.parseFloat(o.h)/2,s=Number.parseFloat(o.p),a={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-r,y:r-s},{x:-1.9,y:0},{x:1.9,y:0},{x:r,y:r-s},{x:1.5,y:Number.parseFloat(o.h)/2+.5},{x:-1.5,y:Number.parseFloat(o.h)/2+.5},{x:-r,y:r-s}],stroke_width:.1,pcb_silkscreen_path_id:""},A=mi(0,r+1,.5),c=Number.parseFloat(o.od),l=r-s,g=-s-c/2,u=s+c/2,h=l-c/2,d=l+c/2,_=-r,m=r,p=0,I=r+.5,f=Math.min(g,_)-.27,C=Math.max(u,m)+.13,y=Math.min(h,p)-.42,E=Math.max(d,I)+.08,B={type:"pcb_courtyard_rect",pcb_courtyard_rect_id:"",pcb_component_id:"",center:{x:(f+C)/2,y:(y+E)/2},width:C-f,height:E-y,layer:"top"};return{circuitJson:[...i,a,A,B],parameters:o}},mwo=ui.extend({fn:F(),p:le.optional(),id:le.optional(),pw:le.optional(),pl:le.optional(),w:le.optional(),h:le.optional(),sh:Fe().optional().describe('JST SH (Surface-mount) connector family. SH stands for "Super High-density".'),ph:Fe().optional().describe('JST PH (Through-hole) connector family. PH stands for "Pin Header".'),zh:Fe().optional().describe("JST ZH (Through-hole) connector family. 1.5mm pitch wire-to-board."),string:F().optional()}),pwo=()=>({minX:Number.POSITIVE_INFINITY,maxX:Number.NEGATIVE_INFINITY,minY:Number.POSITIVE_INFINITY,maxY:Number.NEGATIVE_INFINITY}),VU=({bounds:t,centerX:e,centerY:n,width:o,height:i})=>{const r=o/2,s=i/2;t.minX=Math.min(t.minX,e-r),t.maxX=Math.max(t.maxX,e+r),t.minY=Math.min(t.minY,n-s),t.maxY=Math.max(t.maxY,n+s)},Iwo={ph:{p:le.parse("2.2mm"),id:le.parse("0.70mm"),pw:le.parse("1.20mm"),pl:le.parse("1.20mm"),w:le.parse("6mm"),h:le.parse("5mm")},sh:{p:le.parse("1mm"),pw:le.parse("0.6mm"),pl:le.parse("1.55mm"),w:le.parse("5.8mm"),h:le.parse("7.8mm")},zh:{p:le.parse("1.5mm"),id:le.parse("0.73mm"),pw:le.parse("1.03mm"),pl:le.parse("1.73mm"),w:le.parse("3mm"),h:le.parse("3.5mm")}};function fwo(t){return t.sh?"sh":t.ph?"ph":t.zh?"zh":"ph"}function Cwo({variant:t,numPins:e,p:n,id:o,pw:i,pl:r}){const s=[],a=pwo();let A=0;if(t==="ph"){const c=-((e-1)/2)*n;for(let l=0;l<e;l++){const g=c+l*n;s.push(vy({pn:l+1,x:g,y:2,holeDiameter:o,rectPadWidth:i,rectPadHeight:r})),VU({bounds:a,centerX:g,centerY:2,width:i,height:r}),A=Math.max(A,r/2)}}else if(t==="zh"){const c=-((e-1)/2)*n;for(let l=0;l<e;l++){const g=c+l*n;l===0?s.push(vy({pn:l+1,x:g,y:0,holeDiameter:o,rectPadWidth:i,rectPadHeight:r,rectBorderRadius:.12499977})):s.push(TP(l+1,g,0,o,i,r)),VU({bounds:a,centerX:g,centerY:0,width:i,height:r}),A=Math.max(A,r/2)}}else{const c=-((e-1)/2)*n;for(let g=0;g<e;g++){const u=c+g*n;s.push(Go(g+1,u,-1.325,i,r)),VU({bounds:a,centerX:u,centerY:-1.325,width:i,height:r}),A=Math.max(A,r/2)}const l=(e-1)/2*n+1.3;s.push(Go(e+1,-l,1.22,1.2,1.8)),s.push(Go(e+2,l,1.22,1.2,1.8)),VU({bounds:a,centerX:-l,centerY:1.22,width:1.2,height:1.8}),VU({bounds:a,centerX:l,centerY:1.22,width:1.2,height:1.8}),A=Math.max(A,.9)}return{pads:s,padBounds:a,maxPadHalfY:A}}function ywo({variant:t,w:e,h:n,numPins:o,p:i}){if(t==="ph")return{type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-3,y:3},{x:3,y:3},{x:3,y:-2},{x:-3,y:-2},{x:-3,y:3}],stroke_width:.1,pcb_silkscreen_path_id:""};if(t==="zh"&&o&&i){const r=(o-1)*i,s=-r/2-1.5,a=r/2+1.5,A=-n/2,c=n/2;return{type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:s,y:A},{x:a,y:A},{x:a,y:c},{x:s,y:c},{x:s,y:A}],stroke_width:.1,pcb_silkscreen_path_id:""}}else return{type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[],stroke_width:.1,pcb_silkscreen_path_id:""}}var Ewo=t=>{const e=mwo.parse(t),n=fwo(e),o=Iwo[n],i=e.p??o.p,r=e.id??o.id,s=e.pw??o.pw,a=e.pl??o.pl,A=e.w??o.w,c=e.h??o.h;let l;const g=t.num_pins;typeof g=="number"&&(l=g);const u=typeof t.string=="string"?t.string:"",h=u.match(/(?:^|_)jst(\d+)(?:_|$)/),d=u.match(/(?:^|_)zh(\d+)(?:_|$)/);if(h&&h[1]){const ie=Number.parseInt(h[1],10);Number.isNaN(ie)||(l=ie)}if(d&&d[1]){const ie=Number.parseInt(d[1],10);Number.isNaN(ie)||(l=ie)}if(typeof l!="number")throw new Error(`JST requires an explicit pin count (e.g. jst6_sh or .jst(6))${e.string?`, from string "${e.string}"`:""}`);const _=Cwo({variant:n,numPins:l,p:i,id:r,pw:s,pl:a}),{pads:m,padBounds:p,maxPadHalfY:I}=_,f=ywo({variant:n,w:A,h:c,numPins:l,p:i}),C=mi(0,c/2+1,.5),y=f.route.map(ie=>ie.x),E=f.route.map(ie=>ie.y),B=y.length>0&&E.length>0,Q=B?Math.min(p.minX,Math.min(...y)):p.minX,b=B?Math.max(p.maxX,Math.max(...y)):p.maxX,D=B?Math.min(p.minY,Math.min(...E)):p.minY,R=B?Math.max(p.maxY,Math.max(...E)):p.maxY,M=.5,L=.05,G=I+.085,O=Q-M,U=b+M,W=D-G,j=R+L,te={type:"pcb_courtyard_rect",pcb_courtyard_rect_id:"",pcb_component_id:"",center:{x:(O+U)/2,y:(W+j)/2},width:U-O,height:j-W,layer:"top"};return{circuitJson:[...m,f,C,te],parameters:{...e,p:i,id:r,pw:s,pl:a,w:A,h:c,num_pins:l,sh:n==="sh",ph:n==="ph",zh:n==="zh"}}},xwo=ui.extend({fn:F(),num_pins:De(2).default(2),w:F().default("3.30mm"),h:F().default("1.70mm"),pl:F().default("0.80mm"),pw:F().default("1mm"),p:F().default("1.90mm")}),Bwo=t=>{const e=xwo.parse(t),n=mi(0,le.parse(e.h)/2+.5,.3),o={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:le.parse(e.p)/2,y:le.parse(e.h)/2},{x:-le.parse(e.w)/2,y:le.parse(e.h)/2},{x:-le.parse(e.w)/2,y:-le.parse(e.h)/2},{x:le.parse(e.p)/2,y:-le.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""},s={type:"pcb_courtyard_rect",pcb_courtyard_rect_id:"",pcb_component_id:"",center:{x:0,y:0},width:3.2,height:2,layer:"top"};return{circuitJson:Swo(e).concat(...Vf(e),o,n,s),parameters:e}},Qwo=t=>{const{pn:e,p:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},Swo=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:o,y:i}=Qwo({pn:n,p:Number.parseFloat(t.p)});e.push(Go(n,o,i,Number.parseFloat(t.pl),Number.parseFloat(t.pw),.1))}return e},bwo=t=>{switch(t){case 8:return{w:"3.06mm",h:"3.14mm",p:"0.65mm",pl:"1.6mm",pw:"0.5mm"};case 10:return{w:"3.10mm",h:"3.33mm",p:"0.5mm",pl:"1.45mm",pw:"0.3mm"};default:return{w:"3.06mm",h:"3.14mm",p:"0.65mm",pl:"1.6mm",pw:"0.5mm"}}},Dwo=ui.extend({fn:F(),num_pins:Rn([De(8),De(10)]).default(8),w:F().optional(),h:F().optional(),p:F().optional(),pl:F().optional(),pw:F().optional(),string:F().optional()}),vwo=t=>{const e=Dwo.parse(t),n=bwo(e.num_pins),o=le.parse(e.w||n.w),i=le.parse(e.h||n.h),r=le.parse(e.p||n.p),s=le.parse(e.pl||n.pl),a=le.parse(e.pw||n.pw),A=[],c=e.num_pins/2;for(let Q=0;Q<e.num_pins;Q++){const{x:b,y:D}=W6t(e.num_pins,Q+1,o,r),R=Q<c?Q+1:e.num_pins-(Q-c);A.push(Go(R,b,D,s,a))}const l=o,g=i,u={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-l/2,y:g/2},{x:l/2,y:g/2}],stroke_width:.05,pcb_silkscreen_path_id:""},h={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-l/2,y:-g/2},{x:l/2,y:-g/2}],stroke_width:.05,pcb_silkscreen_path_id:""},d=W6t(e.num_pins,1,l,r),_={x:d.x-.8,y:d.y},m={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"},p=mi(0,g/2+.5,.3),I=(e.num_pins/2-1)*r+a,f=o/2+.25,C=f+1.43,y=I/2+.255,E=i/2+.25,B={type:"pcb_courtyard_outline",pcb_courtyard_outline_id:"",pcb_component_id:"",layer:"top",outline:n1([{minX:-C,maxX:C,minY:-y,maxY:y},{minX:-f,maxX:f,minY:-E,maxY:E}])};return{circuitJson:[...A,u,h,p,m,B],parameters:e}},W6t=(t,e,n,o)=>{const i=t/2,r=(e-1)%i,s=e<=i?-1:1,a=(i-1)/2-r;return{x:s*2.11,y:a*o}},Pwo=t=>{switch(t){case 10:return{w:"3.10mm",h:"3.32mm",p:"0.5mm",pl:"1.63mm",pw:"0.33mm"};case 12:return{w:"3mm",h:"4mm",p:"0.65mm",pl:"0.88mm",pw:"0.4mm"};case 16:return{w:"3.10mm",h:"4mm",p:"0.5mm",pl:"0.88mm",pw:"0.3mm"};default:return{w:"3.10mm",h:"3.32mm",p:"0.65mm",pl:"1.63mm",pw:"0.4mm"}}},wwo=ui.extend({fn:F(),num_pins:Rn([De(8),De(10),De(12),De(16)]).default(8),w:F().optional(),h:F().optional(),p:F().optional(),pl:F().optional(),pw:F().optional(),string:F().optional()}),j6t=(t,e,n,o,i)=>{const r=t/2,s=(e-1)%r,a=e<=r?-1:1,A=(r-1)/2-s,c=le.parse("0.2mm");return{x:a*(n/2+i/2-c),y:A*o}},Mwo=t=>{const e=wwo.parse(t),n=Pwo(e.num_pins),o=le.parse(e.w||n.w),i=le.parse(e.h||n.h),r=le.parse(e.p||n.p),s=le.parse(e.pl||n.pl),a=le.parse(e.pw||n.pw),A=[];for(let B=0;B<e.num_pins;B++){const{x:Q,y:b}=j6t(e.num_pins,B+1,o,r,s);A.push(Go(B+1,Q,b,s,a))}const c=o,l=i,g={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-c/2,y:l/2},{x:c/2,y:l/2}],stroke_width:.05,pcb_silkscreen_path_id:""},u={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-c/2,y:-l/2},{x:c/2,y:-l/2}],stroke_width:.05,pcb_silkscreen_path_id:""},h=j6t(e.num_pins,1,c,r,s),d={x:h.x-.8,y:h.y},_={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"pin_marker_1",route:[{x:d.x-.4,y:d.y},{x:d.x-.7,y:d.y+.3},{x:d.x-.7,y:d.y-.3},{x:d.x-.4,y:d.y}],stroke_width:.05,pcb_silkscreen_path_id:"pin_marker_1"},m=mi(0,l/2+.5,.3),p=(e.num_pins/2-1)*r+a,I=o/2+.25,f=I+1.43,C=p/2+.255,y=i/2+.25,E={type:"pcb_courtyard_outline",pcb_courtyard_outline_id:"",pcb_component_id:"",layer:"top",outline:n1([{minX:-f,maxX:f,minY:-C,maxY:C},{minX:-I,maxX:I,minY:-y,maxY:y}])};return{circuitJson:[...A,g,u,m,_,E],parameters:e}},Nwo=ui.extend({fn:F(),num_pins:De(2).default(2),w:F().default("3.8mm"),h:F().default("1.65mm"),pl:F().default("1.2mm"),pw:F().default("1.2mm"),pad_spacing:F().default("2.6mm")}),Rwo=t=>{const e=Nwo.parse(t),n=mi(0,le.parse(e.h),.3),o={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:le.parse(e.pad_spacing)/2,y:le.parse(e.h)/2},{x:-le.parse(e.w)/2-.2,y:le.parse(e.h)/2},{x:-le.parse(e.w)/2-.2,y:-le.parse(e.h)/2},{x:le.parse(e.pad_spacing)/2,y:-le.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""},s={type:"pcb_courtyard_rect",pcb_courtyard_rect_id:"",pcb_component_id:"",center:{x:0,y:0},width:4.3,height:2.15,layer:"top"};return{circuitJson:kwo(e).concat(...Vf(e),o,n,s),parameters:e}},Two=t=>{const{pn:e,pad_spacing:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},kwo=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:o,y:i}=Two({pn:n,pad_spacing:Number.parseFloat(t.pad_spacing)});e.push(Go(n,o,i,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return e},Fwo=ui.extend({fn:F(),num_pins:De(2).default(2),w:F().default("3.20mm"),h:F().default("1.65mm"),pl:F().default("0.8mm"),pw:F().default("0.9mm"),pad_spacing:F().default("2.1mm")}),Lwo=t=>{const e=Fwo.parse(t),n=mi(0,le.parse(e.h),.3),o={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:le.parse(e.pad_spacing)/2,y:le.parse(e.h)/2},{x:-le.parse(e.w)/2-.2,y:le.parse(e.h)/2},{x:-le.parse(e.w)/2-.2,y:-le.parse(e.h)/2},{x:le.parse(e.pad_spacing)/2,y:-le.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""},s={type:"pcb_courtyard_rect",pcb_courtyard_rect_id:"",pcb_component_id:"",center:{x:0,y:0},width:3.7,height:2.15,layer:"top"};return{circuitJson:Gwo(e).concat(...Vf(e),o,n,s),parameters:e}},Hwo=t=>{const{pn:e,pad_spacing:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},Gwo=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:o,y:i}=Hwo({pn:n,pad_spacing:Number.parseFloat(t.pad_spacing)});e.push(Go(n,o,i,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return e},Owo=ui.extend({fn:F(),num_pins:Rn([De(6),De(8)]).default(8),w:F().default("3mm"),h:F().default("3mm"),p:F().default("0.5mm"),pl:F().default("0.52mm"),pw:F().default("0.35mm"),epw:F().default("1.40mm"),eph:F().default("1.60mm"),string:F().optional(),ep:Fe().default(!1)}),Kwo=t=>{t.string&&t.string.includes("_ep")&&(t.ep=!0);const e=t.string?.match(/^son_(\d+)/),n=e?Number.parseInt(e[1],10):t.num_pins||8,o=Owo.parse({...t,num_pins:n}),i=le.parse(o.w),r=le.parse(o.h),s=le.parse(o.p),a=le.parse(o.pl),A=le.parse(o.pw),c=le.parse(o.epw),l=le.parse(o.eph),g=[];for(let M=0;M<o.num_pins;M++){const{x:L,y:G}=r3e(o.num_pins,M+1,i,s);g.push(Go(M+1,L,G,a,A))}o.ep&&g.push(Go(o.num_pins+1,0,0,c,l));const u=i,h=r,d={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-u/2,y:h/2},{x:u/2,y:h/2}],stroke_width:.05,pcb_silkscreen_path_id:""},_={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-u/2,y:-h/2},{x:u/2,y:-h/2}],stroke_width:.05,pcb_silkscreen_path_id:""},m=r3e(o.num_pins,1,u,s),p={x:m.x-.4,y:m.y},I={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"pin_marker_1",route:[{x:p.x-.4,y:p.y},{x:p.x-.7,y:p.y+.3},{x:p.x-.7,y:p.y-.3},{x:p.x-.4,y:p.y}],stroke_width:.05,pcb_silkscreen_path_id:"pin_marker_1"},f=mi(0,h/2+.5,.3),C=Math.abs(r3e(o.num_pins,1,i,s).x),y=(o.num_pins/2-1)*s+A,E=C*2+a,B=i/2+.25,Q=E/2+.25,b=y/2+.25,D=r/2+.25,R={type:"pcb_courtyard_outline",pcb_courtyard_outline_id:"",pcb_component_id:"",layer:"top",outline:n1([{minX:-Q,maxX:Q,minY:-b,maxY:b},{minX:-B,maxX:B,minY:-D,maxY:D}])};return{circuitJson:[...g,d,_,f,I,R],parameters:o}},r3e=(t,e,n,o)=>{const i=t/2,r=(e-1)%i,s=e<=i?-1:1,a=(i-1)/2-r;return{x:s*le.parse("1.4mm"),y:a*o}},Uwo=ui.extend({fn:F(),num_pins:Ue().optional().default(8),p:it.describe("pitch (distance between center of each pin)"),w:le.describe("width between vertical rows of pins"),grid:$ie.describe("width and height of the border of the footprint"),ep:$ie.default("0x0mm").describe("width and height of the central exposed thermal pad"),epx:le.default("0mm").describe("x offset of the center of the central exposed thermal pad"),pinw:le.describe("width of the pin pads"),pinh:le.describe("height of the pin pads")}),Ywo=t=>{const e=Uwo.parse(t),{num_pins:n,p:o,w:i,grid:r,ep:s,epx:a,pinw:A,pinh:c}=e;if(n%2!==0)throw new Error("invalid number of pins");const l=[];for(let B=0;B<n;B++){const{pinX:Q,pinY:b}=zwo({pinCount:n,pinIndex:B,width:i,pitch:o});l.push(Go(B+1,Q,b,A,c))}s.x>0&&s.y>0&&l.push(Go(e.num_pins+1,a,0,s.x,s.y));const g=Vwo(r),u=mi(0,r.y/2+o,r.y/6),h=(n/2-1)*o+c,d=i+A,_=r.x/2+.25,m=d/2+.25,p=h/2+.25,I=h/2+.45+Math.max(0,.8-o),f=Math.min(r.y/2+.25,I),C=Math.max(0,.37-Math.max(0,m-_-.38)*1.4),y=Math.max(p,f-C),E={type:"pcb_courtyard_outline",pcb_courtyard_outline_id:"",pcb_component_id:"",layer:"top",outline:n1([{minX:-m,maxX:m,minY:-y,maxY:y},{minX:-_,maxX:_,minY:-f,maxY:f}])};return{circuitJson:[...l,...g,u,E],parameters:e}},zwo=t=>{let e=0,n=0;const o=(t.pinCount/2-1)*t.pitch/2,i=t.pinCount/2;return t.pinIndex+1<=i?(e=t.pitch*t.pinIndex-o,n=0-t.width/2):(e=t.pitch*(t.pinCount-t.pinIndex-1)-o,n=t.width/2),{pinX:n,pinY:e}},Vwo=t=>{const n=t.y/30;return[{layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"",type:"pcb_silkscreen_path",route:[{x:-t.x/2-.1,y:t.y/2+.1-n},{x:-t.x/2-.1,y:t.y/2+.1},{x:t.x/2+.1,y:t.y/2+.1},{x:t.x/2+.1,y:t.y/2+.1-n}],stroke_width:t.y/30},{layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"",type:"pcb_silkscreen_path",route:[{x:-t.x/2-.1,y:-t.y/2-.1+n},{x:-t.x/2-.1,y:-t.y/2-.1},{x:t.x/2+.1,y:-t.y/2-.1},{x:t.x/2+.1,y:-t.y/2-.1+n}],stroke_width:t.y/30}]},Jwo=t=>{const{num_pins:e,bridged:n,p:o=2.54,pw:i=1.5,ph:r=1.5}=t,s=le.parse(o),a=le.parse(i),A=le.parse(r),c=Math.min(A/4,.5),l=[];for(let D=0;D<e;D++)l.push(Go(D+1,D*s,0,a,A));let g=[];if(n){const D=n.split("").map(Number);if(D.length>1)for(let R=0;R<D.length-1;R++){const M=D[R],L=D[R+1];if(typeof M=="number"&&typeof L=="number"&&!isNaN(M)&&!isNaN(L)){const G=(M-1)*s,O=(L-1)*s,U=Math.sign(O-G),W=G+U*(a/2),j=O-U*(a/2);g.push({type:"pcb_trace",pcb_trace_id:"",route:[{start_pcb_port_id:`{PIN${M}}`,x:W,y:0,width:c,layer:"top",route_type:"wire"},{end_pcb_port_id:`{PIN${L}}`,x:j,y:0,width:c,layer:"top",route_type:"wire"}]})}}}const u=(e-1)*s+a+.7,h=A+1,d=(e-1)*s/2,_=0,m={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"outline",route:[{x:d-u/2,y:_-h/2},{x:d+u/2,y:_-h/2},{x:d+u/2,y:_+h/2},{x:d-u/2,y:_+h/2},{x:d-u/2,y:_-h/2}],stroke_width:.15},I=_+h/2+.6,f=mi(d,I,.4),C=(e-1)*s,y=C/2+a/2,E=A/2,B=y+.5,Q=E+.5,b={type:"pcb_courtyard_rect",pcb_courtyard_rect_id:"",pcb_component_id:"",center:{x:C/2,y:0},width:2*B,height:2*Q,layer:"top"};return{circuitJson:[...l,...g,m,f,b],parameters:t}},X6t={fn:De("sot457"),num_pins:De(6).default(6),pillh:F().default("0.45mm"),pillw:F().default("1.45mm"),pl:F(),pw:F(),p:F(),wave:Fe().optional(),reflow:Fe().optional()},qwo=ui.extend({...X6t,h:F().default("2.5mm"),w:F().default("2.7mm"),pl:F().default("0.8mm"),pw:F().default("0.55mm"),p:F().default("0.95mm")}),Wwo=ui.extend({...X6t,h:F().default("3mm"),w:F().default("4mm"),pillr:F().default("0.225mm"),pl:F().default("1.45mm"),pw:F().default("1.5mm"),p:F().default("1.475mm")}).transform(t=>({...t,wave:t.wave??(t.reflow===void 0?!0:!t.reflow),reflow:t.reflow??(t.wave===void 0?!1:!t.wave)})),A5=t=>Number.parseFloat(t.replace("mm","")),$6t=({pitch:t,width:e,pinNumber:n})=>{const r={1:{x:-e/2-.1,y:t},2:{x:-e/2-.1,y:0},3:{x:-e/2-.1,y:-t},4:{x:e/2+.1,y:-t},5:{x:e/2+.1,y:0},6:{x:e/2+.1,y:t}}[n];if(!r)throw new Error(`Invalid pin number: ${n}`);return r},Z6t=t=>{const e=[],n=A5(t.p),o=A5(t.pl),i=A5(t.pw),r=A5(t.w),s=A5(t.h);if(t.wave){const _={1:({padWidth:m,padHeight:p})=>Go(1,-n,n,p,m),2:({padWidth:m,padHeight:p})=>Go(2,-n,-n,p,m),3:({padWidth:m,padHeight:p})=>Zie(3,-n,0,A5(t.pillw),A5(t.pillh)),4:({padWidth:m,padHeight:p})=>Zie(4,n,0,A5(t.pillw),A5(t.pillh)),5:({padWidth:m,padHeight:p})=>Go(5,n,n,p,m),6:({padWidth:m,padHeight:p})=>Go(6,n,-n,p,m)};for(let m=1;m<=t.num_pins;m++){const p=_[m];p&&e.push(p({padWidth:o,padHeight:i}))}}else for(let _=1;_<=t.num_pins;_++){const{x:m,y:p}=$6t({pitch:n,width:r,pinNumber:_});e.push(Go(_,m,p,o,i))}const a={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-r/3,y:s/2+n/1.3},{x:r/3,y:s/2+n/1.3}],stroke_width:.05},A={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_2",route:[{x:-r/3,y:-s/2-n/1.3},{x:r/3,y:-s/2-n/1.3}],stroke_width:.05},c=mi(0,s+.5,.3),l=$6t({pitch:n,width:r,pinNumber:1}),g=t.wave?1:.5,u=t.wave?.7:.3;l.x-=t.wave?i:i*1.7;const h={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"pin1_indicator",route:[{x:l.x+g/2,y:l.y},{x:l.x-g/2,y:l.y+u/2},{x:l.x-g/2,y:l.y-u/2},{x:l.x+g/2,y:l.y}],stroke_width:.05};let d;if(t.wave){const _=2*n,m=2*n,p=_/2+i/2,I=m/2+o/2,f=p+.25,C=I+.25;d={type:"pcb_courtyard_rect",pcb_courtyard_rect_id:"",pcb_component_id:"",center:{x:0,y:0},width:2*f,height:2*C,layer:"top"}}else{const m=r/2+.1+o/2,p=n+i/2,I=r/2,f=s/2,C=m+.25,y=I+.08,E=p+.25,B=Math.max(f+.45,E);d={type:"pcb_courtyard_outline",pcb_courtyard_outline_id:"",pcb_component_id:"",outline:n1([{minX:-C,maxX:C,minY:-E,maxY:E},{minX:-y,maxX:y,minY:-B,maxY:B}]),layer:"top"}}return[c,a,A,h,...e,d]},jwo=t=>{if(t.wave){const n=Wwo.parse({...t,fn:"sot457"});return{circuitJson:Z6t(n),parameters:n}}const e=qwo.parse(t);return{circuitJson:Z6t(e),parameters:e}},Xwo=[{x:-.8,y:.75},{x:.8,y:.75},{x:.8,y:-.75},{x:-.8,y:-.75}],$wo=ui.extend({fn:F(),num_pins:De(6).default(6),w:F().default("1.1mm"),h:F().default("1.45mm"),p:F().default("0.35mm"),pl:F().default("0.2mm"),pw:F().default("0.2mm"),string:F().optional()}),Zwo=t=>{const e=$wo.parse({...t,fn:"sot963"}),n=le.parse(e.w),o=le.parse(e.h),i=le.parse(e.p),r=le.parse(e.pl),s=le.parse(e.pw),a=[];for(let d=0;d<6;d++){const{x:_,y:m}=e8t(d+1,n,i,r);a.push(Go(d+1,_,m,r,s))}const A={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-n/2,y:o/2},{x:n/2,y:o/2}],stroke_width:.05,pcb_silkscreen_path_id:""},c={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-n/2,y:-o/2},{x:n/2,y:-o/2}],stroke_width:.05,pcb_silkscreen_path_id:""},l=e8t(1,n,i,r),g={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"pin_marker_1",route:[{x:l.x-r/2-.3,y:l.y},{x:l.x-r/2-.45,y:l.y+.15},{x:l.x-r/2-.45,y:l.y-.15},{x:l.x-r/2-.3,y:l.y}],stroke_width:.05,pcb_silkscreen_path_id:"pin_marker_1"},u=mi(0,o/2+.4,.25),h={type:"pcb_courtyard_outline",pcb_courtyard_outline_id:"",pcb_component_id:"",outline:Xwo,layer:"top"};return{circuitJson:[...a,A,c,u,g,h],parameters:e}},e8t=(t,e,n,o)=>{const i=e/2-o/2;return t<=3?{x:-i,y:n-(t-1)*n}:{x:i,y:-n+(t-4)*n}},eMo=ui.extend({fn:F(),num_pins:Rn([De(3),De(2)]).default(3),p:F().default("5mm"),id:F().default("1.25mm"),od:F().default("2.35mm"),ca:F().default("14mm").describe("Caliper axis (width or diameter of the potentiometer body or adjustment knob)"),w:F().default("5.35mm"),h:F().default("4mm"),string:F().optional()}),tMo=t=>{const{p:e,id:n,od:o,h:i}=t,r=Number.parseFloat(i),s=Number.parseFloat(e);return[qs(1,0,s,n,o),qs(2,r,0,n,o),qs(3,0,-s,n,o)]},nMo=t=>{const e=t.string?.match(/^potentiometer_(\d+)/),n=e?Number.parseInt(e[1],10):3,o=eMo.parse({...t,num_pins:n});let i=[];o.num_pins===3&&(i=tMo(o));const r=Number.parseFloat(o.ca)/2+.15,s=Number.parseFloat(o.w),a=Number.parseFloat(o.od)/2+.35,A={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:0,y:r-1.75},{x:0,y:r},{x:s,y:r},{x:s,y:a}],stroke_width:.1,pcb_silkscreen_path_id:""},c={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:s,y:-a},{x:s,y:-r},{x:0,y:-r},{x:0,y:-r+1.75}],stroke_width:.1,pcb_silkscreen_path_id:""},l=Number.parseFloat(o.w)/2,g=mi(l,r+1,.5),u=Number.parseFloat(o.od)/2,h=Number.parseFloat(o.h),d=Number.parseFloat(o.ca)/2,_=-(u+.25),m=h+u+.25,p=d+.25,I={type:"pcb_courtyard_rect",pcb_courtyard_rect_id:"",pcb_component_id:"",center:{x:(_+m)/2,y:0},width:m-_,height:2*p,layer:"top"};return{circuitJson:[...i,A,c,g,I],parameters:o}},oMo=ui.extend({fn:F(),p:le.optional().default("7.5mm"),id:le.optional().default("1mm"),od:le.optional().default("2mm"),d:le.optional().default("10.5mm")}),iMo=(t,e,n,o,i)=>{const r=[],s=[];for(let a=0;a<=50;a++){const A=a/50*Math.PI,c=t+Math.cos(A)*n,l=e+Math.sin(A)*n;c<t-o&&l>=e-i/2&&l<=e+i/2||r.push({x:c,y:l})}for(let a=0;a<=50;a++){const A=Math.PI+a/50*Math.PI,c=t+Math.cos(A)*n,l=e+Math.sin(A)*n;c<t-o&&l>=e-i/2&&l<=e+i/2||s.push({x:c,y:l})}return{topArc:r,bottomArc:s}},rMo=t=>{const e=oMo.parse(t),{p:n,id:o,od:i,d:r}=e,s=[vy({pn:1,x:-n/2,y:0,holeDiameter:o,rectPadWidth:i,rectPadHeight:i}),qs(2,n/2,0,o,i)],{topArc:a,bottomArc:A}=iMo(0,0,r/2+.1,i/2,i),c={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:a,stroke_width:.1,pcb_silkscreen_path_id:""},l={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:A,stroke_width:.1,pcb_silkscreen_path_id:""},g={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:0,y:r/2+.1},{x:0,y:-(r/2+.1)}],stroke_width:.1,pcb_silkscreen_path_id:""},u=-(r/2+.5),h=i/2+1.5,d=.5,_={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:u-d,y:h},{x:u+d,y:h}],stroke_width:.1,pcb_silkscreen_path_id:""},m={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:u,y:h-d},{x:u,y:h+d}],stroke_width:.1,pcb_silkscreen_path_id:""},p=mi(0,r/2+1,.5),I=r/2,f=n/2+i/2,y=Math.max(I,f)+.25,E={type:"pcb_courtyard_circle",pcb_courtyard_circle_id:"",pcb_component_id:"",center:{x:0,y:0},radius:y,layer:"top"};return{circuitJson:[...s,c,l,g,_,m,p,E],parameters:e}},sMo=ui.extend({fn:F(),num_pins:De(2).default(2),w:F().default("6.5mm"),h:F().default("3mm"),pl:F().default("1.75mm"),pw:F().default("2.40mm"),p:F().default("4.75mm")}),aMo=t=>{const e=sMo.parse(t),n=mi(0,le.parse(e.h)-.5,.3),o={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:le.parse(e.p)/2,y:le.parse(e.h)/2},{x:-le.parse(e.w)/2-.3,y:le.parse(e.h)/2},{x:-le.parse(e.w)/2-.3,y:-le.parse(e.h)/2},{x:le.parse(e.p)/2,y:-le.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""},s={type:"pcb_courtyard_rect",pcb_courtyard_rect_id:"",pcb_component_id:"",center:{x:0,y:0},width:7,height:3.5,layer:"top"};return{circuitJson:cMo(e).concat(o,n,s),parameters:e}},AMo=t=>{const{pn:e,p:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},cMo=t=>{const e=[],n=le.parse(t.p),o=le.parse(t.pl),i=le.parse(t.pw),r=.125;for(let s=1;s<=t.num_pins;s++){const{x:a,y:A}=AMo({pn:s,p:n});e.push(Go(s,a,A,o,i,r))}return e},lMo=[{x:-1.45,y:.98},{x:-.73,y:.98},{x:-.73,y:1.1},{x:.73,y:1.1},{x:.73,y:.33},{x:1.45,y:.33},{x:1.45,y:-.33},{x:.73,y:-.33},{x:.73,y:-1.1},{x:-.73,y:-1.1},{x:-.73,y:-.98},{x:-1.45,y:-.98},{x:-1.45,y:-.32},{x:-.73,y:-.32},{x:-.73,y:.32},{x:-1.45,y:.32}],gMo=ui.extend({fn:F(),num_pins:Ue().default(3),w:F().default("2.45mm"),h:F().default("2.40mm"),pl:F().default("0.92mm"),pw:F().default("0.45mm"),p:F().default("0.891mm"),string:F().optional()}),uMo=t=>{const e=t.string?.match(/^sot323_(\d+)/),n=e?Number.parseInt(e[1],3):3,o=gMo.parse({...t,num_pins:n});if(o.num_pins===3)return{circuitJson:hMo(o),parameters:o};throw new Error("Invalid number of pins")},dMo=t=>{const{pn:e,p:n}=t;return e===1?{x:-n,y:.65}:e===2?{x:-n,y:-.65}:{x:n,y:0}},hMo=t=>{const e=[];for(let A=0;A<t.num_pins;A++){const{x:c,y:l}=dMo({num_pins:t.num_pins,pn:A+1,w:Number.parseFloat(t.w),h:Number.parseFloat(t.h),pl:Number.parseFloat(t.pl),p:Number.parseFloat(t.p)});e.push(Go(A+1,c,l,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}const n=mi(0,Number.parseInt(t.h)/2+1,.3),o=Number.parseFloat(t.w)/2-Number.parseFloat(t.pl),i=Number.parseFloat(t.h)/2,r={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-o,y:i+.3},{x:o,y:i+.3},{x:o,y:i/2}],type:"pcb_silkscreen_path",stroke_width:.1},s={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_2",route:[{x:-o,y:-i-.3},{x:o,y:-i-.3},{x:o,y:-i/2}],type:"pcb_silkscreen_path",stroke_width:.1},a={type:"pcb_courtyard_outline",pcb_courtyard_outline_id:"",pcb_component_id:"",outline:lMo,layer:"top"};return[...e,r,s,n,a]},_Mo=ui.extend({fn:F(),circle:Fe().optional(),rect:Fe().optional(),square:Fe().optional(),pill:Fe().optional(),d:le.optional(),pd:le.optional(),diameter:le.optional(),r:le.optional(),pr:le.optional(),radius:le.optional(),w:le.optional(),pw:le.optional(),width:le.optional(),h:le.optional(),ph:le.optional(),height:le.optional(),s:le.optional(),size:le.optional(),string:F().optional()}).transform(t=>{let e="rect";t.circle&&(e="circle"),t.square&&(e="square"),t.rect&&(e="rect"),t.pill&&(e="pill");let n,o,i;return e==="circle"?t.r!==void 0?n=Oa(t.r):t.pr!==void 0?n=Oa(t.pr):t.radius!==void 0?n=Oa(t.radius):t.d!==void 0?n=Oa(t.d)/2:t.pd!==void 0?n=Oa(t.pd)/2:t.diameter!==void 0?n=Oa(t.diameter)/2:n=Oa("1mm")/2:(t.w!==void 0?o=Oa(t.w):t.pw!==void 0?o=Oa(t.pw):t.width!==void 0?o=Oa(t.width):t.s!==void 0?o=Oa(t.s):t.size!==void 0?o=Oa(t.size):o=Oa("1mm"),t.h!==void 0?i=Oa(t.h):t.ph!==void 0?i=Oa(t.ph):t.height!==void 0?i=Oa(t.height):e==="square"||e==="rect"?i=o:i=Oa("1mm")),{fn:t.fn,shape:e,radius:n,width:o,height:i}}),mMo=t=>{const e=_Mo.parse(t),{shape:n,radius:o,width:i,height:r}=e;let s,a;return n==="circle"?(s=M6t(1,{x:0,y:0,radius:o}),a=o+.5):n==="pill"?(s=Zie(1,0,0,i,r),a=Math.max(i,r)/2+.5):(s=Go(1,0,0,i,r),a=r/2+.5),{circuitJson:[s,mi(0,a,.2)],parameters:e}},pMo=ui.extend({fn:F(),d:le.optional(),hd:le.optional(),r:le.optional(),hr:le.optional(),pd:le.optional(),pr:le.optional(),squarepad:Fe().optional().default(!1)}).transform(t=>{let e;t.d!==void 0?e=Oa(t.d):t.hd!==void 0?e=Oa(t.hd):t.r!==void 0?e=Oa(t.r)*2:t.hr!==void 0?e=Oa(t.hr)*2:e=Oa("1mm");let n;return t.pd!==void 0?n=Oa(t.pd):t.pr!==void 0?n=Oa(t.pr)*2:n=e*(1.5/1),{fn:t.fn,d:e,pd:n,squarepad:t.squarepad??!1}}),IMo=t=>{const e=pMo.parse(t),{d:n,pd:o,squarepad:i}=e;return{circuitJson:[i?vy({pn:1,x:0,y:0,holeDiameter:n,rectPadWidth:o,rectPadHeight:o}):qs(1,0,0,n,o),mi(0,o/2+.5,.2)],parameters:e}},fMo=ui.extend({fn:F(),num_pins:De(6).default(6),h:F().default("1.3mm"),pl:F().default("1.325mm"),pw:F().default("0.6mm"),p:F().default("0.95mm")}),CMo=t=>{const e=fMo.parse(t);return{circuitJson:yMo(e),parameters:e}},t8t=t=>{const{p:e,h:n,pn:o}=t;if(o===1)return{x:-n/2-.4875,y:e};if(o===2)return{x:-n/2-.4875,y:0};if(o===3)return{x:-n/2-.4875,y:-e};if(o===4)return{x:n/2+.4875,y:-e};if(o===5)return{x:n/2+.4875,y:0};if(o===6)return{x:n/2+.4875,y:e};throw new Error("Invalid pin number")},yMo=t=>{const e=[];for(let B=1;B<=t.num_pins;B++){const{x:Q,y:b}=t8t({h:Number.parseFloat(t.h),p:Number.parseFloat(t.p),pn:B});e.push(Go(B,Q,b,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}const n=t.num_pins/2*Number.parseFloat(t.p),o=Number.parseFloat(t.h),i={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-n/3,y:o/2+Number.parseFloat(t.p)/1.3},{x:n/3,y:o/2+Number.parseFloat(t.p)/1.3}],type:"pcb_silkscreen_path",stroke_width:.05},r={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_2",route:[{x:-n/3,y:-o/2-Number.parseFloat(t.p)/1.3},{x:n/3,y:-o/2-Number.parseFloat(t.p)/1.3}],type:"pcb_silkscreen_path",stroke_width:.05},s=mi(0,o+.3,.3),a=t8t({h:Number.parseFloat(t.h),p:Number.parseFloat(t.p),pn:1});a.x=a.x-Number.parseFloat(t.pw)*1.5;const A=.7,c=.3,l={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"pin1_indicator",route:[{x:a.x+A/2-.2,y:a.y},{x:a.x-A/2,y:a.y+c/2},{x:a.x-A/2,y:a.y-c/2},{x:a.x+A/2-.2,y:a.y}],stroke_width:.05},g=Number.parseFloat(t.h),u=Number.parseFloat(t.p),h=Number.parseFloat(t.pl),d=Number.parseFloat(t.pw),_=g/2+.4875,m=u*2+d,p=_+h/2,I=g/2+.4,f=p+.25,C=m/2+.25,y=C+.2,E={type:"pcb_courtyard_outline",pcb_courtyard_outline_id:"",pcb_component_id:"",layer:"top",outline:n1([{minX:-f,maxX:f,minY:-C,maxY:C},{minX:-I,maxX:I,minY:-y,maxY:y}])};return[...e,s,i,r,l,E]},EMo=[{x:-1.703,y:.98},{x:-.983,y:.98},{x:-.983,y:1.1},{x:.477,y:1.1},{x:.477,y:.98},{x:1.197,y:.98},{x:1.197,y:-.98},{x:.477,y:-.98},{x:.477,y:-1.1},{x:-.983,y:-1.1},{x:-.983,y:-.98},{x:-1.703,y:-.98}],xMo=ui.extend({fn:F(),num_pins:Ue().default(4),w:F().default("3.2mm"),h:F().default("2.6mm"),pl:F().default("1.05mm"),pw:F().default("0.45mm"),p:F().default("0.55mm"),string:F().optional()}),BMo=t=>{const e=t.string?.match(/^sot343_(\d+)/),n=e?Number.parseInt(e[1],4):4,o=xMo.parse({...t,num_pins:n});if(o.num_pins===4)return{circuitJson:SMo(o),parameters:o};throw new Error("Invalid number of pins")},QMo=t=>{const{pn:e,p:n}=t;return e===1?{x:-n*1.92,y:-.65}:e===2?{x:-n*1.92,y:.65}:e===3?{x:n,y:.65}:e===4?{x:n,y:-.65}:{x:0,y:0}},SMo=t=>{const e=[],n=Number.parseFloat(t.w),o=Number.parseFloat(t.h),i=Number.parseFloat(t.pl),r=Number.parseFloat(t.pw),s=Number.parseFloat(t.p);let a=1/0,A=-1/0,c=1/0,l=-1/0;for(let C=0;C<t.num_pins;C++){const{x:y,y:E}=QMo({num_pins:t.num_pins,pn:C+1,p:s});e.push(Go(C+1,y,E,i,r)),y<a&&(a=y),y>A&&(A=y),E<c&&(c=E),E>l&&(l=E)}const g=(a+A)/2,u=l-c,h=o*.3,d=u/2+h;let _=n*.8;o<=2.6&&(_/=2);const m=mi(g,d+.5,.3),p={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_top",route:[{x:g-_/2,y:d},{x:g+_/2,y:d}],type:"pcb_silkscreen_path",stroke_width:.1},I={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_bottom",route:[{x:g-_/2,y:-d},{x:g+_/2,y:-d}],type:"pcb_silkscreen_path",stroke_width:.1},f={type:"pcb_courtyard_outline",pcb_courtyard_outline_id:"",pcb_component_id:"",outline:EMo,layer:"top"};return[...e,p,I,m,f]},bMo=ui.extend({fn:F()}),DMo=t=>{const e=bMo.parse(t),n=[],o=.5-.15,i=1.5,s=.5/2,a=75,A=-37/2;for(let B=0;B<a;B++){const Q=B+1;if(Q>=24&&Q<=31)continue;const b=A-B*s,D=Q%2===0,R=i+(D?.25:0),L=.5-R/2,G=Go(Q,L,b,R,o);G.layer=D?"bottom":"top",n.push(G)}const c=46*.0254,l=137*.0254,g=261*.0254,u={type:"pcb_cutout",pcb_cutout_id:"",shape:"rect",center:{x:-l/2+i/2,y:A-g},width:l,height:c},h={x:-.5,y:A},d={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"pin_marker_1",route:[{x:h.x-.4,y:h.y},{x:h.x-.7,y:h.y+.3},{x:h.x-.7,y:h.y-.3},{x:h.x-.4,y:h.y}],stroke_width:.05,pcb_silkscreen_path_id:"pin_marker_1"};let _=1/0,m=-1/0,p=1/0,I=-1/0;const f=(B,Q,b=0,D=0)=>{_=Math.min(_,B-b/2),m=Math.max(m,B+b/2),p=Math.min(p,Q-D/2),I=Math.max(I,Q+D/2)};for(const B of n){const Q=B;f(Q.x,Q.y,Q.width,Q.height)}f(u.center.x,u.center.y,u.width,u.height);for(const B of d.route)f(B.x,B.y);const C=(_+m)/2,y=(p+I)/2,E=B=>{typeof B.x=="number"&&(B.x-=C),typeof B.y=="number"&&(B.y-=y),B.center&&(B.center.x-=C,B.center.y-=y),Array.isArray(B.route)&&(B.route=B.route.map(Q=>({x:Q.x-C,y:Q.y-y})))};for(const B of n)E(B);return E(u),E(d),{circuitJson:[...n,u,d],parameters:e}},vMo=ui.extend({fn:F(),numPins:Ue().optional().default(0),rows:Rn([F(),Ue()]).transform(t=>Number(t)).optional().default(1).describe("number of rows"),p:le.default("2.54mm").describe("pitch"),id:le.default("1.0mm").describe("inner diameter"),od:le.default("1.5mm").describe("outer diameter"),male:Fe().optional().describe("the module uses male headers"),nopin:Fe().optional().default(!1).describe("omit pins rendering"),female:Fe().optional().describe("the module uses female headers"),smd:Fe().optional().describe("surface mount device"),pinlabeltextalignleft:Fe().optional().default(!1),pinlabeltextaligncenter:Fe().optional().default(!1),pinlabeltextalignright:Fe().optional().default(!1),pinlabelverticallyinverted:Fe().optional().default(!1),pinlabelorthogonal:Fe().optional().default(!1),nopinlabels:Fe().optional().default(!1).describe("omit silkscreen pin labels"),doublesidedpinlabel:Fe().optional().default(!1).describe("add silkscreen pins in top and bottom layers"),bottomsidepinlabel:Fe().optional().default(!1).describe("place the silkscreen reference text on the bottom layer instead of top"),pinRowSide:qt(["left","right","top","bottom"]).optional().default("left"),pinrowleft:Fe().optional().default(!1),pinrowright:Fe().optional().default(!1),pinrowtop:Fe().optional().default(!1),pinrowbottom:Fe().optional().default(!1),pinrowleftpins:Rn([F(),Ue()]).transform(t=>Number(t)).optional(),pinrowrightpins:Rn([F(),Ue()]).transform(t=>Number(t)).optional(),pinrowtoppins:Rn([F(),Ue()]).transform(t=>Number(t)).optional(),pinrowbottompins:Rn([F(),Ue()]).transform(t=>Number(t)).optional(),width:le.optional(),height:le.optional(),pinRowHoleEdgeToEdgeDist:le.default("2mm"),holes:Rn([F(),Qt(F())]).optional().transform(t=>!t||Array.isArray(t)?t:t.startsWith("(")&&t.endsWith(")")?t.slice(1,-1).split(",").map(e=>e.trim()):[t]),holeXDist:le.optional(),holeYDist:le.optional(),holeInset:le.default("1mm"),pinrow:Rn([F(),Ue()]).optional(),usbposition:qt(["left","right","top","bottom"]).optional().default("left"),usbleft:Fe().optional().default(!1),usbtop:Fe().optional().default(!1),usbright:Fe().optional().default(!1),usbbottom:Fe().optional().default(!1),usbtype:qt(["micro","c"]).optional(),usbmicro:Fe().optional().default(!1),usbc:Fe().optional().default(!1),screen:Fe().optional().default(!1).describe("add silkscreen outline for screen/display area"),screenwidth:le.optional(),screenheight:le.optional(),screencenteroffsetx:le.optional(),screencenteroffsety:le.optional()}).transform(t=>{const e=O6t(t);let n=t.pinRowSide;t.pinrowleft&&(n="left"),t.pinrowright&&(n="right"),t.pinrowtop&&(n="top"),t.pinrowbottom&&(n="bottom");let o=t.usbposition;t.usbleft&&(o="left"),t.usbtop&&(o="top"),t.usbright&&(o="right"),t.usbbottom&&(o="bottom");let i=t.usbtype;t.usbmicro&&(i="micro"),t.usbc&&(i="c"),t.pinrow!==void 0&&(t.numPins=Number(t.pinrow));const r={left:t.pinrowleftpins,right:t.pinrowrightpins,top:t.pinrowtoppins,bottom:t.pinrowbottompins},s=Object.values(r).some(C=>C!==void 0&&C>0),a=(r.left??0)>0&&(r.right??0)>0,A=(r.top??0)>0&&(r.bottom??0)>0;s&&((r.left??0)>0?n="left":(r.right??0)>0?n="right":(r.top??0)>0?n="top":(r.bottom??0)>0&&(n="bottom"),t.numPins=(r.left??0)+(r.right??0)+(r.top??0)+(r.bottom??0));const c=Math.ceil(t.numPins/t.rows),l=Math.max(r.left??0,r.right??0),g=Math.max(r.top??0,r.bottom??0);let u,h;if(s){const C=a?t.p:0,y=A?t.p:0;u=(g>0?(g-1)*t.p:0)+2*t.pinRowHoleEdgeToEdgeDist+C,h=(l>0?(l-1)*t.p:0)+2*t.pinRowHoleEdgeToEdgeDist+y}else n==="left"||n==="right"?(u=(t.rows-1)*t.p+2*t.pinRowHoleEdgeToEdgeDist,h=(c-1)*t.p+2*t.pinRowHoleEdgeToEdgeDist):(h=(t.rows-1)*t.p+2*t.pinRowHoleEdgeToEdgeDist,u=(c-1)*t.p+2*t.pinRowHoleEdgeToEdgeDist);t.numPins===0&&(u=10,h=10);const d=t.width??u,_=t.height??h,m=t.screenwidth??d*.95,p=t.screenheight??_*.95,I=t.screencenteroffsetx??0,f=t.screencenteroffsety??0;return{...t,pinlabelAnchorSide:e,pinRowSide:n,usbposition:o,usbtype:i,male:t.male??!t.female,female:t.female??!1,width:d,height:_,screenwidth:m,screenheight:p,screencenteroffsetx:I,screencenteroffsety:f,pinrowleftpins:r.left,pinrowrightpins:r.right,pinrowtoppins:r.top,pinrowbottompins:r.bottom}}).superRefine((t,e)=>{t.male&&t.female&&e.addIssue({code:Nn.custom,message:"'male' and 'female' cannot both be true; it should be male or female.",path:["male","female"]})}),PMo=t=>{const e=vMo.parse(t),{p:n,id:o,od:i,rows:r,numPins:s,pinlabelAnchorSide:a,pinlabelverticallyinverted:A,pinlabelorthogonal:c,pinlabeltextalignleft:l,pinlabeltextalignright:g,nopinlabels:u,doublesidedpinlabel:h,bottomsidepinlabel:d,pinRowSide:_,width:m,height:p,pinRowHoleEdgeToEdgeDist:I,holes:f,holeXDist:C,holeYDist:y,holeInset:E,pinrowleftpins:B,pinrowrightpins:Q,pinrowtoppins:b,pinrowbottompins:D,usbposition:R,usbtype:M,screen:L,screenwidth:G,screenheight:O,screencenteroffsetx:U,screencenteroffsety:W}=e;let j="center";l?j="left":g&&(j="right");const te=[],ie={left:B,right:Q,top:b,bottom:D},$=Object.values(ie).some(ae=>ae!==void 0&&ae>0),Z=(ae,ce,fe,Ce)=>{if(e.smd?te.push(Go(ae,ce,fe,e.od,e.od)):ae===1?te.push(vy({pn:ae,x:ce,y:fe,holeDiameter:o,rectPadWidth:i,rectPadHeight:i})):te.push(qs(ae,ce,fe,o,i)),!u){const xe=ce+(Ce==="left"?-i:Ce==="right"?i:0),de=fe+(Ce==="top"?i:Ce==="bottom"?-i:0);d||te.push(P6({fs:i/5,pn:ae,anchor_x:xe,anchor_y:de,textalign:j,orthogonal:c,verticallyinverted:A,layer:"top"})),(h||d)&&te.push(P6({fs:i/5,pn:ae,anchor_x:xe,anchor_y:de,textalign:j,orthogonal:c,verticallyinverted:A,layer:"bottom"}))}};if($){const ae=n;let ce=1;const fe=ie.left??0,Ce=ie.right??0,xe=ie.top??0,de=ie.bottom??0,Ee=(he,ve)=>{if(!(ve<=0))if(he==="left"||he==="right"){const Re=he==="left"?-m/2+I:m/2-I,ze=(ve-1)/2*ae;for(let Ie=0;Ie<ve;Ie++)Z(ce,Re,ze-Ie*ae,he),ce++}else{const Re=he==="top"?p/2-I:-p/2+I,ze=-((ve-1)/2)*ae;for(let Ie=0;Ie<ve;Ie++)Z(ce,ze+Ie*ae,Re,he),ce++}};Ee("left",fe),Ee("right",Ce),Ee("top",xe),Ee("bottom",de)}else{const ae=n;let ce=0,fe=0,Ce=0,xe=0,de=0,Ee=0;const he=Math.ceil(s/r);_==="left"||_==="right"?(ce=_==="left"?-m/2+I:m/2-I,fe=(he-1)/2*ae,Ce=0,xe=-ae,de=_==="left"?ae:-ae,Ee=0):(ce=-(he-1)/2*ae,fe=_==="top"?p/2-I:-p/2+I,Ce=ae,xe=0,de=0,Ee=_==="top"?-ae:ae);let ve=1;for(let Re=0;Re<r&&ve<=s;Re++)for(let ze=0;ze<he&&ve<=s;ze++){const Ie=ce+ze*Ce+Re*de,We=fe+ze*xe+Re*Ee;if(e.smd?te.push(Go(ve,Ie,We,e.od,e.od)):ve===1?te.push(vy({pn:ve,x:Ie,y:We,holeDiameter:o,rectPadWidth:i,rectPadHeight:i})):te.push(qs(ve,Ie,We,o,i)),!u){const Me=Ie+(_==="left"?-i:_==="right"?i:0),Te=We+(_==="top"?i:_==="bottom"?-i:0);d||te.push(P6({fs:i/5,pn:ve,anchor_x:Me,anchor_y:Te,textalign:j,orthogonal:c,verticallyinverted:A,layer:"top"})),(h||d)&&te.push(P6({fs:i/5,pn:ve,anchor_x:Me,anchor_y:Te,textalign:j,orthogonal:c,verticallyinverted:A,layer:"bottom"}))}ve++}}if(f)for(const ae of f){let ce=0,fe=0;ae==="topleft"?(ce=-m/2+E,fe=p/2-E):ae==="topright"?(ce=m/2-E,fe=p/2-E):ae==="bottomleft"?(ce=-m/2+E,fe=-p/2+E):ae==="bottomright"?(ce=m/2-E,fe=-p/2+E):ae==="center"&&(ce=0,fe=0),C!==void 0&&(ce+=C),y!==void 0&&(fe+=y),te.push(qs(s+f.indexOf(ae)+1,ce,fe,o,i))}if(!e.nosilkscreen){const ae=[{x:-m/2,y:-p/2},{x:m/2,y:-p/2},{x:m/2,y:p/2},{x:-m/2,y:p/2},{x:-m/2,y:-p/2}];te.push(w6(ae,{stroke_width:.1,layer:"top"}))}const se=mi(0,p/2+1,.5);if(te.push(se),R&&M){let ae,ce;if(M==="c")ae=8,ce=3;else if(M==="micro")ae=6,ce=2;else return{circuitJson:te,parameters:e};let fe;if(R==="left")fe=[{x:-m/2,y:-ae/2},{x:-m/2+ce,y:-ae/2},{x:-m/2+ce,y:ae/2},{x:-m/2,y:ae/2},{x:-m/2,y:-ae/2}];else if(R==="right")fe=[{x:m/2-ce,y:-ae/2},{x:m/2,y:-ae/2},{x:m/2,y:ae/2},{x:m/2-ce,y:ae/2},{x:m/2-ce,y:-ae/2}];else if(R==="top")fe=[{x:-ae/2,y:p/2-ce},{x:ae/2,y:p/2-ce},{x:ae/2,y:p/2},{x:-ae/2,y:p/2},{x:-ae/2,y:p/2-ce}];else if(R==="bottom")fe=[{x:-ae/2,y:-p/2},{x:ae/2,y:-p/2},{x:ae/2,y:-p/2+ce},{x:-ae/2,y:-p/2+ce},{x:-ae/2,y:-p/2}];else return{circuitJson:te,parameters:e};te.push(w6(fe,{stroke_width:.1,layer:"top"}))}if(L){const ae=G/2,ce=O/2,fe=U,Ce=W,xe=[{x:-ae+fe,y:-ce+Ce},{x:ae+fe,y:-ce+Ce},{x:ae+fe,y:ce+Ce},{x:-ae+fe,y:ce+Ce},{x:-ae+fe,y:-ce+Ce}];te.push(w6(xe,{stroke_width:.05,layer:"top"}))}return{circuitJson:te,parameters:e}},wMo=[{x:-1.45,y:2.75},{x:-1.45,y:-1.85},{x:4.05,y:-1.85},{x:4.05,y:2.75}],MMo=[{x:-1.55,y:2.75},{x:-1.55,y:-1.85},{x:3.95,y:-1.85},{x:3.95,y:2.75}],NMo=ui.extend({fn:F(),num_pins:Ue().default(3),inline:Fe().default(!1),p:F().default("1.27mm"),id:F().default("0.75mm"),od:F().default("1.3mm"),w:F().default("4.8mm"),h:F().default("4.0mm")}),RMo=t=>{const e=NMo.parse(t),n=Number.parseFloat(e.p),o=Number.parseFloat(e.w),i=Number.parseFloat(e.h),r=e.inline?1.05:Number.parseFloat(e.od),s=e.inline?1.5:r,a=[vy({pn:1,x:0,y:0,holeDiameter:e.id,rectPadWidth:r,rectPadHeight:s}),e.inline?TP(2,n,0,Number.parseFloat(e.id),r,s):qs(2,n,n,e.id,r),e.inline?TP(3,n*2,0,Number.parseFloat(e.id),r,s):qs(3,n*2,0,e.id,r)],A=o/2,c=e.inline?n-.09:n,l=.2,g=l+A-i,u=Array.from({length:32},(m,p)=>{const I=Math.PI*p/31;return{x:c+A*Math.cos(I),y:l+A*Math.sin(I)}}),h={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"",stroke_width:.12,route:[...u,{x:c-A,y:g},{x:c+A,y:g},u[0]]},d=mi(c,l+A+1,.5),_={type:"pcb_courtyard_outline",pcb_courtyard_outline_id:"",pcb_component_id:"",outline:e.inline?MMo:wMo,layer:"top"};return{circuitJson:[...a,h,d,_],parameters:e}},TMo=(t,e)=>{const n=t.filter(o=>o.type==="pcb_silkscreen_text");if(n.length===0)return t;for(const o of n)e.norefdes&&(o.text="");return t},kMo=(t,e)=>e.nosilkscreen?t.filter(n=>n.type!=="pcb_silkscreen_path"&&n.type!=="pcb_silkscreen_text"):t,FMo=(t,e)=>{if(!e)return t;const n=t.filter(l=>l.type==="pcb_smtpad"||l.type==="pcb_plated_hole");if(n.length===0)return t;let o=Number.POSITIVE_INFINITY,i=Number.NEGATIVE_INFINITY,r=Number.POSITIVE_INFINITY,s=Number.NEGATIVE_INFINITY;const a=(l,g,u=0,h=0)=>{const d=l-u/2,_=l+u/2,m=g-h/2,p=g+h/2;o=Math.min(o,d),i=Math.max(i,_),r=Math.min(r,m),s=Math.max(s,p)};for(const l of n)if(l.type==="pcb_smtpad"){const g=l.shape==="circle"?l.radius*2:l.width,u=l.shape==="circle"?l.radius*2:l.height;a(l.x,l.y,g,u)}else if(l.type==="pcb_plated_hole"){const g=l.outer_diameter??l.hole_diameter;a(l.x,l.y,g,g)}let A=0,c=0;switch(e){case"center":A=(o+i)/2,c=(r+s)/2;break;case"bottomleft":A=o,c=r;break;case"bottomcenter":case"centerbottom":A=(o+i)/2,c=r;break;case"topcenter":case"centertop":A=(o+i)/2,c=s;break;case"leftcenter":case"centerleft":A=o,c=(r+s)/2;break;case"rightcenter":case"centerright":A=i,c=(r+s)/2;break;case"pin1":{const l=n.find(g=>g.port_hints?.[0]==="1")||n[0];A=l.x,c=l.y;break}}if(A===0&&c===0)return t;for(const l of t){if(typeof l.x=="number"&&(l.x-=A),typeof l.y=="number"&&(l.y-=c),l.center&&typeof l.center.x=="number"&&(l.center.x-=A,l.center.y-=c),l.type==="pcb_silkscreen_path")for(const g of l.route)g.x-=A,g.y-=c;l.type==="pcb_silkscreen_text"&&l.anchor_position&&(l.anchor_position.x-=A,l.anchor_position.y-=c)}return t};function LMo(t){return t!=null}var HMo=t=>t.trim().replace(/^pinheader(?=[\d_]|$)/i,"pinrow").replace(/^sot23-(\d+)(?=_|$)/i,"sot23_$1").replace(/^sot-223-(\d+)(?=_|$)/i,"sot223_$1").replace(/^to-220f-(\d+)(?=_|$)/i,"to220f_$1").replace(/^jst_(ph|sh|zh)_(\d+)(?=_|$)/i,"jst$2_$1"),GMo=t=>{let e=nre();const n=HMo(t),i=n.replace(/^((?:\d{4}|\d{5}))(?=$|_|x)/,"res$1").replace(/^zh(\d+)(?:$|_)/,"jst$1_zh").split(/_(?!metric)/).map(r=>{const s=r.match(/([a-zA-Z]+)([\(\d\.\+\?].*)?/);if(!s)return null;const[,a,A]=s;if(!a)return null;const c=a.toLowerCase();return A?.includes("?")?null:{fn:c,v:A}}).filter(LMo);for(const{fn:r,v:s}of i)e=e[r](s);return e.setString(n),e},OMo=()=>Object.keys(a5),nre=()=>{const t=new Proxy({},{get:(e,n)=>{if(n==="soup"||n==="circuitJson"){if("fn"in e&&a5[e.fn])return()=>{const{circuitJson:o}=a5[e.fn](e),i=kMo(o,e),r=TMo(i,e);return FMo(r,e.origin)};if(!a5[e.fn])throw new Error(`Invalid footprint function, got "${e.fn}"${e.string?`, from string "${e.string}"`:""}`);return()=>{throw new Error(`No function found for footprinter, make sure to specify .dip, .lr, .p, etc. Got "${n}"`)}}if(n==="json"){if(!a5[e.fn])throw new Error(`Invalid footprint function, got "${e.fn}"${e.string?`, from string "${e.string}"`:""}`);return()=>a5[e.fn](e).parameters}return n==="getFootprintNames"?()=>Object.keys(a5):n==="params"?()=>e:n==="setString"?o=>(e.string=o,t):o=>(Object.keys(e).length===0?`${n}${o}`in a5?(e[`${n}${o}`]=!0,e.fn=`${n}${o}`):(e[n]=!0,e.fn=n,n==="res"||n==="cap"||n==="led"||n==="diode"?o&&(typeof o=="string"&&o.includes("_metric")?e.metric=o.split("_metric")[0]:e.imperial=o):e.num_pins=Number.isNaN(Number.parseFloat(o))?void 0:Number.parseFloat(o)):!o&&["w","h","p"].includes(n)||(e[n]=o??!0),t)}});return t};nre.string=GMo,nre.getFootprintNames=OMo;var KMo=nre,n8t=Symbol("Fragment");function s3e(t,e,...n){const o=n.length?n:e?.children!==void 0?[e.children]:[],i=[],r=(Array.isArray(o)?o:[o]).flat(1/0);for(const s of r)s==null||s===!1||(Array.isArray(s)?i.push(...s):i.push(s));return{type:t,props:(e&&e.children!==void 0?{...e,children:void 0}:e)||{},children:i}}var Jt=Symbol("Cuboid"),o8t=Symbol("Cube"),_A=Symbol("Cylinder"),ore=Symbol("Sphere"),NI=Symbol("RoundedCuboid"),jo=Symbol("Translate"),o0=Symbol("Rotate"),T_=Symbol("Union"),k_=Symbol("Subtract"),_c=Symbol("Hull"),ir=Symbol("Colorize"),WT=Symbol("Polygon"),jT=Symbol("ExtrudeLinear"),Py=Symbol("RoundedCylinder"),Oi=n8t,Ye=(t,e,n)=>s3e(t,e),Mn=(t,e,n)=>s3e(t,e),UMo=({hole:t,isPin1:e})=>{const n=e?"#00ff00":"#b87333";if(t.shape==="circle")return Ye(ir,{color:n,children:Ye(jo,{offset:[t.x,t.y,-.005],children:Mn(k_,{children:[Ye(_A,{radius:t.outer_diameter/2,height:.01}),Ye(_A,{radius:t.hole_diameter/2,height:.01})]})})});if(t.shape==="circular_hole_with_rect_pad")return Ye(ir,{color:n,children:Ye(jo,{offset:[t.x,t.y,0],children:Mn(k_,{children:[Ye(Jt,{size:[t.rect_pad_width,t.rect_pad_height,.01],center:[0,0,0]}),Ye(_A,{radius:t.hole_diameter/2,height:.01})]})})});if(t.shape==="pill"){const o=t.outer_width,i=t.outer_height,r=Math.min(o,i)/2,s=o>i,a=t.hole_width??.8,A=t.hole_height??.8;return Ye(ir,{color:n,children:Ye(jo,{offset:[t.x,t.y,0],children:Mn(k_,{children:[Mn(_c,{children:[Ye(_A,{radius:r,height:.01,center:[s?-(o/2-r):0,s?0:-(i/2-r),0]}),Ye(_A,{radius:r,height:.01,center:[s?o/2-r:0,s?0:i/2-r,0]})]}),a===A?Ye(_A,{radius:a/2,height:.01}):Mn(_c,{children:[Ye(_A,{radius:Math.min(a,A)/2,height:.01,center:[a>A?-(a/2-A/2):0,a>A?0:-(A/2-a/2),0]}),Ye(_A,{radius:Math.min(a,A)/2,height:.01,center:[a>A?a/2-A/2:0,a>A?0:A/2-a/2,0]})]})]})})})}throw new Error("Shape not supported: "+t.shape)},i0=({center:t,width:e,length:n,height:o,heightAboveSurface:i=.15,color:r="#555",taperRatio:s=.12,faceRatio:a=.75,straightHeightRatio:A=.5,includeNotch:c=!0,notchRadius:l,notchPosition:g,notchRotation:u=[0,0,0],notchLength:h=.5,notchWidth:d=.25,chamferSize:_=0})=>{const m=o*A,p=o-m,I=Math.min(e,n)*s,f=Math.max(e-I,e*a),C=Math.max(n-I,n*a),y=Math.min(e,n)*.12,E=l??y,B={x:0,y:n/2-E*.25,z:o},Q=g??B,b=Mn(T_,{children:[Mn(_c,{children:[Ye(jo,{z:.005,children:Ye(Jt,{size:[f,C,.01]})}),Ye(jo,{z:m,children:Ye(Jt,{size:[e,n,.01]})})]}),Mn(_c,{children:[Ye(jo,{z:m,children:Ye(Jt,{size:[e,n,.01]})}),Ye(jo,{z:m+p,children:Ye(Jt,{size:[f,C,.01]})})]})]}),D=(M,L)=>Ye(jo,{offset:{x:M,y:L,z:0},children:Ye(o0,{rotation:[0,0,Math.PI/4],children:Ye(Jt,{size:[_*Math.SQRT2,_*Math.SQRT2,o*3]})})});let R=b;if(_>0){const M=e/2,L=n/2;R=Mn(k_,{children:[b,D(M,L),D(-M,L),D(M,-L),D(-M,-L)]})}return Ye(ir,{color:r,children:Ye(jo,{offset:t,children:Ye(jo,{offset:{x:0,y:0,z:i},children:c?Mn(k_,{children:[R,Ye(jo,{offset:Q,children:Ye(o0,{rotation:u,children:Ye(_A,{radius:E,height:d})})})]}):R})})})},YMo=t=>Array.from({length:t},(e,n)=>n);function a3e(t,e){if(t.length<2)throw new Error("Stroke must have at least two points");const n=Array.isArray(t[0])?t.map(([l,g])=>({x:l,y:g})):t,o=e/2,i=[],r=[];function s(l,g){const u=g.x-l.x,h=g.y-l.y,d=Math.sqrt(u*u+h*h);return{x:-h/d,y:u/d}}function a(l,g,u){const h={x:l.x+g.x*o*u,y:l.y+g.y*o*u};u>0?i.push(h):r.unshift(h)}const A=s(n[0],n[1]);a(n[0],A,1),a(n[0],A,-1);for(let l=1;l<n.length-1;l++){const g=n[l-1],u=n[l],h=n[l+1],d=s(g,u),_=s(u,h),m=d.x+_.x,p=d.y+_.y,I=Math.sqrt(m*m+p*p);if(I/2>2*o)a(u,d,1),a(u,_,1),a(u,d,-1),a(u,_,-1);else{const C=1/I;a(u,{x:m*C,y:p*C},1),a(u,{x:m*C,y:p*C},-1)}}const c=s(n[n.length-2],n[n.length-1]);return a(n[n.length-1],c,1),a(n[n.length-1],c,-1),[...i,...r]}var zMo=t=>{const e=Math.min(...t.map(a=>a.x)),n=Math.max(...t.map(a=>a.x)),o=Math.min(...t.map(a=>a.y)),s=5.47/(Math.max(...t.map(a=>a.y))-o);return t.map(a=>({x:(a.x-e-(n-e)/2)*s,y:(a.y-o)*s}))},VMo=zMo([{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}]),i8t=5.47,ire=.5,JMo=({x:t,y:e,z:n})=>{const o=t>0;return Mn(Oi,{children:[Ye(jo,{offset:{x:t+.25/2,y:e,z:n},children:Ye(o0,{rotation:["-90deg",0,"90deg"],children:Ye(jT,{height:.25,children:Ye(WT,{points:VMo.slice().reverse().map(i=>[i.x,i.y])})})})}),Ye(jo,{offset:{x:t,y:e+(o?1:-1),z:n},children:Ye(o0,{rotation:["-90deg","90deg",o?"180deg":"0deg"],children:Ye(jT,{height:2,children:Ye(WT,{points:a3e([[0,0],[-1,0],[-1,-1]],.25).map(i=>[i.x,i.y])})})})})]})},qMo=({numPins:t=8,pitch:e=2.54,bodyWidth:n=6.4,rowSpacing:o})=>{const i=Math.floor(t/2),r=o??(n>=7?n:n+1.22),s=n>=7?r-1.22:n;return Mn(Oi,{children:[YMo(t).map(a=>{const A=a%i,c=(Math.floor(a/i)-.5)*2;return Ye(JMo,{x:c*r/2,y:A*e-(i-1)/2*e,z:i8t/2+ire})}),Ye(i0,{width:s,length:i*e+.5,height:i8t-ire,heightAboveSurface:ire,center:{x:0,y:0,z:ire}})]})};function WMo(t,{height:e,padContactLength:n,curveLength:o,bodyDistance:i,steepness:r=10}){o||(o=i*.3);let s=i-n-o;s<0&&(o+=s,s=0);const a=n*.75,A=n+o+(i-n-o)*.25;if(t<=a)return 0;if(t>=A)return e;const c=(t-a)/(A-a);return e/(1+Math.exp(-r*(c-.5)))}var Tr=t=>{const{thickness:e,width:n,padContactLength:o,bodyDistance:i,height:r,rotation:s}=t,a=15,A=Array.from({length:a}).map((l,g)=>g/(a-1)*i).map(l=>[l,WMo(l,t)]),c=a3e(A,e);return Ye(ir,{color:"#fff",children:Ye(jo,{offset:{z:0,y:0,x:0,...t.position},children:Ye(o0,{rotation:["90deg",0,s??0],children:Ye(jo,{offset:{x:0,y:0,z:-n/2},children:Ye(jT,{height:n,children:Ye(WT,{points:c.map(l=>[l.x,l.y])})})})})})})},jMo=({pinCount:t,leadLength:e,leadWidth:n,pitch:o,bodyWidth:i})=>{const r=Math.ceil(t/2),s=r<=4,a=(r-1)*o/2,A=o*Math.max(r-1,0)+(s?1.5:1.15),c=i-(s?.66:.58),l=.15,g=.8,u=1.22,h=e*.5,d=h+Math.max(.22,Math.min(.4,e*.65)),_=i/2+e/2,m=d*.1,p=Math.min(Math.min(c,A)*.18,1),I=Math.min(Math.min(c,A)*.12,.45);return Mn(Oi,{children:[Array.from({length:r}).map((f,C)=>Ye(Tr,{position:{x:-_,y:C*o-a,z:l/2},width:n,thickness:l,padContactLength:h,bodyDistance:d,curveLength:m,height:g})),Array.from({length:r}).map((f,C)=>Ye(Tr,{rotation:Math.PI,position:{x:_,y:C*o-a,z:l/2},width:n,thickness:l,padContactLength:h,bodyDistance:d,curveLength:m,height:g})),Ye(i0,{center:{x:0,y:0,z:0},width:c,length:A,height:u,notchPosition:{x:-(c/2-p-.2),y:A/2-p-.2,z:u},notchRadius:I})]})},XMo=({pinCount:t,padContactLength:e=.4,leadWidth:n=.2,pitch:o=.65,bodyWidth:i=3})=>{const r=Math.ceil(t/2),s=(r-1)*o/2,a=.2;return Mn(Oi,{children:[Array.from({length:r}).map((A,c)=>Ye(Tr,{position:{x:-i/2-e-.3,y:c*o-s,z:a/2},width:n,thickness:a,padContactLength:e,bodyDistance:e+.4,height:.6})),Array.from({length:r}).map((A,c)=>Ye(Tr,{rotation:Math.PI,position:{x:i/2+e+.3,y:c*o-s,z:a/2},width:n,thickness:a,padContactLength:e,bodyDistance:e+.4,height:.6})),Ye(i0,{center:{x:0,y:0,z:a/2},width:i,length:i,height:1.1,notchRadius:.35,heightAboveSurface:.1,taperRatio:.09})]})},A3e=1,c3e=.5,XT=.5,JU=.2,$Mo=A3e-JU*2,r8t=({color:t="#333"})=>Mn(Oi,{children:[Ye(Jt,{size:[$Mo,c3e,XT],offset:[0,0,XT/2],color:t}),Ye(Jt,{size:[JU,XT,c3e],offset:[A3e/2-JU/2,0,XT/2],color:"#ccc"}),Ye(Jt,{size:[JU,XT,c3e],offset:[-A3e/2+JU/2,0,XT/2],color:"#ccc"})]}),l3e=1.6,ZMo=l3e-.3*2,rre=.3,g3e=.85,$T=.6,s8t=({color:t="#333"})=>Mn(Oi,{children:[Ye(Jt,{size:[ZMo,g3e,$T],offset:[0,0,$T/2],color:t}),Ye(Jt,{size:[rre,g3e,$T],offset:[l3e/2-rre/2,0,$T/2],color:"#ccc"}),Ye(Jt,{size:[rre,g3e,$T],offset:[-l3e/2+rre/2,0,$T/2],color:"#ccc"})]}),u3e=2,d3e=1.25,ZT=.55,qU=.5,e3o=u3e-qU*2,a8t=({color:t="#333"})=>Mn(Oi,{children:[Ye(Jt,{size:[e3o,d3e,ZT],offset:[0,0,ZT/2],color:t}),Ye(Jt,{size:[qU,d3e,ZT],offset:[u3e/2-qU/2,0,ZT/2],color:"#ccc"}),Ye(Jt,{size:[qU,d3e,ZT],offset:[-u3e/2+qU/2,0,ZT/2],color:"#ccc"})]}),t3o=({pinCount:t,pitch:e,leadWidth:n,padContactLength:o,bodyWidth:i})=>{const r=t/4;e||(e=n3o(t,i)),o||(o=o3o(t)),n||(n=i3o(t,i)),i||(i=e*(r+4));const s=o,a=i,A=(r-1)*e/2,c=s*.5,l=a+2*c,g=l,u=.8,h=.15,d=c,_=c*.5,m=c*.18;return Mn(Oi,{children:[Array.from({length:r}).map((p,I)=>Ye(Tr,{position:{x:-g/2,y:I*e-A,z:h/2},width:n,thickness:h,padContactLength:_,bodyDistance:d,curveLength:m,height:u})),Array.from({length:r}).map((p,I)=>Ye(Tr,{rotation:Math.PI,position:{x:g/2,y:I*e-A,z:h/2},width:n,thickness:h,padContactLength:_,bodyDistance:d,curveLength:m,height:u})),Array.from({length:r}).map((p,I)=>Ye(Tr,{rotation:Math.PI/2,position:{x:I*e-A,y:-l/2,z:h/2},width:n,thickness:h,padContactLength:_,bodyDistance:d,curveLength:m,height:u})),Array.from({length:r}).map((p,I)=>Ye(Tr,{rotation:-Math.PI/2,position:{x:I*e-A,y:l/2,z:h/2},width:n,thickness:h,padContactLength:_,bodyDistance:d,curveLength:m,height:u})),Ye(i0,{center:{x:0,y:0,z:0},width:i,length:a,height:1.5,taperRatio:.03,chamferSize:.7,notchPosition:{x:-(a/2-1.5),y:i/2-1.5,z:1.5},notchRadius:1.5/2})]})},n3o=(t,e)=>{switch(t){case 44:case 64:return .8;case 52:return e===14?1:.65;case 208:return .5;default:return .5}},o3o=t=>{switch(t){case 32:return .6;case 40:return .6;case 52:case 64:return .65;case 208:return 1.65;default:return .6}},i3o=(t,e)=>{switch(t){case 44:case 64:return .5;case 52:return e===14?.45:.55;case 208:return .3;default:return .25}},A8t=({x:t,y:e,pinThickness:n,shortSidePinLength:o,longSidePinLength:i,bodyHeight:r,bodyLength:s=2.54,bodyWidth:a=2.54,flipZ:A,faceup:c,smd:l,rightangle:g})=>Mn(Oi,{children:[Ye(jo,{y:g?-3:0,children:Ye(Jt,{color:"#222",size:[s,a,r],center:[t,e,A(r/2)]})}),!c&&Ye(ir,{color:"gold",children:l?Ye(Tr,{rotation:-Math.PI/2,position:{x:t,y:e+1,z:n/2},thickness:n,width:n,height:n,padContactLength:2,bodyDistance:3}):Mn(_c,{children:[Ye(Jt,{color:"gold",size:[n,n,o*.9],center:[t,e,A(r*.9+r/2)]}),Ye(Jt,{color:"gold",size:[n/1.8,n/1.8,o],center:[t,e,A(r+r/2)]})]})}),Ye(ir,{color:"gold",children:Ye(jo,{y:g?-3.9:0,z:g?1:0,children:Ye(o0,{rotation:g?[-Math.PI/2,0,0]:[0,0,0],children:Mn(_c,{children:[Ye(Jt,{color:"gold",size:[n,n,i*.9],center:[t,e,A(-i/2*.9)]}),Ye(Jt,{color:"gold",size:[n/1.8,n/1.8,i],center:[t,e,A(-i/2)]})]})})})})]}),r3o=({numberOfPins:t,pitch:e=2.54,longSidePinLength:n=6,invert:o,faceup:i,rows:r=1,smd:s,rightangle:a})=>{const l=Math.ceil(t/r),g=2.54,u=3,h=-((l-1)/2)*e,d=!s&&!a?-2-1.6:0,_=m=>(o||i?-m+2:m)+d;return Ye(Oi,{children:Array.from({length:t},(m,p)=>{const I=Math.floor(p/l),f=p%l,C=h+f*e,y=((r-1)/2-I)*g;return Ye(A8t,{x:C,y,pinThickness:.63,shortSidePinLength:u,longSidePinLength:n,bodyHeight:2,flipZ:_,faceup:i,smd:s,rightangle:a},p)})})},s3o=t=>{const e=["left","bottom","right","top"],{pin_count:n,pn:o,w:i,h:r,p:s,pl:a}=t,A=n/4,c=e[Math.floor((o-1)/A)],l=(o-1)%A,g=s*(A-1),u=s*(A-1),h=-a/2;switch(c){case"left":return{x:-i/2-h,y:u/2-l*s,o:"vert"};case"bottom":return{x:-g/2+l*s,y:-r/2-h,o:"horz"};case"right":return{x:i/2+h,y:-u/2+l*s,o:"vert"};case"top":return{x:g/2-l*s,y:r/2+h,o:"horz"};default:throw new Error("Invalid pin number")}},a3o=({num_pins:t,cw:e,ccw:n,startingpin:o})=>{const i=[],r=t/4;let s=1;const a={};for(const A of o??[])a[A]=!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=r:a.bottomside&&a.leftpin?s=r+1:a.bottomside&&a.rightpin?s=r*2:a.rightside&&a.bottompin?s=r*2+1:a.rightside&&a.toppin?s=r*3:a.topside&&a.rightpin?s=r*3+1:a.topside&&a.leftpin&&(s=r*4),i.push(-1);for(let A=0;A<t;A++)i[s]=A+1,s++,s>t&&(s=1);return i},A3o=({num_pins:t=16,bodyWidth:e=9,bodyLength:n=9,bodyThickness:o=.8,thermalPadSize:i,padWidth:r=.25,padLength:s=.25,pitch:a=.5,thermalPadThickness:A=.05})=>{const c=a3o({num_pins:t,cw:!0,ccw:!0}),l=[];for(let g=0;g<t;g++){const{x:u,y:h,o:d}=s3o({pin_count:t,pn:g+1,w:e,h:n,p:a,pl:s});let _=r,m=s;d==="vert"&&([_,m]=[m,_]);const p=c[g+1];l.push({pn:p,x:u,y:h,pw:_,pl:m})}return Mn(Oi,{children:[Ye(ir,{color:"grey",children:Ye(Jt,{center:[0,0,o/2],size:[e,n,o]})}),l.map((g,u)=>Ye(Jt,{center:[g.x,g.y,A/2],size:[g.pw,g.pl,A]})),i?.length!==void 0&&i?.width!==void 0&&Ye(Jt,{center:[0,0,A/2],size:[i.width,i.length,A]})]})},c3o=A3o,l3o=()=>{const A=1.1999999999999997;return Mn(Oi,{children:[Ye(Tr,{rotation:Math.PI,position:{x:2.8/2+A/4,y:-1,z:.15/2},width:.4,thickness:.15,padContactLength:.5,bodyDistance:A,height:.95}),Ye(Tr,{rotation:Math.PI,position:{x:2.8/2+A/4,y:1,z:.15/2},width:.4,thickness:.15,padContactLength:.5,bodyDistance:A,height:.95}),Ye(Tr,{position:{x:-2.8/2-A/4,y:0,z:.15/2},width:.4,thickness:.15,padContactLength:.5,bodyDistance:A,height:.95}),Ye(Tr,{position:{x:-2.8/2-A/4,y:-1,z:.15/2},width:.4,thickness:.15,padContactLength:.5,bodyDistance:A,height:.95}),Ye(Tr,{position:{x:-2.8/2-A/4,y:1,z:.15/2},width:.4,thickness:.15,padContactLength:.5,bodyDistance:A,height:.95}),Ye(i0,{center:{x:0,y:0,z:0},width:1.6,length:2.9,height:1.2})]})},g3o=l3o,u3o=({fullWidth:t=2.9,fullLength:e=2.8})=>{const l=(t-1.92)/2+.3;return Mn(Oi,{children:[Ye(Tr,{rotation:Math.PI,position:{x:t/2,y:0,z:.075},width:.4,thickness:.15,padContactLength:.25,bodyDistance:l,height:.45}),Ye(Tr,{position:{x:-t/2,y:-.95,z:.075},width:.4,thickness:.15,padContactLength:.25,bodyDistance:l,height:.45}),Ye(Tr,{position:{x:-t/2,y:.95,z:.075},width:.4,thickness:.15,padContactLength:.25,bodyDistance:l,height:.45}),Ye(i0,{center:{x:0,y:0,z:0},width:1.92,length:2.9,height:1.1,straightHeightRatio:.45,heightAboveSurface:.05})]})},h3e=.6,_3e=.3,ek=.33,WU=.1,d3o=h3e-WU*2,c8t=({color:t="#333"})=>Mn(Oi,{children:[Ye(Jt,{size:[d3o,_3e,ek],offset:[0,0,ek/2],color:t}),Ye(Jt,{size:[WU,_3e,ek],offset:[h3e/2-WU/2,0,ek/2],color:"#ccc"}),Ye(Jt,{size:[WU,_3e,ek],offset:[-h3e/2+WU/2,0,ek/2],color:"#ccc"})]}),m3e=.4,p3e=.2,tk=.13,jU=.07,h3o=m3e-jU*2,l8t=({color:t="#333"})=>Mn(Oi,{children:[Ye(Jt,{size:[h3o,p3e,tk],offset:[0,0,tk/2],color:t}),Ye(Jt,{size:[jU,p3e,tk],offset:[m3e/2-jU/2,0,tk/2],color:"#ccc"}),Ye(Jt,{size:[jU,p3e,tk],offset:[-m3e/2+jU/2,0,tk/2],color:"#ccc"})]}),I3e=3.2,f3e=1.6,nk=.9,XU=.5,_3o=I3e-XU*2,g8t=({color:t="#333"})=>Mn(Oi,{children:[Ye(Jt,{size:[_3o,f3e,nk],offset:[0,0,nk/2],color:t}),Ye(Jt,{size:[XU,f3e,nk],offset:[I3e/2-XU/2,0,nk/2],color:"#ccc"}),Ye(Jt,{size:[XU,f3e,nk],offset:[-I3e/2+XU/2,0,nk/2],color:"#ccc"})]}),C3e=3.2,y3e=2.5,ok=1,$U=.6,m3o=C3e-$U*2,u8t=({color:t="#333"})=>Mn(Oi,{children:[Ye(Jt,{size:[m3o,y3e,ok],offset:[0,0,ok/2],color:t}),Ye(Jt,{size:[$U,y3e,ok],offset:[C3e/2-$U/2,0,ok/2],color:"#ccc"}),Ye(Jt,{size:[$U,y3e,ok],offset:[-C3e/2+$U/2,0,ok/2],color:"#ccc"})]}),E3e=5,x3e=2.5,ik=1.4,ZU=.6,p3o=E3e-ZU*2,d8t=({color:t="#333"})=>Mn(Oi,{children:[Ye(Jt,{size:[p3o,x3e,ik],offset:[0,0,ik/2],color:t}),Ye(Jt,{size:[ZU,x3e,ik],offset:[E3e/2-ZU/2,0,ik/2],color:"#ccc"}),Ye(Jt,{size:[ZU,x3e,ik],offset:[-E3e/2+ZU/2,0,ik/2],color:"#ccc"})]}),B3e=6.3,Q3e=3.2,rk=1.8,eY=.8,I3o=B3e-eY*2,h8t=({color:t="#333"})=>Mn(Oi,{children:[Ye(Jt,{size:[I3o,Q3e,rk],offset:[0,0,rk/2],color:t}),Ye(Jt,{size:[eY,Q3e,rk],offset:[B3e/2-eY/2,0,rk/2],color:"#ccc"}),Ye(Jt,{size:[eY,Q3e,rk],offset:[-B3e/2+eY/2,0,rk/2],color:"#ccc"})]}),_8t=({x:t,y:e,z:n=0,pitch:o=2.54,legsLength:i=3,innerDiameter:r=.945,bodyHeight:s=5,bodyLength:a=o,bodyWidth:A=o,flipZ:c})=>{const l=r||.945,g=l/1.5,u=l,h=u*1.8,d=Math.min(s*.18,o*.24),_=s+.1,m=c(n+_/2),p=n+s-d,I=g*1.6;return Mn(Oi,{children:[Ye(ir,{color:"#1a1a1a",children:Mn(k_,{children:[Ye(Jt,{color:"#000",size:[a,A,s],center:[t,e,c(n+s/2)]}),Ye(Jt,{size:[u,u,_],center:[t,e,m]}),Mn(_c,{children:[Ye(Jt,{size:[u,u,.01],center:[t,e,c(p)]}),Ye(Jt,{size:[h,h,.01],center:[t,e,c(n+s)]})]})]})}),Mn(ir,{color:"silver",children:[Mn(_c,{children:[Ye(Jt,{color:"silver",size:[g,g,i*.9],center:[t,e,c(n+-i/2*.9)]}),Ye(Jt,{color:"silver",size:[g/1.8,g/1.8,i],center:[t,e,c(n+-i/2)]})]}),Ye(Jt,{color:"silver",size:[I,I,I*.5],center:[t,e,c(n+I/2*.5)]})]})]})},f3o=({numberOfPins:t,pitch:e=2.54,legsLength:n=3,innerDiameter:o=.945,rows:i=1,invert:r})=>{const a=Math.ceil(t/i),A=2.54,c=-((a-1)/2)*e,l=g=>r?-g+5:g;return Ye(Oi,{children:Array.from({length:t},(g,u)=>{const h=Math.floor(u/a),d=u%a,_=c+d*e,m=((i-1)/2-h)*A;return Ye(_8t,{x:_,y:m,pitch:e,legsLength:n,innerDiameter:o,flipZ:l},u)})})},C3o=({width:t,length:e,innerDiameter:n=1})=>{const o=t,i=e,r=t*.7,s=n/2.5;return Mn(Oi,{children:[Ye(NI,{color:"#1a1a1f",center:[0,0,r/2],size:[i,i,r],roundRadius:.3}),Ye(NI,{color:"#f2f2f2",center:[0,0,r+r*.1/2.5],size:[i,i,r*.1],roundRadius:.14}),Ye(_A,{color:"#1a1a1f",height:r*.8,radius:o/3,center:[0,0,r+r*.8/2]}),Ye(_A,{color:"#1a1a1f",height:r*.2,radius:n/2,center:[i/3,i/3,r+r*.1/2]}),Ye(_A,{color:"#1a1a1f",height:r*.2,radius:n/2,center:[-i/3,-i/3,r+r*.1/2]}),Ye(_A,{color:"#1a1a1f",height:r*.2,radius:n/2,center:[-i/3,i/3,r+r*.1/2]}),Ye(_A,{color:"#1a1a1f",height:r*.2,radius:n/2,center:[i/3,-i/3,r+r*.1/2]}),Ye(sre,{thickness:n/3,width:s,horizontalLength:i*.8,verticalLength:r/2,position:{x:-o/2,y:-i/2,z:-r*1.2}}),Ye(sre,{thickness:n/3,width:s,horizontalLength:i*.8,verticalLength:r/2,position:{x:-o/2,y:i/2,z:-r*1.2},rotation:Math.PI}),Ye(sre,{thickness:n/3,width:s,horizontalLength:i*.8,verticalLength:r/2,position:{x:o/2,y:i/2,z:-r*1.2},rotation:Math.PI}),Ye(sre,{thickness:n/3,width:s,horizontalLength:i*.8,verticalLength:r/2,position:{x:o/2+n/3.6,y:-i/2,z:-r*1.2}})]})},sre=t=>{const{thickness:e,width:n,horizontalLength:o,verticalLength:i,rotation:r=0,position:s}=t,a=[[0,o],[-i/3,o/3],[-i/5,o/4],[0,0]],A=a3e(a,e);return Ye(ir,{color:"#f2f2f2",children:Ye(jo,{offset:{x:s?.x||0,y:s?.y||0,z:s?.z||0},children:Ye(o0,{rotation:[0,55,r],children:Ye(jT,{height:n,children:Ye(WT,{points:A.map(c=>[c.y,c.x])})})})})})},y3o=({pinCount:t,leadLength:e,leadWidth:n,pitch:o,bodyWidth:i})=>{const r=Math.ceil(t/2),s=(r-1)*o/2,a=.25,A=1,c=.8,l=e*0,g=o*(r-1)+n+.2,u=i*.55;return Mn(Oi,{children:[Array.from({length:r}).map((h,d)=>Ye(Tr,{position:{x:-i/2-l,y:d*o-s,z:a/2},width:n,thickness:a,padContactLength:e/2,bodyDistance:e+.3,height:c})),Array.from({length:r}).map((h,d)=>Ye(Tr,{rotation:Math.PI,position:{x:i/2+l,y:d*o-s,z:a/2},width:n,thickness:a,padContactLength:e/2,bodyDistance:e+.3,height:c})),Ye(i0,{center:{x:0,y:0,z:a/2},width:u,length:g,height:A})]})},E3o=({pinCount:t,pitch:e,leadWidth:n,leadLength:o,bodyWidth:i,bodyLength:r})=>{const s=t===8?{pitch:.65,leadWidth:.3}:{pitch:.5,leadWidth:.225},a=isNaN(parseFloat(e))?s.pitch:parseFloat(e),A=isNaN(parseFloat(n))?s.leadWidth:parseFloat(n)*.8,c=isNaN(parseFloat(i))?2.6:parseFloat(i)*.8,l=isNaN(parseFloat(r))?2+Number(a)*1.4:parseFloat(r),g=t/2,u=(g-1)*a/2,h=.15,d=.8,_=4.5,m=(_-c)/2,p=m*.5;return Mn(Oi,{children:[Array.from({length:g}).map((I,f)=>Ye(Tr,{position:{x:-_/2,y:u-f*a,z:h/2},width:A,thickness:h,padContactLength:p+.05,bodyDistance:m+.1,height:d})),Array.from({length:g}).map((I,f)=>Ye(Tr,{rotation:Math.PI,position:{x:_/2,y:u-f*a,z:h/2},width:A,thickness:h,padContactLength:p+.05,bodyDistance:m+.1,height:d})),Ye(i0,{center:{x:0,y:0,z:h/2},width:c,length:l,height:1})]})},x3o=()=>Mn(Oi,{children:[Ye(Jt,{color:"#ccc",size:[.5,.6,.12],center:[-.725,0,.12/2]}),Ye(Jt,{color:"#ccc",size:[.5,.6,.12],center:[.725,0,.12/2]}),Ye(ir,{color:"#222",children:Mn(T_,{children:[Ye(jo,{z:.3/2,children:Ye(Jt,{size:[1.65,.8,.3]})}),Mn(_c,{children:[Ye(jo,{z:.3,children:Ye(Jt,{size:[1.65,.8,.01]})}),Ye(jo,{z:.6,children:Ye(Jt,{size:[1.65-.2,.8-.2,.01]})})]})]})})]}),B3o=()=>Mn(Oi,{children:[Ye(Jt,{color:"#ccc",size:[.26,.51,.12],center:[-.325,0,.12/2]}),Ye(Jt,{color:"#ccc",size:[.26,.51,.12],center:[.325,0,.12/2]}),Ye(ir,{color:"#222",children:Ye(jo,{z:.47/2+.02,children:Ye(Jt,{size:[.98,.58,.47]})})}),Ye(Jt,{color:"#ccc",size:[.98+.001,.26/2,.26/4],center:[0,.26/2,.47/4]}),Ye(Jt,{color:"#ccc",size:[.98+.001,.26/2,.26/4],center:[0,-.26/2,.47/4]}),Ye(Jt,{color:"#ccc",size:[.26/1.5,.58+.001,.26/4],center:[.65/2,0,.47/4]}),Ye(Jt,{color:"#ccc",size:[.26/1.5,.58+.001,.26/4],center:[-.65/2,0,.47/4]})]}),Q3o=()=>{const c=Ye(ir,{color:"#1a1a1a",children:Mn(T_,{children:[Mn(_c,{children:[Ye(jo,{z:.13,children:Ye(Jt,{size:[4,3,.03]})}),Ye(jo,{z:1.15,children:Ye(Jt,{size:[4.4,3.4,.01]})})]}),Mn(_c,{children:[Ye(jo,{z:1.15,children:Ye(Jt,{size:[4.4,3.4,.01]})}),Ye(jo,{z:2.3,children:Ye(Jt,{size:[4,3,.01]})})]})]})}),l=({xDir:g})=>{const d=g*1.78,_=g*(3.4/2-.2/2+1),m=g*(3.4/2-.2/2),p=Math.abs(m-_),I=(_+m)/2;return Ye(ir,{color:"#c0c0c0",children:Mn(T_,{children:[Ye(Jt,{size:[2.3*.8,1.45,.2],center:[d,0,.2/2]}),Ye(Jt,{size:[.2,1.45,1.14],center:[_,0,1.14/2+.2]}),Ye(Jt,{size:[p,1.45,.2],center:[I,0,.2/2+1.14]})]})})};return Mn(Oi,{children:[Ye(l,{xDir:1}),Ye(l,{xDir:-1}),c]})},S3o=()=>{const c=Ye(ir,{color:"#1a1a1a",children:Mn(T_,{children:[Mn(_c,{children:[Ye(jo,{z:.13,children:Ye(Jt,{size:[4,3,.03]})}),Ye(jo,{z:1.15,children:Ye(Jt,{size:[4.4,3.4,.01]})})]}),Mn(_c,{children:[Ye(jo,{z:1.15,children:Ye(Jt,{size:[4.4,3.4,.01]})}),Ye(jo,{z:2.3,children:Ye(Jt,{size:[4,3,.01]})})]})]})}),l=({xDir:g})=>{const d=g*1.78,_=g*(3.4/2-.2/2+1),m=g*(3.4/2-.2/2),p=Math.abs(m-_),I=(_+m)/2;return Ye(ir,{color:"#c0c0c0",children:Mn(T_,{children:[Ye(Jt,{size:[2.3*.8,1.45,.2],center:[d,0,.2/2]}),Ye(Jt,{size:[.2,1.45,1.14],center:[_,0,1.14/2+.2]}),Ye(Jt,{size:[p,1.45,.2],center:[I,0,.2/2+1.14]})]})})};return Mn(Oi,{children:[Ye(l,{xDir:1}),Ye(l,{xDir:-1}),c]})},b3o=()=>{const c=Ye(ir,{color:"#1a1a1a",children:Mn(T_,{children:[Mn(_c,{children:[Ye(jo,{z:.21000000000000002,children:Ye(Jt,{size:[6.3999999999999995,5.6,.03]})}),Ye(jo,{z:1.15,children:Ye(Jt,{size:[6.8,6,.01]})})]}),Mn(_c,{children:[Ye(jo,{z:1.15,children:Ye(Jt,{size:[6.8,6,.01]})}),Ye(jo,{z:2.3,children:Ye(Jt,{size:[6.3999999999999995,5.6,.01]})})]})]})}),l=({xDir:g})=>{const d=g*3.08,_=g*(6/2-.2/2+1),m=g*(6/2-.2/2),p=Math.abs(m-_),I=(_+m)/2;return Ye(ir,{color:"#c0c0c0",children:Mn(T_,{children:[Ye(Jt,{size:[2.3*.8,2.95,.2],center:[d,0,.2/2]}),Ye(Jt,{size:[.2,2.95,1.14],center:[_,0,1.14/2+.2]}),Ye(Jt,{size:[p,2.95,.2],center:[I,0,.2/2+1.14]})]})})};return Mn(Oi,{children:[Ye(l,{xDir:1}),Ye(l,{xDir:-1}),c]})},D3o=()=>{const g=Ye(ir,{color:"#222",children:Mn(T_,{children:[Ye(jo,{z:.27,children:Ye(Jt,{size:[2.9,1.9,.54]})}),Mn(_c,{children:[Ye(jo,{z:.54,children:Ye(Jt,{size:[2.9,1.9,.01]})}),Ye(jo,{z:1.08,children:Ye(Jt,{size:[2.6999999999999997,1.7,.01]})})]})]})});return Mn(Oi,{children:[Ye(Jt,{color:"#ccc",size:[1,1.2,.25],center:[-1.3,0,.25/2]}),Ye(Jt,{color:"#ccc",size:[1,1.2,.25],center:[1.3,0,.25/2]}),g]})},v3o=()=>Mn(Oi,{children:[Ye(Jt,{color:"#ccc",size:[1,.6,.12],center:[-1.3,0,.12/2]}),Ye(Jt,{color:"#ccc",size:[1,.6,.12],center:[1.3,0,.12/2]}),Ye(ir,{color:"#222",children:Mn(T_,{children:[Ye(jo,{z:.55/2,children:Ye(Jt,{size:[2.7,1.6,.55]})}),Mn(_c,{children:[Ye(jo,{z:.55,children:Ye(Jt,{size:[2.7,1.6,.01]})}),Ye(jo,{z:1.1,children:Ye(Jt,{size:[2.7-.2,1.6-.2,.01]})})]})]})})]}),P3o=()=>Mn(Oi,{children:[Ye(Jt,{color:"#ccc",size:[1,.9,.2],center:[-1.3,0,.2/2]}),Ye(Jt,{color:"#ccc",size:[1,.9,.2],center:[1.3,0,.2/2]}),Ye(ir,{color:"#222",children:Mn(T_,{children:[Ye(jo,{z:.2/2,children:Ye(Jt,{size:[2.75,1.8,.2]})}),Mn(_c,{children:[Ye(jo,{z:.2,children:Ye(Jt,{size:[2.75,1.8,.01]})}),Ye(jo,{z:1,children:Ye(Jt,{size:[2.75-.4,1.8-.4,.01]})})]})]})}),Ye(Jt,{color:"#777",size:[.2,1.8-.4,.01],center:[-1.3+.4,0,1]})]}),w3o=()=>Mn(Oi,{children:[Ye(Jt,{color:"#ccc",size:[.9,.9,.2],center:[-1.225,0,.2/2]}),Ye(Jt,{color:"#ccc",size:[.9,.9,.2],center:[1.225,0,.2/2]}),Ye(ir,{color:"#222",children:Mn(T_,{children:[Mn(_c,{children:[Ye(jo,{z:.2,children:Ye(Jt,{size:[2.6-.1/2,1.7-.1/2,.01]})}),Ye(jo,{z:.01,children:Ye(Jt,{size:[2.6-.1,1.7-.1,.01]})})]}),Mn(_c,{children:[Ye(jo,{z:.2,children:Ye(Jt,{size:[2.6,1.7,.01]})}),Ye(jo,{z:1,children:Ye(Jt,{size:[2.6-.4,1.7-.4,.01]})})]})]})}),Ye(Jt,{color:"#777",size:[.2*2.7,1.7-.4,.02],center:[-1.225+.4,0,1]})]}),M3o=({fullWidth:t=3.7,fullLength:e=1.55}={})=>{const n=t-1,o=e,i=1.175,r=.1,s=i-r,a=.55,A=.12,c=.35,l=(t-n)/2,g=.25,u=.2;return Mn(Oi,{children:[Ye(Tr,{position:{x:-t/2,y:0,z:A/2},width:a,thickness:A,padContactLength:g,bodyDistance:l,curveLength:u,height:c}),Ye(Tr,{rotation:Math.PI,position:{x:t/2,y:0,z:A/2},width:a,thickness:A,padContactLength:g,bodyDistance:l,curveLength:u,height:c}),Ye(i0,{center:{x:0,y:0,z:0},width:n,length:o,height:s,heightAboveSurface:r,includeNotch:!1,color:"#222",taperRatio:.06,straightHeightRatio:.6}),Ye(Jt,{color:"#777",size:[.45,o-.15,.02],center:[-n/4,0,i]})]})},N3o=()=>Mn(Oi,{children:[Ye(Jt,{color:"#ccc",size:[.9,1.75,.2],center:[-1.825,0,.2/2]}),Ye(Jt,{color:"#ccc",size:[.9,1.75,.2],center:[1.825,0,.2/2]}),Ye(ir,{color:"#222",children:Mn(T_,{children:[Mn(_c,{children:[Ye(jo,{z:.2,children:Ye(Jt,{size:[3.8-.05/2,2.5-.05/2,.01]})}),Ye(jo,{z:.01,children:Ye(Jt,{size:[3.8-.05,2.5-.05,.01]})})]}),Mn(_c,{children:[Ye(jo,{z:.2,children:Ye(Jt,{size:[3.8,2.5,.01]})}),Ye(jo,{z:1,children:Ye(Jt,{size:[3.8-.4,2.5-.4,.01]})})]})]})}),Ye(Jt,{color:"#777",size:[.2*2.7,2.5-.4,.02],center:[-1.825+.4,0,1]})]}),R3o=()=>Mn(Oi,{children:[Ye(Jt,{color:"#ccc",size:[.4,.25,.14],center:[-.4,0,.14/2]}),Ye(Jt,{color:"#ccc",size:[.4,.25,.14],center:[.4,0,.14/2]}),Ye(ir,{color:"#222",children:Mn(T_,{children:[Ye(jo,{z:.14/2,children:Ye(Jt,{size:[.8,.6,.14]})}),Mn(_c,{children:[Ye(jo,{z:.14,children:Ye(Jt,{size:[.8,.6,.01]})}),Ye(jo,{z:.37,children:Ye(Jt,{size:[.8-.1,.6-.1,.01]})})]})]})})]}),T3o=()=>{const l=3.0999999999999996;return Mn(Oi,{children:[Ye(Tr,{rotation:Math.PI,position:{x:6.6/2+l/4,y:0,z:.25/2},width:3,thickness:.25,padContactLength:.5,bodyDistance:l,height:.75}),Ye(Tr,{position:{x:-6.6/2-l/4,y:0,z:.25/2},width:.7,thickness:.25,padContactLength:.5,bodyDistance:l,height:.75}),Ye(Tr,{position:{x:-6.6/2-l/4,y:-2.3,z:.25/2},width:.7,thickness:.25,padContactLength:.5,bodyDistance:l,height:.75}),Ye(Tr,{position:{x:-6.6/2-l/4,y:2.3,z:.25/2},width:.7,thickness:.25,padContactLength:.5,bodyDistance:l,height:.75}),Ye(i0,{center:{x:0,y:0,z:0},width:3.5,length:6.5,height:1.7,includeNotch:!1,taperRatio:.06,straightHeightRatio:.45})]})},k3o=()=>Mn(Oi,{children:[Array.from({length:16}).map((h,d)=>Ye(Tr,{position:{x:-10.5/2,y:d*.5-3.75,z:.25/2},width:.2,thickness:.25,padContactLength:.45,bodyDistance:.95,height:.65})),Array.from({length:16}).map((h,d)=>Ye(Tr,{rotation:Math.PI,position:{x:10.5/2,y:d*.5-3.75,z:.25/2},width:.2,thickness:.25,padContactLength:.45,bodyDistance:.95,height:.65})),Array.from({length:16}).map((h,d)=>Ye(Tr,{rotation:Math.PI/2,position:{x:d*.5-3.75,y:-10.5/2,z:.25/2},width:.2,thickness:.25,padContactLength:.45,bodyDistance:.95,height:.65})),Array.from({length:16}).map((h,d)=>Ye(Tr,{rotation:-Math.PI/2,position:{x:d*.5-3.75,y:10.5/2,z:.25/2},width:.2,thickness:.25,padContactLength:.45,bodyDistance:.95,height:.65})),Ye(i0,{center:{x:0,y:0,z:0},width:9,length:9,height:1.2,chamferSize:.7,taperRatio:.05,notchPosition:{x:-3.5,y:3.5,z:1.2},notchRadius:1.2/2})]}),F3o=k3o,L3o=()=>{const c=.7999999999999998;return Mn(Oi,{children:[Ye(Tr,{rotation:Math.PI,position:{x:2.05/2+c/4,y:0,z:.18/2},width:.3,thickness:.18,padContactLength:.2,bodyDistance:c,height:.65}),Ye(Tr,{position:{x:-2.05/2-c/4,y:-.65,z:.18/2},width:.3,thickness:.18,padContactLength:.2,bodyDistance:c,height:.65}),Ye(Tr,{position:{x:-2.05/2-c/4,y:.65,z:.18/2},width:.3,thickness:.18,padContactLength:.2,bodyDistance:c,height:.65}),Ye(i0,{center:{x:0,y:0,z:0},width:1.25,length:2,height:.9,includeNotch:!1,taperRatio:.06,straightHeightRatio:.7,heightAboveSurface:.05})]})},H3o=({pinCount:t,pitch:e,leadWidth:n,padContactLength:o,bodyWidth:i})=>{const r=t/4;if(r!==Math.floor(r))throw new Error(`LQFP pinCount must be divisible by 4, got ${t}`);e||(e=.5),o||(o=.6),n||(n=.22),i||(i=e*(r+4));const s=i,a=(r-1)*e/2,A=s+3.3*o,c=A,l=.8,g=.2,u=(c-i)/2+.4;return Mn(Oi,{children:[Array.from({length:r}).map((h,d)=>Ye(Tr,{position:{x:-c/2-.36,y:d*e-a,z:g/2},width:n,thickness:g,padContactLength:o,bodyDistance:u,height:l})),Array.from({length:r}).map((h,d)=>Ye(Tr,{rotation:Math.PI,position:{x:c/2+.36,y:d*e-a,z:g/2},width:n,thickness:g,padContactLength:o,bodyDistance:u,height:l})),Array.from({length:r}).map((h,d)=>Ye(Tr,{rotation:Math.PI/2,position:{x:d*e-a,y:-A/2-.36,z:g/2},width:n,thickness:g,padContactLength:o,bodyDistance:u,height:l})),Array.from({length:r}).map((h,d)=>Ye(Tr,{rotation:-Math.PI/2,position:{x:d*e-a,y:A/2+.36,z:g/2},width:n,thickness:g,padContactLength:o,bodyDistance:u,height:l})),Ye(i0,{center:{x:0,y:0,z:0},width:i,length:s,height:1.5,heightAboveSurface:.1,taperRatio:.04,chamferSize:.7,notchPosition:{x:-(s/2-1.5),y:s/2-1.5,z:1.5},notchRadius:1.5/2})]})},G3o=()=>{const o=.20900000000000002,i=.1,r=.3,s=.1,a=.2;return Mn(Oi,{children:[Ye(ir,{color:"#222",children:Mn(T_,{children:[Ye(Jt,{size:[.85,1.2,o],center:[0,0,o/2]}),Mn(_c,{children:[Ye(jo,{z:o,children:Ye(Jt,{size:[.85,1.2,.01]})}),Ye(jo,{z:.38,children:Ye(Jt,{size:[.85-i,1.2-i,.01]})})]})]})}),Ye(Jt,{color:"#ccc",size:[r,.25,s],center:[.55,0,s/2]}),Ye(Jt,{color:"#ccc",size:[r,a,s],center:[-.55,.4,s/2]}),Ye(Jt,{color:"#ccc",size:[r,a,s],center:[-.55,-.4,s/2]})]})},O3o=({num_pins:t,bodyWidth:e=5.3,bodyLength:n=5.3,bodyThickness:o=1,thermalPadSize:i,padWidth:r=n/5.3*.6,padLength:s=n/5.3*1,pitch:a=.5,thermalPadThickness:A=.2})=>{const c=[],l=Math.floor(t/2),g=a*(l-1);for(let u=0;u<t;u++){const h=u<l?"left":"right",d=u%l,_=g/2-d*a,m=s,p=r,I=h==="left"?-e/2+m/2:e/2-m/2,f=u+1;c.push({pinNumber:f,x:I,y:_,padSizeX:m,padSizeY:p})}return Mn(Oi,{children:[Ye(i0,{center:{x:0,y:0,z:0},width:e,length:n,height:o,heightAboveSurface:0,color:"grey",chamferSize:.2,taperRatio:0,notchPosition:{x:-(e/2-s),y:n/2-s,z:o}}),c.map((u,h)=>Ye(Jt,{center:[u.x,u.y,A/2],size:[u.padSizeX,u.padSizeY,A]})),i?.length!==void 0&&i?.width!==void 0&&Ye(Jt,{center:[0,0,A/2],size:[i.width,i.length,A]})]})},K3o=({bodyLength:t=10.2,bodyWidth:e=4.65,bodyHeight:n=13.46,leadSpacing:o=5,leadDiameter:i=.8,leadLength:r=12.7,color:s="#ddd",leadColor:a="#b87333"})=>{const A=t/2,c=e/2,l=A-c,g=o/2,u=.85;return Mn(Oi,{children:[Mn(ir,{color:s,children:[Mn(_c,{children:[Ye(Py,{height:n,roundRadius:.5,radius:c,center:[-l,0,n]}),Ye(Py,{height:n,roundRadius:.5,radius:c,center:[l,0,n]})]}),Mn(_c,{children:[Ye(Py,{height:u,roundRadius:.1,radius:c+.85,center:[-l,0,n/2+u/2]}),Ye(Py,{height:u,roundRadius:.1,radius:c+.85,center:[l,0,n/2+u/2]})]})]}),Mn(ir,{color:a,children:[Ye(_A,{height:r+n/2,radius:i/2,center:[-g+.06,0,-(r/2)+n/2]}),Ye(_A,{height:r+n/2,radius:i/2,center:[g-.06,0,-(r/2)+n/2]})]})]})},U3o=({bodyLength:t=1.4,bodyDiameter:e=1.1,color:n="#3a3a3aff",contactColor:o="#c6c6c6",cathodeIdentification:i="#111"})=>Mn(Oi,{children:[Ye(ir,{color:n,children:Mn(o0,{rotation:[0,"90deg",0],children:[Ye(NI,{size:[e,e,t-.2],roundRadius:.2,center:[-e/2,0,.05]}),Ye(_A,{height:.2/2,radius:e/2-.2,center:[-e/2,0,-t/2+.2/2]})]})}),Ye(ir,{color:i,children:Ye(o0,{rotation:[0,"90deg",0],children:Ye(NI,{size:[e*1.01,e*1.01,t/3],roundRadius:.2,center:[-e/2,0,-t/4+.1]})})}),Ye(ir,{color:o,children:Ye(o0,{rotation:[0,"90deg",0],children:Ye(Py,{height:.2,radius:e/2,roundRadius:.2/3,center:[-e/2,0,-t/2]})})}),Ye(ir,{color:o,children:Ye(o0,{rotation:[0,"90deg",0],children:Ye(Py,{height:.2,radius:e/2,roundRadius:.2/3,center:[-e/2,0,t/2]})})})]}),Y3o=({bodyLength:t=3.5,bodyDiameter:e=1.5,color:n="#3a3a3aff",contactColor:o="#c6c6c6"})=>Mn(Oi,{children:[Ye(ir,{color:n,children:Ye(o0,{rotation:[0,"90deg",0],children:Ye(Py,{height:t,radius:e/2,roundRadius:.3,center:[-e/2,0,0]})})}),Ye(ir,{color:o,children:Ye(o0,{rotation:[0,"90deg",0],children:Ye(Py,{height:.5,radius:e/2,roundRadius:.2,center:[-e/2,0,-t/2]})})}),Ye(ir,{color:o,children:Ye(o0,{rotation:[0,"90deg",0],children:Ye(Py,{height:.5,radius:e/2,roundRadius:.2,center:[-e/2,0,t/2]})})})]}),z3o=({bodyLength:t=3.9,bodyDiameter:e=2.5,color:n="#3a3a3aff",contactColor:o="#c6c6c6"})=>Mn(Oi,{children:[Ye(ir,{color:n,children:Ye(o0,{rotation:[0,"90deg",0],children:Ye(Py,{height:t,radius:e/2,roundRadius:.3,center:[-e/2,0,0]})})}),Ye(ir,{color:o,children:Ye(o0,{rotation:[0,"90deg",0],children:Ye(Py,{height:.55,radius:e/2,roundRadius:.2,center:[-e/2,0,-t/2]})})}),Ye(ir,{color:o,children:Ye(o0,{rotation:[0,"90deg",0],children:Ye(Py,{height:.55,radius:e/2,roundRadius:.2,center:[-e/2,0,t/2]})})})]}),V3o=({pinCount:t,padContactLength:e=.6,leadWidth:n=.41,pitch:o=1.27})=>{if(t%2!==0)throw new Error("MS012 pinCount must be even");const i=t/2,r=4.9,s=3.9,a=(i-1)*o/2,A=.2;return Mn(Oi,{children:[Array.from({length:i}).map((c,l)=>Ye(Tr,{position:{x:-s/2-e-.3,y:l*o-a,z:A/2},width:n,thickness:A,padContactLength:e,bodyDistance:e+.4,height:.85})),Array.from({length:i}).map((c,l)=>Ye(Tr,{rotation:Math.PI,position:{x:s/2+e+.3,y:l*o-a,z:A/2},width:n,thickness:A,padContactLength:e,bodyDistance:e+.4,height:.85})),Ye(i0,{center:{x:0,y:0,z:A/2},width:s,length:r,height:1.55,notchPosition:{x:-.95,y:r/2-1,z:1.55},heightAboveSurface:.17,taperRatio:.09})]})},J3o=({pinCount:t=16,padContactLength:e=.6,leadWidth:n=.41,pitch:o=1.27})=>{if(t!==16)throw new Error("MS013 only supports 16 pins");const i=t/2,r=7.5,s=10.3,a=(i-1)*o/2,A=.2;return Mn(Oi,{children:[Array.from({length:i}).map((c,l)=>Ye(Tr,{position:{x:-r/2-e-.3,y:l*o-a,z:A/2},width:n,thickness:A,padContactLength:e,bodyDistance:e+.4,height:.85})),Array.from({length:i}).map((c,l)=>Ye(Tr,{rotation:Math.PI,position:{x:r/2+e+.3,y:l*o-a,z:A/2},width:n,thickness:A,padContactLength:e,bodyDistance:e+.4,height:.85})),Ye(i0,{center:{x:0,y:0,z:A/2},width:r,length:s,height:1.1,notchPosition:{x:-2.25,y:s/2-1.5,z:1.1},heightAboveSurface:.17,taperRatio:.05})]})},q3o=()=>{const _=7.050000000000001,m=24.95+6.5/2;return Ye(jo,{center:[0,0,1],children:Mn(Oi,{children:[Mn(o0,{rotation:[0,55,-55],children:[Mn(k_,{children:[Ye(Jt,{color:"#ccc",size:[6.5+.1,9.9,1.3],center:[m,0,1.3-2]}),Ye(_A,{color:"black",center:[m,0,1.3-2],radius:3/2,height:1.3*1.2})]}),Ye(ir,{color:"#222",children:Ye(i0,{width:9.9,length:9.9,height:4.5,center:{x:20,y:0,z:-2.4},includeNotch:!1,straightHeightRatio:.3,taperRatio:.04,heightAboveSurface:1})})]}),Ye(o0,{rotation:[0,55,55],children:Array.from({length:3}).map((p,I)=>{const f=_,C=(I-1)*2.7,y=-.5-.6;return Mn(ir,{color:"gold",children:[Mn(_c,{children:[Ye(jo,{center:[15.05-4.5/2+.1,C,y],children:Ye(Jt,{size:[4.5,.81+1,.5]})}),Ye(jo,{center:[15.05-4.5/2-1+.1,C,y],children:Ye(Jt,{size:[4.5,.81,.5]})})]}),Ye(jo,{center:[f,C,y],children:Ye(Jt,{size:[16+.1,.81,.5]})})]},`prong-${I}`)})})]})})},W3o=()=>{const c=1.1999999999999997;return Mn(Oi,{children:[Ye(Tr,{rotation:Math.PI,position:{x:2.8/2+c/4,y:-.95,z:.15/2},width:.4,thickness:.15,padContactLength:.5,bodyDistance:c,height:.95}),Ye(Tr,{rotation:Math.PI,position:{x:2.8/2+c/4,y:0,z:.15/2},width:.4,thickness:.15,padContactLength:.5,bodyDistance:c,height:.95}),Ye(Tr,{rotation:Math.PI,position:{x:2.8/2+c/4,y:.95,z:.15/2},width:.4,thickness:.15,padContactLength:.5,bodyDistance:c,height:.95}),Ye(Tr,{position:{x:-2.8/2-c/4,y:0,z:.15/2},width:.4,thickness:.15,padContactLength:.5,bodyDistance:c,height:.95}),Ye(Tr,{position:{x:-2.8/2-c/4,y:-.95,z:.15/2},width:.4,thickness:.15,padContactLength:.5,bodyDistance:c,height:.95}),Ye(Tr,{position:{x:-2.8/2-c/4,y:.95,z:.15/2},width:.4,thickness:.15,padContactLength:.5,bodyDistance:c,height:.95}),Ye(i0,{center:{x:0,y:0,z:0},width:1.6,length:2.9,height:1.2,straightHeightRatio:.6,notchPosition:{x:-.4,y:1.2/2+.4,z:1.2+.05},notchRadius:.1})]})},j3o=()=>Mn(Oi,{children:[Ye(i0,{center:{x:0,y:0,z:0},width:.8,length:1,height:.37,heightAboveSurface:0,color:"#1a1a1a",taperRatio:.15,straightHeightRatio:0,notchPosition:{x:-.8/4,y:.7/2.2,z:.37+.1}}),[0,1,2].map(c=>{const l=-.35+c*.35;return Ye(Jt,{center:[-.8/2+.19/2-.1,l,.12/2],size:[.19,.15,.12]})}),[0,1,2].map(c=>{const l=-.35+c*.35;return Ye(Jt,{center:[.8/2-.19/2+.1,l,.12/2],size:[.19,.15,.12]})})]}),X3o=()=>{const s="#222",A=[.43,.4,1.32],c=[.43,.4,.25],l=[0,0,-.66],g=[0,0,-1.32],u=[0,1.28,-2.72],h=[0,1.28,-8.9],d=-7.5;return Mn(jo,{center:[0,1,10.5],children:[Ye(ir,{color:s,children:Mn(k_,{children:[Ye(jo,{center:[0,0,2.25],children:Ye(_A,{radius:2.4,height:4.5})}),Ye(jo,{center:[0,-1.8499999999999999,2.25],children:Ye(Jt,{size:[2.4*2,1.1,4.5+.2]})})]})}),Ye(jo,{center:l,children:Ye(Jt,{size:A})}),Mn(_c,{children:[Ye(jo,{center:g,children:Ye(Jt,{size:c})}),Ye(jo,{center:u,children:Ye(Jt,{size:c})})]}),Ye(jo,{center:h,children:Ye(Jt,{size:[.43,.4,12.2]})}),Ye(jo,{center:[1.3,0,d],children:Ye(Jt,{size:[.43,.4,15]})}),Ye(jo,{center:[-1.3,0,d],children:Ye(Jt,{size:[.43,.4,15]})})]})},$3o=()=>Mn(Oi,{children:[Ye(Tr,{rotation:Math.PI,position:{x:2/2+.75/4,y:-.65,z:.15/2},width:.25,thickness:.15,padContactLength:.3,bodyDistance:.75,height:.85}),Ye(Tr,{rotation:Math.PI,position:{x:2/2+.75/4,y:0,z:.15/2},width:.25,thickness:.15,padContactLength:.3,bodyDistance:.75,height:.85}),Ye(Tr,{rotation:Math.PI,position:{x:2/2+.75/4,y:.65,z:.15/2},width:.25,thickness:.15,padContactLength:.3,bodyDistance:.75,height:.85}),Ye(Tr,{position:{x:-2/2-.75/4,y:0,z:.15/2},width:.25,thickness:.15,padContactLength:.3,bodyDistance:.75,height:.85}),Ye(Tr,{position:{x:-2/2-.75/4,y:-.65,z:.15/2},width:.25,thickness:.15,padContactLength:.3,bodyDistance:.75,height:.85}),Ye(Tr,{position:{x:-2/2-.75/4,y:.65,z:.15/2},width:.25,thickness:.15,padContactLength:.3,bodyDistance:.75,height:.85}),Ye(i0,{center:{x:0,y:0,z:0},width:1.25,length:2,height:1.1,straightHeightRatio:.6,notchPosition:{x:-.375,y:1.1/2+.2,z:1.1},heightAboveSurface:.1})]}),Z3o=$3o,e6o=()=>Mn(Oi,{children:[Ye(i0,{center:{x:0,y:0,z:.05},width:1,length:1.45,height:.5,heightAboveSurface:0,color:"#1a1a1a",taperRatio:0,includeNotch:!1}),[0,1,2].map(a=>{const A=-.5+a*.5;return Ye(Jt,{center:[-1/2+.3/2,A,.05/2],size:[.3,.2,.05]})}),[0,1,2].map(a=>{const A=-.5+a*.5;return Ye(Jt,{center:[1/2-.3/2,A,.05/2],size:[.3,.2,.05]})})]}),t6o=()=>Mn(Oi,{children:[Ye(Tr,{position:{x:-2.5/2,y:0,z:.175/2},width:.3,thickness:.175,padContactLength:.3,bodyDistance:.45,height:.7}),Ye(Tr,{rotation:Math.PI,position:{x:2.5/2,y:0,z:.175/2},width:.3,thickness:.175,padContactLength:.3,bodyDistance:.45,height:.7}),Ye(ir,{color:"#222",children:Ye(i0,{center:{x:0,y:0,z:0},width:1.7,length:1.25,height:.95,includeNotch:!1,taperRatio:.06,straightHeightRatio:.7,heightAboveSurface:.05})}),Ye(Jt,{color:"#777",size:[1.7/3,1.25-.075,.02],center:[-.85*2/3+.035,0,.95+.05]})]}),n6o=()=>Mn(Oi,{children:[Ye(Jt,{color:"#ccc",size:[.4,.325,.175],center:[-1.05,0,.175/2]}),Ye(Jt,{color:"#ccc",size:[.4,.325,.175],center:[1.05,0,.175/2]}),Ye(ir,{color:"#222",children:Mn(T_,{children:[Ye(jo,{z:.175/2,children:Ye(Jt,{size:[1.7,1.25,.175]})}),Mn(_c,{children:[Ye(jo,{z:.175,children:Ye(Jt,{size:[1.7,1.25,.01]})}),Ye(jo,{z:.725,children:Ye(Jt,{size:[1.7-.2,1.25-.2,.01]})})]})]})}),Ye(Jt,{color:"#777",size:[1.7/3,1.25-.2,.02],center:[-1.05+1.7/4.4+.2,0,.725]})]}),o6o=()=>{const s=-1.0474999999999999,a=1.775/2+.4/2-.04;return Mn(Oi,{children:[Ye(Jt,{color:"#ccc",size:[.4,.325,.13],center:[s,0,.13/2]}),Ye(Jt,{color:"#ccc",size:[.4,.325,.13],center:[a,0,.13/2]}),Ye(ir,{color:"#222",children:Ye(i0,{width:1.775,length:1.25,height:.725,center:{x:0,y:0,z:0},heightAboveSurface:0,straightHeightRatio:.7,taperRatio:.06,includeNotch:!1})}),Ye(Jt,{color:"#777",size:[1.775/3,1.25-.05,.02],center:[s+1.775/4.4+.2,0,.725]})]})},i6o=({pitch:t=10})=>Mn(Oi,{children:[Ye(_A,{height:4,radius:.5,center:[-t/2,0,.5]}),Ye(ore,{radius:.5,center:[-t/2,0,2.5]}),Ye(jo,{x:-2.5,y:0,z:2.5,children:Mn(o0,{rotation:[0,Math.PI/2,0],children:[Ye(_A,{height:t,radius:.5,center:[0,0,2.5]}),Ye(ir,{color:"#d2b48c",children:Ye(_A,{height:5,radius:1.3,center:[0,0,2.5]})})]})}),Ye(_A,{height:4,radius:.5,center:[t/2,0,.5]}),Ye(ore,{radius:.5,center:[t/2,0,2.5]})]}),r6o=({bodyWidth:t=21,boardThickness:e=.5,leadWidth:n=1.6,leadLength:o=2.4,leadsPitch:i=2.54,leadsLeft:r,leadsRight:s,leadsTop:a,leadsBottom:A,innerHoles:c=!0,innerHoleEdgeDistance:l=1.61,innerHoleDiameter:g=1})=>{const u=t/2,h=e/2,d=e*1.05,_=g/2,m=Math.max(r||0,s||0,a||0,A||0)*i||51,p=[],I=[];if(s){const E=-((s-1)/2)*i;for(let B=0;B<s;B++){const Q=E+B*i;p.push({x:u-o/2,y:-Q,pl:o,pw:n}),c&&I.push({x:u,y:-Q},{x:u-l,y:-Q})}}if(r){const E=-((r-1)/2)*i;for(let B=0;B<r;B++){const Q=E+B*i;p.push({x:-u+o/2,y:-Q,pl:o,pw:n}),c&&I.push({x:-u,y:-Q},{x:-u+l,y:-Q})}}if(a){const E=-((a-1)/2)*i;for(let B=0;B<a;B++){const Q=E+B*i;p.push({x:-Q,y:m/2-o/2,pl:n,pw:o}),c&&I.push({x:-Q,y:m/2},{x:-Q,y:m/2-l})}}if(A){const E=-((A-1)/2)*i;for(let B=0;B<A;B++){const Q=E+B*i;p.push({x:-Q,y:-m/2+o/2,pl:n,pw:o}),c&&I.push({x:-Q,y:-m/2},{x:-Q,y:-m/2+l})}}const f=Ye(ir,{color:"#051a0a",children:Mn(k_,{children:[Ye(Jt,{center:[0,0,h],size:[t,m,e]}),p.map((E,B)=>Ye(Jt,{center:[E.x,E.y,h],size:[E.pl+.01,E.pw+.01,d]},B))]})}),C=c&&I.map((E,B)=>Ye(_A,{color:"black",center:[E.x,E.y,h],radius:_,height:e*1.07})),y=p.map((E,B)=>Ye(Jt,{center:[E.x,E.y,h],size:[E.pl+.01,E.pw+.01,d]}));return Mn(Oi,{children:[f,Ye(ir,{color:"#FFD700",children:c?Mn(k_,{children:[Ye(T_,{children:p.map((E,B)=>Ye(Jt,{center:[E.x,E.y,h],size:[E.pl+.01,E.pw+.01,d]},B))}),C]}):y})]})},s6o=({width:t=30,height:e=22,thickness:n=1,bezelInset:o=2,bezelDepth:i=1,screenColor:r="#001414",bezelColor:s="#0f1116",screenWidth:a,screenHeight:A,offset:c})=>{const l=t,g=e,u=Math.max(n,.4),h=Math.max(Math.min(i,u),.2),d=Math.max(u-h,0),_=Math.max(o,0),m=Math.max(a??l-_*2,2),p=Math.max(A??g-_*2,2),I=Math.min(Math.max(h*.6,.2),h),f=c?.x??0,C=c?.y??0,y=c?.z??0;return Mn(jo,{offset:{x:f,y:C,z:y},children:[d>0&&Ye(ir,{color:s,children:Ye(Jt,{size:[l,g,d],offset:[0,0,d/2]})}),Ye(ir,{color:s,children:Mn(k_,{children:[Ye(Jt,{size:[l,g,h],offset:[0,0,d+h/2]}),Ye(Jt,{size:[m,p,h+.02],offset:[0,0,d+h/2]})]})}),Ye(ir,{color:r,children:Ye(Jt,{size:[m,p,I],offset:[0,0,d+I/2]})})]})},a6o=({numPins:t=5,rows:e=1,p:n=2.54,id:o=1,od:i=1.5,boardThickness:r=1.6,width:s,height:a,pinRowSide:A="left",holes:c=[],holeInset:l=1,pinRowHoleEdgeToEdgeDist:g=2,female:u,nopin:h,screen:d,screenWidth:_,screenHeight:m,screenCenterOffsetX:p,screenCenterOffsetY:I})=>{const f=d??!1,C=r/2,y=Math.ceil(t/e);let E,B;A==="left"||A==="right"?(E=(e-1)*n+2*g,B=(y-1)*n+2*g):(B=(e-1)*n+2*g,E=(y-1)*n+2*g),t===0&&(E=10,B=10);const Q=Number(s??E),b=Number(a??B),D=[];let R=0,M=0,L=0,G=0,O=0,U=0;A==="left"||A==="right"?(R=A==="left"?-Q/2+g:Q/2-g,M=-((y-1)/2)*n,L=0,G=n,O=A==="left"?n:-n,U=0):(R=-((y-1)/2)*n,M=A==="top"?b/2-g:-b/2+g,L=n,G=0,O=0,U=A==="top"?-n:n);let W=0;for(let de=0;de<e&&W<t;de++)for(let Ee=0;Ee<y&&W<t;Ee++){const he=R+Ee*L+de*O,ve=M+Ee*G+de*U;D.push({x:he,y:ve}),W++}const j=[];if(c)for(const de of c){let Ee=0,he=0;de==="topleft"?(Ee=-Q/2+l,he=b/2-l):de==="topright"?(Ee=Q/2-l,he=b/2-l):de==="bottomleft"?(Ee=-Q/2+l,he=-b/2+l):de==="bottomright"?(Ee=Q/2-l,he=-b/2+l):de==="center"&&(Ee=0,he=0),j.push({x:Ee,y:he})}const te=.63,ie=2,$=6,Z=3,se=h||u?0:ie,ae=se+r,ce=Ye(ir,{color:"#008080",children:Mn(k_,{children:[Ye(Jt,{center:[0,0,C+se],size:[Q,b,r]}),j.map((de,Ee)=>Ye(_A,{center:[de.x,de.y,C+se],radius:i/2,height:r},`hole-${Ee}`)),D.map((de,Ee)=>Ye(_A,{center:[de.x,de.y,C+se],radius:i/2,height:r},`pin-hole-${Ee}`))]})}),fe=D.map((de,Ee)=>Ye(ir,{color:"#FFD700",children:Mn(k_,{children:[Ye(_A,{center:[de.x,de.y,r/2+se],radius:i/2,height:r}),Ye(_A,{center:[de.x,de.y,r/2+se],radius:o/2,height:r})]})})),Ce=D.map((de,Ee)=>Ye(A8t,{x:de.x,y:de.y,pinThickness:te,shortSidePinLength:Z,longSidePinLength:$,bodyHeight:ie,flipZ:he=>he})),xe=D.map((de,Ee)=>Ye(_8t,{x:de.x,y:de.y,flipZ:he=>-he}));return Mn(Oi,{children:[ce,fe,!u&&!h&&Ce,u&&xe,f&&Ye(s6o,{width:_??Q*.8,height:m??b*.6,offset:{x:p??0,y:I??0,z:ae}})]})},A6o=()=>{const s=.8999999999999999,a=-s/2+.5/2-.15,A=s/2-.5/2+.15,c=.2,l=.5*.24;return Mn(Oi,{children:[Ye(Jt,{color:"#ccc",size:[.5,.28,.12],center:[a,0,.12/2]}),Ye(Jt,{color:"#ccc",size:[.5,.28,.12],center:[A,0,.12/2]}),Ye(ir,{color:"#222",children:Mn(T_,{children:[Ye(jo,{z:l/2,children:Ye(Jt,{size:[s,.6,l]})}),Mn(_c,{children:[Ye(jo,{z:l,children:Ye(Jt,{size:[s,.6,.01]})}),Ye(jo,{z:.5,children:Ye(Jt,{size:[s-c,.6-c,.01]})})]})]})}),Ye(Jt,{color:"#777",size:[1.4/6,.6-c,.02],center:[-s/4,0,.5]})]})},c6o=A6o,l6o=({numPins:t=7,showPins:e=!0,showFootprint:n=!0,bodyColor:o="#f5f5f5",pinColor:i="#635959"})=>{const c=3.5999999999999996,l=6,g=(t-1)*1.5+4,u=-((t-1)*1.5)/2;return Mn(Oi,{children:[Ye(jo,{offset:[0,0,6],children:Ye(o0,{angles:[Math.PI,0,0],children:Ye(ir,{color:o,children:Mn(k_,{children:[Ye(Jt,{size:[g,3.5,6],center:[0,0,6/2]}),Ye(Jt,{size:[g-.5*2,3.5-.5*2,c],center:[0,0,c/2]}),Ye(Jt,{size:[g,3.5/3,c],center:[0,0,c/6]}),Ye(Jt,{size:[g-.5*2,.5/2,c],center:[0,3.5/2-.5/4,c/2]}),Ye(Jt,{size:[g-.5*2,.5/2,c],center:[0,-3.5/2+.5/4,c/2]}),Ye(Jt,{size:[1,.5+2,1],center:[-g/4,3.5/2,6/2]}),Ye(Jt,{size:[1,.5+3,1],center:[g/4,3.5/2,6/2]}),Ye(Jt,{size:[1,.5+2,1],center:[-g/4,-3.5/2,6/2]}),Ye(Jt,{size:[1,.5+3,1],center:[g/4,-3.5/2,6/2]})]})})})}),e&&Array.from({length:t}).map((h,d)=>Ye(ir,{color:i,children:Ye(_A,{height:l,radius:.35,center:[u+d*1.5,0,2.5]})})),n&&Array.from({length:t}).map((h,d)=>{const _=d===0,m=_?{type:"pcb_plated_hole",pcb_plated_hole_id:`jstzh_${d}`,shape:"circular_hole_with_rect_pad",x:u+d*1.5,y:0,hole_diameter:.73,rect_pad_width:1.03,rect_pad_height:1.73,hole_shape:"circle",pad_shape:"rect",layers:["top","bottom"],port_hints:[`${d+1}`]}:{type:"pcb_plated_hole",pcb_plated_hole_id:`jstzh_${d}`,shape:"pill",x:u+d*1.5,y:0,hole_height:.73,hole_width:.73,outer_height:1.73,outer_width:1.03,layers:["top","bottom"],port_hints:[`${d+1}`]};return Ye(UMo,{hole:m,isPin1:_})})]})},g6o=([t,e],n,o,i,r)=>{const s=Math.sign(t),a=Math.sign(e),A=n/2,c=o/2,l=r?Math.min(.32,o*.36):0,g=Math.min(i,A,c),u=[[-A,-c],[A,-c],[A,c-g],[A-g,c],[-A,c]];l&&(u[0]=[-A+l,-c],u.push([-A,-c+l]));const h=u.map(([d,_])=>[t+d*s,e+_*a]);return s*a<0?h.reverse():h},S3e=({width:t,length:e,radius:n,height:o,z:i})=>{const r=t/2-n,s=e/2-n;return[[-r,-s],[r,-s],[r,s],[-r,s]].map(([a,A],c)=>Ye(_A,{center:[a,A,i+o/2],height:o,radius:n}))},u6o=({horizontalPadPitch:t=2.2,verticalPadPitch:e=1.7,padWidth:n=1.4,padHeight:o=1.2,bodyHeight:i=.7})=>{const r=t+n*.7142857142857143,s=e+o*(2/3),a=Math.min(.01,i*.02),A=n*(5/7),c=o*.75,l=i*(5/7),g=l-a,u=i*(2/35),h=r*.95,d=s*.94,_=r*.905,m=s*.9,p=r*.83,I=s*.82,f=l+u,C=Math.min(.01,i*.015),y=Math.min(.12,s*.05),E=(r-A)/2,B=(s-c)/2,Q=[[-E,-B],[E,-B],[E,B],[-E,B]],b=S3e({width:h,length:d,radius:Math.min(.13,d*.08),height:u,z:l}),D=[...S3e({width:_,length:m,radius:Math.min(.14,m*.08),height:C,z:f}),...S3e({width:p,length:I,radius:Math.min(.15,I*.09),height:C,z:i-C})];return Mn(Oi,{children:[Q.map((R,M)=>Ye(ir,{color:"#d6a258",children:Ye(jT,{height:a,children:Ye(WT,{points:g6o(R,A,c,y,M===0)})})})),Ye(i0,{center:{x:0,y:0,z:a},width:r,length:s,height:g-.005,heightAboveSurface:0,color:"#34343d",taperRatio:0,straightHeightRatio:1,includeNotch:!1,chamferSize:y}),Ye(ir,{color:"#d2a057",children:Ye(_c,{children:b})}),Ye(ir,{color:"#b9bec2",children:Ye(_c,{children:D})})]})},d6o="#303339",are="#1f2227",m8t="#eee8d8",p8t="#f8f3e7",b3e="#b7bdc2",h6o="#d2d6d9",_6o="#767d82",m6o="#9ba1a5",p6o=({pinCount:t=12,pitch:e=.5,padWidth:n=.3,padLength:o=1.25,staggered:i=!1,reverse:r=!1,rowPitch:s=2.4,topPadLength:a=o,bottomPadLength:A=o,mountPadPitchX:c,mountPadOffsetY:l=2.575,mountTop:g=!1,mountPadWidth:u=2,mountPadLength:h=2.5})=>{const d=Math.max((t-1)*e,e),_=-d/2,m=c??d+(i?3.5:3.38),p=l===0?0:(g?1:-1)*l,I=Array.from({length:t},(Pe,qe)=>{const $e=i&&qe%2===1!==r,at=i?$e?s/2:-s/2:0,ct=$e?a:A;return{index:qe,x:_+qe*e,y:at,length:ct}}),f=Math.max(...I.map(Pe=>Pe.y+Pe.length/2)),C=Math.min(...I.map(Pe=>Pe.y-Pe.length/2)),y=p-h/2,E=p+h/2,B=g?C:f,Q=g?Math.max(E,f)+.67:Math.min(y,C)-.67,b=g?-1:1,D=B-b*Math.max(o*.86,1.05),R=Q+b*.22,M=Math.abs(D-R),L=(D+R)/2,G=R-b*.01,O=Math.max(d+4.9,m+u*.76),U=Math.min(O-2.3,d+1.1),W=.3,j=1.42,te=2,ie=Math.min(.92,M*.28),$=G+b*(ie/2-.04),Z=1.6,se=1.1,ae=Math.max(M-.78,1.5),ce=G+b*(ae/2+.68),fe=O-.72,Ce=.34,xe=te-Ce/2,de=G+b*Math.min(.68,M*.22),Ee=1.48,he=Math.max(n*.82,.15),ve=B,Re=Math.abs(ve-D),ze=(ve+D)/2,Ie=Math.max(ie*.8,.5),We=G+b*(Ie/2+.08),Me=m/2,Te=.75,Ve=O/2-.04,Ne=O/2-.23,Se=O/2-.32,Oe=.68;return Mn(Oi,{children:[[-1,1].map(Pe=>Ye(Jt,{color:b3e,center:[Pe*Me,p,.07],size:[u,h,.14]})),I.map(Pe=>Ye(Jt,{color:b3e,center:[Pe.x,ze,.065],size:[he,Re,.13]},`terminal:${Pe.index}`)),Ye(NI,{color:are,center:[0,L,W/2],size:[O,M,W],roundRadius:.1}),Ye(ir,{color:d6o,children:Mn(k_,{children:[Ye(NI,{center:[0,L,W+j/2],size:[O-.2,M-.12,j],roundRadius:.14}),Ye(Jt,{center:[0,$,se],size:[U,ie,Z]}),Ye(Jt,{center:[0,ce,te-Ce*.72],size:[fe-.32,ae-.16,Ce]})]})}),I.map(Pe=>Ye(NI,{color:h6o,center:[Pe.x,We,W+.82],size:[he*.82,Ie,.14],roundRadius:.035},`spring:${Pe.index}`)),I.map(Pe=>Ye(Jt,{color:b3e,center:[Pe.x,D-b*.03,W+.32],size:[he,.13,.62]},`terminal-rise:${Pe.index}`)),Ye(Jt,{color:are,center:[0,G+b*.1,W+.71],size:[U+.18,.16,.8]}),Ye(NI,{color:m8t,center:[0,ce,xe],size:[fe,ae,Ce],roundRadius:.11}),Ye(Jt,{color:p8t,center:[0,ce-b*(ae/2-.12),te-.035],size:[fe-.36,.24,.07]}),[-1,1].map(Pe=>Ye(NI,{color:m8t,center:[Pe*Se,de,Ee],size:[Oe,.92,.72],roundRadius:.1})),[-1,1].map(Pe=>Ye(jo,{x:Pe*Se,y:de,z:Ee,children:Ye(o0,{rotation:[0,Math.PI/2,0],children:Ye(_A,{color:p8t,height:Oe+.12,radius:.24})})})),[-1,1].map(Pe=>Ye(NI,{color:_6o,center:[Pe*Ve,p,Te/2],size:[.17,Math.min(h*.3,.7),Te],roundRadius:.04})),[-1,1].map(Pe=>Ye(NI,{color:m6o,center:[Pe*Ne,p,Te-.05],size:[.42,Math.min(h*.3,.7),.1],roundRadius:.035})),Ye(Jt,{color:are,center:[0,L,.025],size:[U+.7,M*.58,.05]}),Ye(Jt,{color:are,center:[0,D-b*.06,W+.82],size:[U+.4,.15,.92]})]})},I6o=({numberOfPins:t,pitch:e=2.54,pinThickness:n=.64,bodyWidth:o=2.5,bodyHeight:i=2.54,standoffHeight:r=1.27,matingPinLength:s=5.8,tailSpan:a=5.08})=>{const A=-((t-1)*e)/2,c=r+i,l=a/2,g=n*.35;return Ye(Oi,{children:Array.from({length:t},(u,h)=>{const d=A+h*e,_=h%2===0?1:-1,m=s-g,p=r-n/2;return Mn(jo,{x:d,children:[Ye(Jt,{color:"#222",size:[e,o,i],center:[0,0,r+i/2]}),Mn(ir,{color:"#d4af37",children:[Ye(Jt,{size:[n,l,n],center:[0,_*(l/2),n/2]}),Ye(Jt,{size:[n,n,p],center:[0,0,n/2+p/2]}),Ye(Jt,{size:[n,n,m],center:[0,0,c+m/2]}),Mn(_c,{children:[Ye(Jt,{size:[n,n,.01],center:[0,0,c+m]}),Ye(Jt,{size:[n*.65,n*.65,.01],center:[0,0,c+s]})]})]})]})})})},f6o=({padPitch:t,padHeight:e,color:n="#333"})=>{const o=t,i=e*.85,r=i,s=o*.2,a=o-s*2;return Mn(Oi,{children:[Ye(Jt,{size:[a,i,r],offset:[0,0,r/2],color:n}),Ye(Jt,{size:[s,r,i],offset:[o/2-s/2,0,r/2],color:"#ccc"}),Ye(Jt,{size:[s,r,i],offset:[-o/2+s/2,0,r/2],color:"#ccc"})]})},C6o=({color:t="#ffff00",bodyColor:e="#ffffff",leadColor:n="#dedede"})=>{const m=[-1.7,0,1.7],p=[-1,1];return Mn(Oi,{children:[m.flatMap(I=>p.map(f=>Ye(Jt,{color:n,size:[1.4,1,.2],center:[f*2,I,.2/2]}))),Ye(ir,{color:e,children:Mn(k_,{children:[Ye(i0,{width:5,length:5,height:1.3,heightAboveSurface:.2,center:{x:0,y:0,z:0},color:e,taperRatio:.036,straightHeightRatio:.01,includeNotch:!1}),Ye(_A,{radius:2,height:.25,center:[0,0,1.5-.25/2]}),Ye(jo,{offset:[-5/2,5/2,1.5-.3/2+.005],children:Ye(o0,{rotation:[0,0,Math.PI/4],children:Ye(Jt,{size:[.9,.9,.3+.01]})})})]})}),Ye(_A,{color:t,radius:2,height:.25,center:[0,0,1.55-.25/2]})]})},I8t=t=>Array.from({length:t},(e,n)=>n),y6o=({bodyWidth:t=16.26,bodyDepth:e=15.88,bodyHeight:n=13.5,bodyCenterY:o=-.96,ledPins:i=!1,firstPinLeft:r=!1,firstPinTop:s=!1,signalPitch:a=1.02,signalRowPitch:A=1.78,signalHoleDiameter:c=.9144,shieldPinX:l=8.13,shieldPinY:g=.13,shieldHoleDiameter:u=1.8,locatorHoleX:h=6.35,locatorHoleY:d=-3.43,locatorHoleDiameter:_=3.25,ledPinX:m=4.57,ledPinPitch:p=2.29,ledPinY:I=5.7,openingDirection:f,shellColor:C="#b7bdc2",housingColor:y="#20242a",contactColor:E="#d6a928"})=>{const B=f??(o>0?1:-1),Q=o+B*e/2,b=Math.min(.38,t*.024),D=Math.max(t-2.5,t*.72),R=Math.min(n-2.4,9.6),M=1.3+R/2,L=Math.min(4.4,e*.34),G=Q-B*L/2,O=Q-B*(L+b*.7),U=Math.max(.22,Math.min(c*.36,.38)),W=I8t(8).map(se=>{const ae=(3.5-se)*a,ce=se%2===0?-A/2:A/2;return{x:r?-ae:ae,y:s?-ce:ce}}),j=[-m-p,-m,m,m+p],te=D/10,ie=Q-B*Math.max(L*.48,1.2),$=M+R*.18,Z=Q+B*b*.2;return Mn(Oi,{children:[Mn(ir,{color:C,children:[Mn(k_,{children:[Ye(Jt,{center:[0,o,n/2],size:[t,e,n]}),Ye(Jt,{center:[0,G,M],size:[D,L+b*2,R]})]}),Ye(Jt,{center:[0,Z,.72],size:[D+.5,b*1.25,1.05]}),[-1,1].map(se=>Ye(Jt,{center:[se*l,g,.25],size:[Math.max(u*.46,.65),Math.max(u*.72,1.1),3.4]})),[-1,1].map(se=>Ye(Jt,{center:[se*t*.24,o-B*e*.08,n+.04],size:[t*.22,e*.42,.1]}))]}),Mn(ir,{color:y,children:[Mn(k_,{children:[Ye(NI,{center:[0,G,M],size:[D-.2,L+b*.5,R-.2],roundRadius:.22}),Ye(Jt,{center:[0,G-B*b*.2,M-.05],size:[D-1.25,L+b,R-1.35]})]}),Ye(Jt,{center:[0,O,M],size:[D-1.15,b,R-1.25]}),Ye(NI,{center:[0,Q-B*L*.28,1.55],size:[D-2.6,L*.5,1.15],roundRadius:.16}),[-1,1].map(se=>Ye(_A,{center:[se*h,d,-.25],radius:Math.max(_*.41,.65),height:2.7}))]}),Mn(ir,{color:E,children:[W.map(({x:se,y:ae},ce)=>Ye(_A,{center:[se,ae,.15],radius:U,height:3.1})),I8t(8).map(se=>Ye(jo,{offset:[(se-3.5)*te,ie,$+(se%2===0?.03:-.03)],children:Ye(o0,{rotation:[B*.2,0,0],children:Ye(NI,{size:[Math.max(te*.28,.28),3.25,.16],roundRadius:.05})})})),i&&j.map((se,ae)=>Ye(_A,{center:[se,I,.15],radius:U,height:3.1}))]}),i&&Mn(Oi,{children:[Ye(NI,{color:"#73b744",center:[-t/2+2.05,Q+B*b*.35,n-2.05],size:[2.15,b*1.55,1.45],roundRadius:.18}),Ye(NI,{color:"#e0aa35",center:[t/2-2.05,Q+B*b*.35,n-2.05],size:[2.15,b*1.55,1.45],roundRadius:.18})]})]})},E6o=({footprint:t})=>{let e=t;if(t.startsWith("jstzh1_5mm")){const r=t.match(/jstzh1_5mm(\d+)?/);e=`zh${r&&r[1]?r[1]:"7"}`}const n=KMo.string(e).json(),o=t.match(/_color\(([^)]+)\)/),i=o?o[1]:void 0;switch(n.fn){case"crystal":return Ye(u6o,{horizontalPadPitch:n.px,verticalPadPitch:n.py,padWidth:n.pw,padHeight:n.ph});case"dip":return Ye(qMo,{numPins:n.num_pins,pitch:n.p,bodyWidth:n.w});case"axial":return Ye(i6o,{pitch:n.p});case"tssop":return Ye(jMo,{pinCount:n.num_pins,leadLength:n.pl,leadWidth:n.pw,pitch:n.p,bodyWidth:n.w});case"msop":return Ye(XMo,{pinCount:n.num_pins,padContactLength:n.pl,leadWidth:n.pw,pitch:n.p,bodyWidth:n.w});case"vssop":return Ye(E3o,{pinCount:n.num_pins,leadLength:n.pl,leadWidth:n.pw,pitch:n.p,bodyWidth:n.w,bodyLength:n.h});case"qfp":return Ye(t3o,{pinCount:n.num_pins,pitch:n.p,leadWidth:n.pw,padContactLength:n.pl,bodyWidth:n.w});case"tqfp":return Ye(F3o,{});case"lqfp":return Ye(H3o,{pinCount:n.num_pins});case"qfn":{const r=typeof n.thermalpad?.x=="number"&&typeof n.thermalpad?.y=="number";return Ye(c3o,{num_pins:n.num_pins,bodyWidth:n.w,bodyLength:n.h,pitch:n.p,padLength:n.pl,padWidth:n.pw,thermalPadSize:r?{width:n.thermalpad.x,length:n.thermalpad.y}:void 0})}case"dfn":{const r=typeof n.thermalpad?.x=="number"&&typeof n.thermalpad?.y=="number";return Ye(O3o,{num_pins:n.num_pins,bodyWidth:n.w,bodyLength:n.h,pitch:n.p,padLength:n.pl,padWidth:n.pw,thermalPadSize:r?{width:n.thermalpad.x,length:n.thermalpad.y}:void 0})}case"pinrow":{const r=t.match(/_rows(\d+)/),s=r&&r[1]?parseInt(r[1],10):1;if(n.male)return Ye(r3o,{numberOfPins:n.num_pins,pitch:n.p,invert:n.invert,faceup:n.faceup,rows:s,smd:n.smd||n.surface_mount,rightangle:n.rightangle});if(n.female)return Ye(f3o,{numberOfPins:n.num_pins,pitch:n.p,rows:s})}case"smdpinheader":return Ye(I6o,{numberOfPins:n.num_pins,pitch:n.p,bodyWidth:n.bh});case"led5050":return Ye(C6o,{color:i});case"cap":{switch(n.imperial){case"0402":return Ye(r8t,{color:"#856c4d"});case"0603":return Ye(s8t,{color:"#856c4d"});case"0805":return Ye(a8t,{color:"#856c4d"});case"0201":return Ye(c8t,{color:"#856c4d"});case"01005":return Ye(l8t,{color:"#856c4d"});case"1206":return Ye(g8t,{color:"#856c4d"});case"1210":return Ye(u8t,{color:"#856c4d"});case"2010":return Ye(d8t,{color:"#856c4d"});case"2512":return Ye(h8t,{color:"#856c4d"})}break}case"sot235":return Ye(g3o,{});case"sot457":return Ye(W3o,{});case"sot223":return Ye(T3o,{});case"sot23w":return Ye(u3o,{});case"sot323":return Ye(L3o,{});case"sod323f":return Ye(n6o,{});case"sod323fl":return Ye(o6o,{});case"sot363":return Ye(Z3o,{});case"sot886":return Ye(e6o,{});case"sot963":return Ye(j3o,{});case"pushbutton":return Ye(C3o,{width:n.w,length:n.h,innerDiameter:n.id});case"jst":if(n.zh)return Ye(l6o,{numPins:n.num_pins});break;case"fpc":return Ye(p6o,{pinCount:n.num_pins,pitch:n.p,padWidth:n.pw,padLength:n.pl,staggered:n.staggered,reverse:n.reverse,rowPitch:n.py,topPadLength:n.toppl,bottomPadLength:n.bottompl,mountPadPitchX:n.mpx,mountPadOffsetY:n.mpy,mountTop:n.mounttop,mountPadWidth:n.mpw,mountPadLength:n.mpl});case"rj45":return Ye(y6o,{bodyWidth:n.w,bodyDepth:n.h,bodyCenterY:n.bodyy,ledPins:n.ledpins||n.num_pins===14,firstPinLeft:n.firstpinleft,firstPinTop:n.firstpintop,signalPitch:n.p,signalRowPitch:n.py,signalHoleDiameter:n.id,shieldPinX:n.shieldx,shieldPinY:n.shieldy,shieldHoleDiameter:n.shieldid,locatorHoleX:n.holex,locatorHoleY:n.holey,locatorHoleDiameter:n.holed,ledPinX:n.ledx,ledPinPitch:n.ledp,ledPinY:n.ledy});case"soic":return Ye(y3o,{pinCount:n.num_pins,leadLength:n.pl,leadWidth:n.pw,pitch:n.p,bodyWidth:n.w});case"sod523":return Ye(x3o,{});case"sod723":return Ye(c6o,{});case"sod882":return Ye(B3o,{});case"sma":return Ye(Q3o,{});case"smb":return Ye(S3o,{});case"smc":return Ye(b3o,{});case"smf":return Ye(D3o,{});case"sod123":return Ye(M3o,{});case"sod123f":return Ye(v3o,{});case"sod123fl":return Ye(P3o,{});case"sod123w":return Ye(w3o,{});case"sod128":return Ye(N3o,{});case"sod323":return Ye(t6o,{});case"sod923":return Ye(R3o,{});case"hc49":return Ye(K3o,{});case"micromelf":return Ye(U3o,{});case"minimelf":return Ye(Y3o,{});case"melf":return Ye(z3o,{});case"ms012":return Ye(V3o,{pinCount:n.num_pins,padContactLength:n.pl,leadWidth:n.pw,pitch:n.p});case"ms013":return Ye(J3o,{pinCount:n.num_pins,padContactLength:n.pl,leadWidth:n.pw,pitch:n.p});case"sot723":return Ye(G3o,{});case"to220":return Ye(q3o,{});case"to92":return Ye(X3o,{});case"stampboard":case"stampreceiver":return Ye(r6o,{bodyWidth:n.w,leadsLeft:n.left,leadsRight:n.right,leadsTop:n.top,leadsBottom:n.bottom,leadsPitch:n.p,leadWidth:n.pw,leadLength:n.pl,innerHoles:n.innerhole,innerHoleEdgeDistance:n.innerholeedgedistance});case"mountedpcbmodule":{const r=n.rows??1,s=n.pinRowSide??"left",a=n.holeInset,A=n.width,c=n.height,l=n.pinrow,g=n.pinRowHoleEdgeToEdgeDist,u=Array.isArray(n.holes)?n.holes:[];return Ye(a6o,{numPins:l,rows:r,p:n.p,id:n.id,od:n.od,width:A,height:c,pinRowSide:s,holes:u,holeInset:a,pinRowHoleEdgeToEdgeDist:g,nopin:n.nopin,female:n.female,screen:n.screen,screenWidth:n.screenwidth,screenHeight:n.screenheight,screenCenterOffsetX:n.screencenteroffsetx,screenCenterOffsetY:n.screencenteroffsety})}}switch(n.imperial){case"0402":return Ye(r8t,{color:i});case"0603":return Ye(s8t,{color:i});case"0805":return Ye(a8t,{color:i});case"0201":return Ye(c8t,{color:i});case"01005":return Ye(l8t,{color:i});case"1206":return Ye(g8t,{color:i});case"1210":return Ye(u8t,{color:i});case"2010":return Ye(d8t,{color:i});case"2512":return Ye(h8t,{color:i})}if((n.fn==="res"||n.fn==="cap")&&n.p!==void 0&&n.ph!==void 0){const r=Oa(n.p),s=Oa(n.ph);if(Number.isFinite(r)&&Number.isFinite(s))return Ye(f6o,{padPitch:r,padHeight:s,color:i??(n.fn==="cap"?"#856c4d":void 0)})}return null},x6o=t=>t&&typeof t=="object"&&"type"in t,sk=t=>{if(typeof t=="number")return t;if(typeof t=="string"){const e=/^(-?\d+(?:\.\d+)?)\s*deg$/i.exec(t);if(e)return parseFloat(e[1])*Math.PI/180;const n=Number(t);if(!Number.isNaN(n))return n}return 0},B6o=t=>Array.isArray(t)?[Number(t[0])||0,Number(t[1])||0,Number(t[2])||0]:typeof t=="object"&&t?[Number(t.x)||0,Number(t.y)||0,Number(t.z)||0]:[0,0,0];function XS(t,e,n){const{jscad:{primitives:o,booleans:i,hulls:r,geometries:s,extrusions:a,transforms:A}}=n;if(t==null||t===!1)return[];if(Array.isArray(t))return t.flatMap(u=>XS(u,e,n));if(!x6o(t))return[];const{type:c,props:l,children:g}=t;if(c===n8t)return(g??[]).flatMap(u=>XS(u,e,n));if(c===ir){const u=l?.color;return(g??[]).flatMap(h=>XS(h,u??e,n))}if(c===jo){const u=B6o(l?.offset??l?.center??{x:l?.x,y:l?.y,z:l?.z});return(g??[]).flatMap(d=>XS(d,e,n)).map(({geom:d,color:_})=>({geom:A.translate(u,d),color:_??e}))}if(c===o0){const u=Array.isArray(l?.rotation)?[sk(l.rotation[0]),sk(l.rotation[1]),sk(l.rotation[2])]:[sk(l?.x??0),sk(l?.y??0),sk(l?.z??0)];return(g??[]).flatMap(d=>XS(d,e,n)).map(({geom:d,color:_})=>({geom:A.rotateZ(u[2],A.rotateY(u[1],A.rotateX(u[0],d))),color:_}))}if(c===T_||c===k_||c===_c){const u=(g??[]).flatMap(d=>XS(d,e,n)).map(d=>d.geom);if(u.length===0)return[];let h;return c===T_?h=i.union(u):c===k_?h=i.subtract(u[0],u.slice(1)):h=r.hull(u),[{geom:h,color:e}]}if(c===WT){const u=l?.points??[];return[{geom:s.geom2.fromPoints(u),color:e??l?.color}]}if(c===jT){const u=(g??[]).flatMap(m=>XS(m,e,n)).map(m=>m.geom);if(u.length===0)return[];const h=u.length>1?i.union(u):u[0],d=l?.height??l?.h??1;let _=a.extrudeLinear({height:d},h);if(_.polygons)for(const m of _.polygons)!m.plane||!m.vertices||m.vertices.length<3||m.vertices.reverse();return[{geom:_,color:e??l?.color}]}if(c===Jt||c===o8t||c===_A||c===ore||c===NI||c===Py){let u;if(c===Jt){const h=l?.size??[1,1,1],d=l?.offset,_=l?.center??(d?[d[0],d[1],d[2]]:[0,0,0]);u=o.cuboid({size:h,center:_})}else if(c===o8t){const h=l?.size??1,d=l?.offset,_=l?.center??(d?[d[0],d[1],d[2]]:[0,0,0]);u=o.cube({size:h,center:_})}else if(c===_A){const h=l?.height??1,d=l?.radius??1,_=l?.center??[0,0,0];u=o.cylinder({height:h,radius:d,center:_})}else if(c===ore){const h=l?.radius??1,d=l?.center??[0,0,0];u=o.sphere({radius:h,center:d})}else if(c===Py){const h=l?.height??1,d=l?.radius??1,_=l?.roundRadius??.1,m=l?.center??[0,0,0];u=o.roundedCylinder({height:h,radius:d,roundRadius:_,center:m})}else{const h=l?.size??[1,1,1],d=l?.roundRadius??.1,_=l?.center??[0,0,0];u=o.roundedCuboid({size:h,roundRadius:d,center:_})}return[{geom:u,color:e??l?.color}]}if(typeof c=="function"){const u=c(l??{});return XS(u,e,n)}return(g??[]).flatMap(u=>XS(u,e,n))}function Q6o(t,e){return{geometries:XS(t,void 0,{jscad:e})}}function f8t(t){if(t.polygons){const e=[],n=[],o=[];let i=0;for(const s of t.polygons){for(const A of s.vertices)A.index=i,e.push(A[0],A[1],A[2]),t.color&&t.color.length>=3?o.push(t.color[0],t.color[1],t.color[2]):o.push(1,1,1),i++;const a=s.vertices[0].index;for(let A=2;A<s.vertices.length;A++){const c=s.vertices[A-1].index,l=s.vertices[A].index;n.push(a,c,l)}}const r=new nl;if(r.setAttribute("position",new Ug(new Float32Array(e),3)),r.setIndex(n),o.length>0&&r.setAttribute("color",new Ug(new Float32Array(o),3)),t.transforms){const s=new Ns;s.fromArray(t.transforms),r.applyMatrix4(s)}return r.computeVertexNormals(),r}if(t.sides){const e=[],n=[];for(const i of t.sides)e.push(i[0][0],i[0][1],0),t.color&&t.color.length>=3?n.push(t.color[0],t.color[1],t.color[2]):n.push(1,1,1);const o=new nl;if(o.setAttribute("position",new Ug(new Float32Array(e),3)),n.length>0&&o.setAttribute("color",new Ug(new Float32Array(n),3)),t.transforms){const i=new Ns;i.fromArray(t.transforms),o.applyMatrix4(i)}return o}return console.error("Invalid CSG object: neither polygons nor sides found"),new nl}function S6o(t,e){const n=s3e(E6o,{footprint:t});return Q6o(n,e)}var b6o=ol(qie()),C8t=X.createContext(null),D6o=()=>{const t=X.useContext(C8t);if(!t)throw new Error("useHover must be used within a HoverProvider");return t},v6o=({children:t})=>{const{camera:e,renderer:n}=MI(),[o,i]=X.useState([]),r=X.useMemo(()=>new lmo,[]),s=X.useMemo(()=>new Io,[]),a=X.useRef(o);a.current=o;const A=X.useRef(null),c=X.useCallback(d=>{i(_=>[..._,d])},[]),l=X.useCallback(d=>{if(A.current){let _=!1,m=A.current.object;for(;m;){if(m===d){_=!0;break}m=m.parent}_&&(A.current.onUnhover(),A.current=null)}i(_=>_.filter(m=>m.object!==d))},[]),g=X.useCallback(d=>{let _=d;for(;_;){const m=a.current.find(p=>p.object===_);if(m)return m;_=_.parent}},[]),u=X.useCallback(d=>{if(!n.domElement)return;const _=n.domElement.getBoundingClientRect();s.x=(d.clientX-_.left)/_.width*2-1,s.y=-((d.clientY-_.top)/_.height)*2+1,r.setFromCamera(s,e);const m=a.current.map(I=>I.object);if(m.length===0){A.current&&(A.current.onUnhover(),A.current=null);return}const p=r.intersectObjects(m,!0);if(p.length>0){const I=p[0],f=g(I.object);if(f){const C={mousePosition:[I.point.x,I.point.y,I.point.z]};A.current!==f?(A.current?.onUnhover(),f.onHover(C),A.current=f):f.onHover(C)}else A.current&&(A.current.onUnhover(),A.current=null)}else A.current&&(A.current.onUnhover(),A.current=null)},[e,n,r,s,g]);X.useEffect(()=>{const d=n.domElement;return d.addEventListener("mousemove",u),()=>{d.removeEventListener("mousemove",u)}},[n,u]);const h=X.useMemo(()=>({addHoverable:c,removeHoverable:l}),[c,l]);return Y.jsx(C8t.Provider,{value:h,children:t})},P6o=({children:t,object:e,onHover:n,onUnhover:o,isHovered:i})=>{const{addHoverable:r,removeHoverable:s}=D6o();return X.useEffect(()=>e?(r({object:e,onHover:n,onUnhover:o}),()=>{s(e)}):void 0,[e,n,o,r,s]),Y.jsx(Y.Fragment,{children:t})},tY=P6o,WB=(t,{castShadow:e=!0,receiveShadow:n=!0}={})=>{t.traverse(o=>{o instanceof Ji&&(o.castShadow=e,o.receiveShadow=n)})},w6o=({positionOffset:t,footprint:e,rotationOffset:n,onHover:o,onUnhover:i,isHovered:r,scale:s,isTranslucent:a=!1})=>{const{rootObject:A}=MI(),c=X.useMemo(()=>{if(!e)return null;const{geometries:l}=S6o(e,b6o),g=new fd;for(const u of l.flat(1/0)){const h=u.geom;if(!h||!h.polygons&&!h.sides)continue;const d=new xi(u.color);d.convertLinearToSRGB();const _={...h,color:[d.r,d.g,d.b]},m=f8t(_),p=new fg({vertexColors:!0,side:Sm,transparent:a,opacity:a?.5:1,depthWrite:!a}),I=new Ji(m,p);I.renderOrder=a?2:1,WB(I,{castShadow:!a,receiveShadow:!0}),g.add(I)}return g},[e,a]);return X.useEffect(()=>{if(!(!c||!A))return A.add(c),()=>{A.remove(c)}},[A,c]),X.useEffect(()=>{c&&(t&&c.position.fromArray(t),n&&c.rotation.fromArray(n),s!==void 0&&c.scale.setScalar(s))},[c,t?.[0],t?.[1],t?.[2],n?.[0],n?.[1],n?.[2],s]),X.useEffect(()=>{c&&c.traverse(l=>{l instanceof Ji&&l.material instanceof fg&&(r?(l.material.emissive.setHex(255),l.material.emissiveIntensity=.2):l.material.emissiveIntensity=0)})},[r,c]),c?Y.jsx(tY,{isHovered:r,onHover:o,onUnhover:i,object:c}):null},y8t=new WeakMap,M6o=()=>{const t=new Cu;return t.name="fallback-environment-map",t.mapping=ooe,t},N6o=t=>{if(!t)return null;const e=t,n=y8t.get(e);if(n)return n;let o;if(t instanceof Toe){const i=new qBe(t);o=i.fromScene(Rmo(),.04).texture,i.dispose()}else o=M6o();return y8t.set(e,o),o};function R6o(t){const e=new By;let n=!1;t.updateWorldMatrix(!0,!1);const o=t.parent?t.parent.matrixWorld.clone().invert():new Ns;return t.traverse(i=>{if(i.updateWorldMatrix(!0,!1),i instanceof Ji&&i.geometry&&(i.geometry.boundingBox||i.geometry.computeBoundingBox(),i.geometry.boundingBox)){const r=o.clone().multiply(i.matrixWorld),s=i.geometry.boundingBox.clone();s.applyMatrix4(r),n?e.union(s):(e.copy(s),n=!0)}}),n?e:null}function T6o(t){const e=R6o(t);return e?e.getSize(new Dt):new Dt}function k6o(t,e,n="contain_within_bounds"){if(!e)return[1,1,1];const o=T6o(t),i=[o.x>0?e[0]/o.x:1,o.y>0?e[1]/o.y:1,o.z>0?e[2]/o.z:1];if(n==="fill_bounds")return i;const r=Math.min(...i);return[r,r,r]}var D3e=({model:t,position:e,rotation:n,modelOffset:o=[0,0,0],modelRotation:i=[0,0,0],sourceCoordinateTransform:r,modelSize:s,modelFitMode:a="contain_within_bounds",scale:A})=>{const{rootObject:c}=MI(),l=X.useMemo(()=>new fd,[]),g=X.useMemo(()=>new fd,[]),u=X.useMemo(()=>new fd,[]),h=X.useMemo(()=>new fd,[]);return X.useEffect(()=>(l.add(g),()=>{l.remove(g)}),[l,g]),X.useEffect(()=>(g.add(u),()=>{g.remove(u)}),[g,u]),X.useEffect(()=>(u.add(h),()=>{u.remove(h)}),[u,h]),X.useEffect(()=>{for(;h.children.length>0;){const d=h.children[0];if(!d)break;h.remove(d)}t&&h.add(t)},[h,t]),X.useEffect(()=>{if(!r){h.matrixAutoUpdate=!0,h.position.set(0,0,0),h.rotation.set(0,0,0),h.scale.set(1,1,1),h.updateMatrix();return}h.matrixAutoUpdate=!1,h.matrix.copy(r),h.matrixWorldNeedsUpdate=!0},[h,r]),X.useEffect(()=>{if(c)return c.add(l),()=>{c.remove(l)}},[c,l]),X.useEffect(()=>{if(e?l.position.fromArray(e):l.position.set(0,0,0),n?l.rotation.fromArray(n):l.rotation.set(0,0,0),u.position.fromArray(o),u.rotation.fromArray(i),u.scale.setScalar(A??1),!t){g.scale.set(1,1,1);return}g.scale.set(1,1,1),g.updateWorldMatrix(!0,!0);const d=k6o(u,s,a);g.scale.set(d[0],d[1],d[2])},[l,g,t,a,o,h,u,i,s,e,n,A]),{boardTransformGroup:l}},E8t=1.25;function x8t({gltfUrl:t,position:e,rotation:n,modelOffset:o=[0,0,0],modelRotation:i=[0,0,0],sourceCoordinateTransform:r,modelSize:s,modelFitMode:a="contain_within_bounds",onHover:A,onUnhover:c,isHovered:l,scale:g,isTranslucent:u=!1}){const{renderer:h}=MI(),[d,_]=X.useState(null),[m,p]=X.useState(null),{boardTransformGroup:I}=D3e({model:d,position:e,rotation:n,modelOffset:o,modelRotation:i,sourceCoordinateTransform:r,modelSize:s,modelFitMode:a,scale:g});if(X.useEffect(()=>{if(!t)return;const f=new kmo;let C=!0;return f.load(t,y=>{if(!C)return;const E=y.scene;E.traverse(B=>{if(B instanceof Ji&&B.material){const Q=b=>{b.transparent=u,b.opacity=u?.5:1,b.depthWrite=!u,b.needsUpdate=!0};Array.isArray(B.material)?B.material.forEach(Q):Q(B.material),B.renderOrder=u?2:1}}),WB(E,{castShadow:!u,receiveShadow:!0}),_(E)},void 0,y=>{if(!C)return;console.error(`An error happened loading ${t}`,y);const E=y instanceof Error?y:new Error(`Failed to load glTF model from ${t}`);p(E)}),()=>{C=!1}},[t,u]),X.useEffect(()=>{if(!d||!h)return;const f=N6o(h);if(!f)return;const C=[],y=E=>{E instanceof fg&&(C.push({material:E,envMap:E.envMap??null,envMapIntensity:E.envMapIntensity??1}),E.envMap=f,(typeof E.envMapIntensity!="number"||E.envMapIntensity<E8t)&&(E.envMapIntensity=E8t),E.needsUpdate=!0)};return d.traverse(E=>{if(!(E instanceof Ji))return;const B=E.material;Array.isArray(B)?B.forEach(y):B&&y(B)}),()=>{C.forEach(({material:E,envMap:B,envMapIntensity:Q})=>{E.envMap=B,E.envMapIntensity=Q,E.needsUpdate=!0})}},[d,h]),X.useEffect(()=>{d&&d.traverse(f=>{if(!(f instanceof Ji))return;const C=Array.isArray(f.material)?f.material:[f.material];for(const y of C)y instanceof fg&&(l?(y.emissive.setHex(255),y.emissiveIntensity=.2):y.emissiveIntensity=0)})},[l,d]),m)throw m;return d?Y.jsx(tY,{isHovered:l,onHover:A,onUnhover:c,object:I}):null}var F6o=ol(x6t()),L6o=ol(qie()),H6o=({jscadPlan:t,positionOffset:e,rotationOffset:n,modelOffset:o=[0,0,0],modelRotation:i=[0,0,0],sourceCoordinateTransform:r,modelSize:s,modelFitMode:a="contain_within_bounds",onHover:A,onUnhover:c,isHovered:l,scale:g,isTranslucent:u=!1})=>{const{threeGeom:h,material:d}=X.useMemo(()=>{const p=(0,F6o.executeJscadOperations)(L6o.default,t);if(!p||!p.polygons&&!p.sides)return{threeGeom:null,material:null};const I=f8t(p),f=new fg({vertexColors:!0,side:Sm,transparent:u,opacity:u?.5:1,depthWrite:!u});return{threeGeom:I,material:f}},[t,u]),_=X.useMemo(()=>{if(!h)return null;const p=new Ji(h,d);return p.renderOrder=u?2:1,WB(p,{castShadow:!u,receiveShadow:!0}),p},[h,d,u]),{boardTransformGroup:m}=D3e({model:_,position:e,rotation:n,modelOffset:o,modelRotation:i,sourceCoordinateTransform:r,modelSize:s,modelFitMode:a,scale:g});return X.useEffect(()=>{if(d)if(l){const p=new xi(d.color.getHex());d.emissive.copy(p),d.emissive.setRGB(0,0,1),d.emissiveIntensity=.2}else d.emissiveIntensity=0},[l,d]),h?Y.jsx(tY,{isHovered:l,onHover:A,onUnhover:c,object:m}):null};function G6o(t){return t.replace(/(DEF|USE)\s+([^\s]+)/g,(e,n,o)=>`${n} ${o.replace(/-/g,"_")}`)}async function O6o(t){const e=await fetch(t);if(!e.ok)throw new Error(`Failed to fetch "${t}": ${e.status} ${e.statusText}`);const n=await e.text();return new ypo().parse(G6o(n),t)}typeof window<"u"&&!window.TSCIRCUIT_OBJ_LOADER_CACHE&&(window.TSCIRCUIT_OBJ_LOADER_CACHE=new Map);function K6o(t){const[e,n]=X.useState(null);return X.useEffect(()=>{if(!t)return;const o=t.replace(/&cachebust_origin=$/,""),i=window.TSCIRCUIT_OBJ_LOADER_CACHE;let r=!1;async function s(){try{if(o.endsWith(".wrl"))return await O6o(o);const A=await fetch(o);if(!A.ok)throw new Error(`Failed to fetch "${o}": ${A.status} ${A.statusText}`);const c=await A.text(),l=c.match(/newmtl[\s\S]*?endmtl/g),g=new Ppo;if(l?.length){const u=l.join(`
|
|
5474
|
-
`).replace(/^d\s+0\./gm,"d 1."),h=c.replace(/newmtl[\s\S]*?endmtl/g,"").replace(/^mtllib.*/gm,""),d=new Ipo;d.setMaterialOptions({invertTrProperty:!0});const _=d.parse(u,"embedded.mtl");return g.setMaterials(_),g.parse(h)}return g.parse(c.replace(/^mtllib.*/gm,""))}catch(A){return A}}function a(){if(i.has(o)){const c=i.get(o);return c.result?Promise.resolve(c.result.clone()):c.promise.then(l=>l instanceof Error?l:l.clone())}const A=s().then(c=>(c instanceof Error||i.set(o,{...i.get(o),result:c}),c));return i.set(o,{promise:A,result:null}),A}return a().then(A=>{r||n(A)}).catch(A=>{console.error(A)}),()=>{r=!0}},[t]),e}function U6o({url:t,position:e,rotation:n,modelOffset:o=[0,0,0],modelRotation:i=[0,0,0],sourceCoordinateTransform:r,modelSize:s,modelFitMode:a="contain_within_bounds",onHover:A,onUnhover:c,isHovered:l,scale:g,isTranslucent:u=!1}){const h=K6o(t),d=X.useMemo(()=>{if(h&&!(h instanceof Error))return h.traverse(p=>{if(p instanceof Ji&&p.material){const I=f=>{f.transparent=u,f.opacity=u?.5:1,f.depthWrite=!u,f.needsUpdate=!0};Array.isArray(p.material)?p.material.forEach(I):I(p.material),p.renderOrder=u?2:1}}),WB(h,{castShadow:!u,receiveShadow:!0}),h;const m=new Ji(new Sy(.5,.5,.5),new fg({transparent:!0,color:"red",opacity:.25}));return WB(m,{castShadow:!1,receiveShadow:!0}),m},[h,u]),{boardTransformGroup:_}=D3e({model:d,position:Array.isArray(e)?e:e?[e.x,e.y,e.z]:void 0,rotation:Array.isArray(n)?n:n?[n.x,n.y,n.z]:void 0,modelOffset:o,modelRotation:i,sourceCoordinateTransform:r,modelSize:s,modelFitMode:a,scale:g});if(h instanceof Error)throw h;return Y.jsx(tY,{isHovered:l,onHover:A,onUnhover:c,object:_})}var Y6o=new xi(.82,.82,.82),B8t=t=>new fg({color:t?new xi(t[0],t[1],t[2]):Y6o});function z6o(t,e){const n=B8t(e.color),o=e.brep_faces??[];if(o.length===0)return[n];const i=o.length>1?[...o].sort((g,u)=>g.first-u.first):o,r=[n],s=new Map,a=e.index.array.length/3;let A=0,c=0;const l=g=>{if(!g)return 0;const u=g.join(","),h=s.get(u);if(h!==void 0)return h;const d=r.length;return r.push(B8t(g)),s.set(u,d),d};for(;A<a;){const g=i[c];let u=a,h=0;g&&(A<g.first?u=g.first:(u=g.last+1,h=l(g.color),c+=1)),u>A&&t.addGroup(A*3,(u-A)*3,h),A=u}return r}function V6o(t){const e=new fd;for(const n of t){const o=n.attributes.position?.array??[],i=n.index?.array??[];if(!o.length||!i.length)continue;const r=new nl;r.setAttribute("position",new zr(o,3));const s=n.attributes.normal?.array??[];s.length?r.setAttribute("normal",new zr(s,3)):r.computeVertexNormals(),r.setIndex(i),r.clearGroups();const a=z6o(r,n),A=new Ji(r,a.length>1?a:a[0]);A.name=n.name,e.add(A)}return e}var v3e,J6o="https://cdn.jsdelivr.net/npm/occt-import-js@0.0.23/dist";function q6o(t){if(typeof t=="function")return t;if(t&&typeof t=="object"&&"default"in t&&typeof t.default=="function")return t.default;throw new Error("Unable to resolve occt-import-js factory export")}async function W6o(){if(!v3e){const t=await import("https://cdn.jsdelivr.net/npm/occt-import-js@0.0.23/+esm");v3e=q6o(t)({locateFile:n=>`${J6o}/${n}`})}return v3e}async function j6o(t){const e=await fetch(t);if(!e.ok)throw new Error(`Failed to fetch STEP file: ${e.statusText}`);const n=await e.arrayBuffer(),i=(await W6o()).ReadStepFile(new Uint8Array(n),null);if(!i.success||!i.meshes.length)throw new Error("occt-import-js failed to convert STEP file");const r=V6o(i.meshes),s=new wQe;return await new Promise((A,c)=>{s.parse(r,l=>{l instanceof ArrayBuffer?A(l):c(new Error("GLTFExporter did not return binary output"))},l=>{c(l)},{binary:!0})})}var Q8t="step-glb-cache:v2:";function X6o(t){const e=new Uint8Array(t),n=32768;let o="";for(let i=0;i<e.length;i+=n){const r=e.subarray(i,i+n);o+=String.fromCharCode(...r)}return btoa(o)}function $6o(t){const e=atob(t),n=new Uint8Array(e.length);for(let o=0;o<e.length;o+=1)n[o]=e.charCodeAt(o);return n.buffer}function Z6o(t){try{const e=localStorage.getItem(`${Q8t}${t}`);return e?$6o(e):null}catch(e){return console.warn("Failed to read STEP GLB cache",e),null}}function S8t(t,e){try{const n=X6o(e);localStorage.setItem(`${Q8t}${t}`,n)}catch(n){console.warn("Failed to write STEP GLB cache",n)}}function e8o(){const t=globalThis;return t.stepUrlToGltfModelConversions||(t.stepUrlToGltfModelConversions={inProgress:new Map,completed:new Map}),t.stepUrlToGltfModelConversions}var t8o=({stepUrl:t,position:e,rotation:n,modelOffset:o,modelRotation:i,sourceCoordinateTransform:r,modelSize:s,modelFitMode:a,scale:A,onHover:c,onUnhover:l,isHovered:g,isTranslucent:u})=>{const[h,d]=X.useState(null);return X.useEffect(()=>{let _=!0,m=null,p=!0;const I=e8o(),f=Z6o(t);if(f){const E={arrayBuffer:f,blobUrl:URL.createObjectURL(new Blob([f],{type:"model/gltf-binary"}))};return I.completed.set(t,E),m=E.blobUrl,p=!1,d(E.blobUrl),()=>{_=!1,m&&p&&URL.revokeObjectURL(m)}}const C=I.completed.get(t);if(C)return m=C.blobUrl,p=!1,d(C.blobUrl),S8t(t,C.arrayBuffer),()=>{_=!1,m&&p&&URL.revokeObjectURL(m)};let y=I.inProgress.get(t);return y||(y=j6o(t).then(E=>{const B={arrayBuffer:E,blobUrl:URL.createObjectURL(new Blob([E],{type:"model/gltf-binary"}))};return I.completed.set(t,B),I.inProgress.delete(t),B}).catch(E=>{throw I.inProgress.delete(t),E}),I.inProgress.set(t,y)),y.then(E=>{_&&(m=E.blobUrl,p=!1,d(E.blobUrl),S8t(t,E.arrayBuffer))}).catch(E=>{console.error("Failed to convert STEP file to GLB",E),_&&d(null)}),()=>{_=!1,m&&p&&URL.revokeObjectURL(m)}},[t]),h?Y.jsx(x8t,{gltfUrl:h,position:e,rotation:n,modelOffset:o,modelRotation:i,sourceCoordinateTransform:r,modelSize:s,modelFitMode:a,scale:A,onHover:c,onUnhover:l,isHovered:g,isTranslucent:u}):null};function Are(t,e){let{x:n,y:o,z:i}=t;if(e.axisMapping){const r={x:n,y:o,z:i};e.axisMapping.x&&(n=P3e(r,e.axisMapping.x)),e.axisMapping.y&&(o=P3e(r,e.axisMapping.y)),e.axisMapping.z&&(i=P3e(r,e.axisMapping.z))}if(n*=e.flipX??1,o*=e.flipY??1,i*=e.flipZ??1,e.rotation){if(e.rotation.x){const r=e.rotation.x*Math.PI/180,s=Math.cos(r),a=Math.sin(r),A=o*s-i*a,c=o*a+i*s;o=A,i=c}if(e.rotation.y){const r=e.rotation.y*Math.PI/180,s=Math.cos(r),a=Math.sin(r),A=n*s+i*a,c=-n*a+i*s;n=A,i=c}if(e.rotation.z){const r=e.rotation.z*Math.PI/180,s=Math.cos(r),a=Math.sin(r),A=n*s-o*a,c=n*a+o*s;n=A,o=c}}return{x:n,y:o,z:i}}function P3e(t,e){switch(e){case"x":return t.x;case"y":return t.y;case"z":return t.z;case"-x":return-t.x;case"-y":return-t.y;case"-z":return-t.z;default:return 0}}var w3e={STEP_INVERTED:{axisMapping:{x:"-x",y:"z",z:"-y"}},Z_UP_TO_Y_UP_USB_FIX:{axisMapping:{x:"x",y:"-z",z:"y"},flipZ:-1},FOOTPRINTER_MODEL_TRANSFORM:{axisMapping:{x:"x",y:"-z",z:"y"},flipX:-1,rotation:{x:180,y:180}}};function n8o(t,e){if(e.coordinateTransform)return e.coordinateTransform;if(!e.usingGlbCoordinates){if(e.hasFootprinterModel)return w3e.FOOTPRINTER_MODEL_TRANSFORM;if(!e.usingObjFormat)return e.usingStepFormat?w3e.STEP_INVERTED:w3e.Z_UP_TO_Y_UP_USB_FIX}}function nY(t,e){return n8o(t,{usingGlbCoordinates:e==="gltf"||e==="glb"||e==="jscad",usingObjFormat:e==="obj"||e==="wrl",usingStepFormat:e==="step",hasFootprinterModel:e==="footprinter"})}function cre(t){if(!t)return;const e=Are({x:1,y:0,z:0},t),n=Are({x:0,y:1,z:0},t),o=Are({x:0,y:0,z:1},t);return new Ns().makeBasis(new Dt(e.x,e.y,e.z),new Dt(n.x,n.y,n.z),new Dt(o.x,o.y,o.z))}function kP(t){return t*Math.PI/180}function o8o(t){if(t==="z+")return[0,0,0];switch(t){case"x+":return[0,kP(-90),0];case"x-":return[0,kP(90),0];case"y+":return[kP(90),0,0];case"y-":return[kP(-90),0,0];case"z-":return[kP(180),0,0];default:return[0,0,0]}}function i8o(t,e,n){if(!t.position)return;let o=t.position.z;return e==="bottom"&&t.position.z>=0&&(o=-(t.position.z+n)),[t.position.x,t.position.y,o]}function r8o(t,e){return t.rotation?[kP(t.rotation.x),kP(t.rotation.y),kP(t.rotation.z)]:e==="bottom"?[Math.PI,0,0]:[0,0,0]}function s8o(t,e){const n=new Dt(t.x,t.y,t.z),o=new $C(e[0],e[1],e[2],"XYZ");return n.applyEuler(o),[n.x,n.y,n.z]}function a8o(t,e,n){if(!t.model_origin_position)return[0,0,0];const o=e?Are(t.model_origin_position,e):t.model_origin_position;return s8o(o,n)}function A8o(t,e){const n=i8o(t,e.layer,e.pcbThickness),o=r8o(t,e.layer),i=nY(t,e.modelType),r=o8o(t.model_board_normal_direction??"z+"),s=a8o(t,i,r);return{position:n,rotation:o,modelPosition:[-s[0],-s[1],-s[2]],modelRotation:r,scale:t.model_unit_to_mm_scale_factor??void 0,fitMode:t.model_object_fit??"contain_within_bounds",size:t.size?[t.size.x,t.size.y,t.size.z]:void 0}}var c8o=t=>t.model_glb_url||t.model_gltf_url?t.model_glb_url?"glb":"gltf":t.model_obj_url||t.model_wrl_url||t.model_stl_url?t.model_wrl_url?"wrl":t.model_stl_url?"stl":"obj":t.model_jscad?"jscad":t.footprinter_string?"footprinter":t.model_step_url?"step":"unknown",l8o=t=>t==="step"?"glb":t,g8o=(t,e)=>{if(!t.model_jscad||t.model_origin_alignment!=="bottom_center_of_component")return!1;const n=e.find(o=>o.type==="pcb_component"&&o.pcb_component_id===t.pcb_component_id);return!!(n&&n.do_not_place&&n.is_allowed_to_be_off_board&&n.obstructs_within_bounds===!1)},u8o=(t,e)=>{if(t)return e?e(t):t},d8o=(...t)=>t,M3e=class extends Xr.Component{constructor(t){super(t),this.state={hasError:!1,error:null}}static getDerivedStateFromError(t){return{hasError:!0,error:t}}render(){return this.state.hasError&&this.state.error?this.props.fallback({error:this.state.error}):this.props.children}},h8o=({error:t,onError:e})=>(X.useEffect(()=>{e(t)},[t,e]),null),b8t=({cad_component:t,circuitJson:e,resolveStaticAsset:n})=>{const o=S6t(e),[i,r]=X.useState(!1),{visibility:s}=D6(),[a,A]=X.useState(null),c=X.useCallback(j=>{j?.mousePosition?(r(!0),A(j.mousePosition)):(r(!1),A(null))},[]),l=X.useCallback(()=>{r(!1),A(null)},[]),g=X.useMemo(()=>Hi(e).source_component.getUsing({source_component_id:t.source_component_id})?.name,[e,t.source_component_id]),u=X.useMemo(()=>e.filter(te=>te.type==="pcb_plated_hole"&&te.pcb_component_id===t.pcb_component_id).length>0,[e,t.pcb_component_id]),h=X.useCallback(j=>u8o(j,n),[n]),d=h(t.model_wrl_url??t.model_stl_url??t.model_obj_url),_=h(t.model_glb_url??t.model_gltf_url),m=h(t.model_step_url),[p,I]=X.useState(0),[f,C]=X.useState(null);X.useEffect(()=>{I(0),C(null)},[t.cad_component_id,d,_,m]);const E=e.find(j=>j.type==="pcb_component"&&j.source_component_id===t.source_component_id)?.layer??"top",B=X.useMemo(()=>g8o(t,e),[t,e]),Q=B?s.enclosure==="translucent":!!t.show_as_translucent_model,b=c8o(t),D=l8o(b),R=t.model_glb_url?"glb":"gltf",M=t.model_wrl_url?"wrl":t.model_stl_url?"stl":"obj",L=X.useMemo(()=>A8o(t,{layer:E,pcbThickness:o,modelType:D}),[t,E,o,D]),G=d8o(...L.rotation),O=L.position,U=X.useMemo(()=>{const j=[];return _&&j.push(Y.jsx(x8t,{gltfUrl:_,position:O,rotation:G,modelOffset:L.modelPosition,modelRotation:L.modelRotation,sourceCoordinateTransform:cre(nY(t,R)),scale:L.scale,modelSize:L.size,modelFitMode:L.fitMode,onHover:c,onUnhover:l,isHovered:i,isTranslucent:Q},`${t.cad_component_id}-gltf-${_}`)),d&&j.push(Y.jsx(U6o,{url:d,position:O,rotation:G,modelOffset:L.modelPosition,modelRotation:L.modelRotation,sourceCoordinateTransform:cre(nY(t,M)),scale:L.scale,modelSize:L.size,modelFitMode:L.fitMode,onHover:c,onUnhover:l,isHovered:i,isTranslucent:Q},`${t.cad_component_id}-mixed-${d}`)),m&&!t.model_jscad&&!t.footprinter_string&&j.push(Y.jsx(t8o,{stepUrl:m,position:O,rotation:G,modelOffset:L.modelPosition,modelRotation:L.modelRotation,sourceCoordinateTransform:cre(nY(t,D)),scale:L.scale,modelSize:L.size,modelFitMode:L.fitMode,onHover:c,onUnhover:l,isHovered:i,isTranslucent:Q},`${t.cad_component_id}-step-${m}`)),j},[O,t.cad_component_id,t.footprinter_string,t.model_jscad,Q,_,R,c,l,i,M,L.modelPosition,L.modelRotation,L.scale,L.fitMode,L.size,D,G,m,d]);let W=null;if(U.length>0){if(p>=U.length){if(f)throw f;return null}W=Y.jsx(M3e,{fallback:({error:j})=>Y.jsx(h8o,{error:j,onError:te=>{C(te),I(ie=>Math.max(ie,p+1))}}),children:U[p]},`${t.cad_component_id}-fallback-${p}`)}else t.model_jscad?W=Y.jsx(H6o,{jscadPlan:t.model_jscad,positionOffset:O,rotationOffset:G,modelOffset:L.modelPosition,modelRotation:L.modelRotation,sourceCoordinateTransform:cre(nY(t,"jscad")),scale:L.scale,modelSize:L.size,modelFitMode:L.fitMode,onHover:c,onUnhover:l,isHovered:i,isTranslucent:Q},t.cad_component_id):t.footprinter_string&&(W=Y.jsx(w6o,{positionOffset:O,rotationOffset:G,footprint:t.footprinter_string,scale:L.scale,onHover:c,onUnhover:l,isHovered:i,isTranslucent:Q}));if(B){if(s.enclosure==="hidden")return null}else if(t.show_as_translucent_model){if(!s.translucentModels)return null}else if(u&&!s.throughHoleModels||!u&&!s.smtModels)return null;return Y.jsxs(Y.Fragment,{children:[W,i&&a?Y.jsx(D6t,{position:a,style:{fontFamily:"sans-serif",transform:"translate3d(1rem, 1rem, 0)",backgroundColor:"white",padding:"5px",borderRadius:"3px",pointerEvents:"none",userSelect:"none",WebkitUserSelect:"none",MozUserSelect:"none",msUserSelect:"none"},children:g??"<unknown>"}):null]})},D8t={version:"0.0.591"},v8t="cadViewerLightingEnabled",_8o=()=>typeof window>"u"?!0:window.localStorage.getItem(v8t)!=="false",P8t=X.createContext(void 0),m8o=({children:t})=>{const[e,n]=X.useState(!1),[o,i]=X.useState(!1),[r,s]=X.useState(_8o);X.useEffect(()=>{window.localStorage.setItem(v8t,r?"true":"false")},[r]);const a=X.useMemo(()=>({darkBackgroundEnabled:e,setDarkBackgroundEnabled:n,gridEnabled:o,setGridEnabled:i,lightingEnabled:r,setLightingEnabled:s}),[e,o,r]);return Y.jsx(P8t.Provider,{value:a,children:t})},N3e=()=>{const t=X.useContext(P8t);if(!t)throw new Error("useAppearance must be used within an AppearanceProvider");return t},w8t="cadViewerCameraStateSession",M8t=(t,e)=>{try{const n={position:t.position.toArray(),quaternion:t.quaternion.toArray(),up:t.up.toArray(),fov:t.fov??50,target:e.target.toArray()};sessionStorage.setItem(w8t,JSON.stringify(n))}catch(n){console.warn("Failed to save camera:",n)}},R3e=(t,e)=>{try{const n=sessionStorage.getItem(w8t);if(!n)return!1;const o=JSON.parse(n);if(t.position.fromArray(o.position),t.quaternion.fromArray(o.quaternion),t.up.fromArray(o.up),"fov"in t){const i=t;i.fov=o.fov,i.updateProjectionMatrix?.()}return e.target.fromArray(o.target),e.update(),t.updateMatrixWorld(),!0}catch(n){return console.warn("Failed to restore camera:",n),!1}},N8t=X.createContext(void 0),p8o=({children:t,defaultTarget:e,initialCameraPosition:n,initialCameraType:o})=>{const i=X.useRef(null),r=X.useRef(null),[s,a]=X.useState(null),[A,c]=X.useState(o??"perspective"),[l,g]=X.useState(n??null),[u,h]=X.useState(new $C(0,0,0)),d=X.useMemo(()=>{const[I,f,C]=n??[5,-5,5],y=Math.hypot(I-e.x,f-e.y,C-e.z);return y>0?y:5},[n,e]),_=X.useCallback(I=>{const f=[e.x,e.y,e.z],C=r.current,y=i.current;let E=d;switch(C&&y&&(E=C.position.distanceTo(y.target)),I){case"Top Center Angled":{const B=E/Math.sqrt(2);return{position:[e.x,e.y-B,e.z+B],target:f,up:[0,0,1]}}case"Top Down":return{position:[e.x,e.y,e.z+E],target:f,up:[0,0,1]};case"Top Left Corner":return{position:[e.x-E*.6,e.y-E*.6,e.z+E*.6],target:f,up:[0,0,1]};case"Top Right Corner":return{position:[e.x+E*.6,e.y-E*.6,e.z+E*.6],target:f,up:[0,0,1]};case"Left Sideview":return{position:[e.x-E,e.y,e.z],target:f,up:[0,0,1]};case"Right Sideview":return{position:[e.x+E,e.y,e.z],target:f,up:[0,0,1]};case"Front":return{position:[e.x,e.y-E,e.z],target:f,up:[0,0,1]};default:return null}},[d,e,r,i]),m=X.useCallback(I=>{i.current=I},[]),p=X.useMemo(()=>({controlsRef:i,mainCameraRef:r,defaultTarget:e,baseDistance:d,controller:s,setController:a,getPresetConfig:_,handleControlsChange:m,cameraType:A,setCameraType:c,cameraPosition:l,setCameraPosition:g,cameraRotation:u,setCameraRotation:h,saveCameraToSession:M8t,loadCameraFromSession:R3e}),[e,d,s,_,m,A,l,u]);return Y.jsx(N8t.Provider,{value:p,children:t})},c5=()=>{const t=X.useContext(N8t);if(!t)throw new Error("useCameraController must be used within a CameraControllerProvider");return t},I8o=t=>t<.5?4*t*t*t:1-Math.pow(-2*t+2,3)/2,f8o=()=>{const{controlsRef:t,mainCameraRef:e,defaultTarget:n,setController:o,getPresetConfig:i}=c5(),r=X.useRef(null),s=X.useRef(new XC),a=X.useRef(new Dt),A=X.useRef(new Dt),c=X.useRef(new XC),l=X.useRef(new XC),g=X.useRef(new yl),u=X.useRef(new yl),h=X.useCallback(({position:_,target:m,up:p,durationMs:I=600})=>{if(!e.current)return;const f=t.current?.target??n,C=new Dt(_[0],_[1],_[2]),y=m?new Dt(m[0],m[1],m[2]):n.clone(),E=new Dt(...p??[0,0,1]).normalize(),B=u.current;B.position.copy(C),B.up.copy(E),B.lookAt(y);const Q=B.quaternion.clone(),b=e.current.quaternion.clone(),D=e.current.position.clone(),R=f.clone(),M=g.current;M.up.set(0,0,1),M.position.copy(D),M.lookAt(R);const L=M.quaternion.clone();M.up.set(0,0,1),M.position.copy(C),M.lookAt(y);const G=M.quaternion.clone(),O=L.clone().invert().multiply(b).normalize(),U=G.clone().invert().multiply(Q).normalize();r.current={fromPosition:D,toPosition:C,fromTarget:R,toTarget:y,toQuaternion:Q,rollFrom:O,rollTo:U,startTime:performance.now(),duration:I}},[e,t,n]),d=X.useCallback(_=>{if(_==="Custom")return;const m=i(_);m&&h(m)},[h,i]);return X.useEffect(()=>e.current?(o({animateTo:h,animateToPreset:d}),()=>{o(null)}):void 0,[h,d,e,o]),UU(()=>{if(!e.current||!r.current)return;const{fromPosition:_,toPosition:m,fromTarget:p,toTarget:I,toQuaternion:f,rollFrom:C,rollTo:y,startTime:E,duration:B}=r.current,Q=performance.now()-E,b=B<=0?1:Math.min(Q/B,1),D=I8o(b);e.current.position.lerpVectors(_,m,D);const R=a.current;R.copy(p).lerp(I,D);const M=g.current;M.up.set(0,0,1),M.position.copy(e.current.position),M.lookAt(R);const L=s.current;L.copy(M.quaternion);const G=c.current;G.copy(C);const O=l.current;O.copy(y),C.dot(y)<0&&(O.x*=-1,O.y*=-1,O.z*=-1,O.w*=-1),O.normalize(),G.slerp(O,D),e.current.quaternion.copy(L).multiply(G).normalize();const U=A.current;U.set(0,1,0).applyQuaternion(e.current.quaternion).normalize(),e.current.up.copy(U),t.current?.target.copy(R),e.current.updateMatrixWorld(),t.current?.update(),b>=1&&(e.current.position.copy(m),e.current.quaternion.copy(f),e.current.up.set(0,0,1),e.current.updateMatrixWorld(),t.current?.target.copy(I),t.current?.update(),r.current=null)}),null},C8o=()=>{const{controlsRef:t}=c5(),e=X.useRef(null),n=X.useRef(!1),o=X.useRef(null),i=X.useCallback(s=>{e.current=s,!n.current&&t.current&&R3e(s,t.current)&&(n.current=!0)},[t]),r=X.useCallback(()=>{if(!(!e.current||!t.current)){if(!n.current&&R3e(e.current,t.current)){n.current=!0;return}clearTimeout(o.current),o.current=setTimeout(()=>{e.current&&t.current&&M8t(e.current,t.current)},150)}},[t]);return{handleCameraCreated:i,handleControlsChange:r}};function y8o(t){t.querySelectorAll("canvas").forEach(e=>e.remove())}var E8o=t=>{t.outputColorSpace=q2,t.toneMapping=w2t,t.toneMappingExposure=1,t.shadowMap.enabled=!0,t.shadowMap.type=b2t},x8o=X.forwardRef(({children:t,scene:e,camera:n,style:o,onCreated:i},r)=>{const{cameraType:s}=c5(),a=X.useRef(null),[A,c]=X.useState(null),l=X.useRef([]),g=X.useRef(void 0);g.current=i;const u=X.useRef(null),h=X.useCallback(p=>{l.current.push(p)},[]),d=X.useCallback(p=>{l.current=l.current.filter(I=>I!==p)},[]),_=X.useMemo(()=>new l6,[]);e?.up&&_.up.set(e.up.x,e.up.y,e.up.z);const m=X.useRef(new yl);return X.useImperativeHandle(r,()=>m.current),X.useEffect(()=>{if(!a.current)return;y8o(a.current);const p=new Toe({antialias:!0,alpha:!0});E8o(p),p.setSize(a.current.clientWidth,a.current.clientHeight),p.setPixelRatio(window.devicePixelRatio),a.current.appendChild(p.domElement);const I=a.current.clientWidth/a.current.clientHeight,f=s==="perspective"?new Dm(75,I,.1,1e3):new CT(-10*I,10*I,10,-10,-1e3,1e3);u.current?(f.position.copy(u.current.position),f.quaternion.copy(u.current.quaternion),f.up.copy(u.current.up)):(n?.up&&f.up.set(n.up[0],n.up[1],n.up[2]),n?.position&&f.position.set(n.position[0],n.position[1],n.position[2]),f.lookAt(0,0,0)),_.add(m.current),window.__TSCIRCUIT_THREE_OBJECT=m.current,c({scene:_,camera:f,renderer:p,rootObject:m.current,addFrameListener:h,removeFrameListener:d}),g.current?.({camera:f,renderer:p});let C;const y=new emo,E=()=>{const Q=y.getElapsedTime(),b=y.getDelta();l.current.forEach(D=>D(Q,b)),p.render(_,f),C=requestAnimationFrame(E)};E();const B=()=>{if(a.current){const Q=a.current.clientWidth/a.current.clientHeight;f instanceof Dm?f.aspect=Q:f instanceof CT&&(f.left=-10*Q,f.right=10*Q,f.top=10,f.bottom=-10),f.updateProjectionMatrix(),p.setSize(a.current.clientWidth,a.current.clientHeight)}};return window.addEventListener("resize",B),()=>{u.current={position:f.position.clone(),quaternion:f.quaternion.clone(),up:f.up.clone()},window.removeEventListener("resize",B),cancelAnimationFrame(C),a.current&&p.domElement&&a.current.removeChild(p.domElement),p.dispose(),_.remove(m.current),window.__TSCIRCUIT_THREE_OBJECT===m.current&&(window.__TSCIRCUIT_THREE_OBJECT=void 0)}},[_,h,d,s]),Y.jsx("div",{ref:a,style:{width:"100%",height:"100%",...o},children:A&&Y.jsx(b6t.Provider,{value:A,children:Y.jsx(v6o,{children:t})})})}),B8o=`
|
|
5474
|
+
`).replace(/^d\s+0\./gm,"d 1."),h=c.replace(/newmtl[\s\S]*?endmtl/g,"").replace(/^mtllib.*/gm,""),d=new Ipo;d.setMaterialOptions({invertTrProperty:!0});const _=d.parse(u,"embedded.mtl");return g.setMaterials(_),g.parse(h)}return g.parse(c.replace(/^mtllib.*/gm,""))}catch(A){return A}}function a(){if(i.has(o)){const c=i.get(o);return c.result?Promise.resolve(c.result.clone()):c.promise.then(l=>l instanceof Error?l:l.clone())}const A=s().then(c=>(c instanceof Error||i.set(o,{...i.get(o),result:c}),c));return i.set(o,{promise:A,result:null}),A}return a().then(A=>{r||n(A)}).catch(A=>{console.error(A)}),()=>{r=!0}},[t]),e}function U6o({url:t,position:e,rotation:n,modelOffset:o=[0,0,0],modelRotation:i=[0,0,0],sourceCoordinateTransform:r,modelSize:s,modelFitMode:a="contain_within_bounds",onHover:A,onUnhover:c,isHovered:l,scale:g,isTranslucent:u=!1}){const h=K6o(t),d=X.useMemo(()=>{if(h&&!(h instanceof Error))return h.traverse(p=>{if(p instanceof Ji&&p.material){const I=f=>{f.transparent=u,f.opacity=u?.5:1,f.depthWrite=!u,f.needsUpdate=!0};Array.isArray(p.material)?p.material.forEach(I):I(p.material),p.renderOrder=u?2:1}}),WB(h,{castShadow:!u,receiveShadow:!0}),h;const m=new Ji(new Sy(.5,.5,.5),new fg({transparent:!0,color:"red",opacity:.25}));return WB(m,{castShadow:!1,receiveShadow:!0}),m},[h,u]),{boardTransformGroup:_}=D3e({model:d,position:Array.isArray(e)?e:e?[e.x,e.y,e.z]:void 0,rotation:Array.isArray(n)?n:n?[n.x,n.y,n.z]:void 0,modelOffset:o,modelRotation:i,sourceCoordinateTransform:r,modelSize:s,modelFitMode:a,scale:g});if(h instanceof Error)throw h;return Y.jsx(tY,{isHovered:l,onHover:A,onUnhover:c,object:_})}var Y6o=new xi(.82,.82,.82),B8t=t=>new fg({color:t?new xi(t[0],t[1],t[2]):Y6o});function z6o(t,e){const n=B8t(e.color),o=e.brep_faces??[];if(o.length===0)return[n];const i=o.length>1?[...o].sort((g,u)=>g.first-u.first):o,r=[n],s=new Map,a=e.index.array.length/3;let A=0,c=0;const l=g=>{if(!g)return 0;const u=g.join(","),h=s.get(u);if(h!==void 0)return h;const d=r.length;return r.push(B8t(g)),s.set(u,d),d};for(;A<a;){const g=i[c];let u=a,h=0;g&&(A<g.first?u=g.first:(u=g.last+1,h=l(g.color),c+=1)),u>A&&t.addGroup(A*3,(u-A)*3,h),A=u}return r}function V6o(t){const e=new fd;for(const n of t){const o=n.attributes.position?.array??[],i=n.index?.array??[];if(!o.length||!i.length)continue;const r=new nl;r.setAttribute("position",new zr(o,3));const s=n.attributes.normal?.array??[];s.length?r.setAttribute("normal",new zr(s,3)):r.computeVertexNormals(),r.setIndex(i),r.clearGroups();const a=z6o(r,n),A=new Ji(r,a.length>1?a:a[0]);A.name=n.name,e.add(A)}return e}var v3e,J6o="https://cdn.jsdelivr.net/npm/occt-import-js@0.0.23/dist";function q6o(t){if(typeof t=="function")return t;if(t&&typeof t=="object"&&"default"in t&&typeof t.default=="function")return t.default;throw new Error("Unable to resolve occt-import-js factory export")}async function W6o(){if(!v3e){const t=await import("https://cdn.jsdelivr.net/npm/occt-import-js@0.0.23/+esm");v3e=q6o(t)({locateFile:n=>`${J6o}/${n}`})}return v3e}async function j6o(t){const e=await fetch(t);if(!e.ok)throw new Error(`Failed to fetch STEP file: ${e.statusText}`);const n=await e.arrayBuffer(),i=(await W6o()).ReadStepFile(new Uint8Array(n),null);if(!i.success||!i.meshes.length)throw new Error("occt-import-js failed to convert STEP file");const r=V6o(i.meshes),s=new wQe;return await new Promise((A,c)=>{s.parse(r,l=>{l instanceof ArrayBuffer?A(l):c(new Error("GLTFExporter did not return binary output"))},l=>{c(l)},{binary:!0})})}var Q8t="step-glb-cache:v2:";function X6o(t){const e=new Uint8Array(t),n=32768;let o="";for(let i=0;i<e.length;i+=n){const r=e.subarray(i,i+n);o+=String.fromCharCode(...r)}return btoa(o)}function $6o(t){const e=atob(t),n=new Uint8Array(e.length);for(let o=0;o<e.length;o+=1)n[o]=e.charCodeAt(o);return n.buffer}function Z6o(t){try{const e=localStorage.getItem(`${Q8t}${t}`);return e?$6o(e):null}catch(e){return console.warn("Failed to read STEP GLB cache",e),null}}function S8t(t,e){try{const n=X6o(e);localStorage.setItem(`${Q8t}${t}`,n)}catch(n){console.warn("Failed to write STEP GLB cache",n)}}function e8o(){const t=globalThis;return t.stepUrlToGltfModelConversions||(t.stepUrlToGltfModelConversions={inProgress:new Map,completed:new Map}),t.stepUrlToGltfModelConversions}var t8o=({stepUrl:t,position:e,rotation:n,modelOffset:o,modelRotation:i,sourceCoordinateTransform:r,modelSize:s,modelFitMode:a,scale:A,onHover:c,onUnhover:l,isHovered:g,isTranslucent:u})=>{const[h,d]=X.useState(null);return X.useEffect(()=>{let _=!0,m=null,p=!0;const I=e8o(),f=Z6o(t);if(f){const E={arrayBuffer:f,blobUrl:URL.createObjectURL(new Blob([f],{type:"model/gltf-binary"}))};return I.completed.set(t,E),m=E.blobUrl,p=!1,d(E.blobUrl),()=>{_=!1,m&&p&&URL.revokeObjectURL(m)}}const C=I.completed.get(t);if(C)return m=C.blobUrl,p=!1,d(C.blobUrl),S8t(t,C.arrayBuffer),()=>{_=!1,m&&p&&URL.revokeObjectURL(m)};let y=I.inProgress.get(t);return y||(y=j6o(t).then(E=>{const B={arrayBuffer:E,blobUrl:URL.createObjectURL(new Blob([E],{type:"model/gltf-binary"}))};return I.completed.set(t,B),I.inProgress.delete(t),B}).catch(E=>{throw I.inProgress.delete(t),E}),I.inProgress.set(t,y)),y.then(E=>{_&&(m=E.blobUrl,p=!1,d(E.blobUrl),S8t(t,E.arrayBuffer))}).catch(E=>{console.error("Failed to convert STEP file to GLB",E),_&&d(null)}),()=>{_=!1,m&&p&&URL.revokeObjectURL(m)}},[t]),h?Y.jsx(x8t,{gltfUrl:h,position:e,rotation:n,modelOffset:o,modelRotation:i,sourceCoordinateTransform:r,modelSize:s,modelFitMode:a,scale:A,onHover:c,onUnhover:l,isHovered:g,isTranslucent:u}):null};function Are(t,e){let{x:n,y:o,z:i}=t;if(e.axisMapping){const r={x:n,y:o,z:i};e.axisMapping.x&&(n=P3e(r,e.axisMapping.x)),e.axisMapping.y&&(o=P3e(r,e.axisMapping.y)),e.axisMapping.z&&(i=P3e(r,e.axisMapping.z))}if(n*=e.flipX??1,o*=e.flipY??1,i*=e.flipZ??1,e.rotation){if(e.rotation.x){const r=e.rotation.x*Math.PI/180,s=Math.cos(r),a=Math.sin(r),A=o*s-i*a,c=o*a+i*s;o=A,i=c}if(e.rotation.y){const r=e.rotation.y*Math.PI/180,s=Math.cos(r),a=Math.sin(r),A=n*s+i*a,c=-n*a+i*s;n=A,i=c}if(e.rotation.z){const r=e.rotation.z*Math.PI/180,s=Math.cos(r),a=Math.sin(r),A=n*s-o*a,c=n*a+o*s;n=A,o=c}}return{x:n,y:o,z:i}}function P3e(t,e){switch(e){case"x":return t.x;case"y":return t.y;case"z":return t.z;case"-x":return-t.x;case"-y":return-t.y;case"-z":return-t.z;default:return 0}}var w3e={STEP_INVERTED:{axisMapping:{x:"-x",y:"z",z:"-y"}},Z_UP_TO_Y_UP_USB_FIX:{axisMapping:{x:"x",y:"-z",z:"y"},flipZ:-1},FOOTPRINTER_MODEL_TRANSFORM:{axisMapping:{x:"x",y:"-z",z:"y"},flipX:-1,rotation:{x:180,y:180}}};function n8o(t,e){if(e.coordinateTransform)return e.coordinateTransform;if(!e.usingGlbCoordinates){if(e.hasFootprinterModel)return w3e.FOOTPRINTER_MODEL_TRANSFORM;if(!e.usingObjFormat)return e.usingStepFormat?w3e.STEP_INVERTED:w3e.Z_UP_TO_Y_UP_USB_FIX}}function nY(t,e){return n8o(t,{usingGlbCoordinates:e==="gltf"||e==="glb"||e==="jscad",usingObjFormat:e==="obj"||e==="wrl",usingStepFormat:e==="step",hasFootprinterModel:e==="footprinter"})}function cre(t){if(!t)return;const e=Are({x:1,y:0,z:0},t),n=Are({x:0,y:1,z:0},t),o=Are({x:0,y:0,z:1},t);return new Ns().makeBasis(new Dt(e.x,e.y,e.z),new Dt(n.x,n.y,n.z),new Dt(o.x,o.y,o.z))}function kP(t){return t*Math.PI/180}function o8o(t){if(t==="z+")return[0,0,0];switch(t){case"x+":return[0,kP(-90),0];case"x-":return[0,kP(90),0];case"y+":return[kP(90),0,0];case"y-":return[kP(-90),0,0];case"z-":return[kP(180),0,0];default:return[0,0,0]}}function i8o(t,e,n){if(!t.position)return;let o=t.position.z;return e==="bottom"&&t.position.z>=0&&(o=-(t.position.z+n)),[t.position.x,t.position.y,o]}function r8o(t,e){return t.rotation?[kP(t.rotation.x),kP(t.rotation.y),kP(t.rotation.z)]:e==="bottom"?[Math.PI,0,0]:[0,0,0]}function s8o(t,e){const n=new Dt(t.x,t.y,t.z),o=new $C(e[0],e[1],e[2],"XYZ");return n.applyEuler(o),[n.x,n.y,n.z]}function a8o(t,e,n){if(!t.model_origin_position)return[0,0,0];const o=e?Are(t.model_origin_position,e):t.model_origin_position;return s8o(o,n)}function A8o(t,e){const n=i8o(t,e.layer,e.pcbThickness),o=r8o(t,e.layer),i=nY(t,e.modelType),r=o8o(t.model_board_normal_direction??"z+"),s=a8o(t,i,r);return{position:n,rotation:o,modelPosition:[-s[0],-s[1],-s[2]],modelRotation:r,scale:t.model_unit_to_mm_scale_factor??void 0,fitMode:t.model_object_fit??"contain_within_bounds",size:t.size?[t.size.x,t.size.y,t.size.z]:void 0}}var c8o=t=>t.model_glb_url||t.model_gltf_url?t.model_glb_url?"glb":"gltf":t.model_obj_url||t.model_wrl_url||t.model_stl_url?t.model_wrl_url?"wrl":t.model_stl_url?"stl":"obj":t.model_jscad?"jscad":t.footprinter_string?"footprinter":t.model_step_url?"step":"unknown",l8o=t=>t==="step"?"glb":t,g8o=(t,e)=>{if(!t.model_jscad||t.model_origin_alignment!=="bottom_center_of_component")return!1;const n=e.find(o=>o.type==="pcb_component"&&o.pcb_component_id===t.pcb_component_id);return!!(n&&n.do_not_place&&n.is_allowed_to_be_off_board&&n.obstructs_within_bounds===!1)},u8o=(t,e)=>{if(t)return e?e(t):t},d8o=(...t)=>t,M3e=class extends Xr.Component{constructor(t){super(t),this.state={hasError:!1,error:null}}static getDerivedStateFromError(t){return{hasError:!0,error:t}}render(){return this.state.hasError&&this.state.error?this.props.fallback({error:this.state.error}):this.props.children}},h8o=({error:t,onError:e})=>(X.useEffect(()=>{e(t)},[t,e]),null),b8t=({cad_component:t,circuitJson:e,resolveStaticAsset:n})=>{const o=S6t(e),[i,r]=X.useState(!1),{visibility:s}=D6(),[a,A]=X.useState(null),c=X.useCallback(j=>{j?.mousePosition?(r(!0),A(j.mousePosition)):(r(!1),A(null))},[]),l=X.useCallback(()=>{r(!1),A(null)},[]),g=X.useMemo(()=>Hi(e).source_component.getUsing({source_component_id:t.source_component_id})?.name,[e,t.source_component_id]),u=X.useMemo(()=>e.filter(te=>te.type==="pcb_plated_hole"&&te.pcb_component_id===t.pcb_component_id).length>0,[e,t.pcb_component_id]),h=X.useCallback(j=>u8o(j,n),[n]),d=h(t.model_wrl_url??t.model_stl_url??t.model_obj_url),_=h(t.model_glb_url??t.model_gltf_url),m=h(t.model_step_url),[p,I]=X.useState(0),[f,C]=X.useState(null);X.useEffect(()=>{I(0),C(null)},[t.cad_component_id,d,_,m]);const E=e.find(j=>j.type==="pcb_component"&&j.source_component_id===t.source_component_id)?.layer??"top",B=X.useMemo(()=>g8o(t,e),[t,e]),Q=B?s.enclosure==="translucent":!!t.show_as_translucent_model,b=c8o(t),D=l8o(b),R=t.model_glb_url?"glb":"gltf",M=t.model_wrl_url?"wrl":t.model_stl_url?"stl":"obj",L=X.useMemo(()=>A8o(t,{layer:E,pcbThickness:o,modelType:D}),[t,E,o,D]),G=d8o(...L.rotation),O=L.position,U=X.useMemo(()=>{const j=[];return _&&j.push(Y.jsx(x8t,{gltfUrl:_,position:O,rotation:G,modelOffset:L.modelPosition,modelRotation:L.modelRotation,sourceCoordinateTransform:cre(nY(t,R)),scale:L.scale,modelSize:L.size,modelFitMode:L.fitMode,onHover:c,onUnhover:l,isHovered:i,isTranslucent:Q},`${t.cad_component_id}-gltf-${_}`)),d&&j.push(Y.jsx(U6o,{url:d,position:O,rotation:G,modelOffset:L.modelPosition,modelRotation:L.modelRotation,sourceCoordinateTransform:cre(nY(t,M)),scale:L.scale,modelSize:L.size,modelFitMode:L.fitMode,onHover:c,onUnhover:l,isHovered:i,isTranslucent:Q},`${t.cad_component_id}-mixed-${d}`)),m&&!t.model_jscad&&!t.footprinter_string&&j.push(Y.jsx(t8o,{stepUrl:m,position:O,rotation:G,modelOffset:L.modelPosition,modelRotation:L.modelRotation,sourceCoordinateTransform:cre(nY(t,D)),scale:L.scale,modelSize:L.size,modelFitMode:L.fitMode,onHover:c,onUnhover:l,isHovered:i,isTranslucent:Q},`${t.cad_component_id}-step-${m}`)),j},[O,t.cad_component_id,t.footprinter_string,t.model_jscad,Q,_,R,c,l,i,M,L.modelPosition,L.modelRotation,L.scale,L.fitMode,L.size,D,G,m,d]);let W=null;if(U.length>0){if(p>=U.length){if(f)throw f;return null}W=Y.jsx(M3e,{fallback:({error:j})=>Y.jsx(h8o,{error:j,onError:te=>{C(te),I(ie=>Math.max(ie,p+1))}}),children:U[p]},`${t.cad_component_id}-fallback-${p}`)}else t.model_jscad?W=Y.jsx(H6o,{jscadPlan:t.model_jscad,positionOffset:O,rotationOffset:G,modelOffset:L.modelPosition,modelRotation:L.modelRotation,sourceCoordinateTransform:cre(nY(t,"jscad")),scale:L.scale,modelSize:L.size,modelFitMode:L.fitMode,onHover:c,onUnhover:l,isHovered:i,isTranslucent:Q},t.cad_component_id):t.footprinter_string&&(W=Y.jsx(w6o,{positionOffset:O,rotationOffset:G,footprint:t.footprinter_string,scale:L.scale,onHover:c,onUnhover:l,isHovered:i,isTranslucent:Q}));if(B){if(s.enclosure==="hidden")return null}else if(t.show_as_translucent_model){if(!s.translucentModels)return null}else if(u&&!s.throughHoleModels||!u&&!s.smtModels)return null;return Y.jsxs(Y.Fragment,{children:[W,i&&a?Y.jsx(D6t,{position:a,style:{fontFamily:"sans-serif",transform:"translate3d(1rem, 1rem, 0)",backgroundColor:"white",padding:"5px",borderRadius:"3px",pointerEvents:"none",userSelect:"none",WebkitUserSelect:"none",MozUserSelect:"none",msUserSelect:"none"},children:g??"<unknown>"}):null]})},D8t={version:"0.0.592"},v8t="cadViewerLightingEnabled",_8o=()=>typeof window>"u"?!0:window.localStorage.getItem(v8t)!=="false",P8t=X.createContext(void 0),m8o=({children:t})=>{const[e,n]=X.useState(!1),[o,i]=X.useState(!1),[r,s]=X.useState(_8o);X.useEffect(()=>{window.localStorage.setItem(v8t,r?"true":"false")},[r]);const a=X.useMemo(()=>({darkBackgroundEnabled:e,setDarkBackgroundEnabled:n,gridEnabled:o,setGridEnabled:i,lightingEnabled:r,setLightingEnabled:s}),[e,o,r]);return Y.jsx(P8t.Provider,{value:a,children:t})},N3e=()=>{const t=X.useContext(P8t);if(!t)throw new Error("useAppearance must be used within an AppearanceProvider");return t},w8t="cadViewerCameraStateSession",M8t=(t,e)=>{try{const n={position:t.position.toArray(),quaternion:t.quaternion.toArray(),up:t.up.toArray(),fov:t.fov??50,target:e.target.toArray()};sessionStorage.setItem(w8t,JSON.stringify(n))}catch(n){console.warn("Failed to save camera:",n)}},R3e=(t,e)=>{try{const n=sessionStorage.getItem(w8t);if(!n)return!1;const o=JSON.parse(n);if(t.position.fromArray(o.position),t.quaternion.fromArray(o.quaternion),t.up.fromArray(o.up),"fov"in t){const i=t;i.fov=o.fov,i.updateProjectionMatrix?.()}return e.target.fromArray(o.target),e.update(),t.updateMatrixWorld(),!0}catch(n){return console.warn("Failed to restore camera:",n),!1}},N8t=X.createContext(void 0),p8o=({children:t,defaultTarget:e,initialCameraPosition:n,initialCameraType:o})=>{const i=X.useRef(null),r=X.useRef(null),[s,a]=X.useState(null),[A,c]=X.useState(o??"perspective"),[l,g]=X.useState(n??null),[u,h]=X.useState(new $C(0,0,0)),d=X.useMemo(()=>{const[I,f,C]=n??[5,-5,5],y=Math.hypot(I-e.x,f-e.y,C-e.z);return y>0?y:5},[n,e]),_=X.useCallback(I=>{const f=[e.x,e.y,e.z],C=r.current,y=i.current;let E=d;switch(C&&y&&(E=C.position.distanceTo(y.target)),I){case"Top Center Angled":{const B=E/Math.sqrt(2);return{position:[e.x,e.y-B,e.z+B],target:f,up:[0,0,1]}}case"Top Down":return{position:[e.x,e.y,e.z+E],target:f,up:[0,0,1]};case"Top Left Corner":return{position:[e.x-E*.6,e.y-E*.6,e.z+E*.6],target:f,up:[0,0,1]};case"Top Right Corner":return{position:[e.x+E*.6,e.y-E*.6,e.z+E*.6],target:f,up:[0,0,1]};case"Left Sideview":return{position:[e.x-E,e.y,e.z],target:f,up:[0,0,1]};case"Right Sideview":return{position:[e.x+E,e.y,e.z],target:f,up:[0,0,1]};case"Front":return{position:[e.x,e.y-E,e.z],target:f,up:[0,0,1]};default:return null}},[d,e,r,i]),m=X.useCallback(I=>{i.current=I},[]),p=X.useMemo(()=>({controlsRef:i,mainCameraRef:r,defaultTarget:e,baseDistance:d,controller:s,setController:a,getPresetConfig:_,handleControlsChange:m,cameraType:A,setCameraType:c,cameraPosition:l,setCameraPosition:g,cameraRotation:u,setCameraRotation:h,saveCameraToSession:M8t,loadCameraFromSession:R3e}),[e,d,s,_,m,A,l,u]);return Y.jsx(N8t.Provider,{value:p,children:t})},c5=()=>{const t=X.useContext(N8t);if(!t)throw new Error("useCameraController must be used within a CameraControllerProvider");return t},I8o=t=>t<.5?4*t*t*t:1-Math.pow(-2*t+2,3)/2,f8o=()=>{const{controlsRef:t,mainCameraRef:e,defaultTarget:n,setController:o,getPresetConfig:i}=c5(),r=X.useRef(null),s=X.useRef(new XC),a=X.useRef(new Dt),A=X.useRef(new Dt),c=X.useRef(new XC),l=X.useRef(new XC),g=X.useRef(new yl),u=X.useRef(new yl),h=X.useCallback(({position:_,target:m,up:p,durationMs:I=600})=>{if(!e.current)return;const f=t.current?.target??n,C=new Dt(_[0],_[1],_[2]),y=m?new Dt(m[0],m[1],m[2]):n.clone(),E=new Dt(...p??[0,0,1]).normalize(),B=u.current;B.position.copy(C),B.up.copy(E),B.lookAt(y);const Q=B.quaternion.clone(),b=e.current.quaternion.clone(),D=e.current.position.clone(),R=f.clone(),M=g.current;M.up.set(0,0,1),M.position.copy(D),M.lookAt(R);const L=M.quaternion.clone();M.up.set(0,0,1),M.position.copy(C),M.lookAt(y);const G=M.quaternion.clone(),O=L.clone().invert().multiply(b).normalize(),U=G.clone().invert().multiply(Q).normalize();r.current={fromPosition:D,toPosition:C,fromTarget:R,toTarget:y,toQuaternion:Q,rollFrom:O,rollTo:U,startTime:performance.now(),duration:I}},[e,t,n]),d=X.useCallback(_=>{if(_==="Custom")return;const m=i(_);m&&h(m)},[h,i]);return X.useEffect(()=>e.current?(o({animateTo:h,animateToPreset:d}),()=>{o(null)}):void 0,[h,d,e,o]),UU(()=>{if(!e.current||!r.current)return;const{fromPosition:_,toPosition:m,fromTarget:p,toTarget:I,toQuaternion:f,rollFrom:C,rollTo:y,startTime:E,duration:B}=r.current,Q=performance.now()-E,b=B<=0?1:Math.min(Q/B,1),D=I8o(b);e.current.position.lerpVectors(_,m,D);const R=a.current;R.copy(p).lerp(I,D);const M=g.current;M.up.set(0,0,1),M.position.copy(e.current.position),M.lookAt(R);const L=s.current;L.copy(M.quaternion);const G=c.current;G.copy(C);const O=l.current;O.copy(y),C.dot(y)<0&&(O.x*=-1,O.y*=-1,O.z*=-1,O.w*=-1),O.normalize(),G.slerp(O,D),e.current.quaternion.copy(L).multiply(G).normalize();const U=A.current;U.set(0,1,0).applyQuaternion(e.current.quaternion).normalize(),e.current.up.copy(U),t.current?.target.copy(R),e.current.updateMatrixWorld(),t.current?.update(),b>=1&&(e.current.position.copy(m),e.current.quaternion.copy(f),e.current.up.set(0,0,1),e.current.updateMatrixWorld(),t.current?.target.copy(I),t.current?.update(),r.current=null)}),null},C8o=()=>{const{controlsRef:t}=c5(),e=X.useRef(null),n=X.useRef(!1),o=X.useRef(null),i=X.useCallback(s=>{e.current=s,!n.current&&t.current&&R3e(s,t.current)&&(n.current=!0)},[t]),r=X.useCallback(()=>{if(!(!e.current||!t.current)){if(!n.current&&R3e(e.current,t.current)){n.current=!0;return}clearTimeout(o.current),o.current=setTimeout(()=>{e.current&&t.current&&M8t(e.current,t.current)},150)}},[t]);return{handleCameraCreated:i,handleControlsChange:r}};function y8o(t){t.querySelectorAll("canvas").forEach(e=>e.remove())}var E8o=t=>{t.outputColorSpace=q2,t.toneMapping=w2t,t.toneMappingExposure=1,t.shadowMap.enabled=!0,t.shadowMap.type=b2t},x8o=X.forwardRef(({children:t,scene:e,camera:n,style:o,onCreated:i},r)=>{const{cameraType:s}=c5(),a=X.useRef(null),[A,c]=X.useState(null),l=X.useRef([]),g=X.useRef(void 0);g.current=i;const u=X.useRef(null),h=X.useCallback(p=>{l.current.push(p)},[]),d=X.useCallback(p=>{l.current=l.current.filter(I=>I!==p)},[]),_=X.useMemo(()=>new l6,[]);e?.up&&_.up.set(e.up.x,e.up.y,e.up.z);const m=X.useRef(new yl);return X.useImperativeHandle(r,()=>m.current),X.useEffect(()=>{if(!a.current)return;y8o(a.current);const p=new Toe({antialias:!0,alpha:!0});E8o(p),p.setSize(a.current.clientWidth,a.current.clientHeight),p.setPixelRatio(window.devicePixelRatio),a.current.appendChild(p.domElement);const I=a.current.clientWidth/a.current.clientHeight,f=s==="perspective"?new Dm(75,I,.1,1e3):new CT(-10*I,10*I,10,-10,-1e3,1e3);u.current?(f.position.copy(u.current.position),f.quaternion.copy(u.current.quaternion),f.up.copy(u.current.up)):(n?.up&&f.up.set(n.up[0],n.up[1],n.up[2]),n?.position&&f.position.set(n.position[0],n.position[1],n.position[2]),f.lookAt(0,0,0)),_.add(m.current),window.__TSCIRCUIT_THREE_OBJECT=m.current,c({scene:_,camera:f,renderer:p,rootObject:m.current,addFrameListener:h,removeFrameListener:d}),g.current?.({camera:f,renderer:p});let C;const y=new emo,E=()=>{const Q=y.getElapsedTime(),b=y.getDelta();l.current.forEach(D=>D(Q,b)),p.render(_,f),C=requestAnimationFrame(E)};E();const B=()=>{if(a.current){const Q=a.current.clientWidth/a.current.clientHeight;f instanceof Dm?f.aspect=Q:f instanceof CT&&(f.left=-10*Q,f.right=10*Q,f.top=10,f.bottom=-10),f.updateProjectionMatrix(),p.setSize(a.current.clientWidth,a.current.clientHeight)}};return window.addEventListener("resize",B),()=>{u.current={position:f.position.clone(),quaternion:f.quaternion.clone(),up:f.up.clone()},window.removeEventListener("resize",B),cancelAnimationFrame(C),a.current&&p.domElement&&a.current.removeChild(p.domElement),p.dispose(),_.remove(m.current),window.__TSCIRCUIT_THREE_OBJECT===m.current&&(window.__TSCIRCUIT_THREE_OBJECT=void 0)}},[_,h,d,s]),Y.jsx("div",{ref:a,style:{width:"100%",height:"100%",...o},children:A&&Y.jsx(b6t.Provider,{value:A,children:Y.jsx(v6o,{children:t})})})}),B8o=`
|
|
5475
5475
|
varying vec3 worldPosition;
|
|
5476
5476
|
void main() {
|
|
5477
5477
|
worldPosition = (modelMatrix * vec4(position, 1.0)).xyz;
|
|
@@ -5795,7 +5795,7 @@ test("${c} should solve problem correctly", () => {
|
|
|
5795
5795
|
// Add more specific assertions based on expected output
|
|
5796
5796
|
// expect(solver.netLabelPlacementSolver!.netLabelPlacements).toMatchInlineSnapshot()
|
|
5797
5797
|
})
|
|
5798
|
-
`,g=new Blob([l],{type:"text/plain"}),u=URL.createObjectURL(g),h=document.createElement("a");h.href=u,h.download=`${c}.test.ts`,h.click(),URL.revokeObjectURL(u)}catch(A){alert(`Error generating test.ts for ${t.constructor.name}: ${A instanceof Error?A.message:String(A)}`)}o(!1)};return Y.jsxs("div",{className:`relative ${e}`,ref:i,children:[Y.jsx("button",{className:"px-2 py-1 rounded text-xs cursor-pointer",onClick:()=>o(!n),title:`Download options for ${t.constructor.name}`,children:t.constructor.name}),n&&Y.jsxs("div",{className:"absolute top-full left-0 mt-1 bg-white border border-gray-300 rounded shadow-lg z-10 min-w-[150px]",children:[Y.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:r,children:"Download JSON"}),Y.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:s,children:"Download page.tsx"}),Y.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:a,children:"Download test.ts"})]})]})},lGt=t=>t.activeSubSolver?[t,...lGt(t.activeSubSolver)]:[t],nWo=({solver:t})=>{const e=lGt(t);return Y.jsx("div",{className:"flex gap-1 items-center text-sm pt-1",children:e.map((n,o)=>Y.jsxs("div",{className:"flex items-center",children:[o>0&&Y.jsx("span",{className:"text-gray-400 mx-1",children:"→"}),Y.jsx(tWo,{solver:n})]},n.constructor.name))})},oWo=({solver:t,triggerRender:e,animationSpeed:n=25,onSolverStarted:o,onSolverCompleted:i})=>{const[r,s]=X.useReducer(_=>!_,!1),a=X.useRef(void 0),A=()=>{!t.solved&&!t.failed&&(t.step(),e())},c=()=>{!t.solved&&!t.failed&&(o&&o(t),t.solve(),e(),i&&i(t))},l=()=>{r?(a.current&&(clearInterval(a.current),a.current=void 0),s()):(s(),a.current=setInterval(()=>{if(t.solved||t.failed){a.current&&(clearInterval(a.current),a.current=void 0),s(),e(),i&&t.solved&&i(t);return}t.step(),e()},n))},g=()=>{const _=t;if(_.getCurrentPhase&&!t.solved&&!t.failed){const m=_.getCurrentPhase();for(;_.getCurrentPhase()===m&&!t.solved&&!t.failed;)t.step();e()}},u=()=>{if(t.solved||t.failed||r)return;const _=window.prompt("Step until which iteration?",`${t.iterations}`);if(_===null)return;const m=Number(_);if(!Number.isFinite(m)){window.alert("Please enter a valid number for the iteration");return}for(;t.iterations<m&&!t.solved&&!t.failed;)t.step();e(),t.solved&&i&&i(t)};X.useEffect(()=>()=>{a.current&&clearInterval(a.current)},[]),X.useEffect(()=>{(t.solved||t.failed)&&r&&(a.current&&(clearInterval(a.current),a.current=void 0),s())},[t.solved,t.failed,r]);const h=t.getCurrentPhase!==void 0,d=h?t.getCurrentPhase():null;return Y.jsxs("div",{className:"space-y-2 p-2 border-b",children:[Y.jsx("div",{className:"flex items-center",children:Y.jsx(nWo,{solver:t})}),Y.jsxs("div",{className:"flex gap-2 items-center flex-wrap",children:[Y.jsx("button",{onClick:A,disabled:t.solved||t.failed||r,className:"bg-blue-500 hover:bg-blue-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Step"}),Y.jsx("button",{onClick:c,disabled:t.solved||t.failed||r,className:"bg-green-500 hover:bg-green-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Solve"}),Y.jsx("button",{onClick:l,disabled:t.solved||t.failed,className:`px-3 py-1 rounded text-white text-sm ${r?"bg-red-500 hover:bg-red-600":"bg-yellow-500 hover:bg-yellow-600"} disabled:bg-gray-300`,children:r?"Stop":"Animate"}),Y.jsx("button",{onClick:u,disabled:t.solved||t.failed||r,className:"bg-orange-500 hover:bg-orange-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Step Until Iteration"}),h&&Y.jsx("button",{onClick:g,disabled:t.solved||t.failed||r,className:"bg-purple-500 hover:bg-purple-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Next Stage"}),Y.jsxs("div",{className:"text-sm text-gray-600",children:["Iterations: ",t.iterations]}),t.timeToSolve!==void 0&&Y.jsxs("div",{className:"text-sm text-gray-600",children:["Time: ",(t.timeToSolve/1e3).toFixed(3),"s"]}),d&&Y.jsxs("div",{className:"text-sm text-gray-600",children:["Phase: ",Y.jsx("span",{className:"font-medium",children:d})]}),t.solved&&Y.jsx("div",{className:"px-2 py-1 bg-green-100 text-green-800 rounded text-sm",children:"Solved"}),t.failed&&Y.jsx("div",{className:"px-2 py-1 bg-red-100 text-red-800 rounded text-sm",children:"Failed"})]}),t.error&&Y.jsxs("div",{className:"text-red-600 text-sm",children:["Error: ",t.error]})]})},iWo=(t,e,n)=>{const o=t.currentPipelineStepIndex;return e<o?"Completed":e===o&&t.activeSubSolver?t.activeSubSolver.failed?"Failed":"In Progress":"Not Started"},rWo=(t,e)=>{const o=t.pipelineDef[e].solverName,i=iWo(t,e),r=t[o],s=t.firstIterationOfPhase?.[o]??null,a=t.iterations;let A=0;if(i==="Completed"){const u=t.pipelineDef[e+1],h=u?t.firstIterationOfPhase?.[u.solverName]:void 0;h!==void 0&&s!==null?A=h-s:s!==null&&(A=a-s)}else i==="In Progress"&&s!==null&&(A=a-s);const c=t.timeSpentOnPhase?.[o]??0;let l=0;i==="Completed"?l=1:i==="In Progress"&&r&&(l=r.progress??0);const g=r?.stats??null;return{index:e,name:o,status:i,firstIteration:s,iterations:A,progress:l,timeSpent:c,stats:g&&Object.keys(g).length>0?g:null,solverInstance:r??null}},sWo=({status:t})=>{const e={"Not Started":"text-blue-600","In Progress":"text-yellow-600",Completed:"text-green-600",Failed:"text-red-600"};return Y.jsx("span",{className:`font-medium ${e[t]}`,children:t})},aWo=({progress:t})=>{if(t===0)return null;const e=Math.round(t*100);return Y.jsxs("div",{className:"flex items-center gap-2",children:[Y.jsx("div",{className:"w-20 h-2 bg-gray-200 rounded overflow-hidden",children:Y.jsx("div",{className:"h-full bg-blue-500 transition-all duration-200",style:{width:`${e}%`}})}),Y.jsxs("span",{className:"text-xs text-gray-500",children:[e,"%"]})]})},AWo=t=>Object.entries(t).map(([e,n])=>`${e}: ${n}`).join(", "),cWo=({stats:t})=>{if(!t||Object.keys(t).length===0)return Y.jsx("span",{children:"-"});const e=Object.entries(t),n=AWo(t);return Y.jsxs("details",{className:"cursor-pointer",children:[Y.jsx("summary",{className:"whitespace-nowrap overflow-hidden text-ellipsis max-w-[200px]",children:n}),Y.jsx("div",{className:"mt-1 text-xs",children:e.map(([o,i])=>Y.jsxs("div",{children:[o,": ",String(i)]},o))})]})},s7e=t=>{if(t===null||typeof t!="object")return t;if(Array.isArray(t))return t.map(s7e);const e={};for(const[n,o]of Object.entries(t))n.startsWith("_")||(e[n]=s7e(o));return e},lWo=(t,e)=>{try{if(typeof t.getConstructorParams!="function"){alert(`getConstructorParams() is not implemented for ${e}`);return}const n=s7e(t.getConstructorParams()),o=new Blob([JSON.stringify(n,null,2)],{type:"application/json"}),i=URL.createObjectURL(o),r=document.createElement("a");r.href=i,r.download=`${e}_input.json`,r.click(),URL.revokeObjectURL(i)}catch(n){alert(`Error downloading input for ${e}: ${n instanceof Error?n.message:String(n)}`)}},gWo=({solver:t,onStepUntilPhase:e,onDownloadInput:n})=>{const o=t.pipelineDef.map((a,A)=>rWo(t,A)),i=a=>{e?.(a)},r=a=>{a.solverInstance&&(n?n(a.solverInstance,a.name):lWo(a.solverInstance,a.name))},s=a=>`${(a/1e3).toFixed(2)}s`;return Y.jsxs("div",{className:"border-t border-gray-200",children:[Y.jsx("div",{className:"px-4 py-2 bg-gray-50 border-b border-gray-200",children:Y.jsx("h3",{className:"text-sm font-semibold text-gray-700",children:"Pipeline Steps"})}),Y.jsx("div",{className:"overflow-x-auto",children:Y.jsxs("table",{className:"w-full text-sm",children:[Y.jsx("thead",{children:Y.jsxs("tr",{className:"bg-gray-50 border-b border-gray-200",children:[Y.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Step"}),Y.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Status"}),Y.jsxs("th",{className:"px-4 py-2 text-center font-semibold text-gray-700",children:["i",Y.jsx("sub",{children:"0"})]}),Y.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Iterations"}),Y.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Progress"}),Y.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Time"}),Y.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Stats"}),Y.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Input"})]})}),Y.jsx("tbody",{children:o.map(a=>Y.jsxs("tr",{className:`border-b border-gray-100 ${a.status==="In Progress"?"bg-yellow-50":""}`,children:[Y.jsx("td",{className:"px-4 py-2",children:Y.jsxs("div",{className:"flex items-center gap-2",children:[Y.jsx("span",{className:"text-gray-400 w-6",children:String(a.index+1).padStart(2,"0")}),Y.jsx("button",{onClick:()=>i(a.name),disabled:a.status==="Completed"||t.solved||t.failed,className:"text-blue-500 hover:text-blue-700 disabled:text-gray-300 disabled:cursor-not-allowed",title:`Step until ${a.name} completes`,children:Y.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:Y.jsx("path",{fillRule:"evenodd",d:"M4.5 5.653c0-1.426 1.529-2.33 2.779-1.643l11.54 6.348c1.295.712 1.295 2.573 0 3.285L7.28 19.991c-1.25.687-2.779-.217-2.779-1.643V5.653z",clipRule:"evenodd"})})}),Y.jsx("span",{className:"font-medium text-gray-900",children:a.name})]})}),Y.jsx("td",{className:"px-4 py-2",children:Y.jsx(sWo,{status:a.status})}),Y.jsx("td",{className:"px-4 py-2 text-center text-gray-600",children:a.firstIteration!==null?a.firstIteration:""}),Y.jsx("td",{className:"px-4 py-2 text-gray-600",children:a.iterations}),Y.jsx("td",{className:"px-4 py-2",children:Y.jsx(aWo,{progress:a.progress})}),Y.jsx("td",{className:"px-4 py-2 text-gray-600",children:s(a.timeSpent)}),Y.jsx("td",{className:"px-4 py-2 text-gray-500",children:Y.jsx(cWo,{stats:a.stats})}),Y.jsx("td",{className:"px-4 py-2",children:a.solverInstance?Y.jsxs("button",{onClick:()=>r(a),className:"flex items-center gap-1 text-blue-500 hover:text-blue-700",title:`Download input for ${a.name}`,children:[Y.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:Y.jsx("path",{fillRule:"evenodd",d:"M12 2.25a.75.75 0 01.75.75v11.69l3.22-3.22a.75.75 0 111.06 1.06l-4.5 4.5a.75.75 0 01-1.06 0l-4.5-4.5a.75.75 0 111.06-1.06l3.22 3.22V3a.75.75 0 01.75-.75zm-9 13.5a.75.75 0 01.75.75v2.25a1.5 1.5 0 001.5 1.5h13.5a1.5 1.5 0 001.5-1.5V16.5a.75.75 0 011.5 0v2.25a3 3 0 01-3 3H5.25a3 3 0 01-3-3V16.5a.75.75 0 01.75-.75z",clipRule:"evenodd"})}),Y.jsx("span",{children:"Input"})]}):null})]},a.name))})]})})]})},uWo=class extends Xr.Component{constructor(t){super(t),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(t){console.error("InteractiveGraphics render error:",t)}render(){return this.state.hasError?this.props.fallback:this.props.children}};function dWo({graphics:t}){const e=t.points??[],n=t.lines??[],o=t.rects??[],i=t.circles??[],r=t.texts??[];let s=Number.POSITIVE_INFINITY,a=Number.POSITIVE_INFINITY,A=Number.NEGATIVE_INFINITY,c=Number.NEGATIVE_INFINITY;const l=(m,p)=>{typeof m=="number"&&(m<s&&(s=m),m>A&&(A=m)),typeof p=="number"&&(p<a&&(a=p),p>c&&(c=p))};for(const m of e)l(m.x,m.y);for(const m of n){const p=m.points??[];for(const I of p)l(I.x,I.y)}for(const m of o){const p=m.x??0,I=m.y??0,f=m.width??0,C=m.height??0;l(p,I),l(p+f,I+C)}for(const m of i){const p=m.x??0,I=m.y??0,f=m.radius??1;l(p-f,I-f),l(p+f,I+f)}for(const m of r)l(m.x,m.y);(!isFinite(s)||!isFinite(a)||!isFinite(A)||!isFinite(c))&&(s=-20,a=-20,A=20,c=20);const g=10,u=s-g,h=a-g,d=Math.max(1,A-s+2*g),_=Math.max(1,c-a+2*g);return Y.jsxs("svg",{className:"w-full h-[400px] bg-white",viewBox:`${u} ${h} ${d} ${_}`,role:"img","aria-label":"Graphics fallback",children:[o.map((m,p)=>Y.jsx("rect",{x:m.x??0,y:m.y??0,width:m.width??0,height:m.height??0,fill:"none",stroke:m.strokeColor??"black",strokeWidth:m.strokeWidth??1},`rect-${p}`)),n.map((m,p)=>Y.jsx("polyline",{fill:"none",stroke:m.strokeColor??"black",strokeWidth:m.strokeWidth??1,points:(m.points??[]).map(I=>`${I.x??0},${I.y??0}`).join(" ")},`line-${p}`)),i.map((m,p)=>Y.jsx("circle",{cx:m.x??0,cy:m.y??0,r:m.radius??1.5,fill:m.fillColor??"none",stroke:m.strokeColor??"black",strokeWidth:m.strokeWidth??1},`circle-${p}`)),e.map((m,p)=>Y.jsx("circle",{cx:m.x??0,cy:m.y??0,r:m.radius??1.5,fill:m.color??"black"},`point-${p}`)),r.map((m,p)=>Y.jsx("text",{x:m.x??0,y:m.y??0,fontSize:m.fontSize??10,fill:m.color??"black",children:m.text??""},`text-${p}`))]})}var hWo=({solver:t,animationSpeed:e=25,onSolverStarted:n,onSolverCompleted:o})=>{const[i,r]=X.useReducer(l=>l+1,0),s=X.useMemo(()=>{try{return t.visualize()||{points:[],lines:[],rects:[],circles:[]}}catch(l){return console.error("Visualization error:",l),{points:[],lines:[],rects:[],circles:[]}}},[t,i]),a=X.useMemo(()=>(s.rects?.length||0)===0&&(s.lines?.length||0)===0&&(s.points?.length||0)===0&&(s.circles?.length||0)===0,[s]);X.useEffect(()=>{if(!(typeof document>"u")&&!document.querySelector('script[src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4"]')){const l=document.createElement("script");l.src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4",document.head.appendChild(l)}},[]);const A=t.pipelineDef!==void 0,c=l=>{const g=t;if(!t.solved&&!t.failed){for(;!t.solved&&!t.failed&&g.currentPipelineStepIndex<=g.pipelineDef.findIndex(u=>u.solverName===l);)t.step();r()}};return Y.jsxs("div",{children:[Y.jsx(oWo,{solver:t,triggerRender:r,animationSpeed:e,onSolverStarted:n,onSolverCompleted:o}),a?Y.jsx("div",{className:"p-4 text-gray-500",children:"No Graphics Yet"}):Y.jsx(uWo,{fallback:Y.jsx(dWo,{graphics:s}),children:Y.jsx(eWo,{graphics:s})}),A&&Y.jsx(gWo,{solver:t,onStepUntilPhase:c})]})};const _Wo=()=>{X.useEffect(()=>{const t="tailwind-cdn-script";if(document.getElementById(t)||window.tailwind)return;const e=document.createElement("div");e.className="hidden",document.body.appendChild(e);const n=window.getComputedStyle(e).display==="none";if(document.body.removeChild(e),n)return;const o=document.createElement("script");o.id=t,o.src="https://cdn.tailwindcss.com",document.head.appendChild(o)},[])},mWo=1e3,rQ=(t,e)=>{const{fileName:n,mimeType:o="text/plain"}=e,i=t instanceof Blob?t:new Blob([t],{type:o}),r=URL.createObjectURL(i),s=document.createElement("a");s.href=r,s.download=n,s.target="_blank",s.rel="noopener noreferrer",s.style.display="none",document.body.appendChild(s),s.click(),document.body.removeChild(s),setTimeout(()=>{URL.revokeObjectURL(r)},mWo)},a7e=t=>{let e=t.trim().replace(/[\\/:*?"<>|]/g,"_").replace(/[\x00-\x1f]/g,"").replace(/^\.+/,"").replace(/\.+$/,"").replace(/\s+/g," ").replace(/_+/g,"_");return/^(con|prn|aux|nul|com[0-9]|lpt[0-9])$/i.test(e)&&(e=`_${e}`),e=e.slice(0,200),e||"untitled"},_b="https://github.com/tscircuit/tscircuit-autorouter/issues/new",gGt="https://github.com/tscircuit/copper-pour-solver/issues/new",uGt="https://github.com/tscircuit/calculate-packing/issues/new",pWo="https://github.com/tscircuit/matchpack/issues/new",dGt="https://github.com/tscircuit/schematic-trace-solver/issues/new?template=json-bug-report.yml",IWo={PackSolver2:uGt,LayoutPipelineSolver:pWo,AutoroutingPipelineSolver:_b,AssignableAutoroutingPipeline2:_b,AssignableAutoroutingPipeline3:_b,AutoroutingPipeline1_OriginalUnravel:_b,AutoroutingPipelineSolver3_HgPortPointPathing:_b,AutoroutingPipelineSolver4:_b,AutoroutingPipelineSolver5:_b,AutoroutingPipelineSolver7_MultiGraph:_b,AutoroutingPipelineSolver8:_b,CopperPourPipelineSolver:gGt,SchematicTracePipelineSolver:dGt},fWo=t=>t.toLowerCase().includes("pack")?hNt:t.toLowerCase().includes("rout")?ALo:OFo,hGt=t=>{const e=IWo[t];if(e)return e;const n=t.toLowerCase();return n.includes("autorout")?_b:n.includes("schematic")&&n.includes("trace")?dGt:n.includes("copperpour")?gGt:n.includes("pack")?uGt:null},CWo=t=>`${a7e(`${t.componentName}-${t.solverName}`)}-solver-input.json`,_Gt=t=>{rQ(JSON.stringify(t.solverParams,null,2),{fileName:CWo(t),mimeType:"application/json"})},yWo=({solverEvent:t})=>{const e=hGt(t.solverName);return Y.jsxs("div",{className:"rf-flex rf-items-center rf-justify-end rf-gap-2 rf-border-b rf-border-gray-200 rf-bg-gray-50 rf-px-4 rf-py-2",children:[Y.jsxs(fa,{type:"button",variant:"outline",size:"sm",onClick:()=>_Gt(t),children:[Y.jsx(ese,{className:"rf-w-4 rf-h-4"}),"Download"]}),e?Y.jsx(fa,{asChild:!0,variant:"outline",size:"sm",children:Y.jsxs("a",{href:e,target:"_blank",rel:"noopener noreferrer",children:[Y.jsx(Zre,{className:"rf-w-4 rf-h-4"}),"Report"]})}):Y.jsxs(fa,{type:"button",variant:"outline",size:"sm",disabled:!0,title:"No report link configured for this solver",children:[Y.jsx(Zre,{className:"rf-w-4 rf-h-4"}),"Report"]})]})},EWo=({solverEvent:t})=>{const e=hGt(t.solverName);return e?Y.jsx(fa,{asChild:!0,variant:"ghost",size:"icon",className:"rf-h-8 rf-w-8",children:Y.jsx("a",{href:e,target:"_blank",rel:"noopener noreferrer",title:"Report solver bug","aria-label":"Report solver bug",children:Y.jsx(Zre,{className:"rf-w-4 rf-h-4"})})}):Y.jsx(fa,{type:"button",variant:"ghost",size:"icon",className:"rf-h-8 rf-w-8",disabled:!0,title:"No report link configured for this solver","aria-label":"Report solver bug",children:Y.jsx(Zre,{className:"rf-w-4 rf-h-4"})})},xWo=({solverEvents:t=[]})=>{const[e,n]=X.useState(null);_Wo();const o=X.useMemo(()=>{const a=new Map;for(const A of t){const c=`${A.componentName}-${A.solverName}`;a.set(c,A)}return a},[t]),i=X.useMemo(()=>Array.from(o.keys()),[o]),r=e?o.get(e):null,s=X.useMemo(()=>{if(!r)return{instance:null,error:null,classFound:!1};const a=Vye[r.solverName];if(!a)return{instance:null,error:`Solver class "${r.solverName}" not found in SOLVERS registry. Available: ${Object.keys(Vye).join(", ")}`,classFound:!1};try{const A=r.solverParams,c=A?.input!==void 0?A.input:A;return{instance:new a(c),error:null,classFound:!0}}catch(A){const c=A instanceof Error?A.message:String(A);return console.error("Failed to reconstruct solver:",A),{instance:null,error:`Failed to instantiate solver: ${c}`,classFound:!0}}},[r]);return t.length===0?Y.jsx("div",{className:"rf-p-4",children:Y.jsx("div",{className:"rf-bg-gray-50 rf-rounded-md rf-border rf-border-gray-200",children:Y.jsxs("div",{className:"rf-p-4",children:[Y.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800 rf-mb-3",children:"No Solvers Detected"}),Y.jsx("p",{className:"rf-text-sm rf-text-gray-600",children:"Solvers will appear here when the circuit runs. Solvers are used for tasks like component packing and autorouting."})]})})}):Y.jsxs("div",{className:"rf-flex rf-h-full rf-overflow-hidden",children:[Y.jsxs("div",{className:"rf-w-64 rf-border-r rf-border-gray-200 rf-overflow-y-auto rf-flex-shrink-0",children:[Y.jsxs("div",{className:"rf-text-xs rf-font-semibold rf-text-gray-500 rf-px-3 rf-py-2 rf-bg-gray-50 rf-border-b rf-border-gray-200",children:[i.length," ",i.length===1?"Solver":"Solvers"]}),i.map(a=>{const A=o.get(a),c=e===a;return Y.jsx("div",{className:`rf-px-3 rf-py-2 rf-cursor-pointer rf-border-b rf-border-gray-100 ${c?"rf-bg-blue-50 rf-border-l-2 rf-border-l-blue-500":"hover:rf-bg-gray-50"}`,onClick:()=>n(a),children:(()=>{const l=fWo(A.solverName);return Y.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2",children:[Y.jsx(l,{className:"rf-w-4 rf-h-4 rf-text-blue-500 rf-flex-shrink-0"}),Y.jsxs("div",{className:"rf-flex-1 rf-min-w-0",children:[Y.jsx("div",{className:"rf-text-sm rf-font-medium rf-text-gray-800 rf-truncate",children:A.componentName}),Y.jsx("div",{className:"rf-text-xs rf-text-gray-500 rf-truncate",children:A.solverName})]})]})})()},a)})]}),Y.jsx("div",{className:"rf-flex-1 rf-overflow-hidden",children:r?s.instance?Y.jsxs("div",{className:"rf-flex rf-h-full rf-flex-col rf-overflow-y-auto",children:[Y.jsx(yWo,{solverEvent:r}),Y.jsx("div",{className:"rf-min-h-0 rf-flex-1",children:Y.jsx(Rx,{fallback:Y.jsx("div",{className:"rf-p-4",children:Y.jsxs("div",{className:"rf-bg-red-50 rf-rounded-md rf-border rf-border-red-200 rf-p-4",children:[Y.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-red-800 rf-mb-2",children:"Error Loading Solver Debugger"}),Y.jsxs("p",{className:"rf-text-sm rf-text-red-600",children:["Failed to render the solver debugger for"," ",r.solverName]})]})}),children:Y.jsx(hWo,{solver:s.instance})})})]}):Y.jsxs("div",{className:"rf-p-4",children:[Y.jsxs("div",{className:"rf-mb-4",children:[Y.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800",children:r.solverName}),Y.jsxs("p",{className:"rf-text-sm rf-text-gray-500",children:["Component: ",r.componentName]})]}),s.error&&Y.jsx("div",{className:`rf-rounded-md rf-border rf-p-4 rf-mb-4 ${s.classFound?"rf-bg-red-50 rf-border-red-200":"rf-bg-yellow-50 rf-border-yellow-200"}`,children:Y.jsx("p",{className:`rf-text-sm ${s.classFound?"rf-text-red-700":"rf-text-yellow-700"}`,children:s.error})}),Y.jsxs("div",{className:"rf-border rf-border-gray-200 rf-rounded-md rf-overflow-hidden",children:[Y.jsxs("div",{className:"rf-px-3 rf-py-2 rf-bg-gray-50 rf-flex rf-items-center rf-justify-between rf-gap-2",children:[Y.jsx("span",{className:"rf-text-sm rf-font-medium rf-text-gray-700",children:"Solver Parameters"}),Y.jsxs("div",{className:"rf-flex rf-items-center rf-gap-1",children:[Y.jsx(EWo,{solverEvent:r}),Y.jsx(fa,{type:"button",variant:"ghost",size:"icon",className:"rf-h-8 rf-w-8","aria-label":"Download solver input JSON",title:"Download solver input JSON",onClick:()=>_Gt(r),children:Y.jsx(ese,{className:"rf-w-4 rf-h-4"})})]})]}),Y.jsx("div",{className:"rf-p-3 rf-bg-white rf-border-t rf-border-gray-200",children:Y.jsx("pre",{className:"rf-text-xs rf-font-mono rf-text-gray-600 rf-whitespace-pre-wrap rf-overflow-x-auto",children:JSON.stringify(r.solverParams,null,2)})})]})]}):Y.jsx("div",{className:"rf-flex rf-items-center rf-justify-center rf-h-full",children:Y.jsx("p",{className:"rf-text-sm rf-text-gray-500",children:"Select a solver from the list to view details"})})})]})},mGt=({errorMessage:t,errorStack:e,circuitJsonErrors:n})=>{X.useEffect(()=>{if(t){const o=new Error(t);e&&(o.stack=e);try{vR.captureException(o)}catch{}}},[t,e]),X.useEffect(()=>{if(n&&n.length>0)for(const o of n){const i=new Error(o.message||"Circuit JSON Error");o.stack&&(i.stack=o.stack);try{vR.captureException(i,{error_type:o.type})}catch{}}},[n])},pGt=t=>{X.useEffect(()=>{try{yro(t)}catch{}},[t.source,t.component,t.isWebEmbedded,t.activeTab])},IGt="0.0.2464",BWo={version:IGt},mae=tIt()(nIt(t=>({lastRunEvalVersion:void 0,setLastRunEvalVersion:e=>{t({lastRunEvalVersion:e})}}),{name:"runframe-runner-store"})),QWo=t=>{const[e,n]=X.useState([]),[o,i]=X.useState(null),[r,s]=X.useState(""),[a,A]=rR("eval-version-selection",null),c=mae(h=>h.setLastRunEvalVersion),l=mae(h=>h.lastRunEvalVersion);return X.useEffect(()=>{t&&fetch("https://data.jsdelivr.com/v1/package/npm/@tscircuit/eval").then(h=>h.json()).then(h=>{if(Array.isArray(h?.versions)){let d=[...h.versions];h.tags?.latest&&(i(h.tags.latest),d=d.filter(_=>_!==h.tags.latest)),n(d)}}).catch(()=>{})},[t]),X.useEffect(()=>{t&&(a?(window.TSCIRCUIT_LATEST_EVAL_VERSION=a,c(a)):o&&(window.TSCIRCUIT_LATEST_EVAL_VERSION=o,c(o)))},[t,a,o]),{versions:X.useMemo(()=>e.filter(h=>h.includes(r)).slice(0,50),[e,r]),latestVersion:o,lastRunEvalVersion:l,search:r,setSearch:s,selectVersion:h=>{A(h),s("")}}},SWo=({snippetNames:t,onSelect:e,onCancel:n,isOpen:o})=>{const[i,r]=X.useState(""),[s,a]=X.useState("");if(!o)return null;const A=t.filter(g=>g.toLowerCase().includes(s.toLowerCase())),c=s&&!t.includes(s),l=g=>{g.key==="Enter"&&(A.length===1?r(A[0]):c&&r(s))};return Y.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:Y.jsxs("div",{className:"rf-bg-white rf-rounded-lg rf-p-6 rf-w-96",children:[Y.jsx("h2",{className:"rf-text-lg rf-font-semibold rf-mb-4",children:"Select Snippet"}),Y.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:g=>a(g.target.value),onKeyDown:l}),Y.jsxs("div",{className:"rf-h-60 rf-overflow-y-auto",children:[A.map(g=>Y.jsx("button",{type:"button",className:`w-full text-left px-4 py-2 rounded hover:bg-gray-100 ${i===g?"bg-blue-50":""}`,onClick:()=>r(g),children:g},g)),c&&Y.jsxs("button",{type:"button",className:`w-full text-left px-4 py-2 rounded hover:bg-gray-100 text-blue-500 ${i===s?"bg-blue-50":""}`,onClick:()=>r(s),children:['Create new "',s,'"']})]}),Y.jsxs("div",{className:"rf-mt-4 rf-flex rf-justify-end rf-gap-2",children:[Y.jsx("button",{type:"button",className:"rf-px-4 rf-py-2 rf-text-gray-600 rf-hover:text-gray-800",onClick:n,children:"Cancel"}),Y.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:()=>i&&e(i),disabled:!i,children:i===s?`Create "${i}"`:`Save to ${i}`})]})]})})},bWo=t=>{const e=X.useRef(null),n=Xu(o=>o.recentEvents);X.useEffect(()=>{if(n.length===0)return;const o=n[0];o.event_id!==e.current&&(t(o),e.current=o.event_id)},[n,t])};var DWo=Object.defineProperty,AE=(t,e)=>DWo(t,"name",{value:e,configurable:!0}),A7e="Dialog",[fGt,CGt]=Cy(A7e),[vWo,sQ]=fGt(A7e),c7e=AE(t=>{const{__scopeDialog:e,children:n,open:o,defaultOpen:i,onOpenChange:r,modal:s=!0}=t,a=X.useRef(null),A=X.useRef(null),[c,l]=NB({prop:o,defaultProp:i??!1,onChange:r,caller:A7e}),[g,u]=X.useState(0),[h,d]=X.useState(0);return Y.jsx(vWo,{scope:e,triggerRef:a,contentRef:A,contentId:P_(),titleId:P_(),descriptionId:P_(),titlePresent:g>0,descriptionPresent:h>0,setTitleCount:u,setDescriptionCount:d,open:c,onOpenChange:l,onOpenToggle:X.useCallback(()=>l(_=>!_),[l]),modal:s,children:n})},"Dialog"),PWo="DialogTrigger",wWo=X.forwardRef(AE(function(e,n){const{__scopeDialog:o,...i}=e,r=sQ(PWo,o),s=Xa(n,r.triggerRef);return Y.jsx(Ls.button,{type:"button","aria-haspopup":"dialog","aria-expanded":r.open,"aria-controls":r.open?r.contentId:void 0,"data-state":fae(r.open),...i,ref:s,onClick:yi(e.onClick,r.onOpenToggle)})},"DialogTrigger")),yGt="DialogPortal",[MWo,EGt]=fGt(yGt,{forceMount:void 0}),l7e=AE(t=>{const{__scopeDialog:e,forceMount:n,children:o,container:i}=t,r=sQ(yGt,e);return Y.jsx(MWo,{scope:e,forceMount:n,children:X.Children.map(o,s=>Y.jsx(K2,{present:n||r.open,children:Y.jsx(pse,{asChild:!0,container:i,children:s})}))})},"DialogPortal"),g7e="DialogOverlay",pae=X.forwardRef(AE(function(e,n){const o=EGt(g7e,e.__scopeDialog),{forceMount:i=o.forceMount,...r}=e,s=sQ(g7e,e.__scopeDialog);return s.modal?Y.jsx(K2,{present:i||s.open,children:Y.jsx(RWo,{...r,ref:n})}):null},"DialogOverlay")),NWo=MB("DialogOverlay.RemoveScroll"),RWo=X.forwardRef(AE(function(e,n){const{__scopeDialog:o,...i}=e,r=sQ(g7e,o),s=INt(),a=Xa(n,s);return Y.jsx(xY,{as:NWo,allowPinchZoom:!0,shards:[r.contentRef],children:Y.jsx(Ls.div,{"data-state":fae(r.open),...i,ref:a,style:{pointerEvents:"auto",...i.style}})})},"DialogOverlayImpl")),VY="DialogContent",Iae=X.forwardRef(AE(function(e,n){const o=EGt(VY,e.__scopeDialog),{forceMount:i=o.forceMount,...r}=e,s=sQ(VY,e.__scopeDialog);return Y.jsx(K2,{present:i||s.open,children:s.modal?Y.jsx(TWo,{...r,ref:n}):Y.jsx(kWo,{...r,ref:n})})},"DialogContent")),TWo=X.forwardRef(AE(function(e,n){const o=sQ(VY,e.__scopeDialog),i=X.useRef(null),r=Xa(n,o.contentRef,i);return X.useEffect(()=>{const s=i.current;if(s)return Cse(s)},[]),Y.jsx(xGt,{...e,ref:r,trapFocus:o.open,disableOutsidePointerEvents:o.open,onCloseAutoFocus:yi(e.onCloseAutoFocus,s=>{s.preventDefault(),o.triggerRef.current?.focus()}),onPointerDownOutside:yi(e.onPointerDownOutside,s=>{const a=s.detail.originalEvent,A=a.button===0&&a.ctrlKey===!0;(a.button===2||A)&&s.preventDefault()}),onFocusOutside:yi(e.onFocusOutside,s=>s.preventDefault())})},"DialogContentModal")),kWo=X.forwardRef(AE(function(e,n){const o=sQ(VY,e.__scopeDialog),i=X.useRef(!1),r=X.useRef(!1);return Y.jsx(xGt,{...e,ref:n,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:s=>{e.onCloseAutoFocus?.(s),s.defaultPrevented||(i.current||o.triggerRef.current?.focus(),s.preventDefault()),i.current=!1,r.current=!1},onInteractOutside:s=>{e.onInteractOutside?.(s),s.defaultPrevented||(i.current=!0,s.detail.originalEvent.type==="pointerdown"&&(r.current=!0));const a=s.target;o.triggerRef.current?.contains(a)&&s.preventDefault(),s.detail.originalEvent.type==="focusin"&&r.current&&s.preventDefault()}})},"DialogContentNonModal")),xGt=X.forwardRef(AE(function(e,n){const{__scopeDialog:o,trapFocus:i,onOpenAutoFocus:r,onCloseAutoFocus:s,...a}=e,A=sQ(VY,o);return Bk(),Y.jsx(Y.Fragment,{children:Y.jsx(nse,{asChild:!0,loop:!0,trapped:i,onMountAutoFocus:r,onUnmountAutoFocus:s,children:Y.jsx(fY,{role:"dialog",id:A.contentId,"aria-describedby":A.descriptionPresent?A.descriptionId:void 0,"aria-labelledby":A.titlePresent?A.titleId:void 0,"data-state":fae(A.open),...a,ref:n,deferPointerDownOutside:!0,onDismiss:()=>A.onOpenChange(!1)})})})},"DialogContentImpl")),FWo="DialogTitle",u7e=X.forwardRef(AE(function(e,n){const{__scopeDialog:o,...i}=e,r=sQ(FWo,o),{setTitleCount:s}=r;return jd(()=>(s(a=>a+1),()=>s(a=>a-1)),[s]),Y.jsx(Ls.h2,{id:r.titleId,...i,ref:n})},"DialogTitle")),LWo="DialogDescription",d7e=X.forwardRef(AE(function(e,n){const{__scopeDialog:o,...i}=e,r=sQ(LWo,o),{setDescriptionCount:s}=r;return jd(()=>(s(a=>a+1),()=>s(a=>a-1)),[s]),Y.jsx(Ls.p,{id:r.descriptionId,...i,ref:n})},"DialogDescription")),HWo="DialogClose",BGt=X.forwardRef(AE(function(e,n){const{__scopeDialog:o,...i}=e,r=sQ(HWo,o);return Y.jsx(Ls.button,{type:"button",...i,ref:n,onClick:yi(e.onClick,()=>r.onOpenChange(!1))})},"DialogClose"));function fae(t){return t?"open":"closed"}AE(fae,"getState");var GWo=Object.defineProperty,D5=(t,e)=>GWo(t,"name",{value:e,configurable:!0}),OWo="AlertDialog",[KWo,Aai]=Cy(OWo,[CGt]),v5=CGt(),UWo=D5(t=>{const{__scopeAlertDialog:e,...n}=t,o=v5(e);return Y.jsx(c7e,{...o,...n,modal:!0})},"AlertDialog");X.forwardRef(D5(function(e,n){const{__scopeAlertDialog:o,...i}=e,r=v5(o);return Y.jsx(wWo,{...r,...i,ref:n})},"AlertDialogTrigger"));var YWo=D5(t=>{const{__scopeAlertDialog:e,...n}=t,o=v5(e);return Y.jsx(l7e,{...o,...n})},"AlertDialogPortal"),zWo=X.forwardRef(D5(function(e,n){const{__scopeAlertDialog:o,...i}=e,r=v5(o);return Y.jsx(pae,{...r,...i,ref:n})},"AlertDialogOverlay")),VWo="AlertDialogContent",[JWo,qWo]=KWo(VWo),WWo=X.forwardRef(D5(function(e,n){const{__scopeAlertDialog:o,children:i,...r}=e,s=v5(o),a=X.useRef(null),A=Xa(n,a),c=X.useRef(null);return Y.jsx(JWo,{scope:o,cancelRef:c,children:Y.jsx(Iae,{role:"alertdialog",...s,...r,ref:A,onOpenAutoFocus:yi(r.onOpenAutoFocus,l=>{l.preventDefault(),c.current?.focus({preventScroll:!0})}),onPointerDownOutside:l=>l.preventDefault(),onInteractOutside:l=>l.preventDefault(),children:i})})},"AlertDialogContent")),jWo=X.forwardRef(D5(function(e,n){const{__scopeAlertDialog:o,...i}=e,r=v5(o);return Y.jsx(u7e,{...r,...i,ref:n})},"AlertDialogTitle")),XWo=X.forwardRef(D5(function(e,n){const{__scopeAlertDialog:o,...i}=e,r=v5(o);return Y.jsx(d7e,{...r,...i,ref:n})},"AlertDialogDescription")),$Wo=X.forwardRef(D5(function(e,n){const{__scopeAlertDialog:o,...i}=e,r=v5(o);return Y.jsx(BGt,{...r,...i,ref:n})},"AlertDialogAction")),ZWo="AlertDialogCancel",ejo=X.forwardRef(D5(function(e,n){const{__scopeAlertDialog:o,...i}=e,{cancelRef:r}=qWo(ZWo,o),s=v5(o),a=Xa(n,r);return Y.jsx(BGt,{...s,...i,ref:a})},"AlertDialogCancel")),tjo=UWo,njo=YWo,QGt=zWo,SGt=WWo,bGt=$Wo,DGt=ejo,vGt=jWo,PGt=XWo;const wGt=tjo,ojo=njo,MGt=X.forwardRef(({className:t,...e},n)=>Y.jsx(QGt,{className:Ei("rf-fixed rf-inset-0 rf-z-50 rf-bg-black/80 data-[state=open]:rf-animate-in data-[state=closed]:rf-animate-out data-[state=closed]:rf-fade-out-0 data-[state=open]:rf-fade-in-0",t),...e,ref:n}));MGt.displayName=QGt.displayName;const h7e=X.forwardRef(({className:t,...e},n)=>Y.jsxs(ojo,{children:[Y.jsx(MGt,{}),Y.jsx(SGt,{ref:n,className:Ei("rf-fixed rf-left-[50%] rf-top-[50%] rf-z-50 rf-grid rf-w-full rf-max-w-lg rf-translate-x-[-50%] rf-translate-y-[-50%] rf-gap-4 rf-border rf-border-zinc-200 rf-bg-white rf-p-6 rf-shadow-lg rf-duration-200 data-[state=open]:rf-animate-in data-[state=closed]:rf-animate-out data-[state=closed]:rf-fade-out-0 data-[state=open]:rf-fade-in-0 data-[state=closed]:rf-zoom-out-95 data-[state=open]:rf-zoom-in-95 data-[state=closed]:rf-slide-out-to-left-1/2 data-[state=closed]:rf-slide-out-to-top-[48%] data-[state=open]:rf-slide-in-from-left-1/2 data-[state=open]:rf-slide-in-from-top-[48%] sm:rf-rounded-lg dark:rf-border-zinc-800 dark:rf-bg-zinc-950",t),...e})]}));h7e.displayName=SGt.displayName;const _7e=({className:t,...e})=>Y.jsx("div",{className:Ei("rf-flex rf-flex-col rf-space-y-2 rf-text-center sm:rf-text-left",t),...e});_7e.displayName="AlertDialogHeader";const m7e=({className:t,...e})=>Y.jsx("div",{className:Ei("rf-flex rf-flex-col-reverse sm:rf-flex-row sm:rf-justify-end sm:rf-space-x-2",t),...e});m7e.displayName="AlertDialogFooter";const p7e=X.forwardRef(({className:t,...e},n)=>Y.jsx(vGt,{ref:n,className:Ei("rf-text-lg rf-font-semibold",t),...e}));p7e.displayName=vGt.displayName;const I7e=X.forwardRef(({className:t,...e},n)=>Y.jsx(PGt,{ref:n,className:Ei("rf-text-sm rf-text-zinc-500 dark:rf-text-zinc-400",t),...e}));I7e.displayName=PGt.displayName;const ijo=X.forwardRef(({className:t,...e},n)=>Y.jsx(bGt,{ref:n,className:Ei(yk(),t),...e}));ijo.displayName=bGt.displayName;const f7e=X.forwardRef(({className:t,...e},n)=>Y.jsx(DGt,{ref:n,className:Ei(yk({variant:"outline"}),"rf-mt-2 sm:rf-mt-0",t),...e}));f7e.displayName=DGt.displayName;var rjo=Object.defineProperty,P5=(t,e)=>rjo(t,"name",{value:e,configurable:!0}),C7e="Checkbox",[sjo,cai]=Cy(C7e),[ajo,y7e]=sjo(C7e);function NGt(t){const{__scopeCheckbox:e,checked:n,children:o,defaultChecked:i,disabled:r,form:s,name:a,onCheckedChange:A,required:c,value:l="on",internal_do_not_use_render:g}=t,[u,h]=NB({prop:n,defaultProp:i??!1,onChange:A,caller:C7e}),[d,_]=X.useState(null),[m,p]=X.useState(null),I=X.useRef(!1),[f,C]=X.useReducer(B=>B+1,0),y=d?!!s||!!d.closest("form"):!0,E={checked:u,disabled:r,setChecked:h,control:d,setControl:_,name:a,form:s,value:l,hasConsumerStoppedPropagationRef:I,userInteractionCount:f,onUserInteraction:C,required:c,defaultChecked:w5(i)?!1:i,isFormControl:y,bubbleInput:m,setBubbleInput:p};return Y.jsx(ajo,{scope:e,...E,children:TGt(g)?g(E):o})}P5(NGt,"CheckboxProvider");var Ajo="CheckboxTrigger",cjo=X.forwardRef(P5(function({__scopeCheckbox:e,onKeyDown:n,onClick:o,...i},r){const{control:s,value:a,disabled:A,checked:c,required:l,setControl:g,setChecked:u,hasConsumerStoppedPropagationRef:h,onUserInteraction:d,isFormControl:_,bubbleInput:m}=y7e(Ajo,e),p=Xa(r,g),I=X.useRef(c);return X.useEffect(()=>{const f=s?.form;if(f){const C=P5(()=>u(I.current),"reset");return f.addEventListener("reset",C),()=>f.removeEventListener("reset",C)}},[s,u]),Y.jsx(Ls.button,{type:"button",role:"checkbox","aria-checked":w5(c)?"mixed":c,"aria-required":l,"data-state":E7e(c),"data-disabled":A?"":void 0,disabled:A,value:a,...i,ref:p,onKeyDown:yi(n,f=>{f.key==="Enter"&&f.preventDefault()}),onClick:yi(o,f=>{d(),u(C=>w5(C)?!0:!C),m&&_&&(h.current=f.isPropagationStopped(),h.current||f.stopPropagation())})})},"CheckboxTrigger")),RGt=X.forwardRef(P5(function(e,n){const{__scopeCheckbox:o,name:i,checked:r,defaultChecked:s,required:a,disabled:A,value:c,onCheckedChange:l,form:g,...u}=e;return Y.jsx(NGt,{__scopeCheckbox:o,checked:r,defaultChecked:s,disabled:A,required:a,onCheckedChange:l,name:i,form:g,value:c,internal_do_not_use_render:({isFormControl:h})=>Y.jsxs(Y.Fragment,{children:[Y.jsx(cjo,{...u,ref:n,__scopeCheckbox:o}),h&&Y.jsx(djo,{__scopeCheckbox:o})]})})},"Checkbox")),ljo="CheckboxIndicator",gjo=X.forwardRef(P5(function(e,n){const{__scopeCheckbox:o,forceMount:i,...r}=e,s=y7e(ljo,o);return Y.jsx(K2,{present:i||w5(s.checked)||s.checked===!0,children:Y.jsx(Ls.span,{"data-state":E7e(s.checked),"data-disabled":s.disabled?"":void 0,...r,ref:n,style:{pointerEvents:"none",...e.style}})})},"CheckboxIndicator")),ujo="CheckboxBubbleInput",djo=X.forwardRef(P5(function({__scopeCheckbox:e,onClick:n,...o},i){const{control:r,hasConsumerStoppedPropagationRef:s,userInteractionCount:a,checked:A,defaultChecked:c,required:l,disabled:g,name:u,value:h,form:d,bubbleInput:_,setBubbleInput:m}=y7e(ujo,e),p=Xa(i,m),I=x8e(r),f=X.useRef(!1),C=X.useRef(A),y=X.useRef(a);X.useEffect(()=>{const B=_;if(!B)return;const Q=window.HTMLInputElement.prototype,D=Object.getOwnPropertyDescriptor(Q,"checked").set,R=a!==y.current;y.current=a;const M=C.current!==A;C.current=A;const L=!(R&&s.current);if(M&&D){f.current=!R;const G=new Event("click",{bubbles:L});B.indeterminate=w5(A),D.call(B,w5(A)?!1:A),B.dispatchEvent(G),f.current=!1}},[_,A,s,a]);const E=X.useRef(w5(A)?!1:A);return Y.jsx(Ls.input,{type:"checkbox","aria-hidden":!0,defaultChecked:c??E.current,required:l,disabled:g,name:u,value:h,form:d,...o,tabIndex:-1,ref:p,onClick:yi(n,B=>{f.current&&B.stopPropagation()}),style:{...o.style,...I,position:"absolute",pointerEvents:"none",opacity:0,margin:0,transform:"translateX(-100%)"}})},"CheckboxBubbleInput"));function TGt(t){return typeof t=="function"}P5(TGt,"isFunction");function w5(t){return t==="indeterminate"}P5(w5,"isIndeterminate");function E7e(t){return w5(t)?"indeterminate":t?"checked":"unchecked"}P5(E7e,"getState");const JY=X.forwardRef(({className:t,...e},n)=>Y.jsx(RGt,{ref:n,className:Ei("rf-peer rf-h-4 rf-w-4 rf-shrink-0 rf-rounded-sm rf-border rf-border-zinc-200 rf-border-zinc-900 rf-shadow focus-visible:rf-outline-none focus-visible:rf-ring-1 focus-visible:rf-ring-zinc-950 disabled:rf-cursor-not-allowed disabled:rf-opacity-50 data-[state=checked]:rf-bg-zinc-900 data-[state=checked]:rf-text-zinc-50 dark:rf-border-zinc-800 dark:rf-border-zinc-50 dark:focus-visible:rf-ring-zinc-300 dark:data-[state=checked]:rf-bg-zinc-50 dark:data-[state=checked]:rf-text-zinc-900",t),...e,children:Y.jsx(gjo,{className:Ei("rf-flex rf-items-center rf-justify-center rf-text-current"),children:Y.jsx(YP,{className:"rf-h-4 rf-w-4"})})}));JY.displayName=RGt.displayName;const $6=c7e,hjo=l7e,kGt=X.forwardRef(({className:t,...e},n)=>Y.jsx(pae,{className:Ei("rf-fixed rf-inset-0 rf-z-50 rf-bg-black/80 data-[state=open]:rf-animate-in data-[state=closed]:rf-animate-out data-[state=closed]:rf-fade-out-0 data-[state=open]:rf-fade-in-0",t),...e,ref:n}));kGt.displayName=pae.displayName;const ow=X.forwardRef(({className:t,children:e,showOverlay:n=!0,...o},i)=>Y.jsxs(hjo,{children:[Y.jsx(kGt,{className:Ei(n?"":"rf-hidden")}),Y.jsx(Iae,{ref:i,className:Ei("rf-fixed rf-left-[50%] rf-top-[50%] rf-z-50 rf-grid rf-w-full rf-max-w-lg rf-translate-x-[-50%] rf-translate-y-[-50%] rf-gap-4 rf-border rf-border-zinc-200 rf-bg-white rf-p-6 rf-shadow-lg rf-duration-200 data-[state=open]:rf-animate-in data-[state=closed]:rf-animate-out data-[state=closed]:rf-fade-out-0 data-[state=open]:rf-fade-in-0 data-[state=closed]:rf-zoom-out-95 data-[state=open]:rf-zoom-in-95 data-[state=closed]:rf-slide-out-to-left-1/2 data-[state=closed]:rf-slide-out-to-top-[48%] data-[state=open]:rf-slide-in-from-left-1/2 data-[state=open]:rf-slide-in-from-top-[48%] sm:rf-rounded-lg dark:rf-border-zinc-800 dark:rf-bg-zinc-950",t),...o,children:e})]}));ow.displayName=Iae.displayName;const iw=({className:t,...e})=>Y.jsx("div",{className:Ei("rf-flex rf-flex-col rf-space-y-2 rf-text-center sm:rf-text-left",t),...e});iw.displayName="DialogHeader";const Uk=({className:t,...e})=>Y.jsx("div",{className:Ei("rf-flex rf-flex-col-reverse sm:rf-flex-row sm:rf-justify-end sm:rf-space-x-2",t),...e});Uk.displayName="DialogFooter";const rw=X.forwardRef(({className:t,...e},n)=>Y.jsx(u7e,{ref:n,className:Ei("rf-text-lg rf-font-semibold",t),...e}));rw.displayName=u7e.displayName;const Z6=X.forwardRef(({className:t,...e},n)=>Y.jsx(d7e,{ref:n,className:Ei("rf-text-sm rf-text-zinc-500 dark:rf-text-zinc-400",t),...e}));Z6.displayName=d7e.displayName;const Cae={"tscircuit.com":{label:"tscircuit.com",placeholder:"Search tscircuit packages...",emptyMessage:"No packages found"},jlcpcb:{label:"JLCPCB Parts",placeholder:"Search JLCPCB parts (e.g. C14663)...",emptyMessage:"No parts found"},kicad:{label:"KiCad Footprints",placeholder:"Search KiCad footprints...",emptyMessage:"No footprints found"}},_jo="https://cdn.jsdelivr.net/npm/easyeda@latest/dist/browser/index.js";let x7e=null;const B7e=async()=>(x7e||(x7e=import(_jo)),x7e),mjo=t=>(e,n)=>{const o=new Headers(n?.headers),i={};return o.forEach((r,s)=>{i[s]=r}),fetch(`${t?.apiBase??Hf}/proxy`,{...n,headers:{...i,"X-Target-Url":e.toString(),"X-Sender-Origin":i.origin??"","X-Sender-Host":i.host??"https://easyeda.com","X-Sender-Referer":i.referer??"","X-Sender-User-Agent":i["user-agent"]??"","X-Sender-Cookie":i.cookie??"",authority:i.authority??"","content-type":i["content-type"]??"",...t?.headers}})},pjo=async(t,e=10)=>{const n=encodeURIComponent(t),o=await fetch(`https://jlcsearch.tscircuit.com/api/search?limit=${e}&q=${n}`);if(!o.ok)throw new Error(`JLCPCB API error: ${o.status}`);return(await o.json()).components??[]},Ijo=t=>({lcscId:t.lcsc,manufacturer:t.mfr,description:t.description,partNumber:`C${t.lcsc}`,package:t.package,price:t.price,stock:t.stock,isBasic:t.is_basic}),FGt=async(t,e)=>{const{fetchEasyEDAComponent:n}=await B7e();return n(t,{fetch:mjo(e),includeModelMetadata:e?.includeModelMetadata})},fjo=async(t,e)=>{const{convertRawEasyToTsx:n}=await B7e(),o=await FGt(t,e);return n({rawEasy:o})},Cjo=async(t,e)=>{const{EasyEdaJsonSchema:n,convertEasyEdaJsonToCircuitJson:o}=await B7e(),i=await FGt(t,{...e,includeModelMetadata:!1}),r=n.parse(i);return o(r,{shouldRecenter:!0,showDesignator:!0,useModelCdn:!1})};function sw(t){return Array.isArray?Array.isArray(t):HGt(t)==="[object Array]"}function yjo(t){if(typeof t=="string")return t;if(typeof t=="bigint")return t.toString();const e=t+"";return e=="0"&&1/t==-1/0?"-0":e}function Q7e(t){return t==null?"":yjo(t)}function Wf(t){return typeof t=="string"}function yae(t){return typeof t=="number"}function Ejo(t){return t===!0||t===!1||xjo(t)&&HGt(t)=="[object Boolean]"}function LGt(t){return typeof t=="object"}function xjo(t){return LGt(t)&&t!==null}function cE(t){return t!=null}function Eae(t){return!t.trim().length}function HGt(t){return t==null?t===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(t)}const Bjo="Incorrect 'index' type",S7e="Invalid doc index: must be a non-negative integer within the bounds of the docs array",Qjo=t=>`Invalid value for key ${t}`,Sjo=t=>`Pattern length exceeds max of ${t}.`,bjo=t=>`Missing ${t} property in key`,Djo=t=>`Property 'weight' in key '${t}' must be a positive integer`,vjo="Fuse.match does not support useTokenSearch: token search requires corpus-level statistics (df, fieldCount) that a one-off string comparison does not have. Use new Fuse(...).search(...) instead.",GGt=Object.prototype.hasOwnProperty;var Pjo=class{constructor(t){this._keys=[],this._keyMap={};let e=0;t.forEach(n=>{const o=OGt(n);this._keys.push(o),this._keyMap[o.id]=o,e+=o.weight}),this._keys.forEach(n=>{n.weight/=e})}get(t){return this._keyMap[t]}keys(){return this._keys}toJSON(){return JSON.stringify(this._keys)}};function OGt(t){let e=null,n=null,o=null,i=1,r=null;if(Wf(t)||sw(t))o=t,e=KGt(t),n=xae(t);else{if(!GGt.call(t,"name"))throw new Error(bjo("name"));const s=t.name;if(o=s,GGt.call(t,"weight")&&t.weight!==void 0&&(i=t.weight,i<=0))throw new Error(Djo(xae(s)));e=KGt(s),n=xae(s),r=t.getFn??null}return{path:e,id:n,weight:i,src:o,getFn:r}}function KGt(t){return sw(t)?t:t.split(".")}function xae(t){return sw(t)?t.join("."):t}function wjo(t,e){const n=[];let o=!1;const i=(r,s,a,A)=>{if(cE(r))if(!s[a])n.push(A!==void 0?{v:r,i:A}:r);else{const c=r[s[a]];if(!cE(c))return;if(a===s.length-1&&(Wf(c)||yae(c)||Ejo(c)||typeof c=="bigint"))n.push(A!==void 0?{v:Q7e(c),i:A}:Q7e(c));else if(sw(c)){o=!0;for(let l=0,g=c.length;l<g;l+=1)i(c[l],s,a+1,l)}else s.length&&i(c,s,a+1,A)}};return i(t,Wf(e)?e.split("."):e,0),o?n:n[0]}const Ts=Object.freeze({...{isCaseSensitive:!1,ignoreDiacritics:!1,includeScore:!1,keys:[],shouldSort:!0,sortFn:(t,e)=>t.score===e.score?t.idx<e.idx?-1:1:t.score<e.score?-1:1},...{includeMatches:!1,findAllMatches:!1,minMatchCharLength:1},...{location:0,threshold:.6,distance:100},...{useExtendedSearch:!1,useTokenSearch:!1,tokenize:void 0,tokenMatch:"any",getFn:wjo,ignoreLocation:!1,ignoreFieldNorm:!1,fieldNormWeight:1}});function Mjo(t){return t>=9&&t<=13||t===32||t===160}function Njo(t=1,e=3){const n=new Map,o=Math.pow(10,e);return{get(i){let r=0,s=!1;for(let A=0;A<i.length;A++)Mjo(i.charCodeAt(A))?s=!1:s||(r++,s=!0);if(r===0&&(r=1),n.has(r))return n.get(r);const a=Math.round(o/Math.pow(r,.5*t))/o;return n.set(r,a),a},clear(){n.clear()}}}var b7e=class{constructor({getFn:t=Ts.getFn,fieldNormWeight:e=Ts.fieldNormWeight}={}){this.norm=Njo(e,3),this.getFn=t,this.isCreated=!1,this.docs=[],this.keys=[],this._keysMap={},this.setIndexRecords()}setSources(t=[]){this.docs=t}setIndexRecords(t=[]){this.records=t}setKeys(t=[]){this.keys=t,this._keysMap={},t.forEach((e,n)=>{this._keysMap[e.id]=n})}create(){if(this.isCreated||!this.docs.length)return;this.isCreated=!0;const t=this.docs.length;this.records=new Array(t);let e=0;if(Wf(this.docs[0]))for(let n=0;n<t;n++){const o=this._createStringRecord(this.docs[n],n);o&&(this.records[e++]=o)}else for(let n=0;n<t;n++)this.records[e++]=this._createObjectRecord(this.docs[n],n);this.records.length=e,this.norm.clear()}add(t,e){if(!Number.isInteger(e)||e<0)throw new Error(S7e);if(Wf(t)){const o=this._createStringRecord(t,e);return o&&this.records.push(o),o}const n=this._createObjectRecord(t,e);return this.records.push(n),n}removeAt(t){if(!Number.isInteger(t)||t<0)throw new Error(S7e);for(let e=0,n=this.records.length;e<n;e+=1)if(this.records[e].i===t){this.records.splice(e,1);break}for(let e=0,n=this.records.length;e<n;e+=1)this.records[e].i>t&&(this.records[e].i-=1)}removeAll(t){const e=new Set;for(const o of t)Number.isInteger(o)&&o>=0&&e.add(o);if(e.size===0)return;this.records=this.records.filter(o=>!e.has(o.i));const n=Array.from(e).sort((o,i)=>o-i);for(const o of this.records){let i=0,r=n.length;for(;i<r;){const s=i+r>>>1;n[s]<o.i?i=s+1:r=s}o.i-=i}}getValueForItemAtKeyId(t,e){return t[this._keysMap[e]]}size(){return this.records.length}_createStringRecord(t,e){return!cE(t)||Eae(t)?null:{v:t,i:e,n:this.norm.get(t)}}_createObjectRecord(t,e){const n={i:e,$:{}};for(let o=0,i=this.keys.length;o<i;o++){const r=this.keys[o],s=r.getFn?r.getFn(t):this.getFn(t,r.path);if(cE(s)){if(sw(s)){const a=[];for(let A=0,c=s.length;A<c;A+=1){const l=s[A];if(cE(l)){if(Wf(l)){if(!Eae(l)){const g={v:l,i:A,n:this.norm.get(l)};a.push(g)}}else if(cE(l.v)){const g=Wf(l.v)?l.v:Q7e(l.v);if(!Eae(g)){const u={v:g,i:l.i,n:this.norm.get(g)};a.push(u)}}}}n.$[o]=a}else if(Wf(s)&&!Eae(s)){const a={v:s,n:this.norm.get(s)};n.$[o]=a}}}return n}toJSON(){return{keys:this.keys.map(({getFn:t,...e})=>e),records:this.records}}};function UGt(t,e,{getFn:n=Ts.getFn,fieldNormWeight:o=Ts.fieldNormWeight}={}){const i=new b7e({getFn:n,fieldNormWeight:o});return i.setKeys(t.map(OGt)),i.setSources(e),i.create(),i}function Rjo(t,{getFn:e=Ts.getFn,fieldNormWeight:n=Ts.fieldNormWeight}={}){const{keys:o,records:i}=t,r=new b7e({getFn:e,fieldNormWeight:n});return r.setKeys(o),r.setIndexRecords(i),r}function Tjo(t=[],e=Ts.minMatchCharLength){const n=[];let o=-1,i=-1,r=0;for(let s=t.length;r<s;r+=1){const a=t[r];a&&o===-1?o=r:!a&&o!==-1&&(i=r-1,i-o+1>=e&&n.push([o,i]),o=-1)}return t[r-1]&&r-o>=e&&n.push([o,r-1]),n}function kjo(t,e,n,{location:o=Ts.location,distance:i=Ts.distance,threshold:r=Ts.threshold,findAllMatches:s=Ts.findAllMatches,minMatchCharLength:a=Ts.minMatchCharLength,includeMatches:A=Ts.includeMatches,ignoreLocation:c=Ts.ignoreLocation}={}){if(e.length>32)throw new Error(Sjo(32));const l=e.length,g=t.length,u=Math.max(0,Math.min(o,g));let h=r,d=u;const _=(b,D)=>{const R=b/l;if(c)return R;const M=Math.abs(u-D);return i?R+M/i:M?1:R},m=a>1||A,p=m?Array(g):[];let I;for(;(I=t.indexOf(e,d))>-1;){const b=_(0,I);if(h=Math.min(b,h),d=I+l,m){let D=0;for(;D<l;)p[I+D]=1,D+=1}}d=-1;let f=[],C=1,y=0,E=l+g;const B=1<<l-1;for(let b=0;b<l;b+=1){let D=0,R=E;for(;D<R;)_(b,u+R)<=h?D=R:E=R,R=Math.floor((E-D)/2+D);E=R;let M=Math.max(1,u-R+1);const L=s?g:Math.min(u+R,g)+l,G=Array(L+2);G[L+1]=(1<<b)-1;for(let O=L;O>=M;O-=1){const U=O-1,W=n[t[U]];if(G[O]=(G[O+1]<<1|1)&W,b&&(G[O]|=(f[O+1]|f[O])<<1|1|f[O+1]),G[O]&B&&(C=_(b,U),C<=h)){if(h=C,d=U,y=b,d<=u)break;M=Math.max(1,2*u-d)}}if(_(b+1,u)>h)break;f=G}if(m&&d>=0){const b=Math.min(g-1,d+l-1+y);for(let D=d;D<=b;D+=1)n[t[D]]&&(p[D]=1)}const Q={isMatch:d>=0,score:Math.max(.001,C)};if(m){const b=Tjo(p,a);b.length?A&&(Q.indices=b):Q.isMatch=!1}return Q}function Fjo(t){const e={};for(let n=0,o=t.length;n<o;n+=1){const i=t.charAt(n);e[i]=(e[i]||0)|1<<o-n-1}return e}function D7e(t){if(t.length<=1)return t;t.sort((n,o)=>n[0]-o[0]||n[1]-o[1]);const e=[t[0]];for(let n=1,o=t.length;n<o;n+=1){const i=e[e.length-1],r=t[n];r[0]<=i[1]+1?i[1]=Math.max(i[1],r[1]):e.push(r)}return e}const YGt={ł:"l",Ł:"L",đ:"d",Đ:"D",ø:"o",Ø:"O",ħ:"h",Ħ:"H",ŧ:"t",Ŧ:"T",ı:"i",ß:"ss"},Ljo=new RegExp("["+Object.keys(YGt).join("")+"]","g"),qY=typeof String.prototype.normalize=="function"?t=>t.normalize("NFD").replace(/[\u0300-\u036F\u0483-\u0489\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u0610-\u061A\u064B-\u065F\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED\u0711\u0730-\u074A\u07A6-\u07B0\u07EB-\u07F3\u07FD\u0816-\u0819\u081B-\u0823\u0825-\u0827\u0829-\u082D\u0859-\u085B\u08D3-\u08E1\u08E3-\u0903\u093A-\u093C\u093E-\u094F\u0951-\u0957\u0962\u0963\u0981-\u0983\u09BC\u09BE-\u09C4\u09C7\u09C8\u09CB-\u09CD\u09D7\u09E2\u09E3\u09FE\u0A01-\u0A03\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A70\u0A71\u0A75\u0A81-\u0A83\u0ABC\u0ABE-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AE2\u0AE3\u0AFA-\u0AFF\u0B01-\u0B03\u0B3C\u0B3E-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B62\u0B63\u0B82\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD7\u0C00-\u0C04\u0C3E-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C62\u0C63\u0C81-\u0C83\u0CBC\u0CBE-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CE2\u0CE3\u0D00-\u0D03\u0D3B\u0D3C\u0D3E-\u0D44\u0D46-\u0D48\u0D4A-\u0D4D\u0D57\u0D62\u0D63\u0D82\u0D83\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DF2\u0DF3\u0E31\u0E34-\u0E3A\u0E47-\u0E4E\u0EB1\u0EB4-\u0EB9\u0EBB\u0EBC\u0EC8-\u0ECD\u0F18\u0F19\u0F35\u0F37\u0F39\u0F3E\u0F3F\u0F71-\u0F84\u0F86\u0F87\u0F8D-\u0F97\u0F99-\u0FBC\u0FC6\u102B-\u103E\u1056-\u1059\u105E-\u1060\u1062-\u1064\u1067-\u106D\u1071-\u1074\u1082-\u108D\u108F\u109A-\u109D\u135D-\u135F\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17B4-\u17D3\u17DD\u180B-\u180D\u1885\u1886\u18A9\u1920-\u192B\u1930-\u193B\u1A17-\u1A1B\u1A55-\u1A5E\u1A60-\u1A7C\u1A7F\u1AB0-\u1ABE\u1B00-\u1B04\u1B34-\u1B44\u1B6B-\u1B73\u1B80-\u1B82\u1BA1-\u1BAD\u1BE6-\u1BF3\u1C24-\u1C37\u1CD0-\u1CD2\u1CD4-\u1CE8\u1CED\u1CF2-\u1CF4\u1CF7-\u1CF9\u1DC0-\u1DF9\u1DFB-\u1DFF\u20D0-\u20F0\u2CEF-\u2CF1\u2D7F\u2DE0-\u2DFF\u302A-\u302F\u3099\u309A\uA66F-\uA672\uA674-\uA67D\uA69E\uA69F\uA6F0\uA6F1\uA802\uA806\uA80B\uA823-\uA827\uA880\uA881\uA8B4-\uA8C5\uA8E0-\uA8F1\uA8FF\uA926-\uA92D\uA947-\uA953\uA980-\uA983\uA9B3-\uA9C0\uA9E5\uAA29-\uAA36\uAA43\uAA4C\uAA4D\uAA7B-\uAA7D\uAAB0\uAAB2-\uAAB4\uAAB7\uAAB8\uAABE\uAABF\uAAC1\uAAEB-\uAAEF\uAAF5\uAAF6\uABE3-\uABEA\uABEC\uABED\uFB1E\uFE00-\uFE0F\uFE20-\uFE2F]/g,"").replace(Ljo,e=>YGt[e]):t=>t;var v7e=class{constructor(t,{location:e=Ts.location,threshold:n=Ts.threshold,distance:o=Ts.distance,includeMatches:i=Ts.includeMatches,findAllMatches:r=Ts.findAllMatches,minMatchCharLength:s=Ts.minMatchCharLength,isCaseSensitive:a=Ts.isCaseSensitive,ignoreDiacritics:A=Ts.ignoreDiacritics,ignoreLocation:c=Ts.ignoreLocation}={}){if(this.options={location:e,threshold:n,distance:o,includeMatches:i,findAllMatches:r,minMatchCharLength:s,isCaseSensitive:a,ignoreDiacritics:A,ignoreLocation:c},t=a?t:t.toLowerCase(),t=A?qY(t):t,this.pattern=t,this.chunks=[],!this.pattern.length)return;const l=(u,h)=>{this.chunks.push({pattern:u,alphabet:Fjo(u),startIndex:h})},g=this.pattern.length;if(g>32){let u=0;const h=g%32,d=g-h;for(;u<d;)l(this.pattern.substr(u,32),u),u+=32;if(h){const _=g-32;l(this.pattern.substr(_),_)}}else l(this.pattern,0)}searchIn(t){const{isCaseSensitive:e,ignoreDiacritics:n,includeMatches:o}=this.options;if(t=e?t:t.toLowerCase(),t=n?qY(t):t,this.pattern===t){if(t.length<this.options.minMatchCharLength)return{isMatch:!1,score:1};const d={isMatch:!0,score:0};return o&&(d.indices=[[0,t.length-1]]),d}const{location:i,distance:r,threshold:s,findAllMatches:a,minMatchCharLength:A,ignoreLocation:c}=this.options,l=[];let g=0,u=!1;this.chunks.forEach(({pattern:d,alphabet:_,startIndex:m})=>{const{isMatch:p,score:I,indices:f}=kjo(t,d,_,{location:i+m,distance:r,threshold:s,findAllMatches:a,minMatchCharLength:A,includeMatches:o,ignoreLocation:c});p&&(u=!0),g+=I,p&&f&&l.push(...f)});const h={isMatch:u,score:u?g/this.chunks.length:1};return u&&o&&(h.indices=D7e(l)),h}};const Hjo=new Set(["fuzzy","include"]);function Gjo(t){return t.startsWith("inverse")}const P7e=[{type:"exact",multiRegex:/^="(.*)"$/,singleRegex:/^=(.*)$/,create:t=>({type:"exact",search(e){const n=e===t;return{isMatch:n,score:n?0:1,indices:[0,t.length-1]}}})},{type:"include",multiRegex:/^'"(.*)"$/,singleRegex:/^'(.*)$/,create:t=>({type:"include",search(e){let n=0,o;const i=[],r=t.length;for(;(o=e.indexOf(t,n))>-1;)n=o+r,i.push([o,n-1]);const s=!!i.length;return{isMatch:s,score:s?0:1,indices:i}}})},{type:"prefix-exact",multiRegex:/^\^"(.*)"$/,singleRegex:/^\^(.*)$/,create:t=>({type:"prefix-exact",search(e){const n=e.startsWith(t);return{isMatch:n,score:n?0:1,indices:[0,t.length-1]}}})},{type:"inverse-prefix-exact",multiRegex:/^!\^"(.*)"$/,singleRegex:/^!\^(.*)$/,create:t=>({type:"inverse-prefix-exact",search(e){const n=!e.startsWith(t);return{isMatch:n,score:n?0:1,indices:[0,e.length-1]}}})},{type:"inverse-suffix-exact",multiRegex:/^!"(.*)"\$$/,singleRegex:/^!(.*)\$$/,create:t=>({type:"inverse-suffix-exact",search(e){const n=!e.endsWith(t);return{isMatch:n,score:n?0:1,indices:[0,e.length-1]}}})},{type:"suffix-exact",multiRegex:/^"(.*)"\$$/,singleRegex:/^(.*)\$$/,create:t=>({type:"suffix-exact",search(e){const n=e.endsWith(t);return{isMatch:n,score:n?0:1,indices:[e.length-t.length,e.length-1]}}})},{type:"inverse-exact",multiRegex:/^!"(.*)"$/,singleRegex:/^!(.*)$/,create:t=>({type:"inverse-exact",search(e){const n=e.indexOf(t)===-1;return{isMatch:n,score:n?0:1,indices:[0,e.length-1]}}})},{type:"fuzzy",multiRegex:/^"(.*)"$/,singleRegex:/^(.*)$/,create:(t,e={})=>{const n=new v7e(t,{location:e.location??Ts.location,threshold:e.threshold??Ts.threshold,distance:e.distance??Ts.distance,includeMatches:e.includeMatches??Ts.includeMatches,findAllMatches:e.findAllMatches??Ts.findAllMatches,minMatchCharLength:e.minMatchCharLength??Ts.minMatchCharLength,isCaseSensitive:e.isCaseSensitive??Ts.isCaseSensitive,ignoreDiacritics:e.ignoreDiacritics??Ts.ignoreDiacritics,ignoreLocation:e.ignoreLocation??Ts.ignoreLocation});return{type:"fuzzy",search(o){return n.searchIn(o)}}}}],zGt=P7e.length,Ojo="\0",Kjo="|";function Ujo(t){const e=[],n=t.length;let o=0;for(;o<n;){for(;o<n&&t[o]===" ";)o++;if(o>=n)break;let i=o;for(;i<n&&t[i]!==" "&&t[i]!=='"';)i++;if(i<n&&t[i]==='"'){for(i++;i<n;){if(t[i]==='"'){const r=i+1;if(r>=n||t[r]===" "){i++;break}if(t[r]==="$"&&(r+1>=n||t[r+1]===" ")){i+=2;break}}i++}e.push(t.substring(o,i)),o=i}else{for(;i<n&&t[i]!==" ";)i++;e.push(t.substring(o,i)),o=i}}return e}function VGt(t,e){const n=t.match(e);return n?n[1]:null}function Yjo(t,e={}){return t.replace(/\\\|/g,Ojo).split(Kjo).map(n=>{const o=Ujo(n.replace(/\u0000/g,"|").trim()).filter(r=>r&&!!r.trim()),i=[];for(let r=0,s=o.length;r<s;r+=1){const a=o[r];let A=!1,c=-1;for(;!A&&++c<zGt;){const l=P7e[c],g=VGt(a,l.multiRegex);g&&(i.push(l.create(g,e)),A=!0)}if(!A)for(c=-1;++c<zGt;){const l=P7e[c],g=VGt(a,l.singleRegex);if(g){i.push(l.create(g,e));break}}}return i})}var zjo=class{constructor(t,{isCaseSensitive:e=Ts.isCaseSensitive,ignoreDiacritics:n=Ts.ignoreDiacritics,includeMatches:o=Ts.includeMatches,minMatchCharLength:i=Ts.minMatchCharLength,ignoreLocation:r=Ts.ignoreLocation,findAllMatches:s=Ts.findAllMatches,location:a=Ts.location,threshold:A=Ts.threshold,distance:c=Ts.distance}={}){this.query=null,this.options={isCaseSensitive:e,ignoreDiacritics:n,includeMatches:o,minMatchCharLength:i,findAllMatches:s,ignoreLocation:r,location:a,threshold:A,distance:c},t=e?t:t.toLowerCase(),t=n?qY(t):t,this.pattern=t,this.query=Yjo(this.pattern,this.options)}static condition(t,e){return e.useExtendedSearch}searchIn(t){const e=this.query;if(!e)return{isMatch:!1,score:1};const{includeMatches:n,isCaseSensitive:o,ignoreDiacritics:i}=this.options;t=o?t:t.toLowerCase(),t=i?qY(t):t;let r=0;const s=[];let a=0,A=!1;for(let c=0,l=e.length;c<l;c+=1){const g=e[c];s.length=0,r=0,A=!1;for(let u=0,h=g.length;u<h;u+=1){const d=g[u],{isMatch:_,indices:m,score:p}=d.search(t);if(_)r+=1,a+=p,Gjo(d.type)&&(A=!0),n&&(Hjo.has(d.type)?s.push(...m):s.push(m));else{a=0,r=0,s.length=0,A=!1;break}}if(r){const u={isMatch:!0,score:a/r};return A&&(u.hasInverse=!0),n&&(u.indices=D7e(s)),u}}return{isMatch:!1,score:1}}};const w7e=[];function M7e(...t){w7e.push(...t)}function Bae(t,e){for(let n=0,o=w7e.length;n<o;n+=1){const i=w7e[n];if(i.condition(t,e))return new i(t,e)}return new v7e(t,e)}const Qae={AND:"$and",OR:"$or"},N7e={PATH:"$path",PATTERN:"$val"},R7e=t=>!!(t[Qae.AND]||t[Qae.OR]),Vjo=t=>!!t[N7e.PATH],Jjo=t=>!sw(t)&&LGt(t)&&!R7e(t),JGt=t=>({[Qae.AND]:Object.keys(t).map(e=>({[e]:t[e]}))});function qGt(t,e,{auto:n=!0}={}){const o=i=>{if(Wf(i)){const A={keyId:null,pattern:i};return n&&(A.searcher=Bae(i,e)),A}const r=Object.keys(i),s=Vjo(i);if(!s&&r.length>1&&!R7e(i))return o(JGt(i));if(Jjo(i)){const A=s?i[N7e.PATH]:r[0],c=s?i[N7e.PATTERN]:i[A];if(!Wf(c))throw new Error(Qjo(A));const l={keyId:xae(A),pattern:c};return n&&(l.searcher=Bae(c,e)),l}const a={children:[],operator:r[0]};return r.forEach(A=>{const c=i[A];sw(c)&&c.forEach(l=>{a.children.push(o(l))})}),a};return R7e(t)||(t=JGt(t)),o(t)}function T7e(t,{ignoreFieldNorm:e=Ts.ignoreFieldNorm}){let n=1;return t.forEach(({key:o,norm:i,score:r})=>{const s=o?o.weight:null;n*=Math.pow(r===0&&s?Number.EPSILON:r,(s||1)*(e?1:i))}),n}function qjo(t,{ignoreFieldNorm:e=Ts.ignoreFieldNorm}){t.forEach(n=>{n.score=T7e(n.matches,{ignoreFieldNorm:e})})}var Wjo=class{constructor(t,e){this.limit=t,this.heap=[],this.comparator=e}get size(){return this.heap.length}insert(t){this.size<this.limit?(this.heap.push(t),this._bubbleUp(this.size-1)):this.comparator(t,this.heap[0])<0&&(this.heap[0]=t,this._sinkDown(0))}extractSorted(){return this.heap.sort(this.comparator)}_bubbleUp(t){const e=this.heap;for(;t>0;){const n=t-1>>1;if(this.comparator(e[t],e[n])<=0)break;const o=e[t];e[t]=e[n],e[n]=o,t=n}}_sinkDown(t){const e=this.heap,n=e.length;let o=t;do{t=o;const i=2*t+1,r=2*t+2;if(i<n&&this.comparator(e[i],e[o])>0&&(o=i),r<n&&this.comparator(e[r],e[o])>0&&(o=r),o!==t){const s=e[t];e[t]=e[o],e[o]=s}}while(o!==t)}};function jjo(t){const e=[];return t.matches.forEach(n=>{if(!cE(n.indices)||!n.indices.length)return;const o={indices:n.indices,value:n.value};n.key&&(o.key=n.key.id),n.idx>-1&&(o.refIndex=n.idx),e.push(o)}),e}function Xjo(t,e,{includeMatches:n=Ts.includeMatches,includeScore:o=Ts.includeScore}={}){return t.map(i=>{const{idx:r}=i,s={item:e[r],refIndex:r};return n&&(s.matches=jjo(i)),o&&(s.score=i.score),s})}const $jo=/[\p{L}\p{M}\p{N}_]+/gu,WGt=new WeakSet;function Zjo(t){WGt.has(t)||(WGt.add(t),console.warn(`[Fuse] tokenize regex ${t} lacks the global flag; only the first match per text will be returned. Add the 'g' flag.`))}function eXo(t){if(typeof t=="function"){let e=!1;return n=>{const o=t(n);if(!e&&(e=!0,!Array.isArray(o)||o.some(i=>typeof i!="string")))throw new Error(`[Fuse] tokenize function must return string[]; received ${Array.isArray(o)?"array containing non-strings":typeof o}.`);return o}}return t instanceof RegExp?(t.global||Zjo(t),e=>e.match(t)||[]):e=>e.match($jo)||[]}function k7e({isCaseSensitive:t=!1,ignoreDiacritics:e=!1,tokenize:n}={}){const o=eXo(n);return{tokenize(i){return t||(i=i.toLowerCase()),e&&(i=qY(i)),o(i)}}}var tXo=class{static condition(t,e){return e.useTokenSearch}constructor(t,e){this.options=e,this.analyzer=k7e({isCaseSensitive:e.isCaseSensitive,ignoreDiacritics:e.ignoreDiacritics,tokenize:e.tokenize});const n=this.analyzer.tokenize(t),{df:o,fieldCount:i}=e._invertedIndex;this.termSearchers=[],this.idfWeights=[];for(const r of n){this.termSearchers.push(new v7e(r,{location:e.location,threshold:e.threshold,distance:e.distance,includeMatches:e.includeMatches,findAllMatches:e.findAllMatches,minMatchCharLength:e.minMatchCharLength,isCaseSensitive:e.isCaseSensitive,ignoreDiacritics:e.ignoreDiacritics,ignoreLocation:!0}));const s=o.get(r)||0,a=Math.log(1+(i-s+.5)/(s+.5));this.idfWeights.push(a)}this.combineAll=e.tokenMatch==="all",this.numTerms=this.termSearchers.length,this.useMask=this.numTerms<=31}searchIn(t){if(!this.termSearchers.length)return{isMatch:!1,score:1};const e=[];let n=0,o=0,i=0,r=0;const s=this.combineAll&&!this.useMask?new Set:null;for(let c=0;c<this.termSearchers.length;c++){const l=this.termSearchers[c].searchIn(t),g=this.idfWeights[c];o+=g,l.isMatch&&(i++,n+=g*(1-l.score),l.indices&&e.push(...l.indices),this.combineAll&&(this.useMask?r|=1<<c:s.add(c)))}if(i===0)return{isMatch:!1,score:1};const a=o>0?1-n/o:0,A={isMatch:!0,score:Math.max(.001,a)};return this.options.includeMatches&&e.length&&(A.indices=D7e(e)),this.combineAll&&(this.useMask?A.matchedMask=r:A.matchedTerms=s,A.termCount=this.numTerms),A}};function F7e(t,e,n,o){const i=o.tokenize(e);if(!i.length)return;t.fieldCount++,t.docFieldCount.set(n,(t.docFieldCount.get(n)||0)+1);const r=new Set(i);let s=t.docTermFieldHits.get(n);s||(s=new Map,t.docTermFieldHits.set(n,s));for(const a of r)s.set(a,(s.get(a)||0)+1),t.df.set(a,(t.df.get(a)||0)+1)}function jGt(t,e,n,o){const{i,v:r,$:s}=e;if(r!==void 0){F7e(t,r,i,o);return}if(s)for(let a=0;a<n;a++){const A=s[a];if(A)if(Array.isArray(A))for(const c of A)F7e(t,c.v,i,o);else F7e(t,A.v,i,o)}}function nXo(t,e,n){const o={fieldCount:0,df:new Map,docFieldCount:new Map,docTermFieldHits:new Map};for(const i of t)jGt(o,i,e,n);return o}function oXo(t,e,n,o){jGt(t,e,n,o)}function iXo(t,e){const n=t.docFieldCount.get(e);if(n===void 0)return;t.fieldCount-=n,t.docFieldCount.delete(e);const o=t.docTermFieldHits.get(e);if(o){for(const[i,r]of o){const s=(t.df.get(i)||0)-r;s<=0?t.df.delete(i):t.df.set(i,s)}t.docTermFieldHits.delete(e)}}function XGt(t,e){if(e.length===0)return;const n=Array.from(new Set(e)).sort((a,A)=>a-A);for(const a of n)iXo(t,a);const o=a=>{let A=0,c=n.length;for(;A<c;){const l=A+c>>>1;n[l]<a?A=l+1:c=l}return a-A},i=n[0],r=new Map;for(const[a,A]of t.docFieldCount)r.set(a>i?o(a):a,A);t.docFieldCount=r;const s=new Map;for(const[a,A]of t.docTermFieldHits)s.set(a>i?o(a):a,A);t.docTermFieldHits=s}var aw=class{constructor(t,e,n){this.options={...Ts,...e},this.options.useExtendedSearch,this.options.useTokenSearch,this._keyStore=new Pjo(this.options.keys),this._docs=t,this._myIndex=null,this._invertedIndex=null,this.setCollection(t,n),this._lastQuery=null,this._lastSearcher=null}_getSearcher(t){if(this._lastQuery===t)return this._lastSearcher;const e=Bae(t,this._invertedIndex?{...this.options,_invertedIndex:this._invertedIndex}:this.options);return this._lastQuery=t,this._lastSearcher=e,e}setCollection(t,e){if(this._docs=t,e&&!(e instanceof b7e))throw new Error(Bjo);if(this._myIndex=e||UGt(this.options.keys,this._docs,{getFn:this.options.getFn,fieldNormWeight:this.options.fieldNormWeight}),this.options.useTokenSearch){const n=k7e({isCaseSensitive:this.options.isCaseSensitive,ignoreDiacritics:this.options.ignoreDiacritics,tokenize:this.options.tokenize});this._invertedIndex=nXo(this._myIndex.records,this._myIndex.keys.length,n)}this._invalidateSearcherCache()}add(t){if(!cE(t))return;this._docs.push(t);const e=this._myIndex.add(t,this._docs.length-1);if(this._invertedIndex&&e){const n=k7e({isCaseSensitive:this.options.isCaseSensitive,ignoreDiacritics:this.options.ignoreDiacritics,tokenize:this.options.tokenize});oXo(this._invertedIndex,e,this._myIndex.keys.length,n)}this._invalidateSearcherCache()}remove(t=()=>!1){const e=[],n=[];for(let o=0,i=this._docs.length;o<i;o+=1)t(this._docs[o],o)&&(e.push(this._docs[o]),n.push(o));if(n.length){this._invertedIndex&&XGt(this._invertedIndex,n);const o=new Set(n);this._docs=this._docs.filter((i,r)=>!o.has(r)),this._myIndex.removeAll(n),this._invalidateSearcherCache()}return e}removeAt(t){if(!Number.isInteger(t)||t<0||t>=this._docs.length)throw new Error(S7e);this._invertedIndex&&XGt(this._invertedIndex,[t]);const e=this._docs.splice(t,1)[0];return this._myIndex.removeAt(t),this._invalidateSearcherCache(),e}_invalidateSearcherCache(){this._lastQuery=null,this._lastSearcher=null}getIndex(){return this._myIndex}_normalizedKeys(){return this._myIndex.keys.map(t=>this._keyStore.get(t.id)||t)}search(t,e){const{limit:n=-1}=e||{},{includeMatches:o,includeScore:i,shouldSort:r,sortFn:s,ignoreFieldNorm:a}=this.options;if(Wf(t)&&!t.trim()){let u=this._docs.map((h,d)=>({item:h,refIndex:d}));return yae(n)&&n>-1&&(u=u.slice(0,n)),u}const A=r&&yae(n)&&n>0&&Wf(t),c=s,l=(u,h)=>c(u,h)||u.idx-h.idx;let g;if(A){const u=new Wjo(n,l);Wf(this._docs[0])?this._searchStringList(t,{heap:u,ignoreFieldNorm:a}):this._searchObjectList(t,{heap:u,ignoreFieldNorm:a}),g=u.extractSorted()}else g=Wf(t)?Wf(this._docs[0])?this._searchStringList(t):this._searchObjectList(t):this._searchLogical(t),qjo(g,{ignoreFieldNorm:a}),r&&g.sort(Wf(t)?l:c),yae(n)&&n>-1&&(g=g.slice(0,n));return Xjo(g,this._docs,{includeMatches:o,includeScore:i})}_searchStringList(t,{heap:e,ignoreFieldNorm:n}={}){const o=this._getSearcher(t),i=this.options.useTokenSearch&&this.options.tokenMatch==="all",{records:r}=this._myIndex,s=e?null:[];return r.forEach(({v:a,i:A,n:c})=>{if(!cE(a))return;const l=o.searchIn(a);if(l.isMatch){const g={score:l.score,value:a,norm:c,indices:l.indices};i&&(g.matchedMask=l.matchedMask,g.matchedTerms=l.matchedTerms,g.termCount=l.termCount);const u=[g];if(!i||this._coversAllTokens(u)){const h={item:a,idx:A,matches:u};e?(h.score=T7e(h.matches,{ignoreFieldNorm:n}),e.insert(h)):s.push(h)}}}),s}_searchLogical(t){const e=qGt(t,this.options),n=this._normalizedKeys(),o=(a,A,c)=>{if(!("children"in a)){const{keyId:h,searcher:d}=a;let _;return h===null?(_=[],n.forEach((m,p)=>{_.push(...this._findMatches({key:m,value:A[p],searcher:d}))})):_=this._findMatches({key:this._keyStore.get(h),value:this._myIndex.getValueForItemAtKeyId(A,h),searcher:d}),_&&_.length?[{idx:c,item:A,matches:_}]:[]}const{children:l,operator:g}=a,u=[];for(let h=0,d=l.length;h<d;h+=1){const _=l[h],m=o(_,A,c);if(m.length)u.push(...m);else if(g===Qae.AND)return[]}return u},i=this._myIndex.records,r=new Map,s=[];return i.forEach(({$:a,i:A})=>{if(cE(a)){const c=o(e,a,A);c.length&&(r.has(A)||(r.set(A,{idx:A,item:a,matches:[]}),s.push(r.get(A))),c.forEach(({matches:l})=>{r.get(A).matches.push(...l)}))}}),s}_searchObjectList(t,{heap:e,ignoreFieldNorm:n}={}){const o=this._getSearcher(t),i=this.options.useTokenSearch&&this.options.tokenMatch==="all",{records:r}=this._myIndex,s=this._normalizedKeys(),a=e?null:[];return r.forEach(({$:A,i:c})=>{if(!cE(A))return;const l=[];let g=!1,u=!1;if(s.forEach((h,d)=>{const _=this._findMatches({key:h,value:A[d],searcher:o});_.length?(l.push(..._),_[0].hasInverse&&(u=!0)):g=!0}),!(u&&g)&&l.length&&(!i||this._coversAllTokens(l))){const h={idx:c,item:A,matches:l};e?(h.score=T7e(h.matches,{ignoreFieldNorm:n}),e.insert(h)):a.push(h)}}),a}_findMatches({key:t,value:e,searcher:n}){if(!cE(e))return[];const o=[];if(sw(e))e.forEach(({v:i,i:r,n:s})=>{if(!cE(i))return;const a=n.searchIn(i);if(a.isMatch){const A={score:a.score,key:t,value:i,idx:r,norm:s,indices:a.indices,hasInverse:a.hasInverse};a.termCount!==void 0&&(A.matchedMask=a.matchedMask,A.matchedTerms=a.matchedTerms,A.termCount=a.termCount),o.push(A)}});else{const{v:i,n:r}=e,s=n.searchIn(i);if(s.isMatch){const a={score:s.score,key:t,value:i,norm:r,indices:s.indices,hasInverse:s.hasInverse};s.termCount!==void 0&&(a.matchedMask=s.matchedMask,a.matchedTerms=s.matchedTerms,a.termCount=s.termCount),o.push(a)}}return o}_coversAllTokens(t){const e=t.length?t[0].termCount:void 0;if(e===void 0)return!0;if(e<=31){let o=0;for(let i=0;i<t.length;i++)o|=t[i].matchedMask||0;return o===2**e-1}const n=new Set;for(let o=0;o<t.length;o++){const i=t[o].matchedTerms;if(i)for(const r of i)n.add(r)}return n.size===e}};aw.version="7.5.0",aw.createIndex=UGt,aw.parseIndex=Rjo,aw.config=Ts,aw.match=function(t,e,n){if(n&&n.useTokenSearch)throw new Error(vjo);return Bae(t,{...Ts,...n}).searchIn(e)},aw.parseQuery=qGt,M7e(zjo),M7e(tXo),aw.use=function(...t){t.forEach(e=>M7e(e))};var rXo=aw;const sXo="https://kicad-mod-cache.tscircuit.com";let L7e=null,WY=null,H7e=null;const aXo=async()=>L7e||WY||(WY=fetch("https://kicad-mod-cache.tscircuit.com/kicad_files.json").then(t=>t.json()).then(t=>(L7e=t,WY=null,t)),WY),AXo=async(t,e=20)=>{const n=await aXo();return H7e||(H7e=new rXo(n)),H7e.search(t).slice(0,e).map(o=>o.item)},cXo=t=>{const e=t.replace(".pretty/","/").replace(".kicad_mod",""),n=`kicad:${e}`;return{path:t,qualifiedName:n,description:e}},lXo=t=>t.replace(/^\/+/,"").split("/").map(e=>encodeURIComponent(e)).join("/"),gXo=async t=>{const e=await fetch(`${sXo}/${lXo(t)}`);if(!e.ok)throw new Error(`KiCad footprint fetch failed: ${e.status}`);const n=await e.text(),{KicadFootprintToCircuitJsonConverter:o}=await iE("kicad-to-circuit-json"),i=new o;return i.addFile(t.split("/").pop()??"selected-footprint.kicad_mod",n),i.runUntilFinished(),i.getOutput()},$Gt=t=>t?.source==="jlcpcb"||t?.source==="kicad",uXo=async(t,e)=>{if(t.source==="jlcpcb")return Cjo(t.component.partNumber,e?.jlcpcb);if(t.source==="kicad")return gXo(t.footprint.path);throw new Error("Footprint preview is not available for this source")},dXo=({query:t,placeholder:e,isSearching:n,onQueryChange:o,onSubmit:i})=>{const r=X.useCallback(s=>{s.key==="Enter"&&(s.preventDefault(),i())},[i]);return Y.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2 rf-mt-4",children:[Y.jsxs("div",{className:"rf-relative rf-flex-grow",children:[Y.jsx(t8e,{className:"rf-absolute rf-left-2 rf-top-2.5 rf-h-4 rf-w-4 rf-text-muted-foreground"}),Y.jsx(z8e,{placeholder:e,className:"rf-pl-8",spellCheck:!1,autoComplete:"off",value:t,onChange:s=>o(s.target.value),onKeyDown:r})]}),Y.jsx(fa,{onClick:i,disabled:n||t.trim().length<1,className:"sm:rf-px-4 rf-px-3",children:n?Y.jsx(Tx,{className:"rf-h-4 rf-w-4 rf-animate-spin"}):Y.jsxs(Y.Fragment,{children:[Y.jsx(t8e,{className:"rf-h-4 rf-w-4 sm:rf-hidden"}),Y.jsx("span",{className:"rf-hidden sm:rf-inline",children:"Search"})]})})]})},hXo=new Intl.NumberFormat("en-US",{style:"currency",currency:"USD"}),_Xo=t=>hXo.format(t),ZGt=t=>{switch(t.source){case"tscircuit.com":{const e=t.package;return`tscircuit-${e.package_id??`${e.org_owner_tscircuit_handle??"unknown"}-${e.unscoped_name??e.name??"package"}`}`}case"jlcpcb":return`jlc-${t.component.lcscId}`;case"kicad":return`kicad-${t.footprint.path}`;default:return"unknown"}},mXo=t=>{switch(t.source){case"tscircuit.com":return t.package.unscoped_name;case"jlcpcb":return t.component.isDirectLookup?t.component.partNumber:t.component.manufacturer;case"kicad":return t.footprint.qualifiedName}},pXo=t=>{switch(t.source){case"tscircuit.com":return t.package.description||(t.package.org_owner_tscircuit_handle?`Component by ${t.package.org_owner_tscircuit_handle}`:void 0);case"jlcpcb":return t.component.description;case"kicad":return t.footprint.description}},IXo=t=>{switch(t.source){case"tscircuit.com":return t.package.name;case"jlcpcb":return t.component.isDirectLookup?void 0:t.component.partNumber;case"kicad":return}},fXo=({results:t,selected:e,onSelect:n,onShowDetails:o})=>{const i=e?ZGt(e):null;return Y.jsx("div",{className:"rf-divide-y rf-w-full rf-overflow-hidden",children:t.map(r=>{const s=ZGt(r),a=i===s,A=mXo(r),c=pXo(r),l=IXo(r),g=r.source==="jlcpcb"?r.component.stock:null,u=r.source==="jlcpcb"?r.component.price:null,h=r.source==="jlcpcb"?r.component.isBasic:null,d=r.source==="jlcpcb"?r.component.isDirectLookup:!1;return Y.jsxs("div",{className:`rf-p-3 rf-flex rf-flex-col sm:rf-grid sm:rf-grid-cols-[minmax(0,1fr)_auto] rf-items-start sm:rf-items-center rf-cursor-pointer hover:rf-bg-zinc-100 rf-gap-2 rf-overflow-hidden ${a?"rf-bg-zinc-100":""}`,onClick:()=>n(r),children:[Y.jsxs("div",{className:"rf-min-w-0 rf-overflow-hidden rf-w-full",children:[Y.jsxs("div",{className:"rf-flex rf-items-start rf-gap-2 rf-min-w-0",children:[Y.jsxs("div",{className:"rf-font-medium rf-text-sm rf-truncate rf-flex-1 rf-min-w-0 rf-flex rf-items-center rf-gap-1.5",children:[A,r.source==="jlcpcb"&&h!=null&&Y.jsx("span",{className:`rf-text-xs rf-px-1.5 rf-py-0.5 rf-rounded rf-font-medium rf-flex-shrink-0 ${h?"rf-bg-green-100 rf-text-green-700":"rf-bg-orange-100 rf-text-orange-700"}`,children:h?"Basic":"Extended"}),d&&Y.jsx("span",{className:"rf-text-xs rf-px-1.5 rf-py-0.5 rf-rounded rf-font-medium rf-flex-shrink-0 rf-bg-blue-100 rf-text-blue-700",children:"Direct lookup"}),r.source==="tscircuit.com"&&r.package.is_private&&Y.jsx(oLo,{className:"rf-ml-1 rf-h-3 rf-w-3 rf-text-zinc-400 rf-flex-shrink-0"})]}),r.source==="jlcpcb"&&g!=null?Y.jsxs("div",{className:"rf-text-xs rf-text-zinc-500 rf-font-medium rf-whitespace-nowrap rf-flex-shrink-0 sm:rf-hidden",children:[g.toLocaleString()," in stock"]}):null]}),Y.jsxs("div",{className:"rf-text-xs rf-text-zinc-500 rf-truncate rf-w-full",children:[l?Y.jsx("span",{className:"rf-mr-2",children:l}):null,c]})]}),Y.jsxs("div",{children:[r.source==="tscircuit.com"&&o?Y.jsx("div",{className:"rf-flex-shrink-0 rf-w-full sm:rf-w-auto",children:Y.jsx(fa,{variant:"outline",size:"sm",className:"rf-text-xs rf-w-full sm:rf-w-auto",onClick:_=>{_.stopPropagation(),o(r)},children:"See Details"})}):r.source==="jlcpcb"&&g!=null?Y.jsxs("div",{className:"rf-hidden sm:rf-block rf-text-xs rf-text-zinc-500 rf-font-medium rf-whitespace-nowrap rf-flex-shrink-0",children:[g.toLocaleString()," in stock"]}):null,u!=null&&Y.jsx("div",{className:"rf-hidden sm:rf-block rf-text-xs rf-text-zinc-500 rf-font-medium rf-whitespace-nowrap rf-flex-shrink-0 rf-text-right",children:_Xo(u)})]})]},s)})})},CXo=({circuitJson:t,error:e,isLoading:n,height:o})=>Y.jsx("section",{className:"rf-flex rf-min-w-0 rf-items-center rf-justify-center",style:{height:o},children:n?Y.jsxs("div",{className:"rf-flex rf-w-full rf-items-center rf-justify-center rf-gap-2 rf-bg-zinc-950 rf-text-sm rf-text-zinc-300",style:{height:o},children:[Y.jsx(Tx,{className:"rf-h-4 rf-w-4 rf-animate-spin"}),"Loading preview..."]}):e?Y.jsx("div",{className:"rf-flex rf-w-full rf-items-center rf-justify-center rf-bg-zinc-950 rf-p-4",style:{height:o},children:Y.jsxs("div",{className:"rf-flex rf-max-w-[320px] rf-items-start rf-gap-2 rf-text-sm rf-text-zinc-300",children:[Y.jsx(uNt,{className:"rf-mt-0.5 rf-h-4 rf-w-4 rf-flex-shrink-0"}),Y.jsx("span",{children:e})]})}):t?Y.jsx("div",{className:"rf-w-full rf-min-w-0 rf-overflow-hidden",children:Y.jsx(aGt,{circuitJson:t,height:o,allowEditing:!1,clickToInteractEnabled:!1,focusOnHover:!1,disablePcbGroups:!0})}):Y.jsx("div",{className:"rf-flex rf-w-full rf-items-center rf-justify-center rf-bg-zinc-950 rf-text-sm rf-text-zinc-300",style:{height:o},children:"No preview"})}),eOt={importComponentDialog:101,importComponentDetailsDialog:102},yXo=({packageResult:t,isOpen:e,onOpenChange:n,isLoading:o,details:i,previewTab:r,onPreviewTabChange:s,isSubmitting:a,onImport:A})=>{const c=t?.package??null,l=c?.latest_pcb_preview_image_url,g=c?.latest_sch_preview_image_url,u=c?.latest_cad_preview_image_url,h=c?.unscoped_name?.split("/").pop()??c?.unscoped_name,d=c?.org_owner_tscircuit_handle??void 0,_=d?`https://tscircuit.com/${d}`:void 0,m=d&&h?`https://tscircuit.com/${d}/${h}`:void 0;return Y.jsx($6,{open:e,onOpenChange:n,children:Y.jsxs(ow,{showOverlay:!1,style:{width:"calc(100vw - 2rem)",zIndex:eOt.importComponentDetailsDialog},className:"rf-max-w-5xl no-scrollbar !rf-overflow-y-auto rf-max-h-[90vh] rf-overflow-hidden rf-flex rf-flex-col rf-rounded-sm",children:[Y.jsx(iw,{className:"rf-pb-4 rf-border-b",children:Y.jsx("div",{className:"rf-flex rf-items-start rf-justify-between rf-gap-4",children:Y.jsxs("div",{className:"rf-flex-1 rf-min-w-0",children:[Y.jsx(rw,{className:"rf-text-xl rf-font-semibold rf-truncate",children:h}),Y.jsx(Z6,{children:c?.description})]})})}),Y.jsxs("div",{className:"rf-flex-1 rf-overflow-y-auto rf-py-4 rf-space-y-6",children:[d?Y.jsxs("div",{children:[Y.jsx("span",{className:"rf-text-xs rf-font-medium rf-text-gray-500 rf-uppercase rf-tracking-wide",children:"Created by"}),Y.jsx("div",{className:"rf-mt-1 rf-text-sm rf-font-medium",children:_?Y.jsx("a",{href:_,target:"_blank",rel:"noopener noreferrer",className:"rf-text-black hover:rf-underline",children:d}):d})]}):null,(u||l||g)&&Y.jsx(Y.Fragment,{children:Y.jsxs("div",{children:[Y.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-mb-4",children:"Preview"}),Y.jsxs(Nxe,{value:r,onValueChange:p=>s(p),children:[Y.jsxs(kne,{className:"rf-inline-flex rf-h-9 rf-items-center rf-justify-center rf-rounded-lg rf-bg-zinc-100 rf-p-1 rf-text-zinc-500 dark:rf-bg-zinc-800 dark:rf-text-zinc-400",children:[l&&Y.jsx(HS,{value:"pcb",children:"PCB"}),g&&Y.jsx(HS,{value:"schematic",children:"Schematic"}),u&&Y.jsx(HS,{value:"3d",children:"3D"})]}),Y.jsxs("div",{className:"rf-mt-4",children:[Y.jsx(Kf,{value:"pcb",className:"rf-border rf-rounded-lg rf-overflow-hidden rf-bg-gray-50",children:l?Y.jsx("img",{src:l,alt:`${h??"package"} PCB preview`,className:"rf-w-full rf-h-full rf-object-contain rf-bg-white rf-p-4"}):null}),Y.jsx(Kf,{value:"schematic",className:"rf-border rf-rounded-lg rf-overflow-hidden rf-bg-gray-50",children:g?Y.jsx("img",{src:g,alt:`${h??"package"} schematic preview`,className:"rf-w-full rf-h-full rf-object-contain rf-bg-white rf-p-4"}):null}),Y.jsx(Kf,{value:"3d",className:"rf-border rf-rounded-lg rf-overflow-hidden rf-bg-gray-50",children:u?Y.jsx("img",{src:u,alt:`${h??"package"} 3D preview`,className:"rf-w-full rf-h-full rf-object-contain rf-bg-white rf-p-4"}):null})]})]})]})}),i?.ai_description?Y.jsxs("section",{children:[Y.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-mb-3",children:"AI Description"}),Y.jsx("div",{className:"rf-bg-gray-50 rf-border rf-border-gray-200 rf-rounded-lg rf-p-4",children:Y.jsx("p",{className:"rf-text-sm rf-text-gray-700 rf-leading-relaxed",children:i.ai_description})})]}):null,i?.ai_usage_instructions?Y.jsxs("section",{children:[Y.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-mb-3",children:"Usage Instructions"}),Y.jsx("div",{className:"rf-bg-gray-50 rf-border rf-border-gray-200 rf-rounded-lg rf-p-4",children:Y.jsx("p",{className:"rf-text-sm rf-text-gray-700 rf-leading-relaxed rf-whitespace-pre-wrap",children:i.ai_usage_instructions})})]}):null,o?Y.jsxs("div",{className:"rf-flex rf-justify-center rf-items-center rf-gap-2 rf-text-gray-500",children:[Y.jsx(Tx,{className:"rf-h-4 rf-w-4 rf-animate-spin"}),Y.jsx("span",{className:"rf-text-sm",children:"Loading package details..."})]}):null]}),Y.jsxs(Uk,{className:"rf-pt-4 rf-border-t rf-flex rf-flex-col sm:rf-flex-row rf-justify-between rf-gap-2",children:[Y.jsx("div",{className:"rf-flex-1",children:m?Y.jsxs(fa,{variant:"outline",size:"sm",className:"rf-gap-2 rf-w-full sm:rf-w-auto",onClick:()=>window.open(m,"_blank"),children:[Y.jsx(jFo,{className:"rf-h-4 rf-w-4"}),"View on tscircuit.com"]}):null}),Y.jsxs("div",{className:"rf-flex rf-flex-col sm:rf-flex-row rf-gap-2",children:[Y.jsx(fa,{variant:"outline",onClick:()=>n(!1),className:"rf-order-2 sm:rf-order-1",children:"Close"}),Y.jsx(fa,{onClick:A,disabled:a,className:"rf-bg-blue-600 hover:rf-bg-blue-700",children:a?Y.jsx(Tx,{className:"rf-h-4 rf-w-4 rf-animate-spin"}):"Import Component"})]})]})]})})},EXo=()=>{const[t,e]=X.useState(null),[n,o]=X.useState(!1),i=X.useCallback(async(s,a)=>{o(!0);try{const A=await fetch(`https://api.tscircuit.com/packages/get?name=${encodeURIComponent(`${s}/${a}`)}`);if(!A.ok)throw new Error(`Failed to load package details: ${A.status}`);const c=await A.json();e(c.package??null)}catch(A){console.error("Failed to fetch package details",A),e(null)}finally{o(!1)}},[]),r=X.useCallback(()=>{e(null),o(!1)},[]);return{details:t,isLoading:n,fetchDetails:i,reset:r}},xXo=(t,e)=>{const[n,o]=X.useState({circuitJson:null,error:null,isLoading:!1});return X.useEffect(()=>{if(!t||!$Gt(t)){o({circuitJson:null,error:null,isLoading:!1});return}let i=!1;return o({circuitJson:null,error:null,isLoading:!0}),uXo(t,e).then(r=>{i||o({circuitJson:r,error:null,isLoading:!1})}).catch(r=>{i||o({circuitJson:null,error:r instanceof Error?r.message:"Failed to load footprint preview",isLoading:!1})}),()=>{i=!0}},[t,e]),n},BXo=async(t,e)=>{const n={"Content-Type":"application/json"};e&&(n.Authorization=`Bearer ${e}`);const o=await fetch("https://registry-api.tscircuit.com/packages/search",{method:"POST",headers:n,body:JSON.stringify({query:t})});if(!o.ok)throw new Error(`tscircuit registry error: ${o.status}`);return(await o.json()).packages??[]},QXo=({sessionToken:t})=>{const[e,n]=X.useState([]),[o,i]=X.useState(!1),[r,s]=X.useState(null),[a,A]=X.useState(!1),c=X.useCallback(async g=>{const u=g.trim();if(!u)return[];i(!0),s(null);try{const d=(await BXo(u,t)).map(_=>({source:"tscircuit.com",package:_}));return n(d),d}catch(h){return console.error("Error searching tscircuit packages",h),n([]),s(h instanceof Error?h.message:"Failed to search tscircuit packages"),[]}finally{i(!1),A(!0)}},[t]),l=X.useCallback(()=>{n([]),i(!1),s(null),A(!1)},[]);return{results:e,isSearching:o,error:r,hasSearched:a,search:c,reset:l}},SXo=t=>{const e=/^C(\d+)$/i.exec(t.trim());if(!e)return null;const n=Number(e[1]);if(!Number.isSafeInteger(n))return null;const o=`C${e[1]}`;return{source:"jlcpcb",component:{lcscId:n,manufacturer:o,partNumber:o,description:"Import directly from EasyEDA; stock and availability are unknown",package:"",isDirectLookup:!0}}},tOt=(t,e)=>{const n=SXo(t);return n?e.some(i=>i.component.partNumber.toUpperCase()===n.component.partNumber)?e:[n,...e]:e},bXo=t=>{const e=t.trim();return/^C\d+/i.test(e)?e.replace(/^C/i,""):e},DXo=()=>{const[t,e]=X.useState([]),[n,o]=X.useState(!1),[i,r]=X.useState(null),[s,a]=X.useState(!1),A=X.useCallback(async l=>{const g=bXo(l);if(!g)return[];o(!0),r(null);try{const u=await pjo(g,10),h=tOt(l,u.map(d=>({source:"jlcpcb",component:Ijo(d)})));return e(h),h}catch(u){console.error("Error searching JLCPCB components",u);const h=tOt(l,[]);return e(h),r(h.length>0?null:u instanceof Error?u.message:"Failed to search JLCPCB components"),h}finally{o(!1),a(!0)}},[]),c=X.useCallback(()=>{e([]),o(!1),r(null),a(!1)},[]);return{results:t,isSearching:n,error:i,hasSearched:s,search:A,reset:c}},vXo=()=>{const[t,e]=X.useState([]),[n,o]=X.useState(!1),[i,r]=X.useState(null),[s,a]=X.useState(!1),A=X.useCallback(async l=>{const g=l.trim();if(!g)return[];o(!0),r(null);try{const h=(await AXo(g,20)).map(d=>({source:"kicad",footprint:cXo(d)}));return e(h),h}catch(u){return console.error("Error searching KiCad footprints",u),e([]),r(u instanceof Error?u.message:"Failed to search KiCad footprints"),[]}finally{o(!1),a(!0)}},[]),c=X.useCallback(()=>{e([]),o(!1),r(null),a(!1)},[]);return{results:t,isSearching:n,error:i,hasSearched:s,search:A,reset:c}},PXo=({onTscircuitPackageSelected:t,onJlcpcbComponentTsxLoaded:e,onKicadStringSelected:n})=>{const o=[];return t&&o.push("tscircuit.com"),e&&o.push("jlcpcb"),n&&o.push("kicad"),o},wXo=({isOpen:t,onClose:e,jlcpcbProxyRequestHeaders:n,onKicadStringSelected:o,onTscircuitPackageSelected:i,onJlcpcbComponentTsxLoaded:r,jlcpcbProxyApiBase:s,tscircuitSessionToken:a})=>{YY();const A=X.useMemo(()=>PXo({onKicadStringSelected:o,onTscircuitPackageSelected:i,onJlcpcbComponentTsxLoaded:r}),[o,i,r]),c=A.length>0,l=A.length===1,[g,u]=X.useState(A[0]??"tscircuit.com"),[h,d]=X.useState(""),[_,m]=X.useState(null),{results:p,isSearching:I,error:f,hasSearched:C,search:y,reset:E}=QXo({sessionToken:a}),{results:B,isSearching:Q,error:b,hasSearched:D,search:R,reset:M}=DXo(),{results:L,isSearching:G,error:O,hasSearched:U,search:W,reset:j}=vXo(),{details:te,isLoading:ie,fetchDetails:$,reset:Z}=EXo(),[se,ae]=X.useState(null),[ce,fe]=X.useState(!1),[Ce,xe]=X.useState("pcb"),[de,Ee]=X.useState(null),[he,ve]=X.useState(!1),Re=X.useMemo(()=>({jlcpcb:{headers:n,apiBase:s}}),[s,n]),{circuitJson:ze,error:Ie,isLoading:We}=xXo(_,Re),Me=$Gt(_);X.useEffect(()=>{Ee(null)},[_]);const Te=X.useCallback(()=>{E(),M(),j(),m(null)},[M,j,E]);X.useEffect(()=>{t||(Te(),d(""),fe(!1),ae(null),Ee(null))},[t,Te]),X.useEffect(()=>{d(""),m(null),g==="tscircuit.com"?E():g==="jlcpcb"?M():g==="kicad"&&j()},[g,M,j,E]);const Ve=gt=>{m(gt),ae(gt),xe("pcb"),fe(!0),Z();const nt=gt.package.org_owner_tscircuit_handle,xt=gt.package.unscoped_name;if(nt&&xt){const mt=xt.split("/").pop()??xt;$(nt,mt)}},Ne=async()=>{h.trim()&&(m(null),g==="tscircuit.com"?await y(h):g==="jlcpcb"?await R(h):g==="kicad"&&await W(h))},Se=async gt=>{try{if(Ee(null),ve(!0),gt.source==="kicad"){if(!o)throw new Error("KiCad handler not provided");await o({result:gt,footprint:gt.footprint.qualifiedName})}else if(gt.source==="jlcpcb"){if(!r)throw new Error("JLCPCB handler not provided");const nt=await fjo(gt.component.partNumber,{headers:n,apiBase:s});await r({result:gt,tsx:nt})}else if(gt.source==="tscircuit.com"){if(!i)throw new Error("tscircuit package handler not provided");const nt=gt.package.org_owner_tscircuit_handle,xt=gt.package.unscoped_name;if(!nt||!xt)throw new Error("Missing package metadata");const mt=xt.split("/").pop()??xt,vt=`@tsci/${nt}.${mt}`;await i({result:gt,fullPackageName:vt})}return!0}catch(nt){return console.error("Failed to import component",nt),Ee(nt instanceof Error?nt.message:"Failed to import component"),!1}finally{ve(!1)}};let Oe=[],Pe=!1,qe=null,$e=!1;g==="tscircuit.com"?(Oe=p,Pe=I,qe=f,$e=C):g==="jlcpcb"?(Oe=B,Pe=Q,qe=b,$e=D):g==="kicad"&&(Oe=L,Pe=G,qe=O,$e=U);const at=async()=>{if(!_)return;await Se(_)&&(e(),Te(),d(""))},ct=gt=>{gt||e()},dt=gt=>{fe(gt),gt||ae(null)};return Y.jsxs($6,{open:t,onOpenChange:ct,children:[Y.jsxs(ow,{style:{width:"calc(100vw - 2rem)",maxWidth:Me?"min(1120px, calc(100vw - 2rem))":"min(672px, calc(100vw - 2rem))",zIndex:eOt.importComponentDialog},className:"rf-rounded-sm rf-max-h-[90vh] rf-overflow-y-auto rf-overflow-x-hidden rf-flex rf-flex-col",children:[Y.jsxs(iw,{children:[Y.jsxs(rw,{className:"rf-text-lg sm:rf-text-xl",children:["Import ",l?Cae[g].label:""," ","Component"]}),Y.jsx(Z6,{className:"rf-text-sm",children:c?"Search for components from available sources.":"Import options are disabled because no handlers were provided."})]}),c?Y.jsxs(Nxe,{value:g,onValueChange:gt=>u(gt),className:"rf-min-w-0 rf-w-full",children:[!l&&Y.jsx(kne,{className:"rf-flex rf-w-full rf-gap-2",children:A.map(gt=>Y.jsx(HS,{value:gt,className:"rf-flex-1 rf-text-xs sm:rf-text-sm",children:Cae[gt].label},gt))}),Y.jsxs("div",{className:"rf-min-w-0",style:Me?{display:"grid",gridTemplateColumns:"minmax(0, 1fr) minmax(360px, 0.95fr)",gap:"1.5rem",alignItems:"start"}:void 0,children:[Y.jsxs("div",{className:"rf-min-w-0",children:[Y.jsx(dXo,{query:h,placeholder:Cae[g].placeholder,isSearching:Pe,onQueryChange:d,onSubmit:Ne}),Y.jsx("div",{className:"no-scrollbar rf-mt-4 rf-flex-1 rf-min-h-[200px] !rf-max-h-[40vh] !rf-overflow-y-auto rf-overflow-x-hidden rf-border rf-rounded-md rf-min-w-0",children:Pe?Y.jsxs("div",{className:"rf-p-8 rf-text-center rf-text-zinc-500",children:[Y.jsx(Tx,{className:"rf-h-8 rf-w-8 rf-animate-spin rf-mx-auto rf-mb-2"}),Y.jsx("p",{children:"Searching..."})]}):Oe.length>0?Y.jsx(fXo,{results:Oe,selected:_,onSelect:m,onShowDetails:g==="tscircuit.com"?Ve:void 0}):Y.jsx("div",{className:"rf-p-8 rf-text-center rf-text-zinc-500",children:qe?`Error: ${qe}`:$e?Cae[g].emptyMessage:"Enter a search term to find components"})})]}),Me?Y.jsx("div",{className:"rf-mt-4",children:Y.jsx(CXo,{circuitJson:ze,error:Ie,isLoading:We,height:325})}):null]})]}):null,de?Y.jsx("div",{className:"rf-text-sm rf-text-red-600 rf-mt-2",children:de}):null,Y.jsxs(Uk,{className:"rf-flex rf-flex-col sm:rf-flex-row rf-gap-2",children:[Y.jsx(fa,{variant:"outline",onClick:e,className:"rf-order-2 sm:rf-order-1",children:"Cancel"}),Y.jsx(fa,{onClick:at,disabled:!_||he,className:"rf-order-1 sm:rf-order-2",children:he?Y.jsx(Tx,{className:"rf-h-4 rf-w-4 rf-animate-spin"}):"Import"})]})]}),Y.jsx(yXo,{packageResult:se,isOpen:ce,onOpenChange:dt,isLoading:ie,details:te,previewTab:Ce,onPreviewTabChange:gt=>xe(gt),isSubmitting:he,onImport:()=>{se&&Se(se).then(gt=>{gt&&(fe(!1),e(),Te(),d(""))})}})]})},MXo=t=>{const e=t.match(/export const (\w+) =/);if(!e)throw new Error("Could not determine component name from TSX contents");return e[1]},nOt=t=>{const e=Xu(s=>s.pushEvent),n=Xu(s=>s.upsertFile),o=async({result:s,fullPackageName:a})=>{const c=s.package.unscoped_name??s.package.name;await Rs.promise(e({event_type:"INSTALL_PACKAGE",full_package_name:a}),{loading:`Requesting install for "${c}"`,success:`Install requested for "${c}"`,error:l=>`Failed to request install: ${l instanceof Error?l.message:String(l)}`})},i=async({footprint:s})=>{await Rs.promise(navigator.clipboard.writeText(s),{loading:`Copying "${s}"`,success:`Copied "${s}" to clipboard`,error:a=>`Failed to copy footprint: ${a instanceof Error?a.message:String(a)}`})},r=async({result:s,tsx:a})=>{const c=`imports/${MXo(a)}.tsx`;await Rs.promise(n(c,a),{loading:`Importing ${s.component.partNumber}`,success:`Imported to "${c}"`,error:l=>`Failed to import component: ${l instanceof Error?l.message:String(l)}`})};return Y.jsx(wXo,{...t,onTscircuitPackageSelected:o,onKicadStringSelected:i,onJlcpcbComponentTsxLoaded:r})};nOt.displayName="ImportComponentDialogForCli";var G7e={exports:{}},oOt;function NXo(){return oOt||(oOt=1,(function(t,e){var n={env:{},version:""};(function(o){t.exports=o()})(function(){return(function o(i,r,s){function a(l,g){if(!r[l]){if(!i[l]){var u=typeof DD=="function"&ⅅif(!g&&u)return u(l,!0);if(A)return A(l,!0);var h=new Error("Cannot find module '"+l+"'");throw h.code="MODULE_NOT_FOUND",h}var d=r[l]={exports:{}};i[l][0].call(d.exports,function(_){var m=i[l][1][_];return a(m||_)},d,d.exports,o,i,r,s)}return r[l].exports}for(var A=typeof DD=="function"&&DD,c=0;c<s.length;c++)a(s[c]);return a})({1:[function(o,i,r){var s=o("./utils"),a=o("./support"),A="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";r.encode=function(c){for(var l,g,u,h,d,_,m,p=[],I=0,f=c.length,C=f,y=s.getTypeOf(c)!=="string";I<c.length;)C=f-I,u=y?(l=c[I++],g=I<f?c[I++]:0,I<f?c[I++]:0):(l=c.charCodeAt(I++),g=I<f?c.charCodeAt(I++):0,I<f?c.charCodeAt(I++):0),h=l>>2,d=(3&l)<<4|g>>4,_=1<C?(15&g)<<2|u>>6:64,m=2<C?63&u:64,p.push(A.charAt(h)+A.charAt(d)+A.charAt(_)+A.charAt(m));return p.join("")},r.decode=function(c){var l,g,u,h,d,_,m=0,p=0,I="data:";if(c.substr(0,I.length)===I)throw new Error("Invalid base64 input, it looks like a data url.");var f,C=3*(c=c.replace(/[^A-Za-z0-9+/=]/g,"")).length/4;if(c.charAt(c.length-1)===A.charAt(64)&&C--,c.charAt(c.length-2)===A.charAt(64)&&C--,C%1!=0)throw new Error("Invalid base64 input, bad content length.");for(f=a.uint8array?new Uint8Array(0|C):new Array(0|C);m<c.length;)l=A.indexOf(c.charAt(m++))<<2|(h=A.indexOf(c.charAt(m++)))>>4,g=(15&h)<<4|(d=A.indexOf(c.charAt(m++)))>>2,u=(3&d)<<6|(_=A.indexOf(c.charAt(m++))),f[p++]=l,d!==64&&(f[p++]=g),_!==64&&(f[p++]=u);return f}},{"./support":30,"./utils":32}],2:[function(o,i,r){var s=o("./external"),a=o("./stream/DataWorker"),A=o("./stream/Crc32Probe"),c=o("./stream/DataLengthProbe");function l(g,u,h,d,_){this.compressedSize=g,this.uncompressedSize=u,this.crc32=h,this.compression=d,this.compressedContent=_}l.prototype={getContentWorker:function(){var g=new a(s.Promise.resolve(this.compressedContent)).pipe(this.compression.uncompressWorker()).pipe(new c("data_length")),u=this;return g.on("end",function(){if(this.streamInfo.data_length!==u.uncompressedSize)throw new Error("Bug : uncompressed data size mismatch")}),g},getCompressedWorker:function(){return new a(s.Promise.resolve(this.compressedContent)).withStreamInfo("compressedSize",this.compressedSize).withStreamInfo("uncompressedSize",this.uncompressedSize).withStreamInfo("crc32",this.crc32).withStreamInfo("compression",this.compression)}},l.createWorkerFrom=function(g,u,h){return g.pipe(new A).pipe(new c("uncompressedSize")).pipe(u.compressWorker(h)).pipe(new c("compressedSize")).withStreamInfo("compression",u)},i.exports=l},{"./external":6,"./stream/Crc32Probe":25,"./stream/DataLengthProbe":26,"./stream/DataWorker":27}],3:[function(o,i,r){var s=o("./stream/GenericWorker");r.STORE={magic:"\0\0",compressWorker:function(){return new s("STORE compression")},uncompressWorker:function(){return new s("STORE decompression")}},r.DEFLATE=o("./flate")},{"./flate":7,"./stream/GenericWorker":28}],4:[function(o,i,r){var s=o("./utils"),a=(function(){for(var A,c=[],l=0;l<256;l++){A=l;for(var g=0;g<8;g++)A=1&A?3988292384^A>>>1:A>>>1;c[l]=A}return c})();i.exports=function(A,c){return A!==void 0&&A.length?s.getTypeOf(A)!=="string"?(function(l,g,u,h){var d=a,_=h+u;l^=-1;for(var m=h;m<_;m++)l=l>>>8^d[255&(l^g[m])];return-1^l})(0|c,A,A.length,0):(function(l,g,u,h){var d=a,_=h+u;l^=-1;for(var m=h;m<_;m++)l=l>>>8^d[255&(l^g.charCodeAt(m))];return-1^l})(0|c,A,A.length,0):0}},{"./utils":32}],5:[function(o,i,r){r.base64=!1,r.binary=!1,r.dir=!1,r.createFolders=!0,r.date=null,r.compression=null,r.compressionOptions=null,r.comment=null,r.unixPermissions=null,r.dosPermissions=null},{}],6:[function(o,i,r){var s=null;s=typeof Promise<"u"?Promise:o("lie"),i.exports={Promise:s}},{lie:37}],7:[function(o,i,r){var s=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Uint32Array<"u",a=o("pako"),A=o("./utils"),c=o("./stream/GenericWorker"),l=s?"uint8array":"array";function g(u,h){c.call(this,"FlateWorker/"+u),this._pako=null,this._pakoAction=u,this._pakoOptions=h,this.meta={}}r.magic="\b\0",A.inherits(g,c),g.prototype.processChunk=function(u){this.meta=u.meta,this._pako===null&&this._createPako(),this._pako.push(A.transformTo(l,u.data),!1)},g.prototype.flush=function(){c.prototype.flush.call(this),this._pako===null&&this._createPako(),this._pako.push([],!0)},g.prototype.cleanUp=function(){c.prototype.cleanUp.call(this),this._pako=null},g.prototype._createPako=function(){this._pako=new a[this._pakoAction]({raw:!0,level:this._pakoOptions.level||-1});var u=this;this._pako.onData=function(h){u.push({data:h,meta:u.meta})}},r.compressWorker=function(u){return new g("Deflate",u)},r.uncompressWorker=function(){return new g("Inflate",{})}},{"./stream/GenericWorker":28,"./utils":32,pako:38}],8:[function(o,i,r){function s(d,_){var m,p="";for(m=0;m<_;m++)p+=String.fromCharCode(255&d),d>>>=8;return p}function a(d,_,m,p,I,f){var C,y,E=d.file,B=d.compression,Q=f!==l.utf8encode,b=A.transformTo("string",f(E.name)),D=A.transformTo("string",l.utf8encode(E.name)),R=E.comment,M=A.transformTo("string",f(R)),L=A.transformTo("string",l.utf8encode(R)),G=D.length!==E.name.length,O=L.length!==R.length,U="",W="",j="",te=E.dir,ie=E.date,$={crc32:0,compressedSize:0,uncompressedSize:0};_&&!m||($.crc32=d.crc32,$.compressedSize=d.compressedSize,$.uncompressedSize=d.uncompressedSize);var Z=0;_&&(Z|=8),Q||!G&&!O||(Z|=2048);var se=0,ae=0;te&&(se|=16),I==="UNIX"?(ae=798,se|=(function(fe,Ce){var xe=fe;return fe||(xe=Ce?16893:33204),(65535&xe)<<16})(E.unixPermissions,te)):(ae=20,se|=(function(fe){return 63&(fe||0)})(E.dosPermissions)),C=ie.getUTCHours(),C<<=6,C|=ie.getUTCMinutes(),C<<=5,C|=ie.getUTCSeconds()/2,y=ie.getUTCFullYear()-1980,y<<=4,y|=ie.getUTCMonth()+1,y<<=5,y|=ie.getUTCDate(),G&&(W=s(1,1)+s(g(b),4)+D,U+="up"+s(W.length,2)+W),O&&(j=s(1,1)+s(g(M),4)+L,U+="uc"+s(j.length,2)+j);var ce="";return ce+=`
|
|
5798
|
+
`,g=new Blob([l],{type:"text/plain"}),u=URL.createObjectURL(g),h=document.createElement("a");h.href=u,h.download=`${c}.test.ts`,h.click(),URL.revokeObjectURL(u)}catch(A){alert(`Error generating test.ts for ${t.constructor.name}: ${A instanceof Error?A.message:String(A)}`)}o(!1)};return Y.jsxs("div",{className:`relative ${e}`,ref:i,children:[Y.jsx("button",{className:"px-2 py-1 rounded text-xs cursor-pointer",onClick:()=>o(!n),title:`Download options for ${t.constructor.name}`,children:t.constructor.name}),n&&Y.jsxs("div",{className:"absolute top-full left-0 mt-1 bg-white border border-gray-300 rounded shadow-lg z-10 min-w-[150px]",children:[Y.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:r,children:"Download JSON"}),Y.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:s,children:"Download page.tsx"}),Y.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:a,children:"Download test.ts"})]})]})},lGt=t=>t.activeSubSolver?[t,...lGt(t.activeSubSolver)]:[t],nWo=({solver:t})=>{const e=lGt(t);return Y.jsx("div",{className:"flex gap-1 items-center text-sm pt-1",children:e.map((n,o)=>Y.jsxs("div",{className:"flex items-center",children:[o>0&&Y.jsx("span",{className:"text-gray-400 mx-1",children:"→"}),Y.jsx(tWo,{solver:n})]},n.constructor.name))})},oWo=({solver:t,triggerRender:e,animationSpeed:n=25,onSolverStarted:o,onSolverCompleted:i})=>{const[r,s]=X.useReducer(_=>!_,!1),a=X.useRef(void 0),A=()=>{!t.solved&&!t.failed&&(t.step(),e())},c=()=>{!t.solved&&!t.failed&&(o&&o(t),t.solve(),e(),i&&i(t))},l=()=>{r?(a.current&&(clearInterval(a.current),a.current=void 0),s()):(s(),a.current=setInterval(()=>{if(t.solved||t.failed){a.current&&(clearInterval(a.current),a.current=void 0),s(),e(),i&&t.solved&&i(t);return}t.step(),e()},n))},g=()=>{const _=t;if(_.getCurrentPhase&&!t.solved&&!t.failed){const m=_.getCurrentPhase();for(;_.getCurrentPhase()===m&&!t.solved&&!t.failed;)t.step();e()}},u=()=>{if(t.solved||t.failed||r)return;const _=window.prompt("Step until which iteration?",`${t.iterations}`);if(_===null)return;const m=Number(_);if(!Number.isFinite(m)){window.alert("Please enter a valid number for the iteration");return}for(;t.iterations<m&&!t.solved&&!t.failed;)t.step();e(),t.solved&&i&&i(t)};X.useEffect(()=>()=>{a.current&&clearInterval(a.current)},[]),X.useEffect(()=>{(t.solved||t.failed)&&r&&(a.current&&(clearInterval(a.current),a.current=void 0),s())},[t.solved,t.failed,r]);const h=t.getCurrentPhase!==void 0,d=h?t.getCurrentPhase():null;return Y.jsxs("div",{className:"space-y-2 p-2 border-b",children:[Y.jsx("div",{className:"flex items-center",children:Y.jsx(nWo,{solver:t})}),Y.jsxs("div",{className:"flex gap-2 items-center flex-wrap",children:[Y.jsx("button",{onClick:A,disabled:t.solved||t.failed||r,className:"bg-blue-500 hover:bg-blue-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Step"}),Y.jsx("button",{onClick:c,disabled:t.solved||t.failed||r,className:"bg-green-500 hover:bg-green-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Solve"}),Y.jsx("button",{onClick:l,disabled:t.solved||t.failed,className:`px-3 py-1 rounded text-white text-sm ${r?"bg-red-500 hover:bg-red-600":"bg-yellow-500 hover:bg-yellow-600"} disabled:bg-gray-300`,children:r?"Stop":"Animate"}),Y.jsx("button",{onClick:u,disabled:t.solved||t.failed||r,className:"bg-orange-500 hover:bg-orange-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Step Until Iteration"}),h&&Y.jsx("button",{onClick:g,disabled:t.solved||t.failed||r,className:"bg-purple-500 hover:bg-purple-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Next Stage"}),Y.jsxs("div",{className:"text-sm text-gray-600",children:["Iterations: ",t.iterations]}),t.timeToSolve!==void 0&&Y.jsxs("div",{className:"text-sm text-gray-600",children:["Time: ",(t.timeToSolve/1e3).toFixed(3),"s"]}),d&&Y.jsxs("div",{className:"text-sm text-gray-600",children:["Phase: ",Y.jsx("span",{className:"font-medium",children:d})]}),t.solved&&Y.jsx("div",{className:"px-2 py-1 bg-green-100 text-green-800 rounded text-sm",children:"Solved"}),t.failed&&Y.jsx("div",{className:"px-2 py-1 bg-red-100 text-red-800 rounded text-sm",children:"Failed"})]}),t.error&&Y.jsxs("div",{className:"text-red-600 text-sm",children:["Error: ",t.error]})]})},iWo=(t,e,n)=>{const o=t.currentPipelineStepIndex;return e<o?"Completed":e===o&&t.activeSubSolver?t.activeSubSolver.failed?"Failed":"In Progress":"Not Started"},rWo=(t,e)=>{const o=t.pipelineDef[e].solverName,i=iWo(t,e),r=t[o],s=t.firstIterationOfPhase?.[o]??null,a=t.iterations;let A=0;if(i==="Completed"){const u=t.pipelineDef[e+1],h=u?t.firstIterationOfPhase?.[u.solverName]:void 0;h!==void 0&&s!==null?A=h-s:s!==null&&(A=a-s)}else i==="In Progress"&&s!==null&&(A=a-s);const c=t.timeSpentOnPhase?.[o]??0;let l=0;i==="Completed"?l=1:i==="In Progress"&&r&&(l=r.progress??0);const g=r?.stats??null;return{index:e,name:o,status:i,firstIteration:s,iterations:A,progress:l,timeSpent:c,stats:g&&Object.keys(g).length>0?g:null,solverInstance:r??null}},sWo=({status:t})=>{const e={"Not Started":"text-blue-600","In Progress":"text-yellow-600",Completed:"text-green-600",Failed:"text-red-600"};return Y.jsx("span",{className:`font-medium ${e[t]}`,children:t})},aWo=({progress:t})=>{if(t===0)return null;const e=Math.round(t*100);return Y.jsxs("div",{className:"flex items-center gap-2",children:[Y.jsx("div",{className:"w-20 h-2 bg-gray-200 rounded overflow-hidden",children:Y.jsx("div",{className:"h-full bg-blue-500 transition-all duration-200",style:{width:`${e}%`}})}),Y.jsxs("span",{className:"text-xs text-gray-500",children:[e,"%"]})]})},AWo=t=>Object.entries(t).map(([e,n])=>`${e}: ${n}`).join(", "),cWo=({stats:t})=>{if(!t||Object.keys(t).length===0)return Y.jsx("span",{children:"-"});const e=Object.entries(t),n=AWo(t);return Y.jsxs("details",{className:"cursor-pointer",children:[Y.jsx("summary",{className:"whitespace-nowrap overflow-hidden text-ellipsis max-w-[200px]",children:n}),Y.jsx("div",{className:"mt-1 text-xs",children:e.map(([o,i])=>Y.jsxs("div",{children:[o,": ",String(i)]},o))})]})},s7e=t=>{if(t===null||typeof t!="object")return t;if(Array.isArray(t))return t.map(s7e);const e={};for(const[n,o]of Object.entries(t))n.startsWith("_")||(e[n]=s7e(o));return e},lWo=(t,e)=>{try{if(typeof t.getConstructorParams!="function"){alert(`getConstructorParams() is not implemented for ${e}`);return}const n=s7e(t.getConstructorParams()),o=new Blob([JSON.stringify(n,null,2)],{type:"application/json"}),i=URL.createObjectURL(o),r=document.createElement("a");r.href=i,r.download=`${e}_input.json`,r.click(),URL.revokeObjectURL(i)}catch(n){alert(`Error downloading input for ${e}: ${n instanceof Error?n.message:String(n)}`)}},gWo=({solver:t,onStepUntilPhase:e,onDownloadInput:n})=>{const o=t.pipelineDef.map((a,A)=>rWo(t,A)),i=a=>{e?.(a)},r=a=>{a.solverInstance&&(n?n(a.solverInstance,a.name):lWo(a.solverInstance,a.name))},s=a=>`${(a/1e3).toFixed(2)}s`;return Y.jsxs("div",{className:"border-t border-gray-200",children:[Y.jsx("div",{className:"px-4 py-2 bg-gray-50 border-b border-gray-200",children:Y.jsx("h3",{className:"text-sm font-semibold text-gray-700",children:"Pipeline Steps"})}),Y.jsx("div",{className:"overflow-x-auto",children:Y.jsxs("table",{className:"w-full text-sm",children:[Y.jsx("thead",{children:Y.jsxs("tr",{className:"bg-gray-50 border-b border-gray-200",children:[Y.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Step"}),Y.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Status"}),Y.jsxs("th",{className:"px-4 py-2 text-center font-semibold text-gray-700",children:["i",Y.jsx("sub",{children:"0"})]}),Y.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Iterations"}),Y.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Progress"}),Y.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Time"}),Y.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Stats"}),Y.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Input"})]})}),Y.jsx("tbody",{children:o.map(a=>Y.jsxs("tr",{className:`border-b border-gray-100 ${a.status==="In Progress"?"bg-yellow-50":""}`,children:[Y.jsx("td",{className:"px-4 py-2",children:Y.jsxs("div",{className:"flex items-center gap-2",children:[Y.jsx("span",{className:"text-gray-400 w-6",children:String(a.index+1).padStart(2,"0")}),Y.jsx("button",{onClick:()=>i(a.name),disabled:a.status==="Completed"||t.solved||t.failed,className:"text-blue-500 hover:text-blue-700 disabled:text-gray-300 disabled:cursor-not-allowed",title:`Step until ${a.name} completes`,children:Y.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:Y.jsx("path",{fillRule:"evenodd",d:"M4.5 5.653c0-1.426 1.529-2.33 2.779-1.643l11.54 6.348c1.295.712 1.295 2.573 0 3.285L7.28 19.991c-1.25.687-2.779-.217-2.779-1.643V5.653z",clipRule:"evenodd"})})}),Y.jsx("span",{className:"font-medium text-gray-900",children:a.name})]})}),Y.jsx("td",{className:"px-4 py-2",children:Y.jsx(sWo,{status:a.status})}),Y.jsx("td",{className:"px-4 py-2 text-center text-gray-600",children:a.firstIteration!==null?a.firstIteration:""}),Y.jsx("td",{className:"px-4 py-2 text-gray-600",children:a.iterations}),Y.jsx("td",{className:"px-4 py-2",children:Y.jsx(aWo,{progress:a.progress})}),Y.jsx("td",{className:"px-4 py-2 text-gray-600",children:s(a.timeSpent)}),Y.jsx("td",{className:"px-4 py-2 text-gray-500",children:Y.jsx(cWo,{stats:a.stats})}),Y.jsx("td",{className:"px-4 py-2",children:a.solverInstance?Y.jsxs("button",{onClick:()=>r(a),className:"flex items-center gap-1 text-blue-500 hover:text-blue-700",title:`Download input for ${a.name}`,children:[Y.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:Y.jsx("path",{fillRule:"evenodd",d:"M12 2.25a.75.75 0 01.75.75v11.69l3.22-3.22a.75.75 0 111.06 1.06l-4.5 4.5a.75.75 0 01-1.06 0l-4.5-4.5a.75.75 0 111.06-1.06l3.22 3.22V3a.75.75 0 01.75-.75zm-9 13.5a.75.75 0 01.75.75v2.25a1.5 1.5 0 001.5 1.5h13.5a1.5 1.5 0 001.5-1.5V16.5a.75.75 0 011.5 0v2.25a3 3 0 01-3 3H5.25a3 3 0 01-3-3V16.5a.75.75 0 01.75-.75z",clipRule:"evenodd"})}),Y.jsx("span",{children:"Input"})]}):null})]},a.name))})]})})]})},uWo=class extends Xr.Component{constructor(t){super(t),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(t){console.error("InteractiveGraphics render error:",t)}render(){return this.state.hasError?this.props.fallback:this.props.children}};function dWo({graphics:t}){const e=t.points??[],n=t.lines??[],o=t.rects??[],i=t.circles??[],r=t.texts??[];let s=Number.POSITIVE_INFINITY,a=Number.POSITIVE_INFINITY,A=Number.NEGATIVE_INFINITY,c=Number.NEGATIVE_INFINITY;const l=(m,p)=>{typeof m=="number"&&(m<s&&(s=m),m>A&&(A=m)),typeof p=="number"&&(p<a&&(a=p),p>c&&(c=p))};for(const m of e)l(m.x,m.y);for(const m of n){const p=m.points??[];for(const I of p)l(I.x,I.y)}for(const m of o){const p=m.x??0,I=m.y??0,f=m.width??0,C=m.height??0;l(p,I),l(p+f,I+C)}for(const m of i){const p=m.x??0,I=m.y??0,f=m.radius??1;l(p-f,I-f),l(p+f,I+f)}for(const m of r)l(m.x,m.y);(!isFinite(s)||!isFinite(a)||!isFinite(A)||!isFinite(c))&&(s=-20,a=-20,A=20,c=20);const g=10,u=s-g,h=a-g,d=Math.max(1,A-s+2*g),_=Math.max(1,c-a+2*g);return Y.jsxs("svg",{className:"w-full h-[400px] bg-white",viewBox:`${u} ${h} ${d} ${_}`,role:"img","aria-label":"Graphics fallback",children:[o.map((m,p)=>Y.jsx("rect",{x:m.x??0,y:m.y??0,width:m.width??0,height:m.height??0,fill:"none",stroke:m.strokeColor??"black",strokeWidth:m.strokeWidth??1},`rect-${p}`)),n.map((m,p)=>Y.jsx("polyline",{fill:"none",stroke:m.strokeColor??"black",strokeWidth:m.strokeWidth??1,points:(m.points??[]).map(I=>`${I.x??0},${I.y??0}`).join(" ")},`line-${p}`)),i.map((m,p)=>Y.jsx("circle",{cx:m.x??0,cy:m.y??0,r:m.radius??1.5,fill:m.fillColor??"none",stroke:m.strokeColor??"black",strokeWidth:m.strokeWidth??1},`circle-${p}`)),e.map((m,p)=>Y.jsx("circle",{cx:m.x??0,cy:m.y??0,r:m.radius??1.5,fill:m.color??"black"},`point-${p}`)),r.map((m,p)=>Y.jsx("text",{x:m.x??0,y:m.y??0,fontSize:m.fontSize??10,fill:m.color??"black",children:m.text??""},`text-${p}`))]})}var hWo=({solver:t,animationSpeed:e=25,onSolverStarted:n,onSolverCompleted:o})=>{const[i,r]=X.useReducer(l=>l+1,0),s=X.useMemo(()=>{try{return t.visualize()||{points:[],lines:[],rects:[],circles:[]}}catch(l){return console.error("Visualization error:",l),{points:[],lines:[],rects:[],circles:[]}}},[t,i]),a=X.useMemo(()=>(s.rects?.length||0)===0&&(s.lines?.length||0)===0&&(s.points?.length||0)===0&&(s.circles?.length||0)===0,[s]);X.useEffect(()=>{if(!(typeof document>"u")&&!document.querySelector('script[src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4"]')){const l=document.createElement("script");l.src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4",document.head.appendChild(l)}},[]);const A=t.pipelineDef!==void 0,c=l=>{const g=t;if(!t.solved&&!t.failed){for(;!t.solved&&!t.failed&&g.currentPipelineStepIndex<=g.pipelineDef.findIndex(u=>u.solverName===l);)t.step();r()}};return Y.jsxs("div",{children:[Y.jsx(oWo,{solver:t,triggerRender:r,animationSpeed:e,onSolverStarted:n,onSolverCompleted:o}),a?Y.jsx("div",{className:"p-4 text-gray-500",children:"No Graphics Yet"}):Y.jsx(uWo,{fallback:Y.jsx(dWo,{graphics:s}),children:Y.jsx(eWo,{graphics:s})}),A&&Y.jsx(gWo,{solver:t,onStepUntilPhase:c})]})};const _Wo=()=>{X.useEffect(()=>{const t="tailwind-cdn-script";if(document.getElementById(t)||window.tailwind)return;const e=document.createElement("div");e.className="hidden",document.body.appendChild(e);const n=window.getComputedStyle(e).display==="none";if(document.body.removeChild(e),n)return;const o=document.createElement("script");o.id=t,o.src="https://cdn.tailwindcss.com",document.head.appendChild(o)},[])},mWo=1e3,rQ=(t,e)=>{const{fileName:n,mimeType:o="text/plain"}=e,i=t instanceof Blob?t:new Blob([t],{type:o}),r=URL.createObjectURL(i),s=document.createElement("a");s.href=r,s.download=n,s.target="_blank",s.rel="noopener noreferrer",s.style.display="none",document.body.appendChild(s),s.click(),document.body.removeChild(s),setTimeout(()=>{URL.revokeObjectURL(r)},mWo)},a7e=t=>{let e=t.trim().replace(/[\\/:*?"<>|]/g,"_").replace(/[\x00-\x1f]/g,"").replace(/^\.+/,"").replace(/\.+$/,"").replace(/\s+/g," ").replace(/_+/g,"_");return/^(con|prn|aux|nul|com[0-9]|lpt[0-9])$/i.test(e)&&(e=`_${e}`),e=e.slice(0,200),e||"untitled"},_b="https://github.com/tscircuit/tscircuit-autorouter/issues/new",gGt="https://github.com/tscircuit/copper-pour-solver/issues/new",uGt="https://github.com/tscircuit/calculate-packing/issues/new",pWo="https://github.com/tscircuit/matchpack/issues/new",dGt="https://github.com/tscircuit/schematic-trace-solver/issues/new?template=json-bug-report.yml",IWo={PackSolver2:uGt,LayoutPipelineSolver:pWo,AutoroutingPipelineSolver:_b,AssignableAutoroutingPipeline2:_b,AssignableAutoroutingPipeline3:_b,AutoroutingPipeline1_OriginalUnravel:_b,AutoroutingPipelineSolver3_HgPortPointPathing:_b,AutoroutingPipelineSolver4:_b,AutoroutingPipelineSolver5:_b,AutoroutingPipelineSolver7_MultiGraph:_b,AutoroutingPipelineSolver8:_b,CopperPourPipelineSolver:gGt,SchematicTracePipelineSolver:dGt},fWo=t=>t.toLowerCase().includes("pack")?hNt:t.toLowerCase().includes("rout")?ALo:OFo,hGt=t=>{const e=IWo[t];if(e)return e;const n=t.toLowerCase();return n.includes("autorout")?_b:n.includes("schematic")&&n.includes("trace")?dGt:n.includes("copperpour")?gGt:n.includes("pack")?uGt:null},CWo=t=>`${a7e(`${t.componentName}-${t.solverName}`)}-solver-input.json`,_Gt=t=>{rQ(JSON.stringify(t.solverParams,null,2),{fileName:CWo(t),mimeType:"application/json"})},yWo=({solverEvent:t})=>{const e=hGt(t.solverName);return Y.jsxs("div",{className:"rf-flex rf-items-center rf-justify-end rf-gap-2 rf-border-b rf-border-gray-200 rf-bg-gray-50 rf-px-4 rf-py-2",children:[Y.jsxs(fa,{type:"button",variant:"outline",size:"sm",onClick:()=>_Gt(t),children:[Y.jsx(ese,{className:"rf-w-4 rf-h-4"}),"Download"]}),e?Y.jsx(fa,{asChild:!0,variant:"outline",size:"sm",children:Y.jsxs("a",{href:e,target:"_blank",rel:"noopener noreferrer",children:[Y.jsx(Zre,{className:"rf-w-4 rf-h-4"}),"Report"]})}):Y.jsxs(fa,{type:"button",variant:"outline",size:"sm",disabled:!0,title:"No report link configured for this solver",children:[Y.jsx(Zre,{className:"rf-w-4 rf-h-4"}),"Report"]})]})},EWo=({solverEvent:t})=>{const e=hGt(t.solverName);return e?Y.jsx(fa,{asChild:!0,variant:"ghost",size:"icon",className:"rf-h-8 rf-w-8",children:Y.jsx("a",{href:e,target:"_blank",rel:"noopener noreferrer",title:"Report solver bug","aria-label":"Report solver bug",children:Y.jsx(Zre,{className:"rf-w-4 rf-h-4"})})}):Y.jsx(fa,{type:"button",variant:"ghost",size:"icon",className:"rf-h-8 rf-w-8",disabled:!0,title:"No report link configured for this solver","aria-label":"Report solver bug",children:Y.jsx(Zre,{className:"rf-w-4 rf-h-4"})})},xWo=({solverEvents:t=[]})=>{const[e,n]=X.useState(null);_Wo();const o=X.useMemo(()=>{const a=new Map;for(const A of t){const c=`${A.componentName}-${A.solverName}`;a.set(c,A)}return a},[t]),i=X.useMemo(()=>Array.from(o.keys()),[o]),r=e?o.get(e):null,s=X.useMemo(()=>{if(!r)return{instance:null,error:null,classFound:!1};const a=Vye[r.solverName];if(!a)return{instance:null,error:`Solver class "${r.solverName}" not found in SOLVERS registry. Available: ${Object.keys(Vye).join(", ")}`,classFound:!1};try{const A=r.solverParams,c=A?.input!==void 0?A.input:A;return{instance:new a(c),error:null,classFound:!0}}catch(A){const c=A instanceof Error?A.message:String(A);return console.error("Failed to reconstruct solver:",A),{instance:null,error:`Failed to instantiate solver: ${c}`,classFound:!0}}},[r]);return t.length===0?Y.jsx("div",{className:"rf-p-4",children:Y.jsx("div",{className:"rf-bg-gray-50 rf-rounded-md rf-border rf-border-gray-200",children:Y.jsxs("div",{className:"rf-p-4",children:[Y.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800 rf-mb-3",children:"No Solvers Detected"}),Y.jsx("p",{className:"rf-text-sm rf-text-gray-600",children:"Solvers will appear here when the circuit runs. Solvers are used for tasks like component packing and autorouting."})]})})}):Y.jsxs("div",{className:"rf-flex rf-h-full rf-overflow-hidden",children:[Y.jsxs("div",{className:"rf-w-64 rf-border-r rf-border-gray-200 rf-overflow-y-auto rf-flex-shrink-0",children:[Y.jsxs("div",{className:"rf-text-xs rf-font-semibold rf-text-gray-500 rf-px-3 rf-py-2 rf-bg-gray-50 rf-border-b rf-border-gray-200",children:[i.length," ",i.length===1?"Solver":"Solvers"]}),i.map(a=>{const A=o.get(a),c=e===a;return Y.jsx("div",{className:`rf-px-3 rf-py-2 rf-cursor-pointer rf-border-b rf-border-gray-100 ${c?"rf-bg-blue-50 rf-border-l-2 rf-border-l-blue-500":"hover:rf-bg-gray-50"}`,onClick:()=>n(a),children:(()=>{const l=fWo(A.solverName);return Y.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2",children:[Y.jsx(l,{className:"rf-w-4 rf-h-4 rf-text-blue-500 rf-flex-shrink-0"}),Y.jsxs("div",{className:"rf-flex-1 rf-min-w-0",children:[Y.jsx("div",{className:"rf-text-sm rf-font-medium rf-text-gray-800 rf-truncate",children:A.componentName}),Y.jsx("div",{className:"rf-text-xs rf-text-gray-500 rf-truncate",children:A.solverName})]})]})})()},a)})]}),Y.jsx("div",{className:"rf-flex-1 rf-overflow-hidden",children:r?s.instance?Y.jsxs("div",{className:"rf-flex rf-h-full rf-flex-col rf-overflow-y-auto",children:[Y.jsx(yWo,{solverEvent:r}),Y.jsx("div",{className:"rf-min-h-0 rf-flex-1",children:Y.jsx(Rx,{fallback:Y.jsx("div",{className:"rf-p-4",children:Y.jsxs("div",{className:"rf-bg-red-50 rf-rounded-md rf-border rf-border-red-200 rf-p-4",children:[Y.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-red-800 rf-mb-2",children:"Error Loading Solver Debugger"}),Y.jsxs("p",{className:"rf-text-sm rf-text-red-600",children:["Failed to render the solver debugger for"," ",r.solverName]})]})}),children:Y.jsx(hWo,{solver:s.instance})})})]}):Y.jsxs("div",{className:"rf-p-4",children:[Y.jsxs("div",{className:"rf-mb-4",children:[Y.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800",children:r.solverName}),Y.jsxs("p",{className:"rf-text-sm rf-text-gray-500",children:["Component: ",r.componentName]})]}),s.error&&Y.jsx("div",{className:`rf-rounded-md rf-border rf-p-4 rf-mb-4 ${s.classFound?"rf-bg-red-50 rf-border-red-200":"rf-bg-yellow-50 rf-border-yellow-200"}`,children:Y.jsx("p",{className:`rf-text-sm ${s.classFound?"rf-text-red-700":"rf-text-yellow-700"}`,children:s.error})}),Y.jsxs("div",{className:"rf-border rf-border-gray-200 rf-rounded-md rf-overflow-hidden",children:[Y.jsxs("div",{className:"rf-px-3 rf-py-2 rf-bg-gray-50 rf-flex rf-items-center rf-justify-between rf-gap-2",children:[Y.jsx("span",{className:"rf-text-sm rf-font-medium rf-text-gray-700",children:"Solver Parameters"}),Y.jsxs("div",{className:"rf-flex rf-items-center rf-gap-1",children:[Y.jsx(EWo,{solverEvent:r}),Y.jsx(fa,{type:"button",variant:"ghost",size:"icon",className:"rf-h-8 rf-w-8","aria-label":"Download solver input JSON",title:"Download solver input JSON",onClick:()=>_Gt(r),children:Y.jsx(ese,{className:"rf-w-4 rf-h-4"})})]})]}),Y.jsx("div",{className:"rf-p-3 rf-bg-white rf-border-t rf-border-gray-200",children:Y.jsx("pre",{className:"rf-text-xs rf-font-mono rf-text-gray-600 rf-whitespace-pre-wrap rf-overflow-x-auto",children:JSON.stringify(r.solverParams,null,2)})})]})]}):Y.jsx("div",{className:"rf-flex rf-items-center rf-justify-center rf-h-full",children:Y.jsx("p",{className:"rf-text-sm rf-text-gray-500",children:"Select a solver from the list to view details"})})})]})},mGt=({errorMessage:t,errorStack:e,circuitJsonErrors:n})=>{X.useEffect(()=>{if(t){const o=new Error(t);e&&(o.stack=e);try{vR.captureException(o)}catch{}}},[t,e]),X.useEffect(()=>{if(n&&n.length>0)for(const o of n){const i=new Error(o.message||"Circuit JSON Error");o.stack&&(i.stack=o.stack);try{vR.captureException(i,{error_type:o.type})}catch{}}},[n])},pGt=t=>{X.useEffect(()=>{try{yro(t)}catch{}},[t.source,t.component,t.isWebEmbedded,t.activeTab])},IGt="0.0.2466",BWo={version:IGt},mae=tIt()(nIt(t=>({lastRunEvalVersion:void 0,setLastRunEvalVersion:e=>{t({lastRunEvalVersion:e})}}),{name:"runframe-runner-store"})),QWo=t=>{const[e,n]=X.useState([]),[o,i]=X.useState(null),[r,s]=X.useState(""),[a,A]=rR("eval-version-selection",null),c=mae(h=>h.setLastRunEvalVersion),l=mae(h=>h.lastRunEvalVersion);return X.useEffect(()=>{t&&fetch("https://data.jsdelivr.com/v1/package/npm/@tscircuit/eval").then(h=>h.json()).then(h=>{if(Array.isArray(h?.versions)){let d=[...h.versions];h.tags?.latest&&(i(h.tags.latest),d=d.filter(_=>_!==h.tags.latest)),n(d)}}).catch(()=>{})},[t]),X.useEffect(()=>{t&&(a?(window.TSCIRCUIT_LATEST_EVAL_VERSION=a,c(a)):o&&(window.TSCIRCUIT_LATEST_EVAL_VERSION=o,c(o)))},[t,a,o]),{versions:X.useMemo(()=>e.filter(h=>h.includes(r)).slice(0,50),[e,r]),latestVersion:o,lastRunEvalVersion:l,search:r,setSearch:s,selectVersion:h=>{A(h),s("")}}},SWo=({snippetNames:t,onSelect:e,onCancel:n,isOpen:o})=>{const[i,r]=X.useState(""),[s,a]=X.useState("");if(!o)return null;const A=t.filter(g=>g.toLowerCase().includes(s.toLowerCase())),c=s&&!t.includes(s),l=g=>{g.key==="Enter"&&(A.length===1?r(A[0]):c&&r(s))};return Y.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:Y.jsxs("div",{className:"rf-bg-white rf-rounded-lg rf-p-6 rf-w-96",children:[Y.jsx("h2",{className:"rf-text-lg rf-font-semibold rf-mb-4",children:"Select Snippet"}),Y.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:g=>a(g.target.value),onKeyDown:l}),Y.jsxs("div",{className:"rf-h-60 rf-overflow-y-auto",children:[A.map(g=>Y.jsx("button",{type:"button",className:`w-full text-left px-4 py-2 rounded hover:bg-gray-100 ${i===g?"bg-blue-50":""}`,onClick:()=>r(g),children:g},g)),c&&Y.jsxs("button",{type:"button",className:`w-full text-left px-4 py-2 rounded hover:bg-gray-100 text-blue-500 ${i===s?"bg-blue-50":""}`,onClick:()=>r(s),children:['Create new "',s,'"']})]}),Y.jsxs("div",{className:"rf-mt-4 rf-flex rf-justify-end rf-gap-2",children:[Y.jsx("button",{type:"button",className:"rf-px-4 rf-py-2 rf-text-gray-600 rf-hover:text-gray-800",onClick:n,children:"Cancel"}),Y.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:()=>i&&e(i),disabled:!i,children:i===s?`Create "${i}"`:`Save to ${i}`})]})]})})},bWo=t=>{const e=X.useRef(null),n=Xu(o=>o.recentEvents);X.useEffect(()=>{if(n.length===0)return;const o=n[0];o.event_id!==e.current&&(t(o),e.current=o.event_id)},[n,t])};var DWo=Object.defineProperty,AE=(t,e)=>DWo(t,"name",{value:e,configurable:!0}),A7e="Dialog",[fGt,CGt]=Cy(A7e),[vWo,sQ]=fGt(A7e),c7e=AE(t=>{const{__scopeDialog:e,children:n,open:o,defaultOpen:i,onOpenChange:r,modal:s=!0}=t,a=X.useRef(null),A=X.useRef(null),[c,l]=NB({prop:o,defaultProp:i??!1,onChange:r,caller:A7e}),[g,u]=X.useState(0),[h,d]=X.useState(0);return Y.jsx(vWo,{scope:e,triggerRef:a,contentRef:A,contentId:P_(),titleId:P_(),descriptionId:P_(),titlePresent:g>0,descriptionPresent:h>0,setTitleCount:u,setDescriptionCount:d,open:c,onOpenChange:l,onOpenToggle:X.useCallback(()=>l(_=>!_),[l]),modal:s,children:n})},"Dialog"),PWo="DialogTrigger",wWo=X.forwardRef(AE(function(e,n){const{__scopeDialog:o,...i}=e,r=sQ(PWo,o),s=Xa(n,r.triggerRef);return Y.jsx(Ls.button,{type:"button","aria-haspopup":"dialog","aria-expanded":r.open,"aria-controls":r.open?r.contentId:void 0,"data-state":fae(r.open),...i,ref:s,onClick:yi(e.onClick,r.onOpenToggle)})},"DialogTrigger")),yGt="DialogPortal",[MWo,EGt]=fGt(yGt,{forceMount:void 0}),l7e=AE(t=>{const{__scopeDialog:e,forceMount:n,children:o,container:i}=t,r=sQ(yGt,e);return Y.jsx(MWo,{scope:e,forceMount:n,children:X.Children.map(o,s=>Y.jsx(K2,{present:n||r.open,children:Y.jsx(pse,{asChild:!0,container:i,children:s})}))})},"DialogPortal"),g7e="DialogOverlay",pae=X.forwardRef(AE(function(e,n){const o=EGt(g7e,e.__scopeDialog),{forceMount:i=o.forceMount,...r}=e,s=sQ(g7e,e.__scopeDialog);return s.modal?Y.jsx(K2,{present:i||s.open,children:Y.jsx(RWo,{...r,ref:n})}):null},"DialogOverlay")),NWo=MB("DialogOverlay.RemoveScroll"),RWo=X.forwardRef(AE(function(e,n){const{__scopeDialog:o,...i}=e,r=sQ(g7e,o),s=INt(),a=Xa(n,s);return Y.jsx(xY,{as:NWo,allowPinchZoom:!0,shards:[r.contentRef],children:Y.jsx(Ls.div,{"data-state":fae(r.open),...i,ref:a,style:{pointerEvents:"auto",...i.style}})})},"DialogOverlayImpl")),VY="DialogContent",Iae=X.forwardRef(AE(function(e,n){const o=EGt(VY,e.__scopeDialog),{forceMount:i=o.forceMount,...r}=e,s=sQ(VY,e.__scopeDialog);return Y.jsx(K2,{present:i||s.open,children:s.modal?Y.jsx(TWo,{...r,ref:n}):Y.jsx(kWo,{...r,ref:n})})},"DialogContent")),TWo=X.forwardRef(AE(function(e,n){const o=sQ(VY,e.__scopeDialog),i=X.useRef(null),r=Xa(n,o.contentRef,i);return X.useEffect(()=>{const s=i.current;if(s)return Cse(s)},[]),Y.jsx(xGt,{...e,ref:r,trapFocus:o.open,disableOutsidePointerEvents:o.open,onCloseAutoFocus:yi(e.onCloseAutoFocus,s=>{s.preventDefault(),o.triggerRef.current?.focus()}),onPointerDownOutside:yi(e.onPointerDownOutside,s=>{const a=s.detail.originalEvent,A=a.button===0&&a.ctrlKey===!0;(a.button===2||A)&&s.preventDefault()}),onFocusOutside:yi(e.onFocusOutside,s=>s.preventDefault())})},"DialogContentModal")),kWo=X.forwardRef(AE(function(e,n){const o=sQ(VY,e.__scopeDialog),i=X.useRef(!1),r=X.useRef(!1);return Y.jsx(xGt,{...e,ref:n,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:s=>{e.onCloseAutoFocus?.(s),s.defaultPrevented||(i.current||o.triggerRef.current?.focus(),s.preventDefault()),i.current=!1,r.current=!1},onInteractOutside:s=>{e.onInteractOutside?.(s),s.defaultPrevented||(i.current=!0,s.detail.originalEvent.type==="pointerdown"&&(r.current=!0));const a=s.target;o.triggerRef.current?.contains(a)&&s.preventDefault(),s.detail.originalEvent.type==="focusin"&&r.current&&s.preventDefault()}})},"DialogContentNonModal")),xGt=X.forwardRef(AE(function(e,n){const{__scopeDialog:o,trapFocus:i,onOpenAutoFocus:r,onCloseAutoFocus:s,...a}=e,A=sQ(VY,o);return Bk(),Y.jsx(Y.Fragment,{children:Y.jsx(nse,{asChild:!0,loop:!0,trapped:i,onMountAutoFocus:r,onUnmountAutoFocus:s,children:Y.jsx(fY,{role:"dialog",id:A.contentId,"aria-describedby":A.descriptionPresent?A.descriptionId:void 0,"aria-labelledby":A.titlePresent?A.titleId:void 0,"data-state":fae(A.open),...a,ref:n,deferPointerDownOutside:!0,onDismiss:()=>A.onOpenChange(!1)})})})},"DialogContentImpl")),FWo="DialogTitle",u7e=X.forwardRef(AE(function(e,n){const{__scopeDialog:o,...i}=e,r=sQ(FWo,o),{setTitleCount:s}=r;return jd(()=>(s(a=>a+1),()=>s(a=>a-1)),[s]),Y.jsx(Ls.h2,{id:r.titleId,...i,ref:n})},"DialogTitle")),LWo="DialogDescription",d7e=X.forwardRef(AE(function(e,n){const{__scopeDialog:o,...i}=e,r=sQ(LWo,o),{setDescriptionCount:s}=r;return jd(()=>(s(a=>a+1),()=>s(a=>a-1)),[s]),Y.jsx(Ls.p,{id:r.descriptionId,...i,ref:n})},"DialogDescription")),HWo="DialogClose",BGt=X.forwardRef(AE(function(e,n){const{__scopeDialog:o,...i}=e,r=sQ(HWo,o);return Y.jsx(Ls.button,{type:"button",...i,ref:n,onClick:yi(e.onClick,()=>r.onOpenChange(!1))})},"DialogClose"));function fae(t){return t?"open":"closed"}AE(fae,"getState");var GWo=Object.defineProperty,D5=(t,e)=>GWo(t,"name",{value:e,configurable:!0}),OWo="AlertDialog",[KWo,Aai]=Cy(OWo,[CGt]),v5=CGt(),UWo=D5(t=>{const{__scopeAlertDialog:e,...n}=t,o=v5(e);return Y.jsx(c7e,{...o,...n,modal:!0})},"AlertDialog");X.forwardRef(D5(function(e,n){const{__scopeAlertDialog:o,...i}=e,r=v5(o);return Y.jsx(wWo,{...r,...i,ref:n})},"AlertDialogTrigger"));var YWo=D5(t=>{const{__scopeAlertDialog:e,...n}=t,o=v5(e);return Y.jsx(l7e,{...o,...n})},"AlertDialogPortal"),zWo=X.forwardRef(D5(function(e,n){const{__scopeAlertDialog:o,...i}=e,r=v5(o);return Y.jsx(pae,{...r,...i,ref:n})},"AlertDialogOverlay")),VWo="AlertDialogContent",[JWo,qWo]=KWo(VWo),WWo=X.forwardRef(D5(function(e,n){const{__scopeAlertDialog:o,children:i,...r}=e,s=v5(o),a=X.useRef(null),A=Xa(n,a),c=X.useRef(null);return Y.jsx(JWo,{scope:o,cancelRef:c,children:Y.jsx(Iae,{role:"alertdialog",...s,...r,ref:A,onOpenAutoFocus:yi(r.onOpenAutoFocus,l=>{l.preventDefault(),c.current?.focus({preventScroll:!0})}),onPointerDownOutside:l=>l.preventDefault(),onInteractOutside:l=>l.preventDefault(),children:i})})},"AlertDialogContent")),jWo=X.forwardRef(D5(function(e,n){const{__scopeAlertDialog:o,...i}=e,r=v5(o);return Y.jsx(u7e,{...r,...i,ref:n})},"AlertDialogTitle")),XWo=X.forwardRef(D5(function(e,n){const{__scopeAlertDialog:o,...i}=e,r=v5(o);return Y.jsx(d7e,{...r,...i,ref:n})},"AlertDialogDescription")),$Wo=X.forwardRef(D5(function(e,n){const{__scopeAlertDialog:o,...i}=e,r=v5(o);return Y.jsx(BGt,{...r,...i,ref:n})},"AlertDialogAction")),ZWo="AlertDialogCancel",ejo=X.forwardRef(D5(function(e,n){const{__scopeAlertDialog:o,...i}=e,{cancelRef:r}=qWo(ZWo,o),s=v5(o),a=Xa(n,r);return Y.jsx(BGt,{...s,...i,ref:a})},"AlertDialogCancel")),tjo=UWo,njo=YWo,QGt=zWo,SGt=WWo,bGt=$Wo,DGt=ejo,vGt=jWo,PGt=XWo;const wGt=tjo,ojo=njo,MGt=X.forwardRef(({className:t,...e},n)=>Y.jsx(QGt,{className:Ei("rf-fixed rf-inset-0 rf-z-50 rf-bg-black/80 data-[state=open]:rf-animate-in data-[state=closed]:rf-animate-out data-[state=closed]:rf-fade-out-0 data-[state=open]:rf-fade-in-0",t),...e,ref:n}));MGt.displayName=QGt.displayName;const h7e=X.forwardRef(({className:t,...e},n)=>Y.jsxs(ojo,{children:[Y.jsx(MGt,{}),Y.jsx(SGt,{ref:n,className:Ei("rf-fixed rf-left-[50%] rf-top-[50%] rf-z-50 rf-grid rf-w-full rf-max-w-lg rf-translate-x-[-50%] rf-translate-y-[-50%] rf-gap-4 rf-border rf-border-zinc-200 rf-bg-white rf-p-6 rf-shadow-lg rf-duration-200 data-[state=open]:rf-animate-in data-[state=closed]:rf-animate-out data-[state=closed]:rf-fade-out-0 data-[state=open]:rf-fade-in-0 data-[state=closed]:rf-zoom-out-95 data-[state=open]:rf-zoom-in-95 data-[state=closed]:rf-slide-out-to-left-1/2 data-[state=closed]:rf-slide-out-to-top-[48%] data-[state=open]:rf-slide-in-from-left-1/2 data-[state=open]:rf-slide-in-from-top-[48%] sm:rf-rounded-lg dark:rf-border-zinc-800 dark:rf-bg-zinc-950",t),...e})]}));h7e.displayName=SGt.displayName;const _7e=({className:t,...e})=>Y.jsx("div",{className:Ei("rf-flex rf-flex-col rf-space-y-2 rf-text-center sm:rf-text-left",t),...e});_7e.displayName="AlertDialogHeader";const m7e=({className:t,...e})=>Y.jsx("div",{className:Ei("rf-flex rf-flex-col-reverse sm:rf-flex-row sm:rf-justify-end sm:rf-space-x-2",t),...e});m7e.displayName="AlertDialogFooter";const p7e=X.forwardRef(({className:t,...e},n)=>Y.jsx(vGt,{ref:n,className:Ei("rf-text-lg rf-font-semibold",t),...e}));p7e.displayName=vGt.displayName;const I7e=X.forwardRef(({className:t,...e},n)=>Y.jsx(PGt,{ref:n,className:Ei("rf-text-sm rf-text-zinc-500 dark:rf-text-zinc-400",t),...e}));I7e.displayName=PGt.displayName;const ijo=X.forwardRef(({className:t,...e},n)=>Y.jsx(bGt,{ref:n,className:Ei(yk(),t),...e}));ijo.displayName=bGt.displayName;const f7e=X.forwardRef(({className:t,...e},n)=>Y.jsx(DGt,{ref:n,className:Ei(yk({variant:"outline"}),"rf-mt-2 sm:rf-mt-0",t),...e}));f7e.displayName=DGt.displayName;var rjo=Object.defineProperty,P5=(t,e)=>rjo(t,"name",{value:e,configurable:!0}),C7e="Checkbox",[sjo,cai]=Cy(C7e),[ajo,y7e]=sjo(C7e);function NGt(t){const{__scopeCheckbox:e,checked:n,children:o,defaultChecked:i,disabled:r,form:s,name:a,onCheckedChange:A,required:c,value:l="on",internal_do_not_use_render:g}=t,[u,h]=NB({prop:n,defaultProp:i??!1,onChange:A,caller:C7e}),[d,_]=X.useState(null),[m,p]=X.useState(null),I=X.useRef(!1),[f,C]=X.useReducer(B=>B+1,0),y=d?!!s||!!d.closest("form"):!0,E={checked:u,disabled:r,setChecked:h,control:d,setControl:_,name:a,form:s,value:l,hasConsumerStoppedPropagationRef:I,userInteractionCount:f,onUserInteraction:C,required:c,defaultChecked:w5(i)?!1:i,isFormControl:y,bubbleInput:m,setBubbleInput:p};return Y.jsx(ajo,{scope:e,...E,children:TGt(g)?g(E):o})}P5(NGt,"CheckboxProvider");var Ajo="CheckboxTrigger",cjo=X.forwardRef(P5(function({__scopeCheckbox:e,onKeyDown:n,onClick:o,...i},r){const{control:s,value:a,disabled:A,checked:c,required:l,setControl:g,setChecked:u,hasConsumerStoppedPropagationRef:h,onUserInteraction:d,isFormControl:_,bubbleInput:m}=y7e(Ajo,e),p=Xa(r,g),I=X.useRef(c);return X.useEffect(()=>{const f=s?.form;if(f){const C=P5(()=>u(I.current),"reset");return f.addEventListener("reset",C),()=>f.removeEventListener("reset",C)}},[s,u]),Y.jsx(Ls.button,{type:"button",role:"checkbox","aria-checked":w5(c)?"mixed":c,"aria-required":l,"data-state":E7e(c),"data-disabled":A?"":void 0,disabled:A,value:a,...i,ref:p,onKeyDown:yi(n,f=>{f.key==="Enter"&&f.preventDefault()}),onClick:yi(o,f=>{d(),u(C=>w5(C)?!0:!C),m&&_&&(h.current=f.isPropagationStopped(),h.current||f.stopPropagation())})})},"CheckboxTrigger")),RGt=X.forwardRef(P5(function(e,n){const{__scopeCheckbox:o,name:i,checked:r,defaultChecked:s,required:a,disabled:A,value:c,onCheckedChange:l,form:g,...u}=e;return Y.jsx(NGt,{__scopeCheckbox:o,checked:r,defaultChecked:s,disabled:A,required:a,onCheckedChange:l,name:i,form:g,value:c,internal_do_not_use_render:({isFormControl:h})=>Y.jsxs(Y.Fragment,{children:[Y.jsx(cjo,{...u,ref:n,__scopeCheckbox:o}),h&&Y.jsx(djo,{__scopeCheckbox:o})]})})},"Checkbox")),ljo="CheckboxIndicator",gjo=X.forwardRef(P5(function(e,n){const{__scopeCheckbox:o,forceMount:i,...r}=e,s=y7e(ljo,o);return Y.jsx(K2,{present:i||w5(s.checked)||s.checked===!0,children:Y.jsx(Ls.span,{"data-state":E7e(s.checked),"data-disabled":s.disabled?"":void 0,...r,ref:n,style:{pointerEvents:"none",...e.style}})})},"CheckboxIndicator")),ujo="CheckboxBubbleInput",djo=X.forwardRef(P5(function({__scopeCheckbox:e,onClick:n,...o},i){const{control:r,hasConsumerStoppedPropagationRef:s,userInteractionCount:a,checked:A,defaultChecked:c,required:l,disabled:g,name:u,value:h,form:d,bubbleInput:_,setBubbleInput:m}=y7e(ujo,e),p=Xa(i,m),I=x8e(r),f=X.useRef(!1),C=X.useRef(A),y=X.useRef(a);X.useEffect(()=>{const B=_;if(!B)return;const Q=window.HTMLInputElement.prototype,D=Object.getOwnPropertyDescriptor(Q,"checked").set,R=a!==y.current;y.current=a;const M=C.current!==A;C.current=A;const L=!(R&&s.current);if(M&&D){f.current=!R;const G=new Event("click",{bubbles:L});B.indeterminate=w5(A),D.call(B,w5(A)?!1:A),B.dispatchEvent(G),f.current=!1}},[_,A,s,a]);const E=X.useRef(w5(A)?!1:A);return Y.jsx(Ls.input,{type:"checkbox","aria-hidden":!0,defaultChecked:c??E.current,required:l,disabled:g,name:u,value:h,form:d,...o,tabIndex:-1,ref:p,onClick:yi(n,B=>{f.current&&B.stopPropagation()}),style:{...o.style,...I,position:"absolute",pointerEvents:"none",opacity:0,margin:0,transform:"translateX(-100%)"}})},"CheckboxBubbleInput"));function TGt(t){return typeof t=="function"}P5(TGt,"isFunction");function w5(t){return t==="indeterminate"}P5(w5,"isIndeterminate");function E7e(t){return w5(t)?"indeterminate":t?"checked":"unchecked"}P5(E7e,"getState");const JY=X.forwardRef(({className:t,...e},n)=>Y.jsx(RGt,{ref:n,className:Ei("rf-peer rf-h-4 rf-w-4 rf-shrink-0 rf-rounded-sm rf-border rf-border-zinc-200 rf-border-zinc-900 rf-shadow focus-visible:rf-outline-none focus-visible:rf-ring-1 focus-visible:rf-ring-zinc-950 disabled:rf-cursor-not-allowed disabled:rf-opacity-50 data-[state=checked]:rf-bg-zinc-900 data-[state=checked]:rf-text-zinc-50 dark:rf-border-zinc-800 dark:rf-border-zinc-50 dark:focus-visible:rf-ring-zinc-300 dark:data-[state=checked]:rf-bg-zinc-50 dark:data-[state=checked]:rf-text-zinc-900",t),...e,children:Y.jsx(gjo,{className:Ei("rf-flex rf-items-center rf-justify-center rf-text-current"),children:Y.jsx(YP,{className:"rf-h-4 rf-w-4"})})}));JY.displayName=RGt.displayName;const $6=c7e,hjo=l7e,kGt=X.forwardRef(({className:t,...e},n)=>Y.jsx(pae,{className:Ei("rf-fixed rf-inset-0 rf-z-50 rf-bg-black/80 data-[state=open]:rf-animate-in data-[state=closed]:rf-animate-out data-[state=closed]:rf-fade-out-0 data-[state=open]:rf-fade-in-0",t),...e,ref:n}));kGt.displayName=pae.displayName;const ow=X.forwardRef(({className:t,children:e,showOverlay:n=!0,...o},i)=>Y.jsxs(hjo,{children:[Y.jsx(kGt,{className:Ei(n?"":"rf-hidden")}),Y.jsx(Iae,{ref:i,className:Ei("rf-fixed rf-left-[50%] rf-top-[50%] rf-z-50 rf-grid rf-w-full rf-max-w-lg rf-translate-x-[-50%] rf-translate-y-[-50%] rf-gap-4 rf-border rf-border-zinc-200 rf-bg-white rf-p-6 rf-shadow-lg rf-duration-200 data-[state=open]:rf-animate-in data-[state=closed]:rf-animate-out data-[state=closed]:rf-fade-out-0 data-[state=open]:rf-fade-in-0 data-[state=closed]:rf-zoom-out-95 data-[state=open]:rf-zoom-in-95 data-[state=closed]:rf-slide-out-to-left-1/2 data-[state=closed]:rf-slide-out-to-top-[48%] data-[state=open]:rf-slide-in-from-left-1/2 data-[state=open]:rf-slide-in-from-top-[48%] sm:rf-rounded-lg dark:rf-border-zinc-800 dark:rf-bg-zinc-950",t),...o,children:e})]}));ow.displayName=Iae.displayName;const iw=({className:t,...e})=>Y.jsx("div",{className:Ei("rf-flex rf-flex-col rf-space-y-2 rf-text-center sm:rf-text-left",t),...e});iw.displayName="DialogHeader";const Uk=({className:t,...e})=>Y.jsx("div",{className:Ei("rf-flex rf-flex-col-reverse sm:rf-flex-row sm:rf-justify-end sm:rf-space-x-2",t),...e});Uk.displayName="DialogFooter";const rw=X.forwardRef(({className:t,...e},n)=>Y.jsx(u7e,{ref:n,className:Ei("rf-text-lg rf-font-semibold",t),...e}));rw.displayName=u7e.displayName;const Z6=X.forwardRef(({className:t,...e},n)=>Y.jsx(d7e,{ref:n,className:Ei("rf-text-sm rf-text-zinc-500 dark:rf-text-zinc-400",t),...e}));Z6.displayName=d7e.displayName;const Cae={"tscircuit.com":{label:"tscircuit.com",placeholder:"Search tscircuit packages...",emptyMessage:"No packages found"},jlcpcb:{label:"JLCPCB Parts",placeholder:"Search JLCPCB parts (e.g. C14663)...",emptyMessage:"No parts found"},kicad:{label:"KiCad Footprints",placeholder:"Search KiCad footprints...",emptyMessage:"No footprints found"}},_jo="https://cdn.jsdelivr.net/npm/easyeda@latest/dist/browser/index.js";let x7e=null;const B7e=async()=>(x7e||(x7e=import(_jo)),x7e),mjo=t=>(e,n)=>{const o=new Headers(n?.headers),i={};return o.forEach((r,s)=>{i[s]=r}),fetch(`${t?.apiBase??Hf}/proxy`,{...n,headers:{...i,"X-Target-Url":e.toString(),"X-Sender-Origin":i.origin??"","X-Sender-Host":i.host??"https://easyeda.com","X-Sender-Referer":i.referer??"","X-Sender-User-Agent":i["user-agent"]??"","X-Sender-Cookie":i.cookie??"",authority:i.authority??"","content-type":i["content-type"]??"",...t?.headers}})},pjo=async(t,e=10)=>{const n=encodeURIComponent(t),o=await fetch(`https://jlcsearch.tscircuit.com/api/search?limit=${e}&q=${n}`);if(!o.ok)throw new Error(`JLCPCB API error: ${o.status}`);return(await o.json()).components??[]},Ijo=t=>({lcscId:t.lcsc,manufacturer:t.mfr,description:t.description,partNumber:`C${t.lcsc}`,package:t.package,price:t.price,stock:t.stock,isBasic:t.is_basic}),FGt=async(t,e)=>{const{fetchEasyEDAComponent:n}=await B7e();return n(t,{fetch:mjo(e),includeModelMetadata:e?.includeModelMetadata})},fjo=async(t,e)=>{const{convertRawEasyToTsx:n}=await B7e(),o=await FGt(t,e);return n({rawEasy:o})},Cjo=async(t,e)=>{const{EasyEdaJsonSchema:n,convertEasyEdaJsonToCircuitJson:o}=await B7e(),i=await FGt(t,{...e,includeModelMetadata:!1}),r=n.parse(i);return o(r,{shouldRecenter:!0,showDesignator:!0,useModelCdn:!1})};function sw(t){return Array.isArray?Array.isArray(t):HGt(t)==="[object Array]"}function yjo(t){if(typeof t=="string")return t;if(typeof t=="bigint")return t.toString();const e=t+"";return e=="0"&&1/t==-1/0?"-0":e}function Q7e(t){return t==null?"":yjo(t)}function Wf(t){return typeof t=="string"}function yae(t){return typeof t=="number"}function Ejo(t){return t===!0||t===!1||xjo(t)&&HGt(t)=="[object Boolean]"}function LGt(t){return typeof t=="object"}function xjo(t){return LGt(t)&&t!==null}function cE(t){return t!=null}function Eae(t){return!t.trim().length}function HGt(t){return t==null?t===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(t)}const Bjo="Incorrect 'index' type",S7e="Invalid doc index: must be a non-negative integer within the bounds of the docs array",Qjo=t=>`Invalid value for key ${t}`,Sjo=t=>`Pattern length exceeds max of ${t}.`,bjo=t=>`Missing ${t} property in key`,Djo=t=>`Property 'weight' in key '${t}' must be a positive integer`,vjo="Fuse.match does not support useTokenSearch: token search requires corpus-level statistics (df, fieldCount) that a one-off string comparison does not have. Use new Fuse(...).search(...) instead.",GGt=Object.prototype.hasOwnProperty;var Pjo=class{constructor(t){this._keys=[],this._keyMap={};let e=0;t.forEach(n=>{const o=OGt(n);this._keys.push(o),this._keyMap[o.id]=o,e+=o.weight}),this._keys.forEach(n=>{n.weight/=e})}get(t){return this._keyMap[t]}keys(){return this._keys}toJSON(){return JSON.stringify(this._keys)}};function OGt(t){let e=null,n=null,o=null,i=1,r=null;if(Wf(t)||sw(t))o=t,e=KGt(t),n=xae(t);else{if(!GGt.call(t,"name"))throw new Error(bjo("name"));const s=t.name;if(o=s,GGt.call(t,"weight")&&t.weight!==void 0&&(i=t.weight,i<=0))throw new Error(Djo(xae(s)));e=KGt(s),n=xae(s),r=t.getFn??null}return{path:e,id:n,weight:i,src:o,getFn:r}}function KGt(t){return sw(t)?t:t.split(".")}function xae(t){return sw(t)?t.join("."):t}function wjo(t,e){const n=[];let o=!1;const i=(r,s,a,A)=>{if(cE(r))if(!s[a])n.push(A!==void 0?{v:r,i:A}:r);else{const c=r[s[a]];if(!cE(c))return;if(a===s.length-1&&(Wf(c)||yae(c)||Ejo(c)||typeof c=="bigint"))n.push(A!==void 0?{v:Q7e(c),i:A}:Q7e(c));else if(sw(c)){o=!0;for(let l=0,g=c.length;l<g;l+=1)i(c[l],s,a+1,l)}else s.length&&i(c,s,a+1,A)}};return i(t,Wf(e)?e.split("."):e,0),o?n:n[0]}const Ts=Object.freeze({...{isCaseSensitive:!1,ignoreDiacritics:!1,includeScore:!1,keys:[],shouldSort:!0,sortFn:(t,e)=>t.score===e.score?t.idx<e.idx?-1:1:t.score<e.score?-1:1},...{includeMatches:!1,findAllMatches:!1,minMatchCharLength:1},...{location:0,threshold:.6,distance:100},...{useExtendedSearch:!1,useTokenSearch:!1,tokenize:void 0,tokenMatch:"any",getFn:wjo,ignoreLocation:!1,ignoreFieldNorm:!1,fieldNormWeight:1}});function Mjo(t){return t>=9&&t<=13||t===32||t===160}function Njo(t=1,e=3){const n=new Map,o=Math.pow(10,e);return{get(i){let r=0,s=!1;for(let A=0;A<i.length;A++)Mjo(i.charCodeAt(A))?s=!1:s||(r++,s=!0);if(r===0&&(r=1),n.has(r))return n.get(r);const a=Math.round(o/Math.pow(r,.5*t))/o;return n.set(r,a),a},clear(){n.clear()}}}var b7e=class{constructor({getFn:t=Ts.getFn,fieldNormWeight:e=Ts.fieldNormWeight}={}){this.norm=Njo(e,3),this.getFn=t,this.isCreated=!1,this.docs=[],this.keys=[],this._keysMap={},this.setIndexRecords()}setSources(t=[]){this.docs=t}setIndexRecords(t=[]){this.records=t}setKeys(t=[]){this.keys=t,this._keysMap={},t.forEach((e,n)=>{this._keysMap[e.id]=n})}create(){if(this.isCreated||!this.docs.length)return;this.isCreated=!0;const t=this.docs.length;this.records=new Array(t);let e=0;if(Wf(this.docs[0]))for(let n=0;n<t;n++){const o=this._createStringRecord(this.docs[n],n);o&&(this.records[e++]=o)}else for(let n=0;n<t;n++)this.records[e++]=this._createObjectRecord(this.docs[n],n);this.records.length=e,this.norm.clear()}add(t,e){if(!Number.isInteger(e)||e<0)throw new Error(S7e);if(Wf(t)){const o=this._createStringRecord(t,e);return o&&this.records.push(o),o}const n=this._createObjectRecord(t,e);return this.records.push(n),n}removeAt(t){if(!Number.isInteger(t)||t<0)throw new Error(S7e);for(let e=0,n=this.records.length;e<n;e+=1)if(this.records[e].i===t){this.records.splice(e,1);break}for(let e=0,n=this.records.length;e<n;e+=1)this.records[e].i>t&&(this.records[e].i-=1)}removeAll(t){const e=new Set;for(const o of t)Number.isInteger(o)&&o>=0&&e.add(o);if(e.size===0)return;this.records=this.records.filter(o=>!e.has(o.i));const n=Array.from(e).sort((o,i)=>o-i);for(const o of this.records){let i=0,r=n.length;for(;i<r;){const s=i+r>>>1;n[s]<o.i?i=s+1:r=s}o.i-=i}}getValueForItemAtKeyId(t,e){return t[this._keysMap[e]]}size(){return this.records.length}_createStringRecord(t,e){return!cE(t)||Eae(t)?null:{v:t,i:e,n:this.norm.get(t)}}_createObjectRecord(t,e){const n={i:e,$:{}};for(let o=0,i=this.keys.length;o<i;o++){const r=this.keys[o],s=r.getFn?r.getFn(t):this.getFn(t,r.path);if(cE(s)){if(sw(s)){const a=[];for(let A=0,c=s.length;A<c;A+=1){const l=s[A];if(cE(l)){if(Wf(l)){if(!Eae(l)){const g={v:l,i:A,n:this.norm.get(l)};a.push(g)}}else if(cE(l.v)){const g=Wf(l.v)?l.v:Q7e(l.v);if(!Eae(g)){const u={v:g,i:l.i,n:this.norm.get(g)};a.push(u)}}}}n.$[o]=a}else if(Wf(s)&&!Eae(s)){const a={v:s,n:this.norm.get(s)};n.$[o]=a}}}return n}toJSON(){return{keys:this.keys.map(({getFn:t,...e})=>e),records:this.records}}};function UGt(t,e,{getFn:n=Ts.getFn,fieldNormWeight:o=Ts.fieldNormWeight}={}){const i=new b7e({getFn:n,fieldNormWeight:o});return i.setKeys(t.map(OGt)),i.setSources(e),i.create(),i}function Rjo(t,{getFn:e=Ts.getFn,fieldNormWeight:n=Ts.fieldNormWeight}={}){const{keys:o,records:i}=t,r=new b7e({getFn:e,fieldNormWeight:n});return r.setKeys(o),r.setIndexRecords(i),r}function Tjo(t=[],e=Ts.minMatchCharLength){const n=[];let o=-1,i=-1,r=0;for(let s=t.length;r<s;r+=1){const a=t[r];a&&o===-1?o=r:!a&&o!==-1&&(i=r-1,i-o+1>=e&&n.push([o,i]),o=-1)}return t[r-1]&&r-o>=e&&n.push([o,r-1]),n}function kjo(t,e,n,{location:o=Ts.location,distance:i=Ts.distance,threshold:r=Ts.threshold,findAllMatches:s=Ts.findAllMatches,minMatchCharLength:a=Ts.minMatchCharLength,includeMatches:A=Ts.includeMatches,ignoreLocation:c=Ts.ignoreLocation}={}){if(e.length>32)throw new Error(Sjo(32));const l=e.length,g=t.length,u=Math.max(0,Math.min(o,g));let h=r,d=u;const _=(b,D)=>{const R=b/l;if(c)return R;const M=Math.abs(u-D);return i?R+M/i:M?1:R},m=a>1||A,p=m?Array(g):[];let I;for(;(I=t.indexOf(e,d))>-1;){const b=_(0,I);if(h=Math.min(b,h),d=I+l,m){let D=0;for(;D<l;)p[I+D]=1,D+=1}}d=-1;let f=[],C=1,y=0,E=l+g;const B=1<<l-1;for(let b=0;b<l;b+=1){let D=0,R=E;for(;D<R;)_(b,u+R)<=h?D=R:E=R,R=Math.floor((E-D)/2+D);E=R;let M=Math.max(1,u-R+1);const L=s?g:Math.min(u+R,g)+l,G=Array(L+2);G[L+1]=(1<<b)-1;for(let O=L;O>=M;O-=1){const U=O-1,W=n[t[U]];if(G[O]=(G[O+1]<<1|1)&W,b&&(G[O]|=(f[O+1]|f[O])<<1|1|f[O+1]),G[O]&B&&(C=_(b,U),C<=h)){if(h=C,d=U,y=b,d<=u)break;M=Math.max(1,2*u-d)}}if(_(b+1,u)>h)break;f=G}if(m&&d>=0){const b=Math.min(g-1,d+l-1+y);for(let D=d;D<=b;D+=1)n[t[D]]&&(p[D]=1)}const Q={isMatch:d>=0,score:Math.max(.001,C)};if(m){const b=Tjo(p,a);b.length?A&&(Q.indices=b):Q.isMatch=!1}return Q}function Fjo(t){const e={};for(let n=0,o=t.length;n<o;n+=1){const i=t.charAt(n);e[i]=(e[i]||0)|1<<o-n-1}return e}function D7e(t){if(t.length<=1)return t;t.sort((n,o)=>n[0]-o[0]||n[1]-o[1]);const e=[t[0]];for(let n=1,o=t.length;n<o;n+=1){const i=e[e.length-1],r=t[n];r[0]<=i[1]+1?i[1]=Math.max(i[1],r[1]):e.push(r)}return e}const YGt={ł:"l",Ł:"L",đ:"d",Đ:"D",ø:"o",Ø:"O",ħ:"h",Ħ:"H",ŧ:"t",Ŧ:"T",ı:"i",ß:"ss"},Ljo=new RegExp("["+Object.keys(YGt).join("")+"]","g"),qY=typeof String.prototype.normalize=="function"?t=>t.normalize("NFD").replace(/[\u0300-\u036F\u0483-\u0489\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u0610-\u061A\u064B-\u065F\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED\u0711\u0730-\u074A\u07A6-\u07B0\u07EB-\u07F3\u07FD\u0816-\u0819\u081B-\u0823\u0825-\u0827\u0829-\u082D\u0859-\u085B\u08D3-\u08E1\u08E3-\u0903\u093A-\u093C\u093E-\u094F\u0951-\u0957\u0962\u0963\u0981-\u0983\u09BC\u09BE-\u09C4\u09C7\u09C8\u09CB-\u09CD\u09D7\u09E2\u09E3\u09FE\u0A01-\u0A03\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A70\u0A71\u0A75\u0A81-\u0A83\u0ABC\u0ABE-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AE2\u0AE3\u0AFA-\u0AFF\u0B01-\u0B03\u0B3C\u0B3E-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B62\u0B63\u0B82\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD7\u0C00-\u0C04\u0C3E-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C62\u0C63\u0C81-\u0C83\u0CBC\u0CBE-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CE2\u0CE3\u0D00-\u0D03\u0D3B\u0D3C\u0D3E-\u0D44\u0D46-\u0D48\u0D4A-\u0D4D\u0D57\u0D62\u0D63\u0D82\u0D83\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DF2\u0DF3\u0E31\u0E34-\u0E3A\u0E47-\u0E4E\u0EB1\u0EB4-\u0EB9\u0EBB\u0EBC\u0EC8-\u0ECD\u0F18\u0F19\u0F35\u0F37\u0F39\u0F3E\u0F3F\u0F71-\u0F84\u0F86\u0F87\u0F8D-\u0F97\u0F99-\u0FBC\u0FC6\u102B-\u103E\u1056-\u1059\u105E-\u1060\u1062-\u1064\u1067-\u106D\u1071-\u1074\u1082-\u108D\u108F\u109A-\u109D\u135D-\u135F\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17B4-\u17D3\u17DD\u180B-\u180D\u1885\u1886\u18A9\u1920-\u192B\u1930-\u193B\u1A17-\u1A1B\u1A55-\u1A5E\u1A60-\u1A7C\u1A7F\u1AB0-\u1ABE\u1B00-\u1B04\u1B34-\u1B44\u1B6B-\u1B73\u1B80-\u1B82\u1BA1-\u1BAD\u1BE6-\u1BF3\u1C24-\u1C37\u1CD0-\u1CD2\u1CD4-\u1CE8\u1CED\u1CF2-\u1CF4\u1CF7-\u1CF9\u1DC0-\u1DF9\u1DFB-\u1DFF\u20D0-\u20F0\u2CEF-\u2CF1\u2D7F\u2DE0-\u2DFF\u302A-\u302F\u3099\u309A\uA66F-\uA672\uA674-\uA67D\uA69E\uA69F\uA6F0\uA6F1\uA802\uA806\uA80B\uA823-\uA827\uA880\uA881\uA8B4-\uA8C5\uA8E0-\uA8F1\uA8FF\uA926-\uA92D\uA947-\uA953\uA980-\uA983\uA9B3-\uA9C0\uA9E5\uAA29-\uAA36\uAA43\uAA4C\uAA4D\uAA7B-\uAA7D\uAAB0\uAAB2-\uAAB4\uAAB7\uAAB8\uAABE\uAABF\uAAC1\uAAEB-\uAAEF\uAAF5\uAAF6\uABE3-\uABEA\uABEC\uABED\uFB1E\uFE00-\uFE0F\uFE20-\uFE2F]/g,"").replace(Ljo,e=>YGt[e]):t=>t;var v7e=class{constructor(t,{location:e=Ts.location,threshold:n=Ts.threshold,distance:o=Ts.distance,includeMatches:i=Ts.includeMatches,findAllMatches:r=Ts.findAllMatches,minMatchCharLength:s=Ts.minMatchCharLength,isCaseSensitive:a=Ts.isCaseSensitive,ignoreDiacritics:A=Ts.ignoreDiacritics,ignoreLocation:c=Ts.ignoreLocation}={}){if(this.options={location:e,threshold:n,distance:o,includeMatches:i,findAllMatches:r,minMatchCharLength:s,isCaseSensitive:a,ignoreDiacritics:A,ignoreLocation:c},t=a?t:t.toLowerCase(),t=A?qY(t):t,this.pattern=t,this.chunks=[],!this.pattern.length)return;const l=(u,h)=>{this.chunks.push({pattern:u,alphabet:Fjo(u),startIndex:h})},g=this.pattern.length;if(g>32){let u=0;const h=g%32,d=g-h;for(;u<d;)l(this.pattern.substr(u,32),u),u+=32;if(h){const _=g-32;l(this.pattern.substr(_),_)}}else l(this.pattern,0)}searchIn(t){const{isCaseSensitive:e,ignoreDiacritics:n,includeMatches:o}=this.options;if(t=e?t:t.toLowerCase(),t=n?qY(t):t,this.pattern===t){if(t.length<this.options.minMatchCharLength)return{isMatch:!1,score:1};const d={isMatch:!0,score:0};return o&&(d.indices=[[0,t.length-1]]),d}const{location:i,distance:r,threshold:s,findAllMatches:a,minMatchCharLength:A,ignoreLocation:c}=this.options,l=[];let g=0,u=!1;this.chunks.forEach(({pattern:d,alphabet:_,startIndex:m})=>{const{isMatch:p,score:I,indices:f}=kjo(t,d,_,{location:i+m,distance:r,threshold:s,findAllMatches:a,minMatchCharLength:A,includeMatches:o,ignoreLocation:c});p&&(u=!0),g+=I,p&&f&&l.push(...f)});const h={isMatch:u,score:u?g/this.chunks.length:1};return u&&o&&(h.indices=D7e(l)),h}};const Hjo=new Set(["fuzzy","include"]);function Gjo(t){return t.startsWith("inverse")}const P7e=[{type:"exact",multiRegex:/^="(.*)"$/,singleRegex:/^=(.*)$/,create:t=>({type:"exact",search(e){const n=e===t;return{isMatch:n,score:n?0:1,indices:[0,t.length-1]}}})},{type:"include",multiRegex:/^'"(.*)"$/,singleRegex:/^'(.*)$/,create:t=>({type:"include",search(e){let n=0,o;const i=[],r=t.length;for(;(o=e.indexOf(t,n))>-1;)n=o+r,i.push([o,n-1]);const s=!!i.length;return{isMatch:s,score:s?0:1,indices:i}}})},{type:"prefix-exact",multiRegex:/^\^"(.*)"$/,singleRegex:/^\^(.*)$/,create:t=>({type:"prefix-exact",search(e){const n=e.startsWith(t);return{isMatch:n,score:n?0:1,indices:[0,t.length-1]}}})},{type:"inverse-prefix-exact",multiRegex:/^!\^"(.*)"$/,singleRegex:/^!\^(.*)$/,create:t=>({type:"inverse-prefix-exact",search(e){const n=!e.startsWith(t);return{isMatch:n,score:n?0:1,indices:[0,e.length-1]}}})},{type:"inverse-suffix-exact",multiRegex:/^!"(.*)"\$$/,singleRegex:/^!(.*)\$$/,create:t=>({type:"inverse-suffix-exact",search(e){const n=!e.endsWith(t);return{isMatch:n,score:n?0:1,indices:[0,e.length-1]}}})},{type:"suffix-exact",multiRegex:/^"(.*)"\$$/,singleRegex:/^(.*)\$$/,create:t=>({type:"suffix-exact",search(e){const n=e.endsWith(t);return{isMatch:n,score:n?0:1,indices:[e.length-t.length,e.length-1]}}})},{type:"inverse-exact",multiRegex:/^!"(.*)"$/,singleRegex:/^!(.*)$/,create:t=>({type:"inverse-exact",search(e){const n=e.indexOf(t)===-1;return{isMatch:n,score:n?0:1,indices:[0,e.length-1]}}})},{type:"fuzzy",multiRegex:/^"(.*)"$/,singleRegex:/^(.*)$/,create:(t,e={})=>{const n=new v7e(t,{location:e.location??Ts.location,threshold:e.threshold??Ts.threshold,distance:e.distance??Ts.distance,includeMatches:e.includeMatches??Ts.includeMatches,findAllMatches:e.findAllMatches??Ts.findAllMatches,minMatchCharLength:e.minMatchCharLength??Ts.minMatchCharLength,isCaseSensitive:e.isCaseSensitive??Ts.isCaseSensitive,ignoreDiacritics:e.ignoreDiacritics??Ts.ignoreDiacritics,ignoreLocation:e.ignoreLocation??Ts.ignoreLocation});return{type:"fuzzy",search(o){return n.searchIn(o)}}}}],zGt=P7e.length,Ojo="\0",Kjo="|";function Ujo(t){const e=[],n=t.length;let o=0;for(;o<n;){for(;o<n&&t[o]===" ";)o++;if(o>=n)break;let i=o;for(;i<n&&t[i]!==" "&&t[i]!=='"';)i++;if(i<n&&t[i]==='"'){for(i++;i<n;){if(t[i]==='"'){const r=i+1;if(r>=n||t[r]===" "){i++;break}if(t[r]==="$"&&(r+1>=n||t[r+1]===" ")){i+=2;break}}i++}e.push(t.substring(o,i)),o=i}else{for(;i<n&&t[i]!==" ";)i++;e.push(t.substring(o,i)),o=i}}return e}function VGt(t,e){const n=t.match(e);return n?n[1]:null}function Yjo(t,e={}){return t.replace(/\\\|/g,Ojo).split(Kjo).map(n=>{const o=Ujo(n.replace(/\u0000/g,"|").trim()).filter(r=>r&&!!r.trim()),i=[];for(let r=0,s=o.length;r<s;r+=1){const a=o[r];let A=!1,c=-1;for(;!A&&++c<zGt;){const l=P7e[c],g=VGt(a,l.multiRegex);g&&(i.push(l.create(g,e)),A=!0)}if(!A)for(c=-1;++c<zGt;){const l=P7e[c],g=VGt(a,l.singleRegex);if(g){i.push(l.create(g,e));break}}}return i})}var zjo=class{constructor(t,{isCaseSensitive:e=Ts.isCaseSensitive,ignoreDiacritics:n=Ts.ignoreDiacritics,includeMatches:o=Ts.includeMatches,minMatchCharLength:i=Ts.minMatchCharLength,ignoreLocation:r=Ts.ignoreLocation,findAllMatches:s=Ts.findAllMatches,location:a=Ts.location,threshold:A=Ts.threshold,distance:c=Ts.distance}={}){this.query=null,this.options={isCaseSensitive:e,ignoreDiacritics:n,includeMatches:o,minMatchCharLength:i,findAllMatches:s,ignoreLocation:r,location:a,threshold:A,distance:c},t=e?t:t.toLowerCase(),t=n?qY(t):t,this.pattern=t,this.query=Yjo(this.pattern,this.options)}static condition(t,e){return e.useExtendedSearch}searchIn(t){const e=this.query;if(!e)return{isMatch:!1,score:1};const{includeMatches:n,isCaseSensitive:o,ignoreDiacritics:i}=this.options;t=o?t:t.toLowerCase(),t=i?qY(t):t;let r=0;const s=[];let a=0,A=!1;for(let c=0,l=e.length;c<l;c+=1){const g=e[c];s.length=0,r=0,A=!1;for(let u=0,h=g.length;u<h;u+=1){const d=g[u],{isMatch:_,indices:m,score:p}=d.search(t);if(_)r+=1,a+=p,Gjo(d.type)&&(A=!0),n&&(Hjo.has(d.type)?s.push(...m):s.push(m));else{a=0,r=0,s.length=0,A=!1;break}}if(r){const u={isMatch:!0,score:a/r};return A&&(u.hasInverse=!0),n&&(u.indices=D7e(s)),u}}return{isMatch:!1,score:1}}};const w7e=[];function M7e(...t){w7e.push(...t)}function Bae(t,e){for(let n=0,o=w7e.length;n<o;n+=1){const i=w7e[n];if(i.condition(t,e))return new i(t,e)}return new v7e(t,e)}const Qae={AND:"$and",OR:"$or"},N7e={PATH:"$path",PATTERN:"$val"},R7e=t=>!!(t[Qae.AND]||t[Qae.OR]),Vjo=t=>!!t[N7e.PATH],Jjo=t=>!sw(t)&&LGt(t)&&!R7e(t),JGt=t=>({[Qae.AND]:Object.keys(t).map(e=>({[e]:t[e]}))});function qGt(t,e,{auto:n=!0}={}){const o=i=>{if(Wf(i)){const A={keyId:null,pattern:i};return n&&(A.searcher=Bae(i,e)),A}const r=Object.keys(i),s=Vjo(i);if(!s&&r.length>1&&!R7e(i))return o(JGt(i));if(Jjo(i)){const A=s?i[N7e.PATH]:r[0],c=s?i[N7e.PATTERN]:i[A];if(!Wf(c))throw new Error(Qjo(A));const l={keyId:xae(A),pattern:c};return n&&(l.searcher=Bae(c,e)),l}const a={children:[],operator:r[0]};return r.forEach(A=>{const c=i[A];sw(c)&&c.forEach(l=>{a.children.push(o(l))})}),a};return R7e(t)||(t=JGt(t)),o(t)}function T7e(t,{ignoreFieldNorm:e=Ts.ignoreFieldNorm}){let n=1;return t.forEach(({key:o,norm:i,score:r})=>{const s=o?o.weight:null;n*=Math.pow(r===0&&s?Number.EPSILON:r,(s||1)*(e?1:i))}),n}function qjo(t,{ignoreFieldNorm:e=Ts.ignoreFieldNorm}){t.forEach(n=>{n.score=T7e(n.matches,{ignoreFieldNorm:e})})}var Wjo=class{constructor(t,e){this.limit=t,this.heap=[],this.comparator=e}get size(){return this.heap.length}insert(t){this.size<this.limit?(this.heap.push(t),this._bubbleUp(this.size-1)):this.comparator(t,this.heap[0])<0&&(this.heap[0]=t,this._sinkDown(0))}extractSorted(){return this.heap.sort(this.comparator)}_bubbleUp(t){const e=this.heap;for(;t>0;){const n=t-1>>1;if(this.comparator(e[t],e[n])<=0)break;const o=e[t];e[t]=e[n],e[n]=o,t=n}}_sinkDown(t){const e=this.heap,n=e.length;let o=t;do{t=o;const i=2*t+1,r=2*t+2;if(i<n&&this.comparator(e[i],e[o])>0&&(o=i),r<n&&this.comparator(e[r],e[o])>0&&(o=r),o!==t){const s=e[t];e[t]=e[o],e[o]=s}}while(o!==t)}};function jjo(t){const e=[];return t.matches.forEach(n=>{if(!cE(n.indices)||!n.indices.length)return;const o={indices:n.indices,value:n.value};n.key&&(o.key=n.key.id),n.idx>-1&&(o.refIndex=n.idx),e.push(o)}),e}function Xjo(t,e,{includeMatches:n=Ts.includeMatches,includeScore:o=Ts.includeScore}={}){return t.map(i=>{const{idx:r}=i,s={item:e[r],refIndex:r};return n&&(s.matches=jjo(i)),o&&(s.score=i.score),s})}const $jo=/[\p{L}\p{M}\p{N}_]+/gu,WGt=new WeakSet;function Zjo(t){WGt.has(t)||(WGt.add(t),console.warn(`[Fuse] tokenize regex ${t} lacks the global flag; only the first match per text will be returned. Add the 'g' flag.`))}function eXo(t){if(typeof t=="function"){let e=!1;return n=>{const o=t(n);if(!e&&(e=!0,!Array.isArray(o)||o.some(i=>typeof i!="string")))throw new Error(`[Fuse] tokenize function must return string[]; received ${Array.isArray(o)?"array containing non-strings":typeof o}.`);return o}}return t instanceof RegExp?(t.global||Zjo(t),e=>e.match(t)||[]):e=>e.match($jo)||[]}function k7e({isCaseSensitive:t=!1,ignoreDiacritics:e=!1,tokenize:n}={}){const o=eXo(n);return{tokenize(i){return t||(i=i.toLowerCase()),e&&(i=qY(i)),o(i)}}}var tXo=class{static condition(t,e){return e.useTokenSearch}constructor(t,e){this.options=e,this.analyzer=k7e({isCaseSensitive:e.isCaseSensitive,ignoreDiacritics:e.ignoreDiacritics,tokenize:e.tokenize});const n=this.analyzer.tokenize(t),{df:o,fieldCount:i}=e._invertedIndex;this.termSearchers=[],this.idfWeights=[];for(const r of n){this.termSearchers.push(new v7e(r,{location:e.location,threshold:e.threshold,distance:e.distance,includeMatches:e.includeMatches,findAllMatches:e.findAllMatches,minMatchCharLength:e.minMatchCharLength,isCaseSensitive:e.isCaseSensitive,ignoreDiacritics:e.ignoreDiacritics,ignoreLocation:!0}));const s=o.get(r)||0,a=Math.log(1+(i-s+.5)/(s+.5));this.idfWeights.push(a)}this.combineAll=e.tokenMatch==="all",this.numTerms=this.termSearchers.length,this.useMask=this.numTerms<=31}searchIn(t){if(!this.termSearchers.length)return{isMatch:!1,score:1};const e=[];let n=0,o=0,i=0,r=0;const s=this.combineAll&&!this.useMask?new Set:null;for(let c=0;c<this.termSearchers.length;c++){const l=this.termSearchers[c].searchIn(t),g=this.idfWeights[c];o+=g,l.isMatch&&(i++,n+=g*(1-l.score),l.indices&&e.push(...l.indices),this.combineAll&&(this.useMask?r|=1<<c:s.add(c)))}if(i===0)return{isMatch:!1,score:1};const a=o>0?1-n/o:0,A={isMatch:!0,score:Math.max(.001,a)};return this.options.includeMatches&&e.length&&(A.indices=D7e(e)),this.combineAll&&(this.useMask?A.matchedMask=r:A.matchedTerms=s,A.termCount=this.numTerms),A}};function F7e(t,e,n,o){const i=o.tokenize(e);if(!i.length)return;t.fieldCount++,t.docFieldCount.set(n,(t.docFieldCount.get(n)||0)+1);const r=new Set(i);let s=t.docTermFieldHits.get(n);s||(s=new Map,t.docTermFieldHits.set(n,s));for(const a of r)s.set(a,(s.get(a)||0)+1),t.df.set(a,(t.df.get(a)||0)+1)}function jGt(t,e,n,o){const{i,v:r,$:s}=e;if(r!==void 0){F7e(t,r,i,o);return}if(s)for(let a=0;a<n;a++){const A=s[a];if(A)if(Array.isArray(A))for(const c of A)F7e(t,c.v,i,o);else F7e(t,A.v,i,o)}}function nXo(t,e,n){const o={fieldCount:0,df:new Map,docFieldCount:new Map,docTermFieldHits:new Map};for(const i of t)jGt(o,i,e,n);return o}function oXo(t,e,n,o){jGt(t,e,n,o)}function iXo(t,e){const n=t.docFieldCount.get(e);if(n===void 0)return;t.fieldCount-=n,t.docFieldCount.delete(e);const o=t.docTermFieldHits.get(e);if(o){for(const[i,r]of o){const s=(t.df.get(i)||0)-r;s<=0?t.df.delete(i):t.df.set(i,s)}t.docTermFieldHits.delete(e)}}function XGt(t,e){if(e.length===0)return;const n=Array.from(new Set(e)).sort((a,A)=>a-A);for(const a of n)iXo(t,a);const o=a=>{let A=0,c=n.length;for(;A<c;){const l=A+c>>>1;n[l]<a?A=l+1:c=l}return a-A},i=n[0],r=new Map;for(const[a,A]of t.docFieldCount)r.set(a>i?o(a):a,A);t.docFieldCount=r;const s=new Map;for(const[a,A]of t.docTermFieldHits)s.set(a>i?o(a):a,A);t.docTermFieldHits=s}var aw=class{constructor(t,e,n){this.options={...Ts,...e},this.options.useExtendedSearch,this.options.useTokenSearch,this._keyStore=new Pjo(this.options.keys),this._docs=t,this._myIndex=null,this._invertedIndex=null,this.setCollection(t,n),this._lastQuery=null,this._lastSearcher=null}_getSearcher(t){if(this._lastQuery===t)return this._lastSearcher;const e=Bae(t,this._invertedIndex?{...this.options,_invertedIndex:this._invertedIndex}:this.options);return this._lastQuery=t,this._lastSearcher=e,e}setCollection(t,e){if(this._docs=t,e&&!(e instanceof b7e))throw new Error(Bjo);if(this._myIndex=e||UGt(this.options.keys,this._docs,{getFn:this.options.getFn,fieldNormWeight:this.options.fieldNormWeight}),this.options.useTokenSearch){const n=k7e({isCaseSensitive:this.options.isCaseSensitive,ignoreDiacritics:this.options.ignoreDiacritics,tokenize:this.options.tokenize});this._invertedIndex=nXo(this._myIndex.records,this._myIndex.keys.length,n)}this._invalidateSearcherCache()}add(t){if(!cE(t))return;this._docs.push(t);const e=this._myIndex.add(t,this._docs.length-1);if(this._invertedIndex&&e){const n=k7e({isCaseSensitive:this.options.isCaseSensitive,ignoreDiacritics:this.options.ignoreDiacritics,tokenize:this.options.tokenize});oXo(this._invertedIndex,e,this._myIndex.keys.length,n)}this._invalidateSearcherCache()}remove(t=()=>!1){const e=[],n=[];for(let o=0,i=this._docs.length;o<i;o+=1)t(this._docs[o],o)&&(e.push(this._docs[o]),n.push(o));if(n.length){this._invertedIndex&&XGt(this._invertedIndex,n);const o=new Set(n);this._docs=this._docs.filter((i,r)=>!o.has(r)),this._myIndex.removeAll(n),this._invalidateSearcherCache()}return e}removeAt(t){if(!Number.isInteger(t)||t<0||t>=this._docs.length)throw new Error(S7e);this._invertedIndex&&XGt(this._invertedIndex,[t]);const e=this._docs.splice(t,1)[0];return this._myIndex.removeAt(t),this._invalidateSearcherCache(),e}_invalidateSearcherCache(){this._lastQuery=null,this._lastSearcher=null}getIndex(){return this._myIndex}_normalizedKeys(){return this._myIndex.keys.map(t=>this._keyStore.get(t.id)||t)}search(t,e){const{limit:n=-1}=e||{},{includeMatches:o,includeScore:i,shouldSort:r,sortFn:s,ignoreFieldNorm:a}=this.options;if(Wf(t)&&!t.trim()){let u=this._docs.map((h,d)=>({item:h,refIndex:d}));return yae(n)&&n>-1&&(u=u.slice(0,n)),u}const A=r&&yae(n)&&n>0&&Wf(t),c=s,l=(u,h)=>c(u,h)||u.idx-h.idx;let g;if(A){const u=new Wjo(n,l);Wf(this._docs[0])?this._searchStringList(t,{heap:u,ignoreFieldNorm:a}):this._searchObjectList(t,{heap:u,ignoreFieldNorm:a}),g=u.extractSorted()}else g=Wf(t)?Wf(this._docs[0])?this._searchStringList(t):this._searchObjectList(t):this._searchLogical(t),qjo(g,{ignoreFieldNorm:a}),r&&g.sort(Wf(t)?l:c),yae(n)&&n>-1&&(g=g.slice(0,n));return Xjo(g,this._docs,{includeMatches:o,includeScore:i})}_searchStringList(t,{heap:e,ignoreFieldNorm:n}={}){const o=this._getSearcher(t),i=this.options.useTokenSearch&&this.options.tokenMatch==="all",{records:r}=this._myIndex,s=e?null:[];return r.forEach(({v:a,i:A,n:c})=>{if(!cE(a))return;const l=o.searchIn(a);if(l.isMatch){const g={score:l.score,value:a,norm:c,indices:l.indices};i&&(g.matchedMask=l.matchedMask,g.matchedTerms=l.matchedTerms,g.termCount=l.termCount);const u=[g];if(!i||this._coversAllTokens(u)){const h={item:a,idx:A,matches:u};e?(h.score=T7e(h.matches,{ignoreFieldNorm:n}),e.insert(h)):s.push(h)}}}),s}_searchLogical(t){const e=qGt(t,this.options),n=this._normalizedKeys(),o=(a,A,c)=>{if(!("children"in a)){const{keyId:h,searcher:d}=a;let _;return h===null?(_=[],n.forEach((m,p)=>{_.push(...this._findMatches({key:m,value:A[p],searcher:d}))})):_=this._findMatches({key:this._keyStore.get(h),value:this._myIndex.getValueForItemAtKeyId(A,h),searcher:d}),_&&_.length?[{idx:c,item:A,matches:_}]:[]}const{children:l,operator:g}=a,u=[];for(let h=0,d=l.length;h<d;h+=1){const _=l[h],m=o(_,A,c);if(m.length)u.push(...m);else if(g===Qae.AND)return[]}return u},i=this._myIndex.records,r=new Map,s=[];return i.forEach(({$:a,i:A})=>{if(cE(a)){const c=o(e,a,A);c.length&&(r.has(A)||(r.set(A,{idx:A,item:a,matches:[]}),s.push(r.get(A))),c.forEach(({matches:l})=>{r.get(A).matches.push(...l)}))}}),s}_searchObjectList(t,{heap:e,ignoreFieldNorm:n}={}){const o=this._getSearcher(t),i=this.options.useTokenSearch&&this.options.tokenMatch==="all",{records:r}=this._myIndex,s=this._normalizedKeys(),a=e?null:[];return r.forEach(({$:A,i:c})=>{if(!cE(A))return;const l=[];let g=!1,u=!1;if(s.forEach((h,d)=>{const _=this._findMatches({key:h,value:A[d],searcher:o});_.length?(l.push(..._),_[0].hasInverse&&(u=!0)):g=!0}),!(u&&g)&&l.length&&(!i||this._coversAllTokens(l))){const h={idx:c,item:A,matches:l};e?(h.score=T7e(h.matches,{ignoreFieldNorm:n}),e.insert(h)):a.push(h)}}),a}_findMatches({key:t,value:e,searcher:n}){if(!cE(e))return[];const o=[];if(sw(e))e.forEach(({v:i,i:r,n:s})=>{if(!cE(i))return;const a=n.searchIn(i);if(a.isMatch){const A={score:a.score,key:t,value:i,idx:r,norm:s,indices:a.indices,hasInverse:a.hasInverse};a.termCount!==void 0&&(A.matchedMask=a.matchedMask,A.matchedTerms=a.matchedTerms,A.termCount=a.termCount),o.push(A)}});else{const{v:i,n:r}=e,s=n.searchIn(i);if(s.isMatch){const a={score:s.score,key:t,value:i,norm:r,indices:s.indices,hasInverse:s.hasInverse};s.termCount!==void 0&&(a.matchedMask=s.matchedMask,a.matchedTerms=s.matchedTerms,a.termCount=s.termCount),o.push(a)}}return o}_coversAllTokens(t){const e=t.length?t[0].termCount:void 0;if(e===void 0)return!0;if(e<=31){let o=0;for(let i=0;i<t.length;i++)o|=t[i].matchedMask||0;return o===2**e-1}const n=new Set;for(let o=0;o<t.length;o++){const i=t[o].matchedTerms;if(i)for(const r of i)n.add(r)}return n.size===e}};aw.version="7.5.0",aw.createIndex=UGt,aw.parseIndex=Rjo,aw.config=Ts,aw.match=function(t,e,n){if(n&&n.useTokenSearch)throw new Error(vjo);return Bae(t,{...Ts,...n}).searchIn(e)},aw.parseQuery=qGt,M7e(zjo),M7e(tXo),aw.use=function(...t){t.forEach(e=>M7e(e))};var rXo=aw;const sXo="https://kicad-mod-cache.tscircuit.com";let L7e=null,WY=null,H7e=null;const aXo=async()=>L7e||WY||(WY=fetch("https://kicad-mod-cache.tscircuit.com/kicad_files.json").then(t=>t.json()).then(t=>(L7e=t,WY=null,t)),WY),AXo=async(t,e=20)=>{const n=await aXo();return H7e||(H7e=new rXo(n)),H7e.search(t).slice(0,e).map(o=>o.item)},cXo=t=>{const e=t.replace(".pretty/","/").replace(".kicad_mod",""),n=`kicad:${e}`;return{path:t,qualifiedName:n,description:e}},lXo=t=>t.replace(/^\/+/,"").split("/").map(e=>encodeURIComponent(e)).join("/"),gXo=async t=>{const e=await fetch(`${sXo}/${lXo(t)}`);if(!e.ok)throw new Error(`KiCad footprint fetch failed: ${e.status}`);const n=await e.text(),{KicadFootprintToCircuitJsonConverter:o}=await iE("kicad-to-circuit-json"),i=new o;return i.addFile(t.split("/").pop()??"selected-footprint.kicad_mod",n),i.runUntilFinished(),i.getOutput()},$Gt=t=>t?.source==="jlcpcb"||t?.source==="kicad",uXo=async(t,e)=>{if(t.source==="jlcpcb")return Cjo(t.component.partNumber,e?.jlcpcb);if(t.source==="kicad")return gXo(t.footprint.path);throw new Error("Footprint preview is not available for this source")},dXo=({query:t,placeholder:e,isSearching:n,onQueryChange:o,onSubmit:i})=>{const r=X.useCallback(s=>{s.key==="Enter"&&(s.preventDefault(),i())},[i]);return Y.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2 rf-mt-4",children:[Y.jsxs("div",{className:"rf-relative rf-flex-grow",children:[Y.jsx(t8e,{className:"rf-absolute rf-left-2 rf-top-2.5 rf-h-4 rf-w-4 rf-text-muted-foreground"}),Y.jsx(z8e,{placeholder:e,className:"rf-pl-8",spellCheck:!1,autoComplete:"off",value:t,onChange:s=>o(s.target.value),onKeyDown:r})]}),Y.jsx(fa,{onClick:i,disabled:n||t.trim().length<1,className:"sm:rf-px-4 rf-px-3",children:n?Y.jsx(Tx,{className:"rf-h-4 rf-w-4 rf-animate-spin"}):Y.jsxs(Y.Fragment,{children:[Y.jsx(t8e,{className:"rf-h-4 rf-w-4 sm:rf-hidden"}),Y.jsx("span",{className:"rf-hidden sm:rf-inline",children:"Search"})]})})]})},hXo=new Intl.NumberFormat("en-US",{style:"currency",currency:"USD"}),_Xo=t=>hXo.format(t),ZGt=t=>{switch(t.source){case"tscircuit.com":{const e=t.package;return`tscircuit-${e.package_id??`${e.org_owner_tscircuit_handle??"unknown"}-${e.unscoped_name??e.name??"package"}`}`}case"jlcpcb":return`jlc-${t.component.lcscId}`;case"kicad":return`kicad-${t.footprint.path}`;default:return"unknown"}},mXo=t=>{switch(t.source){case"tscircuit.com":return t.package.unscoped_name;case"jlcpcb":return t.component.isDirectLookup?t.component.partNumber:t.component.manufacturer;case"kicad":return t.footprint.qualifiedName}},pXo=t=>{switch(t.source){case"tscircuit.com":return t.package.description||(t.package.org_owner_tscircuit_handle?`Component by ${t.package.org_owner_tscircuit_handle}`:void 0);case"jlcpcb":return t.component.description;case"kicad":return t.footprint.description}},IXo=t=>{switch(t.source){case"tscircuit.com":return t.package.name;case"jlcpcb":return t.component.isDirectLookup?void 0:t.component.partNumber;case"kicad":return}},fXo=({results:t,selected:e,onSelect:n,onShowDetails:o})=>{const i=e?ZGt(e):null;return Y.jsx("div",{className:"rf-divide-y rf-w-full rf-overflow-hidden",children:t.map(r=>{const s=ZGt(r),a=i===s,A=mXo(r),c=pXo(r),l=IXo(r),g=r.source==="jlcpcb"?r.component.stock:null,u=r.source==="jlcpcb"?r.component.price:null,h=r.source==="jlcpcb"?r.component.isBasic:null,d=r.source==="jlcpcb"?r.component.isDirectLookup:!1;return Y.jsxs("div",{className:`rf-p-3 rf-flex rf-flex-col sm:rf-grid sm:rf-grid-cols-[minmax(0,1fr)_auto] rf-items-start sm:rf-items-center rf-cursor-pointer hover:rf-bg-zinc-100 rf-gap-2 rf-overflow-hidden ${a?"rf-bg-zinc-100":""}`,onClick:()=>n(r),children:[Y.jsxs("div",{className:"rf-min-w-0 rf-overflow-hidden rf-w-full",children:[Y.jsxs("div",{className:"rf-flex rf-items-start rf-gap-2 rf-min-w-0",children:[Y.jsxs("div",{className:"rf-font-medium rf-text-sm rf-truncate rf-flex-1 rf-min-w-0 rf-flex rf-items-center rf-gap-1.5",children:[A,r.source==="jlcpcb"&&h!=null&&Y.jsx("span",{className:`rf-text-xs rf-px-1.5 rf-py-0.5 rf-rounded rf-font-medium rf-flex-shrink-0 ${h?"rf-bg-green-100 rf-text-green-700":"rf-bg-orange-100 rf-text-orange-700"}`,children:h?"Basic":"Extended"}),d&&Y.jsx("span",{className:"rf-text-xs rf-px-1.5 rf-py-0.5 rf-rounded rf-font-medium rf-flex-shrink-0 rf-bg-blue-100 rf-text-blue-700",children:"Direct lookup"}),r.source==="tscircuit.com"&&r.package.is_private&&Y.jsx(oLo,{className:"rf-ml-1 rf-h-3 rf-w-3 rf-text-zinc-400 rf-flex-shrink-0"})]}),r.source==="jlcpcb"&&g!=null?Y.jsxs("div",{className:"rf-text-xs rf-text-zinc-500 rf-font-medium rf-whitespace-nowrap rf-flex-shrink-0 sm:rf-hidden",children:[g.toLocaleString()," in stock"]}):null]}),Y.jsxs("div",{className:"rf-text-xs rf-text-zinc-500 rf-truncate rf-w-full",children:[l?Y.jsx("span",{className:"rf-mr-2",children:l}):null,c]})]}),Y.jsxs("div",{children:[r.source==="tscircuit.com"&&o?Y.jsx("div",{className:"rf-flex-shrink-0 rf-w-full sm:rf-w-auto",children:Y.jsx(fa,{variant:"outline",size:"sm",className:"rf-text-xs rf-w-full sm:rf-w-auto",onClick:_=>{_.stopPropagation(),o(r)},children:"See Details"})}):r.source==="jlcpcb"&&g!=null?Y.jsxs("div",{className:"rf-hidden sm:rf-block rf-text-xs rf-text-zinc-500 rf-font-medium rf-whitespace-nowrap rf-flex-shrink-0",children:[g.toLocaleString()," in stock"]}):null,u!=null&&Y.jsx("div",{className:"rf-hidden sm:rf-block rf-text-xs rf-text-zinc-500 rf-font-medium rf-whitespace-nowrap rf-flex-shrink-0 rf-text-right",children:_Xo(u)})]})]},s)})})},CXo=({circuitJson:t,error:e,isLoading:n,height:o})=>Y.jsx("section",{className:"rf-flex rf-min-w-0 rf-items-center rf-justify-center",style:{height:o},children:n?Y.jsxs("div",{className:"rf-flex rf-w-full rf-items-center rf-justify-center rf-gap-2 rf-bg-zinc-950 rf-text-sm rf-text-zinc-300",style:{height:o},children:[Y.jsx(Tx,{className:"rf-h-4 rf-w-4 rf-animate-spin"}),"Loading preview..."]}):e?Y.jsx("div",{className:"rf-flex rf-w-full rf-items-center rf-justify-center rf-bg-zinc-950 rf-p-4",style:{height:o},children:Y.jsxs("div",{className:"rf-flex rf-max-w-[320px] rf-items-start rf-gap-2 rf-text-sm rf-text-zinc-300",children:[Y.jsx(uNt,{className:"rf-mt-0.5 rf-h-4 rf-w-4 rf-flex-shrink-0"}),Y.jsx("span",{children:e})]})}):t?Y.jsx("div",{className:"rf-w-full rf-min-w-0 rf-overflow-hidden",children:Y.jsx(aGt,{circuitJson:t,height:o,allowEditing:!1,clickToInteractEnabled:!1,focusOnHover:!1,disablePcbGroups:!0})}):Y.jsx("div",{className:"rf-flex rf-w-full rf-items-center rf-justify-center rf-bg-zinc-950 rf-text-sm rf-text-zinc-300",style:{height:o},children:"No preview"})}),eOt={importComponentDialog:101,importComponentDetailsDialog:102},yXo=({packageResult:t,isOpen:e,onOpenChange:n,isLoading:o,details:i,previewTab:r,onPreviewTabChange:s,isSubmitting:a,onImport:A})=>{const c=t?.package??null,l=c?.latest_pcb_preview_image_url,g=c?.latest_sch_preview_image_url,u=c?.latest_cad_preview_image_url,h=c?.unscoped_name?.split("/").pop()??c?.unscoped_name,d=c?.org_owner_tscircuit_handle??void 0,_=d?`https://tscircuit.com/${d}`:void 0,m=d&&h?`https://tscircuit.com/${d}/${h}`:void 0;return Y.jsx($6,{open:e,onOpenChange:n,children:Y.jsxs(ow,{showOverlay:!1,style:{width:"calc(100vw - 2rem)",zIndex:eOt.importComponentDetailsDialog},className:"rf-max-w-5xl no-scrollbar !rf-overflow-y-auto rf-max-h-[90vh] rf-overflow-hidden rf-flex rf-flex-col rf-rounded-sm",children:[Y.jsx(iw,{className:"rf-pb-4 rf-border-b",children:Y.jsx("div",{className:"rf-flex rf-items-start rf-justify-between rf-gap-4",children:Y.jsxs("div",{className:"rf-flex-1 rf-min-w-0",children:[Y.jsx(rw,{className:"rf-text-xl rf-font-semibold rf-truncate",children:h}),Y.jsx(Z6,{children:c?.description})]})})}),Y.jsxs("div",{className:"rf-flex-1 rf-overflow-y-auto rf-py-4 rf-space-y-6",children:[d?Y.jsxs("div",{children:[Y.jsx("span",{className:"rf-text-xs rf-font-medium rf-text-gray-500 rf-uppercase rf-tracking-wide",children:"Created by"}),Y.jsx("div",{className:"rf-mt-1 rf-text-sm rf-font-medium",children:_?Y.jsx("a",{href:_,target:"_blank",rel:"noopener noreferrer",className:"rf-text-black hover:rf-underline",children:d}):d})]}):null,(u||l||g)&&Y.jsx(Y.Fragment,{children:Y.jsxs("div",{children:[Y.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-mb-4",children:"Preview"}),Y.jsxs(Nxe,{value:r,onValueChange:p=>s(p),children:[Y.jsxs(kne,{className:"rf-inline-flex rf-h-9 rf-items-center rf-justify-center rf-rounded-lg rf-bg-zinc-100 rf-p-1 rf-text-zinc-500 dark:rf-bg-zinc-800 dark:rf-text-zinc-400",children:[l&&Y.jsx(HS,{value:"pcb",children:"PCB"}),g&&Y.jsx(HS,{value:"schematic",children:"Schematic"}),u&&Y.jsx(HS,{value:"3d",children:"3D"})]}),Y.jsxs("div",{className:"rf-mt-4",children:[Y.jsx(Kf,{value:"pcb",className:"rf-border rf-rounded-lg rf-overflow-hidden rf-bg-gray-50",children:l?Y.jsx("img",{src:l,alt:`${h??"package"} PCB preview`,className:"rf-w-full rf-h-full rf-object-contain rf-bg-white rf-p-4"}):null}),Y.jsx(Kf,{value:"schematic",className:"rf-border rf-rounded-lg rf-overflow-hidden rf-bg-gray-50",children:g?Y.jsx("img",{src:g,alt:`${h??"package"} schematic preview`,className:"rf-w-full rf-h-full rf-object-contain rf-bg-white rf-p-4"}):null}),Y.jsx(Kf,{value:"3d",className:"rf-border rf-rounded-lg rf-overflow-hidden rf-bg-gray-50",children:u?Y.jsx("img",{src:u,alt:`${h??"package"} 3D preview`,className:"rf-w-full rf-h-full rf-object-contain rf-bg-white rf-p-4"}):null})]})]})]})}),i?.ai_description?Y.jsxs("section",{children:[Y.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-mb-3",children:"AI Description"}),Y.jsx("div",{className:"rf-bg-gray-50 rf-border rf-border-gray-200 rf-rounded-lg rf-p-4",children:Y.jsx("p",{className:"rf-text-sm rf-text-gray-700 rf-leading-relaxed",children:i.ai_description})})]}):null,i?.ai_usage_instructions?Y.jsxs("section",{children:[Y.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-mb-3",children:"Usage Instructions"}),Y.jsx("div",{className:"rf-bg-gray-50 rf-border rf-border-gray-200 rf-rounded-lg rf-p-4",children:Y.jsx("p",{className:"rf-text-sm rf-text-gray-700 rf-leading-relaxed rf-whitespace-pre-wrap",children:i.ai_usage_instructions})})]}):null,o?Y.jsxs("div",{className:"rf-flex rf-justify-center rf-items-center rf-gap-2 rf-text-gray-500",children:[Y.jsx(Tx,{className:"rf-h-4 rf-w-4 rf-animate-spin"}),Y.jsx("span",{className:"rf-text-sm",children:"Loading package details..."})]}):null]}),Y.jsxs(Uk,{className:"rf-pt-4 rf-border-t rf-flex rf-flex-col sm:rf-flex-row rf-justify-between rf-gap-2",children:[Y.jsx("div",{className:"rf-flex-1",children:m?Y.jsxs(fa,{variant:"outline",size:"sm",className:"rf-gap-2 rf-w-full sm:rf-w-auto",onClick:()=>window.open(m,"_blank"),children:[Y.jsx(jFo,{className:"rf-h-4 rf-w-4"}),"View on tscircuit.com"]}):null}),Y.jsxs("div",{className:"rf-flex rf-flex-col sm:rf-flex-row rf-gap-2",children:[Y.jsx(fa,{variant:"outline",onClick:()=>n(!1),className:"rf-order-2 sm:rf-order-1",children:"Close"}),Y.jsx(fa,{onClick:A,disabled:a,className:"rf-bg-blue-600 hover:rf-bg-blue-700",children:a?Y.jsx(Tx,{className:"rf-h-4 rf-w-4 rf-animate-spin"}):"Import Component"})]})]})]})})},EXo=()=>{const[t,e]=X.useState(null),[n,o]=X.useState(!1),i=X.useCallback(async(s,a)=>{o(!0);try{const A=await fetch(`https://api.tscircuit.com/packages/get?name=${encodeURIComponent(`${s}/${a}`)}`);if(!A.ok)throw new Error(`Failed to load package details: ${A.status}`);const c=await A.json();e(c.package??null)}catch(A){console.error("Failed to fetch package details",A),e(null)}finally{o(!1)}},[]),r=X.useCallback(()=>{e(null),o(!1)},[]);return{details:t,isLoading:n,fetchDetails:i,reset:r}},xXo=(t,e)=>{const[n,o]=X.useState({circuitJson:null,error:null,isLoading:!1});return X.useEffect(()=>{if(!t||!$Gt(t)){o({circuitJson:null,error:null,isLoading:!1});return}let i=!1;return o({circuitJson:null,error:null,isLoading:!0}),uXo(t,e).then(r=>{i||o({circuitJson:r,error:null,isLoading:!1})}).catch(r=>{i||o({circuitJson:null,error:r instanceof Error?r.message:"Failed to load footprint preview",isLoading:!1})}),()=>{i=!0}},[t,e]),n},BXo=async(t,e)=>{const n={"Content-Type":"application/json"};e&&(n.Authorization=`Bearer ${e}`);const o=await fetch("https://registry-api.tscircuit.com/packages/search",{method:"POST",headers:n,body:JSON.stringify({query:t})});if(!o.ok)throw new Error(`tscircuit registry error: ${o.status}`);return(await o.json()).packages??[]},QXo=({sessionToken:t})=>{const[e,n]=X.useState([]),[o,i]=X.useState(!1),[r,s]=X.useState(null),[a,A]=X.useState(!1),c=X.useCallback(async g=>{const u=g.trim();if(!u)return[];i(!0),s(null);try{const d=(await BXo(u,t)).map(_=>({source:"tscircuit.com",package:_}));return n(d),d}catch(h){return console.error("Error searching tscircuit packages",h),n([]),s(h instanceof Error?h.message:"Failed to search tscircuit packages"),[]}finally{i(!1),A(!0)}},[t]),l=X.useCallback(()=>{n([]),i(!1),s(null),A(!1)},[]);return{results:e,isSearching:o,error:r,hasSearched:a,search:c,reset:l}},SXo=t=>{const e=/^C(\d+)$/i.exec(t.trim());if(!e)return null;const n=Number(e[1]);if(!Number.isSafeInteger(n))return null;const o=`C${e[1]}`;return{source:"jlcpcb",component:{lcscId:n,manufacturer:o,partNumber:o,description:"Import directly from EasyEDA; stock and availability are unknown",package:"",isDirectLookup:!0}}},tOt=(t,e)=>{const n=SXo(t);return n?e.some(i=>i.component.partNumber.toUpperCase()===n.component.partNumber)?e:[n,...e]:e},bXo=t=>{const e=t.trim();return/^C\d+/i.test(e)?e.replace(/^C/i,""):e},DXo=()=>{const[t,e]=X.useState([]),[n,o]=X.useState(!1),[i,r]=X.useState(null),[s,a]=X.useState(!1),A=X.useCallback(async l=>{const g=bXo(l);if(!g)return[];o(!0),r(null);try{const u=await pjo(g,10),h=tOt(l,u.map(d=>({source:"jlcpcb",component:Ijo(d)})));return e(h),h}catch(u){console.error("Error searching JLCPCB components",u);const h=tOt(l,[]);return e(h),r(h.length>0?null:u instanceof Error?u.message:"Failed to search JLCPCB components"),h}finally{o(!1),a(!0)}},[]),c=X.useCallback(()=>{e([]),o(!1),r(null),a(!1)},[]);return{results:t,isSearching:n,error:i,hasSearched:s,search:A,reset:c}},vXo=()=>{const[t,e]=X.useState([]),[n,o]=X.useState(!1),[i,r]=X.useState(null),[s,a]=X.useState(!1),A=X.useCallback(async l=>{const g=l.trim();if(!g)return[];o(!0),r(null);try{const h=(await AXo(g,20)).map(d=>({source:"kicad",footprint:cXo(d)}));return e(h),h}catch(u){return console.error("Error searching KiCad footprints",u),e([]),r(u instanceof Error?u.message:"Failed to search KiCad footprints"),[]}finally{o(!1),a(!0)}},[]),c=X.useCallback(()=>{e([]),o(!1),r(null),a(!1)},[]);return{results:t,isSearching:n,error:i,hasSearched:s,search:A,reset:c}},PXo=({onTscircuitPackageSelected:t,onJlcpcbComponentTsxLoaded:e,onKicadStringSelected:n})=>{const o=[];return t&&o.push("tscircuit.com"),e&&o.push("jlcpcb"),n&&o.push("kicad"),o},wXo=({isOpen:t,onClose:e,jlcpcbProxyRequestHeaders:n,onKicadStringSelected:o,onTscircuitPackageSelected:i,onJlcpcbComponentTsxLoaded:r,jlcpcbProxyApiBase:s,tscircuitSessionToken:a})=>{YY();const A=X.useMemo(()=>PXo({onKicadStringSelected:o,onTscircuitPackageSelected:i,onJlcpcbComponentTsxLoaded:r}),[o,i,r]),c=A.length>0,l=A.length===1,[g,u]=X.useState(A[0]??"tscircuit.com"),[h,d]=X.useState(""),[_,m]=X.useState(null),{results:p,isSearching:I,error:f,hasSearched:C,search:y,reset:E}=QXo({sessionToken:a}),{results:B,isSearching:Q,error:b,hasSearched:D,search:R,reset:M}=DXo(),{results:L,isSearching:G,error:O,hasSearched:U,search:W,reset:j}=vXo(),{details:te,isLoading:ie,fetchDetails:$,reset:Z}=EXo(),[se,ae]=X.useState(null),[ce,fe]=X.useState(!1),[Ce,xe]=X.useState("pcb"),[de,Ee]=X.useState(null),[he,ve]=X.useState(!1),Re=X.useMemo(()=>({jlcpcb:{headers:n,apiBase:s}}),[s,n]),{circuitJson:ze,error:Ie,isLoading:We}=xXo(_,Re),Me=$Gt(_);X.useEffect(()=>{Ee(null)},[_]);const Te=X.useCallback(()=>{E(),M(),j(),m(null)},[M,j,E]);X.useEffect(()=>{t||(Te(),d(""),fe(!1),ae(null),Ee(null))},[t,Te]),X.useEffect(()=>{d(""),m(null),g==="tscircuit.com"?E():g==="jlcpcb"?M():g==="kicad"&&j()},[g,M,j,E]);const Ve=gt=>{m(gt),ae(gt),xe("pcb"),fe(!0),Z();const nt=gt.package.org_owner_tscircuit_handle,xt=gt.package.unscoped_name;if(nt&&xt){const mt=xt.split("/").pop()??xt;$(nt,mt)}},Ne=async()=>{h.trim()&&(m(null),g==="tscircuit.com"?await y(h):g==="jlcpcb"?await R(h):g==="kicad"&&await W(h))},Se=async gt=>{try{if(Ee(null),ve(!0),gt.source==="kicad"){if(!o)throw new Error("KiCad handler not provided");await o({result:gt,footprint:gt.footprint.qualifiedName})}else if(gt.source==="jlcpcb"){if(!r)throw new Error("JLCPCB handler not provided");const nt=await fjo(gt.component.partNumber,{headers:n,apiBase:s});await r({result:gt,tsx:nt})}else if(gt.source==="tscircuit.com"){if(!i)throw new Error("tscircuit package handler not provided");const nt=gt.package.org_owner_tscircuit_handle,xt=gt.package.unscoped_name;if(!nt||!xt)throw new Error("Missing package metadata");const mt=xt.split("/").pop()??xt,vt=`@tsci/${nt}.${mt}`;await i({result:gt,fullPackageName:vt})}return!0}catch(nt){return console.error("Failed to import component",nt),Ee(nt instanceof Error?nt.message:"Failed to import component"),!1}finally{ve(!1)}};let Oe=[],Pe=!1,qe=null,$e=!1;g==="tscircuit.com"?(Oe=p,Pe=I,qe=f,$e=C):g==="jlcpcb"?(Oe=B,Pe=Q,qe=b,$e=D):g==="kicad"&&(Oe=L,Pe=G,qe=O,$e=U);const at=async()=>{if(!_)return;await Se(_)&&(e(),Te(),d(""))},ct=gt=>{gt||e()},dt=gt=>{fe(gt),gt||ae(null)};return Y.jsxs($6,{open:t,onOpenChange:ct,children:[Y.jsxs(ow,{style:{width:"calc(100vw - 2rem)",maxWidth:Me?"min(1120px, calc(100vw - 2rem))":"min(672px, calc(100vw - 2rem))",zIndex:eOt.importComponentDialog},className:"rf-rounded-sm rf-max-h-[90vh] rf-overflow-y-auto rf-overflow-x-hidden rf-flex rf-flex-col",children:[Y.jsxs(iw,{children:[Y.jsxs(rw,{className:"rf-text-lg sm:rf-text-xl",children:["Import ",l?Cae[g].label:""," ","Component"]}),Y.jsx(Z6,{className:"rf-text-sm",children:c?"Search for components from available sources.":"Import options are disabled because no handlers were provided."})]}),c?Y.jsxs(Nxe,{value:g,onValueChange:gt=>u(gt),className:"rf-min-w-0 rf-w-full",children:[!l&&Y.jsx(kne,{className:"rf-flex rf-w-full rf-gap-2",children:A.map(gt=>Y.jsx(HS,{value:gt,className:"rf-flex-1 rf-text-xs sm:rf-text-sm",children:Cae[gt].label},gt))}),Y.jsxs("div",{className:"rf-min-w-0",style:Me?{display:"grid",gridTemplateColumns:"minmax(0, 1fr) minmax(360px, 0.95fr)",gap:"1.5rem",alignItems:"start"}:void 0,children:[Y.jsxs("div",{className:"rf-min-w-0",children:[Y.jsx(dXo,{query:h,placeholder:Cae[g].placeholder,isSearching:Pe,onQueryChange:d,onSubmit:Ne}),Y.jsx("div",{className:"no-scrollbar rf-mt-4 rf-flex-1 rf-min-h-[200px] !rf-max-h-[40vh] !rf-overflow-y-auto rf-overflow-x-hidden rf-border rf-rounded-md rf-min-w-0",children:Pe?Y.jsxs("div",{className:"rf-p-8 rf-text-center rf-text-zinc-500",children:[Y.jsx(Tx,{className:"rf-h-8 rf-w-8 rf-animate-spin rf-mx-auto rf-mb-2"}),Y.jsx("p",{children:"Searching..."})]}):Oe.length>0?Y.jsx(fXo,{results:Oe,selected:_,onSelect:m,onShowDetails:g==="tscircuit.com"?Ve:void 0}):Y.jsx("div",{className:"rf-p-8 rf-text-center rf-text-zinc-500",children:qe?`Error: ${qe}`:$e?Cae[g].emptyMessage:"Enter a search term to find components"})})]}),Me?Y.jsx("div",{className:"rf-mt-4",children:Y.jsx(CXo,{circuitJson:ze,error:Ie,isLoading:We,height:325})}):null]})]}):null,de?Y.jsx("div",{className:"rf-text-sm rf-text-red-600 rf-mt-2",children:de}):null,Y.jsxs(Uk,{className:"rf-flex rf-flex-col sm:rf-flex-row rf-gap-2",children:[Y.jsx(fa,{variant:"outline",onClick:e,className:"rf-order-2 sm:rf-order-1",children:"Cancel"}),Y.jsx(fa,{onClick:at,disabled:!_||he,className:"rf-order-1 sm:rf-order-2",children:he?Y.jsx(Tx,{className:"rf-h-4 rf-w-4 rf-animate-spin"}):"Import"})]})]}),Y.jsx(yXo,{packageResult:se,isOpen:ce,onOpenChange:dt,isLoading:ie,details:te,previewTab:Ce,onPreviewTabChange:gt=>xe(gt),isSubmitting:he,onImport:()=>{se&&Se(se).then(gt=>{gt&&(fe(!1),e(),Te(),d(""))})}})]})},MXo=t=>{const e=t.match(/export const (\w+) =/);if(!e)throw new Error("Could not determine component name from TSX contents");return e[1]},nOt=t=>{const e=Xu(s=>s.pushEvent),n=Xu(s=>s.upsertFile),o=async({result:s,fullPackageName:a})=>{const c=s.package.unscoped_name??s.package.name;await Rs.promise(e({event_type:"INSTALL_PACKAGE",full_package_name:a}),{loading:`Requesting install for "${c}"`,success:`Install requested for "${c}"`,error:l=>`Failed to request install: ${l instanceof Error?l.message:String(l)}`})},i=async({footprint:s})=>{await Rs.promise(navigator.clipboard.writeText(s),{loading:`Copying "${s}"`,success:`Copied "${s}" to clipboard`,error:a=>`Failed to copy footprint: ${a instanceof Error?a.message:String(a)}`})},r=async({result:s,tsx:a})=>{const c=`imports/${MXo(a)}.tsx`;await Rs.promise(n(c,a),{loading:`Importing ${s.component.partNumber}`,success:`Imported to "${c}"`,error:l=>`Failed to import component: ${l instanceof Error?l.message:String(l)}`})};return Y.jsx(wXo,{...t,onTscircuitPackageSelected:o,onKicadStringSelected:i,onJlcpcbComponentTsxLoaded:r})};nOt.displayName="ImportComponentDialogForCli";var G7e={exports:{}},oOt;function NXo(){return oOt||(oOt=1,(function(t,e){var n={env:{},version:""};(function(o){t.exports=o()})(function(){return(function o(i,r,s){function a(l,g){if(!r[l]){if(!i[l]){var u=typeof DD=="function"&ⅅif(!g&&u)return u(l,!0);if(A)return A(l,!0);var h=new Error("Cannot find module '"+l+"'");throw h.code="MODULE_NOT_FOUND",h}var d=r[l]={exports:{}};i[l][0].call(d.exports,function(_){var m=i[l][1][_];return a(m||_)},d,d.exports,o,i,r,s)}return r[l].exports}for(var A=typeof DD=="function"&&DD,c=0;c<s.length;c++)a(s[c]);return a})({1:[function(o,i,r){var s=o("./utils"),a=o("./support"),A="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";r.encode=function(c){for(var l,g,u,h,d,_,m,p=[],I=0,f=c.length,C=f,y=s.getTypeOf(c)!=="string";I<c.length;)C=f-I,u=y?(l=c[I++],g=I<f?c[I++]:0,I<f?c[I++]:0):(l=c.charCodeAt(I++),g=I<f?c.charCodeAt(I++):0,I<f?c.charCodeAt(I++):0),h=l>>2,d=(3&l)<<4|g>>4,_=1<C?(15&g)<<2|u>>6:64,m=2<C?63&u:64,p.push(A.charAt(h)+A.charAt(d)+A.charAt(_)+A.charAt(m));return p.join("")},r.decode=function(c){var l,g,u,h,d,_,m=0,p=0,I="data:";if(c.substr(0,I.length)===I)throw new Error("Invalid base64 input, it looks like a data url.");var f,C=3*(c=c.replace(/[^A-Za-z0-9+/=]/g,"")).length/4;if(c.charAt(c.length-1)===A.charAt(64)&&C--,c.charAt(c.length-2)===A.charAt(64)&&C--,C%1!=0)throw new Error("Invalid base64 input, bad content length.");for(f=a.uint8array?new Uint8Array(0|C):new Array(0|C);m<c.length;)l=A.indexOf(c.charAt(m++))<<2|(h=A.indexOf(c.charAt(m++)))>>4,g=(15&h)<<4|(d=A.indexOf(c.charAt(m++)))>>2,u=(3&d)<<6|(_=A.indexOf(c.charAt(m++))),f[p++]=l,d!==64&&(f[p++]=g),_!==64&&(f[p++]=u);return f}},{"./support":30,"./utils":32}],2:[function(o,i,r){var s=o("./external"),a=o("./stream/DataWorker"),A=o("./stream/Crc32Probe"),c=o("./stream/DataLengthProbe");function l(g,u,h,d,_){this.compressedSize=g,this.uncompressedSize=u,this.crc32=h,this.compression=d,this.compressedContent=_}l.prototype={getContentWorker:function(){var g=new a(s.Promise.resolve(this.compressedContent)).pipe(this.compression.uncompressWorker()).pipe(new c("data_length")),u=this;return g.on("end",function(){if(this.streamInfo.data_length!==u.uncompressedSize)throw new Error("Bug : uncompressed data size mismatch")}),g},getCompressedWorker:function(){return new a(s.Promise.resolve(this.compressedContent)).withStreamInfo("compressedSize",this.compressedSize).withStreamInfo("uncompressedSize",this.uncompressedSize).withStreamInfo("crc32",this.crc32).withStreamInfo("compression",this.compression)}},l.createWorkerFrom=function(g,u,h){return g.pipe(new A).pipe(new c("uncompressedSize")).pipe(u.compressWorker(h)).pipe(new c("compressedSize")).withStreamInfo("compression",u)},i.exports=l},{"./external":6,"./stream/Crc32Probe":25,"./stream/DataLengthProbe":26,"./stream/DataWorker":27}],3:[function(o,i,r){var s=o("./stream/GenericWorker");r.STORE={magic:"\0\0",compressWorker:function(){return new s("STORE compression")},uncompressWorker:function(){return new s("STORE decompression")}},r.DEFLATE=o("./flate")},{"./flate":7,"./stream/GenericWorker":28}],4:[function(o,i,r){var s=o("./utils"),a=(function(){for(var A,c=[],l=0;l<256;l++){A=l;for(var g=0;g<8;g++)A=1&A?3988292384^A>>>1:A>>>1;c[l]=A}return c})();i.exports=function(A,c){return A!==void 0&&A.length?s.getTypeOf(A)!=="string"?(function(l,g,u,h){var d=a,_=h+u;l^=-1;for(var m=h;m<_;m++)l=l>>>8^d[255&(l^g[m])];return-1^l})(0|c,A,A.length,0):(function(l,g,u,h){var d=a,_=h+u;l^=-1;for(var m=h;m<_;m++)l=l>>>8^d[255&(l^g.charCodeAt(m))];return-1^l})(0|c,A,A.length,0):0}},{"./utils":32}],5:[function(o,i,r){r.base64=!1,r.binary=!1,r.dir=!1,r.createFolders=!0,r.date=null,r.compression=null,r.compressionOptions=null,r.comment=null,r.unixPermissions=null,r.dosPermissions=null},{}],6:[function(o,i,r){var s=null;s=typeof Promise<"u"?Promise:o("lie"),i.exports={Promise:s}},{lie:37}],7:[function(o,i,r){var s=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Uint32Array<"u",a=o("pako"),A=o("./utils"),c=o("./stream/GenericWorker"),l=s?"uint8array":"array";function g(u,h){c.call(this,"FlateWorker/"+u),this._pako=null,this._pakoAction=u,this._pakoOptions=h,this.meta={}}r.magic="\b\0",A.inherits(g,c),g.prototype.processChunk=function(u){this.meta=u.meta,this._pako===null&&this._createPako(),this._pako.push(A.transformTo(l,u.data),!1)},g.prototype.flush=function(){c.prototype.flush.call(this),this._pako===null&&this._createPako(),this._pako.push([],!0)},g.prototype.cleanUp=function(){c.prototype.cleanUp.call(this),this._pako=null},g.prototype._createPako=function(){this._pako=new a[this._pakoAction]({raw:!0,level:this._pakoOptions.level||-1});var u=this;this._pako.onData=function(h){u.push({data:h,meta:u.meta})}},r.compressWorker=function(u){return new g("Deflate",u)},r.uncompressWorker=function(){return new g("Inflate",{})}},{"./stream/GenericWorker":28,"./utils":32,pako:38}],8:[function(o,i,r){function s(d,_){var m,p="";for(m=0;m<_;m++)p+=String.fromCharCode(255&d),d>>>=8;return p}function a(d,_,m,p,I,f){var C,y,E=d.file,B=d.compression,Q=f!==l.utf8encode,b=A.transformTo("string",f(E.name)),D=A.transformTo("string",l.utf8encode(E.name)),R=E.comment,M=A.transformTo("string",f(R)),L=A.transformTo("string",l.utf8encode(R)),G=D.length!==E.name.length,O=L.length!==R.length,U="",W="",j="",te=E.dir,ie=E.date,$={crc32:0,compressedSize:0,uncompressedSize:0};_&&!m||($.crc32=d.crc32,$.compressedSize=d.compressedSize,$.uncompressedSize=d.uncompressedSize);var Z=0;_&&(Z|=8),Q||!G&&!O||(Z|=2048);var se=0,ae=0;te&&(se|=16),I==="UNIX"?(ae=798,se|=(function(fe,Ce){var xe=fe;return fe||(xe=Ce?16893:33204),(65535&xe)<<16})(E.unixPermissions,te)):(ae=20,se|=(function(fe){return 63&(fe||0)})(E.dosPermissions)),C=ie.getUTCHours(),C<<=6,C|=ie.getUTCMinutes(),C<<=5,C|=ie.getUTCSeconds()/2,y=ie.getUTCFullYear()-1980,y<<=4,y|=ie.getUTCMonth()+1,y<<=5,y|=ie.getUTCDate(),G&&(W=s(1,1)+s(g(b),4)+D,U+="up"+s(W.length,2)+W),O&&(j=s(1,1)+s(g(M),4)+L,U+="uc"+s(j.length,2)+j);var ce="";return ce+=`
|
|
5799
5799
|
\0`,ce+=s(Z,2),ce+=B.magic,ce+=s(C,2),ce+=s(y,2),ce+=s($.crc32,4),ce+=s($.compressedSize,4),ce+=s($.uncompressedSize,4),ce+=s(b.length,2),ce+=s(U.length,2),{fileRecord:u.LOCAL_FILE_HEADER+ce+b+U,dirRecord:u.CENTRAL_FILE_HEADER+s(ae,2)+ce+s(M.length,2)+"\0\0\0\0"+s(se,4)+s(p,4)+b+U+M}}var A=o("../utils"),c=o("../stream/GenericWorker"),l=o("../utf8"),g=o("../crc32"),u=o("../signature");function h(d,_,m,p){c.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=_,this.zipPlatform=m,this.encodeFileName=p,this.streamFiles=d,this.accumulate=!1,this.contentBuffer=[],this.dirRecords=[],this.currentSourceOffset=0,this.entriesCount=0,this.currentFile=null,this._sources=[]}A.inherits(h,c),h.prototype.push=function(d){var _=d.meta.percent||0,m=this.entriesCount,p=this._sources.length;this.accumulate?this.contentBuffer.push(d):(this.bytesWritten+=d.data.length,c.prototype.push.call(this,{data:d.data,meta:{currentFile:this.currentFile,percent:m?(_+100*(m-p-1))/m:100}}))},h.prototype.openedSource=function(d){this.currentSourceOffset=this.bytesWritten,this.currentFile=d.file.name;var _=this.streamFiles&&!d.file.dir;if(_){var m=a(d,_,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:m.fileRecord,meta:{percent:0}})}else this.accumulate=!0},h.prototype.closedSource=function(d){this.accumulate=!1;var _=this.streamFiles&&!d.file.dir,m=a(d,_,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(m.dirRecord),_)this.push({data:(function(p){return u.DATA_DESCRIPTOR+s(p.crc32,4)+s(p.compressedSize,4)+s(p.uncompressedSize,4)})(d),meta:{percent:100}});else for(this.push({data:m.fileRecord,meta:{percent:0}});this.contentBuffer.length;)this.push(this.contentBuffer.shift());this.currentFile=null},h.prototype.flush=function(){for(var d=this.bytesWritten,_=0;_<this.dirRecords.length;_++)this.push({data:this.dirRecords[_],meta:{percent:100}});var m=this.bytesWritten-d,p=(function(I,f,C,y,E){var B=A.transformTo("string",E(y));return u.CENTRAL_DIRECTORY_END+"\0\0\0\0"+s(I,2)+s(I,2)+s(f,4)+s(C,4)+s(B.length,2)+B})(this.dirRecords.length,m,d,this.zipComment,this.encodeFileName);this.push({data:p,meta:{percent:100}})},h.prototype.prepareNextSource=function(){this.previous=this._sources.shift(),this.openedSource(this.previous.streamInfo),this.isPaused?this.previous.pause():this.previous.resume()},h.prototype.registerPrevious=function(d){this._sources.push(d);var _=this;return d.on("data",function(m){_.processChunk(m)}),d.on("end",function(){_.closedSource(_.previous.streamInfo),_._sources.length?_.prepareNextSource():_.end()}),d.on("error",function(m){_.error(m)}),this},h.prototype.resume=function(){return!!c.prototype.resume.call(this)&&(!this.previous&&this._sources.length?(this.prepareNextSource(),!0):this.previous||this._sources.length||this.generatedError?void 0:(this.end(),!0))},h.prototype.error=function(d){var _=this._sources;if(!c.prototype.error.call(this,d))return!1;for(var m=0;m<_.length;m++)try{_[m].error(d)}catch{}return!0},h.prototype.lock=function(){c.prototype.lock.call(this);for(var d=this._sources,_=0;_<d.length;_++)d[_].lock()},i.exports=h},{"../crc32":4,"../signature":23,"../stream/GenericWorker":28,"../utf8":31,"../utils":32}],9:[function(o,i,r){var s=o("../compressions"),a=o("./ZipFileWorker");r.generateWorker=function(A,c,l){var g=new a(c.streamFiles,l,c.platform,c.encodeFileName),u=0;try{A.forEach(function(h,d){u++;var _=(function(f,C){var y=f||C,E=s[y];if(!E)throw new Error(y+" is not a valid compression method !");return E})(d.options.compression,c.compression),m=d.options.compressionOptions||c.compressionOptions||{},p=d.dir,I=d.date;d._compressWorker(_,m).withStreamInfo("file",{name:h,dir:p,date:I,comment:d.comment||"",unixPermissions:d.unixPermissions,dosPermissions:d.dosPermissions}).pipe(g)}),g.entriesCount=u}catch(h){g.error(h)}return g}},{"../compressions":3,"./ZipFileWorker":8}],10:[function(o,i,r){function s(){if(!(this instanceof s))return new s;if(arguments.length)throw new Error("The constructor with parameters has been removed in JSZip 3.0, please check the upgrade guide.");this.files=Object.create(null),this.comment=null,this.root="",this.clone=function(){var a=new s;for(var A in this)typeof this[A]!="function"&&(a[A]=this[A]);return a}}(s.prototype=o("./object")).loadAsync=o("./load"),s.support=o("./support"),s.defaults=o("./defaults"),s.version="3.10.1",s.loadAsync=function(a,A){return new s().loadAsync(a,A)},s.external=o("./external"),i.exports=s},{"./defaults":5,"./external":6,"./load":11,"./object":15,"./support":30}],11:[function(o,i,r){var s=o("./utils"),a=o("./external"),A=o("./utf8"),c=o("./zipEntries"),l=o("./stream/Crc32Probe"),g=o("./nodejsUtils");function u(h){return new a.Promise(function(d,_){var m=h.decompressed.getContentWorker().pipe(new l);m.on("error",function(p){_(p)}).on("end",function(){m.streamInfo.crc32!==h.decompressed.crc32?_(new Error("Corrupted zip : CRC32 mismatch")):d()}).resume()})}i.exports=function(h,d){var _=this;return d=s.extend(d||{},{base64:!1,checkCRC32:!1,optimizedBinaryString:!1,createFolders:!1,decodeFileName:A.utf8decode}),g.isNode&&g.isStream(h)?a.Promise.reject(new Error("JSZip can't accept a stream when loading a zip file.")):s.prepareContent("the loaded zip file",h,!0,d.optimizedBinaryString,d.base64).then(function(m){var p=new c(d);return p.load(m),p}).then(function(m){var p=[a.Promise.resolve(m)],I=m.files;if(d.checkCRC32)for(var f=0;f<I.length;f++)p.push(u(I[f]));return a.Promise.all(p)}).then(function(m){for(var p=m.shift(),I=p.files,f=0;f<I.length;f++){var C=I[f],y=C.fileNameStr,E=s.resolve(C.fileNameStr);_.file(E,C.decompressed,{binary:!0,optimizedBinaryString:!0,date:C.date,dir:C.dir,comment:C.fileCommentStr.length?C.fileCommentStr:null,unixPermissions:C.unixPermissions,dosPermissions:C.dosPermissions,createFolders:d.createFolders}),C.dir||(_.file(E).unsafeOriginalName=y)}return p.zipComment.length&&(_.comment=p.zipComment),_})}},{"./external":6,"./nodejsUtils":14,"./stream/Crc32Probe":25,"./utf8":31,"./utils":32,"./zipEntries":33}],12:[function(o,i,r){var s=o("../utils"),a=o("../stream/GenericWorker");function A(c,l){a.call(this,"Nodejs stream input adapter for "+c),this._upstreamEnded=!1,this._bindStream(l)}s.inherits(A,a),A.prototype._bindStream=function(c){var l=this;(this._stream=c).pause(),c.on("data",function(g){l.push({data:g,meta:{percent:0}})}).on("error",function(g){l.isPaused?this.generatedError=g:l.error(g)}).on("end",function(){l.isPaused?l._upstreamEnded=!0:l.end()})},A.prototype.pause=function(){return!!a.prototype.pause.call(this)&&(this._stream.pause(),!0)},A.prototype.resume=function(){return!!a.prototype.resume.call(this)&&(this._upstreamEnded?this.end():this._stream.resume(),!0)},i.exports=A},{"../stream/GenericWorker":28,"../utils":32}],13:[function(o,i,r){var s=o("readable-stream").Readable;function a(A,c,l){s.call(this,c),this._helper=A;var g=this;A.on("data",function(u,h){g.push(u)||g._helper.pause(),l&&l(h)}).on("error",function(u){g.emit("error",u)}).on("end",function(){g.push(null)})}o("../utils").inherits(a,s),a.prototype._read=function(){this._helper.resume()},i.exports=a},{"../utils":32,"readable-stream":16}],14:[function(o,i,r){i.exports={isNode:typeof Buffer<"u",newBufferFrom:function(s,a){if(Buffer.from&&Buffer.from!==Uint8Array.from)return Buffer.from(s,a);if(typeof s=="number")throw new Error('The "data" argument must not be a number');return new Buffer(s,a)},allocBuffer:function(s){if(Buffer.alloc)return Buffer.alloc(s);var a=new Buffer(s);return a.fill(0),a},isBuffer:function(s){return Buffer.isBuffer(s)},isStream:function(s){return s&&typeof s.on=="function"&&typeof s.pause=="function"&&typeof s.resume=="function"}}},{}],15:[function(o,i,r){function s(E,B,Q){var b,D=A.getTypeOf(B),R=A.extend(Q||{},g);R.date=R.date||new Date,R.compression!==null&&(R.compression=R.compression.toUpperCase()),typeof R.unixPermissions=="string"&&(R.unixPermissions=parseInt(R.unixPermissions,8)),R.unixPermissions&&16384&R.unixPermissions&&(R.dir=!0),R.dosPermissions&&16&R.dosPermissions&&(R.dir=!0),R.dir&&(E=I(E)),R.createFolders&&(b=p(E))&&f.call(this,b,!0);var M=D==="string"&&R.binary===!1&&R.base64===!1;Q&&Q.binary!==void 0||(R.binary=!M),(B instanceof u&&B.uncompressedSize===0||R.dir||!B||B.length===0)&&(R.base64=!1,R.binary=!0,B="",R.compression="STORE",D="string");var L=null;L=B instanceof u||B instanceof c?B:_.isNode&&_.isStream(B)?new m(E,B):A.prepareContent(E,B,R.binary,R.optimizedBinaryString,R.base64);var G=new h(E,L,R);this.files[E]=G}var a=o("./utf8"),A=o("./utils"),c=o("./stream/GenericWorker"),l=o("./stream/StreamHelper"),g=o("./defaults"),u=o("./compressedObject"),h=o("./zipObject"),d=o("./generate"),_=o("./nodejsUtils"),m=o("./nodejs/NodejsStreamInputAdapter"),p=function(E){E.slice(-1)==="/"&&(E=E.substring(0,E.length-1));var B=E.lastIndexOf("/");return 0<B?E.substring(0,B):""},I=function(E){return E.slice(-1)!=="/"&&(E+="/"),E},f=function(E,B){return B=B!==void 0?B:g.createFolders,E=I(E),this.files[E]||s.call(this,E,null,{dir:!0,createFolders:B}),this.files[E]};function C(E){return Object.prototype.toString.call(E)==="[object RegExp]"}var y={load:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},forEach:function(E){var B,Q,b;for(B in this.files)b=this.files[B],(Q=B.slice(this.root.length,B.length))&&B.slice(0,this.root.length)===this.root&&E(Q,b)},filter:function(E){var B=[];return this.forEach(function(Q,b){E(Q,b)&&B.push(b)}),B},file:function(E,B,Q){if(arguments.length!==1)return E=this.root+E,s.call(this,E,B,Q),this;if(C(E)){var b=E;return this.filter(function(R,M){return!M.dir&&b.test(R)})}var D=this.files[this.root+E];return D&&!D.dir?D:null},folder:function(E){if(!E)return this;if(C(E))return this.filter(function(D,R){return R.dir&&E.test(D)});var B=this.root+E,Q=f.call(this,B),b=this.clone();return b.root=Q.name,b},remove:function(E){E=this.root+E;var B=this.files[E];if(B||(E.slice(-1)!=="/"&&(E+="/"),B=this.files[E]),B&&!B.dir)delete this.files[E];else for(var Q=this.filter(function(D,R){return R.name.slice(0,E.length)===E}),b=0;b<Q.length;b++)delete this.files[Q[b].name];return this},generate:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},generateInternalStream:function(E){var B,Q={};try{if((Q=A.extend(E||{},{streamFiles:!1,compression:"STORE",compressionOptions:null,type:"",platform:"DOS",comment:null,mimeType:"application/zip",encodeFileName:a.utf8encode})).type=Q.type.toLowerCase(),Q.compression=Q.compression.toUpperCase(),Q.type==="binarystring"&&(Q.type="string"),!Q.type)throw new Error("No output type specified.");A.checkSupport(Q.type),Q.platform!=="darwin"&&Q.platform!=="freebsd"&&Q.platform!=="linux"&&Q.platform!=="sunos"||(Q.platform="UNIX"),Q.platform==="win32"&&(Q.platform="DOS");var b=Q.comment||this.comment||"";B=d.generateWorker(this,Q,b)}catch(D){(B=new c("error")).error(D)}return new l(B,Q.type||"string",Q.mimeType)},generateAsync:function(E,B){return this.generateInternalStream(E).accumulate(B)},generateNodeStream:function(E,B){return(E=E||{}).type||(E.type="nodebuffer"),this.generateInternalStream(E).toNodejsStream(B)}};i.exports=y},{"./compressedObject":2,"./defaults":5,"./generate":9,"./nodejs/NodejsStreamInputAdapter":12,"./nodejsUtils":14,"./stream/GenericWorker":28,"./stream/StreamHelper":29,"./utf8":31,"./utils":32,"./zipObject":35}],16:[function(o,i,r){i.exports=o("stream")},{stream:void 0}],17:[function(o,i,r){var s=o("./DataReader");function a(A){s.call(this,A);for(var c=0;c<this.data.length;c++)A[c]=255&A[c]}o("../utils").inherits(a,s),a.prototype.byteAt=function(A){return this.data[this.zero+A]},a.prototype.lastIndexOfSignature=function(A){for(var c=A.charCodeAt(0),l=A.charCodeAt(1),g=A.charCodeAt(2),u=A.charCodeAt(3),h=this.length-4;0<=h;--h)if(this.data[h]===c&&this.data[h+1]===l&&this.data[h+2]===g&&this.data[h+3]===u)return h-this.zero;return-1},a.prototype.readAndCheckSignature=function(A){var c=A.charCodeAt(0),l=A.charCodeAt(1),g=A.charCodeAt(2),u=A.charCodeAt(3),h=this.readData(4);return c===h[0]&&l===h[1]&&g===h[2]&&u===h[3]},a.prototype.readData=function(A){if(this.checkOffset(A),A===0)return[];var c=this.data.slice(this.zero+this.index,this.zero+this.index+A);return this.index+=A,c},i.exports=a},{"../utils":32,"./DataReader":18}],18:[function(o,i,r){var s=o("../utils");function a(A){this.data=A,this.length=A.length,this.index=0,this.zero=0}a.prototype={checkOffset:function(A){this.checkIndex(this.index+A)},checkIndex:function(A){if(this.length<this.zero+A||A<0)throw new Error("End of data reached (data length = "+this.length+", asked index = "+A+"). Corrupted zip ?")},setIndex:function(A){this.checkIndex(A),this.index=A},skip:function(A){this.setIndex(this.index+A)},byteAt:function(){},readInt:function(A){var c,l=0;for(this.checkOffset(A),c=this.index+A-1;c>=this.index;c--)l=(l<<8)+this.byteAt(c);return this.index+=A,l},readString:function(A){return s.transformTo("string",this.readData(A))},readData:function(){},lastIndexOfSignature:function(){},readAndCheckSignature:function(){},readDate:function(){var A=this.readInt(4);return new Date(Date.UTC(1980+(A>>25&127),(A>>21&15)-1,A>>16&31,A>>11&31,A>>5&63,(31&A)<<1))}},i.exports=a},{"../utils":32}],19:[function(o,i,r){var s=o("./Uint8ArrayReader");function a(A){s.call(this,A)}o("../utils").inherits(a,s),a.prototype.readData=function(A){this.checkOffset(A);var c=this.data.slice(this.zero+this.index,this.zero+this.index+A);return this.index+=A,c},i.exports=a},{"../utils":32,"./Uint8ArrayReader":21}],20:[function(o,i,r){var s=o("./DataReader");function a(A){s.call(this,A)}o("../utils").inherits(a,s),a.prototype.byteAt=function(A){return this.data.charCodeAt(this.zero+A)},a.prototype.lastIndexOfSignature=function(A){return this.data.lastIndexOf(A)-this.zero},a.prototype.readAndCheckSignature=function(A){return A===this.readData(4)},a.prototype.readData=function(A){this.checkOffset(A);var c=this.data.slice(this.zero+this.index,this.zero+this.index+A);return this.index+=A,c},i.exports=a},{"../utils":32,"./DataReader":18}],21:[function(o,i,r){var s=o("./ArrayReader");function a(A){s.call(this,A)}o("../utils").inherits(a,s),a.prototype.readData=function(A){if(this.checkOffset(A),A===0)return new Uint8Array(0);var c=this.data.subarray(this.zero+this.index,this.zero+this.index+A);return this.index+=A,c},i.exports=a},{"../utils":32,"./ArrayReader":17}],22:[function(o,i,r){var s=o("../utils"),a=o("../support"),A=o("./ArrayReader"),c=o("./StringReader"),l=o("./NodeBufferReader"),g=o("./Uint8ArrayReader");i.exports=function(u){var h=s.getTypeOf(u);return s.checkSupport(h),h!=="string"||a.uint8array?h==="nodebuffer"?new l(u):a.uint8array?new g(s.transformTo("uint8array",u)):new A(s.transformTo("array",u)):new c(u)}},{"../support":30,"../utils":32,"./ArrayReader":17,"./NodeBufferReader":19,"./StringReader":20,"./Uint8ArrayReader":21}],23:[function(o,i,r){r.LOCAL_FILE_HEADER="PK",r.CENTRAL_FILE_HEADER="PK",r.CENTRAL_DIRECTORY_END="PK",r.ZIP64_CENTRAL_DIRECTORY_LOCATOR="PK\x07",r.ZIP64_CENTRAL_DIRECTORY_END="PK",r.DATA_DESCRIPTOR="PK\x07\b"},{}],24:[function(o,i,r){var s=o("./GenericWorker"),a=o("../utils");function A(c){s.call(this,"ConvertWorker to "+c),this.destType=c}a.inherits(A,s),A.prototype.processChunk=function(c){this.push({data:a.transformTo(this.destType,c.data),meta:c.meta})},i.exports=A},{"../utils":32,"./GenericWorker":28}],25:[function(o,i,r){var s=o("./GenericWorker"),a=o("../crc32");function A(){s.call(this,"Crc32Probe"),this.withStreamInfo("crc32",0)}o("../utils").inherits(A,s),A.prototype.processChunk=function(c){this.streamInfo.crc32=a(c.data,this.streamInfo.crc32||0),this.push(c)},i.exports=A},{"../crc32":4,"../utils":32,"./GenericWorker":28}],26:[function(o,i,r){var s=o("../utils"),a=o("./GenericWorker");function A(c){a.call(this,"DataLengthProbe for "+c),this.propName=c,this.withStreamInfo(c,0)}s.inherits(A,a),A.prototype.processChunk=function(c){if(c){var l=this.streamInfo[this.propName]||0;this.streamInfo[this.propName]=l+c.data.length}a.prototype.processChunk.call(this,c)},i.exports=A},{"../utils":32,"./GenericWorker":28}],27:[function(o,i,r){var s=o("../utils"),a=o("./GenericWorker");function A(c){a.call(this,"DataWorker");var l=this;this.dataIsReady=!1,this.index=0,this.max=0,this.data=null,this.type="",this._tickScheduled=!1,c.then(function(g){l.dataIsReady=!0,l.data=g,l.max=g&&g.length||0,l.type=s.getTypeOf(g),l.isPaused||l._tickAndRepeat()},function(g){l.error(g)})}s.inherits(A,a),A.prototype.cleanUp=function(){a.prototype.cleanUp.call(this),this.data=null},A.prototype.resume=function(){return!!a.prototype.resume.call(this)&&(!this._tickScheduled&&this.dataIsReady&&(this._tickScheduled=!0,s.delay(this._tickAndRepeat,[],this)),!0)},A.prototype._tickAndRepeat=function(){this._tickScheduled=!1,this.isPaused||this.isFinished||(this._tick(),this.isFinished||(s.delay(this._tickAndRepeat,[],this),this._tickScheduled=!0))},A.prototype._tick=function(){if(this.isPaused||this.isFinished)return!1;var c=null,l=Math.min(this.max,this.index+16384);if(this.index>=this.max)return this.end();switch(this.type){case"string":c=this.data.substring(this.index,l);break;case"uint8array":c=this.data.subarray(this.index,l);break;case"array":case"nodebuffer":c=this.data.slice(this.index,l)}return this.index=l,this.push({data:c,meta:{percent:this.max?this.index/this.max*100:0}})},i.exports=A},{"../utils":32,"./GenericWorker":28}],28:[function(o,i,r){function s(a){this.name=a||"default",this.streamInfo={},this.generatedError=null,this.extraStreamInfo={},this.isPaused=!0,this.isFinished=!1,this.isLocked=!1,this._listeners={data:[],end:[],error:[]},this.previous=null}s.prototype={push:function(a){this.emit("data",a)},end:function(){if(this.isFinished)return!1;this.flush();try{this.emit("end"),this.cleanUp(),this.isFinished=!0}catch(a){this.emit("error",a)}return!0},error:function(a){return!this.isFinished&&(this.isPaused?this.generatedError=a:(this.isFinished=!0,this.emit("error",a),this.previous&&this.previous.error(a),this.cleanUp()),!0)},on:function(a,A){return this._listeners[a].push(A),this},cleanUp:function(){this.streamInfo=this.generatedError=this.extraStreamInfo=null,this._listeners=[]},emit:function(a,A){if(this._listeners[a])for(var c=0;c<this._listeners[a].length;c++)this._listeners[a][c].call(this,A)},pipe:function(a){return a.registerPrevious(this)},registerPrevious:function(a){if(this.isLocked)throw new Error("The stream '"+this+"' has already been used.");this.streamInfo=a.streamInfo,this.mergeStreamInfo(),this.previous=a;var A=this;return a.on("data",function(c){A.processChunk(c)}),a.on("end",function(){A.end()}),a.on("error",function(c){A.error(c)}),this},pause:function(){return!this.isPaused&&!this.isFinished&&(this.isPaused=!0,this.previous&&this.previous.pause(),!0)},resume:function(){if(!this.isPaused||this.isFinished)return!1;var a=this.isPaused=!1;return this.generatedError&&(this.error(this.generatedError),a=!0),this.previous&&this.previous.resume(),!a},flush:function(){},processChunk:function(a){this.push(a)},withStreamInfo:function(a,A){return this.extraStreamInfo[a]=A,this.mergeStreamInfo(),this},mergeStreamInfo:function(){for(var a in this.extraStreamInfo)Object.prototype.hasOwnProperty.call(this.extraStreamInfo,a)&&(this.streamInfo[a]=this.extraStreamInfo[a])},lock:function(){if(this.isLocked)throw new Error("The stream '"+this+"' has already been used.");this.isLocked=!0,this.previous&&this.previous.lock()},toString:function(){var a="Worker "+this.name;return this.previous?this.previous+" -> "+a:a}},i.exports=s},{}],29:[function(o,i,r){var s=o("../utils"),a=o("./ConvertWorker"),A=o("./GenericWorker"),c=o("../base64"),l=o("../support"),g=o("../external"),u=null;if(l.nodestream)try{u=o("../nodejs/NodejsStreamOutputAdapter")}catch{}function h(_,m){return new g.Promise(function(p,I){var f=[],C=_._internalType,y=_._outputType,E=_._mimeType;_.on("data",function(B,Q){f.push(B),m&&m(Q)}).on("error",function(B){f=[],I(B)}).on("end",function(){try{var B=(function(Q,b,D){switch(Q){case"blob":return s.newBlob(s.transformTo("arraybuffer",b),D);case"base64":return c.encode(b);default:return s.transformTo(Q,b)}})(y,(function(Q,b){var D,R=0,M=null,L=0;for(D=0;D<b.length;D++)L+=b[D].length;switch(Q){case"string":return b.join("");case"array":return Array.prototype.concat.apply([],b);case"uint8array":for(M=new Uint8Array(L),D=0;D<b.length;D++)M.set(b[D],R),R+=b[D].length;return M;case"nodebuffer":return Buffer.concat(b);default:throw new Error("concat : unsupported type '"+Q+"'")}})(C,f),E);p(B)}catch(Q){I(Q)}f=[]}).resume()})}function d(_,m,p){var I=m;switch(m){case"blob":case"arraybuffer":I="uint8array";break;case"base64":I="string"}try{this._internalType=I,this._outputType=m,this._mimeType=p,s.checkSupport(I),this._worker=_.pipe(new a(I)),_.lock()}catch(f){this._worker=new A("error"),this._worker.error(f)}}d.prototype={accumulate:function(_){return h(this,_)},on:function(_,m){var p=this;return _==="data"?this._worker.on(_,function(I){m.call(p,I.data,I.meta)}):this._worker.on(_,function(){s.delay(m,arguments,p)}),this},resume:function(){return s.delay(this._worker.resume,[],this._worker),this},pause:function(){return this._worker.pause(),this},toNodejsStream:function(_){if(s.checkSupport("nodestream"),this._outputType!=="nodebuffer")throw new Error(this._outputType+" is not supported by this method");return new u(this,{objectMode:this._outputType!=="nodebuffer"},_)}},i.exports=d},{"../base64":1,"../external":6,"../nodejs/NodejsStreamOutputAdapter":13,"../support":30,"../utils":32,"./ConvertWorker":24,"./GenericWorker":28}],30:[function(o,i,r){if(r.base64=!0,r.array=!0,r.string=!0,r.arraybuffer=typeof ArrayBuffer<"u"&&typeof Uint8Array<"u",r.nodebuffer=typeof Buffer<"u",r.uint8array=typeof Uint8Array<"u",typeof ArrayBuffer>"u")r.blob=!1;else{var s=new ArrayBuffer(0);try{r.blob=new Blob([s],{type:"application/zip"}).size===0}catch{try{var a=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);a.append(s),r.blob=a.getBlob("application/zip").size===0}catch{r.blob=!1}}}try{r.nodestream=!!o("readable-stream").Readable}catch{r.nodestream=!1}},{"readable-stream":16}],31:[function(o,i,r){for(var s=o("./utils"),a=o("./support"),A=o("./nodejsUtils"),c=o("./stream/GenericWorker"),l=new Array(256),g=0;g<256;g++)l[g]=252<=g?6:248<=g?5:240<=g?4:224<=g?3:192<=g?2:1;l[254]=l[254]=1;function u(){c.call(this,"utf-8 decode"),this.leftOver=null}function h(){c.call(this,"utf-8 encode")}r.utf8encode=function(d){return a.nodebuffer?A.newBufferFrom(d,"utf-8"):(function(_){var m,p,I,f,C,y=_.length,E=0;for(f=0;f<y;f++)(64512&(p=_.charCodeAt(f)))==55296&&f+1<y&&(64512&(I=_.charCodeAt(f+1)))==56320&&(p=65536+(p-55296<<10)+(I-56320),f++),E+=p<128?1:p<2048?2:p<65536?3:4;for(m=a.uint8array?new Uint8Array(E):new Array(E),f=C=0;C<E;f++)(64512&(p=_.charCodeAt(f)))==55296&&f+1<y&&(64512&(I=_.charCodeAt(f+1)))==56320&&(p=65536+(p-55296<<10)+(I-56320),f++),p<128?m[C++]=p:(p<2048?m[C++]=192|p>>>6:(p<65536?m[C++]=224|p>>>12:(m[C++]=240|p>>>18,m[C++]=128|p>>>12&63),m[C++]=128|p>>>6&63),m[C++]=128|63&p);return m})(d)},r.utf8decode=function(d){return a.nodebuffer?s.transformTo("nodebuffer",d).toString("utf-8"):(function(_){var m,p,I,f,C=_.length,y=new Array(2*C);for(m=p=0;m<C;)if((I=_[m++])<128)y[p++]=I;else if(4<(f=l[I]))y[p++]=65533,m+=f-1;else{for(I&=f===2?31:f===3?15:7;1<f&&m<C;)I=I<<6|63&_[m++],f--;1<f?y[p++]=65533:I<65536?y[p++]=I:(I-=65536,y[p++]=55296|I>>10&1023,y[p++]=56320|1023&I)}return y.length!==p&&(y.subarray?y=y.subarray(0,p):y.length=p),s.applyFromCharCode(y)})(d=s.transformTo(a.uint8array?"uint8array":"array",d))},s.inherits(u,c),u.prototype.processChunk=function(d){var _=s.transformTo(a.uint8array?"uint8array":"array",d.data);if(this.leftOver&&this.leftOver.length){if(a.uint8array){var m=_;(_=new Uint8Array(m.length+this.leftOver.length)).set(this.leftOver,0),_.set(m,this.leftOver.length)}else _=this.leftOver.concat(_);this.leftOver=null}var p=(function(f,C){var y;for((C=C||f.length)>f.length&&(C=f.length),y=C-1;0<=y&&(192&f[y])==128;)y--;return y<0||y===0?C:y+l[f[y]]>C?y:C})(_),I=_;p!==_.length&&(a.uint8array?(I=_.subarray(0,p),this.leftOver=_.subarray(p,_.length)):(I=_.slice(0,p),this.leftOver=_.slice(p,_.length))),this.push({data:r.utf8decode(I),meta:d.meta})},u.prototype.flush=function(){this.leftOver&&this.leftOver.length&&(this.push({data:r.utf8decode(this.leftOver),meta:{}}),this.leftOver=null)},r.Utf8DecodeWorker=u,s.inherits(h,c),h.prototype.processChunk=function(d){this.push({data:r.utf8encode(d.data),meta:d.meta})},r.Utf8EncodeWorker=h},{"./nodejsUtils":14,"./stream/GenericWorker":28,"./support":30,"./utils":32}],32:[function(o,i,r){var s=o("./support"),a=o("./base64"),A=o("./nodejsUtils"),c=o("./external");function l(m){return m}function g(m,p){for(var I=0;I<m.length;++I)p[I]=255&m.charCodeAt(I);return p}o("setimmediate"),r.newBlob=function(m,p){r.checkSupport("blob");try{return new Blob([m],{type:p})}catch{try{var I=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);return I.append(m),I.getBlob(p)}catch{throw new Error("Bug : can't construct the Blob.")}}};var u={stringifyByChunk:function(m,p,I){var f=[],C=0,y=m.length;if(y<=I)return String.fromCharCode.apply(null,m);for(;C<y;)p==="array"||p==="nodebuffer"?f.push(String.fromCharCode.apply(null,m.slice(C,Math.min(C+I,y)))):f.push(String.fromCharCode.apply(null,m.subarray(C,Math.min(C+I,y)))),C+=I;return f.join("")},stringifyByChar:function(m){for(var p="",I=0;I<m.length;I++)p+=String.fromCharCode(m[I]);return p},applyCanBeUsed:{uint8array:(function(){try{return s.uint8array&&String.fromCharCode.apply(null,new Uint8Array(1)).length===1}catch{return!1}})(),nodebuffer:(function(){try{return s.nodebuffer&&String.fromCharCode.apply(null,A.allocBuffer(1)).length===1}catch{return!1}})()}};function h(m){var p=65536,I=r.getTypeOf(m),f=!0;if(I==="uint8array"?f=u.applyCanBeUsed.uint8array:I==="nodebuffer"&&(f=u.applyCanBeUsed.nodebuffer),f)for(;1<p;)try{return u.stringifyByChunk(m,I,p)}catch{p=Math.floor(p/2)}return u.stringifyByChar(m)}function d(m,p){for(var I=0;I<m.length;I++)p[I]=m[I];return p}r.applyFromCharCode=h;var _={};_.string={string:l,array:function(m){return g(m,new Array(m.length))},arraybuffer:function(m){return _.string.uint8array(m).buffer},uint8array:function(m){return g(m,new Uint8Array(m.length))},nodebuffer:function(m){return g(m,A.allocBuffer(m.length))}},_.array={string:h,array:l,arraybuffer:function(m){return new Uint8Array(m).buffer},uint8array:function(m){return new Uint8Array(m)},nodebuffer:function(m){return A.newBufferFrom(m)}},_.arraybuffer={string:function(m){return h(new Uint8Array(m))},array:function(m){return d(new Uint8Array(m),new Array(m.byteLength))},arraybuffer:l,uint8array:function(m){return new Uint8Array(m)},nodebuffer:function(m){return A.newBufferFrom(new Uint8Array(m))}},_.uint8array={string:h,array:function(m){return d(m,new Array(m.length))},arraybuffer:function(m){return m.buffer},uint8array:l,nodebuffer:function(m){return A.newBufferFrom(m)}},_.nodebuffer={string:h,array:function(m){return d(m,new Array(m.length))},arraybuffer:function(m){return _.nodebuffer.uint8array(m).buffer},uint8array:function(m){return d(m,new Uint8Array(m.length))},nodebuffer:l},r.transformTo=function(m,p){if(p=p||"",!m)return p;r.checkSupport(m);var I=r.getTypeOf(p);return _[I][m](p)},r.resolve=function(m){for(var p=m.split("/"),I=[],f=0;f<p.length;f++){var C=p[f];C==="."||C===""&&f!==0&&f!==p.length-1||(C===".."?I.pop():I.push(C))}return I.join("/")},r.getTypeOf=function(m){return typeof m=="string"?"string":Object.prototype.toString.call(m)==="[object Array]"?"array":s.nodebuffer&&A.isBuffer(m)?"nodebuffer":s.uint8array&&m instanceof Uint8Array?"uint8array":s.arraybuffer&&m instanceof ArrayBuffer?"arraybuffer":void 0},r.checkSupport=function(m){if(!s[m.toLowerCase()])throw new Error(m+" is not supported by this platform")},r.MAX_VALUE_16BITS=65535,r.MAX_VALUE_32BITS=-1,r.pretty=function(m){var p,I,f="";for(I=0;I<(m||"").length;I++)f+="\\x"+((p=m.charCodeAt(I))<16?"0":"")+p.toString(16).toUpperCase();return f},r.delay=function(m,p,I){setImmediate(function(){m.apply(I||null,p||[])})},r.inherits=function(m,p){function I(){}I.prototype=p.prototype,m.prototype=new I},r.extend=function(){var m,p,I={};for(m=0;m<arguments.length;m++)for(p in arguments[m])Object.prototype.hasOwnProperty.call(arguments[m],p)&&I[p]===void 0&&(I[p]=arguments[m][p]);return I},r.prepareContent=function(m,p,I,f,C){return c.Promise.resolve(p).then(function(y){return s.blob&&(y instanceof Blob||["[object File]","[object Blob]"].indexOf(Object.prototype.toString.call(y))!==-1)&&typeof FileReader<"u"?new c.Promise(function(E,B){var Q=new FileReader;Q.onload=function(b){E(b.target.result)},Q.onerror=function(b){B(b.target.error)},Q.readAsArrayBuffer(y)}):y}).then(function(y){var E=r.getTypeOf(y);return E?(E==="arraybuffer"?y=r.transformTo("uint8array",y):E==="string"&&(C?y=a.decode(y):I&&f!==!0&&(y=(function(B){return g(B,s.uint8array?new Uint8Array(B.length):new Array(B.length))})(y))),y):c.Promise.reject(new Error("Can't read the data of '"+m+"'. Is it in a supported JavaScript type (String, Blob, ArrayBuffer, etc) ?"))})}},{"./base64":1,"./external":6,"./nodejsUtils":14,"./support":30,setimmediate:54}],33:[function(o,i,r){var s=o("./reader/readerFor"),a=o("./utils"),A=o("./signature"),c=o("./zipEntry"),l=o("./support");function g(u){this.files=[],this.loadOptions=u}g.prototype={checkSignature:function(u){if(!this.reader.readAndCheckSignature(u)){this.reader.index-=4;var h=this.reader.readString(4);throw new Error("Corrupted zip or bug: unexpected signature ("+a.pretty(h)+", expected "+a.pretty(u)+")")}},isSignature:function(u,h){var d=this.reader.index;this.reader.setIndex(u);var _=this.reader.readString(4)===h;return this.reader.setIndex(d),_},readBlockEndOfCentral:function(){this.diskNumber=this.reader.readInt(2),this.diskWithCentralDirStart=this.reader.readInt(2),this.centralDirRecordsOnThisDisk=this.reader.readInt(2),this.centralDirRecords=this.reader.readInt(2),this.centralDirSize=this.reader.readInt(4),this.centralDirOffset=this.reader.readInt(4),this.zipCommentLength=this.reader.readInt(2);var u=this.reader.readData(this.zipCommentLength),h=l.uint8array?"uint8array":"array",d=a.transformTo(h,u);this.zipComment=this.loadOptions.decodeFileName(d)},readBlockZip64EndOfCentral:function(){this.zip64EndOfCentralSize=this.reader.readInt(8),this.reader.skip(4),this.diskNumber=this.reader.readInt(4),this.diskWithCentralDirStart=this.reader.readInt(4),this.centralDirRecordsOnThisDisk=this.reader.readInt(8),this.centralDirRecords=this.reader.readInt(8),this.centralDirSize=this.reader.readInt(8),this.centralDirOffset=this.reader.readInt(8),this.zip64ExtensibleData={};for(var u,h,d,_=this.zip64EndOfCentralSize-44;0<_;)u=this.reader.readInt(2),h=this.reader.readInt(4),d=this.reader.readData(h),this.zip64ExtensibleData[u]={id:u,length:h,value:d}},readBlockZip64EndOfCentralLocator:function(){if(this.diskWithZip64CentralDirStart=this.reader.readInt(4),this.relativeOffsetEndOfZip64CentralDir=this.reader.readInt(8),this.disksCount=this.reader.readInt(4),1<this.disksCount)throw new Error("Multi-volumes zip are not supported")},readLocalFiles:function(){var u,h;for(u=0;u<this.files.length;u++)h=this.files[u],this.reader.setIndex(h.localHeaderOffset),this.checkSignature(A.LOCAL_FILE_HEADER),h.readLocalPart(this.reader),h.handleUTF8(),h.processAttributes()},readCentralDir:function(){var u;for(this.reader.setIndex(this.centralDirOffset);this.reader.readAndCheckSignature(A.CENTRAL_FILE_HEADER);)(u=new c({zip64:this.zip64},this.loadOptions)).readCentralPart(this.reader),this.files.push(u);if(this.centralDirRecords!==this.files.length&&this.centralDirRecords!==0&&this.files.length===0)throw new Error("Corrupted zip or bug: expected "+this.centralDirRecords+" records in central dir, got "+this.files.length)},readEndOfCentral:function(){var u=this.reader.lastIndexOfSignature(A.CENTRAL_DIRECTORY_END);if(u<0)throw this.isSignature(0,A.LOCAL_FILE_HEADER)?new Error("Corrupted zip: can't find end of central directory"):new Error("Can't find end of central directory : is this a zip file ? If it is, see https://stuk.github.io/jszip/documentation/howto/read_zip.html");this.reader.setIndex(u);var h=u;if(this.checkSignature(A.CENTRAL_DIRECTORY_END),this.readBlockEndOfCentral(),this.diskNumber===a.MAX_VALUE_16BITS||this.diskWithCentralDirStart===a.MAX_VALUE_16BITS||this.centralDirRecordsOnThisDisk===a.MAX_VALUE_16BITS||this.centralDirRecords===a.MAX_VALUE_16BITS||this.centralDirSize===a.MAX_VALUE_32BITS||this.centralDirOffset===a.MAX_VALUE_32BITS){if(this.zip64=!0,(u=this.reader.lastIndexOfSignature(A.ZIP64_CENTRAL_DIRECTORY_LOCATOR))<0)throw new Error("Corrupted zip: can't find the ZIP64 end of central directory locator");if(this.reader.setIndex(u),this.checkSignature(A.ZIP64_CENTRAL_DIRECTORY_LOCATOR),this.readBlockZip64EndOfCentralLocator(),!this.isSignature(this.relativeOffsetEndOfZip64CentralDir,A.ZIP64_CENTRAL_DIRECTORY_END)&&(this.relativeOffsetEndOfZip64CentralDir=this.reader.lastIndexOfSignature(A.ZIP64_CENTRAL_DIRECTORY_END),this.relativeOffsetEndOfZip64CentralDir<0))throw new Error("Corrupted zip: can't find the ZIP64 end of central directory");this.reader.setIndex(this.relativeOffsetEndOfZip64CentralDir),this.checkSignature(A.ZIP64_CENTRAL_DIRECTORY_END),this.readBlockZip64EndOfCentral()}var d=this.centralDirOffset+this.centralDirSize;this.zip64&&(d+=20,d+=12+this.zip64EndOfCentralSize);var _=h-d;if(0<_)this.isSignature(h,A.CENTRAL_FILE_HEADER)||(this.reader.zero=_);else if(_<0)throw new Error("Corrupted zip: missing "+Math.abs(_)+" bytes.")},prepareReader:function(u){this.reader=s(u)},load:function(u){this.prepareReader(u),this.readEndOfCentral(),this.readCentralDir(),this.readLocalFiles()}},i.exports=g},{"./reader/readerFor":22,"./signature":23,"./support":30,"./utils":32,"./zipEntry":34}],34:[function(o,i,r){var s=o("./reader/readerFor"),a=o("./utils"),A=o("./compressedObject"),c=o("./crc32"),l=o("./utf8"),g=o("./compressions"),u=o("./support");function h(d,_){this.options=d,this.loadOptions=_}h.prototype={isEncrypted:function(){return(1&this.bitFlag)==1},useUTF8:function(){return(2048&this.bitFlag)==2048},readLocalPart:function(d){var _,m;if(d.skip(22),this.fileNameLength=d.readInt(2),m=d.readInt(2),this.fileName=d.readData(this.fileNameLength),d.skip(m),this.compressedSize===-1||this.uncompressedSize===-1)throw new Error("Bug or corrupted zip : didn't get enough information from the central directory (compressedSize === -1 || uncompressedSize === -1)");if((_=(function(p){for(var I in g)if(Object.prototype.hasOwnProperty.call(g,I)&&g[I].magic===p)return g[I];return null})(this.compressionMethod))===null)throw new Error("Corrupted zip : compression "+a.pretty(this.compressionMethod)+" unknown (inner file : "+a.transformTo("string",this.fileName)+")");this.decompressed=new A(this.compressedSize,this.uncompressedSize,this.crc32,_,d.readData(this.compressedSize))},readCentralPart:function(d){this.versionMadeBy=d.readInt(2),d.skip(2),this.bitFlag=d.readInt(2),this.compressionMethod=d.readString(2),this.date=d.readDate(),this.crc32=d.readInt(4),this.compressedSize=d.readInt(4),this.uncompressedSize=d.readInt(4);var _=d.readInt(2);if(this.extraFieldsLength=d.readInt(2),this.fileCommentLength=d.readInt(2),this.diskNumberStart=d.readInt(2),this.internalFileAttributes=d.readInt(2),this.externalFileAttributes=d.readInt(4),this.localHeaderOffset=d.readInt(4),this.isEncrypted())throw new Error("Encrypted zip are not supported");d.skip(_),this.readExtraFields(d),this.parseZIP64ExtraField(d),this.fileComment=d.readData(this.fileCommentLength)},processAttributes:function(){this.unixPermissions=null,this.dosPermissions=null;var d=this.versionMadeBy>>8;this.dir=!!(16&this.externalFileAttributes),d==0&&(this.dosPermissions=63&this.externalFileAttributes),d==3&&(this.unixPermissions=this.externalFileAttributes>>16&65535),this.dir||this.fileNameStr.slice(-1)!=="/"||(this.dir=!0)},parseZIP64ExtraField:function(){if(this.extraFields[1]){var d=s(this.extraFields[1].value);this.uncompressedSize===a.MAX_VALUE_32BITS&&(this.uncompressedSize=d.readInt(8)),this.compressedSize===a.MAX_VALUE_32BITS&&(this.compressedSize=d.readInt(8)),this.localHeaderOffset===a.MAX_VALUE_32BITS&&(this.localHeaderOffset=d.readInt(8)),this.diskNumberStart===a.MAX_VALUE_32BITS&&(this.diskNumberStart=d.readInt(4))}},readExtraFields:function(d){var _,m,p,I=d.index+this.extraFieldsLength;for(this.extraFields||(this.extraFields={});d.index+4<I;)_=d.readInt(2),m=d.readInt(2),p=d.readData(m),this.extraFields[_]={id:_,length:m,value:p};d.setIndex(I)},handleUTF8:function(){var d=u.uint8array?"uint8array":"array";if(this.useUTF8())this.fileNameStr=l.utf8decode(this.fileName),this.fileCommentStr=l.utf8decode(this.fileComment);else{var _=this.findExtraFieldUnicodePath();if(_!==null)this.fileNameStr=_;else{var m=a.transformTo(d,this.fileName);this.fileNameStr=this.loadOptions.decodeFileName(m)}var p=this.findExtraFieldUnicodeComment();if(p!==null)this.fileCommentStr=p;else{var I=a.transformTo(d,this.fileComment);this.fileCommentStr=this.loadOptions.decodeFileName(I)}}},findExtraFieldUnicodePath:function(){var d=this.extraFields[28789];if(d){var _=s(d.value);return _.readInt(1)!==1||c(this.fileName)!==_.readInt(4)?null:l.utf8decode(_.readData(d.length-5))}return null},findExtraFieldUnicodeComment:function(){var d=this.extraFields[25461];if(d){var _=s(d.value);return _.readInt(1)!==1||c(this.fileComment)!==_.readInt(4)?null:l.utf8decode(_.readData(d.length-5))}return null}},i.exports=h},{"./compressedObject":2,"./compressions":3,"./crc32":4,"./reader/readerFor":22,"./support":30,"./utf8":31,"./utils":32}],35:[function(o,i,r){function s(_,m,p){this.name=_,this.dir=p.dir,this.date=p.date,this.comment=p.comment,this.unixPermissions=p.unixPermissions,this.dosPermissions=p.dosPermissions,this._data=m,this._dataBinary=p.binary,this.options={compression:p.compression,compressionOptions:p.compressionOptions}}var a=o("./stream/StreamHelper"),A=o("./stream/DataWorker"),c=o("./utf8"),l=o("./compressedObject"),g=o("./stream/GenericWorker");s.prototype={internalStream:function(_){var m=null,p="string";try{if(!_)throw new Error("No output type specified.");var I=(p=_.toLowerCase())==="string"||p==="text";p!=="binarystring"&&p!=="text"||(p="string"),m=this._decompressWorker();var f=!this._dataBinary;f&&!I&&(m=m.pipe(new c.Utf8EncodeWorker)),!f&&I&&(m=m.pipe(new c.Utf8DecodeWorker))}catch(C){(m=new g("error")).error(C)}return new a(m,p,"")},async:function(_,m){return this.internalStream(_).accumulate(m)},nodeStream:function(_,m){return this.internalStream(_||"nodebuffer").toNodejsStream(m)},_compressWorker:function(_,m){if(this._data instanceof l&&this._data.compression.magic===_.magic)return this._data.getCompressedWorker();var p=this._decompressWorker();return this._dataBinary||(p=p.pipe(new c.Utf8EncodeWorker)),l.createWorkerFrom(p,_,m)},_decompressWorker:function(){return this._data instanceof l?this._data.getContentWorker():this._data instanceof g?this._data:new A(this._data)}};for(var u=["asText","asBinary","asNodeBuffer","asUint8Array","asArrayBuffer"],h=function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},d=0;d<u.length;d++)s.prototype[u[d]]=h;i.exports=s},{"./compressedObject":2,"./stream/DataWorker":27,"./stream/GenericWorker":28,"./stream/StreamHelper":29,"./utf8":31}],36:[function(o,i,r){(function(s){var a,A,c=s.MutationObserver||s.WebKitMutationObserver;if(c){var l=0,g=new c(_),u=s.document.createTextNode("");g.observe(u,{characterData:!0}),a=function(){u.data=l=++l%2}}else if(s.setImmediate||s.MessageChannel===void 0)a="document"in s&&"onreadystatechange"in s.document.createElement("script")?function(){var m=s.document.createElement("script");m.onreadystatechange=function(){_(),m.onreadystatechange=null,m.parentNode.removeChild(m),m=null},s.document.documentElement.appendChild(m)}:function(){setTimeout(_,0)};else{var h=new s.MessageChannel;h.port1.onmessage=_,a=function(){h.port2.postMessage(0)}}var d=[];function _(){var m,p;A=!0;for(var I=d.length;I;){for(p=d,d=[],m=-1;++m<I;)p[m]();I=d.length}A=!1}i.exports=function(m){d.push(m)!==1||A||a()}}).call(this,typeof PC<"u"?PC:typeof self<"u"?self:typeof window<"u"?window:{})},{}],37:[function(o,i,r){var s=o("immediate");function a(){}var A={},c=["REJECTED"],l=["FULFILLED"],g=["PENDING"];function u(I){if(typeof I!="function")throw new TypeError("resolver must be a function");this.state=g,this.queue=[],this.outcome=void 0,I!==a&&m(this,I)}function h(I,f,C){this.promise=I,typeof f=="function"&&(this.onFulfilled=f,this.callFulfilled=this.otherCallFulfilled),typeof C=="function"&&(this.onRejected=C,this.callRejected=this.otherCallRejected)}function d(I,f,C){s(function(){var y;try{y=f(C)}catch(E){return A.reject(I,E)}y===I?A.reject(I,new TypeError("Cannot resolve promise with itself")):A.resolve(I,y)})}function _(I){var f=I&&I.then;if(I&&(typeof I=="object"||typeof I=="function")&&typeof f=="function")return function(){f.apply(I,arguments)}}function m(I,f){var C=!1;function y(Q){C||(C=!0,A.reject(I,Q))}function E(Q){C||(C=!0,A.resolve(I,Q))}var B=p(function(){f(E,y)});B.status==="error"&&y(B.value)}function p(I,f){var C={};try{C.value=I(f),C.status="success"}catch(y){C.status="error",C.value=y}return C}(i.exports=u).prototype.finally=function(I){if(typeof I!="function")return this;var f=this.constructor;return this.then(function(C){return f.resolve(I()).then(function(){return C})},function(C){return f.resolve(I()).then(function(){throw C})})},u.prototype.catch=function(I){return this.then(null,I)},u.prototype.then=function(I,f){if(typeof I!="function"&&this.state===l||typeof f!="function"&&this.state===c)return this;var C=new this.constructor(a);return this.state!==g?d(C,this.state===l?I:f,this.outcome):this.queue.push(new h(C,I,f)),C},h.prototype.callFulfilled=function(I){A.resolve(this.promise,I)},h.prototype.otherCallFulfilled=function(I){d(this.promise,this.onFulfilled,I)},h.prototype.callRejected=function(I){A.reject(this.promise,I)},h.prototype.otherCallRejected=function(I){d(this.promise,this.onRejected,I)},A.resolve=function(I,f){var C=p(_,f);if(C.status==="error")return A.reject(I,C.value);var y=C.value;if(y)m(I,y);else{I.state=l,I.outcome=f;for(var E=-1,B=I.queue.length;++E<B;)I.queue[E].callFulfilled(f)}return I},A.reject=function(I,f){I.state=c,I.outcome=f;for(var C=-1,y=I.queue.length;++C<y;)I.queue[C].callRejected(f);return I},u.resolve=function(I){return I instanceof this?I:A.resolve(new this(a),I)},u.reject=function(I){var f=new this(a);return A.reject(f,I)},u.all=function(I){var f=this;if(Object.prototype.toString.call(I)!=="[object Array]")return this.reject(new TypeError("must be an array"));var C=I.length,y=!1;if(!C)return this.resolve([]);for(var E=new Array(C),B=0,Q=-1,b=new this(a);++Q<C;)D(I[Q],Q);return b;function D(R,M){f.resolve(R).then(function(L){E[M]=L,++B!==C||y||(y=!0,A.resolve(b,E))},function(L){y||(y=!0,A.reject(b,L))})}},u.race=function(I){var f=this;if(Object.prototype.toString.call(I)!=="[object Array]")return this.reject(new TypeError("must be an array"));var C=I.length,y=!1;if(!C)return this.resolve([]);for(var E=-1,B=new this(a);++E<C;)Q=I[E],f.resolve(Q).then(function(b){y||(y=!0,A.resolve(B,b))},function(b){y||(y=!0,A.reject(B,b))});var Q;return B}},{immediate:36}],38:[function(o,i,r){var s={};(0,o("./lib/utils/common").assign)(s,o("./lib/deflate"),o("./lib/inflate"),o("./lib/zlib/constants")),i.exports=s},{"./lib/deflate":39,"./lib/inflate":40,"./lib/utils/common":41,"./lib/zlib/constants":44}],39:[function(o,i,r){var s=o("./zlib/deflate"),a=o("./utils/common"),A=o("./utils/strings"),c=o("./zlib/messages"),l=o("./zlib/zstream"),g=Object.prototype.toString,u=0,h=-1,d=0,_=8;function m(I){if(!(this instanceof m))return new m(I);this.options=a.assign({level:h,method:_,chunkSize:16384,windowBits:15,memLevel:8,strategy:d,to:""},I||{});var f=this.options;f.raw&&0<f.windowBits?f.windowBits=-f.windowBits:f.gzip&&0<f.windowBits&&f.windowBits<16&&(f.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new l,this.strm.avail_out=0;var C=s.deflateInit2(this.strm,f.level,f.method,f.windowBits,f.memLevel,f.strategy);if(C!==u)throw new Error(c[C]);if(f.header&&s.deflateSetHeader(this.strm,f.header),f.dictionary){var y;if(y=typeof f.dictionary=="string"?A.string2buf(f.dictionary):g.call(f.dictionary)==="[object ArrayBuffer]"?new Uint8Array(f.dictionary):f.dictionary,(C=s.deflateSetDictionary(this.strm,y))!==u)throw new Error(c[C]);this._dict_set=!0}}function p(I,f){var C=new m(f);if(C.push(I,!0),C.err)throw C.msg||c[C.err];return C.result}m.prototype.push=function(I,f){var C,y,E=this.strm,B=this.options.chunkSize;if(this.ended)return!1;y=f===~~f?f:f===!0?4:0,typeof I=="string"?E.input=A.string2buf(I):g.call(I)==="[object ArrayBuffer]"?E.input=new Uint8Array(I):E.input=I,E.next_in=0,E.avail_in=E.input.length;do{if(E.avail_out===0&&(E.output=new a.Buf8(B),E.next_out=0,E.avail_out=B),(C=s.deflate(E,y))!==1&&C!==u)return this.onEnd(C),!(this.ended=!0);E.avail_out!==0&&(E.avail_in!==0||y!==4&&y!==2)||(this.options.to==="string"?this.onData(A.buf2binstring(a.shrinkBuf(E.output,E.next_out))):this.onData(a.shrinkBuf(E.output,E.next_out)))}while((0<E.avail_in||E.avail_out===0)&&C!==1);return y===4?(C=s.deflateEnd(this.strm),this.onEnd(C),this.ended=!0,C===u):y!==2||(this.onEnd(u),!(E.avail_out=0))},m.prototype.onData=function(I){this.chunks.push(I)},m.prototype.onEnd=function(I){I===u&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=a.flattenChunks(this.chunks)),this.chunks=[],this.err=I,this.msg=this.strm.msg},r.Deflate=m,r.deflate=p,r.deflateRaw=function(I,f){return(f=f||{}).raw=!0,p(I,f)},r.gzip=function(I,f){return(f=f||{}).gzip=!0,p(I,f)}},{"./utils/common":41,"./utils/strings":42,"./zlib/deflate":46,"./zlib/messages":51,"./zlib/zstream":53}],40:[function(o,i,r){var s=o("./zlib/inflate"),a=o("./utils/common"),A=o("./utils/strings"),c=o("./zlib/constants"),l=o("./zlib/messages"),g=o("./zlib/zstream"),u=o("./zlib/gzheader"),h=Object.prototype.toString;function d(m){if(!(this instanceof d))return new d(m);this.options=a.assign({chunkSize:16384,windowBits:0,to:""},m||{});var p=this.options;p.raw&&0<=p.windowBits&&p.windowBits<16&&(p.windowBits=-p.windowBits,p.windowBits===0&&(p.windowBits=-15)),!(0<=p.windowBits&&p.windowBits<16)||m&&m.windowBits||(p.windowBits+=32),15<p.windowBits&&p.windowBits<48&&(15&p.windowBits)==0&&(p.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new g,this.strm.avail_out=0;var I=s.inflateInit2(this.strm,p.windowBits);if(I!==c.Z_OK)throw new Error(l[I]);this.header=new u,s.inflateGetHeader(this.strm,this.header)}function _(m,p){var I=new d(p);if(I.push(m,!0),I.err)throw I.msg||l[I.err];return I.result}d.prototype.push=function(m,p){var I,f,C,y,E,B,Q=this.strm,b=this.options.chunkSize,D=this.options.dictionary,R=!1;if(this.ended)return!1;f=p===~~p?p:p===!0?c.Z_FINISH:c.Z_NO_FLUSH,typeof m=="string"?Q.input=A.binstring2buf(m):h.call(m)==="[object ArrayBuffer]"?Q.input=new Uint8Array(m):Q.input=m,Q.next_in=0,Q.avail_in=Q.input.length;do{if(Q.avail_out===0&&(Q.output=new a.Buf8(b),Q.next_out=0,Q.avail_out=b),(I=s.inflate(Q,c.Z_NO_FLUSH))===c.Z_NEED_DICT&&D&&(B=typeof D=="string"?A.string2buf(D):h.call(D)==="[object ArrayBuffer]"?new Uint8Array(D):D,I=s.inflateSetDictionary(this.strm,B)),I===c.Z_BUF_ERROR&&R===!0&&(I=c.Z_OK,R=!1),I!==c.Z_STREAM_END&&I!==c.Z_OK)return this.onEnd(I),!(this.ended=!0);Q.next_out&&(Q.avail_out!==0&&I!==c.Z_STREAM_END&&(Q.avail_in!==0||f!==c.Z_FINISH&&f!==c.Z_SYNC_FLUSH)||(this.options.to==="string"?(C=A.utf8border(Q.output,Q.next_out),y=Q.next_out-C,E=A.buf2string(Q.output,C),Q.next_out=y,Q.avail_out=b-y,y&&a.arraySet(Q.output,Q.output,C,y,0),this.onData(E)):this.onData(a.shrinkBuf(Q.output,Q.next_out)))),Q.avail_in===0&&Q.avail_out===0&&(R=!0)}while((0<Q.avail_in||Q.avail_out===0)&&I!==c.Z_STREAM_END);return I===c.Z_STREAM_END&&(f=c.Z_FINISH),f===c.Z_FINISH?(I=s.inflateEnd(this.strm),this.onEnd(I),this.ended=!0,I===c.Z_OK):f!==c.Z_SYNC_FLUSH||(this.onEnd(c.Z_OK),!(Q.avail_out=0))},d.prototype.onData=function(m){this.chunks.push(m)},d.prototype.onEnd=function(m){m===c.Z_OK&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=a.flattenChunks(this.chunks)),this.chunks=[],this.err=m,this.msg=this.strm.msg},r.Inflate=d,r.inflate=_,r.inflateRaw=function(m,p){return(p=p||{}).raw=!0,_(m,p)},r.ungzip=_},{"./utils/common":41,"./utils/strings":42,"./zlib/constants":44,"./zlib/gzheader":47,"./zlib/inflate":49,"./zlib/messages":51,"./zlib/zstream":53}],41:[function(o,i,r){var s=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Int32Array<"u";r.assign=function(c){for(var l=Array.prototype.slice.call(arguments,1);l.length;){var g=l.shift();if(g){if(typeof g!="object")throw new TypeError(g+"must be non-object");for(var u in g)g.hasOwnProperty(u)&&(c[u]=g[u])}}return c},r.shrinkBuf=function(c,l){return c.length===l?c:c.subarray?c.subarray(0,l):(c.length=l,c)};var a={arraySet:function(c,l,g,u,h){if(l.subarray&&c.subarray)c.set(l.subarray(g,g+u),h);else for(var d=0;d<u;d++)c[h+d]=l[g+d]},flattenChunks:function(c){var l,g,u,h,d,_;for(l=u=0,g=c.length;l<g;l++)u+=c[l].length;for(_=new Uint8Array(u),l=h=0,g=c.length;l<g;l++)d=c[l],_.set(d,h),h+=d.length;return _}},A={arraySet:function(c,l,g,u,h){for(var d=0;d<u;d++)c[h+d]=l[g+d]},flattenChunks:function(c){return[].concat.apply([],c)}};r.setTyped=function(c){c?(r.Buf8=Uint8Array,r.Buf16=Uint16Array,r.Buf32=Int32Array,r.assign(r,a)):(r.Buf8=Array,r.Buf16=Array,r.Buf32=Array,r.assign(r,A))},r.setTyped(s)},{}],42:[function(o,i,r){var s=o("./common"),a=!0,A=!0;try{String.fromCharCode.apply(null,[0])}catch{a=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch{A=!1}for(var c=new s.Buf8(256),l=0;l<256;l++)c[l]=252<=l?6:248<=l?5:240<=l?4:224<=l?3:192<=l?2:1;function g(u,h){if(h<65537&&(u.subarray&&A||!u.subarray&&a))return String.fromCharCode.apply(null,s.shrinkBuf(u,h));for(var d="",_=0;_<h;_++)d+=String.fromCharCode(u[_]);return d}c[254]=c[254]=1,r.string2buf=function(u){var h,d,_,m,p,I=u.length,f=0;for(m=0;m<I;m++)(64512&(d=u.charCodeAt(m)))==55296&&m+1<I&&(64512&(_=u.charCodeAt(m+1)))==56320&&(d=65536+(d-55296<<10)+(_-56320),m++),f+=d<128?1:d<2048?2:d<65536?3:4;for(h=new s.Buf8(f),m=p=0;p<f;m++)(64512&(d=u.charCodeAt(m)))==55296&&m+1<I&&(64512&(_=u.charCodeAt(m+1)))==56320&&(d=65536+(d-55296<<10)+(_-56320),m++),d<128?h[p++]=d:(d<2048?h[p++]=192|d>>>6:(d<65536?h[p++]=224|d>>>12:(h[p++]=240|d>>>18,h[p++]=128|d>>>12&63),h[p++]=128|d>>>6&63),h[p++]=128|63&d);return h},r.buf2binstring=function(u){return g(u,u.length)},r.binstring2buf=function(u){for(var h=new s.Buf8(u.length),d=0,_=h.length;d<_;d++)h[d]=u.charCodeAt(d);return h},r.buf2string=function(u,h){var d,_,m,p,I=h||u.length,f=new Array(2*I);for(d=_=0;d<I;)if((m=u[d++])<128)f[_++]=m;else if(4<(p=c[m]))f[_++]=65533,d+=p-1;else{for(m&=p===2?31:p===3?15:7;1<p&&d<I;)m=m<<6|63&u[d++],p--;1<p?f[_++]=65533:m<65536?f[_++]=m:(m-=65536,f[_++]=55296|m>>10&1023,f[_++]=56320|1023&m)}return g(f,_)},r.utf8border=function(u,h){var d;for((h=h||u.length)>u.length&&(h=u.length),d=h-1;0<=d&&(192&u[d])==128;)d--;return d<0||d===0?h:d+c[u[d]]>h?d:h}},{"./common":41}],43:[function(o,i,r){i.exports=function(s,a,A,c){for(var l=65535&s|0,g=s>>>16&65535|0,u=0;A!==0;){for(A-=u=2e3<A?2e3:A;g=g+(l=l+a[c++]|0)|0,--u;);l%=65521,g%=65521}return l|g<<16|0}},{}],44:[function(o,i,r){i.exports={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8}},{}],45:[function(o,i,r){var s=(function(){for(var a,A=[],c=0;c<256;c++){a=c;for(var l=0;l<8;l++)a=1&a?3988292384^a>>>1:a>>>1;A[c]=a}return A})();i.exports=function(a,A,c,l){var g=s,u=l+c;a^=-1;for(var h=l;h<u;h++)a=a>>>8^g[255&(a^A[h])];return-1^a}},{}],46:[function(o,i,r){var s,a=o("../utils/common"),A=o("./trees"),c=o("./adler32"),l=o("./crc32"),g=o("./messages"),u=0,h=4,d=0,_=-2,m=-1,p=4,I=2,f=8,C=9,y=286,E=30,B=19,Q=2*y+1,b=15,D=3,R=258,M=R+D+1,L=42,G=113,O=1,U=2,W=3,j=4;function te(Ie,We){return Ie.msg=g[We],We}function ie(Ie){return(Ie<<1)-(4<Ie?9:0)}function $(Ie){for(var We=Ie.length;0<=--We;)Ie[We]=0}function Z(Ie){var We=Ie.state,Me=We.pending;Me>Ie.avail_out&&(Me=Ie.avail_out),Me!==0&&(a.arraySet(Ie.output,We.pending_buf,We.pending_out,Me,Ie.next_out),Ie.next_out+=Me,We.pending_out+=Me,Ie.total_out+=Me,Ie.avail_out-=Me,We.pending-=Me,We.pending===0&&(We.pending_out=0))}function se(Ie,We){A._tr_flush_block(Ie,0<=Ie.block_start?Ie.block_start:-1,Ie.strstart-Ie.block_start,We),Ie.block_start=Ie.strstart,Z(Ie.strm)}function ae(Ie,We){Ie.pending_buf[Ie.pending++]=We}function ce(Ie,We){Ie.pending_buf[Ie.pending++]=We>>>8&255,Ie.pending_buf[Ie.pending++]=255&We}function fe(Ie,We){var Me,Te,Ve=Ie.max_chain_length,Ne=Ie.strstart,Se=Ie.prev_length,Oe=Ie.nice_match,Pe=Ie.strstart>Ie.w_size-M?Ie.strstart-(Ie.w_size-M):0,qe=Ie.window,$e=Ie.w_mask,at=Ie.prev,ct=Ie.strstart+R,dt=qe[Ne+Se-1],gt=qe[Ne+Se];Ie.prev_length>=Ie.good_match&&(Ve>>=2),Oe>Ie.lookahead&&(Oe=Ie.lookahead);do if(qe[(Me=We)+Se]===gt&&qe[Me+Se-1]===dt&&qe[Me]===qe[Ne]&&qe[++Me]===qe[Ne+1]){Ne+=2,Me++;do;while(qe[++Ne]===qe[++Me]&&qe[++Ne]===qe[++Me]&&qe[++Ne]===qe[++Me]&&qe[++Ne]===qe[++Me]&&qe[++Ne]===qe[++Me]&&qe[++Ne]===qe[++Me]&&qe[++Ne]===qe[++Me]&&qe[++Ne]===qe[++Me]&&Ne<ct);if(Te=R-(ct-Ne),Ne=ct-R,Se<Te){if(Ie.match_start=We,Oe<=(Se=Te))break;dt=qe[Ne+Se-1],gt=qe[Ne+Se]}}while((We=at[We&$e])>Pe&&--Ve!=0);return Se<=Ie.lookahead?Se:Ie.lookahead}function Ce(Ie){var We,Me,Te,Ve,Ne,Se,Oe,Pe,qe,$e,at=Ie.w_size;do{if(Ve=Ie.window_size-Ie.lookahead-Ie.strstart,Ie.strstart>=at+(at-M)){for(a.arraySet(Ie.window,Ie.window,at,at,0),Ie.match_start-=at,Ie.strstart-=at,Ie.block_start-=at,We=Me=Ie.hash_size;Te=Ie.head[--We],Ie.head[We]=at<=Te?Te-at:0,--Me;);for(We=Me=at;Te=Ie.prev[--We],Ie.prev[We]=at<=Te?Te-at:0,--Me;);Ve+=at}if(Ie.strm.avail_in===0)break;if(Se=Ie.strm,Oe=Ie.window,Pe=Ie.strstart+Ie.lookahead,qe=Ve,$e=void 0,$e=Se.avail_in,qe<$e&&($e=qe),Me=$e===0?0:(Se.avail_in-=$e,a.arraySet(Oe,Se.input,Se.next_in,$e,Pe),Se.state.wrap===1?Se.adler=c(Se.adler,Oe,$e,Pe):Se.state.wrap===2&&(Se.adler=l(Se.adler,Oe,$e,Pe)),Se.next_in+=$e,Se.total_in+=$e,$e),Ie.lookahead+=Me,Ie.lookahead+Ie.insert>=D)for(Ne=Ie.strstart-Ie.insert,Ie.ins_h=Ie.window[Ne],Ie.ins_h=(Ie.ins_h<<Ie.hash_shift^Ie.window[Ne+1])&Ie.hash_mask;Ie.insert&&(Ie.ins_h=(Ie.ins_h<<Ie.hash_shift^Ie.window[Ne+D-1])&Ie.hash_mask,Ie.prev[Ne&Ie.w_mask]=Ie.head[Ie.ins_h],Ie.head[Ie.ins_h]=Ne,Ne++,Ie.insert--,!(Ie.lookahead+Ie.insert<D)););}while(Ie.lookahead<M&&Ie.strm.avail_in!==0)}function xe(Ie,We){for(var Me,Te;;){if(Ie.lookahead<M){if(Ce(Ie),Ie.lookahead<M&&We===u)return O;if(Ie.lookahead===0)break}if(Me=0,Ie.lookahead>=D&&(Ie.ins_h=(Ie.ins_h<<Ie.hash_shift^Ie.window[Ie.strstart+D-1])&Ie.hash_mask,Me=Ie.prev[Ie.strstart&Ie.w_mask]=Ie.head[Ie.ins_h],Ie.head[Ie.ins_h]=Ie.strstart),Me!==0&&Ie.strstart-Me<=Ie.w_size-M&&(Ie.match_length=fe(Ie,Me)),Ie.match_length>=D)if(Te=A._tr_tally(Ie,Ie.strstart-Ie.match_start,Ie.match_length-D),Ie.lookahead-=Ie.match_length,Ie.match_length<=Ie.max_lazy_match&&Ie.lookahead>=D){for(Ie.match_length--;Ie.strstart++,Ie.ins_h=(Ie.ins_h<<Ie.hash_shift^Ie.window[Ie.strstart+D-1])&Ie.hash_mask,Me=Ie.prev[Ie.strstart&Ie.w_mask]=Ie.head[Ie.ins_h],Ie.head[Ie.ins_h]=Ie.strstart,--Ie.match_length!=0;);Ie.strstart++}else Ie.strstart+=Ie.match_length,Ie.match_length=0,Ie.ins_h=Ie.window[Ie.strstart],Ie.ins_h=(Ie.ins_h<<Ie.hash_shift^Ie.window[Ie.strstart+1])&Ie.hash_mask;else Te=A._tr_tally(Ie,0,Ie.window[Ie.strstart]),Ie.lookahead--,Ie.strstart++;if(Te&&(se(Ie,!1),Ie.strm.avail_out===0))return O}return Ie.insert=Ie.strstart<D-1?Ie.strstart:D-1,We===h?(se(Ie,!0),Ie.strm.avail_out===0?W:j):Ie.last_lit&&(se(Ie,!1),Ie.strm.avail_out===0)?O:U}function de(Ie,We){for(var Me,Te,Ve;;){if(Ie.lookahead<M){if(Ce(Ie),Ie.lookahead<M&&We===u)return O;if(Ie.lookahead===0)break}if(Me=0,Ie.lookahead>=D&&(Ie.ins_h=(Ie.ins_h<<Ie.hash_shift^Ie.window[Ie.strstart+D-1])&Ie.hash_mask,Me=Ie.prev[Ie.strstart&Ie.w_mask]=Ie.head[Ie.ins_h],Ie.head[Ie.ins_h]=Ie.strstart),Ie.prev_length=Ie.match_length,Ie.prev_match=Ie.match_start,Ie.match_length=D-1,Me!==0&&Ie.prev_length<Ie.max_lazy_match&&Ie.strstart-Me<=Ie.w_size-M&&(Ie.match_length=fe(Ie,Me),Ie.match_length<=5&&(Ie.strategy===1||Ie.match_length===D&&4096<Ie.strstart-Ie.match_start)&&(Ie.match_length=D-1)),Ie.prev_length>=D&&Ie.match_length<=Ie.prev_length){for(Ve=Ie.strstart+Ie.lookahead-D,Te=A._tr_tally(Ie,Ie.strstart-1-Ie.prev_match,Ie.prev_length-D),Ie.lookahead-=Ie.prev_length-1,Ie.prev_length-=2;++Ie.strstart<=Ve&&(Ie.ins_h=(Ie.ins_h<<Ie.hash_shift^Ie.window[Ie.strstart+D-1])&Ie.hash_mask,Me=Ie.prev[Ie.strstart&Ie.w_mask]=Ie.head[Ie.ins_h],Ie.head[Ie.ins_h]=Ie.strstart),--Ie.prev_length!=0;);if(Ie.match_available=0,Ie.match_length=D-1,Ie.strstart++,Te&&(se(Ie,!1),Ie.strm.avail_out===0))return O}else if(Ie.match_available){if((Te=A._tr_tally(Ie,0,Ie.window[Ie.strstart-1]))&&se(Ie,!1),Ie.strstart++,Ie.lookahead--,Ie.strm.avail_out===0)return O}else Ie.match_available=1,Ie.strstart++,Ie.lookahead--}return Ie.match_available&&(Te=A._tr_tally(Ie,0,Ie.window[Ie.strstart-1]),Ie.match_available=0),Ie.insert=Ie.strstart<D-1?Ie.strstart:D-1,We===h?(se(Ie,!0),Ie.strm.avail_out===0?W:j):Ie.last_lit&&(se(Ie,!1),Ie.strm.avail_out===0)?O:U}function Ee(Ie,We,Me,Te,Ve){this.good_length=Ie,this.max_lazy=We,this.nice_length=Me,this.max_chain=Te,this.func=Ve}function he(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=f,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new a.Buf16(2*Q),this.dyn_dtree=new a.Buf16(2*(2*E+1)),this.bl_tree=new a.Buf16(2*(2*B+1)),$(this.dyn_ltree),$(this.dyn_dtree),$(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new a.Buf16(b+1),this.heap=new a.Buf16(2*y+1),$(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new a.Buf16(2*y+1),$(this.depth),this.l_buf=0,this.lit_bufsize=0,this.last_lit=0,this.d_buf=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}function ve(Ie){var We;return Ie&&Ie.state?(Ie.total_in=Ie.total_out=0,Ie.data_type=I,(We=Ie.state).pending=0,We.pending_out=0,We.wrap<0&&(We.wrap=-We.wrap),We.status=We.wrap?L:G,Ie.adler=We.wrap===2?0:1,We.last_flush=u,A._tr_init(We),d):te(Ie,_)}function Re(Ie){var We=ve(Ie);return We===d&&(function(Me){Me.window_size=2*Me.w_size,$(Me.head),Me.max_lazy_match=s[Me.level].max_lazy,Me.good_match=s[Me.level].good_length,Me.nice_match=s[Me.level].nice_length,Me.max_chain_length=s[Me.level].max_chain,Me.strstart=0,Me.block_start=0,Me.lookahead=0,Me.insert=0,Me.match_length=Me.prev_length=D-1,Me.match_available=0,Me.ins_h=0})(Ie.state),We}function ze(Ie,We,Me,Te,Ve,Ne){if(!Ie)return _;var Se=1;if(We===m&&(We=6),Te<0?(Se=0,Te=-Te):15<Te&&(Se=2,Te-=16),Ve<1||C<Ve||Me!==f||Te<8||15<Te||We<0||9<We||Ne<0||p<Ne)return te(Ie,_);Te===8&&(Te=9);var Oe=new he;return(Ie.state=Oe).strm=Ie,Oe.wrap=Se,Oe.gzhead=null,Oe.w_bits=Te,Oe.w_size=1<<Oe.w_bits,Oe.w_mask=Oe.w_size-1,Oe.hash_bits=Ve+7,Oe.hash_size=1<<Oe.hash_bits,Oe.hash_mask=Oe.hash_size-1,Oe.hash_shift=~~((Oe.hash_bits+D-1)/D),Oe.window=new a.Buf8(2*Oe.w_size),Oe.head=new a.Buf16(Oe.hash_size),Oe.prev=new a.Buf16(Oe.w_size),Oe.lit_bufsize=1<<Ve+6,Oe.pending_buf_size=4*Oe.lit_bufsize,Oe.pending_buf=new a.Buf8(Oe.pending_buf_size),Oe.d_buf=1*Oe.lit_bufsize,Oe.l_buf=3*Oe.lit_bufsize,Oe.level=We,Oe.strategy=Ne,Oe.method=Me,Re(Ie)}s=[new Ee(0,0,0,0,function(Ie,We){var Me=65535;for(Me>Ie.pending_buf_size-5&&(Me=Ie.pending_buf_size-5);;){if(Ie.lookahead<=1){if(Ce(Ie),Ie.lookahead===0&&We===u)return O;if(Ie.lookahead===0)break}Ie.strstart+=Ie.lookahead,Ie.lookahead=0;var Te=Ie.block_start+Me;if((Ie.strstart===0||Ie.strstart>=Te)&&(Ie.lookahead=Ie.strstart-Te,Ie.strstart=Te,se(Ie,!1),Ie.strm.avail_out===0)||Ie.strstart-Ie.block_start>=Ie.w_size-M&&(se(Ie,!1),Ie.strm.avail_out===0))return O}return Ie.insert=0,We===h?(se(Ie,!0),Ie.strm.avail_out===0?W:j):(Ie.strstart>Ie.block_start&&(se(Ie,!1),Ie.strm.avail_out),O)}),new Ee(4,4,8,4,xe),new Ee(4,5,16,8,xe),new Ee(4,6,32,32,xe),new Ee(4,4,16,16,de),new Ee(8,16,32,32,de),new Ee(8,16,128,128,de),new Ee(8,32,128,256,de),new Ee(32,128,258,1024,de),new Ee(32,258,258,4096,de)],r.deflateInit=function(Ie,We){return ze(Ie,We,f,15,8,0)},r.deflateInit2=ze,r.deflateReset=Re,r.deflateResetKeep=ve,r.deflateSetHeader=function(Ie,We){return Ie&&Ie.state?Ie.state.wrap!==2?_:(Ie.state.gzhead=We,d):_},r.deflate=function(Ie,We){var Me,Te,Ve,Ne;if(!Ie||!Ie.state||5<We||We<0)return Ie?te(Ie,_):_;if(Te=Ie.state,!Ie.output||!Ie.input&&Ie.avail_in!==0||Te.status===666&&We!==h)return te(Ie,Ie.avail_out===0?-5:_);if(Te.strm=Ie,Me=Te.last_flush,Te.last_flush=We,Te.status===L)if(Te.wrap===2)Ie.adler=0,ae(Te,31),ae(Te,139),ae(Te,8),Te.gzhead?(ae(Te,(Te.gzhead.text?1:0)+(Te.gzhead.hcrc?2:0)+(Te.gzhead.extra?4:0)+(Te.gzhead.name?8:0)+(Te.gzhead.comment?16:0)),ae(Te,255&Te.gzhead.time),ae(Te,Te.gzhead.time>>8&255),ae(Te,Te.gzhead.time>>16&255),ae(Te,Te.gzhead.time>>24&255),ae(Te,Te.level===9?2:2<=Te.strategy||Te.level<2?4:0),ae(Te,255&Te.gzhead.os),Te.gzhead.extra&&Te.gzhead.extra.length&&(ae(Te,255&Te.gzhead.extra.length),ae(Te,Te.gzhead.extra.length>>8&255)),Te.gzhead.hcrc&&(Ie.adler=l(Ie.adler,Te.pending_buf,Te.pending,0)),Te.gzindex=0,Te.status=69):(ae(Te,0),ae(Te,0),ae(Te,0),ae(Te,0),ae(Te,0),ae(Te,Te.level===9?2:2<=Te.strategy||Te.level<2?4:0),ae(Te,3),Te.status=G);else{var Se=f+(Te.w_bits-8<<4)<<8;Se|=(2<=Te.strategy||Te.level<2?0:Te.level<6?1:Te.level===6?2:3)<<6,Te.strstart!==0&&(Se|=32),Se+=31-Se%31,Te.status=G,ce(Te,Se),Te.strstart!==0&&(ce(Te,Ie.adler>>>16),ce(Te,65535&Ie.adler)),Ie.adler=1}if(Te.status===69)if(Te.gzhead.extra){for(Ve=Te.pending;Te.gzindex<(65535&Te.gzhead.extra.length)&&(Te.pending!==Te.pending_buf_size||(Te.gzhead.hcrc&&Te.pending>Ve&&(Ie.adler=l(Ie.adler,Te.pending_buf,Te.pending-Ve,Ve)),Z(Ie),Ve=Te.pending,Te.pending!==Te.pending_buf_size));)ae(Te,255&Te.gzhead.extra[Te.gzindex]),Te.gzindex++;Te.gzhead.hcrc&&Te.pending>Ve&&(Ie.adler=l(Ie.adler,Te.pending_buf,Te.pending-Ve,Ve)),Te.gzindex===Te.gzhead.extra.length&&(Te.gzindex=0,Te.status=73)}else Te.status=73;if(Te.status===73)if(Te.gzhead.name){Ve=Te.pending;do{if(Te.pending===Te.pending_buf_size&&(Te.gzhead.hcrc&&Te.pending>Ve&&(Ie.adler=l(Ie.adler,Te.pending_buf,Te.pending-Ve,Ve)),Z(Ie),Ve=Te.pending,Te.pending===Te.pending_buf_size)){Ne=1;break}Ne=Te.gzindex<Te.gzhead.name.length?255&Te.gzhead.name.charCodeAt(Te.gzindex++):0,ae(Te,Ne)}while(Ne!==0);Te.gzhead.hcrc&&Te.pending>Ve&&(Ie.adler=l(Ie.adler,Te.pending_buf,Te.pending-Ve,Ve)),Ne===0&&(Te.gzindex=0,Te.status=91)}else Te.status=91;if(Te.status===91)if(Te.gzhead.comment){Ve=Te.pending;do{if(Te.pending===Te.pending_buf_size&&(Te.gzhead.hcrc&&Te.pending>Ve&&(Ie.adler=l(Ie.adler,Te.pending_buf,Te.pending-Ve,Ve)),Z(Ie),Ve=Te.pending,Te.pending===Te.pending_buf_size)){Ne=1;break}Ne=Te.gzindex<Te.gzhead.comment.length?255&Te.gzhead.comment.charCodeAt(Te.gzindex++):0,ae(Te,Ne)}while(Ne!==0);Te.gzhead.hcrc&&Te.pending>Ve&&(Ie.adler=l(Ie.adler,Te.pending_buf,Te.pending-Ve,Ve)),Ne===0&&(Te.status=103)}else Te.status=103;if(Te.status===103&&(Te.gzhead.hcrc?(Te.pending+2>Te.pending_buf_size&&Z(Ie),Te.pending+2<=Te.pending_buf_size&&(ae(Te,255&Ie.adler),ae(Te,Ie.adler>>8&255),Ie.adler=0,Te.status=G)):Te.status=G),Te.pending!==0){if(Z(Ie),Ie.avail_out===0)return Te.last_flush=-1,d}else if(Ie.avail_in===0&&ie(We)<=ie(Me)&&We!==h)return te(Ie,-5);if(Te.status===666&&Ie.avail_in!==0)return te(Ie,-5);if(Ie.avail_in!==0||Te.lookahead!==0||We!==u&&Te.status!==666){var Oe=Te.strategy===2?(function(Pe,qe){for(var $e;;){if(Pe.lookahead===0&&(Ce(Pe),Pe.lookahead===0)){if(qe===u)return O;break}if(Pe.match_length=0,$e=A._tr_tally(Pe,0,Pe.window[Pe.strstart]),Pe.lookahead--,Pe.strstart++,$e&&(se(Pe,!1),Pe.strm.avail_out===0))return O}return Pe.insert=0,qe===h?(se(Pe,!0),Pe.strm.avail_out===0?W:j):Pe.last_lit&&(se(Pe,!1),Pe.strm.avail_out===0)?O:U})(Te,We):Te.strategy===3?(function(Pe,qe){for(var $e,at,ct,dt,gt=Pe.window;;){if(Pe.lookahead<=R){if(Ce(Pe),Pe.lookahead<=R&&qe===u)return O;if(Pe.lookahead===0)break}if(Pe.match_length=0,Pe.lookahead>=D&&0<Pe.strstart&&(at=gt[ct=Pe.strstart-1])===gt[++ct]&&at===gt[++ct]&&at===gt[++ct]){dt=Pe.strstart+R;do;while(at===gt[++ct]&&at===gt[++ct]&&at===gt[++ct]&&at===gt[++ct]&&at===gt[++ct]&&at===gt[++ct]&&at===gt[++ct]&&at===gt[++ct]&&ct<dt);Pe.match_length=R-(dt-ct),Pe.match_length>Pe.lookahead&&(Pe.match_length=Pe.lookahead)}if(Pe.match_length>=D?($e=A._tr_tally(Pe,1,Pe.match_length-D),Pe.lookahead-=Pe.match_length,Pe.strstart+=Pe.match_length,Pe.match_length=0):($e=A._tr_tally(Pe,0,Pe.window[Pe.strstart]),Pe.lookahead--,Pe.strstart++),$e&&(se(Pe,!1),Pe.strm.avail_out===0))return O}return Pe.insert=0,qe===h?(se(Pe,!0),Pe.strm.avail_out===0?W:j):Pe.last_lit&&(se(Pe,!1),Pe.strm.avail_out===0)?O:U})(Te,We):s[Te.level].func(Te,We);if(Oe!==W&&Oe!==j||(Te.status=666),Oe===O||Oe===W)return Ie.avail_out===0&&(Te.last_flush=-1),d;if(Oe===U&&(We===1?A._tr_align(Te):We!==5&&(A._tr_stored_block(Te,0,0,!1),We===3&&($(Te.head),Te.lookahead===0&&(Te.strstart=0,Te.block_start=0,Te.insert=0))),Z(Ie),Ie.avail_out===0))return Te.last_flush=-1,d}return We!==h?d:Te.wrap<=0?1:(Te.wrap===2?(ae(Te,255&Ie.adler),ae(Te,Ie.adler>>8&255),ae(Te,Ie.adler>>16&255),ae(Te,Ie.adler>>24&255),ae(Te,255&Ie.total_in),ae(Te,Ie.total_in>>8&255),ae(Te,Ie.total_in>>16&255),ae(Te,Ie.total_in>>24&255)):(ce(Te,Ie.adler>>>16),ce(Te,65535&Ie.adler)),Z(Ie),0<Te.wrap&&(Te.wrap=-Te.wrap),Te.pending!==0?d:1)},r.deflateEnd=function(Ie){var We;return Ie&&Ie.state?(We=Ie.state.status)!==L&&We!==69&&We!==73&&We!==91&&We!==103&&We!==G&&We!==666?te(Ie,_):(Ie.state=null,We===G?te(Ie,-3):d):_},r.deflateSetDictionary=function(Ie,We){var Me,Te,Ve,Ne,Se,Oe,Pe,qe,$e=We.length;if(!Ie||!Ie.state||(Ne=(Me=Ie.state).wrap)===2||Ne===1&&Me.status!==L||Me.lookahead)return _;for(Ne===1&&(Ie.adler=c(Ie.adler,We,$e,0)),Me.wrap=0,$e>=Me.w_size&&(Ne===0&&($(Me.head),Me.strstart=0,Me.block_start=0,Me.insert=0),qe=new a.Buf8(Me.w_size),a.arraySet(qe,We,$e-Me.w_size,Me.w_size,0),We=qe,$e=Me.w_size),Se=Ie.avail_in,Oe=Ie.next_in,Pe=Ie.input,Ie.avail_in=$e,Ie.next_in=0,Ie.input=We,Ce(Me);Me.lookahead>=D;){for(Te=Me.strstart,Ve=Me.lookahead-(D-1);Me.ins_h=(Me.ins_h<<Me.hash_shift^Me.window[Te+D-1])&Me.hash_mask,Me.prev[Te&Me.w_mask]=Me.head[Me.ins_h],Me.head[Me.ins_h]=Te,Te++,--Ve;);Me.strstart=Te,Me.lookahead=D-1,Ce(Me)}return Me.strstart+=Me.lookahead,Me.block_start=Me.strstart,Me.insert=Me.lookahead,Me.lookahead=0,Me.match_length=Me.prev_length=D-1,Me.match_available=0,Ie.next_in=Oe,Ie.input=Pe,Ie.avail_in=Se,Me.wrap=Ne,d},r.deflateInfo="pako deflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./messages":51,"./trees":52}],47:[function(o,i,r){i.exports=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}},{}],48:[function(o,i,r){i.exports=function(s,a){var A,c,l,g,u,h,d,_,m,p,I,f,C,y,E,B,Q,b,D,R,M,L,G,O,U;A=s.state,c=s.next_in,O=s.input,l=c+(s.avail_in-5),g=s.next_out,U=s.output,u=g-(a-s.avail_out),h=g+(s.avail_out-257),d=A.dmax,_=A.wsize,m=A.whave,p=A.wnext,I=A.window,f=A.hold,C=A.bits,y=A.lencode,E=A.distcode,B=(1<<A.lenbits)-1,Q=(1<<A.distbits)-1;e:do{C<15&&(f+=O[c++]<<C,C+=8,f+=O[c++]<<C,C+=8),b=y[f&B];t:for(;;){if(f>>>=D=b>>>24,C-=D,(D=b>>>16&255)===0)U[g++]=65535&b;else{if(!(16&D)){if((64&D)==0){b=y[(65535&b)+(f&(1<<D)-1)];continue t}if(32&D){A.mode=12;break e}s.msg="invalid literal/length code",A.mode=30;break e}R=65535&b,(D&=15)&&(C<D&&(f+=O[c++]<<C,C+=8),R+=f&(1<<D)-1,f>>>=D,C-=D),C<15&&(f+=O[c++]<<C,C+=8,f+=O[c++]<<C,C+=8),b=E[f&Q];n:for(;;){if(f>>>=D=b>>>24,C-=D,!(16&(D=b>>>16&255))){if((64&D)==0){b=E[(65535&b)+(f&(1<<D)-1)];continue n}s.msg="invalid distance code",A.mode=30;break e}if(M=65535&b,C<(D&=15)&&(f+=O[c++]<<C,(C+=8)<D&&(f+=O[c++]<<C,C+=8)),d<(M+=f&(1<<D)-1)){s.msg="invalid distance too far back",A.mode=30;break e}if(f>>>=D,C-=D,(D=g-u)<M){if(m<(D=M-D)&&A.sane){s.msg="invalid distance too far back",A.mode=30;break e}if(G=I,(L=0)===p){if(L+=_-D,D<R){for(R-=D;U[g++]=I[L++],--D;);L=g-M,G=U}}else if(p<D){if(L+=_+p-D,(D-=p)<R){for(R-=D;U[g++]=I[L++],--D;);if(L=0,p<R){for(R-=D=p;U[g++]=I[L++],--D;);L=g-M,G=U}}}else if(L+=p-D,D<R){for(R-=D;U[g++]=I[L++],--D;);L=g-M,G=U}for(;2<R;)U[g++]=G[L++],U[g++]=G[L++],U[g++]=G[L++],R-=3;R&&(U[g++]=G[L++],1<R&&(U[g++]=G[L++]))}else{for(L=g-M;U[g++]=U[L++],U[g++]=U[L++],U[g++]=U[L++],2<(R-=3););R&&(U[g++]=U[L++],1<R&&(U[g++]=U[L++]))}break}}break}}while(c<l&&g<h);c-=R=C>>3,f&=(1<<(C-=R<<3))-1,s.next_in=c,s.next_out=g,s.avail_in=c<l?l-c+5:5-(c-l),s.avail_out=g<h?h-g+257:257-(g-h),A.hold=f,A.bits=C}},{}],49:[function(o,i,r){var s=o("../utils/common"),a=o("./adler32"),A=o("./crc32"),c=o("./inffast"),l=o("./inftrees"),g=1,u=2,h=0,d=-2,_=1,m=852,p=592;function I(L){return(L>>>24&255)+(L>>>8&65280)+((65280&L)<<8)+((255&L)<<24)}function f(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new s.Buf16(320),this.work=new s.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function C(L){var G;return L&&L.state?(G=L.state,L.total_in=L.total_out=G.total=0,L.msg="",G.wrap&&(L.adler=1&G.wrap),G.mode=_,G.last=0,G.havedict=0,G.dmax=32768,G.head=null,G.hold=0,G.bits=0,G.lencode=G.lendyn=new s.Buf32(m),G.distcode=G.distdyn=new s.Buf32(p),G.sane=1,G.back=-1,h):d}function y(L){var G;return L&&L.state?((G=L.state).wsize=0,G.whave=0,G.wnext=0,C(L)):d}function E(L,G){var O,U;return L&&L.state?(U=L.state,G<0?(O=0,G=-G):(O=1+(G>>4),G<48&&(G&=15)),G&&(G<8||15<G)?d:(U.window!==null&&U.wbits!==G&&(U.window=null),U.wrap=O,U.wbits=G,y(L))):d}function B(L,G){var O,U;return L?(U=new f,(L.state=U).window=null,(O=E(L,G))!==h&&(L.state=null),O):d}var Q,b,D=!0;function R(L){if(D){var G;for(Q=new s.Buf32(512),b=new s.Buf32(32),G=0;G<144;)L.lens[G++]=8;for(;G<256;)L.lens[G++]=9;for(;G<280;)L.lens[G++]=7;for(;G<288;)L.lens[G++]=8;for(l(g,L.lens,0,288,Q,0,L.work,{bits:9}),G=0;G<32;)L.lens[G++]=5;l(u,L.lens,0,32,b,0,L.work,{bits:5}),D=!1}L.lencode=Q,L.lenbits=9,L.distcode=b,L.distbits=5}function M(L,G,O,U){var W,j=L.state;return j.window===null&&(j.wsize=1<<j.wbits,j.wnext=0,j.whave=0,j.window=new s.Buf8(j.wsize)),U>=j.wsize?(s.arraySet(j.window,G,O-j.wsize,j.wsize,0),j.wnext=0,j.whave=j.wsize):(U<(W=j.wsize-j.wnext)&&(W=U),s.arraySet(j.window,G,O-U,W,j.wnext),(U-=W)?(s.arraySet(j.window,G,O-U,U,0),j.wnext=U,j.whave=j.wsize):(j.wnext+=W,j.wnext===j.wsize&&(j.wnext=0),j.whave<j.wsize&&(j.whave+=W))),0}r.inflateReset=y,r.inflateReset2=E,r.inflateResetKeep=C,r.inflateInit=function(L){return B(L,15)},r.inflateInit2=B,r.inflate=function(L,G){var O,U,W,j,te,ie,$,Z,se,ae,ce,fe,Ce,xe,de,Ee,he,ve,Re,ze,Ie,We,Me,Te,Ve=0,Ne=new s.Buf8(4),Se=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!L||!L.state||!L.output||!L.input&&L.avail_in!==0)return d;(O=L.state).mode===12&&(O.mode=13),te=L.next_out,W=L.output,$=L.avail_out,j=L.next_in,U=L.input,ie=L.avail_in,Z=O.hold,se=O.bits,ae=ie,ce=$,We=h;e:for(;;)switch(O.mode){case _:if(O.wrap===0){O.mode=13;break}for(;se<16;){if(ie===0)break e;ie--,Z+=U[j++]<<se,se+=8}if(2&O.wrap&&Z===35615){Ne[O.check=0]=255&Z,Ne[1]=Z>>>8&255,O.check=A(O.check,Ne,2,0),se=Z=0,O.mode=2;break}if(O.flags=0,O.head&&(O.head.done=!1),!(1&O.wrap)||(((255&Z)<<8)+(Z>>8))%31){L.msg="incorrect header check",O.mode=30;break}if((15&Z)!=8){L.msg="unknown compression method",O.mode=30;break}if(se-=4,Ie=8+(15&(Z>>>=4)),O.wbits===0)O.wbits=Ie;else if(Ie>O.wbits){L.msg="invalid window size",O.mode=30;break}O.dmax=1<<Ie,L.adler=O.check=1,O.mode=512&Z?10:12,se=Z=0;break;case 2:for(;se<16;){if(ie===0)break e;ie--,Z+=U[j++]<<se,se+=8}if(O.flags=Z,(255&O.flags)!=8){L.msg="unknown compression method",O.mode=30;break}if(57344&O.flags){L.msg="unknown header flags set",O.mode=30;break}O.head&&(O.head.text=Z>>8&1),512&O.flags&&(Ne[0]=255&Z,Ne[1]=Z>>>8&255,O.check=A(O.check,Ne,2,0)),se=Z=0,O.mode=3;case 3:for(;se<32;){if(ie===0)break e;ie--,Z+=U[j++]<<se,se+=8}O.head&&(O.head.time=Z),512&O.flags&&(Ne[0]=255&Z,Ne[1]=Z>>>8&255,Ne[2]=Z>>>16&255,Ne[3]=Z>>>24&255,O.check=A(O.check,Ne,4,0)),se=Z=0,O.mode=4;case 4:for(;se<16;){if(ie===0)break e;ie--,Z+=U[j++]<<se,se+=8}O.head&&(O.head.xflags=255&Z,O.head.os=Z>>8),512&O.flags&&(Ne[0]=255&Z,Ne[1]=Z>>>8&255,O.check=A(O.check,Ne,2,0)),se=Z=0,O.mode=5;case 5:if(1024&O.flags){for(;se<16;){if(ie===0)break e;ie--,Z+=U[j++]<<se,se+=8}O.length=Z,O.head&&(O.head.extra_len=Z),512&O.flags&&(Ne[0]=255&Z,Ne[1]=Z>>>8&255,O.check=A(O.check,Ne,2,0)),se=Z=0}else O.head&&(O.head.extra=null);O.mode=6;case 6:if(1024&O.flags&&(ie<(fe=O.length)&&(fe=ie),fe&&(O.head&&(Ie=O.head.extra_len-O.length,O.head.extra||(O.head.extra=new Array(O.head.extra_len)),s.arraySet(O.head.extra,U,j,fe,Ie)),512&O.flags&&(O.check=A(O.check,U,fe,j)),ie-=fe,j+=fe,O.length-=fe),O.length))break e;O.length=0,O.mode=7;case 7:if(2048&O.flags){if(ie===0)break e;for(fe=0;Ie=U[j+fe++],O.head&&Ie&&O.length<65536&&(O.head.name+=String.fromCharCode(Ie)),Ie&&fe<ie;);if(512&O.flags&&(O.check=A(O.check,U,fe,j)),ie-=fe,j+=fe,Ie)break e}else O.head&&(O.head.name=null);O.length=0,O.mode=8;case 8:if(4096&O.flags){if(ie===0)break e;for(fe=0;Ie=U[j+fe++],O.head&&Ie&&O.length<65536&&(O.head.comment+=String.fromCharCode(Ie)),Ie&&fe<ie;);if(512&O.flags&&(O.check=A(O.check,U,fe,j)),ie-=fe,j+=fe,Ie)break e}else O.head&&(O.head.comment=null);O.mode=9;case 9:if(512&O.flags){for(;se<16;){if(ie===0)break e;ie--,Z+=U[j++]<<se,se+=8}if(Z!==(65535&O.check)){L.msg="header crc mismatch",O.mode=30;break}se=Z=0}O.head&&(O.head.hcrc=O.flags>>9&1,O.head.done=!0),L.adler=O.check=0,O.mode=12;break;case 10:for(;se<32;){if(ie===0)break e;ie--,Z+=U[j++]<<se,se+=8}L.adler=O.check=I(Z),se=Z=0,O.mode=11;case 11:if(O.havedict===0)return L.next_out=te,L.avail_out=$,L.next_in=j,L.avail_in=ie,O.hold=Z,O.bits=se,2;L.adler=O.check=1,O.mode=12;case 12:if(G===5||G===6)break e;case 13:if(O.last){Z>>>=7&se,se-=7&se,O.mode=27;break}for(;se<3;){if(ie===0)break e;ie--,Z+=U[j++]<<se,se+=8}switch(O.last=1&Z,se-=1,3&(Z>>>=1)){case 0:O.mode=14;break;case 1:if(R(O),O.mode=20,G!==6)break;Z>>>=2,se-=2;break e;case 2:O.mode=17;break;case 3:L.msg="invalid block type",O.mode=30}Z>>>=2,se-=2;break;case 14:for(Z>>>=7&se,se-=7&se;se<32;){if(ie===0)break e;ie--,Z+=U[j++]<<se,se+=8}if((65535&Z)!=(Z>>>16^65535)){L.msg="invalid stored block lengths",O.mode=30;break}if(O.length=65535&Z,se=Z=0,O.mode=15,G===6)break e;case 15:O.mode=16;case 16:if(fe=O.length){if(ie<fe&&(fe=ie),$<fe&&(fe=$),fe===0)break e;s.arraySet(W,U,j,fe,te),ie-=fe,j+=fe,$-=fe,te+=fe,O.length-=fe;break}O.mode=12;break;case 17:for(;se<14;){if(ie===0)break e;ie--,Z+=U[j++]<<se,se+=8}if(O.nlen=257+(31&Z),Z>>>=5,se-=5,O.ndist=1+(31&Z),Z>>>=5,se-=5,O.ncode=4+(15&Z),Z>>>=4,se-=4,286<O.nlen||30<O.ndist){L.msg="too many length or distance symbols",O.mode=30;break}O.have=0,O.mode=18;case 18:for(;O.have<O.ncode;){for(;se<3;){if(ie===0)break e;ie--,Z+=U[j++]<<se,se+=8}O.lens[Se[O.have++]]=7&Z,Z>>>=3,se-=3}for(;O.have<19;)O.lens[Se[O.have++]]=0;if(O.lencode=O.lendyn,O.lenbits=7,Me={bits:O.lenbits},We=l(0,O.lens,0,19,O.lencode,0,O.work,Me),O.lenbits=Me.bits,We){L.msg="invalid code lengths set",O.mode=30;break}O.have=0,O.mode=19;case 19:for(;O.have<O.nlen+O.ndist;){for(;Ee=(Ve=O.lencode[Z&(1<<O.lenbits)-1])>>>16&255,he=65535&Ve,!((de=Ve>>>24)<=se);){if(ie===0)break e;ie--,Z+=U[j++]<<se,se+=8}if(he<16)Z>>>=de,se-=de,O.lens[O.have++]=he;else{if(he===16){for(Te=de+2;se<Te;){if(ie===0)break e;ie--,Z+=U[j++]<<se,se+=8}if(Z>>>=de,se-=de,O.have===0){L.msg="invalid bit length repeat",O.mode=30;break}Ie=O.lens[O.have-1],fe=3+(3&Z),Z>>>=2,se-=2}else if(he===17){for(Te=de+3;se<Te;){if(ie===0)break e;ie--,Z+=U[j++]<<se,se+=8}se-=de,Ie=0,fe=3+(7&(Z>>>=de)),Z>>>=3,se-=3}else{for(Te=de+7;se<Te;){if(ie===0)break e;ie--,Z+=U[j++]<<se,se+=8}se-=de,Ie=0,fe=11+(127&(Z>>>=de)),Z>>>=7,se-=7}if(O.have+fe>O.nlen+O.ndist){L.msg="invalid bit length repeat",O.mode=30;break}for(;fe--;)O.lens[O.have++]=Ie}}if(O.mode===30)break;if(O.lens[256]===0){L.msg="invalid code -- missing end-of-block",O.mode=30;break}if(O.lenbits=9,Me={bits:O.lenbits},We=l(g,O.lens,0,O.nlen,O.lencode,0,O.work,Me),O.lenbits=Me.bits,We){L.msg="invalid literal/lengths set",O.mode=30;break}if(O.distbits=6,O.distcode=O.distdyn,Me={bits:O.distbits},We=l(u,O.lens,O.nlen,O.ndist,O.distcode,0,O.work,Me),O.distbits=Me.bits,We){L.msg="invalid distances set",O.mode=30;break}if(O.mode=20,G===6)break e;case 20:O.mode=21;case 21:if(6<=ie&&258<=$){L.next_out=te,L.avail_out=$,L.next_in=j,L.avail_in=ie,O.hold=Z,O.bits=se,c(L,ce),te=L.next_out,W=L.output,$=L.avail_out,j=L.next_in,U=L.input,ie=L.avail_in,Z=O.hold,se=O.bits,O.mode===12&&(O.back=-1);break}for(O.back=0;Ee=(Ve=O.lencode[Z&(1<<O.lenbits)-1])>>>16&255,he=65535&Ve,!((de=Ve>>>24)<=se);){if(ie===0)break e;ie--,Z+=U[j++]<<se,se+=8}if(Ee&&(240&Ee)==0){for(ve=de,Re=Ee,ze=he;Ee=(Ve=O.lencode[ze+((Z&(1<<ve+Re)-1)>>ve)])>>>16&255,he=65535&Ve,!(ve+(de=Ve>>>24)<=se);){if(ie===0)break e;ie--,Z+=U[j++]<<se,se+=8}Z>>>=ve,se-=ve,O.back+=ve}if(Z>>>=de,se-=de,O.back+=de,O.length=he,Ee===0){O.mode=26;break}if(32&Ee){O.back=-1,O.mode=12;break}if(64&Ee){L.msg="invalid literal/length code",O.mode=30;break}O.extra=15&Ee,O.mode=22;case 22:if(O.extra){for(Te=O.extra;se<Te;){if(ie===0)break e;ie--,Z+=U[j++]<<se,se+=8}O.length+=Z&(1<<O.extra)-1,Z>>>=O.extra,se-=O.extra,O.back+=O.extra}O.was=O.length,O.mode=23;case 23:for(;Ee=(Ve=O.distcode[Z&(1<<O.distbits)-1])>>>16&255,he=65535&Ve,!((de=Ve>>>24)<=se);){if(ie===0)break e;ie--,Z+=U[j++]<<se,se+=8}if((240&Ee)==0){for(ve=de,Re=Ee,ze=he;Ee=(Ve=O.distcode[ze+((Z&(1<<ve+Re)-1)>>ve)])>>>16&255,he=65535&Ve,!(ve+(de=Ve>>>24)<=se);){if(ie===0)break e;ie--,Z+=U[j++]<<se,se+=8}Z>>>=ve,se-=ve,O.back+=ve}if(Z>>>=de,se-=de,O.back+=de,64&Ee){L.msg="invalid distance code",O.mode=30;break}O.offset=he,O.extra=15&Ee,O.mode=24;case 24:if(O.extra){for(Te=O.extra;se<Te;){if(ie===0)break e;ie--,Z+=U[j++]<<se,se+=8}O.offset+=Z&(1<<O.extra)-1,Z>>>=O.extra,se-=O.extra,O.back+=O.extra}if(O.offset>O.dmax){L.msg="invalid distance too far back",O.mode=30;break}O.mode=25;case 25:if($===0)break e;if(fe=ce-$,O.offset>fe){if((fe=O.offset-fe)>O.whave&&O.sane){L.msg="invalid distance too far back",O.mode=30;break}Ce=fe>O.wnext?(fe-=O.wnext,O.wsize-fe):O.wnext-fe,fe>O.length&&(fe=O.length),xe=O.window}else xe=W,Ce=te-O.offset,fe=O.length;for($<fe&&(fe=$),$-=fe,O.length-=fe;W[te++]=xe[Ce++],--fe;);O.length===0&&(O.mode=21);break;case 26:if($===0)break e;W[te++]=O.length,$--,O.mode=21;break;case 27:if(O.wrap){for(;se<32;){if(ie===0)break e;ie--,Z|=U[j++]<<se,se+=8}if(ce-=$,L.total_out+=ce,O.total+=ce,ce&&(L.adler=O.check=O.flags?A(O.check,W,ce,te-ce):a(O.check,W,ce,te-ce)),ce=$,(O.flags?Z:I(Z))!==O.check){L.msg="incorrect data check",O.mode=30;break}se=Z=0}O.mode=28;case 28:if(O.wrap&&O.flags){for(;se<32;){if(ie===0)break e;ie--,Z+=U[j++]<<se,se+=8}if(Z!==(4294967295&O.total)){L.msg="incorrect length check",O.mode=30;break}se=Z=0}O.mode=29;case 29:We=1;break e;case 30:We=-3;break e;case 31:return-4;default:return d}return L.next_out=te,L.avail_out=$,L.next_in=j,L.avail_in=ie,O.hold=Z,O.bits=se,(O.wsize||ce!==L.avail_out&&O.mode<30&&(O.mode<27||G!==4))&&M(L,L.output,L.next_out,ce-L.avail_out)?(O.mode=31,-4):(ae-=L.avail_in,ce-=L.avail_out,L.total_in+=ae,L.total_out+=ce,O.total+=ce,O.wrap&&ce&&(L.adler=O.check=O.flags?A(O.check,W,ce,L.next_out-ce):a(O.check,W,ce,L.next_out-ce)),L.data_type=O.bits+(O.last?64:0)+(O.mode===12?128:0)+(O.mode===20||O.mode===15?256:0),(ae==0&&ce===0||G===4)&&We===h&&(We=-5),We)},r.inflateEnd=function(L){if(!L||!L.state)return d;var G=L.state;return G.window&&(G.window=null),L.state=null,h},r.inflateGetHeader=function(L,G){var O;return L&&L.state?(2&(O=L.state).wrap)==0?d:((O.head=G).done=!1,h):d},r.inflateSetDictionary=function(L,G){var O,U=G.length;return L&&L.state?(O=L.state).wrap!==0&&O.mode!==11?d:O.mode===11&&a(1,G,U,0)!==O.check?-3:M(L,G,U,U)?(O.mode=31,-4):(O.havedict=1,h):d},r.inflateInfo="pako inflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./inffast":48,"./inftrees":50}],50:[function(o,i,r){var s=o("../utils/common"),a=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0],A=[16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78],c=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0],l=[16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64];i.exports=function(g,u,h,d,_,m,p,I){var f,C,y,E,B,Q,b,D,R,M=I.bits,L=0,G=0,O=0,U=0,W=0,j=0,te=0,ie=0,$=0,Z=0,se=null,ae=0,ce=new s.Buf16(16),fe=new s.Buf16(16),Ce=null,xe=0;for(L=0;L<=15;L++)ce[L]=0;for(G=0;G<d;G++)ce[u[h+G]]++;for(W=M,U=15;1<=U&&ce[U]===0;U--);if(U<W&&(W=U),U===0)return _[m++]=20971520,_[m++]=20971520,I.bits=1,0;for(O=1;O<U&&ce[O]===0;O++);for(W<O&&(W=O),L=ie=1;L<=15;L++)if(ie<<=1,(ie-=ce[L])<0)return-1;if(0<ie&&(g===0||U!==1))return-1;for(fe[1]=0,L=1;L<15;L++)fe[L+1]=fe[L]+ce[L];for(G=0;G<d;G++)u[h+G]!==0&&(p[fe[u[h+G]]++]=G);if(Q=g===0?(se=Ce=p,19):g===1?(se=a,ae-=257,Ce=A,xe-=257,256):(se=c,Ce=l,-1),L=O,B=m,te=G=Z=0,y=-1,E=($=1<<(j=W))-1,g===1&&852<$||g===2&&592<$)return 1;for(;;){for(b=L-te,R=p[G]<Q?(D=0,p[G]):p[G]>Q?(D=Ce[xe+p[G]],se[ae+p[G]]):(D=96,0),f=1<<L-te,O=C=1<<j;_[B+(Z>>te)+(C-=f)]=b<<24|D<<16|R|0,C!==0;);for(f=1<<L-1;Z&f;)f>>=1;if(f!==0?(Z&=f-1,Z+=f):Z=0,G++,--ce[L]==0){if(L===U)break;L=u[h+p[G]]}if(W<L&&(Z&E)!==y){for(te===0&&(te=W),B+=O,ie=1<<(j=L-te);j+te<U&&!((ie-=ce[j+te])<=0);)j++,ie<<=1;if($+=1<<j,g===1&&852<$||g===2&&592<$)return 1;_[y=Z&E]=W<<24|j<<16|B-m|0}}return Z!==0&&(_[B+Z]=L-te<<24|64<<16|0),I.bits=W,0}},{"../utils/common":41}],51:[function(o,i,r){i.exports={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"}},{}],52:[function(o,i,r){var s=o("../utils/common"),a=0,A=1;function c(Ve){for(var Ne=Ve.length;0<=--Ne;)Ve[Ne]=0}var l=0,g=29,u=256,h=u+1+g,d=30,_=19,m=2*h+1,p=15,I=16,f=7,C=256,y=16,E=17,B=18,Q=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0],b=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],D=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],R=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],M=new Array(2*(h+2));c(M);var L=new Array(2*d);c(L);var G=new Array(512);c(G);var O=new Array(256);c(O);var U=new Array(g);c(U);var W,j,te,ie=new Array(d);function $(Ve,Ne,Se,Oe,Pe){this.static_tree=Ve,this.extra_bits=Ne,this.extra_base=Se,this.elems=Oe,this.max_length=Pe,this.has_stree=Ve&&Ve.length}function Z(Ve,Ne){this.dyn_tree=Ve,this.max_code=0,this.stat_desc=Ne}function se(Ve){return Ve<256?G[Ve]:G[256+(Ve>>>7)]}function ae(Ve,Ne){Ve.pending_buf[Ve.pending++]=255&Ne,Ve.pending_buf[Ve.pending++]=Ne>>>8&255}function ce(Ve,Ne,Se){Ve.bi_valid>I-Se?(Ve.bi_buf|=Ne<<Ve.bi_valid&65535,ae(Ve,Ve.bi_buf),Ve.bi_buf=Ne>>I-Ve.bi_valid,Ve.bi_valid+=Se-I):(Ve.bi_buf|=Ne<<Ve.bi_valid&65535,Ve.bi_valid+=Se)}function fe(Ve,Ne,Se){ce(Ve,Se[2*Ne],Se[2*Ne+1])}function Ce(Ve,Ne){for(var Se=0;Se|=1&Ve,Ve>>>=1,Se<<=1,0<--Ne;);return Se>>>1}function xe(Ve,Ne,Se){var Oe,Pe,qe=new Array(p+1),$e=0;for(Oe=1;Oe<=p;Oe++)qe[Oe]=$e=$e+Se[Oe-1]<<1;for(Pe=0;Pe<=Ne;Pe++){var at=Ve[2*Pe+1];at!==0&&(Ve[2*Pe]=Ce(qe[at]++,at))}}function de(Ve){var Ne;for(Ne=0;Ne<h;Ne++)Ve.dyn_ltree[2*Ne]=0;for(Ne=0;Ne<d;Ne++)Ve.dyn_dtree[2*Ne]=0;for(Ne=0;Ne<_;Ne++)Ve.bl_tree[2*Ne]=0;Ve.dyn_ltree[2*C]=1,Ve.opt_len=Ve.static_len=0,Ve.last_lit=Ve.matches=0}function Ee(Ve){8<Ve.bi_valid?ae(Ve,Ve.bi_buf):0<Ve.bi_valid&&(Ve.pending_buf[Ve.pending++]=Ve.bi_buf),Ve.bi_buf=0,Ve.bi_valid=0}function he(Ve,Ne,Se,Oe){var Pe=2*Ne,qe=2*Se;return Ve[Pe]<Ve[qe]||Ve[Pe]===Ve[qe]&&Oe[Ne]<=Oe[Se]}function ve(Ve,Ne,Se){for(var Oe=Ve.heap[Se],Pe=Se<<1;Pe<=Ve.heap_len&&(Pe<Ve.heap_len&&he(Ne,Ve.heap[Pe+1],Ve.heap[Pe],Ve.depth)&&Pe++,!he(Ne,Oe,Ve.heap[Pe],Ve.depth));)Ve.heap[Se]=Ve.heap[Pe],Se=Pe,Pe<<=1;Ve.heap[Se]=Oe}function Re(Ve,Ne,Se){var Oe,Pe,qe,$e,at=0;if(Ve.last_lit!==0)for(;Oe=Ve.pending_buf[Ve.d_buf+2*at]<<8|Ve.pending_buf[Ve.d_buf+2*at+1],Pe=Ve.pending_buf[Ve.l_buf+at],at++,Oe===0?fe(Ve,Pe,Ne):(fe(Ve,(qe=O[Pe])+u+1,Ne),($e=Q[qe])!==0&&ce(Ve,Pe-=U[qe],$e),fe(Ve,qe=se(--Oe),Se),($e=b[qe])!==0&&ce(Ve,Oe-=ie[qe],$e)),at<Ve.last_lit;);fe(Ve,C,Ne)}function ze(Ve,Ne){var Se,Oe,Pe,qe=Ne.dyn_tree,$e=Ne.stat_desc.static_tree,at=Ne.stat_desc.has_stree,ct=Ne.stat_desc.elems,dt=-1;for(Ve.heap_len=0,Ve.heap_max=m,Se=0;Se<ct;Se++)qe[2*Se]!==0?(Ve.heap[++Ve.heap_len]=dt=Se,Ve.depth[Se]=0):qe[2*Se+1]=0;for(;Ve.heap_len<2;)qe[2*(Pe=Ve.heap[++Ve.heap_len]=dt<2?++dt:0)]=1,Ve.depth[Pe]=0,Ve.opt_len--,at&&(Ve.static_len-=$e[2*Pe+1]);for(Ne.max_code=dt,Se=Ve.heap_len>>1;1<=Se;Se--)ve(Ve,qe,Se);for(Pe=ct;Se=Ve.heap[1],Ve.heap[1]=Ve.heap[Ve.heap_len--],ve(Ve,qe,1),Oe=Ve.heap[1],Ve.heap[--Ve.heap_max]=Se,Ve.heap[--Ve.heap_max]=Oe,qe[2*Pe]=qe[2*Se]+qe[2*Oe],Ve.depth[Pe]=(Ve.depth[Se]>=Ve.depth[Oe]?Ve.depth[Se]:Ve.depth[Oe])+1,qe[2*Se+1]=qe[2*Oe+1]=Pe,Ve.heap[1]=Pe++,ve(Ve,qe,1),2<=Ve.heap_len;);Ve.heap[--Ve.heap_max]=Ve.heap[1],(function(gt,nt){var xt,mt,vt,Ft,en,tn,Ut=nt.dyn_tree,ye=nt.max_code,st=nt.stat_desc.static_tree,lt=nt.stat_desc.has_stree,ht=nt.stat_desc.extra_bits,Tt=nt.stat_desc.extra_base,Ht=nt.stat_desc.max_length,gn=0;for(Ft=0;Ft<=p;Ft++)gt.bl_count[Ft]=0;for(Ut[2*gt.heap[gt.heap_max]+1]=0,xt=gt.heap_max+1;xt<m;xt++)Ht<(Ft=Ut[2*Ut[2*(mt=gt.heap[xt])+1]+1]+1)&&(Ft=Ht,gn++),Ut[2*mt+1]=Ft,ye<mt||(gt.bl_count[Ft]++,en=0,Tt<=mt&&(en=ht[mt-Tt]),tn=Ut[2*mt],gt.opt_len+=tn*(Ft+en),lt&&(gt.static_len+=tn*(st[2*mt+1]+en)));if(gn!==0){do{for(Ft=Ht-1;gt.bl_count[Ft]===0;)Ft--;gt.bl_count[Ft]--,gt.bl_count[Ft+1]+=2,gt.bl_count[Ht]--,gn-=2}while(0<gn);for(Ft=Ht;Ft!==0;Ft--)for(mt=gt.bl_count[Ft];mt!==0;)ye<(vt=gt.heap[--xt])||(Ut[2*vt+1]!==Ft&&(gt.opt_len+=(Ft-Ut[2*vt+1])*Ut[2*vt],Ut[2*vt+1]=Ft),mt--)}})(Ve,Ne),xe(qe,dt,Ve.bl_count)}function Ie(Ve,Ne,Se){var Oe,Pe,qe=-1,$e=Ne[1],at=0,ct=7,dt=4;for($e===0&&(ct=138,dt=3),Ne[2*(Se+1)+1]=65535,Oe=0;Oe<=Se;Oe++)Pe=$e,$e=Ne[2*(Oe+1)+1],++at<ct&&Pe===$e||(at<dt?Ve.bl_tree[2*Pe]+=at:Pe!==0?(Pe!==qe&&Ve.bl_tree[2*Pe]++,Ve.bl_tree[2*y]++):at<=10?Ve.bl_tree[2*E]++:Ve.bl_tree[2*B]++,qe=Pe,dt=(at=0)===$e?(ct=138,3):Pe===$e?(ct=6,3):(ct=7,4))}function We(Ve,Ne,Se){var Oe,Pe,qe=-1,$e=Ne[1],at=0,ct=7,dt=4;for($e===0&&(ct=138,dt=3),Oe=0;Oe<=Se;Oe++)if(Pe=$e,$e=Ne[2*(Oe+1)+1],!(++at<ct&&Pe===$e)){if(at<dt)for(;fe(Ve,Pe,Ve.bl_tree),--at!=0;);else Pe!==0?(Pe!==qe&&(fe(Ve,Pe,Ve.bl_tree),at--),fe(Ve,y,Ve.bl_tree),ce(Ve,at-3,2)):at<=10?(fe(Ve,E,Ve.bl_tree),ce(Ve,at-3,3)):(fe(Ve,B,Ve.bl_tree),ce(Ve,at-11,7));qe=Pe,dt=(at=0)===$e?(ct=138,3):Pe===$e?(ct=6,3):(ct=7,4)}}c(ie);var Me=!1;function Te(Ve,Ne,Se,Oe){ce(Ve,(l<<1)+(Oe?1:0),3),(function(Pe,qe,$e,at){Ee(Pe),ae(Pe,$e),ae(Pe,~$e),s.arraySet(Pe.pending_buf,Pe.window,qe,$e,Pe.pending),Pe.pending+=$e})(Ve,Ne,Se)}r._tr_init=function(Ve){Me||((function(){var Ne,Se,Oe,Pe,qe,$e=new Array(p+1);for(Pe=Oe=0;Pe<g-1;Pe++)for(U[Pe]=Oe,Ne=0;Ne<1<<Q[Pe];Ne++)O[Oe++]=Pe;for(O[Oe-1]=Pe,Pe=qe=0;Pe<16;Pe++)for(ie[Pe]=qe,Ne=0;Ne<1<<b[Pe];Ne++)G[qe++]=Pe;for(qe>>=7;Pe<d;Pe++)for(ie[Pe]=qe<<7,Ne=0;Ne<1<<b[Pe]-7;Ne++)G[256+qe++]=Pe;for(Se=0;Se<=p;Se++)$e[Se]=0;for(Ne=0;Ne<=143;)M[2*Ne+1]=8,Ne++,$e[8]++;for(;Ne<=255;)M[2*Ne+1]=9,Ne++,$e[9]++;for(;Ne<=279;)M[2*Ne+1]=7,Ne++,$e[7]++;for(;Ne<=287;)M[2*Ne+1]=8,Ne++,$e[8]++;for(xe(M,h+1,$e),Ne=0;Ne<d;Ne++)L[2*Ne+1]=5,L[2*Ne]=Ce(Ne,5);W=new $(M,Q,u+1,h,p),j=new $(L,b,0,d,p),te=new $(new Array(0),D,0,_,f)})(),Me=!0),Ve.l_desc=new Z(Ve.dyn_ltree,W),Ve.d_desc=new Z(Ve.dyn_dtree,j),Ve.bl_desc=new Z(Ve.bl_tree,te),Ve.bi_buf=0,Ve.bi_valid=0,de(Ve)},r._tr_stored_block=Te,r._tr_flush_block=function(Ve,Ne,Se,Oe){var Pe,qe,$e=0;0<Ve.level?(Ve.strm.data_type===2&&(Ve.strm.data_type=(function(at){var ct,dt=4093624447;for(ct=0;ct<=31;ct++,dt>>>=1)if(1&dt&&at.dyn_ltree[2*ct]!==0)return a;if(at.dyn_ltree[18]!==0||at.dyn_ltree[20]!==0||at.dyn_ltree[26]!==0)return A;for(ct=32;ct<u;ct++)if(at.dyn_ltree[2*ct]!==0)return A;return a})(Ve)),ze(Ve,Ve.l_desc),ze(Ve,Ve.d_desc),$e=(function(at){var ct;for(Ie(at,at.dyn_ltree,at.l_desc.max_code),Ie(at,at.dyn_dtree,at.d_desc.max_code),ze(at,at.bl_desc),ct=_-1;3<=ct&&at.bl_tree[2*R[ct]+1]===0;ct--);return at.opt_len+=3*(ct+1)+5+5+4,ct})(Ve),Pe=Ve.opt_len+3+7>>>3,(qe=Ve.static_len+3+7>>>3)<=Pe&&(Pe=qe)):Pe=qe=Se+5,Se+4<=Pe&&Ne!==-1?Te(Ve,Ne,Se,Oe):Ve.strategy===4||qe===Pe?(ce(Ve,2+(Oe?1:0),3),Re(Ve,M,L)):(ce(Ve,4+(Oe?1:0),3),(function(at,ct,dt,gt){var nt;for(ce(at,ct-257,5),ce(at,dt-1,5),ce(at,gt-4,4),nt=0;nt<gt;nt++)ce(at,at.bl_tree[2*R[nt]+1],3);We(at,at.dyn_ltree,ct-1),We(at,at.dyn_dtree,dt-1)})(Ve,Ve.l_desc.max_code+1,Ve.d_desc.max_code+1,$e+1),Re(Ve,Ve.dyn_ltree,Ve.dyn_dtree)),de(Ve),Oe&&Ee(Ve)},r._tr_tally=function(Ve,Ne,Se){return Ve.pending_buf[Ve.d_buf+2*Ve.last_lit]=Ne>>>8&255,Ve.pending_buf[Ve.d_buf+2*Ve.last_lit+1]=255&Ne,Ve.pending_buf[Ve.l_buf+Ve.last_lit]=255&Se,Ve.last_lit++,Ne===0?Ve.dyn_ltree[2*Se]++:(Ve.matches++,Ne--,Ve.dyn_ltree[2*(O[Se]+u+1)]++,Ve.dyn_dtree[2*se(Ne)]++),Ve.last_lit===Ve.lit_bufsize-1},r._tr_align=function(Ve){ce(Ve,2,3),fe(Ve,C,M),(function(Ne){Ne.bi_valid===16?(ae(Ne,Ne.bi_buf),Ne.bi_buf=0,Ne.bi_valid=0):8<=Ne.bi_valid&&(Ne.pending_buf[Ne.pending++]=255&Ne.bi_buf,Ne.bi_buf>>=8,Ne.bi_valid-=8)})(Ve)}},{"../utils/common":41}],53:[function(o,i,r){i.exports=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}},{}],54:[function(o,i,r){(function(s){(function(a,A){if(!a.setImmediate){var c,l,g,u,h=1,d={},_=!1,m=a.document,p=Object.getPrototypeOf&&Object.getPrototypeOf(a);p=p&&p.setTimeout?p:a,c={}.toString.call(a.process)==="[object process]"?function(y){n.nextTick(function(){f(y)})}:(function(){if(a.postMessage&&!a.importScripts){var y=!0,E=a.onmessage;return a.onmessage=function(){y=!1},a.postMessage("","*"),a.onmessage=E,y}})()?(u="setImmediate$"+Math.random()+"$",a.addEventListener?a.addEventListener("message",C,!1):a.attachEvent("onmessage",C),function(y){a.postMessage(u+y,"*")}):a.MessageChannel?((g=new MessageChannel).port1.onmessage=function(y){f(y.data)},function(y){g.port2.postMessage(y)}):m&&"onreadystatechange"in m.createElement("script")?(l=m.documentElement,function(y){var E=m.createElement("script");E.onreadystatechange=function(){f(y),E.onreadystatechange=null,l.removeChild(E),E=null},l.appendChild(E)}):function(y){setTimeout(f,0,y)},p.setImmediate=function(y){typeof y!="function"&&(y=new Function(""+y));for(var E=new Array(arguments.length-1),B=0;B<E.length;B++)E[B]=arguments[B+1];var Q={callback:y,args:E};return d[h]=Q,c(h),h++},p.clearImmediate=I}function I(y){delete d[y]}function f(y){if(_)setTimeout(f,0,y);else{var E=d[y];if(E){_=!0;try{(function(B){var Q=B.callback,b=B.args;switch(b.length){case 0:Q();break;case 1:Q(b[0]);break;case 2:Q(b[0],b[1]);break;case 3:Q(b[0],b[1],b[2]);break;default:Q.apply(A,b)}})(E)}finally{I(y),_=!1}}}}function C(y){y.source===a&&typeof y.data=="string"&&y.data.indexOf(u)===0&&f(+y.data.slice(u.length))}})(typeof self>"u"?s===void 0?this:s:self)}).call(this,typeof PC<"u"?PC:typeof self<"u"?self:typeof window<"u"?window:{})},{}]},{},[10])(10)})})(G7e)),G7e.exports}var RXo=NXo();const O7e=ty(RXo),TXo=async({circuitJson:t,projectName:e})=>{await Rs.promise((async()=>{const n=new O7e,[{stringifyGerberCommandLayers:o,convertSoupToGerberCommands:i,convertSoupToExcellonDrillCommands:r,stringifyExcellonDrill:s},{convertCircuitJsonToBomRows:a,convertBomRowsToCsv:A},{convertCircuitJsonToPickAndPlaceCsv:c}]=await Promise.all([iE("circuit-json-to-gerber"),iE("circuit-json-to-bom-csv"),iE("circuit-json-to-pnp-csv")]),l=t.filter(f=>!("error_type"in f)&&!("warning_type"in f)),g=i(l,{flip_y_axis:!1}),u=o(g);for(const[f,C]of Object.entries(u))n.file(`gerber/${f}.gbr`,C);const h=r({circuitJson:l,is_plated:!0,flip_y_axis:!1}),d=s(h);n.file("gerber/drill.drl",d);const _=await a({circuitJson:t}),m=await A(_);n.file("bom.csv",m);const p=await c(t,{supplier:"jlcpcb"});n.file("pick_and_place.csv",p);const I=await n.generateAsync({type:"blob"});rQ(I,{fileName:`${e}_fabrication_files.zip`})})(),{loading:"Generating fabrication files...",success:"Fabrication ZIP ready",error:n=>`Failed to generate fabrication files: ${n instanceof Error?n.message:String(n)}`})},kXo=async t=>{const{createFdmComponentBox:e,renderFdmComponentBoxPng:n}=await iE("circuit-json-to-fdm-component-box"),[o,i]=await Promise.all([e(t),n(t,{},{width:960,height:640})]);return{...o,previewPng:i}},FXo=async t=>{const{createFdmComponentBox:e}=await iE("circuit-json-to-fdm-component-box");return e(t)},iOt=({generatedBox:t,projectName:e})=>{const n=Uint8Array.from(t.threeMf);rQ(new Blob([n.buffer],{type:"model/3mf"}),{fileName:`${a7e(e)}-component-box.3mf`})},LXo=async({circuitJson:t,projectName:e})=>{await Rs.promise((async()=>{const n=await FXo(t);iOt({generatedBox:n,projectName:e})})(),{loading:"Generating component box...",success:"Component box 3MF ready",error:n=>`Failed to generate component box: ${n instanceof Error?n.message:String(n)}`})},HXo=async({circuitJson:t,projectName:e})=>{let n;try{const{convertCircuitJsonToGltf:o}=await iE("circuit-json-to-gltf");console.log("convertCircuitJsonToGltf",o);const i=await o(t,{format:"glb",boardTextureResolution:1024});if(!i||!(i instanceof ArrayBuffer))throw new Error("Invalid GLB data returned from converter");n=new Blob([i],{type:"model/gltf-binary"})}catch(o){console.error("GLB Export Error:",o);return}rQ(n,{fileName:`${e}.glb`})},GXo=async({circuitJson:t,libraryName:e})=>{const{CircuitJsonToKicadLibraryConverter:n}=await iE("circuit-json-to-kicad"),o=new n(t,{libraryName:e,footprintLibraryName:e});o.runUntilFinished();const i=o.getOutput(),r=new O7e;r.file(`${e}.kicad_sym`,i.kicadSymString);for(const s of i.footprints){const a=r.folder(`${e}.pretty`);a&&a.file(`${s.footprintName}.kicad_mod`,`${s.kicadModString}
|
|
5800
5800
|
`)}if(i.model3dSourcePaths.length>0){const s=r.folder(`${e}.3dshapes`);if(s)for(const a of i.model3dSourcePaths)try{const A=a.split("/").pop()||a,c=await fetch(a);if(c.ok){const l=await c.arrayBuffer();s.file(A,l)}}catch{}}return r.file("fp-lib-table",i.fpLibTableString),r.file("sym-lib-table",i.symLibTableString),r},OXo=async({circuitJson:t,projectName:e})=>{await Rs.promise((async()=>{const o=await(await GXo({circuitJson:t,libraryName:e})).generateAsync({type:"blob"});rQ(o,{fileName:`${e}_kicad_library.zip`})})(),{loading:"Generating KiCad library...",success:"KiCad library ZIP ready",error:n=>`Failed to generate KiCad library: ${n instanceof Error?n.message:String(n)}`})},KXo=async({circuitJson:t,projectName:e})=>{const{CircuitJsonToKicadPcbConverter:n,CircuitJsonToKicadSchConverter:o,CircuitJsonToKicadProConverter:i,resolveAndLoadKicad3dModelFiles:r}=await iE("circuit-json-to-kicad"),s=new o(t);s.runUntilFinished();const a=s.getOutputString(),A=new n(t,{includeBuiltin3dModels:!0,projectName:e});A.runUntilFinished();const c=A.getOutputString(),l=new i(t,{projectName:e,schematicFilename:`${e}.kicad_sch`,pcbFilename:`${e}.kicad_pcb`});l.runUntilFinished();const g=l.getOutputString(),u=new O7e;return u.file(`${e}.kicad_sch`,a),u.file(`${e}.kicad_pcb`,c),u.file(`${e}.kicad_pro`,g),await r({projectName:e,model3dSourcePaths:A.getModel3dSourcePaths(),fetch,onModelFile:({outputPath:h,content:d})=>{u.file(h,d)},onError:({sourcePath:h})=>{console.warn(`Failed to load 3D model from ${h}`)}}),u},UXo=async({circuitJson:t,projectName:e})=>{await Rs.promise((async()=>{const o=await(await KXo({circuitJson:t,projectName:e})).generateAsync({type:"blob"});rQ(o,{fileName:`${e}_kicad_project.zip`})})(),{loading:"Generating KiCad project...",success:"KiCad project ZIP ready",error:n=>`Failed to generate KiCad project: ${n instanceof Error?n.message:String(n)}`})},rOt=async({circuitJson:t,projectName:e,options:n={}})=>{try{const{convertCircuitJsonToLbrn:o}=await iE("circuit-json-to-lbrn"),r=(await o(t,{includeSilkscreen:n.includeSilkscreen??!1,includeOxidationCleaningLayer:n.includeOxidationCleaningLayer??!0})).toXml(),s=new Blob([r],{type:"application/lbrn"});rQ(s,{fileName:`${e}.lbrn2`})}catch(o){const i=o instanceof Error?o.message:"Unknown error";Rs.error(`Failed to export to LBRN format: ${i}`)}},YXo=async({circuitJson:t,projectName:e})=>{const{convertCircuitJsonToPinoutSvg:n}=await iE("circuit-to-svg"),o=n(t);rQ(o,{fileName:`${e}-pinout.svg`,mimeType:"image/svg+xml"})},zXo=async({circuitJson:t,projectName:e})=>{const{circuitJsonToStep:n}=await iE("circuit-json-to-step"),o=t.find(c=>c.type==="pcb_board"),i=o&&"width"in o?o.width:void 0,r=o&&"height"in o?o.height:void 0,s=o&&"thickness"in o?o.thickness:void 0;if(i===void 0||r===void 0||s===void 0){Rs.error("Board dimensions not found. Please add a pcb_board with width, height, and thickness to your circuit.");return}let a;try{a=await n(t,{boardWidth:i,boardHeight:r,boardThickness:s,productName:e,includeComponents:!0,includeExternalMeshes:!0})}catch(c){const l=c instanceof Error?c.message:"Unknown error";Rs.error(`Failed to convert circuit to STEP format: ${l}`);return}const A=new Blob([a],{type:"application/step"});try{rQ(A,{fileName:`${e}.step`})}catch(c){const l=c instanceof Error?c.message:"Unknown error";Rs.error(`Failed to download STEP file: ${l}`)}},VXo=[{extension:"json",name:"Circuit JSON"},{extension:"json",name:"Simple Route JSON"},{extension:"zip",name:"Fabrication Files"},{extension:"zip",name:"KiCad Project"},{extension:"zip",name:"KiCad Library"},{extension:"glb",name:"GLB (Binary GLTF)"},{extension:"svg",name:"Pinout SVG"},{extension:"step",name:"STEP"},{extension:"lbrn2",name:"LightBurn"}],JXo=async({exportName:t,circuitJson:e,simpleRouteJson:n,projectName:o})=>{const i=a7e(o);if(t==="Fabrication Files"){await TXo({circuitJson:e,projectName:i});return}if(t==="KiCad Project"){await UXo({circuitJson:e,projectName:i});return}if(t==="KiCad Library"){await OXo({circuitJson:e,projectName:i});return}if(t==="Circuit JSON"){rQ(JSON.stringify(e,null,2),{fileName:`${i}.circuit.json`,mimeType:"application/json"});return}if(t==="Simple Route JSON"){if(!n)throw new Error("No Simple Route JSON available to export");rQ(JSON.stringify(n,null,2),{fileName:`${i}.simple-route.json`,mimeType:"application/json"});return}if(t==="GLB (Binary GLTF)"){await HXo({circuitJson:e,projectName:i});return}if(t==="Pinout SVG"){YXo({circuitJson:e,projectName:i});return}if(t==="STEP"){await zXo({circuitJson:e,projectName:i});return}if(t==="Component Box (3MF)"){await LXo({circuitJson:e,projectName:i});return}if(t==="LightBurn"){await rOt({circuitJson:e,projectName:i});return}throw new Error(`Unsupported export type: "${t}"`)},qXo=({packageName:t,onSelectReview:e})=>{const n=Xu(g=>g.fsMap),o=Xu(g=>g.circuitJson),[i,r]=X.useState([]),[s,a]=X.useState(!1),[A,c]=X.useState(!1);X.useEffect(()=>{!t||!Tne()||(a(!0),QK.get("ai_reviews/list",{searchParams:{package_name:t}}).json().then(g=>r(g.ai_reviews)).catch(g=>{console.error("Failed to load AI reviews",g),Rs.error("Failed to load AI reviews")}).finally(()=>a(!1)))},[t]);const l=async()=>{if(!o){Rs.error("Need Circuit JSON to Request AI Review");return}if(!Tne()){Rs.error("Missing registry token");return}c(!0);try{const{ai_review:g}=await QK.post("ai_reviews/create",{json:{package_name:t??"unknown",fs_map:Object.fromEntries(n),circuit_json:o}}).json();r(u=>[g,...u]),e(g),Rs.success("AI review requested")}catch(g){console.error("Failed to create AI review",g),Rs.error("Failed to request AI review")}finally{c(!1)}};return Y.jsxs(Y.Fragment,{children:[Y.jsxs(iw,{children:[Y.jsx(rw,{children:"AI Review"}),Y.jsx(Z6,{children:"Select an AI review or request a new one."})]}),Y.jsx("div",{className:"rf-flex rf-gap-4 rf-mt-4",children:Y.jsx("div",{className:"rf-w-48 rf-h-64 rf-overflow-y-auto rf-border rf-rounded rf-p-2 rf-flex-shrink-0",children:s?Y.jsx("div",{className:"rf-text-sm",children:"Loading..."}):i.length>0?i.map(g=>Y.jsx("div",{className:"rf-text-sm rf-p-2 rf-cursor-pointer rf-rounded hover:rf-bg-zinc-100",onClick:()=>e(g),children:new Date(g.created_at||"").toLocaleString()},g.ai_review_id)):Y.jsx("div",{className:"rf-text-sm rf-text-muted-foreground",children:"No AI reviews found."})})}),Y.jsx(Uk,{className:"rf-mt-4",children:Y.jsx(fa,{onClick:l,disabled:A,children:A?"Requesting...":"Review my Board"})})]})};function K7e(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var e8=K7e();function sOt(t){e8=t}var jY={exec:()=>null};function xl(t,e=""){let n=typeof t=="string"?t:t.source;const o={replace:(i,r)=>{let s=typeof r=="string"?r:r.source;return s=s.replace(a1.caret,"$1"),n=n.replace(i,s),o},getRegex:()=>new RegExp(n,e)};return o}var a1={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceTabs:/^\t+/,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] /,listReplaceTask:/^\[[ xX]\] +/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,unescapeTest:/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:t=>new RegExp(`^( {0,3}${t})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),hrRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}#`),htmlBeginRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}<(?:[a-z].*>|!--)`,"i")},WXo=/^(?:[ \t]*(?:\n|$))+/,jXo=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,XXo=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,XY=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,$Xo=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,U7e=/(?:[*+-]|\d{1,9}[.)])/,aOt=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,AOt=xl(aOt).replace(/bull/g,U7e).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,"").getRegex(),ZXo=xl(aOt).replace(/bull/g,U7e).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),Y7e=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,e$o=/^[^\n]+/,z7e=/(?!\s*\])(?:\\.|[^\[\]\\])+/,t$o=xl(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",z7e).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),n$o=xl(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,U7e).getRegex(),Sae="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",V7e=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,o$o=xl("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))","i").replace("comment",V7e).replace("tag",Sae).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),cOt=xl(Y7e).replace("hr",XY).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Sae).getRegex(),i$o=xl(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",cOt).getRegex(),J7e={blockquote:i$o,code:jXo,def:t$o,fences:XXo,heading:$Xo,hr:XY,html:o$o,lheading:AOt,list:n$o,newline:WXo,paragraph:cOt,table:jY,text:e$o},lOt=xl("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",XY).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code","(?: {4}| {0,3} )[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Sae).getRegex(),r$o={...J7e,lheading:ZXo,table:lOt,paragraph:xl(Y7e).replace("hr",XY).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",lOt).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Sae).getRegex()},s$o={...J7e,html:xl(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",V7e).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:jY,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:xl(Y7e).replace("hr",XY).replace("heading",` *#{1,6} *[^
|
|
5801
5801
|
]`).replace("lheading",AOt).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},a$o=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,A$o=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,gOt=/^( {2,}|\\)\n(?!\s*$)/,c$o=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,bae=/[\p{P}\p{S}]/u,q7e=/[\s\p{P}\p{S}]/u,uOt=/[^\s\p{P}\p{S}]/u,l$o=xl(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,q7e).getRegex(),dOt=/(?!~)[\p{P}\p{S}]/u,g$o=/(?!~)[\s\p{P}\p{S}]/u,u$o=/(?:[^\s\p{P}\p{S}]|~)/u,d$o=/\[[^[\]]*?\]\((?:\\.|[^\\\(\)]|\((?:\\.|[^\\\(\)])*\))*\)|`[^`]*?`|<[^<>]*?>/g,hOt=/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,h$o=xl(hOt,"u").replace(/punct/g,bae).getRegex(),_$o=xl(hOt,"u").replace(/punct/g,dOt).getRegex(),_Ot="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",m$o=xl(_Ot,"gu").replace(/notPunctSpace/g,uOt).replace(/punctSpace/g,q7e).replace(/punct/g,bae).getRegex(),p$o=xl(_Ot,"gu").replace(/notPunctSpace/g,u$o).replace(/punctSpace/g,g$o).replace(/punct/g,dOt).getRegex(),I$o=xl("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,uOt).replace(/punctSpace/g,q7e).replace(/punct/g,bae).getRegex(),f$o=xl(/\\(punct)/,"gu").replace(/punct/g,bae).getRegex(),C$o=xl(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme",/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email",/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),y$o=xl(V7e).replace("(?:-->|$)","-->").getRegex(),E$o=xl("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment",y$o).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),Dae=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,x$o=xl(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]*(?:\n[ \t]*)?)(title))?\s*\)/).replace("label",Dae).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),mOt=xl(/^!?\[(label)\]\[(ref)\]/).replace("label",Dae).replace("ref",z7e).getRegex(),pOt=xl(/^!?\[(ref)\](?:\[\])?/).replace("ref",z7e).getRegex(),B$o=xl("reflink|nolink(?!\\()","g").replace("reflink",mOt).replace("nolink",pOt).getRegex(),W7e={_backpedal:jY,anyPunctuation:f$o,autolink:C$o,blockSkip:d$o,br:gOt,code:A$o,del:jY,emStrongLDelim:h$o,emStrongRDelimAst:m$o,emStrongRDelimUnd:I$o,escape:a$o,link:x$o,nolink:pOt,punctuation:l$o,reflink:mOt,reflinkSearch:B$o,tag:E$o,text:c$o,url:jY},Q$o={...W7e,link:xl(/^!?\[(label)\]\((.*?)\)/).replace("label",Dae).getRegex(),reflink:xl(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",Dae).getRegex()},j7e={...W7e,emStrongRDelimAst:p$o,emStrongLDelim:_$o,url:xl(/^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/,"i").replace("email",/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\.|[^\\])*?(?:\\.|[^\s~\\]))\1(?=[^~]|$)/,text:/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|https?:\/\/|ftp:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/},S$o={...j7e,br:xl(gOt).replace("{2,}","*").getRegex(),text:xl(j7e.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},vae={normal:J7e,gfm:r$o,pedantic:s$o},$Y={normal:W7e,gfm:j7e,breaks:S$o,pedantic:Q$o},b$o={"&":"&","<":"<",">":">",'"':""","'":"'"},IOt=t=>b$o[t];function mb(t,e){if(e){if(a1.escapeTest.test(t))return t.replace(a1.escapeReplace,IOt)}else if(a1.escapeTestNoEncode.test(t))return t.replace(a1.escapeReplaceNoEncode,IOt);return t}function fOt(t){try{t=encodeURI(t).replace(a1.percentDecode,"%")}catch{return null}return t}function COt(t,e){const n=t.replace(a1.findPipe,(r,s,a)=>{let A=!1,c=s;for(;--c>=0&&a[c]==="\\";)A=!A;return A?"|":" |"}),o=n.split(a1.splitPipe);let i=0;if(o[0].trim()||o.shift(),o.length>0&&!o.at(-1)?.trim()&&o.pop(),e)if(o.length>e)o.splice(e);else for(;o.length<e;)o.push("");for(;i<o.length;i++)o[i]=o[i].trim().replace(a1.slashPipe,"|");return o}function ZY(t,e,n){const o=t.length;if(o===0)return"";let i=0;for(;i<o&&t.charAt(o-i-1)===e;)i++;return t.slice(0,o-i)}function D$o(t,e){if(t.indexOf(e[1])===-1)return-1;let n=0;for(let o=0;o<t.length;o++)if(t[o]==="\\")o++;else if(t[o]===e[0])n++;else if(t[o]===e[1]&&(n--,n<0))return o;return n>0?-2:-1}function yOt(t,e,n,o,i){const r=e.href,s=e.title||null,a=t[1].replace(i.other.outputLinkReplace,"$1");o.state.inLink=!0;const A={type:t[0].charAt(0)==="!"?"image":"link",raw:n,href:r,title:s,text:a,tokens:o.inlineTokens(a)};return o.state.inLink=!1,A}function v$o(t,e,n){const o=t.match(n.other.indentCodeCompensation);if(o===null)return e;const i=o[1];return e.split(`
|