@tscircuit/runframe 0.0.1602 → 0.0.1604

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.1601";
1733
+ var version = "0.0.1603";
1734
1734
  var package_default = {
1735
1735
  name: "@tscircuit/runframe",
1736
1736
  main: "dist/preview.js",
@@ -1782,12 +1782,12 @@ var package_default = {
1782
1782
  "@tscircuit/3d-viewer": "^0.0.512",
1783
1783
  "@tscircuit/assembly-viewer": "^0.0.5",
1784
1784
  "@tscircuit/create-snippet-url": "^0.0.9",
1785
- "@tscircuit/eval": "^0.0.636",
1785
+ "@tscircuit/eval": "^0.0.637",
1786
1786
  "@tscircuit/circuit-json-util": "^0.0.75",
1787
1787
  "@tscircuit/fake-snippets": "^0.0.163",
1788
1788
  "@tscircuit/file-server": "^0.0.32",
1789
1789
  "@tscircuit/footprinter": "^0.0.236",
1790
- "@tscircuit/pcb-viewer": "1.11.335",
1790
+ "@tscircuit/pcb-viewer": "1.11.336",
1791
1791
  "@tscircuit/props": "^0.0.455",
1792
1792
  "@tscircuit/schematic-trace-solver": "^0.0.40",
1793
1793
  "@tscircuit/schematic-viewer": "^2.0.56",
package/dist/preview.js CHANGED
@@ -8,7 +8,7 @@ import {
8
8
  linkify,
9
9
  useOrderDialog,
10
10
  useOrderDialogCli
11
- } from "./chunk-DCK7KR2L.js";
11
+ } from "./chunk-CPR6XC5L.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-DCK7KR2L.js";
37
+ } from "./chunk-CPR6XC5L.js";
38
38
 
39
39
  // lib/components/RunFrame/RunFrame.tsx
40
40
  import { createCircuitWebWorker } from "@tscircuit/eval/worker";
