@tscircuit/runframe 0.0.670 → 0.0.672

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.
@@ -13078,13 +13078,13 @@ ${l.join(`
13078
13078
  `)!==-1&&(i=i.replace(/\r\n/g,`
13079
13079
  `)),i.indexOf(`\\
13080
13080
  `)!==-1&&(i=i.replace(/\\\n/g,""));const t=i.split(`
13081
- `);let n="",r="",a=0,o=[];const s=typeof"".trimLeft=="function";for(let u=0,f=t.length;u<f;u++)if(n=t[u],n=s?n.trimLeft():n.trim(),a=n.length,a!==0&&(r=n.charAt(0),r!=="#"))if(r==="v"){const h=n.split(/\s+/);switch(h[0]){case"v":e.vertices.push(parseFloat(h[1]),parseFloat(h[2]),parseFloat(h[3])),h.length>=7?e.colors.push(parseFloat(h[4]),parseFloat(h[5]),parseFloat(h[6])):e.colors.push(void 0,void 0,void 0);break;case"vn":e.normals.push(parseFloat(h[1]),parseFloat(h[2]),parseFloat(h[3]));break;case"vt":e.uvs.push(parseFloat(h[1]),parseFloat(h[2]));break}}else if(r==="f"){const p=n.substr(1).trim().split(/\s+/),y=[];for(let I=0,C=p.length;I<C;I++){const b=p[I];if(b.length>0){const w=b.split("/");y.push(w)}}const _=y[0];for(let I=1,C=y.length-1;I<C;I++){const b=y[I],w=y[I+1];e.addFace(_[0],b[0],w[0],_[1],b[1],w[1],_[2],b[2],w[2])}}else if(r==="l"){const h=n.substring(1).trim().split(" ");let p=[];const y=[];if(n.indexOf("/")===-1)p=h;else for(let _=0,I=h.length;_<I;_++){const C=h[_].split("/");C[0]!==""&&p.push(C[0]),C[1]!==""&&y.push(C[1])}e.addLineGeometry(p,y)}else if(r==="p"){const p=n.substr(1).trim().split(" ");e.addPointGeometry(p)}else if((o=opn.exec(n))!==null){const h=(" "+o[0].substr(1).trim()).substr(1);e.startObject(h)}else if(lpn.test(n))e.object.startMaterial(n.substring(7).trim(),e.materialLibraries);else if(spn.test(n))e.materialLibraries.push(n.substring(7).trim());else if(cpn.test(n))console.warn('THREE.OBJLoader: Rendering identifier "usemap" not supported. Textures must be defined in MTL files.');else if(r==="s"){if(o=n.split(" "),o.length>1){const p=o[1].trim().toLowerCase();e.object.smooth=p!=="0"&&p!=="off"}else e.object.smooth=!0;const h=e.object.currentMaterial();h&&(h.smooth=e.object.smooth)}else{if(n==="\0")continue;console.warn('THREE.OBJLoader: Unexpected line: "'+n+'"')}e.finalize();const l=new IM;if(l.materialLibraries=[].concat(e.materialLibraries),!(e.objects.length===1&&e.objects[0].geometry.vertices.length===0)===!0)for(let u=0,f=e.objects.length;u<f;u++){const h=e.objects[u],p=h.geometry,y=h.materials,_=p.type==="Line",I=p.type==="Points";let C=!1;if(p.vertices.length===0)continue;const b=new Eg;b.setAttribute("position",new yA(p.vertices,3)),p.normals.length>0&&b.setAttribute("normal",new yA(p.normals,3)),p.colors.length>0&&(C=!0,b.setAttribute("color",new yA(p.colors,3))),p.hasUVIndices===!0&&b.setAttribute("uv",new yA(p.uvs,2));const w=[];for(let V=0,z=y.length;V<z;V++){const K=y[V],G=K.name+"_"+K.smooth+"_"+C;let q=e.materials[G];if(this.materials!==null){if(q=this.materials.create(K.name),_&&q&&!(q instanceof Mx)){const Y=new Mx;eE.prototype.copy.call(Y,q),Y.color.copy(q.color),q=Y}else if(I&&q&&!(q instanceof BM)){const Y=new BM({size:10,sizeAttenuation:!1});eE.prototype.copy.call(Y,q),Y.color.copy(q.color),Y.map=q.map,q=Y}}q===void 0&&(_?q=new Mx:I?q=new BM({size:1,sizeAttenuation:!1}):q=new PH,q.name=K.name,q.flatShading=!K.smooth,q.vertexColors=C,e.materials[G]=q),w.push(q)}let N;if(w.length>1){for(let V=0,z=y.length;V<z;V++){const K=y[V];b.addGroup(K.groupStart,K.groupCount,V)}_?N=new i2(b,w):I?N=new g6(b,w):N=new FI(b,w)}else _?N=new i2(b,w[0]):I?N=new g6(b,w[0]):N=new FI(b,w[0]);N.name=h.name,l.add(N)}else if(e.vertices.length>0){const u=new BM({size:1,sizeAttenuation:!1}),f=new Eg;f.setAttribute("position",new yA(e.vertices,3)),e.colors.length>0&&e.colors[0]!==void 0&&(f.setAttribute("color",new yA(e.colors,3)),u.vertexColors=!0);const h=new g6(f,u);l.add(h)}return l}};typeof window<"u"&&!window.TSCIRCUIT_OBJ_LOADER_CACHE&&(window.TSCIRCUIT_OBJ_LOADER_CACHE=new Map);function fpn(i){const[e,t]=pt.useState(null);return pt.useEffect(()=>{if(!i)return;const n=window.TSCIRCUIT_OBJ_LOADER_CACHE;let r=!1;async function a(){var s;try{const l=await fetch(i);if(!l.ok)throw new Error(`Failed to fetch "${i}": ${l.status} ${l.statusText}`);const c=await l.text(),u=(s=c.match(/newmtl[\s\S]*?endmtl/g))==null?void 0:s.join(`
13082
- `).replace(/d 0\./g,"d 1."),f=c.replace(/newmtl[\s\S]*?endmtl/g,""),h=new rpn;h.setMaterialOptions({invertTrProperty:!0});const p=h.parse(u.replace(/Kd\s+([\d.]+)\s+([\d.]+)\s+([\d.]+)/g,"Kd $2 $2 $2"),"test.mtl"),y=new dpn;return y.setMaterials(p),y.parse(f)}catch(l){return l}}function o(){if(n.has(i)){const l=n.get(i);return l.result?Promise.resolve(l.result.clone()):l.promise.then(c=>c instanceof Error?c:c.clone())}const s=a().then(l=>(l instanceof Error||n.set(i,{...n.get(i),result:l}),l));return n.set(i,{promise:s,result:null}),s}return o().then(s=>{r||t(s)}).catch(s=>{console.error(s)}),()=>{r=!0}},[i]),e}function Apn({url:i,position:e,rotation:t,onHover:n,onUnhover:r,isHovered:a}){const o=fpn(i);if(!o)return We.jsx(NV,{isHovered:a,onHover:n,onUnhover:r,children:We.jsxs("mesh",{position:e,children:[We.jsx("boxGeometry",{args:[.5,.5,.5]}),We.jsx("meshStandardMaterial",{transparent:!0,color:"red",opacity:.25})]})});if(o instanceof Error)throw o;return We.jsx(NV,{isHovered:a,onHover:n,onUnhover:r,children:We.jsx("primitive",{rotation:t,position:e,object:o})})}var hpn=KC(D$e()),k$e=({jscadPlan:i,positionOffset:e,rotationOffset:t,onHover:n,onUnhover:r,isHovered:a})=>{const{threeGeom:o,material:s}=pt.useMemo(()=>{const l=xPe.executeJscadOperations(hpn.default,i),c=uZt(l),u=new CD({vertexColors:!0,side:YE});return{threeGeom:c,material:u}},[i]);return pt.useMemo(()=>{if(a){const l=new td(s.color.getHex());s.emissive.copy(l),s.emissive.setRGB(0,0,1),s.emissiveIntensity=.2}else s.emissiveIntensity=0},[a,s]),o?We.jsx(NV,{isHovered:a,onHover:n,onUnhover:r,position:e,children:We.jsx("mesh",{geometry:o,material:s,position:e,rotation:t})}):null},{createJSCADRoot:ppn}=vjt(xPe.jscadPlanner),gpn=({positionOffset:i,footprint:e,rotationOffset:t,onHover:n,onUnhover:r,isHovered:a})=>{const o=pt.useMemo(()=>{if(!e)return null;const s=[];return ppn(s).render(We.jsx(ksn,{footprint:e})),s},[e]);return o?We.jsx(We.Fragment,{children:o.map((s,l)=>We.jsx(k$e,{positionOffset:i,rotationOffset:t,jscadPlan:s,onHover:n,onUnhover:r,isHovered:a},l))}):null},mpn=(...i)=>i,U$e=({cad_component:i,circuitJson:e})=>{const[t,n]=pt.useState(!1),[r,a]=pt.useState(null),o=pt.useCallback(h=>{h!=null&&h.mousePosition?(n(!0),a(h.mousePosition)):(n(!1),a(null))},[]),s=pt.useCallback(()=>{n(!1),a(null)},[]),l=pt.useMemo(()=>{var h;return(h=O1(e).source_component.getUsing({source_component_id:i.source_component_id}))==null?void 0:h.name},[e,i.source_component_id]),c=i.model_obj_url??i.model_stl_url,u=i.rotation?mpn(i.rotation.x*Math.PI/180,i.rotation.y*Math.PI/180,i.rotation.z*Math.PI/180):void 0;let f=null;return c?f=We.jsx(Apn,{url:c,position:i.position?[i.position.x,i.position.y,i.position.z]:void 0,rotation:u,onHover:o,onUnhover:s,isHovered:t},i.cad_component_id):i.model_jscad?f=We.jsx(k$e,{jscadPlan:i.model_jscad,rotationOffset:u,onHover:o,onUnhover:s,isHovered:t},i.cad_component_id):i.footprinter_string&&(f=We.jsx(gpn,{positionOffset:i.position?[i.position.x,i.position.y,i.position.z]:void 0,rotationOffset:u,footprint:i.footprinter_string,onHover:o,onUnhover:s,isHovered:t})),We.jsxs(We.Fragment,{children:[f,t&&r?We.jsx(CZe,{position:r,style:{fontFamily:"sans-serif",transform:"translate3d(50%, 50%, 0)",backgroundColor:"white",padding:"5px",borderRadius:"3px",pointerEvents:"none",userSelect:"none",WebkitUserSelect:"none",MozUserSelect:"none",msUserSelect:"none"},children:l??"<unknown>"}):null]})},ypn={version:"0.0.297"};typeof window<"u"&&(window.TSCI_MAIN_CAMERA_ROTATION=new Kb(0,0,0));function vpn(i,e){const t=new fE().setFromEuler(new Kb(i.x,i.y,i.z)),n=new wi(0,0,1);return n.applyQuaternion(t),n.multiplyScalar(e)}var _pn=({})=>{const i=pt.useRef();return pt.useRef({lastRotation:new Kb}),T7((e,t)=>{if(!i.current)return;const n=window.TSCI_MAIN_CAMERA_ROTATION,r=vpn(n,2);e.camera.position.copy(r),e.camera.lookAt(0,0,0)}),We.jsxs("mesh",{ref:i,rotation:[Math.PI/2,0,0],children:[We.jsx("boxGeometry",{args:[1,1,1]}),We.jsx("meshStandardMaterial",{color:"white"}),We.jsx(eQ,{position:[0,0,.51],fontSize:.25,color:"black",children:"Front"}),We.jsx(eQ,{position:[0,0,-.51],fontSize:.25,color:"black",rotation:[0,Math.PI,0],children:"Back"}),We.jsx(eQ,{position:[.51,0,0],fontSize:.25,color:"black",rotation:[0,Math.PI/2,0],children:"Right"}),We.jsx(eQ,{position:[-.51,0,0],fontSize:.25,color:"black",rotation:[0,-Math.PI/2,0],children:"Left"}),We.jsx(eQ,{position:[0,.51,0],fontSize:.25,color:"black",rotation:[-Math.PI/2,0,0],children:"Top"}),We.jsx(eQ,{position:[0,-.51,0],fontSize:.25,color:"black",rotation:[Math.PI/2,0,0],children:"Bottom"}),We.jsx("lineSegments",{args:[new doe(new Sw(1,1,1))],material:new Mx({color:0,linewidth:2})})]})},Ipn=()=>(T7(({camera:i})=>{window.TSCI_MAIN_CAMERA_ROTATION=i.rotation}),We.jsx(We.Fragment,{})),L$e=pt.forwardRef(({children:i,initialCameraPosition:e=[5,5,5],autoRotateDisabled:t,clickToInteractEnabled:n=!1,boardDimensions:r},a)=>{const[o,s]=pt.useState(!n),l=pt.useMemo(()=>{if(!r)return 10;const c=r.width??0,u=r.height??0,h=Math.max(c,u)*1.5;return h>10?h:10},[r]);return We.jsxs("div",{style:{position:"relative",width:"100%",height:"100%"},children:[We.jsx("div",{style:{position:"absolute",top:0,left:0,width:120,height:120},children:We.jsxs(vZe,{camera:{up:[0,0,1],position:[1,1,1]},style:{zIndex:10},children:[We.jsx("ambientLight",{intensity:Math.PI/2}),We.jsx(_pn,{})]})}),We.jsxs(vZe,{scene:{up:[0,0,1]},camera:{up:[0,0,1],position:e},children:[We.jsx(Ipn,{}),o&&We.jsx(Kcn,{autoRotate:!t,autoRotateSpeed:1}),We.jsx("ambientLight",{intensity:Math.PI/2}),We.jsx("pointLight",{position:[-10,-10,10],decay:0,intensity:Math.PI/4}),We.jsx(qcn,{rotation:[Math.PI/2,0,0],infiniteGrid:!0,cellSize:1,sectionSize:l,args:[l,l]}),We.jsx("object3D",{ref:a,children:i})]}),We.jsxs("div",{style:{position:"absolute",right:24,bottom:24,fontFamily:"sans-serif",color:"white",WebkitTextStroke:"0.5px rgba(0, 0, 0, 0.5)",fontSize:11},children:["@",ypn.version]}),n&&!o&&We.jsx("button",{type:"button",onClick:()=>s(!0),onKeyDown:c=>{(c.key==="Enter"||c.key===" ")&&s(!0)},style:{position:"absolute",inset:0,cursor:"pointer",zIndex:10,display:"flex",alignItems:"center",justifyContent:"center"},children:We.jsx("div",{style:{backgroundColor:"rgba(0, 0, 0, 0.8)",color:"white",padding:"12px 24px",borderRadius:"8px",fontSize:"16px",fontFamily:"sans-serif",pointerEvents:"none"},children:"Click to Interact"})})]})}),F$e=i=>pt.useMemo(()=>{if(!i)return[];const e=new S7t;return e.add(i),e.render(),e.getCircuitJson()},[i]);function Cpn(i){return new Promise((e,t)=>{const n=new FileReader;n.onload=()=>{e(n.result)},n.onerror=t,n.readAsDataURL(i)})}var xpn=i=>{const[e,t]=pt.useState([]),[n,r]=pt.useState(!0);return pt.useEffect(()=>{if(!i)return;(async()=>{r(!0);const s=(Array.isArray(i)?i:[i]).map(async l=>{const c=lun.serialize({binary:!0},[l]),u=new Blob(c);return{stlUrl:await Cpn(u),color:l.color}});try{const l=await Promise.all(s);t(l)}catch(l){console.error("Error generating STLs:",l),t([])}finally{r(!1)}})()},[i]),{stls:e,loading:n}},Epn=KC(rN()),bpn=KC(H7()),D_=.01,Px={copper:[.9,.6,.2],fr4Green:[5/255,163/255,46/255],fr4GreenSolderWithMask:[0/255,152/255,19/255],fr1Copper:[.8,.4,.2],fr1CopperSolderWithMask:[.9,.6,.2]},a3=.001,zB=32,Spn=.035,TV=50,Fge={fr1:Px.fr1Copper,fr4:Px.fr4Green},G$e={fr1:Px.fr1CopperSolderWithMask,fr4:Px.fr4GreenSolderWithMask},Bpn=KC(MV()),wpn=KC(rN()),Mpn=KC(DV()),O$e=i=>{let e=0;for(let n=0;n<i.length;n++){const r=(n+1)%i.length;e+=i[n][0]*i[r][1],e-=i[r][0]*i[n][1]}return e/2<=0},z$e=(i,e=1.2)=>{const{outline:t}=i;let n=t.map(o=>[o.x,o.y]);O$e(n)&&(n=n.reverse());const r=(0,wpn.polygon)({points:n});let a=(0,Bpn.extrudeLinear)({height:e},r);return a=(0,Mpn.translate)([0,0,-e/2],a),a},Qpn=i=>{const e=O1(i).pcb_board.list()[0];if(!e)return console.warn("No pcb_board found for simplified geometry"),[];let t;const n=1.2;e.outline&&e.outline.length>0?t=z$e({outline:e.outline},n):t=(0,Epn.cuboid)({size:[e.width,e.height,n],center:[e.center.x,e.center.y,0]});const r=Fge[e.material]??Px.fr4Green;return[(0,bpn.colorize)(r,t)]},rQ=KC(DV()),ZE=KC(rN()),aN=KC(H7()),aQ=KC(Nge()),HI=KC(rN()),PV=KC(H7()),BS=KC(Nge()),x9=.05,H$e=(i,e)=>{if(i.shape||(i.shape="circle"),i.shape==="circle")return(0,PV.colorize)(Px.copper,(0,BS.subtract)((0,BS.union)((0,HI.cylinder)({center:[i.x,i.y,0],radius:i.hole_diameter/2,height:e.pcbThickness}),(0,HI.cylinder)({center:[i.x,i.y,e.pcbThickness/2+x9/2+D_],radius:i.outer_diameter/2,height:x9}),(0,HI.cylinder)({center:[i.x,i.y,-e.pcbThickness/2-x9/2-D_],radius:i.outer_diameter/2,height:x9})),(0,HI.cylinder)({center:[i.x,i.y,0],radius:i.hole_diameter/2-D_,height:1.5})));if(i.shape==="circular_hole_with_rect_pad"){const t=i.rect_pad_width||i.hole_diameter,n=i.rect_pad_height||i.hole_diameter;return(0,PV.colorize)(Px.copper,(0,BS.subtract)((0,BS.union)((0,HI.cuboid)({center:[i.x,i.y,1.2/2],size:[t,n,x9]}),(0,HI.cuboid)({center:[i.x,i.y,-1.2/2],size:[t,n,x9]}),(0,HI.cylinder)({center:[i.x,i.y,0],radius:i.hole_diameter/2,height:1.2})),(0,HI.cylinder)({center:[i.x,i.y,0],radius:Math.max(i.hole_diameter/2-D_,.01),height:1.5})))}if(i.shape==="pill"){const t=i.hole_height>i.hole_width,n=t?i.hole_height:i.hole_width,r=t?i.hole_width:i.hole_height,a=t?i.outer_height||r+.2:i.outer_width||n+.2,o=t?i.outer_width||n+.2:i.outer_height||r+.2,s=r/2,l=o/2,c=Math.abs(n-r),u=Math.abs(a-o),f=(0,HI.cuboid)({center:[i.x,i.y,0],size:t?[r,c,e.pcbThickness]:[c,r,e.pcbThickness]}),h=(0,HI.cylinder)({center:t?[i.x,i.y-c/2,0]:[i.x-c/2,i.y,0],radius:s,height:e.pcbThickness}),p=(0,HI.cylinder)({center:t?[i.x,i.y+c/2,0]:[i.x+c/2,i.y,0],radius:s,height:e.pcbThickness}),y=(0,BS.union)(f,h,p),_=e.pcbThickness/2+x9/2+D_,I=(0,HI.cuboid)({center:[i.x,i.y,_],size:t?[o,u,x9]:[u,o,x9]}),C=(0,HI.cylinder)({center:t?[i.x,i.y-u/2,_]:[i.x-u/2,i.y,_],radius:l,height:x9}),b=(0,HI.cylinder)({center:t?[i.x,i.y+u/2,_]:[i.x+u/2,i.y,_],radius:l,height:x9}),w=(0,BS.union)(I,C,b),N=-e.pcbThickness/2-x9/2-D_,V=(0,HI.cuboid)({center:[i.x,i.y,N],size:t?[o,u,x9]:[u,o,x9]}),z=(0,HI.cylinder)({center:t?[i.x,i.y-u/2,N]:[i.x-u/2,i.y,N],radius:l,height:x9}),K=(0,HI.cylinder)({center:t?[i.x,i.y+u/2,N]:[i.x+u/2,i.y,N],radius:l,height:x9}),G=(0,BS.union)(V,z,K),q=(0,HI.cuboid)({center:[i.x,i.y,0],size:t?[r-2*D_,c,e.pcbThickness+2*D_]:[c,r-2*D_,e.pcbThickness+2*D_]}),Y=(0,HI.cylinder)({center:t?[i.x,i.y-c/2,0]:[i.x-c/2,i.y,0],radius:s-D_,height:e.pcbThickness+2*D_}),oe=(0,HI.cylinder)({center:t?[i.x,i.y+c/2,0]:[i.x+c/2,i.y,0],radius:s-D_,height:e.pcbThickness+2*D_}),W=(0,BS.union)(q,Y,oe);return(0,PV.colorize)(Px.copper,(0,BS.subtract)((0,BS.union)(y,w,G),W))}if(i.shape==="pill_hole_with_rect_pad"){const t=i.hole_height>i.hole_width,n=t?i.hole_height:i.hole_width,r=t?i.hole_width:i.hole_height,a=r/2,o=Math.abs(n-r),s=i.rect_pad_width||n+.2,l=i.rect_pad_height||r+.2,c=(0,HI.cuboid)({center:[i.x,i.y,0],size:t?[r,o,1.2]:[o,r,1.2]}),u=(0,HI.cylinder)({center:t?[i.x,i.y-o/2,0]:[i.x-o/2,i.y,0],radius:a,height:1.2}),f=(0,HI.cylinder)({center:t?[i.x,i.y+o/2,0]:[i.x+o/2,i.y,0],radius:a,height:1.2}),h=(0,HI.cuboid)({center:[i.x,i.y,1.2/2],size:[s,l,x9]}),p=(0,HI.cuboid)({center:[i.x,i.y,-1.2/2],size:[s,l,x9]}),y=(0,BS.union)((0,HI.cuboid)({center:[i.x,i.y,0],size:t?[r-x9,o,1.5]:[o,r-x9,1.5]}),(0,HI.cylinder)({center:t?[i.x,i.y-o/2,0]:[i.x-o/2,i.y,0],radius:a-x9,height:1.5}),(0,HI.cylinder)({center:t?[i.x,i.y+o/2,0]:[i.x+o/2,i.y,0],radius:a-x9,height:1.5}));return(0,PV.colorize)(Px.copper,(0,BS.subtract)((0,BS.union)(c,u,f,h,p),y))}else throw new Error(`Unsupported plated hole shape: ${i.shape}`)},kV=KC(MV()),Y$e=KC(Pge()),Rpn=KC(Bge());function V$e(i,e){return Array.isArray(e)?[i.a*e[0]+i.c*e[1]+i.e,i.b*e[0]+i.d*e[1]+i.f]:{x:i.a*e.x+i.c*e.y+i.e,y:i.b*e.x+i.d*e.y+i.f}}function Ow(i,e=0){return{a:1,c:0,e:i,b:0,d:1,f:e}}function j$e(...i){i=Array.isArray(i[0])?i[0]:i;const e=(t,n)=>({a:t.a*n.a+t.c*n.b,c:t.a*n.c+t.c*n.d,e:t.a*n.e+t.c*n.f+t.e,b:t.b*n.a+t.d*n.b,d:t.b*n.c+t.d*n.d,f:t.b*n.e+t.d*n.f+t.f});switch(i.length){case 0:throw new Error("no matrices provided");case 1:return i[0];case 2:return e(i[0],i[1]);default:{const[t,n,...r]=i,a=e(t,n);return j$e(a,...r)}}}function K$e(...i){return j$e(...i)}var{cos:Dpn,sin:Npn}=Math;function J$e(i,e,t){const n=Dpn(i),r=Npn(i);return{a:n,c:-r,e:0,b:r,d:n,f:0}}function Tpn(i,e){function t(){this.constructor=i}t.prototype=e.prototype,i.prototype=new t}function UV(i,e,t,n){var r=Error.call(this,i);return Object.setPrototypeOf&&Object.setPrototypeOf(r,UV.prototype),r.expected=e,r.found=t,r.location=n,r.name="SyntaxError",r}Tpn(UV,Error);function Gge(i,e,t){return t=t||" ",i.length>e?i:(e-=i.length,t+=t.repeat(e),i+t.slice(0,e))}UV.prototype.format=function(i){var e="Error: "+this.message;if(this.location){var t=null,n;for(n=0;n<i.length;n++)if(i[n].source===this.location.source){t=i[n].text.split(/\r\n|\n|\r/g);break}var r=this.location.start,a=this.location.source&&typeof this.location.source.offset=="function"?this.location.source.offset(r):r,o=this.location.source+":"+a.line+":"+a.column;if(t){var s=this.location.end,l=Gge("",a.line.toString().length," "),c=t[r.line-1],u=r.line===s.line?s.column:c.length+1,f=u-r.column||1;e+=`
13081
+ `);let n="",r="",a=0,o=[];const s=typeof"".trimLeft=="function";for(let u=0,f=t.length;u<f;u++)if(n=t[u],n=s?n.trimLeft():n.trim(),a=n.length,a!==0&&(r=n.charAt(0),r!=="#"))if(r==="v"){const h=n.split(/\s+/);switch(h[0]){case"v":e.vertices.push(parseFloat(h[1]),parseFloat(h[2]),parseFloat(h[3])),h.length>=7?e.colors.push(parseFloat(h[4]),parseFloat(h[5]),parseFloat(h[6])):e.colors.push(void 0,void 0,void 0);break;case"vn":e.normals.push(parseFloat(h[1]),parseFloat(h[2]),parseFloat(h[3]));break;case"vt":e.uvs.push(parseFloat(h[1]),parseFloat(h[2]));break}}else if(r==="f"){const p=n.substr(1).trim().split(/\s+/),y=[];for(let I=0,C=p.length;I<C;I++){const b=p[I];if(b.length>0){const w=b.split("/");y.push(w)}}const _=y[0];for(let I=1,C=y.length-1;I<C;I++){const b=y[I],w=y[I+1];e.addFace(_[0],b[0],w[0],_[1],b[1],w[1],_[2],b[2],w[2])}}else if(r==="l"){const h=n.substring(1).trim().split(" ");let p=[];const y=[];if(n.indexOf("/")===-1)p=h;else for(let _=0,I=h.length;_<I;_++){const C=h[_].split("/");C[0]!==""&&p.push(C[0]),C[1]!==""&&y.push(C[1])}e.addLineGeometry(p,y)}else if(r==="p"){const p=n.substr(1).trim().split(" ");e.addPointGeometry(p)}else if((o=opn.exec(n))!==null){const h=(" "+o[0].substr(1).trim()).substr(1);e.startObject(h)}else if(lpn.test(n))e.object.startMaterial(n.substring(7).trim(),e.materialLibraries);else if(spn.test(n))e.materialLibraries.push(n.substring(7).trim());else if(cpn.test(n))console.warn('THREE.OBJLoader: Rendering identifier "usemap" not supported. Textures must be defined in MTL files.');else if(r==="s"){if(o=n.split(" "),o.length>1){const p=o[1].trim().toLowerCase();e.object.smooth=p!=="0"&&p!=="off"}else e.object.smooth=!0;const h=e.object.currentMaterial();h&&(h.smooth=e.object.smooth)}else{if(n==="\0")continue;console.warn('THREE.OBJLoader: Unexpected line: "'+n+'"')}e.finalize();const l=new IM;if(l.materialLibraries=[].concat(e.materialLibraries),!(e.objects.length===1&&e.objects[0].geometry.vertices.length===0)===!0)for(let u=0,f=e.objects.length;u<f;u++){const h=e.objects[u],p=h.geometry,y=h.materials,_=p.type==="Line",I=p.type==="Points";let C=!1;if(p.vertices.length===0)continue;const b=new Eg;b.setAttribute("position",new yA(p.vertices,3)),p.normals.length>0&&b.setAttribute("normal",new yA(p.normals,3)),p.colors.length>0&&(C=!0,b.setAttribute("color",new yA(p.colors,3))),p.hasUVIndices===!0&&b.setAttribute("uv",new yA(p.uvs,2));const w=[];for(let V=0,z=y.length;V<z;V++){const K=y[V],G=K.name+"_"+K.smooth+"_"+C;let q=e.materials[G];if(this.materials!==null){if(q=this.materials.create(K.name),_&&q&&!(q instanceof Mx)){const Y=new Mx;eE.prototype.copy.call(Y,q),Y.color.copy(q.color),q=Y}else if(I&&q&&!(q instanceof BM)){const Y=new BM({size:10,sizeAttenuation:!1});eE.prototype.copy.call(Y,q),Y.color.copy(q.color),Y.map=q.map,q=Y}}q===void 0&&(_?q=new Mx:I?q=new BM({size:1,sizeAttenuation:!1}):q=new PH,q.name=K.name,q.flatShading=!K.smooth,q.vertexColors=C,e.materials[G]=q),w.push(q)}let N;if(w.length>1){for(let V=0,z=y.length;V<z;V++){const K=y[V];b.addGroup(K.groupStart,K.groupCount,V)}_?N=new i2(b,w):I?N=new g6(b,w):N=new FI(b,w)}else _?N=new i2(b,w[0]):I?N=new g6(b,w[0]):N=new FI(b,w[0]);N.name=h.name,l.add(N)}else if(e.vertices.length>0){const u=new BM({size:1,sizeAttenuation:!1}),f=new Eg;f.setAttribute("position",new yA(e.vertices,3)),e.colors.length>0&&e.colors[0]!==void 0&&(f.setAttribute("color",new yA(e.colors,3)),u.vertexColors=!0);const h=new g6(f,u);l.add(h)}return l}};typeof window<"u"&&!window.TSCIRCUIT_OBJ_LOADER_CACHE&&(window.TSCIRCUIT_OBJ_LOADER_CACHE=new Map);function fpn(i){const[e,t]=pt.useState(null);return pt.useEffect(()=>{if(!i)return;const n=i.replace(/&cachebust_origin=$/,""),r=window.TSCIRCUIT_OBJ_LOADER_CACHE;let a=!1;async function o(){var l;try{const c=await fetch(n);if(!c.ok)throw new Error(`Failed to fetch "${n}": ${c.status} ${c.statusText}`);const u=await c.text(),f=(l=u.match(/newmtl[\s\S]*?endmtl/g))==null?void 0:l.join(`
13082
+ `).replace(/d 0\./g,"d 1."),h=u.replace(/newmtl[\s\S]*?endmtl/g,""),p=new rpn;p.setMaterialOptions({invertTrProperty:!0});const y=p.parse(f.replace(/Kd\s+([\d.]+)\s+([\d.]+)\s+([\d.]+)/g,"Kd $2 $2 $2"),"test.mtl"),_=new dpn;return _.setMaterials(y),_.parse(h)}catch(c){return c}}function s(){if(r.has(n)){const c=r.get(n);return c.result?Promise.resolve(c.result.clone()):c.promise.then(u=>u instanceof Error?u:u.clone())}const l=o().then(c=>(c instanceof Error||r.set(n,{...r.get(n),result:c}),c));return r.set(n,{promise:l,result:null}),l}return s().then(l=>{a||t(l)}).catch(l=>{console.error(l)}),()=>{a=!0}},[i]),e}function Apn({url:i,position:e,rotation:t,onHover:n,onUnhover:r,isHovered:a}){const o=fpn(i);if(!o)return We.jsx(NV,{isHovered:a,onHover:n,onUnhover:r,children:We.jsxs("mesh",{position:e,children:[We.jsx("boxGeometry",{args:[.5,.5,.5]}),We.jsx("meshStandardMaterial",{transparent:!0,color:"red",opacity:.25})]})});if(o instanceof Error)throw o;return We.jsx(NV,{isHovered:a,onHover:n,onUnhover:r,children:We.jsx("primitive",{rotation:t,position:e,object:o})})}var hpn=KC(D$e()),k$e=({jscadPlan:i,positionOffset:e,rotationOffset:t,onHover:n,onUnhover:r,isHovered:a})=>{const{threeGeom:o,material:s}=pt.useMemo(()=>{const l=xPe.executeJscadOperations(hpn.default,i),c=uZt(l),u=new CD({vertexColors:!0,side:YE});return{threeGeom:c,material:u}},[i]);return pt.useMemo(()=>{if(a){const l=new td(s.color.getHex());s.emissive.copy(l),s.emissive.setRGB(0,0,1),s.emissiveIntensity=.2}else s.emissiveIntensity=0},[a,s]),o?We.jsx(NV,{isHovered:a,onHover:n,onUnhover:r,position:e,children:We.jsx("mesh",{geometry:o,material:s,position:e,rotation:t})}):null},{createJSCADRoot:ppn}=vjt(xPe.jscadPlanner),gpn=({positionOffset:i,footprint:e,rotationOffset:t,onHover:n,onUnhover:r,isHovered:a})=>{const o=pt.useMemo(()=>{if(!e)return null;const s=[];return ppn(s).render(We.jsx(ksn,{footprint:e})),s},[e]);return o?We.jsx(We.Fragment,{children:o.map((s,l)=>We.jsx(k$e,{positionOffset:i,rotationOffset:t,jscadPlan:s,onHover:n,onUnhover:r,isHovered:a},l))}):null},mpn=(...i)=>i,U$e=({cad_component:i,circuitJson:e})=>{const[t,n]=pt.useState(!1),[r,a]=pt.useState(null),o=pt.useCallback(h=>{h!=null&&h.mousePosition?(n(!0),a(h.mousePosition)):(n(!1),a(null))},[]),s=pt.useCallback(()=>{n(!1),a(null)},[]),l=pt.useMemo(()=>{var h;return(h=O1(e).source_component.getUsing({source_component_id:i.source_component_id}))==null?void 0:h.name},[e,i.source_component_id]),c=i.model_obj_url??i.model_stl_url,u=i.rotation?mpn(i.rotation.x*Math.PI/180,i.rotation.y*Math.PI/180,i.rotation.z*Math.PI/180):void 0;let f=null;return c?f=We.jsx(Apn,{url:c,position:i.position?[i.position.x,i.position.y,i.position.z]:void 0,rotation:u,onHover:o,onUnhover:s,isHovered:t},i.cad_component_id):i.model_jscad?f=We.jsx(k$e,{jscadPlan:i.model_jscad,rotationOffset:u,onHover:o,onUnhover:s,isHovered:t},i.cad_component_id):i.footprinter_string&&(f=We.jsx(gpn,{positionOffset:i.position?[i.position.x,i.position.y,i.position.z]:void 0,rotationOffset:u,footprint:i.footprinter_string,onHover:o,onUnhover:s,isHovered:t})),We.jsxs(We.Fragment,{children:[f,t&&r?We.jsx(CZe,{position:r,style:{fontFamily:"sans-serif",transform:"translate3d(1rem, 1rem, 0)",backgroundColor:"white",padding:"5px",borderRadius:"3px",pointerEvents:"none",userSelect:"none",WebkitUserSelect:"none",MozUserSelect:"none",msUserSelect:"none"},children:l??"<unknown>"}):null]})},ypn={version:"0.0.299"};typeof window<"u"&&(window.TSCI_MAIN_CAMERA_ROTATION=new Kb(0,0,0));function vpn(i,e){const t=new fE().setFromEuler(new Kb(i.x,i.y,i.z)),n=new wi(0,0,1);return n.applyQuaternion(t),n.multiplyScalar(e)}var _pn=({})=>{const i=pt.useRef();return pt.useRef({lastRotation:new Kb}),T7((e,t)=>{if(!i.current)return;const n=window.TSCI_MAIN_CAMERA_ROTATION,r=vpn(n,2);e.camera.position.copy(r),e.camera.lookAt(0,0,0)}),We.jsxs("mesh",{ref:i,rotation:[Math.PI/2,0,0],children:[We.jsx("boxGeometry",{args:[1,1,1]}),We.jsx("meshStandardMaterial",{color:"white"}),We.jsx(eQ,{position:[0,0,.51],fontSize:.25,color:"black",children:"Front"}),We.jsx(eQ,{position:[0,0,-.51],fontSize:.25,color:"black",rotation:[0,Math.PI,0],children:"Back"}),We.jsx(eQ,{position:[.51,0,0],fontSize:.25,color:"black",rotation:[0,Math.PI/2,0],children:"Right"}),We.jsx(eQ,{position:[-.51,0,0],fontSize:.25,color:"black",rotation:[0,-Math.PI/2,0],children:"Left"}),We.jsx(eQ,{position:[0,.51,0],fontSize:.25,color:"black",rotation:[-Math.PI/2,0,0],children:"Top"}),We.jsx(eQ,{position:[0,-.51,0],fontSize:.25,color:"black",rotation:[Math.PI/2,0,0],children:"Bottom"}),We.jsx("lineSegments",{args:[new doe(new Sw(1,1,1))],material:new Mx({color:0,linewidth:2})})]})},Ipn=()=>(T7(({camera:i})=>{window.TSCI_MAIN_CAMERA_ROTATION=i.rotation}),We.jsx(We.Fragment,{})),L$e=pt.forwardRef(({children:i,initialCameraPosition:e=[5,5,5],autoRotateDisabled:t,clickToInteractEnabled:n=!1,boardDimensions:r},a)=>{const[o,s]=pt.useState(!n),l=pt.useMemo(()=>{if(!r)return 10;const c=r.width??0,u=r.height??0,h=Math.max(c,u)*1.5;return h>10?h:10},[r]);return We.jsxs("div",{style:{position:"relative",width:"100%",height:"100%"},children:[We.jsx("div",{style:{position:"absolute",top:0,left:0,width:120,height:120},children:We.jsxs(vZe,{camera:{up:[0,0,1],position:[1,1,1]},style:{zIndex:10},children:[We.jsx("ambientLight",{intensity:Math.PI/2}),We.jsx(_pn,{})]})}),We.jsxs(vZe,{scene:{up:[0,0,1]},camera:{up:[0,0,1],position:e},children:[We.jsx(Ipn,{}),o&&We.jsx(Kcn,{autoRotate:!t,autoRotateSpeed:1}),We.jsx("ambientLight",{intensity:Math.PI/2}),We.jsx("pointLight",{position:[-10,-10,10],decay:0,intensity:Math.PI/4}),We.jsx(qcn,{rotation:[Math.PI/2,0,0],infiniteGrid:!0,cellSize:1,sectionSize:l,args:[l,l]}),We.jsx("object3D",{ref:a,children:i})]}),We.jsxs("div",{style:{position:"absolute",right:24,bottom:24,fontFamily:"sans-serif",color:"white",WebkitTextStroke:"0.5px rgba(0, 0, 0, 0.5)",fontSize:11},children:["@",ypn.version]}),n&&!o&&We.jsx("button",{type:"button",onClick:()=>s(!0),onKeyDown:c=>{(c.key==="Enter"||c.key===" ")&&s(!0)},style:{position:"absolute",inset:0,cursor:"pointer",zIndex:10,display:"flex",alignItems:"center",justifyContent:"center"},children:We.jsx("div",{style:{backgroundColor:"rgba(0, 0, 0, 0.8)",color:"white",padding:"12px 24px",borderRadius:"8px",fontSize:"16px",fontFamily:"sans-serif",pointerEvents:"none"},children:"Click to Interact"})})]})}),F$e=i=>pt.useMemo(()=>{if(!i)return[];const e=new S7t;return e.add(i),e.render(),e.getCircuitJson()},[i]);function Cpn(i){return new Promise((e,t)=>{const n=new FileReader;n.onload=()=>{e(n.result)},n.onerror=t,n.readAsDataURL(i)})}var xpn=i=>{const[e,t]=pt.useState([]),[n,r]=pt.useState(!0);return pt.useEffect(()=>{if(!i)return;(async()=>{r(!0);const s=(Array.isArray(i)?i:[i]).map(async l=>{const c=lun.serialize({binary:!0},[l]),u=new Blob(c);return{stlUrl:await Cpn(u),color:l.color}});try{const l=await Promise.all(s);t(l)}catch(l){console.error("Error generating STLs:",l),t([])}finally{r(!1)}})()},[i]),{stls:e,loading:n}},Epn=KC(rN()),bpn=KC(H7()),D_=.01,Px={copper:[.9,.6,.2],fr4Green:[5/255,163/255,46/255],fr4GreenSolderWithMask:[0/255,152/255,19/255],fr1Copper:[.8,.4,.2],fr1CopperSolderWithMask:[.9,.6,.2]},a3=.001,zB=32,Spn=.035,TV=50,Fge={fr1:Px.fr1Copper,fr4:Px.fr4Green},G$e={fr1:Px.fr1CopperSolderWithMask,fr4:Px.fr4GreenSolderWithMask},Bpn=KC(MV()),wpn=KC(rN()),Mpn=KC(DV()),O$e=i=>{let e=0;for(let n=0;n<i.length;n++){const r=(n+1)%i.length;e+=i[n][0]*i[r][1],e-=i[r][0]*i[n][1]}return e/2<=0},z$e=(i,e=1.2)=>{const{outline:t}=i;let n=t.map(o=>[o.x,o.y]);O$e(n)&&(n=n.reverse());const r=(0,wpn.polygon)({points:n});let a=(0,Bpn.extrudeLinear)({height:e},r);return a=(0,Mpn.translate)([0,0,-e/2],a),a},Qpn=i=>{const e=O1(i).pcb_board.list()[0];if(!e)return console.warn("No pcb_board found for simplified geometry"),[];let t;const n=1.2;e.outline&&e.outline.length>0?t=z$e({outline:e.outline},n):t=(0,Epn.cuboid)({size:[e.width,e.height,n],center:[e.center.x,e.center.y,0]});const r=Fge[e.material]??Px.fr4Green;return[(0,bpn.colorize)(r,t)]},rQ=KC(DV()),ZE=KC(rN()),aN=KC(H7()),aQ=KC(Nge()),HI=KC(rN()),PV=KC(H7()),BS=KC(Nge()),x9=.05,H$e=(i,e)=>{if(i.shape||(i.shape="circle"),i.shape==="circle")return(0,PV.colorize)(Px.copper,(0,BS.subtract)((0,BS.union)((0,HI.cylinder)({center:[i.x,i.y,0],radius:i.hole_diameter/2,height:e.pcbThickness}),(0,HI.cylinder)({center:[i.x,i.y,e.pcbThickness/2+x9/2+D_],radius:i.outer_diameter/2,height:x9}),(0,HI.cylinder)({center:[i.x,i.y,-e.pcbThickness/2-x9/2-D_],radius:i.outer_diameter/2,height:x9})),(0,HI.cylinder)({center:[i.x,i.y,0],radius:i.hole_diameter/2-D_,height:1.5})));if(i.shape==="circular_hole_with_rect_pad"){const t=i.rect_pad_width||i.hole_diameter,n=i.rect_pad_height||i.hole_diameter;return(0,PV.colorize)(Px.copper,(0,BS.subtract)((0,BS.union)((0,HI.cuboid)({center:[i.x,i.y,1.2/2],size:[t,n,x9]}),(0,HI.cuboid)({center:[i.x,i.y,-1.2/2],size:[t,n,x9]}),(0,HI.cylinder)({center:[i.x,i.y,0],radius:i.hole_diameter/2,height:1.2})),(0,HI.cylinder)({center:[i.x,i.y,0],radius:Math.max(i.hole_diameter/2-D_,.01),height:1.5})))}if(i.shape==="pill"){const t=i.hole_height>i.hole_width,n=t?i.hole_height:i.hole_width,r=t?i.hole_width:i.hole_height,a=t?i.outer_height||r+.2:i.outer_width||n+.2,o=t?i.outer_width||n+.2:i.outer_height||r+.2,s=r/2,l=o/2,c=Math.abs(n-r),u=Math.abs(a-o),f=(0,HI.cuboid)({center:[i.x,i.y,0],size:t?[r,c,e.pcbThickness]:[c,r,e.pcbThickness]}),h=(0,HI.cylinder)({center:t?[i.x,i.y-c/2,0]:[i.x-c/2,i.y,0],radius:s,height:e.pcbThickness}),p=(0,HI.cylinder)({center:t?[i.x,i.y+c/2,0]:[i.x+c/2,i.y,0],radius:s,height:e.pcbThickness}),y=(0,BS.union)(f,h,p),_=e.pcbThickness/2+x9/2+D_,I=(0,HI.cuboid)({center:[i.x,i.y,_],size:t?[o,u,x9]:[u,o,x9]}),C=(0,HI.cylinder)({center:t?[i.x,i.y-u/2,_]:[i.x-u/2,i.y,_],radius:l,height:x9}),b=(0,HI.cylinder)({center:t?[i.x,i.y+u/2,_]:[i.x+u/2,i.y,_],radius:l,height:x9}),w=(0,BS.union)(I,C,b),N=-e.pcbThickness/2-x9/2-D_,V=(0,HI.cuboid)({center:[i.x,i.y,N],size:t?[o,u,x9]:[u,o,x9]}),z=(0,HI.cylinder)({center:t?[i.x,i.y-u/2,N]:[i.x-u/2,i.y,N],radius:l,height:x9}),K=(0,HI.cylinder)({center:t?[i.x,i.y+u/2,N]:[i.x+u/2,i.y,N],radius:l,height:x9}),G=(0,BS.union)(V,z,K),q=(0,HI.cuboid)({center:[i.x,i.y,0],size:t?[r-2*D_,c,e.pcbThickness+2*D_]:[c,r-2*D_,e.pcbThickness+2*D_]}),Y=(0,HI.cylinder)({center:t?[i.x,i.y-c/2,0]:[i.x-c/2,i.y,0],radius:s-D_,height:e.pcbThickness+2*D_}),oe=(0,HI.cylinder)({center:t?[i.x,i.y+c/2,0]:[i.x+c/2,i.y,0],radius:s-D_,height:e.pcbThickness+2*D_}),W=(0,BS.union)(q,Y,oe);return(0,PV.colorize)(Px.copper,(0,BS.subtract)((0,BS.union)(y,w,G),W))}if(i.shape==="pill_hole_with_rect_pad"){const t=i.hole_height>i.hole_width,n=t?i.hole_height:i.hole_width,r=t?i.hole_width:i.hole_height,a=r/2,o=Math.abs(n-r),s=i.rect_pad_width||n+.2,l=i.rect_pad_height||r+.2,c=(0,HI.cuboid)({center:[i.x,i.y,0],size:t?[r,o,1.2]:[o,r,1.2]}),u=(0,HI.cylinder)({center:t?[i.x,i.y-o/2,0]:[i.x-o/2,i.y,0],radius:a,height:1.2}),f=(0,HI.cylinder)({center:t?[i.x,i.y+o/2,0]:[i.x+o/2,i.y,0],radius:a,height:1.2}),h=(0,HI.cuboid)({center:[i.x,i.y,1.2/2],size:[s,l,x9]}),p=(0,HI.cuboid)({center:[i.x,i.y,-1.2/2],size:[s,l,x9]}),y=(0,BS.union)((0,HI.cuboid)({center:[i.x,i.y,0],size:t?[r-x9,o,1.5]:[o,r-x9,1.5]}),(0,HI.cylinder)({center:t?[i.x,i.y-o/2,0]:[i.x-o/2,i.y,0],radius:a-x9,height:1.5}),(0,HI.cylinder)({center:t?[i.x,i.y+o/2,0]:[i.x+o/2,i.y,0],radius:a-x9,height:1.5}));return(0,PV.colorize)(Px.copper,(0,BS.subtract)((0,BS.union)(c,u,f,h,p),y))}else throw new Error(`Unsupported plated hole shape: ${i.shape}`)},kV=KC(MV()),Y$e=KC(Pge()),Rpn=KC(Bge());function V$e(i,e){return Array.isArray(e)?[i.a*e[0]+i.c*e[1]+i.e,i.b*e[0]+i.d*e[1]+i.f]:{x:i.a*e.x+i.c*e.y+i.e,y:i.b*e.x+i.d*e.y+i.f}}function Ow(i,e=0){return{a:1,c:0,e:i,b:0,d:1,f:e}}function j$e(...i){i=Array.isArray(i[0])?i[0]:i;const e=(t,n)=>({a:t.a*n.a+t.c*n.b,c:t.a*n.c+t.c*n.d,e:t.a*n.e+t.c*n.f+t.e,b:t.b*n.a+t.d*n.b,d:t.b*n.c+t.d*n.d,f:t.b*n.e+t.d*n.f+t.f});switch(i.length){case 0:throw new Error("no matrices provided");case 1:return i[0];case 2:return e(i[0],i[1]);default:{const[t,n,...r]=i,a=e(t,n);return j$e(a,...r)}}}function K$e(...i){return j$e(...i)}var{cos:Dpn,sin:Npn}=Math;function J$e(i,e,t){const n=Dpn(i),r=Npn(i);return{a:n,c:-r,e:0,b:r,d:n,f:0}}function Tpn(i,e){function t(){this.constructor=i}t.prototype=e.prototype,i.prototype=new t}function UV(i,e,t,n){var r=Error.call(this,i);return Object.setPrototypeOf&&Object.setPrototypeOf(r,UV.prototype),r.expected=e,r.found=t,r.location=n,r.name="SyntaxError",r}Tpn(UV,Error);function Gge(i,e,t){return t=t||" ",i.length>e?i:(e-=i.length,t+=t.repeat(e),i+t.slice(0,e))}UV.prototype.format=function(i){var e="Error: "+this.message;if(this.location){var t=null,n;for(n=0;n<i.length;n++)if(i[n].source===this.location.source){t=i[n].text.split(/\r\n|\n|\r/g);break}var r=this.location.start,a=this.location.source&&typeof this.location.source.offset=="function"?this.location.source.offset(r):r,o=this.location.source+":"+a.line+":"+a.column;if(t){var s=this.location.end,l=Gge("",a.line.toString().length," "),c=t[r.line-1],u=r.line===s.line?s.column:c.length+1,f=u-r.column||1;e+=`
13083
13083
  --> `+o+`
13084
13084
  `+l+` |
13085
13085
  `+a.line+" | "+c+`
13086
13086
  `+l+" | "+Gge("",r.column-1," ")+Gge("",f,"^")}else e+=`
13087
- at `+o}return e},UV.buildMessage=function(i,e){var t={literal:function(c){return'"'+r(c.text)+'"'},class:function(c){var u=c.parts.map(function(f){return Array.isArray(f)?a(f[0])+"-"+a(f[1]):a(f)});return"["+(c.inverted?"^":"")+u.join("")+"]"},any:function(){return"any character"},end:function(){return"end of input"},other:function(c){return c.description}};function n(c){return c.charCodeAt(0).toString(16).toUpperCase()}function r(c){return c.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,function(u){return"\\x0"+n(u)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(u){return"\\x"+n(u)})}function a(c){return c.replace(/\\/g,"\\\\").replace(/\]/g,"\\]").replace(/\^/g,"\\^").replace(/-/g,"\\-").replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,function(u){return"\\x0"+n(u)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(u){return"\\x"+n(u)})}function o(c){return t[c.type](c)}function s(c){var u=c.map(o),f,h;if(u.sort(),u.length>0){for(f=1,h=1;f<u.length;f++)u[f-1]!==u[f]&&(u[h]=u[f],h++);u.length=h}switch(u.length){case 1:return u[0];case 2:return u[0]+" or "+u[1];default:return u.slice(0,-1).join(", ")+", or "+u[u.length-1]}}function l(c){return c?'"'+r(c)+'"':"end of input"}return"Expected "+s(i)+" but "+l(e)+" found."};function Ppn(i){var f,h,p,y;const e=(0,Rpn.vectorText)({height:i.font_size*.45,input:i.text});let t=i.ccw_rotation??0;e.forEach(_=>{_.length===29?(e.splice(e.indexOf(_),1,_.slice(0,15)),e.splice(e.indexOf(_),0,_.slice(14,29))):_.length===17&&(e.splice(e.indexOf(_),1,_.slice(0,10)),e.splice(e.indexOf(_),0,_.slice(9,17)))});const n=e.flatMap(_=>_),r={minX:Math.min(...n.map(_=>_[0])),maxX:Math.max(...n.map(_=>_[0])),minY:Math.min(...n.map(_=>_[1])),maxY:Math.max(...n.map(_=>_[1]))},a=(r.minX+r.maxX)/2,o=(r.minY+r.maxY)/2;let s=-a,l=-o;(f=i.anchor_alignment)!=null&&f.includes("right")?s=-r.maxX:(h=i.anchor_alignment)!=null&&h.includes("left")&&(s=-r.minX),(p=i.anchor_alignment)!=null&&p.includes("top")?l=-r.maxY:(y=i.anchor_alignment)!=null&&y.includes("bottom")&&(l=-r.minY);const c=[];if(i.layer==="bottom"&&(c.push(Ow(a,o),{a:-1,b:0,c:0,d:1,e:0,f:0},Ow(-a,-o)),t=-t),t){const _=t*Math.PI/180;c.push(Ow(a,o),J$e(_),Ow(-a,-o))}let u=e;if(c.length>0){const _=K$e(...c);u=e.map(I=>I.map(([C,b])=>{const{x:w,y:N}=V$e(_,{x:C,y:b});return[w,N]}))}return{textOutlines:u,xOffset:s,yOffset:l}}var kpn=KC(rN()),Upn=KC(Pge()),Lpn=KC(MV()),Fpn=KC(DV()),Gpn=KC(H7());function Opn(i,e){if(i.route.length<2)return;const t=i.route.map(c=>[c.x,c.y]),n=(0,kpn.line)(t),r=i.stroke_width||.1,a=(0,Upn.expand)({delta:r/2,corners:"round"},n),o=i.layer==="bottom"?-1:1,s=o*e.pcbThickness/2+o*D_*1.5;let l=(0,Fpn.translate)([0,0,s],(0,Lpn.extrudeLinear)({height:.012},a));return l=(0,Gpn.colorize)([1,1,1],l),l}var q$e=["initializing","processing_plated_holes","processing_holes","processing_cutouts","processing_pads","processing_traces","processing_vias","processing_silkscreen_text","processing_silkscreen_paths","finalizing","done"],zpn=class{constructor(i,e){be(this,"circuitJson");be(this,"board");be(this,"plated_holes");be(this,"holes");be(this,"pads");be(this,"traces");be(this,"pcb_vias");be(this,"silkscreenTexts");be(this,"silkscreenPaths");be(this,"pcb_cutouts");be(this,"boardGeom",null);be(this,"platedHoleGeoms",[]);be(this,"holeGeoms",[]);be(this,"padGeoms",[]);be(this,"traceGeoms",[]);be(this,"viaGeoms",[]);be(this,"silkscreenTextGeoms",[]);be(this,"silkscreenPathGeoms",[]);be(this,"state","initializing");be(this,"currentIndex",0);be(this,"ctx");be(this,"onCompleteCallback");be(this,"finalGeoms",[]);this.circuitJson=i,this.onCompleteCallback=e,this.board=O1(i).pcb_board.list()[0],this.plated_holes=O1(i).pcb_plated_hole.list(),this.holes=O1(i).pcb_hole.list(),this.pads=O1(i).pcb_smtpad.list(),this.traces=O1(i).pcb_trace.list(),this.pcb_vias=O1(i).pcb_via.list(),this.silkscreenTexts=O1(i).pcb_silkscreen_text.list(),this.silkscreenPaths=O1(i).pcb_silkscreen_path.list(),this.pcb_cutouts=O1(i).pcb_cutout.list(),this.ctx={pcbThickness:1.2},this.initializeBoard()}getHoleToCut(i,e){const t=D_/10;for(const n of this.pcb_vias)if(Math.abs(n.x-i)<t&&Math.abs(n.y-e)<t&&n.hole_diameter)return{diameter:n.hole_diameter};for(const n of this.plated_holes)if(n.shape==="circle"&&Math.abs(n.x-i)<t&&Math.abs(n.y-e)<t&&n.hole_diameter)return{diameter:n.hole_diameter};return null}initializeBoard(){this.board.outline&&this.board.outline.length>0?this.boardGeom=z$e({outline:this.board.outline},this.ctx.pcbThickness):this.boardGeom=(0,ZE.cuboid)({size:[this.board.width,this.board.height,this.ctx.pcbThickness],center:[this.board.center.x,this.board.center.y,0]}),this.state="processing_plated_holes",this.currentIndex=0}goToNextState(){const i=q$e.indexOf(this.state);i!==-1&&(this.state=q$e[i+1],this.currentIndex=0)}step(i=1){if(this.state==="done"||!this.boardGeom)return!0;for(let e=0;e<i&&this.state!=="done";e++)switch(this.state){case"processing_plated_holes":this.currentIndex<this.plated_holes.length?(this.processPlatedHole(this.plated_holes[this.currentIndex]),this.currentIndex++):this.goToNextState();break;case"processing_holes":this.currentIndex<this.holes.length?(this.processHole(this.holes[this.currentIndex]),this.currentIndex++):this.goToNextState();break;case"processing_pads":this.currentIndex<this.pads.length?(this.processPad(this.pads[this.currentIndex]),this.currentIndex++):this.goToNextState();break;case"processing_traces":this.currentIndex<this.traces.length?(this.processTrace(this.traces[this.currentIndex]),this.currentIndex++):this.goToNextState();break;case"processing_vias":this.currentIndex<this.pcb_vias.length?(this.processVia(this.pcb_vias[this.currentIndex]),this.currentIndex++):this.goToNextState();break;case"processing_silkscreen_text":this.currentIndex<this.silkscreenTexts.length?(this.processSilkscreenText(this.silkscreenTexts[this.currentIndex]),this.currentIndex++):this.goToNextState();break;case"processing_silkscreen_paths":this.currentIndex<this.silkscreenPaths.length?(this.processSilkscreenPath(this.silkscreenPaths[this.currentIndex]),this.currentIndex++):this.goToNextState();break;case"processing_cutouts":this.currentIndex<this.pcb_cutouts.length?(this.processCutout(this.pcb_cutouts[this.currentIndex]),this.currentIndex++):this.goToNextState();break;case"finalizing":this.finalize(),this.state="done";break}return this.state==="done"}processCutout(i){if(!this.boardGeom)return;let e=null;const t=this.ctx.pcbThickness*1.5;switch(i.shape){case"rect":if(e=(0,ZE.cuboid)({center:[i.center.x,i.center.y,0],size:[i.width,i.height,t]}),i.rotation){const a=i.rotation*Math.PI/180;e=(0,rQ.rotateZ)(a,e)}break;case"circle":e=(0,ZE.cylinder)({center:[i.center.x,i.center.y,0],radius:i.radius,height:t});break;case"polygon":let n=i.points.map(a=>[a.x,a.y]);if(n.length<3){console.warn(`PCB Cutout [${i.pcb_cutout_id}] polygon has fewer than 3 points, skipping.`);break}O$e(n)&&(n=n.reverse());const r=(0,ZE.polygon)({points:n});e=(0,kV.extrudeLinear)({height:t},r),e=(0,rQ.translate)([0,0,-t/2],e);break}e&&(this.boardGeom=(0,aQ.subtract)(this.boardGeom,e))}processPlatedHole(i,e={}){if(this.boardGeom){if(i.shape==="circle"||i.shape==="circular_hole_with_rect_pad"){const t=(0,ZE.cylinder)({center:[i.x,i.y,0],radius:i.hole_diameter/2+D_,height:this.ctx.pcbThickness*1.5});e.dontCutBoard||(this.boardGeom=(0,aQ.subtract)(this.boardGeom,t));const n=H$e(i,this.ctx);this.platedHoleGeoms.push(n)}else if(i.shape==="pill"||i.shape==="pill_hole_with_rect_pad"){const t=i.hole_height>i.hole_width,n=t?i.hole_height:i.hole_width,r=t?i.hole_width:i.hole_height,a=r/2,o=Math.abs(n-r),s=(0,aQ.union)((0,ZE.cuboid)({center:[i.x,i.y,0],size:t?[r,o,this.ctx.pcbThickness*1.5]:[o,r,this.ctx.pcbThickness*1.5]}),(0,ZE.cylinder)({center:t?[i.x,i.y-o/2,0]:[i.x-o/2,i.y,0],radius:a,height:this.ctx.pcbThickness*1.5}),(0,ZE.cylinder)({center:t?[i.x,i.y+o/2,0]:[i.x+o/2,i.y,0],radius:a,height:this.ctx.pcbThickness*1.5}));e.dontCutBoard||(this.boardGeom=(0,aQ.subtract)(this.boardGeom,s));const l=H$e(i,this.ctx);this.platedHoleGeoms.push(l)}}}processHole(i){if(this.boardGeom&&(i.hole_shape==="round"||i.hole_shape==="circle")){const e=(0,ZE.cylinder)({center:[i.x,i.y,0],radius:i.hole_diameter/2+D_,height:this.ctx.pcbThickness*1.5});this.boardGeom=(0,aQ.subtract)(this.boardGeom,e)}}processPad(i){const e=i.layer==="bottom"?-1:1,t=e*this.ctx.pcbThickness/2+e*D_*2;if(i.shape==="rect"){const n=(0,aN.colorize)(Px.copper,(0,ZE.cuboid)({center:[i.x,i.y,t],size:[i.width,i.height,D_]}));this.padGeoms.push(n)}else if(i.shape==="rotated_rect"){let n=(0,ZE.cuboid)({center:[0,0,0],size:[i.width,i.height,D_]});const r=i.ccw_rotation*Math.PI/180;n=(0,rQ.rotateZ)(r,n);const a=(0,rQ.translate)([i.x,i.y,t],n),o=(0,aN.colorize)(Px.copper,a);this.padGeoms.push(o)}else if(i.shape==="circle"){const n=(0,aN.colorize)(Px.copper,(0,ZE.cylinder)({center:[i.x,i.y,t],radius:i.radius,height:D_}));this.padGeoms.push(n)}}processTrace(i){const{route:e}=i;if(e.length<2)return;let t=[],n=null,r=.1;const a=()=>{if(t.length>=2&&n){const o=n==="bottom"?-1:1,s=o*this.ctx.pcbThickness/2+o*D_,l=(0,ZE.line)(t),c=(0,Y$e.expand)({delta:r/2,corners:"round"},l);let u=(0,rQ.translate)([0,0,s],(0,kV.extrudeLinear)({height:D_},c));const f=t[0],h=t[t.length-1],p=this.getHoleToCut(f[0],f[1]);if(p){const I=(0,ZE.cylinder)({center:[f[0],f[1],s+D_/2],radius:p.diameter/2+D_,height:D_});u=(0,aQ.subtract)(u,I)}const y=this.getHoleToCut(h[0],h[1]);if(y){const I=(0,ZE.cylinder)({center:[h[0],h[1],s+D_/2],radius:y.diameter/2+D_,height:D_});u=(0,aQ.subtract)(u,I)}const _=G$e[this.board.material]??Px.fr4GreenSolderWithMask;u=(0,aN.colorize)(_,u),this.traceGeoms.push(u)}t=[],n=null};for(let o=0;o<e.length;o++){const s=e[o];if(s.route_type==="wire")n===null?(n=s.layer,r=s.width,t.push([s.x,s.y])):s.layer===n?t.push([s.x,s.y]):(t.push([s.x,s.y]),a(),n=s.layer,r=s.width,e[o-1]?t.push([s.x,s.y]):t.push([s.x,s.y]));else if(s.route_type==="via"){t.push([s.x,s.y]),a();const l=e[o+1];l&&l.route_type==="wire"&&(n=l.layer,r=l.width,t.push([s.x,s.y]))}}a()}processVia(i){this.processPlatedHole({x:i.x,y:i.y,hole_diameter:i.hole_diameter,outer_diameter:i.outer_diameter,shape:"circle",layers:["top","bottom"],type:"pcb_plated_hole",pcb_plated_hole_id:`via_${i.pcb_via_id}`},{dontCutBoard:!0})}processSilkscreenText(i){const{textOutlines:e,xOffset:t,yOffset:n}=Ppn(i);for(const r of e){const a=r.map(f=>[f[0]+t+i.anchor_position.x,f[1]+n+i.anchor_position.y]),o=(0,ZE.line)(a),s=i.font_size||.25,l=Math.min(Math.max(.01,s*.1),s*.05),c=(0,Y$e.expand)({delta:l,corners:"round"},o);let u;i.layer==="bottom"?u=(0,rQ.translate)([0,0,-this.ctx.pcbThickness/2-D_],(0,kV.extrudeLinear)({height:.012},c)):u=(0,rQ.translate)([0,0,this.ctx.pcbThickness/2+D_],(0,kV.extrudeLinear)({height:.012},c)),u=(0,aN.colorize)([1,1,1],u),this.silkscreenTextGeoms.push(u)}}processSilkscreenPath(i){const e=Opn(i,this.ctx);e&&this.silkscreenPathGeoms.push(e)}finalize(){if(!this.boardGeom)return;const i=Fge[this.board.material]??Px.fr4Green;this.boardGeom=(0,aN.colorize)(i,this.boardGeom),this.finalGeoms=[this.boardGeom,...this.platedHoleGeoms,...this.padGeoms,...this.traceGeoms,...this.viaGeoms,...this.silkscreenTextGeoms,...this.silkscreenPathGeoms],this.onCompleteCallback&&this.onCompleteCallback(this.finalGeoms)}getGeoms(){return this.finalGeoms}},Hpn=i=>{const[e,t]=pt.useState(null),n=pt.useRef(!1);return pt.useEffect(()=>{let r=!1;if(!i){t(null);return}if(!i.some(l=>l.type==="pcb_board")){t(null);return}const a=Qpn(i);t(a);const o=new zpn(i,l=>{});return(async()=>{if(!n.current){n.current=!0;try{let l=!1;for(;!l&&!r;)l=o.step(1),l||await new Promise(c=>setTimeout(c,0));r||t(o.getGeoms())}catch(l){console.error("Error during board geometry building:",l)}finally{n.current=!1}}})(),()=>{r=!0}},[i]),e},X$e=({error:i,cad_component:e})=>{const[t,n]=pt.useState(!1),[r,a]=pt.useState(null),o=pt.useCallback(c=>{c!=null&&c.mousePosition?(n(!0),a(c.mousePosition)):(n(!1),a(null))},[]),s=pt.useCallback(()=>{n(!1),a(null)},[]);let l=[0,0,0];return e!=null&&e.position&&(l=[e.position.x,e.position.y,e.position.z],l=l.map(c=>Number.isNaN(c)?0:c)),We.jsxs(We.Fragment,{children:[We.jsx(NV,{isHovered:t,onHover:o,onUnhover:s,position:l,children:We.jsxs("group",{position:l,children:[We.jsxs("mesh",{renderOrder:-99999,rotation:[Math.PI/4,Math.PI/4,0],ref:c=>{c&&(c.renderOrder=999999)},children:[We.jsx("boxGeometry",{args:[.5,.5,.5]}),We.jsx("meshStandardMaterial",{depthTest:!1,transparent:!0,color:"red",opacity:.5})]}),We.jsxs(eQ,{scale:[.1,.1,.1],color:"red",anchorX:"center",anchorY:"middle",depthOffset:-99999,children:[i.toString().slice(0,50),"..."]})]})}),t&&r?We.jsx(CZe,{position:r,style:{fontFamily:"sans-serif",transform:"translate3d(50%, 50%, 0)",backgroundColor:"white",padding:"6px",borderRadius:"4px",color:"red",pointerEvents:"none",userSelect:"none",WebkitUserSelect:"none",MozUserSelect:"none",msUserSelect:"none"},children:i.toString()}):null]})};function Ypn({stlUrl:i,mtlUrl:e,color:t,opacity:n=1}){const r=G0e(ipn,i),a=pt.useRef();return We.jsxs("mesh",{ref:a,children:[We.jsx("primitive",{object:r,attach:"geometry"}),We.jsx("meshStandardMaterial",{color:t,transparent:n!==1,opacity:n})]})}var Z$e=class extends Qh.Component{constructor(i){super(i),this.state={hasError:!1,error:null}}static getDerivedStateFromError(i){return{hasError:!0,error:i}}render(){return this.state.hasError&&this.state.error?this.props.fallback({error:this.state.error}):this.props.children}},Vpn=pt.forwardRef(({soup:i,circuitJson:e,children:t,autoRotateDisabled:n,clickToInteractEnabled:r},a)=>{const o=F$e(t),s=pt.useMemo(()=>i??e??o,[i,e,o]),l=Hpn(s),c=pt.useMemo(()=>{if(!s)return[5,5,5];try{const p=O1(s).pcb_board.list()[0];if(!p)return[5,5,5];const{width:y,height:_}=p;if(!y&&!_)return[5,5,5];const I=5,C=Math.max(y,I),b=Math.max(_,I),w=Math.max(C,b);return[w/2,w/2,w]}catch(p){return console.error(p),[5,5,5]}},[s]),u=pt.useMemo(()=>{if(s)try{const p=O1(s).pcb_board.list()[0];return p?{width:p.width??0,height:p.height??0}:void 0}catch(p){console.error(p);return}},[s]),{stls:f}=xpn(l),h=O1(s).cad_component.list();return We.jsxs(L$e,{ref:a,autoRotateDisabled:n,initialCameraPosition:c,clickToInteractEnabled:r,boardDimensions:u,children:[f.map(({stlUrl:p,color:y},_)=>We.jsx(Ypn,{stlUrl:p,color:y,opacity:_===0?.95:1},p)),h.map(p=>We.jsx(Z$e,{fallback:({error:y})=>We.jsx(X$e,{cad_component:p,error:y}),children:We.jsx(U$e,{cad_component:p,circuitJson:s},p.cad_component_id)},p.cad_component_id))]})});function X7(i){const e=new Eg;if(e.setAttribute("position",new yA(i.vertProperties,3)),e.setIndex(new Dz(i.triVerts,1)),i.runIndex&&i.runIndex.length>1&&i.runOriginalID)for(let t=0;t<i.runIndex.length-1;t++){const n=i.runIndex[t],r=i.runIndex[t+1]-n;e.addGroup(n,r,0)}else e.addGroup(0,i.triVerts.length,0);return e}function W$e(i){return i&&i.route_type==="wire"&&typeof i.layer=="string"&&typeof i.width=="number"}function $$e({layer:i,circuitJson:e,boardData:t,traceColor:n,traceTextureResolution:r}){const a=O1(e).pcb_trace.list(),o=O1(e).pcb_via.list(),s=O1(e).pcb_plated_hole.list(),l=a.filter(y=>y.route.some(_=>W$e(_)&&_.layer===i));if(l.length===0)return null;const c=document.createElement("canvas"),u=Math.floor(t.width*r),f=Math.floor(t.height*r);c.width=u,c.height=f;const h=c.getContext("2d");if(!h)return null;i==="bottom"&&(h.translate(0,f),h.scale(1,-1)),l.forEach(y=>{let _=!0;h.beginPath(),h.strokeStyle=n,h.lineCap="round",h.lineJoin="round";let I=0;for(const C of y.route){if(!W$e(C)||C.layer!==i){_||h.stroke(),_=!0;continue}const b=C.x,w=C.y;I=C.width*r,h.lineWidth=I;const N=(b-t.center.x+t.width/2)*r,V=(-(w-t.center.y)+t.height/2)*r;_?(h.moveTo(N,V),_=!1):h.lineTo(N,V)}_||h.stroke()}),h.globalCompositeOperation="destination-out",h.fillStyle="black",o.forEach(y=>{const _=(y.x-t.center.x+t.width/2)*r,I=(-(y.y-t.center.y)+t.height/2)*r,C=y.outer_diameter/2*r;h.beginPath(),h.arc(_,I,C,0,2*Math.PI,!1),h.fill()}),s.forEach(y=>{if(y.layers.includes(i)&&y.shape==="circle"){const _=(y.x-t.center.x+t.width/2)*r,I=(-(y.y-t.center.y)+t.height/2)*r,C=y.outer_diameter/2*r;h.beginPath(),h.arc(_,I,C,0,2*Math.PI,!1),h.fill()}}),h.globalCompositeOperation="source-over";const p=new eoe(c);return p.generateMipmaps=!0,p.minFilter=e2,p.magFilter=i9,p.anisotropy=16,p.needsUpdate=!0,p}var jpn=KC(Bge());function eet({layer:i,circuitJson:e,boardData:t,silkscreenColor:n="rgb(255,255,255)",traceTextureResolution:r}){const a=O1(e).pcb_silkscreen_text.list(),o=O1(e).pcb_silkscreen_path.list(),s=a.filter(y=>y.layer===i),l=o.filter(y=>y.layer===i);if(s.length===0&&l.length===0)return null;const c=document.createElement("canvas"),u=Math.floor(t.width*r),f=Math.floor(t.height*r);c.width=u,c.height=f;const h=c.getContext("2d");if(!h)return null;i==="bottom"&&(h.translate(0,f),h.scale(1,-1)),h.strokeStyle=n,h.fillStyle=n,l.forEach(y=>{y.route.length<2||(h.beginPath(),h.lineWidth=(y.stroke_width||.1)*r,h.lineCap="round",h.lineJoin="round",y.route.forEach((_,I)=>{const C=(_.x-t.center.x+t.width/2)*r,b=(-(_.y-t.center.y)+t.height/2)*r;I===0?h.moveTo(C,b):h.lineTo(C,b)}),h.stroke())}),s.forEach(y=>{const _=y.font_size||.25,I=Math.min(Math.max(.01,_*.1),_*.05)*r;h.lineWidth=I,h.lineCap="butt",h.lineJoin="miter";const C=(0,jpn.vectorText)({height:_*.45,input:y.text}),b=[];C.forEach(re=>{re.length===29?(b.push(re.slice(0,15)),b.push(re.slice(14,29))):re.length===17?(b.push(re.slice(0,10)),b.push(re.slice(9,17))):b.push(re)});const w=b.flat(),N={minX:w.length>0?Math.min(...w.map(re=>re[0])):0,maxX:w.length>0?Math.max(...w.map(re=>re[0])):0,minY:w.length>0?Math.min(...w.map(re=>re[1])):0,maxY:w.length>0?Math.max(...w.map(re=>re[1])):0},V=(N.minX+N.maxX)/2,z=(N.minY+N.maxY)/2;let K=-V,G=-z;const q=y.anchor_alignment||"center";q.includes("left")?K=-N.minX:q.includes("right")&&(K=-N.maxX),q.includes("top")?G=-N.maxY:q.includes("bottom")&&(G=-N.minY);const Y=[];let oe=y.ccw_rotation??0;if(y.layer==="bottom"&&(Y.push(Ow(V,z),{a:-1,b:0,c:0,d:1,e:0,f:0},Ow(-V,-z)),oe=-oe),oe){const re=oe*Math.PI/180;Y.push(Ow(V,z),J$e(re),Ow(-V,-z))}const W=Y.length>0?K$e(...Y):void 0;b.forEach(re=>{h.beginPath(),re.forEach((fe,Ae)=>{let ce={x:fe[0],y:fe[1]};W&&(ce=V$e(W,ce));const xe=ce.x+K+y.anchor_position.x,me=ce.y+G+y.anchor_position.y,Re=(xe-t.center.x+t.width/2)*r,we=(-(me-t.center.y)+t.height/2)*r;Ae===0?h.moveTo(Re,we):h.lineTo(Re,we)}),h.stroke()})});const p=new eoe(c);return p.generateMipmaps=!0,p.minFilter=e2,p.magFilter=i9,p.anisotropy=16,p.needsUpdate=!0,p}function Kpn({Manifold:i,x:e,y:t,diameter:n,thickness:r,segments:a=32}){return i.cylinder(r*1.2,n/2,n/2,a,!0).translate([e,t,0])}function tet({Manifold:i,x:e,y:t,outerDiameter:n,thickness:r,zOffset:a=.001,segments:o=32}){const s=n/2+a;return i.cylinder(r*1.2,s,s,o,!0).translate([e,t,0])}function Jpn(i){return(i.shape==="circle"||i.hole_shape==="circle")&&typeof i.hole_diameter=="number"}function qpn(i,e,t,n){const r=[];return O1(e).pcb_hole.list().forEach(o=>{if(Jpn(o)){const s=Kpn({Manifold:i,x:o.x,y:o.y,diameter:o.hole_diameter,thickness:t,segments:zB});n.push(s),r.push(s)}}),{nonPlatedHoleBoardDrills:r}}var net=new td(...Px.copper);function Xpn(i,e,t,n){const r=[],a=O1(e).pcb_plated_hole.list(),o=[];return a.forEach((s,l)=>{if(s.shape==="circle"){const c=tet({Manifold:i,x:s.x,y:s.y,outerDiameter:s.outer_diameter,thickness:t,zOffset:a3,segments:zB});n.push(c),r.push(c);const u=t+2*a3;let f=i.cylinder(u,s.outer_diameter/2,s.outer_diameter/2,zB,!0);n.push(f);const h=i.cylinder(u*1.05,s.hole_diameter/2,s.hole_diameter/2,zB,!0);n.push(h);const p=f.subtract(h);n.push(p);const y=p.translate([s.x,s.y,0]);n.push(y);const _=X7(y.getMesh());o.push({key:`ph-${s.pcb_plated_hole_id||l}`,geometry:_,color:net})}else if(s.shape==="pill"){const c=s.hole_width,u=s.hole_height,f=u>c,h=f?u:c,p=f?c:u,y=.4,_=f?s.outer_height??p+y/2:s.outer_width??h+y/2,I=f?s.outer_width??h+y/2:s.outer_height??p+y/2,C=(re,fe,Ae)=>{const ce=fe/2,xe=re-fe;let me;if(xe<1e-9)me=i.cylinder(Ae,ce,ce,zB,!0);else{const Re=i.cube([Math.max(0,xe),fe,Ae],!0),we=i.cylinder(Ae,ce,ce,zB,!0).translate([-xe/2,0,0]),Te=i.cylinder(Ae,ce,ce,zB,!0).translate([xe/2,0,0]);me=i.union([Re,we,Te]),n.push(Re,we,Te)}return n.push(me),me},b=h+2*a3,w=p+2*a3,N=t*1.2;let V=C(b,w,N);if(f){const re=V.rotate([0,0,90]);n.push(re),V=re}const z=V.translate([s.x,s.y,0]);n.push(z),r.push(z);const K=t+2*a3,G=C(_,I,K),q=C(h,p,K*1.05);let Y=G.subtract(q);if(n.push(Y),f){const re=Y.rotate([0,0,90]);n.push(re),Y=re}const oe=Y.translate([s.x,s.y,0]);n.push(oe);const W=X7(oe.getMesh());o.push({key:`ph-${s.pcb_plated_hole_id||l}`,geometry:W,color:net})}}),{platedHoleBoardDrills:r,platedHoleCopperGeoms:o}}function Zpn({Manifold:i,x:e,y:t,outerDiameter:n,holeDiameter:r,thickness:a,zOffset:o=.001,segments:s=32}){const l=a+2*o;let c=i.cylinder(l,n/2,-1,s,!0);const u=i.cylinder(l*1.05,r/2,-1,s,!0);return c.subtract(u).translate([e,t,0])}var Wpn=new td(...Px.copper);function $pn(i,e,t,n){const r=[],a=O1(e).pcb_via.list(),o=[];return a.forEach((s,l)=>{if(typeof s.outer_diameter=="number"){const c=tet({Manifold:i,x:s.x,y:s.y,outerDiameter:s.outer_diameter,thickness:t,zOffset:a3,segments:zB});n.push(c),r.push(c)}if(typeof s.outer_diameter=="number"&&typeof s.hole_diameter=="number"){const c=Zpn({Manifold:i,x:s.x,y:s.y,outerDiameter:s.outer_diameter,holeDiameter:s.hole_diameter,thickness:t,zOffset:a3,segments:zB});n.push(c);const u=X7(c.getMesh());o.push({key:`via-${s.pcb_via_id||l}`,geometry:u,color:Wpn})}}),{viaBoardDrills:r,viaCopperGeoms:o}}function e0n({Manifold:i,pad:e,padBaseThickness:t}){return e.shape==="rect"?i.cube([e.width,e.height,t],!0):e.shape==="circle"&&e.radius?i.cylinder(t,e.radius,-1,32,!0):null}var t0n=new td(...Px.copper);function n0n(i,e,t,n){const r=[];return O1(e).pcb_smtpad.list().forEach((o,s)=>{const l=Spn,c=o.layer==="bottom"?-t/2-l/2-a3:t/2+l/2+a3;let u=e0n({Manifold:i,pad:o,padBaseThickness:l});if(u){n.push(u);const f=u.translate([o.x,o.y,c]);n.push(f);const h=X7(f.getMesh());r.push({key:`pad-${o.pcb_smtpad_id||s}`,geometry:h,color:t0n})}}),{smtPadGeoms:r}}var i0n=i=>{let e=0;for(let n=0;n<i.length;n++){const r=(n+1)%i.length;i[n]&&i[r]&&(e+=i[n][0]*i[r][1],e-=i[r][0]*i[n][1])}return e/2<=0};function r0n(i,e,t,n,r){let a;if(t.outline&&t.outline.length>=3){let o=t.outline.map(l=>[l.x,l.y]);i0n(o)&&(o=o.reverse());const s=e.ofPolygons([o]);r.push(s),a=i.extrude(s,n,void 0,void 0,void 0,!0),r.push(a)}else t.outline&&t.outline.length>0&&console.warn("Board outline has fewer than 3 points, falling back to rectangular board."),a=i.cube([t.width,t.height,n],!0),r.push(a),a=a.translate([t.center.x,t.center.y,0]),r.push(a);return a}var a0n=i=>{let e=0;for(let n=0;n<i.length;n++){const r=(n+1)%i.length;i[n]&&i[r]&&(e+=i[n][0]*i[r][1],e-=i[r][0]*i[n][1])}return e/2<=0};function o0n(i,e,t,n,r){const a=[],o=O1(t).pcb_cutout.list();for(const s of o){let l;const c=n*1.5;switch(s.shape){case"rect":if(l=i.cube([s.width,s.height,c],!0),r.push(l),s.rotation){s.rotation*Math.PI/180;const h=l.rotate([0,0,s.rotation]);r.push(h),l=h}l=l.translate([s.center.x,s.center.y,0]),r.push(l);break;case"circle":l=i.cylinder(c,s.radius,-1,zB,!0),r.push(l),l=l.translate([s.center.x,s.center.y,0]),r.push(l);break;case"polygon":if(s.points.length<3){console.warn(`PCB Cutout [${s.pcb_cutout_id}] polygon has fewer than 3 points, skipping.`);continue}let u=s.points.map(h=>[h.x,h.y]);a0n(u)&&(u=u.reverse());const f=e.ofPolygons([u]);r.push(f),l=i.extrude(f,c,0,0,[1,1],!0),r.push(l);break;default:console.warn(`Unsupported cutout shape: ${s.shape} for cutout ${s.pcb_cutout_id}`);continue}l&&a.push(l)}return{cutoutOps:a}}var s0n=(i,e)=>{const[t,n]=pt.useState(null),[r,a]=pt.useState(null),[o,s]=pt.useState(null),[l,c]=pt.useState(null),[u,f]=pt.useState(!0),h=pt.useRef([]),p=pt.useMemo(()=>{const y=O1(e).pcb_board.list();return y.length===0?null:y[0]},[e]);return pt.useEffect(()=>{if(!i||!p){n(null),a(null),s(null),O1(e).pcb_board.list().length===0&&c("No pcb_board found in circuitJson."),f(!1);return}if((p.width===0||!p.width)&&(p.height===0||!p.height)&&(!p.outline||p.outline.length<3)){n({platedHoles:[],smtPads:[],vias:[]}),a({}),s(p.thickness??0),f(!1);return}f(!0),c(null);const y=i.Manifold,_=i.CrossSection;h.current.forEach(w=>w.delete()),h.current=[];let I=null;const C={},b={};try{const w=p.thickness||1.6;s(w);let N=r0n(y,_,p,w,h.current);const V=[],{nonPlatedHoleBoardDrills:z}=qpn(y,e,w,h.current);V.push(...z);const{platedHoleBoardDrills:K,platedHoleCopperGeoms:G}=Xpn(y,e,w,h.current);V.push(...K),C.platedHoles=G;const{viaBoardDrills:q,viaCopperGeoms:Y}=$pn(y,e,w,h.current);if(V.push(...q),C.vias=Y,V.length>0){const ce=y.union(V);h.current.push(ce);const xe=N.subtract(ce);h.current.push(xe),N=xe}const{cutoutOps:oe}=o0n(y,_,e,w,h.current);if(oe.length>0){const ce=y.union(oe);h.current.push(ce);const xe=N.subtract(ce);h.current.push(xe),N=xe}if(I=N,I){const ce=I.getMesh(),xe=X7(ce),me=Fge[p.material]??Px.fr4Green;C.board={geometry:xe,color:new td(me[0],me[1],me[2])}}const{smtPadGeoms:W}=n0n(y,e,w,h.current);C.smtPads=W,n(C);const re=G$e[p.material]??Px.fr4GreenSolderWithMask,fe=`rgb(${Math.round(re[0]*255)}, ${Math.round(re[1]*255)}, ${Math.round(re[2]*255)})`;b.topTrace=$$e({layer:"top",circuitJson:e,boardData:p,traceColor:fe,traceTextureResolution:TV}),b.bottomTrace=$$e({layer:"bottom",circuitJson:e,boardData:p,traceColor:fe,traceTextureResolution:TV});const Ae="rgb(255,255,255)";b.topSilkscreen=eet({layer:"top",circuitJson:e,boardData:p,silkscreenColor:Ae,traceTextureResolution:TV}),b.bottomSilkscreen=eet({layer:"bottom",circuitJson:e,boardData:p,silkscreenColor:Ae,traceTextureResolution:TV}),a(b)}catch(w){console.error("Error processing geometry with Manifold in hook:",w),c(w.message||"An unknown error occurred while processing geometry in hook."),n(null),a(null)}finally{f(!1)}return()=>{h.current.forEach(w=>w.delete()),h.current=[]}},[i,e,p]),{geoms:t,textures:r,pcbThickness:o,error:l,isLoading:u,boardData:p}};function l0n(i){const e=[];if(!i)return e;if(i.board&&i.board.geometry){const n=new FI(i.board.geometry,new CD({color:i.board.color,side:YE,flatShading:!0}));n.name="board-geom",e.push(n)}const t=n=>{n&&n.forEach(r=>{const a=new FI(r.geometry,new CD({color:r.color,side:YE,flatShading:!0}));a.name=r.key,e.push(a)})};return t(i.platedHoles),t(i.smtPads),t(i.vias),e}function c0n(i,e,t){const n=[];if(!i||!e||t===null)return n;const r=(c,u,f,h)=>{if(!c)return null;const p=new wB(e.width,e.height),y=new SB({map:c,transparent:!0,side:YE,depthWrite:!1}),_=new FI(p,y);return _.position.set(e.center.x,e.center.y,u),f&&_.rotation.set(Math.PI,0,0),_.name=`${f?"bottom":"top"}-${h}-texture-plane`,_},a=r(i.topTrace,t/2+.015,!1,"trace");a&&n.push(a);const o=r(i.topSilkscreen,t/2+.017,!1,"silkscreen");o&&n.push(o);const s=r(i.bottomTrace,-t/2-.015,!0,"trace");s&&n.push(s);const l=r(i.bottomSilkscreen,-t/2-.017,!0,"silkscreen");return l&&n.push(l),n}var u0n="https://cdn.jsdelivr.net/npm/manifold-3d@3.1.1",d0n=({circuitJson:i,autoRotateDisabled:e,clickToInteractEnabled:t,children:n})=>{const r=F$e(n),a=pt.useMemo(()=>i??r,[i,r]),[o,s]=pt.useState(null),[l,c]=pt.useState(null);pt.useEffect(()=>{(async()=>{try{const z=`${u0n}/manifold.wasm`,G=await cun({locateFile:(q,Y)=>q==="manifold.wasm"?z:Y+q});G.setup(),s(G)}catch(z){console.error("Failed to load Manifold from CDN:",z),c(`Failed to load Manifold module: ${z instanceof Error?z.message:"Unknown error"}`)}})()},[]);const{geoms:u,textures:f,pcbThickness:h,error:p,isLoading:y,boardData:_}=s0n(o,a),I=pt.useMemo(()=>l0n(u),[u]),C=pt.useMemo(()=>c0n(f,_,h),[f,_,h]),b=pt.useMemo(()=>O1(a).cad_component.list(),[a]),w=pt.useMemo(()=>{if(!_)return;const{width:V=0,height:z=0}=_;return{width:V,height:z}},[_]),N=pt.useMemo(()=>{if(!_)return[5,5,5];const{width:V=0,height:z=0}=_,K=Math.max(V,1),G=Math.max(z,1),q=Math.max(K,G,5);return[q*.75,q*.75,q*.75]},[_]);return l?We.jsxs("div",{style:{color:"red",padding:"1em",border:"1px solid red",margin:"1em"},children:["Error: ",l]}):o?p?We.jsxs("div",{style:{color:"red",padding:"1em",border:"1px solid red",margin:"1em"},children:["Error: ",p]}):y?We.jsx("div",{style:{padding:"1em"},children:"Processing board geometry..."}):We.jsxs(L$e,{initialCameraPosition:N,autoRotateDisabled:e,clickToInteractEnabled:t,boardDimensions:w,children:[I.map((V,z)=>We.jsx("primitive",{object:V},`${V.name}-${z}`)),C.map((V,z)=>We.jsx("primitive",{object:V},`${V.name}-${z}`)),b.map(V=>We.jsx(Z$e,{fallback:({error:z})=>We.jsx(X$e,{cad_component:V,error:z}),children:We.jsx(U$e,{cad_component:V,circuitJson:a})},V.cad_component_id))]}):We.jsx("div",{style:{padding:"1em"},children:"Loading Manifold module..."})},f0n=d0n,A0n=({containerRef:i})=>{const[e,t]=pt.useState(!1),[n,r]=pt.useState({x:0,y:0}),a=pt.useRef(null),o=pt.useRef(null),s=pt.useCallback(p=>{p.preventDefault();const y=typeof p.clientX=="number"?p.clientX:0,_=typeof p.clientY=="number"?p.clientY:0;if(!o.current)return;const{x:I,y:C}=o.current,b=Math.abs(y-I),w=Math.abs(_-C),N=10;if(b>N||w>N){o.current=null;return}r({x:y,y:_}),t(!0),o.current=null},[r,t]),l=pt.useCallback(p=>{if(p.touches.length===1){const y=p.touches[0];y?o.current={x:y.clientX,y:y.clientY}:o.current=null}else o.current=null},[]),c=pt.useCallback(p=>{if(!o.current||p.touches.length!==1)return;const y=p.touches[0];if(y){const _=Math.abs(y.clientX-o.current.x),I=Math.abs(y.clientY-o.current.y),C=10;(_>C||I>C)&&(o.current=null)}else o.current=null},[]),u=pt.useCallback(()=>{setTimeout(()=>{o.current&&(o.current=null)},0)},[]),f=pt.useCallback(p=>{const y=p.target;a.current&&!a.current.contains(y)&&t(!1)},[]);return pt.useEffect(()=>{if(e)return document.addEventListener("mousedown",f),()=>document.removeEventListener("mousedown",f)},[e,f]),{menuVisible:e,menuPos:n,menuRef:a,contextMenuEventHandlers:{onMouseDown:p=>{p.button===2?o.current={x:p.clientX,y:p.clientY}:o.current=null},onContextMenu:s,onTouchStart:l,onTouchMove:c,onTouchEnd:u},setMenuVisible:t}},h0n=i=>{const[e,t]=pt.useState("jscad"),n=pt.useRef(null),{menuVisible:r,menuPos:a,menuRef:o,contextMenuEventHandlers:s,setMenuVisible:l}=A0n({containerRef:n}),c=f=>{t(f),l(!1)};pt.useEffect(()=>{const f=window.localStorage.getItem("cadViewerEngine");(f==="jscad"||f==="manifold")&&t(f)},[]),pt.useEffect(()=>{window.localStorage.setItem("cadViewerEngine",e)},[e]);const u=i.circuitJson?JSON.stringify(i.circuitJson):void 0;return We.jsxs("div",{ref:n,style:{width:"100%",height:"100%",position:"relative"},...s,children:[e==="jscad"?We.jsx(Vpn,{...i}):We.jsx(f0n,{...i}),We.jsxs("div",{style:{position:"absolute",right:8,top:8,background:"#222",color:"#fff",padding:"2px 8px",borderRadius:4,fontSize:12,opacity:.7,userSelect:"none"},children:["Engine: ",We.jsx("b",{children:e==="jscad"?"JSCAD":"Manifold"})]}),r&&We.jsx("div",{ref:o,style:{position:"fixed",top:a.y,left:a.x,background:"#23272f",color:"#f5f6fa",borderRadius:6,boxShadow:"0 6px 24px 0 rgba(0,0,0,0.18)",zIndex:1e3,minWidth:200,border:"1px solid #353945",padding:0,fontSize:15,fontWeight:500,transition:"opacity 0.1s"},children:We.jsxs("div",{style:{padding:"12px 18px",cursor:"pointer",display:"flex",alignItems:"center",gap:10,color:"#f5f6fa",fontWeight:500,borderRadius:6,transition:"background 0.1s"},onClick:()=>c(e==="jscad"?"manifold":"jscad"),onMouseOver:f=>f.currentTarget.style.background="#2d313a",onMouseOut:f=>f.currentTarget.style.background="transparent",children:["Switch to ",e==="jscad"?"Manifold":"JSCAD"," Engine",We.jsx("span",{style:{fontSize:12,marginLeft:"auto",opacity:.5,fontWeight:400},children:e==="jscad"?"experimental":"default"})]})})]},u)},p0n=KC($hn());KC(D$e()),(0,p0n.default)("tscircuit:3d-viewer:convert-circuit-json-to-3d-svg");const g0n=({error:i})=>We.jsx("div",{"data-testid":"error-container",className:"rf-error-container rf-mt-4 rf-bg-red-50 rf-rounded-md rf-border rf-border-red-200",children:We.jsxs("div",{className:"rf-p-4",children:[We.jsx("h2",{className:"rf-text-lg rf-font-semibold rf-text-red-800 rf-mb-3",children:"Error Loading 3D Viewer"}),We.jsx("p",{className:"rf-text-xs rf-font-mono rf-whitespace-pre-wrap rf-text-red-700",children:i.message}),We.jsx("details",{style:{whiteSpace:"pre-wrap"},className:"rf-text-xs rf-font-mono rf-text-red-600 rf-mt-2",children:i.stack})]})}),m0n=pt.createContext(null),Oge={didCatch:!1,error:null};class oN extends pt.Component{constructor(e){super(e),this.resetErrorBoundary=this.resetErrorBoundary.bind(this),this.state=Oge}static getDerivedStateFromError(e){return{didCatch:!0,error:e}}resetErrorBoundary(){const{error:e}=this.state;if(e!==null){for(var t,n,r=arguments.length,a=new Array(r),o=0;o<r;o++)a[o]=arguments[o];(t=(n=this.props).onReset)===null||t===void 0||t.call(n,{args:a,reason:"imperative-api"}),this.setState(Oge)}}componentDidCatch(e,t){var n,r;(n=(r=this.props).onError)===null||n===void 0||n.call(r,e,t)}componentDidUpdate(e,t){const{didCatch:n}=this.state,{resetKeys:r}=this.props;if(n&&t.error!==null&&y0n(e.resetKeys,r)){var a,o;(a=(o=this.props).onReset)===null||a===void 0||a.call(o,{next:r,prev:e.resetKeys,reason:"keys"}),this.setState(Oge)}}render(){const{children:e,fallbackRender:t,FallbackComponent:n,fallback:r}=this.props,{didCatch:a,error:o}=this.state;let s=e;if(a){const l={error:o,resetErrorBoundary:this.resetErrorBoundary};if(typeof t=="function")s=t(l);else if(n)s=pt.createElement(n,l);else if(r!==void 0)s=r;else throw o}return pt.createElement(m0n.Provider,{value:{didCatch:a,error:o,resetErrorBoundary:this.resetErrorBoundary}},s)}}function y0n(){let i=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[];return i.length!==e.length||i.some((t,n)=>!Object.is(t,e[n]))}function v0n(i,e){if(i==null)return{};var t={},n=Object.keys(i),r,a;for(a=0;a<n.length;a++)r=n[a],!(e.indexOf(r)>=0)&&(t[r]=i[r]);return t}var _0n=["color"],iet=pt.forwardRef(function(i,e){var t=i.color,n=t===void 0?"currentColor":t,r=v0n(i,_0n);return pt.createElement("svg",Object.assign({width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg"},r,{ref:e}),pt.createElement("path",{d:"M7.49933 0.25C3.49635 0.25 0.25 3.49593 0.25 7.50024C0.25 10.703 2.32715 13.4206 5.2081 14.3797C5.57084 14.446 5.70302 14.2222 5.70302 14.0299C5.70302 13.8576 5.69679 13.4019 5.69323 12.797C3.67661 13.235 3.25112 11.825 3.25112 11.825C2.92132 10.9874 2.44599 10.7644 2.44599 10.7644C1.78773 10.3149 2.49584 10.3238 2.49584 10.3238C3.22353 10.375 3.60629 11.0711 3.60629 11.0711C4.25298 12.1788 5.30335 11.8588 5.71638 11.6732C5.78225 11.205 5.96962 10.8854 6.17658 10.7043C4.56675 10.5209 2.87415 9.89918 2.87415 7.12104C2.87415 6.32925 3.15677 5.68257 3.62053 5.17563C3.54576 4.99226 3.29697 4.25521 3.69174 3.25691C3.69174 3.25691 4.30015 3.06196 5.68522 3.99973C6.26337 3.83906 6.8838 3.75895 7.50022 3.75583C8.1162 3.75895 8.73619 3.83906 9.31523 3.99973C10.6994 3.06196 11.3069 3.25691 11.3069 3.25691C11.7026 4.25521 11.4538 4.99226 11.3795 5.17563C11.8441 5.68257 12.1245 6.32925 12.1245 7.12104C12.1245 9.9063 10.4292 10.5192 8.81452 10.6985C9.07444 10.9224 9.30633 11.3648 9.30633 12.0413C9.30633 13.0102 9.29742 13.7922 9.29742 14.0299C9.29742 14.2239 9.42828 14.4496 9.79591 14.3788C12.6746 13.4179 14.75 10.7025 14.75 7.50024C14.75 3.49593 11.5036 0.25 7.49933 0.25Z",fill:n,fillRule:"evenodd",clipRule:"evenodd"}))});/**
13087
+ at `+o}return e},UV.buildMessage=function(i,e){var t={literal:function(c){return'"'+r(c.text)+'"'},class:function(c){var u=c.parts.map(function(f){return Array.isArray(f)?a(f[0])+"-"+a(f[1]):a(f)});return"["+(c.inverted?"^":"")+u.join("")+"]"},any:function(){return"any character"},end:function(){return"end of input"},other:function(c){return c.description}};function n(c){return c.charCodeAt(0).toString(16).toUpperCase()}function r(c){return c.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,function(u){return"\\x0"+n(u)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(u){return"\\x"+n(u)})}function a(c){return c.replace(/\\/g,"\\\\").replace(/\]/g,"\\]").replace(/\^/g,"\\^").replace(/-/g,"\\-").replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,function(u){return"\\x0"+n(u)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(u){return"\\x"+n(u)})}function o(c){return t[c.type](c)}function s(c){var u=c.map(o),f,h;if(u.sort(),u.length>0){for(f=1,h=1;f<u.length;f++)u[f-1]!==u[f]&&(u[h]=u[f],h++);u.length=h}switch(u.length){case 1:return u[0];case 2:return u[0]+" or "+u[1];default:return u.slice(0,-1).join(", ")+", or "+u[u.length-1]}}function l(c){return c?'"'+r(c)+'"':"end of input"}return"Expected "+s(i)+" but "+l(e)+" found."};function Ppn(i){var f,h,p,y;const e=(0,Rpn.vectorText)({height:i.font_size*.45,input:i.text});let t=i.ccw_rotation??0;e.forEach(_=>{_.length===29?(e.splice(e.indexOf(_),1,_.slice(0,15)),e.splice(e.indexOf(_),0,_.slice(14,29))):_.length===17&&(e.splice(e.indexOf(_),1,_.slice(0,10)),e.splice(e.indexOf(_),0,_.slice(9,17)))});const n=e.flatMap(_=>_),r={minX:Math.min(...n.map(_=>_[0])),maxX:Math.max(...n.map(_=>_[0])),minY:Math.min(...n.map(_=>_[1])),maxY:Math.max(...n.map(_=>_[1]))},a=(r.minX+r.maxX)/2,o=(r.minY+r.maxY)/2;let s=-a,l=-o;(f=i.anchor_alignment)!=null&&f.includes("right")?s=-r.maxX:(h=i.anchor_alignment)!=null&&h.includes("left")&&(s=-r.minX),(p=i.anchor_alignment)!=null&&p.includes("top")?l=-r.maxY:(y=i.anchor_alignment)!=null&&y.includes("bottom")&&(l=-r.minY);const c=[];if(i.layer==="bottom"&&(c.push(Ow(a,o),{a:-1,b:0,c:0,d:1,e:0,f:0},Ow(-a,-o)),t=-t),t){const _=t*Math.PI/180;c.push(Ow(a,o),J$e(_),Ow(-a,-o))}let u=e;if(c.length>0){const _=K$e(...c);u=e.map(I=>I.map(([C,b])=>{const{x:w,y:N}=V$e(_,{x:C,y:b});return[w,N]}))}return{textOutlines:u,xOffset:s,yOffset:l}}var kpn=KC(rN()),Upn=KC(Pge()),Lpn=KC(MV()),Fpn=KC(DV()),Gpn=KC(H7());function Opn(i,e){if(i.route.length<2)return;const t=i.route.map(c=>[c.x,c.y]),n=(0,kpn.line)(t),r=i.stroke_width||.1,a=(0,Upn.expand)({delta:r/2,corners:"round"},n),o=i.layer==="bottom"?-1:1,s=o*e.pcbThickness/2+o*D_*1.5;let l=(0,Fpn.translate)([0,0,s],(0,Lpn.extrudeLinear)({height:.012},a));return l=(0,Gpn.colorize)([1,1,1],l),l}var q$e=["initializing","processing_plated_holes","processing_holes","processing_cutouts","processing_pads","processing_traces","processing_vias","processing_silkscreen_text","processing_silkscreen_paths","finalizing","done"],zpn=class{constructor(i,e){be(this,"circuitJson");be(this,"board");be(this,"plated_holes");be(this,"holes");be(this,"pads");be(this,"traces");be(this,"pcb_vias");be(this,"silkscreenTexts");be(this,"silkscreenPaths");be(this,"pcb_cutouts");be(this,"boardGeom",null);be(this,"platedHoleGeoms",[]);be(this,"holeGeoms",[]);be(this,"padGeoms",[]);be(this,"traceGeoms",[]);be(this,"viaGeoms",[]);be(this,"silkscreenTextGeoms",[]);be(this,"silkscreenPathGeoms",[]);be(this,"state","initializing");be(this,"currentIndex",0);be(this,"ctx");be(this,"onCompleteCallback");be(this,"finalGeoms",[]);this.circuitJson=i,this.onCompleteCallback=e,this.board=O1(i).pcb_board.list()[0],this.plated_holes=O1(i).pcb_plated_hole.list(),this.holes=O1(i).pcb_hole.list(),this.pads=O1(i).pcb_smtpad.list(),this.traces=O1(i).pcb_trace.list(),this.pcb_vias=O1(i).pcb_via.list(),this.silkscreenTexts=O1(i).pcb_silkscreen_text.list(),this.silkscreenPaths=O1(i).pcb_silkscreen_path.list(),this.pcb_cutouts=O1(i).pcb_cutout.list(),this.ctx={pcbThickness:1.2},this.initializeBoard()}getHoleToCut(i,e){const t=D_/10;for(const n of this.pcb_vias)if(Math.abs(n.x-i)<t&&Math.abs(n.y-e)<t&&n.hole_diameter)return{diameter:n.hole_diameter};for(const n of this.plated_holes)if(n.shape==="circle"&&Math.abs(n.x-i)<t&&Math.abs(n.y-e)<t&&n.hole_diameter)return{diameter:n.hole_diameter};return null}initializeBoard(){this.board.outline&&this.board.outline.length>0?this.boardGeom=z$e({outline:this.board.outline},this.ctx.pcbThickness):this.boardGeom=(0,ZE.cuboid)({size:[this.board.width,this.board.height,this.ctx.pcbThickness],center:[this.board.center.x,this.board.center.y,0]}),this.state="processing_plated_holes",this.currentIndex=0}goToNextState(){const i=q$e.indexOf(this.state);i!==-1&&(this.state=q$e[i+1],this.currentIndex=0)}step(i=1){if(this.state==="done"||!this.boardGeom)return!0;for(let e=0;e<i&&this.state!=="done";e++)switch(this.state){case"processing_plated_holes":this.currentIndex<this.plated_holes.length?(this.processPlatedHole(this.plated_holes[this.currentIndex]),this.currentIndex++):this.goToNextState();break;case"processing_holes":this.currentIndex<this.holes.length?(this.processHole(this.holes[this.currentIndex]),this.currentIndex++):this.goToNextState();break;case"processing_pads":this.currentIndex<this.pads.length?(this.processPad(this.pads[this.currentIndex]),this.currentIndex++):this.goToNextState();break;case"processing_traces":this.currentIndex<this.traces.length?(this.processTrace(this.traces[this.currentIndex]),this.currentIndex++):this.goToNextState();break;case"processing_vias":this.currentIndex<this.pcb_vias.length?(this.processVia(this.pcb_vias[this.currentIndex]),this.currentIndex++):this.goToNextState();break;case"processing_silkscreen_text":this.currentIndex<this.silkscreenTexts.length?(this.processSilkscreenText(this.silkscreenTexts[this.currentIndex]),this.currentIndex++):this.goToNextState();break;case"processing_silkscreen_paths":this.currentIndex<this.silkscreenPaths.length?(this.processSilkscreenPath(this.silkscreenPaths[this.currentIndex]),this.currentIndex++):this.goToNextState();break;case"processing_cutouts":this.currentIndex<this.pcb_cutouts.length?(this.processCutout(this.pcb_cutouts[this.currentIndex]),this.currentIndex++):this.goToNextState();break;case"finalizing":this.finalize(),this.state="done";break}return this.state==="done"}processCutout(i){if(!this.boardGeom)return;let e=null;const t=this.ctx.pcbThickness*1.5;switch(i.shape){case"rect":if(e=(0,ZE.cuboid)({center:[i.center.x,i.center.y,0],size:[i.width,i.height,t]}),i.rotation){const a=i.rotation*Math.PI/180;e=(0,rQ.rotateZ)(a,e)}break;case"circle":e=(0,ZE.cylinder)({center:[i.center.x,i.center.y,0],radius:i.radius,height:t});break;case"polygon":let n=i.points.map(a=>[a.x,a.y]);if(n.length<3){console.warn(`PCB Cutout [${i.pcb_cutout_id}] polygon has fewer than 3 points, skipping.`);break}O$e(n)&&(n=n.reverse());const r=(0,ZE.polygon)({points:n});e=(0,kV.extrudeLinear)({height:t},r),e=(0,rQ.translate)([0,0,-t/2],e);break}e&&(this.boardGeom=(0,aQ.subtract)(this.boardGeom,e))}processPlatedHole(i,e={}){if(this.boardGeom){if(i.shape==="circle"||i.shape==="circular_hole_with_rect_pad"){const t=(0,ZE.cylinder)({center:[i.x,i.y,0],radius:i.hole_diameter/2+D_,height:this.ctx.pcbThickness*1.5});e.dontCutBoard||(this.boardGeom=(0,aQ.subtract)(this.boardGeom,t));const n=H$e(i,this.ctx);this.platedHoleGeoms.push(n)}else if(i.shape==="pill"||i.shape==="pill_hole_with_rect_pad"){const t=i.hole_height>i.hole_width,n=t?i.hole_height:i.hole_width,r=t?i.hole_width:i.hole_height,a=r/2,o=Math.abs(n-r),s=(0,aQ.union)((0,ZE.cuboid)({center:[i.x,i.y,0],size:t?[r,o,this.ctx.pcbThickness*1.5]:[o,r,this.ctx.pcbThickness*1.5]}),(0,ZE.cylinder)({center:t?[i.x,i.y-o/2,0]:[i.x-o/2,i.y,0],radius:a,height:this.ctx.pcbThickness*1.5}),(0,ZE.cylinder)({center:t?[i.x,i.y+o/2,0]:[i.x+o/2,i.y,0],radius:a,height:this.ctx.pcbThickness*1.5}));e.dontCutBoard||(this.boardGeom=(0,aQ.subtract)(this.boardGeom,s));const l=H$e(i,this.ctx);this.platedHoleGeoms.push(l)}}}processHole(i){if(this.boardGeom&&(i.hole_shape==="round"||i.hole_shape==="circle")){const e=(0,ZE.cylinder)({center:[i.x,i.y,0],radius:i.hole_diameter/2+D_,height:this.ctx.pcbThickness*1.5});this.boardGeom=(0,aQ.subtract)(this.boardGeom,e)}}processPad(i){const e=i.layer==="bottom"?-1:1,t=e*this.ctx.pcbThickness/2+e*D_*2;if(i.shape==="rect"){const n=(0,aN.colorize)(Px.copper,(0,ZE.cuboid)({center:[i.x,i.y,t],size:[i.width,i.height,D_]}));this.padGeoms.push(n)}else if(i.shape==="rotated_rect"){let n=(0,ZE.cuboid)({center:[0,0,0],size:[i.width,i.height,D_]});const r=i.ccw_rotation*Math.PI/180;n=(0,rQ.rotateZ)(r,n);const a=(0,rQ.translate)([i.x,i.y,t],n),o=(0,aN.colorize)(Px.copper,a);this.padGeoms.push(o)}else if(i.shape==="circle"){const n=(0,aN.colorize)(Px.copper,(0,ZE.cylinder)({center:[i.x,i.y,t],radius:i.radius,height:D_}));this.padGeoms.push(n)}}processTrace(i){const{route:e}=i;if(e.length<2)return;let t=[],n=null,r=.1;const a=()=>{if(t.length>=2&&n){const o=n==="bottom"?-1:1,s=o*this.ctx.pcbThickness/2+o*D_,l=(0,ZE.line)(t),c=(0,Y$e.expand)({delta:r/2,corners:"round"},l);let u=(0,rQ.translate)([0,0,s],(0,kV.extrudeLinear)({height:D_},c));const f=t[0],h=t[t.length-1],p=this.getHoleToCut(f[0],f[1]);if(p){const I=(0,ZE.cylinder)({center:[f[0],f[1],s+D_/2],radius:p.diameter/2+D_,height:D_});u=(0,aQ.subtract)(u,I)}const y=this.getHoleToCut(h[0],h[1]);if(y){const I=(0,ZE.cylinder)({center:[h[0],h[1],s+D_/2],radius:y.diameter/2+D_,height:D_});u=(0,aQ.subtract)(u,I)}const _=G$e[this.board.material]??Px.fr4GreenSolderWithMask;u=(0,aN.colorize)(_,u),this.traceGeoms.push(u)}t=[],n=null};for(let o=0;o<e.length;o++){const s=e[o];if(s.route_type==="wire")n===null?(n=s.layer,r=s.width,t.push([s.x,s.y])):s.layer===n?t.push([s.x,s.y]):(t.push([s.x,s.y]),a(),n=s.layer,r=s.width,e[o-1]?t.push([s.x,s.y]):t.push([s.x,s.y]));else if(s.route_type==="via"){t.push([s.x,s.y]),a();const l=e[o+1];l&&l.route_type==="wire"&&(n=l.layer,r=l.width,t.push([s.x,s.y]))}}a()}processVia(i){this.processPlatedHole({x:i.x,y:i.y,hole_diameter:i.hole_diameter,outer_diameter:i.outer_diameter,shape:"circle",layers:["top","bottom"],type:"pcb_plated_hole",pcb_plated_hole_id:`via_${i.pcb_via_id}`},{dontCutBoard:!0})}processSilkscreenText(i){const{textOutlines:e,xOffset:t,yOffset:n}=Ppn(i);for(const r of e){const a=r.map(f=>[f[0]+t+i.anchor_position.x,f[1]+n+i.anchor_position.y]),o=(0,ZE.line)(a),s=i.font_size||.25,l=Math.min(Math.max(.01,s*.1),s*.05),c=(0,Y$e.expand)({delta:l,corners:"round"},o);let u;i.layer==="bottom"?u=(0,rQ.translate)([0,0,-this.ctx.pcbThickness/2-D_],(0,kV.extrudeLinear)({height:.012},c)):u=(0,rQ.translate)([0,0,this.ctx.pcbThickness/2+D_],(0,kV.extrudeLinear)({height:.012},c)),u=(0,aN.colorize)([1,1,1],u),this.silkscreenTextGeoms.push(u)}}processSilkscreenPath(i){const e=Opn(i,this.ctx);e&&this.silkscreenPathGeoms.push(e)}finalize(){if(!this.boardGeom)return;const i=Fge[this.board.material]??Px.fr4Green;this.boardGeom=(0,aN.colorize)(i,this.boardGeom),this.finalGeoms=[this.boardGeom,...this.platedHoleGeoms,...this.padGeoms,...this.traceGeoms,...this.viaGeoms,...this.silkscreenTextGeoms,...this.silkscreenPathGeoms],this.onCompleteCallback&&this.onCompleteCallback(this.finalGeoms)}getGeoms(){return this.finalGeoms}},Hpn=i=>{const[e,t]=pt.useState(null),n=pt.useRef(!1);return pt.useEffect(()=>{let r=!1;if(!i){t(null);return}if(!i.some(l=>l.type==="pcb_board")){t(null);return}const a=Qpn(i);t(a);const o=new zpn(i,l=>{});return(async()=>{if(!n.current){n.current=!0;try{let l=!1;for(;!l&&!r;)l=o.step(1),l||await new Promise(c=>setTimeout(c,0));r||t(o.getGeoms())}catch(l){console.error("Error during board geometry building:",l)}finally{n.current=!1}}})(),()=>{r=!0}},[i]),e},X$e=({error:i,cad_component:e})=>{const[t,n]=pt.useState(!1),[r,a]=pt.useState(null),o=pt.useCallback(c=>{c!=null&&c.mousePosition?(n(!0),a(c.mousePosition)):(n(!1),a(null))},[]),s=pt.useCallback(()=>{n(!1),a(null)},[]);let l=[0,0,0];return e!=null&&e.position&&(l=[e.position.x,e.position.y,e.position.z],l=l.map(c=>Number.isNaN(c)?0:c)),We.jsxs(We.Fragment,{children:[We.jsx(NV,{isHovered:t,onHover:o,onUnhover:s,position:l,children:We.jsxs("group",{position:l,children:[We.jsxs("mesh",{renderOrder:-99999,rotation:[Math.PI/4,Math.PI/4,0],ref:c=>{c&&(c.renderOrder=999999)},children:[We.jsx("boxGeometry",{args:[.5,.5,.5]}),We.jsx("meshStandardMaterial",{depthTest:!1,transparent:!0,color:"red",opacity:.5})]}),We.jsxs(eQ,{scale:[.1,.1,.1],color:"red",anchorX:"center",anchorY:"middle",depthOffset:-99999,children:[i.toString().slice(0,50),"..."]})]})}),t&&r?We.jsx(CZe,{position:r,style:{fontFamily:"sans-serif",transform:"translate3d(1rem, 1rem, 0)",backgroundColor:"white",padding:"6px",borderRadius:"4px",color:"red",pointerEvents:"none",userSelect:"none",WebkitUserSelect:"none",MozUserSelect:"none",msUserSelect:"none"},children:i.toString()}):null]})};function Ypn({stlUrl:i,mtlUrl:e,color:t,opacity:n=1}){const r=G0e(ipn,i),a=pt.useRef();return We.jsxs("mesh",{ref:a,children:[We.jsx("primitive",{object:r,attach:"geometry"}),We.jsx("meshStandardMaterial",{color:t,transparent:n!==1,opacity:n})]})}var Z$e=class extends Qh.Component{constructor(i){super(i),this.state={hasError:!1,error:null}}static getDerivedStateFromError(i){return{hasError:!0,error:i}}render(){return this.state.hasError&&this.state.error?this.props.fallback({error:this.state.error}):this.props.children}},Vpn=pt.forwardRef(({soup:i,circuitJson:e,children:t,autoRotateDisabled:n,clickToInteractEnabled:r},a)=>{const o=F$e(t),s=pt.useMemo(()=>i??e??o,[i,e,o]),l=Hpn(s),c=pt.useMemo(()=>{if(!s)return[5,5,5];try{const p=O1(s).pcb_board.list()[0];if(!p)return[5,5,5];const{width:y,height:_}=p;if(!y&&!_)return[5,5,5];const I=5,C=Math.max(y,I),b=Math.max(_,I),w=Math.max(C,b);return[w/2,w/2,w]}catch(p){return console.error(p),[5,5,5]}},[s]),u=pt.useMemo(()=>{if(s)try{const p=O1(s).pcb_board.list()[0];return p?{width:p.width??0,height:p.height??0}:void 0}catch(p){console.error(p);return}},[s]),{stls:f}=xpn(l),h=O1(s).cad_component.list();return We.jsxs(L$e,{ref:a,autoRotateDisabled:n,initialCameraPosition:c,clickToInteractEnabled:r,boardDimensions:u,children:[f.map(({stlUrl:p,color:y},_)=>We.jsx(Ypn,{stlUrl:p,color:y,opacity:_===0?.95:1},p)),h.map(p=>We.jsx(Z$e,{fallback:({error:y})=>We.jsx(X$e,{cad_component:p,error:y}),children:We.jsx(U$e,{cad_component:p,circuitJson:s},p.cad_component_id)},p.cad_component_id))]})});function X7(i){const e=new Eg;if(e.setAttribute("position",new yA(i.vertProperties,3)),e.setIndex(new Dz(i.triVerts,1)),i.runIndex&&i.runIndex.length>1&&i.runOriginalID)for(let t=0;t<i.runIndex.length-1;t++){const n=i.runIndex[t],r=i.runIndex[t+1]-n;e.addGroup(n,r,0)}else e.addGroup(0,i.triVerts.length,0);return e}function W$e(i){return i&&i.route_type==="wire"&&typeof i.layer=="string"&&typeof i.width=="number"}function $$e({layer:i,circuitJson:e,boardData:t,traceColor:n,traceTextureResolution:r}){const a=O1(e).pcb_trace.list(),o=O1(e).pcb_via.list(),s=O1(e).pcb_plated_hole.list(),l=a.filter(y=>y.route.some(_=>W$e(_)&&_.layer===i));if(l.length===0)return null;const c=document.createElement("canvas"),u=Math.floor(t.width*r),f=Math.floor(t.height*r);c.width=u,c.height=f;const h=c.getContext("2d");if(!h)return null;i==="bottom"&&(h.translate(0,f),h.scale(1,-1)),l.forEach(y=>{let _=!0;h.beginPath(),h.strokeStyle=n,h.lineCap="round",h.lineJoin="round";let I=0;for(const C of y.route){if(!W$e(C)||C.layer!==i){_||h.stroke(),_=!0;continue}const b=C.x,w=C.y;I=C.width*r,h.lineWidth=I;const N=(b-t.center.x+t.width/2)*r,V=(-(w-t.center.y)+t.height/2)*r;_?(h.moveTo(N,V),_=!1):h.lineTo(N,V)}_||h.stroke()}),h.globalCompositeOperation="destination-out",h.fillStyle="black",o.forEach(y=>{const _=(y.x-t.center.x+t.width/2)*r,I=(-(y.y-t.center.y)+t.height/2)*r,C=y.outer_diameter/2*r;h.beginPath(),h.arc(_,I,C,0,2*Math.PI,!1),h.fill()}),s.forEach(y=>{if(y.layers.includes(i)&&y.shape==="circle"){const _=(y.x-t.center.x+t.width/2)*r,I=(-(y.y-t.center.y)+t.height/2)*r,C=y.outer_diameter/2*r;h.beginPath(),h.arc(_,I,C,0,2*Math.PI,!1),h.fill()}}),h.globalCompositeOperation="source-over";const p=new eoe(c);return p.generateMipmaps=!0,p.minFilter=e2,p.magFilter=i9,p.anisotropy=16,p.needsUpdate=!0,p}var jpn=KC(Bge());function eet({layer:i,circuitJson:e,boardData:t,silkscreenColor:n="rgb(255,255,255)",traceTextureResolution:r}){const a=O1(e).pcb_silkscreen_text.list(),o=O1(e).pcb_silkscreen_path.list(),s=a.filter(y=>y.layer===i),l=o.filter(y=>y.layer===i);if(s.length===0&&l.length===0)return null;const c=document.createElement("canvas"),u=Math.floor(t.width*r),f=Math.floor(t.height*r);c.width=u,c.height=f;const h=c.getContext("2d");if(!h)return null;i==="bottom"&&(h.translate(0,f),h.scale(1,-1)),h.strokeStyle=n,h.fillStyle=n,l.forEach(y=>{y.route.length<2||(h.beginPath(),h.lineWidth=(y.stroke_width||.1)*r,h.lineCap="round",h.lineJoin="round",y.route.forEach((_,I)=>{const C=(_.x-t.center.x+t.width/2)*r,b=(-(_.y-t.center.y)+t.height/2)*r;I===0?h.moveTo(C,b):h.lineTo(C,b)}),h.stroke())}),s.forEach(y=>{const _=y.font_size||.25,I=Math.min(Math.max(.01,_*.1),_*.05)*r;h.lineWidth=I,h.lineCap="butt",h.lineJoin="miter";const C=(0,jpn.vectorText)({height:_*.45,input:y.text}),b=[];C.forEach(re=>{re.length===29?(b.push(re.slice(0,15)),b.push(re.slice(14,29))):re.length===17?(b.push(re.slice(0,10)),b.push(re.slice(9,17))):b.push(re)});const w=b.flat(),N={minX:w.length>0?Math.min(...w.map(re=>re[0])):0,maxX:w.length>0?Math.max(...w.map(re=>re[0])):0,minY:w.length>0?Math.min(...w.map(re=>re[1])):0,maxY:w.length>0?Math.max(...w.map(re=>re[1])):0},V=(N.minX+N.maxX)/2,z=(N.minY+N.maxY)/2;let K=-V,G=-z;const q=y.anchor_alignment||"center";q.includes("left")?K=-N.minX:q.includes("right")&&(K=-N.maxX),q.includes("top")?G=-N.maxY:q.includes("bottom")&&(G=-N.minY);const Y=[];let oe=y.ccw_rotation??0;if(y.layer==="bottom"&&(Y.push(Ow(V,z),{a:-1,b:0,c:0,d:1,e:0,f:0},Ow(-V,-z)),oe=-oe),oe){const re=oe*Math.PI/180;Y.push(Ow(V,z),J$e(re),Ow(-V,-z))}const W=Y.length>0?K$e(...Y):void 0;b.forEach(re=>{h.beginPath(),re.forEach((fe,Ae)=>{let ce={x:fe[0],y:fe[1]};W&&(ce=V$e(W,ce));const xe=ce.x+K+y.anchor_position.x,me=ce.y+G+y.anchor_position.y,Re=(xe-t.center.x+t.width/2)*r,we=(-(me-t.center.y)+t.height/2)*r;Ae===0?h.moveTo(Re,we):h.lineTo(Re,we)}),h.stroke()})});const p=new eoe(c);return p.generateMipmaps=!0,p.minFilter=e2,p.magFilter=i9,p.anisotropy=16,p.needsUpdate=!0,p}function Kpn({Manifold:i,x:e,y:t,diameter:n,thickness:r,segments:a=32}){return i.cylinder(r*1.2,n/2,n/2,a,!0).translate([e,t,0])}function tet({Manifold:i,x:e,y:t,outerDiameter:n,thickness:r,zOffset:a=.001,segments:o=32}){const s=n/2+a;return i.cylinder(r*1.2,s,s,o,!0).translate([e,t,0])}function Jpn(i){return(i.shape==="circle"||i.hole_shape==="circle")&&typeof i.hole_diameter=="number"}function qpn(i,e,t,n){const r=[];return O1(e).pcb_hole.list().forEach(o=>{if(Jpn(o)){const s=Kpn({Manifold:i,x:o.x,y:o.y,diameter:o.hole_diameter,thickness:t,segments:zB});n.push(s),r.push(s)}}),{nonPlatedHoleBoardDrills:r}}var net=new td(...Px.copper);function Xpn(i,e,t,n){const r=[],a=O1(e).pcb_plated_hole.list(),o=[];return a.forEach((s,l)=>{if(s.shape==="circle"){const c=tet({Manifold:i,x:s.x,y:s.y,outerDiameter:s.outer_diameter,thickness:t,zOffset:a3,segments:zB});n.push(c),r.push(c);const u=t+2*a3;let f=i.cylinder(u,s.outer_diameter/2,s.outer_diameter/2,zB,!0);n.push(f);const h=i.cylinder(u*1.05,s.hole_diameter/2,s.hole_diameter/2,zB,!0);n.push(h);const p=f.subtract(h);n.push(p);const y=p.translate([s.x,s.y,0]);n.push(y);const _=X7(y.getMesh());o.push({key:`ph-${s.pcb_plated_hole_id||l}`,geometry:_,color:net})}else if(s.shape==="pill"){const c=s.hole_width,u=s.hole_height,f=u>c,h=f?u:c,p=f?c:u,y=.4,_=f?s.outer_height??p+y/2:s.outer_width??h+y/2,I=f?s.outer_width??h+y/2:s.outer_height??p+y/2,C=(re,fe,Ae)=>{const ce=fe/2,xe=re-fe;let me;if(xe<1e-9)me=i.cylinder(Ae,ce,ce,zB,!0);else{const Re=i.cube([Math.max(0,xe),fe,Ae],!0),we=i.cylinder(Ae,ce,ce,zB,!0).translate([-xe/2,0,0]),Te=i.cylinder(Ae,ce,ce,zB,!0).translate([xe/2,0,0]);me=i.union([Re,we,Te]),n.push(Re,we,Te)}return n.push(me),me},b=h+2*a3,w=p+2*a3,N=t*1.2;let V=C(b,w,N);if(f){const re=V.rotate([0,0,90]);n.push(re),V=re}const z=V.translate([s.x,s.y,0]);n.push(z),r.push(z);const K=t+2*a3,G=C(_,I,K),q=C(h,p,K*1.05);let Y=G.subtract(q);if(n.push(Y),f){const re=Y.rotate([0,0,90]);n.push(re),Y=re}const oe=Y.translate([s.x,s.y,0]);n.push(oe);const W=X7(oe.getMesh());o.push({key:`ph-${s.pcb_plated_hole_id||l}`,geometry:W,color:net})}}),{platedHoleBoardDrills:r,platedHoleCopperGeoms:o}}function Zpn({Manifold:i,x:e,y:t,outerDiameter:n,holeDiameter:r,thickness:a,zOffset:o=.001,segments:s=32}){const l=a+2*o;let c=i.cylinder(l,n/2,-1,s,!0);const u=i.cylinder(l*1.05,r/2,-1,s,!0);return c.subtract(u).translate([e,t,0])}var Wpn=new td(...Px.copper);function $pn(i,e,t,n){const r=[],a=O1(e).pcb_via.list(),o=[];return a.forEach((s,l)=>{if(typeof s.outer_diameter=="number"){const c=tet({Manifold:i,x:s.x,y:s.y,outerDiameter:s.outer_diameter,thickness:t,zOffset:a3,segments:zB});n.push(c),r.push(c)}if(typeof s.outer_diameter=="number"&&typeof s.hole_diameter=="number"){const c=Zpn({Manifold:i,x:s.x,y:s.y,outerDiameter:s.outer_diameter,holeDiameter:s.hole_diameter,thickness:t,zOffset:a3,segments:zB});n.push(c);const u=X7(c.getMesh());o.push({key:`via-${s.pcb_via_id||l}`,geometry:u,color:Wpn})}}),{viaBoardDrills:r,viaCopperGeoms:o}}function e0n({Manifold:i,pad:e,padBaseThickness:t}){return e.shape==="rect"?i.cube([e.width,e.height,t],!0):e.shape==="circle"&&e.radius?i.cylinder(t,e.radius,-1,32,!0):null}var t0n=new td(...Px.copper);function n0n(i,e,t,n){const r=[];return O1(e).pcb_smtpad.list().forEach((o,s)=>{const l=Spn,c=o.layer==="bottom"?-t/2-l/2-a3:t/2+l/2+a3;let u=e0n({Manifold:i,pad:o,padBaseThickness:l});if(u){n.push(u);const f=u.translate([o.x,o.y,c]);n.push(f);const h=X7(f.getMesh());r.push({key:`pad-${o.pcb_smtpad_id||s}`,geometry:h,color:t0n})}}),{smtPadGeoms:r}}var i0n=i=>{let e=0;for(let n=0;n<i.length;n++){const r=(n+1)%i.length;i[n]&&i[r]&&(e+=i[n][0]*i[r][1],e-=i[r][0]*i[n][1])}return e/2<=0};function r0n(i,e,t,n,r){let a;if(t.outline&&t.outline.length>=3){let o=t.outline.map(l=>[l.x,l.y]);i0n(o)&&(o=o.reverse());const s=e.ofPolygons([o]);r.push(s),a=i.extrude(s,n,void 0,void 0,void 0,!0),r.push(a)}else t.outline&&t.outline.length>0&&console.warn("Board outline has fewer than 3 points, falling back to rectangular board."),a=i.cube([t.width,t.height,n],!0),r.push(a),a=a.translate([t.center.x,t.center.y,0]),r.push(a);return a}var a0n=i=>{let e=0;for(let n=0;n<i.length;n++){const r=(n+1)%i.length;i[n]&&i[r]&&(e+=i[n][0]*i[r][1],e-=i[r][0]*i[n][1])}return e/2<=0};function o0n(i,e,t,n,r){const a=[],o=O1(t).pcb_cutout.list();for(const s of o){let l;const c=n*1.5;switch(s.shape){case"rect":if(l=i.cube([s.width,s.height,c],!0),r.push(l),s.rotation){s.rotation*Math.PI/180;const h=l.rotate([0,0,s.rotation]);r.push(h),l=h}l=l.translate([s.center.x,s.center.y,0]),r.push(l);break;case"circle":l=i.cylinder(c,s.radius,-1,zB,!0),r.push(l),l=l.translate([s.center.x,s.center.y,0]),r.push(l);break;case"polygon":if(s.points.length<3){console.warn(`PCB Cutout [${s.pcb_cutout_id}] polygon has fewer than 3 points, skipping.`);continue}let u=s.points.map(h=>[h.x,h.y]);a0n(u)&&(u=u.reverse());const f=e.ofPolygons([u]);r.push(f),l=i.extrude(f,c,0,0,[1,1],!0),r.push(l);break;default:console.warn(`Unsupported cutout shape: ${s.shape} for cutout ${s.pcb_cutout_id}`);continue}l&&a.push(l)}return{cutoutOps:a}}var s0n=(i,e)=>{const[t,n]=pt.useState(null),[r,a]=pt.useState(null),[o,s]=pt.useState(null),[l,c]=pt.useState(null),[u,f]=pt.useState(!0),h=pt.useRef([]),p=pt.useMemo(()=>{const y=O1(e).pcb_board.list();return y.length===0?null:y[0]},[e]);return pt.useEffect(()=>{if(!i||!p){n(null),a(null),s(null),O1(e).pcb_board.list().length===0&&c("No pcb_board found in circuitJson."),f(!1);return}if((p.width===0||!p.width)&&(p.height===0||!p.height)&&(!p.outline||p.outline.length<3)){n({platedHoles:[],smtPads:[],vias:[]}),a({}),s(p.thickness??0),f(!1);return}f(!0),c(null);const y=i.Manifold,_=i.CrossSection;h.current.forEach(w=>w.delete()),h.current=[];let I=null;const C={},b={};try{const w=p.thickness||1.6;s(w);let N=r0n(y,_,p,w,h.current);const V=[],{nonPlatedHoleBoardDrills:z}=qpn(y,e,w,h.current);V.push(...z);const{platedHoleBoardDrills:K,platedHoleCopperGeoms:G}=Xpn(y,e,w,h.current);V.push(...K),C.platedHoles=G;const{viaBoardDrills:q,viaCopperGeoms:Y}=$pn(y,e,w,h.current);if(V.push(...q),C.vias=Y,V.length>0){const ce=y.union(V);h.current.push(ce);const xe=N.subtract(ce);h.current.push(xe),N=xe}const{cutoutOps:oe}=o0n(y,_,e,w,h.current);if(oe.length>0){const ce=y.union(oe);h.current.push(ce);const xe=N.subtract(ce);h.current.push(xe),N=xe}if(I=N,I){const ce=I.getMesh(),xe=X7(ce),me=Fge[p.material]??Px.fr4Green;C.board={geometry:xe,color:new td(me[0],me[1],me[2])}}const{smtPadGeoms:W}=n0n(y,e,w,h.current);C.smtPads=W,n(C);const re=G$e[p.material]??Px.fr4GreenSolderWithMask,fe=`rgb(${Math.round(re[0]*255)}, ${Math.round(re[1]*255)}, ${Math.round(re[2]*255)})`;b.topTrace=$$e({layer:"top",circuitJson:e,boardData:p,traceColor:fe,traceTextureResolution:TV}),b.bottomTrace=$$e({layer:"bottom",circuitJson:e,boardData:p,traceColor:fe,traceTextureResolution:TV});const Ae="rgb(255,255,255)";b.topSilkscreen=eet({layer:"top",circuitJson:e,boardData:p,silkscreenColor:Ae,traceTextureResolution:TV}),b.bottomSilkscreen=eet({layer:"bottom",circuitJson:e,boardData:p,silkscreenColor:Ae,traceTextureResolution:TV}),a(b)}catch(w){console.error("Error processing geometry with Manifold in hook:",w),c(w.message||"An unknown error occurred while processing geometry in hook."),n(null),a(null)}finally{f(!1)}return()=>{h.current.forEach(w=>w.delete()),h.current=[]}},[i,e,p]),{geoms:t,textures:r,pcbThickness:o,error:l,isLoading:u,boardData:p}};function l0n(i){const e=[];if(!i)return e;if(i.board&&i.board.geometry){const n=new FI(i.board.geometry,new CD({color:i.board.color,side:YE,flatShading:!0}));n.name="board-geom",e.push(n)}const t=n=>{n&&n.forEach(r=>{const a=new FI(r.geometry,new CD({color:r.color,side:YE,flatShading:!0}));a.name=r.key,e.push(a)})};return t(i.platedHoles),t(i.smtPads),t(i.vias),e}function c0n(i,e,t){const n=[];if(!i||!e||t===null)return n;const r=(c,u,f,h)=>{if(!c)return null;const p=new wB(e.width,e.height),y=new SB({map:c,transparent:!0,side:YE,depthWrite:!1}),_=new FI(p,y);return _.position.set(e.center.x,e.center.y,u),f&&_.rotation.set(Math.PI,0,0),_.name=`${f?"bottom":"top"}-${h}-texture-plane`,_},a=r(i.topTrace,t/2+.015,!1,"trace");a&&n.push(a);const o=r(i.topSilkscreen,t/2+.017,!1,"silkscreen");o&&n.push(o);const s=r(i.bottomTrace,-t/2-.015,!0,"trace");s&&n.push(s);const l=r(i.bottomSilkscreen,-t/2-.017,!0,"silkscreen");return l&&n.push(l),n}var u0n="https://cdn.jsdelivr.net/npm/manifold-3d@3.1.1",d0n=({circuitJson:i,autoRotateDisabled:e,clickToInteractEnabled:t,children:n})=>{const r=F$e(n),a=pt.useMemo(()=>i??r,[i,r]),[o,s]=pt.useState(null),[l,c]=pt.useState(null);pt.useEffect(()=>{(async()=>{try{const z=`${u0n}/manifold.wasm`,G=await cun({locateFile:(q,Y)=>q==="manifold.wasm"?z:Y+q});G.setup(),s(G)}catch(z){console.error("Failed to load Manifold from CDN:",z),c(`Failed to load Manifold module: ${z instanceof Error?z.message:"Unknown error"}`)}})()},[]);const{geoms:u,textures:f,pcbThickness:h,error:p,isLoading:y,boardData:_}=s0n(o,a),I=pt.useMemo(()=>l0n(u),[u]),C=pt.useMemo(()=>c0n(f,_,h),[f,_,h]),b=pt.useMemo(()=>O1(a).cad_component.list(),[a]),w=pt.useMemo(()=>{if(!_)return;const{width:V=0,height:z=0}=_;return{width:V,height:z}},[_]),N=pt.useMemo(()=>{if(!_)return[5,5,5];const{width:V=0,height:z=0}=_,K=Math.max(V,1),G=Math.max(z,1),q=Math.max(K,G,5);return[q*.75,q*.75,q*.75]},[_]);return l?We.jsxs("div",{style:{color:"red",padding:"1em",border:"1px solid red",margin:"1em"},children:["Error: ",l]}):o?p?We.jsxs("div",{style:{color:"red",padding:"1em",border:"1px solid red",margin:"1em"},children:["Error: ",p]}):y?We.jsx("div",{style:{padding:"1em"},children:"Processing board geometry..."}):We.jsxs(L$e,{initialCameraPosition:N,autoRotateDisabled:e,clickToInteractEnabled:t,boardDimensions:w,children:[I.map((V,z)=>We.jsx("primitive",{object:V},`${V.name}-${z}`)),C.map((V,z)=>We.jsx("primitive",{object:V},`${V.name}-${z}`)),b.map(V=>We.jsx(Z$e,{fallback:({error:z})=>We.jsx(X$e,{cad_component:V,error:z}),children:We.jsx(U$e,{cad_component:V,circuitJson:a})},V.cad_component_id))]}):We.jsx("div",{style:{padding:"1em"},children:"Loading Manifold module..."})},f0n=d0n,A0n=({containerRef:i})=>{const[e,t]=pt.useState(!1),[n,r]=pt.useState({x:0,y:0}),a=pt.useRef(null),o=pt.useRef(null),s=pt.useCallback(p=>{p.preventDefault();const y=typeof p.clientX=="number"?p.clientX:0,_=typeof p.clientY=="number"?p.clientY:0;if(!o.current)return;const{x:I,y:C}=o.current,b=Math.abs(y-I),w=Math.abs(_-C),N=10;if(b>N||w>N){o.current=null;return}r({x:y,y:_}),t(!0),o.current=null},[r,t]),l=pt.useCallback(p=>{if(p.touches.length===1){const y=p.touches[0];y?o.current={x:y.clientX,y:y.clientY}:o.current=null}else o.current=null},[]),c=pt.useCallback(p=>{if(!o.current||p.touches.length!==1)return;const y=p.touches[0];if(y){const _=Math.abs(y.clientX-o.current.x),I=Math.abs(y.clientY-o.current.y),C=10;(_>C||I>C)&&(o.current=null)}else o.current=null},[]),u=pt.useCallback(()=>{setTimeout(()=>{o.current&&(o.current=null)},0)},[]),f=pt.useCallback(p=>{const y=p.target;a.current&&!a.current.contains(y)&&t(!1)},[]);return pt.useEffect(()=>{if(e)return document.addEventListener("mousedown",f),()=>document.removeEventListener("mousedown",f)},[e,f]),{menuVisible:e,menuPos:n,menuRef:a,contextMenuEventHandlers:{onMouseDown:p=>{p.button===2?o.current={x:p.clientX,y:p.clientY}:o.current=null},onContextMenu:s,onTouchStart:l,onTouchMove:c,onTouchEnd:u},setMenuVisible:t}},h0n=i=>{const[e,t]=pt.useState("jscad"),n=pt.useRef(null),{menuVisible:r,menuPos:a,menuRef:o,contextMenuEventHandlers:s,setMenuVisible:l}=A0n({containerRef:n}),c=f=>{t(f),l(!1)};pt.useEffect(()=>{const f=window.localStorage.getItem("cadViewerEngine");(f==="jscad"||f==="manifold")&&t(f)},[]),pt.useEffect(()=>{window.localStorage.setItem("cadViewerEngine",e)},[e]);const u=i.circuitJson?JSON.stringify(i.circuitJson):void 0;return We.jsxs("div",{ref:n,style:{width:"100%",height:"100%",position:"relative"},...s,children:[e==="jscad"?We.jsx(Vpn,{...i}):We.jsx(f0n,{...i}),We.jsxs("div",{style:{position:"absolute",right:8,top:8,background:"#222",color:"#fff",padding:"2px 8px",borderRadius:4,fontSize:12,opacity:.7,userSelect:"none"},children:["Engine: ",We.jsx("b",{children:e==="jscad"?"JSCAD":"Manifold"})]}),r&&We.jsx("div",{ref:o,style:{position:"fixed",top:a.y,left:a.x,background:"#23272f",color:"#f5f6fa",borderRadius:6,boxShadow:"0 6px 24px 0 rgba(0,0,0,0.18)",zIndex:1e3,minWidth:200,border:"1px solid #353945",padding:0,fontSize:15,fontWeight:500,transition:"opacity 0.1s"},children:We.jsxs("div",{style:{padding:"12px 18px",cursor:"pointer",display:"flex",alignItems:"center",gap:10,color:"#f5f6fa",fontWeight:500,borderRadius:6,transition:"background 0.1s"},onClick:()=>c(e==="jscad"?"manifold":"jscad"),onMouseOver:f=>f.currentTarget.style.background="#2d313a",onMouseOut:f=>f.currentTarget.style.background="transparent",children:["Switch to ",e==="jscad"?"Manifold":"JSCAD"," Engine",We.jsx("span",{style:{fontSize:12,marginLeft:"auto",opacity:.5,fontWeight:400},children:e==="jscad"?"experimental":"default"})]})})]},u)},p0n=KC($hn());KC(D$e()),(0,p0n.default)("tscircuit:3d-viewer:convert-circuit-json-to-3d-svg");const g0n=({error:i})=>We.jsx("div",{"data-testid":"error-container",className:"rf-error-container rf-mt-4 rf-bg-red-50 rf-rounded-md rf-border rf-border-red-200",children:We.jsxs("div",{className:"rf-p-4",children:[We.jsx("h2",{className:"rf-text-lg rf-font-semibold rf-text-red-800 rf-mb-3",children:"Error Loading 3D Viewer"}),We.jsx("p",{className:"rf-text-xs rf-font-mono rf-whitespace-pre-wrap rf-text-red-700",children:i.message}),We.jsx("details",{style:{whiteSpace:"pre-wrap"},className:"rf-text-xs rf-font-mono rf-text-red-600 rf-mt-2",children:i.stack})]})}),m0n=pt.createContext(null),Oge={didCatch:!1,error:null};class oN extends pt.Component{constructor(e){super(e),this.resetErrorBoundary=this.resetErrorBoundary.bind(this),this.state=Oge}static getDerivedStateFromError(e){return{didCatch:!0,error:e}}resetErrorBoundary(){const{error:e}=this.state;if(e!==null){for(var t,n,r=arguments.length,a=new Array(r),o=0;o<r;o++)a[o]=arguments[o];(t=(n=this.props).onReset)===null||t===void 0||t.call(n,{args:a,reason:"imperative-api"}),this.setState(Oge)}}componentDidCatch(e,t){var n,r;(n=(r=this.props).onError)===null||n===void 0||n.call(r,e,t)}componentDidUpdate(e,t){const{didCatch:n}=this.state,{resetKeys:r}=this.props;if(n&&t.error!==null&&y0n(e.resetKeys,r)){var a,o;(a=(o=this.props).onReset)===null||a===void 0||a.call(o,{next:r,prev:e.resetKeys,reason:"keys"}),this.setState(Oge)}}render(){const{children:e,fallbackRender:t,FallbackComponent:n,fallback:r}=this.props,{didCatch:a,error:o}=this.state;let s=e;if(a){const l={error:o,resetErrorBoundary:this.resetErrorBoundary};if(typeof t=="function")s=t(l);else if(n)s=pt.createElement(n,l);else if(r!==void 0)s=r;else throw o}return pt.createElement(m0n.Provider,{value:{didCatch:a,error:o,resetErrorBoundary:this.resetErrorBoundary}},s)}}function y0n(){let i=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[];return i.length!==e.length||i.some((t,n)=>!Object.is(t,e[n]))}function v0n(i,e){if(i==null)return{};var t={},n=Object.keys(i),r,a;for(a=0;a<n.length;a++)r=n[a],!(e.indexOf(r)>=0)&&(t[r]=i[r]);return t}var _0n=["color"],iet=pt.forwardRef(function(i,e){var t=i.color,n=t===void 0?"currentColor":t,r=v0n(i,_0n);return pt.createElement("svg",Object.assign({width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg"},r,{ref:e}),pt.createElement("path",{d:"M7.49933 0.25C3.49635 0.25 0.25 3.49593 0.25 7.50024C0.25 10.703 2.32715 13.4206 5.2081 14.3797C5.57084 14.446 5.70302 14.2222 5.70302 14.0299C5.70302 13.8576 5.69679 13.4019 5.69323 12.797C3.67661 13.235 3.25112 11.825 3.25112 11.825C2.92132 10.9874 2.44599 10.7644 2.44599 10.7644C1.78773 10.3149 2.49584 10.3238 2.49584 10.3238C3.22353 10.375 3.60629 11.0711 3.60629 11.0711C4.25298 12.1788 5.30335 11.8588 5.71638 11.6732C5.78225 11.205 5.96962 10.8854 6.17658 10.7043C4.56675 10.5209 2.87415 9.89918 2.87415 7.12104C2.87415 6.32925 3.15677 5.68257 3.62053 5.17563C3.54576 4.99226 3.29697 4.25521 3.69174 3.25691C3.69174 3.25691 4.30015 3.06196 5.68522 3.99973C6.26337 3.83906 6.8838 3.75895 7.50022 3.75583C8.1162 3.75895 8.73619 3.83906 9.31523 3.99973C10.6994 3.06196 11.3069 3.25691 11.3069 3.25691C11.7026 4.25521 11.4538 4.99226 11.3795 5.17563C11.8441 5.68257 12.1245 6.32925 12.1245 7.12104C12.1245 9.9063 10.4292 10.5192 8.81452 10.6985C9.07444 10.9224 9.30633 11.3648 9.30633 12.0413C9.30633 13.0102 9.29742 13.7922 9.29742 14.0299C9.29742 14.2239 9.42828 14.4496 9.79591 14.3788C12.6746 13.4179 14.75 10.7025 14.75 7.50024C14.75 3.49593 11.5036 0.25 7.49933 0.25Z",fill:n,fillRule:"evenodd",clipRule:"evenodd"}))});/**
13088
13088
  * @license lucide-react v0.488.0 - ISC
13089
13089
  *
13090
13090
  * This source code is licensed under the ISC license.
@@ -13746,7 +13746,7 @@ $1`).replace(/>(\s*)(?=<!--\s*\/)/g,"> ")}return Vye}SCn();function vrt(i,e,t,n=
13746
13746
  &:hover {
13747
13747
  background-color: rgba(255, 255, 255, 0.1);
13748
13748
  }
13749
- `,onClick:n=>{n.stopPropagation(),t()},children:[We.jsx("input",{type:"checkbox",checked:e}),We.jsx("span",{style:{color:"#eee"},children:i})]}),$En=({children:i,elements:e})=>{const[t,n]=lx(G=>[G.is_mouse_over_container,G.setIsMouseOverContainer]),[r,a]=pt.useState(!1),[o,s]=pt.useState(!1),[l,c]=pt.useState(!1),[u,f]=lx(G=>[G.selected_layer,G.selectLayer]),[h,p,y,_,I,C]=lx(G=>[G.in_move_footprint_mode,G.in_draw_trace_mode,G.is_showing_rats_nest,G.is_showing_multiple_traces_length,G.is_showing_autorouting,G.is_showing_drc_errors]),b=lx(G=>G.setEditMode),w=lx(G=>G.setIsShowingRatsNest),N=lx(G=>G.setIsShowingMultipleTracesLength),V=lx(G=>G.setIsShowingAutorouting),z=lx(G=>G.setIsShowingDrcErrors);$w("1",()=>f("top")),$w("2",()=>f("bottom")),$w("3",()=>f("inner1")),$w("4",()=>f("inner2")),$w("5",()=>f("inner3")),$w("6",()=>f("inner4")),$w("7",()=>f("inner5")),$w("8",()=>f("inner6"));const K=(e==null?void 0:e.filter(G=>G.type.includes("error")).length)??0;return We.jsxs("div",{style:{position:"relative"},onMouseEnter:()=>{n(!0)},onMouseLeave:G=>{n(!1),s(!1)},children:[i,We.jsxs("div",{style:{position:"absolute",bottom:4,right:8,pointerEvents:"none",color:"white",fontSize:11,opacity:t?.5:0,transition:"opacity 1s",transitionDelay:"2s",fontFamily:"sans-serif"},children:["@tscircuit/pcb-viewer@",ZEn.version]}),We.jsxs("div",{style:{position:"absolute",opacity:t?1:0,top:16,left:16,transition:t?"opacity 100ms linear":"opacity 1s linear",zIndex:eb.toolbarOverlay,color:"red",display:"flex",fontSize:12,height:100,fontFamily:"sans-serif"},children:[We.jsxs(QN,{onClick:()=>{s(!o)},onMouseLeave:()=>{o&&s(!1)},children:[We.jsxs("div",{children:["layer:"," ",We.jsx("span",{style:{marginLeft:2,fontWeight:500,color:MN[u]},children:u})]}),o&&We.jsx("div",{style:{marginTop:4,minWidth:120},children:Sve.map(G=>G.replace(/-/g,"")).map(G=>We.jsx(WEn,{name:G,selected:G===u,onClick:()=>{f(G.replace(/-/,""))}},G))})]}),We.jsxs(QN,{style:K>0?{color:"red"}:{},onClick:()=>c(!l),onMouseLeave:()=>c(!1),children:[We.jsxs("div",{children:[K," errors"]}),l&&We.jsx("div",{style:{display:"grid",gridTemplateColumns:"100px 300px"},children:e==null?void 0:e.filter(G=>G.type.includes("error")).map((G,q)=>We.jsxs(pt.Fragment,{children:[We.jsx("div",{children:G.error_type}),We.jsx("div",{children:G.message})]},q))})]}),We.jsx(QN,{style:{},onClick:()=>{b(p?"off":"draw_trace")},children:We.jsxs("div",{children:[p?"✖ ":"","Edit Traces"]})}),We.jsx(QN,{style:{},onClick:()=>{b(h?"off":"move_footprint")},children:We.jsxs("div",{children:[h?"✖ ":"","Move Components"]})}),We.jsx(QN,{style:{},onClick:()=>{w(!y)},children:We.jsxs("div",{children:[y?"✖ ":"","Rats Nest"]})}),We.jsx(QN,{onClick:()=>{a(!r)},children:We.jsxs("div",{children:[We.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"4px"},children:["View"," ",We.jsx("span",{style:{fontSize:"8px",transform:r?"rotate(180deg)":"rotate(0)",transition:"transform 0.1s ease",display:"inline-block"},children:"▼"})]}),r&&We.jsxs("div",{style:{marginTop:4,minWidth:120},children:[We.jsx(Dve,{label:"Show All Trace Lengths",checked:_,onClick:()=>{N(!_)}}),We.jsx(Dve,{label:"Show Autorouting Animation",checked:I,onClick:()=>{V(!I)}}),We.jsx(Dve,{label:"Show DRC Errors",checked:C,onClick:()=>{z(!C)}})]})]})})]})]})},ebn=i=>{const{transform:e,elements:t}=i,[n,r]=pt.useMemo(()=>{const c=i.elements.flatMap(f=>dEn(f,i.elements)),u=x5(i.elements);return[c,u]},[i.elements]),[a,o]=pt.useState({drawingObjectIdsWithMouseOver:new Set,primitiveIdsInMousedOverNet:[]}),s=pt.useMemo(()=>cEn({primitivesWithoutInteractionMetadata:n,drawingObjectIdsWithMouseOver:a.drawingObjectIdsWithMouseOver,primitiveIdsInMousedOverNet:a.primitiveIdsInMousedOverNet}),[n,a]),l=pt.useCallback(c=>{var h,p;const u=[];for(const y of c)if(y._element){const _=r.getNetConnectedToId("pcb_port_id"in y._element?(h=y._element)==null?void 0:h.pcb_port_id:"pcb_trace_id"in y._element?(p=y._element)==null?void 0:p.pcb_trace_id:"");u.push(...r.getIdsConnectedToNet(_))}const f=new Set(c.map(y=>y._pcb_drawing_object_id));o({drawingObjectIdsWithMouseOver:f,primitiveIdsInMousedOverNet:u})},[r]);return We.jsx(qEn,{elements:t,transform:e,primitives:n,onMouseHoverOverPrimitives:l,children:We.jsx(DEn,{disabled:!i.allowEditing,transform:e,soup:t,cancelPanDrag:i.cancelPanDrag,onCreateEditEvent:i.onCreateEditEvent,onModifyEditEvent:i.onModifyEditEvent,children:We.jsx(kEn,{disabled:!i.allowEditing,transform:e,soup:t,cancelPanDrag:i.cancelPanDrag,onCreateEditEvent:i.onCreateEditEvent,onModifyEditEvent:i.onModifyEditEvent,children:We.jsx(QEn,{transform:e,focusOnHover:i.focusOnHover,children:We.jsx($En,{elements:t,children:We.jsx(FEn,{transform:e,elements:t,children:We.jsx(XEn,{transform:e,soup:t,children:We.jsx(wEn,{transform:e,debugGraphics:i.debugGraphics,children:We.jsx(MEn,{transform:e,elements:t,children:We.jsx(BEn,{transform:e,primitives:s,width:i.width,height:i.height,grid:i.grid})})})})})})})})})})},tbn=Gh(P0(400,300),vx(40,-40)),nbn=({circuitJson:i,debugGraphics:e,height:t=600,initialState:n,allowEditing:r=!0,editEvents:a,onEditEventsChanged:o,focusOnHover:s=!1,clickToInteractEnabled:l=!1})=>{const[c,u]=pt.useState(!l),[f,h]=Qve(),[p,y]=pt.useState(tbn),{ref:_,setTransform:I,cancelDrag:C}=lEn({transform:p,onSetTransform:y,enabled:c});let[b,w]=pt.useState([]);b=a??b;const N=pt.useRef(!1),V=pt.useRef(null),z=`${(i==null?void 0:i.length)||0}_${(i==null?void 0:i.editCount)||0}`,K=()=>{const W=(h==null?void 0:h.width)>0?h:{width:500,height:500},{center:re,width:fe,height:Ae}=q.some(me=>me.type.startsWith("pcb_"))?Wxn(q.filter(me=>me.type.startsWith("pcb_"))):{center:{x:0,y:0},width:.001,height:.001},ce=Math.min((W.width??0)/fe,(W.height??0)/Ae,100)*.75,xe=Gh(P0((W.width??0)/2,(W.height??0)/2),vx(ce,-ce,0,0),P0(-re.x,-re.y));I(xe)};pt.useEffect(()=>{h!=null&&h.width&&i&&i.length!==0&&(N.current||(K(),N.current=!0))},[i,h]);const G=pt.useMemo(()=>(i==null?void 0:i.filter(W=>W.type.startsWith("pcb_")||W.type.startsWith("source_")))??[],[z]),q=pt.useMemo(()=>dIn({circuitJson:G,editEvents:b}),[G,b]),Y=W=>{w([...b,W]),o==null||o([...b,W])},oe=W=>{const re=b.map(fe=>fe.edit_event_id===W.edit_event_id?{...fe,...W}:fe);w(re),o==null||o(re)};return We.jsxs("div",{ref:_,style:{position:"relative"},children:[We.jsx("div",{ref:f,children:We.jsxs(eEn,{initialState:n,children:[We.jsx(ebn,{transform:p,height:t,width:h.width,allowEditing:r,focusOnHover:s,cancelPanDrag:C,onCreateEditEvent:Y,onModifyEditEvent:oe,grid:{spacing:1,view_window:{left:0,right:h.width||500,top:t,bottom:0}},elements:q,debugGraphics:e},h.width),We.jsx(nEn,{})]})}),l&&!c&&We.jsx("div",{onClick:()=>{u(!0),K()},onTouchStart:W=>{const re=W.touches[0];V.current={x:re.clientX,y:re.clientY}},onTouchEnd:W=>{const re=W.changedTouches[0],fe=V.current;if(!fe)return;const Ae=Math.abs(re.clientX-fe.x),ce=Math.abs(re.clientY-fe.y);Ae<10&&ce<10&&(W.preventDefault(),u(!0),K()),V.current=null},style:{position:"absolute",inset:0,cursor:"pointer",zIndex:eb.clickToInteractOverlay,display:"flex",alignItems:"center",justifyContent:"center",touchAction:"pan-x pan-y pinch-zoom"},children:We.jsx("div",{style:{backgroundColor:"rgba(0, 0, 0, 0.8)",color:"white",padding:"12px 24px",borderRadius:"8px",fontSize:"16px",pointerEvents:"none"},children:typeof window<"u"&&("ontouchstart"in window||navigator.maxTouchPoints>0)?"Touch to Interact":"Click to Interact"})})]})};const ibn=({containerClassName:i,...e})=>{const t=pt.useRef(null),[n,r]=pt.useState(620);return pt.useLayoutEffect(()=>{const a=()=>{if(t.current){const s=t.current.clientHeight,l=window.innerHeight;r(Math.min(Math.max(s,620),l))}};a();const o=new ResizeObserver(a);return t.current&&o.observe(t.current),window.addEventListener("resize",a),()=>{o.disconnect(),window.removeEventListener("resize",a)}},[]),We.jsx("div",{ref:t,className:i||"rf-w-full rf-h-full",children:We.jsx(nbn,{...e,height:n})})},rbn='*,:after,:before{--tw-border-spacing-x:0;--tw-border-spacing-y:0;--tw-translate-x:0;--tw-translate-y:0;--tw-rotate:0;--tw-skew-x:0;--tw-skew-y:0;--tw-scale-x:1;--tw-scale-y:1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness:proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:rgba(59,130,246,.5);--tw-ring-offset-shadow:0 0 #0000;--tw-ring-shadow:0 0 #0000;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }::backdrop{--tw-border-spacing-x:0;--tw-border-spacing-y:0;--tw-translate-x:0;--tw-translate-y:0;--tw-rotate:0;--tw-skew-x:0;--tw-skew-y:0;--tw-scale-x:1;--tw-scale-y:1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness:proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:rgba(59,130,246,.5);--tw-ring-offset-shadow:0 0 #0000;--tw-ring-shadow:0 0 #0000;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }/*! tailwindcss v3.4.17 | MIT License | https://tailwindcss.com*/*,:after,:before{border:0 solid #e5e7eb;box-sizing:border-box}:after,:before{--tw-content:""}:host,html{line-height:1.5;-webkit-text-size-adjust:100%;font-family:ui-sans-serif,system-ui,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;font-feature-settings:normal;font-variation-settings:normal;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-tap-highlight-color:transparent}body{line-height:inherit;margin:0}hr{border-top-width:1px;color:inherit;height:0}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,pre,samp{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace;font-feature-settings:normal;font-size:1em;font-variation-settings:normal}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}table{border-collapse:collapse;border-color:inherit;text-indent:0}button,input,optgroup,select,textarea{color:inherit;font-family:inherit;font-feature-settings:inherit;font-size:100%;font-variation-settings:inherit;font-weight:inherit;letter-spacing:inherit;line-height:inherit;margin:0;padding:0}button,select{text-transform:none}button,input:where([type=button]),input:where([type=reset]),input:where([type=submit]){-webkit-appearance:button;background-color:transparent;background-image:none}:-moz-focusring{outline:auto}:-moz-ui-invalid{box-shadow:none}progress{vertical-align:baseline}::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}summary{display:list-item}blockquote,dd,dl,figure,h1,h2,h3,h4,h5,h6,hr,p,pre{margin:0}fieldset{margin:0}fieldset,legend{padding:0}menu,ol,ul{list-style:none;margin:0;padding:0}dialog{padding:0}textarea{resize:vertical}input::-moz-placeholder,textarea::-moz-placeholder{color:#9ca3af;opacity:1}input::placeholder,textarea::placeholder{color:#9ca3af;opacity:1}[role=button],button{cursor:pointer}:disabled{cursor:default}audio,canvas,embed,iframe,img,object,svg,video{display:block;vertical-align:middle}img,video{height:auto;max-width:100%}[hidden]:where(:not([hidden=until-found])){display:none}:root{--radius:0.5rem}.rf-pointer-events-none{pointer-events:none}.rf-invisible{visibility:hidden}.rf-fixed{position:fixed}.rf-absolute{position:absolute}.rf-relative{position:relative}.rf-inset-0{inset:0}.-rf-left-2{left:-.5rem}.-rf-right-10{right:-2.5rem}.-rf-right-2{right:-.5rem}.-rf-right-4{right:-1rem}.-rf-right-6{right:-1.5rem}.-rf-right-7{right:-1.75rem}.-rf-right-8{right:-2rem}.-rf-right-9{right:-2.25rem}.rf-bottom-full{bottom:100%}.rf-left-0{left:0}.rf-left-1{left:.25rem}.rf-left-1\\/2{left:50%}.rf-left-2{left:.5rem}.rf-left-\\[50\\%\\]{left:50%}.rf-right-0{right:0}.rf-right-4{right:1rem}.rf-right-\\[4px\\]{right:4px}.rf-top-0{top:0}.rf-top-1{top:.25rem}.rf-top-2{top:.5rem}.rf-top-2\\.5{top:.625rem}.rf-top-\\[50\\%\\]{top:50%}.rf-top-\\[6px\\]{top:6px}.\\!rf-z-\\[101\\]{z-index:101!important}.rf-z-50{z-index:50}.rf-z-\\[100\\]{z-index:100}.-rf-mx-1,.rf--mx-1{margin-left:-.25rem;margin-right:-.25rem}.rf-mx-1{margin-left:.25rem;margin-right:.25rem}.rf-mx-2{margin-left:.5rem;margin-right:.5rem}.rf-mx-auto{margin-left:auto;margin-right:auto}.rf-my-1{margin-bottom:.25rem;margin-top:.25rem}.rf-my-12{margin-bottom:3rem;margin-top:3rem}.rf-my-4{margin-bottom:1rem;margin-top:1rem}.rf-my-auto{margin-bottom:auto;margin-top:auto}.rf-mb-1{margin-bottom:.25rem}.rf-mb-12{margin-bottom:3rem}.rf-mb-2{margin-bottom:.5rem}.rf-mb-3{margin-bottom:.75rem}.rf-mb-4{margin-bottom:1rem}.rf-mb-6{margin-bottom:1.5rem}.rf-mb-8{margin-bottom:2rem}.rf-ml-1{margin-left:.25rem}.rf-ml-2{margin-left:.5rem}.rf-ml-auto{margin-left:auto}.rf-mr-1{margin-right:.25rem}.rf-mr-2{margin-right:.5rem}.rf-mt-0{margin-top:0}.rf-mt-0\\.5{margin-top:.125rem}.rf-mt-1{margin-top:.25rem}.rf-mt-2{margin-top:.5rem}.rf-mt-3{margin-top:.75rem}.rf-mt-4{margin-top:1rem}.rf-mt-5{margin-top:1.25rem}.rf-mt-auto{margin-top:auto}.rf-block{display:block}.rf-inline{display:inline}.rf-flex{display:flex}.rf-inline-flex{display:inline-flex}.rf-grid{display:grid}.rf-hidden{display:none}.rf-aspect-square{aspect-ratio:1/1}.rf-aspect-video{aspect-ratio:16/9}.rf-size-14{height:3.5rem;width:3.5rem}.rf-size-4{height:1rem;width:1rem}.\\!rf-h-2{height:.5rem!important}.\\!rf-h-2\\.5{height:.625rem!important}.\\!rf-h-3{height:.75rem!important}.\\!rf-h-full{height:100%!important}.rf-h-1{height:.25rem}.rf-h-10{height:2.5rem}.rf-h-12{height:3rem}.rf-h-2{height:.5rem}.rf-h-2\\.5{height:.625rem}.rf-h-3{height:.75rem}.rf-h-3\\.5{height:.875rem}.rf-h-4{height:1rem}.rf-h-5{height:1.25rem}.rf-h-6{height:1.5rem}.rf-h-60{height:15rem}.rf-h-64{height:16rem}.rf-h-8{height:2rem}.rf-h-9{height:2.25rem}.rf-h-\\[400px\\]{height:400px}.rf-h-\\[calc\\(100vh-52px\\)\\]{height:calc(100vh - 52px)}.rf-h-\\[var\\(--radix-select-trigger-height\\)\\]{height:var(--radix-select-trigger-height)}.rf-h-fit{height:-moz-fit-content;height:fit-content}.rf-h-full{height:100%}.rf-h-px{height:1px}.rf-h-screen{height:100vh}.\\!rf-max-h-\\[40vh\\]{max-height:40vh!important}.rf-max-h-32{max-height:8rem}.rf-max-h-96{max-height:24rem}.rf-max-h-\\[500px\\]{max-height:500px}.rf-max-h-\\[90vh\\]{max-height:90vh}.rf-max-h-full{max-height:100%}.rf-min-h-0{min-height:0}.rf-min-h-\\[200px\\]{min-height:200px}.rf-min-h-\\[620px\\]{min-height:620px}.rf-min-h-\\[calc\\(100vh-240px\\)\\]{min-height:calc(100vh - 240px)}.\\!rf-w-2{width:.5rem!important}.\\!rf-w-2\\.5{width:.625rem!important}.rf-w-1{width:.25rem}.rf-w-1\\/2{width:50%}.rf-w-11{width:2.75rem}.rf-w-11\\/12{width:91.666667%}.rf-w-12{width:3rem}.rf-w-16{width:4rem}.rf-w-2{width:.5rem}.rf-w-2\\.5{width:.625rem}.rf-w-3{width:.75rem}.rf-w-3\\.5{width:.875rem}.rf-w-32{width:8rem}.rf-w-4{width:1rem}.rf-w-48{width:12rem}.rf-w-5{width:1.25rem}.rf-w-6{width:1.5rem}.rf-w-64{width:16rem}.rf-w-72{width:18rem}.rf-w-8{width:2rem}.rf-w-9{width:2.25rem}.rf-w-96{width:24rem}.rf-w-\\[95\\%\\]{width:95%}.rf-w-fit{width:-moz-fit-content;width:fit-content}.rf-w-full{width:100%}.rf-min-w-0{min-width:0}.rf-min-w-10{min-width:2.5rem}.rf-min-w-16{min-width:4rem}.rf-min-w-\\[148px\\]{min-width:148px}.rf-min-w-\\[8rem\\]{min-width:8rem}.rf-min-w-\\[var\\(--radix-select-trigger-width\\)\\]{min-width:var(--radix-select-trigger-width)}.\\!rf-max-w-\\[660px\\]{max-width:660px!important}.rf-max-w-2xl{max-width:42rem}.rf-max-w-3xl{max-width:48rem}.rf-max-w-4xl{max-width:56rem}.rf-max-w-5xl{max-width:64rem}.rf-max-w-full{max-width:100%}.rf-max-w-lg{max-width:32rem}.rf-max-w-md{max-width:28rem}.rf-max-w-none{max-width:none}.rf-max-w-xl{max-width:36rem}.rf-flex-1{flex:1 1 0%}.rf-flex-shrink-0,.rf-shrink-0{flex-shrink:0}.rf-flex-grow{flex-grow:1}.rf-table-auto{table-layout:auto}.-rf-translate-x-1{--tw-translate-x:-0.25rem}.-rf-translate-x-1,.-rf-translate-x-1\\/2{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.-rf-translate-x-1\\/2{--tw-translate-x:-50%}.-rf-translate-y-1{--tw-translate-y:-0.25rem}.-rf-translate-y-1,.rf--translate-x-1{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.rf--translate-x-1{--tw-translate-x:-0.25rem}.rf-translate-x-\\[-50\\%\\]{--tw-translate-x:-50%}.rf-translate-x-\\[-50\\%\\],.rf-translate-y-\\[-50\\%\\]{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.rf-translate-y-\\[-50\\%\\]{--tw-translate-y:-50%}.rf-transform{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}@keyframes rf-pulse{50%{opacity:.5}}.rf-animate-pulse{animation:rf-pulse 2s cubic-bezier(.4,0,.6,1) infinite}@keyframes rf-spin{to{transform:rotate(1turn)}}.rf-animate-spin{animation:rf-spin 1s linear infinite}.rf-cursor-default{cursor:default}.rf-cursor-not-allowed{cursor:not-allowed}.rf-cursor-pointer{cursor:pointer}.rf-select-none{-webkit-user-select:none;-moz-user-select:none;user-select:none}.rf-grid-cols-1{grid-template-columns:repeat(1,minmax(0,1fr))}.rf-grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.rf-flex-row{flex-direction:row}.rf-flex-col{flex-direction:column}.rf-flex-col-reverse{flex-direction:column-reverse}.rf-flex-wrap{flex-wrap:wrap}.rf-place-items-center{place-items:center}.rf-items-start{align-items:flex-start}.rf-items-end{align-items:flex-end}.rf-items-center{align-items:center}.rf-justify-end{justify-content:flex-end}.rf-justify-center{justify-content:center}.rf-justify-between{justify-content:space-between}.rf-gap-0{gap:0}.rf-gap-1{gap:.25rem}.rf-gap-2{gap:.5rem}.rf-gap-3{gap:.75rem}.rf-gap-4{gap:1rem}.rf-gap-5{gap:1.25rem}.rf-gap-6{gap:1.5rem}.rf-gap-8{gap:2rem}.rf-space-x-2>:not([hidden])~:not([hidden]){--tw-space-x-reverse:0;margin-left:calc(.5rem*(1 - var(--tw-space-x-reverse)));margin-right:calc(.5rem*var(--tw-space-x-reverse))}.rf-space-y-2>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-bottom:calc(.5rem*var(--tw-space-y-reverse));margin-top:calc(.5rem*(1 - var(--tw-space-y-reverse)))}.rf-space-y-3>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-bottom:calc(.75rem*var(--tw-space-y-reverse));margin-top:calc(.75rem*(1 - var(--tw-space-y-reverse)))}.rf-space-y-4>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-bottom:calc(1rem*var(--tw-space-y-reverse));margin-top:calc(1rem*(1 - var(--tw-space-y-reverse)))}.rf-space-y-6>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-bottom:calc(1.5rem*var(--tw-space-y-reverse));margin-top:calc(1.5rem*(1 - var(--tw-space-y-reverse)))}.rf-divide-y>:not([hidden])~:not([hidden]){--tw-divide-y-reverse:0;border-bottom-width:calc(1px*var(--tw-divide-y-reverse));border-top-width:calc(1px*(1 - var(--tw-divide-y-reverse)))}.rf-overflow-auto{overflow:auto}.rf-overflow-hidden{overflow:hidden}.rf-overflow-visible{overflow:visible}.rf-overflow-x-auto{overflow-x:auto}.\\!rf-overflow-y-auto{overflow-y:auto!important}.rf-overflow-y-auto{overflow-y:auto}.rf-overflow-x-hidden{overflow-x:hidden}.rf-overflow-x-clip{overflow-x:clip}.rf-truncate{overflow:hidden;text-overflow:ellipsis}.rf-truncate,.rf-whitespace-nowrap{white-space:nowrap}.rf-whitespace-pre-wrap{white-space:pre-wrap}.rf-break-words{overflow-wrap:break-word}.rf-rounded{border-radius:.25rem}.rf-rounded-2xl{border-radius:1rem}.rf-rounded-full{border-radius:9999px}.rf-rounded-lg{border-radius:var(--radius)}.rf-rounded-md{border-radius:calc(var(--radius) - 2px)}.rf-rounded-sm{border-radius:calc(var(--radius) - 4px)}.rf-rounded-xl{border-radius:.75rem}.rf-border{border-width:1px}.rf-border-b{border-bottom-width:1px}.rf-border-t{border-top-width:1px}.rf-border-blue-200{--tw-border-opacity:1;border-color:rgb(191 219 254/var(--tw-border-opacity,1))}.rf-border-blue-500{--tw-border-opacity:1;border-color:rgb(59 130 246/var(--tw-border-opacity,1))}.rf-border-blue-600{--tw-border-opacity:1;border-color:rgb(37 99 235/var(--tw-border-opacity,1))}.rf-border-gray-200{--tw-border-opacity:1;border-color:rgb(229 231 235/var(--tw-border-opacity,1))}.rf-border-gray-300{--tw-border-opacity:1;border-color:rgb(209 213 219/var(--tw-border-opacity,1))}.rf-border-green-200{--tw-border-opacity:1;border-color:rgb(187 247 208/var(--tw-border-opacity,1))}.rf-border-input{border-color:hsl(var(--input))}.rf-border-neutral-200{--tw-border-opacity:1;border-color:rgb(229 229 229/var(--tw-border-opacity,1))}.rf-border-orange-200{--tw-border-opacity:1;border-color:rgb(254 215 170/var(--tw-border-opacity,1))}.rf-border-primary{border-color:hsl(var(--primary))}.rf-border-red-200{--tw-border-opacity:1;border-color:rgb(254 202 202/var(--tw-border-opacity,1))}.rf-border-red-500{--tw-border-opacity:1;border-color:rgb(239 68 68/var(--tw-border-opacity,1))}.rf-border-zinc-200{--tw-border-opacity:1;border-color:rgb(228 228 231/var(--tw-border-opacity,1))}.rf-border-zinc-900{--tw-border-opacity:1;border-color:rgb(24 24 27/var(--tw-border-opacity,1))}.rf-bg-background{background-color:hsl(var(--background))}.rf-bg-black{--tw-bg-opacity:1;background-color:rgb(0 0 0/var(--tw-bg-opacity,1))}.rf-bg-black\\/80{background-color:rgba(0,0,0,.8)}.rf-bg-blue-100{--tw-bg-opacity:1;background-color:rgb(219 234 254/var(--tw-bg-opacity,1))}.rf-bg-blue-50{--tw-bg-opacity:1;background-color:rgb(239 246 255/var(--tw-bg-opacity,1))}.rf-bg-blue-500{--tw-bg-opacity:1;background-color:rgb(59 130 246/var(--tw-bg-opacity,1))}.rf-bg-blue-600{--tw-bg-opacity:1;background-color:rgb(37 99 235/var(--tw-bg-opacity,1))}.rf-bg-gray-100{--tw-bg-opacity:1;background-color:rgb(243 244 246/var(--tw-bg-opacity,1))}.rf-bg-gray-200{--tw-bg-opacity:1;background-color:rgb(229 231 235/var(--tw-bg-opacity,1))}.rf-bg-gray-300{--tw-bg-opacity:1;background-color:rgb(209 213 219/var(--tw-bg-opacity,1))}.rf-bg-gray-400{--tw-bg-opacity:1;background-color:rgb(156 163 175/var(--tw-bg-opacity,1))}.rf-bg-gray-50{--tw-bg-opacity:1;background-color:rgb(249 250 251/var(--tw-bg-opacity,1))}.rf-bg-gray-500{--tw-bg-opacity:1;background-color:rgb(107 114 128/var(--tw-bg-opacity,1))}.rf-bg-gray-700{--tw-bg-opacity:1;background-color:rgb(55 65 81/var(--tw-bg-opacity,1))}.rf-bg-gray-800{--tw-bg-opacity:1;background-color:rgb(31 41 55/var(--tw-bg-opacity,1))}.rf-bg-gray-900{--tw-bg-opacity:1;background-color:rgb(17 24 39/var(--tw-bg-opacity,1))}.rf-bg-green-100{--tw-bg-opacity:1;background-color:rgb(220 252 231/var(--tw-bg-opacity,1))}.rf-bg-green-50{--tw-bg-opacity:1;background-color:rgb(240 253 244/var(--tw-bg-opacity,1))}.rf-bg-muted{background-color:hsl(var(--muted))}.rf-bg-neutral-100{--tw-bg-opacity:1;background-color:rgb(245 245 245/var(--tw-bg-opacity,1))}.rf-bg-neutral-50{--tw-bg-opacity:1;background-color:rgb(250 250 250/var(--tw-bg-opacity,1))}.rf-bg-neutral-800{--tw-bg-opacity:1;background-color:rgb(38 38 38/var(--tw-bg-opacity,1))}.rf-bg-neutral-900{--tw-bg-opacity:1;background-color:rgb(23 23 23/var(--tw-bg-opacity,1))}.rf-bg-orange-400{--tw-bg-opacity:1;background-color:rgb(251 146 60/var(--tw-bg-opacity,1))}.rf-bg-orange-50{--tw-bg-opacity:1;background-color:rgb(255 247 237/var(--tw-bg-opacity,1))}.rf-bg-popover{background-color:hsl(var(--popover))}.rf-bg-red-100{--tw-bg-opacity:1;background-color:rgb(254 226 226/var(--tw-bg-opacity,1))}.rf-bg-red-50{--tw-bg-opacity:1;background-color:rgb(254 242 242/var(--tw-bg-opacity,1))}.rf-bg-red-500{--tw-bg-opacity:1;background-color:rgb(239 68 68/var(--tw-bg-opacity,1))}.rf-bg-red-900{--tw-bg-opacity:1;background-color:rgb(127 29 29/var(--tw-bg-opacity,1))}.rf-bg-white{--tw-bg-opacity:1;background-color:rgb(255 255 255/var(--tw-bg-opacity,1))}.rf-bg-yellow-100{--tw-bg-opacity:1;background-color:rgb(254 249 195/var(--tw-bg-opacity,1))}.rf-bg-zinc-100{--tw-bg-opacity:1;background-color:rgb(244 244 245/var(--tw-bg-opacity,1))}.rf-bg-zinc-200{--tw-bg-opacity:1;background-color:rgb(228 228 231/var(--tw-bg-opacity,1))}.rf-bg-zinc-50{--tw-bg-opacity:1;background-color:rgb(250 250 250/var(--tw-bg-opacity,1))}.rf-bg-zinc-800{--tw-bg-opacity:1;background-color:rgb(39 39 42/var(--tw-bg-opacity,1))}.rf-bg-zinc-900{--tw-bg-opacity:1;background-color:rgb(24 24 27/var(--tw-bg-opacity,1))}.rf-bg-opacity-50{--tw-bg-opacity:0.5}.rf-fill-current{fill:currentColor}.rf-object-contain{-o-object-fit:contain;object-fit:contain}.rf-object-cover{-o-object-fit:cover;object-fit:cover}.\\!rf-p-0{padding:0!important}.rf-p-0{padding:0}.rf-p-1{padding:.25rem}.rf-p-2{padding:.5rem}.rf-p-3{padding:.75rem}.rf-p-4{padding:1rem}.rf-p-5{padding:1.25rem}.rf-p-6{padding:1.5rem}.rf-p-8{padding:2rem}.rf-px-1{padding-left:.25rem;padding-right:.25rem}.rf-px-2{padding-left:.5rem;padding-right:.5rem}.rf-px-3{padding-left:.75rem;padding-right:.75rem}.rf-px-4{padding-left:1rem;padding-right:1rem}.rf-px-6{padding-left:1.5rem;padding-right:1.5rem}.rf-px-8{padding-left:2rem;padding-right:2rem}.rf-py-0{padding-bottom:0;padding-top:0}.rf-py-0\\.5{padding-bottom:.125rem;padding-top:.125rem}.rf-py-1{padding-bottom:.25rem;padding-top:.25rem}.rf-py-1\\.5{padding-bottom:.375rem;padding-top:.375rem}.rf-py-10{padding-bottom:2.5rem;padding-top:2.5rem}.rf-py-12{padding-bottom:3rem;padding-top:3rem}.rf-py-2{padding-bottom:.5rem;padding-top:.5rem}.rf-py-3{padding-bottom:.75rem;padding-top:.75rem}.rf-py-4{padding-bottom:1rem;padding-top:1rem}.rf-py-8{padding-bottom:2rem;padding-top:2rem}.rf-pb-0{padding-bottom:0}.rf-pb-2{padding-bottom:.5rem}.rf-pb-3{padding-bottom:.75rem}.rf-pb-4{padding-bottom:1rem}.rf-pl-2{padding-left:.5rem}.rf-pl-4{padding-left:1rem}.rf-pl-8{padding-left:2rem}.rf-pr-2{padding-right:.5rem}.rf-pt-2{padding-top:.5rem}.rf-pt-4{padding-top:1rem}.rf-text-left{text-align:left}.rf-text-center{text-align:center}.rf-text-right{text-align:right}.rf-font-mono{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace}.rf-text-2xl{font-size:1.5rem;line-height:2rem}.rf-text-3xl{font-size:1.875rem;line-height:2.25rem}.rf-text-\\[8px\\]{font-size:8px}.rf-text-base{font-size:1rem;line-height:1.5rem}.rf-text-lg{font-size:1.125rem;line-height:1.75rem}.rf-text-sm{font-size:.875rem;line-height:1.25rem}.rf-text-xl{font-size:1.25rem;line-height:1.75rem}.rf-text-xs{font-size:.75rem;line-height:1rem}.rf-font-bold{font-weight:700}.rf-font-medium{font-weight:500}.rf-font-semibold{font-weight:600}.rf-uppercase{text-transform:uppercase}.rf-capitalize{text-transform:capitalize}.rf-tabular-nums{--tw-numeric-spacing:tabular-nums;font-variant-numeric:var(--tw-ordinal) var(--tw-slashed-zero) var(--tw-numeric-figure) var(--tw-numeric-spacing) var(--tw-numeric-fraction)}.rf-leading-5{line-height:1.25rem}.rf-leading-none{line-height:1}.rf-leading-relaxed{line-height:1.625}.rf-leading-tight{line-height:1.25}.rf-tracking-wide{letter-spacing:.025em}.rf-tracking-widest{letter-spacing:.1em}.rf-text-black{--tw-text-opacity:1;color:rgb(0 0 0/var(--tw-text-opacity,1))}.rf-text-blue-500{--tw-text-opacity:1;color:rgb(59 130 246/var(--tw-text-opacity,1))}.rf-text-blue-600{--tw-text-opacity:1;color:rgb(37 99 235/var(--tw-text-opacity,1))}.rf-text-blue-700{--tw-text-opacity:1;color:rgb(29 78 216/var(--tw-text-opacity,1))}.rf-text-blue-800{--tw-text-opacity:1;color:rgb(30 64 175/var(--tw-text-opacity,1))}.rf-text-blue-900{--tw-text-opacity:1;color:rgb(30 58 138/var(--tw-text-opacity,1))}.rf-text-current{color:currentColor}.rf-text-gray-400{--tw-text-opacity:1;color:rgb(156 163 175/var(--tw-text-opacity,1))}.rf-text-gray-500{--tw-text-opacity:1;color:rgb(107 114 128/var(--tw-text-opacity,1))}.rf-text-gray-600{--tw-text-opacity:1;color:rgb(75 85 99/var(--tw-text-opacity,1))}.rf-text-gray-700{--tw-text-opacity:1;color:rgb(55 65 81/var(--tw-text-opacity,1))}.rf-text-gray-800{--tw-text-opacity:1;color:rgb(31 41 55/var(--tw-text-opacity,1))}.rf-text-gray-900{--tw-text-opacity:1;color:rgb(17 24 39/var(--tw-text-opacity,1))}.rf-text-green-500{--tw-text-opacity:1;color:rgb(34 197 94/var(--tw-text-opacity,1))}.rf-text-green-600{--tw-text-opacity:1;color:rgb(22 163 74/var(--tw-text-opacity,1))}.rf-text-green-700{--tw-text-opacity:1;color:rgb(21 128 61/var(--tw-text-opacity,1))}.rf-text-green-800{--tw-text-opacity:1;color:rgb(22 101 52/var(--tw-text-opacity,1))}.rf-text-green-900{--tw-text-opacity:1;color:rgb(20 83 45/var(--tw-text-opacity,1))}.rf-text-muted-foreground{color:hsl(var(--muted-foreground))}.rf-text-neutral-50{--tw-text-opacity:1;color:rgb(250 250 250/var(--tw-text-opacity,1))}.rf-text-neutral-500{--tw-text-opacity:1;color:rgb(115 115 115/var(--tw-text-opacity,1))}.rf-text-neutral-900{--tw-text-opacity:1;color:rgb(23 23 23/var(--tw-text-opacity,1))}.rf-text-neutral-950{--tw-text-opacity:1;color:rgb(10 10 10/var(--tw-text-opacity,1))}.rf-text-orange-500{--tw-text-opacity:1;color:rgb(249 115 22/var(--tw-text-opacity,1))}.rf-text-orange-600{--tw-text-opacity:1;color:rgb(234 88 12/var(--tw-text-opacity,1))}.rf-text-orange-800{--tw-text-opacity:1;color:rgb(154 52 18/var(--tw-text-opacity,1))}.rf-text-popover-foreground{color:hsl(var(--popover-foreground))}.rf-text-red-200{--tw-text-opacity:1;color:rgb(254 202 202/var(--tw-text-opacity,1))}.rf-text-red-300{--tw-text-opacity:1;color:rgb(252 165 165/var(--tw-text-opacity,1))}.rf-text-red-400{--tw-text-opacity:1;color:rgb(248 113 113/var(--tw-text-opacity,1))}.rf-text-red-500{--tw-text-opacity:1;color:rgb(239 68 68/var(--tw-text-opacity,1))}.rf-text-red-600{--tw-text-opacity:1;color:rgb(220 38 38/var(--tw-text-opacity,1))}.rf-text-red-700{--tw-text-opacity:1;color:rgb(185 28 28/var(--tw-text-opacity,1))}.rf-text-red-800{--tw-text-opacity:1;color:rgb(153 27 27/var(--tw-text-opacity,1))}.rf-text-red-900{--tw-text-opacity:1;color:rgb(127 29 29/var(--tw-text-opacity,1))}.rf-text-white{--tw-text-opacity:1;color:rgb(255 255 255/var(--tw-text-opacity,1))}.rf-text-yellow-400{--tw-text-opacity:1;color:rgb(250 204 21/var(--tw-text-opacity,1))}.rf-text-yellow-500{--tw-text-opacity:1;color:rgb(234 179 8/var(--tw-text-opacity,1))}.rf-text-yellow-900{--tw-text-opacity:1;color:rgb(113 63 18/var(--tw-text-opacity,1))}.rf-text-zinc-200{--tw-text-opacity:1;color:rgb(228 228 231/var(--tw-text-opacity,1))}.rf-text-zinc-300{--tw-text-opacity:1;color:rgb(212 212 216/var(--tw-text-opacity,1))}.rf-text-zinc-400{--tw-text-opacity:1;color:rgb(161 161 170/var(--tw-text-opacity,1))}.rf-text-zinc-50{--tw-text-opacity:1;color:rgb(250 250 250/var(--tw-text-opacity,1))}.rf-text-zinc-500{--tw-text-opacity:1;color:rgb(113 113 122/var(--tw-text-opacity,1))}.rf-text-zinc-900{--tw-text-opacity:1;color:rgb(24 24 27/var(--tw-text-opacity,1))}.rf-text-zinc-950{--tw-text-opacity:1;color:rgb(9 9 11/var(--tw-text-opacity,1))}.rf-underline{text-decoration-line:underline}.rf-line-through{text-decoration-line:line-through}.rf-underline-offset-4{text-underline-offset:4px}.rf-opacity-0{opacity:0}.rf-opacity-25{opacity:.25}.rf-opacity-30{opacity:.3}.rf-opacity-50{opacity:.5}.rf-opacity-60{opacity:.6}.rf-opacity-75{opacity:.75}.rf-shadow{--tw-shadow:0 1px 3px 0 rgba(0,0,0,.1),0 1px 2px -1px rgba(0,0,0,.1);--tw-shadow-colored:0 1px 3px 0 var(--tw-shadow-color),0 1px 2px -1px var(--tw-shadow-color)}.rf-shadow,.rf-shadow-lg{box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}.rf-shadow-lg{--tw-shadow:0 10px 15px -3px rgba(0,0,0,.1),0 4px 6px -4px rgba(0,0,0,.1);--tw-shadow-colored:0 10px 15px -3px var(--tw-shadow-color),0 4px 6px -4px var(--tw-shadow-color)}.rf-shadow-md{--tw-shadow:0 4px 6px -1px rgba(0,0,0,.1),0 2px 4px -2px rgba(0,0,0,.1);--tw-shadow-colored:0 4px 6px -1px var(--tw-shadow-color),0 2px 4px -2px var(--tw-shadow-color)}.rf-shadow-md,.rf-shadow-sm{box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}.rf-shadow-sm{--tw-shadow:0 1px 2px 0 rgba(0,0,0,.05);--tw-shadow-colored:0 1px 2px 0 var(--tw-shadow-color)}.rf-outline-none{outline:2px solid transparent;outline-offset:2px}.rf-ring-2{--tw-ring-offset-shadow:var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow:var(--tw-ring-inset) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow,0 0 #0000)}.rf-ring-blue-500{--tw-ring-opacity:1;--tw-ring-color:rgb(59 130 246/var(--tw-ring-opacity,1))}.rf-ring-primary{--tw-ring-color:hsl(var(--primary))}.rf-ring-offset-background{--tw-ring-offset-color:hsl(var(--background))}.rf-ring-offset-white{--tw-ring-offset-color:#fff}.rf-transition{transition-duration:.15s;transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,-webkit-backdrop-filter;transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,backdrop-filter;transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,backdrop-filter,-webkit-backdrop-filter;transition-timing-function:cubic-bezier(.4,0,.2,1)}.rf-transition-all{transition-duration:.15s;transition-property:all;transition-timing-function:cubic-bezier(.4,0,.2,1)}.rf-transition-colors{transition-duration:.15s;transition-property:color,background-color,border-color,text-decoration-color,fill,stroke;transition-timing-function:cubic-bezier(.4,0,.2,1)}.rf-transition-opacity{transition-duration:.15s;transition-property:opacity;transition-timing-function:cubic-bezier(.4,0,.2,1)}.rf-duration-200{transition-duration:.2s}.rf-ease-in-out{transition-timing-function:cubic-bezier(.4,0,.2,1)}@keyframes enter{0%{opacity:var(--tw-enter-opacity,1);transform:translate3d(var(--tw-enter-translate-x,0),var(--tw-enter-translate-y,0),0) scale3d(var(--tw-enter-scale,1),var(--tw-enter-scale,1),var(--tw-enter-scale,1)) rotate(var(--tw-enter-rotate,0))}}@keyframes exit{to{opacity:var(--tw-exit-opacity,1);transform:translate3d(var(--tw-exit-translate-x,0),var(--tw-exit-translate-y,0),0) scale3d(var(--tw-exit-scale,1),var(--tw-exit-scale,1),var(--tw-exit-scale,1)) rotate(var(--tw-exit-rotate,0))}}.rf-slide-in-from-left-1{--tw-enter-translate-x:-0.25rem}.rf-slide-out-to-left-1{--tw-exit-translate-x:-0.25rem}.rf-duration-200{animation-duration:.2s}.rf-ease-in-out{animation-timing-function:cubic-bezier(.4,0,.2,1)}.file\\:rf-border-0::file-selector-button{border-width:0}.file\\:rf-bg-transparent::file-selector-button{background-color:transparent}.file\\:rf-text-sm::file-selector-button{font-size:.875rem;line-height:1.25rem}.file\\:rf-font-medium::file-selector-button{font-weight:500}.placeholder\\:rf-text-zinc-500::-moz-placeholder{--tw-text-opacity:1;color:rgb(113 113 122/var(--tw-text-opacity,1))}.placeholder\\:rf-text-zinc-500::placeholder{--tw-text-opacity:1;color:rgb(113 113 122/var(--tw-text-opacity,1))}.hover\\:rf-border-blue-300:hover{--tw-border-opacity:1;border-color:rgb(147 197 253/var(--tw-border-opacity,1))}.hover\\:\\!rf-bg-transparent:hover{background-color:transparent!important}.hover\\:rf-bg-blue-700:hover{--tw-bg-opacity:1;background-color:rgb(29 78 216/var(--tw-bg-opacity,1))}.hover\\:rf-bg-red-500\\/90:hover{background-color:rgba(239,68,68,.9)}.hover\\:rf-bg-zinc-100:hover{--tw-bg-opacity:1;background-color:rgb(244 244 245/var(--tw-bg-opacity,1))}.hover\\:rf-bg-zinc-100\\/80:hover{background-color:hsla(240,5%,96%,.8)}.hover\\:rf-bg-zinc-900\\/90:hover{background-color:rgba(24,24,27,.9)}.hover\\:rf-text-red-400:hover{--tw-text-opacity:1;color:rgb(248 113 113/var(--tw-text-opacity,1))}.hover\\:rf-text-zinc-900:hover{--tw-text-opacity:1;color:rgb(24 24 27/var(--tw-text-opacity,1))}.hover\\:rf-underline:hover{text-decoration-line:underline}.focus\\:rf-bg-gray-100:focus{--tw-bg-opacity:1;background-color:rgb(243 244 246/var(--tw-bg-opacity,1))}.focus\\:rf-bg-zinc-100:focus{--tw-bg-opacity:1;background-color:rgb(244 244 245/var(--tw-bg-opacity,1))}.focus\\:rf-text-gray-900:focus{--tw-text-opacity:1;color:rgb(17 24 39/var(--tw-text-opacity,1))}.focus\\:rf-text-zinc-900:focus{--tw-text-opacity:1;color:rgb(24 24 27/var(--tw-text-opacity,1))}.focus\\:rf-outline-none:focus{outline:2px solid transparent;outline-offset:2px}.focus\\:rf-ring-2:focus{--tw-ring-offset-shadow:var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow:var(--tw-ring-inset) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow,0 0 #0000)}.focus\\:rf-ring-ring:focus{--tw-ring-color:hsl(var(--ring))}.focus\\:rf-ring-offset-2:focus{--tw-ring-offset-width:2px}.focus-visible\\:rf-outline-none:focus-visible{outline:2px solid transparent;outline-offset:2px}.focus-visible\\:rf-ring-1:focus-visible{--tw-ring-offset-shadow:var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow:var(--tw-ring-inset) 0 0 0 calc(1px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow,0 0 #0000)}.focus-visible\\:rf-ring-2:focus-visible{--tw-ring-offset-shadow:var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow:var(--tw-ring-inset) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow,0 0 #0000)}.focus-visible\\:rf-ring-zinc-950:focus-visible{--tw-ring-opacity:1;--tw-ring-color:rgb(9 9 11/var(--tw-ring-opacity,1))}.focus-visible\\:rf-ring-offset-2:focus-visible{--tw-ring-offset-width:2px}.disabled\\:rf-pointer-events-none:disabled{pointer-events:none}.disabled\\:rf-cursor-not-allowed:disabled{cursor:not-allowed}.disabled\\:rf-opacity-50:disabled{opacity:.5}.rf-group\\/bar:hover .group-hover\\/bar\\:rf-opacity-100{opacity:1}.data-\\[disabled\\]\\:rf-pointer-events-none[data-disabled]{pointer-events:none}.data-\\[side\\=bottom\\]\\:rf-translate-y-1[data-side=bottom]{--tw-translate-y:0.25rem}.data-\\[side\\=bottom\\]\\:rf-translate-y-1[data-side=bottom],.data-\\[side\\=left\\]\\:-rf-translate-x-1[data-side=left]{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.data-\\[side\\=left\\]\\:-rf-translate-x-1[data-side=left]{--tw-translate-x:-0.25rem}.data-\\[side\\=right\\]\\:rf-translate-x-1[data-side=right]{--tw-translate-x:0.25rem}.data-\\[side\\=right\\]\\:rf-translate-x-1[data-side=right],.data-\\[side\\=top\\]\\:-rf-translate-y-1[data-side=top]{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.data-\\[side\\=top\\]\\:-rf-translate-y-1[data-side=top]{--tw-translate-y:-0.25rem}.data-\\[state\\=active\\]\\:rf-bg-white[data-state=active]{--tw-bg-opacity:1;background-color:rgb(255 255 255/var(--tw-bg-opacity,1))}.data-\\[state\\=checked\\]\\:rf-bg-zinc-900[data-state=checked]{--tw-bg-opacity:1;background-color:rgb(24 24 27/var(--tw-bg-opacity,1))}.data-\\[state\\=open\\]\\:rf-bg-zinc-100[data-state=open]{--tw-bg-opacity:1;background-color:rgb(244 244 245/var(--tw-bg-opacity,1))}.data-\\[state\\=active\\]\\:rf-text-zinc-950[data-state=active]{--tw-text-opacity:1;color:rgb(9 9 11/var(--tw-text-opacity,1))}.data-\\[state\\=checked\\]\\:rf-text-zinc-50[data-state=checked]{--tw-text-opacity:1;color:rgb(250 250 250/var(--tw-text-opacity,1))}.data-\\[disabled\\]\\:rf-opacity-50[data-disabled]{opacity:.5}.data-\\[state\\=active\\]\\:rf-shadow[data-state=active]{--tw-shadow:0 1px 3px 0 rgba(0,0,0,.1),0 1px 2px -1px rgba(0,0,0,.1);--tw-shadow-colored:0 1px 3px 0 var(--tw-shadow-color),0 1px 2px -1px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}.data-\\[state\\=open\\]\\:rf-animate-in[data-state=open]{animation-duration:.15s;animation-name:enter;--tw-enter-opacity:initial;--tw-enter-scale:initial;--tw-enter-rotate:initial;--tw-enter-translate-x:initial;--tw-enter-translate-y:initial}.data-\\[state\\=closed\\]\\:rf-animate-out[data-state=closed]{animation-duration:.15s;animation-name:exit;--tw-exit-opacity:initial;--tw-exit-scale:initial;--tw-exit-rotate:initial;--tw-exit-translate-x:initial;--tw-exit-translate-y:initial}.data-\\[state\\=closed\\]\\:rf-fade-out-0[data-state=closed]{--tw-exit-opacity:0}.data-\\[state\\=open\\]\\:rf-fade-in-0[data-state=open]{--tw-enter-opacity:0}.data-\\[state\\=closed\\]\\:rf-zoom-out-95[data-state=closed]{--tw-exit-scale:.95}.data-\\[state\\=open\\]\\:rf-zoom-in-95[data-state=open]{--tw-enter-scale:.95}.data-\\[side\\=bottom\\]\\:rf-slide-in-from-top-2[data-side=bottom]{--tw-enter-translate-y:-0.5rem}.data-\\[side\\=left\\]\\:rf-slide-in-from-right-2[data-side=left]{--tw-enter-translate-x:0.5rem}.data-\\[side\\=right\\]\\:rf-slide-in-from-left-2[data-side=right]{--tw-enter-translate-x:-0.5rem}.data-\\[side\\=top\\]\\:rf-slide-in-from-bottom-2[data-side=top]{--tw-enter-translate-y:0.5rem}.data-\\[state\\=closed\\]\\:rf-slide-out-to-left-1\\/2[data-state=closed]{--tw-exit-translate-x:-50%}.data-\\[state\\=closed\\]\\:rf-slide-out-to-top-\\[48\\%\\][data-state=closed]{--tw-exit-translate-y:-48%}.data-\\[state\\=open\\]\\:rf-slide-in-from-left-1\\/2[data-state=open]{--tw-enter-translate-x:-50%}.data-\\[state\\=open\\]\\:rf-slide-in-from-top-\\[48\\%\\][data-state=open]{--tw-enter-translate-y:-48%}.dark\\:rf-border-zinc-50:is(.rf-dark *){--tw-border-opacity:1;border-color:rgb(250 250 250/var(--tw-border-opacity,1))}.dark\\:rf-border-zinc-800:is(.rf-dark *){--tw-border-opacity:1;border-color:rgb(39 39 42/var(--tw-border-opacity,1))}.dark\\:rf-bg-red-900:is(.rf-dark *){--tw-bg-opacity:1;background-color:rgb(127 29 29/var(--tw-bg-opacity,1))}.dark\\:rf-bg-zinc-50:is(.rf-dark *){--tw-bg-opacity:1;background-color:rgb(250 250 250/var(--tw-bg-opacity,1))}.dark\\:rf-bg-zinc-800:is(.rf-dark *){--tw-bg-opacity:1;background-color:rgb(39 39 42/var(--tw-bg-opacity,1))}.dark\\:rf-bg-zinc-950:is(.rf-dark *){--tw-bg-opacity:1;background-color:rgb(9 9 11/var(--tw-bg-opacity,1))}.dark\\:rf-text-zinc-400:is(.rf-dark *){--tw-text-opacity:1;color:rgb(161 161 170/var(--tw-text-opacity,1))}.dark\\:rf-text-zinc-50:is(.rf-dark *){--tw-text-opacity:1;color:rgb(250 250 250/var(--tw-text-opacity,1))}.dark\\:rf-text-zinc-900:is(.rf-dark *){--tw-text-opacity:1;color:rgb(24 24 27/var(--tw-text-opacity,1))}.dark\\:rf-placeholder-zinc-400:is(.rf-dark *)::-moz-placeholder{--tw-placeholder-opacity:1;color:rgb(161 161 170/var(--tw-placeholder-opacity,1))}.dark\\:rf-placeholder-zinc-400:is(.rf-dark *)::placeholder{--tw-placeholder-opacity:1;color:rgb(161 161 170/var(--tw-placeholder-opacity,1))}.dark\\:rf-ring-offset-zinc-950:is(.rf-dark *){--tw-ring-offset-color:#09090b}.dark\\:hover\\:rf-bg-red-900\\/90:hover:is(.rf-dark *){background-color:rgba(127,29,29,.9)}.dark\\:hover\\:rf-bg-zinc-50\\/90:hover:is(.rf-dark *){background-color:hsla(0,0%,98%,.9)}.dark\\:hover\\:rf-bg-zinc-800:hover:is(.rf-dark *){--tw-bg-opacity:1;background-color:rgb(39 39 42/var(--tw-bg-opacity,1))}.dark\\:hover\\:rf-bg-zinc-800\\/80:hover:is(.rf-dark *){background-color:rgba(39,39,42,.8)}.dark\\:hover\\:rf-text-zinc-50:hover:is(.rf-dark *){--tw-text-opacity:1;color:rgb(250 250 250/var(--tw-text-opacity,1))}.dark\\:focus\\:rf-bg-zinc-800:focus:is(.rf-dark *){--tw-bg-opacity:1;background-color:rgb(39 39 42/var(--tw-bg-opacity,1))}.dark\\:focus\\:rf-text-zinc-50:focus:is(.rf-dark *){--tw-text-opacity:1;color:rgb(250 250 250/var(--tw-text-opacity,1))}.dark\\:focus-visible\\:rf-ring-zinc-300:focus-visible:is(.rf-dark *){--tw-ring-opacity:1;--tw-ring-color:rgb(212 212 216/var(--tw-ring-opacity,1))}.dark\\:data-\\[state\\=active\\]\\:rf-bg-zinc-950[data-state=active]:is(.rf-dark *){--tw-bg-opacity:1;background-color:rgb(9 9 11/var(--tw-bg-opacity,1))}.dark\\:data-\\[state\\=checked\\]\\:rf-bg-zinc-50[data-state=checked]:is(.rf-dark *){--tw-bg-opacity:1;background-color:rgb(250 250 250/var(--tw-bg-opacity,1))}.dark\\:data-\\[state\\=open\\]\\:rf-bg-zinc-800[data-state=open]:is(.rf-dark *){--tw-bg-opacity:1;background-color:rgb(39 39 42/var(--tw-bg-opacity,1))}.dark\\:data-\\[state\\=active\\]\\:rf-text-zinc-50[data-state=active]:is(.rf-dark *){--tw-text-opacity:1;color:rgb(250 250 250/var(--tw-text-opacity,1))}.dark\\:data-\\[state\\=checked\\]\\:rf-text-zinc-900[data-state=checked]:is(.rf-dark *){--tw-text-opacity:1;color:rgb(24 24 27/var(--tw-text-opacity,1))}@media (min-width:640px){.sm\\:rf-mt-0{margin-top:0}.sm\\:rf-flex-row{flex-direction:row}.sm\\:rf-justify-end{justify-content:flex-end}.sm\\:rf-space-x-2>:not([hidden])~:not([hidden]){--tw-space-x-reverse:0;margin-left:calc(.5rem*(1 - var(--tw-space-x-reverse)));margin-right:calc(.5rem*var(--tw-space-x-reverse))}.sm\\:rf-rounded-lg{border-radius:var(--radius)}.sm\\:rf-text-left{text-align:left}}@media (min-width:768px){.md\\:rf-grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}}.\\[\\&\\>span\\]\\:rf-line-clamp-1>span{display:-webkit-box;overflow:hidden;-webkit-box-orient:vertical;-webkit-line-clamp:1}.\\[\\&\\>svg\\]\\:rf-size-4>svg{height:1rem;width:1rem}.\\[\\&\\>svg\\]\\:rf-shrink-0>svg{flex-shrink:0}.\\[\\&\\>svg\\]\\:rf-text-red-300>svg{--tw-text-opacity:1;color:rgb(252 165 165/var(--tw-text-opacity,1))}.\\[\\&\\>svg\\]\\:hover\\:rf-text-red-400:hover>svg{--tw-text-opacity:1;color:rgb(248 113 113/var(--tw-text-opacity,1))}.\\[\\&_svg\\]\\:rf-pointer-events-none svg{pointer-events:none}.\\[\\&_svg\\]\\:rf-size-4 svg{height:1rem;width:1rem}.\\[\\&_svg\\]\\:rf-shrink-0 svg{flex-shrink:0}',abn=()=>{pt.useEffect(()=>{if(document.querySelector('style[data-styles="tscircuit-runframe"]'))return;const e=document.createElement("style");e.setAttribute("data-styles","tscircuit-runframe"),e.textContent=rbn,document.head.appendChild(e)},[])},obn=i=>{pt.useEffect(()=>(i?document.body.style.overflow="hidden":document.body.style.overflow="",()=>{document.body.style.overflow=""}),[i])},Tot=i=>`hsl(${Gb.indexOf(i)*137.5%360}, 70%, 50%)`,sbn=({phaseTimings:i})=>{if(!i)return null;const e=Object.values(i).reduce((t,n)=>t+n,0);return We.jsxs("div",{className:"rf-space-y-2 rf-w-full rf-px-4",children:[We.jsx("div",{className:"rf-relative rf-h-8 rf-flex rf-rounded-sm",children:Gb.map(t=>{const n=i[t]||0,r=n/e*100;return We.jsx("div",{className:"rf-group/bar rf-relative rf-overflow-visible",style:{width:`${r}%`,backgroundColor:Tot(t)},children:We.jsxs("div",{className:"rf-opacity-0 group-hover/bar:rf-opacity-100 rf-transition-opacity rf-absolute rf-bottom-full rf-left-1/2 rf-transform -rf-translate-x-1/2 rf-mb-2 rf-px-2 rf-py-1 rf-text-xs rf-whitespace-nowrap rf-rounded rf-bg-gray-900 rf-text-white rf-pointer-events-none",children:[t,": ",n.toFixed(1),"ms"]})},t)})}),We.jsxs("div",{className:"rf-text-xs rf-text-gray-500",children:["Total: ",e.toFixed(2),"ms"]})]})},lbn=({renderLog:i})=>{const[e,t]=pt.useState("chronological");if(!i)return We.jsx("div",{className:"rf-p-4 rf-bg-gray-100 rf-rounded-md",children:"No render log, make sure this tab is open when you render (TODO add a rerender button here)"});const n=Object.entries((i==null?void 0:i.phaseTimings)??{});e==="chronological"?n.sort((a,o)=>Gb.indexOf(a[0])-Gb.indexOf(o[0])):n.sort((a,o)=>o[1]-a[1]);const r=n.reduce((a,[o,s])=>a+s,0);return We.jsxs("div",{className:"rf-bg-white",children:[We.jsxs("div",{className:"rf-flex rf-justify-between rf-items-center",children:[We.jsx("div",{children:"Render Logs"}),We.jsxs("div",{className:"rf-mb-4 rf-pr-2 rf-flex rf-text-xs rf-items-center",children:[We.jsx("div",{className:"rf-mr-2",children:"Sort by:"}),We.jsxs("select",{value:e,onChange:a=>t(a.target.value),className:"rf-px-2 rf-py-1 rf-border rf-rounded rf-text-xs",children:[We.jsx("option",{value:"chronological",children:"Phase Order"}),We.jsx("option",{value:"longest",children:"Duration"})]})]})]}),We.jsx(sbn,{phaseTimings:i.phaseTimings}),We.jsxs("table",{className:"rf-w-full rf-text-xs",children:[We.jsx("thead",{children:We.jsxs("tr",{children:[We.jsx("th",{className:"rf-text-left rf-p-2",children:"Phase Order"}),We.jsx("th",{className:"rf-text-left rf-p-2",children:"Phase"}),We.jsx("th",{className:"rf-text-left rf-p-2",children:"Duration (ms)"})]})}),We.jsx("tbody",{children:n.map(([a,o])=>We.jsxs("tr",{children:[We.jsx("td",{className:"rf-p-2",children:Gb.indexOf(a)}),We.jsx("td",{className:"rf-p-2",children:a}),We.jsx("td",{className:"rf-p-2",children:We.jsx("div",{className:"rf-w-8",children:We.jsx("div",{className:"rf-h-2 rf-rounded-sm",style:{backgroundColor:Tot(a),width:`${o/r*100}%`}})})}),We.jsx("td",{className:"rf-p-2",children:We.jsxs("div",{className:"rf-flex w-full",children:[We.jsxs("span",{className:"rf-flex-grow",children:[o,"ms"]}),We.jsxs("span",{className:"rf-text-gray-500 rf-pr-2",children:[(o/r*100).toFixed(1),"%"]})]})})]},a))})]})]})},Pot=({errorMessage:i,errorStack:e,circuitJsonErrors:t})=>{pt.useEffect(()=>{if(i){const n=new Error(i);e&&(n.stack=e);try{wO.captureException(n)}catch{}}},[i,e]),pt.useEffect(()=>{if(t&&t.length>0)for(const n of t){const r=new Error(n.message||"Circuit JSON Error");n.stack&&(r.stack=n.stack);try{wO.captureException(r,{error_type:n.type})}catch{}}},[t])},cbn="0.0.669",Nve=XRe()(ZRe(i=>({lastRunEvalVersion:void 0,setLastRunEvalVersion:e=>{i({lastRunEvalVersion:e})}}),{name:"runframe-runner-store"})),ubn=["assembly","bom","circuit_json","errors","render_log"],dbn=({code:i,onRunClicked:e=void 0,errorMessage:t,errorStack:n,circuitJson:r,autoroutingGraphics:a,showRightHeaderContent:o=!0,showCodeTab:s=!1,codeTabContent:l,showJsonTab:c=!0,showRenderLogTab:u=!0,onActiveTabChange:f,renderLog:h,showImportAndFormatButtons:p=!0,className:y,headerClassName:_,leftHeaderContent:I,readOnly:C,isStreaming:b,autoroutingLog:w,onReportAutoroutingLog:N,isRunningCode:V,hasCodeChangedSinceLastRun:z,onEditEvent:K,editEvents:G,defaultActiveTab:q,autoRotate3dViewerDisabled:Y,showSchematicDebugGrid:oe=!1,showToggleFullScreen:W=!0,defaultToFullScreen:re=!1,activeEffectName:fe})=>{var Tt;abn();const Ae=Nve(mt=>mt.lastRunEvalVersion),ce=pt.useMemo(()=>r?r.filter(mt=>mt&&"error_type"in mt||mt.type.includes("error")):null,[r]),xe=pt.useMemo(()=>r?r.filter(mt=>mt&&"warning_type"in mt||mt.type.includes("warning")):null,[r]);Pot({errorMessage:t,errorStack:n,circuitJsonErrors:ce});const[me,Re]=pt.useState(q??"pcb"),[we,Te]=pt.useState(null),[Be,je]=pt.useState(re);obn(Be);const Xe=pt.useCallback(mt=>{Re(mt),f==null||f(mt)},[f]),ot=()=>{je(!Be)};pt.useEffect(()=>{t&&(me!=="errors"&&Te(me),Xe("errors"))},[t]),pt.useEffect(()=>{(me==="code"||me==="errors")&&r&&!t&&Xe(we??q??"pcb")},[r]);const ft=pt.useCallback(mt=>{window.TSCIRCUIT_3D_OBJECT_REF=mt===null?void 0:mt},[]);return We.jsx("div",{className:Km("flex flex-col relative rf-overflow-x-hidden rf-h-full",y),children:We.jsx("div",{className:Km("rf-md:sticky rf-md:top-2 rf-h-full",Be&&"rf-fixed rf-top-0 rf-left-0 rf-w-full rf-h-full rf-bg-white rf-overflow-hidden"),children:We.jsxs(Gre,{value:me,onValueChange:Xe,className:"rf-flex-grow rf-flex rf-flex-col rf-h-full",children:[We.jsxs("div",{className:Km("rf-flex rf-items-center rf-gap-2 rf-p-2 rf-pb-0",_),children:[I,I&&We.jsx("div",{className:"rf-flex-grow"}),!I&&V&&We.jsx(oQ,{className:"rf-w-4 rf-h-4 rf-animate-spin"}),!I&&We.jsx("div",{className:"rf-flex-grow"}),h&&h.progress!==1&&!t&&We.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2",children:[fe?We.jsx("div",{className:"rf-text-xs rf-text-gray-500",children:fe}):h.lastRenderEvent&&We.jsx("div",{className:"rf-text-xs rf-text-gray-500",children:((Tt=h.lastRenderEvent)==null?void 0:Tt.phase)??""}),We.jsx("div",{className:"rf-w-4 rf-h-4 rf-bg-blue-500 rf-opacity-50 rf-rounded-full rf-text-white",children:We.jsx(oQ,{className:"rf-w-4 rf-h-4 rf-animate-spin"})}),We.jsxs("div",{className:"rf-text-xs rf-font-bold rf-text-gray-700 rf-tabular-nums",children:[((h.progress??0)*100).toFixed(1),"%"]})]}),o&&We.jsxs(MO,{children:[s&&We.jsx(IB,{value:"code",children:"Code"}),We.jsxs(IB,{value:"pcb",className:"rf-whitespace-nowrap",children:[r&&We.jsx("span",{className:Km("rf-inline-flex rf-items-center rf-justify-center rf-w-2 rf-h-2 rf-mr-1 rf-text-xs rf-font-bold rf-text-white rf-rounded-full",z?"rf-bg-gray-500":"rf-bg-blue-500")}),"PCB"]}),We.jsxs(IB,{value:"schematic",className:"rf-whitespace-nowrap",children:[r&&We.jsx("span",{className:Km("rf-inline-flex rf-items-center rf-justify-center rf-w-2 rf-h-2 rf-mr-1 rf-text-xs rf-font-bold rf-text-white rf-rounded-full",z?"rf-bg-gray-500":"rf-bg-blue-500")}),"Schematic"]}),We.jsxs(IB,{value:"cad",children:[r&&We.jsx("span",{className:Km("inline-flex items-center justify-center w-2 h-2 mr-1 text-xs font-bold text-white rounded-full",z?"rf-bg-gray-500":"rf-bg-blue-500")}),"3D"]}),!["pcb","cad","schematic"].includes(me)&&We.jsx(IB,{value:me,children:j8e(me)}),We.jsxs(Pme,{children:[We.jsx(kme,{asChild:!0,children:We.jsxs("div",{className:"rf-whitespace-nowrap rf-p-2 rf-mr-1 rf-cursor-pointer rf-relative",children:[We.jsx(w0n,{className:"rf-w-4 rf-h-4"}),(ce&&ce.length>0||t)&&We.jsx("span",{className:"rf-inline-flex rf-absolute rf-top-[6px] rf-right-[4px] rf-items-center rf-justify-center rf-w-1 rf-h-1 rf-ml-2 rf-text-[8px] rf-font-bold rf-text-white rf-bg-red-500 rf-rounded-full"})]})}),We.jsxs(aj,{className:"rf-*:text-xs",children:[ubn.map(mt=>We.jsxs(DS,{onSelect:()=>Xe(mt),children:[me!==mt&&We.jsx(set,{className:"rf-w-3 rf-h-3 rf-opacity-30"}),me===mt&&We.jsx(zge,{className:"rf-w-3 rf-h-3"}),We.jsx("div",{className:"rf-pr-2",children:j8e(mt)}),mt==="errors"&&(ce&&ce.length>0||t)&&We.jsx("span",{className:"rf-inline-flex rf-items-center rf-justify-center rf-w-3 rf-h-3 rf-ml-2 rf-text-[8px] rf-font-bold rf-text-white rf-bg-red-500 rf-rounded-full",children:t?1:ce==null?void 0:ce.length})]},mt)),We.jsx(DS,{disabled:!0,className:"rf-opacity-60 rf-cursor-default rf-select-none",children:We.jsxs("div",{className:"rf-pr-2 rf-text-xs rf-text-gray-500",children:["@tscircuit/runframe@",cbn.split(".").map((mt,ze)=>ze===2?parseInt(mt)+1:mt).join(".")]})}),Ae&&We.jsx(DS,{disabled:!0,className:"rf-opacity-60 rf-cursor-default rf-select-none",children:We.jsxs("div",{className:"rf-pr-2 rf-text-xs rf-text-gray-500",children:["@tscircuit/eval@",Ae]})})]})]})]}),W&&We.jsx(F9,{onClick:ot,variant:"ghost",children:Be?We.jsx(D0n,{size:16}):We.jsx(Q0n,{size:16})})]}),s&&We.jsx(WS,{value:"code",className:"rf-flex-grow rf-overflow-hidden",children:We.jsx("div",{className:"rf-h-full",children:l})}),We.jsx(WS,{value:"pcb",children:We.jsx("div",{className:Km("rf-overflow-hidden",Be?"rf-h-[calc(100vh-52px)]":"rf-h-full"),children:We.jsx(oN,{fallbackRender:({error:mt})=>We.jsx("div",{className:"rf-mt-4 rf-bg-red-50 rf-rounded-md rf-border rf-border-red-200",children:We.jsxs("div",{className:"rf-p-4",children:[We.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-red-800 rf-mb-3",children:"Error loading PCB viewer"}),We.jsx("p",{className:"rf-text-xs rf-font-mono rf-whitespace-pre-wrap rf-text-red-600 rf-mt-2",children:(mt==null?void 0:mt.message)||"An unknown error occurred"})]})}),children:r?We.jsx(ibn,{focusOnHover:!1,circuitJson:r,debugGraphics:a,containerClassName:Km("rf-h-full rf-w-full",Be?"rf-min-h-[calc(100vh-240px)]":"rf-min-h-[620px]"),onEditEventsChanged:mt=>{K&&mt.forEach(ze=>K(ze))}}):We.jsx(dQ,{onRunClicked:e})})})}),We.jsx(WS,{value:"assembly",children:We.jsx("div",{className:Km("rf-overflow-auto",Be?"rf-h-screen":"rf-h-full rf-min-h-[620px]"),children:We.jsx(oN,{fallback:We.jsx("div",{children:"Error loading Assembly"}),children:r?We.jsx(r_n,{circuitJson:r,containerStyle:{height:"100%"},editingEnabled:!0,debugGrid:!0}):We.jsx(dQ,{onRunClicked:e})})})}),We.jsx(WS,{value:"schematic",children:We.jsx("div",{className:Km("rf-overflow-auto rf-bg-white",Be?"rf-h-screen":"rf-h-full rf-min-h-[620px]"),children:We.jsx(oN,{fallbackRender:({error:mt})=>We.jsx("div",{className:"rf-mt-4 rf-bg-red-50 rf-rounded-md rf-border rf-border-red-200",children:We.jsxs("div",{className:"rf-p-4",children:[We.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-red-800 rf-mb-3",children:"Error loading Schematic"}),We.jsx("p",{className:"rf-text-xs rf-font-mono rf-whitespace-pre-wrap rf-text-red-600 rf-mt-2",children:(mt==null?void 0:mt.message)||"An unknown error occurred"})]})}),children:r?We.jsx(t_n,{circuitJson:r,containerStyle:{height:"100%"},editingEnabled:!0,onEditEvent:mt=>{K==null||K(mt)},debugGrid:oe}):We.jsx(dQ,{onRunClicked:e})})})}),We.jsx(WS,{value:"cad",children:We.jsx("div",{className:Km("rf-overflow-auto",Be?"rf-h-screen":"rf-h-full rf-min-h-[620px]"),children:We.jsx(oN,{FallbackComponent:g0n,children:r?We.jsx(h0n,{ref:ft,circuitJson:r,autoRotateDisabled:Y}):We.jsx(dQ,{onRunClicked:e})})})}),We.jsx(WS,{value:"bom",children:We.jsx("div",{className:Km("rf-overflow-auto",Be?"rf-h-screen":"rf-h-full rf-min-h-[620px]"),children:We.jsx(oN,{fallbackRender:({error:mt})=>We.jsx("div",{className:"rf-mt-4 rf-bg-red-50 rf-rounded-md rf-border rf-border-red-200",children:We.jsxs("div",{className:"rf-p-4",children:[We.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-red-800 rf-mb-3",children:"Error loading Bill of Materials"}),We.jsx("p",{className:"rf-text-xs rf-font-mono rf-whitespace-pre-wrap rf-text-red-600 rf-mt-2",children:(mt==null?void 0:mt.message)||"An unknown error occurred"})]})}),children:r?We.jsx(c_n,{circuitJson:r}):We.jsx(dQ,{onRunClicked:e})})})}),We.jsx(WS,{value:"circuit_json",children:We.jsx("div",{className:Km("rf-overflow-auto",Be?"rf-h-screen":"rf-h-full rf-min-h-[620px]"),children:We.jsx(oN,{fallback:We.jsx("div",{children:"Error loading JSON viewer"}),children:r?We.jsx(s_n,{elements:r}):We.jsx(dQ,{onRunClicked:e})})})}),We.jsx(WS,{value:"errors",children:We.jsx("div",{className:Km("rf-overflow-auto",Be?"rf-h-screen":"rf-h-full rf-min-h-[620px]"),children:t||ce&&ce.length>0||r?We.jsx(Svn,{code:i,circuitJsonErrors:ce,circuitJsonWarnings:xe,errorMessage:t,errorStack:n,circuitJson:r,evalVersion:Ae,autoroutingLog:w,onReportAutoroutingLog:N}):We.jsx(dQ,{onRunClicked:e})})}),u&&We.jsx(WS,{value:"render_log",children:We.jsx(lbn,{renderLog:h})})]})})})};var rK="Dialog",[kot,Uot]=w5(rK),[fbn,G2]=kot(rK),Lot=i=>{const{__scopeDialog:e,children:t,open:n,defaultOpen:r,onOpenChange:a,modal:o=!0}=i,s=pt.useRef(null),l=pt.useRef(null),[c,u]=MR({prop:n,defaultProp:r??!1,onChange:a,caller:rK});return We.jsx(fbn,{scope:e,triggerRef:s,contentRef:l,contentId:M5(),titleId:M5(),descriptionId:M5(),open:c,onOpenChange:u,onOpenToggle:pt.useCallback(()=>u(f=>!f),[u]),modal:o,children:t})};Lot.displayName=rK;var Fot="DialogTrigger",Got=pt.forwardRef((i,e)=>{const{__scopeDialog:t,...n}=i,r=G2(Fot,t),a=k9(e,r.triggerRef);return We.jsx(iC.button,{type:"button","aria-haspopup":"dialog","aria-expanded":r.open,"aria-controls":r.contentId,"data-state":kve(r.open),...n,ref:a,onClick:Qm(i.onClick,r.onOpenToggle)})});Got.displayName=Fot;var Tve="DialogPortal",[Abn,Oot]=kot(Tve,{forceMount:void 0}),zot=i=>{const{__scopeDialog:e,forceMount:t,children:n,container:r}=i,a=G2(Tve,e);return We.jsx(Abn,{scope:e,forceMount:t,children:pt.Children.map(n,o=>We.jsx(hB,{present:t||a.open,children:We.jsx(vme,{asChild:!0,container:r,children:o})}))})};zot.displayName=Tve;var aK="DialogOverlay",Hot=pt.forwardRef((i,e)=>{const t=Oot(aK,i.__scopeDialog),{forceMount:n=t.forceMount,...r}=i,a=G2(aK,i.__scopeDialog);return a.modal?We.jsx(hB,{present:n||a.open,children:We.jsx(pbn,{...r,ref:e})}):null});Hot.displayName=aK;var hbn=wR("DialogOverlay.RemoveScroll"),pbn=pt.forwardRef((i,e)=>{const{__scopeDialog:t,...n}=i,r=G2(aK,t);return We.jsx(bme,{as:hbn,allowPinchZoom:!0,shards:[r.contentRef],children:We.jsx(iC.div,{"data-state":kve(r.open),...n,ref:e,style:{pointerEvents:"auto",...n.style}})})}),_Q="DialogContent",Yot=pt.forwardRef((i,e)=>{const t=Oot(_Q,i.__scopeDialog),{forceMount:n=t.forceMount,...r}=i,a=G2(_Q,i.__scopeDialog);return We.jsx(hB,{present:n||a.open,children:a.modal?We.jsx(gbn,{...r,ref:e}):We.jsx(mbn,{...r,ref:e})})});Yot.displayName=_Q;var gbn=pt.forwardRef((i,e)=>{const t=G2(_Q,i.__scopeDialog),n=pt.useRef(null),r=k9(e,t.contentRef,n);return pt.useEffect(()=>{const a=n.current;if(a)return Att(a)},[]),We.jsx(Vot,{...i,ref:r,trapFocus:t.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Qm(i.onCloseAutoFocus,a=>{var o;a.preventDefault(),(o=t.triggerRef.current)==null||o.focus()}),onPointerDownOutside:Qm(i.onPointerDownOutside,a=>{const o=a.detail.originalEvent,s=o.button===0&&o.ctrlKey===!0;(o.button===2||s)&&a.preventDefault()}),onFocusOutside:Qm(i.onFocusOutside,a=>a.preventDefault())})}),mbn=pt.forwardRef((i,e)=>{const t=G2(_Q,i.__scopeDialog),n=pt.useRef(!1),r=pt.useRef(!1);return We.jsx(Vot,{...i,ref:e,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:a=>{var o,s;(o=i.onCloseAutoFocus)==null||o.call(i,a),a.defaultPrevented||(n.current||(s=t.triggerRef.current)==null||s.focus(),a.preventDefault()),n.current=!1,r.current=!1},onInteractOutside:a=>{var l,c;(l=i.onInteractOutside)==null||l.call(i,a),a.defaultPrevented||(n.current=!0,a.detail.originalEvent.type==="pointerdown"&&(r.current=!0));const o=a.target;((c=t.triggerRef.current)==null?void 0:c.contains(o))&&a.preventDefault(),a.detail.originalEvent.type==="focusin"&&r.current&&a.preventDefault()}})}),Vot=pt.forwardRef((i,e)=>{const{__scopeDialog:t,trapFocus:n,onOpenAutoFocus:r,onCloseAutoFocus:a,...o}=i,s=G2(_Q,t),l=pt.useRef(null),c=k9(e,l);return wet(),We.jsxs(We.Fragment,{children:[We.jsx(rme,{asChild:!0,loop:!0,trapped:n,onMountAutoFocus:r,onUnmountAutoFocus:a,children:We.jsx(eme,{role:"dialog",id:s.contentId,"aria-describedby":s.descriptionId,"aria-labelledby":s.titleId,"data-state":kve(s.open),...o,ref:c,onDismiss:()=>s.onOpenChange(!1)})}),We.jsxs(We.Fragment,{children:[We.jsx(vbn,{titleId:s.titleId}),We.jsx(Ibn,{contentRef:l,descriptionId:s.descriptionId})]})]})}),Pve="DialogTitle",jot=pt.forwardRef((i,e)=>{const{__scopeDialog:t,...n}=i,r=G2(Pve,t);return We.jsx(iC.h2,{id:r.titleId,...n,ref:e})});jot.displayName=Pve;var Kot="DialogDescription",Jot=pt.forwardRef((i,e)=>{const{__scopeDialog:t,...n}=i,r=G2(Kot,t);return We.jsx(iC.p,{id:r.descriptionId,...n,ref:e})});Jot.displayName=Kot;var qot="DialogClose",Xot=pt.forwardRef((i,e)=>{const{__scopeDialog:t,...n}=i,r=G2(qot,t);return We.jsx(iC.button,{type:"button",...n,ref:e,onClick:Qm(i.onClick,()=>r.onOpenChange(!1))})});Xot.displayName=qot;function kve(i){return i?"open":"closed"}var Zot="DialogTitleWarning",[ybn,Wot]=Y7t(Zot,{contentName:_Q,titleName:Pve,docsSlug:"dialog"}),vbn=({titleId:i})=>{const e=Wot(Zot),t=`\`${e.contentName}\` requires a \`${e.titleName}\` for the component to be accessible for screen reader users.
13749
+ `,onClick:n=>{n.stopPropagation(),t()},children:[We.jsx("input",{type:"checkbox",checked:e}),We.jsx("span",{style:{color:"#eee"},children:i})]}),$En=({children:i,elements:e})=>{const[t,n]=lx(G=>[G.is_mouse_over_container,G.setIsMouseOverContainer]),[r,a]=pt.useState(!1),[o,s]=pt.useState(!1),[l,c]=pt.useState(!1),[u,f]=lx(G=>[G.selected_layer,G.selectLayer]),[h,p,y,_,I,C]=lx(G=>[G.in_move_footprint_mode,G.in_draw_trace_mode,G.is_showing_rats_nest,G.is_showing_multiple_traces_length,G.is_showing_autorouting,G.is_showing_drc_errors]),b=lx(G=>G.setEditMode),w=lx(G=>G.setIsShowingRatsNest),N=lx(G=>G.setIsShowingMultipleTracesLength),V=lx(G=>G.setIsShowingAutorouting),z=lx(G=>G.setIsShowingDrcErrors);$w("1",()=>f("top")),$w("2",()=>f("bottom")),$w("3",()=>f("inner1")),$w("4",()=>f("inner2")),$w("5",()=>f("inner3")),$w("6",()=>f("inner4")),$w("7",()=>f("inner5")),$w("8",()=>f("inner6"));const K=(e==null?void 0:e.filter(G=>G.type.includes("error")).length)??0;return We.jsxs("div",{style:{position:"relative"},onMouseEnter:()=>{n(!0)},onMouseLeave:G=>{n(!1),s(!1)},children:[i,We.jsxs("div",{style:{position:"absolute",bottom:4,right:8,pointerEvents:"none",color:"white",fontSize:11,opacity:t?.5:0,transition:"opacity 1s",transitionDelay:"2s",fontFamily:"sans-serif"},children:["@tscircuit/pcb-viewer@",ZEn.version]}),We.jsxs("div",{style:{position:"absolute",opacity:t?1:0,top:16,left:16,transition:t?"opacity 100ms linear":"opacity 1s linear",zIndex:eb.toolbarOverlay,color:"red",display:"flex",fontSize:12,height:100,fontFamily:"sans-serif"},children:[We.jsxs(QN,{onClick:()=>{s(!o)},onMouseLeave:()=>{o&&s(!1)},children:[We.jsxs("div",{children:["layer:"," ",We.jsx("span",{style:{marginLeft:2,fontWeight:500,color:MN[u]},children:u})]}),o&&We.jsx("div",{style:{marginTop:4,minWidth:120},children:Sve.map(G=>G.replace(/-/g,"")).map(G=>We.jsx(WEn,{name:G,selected:G===u,onClick:()=>{f(G.replace(/-/,""))}},G))})]}),We.jsxs(QN,{style:K>0?{color:"red"}:{},onClick:()=>c(!l),onMouseLeave:()=>c(!1),children:[We.jsxs("div",{children:[K," errors"]}),l&&We.jsx("div",{style:{display:"grid",gridTemplateColumns:"100px 300px"},children:e==null?void 0:e.filter(G=>G.type.includes("error")).map((G,q)=>We.jsxs(pt.Fragment,{children:[We.jsx("div",{children:G.error_type}),We.jsx("div",{children:G.message})]},q))})]}),We.jsx(QN,{style:{},onClick:()=>{b(p?"off":"draw_trace")},children:We.jsxs("div",{children:[p?"✖ ":"","Edit Traces"]})}),We.jsx(QN,{style:{},onClick:()=>{b(h?"off":"move_footprint")},children:We.jsxs("div",{children:[h?"✖ ":"","Move Components"]})}),We.jsx(QN,{style:{},onClick:()=>{w(!y)},children:We.jsxs("div",{children:[y?"✖ ":"","Rats Nest"]})}),We.jsx(QN,{onClick:()=>{a(!r)},children:We.jsxs("div",{children:[We.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"4px"},children:["View"," ",We.jsx("span",{style:{fontSize:"8px",transform:r?"rotate(180deg)":"rotate(0)",transition:"transform 0.1s ease",display:"inline-block"},children:"▼"})]}),r&&We.jsxs("div",{style:{marginTop:4,minWidth:120},children:[We.jsx(Dve,{label:"Show All Trace Lengths",checked:_,onClick:()=>{N(!_)}}),We.jsx(Dve,{label:"Show Autorouting Animation",checked:I,onClick:()=>{V(!I)}}),We.jsx(Dve,{label:"Show DRC Errors",checked:C,onClick:()=>{z(!C)}})]})]})})]})]})},ebn=i=>{const{transform:e,elements:t}=i,[n,r]=pt.useMemo(()=>{const c=i.elements.flatMap(f=>dEn(f,i.elements)),u=x5(i.elements);return[c,u]},[i.elements]),[a,o]=pt.useState({drawingObjectIdsWithMouseOver:new Set,primitiveIdsInMousedOverNet:[]}),s=pt.useMemo(()=>cEn({primitivesWithoutInteractionMetadata:n,drawingObjectIdsWithMouseOver:a.drawingObjectIdsWithMouseOver,primitiveIdsInMousedOverNet:a.primitiveIdsInMousedOverNet}),[n,a]),l=pt.useCallback(c=>{var h,p;const u=[];for(const y of c)if(y._element){const _=r.getNetConnectedToId("pcb_port_id"in y._element?(h=y._element)==null?void 0:h.pcb_port_id:"pcb_trace_id"in y._element?(p=y._element)==null?void 0:p.pcb_trace_id:"");u.push(...r.getIdsConnectedToNet(_))}const f=new Set(c.map(y=>y._pcb_drawing_object_id));o({drawingObjectIdsWithMouseOver:f,primitiveIdsInMousedOverNet:u})},[r]);return We.jsx(qEn,{elements:t,transform:e,primitives:n,onMouseHoverOverPrimitives:l,children:We.jsx(DEn,{disabled:!i.allowEditing,transform:e,soup:t,cancelPanDrag:i.cancelPanDrag,onCreateEditEvent:i.onCreateEditEvent,onModifyEditEvent:i.onModifyEditEvent,children:We.jsx(kEn,{disabled:!i.allowEditing,transform:e,soup:t,cancelPanDrag:i.cancelPanDrag,onCreateEditEvent:i.onCreateEditEvent,onModifyEditEvent:i.onModifyEditEvent,children:We.jsx(QEn,{transform:e,focusOnHover:i.focusOnHover,children:We.jsx($En,{elements:t,children:We.jsx(FEn,{transform:e,elements:t,children:We.jsx(XEn,{transform:e,soup:t,children:We.jsx(wEn,{transform:e,debugGraphics:i.debugGraphics,children:We.jsx(MEn,{transform:e,elements:t,children:We.jsx(BEn,{transform:e,primitives:s,width:i.width,height:i.height,grid:i.grid})})})})})})})})})})},tbn=Gh(P0(400,300),vx(40,-40)),nbn=({circuitJson:i,debugGraphics:e,height:t=600,initialState:n,allowEditing:r=!0,editEvents:a,onEditEventsChanged:o,focusOnHover:s=!1,clickToInteractEnabled:l=!1})=>{const[c,u]=pt.useState(!l),[f,h]=Qve(),[p,y]=pt.useState(tbn),{ref:_,setTransform:I,cancelDrag:C}=lEn({transform:p,onSetTransform:y,enabled:c});let[b,w]=pt.useState([]);b=a??b;const N=pt.useRef(!1),V=pt.useRef(null),z=`${(i==null?void 0:i.length)||0}_${(i==null?void 0:i.editCount)||0}`,K=()=>{const W=(h==null?void 0:h.width)>0?h:{width:500,height:500},{center:re,width:fe,height:Ae}=q.some(me=>me.type.startsWith("pcb_"))?Wxn(q.filter(me=>me.type.startsWith("pcb_"))):{center:{x:0,y:0},width:.001,height:.001},ce=Math.min((W.width??0)/fe,(W.height??0)/Ae,100)*.75,xe=Gh(P0((W.width??0)/2,(W.height??0)/2),vx(ce,-ce,0,0),P0(-re.x,-re.y));I(xe)};pt.useEffect(()=>{h!=null&&h.width&&i&&i.length!==0&&(N.current||(K(),N.current=!0))},[i,h]);const G=pt.useMemo(()=>(i==null?void 0:i.filter(W=>W.type.startsWith("pcb_")||W.type.startsWith("source_")))??[],[z]),q=pt.useMemo(()=>dIn({circuitJson:G,editEvents:b}),[G,b]),Y=W=>{w([...b,W]),o==null||o([...b,W])},oe=W=>{const re=b.map(fe=>fe.edit_event_id===W.edit_event_id?{...fe,...W}:fe);w(re),o==null||o(re)};return We.jsxs("div",{ref:_,style:{position:"relative"},children:[We.jsx("div",{ref:f,children:We.jsxs(eEn,{initialState:n,children:[We.jsx(ebn,{transform:p,height:t,width:h.width,allowEditing:r,focusOnHover:s,cancelPanDrag:C,onCreateEditEvent:Y,onModifyEditEvent:oe,grid:{spacing:1,view_window:{left:0,right:h.width||500,top:t,bottom:0}},elements:q,debugGraphics:e},h.width),We.jsx(nEn,{})]})}),l&&!c&&We.jsx("div",{onClick:()=>{u(!0),K()},onTouchStart:W=>{const re=W.touches[0];V.current={x:re.clientX,y:re.clientY}},onTouchEnd:W=>{const re=W.changedTouches[0],fe=V.current;if(!fe)return;const Ae=Math.abs(re.clientX-fe.x),ce=Math.abs(re.clientY-fe.y);Ae<10&&ce<10&&(W.preventDefault(),u(!0),K()),V.current=null},style:{position:"absolute",inset:0,cursor:"pointer",zIndex:eb.clickToInteractOverlay,display:"flex",alignItems:"center",justifyContent:"center",touchAction:"pan-x pan-y pinch-zoom"},children:We.jsx("div",{style:{backgroundColor:"rgba(0, 0, 0, 0.8)",color:"white",padding:"12px 24px",borderRadius:"8px",fontSize:"16px",pointerEvents:"none"},children:typeof window<"u"&&("ontouchstart"in window||navigator.maxTouchPoints>0)?"Touch to Interact":"Click to Interact"})})]})};const ibn=({containerClassName:i,...e})=>{const t=pt.useRef(null),[n,r]=pt.useState(620);return pt.useLayoutEffect(()=>{const a=()=>{if(t.current){const s=t.current.clientHeight,l=window.innerHeight;r(Math.min(Math.max(s,620),l))}};a();const o=new ResizeObserver(a);return t.current&&o.observe(t.current),window.addEventListener("resize",a),()=>{o.disconnect(),window.removeEventListener("resize",a)}},[]),We.jsx("div",{ref:t,className:i||"rf-w-full rf-h-full",children:We.jsx(nbn,{...e,height:n})})},rbn='*,:after,:before{--tw-border-spacing-x:0;--tw-border-spacing-y:0;--tw-translate-x:0;--tw-translate-y:0;--tw-rotate:0;--tw-skew-x:0;--tw-skew-y:0;--tw-scale-x:1;--tw-scale-y:1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness:proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:rgba(59,130,246,.5);--tw-ring-offset-shadow:0 0 #0000;--tw-ring-shadow:0 0 #0000;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }::backdrop{--tw-border-spacing-x:0;--tw-border-spacing-y:0;--tw-translate-x:0;--tw-translate-y:0;--tw-rotate:0;--tw-skew-x:0;--tw-skew-y:0;--tw-scale-x:1;--tw-scale-y:1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness:proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:rgba(59,130,246,.5);--tw-ring-offset-shadow:0 0 #0000;--tw-ring-shadow:0 0 #0000;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }/*! tailwindcss v3.4.17 | MIT License | https://tailwindcss.com*/*,:after,:before{border:0 solid #e5e7eb;box-sizing:border-box}:after,:before{--tw-content:""}:host,html{line-height:1.5;-webkit-text-size-adjust:100%;font-family:ui-sans-serif,system-ui,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;font-feature-settings:normal;font-variation-settings:normal;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-tap-highlight-color:transparent}body{line-height:inherit;margin:0}hr{border-top-width:1px;color:inherit;height:0}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,pre,samp{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace;font-feature-settings:normal;font-size:1em;font-variation-settings:normal}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}table{border-collapse:collapse;border-color:inherit;text-indent:0}button,input,optgroup,select,textarea{color:inherit;font-family:inherit;font-feature-settings:inherit;font-size:100%;font-variation-settings:inherit;font-weight:inherit;letter-spacing:inherit;line-height:inherit;margin:0;padding:0}button,select{text-transform:none}button,input:where([type=button]),input:where([type=reset]),input:where([type=submit]){-webkit-appearance:button;background-color:transparent;background-image:none}:-moz-focusring{outline:auto}:-moz-ui-invalid{box-shadow:none}progress{vertical-align:baseline}::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}summary{display:list-item}blockquote,dd,dl,figure,h1,h2,h3,h4,h5,h6,hr,p,pre{margin:0}fieldset{margin:0}fieldset,legend{padding:0}menu,ol,ul{list-style:none;margin:0;padding:0}dialog{padding:0}textarea{resize:vertical}input::-moz-placeholder,textarea::-moz-placeholder{color:#9ca3af;opacity:1}input::placeholder,textarea::placeholder{color:#9ca3af;opacity:1}[role=button],button{cursor:pointer}:disabled{cursor:default}audio,canvas,embed,iframe,img,object,svg,video{display:block;vertical-align:middle}img,video{height:auto;max-width:100%}[hidden]:where(:not([hidden=until-found])){display:none}:root{--radius:0.5rem}.rf-pointer-events-none{pointer-events:none}.rf-invisible{visibility:hidden}.rf-fixed{position:fixed}.rf-absolute{position:absolute}.rf-relative{position:relative}.rf-inset-0{inset:0}.-rf-left-2{left:-.5rem}.-rf-right-10{right:-2.5rem}.-rf-right-2{right:-.5rem}.-rf-right-4{right:-1rem}.-rf-right-6{right:-1.5rem}.-rf-right-7{right:-1.75rem}.-rf-right-8{right:-2rem}.-rf-right-9{right:-2.25rem}.rf-bottom-full{bottom:100%}.rf-left-0{left:0}.rf-left-1{left:.25rem}.rf-left-1\\/2{left:50%}.rf-left-2{left:.5rem}.rf-left-\\[50\\%\\]{left:50%}.rf-right-0{right:0}.rf-right-4{right:1rem}.rf-right-\\[4px\\]{right:4px}.rf-top-0{top:0}.rf-top-1{top:.25rem}.rf-top-2{top:.5rem}.rf-top-2\\.5{top:.625rem}.rf-top-\\[50\\%\\]{top:50%}.rf-top-\\[6px\\]{top:6px}.\\!rf-z-\\[101\\]{z-index:101!important}.rf-z-50{z-index:50}.rf-z-\\[100\\]{z-index:100}.-rf-mx-1,.rf--mx-1{margin-left:-.25rem;margin-right:-.25rem}.rf-mx-1{margin-left:.25rem;margin-right:.25rem}.rf-mx-2{margin-left:.5rem;margin-right:.5rem}.rf-mx-auto{margin-left:auto;margin-right:auto}.rf-my-1{margin-bottom:.25rem;margin-top:.25rem}.rf-my-12{margin-bottom:3rem;margin-top:3rem}.rf-my-4{margin-bottom:1rem;margin-top:1rem}.rf-my-auto{margin-bottom:auto;margin-top:auto}.rf-mb-1{margin-bottom:.25rem}.rf-mb-12{margin-bottom:3rem}.rf-mb-2{margin-bottom:.5rem}.rf-mb-3{margin-bottom:.75rem}.rf-mb-4{margin-bottom:1rem}.rf-mb-6{margin-bottom:1.5rem}.rf-mb-8{margin-bottom:2rem}.rf-ml-1{margin-left:.25rem}.rf-ml-2{margin-left:.5rem}.rf-ml-auto{margin-left:auto}.rf-mr-1{margin-right:.25rem}.rf-mr-2{margin-right:.5rem}.rf-mt-0{margin-top:0}.rf-mt-0\\.5{margin-top:.125rem}.rf-mt-1{margin-top:.25rem}.rf-mt-2{margin-top:.5rem}.rf-mt-3{margin-top:.75rem}.rf-mt-4{margin-top:1rem}.rf-mt-5{margin-top:1.25rem}.rf-mt-auto{margin-top:auto}.rf-block{display:block}.rf-inline{display:inline}.rf-flex{display:flex}.rf-inline-flex{display:inline-flex}.rf-grid{display:grid}.rf-hidden{display:none}.rf-aspect-square{aspect-ratio:1/1}.rf-aspect-video{aspect-ratio:16/9}.rf-size-14{height:3.5rem;width:3.5rem}.rf-size-4{height:1rem;width:1rem}.\\!rf-h-2{height:.5rem!important}.\\!rf-h-2\\.5{height:.625rem!important}.\\!rf-h-3{height:.75rem!important}.\\!rf-h-full{height:100%!important}.rf-h-1{height:.25rem}.rf-h-10{height:2.5rem}.rf-h-12{height:3rem}.rf-h-2{height:.5rem}.rf-h-2\\.5{height:.625rem}.rf-h-3{height:.75rem}.rf-h-3\\.5{height:.875rem}.rf-h-4{height:1rem}.rf-h-5{height:1.25rem}.rf-h-6{height:1.5rem}.rf-h-60{height:15rem}.rf-h-64{height:16rem}.rf-h-8{height:2rem}.rf-h-9{height:2.25rem}.rf-h-\\[400px\\]{height:400px}.rf-h-\\[calc\\(100vh-52px\\)\\]{height:calc(100vh - 52px)}.rf-h-\\[var\\(--radix-select-trigger-height\\)\\]{height:var(--radix-select-trigger-height)}.rf-h-fit{height:-moz-fit-content;height:fit-content}.rf-h-full{height:100%}.rf-h-px{height:1px}.rf-h-screen{height:100vh}.\\!rf-max-h-\\[40vh\\]{max-height:40vh!important}.rf-max-h-32{max-height:8rem}.rf-max-h-96{max-height:24rem}.rf-max-h-\\[500px\\]{max-height:500px}.rf-max-h-\\[90vh\\]{max-height:90vh}.rf-max-h-full{max-height:100%}.rf-min-h-0{min-height:0}.rf-min-h-\\[200px\\]{min-height:200px}.rf-min-h-\\[620px\\]{min-height:620px}.rf-min-h-\\[calc\\(100vh-240px\\)\\]{min-height:calc(100vh - 240px)}.\\!rf-w-2{width:.5rem!important}.\\!rf-w-2\\.5{width:.625rem!important}.rf-w-1{width:.25rem}.rf-w-1\\/2{width:50%}.rf-w-11{width:2.75rem}.rf-w-11\\/12{width:91.666667%}.rf-w-12{width:3rem}.rf-w-16{width:4rem}.rf-w-2{width:.5rem}.rf-w-2\\.5{width:.625rem}.rf-w-3{width:.75rem}.rf-w-3\\.5{width:.875rem}.rf-w-32{width:8rem}.rf-w-4{width:1rem}.rf-w-48{width:12rem}.rf-w-5{width:1.25rem}.rf-w-6{width:1.5rem}.rf-w-64{width:16rem}.rf-w-72{width:18rem}.rf-w-8{width:2rem}.rf-w-9{width:2.25rem}.rf-w-96{width:24rem}.rf-w-\\[95\\%\\]{width:95%}.rf-w-fit{width:-moz-fit-content;width:fit-content}.rf-w-full{width:100%}.rf-min-w-0{min-width:0}.rf-min-w-10{min-width:2.5rem}.rf-min-w-16{min-width:4rem}.rf-min-w-\\[148px\\]{min-width:148px}.rf-min-w-\\[8rem\\]{min-width:8rem}.rf-min-w-\\[var\\(--radix-select-trigger-width\\)\\]{min-width:var(--radix-select-trigger-width)}.\\!rf-max-w-\\[660px\\]{max-width:660px!important}.rf-max-w-2xl{max-width:42rem}.rf-max-w-3xl{max-width:48rem}.rf-max-w-4xl{max-width:56rem}.rf-max-w-5xl{max-width:64rem}.rf-max-w-full{max-width:100%}.rf-max-w-lg{max-width:32rem}.rf-max-w-md{max-width:28rem}.rf-max-w-none{max-width:none}.rf-max-w-xl{max-width:36rem}.rf-flex-1{flex:1 1 0%}.rf-flex-shrink-0,.rf-shrink-0{flex-shrink:0}.rf-flex-grow{flex-grow:1}.rf-table-auto{table-layout:auto}.-rf-translate-x-1{--tw-translate-x:-0.25rem}.-rf-translate-x-1,.-rf-translate-x-1\\/2{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.-rf-translate-x-1\\/2{--tw-translate-x:-50%}.-rf-translate-y-1{--tw-translate-y:-0.25rem}.-rf-translate-y-1,.rf--translate-x-1{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.rf--translate-x-1{--tw-translate-x:-0.25rem}.rf-translate-x-\\[-50\\%\\]{--tw-translate-x:-50%}.rf-translate-x-\\[-50\\%\\],.rf-translate-y-\\[-50\\%\\]{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.rf-translate-y-\\[-50\\%\\]{--tw-translate-y:-50%}.rf-transform{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}@keyframes rf-pulse{50%{opacity:.5}}.rf-animate-pulse{animation:rf-pulse 2s cubic-bezier(.4,0,.6,1) infinite}@keyframes rf-spin{to{transform:rotate(1turn)}}.rf-animate-spin{animation:rf-spin 1s linear infinite}.rf-cursor-default{cursor:default}.rf-cursor-not-allowed{cursor:not-allowed}.rf-cursor-pointer{cursor:pointer}.rf-select-none{-webkit-user-select:none;-moz-user-select:none;user-select:none}.rf-grid-cols-1{grid-template-columns:repeat(1,minmax(0,1fr))}.rf-grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.rf-flex-row{flex-direction:row}.rf-flex-col{flex-direction:column}.rf-flex-col-reverse{flex-direction:column-reverse}.rf-flex-wrap{flex-wrap:wrap}.rf-place-items-center{place-items:center}.rf-items-start{align-items:flex-start}.rf-items-end{align-items:flex-end}.rf-items-center{align-items:center}.rf-justify-end{justify-content:flex-end}.rf-justify-center{justify-content:center}.rf-justify-between{justify-content:space-between}.rf-gap-0{gap:0}.rf-gap-1{gap:.25rem}.rf-gap-2{gap:.5rem}.rf-gap-3{gap:.75rem}.rf-gap-4{gap:1rem}.rf-gap-5{gap:1.25rem}.rf-gap-6{gap:1.5rem}.rf-gap-8{gap:2rem}.rf-space-x-2>:not([hidden])~:not([hidden]){--tw-space-x-reverse:0;margin-left:calc(.5rem*(1 - var(--tw-space-x-reverse)));margin-right:calc(.5rem*var(--tw-space-x-reverse))}.rf-space-y-2>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-bottom:calc(.5rem*var(--tw-space-y-reverse));margin-top:calc(.5rem*(1 - var(--tw-space-y-reverse)))}.rf-space-y-3>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-bottom:calc(.75rem*var(--tw-space-y-reverse));margin-top:calc(.75rem*(1 - var(--tw-space-y-reverse)))}.rf-space-y-4>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-bottom:calc(1rem*var(--tw-space-y-reverse));margin-top:calc(1rem*(1 - var(--tw-space-y-reverse)))}.rf-space-y-6>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-bottom:calc(1.5rem*var(--tw-space-y-reverse));margin-top:calc(1.5rem*(1 - var(--tw-space-y-reverse)))}.rf-divide-y>:not([hidden])~:not([hidden]){--tw-divide-y-reverse:0;border-bottom-width:calc(1px*var(--tw-divide-y-reverse));border-top-width:calc(1px*(1 - var(--tw-divide-y-reverse)))}.rf-overflow-auto{overflow:auto}.rf-overflow-hidden{overflow:hidden}.rf-overflow-visible{overflow:visible}.rf-overflow-x-auto{overflow-x:auto}.\\!rf-overflow-y-auto{overflow-y:auto!important}.rf-overflow-y-auto{overflow-y:auto}.rf-overflow-x-hidden{overflow-x:hidden}.rf-overflow-x-clip{overflow-x:clip}.rf-truncate{overflow:hidden;text-overflow:ellipsis}.rf-truncate,.rf-whitespace-nowrap{white-space:nowrap}.rf-whitespace-pre-wrap{white-space:pre-wrap}.rf-break-words{overflow-wrap:break-word}.rf-rounded{border-radius:.25rem}.rf-rounded-2xl{border-radius:1rem}.rf-rounded-full{border-radius:9999px}.rf-rounded-lg{border-radius:var(--radius)}.rf-rounded-md{border-radius:calc(var(--radius) - 2px)}.rf-rounded-sm{border-radius:calc(var(--radius) - 4px)}.rf-rounded-xl{border-radius:.75rem}.rf-border{border-width:1px}.rf-border-b{border-bottom-width:1px}.rf-border-t{border-top-width:1px}.rf-border-blue-200{--tw-border-opacity:1;border-color:rgb(191 219 254/var(--tw-border-opacity,1))}.rf-border-blue-500{--tw-border-opacity:1;border-color:rgb(59 130 246/var(--tw-border-opacity,1))}.rf-border-blue-600{--tw-border-opacity:1;border-color:rgb(37 99 235/var(--tw-border-opacity,1))}.rf-border-gray-200{--tw-border-opacity:1;border-color:rgb(229 231 235/var(--tw-border-opacity,1))}.rf-border-gray-300{--tw-border-opacity:1;border-color:rgb(209 213 219/var(--tw-border-opacity,1))}.rf-border-green-200{--tw-border-opacity:1;border-color:rgb(187 247 208/var(--tw-border-opacity,1))}.rf-border-input{border-color:hsl(var(--input))}.rf-border-neutral-200{--tw-border-opacity:1;border-color:rgb(229 229 229/var(--tw-border-opacity,1))}.rf-border-orange-200{--tw-border-opacity:1;border-color:rgb(254 215 170/var(--tw-border-opacity,1))}.rf-border-primary{border-color:hsl(var(--primary))}.rf-border-red-200{--tw-border-opacity:1;border-color:rgb(254 202 202/var(--tw-border-opacity,1))}.rf-border-red-500{--tw-border-opacity:1;border-color:rgb(239 68 68/var(--tw-border-opacity,1))}.rf-border-zinc-200{--tw-border-opacity:1;border-color:rgb(228 228 231/var(--tw-border-opacity,1))}.rf-border-zinc-900{--tw-border-opacity:1;border-color:rgb(24 24 27/var(--tw-border-opacity,1))}.rf-bg-background{background-color:hsl(var(--background))}.rf-bg-black{--tw-bg-opacity:1;background-color:rgb(0 0 0/var(--tw-bg-opacity,1))}.rf-bg-black\\/80{background-color:rgba(0,0,0,.8)}.rf-bg-blue-100{--tw-bg-opacity:1;background-color:rgb(219 234 254/var(--tw-bg-opacity,1))}.rf-bg-blue-50{--tw-bg-opacity:1;background-color:rgb(239 246 255/var(--tw-bg-opacity,1))}.rf-bg-blue-500{--tw-bg-opacity:1;background-color:rgb(59 130 246/var(--tw-bg-opacity,1))}.rf-bg-blue-600{--tw-bg-opacity:1;background-color:rgb(37 99 235/var(--tw-bg-opacity,1))}.rf-bg-gray-100{--tw-bg-opacity:1;background-color:rgb(243 244 246/var(--tw-bg-opacity,1))}.rf-bg-gray-200{--tw-bg-opacity:1;background-color:rgb(229 231 235/var(--tw-bg-opacity,1))}.rf-bg-gray-300{--tw-bg-opacity:1;background-color:rgb(209 213 219/var(--tw-bg-opacity,1))}.rf-bg-gray-400{--tw-bg-opacity:1;background-color:rgb(156 163 175/var(--tw-bg-opacity,1))}.rf-bg-gray-50{--tw-bg-opacity:1;background-color:rgb(249 250 251/var(--tw-bg-opacity,1))}.rf-bg-gray-500{--tw-bg-opacity:1;background-color:rgb(107 114 128/var(--tw-bg-opacity,1))}.rf-bg-gray-700{--tw-bg-opacity:1;background-color:rgb(55 65 81/var(--tw-bg-opacity,1))}.rf-bg-gray-800{--tw-bg-opacity:1;background-color:rgb(31 41 55/var(--tw-bg-opacity,1))}.rf-bg-gray-900{--tw-bg-opacity:1;background-color:rgb(17 24 39/var(--tw-bg-opacity,1))}.rf-bg-green-100{--tw-bg-opacity:1;background-color:rgb(220 252 231/var(--tw-bg-opacity,1))}.rf-bg-green-50{--tw-bg-opacity:1;background-color:rgb(240 253 244/var(--tw-bg-opacity,1))}.rf-bg-muted{background-color:hsl(var(--muted))}.rf-bg-neutral-100{--tw-bg-opacity:1;background-color:rgb(245 245 245/var(--tw-bg-opacity,1))}.rf-bg-neutral-50{--tw-bg-opacity:1;background-color:rgb(250 250 250/var(--tw-bg-opacity,1))}.rf-bg-neutral-800{--tw-bg-opacity:1;background-color:rgb(38 38 38/var(--tw-bg-opacity,1))}.rf-bg-neutral-900{--tw-bg-opacity:1;background-color:rgb(23 23 23/var(--tw-bg-opacity,1))}.rf-bg-orange-400{--tw-bg-opacity:1;background-color:rgb(251 146 60/var(--tw-bg-opacity,1))}.rf-bg-orange-50{--tw-bg-opacity:1;background-color:rgb(255 247 237/var(--tw-bg-opacity,1))}.rf-bg-popover{background-color:hsl(var(--popover))}.rf-bg-red-100{--tw-bg-opacity:1;background-color:rgb(254 226 226/var(--tw-bg-opacity,1))}.rf-bg-red-50{--tw-bg-opacity:1;background-color:rgb(254 242 242/var(--tw-bg-opacity,1))}.rf-bg-red-500{--tw-bg-opacity:1;background-color:rgb(239 68 68/var(--tw-bg-opacity,1))}.rf-bg-red-900{--tw-bg-opacity:1;background-color:rgb(127 29 29/var(--tw-bg-opacity,1))}.rf-bg-white{--tw-bg-opacity:1;background-color:rgb(255 255 255/var(--tw-bg-opacity,1))}.rf-bg-yellow-100{--tw-bg-opacity:1;background-color:rgb(254 249 195/var(--tw-bg-opacity,1))}.rf-bg-zinc-100{--tw-bg-opacity:1;background-color:rgb(244 244 245/var(--tw-bg-opacity,1))}.rf-bg-zinc-200{--tw-bg-opacity:1;background-color:rgb(228 228 231/var(--tw-bg-opacity,1))}.rf-bg-zinc-50{--tw-bg-opacity:1;background-color:rgb(250 250 250/var(--tw-bg-opacity,1))}.rf-bg-zinc-800{--tw-bg-opacity:1;background-color:rgb(39 39 42/var(--tw-bg-opacity,1))}.rf-bg-zinc-900{--tw-bg-opacity:1;background-color:rgb(24 24 27/var(--tw-bg-opacity,1))}.rf-bg-opacity-50{--tw-bg-opacity:0.5}.rf-fill-current{fill:currentColor}.rf-object-contain{-o-object-fit:contain;object-fit:contain}.rf-object-cover{-o-object-fit:cover;object-fit:cover}.\\!rf-p-0{padding:0!important}.rf-p-0{padding:0}.rf-p-1{padding:.25rem}.rf-p-2{padding:.5rem}.rf-p-3{padding:.75rem}.rf-p-4{padding:1rem}.rf-p-5{padding:1.25rem}.rf-p-6{padding:1.5rem}.rf-p-8{padding:2rem}.rf-px-1{padding-left:.25rem;padding-right:.25rem}.rf-px-2{padding-left:.5rem;padding-right:.5rem}.rf-px-3{padding-left:.75rem;padding-right:.75rem}.rf-px-4{padding-left:1rem;padding-right:1rem}.rf-px-6{padding-left:1.5rem;padding-right:1.5rem}.rf-px-8{padding-left:2rem;padding-right:2rem}.rf-py-0{padding-bottom:0;padding-top:0}.rf-py-0\\.5{padding-bottom:.125rem;padding-top:.125rem}.rf-py-1{padding-bottom:.25rem;padding-top:.25rem}.rf-py-1\\.5{padding-bottom:.375rem;padding-top:.375rem}.rf-py-10{padding-bottom:2.5rem;padding-top:2.5rem}.rf-py-12{padding-bottom:3rem;padding-top:3rem}.rf-py-2{padding-bottom:.5rem;padding-top:.5rem}.rf-py-3{padding-bottom:.75rem;padding-top:.75rem}.rf-py-4{padding-bottom:1rem;padding-top:1rem}.rf-py-8{padding-bottom:2rem;padding-top:2rem}.rf-pb-0{padding-bottom:0}.rf-pb-2{padding-bottom:.5rem}.rf-pb-3{padding-bottom:.75rem}.rf-pb-4{padding-bottom:1rem}.rf-pl-2{padding-left:.5rem}.rf-pl-4{padding-left:1rem}.rf-pl-8{padding-left:2rem}.rf-pr-2{padding-right:.5rem}.rf-pt-2{padding-top:.5rem}.rf-pt-4{padding-top:1rem}.rf-text-left{text-align:left}.rf-text-center{text-align:center}.rf-text-right{text-align:right}.rf-font-mono{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace}.rf-text-2xl{font-size:1.5rem;line-height:2rem}.rf-text-3xl{font-size:1.875rem;line-height:2.25rem}.rf-text-\\[8px\\]{font-size:8px}.rf-text-base{font-size:1rem;line-height:1.5rem}.rf-text-lg{font-size:1.125rem;line-height:1.75rem}.rf-text-sm{font-size:.875rem;line-height:1.25rem}.rf-text-xl{font-size:1.25rem;line-height:1.75rem}.rf-text-xs{font-size:.75rem;line-height:1rem}.rf-font-bold{font-weight:700}.rf-font-medium{font-weight:500}.rf-font-semibold{font-weight:600}.rf-uppercase{text-transform:uppercase}.rf-capitalize{text-transform:capitalize}.rf-tabular-nums{--tw-numeric-spacing:tabular-nums;font-variant-numeric:var(--tw-ordinal) var(--tw-slashed-zero) var(--tw-numeric-figure) var(--tw-numeric-spacing) var(--tw-numeric-fraction)}.rf-leading-5{line-height:1.25rem}.rf-leading-none{line-height:1}.rf-leading-relaxed{line-height:1.625}.rf-leading-tight{line-height:1.25}.rf-tracking-wide{letter-spacing:.025em}.rf-tracking-widest{letter-spacing:.1em}.rf-text-black{--tw-text-opacity:1;color:rgb(0 0 0/var(--tw-text-opacity,1))}.rf-text-blue-500{--tw-text-opacity:1;color:rgb(59 130 246/var(--tw-text-opacity,1))}.rf-text-blue-600{--tw-text-opacity:1;color:rgb(37 99 235/var(--tw-text-opacity,1))}.rf-text-blue-700{--tw-text-opacity:1;color:rgb(29 78 216/var(--tw-text-opacity,1))}.rf-text-blue-800{--tw-text-opacity:1;color:rgb(30 64 175/var(--tw-text-opacity,1))}.rf-text-blue-900{--tw-text-opacity:1;color:rgb(30 58 138/var(--tw-text-opacity,1))}.rf-text-current{color:currentColor}.rf-text-gray-400{--tw-text-opacity:1;color:rgb(156 163 175/var(--tw-text-opacity,1))}.rf-text-gray-500{--tw-text-opacity:1;color:rgb(107 114 128/var(--tw-text-opacity,1))}.rf-text-gray-600{--tw-text-opacity:1;color:rgb(75 85 99/var(--tw-text-opacity,1))}.rf-text-gray-700{--tw-text-opacity:1;color:rgb(55 65 81/var(--tw-text-opacity,1))}.rf-text-gray-800{--tw-text-opacity:1;color:rgb(31 41 55/var(--tw-text-opacity,1))}.rf-text-gray-900{--tw-text-opacity:1;color:rgb(17 24 39/var(--tw-text-opacity,1))}.rf-text-green-500{--tw-text-opacity:1;color:rgb(34 197 94/var(--tw-text-opacity,1))}.rf-text-green-600{--tw-text-opacity:1;color:rgb(22 163 74/var(--tw-text-opacity,1))}.rf-text-green-700{--tw-text-opacity:1;color:rgb(21 128 61/var(--tw-text-opacity,1))}.rf-text-green-800{--tw-text-opacity:1;color:rgb(22 101 52/var(--tw-text-opacity,1))}.rf-text-green-900{--tw-text-opacity:1;color:rgb(20 83 45/var(--tw-text-opacity,1))}.rf-text-muted-foreground{color:hsl(var(--muted-foreground))}.rf-text-neutral-50{--tw-text-opacity:1;color:rgb(250 250 250/var(--tw-text-opacity,1))}.rf-text-neutral-500{--tw-text-opacity:1;color:rgb(115 115 115/var(--tw-text-opacity,1))}.rf-text-neutral-900{--tw-text-opacity:1;color:rgb(23 23 23/var(--tw-text-opacity,1))}.rf-text-neutral-950{--tw-text-opacity:1;color:rgb(10 10 10/var(--tw-text-opacity,1))}.rf-text-orange-500{--tw-text-opacity:1;color:rgb(249 115 22/var(--tw-text-opacity,1))}.rf-text-orange-600{--tw-text-opacity:1;color:rgb(234 88 12/var(--tw-text-opacity,1))}.rf-text-orange-800{--tw-text-opacity:1;color:rgb(154 52 18/var(--tw-text-opacity,1))}.rf-text-popover-foreground{color:hsl(var(--popover-foreground))}.rf-text-red-200{--tw-text-opacity:1;color:rgb(254 202 202/var(--tw-text-opacity,1))}.rf-text-red-300{--tw-text-opacity:1;color:rgb(252 165 165/var(--tw-text-opacity,1))}.rf-text-red-400{--tw-text-opacity:1;color:rgb(248 113 113/var(--tw-text-opacity,1))}.rf-text-red-500{--tw-text-opacity:1;color:rgb(239 68 68/var(--tw-text-opacity,1))}.rf-text-red-600{--tw-text-opacity:1;color:rgb(220 38 38/var(--tw-text-opacity,1))}.rf-text-red-700{--tw-text-opacity:1;color:rgb(185 28 28/var(--tw-text-opacity,1))}.rf-text-red-800{--tw-text-opacity:1;color:rgb(153 27 27/var(--tw-text-opacity,1))}.rf-text-red-900{--tw-text-opacity:1;color:rgb(127 29 29/var(--tw-text-opacity,1))}.rf-text-white{--tw-text-opacity:1;color:rgb(255 255 255/var(--tw-text-opacity,1))}.rf-text-yellow-400{--tw-text-opacity:1;color:rgb(250 204 21/var(--tw-text-opacity,1))}.rf-text-yellow-500{--tw-text-opacity:1;color:rgb(234 179 8/var(--tw-text-opacity,1))}.rf-text-yellow-900{--tw-text-opacity:1;color:rgb(113 63 18/var(--tw-text-opacity,1))}.rf-text-zinc-200{--tw-text-opacity:1;color:rgb(228 228 231/var(--tw-text-opacity,1))}.rf-text-zinc-300{--tw-text-opacity:1;color:rgb(212 212 216/var(--tw-text-opacity,1))}.rf-text-zinc-400{--tw-text-opacity:1;color:rgb(161 161 170/var(--tw-text-opacity,1))}.rf-text-zinc-50{--tw-text-opacity:1;color:rgb(250 250 250/var(--tw-text-opacity,1))}.rf-text-zinc-500{--tw-text-opacity:1;color:rgb(113 113 122/var(--tw-text-opacity,1))}.rf-text-zinc-900{--tw-text-opacity:1;color:rgb(24 24 27/var(--tw-text-opacity,1))}.rf-text-zinc-950{--tw-text-opacity:1;color:rgb(9 9 11/var(--tw-text-opacity,1))}.rf-underline{text-decoration-line:underline}.rf-line-through{text-decoration-line:line-through}.rf-underline-offset-4{text-underline-offset:4px}.rf-opacity-0{opacity:0}.rf-opacity-25{opacity:.25}.rf-opacity-30{opacity:.3}.rf-opacity-50{opacity:.5}.rf-opacity-60{opacity:.6}.rf-opacity-75{opacity:.75}.rf-shadow{--tw-shadow:0 1px 3px 0 rgba(0,0,0,.1),0 1px 2px -1px rgba(0,0,0,.1);--tw-shadow-colored:0 1px 3px 0 var(--tw-shadow-color),0 1px 2px -1px var(--tw-shadow-color)}.rf-shadow,.rf-shadow-lg{box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}.rf-shadow-lg{--tw-shadow:0 10px 15px -3px rgba(0,0,0,.1),0 4px 6px -4px rgba(0,0,0,.1);--tw-shadow-colored:0 10px 15px -3px var(--tw-shadow-color),0 4px 6px -4px var(--tw-shadow-color)}.rf-shadow-md{--tw-shadow:0 4px 6px -1px rgba(0,0,0,.1),0 2px 4px -2px rgba(0,0,0,.1);--tw-shadow-colored:0 4px 6px -1px var(--tw-shadow-color),0 2px 4px -2px var(--tw-shadow-color)}.rf-shadow-md,.rf-shadow-sm{box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}.rf-shadow-sm{--tw-shadow:0 1px 2px 0 rgba(0,0,0,.05);--tw-shadow-colored:0 1px 2px 0 var(--tw-shadow-color)}.rf-outline-none{outline:2px solid transparent;outline-offset:2px}.rf-ring-2{--tw-ring-offset-shadow:var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow:var(--tw-ring-inset) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow,0 0 #0000)}.rf-ring-blue-500{--tw-ring-opacity:1;--tw-ring-color:rgb(59 130 246/var(--tw-ring-opacity,1))}.rf-ring-primary{--tw-ring-color:hsl(var(--primary))}.rf-ring-offset-background{--tw-ring-offset-color:hsl(var(--background))}.rf-ring-offset-white{--tw-ring-offset-color:#fff}.rf-transition{transition-duration:.15s;transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,-webkit-backdrop-filter;transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,backdrop-filter;transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,backdrop-filter,-webkit-backdrop-filter;transition-timing-function:cubic-bezier(.4,0,.2,1)}.rf-transition-all{transition-duration:.15s;transition-property:all;transition-timing-function:cubic-bezier(.4,0,.2,1)}.rf-transition-colors{transition-duration:.15s;transition-property:color,background-color,border-color,text-decoration-color,fill,stroke;transition-timing-function:cubic-bezier(.4,0,.2,1)}.rf-transition-opacity{transition-duration:.15s;transition-property:opacity;transition-timing-function:cubic-bezier(.4,0,.2,1)}.rf-duration-200{transition-duration:.2s}.rf-ease-in-out{transition-timing-function:cubic-bezier(.4,0,.2,1)}@keyframes enter{0%{opacity:var(--tw-enter-opacity,1);transform:translate3d(var(--tw-enter-translate-x,0),var(--tw-enter-translate-y,0),0) scale3d(var(--tw-enter-scale,1),var(--tw-enter-scale,1),var(--tw-enter-scale,1)) rotate(var(--tw-enter-rotate,0))}}@keyframes exit{to{opacity:var(--tw-exit-opacity,1);transform:translate3d(var(--tw-exit-translate-x,0),var(--tw-exit-translate-y,0),0) scale3d(var(--tw-exit-scale,1),var(--tw-exit-scale,1),var(--tw-exit-scale,1)) rotate(var(--tw-exit-rotate,0))}}.rf-slide-in-from-left-1{--tw-enter-translate-x:-0.25rem}.rf-slide-out-to-left-1{--tw-exit-translate-x:-0.25rem}.rf-duration-200{animation-duration:.2s}.rf-ease-in-out{animation-timing-function:cubic-bezier(.4,0,.2,1)}.file\\:rf-border-0::file-selector-button{border-width:0}.file\\:rf-bg-transparent::file-selector-button{background-color:transparent}.file\\:rf-text-sm::file-selector-button{font-size:.875rem;line-height:1.25rem}.file\\:rf-font-medium::file-selector-button{font-weight:500}.placeholder\\:rf-text-zinc-500::-moz-placeholder{--tw-text-opacity:1;color:rgb(113 113 122/var(--tw-text-opacity,1))}.placeholder\\:rf-text-zinc-500::placeholder{--tw-text-opacity:1;color:rgb(113 113 122/var(--tw-text-opacity,1))}.hover\\:rf-border-blue-300:hover{--tw-border-opacity:1;border-color:rgb(147 197 253/var(--tw-border-opacity,1))}.hover\\:\\!rf-bg-transparent:hover{background-color:transparent!important}.hover\\:rf-bg-blue-700:hover{--tw-bg-opacity:1;background-color:rgb(29 78 216/var(--tw-bg-opacity,1))}.hover\\:rf-bg-red-500\\/90:hover{background-color:rgba(239,68,68,.9)}.hover\\:rf-bg-zinc-100:hover{--tw-bg-opacity:1;background-color:rgb(244 244 245/var(--tw-bg-opacity,1))}.hover\\:rf-bg-zinc-100\\/80:hover{background-color:hsla(240,5%,96%,.8)}.hover\\:rf-bg-zinc-900\\/90:hover{background-color:rgba(24,24,27,.9)}.hover\\:rf-text-red-400:hover{--tw-text-opacity:1;color:rgb(248 113 113/var(--tw-text-opacity,1))}.hover\\:rf-text-zinc-900:hover{--tw-text-opacity:1;color:rgb(24 24 27/var(--tw-text-opacity,1))}.hover\\:rf-underline:hover{text-decoration-line:underline}.focus\\:rf-bg-gray-100:focus{--tw-bg-opacity:1;background-color:rgb(243 244 246/var(--tw-bg-opacity,1))}.focus\\:rf-bg-zinc-100:focus{--tw-bg-opacity:1;background-color:rgb(244 244 245/var(--tw-bg-opacity,1))}.focus\\:rf-text-gray-900:focus{--tw-text-opacity:1;color:rgb(17 24 39/var(--tw-text-opacity,1))}.focus\\:rf-text-zinc-900:focus{--tw-text-opacity:1;color:rgb(24 24 27/var(--tw-text-opacity,1))}.focus\\:rf-outline-none:focus{outline:2px solid transparent;outline-offset:2px}.focus\\:rf-ring-2:focus{--tw-ring-offset-shadow:var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow:var(--tw-ring-inset) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow,0 0 #0000)}.focus\\:rf-ring-ring:focus{--tw-ring-color:hsl(var(--ring))}.focus\\:rf-ring-offset-2:focus{--tw-ring-offset-width:2px}.focus-visible\\:rf-outline-none:focus-visible{outline:2px solid transparent;outline-offset:2px}.focus-visible\\:rf-ring-1:focus-visible{--tw-ring-offset-shadow:var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow:var(--tw-ring-inset) 0 0 0 calc(1px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow,0 0 #0000)}.focus-visible\\:rf-ring-2:focus-visible{--tw-ring-offset-shadow:var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow:var(--tw-ring-inset) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow,0 0 #0000)}.focus-visible\\:rf-ring-zinc-950:focus-visible{--tw-ring-opacity:1;--tw-ring-color:rgb(9 9 11/var(--tw-ring-opacity,1))}.focus-visible\\:rf-ring-offset-2:focus-visible{--tw-ring-offset-width:2px}.disabled\\:rf-pointer-events-none:disabled{pointer-events:none}.disabled\\:rf-cursor-not-allowed:disabled{cursor:not-allowed}.disabled\\:rf-opacity-50:disabled{opacity:.5}.rf-group\\/bar:hover .group-hover\\/bar\\:rf-opacity-100{opacity:1}.data-\\[disabled\\]\\:rf-pointer-events-none[data-disabled]{pointer-events:none}.data-\\[side\\=bottom\\]\\:rf-translate-y-1[data-side=bottom]{--tw-translate-y:0.25rem}.data-\\[side\\=bottom\\]\\:rf-translate-y-1[data-side=bottom],.data-\\[side\\=left\\]\\:-rf-translate-x-1[data-side=left]{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.data-\\[side\\=left\\]\\:-rf-translate-x-1[data-side=left]{--tw-translate-x:-0.25rem}.data-\\[side\\=right\\]\\:rf-translate-x-1[data-side=right]{--tw-translate-x:0.25rem}.data-\\[side\\=right\\]\\:rf-translate-x-1[data-side=right],.data-\\[side\\=top\\]\\:-rf-translate-y-1[data-side=top]{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.data-\\[side\\=top\\]\\:-rf-translate-y-1[data-side=top]{--tw-translate-y:-0.25rem}.data-\\[state\\=active\\]\\:rf-bg-white[data-state=active]{--tw-bg-opacity:1;background-color:rgb(255 255 255/var(--tw-bg-opacity,1))}.data-\\[state\\=checked\\]\\:rf-bg-zinc-900[data-state=checked]{--tw-bg-opacity:1;background-color:rgb(24 24 27/var(--tw-bg-opacity,1))}.data-\\[state\\=open\\]\\:rf-bg-zinc-100[data-state=open]{--tw-bg-opacity:1;background-color:rgb(244 244 245/var(--tw-bg-opacity,1))}.data-\\[state\\=active\\]\\:rf-text-zinc-950[data-state=active]{--tw-text-opacity:1;color:rgb(9 9 11/var(--tw-text-opacity,1))}.data-\\[state\\=checked\\]\\:rf-text-zinc-50[data-state=checked]{--tw-text-opacity:1;color:rgb(250 250 250/var(--tw-text-opacity,1))}.data-\\[disabled\\]\\:rf-opacity-50[data-disabled]{opacity:.5}.data-\\[state\\=active\\]\\:rf-shadow[data-state=active]{--tw-shadow:0 1px 3px 0 rgba(0,0,0,.1),0 1px 2px -1px rgba(0,0,0,.1);--tw-shadow-colored:0 1px 3px 0 var(--tw-shadow-color),0 1px 2px -1px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}.data-\\[state\\=open\\]\\:rf-animate-in[data-state=open]{animation-duration:.15s;animation-name:enter;--tw-enter-opacity:initial;--tw-enter-scale:initial;--tw-enter-rotate:initial;--tw-enter-translate-x:initial;--tw-enter-translate-y:initial}.data-\\[state\\=closed\\]\\:rf-animate-out[data-state=closed]{animation-duration:.15s;animation-name:exit;--tw-exit-opacity:initial;--tw-exit-scale:initial;--tw-exit-rotate:initial;--tw-exit-translate-x:initial;--tw-exit-translate-y:initial}.data-\\[state\\=closed\\]\\:rf-fade-out-0[data-state=closed]{--tw-exit-opacity:0}.data-\\[state\\=open\\]\\:rf-fade-in-0[data-state=open]{--tw-enter-opacity:0}.data-\\[state\\=closed\\]\\:rf-zoom-out-95[data-state=closed]{--tw-exit-scale:.95}.data-\\[state\\=open\\]\\:rf-zoom-in-95[data-state=open]{--tw-enter-scale:.95}.data-\\[side\\=bottom\\]\\:rf-slide-in-from-top-2[data-side=bottom]{--tw-enter-translate-y:-0.5rem}.data-\\[side\\=left\\]\\:rf-slide-in-from-right-2[data-side=left]{--tw-enter-translate-x:0.5rem}.data-\\[side\\=right\\]\\:rf-slide-in-from-left-2[data-side=right]{--tw-enter-translate-x:-0.5rem}.data-\\[side\\=top\\]\\:rf-slide-in-from-bottom-2[data-side=top]{--tw-enter-translate-y:0.5rem}.data-\\[state\\=closed\\]\\:rf-slide-out-to-left-1\\/2[data-state=closed]{--tw-exit-translate-x:-50%}.data-\\[state\\=closed\\]\\:rf-slide-out-to-top-\\[48\\%\\][data-state=closed]{--tw-exit-translate-y:-48%}.data-\\[state\\=open\\]\\:rf-slide-in-from-left-1\\/2[data-state=open]{--tw-enter-translate-x:-50%}.data-\\[state\\=open\\]\\:rf-slide-in-from-top-\\[48\\%\\][data-state=open]{--tw-enter-translate-y:-48%}.dark\\:rf-border-zinc-50:is(.rf-dark *){--tw-border-opacity:1;border-color:rgb(250 250 250/var(--tw-border-opacity,1))}.dark\\:rf-border-zinc-800:is(.rf-dark *){--tw-border-opacity:1;border-color:rgb(39 39 42/var(--tw-border-opacity,1))}.dark\\:rf-bg-red-900:is(.rf-dark *){--tw-bg-opacity:1;background-color:rgb(127 29 29/var(--tw-bg-opacity,1))}.dark\\:rf-bg-zinc-50:is(.rf-dark *){--tw-bg-opacity:1;background-color:rgb(250 250 250/var(--tw-bg-opacity,1))}.dark\\:rf-bg-zinc-800:is(.rf-dark *){--tw-bg-opacity:1;background-color:rgb(39 39 42/var(--tw-bg-opacity,1))}.dark\\:rf-bg-zinc-950:is(.rf-dark *){--tw-bg-opacity:1;background-color:rgb(9 9 11/var(--tw-bg-opacity,1))}.dark\\:rf-text-zinc-400:is(.rf-dark *){--tw-text-opacity:1;color:rgb(161 161 170/var(--tw-text-opacity,1))}.dark\\:rf-text-zinc-50:is(.rf-dark *){--tw-text-opacity:1;color:rgb(250 250 250/var(--tw-text-opacity,1))}.dark\\:rf-text-zinc-900:is(.rf-dark *){--tw-text-opacity:1;color:rgb(24 24 27/var(--tw-text-opacity,1))}.dark\\:rf-placeholder-zinc-400:is(.rf-dark *)::-moz-placeholder{--tw-placeholder-opacity:1;color:rgb(161 161 170/var(--tw-placeholder-opacity,1))}.dark\\:rf-placeholder-zinc-400:is(.rf-dark *)::placeholder{--tw-placeholder-opacity:1;color:rgb(161 161 170/var(--tw-placeholder-opacity,1))}.dark\\:rf-ring-offset-zinc-950:is(.rf-dark *){--tw-ring-offset-color:#09090b}.dark\\:hover\\:rf-bg-red-900\\/90:hover:is(.rf-dark *){background-color:rgba(127,29,29,.9)}.dark\\:hover\\:rf-bg-zinc-50\\/90:hover:is(.rf-dark *){background-color:hsla(0,0%,98%,.9)}.dark\\:hover\\:rf-bg-zinc-800:hover:is(.rf-dark *){--tw-bg-opacity:1;background-color:rgb(39 39 42/var(--tw-bg-opacity,1))}.dark\\:hover\\:rf-bg-zinc-800\\/80:hover:is(.rf-dark *){background-color:rgba(39,39,42,.8)}.dark\\:hover\\:rf-text-zinc-50:hover:is(.rf-dark *){--tw-text-opacity:1;color:rgb(250 250 250/var(--tw-text-opacity,1))}.dark\\:focus\\:rf-bg-zinc-800:focus:is(.rf-dark *){--tw-bg-opacity:1;background-color:rgb(39 39 42/var(--tw-bg-opacity,1))}.dark\\:focus\\:rf-text-zinc-50:focus:is(.rf-dark *){--tw-text-opacity:1;color:rgb(250 250 250/var(--tw-text-opacity,1))}.dark\\:focus-visible\\:rf-ring-zinc-300:focus-visible:is(.rf-dark *){--tw-ring-opacity:1;--tw-ring-color:rgb(212 212 216/var(--tw-ring-opacity,1))}.dark\\:data-\\[state\\=active\\]\\:rf-bg-zinc-950[data-state=active]:is(.rf-dark *){--tw-bg-opacity:1;background-color:rgb(9 9 11/var(--tw-bg-opacity,1))}.dark\\:data-\\[state\\=checked\\]\\:rf-bg-zinc-50[data-state=checked]:is(.rf-dark *){--tw-bg-opacity:1;background-color:rgb(250 250 250/var(--tw-bg-opacity,1))}.dark\\:data-\\[state\\=open\\]\\:rf-bg-zinc-800[data-state=open]:is(.rf-dark *){--tw-bg-opacity:1;background-color:rgb(39 39 42/var(--tw-bg-opacity,1))}.dark\\:data-\\[state\\=active\\]\\:rf-text-zinc-50[data-state=active]:is(.rf-dark *){--tw-text-opacity:1;color:rgb(250 250 250/var(--tw-text-opacity,1))}.dark\\:data-\\[state\\=checked\\]\\:rf-text-zinc-900[data-state=checked]:is(.rf-dark *){--tw-text-opacity:1;color:rgb(24 24 27/var(--tw-text-opacity,1))}@media (min-width:640px){.sm\\:rf-mt-0{margin-top:0}.sm\\:rf-flex-row{flex-direction:row}.sm\\:rf-justify-end{justify-content:flex-end}.sm\\:rf-space-x-2>:not([hidden])~:not([hidden]){--tw-space-x-reverse:0;margin-left:calc(.5rem*(1 - var(--tw-space-x-reverse)));margin-right:calc(.5rem*var(--tw-space-x-reverse))}.sm\\:rf-rounded-lg{border-radius:var(--radius)}.sm\\:rf-text-left{text-align:left}}@media (min-width:768px){.md\\:rf-grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}}.\\[\\&\\>span\\]\\:rf-line-clamp-1>span{display:-webkit-box;overflow:hidden;-webkit-box-orient:vertical;-webkit-line-clamp:1}.\\[\\&\\>svg\\]\\:rf-size-4>svg{height:1rem;width:1rem}.\\[\\&\\>svg\\]\\:rf-shrink-0>svg{flex-shrink:0}.\\[\\&\\>svg\\]\\:rf-text-red-300>svg{--tw-text-opacity:1;color:rgb(252 165 165/var(--tw-text-opacity,1))}.\\[\\&\\>svg\\]\\:hover\\:rf-text-red-400:hover>svg{--tw-text-opacity:1;color:rgb(248 113 113/var(--tw-text-opacity,1))}.\\[\\&_svg\\]\\:rf-pointer-events-none svg{pointer-events:none}.\\[\\&_svg\\]\\:rf-size-4 svg{height:1rem;width:1rem}.\\[\\&_svg\\]\\:rf-shrink-0 svg{flex-shrink:0}',abn=()=>{pt.useEffect(()=>{if(document.querySelector('style[data-styles="tscircuit-runframe"]'))return;const e=document.createElement("style");e.setAttribute("data-styles","tscircuit-runframe"),e.textContent=rbn,document.head.appendChild(e)},[])},obn=i=>{pt.useEffect(()=>(i?document.body.style.overflow="hidden":document.body.style.overflow="",()=>{document.body.style.overflow=""}),[i])},Tot=i=>`hsl(${Gb.indexOf(i)*137.5%360}, 70%, 50%)`,sbn=({phaseTimings:i})=>{if(!i)return null;const e=Object.values(i).reduce((t,n)=>t+n,0);return We.jsxs("div",{className:"rf-space-y-2 rf-w-full rf-px-4",children:[We.jsx("div",{className:"rf-relative rf-h-8 rf-flex rf-rounded-sm",children:Gb.map(t=>{const n=i[t]||0,r=n/e*100;return We.jsx("div",{className:"rf-group/bar rf-relative rf-overflow-visible",style:{width:`${r}%`,backgroundColor:Tot(t)},children:We.jsxs("div",{className:"rf-opacity-0 group-hover/bar:rf-opacity-100 rf-transition-opacity rf-absolute rf-bottom-full rf-left-1/2 rf-transform -rf-translate-x-1/2 rf-mb-2 rf-px-2 rf-py-1 rf-text-xs rf-whitespace-nowrap rf-rounded rf-bg-gray-900 rf-text-white rf-pointer-events-none",children:[t,": ",n.toFixed(1),"ms"]})},t)})}),We.jsxs("div",{className:"rf-text-xs rf-text-gray-500",children:["Total: ",e.toFixed(2),"ms"]})]})},lbn=({renderLog:i})=>{const[e,t]=pt.useState("chronological");if(!i)return We.jsx("div",{className:"rf-p-4 rf-bg-gray-100 rf-rounded-md",children:"No render log, make sure this tab is open when you render (TODO add a rerender button here)"});const n=Object.entries((i==null?void 0:i.phaseTimings)??{});e==="chronological"?n.sort((a,o)=>Gb.indexOf(a[0])-Gb.indexOf(o[0])):n.sort((a,o)=>o[1]-a[1]);const r=n.reduce((a,[o,s])=>a+s,0);return We.jsxs("div",{className:"rf-bg-white",children:[We.jsxs("div",{className:"rf-flex rf-justify-between rf-items-center",children:[We.jsx("div",{children:"Render Logs"}),We.jsxs("div",{className:"rf-mb-4 rf-pr-2 rf-flex rf-text-xs rf-items-center",children:[We.jsx("div",{className:"rf-mr-2",children:"Sort by:"}),We.jsxs("select",{value:e,onChange:a=>t(a.target.value),className:"rf-px-2 rf-py-1 rf-border rf-rounded rf-text-xs",children:[We.jsx("option",{value:"chronological",children:"Phase Order"}),We.jsx("option",{value:"longest",children:"Duration"})]})]})]}),We.jsx(sbn,{phaseTimings:i.phaseTimings}),We.jsxs("table",{className:"rf-w-full rf-text-xs",children:[We.jsx("thead",{children:We.jsxs("tr",{children:[We.jsx("th",{className:"rf-text-left rf-p-2",children:"Phase Order"}),We.jsx("th",{className:"rf-text-left rf-p-2",children:"Phase"}),We.jsx("th",{className:"rf-text-left rf-p-2",children:"Duration (ms)"})]})}),We.jsx("tbody",{children:n.map(([a,o])=>We.jsxs("tr",{children:[We.jsx("td",{className:"rf-p-2",children:Gb.indexOf(a)}),We.jsx("td",{className:"rf-p-2",children:a}),We.jsx("td",{className:"rf-p-2",children:We.jsx("div",{className:"rf-w-8",children:We.jsx("div",{className:"rf-h-2 rf-rounded-sm",style:{backgroundColor:Tot(a),width:`${o/r*100}%`}})})}),We.jsx("td",{className:"rf-p-2",children:We.jsxs("div",{className:"rf-flex w-full",children:[We.jsxs("span",{className:"rf-flex-grow",children:[o,"ms"]}),We.jsxs("span",{className:"rf-text-gray-500 rf-pr-2",children:[(o/r*100).toFixed(1),"%"]})]})})]},a))})]})]})},Pot=({errorMessage:i,errorStack:e,circuitJsonErrors:t})=>{pt.useEffect(()=>{if(i){const n=new Error(i);e&&(n.stack=e);try{wO.captureException(n)}catch{}}},[i,e]),pt.useEffect(()=>{if(t&&t.length>0)for(const n of t){const r=new Error(n.message||"Circuit JSON Error");n.stack&&(r.stack=n.stack);try{wO.captureException(r,{error_type:n.type})}catch{}}},[t])},cbn="0.0.671",Nve=XRe()(ZRe(i=>({lastRunEvalVersion:void 0,setLastRunEvalVersion:e=>{i({lastRunEvalVersion:e})}}),{name:"runframe-runner-store"})),ubn=["assembly","bom","circuit_json","errors","render_log"],dbn=({code:i,onRunClicked:e=void 0,errorMessage:t,errorStack:n,circuitJson:r,autoroutingGraphics:a,showRightHeaderContent:o=!0,showCodeTab:s=!1,codeTabContent:l,showJsonTab:c=!0,showRenderLogTab:u=!0,onActiveTabChange:f,renderLog:h,showImportAndFormatButtons:p=!0,className:y,headerClassName:_,leftHeaderContent:I,readOnly:C,isStreaming:b,autoroutingLog:w,onReportAutoroutingLog:N,isRunningCode:V,hasCodeChangedSinceLastRun:z,onEditEvent:K,editEvents:G,defaultActiveTab:q,autoRotate3dViewerDisabled:Y,showSchematicDebugGrid:oe=!1,showToggleFullScreen:W=!0,defaultToFullScreen:re=!1,activeEffectName:fe})=>{var Tt;abn();const Ae=Nve(mt=>mt.lastRunEvalVersion),ce=pt.useMemo(()=>r?r.filter(mt=>mt&&"error_type"in mt||mt.type.includes("error")):null,[r]),xe=pt.useMemo(()=>r?r.filter(mt=>mt&&"warning_type"in mt||mt.type.includes("warning")):null,[r]);Pot({errorMessage:t,errorStack:n,circuitJsonErrors:ce});const[me,Re]=pt.useState(q??"pcb"),[we,Te]=pt.useState(null),[Be,je]=pt.useState(re);obn(Be);const Xe=pt.useCallback(mt=>{Re(mt),f==null||f(mt)},[f]),ot=()=>{je(!Be)};pt.useEffect(()=>{t&&(me!=="errors"&&Te(me),Xe("errors"))},[t]),pt.useEffect(()=>{(me==="code"||me==="errors")&&r&&!t&&Xe(we??q??"pcb")},[r]);const ft=pt.useCallback(mt=>{window.TSCIRCUIT_3D_OBJECT_REF=mt===null?void 0:mt},[]);return We.jsx("div",{className:Km("flex flex-col relative rf-overflow-x-hidden rf-h-full",y),children:We.jsx("div",{className:Km("rf-md:sticky rf-md:top-2 rf-h-full",Be&&"rf-fixed rf-top-0 rf-left-0 rf-w-full rf-h-full rf-bg-white rf-overflow-hidden"),children:We.jsxs(Gre,{value:me,onValueChange:Xe,className:"rf-flex-grow rf-flex rf-flex-col rf-h-full",children:[We.jsxs("div",{className:Km("rf-flex rf-items-center rf-gap-2 rf-p-2 rf-pb-0",_),children:[I,I&&We.jsx("div",{className:"rf-flex-grow"}),!I&&V&&We.jsx(oQ,{className:"rf-w-4 rf-h-4 rf-animate-spin"}),!I&&We.jsx("div",{className:"rf-flex-grow"}),h&&h.progress!==1&&!t&&We.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2",children:[fe?We.jsx("div",{className:"rf-text-xs rf-text-gray-500",children:fe}):h.lastRenderEvent&&We.jsx("div",{className:"rf-text-xs rf-text-gray-500",children:((Tt=h.lastRenderEvent)==null?void 0:Tt.phase)??""}),We.jsx("div",{className:"rf-w-4 rf-h-4 rf-bg-blue-500 rf-opacity-50 rf-rounded-full rf-text-white",children:We.jsx(oQ,{className:"rf-w-4 rf-h-4 rf-animate-spin"})}),We.jsxs("div",{className:"rf-text-xs rf-font-bold rf-text-gray-700 rf-tabular-nums",children:[((h.progress??0)*100).toFixed(1),"%"]})]}),o&&We.jsxs(MO,{children:[s&&We.jsx(IB,{value:"code",children:"Code"}),We.jsxs(IB,{value:"pcb",className:"rf-whitespace-nowrap",children:[r&&We.jsx("span",{className:Km("rf-inline-flex rf-items-center rf-justify-center rf-w-2 rf-h-2 rf-mr-1 rf-text-xs rf-font-bold rf-text-white rf-rounded-full",z?"rf-bg-gray-500":"rf-bg-blue-500")}),"PCB"]}),We.jsxs(IB,{value:"schematic",className:"rf-whitespace-nowrap",children:[r&&We.jsx("span",{className:Km("rf-inline-flex rf-items-center rf-justify-center rf-w-2 rf-h-2 rf-mr-1 rf-text-xs rf-font-bold rf-text-white rf-rounded-full",z?"rf-bg-gray-500":"rf-bg-blue-500")}),"Schematic"]}),We.jsxs(IB,{value:"cad",children:[r&&We.jsx("span",{className:Km("inline-flex items-center justify-center w-2 h-2 mr-1 text-xs font-bold text-white rounded-full",z?"rf-bg-gray-500":"rf-bg-blue-500")}),"3D"]}),!["pcb","cad","schematic"].includes(me)&&We.jsx(IB,{value:me,children:j8e(me)}),We.jsxs(Pme,{children:[We.jsx(kme,{asChild:!0,children:We.jsxs("div",{className:"rf-whitespace-nowrap rf-p-2 rf-mr-1 rf-cursor-pointer rf-relative",children:[We.jsx(w0n,{className:"rf-w-4 rf-h-4"}),(ce&&ce.length>0||t)&&We.jsx("span",{className:"rf-inline-flex rf-absolute rf-top-[6px] rf-right-[4px] rf-items-center rf-justify-center rf-w-1 rf-h-1 rf-ml-2 rf-text-[8px] rf-font-bold rf-text-white rf-bg-red-500 rf-rounded-full"})]})}),We.jsxs(aj,{className:"rf-*:text-xs",children:[ubn.map(mt=>We.jsxs(DS,{onSelect:()=>Xe(mt),children:[me!==mt&&We.jsx(set,{className:"rf-w-3 rf-h-3 rf-opacity-30"}),me===mt&&We.jsx(zge,{className:"rf-w-3 rf-h-3"}),We.jsx("div",{className:"rf-pr-2",children:j8e(mt)}),mt==="errors"&&(ce&&ce.length>0||t)&&We.jsx("span",{className:"rf-inline-flex rf-items-center rf-justify-center rf-w-3 rf-h-3 rf-ml-2 rf-text-[8px] rf-font-bold rf-text-white rf-bg-red-500 rf-rounded-full",children:t?1:ce==null?void 0:ce.length})]},mt)),We.jsx(DS,{disabled:!0,className:"rf-opacity-60 rf-cursor-default rf-select-none",children:We.jsxs("div",{className:"rf-pr-2 rf-text-xs rf-text-gray-500",children:["@tscircuit/runframe@",cbn.split(".").map((mt,ze)=>ze===2?parseInt(mt)+1:mt).join(".")]})}),Ae&&We.jsx(DS,{disabled:!0,className:"rf-opacity-60 rf-cursor-default rf-select-none",children:We.jsxs("div",{className:"rf-pr-2 rf-text-xs rf-text-gray-500",children:["@tscircuit/eval@",Ae]})})]})]})]}),W&&We.jsx(F9,{onClick:ot,variant:"ghost",children:Be?We.jsx(D0n,{size:16}):We.jsx(Q0n,{size:16})})]}),s&&We.jsx(WS,{value:"code",className:"rf-flex-grow rf-overflow-hidden",children:We.jsx("div",{className:"rf-h-full",children:l})}),We.jsx(WS,{value:"pcb",children:We.jsx("div",{className:Km("rf-overflow-hidden",Be?"rf-h-[calc(100vh-52px)]":"rf-h-full"),children:We.jsx(oN,{fallbackRender:({error:mt})=>We.jsx("div",{className:"rf-mt-4 rf-bg-red-50 rf-rounded-md rf-border rf-border-red-200",children:We.jsxs("div",{className:"rf-p-4",children:[We.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-red-800 rf-mb-3",children:"Error loading PCB viewer"}),We.jsx("p",{className:"rf-text-xs rf-font-mono rf-whitespace-pre-wrap rf-text-red-600 rf-mt-2",children:(mt==null?void 0:mt.message)||"An unknown error occurred"})]})}),children:r?We.jsx(ibn,{focusOnHover:!1,circuitJson:r,debugGraphics:a,containerClassName:Km("rf-h-full rf-w-full",Be?"rf-min-h-[calc(100vh-240px)]":"rf-min-h-[620px]"),onEditEventsChanged:mt=>{K&&mt.forEach(ze=>K(ze))}}):We.jsx(dQ,{onRunClicked:e})})})}),We.jsx(WS,{value:"assembly",children:We.jsx("div",{className:Km("rf-overflow-auto",Be?"rf-h-screen":"rf-h-full rf-min-h-[620px]"),children:We.jsx(oN,{fallback:We.jsx("div",{children:"Error loading Assembly"}),children:r?We.jsx(r_n,{circuitJson:r,containerStyle:{height:"100%"},editingEnabled:!0,debugGrid:!0}):We.jsx(dQ,{onRunClicked:e})})})}),We.jsx(WS,{value:"schematic",children:We.jsx("div",{className:Km("rf-overflow-auto rf-bg-white",Be?"rf-h-screen":"rf-h-full rf-min-h-[620px]"),children:We.jsx(oN,{fallbackRender:({error:mt})=>We.jsx("div",{className:"rf-mt-4 rf-bg-red-50 rf-rounded-md rf-border rf-border-red-200",children:We.jsxs("div",{className:"rf-p-4",children:[We.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-red-800 rf-mb-3",children:"Error loading Schematic"}),We.jsx("p",{className:"rf-text-xs rf-font-mono rf-whitespace-pre-wrap rf-text-red-600 rf-mt-2",children:(mt==null?void 0:mt.message)||"An unknown error occurred"})]})}),children:r?We.jsx(t_n,{circuitJson:r,containerStyle:{height:"100%"},editingEnabled:!0,onEditEvent:mt=>{K==null||K(mt)},debugGrid:oe}):We.jsx(dQ,{onRunClicked:e})})})}),We.jsx(WS,{value:"cad",children:We.jsx("div",{className:Km("rf-overflow-auto",Be?"rf-h-screen":"rf-h-full rf-min-h-[620px]"),children:We.jsx(oN,{FallbackComponent:g0n,children:r?We.jsx(h0n,{ref:ft,circuitJson:r,autoRotateDisabled:Y}):We.jsx(dQ,{onRunClicked:e})})})}),We.jsx(WS,{value:"bom",children:We.jsx("div",{className:Km("rf-overflow-auto",Be?"rf-h-screen":"rf-h-full rf-min-h-[620px]"),children:We.jsx(oN,{fallbackRender:({error:mt})=>We.jsx("div",{className:"rf-mt-4 rf-bg-red-50 rf-rounded-md rf-border rf-border-red-200",children:We.jsxs("div",{className:"rf-p-4",children:[We.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-red-800 rf-mb-3",children:"Error loading Bill of Materials"}),We.jsx("p",{className:"rf-text-xs rf-font-mono rf-whitespace-pre-wrap rf-text-red-600 rf-mt-2",children:(mt==null?void 0:mt.message)||"An unknown error occurred"})]})}),children:r?We.jsx(c_n,{circuitJson:r}):We.jsx(dQ,{onRunClicked:e})})})}),We.jsx(WS,{value:"circuit_json",children:We.jsx("div",{className:Km("rf-overflow-auto",Be?"rf-h-screen":"rf-h-full rf-min-h-[620px]"),children:We.jsx(oN,{fallback:We.jsx("div",{children:"Error loading JSON viewer"}),children:r?We.jsx(s_n,{elements:r}):We.jsx(dQ,{onRunClicked:e})})})}),We.jsx(WS,{value:"errors",children:We.jsx("div",{className:Km("rf-overflow-auto",Be?"rf-h-screen":"rf-h-full rf-min-h-[620px]"),children:t||ce&&ce.length>0||r?We.jsx(Svn,{code:i,circuitJsonErrors:ce,circuitJsonWarnings:xe,errorMessage:t,errorStack:n,circuitJson:r,evalVersion:Ae,autoroutingLog:w,onReportAutoroutingLog:N}):We.jsx(dQ,{onRunClicked:e})})}),u&&We.jsx(WS,{value:"render_log",children:We.jsx(lbn,{renderLog:h})})]})})})};var rK="Dialog",[kot,Uot]=w5(rK),[fbn,G2]=kot(rK),Lot=i=>{const{__scopeDialog:e,children:t,open:n,defaultOpen:r,onOpenChange:a,modal:o=!0}=i,s=pt.useRef(null),l=pt.useRef(null),[c,u]=MR({prop:n,defaultProp:r??!1,onChange:a,caller:rK});return We.jsx(fbn,{scope:e,triggerRef:s,contentRef:l,contentId:M5(),titleId:M5(),descriptionId:M5(),open:c,onOpenChange:u,onOpenToggle:pt.useCallback(()=>u(f=>!f),[u]),modal:o,children:t})};Lot.displayName=rK;var Fot="DialogTrigger",Got=pt.forwardRef((i,e)=>{const{__scopeDialog:t,...n}=i,r=G2(Fot,t),a=k9(e,r.triggerRef);return We.jsx(iC.button,{type:"button","aria-haspopup":"dialog","aria-expanded":r.open,"aria-controls":r.contentId,"data-state":kve(r.open),...n,ref:a,onClick:Qm(i.onClick,r.onOpenToggle)})});Got.displayName=Fot;var Tve="DialogPortal",[Abn,Oot]=kot(Tve,{forceMount:void 0}),zot=i=>{const{__scopeDialog:e,forceMount:t,children:n,container:r}=i,a=G2(Tve,e);return We.jsx(Abn,{scope:e,forceMount:t,children:pt.Children.map(n,o=>We.jsx(hB,{present:t||a.open,children:We.jsx(vme,{asChild:!0,container:r,children:o})}))})};zot.displayName=Tve;var aK="DialogOverlay",Hot=pt.forwardRef((i,e)=>{const t=Oot(aK,i.__scopeDialog),{forceMount:n=t.forceMount,...r}=i,a=G2(aK,i.__scopeDialog);return a.modal?We.jsx(hB,{present:n||a.open,children:We.jsx(pbn,{...r,ref:e})}):null});Hot.displayName=aK;var hbn=wR("DialogOverlay.RemoveScroll"),pbn=pt.forwardRef((i,e)=>{const{__scopeDialog:t,...n}=i,r=G2(aK,t);return We.jsx(bme,{as:hbn,allowPinchZoom:!0,shards:[r.contentRef],children:We.jsx(iC.div,{"data-state":kve(r.open),...n,ref:e,style:{pointerEvents:"auto",...n.style}})})}),_Q="DialogContent",Yot=pt.forwardRef((i,e)=>{const t=Oot(_Q,i.__scopeDialog),{forceMount:n=t.forceMount,...r}=i,a=G2(_Q,i.__scopeDialog);return We.jsx(hB,{present:n||a.open,children:a.modal?We.jsx(gbn,{...r,ref:e}):We.jsx(mbn,{...r,ref:e})})});Yot.displayName=_Q;var gbn=pt.forwardRef((i,e)=>{const t=G2(_Q,i.__scopeDialog),n=pt.useRef(null),r=k9(e,t.contentRef,n);return pt.useEffect(()=>{const a=n.current;if(a)return Att(a)},[]),We.jsx(Vot,{...i,ref:r,trapFocus:t.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Qm(i.onCloseAutoFocus,a=>{var o;a.preventDefault(),(o=t.triggerRef.current)==null||o.focus()}),onPointerDownOutside:Qm(i.onPointerDownOutside,a=>{const o=a.detail.originalEvent,s=o.button===0&&o.ctrlKey===!0;(o.button===2||s)&&a.preventDefault()}),onFocusOutside:Qm(i.onFocusOutside,a=>a.preventDefault())})}),mbn=pt.forwardRef((i,e)=>{const t=G2(_Q,i.__scopeDialog),n=pt.useRef(!1),r=pt.useRef(!1);return We.jsx(Vot,{...i,ref:e,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:a=>{var o,s;(o=i.onCloseAutoFocus)==null||o.call(i,a),a.defaultPrevented||(n.current||(s=t.triggerRef.current)==null||s.focus(),a.preventDefault()),n.current=!1,r.current=!1},onInteractOutside:a=>{var l,c;(l=i.onInteractOutside)==null||l.call(i,a),a.defaultPrevented||(n.current=!0,a.detail.originalEvent.type==="pointerdown"&&(r.current=!0));const o=a.target;((c=t.triggerRef.current)==null?void 0:c.contains(o))&&a.preventDefault(),a.detail.originalEvent.type==="focusin"&&r.current&&a.preventDefault()}})}),Vot=pt.forwardRef((i,e)=>{const{__scopeDialog:t,trapFocus:n,onOpenAutoFocus:r,onCloseAutoFocus:a,...o}=i,s=G2(_Q,t),l=pt.useRef(null),c=k9(e,l);return wet(),We.jsxs(We.Fragment,{children:[We.jsx(rme,{asChild:!0,loop:!0,trapped:n,onMountAutoFocus:r,onUnmountAutoFocus:a,children:We.jsx(eme,{role:"dialog",id:s.contentId,"aria-describedby":s.descriptionId,"aria-labelledby":s.titleId,"data-state":kve(s.open),...o,ref:c,onDismiss:()=>s.onOpenChange(!1)})}),We.jsxs(We.Fragment,{children:[We.jsx(vbn,{titleId:s.titleId}),We.jsx(Ibn,{contentRef:l,descriptionId:s.descriptionId})]})]})}),Pve="DialogTitle",jot=pt.forwardRef((i,e)=>{const{__scopeDialog:t,...n}=i,r=G2(Pve,t);return We.jsx(iC.h2,{id:r.titleId,...n,ref:e})});jot.displayName=Pve;var Kot="DialogDescription",Jot=pt.forwardRef((i,e)=>{const{__scopeDialog:t,...n}=i,r=G2(Kot,t);return We.jsx(iC.p,{id:r.descriptionId,...n,ref:e})});Jot.displayName=Kot;var qot="DialogClose",Xot=pt.forwardRef((i,e)=>{const{__scopeDialog:t,...n}=i,r=G2(qot,t);return We.jsx(iC.button,{type:"button",...n,ref:e,onClick:Qm(i.onClick,()=>r.onOpenChange(!1))})});Xot.displayName=qot;function kve(i){return i?"open":"closed"}var Zot="DialogTitleWarning",[ybn,Wot]=Y7t(Zot,{contentName:_Q,titleName:Pve,docsSlug:"dialog"}),vbn=({titleId:i})=>{const e=Wot(Zot),t=`\`${e.contentName}\` requires a \`${e.titleName}\` for the component to be accessible for screen reader users.
13750
13750
 
13751
13751
  If you want to hide the \`${e.titleName}\`, you can wrap it with our VisuallyHidden component.
13752
13752