@tscircuit/runframe 0.0.3007 → 0.0.3009
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
|
@@ -5320,7 +5320,7 @@ ${Q.join(`
|
|
|
5320
5320
|
${c}polygon: ${a.polygon.vertices}
|
|
5321
5321
|
`:Q+=`
|
|
5322
5322
|
`,a.children.length>0&&E.push(a.children)}return Q}};A.exports=B}}),w6t=fg({"node_modules/@jscad/modeling/src/operations/booleans/trees/Tree.js"(g,A){var I=l6t(),e=y6t(),t=class{constructor(o){this.polygonTree=new e,this.rootnode=new I(null),o&&this.addPolygons(o)}invert(){this.polygonTree.invert(),this.rootnode.invert()}clipTo(o,B=!1){this.rootnode.clipTo(o,B)}allPolygons(){const o=[];return this.polygonTree.getPolygons(o),o}addPolygons(o){const B=new Array(o.length);for(let C=0;C<o.length;C++)B[C]=this.polygonTree.addChild(o[C]);this.rootnode.addPolygonTreeNodes(B)}clear(){this.polygonTree.clear()}toString(){return"Tree: "+this.polygonTree.toString("")}};A.exports=t}}),iAg=fg({"node_modules/@jscad/modeling/src/operations/booleans/trees/index.js"(g,A){A.exports={Tree:w6t()}}}),u6t=fg({"node_modules/@jscad/modeling/src/operations/booleans/intersectGeom3Sub.js"(g,A){var I=wQ(),e=QAg(),{Tree:t}=iAg(),o=(B,C)=>{if(!e(B,C))return I.create();const Q=new t(I.toPolygons(B)),i=new t(I.toPolygons(C));Q.invert(),i.clipTo(Q),i.invert(),Q.clipTo(i),i.clipTo(Q),Q.addPolygons(i.allPolygons()),Q.invert();const E=Q.allPolygons();return I.create(E)};A.exports=o}}),lwI=fg({"node_modules/@jscad/modeling/src/operations/booleans/intersectGeom3.js"(g,A){var I=ZC(),e=rIA(),t=u6t(),o=(...B)=>{B=I(B);let C=B.shift();return B.forEach(Q=>{C=t(C,Q)}),C=e(C),C};A.exports=o}}),G6t=fg({"node_modules/@jscad/modeling/src/operations/booleans/intersectGeom2.js"(g,A){var I=ZC(),e=wQ(),t=c3(),o=BAg(),B=CAg(),C=lwI(),Q=(...i)=>{i=I(i);const E=i.map(r=>B({z0:-1,z1:1},r)),n=C(E),s=t(n);return o(s,e.toPolygons(n))};A.exports=Q}}),m6t=fg({"node_modules/@jscad/modeling/src/operations/booleans/intersect.js"(g,A){var I=ZC(),e=aIA(),t=RQ(),o=wQ(),B=G6t(),C=lwI(),Q=(...i)=>{if(i=I(i),i.length===0)throw new Error("wrong number of arguments");if(!e(i))throw new Error("only intersect of the types are supported");const E=i[0];return t.isA(E)?B(i):o.isA(E)?C(i):E};A.exports=Q}}),EAg=fg({"node_modules/@jscad/modeling/src/operations/hulls/hullPoints3.js"(g,A){var I=vi(),e=wyI(),t=o=>e(o,{skipTriangulation:!0}).map(Q=>{const i=Q.map(E=>o[E]);return I.create(i)});A.exports=t}}),DwI=fg({"node_modules/@jscad/modeling/src/operations/booleans/unionGeom3Sub.js"(g,A){var I=wQ(),e=QAg(),{Tree:t}=iAg(),o=(C,Q)=>{if(!e(C,Q))return B(C,Q);const i=new t(I.toPolygons(C)),E=new t(I.toPolygons(Q));i.clipTo(E,!1),E.clipTo(i),E.invert(),E.clipTo(i),E.invert();const n=i.allPolygons().concat(E.allPolygons());return I.create(n)},B=(C,Q)=>{let i=I.toPolygons(C);return i=i.concat(I.toPolygons(Q)),I.create(i)};A.exports=o}}),nAg=fg({"node_modules/@jscad/modeling/src/operations/booleans/unionGeom3.js"(g,A){var I=ZC(),e=rIA(),t=DwI(),o=(...B)=>{B=I(B);let C;for(C=1;C<B.length;C+=2)B.push(t(B[C-1],B[C]));let Q=B[C-1];return Q=e(Q),Q};A.exports=o}}),dwI=fg({"node_modules/@jscad/modeling/src/operations/minkowski/minkowskiSum.js"(g,A){var I=ZC(),e=wQ(),t=vi(),o=EAg(),B=nAg(),C=(...r)=>{if(r=I(r),r.length!==2)throw new Error("minkowskiSum requires exactly two geometries");const[a,c]=r;if(!e.isA(a)||!e.isA(c))throw new Error("minkowskiSum requires geom3 geometries");const h=e.isConvex(a),l=e.isConvex(c);if(h&&l)return n(a,c);if(!h&&l)return Q(a,c);if(h&&!l)return Q(c,a);throw new Error("minkowskiSum of two non-convex geometries is not yet supported")},Q=(r,a)=>{const c=i(r);if(c.length===0)return e.create();const h=c.map(l=>n(l,a));return h.length===1?h[0]:B(h)},i=r=>{const a=e.toPolygons(r);if(a.length===0)return[];const c=[];for(let h=0;h<a.length;h++){const l=a[h],D=l.vertices;let d=0,y=0,w=0;for(let R=0;R<D.length;R++)d+=D[R][0],y+=D[R][1],w+=D[R][2];d/=D.length,y/=D.length,w/=D.length;const u=t.plane(l),G=u[0],m=u[1],p=u[2],k=.1,S=[d-G*k,y-m*k,w-p*k];for(let R=1;R<D.length-1;R++){const x=D[0],N=D[R],J=D[R+1],K=E(S,x,N,J);c.push(e.create(K))}}return c},E=(r,a,c,h)=>[t.create([r,c,a]),t.create([r,a,h]),t.create([a,c,h]),t.create([c,r,h])],n=(r,a)=>{const c=s(r),h=s(a);if(c.length===0||h.length===0)return e.create();const l=[];for(let d=0;d<c.length;d++){const y=c[d];for(let w=0;w<h.length;w++){const u=h[w];l.push([y[0]+u[0],y[1]+u[1],y[2]+u[2]])}}const D=o(l);return e.create(D)},s=r=>{const a=new Set,c=[],h=e.toPolygons(r);for(let l=0;l<h.length;l++){const D=h[l].vertices;for(let d=0;d<D.length;d++){const y=D[d],w=`${y[0]},${y[1]},${y[2]}`;a.has(w)||(a.add(w),c.push(y))}}return c};A.exports=C}}),p6t=fg({"node_modules/@jscad/modeling/src/operations/booleans/scissionGeom3.js"(g,A){var I=yB(),e=c3(),t=wQ(),o=i=>i.sort((E,n)=>E-n).filter((E,n,s)=>!n||E!==s[n-1]),B=(i,E,n)=>{const s=`${E}`,r=i.get(s);r===void 0?i.set(s,[n]):r.push(n)},C=(i,E)=>{const n=`${E}`;return i.get(n)},Q=i=>{const E=e(i),n=t.toPolygons(i),s=n.length,r=new Map,a=I.create();n.forEach((d,y)=>{d.vertices.forEach(w=>{B(r,I.snap(a,w,E),y)})});const c=n.map(d=>{let y=[];return d.vertices.forEach(w=>{y=y.concat(C(r,I.snap(a,w,E)))}),{e:1,d:o(y)}});r.clear();let h=0;const l=c.length;for(let d=0;d<l;d++){const y=c[d];if(y.e>0){const w=new Array(s);w[d]=!0;do h=0,w.forEach((u,G)=>{const m=c[G];if(m.e>0){m.e=-1;for(let p=0;p<m.d.length;p++)w[m.d[p]]=!0;h++}});while(h>0);y.indexes=w}}const D=[];for(let d=0;d<l;d++)if(c[d].indexes){const y=[];c[d].indexes.forEach((w,u)=>y.push(n[u])),D.push(t.create(y))}return D};A.exports=Q}}),k6t=fg({"node_modules/@jscad/modeling/src/operations/booleans/scission.js"(g,A){var I=ZC(),e=wQ(),t=p6t(),o=(...B)=>{if(B=I(B),B.length===0)throw new Error("wrong number of arguments");const C=B.map(Q=>e.isA(Q)?t(Q):Q);return C.length===1?C[0]:C};A.exports=o}}),M6t=fg({"node_modules/@jscad/modeling/src/operations/booleans/subtractGeom3Sub.js"(g,A){var I=wQ(),e=QAg(),{Tree:t}=iAg(),o=(B,C)=>{if(!e(B,C))return I.clone(B);const Q=new t(I.toPolygons(B)),i=new t(I.toPolygons(C));Q.invert(),Q.clipTo(i),i.clipTo(Q,!0),Q.addPolygons(i.allPolygons()),Q.invert();const E=Q.allPolygons();return I.create(E)};A.exports=o}}),ywI=fg({"node_modules/@jscad/modeling/src/operations/booleans/subtractGeom3.js"(g,A){var I=ZC(),e=rIA(),t=M6t(),o=(...B)=>{B=I(B);let C=B.shift();return B.forEach(Q=>{C=t(C,Q)}),C=e(C),C};A.exports=o}}),S6t=fg({"node_modules/@jscad/modeling/src/operations/booleans/subtractGeom2.js"(g,A){var I=ZC(),e=wQ(),t=c3(),o=BAg(),B=CAg(),C=ywI(),Q=(...i)=>{i=I(i);const E=i.map(r=>B({z0:-1,z1:1},r)),n=C(E),s=t(n);return o(s,e.toPolygons(n))};A.exports=Q}}),f6t=fg({"node_modules/@jscad/modeling/src/operations/booleans/subtract.js"(g,A){var I=ZC(),e=aIA(),t=RQ(),o=wQ(),B=S6t(),C=ywI(),Q=(...i)=>{if(i=I(i),i.length===0)throw new Error("wrong number of arguments");if(!e(i))throw new Error("only subtract of the types are supported");const E=i[0];return t.isA(E)?B(i):o.isA(E)?C(i):E};A.exports=Q}}),wwI=fg({"node_modules/@jscad/modeling/src/operations/booleans/unionGeom2.js"(g,A){var I=ZC(),e=wQ(),t=c3(),o=BAg(),B=CAg(),C=nAg(),Q=(...i)=>{i=I(i);const E=i.map(r=>B({z0:-1,z1:1},r)),n=C(E),s=t(n);return o(s,e.toPolygons(n))};A.exports=Q}}),sAg=fg({"node_modules/@jscad/modeling/src/operations/booleans/union.js"(g,A){var I=ZC(),e=aIA(),t=RQ(),o=wQ(),B=wwI(),C=nAg(),Q=(...i)=>{if(i=I(i),i.length===0)throw new Error("wrong number of arguments");if(!e(i))throw new Error("only unions of the same type are supported");const E=i[0];return t.isA(E)?B(i):o.isA(E)?C(i):E};A.exports=Q}}),cIA=fg({"node_modules/@jscad/modeling/src/operations/booleans/index.js"(g,A){A.exports={intersect:m6t(),minkowski:dwI(),scission:k6t(),subtract:f6t(),union:sAg()}}}),$dA=fg({"node_modules/@jscad/modeling/src/operations/expansions/offsetFromPoints.js"(g,A){var{EPS:I,TAU:e}=aE(),t=VyI(),o=gAg(),B=Qi(),C=jdA(),Q=(i,E)=>{const n={delta:1,corners:"edge",closed:!1,segments:16};let{delta:s,corners:r,closed:a,segments:c}=Object.assign({},n,i);if(Math.abs(s)<I)return E;let h=i.closed?C(E):1;h===0&&(h=1);const l=h>0&&s>=0||h<0&&s<0;s=Math.abs(s);let D=null,d=[];const y=[],w=B.create(),u=E.length;for(let G=0;G<u;G++){const m=(G+1)%u,p=E[G],k=E[m];l?B.subtract(w,p,k):B.subtract(w,k,p),B.normal(w,w),B.normalize(w,w),B.scale(w,w,s);const S=B.add(B.create(),p,w),R=B.add(B.create(),k,w),x=[S,R];if(D!=null&&(a||!a&&m!==0)){const N=t(D[0],D[1],x[0],x[1]);N?(d.pop(),x[0]=N):y.push({c:p,s0:D,s1:x})}D=[S,R],!(m===0&&!a)&&(d.push(x[0]),d.push(x[1]))}if(a&&D!=null){const G=d[0],m=d[1],p=t(D[0],D[1],G,m);if(p)d[0]=p,d.pop();else{const k=E[0],S=[G,m];y.push({c:k,s0:D,s1:S})}}if(r==="edge"){const G=new Map;d.forEach((k,S)=>G.set(k,S));const m=o.create(),p=o.create();y.forEach(k=>{o.fromPoints(m,k.s0[0],k.s0[1]),o.fromPoints(p,k.s1[0],k.s1[1]);const S=o.intersectPointOfLines(m,p);if(Number.isFinite(S[0])&&Number.isFinite(S[1])){const R=k.s0[1],x=G.get(R);d[x]=S,d[(x+1)%d.length]=void 0}else{const R=k.s1[0],x=G.get(R);d[x]=void 0}}),d=d.filter(k=>k!==void 0)}if(r==="round"){let G=Math.floor(c/4);const m=B.create();y.forEach(p=>{let k=B.angle(B.subtract(m,p.s1[0],p.c));if(k-=B.angle(B.subtract(m,p.s0[1],p.c)),l&&k<0&&(k=k+Math.PI,k<0&&(k=k+Math.PI)),!l&&k>0&&(k=k-Math.PI,k>0&&(k=k-Math.PI)),k!==0){G=Math.floor(c*(Math.abs(k)/e));const S=k/G,R=B.angle(B.subtract(m,p.s0[1],p.c)),x=[];for(let N=1;N<G;N++){const J=R+S*N,K=B.fromAngleRadians(B.create(),J);B.scale(K,K,s),B.add(K,K,p.c),x.push(K)}if(x.length>0){const N=p.s0[1];let J=d.findIndex(K=>B.equals(N,K));J=(J+1)%d.length,d.splice(J,0,...x)}}else{const S=p.s1[0],R=d.findIndex(x=>B.equals(S,x));d.splice(R,1)}})}return d};A.exports=Q}}),R6t=fg({"node_modules/@jscad/modeling/src/operations/expansions/expandGeom2.js"(g,A){var I=RQ(),e=$dA(),t=(o,B)=>{const C={delta:1,corners:"edge",segments:16},{delta:Q,corners:i,segments:E}=Object.assign({},C,o);if(!(i==="edge"||i==="chamfer"||i==="round"))throw new Error('corners must be "edge", "chamfer", or "round"');const r=I.toOutlines(B).map(a=>(o={delta:Q,corners:i,closed:!0,segments:E},e(o,a))).reduce((a,c)=>a.concat(I.toSides(I.fromPoints(c))),[]);return I.create(r)};A.exports=t}}),N6t=fg({"node_modules/@jscad/modeling/src/operations/expansions/extrudePolygon.js"(g,A){var I=ba(),e=yB(),t=wQ(),o=vi(),B=(C,Q)=>{e.dot(o.plane(Q),C)>0&&(Q=o.invert(Q));const E=[Q],n=o.transform(I.fromTranslation(I.create(),C),Q),s=Q.vertices.length;for(let r=0;r<s;r++){const a=r<s-1?r+1:0,c=o.create([Q.vertices[r],n.vertices[r],n.vertices[a],Q.vertices[a]]);E.push(c)}return E.push(o.invert(n)),t.create(E)};A.exports=B}}),x6t=fg({"node_modules/@jscad/modeling/src/operations/expansions/expandShell.js"(g,A){var{EPS:I,TAU:e}=aE(),t=ba(),o=yB(),B=cwI(),C=wQ(),Q=vi(),i=QwI(),E=rIA(),n=DwI(),s=N6t(),r=(l,D,d)=>{const y=D.toString();if(l.has(y))l.get(y)[1].push(d);else{const w=[D,[d]];l.set(y,w)}},a=(l,D,d)=>{const y=D[0].toString(),w=D[1].toString(),u=y<w?`${y},${w}`:`${w},${y}`;if(l.has(u))l.get(u)[1].push(d);else{const G=[D,[d]];l.set(u,G)}},c=(l,D)=>{l.findIndex(y=>y===D)<0&&l.push(D)},h=(l,D)=>{const d={delta:1,segments:12},{delta:y,segments:w}=Object.assign({},d,l);let u=C.create();const G=new Map,m=new Map,p=o.create(),k=o.create();return C.toPolygons(D).forEach((R,x)=>{const N=o.scale(o.create(),Q.plane(R),2*y),J=Q.transform(t.fromTranslation(t.create(),o.scale(o.create(),N,-.5)),R),K=s(N,J);u=n(u,K);const _=R.vertices;for(let b=0;b<_.length;b++){r(G,_[b],Q.plane(R));const T=(b+1)%_.length,j=[_[b],_[T]];a(m,j,Q.plane(R))}}),m.forEach(R=>{const x=R[0],N=R[1],J=x[0],K=x[1],_=o.subtract(o.create(),K,J);o.normalize(_,_);const b=N[0],T=o.cross(o.create(),b,_);let j=[];for(let DA=0;DA<w;DA++)c(j,DA*e/w);for(let DA=0,CA=N.length;DA<CA;DA++){const hA=N[DA],sA=o.dot(T,hA),cA=o.dot(b,hA);let SA=Math.atan2(sA,cA);SA<0&&(SA+=e),c(j,SA),SA=Math.atan2(-sA,-cA),SA<0&&(SA+=e),c(j,SA)}j=j.sort(B);const O=j.length;let W,gA;const tA=[],IA=[],QA=[];for(let DA=-1;DA<O;DA++){const CA=j[DA<0?DA+O:DA],hA=Math.sin(CA),sA=Math.cos(CA);o.scale(p,b,sA*y),o.scale(k,T,hA*y),o.add(p,p,k);const cA=o.add(o.create(),J,p),SA=o.add(o.create(),K,p);let xA=!1;if(DA>=0&&o.distance(cA,W)<I&&(xA=!0),!xA){if(DA>=0){tA.push(cA),IA.push(SA);const aA=[gA,SA,cA,W],FA=Q.create(aA);QA.push(FA)}W=cA,gA=SA}}IA.reverse(),QA.push(Q.create(tA)),QA.push(Q.create(IA));const nA=C.create(QA);u=n(u,nA)}),G.forEach(R=>{const x=R[0],N=R[1],J=N[0];let K=null,_=0;for(let O=1;O<N.length;O++){const W=N[O],gA=o.cross(p,J,W),tA=o.length(gA);tA>.05&&tA>_&&(_=tA,K=W)}K||(K=o.orthogonal(p,J));const b=o.cross(p,J,K);o.normalize(b,b);const T=o.cross(k,b,J),j=i({center:[x[0],x[1],x[2]],radius:y,segments:w,axes:[J,b,T]});u=n(u,j)}),E(u)};A.exports=h}}),F6t=fg({"node_modules/@jscad/modeling/src/operations/expansions/expandGeom3.js"(g,A){var I=wQ(),e=sAg(),t=x6t(),o=(B,C)=>{const Q={delta:1,corners:"round",segments:12},{delta:i,corners:E,segments:n}=Object.assign({},Q,B);if(E!=="round")throw new Error('corners must be "round" for 3D geometries');if(I.toPolygons(C).length===0)throw new Error("the given geometry cannot be empty");B={delta:i,corners:E,segments:n};const r=t(B,C);return e(C,r)};A.exports=o}}),U6t=fg({"node_modules/@jscad/modeling/src/operations/expansions/expandPath2.js"(g,A){var I=jdA(),e=Qi(),t=RQ(),o=ha(),B=$dA(),C=E=>{let{external:n,internal:s}=E;I(n)<0?n=n.reverse():s=s.reverse();const r=o.fromPoints({closed:!0},n),a=o.fromPoints({closed:!0},s),c=t.toSides(t.fromPoints(o.toPoints(r))),h=t.toSides(t.fromPoints(o.toPoints(a)));return c.push(...h),t.create(c)},Q=(E,n,s,r)=>{const{points:a,external:c,internal:h}=E,l=Math.floor(n/2),D=[],d=[];if(s==="round"&&l>0){const w=Math.PI/l,u=a[a.length-1],G=e.angle(e.subtract(e.create(),c[c.length-1],u)),m=a[0],p=e.angle(e.subtract(e.create(),h[0],m));for(let k=1;k<l;k++){let S=G+w*k,R=e.fromAngleRadians(e.create(),S);e.scale(R,R,r),e.add(R,R,u),D.push(R),S=p+w*k,R=e.fromAngleRadians(e.create(),S),e.scale(R,R,r),e.add(R,R,m),d.push(R)}}const y=[];return y.push(...c,...D,...h.reverse(),...d),t.fromPoints(y)},i=(E,n)=>{E=Object.assign({},{delta:1,corners:"edge",segments:16},E);const{delta:r,corners:a,segments:c}=E;if(r<=0)throw new Error("the given delta must be positive for paths");if(!(a==="edge"||a==="chamfer"||a==="round"))throw new Error('corners must be "edge", "chamfer", or "round"');const h=n.isClosed,l=o.toPoints(n);if(l.length===0)throw new Error("the given geometry cannot be empty");const D={points:l,external:B({delta:r,corners:a,segments:c,closed:h},l),internal:B({delta:-r,corners:a,segments:c,closed:h},l)};return n.isClosed?C(D):Q(D,c,a,r)};A.exports=i}}),aAg=fg({"node_modules/@jscad/modeling/src/operations/expansions/expand.js"(g,A){var I=ZC(),e=RQ(),t=wQ(),o=ha(),B=R6t(),C=F6t(),Q=U6t(),i=(E,...n)=>{if(n=I(n),n.length===0)throw new Error("wrong number of arguments");const s=n.map(r=>o.isA(r)?Q(E,r):e.isA(r)?B(E,r):t.isA(r)?C(E,r):r);return s.length===1?s[0]:s};A.exports=i}}),J6t=fg({"node_modules/@jscad/modeling/src/operations/expansions/offsetGeom2.js"(g,A){var I=RQ(),e=j$A(),t=$dA(),o=(B,C)=>{const Q={delta:1,corners:"edge",segments:0},{delta:i,corners:E,segments:n}=Object.assign({},Q,B);if(!(E==="edge"||E==="chamfer"||E==="round"))throw new Error('corners must be "edge", "chamfer", or "round"');const s=I.toOutlines(C),a=s.map(c=>(B={delta:s.reduce((D,d)=>D+e.arePointsInside(c,e.create(d)),0)%2===0?i:-i,corners:E,closed:!0,segments:n},t(B,c))).reduce((c,h)=>c.concat(I.toSides(I.fromPoints(h))),[]);return I.create(a)};A.exports=o}}),P6t=fg({"node_modules/@jscad/modeling/src/operations/expansions/offsetPath2.js"(g,A){var I=ha(),e=$dA(),t=(o,B)=>{const C={delta:1,corners:"edge",closed:B.isClosed,segments:16},{delta:Q,corners:i,closed:E,segments:n}=Object.assign({},C,o);if(!(i==="edge"||i==="chamfer"||i==="round"))throw new Error('corners must be "edge", "chamfer", or "round"');o={delta:Q,corners:i,closed:E,segments:n};const s=e(o,I.toPoints(B));return I.fromPoints({closed:E},s)};A.exports=t}}),K6t=fg({"node_modules/@jscad/modeling/src/operations/expansions/offset.js"(g,A){var I=ZC(),e=RQ(),t=ha(),o=J6t(),B=P6t(),C=(Q,...i)=>{if(i=I(i),i.length===0)throw new Error("wrong number of arguments");const E=i.map(n=>t.isA(n)?B(Q,n):e.isA(n)?o(Q,n):n);return E.length===1?E[0]:E};A.exports=C}}),uwI=fg({"node_modules/@jscad/modeling/src/operations/expansions/index.js"(g,A){A.exports={expand:aAg(),offset:K6t()}}}),AyA=fg({"node_modules/@jscad/modeling/src/operations/extrusions/extrudeLinearGeom2.js"(g,A){var I=ba(),e=yB(),t=RQ(),o=m7(),B=XdA(),C=(Q,i)=>{const E={offset:[0,0,1],twistAngle:0,twistSteps:12,repair:!0};let{offset:n,twistAngle:s,twistSteps:r,repair:a}=Object.assign({},E,Q);if(r<1)throw new Error("twistSteps must be 1 or more");s===0&&(r=1);const c=e.clone(n),h=t.toSides(i);if(h.length===0)throw new Error("the given geometry cannot be empty");const l=o.fromSides(h);c[2]<0&&o.reverse(l,l);const D=I.create(),d=(y,w,u)=>{const G=w/r*s,m=e.scale(e.create(),c,w/r);return I.multiply(D,I.fromZRotation(D,G),I.fromTranslation(I.create(),m)),o.transform(D,u)};return Q={numberOfSlices:r+1,capStart:!0,capEnd:!0,repair:a,callback:d},B(Q,l)};A.exports=C}}),L6t=fg({"node_modules/@jscad/modeling/src/operations/extrusions/extrudeLinearPath2.js"(g,A){var I=RQ(),e=ha(),t=AyA(),o=(B,C)=>{if(!C.isClosed)throw new Error("extruded path must be closed");const Q=e.toPoints(C),i=I.fromPoints(Q);return t(B,i)};A.exports=o}}),Y6t=fg({"node_modules/@jscad/modeling/src/operations/extrusions/extrudeLinear.js"(g,A){var I=ZC(),e=RQ(),t=ha(),o=AyA(),B=L6t(),C=(Q,...i)=>{const E={height:1,twistAngle:0,twistSteps:1,repair:!0},{height:n,twistAngle:s,twistSteps:r,repair:a}=Object.assign({},E,Q);if(i=I(i),i.length===0)throw new Error("wrong number of arguments");Q={offset:[0,0,n],twistAngle:s,twistSteps:r,repair:a};const c=i.map(h=>t.isA(h)?B(Q,h):e.isA(h)?o(Q,h):h);return c.length===1?c[0]:c};A.exports=C}}),_6t=fg({"node_modules/@jscad/modeling/src/operations/extrusions/extrudeRectangularPath2.js"(g,A){var I=ha(),e=aAg(),t=AyA(),o=(B,C)=>{const Q={size:1,height:1},{size:i,height:E}=Object.assign({},Q,B);if(B.delta=i,B.offset=[0,0,E],I.toPoints(C).length===0)throw new Error("the given geometry cannot be empty");const s=e(B,C);return t(B,s)};A.exports=o}}),b6t=fg({"node_modules/@jscad/modeling/src/operations/extrusions/extrudeRectangularGeom2.js"(g,A){var{area:I}=iIA(),e=RQ(),t=ha(),o=aAg(),B=AyA(),C=(Q,i)=>{const E={size:1,height:1},{size:n,height:s}=Object.assign({},E,Q);Q.delta=n,Q.offset=[0,0,s];const r=e.toOutlines(i);if(r.length===0)throw new Error("the given geometry cannot be empty");const c=r.map(l=>(I(l)<0&&l.reverse(),o(Q,t.fromPoints({closed:!0},l)))).reduce((l,D)=>l.concat(e.toSides(D)),[]),h=e.create(c);return B(Q,h)};A.exports=C}}),H6t=fg({"node_modules/@jscad/modeling/src/operations/extrusions/extrudeRectangular.js"(g,A){var I=ZC(),e=RQ(),t=ha(),o=_6t(),B=b6t(),C=(Q,...i)=>{const E={size:1,height:1},{size:n,height:s}=Object.assign({},E,Q);if(i=I(i),i.length===0)throw new Error("wrong number of arguments");if(n<=0)throw new Error("size must be positive");if(s<=0)throw new Error("height must be positive");const r=i.map(a=>t.isA(a)?o(Q,a):e.isA(a)?B(Q,a):a);return r.length===1?r[0]:r};A.exports=C}}),v6t=fg({"node_modules/@jscad/modeling/src/operations/extrusions/extrudeHelical.js"(g,A){var{TAU:I}=aE(),e=ba(),t=RQ(),o=XdA(),B=m7(),C=(Q,i)=>{const E={angle:I,startAngle:0,pitch:10,height:0,endOffset:0,segmentsPerRotation:32};let{angle:n,startAngle:s,pitch:r,height:a,endOffset:c,segmentsPerRotation:h}=Object.assign({},E,Q);if(a!=0&&(r=a/(n/I)),h<3)throw new Error("The number of segments per rotation needs to be at least 3.");const D=t.toSides(i);if(D.length===0)throw new Error("The given geometry cannot be empty");const d=D.filter(k=>k[0][0]>=0);let y=B.fromSides(D);d.length===0&&(y=B.reverse(y));const w=Math.round(h/I*Math.abs(n)),u=w>=2?w:2,G=e.create(),m=e.create(),p=(k,S,R)=>{const x=s+n/u*S,N=c/u*S,J=(x-s)/I*r;return e.multiply(G,e.fromTranslation(e.create(),[N,0,J*Math.sign(n)]),e.fromXRotation(e.create(),-I/4*Math.sign(n))),e.multiply(m,e.fromZRotation(e.create(),x),G),B.transform(m,R)};return o({numberOfSlices:u+1,callback:p},y)};A.exports=C}}),q6t=fg({"node_modules/@jscad/modeling/src/operations/extrusions/project.js"(g,A){var I=ZC(),e=AAg(),t=lx(),o=ba(),B=RQ(),C=wQ(),Q=vi(),i=c3(),E=wwI(),n=(r,a)=>{const c=t.fromNormalAndPoint(t.create(),r.axis,r.origin);if(Number.isNaN(c[0])||Number.isNaN(c[1])||Number.isNaN(c[2])||Number.isNaN(c[3]))throw new Error("project: invalid axis or origin");const h=i(a),l=h*h*Math.sqrt(3)/4;if(h===0)return B.create();const D=C.toPolygons(a);let d=[];for(let w=0;w<D.length;w++){const u=D[w].vertices.map(p=>t.projectionOfPoint(c,p)),G=Q.create(u),m=Q.plane(G);e(c,m)&&(Q.measureArea(G)<l||d.push(G))}if(!e(c,[0,0,1])){const w=o.fromVectorRotation(o.create(),c,[0,0,1]);d=d.map(u=>Q.transform(w,u))}d=d.sort((w,u)=>Q.measureArea(u)-Q.measureArea(w));const y=d.map(w=>B.fromPoints(w.vertices));return E(y)},s=(r,...a)=>{const c={axis:[0,0,1],origin:[0,0,0]},{axis:h,origin:l}=Object.assign({},c,r);if(a=I(a),a.length===0)throw new Error("wrong number of arguments");r={axis:h,origin:l};const D=a.map(d=>C.isA(d)?n(r,d):d);return D.length===1?D[0]:D};A.exports=s}}),hIA=fg({"node_modules/@jscad/modeling/src/operations/extrusions/index.js"(g,A){A.exports={extrudeFromSlices:XdA(),extrudeLinear:Y6t(),extrudeRectangular:H6t(),extrudeRotate:swI(),extrudeHelical:v6t(),project:q6t(),slice:m7()}}}),rAg=fg({"node_modules/@jscad/modeling/src/operations/hulls/hullPoints2.js"(g,A){var I=Qi(),e=B=>{let C=I.fromValues(1/0,1/0);B.forEach(E=>{(E[1]<C[1]||E[1]===C[1]&&E[0]<C[0])&&(C=E)});const Q=[];B.forEach(E=>{const n=o(E[1]-C[1],E[0]-C[0]),s=I.squaredDistance(E,C);Q.push({point:E,angle:n,distSq:s})}),Q.sort((E,n)=>E.angle!==n.angle?E.angle-n.angle:E.distSq-n.distSq);const i=[];return Q.forEach(E=>{let n=i.length;for(;n>1&&t(i[n-2],i[n-1],E.point)<=Number.EPSILON;)i.pop(),n=i.length;i.push(E.point)}),i},t=(B,C,Q)=>(C[0]-B[0])*(Q[1]-B[1])-(C[1]-B[1])*(Q[0]-B[0]),o=(B,C)=>B===0&&C===0?-1/0:-C/B;A.exports=e}}),cAg=fg({"node_modules/@jscad/modeling/src/operations/hulls/toUniquePoints.js"(g,A){var I=RQ(),e=wQ(),t=ha(),o=B=>{const C=new Set,Q=[],i=E=>{const n=E.toString();C.has(n)||(Q.push(E),C.add(n))};return B.forEach(E=>{I.isA(E)?I.toPoints(E).forEach(i):e.isA(E)?e.toPoints(E).forEach(n=>n.forEach(i)):t.isA(E)&&t.toPoints(E).forEach(i)}),Q};A.exports=o}}),T6t=fg({"node_modules/@jscad/modeling/src/operations/hulls/hullPath2.js"(g,A){var I=ZC(),e=ha(),t=rAg(),o=cAg(),B=(...C)=>{C=I(C);const Q=o(C),i=t(Q);return e.fromPoints({closed:!0},i)};A.exports=B}}),Z6t=fg({"node_modules/@jscad/modeling/src/operations/hulls/hullGeom2.js"(g,A){var I=ZC(),e=RQ(),t=rAg(),o=cAg(),B=(...C)=>{C=I(C);const Q=o(C),i=t(Q);return i.length<3?e.create():e.fromPoints(i)};A.exports=B}}),O6t=fg({"node_modules/@jscad/modeling/src/operations/hulls/hullGeom3.js"(g,A){var I=ZC(),e=wQ(),t=cAg(),o=EAg(),B=(...C)=>{C=I(C);const Q=t(C);return Q.length===0?e.create():e.create(o(Q))};A.exports=B}}),GwI=fg({"node_modules/@jscad/modeling/src/operations/hulls/hull.js"(g,A){var I=ZC(),e=aIA(),t=RQ(),o=wQ(),B=ha(),C=T6t(),Q=Z6t(),i=O6t(),E=(...n)=>{if(n=I(n),n.length===0)throw new Error("wrong number of arguments");if(!e(n))throw new Error("only hulls of the same type are supported");const s=n[0];return B.isA(s)?C(n):t.isA(s)?Q(n):o.isA(s)?i(n):s};A.exports=E}}),W6t=fg({"node_modules/@jscad/modeling/src/operations/hulls/hullChain.js"(g,A){var I=ZC(),e=sAg(),t=GwI(),o=(...B)=>{if(B=I(B),B.length<2)throw new Error("wrong number of arguments");const C=[];for(let Q=1;Q<B.length;Q++)C.push(t(B[Q-1],B[Q]));return e(C)};A.exports=o}}),V6t=fg({"node_modules/@jscad/modeling/src/operations/hulls/index.js"(g,A){A.exports={hull:GwI(),hullChain:W6t(),hullPoints2:rAg(),hullPoints3:EAg()}}}),j6t=fg({"node_modules/@jscad/modeling/src/operations/minkowski/index.js"(g,A){A.exports={minkowskiSum:dwI()}}}),mwI=fg({"node_modules/@jscad/modeling/src/operations/modifiers/snapPolygons.js"(g,A){var I=yB(),e=vi(),t=(B,C)=>{const Q=Math.abs(e.measureArea(C));return Number.isFinite(Q)&&Q>B},o=(B,C)=>{let Q=C.map(E=>{const n=E.vertices.map(a=>I.snap(I.create(),a,B)),s=[];for(let a=0;a<n.length;a++){const c=(a+1)%n.length;I.equals(n[a],n[c])||s.push(n[a])}const r=e.create(s);return E.color&&(r.color=E.color),r});const i=B*B*Math.sqrt(3)/4;return Q=Q.filter(E=>t(i,E)),Q};A.exports=o}}),z6t=fg({"node_modules/@jscad/modeling/src/operations/modifiers/mergePolygons.js"(g,A){var I=AAg(),e=yB(),t=vi(),o=l=>{const D=t.toPoints(l),d=[];for(let y=0;y<D.length;y++){const w=(y+1)%D.length,u={v1:D[y],v2:D[w]};d.push(u)}for(let y=0;y<d.length;y++){const w=(y+1)%D.length;d[y].next=d[w],d[w].prev=d[y]}return d},B=(l,D)=>{const d=`${D.v1}:${D.v2}`;l.set(d,D)},C=(l,D)=>{const d=`${D.v1}:${D.v2}`;l.delete(d)},Q=(l,D)=>{const d=`${D.v2}:${D.v1}`;return l.get(d)},i=(l,D,d)=>{let y=l.prev.v1,w=l.prev.v2,u=D.next.v2;const G=s(y,w,u,d);y=D.prev.v1,w=D.prev.v2,u=l.next.v2;const m=s(y,w,u,d);return[G,m]},E=e.create(),n=e.create(),s=(l,D,d,y)=>{const w=e.subtract(E,D,l),u=e.subtract(n,d,D);return e.cross(w,w,u),e.dot(w,y)},r=l=>{let D;const d=[];for(;l.next;){const y=l.next;d.push(l.v1),l.v1=null,l.v2=null,l.next=null,l.prev=null,l=y}return d.length>0&&(D=t.create(d)),D},a=l=>{if(l.length<2)return l;const D=l[0].plane,d=l.slice(),y=new Map;for(;d.length>0;){const u=d.shift(),G=o(u);for(let m=0;m<G.length;m++){const p=G[m],k=Q(y,p);if(k){const S=i(p,k,D);if(S[0]>=0&&S[1]>=0){const R=k.next,x=p.next;p.prev.next=k.next,p.next.prev=k.prev,k.prev.next=p.next,k.next.prev=p.prev,p.v1=null,p.v2=null,p.next=null,p.prev=null,C(y,k),k.v1=null,k.v2=null,k.next=null,k.prev=null;const N=(J,K,_)=>{const b={v1:_.v1,v2:K.v2,next:K.next,prev:_.prev};_.prev.next=b,K.next.prev=b,C(J,K),K.v1=null,K.v2=null,K.next=null,K.prev=null,C(J,_),_.v1=null,_.v2=null,_.next=null,_.prev=null};S[0]===0&&N(y,R,R.prev),S[1]===0&&N(y,x,x.prev)}}else p.next&&B(y,p)}}const w=[];return y.forEach(u=>{const G=r(u);G&&w.push(G)}),y.clear(),w},c=(l,D)=>Math.abs(l[3]-D[3])<15e-8?I(l,D):!1,h=(l,D)=>{const d=[];D.forEach(w=>{const u=d.find(G=>c(G[0],t.plane(w)));u?u[1].push(w):d.push([t.plane(w),[w]])});let y=[];return d.forEach(w=>{const u=w[1],G=a(u);y=y.concat(G)}),y};A.exports=h}}),X6t=fg({"node_modules/@jscad/modeling/src/operations/modifiers/insertTjunctions.js"(g,A){var I=aE(),e=yB(),t=vi(),o=i=>`${i}`,B=(i,E,n,s,r,a)=>{const c=o(s),h=o(r),l=`${c}/${h}`,D=`${h}/${c}`;if(i.has(D))return C(i,E,n,r,s,null),null;const d={vertex0:s,vertex1:r,polygonindex:a};return i.has(l)?i.get(l).push(d):i.set(l,[d]),E.has(c)?E.get(c).push(l):E.set(c,[l]),n.has(h)?n.get(h).push(l):n.set(h,[l]),l},C=(i,E,n,s,r,a)=>{const c=o(s),h=o(r),l=`${c}/${h}`;let D=-1;const d=i.get(l);for(let y=0;y<d.length;y++){const w=d[y];let u=o(w.vertex0);if(u===c&&(u=o(w.vertex1),u===h&&!(a!==null&&w.polygonindex!==a))){D=y;break}}d.splice(D,1),d.length===0&&i.delete(l),D=E.get(c).indexOf(l),E.get(c).splice(D,1),E.get(c).length===0&&E.delete(c),D=n.get(h).indexOf(l),n.get(h).splice(D,1),n.get(h).length===0&&n.delete(h)},Q=i=>{const E=new Map;for(let n=0;n<i.length;n++){const s=i[n],r=s.vertices.length;if(r>=3){let a=s.vertices[0],c=o(a);for(let h=0;h<r;h++){let l=h+1;l===r&&(l=0);const D=s.vertices[l],d=o(D),y=`${c}/${d}`,w=`${d}/${c}`;if(E.has(w)){const u=E.get(w);u.splice(-1,1),u.length===0&&E.delete(w)}else{const u={vertex0:a,vertex1:D,polygonindex:n};E.has(y)?E.get(y).push(u):E.set(y,[u])}a=D,c=d}}else console.warn("warning: invalid polygon found during insertTjunctions")}if(E.size>0){const n=new Map,s=new Map,r=new Map;for(const[c,h]of E)r.set(c,!0),h.forEach(l=>{const D=o(l.vertex0),d=o(l.vertex1);n.has(D)?n.get(D).push(c):n.set(D,[c]),s.has(d)?s.get(d).push(c):s.set(d,[c])});const a=i.slice(0);for(;E.size!==0;){for(const h of E.keys())r.set(h,!0);let c=!1;for(;;){const h=Array.from(r.keys());if(h.length===0)break;const l=h[0];let D=!0;if(E.has(l)){const y=E.get(l)[0];for(let w=0;w<2;w++){const u=w===0?y.vertex0:y.vertex1,G=w===0?y.vertex1:y.vertex0,m=o(u),p=o(G);let k=[];w===0?s.has(m)&&(k=s.get(m)):n.has(m)&&(k=n.get(m));for(let S=0;S<k.length;S++){const R=k[S],x=E.get(R)[0],N=w===0?x.vertex0:x.vertex1;if(w===0?x.vertex1:x.vertex0,o(N)===p){C(E,n,s,u,G,null),C(E,n,s,G,u,null),D=!1,w=2,c=!0;break}else{const K=u,_=G,b=N,T=e.subtract(e.create(),b,K),j=e.dot(e.subtract(e.create(),_,K),T)/e.dot(T,T);if(j>0&&j<1){const O=e.scale(e.create(),T,j);if(e.add(O,O,K),e.squaredDistance(O,_)<I.EPS*I.EPS){const gA=x.polygonindex,tA=a[gA],IA=o(x.vertex1);let QA=-1;for(let sA=0;sA<tA.vertices.length;sA++)if(o(tA.vertices[sA])===IA){QA=sA;break}const nA=tA.vertices.slice(0);nA.splice(QA,0,G);const DA=t.create(nA);a[gA]=DA,C(E,n,s,x.vertex0,x.vertex1,gA);const CA=B(E,n,s,x.vertex0,G,gA),hA=B(E,n,s,G,x.vertex1,gA);CA!==null&&r.set(CA,!0),hA!==null&&r.set(hA,!0),D=!1,w=2,c=!0;break}}}}}}D&&r.delete(l)}if(!c)break}i=a}return E.clear(),i};A.exports=Q}}),$6t=fg({"node_modules/@jscad/modeling/src/operations/modifiers/triangulatePolygons.js"(g,A){var I=yB(),e=vi(),t=(B,C,Q)=>{const i=C.vertices.length;if(i>3){if(i>4){const s=[0,0,0];C.vertices.forEach(r=>I.add(s,s,r)),I.snap(s,I.divide(s,s,[i,i,i]),B);for(let r=0;r<i;r++){const a=e.create([s,C.vertices[r],C.vertices[(r+1)%i]]);C.color&&(a.color=C.color),Q.push(a)}return}const E=e.create([C.vertices[0],C.vertices[1],C.vertices[2]]),n=e.create([C.vertices[0],C.vertices[2],C.vertices[3]]);C.color&&(E.color=C.color,n.color=C.color),Q.push(E,n);return}Q.push(C)},o=(B,C)=>{const Q=[];return C.forEach(i=>{t(B,i,Q)}),Q};A.exports=o}}),Avt=fg({"node_modules/@jscad/modeling/src/operations/modifiers/generalize.js"(g,A){var I=ZC(),e=c3(),t=RQ(),o=wQ(),B=ha(),C=mwI(),Q=z6t(),i=X6t(),E=$6t(),n=(c,h)=>h,s=(c,h)=>h,r=(c,h)=>{const l={snap:!1,simplify:!1,triangulate:!1},{snap:D,simplify:d,triangulate:y}=Object.assign({},l,c),w=e(h);let u=o.toPolygons(h);D&&(u=C(w,u)),d&&(u=Q(w,u)),y&&(u=i(u),u=E(w,u));const G=Object.assign({},h);return G.polygons=u,G},a=(c,...h)=>{if(h=I(h),h.length===0)throw new Error("wrong number of arguments");const l=h.map(D=>{if(B.isA(D))return n(c,D);if(t.isA(D))return s(c,D);if(o.isA(D))return r(c,D);throw new Error("invalid geometry")});return l.length===1?l[0]:l};A.exports=a}}),gvt=fg({"node_modules/@jscad/modeling/src/operations/modifiers/snap.js"(g,A){var I=ZC(),e=Qi(),t=RQ(),o=wQ(),B=ha(),C=c3(),Q=mwI(),i=r=>{const a=C(r),h=B.toPoints(r).map(l=>e.snap(e.create(),l,a));return B.create(h)},E=r=>{const a=C(r);let h=t.toSides(r).map(l=>[e.snap(e.create(),l[0],a),e.snap(e.create(),l[1],a)]);return h=h.filter(l=>!e.equals(l[0],l[1])),t.create(h)},n=r=>{const a=C(r),c=o.toPolygons(r),h=Q(a,c);return o.create(h)},s=(...r)=>{if(r=I(r),r.length===0)throw new Error("wrong number of arguments");const a=r.map(c=>B.isA(c)?i(c):t.isA(c)?E(c):o.isA(c)?n(c):c);return a.length===1?a[0]:a};A.exports=s}}),Ivt=fg({"node_modules/@jscad/modeling/src/operations/modifiers/index.js"(g,A){A.exports={generalize:Avt(),snap:gvt(),retessellate:rIA()}}}),evt=fg({"node_modules/@jscad/modeling/src/utils/padArrayToLength.js"(g,A){var I=(e,t,o)=>{for(e=e.slice();e.length<o;)e.push(t);return e};A.exports=I}}),tvt=fg({"node_modules/@jscad/modeling/src/operations/transforms/align.js"(g,A){var I=ZC(),e=evt(),t=IAg(),{translate:o}=a5(),B=E=>{if(!Array.isArray(E.modes)||E.modes.length>3)throw new Error("align(): modes must be an array of length <= 3");if(E.modes=e(E.modes,"none",3),E.modes.filter(n=>["center","max","min","none"].includes(n)).length!==3)throw new Error('align(): all modes must be one of "center", "max" or "min"');if(!Array.isArray(E.relativeTo)||E.relativeTo.length>3)throw new Error("align(): relativeTo must be an array of length <= 3");if(E.relativeTo=e(E.relativeTo,0,3),E.relativeTo.filter(n=>Number.isFinite(n)||n==null).length!==3)throw new Error("align(): all relativeTo values must be a number, or null.");if(typeof E.grouped!="boolean")throw new Error("align(): grouped must be a boolean value.");return E},C=(E,n,s)=>{for(let r=0;r<3;r++)E[r]==null&&(n[r]==="center"?E[r]=(s[0][r]+s[1][r])/2:n[r]==="max"?E[r]=s[1][r]:n[r]==="min"&&(E[r]=s[0][r]));return E},Q=(E,n,s)=>{const r=t(E),a=[0,0,0];for(let c=0;c<3;c++)n[c]==="center"?a[c]=s[c]-(r[0][c]+r[1][c])/2:n[c]==="max"?a[c]=s[c]-r[1][c]:n[c]==="min"&&(a[c]=s[c]-r[0][c]);return o(a,E)},i=(E,...n)=>{E=Object.assign({},{modes:["center","center","min"],relativeTo:[0,0,0],grouped:!1},E),E=B(E);let{modes:r,relativeTo:a,grouped:c}=E;if(n=I(n),n.length===0)throw new Error("align(): No geometries were provided to act upon");if(a.filter(h=>h==null).length){const h=t(n);a=C(a,r,h)}return c?n=Q(n,r,a):n=n.map(h=>Q(h,r,a)),n.length===1?n[0]:n};A.exports=i}}),gyA=fg({"node_modules/@jscad/modeling/src/operations/transforms/center.js"(g,A){var I=ZC(),e=RQ(),t=wQ(),o=ha(),B=n5(),{translate:C}=a5(),Q=(r,a)=>{const c={axes:[!0,!0,!0],relativeTo:[0,0,0]},{axes:h,relativeTo:l}=Object.assign({},c,r),D=B(a),d=[0,0,0];return h[0]&&(d[0]=l[0]-(D[0][0]+(D[1][0]-D[0][0])/2)),h[1]&&(d[1]=l[1]-(D[0][1]+(D[1][1]-D[0][1])/2)),h[2]&&(d[2]=l[2]-(D[0][2]+(D[1][2]-D[0][2])/2)),C(d,a)},i=(r,...a)=>{const c={axes:[!0,!0,!0],relativeTo:[0,0,0]},{axes:h,relativeTo:l}=Object.assign({},c,r);if(a=I(a),a.length===0)throw new Error("wrong number of arguments");if(l.length!==3)throw new Error("relativeTo must be an array of length 3");r={axes:h,relativeTo:l};const D=a.map(d=>o.isA(d)||e.isA(d)||t.isA(d)?Q(r,d):d);return D.length===1?D[0]:D},E=(...r)=>i({axes:[!0,!1,!1]},r),n=(...r)=>i({axes:[!1,!0,!1]},r),s=(...r)=>i({axes:[!1,!1,!0]},r);A.exports={center:i,centerX:E,centerY:n,centerZ:s}}}),IyA=fg({"node_modules/@jscad/modeling/src/operations/transforms/scale.js"(g,A){var I=ZC(),e=ba(),t=RQ(),o=wQ(),B=ha(),C=(n,...s)=>{if(!Array.isArray(n))throw new Error("factors must be an array");if(s=I(s),s.length===0)throw new Error("wrong number of arguments");for(n=n.slice();n.length<3;)n.push(1);if(n[0]<=0||n[1]<=0||n[2]<=0)throw new Error("factors must be positive");const r=e.fromScaling(e.create(),n),a=s.map(c=>B.isA(c)?B.transform(r,c):t.isA(c)?t.transform(r,c):o.isA(c)?o.transform(r,c):c);return a.length===1?a[0]:a},Q=(n,...s)=>C([n,1,1],s),i=(n,...s)=>C([1,n,1],s),E=(n,...s)=>C([1,1,n],s);A.exports={scale:C,scaleX:Q,scaleY:i,scaleZ:E}}}),ovt=fg({"node_modules/@jscad/modeling/src/operations/transforms/transform.js"(g,A){var I=ZC(),e=RQ(),t=wQ(),o=ha(),B=(C,...Q)=>{if(Q=I(Q),Q.length===0)throw new Error("wrong number of arguments");const i=Q.map(E=>o.isA(E)?o.transform(C,E):e.isA(E)?e.transform(C,E):t.isA(E)?t.transform(C,E):E);return i.length===1?i[0]:i};A.exports=B}}),c5=fg({"node_modules/@jscad/modeling/src/operations/transforms/index.js"(g,A){A.exports={align:tvt(),center:gyA().center,centerX:gyA().centerX,centerY:gyA().centerY,centerZ:gyA().centerZ,mirror:nIA().mirror,mirrorX:nIA().mirrorX,mirrorY:nIA().mirrorY,mirrorZ:nIA().mirrorZ,rotate:sIA().rotate,rotateX:sIA().rotateX,rotateY:sIA().rotateY,rotateZ:sIA().rotateZ,scale:IyA().scale,scaleX:IyA().scaleX,scaleY:IyA().scaleY,scaleZ:IyA().scaleZ,transform:ovt(),translate:a5().translate,translateX:a5().translateX,translateY:a5().translateY,translateZ:a5().translateZ}}}),eyA=fg({"node_modules/@jscad/modeling/src/index.js"(g,A){A.exports={colors:VdA(),curves:AHt(),geometries:z$A(),maths:pHt(),measurements:gwI(),primitives:r5(),text:E6t(),utils:hwI(),booleans:cIA(),expansions:uwI(),extrusions:hIA(),hulls:V6t(),minkowski:j6t(),modifiers:Ivt(),transforms:c5()}}}),pwI={};xR(pwI,{ANGLE_ORDER:()=>hAg,ARRAY_TYPE:()=>Ni,EPSILON:()=>rB,RANDOM:()=>Z2,equals:()=>ivt,round:()=>Dx,setMatrixArrayType:()=>Bvt,toDegree:()=>Qvt,toRadian:()=>Cvt});function Dx(g){return g>=0?Math.round(g):g%.5===0?Math.floor(g):Math.round(g)}function Bvt(g){Ni=g}function Cvt(g){return g*kwI}function Qvt(g){return g*MwI}function ivt(g,A){var I=arguments.length>2&&arguments[2]!==void 0?arguments[2]:rB;return Math.abs(g-A)<=I*Math.max(1,Math.abs(g),Math.abs(A))}var rB,Ni,Z2,hAg,kwI,MwI,dx=NR({"node_modules/gl-matrix/esm/common.js"(){rB=1e-6,Ni=typeof Float32Array<"u"?Float32Array:Array,Z2=Math.random,hAg="zyx",kwI=Math.PI/180,MwI=180/Math.PI}}),SwI={};xR(SwI,{LDU:()=>kvt,add:()=>Mvt,adjoint:()=>Dvt,clone:()=>nvt,copy:()=>svt,create:()=>Evt,determinant:()=>dvt,equals:()=>fvt,exactEquals:()=>Svt,frob:()=>pvt,fromRotation:()=>uvt,fromScaling:()=>Gvt,fromValues:()=>rvt,identity:()=>avt,invert:()=>lvt,mul:()=>NwI,multiply:()=>fwI,multiplyScalar:()=>Rvt,multiplyScalarAndAdd:()=>Nvt,rotate:()=>yvt,scale:()=>wvt,set:()=>cvt,str:()=>mvt,sub:()=>xwI,subtract:()=>RwI,transpose:()=>hvt});function Evt(){var g=new Ni(4);return Ni!=Float32Array&&(g[1]=0,g[2]=0),g[0]=1,g[3]=1,g}function nvt(g){var A=new Ni(4);return A[0]=g[0],A[1]=g[1],A[2]=g[2],A[3]=g[3],A}function svt(g,A){return g[0]=A[0],g[1]=A[1],g[2]=A[2],g[3]=A[3],g}function avt(g){return g[0]=1,g[1]=0,g[2]=0,g[3]=1,g}function rvt(g,A,I,e){var t=new Ni(4);return t[0]=g,t[1]=A,t[2]=I,t[3]=e,t}function cvt(g,A,I,e,t){return g[0]=A,g[1]=I,g[2]=e,g[3]=t,g}function hvt(g,A){if(g===A){var I=A[1];g[1]=A[2],g[2]=I}else g[0]=A[0],g[1]=A[2],g[2]=A[1],g[3]=A[3];return g}function lvt(g,A){var I=A[0],e=A[1],t=A[2],o=A[3],B=I*o-t*e;return B?(B=1/B,g[0]=o*B,g[1]=-e*B,g[2]=-t*B,g[3]=I*B,g):null}function Dvt(g,A){var I=A[0];return g[0]=A[3],g[1]=-A[1],g[2]=-A[2],g[3]=I,g}function dvt(g){return g[0]*g[3]-g[2]*g[1]}function fwI(g,A,I){var e=A[0],t=A[1],o=A[2],B=A[3],C=I[0],Q=I[1],i=I[2],E=I[3];return g[0]=e*C+o*Q,g[1]=t*C+B*Q,g[2]=e*i+o*E,g[3]=t*i+B*E,g}function yvt(g,A,I){var e=A[0],t=A[1],o=A[2],B=A[3],C=Math.sin(I),Q=Math.cos(I);return g[0]=e*Q+o*C,g[1]=t*Q+B*C,g[2]=e*-C+o*Q,g[3]=t*-C+B*Q,g}function wvt(g,A,I){var e=A[0],t=A[1],o=A[2],B=A[3],C=I[0],Q=I[1];return g[0]=e*C,g[1]=t*C,g[2]=o*Q,g[3]=B*Q,g}function uvt(g,A){var I=Math.sin(A),e=Math.cos(A);return g[0]=e,g[1]=I,g[2]=-I,g[3]=e,g}function Gvt(g,A){return g[0]=A[0],g[1]=0,g[2]=0,g[3]=A[1],g}function mvt(g){return"mat2("+g[0]+", "+g[1]+", "+g[2]+", "+g[3]+")"}function pvt(g){return Math.sqrt(g[0]*g[0]+g[1]*g[1]+g[2]*g[2]+g[3]*g[3])}function kvt(g,A,I,e){return g[2]=e[2]/e[0],I[0]=e[0],I[1]=e[1],I[3]=e[3]-g[2]*I[1],[g,A,I]}function Mvt(g,A,I){return g[0]=A[0]+I[0],g[1]=A[1]+I[1],g[2]=A[2]+I[2],g[3]=A[3]+I[3],g}function RwI(g,A,I){return g[0]=A[0]-I[0],g[1]=A[1]-I[1],g[2]=A[2]-I[2],g[3]=A[3]-I[3],g}function Svt(g,A){return g[0]===A[0]&&g[1]===A[1]&&g[2]===A[2]&&g[3]===A[3]}function fvt(g,A){var I=g[0],e=g[1],t=g[2],o=g[3],B=A[0],C=A[1],Q=A[2],i=A[3];return Math.abs(I-B)<=rB*Math.max(1,Math.abs(I),Math.abs(B))&&Math.abs(e-C)<=rB*Math.max(1,Math.abs(e),Math.abs(C))&&Math.abs(t-Q)<=rB*Math.max(1,Math.abs(t),Math.abs(Q))&&Math.abs(o-i)<=rB*Math.max(1,Math.abs(o),Math.abs(i))}function Rvt(g,A,I){return g[0]=A[0]*I,g[1]=A[1]*I,g[2]=A[2]*I,g[3]=A[3]*I,g}function Nvt(g,A,I,e){return g[0]=A[0]+I[0]*e,g[1]=A[1]+I[1]*e,g[2]=A[2]+I[2]*e,g[3]=A[3]+I[3]*e,g}var NwI,xwI,xvt=NR({"node_modules/gl-matrix/esm/mat2.js"(){dx(),NwI=fwI,xwI=RwI}}),FwI={};xR(FwI,{add:()=>Vvt,clone:()=>Uvt,copy:()=>Jvt,create:()=>Fvt,determinant:()=>_vt,equals:()=>$vt,exactEquals:()=>Xvt,frob:()=>Wvt,fromRotation:()=>qvt,fromScaling:()=>Tvt,fromTranslation:()=>Zvt,fromValues:()=>Kvt,identity:()=>Pvt,invert:()=>Yvt,mul:()=>PwI,multiply:()=>UwI,multiplyScalar:()=>jvt,multiplyScalarAndAdd:()=>zvt,rotate:()=>bvt,scale:()=>Hvt,set:()=>Lvt,str:()=>Ovt,sub:()=>KwI,subtract:()=>JwI,translate:()=>vvt});function Fvt(){var g=new Ni(6);return Ni!=Float32Array&&(g[1]=0,g[2]=0,g[4]=0,g[5]=0),g[0]=1,g[3]=1,g}function Uvt(g){var A=new Ni(6);return A[0]=g[0],A[1]=g[1],A[2]=g[2],A[3]=g[3],A[4]=g[4],A[5]=g[5],A}function Jvt(g,A){return g[0]=A[0],g[1]=A[1],g[2]=A[2],g[3]=A[3],g[4]=A[4],g[5]=A[5],g}function Pvt(g){return g[0]=1,g[1]=0,g[2]=0,g[3]=1,g[4]=0,g[5]=0,g}function Kvt(g,A,I,e,t,o){var B=new Ni(6);return B[0]=g,B[1]=A,B[2]=I,B[3]=e,B[4]=t,B[5]=o,B}function Lvt(g,A,I,e,t,o,B){return g[0]=A,g[1]=I,g[2]=e,g[3]=t,g[4]=o,g[5]=B,g}function Yvt(g,A){var I=A[0],e=A[1],t=A[2],o=A[3],B=A[4],C=A[5],Q=I*o-e*t;return Q?(Q=1/Q,g[0]=o*Q,g[1]=-e*Q,g[2]=-t*Q,g[3]=I*Q,g[4]=(t*C-o*B)*Q,g[5]=(e*B-I*C)*Q,g):null}function _vt(g){return g[0]*g[3]-g[1]*g[2]}function UwI(g,A,I){var e=A[0],t=A[1],o=A[2],B=A[3],C=A[4],Q=A[5],i=I[0],E=I[1],n=I[2],s=I[3],r=I[4],a=I[5];return g[0]=e*i+o*E,g[1]=t*i+B*E,g[2]=e*n+o*s,g[3]=t*n+B*s,g[4]=e*r+o*a+C,g[5]=t*r+B*a+Q,g}function bvt(g,A,I){var e=A[0],t=A[1],o=A[2],B=A[3],C=A[4],Q=A[5],i=Math.sin(I),E=Math.cos(I);return g[0]=e*E+o*i,g[1]=t*E+B*i,g[2]=e*-i+o*E,g[3]=t*-i+B*E,g[4]=C,g[5]=Q,g}function Hvt(g,A,I){var e=A[0],t=A[1],o=A[2],B=A[3],C=A[4],Q=A[5],i=I[0],E=I[1];return g[0]=e*i,g[1]=t*i,g[2]=o*E,g[3]=B*E,g[4]=C,g[5]=Q,g}function vvt(g,A,I){var e=A[0],t=A[1],o=A[2],B=A[3],C=A[4],Q=A[5],i=I[0],E=I[1];return g[0]=e,g[1]=t,g[2]=o,g[3]=B,g[4]=e*i+o*E+C,g[5]=t*i+B*E+Q,g}function qvt(g,A){var I=Math.sin(A),e=Math.cos(A);return g[0]=e,g[1]=I,g[2]=-I,g[3]=e,g[4]=0,g[5]=0,g}function Tvt(g,A){return g[0]=A[0],g[1]=0,g[2]=0,g[3]=A[1],g[4]=0,g[5]=0,g}function Zvt(g,A){return g[0]=1,g[1]=0,g[2]=0,g[3]=1,g[4]=A[0],g[5]=A[1],g}function Ovt(g){return"mat2d("+g[0]+", "+g[1]+", "+g[2]+", "+g[3]+", "+g[4]+", "+g[5]+")"}function Wvt(g){return Math.sqrt(g[0]*g[0]+g[1]*g[1]+g[2]*g[2]+g[3]*g[3]+g[4]*g[4]+g[5]*g[5]+1)}function Vvt(g,A,I){return g[0]=A[0]+I[0],g[1]=A[1]+I[1],g[2]=A[2]+I[2],g[3]=A[3]+I[3],g[4]=A[4]+I[4],g[5]=A[5]+I[5],g}function JwI(g,A,I){return g[0]=A[0]-I[0],g[1]=A[1]-I[1],g[2]=A[2]-I[2],g[3]=A[3]-I[3],g[4]=A[4]-I[4],g[5]=A[5]-I[5],g}function jvt(g,A,I){return g[0]=A[0]*I,g[1]=A[1]*I,g[2]=A[2]*I,g[3]=A[3]*I,g[4]=A[4]*I,g[5]=A[5]*I,g}function zvt(g,A,I,e){return g[0]=A[0]+I[0]*e,g[1]=A[1]+I[1]*e,g[2]=A[2]+I[2]*e,g[3]=A[3]+I[3]*e,g[4]=A[4]+I[4]*e,g[5]=A[5]+I[5]*e,g}function Xvt(g,A){return g[0]===A[0]&&g[1]===A[1]&&g[2]===A[2]&&g[3]===A[3]&&g[4]===A[4]&&g[5]===A[5]}function $vt(g,A){var I=g[0],e=g[1],t=g[2],o=g[3],B=g[4],C=g[5],Q=A[0],i=A[1],E=A[2],n=A[3],s=A[4],r=A[5];return Math.abs(I-Q)<=rB*Math.max(1,Math.abs(I),Math.abs(Q))&&Math.abs(e-i)<=rB*Math.max(1,Math.abs(e),Math.abs(i))&&Math.abs(t-E)<=rB*Math.max(1,Math.abs(t),Math.abs(E))&&Math.abs(o-n)<=rB*Math.max(1,Math.abs(o),Math.abs(n))&&Math.abs(B-s)<=rB*Math.max(1,Math.abs(B),Math.abs(s))&&Math.abs(C-r)<=rB*Math.max(1,Math.abs(C),Math.abs(r))}var PwI,KwI,Aqt=NR({"node_modules/gl-matrix/esm/mat2d.js"(){dx(),PwI=UwI,KwI=JwI}}),LwI={};xR(LwI,{add:()=>Gqt,adjoint:()=>iqt,clone:()=>Iqt,copy:()=>eqt,create:()=>YwI,determinant:()=>Eqt,equals:()=>Mqt,exactEquals:()=>kqt,frob:()=>uqt,fromMat2d:()=>lqt,fromMat4:()=>gqt,fromQuat:()=>Dqt,fromRotation:()=>cqt,fromScaling:()=>hqt,fromTranslation:()=>rqt,fromValues:()=>tqt,identity:()=>Bqt,invert:()=>Qqt,mul:()=>HwI,multiply:()=>_wI,multiplyScalar:()=>mqt,multiplyScalarAndAdd:()=>pqt,normalFromMat4:()=>dqt,projection:()=>yqt,rotate:()=>sqt,scale:()=>aqt,set:()=>oqt,str:()=>wqt,sub:()=>vwI,subtract:()=>bwI,translate:()=>nqt,transpose:()=>Cqt});function YwI(){var g=new Ni(9);return Ni!=Float32Array&&(g[1]=0,g[2]=0,g[3]=0,g[5]=0,g[6]=0,g[7]=0),g[0]=1,g[4]=1,g[8]=1,g}function gqt(g,A){return g[0]=A[0],g[1]=A[1],g[2]=A[2],g[3]=A[4],g[4]=A[5],g[5]=A[6],g[6]=A[8],g[7]=A[9],g[8]=A[10],g}function Iqt(g){var A=new Ni(9);return A[0]=g[0],A[1]=g[1],A[2]=g[2],A[3]=g[3],A[4]=g[4],A[5]=g[5],A[6]=g[6],A[7]=g[7],A[8]=g[8],A}function eqt(g,A){return g[0]=A[0],g[1]=A[1],g[2]=A[2],g[3]=A[3],g[4]=A[4],g[5]=A[5],g[6]=A[6],g[7]=A[7],g[8]=A[8],g}function tqt(g,A,I,e,t,o,B,C,Q){var i=new Ni(9);return i[0]=g,i[1]=A,i[2]=I,i[3]=e,i[4]=t,i[5]=o,i[6]=B,i[7]=C,i[8]=Q,i}function oqt(g,A,I,e,t,o,B,C,Q,i){return g[0]=A,g[1]=I,g[2]=e,g[3]=t,g[4]=o,g[5]=B,g[6]=C,g[7]=Q,g[8]=i,g}function Bqt(g){return g[0]=1,g[1]=0,g[2]=0,g[3]=0,g[4]=1,g[5]=0,g[6]=0,g[7]=0,g[8]=1,g}function Cqt(g,A){if(g===A){var I=A[1],e=A[2],t=A[5];g[1]=A[3],g[2]=A[6],g[3]=I,g[5]=A[7],g[6]=e,g[7]=t}else g[0]=A[0],g[1]=A[3],g[2]=A[6],g[3]=A[1],g[4]=A[4],g[5]=A[7],g[6]=A[2],g[7]=A[5],g[8]=A[8];return g}function Qqt(g,A){var I=A[0],e=A[1],t=A[2],o=A[3],B=A[4],C=A[5],Q=A[6],i=A[7],E=A[8],n=E*B-C*i,s=-E*o+C*Q,r=i*o-B*Q,a=I*n+e*s+t*r;return a?(a=1/a,g[0]=n*a,g[1]=(-E*e+t*i)*a,g[2]=(C*e-t*B)*a,g[3]=s*a,g[4]=(E*I-t*Q)*a,g[5]=(-C*I+t*o)*a,g[6]=r*a,g[7]=(-i*I+e*Q)*a,g[8]=(B*I-e*o)*a,g):null}function iqt(g,A){var I=A[0],e=A[1],t=A[2],o=A[3],B=A[4],C=A[5],Q=A[6],i=A[7],E=A[8];return g[0]=B*E-C*i,g[1]=t*i-e*E,g[2]=e*C-t*B,g[3]=C*Q-o*E,g[4]=I*E-t*Q,g[5]=t*o-I*C,g[6]=o*i-B*Q,g[7]=e*Q-I*i,g[8]=I*B-e*o,g}function Eqt(g){var A=g[0],I=g[1],e=g[2],t=g[3],o=g[4],B=g[5],C=g[6],Q=g[7],i=g[8];return A*(i*o-B*Q)+I*(-i*t+B*C)+e*(Q*t-o*C)}function _wI(g,A,I){var e=A[0],t=A[1],o=A[2],B=A[3],C=A[4],Q=A[5],i=A[6],E=A[7],n=A[8],s=I[0],r=I[1],a=I[2],c=I[3],h=I[4],l=I[5],D=I[6],d=I[7],y=I[8];return g[0]=s*e+r*B+a*i,g[1]=s*t+r*C+a*E,g[2]=s*o+r*Q+a*n,g[3]=c*e+h*B+l*i,g[4]=c*t+h*C+l*E,g[5]=c*o+h*Q+l*n,g[6]=D*e+d*B+y*i,g[7]=D*t+d*C+y*E,g[8]=D*o+d*Q+y*n,g}function nqt(g,A,I){var e=A[0],t=A[1],o=A[2],B=A[3],C=A[4],Q=A[5],i=A[6],E=A[7],n=A[8],s=I[0],r=I[1];return g[0]=e,g[1]=t,g[2]=o,g[3]=B,g[4]=C,g[5]=Q,g[6]=s*e+r*B+i,g[7]=s*t+r*C+E,g[8]=s*o+r*Q+n,g}function sqt(g,A,I){var e=A[0],t=A[1],o=A[2],B=A[3],C=A[4],Q=A[5],i=A[6],E=A[7],n=A[8],s=Math.sin(I),r=Math.cos(I);return g[0]=r*e+s*B,g[1]=r*t+s*C,g[2]=r*o+s*Q,g[3]=r*B-s*e,g[4]=r*C-s*t,g[5]=r*Q-s*o,g[6]=i,g[7]=E,g[8]=n,g}function aqt(g,A,I){var e=I[0],t=I[1];return g[0]=e*A[0],g[1]=e*A[1],g[2]=e*A[2],g[3]=t*A[3],g[4]=t*A[4],g[5]=t*A[5],g[6]=A[6],g[7]=A[7],g[8]=A[8],g}function rqt(g,A){return g[0]=1,g[1]=0,g[2]=0,g[3]=0,g[4]=1,g[5]=0,g[6]=A[0],g[7]=A[1],g[8]=1,g}function cqt(g,A){var I=Math.sin(A),e=Math.cos(A);return g[0]=e,g[1]=I,g[2]=0,g[3]=-I,g[4]=e,g[5]=0,g[6]=0,g[7]=0,g[8]=1,g}function hqt(g,A){return g[0]=A[0],g[1]=0,g[2]=0,g[3]=0,g[4]=A[1],g[5]=0,g[6]=0,g[7]=0,g[8]=1,g}function lqt(g,A){return g[0]=A[0],g[1]=A[1],g[2]=0,g[3]=A[2],g[4]=A[3],g[5]=0,g[6]=A[4],g[7]=A[5],g[8]=1,g}function Dqt(g,A){var I=A[0],e=A[1],t=A[2],o=A[3],B=I+I,C=e+e,Q=t+t,i=I*B,E=e*B,n=e*C,s=t*B,r=t*C,a=t*Q,c=o*B,h=o*C,l=o*Q;return g[0]=1-n-a,g[3]=E-l,g[6]=s+h,g[1]=E+l,g[4]=1-i-a,g[7]=r-c,g[2]=s-h,g[5]=r+c,g[8]=1-i-n,g}function dqt(g,A){var I=A[0],e=A[1],t=A[2],o=A[3],B=A[4],C=A[5],Q=A[6],i=A[7],E=A[8],n=A[9],s=A[10],r=A[11],a=A[12],c=A[13],h=A[14],l=A[15],D=I*C-e*B,d=I*Q-t*B,y=I*i-o*B,w=e*Q-t*C,u=e*i-o*C,G=t*i-o*Q,m=E*c-n*a,p=E*h-s*a,k=E*l-r*a,S=n*h-s*c,R=n*l-r*c,x=s*l-r*h,N=D*x-d*R+y*S+w*k-u*p+G*m;return N?(N=1/N,g[0]=(C*x-Q*R+i*S)*N,g[1]=(Q*k-B*x-i*p)*N,g[2]=(B*R-C*k+i*m)*N,g[3]=(t*R-e*x-o*S)*N,g[4]=(I*x-t*k+o*p)*N,g[5]=(e*k-I*R-o*m)*N,g[6]=(c*G-h*u+l*w)*N,g[7]=(h*y-a*G-l*d)*N,g[8]=(a*u-c*y+l*D)*N,g):null}function yqt(g,A,I){return g[0]=2/A,g[1]=0,g[2]=0,g[3]=0,g[4]=-2/I,g[5]=0,g[6]=-1,g[7]=1,g[8]=1,g}function wqt(g){return"mat3("+g[0]+", "+g[1]+", "+g[2]+", "+g[3]+", "+g[4]+", "+g[5]+", "+g[6]+", "+g[7]+", "+g[8]+")"}function uqt(g){return Math.sqrt(g[0]*g[0]+g[1]*g[1]+g[2]*g[2]+g[3]*g[3]+g[4]*g[4]+g[5]*g[5]+g[6]*g[6]+g[7]*g[7]+g[8]*g[8])}function Gqt(g,A,I){return g[0]=A[0]+I[0],g[1]=A[1]+I[1],g[2]=A[2]+I[2],g[3]=A[3]+I[3],g[4]=A[4]+I[4],g[5]=A[5]+I[5],g[6]=A[6]+I[6],g[7]=A[7]+I[7],g[8]=A[8]+I[8],g}function bwI(g,A,I){return g[0]=A[0]-I[0],g[1]=A[1]-I[1],g[2]=A[2]-I[2],g[3]=A[3]-I[3],g[4]=A[4]-I[4],g[5]=A[5]-I[5],g[6]=A[6]-I[6],g[7]=A[7]-I[7],g[8]=A[8]-I[8],g}function mqt(g,A,I){return g[0]=A[0]*I,g[1]=A[1]*I,g[2]=A[2]*I,g[3]=A[3]*I,g[4]=A[4]*I,g[5]=A[5]*I,g[6]=A[6]*I,g[7]=A[7]*I,g[8]=A[8]*I,g}function pqt(g,A,I,e){return g[0]=A[0]+I[0]*e,g[1]=A[1]+I[1]*e,g[2]=A[2]+I[2]*e,g[3]=A[3]+I[3]*e,g[4]=A[4]+I[4]*e,g[5]=A[5]+I[5]*e,g[6]=A[6]+I[6]*e,g[7]=A[7]+I[7]*e,g[8]=A[8]+I[8]*e,g}function kqt(g,A){return g[0]===A[0]&&g[1]===A[1]&&g[2]===A[2]&&g[3]===A[3]&&g[4]===A[4]&&g[5]===A[5]&&g[6]===A[6]&&g[7]===A[7]&&g[8]===A[8]}function Mqt(g,A){var I=g[0],e=g[1],t=g[2],o=g[3],B=g[4],C=g[5],Q=g[6],i=g[7],E=g[8],n=A[0],s=A[1],r=A[2],a=A[3],c=A[4],h=A[5],l=A[6],D=A[7],d=A[8];return Math.abs(I-n)<=rB*Math.max(1,Math.abs(I),Math.abs(n))&&Math.abs(e-s)<=rB*Math.max(1,Math.abs(e),Math.abs(s))&&Math.abs(t-r)<=rB*Math.max(1,Math.abs(t),Math.abs(r))&&Math.abs(o-a)<=rB*Math.max(1,Math.abs(o),Math.abs(a))&&Math.abs(B-c)<=rB*Math.max(1,Math.abs(B),Math.abs(c))&&Math.abs(C-h)<=rB*Math.max(1,Math.abs(C),Math.abs(h))&&Math.abs(Q-l)<=rB*Math.max(1,Math.abs(Q),Math.abs(l))&&Math.abs(i-D)<=rB*Math.max(1,Math.abs(i),Math.abs(D))&&Math.abs(E-d)<=rB*Math.max(1,Math.abs(E),Math.abs(d))}var HwI,vwI,qwI=NR({"node_modules/gl-matrix/esm/mat3.js"(){dx(),HwI=_wI,vwI=bwI}}),TwI={};xR(TwI,{add:()=>QTt,adjoint:()=>Jqt,clone:()=>fqt,copy:()=>Rqt,create:()=>Sqt,decompose:()=>jqt,determinant:()=>Pqt,equals:()=>sTt,exactEquals:()=>nTt,frob:()=>CTt,fromQuat:()=>$qt,fromQuat2:()=>Vqt,fromRotation:()=>Tqt,fromRotationTranslation:()=>WwI,fromRotationTranslationScale:()=>zqt,fromRotationTranslationScaleOrigin:()=>Xqt,fromScaling:()=>qqt,fromTranslation:()=>vqt,fromValues:()=>Nqt,fromXRotation:()=>Zqt,fromYRotation:()=>Oqt,fromZRotation:()=>Wqt,frustum:()=>ATt,getRotation:()=>zwI,getScaling:()=>jwI,getTranslation:()=>VwI,identity:()=>ZwI,invert:()=>Uqt,lookAt:()=>tTt,mul:()=>euI,multiply:()=>OwI,multiplyScalar:()=>iTt,multiplyScalarAndAdd:()=>ETt,ortho:()=>IuI,orthoNO:()=>$wI,orthoZO:()=>eTt,perspective:()=>guI,perspectiveFromFieldOfView:()=>ITt,perspectiveNO:()=>XwI,perspectiveZO:()=>gTt,rotate:()=>Yqt,rotateX:()=>_qt,rotateY:()=>bqt,rotateZ:()=>Hqt,scale:()=>Lqt,set:()=>xqt,str:()=>BTt,sub:()=>tuI,subtract:()=>AuI,targetTo:()=>oTt,translate:()=>Kqt,transpose:()=>Fqt});function Sqt(){var g=new Ni(16);return Ni!=Float32Array&&(g[1]=0,g[2]=0,g[3]=0,g[4]=0,g[6]=0,g[7]=0,g[8]=0,g[9]=0,g[11]=0,g[12]=0,g[13]=0,g[14]=0),g[0]=1,g[5]=1,g[10]=1,g[15]=1,g}function fqt(g){var A=new Ni(16);return A[0]=g[0],A[1]=g[1],A[2]=g[2],A[3]=g[3],A[4]=g[4],A[5]=g[5],A[6]=g[6],A[7]=g[7],A[8]=g[8],A[9]=g[9],A[10]=g[10],A[11]=g[11],A[12]=g[12],A[13]=g[13],A[14]=g[14],A[15]=g[15],A}function Rqt(g,A){return g[0]=A[0],g[1]=A[1],g[2]=A[2],g[3]=A[3],g[4]=A[4],g[5]=A[5],g[6]=A[6],g[7]=A[7],g[8]=A[8],g[9]=A[9],g[10]=A[10],g[11]=A[11],g[12]=A[12],g[13]=A[13],g[14]=A[14],g[15]=A[15],g}function Nqt(g,A,I,e,t,o,B,C,Q,i,E,n,s,r,a,c){var h=new Ni(16);return h[0]=g,h[1]=A,h[2]=I,h[3]=e,h[4]=t,h[5]=o,h[6]=B,h[7]=C,h[8]=Q,h[9]=i,h[10]=E,h[11]=n,h[12]=s,h[13]=r,h[14]=a,h[15]=c,h}function xqt(g,A,I,e,t,o,B,C,Q,i,E,n,s,r,a,c,h){return g[0]=A,g[1]=I,g[2]=e,g[3]=t,g[4]=o,g[5]=B,g[6]=C,g[7]=Q,g[8]=i,g[9]=E,g[10]=n,g[11]=s,g[12]=r,g[13]=a,g[14]=c,g[15]=h,g}function ZwI(g){return g[0]=1,g[1]=0,g[2]=0,g[3]=0,g[4]=0,g[5]=1,g[6]=0,g[7]=0,g[8]=0,g[9]=0,g[10]=1,g[11]=0,g[12]=0,g[13]=0,g[14]=0,g[15]=1,g}function Fqt(g,A){if(g===A){var I=A[1],e=A[2],t=A[3],o=A[6],B=A[7],C=A[11];g[1]=A[4],g[2]=A[8],g[3]=A[12],g[4]=I,g[6]=A[9],g[7]=A[13],g[8]=e,g[9]=o,g[11]=A[14],g[12]=t,g[13]=B,g[14]=C}else g[0]=A[0],g[1]=A[4],g[2]=A[8],g[3]=A[12],g[4]=A[1],g[5]=A[5],g[6]=A[9],g[7]=A[13],g[8]=A[2],g[9]=A[6],g[10]=A[10],g[11]=A[14],g[12]=A[3],g[13]=A[7],g[14]=A[11],g[15]=A[15];return g}function Uqt(g,A){var I=A[0],e=A[1],t=A[2],o=A[3],B=A[4],C=A[5],Q=A[6],i=A[7],E=A[8],n=A[9],s=A[10],r=A[11],a=A[12],c=A[13],h=A[14],l=A[15],D=I*C-e*B,d=I*Q-t*B,y=I*i-o*B,w=e*Q-t*C,u=e*i-o*C,G=t*i-o*Q,m=E*c-n*a,p=E*h-s*a,k=E*l-r*a,S=n*h-s*c,R=n*l-r*c,x=s*l-r*h,N=D*x-d*R+y*S+w*k-u*p+G*m;return N?(N=1/N,g[0]=(C*x-Q*R+i*S)*N,g[1]=(t*R-e*x-o*S)*N,g[2]=(c*G-h*u+l*w)*N,g[3]=(s*u-n*G-r*w)*N,g[4]=(Q*k-B*x-i*p)*N,g[5]=(I*x-t*k+o*p)*N,g[6]=(h*y-a*G-l*d)*N,g[7]=(E*G-s*y+r*d)*N,g[8]=(B*R-C*k+i*m)*N,g[9]=(e*k-I*R-o*m)*N,g[10]=(a*u-c*y+l*D)*N,g[11]=(n*y-E*u-r*D)*N,g[12]=(C*p-B*S-Q*m)*N,g[13]=(I*S-e*p+t*m)*N,g[14]=(c*d-a*w-h*D)*N,g[15]=(E*w-n*d+s*D)*N,g):null}function Jqt(g,A){var I=A[0],e=A[1],t=A[2],o=A[3],B=A[4],C=A[5],Q=A[6],i=A[7],E=A[8],n=A[9],s=A[10],r=A[11],a=A[12],c=A[13],h=A[14],l=A[15],D=I*C-e*B,d=I*Q-t*B,y=I*i-o*B,w=e*Q-t*C,u=e*i-o*C,G=t*i-o*Q,m=E*c-n*a,p=E*h-s*a,k=E*l-r*a,S=n*h-s*c,R=n*l-r*c,x=s*l-r*h;return g[0]=C*x-Q*R+i*S,g[1]=t*R-e*x-o*S,g[2]=c*G-h*u+l*w,g[3]=s*u-n*G-r*w,g[4]=Q*k-B*x-i*p,g[5]=I*x-t*k+o*p,g[6]=h*y-a*G-l*d,g[7]=E*G-s*y+r*d,g[8]=B*R-C*k+i*m,g[9]=e*k-I*R-o*m,g[10]=a*u-c*y+l*D,g[11]=n*y-E*u-r*D,g[12]=C*p-B*S-Q*m,g[13]=I*S-e*p+t*m,g[14]=c*d-a*w-h*D,g[15]=E*w-n*d+s*D,g}function Pqt(g){var A=g[0],I=g[1],e=g[2],t=g[3],o=g[4],B=g[5],C=g[6],Q=g[7],i=g[8],E=g[9],n=g[10],s=g[11],r=g[12],a=g[13],c=g[14],h=g[15],l=A*B-I*o,D=A*C-e*o,d=I*C-e*B,y=i*a-E*r,w=i*c-n*r,u=E*c-n*a,G=A*u-I*w+e*y,m=o*u-B*w+C*y,p=i*d-E*D+n*l,k=r*d-a*D+c*l;return Q*G-t*m+h*p-s*k}function OwI(g,A,I){var e=A[0],t=A[1],o=A[2],B=A[3],C=A[4],Q=A[5],i=A[6],E=A[7],n=A[8],s=A[9],r=A[10],a=A[11],c=A[12],h=A[13],l=A[14],D=A[15],d=I[0],y=I[1],w=I[2],u=I[3];return g[0]=d*e+y*C+w*n+u*c,g[1]=d*t+y*Q+w*s+u*h,g[2]=d*o+y*i+w*r+u*l,g[3]=d*B+y*E+w*a+u*D,d=I[4],y=I[5],w=I[6],u=I[7],g[4]=d*e+y*C+w*n+u*c,g[5]=d*t+y*Q+w*s+u*h,g[6]=d*o+y*i+w*r+u*l,g[7]=d*B+y*E+w*a+u*D,d=I[8],y=I[9],w=I[10],u=I[11],g[8]=d*e+y*C+w*n+u*c,g[9]=d*t+y*Q+w*s+u*h,g[10]=d*o+y*i+w*r+u*l,g[11]=d*B+y*E+w*a+u*D,d=I[12],y=I[13],w=I[14],u=I[15],g[12]=d*e+y*C+w*n+u*c,g[13]=d*t+y*Q+w*s+u*h,g[14]=d*o+y*i+w*r+u*l,g[15]=d*B+y*E+w*a+u*D,g}function Kqt(g,A,I){var e=I[0],t=I[1],o=I[2],B,C,Q,i,E,n,s,r,a,c,h,l;return A===g?(g[12]=A[0]*e+A[4]*t+A[8]*o+A[12],g[13]=A[1]*e+A[5]*t+A[9]*o+A[13],g[14]=A[2]*e+A[6]*t+A[10]*o+A[14],g[15]=A[3]*e+A[7]*t+A[11]*o+A[15]):(B=A[0],C=A[1],Q=A[2],i=A[3],E=A[4],n=A[5],s=A[6],r=A[7],a=A[8],c=A[9],h=A[10],l=A[11],g[0]=B,g[1]=C,g[2]=Q,g[3]=i,g[4]=E,g[5]=n,g[6]=s,g[7]=r,g[8]=a,g[9]=c,g[10]=h,g[11]=l,g[12]=B*e+E*t+a*o+A[12],g[13]=C*e+n*t+c*o+A[13],g[14]=Q*e+s*t+h*o+A[14],g[15]=i*e+r*t+l*o+A[15]),g}function Lqt(g,A,I){var e=I[0],t=I[1],o=I[2];return g[0]=A[0]*e,g[1]=A[1]*e,g[2]=A[2]*e,g[3]=A[3]*e,g[4]=A[4]*t,g[5]=A[5]*t,g[6]=A[6]*t,g[7]=A[7]*t,g[8]=A[8]*o,g[9]=A[9]*o,g[10]=A[10]*o,g[11]=A[11]*o,g[12]=A[12],g[13]=A[13],g[14]=A[14],g[15]=A[15],g}function Yqt(g,A,I,e){var t=e[0],o=e[1],B=e[2],C=Math.sqrt(t*t+o*o+B*B),Q,i,E,n,s,r,a,c,h,l,D,d,y,w,u,G,m,p,k,S,R,x,N,J;return C<rB?null:(C=1/C,t*=C,o*=C,B*=C,Q=Math.sin(I),i=Math.cos(I),E=1-i,n=A[0],s=A[1],r=A[2],a=A[3],c=A[4],h=A[5],l=A[6],D=A[7],d=A[8],y=A[9],w=A[10],u=A[11],G=t*t*E+i,m=o*t*E+B*Q,p=B*t*E-o*Q,k=t*o*E-B*Q,S=o*o*E+i,R=B*o*E+t*Q,x=t*B*E+o*Q,N=o*B*E-t*Q,J=B*B*E+i,g[0]=n*G+c*m+d*p,g[1]=s*G+h*m+y*p,g[2]=r*G+l*m+w*p,g[3]=a*G+D*m+u*p,g[4]=n*k+c*S+d*R,g[5]=s*k+h*S+y*R,g[6]=r*k+l*S+w*R,g[7]=a*k+D*S+u*R,g[8]=n*x+c*N+d*J,g[9]=s*x+h*N+y*J,g[10]=r*x+l*N+w*J,g[11]=a*x+D*N+u*J,A!==g&&(g[12]=A[12],g[13]=A[13],g[14]=A[14],g[15]=A[15]),g)}function _qt(g,A,I){var e=Math.sin(I),t=Math.cos(I),o=A[4],B=A[5],C=A[6],Q=A[7],i=A[8],E=A[9],n=A[10],s=A[11];return A!==g&&(g[0]=A[0],g[1]=A[1],g[2]=A[2],g[3]=A[3],g[12]=A[12],g[13]=A[13],g[14]=A[14],g[15]=A[15]),g[4]=o*t+i*e,g[5]=B*t+E*e,g[6]=C*t+n*e,g[7]=Q*t+s*e,g[8]=i*t-o*e,g[9]=E*t-B*e,g[10]=n*t-C*e,g[11]=s*t-Q*e,g}function bqt(g,A,I){var e=Math.sin(I),t=Math.cos(I),o=A[0],B=A[1],C=A[2],Q=A[3],i=A[8],E=A[9],n=A[10],s=A[11];return A!==g&&(g[4]=A[4],g[5]=A[5],g[6]=A[6],g[7]=A[7],g[12]=A[12],g[13]=A[13],g[14]=A[14],g[15]=A[15]),g[0]=o*t-i*e,g[1]=B*t-E*e,g[2]=C*t-n*e,g[3]=Q*t-s*e,g[8]=o*e+i*t,g[9]=B*e+E*t,g[10]=C*e+n*t,g[11]=Q*e+s*t,g}function Hqt(g,A,I){var e=Math.sin(I),t=Math.cos(I),o=A[0],B=A[1],C=A[2],Q=A[3],i=A[4],E=A[5],n=A[6],s=A[7];return A!==g&&(g[8]=A[8],g[9]=A[9],g[10]=A[10],g[11]=A[11],g[12]=A[12],g[13]=A[13],g[14]=A[14],g[15]=A[15]),g[0]=o*t+i*e,g[1]=B*t+E*e,g[2]=C*t+n*e,g[3]=Q*t+s*e,g[4]=i*t-o*e,g[5]=E*t-B*e,g[6]=n*t-C*e,g[7]=s*t-Q*e,g}function vqt(g,A){return g[0]=1,g[1]=0,g[2]=0,g[3]=0,g[4]=0,g[5]=1,g[6]=0,g[7]=0,g[8]=0,g[9]=0,g[10]=1,g[11]=0,g[12]=A[0],g[13]=A[1],g[14]=A[2],g[15]=1,g}function qqt(g,A){return g[0]=A[0],g[1]=0,g[2]=0,g[3]=0,g[4]=0,g[5]=A[1],g[6]=0,g[7]=0,g[8]=0,g[9]=0,g[10]=A[2],g[11]=0,g[12]=0,g[13]=0,g[14]=0,g[15]=1,g}function Tqt(g,A,I){var e=I[0],t=I[1],o=I[2],B=Math.sqrt(e*e+t*t+o*o),C,Q,i;return B<rB?null:(B=1/B,e*=B,t*=B,o*=B,C=Math.sin(A),Q=Math.cos(A),i=1-Q,g[0]=e*e*i+Q,g[1]=t*e*i+o*C,g[2]=o*e*i-t*C,g[3]=0,g[4]=e*t*i-o*C,g[5]=t*t*i+Q,g[6]=o*t*i+e*C,g[7]=0,g[8]=e*o*i+t*C,g[9]=t*o*i-e*C,g[10]=o*o*i+Q,g[11]=0,g[12]=0,g[13]=0,g[14]=0,g[15]=1,g)}function Zqt(g,A){var I=Math.sin(A),e=Math.cos(A);return g[0]=1,g[1]=0,g[2]=0,g[3]=0,g[4]=0,g[5]=e,g[6]=I,g[7]=0,g[8]=0,g[9]=-I,g[10]=e,g[11]=0,g[12]=0,g[13]=0,g[14]=0,g[15]=1,g}function Oqt(g,A){var I=Math.sin(A),e=Math.cos(A);return g[0]=e,g[1]=0,g[2]=-I,g[3]=0,g[4]=0,g[5]=1,g[6]=0,g[7]=0,g[8]=I,g[9]=0,g[10]=e,g[11]=0,g[12]=0,g[13]=0,g[14]=0,g[15]=1,g}function Wqt(g,A){var I=Math.sin(A),e=Math.cos(A);return g[0]=e,g[1]=I,g[2]=0,g[3]=0,g[4]=-I,g[5]=e,g[6]=0,g[7]=0,g[8]=0,g[9]=0,g[10]=1,g[11]=0,g[12]=0,g[13]=0,g[14]=0,g[15]=1,g}function WwI(g,A,I){var e=A[0],t=A[1],o=A[2],B=A[3],C=e+e,Q=t+t,i=o+o,E=e*C,n=e*Q,s=e*i,r=t*Q,a=t*i,c=o*i,h=B*C,l=B*Q,D=B*i;return g[0]=1-(r+c),g[1]=n+D,g[2]=s-l,g[3]=0,g[4]=n-D,g[5]=1-(E+c),g[6]=a+h,g[7]=0,g[8]=s+l,g[9]=a-h,g[10]=1-(E+r),g[11]=0,g[12]=I[0],g[13]=I[1],g[14]=I[2],g[15]=1,g}function Vqt(g,A){var I=new Ni(3),e=-A[0],t=-A[1],o=-A[2],B=A[3],C=A[4],Q=A[5],i=A[6],E=A[7],n=e*e+t*t+o*o+B*B;return n>0?(I[0]=(C*B+E*e+Q*o-i*t)*2/n,I[1]=(Q*B+E*t+i*e-C*o)*2/n,I[2]=(i*B+E*o+C*t-Q*e)*2/n):(I[0]=(C*B+E*e+Q*o-i*t)*2,I[1]=(Q*B+E*t+i*e-C*o)*2,I[2]=(i*B+E*o+C*t-Q*e)*2),WwI(g,A,I),g}function VwI(g,A){return g[0]=A[12],g[1]=A[13],g[2]=A[14],g}function jwI(g,A){var I=A[0],e=A[1],t=A[2],o=A[4],B=A[5],C=A[6],Q=A[8],i=A[9],E=A[10];return g[0]=Math.sqrt(I*I+e*e+t*t),g[1]=Math.sqrt(o*o+B*B+C*C),g[2]=Math.sqrt(Q*Q+i*i+E*E),g}function zwI(g,A){var I=new Ni(3);jwI(I,A);var e=1/I[0],t=1/I[1],o=1/I[2],B=A[0]*e,C=A[1]*t,Q=A[2]*o,i=A[4]*e,E=A[5]*t,n=A[6]*o,s=A[8]*e,r=A[9]*t,a=A[10]*o,c=B+E+a,h=0;return c>0?(h=Math.sqrt(c+1)*2,g[3]=.25*h,g[0]=(n-r)/h,g[1]=(s-Q)/h,g[2]=(C-i)/h):B>E&&B>a?(h=Math.sqrt(1+B-E-a)*2,g[3]=(n-r)/h,g[0]=.25*h,g[1]=(C+i)/h,g[2]=(s+Q)/h):E>a?(h=Math.sqrt(1+E-B-a)*2,g[3]=(s-Q)/h,g[0]=(C+i)/h,g[1]=.25*h,g[2]=(n+r)/h):(h=Math.sqrt(1+a-B-E)*2,g[3]=(C-i)/h,g[0]=(s+Q)/h,g[1]=(n+r)/h,g[2]=.25*h),g}function jqt(g,A,I,e){A[0]=e[12],A[1]=e[13],A[2]=e[14];var t=e[0],o=e[1],B=e[2],C=e[4],Q=e[5],i=e[6],E=e[8],n=e[9],s=e[10];I[0]=Math.sqrt(t*t+o*o+B*B),I[1]=Math.sqrt(C*C+Q*Q+i*i),I[2]=Math.sqrt(E*E+n*n+s*s);var r=1/I[0],a=1/I[1],c=1/I[2],h=t*r,l=o*a,D=B*c,d=C*r,y=Q*a,w=i*c,u=E*r,G=n*a,m=s*c,p=h+y+m,k=0;return p>0?(k=Math.sqrt(p+1)*2,g[3]=.25*k,g[0]=(w-G)/k,g[1]=(u-D)/k,g[2]=(l-d)/k):h>y&&h>m?(k=Math.sqrt(1+h-y-m)*2,g[3]=(w-G)/k,g[0]=.25*k,g[1]=(l+d)/k,g[2]=(u+D)/k):y>m?(k=Math.sqrt(1+y-h-m)*2,g[3]=(u-D)/k,g[0]=(l+d)/k,g[1]=.25*k,g[2]=(w+G)/k):(k=Math.sqrt(1+m-h-y)*2,g[3]=(l-d)/k,g[0]=(u+D)/k,g[1]=(w+G)/k,g[2]=.25*k),g}function zqt(g,A,I,e){var t=A[0],o=A[1],B=A[2],C=A[3],Q=t+t,i=o+o,E=B+B,n=t*Q,s=t*i,r=t*E,a=o*i,c=o*E,h=B*E,l=C*Q,D=C*i,d=C*E,y=e[0],w=e[1],u=e[2];return g[0]=(1-(a+h))*y,g[1]=(s+d)*y,g[2]=(r-D)*y,g[3]=0,g[4]=(s-d)*w,g[5]=(1-(n+h))*w,g[6]=(c+l)*w,g[7]=0,g[8]=(r+D)*u,g[9]=(c-l)*u,g[10]=(1-(n+a))*u,g[11]=0,g[12]=I[0],g[13]=I[1],g[14]=I[2],g[15]=1,g}function Xqt(g,A,I,e,t){var o=A[0],B=A[1],C=A[2],Q=A[3],i=o+o,E=B+B,n=C+C,s=o*i,r=o*E,a=o*n,c=B*E,h=B*n,l=C*n,D=Q*i,d=Q*E,y=Q*n,w=e[0],u=e[1],G=e[2],m=t[0],p=t[1],k=t[2],S=(1-(c+l))*w,R=(r+y)*w,x=(a-d)*w,N=(r-y)*u,J=(1-(s+l))*u,K=(h+D)*u,_=(a+d)*G,b=(h-D)*G,T=(1-(s+c))*G;return g[0]=S,g[1]=R,g[2]=x,g[3]=0,g[4]=N,g[5]=J,g[6]=K,g[7]=0,g[8]=_,g[9]=b,g[10]=T,g[11]=0,g[12]=I[0]+m-(S*m+N*p+_*k),g[13]=I[1]+p-(R*m+J*p+b*k),g[14]=I[2]+k-(x*m+K*p+T*k),g[15]=1,g}function $qt(g,A){var I=A[0],e=A[1],t=A[2],o=A[3],B=I+I,C=e+e,Q=t+t,i=I*B,E=e*B,n=e*C,s=t*B,r=t*C,a=t*Q,c=o*B,h=o*C,l=o*Q;return g[0]=1-n-a,g[1]=E+l,g[2]=s-h,g[3]=0,g[4]=E-l,g[5]=1-i-a,g[6]=r+c,g[7]=0,g[8]=s+h,g[9]=r-c,g[10]=1-i-n,g[11]=0,g[12]=0,g[13]=0,g[14]=0,g[15]=1,g}function ATt(g,A,I,e,t,o,B){var C=1/(I-A),Q=1/(t-e),i=1/(o-B);return g[0]=o*2*C,g[1]=0,g[2]=0,g[3]=0,g[4]=0,g[5]=o*2*Q,g[6]=0,g[7]=0,g[8]=(I+A)*C,g[9]=(t+e)*Q,g[10]=(B+o)*i,g[11]=-1,g[12]=0,g[13]=0,g[14]=B*o*2*i,g[15]=0,g}function XwI(g,A,I,e,t){var o=1/Math.tan(A/2);if(g[0]=o/I,g[1]=0,g[2]=0,g[3]=0,g[4]=0,g[5]=o,g[6]=0,g[7]=0,g[8]=0,g[9]=0,g[11]=-1,g[12]=0,g[13]=0,g[15]=0,t!=null&&t!==1/0){var B=1/(e-t);g[10]=(t+e)*B,g[14]=2*t*e*B}else g[10]=-1,g[14]=-2*e;return g}function gTt(g,A,I,e,t){var o=1/Math.tan(A/2);if(g[0]=o/I,g[1]=0,g[2]=0,g[3]=0,g[4]=0,g[5]=o,g[6]=0,g[7]=0,g[8]=0,g[9]=0,g[11]=-1,g[12]=0,g[13]=0,g[15]=0,t!=null&&t!==1/0){var B=1/(e-t);g[10]=t*B,g[14]=t*e*B}else g[10]=-1,g[14]=-e;return g}function ITt(g,A,I,e){var t=Math.tan(A.upDegrees*Math.PI/180),o=Math.tan(A.downDegrees*Math.PI/180),B=Math.tan(A.leftDegrees*Math.PI/180),C=Math.tan(A.rightDegrees*Math.PI/180),Q=2/(B+C),i=2/(t+o);return g[0]=Q,g[1]=0,g[2]=0,g[3]=0,g[4]=0,g[5]=i,g[6]=0,g[7]=0,g[8]=-((B-C)*Q*.5),g[9]=(t-o)*i*.5,g[10]=e/(I-e),g[11]=-1,g[12]=0,g[13]=0,g[14]=e*I/(I-e),g[15]=0,g}function $wI(g,A,I,e,t,o,B){var C=1/(A-I),Q=1/(e-t),i=1/(o-B);return g[0]=-2*C,g[1]=0,g[2]=0,g[3]=0,g[4]=0,g[5]=-2*Q,g[6]=0,g[7]=0,g[8]=0,g[9]=0,g[10]=2*i,g[11]=0,g[12]=(A+I)*C,g[13]=(t+e)*Q,g[14]=(B+o)*i,g[15]=1,g}function eTt(g,A,I,e,t,o,B){var C=1/(A-I),Q=1/(e-t),i=1/(o-B);return g[0]=-2*C,g[1]=0,g[2]=0,g[3]=0,g[4]=0,g[5]=-2*Q,g[6]=0,g[7]=0,g[8]=0,g[9]=0,g[10]=i,g[11]=0,g[12]=(A+I)*C,g[13]=(t+e)*Q,g[14]=o*i,g[15]=1,g}function tTt(g,A,I,e){var t,o,B,C,Q,i,E,n,s,r,a=A[0],c=A[1],h=A[2],l=e[0],D=e[1],d=e[2],y=I[0],w=I[1],u=I[2];return Math.abs(a-y)<rB&&Math.abs(c-w)<rB&&Math.abs(h-u)<rB?ZwI(g):(E=a-y,n=c-w,s=h-u,r=1/Math.sqrt(E*E+n*n+s*s),E*=r,n*=r,s*=r,t=D*s-d*n,o=d*E-l*s,B=l*n-D*E,r=Math.sqrt(t*t+o*o+B*B),r?(r=1/r,t*=r,o*=r,B*=r):(t=0,o=0,B=0),C=n*B-s*o,Q=s*t-E*B,i=E*o-n*t,r=Math.sqrt(C*C+Q*Q+i*i),r?(r=1/r,C*=r,Q*=r,i*=r):(C=0,Q=0,i=0),g[0]=t,g[1]=C,g[2]=E,g[3]=0,g[4]=o,g[5]=Q,g[6]=n,g[7]=0,g[8]=B,g[9]=i,g[10]=s,g[11]=0,g[12]=-(t*a+o*c+B*h),g[13]=-(C*a+Q*c+i*h),g[14]=-(E*a+n*c+s*h),g[15]=1,g)}function oTt(g,A,I,e){var t=A[0],o=A[1],B=A[2],C=e[0],Q=e[1],i=e[2],E=t-I[0],n=o-I[1],s=B-I[2],r=E*E+n*n+s*s;r>0&&(r=1/Math.sqrt(r),E*=r,n*=r,s*=r);var a=Q*s-i*n,c=i*E-C*s,h=C*n-Q*E;return r=a*a+c*c+h*h,r>0&&(r=1/Math.sqrt(r),a*=r,c*=r,h*=r),g[0]=a,g[1]=c,g[2]=h,g[3]=0,g[4]=n*h-s*c,g[5]=s*a-E*h,g[6]=E*c-n*a,g[7]=0,g[8]=E,g[9]=n,g[10]=s,g[11]=0,g[12]=t,g[13]=o,g[14]=B,g[15]=1,g}function BTt(g){return"mat4("+g[0]+", "+g[1]+", "+g[2]+", "+g[3]+", "+g[4]+", "+g[5]+", "+g[6]+", "+g[7]+", "+g[8]+", "+g[9]+", "+g[10]+", "+g[11]+", "+g[12]+", "+g[13]+", "+g[14]+", "+g[15]+")"}function CTt(g){return Math.sqrt(g[0]*g[0]+g[1]*g[1]+g[2]*g[2]+g[3]*g[3]+g[4]*g[4]+g[5]*g[5]+g[6]*g[6]+g[7]*g[7]+g[8]*g[8]+g[9]*g[9]+g[10]*g[10]+g[11]*g[11]+g[12]*g[12]+g[13]*g[13]+g[14]*g[14]+g[15]*g[15])}function QTt(g,A,I){return g[0]=A[0]+I[0],g[1]=A[1]+I[1],g[2]=A[2]+I[2],g[3]=A[3]+I[3],g[4]=A[4]+I[4],g[5]=A[5]+I[5],g[6]=A[6]+I[6],g[7]=A[7]+I[7],g[8]=A[8]+I[8],g[9]=A[9]+I[9],g[10]=A[10]+I[10],g[11]=A[11]+I[11],g[12]=A[12]+I[12],g[13]=A[13]+I[13],g[14]=A[14]+I[14],g[15]=A[15]+I[15],g}function AuI(g,A,I){return g[0]=A[0]-I[0],g[1]=A[1]-I[1],g[2]=A[2]-I[2],g[3]=A[3]-I[3],g[4]=A[4]-I[4],g[5]=A[5]-I[5],g[6]=A[6]-I[6],g[7]=A[7]-I[7],g[8]=A[8]-I[8],g[9]=A[9]-I[9],g[10]=A[10]-I[10],g[11]=A[11]-I[11],g[12]=A[12]-I[12],g[13]=A[13]-I[13],g[14]=A[14]-I[14],g[15]=A[15]-I[15],g}function iTt(g,A,I){return g[0]=A[0]*I,g[1]=A[1]*I,g[2]=A[2]*I,g[3]=A[3]*I,g[4]=A[4]*I,g[5]=A[5]*I,g[6]=A[6]*I,g[7]=A[7]*I,g[8]=A[8]*I,g[9]=A[9]*I,g[10]=A[10]*I,g[11]=A[11]*I,g[12]=A[12]*I,g[13]=A[13]*I,g[14]=A[14]*I,g[15]=A[15]*I,g}function ETt(g,A,I,e){return g[0]=A[0]+I[0]*e,g[1]=A[1]+I[1]*e,g[2]=A[2]+I[2]*e,g[3]=A[3]+I[3]*e,g[4]=A[4]+I[4]*e,g[5]=A[5]+I[5]*e,g[6]=A[6]+I[6]*e,g[7]=A[7]+I[7]*e,g[8]=A[8]+I[8]*e,g[9]=A[9]+I[9]*e,g[10]=A[10]+I[10]*e,g[11]=A[11]+I[11]*e,g[12]=A[12]+I[12]*e,g[13]=A[13]+I[13]*e,g[14]=A[14]+I[14]*e,g[15]=A[15]+I[15]*e,g}function nTt(g,A){return g[0]===A[0]&&g[1]===A[1]&&g[2]===A[2]&&g[3]===A[3]&&g[4]===A[4]&&g[5]===A[5]&&g[6]===A[6]&&g[7]===A[7]&&g[8]===A[8]&&g[9]===A[9]&&g[10]===A[10]&&g[11]===A[11]&&g[12]===A[12]&&g[13]===A[13]&&g[14]===A[14]&&g[15]===A[15]}function sTt(g,A){var I=g[0],e=g[1],t=g[2],o=g[3],B=g[4],C=g[5],Q=g[6],i=g[7],E=g[8],n=g[9],s=g[10],r=g[11],a=g[12],c=g[13],h=g[14],l=g[15],D=A[0],d=A[1],y=A[2],w=A[3],u=A[4],G=A[5],m=A[6],p=A[7],k=A[8],S=A[9],R=A[10],x=A[11],N=A[12],J=A[13],K=A[14],_=A[15];return Math.abs(I-D)<=rB*Math.max(1,Math.abs(I),Math.abs(D))&&Math.abs(e-d)<=rB*Math.max(1,Math.abs(e),Math.abs(d))&&Math.abs(t-y)<=rB*Math.max(1,Math.abs(t),Math.abs(y))&&Math.abs(o-w)<=rB*Math.max(1,Math.abs(o),Math.abs(w))&&Math.abs(B-u)<=rB*Math.max(1,Math.abs(B),Math.abs(u))&&Math.abs(C-G)<=rB*Math.max(1,Math.abs(C),Math.abs(G))&&Math.abs(Q-m)<=rB*Math.max(1,Math.abs(Q),Math.abs(m))&&Math.abs(i-p)<=rB*Math.max(1,Math.abs(i),Math.abs(p))&&Math.abs(E-k)<=rB*Math.max(1,Math.abs(E),Math.abs(k))&&Math.abs(n-S)<=rB*Math.max(1,Math.abs(n),Math.abs(S))&&Math.abs(s-R)<=rB*Math.max(1,Math.abs(s),Math.abs(R))&&Math.abs(r-x)<=rB*Math.max(1,Math.abs(r),Math.abs(x))&&Math.abs(a-N)<=rB*Math.max(1,Math.abs(a),Math.abs(N))&&Math.abs(c-J)<=rB*Math.max(1,Math.abs(c),Math.abs(J))&&Math.abs(h-K)<=rB*Math.max(1,Math.abs(h),Math.abs(K))&&Math.abs(l-_)<=rB*Math.max(1,Math.abs(l),Math.abs(_))}var guI,IuI,euI,tuI,ouI=NR({"node_modules/gl-matrix/esm/mat4.js"(){dx(),guI=XwI,IuI=$wI,euI=OwI,tuI=AuI}}),BuI={};xR(BuI,{add:()=>hTt,angle:()=>KTt,bezier:()=>fTt,ceil:()=>lTt,clone:()=>aTt,copy:()=>rTt,create:()=>lAg,cross:()=>oyA,dist:()=>DuI,distance:()=>nuI,div:()=>luI,divide:()=>EuI,dot:()=>tyA,equals:()=>bTt,exactEquals:()=>_Tt,floor:()=>DTt,forEach:()=>wuI,fromValues:()=>DAg,hermite:()=>STt,inverse:()=>pTt,len:()=>dAg,length:()=>CuI,lerp:()=>kTt,max:()=>yTt,min:()=>dTt,mul:()=>huI,multiply:()=>iuI,negate:()=>mTt,normalize:()=>ruI,random:()=>RTt,rotateX:()=>UTt,rotateY:()=>JTt,rotateZ:()=>PTt,round:()=>wTt,scale:()=>uTt,scaleAndAdd:()=>GTt,set:()=>cTt,slerp:()=>MTt,sqrDist:()=>duI,sqrLen:()=>yuI,squaredDistance:()=>suI,squaredLength:()=>auI,str:()=>YTt,sub:()=>cuI,subtract:()=>QuI,transformMat3:()=>xTt,transformMat4:()=>NTt,transformQuat:()=>FTt,zero:()=>LTt});function lAg(){var g=new Ni(3);return Ni!=Float32Array&&(g[0]=0,g[1]=0,g[2]=0),g}function aTt(g){var A=new Ni(3);return A[0]=g[0],A[1]=g[1],A[2]=g[2],A}function CuI(g){var A=g[0],I=g[1],e=g[2];return Math.sqrt(A*A+I*I+e*e)}function DAg(g,A,I){var e=new Ni(3);return e[0]=g,e[1]=A,e[2]=I,e}function rTt(g,A){return g[0]=A[0],g[1]=A[1],g[2]=A[2],g}function cTt(g,A,I,e){return g[0]=A,g[1]=I,g[2]=e,g}function hTt(g,A,I){return g[0]=A[0]+I[0],g[1]=A[1]+I[1],g[2]=A[2]+I[2],g}function QuI(g,A,I){return g[0]=A[0]-I[0],g[1]=A[1]-I[1],g[2]=A[2]-I[2],g}function iuI(g,A,I){return g[0]=A[0]*I[0],g[1]=A[1]*I[1],g[2]=A[2]*I[2],g}function EuI(g,A,I){return g[0]=A[0]/I[0],g[1]=A[1]/I[1],g[2]=A[2]/I[2],g}function lTt(g,A){return g[0]=Math.ceil(A[0]),g[1]=Math.ceil(A[1]),g[2]=Math.ceil(A[2]),g}function DTt(g,A){return g[0]=Math.floor(A[0]),g[1]=Math.floor(A[1]),g[2]=Math.floor(A[2]),g}function dTt(g,A,I){return g[0]=Math.min(A[0],I[0]),g[1]=Math.min(A[1],I[1]),g[2]=Math.min(A[2],I[2]),g}function yTt(g,A,I){return g[0]=Math.max(A[0],I[0]),g[1]=Math.max(A[1],I[1]),g[2]=Math.max(A[2],I[2]),g}function wTt(g,A){return g[0]=Dx(A[0]),g[1]=Dx(A[1]),g[2]=Dx(A[2]),g}function uTt(g,A,I){return g[0]=A[0]*I,g[1]=A[1]*I,g[2]=A[2]*I,g}function GTt(g,A,I,e){return g[0]=A[0]+I[0]*e,g[1]=A[1]+I[1]*e,g[2]=A[2]+I[2]*e,g}function nuI(g,A){var I=A[0]-g[0],e=A[1]-g[1],t=A[2]-g[2];return Math.sqrt(I*I+e*e+t*t)}function suI(g,A){var I=A[0]-g[0],e=A[1]-g[1],t=A[2]-g[2];return I*I+e*e+t*t}function auI(g){var A=g[0],I=g[1],e=g[2];return A*A+I*I+e*e}function mTt(g,A){return g[0]=-A[0],g[1]=-A[1],g[2]=-A[2],g}function pTt(g,A){return g[0]=1/A[0],g[1]=1/A[1],g[2]=1/A[2],g}function ruI(g,A){var I=A[0],e=A[1],t=A[2],o=I*I+e*e+t*t;return o>0&&(o=1/Math.sqrt(o)),g[0]=A[0]*o,g[1]=A[1]*o,g[2]=A[2]*o,g}function tyA(g,A){return g[0]*A[0]+g[1]*A[1]+g[2]*A[2]}function oyA(g,A,I){var e=A[0],t=A[1],o=A[2],B=I[0],C=I[1],Q=I[2];return g[0]=t*Q-o*C,g[1]=o*B-e*Q,g[2]=e*C-t*B,g}function kTt(g,A,I,e){var t=A[0],o=A[1],B=A[2];return g[0]=t+e*(I[0]-t),g[1]=o+e*(I[1]-o),g[2]=B+e*(I[2]-B),g}function MTt(g,A,I,e){var t=Math.acos(Math.min(Math.max(tyA(A,I),-1),1)),o=Math.sin(t),B=Math.sin((1-e)*t)/o,C=Math.sin(e*t)/o;return g[0]=B*A[0]+C*I[0],g[1]=B*A[1]+C*I[1],g[2]=B*A[2]+C*I[2],g}function STt(g,A,I,e,t,o){var B=o*o,C=B*(2*o-3)+1,Q=B*(o-2)+o,i=B*(o-1),E=B*(3-2*o);return g[0]=A[0]*C+I[0]*Q+e[0]*i+t[0]*E,g[1]=A[1]*C+I[1]*Q+e[1]*i+t[1]*E,g[2]=A[2]*C+I[2]*Q+e[2]*i+t[2]*E,g}function fTt(g,A,I,e,t,o){var B=1-o,C=B*B,Q=o*o,i=C*B,E=3*o*C,n=3*Q*B,s=Q*o;return g[0]=A[0]*i+I[0]*E+e[0]*n+t[0]*s,g[1]=A[1]*i+I[1]*E+e[1]*n+t[1]*s,g[2]=A[2]*i+I[2]*E+e[2]*n+t[2]*s,g}function RTt(g,A){A=A===void 0?1:A;var I=Z2()*2*Math.PI,e=Z2()*2-1,t=Math.sqrt(1-e*e)*A;return g[0]=Math.cos(I)*t,g[1]=Math.sin(I)*t,g[2]=e*A,g}function NTt(g,A,I){var e=A[0],t=A[1],o=A[2],B=I[3]*e+I[7]*t+I[11]*o+I[15];return B=B||1,g[0]=(I[0]*e+I[4]*t+I[8]*o+I[12])/B,g[1]=(I[1]*e+I[5]*t+I[9]*o+I[13])/B,g[2]=(I[2]*e+I[6]*t+I[10]*o+I[14])/B,g}function xTt(g,A,I){var e=A[0],t=A[1],o=A[2];return g[0]=e*I[0]+t*I[3]+o*I[6],g[1]=e*I[1]+t*I[4]+o*I[7],g[2]=e*I[2]+t*I[5]+o*I[8],g}function FTt(g,A,I){var e=I[0],t=I[1],o=I[2],B=I[3],C=A[0],Q=A[1],i=A[2],E=t*i-o*Q,n=o*C-e*i,s=e*Q-t*C;return E=E+E,n=n+n,s=s+s,g[0]=C+B*E+t*s-o*n,g[1]=Q+B*n+o*E-e*s,g[2]=i+B*s+e*n-t*E,g}function UTt(g,A,I,e){var t=[],o=[];return t[0]=A[0]-I[0],t[1]=A[1]-I[1],t[2]=A[2]-I[2],o[0]=t[0],o[1]=t[1]*Math.cos(e)-t[2]*Math.sin(e),o[2]=t[1]*Math.sin(e)+t[2]*Math.cos(e),g[0]=o[0]+I[0],g[1]=o[1]+I[1],g[2]=o[2]+I[2],g}function JTt(g,A,I,e){var t=[],o=[];return t[0]=A[0]-I[0],t[1]=A[1]-I[1],t[2]=A[2]-I[2],o[0]=t[2]*Math.sin(e)+t[0]*Math.cos(e),o[1]=t[1],o[2]=t[2]*Math.cos(e)-t[0]*Math.sin(e),g[0]=o[0]+I[0],g[1]=o[1]+I[1],g[2]=o[2]+I[2],g}function PTt(g,A,I,e){var t=[],o=[];return t[0]=A[0]-I[0],t[1]=A[1]-I[1],t[2]=A[2]-I[2],o[0]=t[0]*Math.cos(e)-t[1]*Math.sin(e),o[1]=t[0]*Math.sin(e)+t[1]*Math.cos(e),o[2]=t[2],g[0]=o[0]+I[0],g[1]=o[1]+I[1],g[2]=o[2]+I[2],g}function KTt(g,A){var I=g[0],e=g[1],t=g[2],o=A[0],B=A[1],C=A[2],Q=Math.sqrt((I*I+e*e+t*t)*(o*o+B*B+C*C)),i=Q&&tyA(g,A)/Q;return Math.acos(Math.min(Math.max(i,-1),1))}function LTt(g){return g[0]=0,g[1]=0,g[2]=0,g}function YTt(g){return"vec3("+g[0]+", "+g[1]+", "+g[2]+")"}function _Tt(g,A){return g[0]===A[0]&&g[1]===A[1]&&g[2]===A[2]}function bTt(g,A){var I=g[0],e=g[1],t=g[2],o=A[0],B=A[1],C=A[2];return Math.abs(I-o)<=rB*Math.max(1,Math.abs(I),Math.abs(o))&&Math.abs(e-B)<=rB*Math.max(1,Math.abs(e),Math.abs(B))&&Math.abs(t-C)<=rB*Math.max(1,Math.abs(t),Math.abs(C))}var cuI,huI,luI,DuI,duI,dAg,yuI,wuI,uuI=NR({"node_modules/gl-matrix/esm/vec3.js"(){dx(),cuI=QuI,huI=iuI,luI=EuI,DuI=nuI,duI=suI,dAg=CuI,yuI=auI,wuI=(function(){var g=lAg();return function(A,I,e,t,o,B){var C,Q;for(I||(I=3),e||(e=0),t?Q=Math.min(t*I+e,A.length):Q=A.length,C=e;C<Q;C+=I)g[0]=A[C],g[1]=A[C+1],g[2]=A[C+2],o(g,g,B),A[C]=g[0],A[C+1]=g[1],A[C+2]=g[2];return A}})()}}),GuI={};xR(GuI,{add:()=>fuI,ceil:()=>HTt,clone:()=>puI,copy:()=>MuI,create:()=>muI,cross:()=>jTt,dist:()=>HuI,distance:()=>UuI,div:()=>buI,divide:()=>xuI,dot:()=>uAg,equals:()=>I7t,exactEquals:()=>LuI,floor:()=>vTt,forEach:()=>ZuI,fromValues:()=>kuI,inverse:()=>VTt,len:()=>quI,length:()=>yAg,lerp:()=>KuI,max:()=>TTt,min:()=>qTt,mul:()=>_uI,multiply:()=>NuI,negate:()=>WTt,normalize:()=>PuI,random:()=>zTt,round:()=>ZTt,scale:()=>FuI,scaleAndAdd:()=>OTt,set:()=>SuI,sqrDist:()=>vuI,sqrLen:()=>TuI,squaredDistance:()=>JuI,squaredLength:()=>wAg,str:()=>g7t,sub:()=>YuI,subtract:()=>RuI,transformMat4:()=>XTt,transformQuat:()=>$Tt,zero:()=>A7t});function muI(){var g=new Ni(4);return Ni!=Float32Array&&(g[0]=0,g[1]=0,g[2]=0,g[3]=0),g}function puI(g){var A=new Ni(4);return A[0]=g[0],A[1]=g[1],A[2]=g[2],A[3]=g[3],A}function kuI(g,A,I,e){var t=new Ni(4);return t[0]=g,t[1]=A,t[2]=I,t[3]=e,t}function MuI(g,A){return g[0]=A[0],g[1]=A[1],g[2]=A[2],g[3]=A[3],g}function SuI(g,A,I,e,t){return g[0]=A,g[1]=I,g[2]=e,g[3]=t,g}function fuI(g,A,I){return g[0]=A[0]+I[0],g[1]=A[1]+I[1],g[2]=A[2]+I[2],g[3]=A[3]+I[3],g}function RuI(g,A,I){return g[0]=A[0]-I[0],g[1]=A[1]-I[1],g[2]=A[2]-I[2],g[3]=A[3]-I[3],g}function NuI(g,A,I){return g[0]=A[0]*I[0],g[1]=A[1]*I[1],g[2]=A[2]*I[2],g[3]=A[3]*I[3],g}function xuI(g,A,I){return g[0]=A[0]/I[0],g[1]=A[1]/I[1],g[2]=A[2]/I[2],g[3]=A[3]/I[3],g}function HTt(g,A){return g[0]=Math.ceil(A[0]),g[1]=Math.ceil(A[1]),g[2]=Math.ceil(A[2]),g[3]=Math.ceil(A[3]),g}function vTt(g,A){return g[0]=Math.floor(A[0]),g[1]=Math.floor(A[1]),g[2]=Math.floor(A[2]),g[3]=Math.floor(A[3]),g}function qTt(g,A,I){return g[0]=Math.min(A[0],I[0]),g[1]=Math.min(A[1],I[1]),g[2]=Math.min(A[2],I[2]),g[3]=Math.min(A[3],I[3]),g}function TTt(g,A,I){return g[0]=Math.max(A[0],I[0]),g[1]=Math.max(A[1],I[1]),g[2]=Math.max(A[2],I[2]),g[3]=Math.max(A[3],I[3]),g}function ZTt(g,A){return g[0]=Dx(A[0]),g[1]=Dx(A[1]),g[2]=Dx(A[2]),g[3]=Dx(A[3]),g}function FuI(g,A,I){return g[0]=A[0]*I,g[1]=A[1]*I,g[2]=A[2]*I,g[3]=A[3]*I,g}function OTt(g,A,I,e){return g[0]=A[0]+I[0]*e,g[1]=A[1]+I[1]*e,g[2]=A[2]+I[2]*e,g[3]=A[3]+I[3]*e,g}function UuI(g,A){var I=A[0]-g[0],e=A[1]-g[1],t=A[2]-g[2],o=A[3]-g[3];return Math.sqrt(I*I+e*e+t*t+o*o)}function JuI(g,A){var I=A[0]-g[0],e=A[1]-g[1],t=A[2]-g[2],o=A[3]-g[3];return I*I+e*e+t*t+o*o}function yAg(g){var A=g[0],I=g[1],e=g[2],t=g[3];return Math.sqrt(A*A+I*I+e*e+t*t)}function wAg(g){var A=g[0],I=g[1],e=g[2],t=g[3];return A*A+I*I+e*e+t*t}function WTt(g,A){return g[0]=-A[0],g[1]=-A[1],g[2]=-A[2],g[3]=-A[3],g}function VTt(g,A){return g[0]=1/A[0],g[1]=1/A[1],g[2]=1/A[2],g[3]=1/A[3],g}function PuI(g,A){var I=A[0],e=A[1],t=A[2],o=A[3],B=I*I+e*e+t*t+o*o;return B>0&&(B=1/Math.sqrt(B)),g[0]=I*B,g[1]=e*B,g[2]=t*B,g[3]=o*B,g}function uAg(g,A){return g[0]*A[0]+g[1]*A[1]+g[2]*A[2]+g[3]*A[3]}function jTt(g,A,I,e){var t=I[0]*e[1]-I[1]*e[0],o=I[0]*e[2]-I[2]*e[0],B=I[0]*e[3]-I[3]*e[0],C=I[1]*e[2]-I[2]*e[1],Q=I[1]*e[3]-I[3]*e[1],i=I[2]*e[3]-I[3]*e[2],E=A[0],n=A[1],s=A[2],r=A[3];return g[0]=n*i-s*Q+r*C,g[1]=-(E*i)+s*B-r*o,g[2]=E*Q-n*B+r*t,g[3]=-(E*C)+n*o-s*t,g}function KuI(g,A,I,e){var t=A[0],o=A[1],B=A[2],C=A[3];return g[0]=t+e*(I[0]-t),g[1]=o+e*(I[1]-o),g[2]=B+e*(I[2]-B),g[3]=C+e*(I[3]-C),g}function zTt(g,A){A=A===void 0?1:A;var I,e,t,o,B,C,Q;Q=Z2(),I=Q*2-1,e=(4*Z2()-2)*Math.sqrt(Q*-Q+Q),B=I*I+e*e,Q=Z2(),t=Q*2-1,o=(4*Z2()-2)*Math.sqrt(Q*-Q+Q),C=t*t+o*o;var i=Math.sqrt((1-B)/C);return g[0]=A*I,g[1]=A*e,g[2]=A*t*i,g[3]=A*o*i,g}function XTt(g,A,I){var e=A[0],t=A[1],o=A[2],B=A[3];return g[0]=I[0]*e+I[4]*t+I[8]*o+I[12]*B,g[1]=I[1]*e+I[5]*t+I[9]*o+I[13]*B,g[2]=I[2]*e+I[6]*t+I[10]*o+I[14]*B,g[3]=I[3]*e+I[7]*t+I[11]*o+I[15]*B,g}function $Tt(g,A,I){var e=I[0],t=I[1],o=I[2],B=I[3],C=A[0],Q=A[1],i=A[2],E=t*i-o*Q,n=o*C-e*i,s=e*Q-t*C;return E=E+E,n=n+n,s=s+s,g[0]=C+B*E+t*s-o*n,g[1]=Q+B*n+o*E-e*s,g[2]=i+B*s+e*n-t*E,g[3]=A[3],g}function A7t(g){return g[0]=0,g[1]=0,g[2]=0,g[3]=0,g}function g7t(g){return"vec4("+g[0]+", "+g[1]+", "+g[2]+", "+g[3]+")"}function LuI(g,A){return g[0]===A[0]&&g[1]===A[1]&&g[2]===A[2]&&g[3]===A[3]}function I7t(g,A){var I=g[0],e=g[1],t=g[2],o=g[3],B=A[0],C=A[1],Q=A[2],i=A[3];return Math.abs(I-B)<=rB*Math.max(1,Math.abs(I),Math.abs(B))&&Math.abs(e-C)<=rB*Math.max(1,Math.abs(e),Math.abs(C))&&Math.abs(t-Q)<=rB*Math.max(1,Math.abs(t),Math.abs(Q))&&Math.abs(o-i)<=rB*Math.max(1,Math.abs(o),Math.abs(i))}var YuI,_uI,buI,HuI,vuI,quI,TuI,ZuI,OuI=NR({"node_modules/gl-matrix/esm/vec4.js"(){dx(),YuI=RuI,_uI=NuI,buI=xuI,HuI=UuI,vuI=JuI,quI=yAg,TuI=wAg,ZuI=(function(){var g=muI();return function(A,I,e,t,o,B){var C,Q;for(I||(I=4),e||(e=0),t?Q=Math.min(t*I+e,A.length):Q=A.length,C=e;C<Q;C+=I)g[0]=A[C],g[1]=A[C+1],g[2]=A[C+2],g[3]=A[C+3],o(g,g,B),A[C]=g[0],A[C+1]=g[1],A[C+2]=g[2],A[C+3]=g[3];return A}})()}}),WuI={};xR(WuI,{add:()=>BGI,calculateW:()=>B7t,clone:()=>eGI,conjugate:()=>E7t,copy:()=>QyA,create:()=>ByA,dot:()=>iyA,equals:()=>a7t,exactEquals:()=>nGI,exp:()=>AGI,fromEuler:()=>n7t,fromMat3:()=>IGI,fromValues:()=>tGI,getAngle:()=>o7t,getAxisAngle:()=>t7t,identity:()=>e7t,invert:()=>i7t,len:()=>iGI,length:()=>EyA,lerp:()=>QGI,ln:()=>gGI,mul:()=>CGI,multiply:()=>juI,normalize:()=>syA,pow:()=>C7t,random:()=>Q7t,rotateX:()=>zuI,rotateY:()=>XuI,rotateZ:()=>$uI,rotationTo:()=>sGI,scale:()=>GAg,set:()=>oGI,setAxes:()=>rGI,setAxisAngle:()=>VuI,slerp:()=>CyA,sqlerp:()=>aGI,sqrLen:()=>EGI,squaredLength:()=>nyA,str:()=>s7t});function ByA(){var g=new Ni(4);return Ni!=Float32Array&&(g[0]=0,g[1]=0,g[2]=0),g[3]=1,g}function e7t(g){return g[0]=0,g[1]=0,g[2]=0,g[3]=1,g}function VuI(g,A,I){I=I*.5;var e=Math.sin(I);return g[0]=e*A[0],g[1]=e*A[1],g[2]=e*A[2],g[3]=Math.cos(I),g}function t7t(g,A){var I=Math.acos(A[3])*2,e=Math.sin(I/2);return e>rB?(g[0]=A[0]/e,g[1]=A[1]/e,g[2]=A[2]/e):(g[0]=1,g[1]=0,g[2]=0),I}function o7t(g,A){var I=iyA(g,A);return Math.acos(2*I*I-1)}function juI(g,A,I){var e=A[0],t=A[1],o=A[2],B=A[3],C=I[0],Q=I[1],i=I[2],E=I[3];return g[0]=e*E+B*C+t*i-o*Q,g[1]=t*E+B*Q+o*C-e*i,g[2]=o*E+B*i+e*Q-t*C,g[3]=B*E-e*C-t*Q-o*i,g}function zuI(g,A,I){I*=.5;var e=A[0],t=A[1],o=A[2],B=A[3],C=Math.sin(I),Q=Math.cos(I);return g[0]=e*Q+B*C,g[1]=t*Q+o*C,g[2]=o*Q-t*C,g[3]=B*Q-e*C,g}function XuI(g,A,I){I*=.5;var e=A[0],t=A[1],o=A[2],B=A[3],C=Math.sin(I),Q=Math.cos(I);return g[0]=e*Q-o*C,g[1]=t*Q+B*C,g[2]=o*Q+e*C,g[3]=B*Q-t*C,g}function $uI(g,A,I){I*=.5;var e=A[0],t=A[1],o=A[2],B=A[3],C=Math.sin(I),Q=Math.cos(I);return g[0]=e*Q+t*C,g[1]=t*Q-e*C,g[2]=o*Q+B*C,g[3]=B*Q-o*C,g}function B7t(g,A){var I=A[0],e=A[1],t=A[2];return g[0]=I,g[1]=e,g[2]=t,g[3]=Math.sqrt(Math.abs(1-I*I-e*e-t*t)),g}function AGI(g,A){var I=A[0],e=A[1],t=A[2],o=A[3],B=Math.sqrt(I*I+e*e+t*t),C=Math.exp(o),Q=B>0?C*Math.sin(B)/B:0;return g[0]=I*Q,g[1]=e*Q,g[2]=t*Q,g[3]=C*Math.cos(B),g}function gGI(g,A){var I=A[0],e=A[1],t=A[2],o=A[3],B=Math.sqrt(I*I+e*e+t*t),C=B>0?Math.atan2(B,o)/B:0;return g[0]=I*C,g[1]=e*C,g[2]=t*C,g[3]=.5*Math.log(I*I+e*e+t*t+o*o),g}function C7t(g,A,I){return gGI(g,A),GAg(g,g,I),AGI(g,g),g}function CyA(g,A,I,e){var t=A[0],o=A[1],B=A[2],C=A[3],Q=I[0],i=I[1],E=I[2],n=I[3],s,r,a,c,h;return r=t*Q+o*i+B*E+C*n,r<0&&(r=-r,Q=-Q,i=-i,E=-E,n=-n),1-r>rB?(s=Math.acos(r),a=Math.sin(s),c=Math.sin((1-e)*s)/a,h=Math.sin(e*s)/a):(c=1-e,h=e),g[0]=c*t+h*Q,g[1]=c*o+h*i,g[2]=c*B+h*E,g[3]=c*C+h*n,g}function Q7t(g){var A=Z2(),I=Z2(),e=Z2(),t=Math.sqrt(1-A),o=Math.sqrt(A);return g[0]=t*Math.sin(2*Math.PI*I),g[1]=t*Math.cos(2*Math.PI*I),g[2]=o*Math.sin(2*Math.PI*e),g[3]=o*Math.cos(2*Math.PI*e),g}function i7t(g,A){var I=A[0],e=A[1],t=A[2],o=A[3],B=I*I+e*e+t*t+o*o,C=B?1/B:0;return g[0]=-I*C,g[1]=-e*C,g[2]=-t*C,g[3]=o*C,g}function E7t(g,A){return g[0]=-A[0],g[1]=-A[1],g[2]=-A[2],g[3]=A[3],g}function IGI(g,A){var I=A[0]+A[4]+A[8],e;if(I>0)e=Math.sqrt(I+1),g[3]=.5*e,e=.5/e,g[0]=(A[5]-A[7])*e,g[1]=(A[6]-A[2])*e,g[2]=(A[1]-A[3])*e;else{var t=0;A[4]>A[0]&&(t=1),A[8]>A[t*3+t]&&(t=2);var o=(t+1)%3,B=(t+2)%3;e=Math.sqrt(A[t*3+t]-A[o*3+o]-A[B*3+B]+1),g[t]=.5*e,e=.5/e,g[3]=(A[o*3+B]-A[B*3+o])*e,g[o]=(A[o*3+t]+A[t*3+o])*e,g[B]=(A[B*3+t]+A[t*3+B])*e}return g}function n7t(g,A,I,e){var t=arguments.length>4&&arguments[4]!==void 0?arguments[4]:hAg,o=Math.PI/360;A*=o,e*=o,I*=o;var B=Math.sin(A),C=Math.cos(A),Q=Math.sin(I),i=Math.cos(I),E=Math.sin(e),n=Math.cos(e);switch(t){case"xyz":g[0]=B*i*n+C*Q*E,g[1]=C*Q*n-B*i*E,g[2]=C*i*E+B*Q*n,g[3]=C*i*n-B*Q*E;break;case"xzy":g[0]=B*i*n-C*Q*E,g[1]=C*Q*n-B*i*E,g[2]=C*i*E+B*Q*n,g[3]=C*i*n+B*Q*E;break;case"yxz":g[0]=B*i*n+C*Q*E,g[1]=C*Q*n-B*i*E,g[2]=C*i*E-B*Q*n,g[3]=C*i*n+B*Q*E;break;case"yzx":g[0]=B*i*n+C*Q*E,g[1]=C*Q*n+B*i*E,g[2]=C*i*E-B*Q*n,g[3]=C*i*n-B*Q*E;break;case"zxy":g[0]=B*i*n-C*Q*E,g[1]=C*Q*n+B*i*E,g[2]=C*i*E+B*Q*n,g[3]=C*i*n-B*Q*E;break;case"zyx":g[0]=B*i*n-C*Q*E,g[1]=C*Q*n+B*i*E,g[2]=C*i*E-B*Q*n,g[3]=C*i*n+B*Q*E;break;default:throw new Error("Unknown angle order "+t)}return g}function s7t(g){return"quat("+g[0]+", "+g[1]+", "+g[2]+", "+g[3]+")"}function a7t(g,A){return Math.abs(uAg(g,A))>=1-rB}var eGI,tGI,QyA,oGI,BGI,CGI,GAg,iyA,QGI,EyA,iGI,nyA,EGI,syA,nGI,sGI,aGI,rGI,cGI=NR({"node_modules/gl-matrix/esm/quat.js"(){dx(),qwI(),uuI(),OuI(),eGI=puI,tGI=kuI,QyA=MuI,oGI=SuI,BGI=fuI,CGI=juI,GAg=FuI,iyA=uAg,QGI=KuI,EyA=yAg,iGI=EyA,nyA=wAg,EGI=nyA,syA=PuI,nGI=LuI,sGI=(function(){var g=lAg(),A=DAg(1,0,0),I=DAg(0,1,0);return function(e,t,o){var B=tyA(t,o);return B<-.999999?(oyA(g,A,t),dAg(g)<1e-6&&oyA(g,I,t),ruI(g,g),VuI(e,g,Math.PI),e):B>.999999?(e[0]=0,e[1]=0,e[2]=0,e[3]=1,e):(oyA(g,t,o),e[0]=g[0],e[1]=g[1],e[2]=g[2],e[3]=1+B,syA(e,e))}})(),aGI=(function(){var g=ByA(),A=ByA();return function(I,e,t,o,B,C){return CyA(g,e,B,C),CyA(A,t,o,C),CyA(I,g,A,2*C*(1-C)),I}})(),rGI=(function(){var g=YwI();return function(A,I,e,t){return g[0]=e[0],g[3]=e[1],g[6]=e[2],g[1]=t[0],g[4]=t[1],g[7]=t[2],g[2]=-I[0],g[5]=-I[1],g[8]=-I[2],syA(A,IGI(A,g))}})()}}),hGI={};xR(hGI,{add:()=>F7t,clone:()=>c7t,conjugate:()=>K7t,copy:()=>DGI,create:()=>r7t,dot:()=>mAg,equals:()=>b7t,exactEquals:()=>_7t,fromMat4:()=>y7t,fromRotation:()=>d7t,fromRotationTranslation:()=>lGI,fromRotationTranslationValues:()=>l7t,fromTranslation:()=>D7t,fromValues:()=>h7t,getDual:()=>G7t,getReal:()=>yGI,getTranslation:()=>p7t,identity:()=>w7t,invert:()=>P7t,len:()=>GGI,length:()=>pAg,lerp:()=>J7t,mul:()=>uGI,multiply:()=>dGI,normalize:()=>L7t,rotateAroundAxis:()=>x7t,rotateByQuatAppend:()=>R7t,rotateByQuatPrepend:()=>N7t,rotateX:()=>M7t,rotateY:()=>S7t,rotateZ:()=>f7t,scale:()=>U7t,set:()=>u7t,setDual:()=>m7t,setReal:()=>wGI,sqrLen:()=>mGI,squaredLength:()=>lIA,str:()=>Y7t,translate:()=>k7t});function r7t(){var g=new Ni(8);return Ni!=Float32Array&&(g[0]=0,g[1]=0,g[2]=0,g[4]=0,g[5]=0,g[6]=0,g[7]=0),g[3]=1,g}function c7t(g){var A=new Ni(8);return A[0]=g[0],A[1]=g[1],A[2]=g[2],A[3]=g[3],A[4]=g[4],A[5]=g[5],A[6]=g[6],A[7]=g[7],A}function h7t(g,A,I,e,t,o,B,C){var Q=new Ni(8);return Q[0]=g,Q[1]=A,Q[2]=I,Q[3]=e,Q[4]=t,Q[5]=o,Q[6]=B,Q[7]=C,Q}function l7t(g,A,I,e,t,o,B){var C=new Ni(8);C[0]=g,C[1]=A,C[2]=I,C[3]=e;var Q=t*.5,i=o*.5,E=B*.5;return C[4]=Q*e+i*I-E*A,C[5]=i*e+E*g-Q*I,C[6]=E*e+Q*A-i*g,C[7]=-Q*g-i*A-E*I,C}function lGI(g,A,I){var e=I[0]*.5,t=I[1]*.5,o=I[2]*.5,B=A[0],C=A[1],Q=A[2],i=A[3];return g[0]=B,g[1]=C,g[2]=Q,g[3]=i,g[4]=e*i+t*Q-o*C,g[5]=t*i+o*B-e*Q,g[6]=o*i+e*C-t*B,g[7]=-e*B-t*C-o*Q,g}function D7t(g,A){return g[0]=0,g[1]=0,g[2]=0,g[3]=1,g[4]=A[0]*.5,g[5]=A[1]*.5,g[6]=A[2]*.5,g[7]=0,g}function d7t(g,A){return g[0]=A[0],g[1]=A[1],g[2]=A[2],g[3]=A[3],g[4]=0,g[5]=0,g[6]=0,g[7]=0,g}function y7t(g,A){var I=ByA();zwI(I,A);var e=new Ni(3);return VwI(e,A),lGI(g,I,e),g}function DGI(g,A){return g[0]=A[0],g[1]=A[1],g[2]=A[2],g[3]=A[3],g[4]=A[4],g[5]=A[5],g[6]=A[6],g[7]=A[7],g}function w7t(g){return g[0]=0,g[1]=0,g[2]=0,g[3]=1,g[4]=0,g[5]=0,g[6]=0,g[7]=0,g}function u7t(g,A,I,e,t,o,B,C,Q){return g[0]=A,g[1]=I,g[2]=e,g[3]=t,g[4]=o,g[5]=B,g[6]=C,g[7]=Q,g}function G7t(g,A){return g[0]=A[4],g[1]=A[5],g[2]=A[6],g[3]=A[7],g}function m7t(g,A){return g[4]=A[0],g[5]=A[1],g[6]=A[2],g[7]=A[3],g}function p7t(g,A){var I=A[4],e=A[5],t=A[6],o=A[7],B=-A[0],C=-A[1],Q=-A[2],i=A[3];return g[0]=(I*i+o*B+e*Q-t*C)*2,g[1]=(e*i+o*C+t*B-I*Q)*2,g[2]=(t*i+o*Q+I*C-e*B)*2,g}function k7t(g,A,I){var e=A[0],t=A[1],o=A[2],B=A[3],C=I[0]*.5,Q=I[1]*.5,i=I[2]*.5,E=A[4],n=A[5],s=A[6],r=A[7];return g[0]=e,g[1]=t,g[2]=o,g[3]=B,g[4]=B*C+t*i-o*Q+E,g[5]=B*Q+o*C-e*i+n,g[6]=B*i+e*Q-t*C+s,g[7]=-e*C-t*Q-o*i+r,g}function M7t(g,A,I){var e=-A[0],t=-A[1],o=-A[2],B=A[3],C=A[4],Q=A[5],i=A[6],E=A[7],n=C*B+E*e+Q*o-i*t,s=Q*B+E*t+i*e-C*o,r=i*B+E*o+C*t-Q*e,a=E*B-C*e-Q*t-i*o;return zuI(g,A,I),e=g[0],t=g[1],o=g[2],B=g[3],g[4]=n*B+a*e+s*o-r*t,g[5]=s*B+a*t+r*e-n*o,g[6]=r*B+a*o+n*t-s*e,g[7]=a*B-n*e-s*t-r*o,g}function S7t(g,A,I){var e=-A[0],t=-A[1],o=-A[2],B=A[3],C=A[4],Q=A[5],i=A[6],E=A[7],n=C*B+E*e+Q*o-i*t,s=Q*B+E*t+i*e-C*o,r=i*B+E*o+C*t-Q*e,a=E*B-C*e-Q*t-i*o;return XuI(g,A,I),e=g[0],t=g[1],o=g[2],B=g[3],g[4]=n*B+a*e+s*o-r*t,g[5]=s*B+a*t+r*e-n*o,g[6]=r*B+a*o+n*t-s*e,g[7]=a*B-n*e-s*t-r*o,g}function f7t(g,A,I){var e=-A[0],t=-A[1],o=-A[2],B=A[3],C=A[4],Q=A[5],i=A[6],E=A[7],n=C*B+E*e+Q*o-i*t,s=Q*B+E*t+i*e-C*o,r=i*B+E*o+C*t-Q*e,a=E*B-C*e-Q*t-i*o;return $uI(g,A,I),e=g[0],t=g[1],o=g[2],B=g[3],g[4]=n*B+a*e+s*o-r*t,g[5]=s*B+a*t+r*e-n*o,g[6]=r*B+a*o+n*t-s*e,g[7]=a*B-n*e-s*t-r*o,g}function R7t(g,A,I){var e=I[0],t=I[1],o=I[2],B=I[3],C=A[0],Q=A[1],i=A[2],E=A[3];return g[0]=C*B+E*e+Q*o-i*t,g[1]=Q*B+E*t+i*e-C*o,g[2]=i*B+E*o+C*t-Q*e,g[3]=E*B-C*e-Q*t-i*o,C=A[4],Q=A[5],i=A[6],E=A[7],g[4]=C*B+E*e+Q*o-i*t,g[5]=Q*B+E*t+i*e-C*o,g[6]=i*B+E*o+C*t-Q*e,g[7]=E*B-C*e-Q*t-i*o,g}function N7t(g,A,I){var e=A[0],t=A[1],o=A[2],B=A[3],C=I[0],Q=I[1],i=I[2],E=I[3];return g[0]=e*E+B*C+t*i-o*Q,g[1]=t*E+B*Q+o*C-e*i,g[2]=o*E+B*i+e*Q-t*C,g[3]=B*E-e*C-t*Q-o*i,C=I[4],Q=I[5],i=I[6],E=I[7],g[4]=e*E+B*C+t*i-o*Q,g[5]=t*E+B*Q+o*C-e*i,g[6]=o*E+B*i+e*Q-t*C,g[7]=B*E-e*C-t*Q-o*i,g}function x7t(g,A,I,e){if(Math.abs(e)<rB)return DGI(g,A);var t=Math.sqrt(I[0]*I[0]+I[1]*I[1]+I[2]*I[2]);e=e*.5;var o=Math.sin(e),B=o*I[0]/t,C=o*I[1]/t,Q=o*I[2]/t,i=Math.cos(e),E=A[0],n=A[1],s=A[2],r=A[3];g[0]=E*i+r*B+n*Q-s*C,g[1]=n*i+r*C+s*B-E*Q,g[2]=s*i+r*Q+E*C-n*B,g[3]=r*i-E*B-n*C-s*Q;var a=A[4],c=A[5],h=A[6],l=A[7];return g[4]=a*i+l*B+c*Q-h*C,g[5]=c*i+l*C+h*B-a*Q,g[6]=h*i+l*Q+a*C-c*B,g[7]=l*i-a*B-c*C-h*Q,g}function F7t(g,A,I){return g[0]=A[0]+I[0],g[1]=A[1]+I[1],g[2]=A[2]+I[2],g[3]=A[3]+I[3],g[4]=A[4]+I[4],g[5]=A[5]+I[5],g[6]=A[6]+I[6],g[7]=A[7]+I[7],g}function dGI(g,A,I){var e=A[0],t=A[1],o=A[2],B=A[3],C=I[4],Q=I[5],i=I[6],E=I[7],n=A[4],s=A[5],r=A[6],a=A[7],c=I[0],h=I[1],l=I[2],D=I[3];return g[0]=e*D+B*c+t*l-o*h,g[1]=t*D+B*h+o*c-e*l,g[2]=o*D+B*l+e*h-t*c,g[3]=B*D-e*c-t*h-o*l,g[4]=e*E+B*C+t*i-o*Q+n*D+a*c+s*l-r*h,g[5]=t*E+B*Q+o*C-e*i+s*D+a*h+r*c-n*l,g[6]=o*E+B*i+e*Q-t*C+r*D+a*l+n*h-s*c,g[7]=B*E-e*C-t*Q-o*i+a*D-n*c-s*h-r*l,g}function U7t(g,A,I){return g[0]=A[0]*I,g[1]=A[1]*I,g[2]=A[2]*I,g[3]=A[3]*I,g[4]=A[4]*I,g[5]=A[5]*I,g[6]=A[6]*I,g[7]=A[7]*I,g}function J7t(g,A,I,e){var t=1-e;return mAg(A,I)<0&&(e=-e),g[0]=A[0]*t+I[0]*e,g[1]=A[1]*t+I[1]*e,g[2]=A[2]*t+I[2]*e,g[3]=A[3]*t+I[3]*e,g[4]=A[4]*t+I[4]*e,g[5]=A[5]*t+I[5]*e,g[6]=A[6]*t+I[6]*e,g[7]=A[7]*t+I[7]*e,g}function P7t(g,A){var I=lIA(A);return g[0]=-A[0]/I,g[1]=-A[1]/I,g[2]=-A[2]/I,g[3]=A[3]/I,g[4]=-A[4]/I,g[5]=-A[5]/I,g[6]=-A[6]/I,g[7]=A[7]/I,g}function K7t(g,A){return g[0]=-A[0],g[1]=-A[1],g[2]=-A[2],g[3]=A[3],g[4]=-A[4],g[5]=-A[5],g[6]=-A[6],g[7]=A[7],g}function L7t(g,A){var I=lIA(A);if(I>0){I=Math.sqrt(I);var e=A[0]/I,t=A[1]/I,o=A[2]/I,B=A[3]/I,C=A[4],Q=A[5],i=A[6],E=A[7],n=e*C+t*Q+o*i+B*E;g[0]=e,g[1]=t,g[2]=o,g[3]=B,g[4]=(C-e*n)/I,g[5]=(Q-t*n)/I,g[6]=(i-o*n)/I,g[7]=(E-B*n)/I}return g}function Y7t(g){return"quat2("+g[0]+", "+g[1]+", "+g[2]+", "+g[3]+", "+g[4]+", "+g[5]+", "+g[6]+", "+g[7]+")"}function _7t(g,A){return g[0]===A[0]&&g[1]===A[1]&&g[2]===A[2]&&g[3]===A[3]&&g[4]===A[4]&&g[5]===A[5]&&g[6]===A[6]&&g[7]===A[7]}function b7t(g,A){var I=g[0],e=g[1],t=g[2],o=g[3],B=g[4],C=g[5],Q=g[6],i=g[7],E=A[0],n=A[1],s=A[2],r=A[3],a=A[4],c=A[5],h=A[6],l=A[7];return Math.abs(I-E)<=rB*Math.max(1,Math.abs(I),Math.abs(E))&&Math.abs(e-n)<=rB*Math.max(1,Math.abs(e),Math.abs(n))&&Math.abs(t-s)<=rB*Math.max(1,Math.abs(t),Math.abs(s))&&Math.abs(o-r)<=rB*Math.max(1,Math.abs(o),Math.abs(r))&&Math.abs(B-a)<=rB*Math.max(1,Math.abs(B),Math.abs(a))&&Math.abs(C-c)<=rB*Math.max(1,Math.abs(C),Math.abs(c))&&Math.abs(Q-h)<=rB*Math.max(1,Math.abs(Q),Math.abs(h))&&Math.abs(i-l)<=rB*Math.max(1,Math.abs(i),Math.abs(l))}var yGI,wGI,uGI,mAg,pAg,GGI,lIA,mGI,H7t=NR({"node_modules/gl-matrix/esm/quat2.js"(){dx(),cGI(),ouI(),yGI=QyA,wGI=QyA,uGI=dGI,mAg=iyA,pAg=EyA,GGI=pAg,lIA=nyA,mGI=lIA}}),pGI={};xR(pGI,{add:()=>O7t,angle:()=>aZt,ceil:()=>W7t,clone:()=>v7t,copy:()=>T7t,create:()=>kGI,cross:()=>oZt,dist:()=>LGI,distance:()=>RGI,div:()=>KGI,divide:()=>fGI,dot:()=>tZt,equals:()=>DZt,exactEquals:()=>lZt,floor:()=>V7t,forEach:()=>bGI,fromValues:()=>q7t,inverse:()=>IZt,len:()=>UGI,length:()=>xGI,lerp:()=>BZt,max:()=>z7t,min:()=>j7t,mul:()=>PGI,multiply:()=>SGI,negate:()=>gZt,normalize:()=>eZt,random:()=>CZt,rotate:()=>sZt,round:()=>X7t,scale:()=>$7t,scaleAndAdd:()=>AZt,set:()=>Z7t,signedAngle:()=>rZt,sqrDist:()=>YGI,sqrLen:()=>_GI,squaredDistance:()=>NGI,squaredLength:()=>FGI,str:()=>hZt,sub:()=>JGI,subtract:()=>MGI,transformMat2:()=>QZt,transformMat2d:()=>iZt,transformMat3:()=>EZt,transformMat4:()=>nZt,zero:()=>cZt});function kGI(){var g=new Ni(2);return Ni!=Float32Array&&(g[0]=0,g[1]=0),g}function v7t(g){var A=new Ni(2);return A[0]=g[0],A[1]=g[1],A}function q7t(g,A){var I=new Ni(2);return I[0]=g,I[1]=A,I}function T7t(g,A){return g[0]=A[0],g[1]=A[1],g}function Z7t(g,A,I){return g[0]=A,g[1]=I,g}function O7t(g,A,I){return g[0]=A[0]+I[0],g[1]=A[1]+I[1],g}function MGI(g,A,I){return g[0]=A[0]-I[0],g[1]=A[1]-I[1],g}function SGI(g,A,I){return g[0]=A[0]*I[0],g[1]=A[1]*I[1],g}function fGI(g,A,I){return g[0]=A[0]/I[0],g[1]=A[1]/I[1],g}function W7t(g,A){return g[0]=Math.ceil(A[0]),g[1]=Math.ceil(A[1]),g}function V7t(g,A){return g[0]=Math.floor(A[0]),g[1]=Math.floor(A[1]),g}function j7t(g,A,I){return g[0]=Math.min(A[0],I[0]),g[1]=Math.min(A[1],I[1]),g}function z7t(g,A,I){return g[0]=Math.max(A[0],I[0]),g[1]=Math.max(A[1],I[1]),g}function X7t(g,A){return g[0]=Dx(A[0]),g[1]=Dx(A[1]),g}function $7t(g,A,I){return g[0]=A[0]*I,g[1]=A[1]*I,g}function AZt(g,A,I,e){return g[0]=A[0]+I[0]*e,g[1]=A[1]+I[1]*e,g}function RGI(g,A){var I=A[0]-g[0],e=A[1]-g[1];return Math.sqrt(I*I+e*e)}function NGI(g,A){var I=A[0]-g[0],e=A[1]-g[1];return I*I+e*e}function xGI(g){var A=g[0],I=g[1];return Math.sqrt(A*A+I*I)}function FGI(g){var A=g[0],I=g[1];return A*A+I*I}function gZt(g,A){return g[0]=-A[0],g[1]=-A[1],g}function IZt(g,A){return g[0]=1/A[0],g[1]=1/A[1],g}function eZt(g,A){var I=A[0],e=A[1],t=I*I+e*e;return t>0&&(t=1/Math.sqrt(t)),g[0]=A[0]*t,g[1]=A[1]*t,g}function tZt(g,A){return g[0]*A[0]+g[1]*A[1]}function oZt(g,A,I){var e=A[0]*I[1]-A[1]*I[0];return g[0]=g[1]=0,g[2]=e,g}function BZt(g,A,I,e){var t=A[0],o=A[1];return g[0]=t+e*(I[0]-t),g[1]=o+e*(I[1]-o),g}function CZt(g,A){A=A===void 0?1:A;var I=Z2()*2*Math.PI;return g[0]=Math.cos(I)*A,g[1]=Math.sin(I)*A,g}function QZt(g,A,I){var e=A[0],t=A[1];return g[0]=I[0]*e+I[2]*t,g[1]=I[1]*e+I[3]*t,g}function iZt(g,A,I){var e=A[0],t=A[1];return g[0]=I[0]*e+I[2]*t+I[4],g[1]=I[1]*e+I[3]*t+I[5],g}function EZt(g,A,I){var e=A[0],t=A[1];return g[0]=I[0]*e+I[3]*t+I[6],g[1]=I[1]*e+I[4]*t+I[7],g}function nZt(g,A,I){var e=A[0],t=A[1];return g[0]=I[0]*e+I[4]*t+I[12],g[1]=I[1]*e+I[5]*t+I[13],g}function sZt(g,A,I,e){var t=A[0]-I[0],o=A[1]-I[1],B=Math.sin(e),C=Math.cos(e);return g[0]=t*C-o*B+I[0],g[1]=t*B+o*C+I[1],g}function aZt(g,A){var I=g[0],e=g[1],t=A[0],o=A[1];return Math.abs(Math.atan2(e*t-I*o,I*t+e*o))}function rZt(g,A){var I=g[0],e=g[1],t=A[0],o=A[1];return Math.atan2(I*o-e*t,I*t+e*o)}function cZt(g){return g[0]=0,g[1]=0,g}function hZt(g){return"vec2("+g[0]+", "+g[1]+")"}function lZt(g,A){return g[0]===A[0]&&g[1]===A[1]}function DZt(g,A){var I=g[0],e=g[1],t=A[0],o=A[1];return Math.abs(I-t)<=rB*Math.max(1,Math.abs(I),Math.abs(t))&&Math.abs(e-o)<=rB*Math.max(1,Math.abs(e),Math.abs(o))}var UGI,JGI,PGI,KGI,LGI,YGI,_GI,bGI,dZt=NR({"node_modules/gl-matrix/esm/vec2.js"(){dx(),UGI=xGI,JGI=MGI,PGI=SGI,KGI=fGI,LGI=RGI,YGI=NGI,_GI=FGI,bGI=(function(){var g=kGI();return function(A,I,e,t,o,B){var C,Q;for(I||(I=2),e||(e=0),t?Q=Math.min(t*I+e,A.length):Q=A.length,C=e;C<Q;C+=I)g[0]=A[C],g[1]=A[C+1],o(g,g,B),A[C]=g[0],A[C+1]=g[1];return A}})()}}),HGI={};xR(HGI,{glMatrix:()=>pwI,mat2:()=>SwI,mat2d:()=>FwI,mat3:()=>LwI,mat4:()=>TwI,quat:()=>WuI,quat2:()=>hGI,vec2:()=>pGI,vec3:()=>BuI,vec4:()=>GuI});var yZt=NR({"node_modules/gl-matrix/esm/index.js"(){dx(),xvt(),Aqt(),qwI(),ouI(),cGI(),H7t(),dZt(),uuI(),OuI()}}),vGI=fg({"node_modules/jscad-planner/dist/index.cjs"(g,A){var I=Object.defineProperty,e=Object.getOwnPropertyDescriptor,t=Object.getOwnPropertyNames,o=Object.prototype.hasOwnProperty,B=(w,u)=>{for(var G in u)I(w,G,{get:u[G],enumerable:!0})},C=(w,u,G,m)=>{if(u&&typeof u=="object"||typeof u=="function")for(let p of t(u))!o.call(w,p)&&p!==G&&I(w,p,{get:()=>u[p],enumerable:!(m=e(u,p))||m.enumerable});return w},Q=w=>C(I({},"__esModule",{value:!0}),w),i={};B(i,{assertTransformMatrix:()=>n,executeJscadOperations:()=>d,jscadPlanner:()=>r,resolveReferencePlanes:()=>D,toTransformMatrix:()=>s}),A.exports=Q(i);var E="Transform matrix must be a column-major array of exactly 16 finite numbers";function n(w){if(!Array.isArray(w)||w.length!==16||!Array.from(w).every(Number.isFinite))throw new Error(E)}function s(w){if(w==null||w.length!==16)throw new Error(E);const u=Array.from(w);return n(u),u}var r={booleans:{intersect:(...w)=>({type:"intersect",shapes:w}),subtract:(...w)=>({type:"subtract",shapes:w}),union:(...w)=>({type:"union",shapes:w})},hulls:{hull:(...w)=>({type:"hull",shapes:w.flat()}),hullChain:(...w)=>({type:"hullChain",shapes:w.flat()})},colors:{colorize:(w,u)=>({type:"colorize",color:w,shape:u})},primitives:{rectangle:w=>({...w,type:"rectangle"}),cube:w=>({type:"cube",...w}),sphere:w=>({type:"sphere",...w}),cylinder:w=>({type:"cylinder",...w}),polygon:w=>({type:"polygon",...w}),cuboid:w=>({type:"cuboid",...w}),roundedCuboid:w=>({type:"roundedCuboid",...w})},transforms:{transform:(w,u)=>(n(w),{type:"transform",matrix:w,shape:u}),rotate:(w,u)=>({type:"rotate",angles:w,shape:u}),rotateX:(w,u)=>({type:"rotateX",angle:w,shape:u}),rotateY:(w,u)=>({type:"rotateY",angle:w,shape:u}),rotateZ:(w,u)=>({type:"rotateZ",angle:w,shape:u}),scale:(w,u)=>({type:"scale",factors:w,shape:u}),translate:(w,u)=>({type:"translate",vector:w,shape:u})},extrusions:{extrudeLinear:(w,u)=>({type:"extrudeLinear",options:w,shape:u}),extrudeRotate:(w,u)=>({type:"extrudeRotate",options:w,shape:u})},maths:{vec2:{create:(w,u)=>[w,u],fromValues:(w,u)=>[w,u]},vec3:{create:(w,u,G)=>[w,u,G],fromValues:(w,u,G)=>[w,u,G]}},geometries:{geom2:{create:w=>({type:"createGeom2",points:w}),fromPoints:w=>({type:"fromPointsGeom2",points:w})},geom3:{create:w=>({type:"createGeom3",polygons:w})},path2:{create:w=>({type:"createPath2",points:w})}},measurements:{measureBoundingBox:w=>({type:"measureBoundingBox",shape:w}),measureArea:w=>({type:"measureArea",shape:w}),measureVolume:w=>({type:"measureVolume",shape:w})},utils:{degToRad:w=>w*Math.PI/180,radToDeg:w=>w*180/Math.PI}},a=(yZt(),w5t(HGI)),c=()=>s(a.mat4.create());function h(w){const u=c();switch(w.type){case"transform":return n(w.matrix),[...w.matrix];case"translate":return s(a.mat4.fromTranslation(u,w.vector));case"scale":return s(a.mat4.fromScaling(u,w.factors));case"rotate":return a.mat4.rotateZ(u,u,w.angles[2]),a.mat4.rotateY(u,u,w.angles[1]),a.mat4.rotateX(u,u,w.angles[0]),u;case"rotateX":return s(a.mat4.fromXRotation(u,w.angle));case"rotateY":return s(a.mat4.fromYRotation(u,w.angle));case"rotateZ":return s(a.mat4.fromZRotation(u,w.angle));default:throw new Error(`Cannot use ${w.type} as a reference transform`)}}function l(w,u){const G=w.name;if(!G?.trim())throw new Error("Reference rectangles require a nonblank name");let m;if(w.type==="rectangle"){if(w.size.length!==2||!w.size.every(N=>Number.isFinite(N)&&N>0))throw new Error(`Reference rectangle "${G}" requires two positive finite dimensions`);m=w.center??[0,0]}else{const N=w.points;if(w.paths||N.length!==4||!N.every(b=>b.length===2&&b.every(T=>typeof T=="number"&&Number.isFinite(T))))throw new Error(`Reference polygon "${G}" must be an axis-aligned rectangle`);const J=N,K=[...new Set(J.map(b=>b[0]))],_=[...new Set(J.map(b=>b[1]))];if(K.length!==2||_.length!==2||new Set(J.map(b=>JSON.stringify(b))).size!==4)throw new Error(`Reference polygon "${G}" must be an axis-aligned rectangle`);m=[(K[0]+K[1])/2,(_[0]+_[1])/2]}if(m.length!==2||!m.every(Number.isFinite))throw new Error(`Reference rectangle "${G}" has an invalid center`);const p=c();for(const N of u)a.mat4.multiply(p,p,h(N));if(n(p),p[3]!==0||p[7]!==0||p[11]!==0||p[15]!==1)throw new Error(`Reference rectangle "${G}" requires affine transforms`);const k=a.mat4.invert(c(),p);if(!k)throw new Error(`Reference rectangle "${G}" has a singular transform`);const S=[0,0,0];a.vec3.transformMat4(S,[m[0],m[1],0],p);const R=[k[2],k[6],k[10]],x=[p[0],p[1],p[2]];if(![...S,...R,...x].every(Number.isFinite)||!a.vec3.length(R)||!a.vec3.length(x))throw new Error(`Reference rectangle "${G}" has an invalid frame`);return a.vec3.normalize(R,R),a.vec3.normalize(x,x),{name:G,origin:S,normal:R,xAxis:x}}function D(w){const u=[],G=new Set;function m(S,R,x=!1){if(S.reference){if(S.type!=="rectangle"&&S.type!=="polygon")throw new Error("Only rectangles can be reference geometry");if(x)throw new Error("Reference rectangles must be outside extrusion and measurement inputs");const N=l(S,R);if(G.has(N.name))throw new Error(`Duplicate reference plane "${N.name}"`);G.add(N.name),u.push(N);return}switch(S.type){case"translate":case"rotate":case"rotateX":case"rotateY":case"rotateZ":case"scale":case"transform":{const N=m(S.shape,[...R,S],x);return N?{...S,shape:N}:void 0}case"colorize":{const N=m(S.shape,R,x);return N?{...S,shape:N}:void 0}case"extrudeLinear":case"extrudeRotate":case"measureArea":case"measureVolume":case"measureBoundingBox":{const N=m(S.shape,R,!0);return N?{...S,shape:N}:void 0}case"union":case"subtract":case"intersect":case"hull":case"hullChain":{const N=S.shapes.map(K=>m(K,R,x));if(S.type==="subtract"&&S.shapes.length&&!N[0])throw new Error("A subtraction base cannot be reference geometry");const J=N.filter(K=>K!==void 0);return J.length?J.length===1?J[0]:{...S,shapes:J}:void 0}default:return{...S}}}const p=(Array.isArray(w)?w:[w]).map(S=>m(S,[])).filter(S=>S!==void 0);return{geometry:p.length>1?{type:"union",shapes:p}:p[0],referencePlanes:u}}var d=(w,u)=>{if(Array.isArray(u)&&u.length===1)return d(w,u[0]);if(Array.isArray(u))throw new Error("executeJscadOperations currently doesn't support Array<JscadOperation>, try adding a root union or or executing each element individually");const{geometry:G}=D(u);if(!G)throw new Error("JSCAD plan contains only reference geometry");return y(w,G)},y=(w,u)=>{const G=k=>y(w,k),{type:m,...p}=u;switch(m){case"rectangle":if(!w.primitives.rectangle)throw new Error("JSCAD adapter does not support primitives.rectangle");return w.primitives.rectangle({size:u.size,center:u.center??[0,0]});case"intersect":return w.booleans.intersect(...u.shapes.map(G));case"subtract":return w.booleans.subtract(...u.shapes.map(G));case"union":return w.booleans.union(...u.shapes.map(G));case"hull":return w.hulls.hull(...u.shapes.map(G));case"hullChain":return w.hulls.hullChain(...u.shapes.map(G));case"colorize":return w.colors.colorize(u.color,G(u.shape));case"cube":return w.primitives.cube(p);case"sphere":return w.primitives.sphere(p);case"cylinder":return w.primitives.cylinder(p);case"polygon":return w.primitives.polygon(p);case"cuboid":return w.primitives.cuboid(p);case"roundedCuboid":return w.primitives.roundedCuboid(p);case"transform":if(n(u.matrix),!w.transforms.transform)throw new Error('Cannot execute "transform" operation: this JSCAD adapter does not support transforms.transform');return w.transforms.transform(u.matrix,G(u.shape));case"rotate":return w.transforms.rotate(u.angles,G(u.shape));case"rotateX":return w.transforms.rotateX(u.angle,G(u.shape));case"rotateY":return w.transforms.rotateY(u.angle,G(u.shape));case"rotateZ":return w.transforms.rotateZ(u.angle,G(u.shape));case"scale":return w.transforms.scale(u.factors,G(u.shape));case"translate":return w.transforms.translate(u.vector,G(u.shape));case"extrudeLinear":return w.extrusions.extrudeLinear(u.options,G(u.shape));case"extrudeRotate":return w.extrusions.extrudeRotate(u.options,G(u.shape));case"createGeom2":return w.geometries.geom2.create(u.points);case"fromPointsGeom2":return w.geometries.geom2.fromPoints(u.points);case"createGeom3":return w.geometries.geom3.create(u.polygons);case"createPath2":return w.geometries.path2.create(u.points);case"measureBoundingBox":return w.measurements.measureBoundingBox(G(u.shape));case"measureArea":return w.measurements.measureArea(G(u.shape));case"measureVolume":return w.measurements.measureVolume(G(u.shape));case"degToRad":return w.utils.degToRad(u.degrees);case"radToDeg":return w.utils.radToDeg(u.radians);default:throw u.type===void 0?new Error(`Operation type is undefined. This usually means the operation object is malformed or not properly initialized. Operation: ${JSON.stringify(u,null,2).slice(0,200)}...`):new Error(`Unsupported operation type: ${u.type}. Operation: ${JSON.stringify(u,null,2)}`)}}}}),wZt=fg({"node_modules/ms/index.js"(g,A){var I=1e3,e=I*60,t=e*60,o=t*24,B=o*7,C=o*365.25;A.exports=function(s,r){r=r||{};var a=typeof s;if(a==="string"&&s.length>0)return Q(s);if(a==="number"&&isFinite(s))return r.long?E(s):i(s);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(s))};function Q(s){if(s=String(s),!(s.length>100)){var r=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(s);if(r){var a=parseFloat(r[1]),c=(r[2]||"ms").toLowerCase();switch(c){case"years":case"year":case"yrs":case"yr":case"y":return a*C;case"weeks":case"week":case"w":return a*B;case"days":case"day":case"d":return a*o;case"hours":case"hour":case"hrs":case"hr":case"h":return a*t;case"minutes":case"minute":case"mins":case"min":case"m":return a*e;case"seconds":case"second":case"secs":case"sec":case"s":return a*I;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return a;default:return}}}}function i(s){var r=Math.abs(s);return r>=o?Math.round(s/o)+"d":r>=t?Math.round(s/t)+"h":r>=e?Math.round(s/e)+"m":r>=I?Math.round(s/I)+"s":s+"ms"}function E(s){var r=Math.abs(s);return r>=o?n(s,r,o,"day"):r>=t?n(s,r,t,"hour"):r>=e?n(s,r,e,"minute"):r>=I?n(s,r,I,"second"):s+" ms"}function n(s,r,a,c){var h=r>=a*1.5;return Math.round(s/a)+" "+c+(h?"s":"")}}}),uZt=fg({"node_modules/debug/src/common.js"(g,A){function I(e){o.debug=o,o.default=o,o.coerce=n,o.disable=i,o.enable=C,o.enabled=E,o.humanize=wZt(),o.destroy=s,Object.keys(e).forEach(r=>{o[r]=e[r]}),o.names=[],o.skips=[],o.formatters={};function t(r){let a=0;for(let c=0;c<r.length;c++)a=(a<<5)-a+r.charCodeAt(c),a|=0;return o.colors[Math.abs(a)%o.colors.length]}o.selectColor=t;function o(r){let a,c=null,h,l;function D(...d){if(!D.enabled)return;const y=D,w=Number(new Date),u=w-(a||w);y.diff=u,y.prev=a,y.curr=w,a=w,d[0]=o.coerce(d[0]),typeof d[0]!="string"&&d.unshift("%O");let G=0;d[0]=d[0].replace(/%([a-zA-Z%])/g,(p,k)=>{if(p==="%%")return"%";G++;const S=o.formatters[k];if(typeof S=="function"){const R=d[G];p=S.call(y,R),d.splice(G,1),G--}return p}),o.formatArgs.call(y,d),(y.log||o.log).apply(y,d)}return D.namespace=r,D.useColors=o.useColors(),D.color=o.selectColor(r),D.extend=B,D.destroy=o.destroy,Object.defineProperty(D,"enabled",{enumerable:!0,configurable:!1,get:()=>c!==null?c:(h!==o.namespaces&&(h=o.namespaces,l=o.enabled(r)),l),set:d=>{c=d}}),typeof o.init=="function"&&o.init(D),D}function B(r,a){const c=o(this.namespace+(typeof a>"u"?":":a)+r);return c.log=this.log,c}function C(r){o.save(r),o.namespaces=r,o.names=[],o.skips=[];const a=(typeof r=="string"?r:"").trim().replace(/\s+/g,",").split(",").filter(Boolean);for(const c of a)c[0]==="-"?o.skips.push(c.slice(1)):o.names.push(c)}function Q(r,a){let c=0,h=0,l=-1,D=0;for(;c<r.length;)if(h<a.length&&(a[h]===r[c]||a[h]==="*"))a[h]==="*"?(l=h,D=c,h++):(c++,h++);else if(l!==-1)h=l+1,D++,c=D;else return!1;for(;h<a.length&&a[h]==="*";)h++;return h===a.length}function i(){const r=[...o.names,...o.skips.map(a=>"-"+a)].join(",");return o.enable(""),r}function E(r){for(const a of o.skips)if(Q(r,a))return!1;for(const a of o.names)if(Q(r,a))return!0;return!1}function n(r){return r instanceof Error?r.stack||r.message:r}function s(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}return o.enable(o.load()),o}A.exports=I}}),GZt=fg({"node_modules/debug/src/browser.js"(g,A){g.formatArgs=e,g.save=t,g.load=o,g.useColors=I,g.storage=B(),g.destroy=(()=>{let Q=!1;return()=>{Q||(Q=!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`."))}})(),g.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 I(){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 Q;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&&(Q=navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/))&&parseInt(Q[1],10)>=31||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}function e(Q){if(Q[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+Q[0]+(this.useColors?"%c ":" ")+"+"+A.exports.humanize(this.diff),!this.useColors)return;const i="color: "+this.color;Q.splice(1,0,i,"color: inherit");let E=0,n=0;Q[0].replace(/%[a-zA-Z%]/g,s=>{s!=="%%"&&(E++,s==="%c"&&(n=E))}),Q.splice(n,0,i)}g.log=console.debug||console.log||(()=>{});function t(Q){try{Q?g.storage.setItem("debug",Q):g.storage.removeItem("debug")}catch{}}function o(){let Q;try{Q=g.storage.getItem("debug")||g.storage.getItem("DEBUG")}catch{}return!Q&&typeof _$A<"u"&&"env"in _$A&&(Q=_$A.env.DEBUG),Q}function B(){try{return localStorage}catch{}}A.exports=uZt()(g);var{formatters:C}=A.exports;C.j=function(Q){try{return JSON.stringify(Q)}catch(i){return"[UnexpectedJSONParseError]: "+i.message}}}}),kAg=X.createContext(null),RD=()=>{const g=X.useContext(kAg);if(!g)throw new Error("useThree must be used within a ThreeProvider");return g},DIA=(g,A=[])=>{const{addFrameListener:I,removeFrameListener:e}=RD();sC.useEffect(()=>(I(g),()=>e(g)),[I,e,...A])},MAg=X.createContext(null),mZt=()=>{const g=X.useContext(MAg),A=RD();return X.useEffect(()=>{if(g)return g.current=A,()=>{g.current=null}},[g,A]),null},pZt=({cadComponent:g,children:A})=>{const I=RD(),e=X.useMemo(()=>new Yc,[]);e.userData.cad_component_id=g.cad_component_id,e.userData.pcb_component_id=g.pcb_component_id,X.useEffect(()=>(I.rootObject.add(e),()=>{I.rootObject.remove(e)}),[I.rootObject,e]);const t=X.useMemo(()=>({...I,rootObject:e}),[I,e]);return q.jsx(kAg.Provider,{value:t,children:A})},qGI=(g,A)=>{if(!g)return;const{camera:I,rootObject:e,renderer:t}=g,o=t.domElement.getBoundingClientRect();if(!o.width||!o.height||A.x<o.left||A.x>o.right||A.y<o.top||A.y>o.bottom)return;const B=new DBI;I.updateWorldMatrix(!0,!1),e.updateWorldMatrix(!0,!0),B.setFromCamera(new ct((A.x-o.left)/o.width*2-1,-((A.y-o.top)/o.height)*2+1),I);for(const C of B.intersectObject(e,!0)){if(!(C.object instanceof Ko))continue;let Q=C.object,i=!0;for(;Q;)Q.visible||(i=!1),Q=Q.parent;if(i)return C.object}},kZt=(g,A,I)=>{let e=qGI(g,A)??null,t;for(;e;)t??=e.userData.pcb_component_id,e=e.parent;if(!t)return;const o=I.find(C=>C.type==="pcb_component"&&C.pcb_component_id===t);if(o?.type!=="pcb_component")return;const B=I.find(C=>C.type==="source_component"&&C.source_component_id===o.source_component_id);if(B?.type==="source_component")return{source_component_id:B.source_component_id,pcb_component_id:o.pcb_component_id,refdes:B.name}};function TGI(g,A){return A??g.some(I=>I.type==="cad_component"&&I.is_on_folded_board===!0)}var MZt=(g,A,I)=>{let e=qGI(g,A)??null;for(;e;){const t=e.userData.cad_component_id;if(t){const o=I.find(C=>C.type==="cad_component"&&C.cad_component_id===t);if(o?.type!=="cad_component")return;const B=I.find(C=>C.type==="source_component"&&C.source_component_id===o.source_component_id);return{cad_component_id:o.cad_component_id,componentName:B?.type==="source_component"?B.name:o.cad_component_id}}e=e.parent}},ayA=new Set,SZt=g=>{const[A,I]=X.useState({circuitKey:g,ids:ayA}),e=A.circuitKey===g?A.ids:ayA;return A.circuitKey!==g&&I({circuitKey:g,ids:ayA}),{hiddenCadComponentIds:e,hideComponent:t=>{I(o=>({circuitKey:g,ids:new Set([...o.circuitKey===g?o.ids:[],t])}))},unhideAllComponents:()=>{I({circuitKey:g,ids:ayA})}}},SAg=g=>X.useMemo(()=>{if(!g)return[];const A=new Nit;return A.add(g),A.render(),A.getCircuitJson()},[g]),fZt=(g,A)=>{const I=g.pcb_component_id?A.find(e=>e.type==="pcb_component"&&e.pcb_component_id===g.pcb_component_id):void 0;return{pcbComponent:I,layer:g.layer??I?.layer??"top",isThroughHole:!!(I&&A.some(e=>e.type==="pcb_plated_hole"&&e.pcb_component_id===I.pcb_component_id))}},fAg=["translucent","opaque","hidden"],RZt=g=>fAg[(fAg.indexOf(g)+1)%fAg.length],ZGI={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"},OGI=X.createContext(void 0),NZt=({children:g})=>{const[A,I]=X.useState(ZGI),e=X.useCallback((B,C)=>{I(Q=>({...Q,[B]:C}))},[]),t=X.useCallback(()=>{I(ZGI)},[]),o=X.useMemo(()=>({visibility:A,setLayerVisibility:e,resetToDefaults:t}),[A,e,t]);return q.jsx(OGI.Provider,{value:o,children:g})},h5=()=>{const g=X.useContext(OGI);if(!g)throw new Error("useLayerVisibility must be used within a LayerVisibilityProvider");return g},RAg=1.2;function WGI(g){return X.useMemo(()=>{if(!g)return RAg;try{return Xo(g).pcb_board.list()[0]?.thickness??RAg}catch{return RAg}},[g])}var dIA={clickToInteractOverlay:100,htmlElements:95,orientationCube:95,contextMenu:110,appearanceMenu:111},VGI=({children:g,position:A,style:I})=>{const{camera:e,renderer:t}=RD(),o=X.useRef(document.createElement("div")),[B,C]=X.useState(null);return X.useEffect(()=>{const Q=t?.domElement.parentNode;if(Q)return Q.style.position!=="relative"&&Q.style.position!=="absolute"&&(Q.style.position="relative"),Q.appendChild(o.current),C(Qjg.createPortal(g,o.current)),()=>{Q.contains(o.current)&&Q.removeChild(o.current)}},[t,g]),DIA(()=>{if(!e||!o.current||!t)return;const Q=new BI(...A);Q.project(e);const i=t.domElement.getBoundingClientRect(),E=Math.round((Q.x+1)/2*i.width),n=Math.round((-Q.y+1)/2*i.height);o.current.style.position="absolute",o.current.style.left=`${E}px`,o.current.style.top=`${n}px`,o.current.style.pointerEvents="none",o.current.style.zIndex=dIA.htmlElements.toString(),I&&Object.assign(o.current.style,I)},[e,t,A,I]),B},xZt=Bs(eyA()),jGI=X.createContext(null),FZt=()=>{const g=X.useContext(jGI);if(!g)throw new Error("useHover must be used within a HoverProvider");return g},UZt=({children:g})=>{const{camera:A,renderer:I}=RD(),[e,t]=X.useState([]),o=X.useMemo(()=>new DBI,[]),B=X.useMemo(()=>new ct,[]),C=X.useRef(e);C.current=e;const Q=X.useRef(null),i=X.useCallback(a=>{t(c=>[...c,a])},[]),E=X.useCallback(a=>{if(Q.current){let c=!1,h=Q.current.object;for(;h;){if(h===a){c=!0;break}h=h.parent}c&&(Q.current.onUnhover(),Q.current=null)}t(c=>c.filter(h=>h.object!==a))},[]),n=X.useCallback(a=>{let c=a;for(;c;){const h=C.current.find(l=>l.object===c);if(h)return h;c=c.parent}},[]),s=X.useCallback(a=>{if(!I.domElement)return;const c=I.domElement.getBoundingClientRect();B.x=(a.clientX-c.left)/c.width*2-1,B.y=-((a.clientY-c.top)/c.height)*2+1,o.setFromCamera(B,A);const h=C.current.map(D=>D.object);if(h.length===0){Q.current&&(Q.current.onUnhover(),Q.current=null);return}const l=o.intersectObjects(h,!0);if(l.length>0){const D=l[0],d=n(D.object);if(d){const y={mousePosition:[D.point.x,D.point.y,D.point.z]};Q.current!==d?(Q.current?.onUnhover(),d.onHover(y),Q.current=d):d.onHover(y)}else Q.current&&(Q.current.onUnhover(),Q.current=null)}else Q.current&&(Q.current.onUnhover(),Q.current=null)},[A,I,o,B,n]);X.useEffect(()=>{const a=I.domElement;return a.addEventListener("mousemove",s),()=>{a.removeEventListener("mousemove",s)}},[I,s]);const r=X.useMemo(()=>({addHoverable:i,removeHoverable:E}),[i,E]);return q.jsx(jGI.Provider,{value:r,children:g})},JZt=({children:g,object:A,onHover:I,onUnhover:e,isHovered:t})=>{const{addHoverable:o,removeHoverable:B}=FZt();return X.useEffect(()=>A?(o({object:A,onHover:I,onUnhover:e}),()=>{B(A)}):void 0,[A,I,e,o,B]),q.jsx(q.Fragment,{children:g})},yIA=JZt,AS=(g,{castShadow:A=!0,receiveShadow:I=!0}={})=>{g.traverse(e=>{e instanceof Ko&&(e.castShadow=A,e.receiveShadow=I)})},PZt=({positionOffset:g,footprint:A,rotationOffset:I,onHover:e,onUnhover:t,isHovered:o,scale:B,isTranslucent:C=!1})=>{const{rootObject:Q}=RD(),i=X.useMemo(()=>{if(!A)return null;const{geometries:E}=PKt(A,xZt),n=new Yc;for(const s of E.flat(1/0)){const r=s.geom;if(!r||!r.polygons&&!r.sides)continue;const a=new oo(s.color);a.convertLinearToSRGB();const c={...r,color:[a.r,a.g,a.b]},h=qlI(c),l=new Hs({vertexColors:!0,side:Ml,transparent:C,opacity:C?.5:1,depthWrite:!C}),D=new Ko(h,l);D.renderOrder=C?2:1,AS(D,{castShadow:!C,receiveShadow:!0}),n.add(D)}return n},[A,C]);return X.useEffect(()=>{if(!(!i||!Q))return Q.add(i),()=>{Q.remove(i)}},[Q,i]),X.useEffect(()=>{i&&(g&&i.position.fromArray(g),I&&i.rotation.fromArray(I),B!==void 0&&i.scale.setScalar(B))},[i,g?.[0],g?.[1],g?.[2],I?.[0],I?.[1],I?.[2],B]),X.useEffect(()=>{i&&i.traverse(E=>{E instanceof Ko&&E.material instanceof Hs&&(o?(E.material.emissive.setHex(255),E.material.emissiveIntensity=.2):E.material.emissiveIntensity=0)})},[o,i]),i?q.jsx(yIA,{isHovered:o,onHover:e,onUnhover:t,object:i}):null},zGI=new WeakMap,KZt=()=>{const g=new $r;return g.name="fallback-environment-map",g.mapping=_lA,g},LZt=g=>{if(!g)return null;const A=g,I=zGI.get(A);if(I)return I;let e;if(g instanceof DDA){const t=new MvA(g);e=t.fromScene(B3t(),.04).texture,t.dispose()}else e=KZt();return zGI.set(A,e),e};function YZt(g){const A=new pm;let I=!1;g.updateWorldMatrix(!0,!1);const e=g.parent?g.parent.matrixWorld.clone().invert():new aQ;return g.traverse(t=>{if(t.updateWorldMatrix(!0,!1),t instanceof Ko&&t.geometry&&(t.geometry.boundingBox||t.geometry.computeBoundingBox(),t.geometry.boundingBox)){const o=e.clone().multiply(t.matrixWorld),B=t.geometry.boundingBox.clone();B.applyMatrix4(o),I?A.union(B):(A.copy(B),I=!0)}}),I?A:null}function _Zt(g){const A=YZt(g);return A?A.getSize(new BI):new BI}function bZt(g,A,I="contain_within_bounds"){if(!A)return[1,1,1];const e=_Zt(g),t=[e.x>0?A[0]/e.x:1,e.y>0?A[1]/e.y:1,e.z>0?A[2]/e.z:1];if(I==="fill_bounds")return t;const o=Math.min(...t);return[o,o,o]}var NAg=({model:g,position:A,rotation:I,modelOffset:e=[0,0,0],modelRotation:t=[0,0,0],sourceCoordinateTransform:o,modelSize:B,modelFitMode:C="contain_within_bounds",scale:Q})=>{const{rootObject:i}=RD(),E=X.useMemo(()=>new Yc,[]),n=X.useMemo(()=>new Yc,[]),s=X.useMemo(()=>new Yc,[]),r=X.useMemo(()=>new Yc,[]);return X.useEffect(()=>(E.add(n),()=>{E.remove(n)}),[E,n]),X.useEffect(()=>(n.add(s),()=>{n.remove(s)}),[n,s]),X.useEffect(()=>(s.add(r),()=>{s.remove(r)}),[s,r]),X.useEffect(()=>{for(;r.children.length>0;){const a=r.children[0];if(!a)break;r.remove(a)}g&&r.add(g)},[r,g]),X.useEffect(()=>{if(!o){r.matrixAutoUpdate=!0,r.position.set(0,0,0),r.rotation.set(0,0,0),r.scale.set(1,1,1),r.updateMatrix();return}r.matrixAutoUpdate=!1,r.matrix.copy(o),r.matrixWorldNeedsUpdate=!0},[r,o]),X.useEffect(()=>{if(i)return i.add(E),()=>{i.remove(E)}},[i,E]),X.useEffect(()=>{if(A?E.position.fromArray(A):E.position.set(0,0,0),I?E.rotation.fromArray(I):E.rotation.set(0,0,0),s.position.fromArray(e),s.rotation.fromArray(t),s.scale.setScalar(Q??1),!g){n.scale.set(1,1,1);return}n.scale.set(1,1,1),n.updateWorldMatrix(!0,!0);const a=bZt(s,B,C);n.scale.set(a[0],a[1],a[2])},[E,n,g,C,e,r,s,t,B,A,I,Q]),{boardTransformGroup:E}},XGI=1.25;function $GI({gltfUrl:g,position:A,rotation:I,modelOffset:e=[0,0,0],modelRotation:t=[0,0,0],sourceCoordinateTransform:o,modelSize:B,modelFitMode:C="contain_within_bounds",onHover:Q,onUnhover:i,isHovered:E,scale:n,isTranslucent:s=!1}){const{renderer:r}=RD(),[a,c]=X.useState(null),[h,l]=X.useState(null),{boardTransformGroup:D}=NAg({model:a,position:A,rotation:I,modelOffset:e,modelRotation:t,sourceCoordinateTransform:o,modelSize:B,modelFitMode:C,scale:n});if(X.useEffect(()=>{if(!g)return;const d=new Q3t;let y=!0;return d.load(g,w=>{if(!y)return;const u=w.scene;u.traverse(G=>{if(G instanceof Ko&&G.material){const m=p=>{p.transparent=s,p.opacity=s?.5:1,p.depthWrite=!s,p.needsUpdate=!0};Array.isArray(G.material)?G.material.forEach(m):m(G.material),G.renderOrder=s?2:1}}),AS(u,{castShadow:!s,receiveShadow:!0}),c(u)},void 0,w=>{if(!y)return;console.error(`An error happened loading ${g}`,w);const u=w instanceof Error?w:new Error(`Failed to load glTF model from ${g}`);l(u)}),()=>{y=!1}},[g,s]),X.useEffect(()=>{if(!a||!r)return;const d=LZt(r);if(!d)return;const y=[],w=u=>{u instanceof Hs&&(y.push({material:u,envMap:u.envMap??null,envMapIntensity:u.envMapIntensity??1}),u.envMap=d,(typeof u.envMapIntensity!="number"||u.envMapIntensity<XGI)&&(u.envMapIntensity=XGI),u.needsUpdate=!0)};return a.traverse(u=>{if(!(u instanceof Ko))return;const G=u.material;Array.isArray(G)?G.forEach(w):G&&w(G)}),()=>{y.forEach(({material:u,envMap:G,envMapIntensity:m})=>{u.envMap=G,u.envMapIntensity=m,u.needsUpdate=!0})}},[a,r]),X.useEffect(()=>{a&&a.traverse(d=>{if(!(d instanceof Ko))return;const y=Array.isArray(d.material)?d.material:[d.material];for(const w of y)w instanceof Hs&&(E?(w.emissive.setHex(255),w.emissiveIntensity=.2):w.emissiveIntensity=0)})},[E,a]),h)throw h;return a?q.jsx(yIA,{isHovered:E,onHover:Q,onUnhover:i,object:D}):null}var HZt=Bs(vGI()),vZt=Bs(eyA()),qZt=({jscadPlan:g,positionOffset:A,rotationOffset:I,modelOffset:e=[0,0,0],modelRotation:t=[0,0,0],sourceCoordinateTransform:o,modelSize:B,modelFitMode:C="contain_within_bounds",onHover:Q,onUnhover:i,isHovered:E,scale:n,isTranslucent:s=!1})=>{const[r,a]=X.useState(null);X.useEffect(()=>{const l=(0,HZt.executeJscadOperations)(vZt.default,g);if(!l||!l.polygons&&!l.sides){a(null);return}const D=qlI(l),d=new Hs({vertexColors:!0,side:Ml}),y=new Ko(D,d);return a(y),()=>{D.dispose(),d.dispose()}},[g]),X.useEffect(()=>{if(!r)return;const l=r.material;l.transparent=s,l.opacity=s?.5:1,l.depthWrite=!s,l.needsUpdate=!0,r.renderOrder=s?2:1,AS(r,{castShadow:!s,receiveShadow:!0})},[r,s]);const c=r?.material,{boardTransformGroup:h}=NAg({model:r,position:A,rotation:I,modelOffset:e,modelRotation:t,sourceCoordinateTransform:o,modelSize:B,modelFitMode:C,scale:n});return X.useEffect(()=>{if(c)if(E){const l=new oo(c.color.getHex());c.emissive.copy(l),c.emissive.setRGB(0,0,1),c.emissiveIntensity=.2}else c.emissiveIntensity=0},[E,c]),r?q.jsx(yIA,{isHovered:E,onHover:Q,onUnhover:i,object:h}):null};function TZt(g){return g.replace(/(DEF|USE)\s+([^\s]+)/g,(A,I,e)=>`${I} ${e.replace(/-/g,"_")}`)}async function ZZt(g){const A=await fetch(g);if(!A.ok)throw new Error(`Failed to fetch "${g}": ${A.status} ${A.statusText}`);const I=await A.text();return new O3t().parse(TZt(I),g)}typeof window<"u"&&!window.TSCIRCUIT_OBJ_LOADER_CACHE&&(window.TSCIRCUIT_OBJ_LOADER_CACHE=new Map);function OZt(g){const[A,I]=X.useState(null);return X.useEffect(()=>{if(!g)return;const e=g.replace(/&cachebust_origin=$/,""),t=window.TSCIRCUIT_OBJ_LOADER_CACHE;let o=!1;async function B(){try{if(e.endsWith(".wrl"))return await ZZt(e);const Q=await fetch(e);if(!Q.ok)throw new Error(`Failed to fetch "${e}": ${Q.status} ${Q.statusText}`);const i=await Q.text(),E=i.match(/newmtl[\s\S]*?endmtl/g),n=new ILt;if(E?.length){const s=E.join(`
|
|
5323
|
-
`).replace(/^d\s+0\./gm,"d 1."),r=i.replace(/newmtl[\s\S]*?endmtl/g,"").replace(/^mtllib.*/gm,""),a=new q3t;a.setMaterialOptions({invertTrProperty:!0});const c=a.parse(s,"embedded.mtl");return n.setMaterials(c),n.parse(r)}return n.parse(i.replace(/^mtllib.*/gm,""))}catch(Q){return Q}}function C(){if(t.has(e)){const i=t.get(e);return i.result?Promise.resolve(i.result.clone()):i.promise.then(E=>E instanceof Error?E:E.clone())}const Q=B().then(i=>(i instanceof Error||t.set(e,{...t.get(e),result:i}),i));return t.set(e,{promise:Q,result:null}),Q}return C().then(Q=>{o||I(Q)}).catch(Q=>{console.error(Q)}),()=>{o=!0}},[g]),A}function WZt({url:g,position:A,rotation:I,modelOffset:e=[0,0,0],modelRotation:t=[0,0,0],sourceCoordinateTransform:o,modelSize:B,modelFitMode:C="contain_within_bounds",onHover:Q,onUnhover:i,isHovered:E,scale:n,isTranslucent:s=!1}){const r=OZt(g),a=X.useMemo(()=>{if(r&&!(r instanceof Error))return r.traverse(l=>{if(l instanceof Ko&&l.material){const D=d=>{d.transparent=s,d.opacity=s?.5:1,d.depthWrite=!s,d.needsUpdate=!0};Array.isArray(l.material)?l.material.forEach(D):D(l.material),l.renderOrder=s?2:1}}),AS(r,{castShadow:!s,receiveShadow:!0}),r;const h=new Ko(new ik(.5,.5,.5),new Hs({transparent:!0,color:"red",opacity:.25}));return AS(h,{castShadow:!1,receiveShadow:!0}),h},[r,s]),{boardTransformGroup:c}=NAg({model:a,position:Array.isArray(A)?A:A?[A.x,A.y,A.z]:void 0,rotation:Array.isArray(I)?I:I?[I.x,I.y,I.z]:void 0,modelOffset:e,modelRotation:t,sourceCoordinateTransform:o,modelSize:B,modelFitMode:C,scale:n});if(r instanceof Error)throw r;return q.jsx(yIA,{isHovered:E,onHover:Q,onUnhover:i,object:c})}var VZt=new oo(.82,.82,.82),AmI=g=>new Hs({color:g?new oo(g[0],g[1],g[2]):VZt});function jZt(g,A){const I=AmI(A.color),e=A.brep_faces??[];if(e.length===0)return[I];const t=e.length>1?[...e].sort((n,s)=>n.first-s.first):e,o=[I],B=new Map,C=A.index.array.length/3;let Q=0,i=0;const E=n=>{if(!n)return 0;const s=n.join(","),r=B.get(s);if(r!==void 0)return r;const a=o.length;return o.push(AmI(n)),B.set(s,a),a};for(;Q<C;){const n=t[i];let s=C,r=0;n&&(Q<n.first?s=n.first:(s=n.last+1,r=E(n.color),i+=1)),s>Q&&g.addGroup(Q*3,(s-Q)*3,r),Q=s}return o}function zZt(g){const A=new Yc;for(const I of g){const e=I.attributes.position?.array??[],t=I.index?.array??[];if(!e.length||!t.length)continue;const o=new Yn;o.setAttribute("position",new ZB(e,3));const B=I.attributes.normal?.array??[];B.length?o.setAttribute("normal",new ZB(B,3)):o.computeVertexNormals(),o.setIndex(t),o.clearGroups();const C=jZt(o,I),Q=new Ko(o,C.length>1?C:C[0]);Q.name=I.name,A.add(Q)}return A}var xAg,XZt="https://cdn.jsdelivr.net/npm/occt-import-js@0.0.23/dist";function $Zt(g){if(typeof g=="function")return g;if(g&&typeof g=="object"&&"default"in g&&typeof g.default=="function")return g.default;throw new Error("Unable to resolve occt-import-js factory export")}async function AOt(){if(!xAg){const g=await import("https://cdn.jsdelivr.net/npm/occt-import-js@0.0.23/+esm");xAg=$Zt(g)({locateFile:I=>`${XZt}/${I}`})}return xAg}async function gOt(g){const A=await fetch(g);if(!A.ok)throw new Error(`Failed to fetch STEP file: ${A.statusText}`);const I=await A.arrayBuffer(),t=(await AOt()).ReadStepFile(new Uint8Array(I),null);if(!t.success||!t.meshes.length)throw new Error("occt-import-js failed to convert STEP file");const o=zZt(t.meshes),B=new ZXA;return await new Promise((Q,i)=>{B.parse(o,E=>{E instanceof ArrayBuffer?Q(E):i(new Error("GLTFExporter did not return binary output"))},E=>{i(E)},{binary:!0})})}var gmI="step-glb-cache:v2:";function IOt(g){const A=new Uint8Array(g),I=32768;let e="";for(let t=0;t<A.length;t+=I){const o=A.subarray(t,t+I);e+=String.fromCharCode(...o)}return btoa(e)}function eOt(g){const A=atob(g),I=new Uint8Array(A.length);for(let e=0;e<A.length;e+=1)I[e]=A.charCodeAt(e);return I.buffer}function tOt(g){try{const A=localStorage.getItem(`${gmI}${g}`);return A?eOt(A):null}catch(A){return console.warn("Failed to read STEP GLB cache",A),null}}function ImI(g,A){try{const I=IOt(A);localStorage.setItem(`${gmI}${g}`,I)}catch(I){console.warn("Failed to write STEP GLB cache",I)}}function oOt(){const g=globalThis;return g.stepUrlToGltfModelConversions||(g.stepUrlToGltfModelConversions={inProgress:new Map,completed:new Map}),g.stepUrlToGltfModelConversions}var BOt=({stepUrl:g,position:A,rotation:I,modelOffset:e,modelRotation:t,sourceCoordinateTransform:o,modelSize:B,modelFitMode:C,scale:Q,onHover:i,onUnhover:E,isHovered:n,isTranslucent:s})=>{const[r,a]=X.useState(null);return X.useEffect(()=>{let c=!0,h=null,l=!0;const D=oOt(),d=tOt(g);if(d){const u={arrayBuffer:d,blobUrl:URL.createObjectURL(new Blob([d],{type:"model/gltf-binary"}))};return D.completed.set(g,u),h=u.blobUrl,l=!1,a(u.blobUrl),()=>{c=!1,h&&l&&URL.revokeObjectURL(h)}}const y=D.completed.get(g);if(y)return h=y.blobUrl,l=!1,a(y.blobUrl),ImI(g,y.arrayBuffer),()=>{c=!1,h&&l&&URL.revokeObjectURL(h)};let w=D.inProgress.get(g);return w||(w=gOt(g).then(u=>{const G={arrayBuffer:u,blobUrl:URL.createObjectURL(new Blob([u],{type:"model/gltf-binary"}))};return D.completed.set(g,G),D.inProgress.delete(g),G}).catch(u=>{throw D.inProgress.delete(g),u}),D.inProgress.set(g,w)),w.then(u=>{c&&(h=u.blobUrl,l=!1,a(u.blobUrl),ImI(g,u.arrayBuffer))}).catch(u=>{console.error("Failed to convert STEP file to GLB",u),c&&a(null)}),()=>{c=!1,h&&l&&URL.revokeObjectURL(h)}},[g]),r?q.jsx($GI,{gltfUrl:r,position:A,rotation:I,modelOffset:e,modelRotation:t,sourceCoordinateTransform:o,modelSize:B,modelFitMode:C,scale:Q,onHover:i,onUnhover:E,isHovered:n,isTranslucent:s}):null};function ryA(g,A){let{x:I,y:e,z:t}=g;if(A.axisMapping){const o={x:I,y:e,z:t};A.axisMapping.x&&(I=FAg(o,A.axisMapping.x)),A.axisMapping.y&&(e=FAg(o,A.axisMapping.y)),A.axisMapping.z&&(t=FAg(o,A.axisMapping.z))}if(I*=A.flipX??1,e*=A.flipY??1,t*=A.flipZ??1,A.rotation){if(A.rotation.x){const o=A.rotation.x*Math.PI/180,B=Math.cos(o),C=Math.sin(o),Q=e*B-t*C,i=e*C+t*B;e=Q,t=i}if(A.rotation.y){const o=A.rotation.y*Math.PI/180,B=Math.cos(o),C=Math.sin(o),Q=I*B+t*C,i=-I*C+t*B;I=Q,t=i}if(A.rotation.z){const o=A.rotation.z*Math.PI/180,B=Math.cos(o),C=Math.sin(o),Q=I*B-e*C,i=I*C+e*B;I=Q,e=i}}return{x:I,y:e,z:t}}function FAg(g,A){switch(A){case"x":return g.x;case"y":return g.y;case"z":return g.z;case"-x":return-g.x;case"-y":return-g.y;case"-z":return-g.z;default:return 0}}var UAg={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 COt(g,A){if(A.coordinateTransform)return A.coordinateTransform;if(!A.usingGlbCoordinates){if(A.hasFootprinterModel)return UAg.FOOTPRINTER_MODEL_TRANSFORM;if(!A.usingObjFormat)return A.usingStepFormat?UAg.STEP_INVERTED:UAg.Z_UP_TO_Y_UP_USB_FIX}}function wIA(g,A){return COt(g,{usingGlbCoordinates:A==="gltf"||A==="glb"||A==="jscad",usingObjFormat:A==="obj"||A==="wrl",usingStepFormat:A==="step",hasFootprinterModel:A==="footprinter"})}function cyA(g){if(!g)return;const A=ryA({x:1,y:0,z:0},g),I=ryA({x:0,y:1,z:0},g),e=ryA({x:0,y:0,z:1},g);return new aQ().makeBasis(new BI(A.x,A.y,A.z),new BI(I.x,I.y,I.z),new BI(e.x,e.y,e.z))}function h3(g){return g*Math.PI/180}function QOt(g){if(g==="z+")return[0,0,0];switch(g){case"x+":return[0,h3(-90),0];case"x-":return[0,h3(90),0];case"y+":return[h3(90),0,0];case"y-":return[h3(-90),0,0];case"z-":return[h3(180),0,0];default:return[0,0,0]}}function iOt(g,A,I){if(!g.position)return;let e=g.position.z;return!g.is_on_folded_board&&g.pcb_component_id&&A==="bottom"&&g.position.z>=0&&(e=-(g.position.z+I)),[g.position.x,g.position.y,e]}function EOt(g,A){return g.rotation?[h3(g.rotation.x),h3(g.rotation.y),h3(g.rotation.z)]:A==="bottom"?[Math.PI,0,0]:[0,0,0]}function nOt(g,A){const I=new BI(g.x,g.y,g.z),e=new km(A[0],A[1],A[2],"XYZ");return I.applyEuler(e),[I.x,I.y,I.z]}function sOt(g,A,I){if(!g.model_origin_position)return[0,0,0];const e=A?ryA(g.model_origin_position,A):g.model_origin_position;return nOt(e,I)}function aOt(g,A){const I=iOt(g,A.layer,A.pcbThickness),e=EOt(g,A.layer),t=wIA(g,A.modelType),o=QOt(g.model_board_normal_direction??"z+"),B=sOt(g,t,o);return{position:I,rotation:e,modelPosition:[-B[0],-B[1],-B[2]],modelRotation:o,scale:g.model_unit_to_mm_scale_factor??void 0,fitMode:g.model_object_fit??"contain_within_bounds",size:g.size?[g.size.x,g.size.y,g.size.z]:void 0}}var rOt=g=>g.model_glb_url||g.model_gltf_url?g.model_glb_url?"glb":"gltf":g.model_obj_url||g.model_wrl_url||g.model_stl_url?g.model_wrl_url?"wrl":g.model_stl_url?"stl":"obj":g.model_jscad?"jscad":g.footprinter_string?"footprinter":g.model_step_url?"step":"unknown",cOt=g=>g==="step"?"glb":g,hOt=(g,A)=>{if(!g.pcb_component_id||!g.model_jscad||g.model_origin_alignment!=="bottom_center_of_component")return!1;const I=A.find(e=>e.type==="pcb_component"&&e.pcb_component_id===g.pcb_component_id);return!!(I&&I.do_not_place&&I.is_allowed_to_be_off_board&&I.obstructs_within_bounds===!1)},lOt=(g,A)=>{if(g)return A?A(g):g},DOt=(...g)=>g,JAg=class extends sC.Component{constructor(g){super(g),this.state={hasError:!1,error:null}}static getDerivedStateFromError(g){return{hasError:!0,error:g}}render(){return this.state.hasError&&this.state.error?this.props.fallback({error:this.state.error}):this.props.children}},dOt=({error:g,onError:A})=>(X.useEffect(()=>{A(g)},[g,A]),null),emI=({cad_component:g,circuitJson:A,resolveStaticAsset:I})=>{const e=WGI(A),[t,o]=X.useState(!1),{visibility:B}=h5(),[C,Q]=X.useState(null),i=X.useCallback(b=>{b?.mousePosition?(o(!0),Q(b.mousePosition)):(o(!1),Q(null))},[]),E=X.useCallback(()=>{o(!1),Q(null)},[]),n=X.useMemo(()=>Xo(A).source_component.getUsing({source_component_id:g.source_component_id})?.name,[A,g.source_component_id]),{pcbComponent:s,layer:r,isThroughHole:a}=X.useMemo(()=>fZt(g,A),[g,A]),c=X.useCallback(b=>lOt(b,I),[I]),h=c(g.model_wrl_url??g.model_stl_url??g.model_obj_url),l=c(g.model_glb_url??g.model_gltf_url),D=c(g.model_step_url),[d,y]=X.useState(0),[w,u]=X.useState(null);X.useEffect(()=>{y(0),u(null)},[g.cad_component_id,h,l,D]);const G=X.useMemo(()=>hOt(g,A),[g,A]),m=G?B.enclosure==="translucent":!!g.show_as_translucent_model,p=rOt(g),k=cOt(p),S=g.model_glb_url?"glb":"gltf",R=g.model_wrl_url?"wrl":g.model_stl_url?"stl":"obj",x=X.useMemo(()=>aOt(g,{layer:r,pcbThickness:e,modelType:k}),[g,r,e,k]),N=DOt(...x.rotation),J=x.position,K=X.useMemo(()=>{const b=[];return l&&b.push(q.jsx($GI,{gltfUrl:l,position:J,rotation:N,modelOffset:x.modelPosition,modelRotation:x.modelRotation,sourceCoordinateTransform:cyA(wIA(g,S)),scale:x.scale,modelSize:x.size,modelFitMode:x.fitMode,onHover:i,onUnhover:E,isHovered:t,isTranslucent:m},`${g.cad_component_id}-gltf-${l}`)),h&&b.push(q.jsx(WZt,{url:h,position:J,rotation:N,modelOffset:x.modelPosition,modelRotation:x.modelRotation,sourceCoordinateTransform:cyA(wIA(g,R)),scale:x.scale,modelSize:x.size,modelFitMode:x.fitMode,onHover:i,onUnhover:E,isHovered:t,isTranslucent:m},`${g.cad_component_id}-mixed-${h}`)),D&&!g.model_jscad&&!g.footprinter_string&&b.push(q.jsx(BOt,{stepUrl:D,position:J,rotation:N,modelOffset:x.modelPosition,modelRotation:x.modelRotation,sourceCoordinateTransform:cyA(wIA(g,k)),scale:x.scale,modelSize:x.size,modelFitMode:x.fitMode,onHover:i,onUnhover:E,isHovered:t,isTranslucent:m},`${g.cad_component_id}-step-${D}`)),b},[J,g.cad_component_id,g.footprinter_string,g.model_jscad,m,l,S,i,E,t,R,x.modelPosition,x.modelRotation,x.scale,x.fitMode,x.size,k,N,D,h]);let _=null;if(K.length>0){if(d>=K.length){if(w)throw w;return null}_=q.jsx(JAg,{fallback:({error:b})=>q.jsx(dOt,{error:b,onError:T=>{u(T),y(j=>Math.max(j,d+1))}}),children:K[d]},`${g.cad_component_id}-fallback-${d}`)}else g.model_jscad?_=q.jsx(qZt,{jscadPlan:g.model_jscad,positionOffset:J,rotationOffset:N,modelOffset:x.modelPosition,modelRotation:x.modelRotation,sourceCoordinateTransform:cyA(wIA(g,"jscad")),scale:x.scale,modelSize:x.size,modelFitMode:x.fitMode,onHover:i,onUnhover:E,isHovered:t,isTranslucent:m},g.cad_component_id):g.footprinter_string&&(_=q.jsx(PZt,{positionOffset:J,rotationOffset:N,footprint:g.footprinter_string,scale:x.scale,onHover:i,onUnhover:E,isHovered:t,isTranslucent:m}));if(G){if(B.enclosure==="hidden")return null}else if(g.show_as_translucent_model){if(!B.translucentModels)return null}else if(s&&(a&&!B.throughHoleModels||!a&&!B.smtModels))return null;return q.jsxs(q.Fragment,{children:[q.jsx(pZt,{cadComponent:g,children:_}),t&&C?q.jsx(VGI,{position:C,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:n??"<unknown>"}):null]})},tmI={version:"0.0.621"},omI="cadViewerLightingEnabled",yOt=()=>typeof window>"u"?!0:window.localStorage.getItem(omI)!=="false",BmI=X.createContext(void 0),wOt=({children:g})=>{const[A,I]=X.useState(!1),[e,t]=X.useState(!1),[o,B]=X.useState(yOt);X.useEffect(()=>{window.localStorage.setItem(omI,o?"true":"false")},[o]);const C=X.useMemo(()=>({darkBackgroundEnabled:A,setDarkBackgroundEnabled:I,gridEnabled:e,setGridEnabled:t,lightingEnabled:o,setLightingEnabled:B}),[A,e,o]);return q.jsx(BmI.Provider,{value:C,children:g})},PAg=()=>{const g=X.useContext(BmI);if(!g)throw new Error("useAppearance must be used within an AppearanceProvider");return g},CmI="cadViewerCameraStateSession",QmI=(g,A)=>{try{const I={position:g.position.toArray(),quaternion:g.quaternion.toArray(),up:g.up.toArray(),fov:g.fov??50,target:A.target.toArray()};sessionStorage.setItem(CmI,JSON.stringify(I))}catch(I){console.warn("Failed to save camera:",I)}},KAg=(g,A)=>{try{const I=sessionStorage.getItem(CmI);if(!I)return!1;const e=JSON.parse(I);if(g.position.fromArray(e.position),g.quaternion.fromArray(e.quaternion),g.up.fromArray(e.up),"fov"in g){const t=g;t.fov=e.fov,t.updateProjectionMatrix?.()}return A.target.fromArray(e.target),A.update(),g.updateMatrixWorld(),!0}catch(I){return console.warn("Failed to restore camera:",I),!1}},imI=X.createContext(void 0),uOt=({children:g,defaultTarget:A,initialCameraPosition:I,initialCameraType:e})=>{const t=X.useRef(null),o=X.useRef(null),[B,C]=X.useState(null),[Q,i]=X.useState(e??"perspective"),[E,n]=X.useState(I??null),[s,r]=X.useState(new km(0,0,0)),a=X.useMemo(()=>{const[D,d,y]=I??[5,-5,5],w=Math.hypot(D-A.x,d-A.y,y-A.z);return w>0?w:5},[I,A]),c=X.useCallback(D=>{const d=[A.x,A.y,A.z],y=o.current,w=t.current;let u=a;switch(y&&w&&(u=y.position.distanceTo(w.target)),D){case"Top Center Angled":{const G=u/Math.sqrt(2);return{position:[A.x,A.y-G,A.z+G],target:d,up:[0,0,1]}}case"Top Down":return{position:[A.x,A.y,A.z+u],target:d,up:[0,0,1]};case"Top Left Corner":return{position:[A.x-u*.6,A.y-u*.6,A.z+u*.6],target:d,up:[0,0,1]};case"Top Right Corner":return{position:[A.x+u*.6,A.y-u*.6,A.z+u*.6],target:d,up:[0,0,1]};case"Left Sideview":return{position:[A.x-u,A.y,A.z],target:d,up:[0,0,1]};case"Right Sideview":return{position:[A.x+u,A.y,A.z],target:d,up:[0,0,1]};case"Front":return{position:[A.x,A.y-u,A.z],target:d,up:[0,0,1]};default:return null}},[a,A,o,t]),h=X.useCallback(D=>{t.current=D},[]),l=X.useMemo(()=>({controlsRef:t,mainCameraRef:o,defaultTarget:A,baseDistance:a,controller:B,setController:C,getPresetConfig:c,handleControlsChange:h,cameraType:Q,setCameraType:i,cameraPosition:E,setCameraPosition:n,cameraRotation:s,setCameraRotation:r,saveCameraToSession:QmI,loadCameraFromSession:KAg}),[A,a,B,c,h,Q,E,s]);return q.jsx(imI.Provider,{value:l,children:g})},iJ=()=>{const g=X.useContext(imI);if(!g)throw new Error("useCameraController must be used within a CameraControllerProvider");return g},GOt=g=>g<.5?4*g*g*g:1-Math.pow(-2*g+2,3)/2,mOt=()=>{const{controlsRef:g,mainCameraRef:A,defaultTarget:I,setController:e,getPresetConfig:t}=iJ(),o=X.useRef(null),B=X.useRef(new mm),C=X.useRef(new BI),Q=X.useRef(new BI),i=X.useRef(new mm),E=X.useRef(new mm),n=X.useRef(new bs),s=X.useRef(new bs),r=X.useCallback(({position:c,target:h,up:l,durationMs:D=600})=>{if(!A.current)return;const d=g.current?.target??I,y=new BI(c[0],c[1],c[2]),w=h?new BI(h[0],h[1],h[2]):I.clone(),u=new BI(...l??[0,0,1]).normalize(),G=s.current;G.position.copy(y),G.up.copy(u),G.lookAt(w);const m=G.quaternion.clone(),p=A.current.quaternion.clone(),k=A.current.position.clone(),S=d.clone(),R=n.current;R.up.set(0,0,1),R.position.copy(k),R.lookAt(S);const x=R.quaternion.clone();R.up.set(0,0,1),R.position.copy(y),R.lookAt(w);const N=R.quaternion.clone(),J=x.clone().invert().multiply(p).normalize(),K=N.clone().invert().multiply(m).normalize();o.current={fromPosition:k,toPosition:y,fromTarget:S,toTarget:w,toQuaternion:m,rollFrom:J,rollTo:K,startTime:performance.now(),duration:D}},[A,g,I]),a=X.useCallback(c=>{if(c==="Custom")return;const h=t(c);h&&r(h)},[r,t]);return X.useEffect(()=>A.current?(e({animateTo:r,animateToPreset:a}),()=>{e(null)}):void 0,[r,a,A,e]),DIA(()=>{if(!A.current||!o.current)return;const{fromPosition:c,toPosition:h,fromTarget:l,toTarget:D,toQuaternion:d,rollFrom:y,rollTo:w,startTime:u,duration:G}=o.current,m=performance.now()-u,p=G<=0?1:Math.min(m/G,1),k=GOt(p);A.current.position.lerpVectors(c,h,k);const S=C.current;S.copy(l).lerp(D,k);const R=n.current;R.up.set(0,0,1),R.position.copy(A.current.position),R.lookAt(S);const x=B.current;x.copy(R.quaternion);const N=i.current;N.copy(y);const J=E.current;J.copy(w),y.dot(w)<0&&(J.x*=-1,J.y*=-1,J.z*=-1,J.w*=-1),J.normalize(),N.slerp(J,k),A.current.quaternion.copy(x).multiply(N).normalize();const K=Q.current;K.set(0,1,0).applyQuaternion(A.current.quaternion).normalize(),A.current.up.copy(K),g.current?.target.copy(S),A.current.updateMatrixWorld(),g.current?.update(),p>=1&&(A.current.position.copy(h),A.current.quaternion.copy(d),A.current.up.set(0,0,1),A.current.updateMatrixWorld(),g.current?.target.copy(D),g.current?.update(),o.current=null)}),null},pOt=()=>{const{controlsRef:g}=iJ(),A=X.useRef(null),I=X.useRef(!1),e=X.useRef(null),t=X.useCallback(B=>{A.current=B,!I.current&&g.current&&KAg(B,g.current)&&(I.current=!0)},[g]),o=X.useCallback(()=>{if(!(!A.current||!g.current)){if(!I.current&&KAg(A.current,g.current)){I.current=!0;return}clearTimeout(e.current),e.current=setTimeout(()=>{A.current&&g.current&&QmI(A.current,g.current)},150)}},[g]);return{handleCameraCreated:t,handleControlsChange:o}};function kOt(g){g.querySelectorAll("canvas").forEach(A=>A.remove())}var MOt=g=>{g.outputColorSpace=Ck,g.toneMapping=KeI,g.toneMappingExposure=1,g.shadowMap.enabled=!0,g.shadowMap.type=FeI},SOt=X.forwardRef(({children:g,scene:A,camera:I,style:e,onCreated:t},o)=>{const{cameraType:B}=iJ(),C=X.useRef(null),[Q,i]=X.useState(null),E=X.useRef([]),n=X.useRef(void 0);n.current=t;const s=X.useRef(null),r=X.useCallback(l=>{E.current.push(l)},[]),a=X.useCallback(l=>{E.current=E.current.filter(D=>D!==l)},[]),c=X.useMemo(()=>new O_,[]);A?.up&&c.up.set(A.up.x,A.up.y,A.up.z);const h=X.useRef(new bs);return X.useImperativeHandle(o,()=>h.current),X.useEffect(()=>{if(!C.current)return;kOt(C.current);const l=new DDA({antialias:!0,alpha:!0});MOt(l),l.setSize(C.current.clientWidth,C.current.clientHeight),l.setPixelRatio(window.devicePixelRatio),C.current.appendChild(l.domElement);const D=C.current.clientWidth/C.current.clientHeight,d=B==="perspective"?new fl(75,D,.1,1e3):new RT(-10*D,10*D,10,-10,-1e3,1e3);s.current?(d.position.copy(s.current.position),d.quaternion.copy(s.current.quaternion),d.up.copy(s.current.up)):(I?.up&&d.up.set(I.up[0],I.up[1],I.up[2]),I?.position&&d.position.set(I.position[0],I.position[1],I.position[2]),d.lookAt(0,0,0)),c.add(h.current),window.__TSCIRCUIT_THREE_OBJECT=h.current,i({scene:c,camera:d,renderer:l,rootObject:h.current,addFrameListener:r,removeFrameListener:a}),n.current?.({camera:d,renderer:l});let y;const w=new CSt;let u=!0;const G=new IntersectionObserver(([k])=>{u=k?.isIntersecting??!1,u&&p()});G.observe(C.current);const m=()=>{if(y=requestAnimationFrame(m),!u)return;const k=w.getElapsedTime(),S=w.getDelta();E.current.forEach(R=>R(k,S)),l.render(c,d)};m();const p=()=>{if(C.current?.clientWidth&&C.current.clientHeight){const k=C.current.clientWidth/C.current.clientHeight;d instanceof fl?d.aspect=k:d instanceof RT&&(d.left=-10*k,d.right=10*k,d.top=10,d.bottom=-10),d.updateProjectionMatrix(),l.setSize(C.current.clientWidth,C.current.clientHeight)}};return window.addEventListener("resize",p),()=>{s.current={position:d.position.clone(),quaternion:d.quaternion.clone(),up:d.up.clone()},window.removeEventListener("resize",p),cancelAnimationFrame(y),G.disconnect(),C.current&&l.domElement&&C.current.removeChild(l.domElement),l.dispose(),c.remove(h.current),window.__TSCIRCUIT_THREE_OBJECT===h.current&&(window.__TSCIRCUIT_THREE_OBJECT=void 0)}},[c,r,a,B]),q.jsx("div",{ref:C,style:{width:"100%",height:"100%",...e},children:Q&&q.jsx(kAg.Provider,{value:Q,children:q.jsx(UZt,{children:g})})})}),fOt=`
|
|
5323
|
+
`).replace(/^d\s+0\./gm,"d 1."),r=i.replace(/newmtl[\s\S]*?endmtl/g,"").replace(/^mtllib.*/gm,""),a=new q3t;a.setMaterialOptions({invertTrProperty:!0});const c=a.parse(s,"embedded.mtl");return n.setMaterials(c),n.parse(r)}return n.parse(i.replace(/^mtllib.*/gm,""))}catch(Q){return Q}}function C(){if(t.has(e)){const i=t.get(e);return i.result?Promise.resolve(i.result.clone()):i.promise.then(E=>E instanceof Error?E:E.clone())}const Q=B().then(i=>(i instanceof Error||t.set(e,{...t.get(e),result:i}),i));return t.set(e,{promise:Q,result:null}),Q}return C().then(Q=>{o||I(Q)}).catch(Q=>{console.error(Q)}),()=>{o=!0}},[g]),A}function WZt({url:g,position:A,rotation:I,modelOffset:e=[0,0,0],modelRotation:t=[0,0,0],sourceCoordinateTransform:o,modelSize:B,modelFitMode:C="contain_within_bounds",onHover:Q,onUnhover:i,isHovered:E,scale:n,isTranslucent:s=!1}){const r=OZt(g),a=X.useMemo(()=>{if(r&&!(r instanceof Error))return r.traverse(l=>{if(l instanceof Ko&&l.material){const D=d=>{d.transparent=s,d.opacity=s?.5:1,d.depthWrite=!s,d.needsUpdate=!0};Array.isArray(l.material)?l.material.forEach(D):D(l.material),l.renderOrder=s?2:1}}),AS(r,{castShadow:!s,receiveShadow:!0}),r;const h=new Ko(new ik(.5,.5,.5),new Hs({transparent:!0,color:"red",opacity:.25}));return AS(h,{castShadow:!1,receiveShadow:!0}),h},[r,s]),{boardTransformGroup:c}=NAg({model:a,position:Array.isArray(A)?A:A?[A.x,A.y,A.z]:void 0,rotation:Array.isArray(I)?I:I?[I.x,I.y,I.z]:void 0,modelOffset:e,modelRotation:t,sourceCoordinateTransform:o,modelSize:B,modelFitMode:C,scale:n});if(r instanceof Error)throw r;return q.jsx(yIA,{isHovered:E,onHover:Q,onUnhover:i,object:c})}var VZt=new oo(.82,.82,.82),AmI=g=>new Hs({color:g?new oo(g[0],g[1],g[2]):VZt});function jZt(g,A){const I=AmI(A.color),e=A.brep_faces??[];if(e.length===0)return[I];const t=e.length>1?[...e].sort((n,s)=>n.first-s.first):e,o=[I],B=new Map,C=A.index.array.length/3;let Q=0,i=0;const E=n=>{if(!n)return 0;const s=n.join(","),r=B.get(s);if(r!==void 0)return r;const a=o.length;return o.push(AmI(n)),B.set(s,a),a};for(;Q<C;){const n=t[i];let s=C,r=0;n&&(Q<n.first?s=n.first:(s=n.last+1,r=E(n.color),i+=1)),s>Q&&g.addGroup(Q*3,(s-Q)*3,r),Q=s}return o}function zZt(g){const A=new Yc;for(const I of g){const e=I.attributes.position?.array??[],t=I.index?.array??[];if(!e.length||!t.length)continue;const o=new Yn;o.setAttribute("position",new ZB(e,3));const B=I.attributes.normal?.array??[];B.length?o.setAttribute("normal",new ZB(B,3)):o.computeVertexNormals(),o.setIndex(t),o.clearGroups();const C=jZt(o,I),Q=new Ko(o,C.length>1?C:C[0]);Q.name=I.name,A.add(Q)}return A}var xAg,XZt="https://cdn.jsdelivr.net/npm/occt-import-js@0.0.23/dist";function $Zt(g){if(typeof g=="function")return g;if(g&&typeof g=="object"&&"default"in g&&typeof g.default=="function")return g.default;throw new Error("Unable to resolve occt-import-js factory export")}async function AOt(){if(!xAg){const g=await import("https://cdn.jsdelivr.net/npm/occt-import-js@0.0.23/+esm");xAg=$Zt(g)({locateFile:I=>`${XZt}/${I}`})}return xAg}async function gOt(g){const A=await fetch(g);if(!A.ok)throw new Error(`Failed to fetch STEP file: ${A.statusText}`);const I=await A.arrayBuffer(),t=(await AOt()).ReadStepFile(new Uint8Array(I),null);if(!t.success||!t.meshes.length)throw new Error("occt-import-js failed to convert STEP file");const o=zZt(t.meshes),B=new ZXA;return await new Promise((Q,i)=>{B.parse(o,E=>{E instanceof ArrayBuffer?Q(E):i(new Error("GLTFExporter did not return binary output"))},E=>{i(E)},{binary:!0})})}var gmI="step-glb-cache:v2:";function IOt(g){const A=new Uint8Array(g),I=32768;let e="";for(let t=0;t<A.length;t+=I){const o=A.subarray(t,t+I);e+=String.fromCharCode(...o)}return btoa(e)}function eOt(g){const A=atob(g),I=new Uint8Array(A.length);for(let e=0;e<A.length;e+=1)I[e]=A.charCodeAt(e);return I.buffer}function tOt(g){try{const A=localStorage.getItem(`${gmI}${g}`);return A?eOt(A):null}catch(A){return console.warn("Failed to read STEP GLB cache",A),null}}function ImI(g,A){try{const I=IOt(A);localStorage.setItem(`${gmI}${g}`,I)}catch(I){console.warn("Failed to write STEP GLB cache",I)}}function oOt(){const g=globalThis;return g.stepUrlToGltfModelConversions||(g.stepUrlToGltfModelConversions={inProgress:new Map,completed:new Map}),g.stepUrlToGltfModelConversions}var BOt=({stepUrl:g,position:A,rotation:I,modelOffset:e,modelRotation:t,sourceCoordinateTransform:o,modelSize:B,modelFitMode:C,scale:Q,onHover:i,onUnhover:E,isHovered:n,isTranslucent:s})=>{const[r,a]=X.useState(null);return X.useEffect(()=>{let c=!0,h=null,l=!0;const D=oOt(),d=tOt(g);if(d){const u={arrayBuffer:d,blobUrl:URL.createObjectURL(new Blob([d],{type:"model/gltf-binary"}))};return D.completed.set(g,u),h=u.blobUrl,l=!1,a(u.blobUrl),()=>{c=!1,h&&l&&URL.revokeObjectURL(h)}}const y=D.completed.get(g);if(y)return h=y.blobUrl,l=!1,a(y.blobUrl),ImI(g,y.arrayBuffer),()=>{c=!1,h&&l&&URL.revokeObjectURL(h)};let w=D.inProgress.get(g);return w||(w=gOt(g).then(u=>{const G={arrayBuffer:u,blobUrl:URL.createObjectURL(new Blob([u],{type:"model/gltf-binary"}))};return D.completed.set(g,G),D.inProgress.delete(g),G}).catch(u=>{throw D.inProgress.delete(g),u}),D.inProgress.set(g,w)),w.then(u=>{c&&(h=u.blobUrl,l=!1,a(u.blobUrl),ImI(g,u.arrayBuffer))}).catch(u=>{console.error("Failed to convert STEP file to GLB",u),c&&a(null)}),()=>{c=!1,h&&l&&URL.revokeObjectURL(h)}},[g]),r?q.jsx($GI,{gltfUrl:r,position:A,rotation:I,modelOffset:e,modelRotation:t,sourceCoordinateTransform:o,modelSize:B,modelFitMode:C,scale:Q,onHover:i,onUnhover:E,isHovered:n,isTranslucent:s}):null};function ryA(g,A){let{x:I,y:e,z:t}=g;if(A.axisMapping){const o={x:I,y:e,z:t};A.axisMapping.x&&(I=FAg(o,A.axisMapping.x)),A.axisMapping.y&&(e=FAg(o,A.axisMapping.y)),A.axisMapping.z&&(t=FAg(o,A.axisMapping.z))}if(I*=A.flipX??1,e*=A.flipY??1,t*=A.flipZ??1,A.rotation){if(A.rotation.x){const o=A.rotation.x*Math.PI/180,B=Math.cos(o),C=Math.sin(o),Q=e*B-t*C,i=e*C+t*B;e=Q,t=i}if(A.rotation.y){const o=A.rotation.y*Math.PI/180,B=Math.cos(o),C=Math.sin(o),Q=I*B+t*C,i=-I*C+t*B;I=Q,t=i}if(A.rotation.z){const o=A.rotation.z*Math.PI/180,B=Math.cos(o),C=Math.sin(o),Q=I*B-e*C,i=I*C+e*B;I=Q,e=i}}return{x:I,y:e,z:t}}function FAg(g,A){switch(A){case"x":return g.x;case"y":return g.y;case"z":return g.z;case"-x":return-g.x;case"-y":return-g.y;case"-z":return-g.z;default:return 0}}var UAg={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 COt(g,A){if(A.coordinateTransform)return A.coordinateTransform;if(!A.usingGlbCoordinates){if(A.hasFootprinterModel)return UAg.FOOTPRINTER_MODEL_TRANSFORM;if(!A.usingObjFormat)return A.usingStepFormat?UAg.STEP_INVERTED:UAg.Z_UP_TO_Y_UP_USB_FIX}}function wIA(g,A){return COt(g,{usingGlbCoordinates:A==="gltf"||A==="glb"||A==="jscad",usingObjFormat:A==="obj"||A==="wrl",usingStepFormat:A==="step",hasFootprinterModel:A==="footprinter"})}function cyA(g){if(!g)return;const A=ryA({x:1,y:0,z:0},g),I=ryA({x:0,y:1,z:0},g),e=ryA({x:0,y:0,z:1},g);return new aQ().makeBasis(new BI(A.x,A.y,A.z),new BI(I.x,I.y,I.z),new BI(e.x,e.y,e.z))}function h3(g){return g*Math.PI/180}function QOt(g){if(g==="z+")return[0,0,0];switch(g){case"x+":return[0,h3(-90),0];case"x-":return[0,h3(90),0];case"y+":return[h3(90),0,0];case"y-":return[h3(-90),0,0];case"z-":return[h3(180),0,0];default:return[0,0,0]}}function iOt(g,A,I){if(!g.position)return;let e=g.position.z;return!g.is_on_folded_board&&g.pcb_component_id&&A==="bottom"&&g.position.z>=0&&(e=-(g.position.z+I)),[g.position.x,g.position.y,e]}function EOt(g,A){return g.rotation?[h3(g.rotation.x),h3(g.rotation.y),h3(g.rotation.z)]:A==="bottom"?[Math.PI,0,0]:[0,0,0]}function nOt(g,A){const I=new BI(g.x,g.y,g.z),e=new km(A[0],A[1],A[2],"XYZ");return I.applyEuler(e),[I.x,I.y,I.z]}function sOt(g,A,I){if(!g.model_origin_position)return[0,0,0];const e=A?ryA(g.model_origin_position,A):g.model_origin_position;return nOt(e,I)}function aOt(g,A){const I=iOt(g,A.layer,A.pcbThickness),e=EOt(g,A.layer),t=wIA(g,A.modelType),o=QOt(g.model_board_normal_direction??"z+"),B=sOt(g,t,o);return{position:I,rotation:e,modelPosition:[-B[0],-B[1],-B[2]],modelRotation:o,scale:g.model_unit_to_mm_scale_factor??void 0,fitMode:g.model_object_fit??"contain_within_bounds",size:g.size?[g.size.x,g.size.y,g.size.z]:void 0}}var rOt=g=>g.model_glb_url||g.model_gltf_url?g.model_glb_url?"glb":"gltf":g.model_obj_url||g.model_wrl_url||g.model_stl_url?g.model_wrl_url?"wrl":g.model_stl_url?"stl":"obj":g.model_jscad?"jscad":g.footprinter_string?"footprinter":g.model_step_url?"step":"unknown",cOt=g=>g==="step"?"glb":g,hOt=(g,A)=>{if(!g.pcb_component_id||!g.model_jscad||g.model_origin_alignment!=="bottom_center_of_component")return!1;const I=A.find(e=>e.type==="pcb_component"&&e.pcb_component_id===g.pcb_component_id);return!!(I&&I.do_not_place&&I.is_allowed_to_be_off_board&&I.obstructs_within_bounds===!1)},lOt=(g,A)=>{if(g)return A?A(g):g},DOt=(...g)=>g,JAg=class extends sC.Component{constructor(g){super(g),this.state={hasError:!1,error:null}}static getDerivedStateFromError(g){return{hasError:!0,error:g}}render(){return this.state.hasError&&this.state.error?this.props.fallback({error:this.state.error}):this.props.children}},dOt=({error:g,onError:A})=>(X.useEffect(()=>{A(g)},[g,A]),null),emI=({cad_component:g,circuitJson:A,resolveStaticAsset:I})=>{const e=WGI(A),[t,o]=X.useState(!1),{visibility:B}=h5(),[C,Q]=X.useState(null),i=X.useCallback(b=>{b?.mousePosition?(o(!0),Q(b.mousePosition)):(o(!1),Q(null))},[]),E=X.useCallback(()=>{o(!1),Q(null)},[]),n=X.useMemo(()=>Xo(A).source_component.getUsing({source_component_id:g.source_component_id})?.name,[A,g.source_component_id]),{pcbComponent:s,layer:r,isThroughHole:a}=X.useMemo(()=>fZt(g,A),[g,A]),c=X.useCallback(b=>lOt(b,I),[I]),h=c(g.model_wrl_url??g.model_stl_url??g.model_obj_url),l=c(g.model_glb_url??g.model_gltf_url),D=c(g.model_step_url),[d,y]=X.useState(0),[w,u]=X.useState(null);X.useEffect(()=>{y(0),u(null)},[g.cad_component_id,h,l,D]);const G=X.useMemo(()=>hOt(g,A),[g,A]),m=G?B.enclosure==="translucent":!!g.show_as_translucent_model,p=rOt(g),k=cOt(p),S=g.model_glb_url?"glb":"gltf",R=g.model_wrl_url?"wrl":g.model_stl_url?"stl":"obj",x=X.useMemo(()=>aOt(g,{layer:r,pcbThickness:e,modelType:k}),[g,r,e,k]),N=DOt(...x.rotation),J=x.position,K=X.useMemo(()=>{const b=[];return l&&b.push(q.jsx($GI,{gltfUrl:l,position:J,rotation:N,modelOffset:x.modelPosition,modelRotation:x.modelRotation,sourceCoordinateTransform:cyA(wIA(g,S)),scale:x.scale,modelSize:x.size,modelFitMode:x.fitMode,onHover:i,onUnhover:E,isHovered:t,isTranslucent:m},`${g.cad_component_id}-gltf-${l}`)),h&&b.push(q.jsx(WZt,{url:h,position:J,rotation:N,modelOffset:x.modelPosition,modelRotation:x.modelRotation,sourceCoordinateTransform:cyA(wIA(g,R)),scale:x.scale,modelSize:x.size,modelFitMode:x.fitMode,onHover:i,onUnhover:E,isHovered:t,isTranslucent:m},`${g.cad_component_id}-mixed-${h}`)),D&&!g.model_jscad&&!g.footprinter_string&&b.push(q.jsx(BOt,{stepUrl:D,position:J,rotation:N,modelOffset:x.modelPosition,modelRotation:x.modelRotation,sourceCoordinateTransform:cyA(wIA(g,k)),scale:x.scale,modelSize:x.size,modelFitMode:x.fitMode,onHover:i,onUnhover:E,isHovered:t,isTranslucent:m},`${g.cad_component_id}-step-${D}`)),b},[J,g.cad_component_id,g.footprinter_string,g.model_jscad,m,l,S,i,E,t,R,x.modelPosition,x.modelRotation,x.scale,x.fitMode,x.size,k,N,D,h]);let _=null;if(K.length>0){if(d>=K.length){if(w)throw w;return null}_=q.jsx(JAg,{fallback:({error:b})=>q.jsx(dOt,{error:b,onError:T=>{u(T),y(j=>Math.max(j,d+1))}}),children:K[d]},`${g.cad_component_id}-fallback-${d}`)}else g.model_jscad?_=q.jsx(qZt,{jscadPlan:g.model_jscad,positionOffset:J,rotationOffset:N,modelOffset:x.modelPosition,modelRotation:x.modelRotation,sourceCoordinateTransform:cyA(wIA(g,"jscad")),scale:x.scale,modelSize:x.size,modelFitMode:x.fitMode,onHover:i,onUnhover:E,isHovered:t,isTranslucent:m},g.cad_component_id):g.footprinter_string&&(_=q.jsx(PZt,{positionOffset:J,rotationOffset:N,footprint:g.footprinter_string,scale:x.scale,onHover:i,onUnhover:E,isHovered:t,isTranslucent:m}));if(G){if(B.enclosure==="hidden")return null}else if(g.show_as_translucent_model){if(!B.translucentModels)return null}else if(s&&(a&&!B.throughHoleModels||!a&&!B.smtModels))return null;return q.jsxs(q.Fragment,{children:[q.jsx(pZt,{cadComponent:g,children:_}),t&&C?q.jsx(VGI,{position:C,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:n??"<unknown>"}):null]})},tmI={version:"0.0.622"},omI="cadViewerLightingEnabled",yOt=()=>typeof window>"u"?!0:window.localStorage.getItem(omI)!=="false",BmI=X.createContext(void 0),wOt=({children:g})=>{const[A,I]=X.useState(!1),[e,t]=X.useState(!1),[o,B]=X.useState(yOt);X.useEffect(()=>{window.localStorage.setItem(omI,o?"true":"false")},[o]);const C=X.useMemo(()=>({darkBackgroundEnabled:A,setDarkBackgroundEnabled:I,gridEnabled:e,setGridEnabled:t,lightingEnabled:o,setLightingEnabled:B}),[A,e,o]);return q.jsx(BmI.Provider,{value:C,children:g})},PAg=()=>{const g=X.useContext(BmI);if(!g)throw new Error("useAppearance must be used within an AppearanceProvider");return g},CmI="cadViewerCameraStateSession",QmI=(g,A)=>{try{const I={position:g.position.toArray(),quaternion:g.quaternion.toArray(),up:g.up.toArray(),fov:g.fov??50,target:A.target.toArray()};sessionStorage.setItem(CmI,JSON.stringify(I))}catch(I){console.warn("Failed to save camera:",I)}},KAg=(g,A)=>{try{const I=sessionStorage.getItem(CmI);if(!I)return!1;const e=JSON.parse(I);if(g.position.fromArray(e.position),g.quaternion.fromArray(e.quaternion),g.up.fromArray(e.up),"fov"in g){const t=g;t.fov=e.fov,t.updateProjectionMatrix?.()}return A.target.fromArray(e.target),A.update(),g.updateMatrixWorld(),!0}catch(I){return console.warn("Failed to restore camera:",I),!1}},imI=X.createContext(void 0),uOt=({children:g,defaultTarget:A,initialCameraPosition:I,initialCameraType:e})=>{const t=X.useRef(null),o=X.useRef(null),[B,C]=X.useState(null),[Q,i]=X.useState(e??"perspective"),[E,n]=X.useState(I??null),[s,r]=X.useState(new km(0,0,0)),a=X.useMemo(()=>{const[D,d,y]=I??[5,-5,5],w=Math.hypot(D-A.x,d-A.y,y-A.z);return w>0?w:5},[I,A]),c=X.useCallback(D=>{const d=[A.x,A.y,A.z],y=o.current,w=t.current;let u=a;switch(y&&w&&(u=y.position.distanceTo(w.target)),D){case"Top Center Angled":{const G=u/Math.sqrt(2);return{position:[A.x,A.y-G,A.z+G],target:d,up:[0,0,1]}}case"Top Down":return{position:[A.x,A.y,A.z+u],target:d,up:[0,0,1]};case"Top Left Corner":return{position:[A.x-u*.6,A.y-u*.6,A.z+u*.6],target:d,up:[0,0,1]};case"Top Right Corner":return{position:[A.x+u*.6,A.y-u*.6,A.z+u*.6],target:d,up:[0,0,1]};case"Left Sideview":return{position:[A.x-u,A.y,A.z],target:d,up:[0,0,1]};case"Right Sideview":return{position:[A.x+u,A.y,A.z],target:d,up:[0,0,1]};case"Front":return{position:[A.x,A.y-u,A.z],target:d,up:[0,0,1]};default:return null}},[a,A,o,t]),h=X.useCallback(D=>{t.current=D},[]),l=X.useMemo(()=>({controlsRef:t,mainCameraRef:o,defaultTarget:A,baseDistance:a,controller:B,setController:C,getPresetConfig:c,handleControlsChange:h,cameraType:Q,setCameraType:i,cameraPosition:E,setCameraPosition:n,cameraRotation:s,setCameraRotation:r,saveCameraToSession:QmI,loadCameraFromSession:KAg}),[A,a,B,c,h,Q,E,s]);return q.jsx(imI.Provider,{value:l,children:g})},iJ=()=>{const g=X.useContext(imI);if(!g)throw new Error("useCameraController must be used within a CameraControllerProvider");return g},GOt=g=>g<.5?4*g*g*g:1-Math.pow(-2*g+2,3)/2,mOt=()=>{const{controlsRef:g,mainCameraRef:A,defaultTarget:I,setController:e,getPresetConfig:t}=iJ(),o=X.useRef(null),B=X.useRef(new mm),C=X.useRef(new BI),Q=X.useRef(new BI),i=X.useRef(new mm),E=X.useRef(new mm),n=X.useRef(new bs),s=X.useRef(new bs),r=X.useCallback(({position:c,target:h,up:l,durationMs:D=600})=>{if(!A.current)return;const d=g.current?.target??I,y=new BI(c[0],c[1],c[2]),w=h?new BI(h[0],h[1],h[2]):I.clone(),u=new BI(...l??[0,0,1]).normalize(),G=s.current;G.position.copy(y),G.up.copy(u),G.lookAt(w);const m=G.quaternion.clone(),p=A.current.quaternion.clone(),k=A.current.position.clone(),S=d.clone(),R=n.current;R.up.set(0,0,1),R.position.copy(k),R.lookAt(S);const x=R.quaternion.clone();R.up.set(0,0,1),R.position.copy(y),R.lookAt(w);const N=R.quaternion.clone(),J=x.clone().invert().multiply(p).normalize(),K=N.clone().invert().multiply(m).normalize();o.current={fromPosition:k,toPosition:y,fromTarget:S,toTarget:w,toQuaternion:m,rollFrom:J,rollTo:K,startTime:performance.now(),duration:D}},[A,g,I]),a=X.useCallback(c=>{if(c==="Custom")return;const h=t(c);h&&r(h)},[r,t]);return X.useEffect(()=>A.current?(e({animateTo:r,animateToPreset:a}),()=>{e(null)}):void 0,[r,a,A,e]),DIA(()=>{if(!A.current||!o.current)return;const{fromPosition:c,toPosition:h,fromTarget:l,toTarget:D,toQuaternion:d,rollFrom:y,rollTo:w,startTime:u,duration:G}=o.current,m=performance.now()-u,p=G<=0?1:Math.min(m/G,1),k=GOt(p);A.current.position.lerpVectors(c,h,k);const S=C.current;S.copy(l).lerp(D,k);const R=n.current;R.up.set(0,0,1),R.position.copy(A.current.position),R.lookAt(S);const x=B.current;x.copy(R.quaternion);const N=i.current;N.copy(y);const J=E.current;J.copy(w),y.dot(w)<0&&(J.x*=-1,J.y*=-1,J.z*=-1,J.w*=-1),J.normalize(),N.slerp(J,k),A.current.quaternion.copy(x).multiply(N).normalize();const K=Q.current;K.set(0,1,0).applyQuaternion(A.current.quaternion).normalize(),A.current.up.copy(K),g.current?.target.copy(S),A.current.updateMatrixWorld(),g.current?.update(),p>=1&&(A.current.position.copy(h),A.current.quaternion.copy(d),A.current.up.set(0,0,1),A.current.updateMatrixWorld(),g.current?.target.copy(D),g.current?.update(),o.current=null)}),null},pOt=()=>{const{controlsRef:g}=iJ(),A=X.useRef(null),I=X.useRef(!1),e=X.useRef(null),t=X.useCallback(B=>{A.current=B,!I.current&&g.current&&KAg(B,g.current)&&(I.current=!0)},[g]),o=X.useCallback(()=>{if(!(!A.current||!g.current)){if(!I.current&&KAg(A.current,g.current)){I.current=!0;return}clearTimeout(e.current),e.current=setTimeout(()=>{A.current&&g.current&&QmI(A.current,g.current)},150)}},[g]);return{handleCameraCreated:t,handleControlsChange:o}};function kOt(g){g.querySelectorAll("canvas").forEach(A=>A.remove())}var MOt=g=>{g.outputColorSpace=Ck,g.toneMapping=KeI,g.toneMappingExposure=1,g.shadowMap.enabled=!0,g.shadowMap.type=FeI},SOt=X.forwardRef(({children:g,scene:A,camera:I,style:e,onCreated:t},o)=>{const{cameraType:B}=iJ(),C=X.useRef(null),[Q,i]=X.useState(null),E=X.useRef([]),n=X.useRef(void 0);n.current=t;const s=X.useRef(null),r=X.useCallback(l=>{E.current.push(l)},[]),a=X.useCallback(l=>{E.current=E.current.filter(D=>D!==l)},[]),c=X.useMemo(()=>new O_,[]);A?.up&&c.up.set(A.up.x,A.up.y,A.up.z);const h=X.useRef(new bs);return X.useImperativeHandle(o,()=>h.current),X.useEffect(()=>{if(!C.current)return;kOt(C.current);const l=new DDA({antialias:!0,alpha:!0});MOt(l),l.setSize(C.current.clientWidth,C.current.clientHeight),l.setPixelRatio(window.devicePixelRatio),C.current.appendChild(l.domElement);const D=C.current.clientWidth/C.current.clientHeight,d=B==="perspective"?new fl(75,D,.1,1e3):new RT(-10*D,10*D,10,-10,-1e3,1e3);s.current?(d.position.copy(s.current.position),d.quaternion.copy(s.current.quaternion),d.up.copy(s.current.up)):(I?.up&&d.up.set(I.up[0],I.up[1],I.up[2]),I?.position&&d.position.set(I.position[0],I.position[1],I.position[2]),d.lookAt(0,0,0)),c.add(h.current),window.__TSCIRCUIT_THREE_OBJECT=h.current,i({scene:c,camera:d,renderer:l,rootObject:h.current,addFrameListener:r,removeFrameListener:a}),n.current?.({camera:d,renderer:l});let y;const w=new CSt;let u=!0;const G=new IntersectionObserver(([k])=>{u=k?.isIntersecting??!1,u&&p()});G.observe(C.current);const m=()=>{if(y=requestAnimationFrame(m),!u)return;const k=w.getElapsedTime(),S=w.getDelta();E.current.forEach(R=>R(k,S)),l.render(c,d)};m();const p=()=>{if(C.current?.clientWidth&&C.current.clientHeight){const k=C.current.clientWidth/C.current.clientHeight;d instanceof fl?d.aspect=k:d instanceof RT&&(d.left=-10*k,d.right=10*k,d.top=10,d.bottom=-10),d.updateProjectionMatrix(),l.setSize(C.current.clientWidth,C.current.clientHeight)}};return window.addEventListener("resize",p),()=>{s.current={position:d.position.clone(),quaternion:d.quaternion.clone(),up:d.up.clone()},window.removeEventListener("resize",p),cancelAnimationFrame(y),G.disconnect(),C.current&&l.domElement&&C.current.removeChild(l.domElement),l.dispose(),c.remove(h.current),window.__TSCIRCUIT_THREE_OBJECT===h.current&&(window.__TSCIRCUIT_THREE_OBJECT=void 0)}},[c,r,a,B]),q.jsx("div",{ref:C,style:{width:"100%",height:"100%",...e},children:Q&&q.jsx(kAg.Provider,{value:Q,children:q.jsx(UZt,{children:g})})})}),fOt=`
|
|
5324
5324
|
varying vec3 worldPosition;
|
|
5325
5325
|
void main() {
|
|
5326
5326
|
worldPosition = (modelMatrix * vec4(position, 1.0)).xyz;
|
|
@@ -5674,7 +5674,7 @@ test("${i} should solve problem correctly", () => {
|
|
|
5674
5674
|
// Add more specific assertions based on expected output
|
|
5675
5675
|
// expect(solver.netLabelPlacementSolver!.netLabelPlacements).toMatchInlineSnapshot()
|
|
5676
5676
|
})
|
|
5677
|
-
`,n=new Blob([E],{type:"text/plain"}),s=URL.createObjectURL(n),r=document.createElement("a");r.href=s,r.download=`${i}.test.ts`,r.click(),URL.revokeObjectURL(s)}catch(Q){alert(`Error generating test.ts for ${g.getSolverName()}: ${Q instanceof Error?Q.message:String(Q)}`)}e(!1)};return q.jsxs("div",{className:`relative ${A}`,ref:t,children:[q.jsx("button",{className:"px-2 py-1 rounded text-xs cursor-pointer",onClick:()=>e(!I),title:`Download options for ${g.getSolverName()}`,children:g.getSolverName()}),I&&q.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:[q.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:o,children:"Download JSON"}),q.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:B,children:"Download page.tsx"}),q.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:C,children:"Download test.ts"})]})]})},rxI=g=>g.activeSubSolver?[g,...rxI(g.activeSubSolver)]:[g],pDo=({solver:g})=>{const A=rxI(g);return q.jsx("div",{className:"flex gap-1 items-center text-sm pt-1",children:A.map((I,e)=>q.jsxs("div",{className:"flex items-center",children:[e>0&&q.jsx("span",{className:"text-gray-400 mx-1",children:"→"}),q.jsx(mDo,{solver:I})]},I.getSolverName()))})},kDo=({solver:g,triggerRender:A,animationSpeed:I=25,renderer:e,onRendererChange:t,onAnimationSpeedChange:o,onDownloadVisualization:B,onSolverStarted:C,onSolverCompleted:Q})=>{const[i,E]=X.useReducer(m=>!m,!1),n=X.useRef(void 0),s=X.useRef(null),r="solver-debugger-last-iteration",[a,c]=X.useState(null),h=X.useRef(null),l=X.useMemo(()=>[{label:"Slow",value:250,description:"250ms"},{label:"Normal",value:100,description:"100ms"},{label:"Fast",value:10,description:"10ms"},{label:"Fast (2x)",value:5,description:"5ms"},{label:"Fast (10x)",value:1,description:"1ms"},{label:"Fast 20x",value:.5,description:"2 steps / 1ms"},{label:"Fast 100x",value:.1,description:"10 steps / 1ms"}],[]),D=()=>{const m=Math.max(1,I),p=I<1?Math.round(1/I):1;n.current=setInterval(()=>{if(g.solved||g.failed){n.current&&(clearInterval(n.current),n.current=void 0),E(),A(),Q&&g.solved&&Q(g);return}for(let k=0;k<p&&!(g.solved||g.failed);k++)g.step();A()},m)},d=()=>{n.current&&(clearInterval(n.current),n.current=void 0)},y=()=>{!g.solved&&!g.failed&&(g.step(),A())},w=()=>{!g.solved&&!g.failed&&(C&&C(g),g.solve(),A(),Q&&Q(g))},u=()=>{i?(d(),E()):(E(),D())},G=()=>{if(g.solved||g.failed||i)return;s.current===null&&typeof window<"u"&&(s.current=window.localStorage.getItem(r));const m=window.prompt("Step until which iteration?",s.current??`${g.iterations}`);if(m===null)return;s.current=m,typeof window<"u"&&window.localStorage.setItem(r,m);const p=Number(m);if(!Number.isFinite(p)){window.alert("Please enter a valid number for the iteration");return}for(;g.iterations<p&&!g.solved&&!g.failed;)g.step();A(),g.solved&&Q&&Q(g)};return X.useEffect(()=>()=>{d()},[]),X.useEffect(()=>{(g.solved||g.failed)&&i&&(d(),E())},[g.solved,g.failed,i]),X.useEffect(()=>{i&&(d(),D())},[I,i]),X.useEffect(()=>{if(typeof document>"u")return;const m=p=>{h.current&&!h.current.contains(p.target)&&c(null)};return document.addEventListener("mousedown",m),()=>{document.removeEventListener("mousedown",m)}},[]),q.jsxs("div",{className:"space-y-2 p-2 border-b",children:[q.jsx("div",{className:"flex items-center",children:q.jsxs("div",{className:"flex items-center gap-2",ref:h,children:[q.jsxs("div",{className:"flex h-9 items-center space-x-1 rounded-md border border-slate-200 bg-white p-1 shadow-sm",children:[q.jsxs("div",{className:"relative",children:[q.jsx("button",{type:"button",onClick:()=>c(a==="renderer"?null:"renderer"),className:"flex select-none items-center rounded-sm px-3 py-1 text-sm font-medium outline-none focus:bg-slate-100 data-[state=open]:bg-slate-100","data-state":a==="renderer"?"open":"closed",children:"Renderer"}),a==="renderer"&&q.jsx("div",{className:"absolute left-0 z-50 mt-1 min-w-[10rem] rounded-md border border-slate-200 bg-white p-1 text-slate-950 shadow-md",children:["vector","canvas"].map(m=>q.jsxs("button",{type:"button",onClick:()=>{t(m),c(null)},className:"flex w-full items-center rounded-sm px-2 py-1.5 text-sm hover:bg-slate-100",children:[m==="vector"?"Vector":"Canvas",e===m&&q.jsx("span",{className:"ml-auto text-xs text-slate-500",children:"✓"})]},m))})]}),q.jsxs("div",{className:"relative",children:[q.jsx("button",{type:"button",onClick:()=>c(a==="debug"?null:"debug"),className:"flex select-none items-center rounded-sm px-3 py-1 text-sm font-medium outline-none focus:bg-slate-100 data-[state=open]:bg-slate-100","data-state":a==="debug"?"open":"closed",children:"Debug"}),a==="debug"&&q.jsx("div",{className:"absolute left-0 z-50 mt-1 min-w-[12rem] rounded-md border border-slate-200 bg-white p-1 text-slate-950 shadow-md",children:q.jsx("button",{type:"button",onClick:()=>{B(),c(null)},className:"flex w-full items-center rounded-sm px-2 py-1.5 text-sm hover:bg-slate-100",children:"Download Visualization"})})]}),q.jsxs("div",{className:"relative",children:[q.jsx("button",{type:"button",onClick:()=>c(a==="animation"?null:"animation"),className:"flex select-none items-center rounded-sm px-3 py-1 text-sm font-medium outline-none focus:bg-slate-100 data-[state=open]:bg-slate-100","data-state":a==="animation"?"open":"closed",children:"Animation"}),a==="animation"&&q.jsx("div",{className:"absolute left-0 z-50 mt-1 min-w-[12rem] rounded-md border border-slate-200 bg-white p-1 text-slate-950 shadow-md",children:l.map(m=>q.jsxs("button",{type:"button",onClick:()=>{o(m.value),c(null)},className:"flex w-full items-center rounded-sm px-2 py-1.5 text-sm hover:bg-slate-100",children:[m.label,q.jsx("span",{className:"ml-auto text-xs text-slate-500",children:m.description}),I===m.value&&q.jsx("span",{className:"ml-2 text-xs text-slate-500",children:"✓"})]},m.value))})]})]}),q.jsx(pDo,{solver:g})]})}),q.jsxs("div",{className:"flex gap-2 items-center flex-wrap",children:[q.jsx("button",{onClick:y,disabled:g.solved||g.failed||i,className:"bg-blue-500 hover:bg-blue-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Step"}),q.jsx("button",{onClick:w,disabled:g.solved||g.failed||i,className:"bg-green-500 hover:bg-green-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Solve"}),q.jsx("button",{onClick:u,disabled:g.solved||g.failed,className:`px-3 py-1 rounded text-white text-sm ${i?"bg-red-500 hover:bg-red-600":"bg-yellow-500 hover:bg-yellow-600"} disabled:bg-gray-300`,children:i?"Stop":"Animate"}),q.jsx("button",{onClick:G,disabled:g.solved||g.failed||i,className:"bg-orange-500 hover:bg-orange-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Step Until Iteration"}),q.jsxs("div",{className:"text-sm text-gray-600",children:["Iterations: ",g.iterations]}),g.timeToSolve!==void 0&&q.jsxs("div",{className:"text-sm text-gray-600",children:["Time: ",(g.timeToSolve/1e3).toFixed(3),"s"]}),g.solved&&q.jsx("div",{className:"px-2 py-1 bg-green-100 text-green-800 rounded text-sm",children:"Solved"}),g.failed&&q.jsx("div",{className:"px-2 py-1 bg-red-100 text-red-800 rounded text-sm",children:"Failed"})]}),g.error&&q.jsxs("div",{className:"text-red-600 text-sm",children:["Error: ",g.error]})]})},MDo=g=>g!==null&&"pipelineDef"in g&&Array.isArray(g.pipelineDef),SDo=(g,A,I)=>{const e=g.currentPipelineStageIndex;return A<e?"Completed":A===e&&g.activeSubSolver?g.activeSubSolver.failed?"Failed":"In Progress":"Not Started"},fDo=(g,A)=>{const e=g.pipelineDef[A].solverName,t=SDo(g,A),o=g[e],B=g.firstIterationOfStage?.[e]??(A===g.currentPipelineStageIndex?g.iterations:null),C=g.iterations;let Q=0;if(t==="Completed"){const s=g.pipelineDef[A+1],r=s?g.firstIterationOfStage?.[s.solverName]:void 0;r!==void 0&&B!==null?Q=r-B:B!==null&&(Q=C-B)}else t==="In Progress"&&B!==null&&(Q=C-B);const i=g.timeSpentOnStage?.[e]??0;let E=0;t==="Completed"?E=1:t==="In Progress"&&o&&(E=o.progress??0);const n=o?.stats??null;return{index:A,name:e,status:t,firstIteration:B,iterations:Q,progress:E,timeSpent:i,stats:n&&Object.keys(n).length>0?n:null,solverInstance:o??null}},RDo=({status:g})=>{const A={"Not Started":"text-blue-600","In Progress":"text-yellow-600",Completed:"text-green-600",Failed:"text-red-600"};return q.jsx("span",{className:`font-medium ${A[g]}`,children:g})},NDo=({progress:g})=>{if(g===0)return null;const A=Math.round(g*100);return q.jsxs("div",{className:"flex items-center gap-2",children:[q.jsx("div",{className:"w-20 h-2 bg-gray-200 rounded overflow-hidden",children:q.jsx("div",{className:"h-full bg-blue-500 transition-all duration-200",style:{width:`${A}%`}})}),q.jsxs("span",{className:"text-xs text-gray-500",children:[A,"%"]})]})},cxI=g=>{if(typeof g=="string")return g;if(typeof g=="number"||typeof g=="boolean"||typeof g=="bigint"||g==null)return String(g);if(typeof g=="object")try{return JSON.stringify(g)}catch{return String(g)}return String(g)},xDo=g=>Object.entries(g).map(([A,I])=>`${A}: ${cxI(I)}`).join(", "),FDo=({stats:g})=>{if(!g||Object.keys(g).length===0)return q.jsx("span",{children:"-"});const A=Object.entries(g),I=xDo(g);return q.jsxs("details",{className:"cursor-pointer",children:[q.jsx("summary",{className:"whitespace-nowrap overflow-hidden text-ellipsis max-w-[200px]",children:I}),q.jsx("div",{className:"mt-1 text-xs",children:A.map(([e,t])=>q.jsxs("div",{children:[e,": ",cxI(t)]},e))})]})},Wtg=g=>{if(g===null||typeof g!="object")return g;if(Array.isArray(g))return g.map(Wtg);const A={};for(const[I,e]of Object.entries(g))I.startsWith("_")||(A[I]=Wtg(e));return A},UDo=(g,A)=>{try{if(typeof g.getConstructorParams!="function"){alert(`getConstructorParams() is not implemented for ${A}`);return}const I=Wtg(g.getConstructorParams()),e=new Blob([JSON.stringify(I,null,2)],{type:"application/json"}),t=URL.createObjectURL(e),o=document.createElement("a");o.href=t,o.download=`${A}_input.json`,o.click(),URL.revokeObjectURL(t)}catch(I){alert(`Error downloading input for ${A}: ${I instanceof Error?I.message:String(I)}`)}},JDo=({expanded:g})=>q.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:`w-4 h-4 transition-transform duration-200 ${g?"rotate-90":""}`,children:q.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"})}),hxI=g=>{let A=g;for(;A.activeSubSolver;)A=A.activeSubSolver;return A},lxI=({solver:g,onStepUntilPhase:A,onDownloadInput:I,isNested:e=!1,indentLevel:t=0,triggerRender:o})=>{const[B,C]=X.useState(new Set),Q=g.pipelineDef.map((h,l)=>fDo(g,l)),i=h=>{C(l=>{const D=new Set(l);return D.has(h)?D.delete(h):D.add(h),D})},E=h=>{A?.(h)},n=h=>{h.solverInstance&&(I?I(h.solverInstance,h.name):UDo(h.solverInstance,h.name))},s=h=>`${(h/1e3).toFixed(2)}s`,r=()=>{if(!g.solved&&!g.failed){const h=g.activeSubSolver;for(;!g.solved&&!g.failed&&(g.step(),!(g.activeSubSolver&&g.activeSubSolver!==h)););o?.()}},a=()=>{if(!g.solved&&!g.failed){const h=hxI(g);for(;!g.solved&&!g.failed&&(g.step(),hxI(g)===h););o?.()}},c=t*24;return q.jsxs("div",{className:e?"":"border-t border-gray-200",children:[!e&&q.jsxs("div",{className:"px-4 py-2 bg-gray-50 border-b border-gray-200 flex items-center justify-between",children:[q.jsx("h3",{className:"text-sm font-semibold text-gray-700",children:"Pipeline Stages"}),q.jsxs("div",{className:"flex gap-2",children:[q.jsx("button",{onClick:a,disabled:g.solved||g.failed,className:"bg-indigo-500 hover:bg-indigo-600 disabled:bg-gray-300 disabled:cursor-not-allowed cursor-pointer text-white px-3 py-1 rounded text-sm",children:"Next Solver"}),q.jsx("button",{onClick:r,disabled:g.solved||g.failed,className:"bg-purple-500 hover:bg-purple-600 disabled:bg-gray-300 disabled:cursor-not-allowed cursor-pointer text-white px-3 py-1 rounded text-sm",children:"Next Stage"})]})]}),q.jsx("div",{className:"overflow-x-auto",children:q.jsxs("table",{className:"w-full text-sm",children:[!e&&q.jsx("thead",{children:q.jsxs("tr",{className:"bg-gray-50 border-b border-gray-200",children:[q.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Stage"}),q.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Status"}),q.jsxs("th",{className:"px-4 py-2 text-center font-semibold text-gray-700",children:["i",q.jsx("sub",{children:"0"})]}),q.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Iterations"}),q.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Progress"}),q.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Time"}),q.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Stats"}),q.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Input"})]})}),q.jsx("tbody",{children:Q.map(h=>{const l=MDo(h.solverInstance),D=B.has(h.name);return q.jsxs(sC.Fragment,{children:[q.jsxs("tr",{className:`border-b border-gray-100 ${h.status==="In Progress"?"bg-yellow-50":""}`,children:[q.jsx("td",{className:"px-4 py-2",children:q.jsxs("div",{className:"flex items-center gap-2",style:{paddingLeft:c},children:[l?q.jsx("button",{onClick:()=>i(h.name),className:"text-gray-500 hover:text-gray-700",title:D?"Collapse":"Expand",children:q.jsx(JDo,{expanded:D})}):q.jsx("span",{className:"w-4"}),q.jsx("span",{className:"text-gray-400 w-6",children:String(h.index+1).padStart(2,"0")}),q.jsx("button",{onClick:()=>E(h.name),disabled:h.status==="Completed"||g.solved||g.failed,className:"text-blue-500 hover:text-blue-700 disabled:text-gray-300 disabled:cursor-not-allowed",title:`Step until ${h.name} completes`,children:q.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:q.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"})})}),q.jsx("span",{className:"font-medium text-gray-900",children:h.name})]})}),q.jsx("td",{className:"px-4 py-2",children:q.jsx(RDo,{status:h.status})}),q.jsx("td",{className:"px-4 py-2 text-center text-gray-600",children:h.firstIteration!==null?h.firstIteration:""}),q.jsx("td",{className:"px-4 py-2 text-gray-600",children:h.iterations}),q.jsx("td",{className:"px-4 py-2",children:q.jsx(NDo,{progress:h.progress})}),q.jsx("td",{className:"px-4 py-2 text-gray-600",children:s(h.timeSpent)}),q.jsx("td",{className:"px-4 py-2 text-gray-500",children:q.jsx(FDo,{stats:h.stats})}),q.jsx("td",{className:"px-4 py-2",children:h.solverInstance?q.jsxs("button",{onClick:()=>n(h),className:"flex items-center gap-1 text-blue-500 hover:text-blue-700",title:`Download input for ${h.name}`,children:[q.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:q.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"})}),q.jsx("span",{children:"Input"})]}):null})]}),l&&D&&q.jsx("tr",{children:q.jsx("td",{colSpan:8,className:"p-0",children:q.jsx(lxI,{solver:h.solverInstance,onStepUntilPhase:A,onDownloadInput:I,isNested:!0,indentLevel:t+1,triggerRender:o})})})]},h.name)})})]})})]})};function PDo({graphics:g}){const A=g.points??[],I=g.lines??[],e=g.rects??[],t=g.circles??[],o=g.texts??[];let B=Number.POSITIVE_INFINITY,C=Number.POSITIVE_INFINITY,Q=Number.NEGATIVE_INFINITY,i=Number.NEGATIVE_INFINITY;const E=(h,l)=>{typeof h=="number"&&(h<B&&(B=h),h>Q&&(Q=h)),typeof l=="number"&&(l<C&&(C=l),l>i&&(i=l))};for(const h of A)E(h.x,h.y);for(const h of I){const l=h.points??[];for(const D of l)E(D.x,D.y)}for(const h of e){const l=h.x??0,D=h.y??0,d=h.width??0,y=h.height??0;E(l,D),E(l+d,D+y)}for(const h of t){const l=h.x??0,D=h.y??0,d=h.radius??1;E(l-d,D-d),E(l+d,D+d)}for(const h of o)E(h.x,h.y);(!isFinite(B)||!isFinite(C)||!isFinite(Q)||!isFinite(i))&&(B=-20,C=-20,Q=20,i=20);const n=10,s=B-n,r=C-n,a=Math.max(1,Q-B+2*n),c=Math.max(1,i-C+2*n);return q.jsxs("svg",{className:"w-full h-[400px] bg-white",viewBox:`${s} ${r} ${a} ${c}`,role:"img","aria-label":"Graphics fallback",children:[e.map((h,l)=>q.jsx("rect",{x:h.x??0,y:h.y??0,width:h.width??0,height:h.height??0,fill:"none",stroke:h.strokeColor??"black",strokeWidth:h.strokeWidth??1},`rect-${l}`)),I.map((h,l)=>q.jsx("polyline",{fill:"none",stroke:h.strokeColor??"black",strokeWidth:h.strokeWidth??1,points:(h.points??[]).map(D=>`${D.x??0},${D.y??0}`).join(" ")},`line-${l}`)),t.map((h,l)=>q.jsx("circle",{cx:h.x??0,cy:h.y??0,r:h.radius??1.5,fill:h.fillColor??"none",stroke:h.strokeColor??"black",strokeWidth:h.strokeWidth??1},`circle-${l}`)),A.map((h,l)=>q.jsx("circle",{cx:h.x??0,cy:h.y??0,r:h.radius??1.5,fill:h.color??"black"},`point-${l}`)),o.map((h,l)=>q.jsx("text",{x:h.x??0,y:h.y??0,fontSize:h.fontSize??10,fill:h.color??"black",children:h.text??""},`text-${l}`))]})}var KDo=class extends sC.Component{constructor(g){super(g),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(g){console.error("InteractiveGraphics render error:",g)}render(){return this.state.hasError?this.props.fallback:this.props.children}},LDo=({solver:g,createSolver:A,animationSpeed:I=25,onSolverStarted:e,onSolverCompleted:t})=>{const[o,B]=X.useReducer(D=>D+1,0),[C]=X.useState(()=>{if(A)return A();if(!g)throw new Error("GenericSolverDebugger requires solver or createSolver");return g}),[Q,i]=X.useState(()=>typeof window>"u"?"vector":window.localStorage.getItem("solver-utils-renderer")==="canvas"?"canvas":"vector"),[E,n]=X.useState(I),s=X.useMemo(()=>{try{return C.visualize()||{points:[],lines:[],rects:[],circles:[]}}catch(D){return console.error("Visualization error:",D),{points:[],lines:[],rects:[],circles:[]}}},[C,o]),r=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 D=document.createElement("script");D.src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4",document.head.appendChild(D)}},[]),X.useEffect(()=>{n(I)},[I]);const a=C.pipelineDef!==void 0,c=D=>{const d=C;if(!C.solved&&!C.failed){for(;!C.solved&&!C.failed&&d.currentPipelineStageIndex<=d.pipelineDef.findIndex(y=>y.solverName===D);)C.step();B()}},h=()=>{const D=JSON.stringify(s,null,2),d=new Blob([D],{type:"application/json"}),y=URL.createObjectURL(d),w=document.createElement("a");w.download="visualization.json",w.href=y,document.body.appendChild(w),w.click(),document.body.removeChild(w),URL.revokeObjectURL(y)},l=D=>{i(D),typeof window<"u"&&window.localStorage.setItem("solver-utils-renderer",D)};return q.jsxs("div",{children:[q.jsx(kDo,{solver:C,triggerRender:B,animationSpeed:E,renderer:Q,onRendererChange:l,onAnimationSpeedChange:n,onDownloadVisualization:h,onSolverStarted:e,onSolverCompleted:t}),r?q.jsx("div",{className:"p-4 text-gray-500",children:"No Graphics Yet"}):q.jsx(KDo,{fallback:q.jsx(PDo,{graphics:s}),children:Q==="canvas"?q.jsx(GDo,{graphics:s}):q.jsx(yDo,{graphics:s})}),a&&q.jsx(lxI,{solver:C,onStepUntilPhase:c,triggerRender:B})]})};const YDo=()=>{X.useEffect(()=>{const g="tailwind-cdn-script";if(document.getElementById(g)||window.tailwind)return;const A=document.createElement("div");A.className="hidden",document.body.appendChild(A);const I=window.getComputedStyle(A).display==="none";if(document.body.removeChild(A),I)return;const e=document.createElement("script");e.id=g,e.src="https://cdn.tailwindcss.com",document.head.appendChild(e)},[])},_Do=1e3,pk=(g,A)=>{const{fileName:I,mimeType:e="text/plain"}=A,t=g instanceof Blob?g:new Blob([g],{type:e}),o=URL.createObjectURL(t),B=document.createElement("a");B.href=o,B.download=I,B.target="_blank",B.rel="noopener noreferrer",B.style.display="none",document.body.appendChild(B),B.click(),document.body.removeChild(B),setTimeout(()=>{URL.revokeObjectURL(o)},_Do)},Vtg=g=>{let A=g.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(A)&&(A=`_${A}`),A=A.slice(0,200),A||"untitled"},bDo=g=>{const A=g.solverConstructorArgs??[g.solverParams];if(g.solverName!=="AutoroutingPipelineSolver7_MultiGraph"||A.length!==1)return A;const[{input:I,options:e}]=A;return[I,e]},qx="https://github.com/tscircuit/tscircuit-autorouter/issues/new",DxI="https://github.com/tscircuit/copper-pour-solver/issues/new",dxI="https://github.com/tscircuit/calculate-packing/issues/new",HDo="https://github.com/tscircuit/matchpack/issues/new",yxI="https://github.com/tscircuit/schematic-trace-solver/issues/new?template=json-bug-report.yml",vDo={PackSolver2:dxI,LayoutPipelineSolver:HDo,AutoroutingPipelineSolver:qx,AssignableAutoroutingPipeline2:qx,AssignableAutoroutingPipeline3:qx,AutoroutingPipeline1_OriginalUnravel:qx,AutoroutingPipelineSolver3_HgPortPointPathing:qx,AutoroutingPipelineSolver4:qx,AutoroutingPipelineSolver5:qx,AutoroutingPipelineSolver7_MultiGraph:qx,AutoroutingPipelineSolver8:qx,CopperPourPipelineSolver:DxI,SchematicTracePipelineSolver:yxI},qDo=g=>g.toLowerCase().includes("pack")?BfI:g.toLowerCase().includes("rout")?QfI:HCo,wxI=g=>{const A=vDo[g];if(A)return A;const I=g.toLowerCase();return I.includes("autorout")?qx:I.includes("schematic")&&I.includes("trace")?yxI:I.includes("copperpour")?DxI:I.includes("pack")?dxI:null},TDo=g=>`${Vtg(`${g.componentName}-${g.solverName}`)}-solver-input.json`,uxI=g=>{pk(JSON.stringify(g.solverParams,null,2),{fileName:TDo(g),mimeType:"application/json"})},ZDo=({solverEvent:g})=>{const A=wxI(g.solverName);return q.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:[q.jsxs(Ei,{type:"button",variant:"outline",size:"sm",onClick:()=>uxI(g),children:[q.jsx(EeA,{className:"rf-w-4 rf-h-4"}),"Download"]}),A?q.jsx(Ei,{asChild:!0,variant:"outline",size:"sm",children:q.jsxs("a",{href:A,target:"_blank",rel:"noopener noreferrer",children:[q.jsx(TwA,{className:"rf-w-4 rf-h-4"}),"Report"]})}):q.jsxs(Ei,{type:"button",variant:"outline",size:"sm",disabled:!0,title:"No report link configured for this solver",children:[q.jsx(TwA,{className:"rf-w-4 rf-h-4"}),"Report"]})]})},ODo=({solverEvent:g})=>{const A=wxI(g.solverName);return A?q.jsx(Ei,{asChild:!0,variant:"ghost",size:"icon",className:"rf-h-8 rf-w-8",children:q.jsx("a",{href:A,target:"_blank",rel:"noopener noreferrer",title:"Report solver bug","aria-label":"Report solver bug",children:q.jsx(TwA,{className:"rf-w-4 rf-h-4"})})}):q.jsx(Ei,{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:q.jsx(TwA,{className:"rf-w-4 rf-h-4"})})},WDo=({solverEvents:g=[]})=>{const[A,I]=X.useState(null);YDo();const e=X.useMemo(()=>{const C=new Map;for(const Q of g){const i=`${Q.componentName}-${Q.solverName}`;C.set(i,Q)}return C},[g]),t=X.useMemo(()=>Array.from(e.keys()),[e]),o=A?e.get(A):null,B=X.useMemo(()=>{if(!o)return{instance:null,error:null,classFound:!1};const C=v5A[o.solverName];if(!C)return{instance:null,error:`Solver class "${o.solverName}" not found in SOLVERS registry. Available: ${Object.keys(v5A).join(", ")}`,classFound:!1};try{return{instance:new C(...bDo(o)),error:null,classFound:!0}}catch(Q){const i=Q instanceof Error?Q.message:String(Q);return console.error("Failed to reconstruct solver:",Q),{instance:null,error:`Failed to instantiate solver: ${i}`,classFound:!0}}},[o]);return g.length===0?q.jsx("div",{className:"rf-p-4",children:q.jsx("div",{className:"rf-bg-gray-50 rf-rounded-md rf-border rf-border-gray-200",children:q.jsxs("div",{className:"rf-p-4",children:[q.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800 rf-mb-3",children:"No Solvers Detected"}),q.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."})]})})}):q.jsxs("div",{className:"rf-flex rf-h-full rf-overflow-hidden",children:[q.jsxs("div",{className:"rf-w-64 rf-border-r rf-border-gray-200 rf-overflow-y-auto rf-flex-shrink-0",children:[q.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:[t.length," ",t.length===1?"Solver":"Solvers"]}),t.map(C=>{const Q=e.get(C),i=A===C;return q.jsx("div",{className:`rf-px-3 rf-py-2 rf-cursor-pointer rf-border-b rf-border-gray-100 ${i?"rf-bg-blue-50 rf-border-l-2 rf-border-l-blue-500":"hover:rf-bg-gray-50"}`,onClick:()=>I(C),children:(()=>{const E=qDo(Q.solverName);return q.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2",children:[q.jsx(E,{className:"rf-w-4 rf-h-4 rf-text-blue-500 rf-flex-shrink-0"}),q.jsxs("div",{className:"rf-flex-1 rf-min-w-0",children:[q.jsx("div",{className:"rf-text-sm rf-font-medium rf-text-gray-800 rf-truncate",children:Q.componentName}),q.jsx("div",{className:"rf-text-xs rf-text-gray-500 rf-truncate",children:Q.solverName})]})]})})()},C)})]}),q.jsx("div",{className:"rf-flex-1 rf-overflow-hidden",children:o?B.instance?q.jsxs("div",{className:"rf-flex rf-h-full rf-flex-col rf-overflow-y-auto",children:[q.jsx(ZDo,{solverEvent:o}),q.jsx("div",{className:"rf-min-h-0 rf-flex-1",children:q.jsx(CS,{fallback:q.jsx("div",{className:"rf-p-4",children:q.jsxs("div",{className:"rf-bg-red-50 rf-rounded-md rf-border rf-border-red-200 rf-p-4",children:[q.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-red-800 rf-mb-2",children:"Error Loading Solver Debugger"}),q.jsxs("p",{className:"rf-text-sm rf-text-red-600",children:["Failed to render the solver debugger for"," ",o.solverName]})]})}),children:q.jsx(LDo,{solver:B.instance})})})]}):q.jsxs("div",{className:"rf-p-4",children:[q.jsxs("div",{className:"rf-mb-4",children:[q.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800",children:o.solverName}),q.jsxs("p",{className:"rf-text-sm rf-text-gray-500",children:["Component: ",o.componentName]})]}),B.error&&q.jsx("div",{className:`rf-rounded-md rf-border rf-p-4 rf-mb-4 ${B.classFound?"rf-bg-red-50 rf-border-red-200":"rf-bg-yellow-50 rf-border-yellow-200"}`,children:q.jsx("p",{className:`rf-text-sm ${B.classFound?"rf-text-red-700":"rf-text-yellow-700"}`,children:B.error})}),q.jsxs("div",{className:"rf-border rf-border-gray-200 rf-rounded-md rf-overflow-hidden",children:[q.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:[q.jsx("span",{className:"rf-text-sm rf-font-medium rf-text-gray-700",children:"Solver Parameters"}),q.jsxs("div",{className:"rf-flex rf-items-center rf-gap-1",children:[q.jsx(ODo,{solverEvent:o}),q.jsx(Ei,{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:()=>uxI(o),children:q.jsx(EeA,{className:"rf-w-4 rf-h-4"})})]})]}),q.jsx("div",{className:"rf-p-3 rf-bg-white rf-border-t rf-border-gray-200",children:q.jsx("pre",{className:"rf-text-xs rf-font-mono rf-text-gray-600 rf-whitespace-pre-wrap rf-overflow-x-auto",children:JSON.stringify(o.solverParams,null,2)})})]})]}):q.jsx("div",{className:"rf-flex rf-items-center rf-justify-center rf-h-full",children:q.jsx("p",{className:"rf-text-sm rf-text-gray-500",children:"Select a solver from the list to view details"})})})]})},VDo=["subcircuit_id","componentDisplayName","phaseName","routingPhaseIndex","phaseOrdinal","phaseCount","phaseStageIndex","phaseStageCount","connectionCount","obstacleCount","previousTraceCount","isReroutePhase","autorouterName","autorouterVersion","solverName","effort","cacheStatus"],jDo=["phaseOrdinal","routingPhaseIndex","phaseName","phaseStageIndex"];function zDo(g,A){let I=-1,e=-1;for(let t=g.length-1;t>=0;t--){const o=g[t];if(o.status!=="running"||o.subcircuit_id!==A.subcircuit_id||o.componentDisplayName!==A.componentDisplayName)continue;let B=0,C=!1;for(const Q of jDo)if(!(o[Q]===void 0||A[Q]===void 0)){if(o[Q]!==A[Q]){C=!0;break}B++}!C&&B>e&&(I=t,e=B)}return I}function XDo(g,A){const I=Object.fromEntries(VDo.filter(B=>A[B]!==void 0).map(B=>[B,A[B]])),e=A.simpleRouteJson?structuredClone(A.simpleRouteJson):void 0,t=A.type==="autorouting:start"?-1:zDo(g,A),o={...t===-1?{id:`autorouting_phase_${g.length+1}`}:g[t],...I,status:A.type==="autorouting:start"?"running":A.type==="autorouting:end"?"complete":"error",...A.type==="autorouting:start"?{startSimpleRouteJson:e}:A.type==="autorouting:end"?{endSimpleRouteJson:e}:{errorSimpleRouteJson:e,error:A.error?{...A.error}:void 0}};return t===-1?[...g,o]:g.map((B,C)=>C===t?o:B)}const $Do=new Map([["custom","Custom"],["fanout","Fanout"],["single_layer_fanout","Single layer fanout"],["tscircuit_simplify","Simplify"]]),Ado=new Set(["tscircuit","default","auto","auto_local"]);function gdo(g){if(g==="FanoutSolver")return"Fanout";if(g==="AutoroutingPipelineSolver11_Simplification")return"Simplify";const A=g.match(/^AutoroutingPipeline(?:Solver)?(\d+)(?:_|$)/);if(A)return`Pipeline${A[1]}`;const I=g.match(/^AssignableAutoroutingPipeline(\d+)$/);return I?`Assignable${I[1]}`:g}function Ido(g){const A=g.autorouterName?.trim(),I=A?.replace(/-/g,"_"),e=I&&$Do.get(I);if(e)return e;if(I&&!Ado.has(I))return A;const t=g.solverName?.trim();if(t)return gdo(t);const o=g.autorouterVersion?.trim();if(o){const B=o.match(/^beta[_-]pipeline(\d+)$/);return B?`Pipeline${B[1]}`:o==="latest"?"default":o}return A?"default":"Unknown"}const jtg="#fbbf24";function edo(g){const A=g.endSimpleRouteJson?.traces??[],I=new Set(A.flatMap(t=>[t.pcb_trace_id,t.__replaces_pcb_trace_id].filter(o=>o!==void 0)));return[...(g.startSimpleRouteJson?.traces??[]).filter(t=>!I.has(t.pcb_trace_id)),...A]}function GxI(g){const A=new Map((g.startSimpleRouteJson?.traces??[]).map(I=>[I.pcb_trace_id,I]));return(g.endSimpleRouteJson?.traces??[]).filter(I=>{const e=A.get(I.pcb_trace_id);return!e||!!I.__replaces_pcb_trace_id&&I.__replaces_pcb_trace_id!==e.__replaces_pcb_trace_id||JSON.stringify(e.route)!==JSON.stringify(I.route)}).map(I=>I.pcb_trace_id)}function tdo(g,A){return{outer_diameter:g.via_diameter??A.minViaPadDiameter??A.min_via_pad_diameter??A.minViaDiameter??.6,hole_diameter:g.via_hole_diameter??A.minViaHoleDiameter??A.min_via_hole_diameter??.3}}function mxI(g,A){const I=[];for(const C of g.route)C.route_type==="wire"?I.push({...C,layer:C.layer}):C.route_type==="via"?I.push({route_type:"via",x:C.x,y:C.y,from_layer:C.from_layer,to_layer:C.to_layer,...tdo(C,A)}):C.route_type==="through_obstacle"&&I.push({route_type:"through_pad",start:{...C.start},end:{...C.end},width:C.width,start_layer:C.from_layer,end_layer:C.to_layer,pcb_smtpad_id:C.circuitJsonMetadata?.pcb_smtpad_id,pcb_plated_hole_id:C.circuitJsonMetadata?.pcb_plated_hole_id});const e=C=>{let Q=-1,i=Number.POSITIVE_INFINITY;return I.forEach((E,n)=>{if(E.route_type!=="wire")return;const s=Math.hypot(E.x-C.x,E.y-C.y);s<i&&(i=s,Q=n)}),Q},t=g.route.filter(C=>C.route_type==="jumper").map(C=>[e(C.start),e(C.end)].sort((Q,i)=>Q-i)).filter(([C,Q])=>C>=0&&Q>C).sort(([C],[Q])=>C-Q),o=[];let B=0;for(const[C,Q]of t)C>=B&&o.push(I.slice(B,C+1)),B=Math.max(B,Q);return B<I.length&&o.push(I.slice(B)),o}function odo(g){const A=[],I=[],e=g.endSimpleRouteJson;if(!e)return{lines:A,circles:I};const t=new Set(GxI(g));for(const o of e.traces??[])if(t.has(o.pcb_trace_id))for(const B of mxI(o,e)){let C;for(const Q of B){if(Q.route_type==="through_pad"){C={...Q.end,layer:Q.end_layer,width:Q.width};continue}const i=Q.route_type==="wire"?Q.layer:Q.from_layer;C&&C.layer===i&&(C.x!==Q.x||C.y!==Q.y)&&A.push({points:[{x:C.x,y:C.y},{x:Q.x,y:Q.y}],strokeWidth:Q.route_type==="wire"?Q.width:C.width,strokeColor:jtg,layer:i}),Q.route_type==="via"&&I.push({center:{x:Q.x,y:Q.y},radius:Q.outer_diameter/2,stroke:jtg,fill:"transparent"}),C={x:Q.x,y:Q.y,layer:Q.route_type==="wire"?Q.layer:Q.to_layer,width:Q.route_type==="wire"?Q.width:C?.width??e.minTraceWidth}}}return{coordinateSystem:"cartesian",lines:A,circles:I}}function Bdo(g){const A=JSON.stringify(g);let I=2166136261;for(let e=0;e<A.length;e++)I=Math.imul(I^A.charCodeAt(e),16777619);return(I>>>0).toString(36)}const Cdo=new Set(["pcb_trace","pcb_via","pcb_copper_pour","pcb_ground_plane","pcb_ground_plane_region","pcb_thermal_spoke","pcb_breakout_point"]);function Qdo(g,A,I){const e=I==="input"?A.startSimpleRouteJson??A.errorSimpleRouteJson:A.endSimpleRouteJson,t=g.filter(i=>!Cdo.has(i.type)&&!i.type.endsWith("_error")&&!i.type.endsWith("_warning"));if(!e)return t;const o=I==="input"?e.traces??[]:edo(A),B=new Set(g.filter(i=>i.type==="source_trace").map(i=>i.source_trace_id)),C=["top",...Array.from({length:Math.max(0,e.layerCount-2)},(i,E)=>`inner${E+1}`),...e.layerCount>1?["bottom"]:[]],Q=[];for(const i of o){const n=e.connections.find(r=>r.name===i.connection_name||r.source_trace_id===i.connection_name)?.source_trace_id??i.connection_name??"",s=mxI(i,e);for(const[r,a]of s.entries()){const c={type:"pcb_trace",pcb_trace_id:`${A.id}_${I}_${i.pcb_trace_id}_${r}_${Bdo(a)}`,subcircuit_id:A.subcircuit_id??void 0,source_trace_id:B.has(n)?n:void 0,route:a};Q.push(c);for(const[h,l]of a.entries()){if(l.route_type!=="via")continue;const D=C.indexOf(l.from_layer),d=C.indexOf(l.to_layer),y={type:"pcb_via",pcb_via_id:`${c.pcb_trace_id}_via_${h}`,pcb_trace_id:c.pcb_trace_id,subcircuit_id:A.subcircuit_id??void 0,x:l.x,y:l.y,outer_diameter:l.outer_diameter,hole_diameter:l.hole_diameter,layers:D>=0&&d>=0?C.slice(Math.min(D,d),Math.max(D,d)+1):[l.from_layer,l.to_layer]};Q.push(y)}}}return[...t,...Q]}const ztg=(g,A)=>g.phaseName||`Phase ${g.phaseOrdinal??A+1}`,pxI=g=>g.componentDisplayName?.match(/name="([^"]+)"/)?.[1]?.replace(/^\./,"")||g.componentDisplayName||g.subcircuit_id||"Board",kxI=g=>g.startSimpleRouteJson??g.endSimpleRouteJson??g.errorSimpleRouteJson,ido={is_showing_autorouting:!0,is_showing_rats_nest:!1,is_showing_drc_errors:!1,is_showing_drc_warnings:!1,is_showing_pcb_groups:!1},Edo=({circuitJson:g,phases:A=[],isRunning:I=!1})=>{const[e,t]=X.useState(null),[o,B]=X.useState("output"),[C,Q]=X.useState(!0),[i,E]=X.useState(!1),n=X.useRef(null),[s,r]=X.useState(480),a=e?A.findIndex(N=>N.id===e.id&&kxI(N)===kxI(e)):-1,c=a<0?A.length-1:a,h=A[c],l=a<0,D=!!h?.endSimpleRouteJson,d=h?.startSimpleRouteJson??h?.errorSimpleRouteJson,y=!!d,w=o==="output"&&!D?"input":o==="input"&&!y?"output":o,u=w==="input"?d:h?.endSimpleRouteJson,G=X.useMemo(()=>!h||!u?null:Qdo(g??[],h,w),[g,h,u,w]),m=X.useMemo(()=>h&&w==="output"&&C?odo(h):{lines:[],circles:[]},[h,w,C]);if(X.useLayoutEffect(()=>{const N=n.current;if(!N)return;const J=()=>r(Math.max(360,N.clientHeight));J();const K=new ResizeObserver(J);return K.observe(N),()=>K.disconnect()},[!!h]),!h)return q.jsxs("div",{className:"rf-flex rf-min-h-[400px] rf-flex-col rf-items-center rf-justify-center rf-gap-3 rf-p-8 rf-text-center",children:[q.jsx(QfI,{className:"rf-h-7 rf-w-7 rf-text-blue-500"}),q.jsx("h3",{className:"rf-text-base rf-font-medium",children:I?"Waiting for autorouting":"No autorouting captures"}),q.jsx("p",{className:"rf-max-w-md rf-text-sm rf-text-gray-500",children:I?"Phases appear as the circuit routes. Each capture includes its input and output on the PCB.":"Run a circuit with autorouting enabled to inspect its phases. A circuit JSON file alone does not include routing history."})]});const p=ztg(h,c),k=h.status==="running"&&I,S=!D,R=d?.connections.length,x=G?.filter(N=>N.type==="pcb_trace").length??0;return q.jsxs("div",{className:"rf-flex rf-h-full rf-min-h-[620px] rf-flex-col rf-bg-white md:rf-flex-row","data-testid":"autorouting-explorer",children:[q.jsxs("aside",{className:"rf-flex rf-shrink-0 rf-flex-col rf-border-b rf-border-gray-200 md:rf-w-52 md:rf-border-b-0 md:rf-border-r","aria-label":"Routing phases",children:[q.jsxs("div",{className:"rf-flex rf-items-center rf-justify-between rf-px-3 rf-py-2 rf-text-xs rf-text-gray-500",children:[q.jsx("span",{children:"Routing phases"}),q.jsx("span",{children:A.length})]}),q.jsx("div",{className:"rf-flex rf-gap-1 rf-overflow-x-auto rf-px-1.5 rf-pb-1.5 md:rf-flex-col md:rf-overflow-x-hidden md:rf-overflow-y-auto",children:A.map((N,J)=>{const K=GxI(N).length,_=N.endSimpleRouteJson?`${K} ${K===1?"trace":"traces"} routed`:N.status==="error"?"Failed":N.status==="running"&&I?"Routing…":"No output";return q.jsxs("button",{type:"button","aria-pressed":J===c,title:`${pxI(N)} · ${_}`,onClick:()=>t(N),className:to("rf-flex rf-min-w-[192px] rf-items-start rf-gap-2 rf-rounded-md rf-border rf-px-2 rf-py-2 rf-text-left md:rf-min-w-0",J===c?"rf-border-blue-200 rf-bg-blue-50":"rf-border-transparent hover:rf-bg-gray-50"),children:[q.jsx("span",{className:to("rf-flex rf-h-5 rf-w-5 rf-shrink-0 rf-items-center rf-justify-center rf-rounded-full rf-text-[11px]",J===c?"rf-bg-blue-600 rf-text-white":"rf-bg-gray-100 rf-text-gray-500"),children:J+1}),q.jsxs("span",{className:"rf-min-w-0 rf-flex-1",children:[q.jsxs("span",{className:"rf-flex rf-items-center rf-gap-1",children:[q.jsx("span",{className:"rf-min-w-0 rf-flex-1 rf-truncate rf-text-xs rf-font-medium rf-leading-5 rf-text-gray-800",title:ztg(N,J),children:ztg(N,J)}),N.status==="complete"?q.jsx(yJ,{"aria-label":"Captured",className:"rf-h-3 rf-w-3 rf-shrink-0 rf-text-green-600"}):N.status==="error"?q.jsx(ceg,{"aria-label":"Failed",className:"rf-h-3 rf-w-3 rf-shrink-0 rf-text-red-500"}):I?q.jsx(QS,{"aria-label":"Routing",className:"rf-h-3 rf-w-3 rf-shrink-0 rf-animate-spin rf-text-blue-500"}):null]}),q.jsxs("span",{className:"rf-block rf-text-[11px] rf-leading-4 rf-text-gray-500",children:[Ido(N)," · ",_]})]})]},N.id)})})]}),q.jsxs("div",{className:"rf-flex rf-min-w-0 rf-flex-1 rf-flex-col",children:[q.jsxs("div",{className:"rf-flex rf-flex-wrap rf-items-center rf-gap-3 rf-border-b rf-border-gray-200 rf-px-4 rf-py-3",children:[q.jsxs("h3",{className:"rf-mr-auto rf-flex rf-items-center rf-gap-2 rf-text-sm rf-font-medium",children:[p,q.jsxs("span",{className:"rf-text-xs rf-font-normal rf-text-gray-500",children:[c+1," of ",A.length]})]}),I&&q.jsx("button",{type:"button",onClick:()=>t(null),disabled:l,className:"rf-text-xs rf-text-blue-600 disabled:rf-text-gray-500",children:l?"Following latest":"Follow latest"}),q.jsx("div",{className:"rf-flex rf-rounded-md rf-bg-gray-100 rf-p-1","aria-label":"Phase snapshot",children:["input","output"].map(N=>q.jsx("button",{type:"button","aria-pressed":w===N,disabled:N==="input"?!y:!D,onClick:()=>B(N),className:to("rf-rounded rf-px-3 rf-py-1 rf-text-xs disabled:rf-opacity-40",w===N?"rf-bg-white rf-text-gray-900 rf-shadow-sm":"rf-text-gray-500"),children:N==="input"?"Input":"Output"},N))})]}),q.jsxs("div",{className:"rf-flex rf-flex-wrap rf-items-center rf-justify-between rf-gap-2 rf-px-4 rf-py-2 rf-text-xs rf-text-gray-600",children:[q.jsxs("label",{className:"rf-flex rf-items-center rf-gap-2",children:[q.jsx("input",{type:"checkbox",checked:C,disabled:w!=="output",onChange:N=>Q(N.target.checked),className:"rf-accent-blue-600"}),q.jsx("span",{"aria-hidden":"true",className:"rf-inline-block rf-h-0.5 rf-w-3",style:{backgroundColor:jtg}}),"Highlight changes (all layers)"]}),q.jsxs("span",{children:[w==="input"?"Before this phase":"After this phase"," ","· ",x," traces"]})]}),S&&q.jsx("div",{className:to("rf-border-y rf-px-4 rf-py-2 rf-text-xs",h.status==="error"?"rf-border-red-100 rf-bg-red-50 rf-text-red-700":"rf-border-blue-100 rf-bg-blue-50 rf-text-blue-700"),role:"status",children:h.status==="error"?`Routing failed: ${h.error?.message||"No output was captured."}`:k?"Routing in progress. Showing captured input until output is available.":"No output was captured for this phase. Showing the available input."}),q.jsx("div",{ref:n,className:"rf-relative rf-min-h-[360px] rf-flex-1","data-testid":"autorouting-pcb",children:G?q.jsx(seg,{circuitJson:G,height:s,allowEditing:!1,clickToInteractEnabled:!1,initialState:ido,debugGraphics:m}):q.jsx("div",{className:"rf-p-6 rf-text-sm rf-text-gray-500",children:"No PCB snapshot available for this capture."})}),q.jsxs("div",{className:"rf-flex rf-flex-wrap rf-items-center rf-justify-between rf-gap-2 rf-border-t rf-border-gray-200 rf-px-4 rf-py-3 rf-text-xs rf-text-gray-500",children:[q.jsxs("span",{children:[R===void 0?"Input unavailable":`${R} input connections`,` · ${pxI(h)}`]}),q.jsxs("div",{className:"rf-flex rf-items-center rf-gap-4",children:[q.jsxs("button",{type:"button",disabled:!u,onClick:()=>pk(JSON.stringify(u,null,2),{fileName:`${h.id}-${w}.srj.json`,mimeType:"application/json"}),className:"rf-flex rf-items-center rf-gap-1 disabled:rf-opacity-40",children:[q.jsx(EeA,{className:"rf-h-3 rf-w-3"}),"Download SRJ"]}),q.jsxs("button",{type:"button","aria-expanded":i,onClick:()=>E(!i),className:"rf-flex rf-items-center rf-gap-1",children:[q.jsx(K5,{className:to("rf-h-3 rf-w-3",i&&"rf-rotate-90")}),"Inspect SRJ"]})]})]}),i&&q.jsx("pre",{className:"rf-m-0 rf-max-h-64 rf-overflow-auto rf-border-t rf-border-gray-200 rf-bg-gray-50 rf-p-4 rf-text-xs","aria-label":`${p} ${w} SRJ`,children:u?JSON.stringify(u,null,2):"No snapshot captured."})]})]})},MxI=({errorMessage:g,errorStack:A,circuitJsonErrors:I})=>{X.useEffect(()=>{if(ZU("TSCIRCUIT_TELEMETRY_DISABLED")!==!0&&g){const e=new Error(g);A&&(e.stack=A);try{Pq.captureException(e)}catch{}}},[g,A]),X.useEffect(()=>{if(ZU("TSCIRCUIT_TELEMETRY_DISABLED")!==!0&&I&&I.length>0)for(const e of I){const t=new Error(e.message||"Circuit JSON Error");e.stack&&(t.stack=e.stack);try{Pq.captureException(t,{error_type:e.type})}catch{}}},[I])},SxI=g=>{X.useEffect(()=>{try{sht(g)}catch{}},[g.source,g.component,g.isWebEmbedded,g.activeTab])},fxI="0.0.3006",ndo={version:fxI},aGA=bVg()(HVg(g=>({lastRunEvalVersion:void 0,setLastRunEvalVersion:A=>{g({lastRunEvalVersion:A})}}),{name:"runframe-runner-store"})),sdo=g=>{const[A,I]=X.useState([]),[e,t]=X.useState(null),[o,B]=X.useState(""),[C,Q]=oq("eval-version-selection",null),i=aGA(r=>r.setLastRunEvalVersion),E=aGA(r=>r.lastRunEvalVersion);return X.useEffect(()=>{g&&fetch("https://data.jsdelivr.com/v1/package/npm/@tscircuit/eval").then(r=>r.json()).then(r=>{if(Array.isArray(r?.versions)){let a=[...r.versions];r.tags?.latest&&(t(r.tags.latest),a=a.filter(c=>c!==r.tags.latest)),I(a)}}).catch(()=>{})},[g]),X.useEffect(()=>{g&&(C?(window.TSCIRCUIT_LATEST_EVAL_VERSION=C,i(C)):e&&(window.TSCIRCUIT_LATEST_EVAL_VERSION=e,i(e)))},[g,C,e]),{versions:X.useMemo(()=>A.filter(r=>r.includes(o)).slice(0,50),[A,o]),latestVersion:e,lastRunEvalVersion:E,search:o,setSearch:B,selectVersion:r=>{Q(r),B("")}}},ado=({snippetNames:g,onSelect:A,onCancel:I,isOpen:e})=>{const[t,o]=X.useState(""),[B,C]=X.useState("");if(!e)return null;const Q=g.filter(n=>n.toLowerCase().includes(B.toLowerCase())),i=B&&!g.includes(B),E=n=>{n.key==="Enter"&&(Q.length===1?o(Q[0]):i&&o(B))};return q.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:q.jsxs("div",{className:"rf-bg-white rf-rounded-lg rf-p-6 rf-w-96",children:[q.jsx("h2",{className:"rf-text-lg rf-font-semibold rf-mb-4",children:"Select Snippet"}),q.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:B,onChange:n=>C(n.target.value),onKeyDown:E}),q.jsxs("div",{className:"rf-h-60 rf-overflow-y-auto",children:[Q.map(n=>q.jsx("button",{type:"button",className:`w-full text-left px-4 py-2 rounded hover:bg-gray-100 ${t===n?"bg-blue-50":""}`,onClick:()=>o(n),children:n},n)),i&&q.jsxs("button",{type:"button",className:`w-full text-left px-4 py-2 rounded hover:bg-gray-100 text-blue-500 ${t===B?"bg-blue-50":""}`,onClick:()=>o(B),children:['Create new "',B,'"']})]}),q.jsxs("div",{className:"rf-mt-4 rf-flex rf-justify-end rf-gap-2",children:[q.jsx("button",{type:"button",className:"rf-px-4 rf-py-2 rf-text-gray-600 rf-hover:text-gray-800",onClick:I,children:"Cancel"}),q.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:()=>t&&A(t),disabled:!t,children:t===B?`Create "${t}"`:`Save to ${t}`})]})]})})},rdo=g=>{const A=X.useRef(null),I=Fc(e=>e.recentEvents);X.useEffect(()=>{if(I.length===0)return;const e=I[0];e.event_id!==A.current&&(g(e),A.current=e.event_id)},[I,g])};var cdo=Object.defineProperty,fJ=(g,A)=>cdo(g,"name",{value:A,configurable:!0}),hdo="AlertDialog",[ldo,yAB]=Ak(hdo,[JRI]),RJ=JRI(),Ddo=fJ(g=>{const{__scopeAlertDialog:A,...I}=g,e=RJ(A);return q.jsx(fuA,{...e,...I,modal:!0})},"AlertDialog");X.forwardRef(fJ(function(A,I){const{__scopeAlertDialog:e,...t}=A,o=RJ(e);return q.jsx(ano,{...o,...t,ref:I})},"AlertDialogTrigger"));var ddo=fJ(g=>{const{__scopeAlertDialog:A,...I}=g,e=RJ(A);return q.jsx(RuA,{...e,...I})},"AlertDialogPortal"),RxI=X.forwardRef(fJ(function(A,I){const{__scopeAlertDialog:e,...t}=A,o=RJ(e);return q.jsx(GeA,{...o,...t,ref:I})},"AlertDialogOverlay")),ydo="AlertDialogContent",[wdo,udo]=ldo(ydo),NxI=X.forwardRef(fJ(function(A,I){const{__scopeAlertDialog:e,children:t,...o}=A,B=RJ(e),C=X.useRef(null),Q=wi(I,C),i=X.useRef(null);return q.jsx(wdo,{scope:e,cancelRef:i,children:q.jsx(peA,{role:"alertdialog",...B,...o,ref:Q,onOpenAutoFocus:Mo(o.onOpenAutoFocus,E=>{E.preventDefault(),i.current?.focus({preventScroll:!0})}),onPointerDownOutside:E=>E.preventDefault(),onInteractOutside:E=>E.preventDefault(),children:t})})},"AlertDialogContent")),xxI=X.forwardRef(fJ(function(A,I){const{__scopeAlertDialog:e,...t}=A,o=RJ(e);return q.jsx(NuA,{...o,...t,ref:I})},"AlertDialogTitle")),FxI=X.forwardRef(fJ(function(A,I){const{__scopeAlertDialog:e,...t}=A,o=RJ(e);return q.jsx(xuA,{...o,...t,ref:I})},"AlertDialogDescription")),UxI=X.forwardRef(fJ(function(A,I){const{__scopeAlertDialog:e,...t}=A,o=RJ(e);return q.jsx(etg,{...o,...t,ref:I})},"AlertDialogAction")),Gdo="AlertDialogCancel",JxI=X.forwardRef(fJ(function(A,I){const{__scopeAlertDialog:e,...t}=A,{cancelRef:o}=udo(Gdo,e),B=RJ(e),C=wi(I,o);return q.jsx(etg,{...B,...t,ref:C})},"AlertDialogCancel"));const PxI=Ddo,mdo=ddo,KxI=X.forwardRef(({className:g,...A},I)=>q.jsx(RxI,{className:to("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",g),...A,ref:I}));KxI.displayName=RxI.displayName;const Xtg=X.forwardRef(({className:g,...A},I)=>q.jsxs(mdo,{children:[q.jsx(KxI,{}),q.jsx(NxI,{ref:I,className:to("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",g),...A})]}));Xtg.displayName=NxI.displayName;const $tg=({className:g,...A})=>q.jsx("div",{className:to("rf-flex rf-flex-col rf-space-y-2 rf-text-center sm:rf-text-left",g),...A});$tg.displayName="AlertDialogHeader";const Aog=({className:g,...A})=>q.jsx("div",{className:to("rf-flex rf-flex-col-reverse sm:rf-flex-row sm:rf-justify-end sm:rf-space-x-2",g),...A});Aog.displayName="AlertDialogFooter";const gog=X.forwardRef(({className:g,...A},I)=>q.jsx(xxI,{ref:I,className:to("rf-text-lg rf-font-semibold",g),...A}));gog.displayName=xxI.displayName;const Iog=X.forwardRef(({className:g,...A},I)=>q.jsx(FxI,{ref:I,className:to("rf-text-sm rf-text-zinc-500 dark:rf-text-zinc-400",g),...A}));Iog.displayName=FxI.displayName;const pdo=X.forwardRef(({className:g,...A},I)=>q.jsx(UxI,{ref:I,className:to(oZ(),g),...A}));pdo.displayName=UxI.displayName;const eog=X.forwardRef(({className:g,...A},I)=>q.jsx(JxI,{ref:I,className:to(oZ({variant:"outline"}),"rf-mt-2 sm:rf-mt-0",g),...A}));eog.displayName=JxI.displayName;var kdo=Object.defineProperty,NJ=(g,A)=>kdo(g,"name",{value:A,configurable:!0}),tog="Checkbox",[Mdo,wAB]=Ak(tog),[Sdo,oog]=Mdo(tog);function LxI(g){const{__scopeCheckbox:A,checked:I,children:e,defaultChecked:t,disabled:o,form:B,name:C,onCheckedChange:Q,required:i,value:E="on",internal_do_not_use_render:n}=g,[s,r]=nR({prop:I,defaultProp:t??!1,onChange:Q,caller:tog}),[a,c]=X.useState(null),[h,l]=X.useState(null),[D,d]=X.useState(null),y=a?!!B||!!a.closest("form"):!0,w={checked:s,disabled:o,setChecked:r,control:a,setControl:c,name:C,form:B,value:E,userClick:D,onUserClick:d,required:i,defaultChecked:Af(t)?!1:t,isFormControl:y,bubbleInput:h,setBubbleInput:l};return q.jsx(Sdo,{scope:A,...w,children:_xI(n)?n(w):e})}NJ(LxI,"CheckboxProvider");var fdo="CheckboxTrigger",Rdo=X.forwardRef(NJ(function({__scopeCheckbox:A,onKeyDown:I,onClick:e,...t},o){const{control:B,value:C,disabled:Q,checked:i,required:E,setControl:n,setChecked:s,onUserClick:r,isFormControl:a,bubbleInput:c}=oog(fdo,A),h=wi(o,n),l=X.useRef(i);return X.useEffect(()=>{const D=B?.form;if(D){const d=NJ(()=>s(l.current),"reset");return D.addEventListener("reset",d),()=>D.removeEventListener("reset",d)}},[B,s]),q.jsx(dQ.button,{type:"button",role:"checkbox","aria-checked":Af(i)?"mixed":i,"aria-required":E,"data-state":Bog(i),"data-disabled":Q?"":void 0,disabled:Q,value:C,...t,ref:h,onKeyDown:Mo(I,D=>{D.key==="Enter"&&D.preventDefault()}),onClick:Mo(e,D=>{const d=D.isPropagationStopped();r({requestedChecked:Af(i)?!0:!i,hasConsumerStoppedPropagation:d}),s(y=>Af(y)?!0:!y),c&&a&&(d||D.stopPropagation())})})},"CheckboxTrigger")),YxI=X.forwardRef(NJ(function(A,I){const{__scopeCheckbox:e,name:t,checked:o,defaultChecked:B,required:C,disabled:Q,value:i,onCheckedChange:E,form:n,...s}=A;return q.jsx(LxI,{__scopeCheckbox:e,checked:o,defaultChecked:B,disabled:Q,required:C,onCheckedChange:E,name:t,form:n,value:i,internal_do_not_use_render:({isFormControl:r})=>q.jsxs(q.Fragment,{children:[q.jsx(Rdo,{...s,ref:I,__scopeCheckbox:e}),r&&q.jsx(Udo,{__scopeCheckbox:e})]})})},"Checkbox")),Ndo="CheckboxIndicator",xdo=X.forwardRef(NJ(function(A,I){const{__scopeCheckbox:e,forceMount:t,...o}=A,B=oog(Ndo,e);return q.jsx(LM,{present:t||Af(B.checked)||B.checked===!0,children:q.jsx(dQ.span,{"data-state":Bog(B.checked),"data-disabled":B.disabled?"":void 0,...o,ref:I,style:{pointerEvents:"none",...A.style}})})},"CheckboxIndicator")),Fdo="CheckboxBubbleInput",Udo=X.forwardRef(NJ(function({__scopeCheckbox:A,onClick:I,...e},t){const{control:o,userClick:B,checked:C,defaultChecked:Q,required:i,disabled:E,name:n,value:s,form:r,bubbleInput:a,setBubbleInput:c}=oog(Fdo,A),h=wi(t,c),l=Leg(o),D=X.useRef(!1),d=X.useRef(C),y=X.useRef(B),w=X.useRef(null);X.useEffect(()=>{const G=a;if(!G)return;const m=window.HTMLInputElement.prototype,k=Object.getOwnPropertyDescriptor(m,"checked").set;if(!k)return;const S=d.current!==C;d.current=C;const R=B!==null&&B!==y.current;if(y.current=B,R)w.current=S?null:B,S&&(G.indeterminate=Af(C),k.call(G,Af(C)?!1:C)),G.dispatchEvent(new Event("click",{bubbles:!B.hasConsumerStoppedPropagation}));else if(S){const x=w.current;w.current=null;const N=x?.requestedChecked===C;D.current=!0,G.indeterminate=Af(C),k.call(G,Af(C)?!1:C),G.dispatchEvent(new Event("click",{bubbles:!(N&&x.hasConsumerStoppedPropagation)})),D.current=!1}},[a,C,B]);const u=X.useRef(Af(C)?!1:C);return q.jsx(dQ.input,{type:"checkbox","aria-hidden":!0,defaultChecked:Q??u.current,required:i,disabled:E,name:n,value:s,form:r,...e,tabIndex:-1,ref:h,onClick:Mo(I,G=>{D.current&&G.stopPropagation()}),style:{...e.style,...l,position:"absolute",pointerEvents:"none",opacity:0,margin:0,transform:"translateX(-100%)"}})},"CheckboxBubbleInput"));function _xI(g){return typeof g=="function"}NJ(_xI,"isFunction");function Af(g){return g==="indeterminate"}NJ(Af,"isIndeterminate");function Bog(g){return Af(g)?"indeterminate":g?"checked":"unchecked"}NJ(Bog,"getState");const OeA=X.forwardRef(({className:g,...A},I)=>q.jsx(YxI,{ref:I,className:to("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",g),...A,children:q.jsx(xdo,{className:to("rf-flex rf-items-center rf-justify-center rf-text-current"),children:q.jsx(yJ,{className:"rf-h-4 rf-w-4"})})}));OeA.displayName=YxI.displayName;const Z5=fuA,Jdo=RuA,bxI=X.forwardRef(({className:g,...A},I)=>q.jsx(GeA,{className:to("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",g),...A,ref:I}));bxI.displayName=GeA.displayName;const q3=X.forwardRef(({className:g,children:A,showOverlay:I=!0,...e},t)=>q.jsxs(Jdo,{children:[q.jsx(bxI,{className:to(I?"":"rf-hidden")}),q.jsx(peA,{ref:t,className:to("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",g),...e,children:A})]}));q3.displayName=peA.displayName;const T3=({className:g,...A})=>q.jsx("div",{className:to("rf-flex rf-flex-col rf-space-y-2 rf-text-center sm:rf-text-left",g),...A});T3.displayName="DialogHeader";const FZ=({className:g,...A})=>q.jsx("div",{className:to("rf-flex rf-flex-col-reverse sm:rf-flex-row sm:rf-justify-end sm:rf-space-x-2",g),...A});FZ.displayName="DialogFooter";const Z3=X.forwardRef(({className:g,...A},I)=>q.jsx(NuA,{ref:I,className:to("rf-text-lg rf-font-semibold",g),...A}));Z3.displayName=NuA.displayName;const O5=X.forwardRef(({className:g,...A},I)=>q.jsx(xuA,{ref:I,className:to("rf-text-sm rf-text-zinc-500 dark:rf-text-zinc-400",g),...A}));O5.displayName=xuA.displayName;const rGA={"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"}},Pdo="https://cdn.jsdelivr.net/npm/easyeda@latest/dist/browser/index.js";let Cog=null;const Qog=async()=>(Cog||(Cog=import(Pdo)),Cog),Kdo=g=>(A,I)=>{const e=new Headers(I?.headers),t={};return e.forEach((o,B)=>{t[B]=o}),fetch(`${g?.apiBase??Dm}/proxy`,{...I,headers:{...t,"X-Target-Url":A.toString(),"X-Sender-Origin":t.origin??"","X-Sender-Host":t.host??"https://easyeda.com","X-Sender-Referer":t.referer??"","X-Sender-User-Agent":t["user-agent"]??"","X-Sender-Cookie":t.cookie??"",authority:t.authority??"","content-type":t["content-type"]??"",...g?.headers}})},Ldo=async(g,A=10)=>{const I=encodeURIComponent(g),e=await fetch(`https://jlcsearch.tscircuit.com/api/search?limit=${A}&q=${I}`);if(!e.ok)throw new Error(`JLCPCB API error: ${e.status}`);return(await e.json()).components??[]},Ydo=g=>({lcscId:g.lcsc,manufacturer:g.mfr,description:g.description,partNumber:`C${g.lcsc}`,package:g.package,price:g.price,stock:g.stock,isBasic:g.is_basic}),HxI=async(g,A)=>{const{fetchEasyEDAComponent:I}=await Qog();return I(g,{fetch:Kdo(A),includeModelMetadata:A?.includeModelMetadata})},_do=async(g,A)=>{const{convertRawEasyToTsx:I}=await Qog(),e=await HxI(g,A);return I({rawEasy:e})},bdo=async(g,A)=>{const{EasyEdaJsonSchema:I,convertEasyEdaJsonToCircuitJson:e}=await Qog(),t=await HxI(g,{...A,includeModelMetadata:!1}),o=I.parse(t);return e(o,{shouldRecenter:!0,showDesignator:!0,useModelCdn:!1})};function O3(g){return Array.isArray?Array.isArray(g):qxI(g)==="[object Array]"}function Hdo(g){if(typeof g=="string")return g;if(typeof g=="bigint")return g.toString();const A=g+"";return A=="0"&&1/g==-1/0?"-0":A}function iog(g){return g==null?"":Hdo(g)}function BG(g){return typeof g=="string"}function cGA(g){return typeof g=="number"}function vdo(g){return g===!0||g===!1||qdo(g)&&qxI(g)=="[object Boolean]"}function vxI(g){return typeof g=="object"}function qdo(g){return vxI(g)&&g!==null}function cS(g){return g!=null}function hGA(g){return!g.trim().length}function qxI(g){return g==null?g===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(g)}const Tdo="Incorrect 'index' type",Eog="Invalid doc index: must be a non-negative integer within the bounds of the docs array",Zdo=g=>`Invalid value for key ${g}`,Odo=g=>`Pattern length exceeds max of ${g}.`,Wdo=g=>`Missing ${g} property in key`,Vdo=g=>`Property 'weight' in key '${g}' must be a positive integer`,jdo="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.",TxI=Object.prototype.hasOwnProperty;var zdo=class{constructor(g){this._keys=[],this._keyMap={};let A=0;g.forEach(I=>{const e=ZxI(I);this._keys.push(e),this._keyMap[e.id]=e,A+=e.weight}),this._keys.forEach(I=>{I.weight/=A})}get(g){return this._keyMap[g]}keys(){return this._keys}toJSON(){return JSON.stringify(this._keys)}};function ZxI(g){let A=null,I=null,e=null,t=1,o=null;if(BG(g)||O3(g))e=g,A=OxI(g),I=lGA(g);else{if(!TxI.call(g,"name"))throw new Error(Wdo("name"));const B=g.name;if(e=B,TxI.call(g,"weight")&&g.weight!==void 0&&(t=g.weight,t<=0))throw new Error(Vdo(lGA(B)));A=OxI(B),I=lGA(B),o=g.getFn??null}return{path:A,id:I,weight:t,src:e,getFn:o}}function OxI(g){return O3(g)?g:g.split(".")}function lGA(g){return O3(g)?g.join("."):g}function Xdo(g,A){const I=[];let e=!1;const t=(o,B,C,Q)=>{if(cS(o))if(!B[C])I.push(Q!==void 0?{v:o,i:Q}:o);else{const i=o[B[C]];if(!cS(i))return;if(C===B.length-1&&(BG(i)||cGA(i)||vdo(i)||typeof i=="bigint"))I.push(Q!==void 0?{v:iog(i),i:Q}:iog(i));else if(O3(i)){e=!0;for(let E=0,n=i.length;E<n;E+=1)t(i[E],B,C+1,E)}else B.length&&t(i,B,C+1,Q)}};return t(g,BG(A)?A.split("."):A,0),e?I:I[0]}const rQ=Object.freeze({...{isCaseSensitive:!1,ignoreDiacritics:!1,includeScore:!1,keys:[],shouldSort:!0,sortFn:(g,A)=>g.score===A.score?g.idx<A.idx?-1:1:g.score<A.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:Xdo,ignoreLocation:!1,ignoreFieldNorm:!1,fieldNormWeight:1}});function $do(g){return g>=9&&g<=13||g===32||g===160}function Ayo(g=1,A=3){const I=new Map,e=Math.pow(10,A);return{get(t){let o=0,B=!1;for(let Q=0;Q<t.length;Q++)$do(t.charCodeAt(Q))?B=!1:B||(o++,B=!0);if(o===0&&(o=1),I.has(o))return I.get(o);const C=Math.round(e/Math.pow(o,.5*g))/e;return I.set(o,C),C},clear(){I.clear()}}}var nog=class{constructor({getFn:g=rQ.getFn,fieldNormWeight:A=rQ.fieldNormWeight}={}){this.norm=Ayo(A,3),this.getFn=g,this.isCreated=!1,this.docs=[],this.keys=[],this._keysMap={},this.setIndexRecords()}setSources(g=[]){this.docs=g}setIndexRecords(g=[]){this.records=g}setKeys(g=[]){this.keys=g,this._keysMap={},g.forEach((A,I)=>{this._keysMap[A.id]=I})}create(){if(this.isCreated||!this.docs.length)return;this.isCreated=!0;const g=this.docs.length;this.records=new Array(g);let A=0;if(BG(this.docs[0]))for(let I=0;I<g;I++){const e=this._createStringRecord(this.docs[I],I);e&&(this.records[A++]=e)}else for(let I=0;I<g;I++)this.records[A++]=this._createObjectRecord(this.docs[I],I);this.records.length=A,this.norm.clear()}add(g,A){if(!Number.isInteger(A)||A<0)throw new Error(Eog);if(BG(g)){const e=this._createStringRecord(g,A);return e&&this.records.push(e),e}const I=this._createObjectRecord(g,A);return this.records.push(I),I}removeAt(g){if(!Number.isInteger(g)||g<0)throw new Error(Eog);for(let A=0,I=this.records.length;A<I;A+=1)if(this.records[A].i===g){this.records.splice(A,1);break}for(let A=0,I=this.records.length;A<I;A+=1)this.records[A].i>g&&(this.records[A].i-=1)}removeAll(g){const A=new Set;for(const e of g)Number.isInteger(e)&&e>=0&&A.add(e);if(A.size===0)return;this.records=this.records.filter(e=>!A.has(e.i));const I=Array.from(A).sort((e,t)=>e-t);for(const e of this.records){let t=0,o=I.length;for(;t<o;){const B=t+o>>>1;I[B]<e.i?t=B+1:o=B}e.i-=t}}getValueForItemAtKeyId(g,A){return g[this._keysMap[A]]}size(){return this.records.length}_createStringRecord(g,A){return!cS(g)||hGA(g)?null:{v:g,i:A,n:this.norm.get(g)}}_createObjectRecord(g,A){const I={i:A,$:{}};for(let e=0,t=this.keys.length;e<t;e++){const o=this.keys[e],B=o.getFn?o.getFn(g):this.getFn(g,o.path);if(cS(B)){if(O3(B)){const C=[];for(let Q=0,i=B.length;Q<i;Q+=1){const E=B[Q];if(cS(E)){if(BG(E)){if(!hGA(E)){const n={v:E,i:Q,n:this.norm.get(E)};C.push(n)}}else if(cS(E.v)){const n=BG(E.v)?E.v:iog(E.v);if(!hGA(n)){const s={v:n,i:E.i,n:this.norm.get(n)};C.push(s)}}}}I.$[e]=C}else if(BG(B)&&!hGA(B)){const C={v:B,n:this.norm.get(B)};I.$[e]=C}}}return I}toJSON(){return{keys:this.keys.map(({getFn:g,...A})=>A),records:this.records}}};function WxI(g,A,{getFn:I=rQ.getFn,fieldNormWeight:e=rQ.fieldNormWeight}={}){const t=new nog({getFn:I,fieldNormWeight:e});return t.setKeys(g.map(ZxI)),t.setSources(A),t.create(),t}function gyo(g,{getFn:A=rQ.getFn,fieldNormWeight:I=rQ.fieldNormWeight}={}){const{keys:e,records:t}=g,o=new nog({getFn:A,fieldNormWeight:I});return o.setKeys(e),o.setIndexRecords(t),o}function Iyo(g=[],A=rQ.minMatchCharLength){const I=[];let e=-1,t=-1,o=0;for(let B=g.length;o<B;o+=1){const C=g[o];C&&e===-1?e=o:!C&&e!==-1&&(t=o-1,t-e+1>=A&&I.push([e,t]),e=-1)}return g[o-1]&&o-e>=A&&I.push([e,o-1]),I}function eyo(g,A,I,{location:e=rQ.location,distance:t=rQ.distance,threshold:o=rQ.threshold,findAllMatches:B=rQ.findAllMatches,minMatchCharLength:C=rQ.minMatchCharLength,includeMatches:Q=rQ.includeMatches,ignoreLocation:i=rQ.ignoreLocation}={}){if(A.length>32)throw new Error(Odo(32));const E=A.length,n=g.length,s=Math.max(0,Math.min(e,n));let r=o,a=s;const c=(p,k)=>{const S=p/E;if(i)return S;const R=Math.abs(s-k);return t?S+R/t:R?1:S},h=C>1||Q,l=h?Array(n):[];let D;for(;(D=g.indexOf(A,a))>-1;){const p=c(0,D);if(r=Math.min(p,r),a=D+E,h){let k=0;for(;k<E;)l[D+k]=1,k+=1}}a=-1;let d=[],y=1,w=0,u=E+n;const G=1<<E-1;for(let p=0;p<E;p+=1){let k=0,S=u;for(;k<S;)c(p,s+S)<=r?k=S:u=S,S=Math.floor((u-k)/2+k);u=S;let R=Math.max(1,s-S+1);const x=B?n:Math.min(s+S,n)+E,N=Array(x+2);N[x+1]=(1<<p)-1;for(let J=x;J>=R;J-=1){const K=J-1,_=I[g[K]];if(N[J]=(N[J+1]<<1|1)&_,p&&(N[J]|=(d[J+1]|d[J])<<1|1|d[J+1]),N[J]&G&&(y=c(p,K),y<=r)){if(r=y,a=K,w=p,a<=s)break;R=Math.max(1,2*s-a)}}if(c(p+1,s)>r)break;d=N}if(h&&a>=0){const p=Math.min(n-1,a+E-1+w);for(let k=a;k<=p;k+=1)I[g[k]]&&(l[k]=1)}const m={isMatch:a>=0,score:Math.max(.001,y)};if(h){const p=Iyo(l,C);p.length?Q&&(m.indices=p):m.isMatch=!1}return m}function tyo(g){const A={};for(let I=0,e=g.length;I<e;I+=1){const t=g.charAt(I);A[t]=(A[t]||0)|1<<e-I-1}return A}function sog(g){if(g.length<=1)return g;g.sort((I,e)=>I[0]-e[0]||I[1]-e[1]);const A=[g[0]];for(let I=1,e=g.length;I<e;I+=1){const t=A[A.length-1],o=g[I];o[0]<=t[1]+1?t[1]=Math.max(t[1],o[1]):A.push(o)}return A}const VxI={ł:"l",Ł:"L",đ:"d",Đ:"D",ø:"o",Ø:"O",ħ:"h",Ħ:"H",ŧ:"t",Ŧ:"T",ı:"i",ß:"ss"},oyo=new RegExp("["+Object.keys(VxI).join("")+"]","g"),WeA=typeof String.prototype.normalize=="function"?g=>g.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(oyo,A=>VxI[A]):g=>g;var aog=class{constructor(g,{location:A=rQ.location,threshold:I=rQ.threshold,distance:e=rQ.distance,includeMatches:t=rQ.includeMatches,findAllMatches:o=rQ.findAllMatches,minMatchCharLength:B=rQ.minMatchCharLength,isCaseSensitive:C=rQ.isCaseSensitive,ignoreDiacritics:Q=rQ.ignoreDiacritics,ignoreLocation:i=rQ.ignoreLocation}={}){if(this.options={location:A,threshold:I,distance:e,includeMatches:t,findAllMatches:o,minMatchCharLength:B,isCaseSensitive:C,ignoreDiacritics:Q,ignoreLocation:i},g=C?g:g.toLowerCase(),g=Q?WeA(g):g,this.pattern=g,this.chunks=[],!this.pattern.length)return;const E=(s,r)=>{this.chunks.push({pattern:s,alphabet:tyo(s),startIndex:r})},n=this.pattern.length;if(n>32){let s=0;const r=n%32,a=n-r;for(;s<a;)E(this.pattern.substr(s,32),s),s+=32;if(r){const c=n-32;E(this.pattern.substr(c),c)}}else E(this.pattern,0)}searchIn(g){const{isCaseSensitive:A,ignoreDiacritics:I,includeMatches:e}=this.options;if(g=A?g:g.toLowerCase(),g=I?WeA(g):g,this.pattern===g){if(g.length<this.options.minMatchCharLength)return{isMatch:!1,score:1};const a={isMatch:!0,score:0};return e&&(a.indices=[[0,g.length-1]]),a}const{location:t,distance:o,threshold:B,findAllMatches:C,minMatchCharLength:Q,ignoreLocation:i}=this.options,E=[];let n=0,s=!1;this.chunks.forEach(({pattern:a,alphabet:c,startIndex:h})=>{const{isMatch:l,score:D,indices:d}=eyo(g,a,c,{location:t+h,distance:o,threshold:B,findAllMatches:C,minMatchCharLength:Q,includeMatches:e,ignoreLocation:i});l&&(s=!0),n+=D,l&&d&&E.push(...d)});const r={isMatch:s,score:s?n/this.chunks.length:1};return s&&e&&(r.indices=sog(E)),r}};const Byo=new Set(["fuzzy","include"]);function Cyo(g){return g.startsWith("inverse")}const rog=[{type:"exact",multiRegex:/^="(.*)"$/,singleRegex:/^=(.*)$/,create:g=>({type:"exact",search(A){const I=A===g;return{isMatch:I,score:I?0:1,indices:[0,g.length-1]}}})},{type:"include",multiRegex:/^'"(.*)"$/,singleRegex:/^'(.*)$/,create:g=>({type:"include",search(A){let I=0,e;const t=[],o=g.length;for(;(e=A.indexOf(g,I))>-1;)I=e+o,t.push([e,I-1]);const B=!!t.length;return{isMatch:B,score:B?0:1,indices:t}}})},{type:"prefix-exact",multiRegex:/^\^"(.*)"$/,singleRegex:/^\^(.*)$/,create:g=>({type:"prefix-exact",search(A){const I=A.startsWith(g);return{isMatch:I,score:I?0:1,indices:[0,g.length-1]}}})},{type:"inverse-prefix-exact",multiRegex:/^!\^"(.*)"$/,singleRegex:/^!\^(.*)$/,create:g=>({type:"inverse-prefix-exact",search(A){const I=!A.startsWith(g);return{isMatch:I,score:I?0:1,indices:[0,A.length-1]}}})},{type:"inverse-suffix-exact",multiRegex:/^!"(.*)"\$$/,singleRegex:/^!(.*)\$$/,create:g=>({type:"inverse-suffix-exact",search(A){const I=!A.endsWith(g);return{isMatch:I,score:I?0:1,indices:[0,A.length-1]}}})},{type:"suffix-exact",multiRegex:/^"(.*)"\$$/,singleRegex:/^(.*)\$$/,create:g=>({type:"suffix-exact",search(A){const I=A.endsWith(g);return{isMatch:I,score:I?0:1,indices:[A.length-g.length,A.length-1]}}})},{type:"inverse-exact",multiRegex:/^!"(.*)"$/,singleRegex:/^!(.*)$/,create:g=>({type:"inverse-exact",search(A){const I=A.indexOf(g)===-1;return{isMatch:I,score:I?0:1,indices:[0,A.length-1]}}})},{type:"fuzzy",multiRegex:/^"(.*)"$/,singleRegex:/^(.*)$/,create:(g,A={})=>{const I=new aog(g,{location:A.location??rQ.location,threshold:A.threshold??rQ.threshold,distance:A.distance??rQ.distance,includeMatches:A.includeMatches??rQ.includeMatches,findAllMatches:A.findAllMatches??rQ.findAllMatches,minMatchCharLength:A.minMatchCharLength??rQ.minMatchCharLength,isCaseSensitive:A.isCaseSensitive??rQ.isCaseSensitive,ignoreDiacritics:A.ignoreDiacritics??rQ.ignoreDiacritics,ignoreLocation:A.ignoreLocation??rQ.ignoreLocation});return{type:"fuzzy",search(e){return I.searchIn(e)}}}}],jxI=rog.length,Qyo="\0",iyo="|";function Eyo(g){const A=[],I=g.length;let e=0;for(;e<I;){for(;e<I&&g[e]===" ";)e++;if(e>=I)break;let t=e;for(;t<I&&g[t]!==" "&&g[t]!=='"';)t++;if(t<I&&g[t]==='"'){for(t++;t<I;){if(g[t]==='"'){const o=t+1;if(o>=I||g[o]===" "){t++;break}if(g[o]==="$"&&(o+1>=I||g[o+1]===" ")){t+=2;break}}t++}A.push(g.substring(e,t)),e=t}else{for(;t<I&&g[t]!==" ";)t++;A.push(g.substring(e,t)),e=t}}return A}function zxI(g,A){const I=g.match(A);return I?I[1]:null}function nyo(g,A={}){return g.replace(/\\\|/g,Qyo).split(iyo).map(I=>{const e=Eyo(I.replace(/\u0000/g,"|").trim()).filter(o=>o&&!!o.trim()),t=[];for(let o=0,B=e.length;o<B;o+=1){const C=e[o];let Q=!1,i=-1;for(;!Q&&++i<jxI;){const E=rog[i],n=zxI(C,E.multiRegex);n&&(t.push(E.create(n,A)),Q=!0)}if(!Q)for(i=-1;++i<jxI;){const E=rog[i],n=zxI(C,E.singleRegex);if(n){t.push(E.create(n,A));break}}}return t})}var syo=class{constructor(g,{isCaseSensitive:A=rQ.isCaseSensitive,ignoreDiacritics:I=rQ.ignoreDiacritics,includeMatches:e=rQ.includeMatches,minMatchCharLength:t=rQ.minMatchCharLength,ignoreLocation:o=rQ.ignoreLocation,findAllMatches:B=rQ.findAllMatches,location:C=rQ.location,threshold:Q=rQ.threshold,distance:i=rQ.distance}={}){this.query=null,this.options={isCaseSensitive:A,ignoreDiacritics:I,includeMatches:e,minMatchCharLength:t,findAllMatches:B,ignoreLocation:o,location:C,threshold:Q,distance:i},g=A?g:g.toLowerCase(),g=I?WeA(g):g,this.pattern=g,this.query=nyo(this.pattern,this.options)}static condition(g,A){return A.useExtendedSearch}searchIn(g){const A=this.query;if(!A)return{isMatch:!1,score:1};const{includeMatches:I,isCaseSensitive:e,ignoreDiacritics:t}=this.options;g=e?g:g.toLowerCase(),g=t?WeA(g):g;let o=0;const B=[];let C=0,Q=!1;for(let i=0,E=A.length;i<E;i+=1){const n=A[i];B.length=0,o=0,Q=!1;for(let s=0,r=n.length;s<r;s+=1){const a=n[s],{isMatch:c,indices:h,score:l}=a.search(g);if(c)o+=1,C+=l,Cyo(a.type)&&(Q=!0),I&&(Byo.has(a.type)?B.push(...h):B.push(h));else{C=0,o=0,B.length=0,Q=!1;break}}if(o){const s={isMatch:!0,score:C/o};return Q&&(s.hasInverse=!0),I&&(s.indices=sog(B)),s}}return{isMatch:!1,score:1}}};const cog=[];function hog(...g){cog.push(...g)}function DGA(g,A){for(let I=0,e=cog.length;I<e;I+=1){const t=cog[I];if(t.condition(g,A))return new t(g,A)}return new aog(g,A)}const dGA={AND:"$and",OR:"$or"},log={PATH:"$path",PATTERN:"$val"},Dog=g=>!!(g[dGA.AND]||g[dGA.OR]),ayo=g=>!!g[log.PATH],ryo=g=>!O3(g)&&vxI(g)&&!Dog(g),XxI=g=>({[dGA.AND]:Object.keys(g).map(A=>({[A]:g[A]}))});function $xI(g,A,{auto:I=!0}={}){const e=t=>{if(BG(t)){const Q={keyId:null,pattern:t};return I&&(Q.searcher=DGA(t,A)),Q}const o=Object.keys(t),B=ayo(t);if(!B&&o.length>1&&!Dog(t))return e(XxI(t));if(ryo(t)){const Q=B?t[log.PATH]:o[0],i=B?t[log.PATTERN]:t[Q];if(!BG(i))throw new Error(Zdo(Q));const E={keyId:lGA(Q),pattern:i};return I&&(E.searcher=DGA(i,A)),E}const C={children:[],operator:o[0]};return o.forEach(Q=>{const i=t[Q];O3(i)&&i.forEach(E=>{C.children.push(e(E))})}),C};return Dog(g)||(g=XxI(g)),e(g)}function dog(g,{ignoreFieldNorm:A=rQ.ignoreFieldNorm}){let I=1;return g.forEach(({key:e,norm:t,score:o})=>{const B=e?e.weight:null;I*=Math.pow(o===0&&B?Number.EPSILON:o,(B||1)*(A?1:t))}),I}function cyo(g,{ignoreFieldNorm:A=rQ.ignoreFieldNorm}){g.forEach(I=>{I.score=dog(I.matches,{ignoreFieldNorm:A})})}var hyo=class{constructor(g,A){this.limit=g,this.heap=[],this.comparator=A}get size(){return this.heap.length}insert(g){this.size<this.limit?(this.heap.push(g),this._bubbleUp(this.size-1)):this.comparator(g,this.heap[0])<0&&(this.heap[0]=g,this._sinkDown(0))}extractSorted(){return this.heap.sort(this.comparator)}_bubbleUp(g){const A=this.heap;for(;g>0;){const I=g-1>>1;if(this.comparator(A[g],A[I])<=0)break;const e=A[g];A[g]=A[I],A[I]=e,g=I}}_sinkDown(g){const A=this.heap,I=A.length;let e=g;do{g=e;const t=2*g+1,o=2*g+2;if(t<I&&this.comparator(A[t],A[e])>0&&(e=t),o<I&&this.comparator(A[o],A[e])>0&&(e=o),e!==g){const B=A[g];A[g]=A[e],A[e]=B}}while(e!==g)}};function lyo(g){const A=[];return g.matches.forEach(I=>{if(!cS(I.indices)||!I.indices.length)return;const e={indices:I.indices,value:I.value};I.key&&(e.key=I.key.id),I.idx>-1&&(e.refIndex=I.idx),A.push(e)}),A}function Dyo(g,A,{includeMatches:I=rQ.includeMatches,includeScore:e=rQ.includeScore}={}){return g.map(t=>{const{idx:o}=t,B={item:A[o],refIndex:o};return I&&(B.matches=lyo(t)),e&&(B.score=t.score),B})}const dyo=/[\p{L}\p{M}\p{N}_]+/gu,AFI=new WeakSet;function yyo(g){AFI.has(g)||(AFI.add(g),console.warn(`[Fuse] tokenize regex ${g} lacks the global flag; only the first match per text will be returned. Add the 'g' flag.`))}function wyo(g){if(typeof g=="function"){let A=!1;return I=>{const e=g(I);if(!A&&(A=!0,!Array.isArray(e)||e.some(t=>typeof t!="string")))throw new Error(`[Fuse] tokenize function must return string[]; received ${Array.isArray(e)?"array containing non-strings":typeof e}.`);return e}}return g instanceof RegExp?(g.global||yyo(g),A=>A.match(g)||[]):A=>A.match(dyo)||[]}function yog({isCaseSensitive:g=!1,ignoreDiacritics:A=!1,tokenize:I}={}){const e=wyo(I);return{tokenize(t){return g||(t=t.toLowerCase()),A&&(t=WeA(t)),e(t)}}}var uyo=class{static condition(g,A){return A.useTokenSearch}constructor(g,A){this.options=A,this.analyzer=yog({isCaseSensitive:A.isCaseSensitive,ignoreDiacritics:A.ignoreDiacritics,tokenize:A.tokenize});const I=this.analyzer.tokenize(g),{df:e,fieldCount:t}=A._invertedIndex;this.termSearchers=[],this.idfWeights=[];for(const o of I){this.termSearchers.push(new aog(o,{location:A.location,threshold:A.threshold,distance:A.distance,includeMatches:A.includeMatches,findAllMatches:A.findAllMatches,minMatchCharLength:A.minMatchCharLength,isCaseSensitive:A.isCaseSensitive,ignoreDiacritics:A.ignoreDiacritics,ignoreLocation:!0}));const B=e.get(o)||0,C=Math.log(1+(t-B+.5)/(B+.5));this.idfWeights.push(C)}this.combineAll=A.tokenMatch==="all",this.numTerms=this.termSearchers.length,this.useMask=this.numTerms<=31}searchIn(g){if(!this.termSearchers.length)return{isMatch:!1,score:1};const A=[];let I=0,e=0,t=0,o=0;const B=this.combineAll&&!this.useMask?new Set:null;for(let i=0;i<this.termSearchers.length;i++){const E=this.termSearchers[i].searchIn(g),n=this.idfWeights[i];e+=n,E.isMatch&&(t++,I+=n*(1-E.score),E.indices&&A.push(...E.indices),this.combineAll&&(this.useMask?o|=1<<i:B.add(i)))}if(t===0)return{isMatch:!1,score:1};const C=e>0?1-I/e:0,Q={isMatch:!0,score:Math.max(.001,C)};return this.options.includeMatches&&A.length&&(Q.indices=sog(A)),this.combineAll&&(this.useMask?Q.matchedMask=o:Q.matchedTerms=B,Q.termCount=this.numTerms),Q}};function wog(g,A,I,e){const t=e.tokenize(A);if(!t.length)return;g.fieldCount++,g.docFieldCount.set(I,(g.docFieldCount.get(I)||0)+1);const o=new Set(t);let B=g.docTermFieldHits.get(I);B||(B=new Map,g.docTermFieldHits.set(I,B));for(const C of o)B.set(C,(B.get(C)||0)+1),g.df.set(C,(g.df.get(C)||0)+1)}function gFI(g,A,I,e){const{i:t,v:o,$:B}=A;if(o!==void 0){wog(g,o,t,e);return}if(B)for(let C=0;C<I;C++){const Q=B[C];if(Q)if(Array.isArray(Q))for(const i of Q)wog(g,i.v,t,e);else wog(g,Q.v,t,e)}}function Gyo(g,A,I){const e={fieldCount:0,df:new Map,docFieldCount:new Map,docTermFieldHits:new Map};for(const t of g)gFI(e,t,A,I);return e}function myo(g,A,I,e){gFI(g,A,I,e)}function pyo(g,A){const I=g.docFieldCount.get(A);if(I===void 0)return;g.fieldCount-=I,g.docFieldCount.delete(A);const e=g.docTermFieldHits.get(A);if(e){for(const[t,o]of e){const B=(g.df.get(t)||0)-o;B<=0?g.df.delete(t):g.df.set(t,B)}g.docTermFieldHits.delete(A)}}function IFI(g,A){if(A.length===0)return;const I=Array.from(new Set(A)).sort((C,Q)=>C-Q);for(const C of I)pyo(g,C);const e=C=>{let Q=0,i=I.length;for(;Q<i;){const E=Q+i>>>1;I[E]<C?Q=E+1:i=E}return C-Q},t=I[0],o=new Map;for(const[C,Q]of g.docFieldCount)o.set(C>t?e(C):C,Q);g.docFieldCount=o;const B=new Map;for(const[C,Q]of g.docTermFieldHits)B.set(C>t?e(C):C,Q);g.docTermFieldHits=B}var W3=class{constructor(g,A,I){this.options={...rQ,...A},this.options.useExtendedSearch,this.options.useTokenSearch,this._keyStore=new zdo(this.options.keys),this._docs=g,this._myIndex=null,this._invertedIndex=null,this.setCollection(g,I),this._lastQuery=null,this._lastSearcher=null}_getSearcher(g){if(this._lastQuery===g)return this._lastSearcher;const A=DGA(g,this._invertedIndex?{...this.options,_invertedIndex:this._invertedIndex}:this.options);return this._lastQuery=g,this._lastSearcher=A,A}setCollection(g,A){if(this._docs=g,A&&!(A instanceof nog))throw new Error(Tdo);if(this._myIndex=A||WxI(this.options.keys,this._docs,{getFn:this.options.getFn,fieldNormWeight:this.options.fieldNormWeight}),this.options.useTokenSearch){const I=yog({isCaseSensitive:this.options.isCaseSensitive,ignoreDiacritics:this.options.ignoreDiacritics,tokenize:this.options.tokenize});this._invertedIndex=Gyo(this._myIndex.records,this._myIndex.keys.length,I)}this._invalidateSearcherCache()}add(g){if(!cS(g))return;this._docs.push(g);const A=this._myIndex.add(g,this._docs.length-1);if(this._invertedIndex&&A){const I=yog({isCaseSensitive:this.options.isCaseSensitive,ignoreDiacritics:this.options.ignoreDiacritics,tokenize:this.options.tokenize});myo(this._invertedIndex,A,this._myIndex.keys.length,I)}this._invalidateSearcherCache()}remove(g=()=>!1){const A=[],I=[];for(let e=0,t=this._docs.length;e<t;e+=1)g(this._docs[e],e)&&(A.push(this._docs[e]),I.push(e));if(I.length){this._invertedIndex&&IFI(this._invertedIndex,I);const e=new Set(I);this._docs=this._docs.filter((t,o)=>!e.has(o)),this._myIndex.removeAll(I),this._invalidateSearcherCache()}return A}removeAt(g){if(!Number.isInteger(g)||g<0||g>=this._docs.length)throw new Error(Eog);this._invertedIndex&&IFI(this._invertedIndex,[g]);const A=this._docs.splice(g,1)[0];return this._myIndex.removeAt(g),this._invalidateSearcherCache(),A}_invalidateSearcherCache(){this._lastQuery=null,this._lastSearcher=null}getIndex(){return this._myIndex}_normalizedKeys(){return this._myIndex.keys.map(g=>this._keyStore.get(g.id)||g)}search(g,A){const{limit:I=-1}=A||{},{includeMatches:e,includeScore:t,shouldSort:o,sortFn:B,ignoreFieldNorm:C}=this.options;if(BG(g)&&!g.trim()){let s=this._docs.map((r,a)=>({item:r,refIndex:a}));return cGA(I)&&I>-1&&(s=s.slice(0,I)),s}const Q=o&&cGA(I)&&I>0&&BG(g),i=B,E=(s,r)=>i(s,r)||s.idx-r.idx;let n;if(Q){const s=new hyo(I,E);BG(this._docs[0])?this._searchStringList(g,{heap:s,ignoreFieldNorm:C}):this._searchObjectList(g,{heap:s,ignoreFieldNorm:C}),n=s.extractSorted()}else n=BG(g)?BG(this._docs[0])?this._searchStringList(g):this._searchObjectList(g):this._searchLogical(g),cyo(n,{ignoreFieldNorm:C}),o&&n.sort(BG(g)?E:i),cGA(I)&&I>-1&&(n=n.slice(0,I));return Dyo(n,this._docs,{includeMatches:e,includeScore:t})}_searchStringList(g,{heap:A,ignoreFieldNorm:I}={}){const e=this._getSearcher(g),t=this.options.useTokenSearch&&this.options.tokenMatch==="all",{records:o}=this._myIndex,B=A?null:[];return o.forEach(({v:C,i:Q,n:i})=>{if(!cS(C))return;const E=e.searchIn(C);if(E.isMatch){const n={score:E.score,value:C,norm:i,indices:E.indices};t&&(n.matchedMask=E.matchedMask,n.matchedTerms=E.matchedTerms,n.termCount=E.termCount);const s=[n];if(!t||this._coversAllTokens(s)){const r={item:C,idx:Q,matches:s};A?(r.score=dog(r.matches,{ignoreFieldNorm:I}),A.insert(r)):B.push(r)}}}),B}_searchLogical(g){const A=$xI(g,this.options),I=this._normalizedKeys(),e=(C,Q,i)=>{if(!("children"in C)){const{keyId:r,searcher:a}=C;let c;return r===null?(c=[],I.forEach((h,l)=>{c.push(...this._findMatches({key:h,value:Q[l],searcher:a}))})):c=this._findMatches({key:this._keyStore.get(r),value:this._myIndex.getValueForItemAtKeyId(Q,r),searcher:a}),c&&c.length?[{idx:i,item:Q,matches:c}]:[]}const{children:E,operator:n}=C,s=[];for(let r=0,a=E.length;r<a;r+=1){const c=E[r],h=e(c,Q,i);if(h.length)s.push(...h);else if(n===dGA.AND)return[]}return s},t=this._myIndex.records,o=new Map,B=[];return t.forEach(({$:C,i:Q})=>{if(cS(C)){const i=e(A,C,Q);i.length&&(o.has(Q)||(o.set(Q,{idx:Q,item:C,matches:[]}),B.push(o.get(Q))),i.forEach(({matches:E})=>{o.get(Q).matches.push(...E)}))}}),B}_searchObjectList(g,{heap:A,ignoreFieldNorm:I}={}){const e=this._getSearcher(g),t=this.options.useTokenSearch&&this.options.tokenMatch==="all",{records:o}=this._myIndex,B=this._normalizedKeys(),C=A?null:[];return o.forEach(({$:Q,i})=>{if(!cS(Q))return;const E=[];let n=!1,s=!1;if(B.forEach((r,a)=>{const c=this._findMatches({key:r,value:Q[a],searcher:e});c.length?(E.push(...c),c[0].hasInverse&&(s=!0)):n=!0}),!(s&&n)&&E.length&&(!t||this._coversAllTokens(E))){const r={idx:i,item:Q,matches:E};A?(r.score=dog(r.matches,{ignoreFieldNorm:I}),A.insert(r)):C.push(r)}}),C}_findMatches({key:g,value:A,searcher:I}){if(!cS(A))return[];const e=[];if(O3(A))A.forEach(({v:t,i:o,n:B})=>{if(!cS(t))return;const C=I.searchIn(t);if(C.isMatch){const Q={score:C.score,key:g,value:t,idx:o,norm:B,indices:C.indices,hasInverse:C.hasInverse};C.termCount!==void 0&&(Q.matchedMask=C.matchedMask,Q.matchedTerms=C.matchedTerms,Q.termCount=C.termCount),e.push(Q)}});else{const{v:t,n:o}=A,B=I.searchIn(t);if(B.isMatch){const C={score:B.score,key:g,value:t,norm:o,indices:B.indices,hasInverse:B.hasInverse};B.termCount!==void 0&&(C.matchedMask=B.matchedMask,C.matchedTerms=B.matchedTerms,C.termCount=B.termCount),e.push(C)}}return e}_coversAllTokens(g){const A=g.length?g[0].termCount:void 0;if(A===void 0)return!0;if(A<=31){let e=0;for(let t=0;t<g.length;t++)e|=g[t].matchedMask||0;return e===2**A-1}const I=new Set;for(let e=0;e<g.length;e++){const t=g[e].matchedTerms;if(t)for(const o of t)I.add(o)}return I.size===A}};W3.version="7.5.0",W3.createIndex=WxI,W3.parseIndex=gyo,W3.config=rQ,W3.match=function(g,A,I){if(I&&I.useTokenSearch)throw new Error(jdo);return DGA(g,{...rQ,...I}).searchIn(A)},W3.parseQuery=$xI,hog(syo),hog(uyo),W3.use=function(...g){g.forEach(A=>hog(A))};var kyo=W3;const Myo="https://kicad-mod-cache.tscircuit.com";let uog=null,VeA=null,Gog=null;const Syo=async()=>uog||VeA||(VeA=fetch("https://kicad-mod-cache.tscircuit.com/kicad_files.json").then(g=>g.json()).then(g=>(uog=g,VeA=null,g)),VeA),fyo=async(g,A=20)=>{const I=await Syo();return Gog||(Gog=new kyo(I)),Gog.search(g).slice(0,A).map(e=>e.item)},Ryo=g=>{const A=g.replace(".pretty/","/").replace(".kicad_mod",""),I=`kicad:${A}`;return{path:g,qualifiedName:I,description:A}},Nyo=g=>g.replace(/^\/+/,"").split("/").map(A=>encodeURIComponent(A)).join("/"),xyo=async g=>{const A=await fetch(`${Myo}/${Nyo(g)}`);if(!A.ok)throw new Error(`KiCad footprint fetch failed: ${A.status}`);const I=await A.text(),{KicadFootprintToCircuitJsonConverter:e}=await rS("kicad-to-circuit-json"),t=new e;return t.addFile(g.split("/").pop()??"selected-footprint.kicad_mod",I),t.runUntilFinished(),t.getOutput()},eFI=g=>g?.source==="jlcpcb"||g?.source==="kicad",Fyo=async(g,A)=>{if(g.source==="jlcpcb")return bdo(g.component.partNumber,A?.jlcpcb);if(g.source==="kicad")return xyo(g.footprint.path);throw new Error("Footprint preview is not available for this source")},Uyo=({query:g,placeholder:A,isSearching:I,onQueryChange:e,onSubmit:t})=>{const o=X.useCallback(B=>{B.key==="Enter"&&(B.preventDefault(),t())},[t]);return q.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2 rf-mt-4",children:[q.jsxs("div",{className:"rf-relative rf-flex-grow",children:[q.jsx(heg,{className:"rf-absolute rf-left-2 rf-top-2.5 rf-h-4 rf-w-4 rf-text-muted-foreground"}),q.jsx(Htg,{placeholder:A,className:"rf-pl-8",spellCheck:!1,autoComplete:"off",value:g,onChange:B=>e(B.target.value),onKeyDown:o})]}),q.jsx(Ei,{onClick:t,disabled:I||g.trim().length<1,className:"sm:rf-px-4 rf-px-3",children:I?q.jsx(QS,{className:"rf-h-4 rf-w-4 rf-animate-spin"}):q.jsxs(q.Fragment,{children:[q.jsx(heg,{className:"rf-h-4 rf-w-4 sm:rf-hidden"}),q.jsx("span",{className:"rf-hidden sm:rf-inline",children:"Search"})]})})]})},Jyo=new Intl.NumberFormat("en-US",{style:"currency",currency:"USD"}),Pyo=g=>Jyo.format(g),tFI=g=>{switch(g.source){case"tscircuit.com":{const A=g.package;return`tscircuit-${A.package_id??`${A.org_owner_tscircuit_handle??"unknown"}-${A.unscoped_name??A.name??"package"}`}`}case"jlcpcb":return`jlc-${g.component.lcscId}`;case"kicad":return`kicad-${g.footprint.path}`;default:return"unknown"}},Kyo=g=>{switch(g.source){case"tscircuit.com":return g.package.unscoped_name;case"jlcpcb":return g.component.isDirectLookup?g.component.partNumber:g.component.manufacturer;case"kicad":return g.footprint.qualifiedName}},Lyo=g=>{switch(g.source){case"tscircuit.com":return g.package.description||(g.package.org_owner_tscircuit_handle?`Component by ${g.package.org_owner_tscircuit_handle}`:void 0);case"jlcpcb":return g.component.description;case"kicad":return g.footprint.description}},Yyo=g=>{switch(g.source){case"tscircuit.com":return g.package.name;case"jlcpcb":return g.component.isDirectLookup?void 0:g.component.partNumber;case"kicad":return}},_yo=({results:g,selected:A,onSelect:I,onShowDetails:e})=>{const t=A?tFI(A):null;return q.jsx("div",{className:"rf-divide-y rf-w-full rf-overflow-hidden",children:g.map(o=>{const B=tFI(o),C=t===B,Q=Kyo(o),i=Lyo(o),E=Yyo(o),n=o.source==="jlcpcb"?o.component.stock:null,s=o.source==="jlcpcb"?o.component.price:null,r=o.source==="jlcpcb"?o.component.isBasic:null,a=o.source==="jlcpcb"?o.component.isDirectLookup:!1;return q.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 ${C?"rf-bg-zinc-100":""}`,onClick:()=>I(o),children:[q.jsxs("div",{className:"rf-min-w-0 rf-overflow-hidden rf-w-full",children:[q.jsxs("div",{className:"rf-flex rf-items-start rf-gap-2 rf-min-w-0",children:[q.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:[Q,o.source==="jlcpcb"&&r!=null&&q.jsx("span",{className:`rf-text-xs rf-px-1.5 rf-py-0.5 rf-rounded rf-font-medium rf-flex-shrink-0 ${r?"rf-bg-green-100 rf-text-green-700":"rf-bg-orange-100 rf-text-orange-700"}`,children:r?"Basic":"Extended"}),a&&q.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"}),o.source==="tscircuit.com"&&o.package.is_private&&q.jsx(tQo,{className:"rf-ml-1 rf-h-3 rf-w-3 rf-text-zinc-400 rf-flex-shrink-0"})]}),o.source==="jlcpcb"&&n!=null?q.jsxs("div",{className:"rf-text-xs rf-text-zinc-500 rf-font-medium rf-whitespace-nowrap rf-flex-shrink-0 sm:rf-hidden",children:[n.toLocaleString()," in stock"]}):null]}),q.jsxs("div",{className:"rf-text-xs rf-text-zinc-500 rf-truncate rf-w-full",children:[E?q.jsx("span",{className:"rf-mr-2",children:E}):null,i]})]}),q.jsxs("div",{children:[o.source==="tscircuit.com"&&e?q.jsx("div",{className:"rf-flex-shrink-0 rf-w-full sm:rf-w-auto",children:q.jsx(Ei,{variant:"outline",size:"sm",className:"rf-text-xs rf-w-full sm:rf-w-auto",onClick:c=>{c.stopPropagation(),e(o)},children:"See Details"})}):o.source==="jlcpcb"&&n!=null?q.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:[n.toLocaleString()," in stock"]}):null,s!=null&&q.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:Pyo(s)})]})]},B)})})},byo=({circuitJson:g,error:A,isLoading:I,height:e})=>q.jsx("section",{className:"rf-flex rf-min-w-0 rf-items-center rf-justify-center",style:{height:e},children:I?q.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:e},children:[q.jsx(QS,{className:"rf-h-4 rf-w-4 rf-animate-spin"}),"Loading preview..."]}):A?q.jsx("div",{className:"rf-flex rf-w-full rf-items-center rf-justify-center rf-bg-zinc-950 rf-p-4",style:{height:e},children:q.jsxs("div",{className:"rf-flex rf-max-w-[320px] rf-items-start rf-gap-2 rf-text-sm rf-text-zinc-300",children:[q.jsx(ceg,{className:"rf-mt-0.5 rf-h-4 rf-w-4 rf-flex-shrink-0"}),q.jsx("span",{children:A})]})}):g?q.jsx("div",{className:"rf-w-full rf-min-w-0 rf-overflow-hidden",children:q.jsx(seg,{circuitJson:g,height:e,allowEditing:!1,clickToInteractEnabled:!1,focusOnHover:!1,disablePcbGroups:!0})}):q.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:e},children:"No preview"})}),oFI={importComponentDialog:101,importComponentDetailsDialog:102},Hyo=({packageResult:g,isOpen:A,onOpenChange:I,isLoading:e,details:t,previewTab:o,onPreviewTabChange:B,isSubmitting:C,onImport:Q})=>{const i=g?.package??null,E=i?.latest_pcb_preview_image_url,n=i?.latest_sch_preview_image_url,s=i?.latest_cad_preview_image_url,r=i?.unscoped_name?.split("/").pop()??i?.unscoped_name,a=i?.org_owner_tscircuit_handle??void 0,c=a?`https://tscircuit.com/${a}`:void 0,h=a&&r?`https://tscircuit.com/${a}/${r}`:void 0;return q.jsx(Z5,{open:A,onOpenChange:I,children:q.jsxs(q3,{showOverlay:!1,style:{width:"calc(100vw - 2rem)",zIndex:oFI.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:[q.jsx(T3,{className:"rf-pb-4 rf-border-b",children:q.jsx("div",{className:"rf-flex rf-items-start rf-justify-between rf-gap-4",children:q.jsxs("div",{className:"rf-flex-1 rf-min-w-0",children:[q.jsx(Z3,{className:"rf-text-xl rf-font-semibold rf-truncate",children:r}),q.jsx(O5,{children:i?.description})]})})}),q.jsxs("div",{className:"rf-flex-1 rf-overflow-y-auto rf-py-4 rf-space-y-6",children:[a?q.jsxs("div",{children:[q.jsx("span",{className:"rf-text-xs rf-font-medium rf-text-gray-500 rf-uppercase rf-tracking-wide",children:"Created by"}),q.jsx("div",{className:"rf-mt-1 rf-text-sm rf-font-medium",children:c?q.jsx("a",{href:c,target:"_blank",rel:"noopener noreferrer",className:"rf-text-black hover:rf-underline",children:a}):a})]}):null,(s||E||n)&&q.jsx(q.Fragment,{children:q.jsxs("div",{children:[q.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-mb-4",children:"Preview"}),q.jsxs(WHA,{value:o,onValueChange:l=>B(l),children:[q.jsxs(hlA,{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:[E&&q.jsx(gx,{value:"pcb",children:"PCB"}),n&&q.jsx(gx,{value:"schematic",children:"Schematic"}),s&&q.jsx(gx,{value:"3d",children:"3D"})]}),q.jsxs("div",{className:"rf-mt-4",children:[q.jsx(xw,{value:"pcb",className:"rf-border rf-rounded-lg rf-overflow-hidden rf-bg-gray-50",children:E?q.jsx("img",{src:E,alt:`${r??"package"} PCB preview`,className:"rf-w-full rf-h-full rf-object-contain rf-bg-white rf-p-4"}):null}),q.jsx(xw,{value:"schematic",className:"rf-border rf-rounded-lg rf-overflow-hidden rf-bg-gray-50",children:n?q.jsx("img",{src:n,alt:`${r??"package"} schematic preview`,className:"rf-w-full rf-h-full rf-object-contain rf-bg-white rf-p-4"}):null}),q.jsx(xw,{value:"3d",className:"rf-border rf-rounded-lg rf-overflow-hidden rf-bg-gray-50",children:s?q.jsx("img",{src:s,alt:`${r??"package"} 3D preview`,className:"rf-w-full rf-h-full rf-object-contain rf-bg-white rf-p-4"}):null})]})]})]})}),t?.ai_description?q.jsxs("section",{children:[q.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-mb-3",children:"AI Description"}),q.jsx("div",{className:"rf-bg-gray-50 rf-border rf-border-gray-200 rf-rounded-lg rf-p-4",children:q.jsx("p",{className:"rf-text-sm rf-text-gray-700 rf-leading-relaxed",children:t.ai_description})})]}):null,t?.ai_usage_instructions?q.jsxs("section",{children:[q.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-mb-3",children:"Usage Instructions"}),q.jsx("div",{className:"rf-bg-gray-50 rf-border rf-border-gray-200 rf-rounded-lg rf-p-4",children:q.jsx("p",{className:"rf-text-sm rf-text-gray-700 rf-leading-relaxed rf-whitespace-pre-wrap",children:t.ai_usage_instructions})})]}):null,e?q.jsxs("div",{className:"rf-flex rf-justify-center rf-items-center rf-gap-2 rf-text-gray-500",children:[q.jsx(QS,{className:"rf-h-4 rf-w-4 rf-animate-spin"}),q.jsx("span",{className:"rf-text-sm",children:"Loading package details..."})]}):null]}),q.jsxs(FZ,{className:"rf-pt-4 rf-border-t rf-flex rf-flex-col sm:rf-flex-row rf-justify-between rf-gap-2",children:[q.jsx("div",{className:"rf-flex-1",children:h?q.jsxs(Ei,{variant:"outline",size:"sm",className:"rf-gap-2 rf-w-full sm:rf-w-auto",onClick:()=>window.open(h,"_blank"),children:[q.jsx(zCo,{className:"rf-h-4 rf-w-4"}),"View on tscircuit.com"]}):null}),q.jsxs("div",{className:"rf-flex rf-flex-col sm:rf-flex-row rf-gap-2",children:[q.jsx(Ei,{variant:"outline",onClick:()=>I(!1),className:"rf-order-2 sm:rf-order-1",children:"Close"}),q.jsx(Ei,{onClick:Q,disabled:C,className:"rf-bg-blue-600 hover:rf-bg-blue-700",children:C?q.jsx(QS,{className:"rf-h-4 rf-w-4 rf-animate-spin"}):"Import Component"})]})]})]})})},vyo=()=>{const[g,A]=X.useState(null),[I,e]=X.useState(!1),t=X.useCallback(async(B,C)=>{e(!0);try{const Q=await fetch(`https://api.tscircuit.com/packages/get?name=${encodeURIComponent(`${B}/${C}`)}`);if(!Q.ok)throw new Error(`Failed to load package details: ${Q.status}`);const i=await Q.json();A(i.package??null)}catch(Q){console.error("Failed to fetch package details",Q),A(null)}finally{e(!1)}},[]),o=X.useCallback(()=>{A(null),e(!1)},[]);return{details:g,isLoading:I,fetchDetails:t,reset:o}},qyo=(g,A)=>{const[I,e]=X.useState({circuitJson:null,error:null,isLoading:!1});return X.useEffect(()=>{if(!g||!eFI(g)){e({circuitJson:null,error:null,isLoading:!1});return}let t=!1;return e({circuitJson:null,error:null,isLoading:!0}),Fyo(g,A).then(o=>{t||e({circuitJson:o,error:null,isLoading:!1})}).catch(o=>{t||e({circuitJson:null,error:o instanceof Error?o.message:"Failed to load footprint preview",isLoading:!1})}),()=>{t=!0}},[g,A]),I},Tyo=async(g,A)=>{const I={"Content-Type":"application/json"};A&&(I.Authorization=`Bearer ${A}`);const e=await fetch("https://registry-api.tscircuit.com/packages/search",{method:"POST",headers:I,body:JSON.stringify({query:g})});if(!e.ok)throw new Error(`tscircuit registry error: ${e.status}`);return(await e.json()).packages??[]},Zyo=({sessionToken:g})=>{const[A,I]=X.useState([]),[e,t]=X.useState(!1),[o,B]=X.useState(null),[C,Q]=X.useState(!1),i=X.useCallback(async n=>{const s=n.trim();if(!s)return[];t(!0),B(null);try{const a=(await Tyo(s,g)).map(c=>({source:"tscircuit.com",package:c}));return I(a),a}catch(r){return console.error("Error searching tscircuit packages",r),I([]),B(r instanceof Error?r.message:"Failed to search tscircuit packages"),[]}finally{t(!1),Q(!0)}},[g]),E=X.useCallback(()=>{I([]),t(!1),B(null),Q(!1)},[]);return{results:A,isSearching:e,error:o,hasSearched:C,search:i,reset:E}},Oyo=g=>{const A=/^C(\d+)$/i.exec(g.trim());if(!A)return null;const I=Number(A[1]);if(!Number.isSafeInteger(I))return null;const e=`C${A[1]}`;return{source:"jlcpcb",component:{lcscId:I,manufacturer:e,partNumber:e,description:"Import directly from EasyEDA; stock and availability are unknown",package:"",isDirectLookup:!0}}},BFI=(g,A)=>{const I=Oyo(g);return I?A.some(t=>t.component.partNumber.toUpperCase()===I.component.partNumber)?A:[I,...A]:A},Wyo=g=>{const A=g.trim();return/^C\d+/i.test(A)?A.replace(/^C/i,""):A},Vyo=()=>{const[g,A]=X.useState([]),[I,e]=X.useState(!1),[t,o]=X.useState(null),[B,C]=X.useState(!1),Q=X.useCallback(async E=>{const n=Wyo(E);if(!n)return[];e(!0),o(null);try{const s=await Ldo(n,10),r=BFI(E,s.map(a=>({source:"jlcpcb",component:Ydo(a)})));return A(r),r}catch(s){console.error("Error searching JLCPCB components",s);const r=BFI(E,[]);return A(r),o(r.length>0?null:s instanceof Error?s.message:"Failed to search JLCPCB components"),r}finally{e(!1),C(!0)}},[]),i=X.useCallback(()=>{A([]),e(!1),o(null),C(!1)},[]);return{results:g,isSearching:I,error:t,hasSearched:B,search:Q,reset:i}},jyo=()=>{const[g,A]=X.useState([]),[I,e]=X.useState(!1),[t,o]=X.useState(null),[B,C]=X.useState(!1),Q=X.useCallback(async E=>{const n=E.trim();if(!n)return[];e(!0),o(null);try{const r=(await fyo(n,20)).map(a=>({source:"kicad",footprint:Ryo(a)}));return A(r),r}catch(s){return console.error("Error searching KiCad footprints",s),A([]),o(s instanceof Error?s.message:"Failed to search KiCad footprints"),[]}finally{e(!1),C(!0)}},[]),i=X.useCallback(()=>{A([]),e(!1),o(null),C(!1)},[]);return{results:g,isSearching:I,error:t,hasSearched:B,search:Q,reset:i}},zyo=({onTscircuitPackageSelected:g,onJlcpcbComponentTsxLoaded:A,onKicadStringSelected:I})=>{const e=[];return g&&e.push("tscircuit.com"),A&&e.push("jlcpcb"),I&&e.push("kicad"),e},Xyo=({isOpen:g,onClose:A,jlcpcbProxyRequestHeaders:I,onKicadStringSelected:e,onTscircuitPackageSelected:t,onJlcpcbComponentTsxLoaded:o,jlcpcbProxyApiBase:B,tscircuitSessionToken:C})=>{qeA();const Q=X.useMemo(()=>zyo({onKicadStringSelected:e,onTscircuitPackageSelected:t,onJlcpcbComponentTsxLoaded:o}),[e,t,o]),i=Q.length>0,E=Q.length===1,[n,s]=X.useState(Q[0]??"tscircuit.com"),[r,a]=X.useState(""),[c,h]=X.useState(null),{results:l,isSearching:D,error:d,hasSearched:y,search:w,reset:u}=Zyo({sessionToken:C}),{results:G,isSearching:m,error:p,hasSearched:k,search:S,reset:R}=Vyo(),{results:x,isSearching:N,error:J,hasSearched:K,search:_,reset:b}=jyo(),{details:T,isLoading:j,fetchDetails:O,reset:W}=vyo(),[gA,tA]=X.useState(null),[IA,QA]=X.useState(!1),[nA,DA]=X.useState("pcb"),[CA,hA]=X.useState(null),[sA,cA]=X.useState(!1),SA=X.useMemo(()=>({jlcpcb:{headers:I,apiBase:B}}),[B,I]),{circuitJson:xA,error:aA,isLoading:FA}=qyo(c,SA),NA=eFI(c);X.useEffect(()=>{hA(null)},[c]);const RA=X.useCallback(()=>{u(),R(),b(),h(null)},[R,b,u]);X.useEffect(()=>{g||(RA(),a(""),QA(!1),tA(null),hA(null))},[g,RA]),X.useEffect(()=>{a(""),h(null),n==="tscircuit.com"?u():n==="jlcpcb"?R():n==="kicad"&&b()},[n,R,b,u]);const JA=kA=>{h(kA),tA(kA),DA("pcb"),QA(!0),W();const OA=kA.package.org_owner_tscircuit_handle,$A=kA.package.unscoped_name;if(OA&&$A){const tg=$A.split("/").pop()??$A;O(OA,tg)}},PA=async()=>{r.trim()&&(h(null),n==="tscircuit.com"?await w(r):n==="jlcpcb"?await S(r):n==="kicad"&&await _(r))},mA=async kA=>{try{if(hA(null),cA(!0),kA.source==="kicad"){if(!e)throw new Error("KiCad handler not provided");await e({result:kA,footprint:kA.footprint.qualifiedName})}else if(kA.source==="jlcpcb"){if(!o)throw new Error("JLCPCB handler not provided");const OA=await _do(kA.component.partNumber,{headers:I,apiBase:B});await o({result:kA,tsx:OA})}else if(kA.source==="tscircuit.com"){if(!t)throw new Error("tscircuit package handler not provided");const OA=kA.package.org_owner_tscircuit_handle,$A=kA.package.unscoped_name;if(!OA||!$A)throw new Error("Missing package metadata");const tg=$A.split("/").pop()??$A,dg=`@tsci/${OA}.${tg}`;await t({result:kA,fullPackageName:dg})}return!0}catch(OA){return console.error("Failed to import component",OA),hA(OA instanceof Error?OA.message:"Failed to import component"),!1}finally{cA(!1)}};let YA=[],dA=!1,HA=null,WA=!1;n==="tscircuit.com"?(YA=l,dA=D,HA=d,WA=y):n==="jlcpcb"?(YA=G,dA=m,HA=p,WA=k):n==="kicad"&&(YA=x,dA=N,HA=J,WA=K);const Qg=async()=>{if(!c)return;await mA(c)&&(A(),RA(),a(""))},_A=kA=>{kA||A()},GA=kA=>{QA(kA),kA||tA(null)};return q.jsxs(Z5,{open:g,onOpenChange:_A,children:[q.jsxs(q3,{style:{width:"calc(100vw - 2rem)",maxWidth:NA?"min(1120px, calc(100vw - 2rem))":"min(672px, calc(100vw - 2rem))",zIndex:oFI.importComponentDialog},className:"rf-rounded-sm rf-max-h-[90vh] rf-overflow-y-auto rf-overflow-x-hidden rf-flex rf-flex-col",children:[q.jsxs(T3,{children:[q.jsxs(Z3,{className:"rf-text-lg sm:rf-text-xl",children:["Import ",E?rGA[n].label:""," ","Component"]}),q.jsx(O5,{className:"rf-text-sm",children:i?"Search for components from available sources.":"Import options are disabled because no handlers were provided."})]}),i?q.jsxs(WHA,{value:n,onValueChange:kA=>s(kA),className:"rf-min-w-0 rf-w-full",children:[!E&&q.jsx(hlA,{className:"rf-flex rf-w-full rf-gap-2",children:Q.map(kA=>q.jsx(gx,{value:kA,className:"rf-flex-1 rf-text-xs sm:rf-text-sm",children:rGA[kA].label},kA))}),q.jsxs("div",{className:"rf-min-w-0",style:NA?{display:"grid",gridTemplateColumns:"minmax(0, 1fr) minmax(360px, 0.95fr)",gap:"1.5rem",alignItems:"start"}:void 0,children:[q.jsxs("div",{className:"rf-min-w-0",children:[q.jsx(Uyo,{query:r,placeholder:rGA[n].placeholder,isSearching:dA,onQueryChange:a,onSubmit:PA}),q.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:dA?q.jsxs("div",{className:"rf-p-8 rf-text-center rf-text-zinc-500",children:[q.jsx(QS,{className:"rf-h-8 rf-w-8 rf-animate-spin rf-mx-auto rf-mb-2"}),q.jsx("p",{children:"Searching..."})]}):YA.length>0?q.jsx(_yo,{results:YA,selected:c,onSelect:h,onShowDetails:n==="tscircuit.com"?JA:void 0}):q.jsx("div",{className:"rf-p-8 rf-text-center rf-text-zinc-500",children:HA?`Error: ${HA}`:WA?rGA[n].emptyMessage:"Enter a search term to find components"})})]}),NA?q.jsx("div",{className:"rf-mt-4",children:q.jsx(byo,{circuitJson:xA,error:aA,isLoading:FA,height:325})}):null]})]}):null,CA?q.jsx("div",{className:"rf-text-sm rf-text-red-600 rf-mt-2",children:CA}):null,q.jsxs(FZ,{className:"rf-flex rf-flex-col sm:rf-flex-row rf-gap-2",children:[q.jsx(Ei,{variant:"outline",onClick:A,className:"rf-order-2 sm:rf-order-1",children:"Cancel"}),q.jsx(Ei,{onClick:Qg,disabled:!c||sA,className:"rf-order-1 sm:rf-order-2",children:sA?q.jsx(QS,{className:"rf-h-4 rf-w-4 rf-animate-spin"}):"Import"})]})]}),q.jsx(Hyo,{packageResult:gA,isOpen:IA,onOpenChange:GA,isLoading:j,details:T,previewTab:nA,onPreviewTabChange:kA=>DA(kA),isSubmitting:sA,onImport:()=>{gA&&mA(gA).then(kA=>{kA&&(QA(!1),A(),RA(),a(""))})}})]})},$yo=g=>{const A=g.match(/export const (\w+) =/);if(!A)throw new Error("Could not determine component name from TSX contents");return A[1]},CFI=g=>{const A=Fc(B=>B.pushEvent),I=Fc(B=>B.upsertFile),e=async({result:B,fullPackageName:C})=>{const i=B.package.unscoped_name??B.package.name;await JC.promise(A({event_type:"INSTALL_PACKAGE",full_package_name:C}),{loading:`Requesting install for "${i}"`,success:`Install requested for "${i}"`,error:E=>`Failed to request install: ${E instanceof Error?E.message:String(E)}`})},t=async({footprint:B})=>{await JC.promise(navigator.clipboard.writeText(B),{loading:`Copying "${B}"`,success:`Copied "${B}" to clipboard`,error:C=>`Failed to copy footprint: ${C instanceof Error?C.message:String(C)}`})},o=async({result:B,tsx:C})=>{const i=`imports/${$yo(C)}.tsx`;await JC.promise(I(i,C),{loading:`Importing ${B.component.partNumber}`,success:`Imported to "${i}"`,error:E=>`Failed to import component: ${E instanceof Error?E.message:String(E)}`})};return q.jsx(Xyo,{...g,onTscircuitPackageSelected:e,onKicadStringSelected:t,onJlcpcbComponentTsxLoaded:o})};CFI.displayName="ImportComponentDialogForCli";const Awo=async({circuitJson:g,projectName:A})=>{const{convertCircuitJsonToAltiumZip:I}=await Promise.resolve().then(()=>d_o),e=await I(g,A);return new Blob([new Uint8Array(e)],{type:"application/zip"})},gwo=async({circuitJson:g,projectName:A})=>{await JC.promise((async()=>{const I=await Awo({circuitJson:g,projectName:A});pk(I,{fileName:`${A}_altium_project.zip`})})(),{loading:"Generating Altium project...",success:"Altium project ZIP ready",error:I=>`Failed to generate Altium project: ${I instanceof Error?I.message:String(I)}`})};var mog={exports:{}},QFI;function Iwo(){return QFI||(QFI=1,(function(g,A){var I={env:{},version:""};(function(e){g.exports=e()})(function(){return(function e(t,o,B){function C(E,n){if(!o[E]){if(!t[E]){var s=typeof LF=="function"&&LF;if(!n&&s)return s(E,!0);if(Q)return Q(E,!0);var r=new Error("Cannot find module '"+E+"'");throw r.code="MODULE_NOT_FOUND",r}var a=o[E]={exports:{}};t[E][0].call(a.exports,function(c){var h=t[E][1][c];return C(h||c)},a,a.exports,e,t,o,B)}return o[E].exports}for(var Q=typeof LF=="function"&&LF,i=0;i<B.length;i++)C(B[i]);return C})({1:[function(e,t,o){var B=e("./utils"),C=e("./support"),Q="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";o.encode=function(i){for(var E,n,s,r,a,c,h,l=[],D=0,d=i.length,y=d,w=B.getTypeOf(i)!=="string";D<i.length;)y=d-D,s=w?(E=i[D++],n=D<d?i[D++]:0,D<d?i[D++]:0):(E=i.charCodeAt(D++),n=D<d?i.charCodeAt(D++):0,D<d?i.charCodeAt(D++):0),r=E>>2,a=(3&E)<<4|n>>4,c=1<y?(15&n)<<2|s>>6:64,h=2<y?63&s:64,l.push(Q.charAt(r)+Q.charAt(a)+Q.charAt(c)+Q.charAt(h));return l.join("")},o.decode=function(i){var E,n,s,r,a,c,h=0,l=0,D="data:";if(i.substr(0,D.length)===D)throw new Error("Invalid base64 input, it looks like a data url.");var d,y=3*(i=i.replace(/[^A-Za-z0-9+/=]/g,"")).length/4;if(i.charAt(i.length-1)===Q.charAt(64)&&y--,i.charAt(i.length-2)===Q.charAt(64)&&y--,y%1!=0)throw new Error("Invalid base64 input, bad content length.");for(d=C.uint8array?new Uint8Array(0|y):new Array(0|y);h<i.length;)E=Q.indexOf(i.charAt(h++))<<2|(r=Q.indexOf(i.charAt(h++)))>>4,n=(15&r)<<4|(a=Q.indexOf(i.charAt(h++)))>>2,s=(3&a)<<6|(c=Q.indexOf(i.charAt(h++))),d[l++]=E,a!==64&&(d[l++]=n),c!==64&&(d[l++]=s);return d}},{"./support":30,"./utils":32}],2:[function(e,t,o){var B=e("./external"),C=e("./stream/DataWorker"),Q=e("./stream/Crc32Probe"),i=e("./stream/DataLengthProbe");function E(n,s,r,a,c){this.compressedSize=n,this.uncompressedSize=s,this.crc32=r,this.compression=a,this.compressedContent=c}E.prototype={getContentWorker:function(){var n=new C(B.Promise.resolve(this.compressedContent)).pipe(this.compression.uncompressWorker()).pipe(new i("data_length")),s=this;return n.on("end",function(){if(this.streamInfo.data_length!==s.uncompressedSize)throw new Error("Bug : uncompressed data size mismatch")}),n},getCompressedWorker:function(){return new C(B.Promise.resolve(this.compressedContent)).withStreamInfo("compressedSize",this.compressedSize).withStreamInfo("uncompressedSize",this.uncompressedSize).withStreamInfo("crc32",this.crc32).withStreamInfo("compression",this.compression)}},E.createWorkerFrom=function(n,s,r){return n.pipe(new Q).pipe(new i("uncompressedSize")).pipe(s.compressWorker(r)).pipe(new i("compressedSize")).withStreamInfo("compression",s)},t.exports=E},{"./external":6,"./stream/Crc32Probe":25,"./stream/DataLengthProbe":26,"./stream/DataWorker":27}],3:[function(e,t,o){var B=e("./stream/GenericWorker");o.STORE={magic:"\0\0",compressWorker:function(){return new B("STORE compression")},uncompressWorker:function(){return new B("STORE decompression")}},o.DEFLATE=e("./flate")},{"./flate":7,"./stream/GenericWorker":28}],4:[function(e,t,o){var B=e("./utils"),C=(function(){for(var Q,i=[],E=0;E<256;E++){Q=E;for(var n=0;n<8;n++)Q=1&Q?3988292384^Q>>>1:Q>>>1;i[E]=Q}return i})();t.exports=function(Q,i){return Q!==void 0&&Q.length?B.getTypeOf(Q)!=="string"?(function(E,n,s,r){var a=C,c=r+s;E^=-1;for(var h=r;h<c;h++)E=E>>>8^a[255&(E^n[h])];return-1^E})(0|i,Q,Q.length,0):(function(E,n,s,r){var a=C,c=r+s;E^=-1;for(var h=r;h<c;h++)E=E>>>8^a[255&(E^n.charCodeAt(h))];return-1^E})(0|i,Q,Q.length,0):0}},{"./utils":32}],5:[function(e,t,o){o.base64=!1,o.binary=!1,o.dir=!1,o.createFolders=!0,o.date=null,o.compression=null,o.compressionOptions=null,o.comment=null,o.unixPermissions=null,o.dosPermissions=null},{}],6:[function(e,t,o){var B=null;B=typeof Promise<"u"?Promise:e("lie"),t.exports={Promise:B}},{lie:37}],7:[function(e,t,o){var B=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Uint32Array<"u",C=e("pako"),Q=e("./utils"),i=e("./stream/GenericWorker"),E=B?"uint8array":"array";function n(s,r){i.call(this,"FlateWorker/"+s),this._pako=null,this._pakoAction=s,this._pakoOptions=r,this.meta={}}o.magic="\b\0",Q.inherits(n,i),n.prototype.processChunk=function(s){this.meta=s.meta,this._pako===null&&this._createPako(),this._pako.push(Q.transformTo(E,s.data),!1)},n.prototype.flush=function(){i.prototype.flush.call(this),this._pako===null&&this._createPako(),this._pako.push([],!0)},n.prototype.cleanUp=function(){i.prototype.cleanUp.call(this),this._pako=null},n.prototype._createPako=function(){this._pako=new C[this._pakoAction]({raw:!0,level:this._pakoOptions.level||-1});var s=this;this._pako.onData=function(r){s.push({data:r,meta:s.meta})}},o.compressWorker=function(s){return new n("Deflate",s)},o.uncompressWorker=function(){return new n("Inflate",{})}},{"./stream/GenericWorker":28,"./utils":32,pako:38}],8:[function(e,t,o){function B(a,c){var h,l="";for(h=0;h<c;h++)l+=String.fromCharCode(255&a),a>>>=8;return l}function C(a,c,h,l,D,d){var y,w,u=a.file,G=a.compression,m=d!==E.utf8encode,p=Q.transformTo("string",d(u.name)),k=Q.transformTo("string",E.utf8encode(u.name)),S=u.comment,R=Q.transformTo("string",d(S)),x=Q.transformTo("string",E.utf8encode(S)),N=k.length!==u.name.length,J=x.length!==S.length,K="",_="",b="",T=u.dir,j=u.date,O={crc32:0,compressedSize:0,uncompressedSize:0};c&&!h||(O.crc32=a.crc32,O.compressedSize=a.compressedSize,O.uncompressedSize=a.uncompressedSize);var W=0;c&&(W|=8),m||!N&&!J||(W|=2048);var gA=0,tA=0;T&&(gA|=16),D==="UNIX"?(tA=798,gA|=(function(QA,nA){var DA=QA;return QA||(DA=nA?16893:33204),(65535&DA)<<16})(u.unixPermissions,T)):(tA=20,gA|=(function(QA){return 63&(QA||0)})(u.dosPermissions)),y=j.getUTCHours(),y<<=6,y|=j.getUTCMinutes(),y<<=5,y|=j.getUTCSeconds()/2,w=j.getUTCFullYear()-1980,w<<=4,w|=j.getUTCMonth()+1,w<<=5,w|=j.getUTCDate(),N&&(_=B(1,1)+B(n(p),4)+k,K+="up"+B(_.length,2)+_),J&&(b=B(1,1)+B(n(R),4)+x,K+="uc"+B(b.length,2)+b);var IA="";return IA+=`
|
|
5677
|
+
`,n=new Blob([E],{type:"text/plain"}),s=URL.createObjectURL(n),r=document.createElement("a");r.href=s,r.download=`${i}.test.ts`,r.click(),URL.revokeObjectURL(s)}catch(Q){alert(`Error generating test.ts for ${g.getSolverName()}: ${Q instanceof Error?Q.message:String(Q)}`)}e(!1)};return q.jsxs("div",{className:`relative ${A}`,ref:t,children:[q.jsx("button",{className:"px-2 py-1 rounded text-xs cursor-pointer",onClick:()=>e(!I),title:`Download options for ${g.getSolverName()}`,children:g.getSolverName()}),I&&q.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:[q.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:o,children:"Download JSON"}),q.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:B,children:"Download page.tsx"}),q.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:C,children:"Download test.ts"})]})]})},rxI=g=>g.activeSubSolver?[g,...rxI(g.activeSubSolver)]:[g],pDo=({solver:g})=>{const A=rxI(g);return q.jsx("div",{className:"flex gap-1 items-center text-sm pt-1",children:A.map((I,e)=>q.jsxs("div",{className:"flex items-center",children:[e>0&&q.jsx("span",{className:"text-gray-400 mx-1",children:"→"}),q.jsx(mDo,{solver:I})]},I.getSolverName()))})},kDo=({solver:g,triggerRender:A,animationSpeed:I=25,renderer:e,onRendererChange:t,onAnimationSpeedChange:o,onDownloadVisualization:B,onSolverStarted:C,onSolverCompleted:Q})=>{const[i,E]=X.useReducer(m=>!m,!1),n=X.useRef(void 0),s=X.useRef(null),r="solver-debugger-last-iteration",[a,c]=X.useState(null),h=X.useRef(null),l=X.useMemo(()=>[{label:"Slow",value:250,description:"250ms"},{label:"Normal",value:100,description:"100ms"},{label:"Fast",value:10,description:"10ms"},{label:"Fast (2x)",value:5,description:"5ms"},{label:"Fast (10x)",value:1,description:"1ms"},{label:"Fast 20x",value:.5,description:"2 steps / 1ms"},{label:"Fast 100x",value:.1,description:"10 steps / 1ms"}],[]),D=()=>{const m=Math.max(1,I),p=I<1?Math.round(1/I):1;n.current=setInterval(()=>{if(g.solved||g.failed){n.current&&(clearInterval(n.current),n.current=void 0),E(),A(),Q&&g.solved&&Q(g);return}for(let k=0;k<p&&!(g.solved||g.failed);k++)g.step();A()},m)},d=()=>{n.current&&(clearInterval(n.current),n.current=void 0)},y=()=>{!g.solved&&!g.failed&&(g.step(),A())},w=()=>{!g.solved&&!g.failed&&(C&&C(g),g.solve(),A(),Q&&Q(g))},u=()=>{i?(d(),E()):(E(),D())},G=()=>{if(g.solved||g.failed||i)return;s.current===null&&typeof window<"u"&&(s.current=window.localStorage.getItem(r));const m=window.prompt("Step until which iteration?",s.current??`${g.iterations}`);if(m===null)return;s.current=m,typeof window<"u"&&window.localStorage.setItem(r,m);const p=Number(m);if(!Number.isFinite(p)){window.alert("Please enter a valid number for the iteration");return}for(;g.iterations<p&&!g.solved&&!g.failed;)g.step();A(),g.solved&&Q&&Q(g)};return X.useEffect(()=>()=>{d()},[]),X.useEffect(()=>{(g.solved||g.failed)&&i&&(d(),E())},[g.solved,g.failed,i]),X.useEffect(()=>{i&&(d(),D())},[I,i]),X.useEffect(()=>{if(typeof document>"u")return;const m=p=>{h.current&&!h.current.contains(p.target)&&c(null)};return document.addEventListener("mousedown",m),()=>{document.removeEventListener("mousedown",m)}},[]),q.jsxs("div",{className:"space-y-2 p-2 border-b",children:[q.jsx("div",{className:"flex items-center",children:q.jsxs("div",{className:"flex items-center gap-2",ref:h,children:[q.jsxs("div",{className:"flex h-9 items-center space-x-1 rounded-md border border-slate-200 bg-white p-1 shadow-sm",children:[q.jsxs("div",{className:"relative",children:[q.jsx("button",{type:"button",onClick:()=>c(a==="renderer"?null:"renderer"),className:"flex select-none items-center rounded-sm px-3 py-1 text-sm font-medium outline-none focus:bg-slate-100 data-[state=open]:bg-slate-100","data-state":a==="renderer"?"open":"closed",children:"Renderer"}),a==="renderer"&&q.jsx("div",{className:"absolute left-0 z-50 mt-1 min-w-[10rem] rounded-md border border-slate-200 bg-white p-1 text-slate-950 shadow-md",children:["vector","canvas"].map(m=>q.jsxs("button",{type:"button",onClick:()=>{t(m),c(null)},className:"flex w-full items-center rounded-sm px-2 py-1.5 text-sm hover:bg-slate-100",children:[m==="vector"?"Vector":"Canvas",e===m&&q.jsx("span",{className:"ml-auto text-xs text-slate-500",children:"✓"})]},m))})]}),q.jsxs("div",{className:"relative",children:[q.jsx("button",{type:"button",onClick:()=>c(a==="debug"?null:"debug"),className:"flex select-none items-center rounded-sm px-3 py-1 text-sm font-medium outline-none focus:bg-slate-100 data-[state=open]:bg-slate-100","data-state":a==="debug"?"open":"closed",children:"Debug"}),a==="debug"&&q.jsx("div",{className:"absolute left-0 z-50 mt-1 min-w-[12rem] rounded-md border border-slate-200 bg-white p-1 text-slate-950 shadow-md",children:q.jsx("button",{type:"button",onClick:()=>{B(),c(null)},className:"flex w-full items-center rounded-sm px-2 py-1.5 text-sm hover:bg-slate-100",children:"Download Visualization"})})]}),q.jsxs("div",{className:"relative",children:[q.jsx("button",{type:"button",onClick:()=>c(a==="animation"?null:"animation"),className:"flex select-none items-center rounded-sm px-3 py-1 text-sm font-medium outline-none focus:bg-slate-100 data-[state=open]:bg-slate-100","data-state":a==="animation"?"open":"closed",children:"Animation"}),a==="animation"&&q.jsx("div",{className:"absolute left-0 z-50 mt-1 min-w-[12rem] rounded-md border border-slate-200 bg-white p-1 text-slate-950 shadow-md",children:l.map(m=>q.jsxs("button",{type:"button",onClick:()=>{o(m.value),c(null)},className:"flex w-full items-center rounded-sm px-2 py-1.5 text-sm hover:bg-slate-100",children:[m.label,q.jsx("span",{className:"ml-auto text-xs text-slate-500",children:m.description}),I===m.value&&q.jsx("span",{className:"ml-2 text-xs text-slate-500",children:"✓"})]},m.value))})]})]}),q.jsx(pDo,{solver:g})]})}),q.jsxs("div",{className:"flex gap-2 items-center flex-wrap",children:[q.jsx("button",{onClick:y,disabled:g.solved||g.failed||i,className:"bg-blue-500 hover:bg-blue-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Step"}),q.jsx("button",{onClick:w,disabled:g.solved||g.failed||i,className:"bg-green-500 hover:bg-green-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Solve"}),q.jsx("button",{onClick:u,disabled:g.solved||g.failed,className:`px-3 py-1 rounded text-white text-sm ${i?"bg-red-500 hover:bg-red-600":"bg-yellow-500 hover:bg-yellow-600"} disabled:bg-gray-300`,children:i?"Stop":"Animate"}),q.jsx("button",{onClick:G,disabled:g.solved||g.failed||i,className:"bg-orange-500 hover:bg-orange-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Step Until Iteration"}),q.jsxs("div",{className:"text-sm text-gray-600",children:["Iterations: ",g.iterations]}),g.timeToSolve!==void 0&&q.jsxs("div",{className:"text-sm text-gray-600",children:["Time: ",(g.timeToSolve/1e3).toFixed(3),"s"]}),g.solved&&q.jsx("div",{className:"px-2 py-1 bg-green-100 text-green-800 rounded text-sm",children:"Solved"}),g.failed&&q.jsx("div",{className:"px-2 py-1 bg-red-100 text-red-800 rounded text-sm",children:"Failed"})]}),g.error&&q.jsxs("div",{className:"text-red-600 text-sm",children:["Error: ",g.error]})]})},MDo=g=>g!==null&&"pipelineDef"in g&&Array.isArray(g.pipelineDef),SDo=(g,A,I)=>{const e=g.currentPipelineStageIndex;return A<e?"Completed":A===e&&g.activeSubSolver?g.activeSubSolver.failed?"Failed":"In Progress":"Not Started"},fDo=(g,A)=>{const e=g.pipelineDef[A].solverName,t=SDo(g,A),o=g[e],B=g.firstIterationOfStage?.[e]??(A===g.currentPipelineStageIndex?g.iterations:null),C=g.iterations;let Q=0;if(t==="Completed"){const s=g.pipelineDef[A+1],r=s?g.firstIterationOfStage?.[s.solverName]:void 0;r!==void 0&&B!==null?Q=r-B:B!==null&&(Q=C-B)}else t==="In Progress"&&B!==null&&(Q=C-B);const i=g.timeSpentOnStage?.[e]??0;let E=0;t==="Completed"?E=1:t==="In Progress"&&o&&(E=o.progress??0);const n=o?.stats??null;return{index:A,name:e,status:t,firstIteration:B,iterations:Q,progress:E,timeSpent:i,stats:n&&Object.keys(n).length>0?n:null,solverInstance:o??null}},RDo=({status:g})=>{const A={"Not Started":"text-blue-600","In Progress":"text-yellow-600",Completed:"text-green-600",Failed:"text-red-600"};return q.jsx("span",{className:`font-medium ${A[g]}`,children:g})},NDo=({progress:g})=>{if(g===0)return null;const A=Math.round(g*100);return q.jsxs("div",{className:"flex items-center gap-2",children:[q.jsx("div",{className:"w-20 h-2 bg-gray-200 rounded overflow-hidden",children:q.jsx("div",{className:"h-full bg-blue-500 transition-all duration-200",style:{width:`${A}%`}})}),q.jsxs("span",{className:"text-xs text-gray-500",children:[A,"%"]})]})},cxI=g=>{if(typeof g=="string")return g;if(typeof g=="number"||typeof g=="boolean"||typeof g=="bigint"||g==null)return String(g);if(typeof g=="object")try{return JSON.stringify(g)}catch{return String(g)}return String(g)},xDo=g=>Object.entries(g).map(([A,I])=>`${A}: ${cxI(I)}`).join(", "),FDo=({stats:g})=>{if(!g||Object.keys(g).length===0)return q.jsx("span",{children:"-"});const A=Object.entries(g),I=xDo(g);return q.jsxs("details",{className:"cursor-pointer",children:[q.jsx("summary",{className:"whitespace-nowrap overflow-hidden text-ellipsis max-w-[200px]",children:I}),q.jsx("div",{className:"mt-1 text-xs",children:A.map(([e,t])=>q.jsxs("div",{children:[e,": ",cxI(t)]},e))})]})},Wtg=g=>{if(g===null||typeof g!="object")return g;if(Array.isArray(g))return g.map(Wtg);const A={};for(const[I,e]of Object.entries(g))I.startsWith("_")||(A[I]=Wtg(e));return A},UDo=(g,A)=>{try{if(typeof g.getConstructorParams!="function"){alert(`getConstructorParams() is not implemented for ${A}`);return}const I=Wtg(g.getConstructorParams()),e=new Blob([JSON.stringify(I,null,2)],{type:"application/json"}),t=URL.createObjectURL(e),o=document.createElement("a");o.href=t,o.download=`${A}_input.json`,o.click(),URL.revokeObjectURL(t)}catch(I){alert(`Error downloading input for ${A}: ${I instanceof Error?I.message:String(I)}`)}},JDo=({expanded:g})=>q.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:`w-4 h-4 transition-transform duration-200 ${g?"rotate-90":""}`,children:q.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"})}),hxI=g=>{let A=g;for(;A.activeSubSolver;)A=A.activeSubSolver;return A},lxI=({solver:g,onStepUntilPhase:A,onDownloadInput:I,isNested:e=!1,indentLevel:t=0,triggerRender:o})=>{const[B,C]=X.useState(new Set),Q=g.pipelineDef.map((h,l)=>fDo(g,l)),i=h=>{C(l=>{const D=new Set(l);return D.has(h)?D.delete(h):D.add(h),D})},E=h=>{A?.(h)},n=h=>{h.solverInstance&&(I?I(h.solverInstance,h.name):UDo(h.solverInstance,h.name))},s=h=>`${(h/1e3).toFixed(2)}s`,r=()=>{if(!g.solved&&!g.failed){const h=g.activeSubSolver;for(;!g.solved&&!g.failed&&(g.step(),!(g.activeSubSolver&&g.activeSubSolver!==h)););o?.()}},a=()=>{if(!g.solved&&!g.failed){const h=hxI(g);for(;!g.solved&&!g.failed&&(g.step(),hxI(g)===h););o?.()}},c=t*24;return q.jsxs("div",{className:e?"":"border-t border-gray-200",children:[!e&&q.jsxs("div",{className:"px-4 py-2 bg-gray-50 border-b border-gray-200 flex items-center justify-between",children:[q.jsx("h3",{className:"text-sm font-semibold text-gray-700",children:"Pipeline Stages"}),q.jsxs("div",{className:"flex gap-2",children:[q.jsx("button",{onClick:a,disabled:g.solved||g.failed,className:"bg-indigo-500 hover:bg-indigo-600 disabled:bg-gray-300 disabled:cursor-not-allowed cursor-pointer text-white px-3 py-1 rounded text-sm",children:"Next Solver"}),q.jsx("button",{onClick:r,disabled:g.solved||g.failed,className:"bg-purple-500 hover:bg-purple-600 disabled:bg-gray-300 disabled:cursor-not-allowed cursor-pointer text-white px-3 py-1 rounded text-sm",children:"Next Stage"})]})]}),q.jsx("div",{className:"overflow-x-auto",children:q.jsxs("table",{className:"w-full text-sm",children:[!e&&q.jsx("thead",{children:q.jsxs("tr",{className:"bg-gray-50 border-b border-gray-200",children:[q.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Stage"}),q.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Status"}),q.jsxs("th",{className:"px-4 py-2 text-center font-semibold text-gray-700",children:["i",q.jsx("sub",{children:"0"})]}),q.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Iterations"}),q.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Progress"}),q.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Time"}),q.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Stats"}),q.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Input"})]})}),q.jsx("tbody",{children:Q.map(h=>{const l=MDo(h.solverInstance),D=B.has(h.name);return q.jsxs(sC.Fragment,{children:[q.jsxs("tr",{className:`border-b border-gray-100 ${h.status==="In Progress"?"bg-yellow-50":""}`,children:[q.jsx("td",{className:"px-4 py-2",children:q.jsxs("div",{className:"flex items-center gap-2",style:{paddingLeft:c},children:[l?q.jsx("button",{onClick:()=>i(h.name),className:"text-gray-500 hover:text-gray-700",title:D?"Collapse":"Expand",children:q.jsx(JDo,{expanded:D})}):q.jsx("span",{className:"w-4"}),q.jsx("span",{className:"text-gray-400 w-6",children:String(h.index+1).padStart(2,"0")}),q.jsx("button",{onClick:()=>E(h.name),disabled:h.status==="Completed"||g.solved||g.failed,className:"text-blue-500 hover:text-blue-700 disabled:text-gray-300 disabled:cursor-not-allowed",title:`Step until ${h.name} completes`,children:q.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:q.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"})})}),q.jsx("span",{className:"font-medium text-gray-900",children:h.name})]})}),q.jsx("td",{className:"px-4 py-2",children:q.jsx(RDo,{status:h.status})}),q.jsx("td",{className:"px-4 py-2 text-center text-gray-600",children:h.firstIteration!==null?h.firstIteration:""}),q.jsx("td",{className:"px-4 py-2 text-gray-600",children:h.iterations}),q.jsx("td",{className:"px-4 py-2",children:q.jsx(NDo,{progress:h.progress})}),q.jsx("td",{className:"px-4 py-2 text-gray-600",children:s(h.timeSpent)}),q.jsx("td",{className:"px-4 py-2 text-gray-500",children:q.jsx(FDo,{stats:h.stats})}),q.jsx("td",{className:"px-4 py-2",children:h.solverInstance?q.jsxs("button",{onClick:()=>n(h),className:"flex items-center gap-1 text-blue-500 hover:text-blue-700",title:`Download input for ${h.name}`,children:[q.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:q.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"})}),q.jsx("span",{children:"Input"})]}):null})]}),l&&D&&q.jsx("tr",{children:q.jsx("td",{colSpan:8,className:"p-0",children:q.jsx(lxI,{solver:h.solverInstance,onStepUntilPhase:A,onDownloadInput:I,isNested:!0,indentLevel:t+1,triggerRender:o})})})]},h.name)})})]})})]})};function PDo({graphics:g}){const A=g.points??[],I=g.lines??[],e=g.rects??[],t=g.circles??[],o=g.texts??[];let B=Number.POSITIVE_INFINITY,C=Number.POSITIVE_INFINITY,Q=Number.NEGATIVE_INFINITY,i=Number.NEGATIVE_INFINITY;const E=(h,l)=>{typeof h=="number"&&(h<B&&(B=h),h>Q&&(Q=h)),typeof l=="number"&&(l<C&&(C=l),l>i&&(i=l))};for(const h of A)E(h.x,h.y);for(const h of I){const l=h.points??[];for(const D of l)E(D.x,D.y)}for(const h of e){const l=h.x??0,D=h.y??0,d=h.width??0,y=h.height??0;E(l,D),E(l+d,D+y)}for(const h of t){const l=h.x??0,D=h.y??0,d=h.radius??1;E(l-d,D-d),E(l+d,D+d)}for(const h of o)E(h.x,h.y);(!isFinite(B)||!isFinite(C)||!isFinite(Q)||!isFinite(i))&&(B=-20,C=-20,Q=20,i=20);const n=10,s=B-n,r=C-n,a=Math.max(1,Q-B+2*n),c=Math.max(1,i-C+2*n);return q.jsxs("svg",{className:"w-full h-[400px] bg-white",viewBox:`${s} ${r} ${a} ${c}`,role:"img","aria-label":"Graphics fallback",children:[e.map((h,l)=>q.jsx("rect",{x:h.x??0,y:h.y??0,width:h.width??0,height:h.height??0,fill:"none",stroke:h.strokeColor??"black",strokeWidth:h.strokeWidth??1},`rect-${l}`)),I.map((h,l)=>q.jsx("polyline",{fill:"none",stroke:h.strokeColor??"black",strokeWidth:h.strokeWidth??1,points:(h.points??[]).map(D=>`${D.x??0},${D.y??0}`).join(" ")},`line-${l}`)),t.map((h,l)=>q.jsx("circle",{cx:h.x??0,cy:h.y??0,r:h.radius??1.5,fill:h.fillColor??"none",stroke:h.strokeColor??"black",strokeWidth:h.strokeWidth??1},`circle-${l}`)),A.map((h,l)=>q.jsx("circle",{cx:h.x??0,cy:h.y??0,r:h.radius??1.5,fill:h.color??"black"},`point-${l}`)),o.map((h,l)=>q.jsx("text",{x:h.x??0,y:h.y??0,fontSize:h.fontSize??10,fill:h.color??"black",children:h.text??""},`text-${l}`))]})}var KDo=class extends sC.Component{constructor(g){super(g),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(g){console.error("InteractiveGraphics render error:",g)}render(){return this.state.hasError?this.props.fallback:this.props.children}},LDo=({solver:g,createSolver:A,animationSpeed:I=25,onSolverStarted:e,onSolverCompleted:t})=>{const[o,B]=X.useReducer(D=>D+1,0),[C]=X.useState(()=>{if(A)return A();if(!g)throw new Error("GenericSolverDebugger requires solver or createSolver");return g}),[Q,i]=X.useState(()=>typeof window>"u"?"vector":window.localStorage.getItem("solver-utils-renderer")==="canvas"?"canvas":"vector"),[E,n]=X.useState(I),s=X.useMemo(()=>{try{return C.visualize()||{points:[],lines:[],rects:[],circles:[]}}catch(D){return console.error("Visualization error:",D),{points:[],lines:[],rects:[],circles:[]}}},[C,o]),r=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 D=document.createElement("script");D.src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4",document.head.appendChild(D)}},[]),X.useEffect(()=>{n(I)},[I]);const a=C.pipelineDef!==void 0,c=D=>{const d=C;if(!C.solved&&!C.failed){for(;!C.solved&&!C.failed&&d.currentPipelineStageIndex<=d.pipelineDef.findIndex(y=>y.solverName===D);)C.step();B()}},h=()=>{const D=JSON.stringify(s,null,2),d=new Blob([D],{type:"application/json"}),y=URL.createObjectURL(d),w=document.createElement("a");w.download="visualization.json",w.href=y,document.body.appendChild(w),w.click(),document.body.removeChild(w),URL.revokeObjectURL(y)},l=D=>{i(D),typeof window<"u"&&window.localStorage.setItem("solver-utils-renderer",D)};return q.jsxs("div",{children:[q.jsx(kDo,{solver:C,triggerRender:B,animationSpeed:E,renderer:Q,onRendererChange:l,onAnimationSpeedChange:n,onDownloadVisualization:h,onSolverStarted:e,onSolverCompleted:t}),r?q.jsx("div",{className:"p-4 text-gray-500",children:"No Graphics Yet"}):q.jsx(KDo,{fallback:q.jsx(PDo,{graphics:s}),children:Q==="canvas"?q.jsx(GDo,{graphics:s}):q.jsx(yDo,{graphics:s})}),a&&q.jsx(lxI,{solver:C,onStepUntilPhase:c,triggerRender:B})]})};const YDo=()=>{X.useEffect(()=>{const g="tailwind-cdn-script";if(document.getElementById(g)||window.tailwind)return;const A=document.createElement("div");A.className="hidden",document.body.appendChild(A);const I=window.getComputedStyle(A).display==="none";if(document.body.removeChild(A),I)return;const e=document.createElement("script");e.id=g,e.src="https://cdn.tailwindcss.com",document.head.appendChild(e)},[])},_Do=1e3,pk=(g,A)=>{const{fileName:I,mimeType:e="text/plain"}=A,t=g instanceof Blob?g:new Blob([g],{type:e}),o=URL.createObjectURL(t),B=document.createElement("a");B.href=o,B.download=I,B.target="_blank",B.rel="noopener noreferrer",B.style.display="none",document.body.appendChild(B),B.click(),document.body.removeChild(B),setTimeout(()=>{URL.revokeObjectURL(o)},_Do)},Vtg=g=>{let A=g.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(A)&&(A=`_${A}`),A=A.slice(0,200),A||"untitled"},bDo=g=>{const A=g.solverConstructorArgs??[g.solverParams];if(g.solverName!=="AutoroutingPipelineSolver7_MultiGraph"||A.length!==1)return A;const[{input:I,options:e}]=A;return[I,e]},qx="https://github.com/tscircuit/tscircuit-autorouter/issues/new",DxI="https://github.com/tscircuit/copper-pour-solver/issues/new",dxI="https://github.com/tscircuit/calculate-packing/issues/new",HDo="https://github.com/tscircuit/matchpack/issues/new",yxI="https://github.com/tscircuit/schematic-trace-solver/issues/new?template=json-bug-report.yml",vDo={PackSolver2:dxI,LayoutPipelineSolver:HDo,AutoroutingPipelineSolver:qx,AssignableAutoroutingPipeline2:qx,AssignableAutoroutingPipeline3:qx,AutoroutingPipeline1_OriginalUnravel:qx,AutoroutingPipelineSolver3_HgPortPointPathing:qx,AutoroutingPipelineSolver4:qx,AutoroutingPipelineSolver5:qx,AutoroutingPipelineSolver7_MultiGraph:qx,AutoroutingPipelineSolver8:qx,CopperPourPipelineSolver:DxI,SchematicTracePipelineSolver:yxI},qDo=g=>g.toLowerCase().includes("pack")?BfI:g.toLowerCase().includes("rout")?QfI:HCo,wxI=g=>{const A=vDo[g];if(A)return A;const I=g.toLowerCase();return I.includes("autorout")?qx:I.includes("schematic")&&I.includes("trace")?yxI:I.includes("copperpour")?DxI:I.includes("pack")?dxI:null},TDo=g=>`${Vtg(`${g.componentName}-${g.solverName}`)}-solver-input.json`,uxI=g=>{pk(JSON.stringify(g.solverParams,null,2),{fileName:TDo(g),mimeType:"application/json"})},ZDo=({solverEvent:g})=>{const A=wxI(g.solverName);return q.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:[q.jsxs(Ei,{type:"button",variant:"outline",size:"sm",onClick:()=>uxI(g),children:[q.jsx(EeA,{className:"rf-w-4 rf-h-4"}),"Download"]}),A?q.jsx(Ei,{asChild:!0,variant:"outline",size:"sm",children:q.jsxs("a",{href:A,target:"_blank",rel:"noopener noreferrer",children:[q.jsx(TwA,{className:"rf-w-4 rf-h-4"}),"Report"]})}):q.jsxs(Ei,{type:"button",variant:"outline",size:"sm",disabled:!0,title:"No report link configured for this solver",children:[q.jsx(TwA,{className:"rf-w-4 rf-h-4"}),"Report"]})]})},ODo=({solverEvent:g})=>{const A=wxI(g.solverName);return A?q.jsx(Ei,{asChild:!0,variant:"ghost",size:"icon",className:"rf-h-8 rf-w-8",children:q.jsx("a",{href:A,target:"_blank",rel:"noopener noreferrer",title:"Report solver bug","aria-label":"Report solver bug",children:q.jsx(TwA,{className:"rf-w-4 rf-h-4"})})}):q.jsx(Ei,{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:q.jsx(TwA,{className:"rf-w-4 rf-h-4"})})},WDo=({solverEvents:g=[]})=>{const[A,I]=X.useState(null);YDo();const e=X.useMemo(()=>{const C=new Map;for(const Q of g){const i=`${Q.componentName}-${Q.solverName}`;C.set(i,Q)}return C},[g]),t=X.useMemo(()=>Array.from(e.keys()),[e]),o=A?e.get(A):null,B=X.useMemo(()=>{if(!o)return{instance:null,error:null,classFound:!1};const C=v5A[o.solverName];if(!C)return{instance:null,error:`Solver class "${o.solverName}" not found in SOLVERS registry. Available: ${Object.keys(v5A).join(", ")}`,classFound:!1};try{return{instance:new C(...bDo(o)),error:null,classFound:!0}}catch(Q){const i=Q instanceof Error?Q.message:String(Q);return console.error("Failed to reconstruct solver:",Q),{instance:null,error:`Failed to instantiate solver: ${i}`,classFound:!0}}},[o]);return g.length===0?q.jsx("div",{className:"rf-p-4",children:q.jsx("div",{className:"rf-bg-gray-50 rf-rounded-md rf-border rf-border-gray-200",children:q.jsxs("div",{className:"rf-p-4",children:[q.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800 rf-mb-3",children:"No Solvers Detected"}),q.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."})]})})}):q.jsxs("div",{className:"rf-flex rf-h-full rf-overflow-hidden",children:[q.jsxs("div",{className:"rf-w-64 rf-border-r rf-border-gray-200 rf-overflow-y-auto rf-flex-shrink-0",children:[q.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:[t.length," ",t.length===1?"Solver":"Solvers"]}),t.map(C=>{const Q=e.get(C),i=A===C;return q.jsx("div",{className:`rf-px-3 rf-py-2 rf-cursor-pointer rf-border-b rf-border-gray-100 ${i?"rf-bg-blue-50 rf-border-l-2 rf-border-l-blue-500":"hover:rf-bg-gray-50"}`,onClick:()=>I(C),children:(()=>{const E=qDo(Q.solverName);return q.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2",children:[q.jsx(E,{className:"rf-w-4 rf-h-4 rf-text-blue-500 rf-flex-shrink-0"}),q.jsxs("div",{className:"rf-flex-1 rf-min-w-0",children:[q.jsx("div",{className:"rf-text-sm rf-font-medium rf-text-gray-800 rf-truncate",children:Q.componentName}),q.jsx("div",{className:"rf-text-xs rf-text-gray-500 rf-truncate",children:Q.solverName})]})]})})()},C)})]}),q.jsx("div",{className:"rf-flex-1 rf-overflow-hidden",children:o?B.instance?q.jsxs("div",{className:"rf-flex rf-h-full rf-flex-col rf-overflow-y-auto",children:[q.jsx(ZDo,{solverEvent:o}),q.jsx("div",{className:"rf-min-h-0 rf-flex-1",children:q.jsx(CS,{fallback:q.jsx("div",{className:"rf-p-4",children:q.jsxs("div",{className:"rf-bg-red-50 rf-rounded-md rf-border rf-border-red-200 rf-p-4",children:[q.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-red-800 rf-mb-2",children:"Error Loading Solver Debugger"}),q.jsxs("p",{className:"rf-text-sm rf-text-red-600",children:["Failed to render the solver debugger for"," ",o.solverName]})]})}),children:q.jsx(LDo,{solver:B.instance})})})]}):q.jsxs("div",{className:"rf-p-4",children:[q.jsxs("div",{className:"rf-mb-4",children:[q.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800",children:o.solverName}),q.jsxs("p",{className:"rf-text-sm rf-text-gray-500",children:["Component: ",o.componentName]})]}),B.error&&q.jsx("div",{className:`rf-rounded-md rf-border rf-p-4 rf-mb-4 ${B.classFound?"rf-bg-red-50 rf-border-red-200":"rf-bg-yellow-50 rf-border-yellow-200"}`,children:q.jsx("p",{className:`rf-text-sm ${B.classFound?"rf-text-red-700":"rf-text-yellow-700"}`,children:B.error})}),q.jsxs("div",{className:"rf-border rf-border-gray-200 rf-rounded-md rf-overflow-hidden",children:[q.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:[q.jsx("span",{className:"rf-text-sm rf-font-medium rf-text-gray-700",children:"Solver Parameters"}),q.jsxs("div",{className:"rf-flex rf-items-center rf-gap-1",children:[q.jsx(ODo,{solverEvent:o}),q.jsx(Ei,{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:()=>uxI(o),children:q.jsx(EeA,{className:"rf-w-4 rf-h-4"})})]})]}),q.jsx("div",{className:"rf-p-3 rf-bg-white rf-border-t rf-border-gray-200",children:q.jsx("pre",{className:"rf-text-xs rf-font-mono rf-text-gray-600 rf-whitespace-pre-wrap rf-overflow-x-auto",children:JSON.stringify(o.solverParams,null,2)})})]})]}):q.jsx("div",{className:"rf-flex rf-items-center rf-justify-center rf-h-full",children:q.jsx("p",{className:"rf-text-sm rf-text-gray-500",children:"Select a solver from the list to view details"})})})]})},VDo=["subcircuit_id","componentDisplayName","phaseName","routingPhaseIndex","phaseOrdinal","phaseCount","phaseStageIndex","phaseStageCount","connectionCount","obstacleCount","previousTraceCount","isReroutePhase","autorouterName","autorouterVersion","solverName","effort","cacheStatus"],jDo=["phaseOrdinal","routingPhaseIndex","phaseName","phaseStageIndex"];function zDo(g,A){let I=-1,e=-1;for(let t=g.length-1;t>=0;t--){const o=g[t];if(o.status!=="running"||o.subcircuit_id!==A.subcircuit_id||o.componentDisplayName!==A.componentDisplayName)continue;let B=0,C=!1;for(const Q of jDo)if(!(o[Q]===void 0||A[Q]===void 0)){if(o[Q]!==A[Q]){C=!0;break}B++}!C&&B>e&&(I=t,e=B)}return I}function XDo(g,A){const I=Object.fromEntries(VDo.filter(B=>A[B]!==void 0).map(B=>[B,A[B]])),e=A.simpleRouteJson?structuredClone(A.simpleRouteJson):void 0,t=A.type==="autorouting:start"?-1:zDo(g,A),o={...t===-1?{id:`autorouting_phase_${g.length+1}`}:g[t],...I,status:A.type==="autorouting:start"?"running":A.type==="autorouting:end"?"complete":"error",...A.type==="autorouting:start"?{startSimpleRouteJson:e}:A.type==="autorouting:end"?{endSimpleRouteJson:e}:{errorSimpleRouteJson:e,error:A.error?{...A.error}:void 0}};return t===-1?[...g,o]:g.map((B,C)=>C===t?o:B)}const $Do=new Map([["custom","Custom"],["fanout","Fanout"],["single_layer_fanout","Single layer fanout"],["tscircuit_simplify","Simplify"]]),Ado=new Set(["tscircuit","default","auto","auto_local"]);function gdo(g){if(g==="FanoutSolver")return"Fanout";if(g==="AutoroutingPipelineSolver11_Simplification")return"Simplify";const A=g.match(/^AutoroutingPipeline(?:Solver)?(\d+)(?:_|$)/);if(A)return`Pipeline${A[1]}`;const I=g.match(/^AssignableAutoroutingPipeline(\d+)$/);return I?`Assignable${I[1]}`:g}function Ido(g){const A=g.autorouterName?.trim(),I=A?.replace(/-/g,"_"),e=I&&$Do.get(I);if(e)return e;if(I&&!Ado.has(I))return A;const t=g.solverName?.trim();if(t)return gdo(t);const o=g.autorouterVersion?.trim();if(o){const B=o.match(/^beta[_-]pipeline(\d+)$/);return B?`Pipeline${B[1]}`:o==="latest"?"default":o}return A?"default":"Unknown"}const jtg="#fbbf24";function edo(g){const A=g.endSimpleRouteJson?.traces??[],I=new Set(A.flatMap(t=>[t.pcb_trace_id,t.__replaces_pcb_trace_id].filter(o=>o!==void 0)));return[...(g.startSimpleRouteJson?.traces??[]).filter(t=>!I.has(t.pcb_trace_id)),...A]}function GxI(g){const A=new Map((g.startSimpleRouteJson?.traces??[]).map(I=>[I.pcb_trace_id,I]));return(g.endSimpleRouteJson?.traces??[]).filter(I=>{const e=A.get(I.pcb_trace_id);return!e||!!I.__replaces_pcb_trace_id&&I.__replaces_pcb_trace_id!==e.__replaces_pcb_trace_id||JSON.stringify(e.route)!==JSON.stringify(I.route)}).map(I=>I.pcb_trace_id)}function tdo(g,A){return{outer_diameter:g.via_diameter??A.minViaPadDiameter??A.min_via_pad_diameter??A.minViaDiameter??.6,hole_diameter:g.via_hole_diameter??A.minViaHoleDiameter??A.min_via_hole_diameter??.3}}function mxI(g,A){const I=[];for(const C of g.route)C.route_type==="wire"?I.push({...C,layer:C.layer}):C.route_type==="via"?I.push({route_type:"via",x:C.x,y:C.y,from_layer:C.from_layer,to_layer:C.to_layer,...tdo(C,A)}):C.route_type==="through_obstacle"&&I.push({route_type:"through_pad",start:{...C.start},end:{...C.end},width:C.width,start_layer:C.from_layer,end_layer:C.to_layer,pcb_smtpad_id:C.circuitJsonMetadata?.pcb_smtpad_id,pcb_plated_hole_id:C.circuitJsonMetadata?.pcb_plated_hole_id});const e=C=>{let Q=-1,i=Number.POSITIVE_INFINITY;return I.forEach((E,n)=>{if(E.route_type!=="wire")return;const s=Math.hypot(E.x-C.x,E.y-C.y);s<i&&(i=s,Q=n)}),Q},t=g.route.filter(C=>C.route_type==="jumper").map(C=>[e(C.start),e(C.end)].sort((Q,i)=>Q-i)).filter(([C,Q])=>C>=0&&Q>C).sort(([C],[Q])=>C-Q),o=[];let B=0;for(const[C,Q]of t)C>=B&&o.push(I.slice(B,C+1)),B=Math.max(B,Q);return B<I.length&&o.push(I.slice(B)),o}function odo(g){const A=[],I=[],e=g.endSimpleRouteJson;if(!e)return{lines:A,circles:I};const t=new Set(GxI(g));for(const o of e.traces??[])if(t.has(o.pcb_trace_id))for(const B of mxI(o,e)){let C;for(const Q of B){if(Q.route_type==="through_pad"){C={...Q.end,layer:Q.end_layer,width:Q.width};continue}const i=Q.route_type==="wire"?Q.layer:Q.from_layer;C&&C.layer===i&&(C.x!==Q.x||C.y!==Q.y)&&A.push({points:[{x:C.x,y:C.y},{x:Q.x,y:Q.y}],strokeWidth:Q.route_type==="wire"?Q.width:C.width,strokeColor:jtg,layer:i}),Q.route_type==="via"&&I.push({center:{x:Q.x,y:Q.y},radius:Q.outer_diameter/2,stroke:jtg,fill:"transparent"}),C={x:Q.x,y:Q.y,layer:Q.route_type==="wire"?Q.layer:Q.to_layer,width:Q.route_type==="wire"?Q.width:C?.width??e.minTraceWidth}}}return{coordinateSystem:"cartesian",lines:A,circles:I}}function Bdo(g){const A=JSON.stringify(g);let I=2166136261;for(let e=0;e<A.length;e++)I=Math.imul(I^A.charCodeAt(e),16777619);return(I>>>0).toString(36)}const Cdo=new Set(["pcb_trace","pcb_via","pcb_copper_pour","pcb_ground_plane","pcb_ground_plane_region","pcb_thermal_spoke","pcb_breakout_point"]);function Qdo(g,A,I){const e=I==="input"?A.startSimpleRouteJson??A.errorSimpleRouteJson:A.endSimpleRouteJson,t=g.filter(i=>!Cdo.has(i.type)&&!i.type.endsWith("_error")&&!i.type.endsWith("_warning"));if(!e)return t;const o=I==="input"?e.traces??[]:edo(A),B=new Set(g.filter(i=>i.type==="source_trace").map(i=>i.source_trace_id)),C=["top",...Array.from({length:Math.max(0,e.layerCount-2)},(i,E)=>`inner${E+1}`),...e.layerCount>1?["bottom"]:[]],Q=[];for(const i of o){const n=e.connections.find(r=>r.name===i.connection_name||r.source_trace_id===i.connection_name)?.source_trace_id??i.connection_name??"",s=mxI(i,e);for(const[r,a]of s.entries()){const c={type:"pcb_trace",pcb_trace_id:`${A.id}_${I}_${i.pcb_trace_id}_${r}_${Bdo(a)}`,subcircuit_id:A.subcircuit_id??void 0,source_trace_id:B.has(n)?n:void 0,route:a};Q.push(c);for(const[h,l]of a.entries()){if(l.route_type!=="via")continue;const D=C.indexOf(l.from_layer),d=C.indexOf(l.to_layer),y={type:"pcb_via",pcb_via_id:`${c.pcb_trace_id}_via_${h}`,pcb_trace_id:c.pcb_trace_id,subcircuit_id:A.subcircuit_id??void 0,x:l.x,y:l.y,outer_diameter:l.outer_diameter,hole_diameter:l.hole_diameter,layers:D>=0&&d>=0?C.slice(Math.min(D,d),Math.max(D,d)+1):[l.from_layer,l.to_layer]};Q.push(y)}}}return[...t,...Q]}const ztg=(g,A)=>g.phaseName||`Phase ${g.phaseOrdinal??A+1}`,pxI=g=>g.componentDisplayName?.match(/name="([^"]+)"/)?.[1]?.replace(/^\./,"")||g.componentDisplayName||g.subcircuit_id||"Board",kxI=g=>g.startSimpleRouteJson??g.endSimpleRouteJson??g.errorSimpleRouteJson,ido={is_showing_autorouting:!0,is_showing_rats_nest:!1,is_showing_drc_errors:!1,is_showing_drc_warnings:!1,is_showing_pcb_groups:!1},Edo=({circuitJson:g,phases:A=[],isRunning:I=!1})=>{const[e,t]=X.useState(null),[o,B]=X.useState("output"),[C,Q]=X.useState(!0),[i,E]=X.useState(!1),n=X.useRef(null),[s,r]=X.useState(480),a=e?A.findIndex(N=>N.id===e.id&&kxI(N)===kxI(e)):-1,c=a<0?A.length-1:a,h=A[c],l=a<0,D=!!h?.endSimpleRouteJson,d=h?.startSimpleRouteJson??h?.errorSimpleRouteJson,y=!!d,w=o==="output"&&!D?"input":o==="input"&&!y?"output":o,u=w==="input"?d:h?.endSimpleRouteJson,G=X.useMemo(()=>!h||!u?null:Qdo(g??[],h,w),[g,h,u,w]),m=X.useMemo(()=>h&&w==="output"&&C?odo(h):{lines:[],circles:[]},[h,w,C]);if(X.useLayoutEffect(()=>{const N=n.current;if(!N)return;const J=()=>r(Math.max(360,N.clientHeight));J();const K=new ResizeObserver(J);return K.observe(N),()=>K.disconnect()},[!!h]),!h)return q.jsxs("div",{className:"rf-flex rf-min-h-[400px] rf-flex-col rf-items-center rf-justify-center rf-gap-3 rf-p-8 rf-text-center",children:[q.jsx(QfI,{className:"rf-h-7 rf-w-7 rf-text-blue-500"}),q.jsx("h3",{className:"rf-text-base rf-font-medium",children:I?"Waiting for autorouting":"No autorouting captures"}),q.jsx("p",{className:"rf-max-w-md rf-text-sm rf-text-gray-500",children:I?"Phases appear as the circuit routes. Each capture includes its input and output on the PCB.":"Run a circuit with autorouting enabled to inspect its phases. A circuit JSON file alone does not include routing history."})]});const p=ztg(h,c),k=h.status==="running"&&I,S=!D,R=d?.connections.length,x=G?.filter(N=>N.type==="pcb_trace").length??0;return q.jsxs("div",{className:"rf-flex rf-h-full rf-min-h-[620px] rf-flex-col rf-bg-white md:rf-flex-row","data-testid":"autorouting-explorer",children:[q.jsxs("aside",{className:"rf-flex rf-shrink-0 rf-flex-col rf-border-b rf-border-gray-200 md:rf-w-52 md:rf-border-b-0 md:rf-border-r","aria-label":"Routing phases",children:[q.jsxs("div",{className:"rf-flex rf-items-center rf-justify-between rf-px-3 rf-py-2 rf-text-xs rf-text-gray-500",children:[q.jsx("span",{children:"Routing phases"}),q.jsx("span",{children:A.length})]}),q.jsx("div",{className:"rf-flex rf-gap-1 rf-overflow-x-auto rf-px-1.5 rf-pb-1.5 md:rf-flex-col md:rf-overflow-x-hidden md:rf-overflow-y-auto",children:A.map((N,J)=>{const K=GxI(N).length,_=N.endSimpleRouteJson?`${K} ${K===1?"trace":"traces"} routed`:N.status==="error"?"Failed":N.status==="running"&&I?"Routing…":"No output";return q.jsxs("button",{type:"button","aria-pressed":J===c,title:`${pxI(N)} · ${_}`,onClick:()=>t(N),className:to("rf-flex rf-min-w-[192px] rf-items-start rf-gap-2 rf-rounded-md rf-border rf-px-2 rf-py-2 rf-text-left md:rf-min-w-0",J===c?"rf-border-blue-200 rf-bg-blue-50":"rf-border-transparent hover:rf-bg-gray-50"),children:[q.jsx("span",{className:to("rf-flex rf-h-5 rf-w-5 rf-shrink-0 rf-items-center rf-justify-center rf-rounded-full rf-text-[11px]",J===c?"rf-bg-blue-600 rf-text-white":"rf-bg-gray-100 rf-text-gray-500"),children:J+1}),q.jsxs("span",{className:"rf-min-w-0 rf-flex-1",children:[q.jsxs("span",{className:"rf-flex rf-items-center rf-gap-1",children:[q.jsx("span",{className:"rf-min-w-0 rf-flex-1 rf-truncate rf-text-xs rf-font-medium rf-leading-5 rf-text-gray-800",title:ztg(N,J),children:ztg(N,J)}),N.status==="complete"?q.jsx(yJ,{"aria-label":"Captured",className:"rf-h-3 rf-w-3 rf-shrink-0 rf-text-green-600"}):N.status==="error"?q.jsx(ceg,{"aria-label":"Failed",className:"rf-h-3 rf-w-3 rf-shrink-0 rf-text-red-500"}):I?q.jsx(QS,{"aria-label":"Routing",className:"rf-h-3 rf-w-3 rf-shrink-0 rf-animate-spin rf-text-blue-500"}):null]}),q.jsxs("span",{className:"rf-block rf-text-[11px] rf-leading-4 rf-text-gray-500",children:[Ido(N)," · ",_]})]})]},N.id)})})]}),q.jsxs("div",{className:"rf-flex rf-min-w-0 rf-flex-1 rf-flex-col",children:[q.jsxs("div",{className:"rf-flex rf-flex-wrap rf-items-center rf-gap-3 rf-border-b rf-border-gray-200 rf-px-4 rf-py-3",children:[q.jsxs("h3",{className:"rf-mr-auto rf-flex rf-items-center rf-gap-2 rf-text-sm rf-font-medium",children:[p,q.jsxs("span",{className:"rf-text-xs rf-font-normal rf-text-gray-500",children:[c+1," of ",A.length]})]}),I&&q.jsx("button",{type:"button",onClick:()=>t(null),disabled:l,className:"rf-text-xs rf-text-blue-600 disabled:rf-text-gray-500",children:l?"Following latest":"Follow latest"}),q.jsx("div",{className:"rf-flex rf-rounded-md rf-bg-gray-100 rf-p-1","aria-label":"Phase snapshot",children:["input","output"].map(N=>q.jsx("button",{type:"button","aria-pressed":w===N,disabled:N==="input"?!y:!D,onClick:()=>B(N),className:to("rf-rounded rf-px-3 rf-py-1 rf-text-xs disabled:rf-opacity-40",w===N?"rf-bg-white rf-text-gray-900 rf-shadow-sm":"rf-text-gray-500"),children:N==="input"?"Input":"Output"},N))})]}),q.jsxs("div",{className:"rf-flex rf-flex-wrap rf-items-center rf-justify-between rf-gap-2 rf-px-4 rf-py-2 rf-text-xs rf-text-gray-600",children:[q.jsxs("label",{className:"rf-flex rf-items-center rf-gap-2",children:[q.jsx("input",{type:"checkbox",checked:C,disabled:w!=="output",onChange:N=>Q(N.target.checked),className:"rf-accent-blue-600"}),q.jsx("span",{"aria-hidden":"true",className:"rf-inline-block rf-h-0.5 rf-w-3",style:{backgroundColor:jtg}}),"Highlight changes (all layers)"]}),q.jsxs("span",{children:[w==="input"?"Before this phase":"After this phase"," ","· ",x," traces"]})]}),S&&q.jsx("div",{className:to("rf-border-y rf-px-4 rf-py-2 rf-text-xs",h.status==="error"?"rf-border-red-100 rf-bg-red-50 rf-text-red-700":"rf-border-blue-100 rf-bg-blue-50 rf-text-blue-700"),role:"status",children:h.status==="error"?`Routing failed: ${h.error?.message||"No output was captured."}`:k?"Routing in progress. Showing captured input until output is available.":"No output was captured for this phase. Showing the available input."}),q.jsx("div",{ref:n,className:"rf-relative rf-min-h-[360px] rf-flex-1","data-testid":"autorouting-pcb",children:G?q.jsx(seg,{circuitJson:G,height:s,allowEditing:!1,clickToInteractEnabled:!1,initialState:ido,debugGraphics:m}):q.jsx("div",{className:"rf-p-6 rf-text-sm rf-text-gray-500",children:"No PCB snapshot available for this capture."})}),q.jsxs("div",{className:"rf-flex rf-flex-wrap rf-items-center rf-justify-between rf-gap-2 rf-border-t rf-border-gray-200 rf-px-4 rf-py-3 rf-text-xs rf-text-gray-500",children:[q.jsxs("span",{children:[R===void 0?"Input unavailable":`${R} input connections`,` · ${pxI(h)}`]}),q.jsxs("div",{className:"rf-flex rf-items-center rf-gap-4",children:[q.jsxs("button",{type:"button",disabled:!u,onClick:()=>pk(JSON.stringify(u,null,2),{fileName:`${h.id}-${w}.srj.json`,mimeType:"application/json"}),className:"rf-flex rf-items-center rf-gap-1 disabled:rf-opacity-40",children:[q.jsx(EeA,{className:"rf-h-3 rf-w-3"}),"Download SRJ"]}),q.jsxs("button",{type:"button","aria-expanded":i,onClick:()=>E(!i),className:"rf-flex rf-items-center rf-gap-1",children:[q.jsx(K5,{className:to("rf-h-3 rf-w-3",i&&"rf-rotate-90")}),"Inspect SRJ"]})]})]}),i&&q.jsx("pre",{className:"rf-m-0 rf-max-h-64 rf-overflow-auto rf-border-t rf-border-gray-200 rf-bg-gray-50 rf-p-4 rf-text-xs","aria-label":`${p} ${w} SRJ`,children:u?JSON.stringify(u,null,2):"No snapshot captured."})]})]})},MxI=({errorMessage:g,errorStack:A,circuitJsonErrors:I})=>{X.useEffect(()=>{if(ZU("TSCIRCUIT_TELEMETRY_DISABLED")!==!0&&g){const e=new Error(g);A&&(e.stack=A);try{Pq.captureException(e)}catch{}}},[g,A]),X.useEffect(()=>{if(ZU("TSCIRCUIT_TELEMETRY_DISABLED")!==!0&&I&&I.length>0)for(const e of I){const t=new Error(e.message||"Circuit JSON Error");e.stack&&(t.stack=e.stack);try{Pq.captureException(t,{error_type:e.type})}catch{}}},[I])},SxI=g=>{X.useEffect(()=>{try{sht(g)}catch{}},[g.source,g.component,g.isWebEmbedded,g.activeTab])},fxI="0.0.3008",ndo={version:fxI},aGA=bVg()(HVg(g=>({lastRunEvalVersion:void 0,setLastRunEvalVersion:A=>{g({lastRunEvalVersion:A})}}),{name:"runframe-runner-store"})),sdo=g=>{const[A,I]=X.useState([]),[e,t]=X.useState(null),[o,B]=X.useState(""),[C,Q]=oq("eval-version-selection",null),i=aGA(r=>r.setLastRunEvalVersion),E=aGA(r=>r.lastRunEvalVersion);return X.useEffect(()=>{g&&fetch("https://data.jsdelivr.com/v1/package/npm/@tscircuit/eval").then(r=>r.json()).then(r=>{if(Array.isArray(r?.versions)){let a=[...r.versions];r.tags?.latest&&(t(r.tags.latest),a=a.filter(c=>c!==r.tags.latest)),I(a)}}).catch(()=>{})},[g]),X.useEffect(()=>{g&&(C?(window.TSCIRCUIT_LATEST_EVAL_VERSION=C,i(C)):e&&(window.TSCIRCUIT_LATEST_EVAL_VERSION=e,i(e)))},[g,C,e]),{versions:X.useMemo(()=>A.filter(r=>r.includes(o)).slice(0,50),[A,o]),latestVersion:e,lastRunEvalVersion:E,search:o,setSearch:B,selectVersion:r=>{Q(r),B("")}}},ado=({snippetNames:g,onSelect:A,onCancel:I,isOpen:e})=>{const[t,o]=X.useState(""),[B,C]=X.useState("");if(!e)return null;const Q=g.filter(n=>n.toLowerCase().includes(B.toLowerCase())),i=B&&!g.includes(B),E=n=>{n.key==="Enter"&&(Q.length===1?o(Q[0]):i&&o(B))};return q.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:q.jsxs("div",{className:"rf-bg-white rf-rounded-lg rf-p-6 rf-w-96",children:[q.jsx("h2",{className:"rf-text-lg rf-font-semibold rf-mb-4",children:"Select Snippet"}),q.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:B,onChange:n=>C(n.target.value),onKeyDown:E}),q.jsxs("div",{className:"rf-h-60 rf-overflow-y-auto",children:[Q.map(n=>q.jsx("button",{type:"button",className:`w-full text-left px-4 py-2 rounded hover:bg-gray-100 ${t===n?"bg-blue-50":""}`,onClick:()=>o(n),children:n},n)),i&&q.jsxs("button",{type:"button",className:`w-full text-left px-4 py-2 rounded hover:bg-gray-100 text-blue-500 ${t===B?"bg-blue-50":""}`,onClick:()=>o(B),children:['Create new "',B,'"']})]}),q.jsxs("div",{className:"rf-mt-4 rf-flex rf-justify-end rf-gap-2",children:[q.jsx("button",{type:"button",className:"rf-px-4 rf-py-2 rf-text-gray-600 rf-hover:text-gray-800",onClick:I,children:"Cancel"}),q.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:()=>t&&A(t),disabled:!t,children:t===B?`Create "${t}"`:`Save to ${t}`})]})]})})},rdo=g=>{const A=X.useRef(null),I=Fc(e=>e.recentEvents);X.useEffect(()=>{if(I.length===0)return;const e=I[0];e.event_id!==A.current&&(g(e),A.current=e.event_id)},[I,g])};var cdo=Object.defineProperty,fJ=(g,A)=>cdo(g,"name",{value:A,configurable:!0}),hdo="AlertDialog",[ldo,yAB]=Ak(hdo,[JRI]),RJ=JRI(),Ddo=fJ(g=>{const{__scopeAlertDialog:A,...I}=g,e=RJ(A);return q.jsx(fuA,{...e,...I,modal:!0})},"AlertDialog");X.forwardRef(fJ(function(A,I){const{__scopeAlertDialog:e,...t}=A,o=RJ(e);return q.jsx(ano,{...o,...t,ref:I})},"AlertDialogTrigger"));var ddo=fJ(g=>{const{__scopeAlertDialog:A,...I}=g,e=RJ(A);return q.jsx(RuA,{...e,...I})},"AlertDialogPortal"),RxI=X.forwardRef(fJ(function(A,I){const{__scopeAlertDialog:e,...t}=A,o=RJ(e);return q.jsx(GeA,{...o,...t,ref:I})},"AlertDialogOverlay")),ydo="AlertDialogContent",[wdo,udo]=ldo(ydo),NxI=X.forwardRef(fJ(function(A,I){const{__scopeAlertDialog:e,children:t,...o}=A,B=RJ(e),C=X.useRef(null),Q=wi(I,C),i=X.useRef(null);return q.jsx(wdo,{scope:e,cancelRef:i,children:q.jsx(peA,{role:"alertdialog",...B,...o,ref:Q,onOpenAutoFocus:Mo(o.onOpenAutoFocus,E=>{E.preventDefault(),i.current?.focus({preventScroll:!0})}),onPointerDownOutside:E=>E.preventDefault(),onInteractOutside:E=>E.preventDefault(),children:t})})},"AlertDialogContent")),xxI=X.forwardRef(fJ(function(A,I){const{__scopeAlertDialog:e,...t}=A,o=RJ(e);return q.jsx(NuA,{...o,...t,ref:I})},"AlertDialogTitle")),FxI=X.forwardRef(fJ(function(A,I){const{__scopeAlertDialog:e,...t}=A,o=RJ(e);return q.jsx(xuA,{...o,...t,ref:I})},"AlertDialogDescription")),UxI=X.forwardRef(fJ(function(A,I){const{__scopeAlertDialog:e,...t}=A,o=RJ(e);return q.jsx(etg,{...o,...t,ref:I})},"AlertDialogAction")),Gdo="AlertDialogCancel",JxI=X.forwardRef(fJ(function(A,I){const{__scopeAlertDialog:e,...t}=A,{cancelRef:o}=udo(Gdo,e),B=RJ(e),C=wi(I,o);return q.jsx(etg,{...B,...t,ref:C})},"AlertDialogCancel"));const PxI=Ddo,mdo=ddo,KxI=X.forwardRef(({className:g,...A},I)=>q.jsx(RxI,{className:to("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",g),...A,ref:I}));KxI.displayName=RxI.displayName;const Xtg=X.forwardRef(({className:g,...A},I)=>q.jsxs(mdo,{children:[q.jsx(KxI,{}),q.jsx(NxI,{ref:I,className:to("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",g),...A})]}));Xtg.displayName=NxI.displayName;const $tg=({className:g,...A})=>q.jsx("div",{className:to("rf-flex rf-flex-col rf-space-y-2 rf-text-center sm:rf-text-left",g),...A});$tg.displayName="AlertDialogHeader";const Aog=({className:g,...A})=>q.jsx("div",{className:to("rf-flex rf-flex-col-reverse sm:rf-flex-row sm:rf-justify-end sm:rf-space-x-2",g),...A});Aog.displayName="AlertDialogFooter";const gog=X.forwardRef(({className:g,...A},I)=>q.jsx(xxI,{ref:I,className:to("rf-text-lg rf-font-semibold",g),...A}));gog.displayName=xxI.displayName;const Iog=X.forwardRef(({className:g,...A},I)=>q.jsx(FxI,{ref:I,className:to("rf-text-sm rf-text-zinc-500 dark:rf-text-zinc-400",g),...A}));Iog.displayName=FxI.displayName;const pdo=X.forwardRef(({className:g,...A},I)=>q.jsx(UxI,{ref:I,className:to(oZ(),g),...A}));pdo.displayName=UxI.displayName;const eog=X.forwardRef(({className:g,...A},I)=>q.jsx(JxI,{ref:I,className:to(oZ({variant:"outline"}),"rf-mt-2 sm:rf-mt-0",g),...A}));eog.displayName=JxI.displayName;var kdo=Object.defineProperty,NJ=(g,A)=>kdo(g,"name",{value:A,configurable:!0}),tog="Checkbox",[Mdo,wAB]=Ak(tog),[Sdo,oog]=Mdo(tog);function LxI(g){const{__scopeCheckbox:A,checked:I,children:e,defaultChecked:t,disabled:o,form:B,name:C,onCheckedChange:Q,required:i,value:E="on",internal_do_not_use_render:n}=g,[s,r]=nR({prop:I,defaultProp:t??!1,onChange:Q,caller:tog}),[a,c]=X.useState(null),[h,l]=X.useState(null),[D,d]=X.useState(null),y=a?!!B||!!a.closest("form"):!0,w={checked:s,disabled:o,setChecked:r,control:a,setControl:c,name:C,form:B,value:E,userClick:D,onUserClick:d,required:i,defaultChecked:Af(t)?!1:t,isFormControl:y,bubbleInput:h,setBubbleInput:l};return q.jsx(Sdo,{scope:A,...w,children:_xI(n)?n(w):e})}NJ(LxI,"CheckboxProvider");var fdo="CheckboxTrigger",Rdo=X.forwardRef(NJ(function({__scopeCheckbox:A,onKeyDown:I,onClick:e,...t},o){const{control:B,value:C,disabled:Q,checked:i,required:E,setControl:n,setChecked:s,onUserClick:r,isFormControl:a,bubbleInput:c}=oog(fdo,A),h=wi(o,n),l=X.useRef(i);return X.useEffect(()=>{const D=B?.form;if(D){const d=NJ(()=>s(l.current),"reset");return D.addEventListener("reset",d),()=>D.removeEventListener("reset",d)}},[B,s]),q.jsx(dQ.button,{type:"button",role:"checkbox","aria-checked":Af(i)?"mixed":i,"aria-required":E,"data-state":Bog(i),"data-disabled":Q?"":void 0,disabled:Q,value:C,...t,ref:h,onKeyDown:Mo(I,D=>{D.key==="Enter"&&D.preventDefault()}),onClick:Mo(e,D=>{const d=D.isPropagationStopped();r({requestedChecked:Af(i)?!0:!i,hasConsumerStoppedPropagation:d}),s(y=>Af(y)?!0:!y),c&&a&&(d||D.stopPropagation())})})},"CheckboxTrigger")),YxI=X.forwardRef(NJ(function(A,I){const{__scopeCheckbox:e,name:t,checked:o,defaultChecked:B,required:C,disabled:Q,value:i,onCheckedChange:E,form:n,...s}=A;return q.jsx(LxI,{__scopeCheckbox:e,checked:o,defaultChecked:B,disabled:Q,required:C,onCheckedChange:E,name:t,form:n,value:i,internal_do_not_use_render:({isFormControl:r})=>q.jsxs(q.Fragment,{children:[q.jsx(Rdo,{...s,ref:I,__scopeCheckbox:e}),r&&q.jsx(Udo,{__scopeCheckbox:e})]})})},"Checkbox")),Ndo="CheckboxIndicator",xdo=X.forwardRef(NJ(function(A,I){const{__scopeCheckbox:e,forceMount:t,...o}=A,B=oog(Ndo,e);return q.jsx(LM,{present:t||Af(B.checked)||B.checked===!0,children:q.jsx(dQ.span,{"data-state":Bog(B.checked),"data-disabled":B.disabled?"":void 0,...o,ref:I,style:{pointerEvents:"none",...A.style}})})},"CheckboxIndicator")),Fdo="CheckboxBubbleInput",Udo=X.forwardRef(NJ(function({__scopeCheckbox:A,onClick:I,...e},t){const{control:o,userClick:B,checked:C,defaultChecked:Q,required:i,disabled:E,name:n,value:s,form:r,bubbleInput:a,setBubbleInput:c}=oog(Fdo,A),h=wi(t,c),l=Leg(o),D=X.useRef(!1),d=X.useRef(C),y=X.useRef(B),w=X.useRef(null);X.useEffect(()=>{const G=a;if(!G)return;const m=window.HTMLInputElement.prototype,k=Object.getOwnPropertyDescriptor(m,"checked").set;if(!k)return;const S=d.current!==C;d.current=C;const R=B!==null&&B!==y.current;if(y.current=B,R)w.current=S?null:B,S&&(G.indeterminate=Af(C),k.call(G,Af(C)?!1:C)),G.dispatchEvent(new Event("click",{bubbles:!B.hasConsumerStoppedPropagation}));else if(S){const x=w.current;w.current=null;const N=x?.requestedChecked===C;D.current=!0,G.indeterminate=Af(C),k.call(G,Af(C)?!1:C),G.dispatchEvent(new Event("click",{bubbles:!(N&&x.hasConsumerStoppedPropagation)})),D.current=!1}},[a,C,B]);const u=X.useRef(Af(C)?!1:C);return q.jsx(dQ.input,{type:"checkbox","aria-hidden":!0,defaultChecked:Q??u.current,required:i,disabled:E,name:n,value:s,form:r,...e,tabIndex:-1,ref:h,onClick:Mo(I,G=>{D.current&&G.stopPropagation()}),style:{...e.style,...l,position:"absolute",pointerEvents:"none",opacity:0,margin:0,transform:"translateX(-100%)"}})},"CheckboxBubbleInput"));function _xI(g){return typeof g=="function"}NJ(_xI,"isFunction");function Af(g){return g==="indeterminate"}NJ(Af,"isIndeterminate");function Bog(g){return Af(g)?"indeterminate":g?"checked":"unchecked"}NJ(Bog,"getState");const OeA=X.forwardRef(({className:g,...A},I)=>q.jsx(YxI,{ref:I,className:to("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",g),...A,children:q.jsx(xdo,{className:to("rf-flex rf-items-center rf-justify-center rf-text-current"),children:q.jsx(yJ,{className:"rf-h-4 rf-w-4"})})}));OeA.displayName=YxI.displayName;const Z5=fuA,Jdo=RuA,bxI=X.forwardRef(({className:g,...A},I)=>q.jsx(GeA,{className:to("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",g),...A,ref:I}));bxI.displayName=GeA.displayName;const q3=X.forwardRef(({className:g,children:A,showOverlay:I=!0,...e},t)=>q.jsxs(Jdo,{children:[q.jsx(bxI,{className:to(I?"":"rf-hidden")}),q.jsx(peA,{ref:t,className:to("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",g),...e,children:A})]}));q3.displayName=peA.displayName;const T3=({className:g,...A})=>q.jsx("div",{className:to("rf-flex rf-flex-col rf-space-y-2 rf-text-center sm:rf-text-left",g),...A});T3.displayName="DialogHeader";const FZ=({className:g,...A})=>q.jsx("div",{className:to("rf-flex rf-flex-col-reverse sm:rf-flex-row sm:rf-justify-end sm:rf-space-x-2",g),...A});FZ.displayName="DialogFooter";const Z3=X.forwardRef(({className:g,...A},I)=>q.jsx(NuA,{ref:I,className:to("rf-text-lg rf-font-semibold",g),...A}));Z3.displayName=NuA.displayName;const O5=X.forwardRef(({className:g,...A},I)=>q.jsx(xuA,{ref:I,className:to("rf-text-sm rf-text-zinc-500 dark:rf-text-zinc-400",g),...A}));O5.displayName=xuA.displayName;const rGA={"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"}},Pdo="https://cdn.jsdelivr.net/npm/easyeda@latest/dist/browser/index.js";let Cog=null;const Qog=async()=>(Cog||(Cog=import(Pdo)),Cog),Kdo=g=>(A,I)=>{const e=new Headers(I?.headers),t={};return e.forEach((o,B)=>{t[B]=o}),fetch(`${g?.apiBase??Dm}/proxy`,{...I,headers:{...t,"X-Target-Url":A.toString(),"X-Sender-Origin":t.origin??"","X-Sender-Host":t.host??"https://easyeda.com","X-Sender-Referer":t.referer??"","X-Sender-User-Agent":t["user-agent"]??"","X-Sender-Cookie":t.cookie??"",authority:t.authority??"","content-type":t["content-type"]??"",...g?.headers}})},Ldo=async(g,A=10)=>{const I=encodeURIComponent(g),e=await fetch(`https://jlcsearch.tscircuit.com/api/search?limit=${A}&q=${I}`);if(!e.ok)throw new Error(`JLCPCB API error: ${e.status}`);return(await e.json()).components??[]},Ydo=g=>({lcscId:g.lcsc,manufacturer:g.mfr,description:g.description,partNumber:`C${g.lcsc}`,package:g.package,price:g.price,stock:g.stock,isBasic:g.is_basic}),HxI=async(g,A)=>{const{fetchEasyEDAComponent:I}=await Qog();return I(g,{fetch:Kdo(A),includeModelMetadata:A?.includeModelMetadata})},_do=async(g,A)=>{const{convertRawEasyToTsx:I}=await Qog(),e=await HxI(g,A);return I({rawEasy:e})},bdo=async(g,A)=>{const{EasyEdaJsonSchema:I,convertEasyEdaJsonToCircuitJson:e}=await Qog(),t=await HxI(g,{...A,includeModelMetadata:!1}),o=I.parse(t);return e(o,{shouldRecenter:!0,showDesignator:!0,useModelCdn:!1})};function O3(g){return Array.isArray?Array.isArray(g):qxI(g)==="[object Array]"}function Hdo(g){if(typeof g=="string")return g;if(typeof g=="bigint")return g.toString();const A=g+"";return A=="0"&&1/g==-1/0?"-0":A}function iog(g){return g==null?"":Hdo(g)}function BG(g){return typeof g=="string"}function cGA(g){return typeof g=="number"}function vdo(g){return g===!0||g===!1||qdo(g)&&qxI(g)=="[object Boolean]"}function vxI(g){return typeof g=="object"}function qdo(g){return vxI(g)&&g!==null}function cS(g){return g!=null}function hGA(g){return!g.trim().length}function qxI(g){return g==null?g===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(g)}const Tdo="Incorrect 'index' type",Eog="Invalid doc index: must be a non-negative integer within the bounds of the docs array",Zdo=g=>`Invalid value for key ${g}`,Odo=g=>`Pattern length exceeds max of ${g}.`,Wdo=g=>`Missing ${g} property in key`,Vdo=g=>`Property 'weight' in key '${g}' must be a positive integer`,jdo="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.",TxI=Object.prototype.hasOwnProperty;var zdo=class{constructor(g){this._keys=[],this._keyMap={};let A=0;g.forEach(I=>{const e=ZxI(I);this._keys.push(e),this._keyMap[e.id]=e,A+=e.weight}),this._keys.forEach(I=>{I.weight/=A})}get(g){return this._keyMap[g]}keys(){return this._keys}toJSON(){return JSON.stringify(this._keys)}};function ZxI(g){let A=null,I=null,e=null,t=1,o=null;if(BG(g)||O3(g))e=g,A=OxI(g),I=lGA(g);else{if(!TxI.call(g,"name"))throw new Error(Wdo("name"));const B=g.name;if(e=B,TxI.call(g,"weight")&&g.weight!==void 0&&(t=g.weight,t<=0))throw new Error(Vdo(lGA(B)));A=OxI(B),I=lGA(B),o=g.getFn??null}return{path:A,id:I,weight:t,src:e,getFn:o}}function OxI(g){return O3(g)?g:g.split(".")}function lGA(g){return O3(g)?g.join("."):g}function Xdo(g,A){const I=[];let e=!1;const t=(o,B,C,Q)=>{if(cS(o))if(!B[C])I.push(Q!==void 0?{v:o,i:Q}:o);else{const i=o[B[C]];if(!cS(i))return;if(C===B.length-1&&(BG(i)||cGA(i)||vdo(i)||typeof i=="bigint"))I.push(Q!==void 0?{v:iog(i),i:Q}:iog(i));else if(O3(i)){e=!0;for(let E=0,n=i.length;E<n;E+=1)t(i[E],B,C+1,E)}else B.length&&t(i,B,C+1,Q)}};return t(g,BG(A)?A.split("."):A,0),e?I:I[0]}const rQ=Object.freeze({...{isCaseSensitive:!1,ignoreDiacritics:!1,includeScore:!1,keys:[],shouldSort:!0,sortFn:(g,A)=>g.score===A.score?g.idx<A.idx?-1:1:g.score<A.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:Xdo,ignoreLocation:!1,ignoreFieldNorm:!1,fieldNormWeight:1}});function $do(g){return g>=9&&g<=13||g===32||g===160}function Ayo(g=1,A=3){const I=new Map,e=Math.pow(10,A);return{get(t){let o=0,B=!1;for(let Q=0;Q<t.length;Q++)$do(t.charCodeAt(Q))?B=!1:B||(o++,B=!0);if(o===0&&(o=1),I.has(o))return I.get(o);const C=Math.round(e/Math.pow(o,.5*g))/e;return I.set(o,C),C},clear(){I.clear()}}}var nog=class{constructor({getFn:g=rQ.getFn,fieldNormWeight:A=rQ.fieldNormWeight}={}){this.norm=Ayo(A,3),this.getFn=g,this.isCreated=!1,this.docs=[],this.keys=[],this._keysMap={},this.setIndexRecords()}setSources(g=[]){this.docs=g}setIndexRecords(g=[]){this.records=g}setKeys(g=[]){this.keys=g,this._keysMap={},g.forEach((A,I)=>{this._keysMap[A.id]=I})}create(){if(this.isCreated||!this.docs.length)return;this.isCreated=!0;const g=this.docs.length;this.records=new Array(g);let A=0;if(BG(this.docs[0]))for(let I=0;I<g;I++){const e=this._createStringRecord(this.docs[I],I);e&&(this.records[A++]=e)}else for(let I=0;I<g;I++)this.records[A++]=this._createObjectRecord(this.docs[I],I);this.records.length=A,this.norm.clear()}add(g,A){if(!Number.isInteger(A)||A<0)throw new Error(Eog);if(BG(g)){const e=this._createStringRecord(g,A);return e&&this.records.push(e),e}const I=this._createObjectRecord(g,A);return this.records.push(I),I}removeAt(g){if(!Number.isInteger(g)||g<0)throw new Error(Eog);for(let A=0,I=this.records.length;A<I;A+=1)if(this.records[A].i===g){this.records.splice(A,1);break}for(let A=0,I=this.records.length;A<I;A+=1)this.records[A].i>g&&(this.records[A].i-=1)}removeAll(g){const A=new Set;for(const e of g)Number.isInteger(e)&&e>=0&&A.add(e);if(A.size===0)return;this.records=this.records.filter(e=>!A.has(e.i));const I=Array.from(A).sort((e,t)=>e-t);for(const e of this.records){let t=0,o=I.length;for(;t<o;){const B=t+o>>>1;I[B]<e.i?t=B+1:o=B}e.i-=t}}getValueForItemAtKeyId(g,A){return g[this._keysMap[A]]}size(){return this.records.length}_createStringRecord(g,A){return!cS(g)||hGA(g)?null:{v:g,i:A,n:this.norm.get(g)}}_createObjectRecord(g,A){const I={i:A,$:{}};for(let e=0,t=this.keys.length;e<t;e++){const o=this.keys[e],B=o.getFn?o.getFn(g):this.getFn(g,o.path);if(cS(B)){if(O3(B)){const C=[];for(let Q=0,i=B.length;Q<i;Q+=1){const E=B[Q];if(cS(E)){if(BG(E)){if(!hGA(E)){const n={v:E,i:Q,n:this.norm.get(E)};C.push(n)}}else if(cS(E.v)){const n=BG(E.v)?E.v:iog(E.v);if(!hGA(n)){const s={v:n,i:E.i,n:this.norm.get(n)};C.push(s)}}}}I.$[e]=C}else if(BG(B)&&!hGA(B)){const C={v:B,n:this.norm.get(B)};I.$[e]=C}}}return I}toJSON(){return{keys:this.keys.map(({getFn:g,...A})=>A),records:this.records}}};function WxI(g,A,{getFn:I=rQ.getFn,fieldNormWeight:e=rQ.fieldNormWeight}={}){const t=new nog({getFn:I,fieldNormWeight:e});return t.setKeys(g.map(ZxI)),t.setSources(A),t.create(),t}function gyo(g,{getFn:A=rQ.getFn,fieldNormWeight:I=rQ.fieldNormWeight}={}){const{keys:e,records:t}=g,o=new nog({getFn:A,fieldNormWeight:I});return o.setKeys(e),o.setIndexRecords(t),o}function Iyo(g=[],A=rQ.minMatchCharLength){const I=[];let e=-1,t=-1,o=0;for(let B=g.length;o<B;o+=1){const C=g[o];C&&e===-1?e=o:!C&&e!==-1&&(t=o-1,t-e+1>=A&&I.push([e,t]),e=-1)}return g[o-1]&&o-e>=A&&I.push([e,o-1]),I}function eyo(g,A,I,{location:e=rQ.location,distance:t=rQ.distance,threshold:o=rQ.threshold,findAllMatches:B=rQ.findAllMatches,minMatchCharLength:C=rQ.minMatchCharLength,includeMatches:Q=rQ.includeMatches,ignoreLocation:i=rQ.ignoreLocation}={}){if(A.length>32)throw new Error(Odo(32));const E=A.length,n=g.length,s=Math.max(0,Math.min(e,n));let r=o,a=s;const c=(p,k)=>{const S=p/E;if(i)return S;const R=Math.abs(s-k);return t?S+R/t:R?1:S},h=C>1||Q,l=h?Array(n):[];let D;for(;(D=g.indexOf(A,a))>-1;){const p=c(0,D);if(r=Math.min(p,r),a=D+E,h){let k=0;for(;k<E;)l[D+k]=1,k+=1}}a=-1;let d=[],y=1,w=0,u=E+n;const G=1<<E-1;for(let p=0;p<E;p+=1){let k=0,S=u;for(;k<S;)c(p,s+S)<=r?k=S:u=S,S=Math.floor((u-k)/2+k);u=S;let R=Math.max(1,s-S+1);const x=B?n:Math.min(s+S,n)+E,N=Array(x+2);N[x+1]=(1<<p)-1;for(let J=x;J>=R;J-=1){const K=J-1,_=I[g[K]];if(N[J]=(N[J+1]<<1|1)&_,p&&(N[J]|=(d[J+1]|d[J])<<1|1|d[J+1]),N[J]&G&&(y=c(p,K),y<=r)){if(r=y,a=K,w=p,a<=s)break;R=Math.max(1,2*s-a)}}if(c(p+1,s)>r)break;d=N}if(h&&a>=0){const p=Math.min(n-1,a+E-1+w);for(let k=a;k<=p;k+=1)I[g[k]]&&(l[k]=1)}const m={isMatch:a>=0,score:Math.max(.001,y)};if(h){const p=Iyo(l,C);p.length?Q&&(m.indices=p):m.isMatch=!1}return m}function tyo(g){const A={};for(let I=0,e=g.length;I<e;I+=1){const t=g.charAt(I);A[t]=(A[t]||0)|1<<e-I-1}return A}function sog(g){if(g.length<=1)return g;g.sort((I,e)=>I[0]-e[0]||I[1]-e[1]);const A=[g[0]];for(let I=1,e=g.length;I<e;I+=1){const t=A[A.length-1],o=g[I];o[0]<=t[1]+1?t[1]=Math.max(t[1],o[1]):A.push(o)}return A}const VxI={ł:"l",Ł:"L",đ:"d",Đ:"D",ø:"o",Ø:"O",ħ:"h",Ħ:"H",ŧ:"t",Ŧ:"T",ı:"i",ß:"ss"},oyo=new RegExp("["+Object.keys(VxI).join("")+"]","g"),WeA=typeof String.prototype.normalize=="function"?g=>g.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(oyo,A=>VxI[A]):g=>g;var aog=class{constructor(g,{location:A=rQ.location,threshold:I=rQ.threshold,distance:e=rQ.distance,includeMatches:t=rQ.includeMatches,findAllMatches:o=rQ.findAllMatches,minMatchCharLength:B=rQ.minMatchCharLength,isCaseSensitive:C=rQ.isCaseSensitive,ignoreDiacritics:Q=rQ.ignoreDiacritics,ignoreLocation:i=rQ.ignoreLocation}={}){if(this.options={location:A,threshold:I,distance:e,includeMatches:t,findAllMatches:o,minMatchCharLength:B,isCaseSensitive:C,ignoreDiacritics:Q,ignoreLocation:i},g=C?g:g.toLowerCase(),g=Q?WeA(g):g,this.pattern=g,this.chunks=[],!this.pattern.length)return;const E=(s,r)=>{this.chunks.push({pattern:s,alphabet:tyo(s),startIndex:r})},n=this.pattern.length;if(n>32){let s=0;const r=n%32,a=n-r;for(;s<a;)E(this.pattern.substr(s,32),s),s+=32;if(r){const c=n-32;E(this.pattern.substr(c),c)}}else E(this.pattern,0)}searchIn(g){const{isCaseSensitive:A,ignoreDiacritics:I,includeMatches:e}=this.options;if(g=A?g:g.toLowerCase(),g=I?WeA(g):g,this.pattern===g){if(g.length<this.options.minMatchCharLength)return{isMatch:!1,score:1};const a={isMatch:!0,score:0};return e&&(a.indices=[[0,g.length-1]]),a}const{location:t,distance:o,threshold:B,findAllMatches:C,minMatchCharLength:Q,ignoreLocation:i}=this.options,E=[];let n=0,s=!1;this.chunks.forEach(({pattern:a,alphabet:c,startIndex:h})=>{const{isMatch:l,score:D,indices:d}=eyo(g,a,c,{location:t+h,distance:o,threshold:B,findAllMatches:C,minMatchCharLength:Q,includeMatches:e,ignoreLocation:i});l&&(s=!0),n+=D,l&&d&&E.push(...d)});const r={isMatch:s,score:s?n/this.chunks.length:1};return s&&e&&(r.indices=sog(E)),r}};const Byo=new Set(["fuzzy","include"]);function Cyo(g){return g.startsWith("inverse")}const rog=[{type:"exact",multiRegex:/^="(.*)"$/,singleRegex:/^=(.*)$/,create:g=>({type:"exact",search(A){const I=A===g;return{isMatch:I,score:I?0:1,indices:[0,g.length-1]}}})},{type:"include",multiRegex:/^'"(.*)"$/,singleRegex:/^'(.*)$/,create:g=>({type:"include",search(A){let I=0,e;const t=[],o=g.length;for(;(e=A.indexOf(g,I))>-1;)I=e+o,t.push([e,I-1]);const B=!!t.length;return{isMatch:B,score:B?0:1,indices:t}}})},{type:"prefix-exact",multiRegex:/^\^"(.*)"$/,singleRegex:/^\^(.*)$/,create:g=>({type:"prefix-exact",search(A){const I=A.startsWith(g);return{isMatch:I,score:I?0:1,indices:[0,g.length-1]}}})},{type:"inverse-prefix-exact",multiRegex:/^!\^"(.*)"$/,singleRegex:/^!\^(.*)$/,create:g=>({type:"inverse-prefix-exact",search(A){const I=!A.startsWith(g);return{isMatch:I,score:I?0:1,indices:[0,A.length-1]}}})},{type:"inverse-suffix-exact",multiRegex:/^!"(.*)"\$$/,singleRegex:/^!(.*)\$$/,create:g=>({type:"inverse-suffix-exact",search(A){const I=!A.endsWith(g);return{isMatch:I,score:I?0:1,indices:[0,A.length-1]}}})},{type:"suffix-exact",multiRegex:/^"(.*)"\$$/,singleRegex:/^(.*)\$$/,create:g=>({type:"suffix-exact",search(A){const I=A.endsWith(g);return{isMatch:I,score:I?0:1,indices:[A.length-g.length,A.length-1]}}})},{type:"inverse-exact",multiRegex:/^!"(.*)"$/,singleRegex:/^!(.*)$/,create:g=>({type:"inverse-exact",search(A){const I=A.indexOf(g)===-1;return{isMatch:I,score:I?0:1,indices:[0,A.length-1]}}})},{type:"fuzzy",multiRegex:/^"(.*)"$/,singleRegex:/^(.*)$/,create:(g,A={})=>{const I=new aog(g,{location:A.location??rQ.location,threshold:A.threshold??rQ.threshold,distance:A.distance??rQ.distance,includeMatches:A.includeMatches??rQ.includeMatches,findAllMatches:A.findAllMatches??rQ.findAllMatches,minMatchCharLength:A.minMatchCharLength??rQ.minMatchCharLength,isCaseSensitive:A.isCaseSensitive??rQ.isCaseSensitive,ignoreDiacritics:A.ignoreDiacritics??rQ.ignoreDiacritics,ignoreLocation:A.ignoreLocation??rQ.ignoreLocation});return{type:"fuzzy",search(e){return I.searchIn(e)}}}}],jxI=rog.length,Qyo="\0",iyo="|";function Eyo(g){const A=[],I=g.length;let e=0;for(;e<I;){for(;e<I&&g[e]===" ";)e++;if(e>=I)break;let t=e;for(;t<I&&g[t]!==" "&&g[t]!=='"';)t++;if(t<I&&g[t]==='"'){for(t++;t<I;){if(g[t]==='"'){const o=t+1;if(o>=I||g[o]===" "){t++;break}if(g[o]==="$"&&(o+1>=I||g[o+1]===" ")){t+=2;break}}t++}A.push(g.substring(e,t)),e=t}else{for(;t<I&&g[t]!==" ";)t++;A.push(g.substring(e,t)),e=t}}return A}function zxI(g,A){const I=g.match(A);return I?I[1]:null}function nyo(g,A={}){return g.replace(/\\\|/g,Qyo).split(iyo).map(I=>{const e=Eyo(I.replace(/\u0000/g,"|").trim()).filter(o=>o&&!!o.trim()),t=[];for(let o=0,B=e.length;o<B;o+=1){const C=e[o];let Q=!1,i=-1;for(;!Q&&++i<jxI;){const E=rog[i],n=zxI(C,E.multiRegex);n&&(t.push(E.create(n,A)),Q=!0)}if(!Q)for(i=-1;++i<jxI;){const E=rog[i],n=zxI(C,E.singleRegex);if(n){t.push(E.create(n,A));break}}}return t})}var syo=class{constructor(g,{isCaseSensitive:A=rQ.isCaseSensitive,ignoreDiacritics:I=rQ.ignoreDiacritics,includeMatches:e=rQ.includeMatches,minMatchCharLength:t=rQ.minMatchCharLength,ignoreLocation:o=rQ.ignoreLocation,findAllMatches:B=rQ.findAllMatches,location:C=rQ.location,threshold:Q=rQ.threshold,distance:i=rQ.distance}={}){this.query=null,this.options={isCaseSensitive:A,ignoreDiacritics:I,includeMatches:e,minMatchCharLength:t,findAllMatches:B,ignoreLocation:o,location:C,threshold:Q,distance:i},g=A?g:g.toLowerCase(),g=I?WeA(g):g,this.pattern=g,this.query=nyo(this.pattern,this.options)}static condition(g,A){return A.useExtendedSearch}searchIn(g){const A=this.query;if(!A)return{isMatch:!1,score:1};const{includeMatches:I,isCaseSensitive:e,ignoreDiacritics:t}=this.options;g=e?g:g.toLowerCase(),g=t?WeA(g):g;let o=0;const B=[];let C=0,Q=!1;for(let i=0,E=A.length;i<E;i+=1){const n=A[i];B.length=0,o=0,Q=!1;for(let s=0,r=n.length;s<r;s+=1){const a=n[s],{isMatch:c,indices:h,score:l}=a.search(g);if(c)o+=1,C+=l,Cyo(a.type)&&(Q=!0),I&&(Byo.has(a.type)?B.push(...h):B.push(h));else{C=0,o=0,B.length=0,Q=!1;break}}if(o){const s={isMatch:!0,score:C/o};return Q&&(s.hasInverse=!0),I&&(s.indices=sog(B)),s}}return{isMatch:!1,score:1}}};const cog=[];function hog(...g){cog.push(...g)}function DGA(g,A){for(let I=0,e=cog.length;I<e;I+=1){const t=cog[I];if(t.condition(g,A))return new t(g,A)}return new aog(g,A)}const dGA={AND:"$and",OR:"$or"},log={PATH:"$path",PATTERN:"$val"},Dog=g=>!!(g[dGA.AND]||g[dGA.OR]),ayo=g=>!!g[log.PATH],ryo=g=>!O3(g)&&vxI(g)&&!Dog(g),XxI=g=>({[dGA.AND]:Object.keys(g).map(A=>({[A]:g[A]}))});function $xI(g,A,{auto:I=!0}={}){const e=t=>{if(BG(t)){const Q={keyId:null,pattern:t};return I&&(Q.searcher=DGA(t,A)),Q}const o=Object.keys(t),B=ayo(t);if(!B&&o.length>1&&!Dog(t))return e(XxI(t));if(ryo(t)){const Q=B?t[log.PATH]:o[0],i=B?t[log.PATTERN]:t[Q];if(!BG(i))throw new Error(Zdo(Q));const E={keyId:lGA(Q),pattern:i};return I&&(E.searcher=DGA(i,A)),E}const C={children:[],operator:o[0]};return o.forEach(Q=>{const i=t[Q];O3(i)&&i.forEach(E=>{C.children.push(e(E))})}),C};return Dog(g)||(g=XxI(g)),e(g)}function dog(g,{ignoreFieldNorm:A=rQ.ignoreFieldNorm}){let I=1;return g.forEach(({key:e,norm:t,score:o})=>{const B=e?e.weight:null;I*=Math.pow(o===0&&B?Number.EPSILON:o,(B||1)*(A?1:t))}),I}function cyo(g,{ignoreFieldNorm:A=rQ.ignoreFieldNorm}){g.forEach(I=>{I.score=dog(I.matches,{ignoreFieldNorm:A})})}var hyo=class{constructor(g,A){this.limit=g,this.heap=[],this.comparator=A}get size(){return this.heap.length}insert(g){this.size<this.limit?(this.heap.push(g),this._bubbleUp(this.size-1)):this.comparator(g,this.heap[0])<0&&(this.heap[0]=g,this._sinkDown(0))}extractSorted(){return this.heap.sort(this.comparator)}_bubbleUp(g){const A=this.heap;for(;g>0;){const I=g-1>>1;if(this.comparator(A[g],A[I])<=0)break;const e=A[g];A[g]=A[I],A[I]=e,g=I}}_sinkDown(g){const A=this.heap,I=A.length;let e=g;do{g=e;const t=2*g+1,o=2*g+2;if(t<I&&this.comparator(A[t],A[e])>0&&(e=t),o<I&&this.comparator(A[o],A[e])>0&&(e=o),e!==g){const B=A[g];A[g]=A[e],A[e]=B}}while(e!==g)}};function lyo(g){const A=[];return g.matches.forEach(I=>{if(!cS(I.indices)||!I.indices.length)return;const e={indices:I.indices,value:I.value};I.key&&(e.key=I.key.id),I.idx>-1&&(e.refIndex=I.idx),A.push(e)}),A}function Dyo(g,A,{includeMatches:I=rQ.includeMatches,includeScore:e=rQ.includeScore}={}){return g.map(t=>{const{idx:o}=t,B={item:A[o],refIndex:o};return I&&(B.matches=lyo(t)),e&&(B.score=t.score),B})}const dyo=/[\p{L}\p{M}\p{N}_]+/gu,AFI=new WeakSet;function yyo(g){AFI.has(g)||(AFI.add(g),console.warn(`[Fuse] tokenize regex ${g} lacks the global flag; only the first match per text will be returned. Add the 'g' flag.`))}function wyo(g){if(typeof g=="function"){let A=!1;return I=>{const e=g(I);if(!A&&(A=!0,!Array.isArray(e)||e.some(t=>typeof t!="string")))throw new Error(`[Fuse] tokenize function must return string[]; received ${Array.isArray(e)?"array containing non-strings":typeof e}.`);return e}}return g instanceof RegExp?(g.global||yyo(g),A=>A.match(g)||[]):A=>A.match(dyo)||[]}function yog({isCaseSensitive:g=!1,ignoreDiacritics:A=!1,tokenize:I}={}){const e=wyo(I);return{tokenize(t){return g||(t=t.toLowerCase()),A&&(t=WeA(t)),e(t)}}}var uyo=class{static condition(g,A){return A.useTokenSearch}constructor(g,A){this.options=A,this.analyzer=yog({isCaseSensitive:A.isCaseSensitive,ignoreDiacritics:A.ignoreDiacritics,tokenize:A.tokenize});const I=this.analyzer.tokenize(g),{df:e,fieldCount:t}=A._invertedIndex;this.termSearchers=[],this.idfWeights=[];for(const o of I){this.termSearchers.push(new aog(o,{location:A.location,threshold:A.threshold,distance:A.distance,includeMatches:A.includeMatches,findAllMatches:A.findAllMatches,minMatchCharLength:A.minMatchCharLength,isCaseSensitive:A.isCaseSensitive,ignoreDiacritics:A.ignoreDiacritics,ignoreLocation:!0}));const B=e.get(o)||0,C=Math.log(1+(t-B+.5)/(B+.5));this.idfWeights.push(C)}this.combineAll=A.tokenMatch==="all",this.numTerms=this.termSearchers.length,this.useMask=this.numTerms<=31}searchIn(g){if(!this.termSearchers.length)return{isMatch:!1,score:1};const A=[];let I=0,e=0,t=0,o=0;const B=this.combineAll&&!this.useMask?new Set:null;for(let i=0;i<this.termSearchers.length;i++){const E=this.termSearchers[i].searchIn(g),n=this.idfWeights[i];e+=n,E.isMatch&&(t++,I+=n*(1-E.score),E.indices&&A.push(...E.indices),this.combineAll&&(this.useMask?o|=1<<i:B.add(i)))}if(t===0)return{isMatch:!1,score:1};const C=e>0?1-I/e:0,Q={isMatch:!0,score:Math.max(.001,C)};return this.options.includeMatches&&A.length&&(Q.indices=sog(A)),this.combineAll&&(this.useMask?Q.matchedMask=o:Q.matchedTerms=B,Q.termCount=this.numTerms),Q}};function wog(g,A,I,e){const t=e.tokenize(A);if(!t.length)return;g.fieldCount++,g.docFieldCount.set(I,(g.docFieldCount.get(I)||0)+1);const o=new Set(t);let B=g.docTermFieldHits.get(I);B||(B=new Map,g.docTermFieldHits.set(I,B));for(const C of o)B.set(C,(B.get(C)||0)+1),g.df.set(C,(g.df.get(C)||0)+1)}function gFI(g,A,I,e){const{i:t,v:o,$:B}=A;if(o!==void 0){wog(g,o,t,e);return}if(B)for(let C=0;C<I;C++){const Q=B[C];if(Q)if(Array.isArray(Q))for(const i of Q)wog(g,i.v,t,e);else wog(g,Q.v,t,e)}}function Gyo(g,A,I){const e={fieldCount:0,df:new Map,docFieldCount:new Map,docTermFieldHits:new Map};for(const t of g)gFI(e,t,A,I);return e}function myo(g,A,I,e){gFI(g,A,I,e)}function pyo(g,A){const I=g.docFieldCount.get(A);if(I===void 0)return;g.fieldCount-=I,g.docFieldCount.delete(A);const e=g.docTermFieldHits.get(A);if(e){for(const[t,o]of e){const B=(g.df.get(t)||0)-o;B<=0?g.df.delete(t):g.df.set(t,B)}g.docTermFieldHits.delete(A)}}function IFI(g,A){if(A.length===0)return;const I=Array.from(new Set(A)).sort((C,Q)=>C-Q);for(const C of I)pyo(g,C);const e=C=>{let Q=0,i=I.length;for(;Q<i;){const E=Q+i>>>1;I[E]<C?Q=E+1:i=E}return C-Q},t=I[0],o=new Map;for(const[C,Q]of g.docFieldCount)o.set(C>t?e(C):C,Q);g.docFieldCount=o;const B=new Map;for(const[C,Q]of g.docTermFieldHits)B.set(C>t?e(C):C,Q);g.docTermFieldHits=B}var W3=class{constructor(g,A,I){this.options={...rQ,...A},this.options.useExtendedSearch,this.options.useTokenSearch,this._keyStore=new zdo(this.options.keys),this._docs=g,this._myIndex=null,this._invertedIndex=null,this.setCollection(g,I),this._lastQuery=null,this._lastSearcher=null}_getSearcher(g){if(this._lastQuery===g)return this._lastSearcher;const A=DGA(g,this._invertedIndex?{...this.options,_invertedIndex:this._invertedIndex}:this.options);return this._lastQuery=g,this._lastSearcher=A,A}setCollection(g,A){if(this._docs=g,A&&!(A instanceof nog))throw new Error(Tdo);if(this._myIndex=A||WxI(this.options.keys,this._docs,{getFn:this.options.getFn,fieldNormWeight:this.options.fieldNormWeight}),this.options.useTokenSearch){const I=yog({isCaseSensitive:this.options.isCaseSensitive,ignoreDiacritics:this.options.ignoreDiacritics,tokenize:this.options.tokenize});this._invertedIndex=Gyo(this._myIndex.records,this._myIndex.keys.length,I)}this._invalidateSearcherCache()}add(g){if(!cS(g))return;this._docs.push(g);const A=this._myIndex.add(g,this._docs.length-1);if(this._invertedIndex&&A){const I=yog({isCaseSensitive:this.options.isCaseSensitive,ignoreDiacritics:this.options.ignoreDiacritics,tokenize:this.options.tokenize});myo(this._invertedIndex,A,this._myIndex.keys.length,I)}this._invalidateSearcherCache()}remove(g=()=>!1){const A=[],I=[];for(let e=0,t=this._docs.length;e<t;e+=1)g(this._docs[e],e)&&(A.push(this._docs[e]),I.push(e));if(I.length){this._invertedIndex&&IFI(this._invertedIndex,I);const e=new Set(I);this._docs=this._docs.filter((t,o)=>!e.has(o)),this._myIndex.removeAll(I),this._invalidateSearcherCache()}return A}removeAt(g){if(!Number.isInteger(g)||g<0||g>=this._docs.length)throw new Error(Eog);this._invertedIndex&&IFI(this._invertedIndex,[g]);const A=this._docs.splice(g,1)[0];return this._myIndex.removeAt(g),this._invalidateSearcherCache(),A}_invalidateSearcherCache(){this._lastQuery=null,this._lastSearcher=null}getIndex(){return this._myIndex}_normalizedKeys(){return this._myIndex.keys.map(g=>this._keyStore.get(g.id)||g)}search(g,A){const{limit:I=-1}=A||{},{includeMatches:e,includeScore:t,shouldSort:o,sortFn:B,ignoreFieldNorm:C}=this.options;if(BG(g)&&!g.trim()){let s=this._docs.map((r,a)=>({item:r,refIndex:a}));return cGA(I)&&I>-1&&(s=s.slice(0,I)),s}const Q=o&&cGA(I)&&I>0&&BG(g),i=B,E=(s,r)=>i(s,r)||s.idx-r.idx;let n;if(Q){const s=new hyo(I,E);BG(this._docs[0])?this._searchStringList(g,{heap:s,ignoreFieldNorm:C}):this._searchObjectList(g,{heap:s,ignoreFieldNorm:C}),n=s.extractSorted()}else n=BG(g)?BG(this._docs[0])?this._searchStringList(g):this._searchObjectList(g):this._searchLogical(g),cyo(n,{ignoreFieldNorm:C}),o&&n.sort(BG(g)?E:i),cGA(I)&&I>-1&&(n=n.slice(0,I));return Dyo(n,this._docs,{includeMatches:e,includeScore:t})}_searchStringList(g,{heap:A,ignoreFieldNorm:I}={}){const e=this._getSearcher(g),t=this.options.useTokenSearch&&this.options.tokenMatch==="all",{records:o}=this._myIndex,B=A?null:[];return o.forEach(({v:C,i:Q,n:i})=>{if(!cS(C))return;const E=e.searchIn(C);if(E.isMatch){const n={score:E.score,value:C,norm:i,indices:E.indices};t&&(n.matchedMask=E.matchedMask,n.matchedTerms=E.matchedTerms,n.termCount=E.termCount);const s=[n];if(!t||this._coversAllTokens(s)){const r={item:C,idx:Q,matches:s};A?(r.score=dog(r.matches,{ignoreFieldNorm:I}),A.insert(r)):B.push(r)}}}),B}_searchLogical(g){const A=$xI(g,this.options),I=this._normalizedKeys(),e=(C,Q,i)=>{if(!("children"in C)){const{keyId:r,searcher:a}=C;let c;return r===null?(c=[],I.forEach((h,l)=>{c.push(...this._findMatches({key:h,value:Q[l],searcher:a}))})):c=this._findMatches({key:this._keyStore.get(r),value:this._myIndex.getValueForItemAtKeyId(Q,r),searcher:a}),c&&c.length?[{idx:i,item:Q,matches:c}]:[]}const{children:E,operator:n}=C,s=[];for(let r=0,a=E.length;r<a;r+=1){const c=E[r],h=e(c,Q,i);if(h.length)s.push(...h);else if(n===dGA.AND)return[]}return s},t=this._myIndex.records,o=new Map,B=[];return t.forEach(({$:C,i:Q})=>{if(cS(C)){const i=e(A,C,Q);i.length&&(o.has(Q)||(o.set(Q,{idx:Q,item:C,matches:[]}),B.push(o.get(Q))),i.forEach(({matches:E})=>{o.get(Q).matches.push(...E)}))}}),B}_searchObjectList(g,{heap:A,ignoreFieldNorm:I}={}){const e=this._getSearcher(g),t=this.options.useTokenSearch&&this.options.tokenMatch==="all",{records:o}=this._myIndex,B=this._normalizedKeys(),C=A?null:[];return o.forEach(({$:Q,i})=>{if(!cS(Q))return;const E=[];let n=!1,s=!1;if(B.forEach((r,a)=>{const c=this._findMatches({key:r,value:Q[a],searcher:e});c.length?(E.push(...c),c[0].hasInverse&&(s=!0)):n=!0}),!(s&&n)&&E.length&&(!t||this._coversAllTokens(E))){const r={idx:i,item:Q,matches:E};A?(r.score=dog(r.matches,{ignoreFieldNorm:I}),A.insert(r)):C.push(r)}}),C}_findMatches({key:g,value:A,searcher:I}){if(!cS(A))return[];const e=[];if(O3(A))A.forEach(({v:t,i:o,n:B})=>{if(!cS(t))return;const C=I.searchIn(t);if(C.isMatch){const Q={score:C.score,key:g,value:t,idx:o,norm:B,indices:C.indices,hasInverse:C.hasInverse};C.termCount!==void 0&&(Q.matchedMask=C.matchedMask,Q.matchedTerms=C.matchedTerms,Q.termCount=C.termCount),e.push(Q)}});else{const{v:t,n:o}=A,B=I.searchIn(t);if(B.isMatch){const C={score:B.score,key:g,value:t,norm:o,indices:B.indices,hasInverse:B.hasInverse};B.termCount!==void 0&&(C.matchedMask=B.matchedMask,C.matchedTerms=B.matchedTerms,C.termCount=B.termCount),e.push(C)}}return e}_coversAllTokens(g){const A=g.length?g[0].termCount:void 0;if(A===void 0)return!0;if(A<=31){let e=0;for(let t=0;t<g.length;t++)e|=g[t].matchedMask||0;return e===2**A-1}const I=new Set;for(let e=0;e<g.length;e++){const t=g[e].matchedTerms;if(t)for(const o of t)I.add(o)}return I.size===A}};W3.version="7.5.0",W3.createIndex=WxI,W3.parseIndex=gyo,W3.config=rQ,W3.match=function(g,A,I){if(I&&I.useTokenSearch)throw new Error(jdo);return DGA(g,{...rQ,...I}).searchIn(A)},W3.parseQuery=$xI,hog(syo),hog(uyo),W3.use=function(...g){g.forEach(A=>hog(A))};var kyo=W3;const Myo="https://kicad-mod-cache.tscircuit.com";let uog=null,VeA=null,Gog=null;const Syo=async()=>uog||VeA||(VeA=fetch("https://kicad-mod-cache.tscircuit.com/kicad_files.json").then(g=>g.json()).then(g=>(uog=g,VeA=null,g)),VeA),fyo=async(g,A=20)=>{const I=await Syo();return Gog||(Gog=new kyo(I)),Gog.search(g).slice(0,A).map(e=>e.item)},Ryo=g=>{const A=g.replace(".pretty/","/").replace(".kicad_mod",""),I=`kicad:${A}`;return{path:g,qualifiedName:I,description:A}},Nyo=g=>g.replace(/^\/+/,"").split("/").map(A=>encodeURIComponent(A)).join("/"),xyo=async g=>{const A=await fetch(`${Myo}/${Nyo(g)}`);if(!A.ok)throw new Error(`KiCad footprint fetch failed: ${A.status}`);const I=await A.text(),{KicadFootprintToCircuitJsonConverter:e}=await rS("kicad-to-circuit-json"),t=new e;return t.addFile(g.split("/").pop()??"selected-footprint.kicad_mod",I),t.runUntilFinished(),t.getOutput()},eFI=g=>g?.source==="jlcpcb"||g?.source==="kicad",Fyo=async(g,A)=>{if(g.source==="jlcpcb")return bdo(g.component.partNumber,A?.jlcpcb);if(g.source==="kicad")return xyo(g.footprint.path);throw new Error("Footprint preview is not available for this source")},Uyo=({query:g,placeholder:A,isSearching:I,onQueryChange:e,onSubmit:t})=>{const o=X.useCallback(B=>{B.key==="Enter"&&(B.preventDefault(),t())},[t]);return q.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2 rf-mt-4",children:[q.jsxs("div",{className:"rf-relative rf-flex-grow",children:[q.jsx(heg,{className:"rf-absolute rf-left-2 rf-top-2.5 rf-h-4 rf-w-4 rf-text-muted-foreground"}),q.jsx(Htg,{placeholder:A,className:"rf-pl-8",spellCheck:!1,autoComplete:"off",value:g,onChange:B=>e(B.target.value),onKeyDown:o})]}),q.jsx(Ei,{onClick:t,disabled:I||g.trim().length<1,className:"sm:rf-px-4 rf-px-3",children:I?q.jsx(QS,{className:"rf-h-4 rf-w-4 rf-animate-spin"}):q.jsxs(q.Fragment,{children:[q.jsx(heg,{className:"rf-h-4 rf-w-4 sm:rf-hidden"}),q.jsx("span",{className:"rf-hidden sm:rf-inline",children:"Search"})]})})]})},Jyo=new Intl.NumberFormat("en-US",{style:"currency",currency:"USD"}),Pyo=g=>Jyo.format(g),tFI=g=>{switch(g.source){case"tscircuit.com":{const A=g.package;return`tscircuit-${A.package_id??`${A.org_owner_tscircuit_handle??"unknown"}-${A.unscoped_name??A.name??"package"}`}`}case"jlcpcb":return`jlc-${g.component.lcscId}`;case"kicad":return`kicad-${g.footprint.path}`;default:return"unknown"}},Kyo=g=>{switch(g.source){case"tscircuit.com":return g.package.unscoped_name;case"jlcpcb":return g.component.isDirectLookup?g.component.partNumber:g.component.manufacturer;case"kicad":return g.footprint.qualifiedName}},Lyo=g=>{switch(g.source){case"tscircuit.com":return g.package.description||(g.package.org_owner_tscircuit_handle?`Component by ${g.package.org_owner_tscircuit_handle}`:void 0);case"jlcpcb":return g.component.description;case"kicad":return g.footprint.description}},Yyo=g=>{switch(g.source){case"tscircuit.com":return g.package.name;case"jlcpcb":return g.component.isDirectLookup?void 0:g.component.partNumber;case"kicad":return}},_yo=({results:g,selected:A,onSelect:I,onShowDetails:e})=>{const t=A?tFI(A):null;return q.jsx("div",{className:"rf-divide-y rf-w-full rf-overflow-hidden",children:g.map(o=>{const B=tFI(o),C=t===B,Q=Kyo(o),i=Lyo(o),E=Yyo(o),n=o.source==="jlcpcb"?o.component.stock:null,s=o.source==="jlcpcb"?o.component.price:null,r=o.source==="jlcpcb"?o.component.isBasic:null,a=o.source==="jlcpcb"?o.component.isDirectLookup:!1;return q.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 ${C?"rf-bg-zinc-100":""}`,onClick:()=>I(o),children:[q.jsxs("div",{className:"rf-min-w-0 rf-overflow-hidden rf-w-full",children:[q.jsxs("div",{className:"rf-flex rf-items-start rf-gap-2 rf-min-w-0",children:[q.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:[Q,o.source==="jlcpcb"&&r!=null&&q.jsx("span",{className:`rf-text-xs rf-px-1.5 rf-py-0.5 rf-rounded rf-font-medium rf-flex-shrink-0 ${r?"rf-bg-green-100 rf-text-green-700":"rf-bg-orange-100 rf-text-orange-700"}`,children:r?"Basic":"Extended"}),a&&q.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"}),o.source==="tscircuit.com"&&o.package.is_private&&q.jsx(tQo,{className:"rf-ml-1 rf-h-3 rf-w-3 rf-text-zinc-400 rf-flex-shrink-0"})]}),o.source==="jlcpcb"&&n!=null?q.jsxs("div",{className:"rf-text-xs rf-text-zinc-500 rf-font-medium rf-whitespace-nowrap rf-flex-shrink-0 sm:rf-hidden",children:[n.toLocaleString()," in stock"]}):null]}),q.jsxs("div",{className:"rf-text-xs rf-text-zinc-500 rf-truncate rf-w-full",children:[E?q.jsx("span",{className:"rf-mr-2",children:E}):null,i]})]}),q.jsxs("div",{children:[o.source==="tscircuit.com"&&e?q.jsx("div",{className:"rf-flex-shrink-0 rf-w-full sm:rf-w-auto",children:q.jsx(Ei,{variant:"outline",size:"sm",className:"rf-text-xs rf-w-full sm:rf-w-auto",onClick:c=>{c.stopPropagation(),e(o)},children:"See Details"})}):o.source==="jlcpcb"&&n!=null?q.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:[n.toLocaleString()," in stock"]}):null,s!=null&&q.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:Pyo(s)})]})]},B)})})},byo=({circuitJson:g,error:A,isLoading:I,height:e})=>q.jsx("section",{className:"rf-flex rf-min-w-0 rf-items-center rf-justify-center",style:{height:e},children:I?q.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:e},children:[q.jsx(QS,{className:"rf-h-4 rf-w-4 rf-animate-spin"}),"Loading preview..."]}):A?q.jsx("div",{className:"rf-flex rf-w-full rf-items-center rf-justify-center rf-bg-zinc-950 rf-p-4",style:{height:e},children:q.jsxs("div",{className:"rf-flex rf-max-w-[320px] rf-items-start rf-gap-2 rf-text-sm rf-text-zinc-300",children:[q.jsx(ceg,{className:"rf-mt-0.5 rf-h-4 rf-w-4 rf-flex-shrink-0"}),q.jsx("span",{children:A})]})}):g?q.jsx("div",{className:"rf-w-full rf-min-w-0 rf-overflow-hidden",children:q.jsx(seg,{circuitJson:g,height:e,allowEditing:!1,clickToInteractEnabled:!1,focusOnHover:!1,disablePcbGroups:!0})}):q.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:e},children:"No preview"})}),oFI={importComponentDialog:101,importComponentDetailsDialog:102},Hyo=({packageResult:g,isOpen:A,onOpenChange:I,isLoading:e,details:t,previewTab:o,onPreviewTabChange:B,isSubmitting:C,onImport:Q})=>{const i=g?.package??null,E=i?.latest_pcb_preview_image_url,n=i?.latest_sch_preview_image_url,s=i?.latest_cad_preview_image_url,r=i?.unscoped_name?.split("/").pop()??i?.unscoped_name,a=i?.org_owner_tscircuit_handle??void 0,c=a?`https://tscircuit.com/${a}`:void 0,h=a&&r?`https://tscircuit.com/${a}/${r}`:void 0;return q.jsx(Z5,{open:A,onOpenChange:I,children:q.jsxs(q3,{showOverlay:!1,style:{width:"calc(100vw - 2rem)",zIndex:oFI.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:[q.jsx(T3,{className:"rf-pb-4 rf-border-b",children:q.jsx("div",{className:"rf-flex rf-items-start rf-justify-between rf-gap-4",children:q.jsxs("div",{className:"rf-flex-1 rf-min-w-0",children:[q.jsx(Z3,{className:"rf-text-xl rf-font-semibold rf-truncate",children:r}),q.jsx(O5,{children:i?.description})]})})}),q.jsxs("div",{className:"rf-flex-1 rf-overflow-y-auto rf-py-4 rf-space-y-6",children:[a?q.jsxs("div",{children:[q.jsx("span",{className:"rf-text-xs rf-font-medium rf-text-gray-500 rf-uppercase rf-tracking-wide",children:"Created by"}),q.jsx("div",{className:"rf-mt-1 rf-text-sm rf-font-medium",children:c?q.jsx("a",{href:c,target:"_blank",rel:"noopener noreferrer",className:"rf-text-black hover:rf-underline",children:a}):a})]}):null,(s||E||n)&&q.jsx(q.Fragment,{children:q.jsxs("div",{children:[q.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-mb-4",children:"Preview"}),q.jsxs(WHA,{value:o,onValueChange:l=>B(l),children:[q.jsxs(hlA,{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:[E&&q.jsx(gx,{value:"pcb",children:"PCB"}),n&&q.jsx(gx,{value:"schematic",children:"Schematic"}),s&&q.jsx(gx,{value:"3d",children:"3D"})]}),q.jsxs("div",{className:"rf-mt-4",children:[q.jsx(xw,{value:"pcb",className:"rf-border rf-rounded-lg rf-overflow-hidden rf-bg-gray-50",children:E?q.jsx("img",{src:E,alt:`${r??"package"} PCB preview`,className:"rf-w-full rf-h-full rf-object-contain rf-bg-white rf-p-4"}):null}),q.jsx(xw,{value:"schematic",className:"rf-border rf-rounded-lg rf-overflow-hidden rf-bg-gray-50",children:n?q.jsx("img",{src:n,alt:`${r??"package"} schematic preview`,className:"rf-w-full rf-h-full rf-object-contain rf-bg-white rf-p-4"}):null}),q.jsx(xw,{value:"3d",className:"rf-border rf-rounded-lg rf-overflow-hidden rf-bg-gray-50",children:s?q.jsx("img",{src:s,alt:`${r??"package"} 3D preview`,className:"rf-w-full rf-h-full rf-object-contain rf-bg-white rf-p-4"}):null})]})]})]})}),t?.ai_description?q.jsxs("section",{children:[q.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-mb-3",children:"AI Description"}),q.jsx("div",{className:"rf-bg-gray-50 rf-border rf-border-gray-200 rf-rounded-lg rf-p-4",children:q.jsx("p",{className:"rf-text-sm rf-text-gray-700 rf-leading-relaxed",children:t.ai_description})})]}):null,t?.ai_usage_instructions?q.jsxs("section",{children:[q.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-mb-3",children:"Usage Instructions"}),q.jsx("div",{className:"rf-bg-gray-50 rf-border rf-border-gray-200 rf-rounded-lg rf-p-4",children:q.jsx("p",{className:"rf-text-sm rf-text-gray-700 rf-leading-relaxed rf-whitespace-pre-wrap",children:t.ai_usage_instructions})})]}):null,e?q.jsxs("div",{className:"rf-flex rf-justify-center rf-items-center rf-gap-2 rf-text-gray-500",children:[q.jsx(QS,{className:"rf-h-4 rf-w-4 rf-animate-spin"}),q.jsx("span",{className:"rf-text-sm",children:"Loading package details..."})]}):null]}),q.jsxs(FZ,{className:"rf-pt-4 rf-border-t rf-flex rf-flex-col sm:rf-flex-row rf-justify-between rf-gap-2",children:[q.jsx("div",{className:"rf-flex-1",children:h?q.jsxs(Ei,{variant:"outline",size:"sm",className:"rf-gap-2 rf-w-full sm:rf-w-auto",onClick:()=>window.open(h,"_blank"),children:[q.jsx(zCo,{className:"rf-h-4 rf-w-4"}),"View on tscircuit.com"]}):null}),q.jsxs("div",{className:"rf-flex rf-flex-col sm:rf-flex-row rf-gap-2",children:[q.jsx(Ei,{variant:"outline",onClick:()=>I(!1),className:"rf-order-2 sm:rf-order-1",children:"Close"}),q.jsx(Ei,{onClick:Q,disabled:C,className:"rf-bg-blue-600 hover:rf-bg-blue-700",children:C?q.jsx(QS,{className:"rf-h-4 rf-w-4 rf-animate-spin"}):"Import Component"})]})]})]})})},vyo=()=>{const[g,A]=X.useState(null),[I,e]=X.useState(!1),t=X.useCallback(async(B,C)=>{e(!0);try{const Q=await fetch(`https://api.tscircuit.com/packages/get?name=${encodeURIComponent(`${B}/${C}`)}`);if(!Q.ok)throw new Error(`Failed to load package details: ${Q.status}`);const i=await Q.json();A(i.package??null)}catch(Q){console.error("Failed to fetch package details",Q),A(null)}finally{e(!1)}},[]),o=X.useCallback(()=>{A(null),e(!1)},[]);return{details:g,isLoading:I,fetchDetails:t,reset:o}},qyo=(g,A)=>{const[I,e]=X.useState({circuitJson:null,error:null,isLoading:!1});return X.useEffect(()=>{if(!g||!eFI(g)){e({circuitJson:null,error:null,isLoading:!1});return}let t=!1;return e({circuitJson:null,error:null,isLoading:!0}),Fyo(g,A).then(o=>{t||e({circuitJson:o,error:null,isLoading:!1})}).catch(o=>{t||e({circuitJson:null,error:o instanceof Error?o.message:"Failed to load footprint preview",isLoading:!1})}),()=>{t=!0}},[g,A]),I},Tyo=async(g,A)=>{const I={"Content-Type":"application/json"};A&&(I.Authorization=`Bearer ${A}`);const e=await fetch("https://registry-api.tscircuit.com/packages/search",{method:"POST",headers:I,body:JSON.stringify({query:g})});if(!e.ok)throw new Error(`tscircuit registry error: ${e.status}`);return(await e.json()).packages??[]},Zyo=({sessionToken:g})=>{const[A,I]=X.useState([]),[e,t]=X.useState(!1),[o,B]=X.useState(null),[C,Q]=X.useState(!1),i=X.useCallback(async n=>{const s=n.trim();if(!s)return[];t(!0),B(null);try{const a=(await Tyo(s,g)).map(c=>({source:"tscircuit.com",package:c}));return I(a),a}catch(r){return console.error("Error searching tscircuit packages",r),I([]),B(r instanceof Error?r.message:"Failed to search tscircuit packages"),[]}finally{t(!1),Q(!0)}},[g]),E=X.useCallback(()=>{I([]),t(!1),B(null),Q(!1)},[]);return{results:A,isSearching:e,error:o,hasSearched:C,search:i,reset:E}},Oyo=g=>{const A=/^C(\d+)$/i.exec(g.trim());if(!A)return null;const I=Number(A[1]);if(!Number.isSafeInteger(I))return null;const e=`C${A[1]}`;return{source:"jlcpcb",component:{lcscId:I,manufacturer:e,partNumber:e,description:"Import directly from EasyEDA; stock and availability are unknown",package:"",isDirectLookup:!0}}},BFI=(g,A)=>{const I=Oyo(g);return I?A.some(t=>t.component.partNumber.toUpperCase()===I.component.partNumber)?A:[I,...A]:A},Wyo=g=>{const A=g.trim();return/^C\d+/i.test(A)?A.replace(/^C/i,""):A},Vyo=()=>{const[g,A]=X.useState([]),[I,e]=X.useState(!1),[t,o]=X.useState(null),[B,C]=X.useState(!1),Q=X.useCallback(async E=>{const n=Wyo(E);if(!n)return[];e(!0),o(null);try{const s=await Ldo(n,10),r=BFI(E,s.map(a=>({source:"jlcpcb",component:Ydo(a)})));return A(r),r}catch(s){console.error("Error searching JLCPCB components",s);const r=BFI(E,[]);return A(r),o(r.length>0?null:s instanceof Error?s.message:"Failed to search JLCPCB components"),r}finally{e(!1),C(!0)}},[]),i=X.useCallback(()=>{A([]),e(!1),o(null),C(!1)},[]);return{results:g,isSearching:I,error:t,hasSearched:B,search:Q,reset:i}},jyo=()=>{const[g,A]=X.useState([]),[I,e]=X.useState(!1),[t,o]=X.useState(null),[B,C]=X.useState(!1),Q=X.useCallback(async E=>{const n=E.trim();if(!n)return[];e(!0),o(null);try{const r=(await fyo(n,20)).map(a=>({source:"kicad",footprint:Ryo(a)}));return A(r),r}catch(s){return console.error("Error searching KiCad footprints",s),A([]),o(s instanceof Error?s.message:"Failed to search KiCad footprints"),[]}finally{e(!1),C(!0)}},[]),i=X.useCallback(()=>{A([]),e(!1),o(null),C(!1)},[]);return{results:g,isSearching:I,error:t,hasSearched:B,search:Q,reset:i}},zyo=({onTscircuitPackageSelected:g,onJlcpcbComponentTsxLoaded:A,onKicadStringSelected:I})=>{const e=[];return g&&e.push("tscircuit.com"),A&&e.push("jlcpcb"),I&&e.push("kicad"),e},Xyo=({isOpen:g,onClose:A,jlcpcbProxyRequestHeaders:I,onKicadStringSelected:e,onTscircuitPackageSelected:t,onJlcpcbComponentTsxLoaded:o,jlcpcbProxyApiBase:B,tscircuitSessionToken:C})=>{qeA();const Q=X.useMemo(()=>zyo({onKicadStringSelected:e,onTscircuitPackageSelected:t,onJlcpcbComponentTsxLoaded:o}),[e,t,o]),i=Q.length>0,E=Q.length===1,[n,s]=X.useState(Q[0]??"tscircuit.com"),[r,a]=X.useState(""),[c,h]=X.useState(null),{results:l,isSearching:D,error:d,hasSearched:y,search:w,reset:u}=Zyo({sessionToken:C}),{results:G,isSearching:m,error:p,hasSearched:k,search:S,reset:R}=Vyo(),{results:x,isSearching:N,error:J,hasSearched:K,search:_,reset:b}=jyo(),{details:T,isLoading:j,fetchDetails:O,reset:W}=vyo(),[gA,tA]=X.useState(null),[IA,QA]=X.useState(!1),[nA,DA]=X.useState("pcb"),[CA,hA]=X.useState(null),[sA,cA]=X.useState(!1),SA=X.useMemo(()=>({jlcpcb:{headers:I,apiBase:B}}),[B,I]),{circuitJson:xA,error:aA,isLoading:FA}=qyo(c,SA),NA=eFI(c);X.useEffect(()=>{hA(null)},[c]);const RA=X.useCallback(()=>{u(),R(),b(),h(null)},[R,b,u]);X.useEffect(()=>{g||(RA(),a(""),QA(!1),tA(null),hA(null))},[g,RA]),X.useEffect(()=>{a(""),h(null),n==="tscircuit.com"?u():n==="jlcpcb"?R():n==="kicad"&&b()},[n,R,b,u]);const JA=kA=>{h(kA),tA(kA),DA("pcb"),QA(!0),W();const OA=kA.package.org_owner_tscircuit_handle,$A=kA.package.unscoped_name;if(OA&&$A){const tg=$A.split("/").pop()??$A;O(OA,tg)}},PA=async()=>{r.trim()&&(h(null),n==="tscircuit.com"?await w(r):n==="jlcpcb"?await S(r):n==="kicad"&&await _(r))},mA=async kA=>{try{if(hA(null),cA(!0),kA.source==="kicad"){if(!e)throw new Error("KiCad handler not provided");await e({result:kA,footprint:kA.footprint.qualifiedName})}else if(kA.source==="jlcpcb"){if(!o)throw new Error("JLCPCB handler not provided");const OA=await _do(kA.component.partNumber,{headers:I,apiBase:B});await o({result:kA,tsx:OA})}else if(kA.source==="tscircuit.com"){if(!t)throw new Error("tscircuit package handler not provided");const OA=kA.package.org_owner_tscircuit_handle,$A=kA.package.unscoped_name;if(!OA||!$A)throw new Error("Missing package metadata");const tg=$A.split("/").pop()??$A,dg=`@tsci/${OA}.${tg}`;await t({result:kA,fullPackageName:dg})}return!0}catch(OA){return console.error("Failed to import component",OA),hA(OA instanceof Error?OA.message:"Failed to import component"),!1}finally{cA(!1)}};let YA=[],dA=!1,HA=null,WA=!1;n==="tscircuit.com"?(YA=l,dA=D,HA=d,WA=y):n==="jlcpcb"?(YA=G,dA=m,HA=p,WA=k):n==="kicad"&&(YA=x,dA=N,HA=J,WA=K);const Qg=async()=>{if(!c)return;await mA(c)&&(A(),RA(),a(""))},_A=kA=>{kA||A()},GA=kA=>{QA(kA),kA||tA(null)};return q.jsxs(Z5,{open:g,onOpenChange:_A,children:[q.jsxs(q3,{style:{width:"calc(100vw - 2rem)",maxWidth:NA?"min(1120px, calc(100vw - 2rem))":"min(672px, calc(100vw - 2rem))",zIndex:oFI.importComponentDialog},className:"rf-rounded-sm rf-max-h-[90vh] rf-overflow-y-auto rf-overflow-x-hidden rf-flex rf-flex-col",children:[q.jsxs(T3,{children:[q.jsxs(Z3,{className:"rf-text-lg sm:rf-text-xl",children:["Import ",E?rGA[n].label:""," ","Component"]}),q.jsx(O5,{className:"rf-text-sm",children:i?"Search for components from available sources.":"Import options are disabled because no handlers were provided."})]}),i?q.jsxs(WHA,{value:n,onValueChange:kA=>s(kA),className:"rf-min-w-0 rf-w-full",children:[!E&&q.jsx(hlA,{className:"rf-flex rf-w-full rf-gap-2",children:Q.map(kA=>q.jsx(gx,{value:kA,className:"rf-flex-1 rf-text-xs sm:rf-text-sm",children:rGA[kA].label},kA))}),q.jsxs("div",{className:"rf-min-w-0",style:NA?{display:"grid",gridTemplateColumns:"minmax(0, 1fr) minmax(360px, 0.95fr)",gap:"1.5rem",alignItems:"start"}:void 0,children:[q.jsxs("div",{className:"rf-min-w-0",children:[q.jsx(Uyo,{query:r,placeholder:rGA[n].placeholder,isSearching:dA,onQueryChange:a,onSubmit:PA}),q.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:dA?q.jsxs("div",{className:"rf-p-8 rf-text-center rf-text-zinc-500",children:[q.jsx(QS,{className:"rf-h-8 rf-w-8 rf-animate-spin rf-mx-auto rf-mb-2"}),q.jsx("p",{children:"Searching..."})]}):YA.length>0?q.jsx(_yo,{results:YA,selected:c,onSelect:h,onShowDetails:n==="tscircuit.com"?JA:void 0}):q.jsx("div",{className:"rf-p-8 rf-text-center rf-text-zinc-500",children:HA?`Error: ${HA}`:WA?rGA[n].emptyMessage:"Enter a search term to find components"})})]}),NA?q.jsx("div",{className:"rf-mt-4",children:q.jsx(byo,{circuitJson:xA,error:aA,isLoading:FA,height:325})}):null]})]}):null,CA?q.jsx("div",{className:"rf-text-sm rf-text-red-600 rf-mt-2",children:CA}):null,q.jsxs(FZ,{className:"rf-flex rf-flex-col sm:rf-flex-row rf-gap-2",children:[q.jsx(Ei,{variant:"outline",onClick:A,className:"rf-order-2 sm:rf-order-1",children:"Cancel"}),q.jsx(Ei,{onClick:Qg,disabled:!c||sA,className:"rf-order-1 sm:rf-order-2",children:sA?q.jsx(QS,{className:"rf-h-4 rf-w-4 rf-animate-spin"}):"Import"})]})]}),q.jsx(Hyo,{packageResult:gA,isOpen:IA,onOpenChange:GA,isLoading:j,details:T,previewTab:nA,onPreviewTabChange:kA=>DA(kA),isSubmitting:sA,onImport:()=>{gA&&mA(gA).then(kA=>{kA&&(QA(!1),A(),RA(),a(""))})}})]})},$yo=g=>{const A=g.match(/export const (\w+) =/);if(!A)throw new Error("Could not determine component name from TSX contents");return A[1]},CFI=g=>{const A=Fc(B=>B.pushEvent),I=Fc(B=>B.upsertFile),e=async({result:B,fullPackageName:C})=>{const i=B.package.unscoped_name??B.package.name;await JC.promise(A({event_type:"INSTALL_PACKAGE",full_package_name:C}),{loading:`Requesting install for "${i}"`,success:`Install requested for "${i}"`,error:E=>`Failed to request install: ${E instanceof Error?E.message:String(E)}`})},t=async({footprint:B})=>{await JC.promise(navigator.clipboard.writeText(B),{loading:`Copying "${B}"`,success:`Copied "${B}" to clipboard`,error:C=>`Failed to copy footprint: ${C instanceof Error?C.message:String(C)}`})},o=async({result:B,tsx:C})=>{const i=`imports/${$yo(C)}.tsx`;await JC.promise(I(i,C),{loading:`Importing ${B.component.partNumber}`,success:`Imported to "${i}"`,error:E=>`Failed to import component: ${E instanceof Error?E.message:String(E)}`})};return q.jsx(Xyo,{...g,onTscircuitPackageSelected:e,onKicadStringSelected:t,onJlcpcbComponentTsxLoaded:o})};CFI.displayName="ImportComponentDialogForCli";const Awo=async({circuitJson:g,projectName:A})=>{const{convertCircuitJsonToAltiumZip:I}=await Promise.resolve().then(()=>d_o),e=await I(g,A);return new Blob([new Uint8Array(e)],{type:"application/zip"})},gwo=async({circuitJson:g,projectName:A})=>{await JC.promise((async()=>{const I=await Awo({circuitJson:g,projectName:A});pk(I,{fileName:`${A}_altium_project.zip`})})(),{loading:"Generating Altium project...",success:"Altium project ZIP ready",error:I=>`Failed to generate Altium project: ${I instanceof Error?I.message:String(I)}`})};var mog={exports:{}},QFI;function Iwo(){return QFI||(QFI=1,(function(g,A){var I={env:{},version:""};(function(e){g.exports=e()})(function(){return(function e(t,o,B){function C(E,n){if(!o[E]){if(!t[E]){var s=typeof LF=="function"&&LF;if(!n&&s)return s(E,!0);if(Q)return Q(E,!0);var r=new Error("Cannot find module '"+E+"'");throw r.code="MODULE_NOT_FOUND",r}var a=o[E]={exports:{}};t[E][0].call(a.exports,function(c){var h=t[E][1][c];return C(h||c)},a,a.exports,e,t,o,B)}return o[E].exports}for(var Q=typeof LF=="function"&&LF,i=0;i<B.length;i++)C(B[i]);return C})({1:[function(e,t,o){var B=e("./utils"),C=e("./support"),Q="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";o.encode=function(i){for(var E,n,s,r,a,c,h,l=[],D=0,d=i.length,y=d,w=B.getTypeOf(i)!=="string";D<i.length;)y=d-D,s=w?(E=i[D++],n=D<d?i[D++]:0,D<d?i[D++]:0):(E=i.charCodeAt(D++),n=D<d?i.charCodeAt(D++):0,D<d?i.charCodeAt(D++):0),r=E>>2,a=(3&E)<<4|n>>4,c=1<y?(15&n)<<2|s>>6:64,h=2<y?63&s:64,l.push(Q.charAt(r)+Q.charAt(a)+Q.charAt(c)+Q.charAt(h));return l.join("")},o.decode=function(i){var E,n,s,r,a,c,h=0,l=0,D="data:";if(i.substr(0,D.length)===D)throw new Error("Invalid base64 input, it looks like a data url.");var d,y=3*(i=i.replace(/[^A-Za-z0-9+/=]/g,"")).length/4;if(i.charAt(i.length-1)===Q.charAt(64)&&y--,i.charAt(i.length-2)===Q.charAt(64)&&y--,y%1!=0)throw new Error("Invalid base64 input, bad content length.");for(d=C.uint8array?new Uint8Array(0|y):new Array(0|y);h<i.length;)E=Q.indexOf(i.charAt(h++))<<2|(r=Q.indexOf(i.charAt(h++)))>>4,n=(15&r)<<4|(a=Q.indexOf(i.charAt(h++)))>>2,s=(3&a)<<6|(c=Q.indexOf(i.charAt(h++))),d[l++]=E,a!==64&&(d[l++]=n),c!==64&&(d[l++]=s);return d}},{"./support":30,"./utils":32}],2:[function(e,t,o){var B=e("./external"),C=e("./stream/DataWorker"),Q=e("./stream/Crc32Probe"),i=e("./stream/DataLengthProbe");function E(n,s,r,a,c){this.compressedSize=n,this.uncompressedSize=s,this.crc32=r,this.compression=a,this.compressedContent=c}E.prototype={getContentWorker:function(){var n=new C(B.Promise.resolve(this.compressedContent)).pipe(this.compression.uncompressWorker()).pipe(new i("data_length")),s=this;return n.on("end",function(){if(this.streamInfo.data_length!==s.uncompressedSize)throw new Error("Bug : uncompressed data size mismatch")}),n},getCompressedWorker:function(){return new C(B.Promise.resolve(this.compressedContent)).withStreamInfo("compressedSize",this.compressedSize).withStreamInfo("uncompressedSize",this.uncompressedSize).withStreamInfo("crc32",this.crc32).withStreamInfo("compression",this.compression)}},E.createWorkerFrom=function(n,s,r){return n.pipe(new Q).pipe(new i("uncompressedSize")).pipe(s.compressWorker(r)).pipe(new i("compressedSize")).withStreamInfo("compression",s)},t.exports=E},{"./external":6,"./stream/Crc32Probe":25,"./stream/DataLengthProbe":26,"./stream/DataWorker":27}],3:[function(e,t,o){var B=e("./stream/GenericWorker");o.STORE={magic:"\0\0",compressWorker:function(){return new B("STORE compression")},uncompressWorker:function(){return new B("STORE decompression")}},o.DEFLATE=e("./flate")},{"./flate":7,"./stream/GenericWorker":28}],4:[function(e,t,o){var B=e("./utils"),C=(function(){for(var Q,i=[],E=0;E<256;E++){Q=E;for(var n=0;n<8;n++)Q=1&Q?3988292384^Q>>>1:Q>>>1;i[E]=Q}return i})();t.exports=function(Q,i){return Q!==void 0&&Q.length?B.getTypeOf(Q)!=="string"?(function(E,n,s,r){var a=C,c=r+s;E^=-1;for(var h=r;h<c;h++)E=E>>>8^a[255&(E^n[h])];return-1^E})(0|i,Q,Q.length,0):(function(E,n,s,r){var a=C,c=r+s;E^=-1;for(var h=r;h<c;h++)E=E>>>8^a[255&(E^n.charCodeAt(h))];return-1^E})(0|i,Q,Q.length,0):0}},{"./utils":32}],5:[function(e,t,o){o.base64=!1,o.binary=!1,o.dir=!1,o.createFolders=!0,o.date=null,o.compression=null,o.compressionOptions=null,o.comment=null,o.unixPermissions=null,o.dosPermissions=null},{}],6:[function(e,t,o){var B=null;B=typeof Promise<"u"?Promise:e("lie"),t.exports={Promise:B}},{lie:37}],7:[function(e,t,o){var B=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Uint32Array<"u",C=e("pako"),Q=e("./utils"),i=e("./stream/GenericWorker"),E=B?"uint8array":"array";function n(s,r){i.call(this,"FlateWorker/"+s),this._pako=null,this._pakoAction=s,this._pakoOptions=r,this.meta={}}o.magic="\b\0",Q.inherits(n,i),n.prototype.processChunk=function(s){this.meta=s.meta,this._pako===null&&this._createPako(),this._pako.push(Q.transformTo(E,s.data),!1)},n.prototype.flush=function(){i.prototype.flush.call(this),this._pako===null&&this._createPako(),this._pako.push([],!0)},n.prototype.cleanUp=function(){i.prototype.cleanUp.call(this),this._pako=null},n.prototype._createPako=function(){this._pako=new C[this._pakoAction]({raw:!0,level:this._pakoOptions.level||-1});var s=this;this._pako.onData=function(r){s.push({data:r,meta:s.meta})}},o.compressWorker=function(s){return new n("Deflate",s)},o.uncompressWorker=function(){return new n("Inflate",{})}},{"./stream/GenericWorker":28,"./utils":32,pako:38}],8:[function(e,t,o){function B(a,c){var h,l="";for(h=0;h<c;h++)l+=String.fromCharCode(255&a),a>>>=8;return l}function C(a,c,h,l,D,d){var y,w,u=a.file,G=a.compression,m=d!==E.utf8encode,p=Q.transformTo("string",d(u.name)),k=Q.transformTo("string",E.utf8encode(u.name)),S=u.comment,R=Q.transformTo("string",d(S)),x=Q.transformTo("string",E.utf8encode(S)),N=k.length!==u.name.length,J=x.length!==S.length,K="",_="",b="",T=u.dir,j=u.date,O={crc32:0,compressedSize:0,uncompressedSize:0};c&&!h||(O.crc32=a.crc32,O.compressedSize=a.compressedSize,O.uncompressedSize=a.uncompressedSize);var W=0;c&&(W|=8),m||!N&&!J||(W|=2048);var gA=0,tA=0;T&&(gA|=16),D==="UNIX"?(tA=798,gA|=(function(QA,nA){var DA=QA;return QA||(DA=nA?16893:33204),(65535&DA)<<16})(u.unixPermissions,T)):(tA=20,gA|=(function(QA){return 63&(QA||0)})(u.dosPermissions)),y=j.getUTCHours(),y<<=6,y|=j.getUTCMinutes(),y<<=5,y|=j.getUTCSeconds()/2,w=j.getUTCFullYear()-1980,w<<=4,w|=j.getUTCMonth()+1,w<<=5,w|=j.getUTCDate(),N&&(_=B(1,1)+B(n(p),4)+k,K+="up"+B(_.length,2)+_),J&&(b=B(1,1)+B(n(R),4)+x,K+="uc"+B(b.length,2)+b);var IA="";return IA+=`
|
|
5678
5678
|
\0`,IA+=B(W,2),IA+=G.magic,IA+=B(y,2),IA+=B(w,2),IA+=B(O.crc32,4),IA+=B(O.compressedSize,4),IA+=B(O.uncompressedSize,4),IA+=B(p.length,2),IA+=B(K.length,2),{fileRecord:s.LOCAL_FILE_HEADER+IA+p+K,dirRecord:s.CENTRAL_FILE_HEADER+B(tA,2)+IA+B(R.length,2)+"\0\0\0\0"+B(gA,4)+B(l,4)+p+K+R}}var Q=e("../utils"),i=e("../stream/GenericWorker"),E=e("../utf8"),n=e("../crc32"),s=e("../signature");function r(a,c,h,l){i.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=c,this.zipPlatform=h,this.encodeFileName=l,this.streamFiles=a,this.accumulate=!1,this.contentBuffer=[],this.dirRecords=[],this.currentSourceOffset=0,this.entriesCount=0,this.currentFile=null,this._sources=[]}Q.inherits(r,i),r.prototype.push=function(a){var c=a.meta.percent||0,h=this.entriesCount,l=this._sources.length;this.accumulate?this.contentBuffer.push(a):(this.bytesWritten+=a.data.length,i.prototype.push.call(this,{data:a.data,meta:{currentFile:this.currentFile,percent:h?(c+100*(h-l-1))/h:100}}))},r.prototype.openedSource=function(a){this.currentSourceOffset=this.bytesWritten,this.currentFile=a.file.name;var c=this.streamFiles&&!a.file.dir;if(c){var h=C(a,c,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:h.fileRecord,meta:{percent:0}})}else this.accumulate=!0},r.prototype.closedSource=function(a){this.accumulate=!1;var c=this.streamFiles&&!a.file.dir,h=C(a,c,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(h.dirRecord),c)this.push({data:(function(l){return s.DATA_DESCRIPTOR+B(l.crc32,4)+B(l.compressedSize,4)+B(l.uncompressedSize,4)})(a),meta:{percent:100}});else for(this.push({data:h.fileRecord,meta:{percent:0}});this.contentBuffer.length;)this.push(this.contentBuffer.shift());this.currentFile=null},r.prototype.flush=function(){for(var a=this.bytesWritten,c=0;c<this.dirRecords.length;c++)this.push({data:this.dirRecords[c],meta:{percent:100}});var h=this.bytesWritten-a,l=(function(D,d,y,w,u){var G=Q.transformTo("string",u(w));return s.CENTRAL_DIRECTORY_END+"\0\0\0\0"+B(D,2)+B(D,2)+B(d,4)+B(y,4)+B(G.length,2)+G})(this.dirRecords.length,h,a,this.zipComment,this.encodeFileName);this.push({data:l,meta:{percent:100}})},r.prototype.prepareNextSource=function(){this.previous=this._sources.shift(),this.openedSource(this.previous.streamInfo),this.isPaused?this.previous.pause():this.previous.resume()},r.prototype.registerPrevious=function(a){this._sources.push(a);var c=this;return a.on("data",function(h){c.processChunk(h)}),a.on("end",function(){c.closedSource(c.previous.streamInfo),c._sources.length?c.prepareNextSource():c.end()}),a.on("error",function(h){c.error(h)}),this},r.prototype.resume=function(){return!!i.prototype.resume.call(this)&&(!this.previous&&this._sources.length?(this.prepareNextSource(),!0):this.previous||this._sources.length||this.generatedError?void 0:(this.end(),!0))},r.prototype.error=function(a){var c=this._sources;if(!i.prototype.error.call(this,a))return!1;for(var h=0;h<c.length;h++)try{c[h].error(a)}catch{}return!0},r.prototype.lock=function(){i.prototype.lock.call(this);for(var a=this._sources,c=0;c<a.length;c++)a[c].lock()},t.exports=r},{"../crc32":4,"../signature":23,"../stream/GenericWorker":28,"../utf8":31,"../utils":32}],9:[function(e,t,o){var B=e("../compressions"),C=e("./ZipFileWorker");o.generateWorker=function(Q,i,E){var n=new C(i.streamFiles,E,i.platform,i.encodeFileName),s=0;try{Q.forEach(function(r,a){s++;var c=(function(d,y){var w=d||y,u=B[w];if(!u)throw new Error(w+" is not a valid compression method !");return u})(a.options.compression,i.compression),h=a.options.compressionOptions||i.compressionOptions||{},l=a.dir,D=a.date;a._compressWorker(c,h).withStreamInfo("file",{name:r,dir:l,date:D,comment:a.comment||"",unixPermissions:a.unixPermissions,dosPermissions:a.dosPermissions}).pipe(n)}),n.entriesCount=s}catch(r){n.error(r)}return n}},{"../compressions":3,"./ZipFileWorker":8}],10:[function(e,t,o){function B(){if(!(this instanceof B))return new B;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 C=new B;for(var Q in this)typeof this[Q]!="function"&&(C[Q]=this[Q]);return C}}(B.prototype=e("./object")).loadAsync=e("./load"),B.support=e("./support"),B.defaults=e("./defaults"),B.version="3.10.2",B.loadAsync=function(C,Q){return new B().loadAsync(C,Q)},B.external=e("./external"),t.exports=B},{"./defaults":5,"./external":6,"./load":11,"./object":15,"./support":30}],11:[function(e,t,o){var B=e("./utils"),C=e("./external"),Q=e("./utf8"),i=e("./zipEntries"),E=e("./stream/Crc32Probe"),n=e("./nodejsUtils");function s(r){return new C.Promise(function(a,c){var h=r.decompressed.getContentWorker().pipe(new E);h.on("error",function(l){c(l)}).on("end",function(){h.streamInfo.crc32!==r.decompressed.crc32?c(new Error("Corrupted zip : CRC32 mismatch")):a()}).resume()})}t.exports=function(r,a){var c=this;return a=B.extend(a||{},{base64:!1,checkCRC32:!1,optimizedBinaryString:!1,createFolders:!1,decodeFileName:Q.utf8decode}),n.isNode&&n.isStream(r)?C.Promise.reject(new Error("JSZip can't accept a stream when loading a zip file.")):B.prepareContent("the loaded zip file",r,!0,a.optimizedBinaryString,a.base64).then(function(h){var l=new i(a);return l.load(h),l}).then(function(h){var l=[C.Promise.resolve(h)],D=h.files;if(a.checkCRC32)for(var d=0;d<D.length;d++)l.push(s(D[d]));return C.Promise.all(l)}).then(function(h){for(var l=h.shift(),D=l.files,d=0;d<D.length;d++){var y=D[d],w=y.fileNameStr,u=B.resolve(y.fileNameStr);c.file(u,y.decompressed,{binary:!0,optimizedBinaryString:!0,date:y.date,dir:y.dir,comment:y.fileCommentStr.length?y.fileCommentStr:null,unixPermissions:y.unixPermissions,dosPermissions:y.dosPermissions,createFolders:a.createFolders}),y.dir||(c.file(u).unsafeOriginalName=w)}return l.zipComment.length&&(c.comment=l.zipComment),c})}},{"./external":6,"./nodejsUtils":14,"./stream/Crc32Probe":25,"./utf8":31,"./utils":32,"./zipEntries":33}],12:[function(e,t,o){var B=e("../utils"),C=e("../stream/GenericWorker");function Q(i,E){C.call(this,"Nodejs stream input adapter for "+i),this._upstreamEnded=!1,this._bindStream(E)}B.inherits(Q,C),Q.prototype._bindStream=function(i){var E=this;(this._stream=i).pause(),i.on("data",function(n){E.push({data:n,meta:{percent:0}})}).on("error",function(n){E.isPaused?this.generatedError=n:E.error(n)}).on("end",function(){E.isPaused?E._upstreamEnded=!0:E.end()})},Q.prototype.pause=function(){return!!C.prototype.pause.call(this)&&(this._stream.pause(),!0)},Q.prototype.resume=function(){return!!C.prototype.resume.call(this)&&(this._upstreamEnded?this.end():this._stream.resume(),!0)},t.exports=Q},{"../stream/GenericWorker":28,"../utils":32}],13:[function(e,t,o){var B=e("readable-stream").Readable;function C(Q,i,E){B.call(this,i),this._helper=Q;var n=this;Q.on("data",function(s,r){n.push(s)||n._helper.pause(),E&&E(r)}).on("error",function(s){n.emit("error",s)}).on("end",function(){n.push(null)})}e("../utils").inherits(C,B),C.prototype._read=function(){this._helper.resume()},t.exports=C},{"../utils":32,"readable-stream":16}],14:[function(e,t,o){t.exports={isNode:typeof Buffer<"u",newBufferFrom:function(B,C){if(Buffer.from&&Buffer.from!==Uint8Array.from)return Buffer.from(B,C);if(typeof B=="number")throw new Error('The "data" argument must not be a number');return new Buffer(B,C)},allocBuffer:function(B){if(Buffer.alloc)return Buffer.alloc(B);var C=new Buffer(B);return C.fill(0),C},isBuffer:function(B){return Buffer.isBuffer(B)},isStream:function(B){return B&&typeof B.on=="function"&&typeof B.pause=="function"&&typeof B.resume=="function"}}},{}],15:[function(e,t,o){function B(u,G,m){var p,k=Q.getTypeOf(G),S=Q.extend(m||{},n);S.date=S.date||new Date,S.compression!==null&&(S.compression=S.compression.toUpperCase()),typeof S.unixPermissions=="string"&&(S.unixPermissions=parseInt(S.unixPermissions,8)),S.unixPermissions&&16384&S.unixPermissions&&(S.dir=!0),S.dosPermissions&&16&S.dosPermissions&&(S.dir=!0),S.dir&&(u=D(u)),S.createFolders&&(p=l(u))&&d.call(this,p,!0);var R=k==="string"&&S.binary===!1&&S.base64===!1;m&&m.binary!==void 0||(S.binary=!R),(G instanceof s&&G.uncompressedSize===0||S.dir||!G||G.length===0)&&(S.base64=!1,S.binary=!0,G="",S.compression="STORE",k="string");var x=null;x=G instanceof s||G instanceof i?G:c.isNode&&c.isStream(G)?new h(u,G):Q.prepareContent(u,G,S.binary,S.optimizedBinaryString,S.base64);var N=new r(u,x,S);this.files[u]=N}var C=e("./utf8"),Q=e("./utils"),i=e("./stream/GenericWorker"),E=e("./stream/StreamHelper"),n=e("./defaults"),s=e("./compressedObject"),r=e("./zipObject"),a=e("./generate"),c=e("./nodejsUtils"),h=e("./nodejs/NodejsStreamInputAdapter"),l=function(u){u.slice(-1)==="/"&&(u=u.substring(0,u.length-1));var G=u.lastIndexOf("/");return 0<G?u.substring(0,G):""},D=function(u){return u.slice(-1)!=="/"&&(u+="/"),u},d=function(u,G){return G=G!==void 0?G:n.createFolders,u=D(u),this.files[u]||B.call(this,u,null,{dir:!0,createFolders:G}),this.files[u]};function y(u){return Object.prototype.toString.call(u)==="[object RegExp]"}var w={load:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},forEach:function(u){var G,m,p;for(G in this.files)p=this.files[G],(m=G.slice(this.root.length,G.length))&&G.slice(0,this.root.length)===this.root&&u(m,p)},filter:function(u){var G=[];return this.forEach(function(m,p){u(m,p)&&G.push(p)}),G},file:function(u,G,m){if(arguments.length!==1)return u=this.root+u,B.call(this,u,G,m),this;if(y(u)){var p=u;return this.filter(function(S,R){return!R.dir&&p.test(S)})}var k=this.files[this.root+u];return k&&!k.dir?k:null},folder:function(u){if(!u)return this;if(y(u))return this.filter(function(k,S){return S.dir&&u.test(k)});var G=this.root+u,m=d.call(this,G),p=this.clone();return p.root=m.name,p},remove:function(u){u=this.root+u;var G=this.files[u];if(G||(u.slice(-1)!=="/"&&(u+="/"),G=this.files[u]),G&&!G.dir)delete this.files[u];else for(var m=this.filter(function(k,S){return S.name.slice(0,u.length)===u}),p=0;p<m.length;p++)delete this.files[m[p].name];return this},generate:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},generateInternalStream:function(u){var G,m={};try{if((m=Q.extend(u||{},{streamFiles:!1,compression:"STORE",compressionOptions:null,type:"",platform:"DOS",comment:null,mimeType:"application/zip",encodeFileName:C.utf8encode})).type=m.type.toLowerCase(),m.compression=m.compression.toUpperCase(),m.type==="binarystring"&&(m.type="string"),!m.type)throw new Error("No output type specified.");Q.checkSupport(m.type),m.platform!=="darwin"&&m.platform!=="freebsd"&&m.platform!=="linux"&&m.platform!=="sunos"||(m.platform="UNIX"),m.platform==="win32"&&(m.platform="DOS");var p=m.comment||this.comment||"";G=a.generateWorker(this,m,p)}catch(k){(G=new i("error")).error(k)}return new E(G,m.type||"string",m.mimeType)},generateAsync:function(u,G){return this.generateInternalStream(u).accumulate(G)},generateNodeStream:function(u,G){return(u=u||{}).type||(u.type="nodebuffer"),this.generateInternalStream(u).toNodejsStream(G)}};t.exports=w},{"./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(e,t,o){t.exports=e("stream")},{stream:void 0}],17:[function(e,t,o){var B=e("./DataReader");function C(Q){B.call(this,Q);for(var i=0;i<this.data.length;i++)Q[i]=255&Q[i]}e("../utils").inherits(C,B),C.prototype.byteAt=function(Q){return this.data[this.zero+Q]},C.prototype.lastIndexOfSignature=function(Q){for(var i=Q.charCodeAt(0),E=Q.charCodeAt(1),n=Q.charCodeAt(2),s=Q.charCodeAt(3),r=this.length-4;0<=r;--r)if(this.data[r]===i&&this.data[r+1]===E&&this.data[r+2]===n&&this.data[r+3]===s)return r-this.zero;return-1},C.prototype.readAndCheckSignature=function(Q){var i=Q.charCodeAt(0),E=Q.charCodeAt(1),n=Q.charCodeAt(2),s=Q.charCodeAt(3),r=this.readData(4);return i===r[0]&&E===r[1]&&n===r[2]&&s===r[3]},C.prototype.readData=function(Q){if(this.checkOffset(Q),Q===0)return[];var i=this.data.slice(this.zero+this.index,this.zero+this.index+Q);return this.index+=Q,i},t.exports=C},{"../utils":32,"./DataReader":18}],18:[function(e,t,o){var B=e("../utils");function C(Q){this.data=Q,this.length=Q.length,this.index=0,this.zero=0}C.prototype={checkOffset:function(Q){this.checkIndex(this.index+Q)},checkIndex:function(Q){if(this.length<this.zero+Q||Q<0)throw new Error("End of data reached (data length = "+this.length+", asked index = "+Q+"). Corrupted zip ?")},setIndex:function(Q){this.checkIndex(Q),this.index=Q},skip:function(Q){this.setIndex(this.index+Q)},byteAt:function(){},readInt:function(Q){var i,E=0;for(this.checkOffset(Q),i=this.index+Q-1;i>=this.index;i--)E=(E<<8)+this.byteAt(i);return this.index+=Q,E},readString:function(Q){return B.transformTo("string",this.readData(Q))},readData:function(){},lastIndexOfSignature:function(){},readAndCheckSignature:function(){},readDate:function(){var Q=this.readInt(4);return new Date(Date.UTC(1980+(Q>>25&127),(Q>>21&15)-1,Q>>16&31,Q>>11&31,Q>>5&63,(31&Q)<<1))}},t.exports=C},{"../utils":32}],19:[function(e,t,o){var B=e("./Uint8ArrayReader");function C(Q){B.call(this,Q)}e("../utils").inherits(C,B),C.prototype.readData=function(Q){this.checkOffset(Q);var i=this.data.slice(this.zero+this.index,this.zero+this.index+Q);return this.index+=Q,i},t.exports=C},{"../utils":32,"./Uint8ArrayReader":21}],20:[function(e,t,o){var B=e("./DataReader");function C(Q){B.call(this,Q)}e("../utils").inherits(C,B),C.prototype.byteAt=function(Q){return this.data.charCodeAt(this.zero+Q)},C.prototype.lastIndexOfSignature=function(Q){return this.data.lastIndexOf(Q)-this.zero},C.prototype.readAndCheckSignature=function(Q){return Q===this.readData(4)},C.prototype.readData=function(Q){this.checkOffset(Q);var i=this.data.slice(this.zero+this.index,this.zero+this.index+Q);return this.index+=Q,i},t.exports=C},{"../utils":32,"./DataReader":18}],21:[function(e,t,o){var B=e("./ArrayReader");function C(Q){B.call(this,Q)}e("../utils").inherits(C,B),C.prototype.readData=function(Q){if(this.checkOffset(Q),Q===0)return new Uint8Array(0);var i=this.data.subarray(this.zero+this.index,this.zero+this.index+Q);return this.index+=Q,i},t.exports=C},{"../utils":32,"./ArrayReader":17}],22:[function(e,t,o){var B=e("../utils"),C=e("../support"),Q=e("./ArrayReader"),i=e("./StringReader"),E=e("./NodeBufferReader"),n=e("./Uint8ArrayReader");t.exports=function(s){var r=B.getTypeOf(s);return B.checkSupport(r),r!=="string"||C.uint8array?r==="nodebuffer"?new E(s):C.uint8array?new n(B.transformTo("uint8array",s)):new Q(B.transformTo("array",s)):new i(s)}},{"../support":30,"../utils":32,"./ArrayReader":17,"./NodeBufferReader":19,"./StringReader":20,"./Uint8ArrayReader":21}],23:[function(e,t,o){o.LOCAL_FILE_HEADER="PK",o.CENTRAL_FILE_HEADER="PK",o.CENTRAL_DIRECTORY_END="PK",o.ZIP64_CENTRAL_DIRECTORY_LOCATOR="PK\x07",o.ZIP64_CENTRAL_DIRECTORY_END="PK",o.DATA_DESCRIPTOR="PK\x07\b"},{}],24:[function(e,t,o){var B=e("./GenericWorker"),C=e("../utils");function Q(i){B.call(this,"ConvertWorker to "+i),this.destType=i}C.inherits(Q,B),Q.prototype.processChunk=function(i){this.push({data:C.transformTo(this.destType,i.data),meta:i.meta})},t.exports=Q},{"../utils":32,"./GenericWorker":28}],25:[function(e,t,o){var B=e("./GenericWorker"),C=e("../crc32");function Q(){B.call(this,"Crc32Probe"),this.withStreamInfo("crc32",0)}e("../utils").inherits(Q,B),Q.prototype.processChunk=function(i){this.streamInfo.crc32=C(i.data,this.streamInfo.crc32||0),this.push(i)},t.exports=Q},{"../crc32":4,"../utils":32,"./GenericWorker":28}],26:[function(e,t,o){var B=e("../utils"),C=e("./GenericWorker");function Q(i){C.call(this,"DataLengthProbe for "+i),this.propName=i,this.withStreamInfo(i,0)}B.inherits(Q,C),Q.prototype.processChunk=function(i){if(i){var E=this.streamInfo[this.propName]||0;this.streamInfo[this.propName]=E+i.data.length}C.prototype.processChunk.call(this,i)},t.exports=Q},{"../utils":32,"./GenericWorker":28}],27:[function(e,t,o){var B=e("../utils"),C=e("./GenericWorker");function Q(i){C.call(this,"DataWorker");var E=this;this.dataIsReady=!1,this.index=0,this.max=0,this.data=null,this.type="",this._tickScheduled=!1,i.then(function(n){E.dataIsReady=!0,E.data=n,E.max=n&&n.length||0,E.type=B.getTypeOf(n),E.isPaused||E._tickAndRepeat()},function(n){E.error(n)})}B.inherits(Q,C),Q.prototype.cleanUp=function(){C.prototype.cleanUp.call(this),this.data=null},Q.prototype.resume=function(){return!!C.prototype.resume.call(this)&&(!this._tickScheduled&&this.dataIsReady&&(this._tickScheduled=!0,B.delay(this._tickAndRepeat,[],this)),!0)},Q.prototype._tickAndRepeat=function(){this._tickScheduled=!1,this.isPaused||this.isFinished||(this._tick(),this.isFinished||(B.delay(this._tickAndRepeat,[],this),this._tickScheduled=!0))},Q.prototype._tick=function(){if(this.isPaused||this.isFinished)return!1;var i=null,E=Math.min(this.max,this.index+16384);if(this.index>=this.max)return this.end();switch(this.type){case"string":i=this.data.substring(this.index,E);break;case"uint8array":i=this.data.subarray(this.index,E);break;case"array":case"nodebuffer":i=this.data.slice(this.index,E)}return this.index=E,this.push({data:i,meta:{percent:this.max?this.index/this.max*100:0}})},t.exports=Q},{"../utils":32,"./GenericWorker":28}],28:[function(e,t,o){function B(C){this.name=C||"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}B.prototype={push:function(C){this.emit("data",C)},end:function(){if(this.isFinished)return!1;this.flush();try{this.emit("end"),this.cleanUp(),this.isFinished=!0}catch(C){this.emit("error",C)}return!0},error:function(C){return!this.isFinished&&(this.isPaused?this.generatedError=C:(this.isFinished=!0,this.emit("error",C),this.previous&&this.previous.error(C),this.cleanUp()),!0)},on:function(C,Q){return this._listeners[C].push(Q),this},cleanUp:function(){this.streamInfo=this.generatedError=this.extraStreamInfo=null,this._listeners=[]},emit:function(C,Q){if(this._listeners[C])for(var i=0;i<this._listeners[C].length;i++)this._listeners[C][i].call(this,Q)},pipe:function(C){return C.registerPrevious(this)},registerPrevious:function(C){if(this.isLocked)throw new Error("The stream '"+this+"' has already been used.");this.streamInfo=C.streamInfo,this.mergeStreamInfo(),this.previous=C;var Q=this;return C.on("data",function(i){Q.processChunk(i)}),C.on("end",function(){Q.end()}),C.on("error",function(i){Q.error(i)}),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 C=this.isPaused=!1;return this.generatedError&&(this.error(this.generatedError),C=!0),this.previous&&this.previous.resume(),!C},flush:function(){},processChunk:function(C){this.push(C)},withStreamInfo:function(C,Q){return this.extraStreamInfo[C]=Q,this.mergeStreamInfo(),this},mergeStreamInfo:function(){for(var C in this.extraStreamInfo)Object.prototype.hasOwnProperty.call(this.extraStreamInfo,C)&&(this.streamInfo[C]=this.extraStreamInfo[C])},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 C="Worker "+this.name;return this.previous?this.previous+" -> "+C:C}},t.exports=B},{}],29:[function(e,t,o){var B=e("../utils"),C=e("./ConvertWorker"),Q=e("./GenericWorker"),i=e("../base64"),E=e("../support"),n=e("../external"),s=null;if(E.nodestream)try{s=e("../nodejs/NodejsStreamOutputAdapter")}catch{}function r(c,h){return new n.Promise(function(l,D){var d=[],y=c._internalType,w=c._outputType,u=c._mimeType;c.on("data",function(G,m){d.push(G),h&&h(m)}).on("error",function(G){d=[],D(G)}).on("end",function(){try{var G=(function(m,p,k){switch(m){case"blob":return B.newBlob(B.transformTo("arraybuffer",p),k);case"base64":return i.encode(p);default:return B.transformTo(m,p)}})(w,(function(m,p){var k,S=0,R=null,x=0;for(k=0;k<p.length;k++)x+=p[k].length;switch(m){case"string":return p.join("");case"array":return Array.prototype.concat.apply([],p);case"uint8array":for(R=new Uint8Array(x),k=0;k<p.length;k++)R.set(p[k],S),S+=p[k].length;return R;case"nodebuffer":return Buffer.concat(p);default:throw new Error("concat : unsupported type '"+m+"'")}})(y,d),u);l(G)}catch(m){D(m)}d=[]}).resume()})}function a(c,h,l){var D=h;switch(h){case"blob":case"arraybuffer":D="uint8array";break;case"base64":D="string"}try{this._internalType=D,this._outputType=h,this._mimeType=l,B.checkSupport(D),this._worker=c.pipe(new C(D)),c.lock()}catch(d){this._worker=new Q("error"),this._worker.error(d)}}a.prototype={accumulate:function(c){return r(this,c)},on:function(c,h){var l=this;return c==="data"?this._worker.on(c,function(D){h.call(l,D.data,D.meta)}):this._worker.on(c,function(){B.delay(h,arguments,l)}),this},resume:function(){return B.delay(this._worker.resume,[],this._worker),this},pause:function(){return this._worker.pause(),this},toNodejsStream:function(c){if(B.checkSupport("nodestream"),this._outputType!=="nodebuffer")throw new Error(this._outputType+" is not supported by this method");return new s(this,{objectMode:this._outputType!=="nodebuffer"},c)}},t.exports=a},{"../base64":1,"../external":6,"../nodejs/NodejsStreamOutputAdapter":13,"../support":30,"../utils":32,"./ConvertWorker":24,"./GenericWorker":28}],30:[function(e,t,o){if(o.base64=!0,o.array=!0,o.string=!0,o.arraybuffer=typeof ArrayBuffer<"u"&&typeof Uint8Array<"u",o.nodebuffer=typeof Buffer<"u",o.uint8array=typeof Uint8Array<"u",typeof ArrayBuffer>"u")o.blob=!1;else{var B=new ArrayBuffer(0);try{o.blob=new Blob([B],{type:"application/zip"}).size===0}catch{try{var C=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);C.append(B),o.blob=C.getBlob("application/zip").size===0}catch{o.blob=!1}}}try{o.nodestream=!!e("readable-stream").Readable}catch{o.nodestream=!1}},{"readable-stream":16}],31:[function(e,t,o){for(var B=e("./utils"),C=e("./support"),Q=e("./nodejsUtils"),i=e("./stream/GenericWorker"),E=new Array(256),n=0;n<256;n++)E[n]=252<=n?6:248<=n?5:240<=n?4:224<=n?3:192<=n?2:1;E[254]=E[254]=1;function s(){i.call(this,"utf-8 decode"),this.leftOver=null}function r(){i.call(this,"utf-8 encode")}o.utf8encode=function(a){return C.nodebuffer?Q.newBufferFrom(a,"utf-8"):(function(c){var h,l,D,d,y,w=c.length,u=0;for(d=0;d<w;d++)(64512&(l=c.charCodeAt(d)))==55296&&d+1<w&&(64512&(D=c.charCodeAt(d+1)))==56320&&(l=65536+(l-55296<<10)+(D-56320),d++),u+=l<128?1:l<2048?2:l<65536?3:4;for(h=C.uint8array?new Uint8Array(u):new Array(u),d=y=0;y<u;d++)(64512&(l=c.charCodeAt(d)))==55296&&d+1<w&&(64512&(D=c.charCodeAt(d+1)))==56320&&(l=65536+(l-55296<<10)+(D-56320),d++),l<128?h[y++]=l:(l<2048?h[y++]=192|l>>>6:(l<65536?h[y++]=224|l>>>12:(h[y++]=240|l>>>18,h[y++]=128|l>>>12&63),h[y++]=128|l>>>6&63),h[y++]=128|63&l);return h})(a)},o.utf8decode=function(a){return C.nodebuffer?B.transformTo("nodebuffer",a).toString("utf-8"):(function(c){var h,l,D,d,y=c.length,w=new Array(2*y);for(h=l=0;h<y;)if((D=c[h++])<128)w[l++]=D;else if(4<(d=E[D]))w[l++]=65533,h+=d-1;else{for(D&=d===2?31:d===3?15:7;1<d&&h<y;)D=D<<6|63&c[h++],d--;1<d?w[l++]=65533:D<65536?w[l++]=D:(D-=65536,w[l++]=55296|D>>10&1023,w[l++]=56320|1023&D)}return w.length!==l&&(w.subarray?w=w.subarray(0,l):w.length=l),B.applyFromCharCode(w)})(a=B.transformTo(C.uint8array?"uint8array":"array",a))},B.inherits(s,i),s.prototype.processChunk=function(a){var c=B.transformTo(C.uint8array?"uint8array":"array",a.data);if(this.leftOver&&this.leftOver.length){if(C.uint8array){var h=c;(c=new Uint8Array(h.length+this.leftOver.length)).set(this.leftOver,0),c.set(h,this.leftOver.length)}else c=this.leftOver.concat(c);this.leftOver=null}var l=(function(d,y){var w;for((y=y||d.length)>d.length&&(y=d.length),w=y-1;0<=w&&(192&d[w])==128;)w--;return w<0||w===0?y:w+E[d[w]]>y?w:y})(c),D=c;l!==c.length&&(C.uint8array?(D=c.subarray(0,l),this.leftOver=c.subarray(l,c.length)):(D=c.slice(0,l),this.leftOver=c.slice(l,c.length))),this.push({data:o.utf8decode(D),meta:a.meta})},s.prototype.flush=function(){this.leftOver&&this.leftOver.length&&(this.push({data:o.utf8decode(this.leftOver),meta:{}}),this.leftOver=null)},o.Utf8DecodeWorker=s,B.inherits(r,i),r.prototype.processChunk=function(a){this.push({data:o.utf8encode(a.data),meta:a.meta})},o.Utf8EncodeWorker=r},{"./nodejsUtils":14,"./stream/GenericWorker":28,"./support":30,"./utils":32}],32:[function(e,t,o){var B=e("./support"),C=e("./base64"),Q=e("./nodejsUtils"),i=e("./external");function E(h){return h}function n(h,l){for(var D=0;D<h.length;++D)l[D]=255&h.charCodeAt(D);return l}e("setimmediate"),o.newBlob=function(h,l){o.checkSupport("blob");try{return new Blob([h],{type:l})}catch{try{var D=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);return D.append(h),D.getBlob(l)}catch{throw new Error("Bug : can't construct the Blob.")}}};var s={stringifyByChunk:function(h,l,D){var d=[],y=0,w=h.length;if(w<=D)return String.fromCharCode.apply(null,h);for(;y<w;)l==="array"||l==="nodebuffer"?d.push(String.fromCharCode.apply(null,h.slice(y,Math.min(y+D,w)))):d.push(String.fromCharCode.apply(null,h.subarray(y,Math.min(y+D,w)))),y+=D;return d.join("")},stringifyByChar:function(h){for(var l="",D=0;D<h.length;D++)l+=String.fromCharCode(h[D]);return l},applyCanBeUsed:{uint8array:(function(){try{return B.uint8array&&String.fromCharCode.apply(null,new Uint8Array(1)).length===1}catch{return!1}})(),nodebuffer:(function(){try{return B.nodebuffer&&String.fromCharCode.apply(null,Q.allocBuffer(1)).length===1}catch{return!1}})()}};function r(h){var l=65536,D=o.getTypeOf(h),d=!0;if(D==="uint8array"?d=s.applyCanBeUsed.uint8array:D==="nodebuffer"&&(d=s.applyCanBeUsed.nodebuffer),d)for(;1<l;)try{return s.stringifyByChunk(h,D,l)}catch{l=Math.floor(l/2)}return s.stringifyByChar(h)}function a(h,l){for(var D=0;D<h.length;D++)l[D]=h[D];return l}o.applyFromCharCode=r;var c={};c.string={string:E,array:function(h){return n(h,new Array(h.length))},arraybuffer:function(h){return c.string.uint8array(h).buffer},uint8array:function(h){return n(h,new Uint8Array(h.length))},nodebuffer:function(h){return n(h,Q.allocBuffer(h.length))}},c.array={string:r,array:E,arraybuffer:function(h){return new Uint8Array(h).buffer},uint8array:function(h){return new Uint8Array(h)},nodebuffer:function(h){return Q.newBufferFrom(h)}},c.arraybuffer={string:function(h){return r(new Uint8Array(h))},array:function(h){return a(new Uint8Array(h),new Array(h.byteLength))},arraybuffer:E,uint8array:function(h){return new Uint8Array(h)},nodebuffer:function(h){return Q.newBufferFrom(new Uint8Array(h))}},c.uint8array={string:r,array:function(h){return a(h,new Array(h.length))},arraybuffer:function(h){return h.buffer},uint8array:E,nodebuffer:function(h){return Q.newBufferFrom(h)}},c.nodebuffer={string:r,array:function(h){return a(h,new Array(h.length))},arraybuffer:function(h){return c.nodebuffer.uint8array(h).buffer},uint8array:function(h){return a(h,new Uint8Array(h.length))},nodebuffer:E},o.transformTo=function(h,l){if(l=l||"",!h)return l;o.checkSupport(h);var D=o.getTypeOf(l);return c[D][h](l)},o.resolve=function(h){for(var l=h.split("/"),D=[],d=0;d<l.length;d++){var y=l[d];y==="."||y===""&&d!==0&&d!==l.length-1||(y===".."?D.pop():D.push(y))}return D.join("/")},o.getTypeOf=function(h){if(typeof h=="string")return"string";var l=Object.prototype.toString.call(h);return l==="[object Array]"?"array":B.nodebuffer&&Q.isBuffer(h)?"nodebuffer":B.uint8array&&l==="[object Uint8Array]"?"uint8array":B.arraybuffer&&l==="[object ArrayBuffer]"?"arraybuffer":void 0},o.checkSupport=function(h){if(!B[h.toLowerCase()])throw new Error(h+" is not supported by this platform")},o.MAX_VALUE_16BITS=65535,o.MAX_VALUE_32BITS=-1,o.pretty=function(h){var l,D,d="";for(D=0;D<(h||"").length;D++)d+="\\x"+((l=h.charCodeAt(D))<16?"0":"")+l.toString(16).toUpperCase();return d},o.delay=function(h,l,D){setImmediate(function(){h.apply(D||null,l||[])})},o.inherits=function(h,l){function D(){}D.prototype=l.prototype,h.prototype=new D},o.extend=function(){var h,l,D={};for(h=0;h<arguments.length;h++)for(l in arguments[h])Object.prototype.hasOwnProperty.call(arguments[h],l)&&D[l]===void 0&&(D[l]=arguments[h][l]);return D},o.prepareContent=function(h,l,D,d,y){return i.Promise.resolve(l).then(function(w){return B.blob&&(w instanceof Blob||["[object File]","[object Blob]"].indexOf(Object.prototype.toString.call(w))!==-1)?Blob.prototype.arrayBuffer!==void 0?w.arrayBuffer():typeof FileReader<"u"?new i.Promise(function(u,G){var m=new FileReader;m.onload=function(p){u(p.target.result)},m.onerror=function(p){G(p.target.error)},m.readAsArrayBuffer(w)}):i.Promise.reject(new Error(h+" is a Blob, but we have no way of reading it.")):w}).then(function(w){var u=o.getTypeOf(w);return u?(u==="arraybuffer"?w=o.transformTo("uint8array",w):u==="string"&&(y?w=C.decode(w):D&&d!==!0&&(w=(function(G){return n(G,B.uint8array?new Uint8Array(G.length):new Array(G.length))})(w))),w):i.Promise.reject(new Error("Can't read the data of '"+h+"'. Is it in a supported JavaScript type (String, Blob, ArrayBuffer, etc) ?"))})}},{"./base64":1,"./external":6,"./nodejsUtils":14,"./support":30,setimmediate:54}],33:[function(e,t,o){var B=e("./reader/readerFor"),C=e("./utils"),Q=e("./signature"),i=e("./zipEntry"),E=e("./support");function n(s){this.files=[],this.loadOptions=s}n.prototype={checkSignature:function(s){if(!this.reader.readAndCheckSignature(s)){this.reader.index-=4;var r=this.reader.readString(4);throw new Error("Corrupted zip or bug: unexpected signature ("+C.pretty(r)+", expected "+C.pretty(s)+")")}},isSignature:function(s,r){var a=this.reader.index;this.reader.setIndex(s);var c=this.reader.readString(4)===r;return this.reader.setIndex(a),c},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 s=this.reader.readData(this.zipCommentLength),r=E.uint8array?"uint8array":"array",a=C.transformTo(r,s);this.zipComment=this.loadOptions.decodeFileName(a)},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 s,r,a,c=this.zip64EndOfCentralSize-44;0<c;)s=this.reader.readInt(2),r=this.reader.readInt(4),a=this.reader.readData(r),this.zip64ExtensibleData[s]={id:s,length:r,value:a}},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 s,r;for(s=0;s<this.files.length;s++)r=this.files[s],this.reader.setIndex(r.localHeaderOffset),this.checkSignature(Q.LOCAL_FILE_HEADER),r.readLocalPart(this.reader),r.handleUTF8(),r.processAttributes()},readCentralDir:function(){var s;for(this.reader.setIndex(this.centralDirOffset);this.reader.readAndCheckSignature(Q.CENTRAL_FILE_HEADER);)(s=new i({zip64:this.zip64},this.loadOptions)).readCentralPart(this.reader),this.files.push(s);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 s=this.reader.lastIndexOfSignature(Q.CENTRAL_DIRECTORY_END);if(s<0)throw this.isSignature(0,Q.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(s);var r=s;if(this.checkSignature(Q.CENTRAL_DIRECTORY_END),this.readBlockEndOfCentral(),this.diskNumber===C.MAX_VALUE_16BITS||this.diskWithCentralDirStart===C.MAX_VALUE_16BITS||this.centralDirRecordsOnThisDisk===C.MAX_VALUE_16BITS||this.centralDirRecords===C.MAX_VALUE_16BITS||this.centralDirSize===C.MAX_VALUE_32BITS||this.centralDirOffset===C.MAX_VALUE_32BITS){if(this.zip64=!0,(s=this.reader.lastIndexOfSignature(Q.ZIP64_CENTRAL_DIRECTORY_LOCATOR))<0)throw new Error("Corrupted zip: can't find the ZIP64 end of central directory locator");if(this.reader.setIndex(s),this.checkSignature(Q.ZIP64_CENTRAL_DIRECTORY_LOCATOR),this.readBlockZip64EndOfCentralLocator(),!this.isSignature(this.relativeOffsetEndOfZip64CentralDir,Q.ZIP64_CENTRAL_DIRECTORY_END)&&(this.relativeOffsetEndOfZip64CentralDir=this.reader.lastIndexOfSignature(Q.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(Q.ZIP64_CENTRAL_DIRECTORY_END),this.readBlockZip64EndOfCentral()}var a=this.centralDirOffset+this.centralDirSize;this.zip64&&(a+=20,a+=12+this.zip64EndOfCentralSize);var c=r-a;if(0<c)this.isSignature(r,Q.CENTRAL_FILE_HEADER)||(this.reader.zero=c);else if(c<0)throw new Error("Corrupted zip: missing "+Math.abs(c)+" bytes.")},prepareReader:function(s){this.reader=B(s)},load:function(s){this.prepareReader(s),this.readEndOfCentral(),this.readCentralDir(),this.readLocalFiles()}},t.exports=n},{"./reader/readerFor":22,"./signature":23,"./support":30,"./utils":32,"./zipEntry":34}],34:[function(e,t,o){var B=e("./reader/readerFor"),C=e("./utils"),Q=e("./compressedObject"),i=e("./crc32"),E=e("./utf8"),n=e("./compressions"),s=e("./support");function r(a,c){this.options=a,this.loadOptions=c}r.prototype={isEncrypted:function(){return(1&this.bitFlag)==1},useUTF8:function(){return(2048&this.bitFlag)==2048},readLocalPart:function(a){var c,h;if(a.skip(22),this.fileNameLength=a.readInt(2),h=a.readInt(2),this.fileName=a.readData(this.fileNameLength),a.skip(h),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((c=(function(l){for(var D in n)if(Object.prototype.hasOwnProperty.call(n,D)&&n[D].magic===l)return n[D];return null})(this.compressionMethod))===null)throw new Error("Corrupted zip : compression "+C.pretty(this.compressionMethod)+" unknown (inner file : "+C.transformTo("string",this.fileName)+")");this.decompressed=new Q(this.compressedSize,this.uncompressedSize,this.crc32,c,a.readData(this.compressedSize))},readCentralPart:function(a){this.versionMadeBy=a.readInt(2),a.skip(2),this.bitFlag=a.readInt(2),this.compressionMethod=a.readString(2),this.date=a.readDate(),this.crc32=a.readInt(4),this.compressedSize=a.readInt(4),this.uncompressedSize=a.readInt(4);var c=a.readInt(2);if(this.extraFieldsLength=a.readInt(2),this.fileCommentLength=a.readInt(2),this.diskNumberStart=a.readInt(2),this.internalFileAttributes=a.readInt(2),this.externalFileAttributes=a.readInt(4),this.localHeaderOffset=a.readInt(4),this.isEncrypted())throw new Error("Encrypted zip are not supported");a.skip(c),this.readExtraFields(a),this.parseZIP64ExtraField(a),this.fileComment=a.readData(this.fileCommentLength)},processAttributes:function(){this.unixPermissions=null,this.dosPermissions=null;var a=this.versionMadeBy>>8;this.dir=!!(16&this.externalFileAttributes),a==0&&(this.dosPermissions=63&this.externalFileAttributes),a==3&&(this.unixPermissions=this.externalFileAttributes>>16&65535),this.dir||this.fileNameStr.slice(-1)!=="/"||(this.dir=!0)},parseZIP64ExtraField:function(){if(this.extraFields[1]){var a=B(this.extraFields[1].value);this.uncompressedSize===C.MAX_VALUE_32BITS&&(this.uncompressedSize=a.readInt(8)),this.compressedSize===C.MAX_VALUE_32BITS&&(this.compressedSize=a.readInt(8)),this.localHeaderOffset===C.MAX_VALUE_32BITS&&(this.localHeaderOffset=a.readInt(8)),this.diskNumberStart===C.MAX_VALUE_32BITS&&(this.diskNumberStart=a.readInt(4))}},readExtraFields:function(a){var c,h,l,D=a.index+this.extraFieldsLength;for(this.extraFields||(this.extraFields={});a.index+4<D;)c=a.readInt(2),h=a.readInt(2),l=a.readData(h),this.extraFields[c]={id:c,length:h,value:l};a.setIndex(D)},handleUTF8:function(){var a=s.uint8array?"uint8array":"array";if(this.useUTF8())this.fileNameStr=E.utf8decode(this.fileName),this.fileCommentStr=E.utf8decode(this.fileComment);else{var c=this.findExtraFieldUnicodePath();if(c!==null)this.fileNameStr=c;else{var h=C.transformTo(a,this.fileName);this.fileNameStr=this.loadOptions.decodeFileName(h)}var l=this.findExtraFieldUnicodeComment();if(l!==null)this.fileCommentStr=l;else{var D=C.transformTo(a,this.fileComment);this.fileCommentStr=this.loadOptions.decodeFileName(D)}}},findExtraFieldUnicodePath:function(){var a=this.extraFields[28789];if(a){var c=B(a.value);return c.readInt(1)!==1||i(this.fileName)!==c.readInt(4)?null:E.utf8decode(c.readData(a.length-5))}return null},findExtraFieldUnicodeComment:function(){var a=this.extraFields[25461];if(a){var c=B(a.value);return c.readInt(1)!==1||i(this.fileComment)!==c.readInt(4)?null:E.utf8decode(c.readData(a.length-5))}return null}},t.exports=r},{"./compressedObject":2,"./compressions":3,"./crc32":4,"./reader/readerFor":22,"./support":30,"./utf8":31,"./utils":32}],35:[function(e,t,o){function B(c,h,l){this.name=c,this.dir=l.dir,this.date=l.date,this.comment=l.comment,this.unixPermissions=l.unixPermissions,this.dosPermissions=l.dosPermissions,this._data=h,this._dataBinary=l.binary,this.options={compression:l.compression,compressionOptions:l.compressionOptions}}var C=e("./stream/StreamHelper"),Q=e("./stream/DataWorker"),i=e("./utf8"),E=e("./compressedObject"),n=e("./stream/GenericWorker");B.prototype={internalStream:function(c){var h=null,l="string";try{if(!c)throw new Error("No output type specified.");var D=(l=c.toLowerCase())==="string"||l==="text";l!=="binarystring"&&l!=="text"||(l="string"),h=this._decompressWorker();var d=!this._dataBinary;d&&!D&&(h=h.pipe(new i.Utf8EncodeWorker)),!d&&D&&(h=h.pipe(new i.Utf8DecodeWorker))}catch(y){(h=new n("error")).error(y)}return new C(h,l,"")},async:function(c,h){return this.internalStream(c).accumulate(h)},nodeStream:function(c,h){return this.internalStream(c||"nodebuffer").toNodejsStream(h)},_compressWorker:function(c,h){if(this._data instanceof E&&this._data.compression.magic===c.magic)return this._data.getCompressedWorker();var l=this._decompressWorker();return this._dataBinary||(l=l.pipe(new i.Utf8EncodeWorker)),E.createWorkerFrom(l,c,h)},_decompressWorker:function(){return this._data instanceof E?this._data.getContentWorker():this._data instanceof n?this._data:new Q(this._data)}};for(var s=["asText","asBinary","asNodeBuffer","asUint8Array","asArrayBuffer"],r=function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},a=0;a<s.length;a++)B.prototype[s[a]]=r;t.exports=B},{"./compressedObject":2,"./stream/DataWorker":27,"./stream/GenericWorker":28,"./stream/StreamHelper":29,"./utf8":31}],36:[function(e,t,o){(function(B){var C,Q,i=B.MutationObserver||B.WebKitMutationObserver;if(i){var E=0,n=new i(c),s=B.document.createTextNode("");n.observe(s,{characterData:!0}),C=function(){s.data=E=++E%2}}else if(B.setImmediate||B.MessageChannel===void 0)C="document"in B&&"onreadystatechange"in B.document.createElement("script")?function(){var h=B.document.createElement("script");h.onreadystatechange=function(){c(),h.onreadystatechange=null,h.parentNode.removeChild(h),h=null},B.document.documentElement.appendChild(h)}:function(){setTimeout(c,0)};else{var r=new B.MessageChannel;r.port1.onmessage=c,C=function(){r.port2.postMessage(0)}}var a=[];function c(){var h,l;Q=!0;for(var D=a.length;D;){for(l=a,a=[],h=-1;++h<D;)l[h]();D=a.length}Q=!1}t.exports=function(h){a.push(h)!==1||Q||C()}}).call(this,typeof OL<"u"?OL:typeof self<"u"?self:typeof window<"u"?window:{})},{}],37:[function(e,t,o){var B=e("immediate");function C(){}var Q={},i=["REJECTED"],E=["FULFILLED"],n=["PENDING"];function s(D){if(typeof D!="function")throw new TypeError("resolver must be a function");this.state=n,this.queue=[],this.outcome=void 0,D!==C&&h(this,D)}function r(D,d,y){this.promise=D,typeof d=="function"&&(this.onFulfilled=d,this.callFulfilled=this.otherCallFulfilled),typeof y=="function"&&(this.onRejected=y,this.callRejected=this.otherCallRejected)}function a(D,d,y){B(function(){var w;try{w=d(y)}catch(u){return Q.reject(D,u)}w===D?Q.reject(D,new TypeError("Cannot resolve promise with itself")):Q.resolve(D,w)})}function c(D){var d=D&&D.then;if(D&&(typeof D=="object"||typeof D=="function")&&typeof d=="function")return function(){d.apply(D,arguments)}}function h(D,d){var y=!1;function w(m){y||(y=!0,Q.reject(D,m))}function u(m){y||(y=!0,Q.resolve(D,m))}var G=l(function(){d(u,w)});G.status==="error"&&w(G.value)}function l(D,d){var y={};try{y.value=D(d),y.status="success"}catch(w){y.status="error",y.value=w}return y}(t.exports=s).prototype.finally=function(D){if(typeof D!="function")return this;var d=this.constructor;return this.then(function(y){return d.resolve(D()).then(function(){return y})},function(y){return d.resolve(D()).then(function(){throw y})})},s.prototype.catch=function(D){return this.then(null,D)},s.prototype.then=function(D,d){if(typeof D!="function"&&this.state===E||typeof d!="function"&&this.state===i)return this;var y=new this.constructor(C);return this.state!==n?a(y,this.state===E?D:d,this.outcome):this.queue.push(new r(y,D,d)),y},r.prototype.callFulfilled=function(D){Q.resolve(this.promise,D)},r.prototype.otherCallFulfilled=function(D){a(this.promise,this.onFulfilled,D)},r.prototype.callRejected=function(D){Q.reject(this.promise,D)},r.prototype.otherCallRejected=function(D){a(this.promise,this.onRejected,D)},Q.resolve=function(D,d){var y=l(c,d);if(y.status==="error")return Q.reject(D,y.value);var w=y.value;if(w)h(D,w);else{D.state=E,D.outcome=d;for(var u=-1,G=D.queue.length;++u<G;)D.queue[u].callFulfilled(d)}return D},Q.reject=function(D,d){D.state=i,D.outcome=d;for(var y=-1,w=D.queue.length;++y<w;)D.queue[y].callRejected(d);return D},s.resolve=function(D){return D instanceof this?D:Q.resolve(new this(C),D)},s.reject=function(D){var d=new this(C);return Q.reject(d,D)},s.all=function(D){var d=this;if(Object.prototype.toString.call(D)!=="[object Array]")return this.reject(new TypeError("must be an array"));var y=D.length,w=!1;if(!y)return this.resolve([]);for(var u=new Array(y),G=0,m=-1,p=new this(C);++m<y;)k(D[m],m);return p;function k(S,R){d.resolve(S).then(function(x){u[R]=x,++G!==y||w||(w=!0,Q.resolve(p,u))},function(x){w||(w=!0,Q.reject(p,x))})}},s.race=function(D){var d=this;if(Object.prototype.toString.call(D)!=="[object Array]")return this.reject(new TypeError("must be an array"));var y=D.length,w=!1;if(!y)return this.resolve([]);for(var u=-1,G=new this(C);++u<y;)m=D[u],d.resolve(m).then(function(p){w||(w=!0,Q.resolve(G,p))},function(p){w||(w=!0,Q.reject(G,p))});var m;return G}},{immediate:36}],38:[function(e,t,o){var B={};(0,e("./lib/utils/common").assign)(B,e("./lib/deflate"),e("./lib/inflate"),e("./lib/zlib/constants")),t.exports=B},{"./lib/deflate":39,"./lib/inflate":40,"./lib/utils/common":41,"./lib/zlib/constants":44}],39:[function(e,t,o){var B=e("./zlib/deflate"),C=e("./utils/common"),Q=e("./utils/strings"),i=e("./zlib/messages"),E=e("./zlib/zstream"),n=Object.prototype.toString,s=0,r=-1,a=0,c=8;function h(D){if(!(this instanceof h))return new h(D);this.options=C.assign({level:r,method:c,chunkSize:16384,windowBits:15,memLevel:8,strategy:a,to:""},D||{});var d=this.options;d.raw&&0<d.windowBits?d.windowBits=-d.windowBits:d.gzip&&0<d.windowBits&&d.windowBits<16&&(d.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new E,this.strm.avail_out=0;var y=B.deflateInit2(this.strm,d.level,d.method,d.windowBits,d.memLevel,d.strategy);if(y!==s)throw new Error(i[y]);if(d.header&&B.deflateSetHeader(this.strm,d.header),d.dictionary){var w;if(w=typeof d.dictionary=="string"?Q.string2buf(d.dictionary):n.call(d.dictionary)==="[object ArrayBuffer]"?new Uint8Array(d.dictionary):d.dictionary,(y=B.deflateSetDictionary(this.strm,w))!==s)throw new Error(i[y]);this._dict_set=!0}}function l(D,d){var y=new h(d);if(y.push(D,!0),y.err)throw y.msg||i[y.err];return y.result}h.prototype.push=function(D,d){var y,w,u=this.strm,G=this.options.chunkSize;if(this.ended)return!1;w=d===~~d?d:d===!0?4:0,typeof D=="string"?u.input=Q.string2buf(D):n.call(D)==="[object ArrayBuffer]"?u.input=new Uint8Array(D):u.input=D,u.next_in=0,u.avail_in=u.input.length;do{if(u.avail_out===0&&(u.output=new C.Buf8(G),u.next_out=0,u.avail_out=G),(y=B.deflate(u,w))!==1&&y!==s)return this.onEnd(y),!(this.ended=!0);u.avail_out!==0&&(u.avail_in!==0||w!==4&&w!==2)||(this.options.to==="string"?this.onData(Q.buf2binstring(C.shrinkBuf(u.output,u.next_out))):this.onData(C.shrinkBuf(u.output,u.next_out)))}while((0<u.avail_in||u.avail_out===0)&&y!==1);return w===4?(y=B.deflateEnd(this.strm),this.onEnd(y),this.ended=!0,y===s):w!==2||(this.onEnd(s),!(u.avail_out=0))},h.prototype.onData=function(D){this.chunks.push(D)},h.prototype.onEnd=function(D){D===s&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=C.flattenChunks(this.chunks)),this.chunks=[],this.err=D,this.msg=this.strm.msg},o.Deflate=h,o.deflate=l,o.deflateRaw=function(D,d){return(d=d||{}).raw=!0,l(D,d)},o.gzip=function(D,d){return(d=d||{}).gzip=!0,l(D,d)}},{"./utils/common":41,"./utils/strings":42,"./zlib/deflate":46,"./zlib/messages":51,"./zlib/zstream":53}],40:[function(e,t,o){var B=e("./zlib/inflate"),C=e("./utils/common"),Q=e("./utils/strings"),i=e("./zlib/constants"),E=e("./zlib/messages"),n=e("./zlib/zstream"),s=e("./zlib/gzheader"),r=Object.prototype.toString;function a(h){if(!(this instanceof a))return new a(h);this.options=C.assign({chunkSize:16384,windowBits:0,to:""},h||{});var l=this.options;l.raw&&0<=l.windowBits&&l.windowBits<16&&(l.windowBits=-l.windowBits,l.windowBits===0&&(l.windowBits=-15)),!(0<=l.windowBits&&l.windowBits<16)||h&&h.windowBits||(l.windowBits+=32),15<l.windowBits&&l.windowBits<48&&(15&l.windowBits)==0&&(l.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new n,this.strm.avail_out=0;var D=B.inflateInit2(this.strm,l.windowBits);if(D!==i.Z_OK)throw new Error(E[D]);this.header=new s,B.inflateGetHeader(this.strm,this.header)}function c(h,l){var D=new a(l);if(D.push(h,!0),D.err)throw D.msg||E[D.err];return D.result}a.prototype.push=function(h,l){var D,d,y,w,u,G,m=this.strm,p=this.options.chunkSize,k=this.options.dictionary,S=!1;if(this.ended)return!1;d=l===~~l?l:l===!0?i.Z_FINISH:i.Z_NO_FLUSH,typeof h=="string"?m.input=Q.binstring2buf(h):r.call(h)==="[object ArrayBuffer]"?m.input=new Uint8Array(h):m.input=h,m.next_in=0,m.avail_in=m.input.length;do{if(m.avail_out===0&&(m.output=new C.Buf8(p),m.next_out=0,m.avail_out=p),(D=B.inflate(m,i.Z_NO_FLUSH))===i.Z_NEED_DICT&&k&&(G=typeof k=="string"?Q.string2buf(k):r.call(k)==="[object ArrayBuffer]"?new Uint8Array(k):k,D=B.inflateSetDictionary(this.strm,G)),D===i.Z_BUF_ERROR&&S===!0&&(D=i.Z_OK,S=!1),D!==i.Z_STREAM_END&&D!==i.Z_OK)return this.onEnd(D),!(this.ended=!0);m.next_out&&(m.avail_out!==0&&D!==i.Z_STREAM_END&&(m.avail_in!==0||d!==i.Z_FINISH&&d!==i.Z_SYNC_FLUSH)||(this.options.to==="string"?(y=Q.utf8border(m.output,m.next_out),w=m.next_out-y,u=Q.buf2string(m.output,y),m.next_out=w,m.avail_out=p-w,w&&C.arraySet(m.output,m.output,y,w,0),this.onData(u)):this.onData(C.shrinkBuf(m.output,m.next_out)))),m.avail_in===0&&m.avail_out===0&&(S=!0)}while((0<m.avail_in||m.avail_out===0)&&D!==i.Z_STREAM_END);return D===i.Z_STREAM_END&&(d=i.Z_FINISH),d===i.Z_FINISH?(D=B.inflateEnd(this.strm),this.onEnd(D),this.ended=!0,D===i.Z_OK):d!==i.Z_SYNC_FLUSH||(this.onEnd(i.Z_OK),!(m.avail_out=0))},a.prototype.onData=function(h){this.chunks.push(h)},a.prototype.onEnd=function(h){h===i.Z_OK&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=C.flattenChunks(this.chunks)),this.chunks=[],this.err=h,this.msg=this.strm.msg},o.Inflate=a,o.inflate=c,o.inflateRaw=function(h,l){return(l=l||{}).raw=!0,c(h,l)},o.ungzip=c},{"./utils/common":41,"./utils/strings":42,"./zlib/constants":44,"./zlib/gzheader":47,"./zlib/inflate":49,"./zlib/messages":51,"./zlib/zstream":53}],41:[function(e,t,o){var B=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Int32Array<"u";o.assign=function(i){for(var E=Array.prototype.slice.call(arguments,1);E.length;){var n=E.shift();if(n){if(typeof n!="object")throw new TypeError(n+"must be non-object");for(var s in n)n.hasOwnProperty(s)&&(i[s]=n[s])}}return i},o.shrinkBuf=function(i,E){return i.length===E?i:i.subarray?i.subarray(0,E):(i.length=E,i)};var C={arraySet:function(i,E,n,s,r){if(E.subarray&&i.subarray)i.set(E.subarray(n,n+s),r);else for(var a=0;a<s;a++)i[r+a]=E[n+a]},flattenChunks:function(i){var E,n,s,r,a,c;for(E=s=0,n=i.length;E<n;E++)s+=i[E].length;for(c=new Uint8Array(s),E=r=0,n=i.length;E<n;E++)a=i[E],c.set(a,r),r+=a.length;return c}},Q={arraySet:function(i,E,n,s,r){for(var a=0;a<s;a++)i[r+a]=E[n+a]},flattenChunks:function(i){return[].concat.apply([],i)}};o.setTyped=function(i){i?(o.Buf8=Uint8Array,o.Buf16=Uint16Array,o.Buf32=Int32Array,o.assign(o,C)):(o.Buf8=Array,o.Buf16=Array,o.Buf32=Array,o.assign(o,Q))},o.setTyped(B)},{}],42:[function(e,t,o){var B=e("./common"),C=!0,Q=!0;try{String.fromCharCode.apply(null,[0])}catch{C=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch{Q=!1}for(var i=new B.Buf8(256),E=0;E<256;E++)i[E]=252<=E?6:248<=E?5:240<=E?4:224<=E?3:192<=E?2:1;function n(s,r){if(r<65537&&(s.subarray&&Q||!s.subarray&&C))return String.fromCharCode.apply(null,B.shrinkBuf(s,r));for(var a="",c=0;c<r;c++)a+=String.fromCharCode(s[c]);return a}i[254]=i[254]=1,o.string2buf=function(s){var r,a,c,h,l,D=s.length,d=0;for(h=0;h<D;h++)(64512&(a=s.charCodeAt(h)))==55296&&h+1<D&&(64512&(c=s.charCodeAt(h+1)))==56320&&(a=65536+(a-55296<<10)+(c-56320),h++),d+=a<128?1:a<2048?2:a<65536?3:4;for(r=new B.Buf8(d),h=l=0;l<d;h++)(64512&(a=s.charCodeAt(h)))==55296&&h+1<D&&(64512&(c=s.charCodeAt(h+1)))==56320&&(a=65536+(a-55296<<10)+(c-56320),h++),a<128?r[l++]=a:(a<2048?r[l++]=192|a>>>6:(a<65536?r[l++]=224|a>>>12:(r[l++]=240|a>>>18,r[l++]=128|a>>>12&63),r[l++]=128|a>>>6&63),r[l++]=128|63&a);return r},o.buf2binstring=function(s){return n(s,s.length)},o.binstring2buf=function(s){for(var r=new B.Buf8(s.length),a=0,c=r.length;a<c;a++)r[a]=s.charCodeAt(a);return r},o.buf2string=function(s,r){var a,c,h,l,D=r||s.length,d=new Array(2*D);for(a=c=0;a<D;)if((h=s[a++])<128)d[c++]=h;else if(4<(l=i[h]))d[c++]=65533,a+=l-1;else{for(h&=l===2?31:l===3?15:7;1<l&&a<D;)h=h<<6|63&s[a++],l--;1<l?d[c++]=65533:h<65536?d[c++]=h:(h-=65536,d[c++]=55296|h>>10&1023,d[c++]=56320|1023&h)}return n(d,c)},o.utf8border=function(s,r){var a;for((r=r||s.length)>s.length&&(r=s.length),a=r-1;0<=a&&(192&s[a])==128;)a--;return a<0||a===0?r:a+i[s[a]]>r?a:r}},{"./common":41}],43:[function(e,t,o){t.exports=function(B,C,Q,i){for(var E=65535&B|0,n=B>>>16&65535|0,s=0;Q!==0;){for(Q-=s=2e3<Q?2e3:Q;n=n+(E=E+C[i++]|0)|0,--s;);E%=65521,n%=65521}return E|n<<16|0}},{}],44:[function(e,t,o){t.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(e,t,o){var B=(function(){for(var C,Q=[],i=0;i<256;i++){C=i;for(var E=0;E<8;E++)C=1&C?3988292384^C>>>1:C>>>1;Q[i]=C}return Q})();t.exports=function(C,Q,i,E){var n=B,s=E+i;C^=-1;for(var r=E;r<s;r++)C=C>>>8^n[255&(C^Q[r])];return-1^C}},{}],46:[function(e,t,o){var B,C=e("../utils/common"),Q=e("./trees"),i=e("./adler32"),E=e("./crc32"),n=e("./messages"),s=0,r=4,a=0,c=-2,h=-1,l=4,D=2,d=8,y=9,w=286,u=30,G=19,m=2*w+1,p=15,k=3,S=258,R=S+k+1,x=42,N=113,J=1,K=2,_=3,b=4;function T(aA,FA){return aA.msg=n[FA],FA}function j(aA){return(aA<<1)-(4<aA?9:0)}function O(aA){for(var FA=aA.length;0<=--FA;)aA[FA]=0}function W(aA){var FA=aA.state,NA=FA.pending;NA>aA.avail_out&&(NA=aA.avail_out),NA!==0&&(C.arraySet(aA.output,FA.pending_buf,FA.pending_out,NA,aA.next_out),aA.next_out+=NA,FA.pending_out+=NA,aA.total_out+=NA,aA.avail_out-=NA,FA.pending-=NA,FA.pending===0&&(FA.pending_out=0))}function gA(aA,FA){Q._tr_flush_block(aA,0<=aA.block_start?aA.block_start:-1,aA.strstart-aA.block_start,FA),aA.block_start=aA.strstart,W(aA.strm)}function tA(aA,FA){aA.pending_buf[aA.pending++]=FA}function IA(aA,FA){aA.pending_buf[aA.pending++]=FA>>>8&255,aA.pending_buf[aA.pending++]=255&FA}function QA(aA,FA){var NA,RA,JA=aA.max_chain_length,PA=aA.strstart,mA=aA.prev_length,YA=aA.nice_match,dA=aA.strstart>aA.w_size-R?aA.strstart-(aA.w_size-R):0,HA=aA.window,WA=aA.w_mask,Qg=aA.prev,_A=aA.strstart+S,GA=HA[PA+mA-1],kA=HA[PA+mA];aA.prev_length>=aA.good_match&&(JA>>=2),YA>aA.lookahead&&(YA=aA.lookahead);do if(HA[(NA=FA)+mA]===kA&&HA[NA+mA-1]===GA&&HA[NA]===HA[PA]&&HA[++NA]===HA[PA+1]){PA+=2,NA++;do;while(HA[++PA]===HA[++NA]&&HA[++PA]===HA[++NA]&&HA[++PA]===HA[++NA]&&HA[++PA]===HA[++NA]&&HA[++PA]===HA[++NA]&&HA[++PA]===HA[++NA]&&HA[++PA]===HA[++NA]&&HA[++PA]===HA[++NA]&&PA<_A);if(RA=S-(_A-PA),PA=_A-S,mA<RA){if(aA.match_start=FA,YA<=(mA=RA))break;GA=HA[PA+mA-1],kA=HA[PA+mA]}}while((FA=Qg[FA&WA])>dA&&--JA!=0);return mA<=aA.lookahead?mA:aA.lookahead}function nA(aA){var FA,NA,RA,JA,PA,mA,YA,dA,HA,WA,Qg=aA.w_size;do{if(JA=aA.window_size-aA.lookahead-aA.strstart,aA.strstart>=Qg+(Qg-R)){for(C.arraySet(aA.window,aA.window,Qg,Qg,0),aA.match_start-=Qg,aA.strstart-=Qg,aA.block_start-=Qg,FA=NA=aA.hash_size;RA=aA.head[--FA],aA.head[FA]=Qg<=RA?RA-Qg:0,--NA;);for(FA=NA=Qg;RA=aA.prev[--FA],aA.prev[FA]=Qg<=RA?RA-Qg:0,--NA;);JA+=Qg}if(aA.strm.avail_in===0)break;if(mA=aA.strm,YA=aA.window,dA=aA.strstart+aA.lookahead,HA=JA,WA=void 0,WA=mA.avail_in,HA<WA&&(WA=HA),NA=WA===0?0:(mA.avail_in-=WA,C.arraySet(YA,mA.input,mA.next_in,WA,dA),mA.state.wrap===1?mA.adler=i(mA.adler,YA,WA,dA):mA.state.wrap===2&&(mA.adler=E(mA.adler,YA,WA,dA)),mA.next_in+=WA,mA.total_in+=WA,WA),aA.lookahead+=NA,aA.lookahead+aA.insert>=k)for(PA=aA.strstart-aA.insert,aA.ins_h=aA.window[PA],aA.ins_h=(aA.ins_h<<aA.hash_shift^aA.window[PA+1])&aA.hash_mask;aA.insert&&(aA.ins_h=(aA.ins_h<<aA.hash_shift^aA.window[PA+k-1])&aA.hash_mask,aA.prev[PA&aA.w_mask]=aA.head[aA.ins_h],aA.head[aA.ins_h]=PA,PA++,aA.insert--,!(aA.lookahead+aA.insert<k)););}while(aA.lookahead<R&&aA.strm.avail_in!==0)}function DA(aA,FA){for(var NA,RA;;){if(aA.lookahead<R){if(nA(aA),aA.lookahead<R&&FA===s)return J;if(aA.lookahead===0)break}if(NA=0,aA.lookahead>=k&&(aA.ins_h=(aA.ins_h<<aA.hash_shift^aA.window[aA.strstart+k-1])&aA.hash_mask,NA=aA.prev[aA.strstart&aA.w_mask]=aA.head[aA.ins_h],aA.head[aA.ins_h]=aA.strstart),NA!==0&&aA.strstart-NA<=aA.w_size-R&&(aA.match_length=QA(aA,NA)),aA.match_length>=k)if(RA=Q._tr_tally(aA,aA.strstart-aA.match_start,aA.match_length-k),aA.lookahead-=aA.match_length,aA.match_length<=aA.max_lazy_match&&aA.lookahead>=k){for(aA.match_length--;aA.strstart++,aA.ins_h=(aA.ins_h<<aA.hash_shift^aA.window[aA.strstart+k-1])&aA.hash_mask,NA=aA.prev[aA.strstart&aA.w_mask]=aA.head[aA.ins_h],aA.head[aA.ins_h]=aA.strstart,--aA.match_length!=0;);aA.strstart++}else aA.strstart+=aA.match_length,aA.match_length=0,aA.ins_h=aA.window[aA.strstart],aA.ins_h=(aA.ins_h<<aA.hash_shift^aA.window[aA.strstart+1])&aA.hash_mask;else RA=Q._tr_tally(aA,0,aA.window[aA.strstart]),aA.lookahead--,aA.strstart++;if(RA&&(gA(aA,!1),aA.strm.avail_out===0))return J}return aA.insert=aA.strstart<k-1?aA.strstart:k-1,FA===r?(gA(aA,!0),aA.strm.avail_out===0?_:b):aA.last_lit&&(gA(aA,!1),aA.strm.avail_out===0)?J:K}function CA(aA,FA){for(var NA,RA,JA;;){if(aA.lookahead<R){if(nA(aA),aA.lookahead<R&&FA===s)return J;if(aA.lookahead===0)break}if(NA=0,aA.lookahead>=k&&(aA.ins_h=(aA.ins_h<<aA.hash_shift^aA.window[aA.strstart+k-1])&aA.hash_mask,NA=aA.prev[aA.strstart&aA.w_mask]=aA.head[aA.ins_h],aA.head[aA.ins_h]=aA.strstart),aA.prev_length=aA.match_length,aA.prev_match=aA.match_start,aA.match_length=k-1,NA!==0&&aA.prev_length<aA.max_lazy_match&&aA.strstart-NA<=aA.w_size-R&&(aA.match_length=QA(aA,NA),aA.match_length<=5&&(aA.strategy===1||aA.match_length===k&&4096<aA.strstart-aA.match_start)&&(aA.match_length=k-1)),aA.prev_length>=k&&aA.match_length<=aA.prev_length){for(JA=aA.strstart+aA.lookahead-k,RA=Q._tr_tally(aA,aA.strstart-1-aA.prev_match,aA.prev_length-k),aA.lookahead-=aA.prev_length-1,aA.prev_length-=2;++aA.strstart<=JA&&(aA.ins_h=(aA.ins_h<<aA.hash_shift^aA.window[aA.strstart+k-1])&aA.hash_mask,NA=aA.prev[aA.strstart&aA.w_mask]=aA.head[aA.ins_h],aA.head[aA.ins_h]=aA.strstart),--aA.prev_length!=0;);if(aA.match_available=0,aA.match_length=k-1,aA.strstart++,RA&&(gA(aA,!1),aA.strm.avail_out===0))return J}else if(aA.match_available){if((RA=Q._tr_tally(aA,0,aA.window[aA.strstart-1]))&&gA(aA,!1),aA.strstart++,aA.lookahead--,aA.strm.avail_out===0)return J}else aA.match_available=1,aA.strstart++,aA.lookahead--}return aA.match_available&&(RA=Q._tr_tally(aA,0,aA.window[aA.strstart-1]),aA.match_available=0),aA.insert=aA.strstart<k-1?aA.strstart:k-1,FA===r?(gA(aA,!0),aA.strm.avail_out===0?_:b):aA.last_lit&&(gA(aA,!1),aA.strm.avail_out===0)?J:K}function hA(aA,FA,NA,RA,JA){this.good_length=aA,this.max_lazy=FA,this.nice_length=NA,this.max_chain=RA,this.func=JA}function sA(){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=d,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 C.Buf16(2*m),this.dyn_dtree=new C.Buf16(2*(2*u+1)),this.bl_tree=new C.Buf16(2*(2*G+1)),O(this.dyn_ltree),O(this.dyn_dtree),O(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new C.Buf16(p+1),this.heap=new C.Buf16(2*w+1),O(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new C.Buf16(2*w+1),O(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 cA(aA){var FA;return aA&&aA.state?(aA.total_in=aA.total_out=0,aA.data_type=D,(FA=aA.state).pending=0,FA.pending_out=0,FA.wrap<0&&(FA.wrap=-FA.wrap),FA.status=FA.wrap?x:N,aA.adler=FA.wrap===2?0:1,FA.last_flush=s,Q._tr_init(FA),a):T(aA,c)}function SA(aA){var FA=cA(aA);return FA===a&&(function(NA){NA.window_size=2*NA.w_size,O(NA.head),NA.max_lazy_match=B[NA.level].max_lazy,NA.good_match=B[NA.level].good_length,NA.nice_match=B[NA.level].nice_length,NA.max_chain_length=B[NA.level].max_chain,NA.strstart=0,NA.block_start=0,NA.lookahead=0,NA.insert=0,NA.match_length=NA.prev_length=k-1,NA.match_available=0,NA.ins_h=0})(aA.state),FA}function xA(aA,FA,NA,RA,JA,PA){if(!aA)return c;var mA=1;if(FA===h&&(FA=6),RA<0?(mA=0,RA=-RA):15<RA&&(mA=2,RA-=16),JA<1||y<JA||NA!==d||RA<8||15<RA||FA<0||9<FA||PA<0||l<PA)return T(aA,c);RA===8&&(RA=9);var YA=new sA;return(aA.state=YA).strm=aA,YA.wrap=mA,YA.gzhead=null,YA.w_bits=RA,YA.w_size=1<<YA.w_bits,YA.w_mask=YA.w_size-1,YA.hash_bits=JA+7,YA.hash_size=1<<YA.hash_bits,YA.hash_mask=YA.hash_size-1,YA.hash_shift=~~((YA.hash_bits+k-1)/k),YA.window=new C.Buf8(2*YA.w_size),YA.head=new C.Buf16(YA.hash_size),YA.prev=new C.Buf16(YA.w_size),YA.lit_bufsize=1<<JA+6,YA.pending_buf_size=4*YA.lit_bufsize,YA.pending_buf=new C.Buf8(YA.pending_buf_size),YA.d_buf=1*YA.lit_bufsize,YA.l_buf=3*YA.lit_bufsize,YA.level=FA,YA.strategy=PA,YA.method=NA,SA(aA)}B=[new hA(0,0,0,0,function(aA,FA){var NA=65535;for(NA>aA.pending_buf_size-5&&(NA=aA.pending_buf_size-5);;){if(aA.lookahead<=1){if(nA(aA),aA.lookahead===0&&FA===s)return J;if(aA.lookahead===0)break}aA.strstart+=aA.lookahead,aA.lookahead=0;var RA=aA.block_start+NA;if((aA.strstart===0||aA.strstart>=RA)&&(aA.lookahead=aA.strstart-RA,aA.strstart=RA,gA(aA,!1),aA.strm.avail_out===0)||aA.strstart-aA.block_start>=aA.w_size-R&&(gA(aA,!1),aA.strm.avail_out===0))return J}return aA.insert=0,FA===r?(gA(aA,!0),aA.strm.avail_out===0?_:b):(aA.strstart>aA.block_start&&(gA(aA,!1),aA.strm.avail_out),J)}),new hA(4,4,8,4,DA),new hA(4,5,16,8,DA),new hA(4,6,32,32,DA),new hA(4,4,16,16,CA),new hA(8,16,32,32,CA),new hA(8,16,128,128,CA),new hA(8,32,128,256,CA),new hA(32,128,258,1024,CA),new hA(32,258,258,4096,CA)],o.deflateInit=function(aA,FA){return xA(aA,FA,d,15,8,0)},o.deflateInit2=xA,o.deflateReset=SA,o.deflateResetKeep=cA,o.deflateSetHeader=function(aA,FA){return aA&&aA.state?aA.state.wrap!==2?c:(aA.state.gzhead=FA,a):c},o.deflate=function(aA,FA){var NA,RA,JA,PA;if(!aA||!aA.state||5<FA||FA<0)return aA?T(aA,c):c;if(RA=aA.state,!aA.output||!aA.input&&aA.avail_in!==0||RA.status===666&&FA!==r)return T(aA,aA.avail_out===0?-5:c);if(RA.strm=aA,NA=RA.last_flush,RA.last_flush=FA,RA.status===x)if(RA.wrap===2)aA.adler=0,tA(RA,31),tA(RA,139),tA(RA,8),RA.gzhead?(tA(RA,(RA.gzhead.text?1:0)+(RA.gzhead.hcrc?2:0)+(RA.gzhead.extra?4:0)+(RA.gzhead.name?8:0)+(RA.gzhead.comment?16:0)),tA(RA,255&RA.gzhead.time),tA(RA,RA.gzhead.time>>8&255),tA(RA,RA.gzhead.time>>16&255),tA(RA,RA.gzhead.time>>24&255),tA(RA,RA.level===9?2:2<=RA.strategy||RA.level<2?4:0),tA(RA,255&RA.gzhead.os),RA.gzhead.extra&&RA.gzhead.extra.length&&(tA(RA,255&RA.gzhead.extra.length),tA(RA,RA.gzhead.extra.length>>8&255)),RA.gzhead.hcrc&&(aA.adler=E(aA.adler,RA.pending_buf,RA.pending,0)),RA.gzindex=0,RA.status=69):(tA(RA,0),tA(RA,0),tA(RA,0),tA(RA,0),tA(RA,0),tA(RA,RA.level===9?2:2<=RA.strategy||RA.level<2?4:0),tA(RA,3),RA.status=N);else{var mA=d+(RA.w_bits-8<<4)<<8;mA|=(2<=RA.strategy||RA.level<2?0:RA.level<6?1:RA.level===6?2:3)<<6,RA.strstart!==0&&(mA|=32),mA+=31-mA%31,RA.status=N,IA(RA,mA),RA.strstart!==0&&(IA(RA,aA.adler>>>16),IA(RA,65535&aA.adler)),aA.adler=1}if(RA.status===69)if(RA.gzhead.extra){for(JA=RA.pending;RA.gzindex<(65535&RA.gzhead.extra.length)&&(RA.pending!==RA.pending_buf_size||(RA.gzhead.hcrc&&RA.pending>JA&&(aA.adler=E(aA.adler,RA.pending_buf,RA.pending-JA,JA)),W(aA),JA=RA.pending,RA.pending!==RA.pending_buf_size));)tA(RA,255&RA.gzhead.extra[RA.gzindex]),RA.gzindex++;RA.gzhead.hcrc&&RA.pending>JA&&(aA.adler=E(aA.adler,RA.pending_buf,RA.pending-JA,JA)),RA.gzindex===RA.gzhead.extra.length&&(RA.gzindex=0,RA.status=73)}else RA.status=73;if(RA.status===73)if(RA.gzhead.name){JA=RA.pending;do{if(RA.pending===RA.pending_buf_size&&(RA.gzhead.hcrc&&RA.pending>JA&&(aA.adler=E(aA.adler,RA.pending_buf,RA.pending-JA,JA)),W(aA),JA=RA.pending,RA.pending===RA.pending_buf_size)){PA=1;break}PA=RA.gzindex<RA.gzhead.name.length?255&RA.gzhead.name.charCodeAt(RA.gzindex++):0,tA(RA,PA)}while(PA!==0);RA.gzhead.hcrc&&RA.pending>JA&&(aA.adler=E(aA.adler,RA.pending_buf,RA.pending-JA,JA)),PA===0&&(RA.gzindex=0,RA.status=91)}else RA.status=91;if(RA.status===91)if(RA.gzhead.comment){JA=RA.pending;do{if(RA.pending===RA.pending_buf_size&&(RA.gzhead.hcrc&&RA.pending>JA&&(aA.adler=E(aA.adler,RA.pending_buf,RA.pending-JA,JA)),W(aA),JA=RA.pending,RA.pending===RA.pending_buf_size)){PA=1;break}PA=RA.gzindex<RA.gzhead.comment.length?255&RA.gzhead.comment.charCodeAt(RA.gzindex++):0,tA(RA,PA)}while(PA!==0);RA.gzhead.hcrc&&RA.pending>JA&&(aA.adler=E(aA.adler,RA.pending_buf,RA.pending-JA,JA)),PA===0&&(RA.status=103)}else RA.status=103;if(RA.status===103&&(RA.gzhead.hcrc?(RA.pending+2>RA.pending_buf_size&&W(aA),RA.pending+2<=RA.pending_buf_size&&(tA(RA,255&aA.adler),tA(RA,aA.adler>>8&255),aA.adler=0,RA.status=N)):RA.status=N),RA.pending!==0){if(W(aA),aA.avail_out===0)return RA.last_flush=-1,a}else if(aA.avail_in===0&&j(FA)<=j(NA)&&FA!==r)return T(aA,-5);if(RA.status===666&&aA.avail_in!==0)return T(aA,-5);if(aA.avail_in!==0||RA.lookahead!==0||FA!==s&&RA.status!==666){var YA=RA.strategy===2?(function(dA,HA){for(var WA;;){if(dA.lookahead===0&&(nA(dA),dA.lookahead===0)){if(HA===s)return J;break}if(dA.match_length=0,WA=Q._tr_tally(dA,0,dA.window[dA.strstart]),dA.lookahead--,dA.strstart++,WA&&(gA(dA,!1),dA.strm.avail_out===0))return J}return dA.insert=0,HA===r?(gA(dA,!0),dA.strm.avail_out===0?_:b):dA.last_lit&&(gA(dA,!1),dA.strm.avail_out===0)?J:K})(RA,FA):RA.strategy===3?(function(dA,HA){for(var WA,Qg,_A,GA,kA=dA.window;;){if(dA.lookahead<=S){if(nA(dA),dA.lookahead<=S&&HA===s)return J;if(dA.lookahead===0)break}if(dA.match_length=0,dA.lookahead>=k&&0<dA.strstart&&(Qg=kA[_A=dA.strstart-1])===kA[++_A]&&Qg===kA[++_A]&&Qg===kA[++_A]){GA=dA.strstart+S;do;while(Qg===kA[++_A]&&Qg===kA[++_A]&&Qg===kA[++_A]&&Qg===kA[++_A]&&Qg===kA[++_A]&&Qg===kA[++_A]&&Qg===kA[++_A]&&Qg===kA[++_A]&&_A<GA);dA.match_length=S-(GA-_A),dA.match_length>dA.lookahead&&(dA.match_length=dA.lookahead)}if(dA.match_length>=k?(WA=Q._tr_tally(dA,1,dA.match_length-k),dA.lookahead-=dA.match_length,dA.strstart+=dA.match_length,dA.match_length=0):(WA=Q._tr_tally(dA,0,dA.window[dA.strstart]),dA.lookahead--,dA.strstart++),WA&&(gA(dA,!1),dA.strm.avail_out===0))return J}return dA.insert=0,HA===r?(gA(dA,!0),dA.strm.avail_out===0?_:b):dA.last_lit&&(gA(dA,!1),dA.strm.avail_out===0)?J:K})(RA,FA):B[RA.level].func(RA,FA);if(YA!==_&&YA!==b||(RA.status=666),YA===J||YA===_)return aA.avail_out===0&&(RA.last_flush=-1),a;if(YA===K&&(FA===1?Q._tr_align(RA):FA!==5&&(Q._tr_stored_block(RA,0,0,!1),FA===3&&(O(RA.head),RA.lookahead===0&&(RA.strstart=0,RA.block_start=0,RA.insert=0))),W(aA),aA.avail_out===0))return RA.last_flush=-1,a}return FA!==r?a:RA.wrap<=0?1:(RA.wrap===2?(tA(RA,255&aA.adler),tA(RA,aA.adler>>8&255),tA(RA,aA.adler>>16&255),tA(RA,aA.adler>>24&255),tA(RA,255&aA.total_in),tA(RA,aA.total_in>>8&255),tA(RA,aA.total_in>>16&255),tA(RA,aA.total_in>>24&255)):(IA(RA,aA.adler>>>16),IA(RA,65535&aA.adler)),W(aA),0<RA.wrap&&(RA.wrap=-RA.wrap),RA.pending!==0?a:1)},o.deflateEnd=function(aA){var FA;return aA&&aA.state?(FA=aA.state.status)!==x&&FA!==69&&FA!==73&&FA!==91&&FA!==103&&FA!==N&&FA!==666?T(aA,c):(aA.state=null,FA===N?T(aA,-3):a):c},o.deflateSetDictionary=function(aA,FA){var NA,RA,JA,PA,mA,YA,dA,HA,WA=FA.length;if(!aA||!aA.state||(PA=(NA=aA.state).wrap)===2||PA===1&&NA.status!==x||NA.lookahead)return c;for(PA===1&&(aA.adler=i(aA.adler,FA,WA,0)),NA.wrap=0,WA>=NA.w_size&&(PA===0&&(O(NA.head),NA.strstart=0,NA.block_start=0,NA.insert=0),HA=new C.Buf8(NA.w_size),C.arraySet(HA,FA,WA-NA.w_size,NA.w_size,0),FA=HA,WA=NA.w_size),mA=aA.avail_in,YA=aA.next_in,dA=aA.input,aA.avail_in=WA,aA.next_in=0,aA.input=FA,nA(NA);NA.lookahead>=k;){for(RA=NA.strstart,JA=NA.lookahead-(k-1);NA.ins_h=(NA.ins_h<<NA.hash_shift^NA.window[RA+k-1])&NA.hash_mask,NA.prev[RA&NA.w_mask]=NA.head[NA.ins_h],NA.head[NA.ins_h]=RA,RA++,--JA;);NA.strstart=RA,NA.lookahead=k-1,nA(NA)}return NA.strstart+=NA.lookahead,NA.block_start=NA.strstart,NA.insert=NA.lookahead,NA.lookahead=0,NA.match_length=NA.prev_length=k-1,NA.match_available=0,aA.next_in=YA,aA.input=dA,aA.avail_in=mA,NA.wrap=PA,a},o.deflateInfo="pako deflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./messages":51,"./trees":52}],47:[function(e,t,o){t.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(e,t,o){t.exports=function(B,C){var Q,i,E,n,s,r,a,c,h,l,D,d,y,w,u,G,m,p,k,S,R,x,N,J,K;Q=B.state,i=B.next_in,J=B.input,E=i+(B.avail_in-5),n=B.next_out,K=B.output,s=n-(C-B.avail_out),r=n+(B.avail_out-257),a=Q.dmax,c=Q.wsize,h=Q.whave,l=Q.wnext,D=Q.window,d=Q.hold,y=Q.bits,w=Q.lencode,u=Q.distcode,G=(1<<Q.lenbits)-1,m=(1<<Q.distbits)-1;A:do{y<15&&(d+=J[i++]<<y,y+=8,d+=J[i++]<<y,y+=8),p=w[d&G];g:for(;;){if(d>>>=k=p>>>24,y-=k,(k=p>>>16&255)===0)K[n++]=65535&p;else{if(!(16&k)){if((64&k)==0){p=w[(65535&p)+(d&(1<<k)-1)];continue g}if(32&k){Q.mode=12;break A}B.msg="invalid literal/length code",Q.mode=30;break A}S=65535&p,(k&=15)&&(y<k&&(d+=J[i++]<<y,y+=8),S+=d&(1<<k)-1,d>>>=k,y-=k),y<15&&(d+=J[i++]<<y,y+=8,d+=J[i++]<<y,y+=8),p=u[d&m];I:for(;;){if(d>>>=k=p>>>24,y-=k,!(16&(k=p>>>16&255))){if((64&k)==0){p=u[(65535&p)+(d&(1<<k)-1)];continue I}B.msg="invalid distance code",Q.mode=30;break A}if(R=65535&p,y<(k&=15)&&(d+=J[i++]<<y,(y+=8)<k&&(d+=J[i++]<<y,y+=8)),a<(R+=d&(1<<k)-1)){B.msg="invalid distance too far back",Q.mode=30;break A}if(d>>>=k,y-=k,(k=n-s)<R){if(h<(k=R-k)&&Q.sane){B.msg="invalid distance too far back",Q.mode=30;break A}if(N=D,(x=0)===l){if(x+=c-k,k<S){for(S-=k;K[n++]=D[x++],--k;);x=n-R,N=K}}else if(l<k){if(x+=c+l-k,(k-=l)<S){for(S-=k;K[n++]=D[x++],--k;);if(x=0,l<S){for(S-=k=l;K[n++]=D[x++],--k;);x=n-R,N=K}}}else if(x+=l-k,k<S){for(S-=k;K[n++]=D[x++],--k;);x=n-R,N=K}for(;2<S;)K[n++]=N[x++],K[n++]=N[x++],K[n++]=N[x++],S-=3;S&&(K[n++]=N[x++],1<S&&(K[n++]=N[x++]))}else{for(x=n-R;K[n++]=K[x++],K[n++]=K[x++],K[n++]=K[x++],2<(S-=3););S&&(K[n++]=K[x++],1<S&&(K[n++]=K[x++]))}break}}break}}while(i<E&&n<r);i-=S=y>>3,d&=(1<<(y-=S<<3))-1,B.next_in=i,B.next_out=n,B.avail_in=i<E?E-i+5:5-(i-E),B.avail_out=n<r?r-n+257:257-(n-r),Q.hold=d,Q.bits=y}},{}],49:[function(e,t,o){var B=e("../utils/common"),C=e("./adler32"),Q=e("./crc32"),i=e("./inffast"),E=e("./inftrees"),n=1,s=2,r=0,a=-2,c=1,h=852,l=592;function D(x){return(x>>>24&255)+(x>>>8&65280)+((65280&x)<<8)+((255&x)<<24)}function d(){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 B.Buf16(320),this.work=new B.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function y(x){var N;return x&&x.state?(N=x.state,x.total_in=x.total_out=N.total=0,x.msg="",N.wrap&&(x.adler=1&N.wrap),N.mode=c,N.last=0,N.havedict=0,N.dmax=32768,N.head=null,N.hold=0,N.bits=0,N.lencode=N.lendyn=new B.Buf32(h),N.distcode=N.distdyn=new B.Buf32(l),N.sane=1,N.back=-1,r):a}function w(x){var N;return x&&x.state?((N=x.state).wsize=0,N.whave=0,N.wnext=0,y(x)):a}function u(x,N){var J,K;return x&&x.state?(K=x.state,N<0?(J=0,N=-N):(J=1+(N>>4),N<48&&(N&=15)),N&&(N<8||15<N)?a:(K.window!==null&&K.wbits!==N&&(K.window=null),K.wrap=J,K.wbits=N,w(x))):a}function G(x,N){var J,K;return x?(K=new d,(x.state=K).window=null,(J=u(x,N))!==r&&(x.state=null),J):a}var m,p,k=!0;function S(x){if(k){var N;for(m=new B.Buf32(512),p=new B.Buf32(32),N=0;N<144;)x.lens[N++]=8;for(;N<256;)x.lens[N++]=9;for(;N<280;)x.lens[N++]=7;for(;N<288;)x.lens[N++]=8;for(E(n,x.lens,0,288,m,0,x.work,{bits:9}),N=0;N<32;)x.lens[N++]=5;E(s,x.lens,0,32,p,0,x.work,{bits:5}),k=!1}x.lencode=m,x.lenbits=9,x.distcode=p,x.distbits=5}function R(x,N,J,K){var _,b=x.state;return b.window===null&&(b.wsize=1<<b.wbits,b.wnext=0,b.whave=0,b.window=new B.Buf8(b.wsize)),K>=b.wsize?(B.arraySet(b.window,N,J-b.wsize,b.wsize,0),b.wnext=0,b.whave=b.wsize):(K<(_=b.wsize-b.wnext)&&(_=K),B.arraySet(b.window,N,J-K,_,b.wnext),(K-=_)?(B.arraySet(b.window,N,J-K,K,0),b.wnext=K,b.whave=b.wsize):(b.wnext+=_,b.wnext===b.wsize&&(b.wnext=0),b.whave<b.wsize&&(b.whave+=_))),0}o.inflateReset=w,o.inflateReset2=u,o.inflateResetKeep=y,o.inflateInit=function(x){return G(x,15)},o.inflateInit2=G,o.inflate=function(x,N){var J,K,_,b,T,j,O,W,gA,tA,IA,QA,nA,DA,CA,hA,sA,cA,SA,xA,aA,FA,NA,RA,JA=0,PA=new B.Buf8(4),mA=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!x||!x.state||!x.output||!x.input&&x.avail_in!==0)return a;(J=x.state).mode===12&&(J.mode=13),T=x.next_out,_=x.output,O=x.avail_out,b=x.next_in,K=x.input,j=x.avail_in,W=J.hold,gA=J.bits,tA=j,IA=O,FA=r;A:for(;;)switch(J.mode){case c:if(J.wrap===0){J.mode=13;break}for(;gA<16;){if(j===0)break A;j--,W+=K[b++]<<gA,gA+=8}if(2&J.wrap&&W===35615){PA[J.check=0]=255&W,PA[1]=W>>>8&255,J.check=Q(J.check,PA,2,0),gA=W=0,J.mode=2;break}if(J.flags=0,J.head&&(J.head.done=!1),!(1&J.wrap)||(((255&W)<<8)+(W>>8))%31){x.msg="incorrect header check",J.mode=30;break}if((15&W)!=8){x.msg="unknown compression method",J.mode=30;break}if(gA-=4,aA=8+(15&(W>>>=4)),J.wbits===0)J.wbits=aA;else if(aA>J.wbits){x.msg="invalid window size",J.mode=30;break}J.dmax=1<<aA,x.adler=J.check=1,J.mode=512&W?10:12,gA=W=0;break;case 2:for(;gA<16;){if(j===0)break A;j--,W+=K[b++]<<gA,gA+=8}if(J.flags=W,(255&J.flags)!=8){x.msg="unknown compression method",J.mode=30;break}if(57344&J.flags){x.msg="unknown header flags set",J.mode=30;break}J.head&&(J.head.text=W>>8&1),512&J.flags&&(PA[0]=255&W,PA[1]=W>>>8&255,J.check=Q(J.check,PA,2,0)),gA=W=0,J.mode=3;case 3:for(;gA<32;){if(j===0)break A;j--,W+=K[b++]<<gA,gA+=8}J.head&&(J.head.time=W),512&J.flags&&(PA[0]=255&W,PA[1]=W>>>8&255,PA[2]=W>>>16&255,PA[3]=W>>>24&255,J.check=Q(J.check,PA,4,0)),gA=W=0,J.mode=4;case 4:for(;gA<16;){if(j===0)break A;j--,W+=K[b++]<<gA,gA+=8}J.head&&(J.head.xflags=255&W,J.head.os=W>>8),512&J.flags&&(PA[0]=255&W,PA[1]=W>>>8&255,J.check=Q(J.check,PA,2,0)),gA=W=0,J.mode=5;case 5:if(1024&J.flags){for(;gA<16;){if(j===0)break A;j--,W+=K[b++]<<gA,gA+=8}J.length=W,J.head&&(J.head.extra_len=W),512&J.flags&&(PA[0]=255&W,PA[1]=W>>>8&255,J.check=Q(J.check,PA,2,0)),gA=W=0}else J.head&&(J.head.extra=null);J.mode=6;case 6:if(1024&J.flags&&(j<(QA=J.length)&&(QA=j),QA&&(J.head&&(aA=J.head.extra_len-J.length,J.head.extra||(J.head.extra=new Array(J.head.extra_len)),B.arraySet(J.head.extra,K,b,QA,aA)),512&J.flags&&(J.check=Q(J.check,K,QA,b)),j-=QA,b+=QA,J.length-=QA),J.length))break A;J.length=0,J.mode=7;case 7:if(2048&J.flags){if(j===0)break A;for(QA=0;aA=K[b+QA++],J.head&&aA&&J.length<65536&&(J.head.name+=String.fromCharCode(aA)),aA&&QA<j;);if(512&J.flags&&(J.check=Q(J.check,K,QA,b)),j-=QA,b+=QA,aA)break A}else J.head&&(J.head.name=null);J.length=0,J.mode=8;case 8:if(4096&J.flags){if(j===0)break A;for(QA=0;aA=K[b+QA++],J.head&&aA&&J.length<65536&&(J.head.comment+=String.fromCharCode(aA)),aA&&QA<j;);if(512&J.flags&&(J.check=Q(J.check,K,QA,b)),j-=QA,b+=QA,aA)break A}else J.head&&(J.head.comment=null);J.mode=9;case 9:if(512&J.flags){for(;gA<16;){if(j===0)break A;j--,W+=K[b++]<<gA,gA+=8}if(W!==(65535&J.check)){x.msg="header crc mismatch",J.mode=30;break}gA=W=0}J.head&&(J.head.hcrc=J.flags>>9&1,J.head.done=!0),x.adler=J.check=0,J.mode=12;break;case 10:for(;gA<32;){if(j===0)break A;j--,W+=K[b++]<<gA,gA+=8}x.adler=J.check=D(W),gA=W=0,J.mode=11;case 11:if(J.havedict===0)return x.next_out=T,x.avail_out=O,x.next_in=b,x.avail_in=j,J.hold=W,J.bits=gA,2;x.adler=J.check=1,J.mode=12;case 12:if(N===5||N===6)break A;case 13:if(J.last){W>>>=7&gA,gA-=7&gA,J.mode=27;break}for(;gA<3;){if(j===0)break A;j--,W+=K[b++]<<gA,gA+=8}switch(J.last=1&W,gA-=1,3&(W>>>=1)){case 0:J.mode=14;break;case 1:if(S(J),J.mode=20,N!==6)break;W>>>=2,gA-=2;break A;case 2:J.mode=17;break;case 3:x.msg="invalid block type",J.mode=30}W>>>=2,gA-=2;break;case 14:for(W>>>=7&gA,gA-=7&gA;gA<32;){if(j===0)break A;j--,W+=K[b++]<<gA,gA+=8}if((65535&W)!=(W>>>16^65535)){x.msg="invalid stored block lengths",J.mode=30;break}if(J.length=65535&W,gA=W=0,J.mode=15,N===6)break A;case 15:J.mode=16;case 16:if(QA=J.length){if(j<QA&&(QA=j),O<QA&&(QA=O),QA===0)break A;B.arraySet(_,K,b,QA,T),j-=QA,b+=QA,O-=QA,T+=QA,J.length-=QA;break}J.mode=12;break;case 17:for(;gA<14;){if(j===0)break A;j--,W+=K[b++]<<gA,gA+=8}if(J.nlen=257+(31&W),W>>>=5,gA-=5,J.ndist=1+(31&W),W>>>=5,gA-=5,J.ncode=4+(15&W),W>>>=4,gA-=4,286<J.nlen||30<J.ndist){x.msg="too many length or distance symbols",J.mode=30;break}J.have=0,J.mode=18;case 18:for(;J.have<J.ncode;){for(;gA<3;){if(j===0)break A;j--,W+=K[b++]<<gA,gA+=8}J.lens[mA[J.have++]]=7&W,W>>>=3,gA-=3}for(;J.have<19;)J.lens[mA[J.have++]]=0;if(J.lencode=J.lendyn,J.lenbits=7,NA={bits:J.lenbits},FA=E(0,J.lens,0,19,J.lencode,0,J.work,NA),J.lenbits=NA.bits,FA){x.msg="invalid code lengths set",J.mode=30;break}J.have=0,J.mode=19;case 19:for(;J.have<J.nlen+J.ndist;){for(;hA=(JA=J.lencode[W&(1<<J.lenbits)-1])>>>16&255,sA=65535&JA,!((CA=JA>>>24)<=gA);){if(j===0)break A;j--,W+=K[b++]<<gA,gA+=8}if(sA<16)W>>>=CA,gA-=CA,J.lens[J.have++]=sA;else{if(sA===16){for(RA=CA+2;gA<RA;){if(j===0)break A;j--,W+=K[b++]<<gA,gA+=8}if(W>>>=CA,gA-=CA,J.have===0){x.msg="invalid bit length repeat",J.mode=30;break}aA=J.lens[J.have-1],QA=3+(3&W),W>>>=2,gA-=2}else if(sA===17){for(RA=CA+3;gA<RA;){if(j===0)break A;j--,W+=K[b++]<<gA,gA+=8}gA-=CA,aA=0,QA=3+(7&(W>>>=CA)),W>>>=3,gA-=3}else{for(RA=CA+7;gA<RA;){if(j===0)break A;j--,W+=K[b++]<<gA,gA+=8}gA-=CA,aA=0,QA=11+(127&(W>>>=CA)),W>>>=7,gA-=7}if(J.have+QA>J.nlen+J.ndist){x.msg="invalid bit length repeat",J.mode=30;break}for(;QA--;)J.lens[J.have++]=aA}}if(J.mode===30)break;if(J.lens[256]===0){x.msg="invalid code -- missing end-of-block",J.mode=30;break}if(J.lenbits=9,NA={bits:J.lenbits},FA=E(n,J.lens,0,J.nlen,J.lencode,0,J.work,NA),J.lenbits=NA.bits,FA){x.msg="invalid literal/lengths set",J.mode=30;break}if(J.distbits=6,J.distcode=J.distdyn,NA={bits:J.distbits},FA=E(s,J.lens,J.nlen,J.ndist,J.distcode,0,J.work,NA),J.distbits=NA.bits,FA){x.msg="invalid distances set",J.mode=30;break}if(J.mode=20,N===6)break A;case 20:J.mode=21;case 21:if(6<=j&&258<=O){x.next_out=T,x.avail_out=O,x.next_in=b,x.avail_in=j,J.hold=W,J.bits=gA,i(x,IA),T=x.next_out,_=x.output,O=x.avail_out,b=x.next_in,K=x.input,j=x.avail_in,W=J.hold,gA=J.bits,J.mode===12&&(J.back=-1);break}for(J.back=0;hA=(JA=J.lencode[W&(1<<J.lenbits)-1])>>>16&255,sA=65535&JA,!((CA=JA>>>24)<=gA);){if(j===0)break A;j--,W+=K[b++]<<gA,gA+=8}if(hA&&(240&hA)==0){for(cA=CA,SA=hA,xA=sA;hA=(JA=J.lencode[xA+((W&(1<<cA+SA)-1)>>cA)])>>>16&255,sA=65535&JA,!(cA+(CA=JA>>>24)<=gA);){if(j===0)break A;j--,W+=K[b++]<<gA,gA+=8}W>>>=cA,gA-=cA,J.back+=cA}if(W>>>=CA,gA-=CA,J.back+=CA,J.length=sA,hA===0){J.mode=26;break}if(32&hA){J.back=-1,J.mode=12;break}if(64&hA){x.msg="invalid literal/length code",J.mode=30;break}J.extra=15&hA,J.mode=22;case 22:if(J.extra){for(RA=J.extra;gA<RA;){if(j===0)break A;j--,W+=K[b++]<<gA,gA+=8}J.length+=W&(1<<J.extra)-1,W>>>=J.extra,gA-=J.extra,J.back+=J.extra}J.was=J.length,J.mode=23;case 23:for(;hA=(JA=J.distcode[W&(1<<J.distbits)-1])>>>16&255,sA=65535&JA,!((CA=JA>>>24)<=gA);){if(j===0)break A;j--,W+=K[b++]<<gA,gA+=8}if((240&hA)==0){for(cA=CA,SA=hA,xA=sA;hA=(JA=J.distcode[xA+((W&(1<<cA+SA)-1)>>cA)])>>>16&255,sA=65535&JA,!(cA+(CA=JA>>>24)<=gA);){if(j===0)break A;j--,W+=K[b++]<<gA,gA+=8}W>>>=cA,gA-=cA,J.back+=cA}if(W>>>=CA,gA-=CA,J.back+=CA,64&hA){x.msg="invalid distance code",J.mode=30;break}J.offset=sA,J.extra=15&hA,J.mode=24;case 24:if(J.extra){for(RA=J.extra;gA<RA;){if(j===0)break A;j--,W+=K[b++]<<gA,gA+=8}J.offset+=W&(1<<J.extra)-1,W>>>=J.extra,gA-=J.extra,J.back+=J.extra}if(J.offset>J.dmax){x.msg="invalid distance too far back",J.mode=30;break}J.mode=25;case 25:if(O===0)break A;if(QA=IA-O,J.offset>QA){if((QA=J.offset-QA)>J.whave&&J.sane){x.msg="invalid distance too far back",J.mode=30;break}nA=QA>J.wnext?(QA-=J.wnext,J.wsize-QA):J.wnext-QA,QA>J.length&&(QA=J.length),DA=J.window}else DA=_,nA=T-J.offset,QA=J.length;for(O<QA&&(QA=O),O-=QA,J.length-=QA;_[T++]=DA[nA++],--QA;);J.length===0&&(J.mode=21);break;case 26:if(O===0)break A;_[T++]=J.length,O--,J.mode=21;break;case 27:if(J.wrap){for(;gA<32;){if(j===0)break A;j--,W|=K[b++]<<gA,gA+=8}if(IA-=O,x.total_out+=IA,J.total+=IA,IA&&(x.adler=J.check=J.flags?Q(J.check,_,IA,T-IA):C(J.check,_,IA,T-IA)),IA=O,(J.flags?W:D(W))!==J.check){x.msg="incorrect data check",J.mode=30;break}gA=W=0}J.mode=28;case 28:if(J.wrap&&J.flags){for(;gA<32;){if(j===0)break A;j--,W+=K[b++]<<gA,gA+=8}if(W!==(4294967295&J.total)){x.msg="incorrect length check",J.mode=30;break}gA=W=0}J.mode=29;case 29:FA=1;break A;case 30:FA=-3;break A;case 31:return-4;default:return a}return x.next_out=T,x.avail_out=O,x.next_in=b,x.avail_in=j,J.hold=W,J.bits=gA,(J.wsize||IA!==x.avail_out&&J.mode<30&&(J.mode<27||N!==4))&&R(x,x.output,x.next_out,IA-x.avail_out)?(J.mode=31,-4):(tA-=x.avail_in,IA-=x.avail_out,x.total_in+=tA,x.total_out+=IA,J.total+=IA,J.wrap&&IA&&(x.adler=J.check=J.flags?Q(J.check,_,IA,x.next_out-IA):C(J.check,_,IA,x.next_out-IA)),x.data_type=J.bits+(J.last?64:0)+(J.mode===12?128:0)+(J.mode===20||J.mode===15?256:0),(tA==0&&IA===0||N===4)&&FA===r&&(FA=-5),FA)},o.inflateEnd=function(x){if(!x||!x.state)return a;var N=x.state;return N.window&&(N.window=null),x.state=null,r},o.inflateGetHeader=function(x,N){var J;return x&&x.state?(2&(J=x.state).wrap)==0?a:((J.head=N).done=!1,r):a},o.inflateSetDictionary=function(x,N){var J,K=N.length;return x&&x.state?(J=x.state).wrap!==0&&J.mode!==11?a:J.mode===11&&C(1,N,K,0)!==J.check?-3:R(x,N,K,K)?(J.mode=31,-4):(J.havedict=1,r):a},o.inflateInfo="pako inflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./inffast":48,"./inftrees":50}],50:[function(e,t,o){var B=e("../utils/common"),C=[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],Q=[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],i=[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],E=[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];t.exports=function(n,s,r,a,c,h,l,D){var d,y,w,u,G,m,p,k,S,R=D.bits,x=0,N=0,J=0,K=0,_=0,b=0,T=0,j=0,O=0,W=0,gA=null,tA=0,IA=new B.Buf16(16),QA=new B.Buf16(16),nA=null,DA=0;for(x=0;x<=15;x++)IA[x]=0;for(N=0;N<a;N++)IA[s[r+N]]++;for(_=R,K=15;1<=K&&IA[K]===0;K--);if(K<_&&(_=K),K===0)return c[h++]=20971520,c[h++]=20971520,D.bits=1,0;for(J=1;J<K&&IA[J]===0;J++);for(_<J&&(_=J),x=j=1;x<=15;x++)if(j<<=1,(j-=IA[x])<0)return-1;if(0<j&&(n===0||K!==1))return-1;for(QA[1]=0,x=1;x<15;x++)QA[x+1]=QA[x]+IA[x];for(N=0;N<a;N++)s[r+N]!==0&&(l[QA[s[r+N]]++]=N);if(m=n===0?(gA=nA=l,19):n===1?(gA=C,tA-=257,nA=Q,DA-=257,256):(gA=i,nA=E,-1),x=J,G=h,T=N=W=0,w=-1,u=(O=1<<(b=_))-1,n===1&&852<O||n===2&&592<O)return 1;for(;;){for(p=x-T,S=l[N]<m?(k=0,l[N]):l[N]>m?(k=nA[DA+l[N]],gA[tA+l[N]]):(k=96,0),d=1<<x-T,J=y=1<<b;c[G+(W>>T)+(y-=d)]=p<<24|k<<16|S|0,y!==0;);for(d=1<<x-1;W&d;)d>>=1;if(d!==0?(W&=d-1,W+=d):W=0,N++,--IA[x]==0){if(x===K)break;x=s[r+l[N]]}if(_<x&&(W&u)!==w){for(T===0&&(T=_),G+=J,j=1<<(b=x-T);b+T<K&&!((j-=IA[b+T])<=0);)b++,j<<=1;if(O+=1<<b,n===1&&852<O||n===2&&592<O)return 1;c[w=W&u]=_<<24|b<<16|G-h|0}}return W!==0&&(c[G+W]=x-T<<24|64<<16|0),D.bits=_,0}},{"../utils/common":41}],51:[function(e,t,o){t.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(e,t,o){var B=e("../utils/common"),C=0,Q=1;function i(JA){for(var PA=JA.length;0<=--PA;)JA[PA]=0}var E=0,n=29,s=256,r=s+1+n,a=30,c=19,h=2*r+1,l=15,D=16,d=7,y=256,w=16,u=17,G=18,m=[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],p=[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],k=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],S=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],R=new Array(2*(r+2));i(R);var x=new Array(2*a);i(x);var N=new Array(512);i(N);var J=new Array(256);i(J);var K=new Array(n);i(K);var _,b,T,j=new Array(a);function O(JA,PA,mA,YA,dA){this.static_tree=JA,this.extra_bits=PA,this.extra_base=mA,this.elems=YA,this.max_length=dA,this.has_stree=JA&&JA.length}function W(JA,PA){this.dyn_tree=JA,this.max_code=0,this.stat_desc=PA}function gA(JA){return JA<256?N[JA]:N[256+(JA>>>7)]}function tA(JA,PA){JA.pending_buf[JA.pending++]=255&PA,JA.pending_buf[JA.pending++]=PA>>>8&255}function IA(JA,PA,mA){JA.bi_valid>D-mA?(JA.bi_buf|=PA<<JA.bi_valid&65535,tA(JA,JA.bi_buf),JA.bi_buf=PA>>D-JA.bi_valid,JA.bi_valid+=mA-D):(JA.bi_buf|=PA<<JA.bi_valid&65535,JA.bi_valid+=mA)}function QA(JA,PA,mA){IA(JA,mA[2*PA],mA[2*PA+1])}function nA(JA,PA){for(var mA=0;mA|=1&JA,JA>>>=1,mA<<=1,0<--PA;);return mA>>>1}function DA(JA,PA,mA){var YA,dA,HA=new Array(l+1),WA=0;for(YA=1;YA<=l;YA++)HA[YA]=WA=WA+mA[YA-1]<<1;for(dA=0;dA<=PA;dA++){var Qg=JA[2*dA+1];Qg!==0&&(JA[2*dA]=nA(HA[Qg]++,Qg))}}function CA(JA){var PA;for(PA=0;PA<r;PA++)JA.dyn_ltree[2*PA]=0;for(PA=0;PA<a;PA++)JA.dyn_dtree[2*PA]=0;for(PA=0;PA<c;PA++)JA.bl_tree[2*PA]=0;JA.dyn_ltree[2*y]=1,JA.opt_len=JA.static_len=0,JA.last_lit=JA.matches=0}function hA(JA){8<JA.bi_valid?tA(JA,JA.bi_buf):0<JA.bi_valid&&(JA.pending_buf[JA.pending++]=JA.bi_buf),JA.bi_buf=0,JA.bi_valid=0}function sA(JA,PA,mA,YA){var dA=2*PA,HA=2*mA;return JA[dA]<JA[HA]||JA[dA]===JA[HA]&&YA[PA]<=YA[mA]}function cA(JA,PA,mA){for(var YA=JA.heap[mA],dA=mA<<1;dA<=JA.heap_len&&(dA<JA.heap_len&&sA(PA,JA.heap[dA+1],JA.heap[dA],JA.depth)&&dA++,!sA(PA,YA,JA.heap[dA],JA.depth));)JA.heap[mA]=JA.heap[dA],mA=dA,dA<<=1;JA.heap[mA]=YA}function SA(JA,PA,mA){var YA,dA,HA,WA,Qg=0;if(JA.last_lit!==0)for(;YA=JA.pending_buf[JA.d_buf+2*Qg]<<8|JA.pending_buf[JA.d_buf+2*Qg+1],dA=JA.pending_buf[JA.l_buf+Qg],Qg++,YA===0?QA(JA,dA,PA):(QA(JA,(HA=J[dA])+s+1,PA),(WA=m[HA])!==0&&IA(JA,dA-=K[HA],WA),QA(JA,HA=gA(--YA),mA),(WA=p[HA])!==0&&IA(JA,YA-=j[HA],WA)),Qg<JA.last_lit;);QA(JA,y,PA)}function xA(JA,PA){var mA,YA,dA,HA=PA.dyn_tree,WA=PA.stat_desc.static_tree,Qg=PA.stat_desc.has_stree,_A=PA.stat_desc.elems,GA=-1;for(JA.heap_len=0,JA.heap_max=h,mA=0;mA<_A;mA++)HA[2*mA]!==0?(JA.heap[++JA.heap_len]=GA=mA,JA.depth[mA]=0):HA[2*mA+1]=0;for(;JA.heap_len<2;)HA[2*(dA=JA.heap[++JA.heap_len]=GA<2?++GA:0)]=1,JA.depth[dA]=0,JA.opt_len--,Qg&&(JA.static_len-=WA[2*dA+1]);for(PA.max_code=GA,mA=JA.heap_len>>1;1<=mA;mA--)cA(JA,HA,mA);for(dA=_A;mA=JA.heap[1],JA.heap[1]=JA.heap[JA.heap_len--],cA(JA,HA,1),YA=JA.heap[1],JA.heap[--JA.heap_max]=mA,JA.heap[--JA.heap_max]=YA,HA[2*dA]=HA[2*mA]+HA[2*YA],JA.depth[dA]=(JA.depth[mA]>=JA.depth[YA]?JA.depth[mA]:JA.depth[YA])+1,HA[2*mA+1]=HA[2*YA+1]=dA,JA.heap[1]=dA++,cA(JA,HA,1),2<=JA.heap_len;);JA.heap[--JA.heap_max]=JA.heap[1],(function(kA,OA){var $A,tg,dg,Sg,Bg,Yg,iI=OA.dyn_tree,uA=OA.max_code,ng=OA.stat_desc.static_tree,Mg=OA.stat_desc.has_stree,Ug=OA.stat_desc.extra_bits,mg=OA.stat_desc.extra_base,Rg=OA.stat_desc.max_length,Kg=0;for(Sg=0;Sg<=l;Sg++)kA.bl_count[Sg]=0;for(iI[2*kA.heap[kA.heap_max]+1]=0,$A=kA.heap_max+1;$A<h;$A++)Rg<(Sg=iI[2*iI[2*(tg=kA.heap[$A])+1]+1]+1)&&(Sg=Rg,Kg++),iI[2*tg+1]=Sg,uA<tg||(kA.bl_count[Sg]++,Bg=0,mg<=tg&&(Bg=Ug[tg-mg]),Yg=iI[2*tg],kA.opt_len+=Yg*(Sg+Bg),Mg&&(kA.static_len+=Yg*(ng[2*tg+1]+Bg)));if(Kg!==0){do{for(Sg=Rg-1;kA.bl_count[Sg]===0;)Sg--;kA.bl_count[Sg]--,kA.bl_count[Sg+1]+=2,kA.bl_count[Rg]--,Kg-=2}while(0<Kg);for(Sg=Rg;Sg!==0;Sg--)for(tg=kA.bl_count[Sg];tg!==0;)uA<(dg=kA.heap[--$A])||(iI[2*dg+1]!==Sg&&(kA.opt_len+=(Sg-iI[2*dg+1])*iI[2*dg],iI[2*dg+1]=Sg),tg--)}})(JA,PA),DA(HA,GA,JA.bl_count)}function aA(JA,PA,mA){var YA,dA,HA=-1,WA=PA[1],Qg=0,_A=7,GA=4;for(WA===0&&(_A=138,GA=3),PA[2*(mA+1)+1]=65535,YA=0;YA<=mA;YA++)dA=WA,WA=PA[2*(YA+1)+1],++Qg<_A&&dA===WA||(Qg<GA?JA.bl_tree[2*dA]+=Qg:dA!==0?(dA!==HA&&JA.bl_tree[2*dA]++,JA.bl_tree[2*w]++):Qg<=10?JA.bl_tree[2*u]++:JA.bl_tree[2*G]++,HA=dA,GA=(Qg=0)===WA?(_A=138,3):dA===WA?(_A=6,3):(_A=7,4))}function FA(JA,PA,mA){var YA,dA,HA=-1,WA=PA[1],Qg=0,_A=7,GA=4;for(WA===0&&(_A=138,GA=3),YA=0;YA<=mA;YA++)if(dA=WA,WA=PA[2*(YA+1)+1],!(++Qg<_A&&dA===WA)){if(Qg<GA)for(;QA(JA,dA,JA.bl_tree),--Qg!=0;);else dA!==0?(dA!==HA&&(QA(JA,dA,JA.bl_tree),Qg--),QA(JA,w,JA.bl_tree),IA(JA,Qg-3,2)):Qg<=10?(QA(JA,u,JA.bl_tree),IA(JA,Qg-3,3)):(QA(JA,G,JA.bl_tree),IA(JA,Qg-11,7));HA=dA,GA=(Qg=0)===WA?(_A=138,3):dA===WA?(_A=6,3):(_A=7,4)}}i(j);var NA=!1;function RA(JA,PA,mA,YA){IA(JA,(E<<1)+(YA?1:0),3),(function(dA,HA,WA,Qg){hA(dA),tA(dA,WA),tA(dA,~WA),B.arraySet(dA.pending_buf,dA.window,HA,WA,dA.pending),dA.pending+=WA})(JA,PA,mA)}o._tr_init=function(JA){NA||((function(){var PA,mA,YA,dA,HA,WA=new Array(l+1);for(dA=YA=0;dA<n-1;dA++)for(K[dA]=YA,PA=0;PA<1<<m[dA];PA++)J[YA++]=dA;for(J[YA-1]=dA,dA=HA=0;dA<16;dA++)for(j[dA]=HA,PA=0;PA<1<<p[dA];PA++)N[HA++]=dA;for(HA>>=7;dA<a;dA++)for(j[dA]=HA<<7,PA=0;PA<1<<p[dA]-7;PA++)N[256+HA++]=dA;for(mA=0;mA<=l;mA++)WA[mA]=0;for(PA=0;PA<=143;)R[2*PA+1]=8,PA++,WA[8]++;for(;PA<=255;)R[2*PA+1]=9,PA++,WA[9]++;for(;PA<=279;)R[2*PA+1]=7,PA++,WA[7]++;for(;PA<=287;)R[2*PA+1]=8,PA++,WA[8]++;for(DA(R,r+1,WA),PA=0;PA<a;PA++)x[2*PA+1]=5,x[2*PA]=nA(PA,5);_=new O(R,m,s+1,r,l),b=new O(x,p,0,a,l),T=new O(new Array(0),k,0,c,d)})(),NA=!0),JA.l_desc=new W(JA.dyn_ltree,_),JA.d_desc=new W(JA.dyn_dtree,b),JA.bl_desc=new W(JA.bl_tree,T),JA.bi_buf=0,JA.bi_valid=0,CA(JA)},o._tr_stored_block=RA,o._tr_flush_block=function(JA,PA,mA,YA){var dA,HA,WA=0;0<JA.level?(JA.strm.data_type===2&&(JA.strm.data_type=(function(Qg){var _A,GA=4093624447;for(_A=0;_A<=31;_A++,GA>>>=1)if(1&GA&&Qg.dyn_ltree[2*_A]!==0)return C;if(Qg.dyn_ltree[18]!==0||Qg.dyn_ltree[20]!==0||Qg.dyn_ltree[26]!==0)return Q;for(_A=32;_A<s;_A++)if(Qg.dyn_ltree[2*_A]!==0)return Q;return C})(JA)),xA(JA,JA.l_desc),xA(JA,JA.d_desc),WA=(function(Qg){var _A;for(aA(Qg,Qg.dyn_ltree,Qg.l_desc.max_code),aA(Qg,Qg.dyn_dtree,Qg.d_desc.max_code),xA(Qg,Qg.bl_desc),_A=c-1;3<=_A&&Qg.bl_tree[2*S[_A]+1]===0;_A--);return Qg.opt_len+=3*(_A+1)+5+5+4,_A})(JA),dA=JA.opt_len+3+7>>>3,(HA=JA.static_len+3+7>>>3)<=dA&&(dA=HA)):dA=HA=mA+5,mA+4<=dA&&PA!==-1?RA(JA,PA,mA,YA):JA.strategy===4||HA===dA?(IA(JA,2+(YA?1:0),3),SA(JA,R,x)):(IA(JA,4+(YA?1:0),3),(function(Qg,_A,GA,kA){var OA;for(IA(Qg,_A-257,5),IA(Qg,GA-1,5),IA(Qg,kA-4,4),OA=0;OA<kA;OA++)IA(Qg,Qg.bl_tree[2*S[OA]+1],3);FA(Qg,Qg.dyn_ltree,_A-1),FA(Qg,Qg.dyn_dtree,GA-1)})(JA,JA.l_desc.max_code+1,JA.d_desc.max_code+1,WA+1),SA(JA,JA.dyn_ltree,JA.dyn_dtree)),CA(JA),YA&&hA(JA)},o._tr_tally=function(JA,PA,mA){return JA.pending_buf[JA.d_buf+2*JA.last_lit]=PA>>>8&255,JA.pending_buf[JA.d_buf+2*JA.last_lit+1]=255&PA,JA.pending_buf[JA.l_buf+JA.last_lit]=255&mA,JA.last_lit++,PA===0?JA.dyn_ltree[2*mA]++:(JA.matches++,PA--,JA.dyn_ltree[2*(J[mA]+s+1)]++,JA.dyn_dtree[2*gA(PA)]++),JA.last_lit===JA.lit_bufsize-1},o._tr_align=function(JA){IA(JA,2,3),QA(JA,y,R),(function(PA){PA.bi_valid===16?(tA(PA,PA.bi_buf),PA.bi_buf=0,PA.bi_valid=0):8<=PA.bi_valid&&(PA.pending_buf[PA.pending++]=255&PA.bi_buf,PA.bi_buf>>=8,PA.bi_valid-=8)})(JA)}},{"../utils/common":41}],53:[function(e,t,o){t.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(e,t,o){(function(B){(function(C,Q){if(!C.setImmediate){var i,E,n,s,r=1,a={},c=!1,h=C.document,l=Object.getPrototypeOf&&Object.getPrototypeOf(C);l=l&&l.setTimeout?l:C,i={}.toString.call(C.process)==="[object process]"?function(w){I.nextTick(function(){d(w)})}:(function(){if(C.postMessage&&!C.importScripts){var w=!0,u=C.onmessage;return C.onmessage=function(){w=!1},C.postMessage("","*"),C.onmessage=u,w}})()?(s="setImmediate$"+Math.random()+"$",C.addEventListener?C.addEventListener("message",y,!1):C.attachEvent("onmessage",y),function(w){C.postMessage(s+w,"*")}):C.MessageChannel?((n=new MessageChannel).port1.onmessage=function(w){d(w.data)},function(w){n.port2.postMessage(w)}):h&&"onreadystatechange"in h.createElement("script")?(E=h.documentElement,function(w){var u=h.createElement("script");u.onreadystatechange=function(){d(w),u.onreadystatechange=null,E.removeChild(u),u=null},E.appendChild(u)}):function(w){setTimeout(d,0,w)},l.setImmediate=function(w){typeof w!="function"&&(w=new Function(""+w));for(var u=new Array(arguments.length-1),G=0;G<u.length;G++)u[G]=arguments[G+1];var m={callback:w,args:u};return a[r]=m,i(r),r++},l.clearImmediate=D}function D(w){delete a[w]}function d(w){if(c)setTimeout(d,0,w);else{var u=a[w];if(u){c=!0;try{(function(G){var m=G.callback,p=G.args;switch(p.length){case 0:m();break;case 1:m(p[0]);break;case 2:m(p[0],p[1]);break;case 3:m(p[0],p[1],p[2]);break;default:m.apply(Q,p)}})(u)}finally{D(w),c=!1}}}}function y(w){w.source===C&&typeof w.data=="string"&&w.data.indexOf(s)===0&&d(+w.data.slice(s.length))}})(typeof self>"u"?B===void 0?this:B:self)}).call(this,typeof OL<"u"?OL:typeof self<"u"?self:typeof window<"u"?window:{})},{}]},{},[10])(10)})})(mog)),mog.exports}var ewo=Iwo();const jeA=Mp(ewo),two=async()=>await Promise.resolve().then(()=>yvo),owo=async({circuitJson:g,projectName:A})=>{try{const{circuitJsonToStep:I}=await two(),e=await I(g,{exportMode:"assembly"}),t=new jeA;for(const[o,B]of Object.entries(e))t.file(o,B);pk(await t.generateAsync({type:"blob"}),{fileName:`${A}-assembly.zip`})}catch(I){JC.error(`Failed to export assembly STEP: ${I instanceof Error?I.message:String(I)}`)}},Bwo=async({circuitJson:g,projectName:A})=>{await JC.promise((async()=>{const I=new jeA,[e,{convertCircuitJsonToBomRows:t,convertBomRowsToCsv:o},{convertCircuitJsonToPickAndPlaceCsv:B}]=await Promise.all([rS("circuit-json-to-gerber"),rS("circuit-json-to-bom-csv"),rS("circuit-json-to-pnp-csv")]),C=g.filter(r=>!("error_type"in r)&&!("warning_type"in r)),Q=e.convertCircuitJsonToGerberFiles(C,{flip_y_axis:!1});for(const[r,a]of Object.entries(Q))I.file(`gerber/${r}`,a);const i=await t({circuitJson:g}),E=await o(i);I.file("bom.csv",E);const n=await B(g,{supplier:"jlcpcb"});I.file("pick_and_place.csv",n);const s=await I.generateAsync({type:"blob"});pk(s,{fileName:`${A}_fabrication_files.zip`})})(),{loading:"Generating fabrication files...",success:"Fabrication ZIP ready",error:I=>`Failed to generate fabrication files: ${I instanceof Error?I.message:String(I)}`})},Cwo=async g=>{const{createFdmComponentBox:A,renderFdmComponentBoxPng:I}=await rS("circuit-json-to-fdm-component-box"),[e,t]=await Promise.all([A(g),I(g,{},{width:960,height:640})]);return{...e,previewPng:t}},Qwo=async g=>{const{createFdmComponentBox:A}=await rS("circuit-json-to-fdm-component-box");return A(g)},iFI=({generatedBox:g,projectName:A})=>{const I=Uint8Array.from(g.threeMf);pk(new Blob([I.buffer],{type:"model/3mf"}),{fileName:`${Vtg(A)}-component-box.3mf`})},iwo=async({circuitJson:g,projectName:A})=>{await JC.promise((async()=>{const I=await Qwo(g);iFI({generatedBox:I,projectName:A})})(),{loading:"Generating component box...",success:"Component box 3MF ready",error:I=>`Failed to generate component box: ${I instanceof Error?I.message:String(I)}`})},Ewo=async({circuitJson:g,projectName:A})=>{let I;try{const{convertCircuitJsonToGltf:e}=await rS("circuit-json-to-gltf");console.log("convertCircuitJsonToGltf",e);const t=await e(g,{format:"glb",boardTextureResolution:1024});if(!t||!(t instanceof ArrayBuffer))throw new Error("Invalid GLB data returned from converter");I=new Blob([t],{type:"model/gltf-binary"})}catch(e){console.error("GLB Export Error:",e);return}pk(I,{fileName:`${A}.glb`})},nwo=async({circuitJson:g,libraryName:A})=>{const{CircuitJsonToKicadLibraryConverter:I}=await rS("circuit-json-to-kicad"),e=new I(g,{libraryName:A,footprintLibraryName:A});e.runUntilFinished();const t=e.getOutput(),o=new jeA;o.file(`${A}.kicad_sym`,t.kicadSymString);for(const B of t.footprints){const C=o.folder(`${A}.pretty`);C&&C.file(`${B.footprintName}.kicad_mod`,`${B.kicadModString}
|
|
5679
5679
|
`)}if(t.model3dSourcePaths.length>0){const B=o.folder(`${A}.3dshapes`);if(B)for(const C of t.model3dSourcePaths)try{const Q=C.split("/").pop()||C,i=await fetch(C);if(i.ok){const E=await i.arrayBuffer();B.file(Q,E)}}catch{}}return o.file("fp-lib-table",t.fpLibTableString),o.file("sym-lib-table",t.symLibTableString),o},swo=async({circuitJson:g,projectName:A})=>{await JC.promise((async()=>{const e=await(await nwo({circuitJson:g,libraryName:A})).generateAsync({type:"blob"});pk(e,{fileName:`${A}_kicad_library.zip`})})(),{loading:"Generating KiCad library...",success:"KiCad library ZIP ready",error:I=>`Failed to generate KiCad library: ${I instanceof Error?I.message:String(I)}`})},awo=async({circuitJson:g,projectName:A})=>{const{CircuitJsonToKicadPcbConverter:I,CircuitJsonToKicadSchConverter:e,CircuitJsonToKicadProConverter:t,resolveAndLoadKicad3dModelFiles:o}=await rS("circuit-json-to-kicad"),B=new e(g);B.runUntilFinished();const C=B.getOutputString(),Q=new I(g,{includeBuiltin3dModels:!0,projectName:A});Q.runUntilFinished();const i=Q.getOutputString(),E=new t(g,{projectName:A,schematicFilename:`${A}.kicad_sch`,pcbFilename:`${A}.kicad_pcb`});E.runUntilFinished();const n=E.getOutputString(),s=new jeA;return s.file(`${A}.kicad_sch`,C),s.file(`${A}.kicad_pcb`,i),s.file(`${A}.kicad_pro`,n),await o({projectName:A,model3dSourcePaths:Q.getModel3dSourcePaths(),fetch,onModelFile:({outputPath:r,content:a})=>{s.file(r,a)},onError:({sourcePath:r})=>{console.warn(`Failed to load 3D model from ${r}`)}}),s},rwo=async({circuitJson:g,projectName:A})=>{await JC.promise((async()=>{const e=await(await awo({circuitJson:g,projectName:A})).generateAsync({type:"blob"});pk(e,{fileName:`${A}_kicad_project.zip`})})(),{loading:"Generating KiCad project...",success:"KiCad project ZIP ready",error:I=>`Failed to generate KiCad project: ${I instanceof Error?I.message:String(I)}`})},EFI=async({circuitJson:g,projectName:A,options:I={}})=>{try{const{convertCircuitJsonToLbrn:e}=await rS("circuit-json-to-lbrn"),o=(await e(g,{includeSilkscreen:I.includeSilkscreen??!1,includeOxidationCleaningLayer:I.includeOxidationCleaningLayer??!0})).toXml(),B=new Blob([o],{type:"application/lbrn"});pk(B,{fileName:`${A}.lbrn2`})}catch(e){const t=e instanceof Error?e.message:"Unknown error";JC.error(`Failed to export to LBRN format: ${t}`)}},cwo=async({circuitJson:g,projectName:A})=>{const{convertCircuitJsonToPinoutSvg:I}=await rS("circuit-to-svg"),e=I(g);pk(e,{fileName:`${A}-pinout.svg`,mimeType:"image/svg+xml"})},hwo=async({circuitJson:g,projectName:A})=>{const{circuitJsonToStep:I}=await rS("circuit-json-to-step"),e=g.find(i=>i.type==="pcb_board"),t=e&&"width"in e?e.width:void 0,o=e&&"height"in e?e.height:void 0,B=e&&"thickness"in e?e.thickness:void 0;if(t===void 0||o===void 0||B===void 0){JC.error("Board dimensions not found. Please add a pcb_board with width, height, and thickness to your circuit.");return}let C;try{C=await I(g,{boardWidth:t,boardHeight:o,boardThickness:B,productName:A,includeComponents:!0,includeExternalMeshes:!0})}catch(i){const E=i instanceof Error?i.message:"Unknown error";JC.error(`Failed to convert circuit to STEP format: ${E}`);return}const Q=new Blob([C],{type:"application/step"});try{pk(Q,{fileName:`${A}.step`})}catch(i){const E=i instanceof Error?i.message:"Unknown error";JC.error(`Failed to download STEP file: ${E}`)}},lwo=[{extension:"json",name:"Circuit JSON"},{extension:"json",name:"Simple Route JSON"},{extension:"zip",name:"Fabrication Files"},{extension:"zip",name:"KiCad Project"},{extension:"zip",name:"Altium Project"},{extension:"zip",name:"KiCad Library"},{extension:"glb",name:"GLB (Binary GLTF)"},{extension:"svg",name:"Pinout SVG"},{extension:"step",name:"STEP"},{extension:"zip",name:"Assembly STEP"},{extension:"lbrn2",name:"LightBurn"}],Dwo=async({exportName:g,circuitJson:A,simpleRouteJson:I,projectName:e})=>{const t=Vtg(e);if(g==="Fabrication Files"){await Bwo({circuitJson:A,projectName:t});return}if(g==="KiCad Project"){await rwo({circuitJson:A,projectName:t});return}if(g==="Altium Project"){await gwo({circuitJson:A,projectName:t});return}if(g==="KiCad Library"){await swo({circuitJson:A,projectName:t});return}if(g==="Circuit JSON"){pk(JSON.stringify(A,null,2),{fileName:`${t}.circuit.json`,mimeType:"application/json"});return}if(g==="Simple Route JSON"){if(!I)throw new Error("No Simple Route JSON available to export");pk(JSON.stringify(I,null,2),{fileName:`${t}.simple-route.json`,mimeType:"application/json"});return}if(g==="GLB (Binary GLTF)"){await Ewo({circuitJson:A,projectName:t});return}if(g==="Pinout SVG"){cwo({circuitJson:A,projectName:t});return}if(g==="STEP"){await hwo({circuitJson:A,projectName:t});return}if(g==="Assembly STEP"){await owo({circuitJson:A,projectName:t});return}if(g==="Component Box (3MF)"){await iwo({circuitJson:A,projectName:t});return}if(g==="LightBurn"){await EFI({circuitJson:A,projectName:t});return}throw new Error(`Unsupported export type: "${g}"`)},dwo=({packageName:g,onSelectReview:A})=>{const I=Fc(n=>n.fsMap),e=Fc(n=>n.circuitJson),[t,o]=X.useState([]),[B,C]=X.useState(!1),[Q,i]=X.useState(!1);X.useEffect(()=>{!g||!clA()||(C(!0),wAA.get("ai_reviews/list",{searchParams:{package_name:g}}).json().then(n=>o(n.ai_reviews)).catch(n=>{console.error("Failed to load AI reviews",n),JC.error("Failed to load AI reviews")}).finally(()=>C(!1)))},[g]);const E=async()=>{if(!e){JC.error("Need Circuit JSON to Request AI Review");return}if(!clA()){JC.error("Missing registry token");return}i(!0);try{const{ai_review:n}=await wAA.post("ai_reviews/create",{json:{package_name:g??"unknown",fs_map:Object.fromEntries(I),circuit_json:e}}).json();o(s=>[n,...s]),A(n),JC.success("AI review requested")}catch(n){console.error("Failed to create AI review",n),JC.error("Failed to request AI review")}finally{i(!1)}};return q.jsxs(q.Fragment,{children:[q.jsxs(T3,{children:[q.jsx(Z3,{children:"AI Review"}),q.jsx(O5,{children:"Select an AI review or request a new one."})]}),q.jsx("div",{className:"rf-flex rf-gap-4 rf-mt-4",children:q.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:B?q.jsx("div",{className:"rf-text-sm",children:"Loading..."}):t.length>0?t.map(n=>q.jsx("div",{className:"rf-text-sm rf-p-2 rf-cursor-pointer rf-rounded hover:rf-bg-zinc-100",onClick:()=>A(n),children:new Date(n.created_at||"").toLocaleString()},n.ai_review_id)):q.jsx("div",{className:"rf-text-sm rf-text-muted-foreground",children:"No AI reviews found."})})}),q.jsx(FZ,{className:"rf-mt-4",children:q.jsx(Ei,{onClick:E,disabled:Q,children:Q?"Requesting...":"Review my Board"})})]})};function pog(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var W5=pog();function nFI(g){W5=g}var zeA={exec:()=>null};function Zs(g,A=""){let I=typeof g=="string"?g:g.source;const e={replace:(t,o)=>{let B=typeof o=="string"?o:o.source;return B=B.replace(Um.caret,"$1"),I=I.replace(t,B),e},getRegex:()=>new RegExp(I,A)};return e}var Um={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:g=>new RegExp(`^( {0,3}${g})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:g=>new RegExp(`^ {0,${Math.min(3,g-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),hrRegex:g=>new RegExp(`^ {0,${Math.min(3,g-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:g=>new RegExp(`^ {0,${Math.min(3,g-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:g=>new RegExp(`^ {0,${Math.min(3,g-1)}}#`),htmlBeginRegex:g=>new RegExp(`^ {0,${Math.min(3,g-1)}}<(?:[a-z].*>|!--)`,"i")},ywo=/^(?:[ \t]*(?:\n|$))+/,wwo=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,uwo=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,XeA=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,Gwo=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,kog=/(?:[*+-]|\d{1,9}[.)])/,sFI=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,aFI=Zs(sFI).replace(/bull/g,kog).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(),mwo=Zs(sFI).replace(/bull/g,kog).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(),Mog=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,pwo=/^[^\n]+/,Sog=/(?!\s*\])(?:\\.|[^\[\]\\])+/,kwo=Zs(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",Sog).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),Mwo=Zs(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,kog).getRegex(),yGA="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",fog=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,Swo=Zs("^ {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",fog).replace("tag",yGA).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),rFI=Zs(Mog).replace("hr",XeA).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",yGA).getRegex(),fwo=Zs(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",rFI).getRegex(),Rog={blockquote:fwo,code:wwo,def:kwo,fences:uwo,heading:Gwo,hr:XeA,html:Swo,lheading:aFI,list:Mwo,newline:ywo,paragraph:rFI,table:zeA,text:pwo},cFI=Zs("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",XeA).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",yGA).getRegex(),Rwo={...Rog,lheading:mwo,table:cFI,paragraph:Zs(Mog).replace("hr",XeA).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",cFI).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",yGA).getRegex()},Nwo={...Rog,html:Zs(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",fog).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:zeA,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:Zs(Mog).replace("hr",XeA).replace("heading",` *#{1,6} *[^
|
|
5680
5680
|
]`).replace("lheading",aFI).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},xwo=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,Fwo=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,hFI=/^( {2,}|\\)\n(?!\s*$)/,Uwo=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,wGA=/[\p{P}\p{S}]/u,Nog=/[\s\p{P}\p{S}]/u,lFI=/[^\s\p{P}\p{S}]/u,Jwo=Zs(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,Nog).getRegex(),DFI=/(?!~)[\p{P}\p{S}]/u,Pwo=/(?!~)[\s\p{P}\p{S}]/u,Kwo=/(?:[^\s\p{P}\p{S}]|~)/u,Lwo=/\[[^[\]]*?\]\((?:\\.|[^\\\(\)]|\((?:\\.|[^\\\(\)])*\))*\)|`[^`]*?`|<[^<>]*?>/g,dFI=/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,Ywo=Zs(dFI,"u").replace(/punct/g,wGA).getRegex(),_wo=Zs(dFI,"u").replace(/punct/g,DFI).getRegex(),yFI="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",bwo=Zs(yFI,"gu").replace(/notPunctSpace/g,lFI).replace(/punctSpace/g,Nog).replace(/punct/g,wGA).getRegex(),Hwo=Zs(yFI,"gu").replace(/notPunctSpace/g,Kwo).replace(/punctSpace/g,Pwo).replace(/punct/g,DFI).getRegex(),vwo=Zs("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,lFI).replace(/punctSpace/g,Nog).replace(/punct/g,wGA).getRegex(),qwo=Zs(/\\(punct)/,"gu").replace(/punct/g,wGA).getRegex(),Two=Zs(/^<(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(),Zwo=Zs(fog).replace("(?:-->|$)","-->").getRegex(),Owo=Zs("^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",Zwo).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),uGA=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,Wwo=Zs(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]*(?:\n[ \t]*)?)(title))?\s*\)/).replace("label",uGA).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),wFI=Zs(/^!?\[(label)\]\[(ref)\]/).replace("label",uGA).replace("ref",Sog).getRegex(),uFI=Zs(/^!?\[(ref)\](?:\[\])?/).replace("ref",Sog).getRegex(),Vwo=Zs("reflink|nolink(?!\\()","g").replace("reflink",wFI).replace("nolink",uFI).getRegex(),xog={_backpedal:zeA,anyPunctuation:qwo,autolink:Two,blockSkip:Lwo,br:hFI,code:Fwo,del:zeA,emStrongLDelim:Ywo,emStrongRDelimAst:bwo,emStrongRDelimUnd:vwo,escape:xwo,link:Wwo,nolink:uFI,punctuation:Jwo,reflink:wFI,reflinkSearch:Vwo,tag:Owo,text:Uwo,url:zeA},jwo={...xog,link:Zs(/^!?\[(label)\]\((.*?)\)/).replace("label",uGA).getRegex(),reflink:Zs(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",uGA).getRegex()},Fog={...xog,emStrongRDelimAst:Hwo,emStrongLDelim:_wo,url:Zs(/^((?: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.!#$%&'*+\/=?_`{\|}~-]+@)))/},zwo={...Fog,br:Zs(hFI).replace("{2,}","*").getRegex(),text:Zs(Fog.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},GGA={normal:Rog,gfm:Rwo,pedantic:Nwo},$eA={normal:xog,gfm:Fog,breaks:zwo,pedantic:jwo},Xwo={"&":"&","<":"<",">":">",'"':""","'":"'"},GFI=g=>Xwo[g];function Tx(g,A){if(A){if(Um.escapeTest.test(g))return g.replace(Um.escapeReplace,GFI)}else if(Um.escapeTestNoEncode.test(g))return g.replace(Um.escapeReplaceNoEncode,GFI);return g}function mFI(g){try{g=encodeURI(g).replace(Um.percentDecode,"%")}catch{return null}return g}function pFI(g,A){const I=g.replace(Um.findPipe,(o,B,C)=>{let Q=!1,i=B;for(;--i>=0&&C[i]==="\\";)Q=!Q;return Q?"|":" |"}),e=I.split(Um.splitPipe);let t=0;if(e[0].trim()||e.shift(),e.length>0&&!e.at(-1)?.trim()&&e.pop(),A)if(e.length>A)e.splice(A);else for(;e.length<A;)e.push("");for(;t<e.length;t++)e[t]=e[t].trim().replace(Um.slashPipe,"|");return e}function AtA(g,A,I){const e=g.length;if(e===0)return"";let t=0;for(;t<e&&g.charAt(e-t-1)===A;)t++;return g.slice(0,e-t)}function $wo(g,A){if(g.indexOf(A[1])===-1)return-1;let I=0;for(let e=0;e<g.length;e++)if(g[e]==="\\")e++;else if(g[e]===A[0])I++;else if(g[e]===A[1]&&(I--,I<0))return e;return I>0?-2:-1}function kFI(g,A,I,e,t){const o=A.href,B=A.title||null,C=g[1].replace(t.other.outputLinkReplace,"$1");e.state.inLink=!0;const Q={type:g[0].charAt(0)==="!"?"image":"link",raw:I,href:o,title:B,text:C,tokens:e.inlineTokens(C)};return e.state.inLink=!1,Q}function Auo(g,A,I){const e=g.match(I.other.indentCodeCompensation);if(e===null)return A;const t=e[1];return A.split(`
|