@tscircuit/runframe 0.0.1899 → 0.0.1900
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.
|
@@ -1821,7 +1821,7 @@ var useErrorTelemetry = ({
|
|
|
1821
1821
|
};
|
|
1822
1822
|
|
|
1823
1823
|
// package.json
|
|
1824
|
-
var version = "0.0.
|
|
1824
|
+
var version = "0.0.1899";
|
|
1825
1825
|
var package_default = {
|
|
1826
1826
|
name: "@tscircuit/runframe",
|
|
1827
1827
|
main: "dist/preview.js",
|
|
@@ -1937,7 +1937,7 @@ var package_default = {
|
|
|
1937
1937
|
yargs: "^17.7.2"
|
|
1938
1938
|
},
|
|
1939
1939
|
dependencies: {
|
|
1940
|
-
"@tscircuit/eval": "^0.0.
|
|
1940
|
+
"@tscircuit/eval": "^0.0.803",
|
|
1941
1941
|
"@tscircuit/solver-utils": "^0.0.7"
|
|
1942
1942
|
}
|
|
1943
1943
|
};
|
package/dist/preview.js
CHANGED
package/dist/runner.js
CHANGED
|
@@ -5691,7 +5691,7 @@ test("${l} should solve problem correctly", () => {
|
|
|
5691
5691
|
// Add more specific assertions based on expected output
|
|
5692
5692
|
// expect(solver.netLabelPlacementSolver!.netLabelPlacements).toMatchInlineSnapshot()
|
|
5693
5693
|
})
|
|
5694
|
-
`,_=new Blob([u],{type:"text/plain"}),d=URL.createObjectURL(_),m=document.createElement("a");m.href=d,m.download=`${l}.test.ts`,m.click(),URL.revokeObjectURL(d)}catch(c){alert(`Error generating test.ts for ${t.constructor.name}: ${c instanceof Error?c.message:String(c)}`)}o(!1)};return G.jsxs("div",{className:`relative ${e}`,ref:r,children:[G.jsx("button",{className:"px-2 py-1 rounded text-xs cursor-pointer",onClick:()=>o(!n),title:`Download options for ${t.constructor.name}`,children:t.constructor.name}),n&&G.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:[G.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:i,children:"Download JSON"}),G.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:s,children:"Download page.tsx"}),G.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:a,children:"Download test.ts"})]})]})},v_t=t=>t.activeSubSolver?[t,...v_t(t.activeSubSolver)]:[t],$Gn=({solver:t})=>{const e=v_t(t);return G.jsx("div",{className:"flex gap-1 items-center text-sm pt-1",children:e.map((n,o)=>G.jsxs("div",{className:"flex items-center",children:[o>0&&G.jsx("span",{className:"text-gray-400 mx-1",children:"→"}),G.jsx(VGn,{solver:n})]},n.constructor.name))})},WGn=({solver:t,triggerRender:e,animationSpeed:n=25,onSolverStarted:o,onSolverCompleted:r})=>{const[i,s]=te.useReducer(p=>!p,!1),a=te.useRef(void 0),c=()=>{!t.solved&&!t.failed&&(t.step(),e())},l=()=>{!t.solved&&!t.failed&&(o&&o(t),t.solve(),e(),r&&r(t))},u=()=>{i?(a.current&&(clearInterval(a.current),a.current=void 0),s()):(s(),a.current=setInterval(()=>{if(t.solved||t.failed){a.current&&(clearInterval(a.current),a.current=void 0),s(),e(),r&&t.solved&&r(t);return}t.step(),e()},n))},_=()=>{const p=t;if(p.getCurrentPhase&&!t.solved&&!t.failed){const x=p.getCurrentPhase();for(;p.getCurrentPhase()===x&&!t.solved&&!t.failed;)t.step();e()}},d=()=>{if(t.solved||t.failed||i)return;const p=window.prompt("Step until which iteration?",`${t.iterations}`);if(p===null)return;const x=Number(p);if(!Number.isFinite(x)){window.alert("Please enter a valid number for the iteration");return}for(;t.iterations<x&&!t.solved&&!t.failed;)t.step();e(),t.solved&&r&&r(t)};te.useEffect(()=>()=>{a.current&&clearInterval(a.current)},[]),te.useEffect(()=>{(t.solved||t.failed)&&i&&(a.current&&(clearInterval(a.current),a.current=void 0),s())},[t.solved,t.failed,i]);const m=t.getCurrentPhase!==void 0,h=m?t.getCurrentPhase():null;return G.jsxs("div",{className:"space-y-2 p-2 border-b",children:[G.jsx("div",{className:"flex items-center",children:G.jsx($Gn,{solver:t})}),G.jsxs("div",{className:"flex gap-2 items-center flex-wrap",children:[G.jsx("button",{onClick:c,disabled:t.solved||t.failed||i,className:"bg-blue-500 hover:bg-blue-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Step"}),G.jsx("button",{onClick:l,disabled:t.solved||t.failed||i,className:"bg-green-500 hover:bg-green-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Solve"}),G.jsx("button",{onClick:u,disabled:t.solved||t.failed,className:`px-3 py-1 rounded text-white text-sm ${i?"bg-red-500 hover:bg-red-600":"bg-yellow-500 hover:bg-yellow-600"} disabled:bg-gray-300`,children:i?"Stop":"Animate"}),G.jsx("button",{onClick:d,disabled:t.solved||t.failed||i,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"}),m&&G.jsx("button",{onClick:_,disabled:t.solved||t.failed||i,className:"bg-purple-500 hover:bg-purple-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Next Stage"}),G.jsxs("div",{className:"text-sm text-gray-600",children:["Iterations: ",t.iterations]}),t.timeToSolve!==void 0&&G.jsxs("div",{className:"text-sm text-gray-600",children:["Time: ",(t.timeToSolve/1e3).toFixed(3),"s"]}),h&&G.jsxs("div",{className:"text-sm text-gray-600",children:["Phase: ",G.jsx("span",{className:"font-medium",children:h})]}),t.solved&&G.jsx("div",{className:"px-2 py-1 bg-green-100 text-green-800 rounded text-sm",children:"Solved"}),t.failed&&G.jsx("div",{className:"px-2 py-1 bg-red-100 text-red-800 rounded text-sm",children:"Failed"})]}),t.error&&G.jsxs("div",{className:"text-red-600 text-sm",children:["Error: ",t.error]})]})},UGn=(t,e,n)=>{const o=t.currentPipelineStepIndex;return e<o?"Completed":e===o&&t.activeSubSolver?t.activeSubSolver.failed?"Failed":"In Progress":"Not Started"},XGn=(t,e)=>{const o=t.pipelineDef[e].solverName,r=UGn(t,e),i=t[o],s=t.firstIterationOfPhase?.[o]??null,a=t.iterations;let c=0;if(r==="Completed"){const d=t.pipelineDef[e+1],m=d?t.firstIterationOfPhase?.[d.solverName]:void 0;m!==void 0&&s!==null?c=m-s:s!==null&&(c=a-s)}else r==="In Progress"&&s!==null&&(c=a-s);const l=t.timeSpentOnPhase?.[o]??0;let u=0;r==="Completed"?u=1:r==="In Progress"&&i&&(u=i.progress??0);const _=i?.stats??null;return{index:e,name:o,status:r,firstIteration:s,iterations:c,progress:u,timeSpent:l,stats:_&&Object.keys(_).length>0?_:null,solverInstance:i??null}},jGn=({status:t})=>{const e={"Not Started":"text-blue-600","In Progress":"text-yellow-600",Completed:"text-green-600",Failed:"text-red-600"};return G.jsx("span",{className:`font-medium ${e[t]}`,children:t})},GGn=({progress:t})=>{if(t===0)return null;const e=Math.round(t*100);return G.jsxs("div",{className:"flex items-center gap-2",children:[G.jsx("div",{className:"w-20 h-2 bg-gray-200 rounded overflow-hidden",children:G.jsx("div",{className:"h-full bg-blue-500 transition-all duration-200",style:{width:`${e}%`}})}),G.jsxs("span",{className:"text-xs text-gray-500",children:[e,"%"]})]})},YGn=t=>Object.entries(t).map(([e,n])=>`${e}: ${n}`).join(", "),qGn=({stats:t})=>{if(!t||Object.keys(t).length===0)return G.jsx("span",{children:"-"});const e=Object.entries(t),n=YGn(t);return G.jsxs("details",{className:"cursor-pointer",children:[G.jsx("summary",{className:"whitespace-nowrap overflow-hidden text-ellipsis max-w-[200px]",children:n}),G.jsx("div",{className:"mt-1 text-xs",children:e.map(([o,r])=>G.jsxs("div",{children:[o,": ",String(r)]},o))})]})},wge=t=>{if(t===null||typeof t!="object")return t;if(Array.isArray(t))return t.map(wge);const e={};for(const[n,o]of Object.entries(t))n.startsWith("_")||(e[n]=wge(o));return e},JGn=(t,e)=>{try{if(typeof t.getConstructorParams!="function"){alert(`getConstructorParams() is not implemented for ${e}`);return}const n=wge(t.getConstructorParams()),o=new Blob([JSON.stringify(n,null,2)],{type:"application/json"}),r=URL.createObjectURL(o),i=document.createElement("a");i.href=r,i.download=`${e}_input.json`,i.click(),URL.revokeObjectURL(r)}catch(n){alert(`Error downloading input for ${e}: ${n instanceof Error?n.message:String(n)}`)}},KGn=({solver:t,onStepUntilPhase:e,onDownloadInput:n})=>{const o=t.pipelineDef.map((a,c)=>XGn(t,c)),r=a=>{e?.(a)},i=a=>{a.solverInstance&&(n?n(a.solverInstance,a.name):JGn(a.solverInstance,a.name))},s=a=>`${(a/1e3).toFixed(2)}s`;return G.jsxs("div",{className:"border-t border-gray-200",children:[G.jsx("div",{className:"px-4 py-2 bg-gray-50 border-b border-gray-200",children:G.jsx("h3",{className:"text-sm font-semibold text-gray-700",children:"Pipeline Steps"})}),G.jsx("div",{className:"overflow-x-auto",children:G.jsxs("table",{className:"w-full text-sm",children:[G.jsx("thead",{children:G.jsxs("tr",{className:"bg-gray-50 border-b border-gray-200",children:[G.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Step"}),G.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Status"}),G.jsxs("th",{className:"px-4 py-2 text-center font-semibold text-gray-700",children:["i",G.jsx("sub",{children:"0"})]}),G.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Iterations"}),G.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Progress"}),G.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Time"}),G.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Stats"}),G.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Input"})]})}),G.jsx("tbody",{children:o.map(a=>G.jsxs("tr",{className:`border-b border-gray-100 ${a.status==="In Progress"?"bg-yellow-50":""}`,children:[G.jsx("td",{className:"px-4 py-2",children:G.jsxs("div",{className:"flex items-center gap-2",children:[G.jsx("span",{className:"text-gray-400 w-6",children:String(a.index+1).padStart(2,"0")}),G.jsx("button",{onClick:()=>r(a.name),disabled:a.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 ${a.name} completes`,children:G.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:G.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"})})}),G.jsx("span",{className:"font-medium text-gray-900",children:a.name})]})}),G.jsx("td",{className:"px-4 py-2",children:G.jsx(jGn,{status:a.status})}),G.jsx("td",{className:"px-4 py-2 text-center text-gray-600",children:a.firstIteration!==null?a.firstIteration:""}),G.jsx("td",{className:"px-4 py-2 text-gray-600",children:a.iterations}),G.jsx("td",{className:"px-4 py-2",children:G.jsx(GGn,{progress:a.progress})}),G.jsx("td",{className:"px-4 py-2 text-gray-600",children:s(a.timeSpent)}),G.jsx("td",{className:"px-4 py-2 text-gray-500",children:G.jsx(qGn,{stats:a.stats})}),G.jsx("td",{className:"px-4 py-2",children:a.solverInstance?G.jsxs("button",{onClick:()=>i(a),className:"flex items-center gap-1 text-blue-500 hover:text-blue-700",title:`Download input for ${a.name}`,children:[G.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:G.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"})}),G.jsx("span",{children:"Input"})]}):null})]},a.name))})]})})]})},QGn=class extends ar.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 ZGn({graphics:t}){const e=t.points??[],n=t.lines??[],o=t.rects??[],r=t.circles??[],i=t.texts??[];let s=Number.POSITIVE_INFINITY,a=Number.POSITIVE_INFINITY,c=Number.NEGATIVE_INFINITY,l=Number.NEGATIVE_INFINITY;const u=(x,f)=>{typeof x=="number"&&(x<s&&(s=x),x>c&&(c=x)),typeof f=="number"&&(f<a&&(a=f),f>l&&(l=f))};for(const x of e)u(x.x,x.y);for(const x of n){const f=x.points??[];for(const g of f)u(g.x,g.y)}for(const x of o){const f=x.x??0,g=x.y??0,y=x.width??0,b=x.height??0;u(f,g),u(f+y,g+b)}for(const x of r){const f=x.x??0,g=x.y??0,y=x.radius??1;u(f-y,g-y),u(f+y,g+y)}for(const x of i)u(x.x,x.y);(!isFinite(s)||!isFinite(a)||!isFinite(c)||!isFinite(l))&&(s=-20,a=-20,c=20,l=20);const _=10,d=s-_,m=a-_,h=Math.max(1,c-s+2*_),p=Math.max(1,l-a+2*_);return G.jsxs("svg",{className:"w-full h-[400px] bg-white",viewBox:`${d} ${m} ${h} ${p}`,role:"img","aria-label":"Graphics fallback",children:[o.map((x,f)=>G.jsx("rect",{x:x.x??0,y:x.y??0,width:x.width??0,height:x.height??0,fill:"none",stroke:x.strokeColor??"black",strokeWidth:x.strokeWidth??1},`rect-${f}`)),n.map((x,f)=>G.jsx("polyline",{fill:"none",stroke:x.strokeColor??"black",strokeWidth:x.strokeWidth??1,points:(x.points??[]).map(g=>`${g.x??0},${g.y??0}`).join(" ")},`line-${f}`)),r.map((x,f)=>G.jsx("circle",{cx:x.x??0,cy:x.y??0,r:x.radius??1.5,fill:x.fillColor??"none",stroke:x.strokeColor??"black",strokeWidth:x.strokeWidth??1},`circle-${f}`)),e.map((x,f)=>G.jsx("circle",{cx:x.x??0,cy:x.y??0,r:x.radius??1.5,fill:x.color??"black"},`point-${f}`)),i.map((x,f)=>G.jsx("text",{x:x.x??0,y:x.y??0,fontSize:x.fontSize??10,fill:x.color??"black",children:x.text??""},`text-${f}`))]})}var eYn=({solver:t,animationSpeed:e=25,onSolverStarted:n,onSolverCompleted:o})=>{const[r,i]=te.useReducer(u=>u+1,0),s=te.useMemo(()=>{try{return t.visualize()||{points:[],lines:[],rects:[],circles:[]}}catch(u){return console.error("Visualization error:",u),{points:[],lines:[],rects:[],circles:[]}}},[t,r]),a=te.useMemo(()=>(s.rects?.length||0)===0&&(s.lines?.length||0)===0&&(s.points?.length||0)===0&&(s.circles?.length||0)===0,[s]);te.useEffect(()=>{if(!(typeof document>"u")&&!document.querySelector('script[src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4"]')){const u=document.createElement("script");u.src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4",document.head.appendChild(u)}},[]);const c=t.pipelineDef!==void 0,l=u=>{const _=t;if(!t.solved&&!t.failed){for(;!t.solved&&!t.failed&&_.currentPipelineStepIndex<=_.pipelineDef.findIndex(d=>d.solverName===u);)t.step();i()}};return G.jsxs("div",{children:[G.jsx(WGn,{solver:t,triggerRender:i,animationSpeed:e,onSolverStarted:n,onSolverCompleted:o}),a?G.jsx("div",{className:"p-4 text-gray-500",children:"No Graphics Yet"}):G.jsx(QGn,{fallback:G.jsx(ZGn,{graphics:s}),children:G.jsx(zGn,{graphics:s})}),c&&G.jsx(KGn,{solver:t,onStepUntilPhase:l})]})};const tYn=()=>{te.useEffect(()=>{const t="tailwind-cdn-script";if(document.getElementById(t)||window.tailwind)return;const e=document.createElement("div");e.className="hidden",document.body.appendChild(e);const n=window.getComputedStyle(e).display==="none";if(document.body.removeChild(e),n)return;const o=document.createElement("script");o.id=t,o.src="https://cdn.tailwindcss.com",document.head.appendChild(o)},[])},nYn=t=>t.toLowerCase().includes("pack")?YTn:t.toLowerCase().includes("rout")?ewn:BTn,oYn=({solverEvents:t=[]})=>{const[e,n]=te.useState(null);tYn();const o=te.useMemo(()=>{const a=new Map;for(const c of t){const l=`${c.componentName}-${c.solverName}`;a.set(l,c)}return a},[t]),r=te.useMemo(()=>Array.from(o.keys()),[o]),i=e?o.get(e):null,s=te.useMemo(()=>{if(!i)return{instance:null,error:null,classFound:!1};const a=Wae[i.solverName];if(!a)return{instance:null,error:`Solver class "${i.solverName}" not found in SOLVERS registry. Available: ${Object.keys(Wae).join(", ")}`,classFound:!1};try{const c=i.solverParams,l=c?.input!==void 0?c.input:c;return{instance:new a(l),error:null,classFound:!0}}catch(c){const l=c instanceof Error?c.message:String(c);return console.error("Failed to reconstruct solver:",c),{instance:null,error:`Failed to instantiate solver: ${l}`,classFound:!0}}},[i]);return t.length===0?G.jsx("div",{className:"rf-p-4",children:G.jsx("div",{className:"rf-bg-gray-50 rf-rounded-md rf-border rf-border-gray-200",children:G.jsxs("div",{className:"rf-p-4",children:[G.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800 rf-mb-3",children:"No Solvers Detected"}),G.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."})]})})}):G.jsxs("div",{className:"rf-flex rf-h-full rf-overflow-hidden",children:[G.jsxs("div",{className:"rf-w-64 rf-border-r rf-border-gray-200 rf-overflow-y-auto rf-flex-shrink-0",children:[G.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:[r.length," ",r.length===1?"Solver":"Solvers"]}),r.map(a=>{const c=o.get(a),l=e===a;return G.jsx("div",{className:`rf-px-3 rf-py-2 rf-cursor-pointer rf-border-b rf-border-gray-100 ${l?"rf-bg-blue-50 rf-border-l-2 rf-border-l-blue-500":"hover:rf-bg-gray-50"}`,onClick:()=>n(a),children:(()=>{const u=nYn(c.solverName);return G.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2",children:[G.jsx(u,{className:"rf-w-4 rf-h-4 rf-text-blue-500 rf-flex-shrink-0"}),G.jsxs("div",{className:"rf-flex-1 rf-min-w-0",children:[G.jsx("div",{className:"rf-text-sm rf-font-medium rf-text-gray-800 rf-truncate",children:c.componentName}),G.jsx("div",{className:"rf-text-xs rf-text-gray-500 rf-truncate",children:c.solverName})]})]})})()},a)})]}),G.jsx("div",{className:"rf-flex-1 rf-overflow-hidden",children:i?s.instance?G.jsx(q6,{fallback:G.jsx("div",{className:"rf-p-4",children:G.jsxs("div",{className:"rf-bg-red-50 rf-rounded-md rf-border rf-border-red-200 rf-p-4",children:[G.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-red-800 rf-mb-2",children:"Error Loading Solver Debugger"}),G.jsxs("p",{className:"rf-text-sm rf-text-red-600",children:["Failed to render the solver debugger for"," ",i.solverName]})]})}),children:G.jsx(eYn,{solver:s.instance})}):G.jsxs("div",{className:"rf-p-4",children:[G.jsxs("div",{className:"rf-mb-4",children:[G.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800",children:i.solverName}),G.jsxs("p",{className:"rf-text-sm rf-text-gray-500",children:["Component: ",i.componentName]})]}),s.error&&G.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:G.jsx("p",{className:`rf-text-sm ${s.classFound?"rf-text-red-700":"rf-text-yellow-700"}`,children:s.error})}),G.jsxs("div",{className:"rf-border rf-border-gray-200 rf-rounded-md rf-overflow-hidden",children:[G.jsx("div",{className:"rf-px-3 rf-py-2 rf-bg-gray-50",children:G.jsx("span",{className:"rf-text-sm rf-font-medium rf-text-gray-700",children:"Solver Parameters"})}),G.jsx("div",{className:"rf-p-3 rf-bg-white rf-border-t rf-border-gray-200",children:G.jsx("pre",{className:"rf-text-xs rf-font-mono rf-text-gray-600 rf-whitespace-pre-wrap rf-overflow-x-auto",children:JSON.stringify(i.solverParams,null,2)})})]})]}):G.jsx("div",{className:"rf-flex rf-items-center rf-justify-center rf-h-full",children:G.jsx("p",{className:"rf-text-sm rf-text-gray-500",children:"Select a solver from the list to view details"})})})]})},S_t=({errorMessage:t,errorStack:e,circuitJsonErrors:n})=>{te.useEffect(()=>{if(t){const o=new Error(t);e&&(o.stack=e);try{bL.captureException(o)}catch{}}},[t,e]),te.useEffect(()=>{if(n&&n.length>0)for(const o of n){const r=new Error(o.message||"Circuit JSON Error");o.stack&&(r.stack=o.stack);try{bL.captureException(r,{error_type:o.type})}catch{}}},[n])},C_t="0.0.1898",rYn={version:C_t},Ege={BASE_URL:"/",DEV:!1,MODE:"production",PROD:!0,SSR:!1},Dge=new Map,HG=t=>{const e=Dge.get(t);return e?Object.fromEntries(Object.entries(e.stores).map(([n,o])=>[n,o.getState()])):{}},iYn=(t,e,n)=>{if(t===void 0)return{type:"untracked",connection:e.connect(n)};const o=Dge.get(n.name);if(o)return{type:"tracked",store:t,...o};const r={connection:e.connect(n),stores:{}};return Dge.set(n.name,r),{type:"tracked",store:t,...r}},M_t=(t,e={})=>(n,o,r)=>{const{enabled:i,anonymousActionType:s,store:a,...c}=e;let l;try{l=(i??(Ege?"production":void 0)!=="production")&&window.__REDUX_DEVTOOLS_EXTENSION__}catch{}if(!l)return(Ege?"production":void 0)!=="production"&&i&&console.warn("[zustand devtools middleware] Please install/enable Redux devtools extension"),t(n,o,r);const{connection:u,..._}=iYn(a,l,c);let d=!0;r.setState=(p,x,f)=>{const g=n(p,x);if(!d)return g;const y=f===void 0?{type:s||"anonymous"}:typeof f=="string"?{type:f}:f;return a===void 0?(u?.send(y,o()),g):(u?.send({...y,type:`${a}/${y.type}`},{...HG(c.name),[a]:r.getState()}),g)};const m=(...p)=>{const x=d;d=!1,n(...p),d=x},h=t(r.setState,o,r);if(_.type==="untracked"?u?.init(h):(_.stores[_.store]=r,u?.init(Object.fromEntries(Object.entries(_.stores).map(([p,x])=>[p,p===_.store?h:x.getState()])))),r.dispatchFromDevtools&&typeof r.dispatch=="function"){let p=!1;const x=r.dispatch;r.dispatch=(...f)=>{(Ege?"production":void 0)!=="production"&&f[0].type==="__setState"&&!p&&(console.warn('[zustand devtools middleware] "__setState" action type is reserved to set state from the devtools. Avoid using it.'),p=!0),x(...f)}}return u.subscribe(p=>{var x;switch(p.type){case"ACTION":if(typeof p.payload!="string"){console.error("[zustand devtools middleware] Unsupported action format");return}return Age(p.payload,f=>{if(f.type==="__setState"){if(a===void 0){m(f.state);return}Object.keys(f.state).length!==1&&console.error(`
|
|
5694
|
+
`,_=new Blob([u],{type:"text/plain"}),d=URL.createObjectURL(_),m=document.createElement("a");m.href=d,m.download=`${l}.test.ts`,m.click(),URL.revokeObjectURL(d)}catch(c){alert(`Error generating test.ts for ${t.constructor.name}: ${c instanceof Error?c.message:String(c)}`)}o(!1)};return G.jsxs("div",{className:`relative ${e}`,ref:r,children:[G.jsx("button",{className:"px-2 py-1 rounded text-xs cursor-pointer",onClick:()=>o(!n),title:`Download options for ${t.constructor.name}`,children:t.constructor.name}),n&&G.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:[G.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:i,children:"Download JSON"}),G.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:s,children:"Download page.tsx"}),G.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:a,children:"Download test.ts"})]})]})},v_t=t=>t.activeSubSolver?[t,...v_t(t.activeSubSolver)]:[t],$Gn=({solver:t})=>{const e=v_t(t);return G.jsx("div",{className:"flex gap-1 items-center text-sm pt-1",children:e.map((n,o)=>G.jsxs("div",{className:"flex items-center",children:[o>0&&G.jsx("span",{className:"text-gray-400 mx-1",children:"→"}),G.jsx(VGn,{solver:n})]},n.constructor.name))})},WGn=({solver:t,triggerRender:e,animationSpeed:n=25,onSolverStarted:o,onSolverCompleted:r})=>{const[i,s]=te.useReducer(p=>!p,!1),a=te.useRef(void 0),c=()=>{!t.solved&&!t.failed&&(t.step(),e())},l=()=>{!t.solved&&!t.failed&&(o&&o(t),t.solve(),e(),r&&r(t))},u=()=>{i?(a.current&&(clearInterval(a.current),a.current=void 0),s()):(s(),a.current=setInterval(()=>{if(t.solved||t.failed){a.current&&(clearInterval(a.current),a.current=void 0),s(),e(),r&&t.solved&&r(t);return}t.step(),e()},n))},_=()=>{const p=t;if(p.getCurrentPhase&&!t.solved&&!t.failed){const x=p.getCurrentPhase();for(;p.getCurrentPhase()===x&&!t.solved&&!t.failed;)t.step();e()}},d=()=>{if(t.solved||t.failed||i)return;const p=window.prompt("Step until which iteration?",`${t.iterations}`);if(p===null)return;const x=Number(p);if(!Number.isFinite(x)){window.alert("Please enter a valid number for the iteration");return}for(;t.iterations<x&&!t.solved&&!t.failed;)t.step();e(),t.solved&&r&&r(t)};te.useEffect(()=>()=>{a.current&&clearInterval(a.current)},[]),te.useEffect(()=>{(t.solved||t.failed)&&i&&(a.current&&(clearInterval(a.current),a.current=void 0),s())},[t.solved,t.failed,i]);const m=t.getCurrentPhase!==void 0,h=m?t.getCurrentPhase():null;return G.jsxs("div",{className:"space-y-2 p-2 border-b",children:[G.jsx("div",{className:"flex items-center",children:G.jsx($Gn,{solver:t})}),G.jsxs("div",{className:"flex gap-2 items-center flex-wrap",children:[G.jsx("button",{onClick:c,disabled:t.solved||t.failed||i,className:"bg-blue-500 hover:bg-blue-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Step"}),G.jsx("button",{onClick:l,disabled:t.solved||t.failed||i,className:"bg-green-500 hover:bg-green-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Solve"}),G.jsx("button",{onClick:u,disabled:t.solved||t.failed,className:`px-3 py-1 rounded text-white text-sm ${i?"bg-red-500 hover:bg-red-600":"bg-yellow-500 hover:bg-yellow-600"} disabled:bg-gray-300`,children:i?"Stop":"Animate"}),G.jsx("button",{onClick:d,disabled:t.solved||t.failed||i,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"}),m&&G.jsx("button",{onClick:_,disabled:t.solved||t.failed||i,className:"bg-purple-500 hover:bg-purple-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Next Stage"}),G.jsxs("div",{className:"text-sm text-gray-600",children:["Iterations: ",t.iterations]}),t.timeToSolve!==void 0&&G.jsxs("div",{className:"text-sm text-gray-600",children:["Time: ",(t.timeToSolve/1e3).toFixed(3),"s"]}),h&&G.jsxs("div",{className:"text-sm text-gray-600",children:["Phase: ",G.jsx("span",{className:"font-medium",children:h})]}),t.solved&&G.jsx("div",{className:"px-2 py-1 bg-green-100 text-green-800 rounded text-sm",children:"Solved"}),t.failed&&G.jsx("div",{className:"px-2 py-1 bg-red-100 text-red-800 rounded text-sm",children:"Failed"})]}),t.error&&G.jsxs("div",{className:"text-red-600 text-sm",children:["Error: ",t.error]})]})},UGn=(t,e,n)=>{const o=t.currentPipelineStepIndex;return e<o?"Completed":e===o&&t.activeSubSolver?t.activeSubSolver.failed?"Failed":"In Progress":"Not Started"},XGn=(t,e)=>{const o=t.pipelineDef[e].solverName,r=UGn(t,e),i=t[o],s=t.firstIterationOfPhase?.[o]??null,a=t.iterations;let c=0;if(r==="Completed"){const d=t.pipelineDef[e+1],m=d?t.firstIterationOfPhase?.[d.solverName]:void 0;m!==void 0&&s!==null?c=m-s:s!==null&&(c=a-s)}else r==="In Progress"&&s!==null&&(c=a-s);const l=t.timeSpentOnPhase?.[o]??0;let u=0;r==="Completed"?u=1:r==="In Progress"&&i&&(u=i.progress??0);const _=i?.stats??null;return{index:e,name:o,status:r,firstIteration:s,iterations:c,progress:u,timeSpent:l,stats:_&&Object.keys(_).length>0?_:null,solverInstance:i??null}},jGn=({status:t})=>{const e={"Not Started":"text-blue-600","In Progress":"text-yellow-600",Completed:"text-green-600",Failed:"text-red-600"};return G.jsx("span",{className:`font-medium ${e[t]}`,children:t})},GGn=({progress:t})=>{if(t===0)return null;const e=Math.round(t*100);return G.jsxs("div",{className:"flex items-center gap-2",children:[G.jsx("div",{className:"w-20 h-2 bg-gray-200 rounded overflow-hidden",children:G.jsx("div",{className:"h-full bg-blue-500 transition-all duration-200",style:{width:`${e}%`}})}),G.jsxs("span",{className:"text-xs text-gray-500",children:[e,"%"]})]})},YGn=t=>Object.entries(t).map(([e,n])=>`${e}: ${n}`).join(", "),qGn=({stats:t})=>{if(!t||Object.keys(t).length===0)return G.jsx("span",{children:"-"});const e=Object.entries(t),n=YGn(t);return G.jsxs("details",{className:"cursor-pointer",children:[G.jsx("summary",{className:"whitespace-nowrap overflow-hidden text-ellipsis max-w-[200px]",children:n}),G.jsx("div",{className:"mt-1 text-xs",children:e.map(([o,r])=>G.jsxs("div",{children:[o,": ",String(r)]},o))})]})},wge=t=>{if(t===null||typeof t!="object")return t;if(Array.isArray(t))return t.map(wge);const e={};for(const[n,o]of Object.entries(t))n.startsWith("_")||(e[n]=wge(o));return e},JGn=(t,e)=>{try{if(typeof t.getConstructorParams!="function"){alert(`getConstructorParams() is not implemented for ${e}`);return}const n=wge(t.getConstructorParams()),o=new Blob([JSON.stringify(n,null,2)],{type:"application/json"}),r=URL.createObjectURL(o),i=document.createElement("a");i.href=r,i.download=`${e}_input.json`,i.click(),URL.revokeObjectURL(r)}catch(n){alert(`Error downloading input for ${e}: ${n instanceof Error?n.message:String(n)}`)}},KGn=({solver:t,onStepUntilPhase:e,onDownloadInput:n})=>{const o=t.pipelineDef.map((a,c)=>XGn(t,c)),r=a=>{e?.(a)},i=a=>{a.solverInstance&&(n?n(a.solverInstance,a.name):JGn(a.solverInstance,a.name))},s=a=>`${(a/1e3).toFixed(2)}s`;return G.jsxs("div",{className:"border-t border-gray-200",children:[G.jsx("div",{className:"px-4 py-2 bg-gray-50 border-b border-gray-200",children:G.jsx("h3",{className:"text-sm font-semibold text-gray-700",children:"Pipeline Steps"})}),G.jsx("div",{className:"overflow-x-auto",children:G.jsxs("table",{className:"w-full text-sm",children:[G.jsx("thead",{children:G.jsxs("tr",{className:"bg-gray-50 border-b border-gray-200",children:[G.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Step"}),G.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Status"}),G.jsxs("th",{className:"px-4 py-2 text-center font-semibold text-gray-700",children:["i",G.jsx("sub",{children:"0"})]}),G.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Iterations"}),G.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Progress"}),G.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Time"}),G.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Stats"}),G.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Input"})]})}),G.jsx("tbody",{children:o.map(a=>G.jsxs("tr",{className:`border-b border-gray-100 ${a.status==="In Progress"?"bg-yellow-50":""}`,children:[G.jsx("td",{className:"px-4 py-2",children:G.jsxs("div",{className:"flex items-center gap-2",children:[G.jsx("span",{className:"text-gray-400 w-6",children:String(a.index+1).padStart(2,"0")}),G.jsx("button",{onClick:()=>r(a.name),disabled:a.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 ${a.name} completes`,children:G.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:G.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"})})}),G.jsx("span",{className:"font-medium text-gray-900",children:a.name})]})}),G.jsx("td",{className:"px-4 py-2",children:G.jsx(jGn,{status:a.status})}),G.jsx("td",{className:"px-4 py-2 text-center text-gray-600",children:a.firstIteration!==null?a.firstIteration:""}),G.jsx("td",{className:"px-4 py-2 text-gray-600",children:a.iterations}),G.jsx("td",{className:"px-4 py-2",children:G.jsx(GGn,{progress:a.progress})}),G.jsx("td",{className:"px-4 py-2 text-gray-600",children:s(a.timeSpent)}),G.jsx("td",{className:"px-4 py-2 text-gray-500",children:G.jsx(qGn,{stats:a.stats})}),G.jsx("td",{className:"px-4 py-2",children:a.solverInstance?G.jsxs("button",{onClick:()=>i(a),className:"flex items-center gap-1 text-blue-500 hover:text-blue-700",title:`Download input for ${a.name}`,children:[G.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:G.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"})}),G.jsx("span",{children:"Input"})]}):null})]},a.name))})]})})]})},QGn=class extends ar.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 ZGn({graphics:t}){const e=t.points??[],n=t.lines??[],o=t.rects??[],r=t.circles??[],i=t.texts??[];let s=Number.POSITIVE_INFINITY,a=Number.POSITIVE_INFINITY,c=Number.NEGATIVE_INFINITY,l=Number.NEGATIVE_INFINITY;const u=(x,f)=>{typeof x=="number"&&(x<s&&(s=x),x>c&&(c=x)),typeof f=="number"&&(f<a&&(a=f),f>l&&(l=f))};for(const x of e)u(x.x,x.y);for(const x of n){const f=x.points??[];for(const g of f)u(g.x,g.y)}for(const x of o){const f=x.x??0,g=x.y??0,y=x.width??0,b=x.height??0;u(f,g),u(f+y,g+b)}for(const x of r){const f=x.x??0,g=x.y??0,y=x.radius??1;u(f-y,g-y),u(f+y,g+y)}for(const x of i)u(x.x,x.y);(!isFinite(s)||!isFinite(a)||!isFinite(c)||!isFinite(l))&&(s=-20,a=-20,c=20,l=20);const _=10,d=s-_,m=a-_,h=Math.max(1,c-s+2*_),p=Math.max(1,l-a+2*_);return G.jsxs("svg",{className:"w-full h-[400px] bg-white",viewBox:`${d} ${m} ${h} ${p}`,role:"img","aria-label":"Graphics fallback",children:[o.map((x,f)=>G.jsx("rect",{x:x.x??0,y:x.y??0,width:x.width??0,height:x.height??0,fill:"none",stroke:x.strokeColor??"black",strokeWidth:x.strokeWidth??1},`rect-${f}`)),n.map((x,f)=>G.jsx("polyline",{fill:"none",stroke:x.strokeColor??"black",strokeWidth:x.strokeWidth??1,points:(x.points??[]).map(g=>`${g.x??0},${g.y??0}`).join(" ")},`line-${f}`)),r.map((x,f)=>G.jsx("circle",{cx:x.x??0,cy:x.y??0,r:x.radius??1.5,fill:x.fillColor??"none",stroke:x.strokeColor??"black",strokeWidth:x.strokeWidth??1},`circle-${f}`)),e.map((x,f)=>G.jsx("circle",{cx:x.x??0,cy:x.y??0,r:x.radius??1.5,fill:x.color??"black"},`point-${f}`)),i.map((x,f)=>G.jsx("text",{x:x.x??0,y:x.y??0,fontSize:x.fontSize??10,fill:x.color??"black",children:x.text??""},`text-${f}`))]})}var eYn=({solver:t,animationSpeed:e=25,onSolverStarted:n,onSolverCompleted:o})=>{const[r,i]=te.useReducer(u=>u+1,0),s=te.useMemo(()=>{try{return t.visualize()||{points:[],lines:[],rects:[],circles:[]}}catch(u){return console.error("Visualization error:",u),{points:[],lines:[],rects:[],circles:[]}}},[t,r]),a=te.useMemo(()=>(s.rects?.length||0)===0&&(s.lines?.length||0)===0&&(s.points?.length||0)===0&&(s.circles?.length||0)===0,[s]);te.useEffect(()=>{if(!(typeof document>"u")&&!document.querySelector('script[src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4"]')){const u=document.createElement("script");u.src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4",document.head.appendChild(u)}},[]);const c=t.pipelineDef!==void 0,l=u=>{const _=t;if(!t.solved&&!t.failed){for(;!t.solved&&!t.failed&&_.currentPipelineStepIndex<=_.pipelineDef.findIndex(d=>d.solverName===u);)t.step();i()}};return G.jsxs("div",{children:[G.jsx(WGn,{solver:t,triggerRender:i,animationSpeed:e,onSolverStarted:n,onSolverCompleted:o}),a?G.jsx("div",{className:"p-4 text-gray-500",children:"No Graphics Yet"}):G.jsx(QGn,{fallback:G.jsx(ZGn,{graphics:s}),children:G.jsx(zGn,{graphics:s})}),c&&G.jsx(KGn,{solver:t,onStepUntilPhase:l})]})};const tYn=()=>{te.useEffect(()=>{const t="tailwind-cdn-script";if(document.getElementById(t)||window.tailwind)return;const e=document.createElement("div");e.className="hidden",document.body.appendChild(e);const n=window.getComputedStyle(e).display==="none";if(document.body.removeChild(e),n)return;const o=document.createElement("script");o.id=t,o.src="https://cdn.tailwindcss.com",document.head.appendChild(o)},[])},nYn=t=>t.toLowerCase().includes("pack")?YTn:t.toLowerCase().includes("rout")?ewn:BTn,oYn=({solverEvents:t=[]})=>{const[e,n]=te.useState(null);tYn();const o=te.useMemo(()=>{const a=new Map;for(const c of t){const l=`${c.componentName}-${c.solverName}`;a.set(l,c)}return a},[t]),r=te.useMemo(()=>Array.from(o.keys()),[o]),i=e?o.get(e):null,s=te.useMemo(()=>{if(!i)return{instance:null,error:null,classFound:!1};const a=Wae[i.solverName];if(!a)return{instance:null,error:`Solver class "${i.solverName}" not found in SOLVERS registry. Available: ${Object.keys(Wae).join(", ")}`,classFound:!1};try{const c=i.solverParams,l=c?.input!==void 0?c.input:c;return{instance:new a(l),error:null,classFound:!0}}catch(c){const l=c instanceof Error?c.message:String(c);return console.error("Failed to reconstruct solver:",c),{instance:null,error:`Failed to instantiate solver: ${l}`,classFound:!0}}},[i]);return t.length===0?G.jsx("div",{className:"rf-p-4",children:G.jsx("div",{className:"rf-bg-gray-50 rf-rounded-md rf-border rf-border-gray-200",children:G.jsxs("div",{className:"rf-p-4",children:[G.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800 rf-mb-3",children:"No Solvers Detected"}),G.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."})]})})}):G.jsxs("div",{className:"rf-flex rf-h-full rf-overflow-hidden",children:[G.jsxs("div",{className:"rf-w-64 rf-border-r rf-border-gray-200 rf-overflow-y-auto rf-flex-shrink-0",children:[G.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:[r.length," ",r.length===1?"Solver":"Solvers"]}),r.map(a=>{const c=o.get(a),l=e===a;return G.jsx("div",{className:`rf-px-3 rf-py-2 rf-cursor-pointer rf-border-b rf-border-gray-100 ${l?"rf-bg-blue-50 rf-border-l-2 rf-border-l-blue-500":"hover:rf-bg-gray-50"}`,onClick:()=>n(a),children:(()=>{const u=nYn(c.solverName);return G.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2",children:[G.jsx(u,{className:"rf-w-4 rf-h-4 rf-text-blue-500 rf-flex-shrink-0"}),G.jsxs("div",{className:"rf-flex-1 rf-min-w-0",children:[G.jsx("div",{className:"rf-text-sm rf-font-medium rf-text-gray-800 rf-truncate",children:c.componentName}),G.jsx("div",{className:"rf-text-xs rf-text-gray-500 rf-truncate",children:c.solverName})]})]})})()},a)})]}),G.jsx("div",{className:"rf-flex-1 rf-overflow-hidden",children:i?s.instance?G.jsx(q6,{fallback:G.jsx("div",{className:"rf-p-4",children:G.jsxs("div",{className:"rf-bg-red-50 rf-rounded-md rf-border rf-border-red-200 rf-p-4",children:[G.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-red-800 rf-mb-2",children:"Error Loading Solver Debugger"}),G.jsxs("p",{className:"rf-text-sm rf-text-red-600",children:["Failed to render the solver debugger for"," ",i.solverName]})]})}),children:G.jsx(eYn,{solver:s.instance})}):G.jsxs("div",{className:"rf-p-4",children:[G.jsxs("div",{className:"rf-mb-4",children:[G.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800",children:i.solverName}),G.jsxs("p",{className:"rf-text-sm rf-text-gray-500",children:["Component: ",i.componentName]})]}),s.error&&G.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:G.jsx("p",{className:`rf-text-sm ${s.classFound?"rf-text-red-700":"rf-text-yellow-700"}`,children:s.error})}),G.jsxs("div",{className:"rf-border rf-border-gray-200 rf-rounded-md rf-overflow-hidden",children:[G.jsx("div",{className:"rf-px-3 rf-py-2 rf-bg-gray-50",children:G.jsx("span",{className:"rf-text-sm rf-font-medium rf-text-gray-700",children:"Solver Parameters"})}),G.jsx("div",{className:"rf-p-3 rf-bg-white rf-border-t rf-border-gray-200",children:G.jsx("pre",{className:"rf-text-xs rf-font-mono rf-text-gray-600 rf-whitespace-pre-wrap rf-overflow-x-auto",children:JSON.stringify(i.solverParams,null,2)})})]})]}):G.jsx("div",{className:"rf-flex rf-items-center rf-justify-center rf-h-full",children:G.jsx("p",{className:"rf-text-sm rf-text-gray-500",children:"Select a solver from the list to view details"})})})]})},S_t=({errorMessage:t,errorStack:e,circuitJsonErrors:n})=>{te.useEffect(()=>{if(t){const o=new Error(t);e&&(o.stack=e);try{bL.captureException(o)}catch{}}},[t,e]),te.useEffect(()=>{if(n&&n.length>0)for(const o of n){const r=new Error(o.message||"Circuit JSON Error");o.stack&&(r.stack=o.stack);try{bL.captureException(r,{error_type:o.type})}catch{}}},[n])},C_t="0.0.1899",rYn={version:C_t},Ege={BASE_URL:"/",DEV:!1,MODE:"production",PROD:!0,SSR:!1},Dge=new Map,HG=t=>{const e=Dge.get(t);return e?Object.fromEntries(Object.entries(e.stores).map(([n,o])=>[n,o.getState()])):{}},iYn=(t,e,n)=>{if(t===void 0)return{type:"untracked",connection:e.connect(n)};const o=Dge.get(n.name);if(o)return{type:"tracked",store:t,...o};const r={connection:e.connect(n),stores:{}};return Dge.set(n.name,r),{type:"tracked",store:t,...r}},M_t=(t,e={})=>(n,o,r)=>{const{enabled:i,anonymousActionType:s,store:a,...c}=e;let l;try{l=(i??(Ege?"production":void 0)!=="production")&&window.__REDUX_DEVTOOLS_EXTENSION__}catch{}if(!l)return(Ege?"production":void 0)!=="production"&&i&&console.warn("[zustand devtools middleware] Please install/enable Redux devtools extension"),t(n,o,r);const{connection:u,..._}=iYn(a,l,c);let d=!0;r.setState=(p,x,f)=>{const g=n(p,x);if(!d)return g;const y=f===void 0?{type:s||"anonymous"}:typeof f=="string"?{type:f}:f;return a===void 0?(u?.send(y,o()),g):(u?.send({...y,type:`${a}/${y.type}`},{...HG(c.name),[a]:r.getState()}),g)};const m=(...p)=>{const x=d;d=!1,n(...p),d=x},h=t(r.setState,o,r);if(_.type==="untracked"?u?.init(h):(_.stores[_.store]=r,u?.init(Object.fromEntries(Object.entries(_.stores).map(([p,x])=>[p,p===_.store?h:x.getState()])))),r.dispatchFromDevtools&&typeof r.dispatch=="function"){let p=!1;const x=r.dispatch;r.dispatch=(...f)=>{(Ege?"production":void 0)!=="production"&&f[0].type==="__setState"&&!p&&(console.warn('[zustand devtools middleware] "__setState" action type is reserved to set state from the devtools. Avoid using it.'),p=!0),x(...f)}}return u.subscribe(p=>{var x;switch(p.type){case"ACTION":if(typeof p.payload!="string"){console.error("[zustand devtools middleware] Unsupported action format");return}return Age(p.payload,f=>{if(f.type==="__setState"){if(a===void 0){m(f.state);return}Object.keys(f.state).length!==1&&console.error(`
|
|
5695
5695
|
[zustand devtools middleware] Unsupported __setState action format.
|
|
5696
5696
|
When using 'store' option in devtools(), the 'state' should have only one key, which is a value of 'store' that was passed in devtools(),
|
|
5697
5697
|
and value of this only key should be a state object. Example: { "type": "__setState", "state": { "abc123Store": { "foo": "bar" } } }
|
package/dist/standalone.min.js
CHANGED
|
@@ -5695,7 +5695,7 @@ test("${l} should solve problem correctly", () => {
|
|
|
5695
5695
|
// Add more specific assertions based on expected output
|
|
5696
5696
|
// expect(solver.netLabelPlacementSolver!.netLabelPlacements).toMatchInlineSnapshot()
|
|
5697
5697
|
})
|
|
5698
|
-
`,_=new Blob([u],{type:"text/plain"}),d=URL.createObjectURL(_),m=document.createElement("a");m.href=d,m.download=`${l}.test.ts`,m.click(),URL.revokeObjectURL(d)}catch(c){alert(`Error generating test.ts for ${t.constructor.name}: ${c instanceof Error?c.message:String(c)}`)}o(!1)};return G.jsxs("div",{className:`relative ${e}`,ref:r,children:[G.jsx("button",{className:"px-2 py-1 rounded text-xs cursor-pointer",onClick:()=>o(!n),title:`Download options for ${t.constructor.name}`,children:t.constructor.name}),n&&G.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:[G.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:i,children:"Download JSON"}),G.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:s,children:"Download page.tsx"}),G.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:a,children:"Download test.ts"})]})]})},Xdt=t=>t.activeSubSolver?[t,...Xdt(t.activeSubSolver)]:[t],$Jn=({solver:t})=>{const e=Xdt(t);return G.jsx("div",{className:"flex gap-1 items-center text-sm pt-1",children:e.map((n,o)=>G.jsxs("div",{className:"flex items-center",children:[o>0&&G.jsx("span",{className:"text-gray-400 mx-1",children:"→"}),G.jsx(VJn,{solver:n})]},n.constructor.name))})},WJn=({solver:t,triggerRender:e,animationSpeed:n=25,onSolverStarted:o,onSolverCompleted:r})=>{const[i,s]=Y.useReducer(p=>!p,!1),a=Y.useRef(void 0),c=()=>{!t.solved&&!t.failed&&(t.step(),e())},l=()=>{!t.solved&&!t.failed&&(o&&o(t),t.solve(),e(),r&&r(t))},u=()=>{i?(a.current&&(clearInterval(a.current),a.current=void 0),s()):(s(),a.current=setInterval(()=>{if(t.solved||t.failed){a.current&&(clearInterval(a.current),a.current=void 0),s(),e(),r&&t.solved&&r(t);return}t.step(),e()},n))},_=()=>{const p=t;if(p.getCurrentPhase&&!t.solved&&!t.failed){const x=p.getCurrentPhase();for(;p.getCurrentPhase()===x&&!t.solved&&!t.failed;)t.step();e()}},d=()=>{if(t.solved||t.failed||i)return;const p=window.prompt("Step until which iteration?",`${t.iterations}`);if(p===null)return;const x=Number(p);if(!Number.isFinite(x)){window.alert("Please enter a valid number for the iteration");return}for(;t.iterations<x&&!t.solved&&!t.failed;)t.step();e(),t.solved&&r&&r(t)};Y.useEffect(()=>()=>{a.current&&clearInterval(a.current)},[]),Y.useEffect(()=>{(t.solved||t.failed)&&i&&(a.current&&(clearInterval(a.current),a.current=void 0),s())},[t.solved,t.failed,i]);const m=t.getCurrentPhase!==void 0,h=m?t.getCurrentPhase():null;return G.jsxs("div",{className:"space-y-2 p-2 border-b",children:[G.jsx("div",{className:"flex items-center",children:G.jsx($Jn,{solver:t})}),G.jsxs("div",{className:"flex gap-2 items-center flex-wrap",children:[G.jsx("button",{onClick:c,disabled:t.solved||t.failed||i,className:"bg-blue-500 hover:bg-blue-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Step"}),G.jsx("button",{onClick:l,disabled:t.solved||t.failed||i,className:"bg-green-500 hover:bg-green-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Solve"}),G.jsx("button",{onClick:u,disabled:t.solved||t.failed,className:`px-3 py-1 rounded text-white text-sm ${i?"bg-red-500 hover:bg-red-600":"bg-yellow-500 hover:bg-yellow-600"} disabled:bg-gray-300`,children:i?"Stop":"Animate"}),G.jsx("button",{onClick:d,disabled:t.solved||t.failed||i,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"}),m&&G.jsx("button",{onClick:_,disabled:t.solved||t.failed||i,className:"bg-purple-500 hover:bg-purple-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Next Stage"}),G.jsxs("div",{className:"text-sm text-gray-600",children:["Iterations: ",t.iterations]}),t.timeToSolve!==void 0&&G.jsxs("div",{className:"text-sm text-gray-600",children:["Time: ",(t.timeToSolve/1e3).toFixed(3),"s"]}),h&&G.jsxs("div",{className:"text-sm text-gray-600",children:["Phase: ",G.jsx("span",{className:"font-medium",children:h})]}),t.solved&&G.jsx("div",{className:"px-2 py-1 bg-green-100 text-green-800 rounded text-sm",children:"Solved"}),t.failed&&G.jsx("div",{className:"px-2 py-1 bg-red-100 text-red-800 rounded text-sm",children:"Failed"})]}),t.error&&G.jsxs("div",{className:"text-red-600 text-sm",children:["Error: ",t.error]})]})},UJn=(t,e,n)=>{const o=t.currentPipelineStepIndex;return e<o?"Completed":e===o&&t.activeSubSolver?t.activeSubSolver.failed?"Failed":"In Progress":"Not Started"},XJn=(t,e)=>{const o=t.pipelineDef[e].solverName,r=UJn(t,e),i=t[o],s=t.firstIterationOfPhase?.[o]??null,a=t.iterations;let c=0;if(r==="Completed"){const d=t.pipelineDef[e+1],m=d?t.firstIterationOfPhase?.[d.solverName]:void 0;m!==void 0&&s!==null?c=m-s:s!==null&&(c=a-s)}else r==="In Progress"&&s!==null&&(c=a-s);const l=t.timeSpentOnPhase?.[o]??0;let u=0;r==="Completed"?u=1:r==="In Progress"&&i&&(u=i.progress??0);const _=i?.stats??null;return{index:e,name:o,status:r,firstIteration:s,iterations:c,progress:u,timeSpent:l,stats:_&&Object.keys(_).length>0?_:null,solverInstance:i??null}},jJn=({status:t})=>{const e={"Not Started":"text-blue-600","In Progress":"text-yellow-600",Completed:"text-green-600",Failed:"text-red-600"};return G.jsx("span",{className:`font-medium ${e[t]}`,children:t})},GJn=({progress:t})=>{if(t===0)return null;const e=Math.round(t*100);return G.jsxs("div",{className:"flex items-center gap-2",children:[G.jsx("div",{className:"w-20 h-2 bg-gray-200 rounded overflow-hidden",children:G.jsx("div",{className:"h-full bg-blue-500 transition-all duration-200",style:{width:`${e}%`}})}),G.jsxs("span",{className:"text-xs text-gray-500",children:[e,"%"]})]})},YJn=t=>Object.entries(t).map(([e,n])=>`${e}: ${n}`).join(", "),qJn=({stats:t})=>{if(!t||Object.keys(t).length===0)return G.jsx("span",{children:"-"});const e=Object.entries(t),n=YJn(t);return G.jsxs("details",{className:"cursor-pointer",children:[G.jsx("summary",{className:"whitespace-nowrap overflow-hidden text-ellipsis max-w-[200px]",children:n}),G.jsx("div",{className:"mt-1 text-xs",children:e.map(([o,r])=>G.jsxs("div",{children:[o,": ",String(r)]},o))})]})},Hye=t=>{if(t===null||typeof t!="object")return t;if(Array.isArray(t))return t.map(Hye);const e={};for(const[n,o]of Object.entries(t))n.startsWith("_")||(e[n]=Hye(o));return e},JJn=(t,e)=>{try{if(typeof t.getConstructorParams!="function"){alert(`getConstructorParams() is not implemented for ${e}`);return}const n=Hye(t.getConstructorParams()),o=new Blob([JSON.stringify(n,null,2)],{type:"application/json"}),r=URL.createObjectURL(o),i=document.createElement("a");i.href=r,i.download=`${e}_input.json`,i.click(),URL.revokeObjectURL(r)}catch(n){alert(`Error downloading input for ${e}: ${n instanceof Error?n.message:String(n)}`)}},KJn=({solver:t,onStepUntilPhase:e,onDownloadInput:n})=>{const o=t.pipelineDef.map((a,c)=>XJn(t,c)),r=a=>{e?.(a)},i=a=>{a.solverInstance&&(n?n(a.solverInstance,a.name):JJn(a.solverInstance,a.name))},s=a=>`${(a/1e3).toFixed(2)}s`;return G.jsxs("div",{className:"border-t border-gray-200",children:[G.jsx("div",{className:"px-4 py-2 bg-gray-50 border-b border-gray-200",children:G.jsx("h3",{className:"text-sm font-semibold text-gray-700",children:"Pipeline Steps"})}),G.jsx("div",{className:"overflow-x-auto",children:G.jsxs("table",{className:"w-full text-sm",children:[G.jsx("thead",{children:G.jsxs("tr",{className:"bg-gray-50 border-b border-gray-200",children:[G.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Step"}),G.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Status"}),G.jsxs("th",{className:"px-4 py-2 text-center font-semibold text-gray-700",children:["i",G.jsx("sub",{children:"0"})]}),G.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Iterations"}),G.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Progress"}),G.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Time"}),G.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Stats"}),G.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Input"})]})}),G.jsx("tbody",{children:o.map(a=>G.jsxs("tr",{className:`border-b border-gray-100 ${a.status==="In Progress"?"bg-yellow-50":""}`,children:[G.jsx("td",{className:"px-4 py-2",children:G.jsxs("div",{className:"flex items-center gap-2",children:[G.jsx("span",{className:"text-gray-400 w-6",children:String(a.index+1).padStart(2,"0")}),G.jsx("button",{onClick:()=>r(a.name),disabled:a.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 ${a.name} completes`,children:G.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:G.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"})})}),G.jsx("span",{className:"font-medium text-gray-900",children:a.name})]})}),G.jsx("td",{className:"px-4 py-2",children:G.jsx(jJn,{status:a.status})}),G.jsx("td",{className:"px-4 py-2 text-center text-gray-600",children:a.firstIteration!==null?a.firstIteration:""}),G.jsx("td",{className:"px-4 py-2 text-gray-600",children:a.iterations}),G.jsx("td",{className:"px-4 py-2",children:G.jsx(GJn,{progress:a.progress})}),G.jsx("td",{className:"px-4 py-2 text-gray-600",children:s(a.timeSpent)}),G.jsx("td",{className:"px-4 py-2 text-gray-500",children:G.jsx(qJn,{stats:a.stats})}),G.jsx("td",{className:"px-4 py-2",children:a.solverInstance?G.jsxs("button",{onClick:()=>i(a),className:"flex items-center gap-1 text-blue-500 hover:text-blue-700",title:`Download input for ${a.name}`,children:[G.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:G.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"})}),G.jsx("span",{children:"Input"})]}):null})]},a.name))})]})})]})},QJn=class extends cr.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 ZJn({graphics:t}){const e=t.points??[],n=t.lines??[],o=t.rects??[],r=t.circles??[],i=t.texts??[];let s=Number.POSITIVE_INFINITY,a=Number.POSITIVE_INFINITY,c=Number.NEGATIVE_INFINITY,l=Number.NEGATIVE_INFINITY;const u=(x,f)=>{typeof x=="number"&&(x<s&&(s=x),x>c&&(c=x)),typeof f=="number"&&(f<a&&(a=f),f>l&&(l=f))};for(const x of e)u(x.x,x.y);for(const x of n){const f=x.points??[];for(const g of f)u(g.x,g.y)}for(const x of o){const f=x.x??0,g=x.y??0,y=x.width??0,b=x.height??0;u(f,g),u(f+y,g+b)}for(const x of r){const f=x.x??0,g=x.y??0,y=x.radius??1;u(f-y,g-y),u(f+y,g+y)}for(const x of i)u(x.x,x.y);(!isFinite(s)||!isFinite(a)||!isFinite(c)||!isFinite(l))&&(s=-20,a=-20,c=20,l=20);const _=10,d=s-_,m=a-_,h=Math.max(1,c-s+2*_),p=Math.max(1,l-a+2*_);return G.jsxs("svg",{className:"w-full h-[400px] bg-white",viewBox:`${d} ${m} ${h} ${p}`,role:"img","aria-label":"Graphics fallback",children:[o.map((x,f)=>G.jsx("rect",{x:x.x??0,y:x.y??0,width:x.width??0,height:x.height??0,fill:"none",stroke:x.strokeColor??"black",strokeWidth:x.strokeWidth??1},`rect-${f}`)),n.map((x,f)=>G.jsx("polyline",{fill:"none",stroke:x.strokeColor??"black",strokeWidth:x.strokeWidth??1,points:(x.points??[]).map(g=>`${g.x??0},${g.y??0}`).join(" ")},`line-${f}`)),r.map((x,f)=>G.jsx("circle",{cx:x.x??0,cy:x.y??0,r:x.radius??1.5,fill:x.fillColor??"none",stroke:x.strokeColor??"black",strokeWidth:x.strokeWidth??1},`circle-${f}`)),e.map((x,f)=>G.jsx("circle",{cx:x.x??0,cy:x.y??0,r:x.radius??1.5,fill:x.color??"black"},`point-${f}`)),i.map((x,f)=>G.jsx("text",{x:x.x??0,y:x.y??0,fontSize:x.fontSize??10,fill:x.color??"black",children:x.text??""},`text-${f}`))]})}var eKn=({solver:t,animationSpeed:e=25,onSolverStarted:n,onSolverCompleted:o})=>{const[r,i]=Y.useReducer(u=>u+1,0),s=Y.useMemo(()=>{try{return t.visualize()||{points:[],lines:[],rects:[],circles:[]}}catch(u){return console.error("Visualization error:",u),{points:[],lines:[],rects:[],circles:[]}}},[t,r]),a=Y.useMemo(()=>(s.rects?.length||0)===0&&(s.lines?.length||0)===0&&(s.points?.length||0)===0&&(s.circles?.length||0)===0,[s]);Y.useEffect(()=>{if(!(typeof document>"u")&&!document.querySelector('script[src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4"]')){const u=document.createElement("script");u.src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4",document.head.appendChild(u)}},[]);const c=t.pipelineDef!==void 0,l=u=>{const _=t;if(!t.solved&&!t.failed){for(;!t.solved&&!t.failed&&_.currentPipelineStepIndex<=_.pipelineDef.findIndex(d=>d.solverName===u);)t.step();i()}};return G.jsxs("div",{children:[G.jsx(WJn,{solver:t,triggerRender:i,animationSpeed:e,onSolverStarted:n,onSolverCompleted:o}),a?G.jsx("div",{className:"p-4 text-gray-500",children:"No Graphics Yet"}):G.jsx(QJn,{fallback:G.jsx(ZJn,{graphics:s}),children:G.jsx(zJn,{graphics:s})}),c&&G.jsx(KJn,{solver:t,onStepUntilPhase:l})]})};const tKn=()=>{Y.useEffect(()=>{const t="tailwind-cdn-script";if(document.getElementById(t)||window.tailwind)return;const e=document.createElement("div");e.className="hidden",document.body.appendChild(e);const n=window.getComputedStyle(e).display==="none";if(document.body.removeChild(e),n)return;const o=document.createElement("script");o.id=t,o.src="https://cdn.tailwindcss.com",document.head.appendChild(o)},[])},nKn=t=>t.toLowerCase().includes("pack")?aAn:t.toLowerCase().includes("rout")?dAn:jDn,oKn=({solverEvents:t=[]})=>{const[e,n]=Y.useState(null);tKn();const o=Y.useMemo(()=>{const a=new Map;for(const c of t){const l=`${c.componentName}-${c.solverName}`;a.set(l,c)}return a},[t]),r=Y.useMemo(()=>Array.from(o.keys()),[o]),i=e?o.get(e):null,s=Y.useMemo(()=>{if(!i)return{instance:null,error:null,classFound:!1};const a=$ie[i.solverName];if(!a)return{instance:null,error:`Solver class "${i.solverName}" not found in SOLVERS registry. Available: ${Object.keys($ie).join(", ")}`,classFound:!1};try{const c=i.solverParams,l=c?.input!==void 0?c.input:c;return{instance:new a(l),error:null,classFound:!0}}catch(c){const l=c instanceof Error?c.message:String(c);return console.error("Failed to reconstruct solver:",c),{instance:null,error:`Failed to instantiate solver: ${l}`,classFound:!0}}},[i]);return t.length===0?G.jsx("div",{className:"rf-p-4",children:G.jsx("div",{className:"rf-bg-gray-50 rf-rounded-md rf-border rf-border-gray-200",children:G.jsxs("div",{className:"rf-p-4",children:[G.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800 rf-mb-3",children:"No Solvers Detected"}),G.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."})]})})}):G.jsxs("div",{className:"rf-flex rf-h-full rf-overflow-hidden",children:[G.jsxs("div",{className:"rf-w-64 rf-border-r rf-border-gray-200 rf-overflow-y-auto rf-flex-shrink-0",children:[G.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:[r.length," ",r.length===1?"Solver":"Solvers"]}),r.map(a=>{const c=o.get(a),l=e===a;return G.jsx("div",{className:`rf-px-3 rf-py-2 rf-cursor-pointer rf-border-b rf-border-gray-100 ${l?"rf-bg-blue-50 rf-border-l-2 rf-border-l-blue-500":"hover:rf-bg-gray-50"}`,onClick:()=>n(a),children:(()=>{const u=nKn(c.solverName);return G.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2",children:[G.jsx(u,{className:"rf-w-4 rf-h-4 rf-text-blue-500 rf-flex-shrink-0"}),G.jsxs("div",{className:"rf-flex-1 rf-min-w-0",children:[G.jsx("div",{className:"rf-text-sm rf-font-medium rf-text-gray-800 rf-truncate",children:c.componentName}),G.jsx("div",{className:"rf-text-xs rf-text-gray-500 rf-truncate",children:c.solverName})]})]})})()},a)})]}),G.jsx("div",{className:"rf-flex-1 rf-overflow-hidden",children:i?s.instance?G.jsx(M5,{fallback:G.jsx("div",{className:"rf-p-4",children:G.jsxs("div",{className:"rf-bg-red-50 rf-rounded-md rf-border rf-border-red-200 rf-p-4",children:[G.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-red-800 rf-mb-2",children:"Error Loading Solver Debugger"}),G.jsxs("p",{className:"rf-text-sm rf-text-red-600",children:["Failed to render the solver debugger for"," ",i.solverName]})]})}),children:G.jsx(eKn,{solver:s.instance})}):G.jsxs("div",{className:"rf-p-4",children:[G.jsxs("div",{className:"rf-mb-4",children:[G.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800",children:i.solverName}),G.jsxs("p",{className:"rf-text-sm rf-text-gray-500",children:["Component: ",i.componentName]})]}),s.error&&G.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:G.jsx("p",{className:`rf-text-sm ${s.classFound?"rf-text-red-700":"rf-text-yellow-700"}`,children:s.error})}),G.jsxs("div",{className:"rf-border rf-border-gray-200 rf-rounded-md rf-overflow-hidden",children:[G.jsx("div",{className:"rf-px-3 rf-py-2 rf-bg-gray-50",children:G.jsx("span",{className:"rf-text-sm rf-font-medium rf-text-gray-700",children:"Solver Parameters"})}),G.jsx("div",{className:"rf-p-3 rf-bg-white rf-border-t rf-border-gray-200",children:G.jsx("pre",{className:"rf-text-xs rf-font-mono rf-text-gray-600 rf-whitespace-pre-wrap rf-overflow-x-auto",children:JSON.stringify(i.solverParams,null,2)})})]})]}):G.jsx("div",{className:"rf-flex rf-items-center rf-justify-center rf-h-full",children:G.jsx("p",{className:"rf-text-sm rf-text-gray-500",children:"Select a solver from the list to view details"})})})]})},jdt=({errorMessage:t,errorStack:e,circuitJsonErrors:n})=>{Y.useEffect(()=>{if(t){const o=new Error(t);e&&(o.stack=e);try{DW.captureException(o)}catch{}}},[t,e]),Y.useEffect(()=>{if(n&&n.length>0)for(const o of n){const r=new Error(o.message||"Circuit JSON Error");o.stack&&(r.stack=o.stack);try{DW.captureException(r,{error_type:o.type})}catch{}}},[n])},Gdt="0.0.1898",rKn={version:Gdt},vY=VIe()($Ie(t=>({lastRunEvalVersion:void 0,setLastRunEvalVersion:e=>{t({lastRunEvalVersion:e})}}),{name:"runframe-runner-store"})),iKn=t=>{const[e,n]=Y.useState([]),[o,r]=Y.useState(null),[i,s]=Y.useState(""),[a,c]=kT("eval-version-selection",null),l=vY(m=>m.setLastRunEvalVersion),u=vY(m=>m.lastRunEvalVersion);return Y.useEffect(()=>{t&&fetch("https://data.jsdelivr.com/v1/package/npm/@tscircuit/eval").then(m=>m.json()).then(m=>{if(Array.isArray(m?.versions)){let h=[...m.versions];m.tags?.latest&&(r(m.tags.latest),h=h.filter(p=>p!==m.tags.latest)),n(h)}}).catch(()=>{})},[t]),Y.useEffect(()=>{t&&(a?(window.TSCIRCUIT_LATEST_EVAL_VERSION=a,l(a)):o&&(window.TSCIRCUIT_LATEST_EVAL_VERSION=o,l(o)))},[t,a,o]),{versions:Y.useMemo(()=>e.filter(m=>m.includes(i)).slice(0,50),[e,i]),latestVersion:o,lastRunEvalVersion:u,search:i,setSearch:s,selectVersion:m=>{c(m),s("")}}},sKn=({snippetNames:t,onSelect:e,onCancel:n,isOpen:o})=>{const[r,i]=Y.useState(""),[s,a]=Y.useState("");if(!o)return null;const c=t.filter(_=>_.toLowerCase().includes(s.toLowerCase())),l=s&&!t.includes(s),u=_=>{_.key==="Enter"&&(c.length===1?i(c[0]):l&&i(s))};return G.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:G.jsxs("div",{className:"rf-bg-white rf-rounded-lg rf-p-6 rf-w-96",children:[G.jsx("h2",{className:"rf-text-lg rf-font-semibold rf-mb-4",children:"Select Snippet"}),G.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:_=>a(_.target.value),onKeyDown:u}),G.jsxs("div",{className:"rf-h-60 rf-overflow-y-auto",children:[c.map(_=>G.jsx("button",{type:"button",className:`w-full text-left px-4 py-2 rounded hover:bg-gray-100 ${r===_?"bg-blue-50":""}`,onClick:()=>i(_),children:_},_)),l&&G.jsxs("button",{type:"button",className:`w-full text-left px-4 py-2 rounded hover:bg-gray-100 text-blue-500 ${r===s?"bg-blue-50":""}`,onClick:()=>i(s),children:['Create new "',s,'"']})]}),G.jsxs("div",{className:"rf-mt-4 rf-flex rf-justify-end rf-gap-2",children:[G.jsx("button",{type:"button",className:"rf-px-4 rf-py-2 rf-text-gray-600 rf-hover:text-gray-800",onClick:n,children:"Cancel"}),G.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:()=>r&&e(r),disabled:!r,children:r===s?`Create "${r}"`:`Save to ${r}`})]})]})})},aKn=t=>{const e=Y.useRef(null),n=eu(o=>o.recentEvents);Y.useEffect(()=>{if(n.length===0)return;const o=n[0];o.event_id!==e.current&&(t(o),e.current=o.event_id)},[n,t])};function cKn(t){const e=lKn(t),n=Y.forwardRef((o,r)=>{const{children:i,...s}=o,a=Y.Children.toArray(i),c=a.find(_Kn);if(c){const l=c.props.children,u=a.map(_=>_===c?Y.Children.count(l)>1?Y.Children.only(null):Y.isValidElement(l)?l.props.children:null:_);return G.jsx(e,{...s,ref:r,children:Y.isValidElement(l)?Y.cloneElement(l,void 0,u):null})}return G.jsx(e,{...s,ref:r,children:i})});return n.displayName=`${t}.Slot`,n}function lKn(t){const e=Y.forwardRef((n,o)=>{const{children:r,...i}=n;if(Y.isValidElement(r)){const s=hKn(r),a=dKn(i,r.props);return r.type!==Y.Fragment&&(a.ref=o?Rx(o,s):s),Y.cloneElement(r,a)}return Y.Children.count(r)>1?Y.Children.only(null):null});return e.displayName=`${t}.SlotClone`,e}var uKn=Symbol("radix.slottable");function _Kn(t){return Y.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===uKn}function dKn(t,e){const n={...e};for(const o in e){const r=t[o],i=e[o];/^on[A-Z]/.test(o)?r&&i?n[o]=(...a)=>{const c=i(...a);return r(...a),c}:r&&(n[o]=r):o==="style"?n[o]={...r,...i}:o==="className"&&(n[o]=[r,i].filter(Boolean).join(" "))}return{...t,...n}}function hKn(t){let e=Object.getOwnPropertyDescriptor(t.props,"ref")?.get,n=e&&"isReactWarning"in e&&e.isReactWarning;return n?t.ref:(e=Object.getOwnPropertyDescriptor(t,"ref")?.get,n=e&&"isReactWarning"in e&&e.isReactWarning,n?t.props.ref:t.props.ref||t.ref)}var SY="Dialog",[Ydt,qdt]=d4(SY),[mKn,B4]=Ydt(SY),Jdt=t=>{const{__scopeDialog:e,children:n,open:o,defaultOpen:r,onOpenChange:i,modal:s=!0}=t,a=Y.useRef(null),c=Y.useRef(null),[l,u]=DP({prop:o,defaultProp:r??!1,onChange:i,caller:SY});return G.jsx(mKn,{scope:e,triggerRef:a,contentRef:c,contentId:Jp(),titleId:Jp(),descriptionId:Jp(),open:l,onOpenChange:u,onOpenToggle:Y.useCallback(()=>u(_=>!_),[u]),modal:s,children:n})};Jdt.displayName=SY;var Kdt="DialogTrigger",Qdt=Y.forwardRef((t,e)=>{const{__scopeDialog:n,...o}=t,r=B4(Kdt,n),i=tu(e,r.triggerRef);return G.jsx(Cc.button,{type:"button","aria-haspopup":"dialog","aria-expanded":r.open,"aria-controls":r.contentId,"data-state":Oye(r.open),...o,ref:i,onClick:Vr(t.onClick,r.onOpenToggle)})});Qdt.displayName=Kdt;var Iye="DialogPortal",[pKn,Zdt]=Ydt(Iye,{forceMount:void 0}),eht=t=>{const{__scopeDialog:e,forceMount:n,children:o,container:r}=t,i=B4(Iye,e);return G.jsx(pKn,{scope:e,forceMount:n,children:Y.Children.map(o,s=>G.jsx(Fg,{present:n||i.open,children:G.jsx(Fj,{asChild:!0,container:r,children:s})}))})};eht.displayName=Iye;var CY="DialogOverlay",tht=Y.forwardRef((t,e)=>{const n=Zdt(CY,t.__scopeDialog),{forceMount:o=n.forceMount,...r}=t,i=B4(CY,t.__scopeDialog);return i.modal?G.jsx(Fg,{present:o||i.open,children:G.jsx(xKn,{...r,ref:e})}):null});tht.displayName=CY;var fKn=cKn("DialogOverlay.RemoveScroll"),xKn=Y.forwardRef((t,e)=>{const{__scopeDialog:n,...o}=t,r=B4(CY,n);return G.jsx(jj,{as:fKn,allowPinchZoom:!0,shards:[r.contentRef],children:G.jsx(Cc.div,{"data-state":Oye(r.open),...o,ref:e,style:{pointerEvents:"auto",...o.style}})})}),eC="DialogContent",nht=Y.forwardRef((t,e)=>{const n=Zdt(eC,t.__scopeDialog),{forceMount:o=n.forceMount,...r}=t,i=B4(eC,t.__scopeDialog);return G.jsx(Fg,{present:o||i.open,children:i.modal?G.jsx(gKn,{...r,ref:e}):G.jsx(yKn,{...r,ref:e})})});nht.displayName=eC;var gKn=Y.forwardRef((t,e)=>{const n=B4(eC,t.__scopeDialog),o=Y.useRef(null),r=tu(e,n.contentRef,o);return Y.useEffect(()=>{const i=o.current;if(i)return Q2e(i)},[]),G.jsx(oht,{...t,ref:r,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Vr(t.onCloseAutoFocus,i=>{i.preventDefault(),n.triggerRef.current?.focus()}),onPointerDownOutside:Vr(t.onPointerDownOutside,i=>{const s=i.detail.originalEvent,a=s.button===0&&s.ctrlKey===!0;(s.button===2||a)&&i.preventDefault()}),onFocusOutside:Vr(t.onFocusOutside,i=>i.preventDefault())})}),yKn=Y.forwardRef((t,e)=>{const n=B4(eC,t.__scopeDialog),o=Y.useRef(!1),r=Y.useRef(!1);return G.jsx(oht,{...t,ref:e,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:i=>{t.onCloseAutoFocus?.(i),i.defaultPrevented||(o.current||n.triggerRef.current?.focus(),i.preventDefault()),o.current=!1,r.current=!1},onInteractOutside:i=>{t.onInteractOutside?.(i),i.defaultPrevented||(o.current=!0,i.detail.originalEvent.type==="pointerdown"&&(r.current=!0));const s=i.target;n.triggerRef.current?.contains(s)&&i.preventDefault(),i.detail.originalEvent.type==="focusin"&&r.current&&i.preventDefault()}})}),oht=Y.forwardRef((t,e)=>{const{__scopeDialog:n,trapFocus:o,onOpenAutoFocus:r,onCloseAutoFocus:i,...s}=t,a=B4(eC,n),c=Y.useRef(null),l=tu(e,c);return N2e(),G.jsxs(G.Fragment,{children:[G.jsx(Mj,{asChild:!0,loop:!0,trapped:o,onMountAutoFocus:r,onUnmountAutoFocus:i,children:G.jsx(eH,{role:"dialog",id:a.contentId,"aria-describedby":a.descriptionId,"aria-labelledby":a.titleId,"data-state":Oye(a.open),...s,ref:l,onDismiss:()=>a.onOpenChange(!1)})}),G.jsxs(G.Fragment,{children:[G.jsx(PKn,{titleId:a.titleId}),G.jsx(SKn,{contentRef:c,descriptionId:a.descriptionId})]})]})}),Lye="DialogTitle",rht=Y.forwardRef((t,e)=>{const{__scopeDialog:n,...o}=t,r=B4(Lye,n);return G.jsx(Cc.h2,{id:r.titleId,...o,ref:e})});rht.displayName=Lye;var iht="DialogDescription",sht=Y.forwardRef((t,e)=>{const{__scopeDialog:n,...o}=t,r=B4(iht,n);return G.jsx(Cc.p,{id:r.descriptionId,...o,ref:e})});sht.displayName=iht;var aht="DialogClose",cht=Y.forwardRef((t,e)=>{const{__scopeDialog:n,...o}=t,r=B4(aht,n);return G.jsx(Cc.button,{type:"button",...o,ref:e,onClick:Vr(t.onClick,()=>r.onOpenChange(!1))})});cht.displayName=aht;function Oye(t){return t?"open":"closed"}var lht="DialogTitleWarning",[bKn,uht]=zZt(lht,{contentName:eC,titleName:Lye,docsSlug:"dialog"}),PKn=({titleId:t})=>{const e=uht(lht),n=`\`${e.contentName}\` requires a \`${e.titleName}\` for the component to be accessible for screen reader users.
|
|
5698
|
+
`,_=new Blob([u],{type:"text/plain"}),d=URL.createObjectURL(_),m=document.createElement("a");m.href=d,m.download=`${l}.test.ts`,m.click(),URL.revokeObjectURL(d)}catch(c){alert(`Error generating test.ts for ${t.constructor.name}: ${c instanceof Error?c.message:String(c)}`)}o(!1)};return G.jsxs("div",{className:`relative ${e}`,ref:r,children:[G.jsx("button",{className:"px-2 py-1 rounded text-xs cursor-pointer",onClick:()=>o(!n),title:`Download options for ${t.constructor.name}`,children:t.constructor.name}),n&&G.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:[G.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:i,children:"Download JSON"}),G.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:s,children:"Download page.tsx"}),G.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:a,children:"Download test.ts"})]})]})},Xdt=t=>t.activeSubSolver?[t,...Xdt(t.activeSubSolver)]:[t],$Jn=({solver:t})=>{const e=Xdt(t);return G.jsx("div",{className:"flex gap-1 items-center text-sm pt-1",children:e.map((n,o)=>G.jsxs("div",{className:"flex items-center",children:[o>0&&G.jsx("span",{className:"text-gray-400 mx-1",children:"→"}),G.jsx(VJn,{solver:n})]},n.constructor.name))})},WJn=({solver:t,triggerRender:e,animationSpeed:n=25,onSolverStarted:o,onSolverCompleted:r})=>{const[i,s]=Y.useReducer(p=>!p,!1),a=Y.useRef(void 0),c=()=>{!t.solved&&!t.failed&&(t.step(),e())},l=()=>{!t.solved&&!t.failed&&(o&&o(t),t.solve(),e(),r&&r(t))},u=()=>{i?(a.current&&(clearInterval(a.current),a.current=void 0),s()):(s(),a.current=setInterval(()=>{if(t.solved||t.failed){a.current&&(clearInterval(a.current),a.current=void 0),s(),e(),r&&t.solved&&r(t);return}t.step(),e()},n))},_=()=>{const p=t;if(p.getCurrentPhase&&!t.solved&&!t.failed){const x=p.getCurrentPhase();for(;p.getCurrentPhase()===x&&!t.solved&&!t.failed;)t.step();e()}},d=()=>{if(t.solved||t.failed||i)return;const p=window.prompt("Step until which iteration?",`${t.iterations}`);if(p===null)return;const x=Number(p);if(!Number.isFinite(x)){window.alert("Please enter a valid number for the iteration");return}for(;t.iterations<x&&!t.solved&&!t.failed;)t.step();e(),t.solved&&r&&r(t)};Y.useEffect(()=>()=>{a.current&&clearInterval(a.current)},[]),Y.useEffect(()=>{(t.solved||t.failed)&&i&&(a.current&&(clearInterval(a.current),a.current=void 0),s())},[t.solved,t.failed,i]);const m=t.getCurrentPhase!==void 0,h=m?t.getCurrentPhase():null;return G.jsxs("div",{className:"space-y-2 p-2 border-b",children:[G.jsx("div",{className:"flex items-center",children:G.jsx($Jn,{solver:t})}),G.jsxs("div",{className:"flex gap-2 items-center flex-wrap",children:[G.jsx("button",{onClick:c,disabled:t.solved||t.failed||i,className:"bg-blue-500 hover:bg-blue-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Step"}),G.jsx("button",{onClick:l,disabled:t.solved||t.failed||i,className:"bg-green-500 hover:bg-green-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Solve"}),G.jsx("button",{onClick:u,disabled:t.solved||t.failed,className:`px-3 py-1 rounded text-white text-sm ${i?"bg-red-500 hover:bg-red-600":"bg-yellow-500 hover:bg-yellow-600"} disabled:bg-gray-300`,children:i?"Stop":"Animate"}),G.jsx("button",{onClick:d,disabled:t.solved||t.failed||i,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"}),m&&G.jsx("button",{onClick:_,disabled:t.solved||t.failed||i,className:"bg-purple-500 hover:bg-purple-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Next Stage"}),G.jsxs("div",{className:"text-sm text-gray-600",children:["Iterations: ",t.iterations]}),t.timeToSolve!==void 0&&G.jsxs("div",{className:"text-sm text-gray-600",children:["Time: ",(t.timeToSolve/1e3).toFixed(3),"s"]}),h&&G.jsxs("div",{className:"text-sm text-gray-600",children:["Phase: ",G.jsx("span",{className:"font-medium",children:h})]}),t.solved&&G.jsx("div",{className:"px-2 py-1 bg-green-100 text-green-800 rounded text-sm",children:"Solved"}),t.failed&&G.jsx("div",{className:"px-2 py-1 bg-red-100 text-red-800 rounded text-sm",children:"Failed"})]}),t.error&&G.jsxs("div",{className:"text-red-600 text-sm",children:["Error: ",t.error]})]})},UJn=(t,e,n)=>{const o=t.currentPipelineStepIndex;return e<o?"Completed":e===o&&t.activeSubSolver?t.activeSubSolver.failed?"Failed":"In Progress":"Not Started"},XJn=(t,e)=>{const o=t.pipelineDef[e].solverName,r=UJn(t,e),i=t[o],s=t.firstIterationOfPhase?.[o]??null,a=t.iterations;let c=0;if(r==="Completed"){const d=t.pipelineDef[e+1],m=d?t.firstIterationOfPhase?.[d.solverName]:void 0;m!==void 0&&s!==null?c=m-s:s!==null&&(c=a-s)}else r==="In Progress"&&s!==null&&(c=a-s);const l=t.timeSpentOnPhase?.[o]??0;let u=0;r==="Completed"?u=1:r==="In Progress"&&i&&(u=i.progress??0);const _=i?.stats??null;return{index:e,name:o,status:r,firstIteration:s,iterations:c,progress:u,timeSpent:l,stats:_&&Object.keys(_).length>0?_:null,solverInstance:i??null}},jJn=({status:t})=>{const e={"Not Started":"text-blue-600","In Progress":"text-yellow-600",Completed:"text-green-600",Failed:"text-red-600"};return G.jsx("span",{className:`font-medium ${e[t]}`,children:t})},GJn=({progress:t})=>{if(t===0)return null;const e=Math.round(t*100);return G.jsxs("div",{className:"flex items-center gap-2",children:[G.jsx("div",{className:"w-20 h-2 bg-gray-200 rounded overflow-hidden",children:G.jsx("div",{className:"h-full bg-blue-500 transition-all duration-200",style:{width:`${e}%`}})}),G.jsxs("span",{className:"text-xs text-gray-500",children:[e,"%"]})]})},YJn=t=>Object.entries(t).map(([e,n])=>`${e}: ${n}`).join(", "),qJn=({stats:t})=>{if(!t||Object.keys(t).length===0)return G.jsx("span",{children:"-"});const e=Object.entries(t),n=YJn(t);return G.jsxs("details",{className:"cursor-pointer",children:[G.jsx("summary",{className:"whitespace-nowrap overflow-hidden text-ellipsis max-w-[200px]",children:n}),G.jsx("div",{className:"mt-1 text-xs",children:e.map(([o,r])=>G.jsxs("div",{children:[o,": ",String(r)]},o))})]})},Hye=t=>{if(t===null||typeof t!="object")return t;if(Array.isArray(t))return t.map(Hye);const e={};for(const[n,o]of Object.entries(t))n.startsWith("_")||(e[n]=Hye(o));return e},JJn=(t,e)=>{try{if(typeof t.getConstructorParams!="function"){alert(`getConstructorParams() is not implemented for ${e}`);return}const n=Hye(t.getConstructorParams()),o=new Blob([JSON.stringify(n,null,2)],{type:"application/json"}),r=URL.createObjectURL(o),i=document.createElement("a");i.href=r,i.download=`${e}_input.json`,i.click(),URL.revokeObjectURL(r)}catch(n){alert(`Error downloading input for ${e}: ${n instanceof Error?n.message:String(n)}`)}},KJn=({solver:t,onStepUntilPhase:e,onDownloadInput:n})=>{const o=t.pipelineDef.map((a,c)=>XJn(t,c)),r=a=>{e?.(a)},i=a=>{a.solverInstance&&(n?n(a.solverInstance,a.name):JJn(a.solverInstance,a.name))},s=a=>`${(a/1e3).toFixed(2)}s`;return G.jsxs("div",{className:"border-t border-gray-200",children:[G.jsx("div",{className:"px-4 py-2 bg-gray-50 border-b border-gray-200",children:G.jsx("h3",{className:"text-sm font-semibold text-gray-700",children:"Pipeline Steps"})}),G.jsx("div",{className:"overflow-x-auto",children:G.jsxs("table",{className:"w-full text-sm",children:[G.jsx("thead",{children:G.jsxs("tr",{className:"bg-gray-50 border-b border-gray-200",children:[G.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Step"}),G.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Status"}),G.jsxs("th",{className:"px-4 py-2 text-center font-semibold text-gray-700",children:["i",G.jsx("sub",{children:"0"})]}),G.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Iterations"}),G.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Progress"}),G.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Time"}),G.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Stats"}),G.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Input"})]})}),G.jsx("tbody",{children:o.map(a=>G.jsxs("tr",{className:`border-b border-gray-100 ${a.status==="In Progress"?"bg-yellow-50":""}`,children:[G.jsx("td",{className:"px-4 py-2",children:G.jsxs("div",{className:"flex items-center gap-2",children:[G.jsx("span",{className:"text-gray-400 w-6",children:String(a.index+1).padStart(2,"0")}),G.jsx("button",{onClick:()=>r(a.name),disabled:a.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 ${a.name} completes`,children:G.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:G.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"})})}),G.jsx("span",{className:"font-medium text-gray-900",children:a.name})]})}),G.jsx("td",{className:"px-4 py-2",children:G.jsx(jJn,{status:a.status})}),G.jsx("td",{className:"px-4 py-2 text-center text-gray-600",children:a.firstIteration!==null?a.firstIteration:""}),G.jsx("td",{className:"px-4 py-2 text-gray-600",children:a.iterations}),G.jsx("td",{className:"px-4 py-2",children:G.jsx(GJn,{progress:a.progress})}),G.jsx("td",{className:"px-4 py-2 text-gray-600",children:s(a.timeSpent)}),G.jsx("td",{className:"px-4 py-2 text-gray-500",children:G.jsx(qJn,{stats:a.stats})}),G.jsx("td",{className:"px-4 py-2",children:a.solverInstance?G.jsxs("button",{onClick:()=>i(a),className:"flex items-center gap-1 text-blue-500 hover:text-blue-700",title:`Download input for ${a.name}`,children:[G.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:G.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"})}),G.jsx("span",{children:"Input"})]}):null})]},a.name))})]})})]})},QJn=class extends cr.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 ZJn({graphics:t}){const e=t.points??[],n=t.lines??[],o=t.rects??[],r=t.circles??[],i=t.texts??[];let s=Number.POSITIVE_INFINITY,a=Number.POSITIVE_INFINITY,c=Number.NEGATIVE_INFINITY,l=Number.NEGATIVE_INFINITY;const u=(x,f)=>{typeof x=="number"&&(x<s&&(s=x),x>c&&(c=x)),typeof f=="number"&&(f<a&&(a=f),f>l&&(l=f))};for(const x of e)u(x.x,x.y);for(const x of n){const f=x.points??[];for(const g of f)u(g.x,g.y)}for(const x of o){const f=x.x??0,g=x.y??0,y=x.width??0,b=x.height??0;u(f,g),u(f+y,g+b)}for(const x of r){const f=x.x??0,g=x.y??0,y=x.radius??1;u(f-y,g-y),u(f+y,g+y)}for(const x of i)u(x.x,x.y);(!isFinite(s)||!isFinite(a)||!isFinite(c)||!isFinite(l))&&(s=-20,a=-20,c=20,l=20);const _=10,d=s-_,m=a-_,h=Math.max(1,c-s+2*_),p=Math.max(1,l-a+2*_);return G.jsxs("svg",{className:"w-full h-[400px] bg-white",viewBox:`${d} ${m} ${h} ${p}`,role:"img","aria-label":"Graphics fallback",children:[o.map((x,f)=>G.jsx("rect",{x:x.x??0,y:x.y??0,width:x.width??0,height:x.height??0,fill:"none",stroke:x.strokeColor??"black",strokeWidth:x.strokeWidth??1},`rect-${f}`)),n.map((x,f)=>G.jsx("polyline",{fill:"none",stroke:x.strokeColor??"black",strokeWidth:x.strokeWidth??1,points:(x.points??[]).map(g=>`${g.x??0},${g.y??0}`).join(" ")},`line-${f}`)),r.map((x,f)=>G.jsx("circle",{cx:x.x??0,cy:x.y??0,r:x.radius??1.5,fill:x.fillColor??"none",stroke:x.strokeColor??"black",strokeWidth:x.strokeWidth??1},`circle-${f}`)),e.map((x,f)=>G.jsx("circle",{cx:x.x??0,cy:x.y??0,r:x.radius??1.5,fill:x.color??"black"},`point-${f}`)),i.map((x,f)=>G.jsx("text",{x:x.x??0,y:x.y??0,fontSize:x.fontSize??10,fill:x.color??"black",children:x.text??""},`text-${f}`))]})}var eKn=({solver:t,animationSpeed:e=25,onSolverStarted:n,onSolverCompleted:o})=>{const[r,i]=Y.useReducer(u=>u+1,0),s=Y.useMemo(()=>{try{return t.visualize()||{points:[],lines:[],rects:[],circles:[]}}catch(u){return console.error("Visualization error:",u),{points:[],lines:[],rects:[],circles:[]}}},[t,r]),a=Y.useMemo(()=>(s.rects?.length||0)===0&&(s.lines?.length||0)===0&&(s.points?.length||0)===0&&(s.circles?.length||0)===0,[s]);Y.useEffect(()=>{if(!(typeof document>"u")&&!document.querySelector('script[src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4"]')){const u=document.createElement("script");u.src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4",document.head.appendChild(u)}},[]);const c=t.pipelineDef!==void 0,l=u=>{const _=t;if(!t.solved&&!t.failed){for(;!t.solved&&!t.failed&&_.currentPipelineStepIndex<=_.pipelineDef.findIndex(d=>d.solverName===u);)t.step();i()}};return G.jsxs("div",{children:[G.jsx(WJn,{solver:t,triggerRender:i,animationSpeed:e,onSolverStarted:n,onSolverCompleted:o}),a?G.jsx("div",{className:"p-4 text-gray-500",children:"No Graphics Yet"}):G.jsx(QJn,{fallback:G.jsx(ZJn,{graphics:s}),children:G.jsx(zJn,{graphics:s})}),c&&G.jsx(KJn,{solver:t,onStepUntilPhase:l})]})};const tKn=()=>{Y.useEffect(()=>{const t="tailwind-cdn-script";if(document.getElementById(t)||window.tailwind)return;const e=document.createElement("div");e.className="hidden",document.body.appendChild(e);const n=window.getComputedStyle(e).display==="none";if(document.body.removeChild(e),n)return;const o=document.createElement("script");o.id=t,o.src="https://cdn.tailwindcss.com",document.head.appendChild(o)},[])},nKn=t=>t.toLowerCase().includes("pack")?aAn:t.toLowerCase().includes("rout")?dAn:jDn,oKn=({solverEvents:t=[]})=>{const[e,n]=Y.useState(null);tKn();const o=Y.useMemo(()=>{const a=new Map;for(const c of t){const l=`${c.componentName}-${c.solverName}`;a.set(l,c)}return a},[t]),r=Y.useMemo(()=>Array.from(o.keys()),[o]),i=e?o.get(e):null,s=Y.useMemo(()=>{if(!i)return{instance:null,error:null,classFound:!1};const a=$ie[i.solverName];if(!a)return{instance:null,error:`Solver class "${i.solverName}" not found in SOLVERS registry. Available: ${Object.keys($ie).join(", ")}`,classFound:!1};try{const c=i.solverParams,l=c?.input!==void 0?c.input:c;return{instance:new a(l),error:null,classFound:!0}}catch(c){const l=c instanceof Error?c.message:String(c);return console.error("Failed to reconstruct solver:",c),{instance:null,error:`Failed to instantiate solver: ${l}`,classFound:!0}}},[i]);return t.length===0?G.jsx("div",{className:"rf-p-4",children:G.jsx("div",{className:"rf-bg-gray-50 rf-rounded-md rf-border rf-border-gray-200",children:G.jsxs("div",{className:"rf-p-4",children:[G.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800 rf-mb-3",children:"No Solvers Detected"}),G.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."})]})})}):G.jsxs("div",{className:"rf-flex rf-h-full rf-overflow-hidden",children:[G.jsxs("div",{className:"rf-w-64 rf-border-r rf-border-gray-200 rf-overflow-y-auto rf-flex-shrink-0",children:[G.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:[r.length," ",r.length===1?"Solver":"Solvers"]}),r.map(a=>{const c=o.get(a),l=e===a;return G.jsx("div",{className:`rf-px-3 rf-py-2 rf-cursor-pointer rf-border-b rf-border-gray-100 ${l?"rf-bg-blue-50 rf-border-l-2 rf-border-l-blue-500":"hover:rf-bg-gray-50"}`,onClick:()=>n(a),children:(()=>{const u=nKn(c.solverName);return G.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2",children:[G.jsx(u,{className:"rf-w-4 rf-h-4 rf-text-blue-500 rf-flex-shrink-0"}),G.jsxs("div",{className:"rf-flex-1 rf-min-w-0",children:[G.jsx("div",{className:"rf-text-sm rf-font-medium rf-text-gray-800 rf-truncate",children:c.componentName}),G.jsx("div",{className:"rf-text-xs rf-text-gray-500 rf-truncate",children:c.solverName})]})]})})()},a)})]}),G.jsx("div",{className:"rf-flex-1 rf-overflow-hidden",children:i?s.instance?G.jsx(M5,{fallback:G.jsx("div",{className:"rf-p-4",children:G.jsxs("div",{className:"rf-bg-red-50 rf-rounded-md rf-border rf-border-red-200 rf-p-4",children:[G.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-red-800 rf-mb-2",children:"Error Loading Solver Debugger"}),G.jsxs("p",{className:"rf-text-sm rf-text-red-600",children:["Failed to render the solver debugger for"," ",i.solverName]})]})}),children:G.jsx(eKn,{solver:s.instance})}):G.jsxs("div",{className:"rf-p-4",children:[G.jsxs("div",{className:"rf-mb-4",children:[G.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800",children:i.solverName}),G.jsxs("p",{className:"rf-text-sm rf-text-gray-500",children:["Component: ",i.componentName]})]}),s.error&&G.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:G.jsx("p",{className:`rf-text-sm ${s.classFound?"rf-text-red-700":"rf-text-yellow-700"}`,children:s.error})}),G.jsxs("div",{className:"rf-border rf-border-gray-200 rf-rounded-md rf-overflow-hidden",children:[G.jsx("div",{className:"rf-px-3 rf-py-2 rf-bg-gray-50",children:G.jsx("span",{className:"rf-text-sm rf-font-medium rf-text-gray-700",children:"Solver Parameters"})}),G.jsx("div",{className:"rf-p-3 rf-bg-white rf-border-t rf-border-gray-200",children:G.jsx("pre",{className:"rf-text-xs rf-font-mono rf-text-gray-600 rf-whitespace-pre-wrap rf-overflow-x-auto",children:JSON.stringify(i.solverParams,null,2)})})]})]}):G.jsx("div",{className:"rf-flex rf-items-center rf-justify-center rf-h-full",children:G.jsx("p",{className:"rf-text-sm rf-text-gray-500",children:"Select a solver from the list to view details"})})})]})},jdt=({errorMessage:t,errorStack:e,circuitJsonErrors:n})=>{Y.useEffect(()=>{if(t){const o=new Error(t);e&&(o.stack=e);try{DW.captureException(o)}catch{}}},[t,e]),Y.useEffect(()=>{if(n&&n.length>0)for(const o of n){const r=new Error(o.message||"Circuit JSON Error");o.stack&&(r.stack=o.stack);try{DW.captureException(r,{error_type:o.type})}catch{}}},[n])},Gdt="0.0.1899",rKn={version:Gdt},vY=VIe()($Ie(t=>({lastRunEvalVersion:void 0,setLastRunEvalVersion:e=>{t({lastRunEvalVersion:e})}}),{name:"runframe-runner-store"})),iKn=t=>{const[e,n]=Y.useState([]),[o,r]=Y.useState(null),[i,s]=Y.useState(""),[a,c]=kT("eval-version-selection",null),l=vY(m=>m.setLastRunEvalVersion),u=vY(m=>m.lastRunEvalVersion);return Y.useEffect(()=>{t&&fetch("https://data.jsdelivr.com/v1/package/npm/@tscircuit/eval").then(m=>m.json()).then(m=>{if(Array.isArray(m?.versions)){let h=[...m.versions];m.tags?.latest&&(r(m.tags.latest),h=h.filter(p=>p!==m.tags.latest)),n(h)}}).catch(()=>{})},[t]),Y.useEffect(()=>{t&&(a?(window.TSCIRCUIT_LATEST_EVAL_VERSION=a,l(a)):o&&(window.TSCIRCUIT_LATEST_EVAL_VERSION=o,l(o)))},[t,a,o]),{versions:Y.useMemo(()=>e.filter(m=>m.includes(i)).slice(0,50),[e,i]),latestVersion:o,lastRunEvalVersion:u,search:i,setSearch:s,selectVersion:m=>{c(m),s("")}}},sKn=({snippetNames:t,onSelect:e,onCancel:n,isOpen:o})=>{const[r,i]=Y.useState(""),[s,a]=Y.useState("");if(!o)return null;const c=t.filter(_=>_.toLowerCase().includes(s.toLowerCase())),l=s&&!t.includes(s),u=_=>{_.key==="Enter"&&(c.length===1?i(c[0]):l&&i(s))};return G.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:G.jsxs("div",{className:"rf-bg-white rf-rounded-lg rf-p-6 rf-w-96",children:[G.jsx("h2",{className:"rf-text-lg rf-font-semibold rf-mb-4",children:"Select Snippet"}),G.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:_=>a(_.target.value),onKeyDown:u}),G.jsxs("div",{className:"rf-h-60 rf-overflow-y-auto",children:[c.map(_=>G.jsx("button",{type:"button",className:`w-full text-left px-4 py-2 rounded hover:bg-gray-100 ${r===_?"bg-blue-50":""}`,onClick:()=>i(_),children:_},_)),l&&G.jsxs("button",{type:"button",className:`w-full text-left px-4 py-2 rounded hover:bg-gray-100 text-blue-500 ${r===s?"bg-blue-50":""}`,onClick:()=>i(s),children:['Create new "',s,'"']})]}),G.jsxs("div",{className:"rf-mt-4 rf-flex rf-justify-end rf-gap-2",children:[G.jsx("button",{type:"button",className:"rf-px-4 rf-py-2 rf-text-gray-600 rf-hover:text-gray-800",onClick:n,children:"Cancel"}),G.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:()=>r&&e(r),disabled:!r,children:r===s?`Create "${r}"`:`Save to ${r}`})]})]})})},aKn=t=>{const e=Y.useRef(null),n=eu(o=>o.recentEvents);Y.useEffect(()=>{if(n.length===0)return;const o=n[0];o.event_id!==e.current&&(t(o),e.current=o.event_id)},[n,t])};function cKn(t){const e=lKn(t),n=Y.forwardRef((o,r)=>{const{children:i,...s}=o,a=Y.Children.toArray(i),c=a.find(_Kn);if(c){const l=c.props.children,u=a.map(_=>_===c?Y.Children.count(l)>1?Y.Children.only(null):Y.isValidElement(l)?l.props.children:null:_);return G.jsx(e,{...s,ref:r,children:Y.isValidElement(l)?Y.cloneElement(l,void 0,u):null})}return G.jsx(e,{...s,ref:r,children:i})});return n.displayName=`${t}.Slot`,n}function lKn(t){const e=Y.forwardRef((n,o)=>{const{children:r,...i}=n;if(Y.isValidElement(r)){const s=hKn(r),a=dKn(i,r.props);return r.type!==Y.Fragment&&(a.ref=o?Rx(o,s):s),Y.cloneElement(r,a)}return Y.Children.count(r)>1?Y.Children.only(null):null});return e.displayName=`${t}.SlotClone`,e}var uKn=Symbol("radix.slottable");function _Kn(t){return Y.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===uKn}function dKn(t,e){const n={...e};for(const o in e){const r=t[o],i=e[o];/^on[A-Z]/.test(o)?r&&i?n[o]=(...a)=>{const c=i(...a);return r(...a),c}:r&&(n[o]=r):o==="style"?n[o]={...r,...i}:o==="className"&&(n[o]=[r,i].filter(Boolean).join(" "))}return{...t,...n}}function hKn(t){let e=Object.getOwnPropertyDescriptor(t.props,"ref")?.get,n=e&&"isReactWarning"in e&&e.isReactWarning;return n?t.ref:(e=Object.getOwnPropertyDescriptor(t,"ref")?.get,n=e&&"isReactWarning"in e&&e.isReactWarning,n?t.props.ref:t.props.ref||t.ref)}var SY="Dialog",[Ydt,qdt]=d4(SY),[mKn,B4]=Ydt(SY),Jdt=t=>{const{__scopeDialog:e,children:n,open:o,defaultOpen:r,onOpenChange:i,modal:s=!0}=t,a=Y.useRef(null),c=Y.useRef(null),[l,u]=DP({prop:o,defaultProp:r??!1,onChange:i,caller:SY});return G.jsx(mKn,{scope:e,triggerRef:a,contentRef:c,contentId:Jp(),titleId:Jp(),descriptionId:Jp(),open:l,onOpenChange:u,onOpenToggle:Y.useCallback(()=>u(_=>!_),[u]),modal:s,children:n})};Jdt.displayName=SY;var Kdt="DialogTrigger",Qdt=Y.forwardRef((t,e)=>{const{__scopeDialog:n,...o}=t,r=B4(Kdt,n),i=tu(e,r.triggerRef);return G.jsx(Cc.button,{type:"button","aria-haspopup":"dialog","aria-expanded":r.open,"aria-controls":r.contentId,"data-state":Oye(r.open),...o,ref:i,onClick:Vr(t.onClick,r.onOpenToggle)})});Qdt.displayName=Kdt;var Iye="DialogPortal",[pKn,Zdt]=Ydt(Iye,{forceMount:void 0}),eht=t=>{const{__scopeDialog:e,forceMount:n,children:o,container:r}=t,i=B4(Iye,e);return G.jsx(pKn,{scope:e,forceMount:n,children:Y.Children.map(o,s=>G.jsx(Fg,{present:n||i.open,children:G.jsx(Fj,{asChild:!0,container:r,children:s})}))})};eht.displayName=Iye;var CY="DialogOverlay",tht=Y.forwardRef((t,e)=>{const n=Zdt(CY,t.__scopeDialog),{forceMount:o=n.forceMount,...r}=t,i=B4(CY,t.__scopeDialog);return i.modal?G.jsx(Fg,{present:o||i.open,children:G.jsx(xKn,{...r,ref:e})}):null});tht.displayName=CY;var fKn=cKn("DialogOverlay.RemoveScroll"),xKn=Y.forwardRef((t,e)=>{const{__scopeDialog:n,...o}=t,r=B4(CY,n);return G.jsx(jj,{as:fKn,allowPinchZoom:!0,shards:[r.contentRef],children:G.jsx(Cc.div,{"data-state":Oye(r.open),...o,ref:e,style:{pointerEvents:"auto",...o.style}})})}),eC="DialogContent",nht=Y.forwardRef((t,e)=>{const n=Zdt(eC,t.__scopeDialog),{forceMount:o=n.forceMount,...r}=t,i=B4(eC,t.__scopeDialog);return G.jsx(Fg,{present:o||i.open,children:i.modal?G.jsx(gKn,{...r,ref:e}):G.jsx(yKn,{...r,ref:e})})});nht.displayName=eC;var gKn=Y.forwardRef((t,e)=>{const n=B4(eC,t.__scopeDialog),o=Y.useRef(null),r=tu(e,n.contentRef,o);return Y.useEffect(()=>{const i=o.current;if(i)return Q2e(i)},[]),G.jsx(oht,{...t,ref:r,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Vr(t.onCloseAutoFocus,i=>{i.preventDefault(),n.triggerRef.current?.focus()}),onPointerDownOutside:Vr(t.onPointerDownOutside,i=>{const s=i.detail.originalEvent,a=s.button===0&&s.ctrlKey===!0;(s.button===2||a)&&i.preventDefault()}),onFocusOutside:Vr(t.onFocusOutside,i=>i.preventDefault())})}),yKn=Y.forwardRef((t,e)=>{const n=B4(eC,t.__scopeDialog),o=Y.useRef(!1),r=Y.useRef(!1);return G.jsx(oht,{...t,ref:e,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:i=>{t.onCloseAutoFocus?.(i),i.defaultPrevented||(o.current||n.triggerRef.current?.focus(),i.preventDefault()),o.current=!1,r.current=!1},onInteractOutside:i=>{t.onInteractOutside?.(i),i.defaultPrevented||(o.current=!0,i.detail.originalEvent.type==="pointerdown"&&(r.current=!0));const s=i.target;n.triggerRef.current?.contains(s)&&i.preventDefault(),i.detail.originalEvent.type==="focusin"&&r.current&&i.preventDefault()}})}),oht=Y.forwardRef((t,e)=>{const{__scopeDialog:n,trapFocus:o,onOpenAutoFocus:r,onCloseAutoFocus:i,...s}=t,a=B4(eC,n),c=Y.useRef(null),l=tu(e,c);return N2e(),G.jsxs(G.Fragment,{children:[G.jsx(Mj,{asChild:!0,loop:!0,trapped:o,onMountAutoFocus:r,onUnmountAutoFocus:i,children:G.jsx(eH,{role:"dialog",id:a.contentId,"aria-describedby":a.descriptionId,"aria-labelledby":a.titleId,"data-state":Oye(a.open),...s,ref:l,onDismiss:()=>a.onOpenChange(!1)})}),G.jsxs(G.Fragment,{children:[G.jsx(PKn,{titleId:a.titleId}),G.jsx(SKn,{contentRef:c,descriptionId:a.descriptionId})]})]})}),Lye="DialogTitle",rht=Y.forwardRef((t,e)=>{const{__scopeDialog:n,...o}=t,r=B4(Lye,n);return G.jsx(Cc.h2,{id:r.titleId,...o,ref:e})});rht.displayName=Lye;var iht="DialogDescription",sht=Y.forwardRef((t,e)=>{const{__scopeDialog:n,...o}=t,r=B4(iht,n);return G.jsx(Cc.p,{id:r.descriptionId,...o,ref:e})});sht.displayName=iht;var aht="DialogClose",cht=Y.forwardRef((t,e)=>{const{__scopeDialog:n,...o}=t,r=B4(aht,n);return G.jsx(Cc.button,{type:"button",...o,ref:e,onClick:Vr(t.onClick,()=>r.onOpenChange(!1))})});cht.displayName=aht;function Oye(t){return t?"open":"closed"}var lht="DialogTitleWarning",[bKn,uht]=zZt(lht,{contentName:eC,titleName:Lye,docsSlug:"dialog"}),PKn=({titleId:t})=>{const e=uht(lht),n=`\`${e.contentName}\` requires a \`${e.titleName}\` for the component to be accessible for screen reader users.
|
|
5699
5699
|
|
|
5700
5700
|
If you want to hide the \`${e.titleName}\`, you can wrap it with our VisuallyHidden component.
|
|
5701
5701
|
|
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.
|
|
5
|
+
"version": "0.0.1900",
|
|
6
6
|
"exports": {
|
|
7
7
|
".": "./dist/preview.js",
|
|
8
8
|
"./preview": "./dist/preview.js",
|
|
@@ -113,7 +113,7 @@
|
|
|
113
113
|
"yargs": "^17.7.2"
|
|
114
114
|
},
|
|
115
115
|
"dependencies": {
|
|
116
|
-
"@tscircuit/eval": "^0.0.
|
|
116
|
+
"@tscircuit/eval": "^0.0.803",
|
|
117
117
|
"@tscircuit/solver-utils": "^0.0.7"
|
|
118
118
|
}
|
|
119
119
|
}
|