@@ -5465,7 +5465,7 @@ $1`).replace(/>(\s*)(?=<!--\s*\/)/g,"> ")}}});function ogt(e,A,t){if(!A||!t)retu
5465
5465
  transition: opacity 0.2s;
5466
5466
  margin-bottom: 10px;
5467
5467
  color: red;
5468
- `,p5e=({children:e,transform:A=pb(),elements:t})=>{const i=AA.useRef(null),{isShowingDRCErrors:n,hoveredErrorId:o}=tC(g=>({isShowingDRCErrors:g.is_showing_drc_errors,hoveredErrorId:g.hovered_error_id}));if(!t)return Z.jsx("div",{style:{position:"relative"},ref:i,children:e});const s=t.filter(g=>g.type==="pcb_trace_error"),r=t.filter(g=>g.type==="pcb_trace_error"&&g.message?.includes("Multiple components found with name")),a=new Map;return t.forEach(g=>{g.type==="pcb_port"&&a.set(g.pcb_port_id,g)}),Z.jsxs("div",{style:{position:"relative"},ref:i,children:[e,s.map((g,I)=>{const{pcb_port_ids:c,pcb_trace_id:l}=g,B=c?.[0]?a.get(c[0]):void 0,C=c?.[1]?a.get(c[1]):void 0,E=t?mb(t).pcb_trace.get(l):void 0,Q=g.pcb_trace_error_id||`error_${I}_${g.error_type}_${g.message?.slice(0,20)}`,h=o===Q;if(B&&C){const u=qi(A,{x:B.x,y:B.y}),d=qi(A,{x:C.x,y:C.y}),f=!(isNaN(u.x)||isNaN(u.y)||isNaN(d.x)||isNaN(d.y)),m={x:(u.x+d.x)/2,y:(u.y+d.y)/2};if(isNaN(m.x)||isNaN(m.y))return null;const w=RpA(m,i);return Z.jsxs(AA.Fragment,{children:[Z.jsx(u5e,{screenPort1:u,screenPort2:d,errorCenter:m,canLineBeDrawn:f,isHighlighted:h}),Z.jsx("div",{style:{position:"absolute",left:m.x-15,top:m.y-15,width:30,height:30,zIndex:dI.errorOverlay+5,cursor:"pointer",borderRadius:"50%"},onMouseEnter:D=>{const b=D.currentTarget.nextElementSibling;if(b){const k=b.querySelector(".error-message");k&&(k.style.opacity="1")}},onMouseLeave:D=>{if(!h){const b=D.currentTarget.nextElementSibling;if(b){const k=b.querySelector(".error-message");k&&(k.style.opacity="0")}}}}),Z.jsx("div",{style:{position:"absolute",zIndex:h?200:100,left:w.left,top:w.top,color:h?"#ff4444":"red",textAlign:"center",fontFamily:"sans-serif",fontSize:12,display:n||h?"flex":"none",flexDirection:"column",alignItems:"center",pointerEvents:"none",transform:w.transform},children:Z.jsx("div",{className:`error-message ${NpA}`,style:{opacity:h?1:0,border:`1px solid ${h?"#ff4444":"red"}`},children:g.message})})]},Q)}if(E?.route&&(n||h)){const u=E.route.map(w=>qi(A,{x:w.x,y:w.y}));if(u.some(w=>isNaN(w.x)||isNaN(w.y)))return null;const d=Math.floor(u.length/2),f=u[d],m=RpA(f,i);return Z.jsxs(AA.Fragment,{children:[Z.jsx(d5e,{points:u,errorCenter:f,isHighlighted:h}),Z.jsx("div",{style:{position:"absolute",left:f.x-15,top:f.y-15,width:30,height:30,zIndex:dI.errorOverlay+5,cursor:"pointer",borderRadius:"50%"},onMouseEnter:w=>{const D=w.currentTarget.nextElementSibling;if(D){const b=D.querySelector(".error-message");b&&(b.style.opacity="1")}},onMouseLeave:w=>{if(!h){const D=w.currentTarget.nextElementSibling;if(D){const b=D.querySelector(".error-message");b&&(b.style.opacity="0")}}}}),Z.jsx("div",{style:{position:"absolute",zIndex:h?dI.errorOverlay+10:dI.errorOverlay+1,left:m.left,top:m.top,color:h?"#ff4444":"red",textAlign:"center",fontFamily:"sans-serif",fontSize:12,display:"flex",flexDirection:"column",alignItems:"center",pointerEvents:"none",transform:m.transform},children:Z.jsx("div",{className:`error-message ${NpA}`,style:{opacity:h?1:0,border:`1px solid ${h?"#ff4444":"red"}`},children:g.message})})]},Q)}return null}),r.map((g,I)=>{const c=g.component_name||g.message?.match(/name "([^"]+)"/)?.[1];if(!c)return null;const l=t?.filter(E=>E.type==="source_component"&&E.name===c||E.type==="pcb_component"&&t?.find(Q=>Q.type==="source_component"&&Q.source_component_id===E.source_component_id&&Q.name===c))||[],B=g.pcb_trace_error_id||`error_${I}_${g.error_type}_${g.message?.slice(0,20)}`,C=o===B;return!C&&!n?null:l.map((E,Q)=>{let h={x:0,y:0};if(E.type==="pcb_component")h=E.center||{x:0,y:0};else if(E.type==="source_component"){const k=t?.find(x=>x.type==="pcb_component"&&x.source_component_id===E.source_component_id);k&&k.type==="pcb_component"&&(h=k.center||{x:0,y:0})}const u=qi(A,h);if(isNaN(u.x)||isNaN(u.y))return null;const d=Math.abs(A.a),D=Math.max(8,Math.min(30,.5*d)),b=RpA(u,i);return Z.jsxs(AA.Fragment,{children:[Z.jsx("svg",{style:{position:"absolute",left:0,top:0,pointerEvents:"none",mixBlendMode:"difference",zIndex:dI.errorOverlay},width:"100%",height:"100%",children:C?Z.jsx("polygon",{points:`${u.x},${u.y-D*1.25} ${u.x+D},${u.y} ${u.x},${u.y+D*1.25} ${u.x-D},${u.y}`,fill:"#ff4444"}):Z.jsx("circle",{cx:u.x,cy:u.y,r:D,fill:"none",stroke:C?"#ff4444":"red",strokeWidth:C?Math.max(2,D*.15):Math.max(1,D*.1),opacity:1})}),Z.jsx("div",{style:{position:"absolute",left:u.x-(D+10),top:u.y-(D+10),width:(D+10)*2,height:(D+10)*2,zIndex:dI.errorOverlay+5,cursor:"pointer",borderRadius:"50%"},onMouseEnter:k=>{const x=k.currentTarget.nextElementSibling;if(x){const N=x.querySelector(".error-message");N&&(N.style.opacity="1")}},onMouseLeave:k=>{if(!C){const x=k.currentTarget.nextElementSibling;if(x){const N=x.querySelector(".error-message");N&&(N.style.opacity="0")}}}}),Z.jsx("div",{style:{position:"absolute",zIndex:C?dI.errorOverlay+20:dI.errorOverlay+10,left:b.left,top:b.top,color:C?"#ff4444":"red",textAlign:"center",fontFamily:"sans-serif",fontSize:12,display:n||C?"flex":"none",flexDirection:"column",alignItems:"center",pointerEvents:"none",transform:b.transform},children:Z.jsx("div",{className:`error-message ${NpA}`,style:{opacity:C?1:0,border:`1px solid ${C?"#ff4444":"red"}`},children:g.message})})]},`${B}_${Q}`)})})]})};function f5e(e,A){return e.size!==A.size?!1:Array.from(e).every(t=>A.has(t))}function y5e({primitiveElement:e,elements:A}){let t=e.trace_length?`${e.trace_length.toFixed(3)}`:"";const i=mb(A).source_trace.get(e?.source_trace_id);if(i?.display_name&&(i?.max_length?t+=` / ${i.max_length}mm `:t+=" mm ",t+=`(${i.display_name})`),!t)return null;const n=e.trace_length&&i?.max_length&&e.trace_length>i.max_length;return{text:t,isOverLength:n}}function m5e(e){const{primitives:A,is_showing_multiple_traces_length:t,elements:i}=e,n=A.filter(a=>a._element.type==="pcb_trace"),o=i.filter(a=>a.type==="source_trace"),s=A.filter(a=>a._element.type!=="pcb_trace"),r=n.filter(a=>o.some(g=>a._element.type==="pcb_trace"&&a._element.source_trace_id===g.source_trace_id&&g.max_length!==void 0));if(!t)return[...s,...r];if(n.length>1){const a=n.reduce((g,I)=>{const c=g._element.trace_length;return I._element.trace_length<c?I:g},n[0]);return[...s,a]}return A}var w5e={position:"absolute",left:0,top:0,pointerEvents:"none",color:"red",fontFamily:"sans-serif",fontSize:12,textShadow:"0 0 2px black"},D5e=e=>{const{_element:A,_parent_pcb_component:t,_parent_source_component:i,_source_port:n}=e;switch(A.type){case"pcb_trace":return A.trace_length?`${A.trace_length.toFixed(3)}`:"";case"pcb_smtpad":case"pcb_plated_hole":{const o=[],s=Array.from(new Set((A.port_hints??[]).concat(n?.port_hints??[]))).filter(a=>!/^[0-9]+$/.test(a)).filter(a=>!a.includes("unnamed_")).sort((a,g)=>g.localeCompare(a)),r=i&&"name"in i&&i.name&&!i.name.includes("unnamed_")?i.name:null;return s.length>0?r?o.push(...s.map(a=>`${r}.${a}`)):o.push(...s):r&&o.push(r),o.join(", ")}default:return""}},S5e={top:"red",bottom:"aqua"},b5e=({primitive:e,mousePos:A,elements:t})=>{const[i,n]=AA.useState(!1),o=e._element;AA.useEffect(()=>{setTimeout(()=>{n(!0)},100)},[]);const[s,r,a,g]=[e.screen_x,e.screen_y,e.screen_w,e.screen_h],I=e.same_space_index??0,c=26,l=S5e[e?._element?.layer]??"red";let B=0;if(o.type==="pcb_smtpad"&&o?.shape==="rotated_rect"?B=o?.ccw_rotation??0:(o.type==="pcb_smtpad"&&(o?.shape==="pill"||o?.shape==="rotated_pill")&&"ccw_rotation"in e||o.type==="pcb_plated_hole"&&(o?.shape==="pill"||o?.shape==="oval")&&"ccw_rotation"in e)&&(B=o.ccw_rotation??0),o.type==="pcb_trace"){const Q=y5e({primitiveElement:o,elements:t});if(!Q)return null;const h=A.y-35;return Z.jsx("div",{style:{zIndex:dI.elementOverlay,position:"absolute",left:A.x,top:h,color:l,pointerEvents:"none",transform:"translateX(-50%)"},children:Z.jsx("div",{style:{backgroundColor:"#f2efcc",color:Q.isOverLength?"red":"black",textShadow:"none",WebkitFontSmoothing:"antialiased",MozOsxFontSmoothing:"grayscale",padding:"6px 6px",borderRadius:"6px",fontSize:"14px",minWidth:"45px",textAlign:"center",whiteSpace:"nowrap"},children:Q.text})})}const C=D5e(e);return C.trim().length===0?null:Z.jsx("div",{style:{zIndex:dI.elementOverlay,position:"absolute",left:s-a/2-8,top:r-g/2-8,width:a+16,height:g+16,color:l,transform:`rotate(${-B}deg)`,transformOrigin:"center center"},children:Z.jsx("div",{style:{width:i?`calc(100% + ${c*2*I}px)`:"100%",height:i?`calc(100% + ${c*2*I}px)`:"100%",marginLeft:i?`${-c*I}px`:0,marginTop:i?`${-c*I}px`:0,border:`1px solid ${l}`,opacity:i||I===0?1:0,transition:"width 0.2s, height 0.2s, margin-left 0.2s, margin-top 0.2s, opacity 0.2s"},children:Z.jsx("div",{style:{position:"absolute",bottom:g+20+c*I,marginRight:i?`${-c*I}px`:0,marginBottom:i?0:-c*I,transition:"margin-right 0.2s, margin-bottom 0.2s",backgroundColor:"#f2efcc",color:"black",textShadow:"none",WebkitFontSmoothing:"antialiased",MozOsxFontSmoothing:"grayscale",padding:"6px 6px",borderRadius:"6px",fontSize:"14px",transform:`rotate(${B}deg)`,minWidth:"45px",textAlign:"center"},children:C})})})},x5e=({highlightedPrimitives:e,mousePos:A,elements:t})=>{const[i,n]=tC(r=>[r.is_moving_component,r.is_showing_multiple_traces_length]),o=e.some(r=>r._element.type==="pcb_smtpad")&&e.some(r=>r._element.type==="pcb_trace");let s=e;return o&&(s=s.filter(r=>r._element.type==="pcb_smtpad")),s=m5e({primitives:s,is_showing_multiple_traces_length:n,elements:t}),Z.jsx("div",{style:w5e,children:!i&&s.map((r,a)=>Z.jsx(b5e,{primitive:r,mousePos:A,elements:t},a))})},V_=e=>e?.type==="pcb_component",Fgt=e=>e?.type==="pcb_group",_5e=e=>e?.type==="pcb_panel",vpA=e=>e?.type==="pcb_board",jI={MIN_LINE_LENGTH_FOR_LABEL:40,LABEL_OFFSET_ABOVE:2,LABEL_OFFSET_BELOW:-18,LABEL_OFFSET_RIGHT:8,LABEL_OFFSET_LEFT:-120,Y_LABEL_MIN_WIDTH:110,LINE_STROKE_WIDTH:1.5,LINE_DASH_PATTERN:"4,4",COMPONENT_MARKER_RADIUS:3,LABEL_FONT_SIZE:11,ANCHOR_MARKER_SIZE:6,ANCHOR_MARKER_STROKE_WIDTH:1.5},F0={OFFSET_LINE:"white",COMPONENT_MARKER_FILL:"#66ccff",COMPONENT_MARKER_STROKE:"white",LABEL_TEXT:"white"},LpA=({targets:e,transform:A,containerWidth:t,containerHeight:i})=>{if(e.length===0)return null;const n={color:F0.LABEL_TEXT,mixBlendMode:"difference",pointerEvents:"none",fontSize:jI.LABEL_FONT_SIZE,fontFamily:"monospace",fontWeight:"bold"},o=new Map;return e.forEach(s=>{if(!o.has(s.anchor_id)){const r=qi(A,s.anchor);o.set(s.anchor_id,r)}}),Z.jsx("div",{style:{position:"absolute",left:0,top:0,width:t,height:i,overflow:"hidden",pointerEvents:"none",zIndex:dI.dimensionOverlay},children:Z.jsxs("svg",{style:{position:"absolute",left:0,top:0,pointerEvents:"none"},width:t,height:i,children:[e.map(s=>{const r=s.anchor,a=s.anchor_id,g=s.target,I=o.get(a),c=qi(A,g),l=g.x-r.x,B=g.y-r.y,C=Math.abs(c.x-I.x),E=Math.abs(c.y-I.y),Q=c.y<I.y,h=c.x>I.x,u=Q?jI.LABEL_OFFSET_ABOVE:jI.LABEL_OFFSET_BELOW,d=h?jI.LABEL_OFFSET_RIGHT:jI.LABEL_OFFSET_LEFT,f=C>jI.MIN_LINE_LENGTH_FOR_LABEL,m=E>jI.MIN_LINE_LENGTH_FOR_LABEL,w=`${s.display_offset_x??l.toFixed(2)}mm`,D=`${s.display_offset_y??B.toFixed(2)}mm`;return Z.jsxs("g",{children:[Z.jsx("line",{x1:I.x,y1:I.y,x2:c.x,y2:I.y,stroke:F0.OFFSET_LINE,strokeWidth:jI.LINE_STROKE_WIDTH,strokeDasharray:jI.LINE_DASH_PATTERN}),Z.jsx("line",{x1:c.x,y1:I.y,x2:c.x,y2:c.y,stroke:F0.OFFSET_LINE,strokeWidth:jI.LINE_STROKE_WIDTH,strokeDasharray:jI.LINE_DASH_PATTERN}),s.type==="component"||s.type==="board"?Z.jsx("circle",{cx:c.x,cy:c.y,r:jI.COMPONENT_MARKER_RADIUS,fill:F0.COMPONENT_MARKER_FILL,stroke:F0.COMPONENT_MARKER_STROKE,strokeWidth:1}):Z.jsxs(Z.Fragment,{children:[Z.jsx("line",{x1:c.x-jI.ANCHOR_MARKER_SIZE,y1:c.y,x2:c.x+jI.ANCHOR_MARKER_SIZE,y2:c.y,stroke:F0.OFFSET_LINE,strokeWidth:jI.ANCHOR_MARKER_STROKE_WIDTH}),Z.jsx("line",{x1:c.x,y1:c.y-jI.ANCHOR_MARKER_SIZE,x2:c.x,y2:c.y+jI.ANCHOR_MARKER_SIZE,stroke:F0.OFFSET_LINE,strokeWidth:jI.ANCHOR_MARKER_STROKE_WIDTH})]}),f&&Z.jsx("foreignObject",{x:Math.min(I.x,c.x),y:I.y+u,width:Math.abs(c.x-I.x),height:20,style:{overflow:"visible"},children:Z.jsx("div",{style:{...n,textAlign:"center"},children:w})}),m&&Z.jsx("foreignObject",{x:c.x+d,y:Math.min(I.y,c.y),width:jI.Y_LABEL_MIN_WIDTH,height:Math.abs(c.y-I.y),style:{overflow:"visible"},children:Z.jsx("div",{style:{...n,display:"flex",alignItems:"center",justifyContent:h?"flex-start":"flex-end",whiteSpace:"nowrap",padding:"0 4px",height:"100%"},children:D})})]},s.id)}),Array.from(o.entries()).map(([s,r])=>Z.jsxs("g",{children:[Z.jsx("line",{x1:r.x-jI.ANCHOR_MARKER_SIZE,y1:r.y,x2:r.x+jI.ANCHOR_MARKER_SIZE,y2:r.y,stroke:F0.OFFSET_LINE,strokeWidth:jI.ANCHOR_MARKER_STROKE_WIDTH}),Z.jsx("line",{x1:r.x,y1:r.y-jI.ANCHOR_MARKER_SIZE,x2:r.x,y2:r.y+jI.ANCHOR_MARKER_SIZE,stroke:F0.OFFSET_LINE,strokeWidth:jI.ANCHOR_MARKER_STROKE_WIDTH})]},`anchor-${s}`))]})})},k5e=({elements:e,highlightedPrimitives:A,transform:t,containerWidth:i,containerHeight:n})=>{const o=e.filter(h=>vpA(h)),s=e.filter(h=>V_(h)),r=e.filter(h=>Fgt(h)),a=A.map(h=>V_(h._parent_pcb_component)?h._parent_pcb_component.pcb_component_id:V_(h._element)?h._element.pcb_component_id:null).filter(h=>!!h),g=new Set;if(a.forEach(h=>{const u=s.find(d=>d.pcb_component_id===h);u?.pcb_group_id&&g.add(u.pcb_group_id)}),!tC(h=>h.is_showing_group_anchor_offsets)&&a.length===0)return null;const c=s.map(h=>{const u=h.positioned_relative_to_pcb_board_id;if(!u)return null;const d=o.find(f=>f.pcb_board_id===u);return d?{component:h,board:d,type:"component"}:null}).filter(h=>!!h),l=r.map(h=>{const u=h.positioned_relative_to_pcb_board_id;if(!u||!h.center)return null;const d=o.find(f=>f.pcb_board_id===u);return d?{group:h,board:d,type:"group"}:null}).filter(h=>!!h),B=[...c,...l];if(B.length===0)return null;const C=a.length===0,E=B.filter(h=>h.type==="component"?C||a.includes(h.component.pcb_component_id):C||g.has(h.group.pcb_group_id));if(E.length===0)return null;const Q=E.map(h=>h.type==="component"?{id:`${h.board.pcb_board_id}-${h.component.pcb_component_id}-${h.type}`,anchor:h.board.center,anchor_id:h.board.pcb_board_id,target:h.component.center,type:"component",display_offset_x:h.component.display_offset_x,display_offset_y:h.component.display_offset_y}:{id:`${h.board.pcb_board_id}-${h.group.pcb_group_id}-${h.type}`,anchor:h.board.center,anchor_id:h.board.pcb_board_id,target:{x:h.group.anchor_position?.x??h.group.center.x,y:h.group.anchor_position?.y??h.group.center.y},type:"group",display_offset_x:h.group.display_offset_x,display_offset_y:h.group.display_offset_y}).filter(h=>!!h);return Z.jsx(LpA,{targets:Q,transform:t,containerWidth:i,containerHeight:n})},G5e=({elements:e,highlightedPrimitives:A,transform:t,containerWidth:i,containerHeight:n})=>{const o=e.filter(h=>Fgt(h)),s=e.filter(h=>V_(h)),r=A.map(h=>V_(h._parent_pcb_component)?h._parent_pcb_component.pcb_component_id:V_(h._element)?h._element.pcb_component_id:null).filter(h=>!!h),a=(h,u)=>{if(u.has(h))return;u.add(h);const d=o.find(f=>f.pcb_group_id===h);d?.position_mode==="relative_to_group_anchor"&&d.positioned_relative_to_pcb_group_id&&a(d.positioned_relative_to_pcb_group_id,u)},g=new Set;if(r.forEach(h=>{const u=s.find(d=>d.pcb_component_id===h);u&&(u.position_mode==="relative_to_group_anchor"&&u.positioned_relative_to_pcb_group_id&&a(u.positioned_relative_to_pcb_group_id,g),u.pcb_group_id&&a(u.pcb_group_id,g))}),!tC(h=>h.is_showing_group_anchor_offsets)&&r.length===0)return null;const c=s.map(h=>{if(h.position_mode==="relative_to_group_anchor"&&h.positioned_relative_to_pcb_group_id){const u=o.find(d=>d.pcb_group_id===h.positioned_relative_to_pcb_group_id);return u&&u.anchor_position?{component:h,parentGroup:u,type:"component"}:null}if(h.pcb_group_id){const u=o.find(d=>d.pcb_group_id===h.pcb_group_id);return u&&u.anchor_position?{component:h,parentGroup:u,type:"component"}:null}return null}).filter(h=>!!h),l=o.map(h=>{if(h.position_mode==="relative_to_group_anchor"&&h.positioned_relative_to_pcb_group_id){const u=o.find(d=>d.pcb_group_id===h.positioned_relative_to_pcb_group_id);if(u&&u.anchor_position&&h.anchor_position)return{group:h,parentGroup:u,type:"group"}}return null}).filter(h=>!!h),B=[...c,...l];if(B.length===0)return null;const C=r.length===0,E=B.filter(h=>h.type==="component"?C||r.includes(h.component.pcb_component_id):C||g.has(h.group.pcb_group_id)||g.has(h.parentGroup.pcb_group_id));if(E.length===0)return null;const Q=E.map(h=>{const u=h.parentGroup.anchor_position;return u?h.type==="component"?h.component.center?{id:`${h.parentGroup.pcb_group_id}-${h.component.pcb_component_id}-${h.type}`,anchor:u,anchor_id:h.parentGroup.pcb_group_id,target:h.component.center,type:"component",display_offset_x:h.component.display_offset_x,display_offset_y:h.component.display_offset_y}:null:h.group.anchor_position?{id:`${h.parentGroup.pcb_group_id}-${h.group.pcb_group_id}-${h.type}`,anchor:u,anchor_id:h.parentGroup.pcb_group_id,target:h.group.anchor_position,type:"group",display_offset_x:h.group.display_offset_x,display_offset_y:h.group.display_offset_y}:null:null}).filter(h=>!!h);return Z.jsx(LpA,{targets:Q,transform:t,containerWidth:i,containerHeight:n})},F5e=(e,A)=>{const t=e.pcb_component_id,i=A.filter(n=>(n.type==="pcb_smtpad"||n.type==="pcb_plated_hole")&&n.pcb_component_id===t||n.type==="pcb_hole"&&n.pcb_component_id===t);return i.length===0?FpA([e]):FpA(i)},M5e=({elements:e,highlightedPrimitives:A,transform:t,containerWidth:i,containerHeight:n})=>{const o=new Map;for(const r of A)V_(r._parent_pcb_component)&&o.set(r._parent_pcb_component.pcb_component_id,r._parent_pcb_component),V_(r._element)&&o.set(r._element.pcb_component_id,r._element);if(o.size===0)return null;const s=[];for(const r of o.values()){const a=F5e(r,e);if(!a)continue;const g=r.positioned_relative_to_pcb_group_id??r.pcb_group_id,I=g?mb(e).pcb_group.get(g):null;s.push({component:r,bbox:a,group:I})}return s.length===0?null:Z.jsx("div",{style:{position:"absolute",left:0,top:0,width:i,height:n,overflow:"hidden",pointerEvents:"none",zIndex:dI.dimensionOverlay},children:Z.jsx("svg",{style:{position:"absolute",left:0,top:0,pointerEvents:"none"},width:i,height:n,children:s.map(({component:r,bbox:a,group:g})=>{const I=qi(t,{x:a.minX,y:a.maxY}),c=qi(t,{x:a.maxX,y:a.minY}),l={x:Math.min(I.x,c.x),y:Math.min(I.y,c.y),width:Math.abs(c.x-I.x),height:Math.abs(c.y-I.y)},B=r.center??{x:(a.minX+a.maxX)/2,y:(a.minY+a.maxY)/2},C=qi(t,B);return Z.jsxs("g",{children:[Z.jsx("rect",{x:l.x,y:l.y,width:l.width,height:l.height,fill:"none",stroke:"white",strokeWidth:1.5,strokeDasharray:"4,4"}),Z.jsx("line",{x1:C.x-6,y1:C.y,x2:C.x+6,y2:C.y,stroke:F0.COMPONENT_MARKER_STROKE,strokeWidth:1.5}),Z.jsx("line",{x1:C.x,y1:C.y-6,x2:C.x,y2:C.y+6,stroke:F0.COMPONENT_MARKER_STROKE,strokeWidth:1.5}),Z.jsx("circle",{cx:C.x,cy:C.y,r:jI.COMPONENT_MARKER_RADIUS,fill:F0.COMPONENT_MARKER_FILL,stroke:F0.COMPONENT_MARKER_STROKE,strokeWidth:1})]},r.pcb_component_id)})})})},R5e=({elements:e,highlightedPrimitives:A,transform:t,containerWidth:i,containerHeight:n})=>{const o=e.filter(B=>_5e(B)),s=e.filter(B=>vpA(B)),r=A.map(B=>vpA(B._element)?B._element.pcb_board_id:null).filter(B=>!!B);if(!tC(B=>B.is_showing_group_anchor_offsets)&&r.length===0)return null;const g=s.map(B=>{const C=B.pcb_panel_id,E=B.position_mode;if(!C||E!=="relative_to_panel_anchor")return null;const Q=o.find(h=>h.pcb_panel_id===C);return Q?{board:B,panel:Q,type:"board"}:null}).filter(B=>!!B);if(g.length===0)return null;const I=r.length===0,c=g.filter(B=>I||r.includes(B.board.pcb_board_id));if(c.length===0)return null;const l=c.map(B=>B.board.center?{id:`${B.panel.pcb_panel_id}-${B.board.pcb_board_id}-${B.type}`,anchor:B.panel.center,anchor_id:B.panel.pcb_panel_id,target:B.board.center,type:"board",display_offset_x:B.board.display_offset_x,display_offset_y:B.board.display_offset_y}:null).filter(B=>!!B);return Z.jsx(LpA,{targets:l,transform:t,containerWidth:i,containerHeight:n})},o9=e=>{if(e.length===0)return null;let A=e[0].x,t=e[0].y,i=e[0].x,n=e[0].y;for(const o of e)o.x<A&&(A=o.x),o.y<t&&(t=o.y),o.x>i&&(i=o.x),o.y>n&&(n=o.y);return{center:{x:(A+i)/2,y:(t+n)/2},width:i-A,height:n-t}},Mgt=(e,A)=>{if(A.length<3)return!1;let t=!1;for(let i=0,n=A.length-1;i<A.length;n=i++){const o=A[i].x,s=A[i].y,r=A[n].x,a=A[n].y;s>e.y!=a>e.y&&e.x<(r-o)*(e.y-s)/(a-s||Number.EPSILON)+o&&(t=!t)}return t},N5e=(e,A,t)=>{const i=[];for(const n of e){if(!n._element)continue;if("x1"in n&&n._element?.type==="pcb_trace"){const r=_h({x:A.x,y:A.y},{x:n.x1,y:n.y1},{x:n.x2,y:n.y2}),a=n.width||.5,g=Math.max(a*25,2)/t.a;r<g&&i.push(n);continue}if(n.pcb_drawing_type==="polygon"){const r=n.points.map(g=>({x:Ee.parse(g.x),y:Ee.parse(g.y)})),a=o9(r);if(!a||A.x<a.center.x-a.width/2||A.x>a.center.x+a.width/2||A.y<a.center.y-a.height/2||A.y>a.center.y+a.height/2)continue;Mgt(A,r)&&i.push(n);continue}if(n.pcb_drawing_type==="polygon_with_arcs"){const r=n.brep_shape.outer_ring.vertices.map(g=>({x:Ee.parse(g.x),y:Ee.parse(g.y)})),a=o9(r);if(!a||A.x<a.center.x-a.width/2||A.x>a.center.x+a.width/2||A.y<a.center.y-a.height/2||A.y>a.center.y+a.height/2)continue;Mgt(A,r)&&i.push(n);continue}if(!("x"in n&&"y"in n))continue;let o=0,s=0;if("w"in n&&"h"in n)o=n.w,s=n.h;else if("r"in n)o=n.r*2,s=n.r*2;else if("rX"in n&&"rY"in n)o=n.rX*2,s=n.rY*2;else continue;Math.abs(n.x-A.x)<o/2&&Math.abs(n.y-A.y)<s/2&&i.push(n)}return i},v5e=({elements:e,children:A,transform:t,primitives:i,onMouseHoverOverPrimitives:n})=>{const[o,s]=AA.useState([]),[r,a]=AA.useState({x:0,y:0}),[g,{width:I,height:c}]=$Y(),l=AA.useMemo(()=>{const C=[];for(const E of o){if(E._element?.type==="pcb_via"||E._element?.type==="pcb_component"||E?.layer==="drill")continue;let Q=null,h=0,u=0;if(E.pcb_drawing_type==="polygon"){const w=o9(E.points);if(!w)continue;Q=w.center,h=w.width,u=w.height}else if(E.pcb_drawing_type==="polygon_with_arcs"){const w=E.brep_shape.outer_ring.vertices.map(b=>({x:b.x,y:b.y})),D=o9(w);if(!D)continue;Q=D.center,h=D.width,u=D.height}else"x"in E&&"y"in E&&(Q={x:E.x,y:E.y},h="w"in E?E.w:"r"in E?E.r*2:"rX"in E&&"rY"in E?E.rX*2:0,u="h"in E?E.h:"r"in E?E.r*2:"rX"in E&&"rY"in E?E.rY*2:0);if(!Q)continue;const d=qi(t,Q),f={w:h*t.a,h:u*t.a},m=C.filter(w=>d.x===w.screen_x&&d.y===w.screen_y&&f.w===w.screen_w&&f.h===w.screen_h).length;C.push({...E,x:Q.x,y:Q.y,w:h,h:u,screen_x:d.x,screen_y:d.y,screen_w:f.w,screen_h:f.h,same_space_index:m})}return C},[o,t]),B=(C,E,Q,h)=>{a({x:C,y:E});const u=qi(fb(Q),{x:C,y:E}),d=N5e(h,u,Q);f5e(new Set(d.map(f=>f._pcb_drawing_object_id)),new Set(o.map(f=>f._pcb_drawing_object_id)))||(s(d),n(d))};return Z.jsxs("div",{ref:g,style:{position:"relative",width:"100%",height:"100%"},onMouseMove:C=>{if(t){const E=C.currentTarget.getBoundingClientRect(),Q=C.clientX-E.left,h=C.clientY-E.top;B(Q,h,t,i)}},onTouchStart:C=>{if(t){const E=C.touches[0],Q=C.currentTarget.getBoundingClientRect(),h=E.clientX-Q.left,u=E.clientY-Q.top;B(h,u,t,i)}},children:[A,Z.jsx(x5e,{elements:e,mousePos:r,highlightedPrimitives:l}),t&&Z.jsxs(Z.Fragment,{children:[Z.jsx(k5e,{elements:e,highlightedPrimitives:l,transform:t,containerWidth:I,containerHeight:c}),Z.jsx(G5e,{elements:e,highlightedPrimitives:l,transform:t,containerWidth:I,containerHeight:c}),Z.jsx(M5e,{elements:e,highlightedPrimitives:l,transform:t,containerWidth:I,containerHeight:c}),Z.jsx(R5e,{elements:e,highlightedPrimitives:l,transform:t,containerWidth:I,containerHeight:c})]})]})},Rgt=["rgb(255, 100, 100)","rgb(100, 255, 100)","rgb(100, 100, 255)","rgb(255, 255, 100)","rgb(255, 100, 255)","rgb(100, 255, 255)","rgb(255, 150, 100)","rgb(150, 100, 255)","rgb(100, 255, 150)","rgb(255, 100, 150)"],L5e=({children:e,transform:A=pb(),elements:t=[],hoveredComponentIds:i=[]})=>{const[n,{width:o,height:s}]=$Y(),r=AA.useRef(null),{is_showing_pcb_groups:a,pcb_group_view_mode:g,is_showing_group_anchor_offsets:I}=tC(c=>({is_showing_pcb_groups:c.is_showing_pcb_groups,pcb_group_view_mode:c.pcb_group_view_mode,is_showing_group_anchor_offsets:c.is_showing_group_anchor_offsets}));return AA.useEffect(()=>{const c=r.current;if(!c||!o||!s)return;c.width=o,c.height=s;const l=c.getContext("2d");if(!l||(l.clearRect(0,0,o,s),!a))return;const B=t.filter(w=>w.type==="pcb_group"),C=t.filter(w=>w.type==="pcb_component"),E=t.filter(w=>w.type==="source_group"),Q=new Map(E.map(w=>[w.source_group_id,w])),h=B.filter(w=>{if(g==="all")return!0;if(!w.source_group_id)return!1;const D=Q.get(w.source_group_id);return D?D.was_automatically_named!==!0:!1}),u=new Map;E.forEach(w=>{const D=w;if(D.parent_source_group_id){const b=u.get(D.parent_source_group_id)||[];b.push(w.source_group_id),u.set(D.parent_source_group_id,b)}});const d=w=>{const D=[],b=u.get(w)||[];for(const k of b)D.push(k),D.push(...d(k));return D},f=w=>{const D=E.find(b=>b.source_group_id===w);return D?.parent_source_group_id?1+f(D.parent_source_group_id):0},m=new Set;if(i.length>0)for(const w of C){if(!i.includes(w.pcb_component_id))continue;const D=w.positioned_relative_to_pcb_group_id??w.pcb_group_id;D&&m.add(D)}h.forEach((w,D)=>{let b=C.filter(HA=>HA.pcb_group_id===w.pcb_group_id);if(w.source_group_id){const HA=d(w.source_group_id),ZA=B.filter(xA=>xA.source_group_id&&HA.includes(xA.source_group_id));for(const xA of ZA){const wA=C.filter(UA=>UA.pcb_group_id===xA.pcb_group_id);b=[...b,...wA]}}let k,x,N,R,U=!1;if(w.center&&w.width&&w.height){U=!0;const HA=w.width/2,ZA=w.height/2;k=w.center.x-HA,N=w.center.x+HA,x=w.center.y-ZA,R=w.center.y+ZA}else if(b.length===0||(k=1/0,x=1/0,N=-1/0,R=-1/0,b.forEach(HA=>{if(HA.center&&typeof HA.width=="number"&&typeof HA.height=="number"){const ZA=HA.center.x-HA.width/2,xA=HA.center.x+HA.width/2,wA=HA.center.y+HA.height/2,UA=HA.center.y-HA.height/2;k=Math.min(k,ZA),N=Math.max(N,xA),x=Math.min(x,UA),R=Math.max(R,wA)}}),k===1/0||N===-1/0))return;const Y=w.source_group_id?f(w.source_group_id):0,H=w.source_group_id?d(w.source_group_id).length>0:!1;if(!U){const xA=1+(H?.5:0);k-=xA,N+=xA,x-=xA,R+=xA}const O=qi(A,{x:k,y:R}),W=qi(A,{x:N,y:R}),$=qi(A,{x:k,y:x}),iA=qi(A,{x:N,y:x}),rA=Rgt[D%Rgt.length];l.strokeStyle=rA,l.lineWidth=2;const tA=Math.max(4,Math.min(12,8*Math.abs(A.a))),oA=Math.max(2,Math.min(6,4*Math.abs(A.a))),QA=tA*(H?1.3:1),SA=oA;l.setLineDash([QA,SA]),l.beginPath(),l.moveTo(O.x,O.y),l.lineTo(W.x,W.y),l.lineTo(iA.x,iA.y),l.lineTo($.x,$.y),l.closePath(),l.stroke();const FA=Math.max(8,Math.min(12,10*Math.abs(A.a))),MA=Y==0||Y==1?0:Y*.11,KA=FA*(1-MA),hA=4,GA=w.name||`Group ${D+1}`;l.font=`${KA}px sans-serif`,l.setLineDash([]);const PA=l.measureText(GA).width+hA*2,JA=KA+hA*2,it=O.x-5,fA=O.y-5,tt=3;if(l.fillStyle="rgba(0, 0, 0, 0.8)",l.beginPath(),l.roundRect(it,fA-JA,PA,JA,tt),l.fill(),l.fillStyle=rA,l.textAlign="left",l.textBaseline="middle",l.fillText(GA,it+hA,fA-JA/2),I&&m.has(w.pcb_group_id)&&!!w.anchor_position&&w.anchor_position){const HA=Array.isArray(w.anchor_position)?{x:w.anchor_position[0]??0,y:w.anchor_position[1]??0}:{x:w.anchor_position.x,y:w.anchor_position.y},ZA=qi(A,HA);l.strokeStyle="white",l.lineWidth=1.5,l.setLineDash([]);const xA=Math.max(4,Math.min(8,6*Math.abs(A.a)));l.beginPath(),l.moveTo(ZA.x-xA,ZA.y),l.lineTo(ZA.x+xA,ZA.y),l.stroke(),l.beginPath(),l.moveTo(ZA.x,ZA.y-xA),l.lineTo(ZA.x,ZA.y+xA),l.stroke()}})},[t,A,o,s,a,g,I,i]),Z.jsxs("div",{ref:n,style:{position:"relative",width:"100%",height:"100%"},children:[e,Z.jsx("canvas",{ref:r,style:{position:"absolute",top:0,left:0,pointerEvents:"none",zIndex:dI.pcbGroupOverlay,display:a?"block":"none"}})]})},U5e=({transform:e,soup:A,children:t})=>{const i=tC(r=>r.is_showing_rats_nest),{netMap:n,idToNetMap:o}=AA.useMemo(()=>lgt(A||[]),[A]),s=AA.useMemo(()=>{if(!A||!i)return[];const r=l=>{const B=mb(A)[l.replace(/_\d+$/,"")].get(l);return B&&"x"in B&&"y"in B?{x:B.x,y:B.y}:null},a=(l,B)=>{const C=n[B]||[];let E=null,Q=1/0;return C.forEach(h=>{const u=r(h);if(u){const d=Math.sqrt((l.x-u.x)**2+(l.y-u.y)**2);d<Q&&d>0&&(Q=d,E=u)}}),E},g=mb(A).pcb_port.list(),I=mb(A).source_trace.list(),c=[];return g.forEach((l,B)=>{const C=o[l.pcb_port_id];let E=!1;for(const u of I)u.connected_source_port_ids.includes(l.source_port_id)&&u.connected_source_net_ids.length>0&&(E=!0);if(!C)return;const Q={x:l.x,y:l.y},h=a(Q,C);h&&c.push({key:`${l.pcb_port_id}-${B}`,startPoint:Q,endPoint:h,isInNet:E})}),c},[A,n,o,i]);return!A||!i?t:(e||(e=pb()),Z.jsxs("div",{style:{position:"relative"},children:[t,Z.jsx("svg",{style:{position:"absolute",left:0,top:0,width:"100%",height:"100%",pointerEvents:"none",opacity:.5,zIndex:dI.ratsNestOverlay},children:s.map(({key:r,startPoint:a,endPoint:g,isInNet:I})=>{const c=qi(e,a),l=qi(e,g);return Z.jsx("line",{x1:c.x,y1:c.y,x2:l.x,y2:l.y,stroke:"white",strokeWidth:"1",strokeDasharray:I?"6,6":void 0},r)})})]}))},H5e={version:"1.11.334"},j_=(e,A,t)=>{const i=tC(s=>s.is_mouse_over_container),n=AA.useRef(i),o=AA.useRef(A);AA.useEffect(()=>{n.current=i},[i]),AA.useEffect(()=>{o.current=A},[A]),AA.useEffect(()=>{if(!e)return;const s=r=>{const a=r.target;if(a.tagName==="INPUT"||a.tagName==="TEXTAREA"||a.isContentEditable)return;const g=e.split("+"),I=g.includes("ctrl"),c=g.includes("shift"),l=g.includes("alt"),B=g.includes("meta"),C=g[g.length-1],E=t?.current?t.current.contains(document.activeElement)||document.activeElement===t.current:!1;(n.current||E)&&(!I||r.ctrlKey)&&(!c||r.shiftKey)&&(!l||r.altKey)&&(!B||r.metaKey)&&r.key.toLowerCase()===C.toLowerCase()&&(r.preventDefault(),o.current())};return window.addEventListener("keydown",s),()=>{window.removeEventListener("keydown",s)}},[e])},Y5e=()=>{const[e,A]=AA.useState(!1);return AA.useEffect(()=>{const t=()=>{A(window.innerWidth<=768)};return t(),window.addEventListener("resize",t),()=>window.removeEventListener("resize",t)},[]),e},J5e=({name:e,selected:A,onClick:t})=>Z.jsxs("div",{className:Wv`
5468
+ `,p5e=({children:e,transform:A=pb(),elements:t})=>{const i=AA.useRef(null),{isShowingDRCErrors:n,hoveredErrorId:o}=tC(g=>({isShowingDRCErrors:g.is_showing_drc_errors,hoveredErrorId:g.hovered_error_id}));if(!t)return Z.jsx("div",{style:{position:"relative"},ref:i,children:e});const s=t.filter(g=>g.type==="pcb_trace_error"),r=t.filter(g=>g.type==="pcb_trace_error"&&g.message?.includes("Multiple components found with name")),a=new Map;return t.forEach(g=>{g.type==="pcb_port"&&a.set(g.pcb_port_id,g)}),Z.jsxs("div",{style:{position:"relative"},ref:i,children:[e,s.map((g,I)=>{const{pcb_port_ids:c,pcb_trace_id:l}=g,B=c?.[0]?a.get(c[0]):void 0,C=c?.[1]?a.get(c[1]):void 0,E=t?mb(t).pcb_trace.get(l):void 0,Q=g.pcb_trace_error_id||`error_${I}_${g.error_type}_${g.message?.slice(0,20)}`,h=o===Q;if(B&&C){const u=qi(A,{x:B.x,y:B.y}),d=qi(A,{x:C.x,y:C.y});if(!n)return null;const f=!(isNaN(u.x)||isNaN(u.y)||isNaN(d.x)||isNaN(d.y)),m={x:(u.x+d.x)/2,y:(u.y+d.y)/2};if(isNaN(m.x)||isNaN(m.y))return null;const w=RpA(m,i);return Z.jsxs(AA.Fragment,{children:[Z.jsx(u5e,{screenPort1:u,screenPort2:d,errorCenter:m,canLineBeDrawn:f,isHighlighted:h}),Z.jsx("div",{style:{position:"absolute",left:m.x-15,top:m.y-15,width:30,height:30,zIndex:dI.errorOverlay+5,cursor:"pointer",borderRadius:"50%"},onMouseEnter:D=>{const b=D.currentTarget.nextElementSibling;if(b){const k=b.querySelector(".error-message");k&&(k.style.opacity="1")}},onMouseLeave:D=>{if(!h){const b=D.currentTarget.nextElementSibling;if(b){const k=b.querySelector(".error-message");k&&(k.style.opacity="0")}}}}),Z.jsx("div",{style:{position:"absolute",zIndex:h?200:100,left:w.left,top:w.top,color:h?"#ff4444":"red",textAlign:"center",fontFamily:"sans-serif",fontSize:12,display:n||h?"flex":"none",flexDirection:"column",alignItems:"center",pointerEvents:"none",transform:w.transform},children:Z.jsx("div",{className:`error-message ${NpA}`,style:{opacity:h?1:0,border:`1px solid ${h?"#ff4444":"red"}`},children:g.message})})]},Q)}if(E?.route&&(n||h)){const u=E.route.map(w=>qi(A,{x:w.x,y:w.y}));if(u.some(w=>isNaN(w.x)||isNaN(w.y)))return null;const d=Math.floor(u.length/2),f=u[d],m=RpA(f,i);return Z.jsxs(AA.Fragment,{children:[Z.jsx(d5e,{points:u,errorCenter:f,isHighlighted:h}),Z.jsx("div",{style:{position:"absolute",left:f.x-15,top:f.y-15,width:30,height:30,zIndex:dI.errorOverlay+5,cursor:"pointer",borderRadius:"50%"},onMouseEnter:w=>{const D=w.currentTarget.nextElementSibling;if(D){const b=D.querySelector(".error-message");b&&(b.style.opacity="1")}},onMouseLeave:w=>{if(!h){const D=w.currentTarget.nextElementSibling;if(D){const b=D.querySelector(".error-message");b&&(b.style.opacity="0")}}}}),Z.jsx("div",{style:{position:"absolute",zIndex:h?dI.errorOverlay+10:dI.errorOverlay+1,left:m.left,top:m.top,color:h?"#ff4444":"red",textAlign:"center",fontFamily:"sans-serif",fontSize:12,display:"flex",flexDirection:"column",alignItems:"center",pointerEvents:"none",transform:m.transform},children:Z.jsx("div",{className:`error-message ${NpA}`,style:{opacity:h?1:0,border:`1px solid ${h?"#ff4444":"red"}`},children:g.message})})]},Q)}return null}),r.map((g,I)=>{const c=g.component_name||g.message?.match(/name "([^"]+)"/)?.[1];if(!c)return null;const l=t?.filter(E=>E.type==="source_component"&&E.name===c||E.type==="pcb_component"&&t?.find(Q=>Q.type==="source_component"&&Q.source_component_id===E.source_component_id&&Q.name===c))||[],B=g.pcb_trace_error_id||`error_${I}_${g.error_type}_${g.message?.slice(0,20)}`,C=o===B;return!C&&!n?null:l.map((E,Q)=>{let h={x:0,y:0};if(E.type==="pcb_component")h=E.center||{x:0,y:0};else if(E.type==="source_component"){const k=t?.find(x=>x.type==="pcb_component"&&x.source_component_id===E.source_component_id);k&&k.type==="pcb_component"&&(h=k.center||{x:0,y:0})}const u=qi(A,h);if(isNaN(u.x)||isNaN(u.y))return null;const d=Math.abs(A.a),D=Math.max(8,Math.min(30,.5*d)),b=RpA(u,i);return Z.jsxs(AA.Fragment,{children:[Z.jsx("svg",{style:{position:"absolute",left:0,top:0,pointerEvents:"none",mixBlendMode:"difference",zIndex:dI.errorOverlay},width:"100%",height:"100%",children:C?Z.jsx("polygon",{points:`${u.x},${u.y-D*1.25} ${u.x+D},${u.y} ${u.x},${u.y+D*1.25} ${u.x-D},${u.y}`,fill:"#ff4444"}):Z.jsx("circle",{cx:u.x,cy:u.y,r:D,fill:"none",stroke:C?"#ff4444":"red",strokeWidth:C?Math.max(2,D*.15):Math.max(1,D*.1),opacity:1})}),Z.jsx("div",{style:{position:"absolute",left:u.x-(D+10),top:u.y-(D+10),width:(D+10)*2,height:(D+10)*2,zIndex:dI.errorOverlay+5,cursor:"pointer",borderRadius:"50%"},onMouseEnter:k=>{const x=k.currentTarget.nextElementSibling;if(x){const N=x.querySelector(".error-message");N&&(N.style.opacity="1")}},onMouseLeave:k=>{if(!C){const x=k.currentTarget.nextElementSibling;if(x){const N=x.querySelector(".error-message");N&&(N.style.opacity="0")}}}}),Z.jsx("div",{style:{position:"absolute",zIndex:C?dI.errorOverlay+20:dI.errorOverlay+10,left:b.left,top:b.top,color:C?"#ff4444":"red",textAlign:"center",fontFamily:"sans-serif",fontSize:12,display:n||C?"flex":"none",flexDirection:"column",alignItems:"center",pointerEvents:"none",transform:b.transform},children:Z.jsx("div",{className:`error-message ${NpA}`,style:{opacity:C?1:0,border:`1px solid ${C?"#ff4444":"red"}`},children:g.message})})]},`${B}_${Q}`)})})]})};function f5e(e,A){return e.size!==A.size?!1:Array.from(e).every(t=>A.has(t))}function y5e({primitiveElement:e,elements:A}){let t=e.trace_length?`${e.trace_length.toFixed(3)}`:"";const i=mb(A).source_trace.get(e?.source_trace_id);if(i?.display_name&&(i?.max_length?t+=` / ${i.max_length}mm `:t+=" mm ",t+=`(${i.display_name})`),!t)return null;const n=e.trace_length&&i?.max_length&&e.trace_length>i.max_length;return{text:t,isOverLength:n}}function m5e(e){const{primitives:A,is_showing_multiple_traces_length:t,elements:i}=e,n=A.filter(a=>a._element.type==="pcb_trace"),o=i.filter(a=>a.type==="source_trace"),s=A.filter(a=>a._element.type!=="pcb_trace"),r=n.filter(a=>o.some(g=>a._element.type==="pcb_trace"&&a._element.source_trace_id===g.source_trace_id&&g.max_length!==void 0));if(!t)return[...s,...r];if(n.length>1){const a=n.reduce((g,I)=>{const c=g._element.trace_length;return I._element.trace_length<c?I:g},n[0]);return[...s,a]}return A}var w5e={position:"absolute",left:0,top:0,pointerEvents:"none",color:"red",fontFamily:"sans-serif",fontSize:12,textShadow:"0 0 2px black"},D5e=e=>{const{_element:A,_parent_pcb_component:t,_parent_source_component:i,_source_port:n}=e;switch(A.type){case"pcb_trace":return A.trace_length?`${A.trace_length.toFixed(3)}`:"";case"pcb_smtpad":case"pcb_plated_hole":{const o=[],s=Array.from(new Set((A.port_hints??[]).concat(n?.port_hints??[]))).filter(a=>!/^[0-9]+$/.test(a)).filter(a=>!a.includes("unnamed_")).sort((a,g)=>g.localeCompare(a)),r=i&&"name"in i&&i.name&&!i.name.includes("unnamed_")?i.name:null;return s.length>0?r?o.push(...s.map(a=>`${r}.${a}`)):o.push(...s):r&&o.push(r),o.join(", ")}default:return""}},S5e={top:"red",bottom:"aqua"},b5e=({primitive:e,mousePos:A,elements:t})=>{const[i,n]=AA.useState(!1),o=e._element;AA.useEffect(()=>{setTimeout(()=>{n(!0)},100)},[]);const[s,r,a,g]=[e.screen_x,e.screen_y,e.screen_w,e.screen_h],I=e.same_space_index??0,c=26,l=S5e[e?._element?.layer]??"red";let B=0;if(o.type==="pcb_smtpad"&&o?.shape==="rotated_rect"?B=o?.ccw_rotation??0:(o.type==="pcb_smtpad"&&(o?.shape==="pill"||o?.shape==="rotated_pill")&&"ccw_rotation"in e||o.type==="pcb_plated_hole"&&(o?.shape==="pill"||o?.shape==="oval")&&"ccw_rotation"in e)&&(B=o.ccw_rotation??0),o.type==="pcb_trace"){const Q=y5e({primitiveElement:o,elements:t});if(!Q)return null;const h=A.y-35;return Z.jsx("div",{style:{zIndex:dI.elementOverlay,position:"absolute",left:A.x,top:h,color:l,pointerEvents:"none",transform:"translateX(-50%)"},children:Z.jsx("div",{style:{backgroundColor:"#f2efcc",color:Q.isOverLength?"red":"black",textShadow:"none",WebkitFontSmoothing:"antialiased",MozOsxFontSmoothing:"grayscale",padding:"6px 6px",borderRadius:"6px",fontSize:"14px",minWidth:"45px",textAlign:"center",whiteSpace:"nowrap"},children:Q.text})})}const C=D5e(e);return C.trim().length===0?null:Z.jsx("div",{style:{zIndex:dI.elementOverlay,position:"absolute",left:s-a/2-8,top:r-g/2-8,width:a+16,height:g+16,color:l,transform:`rotate(${-B}deg)`,transformOrigin:"center center"},children:Z.jsx("div",{style:{width:i?`calc(100% + ${c*2*I}px)`:"100%",height:i?`calc(100% + ${c*2*I}px)`:"100%",marginLeft:i?`${-c*I}px`:0,marginTop:i?`${-c*I}px`:0,border:`1px solid ${l}`,opacity:i||I===0?1:0,transition:"width 0.2s, height 0.2s, margin-left 0.2s, margin-top 0.2s, opacity 0.2s"},children:Z.jsx("div",{style:{position:"absolute",bottom:g+20+c*I,marginRight:i?`${-c*I}px`:0,marginBottom:i?0:-c*I,transition:"margin-right 0.2s, margin-bottom 0.2s",backgroundColor:"#f2efcc",color:"black",textShadow:"none",WebkitFontSmoothing:"antialiased",MozOsxFontSmoothing:"grayscale",padding:"6px 6px",borderRadius:"6px",fontSize:"14px",transform:`rotate(${B}deg)`,minWidth:"45px",textAlign:"center"},children:C})})})},x5e=({highlightedPrimitives:e,mousePos:A,elements:t})=>{const[i,n]=tC(r=>[r.is_moving_component,r.is_showing_multiple_traces_length]),o=e.some(r=>r._element.type==="pcb_smtpad")&&e.some(r=>r._element.type==="pcb_trace");let s=e;return o&&(s=s.filter(r=>r._element.type==="pcb_smtpad")),s=m5e({primitives:s,is_showing_multiple_traces_length:n,elements:t}),Z.jsx("div",{style:w5e,children:!i&&s.map((r,a)=>Z.jsx(b5e,{primitive:r,mousePos:A,elements:t},a))})},V_=e=>e?.type==="pcb_component",Fgt=e=>e?.type==="pcb_group",_5e=e=>e?.type==="pcb_panel",vpA=e=>e?.type==="pcb_board",jI={MIN_LINE_LENGTH_FOR_LABEL:40,LABEL_OFFSET_ABOVE:2,LABEL_OFFSET_BELOW:-18,LABEL_OFFSET_RIGHT:8,LABEL_OFFSET_LEFT:-120,Y_LABEL_MIN_WIDTH:110,LINE_STROKE_WIDTH:1.5,LINE_DASH_PATTERN:"4,4",COMPONENT_MARKER_RADIUS:3,LABEL_FONT_SIZE:11,ANCHOR_MARKER_SIZE:6,ANCHOR_MARKER_STROKE_WIDTH:1.5},F0={OFFSET_LINE:"white",COMPONENT_MARKER_FILL:"#66ccff",COMPONENT_MARKER_STROKE:"white",LABEL_TEXT:"white"},LpA=({targets:e,transform:A,containerWidth:t,containerHeight:i})=>{if(e.length===0)return null;const n={color:F0.LABEL_TEXT,mixBlendMode:"difference",pointerEvents:"none",fontSize:jI.LABEL_FONT_SIZE,fontFamily:"monospace",fontWeight:"bold"},o=new Map;return e.forEach(s=>{if(!o.has(s.anchor_id)){const r=qi(A,s.anchor);o.set(s.anchor_id,r)}}),Z.jsx("div",{style:{position:"absolute",left:0,top:0,width:t,height:i,overflow:"hidden",pointerEvents:"none",zIndex:dI.dimensionOverlay},children:Z.jsxs("svg",{style:{position:"absolute",left:0,top:0,pointerEvents:"none"},width:t,height:i,children:[e.map(s=>{const r=s.anchor,a=s.anchor_id,g=s.target,I=o.get(a),c=qi(A,g),l=g.x-r.x,B=g.y-r.y,C=Math.abs(c.x-I.x),E=Math.abs(c.y-I.y),Q=c.y<I.y,h=c.x>I.x,u=Q?jI.LABEL_OFFSET_ABOVE:jI.LABEL_OFFSET_BELOW,d=h?jI.LABEL_OFFSET_RIGHT:jI.LABEL_OFFSET_LEFT,f=C>jI.MIN_LINE_LENGTH_FOR_LABEL,m=E>jI.MIN_LINE_LENGTH_FOR_LABEL,w=`${s.display_offset_x??l.toFixed(2)}mm`,D=`${s.display_offset_y??B.toFixed(2)}mm`;return Z.jsxs("g",{children:[Z.jsx("line",{x1:I.x,y1:I.y,x2:c.x,y2:I.y,stroke:F0.OFFSET_LINE,strokeWidth:jI.LINE_STROKE_WIDTH,strokeDasharray:jI.LINE_DASH_PATTERN}),Z.jsx("line",{x1:c.x,y1:I.y,x2:c.x,y2:c.y,stroke:F0.OFFSET_LINE,strokeWidth:jI.LINE_STROKE_WIDTH,strokeDasharray:jI.LINE_DASH_PATTERN}),s.type==="component"||s.type==="board"?Z.jsx("circle",{cx:c.x,cy:c.y,r:jI.COMPONENT_MARKER_RADIUS,fill:F0.COMPONENT_MARKER_FILL,stroke:F0.COMPONENT_MARKER_STROKE,strokeWidth:1}):Z.jsxs(Z.Fragment,{children:[Z.jsx("line",{x1:c.x-jI.ANCHOR_MARKER_SIZE,y1:c.y,x2:c.x+jI.ANCHOR_MARKER_SIZE,y2:c.y,stroke:F0.OFFSET_LINE,strokeWidth:jI.ANCHOR_MARKER_STROKE_WIDTH}),Z.jsx("line",{x1:c.x,y1:c.y-jI.ANCHOR_MARKER_SIZE,x2:c.x,y2:c.y+jI.ANCHOR_MARKER_SIZE,stroke:F0.OFFSET_LINE,strokeWidth:jI.ANCHOR_MARKER_STROKE_WIDTH})]}),f&&Z.jsx("foreignObject",{x:Math.min(I.x,c.x),y:I.y+u,width:Math.abs(c.x-I.x),height:20,style:{overflow:"visible"},children:Z.jsx("div",{style:{...n,textAlign:"center"},children:w})}),m&&Z.jsx("foreignObject",{x:c.x+d,y:Math.min(I.y,c.y),width:jI.Y_LABEL_MIN_WIDTH,height:Math.abs(c.y-I.y),style:{overflow:"visible"},children:Z.jsx("div",{style:{...n,display:"flex",alignItems:"center",justifyContent:h?"flex-start":"flex-end",whiteSpace:"nowrap",padding:"0 4px",height:"100%"},children:D})})]},s.id)}),Array.from(o.entries()).map(([s,r])=>Z.jsxs("g",{children:[Z.jsx("line",{x1:r.x-jI.ANCHOR_MARKER_SIZE,y1:r.y,x2:r.x+jI.ANCHOR_MARKER_SIZE,y2:r.y,stroke:F0.OFFSET_LINE,strokeWidth:jI.ANCHOR_MARKER_STROKE_WIDTH}),Z.jsx("line",{x1:r.x,y1:r.y-jI.ANCHOR_MARKER_SIZE,x2:r.x,y2:r.y+jI.ANCHOR_MARKER_SIZE,stroke:F0.OFFSET_LINE,strokeWidth:jI.ANCHOR_MARKER_STROKE_WIDTH})]},`anchor-${s}`))]})})},k5e=({elements:e,highlightedPrimitives:A,transform:t,containerWidth:i,containerHeight:n})=>{const o=e.filter(h=>vpA(h)),s=e.filter(h=>V_(h)),r=e.filter(h=>Fgt(h)),a=A.map(h=>V_(h._parent_pcb_component)?h._parent_pcb_component.pcb_component_id:V_(h._element)?h._element.pcb_component_id:null).filter(h=>!!h),g=new Set;if(a.forEach(h=>{const u=s.find(d=>d.pcb_component_id===h);u?.pcb_group_id&&g.add(u.pcb_group_id)}),!tC(h=>h.is_showing_group_anchor_offsets)&&a.length===0)return null;const c=s.map(h=>{const u=h.positioned_relative_to_pcb_board_id;if(!u)return null;const d=o.find(f=>f.pcb_board_id===u);return d?{component:h,board:d,type:"component"}:null}).filter(h=>!!h),l=r.map(h=>{const u=h.positioned_relative_to_pcb_board_id;if(!u||!h.center)return null;const d=o.find(f=>f.pcb_board_id===u);return d?{group:h,board:d,type:"group"}:null}).filter(h=>!!h),B=[...c,...l];if(B.length===0)return null;const C=a.length===0,E=B.filter(h=>h.type==="component"?C||a.includes(h.component.pcb_component_id):C||g.has(h.group.pcb_group_id));if(E.length===0)return null;const Q=E.map(h=>h.type==="component"?{id:`${h.board.pcb_board_id}-${h.component.pcb_component_id}-${h.type}`,anchor:h.board.center,anchor_id:h.board.pcb_board_id,target:h.component.center,type:"component",display_offset_x:h.component.display_offset_x,display_offset_y:h.component.display_offset_y}:{id:`${h.board.pcb_board_id}-${h.group.pcb_group_id}-${h.type}`,anchor:h.board.center,anchor_id:h.board.pcb_board_id,target:{x:h.group.anchor_position?.x??h.group.center.x,y:h.group.anchor_position?.y??h.group.center.y},type:"group",display_offset_x:h.group.display_offset_x,display_offset_y:h.group.display_offset_y}).filter(h=>!!h);return Z.jsx(LpA,{targets:Q,transform:t,containerWidth:i,containerHeight:n})},G5e=({elements:e,highlightedPrimitives:A,transform:t,containerWidth:i,containerHeight:n})=>{const o=e.filter(h=>Fgt(h)),s=e.filter(h=>V_(h)),r=A.map(h=>V_(h._parent_pcb_component)?h._parent_pcb_component.pcb_component_id:V_(h._element)?h._element.pcb_component_id:null).filter(h=>!!h),a=(h,u)=>{if(u.has(h))return;u.add(h);const d=o.find(f=>f.pcb_group_id===h);d?.position_mode==="relative_to_group_anchor"&&d.positioned_relative_to_pcb_group_id&&a(d.positioned_relative_to_pcb_group_id,u)},g=new Set;if(r.forEach(h=>{const u=s.find(d=>d.pcb_component_id===h);u&&(u.position_mode==="relative_to_group_anchor"&&u.positioned_relative_to_pcb_group_id&&a(u.positioned_relative_to_pcb_group_id,g),u.pcb_group_id&&a(u.pcb_group_id,g))}),!tC(h=>h.is_showing_group_anchor_offsets)&&r.length===0)return null;const c=s.map(h=>{if(h.position_mode==="relative_to_group_anchor"&&h.positioned_relative_to_pcb_group_id){const u=o.find(d=>d.pcb_group_id===h.positioned_relative_to_pcb_group_id);return u&&u.anchor_position?{component:h,parentGroup:u,type:"component"}:null}if(h.pcb_group_id){const u=o.find(d=>d.pcb_group_id===h.pcb_group_id);return u&&u.anchor_position?{component:h,parentGroup:u,type:"component"}:null}return null}).filter(h=>!!h),l=o.map(h=>{if(h.position_mode==="relative_to_group_anchor"&&h.positioned_relative_to_pcb_group_id){const u=o.find(d=>d.pcb_group_id===h.positioned_relative_to_pcb_group_id);if(u&&u.anchor_position&&h.anchor_position)return{group:h,parentGroup:u,type:"group"}}return null}).filter(h=>!!h),B=[...c,...l];if(B.length===0)return null;const C=r.length===0,E=B.filter(h=>h.type==="component"?C||r.includes(h.component.pcb_component_id):C||g.has(h.group.pcb_group_id)||g.has(h.parentGroup.pcb_group_id));if(E.length===0)return null;const Q=E.map(h=>{const u=h.parentGroup.anchor_position;return u?h.type==="component"?h.component.center?{id:`${h.parentGroup.pcb_group_id}-${h.component.pcb_component_id}-${h.type}`,anchor:u,anchor_id:h.parentGroup.pcb_group_id,target:h.component.center,type:"component",display_offset_x:h.component.display_offset_x,display_offset_y:h.component.display_offset_y}:null:h.group.anchor_position?{id:`${h.parentGroup.pcb_group_id}-${h.group.pcb_group_id}-${h.type}`,anchor:u,anchor_id:h.parentGroup.pcb_group_id,target:h.group.anchor_position,type:"group",display_offset_x:h.group.display_offset_x,display_offset_y:h.group.display_offset_y}:null:null}).filter(h=>!!h);return Z.jsx(LpA,{targets:Q,transform:t,containerWidth:i,containerHeight:n})},F5e=(e,A)=>{const t=e.pcb_component_id,i=A.filter(n=>(n.type==="pcb_smtpad"||n.type==="pcb_plated_hole")&&n.pcb_component_id===t||n.type==="pcb_hole"&&n.pcb_component_id===t);return i.length===0?FpA([e]):FpA(i)},M5e=({elements:e,highlightedPrimitives:A,transform:t,containerWidth:i,containerHeight:n})=>{const o=new Map;for(const r of A)V_(r._parent_pcb_component)&&o.set(r._parent_pcb_component.pcb_component_id,r._parent_pcb_component),V_(r._element)&&o.set(r._element.pcb_component_id,r._element);if(o.size===0)return null;const s=[];for(const r of o.values()){const a=F5e(r,e);if(!a)continue;const g=r.positioned_relative_to_pcb_group_id??r.pcb_group_id,I=g?mb(e).pcb_group.get(g):null;s.push({component:r,bbox:a,group:I})}return s.length===0?null:Z.jsx("div",{style:{position:"absolute",left:0,top:0,width:i,height:n,overflow:"hidden",pointerEvents:"none",zIndex:dI.dimensionOverlay},children:Z.jsx("svg",{style:{position:"absolute",left:0,top:0,pointerEvents:"none"},width:i,height:n,children:s.map(({component:r,bbox:a,group:g})=>{const I=qi(t,{x:a.minX,y:a.maxY}),c=qi(t,{x:a.maxX,y:a.minY}),l={x:Math.min(I.x,c.x),y:Math.min(I.y,c.y),width:Math.abs(c.x-I.x),height:Math.abs(c.y-I.y)},B=r.center??{x:(a.minX+a.maxX)/2,y:(a.minY+a.maxY)/2},C=qi(t,B);return Z.jsxs("g",{children:[Z.jsx("rect",{x:l.x,y:l.y,width:l.width,height:l.height,fill:"none",stroke:"white",strokeWidth:1.5,strokeDasharray:"4,4"}),Z.jsx("line",{x1:C.x-6,y1:C.y,x2:C.x+6,y2:C.y,stroke:F0.COMPONENT_MARKER_STROKE,strokeWidth:1.5}),Z.jsx("line",{x1:C.x,y1:C.y-6,x2:C.x,y2:C.y+6,stroke:F0.COMPONENT_MARKER_STROKE,strokeWidth:1.5}),Z.jsx("circle",{cx:C.x,cy:C.y,r:jI.COMPONENT_MARKER_RADIUS,fill:F0.COMPONENT_MARKER_FILL,stroke:F0.COMPONENT_MARKER_STROKE,strokeWidth:1})]},r.pcb_component_id)})})})},R5e=({elements:e,highlightedPrimitives:A,transform:t,containerWidth:i,containerHeight:n})=>{const o=e.filter(B=>_5e(B)),s=e.filter(B=>vpA(B)),r=A.map(B=>vpA(B._element)?B._element.pcb_board_id:null).filter(B=>!!B);if(!tC(B=>B.is_showing_group_anchor_offsets)&&r.length===0)return null;const g=s.map(B=>{const C=B.pcb_panel_id,E=B.position_mode;if(!C||E!=="relative_to_panel_anchor")return null;const Q=o.find(h=>h.pcb_panel_id===C);return Q?{board:B,panel:Q,type:"board"}:null}).filter(B=>!!B);if(g.length===0)return null;const I=r.length===0,c=g.filter(B=>I||r.includes(B.board.pcb_board_id));if(c.length===0)return null;const l=c.map(B=>B.board.center?{id:`${B.panel.pcb_panel_id}-${B.board.pcb_board_id}-${B.type}`,anchor:B.panel.center,anchor_id:B.panel.pcb_panel_id,target:B.board.center,type:"board",display_offset_x:B.board.display_offset_x,display_offset_y:B.board.display_offset_y}:null).filter(B=>!!B);return Z.jsx(LpA,{targets:l,transform:t,containerWidth:i,containerHeight:n})},o9=e=>{if(e.length===0)return null;let A=e[0].x,t=e[0].y,i=e[0].x,n=e[0].y;for(const o of e)o.x<A&&(A=o.x),o.y<t&&(t=o.y),o.x>i&&(i=o.x),o.y>n&&(n=o.y);return{center:{x:(A+i)/2,y:(t+n)/2},width:i-A,height:n-t}},Mgt=(e,A)=>{if(A.length<3)return!1;let t=!1;for(let i=0,n=A.length-1;i<A.length;n=i++){const o=A[i].x,s=A[i].y,r=A[n].x,a=A[n].y;s>e.y!=a>e.y&&e.x<(r-o)*(e.y-s)/(a-s||Number.EPSILON)+o&&(t=!t)}return t},N5e=(e,A,t)=>{const i=[];for(const n of e){if(!n._element)continue;if("x1"in n&&n._element?.type==="pcb_trace"){const r=_h({x:A.x,y:A.y},{x:n.x1,y:n.y1},{x:n.x2,y:n.y2}),a=n.width||.5,g=Math.max(a*25,2)/t.a;r<g&&i.push(n);continue}if(n.pcb_drawing_type==="polygon"){const r=n.points.map(g=>({x:Ee.parse(g.x),y:Ee.parse(g.y)})),a=o9(r);if(!a||A.x<a.center.x-a.width/2||A.x>a.center.x+a.width/2||A.y<a.center.y-a.height/2||A.y>a.center.y+a.height/2)continue;Mgt(A,r)&&i.push(n);continue}if(n.pcb_drawing_type==="polygon_with_arcs"){const r=n.brep_shape.outer_ring.vertices.map(g=>({x:Ee.parse(g.x),y:Ee.parse(g.y)})),a=o9(r);if(!a||A.x<a.center.x-a.width/2||A.x>a.center.x+a.width/2||A.y<a.center.y-a.height/2||A.y>a.center.y+a.height/2)continue;Mgt(A,r)&&i.push(n);continue}if(!("x"in n&&"y"in n))continue;let o=0,s=0;if("w"in n&&"h"in n)o=n.w,s=n.h;else if("r"in n)o=n.r*2,s=n.r*2;else if("rX"in n&&"rY"in n)o=n.rX*2,s=n.rY*2;else continue;Math.abs(n.x-A.x)<o/2&&Math.abs(n.y-A.y)<s/2&&i.push(n)}return i},v5e=({elements:e,children:A,transform:t,primitives:i,onMouseHoverOverPrimitives:n})=>{const[o,s]=AA.useState([]),[r,a]=AA.useState({x:0,y:0}),[g,{width:I,height:c}]=$Y(),l=AA.useMemo(()=>{const C=[];for(const E of o){if(E._element?.type==="pcb_via"||E._element?.type==="pcb_component"||E?.layer==="drill")continue;let Q=null,h=0,u=0;if(E.pcb_drawing_type==="polygon"){const w=o9(E.points);if(!w)continue;Q=w.center,h=w.width,u=w.height}else if(E.pcb_drawing_type==="polygon_with_arcs"){const w=E.brep_shape.outer_ring.vertices.map(b=>({x:b.x,y:b.y})),D=o9(w);if(!D)continue;Q=D.center,h=D.width,u=D.height}else"x"in E&&"y"in E&&(Q={x:E.x,y:E.y},h="w"in E?E.w:"r"in E?E.r*2:"rX"in E&&"rY"in E?E.rX*2:0,u="h"in E?E.h:"r"in E?E.r*2:"rX"in E&&"rY"in E?E.rY*2:0);if(!Q)continue;const d=qi(t,Q),f={w:h*t.a,h:u*t.a},m=C.filter(w=>d.x===w.screen_x&&d.y===w.screen_y&&f.w===w.screen_w&&f.h===w.screen_h).length;C.push({...E,x:Q.x,y:Q.y,w:h,h:u,screen_x:d.x,screen_y:d.y,screen_w:f.w,screen_h:f.h,same_space_index:m})}return C},[o,t]),B=(C,E,Q,h)=>{a({x:C,y:E});const u=qi(fb(Q),{x:C,y:E}),d=N5e(h,u,Q);f5e(new Set(d.map(f=>f._pcb_drawing_object_id)),new Set(o.map(f=>f._pcb_drawing_object_id)))||(s(d),n(d))};return Z.jsxs("div",{ref:g,style:{position:"relative",width:"100%",height:"100%"},onMouseMove:C=>{if(t){const E=C.currentTarget.getBoundingClientRect(),Q=C.clientX-E.left,h=C.clientY-E.top;B(Q,h,t,i)}},onTouchStart:C=>{if(t){const E=C.touches[0],Q=C.currentTarget.getBoundingClientRect(),h=E.clientX-Q.left,u=E.clientY-Q.top;B(h,u,t,i)}},children:[A,Z.jsx(x5e,{elements:e,mousePos:r,highlightedPrimitives:l}),t&&Z.jsxs(Z.Fragment,{children:[Z.jsx(k5e,{elements:e,highlightedPrimitives:l,transform:t,containerWidth:I,containerHeight:c}),Z.jsx(G5e,{elements:e,highlightedPrimitives:l,transform:t,containerWidth:I,containerHeight:c}),Z.jsx(M5e,{elements:e,highlightedPrimitives:l,transform:t,containerWidth:I,containerHeight:c}),Z.jsx(R5e,{elements:e,highlightedPrimitives:l,transform:t,containerWidth:I,containerHeight:c})]})]})},Rgt=["rgb(255, 100, 100)","rgb(100, 255, 100)","rgb(100, 100, 255)","rgb(255, 255, 100)","rgb(255, 100, 255)","rgb(100, 255, 255)","rgb(255, 150, 100)","rgb(150, 100, 255)","rgb(100, 255, 150)","rgb(255, 100, 150)"],L5e=({children:e,transform:A=pb(),elements:t=[],hoveredComponentIds:i=[]})=>{const[n,{width:o,height:s}]=$Y(),r=AA.useRef(null),{is_showing_pcb_groups:a,pcb_group_view_mode:g,is_showing_group_anchor_offsets:I}=tC(c=>({is_showing_pcb_groups:c.is_showing_pcb_groups,pcb_group_view_mode:c.pcb_group_view_mode,is_showing_group_anchor_offsets:c.is_showing_group_anchor_offsets}));return AA.useEffect(()=>{const c=r.current;if(!c||!o||!s)return;c.width=o,c.height=s;const l=c.getContext("2d");if(!l||(l.clearRect(0,0,o,s),!a))return;const B=t.filter(w=>w.type==="pcb_group"),C=t.filter(w=>w.type==="pcb_component"),E=t.filter(w=>w.type==="source_group"),Q=new Map(E.map(w=>[w.source_group_id,w])),h=B.filter(w=>{if(g==="all")return!0;if(!w.source_group_id)return!1;const D=Q.get(w.source_group_id);return D?D.was_automatically_named!==!0:!1}),u=new Map;E.forEach(w=>{const D=w;if(D.parent_source_group_id){const b=u.get(D.parent_source_group_id)||[];b.push(w.source_group_id),u.set(D.parent_source_group_id,b)}});const d=w=>{const D=[],b=u.get(w)||[];for(const k of b)D.push(k),D.push(...d(k));return D},f=w=>{const D=E.find(b=>b.source_group_id===w);return D?.parent_source_group_id?1+f(D.parent_source_group_id):0},m=new Set;if(i.length>0)for(const w of C){if(!i.includes(w.pcb_component_id))continue;const D=w.positioned_relative_to_pcb_group_id??w.pcb_group_id;D&&m.add(D)}h.forEach((w,D)=>{let b=C.filter(HA=>HA.pcb_group_id===w.pcb_group_id);if(w.source_group_id){const HA=d(w.source_group_id),ZA=B.filter(xA=>xA.source_group_id&&HA.includes(xA.source_group_id));for(const xA of ZA){const wA=C.filter(UA=>UA.pcb_group_id===xA.pcb_group_id);b=[...b,...wA]}}let k,x,N,R,U=!1;if(w.center&&w.width&&w.height){U=!0;const HA=w.width/2,ZA=w.height/2;k=w.center.x-HA,N=w.center.x+HA,x=w.center.y-ZA,R=w.center.y+ZA}else if(b.length===0||(k=1/0,x=1/0,N=-1/0,R=-1/0,b.forEach(HA=>{if(HA.center&&typeof HA.width=="number"&&typeof HA.height=="number"){const ZA=HA.center.x-HA.width/2,xA=HA.center.x+HA.width/2,wA=HA.center.y+HA.height/2,UA=HA.center.y-HA.height/2;k=Math.min(k,ZA),N=Math.max(N,xA),x=Math.min(x,UA),R=Math.max(R,wA)}}),k===1/0||N===-1/0))return;const Y=w.source_group_id?f(w.source_group_id):0,H=w.source_group_id?d(w.source_group_id).length>0:!1;if(!U){const xA=1+(H?.5:0);k-=xA,N+=xA,x-=xA,R+=xA}const O=qi(A,{x:k,y:R}),W=qi(A,{x:N,y:R}),$=qi(A,{x:k,y:x}),iA=qi(A,{x:N,y:x}),rA=Rgt[D%Rgt.length];l.strokeStyle=rA,l.lineWidth=2;const tA=Math.max(4,Math.min(12,8*Math.abs(A.a))),oA=Math.max(2,Math.min(6,4*Math.abs(A.a))),QA=tA*(H?1.3:1),SA=oA;l.setLineDash([QA,SA]),l.beginPath(),l.moveTo(O.x,O.y),l.lineTo(W.x,W.y),l.lineTo(iA.x,iA.y),l.lineTo($.x,$.y),l.closePath(),l.stroke();const FA=Math.max(8,Math.min(12,10*Math.abs(A.a))),MA=Y==0||Y==1?0:Y*.11,KA=FA*(1-MA),hA=4,GA=w.name||`Group ${D+1}`;l.font=`${KA}px sans-serif`,l.setLineDash([]);const PA=l.measureText(GA).width+hA*2,JA=KA+hA*2,it=O.x-5,fA=O.y-5,tt=3;if(l.fillStyle="rgba(0, 0, 0, 0.8)",l.beginPath(),l.roundRect(it,fA-JA,PA,JA,tt),l.fill(),l.fillStyle=rA,l.textAlign="left",l.textBaseline="middle",l.fillText(GA,it+hA,fA-JA/2),I&&m.has(w.pcb_group_id)&&!!w.anchor_position&&w.anchor_position){const HA=Array.isArray(w.anchor_position)?{x:w.anchor_position[0]??0,y:w.anchor_position[1]??0}:{x:w.anchor_position.x,y:w.anchor_position.y},ZA=qi(A,HA);l.strokeStyle="white",l.lineWidth=1.5,l.setLineDash([]);const xA=Math.max(4,Math.min(8,6*Math.abs(A.a)));l.beginPath(),l.moveTo(ZA.x-xA,ZA.y),l.lineTo(ZA.x+xA,ZA.y),l.stroke(),l.beginPath(),l.moveTo(ZA.x,ZA.y-xA),l.lineTo(ZA.x,ZA.y+xA),l.stroke()}})},[t,A,o,s,a,g,I,i]),Z.jsxs("div",{ref:n,style:{position:"relative",width:"100%",height:"100%"},children:[e,Z.jsx("canvas",{ref:r,style:{position:"absolute",top:0,left:0,pointerEvents:"none",zIndex:dI.pcbGroupOverlay,display:a?"block":"none"}})]})},U5e=({transform:e,soup:A,children:t})=>{const i=tC(r=>r.is_showing_rats_nest),{netMap:n,idToNetMap:o}=AA.useMemo(()=>lgt(A||[]),[A]),s=AA.useMemo(()=>{if(!A||!i)return[];const r=l=>{const B=mb(A)[l.replace(/_\d+$/,"")].get(l);return B&&"x"in B&&"y"in B?{x:B.x,y:B.y}:null},a=(l,B)=>{const C=n[B]||[];let E=null,Q=1/0;return C.forEach(h=>{const u=r(h);if(u){const d=Math.sqrt((l.x-u.x)**2+(l.y-u.y)**2);d<Q&&d>0&&(Q=d,E=u)}}),E},g=mb(A).pcb_port.list(),I=mb(A).source_trace.list(),c=[];return g.forEach((l,B)=>{const C=o[l.pcb_port_id];let E=!1;for(const u of I)u.connected_source_port_ids.includes(l.source_port_id)&&u.connected_source_net_ids.length>0&&(E=!0);if(!C)return;const Q={x:l.x,y:l.y},h=a(Q,C);h&&c.push({key:`${l.pcb_port_id}-${B}`,startPoint:Q,endPoint:h,isInNet:E})}),c},[A,n,o,i]);return!A||!i?t:(e||(e=pb()),Z.jsxs("div",{style:{position:"relative"},children:[t,Z.jsx("svg",{style:{position:"absolute",left:0,top:0,width:"100%",height:"100%",pointerEvents:"none",opacity:.5,zIndex:dI.ratsNestOverlay},children:s.map(({key:r,startPoint:a,endPoint:g,isInNet:I})=>{const c=qi(e,a),l=qi(e,g);return Z.jsx("line",{x1:c.x,y1:c.y,x2:l.x,y2:l.y,stroke:"white",strokeWidth:"1",strokeDasharray:I?"6,6":void 0},r)})})]}))},H5e={version:"1.11.335"},j_=(e,A,t)=>{const i=tC(s=>s.is_mouse_over_container),n=AA.useRef(i),o=AA.useRef(A);AA.useEffect(()=>{n.current=i},[i]),AA.useEffect(()=>{o.current=A},[A]),AA.useEffect(()=>{if(!e)return;const s=r=>{const a=r.target;if(a.tagName==="INPUT"||a.tagName==="TEXTAREA"||a.isContentEditable)return;const g=e.split("+"),I=g.includes("ctrl"),c=g.includes("shift"),l=g.includes("alt"),B=g.includes("meta"),C=g[g.length-1],E=t?.current?t.current.contains(document.activeElement)||document.activeElement===t.current:!1;(n.current||E)&&(!I||r.ctrlKey)&&(!c||r.shiftKey)&&(!l||r.altKey)&&(!B||r.metaKey)&&r.key.toLowerCase()===C.toLowerCase()&&(r.preventDefault(),o.current())};return window.addEventListener("keydown",s),()=>{window.removeEventListener("keydown",s)}},[e])},Y5e=()=>{const[e,A]=AA.useState(!1);return AA.useEffect(()=>{const t=()=>{A(window.innerWidth<=768)};return t(),window.addEventListener("resize",t),()=>window.removeEventListener("resize",t)},[]),e},J5e=({name:e,selected:A,onClick:t})=>Z.jsxs("div",{className:Wv`
5469
5469
  margin-top: 2px;
5470
5470
  padding: 4px;
5471
5471
  padding-left: 8px;
@@ -5682,7 +5682,7 @@ test("${g} should solve problem correctly", () => {
5682
5682
  // Add more specific assertions based on expected output
5683
5683
  // expect(solver.netLabelPlacementSolver!.netLabelPlacements).toMatchInlineSnapshot()
5684
5684
  })
5685
- `,c=new Blob([I],{type:"text/plain"}),l=URL.createObjectURL(c),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 ${e.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(!t),title:`Download options for ${e.constructor.name}`,children:e.constructor.name}),t&&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"})]})]})},qgt=e=>e.activeSubSolver?[e,...qgt(e.activeSubSolver)]:[e],BWe=({solver:e})=>{const A=qgt(e);return Z.jsx("div",{className:"flex gap-1 items-center text-sm pt-1",children:A.map((t,i)=>Z.jsxs("div",{className:"flex items-center",children:[i>0&&Z.jsx("span",{className:"text-gray-400 mx-1",children:"→"}),Z.jsx(lWe,{solver:t})]},t.constructor.name))})},CWe=({solver:e,triggerRender:A,animationSpeed:t=25,onSolverStarted:i,onSolverCompleted:n})=>{const[o,s]=AA.useReducer(E=>!E,!1),r=AA.useRef(void 0),a=()=>{!e.solved&&!e.failed&&(e.step(),A())},g=()=>{!e.solved&&!e.failed&&(i&&i(e),e.solve(),A(),n&&n(e))},I=()=>{o?(r.current&&(clearInterval(r.current),r.current=void 0),s()):(s(),r.current=setInterval(()=>{if(e.solved||e.failed){r.current&&(clearInterval(r.current),r.current=void 0),s(),A(),n&&e.solved&&n(e);return}e.step(),A()},t))},c=()=>{const E=e;if(E.getCurrentPhase&&!e.solved&&!e.failed){const Q=E.getCurrentPhase();for(;E.getCurrentPhase()===Q&&!e.solved&&!e.failed;)e.step();A()}},l=()=>{if(e.solved||e.failed||o)return;const E=window.prompt("Step until which iteration?",`${e.iterations}`);if(E===null)return;const Q=Number(E);if(!Number.isFinite(Q)){window.alert("Please enter a valid number for the iteration");return}for(;e.iterations<Q&&!e.solved&&!e.failed;)e.step();A(),e.solved&&n&&n(e)};AA.useEffect(()=>()=>{r.current&&clearInterval(r.current)},[]),AA.useEffect(()=>{(e.solved||e.failed)&&o&&(r.current&&(clearInterval(r.current),r.current=void 0),s())},[e.solved,e.failed,o]);const B=e.getCurrentPhase!==void 0,C=B?e.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(BWe,{solver:e})}),Z.jsxs("div",{className:"flex gap-2 items-center flex-wrap",children:[Z.jsx("button",{onClick:a,disabled:e.solved||e.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:e.solved||e.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:I,disabled:e.solved||e.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:e.solved||e.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:c,disabled:e.solved||e.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: ",e.iterations]}),e.timeToSolve!==void 0&&Z.jsxs("div",{className:"text-sm text-gray-600",children:["Time: ",(e.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})]}),e.solved&&Z.jsx("div",{className:"px-2 py-1 bg-green-100 text-green-800 rounded text-sm",children:"Solved"}),e.failed&&Z.jsx("div",{className:"px-2 py-1 bg-red-100 text-red-800 rounded text-sm",children:"Failed"})]}),e.error&&Z.jsxs("div",{className:"text-red-600 text-sm",children:["Error: ",e.error]})]})},QWe=(e,A,t)=>{const i=e.currentPipelineStepIndex;return A<i?"Completed":A===i&&e.activeSubSolver?e.activeSubSolver.failed?"Failed":"In Progress":"Not Started"},EWe=(e,A)=>{const i=e.pipelineDef[A].solverName,n=QWe(e,A),o=e[i],s=e.firstIterationOfPhase?.[i]??null,r=e.iterations;let a=0;if(n==="Completed"){const l=e.pipelineDef[A+1],B=l?e.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=e.timeSpentOnPhase?.[i]??0;let I=0;n==="Completed"?I=1:n==="In Progress"&&o&&(I=o.progress??0);const c=o?.stats??null;return{index:A,name:i,status:n,firstIteration:s,iterations:a,progress:I,timeSpent:g,stats:c&&Object.keys(c).length>0?c:null,solverInstance:o??null}},hWe=({status:e})=>{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[e]}`,children:e})},uWe=({progress:e})=>{if(e===0)return null;const A=Math.round(e*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,"%"]})]})},dWe=e=>Object.entries(e).map(([A,t])=>`${A}: ${t}`).join(", "),pWe=({stats:e})=>{if(!e||Object.keys(e).length===0)return Z.jsx("span",{children:"-"});const A=Object.entries(e),t=dWe(e);return Z.jsxs("details",{className:"cursor-pointer",children:[Z.jsx("summary",{className:"whitespace-nowrap overflow-hidden text-ellipsis max-w-[200px]",children:t}),Z.jsx("div",{className:"mt-1 text-xs",children:A.map(([i,n])=>Z.jsxs("div",{children:[i,": ",String(n)]},i))})]})},qpA=e=>{if(e===null||typeof e!="object")return e;if(Array.isArray(e))return e.map(qpA);const A={};for(const[t,i]of Object.entries(e))t.startsWith("_")||(A[t]=qpA(i));return A},fWe=(e,A)=>{try{if(typeof e.getConstructorParams!="function"){alert(`getConstructorParams() is not implemented for ${A}`);return}const t=qpA(e.getConstructorParams()),i=new Blob([JSON.stringify(t,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(t){alert(`Error downloading input for ${A}: ${t instanceof Error?t.message:String(t)}`)}},yWe=({solver:e,onStepUntilPhase:A,onDownloadInput:t})=>{const i=e.pipelineDef.map((r,a)=>EWe(e,a)),n=r=>{A?.(r)},o=r=>{r.solverInstance&&(t?t(r.solverInstance,r.name):fWe(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"||e.solved||e.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(hWe,{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(uWe,{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(pWe,{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))})]})})]})},mWe=class extends en.Component{constructor(e){super(e),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(e){console.error("InteractiveGraphics render error:",e)}render(){return this.state.hasError?this.props.fallback:this.props.children}};function wWe({graphics:e}){const A=e.points??[],t=e.lines??[],i=e.rects??[],n=e.circles??[],o=e.texts??[];let s=Number.POSITIVE_INFINITY,r=Number.POSITIVE_INFINITY,a=Number.NEGATIVE_INFINITY,g=Number.NEGATIVE_INFINITY;const I=(Q,h)=>{typeof Q=="number"&&(Q<s&&(s=Q),Q>a&&(a=Q)),typeof h=="number"&&(h<r&&(r=h),h>g&&(g=h))};for(const Q of A)I(Q.x,Q.y);for(const Q of t){const h=Q.points??[];for(const u of h)I(u.x,u.y)}for(const Q of i){const h=Q.x??0,u=Q.y??0,d=Q.width??0,f=Q.height??0;I(h,u),I(h+d,u+f)}for(const Q of n){const h=Q.x??0,u=Q.y??0,d=Q.radius??1;I(h-d,u-d),I(h+d,u+d)}for(const Q of o)I(Q.x,Q.y);(!isFinite(s)||!isFinite(r)||!isFinite(a)||!isFinite(g))&&(s=-20,r=-20,a=20,g=20);const c=10,l=s-c,B=r-c,C=Math.max(1,a-s+2*c),E=Math.max(1,g-r+2*c);return Z.jsxs("svg",{className:"w-full h-[400px] bg-white",viewBox:`${l} ${B} ${C} ${E}`,role:"img","aria-label":"Graphics fallback",children:[i.map((Q,h)=>Z.jsx("rect",{x:Q.x??0,y:Q.y??0,width:Q.width??0,height:Q.height??0,fill:"none",stroke:Q.strokeColor??"black",strokeWidth:Q.strokeWidth??1},`rect-${h}`)),t.map((Q,h)=>Z.jsx("polyline",{fill:"none",stroke:Q.strokeColor??"black",strokeWidth:Q.strokeWidth??1,points:(Q.points??[]).map(u=>`${u.x??0},${u.y??0}`).join(" ")},`line-${h}`)),n.map((Q,h)=>Z.jsx("circle",{cx:Q.x??0,cy:Q.y??0,r:Q.radius??1.5,fill:Q.fillColor??"none",stroke:Q.strokeColor??"black",strokeWidth:Q.strokeWidth??1},`circle-${h}`)),A.map((Q,h)=>Z.jsx("circle",{cx:Q.x??0,cy:Q.y??0,r:Q.radius??1.5,fill:Q.color??"black"},`point-${h}`)),o.map((Q,h)=>Z.jsx("text",{x:Q.x??0,y:Q.y??0,fontSize:Q.fontSize??10,fill:Q.color??"black",children:Q.text??""},`text-${h}`))]})}var DWe=({solver:e,animationSpeed:A=25,onSolverStarted:t,onSolverCompleted:i})=>{const[n,o]=AA.useReducer(I=>I+1,0),s=AA.useMemo(()=>{try{return e.visualize()||{points:[],lines:[],rects:[],circles:[]}}catch(I){return console.error("Visualization error:",I),{points:[],lines:[],rects:[],circles:[]}}},[e,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 I=document.createElement("script");I.src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4",document.head.appendChild(I)}},[]);const a=e.pipelineDef!==void 0,g=I=>{const c=e;if(!e.solved&&!e.failed){for(;!e.solved&&!e.failed&&c.currentPipelineStepIndex<=c.pipelineDef.findIndex(l=>l.solverName===I);)e.step();o()}};return Z.jsxs("div",{children:[Z.jsx(CWe,{solver:e,triggerRender:o,animationSpeed:A,onSolverStarted:t,onSolverCompleted:i}),r?Z.jsx("div",{className:"p-4 text-gray-500",children:"No Graphics Yet"}):Z.jsx(mWe,{fallback:Z.jsx(wWe,{graphics:s}),children:Z.jsx(cWe,{graphics:s})}),a&&Z.jsx(yWe,{solver:e,onStepUntilPhase:g})]})};const SWe=()=>{AA.useEffect(()=>{const e="tailwind-cdn-script";if(document.getElementById(e)||window.tailwind)return;const A=document.createElement("div");A.className="hidden",document.body.appendChild(A);const t=window.getComputedStyle(A).display==="none";if(document.body.removeChild(A),t)return;const i=document.createElement("script");i.id=e,i.src="https://cdn.tailwindcss.com",document.head.appendChild(i)},[])},bWe=e=>e.toLowerCase().includes("pack")?DGe:e.toLowerCase().includes("rout")?GGe:EGe,xWe=({solverEvents:e=[]})=>{const[A,t]=AA.useState(null);SWe();const i=AA.useMemo(()=>{const r=new Map;for(const a of e){const g=`${a.componentName}-${a.solverName}`;r.set(g,a)}return r},[e]),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=irA[o.solverName];if(!r)return{instance:null,error:`Solver class "${o.solverName}" not found in SOLVERS registry. Available: ${Object.keys(irA).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 e.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:()=>t(r),children:(()=>{const I=bWe(a.solverName);return Z.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2",children:[Z.jsx(I,{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(dD,{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(DWe,{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"})})})]})},Ogt=({errorMessage:e,errorStack:A,circuitJsonErrors:t})=>{AA.useEffect(()=>{if(e){const i=new Error(e);A&&(i.stack=A);try{UK.captureException(i)}catch{}}},[e,A]),AA.useEffect(()=>{if(t&&t.length>0)for(const i of t){const n=new Error(i.message||"Circuit JSON Error");i.stack&&(n.stack=i.stack);try{UK.captureException(n,{error_type:i.type})}catch{}}},[t])},Wgt="0.0.1601",_We={version:Wgt},OpA={BASE_URL:"/",DEV:!1,MODE:"production",PROD:!0,SSR:!1},WpA=new Map,I9=e=>{const A=WpA.get(e);return A?Object.fromEntries(Object.entries(A.stores).map(([t,i])=>[t,i.getState()])):{}},kWe=(e,A,t)=>{if(e===void 0)return{type:"untracked",connection:A.connect(t)};const i=WpA.get(t.name);if(i)return{type:"tracked",store:e,...i};const n={connection:A.connect(t),stores:{}};return WpA.set(t.name,n),{type:"tracked",store:e,...n}},Zgt=(e,A={})=>(t,i,n)=>{const{enabled:o,anonymousActionType:s,store:r,...a}=A;let g;try{g=(o??(OpA?"production":void 0)!=="production")&&window.__REDUX_DEVTOOLS_EXTENSION__}catch{}if(!g)return(OpA?"production":void 0)!=="production"&&o&&console.warn("[zustand devtools middleware] Please install/enable Redux devtools extension"),e(t,i,n);const{connection:I,...c}=kWe(r,g,a);let l=!0;n.setState=(E,Q,h)=>{const u=t(E,Q);if(!l)return u;const d=h===void 0?{type:s||"anonymous"}:typeof h=="string"?{type:h}:h;return r===void 0?(I?.send(d,i()),u):(I?.send({...d,type:`${r}/${d.type}`},{...I9(a.name),[r]:n.getState()}),u)};const B=(...E)=>{const Q=l;l=!1,t(...E),l=Q},C=e(n.setState,i,n);if(c.type==="untracked"?I?.init(C):(c.stores[c.store]=n,I?.init(Object.fromEntries(Object.entries(c.stores).map(([E,Q])=>[E,E===c.store?C:Q.getState()])))),n.dispatchFromDevtools&&typeof n.dispatch=="function"){let E=!1;const Q=n.dispatch;n.dispatch=(...h)=>{(OpA?"production":void 0)!=="production"&&h[0].type==="__setState"&&!E&&(console.warn('[zustand devtools middleware] "__setState" action type is reserved to set state from the devtools. Avoid using it.'),E=!0),Q(...h)}}return I.subscribe(E=>{var Q;switch(E.type){case"ACTION":if(typeof E.payload!="string"){console.error("[zustand devtools middleware] Unsupported action format");return}return ZpA(E.payload,h=>{if(h.type==="__setState"){if(r===void 0){B(h.state);return}Object.keys(h.state).length!==1&&console.error(`
5685
+ `,c=new Blob([I],{type:"text/plain"}),l=URL.createObjectURL(c),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 ${e.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(!t),title:`Download options for ${e.constructor.name}`,children:e.constructor.name}),t&&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"})]})]})},qgt=e=>e.activeSubSolver?[e,...qgt(e.activeSubSolver)]:[e],BWe=({solver:e})=>{const A=qgt(e);return Z.jsx("div",{className:"flex gap-1 items-center text-sm pt-1",children:A.map((t,i)=>Z.jsxs("div",{className:"flex items-center",children:[i>0&&Z.jsx("span",{className:"text-gray-400 mx-1",children:"→"}),Z.jsx(lWe,{solver:t})]},t.constructor.name))})},CWe=({solver:e,triggerRender:A,animationSpeed:t=25,onSolverStarted:i,onSolverCompleted:n})=>{const[o,s]=AA.useReducer(E=>!E,!1),r=AA.useRef(void 0),a=()=>{!e.solved&&!e.failed&&(e.step(),A())},g=()=>{!e.solved&&!e.failed&&(i&&i(e),e.solve(),A(),n&&n(e))},I=()=>{o?(r.current&&(clearInterval(r.current),r.current=void 0),s()):(s(),r.current=setInterval(()=>{if(e.solved||e.failed){r.current&&(clearInterval(r.current),r.current=void 0),s(),A(),n&&e.solved&&n(e);return}e.step(),A()},t))},c=()=>{const E=e;if(E.getCurrentPhase&&!e.solved&&!e.failed){const Q=E.getCurrentPhase();for(;E.getCurrentPhase()===Q&&!e.solved&&!e.failed;)e.step();A()}},l=()=>{if(e.solved||e.failed||o)return;const E=window.prompt("Step until which iteration?",`${e.iterations}`);if(E===null)return;const Q=Number(E);if(!Number.isFinite(Q)){window.alert("Please enter a valid number for the iteration");return}for(;e.iterations<Q&&!e.solved&&!e.failed;)e.step();A(),e.solved&&n&&n(e)};AA.useEffect(()=>()=>{r.current&&clearInterval(r.current)},[]),AA.useEffect(()=>{(e.solved||e.failed)&&o&&(r.current&&(clearInterval(r.current),r.current=void 0),s())},[e.solved,e.failed,o]);const B=e.getCurrentPhase!==void 0,C=B?e.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(BWe,{solver:e})}),Z.jsxs("div",{className:"flex gap-2 items-center flex-wrap",children:[Z.jsx("button",{onClick:a,disabled:e.solved||e.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:e.solved||e.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:I,disabled:e.solved||e.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:e.solved||e.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:c,disabled:e.solved||e.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: ",e.iterations]}),e.timeToSolve!==void 0&&Z.jsxs("div",{className:"text-sm text-gray-600",children:["Time: ",(e.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})]}),e.solved&&Z.jsx("div",{className:"px-2 py-1 bg-green-100 text-green-800 rounded text-sm",children:"Solved"}),e.failed&&Z.jsx("div",{className:"px-2 py-1 bg-red-100 text-red-800 rounded text-sm",children:"Failed"})]}),e.error&&Z.jsxs("div",{className:"text-red-600 text-sm",children:["Error: ",e.error]})]})},QWe=(e,A,t)=>{const i=e.currentPipelineStepIndex;return A<i?"Completed":A===i&&e.activeSubSolver?e.activeSubSolver.failed?"Failed":"In Progress":"Not Started"},EWe=(e,A)=>{const i=e.pipelineDef[A].solverName,n=QWe(e,A),o=e[i],s=e.firstIterationOfPhase?.[i]??null,r=e.iterations;let a=0;if(n==="Completed"){const l=e.pipelineDef[A+1],B=l?e.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=e.timeSpentOnPhase?.[i]??0;let I=0;n==="Completed"?I=1:n==="In Progress"&&o&&(I=o.progress??0);const c=o?.stats??null;return{index:A,name:i,status:n,firstIteration:s,iterations:a,progress:I,timeSpent:g,stats:c&&Object.keys(c).length>0?c:null,solverInstance:o??null}},hWe=({status:e})=>{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[e]}`,children:e})},uWe=({progress:e})=>{if(e===0)return null;const A=Math.round(e*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,"%"]})]})},dWe=e=>Object.entries(e).map(([A,t])=>`${A}: ${t}`).join(", "),pWe=({stats:e})=>{if(!e||Object.keys(e).length===0)return Z.jsx("span",{children:"-"});const A=Object.entries(e),t=dWe(e);return Z.jsxs("details",{className:"cursor-pointer",children:[Z.jsx("summary",{className:"whitespace-nowrap overflow-hidden text-ellipsis max-w-[200px]",children:t}),Z.jsx("div",{className:"mt-1 text-xs",children:A.map(([i,n])=>Z.jsxs("div",{children:[i,": ",String(n)]},i))})]})},qpA=e=>{if(e===null||typeof e!="object")return e;if(Array.isArray(e))return e.map(qpA);const A={};for(const[t,i]of Object.entries(e))t.startsWith("_")||(A[t]=qpA(i));return A},fWe=(e,A)=>{try{if(typeof e.getConstructorParams!="function"){alert(`getConstructorParams() is not implemented for ${A}`);return}const t=qpA(e.getConstructorParams()),i=new Blob([JSON.stringify(t,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(t){alert(`Error downloading input for ${A}: ${t instanceof Error?t.message:String(t)}`)}},yWe=({solver:e,onStepUntilPhase:A,onDownloadInput:t})=>{const i=e.pipelineDef.map((r,a)=>EWe(e,a)),n=r=>{A?.(r)},o=r=>{r.solverInstance&&(t?t(r.solverInstance,r.name):fWe(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"||e.solved||e.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(hWe,{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(uWe,{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(pWe,{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))})]})})]})},mWe=class extends en.Component{constructor(e){super(e),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(e){console.error("InteractiveGraphics render error:",e)}render(){return this.state.hasError?this.props.fallback:this.props.children}};function wWe({graphics:e}){const A=e.points??[],t=e.lines??[],i=e.rects??[],n=e.circles??[],o=e.texts??[];let s=Number.POSITIVE_INFINITY,r=Number.POSITIVE_INFINITY,a=Number.NEGATIVE_INFINITY,g=Number.NEGATIVE_INFINITY;const I=(Q,h)=>{typeof Q=="number"&&(Q<s&&(s=Q),Q>a&&(a=Q)),typeof h=="number"&&(h<r&&(r=h),h>g&&(g=h))};for(const Q of A)I(Q.x,Q.y);for(const Q of t){const h=Q.points??[];for(const u of h)I(u.x,u.y)}for(const Q of i){const h=Q.x??0,u=Q.y??0,d=Q.width??0,f=Q.height??0;I(h,u),I(h+d,u+f)}for(const Q of n){const h=Q.x??0,u=Q.y??0,d=Q.radius??1;I(h-d,u-d),I(h+d,u+d)}for(const Q of o)I(Q.x,Q.y);(!isFinite(s)||!isFinite(r)||!isFinite(a)||!isFinite(g))&&(s=-20,r=-20,a=20,g=20);const c=10,l=s-c,B=r-c,C=Math.max(1,a-s+2*c),E=Math.max(1,g-r+2*c);return Z.jsxs("svg",{className:"w-full h-[400px] bg-white",viewBox:`${l} ${B} ${C} ${E}`,role:"img","aria-label":"Graphics fallback",children:[i.map((Q,h)=>Z.jsx("rect",{x:Q.x??0,y:Q.y??0,width:Q.width??0,height:Q.height??0,fill:"none",stroke:Q.strokeColor??"black",strokeWidth:Q.strokeWidth??1},`rect-${h}`)),t.map((Q,h)=>Z.jsx("polyline",{fill:"none",stroke:Q.strokeColor??"black",strokeWidth:Q.strokeWidth??1,points:(Q.points??[]).map(u=>`${u.x??0},${u.y??0}`).join(" ")},`line-${h}`)),n.map((Q,h)=>Z.jsx("circle",{cx:Q.x??0,cy:Q.y??0,r:Q.radius??1.5,fill:Q.fillColor??"none",stroke:Q.strokeColor??"black",strokeWidth:Q.strokeWidth??1},`circle-${h}`)),A.map((Q,h)=>Z.jsx("circle",{cx:Q.x??0,cy:Q.y??0,r:Q.radius??1.5,fill:Q.color??"black"},`point-${h}`)),o.map((Q,h)=>Z.jsx("text",{x:Q.x??0,y:Q.y??0,fontSize:Q.fontSize??10,fill:Q.color??"black",children:Q.text??""},`text-${h}`))]})}var DWe=({solver:e,animationSpeed:A=25,onSolverStarted:t,onSolverCompleted:i})=>{const[n,o]=AA.useReducer(I=>I+1,0),s=AA.useMemo(()=>{try{return e.visualize()||{points:[],lines:[],rects:[],circles:[]}}catch(I){return console.error("Visualization error:",I),{points:[],lines:[],rects:[],circles:[]}}},[e,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 I=document.createElement("script");I.src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4",document.head.appendChild(I)}},[]);const a=e.pipelineDef!==void 0,g=I=>{const c=e;if(!e.solved&&!e.failed){for(;!e.solved&&!e.failed&&c.currentPipelineStepIndex<=c.pipelineDef.findIndex(l=>l.solverName===I);)e.step();o()}};return Z.jsxs("div",{children:[Z.jsx(CWe,{solver:e,triggerRender:o,animationSpeed:A,onSolverStarted:t,onSolverCompleted:i}),r?Z.jsx("div",{className:"p-4 text-gray-500",children:"No Graphics Yet"}):Z.jsx(mWe,{fallback:Z.jsx(wWe,{graphics:s}),children:Z.jsx(cWe,{graphics:s})}),a&&Z.jsx(yWe,{solver:e,onStepUntilPhase:g})]})};const SWe=()=>{AA.useEffect(()=>{const e="tailwind-cdn-script";if(document.getElementById(e)||window.tailwind)return;const A=document.createElement("div");A.className="hidden",document.body.appendChild(A);const t=window.getComputedStyle(A).display==="none";if(document.body.removeChild(A),t)return;const i=document.createElement("script");i.id=e,i.src="https://cdn.tailwindcss.com",document.head.appendChild(i)},[])},bWe=e=>e.toLowerCase().includes("pack")?DGe:e.toLowerCase().includes("rout")?GGe:EGe,xWe=({solverEvents:e=[]})=>{const[A,t]=AA.useState(null);SWe();const i=AA.useMemo(()=>{const r=new Map;for(const a of e){const g=`${a.componentName}-${a.solverName}`;r.set(g,a)}return r},[e]),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=irA[o.solverName];if(!r)return{instance:null,error:`Solver class "${o.solverName}" not found in SOLVERS registry. Available: ${Object.keys(irA).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 e.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:()=>t(r),children:(()=>{const I=bWe(a.solverName);return Z.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2",children:[Z.jsx(I,{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(dD,{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(DWe,{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"})})})]})},Ogt=({errorMessage:e,errorStack:A,circuitJsonErrors:t})=>{AA.useEffect(()=>{if(e){const i=new Error(e);A&&(i.stack=A);try{UK.captureException(i)}catch{}}},[e,A]),AA.useEffect(()=>{if(t&&t.length>0)for(const i of t){const n=new Error(i.message||"Circuit JSON Error");i.stack&&(n.stack=i.stack);try{UK.captureException(n,{error_type:i.type})}catch{}}},[t])},Wgt="0.0.1603",_We={version:Wgt},OpA={BASE_URL:"/",DEV:!1,MODE:"production",PROD:!0,SSR:!1},WpA=new Map,I9=e=>{const A=WpA.get(e);return A?Object.fromEntries(Object.entries(A.stores).map(([t,i])=>[t,i.getState()])):{}},kWe=(e,A,t)=>{if(e===void 0)return{type:"untracked",connection:A.connect(t)};const i=WpA.get(t.name);if(i)return{type:"tracked",store:e,...i};const n={connection:A.connect(t),stores:{}};return WpA.set(t.name,n),{type:"tracked",store:e,...n}},Zgt=(e,A={})=>(t,i,n)=>{const{enabled:o,anonymousActionType:s,store:r,...a}=A;let g;try{g=(o??(OpA?"production":void 0)!=="production")&&window.__REDUX_DEVTOOLS_EXTENSION__}catch{}if(!g)return(OpA?"production":void 0)!=="production"&&o&&console.warn("[zustand devtools middleware] Please install/enable Redux devtools extension"),e(t,i,n);const{connection:I,...c}=kWe(r,g,a);let l=!0;n.setState=(E,Q,h)=>{const u=t(E,Q);if(!l)return u;const d=h===void 0?{type:s||"anonymous"}:typeof h=="string"?{type:h}:h;return r===void 0?(I?.send(d,i()),u):(I?.send({...d,type:`${r}/${d.type}`},{...I9(a.name),[r]:n.getState()}),u)};const B=(...E)=>{const Q=l;l=!1,t(...E),l=Q},C=e(n.setState,i,n);if(c.type==="untracked"?I?.init(C):(c.stores[c.store]=n,I?.init(Object.fromEntries(Object.entries(c.stores).map(([E,Q])=>[E,E===c.store?C:Q.getState()])))),n.dispatchFromDevtools&&typeof n.dispatch=="function"){let E=!1;const Q=n.dispatch;n.dispatch=(...h)=>{(OpA?"production":void 0)!=="production"&&h[0].type==="__setState"&&!E&&(console.warn('[zustand devtools middleware] "__setState" action type is reserved to set state from the devtools. Avoid using it.'),E=!0),Q(...h)}}return I.subscribe(E=>{var Q;switch(E.type){case"ACTION":if(typeof E.payload!="string"){console.error("[zustand devtools middleware] Unsupported action format");return}return ZpA(E.payload,h=>{if(h.type==="__setState"){if(r===void 0){B(h.state);return}Object.keys(h.state).length!==1&&console.error(`
5686
5686
  [zustand devtools middleware] Unsupported __setState action format.
5687
5687
  When using 'store' option in devtools(), the 'state' should have only one key, which is a value of 'store' that was passed in devtools(),
5688
5688
  and value of this only key should be a state object. Example: { "type": "__setState", "state": { "abc123Store": { "foo": "bar" } } }
@@ -5469,7 +5469,7 @@ $1`).replace(/>(\s*)(?=<!--\s*\/)/g,"> ")}}});function xct(e,A,t){if(!A||!t)retu
5469
5469
  transition: opacity 0.2s;
5470
5470
  margin-bottom: 10px;
5471
5471
  color: red;
5472
- `,EZe=({children:e,transform:A=_b(),elements:t})=>{const i=V.useRef(null),{isShowingDRCErrors:n,hoveredErrorId:o}=eC(g=>({isShowingDRCErrors:g.is_showing_drc_errors,hoveredErrorId:g.hovered_error_id}));if(!t)return W.jsx("div",{style:{position:"relative"},ref:i,children:e});const s=t.filter(g=>g.type==="pcb_trace_error"),r=t.filter(g=>g.type==="pcb_trace_error"&&g.message?.includes("Multiple components found with name")),a=new Map;return t.forEach(g=>{g.type==="pcb_port"&&a.set(g.pcb_port_id,g)}),W.jsxs("div",{style:{position:"relative"},ref:i,children:[e,s.map((g,c)=>{const{pcb_port_ids:I,pcb_trace_id:l}=g,B=I?.[0]?a.get(I[0]):void 0,C=I?.[1]?a.get(I[1]):void 0,Q=t?Gb(t).pcb_trace.get(l):void 0,h=g.pcb_trace_error_id||`error_${c}_${g.error_type}_${g.message?.slice(0,20)}`,E=o===h;if(B&&C){const u=qi(A,{x:B.x,y:B.y}),d=qi(A,{x:C.x,y:C.y}),f=!(isNaN(u.x)||isNaN(u.y)||isNaN(d.x)||isNaN(d.y)),m={x:(u.x+d.x)/2,y:(u.y+d.y)/2};if(isNaN(m.x)||isNaN(m.y))return null;const D=HfA(m,i);return W.jsxs(V.Fragment,{children:[W.jsx(QZe,{screenPort1:u,screenPort2:d,errorCenter:m,canLineBeDrawn:f,isHighlighted:E}),W.jsx("div",{style:{position:"absolute",left:m.x-15,top:m.y-15,width:30,height:30,zIndex:fc.errorOverlay+5,cursor:"pointer",borderRadius:"50%"},onMouseEnter:w=>{const S=w.currentTarget.nextElementSibling;if(S){const k=S.querySelector(".error-message");k&&(k.style.opacity="1")}},onMouseLeave:w=>{if(!E){const S=w.currentTarget.nextElementSibling;if(S){const k=S.querySelector(".error-message");k&&(k.style.opacity="0")}}}}),W.jsx("div",{style:{position:"absolute",zIndex:E?200:100,left:D.left,top:D.top,color:E?"#ff4444":"red",textAlign:"center",fontFamily:"sans-serif",fontSize:12,display:n||E?"flex":"none",flexDirection:"column",alignItems:"center",pointerEvents:"none",transform:D.transform},children:W.jsx("div",{className:`error-message ${YfA}`,style:{opacity:E?1:0,border:`1px solid ${E?"#ff4444":"red"}`},children:g.message})})]},h)}if(Q?.route&&(n||E)){const u=Q.route.map(D=>qi(A,{x:D.x,y:D.y}));if(u.some(D=>isNaN(D.x)||isNaN(D.y)))return null;const d=Math.floor(u.length/2),f=u[d],m=HfA(f,i);return W.jsxs(V.Fragment,{children:[W.jsx(hZe,{points:u,errorCenter:f,isHighlighted:E}),W.jsx("div",{style:{position:"absolute",left:f.x-15,top:f.y-15,width:30,height:30,zIndex:fc.errorOverlay+5,cursor:"pointer",borderRadius:"50%"},onMouseEnter:D=>{const w=D.currentTarget.nextElementSibling;if(w){const S=w.querySelector(".error-message");S&&(S.style.opacity="1")}},onMouseLeave:D=>{if(!E){const w=D.currentTarget.nextElementSibling;if(w){const S=w.querySelector(".error-message");S&&(S.style.opacity="0")}}}}),W.jsx("div",{style:{position:"absolute",zIndex:E?fc.errorOverlay+10:fc.errorOverlay+1,left:m.left,top:m.top,color:E?"#ff4444":"red",textAlign:"center",fontFamily:"sans-serif",fontSize:12,display:"flex",flexDirection:"column",alignItems:"center",pointerEvents:"none",transform:m.transform},children:W.jsx("div",{className:`error-message ${YfA}`,style:{opacity:E?1:0,border:`1px solid ${E?"#ff4444":"red"}`},children:g.message})})]},h)}return null}),r.map((g,c)=>{const I=g.component_name||g.message?.match(/name "([^"]+)"/)?.[1];if(!I)return null;const l=t?.filter(Q=>Q.type==="source_component"&&Q.name===I||Q.type==="pcb_component"&&t?.find(h=>h.type==="source_component"&&h.source_component_id===Q.source_component_id&&h.name===I))||[],B=g.pcb_trace_error_id||`error_${c}_${g.error_type}_${g.message?.slice(0,20)}`,C=o===B;return!C&&!n?null:l.map((Q,h)=>{let E={x:0,y:0};if(Q.type==="pcb_component")E=Q.center||{x:0,y:0};else if(Q.type==="source_component"){const k=t?.find(x=>x.type==="pcb_component"&&x.source_component_id===Q.source_component_id);k&&k.type==="pcb_component"&&(E=k.center||{x:0,y:0})}const u=qi(A,E);if(isNaN(u.x)||isNaN(u.y))return null;const d=Math.abs(A.a),w=Math.max(8,Math.min(30,.5*d)),S=HfA(u,i);return W.jsxs(V.Fragment,{children:[W.jsx("svg",{style:{position:"absolute",left:0,top:0,pointerEvents:"none",mixBlendMode:"difference",zIndex:fc.errorOverlay},width:"100%",height:"100%",children:C?W.jsx("polygon",{points:`${u.x},${u.y-w*1.25} ${u.x+w},${u.y} ${u.x},${u.y+w*1.25} ${u.x-w},${u.y}`,fill:"#ff4444"}):W.jsx("circle",{cx:u.x,cy:u.y,r:w,fill:"none",stroke:C?"#ff4444":"red",strokeWidth:C?Math.max(2,w*.15):Math.max(1,w*.1),opacity:1})}),W.jsx("div",{style:{position:"absolute",left:u.x-(w+10),top:u.y-(w+10),width:(w+10)*2,height:(w+10)*2,zIndex:fc.errorOverlay+5,cursor:"pointer",borderRadius:"50%"},onMouseEnter:k=>{const x=k.currentTarget.nextElementSibling;if(x){const N=x.querySelector(".error-message");N&&(N.style.opacity="1")}},onMouseLeave:k=>{if(!C){const x=k.currentTarget.nextElementSibling;if(x){const N=x.querySelector(".error-message");N&&(N.style.opacity="0")}}}}),W.jsx("div",{style:{position:"absolute",zIndex:C?fc.errorOverlay+20:fc.errorOverlay+10,left:S.left,top:S.top,color:C?"#ff4444":"red",textAlign:"center",fontFamily:"sans-serif",fontSize:12,display:n||C?"flex":"none",flexDirection:"column",alignItems:"center",pointerEvents:"none",transform:S.transform},children:W.jsx("div",{className:`error-message ${YfA}`,style:{opacity:C?1:0,border:`1px solid ${C?"#ff4444":"red"}`},children:g.message})})]},`${B}_${h}`)})})]})};function uZe(e,A){return e.size!==A.size?!1:Array.from(e).every(t=>A.has(t))}function dZe({primitiveElement:e,elements:A}){let t=e.trace_length?`${e.trace_length.toFixed(3)}`:"";const i=Gb(A).source_trace.get(e?.source_trace_id);if(i?.display_name&&(i?.max_length?t+=` / ${i.max_length}mm `:t+=" mm ",t+=`(${i.display_name})`),!t)return null;const n=e.trace_length&&i?.max_length&&e.trace_length>i.max_length;return{text:t,isOverLength:n}}function pZe(e){const{primitives:A,is_showing_multiple_traces_length:t,elements:i}=e,n=A.filter(a=>a._element.type==="pcb_trace"),o=i.filter(a=>a.type==="source_trace"),s=A.filter(a=>a._element.type!=="pcb_trace"),r=n.filter(a=>o.some(g=>a._element.type==="pcb_trace"&&a._element.source_trace_id===g.source_trace_id&&g.max_length!==void 0));if(!t)return[...s,...r];if(n.length>1){const a=n.reduce((g,c)=>{const I=g._element.trace_length;return c._element.trace_length<I?c:g},n[0]);return[...s,a]}return A}var fZe={position:"absolute",left:0,top:0,pointerEvents:"none",color:"red",fontFamily:"sans-serif",fontSize:12,textShadow:"0 0 2px black"},yZe=e=>{const{_element:A,_parent_pcb_component:t,_parent_source_component:i,_source_port:n}=e;switch(A.type){case"pcb_trace":return A.trace_length?`${A.trace_length.toFixed(3)}`:"";case"pcb_smtpad":case"pcb_plated_hole":{const o=[],s=Array.from(new Set((A.port_hints??[]).concat(n?.port_hints??[]))).filter(a=>!/^[0-9]+$/.test(a)).filter(a=>!a.includes("unnamed_")).sort((a,g)=>g.localeCompare(a)),r=i&&"name"in i&&i.name&&!i.name.includes("unnamed_")?i.name:null;return s.length>0?r?o.push(...s.map(a=>`${r}.${a}`)):o.push(...s):r&&o.push(r),o.join(", ")}default:return""}},mZe={top:"red",bottom:"aqua"},wZe=({primitive:e,mousePos:A,elements:t})=>{const[i,n]=V.useState(!1),o=e._element;V.useEffect(()=>{setTimeout(()=>{n(!0)},100)},[]);const[s,r,a,g]=[e.screen_x,e.screen_y,e.screen_w,e.screen_h],c=e.same_space_index??0,I=26,l=mZe[e?._element?.layer]??"red";let B=0;if(o.type==="pcb_smtpad"&&o?.shape==="rotated_rect"?B=o?.ccw_rotation??0:(o.type==="pcb_smtpad"&&(o?.shape==="pill"||o?.shape==="rotated_pill")&&"ccw_rotation"in e||o.type==="pcb_plated_hole"&&(o?.shape==="pill"||o?.shape==="oval")&&"ccw_rotation"in e)&&(B=o.ccw_rotation??0),o.type==="pcb_trace"){const h=dZe({primitiveElement:o,elements:t});if(!h)return null;const E=A.y-35;return W.jsx("div",{style:{zIndex:fc.elementOverlay,position:"absolute",left:A.x,top:E,color:l,pointerEvents:"none",transform:"translateX(-50%)"},children:W.jsx("div",{style:{backgroundColor:"#f2efcc",color:h.isOverLength?"red":"black",textShadow:"none",WebkitFontSmoothing:"antialiased",MozOsxFontSmoothing:"grayscale",padding:"6px 6px",borderRadius:"6px",fontSize:"14px",minWidth:"45px",textAlign:"center",whiteSpace:"nowrap"},children:h.text})})}const C=yZe(e);return C.trim().length===0?null:W.jsx("div",{style:{zIndex:fc.elementOverlay,position:"absolute",left:s-a/2-8,top:r-g/2-8,width:a+16,height:g+16,color:l,transform:`rotate(${-B}deg)`,transformOrigin:"center center"},children:W.jsx("div",{style:{width:i?`calc(100% + ${I*2*c}px)`:"100%",height:i?`calc(100% + ${I*2*c}px)`:"100%",marginLeft:i?`${-I*c}px`:0,marginTop:i?`${-I*c}px`:0,border:`1px solid ${l}`,opacity:i||c===0?1:0,transition:"width 0.2s, height 0.2s, margin-left 0.2s, margin-top 0.2s, opacity 0.2s"},children:W.jsx("div",{style:{position:"absolute",bottom:g+20+I*c,marginRight:i?`${-I*c}px`:0,marginBottom:i?0:-I*c,transition:"margin-right 0.2s, margin-bottom 0.2s",backgroundColor:"#f2efcc",color:"black",textShadow:"none",WebkitFontSmoothing:"antialiased",MozOsxFontSmoothing:"grayscale",padding:"6px 6px",borderRadius:"6px",fontSize:"14px",transform:`rotate(${B}deg)`,minWidth:"45px",textAlign:"center"},children:C})})})},DZe=({highlightedPrimitives:e,mousePos:A,elements:t})=>{const[i,n]=eC(r=>[r.is_moving_component,r.is_showing_multiple_traces_length]),o=e.some(r=>r._element.type==="pcb_smtpad")&&e.some(r=>r._element.type==="pcb_trace");let s=e;return o&&(s=s.filter(r=>r._element.type==="pcb_smtpad")),s=pZe({primitives:s,is_showing_multiple_traces_length:n,elements:t}),W.jsx("div",{style:fZe,children:!i&&s.map((r,a)=>W.jsx(wZe,{primitive:r,mousePos:A,elements:t},a))})},ek=e=>e?.type==="pcb_component",tIt=e=>e?.type==="pcb_group",SZe=e=>e?.type==="pcb_panel",JfA=e=>e?.type==="pcb_board",zc={MIN_LINE_LENGTH_FOR_LABEL:40,LABEL_OFFSET_ABOVE:2,LABEL_OFFSET_BELOW:-18,LABEL_OFFSET_RIGHT:8,LABEL_OFFSET_LEFT:-120,Y_LABEL_MIN_WIDTH:110,LINE_STROKE_WIDTH:1.5,LINE_DASH_PATTERN:"4,4",COMPONENT_MARKER_RADIUS:3,LABEL_FONT_SIZE:11,ANCHOR_MARKER_SIZE:6,ANCHOR_MARKER_STROKE_WIDTH:1.5},T0={OFFSET_LINE:"white",COMPONENT_MARKER_FILL:"#66ccff",COMPONENT_MARKER_STROKE:"white",LABEL_TEXT:"white"},TfA=({targets:e,transform:A,containerWidth:t,containerHeight:i})=>{if(e.length===0)return null;const n={color:T0.LABEL_TEXT,mixBlendMode:"difference",pointerEvents:"none",fontSize:zc.LABEL_FONT_SIZE,fontFamily:"monospace",fontWeight:"bold"},o=new Map;return e.forEach(s=>{if(!o.has(s.anchor_id)){const r=qi(A,s.anchor);o.set(s.anchor_id,r)}}),W.jsx("div",{style:{position:"absolute",left:0,top:0,width:t,height:i,overflow:"hidden",pointerEvents:"none",zIndex:fc.dimensionOverlay},children:W.jsxs("svg",{style:{position:"absolute",left:0,top:0,pointerEvents:"none"},width:t,height:i,children:[e.map(s=>{const r=s.anchor,a=s.anchor_id,g=s.target,c=o.get(a),I=qi(A,g),l=g.x-r.x,B=g.y-r.y,C=Math.abs(I.x-c.x),Q=Math.abs(I.y-c.y),h=I.y<c.y,E=I.x>c.x,u=h?zc.LABEL_OFFSET_ABOVE:zc.LABEL_OFFSET_BELOW,d=E?zc.LABEL_OFFSET_RIGHT:zc.LABEL_OFFSET_LEFT,f=C>zc.MIN_LINE_LENGTH_FOR_LABEL,m=Q>zc.MIN_LINE_LENGTH_FOR_LABEL,D=`${s.display_offset_x??l.toFixed(2)}mm`,w=`${s.display_offset_y??B.toFixed(2)}mm`;return W.jsxs("g",{children:[W.jsx("line",{x1:c.x,y1:c.y,x2:I.x,y2:c.y,stroke:T0.OFFSET_LINE,strokeWidth:zc.LINE_STROKE_WIDTH,strokeDasharray:zc.LINE_DASH_PATTERN}),W.jsx("line",{x1:I.x,y1:c.y,x2:I.x,y2:I.y,stroke:T0.OFFSET_LINE,strokeWidth:zc.LINE_STROKE_WIDTH,strokeDasharray:zc.LINE_DASH_PATTERN}),s.type==="component"||s.type==="board"?W.jsx("circle",{cx:I.x,cy:I.y,r:zc.COMPONENT_MARKER_RADIUS,fill:T0.COMPONENT_MARKER_FILL,stroke:T0.COMPONENT_MARKER_STROKE,strokeWidth:1}):W.jsxs(W.Fragment,{children:[W.jsx("line",{x1:I.x-zc.ANCHOR_MARKER_SIZE,y1:I.y,x2:I.x+zc.ANCHOR_MARKER_SIZE,y2:I.y,stroke:T0.OFFSET_LINE,strokeWidth:zc.ANCHOR_MARKER_STROKE_WIDTH}),W.jsx("line",{x1:I.x,y1:I.y-zc.ANCHOR_MARKER_SIZE,x2:I.x,y2:I.y+zc.ANCHOR_MARKER_SIZE,stroke:T0.OFFSET_LINE,strokeWidth:zc.ANCHOR_MARKER_STROKE_WIDTH})]}),f&&W.jsx("foreignObject",{x:Math.min(c.x,I.x),y:c.y+u,width:Math.abs(I.x-c.x),height:20,style:{overflow:"visible"},children:W.jsx("div",{style:{...n,textAlign:"center"},children:D})}),m&&W.jsx("foreignObject",{x:I.x+d,y:Math.min(c.y,I.y),width:zc.Y_LABEL_MIN_WIDTH,height:Math.abs(I.y-c.y),style:{overflow:"visible"},children:W.jsx("div",{style:{...n,display:"flex",alignItems:"center",justifyContent:E?"flex-start":"flex-end",whiteSpace:"nowrap",padding:"0 4px",height:"100%"},children:w})})]},s.id)}),Array.from(o.entries()).map(([s,r])=>W.jsxs("g",{children:[W.jsx("line",{x1:r.x-zc.ANCHOR_MARKER_SIZE,y1:r.y,x2:r.x+zc.ANCHOR_MARKER_SIZE,y2:r.y,stroke:T0.OFFSET_LINE,strokeWidth:zc.ANCHOR_MARKER_STROKE_WIDTH}),W.jsx("line",{x1:r.x,y1:r.y-zc.ANCHOR_MARKER_SIZE,x2:r.x,y2:r.y+zc.ANCHOR_MARKER_SIZE,stroke:T0.OFFSET_LINE,strokeWidth:zc.ANCHOR_MARKER_STROKE_WIDTH})]},`anchor-${s}`))]})})},bZe=({elements:e,highlightedPrimitives:A,transform:t,containerWidth:i,containerHeight:n})=>{const o=e.filter(E=>JfA(E)),s=e.filter(E=>ek(E)),r=e.filter(E=>tIt(E)),a=A.map(E=>ek(E._parent_pcb_component)?E._parent_pcb_component.pcb_component_id:ek(E._element)?E._element.pcb_component_id:null).filter(E=>!!E),g=new Set;if(a.forEach(E=>{const u=s.find(d=>d.pcb_component_id===E);u?.pcb_group_id&&g.add(u.pcb_group_id)}),!eC(E=>E.is_showing_group_anchor_offsets)&&a.length===0)return null;const I=s.map(E=>{const u=E.positioned_relative_to_pcb_board_id;if(!u)return null;const d=o.find(f=>f.pcb_board_id===u);return d?{component:E,board:d,type:"component"}:null}).filter(E=>!!E),l=r.map(E=>{const u=E.positioned_relative_to_pcb_board_id;if(!u||!E.center)return null;const d=o.find(f=>f.pcb_board_id===u);return d?{group:E,board:d,type:"group"}:null}).filter(E=>!!E),B=[...I,...l];if(B.length===0)return null;const C=a.length===0,Q=B.filter(E=>E.type==="component"?C||a.includes(E.component.pcb_component_id):C||g.has(E.group.pcb_group_id));if(Q.length===0)return null;const h=Q.map(E=>E.type==="component"?{id:`${E.board.pcb_board_id}-${E.component.pcb_component_id}-${E.type}`,anchor:E.board.center,anchor_id:E.board.pcb_board_id,target:E.component.center,type:"component",display_offset_x:E.component.display_offset_x,display_offset_y:E.component.display_offset_y}:{id:`${E.board.pcb_board_id}-${E.group.pcb_group_id}-${E.type}`,anchor:E.board.center,anchor_id:E.board.pcb_board_id,target:{x:E.group.anchor_position?.x??E.group.center.x,y:E.group.anchor_position?.y??E.group.center.y},type:"group",display_offset_x:E.group.display_offset_x,display_offset_y:E.group.display_offset_y}).filter(E=>!!E);return W.jsx(TfA,{targets:h,transform:t,containerWidth:i,containerHeight:n})},xZe=({elements:e,highlightedPrimitives:A,transform:t,containerWidth:i,containerHeight:n})=>{const o=e.filter(E=>tIt(E)),s=e.filter(E=>ek(E)),r=A.map(E=>ek(E._parent_pcb_component)?E._parent_pcb_component.pcb_component_id:ek(E._element)?E._element.pcb_component_id:null).filter(E=>!!E),a=(E,u)=>{if(u.has(E))return;u.add(E);const d=o.find(f=>f.pcb_group_id===E);d?.position_mode==="relative_to_group_anchor"&&d.positioned_relative_to_pcb_group_id&&a(d.positioned_relative_to_pcb_group_id,u)},g=new Set;if(r.forEach(E=>{const u=s.find(d=>d.pcb_component_id===E);u&&(u.position_mode==="relative_to_group_anchor"&&u.positioned_relative_to_pcb_group_id&&a(u.positioned_relative_to_pcb_group_id,g),u.pcb_group_id&&a(u.pcb_group_id,g))}),!eC(E=>E.is_showing_group_anchor_offsets)&&r.length===0)return null;const I=s.map(E=>{if(E.position_mode==="relative_to_group_anchor"&&E.positioned_relative_to_pcb_group_id){const u=o.find(d=>d.pcb_group_id===E.positioned_relative_to_pcb_group_id);return u&&u.anchor_position?{component:E,parentGroup:u,type:"component"}:null}if(E.pcb_group_id){const u=o.find(d=>d.pcb_group_id===E.pcb_group_id);return u&&u.anchor_position?{component:E,parentGroup:u,type:"component"}:null}return null}).filter(E=>!!E),l=o.map(E=>{if(E.position_mode==="relative_to_group_anchor"&&E.positioned_relative_to_pcb_group_id){const u=o.find(d=>d.pcb_group_id===E.positioned_relative_to_pcb_group_id);if(u&&u.anchor_position&&E.anchor_position)return{group:E,parentGroup:u,type:"group"}}return null}).filter(E=>!!E),B=[...I,...l];if(B.length===0)return null;const C=r.length===0,Q=B.filter(E=>E.type==="component"?C||r.includes(E.component.pcb_component_id):C||g.has(E.group.pcb_group_id)||g.has(E.parentGroup.pcb_group_id));if(Q.length===0)return null;const h=Q.map(E=>{const u=E.parentGroup.anchor_position;return u?E.type==="component"?E.component.center?{id:`${E.parentGroup.pcb_group_id}-${E.component.pcb_component_id}-${E.type}`,anchor:u,anchor_id:E.parentGroup.pcb_group_id,target:E.component.center,type:"component",display_offset_x:E.component.display_offset_x,display_offset_y:E.component.display_offset_y}:null:E.group.anchor_position?{id:`${E.parentGroup.pcb_group_id}-${E.group.pcb_group_id}-${E.type}`,anchor:u,anchor_id:E.parentGroup.pcb_group_id,target:E.group.anchor_position,type:"group",display_offset_x:E.group.display_offset_x,display_offset_y:E.group.display_offset_y}:null:null}).filter(E=>!!E);return W.jsx(TfA,{targets:h,transform:t,containerWidth:i,containerHeight:n})},_Ze=(e,A)=>{const t=e.pcb_component_id,i=A.filter(n=>(n.type==="pcb_smtpad"||n.type==="pcb_plated_hole")&&n.pcb_component_id===t||n.type==="pcb_hole"&&n.pcb_component_id===t);return i.length===0?LfA([e]):LfA(i)},kZe=({elements:e,highlightedPrimitives:A,transform:t,containerWidth:i,containerHeight:n})=>{const o=new Map;for(const r of A)ek(r._parent_pcb_component)&&o.set(r._parent_pcb_component.pcb_component_id,r._parent_pcb_component),ek(r._element)&&o.set(r._element.pcb_component_id,r._element);if(o.size===0)return null;const s=[];for(const r of o.values()){const a=_Ze(r,e);if(!a)continue;const g=r.positioned_relative_to_pcb_group_id??r.pcb_group_id,c=g?Gb(e).pcb_group.get(g):null;s.push({component:r,bbox:a,group:c})}return s.length===0?null:W.jsx("div",{style:{position:"absolute",left:0,top:0,width:i,height:n,overflow:"hidden",pointerEvents:"none",zIndex:fc.dimensionOverlay},children:W.jsx("svg",{style:{position:"absolute",left:0,top:0,pointerEvents:"none"},width:i,height:n,children:s.map(({component:r,bbox:a,group:g})=>{const c=qi(t,{x:a.minX,y:a.maxY}),I=qi(t,{x:a.maxX,y:a.minY}),l={x:Math.min(c.x,I.x),y:Math.min(c.y,I.y),width:Math.abs(I.x-c.x),height:Math.abs(I.y-c.y)},B=r.center??{x:(a.minX+a.maxX)/2,y:(a.minY+a.maxY)/2},C=qi(t,B);return W.jsxs("g",{children:[W.jsx("rect",{x:l.x,y:l.y,width:l.width,height:l.height,fill:"none",stroke:"white",strokeWidth:1.5,strokeDasharray:"4,4"}),W.jsx("line",{x1:C.x-6,y1:C.y,x2:C.x+6,y2:C.y,stroke:T0.COMPONENT_MARKER_STROKE,strokeWidth:1.5}),W.jsx("line",{x1:C.x,y1:C.y-6,x2:C.x,y2:C.y+6,stroke:T0.COMPONENT_MARKER_STROKE,strokeWidth:1.5}),W.jsx("circle",{cx:C.x,cy:C.y,r:zc.COMPONENT_MARKER_RADIUS,fill:T0.COMPONENT_MARKER_FILL,stroke:T0.COMPONENT_MARKER_STROKE,strokeWidth:1})]},r.pcb_component_id)})})})},FZe=({elements:e,highlightedPrimitives:A,transform:t,containerWidth:i,containerHeight:n})=>{const o=e.filter(B=>SZe(B)),s=e.filter(B=>JfA(B)),r=A.map(B=>JfA(B._element)?B._element.pcb_board_id:null).filter(B=>!!B);if(!eC(B=>B.is_showing_group_anchor_offsets)&&r.length===0)return null;const g=s.map(B=>{const C=B.pcb_panel_id,Q=B.position_mode;if(!C||Q!=="relative_to_panel_anchor")return null;const h=o.find(E=>E.pcb_panel_id===C);return h?{board:B,panel:h,type:"board"}:null}).filter(B=>!!B);if(g.length===0)return null;const c=r.length===0,I=g.filter(B=>c||r.includes(B.board.pcb_board_id));if(I.length===0)return null;const l=I.map(B=>B.board.center?{id:`${B.panel.pcb_panel_id}-${B.board.pcb_board_id}-${B.type}`,anchor:B.panel.center,anchor_id:B.panel.pcb_panel_id,target:B.board.center,type:"board",display_offset_x:B.board.display_offset_x,display_offset_y:B.board.display_offset_y}:null).filter(B=>!!B);return W.jsx(TfA,{targets:l,transform:t,containerWidth:i,containerHeight:n})},q9=e=>{if(e.length===0)return null;let A=e[0].x,t=e[0].y,i=e[0].x,n=e[0].y;for(const o of e)o.x<A&&(A=o.x),o.y<t&&(t=o.y),o.x>i&&(i=o.x),o.y>n&&(n=o.y);return{center:{x:(A+i)/2,y:(t+n)/2},width:i-A,height:n-t}},eIt=(e,A)=>{if(A.length<3)return!1;let t=!1;for(let i=0,n=A.length-1;i<A.length;n=i++){const o=A[i].x,s=A[i].y,r=A[n].x,a=A[n].y;s>e.y!=a>e.y&&e.x<(r-o)*(e.y-s)/(a-s||Number.EPSILON)+o&&(t=!t)}return t},GZe=(e,A,t)=>{const i=[];for(const n of e){if(!n._element)continue;if("x1"in n&&n._element?.type==="pcb_trace"){const r=wE({x:A.x,y:A.y},{x:n.x1,y:n.y1},{x:n.x2,y:n.y2}),a=n.width||.5,g=Math.max(a*25,2)/t.a;r<g&&i.push(n);continue}if(n.pcb_drawing_type==="polygon"){const r=n.points.map(g=>({x:he.parse(g.x),y:he.parse(g.y)})),a=q9(r);if(!a||A.x<a.center.x-a.width/2||A.x>a.center.x+a.width/2||A.y<a.center.y-a.height/2||A.y>a.center.y+a.height/2)continue;eIt(A,r)&&i.push(n);continue}if(n.pcb_drawing_type==="polygon_with_arcs"){const r=n.brep_shape.outer_ring.vertices.map(g=>({x:he.parse(g.x),y:he.parse(g.y)})),a=q9(r);if(!a||A.x<a.center.x-a.width/2||A.x>a.center.x+a.width/2||A.y<a.center.y-a.height/2||A.y>a.center.y+a.height/2)continue;eIt(A,r)&&i.push(n);continue}if(!("x"in n&&"y"in n))continue;let o=0,s=0;if("w"in n&&"h"in n)o=n.w,s=n.h;else if("r"in n)o=n.r*2,s=n.r*2;else if("rX"in n&&"rY"in n)o=n.rX*2,s=n.rY*2;else continue;Math.abs(n.x-A.x)<o/2&&Math.abs(n.y-A.y)<s/2&&i.push(n)}return i},RZe=({elements:e,children:A,transform:t,primitives:i,onMouseHoverOverPrimitives:n})=>{const[o,s]=V.useState([]),[r,a]=V.useState({x:0,y:0}),[g,{width:c,height:I}]=yJ(),l=V.useMemo(()=>{const C=[];for(const Q of o){if(Q._element?.type==="pcb_via"||Q._element?.type==="pcb_component"||Q?.layer==="drill")continue;let h=null,E=0,u=0;if(Q.pcb_drawing_type==="polygon"){const D=q9(Q.points);if(!D)continue;h=D.center,E=D.width,u=D.height}else if(Q.pcb_drawing_type==="polygon_with_arcs"){const D=Q.brep_shape.outer_ring.vertices.map(S=>({x:S.x,y:S.y})),w=q9(D);if(!w)continue;h=w.center,E=w.width,u=w.height}else"x"in Q&&"y"in Q&&(h={x:Q.x,y:Q.y},E="w"in Q?Q.w:"r"in Q?Q.r*2:"rX"in Q&&"rY"in Q?Q.rX*2:0,u="h"in Q?Q.h:"r"in Q?Q.r*2:"rX"in Q&&"rY"in Q?Q.rY*2:0);if(!h)continue;const d=qi(t,h),f={w:E*t.a,h:u*t.a},m=C.filter(D=>d.x===D.screen_x&&d.y===D.screen_y&&f.w===D.screen_w&&f.h===D.screen_h).length;C.push({...Q,x:h.x,y:h.y,w:E,h:u,screen_x:d.x,screen_y:d.y,screen_w:f.w,screen_h:f.h,same_space_index:m})}return C},[o,t]),B=(C,Q,h,E)=>{a({x:C,y:Q});const u=qi(kb(h),{x:C,y:Q}),d=GZe(E,u,h);uZe(new Set(d.map(f=>f._pcb_drawing_object_id)),new Set(o.map(f=>f._pcb_drawing_object_id)))||(s(d),n(d))};return W.jsxs("div",{ref:g,style:{position:"relative",width:"100%",height:"100%"},onMouseMove:C=>{if(t){const Q=C.currentTarget.getBoundingClientRect(),h=C.clientX-Q.left,E=C.clientY-Q.top;B(h,E,t,i)}},onTouchStart:C=>{if(t){const Q=C.touches[0],h=C.currentTarget.getBoundingClientRect(),E=Q.clientX-h.left,u=Q.clientY-h.top;B(E,u,t,i)}},children:[A,W.jsx(DZe,{elements:e,mousePos:r,highlightedPrimitives:l}),t&&W.jsxs(W.Fragment,{children:[W.jsx(bZe,{elements:e,highlightedPrimitives:l,transform:t,containerWidth:c,containerHeight:I}),W.jsx(xZe,{elements:e,highlightedPrimitives:l,transform:t,containerWidth:c,containerHeight:I}),W.jsx(kZe,{elements:e,highlightedPrimitives:l,transform:t,containerWidth:c,containerHeight:I}),W.jsx(FZe,{elements:e,highlightedPrimitives:l,transform:t,containerWidth:c,containerHeight:I})]})]})},iIt=["rgb(255, 100, 100)","rgb(100, 255, 100)","rgb(100, 100, 255)","rgb(255, 255, 100)","rgb(255, 100, 255)","rgb(100, 255, 255)","rgb(255, 150, 100)","rgb(150, 100, 255)","rgb(100, 255, 150)","rgb(255, 100, 150)"],MZe=({children:e,transform:A=_b(),elements:t=[],hoveredComponentIds:i=[]})=>{const[n,{width:o,height:s}]=yJ(),r=V.useRef(null),{is_showing_pcb_groups:a,pcb_group_view_mode:g,is_showing_group_anchor_offsets:c}=eC(I=>({is_showing_pcb_groups:I.is_showing_pcb_groups,pcb_group_view_mode:I.pcb_group_view_mode,is_showing_group_anchor_offsets:I.is_showing_group_anchor_offsets}));return V.useEffect(()=>{const I=r.current;if(!I||!o||!s)return;I.width=o,I.height=s;const l=I.getContext("2d");if(!l||(l.clearRect(0,0,o,s),!a))return;const B=t.filter(D=>D.type==="pcb_group"),C=t.filter(D=>D.type==="pcb_component"),Q=t.filter(D=>D.type==="source_group"),h=new Map(Q.map(D=>[D.source_group_id,D])),E=B.filter(D=>{if(g==="all")return!0;if(!D.source_group_id)return!1;const w=h.get(D.source_group_id);return w?w.was_automatically_named!==!0:!1}),u=new Map;Q.forEach(D=>{const w=D;if(w.parent_source_group_id){const S=u.get(w.parent_source_group_id)||[];S.push(D.source_group_id),u.set(w.parent_source_group_id,S)}});const d=D=>{const w=[],S=u.get(D)||[];for(const k of S)w.push(k),w.push(...d(k));return w},f=D=>{const w=Q.find(S=>S.source_group_id===D);return w?.parent_source_group_id?1+f(w.parent_source_group_id):0},m=new Set;if(i.length>0)for(const D of C){if(!i.includes(D.pcb_component_id))continue;const w=D.positioned_relative_to_pcb_group_id??D.pcb_group_id;w&&m.add(w)}E.forEach((D,w)=>{let S=C.filter(HA=>HA.pcb_group_id===D.pcb_group_id);if(D.source_group_id){const HA=d(D.source_group_id),ZA=B.filter(xA=>xA.source_group_id&&HA.includes(xA.source_group_id));for(const xA of ZA){const wA=C.filter(NA=>NA.pcb_group_id===xA.pcb_group_id);S=[...S,...wA]}}let k,x,N,M,L=!1;if(D.center&&D.width&&D.height){L=!0;const HA=D.width/2,ZA=D.height/2;k=D.center.x-HA,N=D.center.x+HA,x=D.center.y-ZA,M=D.center.y+ZA}else if(S.length===0||(k=1/0,x=1/0,N=-1/0,M=-1/0,S.forEach(HA=>{if(HA.center&&typeof HA.width=="number"&&typeof HA.height=="number"){const ZA=HA.center.x-HA.width/2,xA=HA.center.x+HA.width/2,wA=HA.center.y+HA.height/2,NA=HA.center.y-HA.height/2;k=Math.min(k,ZA),N=Math.max(N,xA),x=Math.min(x,NA),M=Math.max(M,wA)}}),k===1/0||N===-1/0))return;const Y=D.source_group_id?f(D.source_group_id):0,H=D.source_group_id?d(D.source_group_id).length>0:!1;if(!L){const xA=1+(H?.5:0);k-=xA,N+=xA,x-=xA,M+=xA}const O=qi(A,{x:k,y:M}),Z=qi(A,{x:N,y:M}),$=qi(A,{x:k,y:x}),eA=qi(A,{x:N,y:x}),aA=iIt[w%iIt.length];l.strokeStyle=aA,l.lineWidth=2;const tA=Math.max(4,Math.min(12,8*Math.abs(A.a))),nA=Math.max(2,Math.min(6,4*Math.abs(A.a))),lA=tA*(H?1.3:1),fA=nA;l.setLineDash([lA,fA]),l.beginPath(),l.moveTo(O.x,O.y),l.lineTo(Z.x,Z.y),l.lineTo(eA.x,eA.y),l.lineTo($.x,$.y),l.closePath(),l.stroke();const bA=Math.max(8,Math.min(12,10*Math.abs(A.a))),GA=Y==0||Y==1?0:Y*.11,YA=bA*(1-GA),QA=4,_A=D.name||`Group ${w+1}`;l.font=`${YA}px sans-serif`,l.setLineDash([]);const PA=l.measureText(_A).width+QA*2,JA=YA+QA*2,it=O.x-5,pA=O.y-5,tt=3;if(l.fillStyle="rgba(0, 0, 0, 0.8)",l.beginPath(),l.roundRect(it,pA-JA,PA,JA,tt),l.fill(),l.fillStyle=aA,l.textAlign="left",l.textBaseline="middle",l.fillText(_A,it+QA,pA-JA/2),c&&m.has(D.pcb_group_id)&&!!D.anchor_position&&D.anchor_position){const HA=Array.isArray(D.anchor_position)?{x:D.anchor_position[0]??0,y:D.anchor_position[1]??0}:{x:D.anchor_position.x,y:D.anchor_position.y},ZA=qi(A,HA);l.strokeStyle="white",l.lineWidth=1.5,l.setLineDash([]);const xA=Math.max(4,Math.min(8,6*Math.abs(A.a)));l.beginPath(),l.moveTo(ZA.x-xA,ZA.y),l.lineTo(ZA.x+xA,ZA.y),l.stroke(),l.beginPath(),l.moveTo(ZA.x,ZA.y-xA),l.lineTo(ZA.x,ZA.y+xA),l.stroke()}})},[t,A,o,s,a,g,c,i]),W.jsxs("div",{ref:n,style:{position:"relative",width:"100%",height:"100%"},children:[e,W.jsx("canvas",{ref:r,style:{position:"absolute",top:0,left:0,pointerEvents:"none",zIndex:fc.pcbGroupOverlay,display:a?"block":"none"}})]})},NZe=({transform:e,soup:A,children:t})=>{const i=eC(r=>r.is_showing_rats_nest),{netMap:n,idToNetMap:o}=V.useMemo(()=>Nct(A||[]),[A]),s=V.useMemo(()=>{if(!A||!i)return[];const r=l=>{const B=Gb(A)[l.replace(/_\d+$/,"")].get(l);return B&&"x"in B&&"y"in B?{x:B.x,y:B.y}:null},a=(l,B)=>{const C=n[B]||[];let Q=null,h=1/0;return C.forEach(E=>{const u=r(E);if(u){const d=Math.sqrt((l.x-u.x)**2+(l.y-u.y)**2);d<h&&d>0&&(h=d,Q=u)}}),Q},g=Gb(A).pcb_port.list(),c=Gb(A).source_trace.list(),I=[];return g.forEach((l,B)=>{const C=o[l.pcb_port_id];let Q=!1;for(const u of c)u.connected_source_port_ids.includes(l.source_port_id)&&u.connected_source_net_ids.length>0&&(Q=!0);if(!C)return;const h={x:l.x,y:l.y},E=a(h,C);E&&I.push({key:`${l.pcb_port_id}-${B}`,startPoint:h,endPoint:E,isInNet:Q})}),I},[A,n,o,i]);return!A||!i?t:(e||(e=_b()),W.jsxs("div",{style:{position:"relative"},children:[t,W.jsx("svg",{style:{position:"absolute",left:0,top:0,width:"100%",height:"100%",pointerEvents:"none",opacity:.5,zIndex:fc.ratsNestOverlay},children:s.map(({key:r,startPoint:a,endPoint:g,isInNet:c})=>{const I=qi(e,a),l=qi(e,g);return W.jsx("line",{x1:I.x,y1:I.y,x2:l.x,y2:l.y,stroke:"white",strokeWidth:"1",strokeDasharray:c?"6,6":void 0},r)})})]}))},vZe={version:"1.11.334"},ik=(e,A,t)=>{const i=eC(s=>s.is_mouse_over_container),n=V.useRef(i),o=V.useRef(A);V.useEffect(()=>{n.current=i},[i]),V.useEffect(()=>{o.current=A},[A]),V.useEffect(()=>{if(!e)return;const s=r=>{const a=r.target;if(a.tagName==="INPUT"||a.tagName==="TEXTAREA"||a.isContentEditable)return;const g=e.split("+"),c=g.includes("ctrl"),I=g.includes("shift"),l=g.includes("alt"),B=g.includes("meta"),C=g[g.length-1],Q=t?.current?t.current.contains(document.activeElement)||document.activeElement===t.current:!1;(n.current||Q)&&(!c||r.ctrlKey)&&(!I||r.shiftKey)&&(!l||r.altKey)&&(!B||r.metaKey)&&r.key.toLowerCase()===C.toLowerCase()&&(r.preventDefault(),o.current())};return window.addEventListener("keydown",s),()=>{window.removeEventListener("keydown",s)}},[e])},LZe=()=>{const[e,A]=V.useState(!1);return V.useEffect(()=>{const t=()=>{A(window.innerWidth<=768)};return t(),window.addEventListener("resize",t),()=>window.removeEventListener("resize",t)},[]),e},UZe=({name:e,selected:A,onClick:t})=>W.jsxs("div",{className:g1`
5472
+ `,EZe=({children:e,transform:A=_b(),elements:t})=>{const i=V.useRef(null),{isShowingDRCErrors:n,hoveredErrorId:o}=eC(g=>({isShowingDRCErrors:g.is_showing_drc_errors,hoveredErrorId:g.hovered_error_id}));if(!t)return W.jsx("div",{style:{position:"relative"},ref:i,children:e});const s=t.filter(g=>g.type==="pcb_trace_error"),r=t.filter(g=>g.type==="pcb_trace_error"&&g.message?.includes("Multiple components found with name")),a=new Map;return t.forEach(g=>{g.type==="pcb_port"&&a.set(g.pcb_port_id,g)}),W.jsxs("div",{style:{position:"relative"},ref:i,children:[e,s.map((g,c)=>{const{pcb_port_ids:I,pcb_trace_id:l}=g,B=I?.[0]?a.get(I[0]):void 0,C=I?.[1]?a.get(I[1]):void 0,Q=t?Gb(t).pcb_trace.get(l):void 0,h=g.pcb_trace_error_id||`error_${c}_${g.error_type}_${g.message?.slice(0,20)}`,E=o===h;if(B&&C){const u=qi(A,{x:B.x,y:B.y}),d=qi(A,{x:C.x,y:C.y});if(!n)return null;const f=!(isNaN(u.x)||isNaN(u.y)||isNaN(d.x)||isNaN(d.y)),m={x:(u.x+d.x)/2,y:(u.y+d.y)/2};if(isNaN(m.x)||isNaN(m.y))return null;const D=HfA(m,i);return W.jsxs(V.Fragment,{children:[W.jsx(QZe,{screenPort1:u,screenPort2:d,errorCenter:m,canLineBeDrawn:f,isHighlighted:E}),W.jsx("div",{style:{position:"absolute",left:m.x-15,top:m.y-15,width:30,height:30,zIndex:fc.errorOverlay+5,cursor:"pointer",borderRadius:"50%"},onMouseEnter:w=>{const S=w.currentTarget.nextElementSibling;if(S){const k=S.querySelector(".error-message");k&&(k.style.opacity="1")}},onMouseLeave:w=>{if(!E){const S=w.currentTarget.nextElementSibling;if(S){const k=S.querySelector(".error-message");k&&(k.style.opacity="0")}}}}),W.jsx("div",{style:{position:"absolute",zIndex:E?200:100,left:D.left,top:D.top,color:E?"#ff4444":"red",textAlign:"center",fontFamily:"sans-serif",fontSize:12,display:n||E?"flex":"none",flexDirection:"column",alignItems:"center",pointerEvents:"none",transform:D.transform},children:W.jsx("div",{className:`error-message ${YfA}`,style:{opacity:E?1:0,border:`1px solid ${E?"#ff4444":"red"}`},children:g.message})})]},h)}if(Q?.route&&(n||E)){const u=Q.route.map(D=>qi(A,{x:D.x,y:D.y}));if(u.some(D=>isNaN(D.x)||isNaN(D.y)))return null;const d=Math.floor(u.length/2),f=u[d],m=HfA(f,i);return W.jsxs(V.Fragment,{children:[W.jsx(hZe,{points:u,errorCenter:f,isHighlighted:E}),W.jsx("div",{style:{position:"absolute",left:f.x-15,top:f.y-15,width:30,height:30,zIndex:fc.errorOverlay+5,cursor:"pointer",borderRadius:"50%"},onMouseEnter:D=>{const w=D.currentTarget.nextElementSibling;if(w){const S=w.querySelector(".error-message");S&&(S.style.opacity="1")}},onMouseLeave:D=>{if(!E){const w=D.currentTarget.nextElementSibling;if(w){const S=w.querySelector(".error-message");S&&(S.style.opacity="0")}}}}),W.jsx("div",{style:{position:"absolute",zIndex:E?fc.errorOverlay+10:fc.errorOverlay+1,left:m.left,top:m.top,color:E?"#ff4444":"red",textAlign:"center",fontFamily:"sans-serif",fontSize:12,display:"flex",flexDirection:"column",alignItems:"center",pointerEvents:"none",transform:m.transform},children:W.jsx("div",{className:`error-message ${YfA}`,style:{opacity:E?1:0,border:`1px solid ${E?"#ff4444":"red"}`},children:g.message})})]},h)}return null}),r.map((g,c)=>{const I=g.component_name||g.message?.match(/name "([^"]+)"/)?.[1];if(!I)return null;const l=t?.filter(Q=>Q.type==="source_component"&&Q.name===I||Q.type==="pcb_component"&&t?.find(h=>h.type==="source_component"&&h.source_component_id===Q.source_component_id&&h.name===I))||[],B=g.pcb_trace_error_id||`error_${c}_${g.error_type}_${g.message?.slice(0,20)}`,C=o===B;return!C&&!n?null:l.map((Q,h)=>{let E={x:0,y:0};if(Q.type==="pcb_component")E=Q.center||{x:0,y:0};else if(Q.type==="source_component"){const k=t?.find(x=>x.type==="pcb_component"&&x.source_component_id===Q.source_component_id);k&&k.type==="pcb_component"&&(E=k.center||{x:0,y:0})}const u=qi(A,E);if(isNaN(u.x)||isNaN(u.y))return null;const d=Math.abs(A.a),w=Math.max(8,Math.min(30,.5*d)),S=HfA(u,i);return W.jsxs(V.Fragment,{children:[W.jsx("svg",{style:{position:"absolute",left:0,top:0,pointerEvents:"none",mixBlendMode:"difference",zIndex:fc.errorOverlay},width:"100%",height:"100%",children:C?W.jsx("polygon",{points:`${u.x},${u.y-w*1.25} ${u.x+w},${u.y} ${u.x},${u.y+w*1.25} ${u.x-w},${u.y}`,fill:"#ff4444"}):W.jsx("circle",{cx:u.x,cy:u.y,r:w,fill:"none",stroke:C?"#ff4444":"red",strokeWidth:C?Math.max(2,w*.15):Math.max(1,w*.1),opacity:1})}),W.jsx("div",{style:{position:"absolute",left:u.x-(w+10),top:u.y-(w+10),width:(w+10)*2,height:(w+10)*2,zIndex:fc.errorOverlay+5,cursor:"pointer",borderRadius:"50%"},onMouseEnter:k=>{const x=k.currentTarget.nextElementSibling;if(x){const N=x.querySelector(".error-message");N&&(N.style.opacity="1")}},onMouseLeave:k=>{if(!C){const x=k.currentTarget.nextElementSibling;if(x){const N=x.querySelector(".error-message");N&&(N.style.opacity="0")}}}}),W.jsx("div",{style:{position:"absolute",zIndex:C?fc.errorOverlay+20:fc.errorOverlay+10,left:S.left,top:S.top,color:C?"#ff4444":"red",textAlign:"center",fontFamily:"sans-serif",fontSize:12,display:n||C?"flex":"none",flexDirection:"column",alignItems:"center",pointerEvents:"none",transform:S.transform},children:W.jsx("div",{className:`error-message ${YfA}`,style:{opacity:C?1:0,border:`1px solid ${C?"#ff4444":"red"}`},children:g.message})})]},`${B}_${h}`)})})]})};function uZe(e,A){return e.size!==A.size?!1:Array.from(e).every(t=>A.has(t))}function dZe({primitiveElement:e,elements:A}){let t=e.trace_length?`${e.trace_length.toFixed(3)}`:"";const i=Gb(A).source_trace.get(e?.source_trace_id);if(i?.display_name&&(i?.max_length?t+=` / ${i.max_length}mm `:t+=" mm ",t+=`(${i.display_name})`),!t)return null;const n=e.trace_length&&i?.max_length&&e.trace_length>i.max_length;return{text:t,isOverLength:n}}function pZe(e){const{primitives:A,is_showing_multiple_traces_length:t,elements:i}=e,n=A.filter(a=>a._element.type==="pcb_trace"),o=i.filter(a=>a.type==="source_trace"),s=A.filter(a=>a._element.type!=="pcb_trace"),r=n.filter(a=>o.some(g=>a._element.type==="pcb_trace"&&a._element.source_trace_id===g.source_trace_id&&g.max_length!==void 0));if(!t)return[...s,...r];if(n.length>1){const a=n.reduce((g,c)=>{const I=g._element.trace_length;return c._element.trace_length<I?c:g},n[0]);return[...s,a]}return A}var fZe={position:"absolute",left:0,top:0,pointerEvents:"none",color:"red",fontFamily:"sans-serif",fontSize:12,textShadow:"0 0 2px black"},yZe=e=>{const{_element:A,_parent_pcb_component:t,_parent_source_component:i,_source_port:n}=e;switch(A.type){case"pcb_trace":return A.trace_length?`${A.trace_length.toFixed(3)}`:"";case"pcb_smtpad":case"pcb_plated_hole":{const o=[],s=Array.from(new Set((A.port_hints??[]).concat(n?.port_hints??[]))).filter(a=>!/^[0-9]+$/.test(a)).filter(a=>!a.includes("unnamed_")).sort((a,g)=>g.localeCompare(a)),r=i&&"name"in i&&i.name&&!i.name.includes("unnamed_")?i.name:null;return s.length>0?r?o.push(...s.map(a=>`${r}.${a}`)):o.push(...s):r&&o.push(r),o.join(", ")}default:return""}},mZe={top:"red",bottom:"aqua"},wZe=({primitive:e,mousePos:A,elements:t})=>{const[i,n]=V.useState(!1),o=e._element;V.useEffect(()=>{setTimeout(()=>{n(!0)},100)},[]);const[s,r,a,g]=[e.screen_x,e.screen_y,e.screen_w,e.screen_h],c=e.same_space_index??0,I=26,l=mZe[e?._element?.layer]??"red";let B=0;if(o.type==="pcb_smtpad"&&o?.shape==="rotated_rect"?B=o?.ccw_rotation??0:(o.type==="pcb_smtpad"&&(o?.shape==="pill"||o?.shape==="rotated_pill")&&"ccw_rotation"in e||o.type==="pcb_plated_hole"&&(o?.shape==="pill"||o?.shape==="oval")&&"ccw_rotation"in e)&&(B=o.ccw_rotation??0),o.type==="pcb_trace"){const h=dZe({primitiveElement:o,elements:t});if(!h)return null;const E=A.y-35;return W.jsx("div",{style:{zIndex:fc.elementOverlay,position:"absolute",left:A.x,top:E,color:l,pointerEvents:"none",transform:"translateX(-50%)"},children:W.jsx("div",{style:{backgroundColor:"#f2efcc",color:h.isOverLength?"red":"black",textShadow:"none",WebkitFontSmoothing:"antialiased",MozOsxFontSmoothing:"grayscale",padding:"6px 6px",borderRadius:"6px",fontSize:"14px",minWidth:"45px",textAlign:"center",whiteSpace:"nowrap"},children:h.text})})}const C=yZe(e);return C.trim().length===0?null:W.jsx("div",{style:{zIndex:fc.elementOverlay,position:"absolute",left:s-a/2-8,top:r-g/2-8,width:a+16,height:g+16,color:l,transform:`rotate(${-B}deg)`,transformOrigin:"center center"},children:W.jsx("div",{style:{width:i?`calc(100% + ${I*2*c}px)`:"100%",height:i?`calc(100% + ${I*2*c}px)`:"100%",marginLeft:i?`${-I*c}px`:0,marginTop:i?`${-I*c}px`:0,border:`1px solid ${l}`,opacity:i||c===0?1:0,transition:"width 0.2s, height 0.2s, margin-left 0.2s, margin-top 0.2s, opacity 0.2s"},children:W.jsx("div",{style:{position:"absolute",bottom:g+20+I*c,marginRight:i?`${-I*c}px`:0,marginBottom:i?0:-I*c,transition:"margin-right 0.2s, margin-bottom 0.2s",backgroundColor:"#f2efcc",color:"black",textShadow:"none",WebkitFontSmoothing:"antialiased",MozOsxFontSmoothing:"grayscale",padding:"6px 6px",borderRadius:"6px",fontSize:"14px",transform:`rotate(${B}deg)`,minWidth:"45px",textAlign:"center"},children:C})})})},DZe=({highlightedPrimitives:e,mousePos:A,elements:t})=>{const[i,n]=eC(r=>[r.is_moving_component,r.is_showing_multiple_traces_length]),o=e.some(r=>r._element.type==="pcb_smtpad")&&e.some(r=>r._element.type==="pcb_trace");let s=e;return o&&(s=s.filter(r=>r._element.type==="pcb_smtpad")),s=pZe({primitives:s,is_showing_multiple_traces_length:n,elements:t}),W.jsx("div",{style:fZe,children:!i&&s.map((r,a)=>W.jsx(wZe,{primitive:r,mousePos:A,elements:t},a))})},ek=e=>e?.type==="pcb_component",tIt=e=>e?.type==="pcb_group",SZe=e=>e?.type==="pcb_panel",JfA=e=>e?.type==="pcb_board",zc={MIN_LINE_LENGTH_FOR_LABEL:40,LABEL_OFFSET_ABOVE:2,LABEL_OFFSET_BELOW:-18,LABEL_OFFSET_RIGHT:8,LABEL_OFFSET_LEFT:-120,Y_LABEL_MIN_WIDTH:110,LINE_STROKE_WIDTH:1.5,LINE_DASH_PATTERN:"4,4",COMPONENT_MARKER_RADIUS:3,LABEL_FONT_SIZE:11,ANCHOR_MARKER_SIZE:6,ANCHOR_MARKER_STROKE_WIDTH:1.5},T0={OFFSET_LINE:"white",COMPONENT_MARKER_FILL:"#66ccff",COMPONENT_MARKER_STROKE:"white",LABEL_TEXT:"white"},TfA=({targets:e,transform:A,containerWidth:t,containerHeight:i})=>{if(e.length===0)return null;const n={color:T0.LABEL_TEXT,mixBlendMode:"difference",pointerEvents:"none",fontSize:zc.LABEL_FONT_SIZE,fontFamily:"monospace",fontWeight:"bold"},o=new Map;return e.forEach(s=>{if(!o.has(s.anchor_id)){const r=qi(A,s.anchor);o.set(s.anchor_id,r)}}),W.jsx("div",{style:{position:"absolute",left:0,top:0,width:t,height:i,overflow:"hidden",pointerEvents:"none",zIndex:fc.dimensionOverlay},children:W.jsxs("svg",{style:{position:"absolute",left:0,top:0,pointerEvents:"none"},width:t,height:i,children:[e.map(s=>{const r=s.anchor,a=s.anchor_id,g=s.target,c=o.get(a),I=qi(A,g),l=g.x-r.x,B=g.y-r.y,C=Math.abs(I.x-c.x),Q=Math.abs(I.y-c.y),h=I.y<c.y,E=I.x>c.x,u=h?zc.LABEL_OFFSET_ABOVE:zc.LABEL_OFFSET_BELOW,d=E?zc.LABEL_OFFSET_RIGHT:zc.LABEL_OFFSET_LEFT,f=C>zc.MIN_LINE_LENGTH_FOR_LABEL,m=Q>zc.MIN_LINE_LENGTH_FOR_LABEL,D=`${s.display_offset_x??l.toFixed(2)}mm`,w=`${s.display_offset_y??B.toFixed(2)}mm`;return W.jsxs("g",{children:[W.jsx("line",{x1:c.x,y1:c.y,x2:I.x,y2:c.y,stroke:T0.OFFSET_LINE,strokeWidth:zc.LINE_STROKE_WIDTH,strokeDasharray:zc.LINE_DASH_PATTERN}),W.jsx("line",{x1:I.x,y1:c.y,x2:I.x,y2:I.y,stroke:T0.OFFSET_LINE,strokeWidth:zc.LINE_STROKE_WIDTH,strokeDasharray:zc.LINE_DASH_PATTERN}),s.type==="component"||s.type==="board"?W.jsx("circle",{cx:I.x,cy:I.y,r:zc.COMPONENT_MARKER_RADIUS,fill:T0.COMPONENT_MARKER_FILL,stroke:T0.COMPONENT_MARKER_STROKE,strokeWidth:1}):W.jsxs(W.Fragment,{children:[W.jsx("line",{x1:I.x-zc.ANCHOR_MARKER_SIZE,y1:I.y,x2:I.x+zc.ANCHOR_MARKER_SIZE,y2:I.y,stroke:T0.OFFSET_LINE,strokeWidth:zc.ANCHOR_MARKER_STROKE_WIDTH}),W.jsx("line",{x1:I.x,y1:I.y-zc.ANCHOR_MARKER_SIZE,x2:I.x,y2:I.y+zc.ANCHOR_MARKER_SIZE,stroke:T0.OFFSET_LINE,strokeWidth:zc.ANCHOR_MARKER_STROKE_WIDTH})]}),f&&W.jsx("foreignObject",{x:Math.min(c.x,I.x),y:c.y+u,width:Math.abs(I.x-c.x),height:20,style:{overflow:"visible"},children:W.jsx("div",{style:{...n,textAlign:"center"},children:D})}),m&&W.jsx("foreignObject",{x:I.x+d,y:Math.min(c.y,I.y),width:zc.Y_LABEL_MIN_WIDTH,height:Math.abs(I.y-c.y),style:{overflow:"visible"},children:W.jsx("div",{style:{...n,display:"flex",alignItems:"center",justifyContent:E?"flex-start":"flex-end",whiteSpace:"nowrap",padding:"0 4px",height:"100%"},children:w})})]},s.id)}),Array.from(o.entries()).map(([s,r])=>W.jsxs("g",{children:[W.jsx("line",{x1:r.x-zc.ANCHOR_MARKER_SIZE,y1:r.y,x2:r.x+zc.ANCHOR_MARKER_SIZE,y2:r.y,stroke:T0.OFFSET_LINE,strokeWidth:zc.ANCHOR_MARKER_STROKE_WIDTH}),W.jsx("line",{x1:r.x,y1:r.y-zc.ANCHOR_MARKER_SIZE,x2:r.x,y2:r.y+zc.ANCHOR_MARKER_SIZE,stroke:T0.OFFSET_LINE,strokeWidth:zc.ANCHOR_MARKER_STROKE_WIDTH})]},`anchor-${s}`))]})})},bZe=({elements:e,highlightedPrimitives:A,transform:t,containerWidth:i,containerHeight:n})=>{const o=e.filter(E=>JfA(E)),s=e.filter(E=>ek(E)),r=e.filter(E=>tIt(E)),a=A.map(E=>ek(E._parent_pcb_component)?E._parent_pcb_component.pcb_component_id:ek(E._element)?E._element.pcb_component_id:null).filter(E=>!!E),g=new Set;if(a.forEach(E=>{const u=s.find(d=>d.pcb_component_id===E);u?.pcb_group_id&&g.add(u.pcb_group_id)}),!eC(E=>E.is_showing_group_anchor_offsets)&&a.length===0)return null;const I=s.map(E=>{const u=E.positioned_relative_to_pcb_board_id;if(!u)return null;const d=o.find(f=>f.pcb_board_id===u);return d?{component:E,board:d,type:"component"}:null}).filter(E=>!!E),l=r.map(E=>{const u=E.positioned_relative_to_pcb_board_id;if(!u||!E.center)return null;const d=o.find(f=>f.pcb_board_id===u);return d?{group:E,board:d,type:"group"}:null}).filter(E=>!!E),B=[...I,...l];if(B.length===0)return null;const C=a.length===0,Q=B.filter(E=>E.type==="component"?C||a.includes(E.component.pcb_component_id):C||g.has(E.group.pcb_group_id));if(Q.length===0)return null;const h=Q.map(E=>E.type==="component"?{id:`${E.board.pcb_board_id}-${E.component.pcb_component_id}-${E.type}`,anchor:E.board.center,anchor_id:E.board.pcb_board_id,target:E.component.center,type:"component",display_offset_x:E.component.display_offset_x,display_offset_y:E.component.display_offset_y}:{id:`${E.board.pcb_board_id}-${E.group.pcb_group_id}-${E.type}`,anchor:E.board.center,anchor_id:E.board.pcb_board_id,target:{x:E.group.anchor_position?.x??E.group.center.x,y:E.group.anchor_position?.y??E.group.center.y},type:"group",display_offset_x:E.group.display_offset_x,display_offset_y:E.group.display_offset_y}).filter(E=>!!E);return W.jsx(TfA,{targets:h,transform:t,containerWidth:i,containerHeight:n})},xZe=({elements:e,highlightedPrimitives:A,transform:t,containerWidth:i,containerHeight:n})=>{const o=e.filter(E=>tIt(E)),s=e.filter(E=>ek(E)),r=A.map(E=>ek(E._parent_pcb_component)?E._parent_pcb_component.pcb_component_id:ek(E._element)?E._element.pcb_component_id:null).filter(E=>!!E),a=(E,u)=>{if(u.has(E))return;u.add(E);const d=o.find(f=>f.pcb_group_id===E);d?.position_mode==="relative_to_group_anchor"&&d.positioned_relative_to_pcb_group_id&&a(d.positioned_relative_to_pcb_group_id,u)},g=new Set;if(r.forEach(E=>{const u=s.find(d=>d.pcb_component_id===E);u&&(u.position_mode==="relative_to_group_anchor"&&u.positioned_relative_to_pcb_group_id&&a(u.positioned_relative_to_pcb_group_id,g),u.pcb_group_id&&a(u.pcb_group_id,g))}),!eC(E=>E.is_showing_group_anchor_offsets)&&r.length===0)return null;const I=s.map(E=>{if(E.position_mode==="relative_to_group_anchor"&&E.positioned_relative_to_pcb_group_id){const u=o.find(d=>d.pcb_group_id===E.positioned_relative_to_pcb_group_id);return u&&u.anchor_position?{component:E,parentGroup:u,type:"component"}:null}if(E.pcb_group_id){const u=o.find(d=>d.pcb_group_id===E.pcb_group_id);return u&&u.anchor_position?{component:E,parentGroup:u,type:"component"}:null}return null}).filter(E=>!!E),l=o.map(E=>{if(E.position_mode==="relative_to_group_anchor"&&E.positioned_relative_to_pcb_group_id){const u=o.find(d=>d.pcb_group_id===E.positioned_relative_to_pcb_group_id);if(u&&u.anchor_position&&E.anchor_position)return{group:E,parentGroup:u,type:"group"}}return null}).filter(E=>!!E),B=[...I,...l];if(B.length===0)return null;const C=r.length===0,Q=B.filter(E=>E.type==="component"?C||r.includes(E.component.pcb_component_id):C||g.has(E.group.pcb_group_id)||g.has(E.parentGroup.pcb_group_id));if(Q.length===0)return null;const h=Q.map(E=>{const u=E.parentGroup.anchor_position;return u?E.type==="component"?E.component.center?{id:`${E.parentGroup.pcb_group_id}-${E.component.pcb_component_id}-${E.type}`,anchor:u,anchor_id:E.parentGroup.pcb_group_id,target:E.component.center,type:"component",display_offset_x:E.component.display_offset_x,display_offset_y:E.component.display_offset_y}:null:E.group.anchor_position?{id:`${E.parentGroup.pcb_group_id}-${E.group.pcb_group_id}-${E.type}`,anchor:u,anchor_id:E.parentGroup.pcb_group_id,target:E.group.anchor_position,type:"group",display_offset_x:E.group.display_offset_x,display_offset_y:E.group.display_offset_y}:null:null}).filter(E=>!!E);return W.jsx(TfA,{targets:h,transform:t,containerWidth:i,containerHeight:n})},_Ze=(e,A)=>{const t=e.pcb_component_id,i=A.filter(n=>(n.type==="pcb_smtpad"||n.type==="pcb_plated_hole")&&n.pcb_component_id===t||n.type==="pcb_hole"&&n.pcb_component_id===t);return i.length===0?LfA([e]):LfA(i)},kZe=({elements:e,highlightedPrimitives:A,transform:t,containerWidth:i,containerHeight:n})=>{const o=new Map;for(const r of A)ek(r._parent_pcb_component)&&o.set(r._parent_pcb_component.pcb_component_id,r._parent_pcb_component),ek(r._element)&&o.set(r._element.pcb_component_id,r._element);if(o.size===0)return null;const s=[];for(const r of o.values()){const a=_Ze(r,e);if(!a)continue;const g=r.positioned_relative_to_pcb_group_id??r.pcb_group_id,c=g?Gb(e).pcb_group.get(g):null;s.push({component:r,bbox:a,group:c})}return s.length===0?null:W.jsx("div",{style:{position:"absolute",left:0,top:0,width:i,height:n,overflow:"hidden",pointerEvents:"none",zIndex:fc.dimensionOverlay},children:W.jsx("svg",{style:{position:"absolute",left:0,top:0,pointerEvents:"none"},width:i,height:n,children:s.map(({component:r,bbox:a,group:g})=>{const c=qi(t,{x:a.minX,y:a.maxY}),I=qi(t,{x:a.maxX,y:a.minY}),l={x:Math.min(c.x,I.x),y:Math.min(c.y,I.y),width:Math.abs(I.x-c.x),height:Math.abs(I.y-c.y)},B=r.center??{x:(a.minX+a.maxX)/2,y:(a.minY+a.maxY)/2},C=qi(t,B);return W.jsxs("g",{children:[W.jsx("rect",{x:l.x,y:l.y,width:l.width,height:l.height,fill:"none",stroke:"white",strokeWidth:1.5,strokeDasharray:"4,4"}),W.jsx("line",{x1:C.x-6,y1:C.y,x2:C.x+6,y2:C.y,stroke:T0.COMPONENT_MARKER_STROKE,strokeWidth:1.5}),W.jsx("line",{x1:C.x,y1:C.y-6,x2:C.x,y2:C.y+6,stroke:T0.COMPONENT_MARKER_STROKE,strokeWidth:1.5}),W.jsx("circle",{cx:C.x,cy:C.y,r:zc.COMPONENT_MARKER_RADIUS,fill:T0.COMPONENT_MARKER_FILL,stroke:T0.COMPONENT_MARKER_STROKE,strokeWidth:1})]},r.pcb_component_id)})})})},FZe=({elements:e,highlightedPrimitives:A,transform:t,containerWidth:i,containerHeight:n})=>{const o=e.filter(B=>SZe(B)),s=e.filter(B=>JfA(B)),r=A.map(B=>JfA(B._element)?B._element.pcb_board_id:null).filter(B=>!!B);if(!eC(B=>B.is_showing_group_anchor_offsets)&&r.length===0)return null;const g=s.map(B=>{const C=B.pcb_panel_id,Q=B.position_mode;if(!C||Q!=="relative_to_panel_anchor")return null;const h=o.find(E=>E.pcb_panel_id===C);return h?{board:B,panel:h,type:"board"}:null}).filter(B=>!!B);if(g.length===0)return null;const c=r.length===0,I=g.filter(B=>c||r.includes(B.board.pcb_board_id));if(I.length===0)return null;const l=I.map(B=>B.board.center?{id:`${B.panel.pcb_panel_id}-${B.board.pcb_board_id}-${B.type}`,anchor:B.panel.center,anchor_id:B.panel.pcb_panel_id,target:B.board.center,type:"board",display_offset_x:B.board.display_offset_x,display_offset_y:B.board.display_offset_y}:null).filter(B=>!!B);return W.jsx(TfA,{targets:l,transform:t,containerWidth:i,containerHeight:n})},q9=e=>{if(e.length===0)return null;let A=e[0].x,t=e[0].y,i=e[0].x,n=e[0].y;for(const o of e)o.x<A&&(A=o.x),o.y<t&&(t=o.y),o.x>i&&(i=o.x),o.y>n&&(n=o.y);return{center:{x:(A+i)/2,y:(t+n)/2},width:i-A,height:n-t}},eIt=(e,A)=>{if(A.length<3)return!1;let t=!1;for(let i=0,n=A.length-1;i<A.length;n=i++){const o=A[i].x,s=A[i].y,r=A[n].x,a=A[n].y;s>e.y!=a>e.y&&e.x<(r-o)*(e.y-s)/(a-s||Number.EPSILON)+o&&(t=!t)}return t},GZe=(e,A,t)=>{const i=[];for(const n of e){if(!n._element)continue;if("x1"in n&&n._element?.type==="pcb_trace"){const r=wE({x:A.x,y:A.y},{x:n.x1,y:n.y1},{x:n.x2,y:n.y2}),a=n.width||.5,g=Math.max(a*25,2)/t.a;r<g&&i.push(n);continue}if(n.pcb_drawing_type==="polygon"){const r=n.points.map(g=>({x:he.parse(g.x),y:he.parse(g.y)})),a=q9(r);if(!a||A.x<a.center.x-a.width/2||A.x>a.center.x+a.width/2||A.y<a.center.y-a.height/2||A.y>a.center.y+a.height/2)continue;eIt(A,r)&&i.push(n);continue}if(n.pcb_drawing_type==="polygon_with_arcs"){const r=n.brep_shape.outer_ring.vertices.map(g=>({x:he.parse(g.x),y:he.parse(g.y)})),a=q9(r);if(!a||A.x<a.center.x-a.width/2||A.x>a.center.x+a.width/2||A.y<a.center.y-a.height/2||A.y>a.center.y+a.height/2)continue;eIt(A,r)&&i.push(n);continue}if(!("x"in n&&"y"in n))continue;let o=0,s=0;if("w"in n&&"h"in n)o=n.w,s=n.h;else if("r"in n)o=n.r*2,s=n.r*2;else if("rX"in n&&"rY"in n)o=n.rX*2,s=n.rY*2;else continue;Math.abs(n.x-A.x)<o/2&&Math.abs(n.y-A.y)<s/2&&i.push(n)}return i},RZe=({elements:e,children:A,transform:t,primitives:i,onMouseHoverOverPrimitives:n})=>{const[o,s]=V.useState([]),[r,a]=V.useState({x:0,y:0}),[g,{width:c,height:I}]=yJ(),l=V.useMemo(()=>{const C=[];for(const Q of o){if(Q._element?.type==="pcb_via"||Q._element?.type==="pcb_component"||Q?.layer==="drill")continue;let h=null,E=0,u=0;if(Q.pcb_drawing_type==="polygon"){const D=q9(Q.points);if(!D)continue;h=D.center,E=D.width,u=D.height}else if(Q.pcb_drawing_type==="polygon_with_arcs"){const D=Q.brep_shape.outer_ring.vertices.map(S=>({x:S.x,y:S.y})),w=q9(D);if(!w)continue;h=w.center,E=w.width,u=w.height}else"x"in Q&&"y"in Q&&(h={x:Q.x,y:Q.y},E="w"in Q?Q.w:"r"in Q?Q.r*2:"rX"in Q&&"rY"in Q?Q.rX*2:0,u="h"in Q?Q.h:"r"in Q?Q.r*2:"rX"in Q&&"rY"in Q?Q.rY*2:0);if(!h)continue;const d=qi(t,h),f={w:E*t.a,h:u*t.a},m=C.filter(D=>d.x===D.screen_x&&d.y===D.screen_y&&f.w===D.screen_w&&f.h===D.screen_h).length;C.push({...Q,x:h.x,y:h.y,w:E,h:u,screen_x:d.x,screen_y:d.y,screen_w:f.w,screen_h:f.h,same_space_index:m})}return C},[o,t]),B=(C,Q,h,E)=>{a({x:C,y:Q});const u=qi(kb(h),{x:C,y:Q}),d=GZe(E,u,h);uZe(new Set(d.map(f=>f._pcb_drawing_object_id)),new Set(o.map(f=>f._pcb_drawing_object_id)))||(s(d),n(d))};return W.jsxs("div",{ref:g,style:{position:"relative",width:"100%",height:"100%"},onMouseMove:C=>{if(t){const Q=C.currentTarget.getBoundingClientRect(),h=C.clientX-Q.left,E=C.clientY-Q.top;B(h,E,t,i)}},onTouchStart:C=>{if(t){const Q=C.touches[0],h=C.currentTarget.getBoundingClientRect(),E=Q.clientX-h.left,u=Q.clientY-h.top;B(E,u,t,i)}},children:[A,W.jsx(DZe,{elements:e,mousePos:r,highlightedPrimitives:l}),t&&W.jsxs(W.Fragment,{children:[W.jsx(bZe,{elements:e,highlightedPrimitives:l,transform:t,containerWidth:c,containerHeight:I}),W.jsx(xZe,{elements:e,highlightedPrimitives:l,transform:t,containerWidth:c,containerHeight:I}),W.jsx(kZe,{elements:e,highlightedPrimitives:l,transform:t,containerWidth:c,containerHeight:I}),W.jsx(FZe,{elements:e,highlightedPrimitives:l,transform:t,containerWidth:c,containerHeight:I})]})]})},iIt=["rgb(255, 100, 100)","rgb(100, 255, 100)","rgb(100, 100, 255)","rgb(255, 255, 100)","rgb(255, 100, 255)","rgb(100, 255, 255)","rgb(255, 150, 100)","rgb(150, 100, 255)","rgb(100, 255, 150)","rgb(255, 100, 150)"],MZe=({children:e,transform:A=_b(),elements:t=[],hoveredComponentIds:i=[]})=>{const[n,{width:o,height:s}]=yJ(),r=V.useRef(null),{is_showing_pcb_groups:a,pcb_group_view_mode:g,is_showing_group_anchor_offsets:c}=eC(I=>({is_showing_pcb_groups:I.is_showing_pcb_groups,pcb_group_view_mode:I.pcb_group_view_mode,is_showing_group_anchor_offsets:I.is_showing_group_anchor_offsets}));return V.useEffect(()=>{const I=r.current;if(!I||!o||!s)return;I.width=o,I.height=s;const l=I.getContext("2d");if(!l||(l.clearRect(0,0,o,s),!a))return;const B=t.filter(D=>D.type==="pcb_group"),C=t.filter(D=>D.type==="pcb_component"),Q=t.filter(D=>D.type==="source_group"),h=new Map(Q.map(D=>[D.source_group_id,D])),E=B.filter(D=>{if(g==="all")return!0;if(!D.source_group_id)return!1;const w=h.get(D.source_group_id);return w?w.was_automatically_named!==!0:!1}),u=new Map;Q.forEach(D=>{const w=D;if(w.parent_source_group_id){const S=u.get(w.parent_source_group_id)||[];S.push(D.source_group_id),u.set(w.parent_source_group_id,S)}});const d=D=>{const w=[],S=u.get(D)||[];for(const k of S)w.push(k),w.push(...d(k));return w},f=D=>{const w=Q.find(S=>S.source_group_id===D);return w?.parent_source_group_id?1+f(w.parent_source_group_id):0},m=new Set;if(i.length>0)for(const D of C){if(!i.includes(D.pcb_component_id))continue;const w=D.positioned_relative_to_pcb_group_id??D.pcb_group_id;w&&m.add(w)}E.forEach((D,w)=>{let S=C.filter(HA=>HA.pcb_group_id===D.pcb_group_id);if(D.source_group_id){const HA=d(D.source_group_id),ZA=B.filter(xA=>xA.source_group_id&&HA.includes(xA.source_group_id));for(const xA of ZA){const wA=C.filter(NA=>NA.pcb_group_id===xA.pcb_group_id);S=[...S,...wA]}}let k,x,N,M,L=!1;if(D.center&&D.width&&D.height){L=!0;const HA=D.width/2,ZA=D.height/2;k=D.center.x-HA,N=D.center.x+HA,x=D.center.y-ZA,M=D.center.y+ZA}else if(S.length===0||(k=1/0,x=1/0,N=-1/0,M=-1/0,S.forEach(HA=>{if(HA.center&&typeof HA.width=="number"&&typeof HA.height=="number"){const ZA=HA.center.x-HA.width/2,xA=HA.center.x+HA.width/2,wA=HA.center.y+HA.height/2,NA=HA.center.y-HA.height/2;k=Math.min(k,ZA),N=Math.max(N,xA),x=Math.min(x,NA),M=Math.max(M,wA)}}),k===1/0||N===-1/0))return;const Y=D.source_group_id?f(D.source_group_id):0,H=D.source_group_id?d(D.source_group_id).length>0:!1;if(!L){const xA=1+(H?.5:0);k-=xA,N+=xA,x-=xA,M+=xA}const O=qi(A,{x:k,y:M}),Z=qi(A,{x:N,y:M}),$=qi(A,{x:k,y:x}),eA=qi(A,{x:N,y:x}),aA=iIt[w%iIt.length];l.strokeStyle=aA,l.lineWidth=2;const tA=Math.max(4,Math.min(12,8*Math.abs(A.a))),nA=Math.max(2,Math.min(6,4*Math.abs(A.a))),lA=tA*(H?1.3:1),fA=nA;l.setLineDash([lA,fA]),l.beginPath(),l.moveTo(O.x,O.y),l.lineTo(Z.x,Z.y),l.lineTo(eA.x,eA.y),l.lineTo($.x,$.y),l.closePath(),l.stroke();const bA=Math.max(8,Math.min(12,10*Math.abs(A.a))),GA=Y==0||Y==1?0:Y*.11,YA=bA*(1-GA),QA=4,_A=D.name||`Group ${w+1}`;l.font=`${YA}px sans-serif`,l.setLineDash([]);const PA=l.measureText(_A).width+QA*2,JA=YA+QA*2,it=O.x-5,pA=O.y-5,tt=3;if(l.fillStyle="rgba(0, 0, 0, 0.8)",l.beginPath(),l.roundRect(it,pA-JA,PA,JA,tt),l.fill(),l.fillStyle=aA,l.textAlign="left",l.textBaseline="middle",l.fillText(_A,it+QA,pA-JA/2),c&&m.has(D.pcb_group_id)&&!!D.anchor_position&&D.anchor_position){const HA=Array.isArray(D.anchor_position)?{x:D.anchor_position[0]??0,y:D.anchor_position[1]??0}:{x:D.anchor_position.x,y:D.anchor_position.y},ZA=qi(A,HA);l.strokeStyle="white",l.lineWidth=1.5,l.setLineDash([]);const xA=Math.max(4,Math.min(8,6*Math.abs(A.a)));l.beginPath(),l.moveTo(ZA.x-xA,ZA.y),l.lineTo(ZA.x+xA,ZA.y),l.stroke(),l.beginPath(),l.moveTo(ZA.x,ZA.y-xA),l.lineTo(ZA.x,ZA.y+xA),l.stroke()}})},[t,A,o,s,a,g,c,i]),W.jsxs("div",{ref:n,style:{position:"relative",width:"100%",height:"100%"},children:[e,W.jsx("canvas",{ref:r,style:{position:"absolute",top:0,left:0,pointerEvents:"none",zIndex:fc.pcbGroupOverlay,display:a?"block":"none"}})]})},NZe=({transform:e,soup:A,children:t})=>{const i=eC(r=>r.is_showing_rats_nest),{netMap:n,idToNetMap:o}=V.useMemo(()=>Nct(A||[]),[A]),s=V.useMemo(()=>{if(!A||!i)return[];const r=l=>{const B=Gb(A)[l.replace(/_\d+$/,"")].get(l);return B&&"x"in B&&"y"in B?{x:B.x,y:B.y}:null},a=(l,B)=>{const C=n[B]||[];let Q=null,h=1/0;return C.forEach(E=>{const u=r(E);if(u){const d=Math.sqrt((l.x-u.x)**2+(l.y-u.y)**2);d<h&&d>0&&(h=d,Q=u)}}),Q},g=Gb(A).pcb_port.list(),c=Gb(A).source_trace.list(),I=[];return g.forEach((l,B)=>{const C=o[l.pcb_port_id];let Q=!1;for(const u of c)u.connected_source_port_ids.includes(l.source_port_id)&&u.connected_source_net_ids.length>0&&(Q=!0);if(!C)return;const h={x:l.x,y:l.y},E=a(h,C);E&&I.push({key:`${l.pcb_port_id}-${B}`,startPoint:h,endPoint:E,isInNet:Q})}),I},[A,n,o,i]);return!A||!i?t:(e||(e=_b()),W.jsxs("div",{style:{position:"relative"},children:[t,W.jsx("svg",{style:{position:"absolute",left:0,top:0,width:"100%",height:"100%",pointerEvents:"none",opacity:.5,zIndex:fc.ratsNestOverlay},children:s.map(({key:r,startPoint:a,endPoint:g,isInNet:c})=>{const I=qi(e,a),l=qi(e,g);return W.jsx("line",{x1:I.x,y1:I.y,x2:l.x,y2:l.y,stroke:"white",strokeWidth:"1",strokeDasharray:c?"6,6":void 0},r)})})]}))},vZe={version:"1.11.335"},ik=(e,A,t)=>{const i=eC(s=>s.is_mouse_over_container),n=V.useRef(i),o=V.useRef(A);V.useEffect(()=>{n.current=i},[i]),V.useEffect(()=>{o.current=A},[A]),V.useEffect(()=>{if(!e)return;const s=r=>{const a=r.target;if(a.tagName==="INPUT"||a.tagName==="TEXTAREA"||a.isContentEditable)return;const g=e.split("+"),c=g.includes("ctrl"),I=g.includes("shift"),l=g.includes("alt"),B=g.includes("meta"),C=g[g.length-1],Q=t?.current?t.current.contains(document.activeElement)||document.activeElement===t.current:!1;(n.current||Q)&&(!c||r.ctrlKey)&&(!I||r.shiftKey)&&(!l||r.altKey)&&(!B||r.metaKey)&&r.key.toLowerCase()===C.toLowerCase()&&(r.preventDefault(),o.current())};return window.addEventListener("keydown",s),()=>{window.removeEventListener("keydown",s)}},[e])},LZe=()=>{const[e,A]=V.useState(!1);return V.useEffect(()=>{const t=()=>{A(window.innerWidth<=768)};return t(),window.addEventListener("resize",t),()=>window.removeEventListener("resize",t)},[]),e},UZe=({name:e,selected:A,onClick:t})=>W.jsxs("div",{className:g1`
5473
5473
  margin-top: 2px;
5474
5474
  padding: 4px;
5475
5475
  padding-left: 8px;
@@ -5686,7 +5686,7 @@ test("${g} should solve problem correctly", () => {
5686
5686
  // Add more specific assertions based on expected output
5687
5687
  // expect(solver.netLabelPlacementSolver!.netLabelPlacements).toMatchInlineSnapshot()
5688
5688
  })
5689
- `,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 ${e.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(!t),title:`Download options for ${e.constructor.name}`,children:e.constructor.name}),t&&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"})]})]})},lIt=e=>e.activeSubSolver?[e,...lIt(e.activeSubSolver)]:[e],c9e=({solver:e})=>{const A=lIt(e);return W.jsx("div",{className:"flex gap-1 items-center text-sm pt-1",children:A.map((t,i)=>W.jsxs("div",{className:"flex items-center",children:[i>0&&W.jsx("span",{className:"text-gray-400 mx-1",children:"→"}),W.jsx(g9e,{solver:t})]},t.constructor.name))})},I9e=({solver:e,triggerRender:A,animationSpeed:t=25,onSolverStarted:i,onSolverCompleted:n})=>{const[o,s]=V.useReducer(Q=>!Q,!1),r=V.useRef(void 0),a=()=>{!e.solved&&!e.failed&&(e.step(),A())},g=()=>{!e.solved&&!e.failed&&(i&&i(e),e.solve(),A(),n&&n(e))},c=()=>{o?(r.current&&(clearInterval(r.current),r.current=void 0),s()):(s(),r.current=setInterval(()=>{if(e.solved||e.failed){r.current&&(clearInterval(r.current),r.current=void 0),s(),A(),n&&e.solved&&n(e);return}e.step(),A()},t))},I=()=>{const Q=e;if(Q.getCurrentPhase&&!e.solved&&!e.failed){const h=Q.getCurrentPhase();for(;Q.getCurrentPhase()===h&&!e.solved&&!e.failed;)e.step();A()}},l=()=>{if(e.solved||e.failed||o)return;const Q=window.prompt("Step until which iteration?",`${e.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(;e.iterations<h&&!e.solved&&!e.failed;)e.step();A(),e.solved&&n&&n(e)};V.useEffect(()=>()=>{r.current&&clearInterval(r.current)},[]),V.useEffect(()=>{(e.solved||e.failed)&&o&&(r.current&&(clearInterval(r.current),r.current=void 0),s())},[e.solved,e.failed,o]);const B=e.getCurrentPhase!==void 0,C=B?e.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(c9e,{solver:e})}),W.jsxs("div",{className:"flex gap-2 items-center flex-wrap",children:[W.jsx("button",{onClick:a,disabled:e.solved||e.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:e.solved||e.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:e.solved||e.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:e.solved||e.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:e.solved||e.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: ",e.iterations]}),e.timeToSolve!==void 0&&W.jsxs("div",{className:"text-sm text-gray-600",children:["Time: ",(e.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})]}),e.solved&&W.jsx("div",{className:"px-2 py-1 bg-green-100 text-green-800 rounded text-sm",children:"Solved"}),e.failed&&W.jsx("div",{className:"px-2 py-1 bg-red-100 text-red-800 rounded text-sm",children:"Failed"})]}),e.error&&W.jsxs("div",{className:"text-red-600 text-sm",children:["Error: ",e.error]})]})},l9e=(e,A,t)=>{const i=e.currentPipelineStepIndex;return A<i?"Completed":A===i&&e.activeSubSolver?e.activeSubSolver.failed?"Failed":"In Progress":"Not Started"},B9e=(e,A)=>{const i=e.pipelineDef[A].solverName,n=l9e(e,A),o=e[i],s=e.firstIterationOfPhase?.[i]??null,r=e.iterations;let a=0;if(n==="Completed"){const l=e.pipelineDef[A+1],B=l?e.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=e.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}},C9e=({status:e})=>{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[e]}`,children:e})},Q9e=({progress:e})=>{if(e===0)return null;const A=Math.round(e*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,"%"]})]})},h9e=e=>Object.entries(e).map(([A,t])=>`${A}: ${t}`).join(", "),E9e=({stats:e})=>{if(!e||Object.keys(e).length===0)return W.jsx("span",{children:"-"});const A=Object.entries(e),t=h9e(e);return W.jsxs("details",{className:"cursor-pointer",children:[W.jsx("summary",{className:"whitespace-nowrap overflow-hidden text-ellipsis max-w-[200px]",children:t}),W.jsx("div",{className:"mt-1 text-xs",children:A.map(([i,n])=>W.jsxs("div",{children:[i,": ",String(n)]},i))})]})},jfA=e=>{if(e===null||typeof e!="object")return e;if(Array.isArray(e))return e.map(jfA);const A={};for(const[t,i]of Object.entries(e))t.startsWith("_")||(A[t]=jfA(i));return A},u9e=(e,A)=>{try{if(typeof e.getConstructorParams!="function"){alert(`getConstructorParams() is not implemented for ${A}`);return}const t=jfA(e.getConstructorParams()),i=new Blob([JSON.stringify(t,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(t){alert(`Error downloading input for ${A}: ${t instanceof Error?t.message:String(t)}`)}},d9e=({solver:e,onStepUntilPhase:A,onDownloadInput:t})=>{const i=e.pipelineDef.map((r,a)=>B9e(e,a)),n=r=>{A?.(r)},o=r=>{r.solverInstance&&(t?t(r.solverInstance,r.name):u9e(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"||e.solved||e.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(C9e,{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(Q9e,{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(E9e,{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))})]})})]})},p9e=class extends en.Component{constructor(e){super(e),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(e){console.error("InteractiveGraphics render error:",e)}render(){return this.state.hasError?this.props.fallback:this.props.children}};function f9e({graphics:e}){const A=e.points??[],t=e.lines??[],i=e.rects??[],n=e.circles??[],o=e.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 t){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}`)),t.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 y9e=({solver:e,animationSpeed:A=25,onSolverStarted:t,onSolverCompleted:i})=>{const[n,o]=V.useReducer(c=>c+1,0),s=V.useMemo(()=>{try{return e.visualize()||{points:[],lines:[],rects:[],circles:[]}}catch(c){return console.error("Visualization error:",c),{points:[],lines:[],rects:[],circles:[]}}},[e,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=e.pipelineDef!==void 0,g=c=>{const I=e;if(!e.solved&&!e.failed){for(;!e.solved&&!e.failed&&I.currentPipelineStepIndex<=I.pipelineDef.findIndex(l=>l.solverName===c);)e.step();o()}};return W.jsxs("div",{children:[W.jsx(I9e,{solver:e,triggerRender:o,animationSpeed:A,onSolverStarted:t,onSolverCompleted:i}),r?W.jsx("div",{className:"p-4 text-gray-500",children:"No Graphics Yet"}):W.jsx(p9e,{fallback:W.jsx(f9e,{graphics:s}),children:W.jsx(a9e,{graphics:s})}),a&&W.jsx(d9e,{solver:e,onStepUntilPhase:g})]})};const m9e=()=>{V.useEffect(()=>{const e="tailwind-cdn-script";if(document.getElementById(e)||window.tailwind)return;const A=document.createElement("div");A.className="hidden",document.body.appendChild(A);const t=window.getComputedStyle(A).display==="none";if(document.body.removeChild(A),t)return;const i=document.createElement("script");i.id=e,i.src="https://cdn.tailwindcss.com",document.head.appendChild(i)},[])},w9e=e=>e.toLowerCase().includes("pack")?NMe:e.toLowerCase().includes("rout")?YMe:pMe,D9e=({solverEvents:e=[]})=>{const[A,t]=V.useState(null);m9e();const i=V.useMemo(()=>{const r=new Map;for(const a of e){const g=`${a.componentName}-${a.solverName}`;r.set(g,a)}return r},[e]),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=AoA[o.solverName];if(!r)return{instance:null,error:`Solver class "${o.solverName}" not found in SOLVERS registry. Available: ${Object.keys(AoA).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 e.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:()=>t(r),children:(()=>{const c=w9e(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(qy,{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(y9e,{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"})})})]})},BIt=({errorMessage:e,errorStack:A,circuitJsonErrors:t})=>{V.useEffect(()=>{if(e){const i=new Error(e);A&&(i.stack=A);try{J5.captureException(i)}catch{}}},[e,A]),V.useEffect(()=>{if(t&&t.length>0)for(const i of t){const n=new Error(i.message||"Circuit JSON Error");i.stack&&(n.stack=i.stack);try{J5.captureException(n,{error_type:i.type})}catch{}}},[t])},CIt="0.0.1601",S9e={version:CIt},z9=xYA()(_YA(e=>({lastRunEvalVersion:void 0,setLastRunEvalVersion:A=>{e({lastRunEvalVersion:A})}}),{name:"runframe-runner-store"})),b9e=e=>{const[A,t]=V.useState([]),[i,n]=V.useState(null),[o,s]=V.useState(""),[r,a]=c1("eval-version-selection",null),g=z9(B=>B.setLastRunEvalVersion),c=z9(B=>B.lastRunEvalVersion);return V.useEffect(()=>{e&&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)),t(C)}}).catch(()=>{})},[e]),V.useEffect(()=>{e&&(r?(window.TSCIRCUIT_LATEST_EVAL_VERSION=r,g(r)):i&&(window.TSCIRCUIT_LATEST_EVAL_VERSION=i,g(i)))},[e,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("")}}},x9e=({snippetNames:e,onSelect:A,onCancel:t,isOpen:i})=>{const[n,o]=V.useState(""),[s,r]=V.useState("");if(!i)return null;const a=e.filter(I=>I.toLowerCase().includes(s.toLowerCase())),g=s&&!e.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:t,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}`})]})]})})},_9e=e=>{const A=V.useRef(null),t=VI(i=>i.recentEvents);V.useEffect(()=>{if(t.length===0)return;const i=t[0];i.event_id!==A.current&&(e(i),A.current=i.event_id)},[t,e])};function k9e(e){const A=F9e(e),t=V.forwardRef((i,n)=>{const{children:o,...s}=i,r=V.Children.toArray(o),a=r.find(R9e);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 t.displayName=`${e}.Slot`,t}function F9e(e){const A=V.forwardRef((t,i)=>{const{children:n,...o}=t;if(V.isValidElement(n)){const s=N9e(n),r=M9e(o,n.props);return n.type!==V.Fragment&&(r.ref=i?Bf(i,s):s),V.cloneElement(n,r)}return V.Children.count(n)>1?V.Children.only(null):null});return A.displayName=`${e}.SlotClone`,A}var G9e=Symbol("radix.slottable");function R9e(e){return V.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===G9e}function M9e(e,A){const t={...A};for(const i in A){const n=e[i],o=A[i];/^on[A-Z]/.test(i)?n&&o?t[i]=(...r)=>{const a=o(...r);return n(...r),a}:n&&(t[i]=n):i==="style"?t[i]={...n,...o}:i==="className"&&(t[i]=[n,o].filter(Boolean).join(" "))}return{...e,...t}}function N9e(e){let A=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,t=A&&"isReactWarning"in A&&A.isReactWarning;return t?e.ref:(A=Object.getOwnPropertyDescriptor(e,"ref")?.get,t=A&&"isReactWarning"in A&&A.isReactWarning,t?e.props.ref:e.props.ref||e.ref)}var X9="Dialog",[QIt,hIt]=Om(X9),[v9e,pw]=QIt(X9),EIt=e=>{const{__scopeDialog:A,children:t,open:i,defaultOpen:n,onOpenChange:o,modal:s=!0}=e,r=V.useRef(null),a=V.useRef(null),[g,c]=qx({prop:i,defaultProp:n??!1,onChange:o,caller:X9});return W.jsx(v9e,{scope:A,triggerRef:r,contentRef:a,contentId:_E(),titleId:_E(),descriptionId:_E(),open:g,onOpenChange:c,onOpenToggle:V.useCallback(()=>c(I=>!I),[c]),modal:s,children:t})};EIt.displayName=X9;var uIt="DialogTrigger",dIt=V.forwardRef((e,A)=>{const{__scopeDialog:t,...i}=e,n=pw(uIt,t),o=fI(A,n.triggerRef);return W.jsx(Wa.button,{type:"button","aria-haspopup":"dialog","aria-expanded":n.open,"aria-controls":n.contentId,"data-state":$fA(n.open),...i,ref:o,onClick:Hn(e.onClick,n.onOpenToggle)})});dIt.displayName=uIt;var zfA="DialogPortal",[L9e,pIt]=QIt(zfA,{forceMount:void 0}),fIt=e=>{const{__scopeDialog:A,forceMount:t,children:i,container:n}=e,o=pw(zfA,A);return W.jsx(L9e,{scope:A,forceMount:t,children:V.Children.map(i,s=>W.jsx(w0,{present:t||o.open,children:W.jsx(VZ,{asChild:!0,container:n,children:s})}))})};fIt.displayName=zfA;var $9="DialogOverlay",yIt=V.forwardRef((e,A)=>{const t=pIt($9,e.__scopeDialog),{forceMount:i=t.forceMount,...n}=e,o=pw($9,e.__scopeDialog);return o.modal?W.jsx(w0,{present:i||o.open,children:W.jsx(H9e,{...n,ref:A})}):null});yIt.displayName=$9;var U9e=k9e("DialogOverlay.RemoveScroll"),H9e=V.forwardRef((e,A)=>{const{__scopeDialog:t,...i}=e,n=pw($9,t);return W.jsx(iV,{as:U9e,allowPinchZoom:!0,shards:[n.contentRef],children:W.jsx(Wa.div,{"data-state":$fA(n.open),...i,ref:A,style:{pointerEvents:"auto",...i.style}})})}),UG="DialogContent",mIt=V.forwardRef((e,A)=>{const t=pIt(UG,e.__scopeDialog),{forceMount:i=t.forceMount,...n}=e,o=pw(UG,e.__scopeDialog);return W.jsx(w0,{present:i||o.open,children:o.modal?W.jsx(Y9e,{...n,ref:A}):W.jsx(J9e,{...n,ref:A})})});mIt.displayName=UG;var Y9e=V.forwardRef((e,A)=>{const t=pw(UG,e.__scopeDialog),i=V.useRef(null),n=fI(A,t.contentRef,i);return V.useEffect(()=>{const o=i.current;if(o)return zuA(o)},[]),W.jsx(wIt,{...e,ref:n,trapFocus:t.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Hn(e.onCloseAutoFocus,o=>{o.preventDefault(),t.triggerRef.current?.focus()}),onPointerDownOutside:Hn(e.onPointerDownOutside,o=>{const s=o.detail.originalEvent,r=s.button===0&&s.ctrlKey===!0;(s.button===2||r)&&o.preventDefault()}),onFocusOutside:Hn(e.onFocusOutside,o=>o.preventDefault())})}),J9e=V.forwardRef((e,A)=>{const t=pw(UG,e.__scopeDialog),i=V.useRef(!1),n=V.useRef(!1);return W.jsx(wIt,{...e,ref:A,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:o=>{e.onCloseAutoFocus?.(o),o.defaultPrevented||(i.current||t.triggerRef.current?.focus(),o.preventDefault()),i.current=!1,n.current=!1},onInteractOutside:o=>{e.onInteractOutside?.(o),o.defaultPrevented||(i.current=!0,o.detail.originalEvent.type==="pointerdown"&&(n.current=!0));const s=o.target;t.triggerRef.current?.contains(s)&&o.preventDefault(),o.detail.originalEvent.type==="focusin"&&n.current&&o.preventDefault()}})}),wIt=V.forwardRef((e,A)=>{const{__scopeDialog:t,trapFocus:i,onOpenAutoFocus:n,onCloseAutoFocus:o,...s}=e,r=pw(UG,t),a=V.useRef(null),g=fI(A,a);return GuA(),W.jsxs(W.Fragment,{children:[W.jsx(vZ,{asChild:!0,loop:!0,trapped:i,onMountAutoFocus:n,onUnmountAutoFocus:o,children:W.jsx(sY,{role:"dialog",id:r.contentId,"aria-describedby":r.descriptionId,"aria-labelledby":r.titleId,"data-state":$fA(r.open),...s,ref:g,onDismiss:()=>r.onOpenChange(!1)})}),W.jsxs(W.Fragment,{children:[W.jsx(K9e,{titleId:r.titleId}),W.jsx(q9e,{contentRef:a,descriptionId:r.descriptionId})]})]})}),XfA="DialogTitle",DIt=V.forwardRef((e,A)=>{const{__scopeDialog:t,...i}=e,n=pw(XfA,t);return W.jsx(Wa.h2,{id:n.titleId,...i,ref:A})});DIt.displayName=XfA;var SIt="DialogDescription",bIt=V.forwardRef((e,A)=>{const{__scopeDialog:t,...i}=e,n=pw(SIt,t);return W.jsx(Wa.p,{id:n.descriptionId,...i,ref:A})});bIt.displayName=SIt;var xIt="DialogClose",_It=V.forwardRef((e,A)=>{const{__scopeDialog:t,...i}=e,n=pw(xIt,t);return W.jsx(Wa.button,{type:"button",...i,ref:A,onClick:Hn(e.onClick,()=>n.onOpenChange(!1))})});_It.displayName=xIt;function $fA(e){return e?"open":"closed"}var kIt="DialogTitleWarning",[T9e,FIt]=r6t(kIt,{contentName:UG,titleName:XfA,docsSlug:"dialog"}),K9e=({titleId:e})=>{const A=FIt(kIt),t=`\`${A.contentName}\` requires a \`${A.titleName}\` for the component to be accessible for screen reader users.
5689
+ `,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 ${e.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(!t),title:`Download options for ${e.constructor.name}`,children:e.constructor.name}),t&&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"})]})]})},lIt=e=>e.activeSubSolver?[e,...lIt(e.activeSubSolver)]:[e],c9e=({solver:e})=>{const A=lIt(e);return W.jsx("div",{className:"flex gap-1 items-center text-sm pt-1",children:A.map((t,i)=>W.jsxs("div",{className:"flex items-center",children:[i>0&&W.jsx("span",{className:"text-gray-400 mx-1",children:"→"}),W.jsx(g9e,{solver:t})]},t.constructor.name))})},I9e=({solver:e,triggerRender:A,animationSpeed:t=25,onSolverStarted:i,onSolverCompleted:n})=>{const[o,s]=V.useReducer(Q=>!Q,!1),r=V.useRef(void 0),a=()=>{!e.solved&&!e.failed&&(e.step(),A())},g=()=>{!e.solved&&!e.failed&&(i&&i(e),e.solve(),A(),n&&n(e))},c=()=>{o?(r.current&&(clearInterval(r.current),r.current=void 0),s()):(s(),r.current=setInterval(()=>{if(e.solved||e.failed){r.current&&(clearInterval(r.current),r.current=void 0),s(),A(),n&&e.solved&&n(e);return}e.step(),A()},t))},I=()=>{const Q=e;if(Q.getCurrentPhase&&!e.solved&&!e.failed){const h=Q.getCurrentPhase();for(;Q.getCurrentPhase()===h&&!e.solved&&!e.failed;)e.step();A()}},l=()=>{if(e.solved||e.failed||o)return;const Q=window.prompt("Step until which iteration?",`${e.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(;e.iterations<h&&!e.solved&&!e.failed;)e.step();A(),e.solved&&n&&n(e)};V.useEffect(()=>()=>{r.current&&clearInterval(r.current)},[]),V.useEffect(()=>{(e.solved||e.failed)&&o&&(r.current&&(clearInterval(r.current),r.current=void 0),s())},[e.solved,e.failed,o]);const B=e.getCurrentPhase!==void 0,C=B?e.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(c9e,{solver:e})}),W.jsxs("div",{className:"flex gap-2 items-center flex-wrap",children:[W.jsx("button",{onClick:a,disabled:e.solved||e.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:e.solved||e.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:e.solved||e.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:e.solved||e.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:e.solved||e.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: ",e.iterations]}),e.timeToSolve!==void 0&&W.jsxs("div",{className:"text-sm text-gray-600",children:["Time: ",(e.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})]}),e.solved&&W.jsx("div",{className:"px-2 py-1 bg-green-100 text-green-800 rounded text-sm",children:"Solved"}),e.failed&&W.jsx("div",{className:"px-2 py-1 bg-red-100 text-red-800 rounded text-sm",children:"Failed"})]}),e.error&&W.jsxs("div",{className:"text-red-600 text-sm",children:["Error: ",e.error]})]})},l9e=(e,A,t)=>{const i=e.currentPipelineStepIndex;return A<i?"Completed":A===i&&e.activeSubSolver?e.activeSubSolver.failed?"Failed":"In Progress":"Not Started"},B9e=(e,A)=>{const i=e.pipelineDef[A].solverName,n=l9e(e,A),o=e[i],s=e.firstIterationOfPhase?.[i]??null,r=e.iterations;let a=0;if(n==="Completed"){const l=e.pipelineDef[A+1],B=l?e.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=e.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}},C9e=({status:e})=>{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[e]}`,children:e})},Q9e=({progress:e})=>{if(e===0)return null;const A=Math.round(e*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,"%"]})]})},h9e=e=>Object.entries(e).map(([A,t])=>`${A}: ${t}`).join(", "),E9e=({stats:e})=>{if(!e||Object.keys(e).length===0)return W.jsx("span",{children:"-"});const A=Object.entries(e),t=h9e(e);return W.jsxs("details",{className:"cursor-pointer",children:[W.jsx("summary",{className:"whitespace-nowrap overflow-hidden text-ellipsis max-w-[200px]",children:t}),W.jsx("div",{className:"mt-1 text-xs",children:A.map(([i,n])=>W.jsxs("div",{children:[i,": ",String(n)]},i))})]})},jfA=e=>{if(e===null||typeof e!="object")return e;if(Array.isArray(e))return e.map(jfA);const A={};for(const[t,i]of Object.entries(e))t.startsWith("_")||(A[t]=jfA(i));return A},u9e=(e,A)=>{try{if(typeof e.getConstructorParams!="function"){alert(`getConstructorParams() is not implemented for ${A}`);return}const t=jfA(e.getConstructorParams()),i=new Blob([JSON.stringify(t,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(t){alert(`Error downloading input for ${A}: ${t instanceof Error?t.message:String(t)}`)}},d9e=({solver:e,onStepUntilPhase:A,onDownloadInput:t})=>{const i=e.pipelineDef.map((r,a)=>B9e(e,a)),n=r=>{A?.(r)},o=r=>{r.solverInstance&&(t?t(r.solverInstance,r.name):u9e(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"||e.solved||e.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(C9e,{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(Q9e,{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(E9e,{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))})]})})]})},p9e=class extends en.Component{constructor(e){super(e),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(e){console.error("InteractiveGraphics render error:",e)}render(){return this.state.hasError?this.props.fallback:this.props.children}};function f9e({graphics:e}){const A=e.points??[],t=e.lines??[],i=e.rects??[],n=e.circles??[],o=e.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 t){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}`)),t.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 y9e=({solver:e,animationSpeed:A=25,onSolverStarted:t,onSolverCompleted:i})=>{const[n,o]=V.useReducer(c=>c+1,0),s=V.useMemo(()=>{try{return e.visualize()||{points:[],lines:[],rects:[],circles:[]}}catch(c){return console.error("Visualization error:",c),{points:[],lines:[],rects:[],circles:[]}}},[e,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=e.pipelineDef!==void 0,g=c=>{const I=e;if(!e.solved&&!e.failed){for(;!e.solved&&!e.failed&&I.currentPipelineStepIndex<=I.pipelineDef.findIndex(l=>l.solverName===c);)e.step();o()}};return W.jsxs("div",{children:[W.jsx(I9e,{solver:e,triggerRender:o,animationSpeed:A,onSolverStarted:t,onSolverCompleted:i}),r?W.jsx("div",{className:"p-4 text-gray-500",children:"No Graphics Yet"}):W.jsx(p9e,{fallback:W.jsx(f9e,{graphics:s}),children:W.jsx(a9e,{graphics:s})}),a&&W.jsx(d9e,{solver:e,onStepUntilPhase:g})]})};const m9e=()=>{V.useEffect(()=>{const e="tailwind-cdn-script";if(document.getElementById(e)||window.tailwind)return;const A=document.createElement("div");A.className="hidden",document.body.appendChild(A);const t=window.getComputedStyle(A).display==="none";if(document.body.removeChild(A),t)return;const i=document.createElement("script");i.id=e,i.src="https://cdn.tailwindcss.com",document.head.appendChild(i)},[])},w9e=e=>e.toLowerCase().includes("pack")?NMe:e.toLowerCase().includes("rout")?YMe:pMe,D9e=({solverEvents:e=[]})=>{const[A,t]=V.useState(null);m9e();const i=V.useMemo(()=>{const r=new Map;for(const a of e){const g=`${a.componentName}-${a.solverName}`;r.set(g,a)}return r},[e]),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=AoA[o.solverName];if(!r)return{instance:null,error:`Solver class "${o.solverName}" not found in SOLVERS registry. Available: ${Object.keys(AoA).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 e.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:()=>t(r),children:(()=>{const c=w9e(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(qy,{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(y9e,{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"})})})]})},BIt=({errorMessage:e,errorStack:A,circuitJsonErrors:t})=>{V.useEffect(()=>{if(e){const i=new Error(e);A&&(i.stack=A);try{J5.captureException(i)}catch{}}},[e,A]),V.useEffect(()=>{if(t&&t.length>0)for(const i of t){const n=new Error(i.message||"Circuit JSON Error");i.stack&&(n.stack=i.stack);try{J5.captureException(n,{error_type:i.type})}catch{}}},[t])},CIt="0.0.1603",S9e={version:CIt},z9=xYA()(_YA(e=>({lastRunEvalVersion:void 0,setLastRunEvalVersion:A=>{e({lastRunEvalVersion:A})}}),{name:"runframe-runner-store"})),b9e=e=>{const[A,t]=V.useState([]),[i,n]=V.useState(null),[o,s]=V.useState(""),[r,a]=c1("eval-version-selection",null),g=z9(B=>B.setLastRunEvalVersion),c=z9(B=>B.lastRunEvalVersion);return V.useEffect(()=>{e&&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)),t(C)}}).catch(()=>{})},[e]),V.useEffect(()=>{e&&(r?(window.TSCIRCUIT_LATEST_EVAL_VERSION=r,g(r)):i&&(window.TSCIRCUIT_LATEST_EVAL_VERSION=i,g(i)))},[e,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("")}}},x9e=({snippetNames:e,onSelect:A,onCancel:t,isOpen:i})=>{const[n,o]=V.useState(""),[s,r]=V.useState("");if(!i)return null;const a=e.filter(I=>I.toLowerCase().includes(s.toLowerCase())),g=s&&!e.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:t,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}`})]})]})})},_9e=e=>{const A=V.useRef(null),t=VI(i=>i.recentEvents);V.useEffect(()=>{if(t.length===0)return;const i=t[0];i.event_id!==A.current&&(e(i),A.current=i.event_id)},[t,e])};function k9e(e){const A=F9e(e),t=V.forwardRef((i,n)=>{const{children:o,...s}=i,r=V.Children.toArray(o),a=r.find(R9e);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 t.displayName=`${e}.Slot`,t}function F9e(e){const A=V.forwardRef((t,i)=>{const{children:n,...o}=t;if(V.isValidElement(n)){const s=N9e(n),r=M9e(o,n.props);return n.type!==V.Fragment&&(r.ref=i?Bf(i,s):s),V.cloneElement(n,r)}return V.Children.count(n)>1?V.Children.only(null):null});return A.displayName=`${e}.SlotClone`,A}var G9e=Symbol("radix.slottable");function R9e(e){return V.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===G9e}function M9e(e,A){const t={...A};for(const i in A){const n=e[i],o=A[i];/^on[A-Z]/.test(i)?n&&o?t[i]=(...r)=>{const a=o(...r);return n(...r),a}:n&&(t[i]=n):i==="style"?t[i]={...n,...o}:i==="className"&&(t[i]=[n,o].filter(Boolean).join(" "))}return{...e,...t}}function N9e(e){let A=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,t=A&&"isReactWarning"in A&&A.isReactWarning;return t?e.ref:(A=Object.getOwnPropertyDescriptor(e,"ref")?.get,t=A&&"isReactWarning"in A&&A.isReactWarning,t?e.props.ref:e.props.ref||e.ref)}var X9="Dialog",[QIt,hIt]=Om(X9),[v9e,pw]=QIt(X9),EIt=e=>{const{__scopeDialog:A,children:t,open:i,defaultOpen:n,onOpenChange:o,modal:s=!0}=e,r=V.useRef(null),a=V.useRef(null),[g,c]=qx({prop:i,defaultProp:n??!1,onChange:o,caller:X9});return W.jsx(v9e,{scope:A,triggerRef:r,contentRef:a,contentId:_E(),titleId:_E(),descriptionId:_E(),open:g,onOpenChange:c,onOpenToggle:V.useCallback(()=>c(I=>!I),[c]),modal:s,children:t})};EIt.displayName=X9;var uIt="DialogTrigger",dIt=V.forwardRef((e,A)=>{const{__scopeDialog:t,...i}=e,n=pw(uIt,t),o=fI(A,n.triggerRef);return W.jsx(Wa.button,{type:"button","aria-haspopup":"dialog","aria-expanded":n.open,"aria-controls":n.contentId,"data-state":$fA(n.open),...i,ref:o,onClick:Hn(e.onClick,n.onOpenToggle)})});dIt.displayName=uIt;var zfA="DialogPortal",[L9e,pIt]=QIt(zfA,{forceMount:void 0}),fIt=e=>{const{__scopeDialog:A,forceMount:t,children:i,container:n}=e,o=pw(zfA,A);return W.jsx(L9e,{scope:A,forceMount:t,children:V.Children.map(i,s=>W.jsx(w0,{present:t||o.open,children:W.jsx(VZ,{asChild:!0,container:n,children:s})}))})};fIt.displayName=zfA;var $9="DialogOverlay",yIt=V.forwardRef((e,A)=>{const t=pIt($9,e.__scopeDialog),{forceMount:i=t.forceMount,...n}=e,o=pw($9,e.__scopeDialog);return o.modal?W.jsx(w0,{present:i||o.open,children:W.jsx(H9e,{...n,ref:A})}):null});yIt.displayName=$9;var U9e=k9e("DialogOverlay.RemoveScroll"),H9e=V.forwardRef((e,A)=>{const{__scopeDialog:t,...i}=e,n=pw($9,t);return W.jsx(iV,{as:U9e,allowPinchZoom:!0,shards:[n.contentRef],children:W.jsx(Wa.div,{"data-state":$fA(n.open),...i,ref:A,style:{pointerEvents:"auto",...i.style}})})}),UG="DialogContent",mIt=V.forwardRef((e,A)=>{const t=pIt(UG,e.__scopeDialog),{forceMount:i=t.forceMount,...n}=e,o=pw(UG,e.__scopeDialog);return W.jsx(w0,{present:i||o.open,children:o.modal?W.jsx(Y9e,{...n,ref:A}):W.jsx(J9e,{...n,ref:A})})});mIt.displayName=UG;var Y9e=V.forwardRef((e,A)=>{const t=pw(UG,e.__scopeDialog),i=V.useRef(null),n=fI(A,t.contentRef,i);return V.useEffect(()=>{const o=i.current;if(o)return zuA(o)},[]),W.jsx(wIt,{...e,ref:n,trapFocus:t.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Hn(e.onCloseAutoFocus,o=>{o.preventDefault(),t.triggerRef.current?.focus()}),onPointerDownOutside:Hn(e.onPointerDownOutside,o=>{const s=o.detail.originalEvent,r=s.button===0&&s.ctrlKey===!0;(s.button===2||r)&&o.preventDefault()}),onFocusOutside:Hn(e.onFocusOutside,o=>o.preventDefault())})}),J9e=V.forwardRef((e,A)=>{const t=pw(UG,e.__scopeDialog),i=V.useRef(!1),n=V.useRef(!1);return W.jsx(wIt,{...e,ref:A,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:o=>{e.onCloseAutoFocus?.(o),o.defaultPrevented||(i.current||t.triggerRef.current?.focus(),o.preventDefault()),i.current=!1,n.current=!1},onInteractOutside:o=>{e.onInteractOutside?.(o),o.defaultPrevented||(i.current=!0,o.detail.originalEvent.type==="pointerdown"&&(n.current=!0));const s=o.target;t.triggerRef.current?.contains(s)&&o.preventDefault(),o.detail.originalEvent.type==="focusin"&&n.current&&o.preventDefault()}})}),wIt=V.forwardRef((e,A)=>{const{__scopeDialog:t,trapFocus:i,onOpenAutoFocus:n,onCloseAutoFocus:o,...s}=e,r=pw(UG,t),a=V.useRef(null),g=fI(A,a);return GuA(),W.jsxs(W.Fragment,{children:[W.jsx(vZ,{asChild:!0,loop:!0,trapped:i,onMountAutoFocus:n,onUnmountAutoFocus:o,children:W.jsx(sY,{role:"dialog",id:r.contentId,"aria-describedby":r.descriptionId,"aria-labelledby":r.titleId,"data-state":$fA(r.open),...s,ref:g,onDismiss:()=>r.onOpenChange(!1)})}),W.jsxs(W.Fragment,{children:[W.jsx(K9e,{titleId:r.titleId}),W.jsx(q9e,{contentRef:a,descriptionId:r.descriptionId})]})]})}),XfA="DialogTitle",DIt=V.forwardRef((e,A)=>{const{__scopeDialog:t,...i}=e,n=pw(XfA,t);return W.jsx(Wa.h2,{id:n.titleId,...i,ref:A})});DIt.displayName=XfA;var SIt="DialogDescription",bIt=V.forwardRef((e,A)=>{const{__scopeDialog:t,...i}=e,n=pw(SIt,t);return W.jsx(Wa.p,{id:n.descriptionId,...i,ref:A})});bIt.displayName=SIt;var xIt="DialogClose",_It=V.forwardRef((e,A)=>{const{__scopeDialog:t,...i}=e,n=pw(xIt,t);return W.jsx(Wa.button,{type:"button",...i,ref:A,onClick:Hn(e.onClick,()=>n.onOpenChange(!1))})});_It.displayName=xIt;function $fA(e){return e?"open":"closed"}var kIt="DialogTitleWarning",[T9e,FIt]=r6t(kIt,{contentName:UG,titleName:XfA,docsSlug:"dialog"}),K9e=({titleId:e})=>{const A=FIt(kIt),t=`\`${A.contentName}\` requires a \`${A.titleName}\` for the component to be accessible for screen reader users.
5690
5690
 
5691
5691
  If you want to hide the \`${A.titleName}\`, you can wrap it with our VisuallyHidden component.
5692
5692
 
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.1602",
5
+ "version": "0.0.1604",
6
6
  "exports": {
7
7
  ".": "./dist/preview.js",
8
8
  "./preview": "./dist/preview.js",
@@ -49,12 +49,12 @@
49
49
  "@tscircuit/3d-viewer": "^0.0.512",
50
50
  "@tscircuit/assembly-viewer": "^0.0.5",
51
51
  "@tscircuit/create-snippet-url": "^0.0.9",
52
- "@tscircuit/eval": "^0.0.636",
52
+ "@tscircuit/eval": "^0.0.637",
53
53
  "@tscircuit/circuit-json-util": "^0.0.75",
54
54
  "@tscircuit/fake-snippets": "^0.0.163",
55
55
  "@tscircuit/file-server": "^0.0.32",
56
56
  "@tscircuit/footprinter": "^0.0.236",
57
- "@tscircuit/pcb-viewer": "1.11.335",
57
+ "@tscircuit/pcb-viewer": "1.11.336",
58
58
  "@tscircuit/props": "^0.0.455",
59
59
  "@tscircuit/schematic-trace-solver": "^0.0.40",
60
60
  "@tscircuit/schematic-viewer": "^2.0.56",