@tscircuit/runframe 0.0.1743 → 0.0.1744

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1730,7 +1730,7 @@ var useErrorTelemetry = ({
1730
1730
  };
1731
1731
 
1732
1732
  // package.json
1733
- var version = "0.0.1742";
1733
+ var version = "0.0.1743";
1734
1734
  var package_default = {
1735
1735
  name: "@tscircuit/runframe",
1736
1736
  main: "dist/preview.js",
@@ -1784,7 +1784,7 @@ var package_default = {
1784
1784
  "@tscircuit/create-snippet-url": "^0.0.9",
1785
1785
  "@tscircuit/fake-snippets": "^0.0.163",
1786
1786
  "@tscircuit/file-server": "^0.0.32",
1787
- "@tscircuit/pcb-viewer": "1.11.354",
1787
+ "@tscircuit/pcb-viewer": "1.11.355",
1788
1788
  "@tscircuit/schematic-viewer": "^2.0.59",
1789
1789
  "@types/bun": "latest",
1790
1790
  "@types/debug": "^4.1.12",
package/dist/preview.js CHANGED
@@ -8,7 +8,7 @@ import {
8
8
  linkify,
9
9
  useOrderDialog,
10
10
  useOrderDialogCli
11
- } from "./chunk-WZZNZHNN.js";
11
+ } from "./chunk-2652JHDP.js";
12
12
  export {
13
13
  BomTable,
14
14
  CadViewer,
package/dist/runner.js CHANGED
@@ -34,7 +34,7 @@ import {
34
34
  useRunFrameStore,
35
35
  useRunnerStore,
36
36
  useStyles
37
- } from "./chunk-WZZNZHNN.js";
37
+ } from "./chunk-2652JHDP.js";
38
38
 
39
39
  // lib/components/RunFrame/RunFrame.tsx
40
40
  import { createCircuitWebWorker } from "@tscircuit/eval/worker";
@@ -5468,7 +5468,7 @@ $1`).replace(/>(\s*)(?=<!--\s*\/)/g,"> ")}}});function gQt(e,A,t){if(!A||!t)retu
5468
5468
  transition: opacity 0.2s;
5469
5469
  margin-bottom: 10px;
5470
5470
  color: red;
5471
- `,f$e=({children:e,transform:A=ba(),elements:t})=>{const i=AA.useRef(null),{isShowingDRCErrors:n,hoveredErrorId:o}=rl(g=>({isShowingDRCErrors:g.is_showing_drc_errors,hoveredErrorId:g.hovered_error_id}));if(!t)return Z.jsx("div",{style:{position:"relative"},ref:i,children:e});const s=t.filter(g=>g.type==="pcb_trace_error"),r=t.filter(g=>g.type==="pcb_trace_error"&&g.message?.includes("Multiple components found with name")),a=new Map;return t.forEach(g=>{g.type==="pcb_port"&&a.set(g.pcb_port_id,g)}),Z.jsxs("div",{style:{position:"relative"},ref:i,children:[e,s.map((g,c)=>{const{pcb_port_ids:I,pcb_trace_id:l}=g,B=I?.[0]?a.get(I[0]):void 0,C=I?.[1]?a.get(I[1]):void 0,Q=t?Xb(t).pcb_trace.get(l):void 0,h=g.pcb_trace_error_id||`error_${c}_${g.error_type}_${g.message?.slice(0,20)}`,E=o===h;if(B&&C){const u=Ct(A,{x:B.x,y:B.y}),d=Ct(A,{x:C.x,y:C.y});if(!n)return null;const f=!(isNaN(u.x)||isNaN(u.y)||isNaN(d.x)||isNaN(d.y)),m={x:(u.x+d.x)/2,y:(u.y+d.y)/2};if(isNaN(m.x)||isNaN(m.y))return null;const w=CyA(m,i);return Z.jsxs(AA.Fragment,{children:[Z.jsx(d$e,{screenPort1:u,screenPort2:d,errorCenter:m,canLineBeDrawn:f,isHighlighted:E}),Z.jsx("div",{style:{position:"absolute",left:m.x-15,top:m.y-15,width:30,height:30,zIndex:xc.errorOverlay+5,cursor:"pointer",borderRadius:"50%"},onMouseEnter:D=>{const S=D.currentTarget.nextElementSibling;if(S){const _=S.querySelector(".error-message");_&&(_.style.opacity="1")}},onMouseLeave:D=>{if(!E){const S=D.currentTarget.nextElementSibling;if(S){const _=S.querySelector(".error-message");_&&(_.style.opacity="0")}}}}),Z.jsx("div",{style:{position:"absolute",zIndex:E?200:100,left:w.left,top:w.top,color:E?"#ff4444":"red",textAlign:"center",fontFamily:"sans-serif",fontSize:12,display:n||E?"flex":"none",flexDirection:"column",alignItems:"center",pointerEvents:"none",transform:w.transform},children:Z.jsx("div",{className:`error-message ${QyA}`,style:{opacity:E?1:0,border:`1px solid ${E?"#ff4444":"red"}`},children:g.message})})]},h)}if(Q?.route&&(n||E)){const u=Q.route.map(w=>Ct(A,{x:w.x,y:w.y}));if(u.some(w=>isNaN(w.x)||isNaN(w.y)))return null;const d=Math.floor(u.length/2),f=u[d],m=CyA(f,i);return Z.jsxs(AA.Fragment,{children:[Z.jsx(p$e,{points:u,errorCenter:f,isHighlighted:E}),Z.jsx("div",{style:{position:"absolute",left:f.x-15,top:f.y-15,width:30,height:30,zIndex:xc.errorOverlay+5,cursor:"pointer",borderRadius:"50%"},onMouseEnter:w=>{const D=w.currentTarget.nextElementSibling;if(D){const S=D.querySelector(".error-message");S&&(S.style.opacity="1")}},onMouseLeave:w=>{if(!E){const D=w.currentTarget.nextElementSibling;if(D){const S=D.querySelector(".error-message");S&&(S.style.opacity="0")}}}}),Z.jsx("div",{style:{position:"absolute",zIndex:E?xc.errorOverlay+10:xc.errorOverlay+1,left:m.left,top:m.top,color:E?"#ff4444":"red",textAlign:"center",fontFamily:"sans-serif",fontSize:12,display:"flex",flexDirection:"column",alignItems:"center",pointerEvents:"none",transform:m.transform},children:Z.jsx("div",{className:`error-message ${QyA}`,style:{opacity:E?1:0,border:`1px solid ${E?"#ff4444":"red"}`},children:g.message})})]},h)}return null}),r.map((g,c)=>{const I=g.component_name||g.message?.match(/name "([^"]+)"/)?.[1];if(!I)return null;const l=t?.filter(Q=>Q.type==="source_component"&&Q.name===I||Q.type==="pcb_component"&&t?.find(h=>h.type==="source_component"&&h.source_component_id===Q.source_component_id&&h.name===I))||[],B=g.pcb_trace_error_id||`error_${c}_${g.error_type}_${g.message?.slice(0,20)}`,C=o===B;return!C&&!n?null:l.map((Q,h)=>{let E={x:0,y:0};if(Q.type==="pcb_component")E=Q.center||{x:0,y:0};else if(Q.type==="source_component"){const _=t?.find(b=>b.type==="pcb_component"&&b.source_component_id===Q.source_component_id);_&&_.type==="pcb_component"&&(E=_.center||{x:0,y:0})}const u=Ct(A,E);if(isNaN(u.x)||isNaN(u.y))return null;const d=Math.abs(A.a),D=Math.max(8,Math.min(30,.5*d)),S=CyA(u,i);return Z.jsxs(AA.Fragment,{children:[Z.jsx("svg",{style:{position:"absolute",left:0,top:0,pointerEvents:"none",mixBlendMode:"difference",zIndex:xc.errorOverlay},width:"100%",height:"100%",children:C?Z.jsx("polygon",{points:`${u.x},${u.y-D*1.25} ${u.x+D},${u.y} ${u.x},${u.y+D*1.25} ${u.x-D},${u.y}`,fill:"#ff4444"}):Z.jsx("circle",{cx:u.x,cy:u.y,r:D,fill:"none",stroke:C?"#ff4444":"red",strokeWidth:C?Math.max(2,D*.15):Math.max(1,D*.1),opacity:1})}),Z.jsx("div",{style:{position:"absolute",left:u.x-(D+10),top:u.y-(D+10),width:(D+10)*2,height:(D+10)*2,zIndex:xc.errorOverlay+5,cursor:"pointer",borderRadius:"50%"},onMouseEnter:_=>{const b=_.currentTarget.nextElementSibling;if(b){const R=b.querySelector(".error-message");R&&(R.style.opacity="1")}},onMouseLeave:_=>{if(!C){const b=_.currentTarget.nextElementSibling;if(b){const R=b.querySelector(".error-message");R&&(R.style.opacity="0")}}}}),Z.jsx("div",{style:{position:"absolute",zIndex:C?xc.errorOverlay+20:xc.errorOverlay+10,left:S.left,top:S.top,color:C?"#ff4444":"red",textAlign:"center",fontFamily:"sans-serif",fontSize:12,display:n||C?"flex":"none",flexDirection:"column",alignItems:"center",pointerEvents:"none",transform:S.transform},children:Z.jsx("div",{className:`error-message ${QyA}`,style:{opacity:C?1:0,border:`1px solid ${C?"#ff4444":"red"}`},children:g.message})})]},`${B}_${h}`)})})]})};function y$e(e,A){return e.size!==A.size?!1:Array.from(e).every(t=>A.has(t))}function m$e({primitiveElement:e,elements:A}){let t=e.trace_length?`${e.trace_length.toFixed(3)}`:"";const i=Xb(A).source_trace.get(e?.source_trace_id);if(i?.display_name&&(i?.max_length?t+=` / ${i.max_length}mm `:t+=" mm ",t+=`(${i.display_name})`),!t)return null;const n=e.trace_length&&i?.max_length&&e.trace_length>i.max_length;return{text:t,isOverLength:n}}function w$e(e){const{primitives:A,is_showing_multiple_traces_length:t,elements:i}=e,n=A.filter(a=>a._element.type==="pcb_trace"),o=i.filter(a=>a.type==="source_trace"),s=A.filter(a=>a._element.type!=="pcb_trace"),r=n.filter(a=>o.some(g=>a._element.type==="pcb_trace"&&a._element.source_trace_id===g.source_trace_id&&g.max_length!==void 0));if(!t)return[...s,...r];if(n.length>1){const a=n.reduce((g,c)=>{const I=g._element.trace_length;return c._element.trace_length<I?c:g},n[0]);return[...s,a]}return A}var D$e={position:"absolute",left:0,top:0,pointerEvents:"none",color:"red",fontFamily:"sans-serif",fontSize:12,textShadow:"0 0 2px black"},S$e=e=>{const{_element:A,_parent_pcb_component:t,_parent_source_component:i,_source_port:n}=e;switch(A.type){case"pcb_trace":return A.trace_length?`${A.trace_length.toFixed(3)}`:"";case"pcb_smtpad":case"pcb_plated_hole":{const o=[],s=Array.from(new Set((A.port_hints??[]).concat(n?.port_hints??[]))).filter(a=>!/^[0-9]+$/.test(a)).filter(a=>!a.includes("unnamed_")).sort((a,g)=>g.localeCompare(a)),r=i&&"name"in i&&i.name&&!i.name.includes("unnamed_")?i.name:null;return s.length>0?r?o.push(...s.map(a=>`${r}.${a}`)):o.push(...s):r&&o.push(r),o.join(", ")}default:return""}},b$e={top:"red",bottom:"aqua"},x$e=({primitive:e,mousePos:A,elements:t})=>{const[i,n]=AA.useState(!1),o=e._element;AA.useEffect(()=>{setTimeout(()=>{n(!0)},100)},[]);const[s,r,a,g]=[e.screen_x,e.screen_y,e.screen_w,e.screen_h],c=e.same_space_index??0,I=26,l=b$e[e?._element?.layer]??"red";let B=0;if(o.type==="pcb_smtpad"&&o?.shape==="rotated_rect"?B=o?.ccw_rotation??0:(o.type==="pcb_smtpad"&&(o?.shape==="pill"||o?.shape==="rotated_pill")&&"ccw_rotation"in e||o.type==="pcb_plated_hole"&&(o?.shape==="pill"||o?.shape==="oval")&&"ccw_rotation"in e)&&(B=o.ccw_rotation??0),o.type==="pcb_trace"){const h=m$e({primitiveElement:o,elements:t});if(!h)return null;const E=A.y-35;return Z.jsx("div",{style:{zIndex:xc.elementOverlay,position:"absolute",left:A.x,top:E,color:l,pointerEvents:"none",transform:"translateX(-50%)"},children:Z.jsx("div",{style:{backgroundColor:"#f2efcc",color:h.isOverLength?"red":"black",textShadow:"none",WebkitFontSmoothing:"antialiased",MozOsxFontSmoothing:"grayscale",padding:"6px 6px",borderRadius:"6px",fontSize:"14px",minWidth:"45px",textAlign:"center",whiteSpace:"nowrap"},children:h.text})})}const C=S$e(e);return C.trim().length===0?null:Z.jsx("div",{style:{zIndex:xc.elementOverlay,position:"absolute",left:s-a/2-8,top:r-g/2-8,width:a+16,height:g+16,color:l,transform:`rotate(${-B}deg)`,transformOrigin:"center center"},children:Z.jsx("div",{style:{width:i?`calc(100% + ${I*2*c}px)`:"100%",height:i?`calc(100% + ${I*2*c}px)`:"100%",marginLeft:i?`${-I*c}px`:0,marginTop:i?`${-I*c}px`:0,border:`1px solid ${l}`,opacity:i||c===0?1:0,transition:"width 0.2s, height 0.2s, margin-left 0.2s, margin-top 0.2s, opacity 0.2s"},children:Z.jsx("div",{style:{position:"absolute",bottom:g+20+I*c,marginRight:i?`${-I*c}px`:0,marginBottom:i?0:-I*c,transition:"margin-right 0.2s, margin-bottom 0.2s",backgroundColor:"#f2efcc",color:"black",textShadow:"none",WebkitFontSmoothing:"antialiased",MozOsxFontSmoothing:"grayscale",padding:"6px 6px",borderRadius:"6px",fontSize:"14px",transform:`rotate(${B}deg)`,minWidth:"45px",textAlign:"center"},children:C})})})},_$e=({highlightedPrimitives:e,mousePos:A,elements:t})=>{const[i,n]=rl(r=>[r.is_moving_component,r.is_showing_multiple_traces_length]),o=e.some(r=>r._element.type==="pcb_smtpad")&&e.some(r=>r._element.type==="pcb_trace");let s=e;return o&&(s=s.filter(r=>r._element.type==="pcb_smtpad")),s=w$e({primitives:s,is_showing_multiple_traces_length:n,elements:t}),Z.jsx("div",{style:D$e,children:!i&&s.map((r,a)=>Z.jsx(x$e,{primitive:r,mousePos:A,elements:t},a))})},Rk=e=>e?.type==="pcb_component",UQt=e=>e?.type==="pcb_group",k$e=e=>e?.type==="pcb_panel",hyA=e=>e?.type==="pcb_board",rI={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},ey={OFFSET_LINE:"white",COMPONENT_MARKER_FILL:"#66ccff",COMPONENT_MARKER_STROKE:"white",LABEL_TEXT:"white"},EyA=({targets:e,transform:A,containerWidth:t,containerHeight:i})=>{if(e.length===0)return null;const n={color:ey.LABEL_TEXT,mixBlendMode:"difference",pointerEvents:"none",fontSize:rI.LABEL_FONT_SIZE,fontFamily:"monospace",fontWeight:"bold"},o=new Map;return e.forEach(s=>{if(!o.has(s.anchor_id)){const r=Ct(A,s.anchor);o.set(s.anchor_id,r)}}),Z.jsx("div",{style:{position:"absolute",left:0,top:0,width:t,height:i,overflow:"hidden",pointerEvents:"none",zIndex:xc.dimensionOverlay},children:Z.jsxs("svg",{style:{position:"absolute",left:0,top:0,pointerEvents:"none"},width:t,height:i,children:[e.map(s=>{const r=s.anchor,a=s.anchor_id,g=s.target,c=o.get(a),I=Ct(A,g),l=g.x-r.x,B=g.y-r.y,C=Math.abs(I.x-c.x),Q=Math.abs(I.y-c.y),h=I.y<c.y,E=I.x>c.x,u=h?rI.LABEL_OFFSET_ABOVE:rI.LABEL_OFFSET_BELOW,d=E?rI.LABEL_OFFSET_RIGHT:rI.LABEL_OFFSET_LEFT,f=C>rI.MIN_LINE_LENGTH_FOR_LABEL,m=Q>rI.MIN_LINE_LENGTH_FOR_LABEL,w=`${s.display_offset_x??l.toFixed(2)}mm`,D=`${s.display_offset_y??B.toFixed(2)}mm`;return Z.jsxs("g",{children:[Z.jsx("line",{x1:c.x,y1:c.y,x2:I.x,y2:c.y,stroke:ey.OFFSET_LINE,strokeWidth:rI.LINE_STROKE_WIDTH,strokeDasharray:rI.LINE_DASH_PATTERN}),Z.jsx("line",{x1:I.x,y1:c.y,x2:I.x,y2:I.y,stroke:ey.OFFSET_LINE,strokeWidth:rI.LINE_STROKE_WIDTH,strokeDasharray:rI.LINE_DASH_PATTERN}),s.type==="component"||s.type==="board"?Z.jsx("circle",{cx:I.x,cy:I.y,r:rI.COMPONENT_MARKER_RADIUS,fill:ey.COMPONENT_MARKER_FILL,stroke:ey.COMPONENT_MARKER_STROKE,strokeWidth:1}):Z.jsxs(Z.Fragment,{children:[Z.jsx("line",{x1:I.x-rI.ANCHOR_MARKER_SIZE,y1:I.y,x2:I.x+rI.ANCHOR_MARKER_SIZE,y2:I.y,stroke:ey.OFFSET_LINE,strokeWidth:rI.ANCHOR_MARKER_STROKE_WIDTH}),Z.jsx("line",{x1:I.x,y1:I.y-rI.ANCHOR_MARKER_SIZE,x2:I.x,y2:I.y+rI.ANCHOR_MARKER_SIZE,stroke:ey.OFFSET_LINE,strokeWidth:rI.ANCHOR_MARKER_STROKE_WIDTH})]}),f&&Z.jsx("foreignObject",{x:Math.min(c.x,I.x),y:c.y+u,width:Math.abs(I.x-c.x),height:20,style:{overflow:"visible"},children:Z.jsx("div",{style:{...n,textAlign:"center"},children:w})}),m&&Z.jsx("foreignObject",{x:I.x+d,y:Math.min(c.y,I.y),width:rI.Y_LABEL_MIN_WIDTH,height:Math.abs(I.y-c.y),style:{overflow:"visible"},children:Z.jsx("div",{style:{...n,display:"flex",alignItems:"center",justifyContent:E?"flex-start":"flex-end",whiteSpace:"nowrap",padding:"0 4px",height:"100%"},children:D})})]},s.id)}),Array.from(o.entries()).map(([s,r])=>Z.jsxs("g",{children:[Z.jsx("line",{x1:r.x-rI.ANCHOR_MARKER_SIZE,y1:r.y,x2:r.x+rI.ANCHOR_MARKER_SIZE,y2:r.y,stroke:ey.OFFSET_LINE,strokeWidth:rI.ANCHOR_MARKER_STROKE_WIDTH}),Z.jsx("line",{x1:r.x,y1:r.y-rI.ANCHOR_MARKER_SIZE,x2:r.x,y2:r.y+rI.ANCHOR_MARKER_SIZE,stroke:ey.OFFSET_LINE,strokeWidth:rI.ANCHOR_MARKER_STROKE_WIDTH})]},`anchor-${s}`))]})})},v$e=({elements:e,highlightedPrimitives:A,transform:t,containerWidth:i,containerHeight:n})=>{const o=e.filter(E=>hyA(E)),s=e.filter(E=>Rk(E)),r=e.filter(E=>UQt(E)),a=A.map(E=>Rk(E._parent_pcb_component)?E._parent_pcb_component.pcb_component_id:Rk(E._element)?E._element.pcb_component_id:null).filter(E=>!!E),g=new Set;if(a.forEach(E=>{const u=s.find(d=>d.pcb_component_id===E);u?.pcb_group_id&&g.add(u.pcb_group_id)}),!rl(E=>E.is_showing_group_anchor_offsets)&&a.length===0)return null;const I=s.map(E=>{const u=E.positioned_relative_to_pcb_board_id;if(!u)return null;const d=o.find(f=>f.pcb_board_id===u);return d?{component:E,board:d,type:"component"}:null}).filter(E=>!!E),l=r.map(E=>{const u=E.positioned_relative_to_pcb_board_id;if(!u||!E.center)return null;const d=o.find(f=>f.pcb_board_id===u);return d?{group:E,board:d,type:"group"}:null}).filter(E=>!!E),B=[...I,...l];if(B.length===0)return null;const C=a.length===0,Q=B.filter(E=>E.type==="component"?C||a.includes(E.component.pcb_component_id):C||g.has(E.group.pcb_group_id));if(Q.length===0)return null;const h=Q.map(E=>E.type==="component"?{id:`${E.board.pcb_board_id}-${E.component.pcb_component_id}-${E.type}`,anchor:E.board.center,anchor_id:E.board.pcb_board_id,target:E.component.center,type:"component",display_offset_x:E.component.display_offset_x,display_offset_y:E.component.display_offset_y}:{id:`${E.board.pcb_board_id}-${E.group.pcb_group_id}-${E.type}`,anchor:E.board.center,anchor_id:E.board.pcb_board_id,target:{x:E.group.anchor_position?.x??E.group.center.x,y:E.group.anchor_position?.y??E.group.center.y},type:"group",display_offset_x:E.group.display_offset_x,display_offset_y:E.group.display_offset_y}).filter(E=>!!E);return Z.jsx(EyA,{targets:h,transform:t,containerWidth:i,containerHeight:n})},F$e=({elements:e,highlightedPrimitives:A,transform:t,containerWidth:i,containerHeight:n})=>{const o=e.filter(E=>UQt(E)),s=e.filter(E=>Rk(E)),r=A.map(E=>Rk(E._parent_pcb_component)?E._parent_pcb_component.pcb_component_id:Rk(E._element)?E._element.pcb_component_id:null).filter(E=>!!E),a=(E,u)=>{if(u.has(E))return;u.add(E);const d=o.find(f=>f.pcb_group_id===E);d?.position_mode==="relative_to_group_anchor"&&d.positioned_relative_to_pcb_group_id&&a(d.positioned_relative_to_pcb_group_id,u)},g=new Set;if(r.forEach(E=>{const u=s.find(d=>d.pcb_component_id===E);u&&(u.position_mode==="relative_to_group_anchor"&&u.positioned_relative_to_pcb_group_id&&a(u.positioned_relative_to_pcb_group_id,g),u.pcb_group_id&&a(u.pcb_group_id,g))}),!rl(E=>E.is_showing_group_anchor_offsets)&&r.length===0)return null;const I=s.map(E=>{if(E.position_mode==="relative_to_group_anchor"&&E.positioned_relative_to_pcb_group_id){const u=o.find(d=>d.pcb_group_id===E.positioned_relative_to_pcb_group_id);return u&&u.anchor_position?{component:E,parentGroup:u,type:"component"}:null}if(E.pcb_group_id){const u=o.find(d=>d.pcb_group_id===E.pcb_group_id);return u&&u.anchor_position?{component:E,parentGroup:u,type:"component"}:null}return null}).filter(E=>!!E),l=o.map(E=>{if(E.position_mode==="relative_to_group_anchor"&&E.positioned_relative_to_pcb_group_id){const u=o.find(d=>d.pcb_group_id===E.positioned_relative_to_pcb_group_id);if(u&&u.anchor_position&&E.anchor_position)return{group:E,parentGroup:u,type:"group"}}return null}).filter(E=>!!E),B=[...I,...l];if(B.length===0)return null;const C=r.length===0,Q=B.filter(E=>E.type==="component"?C||r.includes(E.component.pcb_component_id):C||g.has(E.group.pcb_group_id)||g.has(E.parentGroup.pcb_group_id));if(Q.length===0)return null;const h=Q.map(E=>{const u=E.parentGroup.anchor_position;return u?E.type==="component"?E.component.center?{id:`${E.parentGroup.pcb_group_id}-${E.component.pcb_component_id}-${E.type}`,anchor:u,anchor_id:E.parentGroup.pcb_group_id,target:E.component.center,type:"component",display_offset_x:E.component.display_offset_x,display_offset_y:E.component.display_offset_y}:null:E.group.anchor_position?{id:`${E.parentGroup.pcb_group_id}-${E.group.pcb_group_id}-${E.type}`,anchor:u,anchor_id:E.parentGroup.pcb_group_id,target:E.group.anchor_position,type:"group",display_offset_x:E.group.display_offset_x,display_offset_y:E.group.display_offset_y}:null:null}).filter(E=>!!E);return Z.jsx(EyA,{targets:h,transform:t,containerWidth:i,containerHeight:n})},M$e=(e,A)=>{const t=e.pcb_component_id,i=A.filter(n=>(n.type==="pcb_smtpad"||n.type==="pcb_plated_hole")&&n.pcb_component_id===t||n.type==="pcb_hole"&&n.pcb_component_id===t);return i.length===0?lyA([e]):lyA(i)},G$e=({elements:e,highlightedPrimitives:A,transform:t,containerWidth:i,containerHeight:n})=>{const o=new Map;for(const r of A)Rk(r._parent_pcb_component)&&o.set(r._parent_pcb_component.pcb_component_id,r._parent_pcb_component),Rk(r._element)&&o.set(r._element.pcb_component_id,r._element);if(o.size===0)return null;const s=[];for(const r of o.values()){const a=M$e(r,e);if(!a)continue;const g=r.positioned_relative_to_pcb_group_id??r.pcb_group_id,c=g?Xb(e).pcb_group.get(g):null;s.push({component:r,bbox:a,group:c})}return s.length===0?null:Z.jsx("div",{style:{position:"absolute",left:0,top:0,width:i,height:n,overflow:"hidden",pointerEvents:"none",zIndex:xc.dimensionOverlay},children:Z.jsx("svg",{style:{position:"absolute",left:0,top:0,pointerEvents:"none"},width:i,height:n,children:s.map(({component:r,bbox:a,group:g})=>{const c=Ct(t,{x:a.minX,y:a.maxY}),I=Ct(t,{x:a.maxX,y:a.minY}),l={x:Math.min(c.x,I.x),y:Math.min(c.y,I.y),width:Math.abs(I.x-c.x),height:Math.abs(I.y-c.y)},B=r.center??{x:(a.minX+a.maxX)/2,y:(a.minY+a.maxY)/2},C=Ct(t,B);return Z.jsxs("g",{children:[Z.jsx("rect",{x:l.x,y:l.y,width:l.width,height:l.height,fill:"none",stroke:"white",strokeWidth:1.5,strokeDasharray:"4,4"}),Z.jsx("line",{x1:C.x-6,y1:C.y,x2:C.x+6,y2:C.y,stroke:ey.COMPONENT_MARKER_STROKE,strokeWidth:1.5}),Z.jsx("line",{x1:C.x,y1:C.y-6,x2:C.x,y2:C.y+6,stroke:ey.COMPONENT_MARKER_STROKE,strokeWidth:1.5}),Z.jsx("circle",{cx:C.x,cy:C.y,r:rI.COMPONENT_MARKER_RADIUS,fill:ey.COMPONENT_MARKER_FILL,stroke:ey.COMPONENT_MARKER_STROKE,strokeWidth:1})]},r.pcb_component_id)})})})},R$e=({elements:e,highlightedPrimitives:A,transform:t,containerWidth:i,containerHeight:n})=>{const o=e.filter(B=>k$e(B)),s=e.filter(B=>hyA(B)),r=A.map(B=>hyA(B._element)?B._element.pcb_board_id:null).filter(B=>!!B);if(!rl(B=>B.is_showing_group_anchor_offsets)&&r.length===0)return null;const g=s.map(B=>{const C=B.pcb_panel_id,Q=B.position_mode;if(!C||Q!=="relative_to_panel_anchor")return null;const h=o.find(E=>E.pcb_panel_id===C);return h?{board:B,panel:h,type:"board"}:null}).filter(B=>!!B);if(g.length===0)return null;const c=r.length===0,I=g.filter(B=>c||r.includes(B.board.pcb_board_id));if(I.length===0)return null;const l=I.map(B=>B.board.center?{id:`${B.panel.pcb_panel_id}-${B.board.pcb_board_id}-${B.type}`,anchor:B.panel.center,anchor_id:B.panel.pcb_panel_id,target:B.board.center,type:"board",display_offset_x:B.board.display_offset_x,display_offset_y:B.board.display_offset_y}:null).filter(B=>!!B);return Z.jsx(EyA,{targets:l,transform:t,containerWidth:i,containerHeight:n})},Zj=e=>{if(e.length===0)return null;let A=e[0].x,t=e[0].y,i=e[0].x,n=e[0].y;for(const o of e)o.x<A&&(A=o.x),o.y<t&&(t=o.y),o.x>i&&(i=o.x),o.y>n&&(n=o.y);return{center:{x:(A+i)/2,y:(t+n)/2},width:i-A,height:n-t}},HQt=(e,A)=>{if(A.length<3)return!1;let t=!1;for(let i=0,n=A.length-1;i<A.length;n=i++){const o=A[i].x,s=A[i].y,r=A[n].x,a=A[n].y;s>e.y!=a>e.y&&e.x<(r-o)*(e.y-s)/(a-s||Number.EPSILON)+o&&(t=!t)}return t},N$e=(e,A,t)=>{const i=[];for(const n of e){if(!n._element)continue;if("x1"in n&&n._element?.type==="pcb_trace"){const r=KE({x:A.x,y:A.y},{x:n.x1,y:n.y1},{x:n.x2,y:n.y2}),a=n.width||.5,g=Math.max(a*25,2)/t.a;r<g&&i.push(n);continue}if(n.pcb_drawing_type==="polygon"){const r=n.points.map(g=>({x:Ee.parse(g.x),y:Ee.parse(g.y)})),a=Zj(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;HQt(A,r)&&i.push(n);continue}if(n.pcb_drawing_type==="polygon_with_arcs"){const r=n.brep_shape.outer_ring.vertices.map(g=>({x:Ee.parse(g.x),y:Ee.parse(g.y)})),a=Zj(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;HQt(A,r)&&i.push(n);continue}if(!("x"in n&&"y"in n))continue;let o=0,s=0;if("w"in n&&"h"in n)o=n.w,s=n.h;else if("r"in n)o=n.r*2,s=n.r*2;else if("rX"in n&&"rY"in n)o=n.rX*2,s=n.rY*2;else continue;Math.abs(n.x-A.x)<o/2&&Math.abs(n.y-A.y)<s/2&&i.push(n)}return i},L$e=({elements:e,children:A,transform:t,primitives:i,onMouseHoverOverPrimitives:n})=>{const[o,s]=AA.useState([]),[r,a]=AA.useState({x:0,y:0}),[g,{width:c,height:I}]=fT(),l=AA.useMemo(()=>{const C=[];for(const Q of o){if(Q._element?.type==="pcb_via"||Q._element?.type==="pcb_component"||Q?.layer==="drill")continue;let h=null,E=0,u=0;if(Q.pcb_drawing_type==="polygon"){const w=Zj(Q.points);if(!w)continue;h=w.center,E=w.width,u=w.height}else if(Q.pcb_drawing_type==="polygon_with_arcs"){const w=Q.brep_shape.outer_ring.vertices.map(S=>({x:S.x,y:S.y})),D=Zj(w);if(!D)continue;h=D.center,E=D.width,u=D.height}else"x"in Q&&"y"in Q&&(h={x:Q.x,y:Q.y},E="w"in Q?Q.w:"r"in Q?Q.r*2:"rX"in Q&&"rY"in Q?Q.rX*2:0,u="h"in Q?Q.h:"r"in Q?Q.r*2:"rX"in Q&&"rY"in Q?Q.rY*2:0);if(!h)continue;const d=Ct(t,h),f={w:E*t.a,h:u*t.a},m=C.filter(w=>d.x===w.screen_x&&d.y===w.screen_y&&f.w===w.screen_w&&f.h===w.screen_h).length;C.push({...Q,x:h.x,y:h.y,w:E,h:u,screen_x:d.x,screen_y:d.y,screen_w:f.w,screen_h:f.h,same_space_index:m})}return C},[o,t]),B=(C,Q,h,E)=>{a({x:C,y:Q});const u=Ct(Xy(h),{x:C,y:Q}),d=N$e(E,u,h);y$e(new Set(d.map(f=>f._pcb_drawing_object_id)),new Set(o.map(f=>f._pcb_drawing_object_id)))||(s(d),n(d))};return Z.jsxs("div",{ref:g,style:{position:"relative",width:"100%",height:"100%"},onMouseMove:C=>{if(t){const Q=C.currentTarget.getBoundingClientRect(),h=C.clientX-Q.left,E=C.clientY-Q.top;B(h,E,t,i)}},onTouchStart:C=>{if(t){const Q=C.touches[0],h=C.currentTarget.getBoundingClientRect(),E=Q.clientX-h.left,u=Q.clientY-h.top;B(E,u,t,i)}},children:[A,Z.jsx(_$e,{elements:e,mousePos:r,highlightedPrimitives:l}),t&&Z.jsxs(Z.Fragment,{children:[Z.jsx(v$e,{elements:e,highlightedPrimitives:l,transform:t,containerWidth:c,containerHeight:I}),Z.jsx(F$e,{elements:e,highlightedPrimitives:l,transform:t,containerWidth:c,containerHeight:I}),Z.jsx(G$e,{elements:e,highlightedPrimitives:l,transform:t,containerWidth:c,containerHeight:I}),Z.jsx(R$e,{elements:e,highlightedPrimitives:l,transform:t,containerWidth:c,containerHeight:I})]})]})},YQt=["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)"],U$e=({children:e,transform:A=ba(),elements:t=[],hoveredComponentIds:i=[]})=>{const[n,{width:o,height:s}]=fT(),r=AA.useRef(null),{is_showing_pcb_groups:a,pcb_group_view_mode:g,is_showing_group_anchor_offsets:c}=rl(I=>({is_showing_pcb_groups:I.is_showing_pcb_groups,pcb_group_view_mode:I.pcb_group_view_mode,is_showing_group_anchor_offsets:I.is_showing_group_anchor_offsets}));return AA.useEffect(()=>{const I=r.current;if(!I||!o||!s)return;I.width=o,I.height=s;const l=I.getContext("2d");if(!l||(l.clearRect(0,0,o,s),!a))return;const B=t.filter(w=>w.type==="pcb_group"),C=t.filter(w=>w.type==="pcb_component"),Q=t.filter(w=>w.type==="source_group"),h=new Map(Q.map(w=>[w.source_group_id,w])),E=B.filter(w=>{if(w.name?.toLowerCase().includes("subpanel"))return!1;if(g==="all")return!0;if(!w.source_group_id)return!1;const D=h.get(w.source_group_id);return D?D.was_automatically_named!==!0:!1}),u=new Map;Q.forEach(w=>{const D=w;if(D.parent_source_group_id){const S=u.get(D.parent_source_group_id)||[];S.push(w.source_group_id),u.set(D.parent_source_group_id,S)}});const d=w=>{const D=[],S=u.get(w)||[];for(const _ of S)D.push(_),D.push(...d(_));return D},f=w=>{const D=Q.find(S=>S.source_group_id===w);return D?.parent_source_group_id?1+f(D.parent_source_group_id):0},m=new Set;if(i.length>0)for(const w of C){if(!i.includes(w.pcb_component_id))continue;const D=w.positioned_relative_to_pcb_group_id??w.pcb_group_id;D&&m.add(D)}E.forEach((w,D)=>{let S=C.filter(JA=>JA.pcb_group_id===w.pcb_group_id);if(w.source_group_id){const JA=d(w.source_group_id),OA=B.filter(_A=>_A.source_group_id&&JA.includes(_A.source_group_id));for(const _A of OA){const DA=C.filter(NA=>NA.pcb_group_id===_A.pcb_group_id);S=[...S,...DA]}}let _,b,R,F,H=!1;if(w.center&&w.width&&w.height){H=!0;const JA=w.width/2,OA=w.height/2;_=w.center.x-JA,R=w.center.x+JA,b=w.center.y-OA,F=w.center.y+OA}else if(S.length===0||(_=1/0,b=1/0,R=-1/0,F=-1/0,S.forEach(JA=>{if(JA.center&&typeof JA.width=="number"&&typeof JA.height=="number"){const OA=JA.center.x-JA.width/2,_A=JA.center.x+JA.width/2,DA=JA.center.y+JA.height/2,NA=JA.center.y-JA.height/2;_=Math.min(_,OA),R=Math.max(R,_A),b=Math.min(b,NA),F=Math.max(F,DA)}}),_===1/0||R===-1/0))return;const Y=w.source_group_id?f(w.source_group_id):0,J=w.source_group_id?d(w.source_group_id).length>0:!1;if(!H){const _A=1+(J?.5:0);_-=_A,R+=_A,b-=_A,F+=_A}const O=Ct(A,{x:_,y:F}),W=Ct(A,{x:R,y:F}),z=Ct(A,{x:_,y:b}),tA=Ct(A,{x:R,y:b}),aA=YQt[D%YQt.length];l.strokeStyle=aA,l.lineWidth=2;const eA=Math.max(4,Math.min(12,8*Math.abs(A.a))),oA=Math.max(2,Math.min(6,4*Math.abs(A.a))),lA=eA*(J?1.3:1),pA=oA;l.setLineDash([lA,pA]),l.beginPath(),l.moveTo(O.x,O.y),l.lineTo(W.x,W.y),l.lineTo(tA.x,tA.y),l.lineTo(z.x,z.y),l.closePath(),l.stroke();const vA=Math.max(8,Math.min(12,10*Math.abs(A.a))),MA=Y==0||Y==1?0:Y*.11,YA=vA*(1-MA),EA=4,xA=w.name||`Group ${D+1}`;l.font=`${YA}px sans-serif`,l.setLineDash([]);const WA=l.measureText(xA).width+EA*2,jA=YA+EA*2,It=O.x-5,mA=O.y-5,gt=3;if(l.fillStyle="rgba(0, 0, 0, 0.8)",l.beginPath(),l.roundRect(It,mA-jA,WA,jA,gt),l.fill(),l.fillStyle=aA,l.textAlign="left",l.textBaseline="middle",l.fillText(xA,It+EA,mA-jA/2),c&&m.has(w.pcb_group_id)&&!!w.anchor_position&&w.anchor_position){const JA=Array.isArray(w.anchor_position)?{x:w.anchor_position[0]??0,y:w.anchor_position[1]??0}:{x:w.anchor_position.x,y:w.anchor_position.y},OA=Ct(A,JA);l.strokeStyle="white",l.lineWidth=1.5,l.setLineDash([]);const _A=Math.max(4,Math.min(8,6*Math.abs(A.a)));l.beginPath(),l.moveTo(OA.x-_A,OA.y),l.lineTo(OA.x+_A,OA.y),l.stroke(),l.beginPath(),l.moveTo(OA.x,OA.y-_A),l.lineTo(OA.x,OA.y+_A),l.stroke()}})},[t,A,o,s,a,g,c,i]),Z.jsxs("div",{ref:n,style:{position:"relative",width:"100%",height:"100%"},children:[e,Z.jsx("canvas",{ref:r,style:{position:"absolute",top:0,left:0,pointerEvents:"none",zIndex:xc.pcbGroupOverlay,display:a?"block":"none"}})]})},H$e=({transform:e,soup:A,children:t})=>{const i=rl(r=>r.is_showing_rats_nest),{netMap:n,idToNetMap:o}=AA.useMemo(()=>EQt(A||[]),[A]),s=AA.useMemo(()=>{if(!A||!i)return[];const r=l=>{const B=Xb(A)[l.replace(/_\d+$/,"")].get(l);return B&&"x"in B&&"y"in B?{x:B.x,y:B.y}:null},a=(l,B)=>{const C=n[B]||[];let Q=null,h=1/0;return C.forEach(E=>{const u=r(E);if(u){const d=Math.sqrt((l.x-u.x)**2+(l.y-u.y)**2);d<h&&d>0&&(h=d,Q=u)}}),Q},g=Xb(A).pcb_port.list(),c=Xb(A).source_trace.list(),I=[];return g.forEach((l,B)=>{const C=o[l.pcb_port_id];let Q=!1;for(const u of c)u.connected_source_port_ids.includes(l.source_port_id)&&u.connected_source_net_ids.length>0&&(Q=!0);if(!C)return;const h={x:l.x,y:l.y},E=a(h,C);E&&I.push({key:`${l.pcb_port_id}-${B}`,startPoint:h,endPoint:E,isInNet:Q})}),I},[A,n,o,i]);return!A||!i?t:(e||(e=ba()),Z.jsxs("div",{style:{position:"relative"},children:[t,Z.jsx("svg",{style:{position:"absolute",left:0,top:0,width:"100%",height:"100%",pointerEvents:"none",opacity:.5,zIndex:xc.ratsNestOverlay},children:s.map(({key:r,startPoint:a,endPoint:g,isInNet:c})=>{const I=Ct(e,a),l=Ct(e,g);return Z.jsx("line",{x1:I.x,y1:I.y,x2:l.x,y2:l.y,stroke:"white",strokeWidth:"1",strokeDasharray:c?"6,6":void 0},r)})})]}))},Y$e={version:"1.11.353"},Nk=(e,A,t)=>{const i=rl(s=>s.is_mouse_over_container),n=AA.useRef(i),o=AA.useRef(A);AA.useEffect(()=>{n.current=i},[i]),AA.useEffect(()=>{o.current=A},[A]),AA.useEffect(()=>{if(!e)return;const s=r=>{const a=r.target;if(a.tagName==="INPUT"||a.tagName==="TEXTAREA"||a.isContentEditable)return;const g=e.split("+"),c=g.includes("ctrl"),I=g.includes("shift"),l=g.includes("alt"),B=g.includes("meta"),C=g[g.length-1],Q=t?.current?t.current.contains(document.activeElement)||document.activeElement===t.current:!1;(n.current||Q)&&(!c||r.ctrlKey)&&(!I||r.shiftKey)&&(!l||r.altKey)&&(!B||r.metaKey)&&r.key.toLowerCase()===C.toLowerCase()&&(r.preventDefault(),o.current())};return window.addEventListener("keydown",s),()=>{window.removeEventListener("keydown",s)}},[e])},J$e=()=>{const[e,A]=AA.useState(!1);return AA.useEffect(()=>{const t=()=>{A(window.innerWidth<=768)};return t(),window.addEventListener("resize",t),()=>window.removeEventListener("resize",t)},[]),e},mT=(e,A={stopPropagation:!0})=>{const t=AA.useRef(0),i=AA.useCallback(s=>{A.stopPropagation&&s.stopPropagation();const r=Date.now();r-t.current<300||(t.current=r,e?.(s))},[e,A.stopPropagation]),n=AA.useCallback(s=>{s.preventDefault(),i(s)},[i]);return{onClick:i,onTouchEnd:n,style:{touchAction:"manipulation"}}},T$e=({name:e,selected:A,onClick:t})=>{const{style:i,...n}=mT(t);return Z.jsxs("div",{className:s1`
5471
+ `,f$e=({children:e,transform:A=ba(),elements:t})=>{const i=AA.useRef(null),{isShowingDRCErrors:n,hoveredErrorId:o}=rl(g=>({isShowingDRCErrors:g.is_showing_drc_errors,hoveredErrorId:g.hovered_error_id}));if(!t)return Z.jsx("div",{style:{position:"relative"},ref:i,children:e});const s=t.filter(g=>g.type==="pcb_trace_error"),r=t.filter(g=>g.type==="pcb_trace_error"&&g.message?.includes("Multiple components found with name")),a=new Map;return t.forEach(g=>{g.type==="pcb_port"&&a.set(g.pcb_port_id,g)}),Z.jsxs("div",{style:{position:"relative"},ref:i,children:[e,s.map((g,c)=>{const{pcb_port_ids:I,pcb_trace_id:l}=g,B=I?.[0]?a.get(I[0]):void 0,C=I?.[1]?a.get(I[1]):void 0,Q=t?Xb(t).pcb_trace.get(l):void 0,h=g.pcb_trace_error_id||`error_${c}_${g.error_type}_${g.message?.slice(0,20)}`,E=o===h;if(B&&C){const u=Ct(A,{x:B.x,y:B.y}),d=Ct(A,{x:C.x,y:C.y});if(!n)return null;const f=!(isNaN(u.x)||isNaN(u.y)||isNaN(d.x)||isNaN(d.y)),m={x:(u.x+d.x)/2,y:(u.y+d.y)/2};if(isNaN(m.x)||isNaN(m.y))return null;const w=CyA(m,i);return Z.jsxs(AA.Fragment,{children:[Z.jsx(d$e,{screenPort1:u,screenPort2:d,errorCenter:m,canLineBeDrawn:f,isHighlighted:E}),Z.jsx("div",{style:{position:"absolute",left:m.x-15,top:m.y-15,width:30,height:30,zIndex:xc.errorOverlay+5,cursor:"pointer",borderRadius:"50%"},onMouseEnter:D=>{const S=D.currentTarget.nextElementSibling;if(S){const _=S.querySelector(".error-message");_&&(_.style.opacity="1")}},onMouseLeave:D=>{if(!E){const S=D.currentTarget.nextElementSibling;if(S){const _=S.querySelector(".error-message");_&&(_.style.opacity="0")}}}}),Z.jsx("div",{style:{position:"absolute",zIndex:E?200:100,left:w.left,top:w.top,color:E?"#ff4444":"red",textAlign:"center",fontFamily:"sans-serif",fontSize:12,display:n||E?"flex":"none",flexDirection:"column",alignItems:"center",pointerEvents:"none",transform:w.transform},children:Z.jsx("div",{className:`error-message ${QyA}`,style:{opacity:E?1:0,border:`1px solid ${E?"#ff4444":"red"}`},children:g.message})})]},h)}if(Q?.route&&(n||E)){const u=Q.route.map(w=>Ct(A,{x:w.x,y:w.y}));if(u.some(w=>isNaN(w.x)||isNaN(w.y)))return null;const d=Math.floor(u.length/2),f=u[d],m=CyA(f,i);return Z.jsxs(AA.Fragment,{children:[Z.jsx(p$e,{points:u,errorCenter:f,isHighlighted:E}),Z.jsx("div",{style:{position:"absolute",left:f.x-15,top:f.y-15,width:30,height:30,zIndex:xc.errorOverlay+5,cursor:"pointer",borderRadius:"50%"},onMouseEnter:w=>{const D=w.currentTarget.nextElementSibling;if(D){const S=D.querySelector(".error-message");S&&(S.style.opacity="1")}},onMouseLeave:w=>{if(!E){const D=w.currentTarget.nextElementSibling;if(D){const S=D.querySelector(".error-message");S&&(S.style.opacity="0")}}}}),Z.jsx("div",{style:{position:"absolute",zIndex:E?xc.errorOverlay+10:xc.errorOverlay+1,left:m.left,top:m.top,color:E?"#ff4444":"red",textAlign:"center",fontFamily:"sans-serif",fontSize:12,display:"flex",flexDirection:"column",alignItems:"center",pointerEvents:"none",transform:m.transform},children:Z.jsx("div",{className:`error-message ${QyA}`,style:{opacity:E?1:0,border:`1px solid ${E?"#ff4444":"red"}`},children:g.message})})]},h)}return null}),r.map((g,c)=>{const I=g.component_name||g.message?.match(/name "([^"]+)"/)?.[1];if(!I)return null;const l=t?.filter(Q=>Q.type==="source_component"&&Q.name===I||Q.type==="pcb_component"&&t?.find(h=>h.type==="source_component"&&h.source_component_id===Q.source_component_id&&h.name===I))||[],B=g.pcb_trace_error_id||`error_${c}_${g.error_type}_${g.message?.slice(0,20)}`,C=o===B;return!C&&!n?null:l.map((Q,h)=>{let E={x:0,y:0};if(Q.type==="pcb_component")E=Q.center||{x:0,y:0};else if(Q.type==="source_component"){const _=t?.find(b=>b.type==="pcb_component"&&b.source_component_id===Q.source_component_id);_&&_.type==="pcb_component"&&(E=_.center||{x:0,y:0})}const u=Ct(A,E);if(isNaN(u.x)||isNaN(u.y))return null;const d=Math.abs(A.a),D=Math.max(8,Math.min(30,.5*d)),S=CyA(u,i);return Z.jsxs(AA.Fragment,{children:[Z.jsx("svg",{style:{position:"absolute",left:0,top:0,pointerEvents:"none",mixBlendMode:"difference",zIndex:xc.errorOverlay},width:"100%",height:"100%",children:C?Z.jsx("polygon",{points:`${u.x},${u.y-D*1.25} ${u.x+D},${u.y} ${u.x},${u.y+D*1.25} ${u.x-D},${u.y}`,fill:"#ff4444"}):Z.jsx("circle",{cx:u.x,cy:u.y,r:D,fill:"none",stroke:C?"#ff4444":"red",strokeWidth:C?Math.max(2,D*.15):Math.max(1,D*.1),opacity:1})}),Z.jsx("div",{style:{position:"absolute",left:u.x-(D+10),top:u.y-(D+10),width:(D+10)*2,height:(D+10)*2,zIndex:xc.errorOverlay+5,cursor:"pointer",borderRadius:"50%"},onMouseEnter:_=>{const b=_.currentTarget.nextElementSibling;if(b){const R=b.querySelector(".error-message");R&&(R.style.opacity="1")}},onMouseLeave:_=>{if(!C){const b=_.currentTarget.nextElementSibling;if(b){const R=b.querySelector(".error-message");R&&(R.style.opacity="0")}}}}),Z.jsx("div",{style:{position:"absolute",zIndex:C?xc.errorOverlay+20:xc.errorOverlay+10,left:S.left,top:S.top,color:C?"#ff4444":"red",textAlign:"center",fontFamily:"sans-serif",fontSize:12,display:n||C?"flex":"none",flexDirection:"column",alignItems:"center",pointerEvents:"none",transform:S.transform},children:Z.jsx("div",{className:`error-message ${QyA}`,style:{opacity:C?1:0,border:`1px solid ${C?"#ff4444":"red"}`},children:g.message})})]},`${B}_${h}`)})})]})};function y$e(e,A){return e.size!==A.size?!1:Array.from(e).every(t=>A.has(t))}function m$e({primitiveElement:e,elements:A}){let t=e.trace_length?`${e.trace_length.toFixed(3)}`:"";const i=Xb(A).source_trace.get(e?.source_trace_id);if(i?.display_name&&(i?.max_length?t+=` / ${i.max_length}mm `:t+=" mm ",t+=`(${i.display_name})`),!t)return null;const n=e.trace_length&&i?.max_length&&e.trace_length>i.max_length;return{text:t,isOverLength:n}}function w$e(e){const{primitives:A,is_showing_multiple_traces_length:t,elements:i}=e,n=A.filter(a=>a._element.type==="pcb_trace"),o=i.filter(a=>a.type==="source_trace"),s=A.filter(a=>a._element.type!=="pcb_trace"),r=n.filter(a=>o.some(g=>a._element.type==="pcb_trace"&&a._element.source_trace_id===g.source_trace_id&&g.max_length!==void 0));if(!t)return[...s,...r];if(n.length>1){const a=n.reduce((g,c)=>{const I=g._element.trace_length;return c._element.trace_length<I?c:g},n[0]);return[...s,a]}return A}var D$e={position:"absolute",left:0,top:0,pointerEvents:"none",color:"red",fontFamily:"sans-serif",fontSize:12,textShadow:"0 0 2px black"},S$e=e=>{const{_element:A,_parent_pcb_component:t,_parent_source_component:i,_source_port:n}=e;switch(A.type){case"pcb_trace":return A.trace_length?`${A.trace_length.toFixed(3)}`:"";case"pcb_smtpad":case"pcb_plated_hole":{const o=[],s=Array.from(new Set((A.port_hints??[]).concat(n?.port_hints??[]))).filter(a=>!/^[0-9]+$/.test(a)).filter(a=>!a.includes("unnamed_")).sort((a,g)=>g.localeCompare(a)),r=i&&"name"in i&&i.name&&!i.name.includes("unnamed_")?i.name:null;return s.length>0?r?o.push(...s.map(a=>`${r}.${a}`)):o.push(...s):r&&o.push(r),o.join(", ")}default:return""}},b$e={top:"red",bottom:"aqua"},x$e=({primitive:e,mousePos:A,elements:t})=>{const[i,n]=AA.useState(!1),o=e._element;AA.useEffect(()=>{setTimeout(()=>{n(!0)},100)},[]);const[s,r,a,g]=[e.screen_x,e.screen_y,e.screen_w,e.screen_h],c=e.same_space_index??0,I=26,l=b$e[e?._element?.layer]??"red";let B=0;if(o.type==="pcb_smtpad"&&o?.shape==="rotated_rect"?B=o?.ccw_rotation??0:(o.type==="pcb_smtpad"&&(o?.shape==="pill"||o?.shape==="rotated_pill")&&"ccw_rotation"in e||o.type==="pcb_plated_hole"&&(o?.shape==="pill"||o?.shape==="oval")&&"ccw_rotation"in e)&&(B=o.ccw_rotation??0),o.type==="pcb_trace"){const h=m$e({primitiveElement:o,elements:t});if(!h)return null;const E=A.y-35;return Z.jsx("div",{style:{zIndex:xc.elementOverlay,position:"absolute",left:A.x,top:E,color:l,pointerEvents:"none",transform:"translateX(-50%)"},children:Z.jsx("div",{style:{backgroundColor:"#f2efcc",color:h.isOverLength?"red":"black",textShadow:"none",WebkitFontSmoothing:"antialiased",MozOsxFontSmoothing:"grayscale",padding:"6px 6px",borderRadius:"6px",fontSize:"14px",minWidth:"45px",textAlign:"center",whiteSpace:"nowrap"},children:h.text})})}const C=S$e(e);return C.trim().length===0?null:Z.jsx("div",{style:{zIndex:xc.elementOverlay,position:"absolute",left:s-a/2-8,top:r-g/2-8,width:a+16,height:g+16,color:l,transform:`rotate(${-B}deg)`,transformOrigin:"center center"},children:Z.jsx("div",{style:{width:i?`calc(100% + ${I*2*c}px)`:"100%",height:i?`calc(100% + ${I*2*c}px)`:"100%",marginLeft:i?`${-I*c}px`:0,marginTop:i?`${-I*c}px`:0,border:`1px solid ${l}`,opacity:i||c===0?1:0,transition:"width 0.2s, height 0.2s, margin-left 0.2s, margin-top 0.2s, opacity 0.2s"},children:Z.jsx("div",{style:{position:"absolute",bottom:g+20+I*c,marginRight:i?`${-I*c}px`:0,marginBottom:i?0:-I*c,transition:"margin-right 0.2s, margin-bottom 0.2s",backgroundColor:"#f2efcc",color:"black",textShadow:"none",WebkitFontSmoothing:"antialiased",MozOsxFontSmoothing:"grayscale",padding:"6px 6px",borderRadius:"6px",fontSize:"14px",transform:`rotate(${B}deg)`,minWidth:"45px",textAlign:"center"},children:C})})})},_$e=({highlightedPrimitives:e,mousePos:A,elements:t})=>{const[i,n]=rl(r=>[r.is_moving_component,r.is_showing_multiple_traces_length]),o=e.some(r=>r._element.type==="pcb_smtpad")&&e.some(r=>r._element.type==="pcb_trace");let s=e;return o&&(s=s.filter(r=>r._element.type==="pcb_smtpad")),s=w$e({primitives:s,is_showing_multiple_traces_length:n,elements:t}),Z.jsx("div",{style:D$e,children:!i&&s.map((r,a)=>Z.jsx(x$e,{primitive:r,mousePos:A,elements:t},a))})},Rk=e=>e?.type==="pcb_component",UQt=e=>e?.type==="pcb_group",k$e=e=>e?.type==="pcb_panel",hyA=e=>e?.type==="pcb_board",rI={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},ey={OFFSET_LINE:"white",COMPONENT_MARKER_FILL:"#66ccff",COMPONENT_MARKER_STROKE:"white",LABEL_TEXT:"white"},EyA=({targets:e,transform:A,containerWidth:t,containerHeight:i})=>{if(e.length===0)return null;const n={color:ey.LABEL_TEXT,mixBlendMode:"difference",pointerEvents:"none",fontSize:rI.LABEL_FONT_SIZE,fontFamily:"monospace",fontWeight:"bold"},o=new Map;return e.forEach(s=>{if(!o.has(s.anchor_id)){const r=Ct(A,s.anchor);o.set(s.anchor_id,r)}}),Z.jsx("div",{style:{position:"absolute",left:0,top:0,width:t,height:i,overflow:"hidden",pointerEvents:"none",zIndex:xc.dimensionOverlay},children:Z.jsxs("svg",{style:{position:"absolute",left:0,top:0,pointerEvents:"none"},width:t,height:i,children:[e.map(s=>{const r=s.anchor,a=s.anchor_id,g=s.target,c=o.get(a),I=Ct(A,g),l=g.x-r.x,B=g.y-r.y,C=Math.abs(I.x-c.x),Q=Math.abs(I.y-c.y),h=I.y<c.y,E=I.x>c.x,u=h?rI.LABEL_OFFSET_ABOVE:rI.LABEL_OFFSET_BELOW,d=E?rI.LABEL_OFFSET_RIGHT:rI.LABEL_OFFSET_LEFT,f=C>rI.MIN_LINE_LENGTH_FOR_LABEL,m=Q>rI.MIN_LINE_LENGTH_FOR_LABEL,w=`${s.display_offset_x??l.toFixed(2)}mm`,D=`${s.display_offset_y??B.toFixed(2)}mm`;return Z.jsxs("g",{children:[Z.jsx("line",{x1:c.x,y1:c.y,x2:I.x,y2:c.y,stroke:ey.OFFSET_LINE,strokeWidth:rI.LINE_STROKE_WIDTH,strokeDasharray:rI.LINE_DASH_PATTERN}),Z.jsx("line",{x1:I.x,y1:c.y,x2:I.x,y2:I.y,stroke:ey.OFFSET_LINE,strokeWidth:rI.LINE_STROKE_WIDTH,strokeDasharray:rI.LINE_DASH_PATTERN}),s.type==="component"||s.type==="board"?Z.jsx("circle",{cx:I.x,cy:I.y,r:rI.COMPONENT_MARKER_RADIUS,fill:ey.COMPONENT_MARKER_FILL,stroke:ey.COMPONENT_MARKER_STROKE,strokeWidth:1}):Z.jsxs(Z.Fragment,{children:[Z.jsx("line",{x1:I.x-rI.ANCHOR_MARKER_SIZE,y1:I.y,x2:I.x+rI.ANCHOR_MARKER_SIZE,y2:I.y,stroke:ey.OFFSET_LINE,strokeWidth:rI.ANCHOR_MARKER_STROKE_WIDTH}),Z.jsx("line",{x1:I.x,y1:I.y-rI.ANCHOR_MARKER_SIZE,x2:I.x,y2:I.y+rI.ANCHOR_MARKER_SIZE,stroke:ey.OFFSET_LINE,strokeWidth:rI.ANCHOR_MARKER_STROKE_WIDTH})]}),f&&Z.jsx("foreignObject",{x:Math.min(c.x,I.x),y:c.y+u,width:Math.abs(I.x-c.x),height:20,style:{overflow:"visible"},children:Z.jsx("div",{style:{...n,textAlign:"center"},children:w})}),m&&Z.jsx("foreignObject",{x:I.x+d,y:Math.min(c.y,I.y),width:rI.Y_LABEL_MIN_WIDTH,height:Math.abs(I.y-c.y),style:{overflow:"visible"},children:Z.jsx("div",{style:{...n,display:"flex",alignItems:"center",justifyContent:E?"flex-start":"flex-end",whiteSpace:"nowrap",padding:"0 4px",height:"100%"},children:D})})]},s.id)}),Array.from(o.entries()).map(([s,r])=>Z.jsxs("g",{children:[Z.jsx("line",{x1:r.x-rI.ANCHOR_MARKER_SIZE,y1:r.y,x2:r.x+rI.ANCHOR_MARKER_SIZE,y2:r.y,stroke:ey.OFFSET_LINE,strokeWidth:rI.ANCHOR_MARKER_STROKE_WIDTH}),Z.jsx("line",{x1:r.x,y1:r.y-rI.ANCHOR_MARKER_SIZE,x2:r.x,y2:r.y+rI.ANCHOR_MARKER_SIZE,stroke:ey.OFFSET_LINE,strokeWidth:rI.ANCHOR_MARKER_STROKE_WIDTH})]},`anchor-${s}`))]})})},v$e=({elements:e,highlightedPrimitives:A,transform:t,containerWidth:i,containerHeight:n})=>{const o=e.filter(E=>hyA(E)),s=e.filter(E=>Rk(E)),r=e.filter(E=>UQt(E)),a=A.map(E=>Rk(E._parent_pcb_component)?E._parent_pcb_component.pcb_component_id:Rk(E._element)?E._element.pcb_component_id:null).filter(E=>!!E),g=new Set;if(a.forEach(E=>{const u=s.find(d=>d.pcb_component_id===E);u?.pcb_group_id&&g.add(u.pcb_group_id)}),!rl(E=>E.is_showing_group_anchor_offsets)&&a.length===0)return null;const I=s.map(E=>{const u=E.positioned_relative_to_pcb_board_id;if(!u)return null;const d=o.find(f=>f.pcb_board_id===u);return d?{component:E,board:d,type:"component"}:null}).filter(E=>!!E),l=r.map(E=>{const u=E.positioned_relative_to_pcb_board_id;if(!u||!E.center)return null;const d=o.find(f=>f.pcb_board_id===u);return d?{group:E,board:d,type:"group"}:null}).filter(E=>!!E),B=[...I,...l];if(B.length===0)return null;const C=a.length===0,Q=B.filter(E=>E.type==="component"?C||a.includes(E.component.pcb_component_id):C||g.has(E.group.pcb_group_id));if(Q.length===0)return null;const h=Q.map(E=>E.type==="component"?{id:`${E.board.pcb_board_id}-${E.component.pcb_component_id}-${E.type}`,anchor:E.board.center,anchor_id:E.board.pcb_board_id,target:E.component.center,type:"component",display_offset_x:E.component.display_offset_x,display_offset_y:E.component.display_offset_y}:{id:`${E.board.pcb_board_id}-${E.group.pcb_group_id}-${E.type}`,anchor:E.board.center,anchor_id:E.board.pcb_board_id,target:{x:E.group.anchor_position?.x??E.group.center.x,y:E.group.anchor_position?.y??E.group.center.y},type:"group",display_offset_x:E.group.display_offset_x,display_offset_y:E.group.display_offset_y}).filter(E=>!!E);return Z.jsx(EyA,{targets:h,transform:t,containerWidth:i,containerHeight:n})},F$e=({elements:e,highlightedPrimitives:A,transform:t,containerWidth:i,containerHeight:n})=>{const o=e.filter(E=>UQt(E)),s=e.filter(E=>Rk(E)),r=A.map(E=>Rk(E._parent_pcb_component)?E._parent_pcb_component.pcb_component_id:Rk(E._element)?E._element.pcb_component_id:null).filter(E=>!!E),a=(E,u)=>{if(u.has(E))return;u.add(E);const d=o.find(f=>f.pcb_group_id===E);d?.position_mode==="relative_to_group_anchor"&&d.positioned_relative_to_pcb_group_id&&a(d.positioned_relative_to_pcb_group_id,u)},g=new Set;if(r.forEach(E=>{const u=s.find(d=>d.pcb_component_id===E);u&&(u.position_mode==="relative_to_group_anchor"&&u.positioned_relative_to_pcb_group_id&&a(u.positioned_relative_to_pcb_group_id,g),u.pcb_group_id&&a(u.pcb_group_id,g))}),!rl(E=>E.is_showing_group_anchor_offsets)&&r.length===0)return null;const I=s.map(E=>{if(E.position_mode==="relative_to_group_anchor"&&E.positioned_relative_to_pcb_group_id){const u=o.find(d=>d.pcb_group_id===E.positioned_relative_to_pcb_group_id);return u&&u.anchor_position?{component:E,parentGroup:u,type:"component"}:null}if(E.pcb_group_id){const u=o.find(d=>d.pcb_group_id===E.pcb_group_id);return u&&u.anchor_position?{component:E,parentGroup:u,type:"component"}:null}return null}).filter(E=>!!E),l=o.map(E=>{if(E.position_mode==="relative_to_group_anchor"&&E.positioned_relative_to_pcb_group_id){const u=o.find(d=>d.pcb_group_id===E.positioned_relative_to_pcb_group_id);if(u&&u.anchor_position&&E.anchor_position)return{group:E,parentGroup:u,type:"group"}}return null}).filter(E=>!!E),B=[...I,...l];if(B.length===0)return null;const C=r.length===0,Q=B.filter(E=>E.type==="component"?C||r.includes(E.component.pcb_component_id):C||g.has(E.group.pcb_group_id)||g.has(E.parentGroup.pcb_group_id));if(Q.length===0)return null;const h=Q.map(E=>{const u=E.parentGroup.anchor_position;return u?E.type==="component"?E.component.center?{id:`${E.parentGroup.pcb_group_id}-${E.component.pcb_component_id}-${E.type}`,anchor:u,anchor_id:E.parentGroup.pcb_group_id,target:E.component.center,type:"component",display_offset_x:E.component.display_offset_x,display_offset_y:E.component.display_offset_y}:null:E.group.anchor_position?{id:`${E.parentGroup.pcb_group_id}-${E.group.pcb_group_id}-${E.type}`,anchor:u,anchor_id:E.parentGroup.pcb_group_id,target:E.group.anchor_position,type:"group",display_offset_x:E.group.display_offset_x,display_offset_y:E.group.display_offset_y}:null:null}).filter(E=>!!E);return Z.jsx(EyA,{targets:h,transform:t,containerWidth:i,containerHeight:n})},M$e=(e,A)=>{const t=e.pcb_component_id,i=A.filter(n=>(n.type==="pcb_smtpad"||n.type==="pcb_plated_hole")&&n.pcb_component_id===t||n.type==="pcb_hole"&&n.pcb_component_id===t);return i.length===0?lyA([e]):lyA(i)},G$e=({elements:e,highlightedPrimitives:A,transform:t,containerWidth:i,containerHeight:n})=>{const o=new Map;for(const r of A)Rk(r._parent_pcb_component)&&o.set(r._parent_pcb_component.pcb_component_id,r._parent_pcb_component),Rk(r._element)&&o.set(r._element.pcb_component_id,r._element);if(o.size===0)return null;const s=[];for(const r of o.values()){const a=M$e(r,e);if(!a)continue;const g=r.positioned_relative_to_pcb_group_id??r.pcb_group_id,c=g?Xb(e).pcb_group.get(g):null;s.push({component:r,bbox:a,group:c})}return s.length===0?null:Z.jsx("div",{style:{position:"absolute",left:0,top:0,width:i,height:n,overflow:"hidden",pointerEvents:"none",zIndex:xc.dimensionOverlay},children:Z.jsx("svg",{style:{position:"absolute",left:0,top:0,pointerEvents:"none"},width:i,height:n,children:s.map(({component:r,bbox:a,group:g})=>{const c=Ct(t,{x:a.minX,y:a.maxY}),I=Ct(t,{x:a.maxX,y:a.minY}),l={x:Math.min(c.x,I.x),y:Math.min(c.y,I.y),width:Math.abs(I.x-c.x),height:Math.abs(I.y-c.y)},B=r.center??{x:(a.minX+a.maxX)/2,y:(a.minY+a.maxY)/2},C=Ct(t,B);return Z.jsxs("g",{children:[Z.jsx("rect",{x:l.x,y:l.y,width:l.width,height:l.height,fill:"none",stroke:"white",strokeWidth:1.5,strokeDasharray:"4,4"}),Z.jsx("line",{x1:C.x-6,y1:C.y,x2:C.x+6,y2:C.y,stroke:ey.COMPONENT_MARKER_STROKE,strokeWidth:1.5}),Z.jsx("line",{x1:C.x,y1:C.y-6,x2:C.x,y2:C.y+6,stroke:ey.COMPONENT_MARKER_STROKE,strokeWidth:1.5}),Z.jsx("circle",{cx:C.x,cy:C.y,r:rI.COMPONENT_MARKER_RADIUS,fill:ey.COMPONENT_MARKER_FILL,stroke:ey.COMPONENT_MARKER_STROKE,strokeWidth:1})]},r.pcb_component_id)})})})},R$e=({elements:e,highlightedPrimitives:A,transform:t,containerWidth:i,containerHeight:n})=>{const o=e.filter(B=>k$e(B)),s=e.filter(B=>hyA(B)),r=A.map(B=>hyA(B._element)?B._element.pcb_board_id:null).filter(B=>!!B);if(!rl(B=>B.is_showing_group_anchor_offsets)&&r.length===0)return null;const g=s.map(B=>{const C=B.pcb_panel_id,Q=B.position_mode;if(!C||Q!=="relative_to_panel_anchor")return null;const h=o.find(E=>E.pcb_panel_id===C);return h?{board:B,panel:h,type:"board"}:null}).filter(B=>!!B);if(g.length===0)return null;const c=r.length===0,I=g.filter(B=>c||r.includes(B.board.pcb_board_id));if(I.length===0)return null;const l=I.map(B=>B.board.center?{id:`${B.panel.pcb_panel_id}-${B.board.pcb_board_id}-${B.type}`,anchor:B.panel.center,anchor_id:B.panel.pcb_panel_id,target:B.board.center,type:"board",display_offset_x:B.board.display_offset_x,display_offset_y:B.board.display_offset_y}:null).filter(B=>!!B);return Z.jsx(EyA,{targets:l,transform:t,containerWidth:i,containerHeight:n})},Zj=e=>{if(e.length===0)return null;let A=e[0].x,t=e[0].y,i=e[0].x,n=e[0].y;for(const o of e)o.x<A&&(A=o.x),o.y<t&&(t=o.y),o.x>i&&(i=o.x),o.y>n&&(n=o.y);return{center:{x:(A+i)/2,y:(t+n)/2},width:i-A,height:n-t}},HQt=(e,A)=>{if(A.length<3)return!1;let t=!1;for(let i=0,n=A.length-1;i<A.length;n=i++){const o=A[i].x,s=A[i].y,r=A[n].x,a=A[n].y;s>e.y!=a>e.y&&e.x<(r-o)*(e.y-s)/(a-s||Number.EPSILON)+o&&(t=!t)}return t},N$e=(e,A,t)=>{const i=[];for(const n of e){if(!n._element)continue;if("x1"in n&&n._element?.type==="pcb_trace"){const r=KE({x:A.x,y:A.y},{x:n.x1,y:n.y1},{x:n.x2,y:n.y2}),a=n.width||.5,g=Math.max(a*25,2)/t.a;r<g&&i.push(n);continue}if(n.pcb_drawing_type==="polygon"){const r=n.points.map(g=>({x:Ee.parse(g.x),y:Ee.parse(g.y)})),a=Zj(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;HQt(A,r)&&i.push(n);continue}if(n.pcb_drawing_type==="polygon_with_arcs"){const r=n.brep_shape.outer_ring.vertices.map(g=>({x:Ee.parse(g.x),y:Ee.parse(g.y)})),a=Zj(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;HQt(A,r)&&i.push(n);continue}if(!("x"in n&&"y"in n))continue;let o=0,s=0;if("w"in n&&"h"in n)o=n.w,s=n.h;else if("r"in n)o=n.r*2,s=n.r*2;else if("rX"in n&&"rY"in n)o=n.rX*2,s=n.rY*2;else continue;Math.abs(n.x-A.x)<o/2&&Math.abs(n.y-A.y)<s/2&&i.push(n)}return i},L$e=({elements:e,children:A,transform:t,primitives:i,onMouseHoverOverPrimitives:n})=>{const[o,s]=AA.useState([]),[r,a]=AA.useState({x:0,y:0}),[g,{width:c,height:I}]=fT(),l=AA.useMemo(()=>{const C=[];for(const Q of o){if(Q._element?.type==="pcb_via"||Q._element?.type==="pcb_component"||Q?.layer==="drill")continue;let h=null,E=0,u=0;if(Q.pcb_drawing_type==="polygon"){const w=Zj(Q.points);if(!w)continue;h=w.center,E=w.width,u=w.height}else if(Q.pcb_drawing_type==="polygon_with_arcs"){const w=Q.brep_shape.outer_ring.vertices.map(S=>({x:S.x,y:S.y})),D=Zj(w);if(!D)continue;h=D.center,E=D.width,u=D.height}else"x"in Q&&"y"in Q&&(h={x:Q.x,y:Q.y},E="w"in Q?Q.w:"r"in Q?Q.r*2:"rX"in Q&&"rY"in Q?Q.rX*2:0,u="h"in Q?Q.h:"r"in Q?Q.r*2:"rX"in Q&&"rY"in Q?Q.rY*2:0);if(!h)continue;const d=Ct(t,h),f={w:E*t.a,h:u*t.a},m=C.filter(w=>d.x===w.screen_x&&d.y===w.screen_y&&f.w===w.screen_w&&f.h===w.screen_h).length;C.push({...Q,x:h.x,y:h.y,w:E,h:u,screen_x:d.x,screen_y:d.y,screen_w:f.w,screen_h:f.h,same_space_index:m})}return C},[o,t]),B=(C,Q,h,E)=>{a({x:C,y:Q});const u=Ct(Xy(h),{x:C,y:Q}),d=N$e(E,u,h);y$e(new Set(d.map(f=>f._pcb_drawing_object_id)),new Set(o.map(f=>f._pcb_drawing_object_id)))||(s(d),n(d))};return Z.jsxs("div",{ref:g,style:{position:"relative",width:"100%",height:"100%"},onMouseMove:C=>{if(t){const Q=C.currentTarget.getBoundingClientRect(),h=C.clientX-Q.left,E=C.clientY-Q.top;B(h,E,t,i)}},onTouchStart:C=>{if(t){const Q=C.touches[0],h=C.currentTarget.getBoundingClientRect(),E=Q.clientX-h.left,u=Q.clientY-h.top;B(E,u,t,i)}},children:[A,Z.jsx(_$e,{elements:e,mousePos:r,highlightedPrimitives:l}),t&&Z.jsxs(Z.Fragment,{children:[Z.jsx(v$e,{elements:e,highlightedPrimitives:l,transform:t,containerWidth:c,containerHeight:I}),Z.jsx(F$e,{elements:e,highlightedPrimitives:l,transform:t,containerWidth:c,containerHeight:I}),Z.jsx(G$e,{elements:e,highlightedPrimitives:l,transform:t,containerWidth:c,containerHeight:I}),Z.jsx(R$e,{elements:e,highlightedPrimitives:l,transform:t,containerWidth:c,containerHeight:I})]})]})},YQt=["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)"],U$e=({children:e,transform:A=ba(),elements:t=[],hoveredComponentIds:i=[]})=>{const[n,{width:o,height:s}]=fT(),r=AA.useRef(null),{is_showing_pcb_groups:a,pcb_group_view_mode:g,is_showing_group_anchor_offsets:c}=rl(I=>({is_showing_pcb_groups:I.is_showing_pcb_groups,pcb_group_view_mode:I.pcb_group_view_mode,is_showing_group_anchor_offsets:I.is_showing_group_anchor_offsets}));return AA.useEffect(()=>{const I=r.current;if(!I||!o||!s)return;I.width=o,I.height=s;const l=I.getContext("2d");if(!l||(l.clearRect(0,0,o,s),!a))return;const B=t.filter(w=>w.type==="pcb_group"),C=t.filter(w=>w.type==="pcb_component"),Q=t.filter(w=>w.type==="source_group"),h=new Map(Q.map(w=>[w.source_group_id,w])),E=B.filter(w=>{if(w.name?.toLowerCase().includes("subpanel"))return!1;if(g==="all")return!0;if(!w.source_group_id)return!1;const D=h.get(w.source_group_id);return D?D.was_automatically_named!==!0:!1}),u=new Map;Q.forEach(w=>{const D=w;if(D.parent_source_group_id){const S=u.get(D.parent_source_group_id)||[];S.push(w.source_group_id),u.set(D.parent_source_group_id,S)}});const d=w=>{const D=[],S=u.get(w)||[];for(const _ of S)D.push(_),D.push(...d(_));return D},f=w=>{const D=Q.find(S=>S.source_group_id===w);return D?.parent_source_group_id?1+f(D.parent_source_group_id):0},m=new Set;if(i.length>0)for(const w of C){if(!i.includes(w.pcb_component_id))continue;const D=w.positioned_relative_to_pcb_group_id??w.pcb_group_id;D&&m.add(D)}E.forEach((w,D)=>{let S=C.filter(JA=>JA.pcb_group_id===w.pcb_group_id);if(w.source_group_id){const JA=d(w.source_group_id),OA=B.filter(_A=>_A.source_group_id&&JA.includes(_A.source_group_id));for(const _A of OA){const DA=C.filter(NA=>NA.pcb_group_id===_A.pcb_group_id);S=[...S,...DA]}}let _,b,R,F,H=!1;if(w.center&&w.width&&w.height){H=!0;const JA=w.width/2,OA=w.height/2;_=w.center.x-JA,R=w.center.x+JA,b=w.center.y-OA,F=w.center.y+OA}else if(S.length===0||(_=1/0,b=1/0,R=-1/0,F=-1/0,S.forEach(JA=>{if(JA.center&&typeof JA.width=="number"&&typeof JA.height=="number"){const OA=JA.center.x-JA.width/2,_A=JA.center.x+JA.width/2,DA=JA.center.y+JA.height/2,NA=JA.center.y-JA.height/2;_=Math.min(_,OA),R=Math.max(R,_A),b=Math.min(b,NA),F=Math.max(F,DA)}}),_===1/0||R===-1/0))return;const Y=w.source_group_id?f(w.source_group_id):0,J=w.source_group_id?d(w.source_group_id).length>0:!1;if(!H){const _A=1+(J?.5:0);_-=_A,R+=_A,b-=_A,F+=_A}const O=Ct(A,{x:_,y:F}),W=Ct(A,{x:R,y:F}),z=Ct(A,{x:_,y:b}),tA=Ct(A,{x:R,y:b}),aA=YQt[D%YQt.length];l.strokeStyle=aA,l.lineWidth=2;const eA=Math.max(4,Math.min(12,8*Math.abs(A.a))),oA=Math.max(2,Math.min(6,4*Math.abs(A.a))),lA=eA*(J?1.3:1),pA=oA;l.setLineDash([lA,pA]),l.beginPath(),l.moveTo(O.x,O.y),l.lineTo(W.x,W.y),l.lineTo(tA.x,tA.y),l.lineTo(z.x,z.y),l.closePath(),l.stroke();const vA=Math.max(8,Math.min(12,10*Math.abs(A.a))),MA=Y==0||Y==1?0:Y*.11,YA=vA*(1-MA),EA=4,xA=w.name||`Group ${D+1}`;l.font=`${YA}px sans-serif`,l.setLineDash([]);const WA=l.measureText(xA).width+EA*2,jA=YA+EA*2,It=O.x-5,mA=O.y-5,gt=3;if(l.fillStyle="rgba(0, 0, 0, 0.8)",l.beginPath(),l.roundRect(It,mA-jA,WA,jA,gt),l.fill(),l.fillStyle=aA,l.textAlign="left",l.textBaseline="middle",l.fillText(xA,It+EA,mA-jA/2),c&&m.has(w.pcb_group_id)&&!!w.anchor_position&&w.anchor_position){const JA=Array.isArray(w.anchor_position)?{x:w.anchor_position[0]??0,y:w.anchor_position[1]??0}:{x:w.anchor_position.x,y:w.anchor_position.y},OA=Ct(A,JA);l.strokeStyle="white",l.lineWidth=1.5,l.setLineDash([]);const _A=Math.max(4,Math.min(8,6*Math.abs(A.a)));l.beginPath(),l.moveTo(OA.x-_A,OA.y),l.lineTo(OA.x+_A,OA.y),l.stroke(),l.beginPath(),l.moveTo(OA.x,OA.y-_A),l.lineTo(OA.x,OA.y+_A),l.stroke()}})},[t,A,o,s,a,g,c,i]),Z.jsxs("div",{ref:n,style:{position:"relative",width:"100%",height:"100%"},children:[e,Z.jsx("canvas",{ref:r,style:{position:"absolute",top:0,left:0,pointerEvents:"none",zIndex:xc.pcbGroupOverlay,display:a?"block":"none"}})]})},H$e=({transform:e,soup:A,children:t})=>{const i=rl(r=>r.is_showing_rats_nest),{netMap:n,idToNetMap:o}=AA.useMemo(()=>EQt(A||[]),[A]),s=AA.useMemo(()=>{if(!A||!i)return[];const r=l=>{const B=Xb(A)[l.replace(/_\d+$/,"")].get(l);return B&&"x"in B&&"y"in B?{x:B.x,y:B.y}:null},a=(l,B)=>{const C=n[B]||[];let Q=null,h=1/0;return C.forEach(E=>{const u=r(E);if(u){const d=Math.sqrt((l.x-u.x)**2+(l.y-u.y)**2);d<h&&d>0&&(h=d,Q=u)}}),Q},g=Xb(A).pcb_port.list(),c=Xb(A).source_trace.list(),I=[];return g.forEach((l,B)=>{const C=o[l.pcb_port_id];let Q=!1;for(const u of c)u.connected_source_port_ids.includes(l.source_port_id)&&u.connected_source_net_ids.length>0&&(Q=!0);if(!C)return;const h={x:l.x,y:l.y},E=a(h,C);E&&I.push({key:`${l.pcb_port_id}-${B}`,startPoint:h,endPoint:E,isInNet:Q})}),I},[A,n,o,i]);return!A||!i?t:(e||(e=ba()),Z.jsxs("div",{style:{position:"relative"},children:[t,Z.jsx("svg",{style:{position:"absolute",left:0,top:0,width:"100%",height:"100%",pointerEvents:"none",opacity:.5,zIndex:xc.ratsNestOverlay},children:s.map(({key:r,startPoint:a,endPoint:g,isInNet:c})=>{const I=Ct(e,a),l=Ct(e,g);return Z.jsx("line",{x1:I.x,y1:I.y,x2:l.x,y2:l.y,stroke:"white",strokeWidth:"1",strokeDasharray:c?"6,6":void 0},r)})})]}))},Y$e={version:"1.11.354"},Nk=(e,A,t)=>{const i=rl(s=>s.is_mouse_over_container),n=AA.useRef(i),o=AA.useRef(A);AA.useEffect(()=>{n.current=i},[i]),AA.useEffect(()=>{o.current=A},[A]),AA.useEffect(()=>{if(!e)return;const s=r=>{const a=r.target;if(a.tagName==="INPUT"||a.tagName==="TEXTAREA"||a.isContentEditable)return;const g=e.split("+"),c=g.includes("ctrl"),I=g.includes("shift"),l=g.includes("alt"),B=g.includes("meta"),C=g[g.length-1],Q=t?.current?t.current.contains(document.activeElement)||document.activeElement===t.current:!1;(n.current||Q)&&(!c||r.ctrlKey)&&(!I||r.shiftKey)&&(!l||r.altKey)&&(!B||r.metaKey)&&r.key.toLowerCase()===C.toLowerCase()&&(r.preventDefault(),o.current())};return window.addEventListener("keydown",s),()=>{window.removeEventListener("keydown",s)}},[e])},J$e=()=>{const[e,A]=AA.useState(!1);return AA.useEffect(()=>{const t=()=>{A(window.innerWidth<=768)};return t(),window.addEventListener("resize",t),()=>window.removeEventListener("resize",t)},[]),e},mT=(e,A={stopPropagation:!0})=>{const t=AA.useRef(0),i=AA.useCallback(s=>{A.stopPropagation&&s.stopPropagation();const r=Date.now();r-t.current<300||(t.current=r,e?.(s))},[e,A.stopPropagation]),n=AA.useCallback(s=>{s.preventDefault(),i(s)},[i]);return{onClick:i,onTouchEnd:n,style:{touchAction:"manipulation"}}},T$e=({name:e,selected:A,onClick:t})=>{const{style:i,...n}=mT(t);return Z.jsxs("div",{className:s1`
5472
5472
  margin-top: 2px;
5473
5473
  padding: 4px;
5474
5474
  padding-left: 8px;
@@ -5685,7 +5685,7 @@ test("${g} should solve problem correctly", () => {
5685
5685
  // Add more specific assertions based on expected output
5686
5686
  // expect(solver.netLabelPlacementSolver!.netLabelPlacements).toMatchInlineSnapshot()
5687
5687
  })
5688
- `,I=new Blob([c],{type:"text/plain"}),l=URL.createObjectURL(I),B=document.createElement("a");B.href=l,B.download=`${g}.test.ts`,B.click(),URL.revokeObjectURL(l)}catch(a){alert(`Error generating test.ts for ${e.constructor.name}: ${a instanceof Error?a.message:String(a)}`)}i(!1)};return Z.jsxs("div",{className:`relative ${A}`,ref:n,children:[Z.jsx("button",{className:"px-2 py-1 rounded text-xs cursor-pointer",onClick:()=>i(!t),title:`Download options for ${e.constructor.name}`,children:e.constructor.name}),t&&Z.jsxs("div",{className:"absolute top-full left-0 mt-1 bg-white border border-gray-300 rounded shadow-lg z-10 min-w-[150px]",children:[Z.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:o,children:"Download JSON"}),Z.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:s,children:"Download page.tsx"}),Z.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:r,children:"Download test.ts"})]})]})},zQt=e=>e.activeSubSolver?[e,...zQt(e.activeSubSolver)]:[e],Qti=({solver:e})=>{const A=zQt(e);return Z.jsx("div",{className:"flex gap-1 items-center text-sm pt-1",children:A.map((t,i)=>Z.jsxs("div",{className:"flex items-center",children:[i>0&&Z.jsx("span",{className:"text-gray-400 mx-1",children:"→"}),Z.jsx(Cti,{solver:t})]},t.constructor.name))})},hti=({solver:e,triggerRender:A,animationSpeed:t=25,onSolverStarted:i,onSolverCompleted:n})=>{const[o,s]=AA.useReducer(Q=>!Q,!1),r=AA.useRef(void 0),a=()=>{!e.solved&&!e.failed&&(e.step(),A())},g=()=>{!e.solved&&!e.failed&&(i&&i(e),e.solve(),A(),n&&n(e))},c=()=>{o?(r.current&&(clearInterval(r.current),r.current=void 0),s()):(s(),r.current=setInterval(()=>{if(e.solved||e.failed){r.current&&(clearInterval(r.current),r.current=void 0),s(),A(),n&&e.solved&&n(e);return}e.step(),A()},t))},I=()=>{const Q=e;if(Q.getCurrentPhase&&!e.solved&&!e.failed){const h=Q.getCurrentPhase();for(;Q.getCurrentPhase()===h&&!e.solved&&!e.failed;)e.step();A()}},l=()=>{if(e.solved||e.failed||o)return;const Q=window.prompt("Step until which iteration?",`${e.iterations}`);if(Q===null)return;const h=Number(Q);if(!Number.isFinite(h)){window.alert("Please enter a valid number for the iteration");return}for(;e.iterations<h&&!e.solved&&!e.failed;)e.step();A(),e.solved&&n&&n(e)};AA.useEffect(()=>()=>{r.current&&clearInterval(r.current)},[]),AA.useEffect(()=>{(e.solved||e.failed)&&o&&(r.current&&(clearInterval(r.current),r.current=void 0),s())},[e.solved,e.failed,o]);const B=e.getCurrentPhase!==void 0,C=B?e.getCurrentPhase():null;return Z.jsxs("div",{className:"space-y-2 p-2 border-b",children:[Z.jsx("div",{className:"flex items-center",children:Z.jsx(Qti,{solver:e})}),Z.jsxs("div",{className:"flex gap-2 items-center flex-wrap",children:[Z.jsx("button",{onClick:a,disabled:e.solved||e.failed||o,className:"bg-blue-500 hover:bg-blue-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Step"}),Z.jsx("button",{onClick:g,disabled:e.solved||e.failed||o,className:"bg-green-500 hover:bg-green-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Solve"}),Z.jsx("button",{onClick:c,disabled:e.solved||e.failed,className:`px-3 py-1 rounded text-white text-sm ${o?"bg-red-500 hover:bg-red-600":"bg-yellow-500 hover:bg-yellow-600"} disabled:bg-gray-300`,children:o?"Stop":"Animate"}),Z.jsx("button",{onClick:l,disabled:e.solved||e.failed||o,className:"bg-orange-500 hover:bg-orange-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Step Until Iteration"}),B&&Z.jsx("button",{onClick:I,disabled:e.solved||e.failed||o,className:"bg-purple-500 hover:bg-purple-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Next Stage"}),Z.jsxs("div",{className:"text-sm text-gray-600",children:["Iterations: ",e.iterations]}),e.timeToSolve!==void 0&&Z.jsxs("div",{className:"text-sm text-gray-600",children:["Time: ",(e.timeToSolve/1e3).toFixed(3),"s"]}),C&&Z.jsxs("div",{className:"text-sm text-gray-600",children:["Phase: ",Z.jsx("span",{className:"font-medium",children:C})]}),e.solved&&Z.jsx("div",{className:"px-2 py-1 bg-green-100 text-green-800 rounded text-sm",children:"Solved"}),e.failed&&Z.jsx("div",{className:"px-2 py-1 bg-red-100 text-red-800 rounded text-sm",children:"Failed"})]}),e.error&&Z.jsxs("div",{className:"text-red-600 text-sm",children:["Error: ",e.error]})]})},Eti=(e,A,t)=>{const i=e.currentPipelineStepIndex;return A<i?"Completed":A===i&&e.activeSubSolver?e.activeSubSolver.failed?"Failed":"In Progress":"Not Started"},uti=(e,A)=>{const i=e.pipelineDef[A].solverName,n=Eti(e,A),o=e[i],s=e.firstIterationOfPhase?.[i]??null,r=e.iterations;let a=0;if(n==="Completed"){const l=e.pipelineDef[A+1],B=l?e.firstIterationOfPhase?.[l.solverName]:void 0;B!==void 0&&s!==null?a=B-s:s!==null&&(a=r-s)}else n==="In Progress"&&s!==null&&(a=r-s);const g=e.timeSpentOnPhase?.[i]??0;let c=0;n==="Completed"?c=1:n==="In Progress"&&o&&(c=o.progress??0);const I=o?.stats??null;return{index:A,name:i,status:n,firstIteration:s,iterations:a,progress:c,timeSpent:g,stats:I&&Object.keys(I).length>0?I:null,solverInstance:o??null}},dti=({status:e})=>{const A={"Not Started":"text-blue-600","In Progress":"text-yellow-600",Completed:"text-green-600",Failed:"text-red-600"};return Z.jsx("span",{className:`font-medium ${A[e]}`,children:e})},pti=({progress:e})=>{if(e===0)return null;const A=Math.round(e*100);return Z.jsxs("div",{className:"flex items-center gap-2",children:[Z.jsx("div",{className:"w-20 h-2 bg-gray-200 rounded overflow-hidden",children:Z.jsx("div",{className:"h-full bg-blue-500 transition-all duration-200",style:{width:`${A}%`}})}),Z.jsxs("span",{className:"text-xs text-gray-500",children:[A,"%"]})]})},fti=e=>Object.entries(e).map(([A,t])=>`${A}: ${t}`).join(", "),yti=({stats:e})=>{if(!e||Object.keys(e).length===0)return Z.jsx("span",{children:"-"});const A=Object.entries(e),t=fti(e);return Z.jsxs("details",{className:"cursor-pointer",children:[Z.jsx("summary",{className:"whitespace-nowrap overflow-hidden text-ellipsis max-w-[200px]",children:t}),Z.jsx("div",{className:"mt-1 text-xs",children:A.map(([i,n])=>Z.jsxs("div",{children:[i,": ",String(n)]},i))})]})},DyA=e=>{if(e===null||typeof e!="object")return e;if(Array.isArray(e))return e.map(DyA);const A={};for(const[t,i]of Object.entries(e))t.startsWith("_")||(A[t]=DyA(i));return A},mti=(e,A)=>{try{if(typeof e.getConstructorParams!="function"){alert(`getConstructorParams() is not implemented for ${A}`);return}const t=DyA(e.getConstructorParams()),i=new Blob([JSON.stringify(t,null,2)],{type:"application/json"}),n=URL.createObjectURL(i),o=document.createElement("a");o.href=n,o.download=`${A}_input.json`,o.click(),URL.revokeObjectURL(n)}catch(t){alert(`Error downloading input for ${A}: ${t instanceof Error?t.message:String(t)}`)}},wti=({solver:e,onStepUntilPhase:A,onDownloadInput:t})=>{const i=e.pipelineDef.map((r,a)=>uti(e,a)),n=r=>{A?.(r)},o=r=>{r.solverInstance&&(t?t(r.solverInstance,r.name):mti(r.solverInstance,r.name))},s=r=>`${(r/1e3).toFixed(2)}s`;return Z.jsxs("div",{className:"border-t border-gray-200",children:[Z.jsx("div",{className:"px-4 py-2 bg-gray-50 border-b border-gray-200",children:Z.jsx("h3",{className:"text-sm font-semibold text-gray-700",children:"Pipeline Steps"})}),Z.jsx("div",{className:"overflow-x-auto",children:Z.jsxs("table",{className:"w-full text-sm",children:[Z.jsx("thead",{children:Z.jsxs("tr",{className:"bg-gray-50 border-b border-gray-200",children:[Z.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Step"}),Z.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Status"}),Z.jsxs("th",{className:"px-4 py-2 text-center font-semibold text-gray-700",children:["i",Z.jsx("sub",{children:"0"})]}),Z.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Iterations"}),Z.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Progress"}),Z.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Time"}),Z.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Stats"}),Z.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Input"})]})}),Z.jsx("tbody",{children:i.map(r=>Z.jsxs("tr",{className:`border-b border-gray-100 ${r.status==="In Progress"?"bg-yellow-50":""}`,children:[Z.jsx("td",{className:"px-4 py-2",children:Z.jsxs("div",{className:"flex items-center gap-2",children:[Z.jsx("span",{className:"text-gray-400 w-6",children:String(r.index+1).padStart(2,"0")}),Z.jsx("button",{onClick:()=>n(r.name),disabled:r.status==="Completed"||e.solved||e.failed,className:"text-blue-500 hover:text-blue-700 disabled:text-gray-300 disabled:cursor-not-allowed",title:`Step until ${r.name} completes`,children:Z.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:Z.jsx("path",{fillRule:"evenodd",d:"M4.5 5.653c0-1.426 1.529-2.33 2.779-1.643l11.54 6.348c1.295.712 1.295 2.573 0 3.285L7.28 19.991c-1.25.687-2.779-.217-2.779-1.643V5.653z",clipRule:"evenodd"})})}),Z.jsx("span",{className:"font-medium text-gray-900",children:r.name})]})}),Z.jsx("td",{className:"px-4 py-2",children:Z.jsx(dti,{status:r.status})}),Z.jsx("td",{className:"px-4 py-2 text-center text-gray-600",children:r.firstIteration!==null?r.firstIteration:""}),Z.jsx("td",{className:"px-4 py-2 text-gray-600",children:r.iterations}),Z.jsx("td",{className:"px-4 py-2",children:Z.jsx(pti,{progress:r.progress})}),Z.jsx("td",{className:"px-4 py-2 text-gray-600",children:s(r.timeSpent)}),Z.jsx("td",{className:"px-4 py-2 text-gray-500",children:Z.jsx(yti,{stats:r.stats})}),Z.jsx("td",{className:"px-4 py-2",children:r.solverInstance?Z.jsxs("button",{onClick:()=>o(r),className:"flex items-center gap-1 text-blue-500 hover:text-blue-700",title:`Download input for ${r.name}`,children:[Z.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:Z.jsx("path",{fillRule:"evenodd",d:"M12 2.25a.75.75 0 01.75.75v11.69l3.22-3.22a.75.75 0 111.06 1.06l-4.5 4.5a.75.75 0 01-1.06 0l-4.5-4.5a.75.75 0 111.06-1.06l3.22 3.22V3a.75.75 0 01.75-.75zm-9 13.5a.75.75 0 01.75.75v2.25a1.5 1.5 0 001.5 1.5h13.5a1.5 1.5 0 001.5-1.5V16.5a.75.75 0 011.5 0v2.25a3 3 0 01-3 3H5.25a3 3 0 01-3-3V16.5a.75.75 0 01.75-.75z",clipRule:"evenodd"})}),Z.jsx("span",{children:"Input"})]}):null})]},r.name))})]})})]})},Dti=class extends Qn.Component{constructor(e){super(e),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(e){console.error("InteractiveGraphics render error:",e)}render(){return this.state.hasError?this.props.fallback:this.props.children}};function Sti({graphics:e}){const A=e.points??[],t=e.lines??[],i=e.rects??[],n=e.circles??[],o=e.texts??[];let s=Number.POSITIVE_INFINITY,r=Number.POSITIVE_INFINITY,a=Number.NEGATIVE_INFINITY,g=Number.NEGATIVE_INFINITY;const c=(h,E)=>{typeof h=="number"&&(h<s&&(s=h),h>a&&(a=h)),typeof E=="number"&&(E<r&&(r=E),E>g&&(g=E))};for(const h of A)c(h.x,h.y);for(const h of t){const E=h.points??[];for(const u of E)c(u.x,u.y)}for(const h of i){const E=h.x??0,u=h.y??0,d=h.width??0,f=h.height??0;c(E,u),c(E+d,u+f)}for(const h of n){const E=h.x??0,u=h.y??0,d=h.radius??1;c(E-d,u-d),c(E+d,u+d)}for(const h of o)c(h.x,h.y);(!isFinite(s)||!isFinite(r)||!isFinite(a)||!isFinite(g))&&(s=-20,r=-20,a=20,g=20);const I=10,l=s-I,B=r-I,C=Math.max(1,a-s+2*I),Q=Math.max(1,g-r+2*I);return Z.jsxs("svg",{className:"w-full h-[400px] bg-white",viewBox:`${l} ${B} ${C} ${Q}`,role:"img","aria-label":"Graphics fallback",children:[i.map((h,E)=>Z.jsx("rect",{x:h.x??0,y:h.y??0,width:h.width??0,height:h.height??0,fill:"none",stroke:h.strokeColor??"black",strokeWidth:h.strokeWidth??1},`rect-${E}`)),t.map((h,E)=>Z.jsx("polyline",{fill:"none",stroke:h.strokeColor??"black",strokeWidth:h.strokeWidth??1,points:(h.points??[]).map(u=>`${u.x??0},${u.y??0}`).join(" ")},`line-${E}`)),n.map((h,E)=>Z.jsx("circle",{cx:h.x??0,cy:h.y??0,r:h.radius??1.5,fill:h.fillColor??"none",stroke:h.strokeColor??"black",strokeWidth:h.strokeWidth??1},`circle-${E}`)),A.map((h,E)=>Z.jsx("circle",{cx:h.x??0,cy:h.y??0,r:h.radius??1.5,fill:h.color??"black"},`point-${E}`)),o.map((h,E)=>Z.jsx("text",{x:h.x??0,y:h.y??0,fontSize:h.fontSize??10,fill:h.color??"black",children:h.text??""},`text-${E}`))]})}var bti=({solver:e,animationSpeed:A=25,onSolverStarted:t,onSolverCompleted:i})=>{const[n,o]=AA.useReducer(c=>c+1,0),s=AA.useMemo(()=>{try{return e.visualize()||{points:[],lines:[],rects:[],circles:[]}}catch(c){return console.error("Visualization error:",c),{points:[],lines:[],rects:[],circles:[]}}},[e,n]),r=AA.useMemo(()=>(s.rects?.length||0)===0&&(s.lines?.length||0)===0&&(s.points?.length||0)===0&&(s.circles?.length||0)===0,[s]);AA.useEffect(()=>{if(!(typeof document>"u")&&!document.querySelector('script[src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4"]')){const c=document.createElement("script");c.src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4",document.head.appendChild(c)}},[]);const a=e.pipelineDef!==void 0,g=c=>{const I=e;if(!e.solved&&!e.failed){for(;!e.solved&&!e.failed&&I.currentPipelineStepIndex<=I.pipelineDef.findIndex(l=>l.solverName===c);)e.step();o()}};return Z.jsxs("div",{children:[Z.jsx(hti,{solver:e,triggerRender:o,animationSpeed:A,onSolverStarted:t,onSolverCompleted:i}),r?Z.jsx("div",{className:"p-4 text-gray-500",children:"No Graphics Yet"}):Z.jsx(Dti,{fallback:Z.jsx(Sti,{graphics:s}),children:Z.jsx(Bti,{graphics:s})}),a&&Z.jsx(wti,{solver:e,onStepUntilPhase:g})]})};const xti=()=>{AA.useEffect(()=>{const e="tailwind-cdn-script";if(document.getElementById(e)||window.tailwind)return;const A=document.createElement("div");A.className="hidden",document.body.appendChild(A);const t=window.getComputedStyle(A).display==="none";if(document.body.removeChild(A),t)return;const i=document.createElement("script");i.id=e,i.src="https://cdn.tailwindcss.com",document.head.appendChild(i)},[])},_ti=e=>e.toLowerCase().includes("pack")?nTe:e.toLowerCase().includes("rout")?cTe:VJe,kti=({solverEvents:e=[]})=>{const[A,t]=AA.useState(null);xti();const i=AA.useMemo(()=>{const r=new Map;for(const a of e){const g=`${a.componentName}-${a.solverName}`;r.set(g,a)}return r},[e]),n=AA.useMemo(()=>Array.from(i.keys()),[i]),o=A?i.get(A):null,s=AA.useMemo(()=>{if(!o)return{instance:null,error:null,classFound:!1};const r=ZgA[o.solverName];if(!r)return{instance:null,error:`Solver class "${o.solverName}" not found in SOLVERS registry. Available: ${Object.keys(ZgA).join(", ")}`,classFound:!1};try{const a=o.solverParams,g=a?.input!==void 0?a.input:a;return{instance:new r(g),error:null,classFound:!0}}catch(a){const g=a instanceof Error?a.message:String(a);return console.error("Failed to reconstruct solver:",a),{instance:null,error:`Failed to instantiate solver: ${g}`,classFound:!0}}},[o]);return e.length===0?Z.jsx("div",{className:"rf-p-4",children:Z.jsx("div",{className:"rf-bg-gray-50 rf-rounded-md rf-border rf-border-gray-200",children:Z.jsxs("div",{className:"rf-p-4",children:[Z.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800 rf-mb-3",children:"No Solvers Detected"}),Z.jsx("p",{className:"rf-text-sm rf-text-gray-600",children:"Solvers will appear here when the circuit runs. Solvers are used for tasks like component packing and autorouting."})]})})}):Z.jsxs("div",{className:"rf-flex rf-h-full rf-overflow-hidden",children:[Z.jsxs("div",{className:"rf-w-64 rf-border-r rf-border-gray-200 rf-overflow-y-auto rf-flex-shrink-0",children:[Z.jsxs("div",{className:"rf-text-xs rf-font-semibold rf-text-gray-500 rf-px-3 rf-py-2 rf-bg-gray-50 rf-border-b rf-border-gray-200",children:[n.length," ",n.length===1?"Solver":"Solvers"]}),n.map(r=>{const a=i.get(r),g=A===r;return Z.jsx("div",{className:`rf-px-3 rf-py-2 rf-cursor-pointer rf-border-b rf-border-gray-100 ${g?"rf-bg-blue-50 rf-border-l-2 rf-border-l-blue-500":"hover:rf-bg-gray-50"}`,onClick:()=>t(r),children:(()=>{const c=_ti(a.solverName);return Z.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2",children:[Z.jsx(c,{className:"rf-w-4 rf-h-4 rf-text-blue-500 rf-flex-shrink-0"}),Z.jsxs("div",{className:"rf-flex-1 rf-min-w-0",children:[Z.jsx("div",{className:"rf-text-sm rf-font-medium rf-text-gray-800 rf-truncate",children:a.componentName}),Z.jsx("div",{className:"rf-text-xs rf-text-gray-500 rf-truncate",children:a.solverName})]})]})})()},r)})]}),Z.jsx("div",{className:"rf-flex-1 rf-overflow-hidden",children:o?s.instance?Z.jsx(jD,{fallback:Z.jsx("div",{className:"rf-p-4",children:Z.jsxs("div",{className:"rf-bg-red-50 rf-rounded-md rf-border rf-border-red-200 rf-p-4",children:[Z.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-red-800 rf-mb-2",children:"Error Loading Solver Debugger"}),Z.jsxs("p",{className:"rf-text-sm rf-text-red-600",children:["Failed to render the solver debugger for"," ",o.solverName]})]})}),children:Z.jsx(bti,{solver:s.instance})}):Z.jsxs("div",{className:"rf-p-4",children:[Z.jsxs("div",{className:"rf-mb-4",children:[Z.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800",children:o.solverName}),Z.jsxs("p",{className:"rf-text-sm rf-text-gray-500",children:["Component: ",o.componentName]})]}),s.error&&Z.jsx("div",{className:`rf-rounded-md rf-border rf-p-4 rf-mb-4 ${s.classFound?"rf-bg-red-50 rf-border-red-200":"rf-bg-yellow-50 rf-border-yellow-200"}`,children:Z.jsx("p",{className:`rf-text-sm ${s.classFound?"rf-text-red-700":"rf-text-yellow-700"}`,children:s.error})}),Z.jsxs("div",{className:"rf-border rf-border-gray-200 rf-rounded-md rf-overflow-hidden",children:[Z.jsx("div",{className:"rf-px-3 rf-py-2 rf-bg-gray-50",children:Z.jsx("span",{className:"rf-text-sm rf-font-medium rf-text-gray-700",children:"Solver Parameters"})}),Z.jsx("div",{className:"rf-p-3 rf-bg-white rf-border-t rf-border-gray-200",children:Z.jsx("pre",{className:"rf-text-xs rf-font-mono rf-text-gray-600 rf-whitespace-pre-wrap rf-overflow-x-auto",children:JSON.stringify(o.solverParams,null,2)})})]})]}):Z.jsx("div",{className:"rf-flex rf-items-center rf-justify-center rf-h-full",children:Z.jsx("p",{className:"rf-text-sm rf-text-gray-500",children:"Select a solver from the list to view details"})})})]})},XQt=({errorMessage:e,errorStack:A,circuitJsonErrors:t})=>{AA.useEffect(()=>{if(e){const i=new Error(e);A&&(i.stack=A);try{lq.captureException(i)}catch{}}},[e,A]),AA.useEffect(()=>{if(t&&t.length>0)for(const i of t){const n=new Error(i.message||"Circuit JSON Error");i.stack&&(n.stack=i.stack);try{lq.captureException(n,{error_type:i.type})}catch{}}},[t])},$Qt="0.0.1742",vti={version:$Qt},SyA={BASE_URL:"/",DEV:!1,MODE:"production",PROD:!0,SSR:!1},byA=new Map,$j=e=>{const A=byA.get(e);return A?Object.fromEntries(Object.entries(A.stores).map(([t,i])=>[t,i.getState()])):{}},Fti=(e,A,t)=>{if(e===void 0)return{type:"untracked",connection:A.connect(t)};const i=byA.get(t.name);if(i)return{type:"tracked",store:e,...i};const n={connection:A.connect(t),stores:{}};return byA.set(t.name,n),{type:"tracked",store:e,...n}},Aht=(e,A={})=>(t,i,n)=>{const{enabled:o,anonymousActionType:s,store:r,...a}=A;let g;try{g=(o??(SyA?"production":void 0)!=="production")&&window.__REDUX_DEVTOOLS_EXTENSION__}catch{}if(!g)return(SyA?"production":void 0)!=="production"&&o&&console.warn("[zustand devtools middleware] Please install/enable Redux devtools extension"),e(t,i,n);const{connection:c,...I}=Fti(r,g,a);let l=!0;n.setState=(Q,h,E)=>{const u=t(Q,h);if(!l)return u;const d=E===void 0?{type:s||"anonymous"}:typeof E=="string"?{type:E}:E;return r===void 0?(c?.send(d,i()),u):(c?.send({...d,type:`${r}/${d.type}`},{...$j(a.name),[r]:n.getState()}),u)};const B=(...Q)=>{const h=l;l=!1,t(...Q),l=h},C=e(n.setState,i,n);if(I.type==="untracked"?c?.init(C):(I.stores[I.store]=n,c?.init(Object.fromEntries(Object.entries(I.stores).map(([Q,h])=>[Q,Q===I.store?C:h.getState()])))),n.dispatchFromDevtools&&typeof n.dispatch=="function"){let Q=!1;const h=n.dispatch;n.dispatch=(...E)=>{(SyA?"production":void 0)!=="production"&&E[0].type==="__setState"&&!Q&&(console.warn('[zustand devtools middleware] "__setState" action type is reserved to set state from the devtools. Avoid using it.'),Q=!0),h(...E)}}return c.subscribe(Q=>{var h;switch(Q.type){case"ACTION":if(typeof Q.payload!="string"){console.error("[zustand devtools middleware] Unsupported action format");return}return xyA(Q.payload,E=>{if(E.type==="__setState"){if(r===void 0){B(E.state);return}Object.keys(E.state).length!==1&&console.error(`
5688
+ `,I=new Blob([c],{type:"text/plain"}),l=URL.createObjectURL(I),B=document.createElement("a");B.href=l,B.download=`${g}.test.ts`,B.click(),URL.revokeObjectURL(l)}catch(a){alert(`Error generating test.ts for ${e.constructor.name}: ${a instanceof Error?a.message:String(a)}`)}i(!1)};return Z.jsxs("div",{className:`relative ${A}`,ref:n,children:[Z.jsx("button",{className:"px-2 py-1 rounded text-xs cursor-pointer",onClick:()=>i(!t),title:`Download options for ${e.constructor.name}`,children:e.constructor.name}),t&&Z.jsxs("div",{className:"absolute top-full left-0 mt-1 bg-white border border-gray-300 rounded shadow-lg z-10 min-w-[150px]",children:[Z.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:o,children:"Download JSON"}),Z.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:s,children:"Download page.tsx"}),Z.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:r,children:"Download test.ts"})]})]})},zQt=e=>e.activeSubSolver?[e,...zQt(e.activeSubSolver)]:[e],Qti=({solver:e})=>{const A=zQt(e);return Z.jsx("div",{className:"flex gap-1 items-center text-sm pt-1",children:A.map((t,i)=>Z.jsxs("div",{className:"flex items-center",children:[i>0&&Z.jsx("span",{className:"text-gray-400 mx-1",children:"→"}),Z.jsx(Cti,{solver:t})]},t.constructor.name))})},hti=({solver:e,triggerRender:A,animationSpeed:t=25,onSolverStarted:i,onSolverCompleted:n})=>{const[o,s]=AA.useReducer(Q=>!Q,!1),r=AA.useRef(void 0),a=()=>{!e.solved&&!e.failed&&(e.step(),A())},g=()=>{!e.solved&&!e.failed&&(i&&i(e),e.solve(),A(),n&&n(e))},c=()=>{o?(r.current&&(clearInterval(r.current),r.current=void 0),s()):(s(),r.current=setInterval(()=>{if(e.solved||e.failed){r.current&&(clearInterval(r.current),r.current=void 0),s(),A(),n&&e.solved&&n(e);return}e.step(),A()},t))},I=()=>{const Q=e;if(Q.getCurrentPhase&&!e.solved&&!e.failed){const h=Q.getCurrentPhase();for(;Q.getCurrentPhase()===h&&!e.solved&&!e.failed;)e.step();A()}},l=()=>{if(e.solved||e.failed||o)return;const Q=window.prompt("Step until which iteration?",`${e.iterations}`);if(Q===null)return;const h=Number(Q);if(!Number.isFinite(h)){window.alert("Please enter a valid number for the iteration");return}for(;e.iterations<h&&!e.solved&&!e.failed;)e.step();A(),e.solved&&n&&n(e)};AA.useEffect(()=>()=>{r.current&&clearInterval(r.current)},[]),AA.useEffect(()=>{(e.solved||e.failed)&&o&&(r.current&&(clearInterval(r.current),r.current=void 0),s())},[e.solved,e.failed,o]);const B=e.getCurrentPhase!==void 0,C=B?e.getCurrentPhase():null;return Z.jsxs("div",{className:"space-y-2 p-2 border-b",children:[Z.jsx("div",{className:"flex items-center",children:Z.jsx(Qti,{solver:e})}),Z.jsxs("div",{className:"flex gap-2 items-center flex-wrap",children:[Z.jsx("button",{onClick:a,disabled:e.solved||e.failed||o,className:"bg-blue-500 hover:bg-blue-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Step"}),Z.jsx("button",{onClick:g,disabled:e.solved||e.failed||o,className:"bg-green-500 hover:bg-green-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Solve"}),Z.jsx("button",{onClick:c,disabled:e.solved||e.failed,className:`px-3 py-1 rounded text-white text-sm ${o?"bg-red-500 hover:bg-red-600":"bg-yellow-500 hover:bg-yellow-600"} disabled:bg-gray-300`,children:o?"Stop":"Animate"}),Z.jsx("button",{onClick:l,disabled:e.solved||e.failed||o,className:"bg-orange-500 hover:bg-orange-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Step Until Iteration"}),B&&Z.jsx("button",{onClick:I,disabled:e.solved||e.failed||o,className:"bg-purple-500 hover:bg-purple-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Next Stage"}),Z.jsxs("div",{className:"text-sm text-gray-600",children:["Iterations: ",e.iterations]}),e.timeToSolve!==void 0&&Z.jsxs("div",{className:"text-sm text-gray-600",children:["Time: ",(e.timeToSolve/1e3).toFixed(3),"s"]}),C&&Z.jsxs("div",{className:"text-sm text-gray-600",children:["Phase: ",Z.jsx("span",{className:"font-medium",children:C})]}),e.solved&&Z.jsx("div",{className:"px-2 py-1 bg-green-100 text-green-800 rounded text-sm",children:"Solved"}),e.failed&&Z.jsx("div",{className:"px-2 py-1 bg-red-100 text-red-800 rounded text-sm",children:"Failed"})]}),e.error&&Z.jsxs("div",{className:"text-red-600 text-sm",children:["Error: ",e.error]})]})},Eti=(e,A,t)=>{const i=e.currentPipelineStepIndex;return A<i?"Completed":A===i&&e.activeSubSolver?e.activeSubSolver.failed?"Failed":"In Progress":"Not Started"},uti=(e,A)=>{const i=e.pipelineDef[A].solverName,n=Eti(e,A),o=e[i],s=e.firstIterationOfPhase?.[i]??null,r=e.iterations;let a=0;if(n==="Completed"){const l=e.pipelineDef[A+1],B=l?e.firstIterationOfPhase?.[l.solverName]:void 0;B!==void 0&&s!==null?a=B-s:s!==null&&(a=r-s)}else n==="In Progress"&&s!==null&&(a=r-s);const g=e.timeSpentOnPhase?.[i]??0;let c=0;n==="Completed"?c=1:n==="In Progress"&&o&&(c=o.progress??0);const I=o?.stats??null;return{index:A,name:i,status:n,firstIteration:s,iterations:a,progress:c,timeSpent:g,stats:I&&Object.keys(I).length>0?I:null,solverInstance:o??null}},dti=({status:e})=>{const A={"Not Started":"text-blue-600","In Progress":"text-yellow-600",Completed:"text-green-600",Failed:"text-red-600"};return Z.jsx("span",{className:`font-medium ${A[e]}`,children:e})},pti=({progress:e})=>{if(e===0)return null;const A=Math.round(e*100);return Z.jsxs("div",{className:"flex items-center gap-2",children:[Z.jsx("div",{className:"w-20 h-2 bg-gray-200 rounded overflow-hidden",children:Z.jsx("div",{className:"h-full bg-blue-500 transition-all duration-200",style:{width:`${A}%`}})}),Z.jsxs("span",{className:"text-xs text-gray-500",children:[A,"%"]})]})},fti=e=>Object.entries(e).map(([A,t])=>`${A}: ${t}`).join(", "),yti=({stats:e})=>{if(!e||Object.keys(e).length===0)return Z.jsx("span",{children:"-"});const A=Object.entries(e),t=fti(e);return Z.jsxs("details",{className:"cursor-pointer",children:[Z.jsx("summary",{className:"whitespace-nowrap overflow-hidden text-ellipsis max-w-[200px]",children:t}),Z.jsx("div",{className:"mt-1 text-xs",children:A.map(([i,n])=>Z.jsxs("div",{children:[i,": ",String(n)]},i))})]})},DyA=e=>{if(e===null||typeof e!="object")return e;if(Array.isArray(e))return e.map(DyA);const A={};for(const[t,i]of Object.entries(e))t.startsWith("_")||(A[t]=DyA(i));return A},mti=(e,A)=>{try{if(typeof e.getConstructorParams!="function"){alert(`getConstructorParams() is not implemented for ${A}`);return}const t=DyA(e.getConstructorParams()),i=new Blob([JSON.stringify(t,null,2)],{type:"application/json"}),n=URL.createObjectURL(i),o=document.createElement("a");o.href=n,o.download=`${A}_input.json`,o.click(),URL.revokeObjectURL(n)}catch(t){alert(`Error downloading input for ${A}: ${t instanceof Error?t.message:String(t)}`)}},wti=({solver:e,onStepUntilPhase:A,onDownloadInput:t})=>{const i=e.pipelineDef.map((r,a)=>uti(e,a)),n=r=>{A?.(r)},o=r=>{r.solverInstance&&(t?t(r.solverInstance,r.name):mti(r.solverInstance,r.name))},s=r=>`${(r/1e3).toFixed(2)}s`;return Z.jsxs("div",{className:"border-t border-gray-200",children:[Z.jsx("div",{className:"px-4 py-2 bg-gray-50 border-b border-gray-200",children:Z.jsx("h3",{className:"text-sm font-semibold text-gray-700",children:"Pipeline Steps"})}),Z.jsx("div",{className:"overflow-x-auto",children:Z.jsxs("table",{className:"w-full text-sm",children:[Z.jsx("thead",{children:Z.jsxs("tr",{className:"bg-gray-50 border-b border-gray-200",children:[Z.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Step"}),Z.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Status"}),Z.jsxs("th",{className:"px-4 py-2 text-center font-semibold text-gray-700",children:["i",Z.jsx("sub",{children:"0"})]}),Z.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Iterations"}),Z.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Progress"}),Z.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Time"}),Z.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Stats"}),Z.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Input"})]})}),Z.jsx("tbody",{children:i.map(r=>Z.jsxs("tr",{className:`border-b border-gray-100 ${r.status==="In Progress"?"bg-yellow-50":""}`,children:[Z.jsx("td",{className:"px-4 py-2",children:Z.jsxs("div",{className:"flex items-center gap-2",children:[Z.jsx("span",{className:"text-gray-400 w-6",children:String(r.index+1).padStart(2,"0")}),Z.jsx("button",{onClick:()=>n(r.name),disabled:r.status==="Completed"||e.solved||e.failed,className:"text-blue-500 hover:text-blue-700 disabled:text-gray-300 disabled:cursor-not-allowed",title:`Step until ${r.name} completes`,children:Z.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:Z.jsx("path",{fillRule:"evenodd",d:"M4.5 5.653c0-1.426 1.529-2.33 2.779-1.643l11.54 6.348c1.295.712 1.295 2.573 0 3.285L7.28 19.991c-1.25.687-2.779-.217-2.779-1.643V5.653z",clipRule:"evenodd"})})}),Z.jsx("span",{className:"font-medium text-gray-900",children:r.name})]})}),Z.jsx("td",{className:"px-4 py-2",children:Z.jsx(dti,{status:r.status})}),Z.jsx("td",{className:"px-4 py-2 text-center text-gray-600",children:r.firstIteration!==null?r.firstIteration:""}),Z.jsx("td",{className:"px-4 py-2 text-gray-600",children:r.iterations}),Z.jsx("td",{className:"px-4 py-2",children:Z.jsx(pti,{progress:r.progress})}),Z.jsx("td",{className:"px-4 py-2 text-gray-600",children:s(r.timeSpent)}),Z.jsx("td",{className:"px-4 py-2 text-gray-500",children:Z.jsx(yti,{stats:r.stats})}),Z.jsx("td",{className:"px-4 py-2",children:r.solverInstance?Z.jsxs("button",{onClick:()=>o(r),className:"flex items-center gap-1 text-blue-500 hover:text-blue-700",title:`Download input for ${r.name}`,children:[Z.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:Z.jsx("path",{fillRule:"evenodd",d:"M12 2.25a.75.75 0 01.75.75v11.69l3.22-3.22a.75.75 0 111.06 1.06l-4.5 4.5a.75.75 0 01-1.06 0l-4.5-4.5a.75.75 0 111.06-1.06l3.22 3.22V3a.75.75 0 01.75-.75zm-9 13.5a.75.75 0 01.75.75v2.25a1.5 1.5 0 001.5 1.5h13.5a1.5 1.5 0 001.5-1.5V16.5a.75.75 0 011.5 0v2.25a3 3 0 01-3 3H5.25a3 3 0 01-3-3V16.5a.75.75 0 01.75-.75z",clipRule:"evenodd"})}),Z.jsx("span",{children:"Input"})]}):null})]},r.name))})]})})]})},Dti=class extends Qn.Component{constructor(e){super(e),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(e){console.error("InteractiveGraphics render error:",e)}render(){return this.state.hasError?this.props.fallback:this.props.children}};function Sti({graphics:e}){const A=e.points??[],t=e.lines??[],i=e.rects??[],n=e.circles??[],o=e.texts??[];let s=Number.POSITIVE_INFINITY,r=Number.POSITIVE_INFINITY,a=Number.NEGATIVE_INFINITY,g=Number.NEGATIVE_INFINITY;const c=(h,E)=>{typeof h=="number"&&(h<s&&(s=h),h>a&&(a=h)),typeof E=="number"&&(E<r&&(r=E),E>g&&(g=E))};for(const h of A)c(h.x,h.y);for(const h of t){const E=h.points??[];for(const u of E)c(u.x,u.y)}for(const h of i){const E=h.x??0,u=h.y??0,d=h.width??0,f=h.height??0;c(E,u),c(E+d,u+f)}for(const h of n){const E=h.x??0,u=h.y??0,d=h.radius??1;c(E-d,u-d),c(E+d,u+d)}for(const h of o)c(h.x,h.y);(!isFinite(s)||!isFinite(r)||!isFinite(a)||!isFinite(g))&&(s=-20,r=-20,a=20,g=20);const I=10,l=s-I,B=r-I,C=Math.max(1,a-s+2*I),Q=Math.max(1,g-r+2*I);return Z.jsxs("svg",{className:"w-full h-[400px] bg-white",viewBox:`${l} ${B} ${C} ${Q}`,role:"img","aria-label":"Graphics fallback",children:[i.map((h,E)=>Z.jsx("rect",{x:h.x??0,y:h.y??0,width:h.width??0,height:h.height??0,fill:"none",stroke:h.strokeColor??"black",strokeWidth:h.strokeWidth??1},`rect-${E}`)),t.map((h,E)=>Z.jsx("polyline",{fill:"none",stroke:h.strokeColor??"black",strokeWidth:h.strokeWidth??1,points:(h.points??[]).map(u=>`${u.x??0},${u.y??0}`).join(" ")},`line-${E}`)),n.map((h,E)=>Z.jsx("circle",{cx:h.x??0,cy:h.y??0,r:h.radius??1.5,fill:h.fillColor??"none",stroke:h.strokeColor??"black",strokeWidth:h.strokeWidth??1},`circle-${E}`)),A.map((h,E)=>Z.jsx("circle",{cx:h.x??0,cy:h.y??0,r:h.radius??1.5,fill:h.color??"black"},`point-${E}`)),o.map((h,E)=>Z.jsx("text",{x:h.x??0,y:h.y??0,fontSize:h.fontSize??10,fill:h.color??"black",children:h.text??""},`text-${E}`))]})}var bti=({solver:e,animationSpeed:A=25,onSolverStarted:t,onSolverCompleted:i})=>{const[n,o]=AA.useReducer(c=>c+1,0),s=AA.useMemo(()=>{try{return e.visualize()||{points:[],lines:[],rects:[],circles:[]}}catch(c){return console.error("Visualization error:",c),{points:[],lines:[],rects:[],circles:[]}}},[e,n]),r=AA.useMemo(()=>(s.rects?.length||0)===0&&(s.lines?.length||0)===0&&(s.points?.length||0)===0&&(s.circles?.length||0)===0,[s]);AA.useEffect(()=>{if(!(typeof document>"u")&&!document.querySelector('script[src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4"]')){const c=document.createElement("script");c.src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4",document.head.appendChild(c)}},[]);const a=e.pipelineDef!==void 0,g=c=>{const I=e;if(!e.solved&&!e.failed){for(;!e.solved&&!e.failed&&I.currentPipelineStepIndex<=I.pipelineDef.findIndex(l=>l.solverName===c);)e.step();o()}};return Z.jsxs("div",{children:[Z.jsx(hti,{solver:e,triggerRender:o,animationSpeed:A,onSolverStarted:t,onSolverCompleted:i}),r?Z.jsx("div",{className:"p-4 text-gray-500",children:"No Graphics Yet"}):Z.jsx(Dti,{fallback:Z.jsx(Sti,{graphics:s}),children:Z.jsx(Bti,{graphics:s})}),a&&Z.jsx(wti,{solver:e,onStepUntilPhase:g})]})};const xti=()=>{AA.useEffect(()=>{const e="tailwind-cdn-script";if(document.getElementById(e)||window.tailwind)return;const A=document.createElement("div");A.className="hidden",document.body.appendChild(A);const t=window.getComputedStyle(A).display==="none";if(document.body.removeChild(A),t)return;const i=document.createElement("script");i.id=e,i.src="https://cdn.tailwindcss.com",document.head.appendChild(i)},[])},_ti=e=>e.toLowerCase().includes("pack")?nTe:e.toLowerCase().includes("rout")?cTe:VJe,kti=({solverEvents:e=[]})=>{const[A,t]=AA.useState(null);xti();const i=AA.useMemo(()=>{const r=new Map;for(const a of e){const g=`${a.componentName}-${a.solverName}`;r.set(g,a)}return r},[e]),n=AA.useMemo(()=>Array.from(i.keys()),[i]),o=A?i.get(A):null,s=AA.useMemo(()=>{if(!o)return{instance:null,error:null,classFound:!1};const r=ZgA[o.solverName];if(!r)return{instance:null,error:`Solver class "${o.solverName}" not found in SOLVERS registry. Available: ${Object.keys(ZgA).join(", ")}`,classFound:!1};try{const a=o.solverParams,g=a?.input!==void 0?a.input:a;return{instance:new r(g),error:null,classFound:!0}}catch(a){const g=a instanceof Error?a.message:String(a);return console.error("Failed to reconstruct solver:",a),{instance:null,error:`Failed to instantiate solver: ${g}`,classFound:!0}}},[o]);return e.length===0?Z.jsx("div",{className:"rf-p-4",children:Z.jsx("div",{className:"rf-bg-gray-50 rf-rounded-md rf-border rf-border-gray-200",children:Z.jsxs("div",{className:"rf-p-4",children:[Z.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800 rf-mb-3",children:"No Solvers Detected"}),Z.jsx("p",{className:"rf-text-sm rf-text-gray-600",children:"Solvers will appear here when the circuit runs. Solvers are used for tasks like component packing and autorouting."})]})})}):Z.jsxs("div",{className:"rf-flex rf-h-full rf-overflow-hidden",children:[Z.jsxs("div",{className:"rf-w-64 rf-border-r rf-border-gray-200 rf-overflow-y-auto rf-flex-shrink-0",children:[Z.jsxs("div",{className:"rf-text-xs rf-font-semibold rf-text-gray-500 rf-px-3 rf-py-2 rf-bg-gray-50 rf-border-b rf-border-gray-200",children:[n.length," ",n.length===1?"Solver":"Solvers"]}),n.map(r=>{const a=i.get(r),g=A===r;return Z.jsx("div",{className:`rf-px-3 rf-py-2 rf-cursor-pointer rf-border-b rf-border-gray-100 ${g?"rf-bg-blue-50 rf-border-l-2 rf-border-l-blue-500":"hover:rf-bg-gray-50"}`,onClick:()=>t(r),children:(()=>{const c=_ti(a.solverName);return Z.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2",children:[Z.jsx(c,{className:"rf-w-4 rf-h-4 rf-text-blue-500 rf-flex-shrink-0"}),Z.jsxs("div",{className:"rf-flex-1 rf-min-w-0",children:[Z.jsx("div",{className:"rf-text-sm rf-font-medium rf-text-gray-800 rf-truncate",children:a.componentName}),Z.jsx("div",{className:"rf-text-xs rf-text-gray-500 rf-truncate",children:a.solverName})]})]})})()},r)})]}),Z.jsx("div",{className:"rf-flex-1 rf-overflow-hidden",children:o?s.instance?Z.jsx(jD,{fallback:Z.jsx("div",{className:"rf-p-4",children:Z.jsxs("div",{className:"rf-bg-red-50 rf-rounded-md rf-border rf-border-red-200 rf-p-4",children:[Z.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-red-800 rf-mb-2",children:"Error Loading Solver Debugger"}),Z.jsxs("p",{className:"rf-text-sm rf-text-red-600",children:["Failed to render the solver debugger for"," ",o.solverName]})]})}),children:Z.jsx(bti,{solver:s.instance})}):Z.jsxs("div",{className:"rf-p-4",children:[Z.jsxs("div",{className:"rf-mb-4",children:[Z.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800",children:o.solverName}),Z.jsxs("p",{className:"rf-text-sm rf-text-gray-500",children:["Component: ",o.componentName]})]}),s.error&&Z.jsx("div",{className:`rf-rounded-md rf-border rf-p-4 rf-mb-4 ${s.classFound?"rf-bg-red-50 rf-border-red-200":"rf-bg-yellow-50 rf-border-yellow-200"}`,children:Z.jsx("p",{className:`rf-text-sm ${s.classFound?"rf-text-red-700":"rf-text-yellow-700"}`,children:s.error})}),Z.jsxs("div",{className:"rf-border rf-border-gray-200 rf-rounded-md rf-overflow-hidden",children:[Z.jsx("div",{className:"rf-px-3 rf-py-2 rf-bg-gray-50",children:Z.jsx("span",{className:"rf-text-sm rf-font-medium rf-text-gray-700",children:"Solver Parameters"})}),Z.jsx("div",{className:"rf-p-3 rf-bg-white rf-border-t rf-border-gray-200",children:Z.jsx("pre",{className:"rf-text-xs rf-font-mono rf-text-gray-600 rf-whitespace-pre-wrap rf-overflow-x-auto",children:JSON.stringify(o.solverParams,null,2)})})]})]}):Z.jsx("div",{className:"rf-flex rf-items-center rf-justify-center rf-h-full",children:Z.jsx("p",{className:"rf-text-sm rf-text-gray-500",children:"Select a solver from the list to view details"})})})]})},XQt=({errorMessage:e,errorStack:A,circuitJsonErrors:t})=>{AA.useEffect(()=>{if(e){const i=new Error(e);A&&(i.stack=A);try{lq.captureException(i)}catch{}}},[e,A]),AA.useEffect(()=>{if(t&&t.length>0)for(const i of t){const n=new Error(i.message||"Circuit JSON Error");i.stack&&(n.stack=i.stack);try{lq.captureException(n,{error_type:i.type})}catch{}}},[t])},$Qt="0.0.1743",vti={version:$Qt},SyA={BASE_URL:"/",DEV:!1,MODE:"production",PROD:!0,SSR:!1},byA=new Map,$j=e=>{const A=byA.get(e);return A?Object.fromEntries(Object.entries(A.stores).map(([t,i])=>[t,i.getState()])):{}},Fti=(e,A,t)=>{if(e===void 0)return{type:"untracked",connection:A.connect(t)};const i=byA.get(t.name);if(i)return{type:"tracked",store:e,...i};const n={connection:A.connect(t),stores:{}};return byA.set(t.name,n),{type:"tracked",store:e,...n}},Aht=(e,A={})=>(t,i,n)=>{const{enabled:o,anonymousActionType:s,store:r,...a}=A;let g;try{g=(o??(SyA?"production":void 0)!=="production")&&window.__REDUX_DEVTOOLS_EXTENSION__}catch{}if(!g)return(SyA?"production":void 0)!=="production"&&o&&console.warn("[zustand devtools middleware] Please install/enable Redux devtools extension"),e(t,i,n);const{connection:c,...I}=Fti(r,g,a);let l=!0;n.setState=(Q,h,E)=>{const u=t(Q,h);if(!l)return u;const d=E===void 0?{type:s||"anonymous"}:typeof E=="string"?{type:E}:E;return r===void 0?(c?.send(d,i()),u):(c?.send({...d,type:`${r}/${d.type}`},{...$j(a.name),[r]:n.getState()}),u)};const B=(...Q)=>{const h=l;l=!1,t(...Q),l=h},C=e(n.setState,i,n);if(I.type==="untracked"?c?.init(C):(I.stores[I.store]=n,c?.init(Object.fromEntries(Object.entries(I.stores).map(([Q,h])=>[Q,Q===I.store?C:h.getState()])))),n.dispatchFromDevtools&&typeof n.dispatch=="function"){let Q=!1;const h=n.dispatch;n.dispatch=(...E)=>{(SyA?"production":void 0)!=="production"&&E[0].type==="__setState"&&!Q&&(console.warn('[zustand devtools middleware] "__setState" action type is reserved to set state from the devtools. Avoid using it.'),Q=!0),h(...E)}}return c.subscribe(Q=>{var h;switch(Q.type){case"ACTION":if(typeof Q.payload!="string"){console.error("[zustand devtools middleware] Unsupported action format");return}return xyA(Q.payload,E=>{if(E.type==="__setState"){if(r===void 0){B(E.state);return}Object.keys(E.state).length!==1&&console.error(`
5689
5689
  [zustand devtools middleware] Unsupported __setState action format.
5690
5690
  When using 'store' option in devtools(), the 'state' should have only one key, which is a value of 'store' that was passed in devtools(),
5691
5691
  and value of this only key should be a state object. Example: { "type": "__setState", "state": { "abc123Store": { "foo": "bar" } } }
@@ -5472,7 +5472,7 @@ $1`).replace(/>(\s*)(?=<!--\s*\/)/g,"> ")}}});function vhe(t,A,e){if(!A||!e)retu
5472
5472
  transition: opacity 0.2s;
5473
5473
  margin-bottom: 10px;
5474
5474
  color: red;
5475
- `,uti=({children:t,transform:A=xa(),elements:e})=>{const i=V.useRef(null),{isShowingDRCErrors:n,hoveredErrorId:o}=gl(g=>({isShowingDRCErrors:g.is_showing_drc_errors,hoveredErrorId:g.hovered_error_id}));if(!e)return W.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)}),W.jsxs("div",{style:{position:"relative"},ref:i,children:[t,s.map((g,c)=>{const{pcb_port_ids:I,pcb_trace_id:l}=g,B=I?.[0]?a.get(I[0]):void 0,C=I?.[1]?a.get(I[1]):void 0,Q=e?rx(e).pcb_trace.get(l):void 0,h=g.pcb_trace_error_id||`error_${c}_${g.error_type}_${g.message?.slice(0,20)}`,E=o===h;if(B&&C){const u=Ce(A,{x:B.x,y:B.y}),d=Ce(A,{x:C.x,y:C.y});if(!n)return null;const f=!(isNaN(u.x)||isNaN(u.y)||isNaN(d.x)||isNaN(d.y)),y={x:(u.x+d.x)/2,y:(u.y+d.y)/2};if(isNaN(y.x)||isNaN(y.y))return null;const w=fmA(y,i);return W.jsxs(V.Fragment,{children:[W.jsx(hti,{screenPort1:u,screenPort2:d,errorCenter:y,canLineBeDrawn:f,isHighlighted:E}),W.jsx("div",{style:{position:"absolute",left:y.x-15,top:y.y-15,width:30,height:30,zIndex:kc.errorOverlay+5,cursor:"pointer",borderRadius:"50%"},onMouseEnter:D=>{const S=D.currentTarget.nextElementSibling;if(S){const _=S.querySelector(".error-message");_&&(_.style.opacity="1")}},onMouseLeave:D=>{if(!E){const S=D.currentTarget.nextElementSibling;if(S){const _=S.querySelector(".error-message");_&&(_.style.opacity="0")}}}}),W.jsx("div",{style:{position:"absolute",zIndex:E?200:100,left:w.left,top:w.top,color:E?"#ff4444":"red",textAlign:"center",fontFamily:"sans-serif",fontSize:12,display:n||E?"flex":"none",flexDirection:"column",alignItems:"center",pointerEvents:"none",transform:w.transform},children:W.jsx("div",{className:`error-message ${ymA}`,style:{opacity:E?1:0,border:`1px solid ${E?"#ff4444":"red"}`},children:g.message})})]},h)}if(Q?.route&&(n||E)){const u=Q.route.map(w=>Ce(A,{x:w.x,y:w.y}));if(u.some(w=>isNaN(w.x)||isNaN(w.y)))return null;const d=Math.floor(u.length/2),f=u[d],y=fmA(f,i);return W.jsxs(V.Fragment,{children:[W.jsx(Eti,{points:u,errorCenter:f,isHighlighted:E}),W.jsx("div",{style:{position:"absolute",left:f.x-15,top:f.y-15,width:30,height:30,zIndex:kc.errorOverlay+5,cursor:"pointer",borderRadius:"50%"},onMouseEnter:w=>{const D=w.currentTarget.nextElementSibling;if(D){const S=D.querySelector(".error-message");S&&(S.style.opacity="1")}},onMouseLeave:w=>{if(!E){const D=w.currentTarget.nextElementSibling;if(D){const S=D.querySelector(".error-message");S&&(S.style.opacity="0")}}}}),W.jsx("div",{style:{position:"absolute",zIndex:E?kc.errorOverlay+10:kc.errorOverlay+1,left:y.left,top:y.top,color:E?"#ff4444":"red",textAlign:"center",fontFamily:"sans-serif",fontSize:12,display:"flex",flexDirection:"column",alignItems:"center",pointerEvents:"none",transform:y.transform},children:W.jsx("div",{className:`error-message ${ymA}`,style:{opacity:E?1:0,border:`1px solid ${E?"#ff4444":"red"}`},children:g.message})})]},h)}return null}),r.map((g,c)=>{const I=g.component_name||g.message?.match(/name "([^"]+)"/)?.[1];if(!I)return null;const l=e?.filter(Q=>Q.type==="source_component"&&Q.name===I||Q.type==="pcb_component"&&e?.find(h=>h.type==="source_component"&&h.source_component_id===Q.source_component_id&&h.name===I))||[],B=g.pcb_trace_error_id||`error_${c}_${g.error_type}_${g.message?.slice(0,20)}`,C=o===B;return!C&&!n?null:l.map((Q,h)=>{let E={x:0,y:0};if(Q.type==="pcb_component")E=Q.center||{x:0,y:0};else if(Q.type==="source_component"){const _=e?.find(b=>b.type==="pcb_component"&&b.source_component_id===Q.source_component_id);_&&_.type==="pcb_component"&&(E=_.center||{x:0,y:0})}const u=Ce(A,E);if(isNaN(u.x)||isNaN(u.y))return null;const d=Math.abs(A.a),D=Math.max(8,Math.min(30,.5*d)),S=fmA(u,i);return W.jsxs(V.Fragment,{children:[W.jsx("svg",{style:{position:"absolute",left:0,top:0,pointerEvents:"none",mixBlendMode:"difference",zIndex:kc.errorOverlay},width:"100%",height:"100%",children:C?W.jsx("polygon",{points:`${u.x},${u.y-D*1.25} ${u.x+D},${u.y} ${u.x},${u.y+D*1.25} ${u.x-D},${u.y}`,fill:"#ff4444"}):W.jsx("circle",{cx:u.x,cy:u.y,r:D,fill:"none",stroke:C?"#ff4444":"red",strokeWidth:C?Math.max(2,D*.15):Math.max(1,D*.1),opacity:1})}),W.jsx("div",{style:{position:"absolute",left:u.x-(D+10),top:u.y-(D+10),width:(D+10)*2,height:(D+10)*2,zIndex:kc.errorOverlay+5,cursor:"pointer",borderRadius:"50%"},onMouseEnter:_=>{const b=_.currentTarget.nextElementSibling;if(b){const N=b.querySelector(".error-message");N&&(N.style.opacity="1")}},onMouseLeave:_=>{if(!C){const b=_.currentTarget.nextElementSibling;if(b){const N=b.querySelector(".error-message");N&&(N.style.opacity="0")}}}}),W.jsx("div",{style:{position:"absolute",zIndex:C?kc.errorOverlay+20:kc.errorOverlay+10,left:S.left,top:S.top,color:C?"#ff4444":"red",textAlign:"center",fontFamily:"sans-serif",fontSize:12,display:n||C?"flex":"none",flexDirection:"column",alignItems:"center",pointerEvents:"none",transform:S.transform},children:W.jsx("div",{className:`error-message ${ymA}`,style:{opacity:C?1:0,border:`1px solid ${C?"#ff4444":"red"}`},children:g.message})})]},`${B}_${h}`)})})]})};function dti(t,A){return t.size!==A.size?!1:Array.from(t).every(e=>A.has(e))}function pti({primitiveElement:t,elements:A}){let e=t.trace_length?`${t.trace_length.toFixed(3)}`:"";const i=rx(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 n=t.trace_length&&i?.max_length&&t.trace_length>i.max_length;return{text:e,isOverLength:n}}function fti(t){const{primitives:A,is_showing_multiple_traces_length:e,elements:i}=t,n=A.filter(a=>a._element.type==="pcb_trace"),o=i.filter(a=>a.type==="source_trace"),s=A.filter(a=>a._element.type!=="pcb_trace"),r=n.filter(a=>o.some(g=>a._element.type==="pcb_trace"&&a._element.source_trace_id===g.source_trace_id&&g.max_length!==void 0));if(!e)return[...s,...r];if(n.length>1){const a=n.reduce((g,c)=>{const I=g._element.trace_length;return c._element.trace_length<I?c:g},n[0]);return[...s,a]}return A}var yti={position:"absolute",left:0,top:0,pointerEvents:"none",color:"red",fontFamily:"sans-serif",fontSize:12,textShadow:"0 0 2px black"},mti=t=>{const{_element:A,_parent_pcb_component:e,_parent_source_component:i,_source_port:n}=t;switch(A.type){case"pcb_trace":return A.trace_length?`${A.trace_length.toFixed(3)}`:"";case"pcb_smtpad":case"pcb_plated_hole":{const o=[],s=Array.from(new Set((A.port_hints??[]).concat(n?.port_hints??[]))).filter(a=>!/^[0-9]+$/.test(a)).filter(a=>!a.includes("unnamed_")).sort((a,g)=>g.localeCompare(a)),r=i&&"name"in i&&i.name&&!i.name.includes("unnamed_")?i.name:null;return s.length>0?r?o.push(...s.map(a=>`${r}.${a}`)):o.push(...s):r&&o.push(r),o.join(", ")}default:return""}},wti={top:"red",bottom:"aqua"},Dti=({primitive:t,mousePos:A,elements:e})=>{const[i,n]=V.useState(!1),o=t._element;V.useEffect(()=>{setTimeout(()=>{n(!0)},100)},[]);const[s,r,a,g]=[t.screen_x,t.screen_y,t.screen_w,t.screen_h],c=t.same_space_index??0,I=26,l=wti[t?._element?.layer]??"red";let B=0;if(o.type==="pcb_smtpad"&&o?.shape==="rotated_rect"?B=o?.ccw_rotation??0:(o.type==="pcb_smtpad"&&(o?.shape==="pill"||o?.shape==="rotated_pill")&&"ccw_rotation"in t||o.type==="pcb_plated_hole"&&(o?.shape==="pill"||o?.shape==="oval")&&"ccw_rotation"in t)&&(B=o.ccw_rotation??0),o.type==="pcb_trace"){const h=pti({primitiveElement:o,elements:e});if(!h)return null;const E=A.y-35;return W.jsx("div",{style:{zIndex:kc.elementOverlay,position:"absolute",left:A.x,top:E,color:l,pointerEvents:"none",transform:"translateX(-50%)"},children:W.jsx("div",{style:{backgroundColor:"#f2efcc",color:h.isOverLength?"red":"black",textShadow:"none",WebkitFontSmoothing:"antialiased",MozOsxFontSmoothing:"grayscale",padding:"6px 6px",borderRadius:"6px",fontSize:"14px",minWidth:"45px",textAlign:"center",whiteSpace:"nowrap"},children:h.text})})}const C=mti(t);return C.trim().length===0?null:W.jsx("div",{style:{zIndex:kc.elementOverlay,position:"absolute",left:s-a/2-8,top:r-g/2-8,width:a+16,height:g+16,color:l,transform:`rotate(${-B}deg)`,transformOrigin:"center center"},children:W.jsx("div",{style:{width:i?`calc(100% + ${I*2*c}px)`:"100%",height:i?`calc(100% + ${I*2*c}px)`:"100%",marginLeft:i?`${-I*c}px`:0,marginTop:i?`${-I*c}px`:0,border:`1px solid ${l}`,opacity:i||c===0?1:0,transition:"width 0.2s, height 0.2s, margin-left 0.2s, margin-top 0.2s, opacity 0.2s"},children:W.jsx("div",{style:{position:"absolute",bottom:g+20+I*c,marginRight:i?`${-I*c}px`:0,marginBottom:i?0:-I*c,transition:"margin-right 0.2s, margin-bottom 0.2s",backgroundColor:"#f2efcc",color:"black",textShadow:"none",WebkitFontSmoothing:"antialiased",MozOsxFontSmoothing:"grayscale",padding:"6px 6px",borderRadius:"6px",fontSize:"14px",transform:`rotate(${B}deg)`,minWidth:"45px",textAlign:"center"},children:C})})})},Sti=({highlightedPrimitives:t,mousePos:A,elements:e})=>{const[i,n]=gl(r=>[r.is_moving_component,r.is_showing_multiple_traces_length]),o=t.some(r=>r._element.type==="pcb_smtpad")&&t.some(r=>r._element.type==="pcb_trace");let s=t;return o&&(s=s.filter(r=>r._element.type==="pcb_smtpad")),s=fti({primitives:s,is_showing_multiple_traces_length:n,elements:e}),W.jsx("div",{style:yti,children:!i&&s.map((r,a)=>W.jsx(Dti,{primitive:r,mousePos:A,elements:e},a))})},Tk=t=>t?.type==="pcb_component",sEe=t=>t?.type==="pcb_group",bti=t=>t?.type==="pcb_panel",mmA=t=>t?.type==="pcb_board",aI={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},ly={OFFSET_LINE:"white",COMPONENT_MARKER_FILL:"#66ccff",COMPONENT_MARKER_STROKE:"white",LABEL_TEXT:"white"},wmA=({targets:t,transform:A,containerWidth:e,containerHeight:i})=>{if(t.length===0)return null;const n={color:ly.LABEL_TEXT,mixBlendMode:"difference",pointerEvents:"none",fontSize:aI.LABEL_FONT_SIZE,fontFamily:"monospace",fontWeight:"bold"},o=new Map;return t.forEach(s=>{if(!o.has(s.anchor_id)){const r=Ce(A,s.anchor);o.set(s.anchor_id,r)}}),W.jsx("div",{style:{position:"absolute",left:0,top:0,width:e,height:i,overflow:"hidden",pointerEvents:"none",zIndex:kc.dimensionOverlay},children:W.jsxs("svg",{style:{position:"absolute",left:0,top:0,pointerEvents:"none"},width:e,height:i,children:[t.map(s=>{const r=s.anchor,a=s.anchor_id,g=s.target,c=o.get(a),I=Ce(A,g),l=g.x-r.x,B=g.y-r.y,C=Math.abs(I.x-c.x),Q=Math.abs(I.y-c.y),h=I.y<c.y,E=I.x>c.x,u=h?aI.LABEL_OFFSET_ABOVE:aI.LABEL_OFFSET_BELOW,d=E?aI.LABEL_OFFSET_RIGHT:aI.LABEL_OFFSET_LEFT,f=C>aI.MIN_LINE_LENGTH_FOR_LABEL,y=Q>aI.MIN_LINE_LENGTH_FOR_LABEL,w=`${s.display_offset_x??l.toFixed(2)}mm`,D=`${s.display_offset_y??B.toFixed(2)}mm`;return W.jsxs("g",{children:[W.jsx("line",{x1:c.x,y1:c.y,x2:I.x,y2:c.y,stroke:ly.OFFSET_LINE,strokeWidth:aI.LINE_STROKE_WIDTH,strokeDasharray:aI.LINE_DASH_PATTERN}),W.jsx("line",{x1:I.x,y1:c.y,x2:I.x,y2:I.y,stroke:ly.OFFSET_LINE,strokeWidth:aI.LINE_STROKE_WIDTH,strokeDasharray:aI.LINE_DASH_PATTERN}),s.type==="component"||s.type==="board"?W.jsx("circle",{cx:I.x,cy:I.y,r:aI.COMPONENT_MARKER_RADIUS,fill:ly.COMPONENT_MARKER_FILL,stroke:ly.COMPONENT_MARKER_STROKE,strokeWidth:1}):W.jsxs(W.Fragment,{children:[W.jsx("line",{x1:I.x-aI.ANCHOR_MARKER_SIZE,y1:I.y,x2:I.x+aI.ANCHOR_MARKER_SIZE,y2:I.y,stroke:ly.OFFSET_LINE,strokeWidth:aI.ANCHOR_MARKER_STROKE_WIDTH}),W.jsx("line",{x1:I.x,y1:I.y-aI.ANCHOR_MARKER_SIZE,x2:I.x,y2:I.y+aI.ANCHOR_MARKER_SIZE,stroke:ly.OFFSET_LINE,strokeWidth:aI.ANCHOR_MARKER_STROKE_WIDTH})]}),f&&W.jsx("foreignObject",{x:Math.min(c.x,I.x),y:c.y+u,width:Math.abs(I.x-c.x),height:20,style:{overflow:"visible"},children:W.jsx("div",{style:{...n,textAlign:"center"},children:w})}),y&&W.jsx("foreignObject",{x:I.x+d,y:Math.min(c.y,I.y),width:aI.Y_LABEL_MIN_WIDTH,height:Math.abs(I.y-c.y),style:{overflow:"visible"},children:W.jsx("div",{style:{...n,display:"flex",alignItems:"center",justifyContent:E?"flex-start":"flex-end",whiteSpace:"nowrap",padding:"0 4px",height:"100%"},children:D})})]},s.id)}),Array.from(o.entries()).map(([s,r])=>W.jsxs("g",{children:[W.jsx("line",{x1:r.x-aI.ANCHOR_MARKER_SIZE,y1:r.y,x2:r.x+aI.ANCHOR_MARKER_SIZE,y2:r.y,stroke:ly.OFFSET_LINE,strokeWidth:aI.ANCHOR_MARKER_STROKE_WIDTH}),W.jsx("line",{x1:r.x,y1:r.y-aI.ANCHOR_MARKER_SIZE,x2:r.x,y2:r.y+aI.ANCHOR_MARKER_SIZE,stroke:ly.OFFSET_LINE,strokeWidth:aI.ANCHOR_MARKER_STROKE_WIDTH})]},`anchor-${s}`))]})})},xti=({elements:t,highlightedPrimitives:A,transform:e,containerWidth:i,containerHeight:n})=>{const o=t.filter(E=>mmA(E)),s=t.filter(E=>Tk(E)),r=t.filter(E=>sEe(E)),a=A.map(E=>Tk(E._parent_pcb_component)?E._parent_pcb_component.pcb_component_id:Tk(E._element)?E._element.pcb_component_id:null).filter(E=>!!E),g=new Set;if(a.forEach(E=>{const u=s.find(d=>d.pcb_component_id===E);u?.pcb_group_id&&g.add(u.pcb_group_id)}),!gl(E=>E.is_showing_group_anchor_offsets)&&a.length===0)return null;const I=s.map(E=>{const u=E.positioned_relative_to_pcb_board_id;if(!u)return null;const d=o.find(f=>f.pcb_board_id===u);return d?{component:E,board:d,type:"component"}:null}).filter(E=>!!E),l=r.map(E=>{const u=E.positioned_relative_to_pcb_board_id;if(!u||!E.center)return null;const d=o.find(f=>f.pcb_board_id===u);return d?{group:E,board:d,type:"group"}:null}).filter(E=>!!E),B=[...I,...l];if(B.length===0)return null;const C=a.length===0,Q=B.filter(E=>E.type==="component"?C||a.includes(E.component.pcb_component_id):C||g.has(E.group.pcb_group_id));if(Q.length===0)return null;const h=Q.map(E=>E.type==="component"?{id:`${E.board.pcb_board_id}-${E.component.pcb_component_id}-${E.type}`,anchor:E.board.center,anchor_id:E.board.pcb_board_id,target:E.component.center,type:"component",display_offset_x:E.component.display_offset_x,display_offset_y:E.component.display_offset_y}:{id:`${E.board.pcb_board_id}-${E.group.pcb_group_id}-${E.type}`,anchor:E.board.center,anchor_id:E.board.pcb_board_id,target:{x:E.group.anchor_position?.x??E.group.center.x,y:E.group.anchor_position?.y??E.group.center.y},type:"group",display_offset_x:E.group.display_offset_x,display_offset_y:E.group.display_offset_y}).filter(E=>!!E);return W.jsx(wmA,{targets:h,transform:e,containerWidth:i,containerHeight:n})},_ti=({elements:t,highlightedPrimitives:A,transform:e,containerWidth:i,containerHeight:n})=>{const o=t.filter(E=>sEe(E)),s=t.filter(E=>Tk(E)),r=A.map(E=>Tk(E._parent_pcb_component)?E._parent_pcb_component.pcb_component_id:Tk(E._element)?E._element.pcb_component_id:null).filter(E=>!!E),a=(E,u)=>{if(u.has(E))return;u.add(E);const d=o.find(f=>f.pcb_group_id===E);d?.position_mode==="relative_to_group_anchor"&&d.positioned_relative_to_pcb_group_id&&a(d.positioned_relative_to_pcb_group_id,u)},g=new Set;if(r.forEach(E=>{const u=s.find(d=>d.pcb_component_id===E);u&&(u.position_mode==="relative_to_group_anchor"&&u.positioned_relative_to_pcb_group_id&&a(u.positioned_relative_to_pcb_group_id,g),u.pcb_group_id&&a(u.pcb_group_id,g))}),!gl(E=>E.is_showing_group_anchor_offsets)&&r.length===0)return null;const I=s.map(E=>{if(E.position_mode==="relative_to_group_anchor"&&E.positioned_relative_to_pcb_group_id){const u=o.find(d=>d.pcb_group_id===E.positioned_relative_to_pcb_group_id);return u&&u.anchor_position?{component:E,parentGroup:u,type:"component"}:null}if(E.pcb_group_id){const u=o.find(d=>d.pcb_group_id===E.pcb_group_id);return u&&u.anchor_position?{component:E,parentGroup:u,type:"component"}:null}return null}).filter(E=>!!E),l=o.map(E=>{if(E.position_mode==="relative_to_group_anchor"&&E.positioned_relative_to_pcb_group_id){const u=o.find(d=>d.pcb_group_id===E.positioned_relative_to_pcb_group_id);if(u&&u.anchor_position&&E.anchor_position)return{group:E,parentGroup:u,type:"group"}}return null}).filter(E=>!!E),B=[...I,...l];if(B.length===0)return null;const C=r.length===0,Q=B.filter(E=>E.type==="component"?C||r.includes(E.component.pcb_component_id):C||g.has(E.group.pcb_group_id)||g.has(E.parentGroup.pcb_group_id));if(Q.length===0)return null;const h=Q.map(E=>{const u=E.parentGroup.anchor_position;return u?E.type==="component"?E.component.center?{id:`${E.parentGroup.pcb_group_id}-${E.component.pcb_component_id}-${E.type}`,anchor:u,anchor_id:E.parentGroup.pcb_group_id,target:E.component.center,type:"component",display_offset_x:E.component.display_offset_x,display_offset_y:E.component.display_offset_y}:null:E.group.anchor_position?{id:`${E.parentGroup.pcb_group_id}-${E.group.pcb_group_id}-${E.type}`,anchor:u,anchor_id:E.parentGroup.pcb_group_id,target:E.group.anchor_position,type:"group",display_offset_x:E.group.display_offset_x,display_offset_y:E.group.display_offset_y}:null:null}).filter(E=>!!E);return W.jsx(wmA,{targets:h,transform:e,containerWidth:i,containerHeight:n})},kti=(t,A)=>{const e=t.pcb_component_id,i=A.filter(n=>(n.type==="pcb_smtpad"||n.type==="pcb_plated_hole")&&n.pcb_component_id===e||n.type==="pcb_hole"&&n.pcb_component_id===e);return i.length===0?dmA([t]):dmA(i)},vti=({elements:t,highlightedPrimitives:A,transform:e,containerWidth:i,containerHeight:n})=>{const o=new Map;for(const r of A)Tk(r._parent_pcb_component)&&o.set(r._parent_pcb_component.pcb_component_id,r._parent_pcb_component),Tk(r._element)&&o.set(r._element.pcb_component_id,r._element);if(o.size===0)return null;const s=[];for(const r of o.values()){const a=kti(r,t);if(!a)continue;const g=r.positioned_relative_to_pcb_group_id??r.pcb_group_id,c=g?rx(t).pcb_group.get(g):null;s.push({component:r,bbox:a,group:c})}return s.length===0?null:W.jsx("div",{style:{position:"absolute",left:0,top:0,width:i,height:n,overflow:"hidden",pointerEvents:"none",zIndex:kc.dimensionOverlay},children:W.jsx("svg",{style:{position:"absolute",left:0,top:0,pointerEvents:"none"},width:i,height:n,children:s.map(({component:r,bbox:a,group:g})=>{const c=Ce(e,{x:a.minX,y:a.maxY}),I=Ce(e,{x:a.maxX,y:a.minY}),l={x:Math.min(c.x,I.x),y:Math.min(c.y,I.y),width:Math.abs(I.x-c.x),height:Math.abs(I.y-c.y)},B=r.center??{x:(a.minX+a.maxX)/2,y:(a.minY+a.maxY)/2},C=Ce(e,B);return W.jsxs("g",{children:[W.jsx("rect",{x:l.x,y:l.y,width:l.width,height:l.height,fill:"none",stroke:"white",strokeWidth:1.5,strokeDasharray:"4,4"}),W.jsx("line",{x1:C.x-6,y1:C.y,x2:C.x+6,y2:C.y,stroke:ly.COMPONENT_MARKER_STROKE,strokeWidth:1.5}),W.jsx("line",{x1:C.x,y1:C.y-6,x2:C.x,y2:C.y+6,stroke:ly.COMPONENT_MARKER_STROKE,strokeWidth:1.5}),W.jsx("circle",{cx:C.x,cy:C.y,r:aI.COMPONENT_MARKER_RADIUS,fill:ly.COMPONENT_MARKER_FILL,stroke:ly.COMPONENT_MARKER_STROKE,strokeWidth:1})]},r.pcb_component_id)})})})},Fti=({elements:t,highlightedPrimitives:A,transform:e,containerWidth:i,containerHeight:n})=>{const o=t.filter(B=>bti(B)),s=t.filter(B=>mmA(B)),r=A.map(B=>mmA(B._element)?B._element.pcb_board_id:null).filter(B=>!!B);if(!gl(B=>B.is_showing_group_anchor_offsets)&&r.length===0)return null;const g=s.map(B=>{const C=B.pcb_panel_id,Q=B.position_mode;if(!C||Q!=="relative_to_panel_anchor")return null;const h=o.find(E=>E.pcb_panel_id===C);return h?{board:B,panel:h,type:"board"}:null}).filter(B=>!!B);if(g.length===0)return null;const c=r.length===0,I=g.filter(B=>c||r.includes(B.board.pcb_board_id));if(I.length===0)return null;const l=I.map(B=>B.board.center?{id:`${B.panel.pcb_panel_id}-${B.board.pcb_board_id}-${B.type}`,anchor:B.panel.center,anchor_id:B.panel.pcb_panel_id,target:B.board.center,type:"board",display_offset_x:B.board.display_offset_x,display_offset_y:B.board.display_offset_y}:null).filter(B=>!!B);return W.jsx(wmA,{targets:l,transform:e,containerWidth:i,containerHeight:n})},Nz=t=>{if(t.length===0)return null;let A=t[0].x,e=t[0].y,i=t[0].x,n=t[0].y;for(const o of t)o.x<A&&(A=o.x),o.y<e&&(e=o.y),o.x>i&&(i=o.x),o.y>n&&(n=o.y);return{center:{x:(A+i)/2,y:(e+n)/2},width:i-A,height:n-e}},rEe=(t,A)=>{if(A.length<3)return!1;let e=!1;for(let i=0,n=A.length-1;i<A.length;n=i++){const o=A[i].x,s=A[i].y,r=A[n].x,a=A[n].y;s>t.y!=a>t.y&&t.x<(r-o)*(t.y-s)/(a-s||Number.EPSILON)+o&&(e=!e)}return e},Mti=(t,A,e)=>{const i=[];for(const n of t){if(!n._element)continue;if("x1"in n&&n._element?.type==="pcb_trace"){const r=HE({x:A.x,y:A.y},{x:n.x1,y:n.y1},{x:n.x2,y:n.y2}),a=n.width||.5,g=Math.max(a*25,2)/e.a;r<g&&i.push(n);continue}if(n.pcb_drawing_type==="polygon"){const r=n.points.map(g=>({x:Et.parse(g.x),y:Et.parse(g.y)})),a=Nz(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;rEe(A,r)&&i.push(n);continue}if(n.pcb_drawing_type==="polygon_with_arcs"){const r=n.brep_shape.outer_ring.vertices.map(g=>({x:Et.parse(g.x),y:Et.parse(g.y)})),a=Nz(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;rEe(A,r)&&i.push(n);continue}if(!("x"in n&&"y"in n))continue;let o=0,s=0;if("w"in n&&"h"in n)o=n.w,s=n.h;else if("r"in n)o=n.r*2,s=n.r*2;else if("rX"in n&&"rY"in n)o=n.rX*2,s=n.rY*2;else continue;Math.abs(n.x-A.x)<o/2&&Math.abs(n.y-A.y)<s/2&&i.push(n)}return i},Rti=({elements:t,children:A,transform:e,primitives:i,onMouseHoverOverPrimitives:n})=>{const[o,s]=V.useState([]),[r,a]=V.useState({x:0,y:0}),[g,{width:c,height:I}]=KT(),l=V.useMemo(()=>{const C=[];for(const Q of o){if(Q._element?.type==="pcb_via"||Q._element?.type==="pcb_component"||Q?.layer==="drill")continue;let h=null,E=0,u=0;if(Q.pcb_drawing_type==="polygon"){const w=Nz(Q.points);if(!w)continue;h=w.center,E=w.width,u=w.height}else if(Q.pcb_drawing_type==="polygon_with_arcs"){const w=Q.brep_shape.outer_ring.vertices.map(S=>({x:S.x,y:S.y})),D=Nz(w);if(!D)continue;h=D.center,E=D.width,u=D.height}else"x"in Q&&"y"in Q&&(h={x:Q.x,y:Q.y},E="w"in Q?Q.w:"r"in Q?Q.r*2:"rX"in Q&&"rY"in Q?Q.rX*2:0,u="h"in Q?Q.h:"r"in Q?Q.r*2:"rX"in Q&&"rY"in Q?Q.rY*2:0);if(!h)continue;const d=Ce(e,h),f={w:E*e.a,h:u*e.a},y=C.filter(w=>d.x===w.screen_x&&d.y===w.screen_y&&f.w===w.screen_w&&f.h===w.screen_h).length;C.push({...Q,x:h.x,y:h.y,w:E,h:u,screen_x:d.x,screen_y:d.y,screen_w:f.w,screen_h:f.h,same_space_index:y})}return C},[o,e]),B=(C,Q,h,E)=>{a({x:C,y:Q});const u=Ce(tm(h),{x:C,y:Q}),d=Mti(E,u,h);dti(new Set(d.map(f=>f._pcb_drawing_object_id)),new Set(o.map(f=>f._pcb_drawing_object_id)))||(s(d),n(d))};return W.jsxs("div",{ref:g,style:{position:"relative",width:"100%",height:"100%"},onMouseMove:C=>{if(e){const Q=C.currentTarget.getBoundingClientRect(),h=C.clientX-Q.left,E=C.clientY-Q.top;B(h,E,e,i)}},onTouchStart:C=>{if(e){const Q=C.touches[0],h=C.currentTarget.getBoundingClientRect(),E=Q.clientX-h.left,u=Q.clientY-h.top;B(E,u,e,i)}},children:[A,W.jsx(Sti,{elements:t,mousePos:r,highlightedPrimitives:l}),e&&W.jsxs(W.Fragment,{children:[W.jsx(xti,{elements:t,highlightedPrimitives:l,transform:e,containerWidth:c,containerHeight:I}),W.jsx(_ti,{elements:t,highlightedPrimitives:l,transform:e,containerWidth:c,containerHeight:I}),W.jsx(vti,{elements:t,highlightedPrimitives:l,transform:e,containerWidth:c,containerHeight:I}),W.jsx(Fti,{elements:t,highlightedPrimitives:l,transform:e,containerWidth:c,containerHeight:I})]})]})},aEe=["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)"],Nti=({children:t,transform:A=xa(),elements:e=[],hoveredComponentIds:i=[]})=>{const[n,{width:o,height:s}]=KT(),r=V.useRef(null),{is_showing_pcb_groups:a,pcb_group_view_mode:g,is_showing_group_anchor_offsets:c}=gl(I=>({is_showing_pcb_groups:I.is_showing_pcb_groups,pcb_group_view_mode:I.pcb_group_view_mode,is_showing_group_anchor_offsets:I.is_showing_group_anchor_offsets}));return V.useEffect(()=>{const I=r.current;if(!I||!o||!s)return;I.width=o,I.height=s;const l=I.getContext("2d");if(!l||(l.clearRect(0,0,o,s),!a))return;const B=e.filter(w=>w.type==="pcb_group"),C=e.filter(w=>w.type==="pcb_component"),Q=e.filter(w=>w.type==="source_group"),h=new Map(Q.map(w=>[w.source_group_id,w])),E=B.filter(w=>{if(w.name?.toLowerCase().includes("subpanel"))return!1;if(g==="all")return!0;if(!w.source_group_id)return!1;const D=h.get(w.source_group_id);return D?D.was_automatically_named!==!0:!1}),u=new Map;Q.forEach(w=>{const D=w;if(D.parent_source_group_id){const S=u.get(D.parent_source_group_id)||[];S.push(w.source_group_id),u.set(D.parent_source_group_id,S)}});const d=w=>{const D=[],S=u.get(w)||[];for(const _ of S)D.push(_),D.push(...d(_));return D},f=w=>{const D=Q.find(S=>S.source_group_id===w);return D?.parent_source_group_id?1+f(D.parent_source_group_id):0},y=new Set;if(i.length>0)for(const w of C){if(!i.includes(w.pcb_component_id))continue;const D=w.positioned_relative_to_pcb_group_id??w.pcb_group_id;D&&y.add(D)}E.forEach((w,D)=>{let S=C.filter(JA=>JA.pcb_group_id===w.pcb_group_id);if(w.source_group_id){const JA=d(w.source_group_id),OA=B.filter(vA=>vA.source_group_id&&JA.includes(vA.source_group_id));for(const vA of OA){const wA=C.filter(RA=>RA.pcb_group_id===vA.pcb_group_id);S=[...S,...wA]}}let _,b,N,F,L=!1;if(w.center&&w.width&&w.height){L=!0;const JA=w.width/2,OA=w.height/2;_=w.center.x-JA,N=w.center.x+JA,b=w.center.y-OA,F=w.center.y+OA}else if(S.length===0||(_=1/0,b=1/0,N=-1/0,F=-1/0,S.forEach(JA=>{if(JA.center&&typeof JA.width=="number"&&typeof JA.height=="number"){const OA=JA.center.x-JA.width/2,vA=JA.center.x+JA.width/2,wA=JA.center.y+JA.height/2,RA=JA.center.y-JA.height/2;_=Math.min(_,OA),N=Math.max(N,vA),b=Math.min(b,RA),F=Math.max(F,wA)}}),_===1/0||N===-1/0))return;const Y=w.source_group_id?f(w.source_group_id):0,J=w.source_group_id?d(w.source_group_id).length>0:!1;if(!L){const vA=1+(J?.5:0);_-=vA,N+=vA,b-=vA,F+=vA}const O=Ce(A,{x:_,y:F}),Z=Ce(A,{x:N,y:F}),X=Ce(A,{x:_,y:b}),eA=Ce(A,{x:N,y:b}),gA=aEe[D%aEe.length];l.strokeStyle=gA,l.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))),aA=tA*(J?1.3:1),EA=iA;l.setLineDash([aA,EA]),l.beginPath(),l.moveTo(O.x,O.y),l.lineTo(Z.x,Z.y),l.lineTo(eA.x,eA.y),l.lineTo(X.x,X.y),l.closePath(),l.stroke();const bA=Math.max(8,Math.min(12,10*Math.abs(A.a))),_A=Y==0||Y==1?0:Y*.11,LA=bA*(1-_A),QA=4,kA=w.name||`Group ${D+1}`;l.font=`${LA}px sans-serif`,l.setLineDash([]);const qA=l.measureText(kA).width+QA*2,VA=LA+QA*2,ce=O.x-5,fA=O.y-5,ge=3;if(l.fillStyle="rgba(0, 0, 0, 0.8)",l.beginPath(),l.roundRect(ce,fA-VA,qA,VA,ge),l.fill(),l.fillStyle=gA,l.textAlign="left",l.textBaseline="middle",l.fillText(kA,ce+QA,fA-VA/2),c&&y.has(w.pcb_group_id)&&!!w.anchor_position&&w.anchor_position){const JA=Array.isArray(w.anchor_position)?{x:w.anchor_position[0]??0,y:w.anchor_position[1]??0}:{x:w.anchor_position.x,y:w.anchor_position.y},OA=Ce(A,JA);l.strokeStyle="white",l.lineWidth=1.5,l.setLineDash([]);const vA=Math.max(4,Math.min(8,6*Math.abs(A.a)));l.beginPath(),l.moveTo(OA.x-vA,OA.y),l.lineTo(OA.x+vA,OA.y),l.stroke(),l.beginPath(),l.moveTo(OA.x,OA.y-vA),l.lineTo(OA.x,OA.y+vA),l.stroke()}})},[e,A,o,s,a,g,c,i]),W.jsxs("div",{ref:n,style:{position:"relative",width:"100%",height:"100%"},children:[t,W.jsx("canvas",{ref:r,style:{position:"absolute",top:0,left:0,pointerEvents:"none",zIndex:kc.pcbGroupOverlay,display:a?"block":"none"}})]})},Gti=({transform:t,soup:A,children:e})=>{const i=gl(r=>r.is_showing_rats_nest),{netMap:n,idToNetMap:o}=V.useMemo(()=>Hhe(A||[]),[A]),s=V.useMemo(()=>{if(!A||!i)return[];const r=l=>{const B=rx(A)[l.replace(/_\d+$/,"")].get(l);return B&&"x"in B&&"y"in B?{x:B.x,y:B.y}:null},a=(l,B)=>{const C=n[B]||[];let Q=null,h=1/0;return C.forEach(E=>{const u=r(E);if(u){const d=Math.sqrt((l.x-u.x)**2+(l.y-u.y)**2);d<h&&d>0&&(h=d,Q=u)}}),Q},g=rx(A).pcb_port.list(),c=rx(A).source_trace.list(),I=[];return g.forEach((l,B)=>{const C=o[l.pcb_port_id];let Q=!1;for(const u of c)u.connected_source_port_ids.includes(l.source_port_id)&&u.connected_source_net_ids.length>0&&(Q=!0);if(!C)return;const h={x:l.x,y:l.y},E=a(h,C);E&&I.push({key:`${l.pcb_port_id}-${B}`,startPoint:h,endPoint:E,isInNet:Q})}),I},[A,n,o,i]);return!A||!i?e:(t||(t=xa()),W.jsxs("div",{style:{position:"relative"},children:[e,W.jsx("svg",{style:{position:"absolute",left:0,top:0,width:"100%",height:"100%",pointerEvents:"none",opacity:.5,zIndex:kc.ratsNestOverlay},children:s.map(({key:r,startPoint:a,endPoint:g,isInNet:c})=>{const I=Ce(t,a),l=Ce(t,g);return W.jsx("line",{x1:I.x,y1:I.y,x2:l.x,y2:l.y,stroke:"white",strokeWidth:"1",strokeDasharray:c?"6,6":void 0},r)})})]}))},Lti={version:"1.11.353"},Pk=(t,A,e)=>{const i=gl(s=>s.is_mouse_over_container),n=V.useRef(i),o=V.useRef(A);V.useEffect(()=>{n.current=i},[i]),V.useEffect(()=>{o.current=A},[A]),V.useEffect(()=>{if(!t)return;const s=r=>{const a=r.target;if(a.tagName==="INPUT"||a.tagName==="TEXTAREA"||a.isContentEditable)return;const g=t.split("+"),c=g.includes("ctrl"),I=g.includes("shift"),l=g.includes("alt"),B=g.includes("meta"),C=g[g.length-1],Q=e?.current?e.current.contains(document.activeElement)||document.activeElement===e.current:!1;(n.current||Q)&&(!c||r.ctrlKey)&&(!I||r.shiftKey)&&(!l||r.altKey)&&(!B||r.metaKey)&&r.key.toLowerCase()===C.toLowerCase()&&(r.preventDefault(),o.current())};return window.addEventListener("keydown",s),()=>{window.removeEventListener("keydown",s)}},[t])},Uti=()=>{const[t,A]=V.useState(!1);return V.useEffect(()=>{const e=()=>{A(window.innerWidth<=768)};return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]),t},OT=(t,A={stopPropagation:!0})=>{const e=V.useRef(0),i=V.useCallback(s=>{A.stopPropagation&&s.stopPropagation();const r=Date.now();r-e.current<300||(e.current=r,t?.(s))},[t,A.stopPropagation]),n=V.useCallback(s=>{s.preventDefault(),i(s)},[i]);return{onClick:i,onTouchEnd:n,style:{touchAction:"manipulation"}}},Hti=({name:t,selected:A,onClick:e})=>{const{style:i,...n}=OT(e);return W.jsxs("div",{className:m2`
5475
+ `,uti=({children:t,transform:A=xa(),elements:e})=>{const i=V.useRef(null),{isShowingDRCErrors:n,hoveredErrorId:o}=gl(g=>({isShowingDRCErrors:g.is_showing_drc_errors,hoveredErrorId:g.hovered_error_id}));if(!e)return W.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)}),W.jsxs("div",{style:{position:"relative"},ref:i,children:[t,s.map((g,c)=>{const{pcb_port_ids:I,pcb_trace_id:l}=g,B=I?.[0]?a.get(I[0]):void 0,C=I?.[1]?a.get(I[1]):void 0,Q=e?rx(e).pcb_trace.get(l):void 0,h=g.pcb_trace_error_id||`error_${c}_${g.error_type}_${g.message?.slice(0,20)}`,E=o===h;if(B&&C){const u=Ce(A,{x:B.x,y:B.y}),d=Ce(A,{x:C.x,y:C.y});if(!n)return null;const f=!(isNaN(u.x)||isNaN(u.y)||isNaN(d.x)||isNaN(d.y)),y={x:(u.x+d.x)/2,y:(u.y+d.y)/2};if(isNaN(y.x)||isNaN(y.y))return null;const w=fmA(y,i);return W.jsxs(V.Fragment,{children:[W.jsx(hti,{screenPort1:u,screenPort2:d,errorCenter:y,canLineBeDrawn:f,isHighlighted:E}),W.jsx("div",{style:{position:"absolute",left:y.x-15,top:y.y-15,width:30,height:30,zIndex:kc.errorOverlay+5,cursor:"pointer",borderRadius:"50%"},onMouseEnter:D=>{const S=D.currentTarget.nextElementSibling;if(S){const _=S.querySelector(".error-message");_&&(_.style.opacity="1")}},onMouseLeave:D=>{if(!E){const S=D.currentTarget.nextElementSibling;if(S){const _=S.querySelector(".error-message");_&&(_.style.opacity="0")}}}}),W.jsx("div",{style:{position:"absolute",zIndex:E?200:100,left:w.left,top:w.top,color:E?"#ff4444":"red",textAlign:"center",fontFamily:"sans-serif",fontSize:12,display:n||E?"flex":"none",flexDirection:"column",alignItems:"center",pointerEvents:"none",transform:w.transform},children:W.jsx("div",{className:`error-message ${ymA}`,style:{opacity:E?1:0,border:`1px solid ${E?"#ff4444":"red"}`},children:g.message})})]},h)}if(Q?.route&&(n||E)){const u=Q.route.map(w=>Ce(A,{x:w.x,y:w.y}));if(u.some(w=>isNaN(w.x)||isNaN(w.y)))return null;const d=Math.floor(u.length/2),f=u[d],y=fmA(f,i);return W.jsxs(V.Fragment,{children:[W.jsx(Eti,{points:u,errorCenter:f,isHighlighted:E}),W.jsx("div",{style:{position:"absolute",left:f.x-15,top:f.y-15,width:30,height:30,zIndex:kc.errorOverlay+5,cursor:"pointer",borderRadius:"50%"},onMouseEnter:w=>{const D=w.currentTarget.nextElementSibling;if(D){const S=D.querySelector(".error-message");S&&(S.style.opacity="1")}},onMouseLeave:w=>{if(!E){const D=w.currentTarget.nextElementSibling;if(D){const S=D.querySelector(".error-message");S&&(S.style.opacity="0")}}}}),W.jsx("div",{style:{position:"absolute",zIndex:E?kc.errorOverlay+10:kc.errorOverlay+1,left:y.left,top:y.top,color:E?"#ff4444":"red",textAlign:"center",fontFamily:"sans-serif",fontSize:12,display:"flex",flexDirection:"column",alignItems:"center",pointerEvents:"none",transform:y.transform},children:W.jsx("div",{className:`error-message ${ymA}`,style:{opacity:E?1:0,border:`1px solid ${E?"#ff4444":"red"}`},children:g.message})})]},h)}return null}),r.map((g,c)=>{const I=g.component_name||g.message?.match(/name "([^"]+)"/)?.[1];if(!I)return null;const l=e?.filter(Q=>Q.type==="source_component"&&Q.name===I||Q.type==="pcb_component"&&e?.find(h=>h.type==="source_component"&&h.source_component_id===Q.source_component_id&&h.name===I))||[],B=g.pcb_trace_error_id||`error_${c}_${g.error_type}_${g.message?.slice(0,20)}`,C=o===B;return!C&&!n?null:l.map((Q,h)=>{let E={x:0,y:0};if(Q.type==="pcb_component")E=Q.center||{x:0,y:0};else if(Q.type==="source_component"){const _=e?.find(b=>b.type==="pcb_component"&&b.source_component_id===Q.source_component_id);_&&_.type==="pcb_component"&&(E=_.center||{x:0,y:0})}const u=Ce(A,E);if(isNaN(u.x)||isNaN(u.y))return null;const d=Math.abs(A.a),D=Math.max(8,Math.min(30,.5*d)),S=fmA(u,i);return W.jsxs(V.Fragment,{children:[W.jsx("svg",{style:{position:"absolute",left:0,top:0,pointerEvents:"none",mixBlendMode:"difference",zIndex:kc.errorOverlay},width:"100%",height:"100%",children:C?W.jsx("polygon",{points:`${u.x},${u.y-D*1.25} ${u.x+D},${u.y} ${u.x},${u.y+D*1.25} ${u.x-D},${u.y}`,fill:"#ff4444"}):W.jsx("circle",{cx:u.x,cy:u.y,r:D,fill:"none",stroke:C?"#ff4444":"red",strokeWidth:C?Math.max(2,D*.15):Math.max(1,D*.1),opacity:1})}),W.jsx("div",{style:{position:"absolute",left:u.x-(D+10),top:u.y-(D+10),width:(D+10)*2,height:(D+10)*2,zIndex:kc.errorOverlay+5,cursor:"pointer",borderRadius:"50%"},onMouseEnter:_=>{const b=_.currentTarget.nextElementSibling;if(b){const N=b.querySelector(".error-message");N&&(N.style.opacity="1")}},onMouseLeave:_=>{if(!C){const b=_.currentTarget.nextElementSibling;if(b){const N=b.querySelector(".error-message");N&&(N.style.opacity="0")}}}}),W.jsx("div",{style:{position:"absolute",zIndex:C?kc.errorOverlay+20:kc.errorOverlay+10,left:S.left,top:S.top,color:C?"#ff4444":"red",textAlign:"center",fontFamily:"sans-serif",fontSize:12,display:n||C?"flex":"none",flexDirection:"column",alignItems:"center",pointerEvents:"none",transform:S.transform},children:W.jsx("div",{className:`error-message ${ymA}`,style:{opacity:C?1:0,border:`1px solid ${C?"#ff4444":"red"}`},children:g.message})})]},`${B}_${h}`)})})]})};function dti(t,A){return t.size!==A.size?!1:Array.from(t).every(e=>A.has(e))}function pti({primitiveElement:t,elements:A}){let e=t.trace_length?`${t.trace_length.toFixed(3)}`:"";const i=rx(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 n=t.trace_length&&i?.max_length&&t.trace_length>i.max_length;return{text:e,isOverLength:n}}function fti(t){const{primitives:A,is_showing_multiple_traces_length:e,elements:i}=t,n=A.filter(a=>a._element.type==="pcb_trace"),o=i.filter(a=>a.type==="source_trace"),s=A.filter(a=>a._element.type!=="pcb_trace"),r=n.filter(a=>o.some(g=>a._element.type==="pcb_trace"&&a._element.source_trace_id===g.source_trace_id&&g.max_length!==void 0));if(!e)return[...s,...r];if(n.length>1){const a=n.reduce((g,c)=>{const I=g._element.trace_length;return c._element.trace_length<I?c:g},n[0]);return[...s,a]}return A}var yti={position:"absolute",left:0,top:0,pointerEvents:"none",color:"red",fontFamily:"sans-serif",fontSize:12,textShadow:"0 0 2px black"},mti=t=>{const{_element:A,_parent_pcb_component:e,_parent_source_component:i,_source_port:n}=t;switch(A.type){case"pcb_trace":return A.trace_length?`${A.trace_length.toFixed(3)}`:"";case"pcb_smtpad":case"pcb_plated_hole":{const o=[],s=Array.from(new Set((A.port_hints??[]).concat(n?.port_hints??[]))).filter(a=>!/^[0-9]+$/.test(a)).filter(a=>!a.includes("unnamed_")).sort((a,g)=>g.localeCompare(a)),r=i&&"name"in i&&i.name&&!i.name.includes("unnamed_")?i.name:null;return s.length>0?r?o.push(...s.map(a=>`${r}.${a}`)):o.push(...s):r&&o.push(r),o.join(", ")}default:return""}},wti={top:"red",bottom:"aqua"},Dti=({primitive:t,mousePos:A,elements:e})=>{const[i,n]=V.useState(!1),o=t._element;V.useEffect(()=>{setTimeout(()=>{n(!0)},100)},[]);const[s,r,a,g]=[t.screen_x,t.screen_y,t.screen_w,t.screen_h],c=t.same_space_index??0,I=26,l=wti[t?._element?.layer]??"red";let B=0;if(o.type==="pcb_smtpad"&&o?.shape==="rotated_rect"?B=o?.ccw_rotation??0:(o.type==="pcb_smtpad"&&(o?.shape==="pill"||o?.shape==="rotated_pill")&&"ccw_rotation"in t||o.type==="pcb_plated_hole"&&(o?.shape==="pill"||o?.shape==="oval")&&"ccw_rotation"in t)&&(B=o.ccw_rotation??0),o.type==="pcb_trace"){const h=pti({primitiveElement:o,elements:e});if(!h)return null;const E=A.y-35;return W.jsx("div",{style:{zIndex:kc.elementOverlay,position:"absolute",left:A.x,top:E,color:l,pointerEvents:"none",transform:"translateX(-50%)"},children:W.jsx("div",{style:{backgroundColor:"#f2efcc",color:h.isOverLength?"red":"black",textShadow:"none",WebkitFontSmoothing:"antialiased",MozOsxFontSmoothing:"grayscale",padding:"6px 6px",borderRadius:"6px",fontSize:"14px",minWidth:"45px",textAlign:"center",whiteSpace:"nowrap"},children:h.text})})}const C=mti(t);return C.trim().length===0?null:W.jsx("div",{style:{zIndex:kc.elementOverlay,position:"absolute",left:s-a/2-8,top:r-g/2-8,width:a+16,height:g+16,color:l,transform:`rotate(${-B}deg)`,transformOrigin:"center center"},children:W.jsx("div",{style:{width:i?`calc(100% + ${I*2*c}px)`:"100%",height:i?`calc(100% + ${I*2*c}px)`:"100%",marginLeft:i?`${-I*c}px`:0,marginTop:i?`${-I*c}px`:0,border:`1px solid ${l}`,opacity:i||c===0?1:0,transition:"width 0.2s, height 0.2s, margin-left 0.2s, margin-top 0.2s, opacity 0.2s"},children:W.jsx("div",{style:{position:"absolute",bottom:g+20+I*c,marginRight:i?`${-I*c}px`:0,marginBottom:i?0:-I*c,transition:"margin-right 0.2s, margin-bottom 0.2s",backgroundColor:"#f2efcc",color:"black",textShadow:"none",WebkitFontSmoothing:"antialiased",MozOsxFontSmoothing:"grayscale",padding:"6px 6px",borderRadius:"6px",fontSize:"14px",transform:`rotate(${B}deg)`,minWidth:"45px",textAlign:"center"},children:C})})})},Sti=({highlightedPrimitives:t,mousePos:A,elements:e})=>{const[i,n]=gl(r=>[r.is_moving_component,r.is_showing_multiple_traces_length]),o=t.some(r=>r._element.type==="pcb_smtpad")&&t.some(r=>r._element.type==="pcb_trace");let s=t;return o&&(s=s.filter(r=>r._element.type==="pcb_smtpad")),s=fti({primitives:s,is_showing_multiple_traces_length:n,elements:e}),W.jsx("div",{style:yti,children:!i&&s.map((r,a)=>W.jsx(Dti,{primitive:r,mousePos:A,elements:e},a))})},Tk=t=>t?.type==="pcb_component",sEe=t=>t?.type==="pcb_group",bti=t=>t?.type==="pcb_panel",mmA=t=>t?.type==="pcb_board",aI={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},ly={OFFSET_LINE:"white",COMPONENT_MARKER_FILL:"#66ccff",COMPONENT_MARKER_STROKE:"white",LABEL_TEXT:"white"},wmA=({targets:t,transform:A,containerWidth:e,containerHeight:i})=>{if(t.length===0)return null;const n={color:ly.LABEL_TEXT,mixBlendMode:"difference",pointerEvents:"none",fontSize:aI.LABEL_FONT_SIZE,fontFamily:"monospace",fontWeight:"bold"},o=new Map;return t.forEach(s=>{if(!o.has(s.anchor_id)){const r=Ce(A,s.anchor);o.set(s.anchor_id,r)}}),W.jsx("div",{style:{position:"absolute",left:0,top:0,width:e,height:i,overflow:"hidden",pointerEvents:"none",zIndex:kc.dimensionOverlay},children:W.jsxs("svg",{style:{position:"absolute",left:0,top:0,pointerEvents:"none"},width:e,height:i,children:[t.map(s=>{const r=s.anchor,a=s.anchor_id,g=s.target,c=o.get(a),I=Ce(A,g),l=g.x-r.x,B=g.y-r.y,C=Math.abs(I.x-c.x),Q=Math.abs(I.y-c.y),h=I.y<c.y,E=I.x>c.x,u=h?aI.LABEL_OFFSET_ABOVE:aI.LABEL_OFFSET_BELOW,d=E?aI.LABEL_OFFSET_RIGHT:aI.LABEL_OFFSET_LEFT,f=C>aI.MIN_LINE_LENGTH_FOR_LABEL,y=Q>aI.MIN_LINE_LENGTH_FOR_LABEL,w=`${s.display_offset_x??l.toFixed(2)}mm`,D=`${s.display_offset_y??B.toFixed(2)}mm`;return W.jsxs("g",{children:[W.jsx("line",{x1:c.x,y1:c.y,x2:I.x,y2:c.y,stroke:ly.OFFSET_LINE,strokeWidth:aI.LINE_STROKE_WIDTH,strokeDasharray:aI.LINE_DASH_PATTERN}),W.jsx("line",{x1:I.x,y1:c.y,x2:I.x,y2:I.y,stroke:ly.OFFSET_LINE,strokeWidth:aI.LINE_STROKE_WIDTH,strokeDasharray:aI.LINE_DASH_PATTERN}),s.type==="component"||s.type==="board"?W.jsx("circle",{cx:I.x,cy:I.y,r:aI.COMPONENT_MARKER_RADIUS,fill:ly.COMPONENT_MARKER_FILL,stroke:ly.COMPONENT_MARKER_STROKE,strokeWidth:1}):W.jsxs(W.Fragment,{children:[W.jsx("line",{x1:I.x-aI.ANCHOR_MARKER_SIZE,y1:I.y,x2:I.x+aI.ANCHOR_MARKER_SIZE,y2:I.y,stroke:ly.OFFSET_LINE,strokeWidth:aI.ANCHOR_MARKER_STROKE_WIDTH}),W.jsx("line",{x1:I.x,y1:I.y-aI.ANCHOR_MARKER_SIZE,x2:I.x,y2:I.y+aI.ANCHOR_MARKER_SIZE,stroke:ly.OFFSET_LINE,strokeWidth:aI.ANCHOR_MARKER_STROKE_WIDTH})]}),f&&W.jsx("foreignObject",{x:Math.min(c.x,I.x),y:c.y+u,width:Math.abs(I.x-c.x),height:20,style:{overflow:"visible"},children:W.jsx("div",{style:{...n,textAlign:"center"},children:w})}),y&&W.jsx("foreignObject",{x:I.x+d,y:Math.min(c.y,I.y),width:aI.Y_LABEL_MIN_WIDTH,height:Math.abs(I.y-c.y),style:{overflow:"visible"},children:W.jsx("div",{style:{...n,display:"flex",alignItems:"center",justifyContent:E?"flex-start":"flex-end",whiteSpace:"nowrap",padding:"0 4px",height:"100%"},children:D})})]},s.id)}),Array.from(o.entries()).map(([s,r])=>W.jsxs("g",{children:[W.jsx("line",{x1:r.x-aI.ANCHOR_MARKER_SIZE,y1:r.y,x2:r.x+aI.ANCHOR_MARKER_SIZE,y2:r.y,stroke:ly.OFFSET_LINE,strokeWidth:aI.ANCHOR_MARKER_STROKE_WIDTH}),W.jsx("line",{x1:r.x,y1:r.y-aI.ANCHOR_MARKER_SIZE,x2:r.x,y2:r.y+aI.ANCHOR_MARKER_SIZE,stroke:ly.OFFSET_LINE,strokeWidth:aI.ANCHOR_MARKER_STROKE_WIDTH})]},`anchor-${s}`))]})})},xti=({elements:t,highlightedPrimitives:A,transform:e,containerWidth:i,containerHeight:n})=>{const o=t.filter(E=>mmA(E)),s=t.filter(E=>Tk(E)),r=t.filter(E=>sEe(E)),a=A.map(E=>Tk(E._parent_pcb_component)?E._parent_pcb_component.pcb_component_id:Tk(E._element)?E._element.pcb_component_id:null).filter(E=>!!E),g=new Set;if(a.forEach(E=>{const u=s.find(d=>d.pcb_component_id===E);u?.pcb_group_id&&g.add(u.pcb_group_id)}),!gl(E=>E.is_showing_group_anchor_offsets)&&a.length===0)return null;const I=s.map(E=>{const u=E.positioned_relative_to_pcb_board_id;if(!u)return null;const d=o.find(f=>f.pcb_board_id===u);return d?{component:E,board:d,type:"component"}:null}).filter(E=>!!E),l=r.map(E=>{const u=E.positioned_relative_to_pcb_board_id;if(!u||!E.center)return null;const d=o.find(f=>f.pcb_board_id===u);return d?{group:E,board:d,type:"group"}:null}).filter(E=>!!E),B=[...I,...l];if(B.length===0)return null;const C=a.length===0,Q=B.filter(E=>E.type==="component"?C||a.includes(E.component.pcb_component_id):C||g.has(E.group.pcb_group_id));if(Q.length===0)return null;const h=Q.map(E=>E.type==="component"?{id:`${E.board.pcb_board_id}-${E.component.pcb_component_id}-${E.type}`,anchor:E.board.center,anchor_id:E.board.pcb_board_id,target:E.component.center,type:"component",display_offset_x:E.component.display_offset_x,display_offset_y:E.component.display_offset_y}:{id:`${E.board.pcb_board_id}-${E.group.pcb_group_id}-${E.type}`,anchor:E.board.center,anchor_id:E.board.pcb_board_id,target:{x:E.group.anchor_position?.x??E.group.center.x,y:E.group.anchor_position?.y??E.group.center.y},type:"group",display_offset_x:E.group.display_offset_x,display_offset_y:E.group.display_offset_y}).filter(E=>!!E);return W.jsx(wmA,{targets:h,transform:e,containerWidth:i,containerHeight:n})},_ti=({elements:t,highlightedPrimitives:A,transform:e,containerWidth:i,containerHeight:n})=>{const o=t.filter(E=>sEe(E)),s=t.filter(E=>Tk(E)),r=A.map(E=>Tk(E._parent_pcb_component)?E._parent_pcb_component.pcb_component_id:Tk(E._element)?E._element.pcb_component_id:null).filter(E=>!!E),a=(E,u)=>{if(u.has(E))return;u.add(E);const d=o.find(f=>f.pcb_group_id===E);d?.position_mode==="relative_to_group_anchor"&&d.positioned_relative_to_pcb_group_id&&a(d.positioned_relative_to_pcb_group_id,u)},g=new Set;if(r.forEach(E=>{const u=s.find(d=>d.pcb_component_id===E);u&&(u.position_mode==="relative_to_group_anchor"&&u.positioned_relative_to_pcb_group_id&&a(u.positioned_relative_to_pcb_group_id,g),u.pcb_group_id&&a(u.pcb_group_id,g))}),!gl(E=>E.is_showing_group_anchor_offsets)&&r.length===0)return null;const I=s.map(E=>{if(E.position_mode==="relative_to_group_anchor"&&E.positioned_relative_to_pcb_group_id){const u=o.find(d=>d.pcb_group_id===E.positioned_relative_to_pcb_group_id);return u&&u.anchor_position?{component:E,parentGroup:u,type:"component"}:null}if(E.pcb_group_id){const u=o.find(d=>d.pcb_group_id===E.pcb_group_id);return u&&u.anchor_position?{component:E,parentGroup:u,type:"component"}:null}return null}).filter(E=>!!E),l=o.map(E=>{if(E.position_mode==="relative_to_group_anchor"&&E.positioned_relative_to_pcb_group_id){const u=o.find(d=>d.pcb_group_id===E.positioned_relative_to_pcb_group_id);if(u&&u.anchor_position&&E.anchor_position)return{group:E,parentGroup:u,type:"group"}}return null}).filter(E=>!!E),B=[...I,...l];if(B.length===0)return null;const C=r.length===0,Q=B.filter(E=>E.type==="component"?C||r.includes(E.component.pcb_component_id):C||g.has(E.group.pcb_group_id)||g.has(E.parentGroup.pcb_group_id));if(Q.length===0)return null;const h=Q.map(E=>{const u=E.parentGroup.anchor_position;return u?E.type==="component"?E.component.center?{id:`${E.parentGroup.pcb_group_id}-${E.component.pcb_component_id}-${E.type}`,anchor:u,anchor_id:E.parentGroup.pcb_group_id,target:E.component.center,type:"component",display_offset_x:E.component.display_offset_x,display_offset_y:E.component.display_offset_y}:null:E.group.anchor_position?{id:`${E.parentGroup.pcb_group_id}-${E.group.pcb_group_id}-${E.type}`,anchor:u,anchor_id:E.parentGroup.pcb_group_id,target:E.group.anchor_position,type:"group",display_offset_x:E.group.display_offset_x,display_offset_y:E.group.display_offset_y}:null:null}).filter(E=>!!E);return W.jsx(wmA,{targets:h,transform:e,containerWidth:i,containerHeight:n})},kti=(t,A)=>{const e=t.pcb_component_id,i=A.filter(n=>(n.type==="pcb_smtpad"||n.type==="pcb_plated_hole")&&n.pcb_component_id===e||n.type==="pcb_hole"&&n.pcb_component_id===e);return i.length===0?dmA([t]):dmA(i)},vti=({elements:t,highlightedPrimitives:A,transform:e,containerWidth:i,containerHeight:n})=>{const o=new Map;for(const r of A)Tk(r._parent_pcb_component)&&o.set(r._parent_pcb_component.pcb_component_id,r._parent_pcb_component),Tk(r._element)&&o.set(r._element.pcb_component_id,r._element);if(o.size===0)return null;const s=[];for(const r of o.values()){const a=kti(r,t);if(!a)continue;const g=r.positioned_relative_to_pcb_group_id??r.pcb_group_id,c=g?rx(t).pcb_group.get(g):null;s.push({component:r,bbox:a,group:c})}return s.length===0?null:W.jsx("div",{style:{position:"absolute",left:0,top:0,width:i,height:n,overflow:"hidden",pointerEvents:"none",zIndex:kc.dimensionOverlay},children:W.jsx("svg",{style:{position:"absolute",left:0,top:0,pointerEvents:"none"},width:i,height:n,children:s.map(({component:r,bbox:a,group:g})=>{const c=Ce(e,{x:a.minX,y:a.maxY}),I=Ce(e,{x:a.maxX,y:a.minY}),l={x:Math.min(c.x,I.x),y:Math.min(c.y,I.y),width:Math.abs(I.x-c.x),height:Math.abs(I.y-c.y)},B=r.center??{x:(a.minX+a.maxX)/2,y:(a.minY+a.maxY)/2},C=Ce(e,B);return W.jsxs("g",{children:[W.jsx("rect",{x:l.x,y:l.y,width:l.width,height:l.height,fill:"none",stroke:"white",strokeWidth:1.5,strokeDasharray:"4,4"}),W.jsx("line",{x1:C.x-6,y1:C.y,x2:C.x+6,y2:C.y,stroke:ly.COMPONENT_MARKER_STROKE,strokeWidth:1.5}),W.jsx("line",{x1:C.x,y1:C.y-6,x2:C.x,y2:C.y+6,stroke:ly.COMPONENT_MARKER_STROKE,strokeWidth:1.5}),W.jsx("circle",{cx:C.x,cy:C.y,r:aI.COMPONENT_MARKER_RADIUS,fill:ly.COMPONENT_MARKER_FILL,stroke:ly.COMPONENT_MARKER_STROKE,strokeWidth:1})]},r.pcb_component_id)})})})},Fti=({elements:t,highlightedPrimitives:A,transform:e,containerWidth:i,containerHeight:n})=>{const o=t.filter(B=>bti(B)),s=t.filter(B=>mmA(B)),r=A.map(B=>mmA(B._element)?B._element.pcb_board_id:null).filter(B=>!!B);if(!gl(B=>B.is_showing_group_anchor_offsets)&&r.length===0)return null;const g=s.map(B=>{const C=B.pcb_panel_id,Q=B.position_mode;if(!C||Q!=="relative_to_panel_anchor")return null;const h=o.find(E=>E.pcb_panel_id===C);return h?{board:B,panel:h,type:"board"}:null}).filter(B=>!!B);if(g.length===0)return null;const c=r.length===0,I=g.filter(B=>c||r.includes(B.board.pcb_board_id));if(I.length===0)return null;const l=I.map(B=>B.board.center?{id:`${B.panel.pcb_panel_id}-${B.board.pcb_board_id}-${B.type}`,anchor:B.panel.center,anchor_id:B.panel.pcb_panel_id,target:B.board.center,type:"board",display_offset_x:B.board.display_offset_x,display_offset_y:B.board.display_offset_y}:null).filter(B=>!!B);return W.jsx(wmA,{targets:l,transform:e,containerWidth:i,containerHeight:n})},Nz=t=>{if(t.length===0)return null;let A=t[0].x,e=t[0].y,i=t[0].x,n=t[0].y;for(const o of t)o.x<A&&(A=o.x),o.y<e&&(e=o.y),o.x>i&&(i=o.x),o.y>n&&(n=o.y);return{center:{x:(A+i)/2,y:(e+n)/2},width:i-A,height:n-e}},rEe=(t,A)=>{if(A.length<3)return!1;let e=!1;for(let i=0,n=A.length-1;i<A.length;n=i++){const o=A[i].x,s=A[i].y,r=A[n].x,a=A[n].y;s>t.y!=a>t.y&&t.x<(r-o)*(t.y-s)/(a-s||Number.EPSILON)+o&&(e=!e)}return e},Mti=(t,A,e)=>{const i=[];for(const n of t){if(!n._element)continue;if("x1"in n&&n._element?.type==="pcb_trace"){const r=HE({x:A.x,y:A.y},{x:n.x1,y:n.y1},{x:n.x2,y:n.y2}),a=n.width||.5,g=Math.max(a*25,2)/e.a;r<g&&i.push(n);continue}if(n.pcb_drawing_type==="polygon"){const r=n.points.map(g=>({x:Et.parse(g.x),y:Et.parse(g.y)})),a=Nz(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;rEe(A,r)&&i.push(n);continue}if(n.pcb_drawing_type==="polygon_with_arcs"){const r=n.brep_shape.outer_ring.vertices.map(g=>({x:Et.parse(g.x),y:Et.parse(g.y)})),a=Nz(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;rEe(A,r)&&i.push(n);continue}if(!("x"in n&&"y"in n))continue;let o=0,s=0;if("w"in n&&"h"in n)o=n.w,s=n.h;else if("r"in n)o=n.r*2,s=n.r*2;else if("rX"in n&&"rY"in n)o=n.rX*2,s=n.rY*2;else continue;Math.abs(n.x-A.x)<o/2&&Math.abs(n.y-A.y)<s/2&&i.push(n)}return i},Rti=({elements:t,children:A,transform:e,primitives:i,onMouseHoverOverPrimitives:n})=>{const[o,s]=V.useState([]),[r,a]=V.useState({x:0,y:0}),[g,{width:c,height:I}]=KT(),l=V.useMemo(()=>{const C=[];for(const Q of o){if(Q._element?.type==="pcb_via"||Q._element?.type==="pcb_component"||Q?.layer==="drill")continue;let h=null,E=0,u=0;if(Q.pcb_drawing_type==="polygon"){const w=Nz(Q.points);if(!w)continue;h=w.center,E=w.width,u=w.height}else if(Q.pcb_drawing_type==="polygon_with_arcs"){const w=Q.brep_shape.outer_ring.vertices.map(S=>({x:S.x,y:S.y})),D=Nz(w);if(!D)continue;h=D.center,E=D.width,u=D.height}else"x"in Q&&"y"in Q&&(h={x:Q.x,y:Q.y},E="w"in Q?Q.w:"r"in Q?Q.r*2:"rX"in Q&&"rY"in Q?Q.rX*2:0,u="h"in Q?Q.h:"r"in Q?Q.r*2:"rX"in Q&&"rY"in Q?Q.rY*2:0);if(!h)continue;const d=Ce(e,h),f={w:E*e.a,h:u*e.a},y=C.filter(w=>d.x===w.screen_x&&d.y===w.screen_y&&f.w===w.screen_w&&f.h===w.screen_h).length;C.push({...Q,x:h.x,y:h.y,w:E,h:u,screen_x:d.x,screen_y:d.y,screen_w:f.w,screen_h:f.h,same_space_index:y})}return C},[o,e]),B=(C,Q,h,E)=>{a({x:C,y:Q});const u=Ce(tm(h),{x:C,y:Q}),d=Mti(E,u,h);dti(new Set(d.map(f=>f._pcb_drawing_object_id)),new Set(o.map(f=>f._pcb_drawing_object_id)))||(s(d),n(d))};return W.jsxs("div",{ref:g,style:{position:"relative",width:"100%",height:"100%"},onMouseMove:C=>{if(e){const Q=C.currentTarget.getBoundingClientRect(),h=C.clientX-Q.left,E=C.clientY-Q.top;B(h,E,e,i)}},onTouchStart:C=>{if(e){const Q=C.touches[0],h=C.currentTarget.getBoundingClientRect(),E=Q.clientX-h.left,u=Q.clientY-h.top;B(E,u,e,i)}},children:[A,W.jsx(Sti,{elements:t,mousePos:r,highlightedPrimitives:l}),e&&W.jsxs(W.Fragment,{children:[W.jsx(xti,{elements:t,highlightedPrimitives:l,transform:e,containerWidth:c,containerHeight:I}),W.jsx(_ti,{elements:t,highlightedPrimitives:l,transform:e,containerWidth:c,containerHeight:I}),W.jsx(vti,{elements:t,highlightedPrimitives:l,transform:e,containerWidth:c,containerHeight:I}),W.jsx(Fti,{elements:t,highlightedPrimitives:l,transform:e,containerWidth:c,containerHeight:I})]})]})},aEe=["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)"],Nti=({children:t,transform:A=xa(),elements:e=[],hoveredComponentIds:i=[]})=>{const[n,{width:o,height:s}]=KT(),r=V.useRef(null),{is_showing_pcb_groups:a,pcb_group_view_mode:g,is_showing_group_anchor_offsets:c}=gl(I=>({is_showing_pcb_groups:I.is_showing_pcb_groups,pcb_group_view_mode:I.pcb_group_view_mode,is_showing_group_anchor_offsets:I.is_showing_group_anchor_offsets}));return V.useEffect(()=>{const I=r.current;if(!I||!o||!s)return;I.width=o,I.height=s;const l=I.getContext("2d");if(!l||(l.clearRect(0,0,o,s),!a))return;const B=e.filter(w=>w.type==="pcb_group"),C=e.filter(w=>w.type==="pcb_component"),Q=e.filter(w=>w.type==="source_group"),h=new Map(Q.map(w=>[w.source_group_id,w])),E=B.filter(w=>{if(w.name?.toLowerCase().includes("subpanel"))return!1;if(g==="all")return!0;if(!w.source_group_id)return!1;const D=h.get(w.source_group_id);return D?D.was_automatically_named!==!0:!1}),u=new Map;Q.forEach(w=>{const D=w;if(D.parent_source_group_id){const S=u.get(D.parent_source_group_id)||[];S.push(w.source_group_id),u.set(D.parent_source_group_id,S)}});const d=w=>{const D=[],S=u.get(w)||[];for(const _ of S)D.push(_),D.push(...d(_));return D},f=w=>{const D=Q.find(S=>S.source_group_id===w);return D?.parent_source_group_id?1+f(D.parent_source_group_id):0},y=new Set;if(i.length>0)for(const w of C){if(!i.includes(w.pcb_component_id))continue;const D=w.positioned_relative_to_pcb_group_id??w.pcb_group_id;D&&y.add(D)}E.forEach((w,D)=>{let S=C.filter(JA=>JA.pcb_group_id===w.pcb_group_id);if(w.source_group_id){const JA=d(w.source_group_id),OA=B.filter(vA=>vA.source_group_id&&JA.includes(vA.source_group_id));for(const vA of OA){const wA=C.filter(RA=>RA.pcb_group_id===vA.pcb_group_id);S=[...S,...wA]}}let _,b,N,F,L=!1;if(w.center&&w.width&&w.height){L=!0;const JA=w.width/2,OA=w.height/2;_=w.center.x-JA,N=w.center.x+JA,b=w.center.y-OA,F=w.center.y+OA}else if(S.length===0||(_=1/0,b=1/0,N=-1/0,F=-1/0,S.forEach(JA=>{if(JA.center&&typeof JA.width=="number"&&typeof JA.height=="number"){const OA=JA.center.x-JA.width/2,vA=JA.center.x+JA.width/2,wA=JA.center.y+JA.height/2,RA=JA.center.y-JA.height/2;_=Math.min(_,OA),N=Math.max(N,vA),b=Math.min(b,RA),F=Math.max(F,wA)}}),_===1/0||N===-1/0))return;const Y=w.source_group_id?f(w.source_group_id):0,J=w.source_group_id?d(w.source_group_id).length>0:!1;if(!L){const vA=1+(J?.5:0);_-=vA,N+=vA,b-=vA,F+=vA}const O=Ce(A,{x:_,y:F}),Z=Ce(A,{x:N,y:F}),X=Ce(A,{x:_,y:b}),eA=Ce(A,{x:N,y:b}),gA=aEe[D%aEe.length];l.strokeStyle=gA,l.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))),aA=tA*(J?1.3:1),EA=iA;l.setLineDash([aA,EA]),l.beginPath(),l.moveTo(O.x,O.y),l.lineTo(Z.x,Z.y),l.lineTo(eA.x,eA.y),l.lineTo(X.x,X.y),l.closePath(),l.stroke();const bA=Math.max(8,Math.min(12,10*Math.abs(A.a))),_A=Y==0||Y==1?0:Y*.11,LA=bA*(1-_A),QA=4,kA=w.name||`Group ${D+1}`;l.font=`${LA}px sans-serif`,l.setLineDash([]);const qA=l.measureText(kA).width+QA*2,VA=LA+QA*2,ce=O.x-5,fA=O.y-5,ge=3;if(l.fillStyle="rgba(0, 0, 0, 0.8)",l.beginPath(),l.roundRect(ce,fA-VA,qA,VA,ge),l.fill(),l.fillStyle=gA,l.textAlign="left",l.textBaseline="middle",l.fillText(kA,ce+QA,fA-VA/2),c&&y.has(w.pcb_group_id)&&!!w.anchor_position&&w.anchor_position){const JA=Array.isArray(w.anchor_position)?{x:w.anchor_position[0]??0,y:w.anchor_position[1]??0}:{x:w.anchor_position.x,y:w.anchor_position.y},OA=Ce(A,JA);l.strokeStyle="white",l.lineWidth=1.5,l.setLineDash([]);const vA=Math.max(4,Math.min(8,6*Math.abs(A.a)));l.beginPath(),l.moveTo(OA.x-vA,OA.y),l.lineTo(OA.x+vA,OA.y),l.stroke(),l.beginPath(),l.moveTo(OA.x,OA.y-vA),l.lineTo(OA.x,OA.y+vA),l.stroke()}})},[e,A,o,s,a,g,c,i]),W.jsxs("div",{ref:n,style:{position:"relative",width:"100%",height:"100%"},children:[t,W.jsx("canvas",{ref:r,style:{position:"absolute",top:0,left:0,pointerEvents:"none",zIndex:kc.pcbGroupOverlay,display:a?"block":"none"}})]})},Gti=({transform:t,soup:A,children:e})=>{const i=gl(r=>r.is_showing_rats_nest),{netMap:n,idToNetMap:o}=V.useMemo(()=>Hhe(A||[]),[A]),s=V.useMemo(()=>{if(!A||!i)return[];const r=l=>{const B=rx(A)[l.replace(/_\d+$/,"")].get(l);return B&&"x"in B&&"y"in B?{x:B.x,y:B.y}:null},a=(l,B)=>{const C=n[B]||[];let Q=null,h=1/0;return C.forEach(E=>{const u=r(E);if(u){const d=Math.sqrt((l.x-u.x)**2+(l.y-u.y)**2);d<h&&d>0&&(h=d,Q=u)}}),Q},g=rx(A).pcb_port.list(),c=rx(A).source_trace.list(),I=[];return g.forEach((l,B)=>{const C=o[l.pcb_port_id];let Q=!1;for(const u of c)u.connected_source_port_ids.includes(l.source_port_id)&&u.connected_source_net_ids.length>0&&(Q=!0);if(!C)return;const h={x:l.x,y:l.y},E=a(h,C);E&&I.push({key:`${l.pcb_port_id}-${B}`,startPoint:h,endPoint:E,isInNet:Q})}),I},[A,n,o,i]);return!A||!i?e:(t||(t=xa()),W.jsxs("div",{style:{position:"relative"},children:[e,W.jsx("svg",{style:{position:"absolute",left:0,top:0,width:"100%",height:"100%",pointerEvents:"none",opacity:.5,zIndex:kc.ratsNestOverlay},children:s.map(({key:r,startPoint:a,endPoint:g,isInNet:c})=>{const I=Ce(t,a),l=Ce(t,g);return W.jsx("line",{x1:I.x,y1:I.y,x2:l.x,y2:l.y,stroke:"white",strokeWidth:"1",strokeDasharray:c?"6,6":void 0},r)})})]}))},Lti={version:"1.11.354"},Pk=(t,A,e)=>{const i=gl(s=>s.is_mouse_over_container),n=V.useRef(i),o=V.useRef(A);V.useEffect(()=>{n.current=i},[i]),V.useEffect(()=>{o.current=A},[A]),V.useEffect(()=>{if(!t)return;const s=r=>{const a=r.target;if(a.tagName==="INPUT"||a.tagName==="TEXTAREA"||a.isContentEditable)return;const g=t.split("+"),c=g.includes("ctrl"),I=g.includes("shift"),l=g.includes("alt"),B=g.includes("meta"),C=g[g.length-1],Q=e?.current?e.current.contains(document.activeElement)||document.activeElement===e.current:!1;(n.current||Q)&&(!c||r.ctrlKey)&&(!I||r.shiftKey)&&(!l||r.altKey)&&(!B||r.metaKey)&&r.key.toLowerCase()===C.toLowerCase()&&(r.preventDefault(),o.current())};return window.addEventListener("keydown",s),()=>{window.removeEventListener("keydown",s)}},[t])},Uti=()=>{const[t,A]=V.useState(!1);return V.useEffect(()=>{const e=()=>{A(window.innerWidth<=768)};return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]),t},OT=(t,A={stopPropagation:!0})=>{const e=V.useRef(0),i=V.useCallback(s=>{A.stopPropagation&&s.stopPropagation();const r=Date.now();r-e.current<300||(e.current=r,t?.(s))},[t,A.stopPropagation]),n=V.useCallback(s=>{s.preventDefault(),i(s)},[i]);return{onClick:i,onTouchEnd:n,style:{touchAction:"manipulation"}}},Hti=({name:t,selected:A,onClick:e})=>{const{style:i,...n}=OT(e);return W.jsxs("div",{className:m2`
5476
5476
  margin-top: 2px;
5477
5477
  padding: 4px;
5478
5478
  padding-left: 8px;
@@ -5689,7 +5689,7 @@ test("${g} should solve problem correctly", () => {
5689
5689
  // Add more specific assertions based on expected output
5690
5690
  // expect(solver.netLabelPlacementSolver!.netLabelPlacements).toMatchInlineSnapshot()
5691
5691
  })
5692
- `,I=new Blob([c],{type:"text/plain"}),l=URL.createObjectURL(I),B=document.createElement("a");B.href=l,B.download=`${g}.test.ts`,B.click(),URL.revokeObjectURL(l)}catch(a){alert(`Error generating test.ts for ${t.constructor.name}: ${a instanceof Error?a.message:String(a)}`)}i(!1)};return W.jsxs("div",{className:`relative ${A}`,ref:n,children:[W.jsx("button",{className:"px-2 py-1 rounded text-xs cursor-pointer",onClick:()=>i(!e),title:`Download options for ${t.constructor.name}`,children:t.constructor.name}),e&&W.jsxs("div",{className:"absolute top-full left-0 mt-1 bg-white border border-gray-300 rounded shadow-lg z-10 min-w-[150px]",children:[W.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:o,children:"Download JSON"}),W.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:s,children:"Download page.tsx"}),W.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:r,children:"Download test.ts"})]})]})},EEe=t=>t.activeSubSolver?[t,...EEe(t.activeSubSolver)]:[t],lni=({solver:t})=>{const A=EEe(t);return W.jsx("div",{className:"flex gap-1 items-center text-sm pt-1",children:A.map((e,i)=>W.jsxs("div",{className:"flex items-center",children:[i>0&&W.jsx("span",{className:"text-gray-400 mx-1",children:"→"}),W.jsx(Ini,{solver:e})]},e.constructor.name))})},Bni=({solver:t,triggerRender:A,animationSpeed:e=25,onSolverStarted:i,onSolverCompleted:n})=>{const[o,s]=V.useReducer(Q=>!Q,!1),r=V.useRef(void 0),a=()=>{!t.solved&&!t.failed&&(t.step(),A())},g=()=>{!t.solved&&!t.failed&&(i&&i(t),t.solve(),A(),n&&n(t))},c=()=>{o?(r.current&&(clearInterval(r.current),r.current=void 0),s()):(s(),r.current=setInterval(()=>{if(t.solved||t.failed){r.current&&(clearInterval(r.current),r.current=void 0),s(),A(),n&&t.solved&&n(t);return}t.step(),A()},e))},I=()=>{const Q=t;if(Q.getCurrentPhase&&!t.solved&&!t.failed){const h=Q.getCurrentPhase();for(;Q.getCurrentPhase()===h&&!t.solved&&!t.failed;)t.step();A()}},l=()=>{if(t.solved||t.failed||o)return;const Q=window.prompt("Step until which iteration?",`${t.iterations}`);if(Q===null)return;const h=Number(Q);if(!Number.isFinite(h)){window.alert("Please enter a valid number for the iteration");return}for(;t.iterations<h&&!t.solved&&!t.failed;)t.step();A(),t.solved&&n&&n(t)};V.useEffect(()=>()=>{r.current&&clearInterval(r.current)},[]),V.useEffect(()=>{(t.solved||t.failed)&&o&&(r.current&&(clearInterval(r.current),r.current=void 0),s())},[t.solved,t.failed,o]);const B=t.getCurrentPhase!==void 0,C=B?t.getCurrentPhase():null;return W.jsxs("div",{className:"space-y-2 p-2 border-b",children:[W.jsx("div",{className:"flex items-center",children:W.jsx(lni,{solver:t})}),W.jsxs("div",{className:"flex gap-2 items-center flex-wrap",children:[W.jsx("button",{onClick:a,disabled:t.solved||t.failed||o,className:"bg-blue-500 hover:bg-blue-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Step"}),W.jsx("button",{onClick:g,disabled:t.solved||t.failed||o,className:"bg-green-500 hover:bg-green-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Solve"}),W.jsx("button",{onClick:c,disabled:t.solved||t.failed,className:`px-3 py-1 rounded text-white text-sm ${o?"bg-red-500 hover:bg-red-600":"bg-yellow-500 hover:bg-yellow-600"} disabled:bg-gray-300`,children:o?"Stop":"Animate"}),W.jsx("button",{onClick:l,disabled:t.solved||t.failed||o,className:"bg-orange-500 hover:bg-orange-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Step Until Iteration"}),B&&W.jsx("button",{onClick:I,disabled:t.solved||t.failed||o,className:"bg-purple-500 hover:bg-purple-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Next Stage"}),W.jsxs("div",{className:"text-sm text-gray-600",children:["Iterations: ",t.iterations]}),t.timeToSolve!==void 0&&W.jsxs("div",{className:"text-sm text-gray-600",children:["Time: ",(t.timeToSolve/1e3).toFixed(3),"s"]}),C&&W.jsxs("div",{className:"text-sm text-gray-600",children:["Phase: ",W.jsx("span",{className:"font-medium",children:C})]}),t.solved&&W.jsx("div",{className:"px-2 py-1 bg-green-100 text-green-800 rounded text-sm",children:"Solved"}),t.failed&&W.jsx("div",{className:"px-2 py-1 bg-red-100 text-red-800 rounded text-sm",children:"Failed"})]}),t.error&&W.jsxs("div",{className:"text-red-600 text-sm",children:["Error: ",t.error]})]})},Cni=(t,A,e)=>{const i=t.currentPipelineStepIndex;return A<i?"Completed":A===i&&t.activeSubSolver?t.activeSubSolver.failed?"Failed":"In Progress":"Not Started"},Qni=(t,A)=>{const i=t.pipelineDef[A].solverName,n=Cni(t,A),o=t[i],s=t.firstIterationOfPhase?.[i]??null,r=t.iterations;let a=0;if(n==="Completed"){const l=t.pipelineDef[A+1],B=l?t.firstIterationOfPhase?.[l.solverName]:void 0;B!==void 0&&s!==null?a=B-s:s!==null&&(a=r-s)}else n==="In Progress"&&s!==null&&(a=r-s);const g=t.timeSpentOnPhase?.[i]??0;let c=0;n==="Completed"?c=1:n==="In Progress"&&o&&(c=o.progress??0);const I=o?.stats??null;return{index:A,name:i,status:n,firstIteration:s,iterations:a,progress:c,timeSpent:g,stats:I&&Object.keys(I).length>0?I:null,solverInstance:o??null}},hni=({status:t})=>{const A={"Not Started":"text-blue-600","In Progress":"text-yellow-600",Completed:"text-green-600",Failed:"text-red-600"};return W.jsx("span",{className:`font-medium ${A[t]}`,children:t})},Eni=({progress:t})=>{if(t===0)return null;const A=Math.round(t*100);return W.jsxs("div",{className:"flex items-center gap-2",children:[W.jsx("div",{className:"w-20 h-2 bg-gray-200 rounded overflow-hidden",children:W.jsx("div",{className:"h-full bg-blue-500 transition-all duration-200",style:{width:`${A}%`}})}),W.jsxs("span",{className:"text-xs text-gray-500",children:[A,"%"]})]})},uni=t=>Object.entries(t).map(([A,e])=>`${A}: ${e}`).join(", "),dni=({stats:t})=>{if(!t||Object.keys(t).length===0)return W.jsx("span",{children:"-"});const A=Object.entries(t),e=uni(t);return W.jsxs("details",{className:"cursor-pointer",children:[W.jsx("summary",{className:"whitespace-nowrap overflow-hidden text-ellipsis max-w-[200px]",children:e}),W.jsx("div",{className:"mt-1 text-xs",children:A.map(([i,n])=>W.jsxs("div",{children:[i,": ",String(n)]},i))})]})},FmA=t=>{if(t===null||typeof t!="object")return t;if(Array.isArray(t))return t.map(FmA);const A={};for(const[e,i]of Object.entries(t))e.startsWith("_")||(A[e]=FmA(i));return A},pni=(t,A)=>{try{if(typeof t.getConstructorParams!="function"){alert(`getConstructorParams() is not implemented for ${A}`);return}const e=FmA(t.getConstructorParams()),i=new Blob([JSON.stringify(e,null,2)],{type:"application/json"}),n=URL.createObjectURL(i),o=document.createElement("a");o.href=n,o.download=`${A}_input.json`,o.click(),URL.revokeObjectURL(n)}catch(e){alert(`Error downloading input for ${A}: ${e instanceof Error?e.message:String(e)}`)}},fni=({solver:t,onStepUntilPhase:A,onDownloadInput:e})=>{const i=t.pipelineDef.map((r,a)=>Qni(t,a)),n=r=>{A?.(r)},o=r=>{r.solverInstance&&(e?e(r.solverInstance,r.name):pni(r.solverInstance,r.name))},s=r=>`${(r/1e3).toFixed(2)}s`;return W.jsxs("div",{className:"border-t border-gray-200",children:[W.jsx("div",{className:"px-4 py-2 bg-gray-50 border-b border-gray-200",children:W.jsx("h3",{className:"text-sm font-semibold text-gray-700",children:"Pipeline Steps"})}),W.jsx("div",{className:"overflow-x-auto",children:W.jsxs("table",{className:"w-full text-sm",children:[W.jsx("thead",{children:W.jsxs("tr",{className:"bg-gray-50 border-b border-gray-200",children:[W.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Step"}),W.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Status"}),W.jsxs("th",{className:"px-4 py-2 text-center font-semibold text-gray-700",children:["i",W.jsx("sub",{children:"0"})]}),W.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Iterations"}),W.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Progress"}),W.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Time"}),W.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Stats"}),W.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Input"})]})}),W.jsx("tbody",{children:i.map(r=>W.jsxs("tr",{className:`border-b border-gray-100 ${r.status==="In Progress"?"bg-yellow-50":""}`,children:[W.jsx("td",{className:"px-4 py-2",children:W.jsxs("div",{className:"flex items-center gap-2",children:[W.jsx("span",{className:"text-gray-400 w-6",children:String(r.index+1).padStart(2,"0")}),W.jsx("button",{onClick:()=>n(r.name),disabled:r.status==="Completed"||t.solved||t.failed,className:"text-blue-500 hover:text-blue-700 disabled:text-gray-300 disabled:cursor-not-allowed",title:`Step until ${r.name} completes`,children:W.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:W.jsx("path",{fillRule:"evenodd",d:"M4.5 5.653c0-1.426 1.529-2.33 2.779-1.643l11.54 6.348c1.295.712 1.295 2.573 0 3.285L7.28 19.991c-1.25.687-2.779-.217-2.779-1.643V5.653z",clipRule:"evenodd"})})}),W.jsx("span",{className:"font-medium text-gray-900",children:r.name})]})}),W.jsx("td",{className:"px-4 py-2",children:W.jsx(hni,{status:r.status})}),W.jsx("td",{className:"px-4 py-2 text-center text-gray-600",children:r.firstIteration!==null?r.firstIteration:""}),W.jsx("td",{className:"px-4 py-2 text-gray-600",children:r.iterations}),W.jsx("td",{className:"px-4 py-2",children:W.jsx(Eni,{progress:r.progress})}),W.jsx("td",{className:"px-4 py-2 text-gray-600",children:s(r.timeSpent)}),W.jsx("td",{className:"px-4 py-2 text-gray-500",children:W.jsx(dni,{stats:r.stats})}),W.jsx("td",{className:"px-4 py-2",children:r.solverInstance?W.jsxs("button",{onClick:()=>o(r),className:"flex items-center gap-1 text-blue-500 hover:text-blue-700",title:`Download input for ${r.name}`,children:[W.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:W.jsx("path",{fillRule:"evenodd",d:"M12 2.25a.75.75 0 01.75.75v11.69l3.22-3.22a.75.75 0 111.06 1.06l-4.5 4.5a.75.75 0 01-1.06 0l-4.5-4.5a.75.75 0 111.06-1.06l3.22 3.22V3a.75.75 0 01.75-.75zm-9 13.5a.75.75 0 01.75.75v2.25a1.5 1.5 0 001.5 1.5h13.5a1.5 1.5 0 001.5-1.5V16.5a.75.75 0 011.5 0v2.25a3 3 0 01-3 3H5.25a3 3 0 01-3-3V16.5a.75.75 0 01.75-.75z",clipRule:"evenodd"})}),W.jsx("span",{children:"Input"})]}):null})]},r.name))})]})})]})},yni=class extends Qn.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 mni({graphics:t}){const A=t.points??[],e=t.lines??[],i=t.rects??[],n=t.circles??[],o=t.texts??[];let s=Number.POSITIVE_INFINITY,r=Number.POSITIVE_INFINITY,a=Number.NEGATIVE_INFINITY,g=Number.NEGATIVE_INFINITY;const c=(h,E)=>{typeof h=="number"&&(h<s&&(s=h),h>a&&(a=h)),typeof E=="number"&&(E<r&&(r=E),E>g&&(g=E))};for(const h of A)c(h.x,h.y);for(const h of e){const E=h.points??[];for(const u of E)c(u.x,u.y)}for(const h of i){const E=h.x??0,u=h.y??0,d=h.width??0,f=h.height??0;c(E,u),c(E+d,u+f)}for(const h of n){const E=h.x??0,u=h.y??0,d=h.radius??1;c(E-d,u-d),c(E+d,u+d)}for(const h of o)c(h.x,h.y);(!isFinite(s)||!isFinite(r)||!isFinite(a)||!isFinite(g))&&(s=-20,r=-20,a=20,g=20);const I=10,l=s-I,B=r-I,C=Math.max(1,a-s+2*I),Q=Math.max(1,g-r+2*I);return W.jsxs("svg",{className:"w-full h-[400px] bg-white",viewBox:`${l} ${B} ${C} ${Q}`,role:"img","aria-label":"Graphics fallback",children:[i.map((h,E)=>W.jsx("rect",{x:h.x??0,y:h.y??0,width:h.width??0,height:h.height??0,fill:"none",stroke:h.strokeColor??"black",strokeWidth:h.strokeWidth??1},`rect-${E}`)),e.map((h,E)=>W.jsx("polyline",{fill:"none",stroke:h.strokeColor??"black",strokeWidth:h.strokeWidth??1,points:(h.points??[]).map(u=>`${u.x??0},${u.y??0}`).join(" ")},`line-${E}`)),n.map((h,E)=>W.jsx("circle",{cx:h.x??0,cy:h.y??0,r:h.radius??1.5,fill:h.fillColor??"none",stroke:h.strokeColor??"black",strokeWidth:h.strokeWidth??1},`circle-${E}`)),A.map((h,E)=>W.jsx("circle",{cx:h.x??0,cy:h.y??0,r:h.radius??1.5,fill:h.color??"black"},`point-${E}`)),o.map((h,E)=>W.jsx("text",{x:h.x??0,y:h.y??0,fontSize:h.fontSize??10,fill:h.color??"black",children:h.text??""},`text-${E}`))]})}var wni=({solver:t,animationSpeed:A=25,onSolverStarted:e,onSolverCompleted:i})=>{const[n,o]=V.useReducer(c=>c+1,0),s=V.useMemo(()=>{try{return t.visualize()||{points:[],lines:[],rects:[],circles:[]}}catch(c){return console.error("Visualization error:",c),{points:[],lines:[],rects:[],circles:[]}}},[t,n]),r=V.useMemo(()=>(s.rects?.length||0)===0&&(s.lines?.length||0)===0&&(s.points?.length||0)===0&&(s.circles?.length||0)===0,[s]);V.useEffect(()=>{if(!(typeof document>"u")&&!document.querySelector('script[src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4"]')){const c=document.createElement("script");c.src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4",document.head.appendChild(c)}},[]);const a=t.pipelineDef!==void 0,g=c=>{const I=t;if(!t.solved&&!t.failed){for(;!t.solved&&!t.failed&&I.currentPipelineStepIndex<=I.pipelineDef.findIndex(l=>l.solverName===c);)t.step();o()}};return W.jsxs("div",{children:[W.jsx(Bni,{solver:t,triggerRender:o,animationSpeed:A,onSolverStarted:e,onSolverCompleted:i}),r?W.jsx("div",{className:"p-4 text-gray-500",children:"No Graphics Yet"}):W.jsx(yni,{fallback:W.jsx(mni,{graphics:s}),children:W.jsx(cni,{graphics:s})}),a&&W.jsx(fni,{solver:t,onStepUntilPhase:g})]})};const Dni=()=>{V.useEffect(()=>{const t="tailwind-cdn-script";if(document.getElementById(t)||window.tailwind)return;const A=document.createElement("div");A.className="hidden",document.body.appendChild(A);const e=window.getComputedStyle(A).display==="none";if(document.body.removeChild(A),e)return;const i=document.createElement("script");i.id=t,i.src="https://cdn.tailwindcss.com",document.head.appendChild(i)},[])},Sni=t=>t.toLowerCase().includes("pack")?Cqt:t.toLowerCase().includes("rout")?dqt:$Kt,bni=({solverEvents:t=[]})=>{const[A,e]=V.useState(null);Dni();const i=V.useMemo(()=>{const r=new Map;for(const a of t){const g=`${a.componentName}-${a.solverName}`;r.set(g,a)}return r},[t]),n=V.useMemo(()=>Array.from(i.keys()),[i]),o=A?i.get(A):null,s=V.useMemo(()=>{if(!o)return{instance:null,error:null,classFound:!1};const r=WrA[o.solverName];if(!r)return{instance:null,error:`Solver class "${o.solverName}" not found in SOLVERS registry. Available: ${Object.keys(WrA).join(", ")}`,classFound:!1};try{const a=o.solverParams,g=a?.input!==void 0?a.input:a;return{instance:new r(g),error:null,classFound:!0}}catch(a){const g=a instanceof Error?a.message:String(a);return console.error("Failed to reconstruct solver:",a),{instance:null,error:`Failed to instantiate solver: ${g}`,classFound:!0}}},[o]);return t.length===0?W.jsx("div",{className:"rf-p-4",children:W.jsx("div",{className:"rf-bg-gray-50 rf-rounded-md rf-border rf-border-gray-200",children:W.jsxs("div",{className:"rf-p-4",children:[W.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800 rf-mb-3",children:"No Solvers Detected"}),W.jsx("p",{className:"rf-text-sm rf-text-gray-600",children:"Solvers will appear here when the circuit runs. Solvers are used for tasks like component packing and autorouting."})]})})}):W.jsxs("div",{className:"rf-flex rf-h-full rf-overflow-hidden",children:[W.jsxs("div",{className:"rf-w-64 rf-border-r rf-border-gray-200 rf-overflow-y-auto rf-flex-shrink-0",children:[W.jsxs("div",{className:"rf-text-xs rf-font-semibold rf-text-gray-500 rf-px-3 rf-py-2 rf-bg-gray-50 rf-border-b rf-border-gray-200",children:[n.length," ",n.length===1?"Solver":"Solvers"]}),n.map(r=>{const a=i.get(r),g=A===r;return W.jsx("div",{className:`rf-px-3 rf-py-2 rf-cursor-pointer rf-border-b rf-border-gray-100 ${g?"rf-bg-blue-50 rf-border-l-2 rf-border-l-blue-500":"hover:rf-bg-gray-50"}`,onClick:()=>e(r),children:(()=>{const c=Sni(a.solverName);return W.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2",children:[W.jsx(c,{className:"rf-w-4 rf-h-4 rf-text-blue-500 rf-flex-shrink-0"}),W.jsxs("div",{className:"rf-flex-1 rf-min-w-0",children:[W.jsx("div",{className:"rf-text-sm rf-font-medium rf-text-gray-800 rf-truncate",children:a.componentName}),W.jsx("div",{className:"rf-text-xs rf-text-gray-500 rf-truncate",children:a.solverName})]})]})})()},r)})]}),W.jsx("div",{className:"rf-flex-1 rf-overflow-hidden",children:o?s.instance?W.jsx(wm,{fallback:W.jsx("div",{className:"rf-p-4",children:W.jsxs("div",{className:"rf-bg-red-50 rf-rounded-md rf-border rf-border-red-200 rf-p-4",children:[W.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-red-800 rf-mb-2",children:"Error Loading Solver Debugger"}),W.jsxs("p",{className:"rf-text-sm rf-text-red-600",children:["Failed to render the solver debugger for"," ",o.solverName]})]})}),children:W.jsx(wni,{solver:s.instance})}):W.jsxs("div",{className:"rf-p-4",children:[W.jsxs("div",{className:"rf-mb-4",children:[W.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800",children:o.solverName}),W.jsxs("p",{className:"rf-text-sm rf-text-gray-500",children:["Component: ",o.componentName]})]}),s.error&&W.jsx("div",{className:`rf-rounded-md rf-border rf-p-4 rf-mb-4 ${s.classFound?"rf-bg-red-50 rf-border-red-200":"rf-bg-yellow-50 rf-border-yellow-200"}`,children:W.jsx("p",{className:`rf-text-sm ${s.classFound?"rf-text-red-700":"rf-text-yellow-700"}`,children:s.error})}),W.jsxs("div",{className:"rf-border rf-border-gray-200 rf-rounded-md rf-overflow-hidden",children:[W.jsx("div",{className:"rf-px-3 rf-py-2 rf-bg-gray-50",children:W.jsx("span",{className:"rf-text-sm rf-font-medium rf-text-gray-700",children:"Solver Parameters"})}),W.jsx("div",{className:"rf-p-3 rf-bg-white rf-border-t rf-border-gray-200",children:W.jsx("pre",{className:"rf-text-xs rf-font-mono rf-text-gray-600 rf-whitespace-pre-wrap rf-overflow-x-auto",children:JSON.stringify(o.solverParams,null,2)})})]})]}):W.jsx("div",{className:"rf-flex rf-items-center rf-justify-center rf-h-full",children:W.jsx("p",{className:"rf-text-sm rf-text-gray-500",children:"Select a solver from the list to view details"})})})]})},uEe=({errorMessage:t,errorStack:A,circuitJsonErrors:e})=>{V.useEffect(()=>{if(t){const i=new Error(t);A&&(i.stack=A);try{qW.captureException(i)}catch{}}},[t,A]),V.useEffect(()=>{if(e&&e.length>0)for(const i of e){const n=new Error(i.message||"Circuit JSON Error");i.stack&&(n.stack=i.stack);try{qW.captureException(n,{error_type:i.type})}catch{}}},[e])},dEe="0.0.1742",xni={version:dEe},Jz=k4A()(v4A(t=>({lastRunEvalVersion:void 0,setLastRunEvalVersion:A=>{t({lastRunEvalVersion:A})}}),{name:"runframe-runner-store"})),_ni=t=>{const[A,e]=V.useState([]),[i,n]=V.useState(null),[o,s]=V.useState(""),[r,a]=aG("eval-version-selection",null),g=Jz(B=>B.setLastRunEvalVersion),c=Jz(B=>B.lastRunEvalVersion);return V.useEffect(()=>{t&&fetch("https://data.jsdelivr.com/v1/package/npm/@tscircuit/eval").then(B=>B.json()).then(B=>{if(Array.isArray(B?.versions)){let C=[...B.versions];B.tags?.latest&&(n(B.tags.latest),C=C.filter(Q=>Q!==B.tags.latest)),e(C)}}).catch(()=>{})},[t]),V.useEffect(()=>{t&&(r?(window.TSCIRCUIT_LATEST_EVAL_VERSION=r,g(r)):i&&(window.TSCIRCUIT_LATEST_EVAL_VERSION=i,g(i)))},[t,r,i]),{versions:V.useMemo(()=>A.filter(B=>B.includes(o)).slice(0,50),[A,o]),latestVersion:i,lastRunEvalVersion:c,search:o,setSearch:s,selectVersion:B=>{a(B),s("")}}},kni=({snippetNames:t,onSelect:A,onCancel:e,isOpen:i})=>{const[n,o]=V.useState(""),[s,r]=V.useState("");if(!i)return null;const a=t.filter(I=>I.toLowerCase().includes(s.toLowerCase())),g=s&&!t.includes(s),c=I=>{I.key==="Enter"&&(a.length===1?o(a[0]):g&&o(s))};return W.jsx("div",{className:"rf-fixed rf-inset-0 rf-bg-black rf-bg-opacity-50 rf-flex rf-items-center rf-justify-center rf-z-[100]",children:W.jsxs("div",{className:"rf-bg-white rf-rounded-lg rf-p-6 rf-w-96",children:[W.jsx("h2",{className:"rf-text-lg rf-font-semibold rf-mb-4",children:"Select Snippet"}),W.jsx("input",{type:"text",className:"rf-w-full rf-px-4 rf-py-2 rf-border rf-rounded rf-mb-4",placeholder:"Search snippets or new snippet name...",value:s,onChange:I=>r(I.target.value),onKeyDown:c}),W.jsxs("div",{className:"rf-h-60 rf-overflow-y-auto",children:[a.map(I=>W.jsx("button",{type:"button",className:`w-full text-left px-4 py-2 rounded hover:bg-gray-100 ${n===I?"bg-blue-50":""}`,onClick:()=>o(I),children:I},I)),g&&W.jsxs("button",{type:"button",className:`w-full text-left px-4 py-2 rounded hover:bg-gray-100 text-blue-500 ${n===s?"bg-blue-50":""}`,onClick:()=>o(s),children:['Create new "',s,'"']})]}),W.jsxs("div",{className:"rf-mt-4 rf-flex rf-justify-end rf-gap-2",children:[W.jsx("button",{type:"button",className:"rf-px-4 rf-py-2 rf-text-gray-600 rf-hover:text-gray-800",onClick:e,children:"Cancel"}),W.jsx("button",{type:"button",className:"rf-px-4 rf-py-2 rf-bg-blue-500 rf-text-white rf-rounded rf-hover:bg-blue-600 rf-disabled:opacity-50",onClick:()=>n&&A(n),disabled:!n,children:n===s?`Create "${n}"`:`Save to ${n}`})]})]})})},vni=t=>{const A=V.useRef(null),e=MI(i=>i.recentEvents);V.useEffect(()=>{if(e.length===0)return;const i=e[0];i.event_id!==A.current&&(t(i),A.current=i.event_id)},[e,t])};function Fni(t){const A=Mni(t),e=V.forwardRef((i,n)=>{const{children:o,...s}=i,r=V.Children.toArray(o),a=r.find(Nni);if(a){const g=a.props.children,c=r.map(I=>I===a?V.Children.count(g)>1?V.Children.only(null):V.isValidElement(g)?g.props.children:null:I);return W.jsx(A,{...s,ref:n,children:V.isValidElement(g)?V.cloneElement(g,void 0,c):null})}return W.jsx(A,{...s,ref:n,children:o})});return e.displayName=`${t}.Slot`,e}function Mni(t){const A=V.forwardRef((e,i)=>{const{children:n,...o}=e;if(V.isValidElement(n)){const s=Lni(n),r=Gni(o,n.props);return n.type!==V.Fragment&&(r.ref=i?_f(i,s):s),V.cloneElement(n,r)}return V.Children.count(n)>1?V.Children.only(null):null});return A.displayName=`${t}.SlotClone`,A}var Rni=Symbol("radix.slottable");function Nni(t){return V.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===Rni}function Gni(t,A){const e={...A};for(const i in A){const n=t[i],o=A[i];/^on[A-Z]/.test(i)?n&&o?e[i]=(...r)=>{const a=o(...r);return n(...r),a}:n&&(e[i]=n):i==="style"?e[i]={...n,...o}:i==="className"&&(e[i]=[n,o].filter(Boolean).join(" "))}return{...t,...e}}function Lni(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 Tz="Dialog",[pEe,fEe]=uw(Tz),[Uni,qw]=pEe(Tz),yEe=t=>{const{__scopeDialog:A,children:e,open:i,defaultOpen:n,onOpenChange:o,modal:s=!0}=t,r=V.useRef(null),a=V.useRef(null),[g,c]=G_({prop:i,defaultProp:n??!1,onChange:o,caller:Tz});return W.jsx(Uni,{scope:A,triggerRef:r,contentRef:a,contentId:qE(),titleId:qE(),descriptionId:qE(),open:g,onOpenChange:c,onOpenToggle:V.useCallback(()=>c(I=>!I),[c]),modal:s,children:e})};yEe.displayName=Tz;var mEe="DialogTrigger",wEe=V.forwardRef((t,A)=>{const{__scopeDialog:e,...i}=t,n=qw(mEe,e),o=RI(A,n.triggerRef);return W.jsx(Ag.button,{type:"button","aria-haspopup":"dialog","aria-expanded":n.open,"aria-controls":n.contentId,"data-state":NmA(n.open),...i,ref:o,onClick:Vn(t.onClick,n.onOpenToggle)})});wEe.displayName=mEe;var MmA="DialogPortal",[Hni,DEe]=pEe(MmA,{forceMount:void 0}),SEe=t=>{const{__scopeDialog:A,forceMount:e,children:i,container:n}=t,o=qw(MmA,A);return W.jsx(Hni,{scope:A,forceMount:e,children:V.Children.map(i,s=>W.jsx(q0,{present:e||o.open,children:W.jsx($9,{asChild:!0,container:n,children:s})}))})};SEe.displayName=MmA;var Pz="DialogOverlay",bEe=V.forwardRef((t,A)=>{const e=DEe(Pz,t.__scopeDialog),{forceMount:i=e.forceMount,...n}=t,o=qw(Pz,t.__scopeDialog);return o.modal?W.jsx(q0,{present:i||o.open,children:W.jsx(Jni,{...n,ref:A})}):null});bEe.displayName=Pz;var Yni=Fni("DialogOverlay.RemoveScroll"),Jni=V.forwardRef((t,A)=>{const{__scopeDialog:e,...i}=t,n=qw(Pz,e);return W.jsx(rj,{as:Yni,allowPinchZoom:!0,shards:[n.contentRef],children:W.jsx(Ag.div,{"data-state":NmA(n.open),...i,ref:A,style:{pointerEvents:"auto",...i.style}})})}),TM="DialogContent",xEe=V.forwardRef((t,A)=>{const e=DEe(TM,t.__scopeDialog),{forceMount:i=e.forceMount,...n}=t,o=qw(TM,t.__scopeDialog);return W.jsx(q0,{present:i||o.open,children:o.modal?W.jsx(Tni,{...n,ref:A}):W.jsx(Pni,{...n,ref:A})})});xEe.displayName=TM;var Tni=V.forwardRef((t,A)=>{const e=qw(TM,t.__scopeDialog),i=V.useRef(null),n=RI(A,e.contentRef,i);return V.useEffect(()=>{const o=i.current;if(o)return VfA(o)},[]),W.jsx(_Ee,{...t,ref:n,trapFocus:e.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Vn(t.onCloseAutoFocus,o=>{o.preventDefault(),e.triggerRef.current?.focus()}),onPointerDownOutside:Vn(t.onPointerDownOutside,o=>{const s=o.detail.originalEvent,r=s.button===0&&s.ctrlKey===!0;(s.button===2||r)&&o.preventDefault()}),onFocusOutside:Vn(t.onFocusOutside,o=>o.preventDefault())})}),Pni=V.forwardRef((t,A)=>{const e=qw(TM,t.__scopeDialog),i=V.useRef(!1),n=V.useRef(!1);return W.jsx(_Ee,{...t,ref:A,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:o=>{t.onCloseAutoFocus?.(o),o.defaultPrevented||(i.current||e.triggerRef.current?.focus(),o.preventDefault()),i.current=!1,n.current=!1},onInteractOutside:o=>{t.onInteractOutside?.(o),o.defaultPrevented||(i.current=!0,o.detail.originalEvent.type==="pointerdown"&&(n.current=!0));const s=o.target;e.triggerRef.current?.contains(s)&&o.preventDefault(),o.detail.originalEvent.type==="focusin"&&n.current&&o.preventDefault()}})}),_Ee=V.forwardRef((t,A)=>{const{__scopeDialog:e,trapFocus:i,onOpenAutoFocus:n,onCloseAutoFocus:o,...s}=t,r=qw(TM,e),a=V.useRef(null),g=RI(A,a);return kfA(),W.jsxs(W.Fragment,{children:[W.jsx(Y9,{asChild:!0,loop:!0,trapped:i,onMountAutoFocus:n,onUnmountAutoFocus:o,children:W.jsx(KJ,{role:"dialog",id:r.contentId,"aria-describedby":r.descriptionId,"aria-labelledby":r.titleId,"data-state":NmA(r.open),...s,ref:g,onDismiss:()=>r.onOpenChange(!1)})}),W.jsxs(W.Fragment,{children:[W.jsx(qni,{titleId:r.titleId}),W.jsx(Wni,{contentRef:a,descriptionId:r.descriptionId})]})]})}),RmA="DialogTitle",kEe=V.forwardRef((t,A)=>{const{__scopeDialog:e,...i}=t,n=qw(RmA,e);return W.jsx(Ag.h2,{id:n.titleId,...i,ref:A})});kEe.displayName=RmA;var vEe="DialogDescription",FEe=V.forwardRef((t,A)=>{const{__scopeDialog:e,...i}=t,n=qw(vEe,e);return W.jsx(Ag.p,{id:n.descriptionId,...i,ref:A})});FEe.displayName=vEe;var MEe="DialogClose",REe=V.forwardRef((t,A)=>{const{__scopeDialog:e,...i}=t,n=qw(MEe,e);return W.jsx(Ag.button,{type:"button",...i,ref:A,onClick:Vn(t.onClick,()=>n.onOpenChange(!1))})});REe.displayName=MEe;function NmA(t){return t?"open":"closed"}var NEe="DialogTitleWarning",[Kni,GEe]=Uat(NEe,{contentName:TM,titleName:RmA,docsSlug:"dialog"}),qni=({titleId:t})=>{const A=GEe(NEe),e=`\`${A.contentName}\` requires a \`${A.titleName}\` for the component to be accessible for screen reader users.
5692
+ `,I=new Blob([c],{type:"text/plain"}),l=URL.createObjectURL(I),B=document.createElement("a");B.href=l,B.download=`${g}.test.ts`,B.click(),URL.revokeObjectURL(l)}catch(a){alert(`Error generating test.ts for ${t.constructor.name}: ${a instanceof Error?a.message:String(a)}`)}i(!1)};return W.jsxs("div",{className:`relative ${A}`,ref:n,children:[W.jsx("button",{className:"px-2 py-1 rounded text-xs cursor-pointer",onClick:()=>i(!e),title:`Download options for ${t.constructor.name}`,children:t.constructor.name}),e&&W.jsxs("div",{className:"absolute top-full left-0 mt-1 bg-white border border-gray-300 rounded shadow-lg z-10 min-w-[150px]",children:[W.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:o,children:"Download JSON"}),W.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:s,children:"Download page.tsx"}),W.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:r,children:"Download test.ts"})]})]})},EEe=t=>t.activeSubSolver?[t,...EEe(t.activeSubSolver)]:[t],lni=({solver:t})=>{const A=EEe(t);return W.jsx("div",{className:"flex gap-1 items-center text-sm pt-1",children:A.map((e,i)=>W.jsxs("div",{className:"flex items-center",children:[i>0&&W.jsx("span",{className:"text-gray-400 mx-1",children:"→"}),W.jsx(Ini,{solver:e})]},e.constructor.name))})},Bni=({solver:t,triggerRender:A,animationSpeed:e=25,onSolverStarted:i,onSolverCompleted:n})=>{const[o,s]=V.useReducer(Q=>!Q,!1),r=V.useRef(void 0),a=()=>{!t.solved&&!t.failed&&(t.step(),A())},g=()=>{!t.solved&&!t.failed&&(i&&i(t),t.solve(),A(),n&&n(t))},c=()=>{o?(r.current&&(clearInterval(r.current),r.current=void 0),s()):(s(),r.current=setInterval(()=>{if(t.solved||t.failed){r.current&&(clearInterval(r.current),r.current=void 0),s(),A(),n&&t.solved&&n(t);return}t.step(),A()},e))},I=()=>{const Q=t;if(Q.getCurrentPhase&&!t.solved&&!t.failed){const h=Q.getCurrentPhase();for(;Q.getCurrentPhase()===h&&!t.solved&&!t.failed;)t.step();A()}},l=()=>{if(t.solved||t.failed||o)return;const Q=window.prompt("Step until which iteration?",`${t.iterations}`);if(Q===null)return;const h=Number(Q);if(!Number.isFinite(h)){window.alert("Please enter a valid number for the iteration");return}for(;t.iterations<h&&!t.solved&&!t.failed;)t.step();A(),t.solved&&n&&n(t)};V.useEffect(()=>()=>{r.current&&clearInterval(r.current)},[]),V.useEffect(()=>{(t.solved||t.failed)&&o&&(r.current&&(clearInterval(r.current),r.current=void 0),s())},[t.solved,t.failed,o]);const B=t.getCurrentPhase!==void 0,C=B?t.getCurrentPhase():null;return W.jsxs("div",{className:"space-y-2 p-2 border-b",children:[W.jsx("div",{className:"flex items-center",children:W.jsx(lni,{solver:t})}),W.jsxs("div",{className:"flex gap-2 items-center flex-wrap",children:[W.jsx("button",{onClick:a,disabled:t.solved||t.failed||o,className:"bg-blue-500 hover:bg-blue-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Step"}),W.jsx("button",{onClick:g,disabled:t.solved||t.failed||o,className:"bg-green-500 hover:bg-green-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Solve"}),W.jsx("button",{onClick:c,disabled:t.solved||t.failed,className:`px-3 py-1 rounded text-white text-sm ${o?"bg-red-500 hover:bg-red-600":"bg-yellow-500 hover:bg-yellow-600"} disabled:bg-gray-300`,children:o?"Stop":"Animate"}),W.jsx("button",{onClick:l,disabled:t.solved||t.failed||o,className:"bg-orange-500 hover:bg-orange-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Step Until Iteration"}),B&&W.jsx("button",{onClick:I,disabled:t.solved||t.failed||o,className:"bg-purple-500 hover:bg-purple-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Next Stage"}),W.jsxs("div",{className:"text-sm text-gray-600",children:["Iterations: ",t.iterations]}),t.timeToSolve!==void 0&&W.jsxs("div",{className:"text-sm text-gray-600",children:["Time: ",(t.timeToSolve/1e3).toFixed(3),"s"]}),C&&W.jsxs("div",{className:"text-sm text-gray-600",children:["Phase: ",W.jsx("span",{className:"font-medium",children:C})]}),t.solved&&W.jsx("div",{className:"px-2 py-1 bg-green-100 text-green-800 rounded text-sm",children:"Solved"}),t.failed&&W.jsx("div",{className:"px-2 py-1 bg-red-100 text-red-800 rounded text-sm",children:"Failed"})]}),t.error&&W.jsxs("div",{className:"text-red-600 text-sm",children:["Error: ",t.error]})]})},Cni=(t,A,e)=>{const i=t.currentPipelineStepIndex;return A<i?"Completed":A===i&&t.activeSubSolver?t.activeSubSolver.failed?"Failed":"In Progress":"Not Started"},Qni=(t,A)=>{const i=t.pipelineDef[A].solverName,n=Cni(t,A),o=t[i],s=t.firstIterationOfPhase?.[i]??null,r=t.iterations;let a=0;if(n==="Completed"){const l=t.pipelineDef[A+1],B=l?t.firstIterationOfPhase?.[l.solverName]:void 0;B!==void 0&&s!==null?a=B-s:s!==null&&(a=r-s)}else n==="In Progress"&&s!==null&&(a=r-s);const g=t.timeSpentOnPhase?.[i]??0;let c=0;n==="Completed"?c=1:n==="In Progress"&&o&&(c=o.progress??0);const I=o?.stats??null;return{index:A,name:i,status:n,firstIteration:s,iterations:a,progress:c,timeSpent:g,stats:I&&Object.keys(I).length>0?I:null,solverInstance:o??null}},hni=({status:t})=>{const A={"Not Started":"text-blue-600","In Progress":"text-yellow-600",Completed:"text-green-600",Failed:"text-red-600"};return W.jsx("span",{className:`font-medium ${A[t]}`,children:t})},Eni=({progress:t})=>{if(t===0)return null;const A=Math.round(t*100);return W.jsxs("div",{className:"flex items-center gap-2",children:[W.jsx("div",{className:"w-20 h-2 bg-gray-200 rounded overflow-hidden",children:W.jsx("div",{className:"h-full bg-blue-500 transition-all duration-200",style:{width:`${A}%`}})}),W.jsxs("span",{className:"text-xs text-gray-500",children:[A,"%"]})]})},uni=t=>Object.entries(t).map(([A,e])=>`${A}: ${e}`).join(", "),dni=({stats:t})=>{if(!t||Object.keys(t).length===0)return W.jsx("span",{children:"-"});const A=Object.entries(t),e=uni(t);return W.jsxs("details",{className:"cursor-pointer",children:[W.jsx("summary",{className:"whitespace-nowrap overflow-hidden text-ellipsis max-w-[200px]",children:e}),W.jsx("div",{className:"mt-1 text-xs",children:A.map(([i,n])=>W.jsxs("div",{children:[i,": ",String(n)]},i))})]})},FmA=t=>{if(t===null||typeof t!="object")return t;if(Array.isArray(t))return t.map(FmA);const A={};for(const[e,i]of Object.entries(t))e.startsWith("_")||(A[e]=FmA(i));return A},pni=(t,A)=>{try{if(typeof t.getConstructorParams!="function"){alert(`getConstructorParams() is not implemented for ${A}`);return}const e=FmA(t.getConstructorParams()),i=new Blob([JSON.stringify(e,null,2)],{type:"application/json"}),n=URL.createObjectURL(i),o=document.createElement("a");o.href=n,o.download=`${A}_input.json`,o.click(),URL.revokeObjectURL(n)}catch(e){alert(`Error downloading input for ${A}: ${e instanceof Error?e.message:String(e)}`)}},fni=({solver:t,onStepUntilPhase:A,onDownloadInput:e})=>{const i=t.pipelineDef.map((r,a)=>Qni(t,a)),n=r=>{A?.(r)},o=r=>{r.solverInstance&&(e?e(r.solverInstance,r.name):pni(r.solverInstance,r.name))},s=r=>`${(r/1e3).toFixed(2)}s`;return W.jsxs("div",{className:"border-t border-gray-200",children:[W.jsx("div",{className:"px-4 py-2 bg-gray-50 border-b border-gray-200",children:W.jsx("h3",{className:"text-sm font-semibold text-gray-700",children:"Pipeline Steps"})}),W.jsx("div",{className:"overflow-x-auto",children:W.jsxs("table",{className:"w-full text-sm",children:[W.jsx("thead",{children:W.jsxs("tr",{className:"bg-gray-50 border-b border-gray-200",children:[W.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Step"}),W.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Status"}),W.jsxs("th",{className:"px-4 py-2 text-center font-semibold text-gray-700",children:["i",W.jsx("sub",{children:"0"})]}),W.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Iterations"}),W.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Progress"}),W.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Time"}),W.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Stats"}),W.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Input"})]})}),W.jsx("tbody",{children:i.map(r=>W.jsxs("tr",{className:`border-b border-gray-100 ${r.status==="In Progress"?"bg-yellow-50":""}`,children:[W.jsx("td",{className:"px-4 py-2",children:W.jsxs("div",{className:"flex items-center gap-2",children:[W.jsx("span",{className:"text-gray-400 w-6",children:String(r.index+1).padStart(2,"0")}),W.jsx("button",{onClick:()=>n(r.name),disabled:r.status==="Completed"||t.solved||t.failed,className:"text-blue-500 hover:text-blue-700 disabled:text-gray-300 disabled:cursor-not-allowed",title:`Step until ${r.name} completes`,children:W.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:W.jsx("path",{fillRule:"evenodd",d:"M4.5 5.653c0-1.426 1.529-2.33 2.779-1.643l11.54 6.348c1.295.712 1.295 2.573 0 3.285L7.28 19.991c-1.25.687-2.779-.217-2.779-1.643V5.653z",clipRule:"evenodd"})})}),W.jsx("span",{className:"font-medium text-gray-900",children:r.name})]})}),W.jsx("td",{className:"px-4 py-2",children:W.jsx(hni,{status:r.status})}),W.jsx("td",{className:"px-4 py-2 text-center text-gray-600",children:r.firstIteration!==null?r.firstIteration:""}),W.jsx("td",{className:"px-4 py-2 text-gray-600",children:r.iterations}),W.jsx("td",{className:"px-4 py-2",children:W.jsx(Eni,{progress:r.progress})}),W.jsx("td",{className:"px-4 py-2 text-gray-600",children:s(r.timeSpent)}),W.jsx("td",{className:"px-4 py-2 text-gray-500",children:W.jsx(dni,{stats:r.stats})}),W.jsx("td",{className:"px-4 py-2",children:r.solverInstance?W.jsxs("button",{onClick:()=>o(r),className:"flex items-center gap-1 text-blue-500 hover:text-blue-700",title:`Download input for ${r.name}`,children:[W.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:W.jsx("path",{fillRule:"evenodd",d:"M12 2.25a.75.75 0 01.75.75v11.69l3.22-3.22a.75.75 0 111.06 1.06l-4.5 4.5a.75.75 0 01-1.06 0l-4.5-4.5a.75.75 0 111.06-1.06l3.22 3.22V3a.75.75 0 01.75-.75zm-9 13.5a.75.75 0 01.75.75v2.25a1.5 1.5 0 001.5 1.5h13.5a1.5 1.5 0 001.5-1.5V16.5a.75.75 0 011.5 0v2.25a3 3 0 01-3 3H5.25a3 3 0 01-3-3V16.5a.75.75 0 01.75-.75z",clipRule:"evenodd"})}),W.jsx("span",{children:"Input"})]}):null})]},r.name))})]})})]})},yni=class extends Qn.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 mni({graphics:t}){const A=t.points??[],e=t.lines??[],i=t.rects??[],n=t.circles??[],o=t.texts??[];let s=Number.POSITIVE_INFINITY,r=Number.POSITIVE_INFINITY,a=Number.NEGATIVE_INFINITY,g=Number.NEGATIVE_INFINITY;const c=(h,E)=>{typeof h=="number"&&(h<s&&(s=h),h>a&&(a=h)),typeof E=="number"&&(E<r&&(r=E),E>g&&(g=E))};for(const h of A)c(h.x,h.y);for(const h of e){const E=h.points??[];for(const u of E)c(u.x,u.y)}for(const h of i){const E=h.x??0,u=h.y??0,d=h.width??0,f=h.height??0;c(E,u),c(E+d,u+f)}for(const h of n){const E=h.x??0,u=h.y??0,d=h.radius??1;c(E-d,u-d),c(E+d,u+d)}for(const h of o)c(h.x,h.y);(!isFinite(s)||!isFinite(r)||!isFinite(a)||!isFinite(g))&&(s=-20,r=-20,a=20,g=20);const I=10,l=s-I,B=r-I,C=Math.max(1,a-s+2*I),Q=Math.max(1,g-r+2*I);return W.jsxs("svg",{className:"w-full h-[400px] bg-white",viewBox:`${l} ${B} ${C} ${Q}`,role:"img","aria-label":"Graphics fallback",children:[i.map((h,E)=>W.jsx("rect",{x:h.x??0,y:h.y??0,width:h.width??0,height:h.height??0,fill:"none",stroke:h.strokeColor??"black",strokeWidth:h.strokeWidth??1},`rect-${E}`)),e.map((h,E)=>W.jsx("polyline",{fill:"none",stroke:h.strokeColor??"black",strokeWidth:h.strokeWidth??1,points:(h.points??[]).map(u=>`${u.x??0},${u.y??0}`).join(" ")},`line-${E}`)),n.map((h,E)=>W.jsx("circle",{cx:h.x??0,cy:h.y??0,r:h.radius??1.5,fill:h.fillColor??"none",stroke:h.strokeColor??"black",strokeWidth:h.strokeWidth??1},`circle-${E}`)),A.map((h,E)=>W.jsx("circle",{cx:h.x??0,cy:h.y??0,r:h.radius??1.5,fill:h.color??"black"},`point-${E}`)),o.map((h,E)=>W.jsx("text",{x:h.x??0,y:h.y??0,fontSize:h.fontSize??10,fill:h.color??"black",children:h.text??""},`text-${E}`))]})}var wni=({solver:t,animationSpeed:A=25,onSolverStarted:e,onSolverCompleted:i})=>{const[n,o]=V.useReducer(c=>c+1,0),s=V.useMemo(()=>{try{return t.visualize()||{points:[],lines:[],rects:[],circles:[]}}catch(c){return console.error("Visualization error:",c),{points:[],lines:[],rects:[],circles:[]}}},[t,n]),r=V.useMemo(()=>(s.rects?.length||0)===0&&(s.lines?.length||0)===0&&(s.points?.length||0)===0&&(s.circles?.length||0)===0,[s]);V.useEffect(()=>{if(!(typeof document>"u")&&!document.querySelector('script[src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4"]')){const c=document.createElement("script");c.src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4",document.head.appendChild(c)}},[]);const a=t.pipelineDef!==void 0,g=c=>{const I=t;if(!t.solved&&!t.failed){for(;!t.solved&&!t.failed&&I.currentPipelineStepIndex<=I.pipelineDef.findIndex(l=>l.solverName===c);)t.step();o()}};return W.jsxs("div",{children:[W.jsx(Bni,{solver:t,triggerRender:o,animationSpeed:A,onSolverStarted:e,onSolverCompleted:i}),r?W.jsx("div",{className:"p-4 text-gray-500",children:"No Graphics Yet"}):W.jsx(yni,{fallback:W.jsx(mni,{graphics:s}),children:W.jsx(cni,{graphics:s})}),a&&W.jsx(fni,{solver:t,onStepUntilPhase:g})]})};const Dni=()=>{V.useEffect(()=>{const t="tailwind-cdn-script";if(document.getElementById(t)||window.tailwind)return;const A=document.createElement("div");A.className="hidden",document.body.appendChild(A);const e=window.getComputedStyle(A).display==="none";if(document.body.removeChild(A),e)return;const i=document.createElement("script");i.id=t,i.src="https://cdn.tailwindcss.com",document.head.appendChild(i)},[])},Sni=t=>t.toLowerCase().includes("pack")?Cqt:t.toLowerCase().includes("rout")?dqt:$Kt,bni=({solverEvents:t=[]})=>{const[A,e]=V.useState(null);Dni();const i=V.useMemo(()=>{const r=new Map;for(const a of t){const g=`${a.componentName}-${a.solverName}`;r.set(g,a)}return r},[t]),n=V.useMemo(()=>Array.from(i.keys()),[i]),o=A?i.get(A):null,s=V.useMemo(()=>{if(!o)return{instance:null,error:null,classFound:!1};const r=WrA[o.solverName];if(!r)return{instance:null,error:`Solver class "${o.solverName}" not found in SOLVERS registry. Available: ${Object.keys(WrA).join(", ")}`,classFound:!1};try{const a=o.solverParams,g=a?.input!==void 0?a.input:a;return{instance:new r(g),error:null,classFound:!0}}catch(a){const g=a instanceof Error?a.message:String(a);return console.error("Failed to reconstruct solver:",a),{instance:null,error:`Failed to instantiate solver: ${g}`,classFound:!0}}},[o]);return t.length===0?W.jsx("div",{className:"rf-p-4",children:W.jsx("div",{className:"rf-bg-gray-50 rf-rounded-md rf-border rf-border-gray-200",children:W.jsxs("div",{className:"rf-p-4",children:[W.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800 rf-mb-3",children:"No Solvers Detected"}),W.jsx("p",{className:"rf-text-sm rf-text-gray-600",children:"Solvers will appear here when the circuit runs. Solvers are used for tasks like component packing and autorouting."})]})})}):W.jsxs("div",{className:"rf-flex rf-h-full rf-overflow-hidden",children:[W.jsxs("div",{className:"rf-w-64 rf-border-r rf-border-gray-200 rf-overflow-y-auto rf-flex-shrink-0",children:[W.jsxs("div",{className:"rf-text-xs rf-font-semibold rf-text-gray-500 rf-px-3 rf-py-2 rf-bg-gray-50 rf-border-b rf-border-gray-200",children:[n.length," ",n.length===1?"Solver":"Solvers"]}),n.map(r=>{const a=i.get(r),g=A===r;return W.jsx("div",{className:`rf-px-3 rf-py-2 rf-cursor-pointer rf-border-b rf-border-gray-100 ${g?"rf-bg-blue-50 rf-border-l-2 rf-border-l-blue-500":"hover:rf-bg-gray-50"}`,onClick:()=>e(r),children:(()=>{const c=Sni(a.solverName);return W.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2",children:[W.jsx(c,{className:"rf-w-4 rf-h-4 rf-text-blue-500 rf-flex-shrink-0"}),W.jsxs("div",{className:"rf-flex-1 rf-min-w-0",children:[W.jsx("div",{className:"rf-text-sm rf-font-medium rf-text-gray-800 rf-truncate",children:a.componentName}),W.jsx("div",{className:"rf-text-xs rf-text-gray-500 rf-truncate",children:a.solverName})]})]})})()},r)})]}),W.jsx("div",{className:"rf-flex-1 rf-overflow-hidden",children:o?s.instance?W.jsx(wm,{fallback:W.jsx("div",{className:"rf-p-4",children:W.jsxs("div",{className:"rf-bg-red-50 rf-rounded-md rf-border rf-border-red-200 rf-p-4",children:[W.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-red-800 rf-mb-2",children:"Error Loading Solver Debugger"}),W.jsxs("p",{className:"rf-text-sm rf-text-red-600",children:["Failed to render the solver debugger for"," ",o.solverName]})]})}),children:W.jsx(wni,{solver:s.instance})}):W.jsxs("div",{className:"rf-p-4",children:[W.jsxs("div",{className:"rf-mb-4",children:[W.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800",children:o.solverName}),W.jsxs("p",{className:"rf-text-sm rf-text-gray-500",children:["Component: ",o.componentName]})]}),s.error&&W.jsx("div",{className:`rf-rounded-md rf-border rf-p-4 rf-mb-4 ${s.classFound?"rf-bg-red-50 rf-border-red-200":"rf-bg-yellow-50 rf-border-yellow-200"}`,children:W.jsx("p",{className:`rf-text-sm ${s.classFound?"rf-text-red-700":"rf-text-yellow-700"}`,children:s.error})}),W.jsxs("div",{className:"rf-border rf-border-gray-200 rf-rounded-md rf-overflow-hidden",children:[W.jsx("div",{className:"rf-px-3 rf-py-2 rf-bg-gray-50",children:W.jsx("span",{className:"rf-text-sm rf-font-medium rf-text-gray-700",children:"Solver Parameters"})}),W.jsx("div",{className:"rf-p-3 rf-bg-white rf-border-t rf-border-gray-200",children:W.jsx("pre",{className:"rf-text-xs rf-font-mono rf-text-gray-600 rf-whitespace-pre-wrap rf-overflow-x-auto",children:JSON.stringify(o.solverParams,null,2)})})]})]}):W.jsx("div",{className:"rf-flex rf-items-center rf-justify-center rf-h-full",children:W.jsx("p",{className:"rf-text-sm rf-text-gray-500",children:"Select a solver from the list to view details"})})})]})},uEe=({errorMessage:t,errorStack:A,circuitJsonErrors:e})=>{V.useEffect(()=>{if(t){const i=new Error(t);A&&(i.stack=A);try{qW.captureException(i)}catch{}}},[t,A]),V.useEffect(()=>{if(e&&e.length>0)for(const i of e){const n=new Error(i.message||"Circuit JSON Error");i.stack&&(n.stack=i.stack);try{qW.captureException(n,{error_type:i.type})}catch{}}},[e])},dEe="0.0.1743",xni={version:dEe},Jz=k4A()(v4A(t=>({lastRunEvalVersion:void 0,setLastRunEvalVersion:A=>{t({lastRunEvalVersion:A})}}),{name:"runframe-runner-store"})),_ni=t=>{const[A,e]=V.useState([]),[i,n]=V.useState(null),[o,s]=V.useState(""),[r,a]=aG("eval-version-selection",null),g=Jz(B=>B.setLastRunEvalVersion),c=Jz(B=>B.lastRunEvalVersion);return V.useEffect(()=>{t&&fetch("https://data.jsdelivr.com/v1/package/npm/@tscircuit/eval").then(B=>B.json()).then(B=>{if(Array.isArray(B?.versions)){let C=[...B.versions];B.tags?.latest&&(n(B.tags.latest),C=C.filter(Q=>Q!==B.tags.latest)),e(C)}}).catch(()=>{})},[t]),V.useEffect(()=>{t&&(r?(window.TSCIRCUIT_LATEST_EVAL_VERSION=r,g(r)):i&&(window.TSCIRCUIT_LATEST_EVAL_VERSION=i,g(i)))},[t,r,i]),{versions:V.useMemo(()=>A.filter(B=>B.includes(o)).slice(0,50),[A,o]),latestVersion:i,lastRunEvalVersion:c,search:o,setSearch:s,selectVersion:B=>{a(B),s("")}}},kni=({snippetNames:t,onSelect:A,onCancel:e,isOpen:i})=>{const[n,o]=V.useState(""),[s,r]=V.useState("");if(!i)return null;const a=t.filter(I=>I.toLowerCase().includes(s.toLowerCase())),g=s&&!t.includes(s),c=I=>{I.key==="Enter"&&(a.length===1?o(a[0]):g&&o(s))};return W.jsx("div",{className:"rf-fixed rf-inset-0 rf-bg-black rf-bg-opacity-50 rf-flex rf-items-center rf-justify-center rf-z-[100]",children:W.jsxs("div",{className:"rf-bg-white rf-rounded-lg rf-p-6 rf-w-96",children:[W.jsx("h2",{className:"rf-text-lg rf-font-semibold rf-mb-4",children:"Select Snippet"}),W.jsx("input",{type:"text",className:"rf-w-full rf-px-4 rf-py-2 rf-border rf-rounded rf-mb-4",placeholder:"Search snippets or new snippet name...",value:s,onChange:I=>r(I.target.value),onKeyDown:c}),W.jsxs("div",{className:"rf-h-60 rf-overflow-y-auto",children:[a.map(I=>W.jsx("button",{type:"button",className:`w-full text-left px-4 py-2 rounded hover:bg-gray-100 ${n===I?"bg-blue-50":""}`,onClick:()=>o(I),children:I},I)),g&&W.jsxs("button",{type:"button",className:`w-full text-left px-4 py-2 rounded hover:bg-gray-100 text-blue-500 ${n===s?"bg-blue-50":""}`,onClick:()=>o(s),children:['Create new "',s,'"']})]}),W.jsxs("div",{className:"rf-mt-4 rf-flex rf-justify-end rf-gap-2",children:[W.jsx("button",{type:"button",className:"rf-px-4 rf-py-2 rf-text-gray-600 rf-hover:text-gray-800",onClick:e,children:"Cancel"}),W.jsx("button",{type:"button",className:"rf-px-4 rf-py-2 rf-bg-blue-500 rf-text-white rf-rounded rf-hover:bg-blue-600 rf-disabled:opacity-50",onClick:()=>n&&A(n),disabled:!n,children:n===s?`Create "${n}"`:`Save to ${n}`})]})]})})},vni=t=>{const A=V.useRef(null),e=MI(i=>i.recentEvents);V.useEffect(()=>{if(e.length===0)return;const i=e[0];i.event_id!==A.current&&(t(i),A.current=i.event_id)},[e,t])};function Fni(t){const A=Mni(t),e=V.forwardRef((i,n)=>{const{children:o,...s}=i,r=V.Children.toArray(o),a=r.find(Nni);if(a){const g=a.props.children,c=r.map(I=>I===a?V.Children.count(g)>1?V.Children.only(null):V.isValidElement(g)?g.props.children:null:I);return W.jsx(A,{...s,ref:n,children:V.isValidElement(g)?V.cloneElement(g,void 0,c):null})}return W.jsx(A,{...s,ref:n,children:o})});return e.displayName=`${t}.Slot`,e}function Mni(t){const A=V.forwardRef((e,i)=>{const{children:n,...o}=e;if(V.isValidElement(n)){const s=Lni(n),r=Gni(o,n.props);return n.type!==V.Fragment&&(r.ref=i?_f(i,s):s),V.cloneElement(n,r)}return V.Children.count(n)>1?V.Children.only(null):null});return A.displayName=`${t}.SlotClone`,A}var Rni=Symbol("radix.slottable");function Nni(t){return V.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===Rni}function Gni(t,A){const e={...A};for(const i in A){const n=t[i],o=A[i];/^on[A-Z]/.test(i)?n&&o?e[i]=(...r)=>{const a=o(...r);return n(...r),a}:n&&(e[i]=n):i==="style"?e[i]={...n,...o}:i==="className"&&(e[i]=[n,o].filter(Boolean).join(" "))}return{...t,...e}}function Lni(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 Tz="Dialog",[pEe,fEe]=uw(Tz),[Uni,qw]=pEe(Tz),yEe=t=>{const{__scopeDialog:A,children:e,open:i,defaultOpen:n,onOpenChange:o,modal:s=!0}=t,r=V.useRef(null),a=V.useRef(null),[g,c]=G_({prop:i,defaultProp:n??!1,onChange:o,caller:Tz});return W.jsx(Uni,{scope:A,triggerRef:r,contentRef:a,contentId:qE(),titleId:qE(),descriptionId:qE(),open:g,onOpenChange:c,onOpenToggle:V.useCallback(()=>c(I=>!I),[c]),modal:s,children:e})};yEe.displayName=Tz;var mEe="DialogTrigger",wEe=V.forwardRef((t,A)=>{const{__scopeDialog:e,...i}=t,n=qw(mEe,e),o=RI(A,n.triggerRef);return W.jsx(Ag.button,{type:"button","aria-haspopup":"dialog","aria-expanded":n.open,"aria-controls":n.contentId,"data-state":NmA(n.open),...i,ref:o,onClick:Vn(t.onClick,n.onOpenToggle)})});wEe.displayName=mEe;var MmA="DialogPortal",[Hni,DEe]=pEe(MmA,{forceMount:void 0}),SEe=t=>{const{__scopeDialog:A,forceMount:e,children:i,container:n}=t,o=qw(MmA,A);return W.jsx(Hni,{scope:A,forceMount:e,children:V.Children.map(i,s=>W.jsx(q0,{present:e||o.open,children:W.jsx($9,{asChild:!0,container:n,children:s})}))})};SEe.displayName=MmA;var Pz="DialogOverlay",bEe=V.forwardRef((t,A)=>{const e=DEe(Pz,t.__scopeDialog),{forceMount:i=e.forceMount,...n}=t,o=qw(Pz,t.__scopeDialog);return o.modal?W.jsx(q0,{present:i||o.open,children:W.jsx(Jni,{...n,ref:A})}):null});bEe.displayName=Pz;var Yni=Fni("DialogOverlay.RemoveScroll"),Jni=V.forwardRef((t,A)=>{const{__scopeDialog:e,...i}=t,n=qw(Pz,e);return W.jsx(rj,{as:Yni,allowPinchZoom:!0,shards:[n.contentRef],children:W.jsx(Ag.div,{"data-state":NmA(n.open),...i,ref:A,style:{pointerEvents:"auto",...i.style}})})}),TM="DialogContent",xEe=V.forwardRef((t,A)=>{const e=DEe(TM,t.__scopeDialog),{forceMount:i=e.forceMount,...n}=t,o=qw(TM,t.__scopeDialog);return W.jsx(q0,{present:i||o.open,children:o.modal?W.jsx(Tni,{...n,ref:A}):W.jsx(Pni,{...n,ref:A})})});xEe.displayName=TM;var Tni=V.forwardRef((t,A)=>{const e=qw(TM,t.__scopeDialog),i=V.useRef(null),n=RI(A,e.contentRef,i);return V.useEffect(()=>{const o=i.current;if(o)return VfA(o)},[]),W.jsx(_Ee,{...t,ref:n,trapFocus:e.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Vn(t.onCloseAutoFocus,o=>{o.preventDefault(),e.triggerRef.current?.focus()}),onPointerDownOutside:Vn(t.onPointerDownOutside,o=>{const s=o.detail.originalEvent,r=s.button===0&&s.ctrlKey===!0;(s.button===2||r)&&o.preventDefault()}),onFocusOutside:Vn(t.onFocusOutside,o=>o.preventDefault())})}),Pni=V.forwardRef((t,A)=>{const e=qw(TM,t.__scopeDialog),i=V.useRef(!1),n=V.useRef(!1);return W.jsx(_Ee,{...t,ref:A,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:o=>{t.onCloseAutoFocus?.(o),o.defaultPrevented||(i.current||e.triggerRef.current?.focus(),o.preventDefault()),i.current=!1,n.current=!1},onInteractOutside:o=>{t.onInteractOutside?.(o),o.defaultPrevented||(i.current=!0,o.detail.originalEvent.type==="pointerdown"&&(n.current=!0));const s=o.target;e.triggerRef.current?.contains(s)&&o.preventDefault(),o.detail.originalEvent.type==="focusin"&&n.current&&o.preventDefault()}})}),_Ee=V.forwardRef((t,A)=>{const{__scopeDialog:e,trapFocus:i,onOpenAutoFocus:n,onCloseAutoFocus:o,...s}=t,r=qw(TM,e),a=V.useRef(null),g=RI(A,a);return kfA(),W.jsxs(W.Fragment,{children:[W.jsx(Y9,{asChild:!0,loop:!0,trapped:i,onMountAutoFocus:n,onUnmountAutoFocus:o,children:W.jsx(KJ,{role:"dialog",id:r.contentId,"aria-describedby":r.descriptionId,"aria-labelledby":r.titleId,"data-state":NmA(r.open),...s,ref:g,onDismiss:()=>r.onOpenChange(!1)})}),W.jsxs(W.Fragment,{children:[W.jsx(qni,{titleId:r.titleId}),W.jsx(Wni,{contentRef:a,descriptionId:r.descriptionId})]})]})}),RmA="DialogTitle",kEe=V.forwardRef((t,A)=>{const{__scopeDialog:e,...i}=t,n=qw(RmA,e);return W.jsx(Ag.h2,{id:n.titleId,...i,ref:A})});kEe.displayName=RmA;var vEe="DialogDescription",FEe=V.forwardRef((t,A)=>{const{__scopeDialog:e,...i}=t,n=qw(vEe,e);return W.jsx(Ag.p,{id:n.descriptionId,...i,ref:A})});FEe.displayName=vEe;var MEe="DialogClose",REe=V.forwardRef((t,A)=>{const{__scopeDialog:e,...i}=t,n=qw(MEe,e);return W.jsx(Ag.button,{type:"button",...i,ref:A,onClick:Vn(t.onClick,()=>n.onOpenChange(!1))})});REe.displayName=MEe;function NmA(t){return t?"open":"closed"}var NEe="DialogTitleWarning",[Kni,GEe]=Uat(NEe,{contentName:TM,titleName:RmA,docsSlug:"dialog"}),qni=({titleId:t})=>{const A=GEe(NEe),e=`\`${A.contentName}\` requires a \`${A.titleName}\` for the component to be accessible for screen reader users.
5693
5693
 
5694
5694
  If you want to hide the \`${A.titleName}\`, you can wrap it with our VisuallyHidden component.
5695
5695
 
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@tscircuit/runframe",
3
3
  "main": "dist/preview.js",
4
4
  "type": "module",
5
- "version": "0.0.1743",
5
+ "version": "0.0.1744",
6
6
  "exports": {
7
7
  ".": "./dist/preview.js",
8
8
  "./preview": "./dist/preview.js",
@@ -51,7 +51,7 @@
51
51
  "@tscircuit/create-snippet-url": "^0.0.9",
52
52
  "@tscircuit/fake-snippets": "^0.0.163",
53
53
  "@tscircuit/file-server": "^0.0.32",
54
- "@tscircuit/pcb-viewer": "1.11.354",
54
+ "@tscircuit/pcb-viewer": "1.11.355",
55
55
  "@tscircuit/schematic-viewer": "^2.0.59",
56
56
  "@types/bun": "latest",
57
57
  "@types/debug": "^4.1.12",