@tscircuit/runframe 0.0.1812 → 0.0.1814
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1730,7 +1730,7 @@ var useErrorTelemetry = ({
|
|
|
1730
1730
|
};
|
|
1731
1731
|
|
|
1732
1732
|
// package.json
|
|
1733
|
-
var version = "0.0.
|
|
1733
|
+
var version = "0.0.1813";
|
|
1734
1734
|
var package_default = {
|
|
1735
1735
|
name: "@tscircuit/runframe",
|
|
1736
1736
|
main: "dist/preview.js",
|
|
@@ -1846,7 +1846,7 @@ var package_default = {
|
|
|
1846
1846
|
yargs: "^17.7.2"
|
|
1847
1847
|
},
|
|
1848
1848
|
dependencies: {
|
|
1849
|
-
"@tscircuit/eval": "^0.0.
|
|
1849
|
+
"@tscircuit/eval": "^0.0.748",
|
|
1850
1850
|
"@tscircuit/solver-utils": "^0.0.7"
|
|
1851
1851
|
}
|
|
1852
1852
|
};
|
|
@@ -3601,7 +3601,7 @@ var exportGlb = async ({
|
|
|
3601
3601
|
console.log("convertCircuitJsonToGltf", convertCircuitJsonToGltf);
|
|
3602
3602
|
const glbArrayBuffer = await convertCircuitJsonToGltf(circuitJson, {
|
|
3603
3603
|
format: "glb",
|
|
3604
|
-
boardTextureResolution:
|
|
3604
|
+
boardTextureResolution: 1024
|
|
3605
3605
|
});
|
|
3606
3606
|
if (!glbArrayBuffer || !(glbArrayBuffer instanceof ArrayBuffer)) {
|
|
3607
3607
|
throw new Error("Invalid GLB data returned from converter");
|
package/dist/preview.js
CHANGED
package/dist/runner.js
CHANGED
|
@@ -5682,7 +5682,7 @@ test("${l} should solve problem correctly", () => {
|
|
|
5682
5682
|
// Add more specific assertions based on expected output
|
|
5683
5683
|
// expect(solver.netLabelPlacementSolver!.netLabelPlacements).toMatchInlineSnapshot()
|
|
5684
5684
|
})
|
|
5685
|
-
`,_=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"})]})]})},Kut=t=>t.activeSubSolver?[t,...Kut(t.activeSubSolver)]:[t],$jn=({solver:t})=>{const e=Kut(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]=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($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))})]})},bge=t=>{if(t===null||typeof t!="object")return t;if(Array.isArray(t))return t.map(bge);const e={};for(const[n,o]of Object.entries(t))n.startsWith("_")||(e[n]=bge(o));return e},Jjn=(t,e)=>{try{if(typeof t.getConstructorParams!="function"){alert(`getConstructorParams() is not implemented for ${e}`);return}const n=bge(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 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 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 eGn=({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(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 tGn=()=>{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)},[])},nGn=t=>t.toLowerCase().includes("pack")?gTn:t.toLowerCase().includes("rout")?CTn:lTn,oGn=({solverEvents:t=[]})=>{const[e,n]=te.useState(null);tGn();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=Bae[i.solverName];if(!a)return{instance:null,error:`Solver class "${i.solverName}" not found in SOLVERS registry. Available: ${Object.keys(Bae).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=nGn(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(G6,{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(eGn,{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"})})})]})},Qut=({errorMessage:t,errorStack:e,circuitJsonErrors:n})=>{te.useEffect(()=>{if(t){const o=new Error(t);e&&(o.stack=e);try{fL.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{fL.captureException(r,{error_type:o.type})}catch{}}},[n])},Zut="0.0.1811",rGn={version:Zut},Pge={BASE_URL:"/",DEV:!1,MODE:"production",PROD:!0,SSR:!1},vge=new Map,DG=t=>{const e=vge.get(t);return e?Object.fromEntries(Object.entries(e.stores).map(([n,o])=>[n,o.getState()])):{}},iGn=(t,e,n)=>{if(t===void 0)return{type:"untracked",connection:e.connect(n)};const o=vge.get(n.name);if(o)return{type:"tracked",store:t,...o};const r={connection:e.connect(n),stores:{}};return vge.set(n.name,r),{type:"tracked",store:t,...r}},e_t=(t,e={})=>(n,o,r)=>{const{enabled:i,anonymousActionType:s,store:a,...c}=e;let l;try{l=(i??(Pge?"production":void 0)!=="production")&&window.__REDUX_DEVTOOLS_EXTENSION__}catch{}if(!l)return(Pge?"production":void 0)!=="production"&&i&&console.warn("[zustand devtools middleware] Please install/enable Redux devtools extension"),t(n,o,r);const{connection:u,..._}=iGn(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}`},{...DG(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)=>{(Pge?"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 Sge(p.payload,f=>{if(f.type==="__setState"){if(a===void 0){m(f.state);return}Object.keys(f.state).length!==1&&console.error(`
|
|
5685
|
+
`,_=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"})]})]})},Kut=t=>t.activeSubSolver?[t,...Kut(t.activeSubSolver)]:[t],$jn=({solver:t})=>{const e=Kut(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]=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($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))})]})},bge=t=>{if(t===null||typeof t!="object")return t;if(Array.isArray(t))return t.map(bge);const e={};for(const[n,o]of Object.entries(t))n.startsWith("_")||(e[n]=bge(o));return e},Jjn=(t,e)=>{try{if(typeof t.getConstructorParams!="function"){alert(`getConstructorParams() is not implemented for ${e}`);return}const n=bge(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 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 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 eGn=({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(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 tGn=()=>{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)},[])},nGn=t=>t.toLowerCase().includes("pack")?gTn:t.toLowerCase().includes("rout")?CTn:lTn,oGn=({solverEvents:t=[]})=>{const[e,n]=te.useState(null);tGn();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=Bae[i.solverName];if(!a)return{instance:null,error:`Solver class "${i.solverName}" not found in SOLVERS registry. Available: ${Object.keys(Bae).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=nGn(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(G6,{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(eGn,{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"})})})]})},Qut=({errorMessage:t,errorStack:e,circuitJsonErrors:n})=>{te.useEffect(()=>{if(t){const o=new Error(t);e&&(o.stack=e);try{fL.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{fL.captureException(r,{error_type:o.type})}catch{}}},[n])},Zut="0.0.1813",rGn={version:Zut},Pge={BASE_URL:"/",DEV:!1,MODE:"production",PROD:!0,SSR:!1},vge=new Map,DG=t=>{const e=vge.get(t);return e?Object.fromEntries(Object.entries(e.stores).map(([n,o])=>[n,o.getState()])):{}},iGn=(t,e,n)=>{if(t===void 0)return{type:"untracked",connection:e.connect(n)};const o=vge.get(n.name);if(o)return{type:"tracked",store:t,...o};const r={connection:e.connect(n),stores:{}};return vge.set(n.name,r),{type:"tracked",store:t,...r}},e_t=(t,e={})=>(n,o,r)=>{const{enabled:i,anonymousActionType:s,store:a,...c}=e;let l;try{l=(i??(Pge?"production":void 0)!=="production")&&window.__REDUX_DEVTOOLS_EXTENSION__}catch{}if(!l)return(Pge?"production":void 0)!=="production"&&i&&console.warn("[zustand devtools middleware] Please install/enable Redux devtools extension"),t(n,o,r);const{connection:u,..._}=iGn(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}`},{...DG(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)=>{(Pge?"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 Sge(p.payload,f=>{if(f.type==="__setState"){if(a===void 0){m(f.state);return}Object.keys(f.state).length!==1&&console.error(`
|
|
5686
5686
|
[zustand devtools middleware] Unsupported __setState action format.
|
|
5687
5687
|
When using 'store' option in devtools(), the 'state' should have only one key, which is a value of 'store' that was passed in devtools(),
|
|
5688
5688
|
and value of this only key should be a state object. Example: { "type": "__setState", "state": { "abc123Store": { "foo": "bar" } } }
|
|
@@ -5706,7 +5706,7 @@ For more information, see https://radix-ui.com/primitives/docs/components/alert-
|
|
|
5706
5706
|
`&&(D=`
|
|
5707
5707
|
`);var ne=0,ae=!1;this.parse=function(Z,re,se){if(typeof Z!="string")throw new Error("Input must be a string");var le=Z.length,me=A.length,Se=D.length,we=I.length,De=M(H),xe=[],Me=[],pe=[],Ue=ne=0;if(!Z)return ze();if(z||z!==!1&&Z.indexOf(Y)===-1){for(var We=Z.split(D),qe=0;qe<We.length;qe++){if(pe=We[qe],ne+=pe.length,qe!==We.length-1)ne+=D.length;else if(se)return ze();if(!I||pe.substring(0,we)!==I){if(De){if(xe=[],ke(pe.split(A)),Xe(),ae)return ze()}else ke(pe.split(A));if(B&&B<=qe)return xe=xe.slice(0,B),ze(!0)}}return ze()}for(var ge=Z.indexOf(A,ne),Ke=Z.indexOf(D,ne),Fe=new RegExp(x(K)+x(Y),"g"),Ne=Z.indexOf(Y,ne);;)if(Z[ne]===Y)for(Ne=ne,ne++;;){if((Ne=Z.indexOf(Y,Ne+1))===-1)return se||Me.push({type:"Quotes",code:"MissingQuotes",message:"Quoted field unterminated",row:xe.length,index:ne}),Ee();if(Ne===le-1)return Ee(Z.substring(ne,Ne).replace(Fe,Y));if(Y===K&&Z[Ne+1]===K)Ne++;else if(Y===K||Ne===0||Z[Ne-1]!==K){ge!==-1&&ge<Ne+1&&(ge=Z.indexOf(A,Ne+1));var $e=ve((Ke=Ke!==-1&&Ke<Ne+1?Z.indexOf(D,Ne+1):Ke)===-1?ge:Math.min(ge,Ke));if(Z.substr(Ne+1+$e,me)===A){pe.push(Z.substring(ne,Ne).replace(Fe,Y)),Z[ne=Ne+1+$e+me]!==Y&&(Ne=Z.indexOf(Y,ne)),ge=Z.indexOf(A,ne),Ke=Z.indexOf(D,ne);break}if($e=ve(Ke),Z.substring(Ne+1+$e,Ne+1+$e+Se)===D){if(pe.push(Z.substring(ne,Ne).replace(Fe,Y)),Te(Ne+1+$e+Se),ge=Z.indexOf(A,ne),Ne=Z.indexOf(Y,ne),De&&(Xe(),ae))return ze();if(B&&xe.length>=B)return ze(!0);break}Me.push({type:"Quotes",code:"InvalidQuotes",message:"Trailing quote on quoted field is malformed",row:xe.length,index:ne}),Ne++}}else if(I&&pe.length===0&&Z.substring(ne,ne+we)===I){if(Ke===-1)return ze();ne=Ke+Se,Ke=Z.indexOf(D,ne),ge=Z.indexOf(A,ne)}else if(ge!==-1&&(ge<Ke||Ke===-1))pe.push(Z.substring(ne,ge)),ne=ge+me,ge=Z.indexOf(A,ne);else{if(Ke===-1)break;if(pe.push(Z.substring(ne,Ke)),Te(Ke+Se),De&&(Xe(),ae))return ze();if(B&&xe.length>=B)return ze(!0)}return Ee();function ke(et){xe.push(et),Ue=ne}function ve(et){var ot=0;return ot=et!==-1&&(et=Z.substring(Ne+1,et))&&et.trim()===""?et.length:ot}function Ee(et){return se||(et===void 0&&(et=Z.substring(ne)),pe.push(et),ne=le,ke(pe),De&&Xe()),ze()}function Te(et){ne=et,ke(pe),pe=[],Ke=Z.indexOf(D,ne)}function ze(et){if(w.header&&!re&&xe.length&&!j){var ot=xe[0],at=Object.create(null),lt=new Set(ot);let xt=!1;for(let Ct=0;Ct<ot.length;Ct++){let Lt=ot[Ct];if(at[Lt=M(w.transformHeader)?w.transformHeader(Lt,Ct):Lt]){let $t,Ot=at[Lt];for(;$t=Lt+"_"+Ot,Ot++,lt.has($t););lt.add($t),ot[Ct]=$t,at[Lt]++,xt=!0,(V=V===null?{}:V)[$t]=Lt}else at[Lt]=1,ot[Ct]=Lt;lt.add(Lt)}xt&&console.warn("Duplicate headers found and renamed."),j=!0}return{data:xe,errors:Me,meta:{delimiter:A,linebreak:D,aborted:ae,truncated:!!et,cursor:Ue+(re||0),renamedHeaders:V}}}function Xe(){H(ze()),xe=[],Me=[]}},this.abort=function(){ae=!0},this.getCharIndex=function(){return ne}}function g(w){var A=w.data,D=a[A.workerId],I=!1;if(A.error)D.userError(A.error,A.file);else if(A.results&&A.results.data){var H={abort:function(){I=!0,y(A.workerId,{data:[],errors:[],meta:{aborted:!0}})},pause:b,resume:b};if(M(D.userStep)){for(var B=0;B<A.results.data.length&&(D.userStep({data:A.results.data[B],errors:A.results.errors,meta:A.results.meta},H),!I);B++);delete A.results}else M(D.userChunk)&&(D.userChunk(A.results,H,A.file),delete A.results)}A.finished&&!I&&y(A.workerId,A.results)}function y(w,A){var D=a[w];M(D.userComplete)&&D.userComplete(A),D.terminate(),delete a[w]}function b(){throw new Error("Not implemented.")}function v(w){if(typeof w!="object"||w===null)return w;var A,D=Array.isArray(w)?[]:{};for(A in w)D[A]=v(w[A]);return D}function S(w,A){return function(){w.apply(A,arguments)}}function M(w){return typeof w=="function"}return l.parse=function(w,A){var D=(A=A||{}).dynamicTyping||!1;if(M(D)&&(A.dynamicTypingFunction=D,D={}),A.dynamicTyping=D,A.transform=!!M(A.transform)&&A.transform,!A.worker||!l.WORKERS_SUPPORTED)return D=null,l.NODE_STREAM_INPUT,typeof w=="string"?(w=(I=>I.charCodeAt(0)!==65279?I:I.slice(1))(w),D=new(A.download?_:m)(A)):w.readable===!0&&M(w.read)&&M(w.on)?D=new h(A):(o.File&&w instanceof File||w instanceof Object)&&(D=new d(A)),D.stream(w);(D=(()=>{var I;return!!l.WORKERS_SUPPORTED&&(I=(()=>{var H=o.URL||o.webkitURL||null,B=n.toString();return l.BLOB_URL||(l.BLOB_URL=H.createObjectURL(new Blob(["var global = (function() { if (typeof self !== 'undefined') { return self; } if (typeof window !== 'undefined') { return window; } if (typeof global !== 'undefined') { return global; } return {}; })(); global.IS_PAPA_WORKER=true; ","(",B,")();"],{type:"text/javascript"})))})(),(I=new o.Worker(I)).onmessage=g,I.id=c++,a[I.id]=I)})()).userStep=A.step,D.userChunk=A.chunk,D.userComplete=A.complete,D.userError=A.error,A.step=M(A.step),A.chunk=M(A.chunk),A.complete=M(A.complete),A.error=M(A.error),delete A.worker,D.postMessage({input:w,config:A,workerId:D.id})},l.unparse=function(w,A){var D=!1,I=!0,H=",",B=`\r
|
|
5708
5708
|
`,z='"',V=z+z,j=!1,Y=null,K=!1,ne=((()=>{if(typeof A=="object"){if(typeof A.delimiter!="string"||l.BAD_DELIMITERS.filter(function(re){return A.delimiter.indexOf(re)!==-1}).length||(H=A.delimiter),typeof A.quotes!="boolean"&&typeof A.quotes!="function"&&!Array.isArray(A.quotes)||(D=A.quotes),typeof A.skipEmptyLines!="boolean"&&typeof A.skipEmptyLines!="string"||(j=A.skipEmptyLines),typeof A.newline=="string"&&(B=A.newline),typeof A.quoteChar=="string"&&(z=A.quoteChar),typeof A.header=="boolean"&&(I=A.header),Array.isArray(A.columns)){if(A.columns.length===0)throw new Error("Option columns is empty");Y=A.columns}A.escapeChar!==void 0&&(V=A.escapeChar+z),A.escapeFormulae instanceof RegExp?K=A.escapeFormulae:typeof A.escapeFormulae=="boolean"&&A.escapeFormulae&&(K=/^[=+\-@\t\r].*$/)}})(),new RegExp(x(z),"g"));if(typeof w=="string"&&(w=JSON.parse(w)),Array.isArray(w)){if(!w.length||Array.isArray(w[0]))return ae(null,w,j);if(typeof w[0]=="object")return ae(Y||Object.keys(w[0]),w,j)}else if(typeof w=="object")return typeof w.data=="string"&&(w.data=JSON.parse(w.data)),Array.isArray(w.data)&&(w.fields||(w.fields=w.meta&&w.meta.fields||Y),w.fields||(w.fields=Array.isArray(w.data[0])?w.fields:typeof w.data[0]=="object"?Object.keys(w.data[0]):[]),Array.isArray(w.data[0])||typeof w.data[0]=="object"||(w.data=[w.data])),ae(w.fields||[],w.data||[],j);throw new Error("Unable to serialize unrecognized input");function ae(re,se,le){var me="",Se=(typeof re=="string"&&(re=JSON.parse(re)),typeof se=="string"&&(se=JSON.parse(se)),Array.isArray(re)&&0<re.length),we=!Array.isArray(se[0]);if(Se&&I){for(var De=0;De<re.length;De++)0<De&&(me+=H),me+=Z(re[De],De);0<se.length&&(me+=B)}for(var xe=0;xe<se.length;xe++){var Me=(Se?re:se[xe]).length,pe=!1,Ue=Se?Object.keys(se[xe]).length===0:se[xe].length===0;if(le&&!Se&&(pe=le==="greedy"?se[xe].join("").trim()==="":se[xe].length===1&&se[xe][0].length===0),le==="greedy"&&Se){for(var We=[],qe=0;qe<Me;qe++){var ge=we?re[qe]:qe;We.push(se[xe][ge])}pe=We.join("").trim()===""}if(!pe){for(var Ke=0;Ke<Me;Ke++){0<Ke&&!Ue&&(me+=H);var Fe=Se&&we?re[Ke]:Ke;me+=Z(se[xe][Fe],Ke)}xe<se.length-1&&(!le||0<Me&&!Ue)&&(me+=B)}}return me}function Z(re,se){var le,me;return re==null?"":re.constructor===Date?JSON.stringify(re).slice(1,25):(me=!1,K&&typeof re=="string"&&K.test(re)&&(re="'"+re,me=!0),le=re.toString().replace(ne,V),(me=me||D===!0||typeof D=="function"&&D(re,se)||Array.isArray(D)&&D[se]||((Se,we)=>{for(var De=0;De<we.length;De++)if(-1<Se.indexOf(we[De]))return!0;return!1})(le,l.BAD_DELIMITERS)||-1<le.indexOf(H)||le.charAt(0)===" "||le.charAt(le.length-1)===" ")?z+le+z:le)}},l.RECORD_SEP="",l.UNIT_SEP="",l.BYTE_ORDER_MARK="\uFEFF",l.BAD_DELIMITERS=["\r",`
|
|
5709
|
-
`,'"',l.BYTE_ORDER_MARK],l.WORKERS_SUPPORTED=!i&&!!o.Worker,l.NODE_STREAM_INPUT=1,l.LocalChunkSize=10485760,l.RemoteChunkSize=5242880,l.DefaultDelimiter=",",l.Parser=f,l.ParserHandle=p,l.NetworkStreamer=_,l.FileStreamer=d,l.StringStreamer=m,l.ReadableStreamStreamer=h,o.jQuery&&((r=o.jQuery).fn.parse=function(w){var A=w.config||{},D=[];return this.each(function(B){if(!(r(this).prop("tagName").toUpperCase()==="INPUT"&&r(this).attr("type").toLowerCase()==="file"&&o.FileReader)||!this.files||this.files.length===0)return!0;for(var z=0;z<this.files.length;z++)D.push({file:this.files[z],inputElem:this,instanceConfig:r.extend({},A)})}),I(),this;function I(){if(D.length===0)M(w.complete)&&w.complete();else{var B,z,V,j,Y=D[0];if(M(w.before)){var K=w.before(Y.file,Y.inputElem);if(typeof K=="object"){if(K.action==="abort")return B="AbortError",z=Y.file,V=Y.inputElem,j=K.reason,void(M(w.error)&&w.error({name:B},z,V,j));if(K.action==="skip")return void H();typeof K.config=="object"&&(Y.instanceConfig=r.extend(Y.instanceConfig,K.config))}else if(K==="skip")return void H()}var ne=Y.instanceConfig.complete;Y.instanceConfig.complete=function(ae){M(ne)&&ne(ae,Y.file,Y.inputElem),H()},l.parse(Y.file,Y.instanceConfig)}}function H(){D.splice(0,1),I()}}),s&&(o.onmessage=function(w){w=w.data,l.WORKER_ID===void 0&&w&&(l.WORKER_ID=w.workerId),typeof w.input=="string"?o.postMessage({workerId:l.WORKER_ID,results:l.parse(w.input,w.config),finished:!0}):(o.File&&w.input instanceof File||w.input instanceof Object)&&(w=l.parse(w.input,w.config))&&o.postMessage({workerId:l.WORKER_ID,results:w,finished:!0})}),(_.prototype=Object.create(u.prototype)).constructor=_,(d.prototype=Object.create(u.prototype)).constructor=d,(m.prototype=Object.create(m.prototype)).constructor=m,(h.prototype=Object.create(u.prototype)).constructor=h,l})})(OG)),OG.exports}var xqn=fqn();const xdt=Ly(xqn);var gqn=async({circuitJson:t,resolvePart:e})=>{const n=[];for(const o of t){if(o.type!=="pcb_component")continue;const r=t.find(c=>c.type==="source_component"&&c.source_component_id===o.source_component_id);if(!r)continue;const i=await e?.({pcb_component:o,source_component:r})??{};let s="";r.ftype==="simple_resistor"&&(s=gdt(r.resistance)),r.ftype==="simple_capacitor"&&(s=gdt(r.capacitance));const a=!!o.do_not_place;n.push({designator:r.name??o.pcb_component_id,comment:a?"DNP":s,value:a?"DNP":s,footprint:i.footprint||"",supplier_part_number_columns:a?void 0:i.supplier_part_number_columns??(r.supplier_part_numbers?yqn(r.supplier_part_numbers):void 0)})}return n};function yqn(t){const e={};return t?.jlcpcb&&(e["JLCPCB Part #"]=t.jlcpcb[0]),t?.lcsc&&(e["JLCPCB Part #"]=t.lcsc[0]),e}function gdt(t){return t==null?"":typeof t=="string"?t:mqn.formatSI(t)}var bqn=t=>{const e=t.map(o=>{const r=o.supplier_part_number_columns;return Object.values(r||{}).join(", "),Object.entries(o.extra_columns||{}).map(([i,s])=>`${i}: ${s}`).join(", "),{Designator:o.designator,Comment:o.comment,Value:o.value,Footprint:o.footprint,...r}}),n=["Designator","Comment","Value","Footprint"];for(const o of e)for(const r in o)n.includes(r)||n.push(r);return xdt.unparse(e,{columns:n})},ydt=3,Pqn=(t,e={})=>{e.flip_y_axis??=!1;const n=[];for(const o of t)if(o.type==="pcb_component"){const r=Qp(t).source_component.get(o.source_component_id);n.push({designator:r?.name??o.pcb_component_id,mid_x:o.center.x,mid_y:o.center.y*(e.flip_y_axis?-1:1),layer:o.layer,rotation:o.rotation})}return n},vqn=t=>xdt.unparse(Pqn(t).map(e=>({Designator:e.designator,"Mid X":e.mid_x.toFixed(ydt),"Mid Y":e.mid_y.toFixed(ydt),Layer:e.layer,Rotation:e.rotation})));const Iv=(t,e)=>{const{fileName:n,mimeType:o="text/plain"}=e,r=t instanceof Blob?t:new Blob([t],{type:o}),i=URL.createObjectURL(r),s=document.createElement("a");s.href=i,s.download=n,document.body.appendChild(s),s.click(),setTimeout(()=>{document.body.removeChild(s),URL.revokeObjectURL(i)},0)},Sqn=async({circuitJson:t,projectName:e})=>{const n=new Zge,{stringifyGerberCommandLayers:o,convertSoupToGerberCommands:r,convertSoupToExcellonDrillCommands:i,stringifyExcellonDrill:s}=await zS("circuit-json-to-gerber"),a=t.filter(x=>!("error_type"in x)&&!("warning_type"in x)),c=r(a,{flip_y_axis:!1}),l=o(c);for(const[x,f]of Object.entries(l))n.file(`gerber/${x}.gbr`,f);const u=i({circuitJson:a,is_plated:!0,flip_y_axis:!1}),_=s(u);n.file("gerber/drill.drl",_);const d=await gqn({circuitJson:t}),m=await bqn(d);n.file("bom.csv",m);const h=await vqn(t);n.file("pick_and_place.csv",h);const p=await n.generateAsync({type:"blob"});Iv(p,{fileName:`${e}_fabrication_files.zip`})},Cqn=async({circuitJson:t,projectName:e})=>{let n;try{const{convertCircuitJsonToGltf:o}=await zS("circuit-json-to-gltf");console.log("convertCircuitJsonToGltf",o);const r=await o(t,{format:"glb",boardTextureResolution:
|
|
5709
|
+
`,'"',l.BYTE_ORDER_MARK],l.WORKERS_SUPPORTED=!i&&!!o.Worker,l.NODE_STREAM_INPUT=1,l.LocalChunkSize=10485760,l.RemoteChunkSize=5242880,l.DefaultDelimiter=",",l.Parser=f,l.ParserHandle=p,l.NetworkStreamer=_,l.FileStreamer=d,l.StringStreamer=m,l.ReadableStreamStreamer=h,o.jQuery&&((r=o.jQuery).fn.parse=function(w){var A=w.config||{},D=[];return this.each(function(B){if(!(r(this).prop("tagName").toUpperCase()==="INPUT"&&r(this).attr("type").toLowerCase()==="file"&&o.FileReader)||!this.files||this.files.length===0)return!0;for(var z=0;z<this.files.length;z++)D.push({file:this.files[z],inputElem:this,instanceConfig:r.extend({},A)})}),I(),this;function I(){if(D.length===0)M(w.complete)&&w.complete();else{var B,z,V,j,Y=D[0];if(M(w.before)){var K=w.before(Y.file,Y.inputElem);if(typeof K=="object"){if(K.action==="abort")return B="AbortError",z=Y.file,V=Y.inputElem,j=K.reason,void(M(w.error)&&w.error({name:B},z,V,j));if(K.action==="skip")return void H();typeof K.config=="object"&&(Y.instanceConfig=r.extend(Y.instanceConfig,K.config))}else if(K==="skip")return void H()}var ne=Y.instanceConfig.complete;Y.instanceConfig.complete=function(ae){M(ne)&&ne(ae,Y.file,Y.inputElem),H()},l.parse(Y.file,Y.instanceConfig)}}function H(){D.splice(0,1),I()}}),s&&(o.onmessage=function(w){w=w.data,l.WORKER_ID===void 0&&w&&(l.WORKER_ID=w.workerId),typeof w.input=="string"?o.postMessage({workerId:l.WORKER_ID,results:l.parse(w.input,w.config),finished:!0}):(o.File&&w.input instanceof File||w.input instanceof Object)&&(w=l.parse(w.input,w.config))&&o.postMessage({workerId:l.WORKER_ID,results:w,finished:!0})}),(_.prototype=Object.create(u.prototype)).constructor=_,(d.prototype=Object.create(u.prototype)).constructor=d,(m.prototype=Object.create(m.prototype)).constructor=m,(h.prototype=Object.create(u.prototype)).constructor=h,l})})(OG)),OG.exports}var xqn=fqn();const xdt=Ly(xqn);var gqn=async({circuitJson:t,resolvePart:e})=>{const n=[];for(const o of t){if(o.type!=="pcb_component")continue;const r=t.find(c=>c.type==="source_component"&&c.source_component_id===o.source_component_id);if(!r)continue;const i=await e?.({pcb_component:o,source_component:r})??{};let s="";r.ftype==="simple_resistor"&&(s=gdt(r.resistance)),r.ftype==="simple_capacitor"&&(s=gdt(r.capacitance));const a=!!o.do_not_place;n.push({designator:r.name??o.pcb_component_id,comment:a?"DNP":s,value:a?"DNP":s,footprint:i.footprint||"",supplier_part_number_columns:a?void 0:i.supplier_part_number_columns??(r.supplier_part_numbers?yqn(r.supplier_part_numbers):void 0)})}return n};function yqn(t){const e={};return t?.jlcpcb&&(e["JLCPCB Part #"]=t.jlcpcb[0]),t?.lcsc&&(e["JLCPCB Part #"]=t.lcsc[0]),e}function gdt(t){return t==null?"":typeof t=="string"?t:mqn.formatSI(t)}var bqn=t=>{const e=t.map(o=>{const r=o.supplier_part_number_columns;return Object.values(r||{}).join(", "),Object.entries(o.extra_columns||{}).map(([i,s])=>`${i}: ${s}`).join(", "),{Designator:o.designator,Comment:o.comment,Value:o.value,Footprint:o.footprint,...r}}),n=["Designator","Comment","Value","Footprint"];for(const o of e)for(const r in o)n.includes(r)||n.push(r);return xdt.unparse(e,{columns:n})},ydt=3,Pqn=(t,e={})=>{e.flip_y_axis??=!1;const n=[];for(const o of t)if(o.type==="pcb_component"){const r=Qp(t).source_component.get(o.source_component_id);n.push({designator:r?.name??o.pcb_component_id,mid_x:o.center.x,mid_y:o.center.y*(e.flip_y_axis?-1:1),layer:o.layer,rotation:o.rotation})}return n},vqn=t=>xdt.unparse(Pqn(t).map(e=>({Designator:e.designator,"Mid X":e.mid_x.toFixed(ydt),"Mid Y":e.mid_y.toFixed(ydt),Layer:e.layer,Rotation:e.rotation})));const Iv=(t,e)=>{const{fileName:n,mimeType:o="text/plain"}=e,r=t instanceof Blob?t:new Blob([t],{type:o}),i=URL.createObjectURL(r),s=document.createElement("a");s.href=i,s.download=n,document.body.appendChild(s),s.click(),setTimeout(()=>{document.body.removeChild(s),URL.revokeObjectURL(i)},0)},Sqn=async({circuitJson:t,projectName:e})=>{const n=new Zge,{stringifyGerberCommandLayers:o,convertSoupToGerberCommands:r,convertSoupToExcellonDrillCommands:i,stringifyExcellonDrill:s}=await zS("circuit-json-to-gerber"),a=t.filter(x=>!("error_type"in x)&&!("warning_type"in x)),c=r(a,{flip_y_axis:!1}),l=o(c);for(const[x,f]of Object.entries(l))n.file(`gerber/${x}.gbr`,f);const u=i({circuitJson:a,is_plated:!0,flip_y_axis:!1}),_=s(u);n.file("gerber/drill.drl",_);const d=await gqn({circuitJson:t}),m=await bqn(d);n.file("bom.csv",m);const h=await vqn(t);n.file("pick_and_place.csv",h);const p=await n.generateAsync({type:"blob"});Iv(p,{fileName:`${e}_fabrication_files.zip`})},Cqn=async({circuitJson:t,projectName:e})=>{let n;try{const{convertCircuitJsonToGltf:o}=await zS("circuit-json-to-gltf");console.log("convertCircuitJsonToGltf",o);const r=await o(t,{format:"glb",boardTextureResolution:1024});if(!r||!(r instanceof ArrayBuffer))throw new Error("Invalid GLB data returned from converter");n=new Blob([r],{type:"model/gltf-binary"})}catch(o){console.error("GLB Export Error:",o);return}Iv(n,{fileName:`${e}.glb`})},Mqn=async({circuitJson:t,projectName:e})=>{const{convertCircuitJsonToPinoutSvg:n}=await zS("circuit-to-svg"),o=n(t);Iv(o,{fileName:`${e}-pinout.svg`,mimeType:"image/svg+xml"})},Tqn=async({circuitJson:t,projectName:e})=>{const{CircuitJsonToKicadPcbConverter:n,CircuitJsonToKicadSchConverter:o,CircuitJsonToKicadProConverter:r}=await zS("circuit-json-to-kicad"),i=new o(t);i.runUntilFinished();const s=i.getOutputString(),a=new n(t);a.runUntilFinished();const c=a.getOutputString(),l=new r(t,{projectName:e,schematicFilename:`${e}.kicad_sch`,pcbFilename:`${e}.kicad_pcb`});l.runUntilFinished();const u=l.getOutputString(),_=new Zge;return _.file(`${e}.kicad_sch`,s),_.file(`${e}.kicad_pcb`,c),_.file(`${e}.kicad_pro`,u),_},wqn=async({circuitJson:t,projectName:e})=>{const o=await(await Tqn({circuitJson:t,projectName:e})).generateAsync({type:"blob"});Iv(o,{fileName:`${e}_kicad_project.zip`})},Eqn=async({circuitJson:t,libraryName:e})=>{const{CircuitJsonToKicadLibraryConverter:n}=await zS("circuit-json-to-kicad"),o=new n(t,{libraryName:e,footprintLibraryName:e});o.runUntilFinished();const r=o.getOutput(),i=new Zge;i.file(`${e}.kicad_sym`,r.kicadSymString);for(const s of r.footprints){const a=i.folder(`${e}.pretty`);a&&a.file(`${s.footprintName}.kicad_mod`,`${s.kicadModString}
|
|
5710
5710
|
`)}if(r.model3dSourcePaths.length>0){const s=i.folder(`${e}.3dshapes`);if(s)for(const a of r.model3dSourcePaths)try{const c=a.split("/").pop()||a,l=await fetch(a);if(l.ok){const u=await l.arrayBuffer();s.file(c,u)}}catch{}}return i.file("fp-lib-table",r.fpLibTableString),i.file("sym-lib-table",r.symLibTableString),i},Dqn=async({circuitJson:t,projectName:e})=>{const o=await(await Eqn({circuitJson:t,libraryName:e})).generateAsync({type:"blob"});Iv(o,{fileName:`${e}_kicad_library.zip`})},Aqn=async({circuitJson:t,projectName:e})=>{const{circuitJsonToStep:n}=await zS("circuit-json-to-step"),o=t.find(l=>l.type==="pcb_board"),r=o&&"width"in o?o.width:void 0,i=o&&"height"in o?o.height:void 0,s=o&&"thickness"in o?o.thickness:void 0;if(r===void 0||i===void 0||s===void 0){Es.error("Board dimensions not found. Please add a pcb_board with width, height, and thickness to your circuit.");return}let a;try{a=await n(t,{boardWidth:r,boardHeight:i,boardThickness:s,productName:e,includeComponents:!0,includeExternalMeshes:!0})}catch(l){const u=l instanceof Error?l.message:"Unknown error";Es.error(`Failed to convert circuit to STEP format: ${u}`);return}const c=new Blob([a],{type:"application/step"});try{Iv(c,{fileName:`${e}.step`})}catch(l){const u=l instanceof Error?l.message:"Unknown error";Es.error(`Failed to download STEP file: ${u}`)}},bdt=async({circuitJson:t,projectName:e,options:n={}})=>{try{const{convertCircuitJsonToLbrn:o}=await zS("circuit-json-to-lbrn"),i=(await o(t,{includeSilkscreen:n.includeSilkscreen??!1})).toXml(),s=new Blob([i],{type:"application/lbrn"});Iv(s,{fileName:`${e}.lbrn2`})}catch(o){const r=o instanceof Error?o.message:"Unknown error";Es.error(`Failed to export to LBRN format: ${r}`)}},Rqn=t=>{let e=t.trim().replace(/[\\/:*?"<>|]/g,"_").replace(/[\x00-\x1f]/g,"").replace(/^\.+/,"").replace(/\.+$/,"").replace(/\s+/g," ").replace(/_+/g,"_");return/^(con|prn|aux|nul|com[0-9]|lpt[0-9])$/i.test(e)&&(e=`_${e}`),e=e.slice(0,200),e||"untitled"},kqn=[{extension:"json",name:"Circuit JSON"},{extension:"zip",name:"Fabrication Files"},{extension:"zip",name:"KiCad Project"},{extension:"zip",name:"KiCad Library"},{extension:"glb",name:"GLB (Binary GLTF)"},{extension:"svg",name:"Pinout SVG"},{extension:"step",name:"STEP"},{extension:"lbrn2",name:"LightBurn"}],Nqn=async({exportName:t,circuitJson:e,projectName:n})=>{const o=Rqn(n);if(t==="Fabrication Files"){Sqn({circuitJson:e,projectName:o});return}if(t==="KiCad Project"){await wqn({circuitJson:e,projectName:o});return}if(t==="KiCad Library"){await Dqn({circuitJson:e,projectName:o});return}if(t==="Circuit JSON"){Iv(JSON.stringify(e,null,2),{fileName:`${o}.circuit.json`,mimeType:"application/json"});return}if(t==="GLB (Binary GLTF)"){await Cqn({circuitJson:e,projectName:o});return}if(t==="Pinout SVG"){Mqn({circuitJson:e,projectName:o});return}if(t==="STEP"){await Aqn({circuitJson:e,projectName:o});return}if(t==="LightBurn"){await bdt({circuitJson:e,projectName:o});return}throw new Error(`Unsupported export type: "${t}"`)};class VS extends Error{response;request;options;constructor(e,n,o){const r=e.status||e.status===0?e.status:"",i=e.statusText??"",s=`${r} ${i}`.trim(),a=s?`status code ${s}`:"an unknown error";super(`Request failed with ${a}: ${n.method} ${n.url}`),this.name="HTTPError",this.response=e,this.request=n,this.options=o}}class Pdt extends Error{name="NonError";value;constructor(e){let n="Non-error value was thrown";try{typeof e=="string"?n=e:e&&typeof e=="object"&&"message"in e&&typeof e.message=="string"&&(n=e.message)}catch{}super(n),this.value=e}}class tye extends Error{name="ForceRetryError";customDelay;code;customRequest;constructor(e){const n=e?.cause?e.cause instanceof Error?e.cause:new Pdt(e.cause):void 0;super(e?.code?`Forced retry: ${e.code}`:"Forced retry",n?{cause:n}:void 0),this.customDelay=e?.delay,this.code=e?.code,this.customRequest=e?.request}}const vdt=(()=>{let t=!1,e=!1;const n=typeof globalThis.ReadableStream=="function",o=typeof globalThis.Request=="function";if(n&&o)try{e=new globalThis.Request("https://empty.invalid",{body:new globalThis.ReadableStream,method:"POST",get duplex(){return t=!0,"half"}}).headers.has("Content-Type")}catch(r){if(r instanceof Error&&r.message==="unsupported BodyInit type")return!1;throw r}return t&&!e})(),Hqn=typeof globalThis.AbortController=="function",Sdt=typeof globalThis.AbortSignal=="function"&&typeof globalThis.AbortSignal.any=="function",Iqn=typeof globalThis.ReadableStream=="function",Lqn=typeof globalThis.FormData=="function",Cdt=["get","post","put","patch","head","delete"],Oqn={json:"application/json",text:"text/*",formData:"multipart/form-data",arrayBuffer:"*/*",blob:"*/*",bytes:"*/*"},nye=2147483647,Fqn=new TextEncoder().encode("------WebKitFormBoundaryaxpyiPgbbPti10Rw").length,Mdt=Symbol("stop");class Tdt{options;constructor(e){this.options=e}}const Bqn=t=>new Tdt(t),zqn={json:!0,parseJson:!0,stringifyJson:!0,searchParams:!0,prefixUrl:!0,retry:!0,timeout:!0,hooks:!0,throwHttpErrors:!0,onDownloadProgress:!0,onUploadProgress:!0,fetch:!0,context:!0},Vqn={next:!0},$qn={method:!0,headers:!0,body:!0,mode:!0,credentials:!0,cache:!0,redirect:!0,referrer:!0,referrerPolicy:!0,integrity:!0,keepalive:!0,signal:!0,window:!0,duplex:!0},Wqn=t=>{if(!t)return 0;if(t instanceof FormData){let e=0;for(const[n,o]of t)e+=Fqn,e+=new TextEncoder().encode(`Content-Disposition: form-data; name="${n}"`).length,e+=typeof o=="string"?new TextEncoder().encode(o).length:o.size;return e}if(t instanceof Blob)return t.size;if(t instanceof ArrayBuffer)return t.byteLength;if(typeof t=="string")return new TextEncoder().encode(t).length;if(t instanceof URLSearchParams)return new TextEncoder().encode(t.toString()).length;if("byteLength"in t)return t.byteLength;if(typeof t=="object"&&t!==null)try{const e=JSON.stringify(t);return new TextEncoder().encode(e).length}catch{return 0}return 0},wdt=(t,e,n)=>{let o,r=0;return t.pipeThrough(new TransformStream({transform(i,s){if(s.enqueue(i),o){r+=o.byteLength;let a=e===0?0:r/e;a>=1&&(a=1-Number.EPSILON),n?.({percent:a,totalBytes:Math.max(e,r),transferredBytes:r},o)}o=i},flush(){o&&(r+=o.byteLength,n?.({percent:1,totalBytes:Math.max(e,r),transferredBytes:r},o))}}))},Uqn=(t,e)=>{if(!t.body)return t;if(t.status===204)return new Response(null,{status:t.status,statusText:t.statusText,headers:t.headers});const n=Math.max(0,Number(t.headers.get("content-length"))||0);return new Response(wdt(t.body,n,e),{status:t.status,statusText:t.statusText,headers:t.headers})},Xqn=(t,e,n)=>{if(!t.body)return t;const o=Wqn(n??t.body);return new Request(t,{duplex:"half",body:wdt(t.body,o,e)})},$S=t=>t!==null&&typeof t=="object",FG=(...t)=>{for(const e of t)if((!$S(e)||Array.isArray(e))&&e!==void 0)throw new TypeError("The `options` argument must be an object");return oye({},...t)},Edt=(t={},e={})=>{const n=new globalThis.Headers(t),o=e instanceof globalThis.Headers,r=new globalThis.Headers(e);for(const[i,s]of r.entries())o&&s==="undefined"||s===void 0?n.delete(i):n.set(i,s);return n};function BG(t,e,n){return Object.hasOwn(e,n)&&e[n]===void 0?[]:oye(t[n]??[],e[n]??[])}const Ddt=(t={},e={})=>({beforeRequest:BG(t,e,"beforeRequest"),beforeRetry:BG(t,e,"beforeRetry"),afterResponse:BG(t,e,"afterResponse"),beforeError:BG(t,e,"beforeError")}),jqn=(t,e)=>{const n=new URLSearchParams;for(const o of[t,e])if(o!==void 0)if(o instanceof URLSearchParams)for(const[r,i]of o.entries())n.append(r,i);else if(Array.isArray(o))for(const r of o){if(!Array.isArray(r)||r.length!==2)throw new TypeError("Array search parameters must be provided in [[key, value], ...] format");n.append(String(r[0]),String(r[1]))}else if($S(o))for(const[r,i]of Object.entries(o))i!==void 0&&n.append(r,String(i));else{const r=new URLSearchParams(o);for(const[i,s]of r.entries())n.append(i,s)}return n},oye=(...t)=>{let e={},n={},o={},r;const i=[];for(const s of t)if(Array.isArray(s))Array.isArray(e)||(e=[]),e=[...e,...s];else if($S(s)){for(let[a,c]of Object.entries(s)){if(a==="signal"&&c instanceof globalThis.AbortSignal){i.push(c);continue}if(a==="context"){if(c!=null&&(!$S(c)||Array.isArray(c)))throw new TypeError("The `context` option must be an object");e={...e,context:c==null?{}:{...e.context,...c}};continue}if(a==="searchParams"){c==null?r=void 0:r=r===void 0?c:jqn(r,c);continue}$S(c)&&a in e&&(c=oye(e[a],c)),e={...e,[a]:c}}$S(s.hooks)&&(o=Ddt(o,s.hooks),e.hooks=o),$S(s.headers)&&(n=Edt(n,s.headers),e.headers=n)}return r!==void 0&&(e.searchParams=r),i.length>0&&(i.length===1?e.signal=i[0]:Sdt?e.signal=AbortSignal.any(i):e.signal=i.at(-1)),e},Gqn=t=>Cdt.includes(t)?t.toUpperCase():t,Adt={limit:2,methods:["get","put","head","delete","options","trace"],statusCodes:[408,413,429,500,502,503,504],afterStatusCodes:[413,429,503],maxRetryAfter:Number.POSITIVE_INFINITY,backoffLimit:Number.POSITIVE_INFINITY,delay:t=>.3*2**(t-1)*1e3,jitter:void 0,retryOnTimeout:!1},Yqn=(t={})=>{if(typeof t=="number")return{...Adt,limit:t};if(t.methods&&!Array.isArray(t.methods))throw new Error("retry.methods must be an array");if(t.methods&&=t.methods.map(n=>n.toLowerCase()),t.statusCodes&&!Array.isArray(t.statusCodes))throw new Error("retry.statusCodes must be an array");const e=Object.fromEntries(Object.entries(t).filter(([,n])=>n!==void 0));return{...Adt,...e}};class rye extends Error{request;constructor(e){super(`Request timed out: ${e.method} ${e.url}`),this.name="TimeoutError",this.request=e}}async function qqn(t,e,n,o){return new Promise((r,i)=>{const s=setTimeout(()=>{n&&n.abort(),i(new rye(t))},o.timeout);o.fetch(t,e).then(r).catch(i).then(()=>{clearTimeout(s)})})}async function Jqn(t,{signal:e}){return new Promise((n,o)=>{e&&(e.throwIfAborted(),e.addEventListener("abort",r,{once:!0}));function r(){clearTimeout(i),o(e.reason)}const i=setTimeout(()=>{e?.removeEventListener("abort",r),n()},t)})}const Kqn=(t,e)=>{const n={};for(const o in e)Object.hasOwn(e,o)&&!(o in $qn)&&!(o in zqn)&&(!(o in t)||o in Vqn)&&(n[o]=e[o]);return n},Qqn=t=>t===void 0?!1:Array.isArray(t)?t.length>0:t instanceof URLSearchParams?t.size>0:typeof t=="object"?Object.keys(t).length>0:typeof t=="string"?t.trim().length>0:!!t;function Zqn(t){return t instanceof VS||t?.name===VS.name}function eJn(t){return t instanceof rye||t?.name===rye.name}class WH{static create(e,n){const o=new WH(e,n),r=async()=>{if(typeof o.#e.timeout=="number"&&o.#e.timeout>nye)throw new RangeError(`The \`timeout\` option cannot be greater than ${nye}`);await Promise.resolve();let s=await o.#x();for(const a of o.#e.hooks.afterResponse){const c=o.#d(s.clone());let l;try{l=await a(o.request,o.#c(),c,{retryCount:o.#n})}catch(_){throw o.#i(c),o.#i(s),_}if(l instanceof Tdt)throw o.#i(c),o.#i(s),new tye(l.options);const u=l instanceof globalThis.Response?l:s;c!==u&&o.#i(c),s!==u&&o.#i(s),s=u}if(o.#d(s),!s.ok&&(typeof o.#e.throwHttpErrors=="function"?o.#e.throwHttpErrors(s.status):o.#e.throwHttpErrors)){let a=new VS(s,o.request,o.#c());for(const c of o.#e.hooks.beforeError)a=await c(a,{retryCount:o.#n});throw a}if(o.#e.onDownloadProgress){if(typeof o.#e.onDownloadProgress!="function")throw new TypeError("The `onDownloadProgress` option must be a function");if(!Iqn)throw new Error("Streams are not supported in your environment. `ReadableStream` is missing.");const a=s.clone();return o.#i(s),Uqn(a,o.#e.onDownloadProgress)}return s},i=o.#h(r).finally(()=>{const s=o.#s;o.#u(s?.body??void 0),o.#u(o.request.body??void 0)});for(const[s,a]of Object.entries(Oqn))s==="bytes"&&typeof globalThis.Response?.prototype?.bytes!="function"||(i[s]=async()=>{o.request.headers.set("accept",o.request.headers.get("accept")||a);const c=await i;if(s==="json"){if(c.status===204)return"";const l=await c.text();return l===""?"":n.parseJson?n.parseJson(l):JSON.parse(l)}return c[s]()});return i}static#p(e){return e&&typeof e=="object"&&!Array.isArray(e)&&!(e instanceof URLSearchParams)?Object.fromEntries(Object.entries(e).filter(([,n])=>n!==void 0)):e}request;#o;#n=0;#t;#e;#s;#r;#a;constructor(e,n={}){if(this.#t=e,this.#e={...n,headers:Edt(this.#t.headers,n.headers),hooks:Ddt({beforeRequest:[],beforeRetry:[],beforeError:[],afterResponse:[]},n.hooks),method:Gqn(n.method??this.#t.method??"GET"),prefixUrl:String(n.prefixUrl||""),retry:Yqn(n.retry),throwHttpErrors:n.throwHttpErrors??!0,timeout:n.timeout??1e4,fetch:n.fetch??globalThis.fetch.bind(globalThis),context:n.context??{}},typeof this.#t!="string"&&!(this.#t instanceof URL||this.#t instanceof globalThis.Request))throw new TypeError("`input` must be a string, URL, or Request");if(this.#e.prefixUrl&&typeof this.#t=="string"){if(this.#t.startsWith("/"))throw new Error("`input` must not begin with a slash when using `prefixUrl`");this.#e.prefixUrl.endsWith("/")||(this.#e.prefixUrl+="/"),this.#t=this.#e.prefixUrl+this.#t}Hqn&&Sdt&&(this.#r=this.#e.signal??this.#t.signal,this.#o=new globalThis.AbortController,this.#e.signal=this.#r?AbortSignal.any([this.#r,this.#o.signal]):this.#o.signal),vdt&&(this.#e.duplex="half"),this.#e.json!==void 0&&(this.#e.body=this.#e.stringifyJson?.(this.#e.json)??JSON.stringify(this.#e.json),this.#e.headers.set("content-type",this.#e.headers.get("content-type")??"application/json"));const o=n.headers&&new globalThis.Headers(n.headers).has("content-type");if(this.#t instanceof globalThis.Request&&(Lqn&&this.#e.body instanceof globalThis.FormData||this.#e.body instanceof URLSearchParams)&&!o&&this.#e.headers.delete("content-type"),this.request=new globalThis.Request(this.#t,this.#e),Qqn(this.#e.searchParams)){const i="?"+(typeof this.#e.searchParams=="string"?this.#e.searchParams.replace(/^\?/,""):new URLSearchParams(WH.#p(this.#e.searchParams)).toString()),s=this.request.url.replace(/(?:\?.*?)?(?=#|$)/,i);this.request=new globalThis.Request(s,this.#e)}if(this.#e.onUploadProgress){if(typeof this.#e.onUploadProgress!="function")throw new TypeError("The `onUploadProgress` option must be a function");if(!vdt)throw new Error("Request streams are not supported in your environment. The `duplex` option for `Request` is not available.");this.request=this.#m(this.request,this.#e.body??void 0)}}#l(){const e=this.#e.retry.delay(this.#n);let n=e;this.#e.retry.jitter===!0?n=Math.random()*e:typeof this.#e.retry.jitter=="function"&&(n=this.#e.retry.jitter(e),(!Number.isFinite(n)||n<0)&&(n=e));const o=this.#e.retry.backoffLimit??Number.POSITIVE_INFINITY;return Math.min(o,n)}async#f(e){if(this.#n++,this.#n>this.#e.retry.limit)throw e;const n=e instanceof Error?e:new Pdt(e);if(n instanceof tye)return n.customDelay??this.#l();if(!this.#e.retry.methods.includes(this.request.method.toLowerCase()))throw e;if(this.#e.retry.shouldRetry!==void 0){const o=await this.#e.retry.shouldRetry({error:n,retryCount:this.#n});if(o===!1)throw e;if(o===!0)return this.#l()}if(eJn(e)&&!this.#e.retry.retryOnTimeout)throw e;if(Zqn(e)){if(!this.#e.retry.statusCodes.includes(e.response.status))throw e;const o=e.response.headers.get("Retry-After")??e.response.headers.get("RateLimit-Reset")??e.response.headers.get("X-RateLimit-Retry-After")??e.response.headers.get("X-RateLimit-Reset")??e.response.headers.get("X-Rate-Limit-Reset");if(o&&this.#e.retry.afterStatusCodes.includes(e.response.status)){let r=Number(o)*1e3;Number.isNaN(r)?r=Date.parse(o)-Date.now():r>=Date.parse("2024-01-01")&&(r-=Date.now());const i=this.#e.retry.maxRetryAfter??r;return r<i?r:i}if(e.response.status===413)throw e}return this.#l()}#d(e){return this.#e.parseJson&&(e.json=async()=>this.#e.parseJson(await e.text())),e}#u(e){e&&e.cancel().catch(()=>{})}#i(e){this.#u(e.body??void 0)}async#h(e){try{return await e()}catch(n){const o=Math.min(await this.#f(n),nye);if(this.#n<1)throw n;if(await Jqn(o,this.#r?{signal:this.#r}:{}),n instanceof tye&&n.customRequest){const r=this.#e.signal?new globalThis.Request(n.customRequest,{signal:this.#e.signal}):new globalThis.Request(n.customRequest);this.#_(r)}for(const r of this.#e.hooks.beforeRetry){const i=await r({request:this.request,options:this.#c(),error:n,retryCount:this.#n});if(i instanceof globalThis.Request){this.#_(i);break}if(i instanceof globalThis.Response)return i;if(i===Mdt)return}return this.#h(e)}}async#x(){this.#o?.signal.aborted&&(this.#o=new globalThis.AbortController,this.#e.signal=this.#r?AbortSignal.any([this.#r,this.#o.signal]):this.#o.signal,this.request=new globalThis.Request(this.request,{signal:this.#e.signal}));for(const n of this.#e.hooks.beforeRequest){const o=await n(this.request,this.#c(),{retryCount:this.#n});if(o instanceof Response)return o;if(o instanceof globalThis.Request){this.#_(o);break}}const e=Kqn(this.request,this.#e);return this.#s=this.request,this.request=this.#s.clone(),this.#e.timeout===!1?this.#e.fetch(this.#s,e):qqn(this.#s,e,this.#o,this.#e)}#c(){if(!this.#a){const{hooks:e,...n}=this.#e;this.#a=Object.freeze(n)}return this.#a}#_(e){this.#a=void 0,this.request=this.#m(e)}#m(e,n){return!this.#e.onUploadProgress||!e.body?e:Xqn(e,this.#e.onUploadProgress,n??this.#e.body??void 0)}}const iye=t=>{const e=(n,o)=>WH.create(n,FG(t,o));for(const n of Cdt)e[n]=(o,r)=>WH.create(o,FG(t,r,{method:n}));return e.create=n=>iye(FG(n)),e.extend=n=>(typeof n=="function"&&(n=n(t??{})),iye(FG(t,n))),e.stop=Mdt,e.retry=Bqn,e},tJn=iye();class nJn extends VS{constructor(e,n,o,r){super(e,n,o),this.name="RegistryHTTPError",this.message=r}}function zG(t){return typeof window<"u"?window[t]:null}function WS(){const t=zG("TSCIRCUIT_REGISTRY_API_BASE_URL")||void 0||"https://registry-api.tscircuit.com",e=zG("TSCIRCUIT_REGISTRY_TOKEN");return tJn.create({prefixUrl:t,headers:{Authorization:`Bearer ${e}`},timeout:3e4,hooks:{afterResponse:[async(n,o,r)=>{if(r.ok)return r;let i=null;try{i=await r.clone().json()}catch(_){console.error("Failed to parse registry error response",_)}const s=i?.error?.message??i?.error?.error_message??i?.message,a=i?.error?.error_code??i?.error_code,c=new URL(r.url),u=[`Registry request failed for ${`${c.pathname}${c.search}`} (${r.status})`];throw s&&u.push(`Server message: ${s}`),a&&u.push(`Error code: ${a}`),new nJn(r,n,o,u.join(" | "))}]}})}function VG(){return!!zG("TSCIRCUIT_REGISTRY_TOKEN")}const $G={get:(t,e)=>WS().get(t,e),post:(t,e)=>WS().post(t,e),put:(t,e)=>WS().put(t,e),delete:(t,e)=>WS().delete(t,e),patch:(t,e)=>WS().patch(t,e)},oJn=({packageName:t,onSelectReview:e})=>{const n=d3(_=>_.fsMap),o=d3(_=>_.circuitJson),[r,i]=te.useState([]),[s,a]=te.useState(!1),[c,l]=te.useState(!1);te.useEffect(()=>{!t||!VG()||(a(!0),$G.get("ai_reviews/list",{searchParams:{package_name:t}}).json().then(_=>i(_.ai_reviews)).catch(_=>{console.error("Failed to load AI reviews",_),Es.error("Failed to load AI reviews")}).finally(()=>a(!1)))},[t]);const u=async()=>{if(!o){Es.error("Need Circuit JSON to Request AI Review");return}if(!VG()){Es.error("Missing registry token");return}l(!0);try{const{ai_review:_}=await $G.post("ai_reviews/create",{json:{package_name:t??"unknown",fs_map:Object.fromEntries(n),circuit_json:o}}).json();i(d=>[_,...d]),e(_),Es.success("AI review requested")}catch(_){console.error("Failed to create AI review",_),Es.error("Failed to request AI review")}finally{l(!1)}};return G.jsxs(G.Fragment,{children:[G.jsxs(NE,{children:[G.jsx(HE,{children:"AI Review"}),G.jsx(zH,{children:"Select an AI review or request a new one."})]}),G.jsx("div",{className:"rf-flex rf-gap-4 rf-mt-4",children:G.jsx("div",{className:"rf-w-48 rf-h-64 rf-overflow-y-auto rf-border rf-rounded rf-p-2 rf-flex-shrink-0",children:s?G.jsx("div",{className:"rf-text-sm",children:"Loading..."}):r.length>0?r.map(_=>G.jsx("div",{className:"rf-text-sm rf-p-2 rf-cursor-pointer rf-rounded hover:rf-bg-zinc-100",onClick:()=>e(_),children:new Date(_.created_at||"").toLocaleString()},_.ai_review_id)):G.jsx("div",{className:"rf-text-sm rf-text-muted-foreground",children:"No AI reviews found."})})}),G.jsx(BH,{className:"rf-mt-4",children:G.jsx(T0,{onClick:u,disabled:c,children:c?"Requesting...":"Review my Board"})})]})};function sye(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var US=sye();function Rdt(t){US=t}var UH={exec:()=>null};function Oc(t,e=""){let n=typeof t=="string"?t:t.source;const o={replace:(r,i)=>{let s=typeof i=="string"?i:i.source;return s=s.replace(h2.caret,"$1"),n=n.replace(r,s),o},getRegex:()=>new RegExp(n,e)};return o}var h2={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceTabs:/^\t+/,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] /,listReplaceTask:/^\[[ xX]\] +/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,unescapeTest:/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:t=>new RegExp(`^( {0,3}${t})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),hrRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}#`),htmlBeginRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}<(?:[a-z].*>|!--)`,"i")},rJn=/^(?:[ \t]*(?:\n|$))+/,iJn=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,sJn=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,XH=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,aJn=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,aye=/(?:[*+-]|\d{1,9}[.)])/,kdt=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,Ndt=Oc(kdt).replace(/bull/g,aye).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,"").getRegex(),cJn=Oc(kdt).replace(/bull/g,aye).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),cye=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,lJn=/^[^\n]+/,lye=/(?!\s*\])(?:\\.|[^\[\]\\])+/,uJn=Oc(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",lye).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),_Jn=Oc(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,aye).getRegex(),WG="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",uye=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,dJn=Oc("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))","i").replace("comment",uye).replace("tag",WG).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),Hdt=Oc(cye).replace("hr",XH).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",WG).getRegex(),hJn=Oc(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",Hdt).getRegex(),_ye={blockquote:hJn,code:iJn,def:uJn,fences:sJn,heading:aJn,hr:XH,html:dJn,lheading:Ndt,list:_Jn,newline:rJn,paragraph:Hdt,table:UH,text:lJn},Idt=Oc("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",XH).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code","(?: {4}| {0,3} )[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",WG).getRegex(),mJn={..._ye,lheading:cJn,table:Idt,paragraph:Oc(cye).replace("hr",XH).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",Idt).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",WG).getRegex()},pJn={..._ye,html:Oc(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",uye).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:UH,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:Oc(cye).replace("hr",XH).replace("heading",` *#{1,6} *[^
|
|
5711
5711
|
]`).replace("lheading",Ndt).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},fJn=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,xJn=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,Ldt=/^( {2,}|\\)\n(?!\s*$)/,gJn=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,UG=/[\p{P}\p{S}]/u,dye=/[\s\p{P}\p{S}]/u,Odt=/[^\s\p{P}\p{S}]/u,yJn=Oc(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,dye).getRegex(),Fdt=/(?!~)[\p{P}\p{S}]/u,bJn=/(?!~)[\s\p{P}\p{S}]/u,PJn=/(?:[^\s\p{P}\p{S}]|~)/u,vJn=/\[[^[\]]*?\]\((?:\\.|[^\\\(\)]|\((?:\\.|[^\\\(\)])*\))*\)|`[^`]*?`|<[^<>]*?>/g,Bdt=/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,SJn=Oc(Bdt,"u").replace(/punct/g,UG).getRegex(),CJn=Oc(Bdt,"u").replace(/punct/g,Fdt).getRegex(),zdt="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",MJn=Oc(zdt,"gu").replace(/notPunctSpace/g,Odt).replace(/punctSpace/g,dye).replace(/punct/g,UG).getRegex(),TJn=Oc(zdt,"gu").replace(/notPunctSpace/g,PJn).replace(/punctSpace/g,bJn).replace(/punct/g,Fdt).getRegex(),wJn=Oc("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,Odt).replace(/punctSpace/g,dye).replace(/punct/g,UG).getRegex(),EJn=Oc(/\\(punct)/,"gu").replace(/punct/g,UG).getRegex(),DJn=Oc(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme",/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email",/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),AJn=Oc(uye).replace("(?:-->|$)","-->").getRegex(),RJn=Oc("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment",AJn).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),XG=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,kJn=Oc(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]*(?:\n[ \t]*)?)(title))?\s*\)/).replace("label",XG).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),Vdt=Oc(/^!?\[(label)\]\[(ref)\]/).replace("label",XG).replace("ref",lye).getRegex(),$dt=Oc(/^!?\[(ref)\](?:\[\])?/).replace("ref",lye).getRegex(),NJn=Oc("reflink|nolink(?!\\()","g").replace("reflink",Vdt).replace("nolink",$dt).getRegex(),hye={_backpedal:UH,anyPunctuation:EJn,autolink:DJn,blockSkip:vJn,br:Ldt,code:xJn,del:UH,emStrongLDelim:SJn,emStrongRDelimAst:MJn,emStrongRDelimUnd:wJn,escape:fJn,link:kJn,nolink:$dt,punctuation:yJn,reflink:Vdt,reflinkSearch:NJn,tag:RJn,text:gJn,url:UH},HJn={...hye,link:Oc(/^!?\[(label)\]\((.*?)\)/).replace("label",XG).getRegex(),reflink:Oc(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",XG).getRegex()},mye={...hye,emStrongRDelimAst:TJn,emStrongLDelim:CJn,url:Oc(/^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/,"i").replace("email",/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\.|[^\\])*?(?:\\.|[^\s~\\]))\1(?=[^~]|$)/,text:/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|https?:\/\/|ftp:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/},IJn={...mye,br:Oc(Ldt).replace("{2,}","*").getRegex(),text:Oc(mye.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},jG={normal:_ye,gfm:mJn,pedantic:pJn},jH={normal:hye,gfm:mye,breaks:IJn,pedantic:HJn},LJn={"&":"&","<":"<",">":">",'"':""","'":"'"},Wdt=t=>LJn[t];function m3(t,e){if(e){if(h2.escapeTest.test(t))return t.replace(h2.escapeReplace,Wdt)}else if(h2.escapeTestNoEncode.test(t))return t.replace(h2.escapeReplaceNoEncode,Wdt);return t}function Udt(t){try{t=encodeURI(t).replace(h2.percentDecode,"%")}catch{return null}return t}function Xdt(t,e){const n=t.replace(h2.findPipe,(i,s,a)=>{let c=!1,l=s;for(;--l>=0&&a[l]==="\\";)c=!c;return c?"|":" |"}),o=n.split(h2.splitPipe);let r=0;if(o[0].trim()||o.shift(),o.length>0&&!o.at(-1)?.trim()&&o.pop(),e)if(o.length>e)o.splice(e);else for(;o.length<e;)o.push("");for(;r<o.length;r++)o[r]=o[r].trim().replace(h2.slashPipe,"|");return o}function GH(t,e,n){const o=t.length;if(o===0)return"";let r=0;for(;r<o&&t.charAt(o-r-1)===e;)r++;return t.slice(0,o-r)}function OJn(t,e){if(t.indexOf(e[1])===-1)return-1;let n=0;for(let o=0;o<t.length;o++)if(t[o]==="\\")o++;else if(t[o]===e[0])n++;else if(t[o]===e[1]&&(n--,n<0))return o;return n>0?-2:-1}function jdt(t,e,n,o,r){const i=e.href,s=e.title||null,a=t[1].replace(r.other.outputLinkReplace,"$1");o.state.inLink=!0;const c={type:t[0].charAt(0)==="!"?"image":"link",raw:n,href:i,title:s,text:a,tokens:o.inlineTokens(a)};return o.state.inLink=!1,c}function FJn(t,e,n){const o=t.match(n.other.indentCodeCompensation);if(o===null)return e;const r=o[1];return e.split(`
|
|
5712
5712
|
`).map(i=>{const s=i.match(n.other.beginningSpace);if(s===null)return i;const[a]=s;return a.length>=r.length?i.slice(r.length):i}).join(`
|
package/dist/standalone.min.js
CHANGED
|
@@ -5686,7 +5686,7 @@ test("${l} should solve problem correctly", () => {
|
|
|
5686
5686
|
// Add more specific assertions based on expected output
|
|
5687
5687
|
// expect(solver.netLabelPlacementSolver!.netLabelPlacements).toMatchInlineSnapshot()
|
|
5688
5688
|
})
|
|
5689
|
-
`,_=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 j.jsxs("div",{className:`relative ${e}`,ref:r,children:[j.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&&j.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:[j.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:i,children:"Download JSON"}),j.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:s,children:"Download page.tsx"}),j.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:a,children:"Download test.ts"})]})]})},bdt=t=>t.activeSubSolver?[t,...bdt(t.activeSubSolver)]:[t],$qn=({solver:t})=>{const e=bdt(t);return j.jsx("div",{className:"flex gap-1 items-center text-sm pt-1",children:e.map((n,o)=>j.jsxs("div",{className:"flex items-center",children:[o>0&&j.jsx("span",{className:"text-gray-400 mx-1",children:"→"}),j.jsx(Vqn,{solver:n})]},n.constructor.name))})},Wqn=({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 j.jsxs("div",{className:"space-y-2 p-2 border-b",children:[j.jsx("div",{className:"flex items-center",children:j.jsx($qn,{solver:t})}),j.jsxs("div",{className:"flex gap-2 items-center flex-wrap",children:[j.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"}),j.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"}),j.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"}),j.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&&j.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"}),j.jsxs("div",{className:"text-sm text-gray-600",children:["Iterations: ",t.iterations]}),t.timeToSolve!==void 0&&j.jsxs("div",{className:"text-sm text-gray-600",children:["Time: ",(t.timeToSolve/1e3).toFixed(3),"s"]}),h&&j.jsxs("div",{className:"text-sm text-gray-600",children:["Phase: ",j.jsx("span",{className:"font-medium",children:h})]}),t.solved&&j.jsx("div",{className:"px-2 py-1 bg-green-100 text-green-800 rounded text-sm",children:"Solved"}),t.failed&&j.jsx("div",{className:"px-2 py-1 bg-red-100 text-red-800 rounded text-sm",children:"Failed"})]}),t.error&&j.jsxs("div",{className:"text-red-600 text-sm",children:["Error: ",t.error]})]})},Uqn=(t,e,n)=>{const o=t.currentPipelineStepIndex;return e<o?"Completed":e===o&&t.activeSubSolver?t.activeSubSolver.failed?"Failed":"In Progress":"Not Started"},Xqn=(t,e)=>{const o=t.pipelineDef[e].solverName,r=Uqn(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}},jqn=({status:t})=>{const e={"Not Started":"text-blue-600","In Progress":"text-yellow-600",Completed:"text-green-600",Failed:"text-red-600"};return j.jsx("span",{className:`font-medium ${e[t]}`,children:t})},Gqn=({progress:t})=>{if(t===0)return null;const e=Math.round(t*100);return j.jsxs("div",{className:"flex items-center gap-2",children:[j.jsx("div",{className:"w-20 h-2 bg-gray-200 rounded overflow-hidden",children:j.jsx("div",{className:"h-full bg-blue-500 transition-all duration-200",style:{width:`${e}%`}})}),j.jsxs("span",{className:"text-xs text-gray-500",children:[e,"%"]})]})},Yqn=t=>Object.entries(t).map(([e,n])=>`${e}: ${n}`).join(", "),qqn=({stats:t})=>{if(!t||Object.keys(t).length===0)return j.jsx("span",{children:"-"});const e=Object.entries(t),n=Yqn(t);return j.jsxs("details",{className:"cursor-pointer",children:[j.jsx("summary",{className:"whitespace-nowrap overflow-hidden text-ellipsis max-w-[200px]",children:n}),j.jsx("div",{className:"mt-1 text-xs",children:e.map(([o,r])=>j.jsxs("div",{children:[o,": ",String(r)]},o))})]})},wye=t=>{if(t===null||typeof t!="object")return t;if(Array.isArray(t))return t.map(wye);const e={};for(const[n,o]of Object.entries(t))n.startsWith("_")||(e[n]=wye(o));return e},Jqn=(t,e)=>{try{if(typeof t.getConstructorParams!="function"){alert(`getConstructorParams() is not implemented for ${e}`);return}const n=wye(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)}`)}},Kqn=({solver:t,onStepUntilPhase:e,onDownloadInput:n})=>{const o=t.pipelineDef.map((a,c)=>Xqn(t,c)),r=a=>{e?.(a)},i=a=>{a.solverInstance&&(n?n(a.solverInstance,a.name):Jqn(a.solverInstance,a.name))},s=a=>`${(a/1e3).toFixed(2)}s`;return j.jsxs("div",{className:"border-t border-gray-200",children:[j.jsx("div",{className:"px-4 py-2 bg-gray-50 border-b border-gray-200",children:j.jsx("h3",{className:"text-sm font-semibold text-gray-700",children:"Pipeline Steps"})}),j.jsx("div",{className:"overflow-x-auto",children:j.jsxs("table",{className:"w-full text-sm",children:[j.jsx("thead",{children:j.jsxs("tr",{className:"bg-gray-50 border-b border-gray-200",children:[j.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Step"}),j.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Status"}),j.jsxs("th",{className:"px-4 py-2 text-center font-semibold text-gray-700",children:["i",j.jsx("sub",{children:"0"})]}),j.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Iterations"}),j.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Progress"}),j.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Time"}),j.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Stats"}),j.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Input"})]})}),j.jsx("tbody",{children:o.map(a=>j.jsxs("tr",{className:`border-b border-gray-100 ${a.status==="In Progress"?"bg-yellow-50":""}`,children:[j.jsx("td",{className:"px-4 py-2",children:j.jsxs("div",{className:"flex items-center gap-2",children:[j.jsx("span",{className:"text-gray-400 w-6",children:String(a.index+1).padStart(2,"0")}),j.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:j.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:j.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"})})}),j.jsx("span",{className:"font-medium text-gray-900",children:a.name})]})}),j.jsx("td",{className:"px-4 py-2",children:j.jsx(jqn,{status:a.status})}),j.jsx("td",{className:"px-4 py-2 text-center text-gray-600",children:a.firstIteration!==null?a.firstIteration:""}),j.jsx("td",{className:"px-4 py-2 text-gray-600",children:a.iterations}),j.jsx("td",{className:"px-4 py-2",children:j.jsx(Gqn,{progress:a.progress})}),j.jsx("td",{className:"px-4 py-2 text-gray-600",children:s(a.timeSpent)}),j.jsx("td",{className:"px-4 py-2 text-gray-500",children:j.jsx(qqn,{stats:a.stats})}),j.jsx("td",{className:"px-4 py-2",children:a.solverInstance?j.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:[j.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:j.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"})}),j.jsx("span",{children:"Input"})]}):null})]},a.name))})]})})]})},Qqn=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 Zqn({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 j.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)=>j.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)=>j.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)=>j.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)=>j.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)=>j.jsx("text",{x:x.x??0,y:x.y??0,fontSize:x.fontSize??10,fill:x.color??"black",children:x.text??""},`text-${f}`))]})}var eJn=({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 j.jsxs("div",{children:[j.jsx(Wqn,{solver:t,triggerRender:i,animationSpeed:e,onSolverStarted:n,onSolverCompleted:o}),a?j.jsx("div",{className:"p-4 text-gray-500",children:"No Graphics Yet"}):j.jsx(Qqn,{fallback:j.jsx(Zqn,{graphics:s}),children:j.jsx(zqn,{graphics:s})}),c&&j.jsx(Kqn,{solver:t,onStepUntilPhase:l})]})};const tJn=()=>{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)},[])},nJn=t=>t.toLowerCase().includes("pack")?RDn:t.toLowerCase().includes("rout")?LDn:fDn,oJn=({solverEvents:t=[]})=>{const[e,n]=Y.useState(null);tJn();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=Fie[i.solverName];if(!a)return{instance:null,error:`Solver class "${i.solverName}" not found in SOLVERS registry. Available: ${Object.keys(Fie).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?j.jsx("div",{className:"rf-p-4",children:j.jsx("div",{className:"rf-bg-gray-50 rf-rounded-md rf-border rf-border-gray-200",children:j.jsxs("div",{className:"rf-p-4",children:[j.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800 rf-mb-3",children:"No Solvers Detected"}),j.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."})]})})}):j.jsxs("div",{className:"rf-flex rf-h-full rf-overflow-hidden",children:[j.jsxs("div",{className:"rf-w-64 rf-border-r rf-border-gray-200 rf-overflow-y-auto rf-flex-shrink-0",children:[j.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 j.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=nJn(c.solverName);return j.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2",children:[j.jsx(u,{className:"rf-w-4 rf-h-4 rf-text-blue-500 rf-flex-shrink-0"}),j.jsxs("div",{className:"rf-flex-1 rf-min-w-0",children:[j.jsx("div",{className:"rf-text-sm rf-font-medium rf-text-gray-800 rf-truncate",children:c.componentName}),j.jsx("div",{className:"rf-text-xs rf-text-gray-500 rf-truncate",children:c.solverName})]})]})})()},a)})]}),j.jsx("div",{className:"rf-flex-1 rf-overflow-hidden",children:i?s.instance?j.jsx(M5,{fallback:j.jsx("div",{className:"rf-p-4",children:j.jsxs("div",{className:"rf-bg-red-50 rf-rounded-md rf-border rf-border-red-200 rf-p-4",children:[j.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-red-800 rf-mb-2",children:"Error Loading Solver Debugger"}),j.jsxs("p",{className:"rf-text-sm rf-text-red-600",children:["Failed to render the solver debugger for"," ",i.solverName]})]})}),children:j.jsx(eJn,{solver:s.instance})}):j.jsxs("div",{className:"rf-p-4",children:[j.jsxs("div",{className:"rf-mb-4",children:[j.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800",children:i.solverName}),j.jsxs("p",{className:"rf-text-sm rf-text-gray-500",children:["Component: ",i.componentName]})]}),s.error&&j.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:j.jsx("p",{className:`rf-text-sm ${s.classFound?"rf-text-red-700":"rf-text-yellow-700"}`,children:s.error})}),j.jsxs("div",{className:"rf-border rf-border-gray-200 rf-rounded-md rf-overflow-hidden",children:[j.jsx("div",{className:"rf-px-3 rf-py-2 rf-bg-gray-50",children:j.jsx("span",{className:"rf-text-sm rf-font-medium rf-text-gray-700",children:"Solver Parameters"})}),j.jsx("div",{className:"rf-p-3 rf-bg-white rf-border-t rf-border-gray-200",children:j.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)})})]})]}):j.jsx("div",{className:"rf-flex rf-items-center rf-justify-center rf-h-full",children:j.jsx("p",{className:"rf-text-sm rf-text-gray-500",children:"Select a solver from the list to view details"})})})]})},Pdt=({errorMessage:t,errorStack:e,circuitJsonErrors:n})=>{Y.useEffect(()=>{if(t){const o=new Error(t);e&&(o.stack=e);try{MW.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{MW.captureException(r,{error_type:o.type})}catch{}}},[n])},vdt="0.0.1811",rJn={version:vdt},xY=IIe()(LIe(t=>({lastRunEvalVersion:void 0,setLastRunEvalVersion:e=>{t({lastRunEvalVersion:e})}}),{name:"runframe-runner-store"})),iJn=t=>{const[e,n]=Y.useState([]),[o,r]=Y.useState(null),[i,s]=Y.useState(""),[a,c]=DT("eval-version-selection",null),l=xY(m=>m.setLastRunEvalVersion),u=xY(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("")}}},sJn=({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 j.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:j.jsxs("div",{className:"rf-bg-white rf-rounded-lg rf-p-6 rf-w-96",children:[j.jsx("h2",{className:"rf-text-lg rf-font-semibold rf-mb-4",children:"Select Snippet"}),j.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}),j.jsxs("div",{className:"rf-h-60 rf-overflow-y-auto",children:[c.map(_=>j.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&&j.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,'"']})]}),j.jsxs("div",{className:"rf-mt-4 rf-flex rf-justify-end rf-gap-2",children:[j.jsx("button",{type:"button",className:"rf-px-4 rf-py-2 rf-text-gray-600 rf-hover:text-gray-800",onClick:n,children:"Cancel"}),j.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}`})]})]})})},aJn=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 cJn(t){const e=lJn(t),n=Y.forwardRef((o,r)=>{const{children:i,...s}=o,a=Y.Children.toArray(i),c=a.find(_Jn);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 j.jsx(e,{...s,ref:r,children:Y.isValidElement(l)?Y.cloneElement(l,void 0,u):null})}return j.jsx(e,{...s,ref:r,children:i})});return n.displayName=`${t}.Slot`,n}function lJn(t){const e=Y.forwardRef((n,o)=>{const{children:r,...i}=n;if(Y.isValidElement(r)){const s=hJn(r),a=dJn(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 uJn=Symbol("radix.slottable");function _Jn(t){return Y.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===uJn}function dJn(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 hJn(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 gY="Dialog",[Sdt,Cdt]=_4(gY),[mJn,F4]=Sdt(gY),Mdt=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:gY});return j.jsx(mJn,{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})};Mdt.displayName=gY;var Tdt="DialogTrigger",wdt=Y.forwardRef((t,e)=>{const{__scopeDialog:n,...o}=t,r=F4(Tdt,n),i=tu(e,r.triggerRef);return j.jsx(Cc.button,{type:"button","aria-haspopup":"dialog","aria-expanded":r.open,"aria-controls":r.contentId,"data-state":Aye(r.open),...o,ref:i,onClick:Vr(t.onClick,r.onOpenToggle)})});wdt.displayName=Tdt;var Eye="DialogPortal",[pJn,Edt]=Sdt(Eye,{forceMount:void 0}),Ddt=t=>{const{__scopeDialog:e,forceMount:n,children:o,container:r}=t,i=F4(Eye,e);return j.jsx(pJn,{scope:e,forceMount:n,children:Y.Children.map(o,s=>j.jsx(Fg,{present:n||i.open,children:j.jsx(Nj,{asChild:!0,container:r,children:s})}))})};Ddt.displayName=Eye;var yY="DialogOverlay",Adt=Y.forwardRef((t,e)=>{const n=Edt(yY,t.__scopeDialog),{forceMount:o=n.forceMount,...r}=t,i=F4(yY,t.__scopeDialog);return i.modal?j.jsx(Fg,{present:o||i.open,children:j.jsx(xJn,{...r,ref:e})}):null});Adt.displayName=yY;var fJn=cJn("DialogOverlay.RemoveScroll"),xJn=Y.forwardRef((t,e)=>{const{__scopeDialog:n,...o}=t,r=F4(yY,n);return j.jsx(Vj,{as:fJn,allowPinchZoom:!0,shards:[r.contentRef],children:j.jsx(Cc.div,{"data-state":Aye(r.open),...o,ref:e,style:{pointerEvents:"auto",...o.style}})})}),K8="DialogContent",Rdt=Y.forwardRef((t,e)=>{const n=Edt(K8,t.__scopeDialog),{forceMount:o=n.forceMount,...r}=t,i=F4(K8,t.__scopeDialog);return j.jsx(Fg,{present:o||i.open,children:i.modal?j.jsx(gJn,{...r,ref:e}):j.jsx(yJn,{...r,ref:e})})});Rdt.displayName=K8;var gJn=Y.forwardRef((t,e)=>{const n=F4(K8,t.__scopeDialog),o=Y.useRef(null),r=tu(e,n.contentRef,o);return Y.useEffect(()=>{const i=o.current;if(i)return j2e(i)},[]),j.jsx(kdt,{...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())})}),yJn=Y.forwardRef((t,e)=>{const n=F4(K8,t.__scopeDialog),o=Y.useRef(!1),r=Y.useRef(!1);return j.jsx(kdt,{...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()}})}),kdt=Y.forwardRef((t,e)=>{const{__scopeDialog:n,trapFocus:o,onOpenAutoFocus:r,onCloseAutoFocus:i,...s}=t,a=F4(K8,n),c=Y.useRef(null),l=tu(e,c);return w2e(),j.jsxs(j.Fragment,{children:[j.jsx(bj,{asChild:!0,loop:!0,trapped:o,onMountAutoFocus:r,onUnmountAutoFocus:i,children:j.jsx(JN,{role:"dialog",id:a.contentId,"aria-describedby":a.descriptionId,"aria-labelledby":a.titleId,"data-state":Aye(a.open),...s,ref:l,onDismiss:()=>a.onOpenChange(!1)})}),j.jsxs(j.Fragment,{children:[j.jsx(PJn,{titleId:a.titleId}),j.jsx(SJn,{contentRef:c,descriptionId:a.descriptionId})]})]})}),Dye="DialogTitle",Ndt=Y.forwardRef((t,e)=>{const{__scopeDialog:n,...o}=t,r=F4(Dye,n);return j.jsx(Cc.h2,{id:r.titleId,...o,ref:e})});Ndt.displayName=Dye;var Hdt="DialogDescription",Idt=Y.forwardRef((t,e)=>{const{__scopeDialog:n,...o}=t,r=F4(Hdt,n);return j.jsx(Cc.p,{id:r.descriptionId,...o,ref:e})});Idt.displayName=Hdt;var Ldt="DialogClose",Odt=Y.forwardRef((t,e)=>{const{__scopeDialog:n,...o}=t,r=F4(Ldt,n);return j.jsx(Cc.button,{type:"button",...o,ref:e,onClick:Vr(t.onClick,()=>r.onOpenChange(!1))})});Odt.displayName=Ldt;function Aye(t){return t?"open":"closed"}var Fdt="DialogTitleWarning",[bJn,Bdt]=yZt(Fdt,{contentName:K8,titleName:Dye,docsSlug:"dialog"}),PJn=({titleId:t})=>{const e=Bdt(Fdt),n=`\`${e.contentName}\` requires a \`${e.titleName}\` for the component to be accessible for screen reader users.
|
|
5689
|
+
`,_=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 j.jsxs("div",{className:`relative ${e}`,ref:r,children:[j.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&&j.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:[j.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:i,children:"Download JSON"}),j.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:s,children:"Download page.tsx"}),j.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:a,children:"Download test.ts"})]})]})},bdt=t=>t.activeSubSolver?[t,...bdt(t.activeSubSolver)]:[t],$qn=({solver:t})=>{const e=bdt(t);return j.jsx("div",{className:"flex gap-1 items-center text-sm pt-1",children:e.map((n,o)=>j.jsxs("div",{className:"flex items-center",children:[o>0&&j.jsx("span",{className:"text-gray-400 mx-1",children:"→"}),j.jsx(Vqn,{solver:n})]},n.constructor.name))})},Wqn=({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 j.jsxs("div",{className:"space-y-2 p-2 border-b",children:[j.jsx("div",{className:"flex items-center",children:j.jsx($qn,{solver:t})}),j.jsxs("div",{className:"flex gap-2 items-center flex-wrap",children:[j.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"}),j.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"}),j.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"}),j.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&&j.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"}),j.jsxs("div",{className:"text-sm text-gray-600",children:["Iterations: ",t.iterations]}),t.timeToSolve!==void 0&&j.jsxs("div",{className:"text-sm text-gray-600",children:["Time: ",(t.timeToSolve/1e3).toFixed(3),"s"]}),h&&j.jsxs("div",{className:"text-sm text-gray-600",children:["Phase: ",j.jsx("span",{className:"font-medium",children:h})]}),t.solved&&j.jsx("div",{className:"px-2 py-1 bg-green-100 text-green-800 rounded text-sm",children:"Solved"}),t.failed&&j.jsx("div",{className:"px-2 py-1 bg-red-100 text-red-800 rounded text-sm",children:"Failed"})]}),t.error&&j.jsxs("div",{className:"text-red-600 text-sm",children:["Error: ",t.error]})]})},Uqn=(t,e,n)=>{const o=t.currentPipelineStepIndex;return e<o?"Completed":e===o&&t.activeSubSolver?t.activeSubSolver.failed?"Failed":"In Progress":"Not Started"},Xqn=(t,e)=>{const o=t.pipelineDef[e].solverName,r=Uqn(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}},jqn=({status:t})=>{const e={"Not Started":"text-blue-600","In Progress":"text-yellow-600",Completed:"text-green-600",Failed:"text-red-600"};return j.jsx("span",{className:`font-medium ${e[t]}`,children:t})},Gqn=({progress:t})=>{if(t===0)return null;const e=Math.round(t*100);return j.jsxs("div",{className:"flex items-center gap-2",children:[j.jsx("div",{className:"w-20 h-2 bg-gray-200 rounded overflow-hidden",children:j.jsx("div",{className:"h-full bg-blue-500 transition-all duration-200",style:{width:`${e}%`}})}),j.jsxs("span",{className:"text-xs text-gray-500",children:[e,"%"]})]})},Yqn=t=>Object.entries(t).map(([e,n])=>`${e}: ${n}`).join(", "),qqn=({stats:t})=>{if(!t||Object.keys(t).length===0)return j.jsx("span",{children:"-"});const e=Object.entries(t),n=Yqn(t);return j.jsxs("details",{className:"cursor-pointer",children:[j.jsx("summary",{className:"whitespace-nowrap overflow-hidden text-ellipsis max-w-[200px]",children:n}),j.jsx("div",{className:"mt-1 text-xs",children:e.map(([o,r])=>j.jsxs("div",{children:[o,": ",String(r)]},o))})]})},wye=t=>{if(t===null||typeof t!="object")return t;if(Array.isArray(t))return t.map(wye);const e={};for(const[n,o]of Object.entries(t))n.startsWith("_")||(e[n]=wye(o));return e},Jqn=(t,e)=>{try{if(typeof t.getConstructorParams!="function"){alert(`getConstructorParams() is not implemented for ${e}`);return}const n=wye(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)}`)}},Kqn=({solver:t,onStepUntilPhase:e,onDownloadInput:n})=>{const o=t.pipelineDef.map((a,c)=>Xqn(t,c)),r=a=>{e?.(a)},i=a=>{a.solverInstance&&(n?n(a.solverInstance,a.name):Jqn(a.solverInstance,a.name))},s=a=>`${(a/1e3).toFixed(2)}s`;return j.jsxs("div",{className:"border-t border-gray-200",children:[j.jsx("div",{className:"px-4 py-2 bg-gray-50 border-b border-gray-200",children:j.jsx("h3",{className:"text-sm font-semibold text-gray-700",children:"Pipeline Steps"})}),j.jsx("div",{className:"overflow-x-auto",children:j.jsxs("table",{className:"w-full text-sm",children:[j.jsx("thead",{children:j.jsxs("tr",{className:"bg-gray-50 border-b border-gray-200",children:[j.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Step"}),j.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Status"}),j.jsxs("th",{className:"px-4 py-2 text-center font-semibold text-gray-700",children:["i",j.jsx("sub",{children:"0"})]}),j.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Iterations"}),j.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Progress"}),j.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Time"}),j.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Stats"}),j.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Input"})]})}),j.jsx("tbody",{children:o.map(a=>j.jsxs("tr",{className:`border-b border-gray-100 ${a.status==="In Progress"?"bg-yellow-50":""}`,children:[j.jsx("td",{className:"px-4 py-2",children:j.jsxs("div",{className:"flex items-center gap-2",children:[j.jsx("span",{className:"text-gray-400 w-6",children:String(a.index+1).padStart(2,"0")}),j.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:j.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:j.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"})})}),j.jsx("span",{className:"font-medium text-gray-900",children:a.name})]})}),j.jsx("td",{className:"px-4 py-2",children:j.jsx(jqn,{status:a.status})}),j.jsx("td",{className:"px-4 py-2 text-center text-gray-600",children:a.firstIteration!==null?a.firstIteration:""}),j.jsx("td",{className:"px-4 py-2 text-gray-600",children:a.iterations}),j.jsx("td",{className:"px-4 py-2",children:j.jsx(Gqn,{progress:a.progress})}),j.jsx("td",{className:"px-4 py-2 text-gray-600",children:s(a.timeSpent)}),j.jsx("td",{className:"px-4 py-2 text-gray-500",children:j.jsx(qqn,{stats:a.stats})}),j.jsx("td",{className:"px-4 py-2",children:a.solverInstance?j.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:[j.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:j.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"})}),j.jsx("span",{children:"Input"})]}):null})]},a.name))})]})})]})},Qqn=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 Zqn({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 j.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)=>j.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)=>j.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)=>j.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)=>j.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)=>j.jsx("text",{x:x.x??0,y:x.y??0,fontSize:x.fontSize??10,fill:x.color??"black",children:x.text??""},`text-${f}`))]})}var eJn=({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 j.jsxs("div",{children:[j.jsx(Wqn,{solver:t,triggerRender:i,animationSpeed:e,onSolverStarted:n,onSolverCompleted:o}),a?j.jsx("div",{className:"p-4 text-gray-500",children:"No Graphics Yet"}):j.jsx(Qqn,{fallback:j.jsx(Zqn,{graphics:s}),children:j.jsx(zqn,{graphics:s})}),c&&j.jsx(Kqn,{solver:t,onStepUntilPhase:l})]})};const tJn=()=>{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)},[])},nJn=t=>t.toLowerCase().includes("pack")?RDn:t.toLowerCase().includes("rout")?LDn:fDn,oJn=({solverEvents:t=[]})=>{const[e,n]=Y.useState(null);tJn();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=Fie[i.solverName];if(!a)return{instance:null,error:`Solver class "${i.solverName}" not found in SOLVERS registry. Available: ${Object.keys(Fie).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?j.jsx("div",{className:"rf-p-4",children:j.jsx("div",{className:"rf-bg-gray-50 rf-rounded-md rf-border rf-border-gray-200",children:j.jsxs("div",{className:"rf-p-4",children:[j.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800 rf-mb-3",children:"No Solvers Detected"}),j.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."})]})})}):j.jsxs("div",{className:"rf-flex rf-h-full rf-overflow-hidden",children:[j.jsxs("div",{className:"rf-w-64 rf-border-r rf-border-gray-200 rf-overflow-y-auto rf-flex-shrink-0",children:[j.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 j.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=nJn(c.solverName);return j.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2",children:[j.jsx(u,{className:"rf-w-4 rf-h-4 rf-text-blue-500 rf-flex-shrink-0"}),j.jsxs("div",{className:"rf-flex-1 rf-min-w-0",children:[j.jsx("div",{className:"rf-text-sm rf-font-medium rf-text-gray-800 rf-truncate",children:c.componentName}),j.jsx("div",{className:"rf-text-xs rf-text-gray-500 rf-truncate",children:c.solverName})]})]})})()},a)})]}),j.jsx("div",{className:"rf-flex-1 rf-overflow-hidden",children:i?s.instance?j.jsx(M5,{fallback:j.jsx("div",{className:"rf-p-4",children:j.jsxs("div",{className:"rf-bg-red-50 rf-rounded-md rf-border rf-border-red-200 rf-p-4",children:[j.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-red-800 rf-mb-2",children:"Error Loading Solver Debugger"}),j.jsxs("p",{className:"rf-text-sm rf-text-red-600",children:["Failed to render the solver debugger for"," ",i.solverName]})]})}),children:j.jsx(eJn,{solver:s.instance})}):j.jsxs("div",{className:"rf-p-4",children:[j.jsxs("div",{className:"rf-mb-4",children:[j.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800",children:i.solverName}),j.jsxs("p",{className:"rf-text-sm rf-text-gray-500",children:["Component: ",i.componentName]})]}),s.error&&j.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:j.jsx("p",{className:`rf-text-sm ${s.classFound?"rf-text-red-700":"rf-text-yellow-700"}`,children:s.error})}),j.jsxs("div",{className:"rf-border rf-border-gray-200 rf-rounded-md rf-overflow-hidden",children:[j.jsx("div",{className:"rf-px-3 rf-py-2 rf-bg-gray-50",children:j.jsx("span",{className:"rf-text-sm rf-font-medium rf-text-gray-700",children:"Solver Parameters"})}),j.jsx("div",{className:"rf-p-3 rf-bg-white rf-border-t rf-border-gray-200",children:j.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)})})]})]}):j.jsx("div",{className:"rf-flex rf-items-center rf-justify-center rf-h-full",children:j.jsx("p",{className:"rf-text-sm rf-text-gray-500",children:"Select a solver from the list to view details"})})})]})},Pdt=({errorMessage:t,errorStack:e,circuitJsonErrors:n})=>{Y.useEffect(()=>{if(t){const o=new Error(t);e&&(o.stack=e);try{MW.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{MW.captureException(r,{error_type:o.type})}catch{}}},[n])},vdt="0.0.1813",rJn={version:vdt},xY=IIe()(LIe(t=>({lastRunEvalVersion:void 0,setLastRunEvalVersion:e=>{t({lastRunEvalVersion:e})}}),{name:"runframe-runner-store"})),iJn=t=>{const[e,n]=Y.useState([]),[o,r]=Y.useState(null),[i,s]=Y.useState(""),[a,c]=DT("eval-version-selection",null),l=xY(m=>m.setLastRunEvalVersion),u=xY(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("")}}},sJn=({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 j.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:j.jsxs("div",{className:"rf-bg-white rf-rounded-lg rf-p-6 rf-w-96",children:[j.jsx("h2",{className:"rf-text-lg rf-font-semibold rf-mb-4",children:"Select Snippet"}),j.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}),j.jsxs("div",{className:"rf-h-60 rf-overflow-y-auto",children:[c.map(_=>j.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&&j.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,'"']})]}),j.jsxs("div",{className:"rf-mt-4 rf-flex rf-justify-end rf-gap-2",children:[j.jsx("button",{type:"button",className:"rf-px-4 rf-py-2 rf-text-gray-600 rf-hover:text-gray-800",onClick:n,children:"Cancel"}),j.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}`})]})]})})},aJn=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 cJn(t){const e=lJn(t),n=Y.forwardRef((o,r)=>{const{children:i,...s}=o,a=Y.Children.toArray(i),c=a.find(_Jn);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 j.jsx(e,{...s,ref:r,children:Y.isValidElement(l)?Y.cloneElement(l,void 0,u):null})}return j.jsx(e,{...s,ref:r,children:i})});return n.displayName=`${t}.Slot`,n}function lJn(t){const e=Y.forwardRef((n,o)=>{const{children:r,...i}=n;if(Y.isValidElement(r)){const s=hJn(r),a=dJn(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 uJn=Symbol("radix.slottable");function _Jn(t){return Y.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===uJn}function dJn(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 hJn(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 gY="Dialog",[Sdt,Cdt]=_4(gY),[mJn,F4]=Sdt(gY),Mdt=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:gY});return j.jsx(mJn,{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})};Mdt.displayName=gY;var Tdt="DialogTrigger",wdt=Y.forwardRef((t,e)=>{const{__scopeDialog:n,...o}=t,r=F4(Tdt,n),i=tu(e,r.triggerRef);return j.jsx(Cc.button,{type:"button","aria-haspopup":"dialog","aria-expanded":r.open,"aria-controls":r.contentId,"data-state":Aye(r.open),...o,ref:i,onClick:Vr(t.onClick,r.onOpenToggle)})});wdt.displayName=Tdt;var Eye="DialogPortal",[pJn,Edt]=Sdt(Eye,{forceMount:void 0}),Ddt=t=>{const{__scopeDialog:e,forceMount:n,children:o,container:r}=t,i=F4(Eye,e);return j.jsx(pJn,{scope:e,forceMount:n,children:Y.Children.map(o,s=>j.jsx(Fg,{present:n||i.open,children:j.jsx(Nj,{asChild:!0,container:r,children:s})}))})};Ddt.displayName=Eye;var yY="DialogOverlay",Adt=Y.forwardRef((t,e)=>{const n=Edt(yY,t.__scopeDialog),{forceMount:o=n.forceMount,...r}=t,i=F4(yY,t.__scopeDialog);return i.modal?j.jsx(Fg,{present:o||i.open,children:j.jsx(xJn,{...r,ref:e})}):null});Adt.displayName=yY;var fJn=cJn("DialogOverlay.RemoveScroll"),xJn=Y.forwardRef((t,e)=>{const{__scopeDialog:n,...o}=t,r=F4(yY,n);return j.jsx(Vj,{as:fJn,allowPinchZoom:!0,shards:[r.contentRef],children:j.jsx(Cc.div,{"data-state":Aye(r.open),...o,ref:e,style:{pointerEvents:"auto",...o.style}})})}),K8="DialogContent",Rdt=Y.forwardRef((t,e)=>{const n=Edt(K8,t.__scopeDialog),{forceMount:o=n.forceMount,...r}=t,i=F4(K8,t.__scopeDialog);return j.jsx(Fg,{present:o||i.open,children:i.modal?j.jsx(gJn,{...r,ref:e}):j.jsx(yJn,{...r,ref:e})})});Rdt.displayName=K8;var gJn=Y.forwardRef((t,e)=>{const n=F4(K8,t.__scopeDialog),o=Y.useRef(null),r=tu(e,n.contentRef,o);return Y.useEffect(()=>{const i=o.current;if(i)return j2e(i)},[]),j.jsx(kdt,{...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())})}),yJn=Y.forwardRef((t,e)=>{const n=F4(K8,t.__scopeDialog),o=Y.useRef(!1),r=Y.useRef(!1);return j.jsx(kdt,{...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()}})}),kdt=Y.forwardRef((t,e)=>{const{__scopeDialog:n,trapFocus:o,onOpenAutoFocus:r,onCloseAutoFocus:i,...s}=t,a=F4(K8,n),c=Y.useRef(null),l=tu(e,c);return w2e(),j.jsxs(j.Fragment,{children:[j.jsx(bj,{asChild:!0,loop:!0,trapped:o,onMountAutoFocus:r,onUnmountAutoFocus:i,children:j.jsx(JN,{role:"dialog",id:a.contentId,"aria-describedby":a.descriptionId,"aria-labelledby":a.titleId,"data-state":Aye(a.open),...s,ref:l,onDismiss:()=>a.onOpenChange(!1)})}),j.jsxs(j.Fragment,{children:[j.jsx(PJn,{titleId:a.titleId}),j.jsx(SJn,{contentRef:c,descriptionId:a.descriptionId})]})]})}),Dye="DialogTitle",Ndt=Y.forwardRef((t,e)=>{const{__scopeDialog:n,...o}=t,r=F4(Dye,n);return j.jsx(Cc.h2,{id:r.titleId,...o,ref:e})});Ndt.displayName=Dye;var Hdt="DialogDescription",Idt=Y.forwardRef((t,e)=>{const{__scopeDialog:n,...o}=t,r=F4(Hdt,n);return j.jsx(Cc.p,{id:r.descriptionId,...o,ref:e})});Idt.displayName=Hdt;var Ldt="DialogClose",Odt=Y.forwardRef((t,e)=>{const{__scopeDialog:n,...o}=t,r=F4(Ldt,n);return j.jsx(Cc.button,{type:"button",...o,ref:e,onClick:Vr(t.onClick,()=>r.onOpenChange(!1))})});Odt.displayName=Ldt;function Aye(t){return t?"open":"closed"}var Fdt="DialogTitleWarning",[bJn,Bdt]=yZt(Fdt,{contentName:K8,titleName:Dye,docsSlug:"dialog"}),PJn=({titleId:t})=>{const e=Bdt(Fdt),n=`\`${e.contentName}\` requires a \`${e.titleName}\` for the component to be accessible for screen reader users.
|
|
5690
5690
|
|
|
5691
5691
|
If you want to hide the \`${e.titleName}\`, you can wrap it with our VisuallyHidden component.
|
|
5692
5692
|
|
|
@@ -5706,7 +5706,7 @@ For more information, see https://radix-ui.com/primitives/docs/components/alert-
|
|
|
5706
5706
|
`&&(A=`
|
|
5707
5707
|
`);var ne=0,ce=!1;this.parse=function(ee,oe,ie){if(typeof ee!="string")throw new Error("Input must be a string");var ae=ee.length,de=D.length,be=A.length,Ce=I.length,De=M(H),pe=[],Me=[],fe=[],We=ne=0;if(!ee)return ze();if(z||z!==!1&&ee.indexOf(q)===-1){for(var Ue=ee.split(A),qe=0;qe<Ue.length;qe++){if(fe=Ue[qe],ne+=fe.length,qe!==Ue.length-1)ne+=A.length;else if(ie)return ze();if(!I||fe.substring(0,Ce)!==I){if(De){if(pe=[],Re(fe.split(D)),Xe(),ce)return ze()}else Re(fe.split(D));if(O&&O<=qe)return pe=pe.slice(0,O),ze(!0)}}return ze()}for(var xe=ee.indexOf(D,ne),Je=ee.indexOf(A,ne),Fe=new RegExp(x(K)+x(q),"g"),Ne=ee.indexOf(q,ne);;)if(ee[ne]===q)for(Ne=ne,ne++;;){if((Ne=ee.indexOf(q,Ne+1))===-1)return ie||Me.push({type:"Quotes",code:"MissingQuotes",message:"Quoted field unterminated",row:pe.length,index:ne}),Ee();if(Ne===ae-1)return Ee(ee.substring(ne,Ne).replace(Fe,q));if(q===K&&ee[Ne+1]===K)Ne++;else if(q===K||Ne===0||ee[Ne-1]!==K){xe!==-1&&xe<Ne+1&&(xe=ee.indexOf(D,Ne+1));var Ve=Pe((Je=Je!==-1&&Je<Ne+1?ee.indexOf(A,Ne+1):Je)===-1?xe:Math.min(xe,Je));if(ee.substr(Ne+1+Ve,de)===D){fe.push(ee.substring(ne,Ne).replace(Fe,q)),ee[ne=Ne+1+Ve+de]!==q&&(Ne=ee.indexOf(q,ne)),xe=ee.indexOf(D,ne),Je=ee.indexOf(A,ne);break}if(Ve=Pe(Je),ee.substring(Ne+1+Ve,Ne+1+Ve+be)===A){if(fe.push(ee.substring(ne,Ne).replace(Fe,q)),we(Ne+1+Ve+be),xe=ee.indexOf(D,ne),Ne=ee.indexOf(q,ne),De&&(Xe(),ce))return ze();if(O&&pe.length>=O)return ze(!0);break}Me.push({type:"Quotes",code:"InvalidQuotes",message:"Trailing quote on quoted field is malformed",row:pe.length,index:ne}),Ne++}}else if(I&&fe.length===0&&ee.substring(ne,ne+Ce)===I){if(Je===-1)return ze();ne=Je+be,Je=ee.indexOf(A,ne),xe=ee.indexOf(D,ne)}else if(xe!==-1&&(xe<Je||Je===-1))fe.push(ee.substring(ne,xe)),ne=xe+de,xe=ee.indexOf(D,ne);else{if(Je===-1)break;if(fe.push(ee.substring(ne,Je)),we(Je+be),De&&(Xe(),ce))return ze();if(O&&pe.length>=O)return ze(!0)}return Ee();function Re(et){pe.push(et),We=ne}function Pe(et){var ot=0;return ot=et!==-1&&(et=ee.substring(Ne+1,et))&&et.trim()===""?et.length:ot}function Ee(et){return ie||(et===void 0&&(et=ee.substring(ne)),fe.push(et),ne=ae,Re(fe),De&&Xe()),ze()}function we(et){ne=et,Re(fe),fe=[],Je=ee.indexOf(A,ne)}function ze(et){if(w.header&&!oe&&pe.length&&!G){var ot=pe[0],at=Object.create(null),lt=new Set(ot);let xt=!1;for(let Ct=0;Ct<ot.length;Ct++){let Lt=ot[Ct];if(at[Lt=M(w.transformHeader)?w.transformHeader(Lt,Ct):Lt]){let $t,Ot=at[Lt];for(;$t=Lt+"_"+Ot,Ot++,lt.has($t););lt.add($t),ot[Ct]=$t,at[Lt]++,xt=!0,(V=V===null?{}:V)[$t]=Lt}else at[Lt]=1,ot[Ct]=Lt;lt.add(Lt)}xt&&console.warn("Duplicate headers found and renamed."),G=!0}return{data:pe,errors:Me,meta:{delimiter:D,linebreak:A,aborted:ce,truncated:!!et,cursor:We+(oe||0),renamedHeaders:V}}}function Xe(){H(ze()),pe=[],Me=[]}},this.abort=function(){ce=!0},this.getCharIndex=function(){return ne}}function g(w){var D=w.data,A=a[D.workerId],I=!1;if(D.error)A.userError(D.error,D.file);else if(D.results&&D.results.data){var H={abort:function(){I=!0,y(D.workerId,{data:[],errors:[],meta:{aborted:!0}})},pause:b,resume:b};if(M(A.userStep)){for(var O=0;O<D.results.data.length&&(A.userStep({data:D.results.data[O],errors:D.results.errors,meta:D.results.meta},H),!I);O++);delete D.results}else M(A.userChunk)&&(A.userChunk(D.results,H,D.file),delete D.results)}D.finished&&!I&&y(D.workerId,D.results)}function y(w,D){var A=a[w];M(A.userComplete)&&A.userComplete(D),A.terminate(),delete a[w]}function b(){throw new Error("Not implemented.")}function v(w){if(typeof w!="object"||w===null)return w;var D,A=Array.isArray(w)?[]:{};for(D in w)A[D]=v(w[D]);return A}function S(w,D){return function(){w.apply(D,arguments)}}function M(w){return typeof w=="function"}return l.parse=function(w,D){var A=(D=D||{}).dynamicTyping||!1;if(M(A)&&(D.dynamicTypingFunction=A,A={}),D.dynamicTyping=A,D.transform=!!M(D.transform)&&D.transform,!D.worker||!l.WORKERS_SUPPORTED)return A=null,l.NODE_STREAM_INPUT,typeof w=="string"?(w=(I=>I.charCodeAt(0)!==65279?I:I.slice(1))(w),A=new(D.download?_:m)(D)):w.readable===!0&&M(w.read)&&M(w.on)?A=new h(D):(o.File&&w instanceof File||w instanceof Object)&&(A=new d(D)),A.stream(w);(A=(()=>{var I;return!!l.WORKERS_SUPPORTED&&(I=(()=>{var H=o.URL||o.webkitURL||null,O=n.toString();return l.BLOB_URL||(l.BLOB_URL=H.createObjectURL(new Blob(["var global = (function() { if (typeof self !== 'undefined') { return self; } if (typeof window !== 'undefined') { return window; } if (typeof global !== 'undefined') { return global; } return {}; })(); global.IS_PAPA_WORKER=true; ","(",O,")();"],{type:"text/javascript"})))})(),(I=new o.Worker(I)).onmessage=g,I.id=c++,a[I.id]=I)})()).userStep=D.step,A.userChunk=D.chunk,A.userComplete=D.complete,A.userError=D.error,D.step=M(D.step),D.chunk=M(D.chunk),D.complete=M(D.complete),D.error=M(D.error),delete D.worker,A.postMessage({input:w,config:D,workerId:A.id})},l.unparse=function(w,D){var A=!1,I=!0,H=",",O=`\r
|
|
5708
5708
|
`,z='"',V=z+z,G=!1,q=null,K=!1,ne=((()=>{if(typeof D=="object"){if(typeof D.delimiter!="string"||l.BAD_DELIMITERS.filter(function(oe){return D.delimiter.indexOf(oe)!==-1}).length||(H=D.delimiter),typeof D.quotes!="boolean"&&typeof D.quotes!="function"&&!Array.isArray(D.quotes)||(A=D.quotes),typeof D.skipEmptyLines!="boolean"&&typeof D.skipEmptyLines!="string"||(G=D.skipEmptyLines),typeof D.newline=="string"&&(O=D.newline),typeof D.quoteChar=="string"&&(z=D.quoteChar),typeof D.header=="boolean"&&(I=D.header),Array.isArray(D.columns)){if(D.columns.length===0)throw new Error("Option columns is empty");q=D.columns}D.escapeChar!==void 0&&(V=D.escapeChar+z),D.escapeFormulae instanceof RegExp?K=D.escapeFormulae:typeof D.escapeFormulae=="boolean"&&D.escapeFormulae&&(K=/^[=+\-@\t\r].*$/)}})(),new RegExp(x(z),"g"));if(typeof w=="string"&&(w=JSON.parse(w)),Array.isArray(w)){if(!w.length||Array.isArray(w[0]))return ce(null,w,G);if(typeof w[0]=="object")return ce(q||Object.keys(w[0]),w,G)}else if(typeof w=="object")return typeof w.data=="string"&&(w.data=JSON.parse(w.data)),Array.isArray(w.data)&&(w.fields||(w.fields=w.meta&&w.meta.fields||q),w.fields||(w.fields=Array.isArray(w.data[0])?w.fields:typeof w.data[0]=="object"?Object.keys(w.data[0]):[]),Array.isArray(w.data[0])||typeof w.data[0]=="object"||(w.data=[w.data])),ce(w.fields||[],w.data||[],G);throw new Error("Unable to serialize unrecognized input");function ce(oe,ie,ae){var de="",be=(typeof oe=="string"&&(oe=JSON.parse(oe)),typeof ie=="string"&&(ie=JSON.parse(ie)),Array.isArray(oe)&&0<oe.length),Ce=!Array.isArray(ie[0]);if(be&&I){for(var De=0;De<oe.length;De++)0<De&&(de+=H),de+=ee(oe[De],De);0<ie.length&&(de+=O)}for(var pe=0;pe<ie.length;pe++){var Me=(be?oe:ie[pe]).length,fe=!1,We=be?Object.keys(ie[pe]).length===0:ie[pe].length===0;if(ae&&!be&&(fe=ae==="greedy"?ie[pe].join("").trim()==="":ie[pe].length===1&&ie[pe][0].length===0),ae==="greedy"&&be){for(var Ue=[],qe=0;qe<Me;qe++){var xe=Ce?oe[qe]:qe;Ue.push(ie[pe][xe])}fe=Ue.join("").trim()===""}if(!fe){for(var Je=0;Je<Me;Je++){0<Je&&!We&&(de+=H);var Fe=be&&Ce?oe[Je]:Je;de+=ee(ie[pe][Fe],Je)}pe<ie.length-1&&(!ae||0<Me&&!We)&&(de+=O)}}return de}function ee(oe,ie){var ae,de;return oe==null?"":oe.constructor===Date?JSON.stringify(oe).slice(1,25):(de=!1,K&&typeof oe=="string"&&K.test(oe)&&(oe="'"+oe,de=!0),ae=oe.toString().replace(ne,V),(de=de||A===!0||typeof A=="function"&&A(oe,ie)||Array.isArray(A)&&A[ie]||((be,Ce)=>{for(var De=0;De<Ce.length;De++)if(-1<be.indexOf(Ce[De]))return!0;return!1})(ae,l.BAD_DELIMITERS)||-1<ae.indexOf(H)||ae.charAt(0)===" "||ae.charAt(ae.length-1)===" ")?z+ae+z:ae)}},l.RECORD_SEP="",l.UNIT_SEP="",l.BYTE_ORDER_MARK="\uFEFF",l.BAD_DELIMITERS=["\r",`
|
|
5709
|
-
`,'"',l.BYTE_ORDER_MARK],l.WORKERS_SUPPORTED=!i&&!!o.Worker,l.NODE_STREAM_INPUT=1,l.LocalChunkSize=10485760,l.RemoteChunkSize=5242880,l.DefaultDelimiter=",",l.Parser=f,l.ParserHandle=p,l.NetworkStreamer=_,l.FileStreamer=d,l.StringStreamer=m,l.ReadableStreamStreamer=h,o.jQuery&&((r=o.jQuery).fn.parse=function(w){var D=w.config||{},A=[];return this.each(function(O){if(!(r(this).prop("tagName").toUpperCase()==="INPUT"&&r(this).attr("type").toLowerCase()==="file"&&o.FileReader)||!this.files||this.files.length===0)return!0;for(var z=0;z<this.files.length;z++)A.push({file:this.files[z],inputElem:this,instanceConfig:r.extend({},D)})}),I(),this;function I(){if(A.length===0)M(w.complete)&&w.complete();else{var O,z,V,G,q=A[0];if(M(w.before)){var K=w.before(q.file,q.inputElem);if(typeof K=="object"){if(K.action==="abort")return O="AbortError",z=q.file,V=q.inputElem,G=K.reason,void(M(w.error)&&w.error({name:O},z,V,G));if(K.action==="skip")return void H();typeof K.config=="object"&&(q.instanceConfig=r.extend(q.instanceConfig,K.config))}else if(K==="skip")return void H()}var ne=q.instanceConfig.complete;q.instanceConfig.complete=function(ce){M(ne)&&ne(ce,q.file,q.inputElem),H()},l.parse(q.file,q.instanceConfig)}}function H(){A.splice(0,1),I()}}),s&&(o.onmessage=function(w){w=w.data,l.WORKER_ID===void 0&&w&&(l.WORKER_ID=w.workerId),typeof w.input=="string"?o.postMessage({workerId:l.WORKER_ID,results:l.parse(w.input,w.config),finished:!0}):(o.File&&w.input instanceof File||w.input instanceof Object)&&(w=l.parse(w.input,w.config))&&o.postMessage({workerId:l.WORKER_ID,results:w,finished:!0})}),(_.prototype=Object.create(u.prototype)).constructor=_,(d.prototype=Object.create(u.prototype)).constructor=d,(m.prototype=Object.create(m.prototype)).constructor=m,(h.prototype=Object.create(u.prototype)).constructor=h,l})})(wY)),wY.exports}var dQn=_Qn();const Iht=jy(dQn);var hQn=async({circuitJson:t,resolvePart:e})=>{const n=[];for(const o of t){if(o.type!=="pcb_component")continue;const r=t.find(c=>c.type==="source_component"&&c.source_component_id===o.source_component_id);if(!r)continue;const i=await e?.({pcb_component:o,source_component:r})??{};let s="";r.ftype==="simple_resistor"&&(s=Lht(r.resistance)),r.ftype==="simple_capacitor"&&(s=Lht(r.capacitance));const a=!!o.do_not_place;n.push({designator:r.name??o.pcb_component_id,comment:a?"DNP":s,value:a?"DNP":s,footprint:i.footprint||"",supplier_part_number_columns:a?void 0:i.supplier_part_number_columns??(r.supplier_part_numbers?mQn(r.supplier_part_numbers):void 0)})}return n};function mQn(t){const e={};return t?.jlcpcb&&(e["JLCPCB Part #"]=t.jlcpcb[0]),t?.lcsc&&(e["JLCPCB Part #"]=t.lcsc[0]),e}function Lht(t){return t==null?"":typeof t=="string"?t:lQn.formatSI(t)}var pQn=t=>{const e=t.map(o=>{const r=o.supplier_part_number_columns;return Object.values(r||{}).join(", "),Object.entries(o.extra_columns||{}).map(([i,s])=>`${i}: ${s}`).join(", "),{Designator:o.designator,Comment:o.comment,Value:o.value,Footprint:o.footprint,...r}}),n=["Designator","Comment","Value","Footprint"];for(const o of e)for(const r in o)n.includes(r)||n.push(r);return Iht.unparse(e,{columns:n})},Oht=3,fQn=(t,e={})=>{e.flip_y_axis??=!1;const n=[];for(const o of t)if(o.type==="pcb_component"){const r=Gp(t).source_component.get(o.source_component_id);n.push({designator:r?.name??o.pcb_component_id,mid_x:o.center.x,mid_y:o.center.y*(e.flip_y_axis?-1:1),layer:o.layer,rotation:o.rotation})}return n},xQn=t=>Iht.unparse(fQn(t).map(e=>({Designator:e.designator,"Mid X":e.mid_x.toFixed(Oht),"Mid Y":e.mid_y.toFixed(Oht),Layer:e.layer,Rotation:e.rotation})));const $v=(t,e)=>{const{fileName:n,mimeType:o="text/plain"}=e,r=t instanceof Blob?t:new Blob([t],{type:o}),i=URL.createObjectURL(r),s=document.createElement("a");s.href=i,s.download=n,document.body.appendChild(s),s.click(),setTimeout(()=>{document.body.removeChild(s),URL.revokeObjectURL(i)},0)},gQn=async({circuitJson:t,projectName:e})=>{const n=new t5e,{stringifyGerberCommandLayers:o,convertSoupToGerberCommands:r,convertSoupToExcellonDrillCommands:i,stringifyExcellonDrill:s}=await nC("circuit-json-to-gerber"),a=t.filter(x=>!("error_type"in x)&&!("warning_type"in x)),c=r(a,{flip_y_axis:!1}),l=o(c);for(const[x,f]of Object.entries(l))n.file(`gerber/${x}.gbr`,f);const u=i({circuitJson:a,is_plated:!0,flip_y_axis:!1}),_=s(u);n.file("gerber/drill.drl",_);const d=await hQn({circuitJson:t}),m=await pQn(d);n.file("bom.csv",m);const h=await xQn(t);n.file("pick_and_place.csv",h);const p=await n.generateAsync({type:"blob"});$v(p,{fileName:`${e}_fabrication_files.zip`})},yQn=async({circuitJson:t,projectName:e})=>{let n;try{const{convertCircuitJsonToGltf:o}=await nC("circuit-json-to-gltf");console.log("convertCircuitJsonToGltf",o);const r=await o(t,{format:"glb",boardTextureResolution:
|
|
5709
|
+
`,'"',l.BYTE_ORDER_MARK],l.WORKERS_SUPPORTED=!i&&!!o.Worker,l.NODE_STREAM_INPUT=1,l.LocalChunkSize=10485760,l.RemoteChunkSize=5242880,l.DefaultDelimiter=",",l.Parser=f,l.ParserHandle=p,l.NetworkStreamer=_,l.FileStreamer=d,l.StringStreamer=m,l.ReadableStreamStreamer=h,o.jQuery&&((r=o.jQuery).fn.parse=function(w){var D=w.config||{},A=[];return this.each(function(O){if(!(r(this).prop("tagName").toUpperCase()==="INPUT"&&r(this).attr("type").toLowerCase()==="file"&&o.FileReader)||!this.files||this.files.length===0)return!0;for(var z=0;z<this.files.length;z++)A.push({file:this.files[z],inputElem:this,instanceConfig:r.extend({},D)})}),I(),this;function I(){if(A.length===0)M(w.complete)&&w.complete();else{var O,z,V,G,q=A[0];if(M(w.before)){var K=w.before(q.file,q.inputElem);if(typeof K=="object"){if(K.action==="abort")return O="AbortError",z=q.file,V=q.inputElem,G=K.reason,void(M(w.error)&&w.error({name:O},z,V,G));if(K.action==="skip")return void H();typeof K.config=="object"&&(q.instanceConfig=r.extend(q.instanceConfig,K.config))}else if(K==="skip")return void H()}var ne=q.instanceConfig.complete;q.instanceConfig.complete=function(ce){M(ne)&&ne(ce,q.file,q.inputElem),H()},l.parse(q.file,q.instanceConfig)}}function H(){A.splice(0,1),I()}}),s&&(o.onmessage=function(w){w=w.data,l.WORKER_ID===void 0&&w&&(l.WORKER_ID=w.workerId),typeof w.input=="string"?o.postMessage({workerId:l.WORKER_ID,results:l.parse(w.input,w.config),finished:!0}):(o.File&&w.input instanceof File||w.input instanceof Object)&&(w=l.parse(w.input,w.config))&&o.postMessage({workerId:l.WORKER_ID,results:w,finished:!0})}),(_.prototype=Object.create(u.prototype)).constructor=_,(d.prototype=Object.create(u.prototype)).constructor=d,(m.prototype=Object.create(m.prototype)).constructor=m,(h.prototype=Object.create(u.prototype)).constructor=h,l})})(wY)),wY.exports}var dQn=_Qn();const Iht=jy(dQn);var hQn=async({circuitJson:t,resolvePart:e})=>{const n=[];for(const o of t){if(o.type!=="pcb_component")continue;const r=t.find(c=>c.type==="source_component"&&c.source_component_id===o.source_component_id);if(!r)continue;const i=await e?.({pcb_component:o,source_component:r})??{};let s="";r.ftype==="simple_resistor"&&(s=Lht(r.resistance)),r.ftype==="simple_capacitor"&&(s=Lht(r.capacitance));const a=!!o.do_not_place;n.push({designator:r.name??o.pcb_component_id,comment:a?"DNP":s,value:a?"DNP":s,footprint:i.footprint||"",supplier_part_number_columns:a?void 0:i.supplier_part_number_columns??(r.supplier_part_numbers?mQn(r.supplier_part_numbers):void 0)})}return n};function mQn(t){const e={};return t?.jlcpcb&&(e["JLCPCB Part #"]=t.jlcpcb[0]),t?.lcsc&&(e["JLCPCB Part #"]=t.lcsc[0]),e}function Lht(t){return t==null?"":typeof t=="string"?t:lQn.formatSI(t)}var pQn=t=>{const e=t.map(o=>{const r=o.supplier_part_number_columns;return Object.values(r||{}).join(", "),Object.entries(o.extra_columns||{}).map(([i,s])=>`${i}: ${s}`).join(", "),{Designator:o.designator,Comment:o.comment,Value:o.value,Footprint:o.footprint,...r}}),n=["Designator","Comment","Value","Footprint"];for(const o of e)for(const r in o)n.includes(r)||n.push(r);return Iht.unparse(e,{columns:n})},Oht=3,fQn=(t,e={})=>{e.flip_y_axis??=!1;const n=[];for(const o of t)if(o.type==="pcb_component"){const r=Gp(t).source_component.get(o.source_component_id);n.push({designator:r?.name??o.pcb_component_id,mid_x:o.center.x,mid_y:o.center.y*(e.flip_y_axis?-1:1),layer:o.layer,rotation:o.rotation})}return n},xQn=t=>Iht.unparse(fQn(t).map(e=>({Designator:e.designator,"Mid X":e.mid_x.toFixed(Oht),"Mid Y":e.mid_y.toFixed(Oht),Layer:e.layer,Rotation:e.rotation})));const $v=(t,e)=>{const{fileName:n,mimeType:o="text/plain"}=e,r=t instanceof Blob?t:new Blob([t],{type:o}),i=URL.createObjectURL(r),s=document.createElement("a");s.href=i,s.download=n,document.body.appendChild(s),s.click(),setTimeout(()=>{document.body.removeChild(s),URL.revokeObjectURL(i)},0)},gQn=async({circuitJson:t,projectName:e})=>{const n=new t5e,{stringifyGerberCommandLayers:o,convertSoupToGerberCommands:r,convertSoupToExcellonDrillCommands:i,stringifyExcellonDrill:s}=await nC("circuit-json-to-gerber"),a=t.filter(x=>!("error_type"in x)&&!("warning_type"in x)),c=r(a,{flip_y_axis:!1}),l=o(c);for(const[x,f]of Object.entries(l))n.file(`gerber/${x}.gbr`,f);const u=i({circuitJson:a,is_plated:!0,flip_y_axis:!1}),_=s(u);n.file("gerber/drill.drl",_);const d=await hQn({circuitJson:t}),m=await pQn(d);n.file("bom.csv",m);const h=await xQn(t);n.file("pick_and_place.csv",h);const p=await n.generateAsync({type:"blob"});$v(p,{fileName:`${e}_fabrication_files.zip`})},yQn=async({circuitJson:t,projectName:e})=>{let n;try{const{convertCircuitJsonToGltf:o}=await nC("circuit-json-to-gltf");console.log("convertCircuitJsonToGltf",o);const r=await o(t,{format:"glb",boardTextureResolution:1024});if(!r||!(r instanceof ArrayBuffer))throw new Error("Invalid GLB data returned from converter");n=new Blob([r],{type:"model/gltf-binary"})}catch(o){console.error("GLB Export Error:",o);return}$v(n,{fileName:`${e}.glb`})},bQn=async({circuitJson:t,projectName:e})=>{const{convertCircuitJsonToPinoutSvg:n}=await nC("circuit-to-svg"),o=n(t);$v(o,{fileName:`${e}-pinout.svg`,mimeType:"image/svg+xml"})},PQn=async({circuitJson:t,projectName:e})=>{const{CircuitJsonToKicadPcbConverter:n,CircuitJsonToKicadSchConverter:o,CircuitJsonToKicadProConverter:r}=await nC("circuit-json-to-kicad"),i=new o(t);i.runUntilFinished();const s=i.getOutputString(),a=new n(t);a.runUntilFinished();const c=a.getOutputString(),l=new r(t,{projectName:e,schematicFilename:`${e}.kicad_sch`,pcbFilename:`${e}.kicad_pcb`});l.runUntilFinished();const u=l.getOutputString(),_=new t5e;return _.file(`${e}.kicad_sch`,s),_.file(`${e}.kicad_pcb`,c),_.file(`${e}.kicad_pro`,u),_},vQn=async({circuitJson:t,projectName:e})=>{const o=await(await PQn({circuitJson:t,projectName:e})).generateAsync({type:"blob"});$v(o,{fileName:`${e}_kicad_project.zip`})},SQn=async({circuitJson:t,libraryName:e})=>{const{CircuitJsonToKicadLibraryConverter:n}=await nC("circuit-json-to-kicad"),o=new n(t,{libraryName:e,footprintLibraryName:e});o.runUntilFinished();const r=o.getOutput(),i=new t5e;i.file(`${e}.kicad_sym`,r.kicadSymString);for(const s of r.footprints){const a=i.folder(`${e}.pretty`);a&&a.file(`${s.footprintName}.kicad_mod`,`${s.kicadModString}
|
|
5710
5710
|
`)}if(r.model3dSourcePaths.length>0){const s=i.folder(`${e}.3dshapes`);if(s)for(const a of r.model3dSourcePaths)try{const c=a.split("/").pop()||a,l=await fetch(a);if(l.ok){const u=await l.arrayBuffer();s.file(c,u)}}catch{}}return i.file("fp-lib-table",r.fpLibTableString),i.file("sym-lib-table",r.symLibTableString),i},CQn=async({circuitJson:t,projectName:e})=>{const o=await(await SQn({circuitJson:t,libraryName:e})).generateAsync({type:"blob"});$v(o,{fileName:`${e}_kicad_library.zip`})},MQn=async({circuitJson:t,projectName:e})=>{const{circuitJsonToStep:n}=await nC("circuit-json-to-step"),o=t.find(l=>l.type==="pcb_board"),r=o&&"width"in o?o.width:void 0,i=o&&"height"in o?o.height:void 0,s=o&&"thickness"in o?o.thickness:void 0;if(r===void 0||i===void 0||s===void 0){ds.error("Board dimensions not found. Please add a pcb_board with width, height, and thickness to your circuit.");return}let a;try{a=await n(t,{boardWidth:r,boardHeight:i,boardThickness:s,productName:e,includeComponents:!0,includeExternalMeshes:!0})}catch(l){const u=l instanceof Error?l.message:"Unknown error";ds.error(`Failed to convert circuit to STEP format: ${u}`);return}const c=new Blob([a],{type:"application/step"});try{$v(c,{fileName:`${e}.step`})}catch(l){const u=l instanceof Error?l.message:"Unknown error";ds.error(`Failed to download STEP file: ${u}`)}},Fht=async({circuitJson:t,projectName:e,options:n={}})=>{try{const{convertCircuitJsonToLbrn:o}=await nC("circuit-json-to-lbrn"),i=(await o(t,{includeSilkscreen:n.includeSilkscreen??!1})).toXml(),s=new Blob([i],{type:"application/lbrn"});$v(s,{fileName:`${e}.lbrn2`})}catch(o){const r=o instanceof Error?o.message:"Unknown error";ds.error(`Failed to export to LBRN format: ${r}`)}},TQn=t=>{let e=t.trim().replace(/[\\/:*?"<>|]/g,"_").replace(/[\x00-\x1f]/g,"").replace(/^\.+/,"").replace(/\.+$/,"").replace(/\s+/g," ").replace(/_+/g,"_");return/^(con|prn|aux|nul|com[0-9]|lpt[0-9])$/i.test(e)&&(e=`_${e}`),e=e.slice(0,200),e||"untitled"},wQn=[{extension:"json",name:"Circuit JSON"},{extension:"zip",name:"Fabrication Files"},{extension:"zip",name:"KiCad Project"},{extension:"zip",name:"KiCad Library"},{extension:"glb",name:"GLB (Binary GLTF)"},{extension:"svg",name:"Pinout SVG"},{extension:"step",name:"STEP"},{extension:"lbrn2",name:"LightBurn"}],EQn=async({exportName:t,circuitJson:e,projectName:n})=>{const o=TQn(n);if(t==="Fabrication Files"){gQn({circuitJson:e,projectName:o});return}if(t==="KiCad Project"){await vQn({circuitJson:e,projectName:o});return}if(t==="KiCad Library"){await CQn({circuitJson:e,projectName:o});return}if(t==="Circuit JSON"){$v(JSON.stringify(e,null,2),{fileName:`${o}.circuit.json`,mimeType:"application/json"});return}if(t==="GLB (Binary GLTF)"){await yQn({circuitJson:e,projectName:o});return}if(t==="Pinout SVG"){bQn({circuitJson:e,projectName:o});return}if(t==="STEP"){await MQn({circuitJson:e,projectName:o});return}if(t==="LightBurn"){await Fht({circuitJson:e,projectName:o});return}throw new Error(`Unsupported export type: "${t}"`)};class Wv extends Error{response;request;options;constructor(e,n,o){const r=e.status||e.status===0?e.status:"",i=e.statusText??"",s=`${r} ${i}`.trim(),a=s?`status code ${s}`:"an unknown error";super(`Request failed with ${a}: ${n.method} ${n.url}`),this.name="HTTPError",this.response=e,this.request=n,this.options=o}}class Bht extends Error{name="NonError";value;constructor(e){let n="Non-error value was thrown";try{typeof e=="string"?n=e:e&&typeof e=="object"&&"message"in e&&typeof e.message=="string"&&(n=e.message)}catch{}super(n),this.value=e}}class o5e extends Error{name="ForceRetryError";customDelay;code;customRequest;constructor(e){const n=e?.cause?e.cause instanceof Error?e.cause:new Bht(e.cause):void 0;super(e?.code?`Forced retry: ${e.code}`:"Forced retry",n?{cause:n}:void 0),this.customDelay=e?.delay,this.code=e?.code,this.customRequest=e?.request}}const zht=(()=>{let t=!1,e=!1;const n=typeof globalThis.ReadableStream=="function",o=typeof globalThis.Request=="function";if(n&&o)try{e=new globalThis.Request("https://empty.invalid",{body:new globalThis.ReadableStream,method:"POST",get duplex(){return t=!0,"half"}}).headers.has("Content-Type")}catch(r){if(r instanceof Error&&r.message==="unsupported BodyInit type")return!1;throw r}return t&&!e})(),DQn=typeof globalThis.AbortController=="function",Vht=typeof globalThis.AbortSignal=="function"&&typeof globalThis.AbortSignal.any=="function",AQn=typeof globalThis.ReadableStream=="function",RQn=typeof globalThis.FormData=="function",$ht=["get","post","put","patch","head","delete"],kQn={json:"application/json",text:"text/*",formData:"multipart/form-data",arrayBuffer:"*/*",blob:"*/*",bytes:"*/*"},r5e=2147483647,NQn=new TextEncoder().encode("------WebKitFormBoundaryaxpyiPgbbPti10Rw").length,Wht=Symbol("stop");class Uht{options;constructor(e){this.options=e}}const HQn=t=>new Uht(t),IQn={json:!0,parseJson:!0,stringifyJson:!0,searchParams:!0,prefixUrl:!0,retry:!0,timeout:!0,hooks:!0,throwHttpErrors:!0,onDownloadProgress:!0,onUploadProgress:!0,fetch:!0,context:!0},LQn={next:!0},OQn={method:!0,headers:!0,body:!0,mode:!0,credentials:!0,cache:!0,redirect:!0,referrer:!0,referrerPolicy:!0,integrity:!0,keepalive:!0,signal:!0,window:!0,duplex:!0},FQn=t=>{if(!t)return 0;if(t instanceof FormData){let e=0;for(const[n,o]of t)e+=NQn,e+=new TextEncoder().encode(`Content-Disposition: form-data; name="${n}"`).length,e+=typeof o=="string"?new TextEncoder().encode(o).length:o.size;return e}if(t instanceof Blob)return t.size;if(t instanceof ArrayBuffer)return t.byteLength;if(typeof t=="string")return new TextEncoder().encode(t).length;if(t instanceof URLSearchParams)return new TextEncoder().encode(t.toString()).length;if("byteLength"in t)return t.byteLength;if(typeof t=="object"&&t!==null)try{const e=JSON.stringify(t);return new TextEncoder().encode(e).length}catch{return 0}return 0},Xht=(t,e,n)=>{let o,r=0;return t.pipeThrough(new TransformStream({transform(i,s){if(s.enqueue(i),o){r+=o.byteLength;let a=e===0?0:r/e;a>=1&&(a=1-Number.EPSILON),n?.({percent:a,totalBytes:Math.max(e,r),transferredBytes:r},o)}o=i},flush(){o&&(r+=o.byteLength,n?.({percent:1,totalBytes:Math.max(e,r),transferredBytes:r},o))}}))},BQn=(t,e)=>{if(!t.body)return t;if(t.status===204)return new Response(null,{status:t.status,statusText:t.statusText,headers:t.headers});const n=Math.max(0,Number(t.headers.get("content-length"))||0);return new Response(Xht(t.body,n,e),{status:t.status,statusText:t.statusText,headers:t.headers})},zQn=(t,e,n)=>{if(!t.body)return t;const o=FQn(n??t.body);return new Request(t,{duplex:"half",body:Xht(t.body,o,e)})},oC=t=>t!==null&&typeof t=="object",EY=(...t)=>{for(const e of t)if((!oC(e)||Array.isArray(e))&&e!==void 0)throw new TypeError("The `options` argument must be an object");return i5e({},...t)},jht=(t={},e={})=>{const n=new globalThis.Headers(t),o=e instanceof globalThis.Headers,r=new globalThis.Headers(e);for(const[i,s]of r.entries())o&&s==="undefined"||s===void 0?n.delete(i):n.set(i,s);return n};function DY(t,e,n){return Object.hasOwn(e,n)&&e[n]===void 0?[]:i5e(t[n]??[],e[n]??[])}const Ght=(t={},e={})=>({beforeRequest:DY(t,e,"beforeRequest"),beforeRetry:DY(t,e,"beforeRetry"),afterResponse:DY(t,e,"afterResponse"),beforeError:DY(t,e,"beforeError")}),VQn=(t,e)=>{const n=new URLSearchParams;for(const o of[t,e])if(o!==void 0)if(o instanceof URLSearchParams)for(const[r,i]of o.entries())n.append(r,i);else if(Array.isArray(o))for(const r of o){if(!Array.isArray(r)||r.length!==2)throw new TypeError("Array search parameters must be provided in [[key, value], ...] format");n.append(String(r[0]),String(r[1]))}else if(oC(o))for(const[r,i]of Object.entries(o))i!==void 0&&n.append(r,String(i));else{const r=new URLSearchParams(o);for(const[i,s]of r.entries())n.append(i,s)}return n},i5e=(...t)=>{let e={},n={},o={},r;const i=[];for(const s of t)if(Array.isArray(s))Array.isArray(e)||(e=[]),e=[...e,...s];else if(oC(s)){for(let[a,c]of Object.entries(s)){if(a==="signal"&&c instanceof globalThis.AbortSignal){i.push(c);continue}if(a==="context"){if(c!=null&&(!oC(c)||Array.isArray(c)))throw new TypeError("The `context` option must be an object");e={...e,context:c==null?{}:{...e.context,...c}};continue}if(a==="searchParams"){c==null?r=void 0:r=r===void 0?c:VQn(r,c);continue}oC(c)&&a in e&&(c=i5e(e[a],c)),e={...e,[a]:c}}oC(s.hooks)&&(o=Ght(o,s.hooks),e.hooks=o),oC(s.headers)&&(n=jht(n,s.headers),e.headers=n)}return r!==void 0&&(e.searchParams=r),i.length>0&&(i.length===1?e.signal=i[0]:Vht?e.signal=AbortSignal.any(i):e.signal=i.at(-1)),e},$Qn=t=>$ht.includes(t)?t.toUpperCase():t,Yht={limit:2,methods:["get","put","head","delete","options","trace"],statusCodes:[408,413,429,500,502,503,504],afterStatusCodes:[413,429,503],maxRetryAfter:Number.POSITIVE_INFINITY,backoffLimit:Number.POSITIVE_INFINITY,delay:t=>.3*2**(t-1)*1e3,jitter:void 0,retryOnTimeout:!1},WQn=(t={})=>{if(typeof t=="number")return{...Yht,limit:t};if(t.methods&&!Array.isArray(t.methods))throw new Error("retry.methods must be an array");if(t.methods&&=t.methods.map(n=>n.toLowerCase()),t.statusCodes&&!Array.isArray(t.statusCodes))throw new Error("retry.statusCodes must be an array");const e=Object.fromEntries(Object.entries(t).filter(([,n])=>n!==void 0));return{...Yht,...e}};class s5e extends Error{request;constructor(e){super(`Request timed out: ${e.method} ${e.url}`),this.name="TimeoutError",this.request=e}}async function UQn(t,e,n,o){return new Promise((r,i)=>{const s=setTimeout(()=>{n&&n.abort(),i(new s5e(t))},o.timeout);o.fetch(t,e).then(r).catch(i).then(()=>{clearTimeout(s)})})}async function XQn(t,{signal:e}){return new Promise((n,o)=>{e&&(e.throwIfAborted(),e.addEventListener("abort",r,{once:!0}));function r(){clearTimeout(i),o(e.reason)}const i=setTimeout(()=>{e?.removeEventListener("abort",r),n()},t)})}const jQn=(t,e)=>{const n={};for(const o in e)Object.hasOwn(e,o)&&!(o in OQn)&&!(o in IQn)&&(!(o in t)||o in LQn)&&(n[o]=e[o]);return n},GQn=t=>t===void 0?!1:Array.isArray(t)?t.length>0:t instanceof URLSearchParams?t.size>0:typeof t=="object"?Object.keys(t).length>0:typeof t=="string"?t.trim().length>0:!!t;function YQn(t){return t instanceof Wv||t?.name===Wv.name}function qQn(t){return t instanceof s5e||t?.name===s5e.name}class lI{static create(e,n){const o=new lI(e,n),r=async()=>{if(typeof o.#e.timeout=="number"&&o.#e.timeout>r5e)throw new RangeError(`The \`timeout\` option cannot be greater than ${r5e}`);await Promise.resolve();let s=await o.#p();for(const a of o.#e.hooks.afterResponse){const c=o.#_(s.clone());let l;try{l=await a(o.request,o.#m(),c,{retryCount:o.#r})}catch(_){throw o.#c(c),o.#c(s),_}if(l instanceof Uht)throw o.#c(c),o.#c(s),new o5e(l.options);const u=l instanceof globalThis.Response?l:s;c!==u&&o.#c(c),s!==u&&o.#c(s),s=u}if(o.#_(s),!s.ok&&(typeof o.#e.throwHttpErrors=="function"?o.#e.throwHttpErrors(s.status):o.#e.throwHttpErrors)){let a=new Wv(s,o.request,o.#m());for(const c of o.#e.hooks.beforeError)a=await c(a,{retryCount:o.#r});throw a}if(o.#e.onDownloadProgress){if(typeof o.#e.onDownloadProgress!="function")throw new TypeError("The `onDownloadProgress` option must be a function");if(!AQn)throw new Error("Streams are not supported in your environment. `ReadableStream` is missing.");const a=s.clone();return o.#c(s),BQn(a,o.#e.onDownloadProgress)}return s},i=o.#h(r).finally(()=>{const s=o.#s;o.#d(s?.body??void 0),o.#d(o.request.body??void 0)});for(const[s,a]of Object.entries(kQn))s==="bytes"&&typeof globalThis.Response?.prototype?.bytes!="function"||(i[s]=async()=>{o.request.headers.set("accept",o.request.headers.get("accept")||a);const c=await i;if(s==="json"){if(c.status===204)return"";const l=await c.text();return l===""?"":n.parseJson?n.parseJson(l):JSON.parse(l)}return c[s]()});return i}static#o(e){return e&&typeof e=="object"&&!Array.isArray(e)&&!(e instanceof URLSearchParams)?Object.fromEntries(Object.entries(e).filter(([,n])=>n!==void 0)):e}request;#n;#r=0;#t;#e;#s;#i;#l;constructor(e,n={}){if(this.#t=e,this.#e={...n,headers:jht(this.#t.headers,n.headers),hooks:Ght({beforeRequest:[],beforeRetry:[],beforeError:[],afterResponse:[]},n.hooks),method:$Qn(n.method??this.#t.method??"GET"),prefixUrl:String(n.prefixUrl||""),retry:WQn(n.retry),throwHttpErrors:n.throwHttpErrors??!0,timeout:n.timeout??1e4,fetch:n.fetch??globalThis.fetch.bind(globalThis),context:n.context??{}},typeof this.#t!="string"&&!(this.#t instanceof URL||this.#t instanceof globalThis.Request))throw new TypeError("`input` must be a string, URL, or Request");if(this.#e.prefixUrl&&typeof this.#t=="string"){if(this.#t.startsWith("/"))throw new Error("`input` must not begin with a slash when using `prefixUrl`");this.#e.prefixUrl.endsWith("/")||(this.#e.prefixUrl+="/"),this.#t=this.#e.prefixUrl+this.#t}DQn&&Vht&&(this.#i=this.#e.signal??this.#t.signal,this.#n=new globalThis.AbortController,this.#e.signal=this.#i?AbortSignal.any([this.#i,this.#n.signal]):this.#n.signal),zht&&(this.#e.duplex="half"),this.#e.json!==void 0&&(this.#e.body=this.#e.stringifyJson?.(this.#e.json)??JSON.stringify(this.#e.json),this.#e.headers.set("content-type",this.#e.headers.get("content-type")??"application/json"));const o=n.headers&&new globalThis.Headers(n.headers).has("content-type");if(this.#t instanceof globalThis.Request&&(RQn&&this.#e.body instanceof globalThis.FormData||this.#e.body instanceof URLSearchParams)&&!o&&this.#e.headers.delete("content-type"),this.request=new globalThis.Request(this.#t,this.#e),GQn(this.#e.searchParams)){const i="?"+(typeof this.#e.searchParams=="string"?this.#e.searchParams.replace(/^\?/,""):new URLSearchParams(lI.#o(this.#e.searchParams)).toString()),s=this.request.url.replace(/(?:\?.*?)?(?=#|$)/,i);this.request=new globalThis.Request(s,this.#e)}if(this.#e.onUploadProgress){if(typeof this.#e.onUploadProgress!="function")throw new TypeError("The `onUploadProgress` option must be a function");if(!zht)throw new Error("Request streams are not supported in your environment. The `duplex` option for `Request` is not available.");this.request=this.#x(this.request,this.#e.body??void 0)}}#a(){const e=this.#e.retry.delay(this.#r);let n=e;this.#e.retry.jitter===!0?n=Math.random()*e:typeof this.#e.retry.jitter=="function"&&(n=this.#e.retry.jitter(e),(!Number.isFinite(n)||n<0)&&(n=e));const o=this.#e.retry.backoffLimit??Number.POSITIVE_INFINITY;return Math.min(o,n)}async#u(e){if(this.#r++,this.#r>this.#e.retry.limit)throw e;const n=e instanceof Error?e:new Bht(e);if(n instanceof o5e)return n.customDelay??this.#a();if(!this.#e.retry.methods.includes(this.request.method.toLowerCase()))throw e;if(this.#e.retry.shouldRetry!==void 0){const o=await this.#e.retry.shouldRetry({error:n,retryCount:this.#r});if(o===!1)throw e;if(o===!0)return this.#a()}if(qQn(e)&&!this.#e.retry.retryOnTimeout)throw e;if(YQn(e)){if(!this.#e.retry.statusCodes.includes(e.response.status))throw e;const o=e.response.headers.get("Retry-After")??e.response.headers.get("RateLimit-Reset")??e.response.headers.get("X-RateLimit-Retry-After")??e.response.headers.get("X-RateLimit-Reset")??e.response.headers.get("X-Rate-Limit-Reset");if(o&&this.#e.retry.afterStatusCodes.includes(e.response.status)){let r=Number(o)*1e3;Number.isNaN(r)?r=Date.parse(o)-Date.now():r>=Date.parse("2024-01-01")&&(r-=Date.now());const i=this.#e.retry.maxRetryAfter??r;return r<i?r:i}if(e.response.status===413)throw e}return this.#a()}#_(e){return this.#e.parseJson&&(e.json=async()=>this.#e.parseJson(await e.text())),e}#d(e){e&&e.cancel().catch(()=>{})}#c(e){this.#d(e.body??void 0)}async#h(e){try{return await e()}catch(n){const o=Math.min(await this.#u(n),r5e);if(this.#r<1)throw n;if(await XQn(o,this.#i?{signal:this.#i}:{}),n instanceof o5e&&n.customRequest){const r=this.#e.signal?new globalThis.Request(n.customRequest,{signal:this.#e.signal}):new globalThis.Request(n.customRequest);this.#f(r)}for(const r of this.#e.hooks.beforeRetry){const i=await r({request:this.request,options:this.#m(),error:n,retryCount:this.#r});if(i instanceof globalThis.Request){this.#f(i);break}if(i instanceof globalThis.Response)return i;if(i===Wht)return}return this.#h(e)}}async#p(){this.#n?.signal.aborted&&(this.#n=new globalThis.AbortController,this.#e.signal=this.#i?AbortSignal.any([this.#i,this.#n.signal]):this.#n.signal,this.request=new globalThis.Request(this.request,{signal:this.#e.signal}));for(const n of this.#e.hooks.beforeRequest){const o=await n(this.request,this.#m(),{retryCount:this.#r});if(o instanceof Response)return o;if(o instanceof globalThis.Request){this.#f(o);break}}const e=jQn(this.request,this.#e);return this.#s=this.request,this.request=this.#s.clone(),this.#e.timeout===!1?this.#e.fetch(this.#s,e):UQn(this.#s,e,this.#n,this.#e)}#m(){if(!this.#l){const{hooks:e,...n}=this.#e;this.#l=Object.freeze(n)}return this.#l}#f(e){this.#l=void 0,this.request=this.#x(e)}#x(e,n){return!this.#e.onUploadProgress||!e.body?e:zQn(e,this.#e.onUploadProgress,n??this.#e.body??void 0)}}const a5e=t=>{const e=(n,o)=>lI.create(n,EY(t,o));for(const n of $ht)e[n]=(o,r)=>lI.create(o,EY(t,r,{method:n}));return e.create=n=>a5e(EY(n)),e.extend=n=>(typeof n=="function"&&(n=n(t??{})),a5e(EY(t,n))),e.stop=Wht,e.retry=HQn,e},JQn=a5e();class KQn extends Wv{constructor(e,n,o,r){super(e,n,o),this.name="RegistryHTTPError",this.message=r}}function AY(t){return typeof window<"u"?window[t]:null}function Uv(){const t=AY("TSCIRCUIT_REGISTRY_API_BASE_URL")||void 0||"https://registry-api.tscircuit.com",e=AY("TSCIRCUIT_REGISTRY_TOKEN");return JQn.create({prefixUrl:t,headers:{Authorization:`Bearer ${e}`},timeout:3e4,hooks:{afterResponse:[async(n,o,r)=>{if(r.ok)return r;let i=null;try{i=await r.clone().json()}catch(_){console.error("Failed to parse registry error response",_)}const s=i?.error?.message??i?.error?.error_message??i?.message,a=i?.error?.error_code??i?.error_code,c=new URL(r.url),u=[`Registry request failed for ${`${c.pathname}${c.search}`} (${r.status})`];throw s&&u.push(`Server message: ${s}`),a&&u.push(`Error code: ${a}`),new KQn(r,n,o,u.join(" | "))}]}})}function RY(){return!!AY("TSCIRCUIT_REGISTRY_TOKEN")}const uI={get:(t,e)=>Uv().get(t,e),post:(t,e)=>Uv().post(t,e),put:(t,e)=>Uv().put(t,e),delete:(t,e)=>Uv().delete(t,e),patch:(t,e)=>Uv().patch(t,e)},QQn=({packageName:t,onSelectReview:e})=>{const n=eu(_=>_.fsMap),o=eu(_=>_.circuitJson),[r,i]=Y.useState([]),[s,a]=Y.useState(!1),[c,l]=Y.useState(!1);Y.useEffect(()=>{!t||!RY()||(a(!0),uI.get("ai_reviews/list",{searchParams:{package_name:t}}).json().then(_=>i(_.ai_reviews)).catch(_=>{console.error("Failed to load AI reviews",_),ds.error("Failed to load AI reviews")}).finally(()=>a(!1)))},[t]);const u=async()=>{if(!o){ds.error("Need Circuit JSON to Request AI Review");return}if(!RY()){ds.error("Missing registry token");return}l(!0);try{const{ai_review:_}=await uI.post("ai_reviews/create",{json:{package_name:t??"unknown",fs_map:Object.fromEntries(n),circuit_json:o}}).json();i(d=>[_,...d]),e(_),ds.success("AI review requested")}catch(_){console.error("Failed to create AI review",_),ds.error("Failed to request AI review")}finally{l(!1)}};return j.jsxs(j.Fragment,{children:[j.jsxs(Z8,{children:[j.jsx(eC,{children:"AI Review"}),j.jsx(JE,{children:"Select an AI review or request a new one."})]}),j.jsx("div",{className:"rf-flex rf-gap-4 rf-mt-4",children:j.jsx("div",{className:"rf-w-48 rf-h-64 rf-overflow-y-auto rf-border rf-rounded rf-p-2 rf-flex-shrink-0",children:s?j.jsx("div",{className:"rf-text-sm",children:"Loading..."}):r.length>0?r.map(_=>j.jsx("div",{className:"rf-text-sm rf-p-2 rf-cursor-pointer rf-rounded hover:rf-bg-zinc-100",onClick:()=>e(_),children:new Date(_.created_at||"").toLocaleString()},_.ai_review_id)):j.jsx("div",{className:"rf-text-sm rf-text-muted-foreground",children:"No AI reviews found."})})}),j.jsx(sI,{className:"rf-mt-4",children:j.jsx(dc,{onClick:u,disabled:c,children:c?"Requesting...":"Review my Board"})})]})};function c5e(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var rC=c5e();function qht(t){rC=t}var _I={exec:()=>null};function Vc(t,e=""){let n=typeof t=="string"?t:t.source;const o={replace:(r,i)=>{let s=typeof i=="string"?i:i.source;return s=s.replace(f2.caret,"$1"),n=n.replace(r,s),o},getRegex:()=>new RegExp(n,e)};return o}var f2={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceTabs:/^\t+/,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] /,listReplaceTask:/^\[[ xX]\] +/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,unescapeTest:/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:t=>new RegExp(`^( {0,3}${t})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),hrRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}#`),htmlBeginRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}<(?:[a-z].*>|!--)`,"i")},ZQn=/^(?:[ \t]*(?:\n|$))+/,eZn=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,tZn=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,dI=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,nZn=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,l5e=/(?:[*+-]|\d{1,9}[.)])/,Jht=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,Kht=Vc(Jht).replace(/bull/g,l5e).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,"").getRegex(),oZn=Vc(Jht).replace(/bull/g,l5e).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),u5e=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,rZn=/^[^\n]+/,_5e=/(?!\s*\])(?:\\.|[^\[\]\\])+/,iZn=Vc(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",_5e).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),sZn=Vc(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,l5e).getRegex(),kY="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",d5e=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,aZn=Vc("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))","i").replace("comment",d5e).replace("tag",kY).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),Qht=Vc(u5e).replace("hr",dI).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",kY).getRegex(),cZn=Vc(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",Qht).getRegex(),h5e={blockquote:cZn,code:eZn,def:iZn,fences:tZn,heading:nZn,hr:dI,html:aZn,lheading:Kht,list:sZn,newline:ZQn,paragraph:Qht,table:_I,text:rZn},Zht=Vc("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",dI).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code","(?: {4}| {0,3} )[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",kY).getRegex(),lZn={...h5e,lheading:oZn,table:Zht,paragraph:Vc(u5e).replace("hr",dI).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",Zht).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",kY).getRegex()},uZn={...h5e,html:Vc(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",d5e).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:_I,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:Vc(u5e).replace("hr",dI).replace("heading",` *#{1,6} *[^
|
|
5711
5711
|
]`).replace("lheading",Kht).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},_Zn=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,dZn=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,emt=/^( {2,}|\\)\n(?!\s*$)/,hZn=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,NY=/[\p{P}\p{S}]/u,m5e=/[\s\p{P}\p{S}]/u,tmt=/[^\s\p{P}\p{S}]/u,mZn=Vc(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,m5e).getRegex(),nmt=/(?!~)[\p{P}\p{S}]/u,pZn=/(?!~)[\s\p{P}\p{S}]/u,fZn=/(?:[^\s\p{P}\p{S}]|~)/u,xZn=/\[[^[\]]*?\]\((?:\\.|[^\\\(\)]|\((?:\\.|[^\\\(\)])*\))*\)|`[^`]*?`|<[^<>]*?>/g,omt=/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,gZn=Vc(omt,"u").replace(/punct/g,NY).getRegex(),yZn=Vc(omt,"u").replace(/punct/g,nmt).getRegex(),rmt="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",bZn=Vc(rmt,"gu").replace(/notPunctSpace/g,tmt).replace(/punctSpace/g,m5e).replace(/punct/g,NY).getRegex(),PZn=Vc(rmt,"gu").replace(/notPunctSpace/g,fZn).replace(/punctSpace/g,pZn).replace(/punct/g,nmt).getRegex(),vZn=Vc("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,tmt).replace(/punctSpace/g,m5e).replace(/punct/g,NY).getRegex(),SZn=Vc(/\\(punct)/,"gu").replace(/punct/g,NY).getRegex(),CZn=Vc(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme",/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email",/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),MZn=Vc(d5e).replace("(?:-->|$)","-->").getRegex(),TZn=Vc("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment",MZn).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),HY=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,wZn=Vc(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]*(?:\n[ \t]*)?)(title))?\s*\)/).replace("label",HY).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),imt=Vc(/^!?\[(label)\]\[(ref)\]/).replace("label",HY).replace("ref",_5e).getRegex(),smt=Vc(/^!?\[(ref)\](?:\[\])?/).replace("ref",_5e).getRegex(),EZn=Vc("reflink|nolink(?!\\()","g").replace("reflink",imt).replace("nolink",smt).getRegex(),p5e={_backpedal:_I,anyPunctuation:SZn,autolink:CZn,blockSkip:xZn,br:emt,code:dZn,del:_I,emStrongLDelim:gZn,emStrongRDelimAst:bZn,emStrongRDelimUnd:vZn,escape:_Zn,link:wZn,nolink:smt,punctuation:mZn,reflink:imt,reflinkSearch:EZn,tag:TZn,text:hZn,url:_I},DZn={...p5e,link:Vc(/^!?\[(label)\]\((.*?)\)/).replace("label",HY).getRegex(),reflink:Vc(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",HY).getRegex()},f5e={...p5e,emStrongRDelimAst:PZn,emStrongLDelim:yZn,url:Vc(/^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/,"i").replace("email",/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\.|[^\\])*?(?:\\.|[^\s~\\]))\1(?=[^~]|$)/,text:/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|https?:\/\/|ftp:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/},AZn={...f5e,br:Vc(emt).replace("{2,}","*").getRegex(),text:Vc(f5e.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},IY={normal:h5e,gfm:lZn,pedantic:uZn},hI={normal:p5e,gfm:f5e,breaks:AZn,pedantic:DZn},RZn={"&":"&","<":"<",">":">",'"':""","'":"'"},amt=t=>RZn[t];function C3(t,e){if(e){if(f2.escapeTest.test(t))return t.replace(f2.escapeReplace,amt)}else if(f2.escapeTestNoEncode.test(t))return t.replace(f2.escapeReplaceNoEncode,amt);return t}function cmt(t){try{t=encodeURI(t).replace(f2.percentDecode,"%")}catch{return null}return t}function lmt(t,e){const n=t.replace(f2.findPipe,(i,s,a)=>{let c=!1,l=s;for(;--l>=0&&a[l]==="\\";)c=!c;return c?"|":" |"}),o=n.split(f2.splitPipe);let r=0;if(o[0].trim()||o.shift(),o.length>0&&!o.at(-1)?.trim()&&o.pop(),e)if(o.length>e)o.splice(e);else for(;o.length<e;)o.push("");for(;r<o.length;r++)o[r]=o[r].trim().replace(f2.slashPipe,"|");return o}function mI(t,e,n){const o=t.length;if(o===0)return"";let r=0;for(;r<o&&t.charAt(o-r-1)===e;)r++;return t.slice(0,o-r)}function kZn(t,e){if(t.indexOf(e[1])===-1)return-1;let n=0;for(let o=0;o<t.length;o++)if(t[o]==="\\")o++;else if(t[o]===e[0])n++;else if(t[o]===e[1]&&(n--,n<0))return o;return n>0?-2:-1}function umt(t,e,n,o,r){const i=e.href,s=e.title||null,a=t[1].replace(r.other.outputLinkReplace,"$1");o.state.inLink=!0;const c={type:t[0].charAt(0)==="!"?"image":"link",raw:n,href:i,title:s,text:a,tokens:o.inlineTokens(a)};return o.state.inLink=!1,c}function NZn(t,e,n){const o=t.match(n.other.indentCodeCompensation);if(o===null)return e;const r=o[1];return e.split(`
|
|
5712
5712
|
`).map(i=>{const s=i.match(n.other.beginningSpace);if(s===null)return i;const[a]=s;return a.length>=r.length?i.slice(r.length):i}).join(`
|
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.1814",
|
|
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.748",
|
|
117
117
|
"@tscircuit/solver-utils": "^0.0.7"
|
|
118
118
|
}
|
|
119
119
|
}
|