tscircuit 0.0.1083 → 0.0.1084

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.
@@ -5385,7 +5385,7 @@ $1`).replace(/>(\s*)(?=<!--\s*\/)/g,"> ")}}});function Qoe(t,A,e){if(!A||!e)retu
5385
5385
  transition: opacity 0.2s;
5386
5386
  margin-bottom: 10px;
5387
5387
  color: red;
5388
- `,fYt=({children:t,transform:A=ug(),elements:e})=>{const i=z.useRef(null),{isShowingDRCErrors:o,hoveredErrorId:n}=FC(g=>({isShowingDRCErrors:g.is_showing_drc_errors,hoveredErrorId:g.hovered_error_id}));if(!e)return O.jsx("div",{style:{position:"relative"},ref:i,children:t});const s=e.filter(g=>g.type==="pcb_trace_error"),r=e.filter(g=>g.type==="pcb_trace_error"&&g.message?.includes("Multiple components found with name")),a=new Map;return e.forEach(g=>{g.type==="pcb_port"&&a.set(g.pcb_port_id,g)}),O.jsxs("div",{style:{position:"relative"},ref:i,children:[t,s.map((g,I)=>{const{pcb_port_ids:c,pcb_trace_id:B}=g,l=c?.[0]?a.get(c[0]):void 0,C=c?.[1]?a.get(c[1]):void 0,Q=e?Ox(e).pcb_trace.get(B):void 0,E=g.pcb_trace_error_id||`error_${I}_${g.error_type}_${g.message?.slice(0,20)}`,h=n===E;if(l&&C){const u=Ie(A,{x:l.x,y:l.y}),d=Ie(A,{x:C.x,y:C.y}),f=!(isNaN(u.x)||isNaN(u.y)||isNaN(d.x)||isNaN(d.y)),w={x:(u.x+d.x)/2,y:(u.y+d.y)/2};if(isNaN(w.x)||isNaN(w.y))return null;const D=phA(w,i);return O.jsxs(z.Fragment,{children:[O.jsx(dYt,{screenPort1:u,screenPort2:d,errorCenter:w,canLineBeDrawn:f,isHighlighted:h}),O.jsx("div",{style:{position:"absolute",left:w.x-15,top:w.y-15,width:30,height:30,zIndex:zg.errorOverlay+5,cursor:"pointer",borderRadius:"50%"},onMouseEnter:S=>{const x=S.currentTarget.nextElementSibling;if(x){const F=x.querySelector(".error-message");F&&(F.style.opacity="1")}},onMouseLeave:S=>{if(!h){const x=S.currentTarget.nextElementSibling;if(x){const F=x.querySelector(".error-message");F&&(F.style.opacity="0")}}}}),O.jsx("div",{style:{position:"absolute",zIndex:h?200:100,left:D.left,top:D.top,color:h?"#ff4444":"red",textAlign:"center",fontFamily:"sans-serif",fontSize:12,display:o||h?"flex":"none",flexDirection:"column",alignItems:"center",pointerEvents:"none",transform:D.transform},children:O.jsx("div",{className:`error-message ${fhA}`,style:{opacity:h?1:0,border:`1px solid ${h?"#ff4444":"red"}`},children:g.message})})]},E)}if(Q?.route&&(o||h)){const u=Q.route.map(D=>Ie(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],w=phA(f,i);return O.jsxs(z.Fragment,{children:[O.jsx(pYt,{points:u,errorCenter:f,isHighlighted:h}),O.jsx("div",{style:{position:"absolute",left:f.x-15,top:f.y-15,width:30,height:30,zIndex:zg.errorOverlay+5,cursor:"pointer",borderRadius:"50%"},onMouseEnter:D=>{const S=D.currentTarget.nextElementSibling;if(S){const x=S.querySelector(".error-message");x&&(x.style.opacity="1")}},onMouseLeave:D=>{if(!h){const S=D.currentTarget.nextElementSibling;if(S){const x=S.querySelector(".error-message");x&&(x.style.opacity="0")}}}}),O.jsx("div",{style:{position:"absolute",zIndex:h?zg.errorOverlay+10:zg.errorOverlay+1,left:w.left,top:w.top,color:h?"#ff4444":"red",textAlign:"center",fontFamily:"sans-serif",fontSize:12,display:"flex",flexDirection:"column",alignItems:"center",pointerEvents:"none",transform:w.transform},children:O.jsx("div",{className:`error-message ${fhA}`,style:{opacity:h?1:0,border:`1px solid ${h?"#ff4444":"red"}`},children:g.message})})]},E)}return null}),r.map((g,I)=>{const c=g.component_name||g.message?.match(/name "([^"]+)"/)?.[1];if(!c)return null;const B=e?.filter(Q=>Q.type==="source_component"&&Q.name===c||Q.type==="pcb_component"&&e?.find(E=>E.type==="source_component"&&E.source_component_id===Q.source_component_id&&E.name===c))||[],l=g.pcb_trace_error_id||`error_${I}_${g.error_type}_${g.message?.slice(0,20)}`,C=n===l;return!C&&!o?null:B.map((Q,E)=>{let h={x:0,y:0};if(Q.type==="pcb_component")h=Q.center||{x:0,y:0};else if(Q.type==="source_component"){const F=e?.find(k=>k.type==="pcb_component"&&k.source_component_id===Q.source_component_id);F&&F.type==="pcb_component"&&(h=F.center||{x:0,y:0})}const u=Ie(A,h);if(isNaN(u.x)||isNaN(u.y))return null;const d=Math.abs(A.a),S=Math.max(8,Math.min(30,.5*d)),x=phA(u,i);return O.jsxs(z.Fragment,{children:[O.jsx("svg",{style:{position:"absolute",left:0,top:0,pointerEvents:"none",mixBlendMode:"difference",zIndex:zg.errorOverlay},width:"100%",height:"100%",children:C?O.jsx("polygon",{points:`${u.x},${u.y-S*1.25} ${u.x+S},${u.y} ${u.x},${u.y+S*1.25} ${u.x-S},${u.y}`,fill:"#ff4444"}):O.jsx("circle",{cx:u.x,cy:u.y,r:S,fill:"none",stroke:C?"#ff4444":"red",strokeWidth:C?Math.max(2,S*.15):Math.max(1,S*.1),opacity:1})}),O.jsx("div",{style:{position:"absolute",left:u.x-(S+10),top:u.y-(S+10),width:(S+10)*2,height:(S+10)*2,zIndex:zg.errorOverlay+5,cursor:"pointer",borderRadius:"50%"},onMouseEnter:F=>{const k=F.currentTarget.nextElementSibling;if(k){const U=k.querySelector(".error-message");U&&(U.style.opacity="1")}},onMouseLeave:F=>{if(!C){const k=F.currentTarget.nextElementSibling;if(k){const U=k.querySelector(".error-message");U&&(U.style.opacity="0")}}}}),O.jsx("div",{style:{position:"absolute",zIndex:C?zg.errorOverlay+20:zg.errorOverlay+10,left:x.left,top:x.top,color:C?"#ff4444":"red",textAlign:"center",fontFamily:"sans-serif",fontSize:12,display:o||C?"flex":"none",flexDirection:"column",alignItems:"center",pointerEvents:"none",transform:x.transform},children:O.jsx("div",{className:`error-message ${fhA}`,style:{opacity:C?1:0,border:`1px solid ${C?"#ff4444":"red"}`},children:g.message})})]},`${l}_${E}`)})})]})};function yYt(t,A){return t.size!==A.size?!1:Array.from(t).every(e=>A.has(e))}function mYt({primitiveElement:t,elements:A}){let e=t.trace_length?`${t.trace_length.toFixed(3)}`:"";const i=Ox(A).source_trace.get(t?.source_trace_id);if(i?.display_name&&(i?.max_length?e+=` / ${i.max_length}mm `:e+=" mm ",e+=`(${i.display_name})`),!e)return null;const o=t.trace_length&&i?.max_length&&t.trace_length>i.max_length;return{text:e,isOverLength:o}}function wYt(t){const{primitives:A,is_showing_multiple_traces_length:e,elements:i}=t,o=A.filter(a=>a._element.type==="pcb_trace"),n=i.filter(a=>a.type==="source_trace"),s=A.filter(a=>a._element.type!=="pcb_trace"),r=o.filter(a=>n.some(g=>a._element.type==="pcb_trace"&&a._element.source_trace_id===g.source_trace_id&&g.max_length!==void 0));if(!e)return[...s,...r];if(o.length>1){const a=o.reduce((g,I)=>{const c=g._element.trace_length;return I._element.trace_length<c?I:g},o[0]);return[...s,a]}return A}var DYt={position:"absolute",left:0,top:0,pointerEvents:"none",color:"red",fontFamily:"sans-serif",fontSize:12,textShadow:"0 0 2px black"},SYt=t=>{const{_element:A,_parent_pcb_component:e,_parent_source_component:i,_source_port:o}=t;switch(A.type){case"pcb_trace":return A.trace_length?`${A.trace_length.toFixed(3)}`:"";case"pcb_smtpad":case"pcb_plated_hole":{const n=[],s=Array.from(new Set((A.port_hints??[]).concat(o?.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?n.push(...s.map(a=>`${r}.${a}`)):n.push(...s):r&&n.push(r),n.join(", ")}default:return""}},bYt={top:"red",bottom:"aqua"},xYt=({primitive:t,mousePos:A,elements:e})=>{const[i,o]=z.useState(!1),n=t._element;z.useEffect(()=>{setTimeout(()=>{o(!0)},100)},[]);const[s,r,a,g]=[t.screen_x,t.screen_y,t.screen_w,t.screen_h],I=t.same_space_index??0,c=26,B=bYt[t?._element?.layer]??"red";let l=0;if(n.type==="pcb_smtpad"&&n?.shape==="rotated_rect"?l=n?.ccw_rotation??0:(n.type==="pcb_smtpad"&&(n?.shape==="pill"||n?.shape==="rotated_pill")&&"ccw_rotation"in t||n.type==="pcb_plated_hole"&&(n?.shape==="pill"||n?.shape==="oval")&&"ccw_rotation"in t)&&(l=n.ccw_rotation??0),n.type==="pcb_trace"){const E=mYt({primitiveElement:n,elements:e});if(!E)return null;const h=A.y-35;return O.jsx("div",{style:{zIndex:zg.elementOverlay,position:"absolute",left:A.x,top:h,color:B,pointerEvents:"none",transform:"translateX(-50%)"},children:O.jsx("div",{style:{backgroundColor:"#f2efcc",color:E.isOverLength?"red":"black",textShadow:"none",WebkitFontSmoothing:"antialiased",MozOsxFontSmoothing:"grayscale",padding:"6px 6px",borderRadius:"6px",fontSize:"14px",minWidth:"45px",textAlign:"center",whiteSpace:"nowrap"},children:E.text})})}const C=SYt(t);return C.trim().length===0?null:O.jsx("div",{style:{zIndex:zg.elementOverlay,position:"absolute",left:s-a/2-8,top:r-g/2-8,width:a+16,height:g+16,color:B,transform:`rotate(${-l}deg)`,transformOrigin:"center center"},children:O.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 ${B}`,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:O.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(${l}deg)`,minWidth:"45px",textAlign:"center"},children:C})})})},kYt=({highlightedPrimitives:t,mousePos:A,elements:e})=>{const[i,o]=FC(r=>[r.is_moving_component,r.is_showing_multiple_traces_length]),n=t.some(r=>r._element.type==="pcb_smtpad")&&t.some(r=>r._element.type==="pcb_trace");let s=t;return n&&(s=s.filter(r=>r._element.type==="pcb_smtpad")),s=wYt({primitives:s,is_showing_multiple_traces_length:o,elements:e}),O.jsx("div",{style:DYt,children:!i&&s.map((r,a)=>O.jsx(xYt,{primitive:r,mousePos:A,elements:e},a))})},Xi={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},yc={OFFSET_LINE:"white",COMPONENT_MARKER_FILL:"#66ccff",COMPONENT_MARKER_STROKE:"white",LABEL_TEXT:"white"},TM=t=>t?.type==="pcb_component",voe=t=>t?.type==="pcb_group",GYt=t=>t?.type==="pcb_panel",yhA=t=>t?.type==="pcb_board",FYt=({elements:t,highlightedPrimitives:A,transform:e,containerWidth:i,containerHeight:o})=>{const n=t.filter(u=>yhA(u)),s=t.filter(u=>TM(u)),r=t.filter(u=>voe(u)),a=A.map(u=>TM(u._parent_pcb_component)?u._parent_pcb_component.pcb_component_id:TM(u._element)?u._element.pcb_component_id:null).filter(u=>!!u),g=new Set;if(a.forEach(u=>{const d=s.find(f=>f.pcb_component_id===u);d?.pcb_group_id&&g.add(d.pcb_group_id)}),!FC(u=>u.is_showing_group_anchor_offsets)&&a.length===0)return null;const c=s.map(u=>{const d=u.positioned_relative_to_pcb_board_id;if(!d)return null;const f=n.find(w=>w.pcb_board_id===d);return f?{component:u,board:f,type:"component"}:null}).filter(u=>!!u),B=r.map(u=>{const d=u.positioned_relative_to_pcb_board_id;if(!d||!u.center)return null;const f=n.find(w=>w.pcb_board_id===d);return f?{group:u,board:f,type:"group"}:null}).filter(u=>!!u),l=[...c,...B];if(l.length===0)return null;const C=a.length===0,Q={color:yc.LABEL_TEXT,mixBlendMode:"difference",pointerEvents:"none",fontSize:Xi.LABEL_FONT_SIZE,fontFamily:"monospace",fontWeight:"bold"},E=l.filter(u=>u.type==="component"?C||a.includes(u.component.pcb_component_id):C||g.has(u.group.pcb_group_id));if(E.length===0)return null;const h=new Map;return O.jsx("div",{style:{position:"absolute",left:0,top:0,width:i,height:o,overflow:"hidden",pointerEvents:"none",zIndex:zg.dimensionOverlay},children:O.jsxs("svg",{style:{position:"absolute",left:0,top:0,pointerEvents:"none"},width:i,height:o,children:[E.map(u=>{const d=u.board.center,f=u.board.pcb_board_id;let w,D,S,x;if(u.type==="component")w=u.component.center,D=u.component.pcb_component_id,S=u.component.display_offset_x,x=u.component.display_offset_y;else{if(!u.group.center)return null;w={x:u.group.anchor_position?.x??u.group.center.x,y:u.group.anchor_position?.y??u.group.center.y},D=u.group.pcb_group_id,S=u.group.display_offset_x,x=u.group.display_offset_y}if(!h.has(f)){const rA=Ie(e,d);h.set(f,rA)}const F=h.get(f),k=Ie(e,w),U=w.x-d.x,N=w.y-d.y,Y=Math.abs(k.x-F.x),K=Math.abs(k.y-F.y),J=k.y<F.y,W=k.x>F.x,Z=J?Xi.LABEL_OFFSET_ABOVE:Xi.LABEL_OFFSET_BELOW,AA=W?Xi.LABEL_OFFSET_RIGHT:Xi.LABEL_OFFSET_LEFT,nA=Y>Xi.MIN_LINE_LENGTH_FOR_LABEL,cA=K>Xi.MIN_LINE_LENGTH_FOR_LABEL,tA=`${S??U.toFixed(2)}mm`,iA=`${x??N.toFixed(2)}mm`;return O.jsxs("g",{children:[O.jsx("line",{x1:F.x,y1:F.y,x2:k.x,y2:F.y,stroke:yc.OFFSET_LINE,strokeWidth:Xi.LINE_STROKE_WIDTH,strokeDasharray:Xi.LINE_DASH_PATTERN}),O.jsx("line",{x1:k.x,y1:F.y,x2:k.x,y2:k.y,stroke:yc.OFFSET_LINE,strokeWidth:Xi.LINE_STROKE_WIDTH,strokeDasharray:Xi.LINE_DASH_PATTERN}),u.type==="component"?O.jsx("circle",{cx:k.x,cy:k.y,r:Xi.COMPONENT_MARKER_RADIUS,fill:yc.COMPONENT_MARKER_FILL,stroke:yc.COMPONENT_MARKER_STROKE,strokeWidth:1}):O.jsxs(O.Fragment,{children:[O.jsx("line",{x1:k.x-Xi.ANCHOR_MARKER_SIZE,y1:k.y,x2:k.x+Xi.ANCHOR_MARKER_SIZE,y2:k.y,stroke:yc.OFFSET_LINE,strokeWidth:Xi.ANCHOR_MARKER_STROKE_WIDTH}),O.jsx("line",{x1:k.x,y1:k.y-Xi.ANCHOR_MARKER_SIZE,x2:k.x,y2:k.y+Xi.ANCHOR_MARKER_SIZE,stroke:yc.OFFSET_LINE,strokeWidth:Xi.ANCHOR_MARKER_STROKE_WIDTH})]}),nA&&O.jsx("foreignObject",{x:Math.min(F.x,k.x),y:F.y+Z,width:Math.abs(k.x-F.x),height:20,style:{overflow:"visible"},children:O.jsx("div",{style:{...Q,textAlign:"center"},children:tA})}),cA&&O.jsx("foreignObject",{x:k.x+AA,y:Math.min(F.y,k.y),width:Xi.Y_LABEL_MIN_WIDTH,height:Math.abs(k.y-F.y),style:{overflow:"visible"},children:O.jsx("div",{style:{...Q,display:"flex",alignItems:"center",justifyContent:W?"flex-start":"flex-end",whiteSpace:"nowrap",padding:"0 4px",height:"100%"},children:iA})})]},`${u.board.pcb_board_id}-${D}-${u.type}`)}),Array.from(h.entries()).map(([u,d])=>O.jsxs("g",{children:[O.jsx("line",{x1:d.x-Xi.ANCHOR_MARKER_SIZE,y1:d.y,x2:d.x+Xi.ANCHOR_MARKER_SIZE,y2:d.y,stroke:yc.OFFSET_LINE,strokeWidth:Xi.ANCHOR_MARKER_STROKE_WIDTH}),O.jsx("line",{x1:d.x,y1:d.y-Xi.ANCHOR_MARKER_SIZE,x2:d.x,y2:d.y+Xi.ANCHOR_MARKER_SIZE,stroke:yc.OFFSET_LINE,strokeWidth:Xi.ANCHOR_MARKER_STROKE_WIDTH})]},`anchor-${u}`))]})})},_Yt=({elements:t,highlightedPrimitives:A,transform:e,containerWidth:i,containerHeight:o})=>{const n=t.filter(u=>voe(u)),s=t.filter(u=>TM(u)),r=A.map(u=>TM(u._parent_pcb_component)?u._parent_pcb_component.pcb_component_id:TM(u._element)?u._element.pcb_component_id:null).filter(u=>!!u),a=(u,d)=>{if(d.has(u))return;d.add(u);const f=n.find(w=>w.pcb_group_id===u);f?.position_mode==="relative_to_group_anchor"&&f.positioned_relative_to_pcb_group_id&&a(f.positioned_relative_to_pcb_group_id,d)},g=new Set;if(r.forEach(u=>{const d=s.find(f=>f.pcb_component_id===u);d&&(d.position_mode==="relative_to_group_anchor"&&d.positioned_relative_to_pcb_group_id&&a(d.positioned_relative_to_pcb_group_id,g),d.pcb_group_id&&a(d.pcb_group_id,g))}),!FC(u=>u.is_showing_group_anchor_offsets)&&r.length===0)return null;const c=s.map(u=>{if(u.position_mode==="relative_to_group_anchor"&&u.positioned_relative_to_pcb_group_id){const d=n.find(f=>f.pcb_group_id===u.positioned_relative_to_pcb_group_id);return d&&d.anchor_position?{component:u,parentGroup:d,type:"component"}:null}if(u.pcb_group_id){const d=n.find(f=>f.pcb_group_id===u.pcb_group_id);return d&&d.anchor_position?{component:u,parentGroup:d,type:"component"}:null}return null}).filter(u=>!!u),B=n.map(u=>{if(u.position_mode==="relative_to_group_anchor"&&u.positioned_relative_to_pcb_group_id){const d=n.find(f=>f.pcb_group_id===u.positioned_relative_to_pcb_group_id);if(d&&d.anchor_position&&u.center)return{group:u,parentGroup:d,type:"group"}}return null}).filter(u=>!!u),l=[...c,...B];if(l.length===0)return null;const C=r.length===0,Q={color:yc.LABEL_TEXT,mixBlendMode:"difference",pointerEvents:"none",fontSize:Xi.LABEL_FONT_SIZE,fontFamily:"monospace",fontWeight:"bold"},E=l.filter(u=>u.type==="component"?C||r.includes(u.component.pcb_component_id):C||g.has(u.group.pcb_group_id)||g.has(u.parentGroup.pcb_group_id));if(E.length===0)return null;const h=new Map;return E.forEach(u=>{if(!u.parentGroup.anchor_position)return;const d=Ie(e,u.parentGroup.anchor_position);h.set(u.parentGroup.pcb_group_id,d)}),O.jsx("div",{style:{position:"absolute",left:0,top:0,width:i,height:o,overflow:"hidden",pointerEvents:"none",zIndex:zg.dimensionOverlay},children:O.jsxs("svg",{style:{position:"absolute",left:0,top:0,pointerEvents:"none"},width:i,height:o,children:[E.map(u=>{const d=u.parentGroup.anchor_position;if(!d)return null;const f={x:d.x,y:d.y};let w=null,D,S,x;if(u.type==="component"){const rA=u.component.center;if(!rA)return null;w={x:rA.x,y:rA.y},D=u.component.pcb_component_id,S=u.component.display_offset_x,x=u.component.display_offset_y}else{if(!u.group.center)return null;w={x:u.group.center.x,y:u.group.center.y},D=u.group.pcb_group_id,S=u.group.display_offset_x,x=u.group.display_offset_y}const F=w.x-f.x,k=w.y-f.y,U=Ie(e,f),N=Ie(e,w),Y=Math.abs(N.x-U.x),K=Math.abs(N.y-U.y),J=N.y<U.y,W=N.x>U.x,Z=J?Xi.LABEL_OFFSET_ABOVE:Xi.LABEL_OFFSET_BELOW,AA=W?Xi.LABEL_OFFSET_RIGHT:Xi.LABEL_OFFSET_LEFT,nA=Y>Xi.MIN_LINE_LENGTH_FOR_LABEL,cA=K>Xi.MIN_LINE_LENGTH_FOR_LABEL,tA=`Δx: ${S||F.toFixed(2)}mm`,iA=`Δy: ${x||k.toFixed(2)}mm`;return O.jsxs("g",{children:[O.jsx("line",{x1:U.x,y1:U.y,x2:N.x,y2:U.y,stroke:yc.OFFSET_LINE,strokeWidth:Xi.LINE_STROKE_WIDTH,strokeDasharray:Xi.LINE_DASH_PATTERN}),O.jsx("line",{x1:N.x,y1:U.y,x2:N.x,y2:N.y,stroke:yc.OFFSET_LINE,strokeWidth:Xi.LINE_STROKE_WIDTH,strokeDasharray:Xi.LINE_DASH_PATTERN}),u.type==="component"?O.jsx("circle",{cx:N.x,cy:N.y,r:Xi.COMPONENT_MARKER_RADIUS,fill:yc.COMPONENT_MARKER_FILL,stroke:yc.COMPONENT_MARKER_STROKE,strokeWidth:1}):O.jsxs(O.Fragment,{children:[O.jsx("line",{x1:N.x-Xi.ANCHOR_MARKER_SIZE,y1:N.y,x2:N.x+Xi.ANCHOR_MARKER_SIZE,y2:N.y,stroke:yc.OFFSET_LINE,strokeWidth:Xi.ANCHOR_MARKER_STROKE_WIDTH}),O.jsx("line",{x1:N.x,y1:N.y-Xi.ANCHOR_MARKER_SIZE,x2:N.x,y2:N.y+Xi.ANCHOR_MARKER_SIZE,stroke:yc.OFFSET_LINE,strokeWidth:Xi.ANCHOR_MARKER_STROKE_WIDTH})]}),nA&&O.jsx("foreignObject",{x:Math.min(U.x,N.x),y:U.y+Z,width:Math.abs(N.x-U.x),height:20,style:{overflow:"visible"},children:O.jsx("div",{style:{...Q,textAlign:"center"},children:tA})}),cA&&O.jsx("foreignObject",{x:N.x+AA,y:Math.min(U.y,N.y),width:20,height:Math.abs(N.y-U.y),style:{overflow:"visible"},children:O.jsx("div",{style:{...Q,display:"flex",alignItems:"center",height:"100%"},children:iA})})]},`${u.parentGroup.pcb_group_id}-${D}-${u.type}`)}),Array.from(h.entries()).map(([u,d])=>O.jsxs("g",{children:[O.jsx("line",{x1:d.x-Xi.ANCHOR_MARKER_SIZE,y1:d.y,x2:d.x+Xi.ANCHOR_MARKER_SIZE,y2:d.y,stroke:yc.OFFSET_LINE,strokeWidth:Xi.ANCHOR_MARKER_STROKE_WIDTH}),O.jsx("line",{x1:d.x,y1:d.y-Xi.ANCHOR_MARKER_SIZE,x2:d.x,y2:d.y+Xi.ANCHOR_MARKER_SIZE,stroke:yc.OFFSET_LINE,strokeWidth:Xi.ANCHOR_MARKER_STROKE_WIDTH})]},`anchor-${u}`))]})})},RYt=({elements:t,highlightedPrimitives:A,transform:e,containerWidth:i,containerHeight:o})=>{const n=t.filter(C=>GYt(C)),s=t.filter(C=>yhA(C)),r=A.map(C=>yhA(C._element)?C._element.pcb_board_id:null).filter(C=>!!C);if(!FC(C=>C.is_showing_group_anchor_offsets)&&r.length===0)return null;const g=s.map(C=>{const Q=C.pcb_panel_id,E=C.position_mode;if(!Q||E!=="relative_to_panel_anchor")return null;const h=n.find(u=>u.pcb_panel_id===Q);return h?{board:C,panel:h,type:"board"}:null}).filter(C=>!!C);if(g.length===0)return null;const I=r.length===0,c={color:yc.LABEL_TEXT,mixBlendMode:"difference",pointerEvents:"none",fontSize:Xi.LABEL_FONT_SIZE,fontFamily:"monospace",fontWeight:"bold"},B=g.filter(C=>I||r.includes(C.board.pcb_board_id));if(B.length===0)return null;const l=new Map;return O.jsx("div",{style:{position:"absolute",left:0,top:0,width:i,height:o,overflow:"hidden",pointerEvents:"none",zIndex:zg.dimensionOverlay},children:O.jsxs("svg",{style:{position:"absolute",left:0,top:0,pointerEvents:"none"},width:i,height:o,children:[B.map(C=>{const Q=C.panel.center,E=C.panel.pcb_panel_id;let h,u,d,f;if(h=C.board.center,u=C.board.pcb_board_id,d=C.board.display_offset_x,f=C.board.display_offset_y,!l.has(E)){const nA=Ie(e,Q);l.set(E,nA)}const w=l.get(E),D=Ie(e,h),S=h.x-Q.x,x=h.y-Q.y,F=Math.abs(D.x-w.x),k=Math.abs(D.y-w.y),U=D.y<w.y,N=D.x>w.x,Y=U?Xi.LABEL_OFFSET_ABOVE:Xi.LABEL_OFFSET_BELOW,K=N?Xi.LABEL_OFFSET_RIGHT:Xi.LABEL_OFFSET_LEFT,J=F>Xi.MIN_LINE_LENGTH_FOR_LABEL,W=k>Xi.MIN_LINE_LENGTH_FOR_LABEL,Z=`${d??S.toFixed(2)}mm`,AA=`${f??x.toFixed(2)}mm`;return O.jsxs("g",{children:[O.jsx("line",{x1:w.x,y1:w.y,x2:D.x,y2:w.y,stroke:yc.OFFSET_LINE,strokeWidth:Xi.LINE_STROKE_WIDTH,strokeDasharray:Xi.LINE_DASH_PATTERN}),O.jsx("line",{x1:D.x,y1:w.y,x2:D.x,y2:D.y,stroke:yc.OFFSET_LINE,strokeWidth:Xi.LINE_STROKE_WIDTH,strokeDasharray:Xi.LINE_DASH_PATTERN}),O.jsx("circle",{cx:D.x,cy:D.y,r:Xi.COMPONENT_MARKER_RADIUS,fill:yc.COMPONENT_MARKER_FILL,stroke:yc.COMPONENT_MARKER_STROKE,strokeWidth:1}),J&&O.jsx("foreignObject",{x:Math.min(w.x,D.x),y:w.y+Y,width:Math.abs(D.x-w.x),height:20,style:{overflow:"visible"},children:O.jsx("div",{style:{...c,textAlign:"center"},children:Z})}),W&&O.jsx("foreignObject",{x:D.x+K,y:Math.min(w.y,D.y),width:Xi.Y_LABEL_MIN_WIDTH,height:Math.abs(D.y-w.y),style:{overflow:"visible"},children:O.jsx("div",{style:{...c,display:"flex",alignItems:"center",justifyContent:N?"flex-start":"flex-end",whiteSpace:"nowrap",padding:"0 4px",height:"100%"},children:AA})})]},`${C.panel.pcb_panel_id}-${u}-${C.type}`)}),Array.from(l.entries()).map(([C,Q])=>O.jsxs("g",{children:[O.jsx("line",{x1:Q.x-Xi.ANCHOR_MARKER_SIZE,y1:Q.y,x2:Q.x+Xi.ANCHOR_MARKER_SIZE,y2:Q.y,stroke:yc.OFFSET_LINE,strokeWidth:Xi.ANCHOR_MARKER_STROKE_WIDTH}),O.jsx("line",{x1:Q.x,y1:Q.y-Xi.ANCHOR_MARKER_SIZE,x2:Q.x,y2:Q.y+Xi.ANCHOR_MARKER_SIZE,stroke:yc.OFFSET_LINE,strokeWidth:Xi.ANCHOR_MARKER_STROKE_WIDTH})]},`anchor-${C}`))]})})},ZW=t=>{if(t.length===0)return null;let A=t[0].x,e=t[0].y,i=t[0].x,o=t[0].y;for(const n of t)n.x<A&&(A=n.x),n.y<e&&(e=n.y),n.x>i&&(i=n.x),n.y>o&&(o=n.y);return{center:{x:(A+i)/2,y:(e+o)/2},width:i-A,height:o-e}},Uoe=(t,A)=>{if(A.length<3)return!1;let e=!1;for(let i=0,o=A.length-1;i<A.length;o=i++){const n=A[i].x,s=A[i].y,r=A[o].x,a=A[o].y;s>t.y!=a>t.y&&t.x<(r-n)*(t.y-s)/(a-s||Number.EPSILON)+n&&(e=!e)}return e},NYt=(t,A,e)=>{const i=[];for(const o of t){if(!o._element)continue;if("x1"in o&&o._element?.type==="pcb_trace"){const r=ah({x:A.x,y:A.y},{x:o.x1,y:o.y1},{x:o.x2,y:o.y2}),a=o.width||.5,g=Math.max(a*25,2)/e.a;r<g&&i.push(o);continue}if(o.pcb_drawing_type==="polygon"){const r=o.points.map(g=>({x:ut.parse(g.x),y:ut.parse(g.y)})),a=ZW(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;Uoe(A,r)&&i.push(o);continue}if(o.pcb_drawing_type==="polygon_with_arcs"){const r=o.brep_shape.outer_ring.vertices.map(g=>({x:ut.parse(g.x),y:ut.parse(g.y)})),a=ZW(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;Uoe(A,r)&&i.push(o);continue}if(!("x"in o&&"y"in o))continue;let n=0,s=0;if("w"in o&&"h"in o)n=o.w,s=o.h;else if("r"in o)n=o.r*2,s=o.r*2;else if("rX"in o&&"rY"in o)n=o.rX*2,s=o.rY*2;else continue;Math.abs(o.x-A.x)<n/2&&Math.abs(o.y-A.y)<s/2&&i.push(o)}return i},MYt=({elements:t,children:A,transform:e,primitives:i,onMouseHoverOverPrimitives:o})=>{const[n,s]=z.useState([]),[r,a]=z.useState({x:0,y:0}),[g,{width:I,height:c}]=xH(),B=z.useMemo(()=>{const C=[];for(const Q of n){if(Q._element?.type==="pcb_via"||Q._element?.type==="pcb_component"||Q?.layer==="drill")continue;let E=null,h=0,u=0;if(Q.pcb_drawing_type==="polygon"){const D=ZW(Q.points);if(!D)continue;E=D.center,h=D.width,u=D.height}else if(Q.pcb_drawing_type==="polygon_with_arcs"){const D=Q.brep_shape.outer_ring.vertices.map(x=>({x:x.x,y:x.y})),S=ZW(D);if(!S)continue;E=S.center,h=S.width,u=S.height}else"x"in Q&&"y"in Q&&(E={x:Q.x,y:Q.y},h="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(!E)continue;const d=Ie(e,E),f={w:h*e.a,h:u*e.a},w=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:E.x,y:E.y,w:h,h:u,screen_x:d.x,screen_y:d.y,screen_w:f.w,screen_h:f.h,same_space_index:w})}return C},[n,e]),l=(C,Q,E,h)=>{a({x:C,y:Q});const u=Ie(oy(E),{x:C,y:Q}),d=NYt(h,u,E);yYt(new Set(d.map(f=>f._pcb_drawing_object_id)),new Set(n.map(f=>f._pcb_drawing_object_id)))||(s(d),o(d))};return O.jsxs("div",{ref:g,style:{position:"relative",width:"100%",height:"100%"},onMouseMove:C=>{if(e){const Q=C.currentTarget.getBoundingClientRect(),E=C.clientX-Q.left,h=C.clientY-Q.top;l(E,h,e,i)}},onTouchStart:C=>{if(e){const Q=C.touches[0],E=C.currentTarget.getBoundingClientRect(),h=Q.clientX-E.left,u=Q.clientY-E.top;l(h,u,e,i)}},children:[A,O.jsx(kYt,{elements:t,mousePos:r,highlightedPrimitives:B}),e&&O.jsxs(O.Fragment,{children:[O.jsx(FYt,{elements:t,highlightedPrimitives:B,transform:e,containerWidth:I,containerHeight:c}),O.jsx(_Yt,{elements:t,highlightedPrimitives:B,transform:e,containerWidth:I,containerHeight:c}),O.jsx(RYt,{elements:t,highlightedPrimitives:B,transform:e,containerWidth:I,containerHeight:c})]})]})},Loe=["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)"],vYt=({children:t,transform:A=ug(),elements:e=[],hoveredComponentIds:i=[]})=>{const[o,{width:n,height:s}]=xH(),r=z.useRef(null),{is_showing_pcb_groups:a,pcb_group_view_mode:g,is_showing_group_anchor_offsets:I}=FC(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 z.useEffect(()=>{const c=r.current;if(!c||!n||!s)return;c.width=n,c.height=s;const B=c.getContext("2d");if(!B||(B.clearRect(0,0,n,s),!a))return;const l=e.filter(D=>D.type==="pcb_group"),C=e.filter(D=>D.type==="pcb_component"),Q=e.filter(D=>D.type==="source_group"),E=new Map(Q.map(D=>[D.source_group_id,D])),h=l.filter(D=>{if(g==="all")return!0;if(!D.source_group_id)return!1;const S=E.get(D.source_group_id);return S?S.was_automatically_named!==!0:!1}),u=new Map;Q.forEach(D=>{const S=D;if(S.parent_source_group_id){const x=u.get(S.parent_source_group_id)||[];x.push(D.source_group_id),u.set(S.parent_source_group_id,x)}});const d=D=>{const S=[],x=u.get(D)||[];for(const F of x)S.push(F),S.push(...d(F));return S},f=D=>{const S=Q.find(x=>x.source_group_id===D);return S?.parent_source_group_id?1+f(S.parent_source_group_id):0},w=new Set;if(i.length>0)for(const D of C){if(!i.includes(D.pcb_component_id))continue;const S=D.positioned_relative_to_pcb_group_id??D.pcb_group_id;S&&w.add(S)}h.forEach((D,S)=>{let x=C.filter(YA=>YA.pcb_group_id===D.pcb_group_id);if(D.source_group_id){const YA=d(D.source_group_id),jA=l.filter(RA=>RA.source_group_id&&YA.includes(RA.source_group_id));for(const RA of jA){const bA=C.filter(LA=>LA.pcb_group_id===RA.pcb_group_id);x=[...x,...bA]}}let F,k,U,N,Y=!1;if(D.center&&D.width&&D.height){Y=!0;const YA=D.width/2,jA=D.height/2;F=D.center.x-YA,U=D.center.x+YA,k=D.center.y-jA,N=D.center.y+jA}else if(x.length===0||(F=1/0,k=1/0,U=-1/0,N=-1/0,x.forEach(YA=>{if(YA.center&&typeof YA.width=="number"&&typeof YA.height=="number"){const jA=YA.center.x-YA.width/2,RA=YA.center.x+YA.width/2,bA=YA.center.y+YA.height/2,LA=YA.center.y-YA.height/2;F=Math.min(F,jA),U=Math.max(U,RA),k=Math.min(k,LA),N=Math.max(N,bA)}}),F===1/0||U===-1/0))return;const K=D.source_group_id?f(D.source_group_id):0,J=D.source_group_id?d(D.source_group_id).length>0:!1;if(!Y){const RA=1+(J?.5:0);F-=RA,U+=RA,k-=RA,N+=RA}const W=Ie(A,{x:F,y:N}),Z=Ie(A,{x:U,y:N}),AA=Ie(A,{x:F,y:k}),nA=Ie(A,{x:U,y:k}),cA=Loe[S%Loe.length];B.strokeStyle=cA,B.lineWidth=2;const tA=Math.max(4,Math.min(12,8*Math.abs(A.a))),iA=Math.max(2,Math.min(6,4*Math.abs(A.a))),CA=tA*(J?1.3:1),pA=iA;B.setLineDash([CA,pA]),B.beginPath(),B.moveTo(W.x,W.y),B.lineTo(Z.x,Z.y),B.lineTo(nA.x,nA.y),B.lineTo(AA.x,AA.y),B.closePath(),B.stroke();const kA=Math.max(8,Math.min(12,10*Math.abs(A.a))),_A=K==0||K==1?0:K*.11,TA=kA*(1-_A),gA=4,mA=D.name||`Group ${S+1}`;B.font=`${TA}px sans-serif`,B.setLineDash([]);const PA=B.measureText(mA).width+gA*2,Ae=TA+gA*2,ne=W.x-5,wA=W.y-5,OA=3;if(B.fillStyle="rgba(0, 0, 0, 0.8)",B.beginPath(),B.roundRect(ne,wA-Ae,PA,Ae,OA),B.fill(),B.fillStyle=cA,B.textAlign="left",B.textBaseline="middle",B.fillText(mA,ne+gA,wA-Ae/2),I&&w.has(D.pcb_group_id)&&!!D.anchor_position&&D.anchor_position){const YA=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},jA=Ie(A,YA);B.strokeStyle="white",B.lineWidth=1.5,B.setLineDash([]);const RA=Math.max(4,Math.min(8,6*Math.abs(A.a)));B.beginPath(),B.moveTo(jA.x-RA,jA.y),B.lineTo(jA.x+RA,jA.y),B.stroke(),B.beginPath(),B.moveTo(jA.x,jA.y-RA),B.lineTo(jA.x,jA.y+RA),B.stroke()}})},[e,A,n,s,a,g,I,i]),O.jsxs("div",{ref:o,style:{position:"relative",width:"100%",height:"100%"},children:[t,O.jsx("canvas",{ref:r,style:{position:"absolute",top:0,left:0,pointerEvents:"none",zIndex:zg.pcbGroupOverlay,display:a?"block":"none"}})]})},UYt=({transform:t,soup:A,children:e})=>{const i=FC(r=>r.is_showing_rats_nest),{netMap:o,idToNetMap:n}=z.useMemo(()=>yoe(A||[]),[A]),s=z.useMemo(()=>{if(!A||!i)return[];const r=B=>{const l=Ox(A)[B.replace(/_\d+$/,"")].get(B);return l&&"x"in l&&"y"in l?{x:l.x,y:l.y}:null},a=(B,l)=>{const C=o[l]||[];let Q=null,E=1/0;return C.forEach(h=>{const u=r(h);if(u){const d=Math.sqrt((B.x-u.x)**2+(B.y-u.y)**2);d<E&&d>0&&(E=d,Q=u)}}),Q},g=Ox(A).pcb_port.list(),I=Ox(A).source_trace.list(),c=[];return g.forEach((B,l)=>{const C=n[B.pcb_port_id];let Q=!1;for(const u of I)u.connected_source_port_ids.includes(B.source_port_id)&&u.connected_source_net_ids.length>0&&(Q=!0);if(!C)return;const E={x:B.x,y:B.y},h=a(E,C);h&&c.push({key:`${B.pcb_port_id}-${l}`,startPoint:E,endPoint:h,isInNet:Q})}),c},[A,o,n,i]);return!A||!i?e:(t||(t=ug()),O.jsxs("div",{style:{position:"relative"},children:[e,O.jsx("svg",{style:{position:"absolute",left:0,top:0,width:"100%",height:"100%",pointerEvents:"none",opacity:.5,zIndex:zg.ratsNestOverlay},children:s.map(({key:r,startPoint:a,endPoint:g,isInNet:I})=>{const c=Ie(t,a),B=Ie(t,g);return O.jsx("line",{x1:c.x,y1:c.y,x2:B.x,y2:B.y,stroke:"white",strokeWidth:"1",strokeDasharray:I?"6,6":void 0},r)})})]}))},LYt={version:"1.11.290"},Wx=(t,A)=>{const e=FC(i=>i.is_mouse_over_container);z.useEffect(()=>{if(!t||typeof A!="function")return;const i=o=>{const n=t.split("+"),s=n.includes("ctrl"),r=n.includes("shift"),a=n.includes("alt"),g=n.includes("meta"),I=n[n.length-1];e&&(!s||o.ctrlKey)&&(!r||o.shiftKey)&&(!a||o.altKey)&&(!g||o.metaKey)&&o.key.toLowerCase()===I.toLowerCase()&&(o.preventDefault(),A())};return window.addEventListener("keydown",i),()=>{window.removeEventListener("keydown",i)}},[t,A])},HYt=()=>{const[t,A]=z.useState(!1);return z.useEffect(()=>{const e=()=>{A(window.innerWidth<=768)};return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]),t},YYt=({name:t,selected:A,onClick:e})=>O.jsxs("div",{className:JM`
5388
+ `,fYt=({children:t,transform:A=ug(),elements:e})=>{const i=z.useRef(null),{isShowingDRCErrors:o,hoveredErrorId:n}=FC(g=>({isShowingDRCErrors:g.is_showing_drc_errors,hoveredErrorId:g.hovered_error_id}));if(!e)return O.jsx("div",{style:{position:"relative"},ref:i,children:t});const s=e.filter(g=>g.type==="pcb_trace_error"),r=e.filter(g=>g.type==="pcb_trace_error"&&g.message?.includes("Multiple components found with name")),a=new Map;return e.forEach(g=>{g.type==="pcb_port"&&a.set(g.pcb_port_id,g)}),O.jsxs("div",{style:{position:"relative"},ref:i,children:[t,s.map((g,I)=>{const{pcb_port_ids:c,pcb_trace_id:B}=g,l=c?.[0]?a.get(c[0]):void 0,C=c?.[1]?a.get(c[1]):void 0,Q=e?Ox(e).pcb_trace.get(B):void 0,E=g.pcb_trace_error_id||`error_${I}_${g.error_type}_${g.message?.slice(0,20)}`,h=n===E;if(l&&C){const u=Ie(A,{x:l.x,y:l.y}),d=Ie(A,{x:C.x,y:C.y}),f=!(isNaN(u.x)||isNaN(u.y)||isNaN(d.x)||isNaN(d.y)),w={x:(u.x+d.x)/2,y:(u.y+d.y)/2};if(isNaN(w.x)||isNaN(w.y))return null;const D=phA(w,i);return O.jsxs(z.Fragment,{children:[O.jsx(dYt,{screenPort1:u,screenPort2:d,errorCenter:w,canLineBeDrawn:f,isHighlighted:h}),O.jsx("div",{style:{position:"absolute",left:w.x-15,top:w.y-15,width:30,height:30,zIndex:zg.errorOverlay+5,cursor:"pointer",borderRadius:"50%"},onMouseEnter:S=>{const x=S.currentTarget.nextElementSibling;if(x){const F=x.querySelector(".error-message");F&&(F.style.opacity="1")}},onMouseLeave:S=>{if(!h){const x=S.currentTarget.nextElementSibling;if(x){const F=x.querySelector(".error-message");F&&(F.style.opacity="0")}}}}),O.jsx("div",{style:{position:"absolute",zIndex:h?200:100,left:D.left,top:D.top,color:h?"#ff4444":"red",textAlign:"center",fontFamily:"sans-serif",fontSize:12,display:o||h?"flex":"none",flexDirection:"column",alignItems:"center",pointerEvents:"none",transform:D.transform},children:O.jsx("div",{className:`error-message ${fhA}`,style:{opacity:h?1:0,border:`1px solid ${h?"#ff4444":"red"}`},children:g.message})})]},E)}if(Q?.route&&(o||h)){const u=Q.route.map(D=>Ie(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],w=phA(f,i);return O.jsxs(z.Fragment,{children:[O.jsx(pYt,{points:u,errorCenter:f,isHighlighted:h}),O.jsx("div",{style:{position:"absolute",left:f.x-15,top:f.y-15,width:30,height:30,zIndex:zg.errorOverlay+5,cursor:"pointer",borderRadius:"50%"},onMouseEnter:D=>{const S=D.currentTarget.nextElementSibling;if(S){const x=S.querySelector(".error-message");x&&(x.style.opacity="1")}},onMouseLeave:D=>{if(!h){const S=D.currentTarget.nextElementSibling;if(S){const x=S.querySelector(".error-message");x&&(x.style.opacity="0")}}}}),O.jsx("div",{style:{position:"absolute",zIndex:h?zg.errorOverlay+10:zg.errorOverlay+1,left:w.left,top:w.top,color:h?"#ff4444":"red",textAlign:"center",fontFamily:"sans-serif",fontSize:12,display:"flex",flexDirection:"column",alignItems:"center",pointerEvents:"none",transform:w.transform},children:O.jsx("div",{className:`error-message ${fhA}`,style:{opacity:h?1:0,border:`1px solid ${h?"#ff4444":"red"}`},children:g.message})})]},E)}return null}),r.map((g,I)=>{const c=g.component_name||g.message?.match(/name "([^"]+)"/)?.[1];if(!c)return null;const B=e?.filter(Q=>Q.type==="source_component"&&Q.name===c||Q.type==="pcb_component"&&e?.find(E=>E.type==="source_component"&&E.source_component_id===Q.source_component_id&&E.name===c))||[],l=g.pcb_trace_error_id||`error_${I}_${g.error_type}_${g.message?.slice(0,20)}`,C=n===l;return!C&&!o?null:B.map((Q,E)=>{let h={x:0,y:0};if(Q.type==="pcb_component")h=Q.center||{x:0,y:0};else if(Q.type==="source_component"){const F=e?.find(k=>k.type==="pcb_component"&&k.source_component_id===Q.source_component_id);F&&F.type==="pcb_component"&&(h=F.center||{x:0,y:0})}const u=Ie(A,h);if(isNaN(u.x)||isNaN(u.y))return null;const d=Math.abs(A.a),S=Math.max(8,Math.min(30,.5*d)),x=phA(u,i);return O.jsxs(z.Fragment,{children:[O.jsx("svg",{style:{position:"absolute",left:0,top:0,pointerEvents:"none",mixBlendMode:"difference",zIndex:zg.errorOverlay},width:"100%",height:"100%",children:C?O.jsx("polygon",{points:`${u.x},${u.y-S*1.25} ${u.x+S},${u.y} ${u.x},${u.y+S*1.25} ${u.x-S},${u.y}`,fill:"#ff4444"}):O.jsx("circle",{cx:u.x,cy:u.y,r:S,fill:"none",stroke:C?"#ff4444":"red",strokeWidth:C?Math.max(2,S*.15):Math.max(1,S*.1),opacity:1})}),O.jsx("div",{style:{position:"absolute",left:u.x-(S+10),top:u.y-(S+10),width:(S+10)*2,height:(S+10)*2,zIndex:zg.errorOverlay+5,cursor:"pointer",borderRadius:"50%"},onMouseEnter:F=>{const k=F.currentTarget.nextElementSibling;if(k){const U=k.querySelector(".error-message");U&&(U.style.opacity="1")}},onMouseLeave:F=>{if(!C){const k=F.currentTarget.nextElementSibling;if(k){const U=k.querySelector(".error-message");U&&(U.style.opacity="0")}}}}),O.jsx("div",{style:{position:"absolute",zIndex:C?zg.errorOverlay+20:zg.errorOverlay+10,left:x.left,top:x.top,color:C?"#ff4444":"red",textAlign:"center",fontFamily:"sans-serif",fontSize:12,display:o||C?"flex":"none",flexDirection:"column",alignItems:"center",pointerEvents:"none",transform:x.transform},children:O.jsx("div",{className:`error-message ${fhA}`,style:{opacity:C?1:0,border:`1px solid ${C?"#ff4444":"red"}`},children:g.message})})]},`${l}_${E}`)})})]})};function yYt(t,A){return t.size!==A.size?!1:Array.from(t).every(e=>A.has(e))}function mYt({primitiveElement:t,elements:A}){let e=t.trace_length?`${t.trace_length.toFixed(3)}`:"";const i=Ox(A).source_trace.get(t?.source_trace_id);if(i?.display_name&&(i?.max_length?e+=` / ${i.max_length}mm `:e+=" mm ",e+=`(${i.display_name})`),!e)return null;const o=t.trace_length&&i?.max_length&&t.trace_length>i.max_length;return{text:e,isOverLength:o}}function wYt(t){const{primitives:A,is_showing_multiple_traces_length:e,elements:i}=t,o=A.filter(a=>a._element.type==="pcb_trace"),n=i.filter(a=>a.type==="source_trace"),s=A.filter(a=>a._element.type!=="pcb_trace"),r=o.filter(a=>n.some(g=>a._element.type==="pcb_trace"&&a._element.source_trace_id===g.source_trace_id&&g.max_length!==void 0));if(!e)return[...s,...r];if(o.length>1){const a=o.reduce((g,I)=>{const c=g._element.trace_length;return I._element.trace_length<c?I:g},o[0]);return[...s,a]}return A}var DYt={position:"absolute",left:0,top:0,pointerEvents:"none",color:"red",fontFamily:"sans-serif",fontSize:12,textShadow:"0 0 2px black"},SYt=t=>{const{_element:A,_parent_pcb_component:e,_parent_source_component:i,_source_port:o}=t;switch(A.type){case"pcb_trace":return A.trace_length?`${A.trace_length.toFixed(3)}`:"";case"pcb_smtpad":case"pcb_plated_hole":{const n=[],s=Array.from(new Set((A.port_hints??[]).concat(o?.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?n.push(...s.map(a=>`${r}.${a}`)):n.push(...s):r&&n.push(r),n.join(", ")}default:return""}},bYt={top:"red",bottom:"aqua"},xYt=({primitive:t,mousePos:A,elements:e})=>{const[i,o]=z.useState(!1),n=t._element;z.useEffect(()=>{setTimeout(()=>{o(!0)},100)},[]);const[s,r,a,g]=[t.screen_x,t.screen_y,t.screen_w,t.screen_h],I=t.same_space_index??0,c=26,B=bYt[t?._element?.layer]??"red";let l=0;if(n.type==="pcb_smtpad"&&n?.shape==="rotated_rect"?l=n?.ccw_rotation??0:(n.type==="pcb_smtpad"&&(n?.shape==="pill"||n?.shape==="rotated_pill")&&"ccw_rotation"in t||n.type==="pcb_plated_hole"&&(n?.shape==="pill"||n?.shape==="oval")&&"ccw_rotation"in t)&&(l=n.ccw_rotation??0),n.type==="pcb_trace"){const E=mYt({primitiveElement:n,elements:e});if(!E)return null;const h=A.y-35;return O.jsx("div",{style:{zIndex:zg.elementOverlay,position:"absolute",left:A.x,top:h,color:B,pointerEvents:"none",transform:"translateX(-50%)"},children:O.jsx("div",{style:{backgroundColor:"#f2efcc",color:E.isOverLength?"red":"black",textShadow:"none",WebkitFontSmoothing:"antialiased",MozOsxFontSmoothing:"grayscale",padding:"6px 6px",borderRadius:"6px",fontSize:"14px",minWidth:"45px",textAlign:"center",whiteSpace:"nowrap"},children:E.text})})}const C=SYt(t);return C.trim().length===0?null:O.jsx("div",{style:{zIndex:zg.elementOverlay,position:"absolute",left:s-a/2-8,top:r-g/2-8,width:a+16,height:g+16,color:B,transform:`rotate(${-l}deg)`,transformOrigin:"center center"},children:O.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 ${B}`,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:O.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(${l}deg)`,minWidth:"45px",textAlign:"center"},children:C})})})},kYt=({highlightedPrimitives:t,mousePos:A,elements:e})=>{const[i,o]=FC(r=>[r.is_moving_component,r.is_showing_multiple_traces_length]),n=t.some(r=>r._element.type==="pcb_smtpad")&&t.some(r=>r._element.type==="pcb_trace");let s=t;return n&&(s=s.filter(r=>r._element.type==="pcb_smtpad")),s=wYt({primitives:s,is_showing_multiple_traces_length:o,elements:e}),O.jsx("div",{style:DYt,children:!i&&s.map((r,a)=>O.jsx(xYt,{primitive:r,mousePos:A,elements:e},a))})},Xi={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},yc={OFFSET_LINE:"white",COMPONENT_MARKER_FILL:"#66ccff",COMPONENT_MARKER_STROKE:"white",LABEL_TEXT:"white"},TM=t=>t?.type==="pcb_component",voe=t=>t?.type==="pcb_group",GYt=t=>t?.type==="pcb_panel",yhA=t=>t?.type==="pcb_board",FYt=({elements:t,highlightedPrimitives:A,transform:e,containerWidth:i,containerHeight:o})=>{const n=t.filter(u=>yhA(u)),s=t.filter(u=>TM(u)),r=t.filter(u=>voe(u)),a=A.map(u=>TM(u._parent_pcb_component)?u._parent_pcb_component.pcb_component_id:TM(u._element)?u._element.pcb_component_id:null).filter(u=>!!u),g=new Set;if(a.forEach(u=>{const d=s.find(f=>f.pcb_component_id===u);d?.pcb_group_id&&g.add(d.pcb_group_id)}),!FC(u=>u.is_showing_group_anchor_offsets)&&a.length===0)return null;const c=s.map(u=>{const d=u.positioned_relative_to_pcb_board_id;if(!d)return null;const f=n.find(w=>w.pcb_board_id===d);return f?{component:u,board:f,type:"component"}:null}).filter(u=>!!u),B=r.map(u=>{const d=u.positioned_relative_to_pcb_board_id;if(!d||!u.center)return null;const f=n.find(w=>w.pcb_board_id===d);return f?{group:u,board:f,type:"group"}:null}).filter(u=>!!u),l=[...c,...B];if(l.length===0)return null;const C=a.length===0,Q={color:yc.LABEL_TEXT,mixBlendMode:"difference",pointerEvents:"none",fontSize:Xi.LABEL_FONT_SIZE,fontFamily:"monospace",fontWeight:"bold"},E=l.filter(u=>u.type==="component"?C||a.includes(u.component.pcb_component_id):C||g.has(u.group.pcb_group_id));if(E.length===0)return null;const h=new Map;return O.jsx("div",{style:{position:"absolute",left:0,top:0,width:i,height:o,overflow:"hidden",pointerEvents:"none",zIndex:zg.dimensionOverlay},children:O.jsxs("svg",{style:{position:"absolute",left:0,top:0,pointerEvents:"none"},width:i,height:o,children:[E.map(u=>{const d=u.board.center,f=u.board.pcb_board_id;let w,D,S,x;if(u.type==="component")w=u.component.center,D=u.component.pcb_component_id,S=u.component.display_offset_x,x=u.component.display_offset_y;else{if(!u.group.center)return null;w={x:u.group.anchor_position?.x??u.group.center.x,y:u.group.anchor_position?.y??u.group.center.y},D=u.group.pcb_group_id,S=u.group.display_offset_x,x=u.group.display_offset_y}if(!h.has(f)){const rA=Ie(e,d);h.set(f,rA)}const F=h.get(f),k=Ie(e,w),U=w.x-d.x,N=w.y-d.y,Y=Math.abs(k.x-F.x),K=Math.abs(k.y-F.y),J=k.y<F.y,W=k.x>F.x,Z=J?Xi.LABEL_OFFSET_ABOVE:Xi.LABEL_OFFSET_BELOW,AA=W?Xi.LABEL_OFFSET_RIGHT:Xi.LABEL_OFFSET_LEFT,nA=Y>Xi.MIN_LINE_LENGTH_FOR_LABEL,cA=K>Xi.MIN_LINE_LENGTH_FOR_LABEL,tA=`${S??U.toFixed(2)}mm`,iA=`${x??N.toFixed(2)}mm`;return O.jsxs("g",{children:[O.jsx("line",{x1:F.x,y1:F.y,x2:k.x,y2:F.y,stroke:yc.OFFSET_LINE,strokeWidth:Xi.LINE_STROKE_WIDTH,strokeDasharray:Xi.LINE_DASH_PATTERN}),O.jsx("line",{x1:k.x,y1:F.y,x2:k.x,y2:k.y,stroke:yc.OFFSET_LINE,strokeWidth:Xi.LINE_STROKE_WIDTH,strokeDasharray:Xi.LINE_DASH_PATTERN}),u.type==="component"?O.jsx("circle",{cx:k.x,cy:k.y,r:Xi.COMPONENT_MARKER_RADIUS,fill:yc.COMPONENT_MARKER_FILL,stroke:yc.COMPONENT_MARKER_STROKE,strokeWidth:1}):O.jsxs(O.Fragment,{children:[O.jsx("line",{x1:k.x-Xi.ANCHOR_MARKER_SIZE,y1:k.y,x2:k.x+Xi.ANCHOR_MARKER_SIZE,y2:k.y,stroke:yc.OFFSET_LINE,strokeWidth:Xi.ANCHOR_MARKER_STROKE_WIDTH}),O.jsx("line",{x1:k.x,y1:k.y-Xi.ANCHOR_MARKER_SIZE,x2:k.x,y2:k.y+Xi.ANCHOR_MARKER_SIZE,stroke:yc.OFFSET_LINE,strokeWidth:Xi.ANCHOR_MARKER_STROKE_WIDTH})]}),nA&&O.jsx("foreignObject",{x:Math.min(F.x,k.x),y:F.y+Z,width:Math.abs(k.x-F.x),height:20,style:{overflow:"visible"},children:O.jsx("div",{style:{...Q,textAlign:"center"},children:tA})}),cA&&O.jsx("foreignObject",{x:k.x+AA,y:Math.min(F.y,k.y),width:Xi.Y_LABEL_MIN_WIDTH,height:Math.abs(k.y-F.y),style:{overflow:"visible"},children:O.jsx("div",{style:{...Q,display:"flex",alignItems:"center",justifyContent:W?"flex-start":"flex-end",whiteSpace:"nowrap",padding:"0 4px",height:"100%"},children:iA})})]},`${u.board.pcb_board_id}-${D}-${u.type}`)}),Array.from(h.entries()).map(([u,d])=>O.jsxs("g",{children:[O.jsx("line",{x1:d.x-Xi.ANCHOR_MARKER_SIZE,y1:d.y,x2:d.x+Xi.ANCHOR_MARKER_SIZE,y2:d.y,stroke:yc.OFFSET_LINE,strokeWidth:Xi.ANCHOR_MARKER_STROKE_WIDTH}),O.jsx("line",{x1:d.x,y1:d.y-Xi.ANCHOR_MARKER_SIZE,x2:d.x,y2:d.y+Xi.ANCHOR_MARKER_SIZE,stroke:yc.OFFSET_LINE,strokeWidth:Xi.ANCHOR_MARKER_STROKE_WIDTH})]},`anchor-${u}`))]})})},_Yt=({elements:t,highlightedPrimitives:A,transform:e,containerWidth:i,containerHeight:o})=>{const n=t.filter(u=>voe(u)),s=t.filter(u=>TM(u)),r=A.map(u=>TM(u._parent_pcb_component)?u._parent_pcb_component.pcb_component_id:TM(u._element)?u._element.pcb_component_id:null).filter(u=>!!u),a=(u,d)=>{if(d.has(u))return;d.add(u);const f=n.find(w=>w.pcb_group_id===u);f?.position_mode==="relative_to_group_anchor"&&f.positioned_relative_to_pcb_group_id&&a(f.positioned_relative_to_pcb_group_id,d)},g=new Set;if(r.forEach(u=>{const d=s.find(f=>f.pcb_component_id===u);d&&(d.position_mode==="relative_to_group_anchor"&&d.positioned_relative_to_pcb_group_id&&a(d.positioned_relative_to_pcb_group_id,g),d.pcb_group_id&&a(d.pcb_group_id,g))}),!FC(u=>u.is_showing_group_anchor_offsets)&&r.length===0)return null;const c=s.map(u=>{if(u.position_mode==="relative_to_group_anchor"&&u.positioned_relative_to_pcb_group_id){const d=n.find(f=>f.pcb_group_id===u.positioned_relative_to_pcb_group_id);return d&&d.anchor_position?{component:u,parentGroup:d,type:"component"}:null}if(u.pcb_group_id){const d=n.find(f=>f.pcb_group_id===u.pcb_group_id);return d&&d.anchor_position?{component:u,parentGroup:d,type:"component"}:null}return null}).filter(u=>!!u),B=n.map(u=>{if(u.position_mode==="relative_to_group_anchor"&&u.positioned_relative_to_pcb_group_id){const d=n.find(f=>f.pcb_group_id===u.positioned_relative_to_pcb_group_id);if(d&&d.anchor_position&&u.center)return{group:u,parentGroup:d,type:"group"}}return null}).filter(u=>!!u),l=[...c,...B];if(l.length===0)return null;const C=r.length===0,Q={color:yc.LABEL_TEXT,mixBlendMode:"difference",pointerEvents:"none",fontSize:Xi.LABEL_FONT_SIZE,fontFamily:"monospace",fontWeight:"bold"},E=l.filter(u=>u.type==="component"?C||r.includes(u.component.pcb_component_id):C||g.has(u.group.pcb_group_id)||g.has(u.parentGroup.pcb_group_id));if(E.length===0)return null;const h=new Map;return E.forEach(u=>{if(!u.parentGroup.anchor_position)return;const d=Ie(e,u.parentGroup.anchor_position);h.set(u.parentGroup.pcb_group_id,d)}),O.jsx("div",{style:{position:"absolute",left:0,top:0,width:i,height:o,overflow:"hidden",pointerEvents:"none",zIndex:zg.dimensionOverlay},children:O.jsxs("svg",{style:{position:"absolute",left:0,top:0,pointerEvents:"none"},width:i,height:o,children:[E.map(u=>{const d=u.parentGroup.anchor_position;if(!d)return null;const f={x:d.x,y:d.y};let w=null,D,S,x;if(u.type==="component"){const rA=u.component.center;if(!rA)return null;w={x:rA.x,y:rA.y},D=u.component.pcb_component_id,S=u.component.display_offset_x,x=u.component.display_offset_y}else{if(!u.group.center)return null;w={x:u.group.center.x,y:u.group.center.y},D=u.group.pcb_group_id,S=u.group.display_offset_x,x=u.group.display_offset_y}const F=w.x-f.x,k=w.y-f.y,U=Ie(e,f),N=Ie(e,w),Y=Math.abs(N.x-U.x),K=Math.abs(N.y-U.y),J=N.y<U.y,W=N.x>U.x,Z=J?Xi.LABEL_OFFSET_ABOVE:Xi.LABEL_OFFSET_BELOW,AA=W?Xi.LABEL_OFFSET_RIGHT:Xi.LABEL_OFFSET_LEFT,nA=Y>Xi.MIN_LINE_LENGTH_FOR_LABEL,cA=K>Xi.MIN_LINE_LENGTH_FOR_LABEL,tA=S||`${F.toFixed(2)}mm`,iA=x||`${k.toFixed(2)}mm`;return O.jsxs("g",{children:[O.jsx("line",{x1:U.x,y1:U.y,x2:N.x,y2:U.y,stroke:yc.OFFSET_LINE,strokeWidth:Xi.LINE_STROKE_WIDTH,strokeDasharray:Xi.LINE_DASH_PATTERN}),O.jsx("line",{x1:N.x,y1:U.y,x2:N.x,y2:N.y,stroke:yc.OFFSET_LINE,strokeWidth:Xi.LINE_STROKE_WIDTH,strokeDasharray:Xi.LINE_DASH_PATTERN}),u.type==="component"?O.jsx("circle",{cx:N.x,cy:N.y,r:Xi.COMPONENT_MARKER_RADIUS,fill:yc.COMPONENT_MARKER_FILL,stroke:yc.COMPONENT_MARKER_STROKE,strokeWidth:1}):O.jsxs(O.Fragment,{children:[O.jsx("line",{x1:N.x-Xi.ANCHOR_MARKER_SIZE,y1:N.y,x2:N.x+Xi.ANCHOR_MARKER_SIZE,y2:N.y,stroke:yc.OFFSET_LINE,strokeWidth:Xi.ANCHOR_MARKER_STROKE_WIDTH}),O.jsx("line",{x1:N.x,y1:N.y-Xi.ANCHOR_MARKER_SIZE,x2:N.x,y2:N.y+Xi.ANCHOR_MARKER_SIZE,stroke:yc.OFFSET_LINE,strokeWidth:Xi.ANCHOR_MARKER_STROKE_WIDTH})]}),nA&&O.jsx("foreignObject",{x:Math.min(U.x,N.x),y:U.y+Z,width:Math.abs(N.x-U.x),height:20,style:{overflow:"visible"},children:O.jsx("div",{style:{...Q,textAlign:"center"},children:tA})}),cA&&O.jsx("foreignObject",{x:N.x+AA,y:Math.min(U.y,N.y),width:20,height:Math.abs(N.y-U.y),style:{overflow:"visible"},children:O.jsx("div",{style:{...Q,display:"flex",alignItems:"center",height:"100%"},children:iA})})]},`${u.parentGroup.pcb_group_id}-${D}-${u.type}`)}),Array.from(h.entries()).map(([u,d])=>O.jsxs("g",{children:[O.jsx("line",{x1:d.x-Xi.ANCHOR_MARKER_SIZE,y1:d.y,x2:d.x+Xi.ANCHOR_MARKER_SIZE,y2:d.y,stroke:yc.OFFSET_LINE,strokeWidth:Xi.ANCHOR_MARKER_STROKE_WIDTH}),O.jsx("line",{x1:d.x,y1:d.y-Xi.ANCHOR_MARKER_SIZE,x2:d.x,y2:d.y+Xi.ANCHOR_MARKER_SIZE,stroke:yc.OFFSET_LINE,strokeWidth:Xi.ANCHOR_MARKER_STROKE_WIDTH})]},`anchor-${u}`))]})})},RYt=({elements:t,highlightedPrimitives:A,transform:e,containerWidth:i,containerHeight:o})=>{const n=t.filter(C=>GYt(C)),s=t.filter(C=>yhA(C)),r=A.map(C=>yhA(C._element)?C._element.pcb_board_id:null).filter(C=>!!C);if(!FC(C=>C.is_showing_group_anchor_offsets)&&r.length===0)return null;const g=s.map(C=>{const Q=C.pcb_panel_id,E=C.position_mode;if(!Q||E!=="relative_to_panel_anchor")return null;const h=n.find(u=>u.pcb_panel_id===Q);return h?{board:C,panel:h,type:"board"}:null}).filter(C=>!!C);if(g.length===0)return null;const I=r.length===0,c={color:yc.LABEL_TEXT,mixBlendMode:"difference",pointerEvents:"none",fontSize:Xi.LABEL_FONT_SIZE,fontFamily:"monospace",fontWeight:"bold"},B=g.filter(C=>I||r.includes(C.board.pcb_board_id));if(B.length===0)return null;const l=new Map;return O.jsx("div",{style:{position:"absolute",left:0,top:0,width:i,height:o,overflow:"hidden",pointerEvents:"none",zIndex:zg.dimensionOverlay},children:O.jsxs("svg",{style:{position:"absolute",left:0,top:0,pointerEvents:"none"},width:i,height:o,children:[B.map(C=>{const Q=C.panel.center,E=C.panel.pcb_panel_id;let h,u,d,f;if(h=C.board.center,u=C.board.pcb_board_id,d=C.board.display_offset_x,f=C.board.display_offset_y,!l.has(E)){const nA=Ie(e,Q);l.set(E,nA)}const w=l.get(E),D=Ie(e,h),S=h.x-Q.x,x=h.y-Q.y,F=Math.abs(D.x-w.x),k=Math.abs(D.y-w.y),U=D.y<w.y,N=D.x>w.x,Y=U?Xi.LABEL_OFFSET_ABOVE:Xi.LABEL_OFFSET_BELOW,K=N?Xi.LABEL_OFFSET_RIGHT:Xi.LABEL_OFFSET_LEFT,J=F>Xi.MIN_LINE_LENGTH_FOR_LABEL,W=k>Xi.MIN_LINE_LENGTH_FOR_LABEL,Z=`${d??S.toFixed(2)}mm`,AA=`${f??x.toFixed(2)}mm`;return O.jsxs("g",{children:[O.jsx("line",{x1:w.x,y1:w.y,x2:D.x,y2:w.y,stroke:yc.OFFSET_LINE,strokeWidth:Xi.LINE_STROKE_WIDTH,strokeDasharray:Xi.LINE_DASH_PATTERN}),O.jsx("line",{x1:D.x,y1:w.y,x2:D.x,y2:D.y,stroke:yc.OFFSET_LINE,strokeWidth:Xi.LINE_STROKE_WIDTH,strokeDasharray:Xi.LINE_DASH_PATTERN}),O.jsx("circle",{cx:D.x,cy:D.y,r:Xi.COMPONENT_MARKER_RADIUS,fill:yc.COMPONENT_MARKER_FILL,stroke:yc.COMPONENT_MARKER_STROKE,strokeWidth:1}),J&&O.jsx("foreignObject",{x:Math.min(w.x,D.x),y:w.y+Y,width:Math.abs(D.x-w.x),height:20,style:{overflow:"visible"},children:O.jsx("div",{style:{...c,textAlign:"center"},children:Z})}),W&&O.jsx("foreignObject",{x:D.x+K,y:Math.min(w.y,D.y),width:Xi.Y_LABEL_MIN_WIDTH,height:Math.abs(D.y-w.y),style:{overflow:"visible"},children:O.jsx("div",{style:{...c,display:"flex",alignItems:"center",justifyContent:N?"flex-start":"flex-end",whiteSpace:"nowrap",padding:"0 4px",height:"100%"},children:AA})})]},`${C.panel.pcb_panel_id}-${u}-${C.type}`)}),Array.from(l.entries()).map(([C,Q])=>O.jsxs("g",{children:[O.jsx("line",{x1:Q.x-Xi.ANCHOR_MARKER_SIZE,y1:Q.y,x2:Q.x+Xi.ANCHOR_MARKER_SIZE,y2:Q.y,stroke:yc.OFFSET_LINE,strokeWidth:Xi.ANCHOR_MARKER_STROKE_WIDTH}),O.jsx("line",{x1:Q.x,y1:Q.y-Xi.ANCHOR_MARKER_SIZE,x2:Q.x,y2:Q.y+Xi.ANCHOR_MARKER_SIZE,stroke:yc.OFFSET_LINE,strokeWidth:Xi.ANCHOR_MARKER_STROKE_WIDTH})]},`anchor-${C}`))]})})},ZW=t=>{if(t.length===0)return null;let A=t[0].x,e=t[0].y,i=t[0].x,o=t[0].y;for(const n of t)n.x<A&&(A=n.x),n.y<e&&(e=n.y),n.x>i&&(i=n.x),n.y>o&&(o=n.y);return{center:{x:(A+i)/2,y:(e+o)/2},width:i-A,height:o-e}},Uoe=(t,A)=>{if(A.length<3)return!1;let e=!1;for(let i=0,o=A.length-1;i<A.length;o=i++){const n=A[i].x,s=A[i].y,r=A[o].x,a=A[o].y;s>t.y!=a>t.y&&t.x<(r-n)*(t.y-s)/(a-s||Number.EPSILON)+n&&(e=!e)}return e},NYt=(t,A,e)=>{const i=[];for(const o of t){if(!o._element)continue;if("x1"in o&&o._element?.type==="pcb_trace"){const r=ah({x:A.x,y:A.y},{x:o.x1,y:o.y1},{x:o.x2,y:o.y2}),a=o.width||.5,g=Math.max(a*25,2)/e.a;r<g&&i.push(o);continue}if(o.pcb_drawing_type==="polygon"){const r=o.points.map(g=>({x:ut.parse(g.x),y:ut.parse(g.y)})),a=ZW(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;Uoe(A,r)&&i.push(o);continue}if(o.pcb_drawing_type==="polygon_with_arcs"){const r=o.brep_shape.outer_ring.vertices.map(g=>({x:ut.parse(g.x),y:ut.parse(g.y)})),a=ZW(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;Uoe(A,r)&&i.push(o);continue}if(!("x"in o&&"y"in o))continue;let n=0,s=0;if("w"in o&&"h"in o)n=o.w,s=o.h;else if("r"in o)n=o.r*2,s=o.r*2;else if("rX"in o&&"rY"in o)n=o.rX*2,s=o.rY*2;else continue;Math.abs(o.x-A.x)<n/2&&Math.abs(o.y-A.y)<s/2&&i.push(o)}return i},MYt=({elements:t,children:A,transform:e,primitives:i,onMouseHoverOverPrimitives:o})=>{const[n,s]=z.useState([]),[r,a]=z.useState({x:0,y:0}),[g,{width:I,height:c}]=xH(),B=z.useMemo(()=>{const C=[];for(const Q of n){if(Q._element?.type==="pcb_via"||Q._element?.type==="pcb_component"||Q?.layer==="drill")continue;let E=null,h=0,u=0;if(Q.pcb_drawing_type==="polygon"){const D=ZW(Q.points);if(!D)continue;E=D.center,h=D.width,u=D.height}else if(Q.pcb_drawing_type==="polygon_with_arcs"){const D=Q.brep_shape.outer_ring.vertices.map(x=>({x:x.x,y:x.y})),S=ZW(D);if(!S)continue;E=S.center,h=S.width,u=S.height}else"x"in Q&&"y"in Q&&(E={x:Q.x,y:Q.y},h="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(!E)continue;const d=Ie(e,E),f={w:h*e.a,h:u*e.a},w=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:E.x,y:E.y,w:h,h:u,screen_x:d.x,screen_y:d.y,screen_w:f.w,screen_h:f.h,same_space_index:w})}return C},[n,e]),l=(C,Q,E,h)=>{a({x:C,y:Q});const u=Ie(oy(E),{x:C,y:Q}),d=NYt(h,u,E);yYt(new Set(d.map(f=>f._pcb_drawing_object_id)),new Set(n.map(f=>f._pcb_drawing_object_id)))||(s(d),o(d))};return O.jsxs("div",{ref:g,style:{position:"relative",width:"100%",height:"100%"},onMouseMove:C=>{if(e){const Q=C.currentTarget.getBoundingClientRect(),E=C.clientX-Q.left,h=C.clientY-Q.top;l(E,h,e,i)}},onTouchStart:C=>{if(e){const Q=C.touches[0],E=C.currentTarget.getBoundingClientRect(),h=Q.clientX-E.left,u=Q.clientY-E.top;l(h,u,e,i)}},children:[A,O.jsx(kYt,{elements:t,mousePos:r,highlightedPrimitives:B}),e&&O.jsxs(O.Fragment,{children:[O.jsx(FYt,{elements:t,highlightedPrimitives:B,transform:e,containerWidth:I,containerHeight:c}),O.jsx(_Yt,{elements:t,highlightedPrimitives:B,transform:e,containerWidth:I,containerHeight:c}),O.jsx(RYt,{elements:t,highlightedPrimitives:B,transform:e,containerWidth:I,containerHeight:c})]})]})},Loe=["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)"],vYt=({children:t,transform:A=ug(),elements:e=[],hoveredComponentIds:i=[]})=>{const[o,{width:n,height:s}]=xH(),r=z.useRef(null),{is_showing_pcb_groups:a,pcb_group_view_mode:g,is_showing_group_anchor_offsets:I}=FC(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 z.useEffect(()=>{const c=r.current;if(!c||!n||!s)return;c.width=n,c.height=s;const B=c.getContext("2d");if(!B||(B.clearRect(0,0,n,s),!a))return;const l=e.filter(D=>D.type==="pcb_group"),C=e.filter(D=>D.type==="pcb_component"),Q=e.filter(D=>D.type==="source_group"),E=new Map(Q.map(D=>[D.source_group_id,D])),h=l.filter(D=>{if(g==="all")return!0;if(!D.source_group_id)return!1;const S=E.get(D.source_group_id);return S?S.was_automatically_named!==!0:!1}),u=new Map;Q.forEach(D=>{const S=D;if(S.parent_source_group_id){const x=u.get(S.parent_source_group_id)||[];x.push(D.source_group_id),u.set(S.parent_source_group_id,x)}});const d=D=>{const S=[],x=u.get(D)||[];for(const F of x)S.push(F),S.push(...d(F));return S},f=D=>{const S=Q.find(x=>x.source_group_id===D);return S?.parent_source_group_id?1+f(S.parent_source_group_id):0},w=new Set;if(i.length>0)for(const D of C){if(!i.includes(D.pcb_component_id))continue;const S=D.positioned_relative_to_pcb_group_id??D.pcb_group_id;S&&w.add(S)}h.forEach((D,S)=>{let x=C.filter(YA=>YA.pcb_group_id===D.pcb_group_id);if(D.source_group_id){const YA=d(D.source_group_id),jA=l.filter(RA=>RA.source_group_id&&YA.includes(RA.source_group_id));for(const RA of jA){const bA=C.filter(LA=>LA.pcb_group_id===RA.pcb_group_id);x=[...x,...bA]}}let F,k,U,N,Y=!1;if(D.center&&D.width&&D.height){Y=!0;const YA=D.width/2,jA=D.height/2;F=D.center.x-YA,U=D.center.x+YA,k=D.center.y-jA,N=D.center.y+jA}else if(x.length===0||(F=1/0,k=1/0,U=-1/0,N=-1/0,x.forEach(YA=>{if(YA.center&&typeof YA.width=="number"&&typeof YA.height=="number"){const jA=YA.center.x-YA.width/2,RA=YA.center.x+YA.width/2,bA=YA.center.y+YA.height/2,LA=YA.center.y-YA.height/2;F=Math.min(F,jA),U=Math.max(U,RA),k=Math.min(k,LA),N=Math.max(N,bA)}}),F===1/0||U===-1/0))return;const K=D.source_group_id?f(D.source_group_id):0,J=D.source_group_id?d(D.source_group_id).length>0:!1;if(!Y){const RA=1+(J?.5:0);F-=RA,U+=RA,k-=RA,N+=RA}const W=Ie(A,{x:F,y:N}),Z=Ie(A,{x:U,y:N}),AA=Ie(A,{x:F,y:k}),nA=Ie(A,{x:U,y:k}),cA=Loe[S%Loe.length];B.strokeStyle=cA,B.lineWidth=2;const tA=Math.max(4,Math.min(12,8*Math.abs(A.a))),iA=Math.max(2,Math.min(6,4*Math.abs(A.a))),CA=tA*(J?1.3:1),pA=iA;B.setLineDash([CA,pA]),B.beginPath(),B.moveTo(W.x,W.y),B.lineTo(Z.x,Z.y),B.lineTo(nA.x,nA.y),B.lineTo(AA.x,AA.y),B.closePath(),B.stroke();const kA=Math.max(8,Math.min(12,10*Math.abs(A.a))),_A=K==0||K==1?0:K*.11,TA=kA*(1-_A),gA=4,mA=D.name||`Group ${S+1}`;B.font=`${TA}px sans-serif`,B.setLineDash([]);const PA=B.measureText(mA).width+gA*2,Ae=TA+gA*2,ne=W.x-5,wA=W.y-5,OA=3;if(B.fillStyle="rgba(0, 0, 0, 0.8)",B.beginPath(),B.roundRect(ne,wA-Ae,PA,Ae,OA),B.fill(),B.fillStyle=cA,B.textAlign="left",B.textBaseline="middle",B.fillText(mA,ne+gA,wA-Ae/2),I&&w.has(D.pcb_group_id)&&!!D.anchor_position&&D.anchor_position){const YA=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},jA=Ie(A,YA);B.strokeStyle="white",B.lineWidth=1.5,B.setLineDash([]);const RA=Math.max(4,Math.min(8,6*Math.abs(A.a)));B.beginPath(),B.moveTo(jA.x-RA,jA.y),B.lineTo(jA.x+RA,jA.y),B.stroke(),B.beginPath(),B.moveTo(jA.x,jA.y-RA),B.lineTo(jA.x,jA.y+RA),B.stroke()}})},[e,A,n,s,a,g,I,i]),O.jsxs("div",{ref:o,style:{position:"relative",width:"100%",height:"100%"},children:[t,O.jsx("canvas",{ref:r,style:{position:"absolute",top:0,left:0,pointerEvents:"none",zIndex:zg.pcbGroupOverlay,display:a?"block":"none"}})]})},UYt=({transform:t,soup:A,children:e})=>{const i=FC(r=>r.is_showing_rats_nest),{netMap:o,idToNetMap:n}=z.useMemo(()=>yoe(A||[]),[A]),s=z.useMemo(()=>{if(!A||!i)return[];const r=B=>{const l=Ox(A)[B.replace(/_\d+$/,"")].get(B);return l&&"x"in l&&"y"in l?{x:l.x,y:l.y}:null},a=(B,l)=>{const C=o[l]||[];let Q=null,E=1/0;return C.forEach(h=>{const u=r(h);if(u){const d=Math.sqrt((B.x-u.x)**2+(B.y-u.y)**2);d<E&&d>0&&(E=d,Q=u)}}),Q},g=Ox(A).pcb_port.list(),I=Ox(A).source_trace.list(),c=[];return g.forEach((B,l)=>{const C=n[B.pcb_port_id];let Q=!1;for(const u of I)u.connected_source_port_ids.includes(B.source_port_id)&&u.connected_source_net_ids.length>0&&(Q=!0);if(!C)return;const E={x:B.x,y:B.y},h=a(E,C);h&&c.push({key:`${B.pcb_port_id}-${l}`,startPoint:E,endPoint:h,isInNet:Q})}),c},[A,o,n,i]);return!A||!i?e:(t||(t=ug()),O.jsxs("div",{style:{position:"relative"},children:[e,O.jsx("svg",{style:{position:"absolute",left:0,top:0,width:"100%",height:"100%",pointerEvents:"none",opacity:.5,zIndex:zg.ratsNestOverlay},children:s.map(({key:r,startPoint:a,endPoint:g,isInNet:I})=>{const c=Ie(t,a),B=Ie(t,g);return O.jsx("line",{x1:c.x,y1:c.y,x2:B.x,y2:B.y,stroke:"white",strokeWidth:"1",strokeDasharray:I?"6,6":void 0},r)})})]}))},LYt={version:"1.11.291"},Wx=(t,A)=>{const e=FC(i=>i.is_mouse_over_container);z.useEffect(()=>{if(!t||typeof A!="function")return;const i=o=>{const n=t.split("+"),s=n.includes("ctrl"),r=n.includes("shift"),a=n.includes("alt"),g=n.includes("meta"),I=n[n.length-1];e&&(!s||o.ctrlKey)&&(!r||o.shiftKey)&&(!a||o.altKey)&&(!g||o.metaKey)&&o.key.toLowerCase()===I.toLowerCase()&&(o.preventDefault(),A())};return window.addEventListener("keydown",i),()=>{window.removeEventListener("keydown",i)}},[t,A])},HYt=()=>{const[t,A]=z.useState(!1);return z.useEffect(()=>{const e=()=>{A(window.innerWidth<=768)};return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]),t},YYt=({name:t,selected:A,onClick:e})=>O.jsxs("div",{className:JM`
5389
5389
  margin-top: 2px;
5390
5390
  padding: 4px;
5391
5391
  padding-left: 8px;
@@ -5602,7 +5602,7 @@ test("${g} should solve problem correctly", () => {
5602
5602
  // Add more specific assertions based on expected output
5603
5603
  // expect(solver.netLabelPlacementSolver!.netLabelPlacements).toMatchInlineSnapshot()
5604
5604
  })
5605
- `,c=new Blob([I],{type:"text/plain"}),B=URL.createObjectURL(c),l=document.createElement("a");l.href=B,l.download=`${g}.test.ts`,l.click(),URL.revokeObjectURL(B)}catch(a){alert(`Error generating test.ts for ${t.constructor.name}: ${a instanceof Error?a.message:String(a)}`)}i(!1)};return O.jsxs("div",{className:`relative ${A}`,ref:o,children:[O.jsx("button",{className:"px-2 py-1 rounded text-xs cursor-pointer",onClick:()=>i(!e),title:`Download options for ${t.constructor.name}`,children:t.constructor.name}),e&&O.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:[O.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:n,children:"Download JSON"}),O.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:s,children:"Download page.tsx"}),O.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:r,children:"Download test.ts"})]})]})},Zoe=t=>t.activeSubSolver?[t,...Zoe(t.activeSubSolver)]:[t],lTt=({solver:t})=>{const A=Zoe(t);return O.jsx("div",{className:"flex gap-1 items-center text-sm pt-1",children:A.map((e,i)=>O.jsxs("div",{className:"flex items-center",children:[i>0&&O.jsx("span",{className:"text-gray-400 mx-1",children:"→"}),O.jsx(BTt,{solver:e})]},e.constructor.name))})},CTt=({solver:t,triggerRender:A,animationSpeed:e=25,onSolverStarted:i,onSolverCompleted:o})=>{const[n,s]=z.useReducer(Q=>!Q,!1),r=z.useRef(void 0),a=()=>{!t.solved&&!t.failed&&(t.step(),A())},g=()=>{!t.solved&&!t.failed&&(i&&i(t),t.solve(),A(),o&&o(t))},I=()=>{n?(r.current&&(clearInterval(r.current),r.current=void 0),s()):(s(),r.current=setInterval(()=>{if(t.solved||t.failed){r.current&&(clearInterval(r.current),r.current=void 0),s(),A(),o&&t.solved&&o(t);return}t.step(),A()},e))},c=()=>{const Q=t;if(Q.getCurrentPhase&&!t.solved&&!t.failed){const E=Q.getCurrentPhase();for(;Q.getCurrentPhase()===E&&!t.solved&&!t.failed;)t.step();A()}},B=()=>{if(t.solved||t.failed||n)return;const Q=window.prompt("Step until which iteration?",`${t.iterations}`);if(Q===null)return;const E=Number(Q);if(!Number.isFinite(E)){window.alert("Please enter a valid number for the iteration");return}for(;t.iterations<E&&!t.solved&&!t.failed;)t.step();A(),t.solved&&o&&o(t)};z.useEffect(()=>()=>{r.current&&clearInterval(r.current)},[]),z.useEffect(()=>{(t.solved||t.failed)&&n&&(r.current&&(clearInterval(r.current),r.current=void 0),s())},[t.solved,t.failed,n]);const l=t.getCurrentPhase!==void 0,C=l?t.getCurrentPhase():null;return O.jsxs("div",{className:"space-y-2 p-2 border-b",children:[O.jsx("div",{className:"flex items-center",children:O.jsx(lTt,{solver:t})}),O.jsxs("div",{className:"flex gap-2 items-center flex-wrap",children:[O.jsx("button",{onClick:a,disabled:t.solved||t.failed||n,className:"bg-blue-500 hover:bg-blue-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Step"}),O.jsx("button",{onClick:g,disabled:t.solved||t.failed||n,className:"bg-green-500 hover:bg-green-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Solve"}),O.jsx("button",{onClick:I,disabled:t.solved||t.failed,className:`px-3 py-1 rounded text-white text-sm ${n?"bg-red-500 hover:bg-red-600":"bg-yellow-500 hover:bg-yellow-600"} disabled:bg-gray-300`,children:n?"Stop":"Animate"}),O.jsx("button",{onClick:B,disabled:t.solved||t.failed||n,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"}),l&&O.jsx("button",{onClick:c,disabled:t.solved||t.failed||n,className:"bg-purple-500 hover:bg-purple-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Next Stage"}),O.jsxs("div",{className:"text-sm text-gray-600",children:["Iterations: ",t.iterations]}),t.timeToSolve!==void 0&&O.jsxs("div",{className:"text-sm text-gray-600",children:["Time: ",(t.timeToSolve/1e3).toFixed(3),"s"]}),C&&O.jsxs("div",{className:"text-sm text-gray-600",children:["Phase: ",O.jsx("span",{className:"font-medium",children:C})]}),t.solved&&O.jsx("div",{className:"px-2 py-1 bg-green-100 text-green-800 rounded text-sm",children:"Solved"}),t.failed&&O.jsx("div",{className:"px-2 py-1 bg-red-100 text-red-800 rounded text-sm",children:"Failed"})]}),t.error&&O.jsxs("div",{className:"text-red-600 text-sm",children:["Error: ",t.error]})]})},QTt=(t,A,e)=>{const i=t.currentPipelineStepIndex;return A<i?"Completed":A===i&&t.activeSubSolver?t.activeSubSolver.failed?"Failed":"In Progress":"Not Started"},ETt=(t,A)=>{const i=t.pipelineDef[A].solverName,o=QTt(t,A),n=t[i],s=t.firstIterationOfPhase?.[i]??null,r=t.iterations;let a=0;if(o==="Completed"){const B=t.pipelineDef[A+1],l=B?t.firstIterationOfPhase?.[B.solverName]:void 0;l!==void 0&&s!==null?a=l-s:s!==null&&(a=r-s)}else o==="In Progress"&&s!==null&&(a=r-s);const g=t.timeSpentOnPhase?.[i]??0;let I=0;o==="Completed"?I=1:o==="In Progress"&&n&&(I=n.progress??0);const c=n?.stats??null;return{index:A,name:i,status:o,firstIteration:s,iterations:a,progress:I,timeSpent:g,stats:c&&Object.keys(c).length>0?c:null,solverInstance:n??null}},hTt=({status:t})=>{const A={"Not Started":"text-blue-600","In Progress":"text-yellow-600",Completed:"text-green-600",Failed:"text-red-600"};return O.jsx("span",{className:`font-medium ${A[t]}`,children:t})},uTt=({progress:t})=>{if(t===0)return null;const A=Math.round(t*100);return O.jsxs("div",{className:"flex items-center gap-2",children:[O.jsx("div",{className:"w-20 h-2 bg-gray-200 rounded overflow-hidden",children:O.jsx("div",{className:"h-full bg-blue-500 transition-all duration-200",style:{width:`${A}%`}})}),O.jsxs("span",{className:"text-xs text-gray-500",children:[A,"%"]})]})},dTt=t=>Object.entries(t).map(([A,e])=>`${A}: ${e}`).join(", "),pTt=({stats:t})=>{if(!t||Object.keys(t).length===0)return O.jsx("span",{children:"-"});const A=Object.entries(t),e=dTt(t);return O.jsxs("details",{className:"cursor-pointer",children:[O.jsx("summary",{className:"whitespace-nowrap overflow-hidden text-ellipsis max-w-[200px]",children:e}),O.jsx("div",{className:"mt-1 text-xs",children:A.map(([i,o])=>O.jsxs("div",{children:[i,": ",String(o)]},i))})]})},GhA=t=>{if(t===null||typeof t!="object")return t;if(Array.isArray(t))return t.map(GhA);const A={};for(const[e,i]of Object.entries(t))e.startsWith("_")||(A[e]=GhA(i));return A},fTt=(t,A)=>{try{if(typeof t.getConstructorParams!="function"){alert(`getConstructorParams() is not implemented for ${A}`);return}const e=GhA(t.getConstructorParams()),i=new Blob([JSON.stringify(e,null,2)],{type:"application/json"}),o=URL.createObjectURL(i),n=document.createElement("a");n.href=o,n.download=`${A}_input.json`,n.click(),URL.revokeObjectURL(o)}catch(e){alert(`Error downloading input for ${A}: ${e instanceof Error?e.message:String(e)}`)}},yTt=({solver:t,onStepUntilPhase:A,onDownloadInput:e})=>{const i=t.pipelineDef.map((r,a)=>ETt(t,a)),o=r=>{A?.(r)},n=r=>{r.solverInstance&&(e?e(r.solverInstance,r.name):fTt(r.solverInstance,r.name))},s=r=>`${(r/1e3).toFixed(2)}s`;return O.jsxs("div",{className:"border-t border-gray-200",children:[O.jsx("div",{className:"px-4 py-2 bg-gray-50 border-b border-gray-200",children:O.jsx("h3",{className:"text-sm font-semibold text-gray-700",children:"Pipeline Steps"})}),O.jsx("div",{className:"overflow-x-auto",children:O.jsxs("table",{className:"w-full text-sm",children:[O.jsx("thead",{children:O.jsxs("tr",{className:"bg-gray-50 border-b border-gray-200",children:[O.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Step"}),O.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Status"}),O.jsxs("th",{className:"px-4 py-2 text-center font-semibold text-gray-700",children:["i",O.jsx("sub",{children:"0"})]}),O.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Iterations"}),O.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Progress"}),O.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Time"}),O.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Stats"}),O.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Input"})]})}),O.jsx("tbody",{children:i.map(r=>O.jsxs("tr",{className:`border-b border-gray-100 ${r.status==="In Progress"?"bg-yellow-50":""}`,children:[O.jsx("td",{className:"px-4 py-2",children:O.jsxs("div",{className:"flex items-center gap-2",children:[O.jsx("span",{className:"text-gray-400 w-6",children:String(r.index+1).padStart(2,"0")}),O.jsx("button",{onClick:()=>o(r.name),disabled:r.status==="Completed"||t.solved||t.failed,className:"text-blue-500 hover:text-blue-700 disabled:text-gray-300 disabled:cursor-not-allowed",title:`Step until ${r.name} completes`,children:O.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:O.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"})})}),O.jsx("span",{className:"font-medium text-gray-900",children:r.name})]})}),O.jsx("td",{className:"px-4 py-2",children:O.jsx(hTt,{status:r.status})}),O.jsx("td",{className:"px-4 py-2 text-center text-gray-600",children:r.firstIteration!==null?r.firstIteration:""}),O.jsx("td",{className:"px-4 py-2 text-gray-600",children:r.iterations}),O.jsx("td",{className:"px-4 py-2",children:O.jsx(uTt,{progress:r.progress})}),O.jsx("td",{className:"px-4 py-2 text-gray-600",children:s(r.timeSpent)}),O.jsx("td",{className:"px-4 py-2 text-gray-500",children:O.jsx(pTt,{stats:r.stats})}),O.jsx("td",{className:"px-4 py-2",children:r.solverInstance?O.jsxs("button",{onClick:()=>n(r),className:"flex items-center gap-1 text-blue-500 hover:text-blue-700",title:`Download input for ${r.name}`,children:[O.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:O.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"})}),O.jsx("span",{children:"Input"})]}):null})]},r.name))})]})})]})},mTt=class extends to.Component{constructor(t){super(t),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(t){console.error("InteractiveGraphics render error:",t)}render(){return this.state.hasError?this.props.fallback:this.props.children}};function wTt({graphics:t}){const A=t.points??[],e=t.lines??[],i=t.rects??[],o=t.circles??[],n=t.texts??[];let s=Number.POSITIVE_INFINITY,r=Number.POSITIVE_INFINITY,a=Number.NEGATIVE_INFINITY,g=Number.NEGATIVE_INFINITY;const I=(E,h)=>{typeof E=="number"&&(E<s&&(s=E),E>a&&(a=E)),typeof h=="number"&&(h<r&&(r=h),h>g&&(g=h))};for(const E of A)I(E.x,E.y);for(const E of e){const h=E.points??[];for(const u of h)I(u.x,u.y)}for(const E of i){const h=E.x??0,u=E.y??0,d=E.width??0,f=E.height??0;I(h,u),I(h+d,u+f)}for(const E of o){const h=E.x??0,u=E.y??0,d=E.radius??1;I(h-d,u-d),I(h+d,u+d)}for(const E of n)I(E.x,E.y);(!isFinite(s)||!isFinite(r)||!isFinite(a)||!isFinite(g))&&(s=-20,r=-20,a=20,g=20);const c=10,B=s-c,l=r-c,C=Math.max(1,a-s+2*c),Q=Math.max(1,g-r+2*c);return O.jsxs("svg",{className:"w-full h-[400px] bg-white",viewBox:`${B} ${l} ${C} ${Q}`,role:"img","aria-label":"Graphics fallback",children:[i.map((E,h)=>O.jsx("rect",{x:E.x??0,y:E.y??0,width:E.width??0,height:E.height??0,fill:"none",stroke:E.strokeColor??"black",strokeWidth:E.strokeWidth??1},`rect-${h}`)),e.map((E,h)=>O.jsx("polyline",{fill:"none",stroke:E.strokeColor??"black",strokeWidth:E.strokeWidth??1,points:(E.points??[]).map(u=>`${u.x??0},${u.y??0}`).join(" ")},`line-${h}`)),o.map((E,h)=>O.jsx("circle",{cx:E.x??0,cy:E.y??0,r:E.radius??1.5,fill:E.fillColor??"none",stroke:E.strokeColor??"black",strokeWidth:E.strokeWidth??1},`circle-${h}`)),A.map((E,h)=>O.jsx("circle",{cx:E.x??0,cy:E.y??0,r:E.radius??1.5,fill:E.color??"black"},`point-${h}`)),n.map((E,h)=>O.jsx("text",{x:E.x??0,y:E.y??0,fontSize:E.fontSize??10,fill:E.color??"black",children:E.text??""},`text-${h}`))]})}var DTt=({solver:t,animationSpeed:A=25,onSolverStarted:e,onSolverCompleted:i})=>{const[o,n]=z.useReducer(I=>I+1,0),s=z.useMemo(()=>{try{return t.visualize()||{points:[],lines:[],rects:[],circles:[]}}catch(I){return console.error("Visualization error:",I),{points:[],lines:[],rects:[],circles:[]}}},[t,o]),r=z.useMemo(()=>(s.rects?.length||0)===0&&(s.lines?.length||0)===0&&(s.points?.length||0)===0&&(s.circles?.length||0)===0,[s]);z.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=t.pipelineDef!==void 0,g=I=>{const c=t;if(!t.solved&&!t.failed){for(;!t.solved&&!t.failed&&c.currentPipelineStepIndex<=c.pipelineDef.findIndex(B=>B.solverName===I);)t.step();n()}};return O.jsxs("div",{children:[O.jsx(CTt,{solver:t,triggerRender:n,animationSpeed:A,onSolverStarted:e,onSolverCompleted:i}),r?O.jsx("div",{className:"p-4 text-gray-500",children:"No Graphics Yet"}):O.jsx(mTt,{fallback:O.jsx(wTt,{graphics:s}),children:O.jsx(cTt,{graphics:s})}),a&&O.jsx(yTt,{solver:t,onStepUntilPhase:g})]})};const STt=()=>{z.useEffect(()=>{const t="tailwind-cdn-script";if(document.getElementById(t)||window.tailwind)return;const A=document.createElement("div");A.className="hidden",document.body.appendChild(A);const e=window.getComputedStyle(A).display==="none";if(document.body.removeChild(A),e)return;const i=document.createElement("script");i.id=t,i.src="https://cdn.tailwindcss.com",document.head.appendChild(i)},[])},bTt=t=>t.toLowerCase().includes("pack")?PSt:t.toLowerCase().includes("rout")?jSt:xSt,xTt=({solverEvents:t=[]})=>{const[A,e]=z.useState(null);STt();const i=z.useMemo(()=>{const r=new Map;for(const a of t){const g=`${a.componentName}-${a.solverName}`;r.set(g,a)}return r},[t]),o=z.useMemo(()=>Array.from(i.keys()),[i]),n=A?i.get(A):null,s=z.useMemo(()=>{if(!n)return{instance:null,error:null,classFound:!1};const r=reA[n.solverName];if(!r)return{instance:null,error:`Solver class "${n.solverName}" not found in SOLVERS registry. Available: ${Object.keys(reA).join(", ")}`,classFound:!1};try{const a=n.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}}},[n]);return t.length===0?O.jsx("div",{className:"rf-p-4",children:O.jsx("div",{className:"rf-bg-gray-50 rf-rounded-md rf-border rf-border-gray-200",children:O.jsxs("div",{className:"rf-p-4",children:[O.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800 rf-mb-3",children:"No Solvers Detected"}),O.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."})]})})}):O.jsxs("div",{className:"rf-flex rf-h-full rf-overflow-hidden",children:[O.jsxs("div",{className:"rf-w-64 rf-border-r rf-border-gray-200 rf-overflow-y-auto rf-flex-shrink-0",children:[O.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:[o.length," ",o.length===1?"Solver":"Solvers"]}),o.map(r=>{const a=i.get(r),g=A===r;return O.jsx("div",{className:`rf-px-3 rf-py-2 rf-cursor-pointer rf-border-b rf-border-gray-100 ${g?"rf-bg-blue-50 rf-border-l-2 rf-border-l-blue-500":"hover:rf-bg-gray-50"}`,onClick:()=>e(r),children:(()=>{const I=bTt(a.solverName);return O.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2",children:[O.jsx(I,{className:"rf-w-4 rf-h-4 rf-text-blue-500 rf-flex-shrink-0"}),O.jsxs("div",{className:"rf-flex-1 rf-min-w-0",children:[O.jsx("div",{className:"rf-text-sm rf-font-medium rf-text-gray-800 rf-truncate",children:a.componentName}),O.jsx("div",{className:"rf-text-xs rf-text-gray-500 rf-truncate",children:a.solverName})]})]})})()},r)})]}),O.jsx("div",{className:"rf-flex-1 rf-overflow-hidden",children:n?s.instance?O.jsx(yy,{fallback:O.jsx("div",{className:"rf-p-4",children:O.jsxs("div",{className:"rf-bg-red-50 rf-rounded-md rf-border rf-border-red-200 rf-p-4",children:[O.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-red-800 rf-mb-2",children:"Error Loading Solver Debugger"}),O.jsxs("p",{className:"rf-text-sm rf-text-red-600",children:["Failed to render the solver debugger for"," ",n.solverName]})]})}),children:O.jsx(DTt,{solver:s.instance})}):O.jsxs("div",{className:"rf-p-4",children:[O.jsxs("div",{className:"rf-mb-4",children:[O.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800",children:n.solverName}),O.jsxs("p",{className:"rf-text-sm rf-text-gray-500",children:["Component: ",n.componentName]})]}),s.error&&O.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:O.jsx("p",{className:`rf-text-sm ${s.classFound?"rf-text-red-700":"rf-text-yellow-700"}`,children:s.error})}),O.jsxs("div",{className:"rf-border rf-border-gray-200 rf-rounded-md rf-overflow-hidden",children:[O.jsx("div",{className:"rf-px-3 rf-py-2 rf-bg-gray-50",children:O.jsx("span",{className:"rf-text-sm rf-font-medium rf-text-gray-700",children:"Solver Parameters"})}),O.jsx("div",{className:"rf-p-3 rf-bg-white rf-border-t rf-border-gray-200",children:O.jsx("pre",{className:"rf-text-xs rf-font-mono rf-text-gray-600 rf-whitespace-pre-wrap rf-overflow-x-auto",children:JSON.stringify(n.solverParams,null,2)})})]})]}):O.jsx("div",{className:"rf-flex rf-items-center rf-justify-center rf-h-full",children:O.jsx("p",{className:"rf-text-sm rf-text-gray-500",children:"Select a solver from the list to view details"})})})]})},Voe=({errorMessage:t,errorStack:A,circuitJsonErrors:e})=>{z.useEffect(()=>{if(t){const i=new Error(t);A&&(i.stack=A);try{Q3.captureException(i)}catch{}}},[t,A]),z.useEffect(()=>{if(e&&e.length>0)for(const i of e){const o=new Error(i.message||"Circuit JSON Error");i.stack&&(o.stack=i.stack);try{Q3.captureException(o,{error_type:i.type})}catch{}}},[e])},joe="0.0.1430",kTt={version:joe},AZ=zvA()(XvA(t=>({lastRunEvalVersion:void 0,setLastRunEvalVersion:A=>{t({lastRunEvalVersion:A})}}),{name:"runframe-runner-store"})),GTt=t=>{const[A,e]=z.useState([]),[i,o]=z.useState(null),[n,s]=z.useState(""),[r,a]=KM("eval-version-selection",null),g=AZ(l=>l.setLastRunEvalVersion),I=AZ(l=>l.lastRunEvalVersion);return z.useEffect(()=>{t&&fetch("https://data.jsdelivr.com/v1/package/npm/@tscircuit/eval").then(l=>l.json()).then(l=>{if(Array.isArray(l?.versions)){let C=[...l.versions];l.tags?.latest&&(o(l.tags.latest),C=C.filter(Q=>Q!==l.tags.latest)),e(C)}}).catch(()=>{})},[t]),z.useEffect(()=>{t&&(r?(window.TSCIRCUIT_LATEST_EVAL_VERSION=r,g(r)):i&&(window.TSCIRCUIT_LATEST_EVAL_VERSION=i,g(i)))},[t,r,i]),{versions:z.useMemo(()=>A.filter(l=>l.includes(n)).slice(0,50),[A,n]),latestVersion:i,lastRunEvalVersion:I,search:n,setSearch:s,selectVersion:l=>{a(l),s("")}}},FTt=({snippetNames:t,onSelect:A,onCancel:e,isOpen:i})=>{const[o,n]=z.useState(""),[s,r]=z.useState("");if(!i)return null;const a=t.filter(c=>c.toLowerCase().includes(s.toLowerCase())),g=s&&!t.includes(s),I=c=>{c.key==="Enter"&&(a.length===1?n(a[0]):g&&n(s))};return O.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:O.jsxs("div",{className:"rf-bg-white rf-rounded-lg rf-p-6 rf-w-96",children:[O.jsx("h2",{className:"rf-text-lg rf-font-semibold rf-mb-4",children:"Select Snippet"}),O.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:c=>r(c.target.value),onKeyDown:I}),O.jsxs("div",{className:"rf-h-60 rf-overflow-y-auto",children:[a.map(c=>O.jsx("button",{type:"button",className:`w-full text-left px-4 py-2 rounded hover:bg-gray-100 ${o===c?"bg-blue-50":""}`,onClick:()=>n(c),children:c},c)),g&&O.jsxs("button",{type:"button",className:`w-full text-left px-4 py-2 rounded hover:bg-gray-100 text-blue-500 ${o===s?"bg-blue-50":""}`,onClick:()=>n(s),children:['Create new "',s,'"']})]}),O.jsxs("div",{className:"rf-mt-4 rf-flex rf-justify-end rf-gap-2",children:[O.jsx("button",{type:"button",className:"rf-px-4 rf-py-2 rf-text-gray-600 rf-hover:text-gray-800",onClick:e,children:"Cancel"}),O.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:()=>o&&A(o),disabled:!o,children:o===s?`Create "${o}"`:`Save to ${o}`})]})]})})},_Tt=t=>{const A=z.useRef(null),e=Tc(i=>i.recentEvents);z.useEffect(()=>{if(e.length===0)return;const i=e[0];i.event_id!==A.current&&(t(i),A.current=i.event_id)},[e,t])};function RTt(t){const A=NTt(t),e=z.forwardRef((i,o)=>{const{children:n,...s}=i,r=z.Children.toArray(n),a=r.find(vTt);if(a){const g=a.props.children,I=r.map(c=>c===a?z.Children.count(g)>1?z.Children.only(null):z.isValidElement(g)?g.props.children:null:c);return O.jsx(A,{...s,ref:o,children:z.isValidElement(g)?z.cloneElement(g,void 0,I):null})}return O.jsx(A,{...s,ref:o,children:n})});return e.displayName=`${t}.Slot`,e}function NTt(t){const A=z.forwardRef((e,i)=>{const{children:o,...n}=e;if(z.isValidElement(o)){const s=LTt(o),r=UTt(n,o.props);return o.type!==z.Fragment&&(r.ref=i?Pp(i,s):s),z.cloneElement(o,r)}return z.Children.count(o)>1?z.Children.only(null):null});return A.displayName=`${t}.SlotClone`,A}var MTt=Symbol("radix.slottable");function vTt(t){return z.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===MTt}function UTt(t,A){const e={...A};for(const i in A){const o=t[i],n=A[i];/^on[A-Z]/.test(i)?o&&n?e[i]=(...r)=>{const a=n(...r);return o(...r),a}:o&&(e[i]=o):i==="style"?e[i]={...o,...n}:i==="className"&&(e[i]=[o,n].filter(Boolean).join(" "))}return{...t,...e}}function LTt(t){let A=Object.getOwnPropertyDescriptor(t.props,"ref")?.get,e=A&&"isReactWarning"in A&&A.isReactWarning;return e?t.ref:(A=Object.getOwnPropertyDescriptor(t,"ref")?.get,e=A&&"isReactWarning"in A&&A.isReactWarning,e?t.props.ref:t.props.ref||t.ref)}var eZ="Dialog",[zoe,Xoe]=fw(eZ),[HTt,Lm]=zoe(eZ),$oe=t=>{const{__scopeDialog:A,children:e,open:i,defaultOpen:o,onOpenChange:n,modal:s=!0}=t,r=z.useRef(null),a=z.useRef(null),[g,I]=QG({prop:i,defaultProp:o??!1,onChange:n,caller:eZ});return O.jsx(HTt,{scope:A,triggerRef:r,contentRef:a,contentId:mu(),titleId:mu(),descriptionId:mu(),open:g,onOpenChange:I,onOpenToggle:z.useCallback(()=>I(c=>!c),[I]),modal:s,children:e})};$oe.displayName=eZ;var Ane="DialogTrigger",ene=z.forwardRef((t,A)=>{const{__scopeDialog:e,...i}=t,o=Lm(Ane,e),n=wB(A,o.triggerRef);return O.jsx(pg.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":RhA(o.open),...i,ref:n,onClick:Qn(t.onClick,o.onOpenToggle)})});ene.displayName=Ane;var FhA="DialogPortal",[YTt,tne]=zoe(FhA,{forceMount:void 0}),ine=t=>{const{__scopeDialog:A,forceMount:e,children:i,container:o}=t,n=Lm(FhA,A);return O.jsx(YTt,{scope:A,forceMount:e,children:z.Children.map(i,s=>O.jsx(cy,{present:e||n.open,children:O.jsx(f8,{asChild:!0,container:o,children:s})}))})};ine.displayName=FhA;var tZ="DialogOverlay",one=z.forwardRef((t,A)=>{const e=tne(tZ,t.__scopeDialog),{forceMount:i=e.forceMount,...o}=t,n=Lm(tZ,t.__scopeDialog);return n.modal?O.jsx(cy,{present:i||n.open,children:O.jsx(TTt,{...o,ref:A})}):null});one.displayName=tZ;var JTt=RTt("DialogOverlay.RemoveScroll"),TTt=z.forwardRef((t,A)=>{const{__scopeDialog:e,...i}=t,o=Lm(tZ,e);return O.jsx(k8,{as:JTt,allowPinchZoom:!0,shards:[o.contentRef],children:O.jsx(pg.div,{"data-state":RhA(o.open),...i,ref:A,style:{pointerEvents:"auto",...i.style}})})}),wF="DialogContent",nne=z.forwardRef((t,A)=>{const e=tne(wF,t.__scopeDialog),{forceMount:i=e.forceMount,...o}=t,n=Lm(wF,t.__scopeDialog);return O.jsx(cy,{present:i||n.open,children:n.modal?O.jsx(KTt,{...o,ref:A}):O.jsx(qTt,{...o,ref:A})})});nne.displayName=wF;var KTt=z.forwardRef((t,A)=>{const e=Lm(wF,t.__scopeDialog),i=z.useRef(null),o=wB(A,e.contentRef,i);return z.useEffect(()=>{const n=i.current;if(n)return sQA(n)},[]),O.jsx(sne,{...t,ref:o,trapFocus:e.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Qn(t.onCloseAutoFocus,n=>{n.preventDefault(),e.triggerRef.current?.focus()}),onPointerDownOutside:Qn(t.onPointerDownOutside,n=>{const s=n.detail.originalEvent,r=s.button===0&&s.ctrlKey===!0;(s.button===2||r)&&n.preventDefault()}),onFocusOutside:Qn(t.onFocusOutside,n=>n.preventDefault())})}),qTt=z.forwardRef((t,A)=>{const e=Lm(wF,t.__scopeDialog),i=z.useRef(!1),o=z.useRef(!1);return O.jsx(sne,{...t,ref:A,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:n=>{t.onCloseAutoFocus?.(n),n.defaultPrevented||(i.current||e.triggerRef.current?.focus(),n.preventDefault()),i.current=!1,o.current=!1},onInteractOutside:n=>{t.onInteractOutside?.(n),n.defaultPrevented||(i.current=!0,n.detail.originalEvent.type==="pointerdown"&&(o.current=!0));const s=n.target;e.triggerRef.current?.contains(s)&&n.preventDefault(),n.detail.originalEvent.type==="focusin"&&o.current&&n.preventDefault()}})}),sne=z.forwardRef((t,A)=>{const{__scopeDialog:e,trapFocus:i,onOpenAutoFocus:o,onCloseAutoFocus:n,...s}=t,r=Lm(wF,e),a=z.useRef(null),g=wB(A,a);return JCA(),O.jsxs(O.Fragment,{children:[O.jsx(g8,{asChild:!0,loop:!0,trapped:i,onMountAutoFocus:o,onUnmountAutoFocus:n,children:O.jsx(a8,{role:"dialog",id:r.contentId,"aria-describedby":r.descriptionId,"aria-labelledby":r.titleId,"data-state":RhA(r.open),...s,ref:g,onDismiss:()=>r.onOpenChange(!1)})}),O.jsxs(O.Fragment,{children:[O.jsx(OTt,{titleId:r.titleId}),O.jsx(ZTt,{contentRef:a,descriptionId:r.descriptionId})]})]})}),_hA="DialogTitle",rne=z.forwardRef((t,A)=>{const{__scopeDialog:e,...i}=t,o=Lm(_hA,e);return O.jsx(pg.h2,{id:o.titleId,...i,ref:A})});rne.displayName=_hA;var ane="DialogDescription",gne=z.forwardRef((t,A)=>{const{__scopeDialog:e,...i}=t,o=Lm(ane,e);return O.jsx(pg.p,{id:o.descriptionId,...i,ref:A})});gne.displayName=ane;var Ine="DialogClose",cne=z.forwardRef((t,A)=>{const{__scopeDialog:e,...i}=t,o=Lm(Ine,e);return O.jsx(pg.button,{type:"button",...i,ref:A,onClick:Qn(t.onClick,()=>o.onOpenChange(!1))})});cne.displayName=Ine;function RhA(t){return t?"open":"closed"}var Bne="DialogTitleWarning",[PTt,lne]=R5e(Bne,{contentName:wF,titleName:_hA,docsSlug:"dialog"}),OTt=({titleId:t})=>{const A=lne(Bne),e=`\`${A.contentName}\` requires a \`${A.titleName}\` for the component to be accessible for screen reader users.
5605
+ `,c=new Blob([I],{type:"text/plain"}),B=URL.createObjectURL(c),l=document.createElement("a");l.href=B,l.download=`${g}.test.ts`,l.click(),URL.revokeObjectURL(B)}catch(a){alert(`Error generating test.ts for ${t.constructor.name}: ${a instanceof Error?a.message:String(a)}`)}i(!1)};return O.jsxs("div",{className:`relative ${A}`,ref:o,children:[O.jsx("button",{className:"px-2 py-1 rounded text-xs cursor-pointer",onClick:()=>i(!e),title:`Download options for ${t.constructor.name}`,children:t.constructor.name}),e&&O.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:[O.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:n,children:"Download JSON"}),O.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:s,children:"Download page.tsx"}),O.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:r,children:"Download test.ts"})]})]})},Zoe=t=>t.activeSubSolver?[t,...Zoe(t.activeSubSolver)]:[t],lTt=({solver:t})=>{const A=Zoe(t);return O.jsx("div",{className:"flex gap-1 items-center text-sm pt-1",children:A.map((e,i)=>O.jsxs("div",{className:"flex items-center",children:[i>0&&O.jsx("span",{className:"text-gray-400 mx-1",children:"→"}),O.jsx(BTt,{solver:e})]},e.constructor.name))})},CTt=({solver:t,triggerRender:A,animationSpeed:e=25,onSolverStarted:i,onSolverCompleted:o})=>{const[n,s]=z.useReducer(Q=>!Q,!1),r=z.useRef(void 0),a=()=>{!t.solved&&!t.failed&&(t.step(),A())},g=()=>{!t.solved&&!t.failed&&(i&&i(t),t.solve(),A(),o&&o(t))},I=()=>{n?(r.current&&(clearInterval(r.current),r.current=void 0),s()):(s(),r.current=setInterval(()=>{if(t.solved||t.failed){r.current&&(clearInterval(r.current),r.current=void 0),s(),A(),o&&t.solved&&o(t);return}t.step(),A()},e))},c=()=>{const Q=t;if(Q.getCurrentPhase&&!t.solved&&!t.failed){const E=Q.getCurrentPhase();for(;Q.getCurrentPhase()===E&&!t.solved&&!t.failed;)t.step();A()}},B=()=>{if(t.solved||t.failed||n)return;const Q=window.prompt("Step until which iteration?",`${t.iterations}`);if(Q===null)return;const E=Number(Q);if(!Number.isFinite(E)){window.alert("Please enter a valid number for the iteration");return}for(;t.iterations<E&&!t.solved&&!t.failed;)t.step();A(),t.solved&&o&&o(t)};z.useEffect(()=>()=>{r.current&&clearInterval(r.current)},[]),z.useEffect(()=>{(t.solved||t.failed)&&n&&(r.current&&(clearInterval(r.current),r.current=void 0),s())},[t.solved,t.failed,n]);const l=t.getCurrentPhase!==void 0,C=l?t.getCurrentPhase():null;return O.jsxs("div",{className:"space-y-2 p-2 border-b",children:[O.jsx("div",{className:"flex items-center",children:O.jsx(lTt,{solver:t})}),O.jsxs("div",{className:"flex gap-2 items-center flex-wrap",children:[O.jsx("button",{onClick:a,disabled:t.solved||t.failed||n,className:"bg-blue-500 hover:bg-blue-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Step"}),O.jsx("button",{onClick:g,disabled:t.solved||t.failed||n,className:"bg-green-500 hover:bg-green-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Solve"}),O.jsx("button",{onClick:I,disabled:t.solved||t.failed,className:`px-3 py-1 rounded text-white text-sm ${n?"bg-red-500 hover:bg-red-600":"bg-yellow-500 hover:bg-yellow-600"} disabled:bg-gray-300`,children:n?"Stop":"Animate"}),O.jsx("button",{onClick:B,disabled:t.solved||t.failed||n,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"}),l&&O.jsx("button",{onClick:c,disabled:t.solved||t.failed||n,className:"bg-purple-500 hover:bg-purple-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Next Stage"}),O.jsxs("div",{className:"text-sm text-gray-600",children:["Iterations: ",t.iterations]}),t.timeToSolve!==void 0&&O.jsxs("div",{className:"text-sm text-gray-600",children:["Time: ",(t.timeToSolve/1e3).toFixed(3),"s"]}),C&&O.jsxs("div",{className:"text-sm text-gray-600",children:["Phase: ",O.jsx("span",{className:"font-medium",children:C})]}),t.solved&&O.jsx("div",{className:"px-2 py-1 bg-green-100 text-green-800 rounded text-sm",children:"Solved"}),t.failed&&O.jsx("div",{className:"px-2 py-1 bg-red-100 text-red-800 rounded text-sm",children:"Failed"})]}),t.error&&O.jsxs("div",{className:"text-red-600 text-sm",children:["Error: ",t.error]})]})},QTt=(t,A,e)=>{const i=t.currentPipelineStepIndex;return A<i?"Completed":A===i&&t.activeSubSolver?t.activeSubSolver.failed?"Failed":"In Progress":"Not Started"},ETt=(t,A)=>{const i=t.pipelineDef[A].solverName,o=QTt(t,A),n=t[i],s=t.firstIterationOfPhase?.[i]??null,r=t.iterations;let a=0;if(o==="Completed"){const B=t.pipelineDef[A+1],l=B?t.firstIterationOfPhase?.[B.solverName]:void 0;l!==void 0&&s!==null?a=l-s:s!==null&&(a=r-s)}else o==="In Progress"&&s!==null&&(a=r-s);const g=t.timeSpentOnPhase?.[i]??0;let I=0;o==="Completed"?I=1:o==="In Progress"&&n&&(I=n.progress??0);const c=n?.stats??null;return{index:A,name:i,status:o,firstIteration:s,iterations:a,progress:I,timeSpent:g,stats:c&&Object.keys(c).length>0?c:null,solverInstance:n??null}},hTt=({status:t})=>{const A={"Not Started":"text-blue-600","In Progress":"text-yellow-600",Completed:"text-green-600",Failed:"text-red-600"};return O.jsx("span",{className:`font-medium ${A[t]}`,children:t})},uTt=({progress:t})=>{if(t===0)return null;const A=Math.round(t*100);return O.jsxs("div",{className:"flex items-center gap-2",children:[O.jsx("div",{className:"w-20 h-2 bg-gray-200 rounded overflow-hidden",children:O.jsx("div",{className:"h-full bg-blue-500 transition-all duration-200",style:{width:`${A}%`}})}),O.jsxs("span",{className:"text-xs text-gray-500",children:[A,"%"]})]})},dTt=t=>Object.entries(t).map(([A,e])=>`${A}: ${e}`).join(", "),pTt=({stats:t})=>{if(!t||Object.keys(t).length===0)return O.jsx("span",{children:"-"});const A=Object.entries(t),e=dTt(t);return O.jsxs("details",{className:"cursor-pointer",children:[O.jsx("summary",{className:"whitespace-nowrap overflow-hidden text-ellipsis max-w-[200px]",children:e}),O.jsx("div",{className:"mt-1 text-xs",children:A.map(([i,o])=>O.jsxs("div",{children:[i,": ",String(o)]},i))})]})},GhA=t=>{if(t===null||typeof t!="object")return t;if(Array.isArray(t))return t.map(GhA);const A={};for(const[e,i]of Object.entries(t))e.startsWith("_")||(A[e]=GhA(i));return A},fTt=(t,A)=>{try{if(typeof t.getConstructorParams!="function"){alert(`getConstructorParams() is not implemented for ${A}`);return}const e=GhA(t.getConstructorParams()),i=new Blob([JSON.stringify(e,null,2)],{type:"application/json"}),o=URL.createObjectURL(i),n=document.createElement("a");n.href=o,n.download=`${A}_input.json`,n.click(),URL.revokeObjectURL(o)}catch(e){alert(`Error downloading input for ${A}: ${e instanceof Error?e.message:String(e)}`)}},yTt=({solver:t,onStepUntilPhase:A,onDownloadInput:e})=>{const i=t.pipelineDef.map((r,a)=>ETt(t,a)),o=r=>{A?.(r)},n=r=>{r.solverInstance&&(e?e(r.solverInstance,r.name):fTt(r.solverInstance,r.name))},s=r=>`${(r/1e3).toFixed(2)}s`;return O.jsxs("div",{className:"border-t border-gray-200",children:[O.jsx("div",{className:"px-4 py-2 bg-gray-50 border-b border-gray-200",children:O.jsx("h3",{className:"text-sm font-semibold text-gray-700",children:"Pipeline Steps"})}),O.jsx("div",{className:"overflow-x-auto",children:O.jsxs("table",{className:"w-full text-sm",children:[O.jsx("thead",{children:O.jsxs("tr",{className:"bg-gray-50 border-b border-gray-200",children:[O.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Step"}),O.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Status"}),O.jsxs("th",{className:"px-4 py-2 text-center font-semibold text-gray-700",children:["i",O.jsx("sub",{children:"0"})]}),O.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Iterations"}),O.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Progress"}),O.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Time"}),O.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Stats"}),O.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Input"})]})}),O.jsx("tbody",{children:i.map(r=>O.jsxs("tr",{className:`border-b border-gray-100 ${r.status==="In Progress"?"bg-yellow-50":""}`,children:[O.jsx("td",{className:"px-4 py-2",children:O.jsxs("div",{className:"flex items-center gap-2",children:[O.jsx("span",{className:"text-gray-400 w-6",children:String(r.index+1).padStart(2,"0")}),O.jsx("button",{onClick:()=>o(r.name),disabled:r.status==="Completed"||t.solved||t.failed,className:"text-blue-500 hover:text-blue-700 disabled:text-gray-300 disabled:cursor-not-allowed",title:`Step until ${r.name} completes`,children:O.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:O.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"})})}),O.jsx("span",{className:"font-medium text-gray-900",children:r.name})]})}),O.jsx("td",{className:"px-4 py-2",children:O.jsx(hTt,{status:r.status})}),O.jsx("td",{className:"px-4 py-2 text-center text-gray-600",children:r.firstIteration!==null?r.firstIteration:""}),O.jsx("td",{className:"px-4 py-2 text-gray-600",children:r.iterations}),O.jsx("td",{className:"px-4 py-2",children:O.jsx(uTt,{progress:r.progress})}),O.jsx("td",{className:"px-4 py-2 text-gray-600",children:s(r.timeSpent)}),O.jsx("td",{className:"px-4 py-2 text-gray-500",children:O.jsx(pTt,{stats:r.stats})}),O.jsx("td",{className:"px-4 py-2",children:r.solverInstance?O.jsxs("button",{onClick:()=>n(r),className:"flex items-center gap-1 text-blue-500 hover:text-blue-700",title:`Download input for ${r.name}`,children:[O.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:O.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"})}),O.jsx("span",{children:"Input"})]}):null})]},r.name))})]})})]})},mTt=class extends to.Component{constructor(t){super(t),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(t){console.error("InteractiveGraphics render error:",t)}render(){return this.state.hasError?this.props.fallback:this.props.children}};function wTt({graphics:t}){const A=t.points??[],e=t.lines??[],i=t.rects??[],o=t.circles??[],n=t.texts??[];let s=Number.POSITIVE_INFINITY,r=Number.POSITIVE_INFINITY,a=Number.NEGATIVE_INFINITY,g=Number.NEGATIVE_INFINITY;const I=(E,h)=>{typeof E=="number"&&(E<s&&(s=E),E>a&&(a=E)),typeof h=="number"&&(h<r&&(r=h),h>g&&(g=h))};for(const E of A)I(E.x,E.y);for(const E of e){const h=E.points??[];for(const u of h)I(u.x,u.y)}for(const E of i){const h=E.x??0,u=E.y??0,d=E.width??0,f=E.height??0;I(h,u),I(h+d,u+f)}for(const E of o){const h=E.x??0,u=E.y??0,d=E.radius??1;I(h-d,u-d),I(h+d,u+d)}for(const E of n)I(E.x,E.y);(!isFinite(s)||!isFinite(r)||!isFinite(a)||!isFinite(g))&&(s=-20,r=-20,a=20,g=20);const c=10,B=s-c,l=r-c,C=Math.max(1,a-s+2*c),Q=Math.max(1,g-r+2*c);return O.jsxs("svg",{className:"w-full h-[400px] bg-white",viewBox:`${B} ${l} ${C} ${Q}`,role:"img","aria-label":"Graphics fallback",children:[i.map((E,h)=>O.jsx("rect",{x:E.x??0,y:E.y??0,width:E.width??0,height:E.height??0,fill:"none",stroke:E.strokeColor??"black",strokeWidth:E.strokeWidth??1},`rect-${h}`)),e.map((E,h)=>O.jsx("polyline",{fill:"none",stroke:E.strokeColor??"black",strokeWidth:E.strokeWidth??1,points:(E.points??[]).map(u=>`${u.x??0},${u.y??0}`).join(" ")},`line-${h}`)),o.map((E,h)=>O.jsx("circle",{cx:E.x??0,cy:E.y??0,r:E.radius??1.5,fill:E.fillColor??"none",stroke:E.strokeColor??"black",strokeWidth:E.strokeWidth??1},`circle-${h}`)),A.map((E,h)=>O.jsx("circle",{cx:E.x??0,cy:E.y??0,r:E.radius??1.5,fill:E.color??"black"},`point-${h}`)),n.map((E,h)=>O.jsx("text",{x:E.x??0,y:E.y??0,fontSize:E.fontSize??10,fill:E.color??"black",children:E.text??""},`text-${h}`))]})}var DTt=({solver:t,animationSpeed:A=25,onSolverStarted:e,onSolverCompleted:i})=>{const[o,n]=z.useReducer(I=>I+1,0),s=z.useMemo(()=>{try{return t.visualize()||{points:[],lines:[],rects:[],circles:[]}}catch(I){return console.error("Visualization error:",I),{points:[],lines:[],rects:[],circles:[]}}},[t,o]),r=z.useMemo(()=>(s.rects?.length||0)===0&&(s.lines?.length||0)===0&&(s.points?.length||0)===0&&(s.circles?.length||0)===0,[s]);z.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=t.pipelineDef!==void 0,g=I=>{const c=t;if(!t.solved&&!t.failed){for(;!t.solved&&!t.failed&&c.currentPipelineStepIndex<=c.pipelineDef.findIndex(B=>B.solverName===I);)t.step();n()}};return O.jsxs("div",{children:[O.jsx(CTt,{solver:t,triggerRender:n,animationSpeed:A,onSolverStarted:e,onSolverCompleted:i}),r?O.jsx("div",{className:"p-4 text-gray-500",children:"No Graphics Yet"}):O.jsx(mTt,{fallback:O.jsx(wTt,{graphics:s}),children:O.jsx(cTt,{graphics:s})}),a&&O.jsx(yTt,{solver:t,onStepUntilPhase:g})]})};const STt=()=>{z.useEffect(()=>{const t="tailwind-cdn-script";if(document.getElementById(t)||window.tailwind)return;const A=document.createElement("div");A.className="hidden",document.body.appendChild(A);const e=window.getComputedStyle(A).display==="none";if(document.body.removeChild(A),e)return;const i=document.createElement("script");i.id=t,i.src="https://cdn.tailwindcss.com",document.head.appendChild(i)},[])},bTt=t=>t.toLowerCase().includes("pack")?PSt:t.toLowerCase().includes("rout")?jSt:xSt,xTt=({solverEvents:t=[]})=>{const[A,e]=z.useState(null);STt();const i=z.useMemo(()=>{const r=new Map;for(const a of t){const g=`${a.componentName}-${a.solverName}`;r.set(g,a)}return r},[t]),o=z.useMemo(()=>Array.from(i.keys()),[i]),n=A?i.get(A):null,s=z.useMemo(()=>{if(!n)return{instance:null,error:null,classFound:!1};const r=reA[n.solverName];if(!r)return{instance:null,error:`Solver class "${n.solverName}" not found in SOLVERS registry. Available: ${Object.keys(reA).join(", ")}`,classFound:!1};try{const a=n.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}}},[n]);return t.length===0?O.jsx("div",{className:"rf-p-4",children:O.jsx("div",{className:"rf-bg-gray-50 rf-rounded-md rf-border rf-border-gray-200",children:O.jsxs("div",{className:"rf-p-4",children:[O.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800 rf-mb-3",children:"No Solvers Detected"}),O.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."})]})})}):O.jsxs("div",{className:"rf-flex rf-h-full rf-overflow-hidden",children:[O.jsxs("div",{className:"rf-w-64 rf-border-r rf-border-gray-200 rf-overflow-y-auto rf-flex-shrink-0",children:[O.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:[o.length," ",o.length===1?"Solver":"Solvers"]}),o.map(r=>{const a=i.get(r),g=A===r;return O.jsx("div",{className:`rf-px-3 rf-py-2 rf-cursor-pointer rf-border-b rf-border-gray-100 ${g?"rf-bg-blue-50 rf-border-l-2 rf-border-l-blue-500":"hover:rf-bg-gray-50"}`,onClick:()=>e(r),children:(()=>{const I=bTt(a.solverName);return O.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2",children:[O.jsx(I,{className:"rf-w-4 rf-h-4 rf-text-blue-500 rf-flex-shrink-0"}),O.jsxs("div",{className:"rf-flex-1 rf-min-w-0",children:[O.jsx("div",{className:"rf-text-sm rf-font-medium rf-text-gray-800 rf-truncate",children:a.componentName}),O.jsx("div",{className:"rf-text-xs rf-text-gray-500 rf-truncate",children:a.solverName})]})]})})()},r)})]}),O.jsx("div",{className:"rf-flex-1 rf-overflow-hidden",children:n?s.instance?O.jsx(yy,{fallback:O.jsx("div",{className:"rf-p-4",children:O.jsxs("div",{className:"rf-bg-red-50 rf-rounded-md rf-border rf-border-red-200 rf-p-4",children:[O.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-red-800 rf-mb-2",children:"Error Loading Solver Debugger"}),O.jsxs("p",{className:"rf-text-sm rf-text-red-600",children:["Failed to render the solver debugger for"," ",n.solverName]})]})}),children:O.jsx(DTt,{solver:s.instance})}):O.jsxs("div",{className:"rf-p-4",children:[O.jsxs("div",{className:"rf-mb-4",children:[O.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800",children:n.solverName}),O.jsxs("p",{className:"rf-text-sm rf-text-gray-500",children:["Component: ",n.componentName]})]}),s.error&&O.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:O.jsx("p",{className:`rf-text-sm ${s.classFound?"rf-text-red-700":"rf-text-yellow-700"}`,children:s.error})}),O.jsxs("div",{className:"rf-border rf-border-gray-200 rf-rounded-md rf-overflow-hidden",children:[O.jsx("div",{className:"rf-px-3 rf-py-2 rf-bg-gray-50",children:O.jsx("span",{className:"rf-text-sm rf-font-medium rf-text-gray-700",children:"Solver Parameters"})}),O.jsx("div",{className:"rf-p-3 rf-bg-white rf-border-t rf-border-gray-200",children:O.jsx("pre",{className:"rf-text-xs rf-font-mono rf-text-gray-600 rf-whitespace-pre-wrap rf-overflow-x-auto",children:JSON.stringify(n.solverParams,null,2)})})]})]}):O.jsx("div",{className:"rf-flex rf-items-center rf-justify-center rf-h-full",children:O.jsx("p",{className:"rf-text-sm rf-text-gray-500",children:"Select a solver from the list to view details"})})})]})},Voe=({errorMessage:t,errorStack:A,circuitJsonErrors:e})=>{z.useEffect(()=>{if(t){const i=new Error(t);A&&(i.stack=A);try{Q3.captureException(i)}catch{}}},[t,A]),z.useEffect(()=>{if(e&&e.length>0)for(const i of e){const o=new Error(i.message||"Circuit JSON Error");i.stack&&(o.stack=i.stack);try{Q3.captureException(o,{error_type:i.type})}catch{}}},[e])},joe="0.0.1431",kTt={version:joe},AZ=zvA()(XvA(t=>({lastRunEvalVersion:void 0,setLastRunEvalVersion:A=>{t({lastRunEvalVersion:A})}}),{name:"runframe-runner-store"})),GTt=t=>{const[A,e]=z.useState([]),[i,o]=z.useState(null),[n,s]=z.useState(""),[r,a]=KM("eval-version-selection",null),g=AZ(l=>l.setLastRunEvalVersion),I=AZ(l=>l.lastRunEvalVersion);return z.useEffect(()=>{t&&fetch("https://data.jsdelivr.com/v1/package/npm/@tscircuit/eval").then(l=>l.json()).then(l=>{if(Array.isArray(l?.versions)){let C=[...l.versions];l.tags?.latest&&(o(l.tags.latest),C=C.filter(Q=>Q!==l.tags.latest)),e(C)}}).catch(()=>{})},[t]),z.useEffect(()=>{t&&(r?(window.TSCIRCUIT_LATEST_EVAL_VERSION=r,g(r)):i&&(window.TSCIRCUIT_LATEST_EVAL_VERSION=i,g(i)))},[t,r,i]),{versions:z.useMemo(()=>A.filter(l=>l.includes(n)).slice(0,50),[A,n]),latestVersion:i,lastRunEvalVersion:I,search:n,setSearch:s,selectVersion:l=>{a(l),s("")}}},FTt=({snippetNames:t,onSelect:A,onCancel:e,isOpen:i})=>{const[o,n]=z.useState(""),[s,r]=z.useState("");if(!i)return null;const a=t.filter(c=>c.toLowerCase().includes(s.toLowerCase())),g=s&&!t.includes(s),I=c=>{c.key==="Enter"&&(a.length===1?n(a[0]):g&&n(s))};return O.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:O.jsxs("div",{className:"rf-bg-white rf-rounded-lg rf-p-6 rf-w-96",children:[O.jsx("h2",{className:"rf-text-lg rf-font-semibold rf-mb-4",children:"Select Snippet"}),O.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:c=>r(c.target.value),onKeyDown:I}),O.jsxs("div",{className:"rf-h-60 rf-overflow-y-auto",children:[a.map(c=>O.jsx("button",{type:"button",className:`w-full text-left px-4 py-2 rounded hover:bg-gray-100 ${o===c?"bg-blue-50":""}`,onClick:()=>n(c),children:c},c)),g&&O.jsxs("button",{type:"button",className:`w-full text-left px-4 py-2 rounded hover:bg-gray-100 text-blue-500 ${o===s?"bg-blue-50":""}`,onClick:()=>n(s),children:['Create new "',s,'"']})]}),O.jsxs("div",{className:"rf-mt-4 rf-flex rf-justify-end rf-gap-2",children:[O.jsx("button",{type:"button",className:"rf-px-4 rf-py-2 rf-text-gray-600 rf-hover:text-gray-800",onClick:e,children:"Cancel"}),O.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:()=>o&&A(o),disabled:!o,children:o===s?`Create "${o}"`:`Save to ${o}`})]})]})})},_Tt=t=>{const A=z.useRef(null),e=Tc(i=>i.recentEvents);z.useEffect(()=>{if(e.length===0)return;const i=e[0];i.event_id!==A.current&&(t(i),A.current=i.event_id)},[e,t])};function RTt(t){const A=NTt(t),e=z.forwardRef((i,o)=>{const{children:n,...s}=i,r=z.Children.toArray(n),a=r.find(vTt);if(a){const g=a.props.children,I=r.map(c=>c===a?z.Children.count(g)>1?z.Children.only(null):z.isValidElement(g)?g.props.children:null:c);return O.jsx(A,{...s,ref:o,children:z.isValidElement(g)?z.cloneElement(g,void 0,I):null})}return O.jsx(A,{...s,ref:o,children:n})});return e.displayName=`${t}.Slot`,e}function NTt(t){const A=z.forwardRef((e,i)=>{const{children:o,...n}=e;if(z.isValidElement(o)){const s=LTt(o),r=UTt(n,o.props);return o.type!==z.Fragment&&(r.ref=i?Pp(i,s):s),z.cloneElement(o,r)}return z.Children.count(o)>1?z.Children.only(null):null});return A.displayName=`${t}.SlotClone`,A}var MTt=Symbol("radix.slottable");function vTt(t){return z.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===MTt}function UTt(t,A){const e={...A};for(const i in A){const o=t[i],n=A[i];/^on[A-Z]/.test(i)?o&&n?e[i]=(...r)=>{const a=n(...r);return o(...r),a}:o&&(e[i]=o):i==="style"?e[i]={...o,...n}:i==="className"&&(e[i]=[o,n].filter(Boolean).join(" "))}return{...t,...e}}function LTt(t){let A=Object.getOwnPropertyDescriptor(t.props,"ref")?.get,e=A&&"isReactWarning"in A&&A.isReactWarning;return e?t.ref:(A=Object.getOwnPropertyDescriptor(t,"ref")?.get,e=A&&"isReactWarning"in A&&A.isReactWarning,e?t.props.ref:t.props.ref||t.ref)}var eZ="Dialog",[zoe,Xoe]=fw(eZ),[HTt,Lm]=zoe(eZ),$oe=t=>{const{__scopeDialog:A,children:e,open:i,defaultOpen:o,onOpenChange:n,modal:s=!0}=t,r=z.useRef(null),a=z.useRef(null),[g,I]=QG({prop:i,defaultProp:o??!1,onChange:n,caller:eZ});return O.jsx(HTt,{scope:A,triggerRef:r,contentRef:a,contentId:mu(),titleId:mu(),descriptionId:mu(),open:g,onOpenChange:I,onOpenToggle:z.useCallback(()=>I(c=>!c),[I]),modal:s,children:e})};$oe.displayName=eZ;var Ane="DialogTrigger",ene=z.forwardRef((t,A)=>{const{__scopeDialog:e,...i}=t,o=Lm(Ane,e),n=wB(A,o.triggerRef);return O.jsx(pg.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":RhA(o.open),...i,ref:n,onClick:Qn(t.onClick,o.onOpenToggle)})});ene.displayName=Ane;var FhA="DialogPortal",[YTt,tne]=zoe(FhA,{forceMount:void 0}),ine=t=>{const{__scopeDialog:A,forceMount:e,children:i,container:o}=t,n=Lm(FhA,A);return O.jsx(YTt,{scope:A,forceMount:e,children:z.Children.map(i,s=>O.jsx(cy,{present:e||n.open,children:O.jsx(f8,{asChild:!0,container:o,children:s})}))})};ine.displayName=FhA;var tZ="DialogOverlay",one=z.forwardRef((t,A)=>{const e=tne(tZ,t.__scopeDialog),{forceMount:i=e.forceMount,...o}=t,n=Lm(tZ,t.__scopeDialog);return n.modal?O.jsx(cy,{present:i||n.open,children:O.jsx(TTt,{...o,ref:A})}):null});one.displayName=tZ;var JTt=RTt("DialogOverlay.RemoveScroll"),TTt=z.forwardRef((t,A)=>{const{__scopeDialog:e,...i}=t,o=Lm(tZ,e);return O.jsx(k8,{as:JTt,allowPinchZoom:!0,shards:[o.contentRef],children:O.jsx(pg.div,{"data-state":RhA(o.open),...i,ref:A,style:{pointerEvents:"auto",...i.style}})})}),wF="DialogContent",nne=z.forwardRef((t,A)=>{const e=tne(wF,t.__scopeDialog),{forceMount:i=e.forceMount,...o}=t,n=Lm(wF,t.__scopeDialog);return O.jsx(cy,{present:i||n.open,children:n.modal?O.jsx(KTt,{...o,ref:A}):O.jsx(qTt,{...o,ref:A})})});nne.displayName=wF;var KTt=z.forwardRef((t,A)=>{const e=Lm(wF,t.__scopeDialog),i=z.useRef(null),o=wB(A,e.contentRef,i);return z.useEffect(()=>{const n=i.current;if(n)return sQA(n)},[]),O.jsx(sne,{...t,ref:o,trapFocus:e.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Qn(t.onCloseAutoFocus,n=>{n.preventDefault(),e.triggerRef.current?.focus()}),onPointerDownOutside:Qn(t.onPointerDownOutside,n=>{const s=n.detail.originalEvent,r=s.button===0&&s.ctrlKey===!0;(s.button===2||r)&&n.preventDefault()}),onFocusOutside:Qn(t.onFocusOutside,n=>n.preventDefault())})}),qTt=z.forwardRef((t,A)=>{const e=Lm(wF,t.__scopeDialog),i=z.useRef(!1),o=z.useRef(!1);return O.jsx(sne,{...t,ref:A,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:n=>{t.onCloseAutoFocus?.(n),n.defaultPrevented||(i.current||e.triggerRef.current?.focus(),n.preventDefault()),i.current=!1,o.current=!1},onInteractOutside:n=>{t.onInteractOutside?.(n),n.defaultPrevented||(i.current=!0,n.detail.originalEvent.type==="pointerdown"&&(o.current=!0));const s=n.target;e.triggerRef.current?.contains(s)&&n.preventDefault(),n.detail.originalEvent.type==="focusin"&&o.current&&n.preventDefault()}})}),sne=z.forwardRef((t,A)=>{const{__scopeDialog:e,trapFocus:i,onOpenAutoFocus:o,onCloseAutoFocus:n,...s}=t,r=Lm(wF,e),a=z.useRef(null),g=wB(A,a);return JCA(),O.jsxs(O.Fragment,{children:[O.jsx(g8,{asChild:!0,loop:!0,trapped:i,onMountAutoFocus:o,onUnmountAutoFocus:n,children:O.jsx(a8,{role:"dialog",id:r.contentId,"aria-describedby":r.descriptionId,"aria-labelledby":r.titleId,"data-state":RhA(r.open),...s,ref:g,onDismiss:()=>r.onOpenChange(!1)})}),O.jsxs(O.Fragment,{children:[O.jsx(OTt,{titleId:r.titleId}),O.jsx(ZTt,{contentRef:a,descriptionId:r.descriptionId})]})]})}),_hA="DialogTitle",rne=z.forwardRef((t,A)=>{const{__scopeDialog:e,...i}=t,o=Lm(_hA,e);return O.jsx(pg.h2,{id:o.titleId,...i,ref:A})});rne.displayName=_hA;var ane="DialogDescription",gne=z.forwardRef((t,A)=>{const{__scopeDialog:e,...i}=t,o=Lm(ane,e);return O.jsx(pg.p,{id:o.descriptionId,...i,ref:A})});gne.displayName=ane;var Ine="DialogClose",cne=z.forwardRef((t,A)=>{const{__scopeDialog:e,...i}=t,o=Lm(Ine,e);return O.jsx(pg.button,{type:"button",...i,ref:A,onClick:Qn(t.onClick,()=>o.onOpenChange(!1))})});cne.displayName=Ine;function RhA(t){return t?"open":"closed"}var Bne="DialogTitleWarning",[PTt,lne]=R5e(Bne,{contentName:wF,titleName:_hA,docsSlug:"dialog"}),OTt=({titleId:t})=>{const A=lne(Bne),e=`\`${A.contentName}\` requires a \`${A.titleName}\` for the component to be accessible for screen reader users.
5606
5606
 
5607
5607
  If you want to hide the \`${A.titleName}\`, you can wrap it with our VisuallyHidden component.
5608
5608
 
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "main": "dist/index.js",
4
4
  "types": "dist/index.d.ts",
5
5
  "type": "module",
6
- "version": "0.0.1083",
6
+ "version": "0.0.1084",
7
7
  "repository": {
8
8
  "type": "git",
9
9
  "url": "https://github.com/tscircuit/tscircuit"
@@ -54,7 +54,7 @@
54
54
  "@tscircuit/checks": "^0.0.87",
55
55
  "@tscircuit/circuit-json-flex": "^0.0.3",
56
56
  "@tscircuit/circuit-json-util": "^0.0.73",
57
- "@tscircuit/cli": "^0.1.677",
57
+ "@tscircuit/cli": "^0.1.678",
58
58
  "@tscircuit/copper-pour-solver": "^0.0.14",
59
59
  "@tscircuit/core": "^0.0.938",
60
60
  "@tscircuit/eval": "^0.0.551",
@@ -65,7 +65,7 @@
65
65
  "@tscircuit/miniflex": "^0.0.4",
66
66
  "@tscircuit/ngspice-spice-engine": "^0.0.8",
67
67
  "@tscircuit/props": "^0.0.432",
68
- "@tscircuit/runframe": "^0.0.1431",
68
+ "@tscircuit/runframe": "^0.0.1432",
69
69
  "@tscircuit/schematic-match-adapt": "^0.0.16",
70
70
  "@tscircuit/schematic-trace-solver": "^v0.0.45",
71
71
  "@tscircuit/simple-3d-svg": "^0.0.41",