@tscircuit/runframe 0.0.1688 → 0.0.1689

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.
@@ -1730,7 +1730,7 @@ var useErrorTelemetry = ({
1730
1730
  };
1731
1731
 
1732
1732
  // package.json
1733
- var version = "0.0.1687";
1733
+ var version = "0.0.1688";
1734
1734
  var package_default = {
1735
1735
  name: "@tscircuit/runframe",
1736
1736
  main: "dist/preview.js",
@@ -1790,7 +1790,7 @@ var package_default = {
1790
1790
  "@tscircuit/pcb-viewer": "1.11.346",
1791
1791
  "@tscircuit/props": "^0.0.455",
1792
1792
  "@tscircuit/schematic-trace-solver": "^0.0.40",
1793
- "@tscircuit/schematic-viewer": "^2.0.57",
1793
+ "@tscircuit/schematic-viewer": "^2.0.58",
1794
1794
  "@types/bun": "latest",
1795
1795
  "@types/debug": "^4.1.12",
1796
1796
  "@types/react": "^19.1.10",
package/dist/preview.js CHANGED
@@ -8,7 +8,7 @@ import {
8
8
  linkify,
9
9
  useOrderDialog,
10
10
  useOrderDialogCli
11
- } from "./chunk-UAJ526UQ.js";
11
+ } from "./chunk-47663OJ5.js";
12
12
  export {
13
13
  BomTable,
14
14
  CadViewer,
package/dist/runner.js CHANGED
@@ -34,7 +34,7 @@ import {
34
34
  useRunFrameStore,
35
35
  useRunnerStore,
36
36
  useStyles
37
- } from "./chunk-UAJ526UQ.js";
37
+ } from "./chunk-47663OJ5.js";
38
38
 
39
39
  // lib/components/RunFrame/RunFrame.tsx
40
40
  import { createCircuitWebWorker } from "@tscircuit/eval/worker";
@@ -5367,7 +5367,7 @@ svg { font-family: 'Inter', 'Helvetica Neue', Arial, sans-serif; }
5367
5367
  50% { opacity: 0.2; }
5368
5368
  100% { opacity: 0.6; }
5369
5369
  }
5370
- `,n.appendChild(u)}})}};o();const s=new MutationObserver(o);return s.observe(n,{childList:!0,subtree:!1,characterData:!1}),()=>{s.disconnect()}},[t,e,A,i])},noe=["#8B0000","#2F4F4F","#191970","#006400","#FF4500","#800080","#2E8B57","#B8860B","#C71585","#008B8B"],zKt=t=>{const{svgDivRef:A,circuitJson:e,circuitJsonKey:i,showGroups:n}=t;AA.useEffect(()=>{if(A.current&&A.current.querySelectorAll(".schematic-group-overlay").forEach(r=>r.remove()),!A.current||!n||!e||e.length===0)return;const o=setTimeout(()=>{if(!A.current)return;const s=A.current.querySelector("svg");if(!s)return;s.querySelectorAll(".schematic-group-overlay").forEach(a=>a.remove());try{const a=nu(e).source_group?.list().filter(u=>!u.is_subcircuit)||[],g=nu(e).schematic_component?.list()||[],c=new Map;a.forEach(u=>{const d=u;if(d.parent_source_group_id){const f=c.get(d.parent_source_group_id)||[];f.push(u.source_group_id),c.set(d.parent_source_group_id,f)}});const I=u=>{const d=[],f=c.get(u)||[];for(const m of f)d.push(m),d.push(...I(m));return d},l=u=>{const d=a.find(f=>f.source_group_id===u);return d?.parent_source_group_id?1+l(d.parent_source_group_id):0},B=a.length>0&&a.some(u=>u.name&&u.name.trim()!=="");let C=[];if(B){const u=new Map;for(const d of g){const f=nu(e).source_component.get(d.source_component_id);f?.source_group_id&&(u.has(f.source_group_id)||u.set(f.source_group_id,[]),u.get(f.source_group_id).push(d))}a.forEach((d,f)=>{let m=u.get(d.source_group_id)||[];const w=I(d.source_group_id);for(const S of w){const b=u.get(S)||[];m=[...m,...b]}if(m.length>0){const S=l(d.source_group_id),b=I(d.source_group_id).length>0;if(d.name?.startsWith("unnamed_board"))return;C.push({id:d.source_group_id,name:d.name||`Group ${f+1}`,components:m,color:noe[f%noe.length],depthLevel:S,hasChildren:b,sourceGroupId:d.source_group_id})}})}const Q=s.viewBox.baseVal,h=s.getBoundingClientRect(),E=Math.min(h.width/Q.width,h.height/Q.height)||1;C.sort((u,d)=>u.depthLevel-d.depthLevel),C.forEach(u=>{if(u.components.length===0)return;const d=XKt(u.components,s);if(!d)return;const f=Math.max(8,Math.min(25,15/Math.max(E,.3))),m=u.hasChildren?f*.6:0,w=f+m,S=Math.max(1,2/Math.max(E,.5)),b=u.depthLevel===0?S:S*.7,k=Math.max(4,8/Math.max(E,.5)),x=u.hasChildren?1.3:1,M=k*x,R=M*.5,U=document.createElementNS("http://www.w3.org/2000/svg","rect");U.setAttribute("class","schematic-group-overlay"),U.setAttribute("x",(d.minX-w).toString()),U.setAttribute("y",(d.minY-w).toString()),U.setAttribute("width",(d.maxX-d.minX+w*2).toString()),U.setAttribute("height",(d.maxY-d.minY+w*2).toString()),U.setAttribute("fill","none"),U.setAttribute("stroke",u.color),U.setAttribute("stroke-width",b.toString()),U.setAttribute("stroke-dasharray",`${M},${R}`),U.setAttribute("opacity","0.8"),U.setAttribute("rx","0"),U.setAttribute("ry","0");const J=Math.max(6,Math.min(20,14/Math.max(E,.2))),T=u.depthLevel===0||u.depthLevel===1?0:u.depthLevel*.2,O=J*(1-T),W=Math.max(1,O*.2),z=u.name,iA=document.createElementNS("http://www.w3.org/2000/svg","text");iA.setAttribute("font-size",O.toString()),iA.setAttribute("font-family","Arial, sans-serif"),iA.textContent=z,s.appendChild(iA);const gA=iA.getBBox();s.removeChild(iA);const eA=gA.width+W*2,nA=O+W*2,sA=d.minX-w,QA=d.minY-w-nA,bA=document.createElementNS("http://www.w3.org/2000/svg","rect");bA.setAttribute("class","schematic-group-overlay"),bA.setAttribute("x",sA.toString()),bA.setAttribute("y",(QA-nA).toString()),bA.setAttribute("width",eA.toString()),bA.setAttribute("height",nA.toString()),bA.setAttribute("fill","transparent"),bA.setAttribute("rx","0"),bA.setAttribute("ry","0");const TA=document.createElementNS("http://www.w3.org/2000/svg","text");TA.setAttribute("class","schematic-group-overlay"),TA.setAttribute("x",(sA+W).toString()),TA.setAttribute("y",(QA+nA-W).toString()),TA.setAttribute("fill",u.color),TA.setAttribute("font-size",O.toString()),TA.setAttribute("font-family","Arial, sans-serif"),TA.setAttribute("font-weight",u.depthLevel===0?"600":"500"),TA.setAttribute("stroke",u.color),TA.setAttribute("stroke-width",Math.max(.2,O*.02).toString()),TA.textContent=z,s.appendChild(U),s.appendChild(bA),s.appendChild(TA)})}catch(a){console.error("Error creating group overlays:",a)}},10);return()=>clearTimeout(o)},[A,i,n])};function XKt(t,A){let e=1/0,i=1/0,n=-1/0,o=-1/0;for(const r of t){let a=A.querySelector(`g[data-schematic-component-id="${r.schematic_component_id}"]`);if(a||(a=A.querySelector(`[data-schematic-component-id="${r.schematic_component_id}"]`)),a){const g=a.getBBox();e=Math.min(e,g.x),i=Math.min(i,g.y),n=Math.max(n,g.x+g.width),o=Math.max(o,g.y+g.height)}}return e===1/0?null:{minX:e,minY:i,maxX:n,maxY:o}}var $Kt=Oc("schematic-viewer"),APt=()=>{Oc.enable("schematic-viewer*")},ePt=$Kt,ooe=t=>{const[A,e]=AA.useState(0),[i,n]=AA.useState(0);return AA.useEffect(()=>{if(!t.current)return;const o=()=>{const r=t.current?.getBoundingClientRect();e(r?.width||0),n(r?.height||0)};o();const s=new ResizeObserver(o);return s.observe(t.current),window.addEventListener("resize",o),()=>{s.disconnect(),window.removeEventListener("resize",o)}},[]),{containerWidth:A,containerHeight:i}},tPt=ePt.extend("useComponentDragging"),iPt=({onEditEvent:t,editEvents:A=[],circuitJson:e,cancelDrag:i,svgToScreenProjection:n,realToSvgProjection:o,enabled:s=!1,snapToGrid:r=!1})=>{const[a,g]=AA.useState(null),c=nl(o,n),I=AA.useRef(null),l=AA.useRef(null),B=AA.useRef(new Map);AA.useEffect(()=>{A.forEach(S=>{"edit_event_type"in S&&S.edit_event_type==="edit_schematic_component_location"&&!S.in_progress&&B.current.set(S.schematic_component_id,{...S.new_center})})},[A]);const C=AA.useCallback((S,b,k)=>{if(!s)return!1;const x=k.closest('[data-circuit-json-type="schematic_component"]');if(!x)return!1;const M=x.getAttribute("data-schematic-component-id");if(!M)return!1;i&&i();const R=nu(e).schematic_component.get(M);if(!R)return!1;I.current={x:S,y:b};let U;const J=B.current.get(M);if(J)U={...J};else{const O=ioe({editEvents:A,schematic_component_id:M});U={x:R.center.x+O.x,y:R.center.y+O.y},B.current.set(M,{...U})}const T={edit_event_id:Math.random().toString(36).substr(2,9),edit_event_type:"edit_schematic_component_location",schematic_component_id:M,original_center:U,new_center:{...U},in_progress:!0,created_at:Date.now(),_element:x};return l.current=T,g(T),!0},[i,s,e,A]),Q=AA.useCallback(S=>{C(S.clientX,S.clientY,S.target)},[C]),h=AA.useCallback(S=>{if(S.touches.length!==1)return;const b=S.touches[0];C(b.clientX,b.clientY,S.target)&&S.preventDefault()},[C]),E=AA.useCallback((S,b)=>{if(!l.current||!I.current)return;const k={x:S-I.current.x,y:b-I.current.y},x={x:k.x/c.a,y:k.y/c.d};let M={x:l.current.original_center.x+x.x,y:l.current.original_center.y+x.y};if(r){const U=J=>Math.round(J*10)/10;M={x:U(M.x),y:U(M.y)}}const R={...l.current,new_center:M};l.current=R,g(R)},[c,r]),u=AA.useCallback(S=>E(S.clientX,S.clientY),[E]),d=AA.useCallback(S=>{if(S.touches.length!==1||!l.current)return;S.preventDefault();const b=S.touches[0];E(b.clientX,b.clientY)},[E]),f=AA.useCallback(()=>{if(!l.current)return;const S={...l.current,in_progress:!1};B.current.set(S.schematic_component_id,{...S.new_center}),tPt("endDrag calling onEditEvent with new edit event",{newEditEvent:S}),t&&t(S),l.current=null,I.current=null,g(null)},[t]),m=AA.useCallback(()=>f(),[f]),w=AA.useCallback(()=>f(),[f]);return AA.useEffect(()=>(window.addEventListener("mousemove",u),window.addEventListener("mouseup",m),window.addEventListener("touchmove",d,{passive:!1}),window.addEventListener("touchend",w),()=>{window.removeEventListener("mousemove",u),window.removeEventListener("mouseup",m),window.removeEventListener("touchmove",d),window.removeEventListener("touchend",w)}),[u,m,d,w]),{handleMouseDown:Q,handleTouchStart:h,isDragging:!!l.current,activeEditEvent:a}},LD={schematicEditIcon:50,schematicGridIcon:49,spiceSimulationIcon:50,viewMenuIcon:48,viewMenu:55,viewMenuBackdrop:54,clickToInteractOverlay:100,schematicComponentHoverOutline:47,schematicPortHoverOutline:48},nPt=({onClick:t,active:A})=>{const e=i=>{i.preventDefault(),t()};return Z.jsx("div",{onClick:e,onTouchEnd:e,title:A?"Disable edit mode":"Enable edit mode",style:{position:"absolute",top:"16px",right:"64px",backgroundColor:A?"#4CAF50":"#fff",color:A?"#fff":"#000",padding:"8px",borderRadius:"4px",cursor:"pointer",boxShadow:"0 2px 4px rgba(0,0,0,0.1)",display:"flex",alignItems:"center",gap:"4px",zIndex:LD.schematicEditIcon},children:Z.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[Z.jsx("path",{d:"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"}),Z.jsx("path",{d:"M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"})]})})},oPt=({onClick:t,active:A})=>{const e=i=>{i.preventDefault(),t()};return Z.jsx("div",{onClick:e,onTouchEnd:e,title:A?"Hide grid":"Show grid",style:{position:"absolute",top:"56px",right:"64px",backgroundColor:A?"#4CAF50":"#fff",color:A?"#fff":"#000",padding:"8px",borderRadius:"4px",cursor:"pointer",boxShadow:"0 2px 4px rgba(0,0,0,0.1)",display:"flex",alignItems:"center",gap:"4px",zIndex:LD.schematicGridIcon},children:Z.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:Z.jsx("path",{d:"M3 3h7v7H3zM14 3h7v7h-7zM3 14h7v7H3zM14 14h7v7h-7z"})})})},sPt=({onClick:t,active:A})=>{const e=i=>{i.preventDefault(),t()};return Z.jsx("div",{onClick:e,onTouchEnd:e,title:A?"Hide view menu":"Show view menu",style:{position:"absolute",top:"16px",right:"16px",backgroundColor:A?"#4CAF50":"#fff",color:A?"#fff":"#000",padding:"8px",borderRadius:"4px",cursor:"pointer",boxShadow:"0 2px 4px rgba(0,0,0,0.1)",display:"flex",alignItems:"center",gap:"4px",zIndex:LD.viewMenuIcon},children:Z.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[Z.jsx("circle",{cx:"12",cy:"12",r:"1"}),Z.jsx("circle",{cx:"12",cy:"5",r:"1"}),Z.jsx("circle",{cx:"12",cy:"19",r:"1"})]})})},rPt={version:"2.0.56"},aPt=({circuitJson:t,circuitJsonKey:A,isVisible:e,onClose:i,showGroups:n,onToggleGroups:o,showGrid:s,onToggleGrid:r})=>{const a=AA.useMemo(()=>{if(!t||t.length===0)return!1;try{if((nu(t).source_group?.list()||[]).length>0)return!0;const c=nu(t).schematic_component?.list()||[];if(c.length>1){const I=new Set;for(const l of c){const B=nu(t).source_component.get(l.source_component_id);B?.ftype&&I.add(B.ftype)}return I.size>1}return!1}catch(g){return console.error("Error checking for groups:",g),!1}},[A]);return e?Z.jsxs(Z.Fragment,{children:[Z.jsx("div",{onClick:i,onTouchEnd:g=>{g.preventDefault(),i()},style:{position:"absolute",inset:0,backgroundColor:"transparent",zIndex:LD.viewMenuBackdrop}}),Z.jsxs("div",{style:{position:"absolute",top:"56px",right:"16px",backgroundColor:"#ffffff",color:"#000000",border:"1px solid #ccc",borderRadius:"4px",boxShadow:"0 4px 12px rgba(0,0,0,0.1)",minWidth:"200px",zIndex:LD.viewMenu},children:[Z.jsxs("div",{onClick:()=>{a&&o(!n)},onTouchEnd:g=>{g.preventDefault(),a&&o(!n)},style:{padding:"8px 12px",cursor:a?"pointer":"not-allowed",opacity:a?1:.5,fontSize:"13px",color:"#000000",fontFamily:"sans-serif",display:"flex",alignItems:"center",gap:"8px"},onMouseEnter:g=>{a&&(g.currentTarget.style.backgroundColor="#f0f0f0")},onMouseLeave:g=>{a&&(g.currentTarget.style.backgroundColor="transparent")},children:[Z.jsx("div",{style:{width:"16px",height:"16px",border:"2px solid #000",borderRadius:"2px",backgroundColor:"transparent",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"10px",fontWeight:"bold"},children:n&&"✓"}),"View Schematic Groups"]}),!a&&Z.jsx("div",{style:{padding:"8px 12px",fontSize:"11px",color:"#666",fontStyle:"italic"},children:"No groups found in this schematic"}),Z.jsxs("div",{onClick:()=>r(!s),onTouchEnd:g=>{g.preventDefault(),r(!s)},style:{padding:"8px 12px",cursor:"pointer",fontSize:"13px",color:"#000000",fontFamily:"sans-serif",display:"flex",alignItems:"center",gap:"8px"},onMouseEnter:g=>{g.currentTarget.style.backgroundColor="#f0f0f0"},onMouseLeave:g=>{g.currentTarget.style.backgroundColor="transparent"},children:[Z.jsx("div",{style:{width:"16px",height:"16px",border:"2px solid #000",borderRadius:"2px",backgroundColor:"transparent",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"10px",fontWeight:"bold"},children:s&&"✓"}),"Show Grid"]}),Z.jsxs("div",{style:{padding:"4px 8px",fontSize:"12px",color:"#999",borderTop:"1px solid #eee",textAlign:"center"},children:["v",String(rPt?.version)]})]})]}):null},gPt=()=>Z.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:Z.jsx("path",{d:"M3 12h2.5l2.5-9 4 18 4-9h5.5"})}),cPt=({onClick:t})=>Z.jsx("div",{onClick:t,title:"Run SPICE simulation",style:{position:"absolute",top:"16px",right:"112px",backgroundColor:"#fff",color:"#000",padding:"8px",borderRadius:"4px",cursor:"pointer",boxShadow:"0 2px 4px rgba(0,0,0,0.1)",display:"flex",alignItems:"center",gap:"4px",zIndex:LD.spiceSimulationIcon},children:Z.jsx(gPt,{})});l9.register(NKt,HKt,hKt,QKt,wKt,GKt,yKt);var h9=["#8884d8","#82ca9d","#ffc658","#ff7300","#387908"],soe=t=>{if(t===0)return"0s";const A=Math.abs(t);let e="s",i=1;return A<1e-12?(e="fs",i=1e15):A<1e-9?(e="ps",i=1e12):A<1e-6?(e="ns",i=1e9):A<.001?(e="us",i=1e6):A<1&&(e="ms",i=1e3),`${parseFloat((t*i).toPrecision(3))}${e}`},IPt=({plotData:t,nodes:A,isLoading:e,error:i,hasRun:n})=>{const o=AA.useMemo(()=>{const a=A.some(c=>c.toLowerCase().startsWith("v(")),g=A.some(c=>c.toLowerCase().startsWith("i("));return a&&g?"Value":a?"Voltage (V)":g?"Current (A)":"Value"},[A]);if(e)return Z.jsx("div",{style:{height:"300px",width:"100%",display:"flex",alignItems:"center",justifyContent:"center"},children:"Running simulation..."});if(!n)return Z.jsx("div",{style:{height:"300px",width:"100%",display:"flex",alignItems:"center",justifyContent:"center"},children:'Click "Run" to start the simulation.'});if(i)return Z.jsxs("div",{style:{height:"300px",width:"100%",display:"flex",alignItems:"center",justifyContent:"center",color:"red"},children:["Error: ",i]});if(t.length===0)return Z.jsx("div",{style:{height:"300px",width:"100%",display:"flex",alignItems:"center",justifyContent:"center"},children:"No data to plot. Check simulation output or SPICE netlist."});const s={datasets:A.map((a,g)=>({label:a,data:t.map(c=>({x:Number(c.name),y:c[a]})),borderColor:h9[g%h9.length],backgroundColor:h9[g%h9.length],fill:!1,tension:.1}))},r={responsive:!0,maintainAspectRatio:!1,plugins:{legend:{position:"top",labels:{font:{family:"sans-serif"}}},title:{display:!1},tooltip:{callbacks:{title:a=>{if(a.length>0){const g=a[0];return soe(g.parsed.x)}return""}}}},scales:{x:{type:"linear",title:{display:!0,text:"Time",font:{family:"sans-serif"}},ticks:{callback:a=>soe(a),font:{family:"sans-serif"}}},y:{title:{display:!0,text:o,font:{family:"sans-serif"}},ticks:{font:{family:"sans-serif"}}}}};return Z.jsx("div",{style:{position:"relative",height:"300px",width:"100%"},children:Z.jsx(ZKt,{options:r,data:s})})},lPt=({spiceString:t,onClose:A,plotData:e,nodes:i,isLoading:n,error:o,simOptions:s,onSimOptionsChange:r,hasRun:a})=>{const[g,c]=AA.useState(String(s.startTime)),[I,l]=AA.useState(String(s.duration));AA.useEffect(()=>{c(String(s.startTime)),l(String(s.duration))},[s.startTime,s.duration]);const B=()=>{r({...s,startTime:Number(g),duration:Number(I)})},C=i.filter(Q=>{const h=Q.toLowerCase().startsWith("v("),E=Q.toLowerCase().startsWith("i(");return!!(s.showVoltage&&h||s.showCurrent&&E)});return Z.jsx("div",{style:{position:"fixed",top:0,left:0,right:0,bottom:0,backgroundColor:"rgba(0, 0, 0, 0.5)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1002,fontFamily:"sans-serif"},children:Z.jsxs("div",{style:{backgroundColor:"white",padding:"24px",borderRadius:"12px",width:"90%",maxWidth:"900px",boxShadow:"0 4px 20px rgba(0, 0, 0, 0.15)"},children:[Z.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"24px",borderBottom:"1px solid #eee",paddingBottom:"16px"},children:[Z.jsx("h2",{style:{margin:0,fontSize:"22px",fontWeight:600,color:"#333"},children:"SPICE Simulation"}),Z.jsx("button",{onClick:A,style:{background:"none",border:"none",fontSize:"28px",cursor:"pointer",color:"#888",padding:0,lineHeight:1},children:"×"})]}),Z.jsx("div",{children:Z.jsx(IPt,{plotData:e,nodes:C,isLoading:n,error:o,hasRun:a})}),Z.jsxs("div",{style:{marginTop:"16px",padding:"12px",backgroundColor:"#f7f7f7",borderRadius:"6px",display:"flex",flexWrap:"wrap",gap:"24px",alignItems:"center",fontSize:"14px"},children:[Z.jsxs("div",{style:{display:"flex",gap:"16px"},children:[Z.jsxs("label",{style:{display:"flex",alignItems:"center",gap:"6px"},children:[Z.jsx("input",{type:"checkbox",checked:s.showVoltage,onChange:Q=>r({...s,showVoltage:Q.target.checked})}),"Voltage"]}),Z.jsxs("label",{style:{display:"flex",alignItems:"center",gap:"6px"},children:[Z.jsx("input",{type:"checkbox",checked:s.showCurrent,onChange:Q=>r({...s,showCurrent:Q.target.checked})}),"Current"]})]}),Z.jsxs("div",{style:{display:"flex",gap:"16px",alignItems:"center"},children:[Z.jsx("label",{htmlFor:"startTime",children:"Start Time (ms):"}),Z.jsx("input",{id:"startTime",type:"number",value:g,onChange:Q=>c(Q.target.value),style:{width:"80px",padding:"4px 8px",borderRadius:"4px",border:"1px solid #ccc"}}),Z.jsx("label",{htmlFor:"duration",children:"Duration (ms):"}),Z.jsx("input",{id:"duration",type:"number",value:I,onChange:Q=>l(Q.target.value),style:{width:"80px",padding:"4px 8px",borderRadius:"4px",border:"1px solid #ccc"}}),Z.jsx("button",{onClick:B,style:{padding:"4px 12px",borderRadius:"4px",border:"1px solid #ccc",backgroundColor:"#f0f0f0",cursor:"pointer"},children:a?"Rerun":"Run"})]})]}),Z.jsxs("div",{style:{marginTop:"24px"},children:[Z.jsx("h3",{style:{marginTop:0,marginBottom:"12px",fontSize:"18px",fontWeight:600,color:"#333"},children:"SPICE Netlist"}),Z.jsx("pre",{style:{backgroundColor:"#fafafa",padding:"16px",borderRadius:"6px",maxHeight:"150px",overflowY:"auto",border:"1px solid #eee",color:"#333",fontSize:"13px",fontFamily:"monospace"},children:t})]})]})})},BPt="dmFyIGU9bnVsbCxzPWFzeW5jKCk9Pihhd2FpdCBpbXBvcnQoImh0dHBzOi8vY2RuLmpzZGVsaXZyLm5ldC9ucG0vZWVjaXJjdWl0LWVuZ2luZUAxLjUuMi8rZXNtIikpLlNpbXVsYXRpb24sYz1hc3luYygpPT57aWYoZSYmZS5pc0luaXRpYWxpemVkKCkpcmV0dXJuO2xldCBpPWF3YWl0IHMoKTtlPW5ldyBpLGF3YWl0IGUuc3RhcnQoKX07c2VsZi5vbm1lc3NhZ2U9YXN5bmMgaT0+e3RyeXtpZihhd2FpdCBjKCksIWUpdGhyb3cgbmV3IEVycm9yKCJTaW11bGF0aW9uIG5vdCBpbml0aWFsaXplZCIpO2xldCB0PWkuZGF0YS5zcGljZVN0cmluZyxhPXQubWF0Y2goL3dyZGF0YVxzKyhcUyspXHMrKC4qKS9pKTtpZihhKXtsZXQgbz1gLnByb2JlICR7YVsyXS50cmltKCkuc3BsaXQoL1xzKy8pLmpvaW4oIiAiKX1gO3Q9dC5yZXBsYWNlKC93cmRhdGEuKi9pLG8pfWVsc2UgaWYoIXQubWF0Y2goL1wucHJvYmUvaSkpdGhyb3cgdC5tYXRjaCgvcGxvdFxzKyguKikvaSk/bmV3IEVycm9yKCJUaGUgJ3Bsb3QnIGNvbW1hbmQgaXMgbm90IHN1cHBvcnRlZCBmb3IgZGF0YSBleHRyYWN0aW9uLiBQbGVhc2UgdXNlICd3cmRhdGEgPGZpbGVuYW1lPiA8dmFyMT4gLi4uJyBvciAnLnByb2JlIDx2YXIxPiAuLi4nIGluc3RlYWQuIik6bmV3IEVycm9yKCJObyAnLnByb2JlJyBvciAnd3JkYXRhJyBjb21tYW5kIGZvdW5kIGluIFNQSUNFIGZpbGUuIFVzZSAnd3JkYXRhIDxmaWxlbmFtZT4gPHZhcjE+IC4uLicgdG8gc3BlY2lmeSBvdXRwdXQuIik7ZS5zZXROZXRMaXN0KHQpO2xldCBuPWF3YWl0IGUucnVuU2ltKCk7c2VsZi5wb3N0TWVzc2FnZSh7dHlwZToicmVzdWx0IixyZXN1bHQ6bn0pfWNhdGNoKHQpe3NlbGYucG9zdE1lc3NhZ2Uoe3R5cGU6ImVycm9yIixlcnJvcjp0Lm1lc3NhZ2V9KX19Owo=",E9=null,CPt=()=>{if(typeof window>"u")return null;if(E9)return E9;try{const t=new Blob([atob(BPt)],{type:"application/javascript"});return E9=URL.createObjectURL(t),E9}catch(t){return console.error("Failed to create blob URL for worker",t),null}},QPt=t=>{const A={};if(t.dataType==="real")t.data.forEach(r=>{A[r.name]=r.values});else if(t.dataType==="complex")t.data.forEach(r=>{A[r.name]=r.values.map(a=>a.real)});else throw new Error("Unsupported data type in simulation result");const e=Object.keys(A).find(r=>r.toLowerCase()==="time"||r.toLowerCase()==="frequency");if(!e)throw new Error("No time or frequency data in simulation result");const i=A[e],n=Object.keys(A).filter(r=>r!==e),o=n;return{plotData:i.map((r,a)=>{const g={name:r.toExponential(2)};return n.forEach(c=>{g[c]=A[c][a]}),g}),nodes:o}},hPt=t=>{const[A,e]=AA.useState([]),[i,n]=AA.useState([]),[o,s]=AA.useState(!0),[r,a]=AA.useState(null);return AA.useEffect(()=>{if(!t){s(!1),e([]),n([]),a(null);return}s(!0),a(null),e([]),n([]);const g=CPt();if(!g){a("Could not create SPICE simulation worker."),s(!1);return}const c=new Worker(g,{type:"module"});return c.onmessage=I=>{if(I.data.type==="result")try{const{plotData:l,nodes:B}=QPt(I.data.result);e(l),n(B)}catch(l){a(l.message||"Failed to parse simulation result"),console.error(l)}else I.data.type==="error"&&a(I.data.error);s(!1)},c.onerror=I=>{a(I.message),s(!1)},c.postMessage({spiceString:t}),()=>{c.terminate()}},[t]),{plotData:A,nodes:i,isLoading:o,error:r}},hdA=t=>{if(t===0)return"0";const A=Math.abs(t),e=i=>i.toPrecision(4);return A>=1?e(t):A>=.001?`${e(t*1e3)}m`:A>=1e-6?`${e(t*1e6)}u`:A>=1e-9?`${e(t*1e9)}n`:A>=1e-12?`${e(t*1e12)}p`:A>=1e-15?`${e(t*1e15)}f`:t.toExponential(3)},EPt=(t,A)=>{const i=BPA(t).toSpiceString(),o=i.split(`
5370
+ `,n.appendChild(u)}})}};o();const s=new MutationObserver(o);return s.observe(n,{childList:!0,subtree:!1,characterData:!1}),()=>{s.disconnect()}},[t,e,A,i])},noe=["#8B0000","#2F4F4F","#191970","#006400","#FF4500","#800080","#2E8B57","#B8860B","#C71585","#008B8B"],zKt=t=>{const{svgDivRef:A,circuitJson:e,circuitJsonKey:i,showGroups:n}=t;AA.useEffect(()=>{if(A.current&&A.current.querySelectorAll(".schematic-group-overlay").forEach(r=>r.remove()),!A.current||!n||!e||e.length===0)return;const o=setTimeout(()=>{if(!A.current)return;const s=A.current.querySelector("svg");if(!s)return;s.querySelectorAll(".schematic-group-overlay").forEach(a=>a.remove());try{const a=nu(e).source_group?.list().filter(u=>!u.is_subcircuit)||[],g=nu(e).schematic_component?.list()||[],c=new Map;a.forEach(u=>{const d=u;if(d.parent_source_group_id){const f=c.get(d.parent_source_group_id)||[];f.push(u.source_group_id),c.set(d.parent_source_group_id,f)}});const I=u=>{const d=[],f=c.get(u)||[];for(const m of f)d.push(m),d.push(...I(m));return d},l=u=>{const d=a.find(f=>f.source_group_id===u);return d?.parent_source_group_id?1+l(d.parent_source_group_id):0},B=a.length>0&&a.some(u=>u.name&&u.name.trim()!=="");let C=[];if(B){const u=new Map;for(const d of g){const f=nu(e).source_component.get(d.source_component_id);f?.source_group_id&&(u.has(f.source_group_id)||u.set(f.source_group_id,[]),u.get(f.source_group_id).push(d))}a.forEach((d,f)=>{let m=u.get(d.source_group_id)||[];const w=I(d.source_group_id);for(const S of w){const b=u.get(S)||[];m=[...m,...b]}if(m.length>0){const S=l(d.source_group_id),b=I(d.source_group_id).length>0;if(d.name?.startsWith("unnamed_board"))return;C.push({id:d.source_group_id,name:d.name||`Group ${f+1}`,components:m,color:noe[f%noe.length],depthLevel:S,hasChildren:b,sourceGroupId:d.source_group_id})}})}const Q=s.viewBox.baseVal,h=s.getBoundingClientRect(),E=Math.min(h.width/Q.width,h.height/Q.height)||1;C.sort((u,d)=>u.depthLevel-d.depthLevel),C.forEach(u=>{if(u.components.length===0)return;const d=XKt(u.components,s);if(!d)return;const f=Math.max(8,Math.min(25,15/Math.max(E,.3))),m=u.hasChildren?f*.6:0,w=f+m,S=Math.max(1,2/Math.max(E,.5)),b=u.depthLevel===0?S:S*.7,k=Math.max(4,8/Math.max(E,.5)),x=u.hasChildren?1.3:1,M=k*x,R=M*.5,U=document.createElementNS("http://www.w3.org/2000/svg","rect");U.setAttribute("class","schematic-group-overlay"),U.setAttribute("x",(d.minX-w).toString()),U.setAttribute("y",(d.minY-w).toString()),U.setAttribute("width",(d.maxX-d.minX+w*2).toString()),U.setAttribute("height",(d.maxY-d.minY+w*2).toString()),U.setAttribute("fill","none"),U.setAttribute("stroke",u.color),U.setAttribute("stroke-width",b.toString()),U.setAttribute("stroke-dasharray",`${M},${R}`),U.setAttribute("opacity","0.8"),U.setAttribute("rx","0"),U.setAttribute("ry","0");const J=Math.max(6,Math.min(20,14/Math.max(E,.2))),T=u.depthLevel===0||u.depthLevel===1?0:u.depthLevel*.2,O=J*(1-T),W=Math.max(1,O*.2),z=u.name,iA=document.createElementNS("http://www.w3.org/2000/svg","text");iA.setAttribute("font-size",O.toString()),iA.setAttribute("font-family","Arial, sans-serif"),iA.textContent=z,s.appendChild(iA);const gA=iA.getBBox();s.removeChild(iA);const eA=gA.width+W*2,nA=O+W*2,sA=d.minX-w,QA=d.minY-w-nA,bA=document.createElementNS("http://www.w3.org/2000/svg","rect");bA.setAttribute("class","schematic-group-overlay"),bA.setAttribute("x",sA.toString()),bA.setAttribute("y",(QA-nA).toString()),bA.setAttribute("width",eA.toString()),bA.setAttribute("height",nA.toString()),bA.setAttribute("fill","transparent"),bA.setAttribute("rx","0"),bA.setAttribute("ry","0");const TA=document.createElementNS("http://www.w3.org/2000/svg","text");TA.setAttribute("class","schematic-group-overlay"),TA.setAttribute("x",(sA+W).toString()),TA.setAttribute("y",(QA+nA-W).toString()),TA.setAttribute("fill",u.color),TA.setAttribute("font-size",O.toString()),TA.setAttribute("font-family","Arial, sans-serif"),TA.setAttribute("font-weight",u.depthLevel===0?"600":"500"),TA.setAttribute("stroke",u.color),TA.setAttribute("stroke-width",Math.max(.2,O*.02).toString()),TA.textContent=z,s.appendChild(U),s.appendChild(bA),s.appendChild(TA)})}catch(a){console.error("Error creating group overlays:",a)}},10);return()=>clearTimeout(o)},[A,i,n])};function XKt(t,A){let e=1/0,i=1/0,n=-1/0,o=-1/0;for(const r of t){let a=A.querySelector(`g[data-schematic-component-id="${r.schematic_component_id}"]`);if(a||(a=A.querySelector(`[data-schematic-component-id="${r.schematic_component_id}"]`)),a){const g=a.getBBox();e=Math.min(e,g.x),i=Math.min(i,g.y),n=Math.max(n,g.x+g.width),o=Math.max(o,g.y+g.height)}}return e===1/0?null:{minX:e,minY:i,maxX:n,maxY:o}}var $Kt=Oc("schematic-viewer"),APt=()=>{Oc.enable("schematic-viewer*")},ePt=$Kt,ooe=t=>{const[A,e]=AA.useState(0),[i,n]=AA.useState(0);return AA.useEffect(()=>{if(!t.current)return;const o=()=>{const r=t.current?.getBoundingClientRect();e(r?.width||0),n(r?.height||0)};o();const s=new ResizeObserver(o);return s.observe(t.current),window.addEventListener("resize",o),()=>{s.disconnect(),window.removeEventListener("resize",o)}},[]),{containerWidth:A,containerHeight:i}},tPt=ePt.extend("useComponentDragging"),iPt=({onEditEvent:t,editEvents:A=[],circuitJson:e,cancelDrag:i,svgToScreenProjection:n,realToSvgProjection:o,enabled:s=!1,snapToGrid:r=!1})=>{const[a,g]=AA.useState(null),c=nl(o,n),I=AA.useRef(null),l=AA.useRef(null),B=AA.useRef(new Map);AA.useEffect(()=>{A.forEach(S=>{"edit_event_type"in S&&S.edit_event_type==="edit_schematic_component_location"&&!S.in_progress&&B.current.set(S.schematic_component_id,{...S.new_center})})},[A]);const C=AA.useCallback((S,b,k)=>{if(!s)return!1;const x=k.closest('[data-circuit-json-type="schematic_component"]');if(!x)return!1;const M=x.getAttribute("data-schematic-component-id");if(!M)return!1;i&&i();const R=nu(e).schematic_component.get(M);if(!R)return!1;I.current={x:S,y:b};let U;const J=B.current.get(M);if(J)U={...J};else{const O=ioe({editEvents:A,schematic_component_id:M});U={x:R.center.x+O.x,y:R.center.y+O.y},B.current.set(M,{...U})}const T={edit_event_id:Math.random().toString(36).substr(2,9),edit_event_type:"edit_schematic_component_location",schematic_component_id:M,original_center:U,new_center:{...U},in_progress:!0,created_at:Date.now(),_element:x};return l.current=T,g(T),!0},[i,s,e,A]),Q=AA.useCallback(S=>{C(S.clientX,S.clientY,S.target)},[C]),h=AA.useCallback(S=>{if(S.touches.length!==1)return;const b=S.touches[0];C(b.clientX,b.clientY,S.target)&&S.preventDefault()},[C]),E=AA.useCallback((S,b)=>{if(!l.current||!I.current)return;const k={x:S-I.current.x,y:b-I.current.y},x={x:k.x/c.a,y:k.y/c.d};let M={x:l.current.original_center.x+x.x,y:l.current.original_center.y+x.y};if(r){const U=J=>Math.round(J*10)/10;M={x:U(M.x),y:U(M.y)}}const R={...l.current,new_center:M};l.current=R,g(R)},[c,r]),u=AA.useCallback(S=>E(S.clientX,S.clientY),[E]),d=AA.useCallback(S=>{if(S.touches.length!==1||!l.current)return;S.preventDefault();const b=S.touches[0];E(b.clientX,b.clientY)},[E]),f=AA.useCallback(()=>{if(!l.current)return;const S={...l.current,in_progress:!1};B.current.set(S.schematic_component_id,{...S.new_center}),tPt("endDrag calling onEditEvent with new edit event",{newEditEvent:S}),t&&t(S),l.current=null,I.current=null,g(null)},[t]),m=AA.useCallback(()=>f(),[f]),w=AA.useCallback(()=>f(),[f]);return AA.useEffect(()=>(window.addEventListener("mousemove",u),window.addEventListener("mouseup",m),window.addEventListener("touchmove",d,{passive:!1}),window.addEventListener("touchend",w),()=>{window.removeEventListener("mousemove",u),window.removeEventListener("mouseup",m),window.removeEventListener("touchmove",d),window.removeEventListener("touchend",w)}),[u,m,d,w]),{handleMouseDown:Q,handleTouchStart:h,isDragging:!!l.current,activeEditEvent:a}},LD={schematicEditIcon:50,schematicGridIcon:49,spiceSimulationIcon:50,viewMenuIcon:48,viewMenu:55,viewMenuBackdrop:54,clickToInteractOverlay:100,schematicComponentHoverOutline:47,schematicPortHoverOutline:48},nPt=({onClick:t,active:A})=>{const e=i=>{i.preventDefault(),t()};return Z.jsx("div",{onClick:e,onTouchEnd:e,title:A?"Disable edit mode":"Enable edit mode",style:{position:"absolute",top:"16px",right:"64px",backgroundColor:A?"#4CAF50":"#fff",color:A?"#fff":"#000",padding:"8px",borderRadius:"4px",cursor:"pointer",boxShadow:"0 2px 4px rgba(0,0,0,0.1)",display:"flex",alignItems:"center",gap:"4px",zIndex:LD.schematicEditIcon},children:Z.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[Z.jsx("path",{d:"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"}),Z.jsx("path",{d:"M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"})]})})},oPt=({onClick:t,active:A})=>{const e=i=>{i.preventDefault(),t()};return Z.jsx("div",{onClick:e,onTouchEnd:e,title:A?"Hide grid":"Show grid",style:{position:"absolute",top:"56px",right:"64px",backgroundColor:A?"#4CAF50":"#fff",color:A?"#fff":"#000",padding:"8px",borderRadius:"4px",cursor:"pointer",boxShadow:"0 2px 4px rgba(0,0,0,0.1)",display:"flex",alignItems:"center",gap:"4px",zIndex:LD.schematicGridIcon},children:Z.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:Z.jsx("path",{d:"M3 3h7v7H3zM14 3h7v7h-7zM3 14h7v7H3zM14 14h7v7h-7z"})})})},sPt=({onClick:t,active:A})=>{const e=i=>{i.preventDefault(),t()};return Z.jsx("div",{onClick:e,onTouchEnd:e,title:A?"Hide view menu":"Show view menu",style:{position:"absolute",top:"16px",right:"16px",backgroundColor:A?"#4CAF50":"#fff",color:A?"#fff":"#000",padding:"8px",borderRadius:"4px",cursor:"pointer",boxShadow:"0 2px 4px rgba(0,0,0,0.1)",display:"flex",alignItems:"center",gap:"4px",zIndex:LD.viewMenuIcon},children:Z.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[Z.jsx("circle",{cx:"12",cy:"12",r:"1"}),Z.jsx("circle",{cx:"12",cy:"5",r:"1"}),Z.jsx("circle",{cx:"12",cy:"19",r:"1"})]})})},rPt={version:"2.0.57"},aPt=({circuitJson:t,circuitJsonKey:A,isVisible:e,onClose:i,showGroups:n,onToggleGroups:o,showGrid:s,onToggleGrid:r})=>{const a=AA.useMemo(()=>{if(!t||t.length===0)return!1;try{if((nu(t).source_group?.list()||[]).length>0)return!0;const c=nu(t).schematic_component?.list()||[];if(c.length>1){const I=new Set;for(const l of c){const B=nu(t).source_component.get(l.source_component_id);B?.ftype&&I.add(B.ftype)}return I.size>1}return!1}catch(g){return console.error("Error checking for groups:",g),!1}},[A]);return e?Z.jsxs(Z.Fragment,{children:[Z.jsx("div",{onClick:i,onTouchEnd:g=>{g.preventDefault(),i()},style:{position:"absolute",inset:0,backgroundColor:"transparent",zIndex:LD.viewMenuBackdrop}}),Z.jsxs("div",{style:{position:"absolute",top:"56px",right:"16px",backgroundColor:"#ffffff",color:"#000000",border:"1px solid #ccc",borderRadius:"4px",boxShadow:"0 4px 12px rgba(0,0,0,0.1)",minWidth:"200px",zIndex:LD.viewMenu},children:[Z.jsxs("div",{onClick:()=>{a&&o(!n)},onTouchEnd:g=>{g.preventDefault(),a&&o(!n)},style:{padding:"8px 12px",cursor:a?"pointer":"not-allowed",opacity:a?1:.5,fontSize:"13px",color:"#000000",fontFamily:"sans-serif",display:"flex",alignItems:"center",gap:"8px"},onMouseEnter:g=>{a&&(g.currentTarget.style.backgroundColor="#f0f0f0")},onMouseLeave:g=>{a&&(g.currentTarget.style.backgroundColor="transparent")},children:[Z.jsx("div",{style:{width:"16px",height:"16px",border:"2px solid #000",borderRadius:"2px",backgroundColor:"transparent",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"10px",fontWeight:"bold"},children:n&&"✓"}),"View Schematic Groups"]}),!a&&Z.jsx("div",{style:{padding:"8px 12px",fontSize:"11px",color:"#666",fontStyle:"italic"},children:"No groups found in this schematic"}),Z.jsxs("div",{onClick:()=>r(!s),onTouchEnd:g=>{g.preventDefault(),r(!s)},style:{padding:"8px 12px",cursor:"pointer",fontSize:"13px",color:"#000000",fontFamily:"sans-serif",display:"flex",alignItems:"center",gap:"8px"},onMouseEnter:g=>{g.currentTarget.style.backgroundColor="#f0f0f0"},onMouseLeave:g=>{g.currentTarget.style.backgroundColor="transparent"},children:[Z.jsx("div",{style:{width:"16px",height:"16px",border:"2px solid #000",borderRadius:"2px",backgroundColor:"transparent",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"10px",fontWeight:"bold"},children:s&&"✓"}),"Show Grid"]}),Z.jsxs("div",{style:{padding:"4px 8px",fontSize:"12px",color:"#999",borderTop:"1px solid #eee",textAlign:"center"},children:["v",String(rPt?.version)]})]})]}):null},gPt=()=>Z.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:Z.jsx("path",{d:"M3 12h2.5l2.5-9 4 18 4-9h5.5"})}),cPt=({onClick:t})=>Z.jsx("div",{onClick:t,title:"Run SPICE simulation",style:{position:"absolute",top:"16px",right:"112px",backgroundColor:"#fff",color:"#000",padding:"8px",borderRadius:"4px",cursor:"pointer",boxShadow:"0 2px 4px rgba(0,0,0,0.1)",display:"flex",alignItems:"center",gap:"4px",zIndex:LD.spiceSimulationIcon},children:Z.jsx(gPt,{})});l9.register(NKt,HKt,hKt,QKt,wKt,GKt,yKt);var h9=["#8884d8","#82ca9d","#ffc658","#ff7300","#387908"],soe=t=>{if(t===0)return"0s";const A=Math.abs(t);let e="s",i=1;return A<1e-12?(e="fs",i=1e15):A<1e-9?(e="ps",i=1e12):A<1e-6?(e="ns",i=1e9):A<.001?(e="us",i=1e6):A<1&&(e="ms",i=1e3),`${parseFloat((t*i).toPrecision(3))}${e}`},IPt=({plotData:t,nodes:A,isLoading:e,error:i,hasRun:n})=>{const o=AA.useMemo(()=>{const a=A.some(c=>c.toLowerCase().startsWith("v(")),g=A.some(c=>c.toLowerCase().startsWith("i("));return a&&g?"Value":a?"Voltage (V)":g?"Current (A)":"Value"},[A]);if(e)return Z.jsx("div",{style:{height:"300px",width:"100%",display:"flex",alignItems:"center",justifyContent:"center"},children:"Running simulation..."});if(!n)return Z.jsx("div",{style:{height:"300px",width:"100%",display:"flex",alignItems:"center",justifyContent:"center"},children:'Click "Run" to start the simulation.'});if(i)return Z.jsxs("div",{style:{height:"300px",width:"100%",display:"flex",alignItems:"center",justifyContent:"center",color:"red"},children:["Error: ",i]});if(t.length===0)return Z.jsx("div",{style:{height:"300px",width:"100%",display:"flex",alignItems:"center",justifyContent:"center"},children:"No data to plot. Check simulation output or SPICE netlist."});const s={datasets:A.map((a,g)=>({label:a,data:t.map(c=>({x:Number(c.name),y:c[a]})),borderColor:h9[g%h9.length],backgroundColor:h9[g%h9.length],fill:!1,tension:.1}))},r={responsive:!0,maintainAspectRatio:!1,plugins:{legend:{position:"top",labels:{font:{family:"sans-serif"}}},title:{display:!1},tooltip:{callbacks:{title:a=>{if(a.length>0){const g=a[0];return soe(g.parsed.x)}return""}}}},scales:{x:{type:"linear",title:{display:!0,text:"Time",font:{family:"sans-serif"}},ticks:{callback:a=>soe(a),font:{family:"sans-serif"}}},y:{title:{display:!0,text:o,font:{family:"sans-serif"}},ticks:{font:{family:"sans-serif"}}}}};return Z.jsx("div",{style:{position:"relative",height:"300px",width:"100%"},children:Z.jsx(ZKt,{options:r,data:s})})},lPt=({spiceString:t,onClose:A,plotData:e,nodes:i,isLoading:n,error:o,simOptions:s,onSimOptionsChange:r,hasRun:a})=>{const[g,c]=AA.useState(String(s.startTime)),[I,l]=AA.useState(String(s.duration));AA.useEffect(()=>{c(String(s.startTime)),l(String(s.duration))},[s.startTime,s.duration]);const B=()=>{r({...s,startTime:Number(g),duration:Number(I)})},C=i.filter(Q=>{const h=Q.toLowerCase().startsWith("v("),E=Q.toLowerCase().startsWith("i(");return!!(s.showVoltage&&h||s.showCurrent&&E)});return Z.jsx("div",{style:{position:"fixed",top:0,left:0,right:0,bottom:0,backgroundColor:"rgba(0, 0, 0, 0.5)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1002,fontFamily:"sans-serif"},children:Z.jsxs("div",{style:{backgroundColor:"white",padding:"24px",borderRadius:"12px",width:"90%",maxWidth:"900px",boxShadow:"0 4px 20px rgba(0, 0, 0, 0.15)"},children:[Z.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"24px",borderBottom:"1px solid #eee",paddingBottom:"16px"},children:[Z.jsx("h2",{style:{margin:0,fontSize:"22px",fontWeight:600,color:"#333"},children:"SPICE Simulation"}),Z.jsx("button",{onClick:A,style:{background:"none",border:"none",fontSize:"28px",cursor:"pointer",color:"#888",padding:0,lineHeight:1},children:"×"})]}),Z.jsx("div",{children:Z.jsx(IPt,{plotData:e,nodes:C,isLoading:n,error:o,hasRun:a})}),Z.jsxs("div",{style:{marginTop:"16px",padding:"12px",backgroundColor:"#f7f7f7",borderRadius:"6px",display:"flex",flexWrap:"wrap",gap:"24px",alignItems:"center",fontSize:"14px"},children:[Z.jsxs("div",{style:{display:"flex",gap:"16px"},children:[Z.jsxs("label",{style:{display:"flex",alignItems:"center",gap:"6px"},children:[Z.jsx("input",{type:"checkbox",checked:s.showVoltage,onChange:Q=>r({...s,showVoltage:Q.target.checked})}),"Voltage"]}),Z.jsxs("label",{style:{display:"flex",alignItems:"center",gap:"6px"},children:[Z.jsx("input",{type:"checkbox",checked:s.showCurrent,onChange:Q=>r({...s,showCurrent:Q.target.checked})}),"Current"]})]}),Z.jsxs("div",{style:{display:"flex",gap:"16px",alignItems:"center"},children:[Z.jsx("label",{htmlFor:"startTime",children:"Start Time (ms):"}),Z.jsx("input",{id:"startTime",type:"number",value:g,onChange:Q=>c(Q.target.value),style:{width:"80px",padding:"4px 8px",borderRadius:"4px",border:"1px solid #ccc"}}),Z.jsx("label",{htmlFor:"duration",children:"Duration (ms):"}),Z.jsx("input",{id:"duration",type:"number",value:I,onChange:Q=>l(Q.target.value),style:{width:"80px",padding:"4px 8px",borderRadius:"4px",border:"1px solid #ccc"}}),Z.jsx("button",{onClick:B,style:{padding:"4px 12px",borderRadius:"4px",border:"1px solid #ccc",backgroundColor:"#f0f0f0",cursor:"pointer"},children:a?"Rerun":"Run"})]})]}),Z.jsxs("div",{style:{marginTop:"24px"},children:[Z.jsx("h3",{style:{marginTop:0,marginBottom:"12px",fontSize:"18px",fontWeight:600,color:"#333"},children:"SPICE Netlist"}),Z.jsx("pre",{style:{backgroundColor:"#fafafa",padding:"16px",borderRadius:"6px",maxHeight:"150px",overflowY:"auto",border:"1px solid #eee",color:"#333",fontSize:"13px",fontFamily:"monospace"},children:t})]})]})})},BPt="dmFyIGU9bnVsbCxzPWFzeW5jKCk9Pihhd2FpdCBpbXBvcnQoImh0dHBzOi8vY2RuLmpzZGVsaXZyLm5ldC9ucG0vZWVjaXJjdWl0LWVuZ2luZUAxLjUuMi8rZXNtIikpLlNpbXVsYXRpb24sYz1hc3luYygpPT57aWYoZSYmZS5pc0luaXRpYWxpemVkKCkpcmV0dXJuO2xldCBpPWF3YWl0IHMoKTtlPW5ldyBpLGF3YWl0IGUuc3RhcnQoKX07c2VsZi5vbm1lc3NhZ2U9YXN5bmMgaT0+e3RyeXtpZihhd2FpdCBjKCksIWUpdGhyb3cgbmV3IEVycm9yKCJTaW11bGF0aW9uIG5vdCBpbml0aWFsaXplZCIpO2xldCB0PWkuZGF0YS5zcGljZVN0cmluZyxhPXQubWF0Y2goL3dyZGF0YVxzKyhcUyspXHMrKC4qKS9pKTtpZihhKXtsZXQgbz1gLnByb2JlICR7YVsyXS50cmltKCkuc3BsaXQoL1xzKy8pLmpvaW4oIiAiKX1gO3Q9dC5yZXBsYWNlKC93cmRhdGEuKi9pLG8pfWVsc2UgaWYoIXQubWF0Y2goL1wucHJvYmUvaSkpdGhyb3cgdC5tYXRjaCgvcGxvdFxzKyguKikvaSk/bmV3IEVycm9yKCJUaGUgJ3Bsb3QnIGNvbW1hbmQgaXMgbm90IHN1cHBvcnRlZCBmb3IgZGF0YSBleHRyYWN0aW9uLiBQbGVhc2UgdXNlICd3cmRhdGEgPGZpbGVuYW1lPiA8dmFyMT4gLi4uJyBvciAnLnByb2JlIDx2YXIxPiAuLi4nIGluc3RlYWQuIik6bmV3IEVycm9yKCJObyAnLnByb2JlJyBvciAnd3JkYXRhJyBjb21tYW5kIGZvdW5kIGluIFNQSUNFIGZpbGUuIFVzZSAnd3JkYXRhIDxmaWxlbmFtZT4gPHZhcjE+IC4uLicgdG8gc3BlY2lmeSBvdXRwdXQuIik7ZS5zZXROZXRMaXN0KHQpO2xldCBuPWF3YWl0IGUucnVuU2ltKCk7c2VsZi5wb3N0TWVzc2FnZSh7dHlwZToicmVzdWx0IixyZXN1bHQ6bn0pfWNhdGNoKHQpe3NlbGYucG9zdE1lc3NhZ2Uoe3R5cGU6ImVycm9yIixlcnJvcjp0Lm1lc3NhZ2V9KX19Owo=",E9=null,CPt=()=>{if(typeof window>"u")return null;if(E9)return E9;try{const t=new Blob([atob(BPt)],{type:"application/javascript"});return E9=URL.createObjectURL(t),E9}catch(t){return console.error("Failed to create blob URL for worker",t),null}},QPt=t=>{const A={};if(t.dataType==="real")t.data.forEach(r=>{A[r.name]=r.values});else if(t.dataType==="complex")t.data.forEach(r=>{A[r.name]=r.values.map(a=>a.real)});else throw new Error("Unsupported data type in simulation result");const e=Object.keys(A).find(r=>r.toLowerCase()==="time"||r.toLowerCase()==="frequency");if(!e)throw new Error("No time or frequency data in simulation result");const i=A[e],n=Object.keys(A).filter(r=>r!==e),o=n;return{plotData:i.map((r,a)=>{const g={name:r.toExponential(2)};return n.forEach(c=>{g[c]=A[c][a]}),g}),nodes:o}},hPt=t=>{const[A,e]=AA.useState([]),[i,n]=AA.useState([]),[o,s]=AA.useState(!0),[r,a]=AA.useState(null);return AA.useEffect(()=>{if(!t){s(!1),e([]),n([]),a(null);return}s(!0),a(null),e([]),n([]);const g=CPt();if(!g){a("Could not create SPICE simulation worker."),s(!1);return}const c=new Worker(g,{type:"module"});return c.onmessage=I=>{if(I.data.type==="result")try{const{plotData:l,nodes:B}=QPt(I.data.result);e(l),n(B)}catch(l){a(l.message||"Failed to parse simulation result"),console.error(l)}else I.data.type==="error"&&a(I.data.error);s(!1)},c.onerror=I=>{a(I.message),s(!1)},c.postMessage({spiceString:t}),()=>{c.terminate()}},[t]),{plotData:A,nodes:i,isLoading:o,error:r}},hdA=t=>{if(t===0)return"0";const A=Math.abs(t),e=i=>i.toPrecision(4);return A>=1?e(t):A>=.001?`${e(t*1e3)}m`:A>=1e-6?`${e(t*1e6)}u`:A>=1e-9?`${e(t*1e9)}n`:A>=1e-12?`${e(t*1e12)}p`:A>=1e-15?`${e(t*1e15)}f`:t.toExponential(3)},EPt=(t,A)=>{const i=BPA(t).toSpiceString(),o=i.split(`
5371
5371
  `).filter(x=>x.trim()!=="").filter(x=>!x.startsWith("*")&&!x.startsWith(".")&&x.trim()!==""),s=new Set,r=new Set,a=new Set;for(const x of o){const M=x.trim().split(/\s+/);if(M.length<3)continue;const R=M[0],U=R[0].toUpperCase();let J=[];if(["R","C","L","V","I","D"].includes(U))J=M.slice(1,3),U==="V"&&a.add(R);else if(U==="Q"&&M.length>=4)J=M.slice(1,4);else if(U==="M"&&M.length>=5)J=M.slice(1,5);else if(U==="X")J=M.slice(1,-1);else continue;J.forEach(T=>s.add(T)),U==="C"&&J.forEach(T=>r.add(T))}s.delete("0"),r.delete("0");const g=Array.from(r).map(x=>`.ic V(${x})=0`),c=[],I=Array.from(s).map(x=>`V(${x})`);c.push(...I);const l=Array.from(a).map(x=>`I(${x})`);c.push(...l);const B=c.length>0?`.probe ${c.join(" ")}`:"",C=A?.startTime??0,Q=A?.duration??20,h=C*.001,E=Q*.001,u=h+E,d=E/50,f=`.tran ${hdA(d)} ${hdA(u)} ${hdA(h)} UIC`,m=".end",w=i.split(`
5372
5372
  `);let S=-1;for(let x=w.length-1;x>=0;x--)if(w[x].trim().toLowerCase().startsWith(m)){S=x;break}const b=[...g,B,f].filter(Boolean);let k;if(S!==-1){const x=w.slice(0,S),M=w.slice(S);k=[...x,...b,...M]}else k=[...w,...b,m];return k.join(`
5373
5373
  `)},uPt=(t,A)=>{if(typeof window>"u")return A;try{const e=localStorage.getItem(t);return e!==null?JSON.parse(e):A}catch{return A}},dPt=(t,A)=>{if(!(typeof window>"u"))try{localStorage.setItem(t,JSON.stringify(A))}catch{}},EdA=AA.createContext(null),pPt=5,fPt=(t,A)=>!t&&!A?!0:!t||!A?!1:t.minX===A.minX&&t.maxX===A.maxX&&t.minY===A.minY&&t.maxY===A.maxY,yPt=({children:t})=>{if(AA.useContext(EdA))return Z.jsx(Z.Fragment,{children:t});const e=AA.useRef({pointer:null,boundingBoxes:new Map,hoveringIds:new Set,subscribers:new Set,mouseDownPosition:null}),i=AA.useCallback(()=>{for(const I of e.current.subscribers)I()},[]),n=AA.useCallback(()=>{const I=e.current.pointer,l=new Set;if(I)for(const[C,Q]of e.current.boundingBoxes){const h=Q.bounds;h&&I.x>=h.minX&&I.x<=h.maxX&&I.y>=h.minY&&I.y<=h.maxY&&l.add(C)}const B=e.current.hoveringIds;l.size===B.size&&[...l].every(C=>B.has(C))||(e.current.hoveringIds=l,i())},[i]),o=AA.useCallback((I,l)=>{e.current.boundingBoxes.set(I,l),n()},[n]),s=AA.useCallback((I,l)=>{const B=e.current.boundingBoxes.get(I);B&&fPt(B.bounds,l.bounds)&&B.onClick===l.onClick||(e.current.boundingBoxes.set(I,l),n())},[n]),r=AA.useCallback(I=>{e.current.boundingBoxes.delete(I)&&n()},[n]),a=AA.useCallback(I=>(e.current.subscribers.add(I),()=>{e.current.subscribers.delete(I)}),[]),g=AA.useCallback(I=>e.current.hoveringIds.has(I),[]);AA.useEffect(()=>{const I=Q=>{const{clientX:h,clientY:E}=Q,u=e.current.pointer;u&&u.x===h&&u.y===E||(e.current.pointer={x:h,y:E},n())},l=()=>{e.current.pointer!==null&&(e.current.pointer=null,e.current.mouseDownPosition=null,n())},B=Q=>{e.current.mouseDownPosition={x:Q.clientX,y:Q.clientY}},C=Q=>{const{clientX:h,clientY:E}=Q,u=e.current.mouseDownPosition;if(u&&Math.sqrt(Math.pow(h-u.x,2)+Math.pow(E-u.y,2))>pPt){e.current.mouseDownPosition=null;return}e.current.mouseDownPosition=null;for(const d of e.current.boundingBoxes.values()){const f=d.bounds;f&&h>=f.minX&&h<=f.maxX&&E>=f.minY&&E<=f.maxY&&d.onClick?.(Q)}};return window.addEventListener("pointermove",I,{passive:!0}),window.addEventListener("pointerdown",I,{passive:!0}),window.addEventListener("pointerup",I,{passive:!0}),window.addEventListener("pointerleave",l),window.addEventListener("pointercancel",l),window.addEventListener("blur",l),window.addEventListener("mousedown",B,{passive:!0}),window.addEventListener("click",C,{passive:!0}),()=>{window.removeEventListener("pointermove",I),window.removeEventListener("pointerdown",I),window.removeEventListener("pointerup",I),window.removeEventListener("pointerleave",l),window.removeEventListener("pointercancel",l),window.removeEventListener("blur",l),window.removeEventListener("mousedown",B),window.removeEventListener("click",C)}},[n]);const c=AA.useMemo(()=>({registerBoundingBox:o,updateBoundingBox:s,unregisterBoundingBox:r,subscribe:a,isHovering:g}),[o,s,r,a,g]);return Z.jsx(EdA.Provider,{value:c,children:t})},roe=t=>{const A=AA.useContext(EdA);if(!A)throw new Error("useMouseEventsOverBoundingBox must be used within a MouseTracker");const e=AA.useId(),i=AA.useRef(t);i.current=t;const n=AA.useMemo(()=>s=>{i.current.onClick?.(s)},[]);return AA.useEffect(()=>(A.registerBoundingBox(e,{bounds:i.current.bounds,onClick:i.current.onClick?n:void 0}),()=>{A.unregisterBoundingBox(e)}),[A,n,e]),AA.useEffect(()=>{A.updateBoundingBox(e,{bounds:i.current.bounds,onClick:i.current.onClick?n:void 0})},[A,n,e,t.bounds?.minX,t.bounds?.maxX,t.bounds?.minY,t.bounds?.maxY,t.onClick]),{hovering:AA.useSyncExternalStore(A.subscribe,()=>A.isHovering(e),()=>!1)}},mPt=(t,A)=>!t&&!A?!0:!t||!A?!1:Math.abs(t.bounds.minX-A.bounds.minX)<.5&&Math.abs(t.bounds.maxX-A.bounds.maxX)<.5&&Math.abs(t.bounds.minY-A.bounds.minY)<.5&&Math.abs(t.bounds.maxY-A.bounds.maxY)<.5&&Math.abs(t.rect.left-A.rect.left)<.5&&Math.abs(t.rect.top-A.rect.top)<.5&&Math.abs(t.rect.width-A.rect.width)<.5&&Math.abs(t.rect.height-A.rect.height)<.5,wPt=({componentId:t,svgDivRef:A,containerRef:e,onComponentClick:i,onHoverChange:n,showOutline:o,circuitJsonKey:s})=>{const[r,a]=AA.useState(null),g=AA.useRef(null),c=AA.useCallback(()=>{g.current=null;const h=A.current,E=e.current;if(!h||!E){a(w=>w&&null);return}const u=h.querySelector(`[data-schematic-component-id="${t}"]`);if(!u){a(w=>w&&null);return}const d=u.getBoundingClientRect(),f=E.getBoundingClientRect(),m={bounds:{minX:d.left,maxX:d.right,minY:d.top,maxY:d.bottom},rect:{left:d.left-f.left,top:d.top-f.top,width:d.width,height:d.height}};a(w=>mPt(w,m)?w:m)},[t,e,A]),I=AA.useCallback(()=>{g.current===null&&(g.current=window.requestAnimationFrame(c))},[c]);AA.useEffect(()=>{I()},[I,s]),AA.useEffect(()=>{I();const h=A.current,E=e.current;if(!h||!E)return;const u=typeof ResizeObserver<"u"?new ResizeObserver(()=>{I()}):null;u?.observe(E),u?.observe(h);const d=typeof MutationObserver<"u"?new MutationObserver(()=>{I()}):null;return d?.observe(h,{attributes:!0,attributeFilter:["style","transform"],subtree:!0,childList:!0}),window.addEventListener("scroll",I,!0),window.addEventListener("resize",I),()=>{u?.disconnect(),d?.disconnect(),window.removeEventListener("scroll",I,!0),window.removeEventListener("resize",I),g.current!==null&&(cancelAnimationFrame(g.current),g.current=null)}},[I,A,e]);const l=AA.useCallback(h=>{i&&i(t,h)},[t,i]),B=r?.bounds??null,{hovering:C}=roe({bounds:B,onClick:i?l:void 0});if(AA.useEffect(()=>{n&&n(t,C)},[C,t,n]),!r||!C||!o)return null;const Q=r.rect;return Z.jsx("div",{style:{position:"absolute",left:Q.left,top:Q.top,width:Q.width,height:Q.height,border:"1.5px solid rgba(51, 153, 255, 0.9)",pointerEvents:"none",zIndex:LD.schematicComponentHoverOutline}})},DPt=(t,A)=>!t&&!A?!0:!t||!A?!1:Math.abs(t.bounds.minX-A.bounds.minX)<.5&&Math.abs(t.bounds.maxX-A.bounds.maxX)<.5&&Math.abs(t.bounds.minY-A.bounds.minY)<.5&&Math.abs(t.bounds.maxY-A.bounds.maxY)<.5&&Math.abs(t.rect.left-A.rect.left)<.5&&Math.abs(t.rect.top-A.rect.top)<.5&&Math.abs(t.rect.width-A.rect.width)<.5&&Math.abs(t.rect.height-A.rect.height)<.5,SPt=({portId:t,portLabel:A,svgDivRef:e,containerRef:i,onPortClick:n,onHoverChange:o,showOutline:s,circuitJsonKey:r})=>{const[a,g]=AA.useState(null),c=AA.useRef(null),I=AA.useCallback(()=>{c.current=null;const E=e.current,u=i.current;if(!E||!u){g(b=>b&&null);return}const d=E.querySelector(`[data-schematic-port-id="${t}"]`);if(!d){g(b=>b&&null);return}const f=d.getBoundingClientRect(),m=u.getBoundingClientRect(),w=4,S={bounds:{minX:f.left-w,maxX:f.right+w,minY:f.top-w,maxY:f.bottom+w},rect:{left:f.left-m.left-w,top:f.top-m.top-w,width:f.width+w*2,height:f.height+w*2}};g(b=>DPt(b,S)?b:S)},[t,i,e]),l=AA.useCallback(()=>{c.current===null&&(c.current=window.requestAnimationFrame(I))},[I]);AA.useEffect(()=>{l()},[l,r]),AA.useEffect(()=>{l();const E=e.current,u=i.current;if(!E||!u)return;const d=typeof ResizeObserver<"u"?new ResizeObserver(()=>{l()}):null;d?.observe(u),d?.observe(E);const f=typeof MutationObserver<"u"?new MutationObserver(()=>{l()}):null;return f?.observe(E,{attributes:!0,attributeFilter:["style","transform"],subtree:!0,childList:!0}),window.addEventListener("scroll",l,!0),window.addEventListener("resize",l),()=>{d?.disconnect(),f?.disconnect(),window.removeEventListener("scroll",l,!0),window.removeEventListener("resize",l),c.current!==null&&(cancelAnimationFrame(c.current),c.current=null)}},[l,e,i]);const B=AA.useCallback(E=>{n&&n(t,E)},[t,n]),C=a?.bounds??null,{hovering:Q}=roe({bounds:C,onClick:n?B:void 0});if(AA.useEffect(()=>{o&&o(t,Q)},[Q,t,o]),!a||!s)return null;const h=a.rect;return Z.jsxs(Z.Fragment,{children:[Z.jsx("div",{style:{position:"absolute",left:h.left,top:h.top,width:h.width,height:h.height,border:Q?"1.5px solid rgba(255, 153, 51, 0.9)":"1.5px solid rgba(255, 153, 51, 0.3)",backgroundColor:Q?"rgba(255, 153, 51, 0.15)":"rgba(255, 153, 51, 0.05)",borderRadius:"50%",pointerEvents:"none",zIndex:LD.schematicPortHoverOutline,transition:"border-color 0.15s, background-color 0.15s"}}),Q&&A&&Z.jsx("div",{style:{position:"absolute",left:h.left+h.width/2,top:h.top-24,transform:"translateX(-50%)",backgroundColor:"rgba(0, 0, 0, 0.85)",color:"white",padding:"4px 8px",borderRadius:"4px",fontSize:"12px",fontFamily:"monospace",whiteSpace:"nowrap",pointerEvents:"none",zIndex:LD.schematicPortHoverOutline+1},children:A})]})},bPt=({circuitJson:t,containerStyle:A,editEvents:e=[],onEditEvent:i,defaultEditMode:n=!1,debugGrid:o=!1,editingEnabled:s=!1,debug:r=!1,clickToInteractEnabled:a=!1,colorOverrides:g,spiceSimulationEnabled:c=!1,disableGroups:I=!1,onSchematicComponentClicked:l,showSchematicPorts:B=!1,onSchematicPortClicked:C})=>{r&&APt();const[Q,h]=AA.useState(!1),[E,u]=AA.useState({showVoltage:!0,showCurrent:!1,startTime:0,duration:20}),d=CA=>`${CA?.length||0}_${CA?.editCount||0}`,f=AA.useMemo(()=>d(t),[t]),m=AA.useMemo(()=>{if(!c)return null;try{return EPt(t,E)}catch(CA){return console.error("Failed to generate SPICE string",CA),null}},[f,c,E.startTime,E.duration]),[w,S]=AA.useState(!1);AA.useEffect(()=>{S(!1)},[f]);const{plotData:b,nodes:k,isLoading:x,error:M}=hPt(w?m:null),[R,U]=AA.useState(n),[J,T]=AA.useState(!0),[O,W]=AA.useState(!1),z=o||O,[iA,gA]=AA.useState(!a),[eA,nA]=AA.useState(!1),[sA,QA]=AA.useState(()=>I?!1:uPt("schematic_viewer_show_groups",!1)),[bA,TA]=AA.useState(!1),MA=AA.useRef(new Set),OA=AA.useCallback((CA,ge)=>{ge?MA.current.add(CA):MA.current.delete(CA),TA(MA.current.size>0)},[]),[dA,vA]=AA.useState(!1),yA=AA.useRef(new Set),jA=AA.useCallback((CA,ge)=>{ge?yA.current.add(CA):yA.current.delete(CA),vA(yA.current.size>0)},[]),$A=AA.useRef(null),Qe=AA.useRef(null),wA=AA.useMemo(()=>{try{return nu(t).schematic_component?.list()?.map(CA=>CA.schematic_component_id)??[]}catch(CA){return console.error("Failed to derive schematic component ids",CA),[]}},[f,t]),se=AA.useMemo(()=>{if(!B)return[];try{return(nu(t).schematic_port?.list()??[]).map(ge=>{const de=nu(t).source_port.get(ge.source_port_id),Ke=(de?.source_component_id?nu(t).source_component.get(de.source_component_id):null)?.name??"?",Xe=ge.display_pin_label??de?.pin_number??de?.name??"?";return{portId:ge.source_port_id,label:`${Ke}.${Xe}`}})}catch(CA){return console.error("Failed to derive schematic port info",CA),[]}},[f,t,B]),ZA=CA=>{const ge=CA.touches[0];Qe.current={x:ge.clientX,y:ge.clientY}},KA=CA=>{const ge=CA.changedTouches[0],de=Qe.current;if(!de)return;const Se=Math.abs(ge.clientX-de.x),Ke=Math.abs(ge.clientY-de.y);Se<10&&Ke<10&&(CA.preventDefault(),gA(!0)),Qe.current=null},[WA,kA]=AA.useState([]),DA=AA.useRef(t);AA.useEffect(()=>{const CA=d(t),ge=d(DA.current);CA!==ge&&(kA([]),DA.current=t)},[t]);const{ref:HA,cancelDrag:RA,transform:qA}=uY({onSetTransform(CA){$A.current&&($A.current.style.transform=hF(CA))},enabled:iA&&!Q}),{containerWidth:VA,containerHeight:re}=ooe(HA),xA=AA.useMemo(()=>!VA||!re?"":TZ(t,{width:VA,height:re||720,grid:z?{cellSize:1,labelCells:!0}:void 0,colorOverrides:g}),[f,VA,re,z]),BA=AA.useMemo(()=>xA.match(/<svg[^>]*style="[^"]*background-color:\s*([^;\"]+)/i)?.[1]??"transparent",[xA]),hA=AA.useMemo(()=>{if(!xA)return ld();const CA=xA.match(/data-real-to-screen-transform="([^"]+)"/)?.[1];try{return tq(CA)}catch(ge){return console.error(ge),ld()}},[xA]),UA=CA=>{kA(ge=>[...ge,CA]),i&&i(CA)},Ie=AA.useMemo(()=>[...e,...WA],[e,WA]),{handleMouseDown:pe,handleTouchStart:me,isDragging:Me,activeEditEvent:Le}=iPt({onEditEvent:UA,cancelDrag:RA,realToSvgProjection:hA,svgToScreenProjection:qA,circuitJson:t,editEvents:Ie,enabled:R&&iA&&!Q,snapToGrid:J});VKt({svgDivRef:$A,editEvents:Ie,realToSvgProjection:hA,svgToScreenProjection:qA,activeEditEvent:Le}),jKt({svgDivRef:$A,circuitJson:t,activeEditEvent:Le,editEvents:Ie}),zKt({svgDivRef:$A,circuitJson:t,circuitJsonKey:f,showGroups:sA&&!I});const Ve=AA.useRef(me);AA.useEffect(()=>{Ve.current=me},[me]);const yt=AA.useMemo(()=>Z.jsx("div",{ref:$A,style:{pointerEvents:a?iA?"auto":"none":"auto",transformOrigin:"0 0"},className:l?"schematic-component-clickable":void 0,onTouchStart:CA=>{R&&iA&&!Q&&Ve.current(CA)},dangerouslySetInnerHTML:{__html:xA}}),[xA,iA,a,R,Q]);return Z.jsxs(yPt,{children:[l&&Z.jsx("style",{children:".schematic-component-clickable [data-schematic-component-id]:hover { cursor: pointer !important; }"}),C&&Z.jsx("style",{children:"[data-schematic-port-id]:hover { cursor: pointer !important; }"}),Z.jsxs("div",{ref:HA,style:{position:"relative",backgroundColor:BA,overflow:"hidden",cursor:Q?"auto":Me?"grabbing":a&&!iA||bA&&l||dA&&C?"pointer":"grab",minHeight:"300px",...A},onWheelCapture:CA=>{Q&&CA.stopPropagation()},onMouseDown:CA=>{if(a&&!iA){CA.preventDefault(),CA.stopPropagation();return}pe(CA)},onMouseDownCapture:CA=>{if(a&&!iA){CA.preventDefault(),CA.stopPropagation();return}},onTouchStart:CA=>{Q||ZA(CA)},onTouchEnd:CA=>{Q||KA(CA)},children:[!iA&&a&&Z.jsx("div",{onClick:CA=>{CA.preventDefault(),CA.stopPropagation(),gA(!0)},style:{position:"absolute",inset:0,cursor:"pointer",zIndex:LD.clickToInteractOverlay,display:"flex",alignItems:"center",justifyContent:"center",pointerEvents:"all",touchAction:"pan-x pan-y pinch-zoom"},children:Z.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:typeof window<"u"&&("ontouchstart"in window||navigator.maxTouchPoints>0)?"Touch to Interact":"Click to Interact"})}),Z.jsx(sPt,{active:eA,onClick:()=>nA(!eA)}),s&&Z.jsx(nPt,{active:R,onClick:()=>U(!R)}),s&&R&&Z.jsx(oPt,{active:J,onClick:()=>T(!J)}),Z.jsx(aPt,{circuitJson:t,circuitJsonKey:f,isVisible:eA,onClose:()=>nA(!1),showGroups:sA,onToggleGroups:CA=>{I||(QA(CA),dPt("schematic_viewer_show_groups",CA))},showGrid:z,onToggleGrid:W}),c&&Z.jsx(cPt,{onClick:()=>h(!0)}),Q&&Z.jsx(lPt,{spiceString:m,onClose:()=>h(!1),plotData:b,nodes:k,isLoading:x,error:M,simOptions:E,onSimOptionsChange:CA=>{S(!0),u(CA)},hasRun:w}),l&&wA.map(CA=>Z.jsx(wPt,{componentId:CA,svgDivRef:$A,containerRef:HA,showOutline:!0,circuitJsonKey:f,onHoverChange:OA,onComponentClick:(ge,de)=>{l?.({schematicComponentId:ge,event:de})}},CA)),yt,B&&se.map(({portId:CA,label:ge})=>Z.jsx(SPt,{portId:CA,portLabel:ge,svgDivRef:$A,containerRef:HA,showOutline:!0,circuitJsonKey:f,onHoverChange:jA,onPortClick:C?(de,Se)=>{C?.({schematicPortId:de,event:Se})}:void 0},CA))]})]})},xPt=({circuitJson:t,containerStyle:A,colorOverrides:e,width:i,height:n,className:o})=>{const[s,r]=AA.useState(null),[a,g]=AA.useState(!0),[c,I]=AA.useState(null),[l,B]=AA.useState(null),C=AA.useRef(null),Q=AA.useRef(null),{containerWidth:h,containerHeight:E}=ooe(C),[u,d]=AA.useState(!1),{ref:f}=uY({onSetTransform(U){Q.current&&(Q.current.style.transform=hF(U))}}),m=i||h||1e3,w=n||E||600;AA.useEffect(()=>{g(!0),I(null),r(t),g(!1)},[t]);const S=AA.useMemo(()=>s&&s.find(J=>J.type==="simulation_experiment")?.simulation_experiment_id||null,[s]),b=AA.useMemo(()=>s?s.filter(U=>U.type==="simulation_transient_voltage_graph").map(U=>U.simulation_transient_voltage_graph_id):[],[s]),k=AA.useMemo(()=>{if(!s||!m||!w||!S)return"";try{return Xte({circuitJson:s,simulation_experiment_id:S,simulation_transient_voltage_graph_ids:b,width:m,height:w,schematicOptions:{colorOverrides:e}})}catch(U){return console.error("Failed to generate fallback schematic SVG:",U),""}},[s,m,w,e,S,b]);AA.useEffect(()=>{if(!k){B(null);return}try{const U=new Blob([k],{type:"image/svg+xml"}),J=URL.createObjectURL(U);return B(J),()=>{URL.revokeObjectURL(J)}}catch(U){console.error("Failed to create SVG object URL:",U),B(null)}},[k]);const x=AA.useMemo(()=>k?k.match(/<svg[^>]*style="[^"]*background-color:\s*([^;\"]+)/i)?.[1]??"transparent":"transparent",[k]),M=U=>{d(!0)},R=U=>{d(!0)};return AA.useEffect(()=>{const U=()=>{d(!1)},J=()=>{d(!1)};return window.addEventListener("mouseup",U),window.addEventListener("touchend",J),()=>{window.removeEventListener("mouseup",U),window.removeEventListener("touchend",J)}},[]),a?Z.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:"#f5f5f5",minHeight:"300px",fontFamily:"sans-serif",fontSize:"16px",color:"#666",...A},className:o,children:"Loading circuit..."}):c?Z.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:"#fef2f2",minHeight:"300px",fontFamily:"sans-serif",fontSize:"16px",color:"#dc2626",...A},className:o,children:Z.jsxs("div",{style:{textAlign:"center",padding:"20px"},children:[Z.jsx("div",{style:{fontWeight:"bold",marginBottom:"8px"},children:"Circuit Conversion Error"}),Z.jsx("div",{style:{fontSize:"14px"},children:c})]})}):k?Z.jsx("div",{ref:U=>{C.current=U,f.current=U},style:{position:"relative",backgroundColor:x,overflow:"hidden",minHeight:"300px",cursor:u?"grabbing":"grab",...A},className:o,onMouseDown:M,onTouchStart:R,children:l?Z.jsx("img",{ref:Q,src:l,alt:"Circuit Simulation",style:{transformOrigin:"0 0",width:"100%",height:"100%",display:"block",objectFit:"contain"}}):Z.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",height:"100%",minHeight:"300px",color:"#666",fontFamily:"sans-serif"},children:"Failed to render SVG"})}):Z.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",backgroundColor:"#f8fafc",minHeight:"300px",fontFamily:"sans-serif",gap:"12px",...A},className:o,children:[Z.jsx("div",{style:{fontSize:"16px",color:"#475569",fontWeight:500},children:"No Simulation Found"}),Z.jsxs("div",{style:{fontSize:"14px",color:"#64748b"},children:["Use"," ",Z.jsx("code",{style:{backgroundColor:"#e2e8f0",padding:"2px 6px",borderRadius:"4px",fontFamily:"monospace",fontSize:"13px"},children:"<analogsimulation />"})," ","to create simulations"]})]})},aoe=t=>{const[A,e]=AA.useState(0),[i,n]=AA.useState(0);return AA.useEffect(()=>{if(!t.current)return;const o=()=>{const r=t.current?.getBoundingClientRect();e(r?.width||0),n(r?.height||0)};o();const s=new ResizeObserver(o);return s.observe(t.current),window.addEventListener("resize",o),()=>{s.disconnect(),window.removeEventListener("resize",o)}},[]),{containerWidth:A,containerHeight:i}};Oc("assembly-viewer");var goe=()=>{Oc.enable("assembly-viewer*")},_Pt=({circuitJson:t,containerStyle:A,debugGrid:e=!1,debug:i=!1})=>{i&&goe();const n=AA.useRef(null),{ref:o}=uY({onSetTransform(c){n.current&&(n.current.style.transform=hF(c))}}),{containerWidth:s,containerHeight:r}=aoe(o),a=AA.useMemo(()=>!s||!r?"":xte(t,{width:s,height:r||720}),[t,s,r]);AA.useMemo(()=>{if(!a)return ld();const c=a.match(/data-real-to-screen-transform="([^"]+)"/)?.[1];try{return tq(c)}catch(I){return console.error(I),ld()}},[a]);const g=AA.useMemo(()=>Z.jsx("div",{ref:n,style:{pointerEvents:"auto",transformOrigin:"0 0"},dangerouslySetInnerHTML:{__html:a}}),[a]);return Z.jsx("div",{ref:o,style:{position:"relative",backgroundColor:"#FFFFFF",overflow:"hidden",minHeight:"300px",...A},children:g})},kPt=({circuitJson:t,containerStyle:A,debugGrid:e=!1,debug:i=!1})=>{i&&goe();const n=AA.useRef(null),{ref:o}=uY({onSetTransform(c){n.current&&(n.current.style.transform=hF(c))}}),{containerWidth:s,containerHeight:r}=aoe(o),a=AA.useMemo(()=>!s||!r?"":RuA(t,{width:s,height:r||720}),[t,s,r]);AA.useMemo(()=>{if(!a)return ld();const c=a.match(/data-real-to-screen-transform="([^"]+)"/)?.[1];try{return tq(c)}catch(I){return console.error(I),ld()}},[a]);const g=AA.useMemo(()=>Z.jsx("div",{ref:n,style:{pointerEvents:"auto",transformOrigin:"0 0"},dangerouslySetInnerHTML:{__html:a}}),[a]);return Z.jsx("div",{ref:o,style:{position:"relative",backgroundColor:"#FFFFFF",overflow:"hidden",minHeight:"300px",...A},children:g})};const coe=["Initialize a tscircuit project using [tsci init](https://github.com/tscircuit/cli) before adding components.","Define reusable modules with cached routes using [<subcircuit />](https://docs.tscircuit.com/elements/subcircuit)","Run `tsci dev` on the command line to preview your boards before export",'Use units like mm or mils consistently across your designs (e.g. pcbX="10mm")',"Quickly set footprints with the [footprint prop](https://docs.tscircuit.com/footprints/footprinter-strings)","Check out the guide on [ordering prototypes](https://docs.tscircuit.com/building-electronics/ordering-prototypes)","Use [net labels](https://docs.tscircuit.com/elements/net) and [group elements](https://docs.tscircuit.com/elements/group) to organize complex schematics.","You can manually drag components on the PCB and Schematic using [manual edits](https://docs.tscircuit.com/guides/manual-edits)","Every tscircuit module can export to [Circuit JSON](https://github.com/tscircuit/circuit-json), Gerbers, Pick'n'Place CSV files, Bill of Materials CSV and more","You can import components from [JLCPCB](https://docs.tscircuit.com/guides/importing-modules-and-chips/importing-from-jlcpcb) or [KiCad](https://docs.tscircuit.com/guides/importing-modules-and-chips/importing-from-kicad)","Any module you push to the [registry](https://tscircuit.com/trending) will have [simple image urls](https://docs.tscircuit.com/web-apis/image-generation-api) you can use display images on a website","The default [Parts Engine](https://docs.tscircuit.com/guides/platform-configuration) will automatically find parts from common vendors for your BOM",'[Pin selectors](https://docs.tscircuit.com/guides/using-sel-references) are similar to CSS selectors, ".R1 > .pin1" means "connect to the first pin of the component R1"',"You can use the [sel](https://docs.tscircuit.com/guides/using-sel-references) object to select pins in a type-safe way","Publish modules via the [registry](https://tscircuit.com/trending) for working with a team or sharing your work","[Explore tutorials](https://docs.tscircuit.com/category/tutorials) for real-world circuit design examples.","Upload your Circuit JSON to [circuitjson.com](https://circuitjson.com) for a quick preview.","You can display Circuit JSON in 3D, PCB or Schematic mode with the [<CircuitJsonPreview />](https://docs.tscircuit.com/guides/running-tscircuit/displaying-circuit-json-on-a-webpage#react-display-all-available-previews-with-circuitjsonpreview-) React component","Use a [<group />](https://docs.tscircuit.com/elements/group) element to move multiple components at once in a schematic or PCB layout.","Check out the [GitHub Discussions page](https://github.com/tscircuit/tscircuit/discussions) to upvote features","You can customize the autorouter using the [autorouter prop](https://docs.tscircuit.com/elements/board#setting-the-autorouter)","Use the [<constraint />](https://docs.tscircuit.com/footprints/constraint) element to enforce geometric relationships in PCB designs.","When working on component placement and circuit design, autorouting can slow down your iteration cycle. Use [routingDisabled](https://docs.tscircuit.com/elements/board#disabling-routing-with-routingdisabled) on the <board /> element to disable autorouting temporarily.","Join the [Discord server](https://tscircuit.com/join) to discuss issues and get help directly from the community."],FPt=(()=>{let t=coe[Math.floor(Math.random()*coe.length)];return t=t.replace(/</g,"&lt;"),t=t.replace(/>/g,"&gt;"),t=t.replace(new RegExp('(?<!href=")(?<!\\()(?<!\\]\\()(https?:\\/\\/[^\\s\\)\\]]+)',"g"),(A,e)=>`<a class="rf-text-blue-500 rf-underline" href="${A}" target="_blank">${A}</a>`),t=t.replace(/\[([^\]]+)\]\((https?:\/\/[^\)]+)\)/g,'<a class="rf-text-blue-500 rf-underline" href="$2" target="_blank">$1</a>'),t})(),wb=({onRunClicked:t})=>Z.jsxs("div",{className:"rf-flex rf-flex-col rf-items-center rf-justify-center rf-h-full rf-bg-gray-50 rf-text-gray-500 rf-p-4",children:[Z.jsx(DGt,{className:"rf-size-14 rf-mb-4"}),Z.jsxs("p",{className:"rf-text-md rf-break-words rf-max-w-xl rf-text-center",children:["Tip: ",Z.jsx("span",{dangerouslySetInnerHTML:{__html:FPt}})]}),t&&Z.jsxs(bI,{className:"rf-mt-4 rf-bg-blue-600 rf-hover:bg-blue-500",onClick:t,children:["Run Code",Z.jsx(_Gt,{className:"rf-w-3 rf-h-3 rf-ml-2"})]})]}),u9=({text:t,onClick:A})=>Z.jsx("span",{className:"rf-cursor-pointer rf-underline rf-text-blue-600 rf-mx-2",onClick:A,children:t}),d9=t=>Z.jsxs("div",{className:"rf-leading-5",children:[Z.jsx("div",{className:"rf-py-2 rf-font-bold",children:t.column.name}),Z.jsx("div",{children:t.field?.()??Z.jsx("input",{type:"text",className:"rf-border rf-rounded rf-p-1 rf-w-full",onChange:A=>{t.onTextChange?.(A.target.value)}})})]}),GPt=({open:t,children:A,title:e,onClose:i})=>t?Z.jsx("div",{className:"rf-fixed rf-inset-0 rf-bg-black rf-bg-opacity-50 rf-flex rf-justify-center rf-items-center rf-z-50",onClick:i,children:Z.jsxs("div",{className:"rf-bg-white rf-p-5 rf-rounded-lg rf-relative rf-w-11/12 rf-max-w-2xl",onClick:n=>{n.preventDefault(),n.stopPropagation()},children:[Z.jsx("h2",{className:"rf-mt-0 rf-text-md rf-pb-4",children:e}),Z.jsx("button",{type:"button",className:"rf-absolute rf-top-2 rf-right-4 rf-text-2xl rf-font-bold",onClick:i,children:"×"}),A]})}):null,vPt=({elements:t})=>{const[A,e]=AA.useState({open:!1}),[i,n]=AA.useReducer((c,I)=>({...c,...I}),{}),o=[...new Set(t.map(c=>c.type))],s=t.map(c=>{const I=c[`${c.type}_id`],l=Object.fromEntries(Object.entries(c).filter(([C])=>!(C===`${c.type}_id`||!C.endsWith("_id")))),B=Object.fromEntries(Object.entries(c).filter(([C])=>!C.endsWith("_id")));return{primary_id:I,other_ids:l,...B,_og_elm:c}}),r=s.map(c=>{let I="";const l=B=>{const C=Object.keys(B.other_ids).find(E=>E.startsWith("source_"));if(!C)return`.${B.name}`;const Q=C.slice(0,-3),h=s.find(E=>E.type===Q&&E.primary_id===B.other_ids[C]);return h?"name"in h?`${l(h)} > .${B.name}`:`#${h.primary_id} > .${B.name}`:`??? > .${B.name}`};return"name"in c&&(I=l(c)),{...c,selector_path:I}}),a=[{key:"primary_id",name:"primary_id",renderCell:c=>Z.jsxs("div",{className:"rf-flex rf-items-center",children:[Z.jsx(u9,{text:c.primary_id,onClick:()=>n({focused_id:c.primary_id,id_search:void 0,selector_search:void 0})}),Z.jsx("span",{className:"rf-flex-grow"}),Z.jsx(u9,{text:"(JSON)",onClick:()=>e({open:!0,element:c._og_elm,title:c.primary_id})})]}),renderHeaderCell:c=>Z.jsx(d9,{column:c,onTextChange:I=>n({id_search:I}),field:i.focused_id?()=>Z.jsxs("div",{children:["Focus:"," ",Z.jsx("span",{className:"rf-underline",children:i.focused_id}),Z.jsx(u9,{text:"(unfocus)",onClick:()=>n({focused_id:void 0})})]}):void 0})},{key:"type",name:"type",renderHeaderCell:c=>Z.jsx(d9,{column:c,field:()=>Z.jsxs("select",{onChange:I=>n({component_type_filter:I.target.value}),className:"rf-border rf-rounded rf-p-1 rf-w-full",children:[Z.jsx("option",{value:"any",children:"any"},"any"),Z.jsx("option",{value:"source",children:"source"},"source"),Z.jsx("option",{value:"source/pcb",children:"source/pcb"},"source/pcb"),Z.jsx("option",{value:"source/schematic",children:"source/schematic"},"source/schematic"),o.map(I=>Z.jsx("option",{value:I,children:I},I))]})})},{key:"name",name:"name",renderHeaderCell:c=>Z.jsx(d9,{column:c,onTextChange:I=>n({name_search:I})})},{key:"selector_path",name:"selector_path",renderHeaderCell:c=>Z.jsx(d9,{column:c,onTextChange:I=>n({selector_search:I})})},{key:"other_ids",name:"other_ids",renderCell:c=>Z.jsx("div",{className:"rf-space-x-2",children:Object.entries(c.other_ids).map(([I,l])=>Z.jsx(u9,{text:l,onClick:()=>n({focused_id:l})},l))})}],g=r.filter(c=>i.name_search?c.name?.toLowerCase()?.includes(i.name_search.toLowerCase()):!0).filter(c=>!i.component_type_filter||i.component_type_filter==="any"?!0:i.component_type_filter==="source"?c.type.startsWith("source_"):i.component_type_filter==="source/pcb"?c.type.startsWith("source_")||c.type.startsWith("pcb_"):i.component_type_filter==="source/schematic"?c.type.startsWith("source_")||c.type.startsWith("schematic_"):c.type?.includes(i.component_type_filter)).filter(c=>i.selector_search?i.selector_search.split(" ").filter(l=>l.length>0).every(l=>c.selector_path?.includes(l)):!0).filter(c=>i.id_search?c.primary_id?.includes(i.id_search):!0).filter(c=>!!(!i.focused_id||c.primary_id===i.focused_id||Object.values(c.other_ids).includes(i.focused_id)));return Z.jsxs("div",{className:"rf-font-mono rf-text-xs rf-bg-white",children:[Z.jsx("div",{className:"rf-overflow-x-auto",children:Z.jsxs("table",{className:"rf-table-auto rf-w-full rf-text-left",children:[Z.jsx("thead",{children:Z.jsx("tr",{children:a.map(c=>Z.jsx("th",{className:"rf-px-4 rf-py-2 rf-border-b",children:c.renderHeaderCell?c.renderHeaderCell(c):c.name},c.key))})}),Z.jsx("tbody",{children:g.map((c,I)=>Z.jsx("tr",{className:"rf-hover:bg-gray-100",children:a.map(l=>Z.jsx("td",{className:"rf-px-4 rf-py-2 rf-border-b",children:l.renderCell?l.renderCell(c):c[l.key]},l.key))},I))})]})}),Z.jsx(GPt,{open:A.open,onClose:()=>e({open:!1}),title:A.open?A.title:"",children:Z.jsx("div",{className:"rf-bg-gray-800 rf-p-3 rf-text-white rf-rounded",children:Z.jsx("pre",{className:"rf-whitespace-pre-wrap",children:A.open?JSON.stringify(A.element,null,2):""})})})]})},RPt=(t,A)=>t==="jlcpcb"?Z.jsx("a",{className:"rf-underline rf-text-blue-500",target:"_blank",rel:"noreferrer",href:`https://jlcpcb.com/partdetail/${A}`,children:A}):A,MPt=({circuitJson:t})=>{const A=t.filter(i=>i.type==="source_component"),e=new Set;for(const i of A)if(i.supplier_part_numbers)for(const n of Object.keys(i.supplier_part_numbers))e.add(n);return Z.jsx("div",{className:"rf-overflow-x-auto",children:Z.jsxs("table",{className:"rf-w-full rf-text-left rf-text-sm",children:[Z.jsx("thead",{children:Z.jsxs("tr",{className:"rf-border-b",children:[Z.jsx("th",{className:"rf-p-2",children:"Name"}),Array.from(e).map(i=>Z.jsx("th",{className:"rf-p-2 rf-capitalize",children:i},i))]})}),Z.jsx("tbody",{children:A.map(i=>Z.jsxs("tr",{className:"rf-border-b",children:[Z.jsx("td",{className:"rf-p-2",children:i.name}),Array.from(e).map(n=>Z.jsx("td",{className:"rf-p-2",children:RPt(n,i.supplier_part_numbers?.[n]?.[0]||"")},n))]},i.source_component_id))})]})})},udA=AA.forwardRef(({className:t,type:A,...e},i)=>Z.jsx("input",{type:A,className:Ho("rf-flex rf-h-9 rf-w-full rf-rounded-md rf-border rf-border-zinc-200 rf-bg-white rf-px-3 rf-py-1 rf-text-sm rf-shadow-sm rf-transition-colors file:rf-border-0 file:rf-bg-transparent file:rf-text-sm file:rf-font-medium placeholder:rf-text-zinc-500 focus-visible:rf-outline-none focus-visible:rf-ring-1 focus-visible:rf-ring-zinc-950 disabled:rf-cursor-not-allowed disabled:rf-opacity-50 dark:rf-border-zinc-800 dark:rf-bg-zinc-950 dark:rf-placeholder-zinc-400 dark:focus-visible:rf-ring-zinc-300",t),ref:i,...e}));udA.displayName="Input";var Ioe={Hz:{baseUnit:"Hz",variants:{MHz:1e6,kHz:1e3,Hz:1}},g:{baseUnit:"g",variants:{kg:1e3,g:1}},Ω:{baseUnit:"Ω",variants:{mΩ:.001,Ω:1,kΩ:1e3,KΩ:1e3,kohm:1e3,MΩ:1e6,GΩ:1e9,TΩ:1e12}},V:{baseUnit:"V",variants:{mV:.001,V:1,kV:1e3,KV:1e3,MV:1e6,GV:1e9,TV:1e12}},A:{baseUnit:"A",variants:{µA:1e-6,mA:.001,ma:.001,A:1,kA:1e3,MA:1e6}},F:{baseUnit:"F",variants:{pF:1e-12,nF:1e-9,µF:1e-6,uF:1e-6,mF:.001,F:1}},ml:{baseUnit:"ml",variants:{ml:1,mL:1,l:1e3,L:1e3}},deg:{baseUnit:"deg",variants:{rad:180/Math.PI}},ms:{baseUnit:"ms",variants:{fs:1e-12,ps:1e-9,ns:1e-6,us:.001,µs:.001,ms:1,s:1e3}},mm:{baseUnit:"mm",variants:{nm:1e-6,µm:.001,um:.001,mm:1,cm:10,dm:100,m:1e3,km:1e6,in:25.4,ft:304.8,IN:25.4,FT:304.8,yd:914.4,mi:1609344,mil:.0254}}},ddA=new Set;for(const[t,A]of Object.entries(Ioe)){ddA.add(t);for(const e of Object.keys(A.variants))ddA.add(e)}function NPt(t){for(const[A,e]of Object.entries(Ioe))if(t in e.variants)return{baseUnit:e.baseUnit,conversionFactor:e.variants[t]};return{baseUnit:t,conversionFactor:1}}var loe={tera:1e12,T:1e12,giga:1e9,G:1e9,mega:1e6,M:1e6,kilo:1e3,k:1e3,deci:.1,d:.1,centi:.01,c:.01,milli:.001,m:.001,micro:1e-6,u:1e-6,µ:1e-6,nano:1e-9,n:1e-9,pico:1e-12,p:1e-12};function Iw(t){if(t==null)return{parsedUnit:null,unitOfValue:null,value:null};if(typeof t=="string"&&t.match(/^-?[\d\.]+$/))return{value:Number.parseFloat(t),parsedUnit:null,unitOfValue:null};if(typeof t=="number")return{value:t,parsedUnit:null,unitOfValue:null};if(typeof t=="object"&&"x"in t&&"y"in t){const{parsedUnit:r,unitOfValue:a}=Iw(t.x),g=Iw(t.x),c=Iw(t.y);return g.value===null||c.value===null?{parsedUnit:null,unitOfValue:null,value:null}:{parsedUnit:r,unitOfValue:a,value:{x:g.value,y:c.value}}}const e=t.toString().split("").reverse().join("").match(/[^\d\s]+/)?.[0];if(!e)throw new Error(`Could not determine unit: "${t}"`);const i=e.split("").reverse().join(""),n=t.slice(0,-i.length);if(i in loe&&!ddA.has(i)){const r=loe[i];return{parsedUnit:null,unitOfValue:null,value:Number.parseFloat(n)*r}}const{baseUnit:o,conversionFactor:s}=NPt(i);return{parsedUnit:i,unitOfValue:o,value:s*Number.parseFloat(n)}}var p9=H().or(zA()).transform(t=>Iw(t).value),pdA=H().or(zA()).transform(t=>Iw(t).value).transform(t=>Number.parseFloat(t.toPrecision(12))),Boe=H().or(zA()).transform(t=>Iw(t).value),Db=H().or(zA()).transform(t=>Iw(t).value),Qn=H().or(zA()).transform(t=>Iw(t).value),wG=H().or(zA()).transform(t=>Iw(t).value),_t=Qn,WN=H().or(zA()).transform(t=>Iw(t).value),HY=H().or(zA()).transform(t=>Iw(t).value),LPt=HY,DG=HY,Coe=H().datetime(),bQ=H().or(zA()).transform(t=>typeof t=="number"?t:t.endsWith("deg")?Number.parseFloat(t.split("deg")[0]):t.endsWith("rad")?Number.parseFloat(t.split("rad")[0])*180/Math.PI:Number.parseFloat(t)),Qoe=zA().or(H().endsWith("mAh")).transform(t=>{if(typeof t=="string"){const A=t.replace("mAh",""),e=Number.parseFloat(A);if(Number.isNaN(e))throw new Error("Invalid capacity");return e}return t}).describe("Battery capacity in mAh"),kn=Ae({x:_t,y:_t}),UPt=kn,j_=Ae({x:_t,y:_t,z:_t}),HPt=j_,fdA=Ae({width:zA(),height:zA()}),YPt=t=>{const A="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";return Array.from({length:t},()=>A[Math.floor(Math.random()*A.length)]).join("")},oi=t=>H().optional().default(()=>`${t}_${YPt(10)}`),z_=pt(["top_left","top_center","top_right","center_left","center","center_right","bottom_left","bottom_center","bottom_right"]),JPt=pt(["top_silkscreen","bottom_silkscreen","top_copper","bottom_copper","top_soldermask","bottom_soldermask","top_fabrication_note","bottom_fabrication_note","top_user_note","bottom_user_note","top_courtyard","bottom_courtyard","inner1_copper","inner2_copper","inner3_copper","inner4_copper","inner5_copper","inner6_copper","edge_cuts","drill"]),hoe=Ae({project_relative_path:H(),url:H(),mimetype:H()}),f9=kn.extend({rotation:bQ.optional()}),ydA=Ae({size:kn.optional(),thickness:_t.optional()}),Eoe=Ae({font:ydA.optional()}),YY=Ae({value:H(),at:f9.optional(),layer:H().optional(),uuid:H().optional(),hide:ce().optional(),effects:Eoe.optional()}),uoe=Ae({Reference:YY.optional(),Value:YY.optional(),Datasheet:YY.optional(),Description:YY.optional()}),doe=Ae({through_hole:ce().optional(),smd:ce().optional(),exclude_from_pos_files:ce().optional(),exclude_from_bom:ce().optional()}),poe=Ae({name:H(),type:H(),shape:H().optional(),at:f9.optional(),size:kn.optional(),drill:_t.optional(),layers:ve(H()).optional(),removeUnusedLayers:ce().optional(),uuid:H().optional()}),foe=Ae({path:H(),offset:j_.optional(),scale:j_.optional(),rotate:j_.optional()}),yoe=Ae({footprintName:H().optional(),version:ii([zA(),H()]).optional(),generator:H().optional(),generatorVersion:ii([zA(),H()]).optional(),layer:H().optional(),properties:uoe.optional(),attributes:doe.optional(),pads:ve(poe).optional(),embeddedFonts:ce().optional(),model:foe.optional()}),moe=Ae({hide:ce().optional()}),woe=Ae({offset:_t.optional(),hide:ce().optional()}),Doe=Ae({font:ydA.optional(),justify:ii([H(),ve(H())]).optional(),hide:ce().optional()}),X_=Ae({value:H(),id:ii([zA(),H()]).optional(),at:f9.optional(),effects:Doe.optional()}),Soe=Ae({Reference:X_.optional(),Value:X_.optional(),Footprint:X_.optional(),Datasheet:X_.optional(),Description:X_.optional(),ki_keywords:X_.optional(),ki_fp_filters:X_.optional()}),boe=Ae({symbolName:H().optional(),extends:H().optional(),pinNumbers:moe.optional(),pinNames:woe.optional(),excludeFromSim:ce().optional(),inBom:ce().optional(),onBoard:ce().optional(),properties:Soe.optional(),embeddedFonts:ce().optional()}),ll=Ae({error_type:H(),message:H(),is_fatal:ce().optional()}),xoe=pt(["jlcpcb","macrofab","pcbway","digikey","mouser","lcsc"]),_I=Ae({type:FA("source_component"),ftype:H().optional(),source_component_id:H(),name:H(),manufacturer_part_number:H().optional(),supplier_part_numbers:ig(xoe,ve(H())).optional(),display_value:H().optional(),display_name:H().optional(),are_pins_interchangeable:ce().optional(),internally_connected_source_port_ids:ve(ve(H())).optional(),source_group_id:H().optional(),subcircuit_id:H().optional()}),mdA=_I.extend({ftype:FA("simple_capacitor"),capacitance:pdA,max_voltage_rating:Db.optional(),display_capacitance:H().optional(),max_decoupling_trace_length:_t.optional()}),wdA=_I.extend({ftype:FA("simple_resistor"),resistance:p9,display_resistance:H().optional()}),y9=_I.extend({ftype:FA("simple_diode")}),_oe=_I.extend({ftype:FA("simple_fiducial")}),DdA=y9.extend({ftype:FA("simple_led"),color:H().optional(),wavelength:H().optional()}),koe=_I.extend({ftype:FA("simple_ground")}),SdA=_I.extend({ftype:FA("simple_chip")}),bdA=_I.extend({ftype:FA("simple_power_source"),voltage:Db}),Foe=_I.extend({ftype:FA("simple_current_source"),current:WN,frequency:wG.optional(),peak_to_peak_current:WN.optional(),wave_shape:pt(["sine","square","triangle","sawtooth","dc"]).optional().default("dc"),phase:zA().optional(),duty_cycle:zA().min(0).max(1).optional()}),TPt=_I.extend({ftype:FA("simple_fuse"),current_rating_amps:zA().describe("Nominal current in amps the fuse is rated for"),voltage_rating_volts:zA().describe("Voltage rating in volts, e.g. ±5V would be 5")}),xdA=_I.extend({ftype:FA("simple_battery"),capacity:Qoe}),_dA=_I.extend({ftype:FA("simple_inductor"),inductance:Boe,max_current_rating:zA().optional()}),kdA=_I.extend({ftype:FA("simple_push_button")}),FdA=_I.extend({ftype:FA("simple_potentiometer"),max_resistance:p9,display_max_resistance:H().optional()}),Goe=_I.extend({ftype:FA("simple_crystal"),frequency:zA().describe("Frequency in Hz"),load_capacitance:zA().optional().describe("Load capacitance in pF"),pin_variant:pt(["two_pin","four_pin"]).optional()}),GdA=_I.extend({ftype:FA("simple_pin_header"),pin_count:zA(),gender:pt(["male","female"]).optional().default("male")}),vdA=_I.extend({ftype:FA("simple_pinout")}),RdA=_I.extend({ftype:FA("simple_resonator"),load_capacitance:pdA,equivalent_series_resistance:p9.optional(),frequency:wG}),MdA=_I.extend({ftype:FA("simple_transistor"),transistor_type:pt(["npn","pnp"])}),NdA=_I.extend({ftype:FA("simple_test_point"),footprint_variant:pt(["pad","through_hole"]).optional(),pad_shape:pt(["rect","circle"]).optional(),pad_diameter:ii([zA(),H()]).optional(),hole_diameter:ii([zA(),H()]).optional(),width:ii([zA(),H()]).optional(),height:ii([zA(),H()]).optional()}),LdA=_I.extend({ftype:FA("simple_mosfet"),channel_type:pt(["n","p"]),mosfet_mode:pt(["enhancement","depletion"])}),UdA=_I.extend({ftype:FA("simple_op_amp")}),HdA=_I.extend({ftype:FA("simple_switch")}),YdA=Ae({type:FA("source_project_metadata"),name:H().optional(),software_used_string:H().optional(),project_url:H().optional(),created_at:Coe.optional()}),voe=ll.extend({type:FA("source_missing_property_error"),source_missing_property_error_id:oi("source_missing_property_error"),source_component_id:H(),property_name:H(),subcircuit_id:H().optional(),error_type:FA("source_missing_property_error").default("source_missing_property_error")}).describe("The source code is missing a property"),Roe=ll.extend({type:FA("source_failed_to_create_component_error"),source_failed_to_create_component_error_id:oi("source_failed_to_create_component_error"),error_type:FA("source_failed_to_create_component_error").default("source_failed_to_create_component_error"),component_name:H().optional(),subcircuit_id:H().optional(),parent_source_component_id:H().optional(),pcb_center:Ae({x:zA().optional(),y:zA().optional()}).optional(),schematic_center:Ae({x:zA().optional(),y:zA().optional()}).optional()}).describe("Error emitted when a component fails to be constructed"),JdA=ll.extend({type:FA("source_trace_not_connected_error"),source_trace_not_connected_error_id:oi("source_trace_not_connected_error"),error_type:FA("source_trace_not_connected_error").default("source_trace_not_connected_error"),subcircuit_id:H().optional(),source_group_id:H().optional(),source_trace_id:H().optional(),connected_source_port_ids:ve(H()).optional(),selectors_not_found:ve(H()).optional()}).describe("Occurs when a source trace selector does not match any ports"),Moe=Ae({type:FA("source_property_ignored_warning"),source_property_ignored_warning_id:oi("source_property_ignored_warning"),source_component_id:H(),property_name:H(),subcircuit_id:H().optional(),error_type:FA("source_property_ignored_warning").default("source_property_ignored_warning"),message:H()}).describe("The source property was ignored"),TdA=Ae({type:FA("source_pin_missing_trace_warning"),source_pin_missing_trace_warning_id:oi("source_pin_missing_trace_warning"),warning_type:FA("source_pin_missing_trace_warning").default("source_pin_missing_trace_warning"),message:H(),source_component_id:H(),source_port_id:H(),subcircuit_id:H().optional()}).describe("Warning emitted when a source component pin is missing a trace connection"),Noe=_I.extend({ftype:FA("simple_voltage_probe")}),Loe=_I.extend({ftype:FA("interconnect")}),KdA=ll.extend({type:FA("source_i2c_misconfigured_error"),source_i2c_misconfigured_error_id:oi("source_i2c_misconfigured_error"),error_type:FA("source_i2c_misconfigured_error").default("source_i2c_misconfigured_error"),source_port_ids:ve(H())}).describe("Error emitted when incompatible I2C pins (e.g. SDA and SCL) are connected to the same net"),Uoe=_I.extend({ftype:FA("simple_voltage_source"),voltage:Db,frequency:wG.optional(),peak_to_peak_voltage:Db.optional(),wave_shape:pt(["sinewave","square","triangle","sawtooth"]).optional(),phase:bQ.optional(),duty_cycle:zA().optional().describe("Duty cycle as a fraction (0 to 1)")}),Hoe=ii([wdA,mdA,y9,_oe,DdA,koe,SdA,bdA,Foe,xdA,_dA,kdA,FdA,Goe,GdA,vdA,RdA,HdA,MdA,NdA,LdA,UdA,TPt,Noe,Loe,Uoe,YdA,voe,Roe,JdA,Moe,TdA,KdA]),Yoe=Ae({type:FA("source_port"),pin_number:zA().optional(),port_hints:ve(H()).optional(),name:H(),source_port_id:H(),source_component_id:H().optional(),source_group_id:H().optional(),most_frequently_referenced_by_name:H().optional(),subcircuit_id:H().optional(),subcircuit_connectivity_map_key:H().optional(),must_be_connected:ce().optional(),is_configured_for_i2c_sda:ce().optional(),is_configured_for_i2c_scl:ce().optional(),is_configured_for_spi_mosi:ce().optional(),is_configured_for_spi_miso:ce().optional(),is_configured_for_spi_sck:ce().optional(),is_configured_for_spi_cs:ce().optional(),is_configured_for_uart_tx:ce().optional(),is_configured_for_uart_rx:ce().optional(),supports_i2c_sda:ce().optional(),supports_i2c_scl:ce().optional(),supports_spi_mosi:ce().optional(),supports_spi_miso:ce().optional(),supports_spi_sck:ce().optional(),supports_spi_cs:ce().optional(),supports_uart_tx:ce().optional(),supports_uart_rx:ce().optional()}),Joe=Ae({type:FA("source_component_internal_connection"),source_component_internal_connection_id:H(),source_component_id:H(),source_port_ids:ve(H()),subcircuit_id:H().optional()}),Toe=Ae({type:FA("source_trace"),source_trace_id:H(),connected_source_port_ids:ve(H()),connected_source_net_ids:ve(H()),subcircuit_id:H().optional(),subcircuit_connectivity_map_key:H().optional(),max_length:zA().optional(),min_trace_thickness:zA().optional(),display_name:H().optional()}),Koe=Ae({type:FA("source_group"),source_group_id:H(),subcircuit_id:H().optional(),parent_subcircuit_id:H().optional(),parent_source_group_id:H().optional(),is_subcircuit:ce().optional(),show_as_schematic_box:ce().optional(),name:H().optional(),was_automatically_named:ce().optional()}),Poe=Ae({type:FA("source_net"),source_net_id:H(),name:H(),member_source_group_ids:ve(H()),is_power:ce().optional(),is_ground:ce().optional(),is_digital_signal:ce().optional(),is_analog_signal:ce().optional(),is_positive_voltage_source:ce().optional(),trace_width:zA().optional(),subcircuit_id:H().optional(),subcircuit_connectivity_map_key:H().optional()}),qoe=Ae({type:FA("source_board"),source_board_id:H(),source_group_id:H(),title:H().optional()}).describe("Defines a board in the source domain"),Ooe=Ae({type:FA("source_pcb_ground_plane"),source_pcb_ground_plane_id:H(),source_group_id:H(),source_net_id:H(),subcircuit_id:H().optional()}).describe("Defines a ground plane in the source domain"),Woe=["top","bottom","inner1","inner2","inner3","inner4","inner5","inner6"],PdA=pt(Woe),oa=PdA.or(Ae({name:PdA})).transform(t=>typeof t=="string"?t:t.name),rm=pt(["top","bottom"]),Zoe=Ae({type:FA("source_manually_placed_via"),source_manually_placed_via_id:H(),source_group_id:H(),source_net_id:H(),subcircuit_id:H().optional(),source_trace_id:H().optional()}).describe("Defines a via that is manually placed in the source domain"),Voe=ll.extend({type:FA("source_pin_must_be_connected_error"),source_pin_must_be_connected_error_id:oi("source_pin_must_be_connected_error"),error_type:FA("source_pin_must_be_connected_error").default("source_pin_must_be_connected_error"),source_component_id:H(),source_port_id:H(),subcircuit_id:H().optional()}).describe("Error emitted when a pin with mustBeConnected attribute is not connected to any trace"),joe=ll.extend({type:FA("unknown_error_finding_part"),unknown_error_finding_part_id:oi("unknown_error_finding_part"),error_type:FA("unknown_error_finding_part").default("unknown_error_finding_part"),source_component_id:H().optional(),subcircuit_id:H().optional()}).describe("Error emitted when an unexpected error occurs while finding a part"),zoe=Ae({type:FA("schematic_box"),schematic_component_id:H().optional(),schematic_symbol_id:H().optional(),width:_t,height:_t,is_dashed:ce().default(!1),x:_t,y:_t,subcircuit_id:H().optional()}).describe("Draws a box on the schematic"),Xoe=Ae({type:FA("schematic_path"),schematic_path_id:oi("schematic_path"),schematic_component_id:H().optional(),schematic_symbol_id:H().optional(),fill_color:H().optional(),is_filled:ce().optional(),stroke_width:_t.nullable().optional(),stroke_color:H().optional(),points:ve(kn),subcircuit_id:H().optional()}),$oe=ig(Ae({left_margin:Qn.optional(),right_margin:Qn.optional(),top_margin:Qn.optional(),bottom_margin:Qn.optional()})),Ase=Ae({left_size:zA(),right_size:zA(),top_size:zA().optional(),bottom_size:zA().optional()}),ese=Ae({left_side:Ae({pins:ve(zA()),direction:pt(["top-to-bottom","bottom-to-top"]).optional()}).optional(),right_side:Ae({pins:ve(zA()),direction:pt(["top-to-bottom","bottom-to-top"]).optional()}).optional(),top_side:Ae({pins:ve(zA()),direction:pt(["left-to-right","right-to-left"]).optional()}).optional(),bottom_side:Ae({pins:ve(zA()),direction:pt(["left-to-right","right-to-left"]).optional()}).optional()}),tse=ii([Ase,ese]),ise=Ae({type:FA("schematic_component"),size:fdA,center:kn,source_component_id:H().optional(),schematic_component_id:H(),schematic_symbol_id:H().optional(),pin_spacing:Qn.optional(),pin_styles:$oe.optional(),box_width:Qn.optional(),symbol_name:H().optional(),port_arrangement:tse.optional(),port_labels:ig(H()).optional(),symbol_display_value:H().optional(),subcircuit_id:H().optional(),schematic_group_id:H().optional(),is_schematic_group:ce().optional(),source_group_id:H().optional(),is_box_with_pins:ce().optional().default(!0)}),KPt=Ae({kicad_symbol:boe.optional()}).catchall(yGA()),nse=Ae({type:FA("schematic_symbol"),schematic_symbol_id:H(),name:H().optional(),metadata:KPt.optional()}).describe("Defines a named schematic symbol that can be referenced by components."),ose=Ae({type:FA("schematic_line"),schematic_line_id:oi("schematic_line"),schematic_component_id:H().optional(),schematic_symbol_id:H().optional(),x1:_t,y1:_t,x2:_t,y2:_t,stroke_width:_t.nullable().optional(),color:H().default("#000000"),is_dashed:ce().default(!1),subcircuit_id:H().optional()}).describe("Draws a styled line on the schematic"),sse=Ae({type:FA("schematic_rect"),schematic_rect_id:oi("schematic_rect"),schematic_component_id:H().optional(),schematic_symbol_id:H().optional(),center:kn,width:_t,height:_t,rotation:bQ.default(0),stroke_width:_t.nullable().optional(),color:H().default("#000000"),is_filled:ce().default(!1),fill_color:H().optional(),is_dashed:ce().default(!1),subcircuit_id:H().optional()}).describe("Draws a styled rectangle on the schematic"),rse=Ae({type:FA("schematic_circle"),schematic_circle_id:oi("schematic_circle"),schematic_component_id:H().optional(),schematic_symbol_id:H().optional(),center:kn,radius:_t,stroke_width:_t.nullable().optional(),color:H().default("#000000"),is_filled:ce().default(!1),fill_color:H().optional(),is_dashed:ce().default(!1),subcircuit_id:H().optional()}).describe("Draws a styled circle on the schematic"),ase=Ae({type:FA("schematic_arc"),schematic_arc_id:oi("schematic_arc"),schematic_component_id:H().optional(),schematic_symbol_id:H().optional(),center:kn,radius:_t,start_angle_degrees:bQ,end_angle_degrees:bQ,direction:pt(["clockwise","counterclockwise"]).default("counterclockwise"),stroke_width:_t.nullable().optional(),color:H().default("#000000"),is_dashed:ce().default(!1),subcircuit_id:H().optional()}).describe("Draws a styled arc on the schematic"),gse=Ae({type:FA("schematic_trace"),schematic_trace_id:H(),source_trace_id:H().optional(),junctions:ve(Ae({x:zA(),y:zA()})),edges:ve(Ae({from:Ae({x:zA(),y:zA()}),to:Ae({x:zA(),y:zA()}),is_crossing:ce().optional(),from_schematic_port_id:H().optional(),to_schematic_port_id:H().optional()})),subcircuit_id:H().optional(),subcircuit_connectivity_map_key:H().optional()}),PPt=pt(["center","left","right","top","bottom"]),cse=Ae({type:FA("schematic_text"),schematic_component_id:H().optional(),schematic_symbol_id:H().optional(),schematic_text_id:H(),text:H(),font_size:zA().default(.18),position:Ae({x:_t,y:_t}),rotation:zA().default(0),anchor:ii([PPt.describe("legacy"),z_]).default("center"),color:H().default("#000000"),subcircuit_id:H().optional()}),Ise=Ae({type:FA("schematic_port"),schematic_port_id:H(),source_port_id:H(),schematic_component_id:H().optional(),center:kn,facing_direction:pt(["up","down","left","right"]).optional(),distance_from_component_edge:zA().optional(),side_of_component:pt(["top","bottom","left","right"]).optional(),true_ccw_index:zA().optional(),pin_number:zA().optional(),display_pin_label:H().optional(),subcircuit_id:H().optional(),is_connected:ce().optional(),has_input_arrow:ce().optional(),has_output_arrow:ce().optional(),is_drawn_with_inversion_circle:ce().optional()}).describe("Defines a port on a schematic component"),lse=Ae({type:FA("schematic_net_label"),schematic_net_label_id:oi("schematic_net_label"),schematic_trace_id:H().optional(),source_trace_id:H().optional(),source_net_id:H(),center:kn,anchor_position:kn.optional(),anchor_side:pt(["top","bottom","left","right"]),text:H(),symbol_name:H().optional(),is_movable:ce().optional(),subcircuit_id:H().optional()}),Bse=ll.extend({type:FA("schematic_error"),schematic_error_id:H(),error_type:FA("schematic_port_not_found").default("schematic_port_not_found"),subcircuit_id:H().optional()}).describe("Defines a schematic error on the schematic"),Cse=ll.extend({type:FA("schematic_layout_error"),schematic_layout_error_id:oi("schematic_layout_error"),error_type:FA("schematic_layout_error").default("schematic_layout_error"),source_group_id:H(),schematic_group_id:H(),subcircuit_id:H().optional()}).describe("Error emitted when schematic layout fails for a group"),m9=Ae({type:FA("schematic_debug_object"),label:H().optional(),subcircuit_id:H().optional()}),Qse=m9.extend({shape:FA("rect"),center:kn,size:fdA}),hse=m9.extend({shape:FA("line"),start:kn,end:kn}),Ese=m9.extend({shape:FA("point"),center:kn}),use=ff("shape",[Qse,hse,Ese]),dse=Ae({type:FA("schematic_voltage_probe"),schematic_voltage_probe_id:H(),source_component_id:H().optional(),name:H().optional(),position:kn,schematic_trace_id:H(),voltage:Db.optional(),subcircuit_id:H().optional(),color:H().optional(),label_alignment:z_.optional()}).describe("Defines a voltage probe measurement point on a schematic trace"),pse=Ae({type:FA("schematic_manual_edit_conflict_warning"),schematic_manual_edit_conflict_warning_id:oi("schematic_manual_edit_conflict_warning"),warning_type:FA("schematic_manual_edit_conflict_warning").default("schematic_manual_edit_conflict_warning"),message:H(),schematic_component_id:H(),schematic_group_id:H().optional(),subcircuit_id:H().optional(),source_component_id:H()}).describe("Warning emitted when a component has both manual placement and explicit schX/schY coordinates"),fse=Ae({type:FA("schematic_group"),schematic_group_id:oi("schematic_group"),source_group_id:H(),is_subcircuit:ce().optional(),subcircuit_id:H().optional(),width:Qn,height:Qn,center:kn,schematic_component_ids:ve(H()),show_as_schematic_box:ce().optional(),name:H().optional(),description:H().optional()}).describe("Defines a group of components on the schematic"),yse=Ae({type:FA("schematic_table"),schematic_table_id:oi("schematic_table"),anchor_position:kn,column_widths:ve(_t),row_heights:ve(_t),cell_padding:_t.optional(),border_width:_t.optional(),subcircuit_id:H().optional(),schematic_component_id:H().optional(),anchor:z_.optional()}).describe("Defines a table on the schematic"),mse=Ae({type:FA("schematic_table_cell"),schematic_table_cell_id:oi("schematic_table_cell"),schematic_table_id:H(),start_row_index:zA(),end_row_index:zA(),start_column_index:zA(),end_column_index:zA(),text:H().optional(),center:kn,width:_t,height:_t,horizontal_align:pt(["left","center","right"]).optional(),vertical_align:pt(["top","middle","bottom"]).optional(),font_size:_t.optional(),subcircuit_id:H().optional()}).describe("Defines a cell within a schematic_table"),wse=Ae({type:FA("schematic_sheet"),schematic_sheet_id:oi("schematic_sheet"),name:H().optional(),subcircuit_id:H().optional()}).describe("Defines a schematic sheet or page that components can be placed on"),Dse=Ae({x:_t,y:_t,bulge:zA().optional()}),qdA=Ae({vertices:ve(Dse)}),Sse=Ae({outer_ring:qdA,inner_rings:ve(qdA).default([])}),bse=Ae({x:_t,y:_t,via:ce().optional(),via_to_layer:oa.optional()}),qPt=ve(bse),xse=Ae({x:_t,y:_t,via:ce().optional(),to_layer:oa.optional(),trace_width:_t.optional()}),_se=Ae({type:FA("pcb_component"),pcb_component_id:oi("pcb_component"),source_component_id:H(),center:kn,layer:oa,rotation:bQ,display_offset_x:H().optional().describe("How to display the x offset for this part, usually corresponding with how the user specified it"),display_offset_y:H().optional().describe("How to display the y offset for this part, usually corresponding with how the user specified it"),width:Qn,height:Qn,do_not_place:ce().optional(),is_allowed_to_be_off_board:ce().optional(),subcircuit_id:H().optional(),pcb_group_id:H().optional(),position_mode:pt(["packed","relative_to_group_anchor","none"]).optional(),positioned_relative_to_pcb_group_id:H().optional(),positioned_relative_to_pcb_board_id:H().optional(),metadata:Ae({kicad_footprint:yoe.optional()}).optional(),obstructs_within_bounds:ce().default(!0).describe("Does this component take up all the space within its bounds on a layer. This is generally true except for when separated pin headers are being represented by a single component (in which case, chips can be placed between the pin headers) or for tall modules where chips fit underneath")}).describe("Defines a component on the PCB"),kse=Ae({type:FA("pcb_hole"),pcb_hole_id:oi("pcb_hole"),pcb_group_id:H().optional(),subcircuit_id:H().optional(),pcb_component_id:H().optional(),hole_shape:FA("circle"),hole_diameter:zA(),x:_t,y:_t,is_covered_with_solder_mask:ce().optional(),soldermask_margin:zA().optional()}),OPt=kse.describe("Defines a circular hole on the PCB"),Fse=Ae({type:FA("pcb_hole"),pcb_hole_id:oi("pcb_hole"),pcb_group_id:H().optional(),subcircuit_id:H().optional(),pcb_component_id:H().optional(),hole_shape:FA("rect"),hole_width:zA(),hole_height:zA(),x:_t,y:_t,is_covered_with_solder_mask:ce().optional(),soldermask_margin:zA().optional()}),WPt=Fse.describe("Defines a rectangular (square-capable) hole on the PCB. Use equal width/height for square."),Gse=Ae({type:FA("pcb_hole"),pcb_hole_id:oi("pcb_hole"),pcb_group_id:H().optional(),subcircuit_id:H().optional(),pcb_component_id:H().optional(),hole_shape:pt(["circle","square"]),hole_diameter:zA(),x:_t,y:_t,is_covered_with_solder_mask:ce().optional(),soldermask_margin:zA().optional()}),ZPt=Gse.describe("Defines a circular or square hole on the PCB"),vse=Ae({type:FA("pcb_hole"),pcb_hole_id:oi("pcb_hole"),pcb_group_id:H().optional(),subcircuit_id:H().optional(),pcb_component_id:H().optional(),hole_shape:FA("oval"),hole_width:zA(),hole_height:zA(),x:_t,y:_t,is_covered_with_solder_mask:ce().optional(),soldermask_margin:zA().optional()}),VPt=vse.describe("Defines an oval hole on the PCB"),Rse=Ae({type:FA("pcb_hole"),pcb_hole_id:oi("pcb_hole"),pcb_group_id:H().optional(),subcircuit_id:H().optional(),pcb_component_id:H().optional(),hole_shape:FA("pill"),hole_width:zA(),hole_height:zA(),x:_t,y:_t,is_covered_with_solder_mask:ce().optional(),soldermask_margin:zA().optional()}),jPt=Rse.describe("Defines a pill-shaped hole on the PCB"),Mse=Ae({type:FA("pcb_hole"),pcb_hole_id:oi("pcb_hole"),pcb_group_id:H().optional(),subcircuit_id:H().optional(),pcb_component_id:H().optional(),hole_shape:FA("rotated_pill"),hole_width:zA(),hole_height:zA(),x:_t,y:_t,ccw_rotation:bQ,is_covered_with_solder_mask:ce().optional(),soldermask_margin:zA().optional()}),zPt=Mse.describe("Defines a rotated pill-shaped hole on the PCB"),Nse=Gse.or(vse).or(Rse).or(Mse).or(kse).or(Fse),XPt=Ae({type:FA("pcb_plated_hole"),shape:FA("circle"),pcb_group_id:H().optional(),subcircuit_id:H().optional(),outer_diameter:zA(),hole_diameter:zA(),is_covered_with_solder_mask:ce().optional(),x:_t,y:_t,layers:ve(oa),port_hints:ve(H()).optional(),pcb_component_id:H().optional(),pcb_port_id:H().optional(),pcb_plated_hole_id:oi("pcb_plated_hole"),soldermask_margin:zA().optional()}),$Pt=Ae({type:FA("pcb_plated_hole"),shape:pt(["oval","pill"]),pcb_group_id:H().optional(),subcircuit_id:H().optional(),outer_width:zA(),outer_height:zA(),hole_width:zA(),hole_height:zA(),is_covered_with_solder_mask:ce().optional(),x:_t,y:_t,ccw_rotation:bQ,layers:ve(oa),port_hints:ve(H()).optional(),pcb_component_id:H().optional(),pcb_port_id:H().optional(),pcb_plated_hole_id:oi("pcb_plated_hole"),soldermask_margin:zA().optional()}),Aqt=Ae({type:FA("pcb_plated_hole"),shape:FA("circular_hole_with_rect_pad"),pcb_group_id:H().optional(),subcircuit_id:H().optional(),hole_shape:FA("circle"),pad_shape:FA("rect"),hole_diameter:zA(),rect_pad_width:zA(),rect_pad_height:zA(),rect_border_radius:zA().optional(),hole_offset_x:_t.default(0),hole_offset_y:_t.default(0),is_covered_with_solder_mask:ce().optional(),x:_t,y:_t,layers:ve(oa),port_hints:ve(H()).optional(),pcb_component_id:H().optional(),pcb_port_id:H().optional(),pcb_plated_hole_id:oi("pcb_plated_hole"),soldermask_margin:zA().optional(),rect_ccw_rotation:bQ.optional()}),eqt=Ae({type:FA("pcb_plated_hole"),shape:FA("pill_hole_with_rect_pad"),pcb_group_id:H().optional(),subcircuit_id:H().optional(),hole_shape:FA("pill"),pad_shape:FA("rect"),hole_width:zA(),hole_height:zA(),rect_pad_width:zA(),rect_pad_height:zA(),rect_border_radius:zA().optional(),hole_offset_x:_t.default(0),hole_offset_y:_t.default(0),is_covered_with_solder_mask:ce().optional(),x:_t,y:_t,layers:ve(oa),port_hints:ve(H()).optional(),pcb_component_id:H().optional(),pcb_port_id:H().optional(),pcb_plated_hole_id:oi("pcb_plated_hole"),soldermask_margin:zA().optional()}),tqt=Ae({type:FA("pcb_plated_hole"),shape:FA("rotated_pill_hole_with_rect_pad"),pcb_group_id:H().optional(),subcircuit_id:H().optional(),hole_shape:FA("rotated_pill"),pad_shape:FA("rect"),hole_width:zA(),hole_height:zA(),hole_ccw_rotation:bQ,rect_pad_width:zA(),rect_pad_height:zA(),rect_border_radius:zA().optional(),rect_ccw_rotation:bQ,hole_offset_x:_t.default(0),hole_offset_y:_t.default(0),is_covered_with_solder_mask:ce().optional(),x:_t,y:_t,layers:ve(oa),port_hints:ve(H()).optional(),pcb_component_id:H().optional(),pcb_port_id:H().optional(),pcb_plated_hole_id:oi("pcb_plated_hole"),soldermask_margin:zA().optional()}),iqt=Ae({type:FA("pcb_plated_hole"),shape:FA("hole_with_polygon_pad"),pcb_group_id:H().optional(),subcircuit_id:H().optional(),hole_shape:pt(["circle","oval","pill","rotated_pill"]),hole_diameter:zA().optional(),hole_width:zA().optional(),hole_height:zA().optional(),pad_outline:ve(Ae({x:_t,y:_t})).min(3),hole_offset_x:_t.default(0),hole_offset_y:_t.default(0),is_covered_with_solder_mask:ce().optional(),x:_t,y:_t,layers:ve(oa),port_hints:ve(H()).optional(),pcb_component_id:H().optional(),pcb_port_id:H().optional(),pcb_plated_hole_id:oi("pcb_plated_hole"),soldermask_margin:zA().optional(),ccw_rotation:bQ.optional()}),Lse=ii([XPt,$Pt,Aqt,eqt,tqt,iqt]),Use=Ae({type:FA("pcb_port"),pcb_port_id:oi("pcb_port"),pcb_group_id:H().optional(),subcircuit_id:H().optional(),source_port_id:H(),pcb_component_id:H().optional(),x:_t,y:_t,layers:ve(oa),is_board_pinout:ce().optional()}).describe("Defines a port on the PCB"),nqt=Ae({type:FA("pcb_smtpad"),shape:FA("circle"),pcb_smtpad_id:oi("pcb_smtpad"),pcb_group_id:H().optional(),subcircuit_id:H().optional(),x:_t,y:_t,radius:zA(),layer:oa,port_hints:ve(H()).optional(),pcb_component_id:H().optional(),pcb_port_id:H().optional(),is_covered_with_solder_mask:ce().optional(),soldermask_margin:zA().optional()}),oqt=Ae({type:FA("pcb_smtpad"),shape:FA("rect"),pcb_smtpad_id:oi("pcb_smtpad"),pcb_group_id:H().optional(),subcircuit_id:H().optional(),x:_t,y:_t,width:zA(),height:zA(),rect_border_radius:zA().optional(),corner_radius:zA().optional(),layer:oa,port_hints:ve(H()).optional(),pcb_component_id:H().optional(),pcb_port_id:H().optional(),is_covered_with_solder_mask:ce().optional(),soldermask_margin:zA().optional(),soldermask_margin_left:zA().optional(),soldermask_margin_top:zA().optional(),soldermask_margin_right:zA().optional(),soldermask_margin_bottom:zA().optional()}),sqt=Ae({type:FA("pcb_smtpad"),shape:FA("rotated_rect"),pcb_smtpad_id:oi("pcb_smtpad"),pcb_group_id:H().optional(),subcircuit_id:H().optional(),x:_t,y:_t,width:zA(),height:zA(),rect_border_radius:zA().optional(),corner_radius:zA().optional(),ccw_rotation:bQ,layer:oa,port_hints:ve(H()).optional(),pcb_component_id:H().optional(),pcb_port_id:H().optional(),is_covered_with_solder_mask:ce().optional(),soldermask_margin:zA().optional(),soldermask_margin_left:zA().optional(),soldermask_margin_top:zA().optional(),soldermask_margin_right:zA().optional(),soldermask_margin_bottom:zA().optional()}),Hse=Ae({type:FA("pcb_smtpad"),shape:FA("pill"),pcb_smtpad_id:oi("pcb_smtpad"),pcb_group_id:H().optional(),subcircuit_id:H().optional(),x:_t,y:_t,width:zA(),height:zA(),radius:zA(),layer:oa,port_hints:ve(H()).optional(),pcb_component_id:H().optional(),pcb_port_id:H().optional(),is_covered_with_solder_mask:ce().optional(),soldermask_margin:zA().optional()}),rqt=Ae({type:FA("pcb_smtpad"),shape:FA("rotated_pill"),pcb_smtpad_id:oi("pcb_smtpad"),pcb_group_id:H().optional(),subcircuit_id:H().optional(),x:_t,y:_t,width:zA(),height:zA(),radius:zA(),ccw_rotation:bQ,layer:oa,port_hints:ve(H()).optional(),pcb_component_id:H().optional(),pcb_port_id:H().optional(),is_covered_with_solder_mask:ce().optional(),soldermask_margin:zA().optional()}),aqt=Ae({type:FA("pcb_smtpad"),shape:FA("polygon"),pcb_smtpad_id:oi("pcb_smtpad"),pcb_group_id:H().optional(),subcircuit_id:H().optional(),points:ve(kn),layer:oa,port_hints:ve(H()).optional(),pcb_component_id:H().optional(),pcb_port_id:H().optional(),is_covered_with_solder_mask:ce().optional(),soldermask_margin:zA().optional()}),Yse=ff("shape",[nqt,oqt,sqt,rqt,Hse,aqt]).describe("Defines an SMT pad on the PCB"),gqt=Ae({type:FA("pcb_solder_paste"),shape:FA("circle"),pcb_solder_paste_id:oi("pcb_solder_paste"),pcb_group_id:H().optional(),subcircuit_id:H().optional(),x:_t,y:_t,radius:zA(),layer:oa,pcb_component_id:H().optional(),pcb_smtpad_id:H().optional()}),cqt=Ae({type:FA("pcb_solder_paste"),shape:FA("rect"),pcb_solder_paste_id:oi("pcb_solder_paste"),pcb_group_id:H().optional(),subcircuit_id:H().optional(),x:_t,y:_t,width:zA(),height:zA(),layer:oa,pcb_component_id:H().optional(),pcb_smtpad_id:H().optional()}),Iqt=Ae({type:FA("pcb_solder_paste"),shape:FA("pill"),pcb_solder_paste_id:oi("pcb_solder_paste"),pcb_group_id:H().optional(),subcircuit_id:H().optional(),x:_t,y:_t,width:zA(),height:zA(),radius:zA(),layer:oa,pcb_component_id:H().optional(),pcb_smtpad_id:H().optional()}),lqt=Ae({type:FA("pcb_solder_paste"),shape:FA("rotated_rect"),pcb_solder_paste_id:oi("pcb_solder_paste"),pcb_group_id:H().optional(),subcircuit_id:H().optional(),x:_t,y:_t,width:zA(),height:zA(),ccw_rotation:_t,layer:oa,pcb_component_id:H().optional(),pcb_smtpad_id:H().optional()}),Bqt=Ae({type:FA("pcb_solder_paste"),shape:FA("oval"),pcb_solder_paste_id:oi("pcb_solder_paste"),pcb_group_id:H().optional(),subcircuit_id:H().optional(),x:_t,y:_t,width:zA(),height:zA(),layer:oa,pcb_component_id:H().optional(),pcb_smtpad_id:H().optional()}),Jse=ii([gqt,cqt,Iqt,lqt,Bqt]).describe("Defines solderpaste on the PCB"),Tse=Ae({type:FA("pcb_text"),pcb_text_id:oi("pcb_text"),pcb_group_id:H().optional(),subcircuit_id:H().optional(),text:H(),center:kn,layer:oa,width:Qn,height:Qn,lines:zA(),align:pt(["bottom-left"])}).describe("Defines text on the PCB"),Kse=Ae({route_type:FA("wire"),x:_t,y:_t,width:_t,start_pcb_port_id:H().optional(),end_pcb_port_id:H().optional(),layer:oa}),Pse=Ae({route_type:FA("via"),x:_t,y:_t,hole_diameter:_t.optional(),outer_diameter:_t.optional(),from_layer:H(),to_layer:H()}),qse=ii([Kse,Pse]),Ose=Ae({type:FA("pcb_trace"),source_trace_id:H().optional(),pcb_component_id:H().optional(),pcb_trace_id:oi("pcb_trace"),pcb_group_id:H().optional(),subcircuit_id:H().optional(),route_thickness_mode:pt(["constant","interpolated"]).default("constant").optional(),route_order_index:zA().optional(),should_round_corners:ce().optional(),trace_length:zA().optional(),highlight_color:H().optional(),route:ve(qse)}).describe("Defines a trace on the PCB"),Wse=ll.extend({type:FA("pcb_trace_error"),pcb_trace_error_id:oi("pcb_trace_error"),error_type:FA("pcb_trace_error").default("pcb_trace_error"),center:kn.optional(),pcb_trace_id:H(),source_trace_id:H(),pcb_component_ids:ve(H()),pcb_port_ids:ve(H()),subcircuit_id:H().optional()}).describe("Defines a trace error on the PCB"),Zse=ll.extend({type:FA("pcb_trace_missing_error"),pcb_trace_missing_error_id:oi("pcb_trace_missing_error"),error_type:FA("pcb_trace_missing_error").default("pcb_trace_missing_error"),center:kn.optional(),source_trace_id:H(),pcb_component_ids:ve(H()),pcb_port_ids:ve(H()),subcircuit_id:H().optional()}).describe("Defines an error when a source trace has no corresponding PCB trace"),Vse=ll.extend({type:FA("pcb_port_not_matched_error"),pcb_error_id:oi("pcb_error"),error_type:FA("pcb_port_not_matched_error").default("pcb_port_not_matched_error"),pcb_component_ids:ve(H()),subcircuit_id:H().optional()}).describe("Defines a trace error on the PCB where a port is not matched"),jse=ll.extend({type:FA("pcb_port_not_connected_error"),pcb_port_not_connected_error_id:oi("pcb_port_not_connected_error"),error_type:FA("pcb_port_not_connected_error").default("pcb_port_not_connected_error"),pcb_port_ids:ve(H()),pcb_component_ids:ve(H()),subcircuit_id:H().optional()}).describe("Defines an error when a pcb port is not connected to any trace"),zse=Ae({type:FA("pcb_net"),pcb_net_id:oi("pcb_net"),source_net_id:H().optional(),highlight_color:H().optional()}).describe("Defines a net on the PCB"),Xse=Ae({type:FA("pcb_via"),pcb_via_id:oi("pcb_via"),pcb_group_id:H().optional(),subcircuit_id:H().optional(),subcircuit_connectivity_map_key:H().optional(),x:_t,y:_t,outer_diameter:_t.default("0.6mm"),hole_diameter:_t.default("0.25mm"),from_layer:oa.optional(),to_layer:oa.optional(),layers:ve(oa),pcb_trace_id:H().optional(),net_is_assignable:ce().optional(),net_assigned:ce().optional(),is_tented:ce().optional()}).describe("Defines a via on the PCB"),$se=Ae({type:FA("pcb_board"),pcb_board_id:oi("pcb_board"),pcb_panel_id:H().optional(),carrier_pcb_board_id:H().optional(),is_subcircuit:ce().optional(),subcircuit_id:H().optional(),is_mounted_to_carrier_board:ce().optional(),width:Qn.optional(),height:Qn.optional(),center:kn,display_offset_x:H().optional().describe("How to display the x offset for this board, usually corresponding with how the user specified it"),display_offset_y:H().optional().describe("How to display the y offset for this board, usually corresponding with how the user specified it"),thickness:Qn.optional().default(1.4),num_layers:zA().optional().default(4),outline:ve(kn).optional(),shape:pt(["rect","polygon"]).optional(),material:pt(["fr4","fr1"]).default("fr4"),anchor_position:kn.optional(),anchor_alignment:z_.optional(),position_mode:pt(["relative_to_panel_anchor","none"]).optional()}).describe("Defines the board outline of the PCB"),Are=Ae({type:FA("pcb_panel"),pcb_panel_id:oi("pcb_panel"),width:Qn,height:Qn,center:kn,covered_with_solder_mask:ce().optional().default(!0)}).describe("Defines a PCB panel that can contain multiple boards"),ere=ll.extend({type:FA("pcb_placement_error"),pcb_placement_error_id:oi("pcb_placement_error"),error_type:FA("pcb_placement_error").default("pcb_placement_error"),subcircuit_id:H().optional()}).describe("Defines a placement error on the PCB"),tre=ll.extend({type:FA("pcb_panelization_placement_error"),pcb_panelization_placement_error_id:oi("pcb_panelization_placement_error"),error_type:FA("pcb_panelization_placement_error").default("pcb_panelization_placement_error"),pcb_panel_id:H().optional(),pcb_board_id:H().optional(),subcircuit_id:H().optional()}).describe("Defines a panelization placement error on the PCB"),ire=Ae({type:FA("pcb_trace_hint"),pcb_trace_hint_id:oi("pcb_trace_hint"),pcb_port_id:H(),pcb_component_id:H(),route:ve(xse),subcircuit_id:H().optional()}).describe("A hint that can be used during generation of a PCB trace"),nre=Ae({type:FA("pcb_silkscreen_line"),pcb_silkscreen_line_id:oi("pcb_silkscreen_line"),pcb_component_id:H(),pcb_group_id:H().optional(),subcircuit_id:H().optional(),stroke_width:_t.default("0.1mm"),x1:_t,y1:_t,x2:_t,y2:_t,layer:rm}).describe("Defines a silkscreen line on the PCB"),ore=Ae({type:FA("pcb_silkscreen_path"),pcb_silkscreen_path_id:oi("pcb_silkscreen_path"),pcb_component_id:H(),pcb_group_id:H().optional(),subcircuit_id:H().optional(),layer:rm,route:ve(kn),stroke_width:Qn}).describe("Defines a silkscreen path on the PCB"),sre=Ae({type:FA("pcb_silkscreen_text"),pcb_silkscreen_text_id:oi("pcb_silkscreen_text"),pcb_group_id:H().optional(),subcircuit_id:H().optional(),font:FA("tscircuit2024").default("tscircuit2024"),font_size:_t.default("0.2mm"),pcb_component_id:H(),text:H(),is_knockout:ce().default(!1).optional(),knockout_padding:Ae({left:Qn,top:Qn,bottom:Qn,right:Qn}).default({left:"0.2mm",top:"0.2mm",bottom:"0.2mm",right:"0.2mm"}).optional(),ccw_rotation:zA().optional(),layer:oa,is_mirrored:ce().default(!1).optional(),anchor_position:kn.default({x:0,y:0}),anchor_alignment:z_.default("center")}).describe("Defines silkscreen text on the PCB"),rre=Ae({type:FA("pcb_copper_text"),pcb_copper_text_id:oi("pcb_copper_text"),pcb_group_id:H().optional(),subcircuit_id:H().optional(),font:FA("tscircuit2024").default("tscircuit2024"),font_size:_t.default("0.2mm"),pcb_component_id:H(),text:H(),is_knockout:ce().default(!1).optional(),knockout_padding:Ae({left:Qn,top:Qn,bottom:Qn,right:Qn}).default({left:"0.2mm",top:"0.2mm",bottom:"0.2mm",right:"0.2mm"}).optional(),ccw_rotation:zA().optional(),layer:oa,is_mirrored:ce().default(!1).optional(),anchor_position:kn.default({x:0,y:0}),anchor_alignment:z_.default("center")}).describe("Defines copper text on the PCB"),are=Ae({type:FA("pcb_silkscreen_rect"),pcb_silkscreen_rect_id:oi("pcb_silkscreen_rect"),pcb_component_id:H(),pcb_group_id:H().optional(),subcircuit_id:H().optional(),center:kn,width:Qn,height:Qn,layer:oa,stroke_width:Qn.default("1mm"),corner_radius:Qn.optional(),is_filled:ce().default(!0).optional(),has_stroke:ce().optional(),is_stroke_dashed:ce().optional(),ccw_rotation:zA().optional()}).describe("Defines a silkscreen rect on the PCB"),gre=Ae({type:FA("pcb_silkscreen_circle"),pcb_silkscreen_circle_id:oi("pcb_silkscreen_circle"),pcb_component_id:H(),pcb_group_id:H().optional(),subcircuit_id:H().optional(),center:kn,radius:Qn,layer:rm,stroke_width:Qn.default("1mm")}).describe("Defines a silkscreen circle on the PCB"),cre=Ae({type:FA("pcb_silkscreen_oval"),pcb_silkscreen_oval_id:oi("pcb_silkscreen_oval"),pcb_component_id:H(),pcb_group_id:H().optional(),subcircuit_id:H().optional(),center:kn,radius_x:_t,radius_y:_t,layer:rm,ccw_rotation:bQ.optional()}).describe("Defines a silkscreen oval on the PCB"),Ire=Ae({type:FA("pcb_silkscreen_pill"),pcb_silkscreen_pill_id:oi("pcb_silkscreen_pill"),pcb_component_id:H(),pcb_group_id:H().optional(),subcircuit_id:H().optional(),center:kn,width:Qn,height:Qn,layer:oa,ccw_rotation:zA().optional()}).describe("Defines a silkscreen pill on the PCB"),lre=Ae({type:FA("pcb_fabrication_note_text"),pcb_fabrication_note_text_id:oi("pcb_fabrication_note_text"),subcircuit_id:H().optional(),pcb_group_id:H().optional(),font:FA("tscircuit2024").default("tscircuit2024"),font_size:_t.default("1mm"),pcb_component_id:H(),text:H(),layer:rm,anchor_position:kn.default({x:0,y:0}),anchor_alignment:pt(["center","top_left","top_right","bottom_left","bottom_right"]).default("center"),color:H().optional()}).describe("Defines a fabrication note in text on the PCB, useful for leaving notes for assemblers or fabricators"),Bre=Ae({type:FA("pcb_fabrication_note_path"),pcb_fabrication_note_path_id:oi("pcb_fabrication_note_path"),pcb_component_id:H(),subcircuit_id:H().optional(),layer:oa,route:ve(kn),stroke_width:Qn,color:H().optional()}).describe("Defines a fabrication path on the PCB for fabricators or assemblers"),Cre=Ae({type:FA("pcb_fabrication_note_rect"),pcb_fabrication_note_rect_id:oi("pcb_fabrication_note_rect"),pcb_component_id:H(),pcb_group_id:H().optional(),subcircuit_id:H().optional(),center:kn,width:Qn,height:Qn,layer:rm,stroke_width:Qn.default("0.1mm"),corner_radius:Qn.optional(),is_filled:ce().optional(),has_stroke:ce().optional(),is_stroke_dashed:ce().optional(),color:H().optional()}).describe("Defines a fabrication note rectangle on the PCB"),Qre=Ae({type:FA("pcb_fabrication_note_dimension"),pcb_fabrication_note_dimension_id:oi("pcb_fabrication_note_dimension"),pcb_component_id:H(),pcb_group_id:H().optional(),subcircuit_id:H().optional(),layer:rm,from:kn,to:kn,text:H().optional(),text_ccw_rotation:zA().optional(),offset:Qn.optional(),offset_distance:Qn.optional(),offset_direction:Ae({x:zA(),y:zA()}).optional(),font:FA("tscircuit2024").default("tscircuit2024"),font_size:Qn.default("1mm"),color:H().optional(),arrow_size:Qn.default("1mm")}).describe("Defines a measurement annotation within PCB fabrication notes"),hre=Ae({type:FA("pcb_note_text"),pcb_note_text_id:oi("pcb_note_text"),pcb_component_id:H().optional(),pcb_group_id:H().optional(),subcircuit_id:H().optional(),name:H().optional(),font:FA("tscircuit2024").default("tscircuit2024"),font_size:_t.default("1mm"),text:H().optional(),anchor_position:kn.default({x:0,y:0}),anchor_alignment:pt(["center","top_left","top_right","bottom_left","bottom_right"]).default("center"),color:H().optional()}).describe("Defines a documentation note in text on the PCB"),Ere=Ae({type:FA("pcb_note_rect"),pcb_note_rect_id:oi("pcb_note_rect"),pcb_component_id:H().optional(),pcb_group_id:H().optional(),subcircuit_id:H().optional(),name:H().optional(),text:H().optional(),center:kn,width:Qn,height:Qn,stroke_width:Qn.default("0.1mm"),corner_radius:Qn.optional(),is_filled:ce().optional(),has_stroke:ce().optional(),is_stroke_dashed:ce().optional(),color:H().optional()}).describe("Defines a rectangular documentation note on the PCB"),ure=Ae({type:FA("pcb_note_path"),pcb_note_path_id:oi("pcb_note_path"),pcb_component_id:H().optional(),pcb_group_id:H().optional(),subcircuit_id:H().optional(),name:H().optional(),text:H().optional(),route:ve(kn),stroke_width:Qn.default("0.1mm"),color:H().optional()}).describe("Defines a polyline documentation note on the PCB"),dre=Ae({type:FA("pcb_note_line"),pcb_note_line_id:oi("pcb_note_line"),pcb_component_id:H().optional(),pcb_group_id:H().optional(),subcircuit_id:H().optional(),name:H().optional(),text:H().optional(),x1:_t,y1:_t,x2:_t,y2:_t,stroke_width:_t.default("0.1mm"),color:H().optional(),is_dashed:ce().optional()}).describe("Defines a straight documentation note line on the PCB"),pre=Ae({type:FA("pcb_note_dimension"),pcb_note_dimension_id:oi("pcb_note_dimension"),pcb_component_id:H().optional(),pcb_group_id:H().optional(),subcircuit_id:H().optional(),name:H().optional(),from:kn,to:kn,text:H().optional(),text_ccw_rotation:zA().optional(),offset_distance:Qn.optional(),offset_direction:Ae({x:zA(),y:zA()}).optional(),font:FA("tscircuit2024").default("tscircuit2024"),font_size:Qn.default("1mm"),color:H().optional(),arrow_size:Qn.default("1mm")}).describe("Defines a measurement annotation within PCB documentation notes"),fre=ll.extend({type:FA("pcb_footprint_overlap_error"),pcb_error_id:oi("pcb_error"),error_type:FA("pcb_footprint_overlap_error").default("pcb_footprint_overlap_error"),pcb_smtpad_ids:ve(H()).optional(),pcb_plated_hole_ids:ve(H()).optional(),pcb_hole_ids:ve(H()).optional(),pcb_keepout_ids:ve(H()).optional()}).describe("Error emitted when a pcb footprint overlaps with another element"),yre=Ae({type:FA("pcb_keepout"),shape:FA("rect"),pcb_group_id:H().optional(),subcircuit_id:H().optional(),center:kn,width:_t,height:_t,pcb_keepout_id:H(),layers:ve(H()),description:H().optional()}).or(Ae({type:FA("pcb_keepout"),shape:FA("circle"),pcb_group_id:H().optional(),subcircuit_id:H().optional(),center:kn,radius:_t,pcb_keepout_id:H(),layers:ve(H()),description:H().optional()})),w9=Ae({type:FA("pcb_cutout"),pcb_cutout_id:oi("pcb_cutout"),pcb_group_id:H().optional(),subcircuit_id:H().optional(),pcb_board_id:H().optional(),pcb_panel_id:H().optional()}),mre=w9.extend({shape:FA("rect"),center:kn,width:Qn,height:Qn,rotation:bQ.optional(),corner_radius:Qn.optional()}),wre=w9.extend({shape:FA("circle"),center:kn,radius:Qn}),Dre=w9.extend({shape:FA("polygon"),points:ve(kn)}),Sre=w9.extend({shape:FA("path"),route:ve(kn),slot_width:Qn,slot_length:Qn.optional(),space_between_slots:Qn.optional(),slot_corner_radius:Qn.optional()}),bre=ff("shape",[mre,wre,Dre,Sre]).describe("Defines a cutout on the PCB, removing board material."),xre=ll.extend({type:FA("pcb_missing_footprint_error"),pcb_missing_footprint_error_id:oi("pcb_missing_footprint_error"),pcb_group_id:H().optional(),subcircuit_id:H().optional(),error_type:FA("pcb_missing_footprint_error").default("pcb_missing_footprint_error"),source_component_id:H()}).describe("Defines a missing footprint error on the PCB"),_re=ll.extend({type:FA("external_footprint_load_error"),external_footprint_load_error_id:oi("external_footprint_load_error"),pcb_component_id:H(),source_component_id:H(),pcb_group_id:H().optional(),subcircuit_id:H().optional(),footprinter_string:H().optional(),error_type:FA("external_footprint_load_error").default("external_footprint_load_error")}).describe("Defines an error when an external footprint fails to load"),kre=ll.extend({type:FA("circuit_json_footprint_load_error"),circuit_json_footprint_load_error_id:oi("circuit_json_footprint_load_error"),pcb_component_id:H(),source_component_id:H(),pcb_group_id:H().optional(),subcircuit_id:H().optional(),error_type:FA("circuit_json_footprint_load_error").default("circuit_json_footprint_load_error"),circuit_json:ve(yI()).optional()}).describe("Defines an error when a circuit JSON footprint fails to load"),Fre=Ae({type:FA("pcb_group"),pcb_group_id:oi("pcb_group"),source_group_id:H(),is_subcircuit:ce().optional(),subcircuit_id:H().optional(),width:Qn.optional(),height:Qn.optional(),center:kn,display_offset_x:H().optional().describe("How to display the x offset for this group, usually corresponding with how the user specified it"),display_offset_y:H().optional().describe("How to display the y offset for this group, usually corresponding with how the user specified it"),outline:ve(kn).optional(),anchor_position:kn.optional(),anchor_alignment:z_.default("center"),position_mode:pt(["packed","relative_to_group_anchor","none"]).optional(),positioned_relative_to_pcb_group_id:H().optional(),positioned_relative_to_pcb_board_id:H().optional(),pcb_component_ids:ve(H()),child_layout_mode:pt(["packed","none"]).optional(),name:H().optional(),description:H().optional(),layout_mode:H().optional(),autorouter_configuration:Ae({trace_clearance:Qn}).optional(),autorouter_used_string:H().optional()}).describe("Defines a group of components on the PCB"),Gre=ll.extend({type:FA("pcb_autorouting_error"),pcb_error_id:oi("pcb_autorouting_error"),error_type:FA("pcb_autorouting_error").default("pcb_autorouting_error"),subcircuit_id:H().optional()}).describe("The autorouting has failed to route a portion of the board"),vre=Ae({type:FA("pcb_manual_edit_conflict_warning"),pcb_manual_edit_conflict_warning_id:oi("pcb_manual_edit_conflict_warning"),warning_type:FA("pcb_manual_edit_conflict_warning").default("pcb_manual_edit_conflict_warning"),message:H(),pcb_component_id:H(),pcb_group_id:H().optional(),subcircuit_id:H().optional(),source_component_id:H()}).describe("Warning emitted when a component has both manual placement and explicit pcbX/pcbY coordinates"),Rre=Ae({type:FA("pcb_breakout_point"),pcb_breakout_point_id:oi("pcb_breakout_point"),pcb_group_id:H(),subcircuit_id:H().optional(),source_trace_id:H().optional(),source_port_id:H().optional(),source_net_id:H().optional(),x:_t,y:_t}).describe("Defines a routing target within a pcb_group for a source_trace or source_net"),Mre=Ae({type:FA("pcb_ground_plane"),pcb_ground_plane_id:oi("pcb_ground_plane"),source_pcb_ground_plane_id:H(),source_net_id:H(),pcb_group_id:H().optional(),subcircuit_id:H().optional()}).describe("Defines a ground plane on the PCB"),Nre=Ae({type:FA("pcb_ground_plane_region"),pcb_ground_plane_region_id:oi("pcb_ground_plane_region"),pcb_ground_plane_id:H(),pcb_group_id:H().optional(),subcircuit_id:H().optional(),layer:oa,points:ve(kn)}).describe("Defines a polygon region of a ground plane"),Lre=Ae({type:FA("pcb_thermal_spoke"),pcb_thermal_spoke_id:oi("pcb_thermal_spoke"),pcb_ground_plane_id:H(),shape:H(),spoke_count:zA(),spoke_thickness:_t,spoke_inner_diameter:_t,spoke_outer_diameter:_t,pcb_plated_hole_id:H().optional(),subcircuit_id:H().optional()}).describe("Pattern for connecting a ground plane to a plated hole"),OdA=Ae({type:FA("pcb_copper_pour"),pcb_copper_pour_id:oi("pcb_copper_pour"),pcb_group_id:H().optional(),subcircuit_id:H().optional(),layer:oa,source_net_id:H().optional(),covered_with_solder_mask:ce().optional().default(!0)}),Ure=OdA.extend({shape:FA("rect"),center:kn,width:Qn,height:Qn,rotation:bQ.optional()}),Hre=OdA.extend({shape:FA("brep"),brep_shape:Sse}),Yre=OdA.extend({shape:FA("polygon"),points:ve(kn)}),Jre=ff("shape",[Ure,Hre,Yre]).describe("Defines a copper pour on the PCB."),Tre=ll.extend({type:FA("pcb_component_outside_board_error"),pcb_component_outside_board_error_id:oi("pcb_component_outside_board_error"),error_type:FA("pcb_component_outside_board_error").default("pcb_component_outside_board_error"),pcb_component_id:H(),pcb_board_id:H(),component_center:kn,component_bounds:Ae({min_x:zA(),max_x:zA(),min_y:zA(),max_y:zA()}),subcircuit_id:H().optional(),source_component_id:H().optional()}).describe("Error emitted when a PCB component is placed outside the board boundaries"),Kre=ll.extend({type:FA("pcb_component_not_on_board_edge_error"),pcb_component_not_on_board_edge_error_id:oi("pcb_component_not_on_board_edge_error"),error_type:FA("pcb_component_not_on_board_edge_error").default("pcb_component_not_on_board_edge_error"),pcb_component_id:H(),pcb_board_id:H(),component_center:kn,pad_to_nearest_board_edge_distance:zA(),source_component_id:H().optional(),subcircuit_id:H().optional()}).describe("Error emitted when a component that must be placed on the board edge is centered away from the edge"),Pre=ll.extend({type:FA("pcb_component_invalid_layer_error"),pcb_component_invalid_layer_error_id:oi("pcb_component_invalid_layer_error"),error_type:FA("pcb_component_invalid_layer_error").default("pcb_component_invalid_layer_error"),pcb_component_id:H().optional(),source_component_id:H(),layer:oa,subcircuit_id:H().optional()}).describe("Error emitted when a component is placed on an invalid layer (components can only be on 'top' or 'bottom' layers)"),qre=ll.extend({type:FA("pcb_via_clearance_error"),pcb_error_id:oi("pcb_error"),error_type:FA("pcb_via_clearance_error").default("pcb_via_clearance_error"),pcb_via_ids:ve(H()).min(2),minimum_clearance:_t.optional(),actual_clearance:_t.optional(),pcb_center:Ae({x:zA().optional(),y:zA().optional()}).optional(),subcircuit_id:H().optional()}).describe("Error emitted when vias are closer than the allowed clearance"),Ore=Ae({type:FA("pcb_courtyard_rect"),pcb_courtyard_rect_id:oi("pcb_courtyard_rect"),pcb_component_id:H(),pcb_group_id:H().optional(),subcircuit_id:H().optional(),center:kn,width:Qn,height:Qn,layer:rm,color:H().optional()}).describe("Defines a courtyard rectangle on the PCB"),Wre=Ae({type:FA("pcb_courtyard_outline"),pcb_courtyard_outline_id:oi("pcb_courtyard_outline"),pcb_component_id:H(),pcb_group_id:H().optional(),subcircuit_id:H().optional(),layer:rm,outline:ve(kn).min(2)}).describe("Defines a courtyard outline on the PCB"),Zre=Ae({type:FA("pcb_courtyard_polygon"),pcb_courtyard_polygon_id:oi("pcb_courtyard_polygon"),pcb_component_id:H(),pcb_group_id:H().optional(),subcircuit_id:H().optional(),layer:rm,points:ve(kn).min(3),color:H().optional()}).describe("Defines a courtyard polygon on the PCB"),Vre=Ae({type:FA("pcb_courtyard_circle"),pcb_courtyard_circle_id:oi("pcb_courtyard_circle"),pcb_component_id:H(),pcb_group_id:H().optional(),subcircuit_id:H().optional(),center:kn,radius:Qn,layer:rm,color:H().optional()}).describe("Defines a courtyard circle on the PCB"),jre=Ae({type:FA("cad_component"),cad_component_id:H(),pcb_component_id:H(),source_component_id:H(),position:j_,rotation:j_.optional(),size:j_.optional(),layer:oa.optional(),subcircuit_id:H().optional(),footprinter_string:H().optional(),model_obj_url:H().optional(),model_stl_url:H().optional(),model_3mf_url:H().optional(),model_gltf_url:H().optional(),model_glb_url:H().optional(),model_step_url:H().optional(),model_wrl_url:H().optional(),model_asset:hoe.optional(),model_unit_to_mm_scale_factor:zA().optional(),model_jscad:yI().optional(),show_as_translucent_model:ce().optional(),anchor_alignment:pt(["center","xy_center_z_board"]).optional().default("center")}).describe("Defines a component on the PCB"),WdA=pt(["sinewave","square","triangle","sawtooth"]),Cqt=ii([H(),zA()]).transform(t=>typeof t=="string"?t.endsWith("%")?parseFloat(t.slice(0,-1))/100:parseFloat(t):t).pipe(zA().min(0,"Duty cycle must be non-negative").max(1,"Duty cycle cannot be greater than 100%")),zre=Ae({type:FA("simulation_voltage_source"),simulation_voltage_source_id:oi("simulation_voltage_source"),is_dc_source:FA(!0).optional().default(!0),positive_source_port_id:H().optional(),negative_source_port_id:H().optional(),positive_source_net_id:H().optional(),negative_source_net_id:H().optional(),voltage:Db}).describe("Defines a DC voltage source for simulation"),Xre=Ae({type:FA("simulation_voltage_source"),simulation_voltage_source_id:oi("simulation_voltage_source"),is_dc_source:FA(!1),terminal1_source_port_id:H().optional(),terminal2_source_port_id:H().optional(),terminal1_source_net_id:H().optional(),terminal2_source_net_id:H().optional(),voltage:Db.optional(),frequency:wG.optional(),peak_to_peak_voltage:Db.optional(),wave_shape:WdA.optional(),phase:bQ.optional(),duty_cycle:Cqt.optional()}).describe("Defines an AC voltage source for simulation"),$re=ii([zre,Xre]).describe("Defines a voltage source for simulation"),Qqt=ii([H(),zA()]).transform(t=>typeof t=="string"?t.endsWith("%")?parseFloat(t.slice(0,-1))/100:parseFloat(t):t).pipe(zA().min(0,"Duty cycle must be non-negative").max(1,"Duty cycle cannot be greater than 100%")),Aae=Ae({type:FA("simulation_current_source"),simulation_current_source_id:oi("simulation_current_source"),is_dc_source:FA(!0).optional().default(!0),positive_source_port_id:H().optional(),negative_source_port_id:H().optional(),positive_source_net_id:H().optional(),negative_source_net_id:H().optional(),current:WN}).describe("Defines a DC current source for simulation"),eae=Ae({type:FA("simulation_current_source"),simulation_current_source_id:oi("simulation_current_source"),is_dc_source:FA(!1),terminal1_source_port_id:H().optional(),terminal2_source_port_id:H().optional(),terminal1_source_net_id:H().optional(),terminal2_source_net_id:H().optional(),current:WN.optional(),frequency:wG.optional(),peak_to_peak_current:WN.optional(),wave_shape:WdA.optional(),phase:bQ.optional(),duty_cycle:Qqt.optional()}).describe("Defines an AC current source for simulation"),tae=ii([Aae,eae]).describe("Defines a current source for simulation"),iae=ii([FA("spice_dc_sweep"),FA("spice_dc_operating_point"),FA("spice_transient_analysis"),FA("spice_ac_analysis")]),nae=Ae({type:FA("simulation_experiment"),simulation_experiment_id:oi("simulation_experiment"),name:H(),experiment_type:iae,time_per_step:HY.optional(),start_time_ms:DG.optional(),end_time_ms:DG.optional()}).describe("Defines a simulation experiment configuration"),oae=Ae({type:FA("simulation_transient_voltage_graph"),simulation_transient_voltage_graph_id:oi("simulation_transient_voltage_graph"),simulation_experiment_id:H(),timestamps_ms:ve(zA()).optional(),voltage_levels:ve(zA()),source_component_id:H().optional(),subcircuit_connectivity_map_key:H().optional(),time_per_step:HY,start_time_ms:DG,end_time_ms:DG,name:H().optional(),color:H().optional()}).describe("Stores voltage measurements over time for a simulation"),sae=Ae({type:FA("simulation_switch"),simulation_switch_id:oi("simulation_switch"),source_component_id:H().optional(),closes_at:DG.optional(),opens_at:DG.optional(),starts_closed:ce().optional(),switching_frequency:wG.optional()}).describe("Defines a switch for simulation timing control"),rae=Ae({type:FA("simulation_voltage_probe"),simulation_voltage_probe_id:oi("simulation_voltage_probe"),source_component_id:H().optional(),name:H().optional(),signal_input_source_port_id:H().optional(),signal_input_source_net_id:H().optional(),reference_input_source_port_id:H().optional(),reference_input_source_net_id:H().optional(),subcircuit_id:H().optional(),color:H().optional()}).describe("Defines a voltage probe for simulation. If a reference input is not provided, it measures against ground. If a reference input is provided, it measures the differential voltage between two points.").superRefine((t,A)=>{if(t.reference_input_source_port_id||t.reference_input_source_net_id){const i=!!t.signal_input_source_port_id||!!t.reference_input_source_port_id,n=!!t.signal_input_source_net_id||!!t.reference_input_source_net_id;i&&n?A.addIssue({code:ri.custom,message:"Cannot mix port and net connections in a differential probe."}):i?(!t.signal_input_source_port_id||!t.reference_input_source_port_id)&&A.addIssue({code:ri.custom,message:"Differential port probe requires both signal_input_source_port_id and reference_input_source_port_id."}):n&&(!t.signal_input_source_net_id||!t.reference_input_source_net_id)&&A.addIssue({code:ri.custom,message:"Differential net probe requires both signal_input_source_net_id and reference_input_source_net_id."})}else!!t.signal_input_source_port_id==!!t.signal_input_source_net_id&&A.addIssue({code:ri.custom,message:"A voltage probe must have exactly one of signal_input_source_port_id or signal_input_source_net_id."})}),aae=ll.extend({type:FA("simulation_unknown_experiment_error"),simulation_unknown_experiment_error_id:oi("simulation_unknown_experiment_error"),error_type:FA("simulation_unknown_experiment_error").default("simulation_unknown_experiment_error"),simulation_experiment_id:H().optional(),subcircuit_id:H().optional()}).describe("An unknown error occurred during the simulation experiment."),gae=Ae({type:FA("simulation_op_amp"),simulation_op_amp_id:oi("simulation_op_amp"),source_component_id:H().optional(),inverting_input_source_port_id:H(),non_inverting_input_source_port_id:H(),output_source_port_id:H(),positive_supply_source_port_id:H(),negative_supply_source_port_id:H()}).describe("Defines a simple ideal operational amplifier for simulation"),cae=ii([Toe,Yoe,Joe,Hoe,Poe,Koe,SdA,mdA,y9,DdA,wdA,bdA,xdA,_dA,GdA,vdA,RdA,HdA,MdA,NdA,LdA,UdA,FdA,kdA,Ooe,Zoe,qoe,YdA,JdA,TdA,Voe,joe,KdA,_se,Nse,xre,_re,kre,vre,Lse,yre,Use,zse,Tse,Ose,Xse,Yse,Jse,$se,Are,Fre,ire,nre,ore,sre,Ire,rre,are,gre,cre,Wse,Zse,ere,tre,Vse,jse,qre,Bre,lre,Cre,Qre,hre,Ere,ure,dre,pre,Gre,fre,Rre,bre,Mre,Nre,Lre,Jre,Tre,Kre,Pre,Ore,Wre,Zre,Vre,zoe,cse,ose,sse,rse,ase,ise,nse,Ise,gse,Xoe,Bse,Cse,lse,use,dse,pse,fse,wse,yse,mse,jre,$re,tae,nae,oae,sae,rae,aae,gae]),ZdA=cae;const Iae=Object.freeze(Object.defineProperty({__proto__:null,all_layers:Woe,any_circuit_element:cae,any_soup_element:ZdA,any_source_component:Hoe,asset:hoe,base_circuit_json_error:ll,battery_capacity:Qoe,brep_shape:Sse,cad_component:jre,capacitance:pdA,circuit_json_footprint_load_error:kre,current:WN,distance:_t,duration_ms:HY,experiment_type:iae,external_footprint_load_error:_re,frequency:wG,getZodPrefixedIdWithDefault:oi,inductance:Boe,kicadAt:f9,kicadEffects:Eoe,kicadFont:ydA,kicadFootprintAttributes:doe,kicadFootprintMetadata:yoe,kicadFootprintModel:foe,kicadFootprintPad:poe,kicadFootprintProperties:uoe,kicadProperty:YY,kicadSymbolEffects:Doe,kicadSymbolMetadata:boe,kicadSymbolPinNames:woe,kicadSymbolPinNumbers:moe,kicadSymbolProperties:Soe,kicadSymbolProperty:X_,layer_ref:oa,layer_string:PdA,length:Qn,ms:DG,ninePointAnchor:z_,pcbRenderLayer:JPt,pcb_autorouting_error:Gre,pcb_board:$se,pcb_breakout_point:Rre,pcb_component:_se,pcb_component_invalid_layer_error:Pre,pcb_component_not_on_board_edge_error:Kre,pcb_component_outside_board_error:Tre,pcb_copper_pour:Jre,pcb_copper_pour_brep:Hre,pcb_copper_pour_polygon:Yre,pcb_copper_pour_rect:Ure,pcb_copper_text:rre,pcb_courtyard_circle:Vre,pcb_courtyard_outline:Wre,pcb_courtyard_polygon:Zre,pcb_courtyard_rect:Ore,pcb_cutout:bre,pcb_cutout_circle:wre,pcb_cutout_path:Sre,pcb_cutout_polygon:Dre,pcb_cutout_rect:mre,pcb_fabrication_note_dimension:Qre,pcb_fabrication_note_path:Bre,pcb_fabrication_note_rect:Cre,pcb_fabrication_note_text:lre,pcb_footprint_overlap_error:fre,pcb_ground_plane:Mre,pcb_ground_plane_region:Nre,pcb_group:Fre,pcb_hole:Nse,pcb_hole_circle_or_square_shape:ZPt,pcb_hole_circle_shape:OPt,pcb_hole_oval_shape:VPt,pcb_hole_pill_shape:jPt,pcb_hole_rect_shape:WPt,pcb_hole_rotated_pill_shape:zPt,pcb_keepout:yre,pcb_manual_edit_conflict_warning:vre,pcb_missing_footprint_error:xre,pcb_net:zse,pcb_note_dimension:pre,pcb_note_line:dre,pcb_note_path:ure,pcb_note_rect:Ere,pcb_note_text:hre,pcb_panel:Are,pcb_panelization_placement_error:tre,pcb_placement_error:ere,pcb_plated_hole:Lse,pcb_port:Use,pcb_port_not_connected_error:jse,pcb_port_not_matched_error:Vse,pcb_route_hint:bse,pcb_route_hints:qPt,pcb_silkscreen_circle:gre,pcb_silkscreen_line:nre,pcb_silkscreen_oval:cre,pcb_silkscreen_path:ore,pcb_silkscreen_pill:Ire,pcb_silkscreen_rect:are,pcb_silkscreen_text:sre,pcb_smtpad:Yse,pcb_smtpad_pill:Hse,pcb_solder_paste:Jse,pcb_text:Tse,pcb_thermal_spoke:Lre,pcb_trace:Ose,pcb_trace_error:Wse,pcb_trace_hint:ire,pcb_trace_missing_error:Zse,pcb_trace_route_point:qse,pcb_trace_route_point_via:Pse,pcb_trace_route_point_wire:Kse,pcb_via:Xse,pcb_via_clearance_error:qre,point:kn,point3:j_,point_with_bulge:Dse,port_arrangement:tse,position:UPt,position3:HPt,resistance:p9,ring:qdA,rotation:bQ,route_hint_point:xse,schematic_arc:ase,schematic_box:zoe,schematic_circle:rse,schematic_component:ise,schematic_component_port_arrangement_by_sides:ese,schematic_component_port_arrangement_by_size:Ase,schematic_debug_line:hse,schematic_debug_object:use,schematic_debug_object_base:m9,schematic_debug_point:Ese,schematic_debug_rect:Qse,schematic_error:Bse,schematic_group:fse,schematic_layout_error:Cse,schematic_line:ose,schematic_manual_edit_conflict_warning:pse,schematic_net_label:lse,schematic_path:Xoe,schematic_pin_styles:$oe,schematic_port:Ise,schematic_rect:sse,schematic_sheet:wse,schematic_symbol:nse,schematic_table:yse,schematic_table_cell:mse,schematic_text:cse,schematic_trace:gse,schematic_voltage_probe:dse,simulation_ac_current_source:eae,simulation_ac_voltage_source:Xre,simulation_current_source:tae,simulation_dc_current_source:Aae,simulation_dc_voltage_source:zre,simulation_experiment:nae,simulation_op_amp:gae,simulation_switch:sae,simulation_transient_voltage_graph:oae,simulation_unknown_experiment_error:aae,simulation_voltage_probe:rae,simulation_voltage_source:$re,size:fdA,source_board:qoe,source_component_base:_I,source_component_internal_connection:Joe,source_failed_to_create_component_error:Roe,source_group:Koe,source_i2c_misconfigured_error:KdA,source_interconnect:Loe,source_manually_placed_via:Zoe,source_missing_property_error:voe,source_net:Poe,source_pcb_ground_plane:Ooe,source_pin_missing_trace_warning:TdA,source_pin_must_be_connected_error:Voe,source_port:Yoe,source_project_metadata:YdA,source_property_ignored_warning:Moe,source_simple_battery:xdA,source_simple_capacitor:mdA,source_simple_chip:SdA,source_simple_crystal:Goe,source_simple_current_source:Foe,source_simple_diode:y9,source_simple_fiducial:_oe,source_simple_ground:koe,source_simple_inductor:_dA,source_simple_led:DdA,source_simple_mosfet:LdA,source_simple_op_amp:UdA,source_simple_pin_header:GdA,source_simple_pinout:vdA,source_simple_potentiometer:FdA,source_simple_power_source:bdA,source_simple_push_button:kdA,source_simple_resistor:wdA,source_simple_resonator:RdA,source_simple_switch:HdA,source_simple_test_point:NdA,source_simple_transistor:MdA,source_simple_voltage_probe:Noe,source_simple_voltage_source:Uoe,source_trace:Toe,source_trace_not_connected_error:JdA,supplier_name:xoe,time:LPt,timestamp:Coe,unknown_error_finding_part:joe,visible_layer:rm,voltage:Db,wave_shape:WdA},Symbol.toStringTag,{value:"Module"}));function gn(t,A){return Array.isArray(A)?[t.a*A[0]+t.c*A[1]+t.e,t.b*A[0]+t.d*A[1]+t.f]:{x:t.a*A.x+t.c*A.y+t.e,y:t.b*A.x+t.d*A.y+t.f}}function Sb(){return{a:1,c:0,e:0,b:0,d:1,f:0}}function bb(t){const{a:A,b:e,c:i,d:n,e:o,f:s}=t,r=A*n-e*i;return{a:n/r,b:e/-r,c:i/-r,d:A/r,e:(n*o-i*s)/-r,f:(e*o-A*s)/r}}function JY(t){return typeof t>"u"}function ZB(t,A=0){return{a:1,c:0,e:t,b:0,d:1,f:A}}function D9(...t){t=Array.isArray(t[0])?t[0]:t;const A=(e,i)=>({a:e.a*i.a+e.c*i.b,c:e.a*i.c+e.c*i.d,e:e.a*i.e+e.c*i.f+e.e,b:e.b*i.a+e.d*i.b,d:e.b*i.c+e.d*i.d,f:e.b*i.e+e.d*i.f+e.f});switch(t.length){case 0:throw new Error("no matrices provided");case 1:return t[0];case 2:return A(t[0],t[1]);default:{const[e,i,...n]=t,o=A(e,i);return D9(o,...n)}}}function am(...t){return D9(...t)}const{cos:hqt,sin:Eqt}=Math;function uqt(t,A,e){const i=hqt(t),n=Eqt(t),o={a:i,c:-n,e:0,b:n,d:i,f:0};return JY(A)||JY(e)?o:D9([ZB(A,e),o,ZB(-A,-e)])}function TY(t,A=void 0,e=void 0,i=void 0){JY(A)&&(A=t);const n={a:t,c:0,e:0,b:0,d:A,f:0};return JY(e)||JY(i)?n:D9([ZB(e,i),n,ZB(-e,-i)])}function dqt(t,A){function e(){this.constructor=t}e.prototype=A.prototype,t.prototype=new e}function S9(t,A,e,i){var n=Error.call(this,t);return Object.setPrototypeOf&&Object.setPrototypeOf(n,S9.prototype),n.expected=A,n.found=e,n.location=i,n.name="SyntaxError",n}dqt(S9,Error);function VdA(t,A,e){return e=e||" ",t.length>A?t:(A-=t.length,e+=e.repeat(A),t+e.slice(0,A))}S9.prototype.format=function(t){var A="Error: "+this.message;if(this.location){var e=null,i;for(i=0;i<t.length;i++)if(t[i].source===this.location.source){e=t[i].text.split(/\r\n|\n|\r/g);break}var n=this.location.start,o=this.location.source&&typeof this.location.source.offset=="function"?this.location.source.offset(n):n,s=this.location.source+":"+o.line+":"+o.column;if(e){var r=this.location.end,a=VdA("",o.line.toString().length," "),g=e[n.line-1],c=n.line===r.line?r.column:g.length+1,I=c-n.column||1;A+=`
@@ -5677,7 +5677,7 @@ test("${g} should solve problem correctly", () => {
5677
5677
  // Add more specific assertions based on expected output
5678
5678
  // expect(solver.netLabelPlacementSolver!.netLabelPlacements).toMatchInlineSnapshot()
5679
5679
  })
5680
- `,I=new Blob([c],{type:"text/plain"}),l=URL.createObjectURL(I),B=document.createElement("a");B.href=l,B.download=`${g}.test.ts`,B.click(),URL.revokeObjectURL(l)}catch(a){alert(`Error generating test.ts for ${t.constructor.name}: ${a instanceof Error?a.message:String(a)}`)}i(!1)};return Z.jsxs("div",{className:`relative ${A}`,ref:n,children:[Z.jsx("button",{className:"px-2 py-1 rounded text-xs cursor-pointer",onClick:()=>i(!e),title:`Download options for ${t.constructor.name}`,children:t.constructor.name}),e&&Z.jsxs("div",{className:"absolute top-full left-0 mt-1 bg-white border border-gray-300 rounded shadow-lg z-10 min-w-[150px]",children:[Z.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:o,children:"Download JSON"}),Z.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:s,children:"Download page.tsx"}),Z.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:r,children:"Download test.ts"})]})]})},tce=t=>t.activeSubSolver?[t,...tce(t.activeSubSolver)]:[t],eWt=({solver:t})=>{const A=tce(t);return Z.jsx("div",{className:"flex gap-1 items-center text-sm pt-1",children:A.map((e,i)=>Z.jsxs("div",{className:"flex items-center",children:[i>0&&Z.jsx("span",{className:"text-gray-400 mx-1",children:"→"}),Z.jsx(AWt,{solver:e})]},e.constructor.name))})},tWt=({solver:t,triggerRender:A,animationSpeed:e=25,onSolverStarted:i,onSolverCompleted:n})=>{const[o,s]=AA.useReducer(Q=>!Q,!1),r=AA.useRef(void 0),a=()=>{!t.solved&&!t.failed&&(t.step(),A())},g=()=>{!t.solved&&!t.failed&&(i&&i(t),t.solve(),A(),n&&n(t))},c=()=>{o?(r.current&&(clearInterval(r.current),r.current=void 0),s()):(s(),r.current=setInterval(()=>{if(t.solved||t.failed){r.current&&(clearInterval(r.current),r.current=void 0),s(),A(),n&&t.solved&&n(t);return}t.step(),A()},e))},I=()=>{const Q=t;if(Q.getCurrentPhase&&!t.solved&&!t.failed){const h=Q.getCurrentPhase();for(;Q.getCurrentPhase()===h&&!t.solved&&!t.failed;)t.step();A()}},l=()=>{if(t.solved||t.failed||o)return;const Q=window.prompt("Step until which iteration?",`${t.iterations}`);if(Q===null)return;const h=Number(Q);if(!Number.isFinite(h)){window.alert("Please enter a valid number for the iteration");return}for(;t.iterations<h&&!t.solved&&!t.failed;)t.step();A(),t.solved&&n&&n(t)};AA.useEffect(()=>()=>{r.current&&clearInterval(r.current)},[]),AA.useEffect(()=>{(t.solved||t.failed)&&o&&(r.current&&(clearInterval(r.current),r.current=void 0),s())},[t.solved,t.failed,o]);const B=t.getCurrentPhase!==void 0,C=B?t.getCurrentPhase():null;return Z.jsxs("div",{className:"space-y-2 p-2 border-b",children:[Z.jsx("div",{className:"flex items-center",children:Z.jsx(eWt,{solver:t})}),Z.jsxs("div",{className:"flex gap-2 items-center flex-wrap",children:[Z.jsx("button",{onClick:a,disabled:t.solved||t.failed||o,className:"bg-blue-500 hover:bg-blue-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Step"}),Z.jsx("button",{onClick:g,disabled:t.solved||t.failed||o,className:"bg-green-500 hover:bg-green-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Solve"}),Z.jsx("button",{onClick:c,disabled:t.solved||t.failed,className:`px-3 py-1 rounded text-white text-sm ${o?"bg-red-500 hover:bg-red-600":"bg-yellow-500 hover:bg-yellow-600"} disabled:bg-gray-300`,children:o?"Stop":"Animate"}),Z.jsx("button",{onClick:l,disabled:t.solved||t.failed||o,className:"bg-orange-500 hover:bg-orange-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Step Until Iteration"}),B&&Z.jsx("button",{onClick:I,disabled:t.solved||t.failed||o,className:"bg-purple-500 hover:bg-purple-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Next Stage"}),Z.jsxs("div",{className:"text-sm text-gray-600",children:["Iterations: ",t.iterations]}),t.timeToSolve!==void 0&&Z.jsxs("div",{className:"text-sm text-gray-600",children:["Time: ",(t.timeToSolve/1e3).toFixed(3),"s"]}),C&&Z.jsxs("div",{className:"text-sm text-gray-600",children:["Phase: ",Z.jsx("span",{className:"font-medium",children:C})]}),t.solved&&Z.jsx("div",{className:"px-2 py-1 bg-green-100 text-green-800 rounded text-sm",children:"Solved"}),t.failed&&Z.jsx("div",{className:"px-2 py-1 bg-red-100 text-red-800 rounded text-sm",children:"Failed"})]}),t.error&&Z.jsxs("div",{className:"text-red-600 text-sm",children:["Error: ",t.error]})]})},iWt=(t,A,e)=>{const i=t.currentPipelineStepIndex;return A<i?"Completed":A===i&&t.activeSubSolver?t.activeSubSolver.failed?"Failed":"In Progress":"Not Started"},nWt=(t,A)=>{const i=t.pipelineDef[A].solverName,n=iWt(t,A),o=t[i],s=t.firstIterationOfPhase?.[i]??null,r=t.iterations;let a=0;if(n==="Completed"){const l=t.pipelineDef[A+1],B=l?t.firstIterationOfPhase?.[l.solverName]:void 0;B!==void 0&&s!==null?a=B-s:s!==null&&(a=r-s)}else n==="In Progress"&&s!==null&&(a=r-s);const g=t.timeSpentOnPhase?.[i]??0;let c=0;n==="Completed"?c=1:n==="In Progress"&&o&&(c=o.progress??0);const I=o?.stats??null;return{index:A,name:i,status:n,firstIteration:s,iterations:a,progress:c,timeSpent:g,stats:I&&Object.keys(I).length>0?I:null,solverInstance:o??null}},oWt=({status:t})=>{const A={"Not Started":"text-blue-600","In Progress":"text-yellow-600",Completed:"text-green-600",Failed:"text-red-600"};return Z.jsx("span",{className:`font-medium ${A[t]}`,children:t})},sWt=({progress:t})=>{if(t===0)return null;const A=Math.round(t*100);return Z.jsxs("div",{className:"flex items-center gap-2",children:[Z.jsx("div",{className:"w-20 h-2 bg-gray-200 rounded overflow-hidden",children:Z.jsx("div",{className:"h-full bg-blue-500 transition-all duration-200",style:{width:`${A}%`}})}),Z.jsxs("span",{className:"text-xs text-gray-500",children:[A,"%"]})]})},rWt=t=>Object.entries(t).map(([A,e])=>`${A}: ${e}`).join(", "),aWt=({stats:t})=>{if(!t||Object.keys(t).length===0)return Z.jsx("span",{children:"-"});const A=Object.entries(t),e=rWt(t);return Z.jsxs("details",{className:"cursor-pointer",children:[Z.jsx("summary",{className:"whitespace-nowrap overflow-hidden text-ellipsis max-w-[200px]",children:e}),Z.jsx("div",{className:"mt-1 text-xs",children:A.map(([i,n])=>Z.jsxs("div",{children:[i,": ",String(n)]},i))})]})},UpA=t=>{if(t===null||typeof t!="object")return t;if(Array.isArray(t))return t.map(UpA);const A={};for(const[e,i]of Object.entries(t))e.startsWith("_")||(A[e]=UpA(i));return A},gWt=(t,A)=>{try{if(typeof t.getConstructorParams!="function"){alert(`getConstructorParams() is not implemented for ${A}`);return}const e=UpA(t.getConstructorParams()),i=new Blob([JSON.stringify(e,null,2)],{type:"application/json"}),n=URL.createObjectURL(i),o=document.createElement("a");o.href=n,o.download=`${A}_input.json`,o.click(),URL.revokeObjectURL(n)}catch(e){alert(`Error downloading input for ${A}: ${e instanceof Error?e.message:String(e)}`)}},cWt=({solver:t,onStepUntilPhase:A,onDownloadInput:e})=>{const i=t.pipelineDef.map((r,a)=>nWt(t,a)),n=r=>{A?.(r)},o=r=>{r.solverInstance&&(e?e(r.solverInstance,r.name):gWt(r.solverInstance,r.name))},s=r=>`${(r/1e3).toFixed(2)}s`;return Z.jsxs("div",{className:"border-t border-gray-200",children:[Z.jsx("div",{className:"px-4 py-2 bg-gray-50 border-b border-gray-200",children:Z.jsx("h3",{className:"text-sm font-semibold text-gray-700",children:"Pipeline Steps"})}),Z.jsx("div",{className:"overflow-x-auto",children:Z.jsxs("table",{className:"w-full text-sm",children:[Z.jsx("thead",{children:Z.jsxs("tr",{className:"bg-gray-50 border-b border-gray-200",children:[Z.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Step"}),Z.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Status"}),Z.jsxs("th",{className:"px-4 py-2 text-center font-semibold text-gray-700",children:["i",Z.jsx("sub",{children:"0"})]}),Z.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Iterations"}),Z.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Progress"}),Z.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Time"}),Z.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Stats"}),Z.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Input"})]})}),Z.jsx("tbody",{children:i.map(r=>Z.jsxs("tr",{className:`border-b border-gray-100 ${r.status==="In Progress"?"bg-yellow-50":""}`,children:[Z.jsx("td",{className:"px-4 py-2",children:Z.jsxs("div",{className:"flex items-center gap-2",children:[Z.jsx("span",{className:"text-gray-400 w-6",children:String(r.index+1).padStart(2,"0")}),Z.jsx("button",{onClick:()=>n(r.name),disabled:r.status==="Completed"||t.solved||t.failed,className:"text-blue-500 hover:text-blue-700 disabled:text-gray-300 disabled:cursor-not-allowed",title:`Step until ${r.name} completes`,children:Z.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:Z.jsx("path",{fillRule:"evenodd",d:"M4.5 5.653c0-1.426 1.529-2.33 2.779-1.643l11.54 6.348c1.295.712 1.295 2.573 0 3.285L7.28 19.991c-1.25.687-2.779-.217-2.779-1.643V5.653z",clipRule:"evenodd"})})}),Z.jsx("span",{className:"font-medium text-gray-900",children:r.name})]})}),Z.jsx("td",{className:"px-4 py-2",children:Z.jsx(oWt,{status:r.status})}),Z.jsx("td",{className:"px-4 py-2 text-center text-gray-600",children:r.firstIteration!==null?r.firstIteration:""}),Z.jsx("td",{className:"px-4 py-2 text-gray-600",children:r.iterations}),Z.jsx("td",{className:"px-4 py-2",children:Z.jsx(sWt,{progress:r.progress})}),Z.jsx("td",{className:"px-4 py-2 text-gray-600",children:s(r.timeSpent)}),Z.jsx("td",{className:"px-4 py-2 text-gray-500",children:Z.jsx(aWt,{stats:r.stats})}),Z.jsx("td",{className:"px-4 py-2",children:r.solverInstance?Z.jsxs("button",{onClick:()=>o(r),className:"flex items-center gap-1 text-blue-500 hover:text-blue-700",title:`Download input for ${r.name}`,children:[Z.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:Z.jsx("path",{fillRule:"evenodd",d:"M12 2.25a.75.75 0 01.75.75v11.69l3.22-3.22a.75.75 0 111.06 1.06l-4.5 4.5a.75.75 0 01-1.06 0l-4.5-4.5a.75.75 0 111.06-1.06l3.22 3.22V3a.75.75 0 01.75-.75zm-9 13.5a.75.75 0 01.75.75v2.25a1.5 1.5 0 001.5 1.5h13.5a1.5 1.5 0 001.5-1.5V16.5a.75.75 0 011.5 0v2.25a3 3 0 01-3 3H5.25a3 3 0 01-3-3V16.5a.75.75 0 01.75-.75z",clipRule:"evenodd"})}),Z.jsx("span",{children:"Input"})]}):null})]},r.name))})]})})]})},IWt=class extends yn.Component{constructor(t){super(t),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(t){console.error("InteractiveGraphics render error:",t)}render(){return this.state.hasError?this.props.fallback:this.props.children}};function lWt({graphics:t}){const A=t.points??[],e=t.lines??[],i=t.rects??[],n=t.circles??[],o=t.texts??[];let s=Number.POSITIVE_INFINITY,r=Number.POSITIVE_INFINITY,a=Number.NEGATIVE_INFINITY,g=Number.NEGATIVE_INFINITY;const c=(h,E)=>{typeof h=="number"&&(h<s&&(s=h),h>a&&(a=h)),typeof E=="number"&&(E<r&&(r=E),E>g&&(g=E))};for(const h of A)c(h.x,h.y);for(const h of e){const E=h.points??[];for(const u of E)c(u.x,u.y)}for(const h of i){const E=h.x??0,u=h.y??0,d=h.width??0,f=h.height??0;c(E,u),c(E+d,u+f)}for(const h of n){const E=h.x??0,u=h.y??0,d=h.radius??1;c(E-d,u-d),c(E+d,u+d)}for(const h of o)c(h.x,h.y);(!isFinite(s)||!isFinite(r)||!isFinite(a)||!isFinite(g))&&(s=-20,r=-20,a=20,g=20);const I=10,l=s-I,B=r-I,C=Math.max(1,a-s+2*I),Q=Math.max(1,g-r+2*I);return Z.jsxs("svg",{className:"w-full h-[400px] bg-white",viewBox:`${l} ${B} ${C} ${Q}`,role:"img","aria-label":"Graphics fallback",children:[i.map((h,E)=>Z.jsx("rect",{x:h.x??0,y:h.y??0,width:h.width??0,height:h.height??0,fill:"none",stroke:h.strokeColor??"black",strokeWidth:h.strokeWidth??1},`rect-${E}`)),e.map((h,E)=>Z.jsx("polyline",{fill:"none",stroke:h.strokeColor??"black",strokeWidth:h.strokeWidth??1,points:(h.points??[]).map(u=>`${u.x??0},${u.y??0}`).join(" ")},`line-${E}`)),n.map((h,E)=>Z.jsx("circle",{cx:h.x??0,cy:h.y??0,r:h.radius??1.5,fill:h.fillColor??"none",stroke:h.strokeColor??"black",strokeWidth:h.strokeWidth??1},`circle-${E}`)),A.map((h,E)=>Z.jsx("circle",{cx:h.x??0,cy:h.y??0,r:h.radius??1.5,fill:h.color??"black"},`point-${E}`)),o.map((h,E)=>Z.jsx("text",{x:h.x??0,y:h.y??0,fontSize:h.fontSize??10,fill:h.color??"black",children:h.text??""},`text-${E}`))]})}var BWt=({solver:t,animationSpeed:A=25,onSolverStarted:e,onSolverCompleted:i})=>{const[n,o]=AA.useReducer(c=>c+1,0),s=AA.useMemo(()=>{try{return t.visualize()||{points:[],lines:[],rects:[],circles:[]}}catch(c){return console.error("Visualization error:",c),{points:[],lines:[],rects:[],circles:[]}}},[t,n]),r=AA.useMemo(()=>(s.rects?.length||0)===0&&(s.lines?.length||0)===0&&(s.points?.length||0)===0&&(s.circles?.length||0)===0,[s]);AA.useEffect(()=>{if(!(typeof document>"u")&&!document.querySelector('script[src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4"]')){const c=document.createElement("script");c.src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4",document.head.appendChild(c)}},[]);const a=t.pipelineDef!==void 0,g=c=>{const I=t;if(!t.solved&&!t.failed){for(;!t.solved&&!t.failed&&I.currentPipelineStepIndex<=I.pipelineDef.findIndex(l=>l.solverName===c);)t.step();o()}};return Z.jsxs("div",{children:[Z.jsx(tWt,{solver:t,triggerRender:o,animationSpeed:A,onSolverStarted:e,onSolverCompleted:i}),r?Z.jsx("div",{className:"p-4 text-gray-500",children:"No Graphics Yet"}):Z.jsx(IWt,{fallback:Z.jsx(lWt,{graphics:s}),children:Z.jsx($8t,{graphics:s})}),a&&Z.jsx(cWt,{solver:t,onStepUntilPhase:g})]})};const CWt=()=>{AA.useEffect(()=>{const t="tailwind-cdn-script";if(document.getElementById(t)||window.tailwind)return;const A=document.createElement("div");A.className="hidden",document.body.appendChild(A);const e=window.getComputedStyle(A).display==="none";if(document.body.removeChild(A),e)return;const i=document.createElement("script");i.id=t,i.src="https://cdn.tailwindcss.com",document.head.appendChild(i)},[])},QWt=t=>t.toLowerCase().includes("pack")?wGt:t.toLowerCase().includes("rout")?kGt:QGt,hWt=({solverEvents:t=[]})=>{const[A,e]=AA.useState(null);CWt();const i=AA.useMemo(()=>{const r=new Map;for(const a of t){const g=`${a.componentName}-${a.solverName}`;r.set(g,a)}return r},[t]),n=AA.useMemo(()=>Array.from(i.keys()),[i]),o=A?i.get(A):null,s=AA.useMemo(()=>{if(!o)return{instance:null,error:null,classFound:!1};const r=$sA[o.solverName];if(!r)return{instance:null,error:`Solver class "${o.solverName}" not found in SOLVERS registry. Available: ${Object.keys($sA).join(", ")}`,classFound:!1};try{const a=o.solverParams,g=a?.input!==void 0?a.input:a;return{instance:new r(g),error:null,classFound:!0}}catch(a){const g=a instanceof Error?a.message:String(a);return console.error("Failed to reconstruct solver:",a),{instance:null,error:`Failed to instantiate solver: ${g}`,classFound:!0}}},[o]);return t.length===0?Z.jsx("div",{className:"rf-p-4",children:Z.jsx("div",{className:"rf-bg-gray-50 rf-rounded-md rf-border rf-border-gray-200",children:Z.jsxs("div",{className:"rf-p-4",children:[Z.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800 rf-mb-3",children:"No Solvers Detected"}),Z.jsx("p",{className:"rf-text-sm rf-text-gray-600",children:"Solvers will appear here when the circuit runs. Solvers are used for tasks like component packing and autorouting."})]})})}):Z.jsxs("div",{className:"rf-flex rf-h-full rf-overflow-hidden",children:[Z.jsxs("div",{className:"rf-w-64 rf-border-r rf-border-gray-200 rf-overflow-y-auto rf-flex-shrink-0",children:[Z.jsxs("div",{className:"rf-text-xs rf-font-semibold rf-text-gray-500 rf-px-3 rf-py-2 rf-bg-gray-50 rf-border-b rf-border-gray-200",children:[n.length," ",n.length===1?"Solver":"Solvers"]}),n.map(r=>{const a=i.get(r),g=A===r;return Z.jsx("div",{className:`rf-px-3 rf-py-2 rf-cursor-pointer rf-border-b rf-border-gray-100 ${g?"rf-bg-blue-50 rf-border-l-2 rf-border-l-blue-500":"hover:rf-bg-gray-50"}`,onClick:()=>e(r),children:(()=>{const c=QWt(a.solverName);return Z.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2",children:[Z.jsx(c,{className:"rf-w-4 rf-h-4 rf-text-blue-500 rf-flex-shrink-0"}),Z.jsxs("div",{className:"rf-flex-1 rf-min-w-0",children:[Z.jsx("div",{className:"rf-text-sm rf-font-medium rf-text-gray-800 rf-truncate",children:a.componentName}),Z.jsx("div",{className:"rf-text-xs rf-text-gray-500 rf-truncate",children:a.solverName})]})]})})()},r)})]}),Z.jsx("div",{className:"rf-flex-1 rf-overflow-hidden",children:o?s.instance?Z.jsx(SD,{fallback:Z.jsx("div",{className:"rf-p-4",children:Z.jsxs("div",{className:"rf-bg-red-50 rf-rounded-md rf-border rf-border-red-200 rf-p-4",children:[Z.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-red-800 rf-mb-2",children:"Error Loading Solver Debugger"}),Z.jsxs("p",{className:"rf-text-sm rf-text-red-600",children:["Failed to render the solver debugger for"," ",o.solverName]})]})}),children:Z.jsx(BWt,{solver:s.instance})}):Z.jsxs("div",{className:"rf-p-4",children:[Z.jsxs("div",{className:"rf-mb-4",children:[Z.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800",children:o.solverName}),Z.jsxs("p",{className:"rf-text-sm rf-text-gray-500",children:["Component: ",o.componentName]})]}),s.error&&Z.jsx("div",{className:`rf-rounded-md rf-border rf-p-4 rf-mb-4 ${s.classFound?"rf-bg-red-50 rf-border-red-200":"rf-bg-yellow-50 rf-border-yellow-200"}`,children:Z.jsx("p",{className:`rf-text-sm ${s.classFound?"rf-text-red-700":"rf-text-yellow-700"}`,children:s.error})}),Z.jsxs("div",{className:"rf-border rf-border-gray-200 rf-rounded-md rf-overflow-hidden",children:[Z.jsx("div",{className:"rf-px-3 rf-py-2 rf-bg-gray-50",children:Z.jsx("span",{className:"rf-text-sm rf-font-medium rf-text-gray-700",children:"Solver Parameters"})}),Z.jsx("div",{className:"rf-p-3 rf-bg-white rf-border-t rf-border-gray-200",children:Z.jsx("pre",{className:"rf-text-xs rf-font-mono rf-text-gray-600 rf-whitespace-pre-wrap rf-overflow-x-auto",children:JSON.stringify(o.solverParams,null,2)})})]})]}):Z.jsx("div",{className:"rf-flex rf-items-center rf-justify-center rf-h-full",children:Z.jsx("p",{className:"rf-text-sm rf-text-gray-500",children:"Select a solver from the list to view details"})})})]})},ice=({errorMessage:t,errorStack:A,circuitJsonErrors:e})=>{AA.useEffect(()=>{if(t){const i=new Error(t);A&&(i.stack=A);try{UK.captureException(i)}catch{}}},[t,A]),AA.useEffect(()=>{if(e&&e.length>0)for(const i of e){const n=new Error(i.message||"Circuit JSON Error");i.stack&&(n.stack=i.stack);try{UK.captureException(n,{error_type:i.type})}catch{}}},[e])},nce="0.0.1687",EWt={version:nce},HpA={BASE_URL:"/",DEV:!1,MODE:"production",PROD:!0,SSR:!1},YpA=new Map,sV=t=>{const A=YpA.get(t);return A?Object.fromEntries(Object.entries(A.stores).map(([e,i])=>[e,i.getState()])):{}},uWt=(t,A,e)=>{if(t===void 0)return{type:"untracked",connection:A.connect(e)};const i=YpA.get(e.name);if(i)return{type:"tracked",store:t,...i};const n={connection:A.connect(e),stores:{}};return YpA.set(e.name,n),{type:"tracked",store:t,...n}},oce=(t,A={})=>(e,i,n)=>{const{enabled:o,anonymousActionType:s,store:r,...a}=A;let g;try{g=(o??(HpA?"production":void 0)!=="production")&&window.__REDUX_DEVTOOLS_EXTENSION__}catch{}if(!g)return(HpA?"production":void 0)!=="production"&&o&&console.warn("[zustand devtools middleware] Please install/enable Redux devtools extension"),t(e,i,n);const{connection:c,...I}=uWt(r,g,a);let l=!0;n.setState=(Q,h,E)=>{const u=e(Q,h);if(!l)return u;const d=E===void 0?{type:s||"anonymous"}:typeof E=="string"?{type:E}:E;return r===void 0?(c?.send(d,i()),u):(c?.send({...d,type:`${r}/${d.type}`},{...sV(a.name),[r]:n.getState()}),u)};const B=(...Q)=>{const h=l;l=!1,e(...Q),l=h},C=t(n.setState,i,n);if(I.type==="untracked"?c?.init(C):(I.stores[I.store]=n,c?.init(Object.fromEntries(Object.entries(I.stores).map(([Q,h])=>[Q,Q===I.store?C:h.getState()])))),n.dispatchFromDevtools&&typeof n.dispatch=="function"){let Q=!1;const h=n.dispatch;n.dispatch=(...E)=>{(HpA?"production":void 0)!=="production"&&E[0].type==="__setState"&&!Q&&(console.warn('[zustand devtools middleware] "__setState" action type is reserved to set state from the devtools. Avoid using it.'),Q=!0),h(...E)}}return c.subscribe(Q=>{var h;switch(Q.type){case"ACTION":if(typeof Q.payload!="string"){console.error("[zustand devtools middleware] Unsupported action format");return}return JpA(Q.payload,E=>{if(E.type==="__setState"){if(r===void 0){B(E.state);return}Object.keys(E.state).length!==1&&console.error(`
5680
+ `,I=new Blob([c],{type:"text/plain"}),l=URL.createObjectURL(I),B=document.createElement("a");B.href=l,B.download=`${g}.test.ts`,B.click(),URL.revokeObjectURL(l)}catch(a){alert(`Error generating test.ts for ${t.constructor.name}: ${a instanceof Error?a.message:String(a)}`)}i(!1)};return Z.jsxs("div",{className:`relative ${A}`,ref:n,children:[Z.jsx("button",{className:"px-2 py-1 rounded text-xs cursor-pointer",onClick:()=>i(!e),title:`Download options for ${t.constructor.name}`,children:t.constructor.name}),e&&Z.jsxs("div",{className:"absolute top-full left-0 mt-1 bg-white border border-gray-300 rounded shadow-lg z-10 min-w-[150px]",children:[Z.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:o,children:"Download JSON"}),Z.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:s,children:"Download page.tsx"}),Z.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:r,children:"Download test.ts"})]})]})},tce=t=>t.activeSubSolver?[t,...tce(t.activeSubSolver)]:[t],eWt=({solver:t})=>{const A=tce(t);return Z.jsx("div",{className:"flex gap-1 items-center text-sm pt-1",children:A.map((e,i)=>Z.jsxs("div",{className:"flex items-center",children:[i>0&&Z.jsx("span",{className:"text-gray-400 mx-1",children:"→"}),Z.jsx(AWt,{solver:e})]},e.constructor.name))})},tWt=({solver:t,triggerRender:A,animationSpeed:e=25,onSolverStarted:i,onSolverCompleted:n})=>{const[o,s]=AA.useReducer(Q=>!Q,!1),r=AA.useRef(void 0),a=()=>{!t.solved&&!t.failed&&(t.step(),A())},g=()=>{!t.solved&&!t.failed&&(i&&i(t),t.solve(),A(),n&&n(t))},c=()=>{o?(r.current&&(clearInterval(r.current),r.current=void 0),s()):(s(),r.current=setInterval(()=>{if(t.solved||t.failed){r.current&&(clearInterval(r.current),r.current=void 0),s(),A(),n&&t.solved&&n(t);return}t.step(),A()},e))},I=()=>{const Q=t;if(Q.getCurrentPhase&&!t.solved&&!t.failed){const h=Q.getCurrentPhase();for(;Q.getCurrentPhase()===h&&!t.solved&&!t.failed;)t.step();A()}},l=()=>{if(t.solved||t.failed||o)return;const Q=window.prompt("Step until which iteration?",`${t.iterations}`);if(Q===null)return;const h=Number(Q);if(!Number.isFinite(h)){window.alert("Please enter a valid number for the iteration");return}for(;t.iterations<h&&!t.solved&&!t.failed;)t.step();A(),t.solved&&n&&n(t)};AA.useEffect(()=>()=>{r.current&&clearInterval(r.current)},[]),AA.useEffect(()=>{(t.solved||t.failed)&&o&&(r.current&&(clearInterval(r.current),r.current=void 0),s())},[t.solved,t.failed,o]);const B=t.getCurrentPhase!==void 0,C=B?t.getCurrentPhase():null;return Z.jsxs("div",{className:"space-y-2 p-2 border-b",children:[Z.jsx("div",{className:"flex items-center",children:Z.jsx(eWt,{solver:t})}),Z.jsxs("div",{className:"flex gap-2 items-center flex-wrap",children:[Z.jsx("button",{onClick:a,disabled:t.solved||t.failed||o,className:"bg-blue-500 hover:bg-blue-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Step"}),Z.jsx("button",{onClick:g,disabled:t.solved||t.failed||o,className:"bg-green-500 hover:bg-green-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Solve"}),Z.jsx("button",{onClick:c,disabled:t.solved||t.failed,className:`px-3 py-1 rounded text-white text-sm ${o?"bg-red-500 hover:bg-red-600":"bg-yellow-500 hover:bg-yellow-600"} disabled:bg-gray-300`,children:o?"Stop":"Animate"}),Z.jsx("button",{onClick:l,disabled:t.solved||t.failed||o,className:"bg-orange-500 hover:bg-orange-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Step Until Iteration"}),B&&Z.jsx("button",{onClick:I,disabled:t.solved||t.failed||o,className:"bg-purple-500 hover:bg-purple-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Next Stage"}),Z.jsxs("div",{className:"text-sm text-gray-600",children:["Iterations: ",t.iterations]}),t.timeToSolve!==void 0&&Z.jsxs("div",{className:"text-sm text-gray-600",children:["Time: ",(t.timeToSolve/1e3).toFixed(3),"s"]}),C&&Z.jsxs("div",{className:"text-sm text-gray-600",children:["Phase: ",Z.jsx("span",{className:"font-medium",children:C})]}),t.solved&&Z.jsx("div",{className:"px-2 py-1 bg-green-100 text-green-800 rounded text-sm",children:"Solved"}),t.failed&&Z.jsx("div",{className:"px-2 py-1 bg-red-100 text-red-800 rounded text-sm",children:"Failed"})]}),t.error&&Z.jsxs("div",{className:"text-red-600 text-sm",children:["Error: ",t.error]})]})},iWt=(t,A,e)=>{const i=t.currentPipelineStepIndex;return A<i?"Completed":A===i&&t.activeSubSolver?t.activeSubSolver.failed?"Failed":"In Progress":"Not Started"},nWt=(t,A)=>{const i=t.pipelineDef[A].solverName,n=iWt(t,A),o=t[i],s=t.firstIterationOfPhase?.[i]??null,r=t.iterations;let a=0;if(n==="Completed"){const l=t.pipelineDef[A+1],B=l?t.firstIterationOfPhase?.[l.solverName]:void 0;B!==void 0&&s!==null?a=B-s:s!==null&&(a=r-s)}else n==="In Progress"&&s!==null&&(a=r-s);const g=t.timeSpentOnPhase?.[i]??0;let c=0;n==="Completed"?c=1:n==="In Progress"&&o&&(c=o.progress??0);const I=o?.stats??null;return{index:A,name:i,status:n,firstIteration:s,iterations:a,progress:c,timeSpent:g,stats:I&&Object.keys(I).length>0?I:null,solverInstance:o??null}},oWt=({status:t})=>{const A={"Not Started":"text-blue-600","In Progress":"text-yellow-600",Completed:"text-green-600",Failed:"text-red-600"};return Z.jsx("span",{className:`font-medium ${A[t]}`,children:t})},sWt=({progress:t})=>{if(t===0)return null;const A=Math.round(t*100);return Z.jsxs("div",{className:"flex items-center gap-2",children:[Z.jsx("div",{className:"w-20 h-2 bg-gray-200 rounded overflow-hidden",children:Z.jsx("div",{className:"h-full bg-blue-500 transition-all duration-200",style:{width:`${A}%`}})}),Z.jsxs("span",{className:"text-xs text-gray-500",children:[A,"%"]})]})},rWt=t=>Object.entries(t).map(([A,e])=>`${A}: ${e}`).join(", "),aWt=({stats:t})=>{if(!t||Object.keys(t).length===0)return Z.jsx("span",{children:"-"});const A=Object.entries(t),e=rWt(t);return Z.jsxs("details",{className:"cursor-pointer",children:[Z.jsx("summary",{className:"whitespace-nowrap overflow-hidden text-ellipsis max-w-[200px]",children:e}),Z.jsx("div",{className:"mt-1 text-xs",children:A.map(([i,n])=>Z.jsxs("div",{children:[i,": ",String(n)]},i))})]})},UpA=t=>{if(t===null||typeof t!="object")return t;if(Array.isArray(t))return t.map(UpA);const A={};for(const[e,i]of Object.entries(t))e.startsWith("_")||(A[e]=UpA(i));return A},gWt=(t,A)=>{try{if(typeof t.getConstructorParams!="function"){alert(`getConstructorParams() is not implemented for ${A}`);return}const e=UpA(t.getConstructorParams()),i=new Blob([JSON.stringify(e,null,2)],{type:"application/json"}),n=URL.createObjectURL(i),o=document.createElement("a");o.href=n,o.download=`${A}_input.json`,o.click(),URL.revokeObjectURL(n)}catch(e){alert(`Error downloading input for ${A}: ${e instanceof Error?e.message:String(e)}`)}},cWt=({solver:t,onStepUntilPhase:A,onDownloadInput:e})=>{const i=t.pipelineDef.map((r,a)=>nWt(t,a)),n=r=>{A?.(r)},o=r=>{r.solverInstance&&(e?e(r.solverInstance,r.name):gWt(r.solverInstance,r.name))},s=r=>`${(r/1e3).toFixed(2)}s`;return Z.jsxs("div",{className:"border-t border-gray-200",children:[Z.jsx("div",{className:"px-4 py-2 bg-gray-50 border-b border-gray-200",children:Z.jsx("h3",{className:"text-sm font-semibold text-gray-700",children:"Pipeline Steps"})}),Z.jsx("div",{className:"overflow-x-auto",children:Z.jsxs("table",{className:"w-full text-sm",children:[Z.jsx("thead",{children:Z.jsxs("tr",{className:"bg-gray-50 border-b border-gray-200",children:[Z.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Step"}),Z.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Status"}),Z.jsxs("th",{className:"px-4 py-2 text-center font-semibold text-gray-700",children:["i",Z.jsx("sub",{children:"0"})]}),Z.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Iterations"}),Z.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Progress"}),Z.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Time"}),Z.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Stats"}),Z.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Input"})]})}),Z.jsx("tbody",{children:i.map(r=>Z.jsxs("tr",{className:`border-b border-gray-100 ${r.status==="In Progress"?"bg-yellow-50":""}`,children:[Z.jsx("td",{className:"px-4 py-2",children:Z.jsxs("div",{className:"flex items-center gap-2",children:[Z.jsx("span",{className:"text-gray-400 w-6",children:String(r.index+1).padStart(2,"0")}),Z.jsx("button",{onClick:()=>n(r.name),disabled:r.status==="Completed"||t.solved||t.failed,className:"text-blue-500 hover:text-blue-700 disabled:text-gray-300 disabled:cursor-not-allowed",title:`Step until ${r.name} completes`,children:Z.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:Z.jsx("path",{fillRule:"evenodd",d:"M4.5 5.653c0-1.426 1.529-2.33 2.779-1.643l11.54 6.348c1.295.712 1.295 2.573 0 3.285L7.28 19.991c-1.25.687-2.779-.217-2.779-1.643V5.653z",clipRule:"evenodd"})})}),Z.jsx("span",{className:"font-medium text-gray-900",children:r.name})]})}),Z.jsx("td",{className:"px-4 py-2",children:Z.jsx(oWt,{status:r.status})}),Z.jsx("td",{className:"px-4 py-2 text-center text-gray-600",children:r.firstIteration!==null?r.firstIteration:""}),Z.jsx("td",{className:"px-4 py-2 text-gray-600",children:r.iterations}),Z.jsx("td",{className:"px-4 py-2",children:Z.jsx(sWt,{progress:r.progress})}),Z.jsx("td",{className:"px-4 py-2 text-gray-600",children:s(r.timeSpent)}),Z.jsx("td",{className:"px-4 py-2 text-gray-500",children:Z.jsx(aWt,{stats:r.stats})}),Z.jsx("td",{className:"px-4 py-2",children:r.solverInstance?Z.jsxs("button",{onClick:()=>o(r),className:"flex items-center gap-1 text-blue-500 hover:text-blue-700",title:`Download input for ${r.name}`,children:[Z.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:Z.jsx("path",{fillRule:"evenodd",d:"M12 2.25a.75.75 0 01.75.75v11.69l3.22-3.22a.75.75 0 111.06 1.06l-4.5 4.5a.75.75 0 01-1.06 0l-4.5-4.5a.75.75 0 111.06-1.06l3.22 3.22V3a.75.75 0 01.75-.75zm-9 13.5a.75.75 0 01.75.75v2.25a1.5 1.5 0 001.5 1.5h13.5a1.5 1.5 0 001.5-1.5V16.5a.75.75 0 011.5 0v2.25a3 3 0 01-3 3H5.25a3 3 0 01-3-3V16.5a.75.75 0 01.75-.75z",clipRule:"evenodd"})}),Z.jsx("span",{children:"Input"})]}):null})]},r.name))})]})})]})},IWt=class extends yn.Component{constructor(t){super(t),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(t){console.error("InteractiveGraphics render error:",t)}render(){return this.state.hasError?this.props.fallback:this.props.children}};function lWt({graphics:t}){const A=t.points??[],e=t.lines??[],i=t.rects??[],n=t.circles??[],o=t.texts??[];let s=Number.POSITIVE_INFINITY,r=Number.POSITIVE_INFINITY,a=Number.NEGATIVE_INFINITY,g=Number.NEGATIVE_INFINITY;const c=(h,E)=>{typeof h=="number"&&(h<s&&(s=h),h>a&&(a=h)),typeof E=="number"&&(E<r&&(r=E),E>g&&(g=E))};for(const h of A)c(h.x,h.y);for(const h of e){const E=h.points??[];for(const u of E)c(u.x,u.y)}for(const h of i){const E=h.x??0,u=h.y??0,d=h.width??0,f=h.height??0;c(E,u),c(E+d,u+f)}for(const h of n){const E=h.x??0,u=h.y??0,d=h.radius??1;c(E-d,u-d),c(E+d,u+d)}for(const h of o)c(h.x,h.y);(!isFinite(s)||!isFinite(r)||!isFinite(a)||!isFinite(g))&&(s=-20,r=-20,a=20,g=20);const I=10,l=s-I,B=r-I,C=Math.max(1,a-s+2*I),Q=Math.max(1,g-r+2*I);return Z.jsxs("svg",{className:"w-full h-[400px] bg-white",viewBox:`${l} ${B} ${C} ${Q}`,role:"img","aria-label":"Graphics fallback",children:[i.map((h,E)=>Z.jsx("rect",{x:h.x??0,y:h.y??0,width:h.width??0,height:h.height??0,fill:"none",stroke:h.strokeColor??"black",strokeWidth:h.strokeWidth??1},`rect-${E}`)),e.map((h,E)=>Z.jsx("polyline",{fill:"none",stroke:h.strokeColor??"black",strokeWidth:h.strokeWidth??1,points:(h.points??[]).map(u=>`${u.x??0},${u.y??0}`).join(" ")},`line-${E}`)),n.map((h,E)=>Z.jsx("circle",{cx:h.x??0,cy:h.y??0,r:h.radius??1.5,fill:h.fillColor??"none",stroke:h.strokeColor??"black",strokeWidth:h.strokeWidth??1},`circle-${E}`)),A.map((h,E)=>Z.jsx("circle",{cx:h.x??0,cy:h.y??0,r:h.radius??1.5,fill:h.color??"black"},`point-${E}`)),o.map((h,E)=>Z.jsx("text",{x:h.x??0,y:h.y??0,fontSize:h.fontSize??10,fill:h.color??"black",children:h.text??""},`text-${E}`))]})}var BWt=({solver:t,animationSpeed:A=25,onSolverStarted:e,onSolverCompleted:i})=>{const[n,o]=AA.useReducer(c=>c+1,0),s=AA.useMemo(()=>{try{return t.visualize()||{points:[],lines:[],rects:[],circles:[]}}catch(c){return console.error("Visualization error:",c),{points:[],lines:[],rects:[],circles:[]}}},[t,n]),r=AA.useMemo(()=>(s.rects?.length||0)===0&&(s.lines?.length||0)===0&&(s.points?.length||0)===0&&(s.circles?.length||0)===0,[s]);AA.useEffect(()=>{if(!(typeof document>"u")&&!document.querySelector('script[src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4"]')){const c=document.createElement("script");c.src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4",document.head.appendChild(c)}},[]);const a=t.pipelineDef!==void 0,g=c=>{const I=t;if(!t.solved&&!t.failed){for(;!t.solved&&!t.failed&&I.currentPipelineStepIndex<=I.pipelineDef.findIndex(l=>l.solverName===c);)t.step();o()}};return Z.jsxs("div",{children:[Z.jsx(tWt,{solver:t,triggerRender:o,animationSpeed:A,onSolverStarted:e,onSolverCompleted:i}),r?Z.jsx("div",{className:"p-4 text-gray-500",children:"No Graphics Yet"}):Z.jsx(IWt,{fallback:Z.jsx(lWt,{graphics:s}),children:Z.jsx($8t,{graphics:s})}),a&&Z.jsx(cWt,{solver:t,onStepUntilPhase:g})]})};const CWt=()=>{AA.useEffect(()=>{const t="tailwind-cdn-script";if(document.getElementById(t)||window.tailwind)return;const A=document.createElement("div");A.className="hidden",document.body.appendChild(A);const e=window.getComputedStyle(A).display==="none";if(document.body.removeChild(A),e)return;const i=document.createElement("script");i.id=t,i.src="https://cdn.tailwindcss.com",document.head.appendChild(i)},[])},QWt=t=>t.toLowerCase().includes("pack")?wGt:t.toLowerCase().includes("rout")?kGt:QGt,hWt=({solverEvents:t=[]})=>{const[A,e]=AA.useState(null);CWt();const i=AA.useMemo(()=>{const r=new Map;for(const a of t){const g=`${a.componentName}-${a.solverName}`;r.set(g,a)}return r},[t]),n=AA.useMemo(()=>Array.from(i.keys()),[i]),o=A?i.get(A):null,s=AA.useMemo(()=>{if(!o)return{instance:null,error:null,classFound:!1};const r=$sA[o.solverName];if(!r)return{instance:null,error:`Solver class "${o.solverName}" not found in SOLVERS registry. Available: ${Object.keys($sA).join(", ")}`,classFound:!1};try{const a=o.solverParams,g=a?.input!==void 0?a.input:a;return{instance:new r(g),error:null,classFound:!0}}catch(a){const g=a instanceof Error?a.message:String(a);return console.error("Failed to reconstruct solver:",a),{instance:null,error:`Failed to instantiate solver: ${g}`,classFound:!0}}},[o]);return t.length===0?Z.jsx("div",{className:"rf-p-4",children:Z.jsx("div",{className:"rf-bg-gray-50 rf-rounded-md rf-border rf-border-gray-200",children:Z.jsxs("div",{className:"rf-p-4",children:[Z.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800 rf-mb-3",children:"No Solvers Detected"}),Z.jsx("p",{className:"rf-text-sm rf-text-gray-600",children:"Solvers will appear here when the circuit runs. Solvers are used for tasks like component packing and autorouting."})]})})}):Z.jsxs("div",{className:"rf-flex rf-h-full rf-overflow-hidden",children:[Z.jsxs("div",{className:"rf-w-64 rf-border-r rf-border-gray-200 rf-overflow-y-auto rf-flex-shrink-0",children:[Z.jsxs("div",{className:"rf-text-xs rf-font-semibold rf-text-gray-500 rf-px-3 rf-py-2 rf-bg-gray-50 rf-border-b rf-border-gray-200",children:[n.length," ",n.length===1?"Solver":"Solvers"]}),n.map(r=>{const a=i.get(r),g=A===r;return Z.jsx("div",{className:`rf-px-3 rf-py-2 rf-cursor-pointer rf-border-b rf-border-gray-100 ${g?"rf-bg-blue-50 rf-border-l-2 rf-border-l-blue-500":"hover:rf-bg-gray-50"}`,onClick:()=>e(r),children:(()=>{const c=QWt(a.solverName);return Z.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2",children:[Z.jsx(c,{className:"rf-w-4 rf-h-4 rf-text-blue-500 rf-flex-shrink-0"}),Z.jsxs("div",{className:"rf-flex-1 rf-min-w-0",children:[Z.jsx("div",{className:"rf-text-sm rf-font-medium rf-text-gray-800 rf-truncate",children:a.componentName}),Z.jsx("div",{className:"rf-text-xs rf-text-gray-500 rf-truncate",children:a.solverName})]})]})})()},r)})]}),Z.jsx("div",{className:"rf-flex-1 rf-overflow-hidden",children:o?s.instance?Z.jsx(SD,{fallback:Z.jsx("div",{className:"rf-p-4",children:Z.jsxs("div",{className:"rf-bg-red-50 rf-rounded-md rf-border rf-border-red-200 rf-p-4",children:[Z.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-red-800 rf-mb-2",children:"Error Loading Solver Debugger"}),Z.jsxs("p",{className:"rf-text-sm rf-text-red-600",children:["Failed to render the solver debugger for"," ",o.solverName]})]})}),children:Z.jsx(BWt,{solver:s.instance})}):Z.jsxs("div",{className:"rf-p-4",children:[Z.jsxs("div",{className:"rf-mb-4",children:[Z.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800",children:o.solverName}),Z.jsxs("p",{className:"rf-text-sm rf-text-gray-500",children:["Component: ",o.componentName]})]}),s.error&&Z.jsx("div",{className:`rf-rounded-md rf-border rf-p-4 rf-mb-4 ${s.classFound?"rf-bg-red-50 rf-border-red-200":"rf-bg-yellow-50 rf-border-yellow-200"}`,children:Z.jsx("p",{className:`rf-text-sm ${s.classFound?"rf-text-red-700":"rf-text-yellow-700"}`,children:s.error})}),Z.jsxs("div",{className:"rf-border rf-border-gray-200 rf-rounded-md rf-overflow-hidden",children:[Z.jsx("div",{className:"rf-px-3 rf-py-2 rf-bg-gray-50",children:Z.jsx("span",{className:"rf-text-sm rf-font-medium rf-text-gray-700",children:"Solver Parameters"})}),Z.jsx("div",{className:"rf-p-3 rf-bg-white rf-border-t rf-border-gray-200",children:Z.jsx("pre",{className:"rf-text-xs rf-font-mono rf-text-gray-600 rf-whitespace-pre-wrap rf-overflow-x-auto",children:JSON.stringify(o.solverParams,null,2)})})]})]}):Z.jsx("div",{className:"rf-flex rf-items-center rf-justify-center rf-h-full",children:Z.jsx("p",{className:"rf-text-sm rf-text-gray-500",children:"Select a solver from the list to view details"})})})]})},ice=({errorMessage:t,errorStack:A,circuitJsonErrors:e})=>{AA.useEffect(()=>{if(t){const i=new Error(t);A&&(i.stack=A);try{UK.captureException(i)}catch{}}},[t,A]),AA.useEffect(()=>{if(e&&e.length>0)for(const i of e){const n=new Error(i.message||"Circuit JSON Error");i.stack&&(n.stack=i.stack);try{UK.captureException(n,{error_type:i.type})}catch{}}},[e])},nce="0.0.1688",EWt={version:nce},HpA={BASE_URL:"/",DEV:!1,MODE:"production",PROD:!0,SSR:!1},YpA=new Map,sV=t=>{const A=YpA.get(t);return A?Object.fromEntries(Object.entries(A.stores).map(([e,i])=>[e,i.getState()])):{}},uWt=(t,A,e)=>{if(t===void 0)return{type:"untracked",connection:A.connect(e)};const i=YpA.get(e.name);if(i)return{type:"tracked",store:t,...i};const n={connection:A.connect(e),stores:{}};return YpA.set(e.name,n),{type:"tracked",store:t,...n}},oce=(t,A={})=>(e,i,n)=>{const{enabled:o,anonymousActionType:s,store:r,...a}=A;let g;try{g=(o??(HpA?"production":void 0)!=="production")&&window.__REDUX_DEVTOOLS_EXTENSION__}catch{}if(!g)return(HpA?"production":void 0)!=="production"&&o&&console.warn("[zustand devtools middleware] Please install/enable Redux devtools extension"),t(e,i,n);const{connection:c,...I}=uWt(r,g,a);let l=!0;n.setState=(Q,h,E)=>{const u=e(Q,h);if(!l)return u;const d=E===void 0?{type:s||"anonymous"}:typeof E=="string"?{type:E}:E;return r===void 0?(c?.send(d,i()),u):(c?.send({...d,type:`${r}/${d.type}`},{...sV(a.name),[r]:n.getState()}),u)};const B=(...Q)=>{const h=l;l=!1,e(...Q),l=h},C=t(n.setState,i,n);if(I.type==="untracked"?c?.init(C):(I.stores[I.store]=n,c?.init(Object.fromEntries(Object.entries(I.stores).map(([Q,h])=>[Q,Q===I.store?C:h.getState()])))),n.dispatchFromDevtools&&typeof n.dispatch=="function"){let Q=!1;const h=n.dispatch;n.dispatch=(...E)=>{(HpA?"production":void 0)!=="production"&&E[0].type==="__setState"&&!Q&&(console.warn('[zustand devtools middleware] "__setState" action type is reserved to set state from the devtools. Avoid using it.'),Q=!0),h(...E)}}return c.subscribe(Q=>{var h;switch(Q.type){case"ACTION":if(typeof Q.payload!="string"){console.error("[zustand devtools middleware] Unsupported action format");return}return JpA(Q.payload,E=>{if(E.type==="__setState"){if(r===void 0){B(E.state);return}Object.keys(E.state).length!==1&&console.error(`
5681
5681
  [zustand devtools middleware] Unsupported __setState action format.
5682
5682
  When using 'store' option in devtools(), the 'state' should have only one key, which is a value of 'store' that was passed in devtools(),
5683
5683
  and value of this only key should be a state object. Example: { "type": "__setState", "state": { "abc123Store": { "foo": "bar" } } }
@@ -5371,7 +5371,7 @@ svg { font-family: 'Inter', 'Helvetica Neue', Arial, sans-serif; }
5371
5371
  50% { opacity: 0.2; }
5372
5372
  100% { opacity: 0.6; }
5373
5373
  }
5374
- `,n.appendChild(u)}})}};o();const s=new MutationObserver(o);return s.observe(n,{childList:!0,subtree:!1,characterData:!1}),()=>{s.disconnect()}},[t,e,A,i])},Jse=["#8B0000","#2F4F4F","#191970","#006400","#FF4500","#800080","#2E8B57","#B8860B","#C71585","#008B8B"],r3t=t=>{const{svgDivRef:A,circuitJson:e,circuitJsonKey:i,showGroups:n}=t;V.useEffect(()=>{if(A.current&&A.current.querySelectorAll(".schematic-group-overlay").forEach(r=>r.remove()),!A.current||!n||!e||e.length===0)return;const o=setTimeout(()=>{if(!A.current)return;const s=A.current.querySelector("svg");if(!s)return;s.querySelectorAll(".schematic-group-overlay").forEach(a=>a.remove());try{const a=$E(e).source_group?.list().filter(u=>!u.is_subcircuit)||[],g=$E(e).schematic_component?.list()||[],c=new Map;a.forEach(u=>{const d=u;if(d.parent_source_group_id){const f=c.get(d.parent_source_group_id)||[];f.push(u.source_group_id),c.set(d.parent_source_group_id,f)}});const I=u=>{const d=[],f=c.get(u)||[];for(const m of f)d.push(m),d.push(...I(m));return d},l=u=>{const d=a.find(f=>f.source_group_id===u);return d?.parent_source_group_id?1+l(d.parent_source_group_id):0},B=a.length>0&&a.some(u=>u.name&&u.name.trim()!=="");let C=[];if(B){const u=new Map;for(const d of g){const f=$E(e).source_component.get(d.source_component_id);f?.source_group_id&&(u.has(f.source_group_id)||u.set(f.source_group_id,[]),u.get(f.source_group_id).push(d))}a.forEach((d,f)=>{let m=u.get(d.source_group_id)||[];const w=I(d.source_group_id);for(const D of w){const b=u.get(D)||[];m=[...m,...b]}if(m.length>0){const D=l(d.source_group_id),b=I(d.source_group_id).length>0;if(d.name?.startsWith("unnamed_board"))return;C.push({id:d.source_group_id,name:d.name||`Group ${f+1}`,components:m,color:Jse[f%Jse.length],depthLevel:D,hasChildren:b,sourceGroupId:d.source_group_id})}})}const Q=s.viewBox.baseVal,h=s.getBoundingClientRect(),E=Math.min(h.width/Q.width,h.height/Q.height)||1;C.sort((u,d)=>u.depthLevel-d.depthLevel),C.forEach(u=>{if(u.components.length===0)return;const d=a3t(u.components,s);if(!d)return;const f=Math.max(8,Math.min(25,15/Math.max(E,.3))),m=u.hasChildren?f*.6:0,w=f+m,D=Math.max(1,2/Math.max(E,.5)),b=u.depthLevel===0?D:D*.7,k=Math.max(4,8/Math.max(E,.5)),x=u.hasChildren?1.3:1,N=k*x,R=N*.5,L=document.createElementNS("http://www.w3.org/2000/svg","rect");L.setAttribute("class","schematic-group-overlay"),L.setAttribute("x",(d.minX-w).toString()),L.setAttribute("y",(d.minY-w).toString()),L.setAttribute("width",(d.maxX-d.minX+w*2).toString()),L.setAttribute("height",(d.maxY-d.minY+w*2).toString()),L.setAttribute("fill","none"),L.setAttribute("stroke",u.color),L.setAttribute("stroke-width",b.toString()),L.setAttribute("stroke-dasharray",`${N},${R}`),L.setAttribute("opacity","0.8"),L.setAttribute("rx","0"),L.setAttribute("ry","0");const Y=Math.max(6,Math.min(20,14/Math.max(E,.2))),J=u.depthLevel===0||u.depthLevel===1?0:u.depthLevel*.2,O=Y*(1-J),Z=Math.max(1,O*.2),X=u.name,iA=document.createElementNS("http://www.w3.org/2000/svg","text");iA.setAttribute("font-size",O.toString()),iA.setAttribute("font-family","Arial, sans-serif"),iA.textContent=X,s.appendChild(iA);const gA=iA.getBBox();s.removeChild(iA);const tA=gA.width+Z*2,eA=O+Z*2,sA=d.minX-w,lA=d.minY-w-eA,pA=document.createElementNS("http://www.w3.org/2000/svg","rect");pA.setAttribute("class","schematic-group-overlay"),pA.setAttribute("x",sA.toString()),pA.setAttribute("y",(lA-eA).toString()),pA.setAttribute("width",tA.toString()),pA.setAttribute("height",eA.toString()),pA.setAttribute("fill","transparent"),pA.setAttribute("rx","0"),pA.setAttribute("ry","0");const MA=document.createElementNS("http://www.w3.org/2000/svg","text");MA.setAttribute("class","schematic-group-overlay"),MA.setAttribute("x",(sA+Z).toString()),MA.setAttribute("y",(lA+eA-Z).toString()),MA.setAttribute("fill",u.color),MA.setAttribute("font-size",O.toString()),MA.setAttribute("font-family","Arial, sans-serif"),MA.setAttribute("font-weight",u.depthLevel===0?"600":"500"),MA.setAttribute("stroke",u.color),MA.setAttribute("stroke-width",Math.max(.2,O*.02).toString()),MA.textContent=X,s.appendChild(L),s.appendChild(pA),s.appendChild(MA)})}catch(a){console.error("Error creating group overlays:",a)}},10);return()=>clearTimeout(o)},[A,i,n])};function a3t(t,A){let e=1/0,i=1/0,n=-1/0,o=-1/0;for(const r of t){let a=A.querySelector(`g[data-schematic-component-id="${r.schematic_component_id}"]`);if(a||(a=A.querySelector(`[data-schematic-component-id="${r.schematic_component_id}"]`)),a){const g=a.getBBox();e=Math.min(e,g.x),i=Math.min(i,g.y),n=Math.max(n,g.x+g.width),o=Math.max(o,g.y+g.height)}}return e===1/0?null:{minX:e,minY:i,maxX:n,maxY:o}}var g3t=Va("schematic-viewer"),c3t=()=>{Va.enable("schematic-viewer*")},I3t=g3t,Tse=t=>{const[A,e]=V.useState(0),[i,n]=V.useState(0);return V.useEffect(()=>{if(!t.current)return;const o=()=>{const r=t.current?.getBoundingClientRect();e(r?.width||0),n(r?.height||0)};o();const s=new ResizeObserver(o);return s.observe(t.current),window.addEventListener("resize",o),()=>{s.disconnect(),window.removeEventListener("resize",o)}},[]),{containerWidth:A,containerHeight:i}},l3t=I3t.extend("useComponentDragging"),B3t=({onEditEvent:t,editEvents:A=[],circuitJson:e,cancelDrag:i,svgToScreenProjection:n,realToSvgProjection:o,enabled:s=!1,snapToGrid:r=!1})=>{const[a,g]=V.useState(null),c=tl(o,n),I=V.useRef(null),l=V.useRef(null),B=V.useRef(new Map);V.useEffect(()=>{A.forEach(D=>{"edit_event_type"in D&&D.edit_event_type==="edit_schematic_component_location"&&!D.in_progress&&B.current.set(D.schematic_component_id,{...D.new_center})})},[A]);const C=V.useCallback((D,b,k)=>{if(!s)return!1;const x=k.closest('[data-circuit-json-type="schematic_component"]');if(!x)return!1;const N=x.getAttribute("data-schematic-component-id");if(!N)return!1;i&&i();const R=$E(e).schematic_component.get(N);if(!R)return!1;I.current={x:D,y:b};let L;const Y=B.current.get(N);if(Y)L={...Y};else{const O=Yse({editEvents:A,schematic_component_id:N});L={x:R.center.x+O.x,y:R.center.y+O.y},B.current.set(N,{...L})}const J={edit_event_id:Math.random().toString(36).substr(2,9),edit_event_type:"edit_schematic_component_location",schematic_component_id:N,original_center:L,new_center:{...L},in_progress:!0,created_at:Date.now(),_element:x};return l.current=J,g(J),!0},[i,s,e,A]),Q=V.useCallback(D=>{C(D.clientX,D.clientY,D.target)},[C]),h=V.useCallback(D=>{if(D.touches.length!==1)return;const b=D.touches[0];C(b.clientX,b.clientY,D.target)&&D.preventDefault()},[C]),E=V.useCallback((D,b)=>{if(!l.current||!I.current)return;const k={x:D-I.current.x,y:b-I.current.y},x={x:k.x/c.a,y:k.y/c.d};let N={x:l.current.original_center.x+x.x,y:l.current.original_center.y+x.y};if(r){const L=Y=>Math.round(Y*10)/10;N={x:L(N.x),y:L(N.y)}}const R={...l.current,new_center:N};l.current=R,g(R)},[c,r]),u=V.useCallback(D=>E(D.clientX,D.clientY),[E]),d=V.useCallback(D=>{if(D.touches.length!==1||!l.current)return;D.preventDefault();const b=D.touches[0];E(b.clientX,b.clientY)},[E]),f=V.useCallback(()=>{if(!l.current)return;const D={...l.current,in_progress:!1};B.current.set(D.schematic_component_id,{...D.new_center}),l3t("endDrag calling onEditEvent with new edit event",{newEditEvent:D}),t&&t(D),l.current=null,I.current=null,g(null)},[t]),m=V.useCallback(()=>f(),[f]),w=V.useCallback(()=>f(),[f]);return V.useEffect(()=>(window.addEventListener("mousemove",u),window.addEventListener("mouseup",m),window.addEventListener("touchmove",d,{passive:!1}),window.addEventListener("touchend",w),()=>{window.removeEventListener("mousemove",u),window.removeEventListener("mouseup",m),window.removeEventListener("touchmove",d),window.removeEventListener("touchend",w)}),[u,m,d,w]),{handleMouseDown:Q,handleTouchStart:h,isDragging:!!l.current,activeEditEvent:a}},ZD={schematicEditIcon:50,schematicGridIcon:49,spiceSimulationIcon:50,viewMenuIcon:48,viewMenu:55,viewMenuBackdrop:54,clickToInteractOverlay:100,schematicComponentHoverOutline:47,schematicPortHoverOutline:48},C3t=({onClick:t,active:A})=>{const e=i=>{i.preventDefault(),t()};return W.jsx("div",{onClick:e,onTouchEnd:e,title:A?"Disable edit mode":"Enable edit mode",style:{position:"absolute",top:"16px",right:"64px",backgroundColor:A?"#4CAF50":"#fff",color:A?"#fff":"#000",padding:"8px",borderRadius:"4px",cursor:"pointer",boxShadow:"0 2px 4px rgba(0,0,0,0.1)",display:"flex",alignItems:"center",gap:"4px",zIndex:ZD.schematicEditIcon},children:W.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[W.jsx("path",{d:"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"}),W.jsx("path",{d:"M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"})]})})},Q3t=({onClick:t,active:A})=>{const e=i=>{i.preventDefault(),t()};return W.jsx("div",{onClick:e,onTouchEnd:e,title:A?"Hide grid":"Show grid",style:{position:"absolute",top:"56px",right:"64px",backgroundColor:A?"#4CAF50":"#fff",color:A?"#fff":"#000",padding:"8px",borderRadius:"4px",cursor:"pointer",boxShadow:"0 2px 4px rgba(0,0,0,0.1)",display:"flex",alignItems:"center",gap:"4px",zIndex:ZD.schematicGridIcon},children:W.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:W.jsx("path",{d:"M3 3h7v7H3zM14 3h7v7h-7zM3 14h7v7H3zM14 14h7v7h-7z"})})})},h3t=({onClick:t,active:A})=>{const e=i=>{i.preventDefault(),t()};return W.jsx("div",{onClick:e,onTouchEnd:e,title:A?"Hide view menu":"Show view menu",style:{position:"absolute",top:"16px",right:"16px",backgroundColor:A?"#4CAF50":"#fff",color:A?"#fff":"#000",padding:"8px",borderRadius:"4px",cursor:"pointer",boxShadow:"0 2px 4px rgba(0,0,0,0.1)",display:"flex",alignItems:"center",gap:"4px",zIndex:ZD.viewMenuIcon},children:W.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[W.jsx("circle",{cx:"12",cy:"12",r:"1"}),W.jsx("circle",{cx:"12",cy:"5",r:"1"}),W.jsx("circle",{cx:"12",cy:"19",r:"1"})]})})},E3t={version:"2.0.56"},u3t=({circuitJson:t,circuitJsonKey:A,isVisible:e,onClose:i,showGroups:n,onToggleGroups:o,showGrid:s,onToggleGrid:r})=>{const a=V.useMemo(()=>{if(!t||t.length===0)return!1;try{if(($E(t).source_group?.list()||[]).length>0)return!0;const c=$E(t).schematic_component?.list()||[];if(c.length>1){const I=new Set;for(const l of c){const B=$E(t).source_component.get(l.source_component_id);B?.ftype&&I.add(B.ftype)}return I.size>1}return!1}catch(g){return console.error("Error checking for groups:",g),!1}},[A]);return e?W.jsxs(W.Fragment,{children:[W.jsx("div",{onClick:i,onTouchEnd:g=>{g.preventDefault(),i()},style:{position:"absolute",inset:0,backgroundColor:"transparent",zIndex:ZD.viewMenuBackdrop}}),W.jsxs("div",{style:{position:"absolute",top:"56px",right:"16px",backgroundColor:"#ffffff",color:"#000000",border:"1px solid #ccc",borderRadius:"4px",boxShadow:"0 4px 12px rgba(0,0,0,0.1)",minWidth:"200px",zIndex:ZD.viewMenu},children:[W.jsxs("div",{onClick:()=>{a&&o(!n)},onTouchEnd:g=>{g.preventDefault(),a&&o(!n)},style:{padding:"8px 12px",cursor:a?"pointer":"not-allowed",opacity:a?1:.5,fontSize:"13px",color:"#000000",fontFamily:"sans-serif",display:"flex",alignItems:"center",gap:"8px"},onMouseEnter:g=>{a&&(g.currentTarget.style.backgroundColor="#f0f0f0")},onMouseLeave:g=>{a&&(g.currentTarget.style.backgroundColor="transparent")},children:[W.jsx("div",{style:{width:"16px",height:"16px",border:"2px solid #000",borderRadius:"2px",backgroundColor:"transparent",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"10px",fontWeight:"bold"},children:n&&"✓"}),"View Schematic Groups"]}),!a&&W.jsx("div",{style:{padding:"8px 12px",fontSize:"11px",color:"#666",fontStyle:"italic"},children:"No groups found in this schematic"}),W.jsxs("div",{onClick:()=>r(!s),onTouchEnd:g=>{g.preventDefault(),r(!s)},style:{padding:"8px 12px",cursor:"pointer",fontSize:"13px",color:"#000000",fontFamily:"sans-serif",display:"flex",alignItems:"center",gap:"8px"},onMouseEnter:g=>{g.currentTarget.style.backgroundColor="#f0f0f0"},onMouseLeave:g=>{g.currentTarget.style.backgroundColor="transparent"},children:[W.jsx("div",{style:{width:"16px",height:"16px",border:"2px solid #000",borderRadius:"2px",backgroundColor:"transparent",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"10px",fontWeight:"bold"},children:s&&"✓"}),"Show Grid"]}),W.jsxs("div",{style:{padding:"4px 8px",fontSize:"12px",color:"#999",borderTop:"1px solid #eee",textAlign:"center"},children:["v",String(E3t?.version)]})]})]}):null},d3t=()=>W.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:W.jsx("path",{d:"M3 12h2.5l2.5-9 4 18 4-9h5.5"})}),p3t=({onClick:t})=>W.jsx("div",{onClick:t,title:"Run SPICE simulation",style:{position:"absolute",top:"16px",right:"112px",backgroundColor:"#fff",color:"#000",padding:"8px",borderRadius:"4px",cursor:"pointer",boxShadow:"0 2px 4px rgba(0,0,0,0.1)",display:"flex",alignItems:"center",gap:"4px",zIndex:ZD.spiceSimulationIcon},children:W.jsx(d3t,{})});AV.register(O4t,V4t,S4t,D4t,R4t,T4t,v4t);var nV=["#8884d8","#82ca9d","#ffc658","#ff7300","#387908"],Kse=t=>{if(t===0)return"0s";const A=Math.abs(t);let e="s",i=1;return A<1e-12?(e="fs",i=1e15):A<1e-9?(e="ps",i=1e12):A<1e-6?(e="ns",i=1e9):A<.001?(e="us",i=1e6):A<1&&(e="ms",i=1e3),`${parseFloat((t*i).toPrecision(3))}${e}`},f3t=({plotData:t,nodes:A,isLoading:e,error:i,hasRun:n})=>{const o=V.useMemo(()=>{const a=A.some(c=>c.toLowerCase().startsWith("v(")),g=A.some(c=>c.toLowerCase().startsWith("i("));return a&&g?"Value":a?"Voltage (V)":g?"Current (A)":"Value"},[A]);if(e)return W.jsx("div",{style:{height:"300px",width:"100%",display:"flex",alignItems:"center",justifyContent:"center"},children:"Running simulation..."});if(!n)return W.jsx("div",{style:{height:"300px",width:"100%",display:"flex",alignItems:"center",justifyContent:"center"},children:'Click "Run" to start the simulation.'});if(i)return W.jsxs("div",{style:{height:"300px",width:"100%",display:"flex",alignItems:"center",justifyContent:"center",color:"red"},children:["Error: ",i]});if(t.length===0)return W.jsx("div",{style:{height:"300px",width:"100%",display:"flex",alignItems:"center",justifyContent:"center"},children:"No data to plot. Check simulation output or SPICE netlist."});const s={datasets:A.map((a,g)=>({label:a,data:t.map(c=>({x:Number(c.name),y:c[a]})),borderColor:nV[g%nV.length],backgroundColor:nV[g%nV.length],fill:!1,tension:.1}))},r={responsive:!0,maintainAspectRatio:!1,plugins:{legend:{position:"top",labels:{font:{family:"sans-serif"}}},title:{display:!1},tooltip:{callbacks:{title:a=>{if(a.length>0){const g=a[0];return Kse(g.parsed.x)}return""}}}},scales:{x:{type:"linear",title:{display:!0,text:"Time",font:{family:"sans-serif"}},ticks:{callback:a=>Kse(a),font:{family:"sans-serif"}}},y:{title:{display:!0,text:o,font:{family:"sans-serif"}},ticks:{font:{family:"sans-serif"}}}}};return W.jsx("div",{style:{position:"relative",height:"300px",width:"100%"},children:W.jsx(n3t,{options:r,data:s})})},y3t=({spiceString:t,onClose:A,plotData:e,nodes:i,isLoading:n,error:o,simOptions:s,onSimOptionsChange:r,hasRun:a})=>{const[g,c]=V.useState(String(s.startTime)),[I,l]=V.useState(String(s.duration));V.useEffect(()=>{c(String(s.startTime)),l(String(s.duration))},[s.startTime,s.duration]);const B=()=>{r({...s,startTime:Number(g),duration:Number(I)})},C=i.filter(Q=>{const h=Q.toLowerCase().startsWith("v("),E=Q.toLowerCase().startsWith("i(");return!!(s.showVoltage&&h||s.showCurrent&&E)});return W.jsx("div",{style:{position:"fixed",top:0,left:0,right:0,bottom:0,backgroundColor:"rgba(0, 0, 0, 0.5)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1002,fontFamily:"sans-serif"},children:W.jsxs("div",{style:{backgroundColor:"white",padding:"24px",borderRadius:"12px",width:"90%",maxWidth:"900px",boxShadow:"0 4px 20px rgba(0, 0, 0, 0.15)"},children:[W.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"24px",borderBottom:"1px solid #eee",paddingBottom:"16px"},children:[W.jsx("h2",{style:{margin:0,fontSize:"22px",fontWeight:600,color:"#333"},children:"SPICE Simulation"}),W.jsx("button",{onClick:A,style:{background:"none",border:"none",fontSize:"28px",cursor:"pointer",color:"#888",padding:0,lineHeight:1},children:"×"})]}),W.jsx("div",{children:W.jsx(f3t,{plotData:e,nodes:C,isLoading:n,error:o,hasRun:a})}),W.jsxs("div",{style:{marginTop:"16px",padding:"12px",backgroundColor:"#f7f7f7",borderRadius:"6px",display:"flex",flexWrap:"wrap",gap:"24px",alignItems:"center",fontSize:"14px"},children:[W.jsxs("div",{style:{display:"flex",gap:"16px"},children:[W.jsxs("label",{style:{display:"flex",alignItems:"center",gap:"6px"},children:[W.jsx("input",{type:"checkbox",checked:s.showVoltage,onChange:Q=>r({...s,showVoltage:Q.target.checked})}),"Voltage"]}),W.jsxs("label",{style:{display:"flex",alignItems:"center",gap:"6px"},children:[W.jsx("input",{type:"checkbox",checked:s.showCurrent,onChange:Q=>r({...s,showCurrent:Q.target.checked})}),"Current"]})]}),W.jsxs("div",{style:{display:"flex",gap:"16px",alignItems:"center"},children:[W.jsx("label",{htmlFor:"startTime",children:"Start Time (ms):"}),W.jsx("input",{id:"startTime",type:"number",value:g,onChange:Q=>c(Q.target.value),style:{width:"80px",padding:"4px 8px",borderRadius:"4px",border:"1px solid #ccc"}}),W.jsx("label",{htmlFor:"duration",children:"Duration (ms):"}),W.jsx("input",{id:"duration",type:"number",value:I,onChange:Q=>l(Q.target.value),style:{width:"80px",padding:"4px 8px",borderRadius:"4px",border:"1px solid #ccc"}}),W.jsx("button",{onClick:B,style:{padding:"4px 12px",borderRadius:"4px",border:"1px solid #ccc",backgroundColor:"#f0f0f0",cursor:"pointer"},children:a?"Rerun":"Run"})]})]}),W.jsxs("div",{style:{marginTop:"24px"},children:[W.jsx("h3",{style:{marginTop:0,marginBottom:"12px",fontSize:"18px",fontWeight:600,color:"#333"},children:"SPICE Netlist"}),W.jsx("pre",{style:{backgroundColor:"#fafafa",padding:"16px",borderRadius:"6px",maxHeight:"150px",overflowY:"auto",border:"1px solid #eee",color:"#333",fontSize:"13px",fontFamily:"monospace"},children:t})]})]})})},m3t="dmFyIGU9bnVsbCxzPWFzeW5jKCk9Pihhd2FpdCBpbXBvcnQoImh0dHBzOi8vY2RuLmpzZGVsaXZyLm5ldC9ucG0vZWVjaXJjdWl0LWVuZ2luZUAxLjUuMi8rZXNtIikpLlNpbXVsYXRpb24sYz1hc3luYygpPT57aWYoZSYmZS5pc0luaXRpYWxpemVkKCkpcmV0dXJuO2xldCBpPWF3YWl0IHMoKTtlPW5ldyBpLGF3YWl0IGUuc3RhcnQoKX07c2VsZi5vbm1lc3NhZ2U9YXN5bmMgaT0+e3RyeXtpZihhd2FpdCBjKCksIWUpdGhyb3cgbmV3IEVycm9yKCJTaW11bGF0aW9uIG5vdCBpbml0aWFsaXplZCIpO2xldCB0PWkuZGF0YS5zcGljZVN0cmluZyxhPXQubWF0Y2goL3dyZGF0YVxzKyhcUyspXHMrKC4qKS9pKTtpZihhKXtsZXQgbz1gLnByb2JlICR7YVsyXS50cmltKCkuc3BsaXQoL1xzKy8pLmpvaW4oIiAiKX1gO3Q9dC5yZXBsYWNlKC93cmRhdGEuKi9pLG8pfWVsc2UgaWYoIXQubWF0Y2goL1wucHJvYmUvaSkpdGhyb3cgdC5tYXRjaCgvcGxvdFxzKyguKikvaSk/bmV3IEVycm9yKCJUaGUgJ3Bsb3QnIGNvbW1hbmQgaXMgbm90IHN1cHBvcnRlZCBmb3IgZGF0YSBleHRyYWN0aW9uLiBQbGVhc2UgdXNlICd3cmRhdGEgPGZpbGVuYW1lPiA8dmFyMT4gLi4uJyBvciAnLnByb2JlIDx2YXIxPiAuLi4nIGluc3RlYWQuIik6bmV3IEVycm9yKCJObyAnLnByb2JlJyBvciAnd3JkYXRhJyBjb21tYW5kIGZvdW5kIGluIFNQSUNFIGZpbGUuIFVzZSAnd3JkYXRhIDxmaWxlbmFtZT4gPHZhcjE+IC4uLicgdG8gc3BlY2lmeSBvdXRwdXQuIik7ZS5zZXROZXRMaXN0KHQpO2xldCBuPWF3YWl0IGUucnVuU2ltKCk7c2VsZi5wb3N0TWVzc2FnZSh7dHlwZToicmVzdWx0IixyZXN1bHQ6bn0pfWNhdGNoKHQpe3NlbGYucG9zdE1lc3NhZ2Uoe3R5cGU6ImVycm9yIixlcnJvcjp0Lm1lc3NhZ2V9KX19Owo=",oV=null,w3t=()=>{if(typeof window>"u")return null;if(oV)return oV;try{const t=new Blob([atob(m3t)],{type:"application/javascript"});return oV=URL.createObjectURL(t),oV}catch(t){return console.error("Failed to create blob URL for worker",t),null}},D3t=t=>{const A={};if(t.dataType==="real")t.data.forEach(r=>{A[r.name]=r.values});else if(t.dataType==="complex")t.data.forEach(r=>{A[r.name]=r.values.map(a=>a.real)});else throw new Error("Unsupported data type in simulation result");const e=Object.keys(A).find(r=>r.toLowerCase()==="time"||r.toLowerCase()==="frequency");if(!e)throw new Error("No time or frequency data in simulation result");const i=A[e],n=Object.keys(A).filter(r=>r!==e),o=n;return{plotData:i.map((r,a)=>{const g={name:r.toExponential(2)};return n.forEach(c=>{g[c]=A[c][a]}),g}),nodes:o}},S3t=t=>{const[A,e]=V.useState([]),[i,n]=V.useState([]),[o,s]=V.useState(!0),[r,a]=V.useState(null);return V.useEffect(()=>{if(!t){s(!1),e([]),n([]),a(null);return}s(!0),a(null),e([]),n([]);const g=w3t();if(!g){a("Could not create SPICE simulation worker."),s(!1);return}const c=new Worker(g,{type:"module"});return c.onmessage=I=>{if(I.data.type==="result")try{const{plotData:l,nodes:B}=D3t(I.data.result);e(l),n(B)}catch(l){a(l.message||"Failed to parse simulation result"),console.error(l)}else I.data.type==="error"&&a(I.data.error);s(!1)},c.onerror=I=>{a(I.message),s(!1)},c.postMessage({spiceString:t}),()=>{c.terminate()}},[t]),{plotData:A,nodes:i,isLoading:o,error:r}},SpA=t=>{if(t===0)return"0";const A=Math.abs(t),e=i=>i.toPrecision(4);return A>=1?e(t):A>=.001?`${e(t*1e3)}m`:A>=1e-6?`${e(t*1e6)}u`:A>=1e-9?`${e(t*1e9)}n`:A>=1e-12?`${e(t*1e12)}p`:A>=1e-15?`${e(t*1e15)}f`:t.toExponential(3)},b3t=(t,A)=>{const i=aHA(t).toSpiceString(),o=i.split(`
5374
+ `,n.appendChild(u)}})}};o();const s=new MutationObserver(o);return s.observe(n,{childList:!0,subtree:!1,characterData:!1}),()=>{s.disconnect()}},[t,e,A,i])},Jse=["#8B0000","#2F4F4F","#191970","#006400","#FF4500","#800080","#2E8B57","#B8860B","#C71585","#008B8B"],r3t=t=>{const{svgDivRef:A,circuitJson:e,circuitJsonKey:i,showGroups:n}=t;V.useEffect(()=>{if(A.current&&A.current.querySelectorAll(".schematic-group-overlay").forEach(r=>r.remove()),!A.current||!n||!e||e.length===0)return;const o=setTimeout(()=>{if(!A.current)return;const s=A.current.querySelector("svg");if(!s)return;s.querySelectorAll(".schematic-group-overlay").forEach(a=>a.remove());try{const a=$E(e).source_group?.list().filter(u=>!u.is_subcircuit)||[],g=$E(e).schematic_component?.list()||[],c=new Map;a.forEach(u=>{const d=u;if(d.parent_source_group_id){const f=c.get(d.parent_source_group_id)||[];f.push(u.source_group_id),c.set(d.parent_source_group_id,f)}});const I=u=>{const d=[],f=c.get(u)||[];for(const m of f)d.push(m),d.push(...I(m));return d},l=u=>{const d=a.find(f=>f.source_group_id===u);return d?.parent_source_group_id?1+l(d.parent_source_group_id):0},B=a.length>0&&a.some(u=>u.name&&u.name.trim()!=="");let C=[];if(B){const u=new Map;for(const d of g){const f=$E(e).source_component.get(d.source_component_id);f?.source_group_id&&(u.has(f.source_group_id)||u.set(f.source_group_id,[]),u.get(f.source_group_id).push(d))}a.forEach((d,f)=>{let m=u.get(d.source_group_id)||[];const w=I(d.source_group_id);for(const D of w){const b=u.get(D)||[];m=[...m,...b]}if(m.length>0){const D=l(d.source_group_id),b=I(d.source_group_id).length>0;if(d.name?.startsWith("unnamed_board"))return;C.push({id:d.source_group_id,name:d.name||`Group ${f+1}`,components:m,color:Jse[f%Jse.length],depthLevel:D,hasChildren:b,sourceGroupId:d.source_group_id})}})}const Q=s.viewBox.baseVal,h=s.getBoundingClientRect(),E=Math.min(h.width/Q.width,h.height/Q.height)||1;C.sort((u,d)=>u.depthLevel-d.depthLevel),C.forEach(u=>{if(u.components.length===0)return;const d=a3t(u.components,s);if(!d)return;const f=Math.max(8,Math.min(25,15/Math.max(E,.3))),m=u.hasChildren?f*.6:0,w=f+m,D=Math.max(1,2/Math.max(E,.5)),b=u.depthLevel===0?D:D*.7,k=Math.max(4,8/Math.max(E,.5)),x=u.hasChildren?1.3:1,N=k*x,R=N*.5,L=document.createElementNS("http://www.w3.org/2000/svg","rect");L.setAttribute("class","schematic-group-overlay"),L.setAttribute("x",(d.minX-w).toString()),L.setAttribute("y",(d.minY-w).toString()),L.setAttribute("width",(d.maxX-d.minX+w*2).toString()),L.setAttribute("height",(d.maxY-d.minY+w*2).toString()),L.setAttribute("fill","none"),L.setAttribute("stroke",u.color),L.setAttribute("stroke-width",b.toString()),L.setAttribute("stroke-dasharray",`${N},${R}`),L.setAttribute("opacity","0.8"),L.setAttribute("rx","0"),L.setAttribute("ry","0");const Y=Math.max(6,Math.min(20,14/Math.max(E,.2))),J=u.depthLevel===0||u.depthLevel===1?0:u.depthLevel*.2,O=Y*(1-J),Z=Math.max(1,O*.2),X=u.name,iA=document.createElementNS("http://www.w3.org/2000/svg","text");iA.setAttribute("font-size",O.toString()),iA.setAttribute("font-family","Arial, sans-serif"),iA.textContent=X,s.appendChild(iA);const gA=iA.getBBox();s.removeChild(iA);const tA=gA.width+Z*2,eA=O+Z*2,sA=d.minX-w,lA=d.minY-w-eA,pA=document.createElementNS("http://www.w3.org/2000/svg","rect");pA.setAttribute("class","schematic-group-overlay"),pA.setAttribute("x",sA.toString()),pA.setAttribute("y",(lA-eA).toString()),pA.setAttribute("width",tA.toString()),pA.setAttribute("height",eA.toString()),pA.setAttribute("fill","transparent"),pA.setAttribute("rx","0"),pA.setAttribute("ry","0");const MA=document.createElementNS("http://www.w3.org/2000/svg","text");MA.setAttribute("class","schematic-group-overlay"),MA.setAttribute("x",(sA+Z).toString()),MA.setAttribute("y",(lA+eA-Z).toString()),MA.setAttribute("fill",u.color),MA.setAttribute("font-size",O.toString()),MA.setAttribute("font-family","Arial, sans-serif"),MA.setAttribute("font-weight",u.depthLevel===0?"600":"500"),MA.setAttribute("stroke",u.color),MA.setAttribute("stroke-width",Math.max(.2,O*.02).toString()),MA.textContent=X,s.appendChild(L),s.appendChild(pA),s.appendChild(MA)})}catch(a){console.error("Error creating group overlays:",a)}},10);return()=>clearTimeout(o)},[A,i,n])};function a3t(t,A){let e=1/0,i=1/0,n=-1/0,o=-1/0;for(const r of t){let a=A.querySelector(`g[data-schematic-component-id="${r.schematic_component_id}"]`);if(a||(a=A.querySelector(`[data-schematic-component-id="${r.schematic_component_id}"]`)),a){const g=a.getBBox();e=Math.min(e,g.x),i=Math.min(i,g.y),n=Math.max(n,g.x+g.width),o=Math.max(o,g.y+g.height)}}return e===1/0?null:{minX:e,minY:i,maxX:n,maxY:o}}var g3t=Va("schematic-viewer"),c3t=()=>{Va.enable("schematic-viewer*")},I3t=g3t,Tse=t=>{const[A,e]=V.useState(0),[i,n]=V.useState(0);return V.useEffect(()=>{if(!t.current)return;const o=()=>{const r=t.current?.getBoundingClientRect();e(r?.width||0),n(r?.height||0)};o();const s=new ResizeObserver(o);return s.observe(t.current),window.addEventListener("resize",o),()=>{s.disconnect(),window.removeEventListener("resize",o)}},[]),{containerWidth:A,containerHeight:i}},l3t=I3t.extend("useComponentDragging"),B3t=({onEditEvent:t,editEvents:A=[],circuitJson:e,cancelDrag:i,svgToScreenProjection:n,realToSvgProjection:o,enabled:s=!1,snapToGrid:r=!1})=>{const[a,g]=V.useState(null),c=tl(o,n),I=V.useRef(null),l=V.useRef(null),B=V.useRef(new Map);V.useEffect(()=>{A.forEach(D=>{"edit_event_type"in D&&D.edit_event_type==="edit_schematic_component_location"&&!D.in_progress&&B.current.set(D.schematic_component_id,{...D.new_center})})},[A]);const C=V.useCallback((D,b,k)=>{if(!s)return!1;const x=k.closest('[data-circuit-json-type="schematic_component"]');if(!x)return!1;const N=x.getAttribute("data-schematic-component-id");if(!N)return!1;i&&i();const R=$E(e).schematic_component.get(N);if(!R)return!1;I.current={x:D,y:b};let L;const Y=B.current.get(N);if(Y)L={...Y};else{const O=Yse({editEvents:A,schematic_component_id:N});L={x:R.center.x+O.x,y:R.center.y+O.y},B.current.set(N,{...L})}const J={edit_event_id:Math.random().toString(36).substr(2,9),edit_event_type:"edit_schematic_component_location",schematic_component_id:N,original_center:L,new_center:{...L},in_progress:!0,created_at:Date.now(),_element:x};return l.current=J,g(J),!0},[i,s,e,A]),Q=V.useCallback(D=>{C(D.clientX,D.clientY,D.target)},[C]),h=V.useCallback(D=>{if(D.touches.length!==1)return;const b=D.touches[0];C(b.clientX,b.clientY,D.target)&&D.preventDefault()},[C]),E=V.useCallback((D,b)=>{if(!l.current||!I.current)return;const k={x:D-I.current.x,y:b-I.current.y},x={x:k.x/c.a,y:k.y/c.d};let N={x:l.current.original_center.x+x.x,y:l.current.original_center.y+x.y};if(r){const L=Y=>Math.round(Y*10)/10;N={x:L(N.x),y:L(N.y)}}const R={...l.current,new_center:N};l.current=R,g(R)},[c,r]),u=V.useCallback(D=>E(D.clientX,D.clientY),[E]),d=V.useCallback(D=>{if(D.touches.length!==1||!l.current)return;D.preventDefault();const b=D.touches[0];E(b.clientX,b.clientY)},[E]),f=V.useCallback(()=>{if(!l.current)return;const D={...l.current,in_progress:!1};B.current.set(D.schematic_component_id,{...D.new_center}),l3t("endDrag calling onEditEvent with new edit event",{newEditEvent:D}),t&&t(D),l.current=null,I.current=null,g(null)},[t]),m=V.useCallback(()=>f(),[f]),w=V.useCallback(()=>f(),[f]);return V.useEffect(()=>(window.addEventListener("mousemove",u),window.addEventListener("mouseup",m),window.addEventListener("touchmove",d,{passive:!1}),window.addEventListener("touchend",w),()=>{window.removeEventListener("mousemove",u),window.removeEventListener("mouseup",m),window.removeEventListener("touchmove",d),window.removeEventListener("touchend",w)}),[u,m,d,w]),{handleMouseDown:Q,handleTouchStart:h,isDragging:!!l.current,activeEditEvent:a}},ZD={schematicEditIcon:50,schematicGridIcon:49,spiceSimulationIcon:50,viewMenuIcon:48,viewMenu:55,viewMenuBackdrop:54,clickToInteractOverlay:100,schematicComponentHoverOutline:47,schematicPortHoverOutline:48},C3t=({onClick:t,active:A})=>{const e=i=>{i.preventDefault(),t()};return W.jsx("div",{onClick:e,onTouchEnd:e,title:A?"Disable edit mode":"Enable edit mode",style:{position:"absolute",top:"16px",right:"64px",backgroundColor:A?"#4CAF50":"#fff",color:A?"#fff":"#000",padding:"8px",borderRadius:"4px",cursor:"pointer",boxShadow:"0 2px 4px rgba(0,0,0,0.1)",display:"flex",alignItems:"center",gap:"4px",zIndex:ZD.schematicEditIcon},children:W.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[W.jsx("path",{d:"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"}),W.jsx("path",{d:"M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"})]})})},Q3t=({onClick:t,active:A})=>{const e=i=>{i.preventDefault(),t()};return W.jsx("div",{onClick:e,onTouchEnd:e,title:A?"Hide grid":"Show grid",style:{position:"absolute",top:"56px",right:"64px",backgroundColor:A?"#4CAF50":"#fff",color:A?"#fff":"#000",padding:"8px",borderRadius:"4px",cursor:"pointer",boxShadow:"0 2px 4px rgba(0,0,0,0.1)",display:"flex",alignItems:"center",gap:"4px",zIndex:ZD.schematicGridIcon},children:W.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:W.jsx("path",{d:"M3 3h7v7H3zM14 3h7v7h-7zM3 14h7v7H3zM14 14h7v7h-7z"})})})},h3t=({onClick:t,active:A})=>{const e=i=>{i.preventDefault(),t()};return W.jsx("div",{onClick:e,onTouchEnd:e,title:A?"Hide view menu":"Show view menu",style:{position:"absolute",top:"16px",right:"16px",backgroundColor:A?"#4CAF50":"#fff",color:A?"#fff":"#000",padding:"8px",borderRadius:"4px",cursor:"pointer",boxShadow:"0 2px 4px rgba(0,0,0,0.1)",display:"flex",alignItems:"center",gap:"4px",zIndex:ZD.viewMenuIcon},children:W.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[W.jsx("circle",{cx:"12",cy:"12",r:"1"}),W.jsx("circle",{cx:"12",cy:"5",r:"1"}),W.jsx("circle",{cx:"12",cy:"19",r:"1"})]})})},E3t={version:"2.0.57"},u3t=({circuitJson:t,circuitJsonKey:A,isVisible:e,onClose:i,showGroups:n,onToggleGroups:o,showGrid:s,onToggleGrid:r})=>{const a=V.useMemo(()=>{if(!t||t.length===0)return!1;try{if(($E(t).source_group?.list()||[]).length>0)return!0;const c=$E(t).schematic_component?.list()||[];if(c.length>1){const I=new Set;for(const l of c){const B=$E(t).source_component.get(l.source_component_id);B?.ftype&&I.add(B.ftype)}return I.size>1}return!1}catch(g){return console.error("Error checking for groups:",g),!1}},[A]);return e?W.jsxs(W.Fragment,{children:[W.jsx("div",{onClick:i,onTouchEnd:g=>{g.preventDefault(),i()},style:{position:"absolute",inset:0,backgroundColor:"transparent",zIndex:ZD.viewMenuBackdrop}}),W.jsxs("div",{style:{position:"absolute",top:"56px",right:"16px",backgroundColor:"#ffffff",color:"#000000",border:"1px solid #ccc",borderRadius:"4px",boxShadow:"0 4px 12px rgba(0,0,0,0.1)",minWidth:"200px",zIndex:ZD.viewMenu},children:[W.jsxs("div",{onClick:()=>{a&&o(!n)},onTouchEnd:g=>{g.preventDefault(),a&&o(!n)},style:{padding:"8px 12px",cursor:a?"pointer":"not-allowed",opacity:a?1:.5,fontSize:"13px",color:"#000000",fontFamily:"sans-serif",display:"flex",alignItems:"center",gap:"8px"},onMouseEnter:g=>{a&&(g.currentTarget.style.backgroundColor="#f0f0f0")},onMouseLeave:g=>{a&&(g.currentTarget.style.backgroundColor="transparent")},children:[W.jsx("div",{style:{width:"16px",height:"16px",border:"2px solid #000",borderRadius:"2px",backgroundColor:"transparent",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"10px",fontWeight:"bold"},children:n&&"✓"}),"View Schematic Groups"]}),!a&&W.jsx("div",{style:{padding:"8px 12px",fontSize:"11px",color:"#666",fontStyle:"italic"},children:"No groups found in this schematic"}),W.jsxs("div",{onClick:()=>r(!s),onTouchEnd:g=>{g.preventDefault(),r(!s)},style:{padding:"8px 12px",cursor:"pointer",fontSize:"13px",color:"#000000",fontFamily:"sans-serif",display:"flex",alignItems:"center",gap:"8px"},onMouseEnter:g=>{g.currentTarget.style.backgroundColor="#f0f0f0"},onMouseLeave:g=>{g.currentTarget.style.backgroundColor="transparent"},children:[W.jsx("div",{style:{width:"16px",height:"16px",border:"2px solid #000",borderRadius:"2px",backgroundColor:"transparent",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"10px",fontWeight:"bold"},children:s&&"✓"}),"Show Grid"]}),W.jsxs("div",{style:{padding:"4px 8px",fontSize:"12px",color:"#999",borderTop:"1px solid #eee",textAlign:"center"},children:["v",String(E3t?.version)]})]})]}):null},d3t=()=>W.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:W.jsx("path",{d:"M3 12h2.5l2.5-9 4 18 4-9h5.5"})}),p3t=({onClick:t})=>W.jsx("div",{onClick:t,title:"Run SPICE simulation",style:{position:"absolute",top:"16px",right:"112px",backgroundColor:"#fff",color:"#000",padding:"8px",borderRadius:"4px",cursor:"pointer",boxShadow:"0 2px 4px rgba(0,0,0,0.1)",display:"flex",alignItems:"center",gap:"4px",zIndex:ZD.spiceSimulationIcon},children:W.jsx(d3t,{})});AV.register(O4t,V4t,S4t,D4t,R4t,T4t,v4t);var nV=["#8884d8","#82ca9d","#ffc658","#ff7300","#387908"],Kse=t=>{if(t===0)return"0s";const A=Math.abs(t);let e="s",i=1;return A<1e-12?(e="fs",i=1e15):A<1e-9?(e="ps",i=1e12):A<1e-6?(e="ns",i=1e9):A<.001?(e="us",i=1e6):A<1&&(e="ms",i=1e3),`${parseFloat((t*i).toPrecision(3))}${e}`},f3t=({plotData:t,nodes:A,isLoading:e,error:i,hasRun:n})=>{const o=V.useMemo(()=>{const a=A.some(c=>c.toLowerCase().startsWith("v(")),g=A.some(c=>c.toLowerCase().startsWith("i("));return a&&g?"Value":a?"Voltage (V)":g?"Current (A)":"Value"},[A]);if(e)return W.jsx("div",{style:{height:"300px",width:"100%",display:"flex",alignItems:"center",justifyContent:"center"},children:"Running simulation..."});if(!n)return W.jsx("div",{style:{height:"300px",width:"100%",display:"flex",alignItems:"center",justifyContent:"center"},children:'Click "Run" to start the simulation.'});if(i)return W.jsxs("div",{style:{height:"300px",width:"100%",display:"flex",alignItems:"center",justifyContent:"center",color:"red"},children:["Error: ",i]});if(t.length===0)return W.jsx("div",{style:{height:"300px",width:"100%",display:"flex",alignItems:"center",justifyContent:"center"},children:"No data to plot. Check simulation output or SPICE netlist."});const s={datasets:A.map((a,g)=>({label:a,data:t.map(c=>({x:Number(c.name),y:c[a]})),borderColor:nV[g%nV.length],backgroundColor:nV[g%nV.length],fill:!1,tension:.1}))},r={responsive:!0,maintainAspectRatio:!1,plugins:{legend:{position:"top",labels:{font:{family:"sans-serif"}}},title:{display:!1},tooltip:{callbacks:{title:a=>{if(a.length>0){const g=a[0];return Kse(g.parsed.x)}return""}}}},scales:{x:{type:"linear",title:{display:!0,text:"Time",font:{family:"sans-serif"}},ticks:{callback:a=>Kse(a),font:{family:"sans-serif"}}},y:{title:{display:!0,text:o,font:{family:"sans-serif"}},ticks:{font:{family:"sans-serif"}}}}};return W.jsx("div",{style:{position:"relative",height:"300px",width:"100%"},children:W.jsx(n3t,{options:r,data:s})})},y3t=({spiceString:t,onClose:A,plotData:e,nodes:i,isLoading:n,error:o,simOptions:s,onSimOptionsChange:r,hasRun:a})=>{const[g,c]=V.useState(String(s.startTime)),[I,l]=V.useState(String(s.duration));V.useEffect(()=>{c(String(s.startTime)),l(String(s.duration))},[s.startTime,s.duration]);const B=()=>{r({...s,startTime:Number(g),duration:Number(I)})},C=i.filter(Q=>{const h=Q.toLowerCase().startsWith("v("),E=Q.toLowerCase().startsWith("i(");return!!(s.showVoltage&&h||s.showCurrent&&E)});return W.jsx("div",{style:{position:"fixed",top:0,left:0,right:0,bottom:0,backgroundColor:"rgba(0, 0, 0, 0.5)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1002,fontFamily:"sans-serif"},children:W.jsxs("div",{style:{backgroundColor:"white",padding:"24px",borderRadius:"12px",width:"90%",maxWidth:"900px",boxShadow:"0 4px 20px rgba(0, 0, 0, 0.15)"},children:[W.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"24px",borderBottom:"1px solid #eee",paddingBottom:"16px"},children:[W.jsx("h2",{style:{margin:0,fontSize:"22px",fontWeight:600,color:"#333"},children:"SPICE Simulation"}),W.jsx("button",{onClick:A,style:{background:"none",border:"none",fontSize:"28px",cursor:"pointer",color:"#888",padding:0,lineHeight:1},children:"×"})]}),W.jsx("div",{children:W.jsx(f3t,{plotData:e,nodes:C,isLoading:n,error:o,hasRun:a})}),W.jsxs("div",{style:{marginTop:"16px",padding:"12px",backgroundColor:"#f7f7f7",borderRadius:"6px",display:"flex",flexWrap:"wrap",gap:"24px",alignItems:"center",fontSize:"14px"},children:[W.jsxs("div",{style:{display:"flex",gap:"16px"},children:[W.jsxs("label",{style:{display:"flex",alignItems:"center",gap:"6px"},children:[W.jsx("input",{type:"checkbox",checked:s.showVoltage,onChange:Q=>r({...s,showVoltage:Q.target.checked})}),"Voltage"]}),W.jsxs("label",{style:{display:"flex",alignItems:"center",gap:"6px"},children:[W.jsx("input",{type:"checkbox",checked:s.showCurrent,onChange:Q=>r({...s,showCurrent:Q.target.checked})}),"Current"]})]}),W.jsxs("div",{style:{display:"flex",gap:"16px",alignItems:"center"},children:[W.jsx("label",{htmlFor:"startTime",children:"Start Time (ms):"}),W.jsx("input",{id:"startTime",type:"number",value:g,onChange:Q=>c(Q.target.value),style:{width:"80px",padding:"4px 8px",borderRadius:"4px",border:"1px solid #ccc"}}),W.jsx("label",{htmlFor:"duration",children:"Duration (ms):"}),W.jsx("input",{id:"duration",type:"number",value:I,onChange:Q=>l(Q.target.value),style:{width:"80px",padding:"4px 8px",borderRadius:"4px",border:"1px solid #ccc"}}),W.jsx("button",{onClick:B,style:{padding:"4px 12px",borderRadius:"4px",border:"1px solid #ccc",backgroundColor:"#f0f0f0",cursor:"pointer"},children:a?"Rerun":"Run"})]})]}),W.jsxs("div",{style:{marginTop:"24px"},children:[W.jsx("h3",{style:{marginTop:0,marginBottom:"12px",fontSize:"18px",fontWeight:600,color:"#333"},children:"SPICE Netlist"}),W.jsx("pre",{style:{backgroundColor:"#fafafa",padding:"16px",borderRadius:"6px",maxHeight:"150px",overflowY:"auto",border:"1px solid #eee",color:"#333",fontSize:"13px",fontFamily:"monospace"},children:t})]})]})})},m3t="dmFyIGU9bnVsbCxzPWFzeW5jKCk9Pihhd2FpdCBpbXBvcnQoImh0dHBzOi8vY2RuLmpzZGVsaXZyLm5ldC9ucG0vZWVjaXJjdWl0LWVuZ2luZUAxLjUuMi8rZXNtIikpLlNpbXVsYXRpb24sYz1hc3luYygpPT57aWYoZSYmZS5pc0luaXRpYWxpemVkKCkpcmV0dXJuO2xldCBpPWF3YWl0IHMoKTtlPW5ldyBpLGF3YWl0IGUuc3RhcnQoKX07c2VsZi5vbm1lc3NhZ2U9YXN5bmMgaT0+e3RyeXtpZihhd2FpdCBjKCksIWUpdGhyb3cgbmV3IEVycm9yKCJTaW11bGF0aW9uIG5vdCBpbml0aWFsaXplZCIpO2xldCB0PWkuZGF0YS5zcGljZVN0cmluZyxhPXQubWF0Y2goL3dyZGF0YVxzKyhcUyspXHMrKC4qKS9pKTtpZihhKXtsZXQgbz1gLnByb2JlICR7YVsyXS50cmltKCkuc3BsaXQoL1xzKy8pLmpvaW4oIiAiKX1gO3Q9dC5yZXBsYWNlKC93cmRhdGEuKi9pLG8pfWVsc2UgaWYoIXQubWF0Y2goL1wucHJvYmUvaSkpdGhyb3cgdC5tYXRjaCgvcGxvdFxzKyguKikvaSk/bmV3IEVycm9yKCJUaGUgJ3Bsb3QnIGNvbW1hbmQgaXMgbm90IHN1cHBvcnRlZCBmb3IgZGF0YSBleHRyYWN0aW9uLiBQbGVhc2UgdXNlICd3cmRhdGEgPGZpbGVuYW1lPiA8dmFyMT4gLi4uJyBvciAnLnByb2JlIDx2YXIxPiAuLi4nIGluc3RlYWQuIik6bmV3IEVycm9yKCJObyAnLnByb2JlJyBvciAnd3JkYXRhJyBjb21tYW5kIGZvdW5kIGluIFNQSUNFIGZpbGUuIFVzZSAnd3JkYXRhIDxmaWxlbmFtZT4gPHZhcjE+IC4uLicgdG8gc3BlY2lmeSBvdXRwdXQuIik7ZS5zZXROZXRMaXN0KHQpO2xldCBuPWF3YWl0IGUucnVuU2ltKCk7c2VsZi5wb3N0TWVzc2FnZSh7dHlwZToicmVzdWx0IixyZXN1bHQ6bn0pfWNhdGNoKHQpe3NlbGYucG9zdE1lc3NhZ2Uoe3R5cGU6ImVycm9yIixlcnJvcjp0Lm1lc3NhZ2V9KX19Owo=",oV=null,w3t=()=>{if(typeof window>"u")return null;if(oV)return oV;try{const t=new Blob([atob(m3t)],{type:"application/javascript"});return oV=URL.createObjectURL(t),oV}catch(t){return console.error("Failed to create blob URL for worker",t),null}},D3t=t=>{const A={};if(t.dataType==="real")t.data.forEach(r=>{A[r.name]=r.values});else if(t.dataType==="complex")t.data.forEach(r=>{A[r.name]=r.values.map(a=>a.real)});else throw new Error("Unsupported data type in simulation result");const e=Object.keys(A).find(r=>r.toLowerCase()==="time"||r.toLowerCase()==="frequency");if(!e)throw new Error("No time or frequency data in simulation result");const i=A[e],n=Object.keys(A).filter(r=>r!==e),o=n;return{plotData:i.map((r,a)=>{const g={name:r.toExponential(2)};return n.forEach(c=>{g[c]=A[c][a]}),g}),nodes:o}},S3t=t=>{const[A,e]=V.useState([]),[i,n]=V.useState([]),[o,s]=V.useState(!0),[r,a]=V.useState(null);return V.useEffect(()=>{if(!t){s(!1),e([]),n([]),a(null);return}s(!0),a(null),e([]),n([]);const g=w3t();if(!g){a("Could not create SPICE simulation worker."),s(!1);return}const c=new Worker(g,{type:"module"});return c.onmessage=I=>{if(I.data.type==="result")try{const{plotData:l,nodes:B}=D3t(I.data.result);e(l),n(B)}catch(l){a(l.message||"Failed to parse simulation result"),console.error(l)}else I.data.type==="error"&&a(I.data.error);s(!1)},c.onerror=I=>{a(I.message),s(!1)},c.postMessage({spiceString:t}),()=>{c.terminate()}},[t]),{plotData:A,nodes:i,isLoading:o,error:r}},SpA=t=>{if(t===0)return"0";const A=Math.abs(t),e=i=>i.toPrecision(4);return A>=1?e(t):A>=.001?`${e(t*1e3)}m`:A>=1e-6?`${e(t*1e6)}u`:A>=1e-9?`${e(t*1e9)}n`:A>=1e-12?`${e(t*1e12)}p`:A>=1e-15?`${e(t*1e15)}f`:t.toExponential(3)},b3t=(t,A)=>{const i=aHA(t).toSpiceString(),o=i.split(`
5375
5375
  `).filter(x=>x.trim()!=="").filter(x=>!x.startsWith("*")&&!x.startsWith(".")&&x.trim()!==""),s=new Set,r=new Set,a=new Set;for(const x of o){const N=x.trim().split(/\s+/);if(N.length<3)continue;const R=N[0],L=R[0].toUpperCase();let Y=[];if(["R","C","L","V","I","D"].includes(L))Y=N.slice(1,3),L==="V"&&a.add(R);else if(L==="Q"&&N.length>=4)Y=N.slice(1,4);else if(L==="M"&&N.length>=5)Y=N.slice(1,5);else if(L==="X")Y=N.slice(1,-1);else continue;Y.forEach(J=>s.add(J)),L==="C"&&Y.forEach(J=>r.add(J))}s.delete("0"),r.delete("0");const g=Array.from(r).map(x=>`.ic V(${x})=0`),c=[],I=Array.from(s).map(x=>`V(${x})`);c.push(...I);const l=Array.from(a).map(x=>`I(${x})`);c.push(...l);const B=c.length>0?`.probe ${c.join(" ")}`:"",C=A?.startTime??0,Q=A?.duration??20,h=C*.001,E=Q*.001,u=h+E,d=E/50,f=`.tran ${SpA(d)} ${SpA(u)} ${SpA(h)} UIC`,m=".end",w=i.split(`
5376
5376
  `);let D=-1;for(let x=w.length-1;x>=0;x--)if(w[x].trim().toLowerCase().startsWith(m)){D=x;break}const b=[...g,B,f].filter(Boolean);let k;if(D!==-1){const x=w.slice(0,D),N=w.slice(D);k=[...x,...b,...N]}else k=[...w,...b,m];return k.join(`
5377
5377
  `)},x3t=(t,A)=>{if(typeof window>"u")return A;try{const e=localStorage.getItem(t);return e!==null?JSON.parse(e):A}catch{return A}},_3t=(t,A)=>{if(!(typeof window>"u"))try{localStorage.setItem(t,JSON.stringify(A))}catch{}},bpA=V.createContext(null),k3t=5,F3t=(t,A)=>!t&&!A?!0:!t||!A?!1:t.minX===A.minX&&t.maxX===A.maxX&&t.minY===A.minY&&t.maxY===A.maxY,v3t=({children:t})=>{if(V.useContext(bpA))return W.jsx(W.Fragment,{children:t});const e=V.useRef({pointer:null,boundingBoxes:new Map,hoveringIds:new Set,subscribers:new Set,mouseDownPosition:null}),i=V.useCallback(()=>{for(const I of e.current.subscribers)I()},[]),n=V.useCallback(()=>{const I=e.current.pointer,l=new Set;if(I)for(const[C,Q]of e.current.boundingBoxes){const h=Q.bounds;h&&I.x>=h.minX&&I.x<=h.maxX&&I.y>=h.minY&&I.y<=h.maxY&&l.add(C)}const B=e.current.hoveringIds;l.size===B.size&&[...l].every(C=>B.has(C))||(e.current.hoveringIds=l,i())},[i]),o=V.useCallback((I,l)=>{e.current.boundingBoxes.set(I,l),n()},[n]),s=V.useCallback((I,l)=>{const B=e.current.boundingBoxes.get(I);B&&F3t(B.bounds,l.bounds)&&B.onClick===l.onClick||(e.current.boundingBoxes.set(I,l),n())},[n]),r=V.useCallback(I=>{e.current.boundingBoxes.delete(I)&&n()},[n]),a=V.useCallback(I=>(e.current.subscribers.add(I),()=>{e.current.subscribers.delete(I)}),[]),g=V.useCallback(I=>e.current.hoveringIds.has(I),[]);V.useEffect(()=>{const I=Q=>{const{clientX:h,clientY:E}=Q,u=e.current.pointer;u&&u.x===h&&u.y===E||(e.current.pointer={x:h,y:E},n())},l=()=>{e.current.pointer!==null&&(e.current.pointer=null,e.current.mouseDownPosition=null,n())},B=Q=>{e.current.mouseDownPosition={x:Q.clientX,y:Q.clientY}},C=Q=>{const{clientX:h,clientY:E}=Q,u=e.current.mouseDownPosition;if(u&&Math.sqrt(Math.pow(h-u.x,2)+Math.pow(E-u.y,2))>k3t){e.current.mouseDownPosition=null;return}e.current.mouseDownPosition=null;for(const d of e.current.boundingBoxes.values()){const f=d.bounds;f&&h>=f.minX&&h<=f.maxX&&E>=f.minY&&E<=f.maxY&&d.onClick?.(Q)}};return window.addEventListener("pointermove",I,{passive:!0}),window.addEventListener("pointerdown",I,{passive:!0}),window.addEventListener("pointerup",I,{passive:!0}),window.addEventListener("pointerleave",l),window.addEventListener("pointercancel",l),window.addEventListener("blur",l),window.addEventListener("mousedown",B,{passive:!0}),window.addEventListener("click",C,{passive:!0}),()=>{window.removeEventListener("pointermove",I),window.removeEventListener("pointerdown",I),window.removeEventListener("pointerup",I),window.removeEventListener("pointerleave",l),window.removeEventListener("pointercancel",l),window.removeEventListener("blur",l),window.removeEventListener("mousedown",B),window.removeEventListener("click",C)}},[n]);const c=V.useMemo(()=>({registerBoundingBox:o,updateBoundingBox:s,unregisterBoundingBox:r,subscribe:a,isHovering:g}),[o,s,r,a,g]);return W.jsx(bpA.Provider,{value:c,children:t})},Pse=t=>{const A=V.useContext(bpA);if(!A)throw new Error("useMouseEventsOverBoundingBox must be used within a MouseTracker");const e=V.useId(),i=V.useRef(t);i.current=t;const n=V.useMemo(()=>s=>{i.current.onClick?.(s)},[]);return V.useEffect(()=>(A.registerBoundingBox(e,{bounds:i.current.bounds,onClick:i.current.onClick?n:void 0}),()=>{A.unregisterBoundingBox(e)}),[A,n,e]),V.useEffect(()=>{A.updateBoundingBox(e,{bounds:i.current.bounds,onClick:i.current.onClick?n:void 0})},[A,n,e,t.bounds?.minX,t.bounds?.maxX,t.bounds?.minY,t.bounds?.maxY,t.onClick]),{hovering:V.useSyncExternalStore(A.subscribe,()=>A.isHovering(e),()=>!1)}},G3t=(t,A)=>!t&&!A?!0:!t||!A?!1:Math.abs(t.bounds.minX-A.bounds.minX)<.5&&Math.abs(t.bounds.maxX-A.bounds.maxX)<.5&&Math.abs(t.bounds.minY-A.bounds.minY)<.5&&Math.abs(t.bounds.maxY-A.bounds.maxY)<.5&&Math.abs(t.rect.left-A.rect.left)<.5&&Math.abs(t.rect.top-A.rect.top)<.5&&Math.abs(t.rect.width-A.rect.width)<.5&&Math.abs(t.rect.height-A.rect.height)<.5,R3t=({componentId:t,svgDivRef:A,containerRef:e,onComponentClick:i,onHoverChange:n,showOutline:o,circuitJsonKey:s})=>{const[r,a]=V.useState(null),g=V.useRef(null),c=V.useCallback(()=>{g.current=null;const h=A.current,E=e.current;if(!h||!E){a(w=>w&&null);return}const u=h.querySelector(`[data-schematic-component-id="${t}"]`);if(!u){a(w=>w&&null);return}const d=u.getBoundingClientRect(),f=E.getBoundingClientRect(),m={bounds:{minX:d.left,maxX:d.right,minY:d.top,maxY:d.bottom},rect:{left:d.left-f.left,top:d.top-f.top,width:d.width,height:d.height}};a(w=>G3t(w,m)?w:m)},[t,e,A]),I=V.useCallback(()=>{g.current===null&&(g.current=window.requestAnimationFrame(c))},[c]);V.useEffect(()=>{I()},[I,s]),V.useEffect(()=>{I();const h=A.current,E=e.current;if(!h||!E)return;const u=typeof ResizeObserver<"u"?new ResizeObserver(()=>{I()}):null;u?.observe(E),u?.observe(h);const d=typeof MutationObserver<"u"?new MutationObserver(()=>{I()}):null;return d?.observe(h,{attributes:!0,attributeFilter:["style","transform"],subtree:!0,childList:!0}),window.addEventListener("scroll",I,!0),window.addEventListener("resize",I),()=>{u?.disconnect(),d?.disconnect(),window.removeEventListener("scroll",I,!0),window.removeEventListener("resize",I),g.current!==null&&(cancelAnimationFrame(g.current),g.current=null)}},[I,A,e]);const l=V.useCallback(h=>{i&&i(t,h)},[t,i]),B=r?.bounds??null,{hovering:C}=Pse({bounds:B,onClick:i?l:void 0});if(V.useEffect(()=>{n&&n(t,C)},[C,t,n]),!r||!C||!o)return null;const Q=r.rect;return W.jsx("div",{style:{position:"absolute",left:Q.left,top:Q.top,width:Q.width,height:Q.height,border:"1.5px solid rgba(51, 153, 255, 0.9)",pointerEvents:"none",zIndex:ZD.schematicComponentHoverOutline}})},N3t=(t,A)=>!t&&!A?!0:!t||!A?!1:Math.abs(t.bounds.minX-A.bounds.minX)<.5&&Math.abs(t.bounds.maxX-A.bounds.maxX)<.5&&Math.abs(t.bounds.minY-A.bounds.minY)<.5&&Math.abs(t.bounds.maxY-A.bounds.maxY)<.5&&Math.abs(t.rect.left-A.rect.left)<.5&&Math.abs(t.rect.top-A.rect.top)<.5&&Math.abs(t.rect.width-A.rect.width)<.5&&Math.abs(t.rect.height-A.rect.height)<.5,M3t=({portId:t,portLabel:A,svgDivRef:e,containerRef:i,onPortClick:n,onHoverChange:o,showOutline:s,circuitJsonKey:r})=>{const[a,g]=V.useState(null),c=V.useRef(null),I=V.useCallback(()=>{c.current=null;const E=e.current,u=i.current;if(!E||!u){g(b=>b&&null);return}const d=E.querySelector(`[data-schematic-port-id="${t}"]`);if(!d){g(b=>b&&null);return}const f=d.getBoundingClientRect(),m=u.getBoundingClientRect(),w=4,D={bounds:{minX:f.left-w,maxX:f.right+w,minY:f.top-w,maxY:f.bottom+w},rect:{left:f.left-m.left-w,top:f.top-m.top-w,width:f.width+w*2,height:f.height+w*2}};g(b=>N3t(b,D)?b:D)},[t,i,e]),l=V.useCallback(()=>{c.current===null&&(c.current=window.requestAnimationFrame(I))},[I]);V.useEffect(()=>{l()},[l,r]),V.useEffect(()=>{l();const E=e.current,u=i.current;if(!E||!u)return;const d=typeof ResizeObserver<"u"?new ResizeObserver(()=>{l()}):null;d?.observe(u),d?.observe(E);const f=typeof MutationObserver<"u"?new MutationObserver(()=>{l()}):null;return f?.observe(E,{attributes:!0,attributeFilter:["style","transform"],subtree:!0,childList:!0}),window.addEventListener("scroll",l,!0),window.addEventListener("resize",l),()=>{d?.disconnect(),f?.disconnect(),window.removeEventListener("scroll",l,!0),window.removeEventListener("resize",l),c.current!==null&&(cancelAnimationFrame(c.current),c.current=null)}},[l,e,i]);const B=V.useCallback(E=>{n&&n(t,E)},[t,n]),C=a?.bounds??null,{hovering:Q}=Pse({bounds:C,onClick:n?B:void 0});if(V.useEffect(()=>{o&&o(t,Q)},[Q,t,o]),!a||!s)return null;const h=a.rect;return W.jsxs(W.Fragment,{children:[W.jsx("div",{style:{position:"absolute",left:h.left,top:h.top,width:h.width,height:h.height,border:Q?"1.5px solid rgba(255, 153, 51, 0.9)":"1.5px solid rgba(255, 153, 51, 0.3)",backgroundColor:Q?"rgba(255, 153, 51, 0.15)":"rgba(255, 153, 51, 0.05)",borderRadius:"50%",pointerEvents:"none",zIndex:ZD.schematicPortHoverOutline,transition:"border-color 0.15s, background-color 0.15s"}}),Q&&A&&W.jsx("div",{style:{position:"absolute",left:h.left+h.width/2,top:h.top-24,transform:"translateX(-50%)",backgroundColor:"rgba(0, 0, 0, 0.85)",color:"white",padding:"4px 8px",borderRadius:"4px",fontSize:"12px",fontFamily:"monospace",whiteSpace:"nowrap",pointerEvents:"none",zIndex:ZD.schematicPortHoverOutline+1},children:A})]})},L3t=({circuitJson:t,containerStyle:A,editEvents:e=[],onEditEvent:i,defaultEditMode:n=!1,debugGrid:o=!1,editingEnabled:s=!1,debug:r=!1,clickToInteractEnabled:a=!1,colorOverrides:g,spiceSimulationEnabled:c=!1,disableGroups:I=!1,onSchematicComponentClicked:l,showSchematicPorts:B=!1,onSchematicPortClicked:C})=>{r&&c3t();const[Q,h]=V.useState(!1),[E,u]=V.useState({showVoltage:!0,showCurrent:!1,startTime:0,duration:20}),d=QA=>`${QA?.length||0}_${QA?.editCount||0}`,f=V.useMemo(()=>d(t),[t]),m=V.useMemo(()=>{if(!c)return null;try{return b3t(t,E)}catch(QA){return console.error("Failed to generate SPICE string",QA),null}},[f,c,E.startTime,E.duration]),[w,D]=V.useState(!1);V.useEffect(()=>{D(!1)},[f]);const{plotData:b,nodes:k,isLoading:x,error:N}=S3t(w?m:null),[R,L]=V.useState(n),[Y,J]=V.useState(!0),[O,Z]=V.useState(!1),X=o||O,[iA,gA]=V.useState(!a),[tA,eA]=V.useState(!1),[sA,lA]=V.useState(()=>I?!1:x3t("schematic_viewer_show_groups",!1)),[pA,MA]=V.useState(!1),vA=V.useRef(new Set),PA=V.useCallback((QA,ge)=>{ge?vA.current.add(QA):vA.current.delete(QA),MA(vA.current.size>0)},[]),[hA,FA]=V.useState(!1),yA=V.useRef(new Set),WA=V.useCallback((QA,ge)=>{ge?yA.current.add(QA):yA.current.delete(QA),FA(yA.current.size>0)},[]),$A=V.useRef(null),Ce=V.useRef(null),wA=V.useMemo(()=>{try{return $E(t).schematic_component?.list()?.map(QA=>QA.schematic_component_id)??[]}catch(QA){return console.error("Failed to derive schematic component ids",QA),[]}},[f,t]),oe=V.useMemo(()=>{if(!B)return[];try{return($E(t).schematic_port?.list()??[]).map(ge=>{const de=$E(t).source_port.get(ge.source_port_id),Ke=(de?.source_component_id?$E(t).source_component.get(de.source_component_id):null)?.name??"?",Xe=ge.display_pin_label??de?.pin_number??de?.name??"?";return{portId:ge.source_port_id,label:`${Ke}.${Xe}`}})}catch(QA){return console.error("Failed to derive schematic port info",QA),[]}},[f,t,B]),ZA=QA=>{const ge=QA.touches[0];Ce.current={x:ge.clientX,y:ge.clientY}},KA=QA=>{const ge=QA.changedTouches[0],de=Ce.current;if(!de)return;const Se=Math.abs(ge.clientX-de.x),Ke=Math.abs(ge.clientY-de.y);Se<10&&Ke<10&&(QA.preventDefault(),gA(!0)),Ce.current=null},[VA,kA]=V.useState([]),DA=V.useRef(t);V.useEffect(()=>{const QA=d(t),ge=d(DA.current);QA!==ge&&(kA([]),DA.current=t)},[t]);const{ref:UA,cancelDrag:NA,transform:OA}=JY({onSetTransform(QA){$A.current&&($A.current.style.transform=gF(QA))},enabled:iA&&!Q}),{containerWidth:jA,containerHeight:re}=Tse(UA),xA=V.useMemo(()=>!jA||!re?"":k9(t,{width:jA,height:re||720,grid:X?{cellSize:1,labelCells:!0}:void 0,colorOverrides:g}),[f,jA,re,X]),CA=V.useMemo(()=>xA.match(/<svg[^>]*style="[^"]*background-color:\s*([^;\"]+)/i)?.[1]??"transparent",[xA]),EA=V.useMemo(()=>{if(!xA)return cd();const QA=xA.match(/data-real-to-screen-transform="([^"]+)"/)?.[1];try{return e3(QA)}catch(ge){return console.error(ge),cd()}},[xA]),YA=QA=>{kA(ge=>[...ge,QA]),i&&i(QA)},Ie=V.useMemo(()=>[...e,...VA],[e,VA]),{handleMouseDown:pe,handleTouchStart:me,isDragging:Ne,activeEditEvent:Le}=B3t({onEditEvent:YA,cancelDrag:NA,realToSvgProjection:EA,svgToScreenProjection:OA,circuitJson:t,editEvents:Ie,enabled:R&&iA&&!Q,snapToGrid:Y});o3t({svgDivRef:$A,editEvents:Ie,realToSvgProjection:EA,svgToScreenProjection:OA,activeEditEvent:Le}),s3t({svgDivRef:$A,circuitJson:t,activeEditEvent:Le,editEvents:Ie}),r3t({svgDivRef:$A,circuitJson:t,circuitJsonKey:f,showGroups:sA&&!I});const Ve=V.useRef(me);V.useEffect(()=>{Ve.current=me},[me]);const yt=V.useMemo(()=>W.jsx("div",{ref:$A,style:{pointerEvents:a?iA?"auto":"none":"auto",transformOrigin:"0 0"},className:l?"schematic-component-clickable":void 0,onTouchStart:QA=>{R&&iA&&!Q&&Ve.current(QA)},dangerouslySetInnerHTML:{__html:xA}}),[xA,iA,a,R,Q]);return W.jsxs(v3t,{children:[l&&W.jsx("style",{children:".schematic-component-clickable [data-schematic-component-id]:hover { cursor: pointer !important; }"}),C&&W.jsx("style",{children:"[data-schematic-port-id]:hover { cursor: pointer !important; }"}),W.jsxs("div",{ref:UA,style:{position:"relative",backgroundColor:CA,overflow:"hidden",cursor:Q?"auto":Ne?"grabbing":a&&!iA||pA&&l||hA&&C?"pointer":"grab",minHeight:"300px",...A},onWheelCapture:QA=>{Q&&QA.stopPropagation()},onMouseDown:QA=>{if(a&&!iA){QA.preventDefault(),QA.stopPropagation();return}pe(QA)},onMouseDownCapture:QA=>{if(a&&!iA){QA.preventDefault(),QA.stopPropagation();return}},onTouchStart:QA=>{Q||ZA(QA)},onTouchEnd:QA=>{Q||KA(QA)},children:[!iA&&a&&W.jsx("div",{onClick:QA=>{QA.preventDefault(),QA.stopPropagation(),gA(!0)},style:{position:"absolute",inset:0,cursor:"pointer",zIndex:ZD.clickToInteractOverlay,display:"flex",alignItems:"center",justifyContent:"center",pointerEvents:"all",touchAction:"pan-x pan-y pinch-zoom"},children:W.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:typeof window<"u"&&("ontouchstart"in window||navigator.maxTouchPoints>0)?"Touch to Interact":"Click to Interact"})}),W.jsx(h3t,{active:tA,onClick:()=>eA(!tA)}),s&&W.jsx(C3t,{active:R,onClick:()=>L(!R)}),s&&R&&W.jsx(Q3t,{active:Y,onClick:()=>J(!Y)}),W.jsx(u3t,{circuitJson:t,circuitJsonKey:f,isVisible:tA,onClose:()=>eA(!1),showGroups:sA,onToggleGroups:QA=>{I||(lA(QA),_3t("schematic_viewer_show_groups",QA))},showGrid:X,onToggleGrid:Z}),c&&W.jsx(p3t,{onClick:()=>h(!0)}),Q&&W.jsx(y3t,{spiceString:m,onClose:()=>h(!1),plotData:b,nodes:k,isLoading:x,error:N,simOptions:E,onSimOptionsChange:QA=>{D(!0),u(QA)},hasRun:w}),l&&wA.map(QA=>W.jsx(R3t,{componentId:QA,svgDivRef:$A,containerRef:UA,showOutline:!0,circuitJsonKey:f,onHoverChange:PA,onComponentClick:(ge,de)=>{l?.({schematicComponentId:ge,event:de})}},QA)),yt,B&&oe.map(({portId:QA,label:ge})=>W.jsx(M3t,{portId:QA,portLabel:ge,svgDivRef:$A,containerRef:UA,showOutline:!0,circuitJsonKey:f,onHoverChange:WA,onPortClick:C?(de,Se)=>{C?.({schematicPortId:de,event:Se})}:void 0},QA))]})]})},U3t=({circuitJson:t,containerStyle:A,colorOverrides:e,width:i,height:n,className:o})=>{const[s,r]=V.useState(null),[a,g]=V.useState(!0),[c,I]=V.useState(null),[l,B]=V.useState(null),C=V.useRef(null),Q=V.useRef(null),{containerWidth:h,containerHeight:E}=Tse(C),[u,d]=V.useState(!1),{ref:f}=JY({onSetTransform(L){Q.current&&(Q.current.style.transform=gF(L))}}),m=i||h||1e3,w=n||E||600;V.useEffect(()=>{g(!0),I(null),r(t),g(!1)},[t]);const D=V.useMemo(()=>s&&s.find(Y=>Y.type==="simulation_experiment")?.simulation_experiment_id||null,[s]),b=V.useMemo(()=>s?s.filter(L=>L.type==="simulation_transient_voltage_graph").map(L=>L.simulation_transient_voltage_graph_id):[],[s]),k=V.useMemo(()=>{if(!s||!m||!w||!D)return"";try{return Nne({circuitJson:s,simulation_experiment_id:D,simulation_transient_voltage_graph_ids:b,width:m,height:w,schematicOptions:{colorOverrides:e}})}catch(L){return console.error("Failed to generate fallback schematic SVG:",L),""}},[s,m,w,e,D,b]);V.useEffect(()=>{if(!k){B(null);return}try{const L=new Blob([k],{type:"image/svg+xml"}),Y=URL.createObjectURL(L);return B(Y),()=>{URL.revokeObjectURL(Y)}}catch(L){console.error("Failed to create SVG object URL:",L),B(null)}},[k]);const x=V.useMemo(()=>k?k.match(/<svg[^>]*style="[^"]*background-color:\s*([^;\"]+)/i)?.[1]??"transparent":"transparent",[k]),N=L=>{d(!0)},R=L=>{d(!0)};return V.useEffect(()=>{const L=()=>{d(!1)},Y=()=>{d(!1)};return window.addEventListener("mouseup",L),window.addEventListener("touchend",Y),()=>{window.removeEventListener("mouseup",L),window.removeEventListener("touchend",Y)}},[]),a?W.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:"#f5f5f5",minHeight:"300px",fontFamily:"sans-serif",fontSize:"16px",color:"#666",...A},className:o,children:"Loading circuit..."}):c?W.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:"#fef2f2",minHeight:"300px",fontFamily:"sans-serif",fontSize:"16px",color:"#dc2626",...A},className:o,children:W.jsxs("div",{style:{textAlign:"center",padding:"20px"},children:[W.jsx("div",{style:{fontWeight:"bold",marginBottom:"8px"},children:"Circuit Conversion Error"}),W.jsx("div",{style:{fontSize:"14px"},children:c})]})}):k?W.jsx("div",{ref:L=>{C.current=L,f.current=L},style:{position:"relative",backgroundColor:x,overflow:"hidden",minHeight:"300px",cursor:u?"grabbing":"grab",...A},className:o,onMouseDown:N,onTouchStart:R,children:l?W.jsx("img",{ref:Q,src:l,alt:"Circuit Simulation",style:{transformOrigin:"0 0",width:"100%",height:"100%",display:"block",objectFit:"contain"}}):W.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",height:"100%",minHeight:"300px",color:"#666",fontFamily:"sans-serif"},children:"Failed to render SVG"})}):W.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",backgroundColor:"#f8fafc",minHeight:"300px",fontFamily:"sans-serif",gap:"12px",...A},className:o,children:[W.jsx("div",{style:{fontSize:"16px",color:"#475569",fontWeight:500},children:"No Simulation Found"}),W.jsxs("div",{style:{fontSize:"14px",color:"#64748b"},children:["Use"," ",W.jsx("code",{style:{backgroundColor:"#e2e8f0",padding:"2px 6px",borderRadius:"4px",fontFamily:"monospace",fontSize:"13px"},children:"<analogsimulation />"})," ","to create simulations"]})]})},qse=t=>{const[A,e]=V.useState(0),[i,n]=V.useState(0);return V.useEffect(()=>{if(!t.current)return;const o=()=>{const r=t.current?.getBoundingClientRect();e(r?.width||0),n(r?.height||0)};o();const s=new ResizeObserver(o);return s.observe(t.current),window.addEventListener("resize",o),()=>{s.disconnect(),window.removeEventListener("resize",o)}},[]),{containerWidth:A,containerHeight:i}};Va("assembly-viewer");var Ose=()=>{Va.enable("assembly-viewer*")},H3t=({circuitJson:t,containerStyle:A,debugGrid:e=!1,debug:i=!1})=>{i&&Ose();const n=V.useRef(null),{ref:o}=JY({onSetTransform(c){n.current&&(n.current.style.transform=gF(c))}}),{containerWidth:s,containerHeight:r}=qse(o),a=V.useMemo(()=>!s||!r?"":Ine(t,{width:s,height:r||720}),[t,s,r]);V.useMemo(()=>{if(!a)return cd();const c=a.match(/data-real-to-screen-transform="([^"]+)"/)?.[1];try{return e3(c)}catch(I){return console.error(I),cd()}},[a]);const g=V.useMemo(()=>W.jsx("div",{ref:n,style:{pointerEvents:"auto",transformOrigin:"0 0"},dangerouslySetInnerHTML:{__html:a}}),[a]);return W.jsx("div",{ref:o,style:{position:"relative",backgroundColor:"#FFFFFF",overflow:"hidden",minHeight:"300px",...A},children:g})},Y3t=({circuitJson:t,containerStyle:A,debugGrid:e=!1,debug:i=!1})=>{i&&Ose();const n=V.useRef(null),{ref:o}=JY({onSetTransform(c){n.current&&(n.current.style.transform=gF(c))}}),{containerWidth:s,containerHeight:r}=qse(o),a=V.useMemo(()=>!s||!r?"":PdA(t,{width:s,height:r||720}),[t,s,r]);V.useMemo(()=>{if(!a)return cd();const c=a.match(/data-real-to-screen-transform="([^"]+)"/)?.[1];try{return e3(c)}catch(I){return console.error(I),cd()}},[a]);const g=V.useMemo(()=>W.jsx("div",{ref:n,style:{pointerEvents:"auto",transformOrigin:"0 0"},dangerouslySetInnerHTML:{__html:a}}),[a]);return W.jsx("div",{ref:o,style:{position:"relative",backgroundColor:"#FFFFFF",overflow:"hidden",minHeight:"300px",...A},children:g})};const Wse=["Initialize a tscircuit project using [tsci init](https://github.com/tscircuit/cli) before adding components.","Define reusable modules with cached routes using [<subcircuit />](https://docs.tscircuit.com/elements/subcircuit)","Run `tsci dev` on the command line to preview your boards before export",'Use units like mm or mils consistently across your designs (e.g. pcbX="10mm")',"Quickly set footprints with the [footprint prop](https://docs.tscircuit.com/footprints/footprinter-strings)","Check out the guide on [ordering prototypes](https://docs.tscircuit.com/building-electronics/ordering-prototypes)","Use [net labels](https://docs.tscircuit.com/elements/net) and [group elements](https://docs.tscircuit.com/elements/group) to organize complex schematics.","You can manually drag components on the PCB and Schematic using [manual edits](https://docs.tscircuit.com/guides/manual-edits)","Every tscircuit module can export to [Circuit JSON](https://github.com/tscircuit/circuit-json), Gerbers, Pick'n'Place CSV files, Bill of Materials CSV and more","You can import components from [JLCPCB](https://docs.tscircuit.com/guides/importing-modules-and-chips/importing-from-jlcpcb) or [KiCad](https://docs.tscircuit.com/guides/importing-modules-and-chips/importing-from-kicad)","Any module you push to the [registry](https://tscircuit.com/trending) will have [simple image urls](https://docs.tscircuit.com/web-apis/image-generation-api) you can use display images on a website","The default [Parts Engine](https://docs.tscircuit.com/guides/platform-configuration) will automatically find parts from common vendors for your BOM",'[Pin selectors](https://docs.tscircuit.com/guides/using-sel-references) are similar to CSS selectors, ".R1 > .pin1" means "connect to the first pin of the component R1"',"You can use the [sel](https://docs.tscircuit.com/guides/using-sel-references) object to select pins in a type-safe way","Publish modules via the [registry](https://tscircuit.com/trending) for working with a team or sharing your work","[Explore tutorials](https://docs.tscircuit.com/category/tutorials) for real-world circuit design examples.","Upload your Circuit JSON to [circuitjson.com](https://circuitjson.com) for a quick preview.","You can display Circuit JSON in 3D, PCB or Schematic mode with the [<CircuitJsonPreview />](https://docs.tscircuit.com/guides/running-tscircuit/displaying-circuit-json-on-a-webpage#react-display-all-available-previews-with-circuitjsonpreview-) React component","Use a [<group />](https://docs.tscircuit.com/elements/group) element to move multiple components at once in a schematic or PCB layout.","Check out the [GitHub Discussions page](https://github.com/tscircuit/tscircuit/discussions) to upvote features","You can customize the autorouter using the [autorouter prop](https://docs.tscircuit.com/elements/board#setting-the-autorouter)","Use the [<constraint />](https://docs.tscircuit.com/footprints/constraint) element to enforce geometric relationships in PCB designs.","When working on component placement and circuit design, autorouting can slow down your iteration cycle. Use [routingDisabled](https://docs.tscircuit.com/elements/board#disabling-routing-with-routingdisabled) on the <board /> element to disable autorouting temporarily.","Join the [Discord server](https://tscircuit.com/join) to discuss issues and get help directly from the community."],J3t=(()=>{let t=Wse[Math.floor(Math.random()*Wse.length)];return t=t.replace(/</g,"&lt;"),t=t.replace(/>/g,"&gt;"),t=t.replace(new RegExp('(?<!href=")(?<!\\()(?<!\\]\\()(https?:\\/\\/[^\\s\\)\\]]+)',"g"),(A,e)=>`<a class="rf-text-blue-500 rf-underline" href="${A}" target="_blank">${A}</a>`),t=t.replace(/\[([^\]]+)\]\((https?:\/\/[^\)]+)\)/g,'<a class="rf-text-blue-500 rf-underline" href="$2" target="_blank">$1</a>'),t})(),Gb=({onRunClicked:t})=>W.jsxs("div",{className:"rf-flex rf-flex-col rf-items-center rf-justify-center rf-h-full rf-bg-gray-50 rf-text-gray-500 rf-p-4",children:[W.jsx(MNt,{className:"rf-size-14 rf-mb-4"}),W.jsxs("p",{className:"rf-text-md rf-break-words rf-max-w-xl rf-text-center",children:["Tip: ",W.jsx("span",{dangerouslySetInnerHTML:{__html:J3t}})]}),t&&W.jsxs(cg,{className:"rf-mt-4 rf-bg-blue-600 rf-hover:bg-blue-500",onClick:t,children:["Run Code",W.jsx(jAe,{className:"rf-w-3 rf-h-3 rf-ml-2"})]})]}),sV=({text:t,onClick:A})=>W.jsx("span",{className:"rf-cursor-pointer rf-underline rf-text-blue-600 rf-mx-2",onClick:A,children:t}),rV=t=>W.jsxs("div",{className:"rf-leading-5",children:[W.jsx("div",{className:"rf-py-2 rf-font-bold",children:t.column.name}),W.jsx("div",{children:t.field?.()??W.jsx("input",{type:"text",className:"rf-border rf-rounded rf-p-1 rf-w-full",onChange:A=>{t.onTextChange?.(A.target.value)}})})]}),T3t=({open:t,children:A,title:e,onClose:i})=>t?W.jsx("div",{className:"rf-fixed rf-inset-0 rf-bg-black rf-bg-opacity-50 rf-flex rf-justify-center rf-items-center rf-z-50",onClick:i,children:W.jsxs("div",{className:"rf-bg-white rf-p-5 rf-rounded-lg rf-relative rf-w-11/12 rf-max-w-2xl",onClick:n=>{n.preventDefault(),n.stopPropagation()},children:[W.jsx("h2",{className:"rf-mt-0 rf-text-md rf-pb-4",children:e}),W.jsx("button",{type:"button",className:"rf-absolute rf-top-2 rf-right-4 rf-text-2xl rf-font-bold",onClick:i,children:"×"}),A]})}):null,K3t=({elements:t})=>{const[A,e]=V.useState({open:!1}),[i,n]=V.useReducer((c,I)=>({...c,...I}),{}),o=[...new Set(t.map(c=>c.type))],s=t.map(c=>{const I=c[`${c.type}_id`],l=Object.fromEntries(Object.entries(c).filter(([C])=>!(C===`${c.type}_id`||!C.endsWith("_id")))),B=Object.fromEntries(Object.entries(c).filter(([C])=>!C.endsWith("_id")));return{primary_id:I,other_ids:l,...B,_og_elm:c}}),r=s.map(c=>{let I="";const l=B=>{const C=Object.keys(B.other_ids).find(E=>E.startsWith("source_"));if(!C)return`.${B.name}`;const Q=C.slice(0,-3),h=s.find(E=>E.type===Q&&E.primary_id===B.other_ids[C]);return h?"name"in h?`${l(h)} > .${B.name}`:`#${h.primary_id} > .${B.name}`:`??? > .${B.name}`};return"name"in c&&(I=l(c)),{...c,selector_path:I}}),a=[{key:"primary_id",name:"primary_id",renderCell:c=>W.jsxs("div",{className:"rf-flex rf-items-center",children:[W.jsx(sV,{text:c.primary_id,onClick:()=>n({focused_id:c.primary_id,id_search:void 0,selector_search:void 0})}),W.jsx("span",{className:"rf-flex-grow"}),W.jsx(sV,{text:"(JSON)",onClick:()=>e({open:!0,element:c._og_elm,title:c.primary_id})})]}),renderHeaderCell:c=>W.jsx(rV,{column:c,onTextChange:I=>n({id_search:I}),field:i.focused_id?()=>W.jsxs("div",{children:["Focus:"," ",W.jsx("span",{className:"rf-underline",children:i.focused_id}),W.jsx(sV,{text:"(unfocus)",onClick:()=>n({focused_id:void 0})})]}):void 0})},{key:"type",name:"type",renderHeaderCell:c=>W.jsx(rV,{column:c,field:()=>W.jsxs("select",{onChange:I=>n({component_type_filter:I.target.value}),className:"rf-border rf-rounded rf-p-1 rf-w-full",children:[W.jsx("option",{value:"any",children:"any"},"any"),W.jsx("option",{value:"source",children:"source"},"source"),W.jsx("option",{value:"source/pcb",children:"source/pcb"},"source/pcb"),W.jsx("option",{value:"source/schematic",children:"source/schematic"},"source/schematic"),o.map(I=>W.jsx("option",{value:I,children:I},I))]})})},{key:"name",name:"name",renderHeaderCell:c=>W.jsx(rV,{column:c,onTextChange:I=>n({name_search:I})})},{key:"selector_path",name:"selector_path",renderHeaderCell:c=>W.jsx(rV,{column:c,onTextChange:I=>n({selector_search:I})})},{key:"other_ids",name:"other_ids",renderCell:c=>W.jsx("div",{className:"rf-space-x-2",children:Object.entries(c.other_ids).map(([I,l])=>W.jsx(sV,{text:l,onClick:()=>n({focused_id:l})},l))})}],g=r.filter(c=>i.name_search?c.name?.toLowerCase()?.includes(i.name_search.toLowerCase()):!0).filter(c=>!i.component_type_filter||i.component_type_filter==="any"?!0:i.component_type_filter==="source"?c.type.startsWith("source_"):i.component_type_filter==="source/pcb"?c.type.startsWith("source_")||c.type.startsWith("pcb_"):i.component_type_filter==="source/schematic"?c.type.startsWith("source_")||c.type.startsWith("schematic_"):c.type?.includes(i.component_type_filter)).filter(c=>i.selector_search?i.selector_search.split(" ").filter(l=>l.length>0).every(l=>c.selector_path?.includes(l)):!0).filter(c=>i.id_search?c.primary_id?.includes(i.id_search):!0).filter(c=>!!(!i.focused_id||c.primary_id===i.focused_id||Object.values(c.other_ids).includes(i.focused_id)));return W.jsxs("div",{className:"rf-font-mono rf-text-xs rf-bg-white",children:[W.jsx("div",{className:"rf-overflow-x-auto",children:W.jsxs("table",{className:"rf-table-auto rf-w-full rf-text-left",children:[W.jsx("thead",{children:W.jsx("tr",{children:a.map(c=>W.jsx("th",{className:"rf-px-4 rf-py-2 rf-border-b",children:c.renderHeaderCell?c.renderHeaderCell(c):c.name},c.key))})}),W.jsx("tbody",{children:g.map((c,I)=>W.jsx("tr",{className:"rf-hover:bg-gray-100",children:a.map(l=>W.jsx("td",{className:"rf-px-4 rf-py-2 rf-border-b",children:l.renderCell?l.renderCell(c):c[l.key]},l.key))},I))})]})}),W.jsx(T3t,{open:A.open,onClose:()=>e({open:!1}),title:A.open?A.title:"",children:W.jsx("div",{className:"rf-bg-gray-800 rf-p-3 rf-text-white rf-rounded",children:W.jsx("pre",{className:"rf-whitespace-pre-wrap",children:A.open?JSON.stringify(A.element,null,2):""})})})]})},P3t=(t,A)=>t==="jlcpcb"?W.jsx("a",{className:"rf-underline rf-text-blue-500",target:"_blank",rel:"noreferrer",href:`https://jlcpcb.com/partdetail/${A}`,children:A}):A,q3t=({circuitJson:t})=>{const A=t.filter(i=>i.type==="source_component"),e=new Set;for(const i of A)if(i.supplier_part_numbers)for(const n of Object.keys(i.supplier_part_numbers))e.add(n);return W.jsx("div",{className:"rf-overflow-x-auto",children:W.jsxs("table",{className:"rf-w-full rf-text-left rf-text-sm",children:[W.jsx("thead",{children:W.jsxs("tr",{className:"rf-border-b",children:[W.jsx("th",{className:"rf-p-2",children:"Name"}),Array.from(e).map(i=>W.jsx("th",{className:"rf-p-2 rf-capitalize",children:i},i))]})}),W.jsx("tbody",{children:A.map(i=>W.jsxs("tr",{className:"rf-border-b",children:[W.jsx("td",{className:"rf-p-2",children:i.name}),Array.from(e).map(n=>W.jsx("td",{className:"rf-p-2",children:P3t(n,i.supplier_part_numbers?.[n]?.[0]||"")},n))]},i.source_component_id))})]})})},xpA=V.forwardRef(({className:t,type:A,...e},i)=>W.jsx("input",{type:A,className:kn("rf-flex rf-h-9 rf-w-full rf-rounded-md rf-border rf-border-zinc-200 rf-bg-white rf-px-3 rf-py-1 rf-text-sm rf-shadow-sm rf-transition-colors file:rf-border-0 file:rf-bg-transparent file:rf-text-sm file:rf-font-medium placeholder:rf-text-zinc-500 focus-visible:rf-outline-none focus-visible:rf-ring-1 focus-visible:rf-ring-zinc-950 disabled:rf-cursor-not-allowed disabled:rf-opacity-50 dark:rf-border-zinc-800 dark:rf-bg-zinc-950 dark:rf-placeholder-zinc-400 dark:focus-visible:rf-ring-zinc-300",t),ref:i,...e}));xpA.displayName="Input";var Zse={Hz:{baseUnit:"Hz",variants:{MHz:1e6,kHz:1e3,Hz:1}},g:{baseUnit:"g",variants:{kg:1e3,g:1}},Ω:{baseUnit:"Ω",variants:{mΩ:.001,Ω:1,kΩ:1e3,KΩ:1e3,kohm:1e3,MΩ:1e6,GΩ:1e9,TΩ:1e12}},V:{baseUnit:"V",variants:{mV:.001,V:1,kV:1e3,KV:1e3,MV:1e6,GV:1e9,TV:1e12}},A:{baseUnit:"A",variants:{µA:1e-6,mA:.001,ma:.001,A:1,kA:1e3,MA:1e6}},F:{baseUnit:"F",variants:{pF:1e-12,nF:1e-9,µF:1e-6,uF:1e-6,mF:.001,F:1}},ml:{baseUnit:"ml",variants:{ml:1,mL:1,l:1e3,L:1e3}},deg:{baseUnit:"deg",variants:{rad:180/Math.PI}},ms:{baseUnit:"ms",variants:{fs:1e-12,ps:1e-9,ns:1e-6,us:.001,µs:.001,ms:1,s:1e3}},mm:{baseUnit:"mm",variants:{nm:1e-6,µm:.001,um:.001,mm:1,cm:10,dm:100,m:1e3,km:1e6,in:25.4,ft:304.8,IN:25.4,FT:304.8,yd:914.4,mi:1609344,mil:.0254}}},_pA=new Set;for(const[t,A]of Object.entries(Zse)){_pA.add(t);for(const e of Object.keys(A.variants))_pA.add(e)}function O3t(t){for(const[A,e]of Object.entries(Zse))if(t in e.variants)return{baseUnit:e.baseUnit,conversionFactor:e.variants[t]};return{baseUnit:t,conversionFactor:1}}var Vse={tera:1e12,T:1e12,giga:1e9,G:1e9,mega:1e6,M:1e6,kilo:1e3,k:1e3,deci:.1,d:.1,centi:.01,c:.01,milli:.001,m:.001,micro:1e-6,u:1e-6,µ:1e-6,nano:1e-9,n:1e-9,pico:1e-12,p:1e-12};function ww(t){if(t==null)return{parsedUnit:null,unitOfValue:null,value:null};if(typeof t=="string"&&t.match(/^-?[\d\.]+$/))return{value:Number.parseFloat(t),parsedUnit:null,unitOfValue:null};if(typeof t=="number")return{value:t,parsedUnit:null,unitOfValue:null};if(typeof t=="object"&&"x"in t&&"y"in t){const{parsedUnit:r,unitOfValue:a}=ww(t.x),g=ww(t.x),c=ww(t.y);return g.value===null||c.value===null?{parsedUnit:null,unitOfValue:null,value:null}:{parsedUnit:r,unitOfValue:a,value:{x:g.value,y:c.value}}}const e=t.toString().split("").reverse().join("").match(/[^\d\s]+/)?.[0];if(!e)throw new Error(`Could not determine unit: "${t}"`);const i=e.split("").reverse().join(""),n=t.slice(0,-i.length);if(i in Vse&&!_pA.has(i)){const r=Vse[i];return{parsedUnit:null,unitOfValue:null,value:Number.parseFloat(n)*r}}const{baseUnit:o,conversionFactor:s}=O3t(i);return{parsedUnit:i,unitOfValue:o,value:s*Number.parseFloat(n)}}var aV=H().or(zA()).transform(t=>ww(t).value),kpA=H().or(zA()).transform(t=>ww(t).value).transform(t=>Number.parseFloat(t.toPrecision(12))),jse=H().or(zA()).transform(t=>ww(t).value),Rb=H().or(zA()).transform(t=>ww(t).value),Qn=H().or(zA()).transform(t=>ww(t).value),Lv=H().or(zA()).transform(t=>ww(t).value),_t=Qn,c1=H().or(zA()).transform(t=>ww(t).value),aJ=H().or(zA()).transform(t=>ww(t).value),W3t=aJ,Uv=aJ,zse=H().datetime(),xQ=H().or(zA()).transform(t=>typeof t=="number"?t:t.endsWith("deg")?Number.parseFloat(t.split("deg")[0]):t.endsWith("rad")?Number.parseFloat(t.split("rad")[0])*180/Math.PI:Number.parseFloat(t)),Xse=zA().or(H().endsWith("mAh")).transform(t=>{if(typeof t=="string"){const A=t.replace("mAh",""),e=Number.parseFloat(A);if(Number.isNaN(e))throw new Error("Invalid capacity");return e}return t}).describe("Battery capacity in mAh"),vn=Ae({x:_t,y:_t}),Z3t=vn,ik=Ae({x:_t,y:_t,z:_t}),V3t=ik,FpA=Ae({width:zA(),height:zA()}),j3t=t=>{const A="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";return Array.from({length:t},()=>A[Math.floor(Math.random()*A.length)]).join("")},oi=t=>H().optional().default(()=>`${t}_${j3t(10)}`),nk=pt(["top_left","top_center","top_right","center_left","center","center_right","bottom_left","bottom_center","bottom_right"]),z3t=pt(["top_silkscreen","bottom_silkscreen","top_copper","bottom_copper","top_soldermask","bottom_soldermask","top_fabrication_note","bottom_fabrication_note","top_user_note","bottom_user_note","top_courtyard","bottom_courtyard","inner1_copper","inner2_copper","inner3_copper","inner4_copper","inner5_copper","inner6_copper","edge_cuts","drill"]),$se=Ae({project_relative_path:H(),url:H(),mimetype:H()}),gV=vn.extend({rotation:xQ.optional()}),vpA=Ae({size:vn.optional(),thickness:_t.optional()}),Are=Ae({font:vpA.optional()}),gJ=Ae({value:H(),at:gV.optional(),layer:H().optional(),uuid:H().optional(),hide:ce().optional(),effects:Are.optional()}),ere=Ae({Reference:gJ.optional(),Value:gJ.optional(),Datasheet:gJ.optional(),Description:gJ.optional()}),tre=Ae({through_hole:ce().optional(),smd:ce().optional(),exclude_from_pos_files:ce().optional(),exclude_from_bom:ce().optional()}),ire=Ae({name:H(),type:H(),shape:H().optional(),at:gV.optional(),size:vn.optional(),drill:_t.optional(),layers:Ge(H()).optional(),removeUnusedLayers:ce().optional(),uuid:H().optional()}),nre=Ae({path:H(),offset:ik.optional(),scale:ik.optional(),rotate:ik.optional()}),ore=Ae({footprintName:H().optional(),version:ii([zA(),H()]).optional(),generator:H().optional(),generatorVersion:ii([zA(),H()]).optional(),layer:H().optional(),properties:ere.optional(),attributes:tre.optional(),pads:Ge(ire).optional(),embeddedFonts:ce().optional(),model:nre.optional()}),sre=Ae({hide:ce().optional()}),rre=Ae({offset:_t.optional(),hide:ce().optional()}),are=Ae({font:vpA.optional(),justify:ii([H(),Ge(H())]).optional(),hide:ce().optional()}),ok=Ae({value:H(),id:ii([zA(),H()]).optional(),at:gV.optional(),effects:are.optional()}),gre=Ae({Reference:ok.optional(),Value:ok.optional(),Footprint:ok.optional(),Datasheet:ok.optional(),Description:ok.optional(),ki_keywords:ok.optional(),ki_fp_filters:ok.optional()}),cre=Ae({symbolName:H().optional(),extends:H().optional(),pinNumbers:sre.optional(),pinNames:rre.optional(),excludeFromSim:ce().optional(),inBom:ce().optional(),onBoard:ce().optional(),properties:gre.optional(),embeddedFonts:ce().optional()}),Cl=Ae({error_type:H(),message:H(),is_fatal:ce().optional()}),Ire=pt(["jlcpcb","macrofab","pcbway","digikey","mouser","lcsc"]),kI=Ae({type:GA("source_component"),ftype:H().optional(),source_component_id:H(),name:H(),manufacturer_part_number:H().optional(),supplier_part_numbers:og(Ire,Ge(H())).optional(),display_value:H().optional(),display_name:H().optional(),are_pins_interchangeable:ce().optional(),internally_connected_source_port_ids:Ge(Ge(H())).optional(),source_group_id:H().optional(),subcircuit_id:H().optional()}),GpA=kI.extend({ftype:GA("simple_capacitor"),capacitance:kpA,max_voltage_rating:Rb.optional(),display_capacitance:H().optional(),max_decoupling_trace_length:_t.optional()}),RpA=kI.extend({ftype:GA("simple_resistor"),resistance:aV,display_resistance:H().optional()}),cV=kI.extend({ftype:GA("simple_diode")}),lre=kI.extend({ftype:GA("simple_fiducial")}),NpA=cV.extend({ftype:GA("simple_led"),color:H().optional(),wavelength:H().optional()}),Bre=kI.extend({ftype:GA("simple_ground")}),MpA=kI.extend({ftype:GA("simple_chip")}),LpA=kI.extend({ftype:GA("simple_power_source"),voltage:Rb}),Cre=kI.extend({ftype:GA("simple_current_source"),current:c1,frequency:Lv.optional(),peak_to_peak_current:c1.optional(),wave_shape:pt(["sine","square","triangle","sawtooth","dc"]).optional().default("dc"),phase:zA().optional(),duty_cycle:zA().min(0).max(1).optional()}),X3t=kI.extend({ftype:GA("simple_fuse"),current_rating_amps:zA().describe("Nominal current in amps the fuse is rated for"),voltage_rating_volts:zA().describe("Voltage rating in volts, e.g. ±5V would be 5")}),UpA=kI.extend({ftype:GA("simple_battery"),capacity:Xse}),HpA=kI.extend({ftype:GA("simple_inductor"),inductance:jse,max_current_rating:zA().optional()}),YpA=kI.extend({ftype:GA("simple_push_button")}),JpA=kI.extend({ftype:GA("simple_potentiometer"),max_resistance:aV,display_max_resistance:H().optional()}),Qre=kI.extend({ftype:GA("simple_crystal"),frequency:zA().describe("Frequency in Hz"),load_capacitance:zA().optional().describe("Load capacitance in pF"),pin_variant:pt(["two_pin","four_pin"]).optional()}),TpA=kI.extend({ftype:GA("simple_pin_header"),pin_count:zA(),gender:pt(["male","female"]).optional().default("male")}),KpA=kI.extend({ftype:GA("simple_pinout")}),PpA=kI.extend({ftype:GA("simple_resonator"),load_capacitance:kpA,equivalent_series_resistance:aV.optional(),frequency:Lv}),qpA=kI.extend({ftype:GA("simple_transistor"),transistor_type:pt(["npn","pnp"])}),OpA=kI.extend({ftype:GA("simple_test_point"),footprint_variant:pt(["pad","through_hole"]).optional(),pad_shape:pt(["rect","circle"]).optional(),pad_diameter:ii([zA(),H()]).optional(),hole_diameter:ii([zA(),H()]).optional(),width:ii([zA(),H()]).optional(),height:ii([zA(),H()]).optional()}),WpA=kI.extend({ftype:GA("simple_mosfet"),channel_type:pt(["n","p"]),mosfet_mode:pt(["enhancement","depletion"])}),ZpA=kI.extend({ftype:GA("simple_op_amp")}),VpA=kI.extend({ftype:GA("simple_switch")}),jpA=Ae({type:GA("source_project_metadata"),name:H().optional(),software_used_string:H().optional(),project_url:H().optional(),created_at:zse.optional()}),hre=Cl.extend({type:GA("source_missing_property_error"),source_missing_property_error_id:oi("source_missing_property_error"),source_component_id:H(),property_name:H(),subcircuit_id:H().optional(),error_type:GA("source_missing_property_error").default("source_missing_property_error")}).describe("The source code is missing a property"),Ere=Cl.extend({type:GA("source_failed_to_create_component_error"),source_failed_to_create_component_error_id:oi("source_failed_to_create_component_error"),error_type:GA("source_failed_to_create_component_error").default("source_failed_to_create_component_error"),component_name:H().optional(),subcircuit_id:H().optional(),parent_source_component_id:H().optional(),pcb_center:Ae({x:zA().optional(),y:zA().optional()}).optional(),schematic_center:Ae({x:zA().optional(),y:zA().optional()}).optional()}).describe("Error emitted when a component fails to be constructed"),zpA=Cl.extend({type:GA("source_trace_not_connected_error"),source_trace_not_connected_error_id:oi("source_trace_not_connected_error"),error_type:GA("source_trace_not_connected_error").default("source_trace_not_connected_error"),subcircuit_id:H().optional(),source_group_id:H().optional(),source_trace_id:H().optional(),connected_source_port_ids:Ge(H()).optional(),selectors_not_found:Ge(H()).optional()}).describe("Occurs when a source trace selector does not match any ports"),ure=Ae({type:GA("source_property_ignored_warning"),source_property_ignored_warning_id:oi("source_property_ignored_warning"),source_component_id:H(),property_name:H(),subcircuit_id:H().optional(),error_type:GA("source_property_ignored_warning").default("source_property_ignored_warning"),message:H()}).describe("The source property was ignored"),XpA=Ae({type:GA("source_pin_missing_trace_warning"),source_pin_missing_trace_warning_id:oi("source_pin_missing_trace_warning"),warning_type:GA("source_pin_missing_trace_warning").default("source_pin_missing_trace_warning"),message:H(),source_component_id:H(),source_port_id:H(),subcircuit_id:H().optional()}).describe("Warning emitted when a source component pin is missing a trace connection"),dre=kI.extend({ftype:GA("simple_voltage_probe")}),pre=kI.extend({ftype:GA("interconnect")}),$pA=Cl.extend({type:GA("source_i2c_misconfigured_error"),source_i2c_misconfigured_error_id:oi("source_i2c_misconfigured_error"),error_type:GA("source_i2c_misconfigured_error").default("source_i2c_misconfigured_error"),source_port_ids:Ge(H())}).describe("Error emitted when incompatible I2C pins (e.g. SDA and SCL) are connected to the same net"),fre=kI.extend({ftype:GA("simple_voltage_source"),voltage:Rb,frequency:Lv.optional(),peak_to_peak_voltage:Rb.optional(),wave_shape:pt(["sinewave","square","triangle","sawtooth"]).optional(),phase:xQ.optional(),duty_cycle:zA().optional().describe("Duty cycle as a fraction (0 to 1)")}),yre=ii([RpA,GpA,cV,lre,NpA,Bre,MpA,LpA,Cre,UpA,HpA,YpA,JpA,Qre,TpA,KpA,PpA,VpA,qpA,OpA,WpA,ZpA,X3t,dre,pre,fre,jpA,hre,Ere,zpA,ure,XpA,$pA]),mre=Ae({type:GA("source_port"),pin_number:zA().optional(),port_hints:Ge(H()).optional(),name:H(),source_port_id:H(),source_component_id:H().optional(),source_group_id:H().optional(),most_frequently_referenced_by_name:H().optional(),subcircuit_id:H().optional(),subcircuit_connectivity_map_key:H().optional(),must_be_connected:ce().optional(),is_configured_for_i2c_sda:ce().optional(),is_configured_for_i2c_scl:ce().optional(),is_configured_for_spi_mosi:ce().optional(),is_configured_for_spi_miso:ce().optional(),is_configured_for_spi_sck:ce().optional(),is_configured_for_spi_cs:ce().optional(),is_configured_for_uart_tx:ce().optional(),is_configured_for_uart_rx:ce().optional(),supports_i2c_sda:ce().optional(),supports_i2c_scl:ce().optional(),supports_spi_mosi:ce().optional(),supports_spi_miso:ce().optional(),supports_spi_sck:ce().optional(),supports_spi_cs:ce().optional(),supports_uart_tx:ce().optional(),supports_uart_rx:ce().optional()}),wre=Ae({type:GA("source_component_internal_connection"),source_component_internal_connection_id:H(),source_component_id:H(),source_port_ids:Ge(H()),subcircuit_id:H().optional()}),Dre=Ae({type:GA("source_trace"),source_trace_id:H(),connected_source_port_ids:Ge(H()),connected_source_net_ids:Ge(H()),subcircuit_id:H().optional(),subcircuit_connectivity_map_key:H().optional(),max_length:zA().optional(),min_trace_thickness:zA().optional(),display_name:H().optional()}),Sre=Ae({type:GA("source_group"),source_group_id:H(),subcircuit_id:H().optional(),parent_subcircuit_id:H().optional(),parent_source_group_id:H().optional(),is_subcircuit:ce().optional(),show_as_schematic_box:ce().optional(),name:H().optional(),was_automatically_named:ce().optional()}),bre=Ae({type:GA("source_net"),source_net_id:H(),name:H(),member_source_group_ids:Ge(H()),is_power:ce().optional(),is_ground:ce().optional(),is_digital_signal:ce().optional(),is_analog_signal:ce().optional(),is_positive_voltage_source:ce().optional(),trace_width:zA().optional(),subcircuit_id:H().optional(),subcircuit_connectivity_map_key:H().optional()}),xre=Ae({type:GA("source_board"),source_board_id:H(),source_group_id:H(),title:H().optional()}).describe("Defines a board in the source domain"),_re=Ae({type:GA("source_pcb_ground_plane"),source_pcb_ground_plane_id:H(),source_group_id:H(),source_net_id:H(),subcircuit_id:H().optional()}).describe("Defines a ground plane in the source domain"),kre=["top","bottom","inner1","inner2","inner3","inner4","inner5","inner6"],AfA=pt(kre),oa=AfA.or(Ae({name:AfA})).transform(t=>typeof t=="string"?t:t.name),um=pt(["top","bottom"]),Fre=Ae({type:GA("source_manually_placed_via"),source_manually_placed_via_id:H(),source_group_id:H(),source_net_id:H(),subcircuit_id:H().optional(),source_trace_id:H().optional()}).describe("Defines a via that is manually placed in the source domain"),vre=Cl.extend({type:GA("source_pin_must_be_connected_error"),source_pin_must_be_connected_error_id:oi("source_pin_must_be_connected_error"),error_type:GA("source_pin_must_be_connected_error").default("source_pin_must_be_connected_error"),source_component_id:H(),source_port_id:H(),subcircuit_id:H().optional()}).describe("Error emitted when a pin with mustBeConnected attribute is not connected to any trace"),Gre=Cl.extend({type:GA("unknown_error_finding_part"),unknown_error_finding_part_id:oi("unknown_error_finding_part"),error_type:GA("unknown_error_finding_part").default("unknown_error_finding_part"),source_component_id:H().optional(),subcircuit_id:H().optional()}).describe("Error emitted when an unexpected error occurs while finding a part"),Rre=Ae({type:GA("schematic_box"),schematic_component_id:H().optional(),schematic_symbol_id:H().optional(),width:_t,height:_t,is_dashed:ce().default(!1),x:_t,y:_t,subcircuit_id:H().optional()}).describe("Draws a box on the schematic"),Nre=Ae({type:GA("schematic_path"),schematic_path_id:oi("schematic_path"),schematic_component_id:H().optional(),schematic_symbol_id:H().optional(),fill_color:H().optional(),is_filled:ce().optional(),stroke_width:_t.nullable().optional(),stroke_color:H().optional(),points:Ge(vn),subcircuit_id:H().optional()}),Mre=og(Ae({left_margin:Qn.optional(),right_margin:Qn.optional(),top_margin:Qn.optional(),bottom_margin:Qn.optional()})),Lre=Ae({left_size:zA(),right_size:zA(),top_size:zA().optional(),bottom_size:zA().optional()}),Ure=Ae({left_side:Ae({pins:Ge(zA()),direction:pt(["top-to-bottom","bottom-to-top"]).optional()}).optional(),right_side:Ae({pins:Ge(zA()),direction:pt(["top-to-bottom","bottom-to-top"]).optional()}).optional(),top_side:Ae({pins:Ge(zA()),direction:pt(["left-to-right","right-to-left"]).optional()}).optional(),bottom_side:Ae({pins:Ge(zA()),direction:pt(["left-to-right","right-to-left"]).optional()}).optional()}),Hre=ii([Lre,Ure]),Yre=Ae({type:GA("schematic_component"),size:FpA,center:vn,source_component_id:H().optional(),schematic_component_id:H(),schematic_symbol_id:H().optional(),pin_spacing:Qn.optional(),pin_styles:Mre.optional(),box_width:Qn.optional(),symbol_name:H().optional(),port_arrangement:Hre.optional(),port_labels:og(H()).optional(),symbol_display_value:H().optional(),subcircuit_id:H().optional(),schematic_group_id:H().optional(),is_schematic_group:ce().optional(),source_group_id:H().optional(),is_box_with_pins:ce().optional().default(!0)}),$3t=Ae({kicad_symbol:cre.optional()}).catchall(IxA()),Jre=Ae({type:GA("schematic_symbol"),schematic_symbol_id:H(),name:H().optional(),metadata:$3t.optional()}).describe("Defines a named schematic symbol that can be referenced by components."),Tre=Ae({type:GA("schematic_line"),schematic_line_id:oi("schematic_line"),schematic_component_id:H().optional(),schematic_symbol_id:H().optional(),x1:_t,y1:_t,x2:_t,y2:_t,stroke_width:_t.nullable().optional(),color:H().default("#000000"),is_dashed:ce().default(!1),subcircuit_id:H().optional()}).describe("Draws a styled line on the schematic"),Kre=Ae({type:GA("schematic_rect"),schematic_rect_id:oi("schematic_rect"),schematic_component_id:H().optional(),schematic_symbol_id:H().optional(),center:vn,width:_t,height:_t,rotation:xQ.default(0),stroke_width:_t.nullable().optional(),color:H().default("#000000"),is_filled:ce().default(!1),fill_color:H().optional(),is_dashed:ce().default(!1),subcircuit_id:H().optional()}).describe("Draws a styled rectangle on the schematic"),Pre=Ae({type:GA("schematic_circle"),schematic_circle_id:oi("schematic_circle"),schematic_component_id:H().optional(),schematic_symbol_id:H().optional(),center:vn,radius:_t,stroke_width:_t.nullable().optional(),color:H().default("#000000"),is_filled:ce().default(!1),fill_color:H().optional(),is_dashed:ce().default(!1),subcircuit_id:H().optional()}).describe("Draws a styled circle on the schematic"),qre=Ae({type:GA("schematic_arc"),schematic_arc_id:oi("schematic_arc"),schematic_component_id:H().optional(),schematic_symbol_id:H().optional(),center:vn,radius:_t,start_angle_degrees:xQ,end_angle_degrees:xQ,direction:pt(["clockwise","counterclockwise"]).default("counterclockwise"),stroke_width:_t.nullable().optional(),color:H().default("#000000"),is_dashed:ce().default(!1),subcircuit_id:H().optional()}).describe("Draws a styled arc on the schematic"),Ore=Ae({type:GA("schematic_trace"),schematic_trace_id:H(),source_trace_id:H().optional(),junctions:Ge(Ae({x:zA(),y:zA()})),edges:Ge(Ae({from:Ae({x:zA(),y:zA()}),to:Ae({x:zA(),y:zA()}),is_crossing:ce().optional(),from_schematic_port_id:H().optional(),to_schematic_port_id:H().optional()})),subcircuit_id:H().optional(),subcircuit_connectivity_map_key:H().optional()}),AOt=pt(["center","left","right","top","bottom"]),Wre=Ae({type:GA("schematic_text"),schematic_component_id:H().optional(),schematic_symbol_id:H().optional(),schematic_text_id:H(),text:H(),font_size:zA().default(.18),position:Ae({x:_t,y:_t}),rotation:zA().default(0),anchor:ii([AOt.describe("legacy"),nk]).default("center"),color:H().default("#000000"),subcircuit_id:H().optional()}),Zre=Ae({type:GA("schematic_port"),schematic_port_id:H(),source_port_id:H(),schematic_component_id:H().optional(),center:vn,facing_direction:pt(["up","down","left","right"]).optional(),distance_from_component_edge:zA().optional(),side_of_component:pt(["top","bottom","left","right"]).optional(),true_ccw_index:zA().optional(),pin_number:zA().optional(),display_pin_label:H().optional(),subcircuit_id:H().optional(),is_connected:ce().optional(),has_input_arrow:ce().optional(),has_output_arrow:ce().optional(),is_drawn_with_inversion_circle:ce().optional()}).describe("Defines a port on a schematic component"),Vre=Ae({type:GA("schematic_net_label"),schematic_net_label_id:oi("schematic_net_label"),schematic_trace_id:H().optional(),source_trace_id:H().optional(),source_net_id:H(),center:vn,anchor_position:vn.optional(),anchor_side:pt(["top","bottom","left","right"]),text:H(),symbol_name:H().optional(),is_movable:ce().optional(),subcircuit_id:H().optional()}),jre=Cl.extend({type:GA("schematic_error"),schematic_error_id:H(),error_type:GA("schematic_port_not_found").default("schematic_port_not_found"),subcircuit_id:H().optional()}).describe("Defines a schematic error on the schematic"),zre=Cl.extend({type:GA("schematic_layout_error"),schematic_layout_error_id:oi("schematic_layout_error"),error_type:GA("schematic_layout_error").default("schematic_layout_error"),source_group_id:H(),schematic_group_id:H(),subcircuit_id:H().optional()}).describe("Error emitted when schematic layout fails for a group"),IV=Ae({type:GA("schematic_debug_object"),label:H().optional(),subcircuit_id:H().optional()}),Xre=IV.extend({shape:GA("rect"),center:vn,size:FpA}),$re=IV.extend({shape:GA("line"),start:vn,end:vn}),Aae=IV.extend({shape:GA("point"),center:vn}),eae=df("shape",[Xre,$re,Aae]),tae=Ae({type:GA("schematic_voltage_probe"),schematic_voltage_probe_id:H(),source_component_id:H().optional(),name:H().optional(),position:vn,schematic_trace_id:H(),voltage:Rb.optional(),subcircuit_id:H().optional(),color:H().optional(),label_alignment:nk.optional()}).describe("Defines a voltage probe measurement point on a schematic trace"),iae=Ae({type:GA("schematic_manual_edit_conflict_warning"),schematic_manual_edit_conflict_warning_id:oi("schematic_manual_edit_conflict_warning"),warning_type:GA("schematic_manual_edit_conflict_warning").default("schematic_manual_edit_conflict_warning"),message:H(),schematic_component_id:H(),schematic_group_id:H().optional(),subcircuit_id:H().optional(),source_component_id:H()}).describe("Warning emitted when a component has both manual placement and explicit schX/schY coordinates"),nae=Ae({type:GA("schematic_group"),schematic_group_id:oi("schematic_group"),source_group_id:H(),is_subcircuit:ce().optional(),subcircuit_id:H().optional(),width:Qn,height:Qn,center:vn,schematic_component_ids:Ge(H()),show_as_schematic_box:ce().optional(),name:H().optional(),description:H().optional()}).describe("Defines a group of components on the schematic"),oae=Ae({type:GA("schematic_table"),schematic_table_id:oi("schematic_table"),anchor_position:vn,column_widths:Ge(_t),row_heights:Ge(_t),cell_padding:_t.optional(),border_width:_t.optional(),subcircuit_id:H().optional(),schematic_component_id:H().optional(),anchor:nk.optional()}).describe("Defines a table on the schematic"),sae=Ae({type:GA("schematic_table_cell"),schematic_table_cell_id:oi("schematic_table_cell"),schematic_table_id:H(),start_row_index:zA(),end_row_index:zA(),start_column_index:zA(),end_column_index:zA(),text:H().optional(),center:vn,width:_t,height:_t,horizontal_align:pt(["left","center","right"]).optional(),vertical_align:pt(["top","middle","bottom"]).optional(),font_size:_t.optional(),subcircuit_id:H().optional()}).describe("Defines a cell within a schematic_table"),rae=Ae({type:GA("schematic_sheet"),schematic_sheet_id:oi("schematic_sheet"),name:H().optional(),subcircuit_id:H().optional()}).describe("Defines a schematic sheet or page that components can be placed on"),aae=Ae({x:_t,y:_t,bulge:zA().optional()}),efA=Ae({vertices:Ge(aae)}),gae=Ae({outer_ring:efA,inner_rings:Ge(efA).default([])}),cae=Ae({x:_t,y:_t,via:ce().optional(),via_to_layer:oa.optional()}),eOt=Ge(cae),Iae=Ae({x:_t,y:_t,via:ce().optional(),to_layer:oa.optional(),trace_width:_t.optional()}),lae=Ae({type:GA("pcb_component"),pcb_component_id:oi("pcb_component"),source_component_id:H(),center:vn,layer:oa,rotation:xQ,display_offset_x:H().optional().describe("How to display the x offset for this part, usually corresponding with how the user specified it"),display_offset_y:H().optional().describe("How to display the y offset for this part, usually corresponding with how the user specified it"),width:Qn,height:Qn,do_not_place:ce().optional(),is_allowed_to_be_off_board:ce().optional(),subcircuit_id:H().optional(),pcb_group_id:H().optional(),position_mode:pt(["packed","relative_to_group_anchor","none"]).optional(),positioned_relative_to_pcb_group_id:H().optional(),positioned_relative_to_pcb_board_id:H().optional(),metadata:Ae({kicad_footprint:ore.optional()}).optional(),obstructs_within_bounds:ce().default(!0).describe("Does this component take up all the space within its bounds on a layer. This is generally true except for when separated pin headers are being represented by a single component (in which case, chips can be placed between the pin headers) or for tall modules where chips fit underneath")}).describe("Defines a component on the PCB"),Bae=Ae({type:GA("pcb_hole"),pcb_hole_id:oi("pcb_hole"),pcb_group_id:H().optional(),subcircuit_id:H().optional(),pcb_component_id:H().optional(),hole_shape:GA("circle"),hole_diameter:zA(),x:_t,y:_t,is_covered_with_solder_mask:ce().optional(),soldermask_margin:zA().optional()}),tOt=Bae.describe("Defines a circular hole on the PCB"),Cae=Ae({type:GA("pcb_hole"),pcb_hole_id:oi("pcb_hole"),pcb_group_id:H().optional(),subcircuit_id:H().optional(),pcb_component_id:H().optional(),hole_shape:GA("rect"),hole_width:zA(),hole_height:zA(),x:_t,y:_t,is_covered_with_solder_mask:ce().optional(),soldermask_margin:zA().optional()}),iOt=Cae.describe("Defines a rectangular (square-capable) hole on the PCB. Use equal width/height for square."),Qae=Ae({type:GA("pcb_hole"),pcb_hole_id:oi("pcb_hole"),pcb_group_id:H().optional(),subcircuit_id:H().optional(),pcb_component_id:H().optional(),hole_shape:pt(["circle","square"]),hole_diameter:zA(),x:_t,y:_t,is_covered_with_solder_mask:ce().optional(),soldermask_margin:zA().optional()}),nOt=Qae.describe("Defines a circular or square hole on the PCB"),hae=Ae({type:GA("pcb_hole"),pcb_hole_id:oi("pcb_hole"),pcb_group_id:H().optional(),subcircuit_id:H().optional(),pcb_component_id:H().optional(),hole_shape:GA("oval"),hole_width:zA(),hole_height:zA(),x:_t,y:_t,is_covered_with_solder_mask:ce().optional(),soldermask_margin:zA().optional()}),oOt=hae.describe("Defines an oval hole on the PCB"),Eae=Ae({type:GA("pcb_hole"),pcb_hole_id:oi("pcb_hole"),pcb_group_id:H().optional(),subcircuit_id:H().optional(),pcb_component_id:H().optional(),hole_shape:GA("pill"),hole_width:zA(),hole_height:zA(),x:_t,y:_t,is_covered_with_solder_mask:ce().optional(),soldermask_margin:zA().optional()}),sOt=Eae.describe("Defines a pill-shaped hole on the PCB"),uae=Ae({type:GA("pcb_hole"),pcb_hole_id:oi("pcb_hole"),pcb_group_id:H().optional(),subcircuit_id:H().optional(),pcb_component_id:H().optional(),hole_shape:GA("rotated_pill"),hole_width:zA(),hole_height:zA(),x:_t,y:_t,ccw_rotation:xQ,is_covered_with_solder_mask:ce().optional(),soldermask_margin:zA().optional()}),rOt=uae.describe("Defines a rotated pill-shaped hole on the PCB"),dae=Qae.or(hae).or(Eae).or(uae).or(Bae).or(Cae),aOt=Ae({type:GA("pcb_plated_hole"),shape:GA("circle"),pcb_group_id:H().optional(),subcircuit_id:H().optional(),outer_diameter:zA(),hole_diameter:zA(),is_covered_with_solder_mask:ce().optional(),x:_t,y:_t,layers:Ge(oa),port_hints:Ge(H()).optional(),pcb_component_id:H().optional(),pcb_port_id:H().optional(),pcb_plated_hole_id:oi("pcb_plated_hole"),soldermask_margin:zA().optional()}),gOt=Ae({type:GA("pcb_plated_hole"),shape:pt(["oval","pill"]),pcb_group_id:H().optional(),subcircuit_id:H().optional(),outer_width:zA(),outer_height:zA(),hole_width:zA(),hole_height:zA(),is_covered_with_solder_mask:ce().optional(),x:_t,y:_t,ccw_rotation:xQ,layers:Ge(oa),port_hints:Ge(H()).optional(),pcb_component_id:H().optional(),pcb_port_id:H().optional(),pcb_plated_hole_id:oi("pcb_plated_hole"),soldermask_margin:zA().optional()}),cOt=Ae({type:GA("pcb_plated_hole"),shape:GA("circular_hole_with_rect_pad"),pcb_group_id:H().optional(),subcircuit_id:H().optional(),hole_shape:GA("circle"),pad_shape:GA("rect"),hole_diameter:zA(),rect_pad_width:zA(),rect_pad_height:zA(),rect_border_radius:zA().optional(),hole_offset_x:_t.default(0),hole_offset_y:_t.default(0),is_covered_with_solder_mask:ce().optional(),x:_t,y:_t,layers:Ge(oa),port_hints:Ge(H()).optional(),pcb_component_id:H().optional(),pcb_port_id:H().optional(),pcb_plated_hole_id:oi("pcb_plated_hole"),soldermask_margin:zA().optional(),rect_ccw_rotation:xQ.optional()}),IOt=Ae({type:GA("pcb_plated_hole"),shape:GA("pill_hole_with_rect_pad"),pcb_group_id:H().optional(),subcircuit_id:H().optional(),hole_shape:GA("pill"),pad_shape:GA("rect"),hole_width:zA(),hole_height:zA(),rect_pad_width:zA(),rect_pad_height:zA(),rect_border_radius:zA().optional(),hole_offset_x:_t.default(0),hole_offset_y:_t.default(0),is_covered_with_solder_mask:ce().optional(),x:_t,y:_t,layers:Ge(oa),port_hints:Ge(H()).optional(),pcb_component_id:H().optional(),pcb_port_id:H().optional(),pcb_plated_hole_id:oi("pcb_plated_hole"),soldermask_margin:zA().optional()}),lOt=Ae({type:GA("pcb_plated_hole"),shape:GA("rotated_pill_hole_with_rect_pad"),pcb_group_id:H().optional(),subcircuit_id:H().optional(),hole_shape:GA("rotated_pill"),pad_shape:GA("rect"),hole_width:zA(),hole_height:zA(),hole_ccw_rotation:xQ,rect_pad_width:zA(),rect_pad_height:zA(),rect_border_radius:zA().optional(),rect_ccw_rotation:xQ,hole_offset_x:_t.default(0),hole_offset_y:_t.default(0),is_covered_with_solder_mask:ce().optional(),x:_t,y:_t,layers:Ge(oa),port_hints:Ge(H()).optional(),pcb_component_id:H().optional(),pcb_port_id:H().optional(),pcb_plated_hole_id:oi("pcb_plated_hole"),soldermask_margin:zA().optional()}),BOt=Ae({type:GA("pcb_plated_hole"),shape:GA("hole_with_polygon_pad"),pcb_group_id:H().optional(),subcircuit_id:H().optional(),hole_shape:pt(["circle","oval","pill","rotated_pill"]),hole_diameter:zA().optional(),hole_width:zA().optional(),hole_height:zA().optional(),pad_outline:Ge(Ae({x:_t,y:_t})).min(3),hole_offset_x:_t.default(0),hole_offset_y:_t.default(0),is_covered_with_solder_mask:ce().optional(),x:_t,y:_t,layers:Ge(oa),port_hints:Ge(H()).optional(),pcb_component_id:H().optional(),pcb_port_id:H().optional(),pcb_plated_hole_id:oi("pcb_plated_hole"),soldermask_margin:zA().optional(),ccw_rotation:xQ.optional()}),pae=ii([aOt,gOt,cOt,IOt,lOt,BOt]),fae=Ae({type:GA("pcb_port"),pcb_port_id:oi("pcb_port"),pcb_group_id:H().optional(),subcircuit_id:H().optional(),source_port_id:H(),pcb_component_id:H().optional(),x:_t,y:_t,layers:Ge(oa),is_board_pinout:ce().optional()}).describe("Defines a port on the PCB"),COt=Ae({type:GA("pcb_smtpad"),shape:GA("circle"),pcb_smtpad_id:oi("pcb_smtpad"),pcb_group_id:H().optional(),subcircuit_id:H().optional(),x:_t,y:_t,radius:zA(),layer:oa,port_hints:Ge(H()).optional(),pcb_component_id:H().optional(),pcb_port_id:H().optional(),is_covered_with_solder_mask:ce().optional(),soldermask_margin:zA().optional()}),QOt=Ae({type:GA("pcb_smtpad"),shape:GA("rect"),pcb_smtpad_id:oi("pcb_smtpad"),pcb_group_id:H().optional(),subcircuit_id:H().optional(),x:_t,y:_t,width:zA(),height:zA(),rect_border_radius:zA().optional(),corner_radius:zA().optional(),layer:oa,port_hints:Ge(H()).optional(),pcb_component_id:H().optional(),pcb_port_id:H().optional(),is_covered_with_solder_mask:ce().optional(),soldermask_margin:zA().optional(),soldermask_margin_left:zA().optional(),soldermask_margin_top:zA().optional(),soldermask_margin_right:zA().optional(),soldermask_margin_bottom:zA().optional()}),hOt=Ae({type:GA("pcb_smtpad"),shape:GA("rotated_rect"),pcb_smtpad_id:oi("pcb_smtpad"),pcb_group_id:H().optional(),subcircuit_id:H().optional(),x:_t,y:_t,width:zA(),height:zA(),rect_border_radius:zA().optional(),corner_radius:zA().optional(),ccw_rotation:xQ,layer:oa,port_hints:Ge(H()).optional(),pcb_component_id:H().optional(),pcb_port_id:H().optional(),is_covered_with_solder_mask:ce().optional(),soldermask_margin:zA().optional(),soldermask_margin_left:zA().optional(),soldermask_margin_top:zA().optional(),soldermask_margin_right:zA().optional(),soldermask_margin_bottom:zA().optional()}),yae=Ae({type:GA("pcb_smtpad"),shape:GA("pill"),pcb_smtpad_id:oi("pcb_smtpad"),pcb_group_id:H().optional(),subcircuit_id:H().optional(),x:_t,y:_t,width:zA(),height:zA(),radius:zA(),layer:oa,port_hints:Ge(H()).optional(),pcb_component_id:H().optional(),pcb_port_id:H().optional(),is_covered_with_solder_mask:ce().optional(),soldermask_margin:zA().optional()}),EOt=Ae({type:GA("pcb_smtpad"),shape:GA("rotated_pill"),pcb_smtpad_id:oi("pcb_smtpad"),pcb_group_id:H().optional(),subcircuit_id:H().optional(),x:_t,y:_t,width:zA(),height:zA(),radius:zA(),ccw_rotation:xQ,layer:oa,port_hints:Ge(H()).optional(),pcb_component_id:H().optional(),pcb_port_id:H().optional(),is_covered_with_solder_mask:ce().optional(),soldermask_margin:zA().optional()}),uOt=Ae({type:GA("pcb_smtpad"),shape:GA("polygon"),pcb_smtpad_id:oi("pcb_smtpad"),pcb_group_id:H().optional(),subcircuit_id:H().optional(),points:Ge(vn),layer:oa,port_hints:Ge(H()).optional(),pcb_component_id:H().optional(),pcb_port_id:H().optional(),is_covered_with_solder_mask:ce().optional(),soldermask_margin:zA().optional()}),mae=df("shape",[COt,QOt,hOt,EOt,yae,uOt]).describe("Defines an SMT pad on the PCB"),dOt=Ae({type:GA("pcb_solder_paste"),shape:GA("circle"),pcb_solder_paste_id:oi("pcb_solder_paste"),pcb_group_id:H().optional(),subcircuit_id:H().optional(),x:_t,y:_t,radius:zA(),layer:oa,pcb_component_id:H().optional(),pcb_smtpad_id:H().optional()}),pOt=Ae({type:GA("pcb_solder_paste"),shape:GA("rect"),pcb_solder_paste_id:oi("pcb_solder_paste"),pcb_group_id:H().optional(),subcircuit_id:H().optional(),x:_t,y:_t,width:zA(),height:zA(),layer:oa,pcb_component_id:H().optional(),pcb_smtpad_id:H().optional()}),fOt=Ae({type:GA("pcb_solder_paste"),shape:GA("pill"),pcb_solder_paste_id:oi("pcb_solder_paste"),pcb_group_id:H().optional(),subcircuit_id:H().optional(),x:_t,y:_t,width:zA(),height:zA(),radius:zA(),layer:oa,pcb_component_id:H().optional(),pcb_smtpad_id:H().optional()}),yOt=Ae({type:GA("pcb_solder_paste"),shape:GA("rotated_rect"),pcb_solder_paste_id:oi("pcb_solder_paste"),pcb_group_id:H().optional(),subcircuit_id:H().optional(),x:_t,y:_t,width:zA(),height:zA(),ccw_rotation:_t,layer:oa,pcb_component_id:H().optional(),pcb_smtpad_id:H().optional()}),mOt=Ae({type:GA("pcb_solder_paste"),shape:GA("oval"),pcb_solder_paste_id:oi("pcb_solder_paste"),pcb_group_id:H().optional(),subcircuit_id:H().optional(),x:_t,y:_t,width:zA(),height:zA(),layer:oa,pcb_component_id:H().optional(),pcb_smtpad_id:H().optional()}),wae=ii([dOt,pOt,fOt,yOt,mOt]).describe("Defines solderpaste on the PCB"),Dae=Ae({type:GA("pcb_text"),pcb_text_id:oi("pcb_text"),pcb_group_id:H().optional(),subcircuit_id:H().optional(),text:H(),center:vn,layer:oa,width:Qn,height:Qn,lines:zA(),align:pt(["bottom-left"])}).describe("Defines text on the PCB"),Sae=Ae({route_type:GA("wire"),x:_t,y:_t,width:_t,start_pcb_port_id:H().optional(),end_pcb_port_id:H().optional(),layer:oa}),bae=Ae({route_type:GA("via"),x:_t,y:_t,hole_diameter:_t.optional(),outer_diameter:_t.optional(),from_layer:H(),to_layer:H()}),xae=ii([Sae,bae]),_ae=Ae({type:GA("pcb_trace"),source_trace_id:H().optional(),pcb_component_id:H().optional(),pcb_trace_id:oi("pcb_trace"),pcb_group_id:H().optional(),subcircuit_id:H().optional(),route_thickness_mode:pt(["constant","interpolated"]).default("constant").optional(),route_order_index:zA().optional(),should_round_corners:ce().optional(),trace_length:zA().optional(),highlight_color:H().optional(),route:Ge(xae)}).describe("Defines a trace on the PCB"),kae=Cl.extend({type:GA("pcb_trace_error"),pcb_trace_error_id:oi("pcb_trace_error"),error_type:GA("pcb_trace_error").default("pcb_trace_error"),center:vn.optional(),pcb_trace_id:H(),source_trace_id:H(),pcb_component_ids:Ge(H()),pcb_port_ids:Ge(H()),subcircuit_id:H().optional()}).describe("Defines a trace error on the PCB"),Fae=Cl.extend({type:GA("pcb_trace_missing_error"),pcb_trace_missing_error_id:oi("pcb_trace_missing_error"),error_type:GA("pcb_trace_missing_error").default("pcb_trace_missing_error"),center:vn.optional(),source_trace_id:H(),pcb_component_ids:Ge(H()),pcb_port_ids:Ge(H()),subcircuit_id:H().optional()}).describe("Defines an error when a source trace has no corresponding PCB trace"),vae=Cl.extend({type:GA("pcb_port_not_matched_error"),pcb_error_id:oi("pcb_error"),error_type:GA("pcb_port_not_matched_error").default("pcb_port_not_matched_error"),pcb_component_ids:Ge(H()),subcircuit_id:H().optional()}).describe("Defines a trace error on the PCB where a port is not matched"),Gae=Cl.extend({type:GA("pcb_port_not_connected_error"),pcb_port_not_connected_error_id:oi("pcb_port_not_connected_error"),error_type:GA("pcb_port_not_connected_error").default("pcb_port_not_connected_error"),pcb_port_ids:Ge(H()),pcb_component_ids:Ge(H()),subcircuit_id:H().optional()}).describe("Defines an error when a pcb port is not connected to any trace"),Rae=Ae({type:GA("pcb_net"),pcb_net_id:oi("pcb_net"),source_net_id:H().optional(),highlight_color:H().optional()}).describe("Defines a net on the PCB"),Nae=Ae({type:GA("pcb_via"),pcb_via_id:oi("pcb_via"),pcb_group_id:H().optional(),subcircuit_id:H().optional(),subcircuit_connectivity_map_key:H().optional(),x:_t,y:_t,outer_diameter:_t.default("0.6mm"),hole_diameter:_t.default("0.25mm"),from_layer:oa.optional(),to_layer:oa.optional(),layers:Ge(oa),pcb_trace_id:H().optional(),net_is_assignable:ce().optional(),net_assigned:ce().optional(),is_tented:ce().optional()}).describe("Defines a via on the PCB"),Mae=Ae({type:GA("pcb_board"),pcb_board_id:oi("pcb_board"),pcb_panel_id:H().optional(),carrier_pcb_board_id:H().optional(),is_subcircuit:ce().optional(),subcircuit_id:H().optional(),is_mounted_to_carrier_board:ce().optional(),width:Qn.optional(),height:Qn.optional(),center:vn,display_offset_x:H().optional().describe("How to display the x offset for this board, usually corresponding with how the user specified it"),display_offset_y:H().optional().describe("How to display the y offset for this board, usually corresponding with how the user specified it"),thickness:Qn.optional().default(1.4),num_layers:zA().optional().default(4),outline:Ge(vn).optional(),shape:pt(["rect","polygon"]).optional(),material:pt(["fr4","fr1"]).default("fr4"),anchor_position:vn.optional(),anchor_alignment:nk.optional(),position_mode:pt(["relative_to_panel_anchor","none"]).optional()}).describe("Defines the board outline of the PCB"),Lae=Ae({type:GA("pcb_panel"),pcb_panel_id:oi("pcb_panel"),width:Qn,height:Qn,center:vn,covered_with_solder_mask:ce().optional().default(!0)}).describe("Defines a PCB panel that can contain multiple boards"),Uae=Cl.extend({type:GA("pcb_placement_error"),pcb_placement_error_id:oi("pcb_placement_error"),error_type:GA("pcb_placement_error").default("pcb_placement_error"),subcircuit_id:H().optional()}).describe("Defines a placement error on the PCB"),Hae=Cl.extend({type:GA("pcb_panelization_placement_error"),pcb_panelization_placement_error_id:oi("pcb_panelization_placement_error"),error_type:GA("pcb_panelization_placement_error").default("pcb_panelization_placement_error"),pcb_panel_id:H().optional(),pcb_board_id:H().optional(),subcircuit_id:H().optional()}).describe("Defines a panelization placement error on the PCB"),Yae=Ae({type:GA("pcb_trace_hint"),pcb_trace_hint_id:oi("pcb_trace_hint"),pcb_port_id:H(),pcb_component_id:H(),route:Ge(Iae),subcircuit_id:H().optional()}).describe("A hint that can be used during generation of a PCB trace"),Jae=Ae({type:GA("pcb_silkscreen_line"),pcb_silkscreen_line_id:oi("pcb_silkscreen_line"),pcb_component_id:H(),pcb_group_id:H().optional(),subcircuit_id:H().optional(),stroke_width:_t.default("0.1mm"),x1:_t,y1:_t,x2:_t,y2:_t,layer:um}).describe("Defines a silkscreen line on the PCB"),Tae=Ae({type:GA("pcb_silkscreen_path"),pcb_silkscreen_path_id:oi("pcb_silkscreen_path"),pcb_component_id:H(),pcb_group_id:H().optional(),subcircuit_id:H().optional(),layer:um,route:Ge(vn),stroke_width:Qn}).describe("Defines a silkscreen path on the PCB"),Kae=Ae({type:GA("pcb_silkscreen_text"),pcb_silkscreen_text_id:oi("pcb_silkscreen_text"),pcb_group_id:H().optional(),subcircuit_id:H().optional(),font:GA("tscircuit2024").default("tscircuit2024"),font_size:_t.default("0.2mm"),pcb_component_id:H(),text:H(),is_knockout:ce().default(!1).optional(),knockout_padding:Ae({left:Qn,top:Qn,bottom:Qn,right:Qn}).default({left:"0.2mm",top:"0.2mm",bottom:"0.2mm",right:"0.2mm"}).optional(),ccw_rotation:zA().optional(),layer:oa,is_mirrored:ce().default(!1).optional(),anchor_position:vn.default({x:0,y:0}),anchor_alignment:nk.default("center")}).describe("Defines silkscreen text on the PCB"),Pae=Ae({type:GA("pcb_copper_text"),pcb_copper_text_id:oi("pcb_copper_text"),pcb_group_id:H().optional(),subcircuit_id:H().optional(),font:GA("tscircuit2024").default("tscircuit2024"),font_size:_t.default("0.2mm"),pcb_component_id:H(),text:H(),is_knockout:ce().default(!1).optional(),knockout_padding:Ae({left:Qn,top:Qn,bottom:Qn,right:Qn}).default({left:"0.2mm",top:"0.2mm",bottom:"0.2mm",right:"0.2mm"}).optional(),ccw_rotation:zA().optional(),layer:oa,is_mirrored:ce().default(!1).optional(),anchor_position:vn.default({x:0,y:0}),anchor_alignment:nk.default("center")}).describe("Defines copper text on the PCB"),qae=Ae({type:GA("pcb_silkscreen_rect"),pcb_silkscreen_rect_id:oi("pcb_silkscreen_rect"),pcb_component_id:H(),pcb_group_id:H().optional(),subcircuit_id:H().optional(),center:vn,width:Qn,height:Qn,layer:oa,stroke_width:Qn.default("1mm"),corner_radius:Qn.optional(),is_filled:ce().default(!0).optional(),has_stroke:ce().optional(),is_stroke_dashed:ce().optional(),ccw_rotation:zA().optional()}).describe("Defines a silkscreen rect on the PCB"),Oae=Ae({type:GA("pcb_silkscreen_circle"),pcb_silkscreen_circle_id:oi("pcb_silkscreen_circle"),pcb_component_id:H(),pcb_group_id:H().optional(),subcircuit_id:H().optional(),center:vn,radius:Qn,layer:um,stroke_width:Qn.default("1mm")}).describe("Defines a silkscreen circle on the PCB"),Wae=Ae({type:GA("pcb_silkscreen_oval"),pcb_silkscreen_oval_id:oi("pcb_silkscreen_oval"),pcb_component_id:H(),pcb_group_id:H().optional(),subcircuit_id:H().optional(),center:vn,radius_x:_t,radius_y:_t,layer:um,ccw_rotation:xQ.optional()}).describe("Defines a silkscreen oval on the PCB"),Zae=Ae({type:GA("pcb_silkscreen_pill"),pcb_silkscreen_pill_id:oi("pcb_silkscreen_pill"),pcb_component_id:H(),pcb_group_id:H().optional(),subcircuit_id:H().optional(),center:vn,width:Qn,height:Qn,layer:oa,ccw_rotation:zA().optional()}).describe("Defines a silkscreen pill on the PCB"),Vae=Ae({type:GA("pcb_fabrication_note_text"),pcb_fabrication_note_text_id:oi("pcb_fabrication_note_text"),subcircuit_id:H().optional(),pcb_group_id:H().optional(),font:GA("tscircuit2024").default("tscircuit2024"),font_size:_t.default("1mm"),pcb_component_id:H(),text:H(),layer:um,anchor_position:vn.default({x:0,y:0}),anchor_alignment:pt(["center","top_left","top_right","bottom_left","bottom_right"]).default("center"),color:H().optional()}).describe("Defines a fabrication note in text on the PCB, useful for leaving notes for assemblers or fabricators"),jae=Ae({type:GA("pcb_fabrication_note_path"),pcb_fabrication_note_path_id:oi("pcb_fabrication_note_path"),pcb_component_id:H(),subcircuit_id:H().optional(),layer:oa,route:Ge(vn),stroke_width:Qn,color:H().optional()}).describe("Defines a fabrication path on the PCB for fabricators or assemblers"),zae=Ae({type:GA("pcb_fabrication_note_rect"),pcb_fabrication_note_rect_id:oi("pcb_fabrication_note_rect"),pcb_component_id:H(),pcb_group_id:H().optional(),subcircuit_id:H().optional(),center:vn,width:Qn,height:Qn,layer:um,stroke_width:Qn.default("0.1mm"),corner_radius:Qn.optional(),is_filled:ce().optional(),has_stroke:ce().optional(),is_stroke_dashed:ce().optional(),color:H().optional()}).describe("Defines a fabrication note rectangle on the PCB"),Xae=Ae({type:GA("pcb_fabrication_note_dimension"),pcb_fabrication_note_dimension_id:oi("pcb_fabrication_note_dimension"),pcb_component_id:H(),pcb_group_id:H().optional(),subcircuit_id:H().optional(),layer:um,from:vn,to:vn,text:H().optional(),text_ccw_rotation:zA().optional(),offset:Qn.optional(),offset_distance:Qn.optional(),offset_direction:Ae({x:zA(),y:zA()}).optional(),font:GA("tscircuit2024").default("tscircuit2024"),font_size:Qn.default("1mm"),color:H().optional(),arrow_size:Qn.default("1mm")}).describe("Defines a measurement annotation within PCB fabrication notes"),$ae=Ae({type:GA("pcb_note_text"),pcb_note_text_id:oi("pcb_note_text"),pcb_component_id:H().optional(),pcb_group_id:H().optional(),subcircuit_id:H().optional(),name:H().optional(),font:GA("tscircuit2024").default("tscircuit2024"),font_size:_t.default("1mm"),text:H().optional(),anchor_position:vn.default({x:0,y:0}),anchor_alignment:pt(["center","top_left","top_right","bottom_left","bottom_right"]).default("center"),color:H().optional()}).describe("Defines a documentation note in text on the PCB"),Age=Ae({type:GA("pcb_note_rect"),pcb_note_rect_id:oi("pcb_note_rect"),pcb_component_id:H().optional(),pcb_group_id:H().optional(),subcircuit_id:H().optional(),name:H().optional(),text:H().optional(),center:vn,width:Qn,height:Qn,stroke_width:Qn.default("0.1mm"),corner_radius:Qn.optional(),is_filled:ce().optional(),has_stroke:ce().optional(),is_stroke_dashed:ce().optional(),color:H().optional()}).describe("Defines a rectangular documentation note on the PCB"),ege=Ae({type:GA("pcb_note_path"),pcb_note_path_id:oi("pcb_note_path"),pcb_component_id:H().optional(),pcb_group_id:H().optional(),subcircuit_id:H().optional(),name:H().optional(),text:H().optional(),route:Ge(vn),stroke_width:Qn.default("0.1mm"),color:H().optional()}).describe("Defines a polyline documentation note on the PCB"),tge=Ae({type:GA("pcb_note_line"),pcb_note_line_id:oi("pcb_note_line"),pcb_component_id:H().optional(),pcb_group_id:H().optional(),subcircuit_id:H().optional(),name:H().optional(),text:H().optional(),x1:_t,y1:_t,x2:_t,y2:_t,stroke_width:_t.default("0.1mm"),color:H().optional(),is_dashed:ce().optional()}).describe("Defines a straight documentation note line on the PCB"),ige=Ae({type:GA("pcb_note_dimension"),pcb_note_dimension_id:oi("pcb_note_dimension"),pcb_component_id:H().optional(),pcb_group_id:H().optional(),subcircuit_id:H().optional(),name:H().optional(),from:vn,to:vn,text:H().optional(),text_ccw_rotation:zA().optional(),offset_distance:Qn.optional(),offset_direction:Ae({x:zA(),y:zA()}).optional(),font:GA("tscircuit2024").default("tscircuit2024"),font_size:Qn.default("1mm"),color:H().optional(),arrow_size:Qn.default("1mm")}).describe("Defines a measurement annotation within PCB documentation notes"),nge=Cl.extend({type:GA("pcb_footprint_overlap_error"),pcb_error_id:oi("pcb_error"),error_type:GA("pcb_footprint_overlap_error").default("pcb_footprint_overlap_error"),pcb_smtpad_ids:Ge(H()).optional(),pcb_plated_hole_ids:Ge(H()).optional(),pcb_hole_ids:Ge(H()).optional(),pcb_keepout_ids:Ge(H()).optional()}).describe("Error emitted when a pcb footprint overlaps with another element"),oge=Ae({type:GA("pcb_keepout"),shape:GA("rect"),pcb_group_id:H().optional(),subcircuit_id:H().optional(),center:vn,width:_t,height:_t,pcb_keepout_id:H(),layers:Ge(H()),description:H().optional()}).or(Ae({type:GA("pcb_keepout"),shape:GA("circle"),pcb_group_id:H().optional(),subcircuit_id:H().optional(),center:vn,radius:_t,pcb_keepout_id:H(),layers:Ge(H()),description:H().optional()})),lV=Ae({type:GA("pcb_cutout"),pcb_cutout_id:oi("pcb_cutout"),pcb_group_id:H().optional(),subcircuit_id:H().optional(),pcb_board_id:H().optional(),pcb_panel_id:H().optional()}),sge=lV.extend({shape:GA("rect"),center:vn,width:Qn,height:Qn,rotation:xQ.optional(),corner_radius:Qn.optional()}),rge=lV.extend({shape:GA("circle"),center:vn,radius:Qn}),age=lV.extend({shape:GA("polygon"),points:Ge(vn)}),gge=lV.extend({shape:GA("path"),route:Ge(vn),slot_width:Qn,slot_length:Qn.optional(),space_between_slots:Qn.optional(),slot_corner_radius:Qn.optional()}),cge=df("shape",[sge,rge,age,gge]).describe("Defines a cutout on the PCB, removing board material."),Ige=Cl.extend({type:GA("pcb_missing_footprint_error"),pcb_missing_footprint_error_id:oi("pcb_missing_footprint_error"),pcb_group_id:H().optional(),subcircuit_id:H().optional(),error_type:GA("pcb_missing_footprint_error").default("pcb_missing_footprint_error"),source_component_id:H()}).describe("Defines a missing footprint error on the PCB"),lge=Cl.extend({type:GA("external_footprint_load_error"),external_footprint_load_error_id:oi("external_footprint_load_error"),pcb_component_id:H(),source_component_id:H(),pcb_group_id:H().optional(),subcircuit_id:H().optional(),footprinter_string:H().optional(),error_type:GA("external_footprint_load_error").default("external_footprint_load_error")}).describe("Defines an error when an external footprint fails to load"),Bge=Cl.extend({type:GA("circuit_json_footprint_load_error"),circuit_json_footprint_load_error_id:oi("circuit_json_footprint_load_error"),pcb_component_id:H(),source_component_id:H(),pcb_group_id:H().optional(),subcircuit_id:H().optional(),error_type:GA("circuit_json_footprint_load_error").default("circuit_json_footprint_load_error"),circuit_json:Ge(fI()).optional()}).describe("Defines an error when a circuit JSON footprint fails to load"),Cge=Ae({type:GA("pcb_group"),pcb_group_id:oi("pcb_group"),source_group_id:H(),is_subcircuit:ce().optional(),subcircuit_id:H().optional(),width:Qn.optional(),height:Qn.optional(),center:vn,display_offset_x:H().optional().describe("How to display the x offset for this group, usually corresponding with how the user specified it"),display_offset_y:H().optional().describe("How to display the y offset for this group, usually corresponding with how the user specified it"),outline:Ge(vn).optional(),anchor_position:vn.optional(),anchor_alignment:nk.default("center"),position_mode:pt(["packed","relative_to_group_anchor","none"]).optional(),positioned_relative_to_pcb_group_id:H().optional(),positioned_relative_to_pcb_board_id:H().optional(),pcb_component_ids:Ge(H()),child_layout_mode:pt(["packed","none"]).optional(),name:H().optional(),description:H().optional(),layout_mode:H().optional(),autorouter_configuration:Ae({trace_clearance:Qn}).optional(),autorouter_used_string:H().optional()}).describe("Defines a group of components on the PCB"),Qge=Cl.extend({type:GA("pcb_autorouting_error"),pcb_error_id:oi("pcb_autorouting_error"),error_type:GA("pcb_autorouting_error").default("pcb_autorouting_error"),subcircuit_id:H().optional()}).describe("The autorouting has failed to route a portion of the board"),hge=Ae({type:GA("pcb_manual_edit_conflict_warning"),pcb_manual_edit_conflict_warning_id:oi("pcb_manual_edit_conflict_warning"),warning_type:GA("pcb_manual_edit_conflict_warning").default("pcb_manual_edit_conflict_warning"),message:H(),pcb_component_id:H(),pcb_group_id:H().optional(),subcircuit_id:H().optional(),source_component_id:H()}).describe("Warning emitted when a component has both manual placement and explicit pcbX/pcbY coordinates"),Ege=Ae({type:GA("pcb_breakout_point"),pcb_breakout_point_id:oi("pcb_breakout_point"),pcb_group_id:H(),subcircuit_id:H().optional(),source_trace_id:H().optional(),source_port_id:H().optional(),source_net_id:H().optional(),x:_t,y:_t}).describe("Defines a routing target within a pcb_group for a source_trace or source_net"),uge=Ae({type:GA("pcb_ground_plane"),pcb_ground_plane_id:oi("pcb_ground_plane"),source_pcb_ground_plane_id:H(),source_net_id:H(),pcb_group_id:H().optional(),subcircuit_id:H().optional()}).describe("Defines a ground plane on the PCB"),dge=Ae({type:GA("pcb_ground_plane_region"),pcb_ground_plane_region_id:oi("pcb_ground_plane_region"),pcb_ground_plane_id:H(),pcb_group_id:H().optional(),subcircuit_id:H().optional(),layer:oa,points:Ge(vn)}).describe("Defines a polygon region of a ground plane"),pge=Ae({type:GA("pcb_thermal_spoke"),pcb_thermal_spoke_id:oi("pcb_thermal_spoke"),pcb_ground_plane_id:H(),shape:H(),spoke_count:zA(),spoke_thickness:_t,spoke_inner_diameter:_t,spoke_outer_diameter:_t,pcb_plated_hole_id:H().optional(),subcircuit_id:H().optional()}).describe("Pattern for connecting a ground plane to a plated hole"),tfA=Ae({type:GA("pcb_copper_pour"),pcb_copper_pour_id:oi("pcb_copper_pour"),pcb_group_id:H().optional(),subcircuit_id:H().optional(),layer:oa,source_net_id:H().optional(),covered_with_solder_mask:ce().optional().default(!0)}),fge=tfA.extend({shape:GA("rect"),center:vn,width:Qn,height:Qn,rotation:xQ.optional()}),yge=tfA.extend({shape:GA("brep"),brep_shape:gae}),mge=tfA.extend({shape:GA("polygon"),points:Ge(vn)}),wge=df("shape",[fge,yge,mge]).describe("Defines a copper pour on the PCB."),Dge=Cl.extend({type:GA("pcb_component_outside_board_error"),pcb_component_outside_board_error_id:oi("pcb_component_outside_board_error"),error_type:GA("pcb_component_outside_board_error").default("pcb_component_outside_board_error"),pcb_component_id:H(),pcb_board_id:H(),component_center:vn,component_bounds:Ae({min_x:zA(),max_x:zA(),min_y:zA(),max_y:zA()}),subcircuit_id:H().optional(),source_component_id:H().optional()}).describe("Error emitted when a PCB component is placed outside the board boundaries"),Sge=Cl.extend({type:GA("pcb_component_not_on_board_edge_error"),pcb_component_not_on_board_edge_error_id:oi("pcb_component_not_on_board_edge_error"),error_type:GA("pcb_component_not_on_board_edge_error").default("pcb_component_not_on_board_edge_error"),pcb_component_id:H(),pcb_board_id:H(),component_center:vn,pad_to_nearest_board_edge_distance:zA(),source_component_id:H().optional(),subcircuit_id:H().optional()}).describe("Error emitted when a component that must be placed on the board edge is centered away from the edge"),bge=Cl.extend({type:GA("pcb_component_invalid_layer_error"),pcb_component_invalid_layer_error_id:oi("pcb_component_invalid_layer_error"),error_type:GA("pcb_component_invalid_layer_error").default("pcb_component_invalid_layer_error"),pcb_component_id:H().optional(),source_component_id:H(),layer:oa,subcircuit_id:H().optional()}).describe("Error emitted when a component is placed on an invalid layer (components can only be on 'top' or 'bottom' layers)"),xge=Cl.extend({type:GA("pcb_via_clearance_error"),pcb_error_id:oi("pcb_error"),error_type:GA("pcb_via_clearance_error").default("pcb_via_clearance_error"),pcb_via_ids:Ge(H()).min(2),minimum_clearance:_t.optional(),actual_clearance:_t.optional(),pcb_center:Ae({x:zA().optional(),y:zA().optional()}).optional(),subcircuit_id:H().optional()}).describe("Error emitted when vias are closer than the allowed clearance"),_ge=Ae({type:GA("pcb_courtyard_rect"),pcb_courtyard_rect_id:oi("pcb_courtyard_rect"),pcb_component_id:H(),pcb_group_id:H().optional(),subcircuit_id:H().optional(),center:vn,width:Qn,height:Qn,layer:um,color:H().optional()}).describe("Defines a courtyard rectangle on the PCB"),kge=Ae({type:GA("pcb_courtyard_outline"),pcb_courtyard_outline_id:oi("pcb_courtyard_outline"),pcb_component_id:H(),pcb_group_id:H().optional(),subcircuit_id:H().optional(),layer:um,outline:Ge(vn).min(2)}).describe("Defines a courtyard outline on the PCB"),Fge=Ae({type:GA("pcb_courtyard_polygon"),pcb_courtyard_polygon_id:oi("pcb_courtyard_polygon"),pcb_component_id:H(),pcb_group_id:H().optional(),subcircuit_id:H().optional(),layer:um,points:Ge(vn).min(3),color:H().optional()}).describe("Defines a courtyard polygon on the PCB"),vge=Ae({type:GA("pcb_courtyard_circle"),pcb_courtyard_circle_id:oi("pcb_courtyard_circle"),pcb_component_id:H(),pcb_group_id:H().optional(),subcircuit_id:H().optional(),center:vn,radius:Qn,layer:um,color:H().optional()}).describe("Defines a courtyard circle on the PCB"),Gge=Ae({type:GA("cad_component"),cad_component_id:H(),pcb_component_id:H(),source_component_id:H(),position:ik,rotation:ik.optional(),size:ik.optional(),layer:oa.optional(),subcircuit_id:H().optional(),footprinter_string:H().optional(),model_obj_url:H().optional(),model_stl_url:H().optional(),model_3mf_url:H().optional(),model_gltf_url:H().optional(),model_glb_url:H().optional(),model_step_url:H().optional(),model_wrl_url:H().optional(),model_asset:$se.optional(),model_unit_to_mm_scale_factor:zA().optional(),model_jscad:fI().optional(),show_as_translucent_model:ce().optional(),anchor_alignment:pt(["center","xy_center_z_board"]).optional().default("center")}).describe("Defines a component on the PCB"),ifA=pt(["sinewave","square","triangle","sawtooth"]),wOt=ii([H(),zA()]).transform(t=>typeof t=="string"?t.endsWith("%")?parseFloat(t.slice(0,-1))/100:parseFloat(t):t).pipe(zA().min(0,"Duty cycle must be non-negative").max(1,"Duty cycle cannot be greater than 100%")),Rge=Ae({type:GA("simulation_voltage_source"),simulation_voltage_source_id:oi("simulation_voltage_source"),is_dc_source:GA(!0).optional().default(!0),positive_source_port_id:H().optional(),negative_source_port_id:H().optional(),positive_source_net_id:H().optional(),negative_source_net_id:H().optional(),voltage:Rb}).describe("Defines a DC voltage source for simulation"),Nge=Ae({type:GA("simulation_voltage_source"),simulation_voltage_source_id:oi("simulation_voltage_source"),is_dc_source:GA(!1),terminal1_source_port_id:H().optional(),terminal2_source_port_id:H().optional(),terminal1_source_net_id:H().optional(),terminal2_source_net_id:H().optional(),voltage:Rb.optional(),frequency:Lv.optional(),peak_to_peak_voltage:Rb.optional(),wave_shape:ifA.optional(),phase:xQ.optional(),duty_cycle:wOt.optional()}).describe("Defines an AC voltage source for simulation"),Mge=ii([Rge,Nge]).describe("Defines a voltage source for simulation"),DOt=ii([H(),zA()]).transform(t=>typeof t=="string"?t.endsWith("%")?parseFloat(t.slice(0,-1))/100:parseFloat(t):t).pipe(zA().min(0,"Duty cycle must be non-negative").max(1,"Duty cycle cannot be greater than 100%")),Lge=Ae({type:GA("simulation_current_source"),simulation_current_source_id:oi("simulation_current_source"),is_dc_source:GA(!0).optional().default(!0),positive_source_port_id:H().optional(),negative_source_port_id:H().optional(),positive_source_net_id:H().optional(),negative_source_net_id:H().optional(),current:c1}).describe("Defines a DC current source for simulation"),Uge=Ae({type:GA("simulation_current_source"),simulation_current_source_id:oi("simulation_current_source"),is_dc_source:GA(!1),terminal1_source_port_id:H().optional(),terminal2_source_port_id:H().optional(),terminal1_source_net_id:H().optional(),terminal2_source_net_id:H().optional(),current:c1.optional(),frequency:Lv.optional(),peak_to_peak_current:c1.optional(),wave_shape:ifA.optional(),phase:xQ.optional(),duty_cycle:DOt.optional()}).describe("Defines an AC current source for simulation"),Hge=ii([Lge,Uge]).describe("Defines a current source for simulation"),Yge=ii([GA("spice_dc_sweep"),GA("spice_dc_operating_point"),GA("spice_transient_analysis"),GA("spice_ac_analysis")]),Jge=Ae({type:GA("simulation_experiment"),simulation_experiment_id:oi("simulation_experiment"),name:H(),experiment_type:Yge,time_per_step:aJ.optional(),start_time_ms:Uv.optional(),end_time_ms:Uv.optional()}).describe("Defines a simulation experiment configuration"),Tge=Ae({type:GA("simulation_transient_voltage_graph"),simulation_transient_voltage_graph_id:oi("simulation_transient_voltage_graph"),simulation_experiment_id:H(),timestamps_ms:Ge(zA()).optional(),voltage_levels:Ge(zA()),source_component_id:H().optional(),subcircuit_connectivity_map_key:H().optional(),time_per_step:aJ,start_time_ms:Uv,end_time_ms:Uv,name:H().optional(),color:H().optional()}).describe("Stores voltage measurements over time for a simulation"),Kge=Ae({type:GA("simulation_switch"),simulation_switch_id:oi("simulation_switch"),source_component_id:H().optional(),closes_at:Uv.optional(),opens_at:Uv.optional(),starts_closed:ce().optional(),switching_frequency:Lv.optional()}).describe("Defines a switch for simulation timing control"),Pge=Ae({type:GA("simulation_voltage_probe"),simulation_voltage_probe_id:oi("simulation_voltage_probe"),source_component_id:H().optional(),name:H().optional(),signal_input_source_port_id:H().optional(),signal_input_source_net_id:H().optional(),reference_input_source_port_id:H().optional(),reference_input_source_net_id:H().optional(),subcircuit_id:H().optional(),color:H().optional()}).describe("Defines a voltage probe for simulation. If a reference input is not provided, it measures against ground. If a reference input is provided, it measures the differential voltage between two points.").superRefine((t,A)=>{if(t.reference_input_source_port_id||t.reference_input_source_net_id){const i=!!t.signal_input_source_port_id||!!t.reference_input_source_port_id,n=!!t.signal_input_source_net_id||!!t.reference_input_source_net_id;i&&n?A.addIssue({code:ri.custom,message:"Cannot mix port and net connections in a differential probe."}):i?(!t.signal_input_source_port_id||!t.reference_input_source_port_id)&&A.addIssue({code:ri.custom,message:"Differential port probe requires both signal_input_source_port_id and reference_input_source_port_id."}):n&&(!t.signal_input_source_net_id||!t.reference_input_source_net_id)&&A.addIssue({code:ri.custom,message:"Differential net probe requires both signal_input_source_net_id and reference_input_source_net_id."})}else!!t.signal_input_source_port_id==!!t.signal_input_source_net_id&&A.addIssue({code:ri.custom,message:"A voltage probe must have exactly one of signal_input_source_port_id or signal_input_source_net_id."})}),qge=Cl.extend({type:GA("simulation_unknown_experiment_error"),simulation_unknown_experiment_error_id:oi("simulation_unknown_experiment_error"),error_type:GA("simulation_unknown_experiment_error").default("simulation_unknown_experiment_error"),simulation_experiment_id:H().optional(),subcircuit_id:H().optional()}).describe("An unknown error occurred during the simulation experiment."),Oge=Ae({type:GA("simulation_op_amp"),simulation_op_amp_id:oi("simulation_op_amp"),source_component_id:H().optional(),inverting_input_source_port_id:H(),non_inverting_input_source_port_id:H(),output_source_port_id:H(),positive_supply_source_port_id:H(),negative_supply_source_port_id:H()}).describe("Defines a simple ideal operational amplifier for simulation"),Wge=ii([Dre,mre,wre,yre,bre,Sre,MpA,GpA,cV,NpA,RpA,LpA,UpA,HpA,TpA,KpA,PpA,VpA,qpA,OpA,WpA,ZpA,JpA,YpA,_re,Fre,xre,jpA,zpA,XpA,vre,Gre,$pA,lae,dae,Ige,lge,Bge,hge,pae,oge,fae,Rae,Dae,_ae,Nae,mae,wae,Mae,Lae,Cge,Yae,Jae,Tae,Kae,Zae,Pae,qae,Oae,Wae,kae,Fae,Uae,Hae,vae,Gae,xge,jae,Vae,zae,Xae,$ae,Age,ege,tge,ige,Qge,nge,Ege,cge,uge,dge,pge,wge,Dge,Sge,bge,_ge,kge,Fge,vge,Rre,Wre,Tre,Kre,Pre,qre,Yre,Jre,Zre,Ore,Nre,jre,zre,Vre,eae,tae,iae,nae,rae,oae,sae,Gge,Mge,Hge,Jge,Tge,Kge,Pge,qge,Oge]),nfA=Wge;const Zge=Object.freeze(Object.defineProperty({__proto__:null,all_layers:kre,any_circuit_element:Wge,any_soup_element:nfA,any_source_component:yre,asset:$se,base_circuit_json_error:Cl,battery_capacity:Xse,brep_shape:gae,cad_component:Gge,capacitance:kpA,circuit_json_footprint_load_error:Bge,current:c1,distance:_t,duration_ms:aJ,experiment_type:Yge,external_footprint_load_error:lge,frequency:Lv,getZodPrefixedIdWithDefault:oi,inductance:jse,kicadAt:gV,kicadEffects:Are,kicadFont:vpA,kicadFootprintAttributes:tre,kicadFootprintMetadata:ore,kicadFootprintModel:nre,kicadFootprintPad:ire,kicadFootprintProperties:ere,kicadProperty:gJ,kicadSymbolEffects:are,kicadSymbolMetadata:cre,kicadSymbolPinNames:rre,kicadSymbolPinNumbers:sre,kicadSymbolProperties:gre,kicadSymbolProperty:ok,layer_ref:oa,layer_string:AfA,length:Qn,ms:Uv,ninePointAnchor:nk,pcbRenderLayer:z3t,pcb_autorouting_error:Qge,pcb_board:Mae,pcb_breakout_point:Ege,pcb_component:lae,pcb_component_invalid_layer_error:bge,pcb_component_not_on_board_edge_error:Sge,pcb_component_outside_board_error:Dge,pcb_copper_pour:wge,pcb_copper_pour_brep:yge,pcb_copper_pour_polygon:mge,pcb_copper_pour_rect:fge,pcb_copper_text:Pae,pcb_courtyard_circle:vge,pcb_courtyard_outline:kge,pcb_courtyard_polygon:Fge,pcb_courtyard_rect:_ge,pcb_cutout:cge,pcb_cutout_circle:rge,pcb_cutout_path:gge,pcb_cutout_polygon:age,pcb_cutout_rect:sge,pcb_fabrication_note_dimension:Xae,pcb_fabrication_note_path:jae,pcb_fabrication_note_rect:zae,pcb_fabrication_note_text:Vae,pcb_footprint_overlap_error:nge,pcb_ground_plane:uge,pcb_ground_plane_region:dge,pcb_group:Cge,pcb_hole:dae,pcb_hole_circle_or_square_shape:nOt,pcb_hole_circle_shape:tOt,pcb_hole_oval_shape:oOt,pcb_hole_pill_shape:sOt,pcb_hole_rect_shape:iOt,pcb_hole_rotated_pill_shape:rOt,pcb_keepout:oge,pcb_manual_edit_conflict_warning:hge,pcb_missing_footprint_error:Ige,pcb_net:Rae,pcb_note_dimension:ige,pcb_note_line:tge,pcb_note_path:ege,pcb_note_rect:Age,pcb_note_text:$ae,pcb_panel:Lae,pcb_panelization_placement_error:Hae,pcb_placement_error:Uae,pcb_plated_hole:pae,pcb_port:fae,pcb_port_not_connected_error:Gae,pcb_port_not_matched_error:vae,pcb_route_hint:cae,pcb_route_hints:eOt,pcb_silkscreen_circle:Oae,pcb_silkscreen_line:Jae,pcb_silkscreen_oval:Wae,pcb_silkscreen_path:Tae,pcb_silkscreen_pill:Zae,pcb_silkscreen_rect:qae,pcb_silkscreen_text:Kae,pcb_smtpad:mae,pcb_smtpad_pill:yae,pcb_solder_paste:wae,pcb_text:Dae,pcb_thermal_spoke:pge,pcb_trace:_ae,pcb_trace_error:kae,pcb_trace_hint:Yae,pcb_trace_missing_error:Fae,pcb_trace_route_point:xae,pcb_trace_route_point_via:bae,pcb_trace_route_point_wire:Sae,pcb_via:Nae,pcb_via_clearance_error:xge,point:vn,point3:ik,point_with_bulge:aae,port_arrangement:Hre,position:Z3t,position3:V3t,resistance:aV,ring:efA,rotation:xQ,route_hint_point:Iae,schematic_arc:qre,schematic_box:Rre,schematic_circle:Pre,schematic_component:Yre,schematic_component_port_arrangement_by_sides:Ure,schematic_component_port_arrangement_by_size:Lre,schematic_debug_line:$re,schematic_debug_object:eae,schematic_debug_object_base:IV,schematic_debug_point:Aae,schematic_debug_rect:Xre,schematic_error:jre,schematic_group:nae,schematic_layout_error:zre,schematic_line:Tre,schematic_manual_edit_conflict_warning:iae,schematic_net_label:Vre,schematic_path:Nre,schematic_pin_styles:Mre,schematic_port:Zre,schematic_rect:Kre,schematic_sheet:rae,schematic_symbol:Jre,schematic_table:oae,schematic_table_cell:sae,schematic_text:Wre,schematic_trace:Ore,schematic_voltage_probe:tae,simulation_ac_current_source:Uge,simulation_ac_voltage_source:Nge,simulation_current_source:Hge,simulation_dc_current_source:Lge,simulation_dc_voltage_source:Rge,simulation_experiment:Jge,simulation_op_amp:Oge,simulation_switch:Kge,simulation_transient_voltage_graph:Tge,simulation_unknown_experiment_error:qge,simulation_voltage_probe:Pge,simulation_voltage_source:Mge,size:FpA,source_board:xre,source_component_base:kI,source_component_internal_connection:wre,source_failed_to_create_component_error:Ere,source_group:Sre,source_i2c_misconfigured_error:$pA,source_interconnect:pre,source_manually_placed_via:Fre,source_missing_property_error:hre,source_net:bre,source_pcb_ground_plane:_re,source_pin_missing_trace_warning:XpA,source_pin_must_be_connected_error:vre,source_port:mre,source_project_metadata:jpA,source_property_ignored_warning:ure,source_simple_battery:UpA,source_simple_capacitor:GpA,source_simple_chip:MpA,source_simple_crystal:Qre,source_simple_current_source:Cre,source_simple_diode:cV,source_simple_fiducial:lre,source_simple_ground:Bre,source_simple_inductor:HpA,source_simple_led:NpA,source_simple_mosfet:WpA,source_simple_op_amp:ZpA,source_simple_pin_header:TpA,source_simple_pinout:KpA,source_simple_potentiometer:JpA,source_simple_power_source:LpA,source_simple_push_button:YpA,source_simple_resistor:RpA,source_simple_resonator:PpA,source_simple_switch:VpA,source_simple_test_point:OpA,source_simple_transistor:qpA,source_simple_voltage_probe:dre,source_simple_voltage_source:fre,source_trace:Dre,source_trace_not_connected_error:zpA,supplier_name:Ire,time:W3t,timestamp:zse,unknown_error_finding_part:Gre,visible_layer:um,voltage:Rb,wave_shape:ifA},Symbol.toStringTag,{value:"Module"}));function gn(t,A){return Array.isArray(A)?[t.a*A[0]+t.c*A[1]+t.e,t.b*A[0]+t.d*A[1]+t.f]:{x:t.a*A.x+t.c*A.y+t.e,y:t.b*A.x+t.d*A.y+t.f}}function Nb(){return{a:1,c:0,e:0,b:0,d:1,f:0}}function Mb(t){const{a:A,b:e,c:i,d:n,e:o,f:s}=t,r=A*n-e*i;return{a:n/r,b:e/-r,c:i/-r,d:A/r,e:(n*o-i*s)/-r,f:(e*o-A*s)/r}}function cJ(t){return typeof t>"u"}function jB(t,A=0){return{a:1,c:0,e:t,b:0,d:1,f:A}}function BV(...t){t=Array.isArray(t[0])?t[0]:t;const A=(e,i)=>({a:e.a*i.a+e.c*i.b,c:e.a*i.c+e.c*i.d,e:e.a*i.e+e.c*i.f+e.e,b:e.b*i.a+e.d*i.b,d:e.b*i.c+e.d*i.d,f:e.b*i.e+e.d*i.f+e.f});switch(t.length){case 0:throw new Error("no matrices provided");case 1:return t[0];case 2:return A(t[0],t[1]);default:{const[e,i,...n]=t,o=A(e,i);return BV(o,...n)}}}function dm(...t){return BV(...t)}const{cos:SOt,sin:bOt}=Math;function xOt(t,A,e){const i=SOt(t),n=bOt(t),o={a:i,c:-n,e:0,b:n,d:i,f:0};return cJ(A)||cJ(e)?o:BV([jB(A,e),o,jB(-A,-e)])}function IJ(t,A=void 0,e=void 0,i=void 0){cJ(A)&&(A=t);const n={a:t,c:0,e:0,b:0,d:A,f:0};return cJ(e)||cJ(i)?n:BV([jB(e,i),n,jB(-e,-i)])}function _Ot(t,A){function e(){this.constructor=t}e.prototype=A.prototype,t.prototype=new e}function CV(t,A,e,i){var n=Error.call(this,t);return Object.setPrototypeOf&&Object.setPrototypeOf(n,CV.prototype),n.expected=A,n.found=e,n.location=i,n.name="SyntaxError",n}_Ot(CV,Error);function ofA(t,A,e){return e=e||" ",t.length>A?t:(A-=t.length,e+=e.repeat(A),t+e.slice(0,A))}CV.prototype.format=function(t){var A="Error: "+this.message;if(this.location){var e=null,i;for(i=0;i<t.length;i++)if(t[i].source===this.location.source){e=t[i].text.split(/\r\n|\n|\r/g);break}var n=this.location.start,o=this.location.source&&typeof this.location.source.offset=="function"?this.location.source.offset(n):n,s=this.location.source+":"+o.line+":"+o.column;if(e){var r=this.location.end,a=ofA("",o.line.toString().length," "),g=e[n.line-1],c=n.line===r.line?r.column:g.length+1,I=c-n.column||1;A+=`
@@ -5681,7 +5681,7 @@ test("${g} should solve problem correctly", () => {
5681
5681
  // Add more specific assertions based on expected output
5682
5682
  // expect(solver.netLabelPlacementSolver!.netLabelPlacements).toMatchInlineSnapshot()
5683
5683
  })
5684
- `,I=new Blob([c],{type:"text/plain"}),l=URL.createObjectURL(I),B=document.createElement("a");B.href=l,B.download=`${g}.test.ts`,B.click(),URL.revokeObjectURL(l)}catch(a){alert(`Error generating test.ts for ${t.constructor.name}: ${a instanceof Error?a.message:String(a)}`)}i(!1)};return W.jsxs("div",{className:`relative ${A}`,ref:n,children:[W.jsx("button",{className:"px-2 py-1 rounded text-xs cursor-pointer",onClick:()=>i(!e),title:`Download options for ${t.constructor.name}`,children:t.constructor.name}),e&&W.jsxs("div",{className:"absolute top-full left-0 mt-1 bg-white border border-gray-300 rounded shadow-lg z-10 min-w-[150px]",children:[W.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:o,children:"Download JSON"}),W.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:s,children:"Download page.tsx"}),W.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:r,children:"Download test.ts"})]})]})},wIe=t=>t.activeSubSolver?[t,...wIe(t.activeSubSolver)]:[t],$9t=({solver:t})=>{const A=wIe(t);return W.jsx("div",{className:"flex gap-1 items-center text-sm pt-1",children:A.map((e,i)=>W.jsxs("div",{className:"flex items-center",children:[i>0&&W.jsx("span",{className:"text-gray-400 mx-1",children:"→"}),W.jsx(X9t,{solver:e})]},e.constructor.name))})},AVt=({solver:t,triggerRender:A,animationSpeed:e=25,onSolverStarted:i,onSolverCompleted:n})=>{const[o,s]=V.useReducer(Q=>!Q,!1),r=V.useRef(void 0),a=()=>{!t.solved&&!t.failed&&(t.step(),A())},g=()=>{!t.solved&&!t.failed&&(i&&i(t),t.solve(),A(),n&&n(t))},c=()=>{o?(r.current&&(clearInterval(r.current),r.current=void 0),s()):(s(),r.current=setInterval(()=>{if(t.solved||t.failed){r.current&&(clearInterval(r.current),r.current=void 0),s(),A(),n&&t.solved&&n(t);return}t.step(),A()},e))},I=()=>{const Q=t;if(Q.getCurrentPhase&&!t.solved&&!t.failed){const h=Q.getCurrentPhase();for(;Q.getCurrentPhase()===h&&!t.solved&&!t.failed;)t.step();A()}},l=()=>{if(t.solved||t.failed||o)return;const Q=window.prompt("Step until which iteration?",`${t.iterations}`);if(Q===null)return;const h=Number(Q);if(!Number.isFinite(h)){window.alert("Please enter a valid number for the iteration");return}for(;t.iterations<h&&!t.solved&&!t.failed;)t.step();A(),t.solved&&n&&n(t)};V.useEffect(()=>()=>{r.current&&clearInterval(r.current)},[]),V.useEffect(()=>{(t.solved||t.failed)&&o&&(r.current&&(clearInterval(r.current),r.current=void 0),s())},[t.solved,t.failed,o]);const B=t.getCurrentPhase!==void 0,C=B?t.getCurrentPhase():null;return W.jsxs("div",{className:"space-y-2 p-2 border-b",children:[W.jsx("div",{className:"flex items-center",children:W.jsx($9t,{solver:t})}),W.jsxs("div",{className:"flex gap-2 items-center flex-wrap",children:[W.jsx("button",{onClick:a,disabled:t.solved||t.failed||o,className:"bg-blue-500 hover:bg-blue-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Step"}),W.jsx("button",{onClick:g,disabled:t.solved||t.failed||o,className:"bg-green-500 hover:bg-green-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Solve"}),W.jsx("button",{onClick:c,disabled:t.solved||t.failed,className:`px-3 py-1 rounded text-white text-sm ${o?"bg-red-500 hover:bg-red-600":"bg-yellow-500 hover:bg-yellow-600"} disabled:bg-gray-300`,children:o?"Stop":"Animate"}),W.jsx("button",{onClick:l,disabled:t.solved||t.failed||o,className:"bg-orange-500 hover:bg-orange-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Step Until Iteration"}),B&&W.jsx("button",{onClick:I,disabled:t.solved||t.failed||o,className:"bg-purple-500 hover:bg-purple-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Next Stage"}),W.jsxs("div",{className:"text-sm text-gray-600",children:["Iterations: ",t.iterations]}),t.timeToSolve!==void 0&&W.jsxs("div",{className:"text-sm text-gray-600",children:["Time: ",(t.timeToSolve/1e3).toFixed(3),"s"]}),C&&W.jsxs("div",{className:"text-sm text-gray-600",children:["Phase: ",W.jsx("span",{className:"font-medium",children:C})]}),t.solved&&W.jsx("div",{className:"px-2 py-1 bg-green-100 text-green-800 rounded text-sm",children:"Solved"}),t.failed&&W.jsx("div",{className:"px-2 py-1 bg-red-100 text-red-800 rounded text-sm",children:"Failed"})]}),t.error&&W.jsxs("div",{className:"text-red-600 text-sm",children:["Error: ",t.error]})]})},eVt=(t,A,e)=>{const i=t.currentPipelineStepIndex;return A<i?"Completed":A===i&&t.activeSubSolver?t.activeSubSolver.failed?"Failed":"In Progress":"Not Started"},tVt=(t,A)=>{const i=t.pipelineDef[A].solverName,n=eVt(t,A),o=t[i],s=t.firstIterationOfPhase?.[i]??null,r=t.iterations;let a=0;if(n==="Completed"){const l=t.pipelineDef[A+1],B=l?t.firstIterationOfPhase?.[l.solverName]:void 0;B!==void 0&&s!==null?a=B-s:s!==null&&(a=r-s)}else n==="In Progress"&&s!==null&&(a=r-s);const g=t.timeSpentOnPhase?.[i]??0;let c=0;n==="Completed"?c=1:n==="In Progress"&&o&&(c=o.progress??0);const I=o?.stats??null;return{index:A,name:i,status:n,firstIteration:s,iterations:a,progress:c,timeSpent:g,stats:I&&Object.keys(I).length>0?I:null,solverInstance:o??null}},iVt=({status:t})=>{const A={"Not Started":"text-blue-600","In Progress":"text-yellow-600",Completed:"text-green-600",Failed:"text-red-600"};return W.jsx("span",{className:`font-medium ${A[t]}`,children:t})},nVt=({progress:t})=>{if(t===0)return null;const A=Math.round(t*100);return W.jsxs("div",{className:"flex items-center gap-2",children:[W.jsx("div",{className:"w-20 h-2 bg-gray-200 rounded overflow-hidden",children:W.jsx("div",{className:"h-full bg-blue-500 transition-all duration-200",style:{width:`${A}%`}})}),W.jsxs("span",{className:"text-xs text-gray-500",children:[A,"%"]})]})},oVt=t=>Object.entries(t).map(([A,e])=>`${A}: ${e}`).join(", "),sVt=({stats:t})=>{if(!t||Object.keys(t).length===0)return W.jsx("span",{children:"-"});const A=Object.entries(t),e=oVt(t);return W.jsxs("details",{className:"cursor-pointer",children:[W.jsx("summary",{className:"whitespace-nowrap overflow-hidden text-ellipsis max-w-[200px]",children:e}),W.jsx("div",{className:"mt-1 text-xs",children:A.map(([i,n])=>W.jsxs("div",{children:[i,": ",String(n)]},i))})]})},PfA=t=>{if(t===null||typeof t!="object")return t;if(Array.isArray(t))return t.map(PfA);const A={};for(const[e,i]of Object.entries(t))e.startsWith("_")||(A[e]=PfA(i));return A},rVt=(t,A)=>{try{if(typeof t.getConstructorParams!="function"){alert(`getConstructorParams() is not implemented for ${A}`);return}const e=PfA(t.getConstructorParams()),i=new Blob([JSON.stringify(e,null,2)],{type:"application/json"}),n=URL.createObjectURL(i),o=document.createElement("a");o.href=n,o.download=`${A}_input.json`,o.click(),URL.revokeObjectURL(n)}catch(e){alert(`Error downloading input for ${A}: ${e instanceof Error?e.message:String(e)}`)}},aVt=({solver:t,onStepUntilPhase:A,onDownloadInput:e})=>{const i=t.pipelineDef.map((r,a)=>tVt(t,a)),n=r=>{A?.(r)},o=r=>{r.solverInstance&&(e?e(r.solverInstance,r.name):rVt(r.solverInstance,r.name))},s=r=>`${(r/1e3).toFixed(2)}s`;return W.jsxs("div",{className:"border-t border-gray-200",children:[W.jsx("div",{className:"px-4 py-2 bg-gray-50 border-b border-gray-200",children:W.jsx("h3",{className:"text-sm font-semibold text-gray-700",children:"Pipeline Steps"})}),W.jsx("div",{className:"overflow-x-auto",children:W.jsxs("table",{className:"w-full text-sm",children:[W.jsx("thead",{children:W.jsxs("tr",{className:"bg-gray-50 border-b border-gray-200",children:[W.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Step"}),W.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Status"}),W.jsxs("th",{className:"px-4 py-2 text-center font-semibold text-gray-700",children:["i",W.jsx("sub",{children:"0"})]}),W.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Iterations"}),W.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Progress"}),W.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Time"}),W.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Stats"}),W.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Input"})]})}),W.jsx("tbody",{children:i.map(r=>W.jsxs("tr",{className:`border-b border-gray-100 ${r.status==="In Progress"?"bg-yellow-50":""}`,children:[W.jsx("td",{className:"px-4 py-2",children:W.jsxs("div",{className:"flex items-center gap-2",children:[W.jsx("span",{className:"text-gray-400 w-6",children:String(r.index+1).padStart(2,"0")}),W.jsx("button",{onClick:()=>n(r.name),disabled:r.status==="Completed"||t.solved||t.failed,className:"text-blue-500 hover:text-blue-700 disabled:text-gray-300 disabled:cursor-not-allowed",title:`Step until ${r.name} completes`,children:W.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:W.jsx("path",{fillRule:"evenodd",d:"M4.5 5.653c0-1.426 1.529-2.33 2.779-1.643l11.54 6.348c1.295.712 1.295 2.573 0 3.285L7.28 19.991c-1.25.687-2.779-.217-2.779-1.643V5.653z",clipRule:"evenodd"})})}),W.jsx("span",{className:"font-medium text-gray-900",children:r.name})]})}),W.jsx("td",{className:"px-4 py-2",children:W.jsx(iVt,{status:r.status})}),W.jsx("td",{className:"px-4 py-2 text-center text-gray-600",children:r.firstIteration!==null?r.firstIteration:""}),W.jsx("td",{className:"px-4 py-2 text-gray-600",children:r.iterations}),W.jsx("td",{className:"px-4 py-2",children:W.jsx(nVt,{progress:r.progress})}),W.jsx("td",{className:"px-4 py-2 text-gray-600",children:s(r.timeSpent)}),W.jsx("td",{className:"px-4 py-2 text-gray-500",children:W.jsx(sVt,{stats:r.stats})}),W.jsx("td",{className:"px-4 py-2",children:r.solverInstance?W.jsxs("button",{onClick:()=>o(r),className:"flex items-center gap-1 text-blue-500 hover:text-blue-700",title:`Download input for ${r.name}`,children:[W.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:W.jsx("path",{fillRule:"evenodd",d:"M12 2.25a.75.75 0 01.75.75v11.69l3.22-3.22a.75.75 0 111.06 1.06l-4.5 4.5a.75.75 0 01-1.06 0l-4.5-4.5a.75.75 0 111.06-1.06l3.22 3.22V3a.75.75 0 01.75-.75zm-9 13.5a.75.75 0 01.75.75v2.25a1.5 1.5 0 001.5 1.5h13.5a1.5 1.5 0 001.5-1.5V16.5a.75.75 0 011.5 0v2.25a3 3 0 01-3 3H5.25a3 3 0 01-3-3V16.5a.75.75 0 01.75-.75z",clipRule:"evenodd"})}),W.jsx("span",{children:"Input"})]}):null})]},r.name))})]})})]})},gVt=class extends yn.Component{constructor(t){super(t),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(t){console.error("InteractiveGraphics render error:",t)}render(){return this.state.hasError?this.props.fallback:this.props.children}};function cVt({graphics:t}){const A=t.points??[],e=t.lines??[],i=t.rects??[],n=t.circles??[],o=t.texts??[];let s=Number.POSITIVE_INFINITY,r=Number.POSITIVE_INFINITY,a=Number.NEGATIVE_INFINITY,g=Number.NEGATIVE_INFINITY;const c=(h,E)=>{typeof h=="number"&&(h<s&&(s=h),h>a&&(a=h)),typeof E=="number"&&(E<r&&(r=E),E>g&&(g=E))};for(const h of A)c(h.x,h.y);for(const h of e){const E=h.points??[];for(const u of E)c(u.x,u.y)}for(const h of i){const E=h.x??0,u=h.y??0,d=h.width??0,f=h.height??0;c(E,u),c(E+d,u+f)}for(const h of n){const E=h.x??0,u=h.y??0,d=h.radius??1;c(E-d,u-d),c(E+d,u+d)}for(const h of o)c(h.x,h.y);(!isFinite(s)||!isFinite(r)||!isFinite(a)||!isFinite(g))&&(s=-20,r=-20,a=20,g=20);const I=10,l=s-I,B=r-I,C=Math.max(1,a-s+2*I),Q=Math.max(1,g-r+2*I);return W.jsxs("svg",{className:"w-full h-[400px] bg-white",viewBox:`${l} ${B} ${C} ${Q}`,role:"img","aria-label":"Graphics fallback",children:[i.map((h,E)=>W.jsx("rect",{x:h.x??0,y:h.y??0,width:h.width??0,height:h.height??0,fill:"none",stroke:h.strokeColor??"black",strokeWidth:h.strokeWidth??1},`rect-${E}`)),e.map((h,E)=>W.jsx("polyline",{fill:"none",stroke:h.strokeColor??"black",strokeWidth:h.strokeWidth??1,points:(h.points??[]).map(u=>`${u.x??0},${u.y??0}`).join(" ")},`line-${E}`)),n.map((h,E)=>W.jsx("circle",{cx:h.x??0,cy:h.y??0,r:h.radius??1.5,fill:h.fillColor??"none",stroke:h.strokeColor??"black",strokeWidth:h.strokeWidth??1},`circle-${E}`)),A.map((h,E)=>W.jsx("circle",{cx:h.x??0,cy:h.y??0,r:h.radius??1.5,fill:h.color??"black"},`point-${E}`)),o.map((h,E)=>W.jsx("text",{x:h.x??0,y:h.y??0,fontSize:h.fontSize??10,fill:h.color??"black",children:h.text??""},`text-${E}`))]})}var IVt=({solver:t,animationSpeed:A=25,onSolverStarted:e,onSolverCompleted:i})=>{const[n,o]=V.useReducer(c=>c+1,0),s=V.useMemo(()=>{try{return t.visualize()||{points:[],lines:[],rects:[],circles:[]}}catch(c){return console.error("Visualization error:",c),{points:[],lines:[],rects:[],circles:[]}}},[t,n]),r=V.useMemo(()=>(s.rects?.length||0)===0&&(s.lines?.length||0)===0&&(s.points?.length||0)===0&&(s.circles?.length||0)===0,[s]);V.useEffect(()=>{if(!(typeof document>"u")&&!document.querySelector('script[src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4"]')){const c=document.createElement("script");c.src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4",document.head.appendChild(c)}},[]);const a=t.pipelineDef!==void 0,g=c=>{const I=t;if(!t.solved&&!t.failed){for(;!t.solved&&!t.failed&&I.currentPipelineStepIndex<=I.pipelineDef.findIndex(l=>l.solverName===c);)t.step();o()}};return W.jsxs("div",{children:[W.jsx(AVt,{solver:t,triggerRender:o,animationSpeed:A,onSolverStarted:e,onSolverCompleted:i}),r?W.jsx("div",{className:"p-4 text-gray-500",children:"No Graphics Yet"}):W.jsx(gVt,{fallback:W.jsx(cVt,{graphics:s}),children:W.jsx(z9t,{graphics:s})}),a&&W.jsx(aVt,{solver:t,onStepUntilPhase:g})]})};const lVt=()=>{V.useEffect(()=>{const t="tailwind-cdn-script";if(document.getElementById(t)||window.tailwind)return;const A=document.createElement("div");A.className="hidden",document.body.appendChild(A);const e=window.getComputedStyle(A).display==="none";if(document.body.removeChild(A),e)return;const i=document.createElement("script");i.id=t,i.src="https://cdn.tailwindcss.com",document.head.appendChild(i)},[])},BVt=t=>t.toLowerCase().includes("pack")?NNt:t.toLowerCase().includes("rout")?YNt:pNt,CVt=({solverEvents:t=[]})=>{const[A,e]=V.useState(null);lVt();const i=V.useMemo(()=>{const r=new Map;for(const a of t){const g=`${a.componentName}-${a.solverName}`;r.set(g,a)}return r},[t]),n=V.useMemo(()=>Array.from(i.keys()),[i]),o=A?i.get(A):null,s=V.useMemo(()=>{if(!o)return{instance:null,error:null,classFound:!1};const r=znA[o.solverName];if(!r)return{instance:null,error:`Solver class "${o.solverName}" not found in SOLVERS registry. Available: ${Object.keys(znA).join(", ")}`,classFound:!1};try{const a=o.solverParams,g=a?.input!==void 0?a.input:a;return{instance:new r(g),error:null,classFound:!0}}catch(a){const g=a instanceof Error?a.message:String(a);return console.error("Failed to reconstruct solver:",a),{instance:null,error:`Failed to instantiate solver: ${g}`,classFound:!0}}},[o]);return t.length===0?W.jsx("div",{className:"rf-p-4",children:W.jsx("div",{className:"rf-bg-gray-50 rf-rounded-md rf-border rf-border-gray-200",children:W.jsxs("div",{className:"rf-p-4",children:[W.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800 rf-mb-3",children:"No Solvers Detected"}),W.jsx("p",{className:"rf-text-sm rf-text-gray-600",children:"Solvers will appear here when the circuit runs. Solvers are used for tasks like component packing and autorouting."})]})})}):W.jsxs("div",{className:"rf-flex rf-h-full rf-overflow-hidden",children:[W.jsxs("div",{className:"rf-w-64 rf-border-r rf-border-gray-200 rf-overflow-y-auto rf-flex-shrink-0",children:[W.jsxs("div",{className:"rf-text-xs rf-font-semibold rf-text-gray-500 rf-px-3 rf-py-2 rf-bg-gray-50 rf-border-b rf-border-gray-200",children:[n.length," ",n.length===1?"Solver":"Solvers"]}),n.map(r=>{const a=i.get(r),g=A===r;return W.jsx("div",{className:`rf-px-3 rf-py-2 rf-cursor-pointer rf-border-b rf-border-gray-100 ${g?"rf-bg-blue-50 rf-border-l-2 rf-border-l-blue-500":"hover:rf-bg-gray-50"}`,onClick:()=>e(r),children:(()=>{const c=BVt(a.solverName);return W.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2",children:[W.jsx(c,{className:"rf-w-4 rf-h-4 rf-text-blue-500 rf-flex-shrink-0"}),W.jsxs("div",{className:"rf-flex-1 rf-min-w-0",children:[W.jsx("div",{className:"rf-text-sm rf-font-medium rf-text-gray-800 rf-truncate",children:a.componentName}),W.jsx("div",{className:"rf-text-xs rf-text-gray-500 rf-truncate",children:a.solverName})]})]})})()},r)})]}),W.jsx("div",{className:"rf-flex-1 rf-overflow-hidden",children:o?s.instance?W.jsx(rm,{fallback:W.jsx("div",{className:"rf-p-4",children:W.jsxs("div",{className:"rf-bg-red-50 rf-rounded-md rf-border rf-border-red-200 rf-p-4",children:[W.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-red-800 rf-mb-2",children:"Error Loading Solver Debugger"}),W.jsxs("p",{className:"rf-text-sm rf-text-red-600",children:["Failed to render the solver debugger for"," ",o.solverName]})]})}),children:W.jsx(IVt,{solver:s.instance})}):W.jsxs("div",{className:"rf-p-4",children:[W.jsxs("div",{className:"rf-mb-4",children:[W.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800",children:o.solverName}),W.jsxs("p",{className:"rf-text-sm rf-text-gray-500",children:["Component: ",o.componentName]})]}),s.error&&W.jsx("div",{className:`rf-rounded-md rf-border rf-p-4 rf-mb-4 ${s.classFound?"rf-bg-red-50 rf-border-red-200":"rf-bg-yellow-50 rf-border-yellow-200"}`,children:W.jsx("p",{className:`rf-text-sm ${s.classFound?"rf-text-red-700":"rf-text-yellow-700"}`,children:s.error})}),W.jsxs("div",{className:"rf-border rf-border-gray-200 rf-rounded-md rf-overflow-hidden",children:[W.jsx("div",{className:"rf-px-3 rf-py-2 rf-bg-gray-50",children:W.jsx("span",{className:"rf-text-sm rf-font-medium rf-text-gray-700",children:"Solver Parameters"})}),W.jsx("div",{className:"rf-p-3 rf-bg-white rf-border-t rf-border-gray-200",children:W.jsx("pre",{className:"rf-text-xs rf-font-mono rf-text-gray-600 rf-whitespace-pre-wrap rf-overflow-x-auto",children:JSON.stringify(o.solverParams,null,2)})})]})]}):W.jsx("div",{className:"rf-flex rf-items-center rf-justify-center rf-h-full",children:W.jsx("p",{className:"rf-text-sm rf-text-gray-500",children:"Select a solver from the list to view details"})})})]})},DIe=({errorMessage:t,errorStack:A,circuitJsonErrors:e})=>{V.useEffect(()=>{if(t){const i=new Error(t);A&&(i.stack=A);try{J5.captureException(i)}catch{}}},[t,A]),V.useEffect(()=>{if(e&&e.length>0)for(const i of e){const n=new Error(i.message||"Circuit JSON Error");i.stack&&(n.stack=i.stack);try{J5.captureException(n,{error_type:i.type})}catch{}}},[e])},SIe="0.0.1687",QVt={version:SIe},WV=FYA()(vYA(t=>({lastRunEvalVersion:void 0,setLastRunEvalVersion:A=>{t({lastRunEvalVersion:A})}}),{name:"runframe-runner-store"})),hVt=t=>{const[A,e]=V.useState([]),[i,n]=V.useState(null),[o,s]=V.useState(""),[r,a]=jR("eval-version-selection",null),g=WV(B=>B.setLastRunEvalVersion),c=WV(B=>B.lastRunEvalVersion);return V.useEffect(()=>{t&&fetch("https://data.jsdelivr.com/v1/package/npm/@tscircuit/eval").then(B=>B.json()).then(B=>{if(Array.isArray(B?.versions)){let C=[...B.versions];B.tags?.latest&&(n(B.tags.latest),C=C.filter(Q=>Q!==B.tags.latest)),e(C)}}).catch(()=>{})},[t]),V.useEffect(()=>{t&&(r?(window.TSCIRCUIT_LATEST_EVAL_VERSION=r,g(r)):i&&(window.TSCIRCUIT_LATEST_EVAL_VERSION=i,g(i)))},[t,r,i]),{versions:V.useMemo(()=>A.filter(B=>B.includes(o)).slice(0,50),[A,o]),latestVersion:i,lastRunEvalVersion:c,search:o,setSearch:s,selectVersion:B=>{a(B),s("")}}},EVt=({snippetNames:t,onSelect:A,onCancel:e,isOpen:i})=>{const[n,o]=V.useState(""),[s,r]=V.useState("");if(!i)return null;const a=t.filter(I=>I.toLowerCase().includes(s.toLowerCase())),g=s&&!t.includes(s),c=I=>{I.key==="Enter"&&(a.length===1?o(a[0]):g&&o(s))};return W.jsx("div",{className:"rf-fixed rf-inset-0 rf-bg-black rf-bg-opacity-50 rf-flex rf-items-center rf-justify-center rf-z-[100]",children:W.jsxs("div",{className:"rf-bg-white rf-rounded-lg rf-p-6 rf-w-96",children:[W.jsx("h2",{className:"rf-text-lg rf-font-semibold rf-mb-4",children:"Select Snippet"}),W.jsx("input",{type:"text",className:"rf-w-full rf-px-4 rf-py-2 rf-border rf-rounded rf-mb-4",placeholder:"Search snippets or new snippet name...",value:s,onChange:I=>r(I.target.value),onKeyDown:c}),W.jsxs("div",{className:"rf-h-60 rf-overflow-y-auto",children:[a.map(I=>W.jsx("button",{type:"button",className:`w-full text-left px-4 py-2 rounded hover:bg-gray-100 ${n===I?"bg-blue-50":""}`,onClick:()=>o(I),children:I},I)),g&&W.jsxs("button",{type:"button",className:`w-full text-left px-4 py-2 rounded hover:bg-gray-100 text-blue-500 ${n===s?"bg-blue-50":""}`,onClick:()=>o(s),children:['Create new "',s,'"']})]}),W.jsxs("div",{className:"rf-mt-4 rf-flex rf-justify-end rf-gap-2",children:[W.jsx("button",{type:"button",className:"rf-px-4 rf-py-2 rf-text-gray-600 rf-hover:text-gray-800",onClick:e,children:"Cancel"}),W.jsx("button",{type:"button",className:"rf-px-4 rf-py-2 rf-bg-blue-500 rf-text-white rf-rounded rf-hover:bg-blue-600 rf-disabled:opacity-50",onClick:()=>n&&A(n),disabled:!n,children:n===s?`Create "${n}"`:`Save to ${n}`})]})]})})},uVt=t=>{const A=V.useRef(null),e=Yl(i=>i.recentEvents);V.useEffect(()=>{if(e.length===0)return;const i=e[0];i.event_id!==A.current&&(t(i),A.current=i.event_id)},[e,t])};function dVt(t){const A=pVt(t),e=V.forwardRef((i,n)=>{const{children:o,...s}=i,r=V.Children.toArray(o),a=r.find(yVt);if(a){const g=a.props.children,c=r.map(I=>I===a?V.Children.count(g)>1?V.Children.only(null):V.isValidElement(g)?g.props.children:null:I);return W.jsx(A,{...s,ref:n,children:V.isValidElement(g)?V.cloneElement(g,void 0,c):null})}return W.jsx(A,{...s,ref:n,children:o})});return e.displayName=`${t}.Slot`,e}function pVt(t){const A=V.forwardRef((e,i)=>{const{children:n,...o}=e;if(V.isValidElement(n)){const s=wVt(n),r=mVt(o,n.props);return n.type!==V.Fragment&&(r.ref=i?xf(i,s):s),V.cloneElement(n,r)}return V.Children.count(n)>1?V.Children.only(null):null});return A.displayName=`${t}.SlotClone`,A}var fVt=Symbol("radix.slottable");function yVt(t){return V.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===fVt}function mVt(t,A){const e={...A};for(const i in A){const n=t[i],o=A[i];/^on[A-Z]/.test(i)?n&&o?e[i]=(...r)=>{const a=o(...r);return n(...r),a}:n&&(e[i]=n):i==="style"?e[i]={...n,...o}:i==="className"&&(e[i]=[n,o].filter(Boolean).join(" "))}return{...t,...e}}function wVt(t){let A=Object.getOwnPropertyDescriptor(t.props,"ref")?.get,e=A&&"isReactWarning"in A&&A.isReactWarning;return e?t.ref:(A=Object.getOwnPropertyDescriptor(t,"ref")?.get,e=A&&"isReactWarning"in A&&A.isReactWarning,e?t.props.ref:t.props.ref||t.ref)}var ZV="Dialog",[bIe,xIe]=ew(ZV),[DVt,Dw]=bIe(ZV),_Ie=t=>{const{__scopeDialog:A,children:e,open:i,defaultOpen:n,onOpenChange:o,modal:s=!0}=t,r=V.useRef(null),a=V.useRef(null),[g,c]=jx({prop:i,defaultProp:n??!1,onChange:o,caller:ZV});return W.jsx(DVt,{scope:A,triggerRef:r,contentRef:a,contentId:ou(),titleId:ou(),descriptionId:ou(),open:g,onOpenChange:c,onOpenToggle:V.useCallback(()=>c(I=>!I),[c]),modal:s,children:e})};_Ie.displayName=ZV;var kIe="DialogTrigger",FIe=V.forwardRef((t,A)=>{const{__scopeDialog:e,...i}=t,n=Dw(kIe,e),o=ol(A,n.triggerRef);return W.jsx(yg.button,{type:"button","aria-haspopup":"dialog","aria-expanded":n.open,"aria-controls":n.contentId,"data-state":WfA(n.open),...i,ref:o,onClick:co(t.onClick,n.onOpenToggle)})});FIe.displayName=kIe;var qfA="DialogPortal",[SVt,vIe]=bIe(qfA,{forceMount:void 0}),GIe=t=>{const{__scopeDialog:A,forceMount:e,children:i,container:n}=t,o=Dw(qfA,A);return W.jsx(SVt,{scope:A,forceMount:e,children:V.Children.map(i,s=>W.jsx(H0,{present:e||o.open,children:W.jsx(VZ,{asChild:!0,container:n,children:s})}))})};GIe.displayName=qfA;var VV="DialogOverlay",RIe=V.forwardRef((t,A)=>{const e=vIe(VV,t.__scopeDialog),{forceMount:i=e.forceMount,...n}=t,o=Dw(VV,t.__scopeDialog);return o.modal?W.jsx(H0,{present:i||o.open,children:W.jsx(xVt,{...n,ref:A})}):null});RIe.displayName=VV;var bVt=dVt("DialogOverlay.RemoveScroll"),xVt=V.forwardRef((t,A)=>{const{__scopeDialog:e,...i}=t,n=Dw(VV,e);return W.jsx(i9,{as:bVt,allowPinchZoom:!0,shards:[n.contentRef],children:W.jsx(yg.div,{"data-state":WfA(n.open),...i,ref:A,style:{pointerEvents:"auto",...i.style}})})}),Ov="DialogContent",NIe=V.forwardRef((t,A)=>{const e=vIe(Ov,t.__scopeDialog),{forceMount:i=e.forceMount,...n}=t,o=Dw(Ov,t.__scopeDialog);return W.jsx(H0,{present:i||o.open,children:o.modal?W.jsx(_Vt,{...n,ref:A}):W.jsx(kVt,{...n,ref:A})})});NIe.displayName=Ov;var _Vt=V.forwardRef((t,A)=>{const e=Dw(Ov,t.__scopeDialog),i=V.useRef(null),n=ol(A,e.contentRef,i);return V.useEffect(()=>{const o=i.current;if(o)return juA(o)},[]),W.jsx(MIe,{...t,ref:n,trapFocus:e.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:co(t.onCloseAutoFocus,o=>{o.preventDefault(),e.triggerRef.current?.focus()}),onPointerDownOutside:co(t.onPointerDownOutside,o=>{const s=o.detail.originalEvent,r=s.button===0&&s.ctrlKey===!0;(s.button===2||r)&&o.preventDefault()}),onFocusOutside:co(t.onFocusOutside,o=>o.preventDefault())})}),kVt=V.forwardRef((t,A)=>{const e=Dw(Ov,t.__scopeDialog),i=V.useRef(!1),n=V.useRef(!1);return W.jsx(MIe,{...t,ref:A,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:o=>{t.onCloseAutoFocus?.(o),o.defaultPrevented||(i.current||e.triggerRef.current?.focus(),o.preventDefault()),i.current=!1,n.current=!1},onInteractOutside:o=>{t.onInteractOutside?.(o),o.defaultPrevented||(i.current=!0,o.detail.originalEvent.type==="pointerdown"&&(n.current=!0));const s=o.target;e.triggerRef.current?.contains(s)&&o.preventDefault(),o.detail.originalEvent.type==="focusin"&&n.current&&o.preventDefault()}})}),MIe=V.forwardRef((t,A)=>{const{__scopeDialog:e,trapFocus:i,onOpenAutoFocus:n,onCloseAutoFocus:o,...s}=t,r=Dw(Ov,e),a=V.useRef(null),g=ol(A,a);return FuA(),W.jsxs(W.Fragment,{children:[W.jsx(MZ,{asChild:!0,loop:!0,trapped:i,onMountAutoFocus:n,onUnmountAutoFocus:o,children:W.jsx(aY,{role:"dialog",id:r.contentId,"aria-describedby":r.descriptionId,"aria-labelledby":r.titleId,"data-state":WfA(r.open),...s,ref:g,onDismiss:()=>r.onOpenChange(!1)})}),W.jsxs(W.Fragment,{children:[W.jsx(vVt,{titleId:r.titleId}),W.jsx(RVt,{contentRef:a,descriptionId:r.descriptionId})]})]})}),OfA="DialogTitle",LIe=V.forwardRef((t,A)=>{const{__scopeDialog:e,...i}=t,n=Dw(OfA,e);return W.jsx(yg.h2,{id:n.titleId,...i,ref:A})});LIe.displayName=OfA;var UIe="DialogDescription",HIe=V.forwardRef((t,A)=>{const{__scopeDialog:e,...i}=t,n=Dw(UIe,e);return W.jsx(yg.p,{id:n.descriptionId,...i,ref:A})});HIe.displayName=UIe;var YIe="DialogClose",JIe=V.forwardRef((t,A)=>{const{__scopeDialog:e,...i}=t,n=Dw(YIe,e);return W.jsx(yg.button,{type:"button",...i,ref:A,onClick:co(t.onClick,()=>n.onOpenChange(!1))})});JIe.displayName=YIe;function WfA(t){return t?"open":"closed"}var TIe="DialogTitleWarning",[FVt,KIe]=w6e(TIe,{contentName:Ov,titleName:OfA,docsSlug:"dialog"}),vVt=({titleId:t})=>{const A=KIe(TIe),e=`\`${A.contentName}\` requires a \`${A.titleName}\` for the component to be accessible for screen reader users.
5684
+ `,I=new Blob([c],{type:"text/plain"}),l=URL.createObjectURL(I),B=document.createElement("a");B.href=l,B.download=`${g}.test.ts`,B.click(),URL.revokeObjectURL(l)}catch(a){alert(`Error generating test.ts for ${t.constructor.name}: ${a instanceof Error?a.message:String(a)}`)}i(!1)};return W.jsxs("div",{className:`relative ${A}`,ref:n,children:[W.jsx("button",{className:"px-2 py-1 rounded text-xs cursor-pointer",onClick:()=>i(!e),title:`Download options for ${t.constructor.name}`,children:t.constructor.name}),e&&W.jsxs("div",{className:"absolute top-full left-0 mt-1 bg-white border border-gray-300 rounded shadow-lg z-10 min-w-[150px]",children:[W.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:o,children:"Download JSON"}),W.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:s,children:"Download page.tsx"}),W.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:r,children:"Download test.ts"})]})]})},wIe=t=>t.activeSubSolver?[t,...wIe(t.activeSubSolver)]:[t],$9t=({solver:t})=>{const A=wIe(t);return W.jsx("div",{className:"flex gap-1 items-center text-sm pt-1",children:A.map((e,i)=>W.jsxs("div",{className:"flex items-center",children:[i>0&&W.jsx("span",{className:"text-gray-400 mx-1",children:"→"}),W.jsx(X9t,{solver:e})]},e.constructor.name))})},AVt=({solver:t,triggerRender:A,animationSpeed:e=25,onSolverStarted:i,onSolverCompleted:n})=>{const[o,s]=V.useReducer(Q=>!Q,!1),r=V.useRef(void 0),a=()=>{!t.solved&&!t.failed&&(t.step(),A())},g=()=>{!t.solved&&!t.failed&&(i&&i(t),t.solve(),A(),n&&n(t))},c=()=>{o?(r.current&&(clearInterval(r.current),r.current=void 0),s()):(s(),r.current=setInterval(()=>{if(t.solved||t.failed){r.current&&(clearInterval(r.current),r.current=void 0),s(),A(),n&&t.solved&&n(t);return}t.step(),A()},e))},I=()=>{const Q=t;if(Q.getCurrentPhase&&!t.solved&&!t.failed){const h=Q.getCurrentPhase();for(;Q.getCurrentPhase()===h&&!t.solved&&!t.failed;)t.step();A()}},l=()=>{if(t.solved||t.failed||o)return;const Q=window.prompt("Step until which iteration?",`${t.iterations}`);if(Q===null)return;const h=Number(Q);if(!Number.isFinite(h)){window.alert("Please enter a valid number for the iteration");return}for(;t.iterations<h&&!t.solved&&!t.failed;)t.step();A(),t.solved&&n&&n(t)};V.useEffect(()=>()=>{r.current&&clearInterval(r.current)},[]),V.useEffect(()=>{(t.solved||t.failed)&&o&&(r.current&&(clearInterval(r.current),r.current=void 0),s())},[t.solved,t.failed,o]);const B=t.getCurrentPhase!==void 0,C=B?t.getCurrentPhase():null;return W.jsxs("div",{className:"space-y-2 p-2 border-b",children:[W.jsx("div",{className:"flex items-center",children:W.jsx($9t,{solver:t})}),W.jsxs("div",{className:"flex gap-2 items-center flex-wrap",children:[W.jsx("button",{onClick:a,disabled:t.solved||t.failed||o,className:"bg-blue-500 hover:bg-blue-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Step"}),W.jsx("button",{onClick:g,disabled:t.solved||t.failed||o,className:"bg-green-500 hover:bg-green-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Solve"}),W.jsx("button",{onClick:c,disabled:t.solved||t.failed,className:`px-3 py-1 rounded text-white text-sm ${o?"bg-red-500 hover:bg-red-600":"bg-yellow-500 hover:bg-yellow-600"} disabled:bg-gray-300`,children:o?"Stop":"Animate"}),W.jsx("button",{onClick:l,disabled:t.solved||t.failed||o,className:"bg-orange-500 hover:bg-orange-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Step Until Iteration"}),B&&W.jsx("button",{onClick:I,disabled:t.solved||t.failed||o,className:"bg-purple-500 hover:bg-purple-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Next Stage"}),W.jsxs("div",{className:"text-sm text-gray-600",children:["Iterations: ",t.iterations]}),t.timeToSolve!==void 0&&W.jsxs("div",{className:"text-sm text-gray-600",children:["Time: ",(t.timeToSolve/1e3).toFixed(3),"s"]}),C&&W.jsxs("div",{className:"text-sm text-gray-600",children:["Phase: ",W.jsx("span",{className:"font-medium",children:C})]}),t.solved&&W.jsx("div",{className:"px-2 py-1 bg-green-100 text-green-800 rounded text-sm",children:"Solved"}),t.failed&&W.jsx("div",{className:"px-2 py-1 bg-red-100 text-red-800 rounded text-sm",children:"Failed"})]}),t.error&&W.jsxs("div",{className:"text-red-600 text-sm",children:["Error: ",t.error]})]})},eVt=(t,A,e)=>{const i=t.currentPipelineStepIndex;return A<i?"Completed":A===i&&t.activeSubSolver?t.activeSubSolver.failed?"Failed":"In Progress":"Not Started"},tVt=(t,A)=>{const i=t.pipelineDef[A].solverName,n=eVt(t,A),o=t[i],s=t.firstIterationOfPhase?.[i]??null,r=t.iterations;let a=0;if(n==="Completed"){const l=t.pipelineDef[A+1],B=l?t.firstIterationOfPhase?.[l.solverName]:void 0;B!==void 0&&s!==null?a=B-s:s!==null&&(a=r-s)}else n==="In Progress"&&s!==null&&(a=r-s);const g=t.timeSpentOnPhase?.[i]??0;let c=0;n==="Completed"?c=1:n==="In Progress"&&o&&(c=o.progress??0);const I=o?.stats??null;return{index:A,name:i,status:n,firstIteration:s,iterations:a,progress:c,timeSpent:g,stats:I&&Object.keys(I).length>0?I:null,solverInstance:o??null}},iVt=({status:t})=>{const A={"Not Started":"text-blue-600","In Progress":"text-yellow-600",Completed:"text-green-600",Failed:"text-red-600"};return W.jsx("span",{className:`font-medium ${A[t]}`,children:t})},nVt=({progress:t})=>{if(t===0)return null;const A=Math.round(t*100);return W.jsxs("div",{className:"flex items-center gap-2",children:[W.jsx("div",{className:"w-20 h-2 bg-gray-200 rounded overflow-hidden",children:W.jsx("div",{className:"h-full bg-blue-500 transition-all duration-200",style:{width:`${A}%`}})}),W.jsxs("span",{className:"text-xs text-gray-500",children:[A,"%"]})]})},oVt=t=>Object.entries(t).map(([A,e])=>`${A}: ${e}`).join(", "),sVt=({stats:t})=>{if(!t||Object.keys(t).length===0)return W.jsx("span",{children:"-"});const A=Object.entries(t),e=oVt(t);return W.jsxs("details",{className:"cursor-pointer",children:[W.jsx("summary",{className:"whitespace-nowrap overflow-hidden text-ellipsis max-w-[200px]",children:e}),W.jsx("div",{className:"mt-1 text-xs",children:A.map(([i,n])=>W.jsxs("div",{children:[i,": ",String(n)]},i))})]})},PfA=t=>{if(t===null||typeof t!="object")return t;if(Array.isArray(t))return t.map(PfA);const A={};for(const[e,i]of Object.entries(t))e.startsWith("_")||(A[e]=PfA(i));return A},rVt=(t,A)=>{try{if(typeof t.getConstructorParams!="function"){alert(`getConstructorParams() is not implemented for ${A}`);return}const e=PfA(t.getConstructorParams()),i=new Blob([JSON.stringify(e,null,2)],{type:"application/json"}),n=URL.createObjectURL(i),o=document.createElement("a");o.href=n,o.download=`${A}_input.json`,o.click(),URL.revokeObjectURL(n)}catch(e){alert(`Error downloading input for ${A}: ${e instanceof Error?e.message:String(e)}`)}},aVt=({solver:t,onStepUntilPhase:A,onDownloadInput:e})=>{const i=t.pipelineDef.map((r,a)=>tVt(t,a)),n=r=>{A?.(r)},o=r=>{r.solverInstance&&(e?e(r.solverInstance,r.name):rVt(r.solverInstance,r.name))},s=r=>`${(r/1e3).toFixed(2)}s`;return W.jsxs("div",{className:"border-t border-gray-200",children:[W.jsx("div",{className:"px-4 py-2 bg-gray-50 border-b border-gray-200",children:W.jsx("h3",{className:"text-sm font-semibold text-gray-700",children:"Pipeline Steps"})}),W.jsx("div",{className:"overflow-x-auto",children:W.jsxs("table",{className:"w-full text-sm",children:[W.jsx("thead",{children:W.jsxs("tr",{className:"bg-gray-50 border-b border-gray-200",children:[W.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Step"}),W.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Status"}),W.jsxs("th",{className:"px-4 py-2 text-center font-semibold text-gray-700",children:["i",W.jsx("sub",{children:"0"})]}),W.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Iterations"}),W.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Progress"}),W.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Time"}),W.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Stats"}),W.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Input"})]})}),W.jsx("tbody",{children:i.map(r=>W.jsxs("tr",{className:`border-b border-gray-100 ${r.status==="In Progress"?"bg-yellow-50":""}`,children:[W.jsx("td",{className:"px-4 py-2",children:W.jsxs("div",{className:"flex items-center gap-2",children:[W.jsx("span",{className:"text-gray-400 w-6",children:String(r.index+1).padStart(2,"0")}),W.jsx("button",{onClick:()=>n(r.name),disabled:r.status==="Completed"||t.solved||t.failed,className:"text-blue-500 hover:text-blue-700 disabled:text-gray-300 disabled:cursor-not-allowed",title:`Step until ${r.name} completes`,children:W.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:W.jsx("path",{fillRule:"evenodd",d:"M4.5 5.653c0-1.426 1.529-2.33 2.779-1.643l11.54 6.348c1.295.712 1.295 2.573 0 3.285L7.28 19.991c-1.25.687-2.779-.217-2.779-1.643V5.653z",clipRule:"evenodd"})})}),W.jsx("span",{className:"font-medium text-gray-900",children:r.name})]})}),W.jsx("td",{className:"px-4 py-2",children:W.jsx(iVt,{status:r.status})}),W.jsx("td",{className:"px-4 py-2 text-center text-gray-600",children:r.firstIteration!==null?r.firstIteration:""}),W.jsx("td",{className:"px-4 py-2 text-gray-600",children:r.iterations}),W.jsx("td",{className:"px-4 py-2",children:W.jsx(nVt,{progress:r.progress})}),W.jsx("td",{className:"px-4 py-2 text-gray-600",children:s(r.timeSpent)}),W.jsx("td",{className:"px-4 py-2 text-gray-500",children:W.jsx(sVt,{stats:r.stats})}),W.jsx("td",{className:"px-4 py-2",children:r.solverInstance?W.jsxs("button",{onClick:()=>o(r),className:"flex items-center gap-1 text-blue-500 hover:text-blue-700",title:`Download input for ${r.name}`,children:[W.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:W.jsx("path",{fillRule:"evenodd",d:"M12 2.25a.75.75 0 01.75.75v11.69l3.22-3.22a.75.75 0 111.06 1.06l-4.5 4.5a.75.75 0 01-1.06 0l-4.5-4.5a.75.75 0 111.06-1.06l3.22 3.22V3a.75.75 0 01.75-.75zm-9 13.5a.75.75 0 01.75.75v2.25a1.5 1.5 0 001.5 1.5h13.5a1.5 1.5 0 001.5-1.5V16.5a.75.75 0 011.5 0v2.25a3 3 0 01-3 3H5.25a3 3 0 01-3-3V16.5a.75.75 0 01.75-.75z",clipRule:"evenodd"})}),W.jsx("span",{children:"Input"})]}):null})]},r.name))})]})})]})},gVt=class extends yn.Component{constructor(t){super(t),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(t){console.error("InteractiveGraphics render error:",t)}render(){return this.state.hasError?this.props.fallback:this.props.children}};function cVt({graphics:t}){const A=t.points??[],e=t.lines??[],i=t.rects??[],n=t.circles??[],o=t.texts??[];let s=Number.POSITIVE_INFINITY,r=Number.POSITIVE_INFINITY,a=Number.NEGATIVE_INFINITY,g=Number.NEGATIVE_INFINITY;const c=(h,E)=>{typeof h=="number"&&(h<s&&(s=h),h>a&&(a=h)),typeof E=="number"&&(E<r&&(r=E),E>g&&(g=E))};for(const h of A)c(h.x,h.y);for(const h of e){const E=h.points??[];for(const u of E)c(u.x,u.y)}for(const h of i){const E=h.x??0,u=h.y??0,d=h.width??0,f=h.height??0;c(E,u),c(E+d,u+f)}for(const h of n){const E=h.x??0,u=h.y??0,d=h.radius??1;c(E-d,u-d),c(E+d,u+d)}for(const h of o)c(h.x,h.y);(!isFinite(s)||!isFinite(r)||!isFinite(a)||!isFinite(g))&&(s=-20,r=-20,a=20,g=20);const I=10,l=s-I,B=r-I,C=Math.max(1,a-s+2*I),Q=Math.max(1,g-r+2*I);return W.jsxs("svg",{className:"w-full h-[400px] bg-white",viewBox:`${l} ${B} ${C} ${Q}`,role:"img","aria-label":"Graphics fallback",children:[i.map((h,E)=>W.jsx("rect",{x:h.x??0,y:h.y??0,width:h.width??0,height:h.height??0,fill:"none",stroke:h.strokeColor??"black",strokeWidth:h.strokeWidth??1},`rect-${E}`)),e.map((h,E)=>W.jsx("polyline",{fill:"none",stroke:h.strokeColor??"black",strokeWidth:h.strokeWidth??1,points:(h.points??[]).map(u=>`${u.x??0},${u.y??0}`).join(" ")},`line-${E}`)),n.map((h,E)=>W.jsx("circle",{cx:h.x??0,cy:h.y??0,r:h.radius??1.5,fill:h.fillColor??"none",stroke:h.strokeColor??"black",strokeWidth:h.strokeWidth??1},`circle-${E}`)),A.map((h,E)=>W.jsx("circle",{cx:h.x??0,cy:h.y??0,r:h.radius??1.5,fill:h.color??"black"},`point-${E}`)),o.map((h,E)=>W.jsx("text",{x:h.x??0,y:h.y??0,fontSize:h.fontSize??10,fill:h.color??"black",children:h.text??""},`text-${E}`))]})}var IVt=({solver:t,animationSpeed:A=25,onSolverStarted:e,onSolverCompleted:i})=>{const[n,o]=V.useReducer(c=>c+1,0),s=V.useMemo(()=>{try{return t.visualize()||{points:[],lines:[],rects:[],circles:[]}}catch(c){return console.error("Visualization error:",c),{points:[],lines:[],rects:[],circles:[]}}},[t,n]),r=V.useMemo(()=>(s.rects?.length||0)===0&&(s.lines?.length||0)===0&&(s.points?.length||0)===0&&(s.circles?.length||0)===0,[s]);V.useEffect(()=>{if(!(typeof document>"u")&&!document.querySelector('script[src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4"]')){const c=document.createElement("script");c.src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4",document.head.appendChild(c)}},[]);const a=t.pipelineDef!==void 0,g=c=>{const I=t;if(!t.solved&&!t.failed){for(;!t.solved&&!t.failed&&I.currentPipelineStepIndex<=I.pipelineDef.findIndex(l=>l.solverName===c);)t.step();o()}};return W.jsxs("div",{children:[W.jsx(AVt,{solver:t,triggerRender:o,animationSpeed:A,onSolverStarted:e,onSolverCompleted:i}),r?W.jsx("div",{className:"p-4 text-gray-500",children:"No Graphics Yet"}):W.jsx(gVt,{fallback:W.jsx(cVt,{graphics:s}),children:W.jsx(z9t,{graphics:s})}),a&&W.jsx(aVt,{solver:t,onStepUntilPhase:g})]})};const lVt=()=>{V.useEffect(()=>{const t="tailwind-cdn-script";if(document.getElementById(t)||window.tailwind)return;const A=document.createElement("div");A.className="hidden",document.body.appendChild(A);const e=window.getComputedStyle(A).display==="none";if(document.body.removeChild(A),e)return;const i=document.createElement("script");i.id=t,i.src="https://cdn.tailwindcss.com",document.head.appendChild(i)},[])},BVt=t=>t.toLowerCase().includes("pack")?NNt:t.toLowerCase().includes("rout")?YNt:pNt,CVt=({solverEvents:t=[]})=>{const[A,e]=V.useState(null);lVt();const i=V.useMemo(()=>{const r=new Map;for(const a of t){const g=`${a.componentName}-${a.solverName}`;r.set(g,a)}return r},[t]),n=V.useMemo(()=>Array.from(i.keys()),[i]),o=A?i.get(A):null,s=V.useMemo(()=>{if(!o)return{instance:null,error:null,classFound:!1};const r=znA[o.solverName];if(!r)return{instance:null,error:`Solver class "${o.solverName}" not found in SOLVERS registry. Available: ${Object.keys(znA).join(", ")}`,classFound:!1};try{const a=o.solverParams,g=a?.input!==void 0?a.input:a;return{instance:new r(g),error:null,classFound:!0}}catch(a){const g=a instanceof Error?a.message:String(a);return console.error("Failed to reconstruct solver:",a),{instance:null,error:`Failed to instantiate solver: ${g}`,classFound:!0}}},[o]);return t.length===0?W.jsx("div",{className:"rf-p-4",children:W.jsx("div",{className:"rf-bg-gray-50 rf-rounded-md rf-border rf-border-gray-200",children:W.jsxs("div",{className:"rf-p-4",children:[W.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800 rf-mb-3",children:"No Solvers Detected"}),W.jsx("p",{className:"rf-text-sm rf-text-gray-600",children:"Solvers will appear here when the circuit runs. Solvers are used for tasks like component packing and autorouting."})]})})}):W.jsxs("div",{className:"rf-flex rf-h-full rf-overflow-hidden",children:[W.jsxs("div",{className:"rf-w-64 rf-border-r rf-border-gray-200 rf-overflow-y-auto rf-flex-shrink-0",children:[W.jsxs("div",{className:"rf-text-xs rf-font-semibold rf-text-gray-500 rf-px-3 rf-py-2 rf-bg-gray-50 rf-border-b rf-border-gray-200",children:[n.length," ",n.length===1?"Solver":"Solvers"]}),n.map(r=>{const a=i.get(r),g=A===r;return W.jsx("div",{className:`rf-px-3 rf-py-2 rf-cursor-pointer rf-border-b rf-border-gray-100 ${g?"rf-bg-blue-50 rf-border-l-2 rf-border-l-blue-500":"hover:rf-bg-gray-50"}`,onClick:()=>e(r),children:(()=>{const c=BVt(a.solverName);return W.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2",children:[W.jsx(c,{className:"rf-w-4 rf-h-4 rf-text-blue-500 rf-flex-shrink-0"}),W.jsxs("div",{className:"rf-flex-1 rf-min-w-0",children:[W.jsx("div",{className:"rf-text-sm rf-font-medium rf-text-gray-800 rf-truncate",children:a.componentName}),W.jsx("div",{className:"rf-text-xs rf-text-gray-500 rf-truncate",children:a.solverName})]})]})})()},r)})]}),W.jsx("div",{className:"rf-flex-1 rf-overflow-hidden",children:o?s.instance?W.jsx(rm,{fallback:W.jsx("div",{className:"rf-p-4",children:W.jsxs("div",{className:"rf-bg-red-50 rf-rounded-md rf-border rf-border-red-200 rf-p-4",children:[W.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-red-800 rf-mb-2",children:"Error Loading Solver Debugger"}),W.jsxs("p",{className:"rf-text-sm rf-text-red-600",children:["Failed to render the solver debugger for"," ",o.solverName]})]})}),children:W.jsx(IVt,{solver:s.instance})}):W.jsxs("div",{className:"rf-p-4",children:[W.jsxs("div",{className:"rf-mb-4",children:[W.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800",children:o.solverName}),W.jsxs("p",{className:"rf-text-sm rf-text-gray-500",children:["Component: ",o.componentName]})]}),s.error&&W.jsx("div",{className:`rf-rounded-md rf-border rf-p-4 rf-mb-4 ${s.classFound?"rf-bg-red-50 rf-border-red-200":"rf-bg-yellow-50 rf-border-yellow-200"}`,children:W.jsx("p",{className:`rf-text-sm ${s.classFound?"rf-text-red-700":"rf-text-yellow-700"}`,children:s.error})}),W.jsxs("div",{className:"rf-border rf-border-gray-200 rf-rounded-md rf-overflow-hidden",children:[W.jsx("div",{className:"rf-px-3 rf-py-2 rf-bg-gray-50",children:W.jsx("span",{className:"rf-text-sm rf-font-medium rf-text-gray-700",children:"Solver Parameters"})}),W.jsx("div",{className:"rf-p-3 rf-bg-white rf-border-t rf-border-gray-200",children:W.jsx("pre",{className:"rf-text-xs rf-font-mono rf-text-gray-600 rf-whitespace-pre-wrap rf-overflow-x-auto",children:JSON.stringify(o.solverParams,null,2)})})]})]}):W.jsx("div",{className:"rf-flex rf-items-center rf-justify-center rf-h-full",children:W.jsx("p",{className:"rf-text-sm rf-text-gray-500",children:"Select a solver from the list to view details"})})})]})},DIe=({errorMessage:t,errorStack:A,circuitJsonErrors:e})=>{V.useEffect(()=>{if(t){const i=new Error(t);A&&(i.stack=A);try{J5.captureException(i)}catch{}}},[t,A]),V.useEffect(()=>{if(e&&e.length>0)for(const i of e){const n=new Error(i.message||"Circuit JSON Error");i.stack&&(n.stack=i.stack);try{J5.captureException(n,{error_type:i.type})}catch{}}},[e])},SIe="0.0.1688",QVt={version:SIe},WV=FYA()(vYA(t=>({lastRunEvalVersion:void 0,setLastRunEvalVersion:A=>{t({lastRunEvalVersion:A})}}),{name:"runframe-runner-store"})),hVt=t=>{const[A,e]=V.useState([]),[i,n]=V.useState(null),[o,s]=V.useState(""),[r,a]=jR("eval-version-selection",null),g=WV(B=>B.setLastRunEvalVersion),c=WV(B=>B.lastRunEvalVersion);return V.useEffect(()=>{t&&fetch("https://data.jsdelivr.com/v1/package/npm/@tscircuit/eval").then(B=>B.json()).then(B=>{if(Array.isArray(B?.versions)){let C=[...B.versions];B.tags?.latest&&(n(B.tags.latest),C=C.filter(Q=>Q!==B.tags.latest)),e(C)}}).catch(()=>{})},[t]),V.useEffect(()=>{t&&(r?(window.TSCIRCUIT_LATEST_EVAL_VERSION=r,g(r)):i&&(window.TSCIRCUIT_LATEST_EVAL_VERSION=i,g(i)))},[t,r,i]),{versions:V.useMemo(()=>A.filter(B=>B.includes(o)).slice(0,50),[A,o]),latestVersion:i,lastRunEvalVersion:c,search:o,setSearch:s,selectVersion:B=>{a(B),s("")}}},EVt=({snippetNames:t,onSelect:A,onCancel:e,isOpen:i})=>{const[n,o]=V.useState(""),[s,r]=V.useState("");if(!i)return null;const a=t.filter(I=>I.toLowerCase().includes(s.toLowerCase())),g=s&&!t.includes(s),c=I=>{I.key==="Enter"&&(a.length===1?o(a[0]):g&&o(s))};return W.jsx("div",{className:"rf-fixed rf-inset-0 rf-bg-black rf-bg-opacity-50 rf-flex rf-items-center rf-justify-center rf-z-[100]",children:W.jsxs("div",{className:"rf-bg-white rf-rounded-lg rf-p-6 rf-w-96",children:[W.jsx("h2",{className:"rf-text-lg rf-font-semibold rf-mb-4",children:"Select Snippet"}),W.jsx("input",{type:"text",className:"rf-w-full rf-px-4 rf-py-2 rf-border rf-rounded rf-mb-4",placeholder:"Search snippets or new snippet name...",value:s,onChange:I=>r(I.target.value),onKeyDown:c}),W.jsxs("div",{className:"rf-h-60 rf-overflow-y-auto",children:[a.map(I=>W.jsx("button",{type:"button",className:`w-full text-left px-4 py-2 rounded hover:bg-gray-100 ${n===I?"bg-blue-50":""}`,onClick:()=>o(I),children:I},I)),g&&W.jsxs("button",{type:"button",className:`w-full text-left px-4 py-2 rounded hover:bg-gray-100 text-blue-500 ${n===s?"bg-blue-50":""}`,onClick:()=>o(s),children:['Create new "',s,'"']})]}),W.jsxs("div",{className:"rf-mt-4 rf-flex rf-justify-end rf-gap-2",children:[W.jsx("button",{type:"button",className:"rf-px-4 rf-py-2 rf-text-gray-600 rf-hover:text-gray-800",onClick:e,children:"Cancel"}),W.jsx("button",{type:"button",className:"rf-px-4 rf-py-2 rf-bg-blue-500 rf-text-white rf-rounded rf-hover:bg-blue-600 rf-disabled:opacity-50",onClick:()=>n&&A(n),disabled:!n,children:n===s?`Create "${n}"`:`Save to ${n}`})]})]})})},uVt=t=>{const A=V.useRef(null),e=Yl(i=>i.recentEvents);V.useEffect(()=>{if(e.length===0)return;const i=e[0];i.event_id!==A.current&&(t(i),A.current=i.event_id)},[e,t])};function dVt(t){const A=pVt(t),e=V.forwardRef((i,n)=>{const{children:o,...s}=i,r=V.Children.toArray(o),a=r.find(yVt);if(a){const g=a.props.children,c=r.map(I=>I===a?V.Children.count(g)>1?V.Children.only(null):V.isValidElement(g)?g.props.children:null:I);return W.jsx(A,{...s,ref:n,children:V.isValidElement(g)?V.cloneElement(g,void 0,c):null})}return W.jsx(A,{...s,ref:n,children:o})});return e.displayName=`${t}.Slot`,e}function pVt(t){const A=V.forwardRef((e,i)=>{const{children:n,...o}=e;if(V.isValidElement(n)){const s=wVt(n),r=mVt(o,n.props);return n.type!==V.Fragment&&(r.ref=i?xf(i,s):s),V.cloneElement(n,r)}return V.Children.count(n)>1?V.Children.only(null):null});return A.displayName=`${t}.SlotClone`,A}var fVt=Symbol("radix.slottable");function yVt(t){return V.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===fVt}function mVt(t,A){const e={...A};for(const i in A){const n=t[i],o=A[i];/^on[A-Z]/.test(i)?n&&o?e[i]=(...r)=>{const a=o(...r);return n(...r),a}:n&&(e[i]=n):i==="style"?e[i]={...n,...o}:i==="className"&&(e[i]=[n,o].filter(Boolean).join(" "))}return{...t,...e}}function wVt(t){let A=Object.getOwnPropertyDescriptor(t.props,"ref")?.get,e=A&&"isReactWarning"in A&&A.isReactWarning;return e?t.ref:(A=Object.getOwnPropertyDescriptor(t,"ref")?.get,e=A&&"isReactWarning"in A&&A.isReactWarning,e?t.props.ref:t.props.ref||t.ref)}var ZV="Dialog",[bIe,xIe]=ew(ZV),[DVt,Dw]=bIe(ZV),_Ie=t=>{const{__scopeDialog:A,children:e,open:i,defaultOpen:n,onOpenChange:o,modal:s=!0}=t,r=V.useRef(null),a=V.useRef(null),[g,c]=jx({prop:i,defaultProp:n??!1,onChange:o,caller:ZV});return W.jsx(DVt,{scope:A,triggerRef:r,contentRef:a,contentId:ou(),titleId:ou(),descriptionId:ou(),open:g,onOpenChange:c,onOpenToggle:V.useCallback(()=>c(I=>!I),[c]),modal:s,children:e})};_Ie.displayName=ZV;var kIe="DialogTrigger",FIe=V.forwardRef((t,A)=>{const{__scopeDialog:e,...i}=t,n=Dw(kIe,e),o=ol(A,n.triggerRef);return W.jsx(yg.button,{type:"button","aria-haspopup":"dialog","aria-expanded":n.open,"aria-controls":n.contentId,"data-state":WfA(n.open),...i,ref:o,onClick:co(t.onClick,n.onOpenToggle)})});FIe.displayName=kIe;var qfA="DialogPortal",[SVt,vIe]=bIe(qfA,{forceMount:void 0}),GIe=t=>{const{__scopeDialog:A,forceMount:e,children:i,container:n}=t,o=Dw(qfA,A);return W.jsx(SVt,{scope:A,forceMount:e,children:V.Children.map(i,s=>W.jsx(H0,{present:e||o.open,children:W.jsx(VZ,{asChild:!0,container:n,children:s})}))})};GIe.displayName=qfA;var VV="DialogOverlay",RIe=V.forwardRef((t,A)=>{const e=vIe(VV,t.__scopeDialog),{forceMount:i=e.forceMount,...n}=t,o=Dw(VV,t.__scopeDialog);return o.modal?W.jsx(H0,{present:i||o.open,children:W.jsx(xVt,{...n,ref:A})}):null});RIe.displayName=VV;var bVt=dVt("DialogOverlay.RemoveScroll"),xVt=V.forwardRef((t,A)=>{const{__scopeDialog:e,...i}=t,n=Dw(VV,e);return W.jsx(i9,{as:bVt,allowPinchZoom:!0,shards:[n.contentRef],children:W.jsx(yg.div,{"data-state":WfA(n.open),...i,ref:A,style:{pointerEvents:"auto",...i.style}})})}),Ov="DialogContent",NIe=V.forwardRef((t,A)=>{const e=vIe(Ov,t.__scopeDialog),{forceMount:i=e.forceMount,...n}=t,o=Dw(Ov,t.__scopeDialog);return W.jsx(H0,{present:i||o.open,children:o.modal?W.jsx(_Vt,{...n,ref:A}):W.jsx(kVt,{...n,ref:A})})});NIe.displayName=Ov;var _Vt=V.forwardRef((t,A)=>{const e=Dw(Ov,t.__scopeDialog),i=V.useRef(null),n=ol(A,e.contentRef,i);return V.useEffect(()=>{const o=i.current;if(o)return juA(o)},[]),W.jsx(MIe,{...t,ref:n,trapFocus:e.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:co(t.onCloseAutoFocus,o=>{o.preventDefault(),e.triggerRef.current?.focus()}),onPointerDownOutside:co(t.onPointerDownOutside,o=>{const s=o.detail.originalEvent,r=s.button===0&&s.ctrlKey===!0;(s.button===2||r)&&o.preventDefault()}),onFocusOutside:co(t.onFocusOutside,o=>o.preventDefault())})}),kVt=V.forwardRef((t,A)=>{const e=Dw(Ov,t.__scopeDialog),i=V.useRef(!1),n=V.useRef(!1);return W.jsx(MIe,{...t,ref:A,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:o=>{t.onCloseAutoFocus?.(o),o.defaultPrevented||(i.current||e.triggerRef.current?.focus(),o.preventDefault()),i.current=!1,n.current=!1},onInteractOutside:o=>{t.onInteractOutside?.(o),o.defaultPrevented||(i.current=!0,o.detail.originalEvent.type==="pointerdown"&&(n.current=!0));const s=o.target;e.triggerRef.current?.contains(s)&&o.preventDefault(),o.detail.originalEvent.type==="focusin"&&n.current&&o.preventDefault()}})}),MIe=V.forwardRef((t,A)=>{const{__scopeDialog:e,trapFocus:i,onOpenAutoFocus:n,onCloseAutoFocus:o,...s}=t,r=Dw(Ov,e),a=V.useRef(null),g=ol(A,a);return FuA(),W.jsxs(W.Fragment,{children:[W.jsx(MZ,{asChild:!0,loop:!0,trapped:i,onMountAutoFocus:n,onUnmountAutoFocus:o,children:W.jsx(aY,{role:"dialog",id:r.contentId,"aria-describedby":r.descriptionId,"aria-labelledby":r.titleId,"data-state":WfA(r.open),...s,ref:g,onDismiss:()=>r.onOpenChange(!1)})}),W.jsxs(W.Fragment,{children:[W.jsx(vVt,{titleId:r.titleId}),W.jsx(RVt,{contentRef:a,descriptionId:r.descriptionId})]})]})}),OfA="DialogTitle",LIe=V.forwardRef((t,A)=>{const{__scopeDialog:e,...i}=t,n=Dw(OfA,e);return W.jsx(yg.h2,{id:n.titleId,...i,ref:A})});LIe.displayName=OfA;var UIe="DialogDescription",HIe=V.forwardRef((t,A)=>{const{__scopeDialog:e,...i}=t,n=Dw(UIe,e);return W.jsx(yg.p,{id:n.descriptionId,...i,ref:A})});HIe.displayName=UIe;var YIe="DialogClose",JIe=V.forwardRef((t,A)=>{const{__scopeDialog:e,...i}=t,n=Dw(YIe,e);return W.jsx(yg.button,{type:"button",...i,ref:A,onClick:co(t.onClick,()=>n.onOpenChange(!1))})});JIe.displayName=YIe;function WfA(t){return t?"open":"closed"}var TIe="DialogTitleWarning",[FVt,KIe]=w6e(TIe,{contentName:Ov,titleName:OfA,docsSlug:"dialog"}),vVt=({titleId:t})=>{const A=KIe(TIe),e=`\`${A.contentName}\` requires a \`${A.titleName}\` for the component to be accessible for screen reader users.
5685
5685
 
5686
5686
  If you want to hide the \`${A.titleName}\`, you can wrap it with our VisuallyHidden component.
5687
5687
 
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@tscircuit/runframe",
3
3
  "main": "dist/preview.js",
4
4
  "type": "module",
5
- "version": "0.0.1688",
5
+ "version": "0.0.1689",
6
6
  "exports": {
7
7
  ".": "./dist/preview.js",
8
8
  "./preview": "./dist/preview.js",
@@ -57,7 +57,7 @@
57
57
  "@tscircuit/pcb-viewer": "1.11.346",
58
58
  "@tscircuit/props": "^0.0.455",
59
59
  "@tscircuit/schematic-trace-solver": "^0.0.40",
60
- "@tscircuit/schematic-viewer": "^2.0.57",
60
+ "@tscircuit/schematic-viewer": "^2.0.58",
61
61
  "@types/bun": "latest",
62
62
  "@types/debug": "^4.1.12",
63
63
  "@types/react": "^19.1.10",