tscircuit 0.0.2245-libonly → 0.0.2246-libonly
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.
- package/dist/browser.min.js +1 -1
- package/package.json +2 -2
package/dist/browser.min.js
CHANGED
|
@@ -5756,7 +5756,7 @@ test("${c} should solve problem correctly", () => {
|
|
|
5756
5756
|
// Add more specific assertions based on expected output
|
|
5757
5757
|
// expect(solver.netLabelPlacementSolver!.netLabelPlacements).toMatchInlineSnapshot()
|
|
5758
5758
|
})
|
|
5759
|
-
`,g=new Blob([l],{type:"text/plain"}),u=URL.createObjectURL(g),h=document.createElement("a");h.href=u,h.download=`${c}.test.ts`,h.click(),URL.revokeObjectURL(u)}catch(a){alert(`Error generating test.ts for ${t.constructor.name}: ${a instanceof Error?a.message:String(a)}`)}o(!1)};return V.jsxs("div",{className:`relative ${e}`,ref:i,children:[V.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&&V.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:[V.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:r,children:"Download JSON"}),V.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:A,children:"Download page.tsx"}),V.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:s,children:"Download test.ts"})]})]})},CRt=t=>t.activeSubSolver?[t,...CRt(t.activeSubSolver)]:[t],EGo=({solver:t})=>{const e=CRt(t);return V.jsx("div",{className:"flex gap-1 items-center text-sm pt-1",children:e.map((n,o)=>V.jsxs("div",{className:"flex items-center",children:[o>0&&V.jsx("span",{className:"text-gray-400 mx-1",children:"→"}),V.jsx(yGo,{solver:n})]},n.constructor.name))})},xGo=({solver:t,triggerRender:e,animationSpeed:n=25,onSolverStarted:o,onSolverCompleted:i})=>{const[r,A]=X.useReducer(_=>!_,!1),s=X.useRef(void 0),a=()=>{!t.solved&&!t.failed&&(t.step(),e())},c=()=>{!t.solved&&!t.failed&&(o&&o(t),t.solve(),e(),i&&i(t))},l=()=>{r?(s.current&&(clearInterval(s.current),s.current=void 0),A()):(A(),s.current=setInterval(()=>{if(t.solved||t.failed){s.current&&(clearInterval(s.current),s.current=void 0),A(),e(),i&&t.solved&&i(t);return}t.step(),e()},n))},g=()=>{const _=t;if(_.getCurrentPhase&&!t.solved&&!t.failed){const m=_.getCurrentPhase();for(;_.getCurrentPhase()===m&&!t.solved&&!t.failed;)t.step();e()}},u=()=>{if(t.solved||t.failed||r)return;const _=window.prompt("Step until which iteration?",`${t.iterations}`);if(_===null)return;const m=Number(_);if(!Number.isFinite(m)){window.alert("Please enter a valid number for the iteration");return}for(;t.iterations<m&&!t.solved&&!t.failed;)t.step();e(),t.solved&&i&&i(t)};X.useEffect(()=>()=>{s.current&&clearInterval(s.current)},[]),X.useEffect(()=>{(t.solved||t.failed)&&r&&(s.current&&(clearInterval(s.current),s.current=void 0),A())},[t.solved,t.failed,r]);const h=t.getCurrentPhase!==void 0,d=h?t.getCurrentPhase():null;return V.jsxs("div",{className:"space-y-2 p-2 border-b",children:[V.jsx("div",{className:"flex items-center",children:V.jsx(EGo,{solver:t})}),V.jsxs("div",{className:"flex gap-2 items-center flex-wrap",children:[V.jsx("button",{onClick:a,disabled:t.solved||t.failed||r,className:"bg-blue-500 hover:bg-blue-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Step"}),V.jsx("button",{onClick:c,disabled:t.solved||t.failed||r,className:"bg-green-500 hover:bg-green-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Solve"}),V.jsx("button",{onClick:l,disabled:t.solved||t.failed,className:`px-3 py-1 rounded text-white text-sm ${r?"bg-red-500 hover:bg-red-600":"bg-yellow-500 hover:bg-yellow-600"} disabled:bg-gray-300`,children:r?"Stop":"Animate"}),V.jsx("button",{onClick:u,disabled:t.solved||t.failed||r,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"}),h&&V.jsx("button",{onClick:g,disabled:t.solved||t.failed||r,className:"bg-purple-500 hover:bg-purple-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Next Stage"}),V.jsxs("div",{className:"text-sm text-gray-600",children:["Iterations: ",t.iterations]}),t.timeToSolve!==void 0&&V.jsxs("div",{className:"text-sm text-gray-600",children:["Time: ",(t.timeToSolve/1e3).toFixed(3),"s"]}),d&&V.jsxs("div",{className:"text-sm text-gray-600",children:["Phase: ",V.jsx("span",{className:"font-medium",children:d})]}),t.solved&&V.jsx("div",{className:"px-2 py-1 bg-green-100 text-green-800 rounded text-sm",children:"Solved"}),t.failed&&V.jsx("div",{className:"px-2 py-1 bg-red-100 text-red-800 rounded text-sm",children:"Failed"})]}),t.error&&V.jsxs("div",{className:"text-red-600 text-sm",children:["Error: ",t.error]})]})},BGo=(t,e,n)=>{const o=t.currentPipelineStepIndex;return e<o?"Completed":e===o&&t.activeSubSolver?t.activeSubSolver.failed?"Failed":"In Progress":"Not Started"},QGo=(t,e)=>{const o=t.pipelineDef[e].solverName,i=BGo(t,e),r=t[o],A=t.firstIterationOfPhase?.[o]??null,s=t.iterations;let a=0;if(i==="Completed"){const u=t.pipelineDef[e+1],h=u?t.firstIterationOfPhase?.[u.solverName]:void 0;h!==void 0&&A!==null?a=h-A:A!==null&&(a=s-A)}else i==="In Progress"&&A!==null&&(a=s-A);const c=t.timeSpentOnPhase?.[o]??0;let l=0;i==="Completed"?l=1:i==="In Progress"&&r&&(l=r.progress??0);const g=r?.stats??null;return{index:e,name:o,status:i,firstIteration:A,iterations:a,progress:l,timeSpent:c,stats:g&&Object.keys(g).length>0?g:null,solverInstance:r??null}},SGo=({status:t})=>{const e={"Not Started":"text-blue-600","In Progress":"text-yellow-600",Completed:"text-green-600",Failed:"text-red-600"};return V.jsx("span",{className:`font-medium ${e[t]}`,children:t})},bGo=({progress:t})=>{if(t===0)return null;const e=Math.round(t*100);return V.jsxs("div",{className:"flex items-center gap-2",children:[V.jsx("div",{className:"w-20 h-2 bg-gray-200 rounded overflow-hidden",children:V.jsx("div",{className:"h-full bg-blue-500 transition-all duration-200",style:{width:`${e}%`}})}),V.jsxs("span",{className:"text-xs text-gray-500",children:[e,"%"]})]})},DGo=t=>Object.entries(t).map(([e,n])=>`${e}: ${n}`).join(", "),MGo=({stats:t})=>{if(!t||Object.keys(t).length===0)return V.jsx("span",{children:"-"});const e=Object.entries(t),n=DGo(t);return V.jsxs("details",{className:"cursor-pointer",children:[V.jsx("summary",{className:"whitespace-nowrap overflow-hidden text-ellipsis max-w-[200px]",children:n}),V.jsx("div",{className:"mt-1 text-xs",children:e.map(([o,i])=>V.jsxs("div",{children:[o,": ",String(i)]},o))})]})},x3e=t=>{if(t===null||typeof t!="object")return t;if(Array.isArray(t))return t.map(x3e);const e={};for(const[n,o]of Object.entries(t))n.startsWith("_")||(e[n]=x3e(o));return e},wGo=(t,e)=>{try{if(typeof t.getConstructorParams!="function"){alert(`getConstructorParams() is not implemented for ${e}`);return}const n=x3e(t.getConstructorParams()),o=new Blob([JSON.stringify(n,null,2)],{type:"application/json"}),i=URL.createObjectURL(o),r=document.createElement("a");r.href=i,r.download=`${e}_input.json`,r.click(),URL.revokeObjectURL(i)}catch(n){alert(`Error downloading input for ${e}: ${n instanceof Error?n.message:String(n)}`)}},PGo=({solver:t,onStepUntilPhase:e,onDownloadInput:n})=>{const o=t.pipelineDef.map((s,a)=>QGo(t,a)),i=s=>{e?.(s)},r=s=>{s.solverInstance&&(n?n(s.solverInstance,s.name):wGo(s.solverInstance,s.name))},A=s=>`${(s/1e3).toFixed(2)}s`;return V.jsxs("div",{className:"border-t border-gray-200",children:[V.jsx("div",{className:"px-4 py-2 bg-gray-50 border-b border-gray-200",children:V.jsx("h3",{className:"text-sm font-semibold text-gray-700",children:"Pipeline Steps"})}),V.jsx("div",{className:"overflow-x-auto",children:V.jsxs("table",{className:"w-full text-sm",children:[V.jsx("thead",{children:V.jsxs("tr",{className:"bg-gray-50 border-b border-gray-200",children:[V.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Step"}),V.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Status"}),V.jsxs("th",{className:"px-4 py-2 text-center font-semibold text-gray-700",children:["i",V.jsx("sub",{children:"0"})]}),V.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Iterations"}),V.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Progress"}),V.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Time"}),V.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Stats"}),V.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Input"})]})}),V.jsx("tbody",{children:o.map(s=>V.jsxs("tr",{className:`border-b border-gray-100 ${s.status==="In Progress"?"bg-yellow-50":""}`,children:[V.jsx("td",{className:"px-4 py-2",children:V.jsxs("div",{className:"flex items-center gap-2",children:[V.jsx("span",{className:"text-gray-400 w-6",children:String(s.index+1).padStart(2,"0")}),V.jsx("button",{onClick:()=>i(s.name),disabled:s.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 ${s.name} completes`,children:V.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:V.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"})})}),V.jsx("span",{className:"font-medium text-gray-900",children:s.name})]})}),V.jsx("td",{className:"px-4 py-2",children:V.jsx(SGo,{status:s.status})}),V.jsx("td",{className:"px-4 py-2 text-center text-gray-600",children:s.firstIteration!==null?s.firstIteration:""}),V.jsx("td",{className:"px-4 py-2 text-gray-600",children:s.iterations}),V.jsx("td",{className:"px-4 py-2",children:V.jsx(bGo,{progress:s.progress})}),V.jsx("td",{className:"px-4 py-2 text-gray-600",children:A(s.timeSpent)}),V.jsx("td",{className:"px-4 py-2 text-gray-500",children:V.jsx(MGo,{stats:s.stats})}),V.jsx("td",{className:"px-4 py-2",children:s.solverInstance?V.jsxs("button",{onClick:()=>r(s),className:"flex items-center gap-1 text-blue-500 hover:text-blue-700",title:`Download input for ${s.name}`,children:[V.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:V.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"})}),V.jsx("span",{children:"Input"})]}):null})]},s.name))})]})})]})},vGo=class extends $r.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 NGo({graphics:t}){const e=t.points??[],n=t.lines??[],o=t.rects??[],i=t.circles??[],r=t.texts??[];let A=Number.POSITIVE_INFINITY,s=Number.POSITIVE_INFINITY,a=Number.NEGATIVE_INFINITY,c=Number.NEGATIVE_INFINITY;const l=(m,p)=>{typeof m=="number"&&(m<A&&(A=m),m>a&&(a=m)),typeof p=="number"&&(p<s&&(s=p),p>c&&(c=p))};for(const m of e)l(m.x,m.y);for(const m of n){const p=m.points??[];for(const C of p)l(C.x,C.y)}for(const m of o){const p=m.x??0,C=m.y??0,I=m.width??0,f=m.height??0;l(p,C),l(p+I,C+f)}for(const m of i){const p=m.x??0,C=m.y??0,I=m.radius??1;l(p-I,C-I),l(p+I,C+I)}for(const m of r)l(m.x,m.y);(!isFinite(A)||!isFinite(s)||!isFinite(a)||!isFinite(c))&&(A=-20,s=-20,a=20,c=20);const g=10,u=A-g,h=s-g,d=Math.max(1,a-A+2*g),_=Math.max(1,c-s+2*g);return V.jsxs("svg",{className:"w-full h-[400px] bg-white",viewBox:`${u} ${h} ${d} ${_}`,role:"img","aria-label":"Graphics fallback",children:[o.map((m,p)=>V.jsx("rect",{x:m.x??0,y:m.y??0,width:m.width??0,height:m.height??0,fill:"none",stroke:m.strokeColor??"black",strokeWidth:m.strokeWidth??1},`rect-${p}`)),n.map((m,p)=>V.jsx("polyline",{fill:"none",stroke:m.strokeColor??"black",strokeWidth:m.strokeWidth??1,points:(m.points??[]).map(C=>`${C.x??0},${C.y??0}`).join(" ")},`line-${p}`)),i.map((m,p)=>V.jsx("circle",{cx:m.x??0,cy:m.y??0,r:m.radius??1.5,fill:m.fillColor??"none",stroke:m.strokeColor??"black",strokeWidth:m.strokeWidth??1},`circle-${p}`)),e.map((m,p)=>V.jsx("circle",{cx:m.x??0,cy:m.y??0,r:m.radius??1.5,fill:m.color??"black"},`point-${p}`)),r.map((m,p)=>V.jsx("text",{x:m.x??0,y:m.y??0,fontSize:m.fontSize??10,fill:m.color??"black",children:m.text??""},`text-${p}`))]})}var RGo=({solver:t,animationSpeed:e=25,onSolverStarted:n,onSolverCompleted:o})=>{const[i,r]=X.useReducer(l=>l+1,0),A=X.useMemo(()=>{try{return t.visualize()||{points:[],lines:[],rects:[],circles:[]}}catch(l){return console.error("Visualization error:",l),{points:[],lines:[],rects:[],circles:[]}}},[t,i]),s=X.useMemo(()=>(A.rects?.length||0)===0&&(A.lines?.length||0)===0&&(A.points?.length||0)===0&&(A.circles?.length||0)===0,[A]);X.useEffect(()=>{if(!(typeof document>"u")&&!document.querySelector('script[src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4"]')){const l=document.createElement("script");l.src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4",document.head.appendChild(l)}},[]);const a=t.pipelineDef!==void 0,c=l=>{const g=t;if(!t.solved&&!t.failed){for(;!t.solved&&!t.failed&&g.currentPipelineStepIndex<=g.pipelineDef.findIndex(u=>u.solverName===l);)t.step();r()}};return V.jsxs("div",{children:[V.jsx(xGo,{solver:t,triggerRender:r,animationSpeed:e,onSolverStarted:n,onSolverCompleted:o}),s?V.jsx("div",{className:"p-4 text-gray-500",children:"No Graphics Yet"}):V.jsx(vGo,{fallback:V.jsx(NGo,{graphics:A}),children:V.jsx(fGo,{graphics:A})}),a&&V.jsx(PGo,{solver:t,onStepUntilPhase:c})]})};const TGo=()=>{X.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)},[])},kGo=1e3,wS=(t,e)=>{const{fileName:n,mimeType:o="text/plain"}=e,i=t instanceof Blob?t:new Blob([t],{type:o}),r=URL.createObjectURL(i),A=document.createElement("a");A.href=r,A.download=n,A.target="_blank",A.rel="noopener noreferrer",A.style.display="none",document.body.appendChild(A),A.click(),document.body.removeChild(A),setTimeout(()=>{URL.revokeObjectURL(r)},kGo)},fRt=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"},PS="https://github.com/tscircuit/tscircuit-autorouter/issues/new",yRt="https://github.com/tscircuit/copper-pour-solver/issues/new",ERt="https://github.com/tscircuit/calculate-packing/issues/new",xRt="https://github.com/tscircuit/schematic-trace-solver/issues/new?template=json-bug-report.yml",FGo={PackSolver2:ERt,AutoroutingPipelineSolver:PS,AssignableAutoroutingPipeline2:PS,AssignableAutoroutingPipeline3:PS,AutoroutingPipeline1_OriginalUnravel:PS,AutoroutingPipelineSolver3_HgPortPointPathing:PS,AutoroutingPipelineSolver4:PS,AutoroutingPipelineSolver5:PS,AutoroutingPipelineSolver7_MultiGraph:PS,AutoroutingPipelineSolver8:PS,CopperPourPipelineSolver:yRt,SchematicTracePipelineSolver:xRt},LGo=t=>t.toLowerCase().includes("pack")?Qvo:t.toLowerCase().includes("rout")?Pvo:uvo,BRt=t=>{const e=FGo[t];if(e)return e;const n=t.toLowerCase();return n.includes("autorout")?PS:n.includes("schematic")&&n.includes("trace")?xRt:n.includes("copperpour")?yRt:n.includes("pack")?ERt:null},HGo=t=>`${fRt(`${t.componentName}-${t.solverName}`)}-solver-input.json`,QRt=t=>{wS(JSON.stringify(t.solverParams,null,2),{fileName:HGo(t),mimeType:"application/json"})},GGo=({solverEvent:t})=>{const e=BRt(t.solverName);return V.jsxs("div",{className:"rf-flex rf-items-center rf-justify-end rf-gap-2 rf-border-b rf-border-gray-200 rf-bg-gray-50 rf-px-4 rf-py-2",children:[V.jsxs(ta,{type:"button",variant:"outline",size:"sm",onClick:()=>QRt(t),children:[V.jsx(rPe,{className:"rf-w-4 rf-h-4"}),"Download"]}),e?V.jsx(ta,{asChild:!0,variant:"outline",size:"sm",children:V.jsxs("a",{href:e,target:"_blank",rel:"noopener noreferrer",children:[V.jsx(coe,{className:"rf-w-4 rf-h-4"}),"Report"]})}):V.jsxs(ta,{type:"button",variant:"outline",size:"sm",disabled:!0,title:"No report link configured for this solver",children:[V.jsx(coe,{className:"rf-w-4 rf-h-4"}),"Report"]})]})},OGo=({solverEvent:t})=>{const e=BRt(t.solverName);return e?V.jsx(ta,{asChild:!0,variant:"ghost",size:"icon",className:"rf-h-8 rf-w-8",children:V.jsx("a",{href:e,target:"_blank",rel:"noopener noreferrer",title:"Report solver bug","aria-label":"Report solver bug",children:V.jsx(coe,{className:"rf-w-4 rf-h-4"})})}):V.jsx(ta,{type:"button",variant:"ghost",size:"icon",className:"rf-h-8 rf-w-8",disabled:!0,title:"No report link configured for this solver","aria-label":"Report solver bug",children:V.jsx(coe,{className:"rf-w-4 rf-h-4"})})},KGo=({solverEvents:t=[]})=>{const[e,n]=X.useState(null);TGo();const o=X.useMemo(()=>{const s=new Map;for(const a of t){const c=`${a.componentName}-${a.solverName}`;s.set(c,a)}return s},[t]),i=X.useMemo(()=>Array.from(o.keys()),[o]),r=e?o.get(e):null,A=X.useMemo(()=>{if(!r)return{instance:null,error:null,classFound:!1};const s=hCe[r.solverName];if(!s)return{instance:null,error:`Solver class "${r.solverName}" not found in SOLVERS registry. Available: ${Object.keys(hCe).join(", ")}`,classFound:!1};try{const a=r.solverParams,c=a?.input!==void 0?a.input:a;return{instance:new s(c),error:null,classFound:!0}}catch(a){const c=a instanceof Error?a.message:String(a);return console.error("Failed to reconstruct solver:",a),{instance:null,error:`Failed to instantiate solver: ${c}`,classFound:!0}}},[r]);return t.length===0?V.jsx("div",{className:"rf-p-4",children:V.jsx("div",{className:"rf-bg-gray-50 rf-rounded-md rf-border rf-border-gray-200",children:V.jsxs("div",{className:"rf-p-4",children:[V.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800 rf-mb-3",children:"No Solvers Detected"}),V.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."})]})})}):V.jsxs("div",{className:"rf-flex rf-h-full rf-overflow-hidden",children:[V.jsxs("div",{className:"rf-w-64 rf-border-r rf-border-gray-200 rf-overflow-y-auto rf-flex-shrink-0",children:[V.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:[i.length," ",i.length===1?"Solver":"Solvers"]}),i.map(s=>{const a=o.get(s),c=e===s;return V.jsx("div",{className:`rf-px-3 rf-py-2 rf-cursor-pointer rf-border-b rf-border-gray-100 ${c?"rf-bg-blue-50 rf-border-l-2 rf-border-l-blue-500":"hover:rf-bg-gray-50"}`,onClick:()=>n(s),children:(()=>{const l=LGo(a.solverName);return V.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2",children:[V.jsx(l,{className:"rf-w-4 rf-h-4 rf-text-blue-500 rf-flex-shrink-0"}),V.jsxs("div",{className:"rf-flex-1 rf-min-w-0",children:[V.jsx("div",{className:"rf-text-sm rf-font-medium rf-text-gray-800 rf-truncate",children:a.componentName}),V.jsx("div",{className:"rf-text-xs rf-text-gray-500 rf-truncate",children:a.solverName})]})]})})()},s)})]}),V.jsx("div",{className:"rf-flex-1 rf-overflow-hidden",children:r?A.instance?V.jsxs("div",{className:"rf-flex rf-h-full rf-flex-col rf-overflow-y-auto",children:[V.jsx(GGo,{solverEvent:r}),V.jsx("div",{className:"rf-min-h-0 rf-flex-1",children:V.jsx(dx,{fallback:V.jsx("div",{className:"rf-p-4",children:V.jsxs("div",{className:"rf-bg-red-50 rf-rounded-md rf-border rf-border-red-200 rf-p-4",children:[V.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-red-800 rf-mb-2",children:"Error Loading Solver Debugger"}),V.jsxs("p",{className:"rf-text-sm rf-text-red-600",children:["Failed to render the solver debugger for"," ",r.solverName]})]})}),children:V.jsx(RGo,{solver:A.instance})})})]}):V.jsxs("div",{className:"rf-p-4",children:[V.jsxs("div",{className:"rf-mb-4",children:[V.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800",children:r.solverName}),V.jsxs("p",{className:"rf-text-sm rf-text-gray-500",children:["Component: ",r.componentName]})]}),A.error&&V.jsx("div",{className:`rf-rounded-md rf-border rf-p-4 rf-mb-4 ${A.classFound?"rf-bg-red-50 rf-border-red-200":"rf-bg-yellow-50 rf-border-yellow-200"}`,children:V.jsx("p",{className:`rf-text-sm ${A.classFound?"rf-text-red-700":"rf-text-yellow-700"}`,children:A.error})}),V.jsxs("div",{className:"rf-border rf-border-gray-200 rf-rounded-md rf-overflow-hidden",children:[V.jsxs("div",{className:"rf-px-3 rf-py-2 rf-bg-gray-50 rf-flex rf-items-center rf-justify-between rf-gap-2",children:[V.jsx("span",{className:"rf-text-sm rf-font-medium rf-text-gray-700",children:"Solver Parameters"}),V.jsxs("div",{className:"rf-flex rf-items-center rf-gap-1",children:[V.jsx(OGo,{solverEvent:r}),V.jsx(ta,{type:"button",variant:"ghost",size:"icon",className:"rf-h-8 rf-w-8","aria-label":"Download solver input JSON",title:"Download solver input JSON",onClick:()=>QRt(r),children:V.jsx(rPe,{className:"rf-w-4 rf-h-4"})})]})]}),V.jsx("div",{className:"rf-p-3 rf-bg-white rf-border-t rf-border-gray-200",children:V.jsx("pre",{className:"rf-text-xs rf-font-mono rf-text-gray-600 rf-whitespace-pre-wrap rf-overflow-x-auto",children:JSON.stringify(r.solverParams,null,2)})})]})]}):V.jsx("div",{className:"rf-flex rf-items-center rf-justify-center rf-h-full",children:V.jsx("p",{className:"rf-text-sm rf-text-gray-500",children:"Select a solver from the list to view details"})})})]})},SRt=({errorMessage:t,errorStack:e,circuitJsonErrors:n})=>{X.useEffect(()=>{if(t){const o=new Error(t);e&&(o.stack=e);try{IN.captureException(o)}catch{}}},[t,e]),X.useEffect(()=>{if(n&&n.length>0)for(const o of n){const i=new Error(o.message||"Circuit JSON Error");o.stack&&(i.stack=o.stack);try{IN.captureException(i,{error_type:o.type})}catch{}}},[n])},bRt=t=>{X.useEffect(()=>{try{lVn(t)}catch{}},[t.source,t.component,t.isWebEmbedded,t.activeTab])},DRt="0.0.2372",UGo={version:DRt},wie=nut()(out(t=>({lastRunEvalVersion:void 0,setLastRunEvalVersion:e=>{t({lastRunEvalVersion:e})}}),{name:"runframe-runner-store"})),YGo=t=>{const[e,n]=X.useState([]),[o,i]=X.useState(null),[r,A]=X.useState(""),[s,a]=q7("eval-version-selection",null),c=wie(h=>h.setLastRunEvalVersion),l=wie(h=>h.lastRunEvalVersion);return X.useEffect(()=>{t&&fetch("https://data.jsdelivr.com/v1/package/npm/@tscircuit/eval").then(h=>h.json()).then(h=>{if(Array.isArray(h?.versions)){let d=[...h.versions];h.tags?.latest&&(i(h.tags.latest),d=d.filter(_=>_!==h.tags.latest)),n(d)}}).catch(()=>{})},[t]),X.useEffect(()=>{t&&(s?(window.TSCIRCUIT_LATEST_EVAL_VERSION=s,c(s)):o&&(window.TSCIRCUIT_LATEST_EVAL_VERSION=o,c(o)))},[t,s,o]),{versions:X.useMemo(()=>e.filter(h=>h.includes(r)).slice(0,50),[e,r]),latestVersion:o,lastRunEvalVersion:l,search:r,setSearch:A,selectVersion:h=>{a(h),A("")}}},zGo=({snippetNames:t,onSelect:e,onCancel:n,isOpen:o})=>{const[i,r]=X.useState(""),[A,s]=X.useState("");if(!o)return null;const a=t.filter(g=>g.toLowerCase().includes(A.toLowerCase())),c=A&&!t.includes(A),l=g=>{g.key==="Enter"&&(a.length===1?r(a[0]):c&&r(A))};return V.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:V.jsxs("div",{className:"rf-bg-white rf-rounded-lg rf-p-6 rf-w-96",children:[V.jsx("h2",{className:"rf-text-lg rf-font-semibold rf-mb-4",children:"Select Snippet"}),V.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:A,onChange:g=>s(g.target.value),onKeyDown:l}),V.jsxs("div",{className:"rf-h-60 rf-overflow-y-auto",children:[a.map(g=>V.jsx("button",{type:"button",className:`w-full text-left px-4 py-2 rounded hover:bg-gray-100 ${i===g?"bg-blue-50":""}`,onClick:()=>r(g),children:g},g)),c&&V.jsxs("button",{type:"button",className:`w-full text-left px-4 py-2 rounded hover:bg-gray-100 text-blue-500 ${i===A?"bg-blue-50":""}`,onClick:()=>r(A),children:['Create new "',A,'"']})]}),V.jsxs("div",{className:"rf-mt-4 rf-flex rf-justify-end rf-gap-2",children:[V.jsx("button",{type:"button",className:"rf-px-4 rf-py-2 rf-text-gray-600 rf-hover:text-gray-800",onClick:n,children:"Cancel"}),V.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:()=>i&&e(i),disabled:!i,children:i===A?`Create "${i}"`:`Save to ${i}`})]})]})})},VGo=t=>{const e=X.useRef(null),n=zu(o=>o.recentEvents);X.useEffect(()=>{if(n.length===0)return;const o=n[0];o.event_id!==e.current&&(t(o),e.current=o.event_id)},[n,t])};var JGo=Object.defineProperty,z2=(t,e)=>JGo(t,"name",{value:e,configurable:!0}),B3e="Dialog",[MRt,wRt]=x2(B3e),[qGo,vB]=MRt(B3e),Q3e=z2(t=>{const{__scopeDialog:e,children:n,open:o,defaultOpen:i,onOpenChange:r,modal:A=!0}=t,s=X.useRef(null),a=X.useRef(null),[c,l]=Vb({prop:o,defaultProp:i??!1,onChange:r,caller:B3e}),[g,u]=X.useState(0),[h,d]=X.useState(0);return V.jsx(qGo,{scope:e,triggerRef:s,contentRef:a,contentId:Am(),titleId:Am(),descriptionId:Am(),titlePresent:g>0,descriptionPresent:h>0,setTitleCount:u,setDescriptionCount:d,open:c,onOpenChange:l,onOpenToggle:X.useCallback(()=>l(_=>!_),[l]),modal:A,children:n})},"Dialog"),WGo="DialogTrigger",jGo=X.forwardRef(z2(function(e,n){const{__scopeDialog:o,...i}=e,r=vB(WGo,o),A=dl(n,r.triggerRef);return V.jsx(Oa.button,{type:"button","aria-haspopup":"dialog","aria-expanded":r.open,"aria-controls":r.open?r.contentId:void 0,"data-state":Nie(r.open),...i,ref:A,onClick:vr(e.onClick,r.onOpenToggle)})},"DialogTrigger")),PRt="DialogPortal",[XGo,vRt]=MRt(PRt,{forceMount:void 0}),S3e=z2(t=>{const{__scopeDialog:e,forceMount:n,children:o,container:i}=t,r=vB(PRt,e);return V.jsx(XGo,{scope:e,forceMount:n,children:X.Children.map(o,A=>V.jsx(ZE,{present:n||r.open,children:V.jsx(vPe,{asChild:!0,container:i,children:A})}))})},"DialogPortal"),b3e="DialogOverlay",Pie=X.forwardRef(z2(function(e,n){const o=vRt(b3e,e.__scopeDialog),{forceMount:i=o.forceMount,...r}=e,A=vB(b3e,e.__scopeDialog);return A.modal?V.jsx(ZE,{present:i||A.open,children:V.jsx(ZGo,{...r,ref:n})}):null},"DialogOverlay")),$Go=qQ("DialogOverlay.RemoveScroll"),ZGo=X.forwardRef(z2(function(e,n){const{__scopeDialog:o,...i}=e,r=vB(b3e,o),A=ZPt(),s=dl(n,A);return V.jsx(voe,{as:$Go,allowPinchZoom:!0,shards:[r.contentRef],children:V.jsx(Oa.div,{"data-state":Nie(r.open),...i,ref:s,style:{pointerEvents:"auto",...i.style}})})},"DialogOverlayImpl")),nU="DialogContent",vie=X.forwardRef(z2(function(e,n){const o=vRt(nU,e.__scopeDialog),{forceMount:i=o.forceMount,...r}=e,A=vB(nU,e.__scopeDialog);return V.jsx(ZE,{present:i||A.open,children:A.modal?V.jsx(eOo,{...r,ref:n}):V.jsx(tOo,{...r,ref:n})})},"DialogContent")),eOo=X.forwardRef(z2(function(e,n){const o=vB(nU,e.__scopeDialog),i=X.useRef(null),r=dl(n,o.contentRef,i);return X.useEffect(()=>{const A=i.current;if(A)return RPe(A)},[]),V.jsx(NRt,{...e,ref:r,trapFocus:o.open,disableOutsidePointerEvents:o.open,onCloseAutoFocus:vr(e.onCloseAutoFocus,A=>{A.preventDefault(),o.triggerRef.current?.focus()}),onPointerDownOutside:vr(e.onPointerDownOutside,A=>{const s=A.detail.originalEvent,a=s.button===0&&s.ctrlKey===!0;(s.button===2||a)&&A.preventDefault()}),onFocusOutside:vr(e.onFocusOutside,A=>A.preventDefault())})},"DialogContentModal")),tOo=X.forwardRef(z2(function(e,n){const o=vB(nU,e.__scopeDialog),i=X.useRef(!1),r=X.useRef(!1);return V.jsx(NRt,{...e,ref:n,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:A=>{e.onCloseAutoFocus?.(A),A.defaultPrevented||(i.current||o.triggerRef.current?.focus(),A.preventDefault()),i.current=!1,r.current=!1},onInteractOutside:A=>{e.onInteractOutside?.(A),A.defaultPrevented||(i.current=!0,A.detail.originalEvent.type==="pointerdown"&&(r.current=!0));const s=A.target;o.triggerRef.current?.contains(s)&&A.preventDefault(),A.detail.originalEvent.type==="focusin"&&r.current&&A.preventDefault()}})},"DialogContentNonModal")),NRt=X.forwardRef(z2(function(e,n){const{__scopeDialog:o,trapFocus:i,onOpenAutoFocus:r,onCloseAutoFocus:A,...s}=e,a=vB(nU,o);return DK(),V.jsx(V.Fragment,{children:V.jsx(hPe,{asChild:!0,loop:!0,trapped:i,onMountAutoFocus:r,onUnmountAutoFocus:A,children:V.jsx(loe,{role:"dialog",id:a.contentId,"aria-describedby":a.descriptionPresent?a.descriptionId:void 0,"aria-labelledby":a.titlePresent?a.titleId:void 0,"data-state":Nie(a.open),...s,ref:n,deferPointerDownOutside:!0,onDismiss:()=>a.onOpenChange(!1)})})})},"DialogContentImpl")),nOo="DialogTitle",D3e=X.forwardRef(z2(function(e,n){const{__scopeDialog:o,...i}=e,r=vB(nOo,o),{setTitleCount:A}=r;return ty(()=>(A(s=>s+1),()=>A(s=>s-1)),[A]),V.jsx(Oa.h2,{id:r.titleId,...i,ref:n})},"DialogTitle")),oOo="DialogDescription",M3e=X.forwardRef(z2(function(e,n){const{__scopeDialog:o,...i}=e,r=vB(oOo,o),{setDescriptionCount:A}=r;return ty(()=>(A(s=>s+1),()=>A(s=>s-1)),[A]),V.jsx(Oa.p,{id:r.descriptionId,...i,ref:n})},"DialogDescription")),iOo="DialogClose",RRt=X.forwardRef(z2(function(e,n){const{__scopeDialog:o,...i}=e,r=vB(iOo,o);return V.jsx(Oa.button,{type:"button",...i,ref:n,onClick:vr(e.onClick,()=>r.onOpenChange(!1))})},"DialogClose"));function Nie(t){return t?"open":"closed"}z2(Nie,"getState");var rOo=Object.defineProperty,G5=(t,e)=>rOo(t,"name",{value:e,configurable:!0}),AOo="AlertDialog",[sOo,wXo]=x2(AOo,[wRt]),O5=wRt(),aOo=G5(t=>{const{__scopeAlertDialog:e,...n}=t,o=O5(e);return V.jsx(Q3e,{...o,...n,modal:!0})},"AlertDialog");X.forwardRef(G5(function(e,n){const{__scopeAlertDialog:o,...i}=e,r=O5(o);return V.jsx(jGo,{...r,...i,ref:n})},"AlertDialogTrigger"));var cOo=G5(t=>{const{__scopeAlertDialog:e,...n}=t,o=O5(e);return V.jsx(S3e,{...o,...n})},"AlertDialogPortal"),lOo=X.forwardRef(G5(function(e,n){const{__scopeAlertDialog:o,...i}=e,r=O5(o);return V.jsx(Pie,{...r,...i,ref:n})},"AlertDialogOverlay")),gOo="AlertDialogContent",[uOo,dOo]=sOo(gOo),hOo=X.forwardRef(G5(function(e,n){const{__scopeAlertDialog:o,children:i,...r}=e,A=O5(o),s=X.useRef(null),a=dl(n,s),c=X.useRef(null);return V.jsx(uOo,{scope:o,cancelRef:c,children:V.jsx(vie,{role:"alertdialog",...A,...r,ref:a,onOpenAutoFocus:vr(r.onOpenAutoFocus,l=>{l.preventDefault(),c.current?.focus({preventScroll:!0})}),onPointerDownOutside:l=>l.preventDefault(),onInteractOutside:l=>l.preventDefault(),children:i})})},"AlertDialogContent")),_Oo=X.forwardRef(G5(function(e,n){const{__scopeAlertDialog:o,...i}=e,r=O5(o);return V.jsx(D3e,{...r,...i,ref:n})},"AlertDialogTitle")),pOo=X.forwardRef(G5(function(e,n){const{__scopeAlertDialog:o,...i}=e,r=O5(o);return V.jsx(M3e,{...r,...i,ref:n})},"AlertDialogDescription")),mOo=X.forwardRef(G5(function(e,n){const{__scopeAlertDialog:o,...i}=e,r=O5(o);return V.jsx(RRt,{...r,...i,ref:n})},"AlertDialogAction")),IOo="AlertDialogCancel",COo=X.forwardRef(G5(function(e,n){const{__scopeAlertDialog:o,...i}=e,{cancelRef:r}=dOo(IOo,o),A=O5(o),s=dl(n,r);return V.jsx(RRt,{...A,...i,ref:s})},"AlertDialogCancel")),fOo=aOo,yOo=cOo,TRt=lOo,kRt=hOo,FRt=mOo,LRt=COo,HRt=_Oo,GRt=pOo;const ORt=fOo,EOo=yOo,KRt=X.forwardRef(({className:t,...e},n)=>V.jsx(TRt,{className:Wi("rf-fixed rf-inset-0 rf-z-50 rf-bg-black/80 data-[state=open]:rf-animate-in data-[state=closed]:rf-animate-out data-[state=closed]:rf-fade-out-0 data-[state=open]:rf-fade-in-0",t),...e,ref:n}));KRt.displayName=TRt.displayName;const w3e=X.forwardRef(({className:t,...e},n)=>V.jsxs(EOo,{children:[V.jsx(KRt,{}),V.jsx(kRt,{ref:n,className:Wi("rf-fixed rf-left-[50%] rf-top-[50%] rf-z-50 rf-grid rf-w-full rf-max-w-lg rf-translate-x-[-50%] rf-translate-y-[-50%] rf-gap-4 rf-border rf-border-zinc-200 rf-bg-white rf-p-6 rf-shadow-lg rf-duration-200 data-[state=open]:rf-animate-in data-[state=closed]:rf-animate-out data-[state=closed]:rf-fade-out-0 data-[state=open]:rf-fade-in-0 data-[state=closed]:rf-zoom-out-95 data-[state=open]:rf-zoom-in-95 data-[state=closed]:rf-slide-out-to-left-1/2 data-[state=closed]:rf-slide-out-to-top-[48%] data-[state=open]:rf-slide-in-from-left-1/2 data-[state=open]:rf-slide-in-from-top-[48%] sm:rf-rounded-lg dark:rf-border-zinc-800 dark:rf-bg-zinc-950",t),...e})]}));w3e.displayName=kRt.displayName;const P3e=({className:t,...e})=>V.jsx("div",{className:Wi("rf-flex rf-flex-col rf-space-y-2 rf-text-center sm:rf-text-left",t),...e});P3e.displayName="AlertDialogHeader";const v3e=({className:t,...e})=>V.jsx("div",{className:Wi("rf-flex rf-flex-col-reverse sm:rf-flex-row sm:rf-justify-end sm:rf-space-x-2",t),...e});v3e.displayName="AlertDialogFooter";const N3e=X.forwardRef(({className:t,...e},n)=>V.jsx(HRt,{ref:n,className:Wi("rf-text-lg rf-font-semibold",t),...e}));N3e.displayName=HRt.displayName;const R3e=X.forwardRef(({className:t,...e},n)=>V.jsx(GRt,{ref:n,className:Wi("rf-text-sm rf-text-zinc-500 dark:rf-text-zinc-400",t),...e}));R3e.displayName=GRt.displayName;const xOo=X.forwardRef(({className:t,...e},n)=>V.jsx(FRt,{ref:n,className:Wi(iT(),t),...e}));xOo.displayName=FRt.displayName;const T3e=X.forwardRef(({className:t,...e},n)=>V.jsx(LRt,{ref:n,className:Wi(iT({variant:"outline"}),"rf-mt-2 sm:rf-mt-0",t),...e}));T3e.displayName=LRt.displayName;var BOo=Object.defineProperty,K5=(t,e)=>BOo(t,"name",{value:e,configurable:!0}),k3e="Checkbox",[QOo,PXo]=x2(k3e),[SOo,F3e]=QOo(k3e);function URt(t){const{__scopeCheckbox:e,checked:n,children:o,defaultChecked:i,disabled:r,form:A,name:s,onCheckedChange:a,required:c,value:l="on",internal_do_not_use_render:g}=t,[u,h]=Vb({prop:n,defaultProp:i??!1,onChange:a,caller:k3e}),[d,_]=X.useState(null),[m,p]=X.useState(null),C=X.useRef(!1),[I,f]=X.useReducer(B=>B+1,0),y=d?!!A||!!d.closest("form"):!0,x={checked:u,disabled:r,setChecked:h,control:d,setControl:_,name:s,form:A,value:l,hasConsumerStoppedPropagationRef:C,userInteractionCount:I,onUserInteraction:f,required:c,defaultChecked:U5(i)?!1:i,isFormControl:y,bubbleInput:m,setBubbleInput:p};return V.jsx(SOo,{scope:e,...x,children:zRt(g)?g(x):o})}K5(URt,"CheckboxProvider");var bOo="CheckboxTrigger",DOo=X.forwardRef(K5(function({__scopeCheckbox:e,onKeyDown:n,onClick:o,...i},r){const{control:A,value:s,disabled:a,checked:c,required:l,setControl:g,setChecked:u,hasConsumerStoppedPropagationRef:h,onUserInteraction:d,isFormControl:_,bubbleInput:m}=F3e(bOo,e),p=dl(r,g),C=X.useRef(c);return X.useEffect(()=>{const I=A?.form;if(I){const f=K5(()=>u(C.current),"reset");return I.addEventListener("reset",f),()=>I.removeEventListener("reset",f)}},[A,u]),V.jsx(Oa.button,{type:"button",role:"checkbox","aria-checked":U5(c)?"mixed":c,"aria-required":l,"data-state":L3e(c),"data-disabled":a?"":void 0,disabled:a,value:s,...i,ref:p,onKeyDown:vr(n,I=>{I.key==="Enter"&&I.preventDefault()}),onClick:vr(o,I=>{d(),u(f=>U5(f)?!0:!f),m&&_&&(h.current=I.isPropagationStopped(),h.current||I.stopPropagation())})})},"CheckboxTrigger")),YRt=X.forwardRef(K5(function(e,n){const{__scopeCheckbox:o,name:i,checked:r,defaultChecked:A,required:s,disabled:a,value:c,onCheckedChange:l,form:g,...u}=e;return V.jsx(URt,{__scopeCheckbox:o,checked:r,defaultChecked:A,disabled:a,required:s,onCheckedChange:l,name:i,form:g,value:c,internal_do_not_use_render:({isFormControl:h})=>V.jsxs(V.Fragment,{children:[V.jsx(DOo,{...u,ref:n,__scopeCheckbox:o}),h&&V.jsx(vOo,{__scopeCheckbox:o})]})})},"Checkbox")),MOo="CheckboxIndicator",wOo=X.forwardRef(K5(function(e,n){const{__scopeCheckbox:o,forceMount:i,...r}=e,A=F3e(MOo,o);return V.jsx(ZE,{present:i||U5(A.checked)||A.checked===!0,children:V.jsx(Oa.span,{"data-state":L3e(A.checked),"data-disabled":A.disabled?"":void 0,...r,ref:n,style:{pointerEvents:"none",...e.style}})})},"CheckboxIndicator")),POo="CheckboxBubbleInput",vOo=X.forwardRef(K5(function({__scopeCheckbox:e,onClick:n,...o},i){const{control:r,hasConsumerStoppedPropagationRef:A,userInteractionCount:s,checked:a,defaultChecked:c,required:l,disabled:g,name:u,value:h,form:d,bubbleInput:_,setBubbleInput:m}=F3e(POo,e),p=dl(i,m),C=MPe(r),I=X.useRef(!1),f=X.useRef(a),y=X.useRef(s);X.useEffect(()=>{const B=_;if(!B)return;const S=window.HTMLInputElement.prototype,w=Object.getOwnPropertyDescriptor(S,"checked").set,F=s!==y.current;y.current=s;const R=f.current!==a;f.current=a;const H=!(F&&A.current);if(R&&w){I.current=!F;const G=new Event("click",{bubbles:H});B.indeterminate=U5(a),w.call(B,U5(a)?!1:a),B.dispatchEvent(G),I.current=!1}},[_,a,A,s]);const x=X.useRef(U5(a)?!1:a);return V.jsx(Oa.input,{type:"checkbox","aria-hidden":!0,defaultChecked:c??x.current,required:l,disabled:g,name:u,value:h,form:d,...o,tabIndex:-1,ref:p,onClick:vr(n,B=>{I.current&&B.stopPropagation()}),style:{...o.style,...C,position:"absolute",pointerEvents:"none",opacity:0,margin:0,transform:"translateX(-100%)"}})},"CheckboxBubbleInput"));function zRt(t){return typeof t=="function"}K5(zRt,"isFunction");function U5(t){return t==="indeterminate"}K5(U5,"isIndeterminate");function L3e(t){return U5(t)?"indeterminate":t?"checked":"unchecked"}K5(L3e,"getState");const oU=X.forwardRef(({className:t,...e},n)=>V.jsx(YRt,{ref:n,className:Wi("rf-peer rf-h-4 rf-w-4 rf-shrink-0 rf-rounded-sm rf-border rf-border-zinc-200 rf-border-zinc-900 rf-shadow focus-visible:rf-outline-none focus-visible:rf-ring-1 focus-visible:rf-ring-zinc-950 disabled:rf-cursor-not-allowed disabled:rf-opacity-50 data-[state=checked]:rf-bg-zinc-900 data-[state=checked]:rf-text-zinc-50 dark:rf-border-zinc-800 dark:rf-border-zinc-50 dark:focus-visible:rf-ring-zinc-300 dark:data-[state=checked]:rf-bg-zinc-50 dark:data-[state=checked]:rf-text-zinc-900",t),...e,children:V.jsx(wOo,{className:Wi("rf-flex rf-items-center rf-justify-center rf-text-current"),children:V.jsx(K3,{className:"rf-h-4 rf-w-4"})})}));oU.displayName=YRt.displayName;const MT=Q3e,NOo=S3e,VRt=X.forwardRef(({className:t,...e},n)=>V.jsx(Pie,{className:Wi("rf-fixed rf-inset-0 rf-z-50 rf-bg-black/80 data-[state=open]:rf-animate-in data-[state=closed]:rf-animate-out data-[state=closed]:rf-fade-out-0 data-[state=open]:rf-fade-in-0",t),...e,ref:n}));VRt.displayName=Pie.displayName;const e6=X.forwardRef(({className:t,children:e,showOverlay:n=!0,...o},i)=>V.jsxs(NOo,{children:[V.jsx(VRt,{className:Wi(n?"":"rf-hidden")}),V.jsx(vie,{ref:i,className:Wi("rf-fixed rf-left-[50%] rf-top-[50%] rf-z-50 rf-grid rf-w-full rf-max-w-lg rf-translate-x-[-50%] rf-translate-y-[-50%] rf-gap-4 rf-border rf-border-zinc-200 rf-bg-white rf-p-6 rf-shadow-lg rf-duration-200 data-[state=open]:rf-animate-in data-[state=closed]:rf-animate-out data-[state=closed]:rf-fade-out-0 data-[state=open]:rf-fade-in-0 data-[state=closed]:rf-zoom-out-95 data-[state=open]:rf-zoom-in-95 data-[state=closed]:rf-slide-out-to-left-1/2 data-[state=closed]:rf-slide-out-to-top-[48%] data-[state=open]:rf-slide-in-from-left-1/2 data-[state=open]:rf-slide-in-from-top-[48%] sm:rf-rounded-lg dark:rf-border-zinc-800 dark:rf-bg-zinc-950",t),...o,children:e})]}));e6.displayName=vie.displayName;const t6=({className:t,...e})=>V.jsx("div",{className:Wi("rf-flex rf-flex-col rf-space-y-2 rf-text-center sm:rf-text-left",t),...e});t6.displayName="DialogHeader";const iU=({className:t,...e})=>V.jsx("div",{className:Wi("rf-flex rf-flex-col-reverse sm:rf-flex-row sm:rf-justify-end sm:rf-space-x-2",t),...e});iU.displayName="DialogFooter";const n6=X.forwardRef(({className:t,...e},n)=>V.jsx(D3e,{ref:n,className:Wi("rf-text-lg rf-font-semibold",t),...e}));n6.displayName=D3e.displayName;const wT=X.forwardRef(({className:t,...e},n)=>V.jsx(M3e,{ref:n,className:Wi("rf-text-sm rf-text-zinc-500 dark:rf-text-zinc-400",t),...e}));wT.displayName=M3e.displayName;const Rie={"tscircuit.com":{label:"tscircuit.com",placeholder:"Search tscircuit packages...",emptyMessage:"No packages found"},jlcpcb:{label:"JLCPCB Parts",placeholder:"Search JLCPCB parts (e.g. C14663)...",emptyMessage:"No parts found"},kicad:{label:"KiCad Footprints",placeholder:"Search KiCad footprints...",emptyMessage:"No footprints found"}},ROo="https://cdn.jsdelivr.net/npm/easyeda@latest/dist/browser/index.js";let H3e=null;const G3e=async()=>(H3e||(H3e=import(ROo)),H3e),TOo=t=>(e,n)=>{const o=new Headers(n?.headers),i={};return o.forEach((r,A)=>{i[A]=r}),fetch(`${t?.apiBase??_C}/proxy`,{...n,headers:{...i,"X-Target-Url":e.toString(),"X-Sender-Origin":i.origin??"","X-Sender-Host":i.host??"https://easyeda.com","X-Sender-Referer":i.referer??"","X-Sender-User-Agent":i["user-agent"]??"","X-Sender-Cookie":i.cookie??"",authority:i.authority??"","content-type":i["content-type"]??"",...t?.headers}})},kOo=async(t,e=10)=>{const n=encodeURIComponent(t),o=await fetch(`https://jlcsearch.tscircuit.com/api/search?limit=${e}&q=${n}`);if(!o.ok)throw new Error(`JLCPCB API error: ${o.status}`);return(await o.json()).components??[]},FOo=t=>({lcscId:t.lcsc,manufacturer:t.mfr,description:t.description,partNumber:`C${t.lcsc}`,package:t.package,price:t.price,stock:t.stock,isBasic:t.is_basic}),JRt=async(t,e)=>{const{fetchEasyEDAComponent:n}=await G3e();return n(t,{fetch:TOo(e),includeModelMetadata:e?.includeModelMetadata})},LOo=async(t,e)=>{const{convertRawEasyToTsx:n}=await G3e(),o=await JRt(t,e);return n({rawEasy:o})},HOo=async(t,e)=>{const{EasyEdaJsonSchema:n,convertEasyEdaJsonToCircuitJson:o}=await G3e(),i=await JRt(t,{...e,includeModelMetadata:!1}),r=n.parse(i);return o(r,{shouldRecenter:!0,showDesignator:!0,useModelCdn:!1})};function hw(t){return Array.isArray?Array.isArray(t):WRt(t)==="[object Array]"}function GOo(t){if(typeof t=="string")return t;if(typeof t=="bigint")return t.toString();const e=t+"";return e=="0"&&1/t==-1/0?"-0":e}function O3e(t){return t==null?"":GOo(t)}function bC(t){return typeof t=="string"}function Tie(t){return typeof t=="number"}function OOo(t){return t===!0||t===!1||KOo(t)&&WRt(t)=="[object Boolean]"}function qRt(t){return typeof t=="object"}function KOo(t){return qRt(t)&&t!==null}function V2(t){return t!=null}function kie(t){return!t.trim().length}function WRt(t){return t==null?t===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(t)}const UOo="Incorrect 'index' type",K3e="Invalid doc index: must be a non-negative integer within the bounds of the docs array",YOo=t=>`Invalid value for key ${t}`,zOo=t=>`Pattern length exceeds max of ${t}.`,VOo=t=>`Missing ${t} property in key`,JOo=t=>`Property 'weight' in key '${t}' must be a positive integer`,qOo="Fuse.match does not support useTokenSearch: token search requires corpus-level statistics (df, fieldCount) that a one-off string comparison does not have. Use new Fuse(...).search(...) instead.",jRt=Object.prototype.hasOwnProperty;var WOo=class{constructor(t){this._keys=[],this._keyMap={};let e=0;t.forEach(n=>{const o=XRt(n);this._keys.push(o),this._keyMap[o.id]=o,e+=o.weight}),this._keys.forEach(n=>{n.weight/=e})}get(t){return this._keyMap[t]}keys(){return this._keys}toJSON(){return JSON.stringify(this._keys)}};function XRt(t){let e=null,n=null,o=null,i=1,r=null;if(bC(t)||hw(t))o=t,e=$Rt(t),n=Fie(t);else{if(!jRt.call(t,"name"))throw new Error(VOo("name"));const A=t.name;if(o=A,jRt.call(t,"weight")&&t.weight!==void 0&&(i=t.weight,i<=0))throw new Error(JOo(Fie(A)));e=$Rt(A),n=Fie(A),r=t.getFn??null}return{path:e,id:n,weight:i,src:o,getFn:r}}function $Rt(t){return hw(t)?t:t.split(".")}function Fie(t){return hw(t)?t.join("."):t}function jOo(t,e){const n=[];let o=!1;const i=(r,A,s,a)=>{if(V2(r))if(!A[s])n.push(a!==void 0?{v:r,i:a}:r);else{const c=r[A[s]];if(!V2(c))return;if(s===A.length-1&&(bC(c)||Tie(c)||OOo(c)||typeof c=="bigint"))n.push(a!==void 0?{v:O3e(c),i:a}:O3e(c));else if(hw(c)){o=!0;for(let l=0,g=c.length;l<g;l+=1)i(c[l],A,s+1,l)}else A.length&&i(c,A,s+1,a)}};return i(t,bC(e)?e.split("."):e,0),o?n:n[0]}const vA=Object.freeze({...{isCaseSensitive:!1,ignoreDiacritics:!1,includeScore:!1,keys:[],shouldSort:!0,sortFn:(t,e)=>t.score===e.score?t.idx<e.idx?-1:1:t.score<e.score?-1:1},...{includeMatches:!1,findAllMatches:!1,minMatchCharLength:1},...{location:0,threshold:.6,distance:100},...{useExtendedSearch:!1,useTokenSearch:!1,tokenize:void 0,tokenMatch:"any",getFn:jOo,ignoreLocation:!1,ignoreFieldNorm:!1,fieldNormWeight:1}});function XOo(t){return t>=9&&t<=13||t===32||t===160}function $Oo(t=1,e=3){const n=new Map,o=Math.pow(10,e);return{get(i){let r=0,A=!1;for(let a=0;a<i.length;a++)XOo(i.charCodeAt(a))?A=!1:A||(r++,A=!0);if(r===0&&(r=1),n.has(r))return n.get(r);const s=Math.round(o/Math.pow(r,.5*t))/o;return n.set(r,s),s},clear(){n.clear()}}}var U3e=class{constructor({getFn:t=vA.getFn,fieldNormWeight:e=vA.fieldNormWeight}={}){this.norm=$Oo(e,3),this.getFn=t,this.isCreated=!1,this.docs=[],this.keys=[],this._keysMap={},this.setIndexRecords()}setSources(t=[]){this.docs=t}setIndexRecords(t=[]){this.records=t}setKeys(t=[]){this.keys=t,this._keysMap={},t.forEach((e,n)=>{this._keysMap[e.id]=n})}create(){if(this.isCreated||!this.docs.length)return;this.isCreated=!0;const t=this.docs.length;this.records=new Array(t);let e=0;if(bC(this.docs[0]))for(let n=0;n<t;n++){const o=this._createStringRecord(this.docs[n],n);o&&(this.records[e++]=o)}else for(let n=0;n<t;n++)this.records[e++]=this._createObjectRecord(this.docs[n],n);this.records.length=e,this.norm.clear()}add(t,e){if(!Number.isInteger(e)||e<0)throw new Error(K3e);if(bC(t)){const o=this._createStringRecord(t,e);return o&&this.records.push(o),o}const n=this._createObjectRecord(t,e);return this.records.push(n),n}removeAt(t){if(!Number.isInteger(t)||t<0)throw new Error(K3e);for(let e=0,n=this.records.length;e<n;e+=1)if(this.records[e].i===t){this.records.splice(e,1);break}for(let e=0,n=this.records.length;e<n;e+=1)this.records[e].i>t&&(this.records[e].i-=1)}removeAll(t){const e=new Set;for(const o of t)Number.isInteger(o)&&o>=0&&e.add(o);if(e.size===0)return;this.records=this.records.filter(o=>!e.has(o.i));const n=Array.from(e).sort((o,i)=>o-i);for(const o of this.records){let i=0,r=n.length;for(;i<r;){const A=i+r>>>1;n[A]<o.i?i=A+1:r=A}o.i-=i}}getValueForItemAtKeyId(t,e){return t[this._keysMap[e]]}size(){return this.records.length}_createStringRecord(t,e){return!V2(t)||kie(t)?null:{v:t,i:e,n:this.norm.get(t)}}_createObjectRecord(t,e){const n={i:e,$:{}};for(let o=0,i=this.keys.length;o<i;o++){const r=this.keys[o],A=r.getFn?r.getFn(t):this.getFn(t,r.path);if(V2(A)){if(hw(A)){const s=[];for(let a=0,c=A.length;a<c;a+=1){const l=A[a];if(V2(l)){if(bC(l)){if(!kie(l)){const g={v:l,i:a,n:this.norm.get(l)};s.push(g)}}else if(V2(l.v)){const g=bC(l.v)?l.v:O3e(l.v);if(!kie(g)){const u={v:g,i:l.i,n:this.norm.get(g)};s.push(u)}}}}n.$[o]=s}else if(bC(A)&&!kie(A)){const s={v:A,n:this.norm.get(A)};n.$[o]=s}}}return n}toJSON(){return{keys:this.keys.map(({getFn:t,...e})=>e),records:this.records}}};function ZRt(t,e,{getFn:n=vA.getFn,fieldNormWeight:o=vA.fieldNormWeight}={}){const i=new U3e({getFn:n,fieldNormWeight:o});return i.setKeys(t.map(XRt)),i.setSources(e),i.create(),i}function ZOo(t,{getFn:e=vA.getFn,fieldNormWeight:n=vA.fieldNormWeight}={}){const{keys:o,records:i}=t,r=new U3e({getFn:e,fieldNormWeight:n});return r.setKeys(o),r.setIndexRecords(i),r}function eKo(t=[],e=vA.minMatchCharLength){const n=[];let o=-1,i=-1,r=0;for(let A=t.length;r<A;r+=1){const s=t[r];s&&o===-1?o=r:!s&&o!==-1&&(i=r-1,i-o+1>=e&&n.push([o,i]),o=-1)}return t[r-1]&&r-o>=e&&n.push([o,r-1]),n}function tKo(t,e,n,{location:o=vA.location,distance:i=vA.distance,threshold:r=vA.threshold,findAllMatches:A=vA.findAllMatches,minMatchCharLength:s=vA.minMatchCharLength,includeMatches:a=vA.includeMatches,ignoreLocation:c=vA.ignoreLocation}={}){if(e.length>32)throw new Error(zOo(32));const l=e.length,g=t.length,u=Math.max(0,Math.min(o,g));let h=r,d=u;const _=(D,w)=>{const F=D/l;if(c)return F;const R=Math.abs(u-w);return i?F+R/i:R?1:F},m=s>1||a,p=m?Array(g):[];let C;for(;(C=t.indexOf(e,d))>-1;){const D=_(0,C);if(h=Math.min(D,h),d=C+l,m){let w=0;for(;w<l;)p[C+w]=1,w+=1}}d=-1;let I=[],f=1,y=0,x=l+g;const B=1<<l-1;for(let D=0;D<l;D+=1){let w=0,F=x;for(;w<F;)_(D,u+F)<=h?w=F:x=F,F=Math.floor((x-w)/2+w);x=F;let R=Math.max(1,u-F+1);const H=A?g:Math.min(u+F,g)+l,G=Array(H+2);G[H+1]=(1<<D)-1;for(let K=H;K>=R;K-=1){const J=K-1,W=n[t[J]];if(G[K]=(G[K+1]<<1|1)&W,D&&(G[K]|=(I[K+1]|I[K])<<1|1|I[K+1]),G[K]&B&&(f=_(D,J),f<=h)){if(h=f,d=J,y=D,d<=u)break;R=Math.max(1,2*u-d)}}if(_(D+1,u)>h)break;I=G}if(m&&d>=0){const D=Math.min(g-1,d+l-1+y);for(let w=d;w<=D;w+=1)n[t[w]]&&(p[w]=1)}const S={isMatch:d>=0,score:Math.max(.001,f)};if(m){const D=eKo(p,s);D.length?a&&(S.indices=D):S.isMatch=!1}return S}function nKo(t){const e={};for(let n=0,o=t.length;n<o;n+=1){const i=t.charAt(n);e[i]=(e[i]||0)|1<<o-n-1}return e}function Y3e(t){if(t.length<=1)return t;t.sort((n,o)=>n[0]-o[0]||n[1]-o[1]);const e=[t[0]];for(let n=1,o=t.length;n<o;n+=1){const i=e[e.length-1],r=t[n];r[0]<=i[1]+1?i[1]=Math.max(i[1],r[1]):e.push(r)}return e}const eTt={ł:"l",Ł:"L",đ:"d",Đ:"D",ø:"o",Ø:"O",ħ:"h",Ħ:"H",ŧ:"t",Ŧ:"T",ı:"i",ß:"ss"},oKo=new RegExp("["+Object.keys(eTt).join("")+"]","g"),rU=typeof String.prototype.normalize=="function"?t=>t.normalize("NFD").replace(/[\u0300-\u036F\u0483-\u0489\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u0610-\u061A\u064B-\u065F\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED\u0711\u0730-\u074A\u07A6-\u07B0\u07EB-\u07F3\u07FD\u0816-\u0819\u081B-\u0823\u0825-\u0827\u0829-\u082D\u0859-\u085B\u08D3-\u08E1\u08E3-\u0903\u093A-\u093C\u093E-\u094F\u0951-\u0957\u0962\u0963\u0981-\u0983\u09BC\u09BE-\u09C4\u09C7\u09C8\u09CB-\u09CD\u09D7\u09E2\u09E3\u09FE\u0A01-\u0A03\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A70\u0A71\u0A75\u0A81-\u0A83\u0ABC\u0ABE-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AE2\u0AE3\u0AFA-\u0AFF\u0B01-\u0B03\u0B3C\u0B3E-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B62\u0B63\u0B82\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD7\u0C00-\u0C04\u0C3E-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C62\u0C63\u0C81-\u0C83\u0CBC\u0CBE-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CE2\u0CE3\u0D00-\u0D03\u0D3B\u0D3C\u0D3E-\u0D44\u0D46-\u0D48\u0D4A-\u0D4D\u0D57\u0D62\u0D63\u0D82\u0D83\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DF2\u0DF3\u0E31\u0E34-\u0E3A\u0E47-\u0E4E\u0EB1\u0EB4-\u0EB9\u0EBB\u0EBC\u0EC8-\u0ECD\u0F18\u0F19\u0F35\u0F37\u0F39\u0F3E\u0F3F\u0F71-\u0F84\u0F86\u0F87\u0F8D-\u0F97\u0F99-\u0FBC\u0FC6\u102B-\u103E\u1056-\u1059\u105E-\u1060\u1062-\u1064\u1067-\u106D\u1071-\u1074\u1082-\u108D\u108F\u109A-\u109D\u135D-\u135F\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17B4-\u17D3\u17DD\u180B-\u180D\u1885\u1886\u18A9\u1920-\u192B\u1930-\u193B\u1A17-\u1A1B\u1A55-\u1A5E\u1A60-\u1A7C\u1A7F\u1AB0-\u1ABE\u1B00-\u1B04\u1B34-\u1B44\u1B6B-\u1B73\u1B80-\u1B82\u1BA1-\u1BAD\u1BE6-\u1BF3\u1C24-\u1C37\u1CD0-\u1CD2\u1CD4-\u1CE8\u1CED\u1CF2-\u1CF4\u1CF7-\u1CF9\u1DC0-\u1DF9\u1DFB-\u1DFF\u20D0-\u20F0\u2CEF-\u2CF1\u2D7F\u2DE0-\u2DFF\u302A-\u302F\u3099\u309A\uA66F-\uA672\uA674-\uA67D\uA69E\uA69F\uA6F0\uA6F1\uA802\uA806\uA80B\uA823-\uA827\uA880\uA881\uA8B4-\uA8C5\uA8E0-\uA8F1\uA8FF\uA926-\uA92D\uA947-\uA953\uA980-\uA983\uA9B3-\uA9C0\uA9E5\uAA29-\uAA36\uAA43\uAA4C\uAA4D\uAA7B-\uAA7D\uAAB0\uAAB2-\uAAB4\uAAB7\uAAB8\uAABE\uAABF\uAAC1\uAAEB-\uAAEF\uAAF5\uAAF6\uABE3-\uABEA\uABEC\uABED\uFB1E\uFE00-\uFE0F\uFE20-\uFE2F]/g,"").replace(oKo,e=>eTt[e]):t=>t;var z3e=class{constructor(t,{location:e=vA.location,threshold:n=vA.threshold,distance:o=vA.distance,includeMatches:i=vA.includeMatches,findAllMatches:r=vA.findAllMatches,minMatchCharLength:A=vA.minMatchCharLength,isCaseSensitive:s=vA.isCaseSensitive,ignoreDiacritics:a=vA.ignoreDiacritics,ignoreLocation:c=vA.ignoreLocation}={}){if(this.options={location:e,threshold:n,distance:o,includeMatches:i,findAllMatches:r,minMatchCharLength:A,isCaseSensitive:s,ignoreDiacritics:a,ignoreLocation:c},t=s?t:t.toLowerCase(),t=a?rU(t):t,this.pattern=t,this.chunks=[],!this.pattern.length)return;const l=(u,h)=>{this.chunks.push({pattern:u,alphabet:nKo(u),startIndex:h})},g=this.pattern.length;if(g>32){let u=0;const h=g%32,d=g-h;for(;u<d;)l(this.pattern.substr(u,32),u),u+=32;if(h){const _=g-32;l(this.pattern.substr(_),_)}}else l(this.pattern,0)}searchIn(t){const{isCaseSensitive:e,ignoreDiacritics:n,includeMatches:o}=this.options;if(t=e?t:t.toLowerCase(),t=n?rU(t):t,this.pattern===t){if(t.length<this.options.minMatchCharLength)return{isMatch:!1,score:1};const d={isMatch:!0,score:0};return o&&(d.indices=[[0,t.length-1]]),d}const{location:i,distance:r,threshold:A,findAllMatches:s,minMatchCharLength:a,ignoreLocation:c}=this.options,l=[];let g=0,u=!1;this.chunks.forEach(({pattern:d,alphabet:_,startIndex:m})=>{const{isMatch:p,score:C,indices:I}=tKo(t,d,_,{location:i+m,distance:r,threshold:A,findAllMatches:s,minMatchCharLength:a,includeMatches:o,ignoreLocation:c});p&&(u=!0),g+=C,p&&I&&l.push(...I)});const h={isMatch:u,score:u?g/this.chunks.length:1};return u&&o&&(h.indices=Y3e(l)),h}};const iKo=new Set(["fuzzy","include"]);function rKo(t){return t.startsWith("inverse")}const V3e=[{type:"exact",multiRegex:/^="(.*)"$/,singleRegex:/^=(.*)$/,create:t=>({type:"exact",search(e){const n=e===t;return{isMatch:n,score:n?0:1,indices:[0,t.length-1]}}})},{type:"include",multiRegex:/^'"(.*)"$/,singleRegex:/^'(.*)$/,create:t=>({type:"include",search(e){let n=0,o;const i=[],r=t.length;for(;(o=e.indexOf(t,n))>-1;)n=o+r,i.push([o,n-1]);const A=!!i.length;return{isMatch:A,score:A?0:1,indices:i}}})},{type:"prefix-exact",multiRegex:/^\^"(.*)"$/,singleRegex:/^\^(.*)$/,create:t=>({type:"prefix-exact",search(e){const n=e.startsWith(t);return{isMatch:n,score:n?0:1,indices:[0,t.length-1]}}})},{type:"inverse-prefix-exact",multiRegex:/^!\^"(.*)"$/,singleRegex:/^!\^(.*)$/,create:t=>({type:"inverse-prefix-exact",search(e){const n=!e.startsWith(t);return{isMatch:n,score:n?0:1,indices:[0,e.length-1]}}})},{type:"inverse-suffix-exact",multiRegex:/^!"(.*)"\$$/,singleRegex:/^!(.*)\$$/,create:t=>({type:"inverse-suffix-exact",search(e){const n=!e.endsWith(t);return{isMatch:n,score:n?0:1,indices:[0,e.length-1]}}})},{type:"suffix-exact",multiRegex:/^"(.*)"\$$/,singleRegex:/^(.*)\$$/,create:t=>({type:"suffix-exact",search(e){const n=e.endsWith(t);return{isMatch:n,score:n?0:1,indices:[e.length-t.length,e.length-1]}}})},{type:"inverse-exact",multiRegex:/^!"(.*)"$/,singleRegex:/^!(.*)$/,create:t=>({type:"inverse-exact",search(e){const n=e.indexOf(t)===-1;return{isMatch:n,score:n?0:1,indices:[0,e.length-1]}}})},{type:"fuzzy",multiRegex:/^"(.*)"$/,singleRegex:/^(.*)$/,create:(t,e={})=>{const n=new z3e(t,{location:e.location??vA.location,threshold:e.threshold??vA.threshold,distance:e.distance??vA.distance,includeMatches:e.includeMatches??vA.includeMatches,findAllMatches:e.findAllMatches??vA.findAllMatches,minMatchCharLength:e.minMatchCharLength??vA.minMatchCharLength,isCaseSensitive:e.isCaseSensitive??vA.isCaseSensitive,ignoreDiacritics:e.ignoreDiacritics??vA.ignoreDiacritics,ignoreLocation:e.ignoreLocation??vA.ignoreLocation});return{type:"fuzzy",search(o){return n.searchIn(o)}}}}],tTt=V3e.length,AKo="\0",sKo="|";function aKo(t){const e=[],n=t.length;let o=0;for(;o<n;){for(;o<n&&t[o]===" ";)o++;if(o>=n)break;let i=o;for(;i<n&&t[i]!==" "&&t[i]!=='"';)i++;if(i<n&&t[i]==='"'){for(i++;i<n;){if(t[i]==='"'){const r=i+1;if(r>=n||t[r]===" "){i++;break}if(t[r]==="$"&&(r+1>=n||t[r+1]===" ")){i+=2;break}}i++}e.push(t.substring(o,i)),o=i}else{for(;i<n&&t[i]!==" ";)i++;e.push(t.substring(o,i)),o=i}}return e}function nTt(t,e){const n=t.match(e);return n?n[1]:null}function cKo(t,e={}){return t.replace(/\\\|/g,AKo).split(sKo).map(n=>{const o=aKo(n.replace(/\u0000/g,"|").trim()).filter(r=>r&&!!r.trim()),i=[];for(let r=0,A=o.length;r<A;r+=1){const s=o[r];let a=!1,c=-1;for(;!a&&++c<tTt;){const l=V3e[c],g=nTt(s,l.multiRegex);g&&(i.push(l.create(g,e)),a=!0)}if(!a)for(c=-1;++c<tTt;){const l=V3e[c],g=nTt(s,l.singleRegex);if(g){i.push(l.create(g,e));break}}}return i})}var lKo=class{constructor(t,{isCaseSensitive:e=vA.isCaseSensitive,ignoreDiacritics:n=vA.ignoreDiacritics,includeMatches:o=vA.includeMatches,minMatchCharLength:i=vA.minMatchCharLength,ignoreLocation:r=vA.ignoreLocation,findAllMatches:A=vA.findAllMatches,location:s=vA.location,threshold:a=vA.threshold,distance:c=vA.distance}={}){this.query=null,this.options={isCaseSensitive:e,ignoreDiacritics:n,includeMatches:o,minMatchCharLength:i,findAllMatches:A,ignoreLocation:r,location:s,threshold:a,distance:c},t=e?t:t.toLowerCase(),t=n?rU(t):t,this.pattern=t,this.query=cKo(this.pattern,this.options)}static condition(t,e){return e.useExtendedSearch}searchIn(t){const e=this.query;if(!e)return{isMatch:!1,score:1};const{includeMatches:n,isCaseSensitive:o,ignoreDiacritics:i}=this.options;t=o?t:t.toLowerCase(),t=i?rU(t):t;let r=0;const A=[];let s=0,a=!1;for(let c=0,l=e.length;c<l;c+=1){const g=e[c];A.length=0,r=0,a=!1;for(let u=0,h=g.length;u<h;u+=1){const d=g[u],{isMatch:_,indices:m,score:p}=d.search(t);if(_)r+=1,s+=p,rKo(d.type)&&(a=!0),n&&(iKo.has(d.type)?A.push(...m):A.push(m));else{s=0,r=0,A.length=0,a=!1;break}}if(r){const u={isMatch:!0,score:s/r};return a&&(u.hasInverse=!0),n&&(u.indices=Y3e(A)),u}}return{isMatch:!1,score:1}}};const J3e=[];function q3e(...t){J3e.push(...t)}function Lie(t,e){for(let n=0,o=J3e.length;n<o;n+=1){const i=J3e[n];if(i.condition(t,e))return new i(t,e)}return new z3e(t,e)}const Hie={AND:"$and",OR:"$or"},W3e={PATH:"$path",PATTERN:"$val"},j3e=t=>!!(t[Hie.AND]||t[Hie.OR]),gKo=t=>!!t[W3e.PATH],uKo=t=>!hw(t)&&qRt(t)&&!j3e(t),oTt=t=>({[Hie.AND]:Object.keys(t).map(e=>({[e]:t[e]}))});function iTt(t,e,{auto:n=!0}={}){const o=i=>{if(bC(i)){const a={keyId:null,pattern:i};return n&&(a.searcher=Lie(i,e)),a}const r=Object.keys(i),A=gKo(i);if(!A&&r.length>1&&!j3e(i))return o(oTt(i));if(uKo(i)){const a=A?i[W3e.PATH]:r[0],c=A?i[W3e.PATTERN]:i[a];if(!bC(c))throw new Error(YOo(a));const l={keyId:Fie(a),pattern:c};return n&&(l.searcher=Lie(c,e)),l}const s={children:[],operator:r[0]};return r.forEach(a=>{const c=i[a];hw(c)&&c.forEach(l=>{s.children.push(o(l))})}),s};return j3e(t)||(t=oTt(t)),o(t)}function X3e(t,{ignoreFieldNorm:e=vA.ignoreFieldNorm}){let n=1;return t.forEach(({key:o,norm:i,score:r})=>{const A=o?o.weight:null;n*=Math.pow(r===0&&A?Number.EPSILON:r,(A||1)*(e?1:i))}),n}function dKo(t,{ignoreFieldNorm:e=vA.ignoreFieldNorm}){t.forEach(n=>{n.score=X3e(n.matches,{ignoreFieldNorm:e})})}var hKo=class{constructor(t,e){this.limit=t,this.heap=[],this.comparator=e}get size(){return this.heap.length}insert(t){this.size<this.limit?(this.heap.push(t),this._bubbleUp(this.size-1)):this.comparator(t,this.heap[0])<0&&(this.heap[0]=t,this._sinkDown(0))}extractSorted(){return this.heap.sort(this.comparator)}_bubbleUp(t){const e=this.heap;for(;t>0;){const n=t-1>>1;if(this.comparator(e[t],e[n])<=0)break;const o=e[t];e[t]=e[n],e[n]=o,t=n}}_sinkDown(t){const e=this.heap,n=e.length;let o=t;do{t=o;const i=2*t+1,r=2*t+2;if(i<n&&this.comparator(e[i],e[o])>0&&(o=i),r<n&&this.comparator(e[r],e[o])>0&&(o=r),o!==t){const A=e[t];e[t]=e[o],e[o]=A}}while(o!==t)}};function _Ko(t){const e=[];return t.matches.forEach(n=>{if(!V2(n.indices)||!n.indices.length)return;const o={indices:n.indices,value:n.value};n.key&&(o.key=n.key.id),n.idx>-1&&(o.refIndex=n.idx),e.push(o)}),e}function pKo(t,e,{includeMatches:n=vA.includeMatches,includeScore:o=vA.includeScore}={}){return t.map(i=>{const{idx:r}=i,A={item:e[r],refIndex:r};return n&&(A.matches=_Ko(i)),o&&(A.score=i.score),A})}const mKo=/[\p{L}\p{M}\p{N}_]+/gu,rTt=new WeakSet;function IKo(t){rTt.has(t)||(rTt.add(t),console.warn(`[Fuse] tokenize regex ${t} lacks the global flag; only the first match per text will be returned. Add the 'g' flag.`))}function CKo(t){if(typeof t=="function"){let e=!1;return n=>{const o=t(n);if(!e&&(e=!0,!Array.isArray(o)||o.some(i=>typeof i!="string")))throw new Error(`[Fuse] tokenize function must return string[]; received ${Array.isArray(o)?"array containing non-strings":typeof o}.`);return o}}return t instanceof RegExp?(t.global||IKo(t),e=>e.match(t)||[]):e=>e.match(mKo)||[]}function $3e({isCaseSensitive:t=!1,ignoreDiacritics:e=!1,tokenize:n}={}){const o=CKo(n);return{tokenize(i){return t||(i=i.toLowerCase()),e&&(i=rU(i)),o(i)}}}var fKo=class{static condition(t,e){return e.useTokenSearch}constructor(t,e){this.options=e,this.analyzer=$3e({isCaseSensitive:e.isCaseSensitive,ignoreDiacritics:e.ignoreDiacritics,tokenize:e.tokenize});const n=this.analyzer.tokenize(t),{df:o,fieldCount:i}=e._invertedIndex;this.termSearchers=[],this.idfWeights=[];for(const r of n){this.termSearchers.push(new z3e(r,{location:e.location,threshold:e.threshold,distance:e.distance,includeMatches:e.includeMatches,findAllMatches:e.findAllMatches,minMatchCharLength:e.minMatchCharLength,isCaseSensitive:e.isCaseSensitive,ignoreDiacritics:e.ignoreDiacritics,ignoreLocation:!0}));const A=o.get(r)||0,s=Math.log(1+(i-A+.5)/(A+.5));this.idfWeights.push(s)}this.combineAll=e.tokenMatch==="all",this.numTerms=this.termSearchers.length,this.useMask=this.numTerms<=31}searchIn(t){if(!this.termSearchers.length)return{isMatch:!1,score:1};const e=[];let n=0,o=0,i=0,r=0;const A=this.combineAll&&!this.useMask?new Set:null;for(let c=0;c<this.termSearchers.length;c++){const l=this.termSearchers[c].searchIn(t),g=this.idfWeights[c];o+=g,l.isMatch&&(i++,n+=g*(1-l.score),l.indices&&e.push(...l.indices),this.combineAll&&(this.useMask?r|=1<<c:A.add(c)))}if(i===0)return{isMatch:!1,score:1};const s=o>0?1-n/o:0,a={isMatch:!0,score:Math.max(.001,s)};return this.options.includeMatches&&e.length&&(a.indices=Y3e(e)),this.combineAll&&(this.useMask?a.matchedMask=r:a.matchedTerms=A,a.termCount=this.numTerms),a}};function Z3e(t,e,n,o){const i=o.tokenize(e);if(!i.length)return;t.fieldCount++,t.docFieldCount.set(n,(t.docFieldCount.get(n)||0)+1);const r=new Set(i);let A=t.docTermFieldHits.get(n);A||(A=new Map,t.docTermFieldHits.set(n,A));for(const s of r)A.set(s,(A.get(s)||0)+1),t.df.set(s,(t.df.get(s)||0)+1)}function ATt(t,e,n,o){const{i,v:r,$:A}=e;if(r!==void 0){Z3e(t,r,i,o);return}if(A)for(let s=0;s<n;s++){const a=A[s];if(a)if(Array.isArray(a))for(const c of a)Z3e(t,c.v,i,o);else Z3e(t,a.v,i,o)}}function yKo(t,e,n){const o={fieldCount:0,df:new Map,docFieldCount:new Map,docTermFieldHits:new Map};for(const i of t)ATt(o,i,e,n);return o}function EKo(t,e,n,o){ATt(t,e,n,o)}function xKo(t,e){const n=t.docFieldCount.get(e);if(n===void 0)return;t.fieldCount-=n,t.docFieldCount.delete(e);const o=t.docTermFieldHits.get(e);if(o){for(const[i,r]of o){const A=(t.df.get(i)||0)-r;A<=0?t.df.delete(i):t.df.set(i,A)}t.docTermFieldHits.delete(e)}}function sTt(t,e){if(e.length===0)return;const n=Array.from(new Set(e)).sort((s,a)=>s-a);for(const s of n)xKo(t,s);const o=s=>{let a=0,c=n.length;for(;a<c;){const l=a+c>>>1;n[l]<s?a=l+1:c=l}return s-a},i=n[0],r=new Map;for(const[s,a]of t.docFieldCount)r.set(s>i?o(s):s,a);t.docFieldCount=r;const A=new Map;for(const[s,a]of t.docTermFieldHits)A.set(s>i?o(s):s,a);t.docTermFieldHits=A}var _w=class{constructor(t,e,n){this.options={...vA,...e},this.options.useExtendedSearch,this.options.useTokenSearch,this._keyStore=new WOo(this.options.keys),this._docs=t,this._myIndex=null,this._invertedIndex=null,this.setCollection(t,n),this._lastQuery=null,this._lastSearcher=null}_getSearcher(t){if(this._lastQuery===t)return this._lastSearcher;const e=Lie(t,this._invertedIndex?{...this.options,_invertedIndex:this._invertedIndex}:this.options);return this._lastQuery=t,this._lastSearcher=e,e}setCollection(t,e){if(this._docs=t,e&&!(e instanceof U3e))throw new Error(UOo);if(this._myIndex=e||ZRt(this.options.keys,this._docs,{getFn:this.options.getFn,fieldNormWeight:this.options.fieldNormWeight}),this.options.useTokenSearch){const n=$3e({isCaseSensitive:this.options.isCaseSensitive,ignoreDiacritics:this.options.ignoreDiacritics,tokenize:this.options.tokenize});this._invertedIndex=yKo(this._myIndex.records,this._myIndex.keys.length,n)}this._invalidateSearcherCache()}add(t){if(!V2(t))return;this._docs.push(t);const e=this._myIndex.add(t,this._docs.length-1);if(this._invertedIndex&&e){const n=$3e({isCaseSensitive:this.options.isCaseSensitive,ignoreDiacritics:this.options.ignoreDiacritics,tokenize:this.options.tokenize});EKo(this._invertedIndex,e,this._myIndex.keys.length,n)}this._invalidateSearcherCache()}remove(t=()=>!1){const e=[],n=[];for(let o=0,i=this._docs.length;o<i;o+=1)t(this._docs[o],o)&&(e.push(this._docs[o]),n.push(o));if(n.length){this._invertedIndex&&sTt(this._invertedIndex,n);const o=new Set(n);this._docs=this._docs.filter((i,r)=>!o.has(r)),this._myIndex.removeAll(n),this._invalidateSearcherCache()}return e}removeAt(t){if(!Number.isInteger(t)||t<0||t>=this._docs.length)throw new Error(K3e);this._invertedIndex&&sTt(this._invertedIndex,[t]);const e=this._docs.splice(t,1)[0];return this._myIndex.removeAt(t),this._invalidateSearcherCache(),e}_invalidateSearcherCache(){this._lastQuery=null,this._lastSearcher=null}getIndex(){return this._myIndex}_normalizedKeys(){return this._myIndex.keys.map(t=>this._keyStore.get(t.id)||t)}search(t,e){const{limit:n=-1}=e||{},{includeMatches:o,includeScore:i,shouldSort:r,sortFn:A,ignoreFieldNorm:s}=this.options;if(bC(t)&&!t.trim()){let u=this._docs.map((h,d)=>({item:h,refIndex:d}));return Tie(n)&&n>-1&&(u=u.slice(0,n)),u}const a=r&&Tie(n)&&n>0&&bC(t),c=A,l=(u,h)=>c(u,h)||u.idx-h.idx;let g;if(a){const u=new hKo(n,l);bC(this._docs[0])?this._searchStringList(t,{heap:u,ignoreFieldNorm:s}):this._searchObjectList(t,{heap:u,ignoreFieldNorm:s}),g=u.extractSorted()}else g=bC(t)?bC(this._docs[0])?this._searchStringList(t):this._searchObjectList(t):this._searchLogical(t),dKo(g,{ignoreFieldNorm:s}),r&&g.sort(bC(t)?l:c),Tie(n)&&n>-1&&(g=g.slice(0,n));return pKo(g,this._docs,{includeMatches:o,includeScore:i})}_searchStringList(t,{heap:e,ignoreFieldNorm:n}={}){const o=this._getSearcher(t),i=this.options.useTokenSearch&&this.options.tokenMatch==="all",{records:r}=this._myIndex,A=e?null:[];return r.forEach(({v:s,i:a,n:c})=>{if(!V2(s))return;const l=o.searchIn(s);if(l.isMatch){const g={score:l.score,value:s,norm:c,indices:l.indices};i&&(g.matchedMask=l.matchedMask,g.matchedTerms=l.matchedTerms,g.termCount=l.termCount);const u=[g];if(!i||this._coversAllTokens(u)){const h={item:s,idx:a,matches:u};e?(h.score=X3e(h.matches,{ignoreFieldNorm:n}),e.insert(h)):A.push(h)}}}),A}_searchLogical(t){const e=iTt(t,this.options),n=this._normalizedKeys(),o=(s,a,c)=>{if(!("children"in s)){const{keyId:h,searcher:d}=s;let _;return h===null?(_=[],n.forEach((m,p)=>{_.push(...this._findMatches({key:m,value:a[p],searcher:d}))})):_=this._findMatches({key:this._keyStore.get(h),value:this._myIndex.getValueForItemAtKeyId(a,h),searcher:d}),_&&_.length?[{idx:c,item:a,matches:_}]:[]}const{children:l,operator:g}=s,u=[];for(let h=0,d=l.length;h<d;h+=1){const _=l[h],m=o(_,a,c);if(m.length)u.push(...m);else if(g===Hie.AND)return[]}return u},i=this._myIndex.records,r=new Map,A=[];return i.forEach(({$:s,i:a})=>{if(V2(s)){const c=o(e,s,a);c.length&&(r.has(a)||(r.set(a,{idx:a,item:s,matches:[]}),A.push(r.get(a))),c.forEach(({matches:l})=>{r.get(a).matches.push(...l)}))}}),A}_searchObjectList(t,{heap:e,ignoreFieldNorm:n}={}){const o=this._getSearcher(t),i=this.options.useTokenSearch&&this.options.tokenMatch==="all",{records:r}=this._myIndex,A=this._normalizedKeys(),s=e?null:[];return r.forEach(({$:a,i:c})=>{if(!V2(a))return;const l=[];let g=!1,u=!1;if(A.forEach((h,d)=>{const _=this._findMatches({key:h,value:a[d],searcher:o});_.length?(l.push(..._),_[0].hasInverse&&(u=!0)):g=!0}),!(u&&g)&&l.length&&(!i||this._coversAllTokens(l))){const h={idx:c,item:a,matches:l};e?(h.score=X3e(h.matches,{ignoreFieldNorm:n}),e.insert(h)):s.push(h)}}),s}_findMatches({key:t,value:e,searcher:n}){if(!V2(e))return[];const o=[];if(hw(e))e.forEach(({v:i,i:r,n:A})=>{if(!V2(i))return;const s=n.searchIn(i);if(s.isMatch){const a={score:s.score,key:t,value:i,idx:r,norm:A,indices:s.indices,hasInverse:s.hasInverse};s.termCount!==void 0&&(a.matchedMask=s.matchedMask,a.matchedTerms=s.matchedTerms,a.termCount=s.termCount),o.push(a)}});else{const{v:i,n:r}=e,A=n.searchIn(i);if(A.isMatch){const s={score:A.score,key:t,value:i,norm:r,indices:A.indices,hasInverse:A.hasInverse};A.termCount!==void 0&&(s.matchedMask=A.matchedMask,s.matchedTerms=A.matchedTerms,s.termCount=A.termCount),o.push(s)}}return o}_coversAllTokens(t){const e=t.length?t[0].termCount:void 0;if(e===void 0)return!0;if(e<=31){let o=0;for(let i=0;i<t.length;i++)o|=t[i].matchedMask||0;return o===2**e-1}const n=new Set;for(let o=0;o<t.length;o++){const i=t[o].matchedTerms;if(i)for(const r of i)n.add(r)}return n.size===e}};_w.version="7.5.0",_w.createIndex=ZRt,_w.parseIndex=ZOo,_w.config=vA,_w.match=function(t,e,n){if(n&&n.useTokenSearch)throw new Error(qOo);return Lie(t,{...vA,...n}).searchIn(e)},_w.parseQuery=iTt,q3e(lKo),q3e(fKo),_w.use=function(...t){t.forEach(e=>q3e(e))};var BKo=_w;const QKo="https://kicad-mod-cache.tscircuit.com";let e6e=null,AU=null,t6e=null;const SKo=async()=>e6e||AU||(AU=fetch("https://kicad-mod-cache.tscircuit.com/kicad_files.json").then(t=>t.json()).then(t=>(e6e=t,AU=null,t)),AU),bKo=async(t,e=20)=>{const n=await SKo();return t6e||(t6e=new BKo(n)),t6e.search(t).slice(0,e).map(o=>o.item)},DKo=t=>{const e=t.replace(".pretty/","/").replace(".kicad_mod",""),n=`kicad:${e}`;return{path:t,qualifiedName:n,description:e}},MKo=t=>t.replace(/^\/+/,"").split("/").map(e=>encodeURIComponent(e)).join("/"),wKo=async t=>{const e=await fetch(`${QKo}/${MKo(t)}`);if(!e.ok)throw new Error(`KiCad footprint fetch failed: ${e.status}`);const n=await e.text(),{KicadFootprintToCircuitJsonConverter:o}=await DB("kicad-to-circuit-json"),i=new o;return i.addFile(t.split("/").pop()??"selected-footprint.kicad_mod",n),i.runUntilFinished(),i.getOutput()},aTt=t=>t?.source==="jlcpcb"||t?.source==="kicad",PKo=async(t,e)=>{if(t.source==="jlcpcb")return HOo(t.component.partNumber,e?.jlcpcb);if(t.source==="kicad")return wKo(t.footprint.path);throw new Error("Footprint preview is not available for this source")},vKo=({query:t,placeholder:e,isSearching:n,onQueryChange:o,onSubmit:i})=>{const r=X.useCallback(A=>{A.key==="Enter"&&(A.preventDefault(),i())},[i]);return V.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2 rf-mt-4",children:[V.jsxs("div",{className:"rf-relative rf-flex-grow",children:[V.jsx(APe,{className:"rf-absolute rf-left-2 rf-top-2.5 rf-h-4 rf-w-4 rf-text-muted-foreground"}),V.jsx(tve,{placeholder:e,className:"rf-pl-8",spellCheck:!1,autoComplete:"off",value:t,onChange:A=>o(A.target.value),onKeyDown:r})]}),V.jsx(ta,{onClick:i,disabled:n||t.trim().length<1,className:"sm:rf-px-4 rf-px-3",children:n?V.jsx(SB,{className:"rf-h-4 rf-w-4 rf-animate-spin"}):V.jsxs(V.Fragment,{children:[V.jsx(APe,{className:"rf-h-4 rf-w-4 sm:rf-hidden"}),V.jsx("span",{className:"rf-hidden sm:rf-inline",children:"Search"})]})})]})},NKo=new Intl.NumberFormat("en-US",{style:"currency",currency:"USD"}),RKo=t=>NKo.format(t),cTt=t=>{switch(t.source){case"tscircuit.com":{const e=t.package;return`tscircuit-${e.package_id??`${e.org_owner_tscircuit_handle??"unknown"}-${e.unscoped_name??e.name??"package"}`}`}case"jlcpcb":return`jlc-${t.component.lcscId}`;case"kicad":return`kicad-${t.footprint.path}`;default:return"unknown"}},TKo=t=>{switch(t.source){case"tscircuit.com":return t.package.unscoped_name;case"jlcpcb":return t.component.isDirectLookup?t.component.partNumber:t.component.manufacturer;case"kicad":return t.footprint.qualifiedName}},kKo=t=>{switch(t.source){case"tscircuit.com":return t.package.description||(t.package.org_owner_tscircuit_handle?`Component by ${t.package.org_owner_tscircuit_handle}`:void 0);case"jlcpcb":return t.component.description;case"kicad":return t.footprint.description}},FKo=t=>{switch(t.source){case"tscircuit.com":return t.package.name;case"jlcpcb":return t.component.isDirectLookup?void 0:t.component.partNumber;case"kicad":return}},LKo=({results:t,selected:e,onSelect:n,onShowDetails:o})=>{const i=e?cTt(e):null;return V.jsx("div",{className:"rf-divide-y rf-w-full rf-overflow-hidden",children:t.map(r=>{const A=cTt(r),s=i===A,a=TKo(r),c=kKo(r),l=FKo(r),g=r.source==="jlcpcb"?r.component.stock:null,u=r.source==="jlcpcb"?r.component.price:null,h=r.source==="jlcpcb"?r.component.isBasic:null,d=r.source==="jlcpcb"?r.component.isDirectLookup:!1;return V.jsxs("div",{className:`rf-p-3 rf-flex rf-flex-col sm:rf-grid sm:rf-grid-cols-[minmax(0,1fr)_auto] rf-items-start sm:rf-items-center rf-cursor-pointer hover:rf-bg-zinc-100 rf-gap-2 rf-overflow-hidden ${s?"rf-bg-zinc-100":""}`,onClick:()=>n(r),children:[V.jsxs("div",{className:"rf-min-w-0 rf-overflow-hidden rf-w-full",children:[V.jsxs("div",{className:"rf-flex rf-items-start rf-gap-2 rf-min-w-0",children:[V.jsxs("div",{className:"rf-font-medium rf-text-sm rf-truncate rf-flex-1 rf-min-w-0 rf-flex rf-items-center rf-gap-1.5",children:[a,r.source==="jlcpcb"&&h!=null&&V.jsx("span",{className:`rf-text-xs rf-px-1.5 rf-py-0.5 rf-rounded rf-font-medium rf-flex-shrink-0 ${h?"rf-bg-green-100 rf-text-green-700":"rf-bg-orange-100 rf-text-orange-700"}`,children:h?"Basic":"Extended"}),d&&V.jsx("span",{className:"rf-text-xs rf-px-1.5 rf-py-0.5 rf-rounded rf-font-medium rf-flex-shrink-0 rf-bg-blue-100 rf-text-blue-700",children:"Direct lookup"}),r.source==="tscircuit.com"&&r.package.is_private&&V.jsx(bvo,{className:"rf-ml-1 rf-h-3 rf-w-3 rf-text-zinc-400 rf-flex-shrink-0"})]}),r.source==="jlcpcb"&&g!=null?V.jsxs("div",{className:"rf-text-xs rf-text-zinc-500 rf-font-medium rf-whitespace-nowrap rf-flex-shrink-0 sm:rf-hidden",children:[g.toLocaleString()," in stock"]}):null]}),V.jsxs("div",{className:"rf-text-xs rf-text-zinc-500 rf-truncate rf-w-full",children:[l?V.jsx("span",{className:"rf-mr-2",children:l}):null,c]})]}),V.jsxs("div",{children:[r.source==="tscircuit.com"&&o?V.jsx("div",{className:"rf-flex-shrink-0 rf-w-full sm:rf-w-auto",children:V.jsx(ta,{variant:"outline",size:"sm",className:"rf-text-xs rf-w-full sm:rf-w-auto",onClick:_=>{_.stopPropagation(),o(r)},children:"See Details"})}):r.source==="jlcpcb"&&g!=null?V.jsxs("div",{className:"rf-hidden sm:rf-block rf-text-xs rf-text-zinc-500 rf-font-medium rf-whitespace-nowrap rf-flex-shrink-0",children:[g.toLocaleString()," in stock"]}):null,u!=null&&V.jsx("div",{className:"rf-hidden sm:rf-block rf-text-xs rf-text-zinc-500 rf-font-medium rf-whitespace-nowrap rf-flex-shrink-0 rf-text-right",children:RKo(u)})]})]},A)})})},HKo=({circuitJson:t,error:e,isLoading:n,height:o})=>V.jsx("section",{className:"rf-flex rf-min-w-0 rf-items-center rf-justify-center",style:{height:o},children:n?V.jsxs("div",{className:"rf-flex rf-w-full rf-items-center rf-justify-center rf-gap-2 rf-bg-zinc-950 rf-text-sm rf-text-zinc-300",style:{height:o},children:[V.jsx(SB,{className:"rf-h-4 rf-w-4 rf-animate-spin"}),"Loading preview..."]}):e?V.jsx("div",{className:"rf-flex rf-w-full rf-items-center rf-justify-center rf-bg-zinc-950 rf-p-4",style:{height:o},children:V.jsxs("div",{className:"rf-flex rf-max-w-[320px] rf-items-start rf-gap-2 rf-text-sm rf-text-zinc-300",children:[V.jsx(qPt,{className:"rf-mt-0.5 rf-h-4 rf-w-4 rf-flex-shrink-0"}),V.jsx("span",{children:e})]})}):t?V.jsx("div",{className:"rf-w-full rf-min-w-0 rf-overflow-hidden",children:V.jsx(pRt,{circuitJson:t,height:o,allowEditing:!1,clickToInteractEnabled:!1,focusOnHover:!1,disablePcbGroups:!0})}):V.jsx("div",{className:"rf-flex rf-w-full rf-items-center rf-justify-center rf-bg-zinc-950 rf-text-sm rf-text-zinc-300",style:{height:o},children:"No preview"})}),lTt={importComponentDialog:101,importComponentDetailsDialog:102},GKo=({packageResult:t,isOpen:e,onOpenChange:n,isLoading:o,details:i,previewTab:r,onPreviewTabChange:A,isSubmitting:s,onImport:a})=>{const c=t?.package??null,l=c?.latest_pcb_preview_image_url,g=c?.latest_sch_preview_image_url,u=c?.latest_cad_preview_image_url,h=c?.unscoped_name?.split("/").pop()??c?.unscoped_name,d=c?.org_owner_tscircuit_handle??void 0,_=d?`https://tscircuit.com/${d}`:void 0,m=d&&h?`https://tscircuit.com/${d}/${h}`:void 0;return V.jsx(MT,{open:e,onOpenChange:n,children:V.jsxs(e6,{showOverlay:!1,style:{width:"calc(100vw - 2rem)",zIndex:lTt.importComponentDetailsDialog},className:"rf-max-w-5xl no-scrollbar !rf-overflow-y-auto rf-max-h-[90vh] rf-overflow-hidden rf-flex rf-flex-col rf-rounded-sm",children:[V.jsx(t6,{className:"rf-pb-4 rf-border-b",children:V.jsx("div",{className:"rf-flex rf-items-start rf-justify-between rf-gap-4",children:V.jsxs("div",{className:"rf-flex-1 rf-min-w-0",children:[V.jsx(n6,{className:"rf-text-xl rf-font-semibold rf-truncate",children:h}),V.jsx(wT,{children:c?.description})]})})}),V.jsxs("div",{className:"rf-flex-1 rf-overflow-y-auto rf-py-4 rf-space-y-6",children:[d?V.jsxs("div",{children:[V.jsx("span",{className:"rf-text-xs rf-font-medium rf-text-gray-500 rf-uppercase rf-tracking-wide",children:"Created by"}),V.jsx("div",{className:"rf-mt-1 rf-text-sm rf-font-medium",children:_?V.jsx("a",{href:_,target:"_blank",rel:"noopener noreferrer",className:"rf-text-black hover:rf-underline",children:d}):d})]}):null,(u||l||g)&&V.jsx(V.Fragment,{children:V.jsxs("div",{children:[V.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-mb-4",children:"Preview"}),V.jsxs(j1e,{value:r,onValueChange:p=>A(p),children:[V.jsxs(YZ,{className:"rf-inline-flex rf-h-9 rf-items-center rf-justify-center rf-rounded-lg rf-bg-zinc-100 rf-p-1 rf-text-zinc-500 dark:rf-bg-zinc-800 dark:rf-text-zinc-400",children:[l&&V.jsx($Q,{value:"pcb",children:"PCB"}),g&&V.jsx($Q,{value:"schematic",children:"Schematic"}),u&&V.jsx($Q,{value:"3d",children:"3D"})]}),V.jsxs("div",{className:"rf-mt-4",children:[V.jsx(IC,{value:"pcb",className:"rf-border rf-rounded-lg rf-overflow-hidden rf-bg-gray-50",children:l?V.jsx("img",{src:l,alt:`${h??"package"} PCB preview`,className:"rf-w-full rf-h-full rf-object-contain rf-bg-white rf-p-4"}):null}),V.jsx(IC,{value:"schematic",className:"rf-border rf-rounded-lg rf-overflow-hidden rf-bg-gray-50",children:g?V.jsx("img",{src:g,alt:`${h??"package"} schematic preview`,className:"rf-w-full rf-h-full rf-object-contain rf-bg-white rf-p-4"}):null}),V.jsx(IC,{value:"3d",className:"rf-border rf-rounded-lg rf-overflow-hidden rf-bg-gray-50",children:u?V.jsx("img",{src:u,alt:`${h??"package"} 3D preview`,className:"rf-w-full rf-h-full rf-object-contain rf-bg-white rf-p-4"}):null})]})]})]})}),i?.ai_description?V.jsxs("section",{children:[V.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-mb-3",children:"AI Description"}),V.jsx("div",{className:"rf-bg-gray-50 rf-border rf-border-gray-200 rf-rounded-lg rf-p-4",children:V.jsx("p",{className:"rf-text-sm rf-text-gray-700 rf-leading-relaxed",children:i.ai_description})})]}):null,i?.ai_usage_instructions?V.jsxs("section",{children:[V.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-mb-3",children:"Usage Instructions"}),V.jsx("div",{className:"rf-bg-gray-50 rf-border rf-border-gray-200 rf-rounded-lg rf-p-4",children:V.jsx("p",{className:"rf-text-sm rf-text-gray-700 rf-leading-relaxed rf-whitespace-pre-wrap",children:i.ai_usage_instructions})})]}):null,o?V.jsxs("div",{className:"rf-flex rf-justify-center rf-items-center rf-gap-2 rf-text-gray-500",children:[V.jsx(SB,{className:"rf-h-4 rf-w-4 rf-animate-spin"}),V.jsx("span",{className:"rf-text-sm",children:"Loading package details..."})]}):null]}),V.jsxs(iU,{className:"rf-pt-4 rf-border-t rf-flex rf-flex-col sm:rf-flex-row rf-justify-between rf-gap-2",children:[V.jsx("div",{className:"rf-flex-1",children:m?V.jsxs(ta,{variant:"outline",size:"sm",className:"rf-gap-2 rf-w-full sm:rf-w-auto",onClick:()=>window.open(m,"_blank"),children:[V.jsx(fvo,{className:"rf-h-4 rf-w-4"}),"View on tscircuit.com"]}):null}),V.jsxs("div",{className:"rf-flex rf-flex-col sm:rf-flex-row rf-gap-2",children:[V.jsx(ta,{variant:"outline",onClick:()=>n(!1),className:"rf-order-2 sm:rf-order-1",children:"Close"}),V.jsx(ta,{onClick:a,disabled:s,className:"rf-bg-blue-600 hover:rf-bg-blue-700",children:s?V.jsx(SB,{className:"rf-h-4 rf-w-4 rf-animate-spin"}):"Import Component"})]})]})]})})},OKo=()=>{const[t,e]=X.useState(null),[n,o]=X.useState(!1),i=X.useCallback(async(A,s)=>{o(!0);try{const a=await fetch(`https://api.tscircuit.com/packages/get?name=${encodeURIComponent(`${A}/${s}`)}`);if(!a.ok)throw new Error(`Failed to load package details: ${a.status}`);const c=await a.json();e(c.package??null)}catch(a){console.error("Failed to fetch package details",a),e(null)}finally{o(!1)}},[]),r=X.useCallback(()=>{e(null),o(!1)},[]);return{details:t,isLoading:n,fetchDetails:i,reset:r}},KKo=(t,e)=>{const[n,o]=X.useState({circuitJson:null,error:null,isLoading:!1});return X.useEffect(()=>{if(!t||!aTt(t)){o({circuitJson:null,error:null,isLoading:!1});return}let i=!1;return o({circuitJson:null,error:null,isLoading:!0}),PKo(t,e).then(r=>{i||o({circuitJson:r,error:null,isLoading:!1})}).catch(r=>{i||o({circuitJson:null,error:r instanceof Error?r.message:"Failed to load footprint preview",isLoading:!1})}),()=>{i=!0}},[t,e]),n},UKo=async(t,e)=>{const n={"Content-Type":"application/json"};e&&(n.Authorization=`Bearer ${e}`);const o=await fetch("https://registry-api.tscircuit.com/packages/search",{method:"POST",headers:n,body:JSON.stringify({query:t})});if(!o.ok)throw new Error(`tscircuit registry error: ${o.status}`);return(await o.json()).packages??[]},YKo=({sessionToken:t})=>{const[e,n]=X.useState([]),[o,i]=X.useState(!1),[r,A]=X.useState(null),[s,a]=X.useState(!1),c=X.useCallback(async g=>{const u=g.trim();if(!u)return[];i(!0),A(null);try{const d=(await UKo(u,t)).map(_=>({source:"tscircuit.com",package:_}));return n(d),d}catch(h){return console.error("Error searching tscircuit packages",h),n([]),A(h instanceof Error?h.message:"Failed to search tscircuit packages"),[]}finally{i(!1),a(!0)}},[t]),l=X.useCallback(()=>{n([]),i(!1),A(null),a(!1)},[]);return{results:e,isSearching:o,error:r,hasSearched:s,search:c,reset:l}},zKo=t=>{const e=/^C(\d+)$/i.exec(t.trim());if(!e)return null;const n=Number(e[1]);if(!Number.isSafeInteger(n))return null;const o=`C${e[1]}`;return{source:"jlcpcb",component:{lcscId:n,manufacturer:o,partNumber:o,description:"Import directly from EasyEDA; stock and availability are unknown",package:"",isDirectLookup:!0}}},gTt=(t,e)=>{const n=zKo(t);return n?e.some(i=>i.component.partNumber.toUpperCase()===n.component.partNumber)?e:[n,...e]:e},VKo=t=>{const e=t.trim();return/^C\d+/i.test(e)?e.replace(/^C/i,""):e},JKo=()=>{const[t,e]=X.useState([]),[n,o]=X.useState(!1),[i,r]=X.useState(null),[A,s]=X.useState(!1),a=X.useCallback(async l=>{const g=VKo(l);if(!g)return[];o(!0),r(null);try{const u=await kOo(g,10),h=gTt(l,u.map(d=>({source:"jlcpcb",component:FOo(d)})));return e(h),h}catch(u){console.error("Error searching JLCPCB components",u);const h=gTt(l,[]);return e(h),r(h.length>0?null:u instanceof Error?u.message:"Failed to search JLCPCB components"),h}finally{o(!1),s(!0)}},[]),c=X.useCallback(()=>{e([]),o(!1),r(null),s(!1)},[]);return{results:t,isSearching:n,error:i,hasSearched:A,search:a,reset:c}},qKo=()=>{const[t,e]=X.useState([]),[n,o]=X.useState(!1),[i,r]=X.useState(null),[A,s]=X.useState(!1),a=X.useCallback(async l=>{const g=l.trim();if(!g)return[];o(!0),r(null);try{const h=(await bKo(g,20)).map(d=>({source:"kicad",footprint:DKo(d)}));return e(h),h}catch(u){return console.error("Error searching KiCad footprints",u),e([]),r(u instanceof Error?u.message:"Failed to search KiCad footprints"),[]}finally{o(!1),s(!0)}},[]),c=X.useCallback(()=>{e([]),o(!1),r(null),s(!1)},[]);return{results:t,isSearching:n,error:i,hasSearched:A,search:a,reset:c}},WKo=({onTscircuitPackageSelected:t,onJlcpcbComponentTsxLoaded:e,onKicadStringSelected:n})=>{const o=[];return t&&o.push("tscircuit.com"),e&&o.push("jlcpcb"),n&&o.push("kicad"),o},jKo=({isOpen:t,onClose:e,jlcpcbProxyRequestHeaders:n,onKicadStringSelected:o,onTscircuitPackageSelected:i,onJlcpcbComponentTsxLoaded:r,jlcpcbProxyApiBase:A,tscircuitSessionToken:s})=>{Mie();const a=X.useMemo(()=>WKo({onKicadStringSelected:o,onTscircuitPackageSelected:i,onJlcpcbComponentTsxLoaded:r}),[o,i,r]),c=a.length>0,l=a.length===1,[g,u]=X.useState(a[0]??"tscircuit.com"),[h,d]=X.useState(""),[_,m]=X.useState(null),{results:p,isSearching:C,error:I,hasSearched:f,search:y,reset:x}=YKo({sessionToken:s}),{results:B,isSearching:S,error:D,hasSearched:w,search:F,reset:R}=JKo(),{results:H,isSearching:G,error:K,hasSearched:J,search:W,reset:j}=qKo(),{details:se,isLoading:Ae,fetchDetails:ee,reset:oe}=OKo(),[ae,ie]=X.useState(null),[le,fe]=X.useState(!1),[xe,Qe]=X.useState("pcb"),[he,be]=X.useState(null),[me,Ke]=X.useState(!1),Je=X.useMemo(()=>({jlcpcb:{headers:n,apiBase:A}}),[A,n]),{circuitJson:et,error:Ce,isLoading:Ze}=KKo(_,Je),Oe=aTt(_);X.useEffect(()=>{be(null)},[_]);const Ye=X.useCallback(()=>{x(),R(),j(),m(null)},[R,j,x]);X.useEffect(()=>{t||(Ye(),d(""),fe(!1),ie(null),be(null))},[t,Ye]),X.useEffect(()=>{d(""),m(null),g==="tscircuit.com"?x():g==="jlcpcb"?R():g==="kicad"&&j()},[g,R,j,x]);const qe=gt=>{m(gt),ie(gt),Qe("pcb"),fe(!0),oe();const Ct=gt.package.org_owner_tscircuit_handle,Dt=gt.package.unscoped_name;if(Ct&&Dt){const mt=Dt.split("/").pop()??Dt;ee(Ct,mt)}},He=async()=>{h.trim()&&(m(null),g==="tscircuit.com"?await y(h):g==="jlcpcb"?await F(h):g==="kicad"&&await W(h))},Pe=async gt=>{try{if(be(null),Ke(!0),gt.source==="kicad"){if(!o)throw new Error("KiCad handler not provided");await o({result:gt,footprint:gt.footprint.qualifiedName})}else if(gt.source==="jlcpcb"){if(!r)throw new Error("JLCPCB handler not provided");const Ct=await LOo(gt.component.partNumber,{headers:n,apiBase:A});await r({result:gt,tsx:Ct})}else if(gt.source==="tscircuit.com"){if(!i)throw new Error("tscircuit package handler not provided");const Ct=gt.package.org_owner_tscircuit_handle,Dt=gt.package.unscoped_name;if(!Ct||!Dt)throw new Error("Missing package metadata");const mt=Dt.split("/").pop()??Dt,Nt=`@tsci/${Ct}.${mt}`;await i({result:gt,fullPackageName:Nt})}return!0}catch(Ct){return console.error("Failed to import component",Ct),be(Ct instanceof Error?Ct.message:"Failed to import component"),!1}finally{Ke(!1)}};let ve=[],De=!1,ze=null,Xe=!1;g==="tscircuit.com"?(ve=p,De=C,ze=I,Xe=f):g==="jlcpcb"?(ve=B,De=S,ze=D,Xe=w):g==="kicad"&&(ve=H,De=G,ze=K,Xe=J);const st=async()=>{if(!_)return;await Pe(_)&&(e(),Ye(),d(""))},ct=gt=>{gt||e()},ut=gt=>{fe(gt),gt||ie(null)};return V.jsxs(MT,{open:t,onOpenChange:ct,children:[V.jsxs(e6,{style:{width:"calc(100vw - 2rem)",maxWidth:Oe?"min(1120px, calc(100vw - 2rem))":"min(672px, calc(100vw - 2rem))",zIndex:lTt.importComponentDialog},className:"rf-rounded-sm rf-max-h-[90vh] rf-overflow-y-auto rf-overflow-x-hidden rf-flex rf-flex-col",children:[V.jsxs(t6,{children:[V.jsxs(n6,{className:"rf-text-lg sm:rf-text-xl",children:["Import ",l?Rie[g].label:""," ","Component"]}),V.jsx(wT,{className:"rf-text-sm",children:c?"Search for components from available sources.":"Import options are disabled because no handlers were provided."})]}),c?V.jsxs(j1e,{value:g,onValueChange:gt=>u(gt),className:"rf-min-w-0 rf-w-full",children:[!l&&V.jsx(YZ,{className:"rf-flex rf-w-full rf-gap-2",children:a.map(gt=>V.jsx($Q,{value:gt,className:"rf-flex-1 rf-text-xs sm:rf-text-sm",children:Rie[gt].label},gt))}),V.jsxs("div",{className:"rf-min-w-0",style:Oe?{display:"grid",gridTemplateColumns:"minmax(0, 1fr) minmax(360px, 0.95fr)",gap:"1.5rem",alignItems:"start"}:void 0,children:[V.jsxs("div",{className:"rf-min-w-0",children:[V.jsx(vKo,{query:h,placeholder:Rie[g].placeholder,isSearching:De,onQueryChange:d,onSubmit:He}),V.jsx("div",{className:"no-scrollbar rf-mt-4 rf-flex-1 rf-min-h-[200px] !rf-max-h-[40vh] !rf-overflow-y-auto rf-overflow-x-hidden rf-border rf-rounded-md rf-min-w-0",children:De?V.jsxs("div",{className:"rf-p-8 rf-text-center rf-text-zinc-500",children:[V.jsx(SB,{className:"rf-h-8 rf-w-8 rf-animate-spin rf-mx-auto rf-mb-2"}),V.jsx("p",{children:"Searching..."})]}):ve.length>0?V.jsx(LKo,{results:ve,selected:_,onSelect:m,onShowDetails:g==="tscircuit.com"?qe:void 0}):V.jsx("div",{className:"rf-p-8 rf-text-center rf-text-zinc-500",children:ze?`Error: ${ze}`:Xe?Rie[g].emptyMessage:"Enter a search term to find components"})})]}),Oe?V.jsx("div",{className:"rf-mt-4",children:V.jsx(HKo,{circuitJson:et,error:Ce,isLoading:Ze,height:325})}):null]})]}):null,he?V.jsx("div",{className:"rf-text-sm rf-text-red-600 rf-mt-2",children:he}):null,V.jsxs(iU,{className:"rf-flex rf-flex-col sm:rf-flex-row rf-gap-2",children:[V.jsx(ta,{variant:"outline",onClick:e,className:"rf-order-2 sm:rf-order-1",children:"Cancel"}),V.jsx(ta,{onClick:st,disabled:!_||me,className:"rf-order-1 sm:rf-order-2",children:me?V.jsx(SB,{className:"rf-h-4 rf-w-4 rf-animate-spin"}):"Import"})]})]}),V.jsx(GKo,{packageResult:ae,isOpen:le,onOpenChange:ut,isLoading:Ae,details:se,previewTab:xe,onPreviewTabChange:gt=>Qe(gt),isSubmitting:me,onImport:()=>{ae&&Pe(ae).then(gt=>{gt&&(fe(!1),e(),Ye(),d(""))})}})]})},XKo=t=>{const e=t.match(/export const (\w+) =/);if(!e)throw new Error("Could not determine component name from TSX contents");return e[1]},uTt=t=>{const e=zu(A=>A.pushEvent),n=zu(A=>A.upsertFile),o=async({result:A,fullPackageName:s})=>{const c=A.package.unscoped_name??A.package.name;await zA.promise(e({event_type:"INSTALL_PACKAGE",full_package_name:s}),{loading:`Requesting install for "${c}"`,success:`Install requested for "${c}"`,error:l=>`Failed to request install: ${l instanceof Error?l.message:String(l)}`})},i=async({footprint:A})=>{await zA.promise(navigator.clipboard.writeText(A),{loading:`Copying "${A}"`,success:`Copied "${A}" to clipboard`,error:s=>`Failed to copy footprint: ${s instanceof Error?s.message:String(s)}`})},r=async({result:A,tsx:s})=>{const c=`imports/${XKo(s)}.tsx`;await zA.promise(n(c,s),{loading:`Importing ${A.component.partNumber}`,success:`Imported to "${c}"`,error:l=>`Failed to import component: ${l instanceof Error?l.message:String(l)}`})};return V.jsx(jKo,{...t,onTscircuitPackageSelected:o,onKicadStringSelected:i,onJlcpcbComponentTsxLoaded:r})};uTt.displayName="ImportComponentDialogForCli";var n6e={exports:{}},dTt;function $Ko(){return dTt||(dTt=1,(function(t,e){var n={env:{},version:""};(function(o){t.exports=o()})(function(){return(function o(i,r,A){function s(l,g){if(!r[l]){if(!i[l]){var u=typeof H4=="function"&&H4;if(!g&&u)return u(l,!0);if(a)return a(l,!0);var h=new Error("Cannot find module '"+l+"'");throw h.code="MODULE_NOT_FOUND",h}var d=r[l]={exports:{}};i[l][0].call(d.exports,function(_){var m=i[l][1][_];return s(m||_)},d,d.exports,o,i,r,A)}return r[l].exports}for(var a=typeof H4=="function"&&H4,c=0;c<A.length;c++)s(A[c]);return s})({1:[function(o,i,r){var A=o("./utils"),s=o("./support"),a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";r.encode=function(c){for(var l,g,u,h,d,_,m,p=[],C=0,I=c.length,f=I,y=A.getTypeOf(c)!=="string";C<c.length;)f=I-C,u=y?(l=c[C++],g=C<I?c[C++]:0,C<I?c[C++]:0):(l=c.charCodeAt(C++),g=C<I?c.charCodeAt(C++):0,C<I?c.charCodeAt(C++):0),h=l>>2,d=(3&l)<<4|g>>4,_=1<f?(15&g)<<2|u>>6:64,m=2<f?63&u:64,p.push(a.charAt(h)+a.charAt(d)+a.charAt(_)+a.charAt(m));return p.join("")},r.decode=function(c){var l,g,u,h,d,_,m=0,p=0,C="data:";if(c.substr(0,C.length)===C)throw new Error("Invalid base64 input, it looks like a data url.");var I,f=3*(c=c.replace(/[^A-Za-z0-9+/=]/g,"")).length/4;if(c.charAt(c.length-1)===a.charAt(64)&&f--,c.charAt(c.length-2)===a.charAt(64)&&f--,f%1!=0)throw new Error("Invalid base64 input, bad content length.");for(I=s.uint8array?new Uint8Array(0|f):new Array(0|f);m<c.length;)l=a.indexOf(c.charAt(m++))<<2|(h=a.indexOf(c.charAt(m++)))>>4,g=(15&h)<<4|(d=a.indexOf(c.charAt(m++)))>>2,u=(3&d)<<6|(_=a.indexOf(c.charAt(m++))),I[p++]=l,d!==64&&(I[p++]=g),_!==64&&(I[p++]=u);return I}},{"./support":30,"./utils":32}],2:[function(o,i,r){var A=o("./external"),s=o("./stream/DataWorker"),a=o("./stream/Crc32Probe"),c=o("./stream/DataLengthProbe");function l(g,u,h,d,_){this.compressedSize=g,this.uncompressedSize=u,this.crc32=h,this.compression=d,this.compressedContent=_}l.prototype={getContentWorker:function(){var g=new s(A.Promise.resolve(this.compressedContent)).pipe(this.compression.uncompressWorker()).pipe(new c("data_length")),u=this;return g.on("end",function(){if(this.streamInfo.data_length!==u.uncompressedSize)throw new Error("Bug : uncompressed data size mismatch")}),g},getCompressedWorker:function(){return new s(A.Promise.resolve(this.compressedContent)).withStreamInfo("compressedSize",this.compressedSize).withStreamInfo("uncompressedSize",this.uncompressedSize).withStreamInfo("crc32",this.crc32).withStreamInfo("compression",this.compression)}},l.createWorkerFrom=function(g,u,h){return g.pipe(new a).pipe(new c("uncompressedSize")).pipe(u.compressWorker(h)).pipe(new c("compressedSize")).withStreamInfo("compression",u)},i.exports=l},{"./external":6,"./stream/Crc32Probe":25,"./stream/DataLengthProbe":26,"./stream/DataWorker":27}],3:[function(o,i,r){var A=o("./stream/GenericWorker");r.STORE={magic:"\0\0",compressWorker:function(){return new A("STORE compression")},uncompressWorker:function(){return new A("STORE decompression")}},r.DEFLATE=o("./flate")},{"./flate":7,"./stream/GenericWorker":28}],4:[function(o,i,r){var A=o("./utils"),s=(function(){for(var a,c=[],l=0;l<256;l++){a=l;for(var g=0;g<8;g++)a=1&a?3988292384^a>>>1:a>>>1;c[l]=a}return c})();i.exports=function(a,c){return a!==void 0&&a.length?A.getTypeOf(a)!=="string"?(function(l,g,u,h){var d=s,_=h+u;l^=-1;for(var m=h;m<_;m++)l=l>>>8^d[255&(l^g[m])];return-1^l})(0|c,a,a.length,0):(function(l,g,u,h){var d=s,_=h+u;l^=-1;for(var m=h;m<_;m++)l=l>>>8^d[255&(l^g.charCodeAt(m))];return-1^l})(0|c,a,a.length,0):0}},{"./utils":32}],5:[function(o,i,r){r.base64=!1,r.binary=!1,r.dir=!1,r.createFolders=!0,r.date=null,r.compression=null,r.compressionOptions=null,r.comment=null,r.unixPermissions=null,r.dosPermissions=null},{}],6:[function(o,i,r){var A=null;A=typeof Promise<"u"?Promise:o("lie"),i.exports={Promise:A}},{lie:37}],7:[function(o,i,r){var A=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Uint32Array<"u",s=o("pako"),a=o("./utils"),c=o("./stream/GenericWorker"),l=A?"uint8array":"array";function g(u,h){c.call(this,"FlateWorker/"+u),this._pako=null,this._pakoAction=u,this._pakoOptions=h,this.meta={}}r.magic="\b\0",a.inherits(g,c),g.prototype.processChunk=function(u){this.meta=u.meta,this._pako===null&&this._createPako(),this._pako.push(a.transformTo(l,u.data),!1)},g.prototype.flush=function(){c.prototype.flush.call(this),this._pako===null&&this._createPako(),this._pako.push([],!0)},g.prototype.cleanUp=function(){c.prototype.cleanUp.call(this),this._pako=null},g.prototype._createPako=function(){this._pako=new s[this._pakoAction]({raw:!0,level:this._pakoOptions.level||-1});var u=this;this._pako.onData=function(h){u.push({data:h,meta:u.meta})}},r.compressWorker=function(u){return new g("Deflate",u)},r.uncompressWorker=function(){return new g("Inflate",{})}},{"./stream/GenericWorker":28,"./utils":32,pako:38}],8:[function(o,i,r){function A(d,_){var m,p="";for(m=0;m<_;m++)p+=String.fromCharCode(255&d),d>>>=8;return p}function s(d,_,m,p,C,I){var f,y,x=d.file,B=d.compression,S=I!==l.utf8encode,D=a.transformTo("string",I(x.name)),w=a.transformTo("string",l.utf8encode(x.name)),F=x.comment,R=a.transformTo("string",I(F)),H=a.transformTo("string",l.utf8encode(F)),G=w.length!==x.name.length,K=H.length!==F.length,J="",W="",j="",se=x.dir,Ae=x.date,ee={crc32:0,compressedSize:0,uncompressedSize:0};_&&!m||(ee.crc32=d.crc32,ee.compressedSize=d.compressedSize,ee.uncompressedSize=d.uncompressedSize);var oe=0;_&&(oe|=8),S||!G&&!K||(oe|=2048);var ae=0,ie=0;se&&(ae|=16),C==="UNIX"?(ie=798,ae|=(function(fe,xe){var Qe=fe;return fe||(Qe=xe?16893:33204),(65535&Qe)<<16})(x.unixPermissions,se)):(ie=20,ae|=(function(fe){return 63&(fe||0)})(x.dosPermissions)),f=Ae.getUTCHours(),f<<=6,f|=Ae.getUTCMinutes(),f<<=5,f|=Ae.getUTCSeconds()/2,y=Ae.getUTCFullYear()-1980,y<<=4,y|=Ae.getUTCMonth()+1,y<<=5,y|=Ae.getUTCDate(),G&&(W=A(1,1)+A(g(D),4)+w,J+="up"+A(W.length,2)+W),K&&(j=A(1,1)+A(g(R),4)+H,J+="uc"+A(j.length,2)+j);var le="";return le+=`
|
|
5759
|
+
`,g=new Blob([l],{type:"text/plain"}),u=URL.createObjectURL(g),h=document.createElement("a");h.href=u,h.download=`${c}.test.ts`,h.click(),URL.revokeObjectURL(u)}catch(a){alert(`Error generating test.ts for ${t.constructor.name}: ${a instanceof Error?a.message:String(a)}`)}o(!1)};return V.jsxs("div",{className:`relative ${e}`,ref:i,children:[V.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&&V.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:[V.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:r,children:"Download JSON"}),V.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:A,children:"Download page.tsx"}),V.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:s,children:"Download test.ts"})]})]})},CRt=t=>t.activeSubSolver?[t,...CRt(t.activeSubSolver)]:[t],EGo=({solver:t})=>{const e=CRt(t);return V.jsx("div",{className:"flex gap-1 items-center text-sm pt-1",children:e.map((n,o)=>V.jsxs("div",{className:"flex items-center",children:[o>0&&V.jsx("span",{className:"text-gray-400 mx-1",children:"→"}),V.jsx(yGo,{solver:n})]},n.constructor.name))})},xGo=({solver:t,triggerRender:e,animationSpeed:n=25,onSolverStarted:o,onSolverCompleted:i})=>{const[r,A]=X.useReducer(_=>!_,!1),s=X.useRef(void 0),a=()=>{!t.solved&&!t.failed&&(t.step(),e())},c=()=>{!t.solved&&!t.failed&&(o&&o(t),t.solve(),e(),i&&i(t))},l=()=>{r?(s.current&&(clearInterval(s.current),s.current=void 0),A()):(A(),s.current=setInterval(()=>{if(t.solved||t.failed){s.current&&(clearInterval(s.current),s.current=void 0),A(),e(),i&&t.solved&&i(t);return}t.step(),e()},n))},g=()=>{const _=t;if(_.getCurrentPhase&&!t.solved&&!t.failed){const m=_.getCurrentPhase();for(;_.getCurrentPhase()===m&&!t.solved&&!t.failed;)t.step();e()}},u=()=>{if(t.solved||t.failed||r)return;const _=window.prompt("Step until which iteration?",`${t.iterations}`);if(_===null)return;const m=Number(_);if(!Number.isFinite(m)){window.alert("Please enter a valid number for the iteration");return}for(;t.iterations<m&&!t.solved&&!t.failed;)t.step();e(),t.solved&&i&&i(t)};X.useEffect(()=>()=>{s.current&&clearInterval(s.current)},[]),X.useEffect(()=>{(t.solved||t.failed)&&r&&(s.current&&(clearInterval(s.current),s.current=void 0),A())},[t.solved,t.failed,r]);const h=t.getCurrentPhase!==void 0,d=h?t.getCurrentPhase():null;return V.jsxs("div",{className:"space-y-2 p-2 border-b",children:[V.jsx("div",{className:"flex items-center",children:V.jsx(EGo,{solver:t})}),V.jsxs("div",{className:"flex gap-2 items-center flex-wrap",children:[V.jsx("button",{onClick:a,disabled:t.solved||t.failed||r,className:"bg-blue-500 hover:bg-blue-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Step"}),V.jsx("button",{onClick:c,disabled:t.solved||t.failed||r,className:"bg-green-500 hover:bg-green-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Solve"}),V.jsx("button",{onClick:l,disabled:t.solved||t.failed,className:`px-3 py-1 rounded text-white text-sm ${r?"bg-red-500 hover:bg-red-600":"bg-yellow-500 hover:bg-yellow-600"} disabled:bg-gray-300`,children:r?"Stop":"Animate"}),V.jsx("button",{onClick:u,disabled:t.solved||t.failed||r,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"}),h&&V.jsx("button",{onClick:g,disabled:t.solved||t.failed||r,className:"bg-purple-500 hover:bg-purple-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Next Stage"}),V.jsxs("div",{className:"text-sm text-gray-600",children:["Iterations: ",t.iterations]}),t.timeToSolve!==void 0&&V.jsxs("div",{className:"text-sm text-gray-600",children:["Time: ",(t.timeToSolve/1e3).toFixed(3),"s"]}),d&&V.jsxs("div",{className:"text-sm text-gray-600",children:["Phase: ",V.jsx("span",{className:"font-medium",children:d})]}),t.solved&&V.jsx("div",{className:"px-2 py-1 bg-green-100 text-green-800 rounded text-sm",children:"Solved"}),t.failed&&V.jsx("div",{className:"px-2 py-1 bg-red-100 text-red-800 rounded text-sm",children:"Failed"})]}),t.error&&V.jsxs("div",{className:"text-red-600 text-sm",children:["Error: ",t.error]})]})},BGo=(t,e,n)=>{const o=t.currentPipelineStepIndex;return e<o?"Completed":e===o&&t.activeSubSolver?t.activeSubSolver.failed?"Failed":"In Progress":"Not Started"},QGo=(t,e)=>{const o=t.pipelineDef[e].solverName,i=BGo(t,e),r=t[o],A=t.firstIterationOfPhase?.[o]??null,s=t.iterations;let a=0;if(i==="Completed"){const u=t.pipelineDef[e+1],h=u?t.firstIterationOfPhase?.[u.solverName]:void 0;h!==void 0&&A!==null?a=h-A:A!==null&&(a=s-A)}else i==="In Progress"&&A!==null&&(a=s-A);const c=t.timeSpentOnPhase?.[o]??0;let l=0;i==="Completed"?l=1:i==="In Progress"&&r&&(l=r.progress??0);const g=r?.stats??null;return{index:e,name:o,status:i,firstIteration:A,iterations:a,progress:l,timeSpent:c,stats:g&&Object.keys(g).length>0?g:null,solverInstance:r??null}},SGo=({status:t})=>{const e={"Not Started":"text-blue-600","In Progress":"text-yellow-600",Completed:"text-green-600",Failed:"text-red-600"};return V.jsx("span",{className:`font-medium ${e[t]}`,children:t})},bGo=({progress:t})=>{if(t===0)return null;const e=Math.round(t*100);return V.jsxs("div",{className:"flex items-center gap-2",children:[V.jsx("div",{className:"w-20 h-2 bg-gray-200 rounded overflow-hidden",children:V.jsx("div",{className:"h-full bg-blue-500 transition-all duration-200",style:{width:`${e}%`}})}),V.jsxs("span",{className:"text-xs text-gray-500",children:[e,"%"]})]})},DGo=t=>Object.entries(t).map(([e,n])=>`${e}: ${n}`).join(", "),MGo=({stats:t})=>{if(!t||Object.keys(t).length===0)return V.jsx("span",{children:"-"});const e=Object.entries(t),n=DGo(t);return V.jsxs("details",{className:"cursor-pointer",children:[V.jsx("summary",{className:"whitespace-nowrap overflow-hidden text-ellipsis max-w-[200px]",children:n}),V.jsx("div",{className:"mt-1 text-xs",children:e.map(([o,i])=>V.jsxs("div",{children:[o,": ",String(i)]},o))})]})},x3e=t=>{if(t===null||typeof t!="object")return t;if(Array.isArray(t))return t.map(x3e);const e={};for(const[n,o]of Object.entries(t))n.startsWith("_")||(e[n]=x3e(o));return e},wGo=(t,e)=>{try{if(typeof t.getConstructorParams!="function"){alert(`getConstructorParams() is not implemented for ${e}`);return}const n=x3e(t.getConstructorParams()),o=new Blob([JSON.stringify(n,null,2)],{type:"application/json"}),i=URL.createObjectURL(o),r=document.createElement("a");r.href=i,r.download=`${e}_input.json`,r.click(),URL.revokeObjectURL(i)}catch(n){alert(`Error downloading input for ${e}: ${n instanceof Error?n.message:String(n)}`)}},PGo=({solver:t,onStepUntilPhase:e,onDownloadInput:n})=>{const o=t.pipelineDef.map((s,a)=>QGo(t,a)),i=s=>{e?.(s)},r=s=>{s.solverInstance&&(n?n(s.solverInstance,s.name):wGo(s.solverInstance,s.name))},A=s=>`${(s/1e3).toFixed(2)}s`;return V.jsxs("div",{className:"border-t border-gray-200",children:[V.jsx("div",{className:"px-4 py-2 bg-gray-50 border-b border-gray-200",children:V.jsx("h3",{className:"text-sm font-semibold text-gray-700",children:"Pipeline Steps"})}),V.jsx("div",{className:"overflow-x-auto",children:V.jsxs("table",{className:"w-full text-sm",children:[V.jsx("thead",{children:V.jsxs("tr",{className:"bg-gray-50 border-b border-gray-200",children:[V.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Step"}),V.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Status"}),V.jsxs("th",{className:"px-4 py-2 text-center font-semibold text-gray-700",children:["i",V.jsx("sub",{children:"0"})]}),V.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Iterations"}),V.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Progress"}),V.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Time"}),V.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Stats"}),V.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Input"})]})}),V.jsx("tbody",{children:o.map(s=>V.jsxs("tr",{className:`border-b border-gray-100 ${s.status==="In Progress"?"bg-yellow-50":""}`,children:[V.jsx("td",{className:"px-4 py-2",children:V.jsxs("div",{className:"flex items-center gap-2",children:[V.jsx("span",{className:"text-gray-400 w-6",children:String(s.index+1).padStart(2,"0")}),V.jsx("button",{onClick:()=>i(s.name),disabled:s.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 ${s.name} completes`,children:V.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:V.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"})})}),V.jsx("span",{className:"font-medium text-gray-900",children:s.name})]})}),V.jsx("td",{className:"px-4 py-2",children:V.jsx(SGo,{status:s.status})}),V.jsx("td",{className:"px-4 py-2 text-center text-gray-600",children:s.firstIteration!==null?s.firstIteration:""}),V.jsx("td",{className:"px-4 py-2 text-gray-600",children:s.iterations}),V.jsx("td",{className:"px-4 py-2",children:V.jsx(bGo,{progress:s.progress})}),V.jsx("td",{className:"px-4 py-2 text-gray-600",children:A(s.timeSpent)}),V.jsx("td",{className:"px-4 py-2 text-gray-500",children:V.jsx(MGo,{stats:s.stats})}),V.jsx("td",{className:"px-4 py-2",children:s.solverInstance?V.jsxs("button",{onClick:()=>r(s),className:"flex items-center gap-1 text-blue-500 hover:text-blue-700",title:`Download input for ${s.name}`,children:[V.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:V.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"})}),V.jsx("span",{children:"Input"})]}):null})]},s.name))})]})})]})},vGo=class extends $r.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 NGo({graphics:t}){const e=t.points??[],n=t.lines??[],o=t.rects??[],i=t.circles??[],r=t.texts??[];let A=Number.POSITIVE_INFINITY,s=Number.POSITIVE_INFINITY,a=Number.NEGATIVE_INFINITY,c=Number.NEGATIVE_INFINITY;const l=(m,p)=>{typeof m=="number"&&(m<A&&(A=m),m>a&&(a=m)),typeof p=="number"&&(p<s&&(s=p),p>c&&(c=p))};for(const m of e)l(m.x,m.y);for(const m of n){const p=m.points??[];for(const C of p)l(C.x,C.y)}for(const m of o){const p=m.x??0,C=m.y??0,I=m.width??0,f=m.height??0;l(p,C),l(p+I,C+f)}for(const m of i){const p=m.x??0,C=m.y??0,I=m.radius??1;l(p-I,C-I),l(p+I,C+I)}for(const m of r)l(m.x,m.y);(!isFinite(A)||!isFinite(s)||!isFinite(a)||!isFinite(c))&&(A=-20,s=-20,a=20,c=20);const g=10,u=A-g,h=s-g,d=Math.max(1,a-A+2*g),_=Math.max(1,c-s+2*g);return V.jsxs("svg",{className:"w-full h-[400px] bg-white",viewBox:`${u} ${h} ${d} ${_}`,role:"img","aria-label":"Graphics fallback",children:[o.map((m,p)=>V.jsx("rect",{x:m.x??0,y:m.y??0,width:m.width??0,height:m.height??0,fill:"none",stroke:m.strokeColor??"black",strokeWidth:m.strokeWidth??1},`rect-${p}`)),n.map((m,p)=>V.jsx("polyline",{fill:"none",stroke:m.strokeColor??"black",strokeWidth:m.strokeWidth??1,points:(m.points??[]).map(C=>`${C.x??0},${C.y??0}`).join(" ")},`line-${p}`)),i.map((m,p)=>V.jsx("circle",{cx:m.x??0,cy:m.y??0,r:m.radius??1.5,fill:m.fillColor??"none",stroke:m.strokeColor??"black",strokeWidth:m.strokeWidth??1},`circle-${p}`)),e.map((m,p)=>V.jsx("circle",{cx:m.x??0,cy:m.y??0,r:m.radius??1.5,fill:m.color??"black"},`point-${p}`)),r.map((m,p)=>V.jsx("text",{x:m.x??0,y:m.y??0,fontSize:m.fontSize??10,fill:m.color??"black",children:m.text??""},`text-${p}`))]})}var RGo=({solver:t,animationSpeed:e=25,onSolverStarted:n,onSolverCompleted:o})=>{const[i,r]=X.useReducer(l=>l+1,0),A=X.useMemo(()=>{try{return t.visualize()||{points:[],lines:[],rects:[],circles:[]}}catch(l){return console.error("Visualization error:",l),{points:[],lines:[],rects:[],circles:[]}}},[t,i]),s=X.useMemo(()=>(A.rects?.length||0)===0&&(A.lines?.length||0)===0&&(A.points?.length||0)===0&&(A.circles?.length||0)===0,[A]);X.useEffect(()=>{if(!(typeof document>"u")&&!document.querySelector('script[src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4"]')){const l=document.createElement("script");l.src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4",document.head.appendChild(l)}},[]);const a=t.pipelineDef!==void 0,c=l=>{const g=t;if(!t.solved&&!t.failed){for(;!t.solved&&!t.failed&&g.currentPipelineStepIndex<=g.pipelineDef.findIndex(u=>u.solverName===l);)t.step();r()}};return V.jsxs("div",{children:[V.jsx(xGo,{solver:t,triggerRender:r,animationSpeed:e,onSolverStarted:n,onSolverCompleted:o}),s?V.jsx("div",{className:"p-4 text-gray-500",children:"No Graphics Yet"}):V.jsx(vGo,{fallback:V.jsx(NGo,{graphics:A}),children:V.jsx(fGo,{graphics:A})}),a&&V.jsx(PGo,{solver:t,onStepUntilPhase:c})]})};const TGo=()=>{X.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)},[])},kGo=1e3,wS=(t,e)=>{const{fileName:n,mimeType:o="text/plain"}=e,i=t instanceof Blob?t:new Blob([t],{type:o}),r=URL.createObjectURL(i),A=document.createElement("a");A.href=r,A.download=n,A.target="_blank",A.rel="noopener noreferrer",A.style.display="none",document.body.appendChild(A),A.click(),document.body.removeChild(A),setTimeout(()=>{URL.revokeObjectURL(r)},kGo)},fRt=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"},PS="https://github.com/tscircuit/tscircuit-autorouter/issues/new",yRt="https://github.com/tscircuit/copper-pour-solver/issues/new",ERt="https://github.com/tscircuit/calculate-packing/issues/new",xRt="https://github.com/tscircuit/schematic-trace-solver/issues/new?template=json-bug-report.yml",FGo={PackSolver2:ERt,AutoroutingPipelineSolver:PS,AssignableAutoroutingPipeline2:PS,AssignableAutoroutingPipeline3:PS,AutoroutingPipeline1_OriginalUnravel:PS,AutoroutingPipelineSolver3_HgPortPointPathing:PS,AutoroutingPipelineSolver4:PS,AutoroutingPipelineSolver5:PS,AutoroutingPipelineSolver7_MultiGraph:PS,AutoroutingPipelineSolver8:PS,CopperPourPipelineSolver:yRt,SchematicTracePipelineSolver:xRt},LGo=t=>t.toLowerCase().includes("pack")?Qvo:t.toLowerCase().includes("rout")?Pvo:uvo,BRt=t=>{const e=FGo[t];if(e)return e;const n=t.toLowerCase();return n.includes("autorout")?PS:n.includes("schematic")&&n.includes("trace")?xRt:n.includes("copperpour")?yRt:n.includes("pack")?ERt:null},HGo=t=>`${fRt(`${t.componentName}-${t.solverName}`)}-solver-input.json`,QRt=t=>{wS(JSON.stringify(t.solverParams,null,2),{fileName:HGo(t),mimeType:"application/json"})},GGo=({solverEvent:t})=>{const e=BRt(t.solverName);return V.jsxs("div",{className:"rf-flex rf-items-center rf-justify-end rf-gap-2 rf-border-b rf-border-gray-200 rf-bg-gray-50 rf-px-4 rf-py-2",children:[V.jsxs(ta,{type:"button",variant:"outline",size:"sm",onClick:()=>QRt(t),children:[V.jsx(rPe,{className:"rf-w-4 rf-h-4"}),"Download"]}),e?V.jsx(ta,{asChild:!0,variant:"outline",size:"sm",children:V.jsxs("a",{href:e,target:"_blank",rel:"noopener noreferrer",children:[V.jsx(coe,{className:"rf-w-4 rf-h-4"}),"Report"]})}):V.jsxs(ta,{type:"button",variant:"outline",size:"sm",disabled:!0,title:"No report link configured for this solver",children:[V.jsx(coe,{className:"rf-w-4 rf-h-4"}),"Report"]})]})},OGo=({solverEvent:t})=>{const e=BRt(t.solverName);return e?V.jsx(ta,{asChild:!0,variant:"ghost",size:"icon",className:"rf-h-8 rf-w-8",children:V.jsx("a",{href:e,target:"_blank",rel:"noopener noreferrer",title:"Report solver bug","aria-label":"Report solver bug",children:V.jsx(coe,{className:"rf-w-4 rf-h-4"})})}):V.jsx(ta,{type:"button",variant:"ghost",size:"icon",className:"rf-h-8 rf-w-8",disabled:!0,title:"No report link configured for this solver","aria-label":"Report solver bug",children:V.jsx(coe,{className:"rf-w-4 rf-h-4"})})},KGo=({solverEvents:t=[]})=>{const[e,n]=X.useState(null);TGo();const o=X.useMemo(()=>{const s=new Map;for(const a of t){const c=`${a.componentName}-${a.solverName}`;s.set(c,a)}return s},[t]),i=X.useMemo(()=>Array.from(o.keys()),[o]),r=e?o.get(e):null,A=X.useMemo(()=>{if(!r)return{instance:null,error:null,classFound:!1};const s=hCe[r.solverName];if(!s)return{instance:null,error:`Solver class "${r.solverName}" not found in SOLVERS registry. Available: ${Object.keys(hCe).join(", ")}`,classFound:!1};try{const a=r.solverParams,c=a?.input!==void 0?a.input:a;return{instance:new s(c),error:null,classFound:!0}}catch(a){const c=a instanceof Error?a.message:String(a);return console.error("Failed to reconstruct solver:",a),{instance:null,error:`Failed to instantiate solver: ${c}`,classFound:!0}}},[r]);return t.length===0?V.jsx("div",{className:"rf-p-4",children:V.jsx("div",{className:"rf-bg-gray-50 rf-rounded-md rf-border rf-border-gray-200",children:V.jsxs("div",{className:"rf-p-4",children:[V.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800 rf-mb-3",children:"No Solvers Detected"}),V.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."})]})})}):V.jsxs("div",{className:"rf-flex rf-h-full rf-overflow-hidden",children:[V.jsxs("div",{className:"rf-w-64 rf-border-r rf-border-gray-200 rf-overflow-y-auto rf-flex-shrink-0",children:[V.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:[i.length," ",i.length===1?"Solver":"Solvers"]}),i.map(s=>{const a=o.get(s),c=e===s;return V.jsx("div",{className:`rf-px-3 rf-py-2 rf-cursor-pointer rf-border-b rf-border-gray-100 ${c?"rf-bg-blue-50 rf-border-l-2 rf-border-l-blue-500":"hover:rf-bg-gray-50"}`,onClick:()=>n(s),children:(()=>{const l=LGo(a.solverName);return V.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2",children:[V.jsx(l,{className:"rf-w-4 rf-h-4 rf-text-blue-500 rf-flex-shrink-0"}),V.jsxs("div",{className:"rf-flex-1 rf-min-w-0",children:[V.jsx("div",{className:"rf-text-sm rf-font-medium rf-text-gray-800 rf-truncate",children:a.componentName}),V.jsx("div",{className:"rf-text-xs rf-text-gray-500 rf-truncate",children:a.solverName})]})]})})()},s)})]}),V.jsx("div",{className:"rf-flex-1 rf-overflow-hidden",children:r?A.instance?V.jsxs("div",{className:"rf-flex rf-h-full rf-flex-col rf-overflow-y-auto",children:[V.jsx(GGo,{solverEvent:r}),V.jsx("div",{className:"rf-min-h-0 rf-flex-1",children:V.jsx(dx,{fallback:V.jsx("div",{className:"rf-p-4",children:V.jsxs("div",{className:"rf-bg-red-50 rf-rounded-md rf-border rf-border-red-200 rf-p-4",children:[V.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-red-800 rf-mb-2",children:"Error Loading Solver Debugger"}),V.jsxs("p",{className:"rf-text-sm rf-text-red-600",children:["Failed to render the solver debugger for"," ",r.solverName]})]})}),children:V.jsx(RGo,{solver:A.instance})})})]}):V.jsxs("div",{className:"rf-p-4",children:[V.jsxs("div",{className:"rf-mb-4",children:[V.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800",children:r.solverName}),V.jsxs("p",{className:"rf-text-sm rf-text-gray-500",children:["Component: ",r.componentName]})]}),A.error&&V.jsx("div",{className:`rf-rounded-md rf-border rf-p-4 rf-mb-4 ${A.classFound?"rf-bg-red-50 rf-border-red-200":"rf-bg-yellow-50 rf-border-yellow-200"}`,children:V.jsx("p",{className:`rf-text-sm ${A.classFound?"rf-text-red-700":"rf-text-yellow-700"}`,children:A.error})}),V.jsxs("div",{className:"rf-border rf-border-gray-200 rf-rounded-md rf-overflow-hidden",children:[V.jsxs("div",{className:"rf-px-3 rf-py-2 rf-bg-gray-50 rf-flex rf-items-center rf-justify-between rf-gap-2",children:[V.jsx("span",{className:"rf-text-sm rf-font-medium rf-text-gray-700",children:"Solver Parameters"}),V.jsxs("div",{className:"rf-flex rf-items-center rf-gap-1",children:[V.jsx(OGo,{solverEvent:r}),V.jsx(ta,{type:"button",variant:"ghost",size:"icon",className:"rf-h-8 rf-w-8","aria-label":"Download solver input JSON",title:"Download solver input JSON",onClick:()=>QRt(r),children:V.jsx(rPe,{className:"rf-w-4 rf-h-4"})})]})]}),V.jsx("div",{className:"rf-p-3 rf-bg-white rf-border-t rf-border-gray-200",children:V.jsx("pre",{className:"rf-text-xs rf-font-mono rf-text-gray-600 rf-whitespace-pre-wrap rf-overflow-x-auto",children:JSON.stringify(r.solverParams,null,2)})})]})]}):V.jsx("div",{className:"rf-flex rf-items-center rf-justify-center rf-h-full",children:V.jsx("p",{className:"rf-text-sm rf-text-gray-500",children:"Select a solver from the list to view details"})})})]})},SRt=({errorMessage:t,errorStack:e,circuitJsonErrors:n})=>{X.useEffect(()=>{if(t){const o=new Error(t);e&&(o.stack=e);try{IN.captureException(o)}catch{}}},[t,e]),X.useEffect(()=>{if(n&&n.length>0)for(const o of n){const i=new Error(o.message||"Circuit JSON Error");o.stack&&(i.stack=o.stack);try{IN.captureException(i,{error_type:o.type})}catch{}}},[n])},bRt=t=>{X.useEffect(()=>{try{lVn(t)}catch{}},[t.source,t.component,t.isWebEmbedded,t.activeTab])},DRt="0.0.2373",UGo={version:DRt},wie=nut()(out(t=>({lastRunEvalVersion:void 0,setLastRunEvalVersion:e=>{t({lastRunEvalVersion:e})}}),{name:"runframe-runner-store"})),YGo=t=>{const[e,n]=X.useState([]),[o,i]=X.useState(null),[r,A]=X.useState(""),[s,a]=q7("eval-version-selection",null),c=wie(h=>h.setLastRunEvalVersion),l=wie(h=>h.lastRunEvalVersion);return X.useEffect(()=>{t&&fetch("https://data.jsdelivr.com/v1/package/npm/@tscircuit/eval").then(h=>h.json()).then(h=>{if(Array.isArray(h?.versions)){let d=[...h.versions];h.tags?.latest&&(i(h.tags.latest),d=d.filter(_=>_!==h.tags.latest)),n(d)}}).catch(()=>{})},[t]),X.useEffect(()=>{t&&(s?(window.TSCIRCUIT_LATEST_EVAL_VERSION=s,c(s)):o&&(window.TSCIRCUIT_LATEST_EVAL_VERSION=o,c(o)))},[t,s,o]),{versions:X.useMemo(()=>e.filter(h=>h.includes(r)).slice(0,50),[e,r]),latestVersion:o,lastRunEvalVersion:l,search:r,setSearch:A,selectVersion:h=>{a(h),A("")}}},zGo=({snippetNames:t,onSelect:e,onCancel:n,isOpen:o})=>{const[i,r]=X.useState(""),[A,s]=X.useState("");if(!o)return null;const a=t.filter(g=>g.toLowerCase().includes(A.toLowerCase())),c=A&&!t.includes(A),l=g=>{g.key==="Enter"&&(a.length===1?r(a[0]):c&&r(A))};return V.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:V.jsxs("div",{className:"rf-bg-white rf-rounded-lg rf-p-6 rf-w-96",children:[V.jsx("h2",{className:"rf-text-lg rf-font-semibold rf-mb-4",children:"Select Snippet"}),V.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:A,onChange:g=>s(g.target.value),onKeyDown:l}),V.jsxs("div",{className:"rf-h-60 rf-overflow-y-auto",children:[a.map(g=>V.jsx("button",{type:"button",className:`w-full text-left px-4 py-2 rounded hover:bg-gray-100 ${i===g?"bg-blue-50":""}`,onClick:()=>r(g),children:g},g)),c&&V.jsxs("button",{type:"button",className:`w-full text-left px-4 py-2 rounded hover:bg-gray-100 text-blue-500 ${i===A?"bg-blue-50":""}`,onClick:()=>r(A),children:['Create new "',A,'"']})]}),V.jsxs("div",{className:"rf-mt-4 rf-flex rf-justify-end rf-gap-2",children:[V.jsx("button",{type:"button",className:"rf-px-4 rf-py-2 rf-text-gray-600 rf-hover:text-gray-800",onClick:n,children:"Cancel"}),V.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:()=>i&&e(i),disabled:!i,children:i===A?`Create "${i}"`:`Save to ${i}`})]})]})})},VGo=t=>{const e=X.useRef(null),n=zu(o=>o.recentEvents);X.useEffect(()=>{if(n.length===0)return;const o=n[0];o.event_id!==e.current&&(t(o),e.current=o.event_id)},[n,t])};var JGo=Object.defineProperty,z2=(t,e)=>JGo(t,"name",{value:e,configurable:!0}),B3e="Dialog",[MRt,wRt]=x2(B3e),[qGo,vB]=MRt(B3e),Q3e=z2(t=>{const{__scopeDialog:e,children:n,open:o,defaultOpen:i,onOpenChange:r,modal:A=!0}=t,s=X.useRef(null),a=X.useRef(null),[c,l]=Vb({prop:o,defaultProp:i??!1,onChange:r,caller:B3e}),[g,u]=X.useState(0),[h,d]=X.useState(0);return V.jsx(qGo,{scope:e,triggerRef:s,contentRef:a,contentId:Am(),titleId:Am(),descriptionId:Am(),titlePresent:g>0,descriptionPresent:h>0,setTitleCount:u,setDescriptionCount:d,open:c,onOpenChange:l,onOpenToggle:X.useCallback(()=>l(_=>!_),[l]),modal:A,children:n})},"Dialog"),WGo="DialogTrigger",jGo=X.forwardRef(z2(function(e,n){const{__scopeDialog:o,...i}=e,r=vB(WGo,o),A=dl(n,r.triggerRef);return V.jsx(Oa.button,{type:"button","aria-haspopup":"dialog","aria-expanded":r.open,"aria-controls":r.open?r.contentId:void 0,"data-state":Nie(r.open),...i,ref:A,onClick:vr(e.onClick,r.onOpenToggle)})},"DialogTrigger")),PRt="DialogPortal",[XGo,vRt]=MRt(PRt,{forceMount:void 0}),S3e=z2(t=>{const{__scopeDialog:e,forceMount:n,children:o,container:i}=t,r=vB(PRt,e);return V.jsx(XGo,{scope:e,forceMount:n,children:X.Children.map(o,A=>V.jsx(ZE,{present:n||r.open,children:V.jsx(vPe,{asChild:!0,container:i,children:A})}))})},"DialogPortal"),b3e="DialogOverlay",Pie=X.forwardRef(z2(function(e,n){const o=vRt(b3e,e.__scopeDialog),{forceMount:i=o.forceMount,...r}=e,A=vB(b3e,e.__scopeDialog);return A.modal?V.jsx(ZE,{present:i||A.open,children:V.jsx(ZGo,{...r,ref:n})}):null},"DialogOverlay")),$Go=qQ("DialogOverlay.RemoveScroll"),ZGo=X.forwardRef(z2(function(e,n){const{__scopeDialog:o,...i}=e,r=vB(b3e,o),A=ZPt(),s=dl(n,A);return V.jsx(voe,{as:$Go,allowPinchZoom:!0,shards:[r.contentRef],children:V.jsx(Oa.div,{"data-state":Nie(r.open),...i,ref:s,style:{pointerEvents:"auto",...i.style}})})},"DialogOverlayImpl")),nU="DialogContent",vie=X.forwardRef(z2(function(e,n){const o=vRt(nU,e.__scopeDialog),{forceMount:i=o.forceMount,...r}=e,A=vB(nU,e.__scopeDialog);return V.jsx(ZE,{present:i||A.open,children:A.modal?V.jsx(eOo,{...r,ref:n}):V.jsx(tOo,{...r,ref:n})})},"DialogContent")),eOo=X.forwardRef(z2(function(e,n){const o=vB(nU,e.__scopeDialog),i=X.useRef(null),r=dl(n,o.contentRef,i);return X.useEffect(()=>{const A=i.current;if(A)return RPe(A)},[]),V.jsx(NRt,{...e,ref:r,trapFocus:o.open,disableOutsidePointerEvents:o.open,onCloseAutoFocus:vr(e.onCloseAutoFocus,A=>{A.preventDefault(),o.triggerRef.current?.focus()}),onPointerDownOutside:vr(e.onPointerDownOutside,A=>{const s=A.detail.originalEvent,a=s.button===0&&s.ctrlKey===!0;(s.button===2||a)&&A.preventDefault()}),onFocusOutside:vr(e.onFocusOutside,A=>A.preventDefault())})},"DialogContentModal")),tOo=X.forwardRef(z2(function(e,n){const o=vB(nU,e.__scopeDialog),i=X.useRef(!1),r=X.useRef(!1);return V.jsx(NRt,{...e,ref:n,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:A=>{e.onCloseAutoFocus?.(A),A.defaultPrevented||(i.current||o.triggerRef.current?.focus(),A.preventDefault()),i.current=!1,r.current=!1},onInteractOutside:A=>{e.onInteractOutside?.(A),A.defaultPrevented||(i.current=!0,A.detail.originalEvent.type==="pointerdown"&&(r.current=!0));const s=A.target;o.triggerRef.current?.contains(s)&&A.preventDefault(),A.detail.originalEvent.type==="focusin"&&r.current&&A.preventDefault()}})},"DialogContentNonModal")),NRt=X.forwardRef(z2(function(e,n){const{__scopeDialog:o,trapFocus:i,onOpenAutoFocus:r,onCloseAutoFocus:A,...s}=e,a=vB(nU,o);return DK(),V.jsx(V.Fragment,{children:V.jsx(hPe,{asChild:!0,loop:!0,trapped:i,onMountAutoFocus:r,onUnmountAutoFocus:A,children:V.jsx(loe,{role:"dialog",id:a.contentId,"aria-describedby":a.descriptionPresent?a.descriptionId:void 0,"aria-labelledby":a.titlePresent?a.titleId:void 0,"data-state":Nie(a.open),...s,ref:n,deferPointerDownOutside:!0,onDismiss:()=>a.onOpenChange(!1)})})})},"DialogContentImpl")),nOo="DialogTitle",D3e=X.forwardRef(z2(function(e,n){const{__scopeDialog:o,...i}=e,r=vB(nOo,o),{setTitleCount:A}=r;return ty(()=>(A(s=>s+1),()=>A(s=>s-1)),[A]),V.jsx(Oa.h2,{id:r.titleId,...i,ref:n})},"DialogTitle")),oOo="DialogDescription",M3e=X.forwardRef(z2(function(e,n){const{__scopeDialog:o,...i}=e,r=vB(oOo,o),{setDescriptionCount:A}=r;return ty(()=>(A(s=>s+1),()=>A(s=>s-1)),[A]),V.jsx(Oa.p,{id:r.descriptionId,...i,ref:n})},"DialogDescription")),iOo="DialogClose",RRt=X.forwardRef(z2(function(e,n){const{__scopeDialog:o,...i}=e,r=vB(iOo,o);return V.jsx(Oa.button,{type:"button",...i,ref:n,onClick:vr(e.onClick,()=>r.onOpenChange(!1))})},"DialogClose"));function Nie(t){return t?"open":"closed"}z2(Nie,"getState");var rOo=Object.defineProperty,G5=(t,e)=>rOo(t,"name",{value:e,configurable:!0}),AOo="AlertDialog",[sOo,wXo]=x2(AOo,[wRt]),O5=wRt(),aOo=G5(t=>{const{__scopeAlertDialog:e,...n}=t,o=O5(e);return V.jsx(Q3e,{...o,...n,modal:!0})},"AlertDialog");X.forwardRef(G5(function(e,n){const{__scopeAlertDialog:o,...i}=e,r=O5(o);return V.jsx(jGo,{...r,...i,ref:n})},"AlertDialogTrigger"));var cOo=G5(t=>{const{__scopeAlertDialog:e,...n}=t,o=O5(e);return V.jsx(S3e,{...o,...n})},"AlertDialogPortal"),lOo=X.forwardRef(G5(function(e,n){const{__scopeAlertDialog:o,...i}=e,r=O5(o);return V.jsx(Pie,{...r,...i,ref:n})},"AlertDialogOverlay")),gOo="AlertDialogContent",[uOo,dOo]=sOo(gOo),hOo=X.forwardRef(G5(function(e,n){const{__scopeAlertDialog:o,children:i,...r}=e,A=O5(o),s=X.useRef(null),a=dl(n,s),c=X.useRef(null);return V.jsx(uOo,{scope:o,cancelRef:c,children:V.jsx(vie,{role:"alertdialog",...A,...r,ref:a,onOpenAutoFocus:vr(r.onOpenAutoFocus,l=>{l.preventDefault(),c.current?.focus({preventScroll:!0})}),onPointerDownOutside:l=>l.preventDefault(),onInteractOutside:l=>l.preventDefault(),children:i})})},"AlertDialogContent")),_Oo=X.forwardRef(G5(function(e,n){const{__scopeAlertDialog:o,...i}=e,r=O5(o);return V.jsx(D3e,{...r,...i,ref:n})},"AlertDialogTitle")),pOo=X.forwardRef(G5(function(e,n){const{__scopeAlertDialog:o,...i}=e,r=O5(o);return V.jsx(M3e,{...r,...i,ref:n})},"AlertDialogDescription")),mOo=X.forwardRef(G5(function(e,n){const{__scopeAlertDialog:o,...i}=e,r=O5(o);return V.jsx(RRt,{...r,...i,ref:n})},"AlertDialogAction")),IOo="AlertDialogCancel",COo=X.forwardRef(G5(function(e,n){const{__scopeAlertDialog:o,...i}=e,{cancelRef:r}=dOo(IOo,o),A=O5(o),s=dl(n,r);return V.jsx(RRt,{...A,...i,ref:s})},"AlertDialogCancel")),fOo=aOo,yOo=cOo,TRt=lOo,kRt=hOo,FRt=mOo,LRt=COo,HRt=_Oo,GRt=pOo;const ORt=fOo,EOo=yOo,KRt=X.forwardRef(({className:t,...e},n)=>V.jsx(TRt,{className:Wi("rf-fixed rf-inset-0 rf-z-50 rf-bg-black/80 data-[state=open]:rf-animate-in data-[state=closed]:rf-animate-out data-[state=closed]:rf-fade-out-0 data-[state=open]:rf-fade-in-0",t),...e,ref:n}));KRt.displayName=TRt.displayName;const w3e=X.forwardRef(({className:t,...e},n)=>V.jsxs(EOo,{children:[V.jsx(KRt,{}),V.jsx(kRt,{ref:n,className:Wi("rf-fixed rf-left-[50%] rf-top-[50%] rf-z-50 rf-grid rf-w-full rf-max-w-lg rf-translate-x-[-50%] rf-translate-y-[-50%] rf-gap-4 rf-border rf-border-zinc-200 rf-bg-white rf-p-6 rf-shadow-lg rf-duration-200 data-[state=open]:rf-animate-in data-[state=closed]:rf-animate-out data-[state=closed]:rf-fade-out-0 data-[state=open]:rf-fade-in-0 data-[state=closed]:rf-zoom-out-95 data-[state=open]:rf-zoom-in-95 data-[state=closed]:rf-slide-out-to-left-1/2 data-[state=closed]:rf-slide-out-to-top-[48%] data-[state=open]:rf-slide-in-from-left-1/2 data-[state=open]:rf-slide-in-from-top-[48%] sm:rf-rounded-lg dark:rf-border-zinc-800 dark:rf-bg-zinc-950",t),...e})]}));w3e.displayName=kRt.displayName;const P3e=({className:t,...e})=>V.jsx("div",{className:Wi("rf-flex rf-flex-col rf-space-y-2 rf-text-center sm:rf-text-left",t),...e});P3e.displayName="AlertDialogHeader";const v3e=({className:t,...e})=>V.jsx("div",{className:Wi("rf-flex rf-flex-col-reverse sm:rf-flex-row sm:rf-justify-end sm:rf-space-x-2",t),...e});v3e.displayName="AlertDialogFooter";const N3e=X.forwardRef(({className:t,...e},n)=>V.jsx(HRt,{ref:n,className:Wi("rf-text-lg rf-font-semibold",t),...e}));N3e.displayName=HRt.displayName;const R3e=X.forwardRef(({className:t,...e},n)=>V.jsx(GRt,{ref:n,className:Wi("rf-text-sm rf-text-zinc-500 dark:rf-text-zinc-400",t),...e}));R3e.displayName=GRt.displayName;const xOo=X.forwardRef(({className:t,...e},n)=>V.jsx(FRt,{ref:n,className:Wi(iT(),t),...e}));xOo.displayName=FRt.displayName;const T3e=X.forwardRef(({className:t,...e},n)=>V.jsx(LRt,{ref:n,className:Wi(iT({variant:"outline"}),"rf-mt-2 sm:rf-mt-0",t),...e}));T3e.displayName=LRt.displayName;var BOo=Object.defineProperty,K5=(t,e)=>BOo(t,"name",{value:e,configurable:!0}),k3e="Checkbox",[QOo,PXo]=x2(k3e),[SOo,F3e]=QOo(k3e);function URt(t){const{__scopeCheckbox:e,checked:n,children:o,defaultChecked:i,disabled:r,form:A,name:s,onCheckedChange:a,required:c,value:l="on",internal_do_not_use_render:g}=t,[u,h]=Vb({prop:n,defaultProp:i??!1,onChange:a,caller:k3e}),[d,_]=X.useState(null),[m,p]=X.useState(null),C=X.useRef(!1),[I,f]=X.useReducer(B=>B+1,0),y=d?!!A||!!d.closest("form"):!0,x={checked:u,disabled:r,setChecked:h,control:d,setControl:_,name:s,form:A,value:l,hasConsumerStoppedPropagationRef:C,userInteractionCount:I,onUserInteraction:f,required:c,defaultChecked:U5(i)?!1:i,isFormControl:y,bubbleInput:m,setBubbleInput:p};return V.jsx(SOo,{scope:e,...x,children:zRt(g)?g(x):o})}K5(URt,"CheckboxProvider");var bOo="CheckboxTrigger",DOo=X.forwardRef(K5(function({__scopeCheckbox:e,onKeyDown:n,onClick:o,...i},r){const{control:A,value:s,disabled:a,checked:c,required:l,setControl:g,setChecked:u,hasConsumerStoppedPropagationRef:h,onUserInteraction:d,isFormControl:_,bubbleInput:m}=F3e(bOo,e),p=dl(r,g),C=X.useRef(c);return X.useEffect(()=>{const I=A?.form;if(I){const f=K5(()=>u(C.current),"reset");return I.addEventListener("reset",f),()=>I.removeEventListener("reset",f)}},[A,u]),V.jsx(Oa.button,{type:"button",role:"checkbox","aria-checked":U5(c)?"mixed":c,"aria-required":l,"data-state":L3e(c),"data-disabled":a?"":void 0,disabled:a,value:s,...i,ref:p,onKeyDown:vr(n,I=>{I.key==="Enter"&&I.preventDefault()}),onClick:vr(o,I=>{d(),u(f=>U5(f)?!0:!f),m&&_&&(h.current=I.isPropagationStopped(),h.current||I.stopPropagation())})})},"CheckboxTrigger")),YRt=X.forwardRef(K5(function(e,n){const{__scopeCheckbox:o,name:i,checked:r,defaultChecked:A,required:s,disabled:a,value:c,onCheckedChange:l,form:g,...u}=e;return V.jsx(URt,{__scopeCheckbox:o,checked:r,defaultChecked:A,disabled:a,required:s,onCheckedChange:l,name:i,form:g,value:c,internal_do_not_use_render:({isFormControl:h})=>V.jsxs(V.Fragment,{children:[V.jsx(DOo,{...u,ref:n,__scopeCheckbox:o}),h&&V.jsx(vOo,{__scopeCheckbox:o})]})})},"Checkbox")),MOo="CheckboxIndicator",wOo=X.forwardRef(K5(function(e,n){const{__scopeCheckbox:o,forceMount:i,...r}=e,A=F3e(MOo,o);return V.jsx(ZE,{present:i||U5(A.checked)||A.checked===!0,children:V.jsx(Oa.span,{"data-state":L3e(A.checked),"data-disabled":A.disabled?"":void 0,...r,ref:n,style:{pointerEvents:"none",...e.style}})})},"CheckboxIndicator")),POo="CheckboxBubbleInput",vOo=X.forwardRef(K5(function({__scopeCheckbox:e,onClick:n,...o},i){const{control:r,hasConsumerStoppedPropagationRef:A,userInteractionCount:s,checked:a,defaultChecked:c,required:l,disabled:g,name:u,value:h,form:d,bubbleInput:_,setBubbleInput:m}=F3e(POo,e),p=dl(i,m),C=MPe(r),I=X.useRef(!1),f=X.useRef(a),y=X.useRef(s);X.useEffect(()=>{const B=_;if(!B)return;const S=window.HTMLInputElement.prototype,w=Object.getOwnPropertyDescriptor(S,"checked").set,F=s!==y.current;y.current=s;const R=f.current!==a;f.current=a;const H=!(F&&A.current);if(R&&w){I.current=!F;const G=new Event("click",{bubbles:H});B.indeterminate=U5(a),w.call(B,U5(a)?!1:a),B.dispatchEvent(G),I.current=!1}},[_,a,A,s]);const x=X.useRef(U5(a)?!1:a);return V.jsx(Oa.input,{type:"checkbox","aria-hidden":!0,defaultChecked:c??x.current,required:l,disabled:g,name:u,value:h,form:d,...o,tabIndex:-1,ref:p,onClick:vr(n,B=>{I.current&&B.stopPropagation()}),style:{...o.style,...C,position:"absolute",pointerEvents:"none",opacity:0,margin:0,transform:"translateX(-100%)"}})},"CheckboxBubbleInput"));function zRt(t){return typeof t=="function"}K5(zRt,"isFunction");function U5(t){return t==="indeterminate"}K5(U5,"isIndeterminate");function L3e(t){return U5(t)?"indeterminate":t?"checked":"unchecked"}K5(L3e,"getState");const oU=X.forwardRef(({className:t,...e},n)=>V.jsx(YRt,{ref:n,className:Wi("rf-peer rf-h-4 rf-w-4 rf-shrink-0 rf-rounded-sm rf-border rf-border-zinc-200 rf-border-zinc-900 rf-shadow focus-visible:rf-outline-none focus-visible:rf-ring-1 focus-visible:rf-ring-zinc-950 disabled:rf-cursor-not-allowed disabled:rf-opacity-50 data-[state=checked]:rf-bg-zinc-900 data-[state=checked]:rf-text-zinc-50 dark:rf-border-zinc-800 dark:rf-border-zinc-50 dark:focus-visible:rf-ring-zinc-300 dark:data-[state=checked]:rf-bg-zinc-50 dark:data-[state=checked]:rf-text-zinc-900",t),...e,children:V.jsx(wOo,{className:Wi("rf-flex rf-items-center rf-justify-center rf-text-current"),children:V.jsx(K3,{className:"rf-h-4 rf-w-4"})})}));oU.displayName=YRt.displayName;const MT=Q3e,NOo=S3e,VRt=X.forwardRef(({className:t,...e},n)=>V.jsx(Pie,{className:Wi("rf-fixed rf-inset-0 rf-z-50 rf-bg-black/80 data-[state=open]:rf-animate-in data-[state=closed]:rf-animate-out data-[state=closed]:rf-fade-out-0 data-[state=open]:rf-fade-in-0",t),...e,ref:n}));VRt.displayName=Pie.displayName;const e6=X.forwardRef(({className:t,children:e,showOverlay:n=!0,...o},i)=>V.jsxs(NOo,{children:[V.jsx(VRt,{className:Wi(n?"":"rf-hidden")}),V.jsx(vie,{ref:i,className:Wi("rf-fixed rf-left-[50%] rf-top-[50%] rf-z-50 rf-grid rf-w-full rf-max-w-lg rf-translate-x-[-50%] rf-translate-y-[-50%] rf-gap-4 rf-border rf-border-zinc-200 rf-bg-white rf-p-6 rf-shadow-lg rf-duration-200 data-[state=open]:rf-animate-in data-[state=closed]:rf-animate-out data-[state=closed]:rf-fade-out-0 data-[state=open]:rf-fade-in-0 data-[state=closed]:rf-zoom-out-95 data-[state=open]:rf-zoom-in-95 data-[state=closed]:rf-slide-out-to-left-1/2 data-[state=closed]:rf-slide-out-to-top-[48%] data-[state=open]:rf-slide-in-from-left-1/2 data-[state=open]:rf-slide-in-from-top-[48%] sm:rf-rounded-lg dark:rf-border-zinc-800 dark:rf-bg-zinc-950",t),...o,children:e})]}));e6.displayName=vie.displayName;const t6=({className:t,...e})=>V.jsx("div",{className:Wi("rf-flex rf-flex-col rf-space-y-2 rf-text-center sm:rf-text-left",t),...e});t6.displayName="DialogHeader";const iU=({className:t,...e})=>V.jsx("div",{className:Wi("rf-flex rf-flex-col-reverse sm:rf-flex-row sm:rf-justify-end sm:rf-space-x-2",t),...e});iU.displayName="DialogFooter";const n6=X.forwardRef(({className:t,...e},n)=>V.jsx(D3e,{ref:n,className:Wi("rf-text-lg rf-font-semibold",t),...e}));n6.displayName=D3e.displayName;const wT=X.forwardRef(({className:t,...e},n)=>V.jsx(M3e,{ref:n,className:Wi("rf-text-sm rf-text-zinc-500 dark:rf-text-zinc-400",t),...e}));wT.displayName=M3e.displayName;const Rie={"tscircuit.com":{label:"tscircuit.com",placeholder:"Search tscircuit packages...",emptyMessage:"No packages found"},jlcpcb:{label:"JLCPCB Parts",placeholder:"Search JLCPCB parts (e.g. C14663)...",emptyMessage:"No parts found"},kicad:{label:"KiCad Footprints",placeholder:"Search KiCad footprints...",emptyMessage:"No footprints found"}},ROo="https://cdn.jsdelivr.net/npm/easyeda@latest/dist/browser/index.js";let H3e=null;const G3e=async()=>(H3e||(H3e=import(ROo)),H3e),TOo=t=>(e,n)=>{const o=new Headers(n?.headers),i={};return o.forEach((r,A)=>{i[A]=r}),fetch(`${t?.apiBase??_C}/proxy`,{...n,headers:{...i,"X-Target-Url":e.toString(),"X-Sender-Origin":i.origin??"","X-Sender-Host":i.host??"https://easyeda.com","X-Sender-Referer":i.referer??"","X-Sender-User-Agent":i["user-agent"]??"","X-Sender-Cookie":i.cookie??"",authority:i.authority??"","content-type":i["content-type"]??"",...t?.headers}})},kOo=async(t,e=10)=>{const n=encodeURIComponent(t),o=await fetch(`https://jlcsearch.tscircuit.com/api/search?limit=${e}&q=${n}`);if(!o.ok)throw new Error(`JLCPCB API error: ${o.status}`);return(await o.json()).components??[]},FOo=t=>({lcscId:t.lcsc,manufacturer:t.mfr,description:t.description,partNumber:`C${t.lcsc}`,package:t.package,price:t.price,stock:t.stock,isBasic:t.is_basic}),JRt=async(t,e)=>{const{fetchEasyEDAComponent:n}=await G3e();return n(t,{fetch:TOo(e),includeModelMetadata:e?.includeModelMetadata})},LOo=async(t,e)=>{const{convertRawEasyToTsx:n}=await G3e(),o=await JRt(t,e);return n({rawEasy:o})},HOo=async(t,e)=>{const{EasyEdaJsonSchema:n,convertEasyEdaJsonToCircuitJson:o}=await G3e(),i=await JRt(t,{...e,includeModelMetadata:!1}),r=n.parse(i);return o(r,{shouldRecenter:!0,showDesignator:!0,useModelCdn:!1})};function hw(t){return Array.isArray?Array.isArray(t):WRt(t)==="[object Array]"}function GOo(t){if(typeof t=="string")return t;if(typeof t=="bigint")return t.toString();const e=t+"";return e=="0"&&1/t==-1/0?"-0":e}function O3e(t){return t==null?"":GOo(t)}function bC(t){return typeof t=="string"}function Tie(t){return typeof t=="number"}function OOo(t){return t===!0||t===!1||KOo(t)&&WRt(t)=="[object Boolean]"}function qRt(t){return typeof t=="object"}function KOo(t){return qRt(t)&&t!==null}function V2(t){return t!=null}function kie(t){return!t.trim().length}function WRt(t){return t==null?t===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(t)}const UOo="Incorrect 'index' type",K3e="Invalid doc index: must be a non-negative integer within the bounds of the docs array",YOo=t=>`Invalid value for key ${t}`,zOo=t=>`Pattern length exceeds max of ${t}.`,VOo=t=>`Missing ${t} property in key`,JOo=t=>`Property 'weight' in key '${t}' must be a positive integer`,qOo="Fuse.match does not support useTokenSearch: token search requires corpus-level statistics (df, fieldCount) that a one-off string comparison does not have. Use new Fuse(...).search(...) instead.",jRt=Object.prototype.hasOwnProperty;var WOo=class{constructor(t){this._keys=[],this._keyMap={};let e=0;t.forEach(n=>{const o=XRt(n);this._keys.push(o),this._keyMap[o.id]=o,e+=o.weight}),this._keys.forEach(n=>{n.weight/=e})}get(t){return this._keyMap[t]}keys(){return this._keys}toJSON(){return JSON.stringify(this._keys)}};function XRt(t){let e=null,n=null,o=null,i=1,r=null;if(bC(t)||hw(t))o=t,e=$Rt(t),n=Fie(t);else{if(!jRt.call(t,"name"))throw new Error(VOo("name"));const A=t.name;if(o=A,jRt.call(t,"weight")&&t.weight!==void 0&&(i=t.weight,i<=0))throw new Error(JOo(Fie(A)));e=$Rt(A),n=Fie(A),r=t.getFn??null}return{path:e,id:n,weight:i,src:o,getFn:r}}function $Rt(t){return hw(t)?t:t.split(".")}function Fie(t){return hw(t)?t.join("."):t}function jOo(t,e){const n=[];let o=!1;const i=(r,A,s,a)=>{if(V2(r))if(!A[s])n.push(a!==void 0?{v:r,i:a}:r);else{const c=r[A[s]];if(!V2(c))return;if(s===A.length-1&&(bC(c)||Tie(c)||OOo(c)||typeof c=="bigint"))n.push(a!==void 0?{v:O3e(c),i:a}:O3e(c));else if(hw(c)){o=!0;for(let l=0,g=c.length;l<g;l+=1)i(c[l],A,s+1,l)}else A.length&&i(c,A,s+1,a)}};return i(t,bC(e)?e.split("."):e,0),o?n:n[0]}const vA=Object.freeze({...{isCaseSensitive:!1,ignoreDiacritics:!1,includeScore:!1,keys:[],shouldSort:!0,sortFn:(t,e)=>t.score===e.score?t.idx<e.idx?-1:1:t.score<e.score?-1:1},...{includeMatches:!1,findAllMatches:!1,minMatchCharLength:1},...{location:0,threshold:.6,distance:100},...{useExtendedSearch:!1,useTokenSearch:!1,tokenize:void 0,tokenMatch:"any",getFn:jOo,ignoreLocation:!1,ignoreFieldNorm:!1,fieldNormWeight:1}});function XOo(t){return t>=9&&t<=13||t===32||t===160}function $Oo(t=1,e=3){const n=new Map,o=Math.pow(10,e);return{get(i){let r=0,A=!1;for(let a=0;a<i.length;a++)XOo(i.charCodeAt(a))?A=!1:A||(r++,A=!0);if(r===0&&(r=1),n.has(r))return n.get(r);const s=Math.round(o/Math.pow(r,.5*t))/o;return n.set(r,s),s},clear(){n.clear()}}}var U3e=class{constructor({getFn:t=vA.getFn,fieldNormWeight:e=vA.fieldNormWeight}={}){this.norm=$Oo(e,3),this.getFn=t,this.isCreated=!1,this.docs=[],this.keys=[],this._keysMap={},this.setIndexRecords()}setSources(t=[]){this.docs=t}setIndexRecords(t=[]){this.records=t}setKeys(t=[]){this.keys=t,this._keysMap={},t.forEach((e,n)=>{this._keysMap[e.id]=n})}create(){if(this.isCreated||!this.docs.length)return;this.isCreated=!0;const t=this.docs.length;this.records=new Array(t);let e=0;if(bC(this.docs[0]))for(let n=0;n<t;n++){const o=this._createStringRecord(this.docs[n],n);o&&(this.records[e++]=o)}else for(let n=0;n<t;n++)this.records[e++]=this._createObjectRecord(this.docs[n],n);this.records.length=e,this.norm.clear()}add(t,e){if(!Number.isInteger(e)||e<0)throw new Error(K3e);if(bC(t)){const o=this._createStringRecord(t,e);return o&&this.records.push(o),o}const n=this._createObjectRecord(t,e);return this.records.push(n),n}removeAt(t){if(!Number.isInteger(t)||t<0)throw new Error(K3e);for(let e=0,n=this.records.length;e<n;e+=1)if(this.records[e].i===t){this.records.splice(e,1);break}for(let e=0,n=this.records.length;e<n;e+=1)this.records[e].i>t&&(this.records[e].i-=1)}removeAll(t){const e=new Set;for(const o of t)Number.isInteger(o)&&o>=0&&e.add(o);if(e.size===0)return;this.records=this.records.filter(o=>!e.has(o.i));const n=Array.from(e).sort((o,i)=>o-i);for(const o of this.records){let i=0,r=n.length;for(;i<r;){const A=i+r>>>1;n[A]<o.i?i=A+1:r=A}o.i-=i}}getValueForItemAtKeyId(t,e){return t[this._keysMap[e]]}size(){return this.records.length}_createStringRecord(t,e){return!V2(t)||kie(t)?null:{v:t,i:e,n:this.norm.get(t)}}_createObjectRecord(t,e){const n={i:e,$:{}};for(let o=0,i=this.keys.length;o<i;o++){const r=this.keys[o],A=r.getFn?r.getFn(t):this.getFn(t,r.path);if(V2(A)){if(hw(A)){const s=[];for(let a=0,c=A.length;a<c;a+=1){const l=A[a];if(V2(l)){if(bC(l)){if(!kie(l)){const g={v:l,i:a,n:this.norm.get(l)};s.push(g)}}else if(V2(l.v)){const g=bC(l.v)?l.v:O3e(l.v);if(!kie(g)){const u={v:g,i:l.i,n:this.norm.get(g)};s.push(u)}}}}n.$[o]=s}else if(bC(A)&&!kie(A)){const s={v:A,n:this.norm.get(A)};n.$[o]=s}}}return n}toJSON(){return{keys:this.keys.map(({getFn:t,...e})=>e),records:this.records}}};function ZRt(t,e,{getFn:n=vA.getFn,fieldNormWeight:o=vA.fieldNormWeight}={}){const i=new U3e({getFn:n,fieldNormWeight:o});return i.setKeys(t.map(XRt)),i.setSources(e),i.create(),i}function ZOo(t,{getFn:e=vA.getFn,fieldNormWeight:n=vA.fieldNormWeight}={}){const{keys:o,records:i}=t,r=new U3e({getFn:e,fieldNormWeight:n});return r.setKeys(o),r.setIndexRecords(i),r}function eKo(t=[],e=vA.minMatchCharLength){const n=[];let o=-1,i=-1,r=0;for(let A=t.length;r<A;r+=1){const s=t[r];s&&o===-1?o=r:!s&&o!==-1&&(i=r-1,i-o+1>=e&&n.push([o,i]),o=-1)}return t[r-1]&&r-o>=e&&n.push([o,r-1]),n}function tKo(t,e,n,{location:o=vA.location,distance:i=vA.distance,threshold:r=vA.threshold,findAllMatches:A=vA.findAllMatches,minMatchCharLength:s=vA.minMatchCharLength,includeMatches:a=vA.includeMatches,ignoreLocation:c=vA.ignoreLocation}={}){if(e.length>32)throw new Error(zOo(32));const l=e.length,g=t.length,u=Math.max(0,Math.min(o,g));let h=r,d=u;const _=(D,w)=>{const F=D/l;if(c)return F;const R=Math.abs(u-w);return i?F+R/i:R?1:F},m=s>1||a,p=m?Array(g):[];let C;for(;(C=t.indexOf(e,d))>-1;){const D=_(0,C);if(h=Math.min(D,h),d=C+l,m){let w=0;for(;w<l;)p[C+w]=1,w+=1}}d=-1;let I=[],f=1,y=0,x=l+g;const B=1<<l-1;for(let D=0;D<l;D+=1){let w=0,F=x;for(;w<F;)_(D,u+F)<=h?w=F:x=F,F=Math.floor((x-w)/2+w);x=F;let R=Math.max(1,u-F+1);const H=A?g:Math.min(u+F,g)+l,G=Array(H+2);G[H+1]=(1<<D)-1;for(let K=H;K>=R;K-=1){const J=K-1,W=n[t[J]];if(G[K]=(G[K+1]<<1|1)&W,D&&(G[K]|=(I[K+1]|I[K])<<1|1|I[K+1]),G[K]&B&&(f=_(D,J),f<=h)){if(h=f,d=J,y=D,d<=u)break;R=Math.max(1,2*u-d)}}if(_(D+1,u)>h)break;I=G}if(m&&d>=0){const D=Math.min(g-1,d+l-1+y);for(let w=d;w<=D;w+=1)n[t[w]]&&(p[w]=1)}const S={isMatch:d>=0,score:Math.max(.001,f)};if(m){const D=eKo(p,s);D.length?a&&(S.indices=D):S.isMatch=!1}return S}function nKo(t){const e={};for(let n=0,o=t.length;n<o;n+=1){const i=t.charAt(n);e[i]=(e[i]||0)|1<<o-n-1}return e}function Y3e(t){if(t.length<=1)return t;t.sort((n,o)=>n[0]-o[0]||n[1]-o[1]);const e=[t[0]];for(let n=1,o=t.length;n<o;n+=1){const i=e[e.length-1],r=t[n];r[0]<=i[1]+1?i[1]=Math.max(i[1],r[1]):e.push(r)}return e}const eTt={ł:"l",Ł:"L",đ:"d",Đ:"D",ø:"o",Ø:"O",ħ:"h",Ħ:"H",ŧ:"t",Ŧ:"T",ı:"i",ß:"ss"},oKo=new RegExp("["+Object.keys(eTt).join("")+"]","g"),rU=typeof String.prototype.normalize=="function"?t=>t.normalize("NFD").replace(/[\u0300-\u036F\u0483-\u0489\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u0610-\u061A\u064B-\u065F\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED\u0711\u0730-\u074A\u07A6-\u07B0\u07EB-\u07F3\u07FD\u0816-\u0819\u081B-\u0823\u0825-\u0827\u0829-\u082D\u0859-\u085B\u08D3-\u08E1\u08E3-\u0903\u093A-\u093C\u093E-\u094F\u0951-\u0957\u0962\u0963\u0981-\u0983\u09BC\u09BE-\u09C4\u09C7\u09C8\u09CB-\u09CD\u09D7\u09E2\u09E3\u09FE\u0A01-\u0A03\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A70\u0A71\u0A75\u0A81-\u0A83\u0ABC\u0ABE-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AE2\u0AE3\u0AFA-\u0AFF\u0B01-\u0B03\u0B3C\u0B3E-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B62\u0B63\u0B82\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD7\u0C00-\u0C04\u0C3E-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C62\u0C63\u0C81-\u0C83\u0CBC\u0CBE-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CE2\u0CE3\u0D00-\u0D03\u0D3B\u0D3C\u0D3E-\u0D44\u0D46-\u0D48\u0D4A-\u0D4D\u0D57\u0D62\u0D63\u0D82\u0D83\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DF2\u0DF3\u0E31\u0E34-\u0E3A\u0E47-\u0E4E\u0EB1\u0EB4-\u0EB9\u0EBB\u0EBC\u0EC8-\u0ECD\u0F18\u0F19\u0F35\u0F37\u0F39\u0F3E\u0F3F\u0F71-\u0F84\u0F86\u0F87\u0F8D-\u0F97\u0F99-\u0FBC\u0FC6\u102B-\u103E\u1056-\u1059\u105E-\u1060\u1062-\u1064\u1067-\u106D\u1071-\u1074\u1082-\u108D\u108F\u109A-\u109D\u135D-\u135F\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17B4-\u17D3\u17DD\u180B-\u180D\u1885\u1886\u18A9\u1920-\u192B\u1930-\u193B\u1A17-\u1A1B\u1A55-\u1A5E\u1A60-\u1A7C\u1A7F\u1AB0-\u1ABE\u1B00-\u1B04\u1B34-\u1B44\u1B6B-\u1B73\u1B80-\u1B82\u1BA1-\u1BAD\u1BE6-\u1BF3\u1C24-\u1C37\u1CD0-\u1CD2\u1CD4-\u1CE8\u1CED\u1CF2-\u1CF4\u1CF7-\u1CF9\u1DC0-\u1DF9\u1DFB-\u1DFF\u20D0-\u20F0\u2CEF-\u2CF1\u2D7F\u2DE0-\u2DFF\u302A-\u302F\u3099\u309A\uA66F-\uA672\uA674-\uA67D\uA69E\uA69F\uA6F0\uA6F1\uA802\uA806\uA80B\uA823-\uA827\uA880\uA881\uA8B4-\uA8C5\uA8E0-\uA8F1\uA8FF\uA926-\uA92D\uA947-\uA953\uA980-\uA983\uA9B3-\uA9C0\uA9E5\uAA29-\uAA36\uAA43\uAA4C\uAA4D\uAA7B-\uAA7D\uAAB0\uAAB2-\uAAB4\uAAB7\uAAB8\uAABE\uAABF\uAAC1\uAAEB-\uAAEF\uAAF5\uAAF6\uABE3-\uABEA\uABEC\uABED\uFB1E\uFE00-\uFE0F\uFE20-\uFE2F]/g,"").replace(oKo,e=>eTt[e]):t=>t;var z3e=class{constructor(t,{location:e=vA.location,threshold:n=vA.threshold,distance:o=vA.distance,includeMatches:i=vA.includeMatches,findAllMatches:r=vA.findAllMatches,minMatchCharLength:A=vA.minMatchCharLength,isCaseSensitive:s=vA.isCaseSensitive,ignoreDiacritics:a=vA.ignoreDiacritics,ignoreLocation:c=vA.ignoreLocation}={}){if(this.options={location:e,threshold:n,distance:o,includeMatches:i,findAllMatches:r,minMatchCharLength:A,isCaseSensitive:s,ignoreDiacritics:a,ignoreLocation:c},t=s?t:t.toLowerCase(),t=a?rU(t):t,this.pattern=t,this.chunks=[],!this.pattern.length)return;const l=(u,h)=>{this.chunks.push({pattern:u,alphabet:nKo(u),startIndex:h})},g=this.pattern.length;if(g>32){let u=0;const h=g%32,d=g-h;for(;u<d;)l(this.pattern.substr(u,32),u),u+=32;if(h){const _=g-32;l(this.pattern.substr(_),_)}}else l(this.pattern,0)}searchIn(t){const{isCaseSensitive:e,ignoreDiacritics:n,includeMatches:o}=this.options;if(t=e?t:t.toLowerCase(),t=n?rU(t):t,this.pattern===t){if(t.length<this.options.minMatchCharLength)return{isMatch:!1,score:1};const d={isMatch:!0,score:0};return o&&(d.indices=[[0,t.length-1]]),d}const{location:i,distance:r,threshold:A,findAllMatches:s,minMatchCharLength:a,ignoreLocation:c}=this.options,l=[];let g=0,u=!1;this.chunks.forEach(({pattern:d,alphabet:_,startIndex:m})=>{const{isMatch:p,score:C,indices:I}=tKo(t,d,_,{location:i+m,distance:r,threshold:A,findAllMatches:s,minMatchCharLength:a,includeMatches:o,ignoreLocation:c});p&&(u=!0),g+=C,p&&I&&l.push(...I)});const h={isMatch:u,score:u?g/this.chunks.length:1};return u&&o&&(h.indices=Y3e(l)),h}};const iKo=new Set(["fuzzy","include"]);function rKo(t){return t.startsWith("inverse")}const V3e=[{type:"exact",multiRegex:/^="(.*)"$/,singleRegex:/^=(.*)$/,create:t=>({type:"exact",search(e){const n=e===t;return{isMatch:n,score:n?0:1,indices:[0,t.length-1]}}})},{type:"include",multiRegex:/^'"(.*)"$/,singleRegex:/^'(.*)$/,create:t=>({type:"include",search(e){let n=0,o;const i=[],r=t.length;for(;(o=e.indexOf(t,n))>-1;)n=o+r,i.push([o,n-1]);const A=!!i.length;return{isMatch:A,score:A?0:1,indices:i}}})},{type:"prefix-exact",multiRegex:/^\^"(.*)"$/,singleRegex:/^\^(.*)$/,create:t=>({type:"prefix-exact",search(e){const n=e.startsWith(t);return{isMatch:n,score:n?0:1,indices:[0,t.length-1]}}})},{type:"inverse-prefix-exact",multiRegex:/^!\^"(.*)"$/,singleRegex:/^!\^(.*)$/,create:t=>({type:"inverse-prefix-exact",search(e){const n=!e.startsWith(t);return{isMatch:n,score:n?0:1,indices:[0,e.length-1]}}})},{type:"inverse-suffix-exact",multiRegex:/^!"(.*)"\$$/,singleRegex:/^!(.*)\$$/,create:t=>({type:"inverse-suffix-exact",search(e){const n=!e.endsWith(t);return{isMatch:n,score:n?0:1,indices:[0,e.length-1]}}})},{type:"suffix-exact",multiRegex:/^"(.*)"\$$/,singleRegex:/^(.*)\$$/,create:t=>({type:"suffix-exact",search(e){const n=e.endsWith(t);return{isMatch:n,score:n?0:1,indices:[e.length-t.length,e.length-1]}}})},{type:"inverse-exact",multiRegex:/^!"(.*)"$/,singleRegex:/^!(.*)$/,create:t=>({type:"inverse-exact",search(e){const n=e.indexOf(t)===-1;return{isMatch:n,score:n?0:1,indices:[0,e.length-1]}}})},{type:"fuzzy",multiRegex:/^"(.*)"$/,singleRegex:/^(.*)$/,create:(t,e={})=>{const n=new z3e(t,{location:e.location??vA.location,threshold:e.threshold??vA.threshold,distance:e.distance??vA.distance,includeMatches:e.includeMatches??vA.includeMatches,findAllMatches:e.findAllMatches??vA.findAllMatches,minMatchCharLength:e.minMatchCharLength??vA.minMatchCharLength,isCaseSensitive:e.isCaseSensitive??vA.isCaseSensitive,ignoreDiacritics:e.ignoreDiacritics??vA.ignoreDiacritics,ignoreLocation:e.ignoreLocation??vA.ignoreLocation});return{type:"fuzzy",search(o){return n.searchIn(o)}}}}],tTt=V3e.length,AKo="\0",sKo="|";function aKo(t){const e=[],n=t.length;let o=0;for(;o<n;){for(;o<n&&t[o]===" ";)o++;if(o>=n)break;let i=o;for(;i<n&&t[i]!==" "&&t[i]!=='"';)i++;if(i<n&&t[i]==='"'){for(i++;i<n;){if(t[i]==='"'){const r=i+1;if(r>=n||t[r]===" "){i++;break}if(t[r]==="$"&&(r+1>=n||t[r+1]===" ")){i+=2;break}}i++}e.push(t.substring(o,i)),o=i}else{for(;i<n&&t[i]!==" ";)i++;e.push(t.substring(o,i)),o=i}}return e}function nTt(t,e){const n=t.match(e);return n?n[1]:null}function cKo(t,e={}){return t.replace(/\\\|/g,AKo).split(sKo).map(n=>{const o=aKo(n.replace(/\u0000/g,"|").trim()).filter(r=>r&&!!r.trim()),i=[];for(let r=0,A=o.length;r<A;r+=1){const s=o[r];let a=!1,c=-1;for(;!a&&++c<tTt;){const l=V3e[c],g=nTt(s,l.multiRegex);g&&(i.push(l.create(g,e)),a=!0)}if(!a)for(c=-1;++c<tTt;){const l=V3e[c],g=nTt(s,l.singleRegex);if(g){i.push(l.create(g,e));break}}}return i})}var lKo=class{constructor(t,{isCaseSensitive:e=vA.isCaseSensitive,ignoreDiacritics:n=vA.ignoreDiacritics,includeMatches:o=vA.includeMatches,minMatchCharLength:i=vA.minMatchCharLength,ignoreLocation:r=vA.ignoreLocation,findAllMatches:A=vA.findAllMatches,location:s=vA.location,threshold:a=vA.threshold,distance:c=vA.distance}={}){this.query=null,this.options={isCaseSensitive:e,ignoreDiacritics:n,includeMatches:o,minMatchCharLength:i,findAllMatches:A,ignoreLocation:r,location:s,threshold:a,distance:c},t=e?t:t.toLowerCase(),t=n?rU(t):t,this.pattern=t,this.query=cKo(this.pattern,this.options)}static condition(t,e){return e.useExtendedSearch}searchIn(t){const e=this.query;if(!e)return{isMatch:!1,score:1};const{includeMatches:n,isCaseSensitive:o,ignoreDiacritics:i}=this.options;t=o?t:t.toLowerCase(),t=i?rU(t):t;let r=0;const A=[];let s=0,a=!1;for(let c=0,l=e.length;c<l;c+=1){const g=e[c];A.length=0,r=0,a=!1;for(let u=0,h=g.length;u<h;u+=1){const d=g[u],{isMatch:_,indices:m,score:p}=d.search(t);if(_)r+=1,s+=p,rKo(d.type)&&(a=!0),n&&(iKo.has(d.type)?A.push(...m):A.push(m));else{s=0,r=0,A.length=0,a=!1;break}}if(r){const u={isMatch:!0,score:s/r};return a&&(u.hasInverse=!0),n&&(u.indices=Y3e(A)),u}}return{isMatch:!1,score:1}}};const J3e=[];function q3e(...t){J3e.push(...t)}function Lie(t,e){for(let n=0,o=J3e.length;n<o;n+=1){const i=J3e[n];if(i.condition(t,e))return new i(t,e)}return new z3e(t,e)}const Hie={AND:"$and",OR:"$or"},W3e={PATH:"$path",PATTERN:"$val"},j3e=t=>!!(t[Hie.AND]||t[Hie.OR]),gKo=t=>!!t[W3e.PATH],uKo=t=>!hw(t)&&qRt(t)&&!j3e(t),oTt=t=>({[Hie.AND]:Object.keys(t).map(e=>({[e]:t[e]}))});function iTt(t,e,{auto:n=!0}={}){const o=i=>{if(bC(i)){const a={keyId:null,pattern:i};return n&&(a.searcher=Lie(i,e)),a}const r=Object.keys(i),A=gKo(i);if(!A&&r.length>1&&!j3e(i))return o(oTt(i));if(uKo(i)){const a=A?i[W3e.PATH]:r[0],c=A?i[W3e.PATTERN]:i[a];if(!bC(c))throw new Error(YOo(a));const l={keyId:Fie(a),pattern:c};return n&&(l.searcher=Lie(c,e)),l}const s={children:[],operator:r[0]};return r.forEach(a=>{const c=i[a];hw(c)&&c.forEach(l=>{s.children.push(o(l))})}),s};return j3e(t)||(t=oTt(t)),o(t)}function X3e(t,{ignoreFieldNorm:e=vA.ignoreFieldNorm}){let n=1;return t.forEach(({key:o,norm:i,score:r})=>{const A=o?o.weight:null;n*=Math.pow(r===0&&A?Number.EPSILON:r,(A||1)*(e?1:i))}),n}function dKo(t,{ignoreFieldNorm:e=vA.ignoreFieldNorm}){t.forEach(n=>{n.score=X3e(n.matches,{ignoreFieldNorm:e})})}var hKo=class{constructor(t,e){this.limit=t,this.heap=[],this.comparator=e}get size(){return this.heap.length}insert(t){this.size<this.limit?(this.heap.push(t),this._bubbleUp(this.size-1)):this.comparator(t,this.heap[0])<0&&(this.heap[0]=t,this._sinkDown(0))}extractSorted(){return this.heap.sort(this.comparator)}_bubbleUp(t){const e=this.heap;for(;t>0;){const n=t-1>>1;if(this.comparator(e[t],e[n])<=0)break;const o=e[t];e[t]=e[n],e[n]=o,t=n}}_sinkDown(t){const e=this.heap,n=e.length;let o=t;do{t=o;const i=2*t+1,r=2*t+2;if(i<n&&this.comparator(e[i],e[o])>0&&(o=i),r<n&&this.comparator(e[r],e[o])>0&&(o=r),o!==t){const A=e[t];e[t]=e[o],e[o]=A}}while(o!==t)}};function _Ko(t){const e=[];return t.matches.forEach(n=>{if(!V2(n.indices)||!n.indices.length)return;const o={indices:n.indices,value:n.value};n.key&&(o.key=n.key.id),n.idx>-1&&(o.refIndex=n.idx),e.push(o)}),e}function pKo(t,e,{includeMatches:n=vA.includeMatches,includeScore:o=vA.includeScore}={}){return t.map(i=>{const{idx:r}=i,A={item:e[r],refIndex:r};return n&&(A.matches=_Ko(i)),o&&(A.score=i.score),A})}const mKo=/[\p{L}\p{M}\p{N}_]+/gu,rTt=new WeakSet;function IKo(t){rTt.has(t)||(rTt.add(t),console.warn(`[Fuse] tokenize regex ${t} lacks the global flag; only the first match per text will be returned. Add the 'g' flag.`))}function CKo(t){if(typeof t=="function"){let e=!1;return n=>{const o=t(n);if(!e&&(e=!0,!Array.isArray(o)||o.some(i=>typeof i!="string")))throw new Error(`[Fuse] tokenize function must return string[]; received ${Array.isArray(o)?"array containing non-strings":typeof o}.`);return o}}return t instanceof RegExp?(t.global||IKo(t),e=>e.match(t)||[]):e=>e.match(mKo)||[]}function $3e({isCaseSensitive:t=!1,ignoreDiacritics:e=!1,tokenize:n}={}){const o=CKo(n);return{tokenize(i){return t||(i=i.toLowerCase()),e&&(i=rU(i)),o(i)}}}var fKo=class{static condition(t,e){return e.useTokenSearch}constructor(t,e){this.options=e,this.analyzer=$3e({isCaseSensitive:e.isCaseSensitive,ignoreDiacritics:e.ignoreDiacritics,tokenize:e.tokenize});const n=this.analyzer.tokenize(t),{df:o,fieldCount:i}=e._invertedIndex;this.termSearchers=[],this.idfWeights=[];for(const r of n){this.termSearchers.push(new z3e(r,{location:e.location,threshold:e.threshold,distance:e.distance,includeMatches:e.includeMatches,findAllMatches:e.findAllMatches,minMatchCharLength:e.minMatchCharLength,isCaseSensitive:e.isCaseSensitive,ignoreDiacritics:e.ignoreDiacritics,ignoreLocation:!0}));const A=o.get(r)||0,s=Math.log(1+(i-A+.5)/(A+.5));this.idfWeights.push(s)}this.combineAll=e.tokenMatch==="all",this.numTerms=this.termSearchers.length,this.useMask=this.numTerms<=31}searchIn(t){if(!this.termSearchers.length)return{isMatch:!1,score:1};const e=[];let n=0,o=0,i=0,r=0;const A=this.combineAll&&!this.useMask?new Set:null;for(let c=0;c<this.termSearchers.length;c++){const l=this.termSearchers[c].searchIn(t),g=this.idfWeights[c];o+=g,l.isMatch&&(i++,n+=g*(1-l.score),l.indices&&e.push(...l.indices),this.combineAll&&(this.useMask?r|=1<<c:A.add(c)))}if(i===0)return{isMatch:!1,score:1};const s=o>0?1-n/o:0,a={isMatch:!0,score:Math.max(.001,s)};return this.options.includeMatches&&e.length&&(a.indices=Y3e(e)),this.combineAll&&(this.useMask?a.matchedMask=r:a.matchedTerms=A,a.termCount=this.numTerms),a}};function Z3e(t,e,n,o){const i=o.tokenize(e);if(!i.length)return;t.fieldCount++,t.docFieldCount.set(n,(t.docFieldCount.get(n)||0)+1);const r=new Set(i);let A=t.docTermFieldHits.get(n);A||(A=new Map,t.docTermFieldHits.set(n,A));for(const s of r)A.set(s,(A.get(s)||0)+1),t.df.set(s,(t.df.get(s)||0)+1)}function ATt(t,e,n,o){const{i,v:r,$:A}=e;if(r!==void 0){Z3e(t,r,i,o);return}if(A)for(let s=0;s<n;s++){const a=A[s];if(a)if(Array.isArray(a))for(const c of a)Z3e(t,c.v,i,o);else Z3e(t,a.v,i,o)}}function yKo(t,e,n){const o={fieldCount:0,df:new Map,docFieldCount:new Map,docTermFieldHits:new Map};for(const i of t)ATt(o,i,e,n);return o}function EKo(t,e,n,o){ATt(t,e,n,o)}function xKo(t,e){const n=t.docFieldCount.get(e);if(n===void 0)return;t.fieldCount-=n,t.docFieldCount.delete(e);const o=t.docTermFieldHits.get(e);if(o){for(const[i,r]of o){const A=(t.df.get(i)||0)-r;A<=0?t.df.delete(i):t.df.set(i,A)}t.docTermFieldHits.delete(e)}}function sTt(t,e){if(e.length===0)return;const n=Array.from(new Set(e)).sort((s,a)=>s-a);for(const s of n)xKo(t,s);const o=s=>{let a=0,c=n.length;for(;a<c;){const l=a+c>>>1;n[l]<s?a=l+1:c=l}return s-a},i=n[0],r=new Map;for(const[s,a]of t.docFieldCount)r.set(s>i?o(s):s,a);t.docFieldCount=r;const A=new Map;for(const[s,a]of t.docTermFieldHits)A.set(s>i?o(s):s,a);t.docTermFieldHits=A}var _w=class{constructor(t,e,n){this.options={...vA,...e},this.options.useExtendedSearch,this.options.useTokenSearch,this._keyStore=new WOo(this.options.keys),this._docs=t,this._myIndex=null,this._invertedIndex=null,this.setCollection(t,n),this._lastQuery=null,this._lastSearcher=null}_getSearcher(t){if(this._lastQuery===t)return this._lastSearcher;const e=Lie(t,this._invertedIndex?{...this.options,_invertedIndex:this._invertedIndex}:this.options);return this._lastQuery=t,this._lastSearcher=e,e}setCollection(t,e){if(this._docs=t,e&&!(e instanceof U3e))throw new Error(UOo);if(this._myIndex=e||ZRt(this.options.keys,this._docs,{getFn:this.options.getFn,fieldNormWeight:this.options.fieldNormWeight}),this.options.useTokenSearch){const n=$3e({isCaseSensitive:this.options.isCaseSensitive,ignoreDiacritics:this.options.ignoreDiacritics,tokenize:this.options.tokenize});this._invertedIndex=yKo(this._myIndex.records,this._myIndex.keys.length,n)}this._invalidateSearcherCache()}add(t){if(!V2(t))return;this._docs.push(t);const e=this._myIndex.add(t,this._docs.length-1);if(this._invertedIndex&&e){const n=$3e({isCaseSensitive:this.options.isCaseSensitive,ignoreDiacritics:this.options.ignoreDiacritics,tokenize:this.options.tokenize});EKo(this._invertedIndex,e,this._myIndex.keys.length,n)}this._invalidateSearcherCache()}remove(t=()=>!1){const e=[],n=[];for(let o=0,i=this._docs.length;o<i;o+=1)t(this._docs[o],o)&&(e.push(this._docs[o]),n.push(o));if(n.length){this._invertedIndex&&sTt(this._invertedIndex,n);const o=new Set(n);this._docs=this._docs.filter((i,r)=>!o.has(r)),this._myIndex.removeAll(n),this._invalidateSearcherCache()}return e}removeAt(t){if(!Number.isInteger(t)||t<0||t>=this._docs.length)throw new Error(K3e);this._invertedIndex&&sTt(this._invertedIndex,[t]);const e=this._docs.splice(t,1)[0];return this._myIndex.removeAt(t),this._invalidateSearcherCache(),e}_invalidateSearcherCache(){this._lastQuery=null,this._lastSearcher=null}getIndex(){return this._myIndex}_normalizedKeys(){return this._myIndex.keys.map(t=>this._keyStore.get(t.id)||t)}search(t,e){const{limit:n=-1}=e||{},{includeMatches:o,includeScore:i,shouldSort:r,sortFn:A,ignoreFieldNorm:s}=this.options;if(bC(t)&&!t.trim()){let u=this._docs.map((h,d)=>({item:h,refIndex:d}));return Tie(n)&&n>-1&&(u=u.slice(0,n)),u}const a=r&&Tie(n)&&n>0&&bC(t),c=A,l=(u,h)=>c(u,h)||u.idx-h.idx;let g;if(a){const u=new hKo(n,l);bC(this._docs[0])?this._searchStringList(t,{heap:u,ignoreFieldNorm:s}):this._searchObjectList(t,{heap:u,ignoreFieldNorm:s}),g=u.extractSorted()}else g=bC(t)?bC(this._docs[0])?this._searchStringList(t):this._searchObjectList(t):this._searchLogical(t),dKo(g,{ignoreFieldNorm:s}),r&&g.sort(bC(t)?l:c),Tie(n)&&n>-1&&(g=g.slice(0,n));return pKo(g,this._docs,{includeMatches:o,includeScore:i})}_searchStringList(t,{heap:e,ignoreFieldNorm:n}={}){const o=this._getSearcher(t),i=this.options.useTokenSearch&&this.options.tokenMatch==="all",{records:r}=this._myIndex,A=e?null:[];return r.forEach(({v:s,i:a,n:c})=>{if(!V2(s))return;const l=o.searchIn(s);if(l.isMatch){const g={score:l.score,value:s,norm:c,indices:l.indices};i&&(g.matchedMask=l.matchedMask,g.matchedTerms=l.matchedTerms,g.termCount=l.termCount);const u=[g];if(!i||this._coversAllTokens(u)){const h={item:s,idx:a,matches:u};e?(h.score=X3e(h.matches,{ignoreFieldNorm:n}),e.insert(h)):A.push(h)}}}),A}_searchLogical(t){const e=iTt(t,this.options),n=this._normalizedKeys(),o=(s,a,c)=>{if(!("children"in s)){const{keyId:h,searcher:d}=s;let _;return h===null?(_=[],n.forEach((m,p)=>{_.push(...this._findMatches({key:m,value:a[p],searcher:d}))})):_=this._findMatches({key:this._keyStore.get(h),value:this._myIndex.getValueForItemAtKeyId(a,h),searcher:d}),_&&_.length?[{idx:c,item:a,matches:_}]:[]}const{children:l,operator:g}=s,u=[];for(let h=0,d=l.length;h<d;h+=1){const _=l[h],m=o(_,a,c);if(m.length)u.push(...m);else if(g===Hie.AND)return[]}return u},i=this._myIndex.records,r=new Map,A=[];return i.forEach(({$:s,i:a})=>{if(V2(s)){const c=o(e,s,a);c.length&&(r.has(a)||(r.set(a,{idx:a,item:s,matches:[]}),A.push(r.get(a))),c.forEach(({matches:l})=>{r.get(a).matches.push(...l)}))}}),A}_searchObjectList(t,{heap:e,ignoreFieldNorm:n}={}){const o=this._getSearcher(t),i=this.options.useTokenSearch&&this.options.tokenMatch==="all",{records:r}=this._myIndex,A=this._normalizedKeys(),s=e?null:[];return r.forEach(({$:a,i:c})=>{if(!V2(a))return;const l=[];let g=!1,u=!1;if(A.forEach((h,d)=>{const _=this._findMatches({key:h,value:a[d],searcher:o});_.length?(l.push(..._),_[0].hasInverse&&(u=!0)):g=!0}),!(u&&g)&&l.length&&(!i||this._coversAllTokens(l))){const h={idx:c,item:a,matches:l};e?(h.score=X3e(h.matches,{ignoreFieldNorm:n}),e.insert(h)):s.push(h)}}),s}_findMatches({key:t,value:e,searcher:n}){if(!V2(e))return[];const o=[];if(hw(e))e.forEach(({v:i,i:r,n:A})=>{if(!V2(i))return;const s=n.searchIn(i);if(s.isMatch){const a={score:s.score,key:t,value:i,idx:r,norm:A,indices:s.indices,hasInverse:s.hasInverse};s.termCount!==void 0&&(a.matchedMask=s.matchedMask,a.matchedTerms=s.matchedTerms,a.termCount=s.termCount),o.push(a)}});else{const{v:i,n:r}=e,A=n.searchIn(i);if(A.isMatch){const s={score:A.score,key:t,value:i,norm:r,indices:A.indices,hasInverse:A.hasInverse};A.termCount!==void 0&&(s.matchedMask=A.matchedMask,s.matchedTerms=A.matchedTerms,s.termCount=A.termCount),o.push(s)}}return o}_coversAllTokens(t){const e=t.length?t[0].termCount:void 0;if(e===void 0)return!0;if(e<=31){let o=0;for(let i=0;i<t.length;i++)o|=t[i].matchedMask||0;return o===2**e-1}const n=new Set;for(let o=0;o<t.length;o++){const i=t[o].matchedTerms;if(i)for(const r of i)n.add(r)}return n.size===e}};_w.version="7.5.0",_w.createIndex=ZRt,_w.parseIndex=ZOo,_w.config=vA,_w.match=function(t,e,n){if(n&&n.useTokenSearch)throw new Error(qOo);return Lie(t,{...vA,...n}).searchIn(e)},_w.parseQuery=iTt,q3e(lKo),q3e(fKo),_w.use=function(...t){t.forEach(e=>q3e(e))};var BKo=_w;const QKo="https://kicad-mod-cache.tscircuit.com";let e6e=null,AU=null,t6e=null;const SKo=async()=>e6e||AU||(AU=fetch("https://kicad-mod-cache.tscircuit.com/kicad_files.json").then(t=>t.json()).then(t=>(e6e=t,AU=null,t)),AU),bKo=async(t,e=20)=>{const n=await SKo();return t6e||(t6e=new BKo(n)),t6e.search(t).slice(0,e).map(o=>o.item)},DKo=t=>{const e=t.replace(".pretty/","/").replace(".kicad_mod",""),n=`kicad:${e}`;return{path:t,qualifiedName:n,description:e}},MKo=t=>t.replace(/^\/+/,"").split("/").map(e=>encodeURIComponent(e)).join("/"),wKo=async t=>{const e=await fetch(`${QKo}/${MKo(t)}`);if(!e.ok)throw new Error(`KiCad footprint fetch failed: ${e.status}`);const n=await e.text(),{KicadFootprintToCircuitJsonConverter:o}=await DB("kicad-to-circuit-json"),i=new o;return i.addFile(t.split("/").pop()??"selected-footprint.kicad_mod",n),i.runUntilFinished(),i.getOutput()},aTt=t=>t?.source==="jlcpcb"||t?.source==="kicad",PKo=async(t,e)=>{if(t.source==="jlcpcb")return HOo(t.component.partNumber,e?.jlcpcb);if(t.source==="kicad")return wKo(t.footprint.path);throw new Error("Footprint preview is not available for this source")},vKo=({query:t,placeholder:e,isSearching:n,onQueryChange:o,onSubmit:i})=>{const r=X.useCallback(A=>{A.key==="Enter"&&(A.preventDefault(),i())},[i]);return V.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2 rf-mt-4",children:[V.jsxs("div",{className:"rf-relative rf-flex-grow",children:[V.jsx(APe,{className:"rf-absolute rf-left-2 rf-top-2.5 rf-h-4 rf-w-4 rf-text-muted-foreground"}),V.jsx(tve,{placeholder:e,className:"rf-pl-8",spellCheck:!1,autoComplete:"off",value:t,onChange:A=>o(A.target.value),onKeyDown:r})]}),V.jsx(ta,{onClick:i,disabled:n||t.trim().length<1,className:"sm:rf-px-4 rf-px-3",children:n?V.jsx(SB,{className:"rf-h-4 rf-w-4 rf-animate-spin"}):V.jsxs(V.Fragment,{children:[V.jsx(APe,{className:"rf-h-4 rf-w-4 sm:rf-hidden"}),V.jsx("span",{className:"rf-hidden sm:rf-inline",children:"Search"})]})})]})},NKo=new Intl.NumberFormat("en-US",{style:"currency",currency:"USD"}),RKo=t=>NKo.format(t),cTt=t=>{switch(t.source){case"tscircuit.com":{const e=t.package;return`tscircuit-${e.package_id??`${e.org_owner_tscircuit_handle??"unknown"}-${e.unscoped_name??e.name??"package"}`}`}case"jlcpcb":return`jlc-${t.component.lcscId}`;case"kicad":return`kicad-${t.footprint.path}`;default:return"unknown"}},TKo=t=>{switch(t.source){case"tscircuit.com":return t.package.unscoped_name;case"jlcpcb":return t.component.isDirectLookup?t.component.partNumber:t.component.manufacturer;case"kicad":return t.footprint.qualifiedName}},kKo=t=>{switch(t.source){case"tscircuit.com":return t.package.description||(t.package.org_owner_tscircuit_handle?`Component by ${t.package.org_owner_tscircuit_handle}`:void 0);case"jlcpcb":return t.component.description;case"kicad":return t.footprint.description}},FKo=t=>{switch(t.source){case"tscircuit.com":return t.package.name;case"jlcpcb":return t.component.isDirectLookup?void 0:t.component.partNumber;case"kicad":return}},LKo=({results:t,selected:e,onSelect:n,onShowDetails:o})=>{const i=e?cTt(e):null;return V.jsx("div",{className:"rf-divide-y rf-w-full rf-overflow-hidden",children:t.map(r=>{const A=cTt(r),s=i===A,a=TKo(r),c=kKo(r),l=FKo(r),g=r.source==="jlcpcb"?r.component.stock:null,u=r.source==="jlcpcb"?r.component.price:null,h=r.source==="jlcpcb"?r.component.isBasic:null,d=r.source==="jlcpcb"?r.component.isDirectLookup:!1;return V.jsxs("div",{className:`rf-p-3 rf-flex rf-flex-col sm:rf-grid sm:rf-grid-cols-[minmax(0,1fr)_auto] rf-items-start sm:rf-items-center rf-cursor-pointer hover:rf-bg-zinc-100 rf-gap-2 rf-overflow-hidden ${s?"rf-bg-zinc-100":""}`,onClick:()=>n(r),children:[V.jsxs("div",{className:"rf-min-w-0 rf-overflow-hidden rf-w-full",children:[V.jsxs("div",{className:"rf-flex rf-items-start rf-gap-2 rf-min-w-0",children:[V.jsxs("div",{className:"rf-font-medium rf-text-sm rf-truncate rf-flex-1 rf-min-w-0 rf-flex rf-items-center rf-gap-1.5",children:[a,r.source==="jlcpcb"&&h!=null&&V.jsx("span",{className:`rf-text-xs rf-px-1.5 rf-py-0.5 rf-rounded rf-font-medium rf-flex-shrink-0 ${h?"rf-bg-green-100 rf-text-green-700":"rf-bg-orange-100 rf-text-orange-700"}`,children:h?"Basic":"Extended"}),d&&V.jsx("span",{className:"rf-text-xs rf-px-1.5 rf-py-0.5 rf-rounded rf-font-medium rf-flex-shrink-0 rf-bg-blue-100 rf-text-blue-700",children:"Direct lookup"}),r.source==="tscircuit.com"&&r.package.is_private&&V.jsx(bvo,{className:"rf-ml-1 rf-h-3 rf-w-3 rf-text-zinc-400 rf-flex-shrink-0"})]}),r.source==="jlcpcb"&&g!=null?V.jsxs("div",{className:"rf-text-xs rf-text-zinc-500 rf-font-medium rf-whitespace-nowrap rf-flex-shrink-0 sm:rf-hidden",children:[g.toLocaleString()," in stock"]}):null]}),V.jsxs("div",{className:"rf-text-xs rf-text-zinc-500 rf-truncate rf-w-full",children:[l?V.jsx("span",{className:"rf-mr-2",children:l}):null,c]})]}),V.jsxs("div",{children:[r.source==="tscircuit.com"&&o?V.jsx("div",{className:"rf-flex-shrink-0 rf-w-full sm:rf-w-auto",children:V.jsx(ta,{variant:"outline",size:"sm",className:"rf-text-xs rf-w-full sm:rf-w-auto",onClick:_=>{_.stopPropagation(),o(r)},children:"See Details"})}):r.source==="jlcpcb"&&g!=null?V.jsxs("div",{className:"rf-hidden sm:rf-block rf-text-xs rf-text-zinc-500 rf-font-medium rf-whitespace-nowrap rf-flex-shrink-0",children:[g.toLocaleString()," in stock"]}):null,u!=null&&V.jsx("div",{className:"rf-hidden sm:rf-block rf-text-xs rf-text-zinc-500 rf-font-medium rf-whitespace-nowrap rf-flex-shrink-0 rf-text-right",children:RKo(u)})]})]},A)})})},HKo=({circuitJson:t,error:e,isLoading:n,height:o})=>V.jsx("section",{className:"rf-flex rf-min-w-0 rf-items-center rf-justify-center",style:{height:o},children:n?V.jsxs("div",{className:"rf-flex rf-w-full rf-items-center rf-justify-center rf-gap-2 rf-bg-zinc-950 rf-text-sm rf-text-zinc-300",style:{height:o},children:[V.jsx(SB,{className:"rf-h-4 rf-w-4 rf-animate-spin"}),"Loading preview..."]}):e?V.jsx("div",{className:"rf-flex rf-w-full rf-items-center rf-justify-center rf-bg-zinc-950 rf-p-4",style:{height:o},children:V.jsxs("div",{className:"rf-flex rf-max-w-[320px] rf-items-start rf-gap-2 rf-text-sm rf-text-zinc-300",children:[V.jsx(qPt,{className:"rf-mt-0.5 rf-h-4 rf-w-4 rf-flex-shrink-0"}),V.jsx("span",{children:e})]})}):t?V.jsx("div",{className:"rf-w-full rf-min-w-0 rf-overflow-hidden",children:V.jsx(pRt,{circuitJson:t,height:o,allowEditing:!1,clickToInteractEnabled:!1,focusOnHover:!1,disablePcbGroups:!0})}):V.jsx("div",{className:"rf-flex rf-w-full rf-items-center rf-justify-center rf-bg-zinc-950 rf-text-sm rf-text-zinc-300",style:{height:o},children:"No preview"})}),lTt={importComponentDialog:101,importComponentDetailsDialog:102},GKo=({packageResult:t,isOpen:e,onOpenChange:n,isLoading:o,details:i,previewTab:r,onPreviewTabChange:A,isSubmitting:s,onImport:a})=>{const c=t?.package??null,l=c?.latest_pcb_preview_image_url,g=c?.latest_sch_preview_image_url,u=c?.latest_cad_preview_image_url,h=c?.unscoped_name?.split("/").pop()??c?.unscoped_name,d=c?.org_owner_tscircuit_handle??void 0,_=d?`https://tscircuit.com/${d}`:void 0,m=d&&h?`https://tscircuit.com/${d}/${h}`:void 0;return V.jsx(MT,{open:e,onOpenChange:n,children:V.jsxs(e6,{showOverlay:!1,style:{width:"calc(100vw - 2rem)",zIndex:lTt.importComponentDetailsDialog},className:"rf-max-w-5xl no-scrollbar !rf-overflow-y-auto rf-max-h-[90vh] rf-overflow-hidden rf-flex rf-flex-col rf-rounded-sm",children:[V.jsx(t6,{className:"rf-pb-4 rf-border-b",children:V.jsx("div",{className:"rf-flex rf-items-start rf-justify-between rf-gap-4",children:V.jsxs("div",{className:"rf-flex-1 rf-min-w-0",children:[V.jsx(n6,{className:"rf-text-xl rf-font-semibold rf-truncate",children:h}),V.jsx(wT,{children:c?.description})]})})}),V.jsxs("div",{className:"rf-flex-1 rf-overflow-y-auto rf-py-4 rf-space-y-6",children:[d?V.jsxs("div",{children:[V.jsx("span",{className:"rf-text-xs rf-font-medium rf-text-gray-500 rf-uppercase rf-tracking-wide",children:"Created by"}),V.jsx("div",{className:"rf-mt-1 rf-text-sm rf-font-medium",children:_?V.jsx("a",{href:_,target:"_blank",rel:"noopener noreferrer",className:"rf-text-black hover:rf-underline",children:d}):d})]}):null,(u||l||g)&&V.jsx(V.Fragment,{children:V.jsxs("div",{children:[V.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-mb-4",children:"Preview"}),V.jsxs(j1e,{value:r,onValueChange:p=>A(p),children:[V.jsxs(YZ,{className:"rf-inline-flex rf-h-9 rf-items-center rf-justify-center rf-rounded-lg rf-bg-zinc-100 rf-p-1 rf-text-zinc-500 dark:rf-bg-zinc-800 dark:rf-text-zinc-400",children:[l&&V.jsx($Q,{value:"pcb",children:"PCB"}),g&&V.jsx($Q,{value:"schematic",children:"Schematic"}),u&&V.jsx($Q,{value:"3d",children:"3D"})]}),V.jsxs("div",{className:"rf-mt-4",children:[V.jsx(IC,{value:"pcb",className:"rf-border rf-rounded-lg rf-overflow-hidden rf-bg-gray-50",children:l?V.jsx("img",{src:l,alt:`${h??"package"} PCB preview`,className:"rf-w-full rf-h-full rf-object-contain rf-bg-white rf-p-4"}):null}),V.jsx(IC,{value:"schematic",className:"rf-border rf-rounded-lg rf-overflow-hidden rf-bg-gray-50",children:g?V.jsx("img",{src:g,alt:`${h??"package"} schematic preview`,className:"rf-w-full rf-h-full rf-object-contain rf-bg-white rf-p-4"}):null}),V.jsx(IC,{value:"3d",className:"rf-border rf-rounded-lg rf-overflow-hidden rf-bg-gray-50",children:u?V.jsx("img",{src:u,alt:`${h??"package"} 3D preview`,className:"rf-w-full rf-h-full rf-object-contain rf-bg-white rf-p-4"}):null})]})]})]})}),i?.ai_description?V.jsxs("section",{children:[V.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-mb-3",children:"AI Description"}),V.jsx("div",{className:"rf-bg-gray-50 rf-border rf-border-gray-200 rf-rounded-lg rf-p-4",children:V.jsx("p",{className:"rf-text-sm rf-text-gray-700 rf-leading-relaxed",children:i.ai_description})})]}):null,i?.ai_usage_instructions?V.jsxs("section",{children:[V.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-mb-3",children:"Usage Instructions"}),V.jsx("div",{className:"rf-bg-gray-50 rf-border rf-border-gray-200 rf-rounded-lg rf-p-4",children:V.jsx("p",{className:"rf-text-sm rf-text-gray-700 rf-leading-relaxed rf-whitespace-pre-wrap",children:i.ai_usage_instructions})})]}):null,o?V.jsxs("div",{className:"rf-flex rf-justify-center rf-items-center rf-gap-2 rf-text-gray-500",children:[V.jsx(SB,{className:"rf-h-4 rf-w-4 rf-animate-spin"}),V.jsx("span",{className:"rf-text-sm",children:"Loading package details..."})]}):null]}),V.jsxs(iU,{className:"rf-pt-4 rf-border-t rf-flex rf-flex-col sm:rf-flex-row rf-justify-between rf-gap-2",children:[V.jsx("div",{className:"rf-flex-1",children:m?V.jsxs(ta,{variant:"outline",size:"sm",className:"rf-gap-2 rf-w-full sm:rf-w-auto",onClick:()=>window.open(m,"_blank"),children:[V.jsx(fvo,{className:"rf-h-4 rf-w-4"}),"View on tscircuit.com"]}):null}),V.jsxs("div",{className:"rf-flex rf-flex-col sm:rf-flex-row rf-gap-2",children:[V.jsx(ta,{variant:"outline",onClick:()=>n(!1),className:"rf-order-2 sm:rf-order-1",children:"Close"}),V.jsx(ta,{onClick:a,disabled:s,className:"rf-bg-blue-600 hover:rf-bg-blue-700",children:s?V.jsx(SB,{className:"rf-h-4 rf-w-4 rf-animate-spin"}):"Import Component"})]})]})]})})},OKo=()=>{const[t,e]=X.useState(null),[n,o]=X.useState(!1),i=X.useCallback(async(A,s)=>{o(!0);try{const a=await fetch(`https://api.tscircuit.com/packages/get?name=${encodeURIComponent(`${A}/${s}`)}`);if(!a.ok)throw new Error(`Failed to load package details: ${a.status}`);const c=await a.json();e(c.package??null)}catch(a){console.error("Failed to fetch package details",a),e(null)}finally{o(!1)}},[]),r=X.useCallback(()=>{e(null),o(!1)},[]);return{details:t,isLoading:n,fetchDetails:i,reset:r}},KKo=(t,e)=>{const[n,o]=X.useState({circuitJson:null,error:null,isLoading:!1});return X.useEffect(()=>{if(!t||!aTt(t)){o({circuitJson:null,error:null,isLoading:!1});return}let i=!1;return o({circuitJson:null,error:null,isLoading:!0}),PKo(t,e).then(r=>{i||o({circuitJson:r,error:null,isLoading:!1})}).catch(r=>{i||o({circuitJson:null,error:r instanceof Error?r.message:"Failed to load footprint preview",isLoading:!1})}),()=>{i=!0}},[t,e]),n},UKo=async(t,e)=>{const n={"Content-Type":"application/json"};e&&(n.Authorization=`Bearer ${e}`);const o=await fetch("https://registry-api.tscircuit.com/packages/search",{method:"POST",headers:n,body:JSON.stringify({query:t})});if(!o.ok)throw new Error(`tscircuit registry error: ${o.status}`);return(await o.json()).packages??[]},YKo=({sessionToken:t})=>{const[e,n]=X.useState([]),[o,i]=X.useState(!1),[r,A]=X.useState(null),[s,a]=X.useState(!1),c=X.useCallback(async g=>{const u=g.trim();if(!u)return[];i(!0),A(null);try{const d=(await UKo(u,t)).map(_=>({source:"tscircuit.com",package:_}));return n(d),d}catch(h){return console.error("Error searching tscircuit packages",h),n([]),A(h instanceof Error?h.message:"Failed to search tscircuit packages"),[]}finally{i(!1),a(!0)}},[t]),l=X.useCallback(()=>{n([]),i(!1),A(null),a(!1)},[]);return{results:e,isSearching:o,error:r,hasSearched:s,search:c,reset:l}},zKo=t=>{const e=/^C(\d+)$/i.exec(t.trim());if(!e)return null;const n=Number(e[1]);if(!Number.isSafeInteger(n))return null;const o=`C${e[1]}`;return{source:"jlcpcb",component:{lcscId:n,manufacturer:o,partNumber:o,description:"Import directly from EasyEDA; stock and availability are unknown",package:"",isDirectLookup:!0}}},gTt=(t,e)=>{const n=zKo(t);return n?e.some(i=>i.component.partNumber.toUpperCase()===n.component.partNumber)?e:[n,...e]:e},VKo=t=>{const e=t.trim();return/^C\d+/i.test(e)?e.replace(/^C/i,""):e},JKo=()=>{const[t,e]=X.useState([]),[n,o]=X.useState(!1),[i,r]=X.useState(null),[A,s]=X.useState(!1),a=X.useCallback(async l=>{const g=VKo(l);if(!g)return[];o(!0),r(null);try{const u=await kOo(g,10),h=gTt(l,u.map(d=>({source:"jlcpcb",component:FOo(d)})));return e(h),h}catch(u){console.error("Error searching JLCPCB components",u);const h=gTt(l,[]);return e(h),r(h.length>0?null:u instanceof Error?u.message:"Failed to search JLCPCB components"),h}finally{o(!1),s(!0)}},[]),c=X.useCallback(()=>{e([]),o(!1),r(null),s(!1)},[]);return{results:t,isSearching:n,error:i,hasSearched:A,search:a,reset:c}},qKo=()=>{const[t,e]=X.useState([]),[n,o]=X.useState(!1),[i,r]=X.useState(null),[A,s]=X.useState(!1),a=X.useCallback(async l=>{const g=l.trim();if(!g)return[];o(!0),r(null);try{const h=(await bKo(g,20)).map(d=>({source:"kicad",footprint:DKo(d)}));return e(h),h}catch(u){return console.error("Error searching KiCad footprints",u),e([]),r(u instanceof Error?u.message:"Failed to search KiCad footprints"),[]}finally{o(!1),s(!0)}},[]),c=X.useCallback(()=>{e([]),o(!1),r(null),s(!1)},[]);return{results:t,isSearching:n,error:i,hasSearched:A,search:a,reset:c}},WKo=({onTscircuitPackageSelected:t,onJlcpcbComponentTsxLoaded:e,onKicadStringSelected:n})=>{const o=[];return t&&o.push("tscircuit.com"),e&&o.push("jlcpcb"),n&&o.push("kicad"),o},jKo=({isOpen:t,onClose:e,jlcpcbProxyRequestHeaders:n,onKicadStringSelected:o,onTscircuitPackageSelected:i,onJlcpcbComponentTsxLoaded:r,jlcpcbProxyApiBase:A,tscircuitSessionToken:s})=>{Mie();const a=X.useMemo(()=>WKo({onKicadStringSelected:o,onTscircuitPackageSelected:i,onJlcpcbComponentTsxLoaded:r}),[o,i,r]),c=a.length>0,l=a.length===1,[g,u]=X.useState(a[0]??"tscircuit.com"),[h,d]=X.useState(""),[_,m]=X.useState(null),{results:p,isSearching:C,error:I,hasSearched:f,search:y,reset:x}=YKo({sessionToken:s}),{results:B,isSearching:S,error:D,hasSearched:w,search:F,reset:R}=JKo(),{results:H,isSearching:G,error:K,hasSearched:J,search:W,reset:j}=qKo(),{details:se,isLoading:Ae,fetchDetails:ee,reset:oe}=OKo(),[ae,ie]=X.useState(null),[le,fe]=X.useState(!1),[xe,Qe]=X.useState("pcb"),[he,be]=X.useState(null),[me,Ke]=X.useState(!1),Je=X.useMemo(()=>({jlcpcb:{headers:n,apiBase:A}}),[A,n]),{circuitJson:et,error:Ce,isLoading:Ze}=KKo(_,Je),Oe=aTt(_);X.useEffect(()=>{be(null)},[_]);const Ye=X.useCallback(()=>{x(),R(),j(),m(null)},[R,j,x]);X.useEffect(()=>{t||(Ye(),d(""),fe(!1),ie(null),be(null))},[t,Ye]),X.useEffect(()=>{d(""),m(null),g==="tscircuit.com"?x():g==="jlcpcb"?R():g==="kicad"&&j()},[g,R,j,x]);const qe=gt=>{m(gt),ie(gt),Qe("pcb"),fe(!0),oe();const Ct=gt.package.org_owner_tscircuit_handle,Dt=gt.package.unscoped_name;if(Ct&&Dt){const mt=Dt.split("/").pop()??Dt;ee(Ct,mt)}},He=async()=>{h.trim()&&(m(null),g==="tscircuit.com"?await y(h):g==="jlcpcb"?await F(h):g==="kicad"&&await W(h))},Pe=async gt=>{try{if(be(null),Ke(!0),gt.source==="kicad"){if(!o)throw new Error("KiCad handler not provided");await o({result:gt,footprint:gt.footprint.qualifiedName})}else if(gt.source==="jlcpcb"){if(!r)throw new Error("JLCPCB handler not provided");const Ct=await LOo(gt.component.partNumber,{headers:n,apiBase:A});await r({result:gt,tsx:Ct})}else if(gt.source==="tscircuit.com"){if(!i)throw new Error("tscircuit package handler not provided");const Ct=gt.package.org_owner_tscircuit_handle,Dt=gt.package.unscoped_name;if(!Ct||!Dt)throw new Error("Missing package metadata");const mt=Dt.split("/").pop()??Dt,Nt=`@tsci/${Ct}.${mt}`;await i({result:gt,fullPackageName:Nt})}return!0}catch(Ct){return console.error("Failed to import component",Ct),be(Ct instanceof Error?Ct.message:"Failed to import component"),!1}finally{Ke(!1)}};let ve=[],De=!1,ze=null,Xe=!1;g==="tscircuit.com"?(ve=p,De=C,ze=I,Xe=f):g==="jlcpcb"?(ve=B,De=S,ze=D,Xe=w):g==="kicad"&&(ve=H,De=G,ze=K,Xe=J);const st=async()=>{if(!_)return;await Pe(_)&&(e(),Ye(),d(""))},ct=gt=>{gt||e()},ut=gt=>{fe(gt),gt||ie(null)};return V.jsxs(MT,{open:t,onOpenChange:ct,children:[V.jsxs(e6,{style:{width:"calc(100vw - 2rem)",maxWidth:Oe?"min(1120px, calc(100vw - 2rem))":"min(672px, calc(100vw - 2rem))",zIndex:lTt.importComponentDialog},className:"rf-rounded-sm rf-max-h-[90vh] rf-overflow-y-auto rf-overflow-x-hidden rf-flex rf-flex-col",children:[V.jsxs(t6,{children:[V.jsxs(n6,{className:"rf-text-lg sm:rf-text-xl",children:["Import ",l?Rie[g].label:""," ","Component"]}),V.jsx(wT,{className:"rf-text-sm",children:c?"Search for components from available sources.":"Import options are disabled because no handlers were provided."})]}),c?V.jsxs(j1e,{value:g,onValueChange:gt=>u(gt),className:"rf-min-w-0 rf-w-full",children:[!l&&V.jsx(YZ,{className:"rf-flex rf-w-full rf-gap-2",children:a.map(gt=>V.jsx($Q,{value:gt,className:"rf-flex-1 rf-text-xs sm:rf-text-sm",children:Rie[gt].label},gt))}),V.jsxs("div",{className:"rf-min-w-0",style:Oe?{display:"grid",gridTemplateColumns:"minmax(0, 1fr) minmax(360px, 0.95fr)",gap:"1.5rem",alignItems:"start"}:void 0,children:[V.jsxs("div",{className:"rf-min-w-0",children:[V.jsx(vKo,{query:h,placeholder:Rie[g].placeholder,isSearching:De,onQueryChange:d,onSubmit:He}),V.jsx("div",{className:"no-scrollbar rf-mt-4 rf-flex-1 rf-min-h-[200px] !rf-max-h-[40vh] !rf-overflow-y-auto rf-overflow-x-hidden rf-border rf-rounded-md rf-min-w-0",children:De?V.jsxs("div",{className:"rf-p-8 rf-text-center rf-text-zinc-500",children:[V.jsx(SB,{className:"rf-h-8 rf-w-8 rf-animate-spin rf-mx-auto rf-mb-2"}),V.jsx("p",{children:"Searching..."})]}):ve.length>0?V.jsx(LKo,{results:ve,selected:_,onSelect:m,onShowDetails:g==="tscircuit.com"?qe:void 0}):V.jsx("div",{className:"rf-p-8 rf-text-center rf-text-zinc-500",children:ze?`Error: ${ze}`:Xe?Rie[g].emptyMessage:"Enter a search term to find components"})})]}),Oe?V.jsx("div",{className:"rf-mt-4",children:V.jsx(HKo,{circuitJson:et,error:Ce,isLoading:Ze,height:325})}):null]})]}):null,he?V.jsx("div",{className:"rf-text-sm rf-text-red-600 rf-mt-2",children:he}):null,V.jsxs(iU,{className:"rf-flex rf-flex-col sm:rf-flex-row rf-gap-2",children:[V.jsx(ta,{variant:"outline",onClick:e,className:"rf-order-2 sm:rf-order-1",children:"Cancel"}),V.jsx(ta,{onClick:st,disabled:!_||me,className:"rf-order-1 sm:rf-order-2",children:me?V.jsx(SB,{className:"rf-h-4 rf-w-4 rf-animate-spin"}):"Import"})]})]}),V.jsx(GKo,{packageResult:ae,isOpen:le,onOpenChange:ut,isLoading:Ae,details:se,previewTab:xe,onPreviewTabChange:gt=>Qe(gt),isSubmitting:me,onImport:()=>{ae&&Pe(ae).then(gt=>{gt&&(fe(!1),e(),Ye(),d(""))})}})]})},XKo=t=>{const e=t.match(/export const (\w+) =/);if(!e)throw new Error("Could not determine component name from TSX contents");return e[1]},uTt=t=>{const e=zu(A=>A.pushEvent),n=zu(A=>A.upsertFile),o=async({result:A,fullPackageName:s})=>{const c=A.package.unscoped_name??A.package.name;await zA.promise(e({event_type:"INSTALL_PACKAGE",full_package_name:s}),{loading:`Requesting install for "${c}"`,success:`Install requested for "${c}"`,error:l=>`Failed to request install: ${l instanceof Error?l.message:String(l)}`})},i=async({footprint:A})=>{await zA.promise(navigator.clipboard.writeText(A),{loading:`Copying "${A}"`,success:`Copied "${A}" to clipboard`,error:s=>`Failed to copy footprint: ${s instanceof Error?s.message:String(s)}`})},r=async({result:A,tsx:s})=>{const c=`imports/${XKo(s)}.tsx`;await zA.promise(n(c,s),{loading:`Importing ${A.component.partNumber}`,success:`Imported to "${c}"`,error:l=>`Failed to import component: ${l instanceof Error?l.message:String(l)}`})};return V.jsx(jKo,{...t,onTscircuitPackageSelected:o,onKicadStringSelected:i,onJlcpcbComponentTsxLoaded:r})};uTt.displayName="ImportComponentDialogForCli";var n6e={exports:{}},dTt;function $Ko(){return dTt||(dTt=1,(function(t,e){var n={env:{},version:""};(function(o){t.exports=o()})(function(){return(function o(i,r,A){function s(l,g){if(!r[l]){if(!i[l]){var u=typeof H4=="function"&&H4;if(!g&&u)return u(l,!0);if(a)return a(l,!0);var h=new Error("Cannot find module '"+l+"'");throw h.code="MODULE_NOT_FOUND",h}var d=r[l]={exports:{}};i[l][0].call(d.exports,function(_){var m=i[l][1][_];return s(m||_)},d,d.exports,o,i,r,A)}return r[l].exports}for(var a=typeof H4=="function"&&H4,c=0;c<A.length;c++)s(A[c]);return s})({1:[function(o,i,r){var A=o("./utils"),s=o("./support"),a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";r.encode=function(c){for(var l,g,u,h,d,_,m,p=[],C=0,I=c.length,f=I,y=A.getTypeOf(c)!=="string";C<c.length;)f=I-C,u=y?(l=c[C++],g=C<I?c[C++]:0,C<I?c[C++]:0):(l=c.charCodeAt(C++),g=C<I?c.charCodeAt(C++):0,C<I?c.charCodeAt(C++):0),h=l>>2,d=(3&l)<<4|g>>4,_=1<f?(15&g)<<2|u>>6:64,m=2<f?63&u:64,p.push(a.charAt(h)+a.charAt(d)+a.charAt(_)+a.charAt(m));return p.join("")},r.decode=function(c){var l,g,u,h,d,_,m=0,p=0,C="data:";if(c.substr(0,C.length)===C)throw new Error("Invalid base64 input, it looks like a data url.");var I,f=3*(c=c.replace(/[^A-Za-z0-9+/=]/g,"")).length/4;if(c.charAt(c.length-1)===a.charAt(64)&&f--,c.charAt(c.length-2)===a.charAt(64)&&f--,f%1!=0)throw new Error("Invalid base64 input, bad content length.");for(I=s.uint8array?new Uint8Array(0|f):new Array(0|f);m<c.length;)l=a.indexOf(c.charAt(m++))<<2|(h=a.indexOf(c.charAt(m++)))>>4,g=(15&h)<<4|(d=a.indexOf(c.charAt(m++)))>>2,u=(3&d)<<6|(_=a.indexOf(c.charAt(m++))),I[p++]=l,d!==64&&(I[p++]=g),_!==64&&(I[p++]=u);return I}},{"./support":30,"./utils":32}],2:[function(o,i,r){var A=o("./external"),s=o("./stream/DataWorker"),a=o("./stream/Crc32Probe"),c=o("./stream/DataLengthProbe");function l(g,u,h,d,_){this.compressedSize=g,this.uncompressedSize=u,this.crc32=h,this.compression=d,this.compressedContent=_}l.prototype={getContentWorker:function(){var g=new s(A.Promise.resolve(this.compressedContent)).pipe(this.compression.uncompressWorker()).pipe(new c("data_length")),u=this;return g.on("end",function(){if(this.streamInfo.data_length!==u.uncompressedSize)throw new Error("Bug : uncompressed data size mismatch")}),g},getCompressedWorker:function(){return new s(A.Promise.resolve(this.compressedContent)).withStreamInfo("compressedSize",this.compressedSize).withStreamInfo("uncompressedSize",this.uncompressedSize).withStreamInfo("crc32",this.crc32).withStreamInfo("compression",this.compression)}},l.createWorkerFrom=function(g,u,h){return g.pipe(new a).pipe(new c("uncompressedSize")).pipe(u.compressWorker(h)).pipe(new c("compressedSize")).withStreamInfo("compression",u)},i.exports=l},{"./external":6,"./stream/Crc32Probe":25,"./stream/DataLengthProbe":26,"./stream/DataWorker":27}],3:[function(o,i,r){var A=o("./stream/GenericWorker");r.STORE={magic:"\0\0",compressWorker:function(){return new A("STORE compression")},uncompressWorker:function(){return new A("STORE decompression")}},r.DEFLATE=o("./flate")},{"./flate":7,"./stream/GenericWorker":28}],4:[function(o,i,r){var A=o("./utils"),s=(function(){for(var a,c=[],l=0;l<256;l++){a=l;for(var g=0;g<8;g++)a=1&a?3988292384^a>>>1:a>>>1;c[l]=a}return c})();i.exports=function(a,c){return a!==void 0&&a.length?A.getTypeOf(a)!=="string"?(function(l,g,u,h){var d=s,_=h+u;l^=-1;for(var m=h;m<_;m++)l=l>>>8^d[255&(l^g[m])];return-1^l})(0|c,a,a.length,0):(function(l,g,u,h){var d=s,_=h+u;l^=-1;for(var m=h;m<_;m++)l=l>>>8^d[255&(l^g.charCodeAt(m))];return-1^l})(0|c,a,a.length,0):0}},{"./utils":32}],5:[function(o,i,r){r.base64=!1,r.binary=!1,r.dir=!1,r.createFolders=!0,r.date=null,r.compression=null,r.compressionOptions=null,r.comment=null,r.unixPermissions=null,r.dosPermissions=null},{}],6:[function(o,i,r){var A=null;A=typeof Promise<"u"?Promise:o("lie"),i.exports={Promise:A}},{lie:37}],7:[function(o,i,r){var A=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Uint32Array<"u",s=o("pako"),a=o("./utils"),c=o("./stream/GenericWorker"),l=A?"uint8array":"array";function g(u,h){c.call(this,"FlateWorker/"+u),this._pako=null,this._pakoAction=u,this._pakoOptions=h,this.meta={}}r.magic="\b\0",a.inherits(g,c),g.prototype.processChunk=function(u){this.meta=u.meta,this._pako===null&&this._createPako(),this._pako.push(a.transformTo(l,u.data),!1)},g.prototype.flush=function(){c.prototype.flush.call(this),this._pako===null&&this._createPako(),this._pako.push([],!0)},g.prototype.cleanUp=function(){c.prototype.cleanUp.call(this),this._pako=null},g.prototype._createPako=function(){this._pako=new s[this._pakoAction]({raw:!0,level:this._pakoOptions.level||-1});var u=this;this._pako.onData=function(h){u.push({data:h,meta:u.meta})}},r.compressWorker=function(u){return new g("Deflate",u)},r.uncompressWorker=function(){return new g("Inflate",{})}},{"./stream/GenericWorker":28,"./utils":32,pako:38}],8:[function(o,i,r){function A(d,_){var m,p="";for(m=0;m<_;m++)p+=String.fromCharCode(255&d),d>>>=8;return p}function s(d,_,m,p,C,I){var f,y,x=d.file,B=d.compression,S=I!==l.utf8encode,D=a.transformTo("string",I(x.name)),w=a.transformTo("string",l.utf8encode(x.name)),F=x.comment,R=a.transformTo("string",I(F)),H=a.transformTo("string",l.utf8encode(F)),G=w.length!==x.name.length,K=H.length!==F.length,J="",W="",j="",se=x.dir,Ae=x.date,ee={crc32:0,compressedSize:0,uncompressedSize:0};_&&!m||(ee.crc32=d.crc32,ee.compressedSize=d.compressedSize,ee.uncompressedSize=d.uncompressedSize);var oe=0;_&&(oe|=8),S||!G&&!K||(oe|=2048);var ae=0,ie=0;se&&(ae|=16),C==="UNIX"?(ie=798,ae|=(function(fe,xe){var Qe=fe;return fe||(Qe=xe?16893:33204),(65535&Qe)<<16})(x.unixPermissions,se)):(ie=20,ae|=(function(fe){return 63&(fe||0)})(x.dosPermissions)),f=Ae.getUTCHours(),f<<=6,f|=Ae.getUTCMinutes(),f<<=5,f|=Ae.getUTCSeconds()/2,y=Ae.getUTCFullYear()-1980,y<<=4,y|=Ae.getUTCMonth()+1,y<<=5,y|=Ae.getUTCDate(),G&&(W=A(1,1)+A(g(D),4)+w,J+="up"+A(W.length,2)+W),K&&(j=A(1,1)+A(g(R),4)+H,J+="uc"+A(j.length,2)+j);var le="";return le+=`
|
|
5760
5760
|
\0`,le+=A(oe,2),le+=B.magic,le+=A(f,2),le+=A(y,2),le+=A(ee.crc32,4),le+=A(ee.compressedSize,4),le+=A(ee.uncompressedSize,4),le+=A(D.length,2),le+=A(J.length,2),{fileRecord:u.LOCAL_FILE_HEADER+le+D+J,dirRecord:u.CENTRAL_FILE_HEADER+A(ie,2)+le+A(R.length,2)+"\0\0\0\0"+A(ae,4)+A(p,4)+D+J+R}}var a=o("../utils"),c=o("../stream/GenericWorker"),l=o("../utf8"),g=o("../crc32"),u=o("../signature");function h(d,_,m,p){c.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=_,this.zipPlatform=m,this.encodeFileName=p,this.streamFiles=d,this.accumulate=!1,this.contentBuffer=[],this.dirRecords=[],this.currentSourceOffset=0,this.entriesCount=0,this.currentFile=null,this._sources=[]}a.inherits(h,c),h.prototype.push=function(d){var _=d.meta.percent||0,m=this.entriesCount,p=this._sources.length;this.accumulate?this.contentBuffer.push(d):(this.bytesWritten+=d.data.length,c.prototype.push.call(this,{data:d.data,meta:{currentFile:this.currentFile,percent:m?(_+100*(m-p-1))/m:100}}))},h.prototype.openedSource=function(d){this.currentSourceOffset=this.bytesWritten,this.currentFile=d.file.name;var _=this.streamFiles&&!d.file.dir;if(_){var m=s(d,_,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:m.fileRecord,meta:{percent:0}})}else this.accumulate=!0},h.prototype.closedSource=function(d){this.accumulate=!1;var _=this.streamFiles&&!d.file.dir,m=s(d,_,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(m.dirRecord),_)this.push({data:(function(p){return u.DATA_DESCRIPTOR+A(p.crc32,4)+A(p.compressedSize,4)+A(p.uncompressedSize,4)})(d),meta:{percent:100}});else for(this.push({data:m.fileRecord,meta:{percent:0}});this.contentBuffer.length;)this.push(this.contentBuffer.shift());this.currentFile=null},h.prototype.flush=function(){for(var d=this.bytesWritten,_=0;_<this.dirRecords.length;_++)this.push({data:this.dirRecords[_],meta:{percent:100}});var m=this.bytesWritten-d,p=(function(C,I,f,y,x){var B=a.transformTo("string",x(y));return u.CENTRAL_DIRECTORY_END+"\0\0\0\0"+A(C,2)+A(C,2)+A(I,4)+A(f,4)+A(B.length,2)+B})(this.dirRecords.length,m,d,this.zipComment,this.encodeFileName);this.push({data:p,meta:{percent:100}})},h.prototype.prepareNextSource=function(){this.previous=this._sources.shift(),this.openedSource(this.previous.streamInfo),this.isPaused?this.previous.pause():this.previous.resume()},h.prototype.registerPrevious=function(d){this._sources.push(d);var _=this;return d.on("data",function(m){_.processChunk(m)}),d.on("end",function(){_.closedSource(_.previous.streamInfo),_._sources.length?_.prepareNextSource():_.end()}),d.on("error",function(m){_.error(m)}),this},h.prototype.resume=function(){return!!c.prototype.resume.call(this)&&(!this.previous&&this._sources.length?(this.prepareNextSource(),!0):this.previous||this._sources.length||this.generatedError?void 0:(this.end(),!0))},h.prototype.error=function(d){var _=this._sources;if(!c.prototype.error.call(this,d))return!1;for(var m=0;m<_.length;m++)try{_[m].error(d)}catch{}return!0},h.prototype.lock=function(){c.prototype.lock.call(this);for(var d=this._sources,_=0;_<d.length;_++)d[_].lock()},i.exports=h},{"../crc32":4,"../signature":23,"../stream/GenericWorker":28,"../utf8":31,"../utils":32}],9:[function(o,i,r){var A=o("../compressions"),s=o("./ZipFileWorker");r.generateWorker=function(a,c,l){var g=new s(c.streamFiles,l,c.platform,c.encodeFileName),u=0;try{a.forEach(function(h,d){u++;var _=(function(I,f){var y=I||f,x=A[y];if(!x)throw new Error(y+" is not a valid compression method !");return x})(d.options.compression,c.compression),m=d.options.compressionOptions||c.compressionOptions||{},p=d.dir,C=d.date;d._compressWorker(_,m).withStreamInfo("file",{name:h,dir:p,date:C,comment:d.comment||"",unixPermissions:d.unixPermissions,dosPermissions:d.dosPermissions}).pipe(g)}),g.entriesCount=u}catch(h){g.error(h)}return g}},{"../compressions":3,"./ZipFileWorker":8}],10:[function(o,i,r){function A(){if(!(this instanceof A))return new A;if(arguments.length)throw new Error("The constructor with parameters has been removed in JSZip 3.0, please check the upgrade guide.");this.files=Object.create(null),this.comment=null,this.root="",this.clone=function(){var s=new A;for(var a in this)typeof this[a]!="function"&&(s[a]=this[a]);return s}}(A.prototype=o("./object")).loadAsync=o("./load"),A.support=o("./support"),A.defaults=o("./defaults"),A.version="3.10.1",A.loadAsync=function(s,a){return new A().loadAsync(s,a)},A.external=o("./external"),i.exports=A},{"./defaults":5,"./external":6,"./load":11,"./object":15,"./support":30}],11:[function(o,i,r){var A=o("./utils"),s=o("./external"),a=o("./utf8"),c=o("./zipEntries"),l=o("./stream/Crc32Probe"),g=o("./nodejsUtils");function u(h){return new s.Promise(function(d,_){var m=h.decompressed.getContentWorker().pipe(new l);m.on("error",function(p){_(p)}).on("end",function(){m.streamInfo.crc32!==h.decompressed.crc32?_(new Error("Corrupted zip : CRC32 mismatch")):d()}).resume()})}i.exports=function(h,d){var _=this;return d=A.extend(d||{},{base64:!1,checkCRC32:!1,optimizedBinaryString:!1,createFolders:!1,decodeFileName:a.utf8decode}),g.isNode&&g.isStream(h)?s.Promise.reject(new Error("JSZip can't accept a stream when loading a zip file.")):A.prepareContent("the loaded zip file",h,!0,d.optimizedBinaryString,d.base64).then(function(m){var p=new c(d);return p.load(m),p}).then(function(m){var p=[s.Promise.resolve(m)],C=m.files;if(d.checkCRC32)for(var I=0;I<C.length;I++)p.push(u(C[I]));return s.Promise.all(p)}).then(function(m){for(var p=m.shift(),C=p.files,I=0;I<C.length;I++){var f=C[I],y=f.fileNameStr,x=A.resolve(f.fileNameStr);_.file(x,f.decompressed,{binary:!0,optimizedBinaryString:!0,date:f.date,dir:f.dir,comment:f.fileCommentStr.length?f.fileCommentStr:null,unixPermissions:f.unixPermissions,dosPermissions:f.dosPermissions,createFolders:d.createFolders}),f.dir||(_.file(x).unsafeOriginalName=y)}return p.zipComment.length&&(_.comment=p.zipComment),_})}},{"./external":6,"./nodejsUtils":14,"./stream/Crc32Probe":25,"./utf8":31,"./utils":32,"./zipEntries":33}],12:[function(o,i,r){var A=o("../utils"),s=o("../stream/GenericWorker");function a(c,l){s.call(this,"Nodejs stream input adapter for "+c),this._upstreamEnded=!1,this._bindStream(l)}A.inherits(a,s),a.prototype._bindStream=function(c){var l=this;(this._stream=c).pause(),c.on("data",function(g){l.push({data:g,meta:{percent:0}})}).on("error",function(g){l.isPaused?this.generatedError=g:l.error(g)}).on("end",function(){l.isPaused?l._upstreamEnded=!0:l.end()})},a.prototype.pause=function(){return!!s.prototype.pause.call(this)&&(this._stream.pause(),!0)},a.prototype.resume=function(){return!!s.prototype.resume.call(this)&&(this._upstreamEnded?this.end():this._stream.resume(),!0)},i.exports=a},{"../stream/GenericWorker":28,"../utils":32}],13:[function(o,i,r){var A=o("readable-stream").Readable;function s(a,c,l){A.call(this,c),this._helper=a;var g=this;a.on("data",function(u,h){g.push(u)||g._helper.pause(),l&&l(h)}).on("error",function(u){g.emit("error",u)}).on("end",function(){g.push(null)})}o("../utils").inherits(s,A),s.prototype._read=function(){this._helper.resume()},i.exports=s},{"../utils":32,"readable-stream":16}],14:[function(o,i,r){i.exports={isNode:typeof Buffer<"u",newBufferFrom:function(A,s){if(Buffer.from&&Buffer.from!==Uint8Array.from)return Buffer.from(A,s);if(typeof A=="number")throw new Error('The "data" argument must not be a number');return new Buffer(A,s)},allocBuffer:function(A){if(Buffer.alloc)return Buffer.alloc(A);var s=new Buffer(A);return s.fill(0),s},isBuffer:function(A){return Buffer.isBuffer(A)},isStream:function(A){return A&&typeof A.on=="function"&&typeof A.pause=="function"&&typeof A.resume=="function"}}},{}],15:[function(o,i,r){function A(x,B,S){var D,w=a.getTypeOf(B),F=a.extend(S||{},g);F.date=F.date||new Date,F.compression!==null&&(F.compression=F.compression.toUpperCase()),typeof F.unixPermissions=="string"&&(F.unixPermissions=parseInt(F.unixPermissions,8)),F.unixPermissions&&16384&F.unixPermissions&&(F.dir=!0),F.dosPermissions&&16&F.dosPermissions&&(F.dir=!0),F.dir&&(x=C(x)),F.createFolders&&(D=p(x))&&I.call(this,D,!0);var R=w==="string"&&F.binary===!1&&F.base64===!1;S&&S.binary!==void 0||(F.binary=!R),(B instanceof u&&B.uncompressedSize===0||F.dir||!B||B.length===0)&&(F.base64=!1,F.binary=!0,B="",F.compression="STORE",w="string");var H=null;H=B instanceof u||B instanceof c?B:_.isNode&&_.isStream(B)?new m(x,B):a.prepareContent(x,B,F.binary,F.optimizedBinaryString,F.base64);var G=new h(x,H,F);this.files[x]=G}var s=o("./utf8"),a=o("./utils"),c=o("./stream/GenericWorker"),l=o("./stream/StreamHelper"),g=o("./defaults"),u=o("./compressedObject"),h=o("./zipObject"),d=o("./generate"),_=o("./nodejsUtils"),m=o("./nodejs/NodejsStreamInputAdapter"),p=function(x){x.slice(-1)==="/"&&(x=x.substring(0,x.length-1));var B=x.lastIndexOf("/");return 0<B?x.substring(0,B):""},C=function(x){return x.slice(-1)!=="/"&&(x+="/"),x},I=function(x,B){return B=B!==void 0?B:g.createFolders,x=C(x),this.files[x]||A.call(this,x,null,{dir:!0,createFolders:B}),this.files[x]};function f(x){return Object.prototype.toString.call(x)==="[object RegExp]"}var y={load:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},forEach:function(x){var B,S,D;for(B in this.files)D=this.files[B],(S=B.slice(this.root.length,B.length))&&B.slice(0,this.root.length)===this.root&&x(S,D)},filter:function(x){var B=[];return this.forEach(function(S,D){x(S,D)&&B.push(D)}),B},file:function(x,B,S){if(arguments.length!==1)return x=this.root+x,A.call(this,x,B,S),this;if(f(x)){var D=x;return this.filter(function(F,R){return!R.dir&&D.test(F)})}var w=this.files[this.root+x];return w&&!w.dir?w:null},folder:function(x){if(!x)return this;if(f(x))return this.filter(function(w,F){return F.dir&&x.test(w)});var B=this.root+x,S=I.call(this,B),D=this.clone();return D.root=S.name,D},remove:function(x){x=this.root+x;var B=this.files[x];if(B||(x.slice(-1)!=="/"&&(x+="/"),B=this.files[x]),B&&!B.dir)delete this.files[x];else for(var S=this.filter(function(w,F){return F.name.slice(0,x.length)===x}),D=0;D<S.length;D++)delete this.files[S[D].name];return this},generate:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},generateInternalStream:function(x){var B,S={};try{if((S=a.extend(x||{},{streamFiles:!1,compression:"STORE",compressionOptions:null,type:"",platform:"DOS",comment:null,mimeType:"application/zip",encodeFileName:s.utf8encode})).type=S.type.toLowerCase(),S.compression=S.compression.toUpperCase(),S.type==="binarystring"&&(S.type="string"),!S.type)throw new Error("No output type specified.");a.checkSupport(S.type),S.platform!=="darwin"&&S.platform!=="freebsd"&&S.platform!=="linux"&&S.platform!=="sunos"||(S.platform="UNIX"),S.platform==="win32"&&(S.platform="DOS");var D=S.comment||this.comment||"";B=d.generateWorker(this,S,D)}catch(w){(B=new c("error")).error(w)}return new l(B,S.type||"string",S.mimeType)},generateAsync:function(x,B){return this.generateInternalStream(x).accumulate(B)},generateNodeStream:function(x,B){return(x=x||{}).type||(x.type="nodebuffer"),this.generateInternalStream(x).toNodejsStream(B)}};i.exports=y},{"./compressedObject":2,"./defaults":5,"./generate":9,"./nodejs/NodejsStreamInputAdapter":12,"./nodejsUtils":14,"./stream/GenericWorker":28,"./stream/StreamHelper":29,"./utf8":31,"./utils":32,"./zipObject":35}],16:[function(o,i,r){i.exports=o("stream")},{stream:void 0}],17:[function(o,i,r){var A=o("./DataReader");function s(a){A.call(this,a);for(var c=0;c<this.data.length;c++)a[c]=255&a[c]}o("../utils").inherits(s,A),s.prototype.byteAt=function(a){return this.data[this.zero+a]},s.prototype.lastIndexOfSignature=function(a){for(var c=a.charCodeAt(0),l=a.charCodeAt(1),g=a.charCodeAt(2),u=a.charCodeAt(3),h=this.length-4;0<=h;--h)if(this.data[h]===c&&this.data[h+1]===l&&this.data[h+2]===g&&this.data[h+3]===u)return h-this.zero;return-1},s.prototype.readAndCheckSignature=function(a){var c=a.charCodeAt(0),l=a.charCodeAt(1),g=a.charCodeAt(2),u=a.charCodeAt(3),h=this.readData(4);return c===h[0]&&l===h[1]&&g===h[2]&&u===h[3]},s.prototype.readData=function(a){if(this.checkOffset(a),a===0)return[];var c=this.data.slice(this.zero+this.index,this.zero+this.index+a);return this.index+=a,c},i.exports=s},{"../utils":32,"./DataReader":18}],18:[function(o,i,r){var A=o("../utils");function s(a){this.data=a,this.length=a.length,this.index=0,this.zero=0}s.prototype={checkOffset:function(a){this.checkIndex(this.index+a)},checkIndex:function(a){if(this.length<this.zero+a||a<0)throw new Error("End of data reached (data length = "+this.length+", asked index = "+a+"). Corrupted zip ?")},setIndex:function(a){this.checkIndex(a),this.index=a},skip:function(a){this.setIndex(this.index+a)},byteAt:function(){},readInt:function(a){var c,l=0;for(this.checkOffset(a),c=this.index+a-1;c>=this.index;c--)l=(l<<8)+this.byteAt(c);return this.index+=a,l},readString:function(a){return A.transformTo("string",this.readData(a))},readData:function(){},lastIndexOfSignature:function(){},readAndCheckSignature:function(){},readDate:function(){var a=this.readInt(4);return new Date(Date.UTC(1980+(a>>25&127),(a>>21&15)-1,a>>16&31,a>>11&31,a>>5&63,(31&a)<<1))}},i.exports=s},{"../utils":32}],19:[function(o,i,r){var A=o("./Uint8ArrayReader");function s(a){A.call(this,a)}o("../utils").inherits(s,A),s.prototype.readData=function(a){this.checkOffset(a);var c=this.data.slice(this.zero+this.index,this.zero+this.index+a);return this.index+=a,c},i.exports=s},{"../utils":32,"./Uint8ArrayReader":21}],20:[function(o,i,r){var A=o("./DataReader");function s(a){A.call(this,a)}o("../utils").inherits(s,A),s.prototype.byteAt=function(a){return this.data.charCodeAt(this.zero+a)},s.prototype.lastIndexOfSignature=function(a){return this.data.lastIndexOf(a)-this.zero},s.prototype.readAndCheckSignature=function(a){return a===this.readData(4)},s.prototype.readData=function(a){this.checkOffset(a);var c=this.data.slice(this.zero+this.index,this.zero+this.index+a);return this.index+=a,c},i.exports=s},{"../utils":32,"./DataReader":18}],21:[function(o,i,r){var A=o("./ArrayReader");function s(a){A.call(this,a)}o("../utils").inherits(s,A),s.prototype.readData=function(a){if(this.checkOffset(a),a===0)return new Uint8Array(0);var c=this.data.subarray(this.zero+this.index,this.zero+this.index+a);return this.index+=a,c},i.exports=s},{"../utils":32,"./ArrayReader":17}],22:[function(o,i,r){var A=o("../utils"),s=o("../support"),a=o("./ArrayReader"),c=o("./StringReader"),l=o("./NodeBufferReader"),g=o("./Uint8ArrayReader");i.exports=function(u){var h=A.getTypeOf(u);return A.checkSupport(h),h!=="string"||s.uint8array?h==="nodebuffer"?new l(u):s.uint8array?new g(A.transformTo("uint8array",u)):new a(A.transformTo("array",u)):new c(u)}},{"../support":30,"../utils":32,"./ArrayReader":17,"./NodeBufferReader":19,"./StringReader":20,"./Uint8ArrayReader":21}],23:[function(o,i,r){r.LOCAL_FILE_HEADER="PK",r.CENTRAL_FILE_HEADER="PK",r.CENTRAL_DIRECTORY_END="PK",r.ZIP64_CENTRAL_DIRECTORY_LOCATOR="PK\x07",r.ZIP64_CENTRAL_DIRECTORY_END="PK",r.DATA_DESCRIPTOR="PK\x07\b"},{}],24:[function(o,i,r){var A=o("./GenericWorker"),s=o("../utils");function a(c){A.call(this,"ConvertWorker to "+c),this.destType=c}s.inherits(a,A),a.prototype.processChunk=function(c){this.push({data:s.transformTo(this.destType,c.data),meta:c.meta})},i.exports=a},{"../utils":32,"./GenericWorker":28}],25:[function(o,i,r){var A=o("./GenericWorker"),s=o("../crc32");function a(){A.call(this,"Crc32Probe"),this.withStreamInfo("crc32",0)}o("../utils").inherits(a,A),a.prototype.processChunk=function(c){this.streamInfo.crc32=s(c.data,this.streamInfo.crc32||0),this.push(c)},i.exports=a},{"../crc32":4,"../utils":32,"./GenericWorker":28}],26:[function(o,i,r){var A=o("../utils"),s=o("./GenericWorker");function a(c){s.call(this,"DataLengthProbe for "+c),this.propName=c,this.withStreamInfo(c,0)}A.inherits(a,s),a.prototype.processChunk=function(c){if(c){var l=this.streamInfo[this.propName]||0;this.streamInfo[this.propName]=l+c.data.length}s.prototype.processChunk.call(this,c)},i.exports=a},{"../utils":32,"./GenericWorker":28}],27:[function(o,i,r){var A=o("../utils"),s=o("./GenericWorker");function a(c){s.call(this,"DataWorker");var l=this;this.dataIsReady=!1,this.index=0,this.max=0,this.data=null,this.type="",this._tickScheduled=!1,c.then(function(g){l.dataIsReady=!0,l.data=g,l.max=g&&g.length||0,l.type=A.getTypeOf(g),l.isPaused||l._tickAndRepeat()},function(g){l.error(g)})}A.inherits(a,s),a.prototype.cleanUp=function(){s.prototype.cleanUp.call(this),this.data=null},a.prototype.resume=function(){return!!s.prototype.resume.call(this)&&(!this._tickScheduled&&this.dataIsReady&&(this._tickScheduled=!0,A.delay(this._tickAndRepeat,[],this)),!0)},a.prototype._tickAndRepeat=function(){this._tickScheduled=!1,this.isPaused||this.isFinished||(this._tick(),this.isFinished||(A.delay(this._tickAndRepeat,[],this),this._tickScheduled=!0))},a.prototype._tick=function(){if(this.isPaused||this.isFinished)return!1;var c=null,l=Math.min(this.max,this.index+16384);if(this.index>=this.max)return this.end();switch(this.type){case"string":c=this.data.substring(this.index,l);break;case"uint8array":c=this.data.subarray(this.index,l);break;case"array":case"nodebuffer":c=this.data.slice(this.index,l)}return this.index=l,this.push({data:c,meta:{percent:this.max?this.index/this.max*100:0}})},i.exports=a},{"../utils":32,"./GenericWorker":28}],28:[function(o,i,r){function A(s){this.name=s||"default",this.streamInfo={},this.generatedError=null,this.extraStreamInfo={},this.isPaused=!0,this.isFinished=!1,this.isLocked=!1,this._listeners={data:[],end:[],error:[]},this.previous=null}A.prototype={push:function(s){this.emit("data",s)},end:function(){if(this.isFinished)return!1;this.flush();try{this.emit("end"),this.cleanUp(),this.isFinished=!0}catch(s){this.emit("error",s)}return!0},error:function(s){return!this.isFinished&&(this.isPaused?this.generatedError=s:(this.isFinished=!0,this.emit("error",s),this.previous&&this.previous.error(s),this.cleanUp()),!0)},on:function(s,a){return this._listeners[s].push(a),this},cleanUp:function(){this.streamInfo=this.generatedError=this.extraStreamInfo=null,this._listeners=[]},emit:function(s,a){if(this._listeners[s])for(var c=0;c<this._listeners[s].length;c++)this._listeners[s][c].call(this,a)},pipe:function(s){return s.registerPrevious(this)},registerPrevious:function(s){if(this.isLocked)throw new Error("The stream '"+this+"' has already been used.");this.streamInfo=s.streamInfo,this.mergeStreamInfo(),this.previous=s;var a=this;return s.on("data",function(c){a.processChunk(c)}),s.on("end",function(){a.end()}),s.on("error",function(c){a.error(c)}),this},pause:function(){return!this.isPaused&&!this.isFinished&&(this.isPaused=!0,this.previous&&this.previous.pause(),!0)},resume:function(){if(!this.isPaused||this.isFinished)return!1;var s=this.isPaused=!1;return this.generatedError&&(this.error(this.generatedError),s=!0),this.previous&&this.previous.resume(),!s},flush:function(){},processChunk:function(s){this.push(s)},withStreamInfo:function(s,a){return this.extraStreamInfo[s]=a,this.mergeStreamInfo(),this},mergeStreamInfo:function(){for(var s in this.extraStreamInfo)Object.prototype.hasOwnProperty.call(this.extraStreamInfo,s)&&(this.streamInfo[s]=this.extraStreamInfo[s])},lock:function(){if(this.isLocked)throw new Error("The stream '"+this+"' has already been used.");this.isLocked=!0,this.previous&&this.previous.lock()},toString:function(){var s="Worker "+this.name;return this.previous?this.previous+" -> "+s:s}},i.exports=A},{}],29:[function(o,i,r){var A=o("../utils"),s=o("./ConvertWorker"),a=o("./GenericWorker"),c=o("../base64"),l=o("../support"),g=o("../external"),u=null;if(l.nodestream)try{u=o("../nodejs/NodejsStreamOutputAdapter")}catch{}function h(_,m){return new g.Promise(function(p,C){var I=[],f=_._internalType,y=_._outputType,x=_._mimeType;_.on("data",function(B,S){I.push(B),m&&m(S)}).on("error",function(B){I=[],C(B)}).on("end",function(){try{var B=(function(S,D,w){switch(S){case"blob":return A.newBlob(A.transformTo("arraybuffer",D),w);case"base64":return c.encode(D);default:return A.transformTo(S,D)}})(y,(function(S,D){var w,F=0,R=null,H=0;for(w=0;w<D.length;w++)H+=D[w].length;switch(S){case"string":return D.join("");case"array":return Array.prototype.concat.apply([],D);case"uint8array":for(R=new Uint8Array(H),w=0;w<D.length;w++)R.set(D[w],F),F+=D[w].length;return R;case"nodebuffer":return Buffer.concat(D);default:throw new Error("concat : unsupported type '"+S+"'")}})(f,I),x);p(B)}catch(S){C(S)}I=[]}).resume()})}function d(_,m,p){var C=m;switch(m){case"blob":case"arraybuffer":C="uint8array";break;case"base64":C="string"}try{this._internalType=C,this._outputType=m,this._mimeType=p,A.checkSupport(C),this._worker=_.pipe(new s(C)),_.lock()}catch(I){this._worker=new a("error"),this._worker.error(I)}}d.prototype={accumulate:function(_){return h(this,_)},on:function(_,m){var p=this;return _==="data"?this._worker.on(_,function(C){m.call(p,C.data,C.meta)}):this._worker.on(_,function(){A.delay(m,arguments,p)}),this},resume:function(){return A.delay(this._worker.resume,[],this._worker),this},pause:function(){return this._worker.pause(),this},toNodejsStream:function(_){if(A.checkSupport("nodestream"),this._outputType!=="nodebuffer")throw new Error(this._outputType+" is not supported by this method");return new u(this,{objectMode:this._outputType!=="nodebuffer"},_)}},i.exports=d},{"../base64":1,"../external":6,"../nodejs/NodejsStreamOutputAdapter":13,"../support":30,"../utils":32,"./ConvertWorker":24,"./GenericWorker":28}],30:[function(o,i,r){if(r.base64=!0,r.array=!0,r.string=!0,r.arraybuffer=typeof ArrayBuffer<"u"&&typeof Uint8Array<"u",r.nodebuffer=typeof Buffer<"u",r.uint8array=typeof Uint8Array<"u",typeof ArrayBuffer>"u")r.blob=!1;else{var A=new ArrayBuffer(0);try{r.blob=new Blob([A],{type:"application/zip"}).size===0}catch{try{var s=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);s.append(A),r.blob=s.getBlob("application/zip").size===0}catch{r.blob=!1}}}try{r.nodestream=!!o("readable-stream").Readable}catch{r.nodestream=!1}},{"readable-stream":16}],31:[function(o,i,r){for(var A=o("./utils"),s=o("./support"),a=o("./nodejsUtils"),c=o("./stream/GenericWorker"),l=new Array(256),g=0;g<256;g++)l[g]=252<=g?6:248<=g?5:240<=g?4:224<=g?3:192<=g?2:1;l[254]=l[254]=1;function u(){c.call(this,"utf-8 decode"),this.leftOver=null}function h(){c.call(this,"utf-8 encode")}r.utf8encode=function(d){return s.nodebuffer?a.newBufferFrom(d,"utf-8"):(function(_){var m,p,C,I,f,y=_.length,x=0;for(I=0;I<y;I++)(64512&(p=_.charCodeAt(I)))==55296&&I+1<y&&(64512&(C=_.charCodeAt(I+1)))==56320&&(p=65536+(p-55296<<10)+(C-56320),I++),x+=p<128?1:p<2048?2:p<65536?3:4;for(m=s.uint8array?new Uint8Array(x):new Array(x),I=f=0;f<x;I++)(64512&(p=_.charCodeAt(I)))==55296&&I+1<y&&(64512&(C=_.charCodeAt(I+1)))==56320&&(p=65536+(p-55296<<10)+(C-56320),I++),p<128?m[f++]=p:(p<2048?m[f++]=192|p>>>6:(p<65536?m[f++]=224|p>>>12:(m[f++]=240|p>>>18,m[f++]=128|p>>>12&63),m[f++]=128|p>>>6&63),m[f++]=128|63&p);return m})(d)},r.utf8decode=function(d){return s.nodebuffer?A.transformTo("nodebuffer",d).toString("utf-8"):(function(_){var m,p,C,I,f=_.length,y=new Array(2*f);for(m=p=0;m<f;)if((C=_[m++])<128)y[p++]=C;else if(4<(I=l[C]))y[p++]=65533,m+=I-1;else{for(C&=I===2?31:I===3?15:7;1<I&&m<f;)C=C<<6|63&_[m++],I--;1<I?y[p++]=65533:C<65536?y[p++]=C:(C-=65536,y[p++]=55296|C>>10&1023,y[p++]=56320|1023&C)}return y.length!==p&&(y.subarray?y=y.subarray(0,p):y.length=p),A.applyFromCharCode(y)})(d=A.transformTo(s.uint8array?"uint8array":"array",d))},A.inherits(u,c),u.prototype.processChunk=function(d){var _=A.transformTo(s.uint8array?"uint8array":"array",d.data);if(this.leftOver&&this.leftOver.length){if(s.uint8array){var m=_;(_=new Uint8Array(m.length+this.leftOver.length)).set(this.leftOver,0),_.set(m,this.leftOver.length)}else _=this.leftOver.concat(_);this.leftOver=null}var p=(function(I,f){var y;for((f=f||I.length)>I.length&&(f=I.length),y=f-1;0<=y&&(192&I[y])==128;)y--;return y<0||y===0?f:y+l[I[y]]>f?y:f})(_),C=_;p!==_.length&&(s.uint8array?(C=_.subarray(0,p),this.leftOver=_.subarray(p,_.length)):(C=_.slice(0,p),this.leftOver=_.slice(p,_.length))),this.push({data:r.utf8decode(C),meta:d.meta})},u.prototype.flush=function(){this.leftOver&&this.leftOver.length&&(this.push({data:r.utf8decode(this.leftOver),meta:{}}),this.leftOver=null)},r.Utf8DecodeWorker=u,A.inherits(h,c),h.prototype.processChunk=function(d){this.push({data:r.utf8encode(d.data),meta:d.meta})},r.Utf8EncodeWorker=h},{"./nodejsUtils":14,"./stream/GenericWorker":28,"./support":30,"./utils":32}],32:[function(o,i,r){var A=o("./support"),s=o("./base64"),a=o("./nodejsUtils"),c=o("./external");function l(m){return m}function g(m,p){for(var C=0;C<m.length;++C)p[C]=255&m.charCodeAt(C);return p}o("setimmediate"),r.newBlob=function(m,p){r.checkSupport("blob");try{return new Blob([m],{type:p})}catch{try{var C=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);return C.append(m),C.getBlob(p)}catch{throw new Error("Bug : can't construct the Blob.")}}};var u={stringifyByChunk:function(m,p,C){var I=[],f=0,y=m.length;if(y<=C)return String.fromCharCode.apply(null,m);for(;f<y;)p==="array"||p==="nodebuffer"?I.push(String.fromCharCode.apply(null,m.slice(f,Math.min(f+C,y)))):I.push(String.fromCharCode.apply(null,m.subarray(f,Math.min(f+C,y)))),f+=C;return I.join("")},stringifyByChar:function(m){for(var p="",C=0;C<m.length;C++)p+=String.fromCharCode(m[C]);return p},applyCanBeUsed:{uint8array:(function(){try{return A.uint8array&&String.fromCharCode.apply(null,new Uint8Array(1)).length===1}catch{return!1}})(),nodebuffer:(function(){try{return A.nodebuffer&&String.fromCharCode.apply(null,a.allocBuffer(1)).length===1}catch{return!1}})()}};function h(m){var p=65536,C=r.getTypeOf(m),I=!0;if(C==="uint8array"?I=u.applyCanBeUsed.uint8array:C==="nodebuffer"&&(I=u.applyCanBeUsed.nodebuffer),I)for(;1<p;)try{return u.stringifyByChunk(m,C,p)}catch{p=Math.floor(p/2)}return u.stringifyByChar(m)}function d(m,p){for(var C=0;C<m.length;C++)p[C]=m[C];return p}r.applyFromCharCode=h;var _={};_.string={string:l,array:function(m){return g(m,new Array(m.length))},arraybuffer:function(m){return _.string.uint8array(m).buffer},uint8array:function(m){return g(m,new Uint8Array(m.length))},nodebuffer:function(m){return g(m,a.allocBuffer(m.length))}},_.array={string:h,array:l,arraybuffer:function(m){return new Uint8Array(m).buffer},uint8array:function(m){return new Uint8Array(m)},nodebuffer:function(m){return a.newBufferFrom(m)}},_.arraybuffer={string:function(m){return h(new Uint8Array(m))},array:function(m){return d(new Uint8Array(m),new Array(m.byteLength))},arraybuffer:l,uint8array:function(m){return new Uint8Array(m)},nodebuffer:function(m){return a.newBufferFrom(new Uint8Array(m))}},_.uint8array={string:h,array:function(m){return d(m,new Array(m.length))},arraybuffer:function(m){return m.buffer},uint8array:l,nodebuffer:function(m){return a.newBufferFrom(m)}},_.nodebuffer={string:h,array:function(m){return d(m,new Array(m.length))},arraybuffer:function(m){return _.nodebuffer.uint8array(m).buffer},uint8array:function(m){return d(m,new Uint8Array(m.length))},nodebuffer:l},r.transformTo=function(m,p){if(p=p||"",!m)return p;r.checkSupport(m);var C=r.getTypeOf(p);return _[C][m](p)},r.resolve=function(m){for(var p=m.split("/"),C=[],I=0;I<p.length;I++){var f=p[I];f==="."||f===""&&I!==0&&I!==p.length-1||(f===".."?C.pop():C.push(f))}return C.join("/")},r.getTypeOf=function(m){return typeof m=="string"?"string":Object.prototype.toString.call(m)==="[object Array]"?"array":A.nodebuffer&&a.isBuffer(m)?"nodebuffer":A.uint8array&&m instanceof Uint8Array?"uint8array":A.arraybuffer&&m instanceof ArrayBuffer?"arraybuffer":void 0},r.checkSupport=function(m){if(!A[m.toLowerCase()])throw new Error(m+" is not supported by this platform")},r.MAX_VALUE_16BITS=65535,r.MAX_VALUE_32BITS=-1,r.pretty=function(m){var p,C,I="";for(C=0;C<(m||"").length;C++)I+="\\x"+((p=m.charCodeAt(C))<16?"0":"")+p.toString(16).toUpperCase();return I},r.delay=function(m,p,C){setImmediate(function(){m.apply(C||null,p||[])})},r.inherits=function(m,p){function C(){}C.prototype=p.prototype,m.prototype=new C},r.extend=function(){var m,p,C={};for(m=0;m<arguments.length;m++)for(p in arguments[m])Object.prototype.hasOwnProperty.call(arguments[m],p)&&C[p]===void 0&&(C[p]=arguments[m][p]);return C},r.prepareContent=function(m,p,C,I,f){return c.Promise.resolve(p).then(function(y){return A.blob&&(y instanceof Blob||["[object File]","[object Blob]"].indexOf(Object.prototype.toString.call(y))!==-1)&&typeof FileReader<"u"?new c.Promise(function(x,B){var S=new FileReader;S.onload=function(D){x(D.target.result)},S.onerror=function(D){B(D.target.error)},S.readAsArrayBuffer(y)}):y}).then(function(y){var x=r.getTypeOf(y);return x?(x==="arraybuffer"?y=r.transformTo("uint8array",y):x==="string"&&(f?y=s.decode(y):C&&I!==!0&&(y=(function(B){return g(B,A.uint8array?new Uint8Array(B.length):new Array(B.length))})(y))),y):c.Promise.reject(new Error("Can't read the data of '"+m+"'. Is it in a supported JavaScript type (String, Blob, ArrayBuffer, etc) ?"))})}},{"./base64":1,"./external":6,"./nodejsUtils":14,"./support":30,setimmediate:54}],33:[function(o,i,r){var A=o("./reader/readerFor"),s=o("./utils"),a=o("./signature"),c=o("./zipEntry"),l=o("./support");function g(u){this.files=[],this.loadOptions=u}g.prototype={checkSignature:function(u){if(!this.reader.readAndCheckSignature(u)){this.reader.index-=4;var h=this.reader.readString(4);throw new Error("Corrupted zip or bug: unexpected signature ("+s.pretty(h)+", expected "+s.pretty(u)+")")}},isSignature:function(u,h){var d=this.reader.index;this.reader.setIndex(u);var _=this.reader.readString(4)===h;return this.reader.setIndex(d),_},readBlockEndOfCentral:function(){this.diskNumber=this.reader.readInt(2),this.diskWithCentralDirStart=this.reader.readInt(2),this.centralDirRecordsOnThisDisk=this.reader.readInt(2),this.centralDirRecords=this.reader.readInt(2),this.centralDirSize=this.reader.readInt(4),this.centralDirOffset=this.reader.readInt(4),this.zipCommentLength=this.reader.readInt(2);var u=this.reader.readData(this.zipCommentLength),h=l.uint8array?"uint8array":"array",d=s.transformTo(h,u);this.zipComment=this.loadOptions.decodeFileName(d)},readBlockZip64EndOfCentral:function(){this.zip64EndOfCentralSize=this.reader.readInt(8),this.reader.skip(4),this.diskNumber=this.reader.readInt(4),this.diskWithCentralDirStart=this.reader.readInt(4),this.centralDirRecordsOnThisDisk=this.reader.readInt(8),this.centralDirRecords=this.reader.readInt(8),this.centralDirSize=this.reader.readInt(8),this.centralDirOffset=this.reader.readInt(8),this.zip64ExtensibleData={};for(var u,h,d,_=this.zip64EndOfCentralSize-44;0<_;)u=this.reader.readInt(2),h=this.reader.readInt(4),d=this.reader.readData(h),this.zip64ExtensibleData[u]={id:u,length:h,value:d}},readBlockZip64EndOfCentralLocator:function(){if(this.diskWithZip64CentralDirStart=this.reader.readInt(4),this.relativeOffsetEndOfZip64CentralDir=this.reader.readInt(8),this.disksCount=this.reader.readInt(4),1<this.disksCount)throw new Error("Multi-volumes zip are not supported")},readLocalFiles:function(){var u,h;for(u=0;u<this.files.length;u++)h=this.files[u],this.reader.setIndex(h.localHeaderOffset),this.checkSignature(a.LOCAL_FILE_HEADER),h.readLocalPart(this.reader),h.handleUTF8(),h.processAttributes()},readCentralDir:function(){var u;for(this.reader.setIndex(this.centralDirOffset);this.reader.readAndCheckSignature(a.CENTRAL_FILE_HEADER);)(u=new c({zip64:this.zip64},this.loadOptions)).readCentralPart(this.reader),this.files.push(u);if(this.centralDirRecords!==this.files.length&&this.centralDirRecords!==0&&this.files.length===0)throw new Error("Corrupted zip or bug: expected "+this.centralDirRecords+" records in central dir, got "+this.files.length)},readEndOfCentral:function(){var u=this.reader.lastIndexOfSignature(a.CENTRAL_DIRECTORY_END);if(u<0)throw this.isSignature(0,a.LOCAL_FILE_HEADER)?new Error("Corrupted zip: can't find end of central directory"):new Error("Can't find end of central directory : is this a zip file ? If it is, see https://stuk.github.io/jszip/documentation/howto/read_zip.html");this.reader.setIndex(u);var h=u;if(this.checkSignature(a.CENTRAL_DIRECTORY_END),this.readBlockEndOfCentral(),this.diskNumber===s.MAX_VALUE_16BITS||this.diskWithCentralDirStart===s.MAX_VALUE_16BITS||this.centralDirRecordsOnThisDisk===s.MAX_VALUE_16BITS||this.centralDirRecords===s.MAX_VALUE_16BITS||this.centralDirSize===s.MAX_VALUE_32BITS||this.centralDirOffset===s.MAX_VALUE_32BITS){if(this.zip64=!0,(u=this.reader.lastIndexOfSignature(a.ZIP64_CENTRAL_DIRECTORY_LOCATOR))<0)throw new Error("Corrupted zip: can't find the ZIP64 end of central directory locator");if(this.reader.setIndex(u),this.checkSignature(a.ZIP64_CENTRAL_DIRECTORY_LOCATOR),this.readBlockZip64EndOfCentralLocator(),!this.isSignature(this.relativeOffsetEndOfZip64CentralDir,a.ZIP64_CENTRAL_DIRECTORY_END)&&(this.relativeOffsetEndOfZip64CentralDir=this.reader.lastIndexOfSignature(a.ZIP64_CENTRAL_DIRECTORY_END),this.relativeOffsetEndOfZip64CentralDir<0))throw new Error("Corrupted zip: can't find the ZIP64 end of central directory");this.reader.setIndex(this.relativeOffsetEndOfZip64CentralDir),this.checkSignature(a.ZIP64_CENTRAL_DIRECTORY_END),this.readBlockZip64EndOfCentral()}var d=this.centralDirOffset+this.centralDirSize;this.zip64&&(d+=20,d+=12+this.zip64EndOfCentralSize);var _=h-d;if(0<_)this.isSignature(h,a.CENTRAL_FILE_HEADER)||(this.reader.zero=_);else if(_<0)throw new Error("Corrupted zip: missing "+Math.abs(_)+" bytes.")},prepareReader:function(u){this.reader=A(u)},load:function(u){this.prepareReader(u),this.readEndOfCentral(),this.readCentralDir(),this.readLocalFiles()}},i.exports=g},{"./reader/readerFor":22,"./signature":23,"./support":30,"./utils":32,"./zipEntry":34}],34:[function(o,i,r){var A=o("./reader/readerFor"),s=o("./utils"),a=o("./compressedObject"),c=o("./crc32"),l=o("./utf8"),g=o("./compressions"),u=o("./support");function h(d,_){this.options=d,this.loadOptions=_}h.prototype={isEncrypted:function(){return(1&this.bitFlag)==1},useUTF8:function(){return(2048&this.bitFlag)==2048},readLocalPart:function(d){var _,m;if(d.skip(22),this.fileNameLength=d.readInt(2),m=d.readInt(2),this.fileName=d.readData(this.fileNameLength),d.skip(m),this.compressedSize===-1||this.uncompressedSize===-1)throw new Error("Bug or corrupted zip : didn't get enough information from the central directory (compressedSize === -1 || uncompressedSize === -1)");if((_=(function(p){for(var C in g)if(Object.prototype.hasOwnProperty.call(g,C)&&g[C].magic===p)return g[C];return null})(this.compressionMethod))===null)throw new Error("Corrupted zip : compression "+s.pretty(this.compressionMethod)+" unknown (inner file : "+s.transformTo("string",this.fileName)+")");this.decompressed=new a(this.compressedSize,this.uncompressedSize,this.crc32,_,d.readData(this.compressedSize))},readCentralPart:function(d){this.versionMadeBy=d.readInt(2),d.skip(2),this.bitFlag=d.readInt(2),this.compressionMethod=d.readString(2),this.date=d.readDate(),this.crc32=d.readInt(4),this.compressedSize=d.readInt(4),this.uncompressedSize=d.readInt(4);var _=d.readInt(2);if(this.extraFieldsLength=d.readInt(2),this.fileCommentLength=d.readInt(2),this.diskNumberStart=d.readInt(2),this.internalFileAttributes=d.readInt(2),this.externalFileAttributes=d.readInt(4),this.localHeaderOffset=d.readInt(4),this.isEncrypted())throw new Error("Encrypted zip are not supported");d.skip(_),this.readExtraFields(d),this.parseZIP64ExtraField(d),this.fileComment=d.readData(this.fileCommentLength)},processAttributes:function(){this.unixPermissions=null,this.dosPermissions=null;var d=this.versionMadeBy>>8;this.dir=!!(16&this.externalFileAttributes),d==0&&(this.dosPermissions=63&this.externalFileAttributes),d==3&&(this.unixPermissions=this.externalFileAttributes>>16&65535),this.dir||this.fileNameStr.slice(-1)!=="/"||(this.dir=!0)},parseZIP64ExtraField:function(){if(this.extraFields[1]){var d=A(this.extraFields[1].value);this.uncompressedSize===s.MAX_VALUE_32BITS&&(this.uncompressedSize=d.readInt(8)),this.compressedSize===s.MAX_VALUE_32BITS&&(this.compressedSize=d.readInt(8)),this.localHeaderOffset===s.MAX_VALUE_32BITS&&(this.localHeaderOffset=d.readInt(8)),this.diskNumberStart===s.MAX_VALUE_32BITS&&(this.diskNumberStart=d.readInt(4))}},readExtraFields:function(d){var _,m,p,C=d.index+this.extraFieldsLength;for(this.extraFields||(this.extraFields={});d.index+4<C;)_=d.readInt(2),m=d.readInt(2),p=d.readData(m),this.extraFields[_]={id:_,length:m,value:p};d.setIndex(C)},handleUTF8:function(){var d=u.uint8array?"uint8array":"array";if(this.useUTF8())this.fileNameStr=l.utf8decode(this.fileName),this.fileCommentStr=l.utf8decode(this.fileComment);else{var _=this.findExtraFieldUnicodePath();if(_!==null)this.fileNameStr=_;else{var m=s.transformTo(d,this.fileName);this.fileNameStr=this.loadOptions.decodeFileName(m)}var p=this.findExtraFieldUnicodeComment();if(p!==null)this.fileCommentStr=p;else{var C=s.transformTo(d,this.fileComment);this.fileCommentStr=this.loadOptions.decodeFileName(C)}}},findExtraFieldUnicodePath:function(){var d=this.extraFields[28789];if(d){var _=A(d.value);return _.readInt(1)!==1||c(this.fileName)!==_.readInt(4)?null:l.utf8decode(_.readData(d.length-5))}return null},findExtraFieldUnicodeComment:function(){var d=this.extraFields[25461];if(d){var _=A(d.value);return _.readInt(1)!==1||c(this.fileComment)!==_.readInt(4)?null:l.utf8decode(_.readData(d.length-5))}return null}},i.exports=h},{"./compressedObject":2,"./compressions":3,"./crc32":4,"./reader/readerFor":22,"./support":30,"./utf8":31,"./utils":32}],35:[function(o,i,r){function A(_,m,p){this.name=_,this.dir=p.dir,this.date=p.date,this.comment=p.comment,this.unixPermissions=p.unixPermissions,this.dosPermissions=p.dosPermissions,this._data=m,this._dataBinary=p.binary,this.options={compression:p.compression,compressionOptions:p.compressionOptions}}var s=o("./stream/StreamHelper"),a=o("./stream/DataWorker"),c=o("./utf8"),l=o("./compressedObject"),g=o("./stream/GenericWorker");A.prototype={internalStream:function(_){var m=null,p="string";try{if(!_)throw new Error("No output type specified.");var C=(p=_.toLowerCase())==="string"||p==="text";p!=="binarystring"&&p!=="text"||(p="string"),m=this._decompressWorker();var I=!this._dataBinary;I&&!C&&(m=m.pipe(new c.Utf8EncodeWorker)),!I&&C&&(m=m.pipe(new c.Utf8DecodeWorker))}catch(f){(m=new g("error")).error(f)}return new s(m,p,"")},async:function(_,m){return this.internalStream(_).accumulate(m)},nodeStream:function(_,m){return this.internalStream(_||"nodebuffer").toNodejsStream(m)},_compressWorker:function(_,m){if(this._data instanceof l&&this._data.compression.magic===_.magic)return this._data.getCompressedWorker();var p=this._decompressWorker();return this._dataBinary||(p=p.pipe(new c.Utf8EncodeWorker)),l.createWorkerFrom(p,_,m)},_decompressWorker:function(){return this._data instanceof l?this._data.getContentWorker():this._data instanceof g?this._data:new a(this._data)}};for(var u=["asText","asBinary","asNodeBuffer","asUint8Array","asArrayBuffer"],h=function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},d=0;d<u.length;d++)A.prototype[u[d]]=h;i.exports=A},{"./compressedObject":2,"./stream/DataWorker":27,"./stream/GenericWorker":28,"./stream/StreamHelper":29,"./utf8":31}],36:[function(o,i,r){(function(A){var s,a,c=A.MutationObserver||A.WebKitMutationObserver;if(c){var l=0,g=new c(_),u=A.document.createTextNode("");g.observe(u,{characterData:!0}),s=function(){u.data=l=++l%2}}else if(A.setImmediate||A.MessageChannel===void 0)s="document"in A&&"onreadystatechange"in A.document.createElement("script")?function(){var m=A.document.createElement("script");m.onreadystatechange=function(){_(),m.onreadystatechange=null,m.parentNode.removeChild(m),m=null},A.document.documentElement.appendChild(m)}:function(){setTimeout(_,0)};else{var h=new A.MessageChannel;h.port1.onmessage=_,s=function(){h.port2.postMessage(0)}}var d=[];function _(){var m,p;a=!0;for(var C=d.length;C;){for(p=d,d=[],m=-1;++m<C;)p[m]();C=d.length}a=!1}i.exports=function(m){d.push(m)!==1||a||s()}}).call(this,typeof cf<"u"?cf:typeof self<"u"?self:typeof window<"u"?window:{})},{}],37:[function(o,i,r){var A=o("immediate");function s(){}var a={},c=["REJECTED"],l=["FULFILLED"],g=["PENDING"];function u(C){if(typeof C!="function")throw new TypeError("resolver must be a function");this.state=g,this.queue=[],this.outcome=void 0,C!==s&&m(this,C)}function h(C,I,f){this.promise=C,typeof I=="function"&&(this.onFulfilled=I,this.callFulfilled=this.otherCallFulfilled),typeof f=="function"&&(this.onRejected=f,this.callRejected=this.otherCallRejected)}function d(C,I,f){A(function(){var y;try{y=I(f)}catch(x){return a.reject(C,x)}y===C?a.reject(C,new TypeError("Cannot resolve promise with itself")):a.resolve(C,y)})}function _(C){var I=C&&C.then;if(C&&(typeof C=="object"||typeof C=="function")&&typeof I=="function")return function(){I.apply(C,arguments)}}function m(C,I){var f=!1;function y(S){f||(f=!0,a.reject(C,S))}function x(S){f||(f=!0,a.resolve(C,S))}var B=p(function(){I(x,y)});B.status==="error"&&y(B.value)}function p(C,I){var f={};try{f.value=C(I),f.status="success"}catch(y){f.status="error",f.value=y}return f}(i.exports=u).prototype.finally=function(C){if(typeof C!="function")return this;var I=this.constructor;return this.then(function(f){return I.resolve(C()).then(function(){return f})},function(f){return I.resolve(C()).then(function(){throw f})})},u.prototype.catch=function(C){return this.then(null,C)},u.prototype.then=function(C,I){if(typeof C!="function"&&this.state===l||typeof I!="function"&&this.state===c)return this;var f=new this.constructor(s);return this.state!==g?d(f,this.state===l?C:I,this.outcome):this.queue.push(new h(f,C,I)),f},h.prototype.callFulfilled=function(C){a.resolve(this.promise,C)},h.prototype.otherCallFulfilled=function(C){d(this.promise,this.onFulfilled,C)},h.prototype.callRejected=function(C){a.reject(this.promise,C)},h.prototype.otherCallRejected=function(C){d(this.promise,this.onRejected,C)},a.resolve=function(C,I){var f=p(_,I);if(f.status==="error")return a.reject(C,f.value);var y=f.value;if(y)m(C,y);else{C.state=l,C.outcome=I;for(var x=-1,B=C.queue.length;++x<B;)C.queue[x].callFulfilled(I)}return C},a.reject=function(C,I){C.state=c,C.outcome=I;for(var f=-1,y=C.queue.length;++f<y;)C.queue[f].callRejected(I);return C},u.resolve=function(C){return C instanceof this?C:a.resolve(new this(s),C)},u.reject=function(C){var I=new this(s);return a.reject(I,C)},u.all=function(C){var I=this;if(Object.prototype.toString.call(C)!=="[object Array]")return this.reject(new TypeError("must be an array"));var f=C.length,y=!1;if(!f)return this.resolve([]);for(var x=new Array(f),B=0,S=-1,D=new this(s);++S<f;)w(C[S],S);return D;function w(F,R){I.resolve(F).then(function(H){x[R]=H,++B!==f||y||(y=!0,a.resolve(D,x))},function(H){y||(y=!0,a.reject(D,H))})}},u.race=function(C){var I=this;if(Object.prototype.toString.call(C)!=="[object Array]")return this.reject(new TypeError("must be an array"));var f=C.length,y=!1;if(!f)return this.resolve([]);for(var x=-1,B=new this(s);++x<f;)S=C[x],I.resolve(S).then(function(D){y||(y=!0,a.resolve(B,D))},function(D){y||(y=!0,a.reject(B,D))});var S;return B}},{immediate:36}],38:[function(o,i,r){var A={};(0,o("./lib/utils/common").assign)(A,o("./lib/deflate"),o("./lib/inflate"),o("./lib/zlib/constants")),i.exports=A},{"./lib/deflate":39,"./lib/inflate":40,"./lib/utils/common":41,"./lib/zlib/constants":44}],39:[function(o,i,r){var A=o("./zlib/deflate"),s=o("./utils/common"),a=o("./utils/strings"),c=o("./zlib/messages"),l=o("./zlib/zstream"),g=Object.prototype.toString,u=0,h=-1,d=0,_=8;function m(C){if(!(this instanceof m))return new m(C);this.options=s.assign({level:h,method:_,chunkSize:16384,windowBits:15,memLevel:8,strategy:d,to:""},C||{});var I=this.options;I.raw&&0<I.windowBits?I.windowBits=-I.windowBits:I.gzip&&0<I.windowBits&&I.windowBits<16&&(I.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new l,this.strm.avail_out=0;var f=A.deflateInit2(this.strm,I.level,I.method,I.windowBits,I.memLevel,I.strategy);if(f!==u)throw new Error(c[f]);if(I.header&&A.deflateSetHeader(this.strm,I.header),I.dictionary){var y;if(y=typeof I.dictionary=="string"?a.string2buf(I.dictionary):g.call(I.dictionary)==="[object ArrayBuffer]"?new Uint8Array(I.dictionary):I.dictionary,(f=A.deflateSetDictionary(this.strm,y))!==u)throw new Error(c[f]);this._dict_set=!0}}function p(C,I){var f=new m(I);if(f.push(C,!0),f.err)throw f.msg||c[f.err];return f.result}m.prototype.push=function(C,I){var f,y,x=this.strm,B=this.options.chunkSize;if(this.ended)return!1;y=I===~~I?I:I===!0?4:0,typeof C=="string"?x.input=a.string2buf(C):g.call(C)==="[object ArrayBuffer]"?x.input=new Uint8Array(C):x.input=C,x.next_in=0,x.avail_in=x.input.length;do{if(x.avail_out===0&&(x.output=new s.Buf8(B),x.next_out=0,x.avail_out=B),(f=A.deflate(x,y))!==1&&f!==u)return this.onEnd(f),!(this.ended=!0);x.avail_out!==0&&(x.avail_in!==0||y!==4&&y!==2)||(this.options.to==="string"?this.onData(a.buf2binstring(s.shrinkBuf(x.output,x.next_out))):this.onData(s.shrinkBuf(x.output,x.next_out)))}while((0<x.avail_in||x.avail_out===0)&&f!==1);return y===4?(f=A.deflateEnd(this.strm),this.onEnd(f),this.ended=!0,f===u):y!==2||(this.onEnd(u),!(x.avail_out=0))},m.prototype.onData=function(C){this.chunks.push(C)},m.prototype.onEnd=function(C){C===u&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=s.flattenChunks(this.chunks)),this.chunks=[],this.err=C,this.msg=this.strm.msg},r.Deflate=m,r.deflate=p,r.deflateRaw=function(C,I){return(I=I||{}).raw=!0,p(C,I)},r.gzip=function(C,I){return(I=I||{}).gzip=!0,p(C,I)}},{"./utils/common":41,"./utils/strings":42,"./zlib/deflate":46,"./zlib/messages":51,"./zlib/zstream":53}],40:[function(o,i,r){var A=o("./zlib/inflate"),s=o("./utils/common"),a=o("./utils/strings"),c=o("./zlib/constants"),l=o("./zlib/messages"),g=o("./zlib/zstream"),u=o("./zlib/gzheader"),h=Object.prototype.toString;function d(m){if(!(this instanceof d))return new d(m);this.options=s.assign({chunkSize:16384,windowBits:0,to:""},m||{});var p=this.options;p.raw&&0<=p.windowBits&&p.windowBits<16&&(p.windowBits=-p.windowBits,p.windowBits===0&&(p.windowBits=-15)),!(0<=p.windowBits&&p.windowBits<16)||m&&m.windowBits||(p.windowBits+=32),15<p.windowBits&&p.windowBits<48&&(15&p.windowBits)==0&&(p.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new g,this.strm.avail_out=0;var C=A.inflateInit2(this.strm,p.windowBits);if(C!==c.Z_OK)throw new Error(l[C]);this.header=new u,A.inflateGetHeader(this.strm,this.header)}function _(m,p){var C=new d(p);if(C.push(m,!0),C.err)throw C.msg||l[C.err];return C.result}d.prototype.push=function(m,p){var C,I,f,y,x,B,S=this.strm,D=this.options.chunkSize,w=this.options.dictionary,F=!1;if(this.ended)return!1;I=p===~~p?p:p===!0?c.Z_FINISH:c.Z_NO_FLUSH,typeof m=="string"?S.input=a.binstring2buf(m):h.call(m)==="[object ArrayBuffer]"?S.input=new Uint8Array(m):S.input=m,S.next_in=0,S.avail_in=S.input.length;do{if(S.avail_out===0&&(S.output=new s.Buf8(D),S.next_out=0,S.avail_out=D),(C=A.inflate(S,c.Z_NO_FLUSH))===c.Z_NEED_DICT&&w&&(B=typeof w=="string"?a.string2buf(w):h.call(w)==="[object ArrayBuffer]"?new Uint8Array(w):w,C=A.inflateSetDictionary(this.strm,B)),C===c.Z_BUF_ERROR&&F===!0&&(C=c.Z_OK,F=!1),C!==c.Z_STREAM_END&&C!==c.Z_OK)return this.onEnd(C),!(this.ended=!0);S.next_out&&(S.avail_out!==0&&C!==c.Z_STREAM_END&&(S.avail_in!==0||I!==c.Z_FINISH&&I!==c.Z_SYNC_FLUSH)||(this.options.to==="string"?(f=a.utf8border(S.output,S.next_out),y=S.next_out-f,x=a.buf2string(S.output,f),S.next_out=y,S.avail_out=D-y,y&&s.arraySet(S.output,S.output,f,y,0),this.onData(x)):this.onData(s.shrinkBuf(S.output,S.next_out)))),S.avail_in===0&&S.avail_out===0&&(F=!0)}while((0<S.avail_in||S.avail_out===0)&&C!==c.Z_STREAM_END);return C===c.Z_STREAM_END&&(I=c.Z_FINISH),I===c.Z_FINISH?(C=A.inflateEnd(this.strm),this.onEnd(C),this.ended=!0,C===c.Z_OK):I!==c.Z_SYNC_FLUSH||(this.onEnd(c.Z_OK),!(S.avail_out=0))},d.prototype.onData=function(m){this.chunks.push(m)},d.prototype.onEnd=function(m){m===c.Z_OK&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=s.flattenChunks(this.chunks)),this.chunks=[],this.err=m,this.msg=this.strm.msg},r.Inflate=d,r.inflate=_,r.inflateRaw=function(m,p){return(p=p||{}).raw=!0,_(m,p)},r.ungzip=_},{"./utils/common":41,"./utils/strings":42,"./zlib/constants":44,"./zlib/gzheader":47,"./zlib/inflate":49,"./zlib/messages":51,"./zlib/zstream":53}],41:[function(o,i,r){var A=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Int32Array<"u";r.assign=function(c){for(var l=Array.prototype.slice.call(arguments,1);l.length;){var g=l.shift();if(g){if(typeof g!="object")throw new TypeError(g+"must be non-object");for(var u in g)g.hasOwnProperty(u)&&(c[u]=g[u])}}return c},r.shrinkBuf=function(c,l){return c.length===l?c:c.subarray?c.subarray(0,l):(c.length=l,c)};var s={arraySet:function(c,l,g,u,h){if(l.subarray&&c.subarray)c.set(l.subarray(g,g+u),h);else for(var d=0;d<u;d++)c[h+d]=l[g+d]},flattenChunks:function(c){var l,g,u,h,d,_;for(l=u=0,g=c.length;l<g;l++)u+=c[l].length;for(_=new Uint8Array(u),l=h=0,g=c.length;l<g;l++)d=c[l],_.set(d,h),h+=d.length;return _}},a={arraySet:function(c,l,g,u,h){for(var d=0;d<u;d++)c[h+d]=l[g+d]},flattenChunks:function(c){return[].concat.apply([],c)}};r.setTyped=function(c){c?(r.Buf8=Uint8Array,r.Buf16=Uint16Array,r.Buf32=Int32Array,r.assign(r,s)):(r.Buf8=Array,r.Buf16=Array,r.Buf32=Array,r.assign(r,a))},r.setTyped(A)},{}],42:[function(o,i,r){var A=o("./common"),s=!0,a=!0;try{String.fromCharCode.apply(null,[0])}catch{s=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch{a=!1}for(var c=new A.Buf8(256),l=0;l<256;l++)c[l]=252<=l?6:248<=l?5:240<=l?4:224<=l?3:192<=l?2:1;function g(u,h){if(h<65537&&(u.subarray&&a||!u.subarray&&s))return String.fromCharCode.apply(null,A.shrinkBuf(u,h));for(var d="",_=0;_<h;_++)d+=String.fromCharCode(u[_]);return d}c[254]=c[254]=1,r.string2buf=function(u){var h,d,_,m,p,C=u.length,I=0;for(m=0;m<C;m++)(64512&(d=u.charCodeAt(m)))==55296&&m+1<C&&(64512&(_=u.charCodeAt(m+1)))==56320&&(d=65536+(d-55296<<10)+(_-56320),m++),I+=d<128?1:d<2048?2:d<65536?3:4;for(h=new A.Buf8(I),m=p=0;p<I;m++)(64512&(d=u.charCodeAt(m)))==55296&&m+1<C&&(64512&(_=u.charCodeAt(m+1)))==56320&&(d=65536+(d-55296<<10)+(_-56320),m++),d<128?h[p++]=d:(d<2048?h[p++]=192|d>>>6:(d<65536?h[p++]=224|d>>>12:(h[p++]=240|d>>>18,h[p++]=128|d>>>12&63),h[p++]=128|d>>>6&63),h[p++]=128|63&d);return h},r.buf2binstring=function(u){return g(u,u.length)},r.binstring2buf=function(u){for(var h=new A.Buf8(u.length),d=0,_=h.length;d<_;d++)h[d]=u.charCodeAt(d);return h},r.buf2string=function(u,h){var d,_,m,p,C=h||u.length,I=new Array(2*C);for(d=_=0;d<C;)if((m=u[d++])<128)I[_++]=m;else if(4<(p=c[m]))I[_++]=65533,d+=p-1;else{for(m&=p===2?31:p===3?15:7;1<p&&d<C;)m=m<<6|63&u[d++],p--;1<p?I[_++]=65533:m<65536?I[_++]=m:(m-=65536,I[_++]=55296|m>>10&1023,I[_++]=56320|1023&m)}return g(I,_)},r.utf8border=function(u,h){var d;for((h=h||u.length)>u.length&&(h=u.length),d=h-1;0<=d&&(192&u[d])==128;)d--;return d<0||d===0?h:d+c[u[d]]>h?d:h}},{"./common":41}],43:[function(o,i,r){i.exports=function(A,s,a,c){for(var l=65535&A|0,g=A>>>16&65535|0,u=0;a!==0;){for(a-=u=2e3<a?2e3:a;g=g+(l=l+s[c++]|0)|0,--u;);l%=65521,g%=65521}return l|g<<16|0}},{}],44:[function(o,i,r){i.exports={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8}},{}],45:[function(o,i,r){var A=(function(){for(var s,a=[],c=0;c<256;c++){s=c;for(var l=0;l<8;l++)s=1&s?3988292384^s>>>1:s>>>1;a[c]=s}return a})();i.exports=function(s,a,c,l){var g=A,u=l+c;s^=-1;for(var h=l;h<u;h++)s=s>>>8^g[255&(s^a[h])];return-1^s}},{}],46:[function(o,i,r){var A,s=o("../utils/common"),a=o("./trees"),c=o("./adler32"),l=o("./crc32"),g=o("./messages"),u=0,h=4,d=0,_=-2,m=-1,p=4,C=2,I=8,f=9,y=286,x=30,B=19,S=2*y+1,D=15,w=3,F=258,R=F+w+1,H=42,G=113,K=1,J=2,W=3,j=4;function se(Ce,Ze){return Ce.msg=g[Ze],Ze}function Ae(Ce){return(Ce<<1)-(4<Ce?9:0)}function ee(Ce){for(var Ze=Ce.length;0<=--Ze;)Ce[Ze]=0}function oe(Ce){var Ze=Ce.state,Oe=Ze.pending;Oe>Ce.avail_out&&(Oe=Ce.avail_out),Oe!==0&&(s.arraySet(Ce.output,Ze.pending_buf,Ze.pending_out,Oe,Ce.next_out),Ce.next_out+=Oe,Ze.pending_out+=Oe,Ce.total_out+=Oe,Ce.avail_out-=Oe,Ze.pending-=Oe,Ze.pending===0&&(Ze.pending_out=0))}function ae(Ce,Ze){a._tr_flush_block(Ce,0<=Ce.block_start?Ce.block_start:-1,Ce.strstart-Ce.block_start,Ze),Ce.block_start=Ce.strstart,oe(Ce.strm)}function ie(Ce,Ze){Ce.pending_buf[Ce.pending++]=Ze}function le(Ce,Ze){Ce.pending_buf[Ce.pending++]=Ze>>>8&255,Ce.pending_buf[Ce.pending++]=255&Ze}function fe(Ce,Ze){var Oe,Ye,qe=Ce.max_chain_length,He=Ce.strstart,Pe=Ce.prev_length,ve=Ce.nice_match,De=Ce.strstart>Ce.w_size-R?Ce.strstart-(Ce.w_size-R):0,ze=Ce.window,Xe=Ce.w_mask,st=Ce.prev,ct=Ce.strstart+F,ut=ze[He+Pe-1],gt=ze[He+Pe];Ce.prev_length>=Ce.good_match&&(qe>>=2),ve>Ce.lookahead&&(ve=Ce.lookahead);do if(ze[(Oe=Ze)+Pe]===gt&&ze[Oe+Pe-1]===ut&&ze[Oe]===ze[He]&&ze[++Oe]===ze[He+1]){He+=2,Oe++;do;while(ze[++He]===ze[++Oe]&&ze[++He]===ze[++Oe]&&ze[++He]===ze[++Oe]&&ze[++He]===ze[++Oe]&&ze[++He]===ze[++Oe]&&ze[++He]===ze[++Oe]&&ze[++He]===ze[++Oe]&&ze[++He]===ze[++Oe]&&He<ct);if(Ye=F-(ct-He),He=ct-F,Pe<Ye){if(Ce.match_start=Ze,ve<=(Pe=Ye))break;ut=ze[He+Pe-1],gt=ze[He+Pe]}}while((Ze=st[Ze&Xe])>De&&--qe!=0);return Pe<=Ce.lookahead?Pe:Ce.lookahead}function xe(Ce){var Ze,Oe,Ye,qe,He,Pe,ve,De,ze,Xe,st=Ce.w_size;do{if(qe=Ce.window_size-Ce.lookahead-Ce.strstart,Ce.strstart>=st+(st-R)){for(s.arraySet(Ce.window,Ce.window,st,st,0),Ce.match_start-=st,Ce.strstart-=st,Ce.block_start-=st,Ze=Oe=Ce.hash_size;Ye=Ce.head[--Ze],Ce.head[Ze]=st<=Ye?Ye-st:0,--Oe;);for(Ze=Oe=st;Ye=Ce.prev[--Ze],Ce.prev[Ze]=st<=Ye?Ye-st:0,--Oe;);qe+=st}if(Ce.strm.avail_in===0)break;if(Pe=Ce.strm,ve=Ce.window,De=Ce.strstart+Ce.lookahead,ze=qe,Xe=void 0,Xe=Pe.avail_in,ze<Xe&&(Xe=ze),Oe=Xe===0?0:(Pe.avail_in-=Xe,s.arraySet(ve,Pe.input,Pe.next_in,Xe,De),Pe.state.wrap===1?Pe.adler=c(Pe.adler,ve,Xe,De):Pe.state.wrap===2&&(Pe.adler=l(Pe.adler,ve,Xe,De)),Pe.next_in+=Xe,Pe.total_in+=Xe,Xe),Ce.lookahead+=Oe,Ce.lookahead+Ce.insert>=w)for(He=Ce.strstart-Ce.insert,Ce.ins_h=Ce.window[He],Ce.ins_h=(Ce.ins_h<<Ce.hash_shift^Ce.window[He+1])&Ce.hash_mask;Ce.insert&&(Ce.ins_h=(Ce.ins_h<<Ce.hash_shift^Ce.window[He+w-1])&Ce.hash_mask,Ce.prev[He&Ce.w_mask]=Ce.head[Ce.ins_h],Ce.head[Ce.ins_h]=He,He++,Ce.insert--,!(Ce.lookahead+Ce.insert<w)););}while(Ce.lookahead<R&&Ce.strm.avail_in!==0)}function Qe(Ce,Ze){for(var Oe,Ye;;){if(Ce.lookahead<R){if(xe(Ce),Ce.lookahead<R&&Ze===u)return K;if(Ce.lookahead===0)break}if(Oe=0,Ce.lookahead>=w&&(Ce.ins_h=(Ce.ins_h<<Ce.hash_shift^Ce.window[Ce.strstart+w-1])&Ce.hash_mask,Oe=Ce.prev[Ce.strstart&Ce.w_mask]=Ce.head[Ce.ins_h],Ce.head[Ce.ins_h]=Ce.strstart),Oe!==0&&Ce.strstart-Oe<=Ce.w_size-R&&(Ce.match_length=fe(Ce,Oe)),Ce.match_length>=w)if(Ye=a._tr_tally(Ce,Ce.strstart-Ce.match_start,Ce.match_length-w),Ce.lookahead-=Ce.match_length,Ce.match_length<=Ce.max_lazy_match&&Ce.lookahead>=w){for(Ce.match_length--;Ce.strstart++,Ce.ins_h=(Ce.ins_h<<Ce.hash_shift^Ce.window[Ce.strstart+w-1])&Ce.hash_mask,Oe=Ce.prev[Ce.strstart&Ce.w_mask]=Ce.head[Ce.ins_h],Ce.head[Ce.ins_h]=Ce.strstart,--Ce.match_length!=0;);Ce.strstart++}else Ce.strstart+=Ce.match_length,Ce.match_length=0,Ce.ins_h=Ce.window[Ce.strstart],Ce.ins_h=(Ce.ins_h<<Ce.hash_shift^Ce.window[Ce.strstart+1])&Ce.hash_mask;else Ye=a._tr_tally(Ce,0,Ce.window[Ce.strstart]),Ce.lookahead--,Ce.strstart++;if(Ye&&(ae(Ce,!1),Ce.strm.avail_out===0))return K}return Ce.insert=Ce.strstart<w-1?Ce.strstart:w-1,Ze===h?(ae(Ce,!0),Ce.strm.avail_out===0?W:j):Ce.last_lit&&(ae(Ce,!1),Ce.strm.avail_out===0)?K:J}function he(Ce,Ze){for(var Oe,Ye,qe;;){if(Ce.lookahead<R){if(xe(Ce),Ce.lookahead<R&&Ze===u)return K;if(Ce.lookahead===0)break}if(Oe=0,Ce.lookahead>=w&&(Ce.ins_h=(Ce.ins_h<<Ce.hash_shift^Ce.window[Ce.strstart+w-1])&Ce.hash_mask,Oe=Ce.prev[Ce.strstart&Ce.w_mask]=Ce.head[Ce.ins_h],Ce.head[Ce.ins_h]=Ce.strstart),Ce.prev_length=Ce.match_length,Ce.prev_match=Ce.match_start,Ce.match_length=w-1,Oe!==0&&Ce.prev_length<Ce.max_lazy_match&&Ce.strstart-Oe<=Ce.w_size-R&&(Ce.match_length=fe(Ce,Oe),Ce.match_length<=5&&(Ce.strategy===1||Ce.match_length===w&&4096<Ce.strstart-Ce.match_start)&&(Ce.match_length=w-1)),Ce.prev_length>=w&&Ce.match_length<=Ce.prev_length){for(qe=Ce.strstart+Ce.lookahead-w,Ye=a._tr_tally(Ce,Ce.strstart-1-Ce.prev_match,Ce.prev_length-w),Ce.lookahead-=Ce.prev_length-1,Ce.prev_length-=2;++Ce.strstart<=qe&&(Ce.ins_h=(Ce.ins_h<<Ce.hash_shift^Ce.window[Ce.strstart+w-1])&Ce.hash_mask,Oe=Ce.prev[Ce.strstart&Ce.w_mask]=Ce.head[Ce.ins_h],Ce.head[Ce.ins_h]=Ce.strstart),--Ce.prev_length!=0;);if(Ce.match_available=0,Ce.match_length=w-1,Ce.strstart++,Ye&&(ae(Ce,!1),Ce.strm.avail_out===0))return K}else if(Ce.match_available){if((Ye=a._tr_tally(Ce,0,Ce.window[Ce.strstart-1]))&&ae(Ce,!1),Ce.strstart++,Ce.lookahead--,Ce.strm.avail_out===0)return K}else Ce.match_available=1,Ce.strstart++,Ce.lookahead--}return Ce.match_available&&(Ye=a._tr_tally(Ce,0,Ce.window[Ce.strstart-1]),Ce.match_available=0),Ce.insert=Ce.strstart<w-1?Ce.strstart:w-1,Ze===h?(ae(Ce,!0),Ce.strm.avail_out===0?W:j):Ce.last_lit&&(ae(Ce,!1),Ce.strm.avail_out===0)?K:J}function be(Ce,Ze,Oe,Ye,qe){this.good_length=Ce,this.max_lazy=Ze,this.nice_length=Oe,this.max_chain=Ye,this.func=qe}function me(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=I,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new s.Buf16(2*S),this.dyn_dtree=new s.Buf16(2*(2*x+1)),this.bl_tree=new s.Buf16(2*(2*B+1)),ee(this.dyn_ltree),ee(this.dyn_dtree),ee(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new s.Buf16(D+1),this.heap=new s.Buf16(2*y+1),ee(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new s.Buf16(2*y+1),ee(this.depth),this.l_buf=0,this.lit_bufsize=0,this.last_lit=0,this.d_buf=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}function Ke(Ce){var Ze;return Ce&&Ce.state?(Ce.total_in=Ce.total_out=0,Ce.data_type=C,(Ze=Ce.state).pending=0,Ze.pending_out=0,Ze.wrap<0&&(Ze.wrap=-Ze.wrap),Ze.status=Ze.wrap?H:G,Ce.adler=Ze.wrap===2?0:1,Ze.last_flush=u,a._tr_init(Ze),d):se(Ce,_)}function Je(Ce){var Ze=Ke(Ce);return Ze===d&&(function(Oe){Oe.window_size=2*Oe.w_size,ee(Oe.head),Oe.max_lazy_match=A[Oe.level].max_lazy,Oe.good_match=A[Oe.level].good_length,Oe.nice_match=A[Oe.level].nice_length,Oe.max_chain_length=A[Oe.level].max_chain,Oe.strstart=0,Oe.block_start=0,Oe.lookahead=0,Oe.insert=0,Oe.match_length=Oe.prev_length=w-1,Oe.match_available=0,Oe.ins_h=0})(Ce.state),Ze}function et(Ce,Ze,Oe,Ye,qe,He){if(!Ce)return _;var Pe=1;if(Ze===m&&(Ze=6),Ye<0?(Pe=0,Ye=-Ye):15<Ye&&(Pe=2,Ye-=16),qe<1||f<qe||Oe!==I||Ye<8||15<Ye||Ze<0||9<Ze||He<0||p<He)return se(Ce,_);Ye===8&&(Ye=9);var ve=new me;return(Ce.state=ve).strm=Ce,ve.wrap=Pe,ve.gzhead=null,ve.w_bits=Ye,ve.w_size=1<<ve.w_bits,ve.w_mask=ve.w_size-1,ve.hash_bits=qe+7,ve.hash_size=1<<ve.hash_bits,ve.hash_mask=ve.hash_size-1,ve.hash_shift=~~((ve.hash_bits+w-1)/w),ve.window=new s.Buf8(2*ve.w_size),ve.head=new s.Buf16(ve.hash_size),ve.prev=new s.Buf16(ve.w_size),ve.lit_bufsize=1<<qe+6,ve.pending_buf_size=4*ve.lit_bufsize,ve.pending_buf=new s.Buf8(ve.pending_buf_size),ve.d_buf=1*ve.lit_bufsize,ve.l_buf=3*ve.lit_bufsize,ve.level=Ze,ve.strategy=He,ve.method=Oe,Je(Ce)}A=[new be(0,0,0,0,function(Ce,Ze){var Oe=65535;for(Oe>Ce.pending_buf_size-5&&(Oe=Ce.pending_buf_size-5);;){if(Ce.lookahead<=1){if(xe(Ce),Ce.lookahead===0&&Ze===u)return K;if(Ce.lookahead===0)break}Ce.strstart+=Ce.lookahead,Ce.lookahead=0;var Ye=Ce.block_start+Oe;if((Ce.strstart===0||Ce.strstart>=Ye)&&(Ce.lookahead=Ce.strstart-Ye,Ce.strstart=Ye,ae(Ce,!1),Ce.strm.avail_out===0)||Ce.strstart-Ce.block_start>=Ce.w_size-R&&(ae(Ce,!1),Ce.strm.avail_out===0))return K}return Ce.insert=0,Ze===h?(ae(Ce,!0),Ce.strm.avail_out===0?W:j):(Ce.strstart>Ce.block_start&&(ae(Ce,!1),Ce.strm.avail_out),K)}),new be(4,4,8,4,Qe),new be(4,5,16,8,Qe),new be(4,6,32,32,Qe),new be(4,4,16,16,he),new be(8,16,32,32,he),new be(8,16,128,128,he),new be(8,32,128,256,he),new be(32,128,258,1024,he),new be(32,258,258,4096,he)],r.deflateInit=function(Ce,Ze){return et(Ce,Ze,I,15,8,0)},r.deflateInit2=et,r.deflateReset=Je,r.deflateResetKeep=Ke,r.deflateSetHeader=function(Ce,Ze){return Ce&&Ce.state?Ce.state.wrap!==2?_:(Ce.state.gzhead=Ze,d):_},r.deflate=function(Ce,Ze){var Oe,Ye,qe,He;if(!Ce||!Ce.state||5<Ze||Ze<0)return Ce?se(Ce,_):_;if(Ye=Ce.state,!Ce.output||!Ce.input&&Ce.avail_in!==0||Ye.status===666&&Ze!==h)return se(Ce,Ce.avail_out===0?-5:_);if(Ye.strm=Ce,Oe=Ye.last_flush,Ye.last_flush=Ze,Ye.status===H)if(Ye.wrap===2)Ce.adler=0,ie(Ye,31),ie(Ye,139),ie(Ye,8),Ye.gzhead?(ie(Ye,(Ye.gzhead.text?1:0)+(Ye.gzhead.hcrc?2:0)+(Ye.gzhead.extra?4:0)+(Ye.gzhead.name?8:0)+(Ye.gzhead.comment?16:0)),ie(Ye,255&Ye.gzhead.time),ie(Ye,Ye.gzhead.time>>8&255),ie(Ye,Ye.gzhead.time>>16&255),ie(Ye,Ye.gzhead.time>>24&255),ie(Ye,Ye.level===9?2:2<=Ye.strategy||Ye.level<2?4:0),ie(Ye,255&Ye.gzhead.os),Ye.gzhead.extra&&Ye.gzhead.extra.length&&(ie(Ye,255&Ye.gzhead.extra.length),ie(Ye,Ye.gzhead.extra.length>>8&255)),Ye.gzhead.hcrc&&(Ce.adler=l(Ce.adler,Ye.pending_buf,Ye.pending,0)),Ye.gzindex=0,Ye.status=69):(ie(Ye,0),ie(Ye,0),ie(Ye,0),ie(Ye,0),ie(Ye,0),ie(Ye,Ye.level===9?2:2<=Ye.strategy||Ye.level<2?4:0),ie(Ye,3),Ye.status=G);else{var Pe=I+(Ye.w_bits-8<<4)<<8;Pe|=(2<=Ye.strategy||Ye.level<2?0:Ye.level<6?1:Ye.level===6?2:3)<<6,Ye.strstart!==0&&(Pe|=32),Pe+=31-Pe%31,Ye.status=G,le(Ye,Pe),Ye.strstart!==0&&(le(Ye,Ce.adler>>>16),le(Ye,65535&Ce.adler)),Ce.adler=1}if(Ye.status===69)if(Ye.gzhead.extra){for(qe=Ye.pending;Ye.gzindex<(65535&Ye.gzhead.extra.length)&&(Ye.pending!==Ye.pending_buf_size||(Ye.gzhead.hcrc&&Ye.pending>qe&&(Ce.adler=l(Ce.adler,Ye.pending_buf,Ye.pending-qe,qe)),oe(Ce),qe=Ye.pending,Ye.pending!==Ye.pending_buf_size));)ie(Ye,255&Ye.gzhead.extra[Ye.gzindex]),Ye.gzindex++;Ye.gzhead.hcrc&&Ye.pending>qe&&(Ce.adler=l(Ce.adler,Ye.pending_buf,Ye.pending-qe,qe)),Ye.gzindex===Ye.gzhead.extra.length&&(Ye.gzindex=0,Ye.status=73)}else Ye.status=73;if(Ye.status===73)if(Ye.gzhead.name){qe=Ye.pending;do{if(Ye.pending===Ye.pending_buf_size&&(Ye.gzhead.hcrc&&Ye.pending>qe&&(Ce.adler=l(Ce.adler,Ye.pending_buf,Ye.pending-qe,qe)),oe(Ce),qe=Ye.pending,Ye.pending===Ye.pending_buf_size)){He=1;break}He=Ye.gzindex<Ye.gzhead.name.length?255&Ye.gzhead.name.charCodeAt(Ye.gzindex++):0,ie(Ye,He)}while(He!==0);Ye.gzhead.hcrc&&Ye.pending>qe&&(Ce.adler=l(Ce.adler,Ye.pending_buf,Ye.pending-qe,qe)),He===0&&(Ye.gzindex=0,Ye.status=91)}else Ye.status=91;if(Ye.status===91)if(Ye.gzhead.comment){qe=Ye.pending;do{if(Ye.pending===Ye.pending_buf_size&&(Ye.gzhead.hcrc&&Ye.pending>qe&&(Ce.adler=l(Ce.adler,Ye.pending_buf,Ye.pending-qe,qe)),oe(Ce),qe=Ye.pending,Ye.pending===Ye.pending_buf_size)){He=1;break}He=Ye.gzindex<Ye.gzhead.comment.length?255&Ye.gzhead.comment.charCodeAt(Ye.gzindex++):0,ie(Ye,He)}while(He!==0);Ye.gzhead.hcrc&&Ye.pending>qe&&(Ce.adler=l(Ce.adler,Ye.pending_buf,Ye.pending-qe,qe)),He===0&&(Ye.status=103)}else Ye.status=103;if(Ye.status===103&&(Ye.gzhead.hcrc?(Ye.pending+2>Ye.pending_buf_size&&oe(Ce),Ye.pending+2<=Ye.pending_buf_size&&(ie(Ye,255&Ce.adler),ie(Ye,Ce.adler>>8&255),Ce.adler=0,Ye.status=G)):Ye.status=G),Ye.pending!==0){if(oe(Ce),Ce.avail_out===0)return Ye.last_flush=-1,d}else if(Ce.avail_in===0&&Ae(Ze)<=Ae(Oe)&&Ze!==h)return se(Ce,-5);if(Ye.status===666&&Ce.avail_in!==0)return se(Ce,-5);if(Ce.avail_in!==0||Ye.lookahead!==0||Ze!==u&&Ye.status!==666){var ve=Ye.strategy===2?(function(De,ze){for(var Xe;;){if(De.lookahead===0&&(xe(De),De.lookahead===0)){if(ze===u)return K;break}if(De.match_length=0,Xe=a._tr_tally(De,0,De.window[De.strstart]),De.lookahead--,De.strstart++,Xe&&(ae(De,!1),De.strm.avail_out===0))return K}return De.insert=0,ze===h?(ae(De,!0),De.strm.avail_out===0?W:j):De.last_lit&&(ae(De,!1),De.strm.avail_out===0)?K:J})(Ye,Ze):Ye.strategy===3?(function(De,ze){for(var Xe,st,ct,ut,gt=De.window;;){if(De.lookahead<=F){if(xe(De),De.lookahead<=F&&ze===u)return K;if(De.lookahead===0)break}if(De.match_length=0,De.lookahead>=w&&0<De.strstart&&(st=gt[ct=De.strstart-1])===gt[++ct]&&st===gt[++ct]&&st===gt[++ct]){ut=De.strstart+F;do;while(st===gt[++ct]&&st===gt[++ct]&&st===gt[++ct]&&st===gt[++ct]&&st===gt[++ct]&&st===gt[++ct]&&st===gt[++ct]&&st===gt[++ct]&&ct<ut);De.match_length=F-(ut-ct),De.match_length>De.lookahead&&(De.match_length=De.lookahead)}if(De.match_length>=w?(Xe=a._tr_tally(De,1,De.match_length-w),De.lookahead-=De.match_length,De.strstart+=De.match_length,De.match_length=0):(Xe=a._tr_tally(De,0,De.window[De.strstart]),De.lookahead--,De.strstart++),Xe&&(ae(De,!1),De.strm.avail_out===0))return K}return De.insert=0,ze===h?(ae(De,!0),De.strm.avail_out===0?W:j):De.last_lit&&(ae(De,!1),De.strm.avail_out===0)?K:J})(Ye,Ze):A[Ye.level].func(Ye,Ze);if(ve!==W&&ve!==j||(Ye.status=666),ve===K||ve===W)return Ce.avail_out===0&&(Ye.last_flush=-1),d;if(ve===J&&(Ze===1?a._tr_align(Ye):Ze!==5&&(a._tr_stored_block(Ye,0,0,!1),Ze===3&&(ee(Ye.head),Ye.lookahead===0&&(Ye.strstart=0,Ye.block_start=0,Ye.insert=0))),oe(Ce),Ce.avail_out===0))return Ye.last_flush=-1,d}return Ze!==h?d:Ye.wrap<=0?1:(Ye.wrap===2?(ie(Ye,255&Ce.adler),ie(Ye,Ce.adler>>8&255),ie(Ye,Ce.adler>>16&255),ie(Ye,Ce.adler>>24&255),ie(Ye,255&Ce.total_in),ie(Ye,Ce.total_in>>8&255),ie(Ye,Ce.total_in>>16&255),ie(Ye,Ce.total_in>>24&255)):(le(Ye,Ce.adler>>>16),le(Ye,65535&Ce.adler)),oe(Ce),0<Ye.wrap&&(Ye.wrap=-Ye.wrap),Ye.pending!==0?d:1)},r.deflateEnd=function(Ce){var Ze;return Ce&&Ce.state?(Ze=Ce.state.status)!==H&&Ze!==69&&Ze!==73&&Ze!==91&&Ze!==103&&Ze!==G&&Ze!==666?se(Ce,_):(Ce.state=null,Ze===G?se(Ce,-3):d):_},r.deflateSetDictionary=function(Ce,Ze){var Oe,Ye,qe,He,Pe,ve,De,ze,Xe=Ze.length;if(!Ce||!Ce.state||(He=(Oe=Ce.state).wrap)===2||He===1&&Oe.status!==H||Oe.lookahead)return _;for(He===1&&(Ce.adler=c(Ce.adler,Ze,Xe,0)),Oe.wrap=0,Xe>=Oe.w_size&&(He===0&&(ee(Oe.head),Oe.strstart=0,Oe.block_start=0,Oe.insert=0),ze=new s.Buf8(Oe.w_size),s.arraySet(ze,Ze,Xe-Oe.w_size,Oe.w_size,0),Ze=ze,Xe=Oe.w_size),Pe=Ce.avail_in,ve=Ce.next_in,De=Ce.input,Ce.avail_in=Xe,Ce.next_in=0,Ce.input=Ze,xe(Oe);Oe.lookahead>=w;){for(Ye=Oe.strstart,qe=Oe.lookahead-(w-1);Oe.ins_h=(Oe.ins_h<<Oe.hash_shift^Oe.window[Ye+w-1])&Oe.hash_mask,Oe.prev[Ye&Oe.w_mask]=Oe.head[Oe.ins_h],Oe.head[Oe.ins_h]=Ye,Ye++,--qe;);Oe.strstart=Ye,Oe.lookahead=w-1,xe(Oe)}return Oe.strstart+=Oe.lookahead,Oe.block_start=Oe.strstart,Oe.insert=Oe.lookahead,Oe.lookahead=0,Oe.match_length=Oe.prev_length=w-1,Oe.match_available=0,Ce.next_in=ve,Ce.input=De,Ce.avail_in=Pe,Oe.wrap=He,d},r.deflateInfo="pako deflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./messages":51,"./trees":52}],47:[function(o,i,r){i.exports=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}},{}],48:[function(o,i,r){i.exports=function(A,s){var a,c,l,g,u,h,d,_,m,p,C,I,f,y,x,B,S,D,w,F,R,H,G,K,J;a=A.state,c=A.next_in,K=A.input,l=c+(A.avail_in-5),g=A.next_out,J=A.output,u=g-(s-A.avail_out),h=g+(A.avail_out-257),d=a.dmax,_=a.wsize,m=a.whave,p=a.wnext,C=a.window,I=a.hold,f=a.bits,y=a.lencode,x=a.distcode,B=(1<<a.lenbits)-1,S=(1<<a.distbits)-1;e:do{f<15&&(I+=K[c++]<<f,f+=8,I+=K[c++]<<f,f+=8),D=y[I&B];t:for(;;){if(I>>>=w=D>>>24,f-=w,(w=D>>>16&255)===0)J[g++]=65535&D;else{if(!(16&w)){if((64&w)==0){D=y[(65535&D)+(I&(1<<w)-1)];continue t}if(32&w){a.mode=12;break e}A.msg="invalid literal/length code",a.mode=30;break e}F=65535&D,(w&=15)&&(f<w&&(I+=K[c++]<<f,f+=8),F+=I&(1<<w)-1,I>>>=w,f-=w),f<15&&(I+=K[c++]<<f,f+=8,I+=K[c++]<<f,f+=8),D=x[I&S];n:for(;;){if(I>>>=w=D>>>24,f-=w,!(16&(w=D>>>16&255))){if((64&w)==0){D=x[(65535&D)+(I&(1<<w)-1)];continue n}A.msg="invalid distance code",a.mode=30;break e}if(R=65535&D,f<(w&=15)&&(I+=K[c++]<<f,(f+=8)<w&&(I+=K[c++]<<f,f+=8)),d<(R+=I&(1<<w)-1)){A.msg="invalid distance too far back",a.mode=30;break e}if(I>>>=w,f-=w,(w=g-u)<R){if(m<(w=R-w)&&a.sane){A.msg="invalid distance too far back",a.mode=30;break e}if(G=C,(H=0)===p){if(H+=_-w,w<F){for(F-=w;J[g++]=C[H++],--w;);H=g-R,G=J}}else if(p<w){if(H+=_+p-w,(w-=p)<F){for(F-=w;J[g++]=C[H++],--w;);if(H=0,p<F){for(F-=w=p;J[g++]=C[H++],--w;);H=g-R,G=J}}}else if(H+=p-w,w<F){for(F-=w;J[g++]=C[H++],--w;);H=g-R,G=J}for(;2<F;)J[g++]=G[H++],J[g++]=G[H++],J[g++]=G[H++],F-=3;F&&(J[g++]=G[H++],1<F&&(J[g++]=G[H++]))}else{for(H=g-R;J[g++]=J[H++],J[g++]=J[H++],J[g++]=J[H++],2<(F-=3););F&&(J[g++]=J[H++],1<F&&(J[g++]=J[H++]))}break}}break}}while(c<l&&g<h);c-=F=f>>3,I&=(1<<(f-=F<<3))-1,A.next_in=c,A.next_out=g,A.avail_in=c<l?l-c+5:5-(c-l),A.avail_out=g<h?h-g+257:257-(g-h),a.hold=I,a.bits=f}},{}],49:[function(o,i,r){var A=o("../utils/common"),s=o("./adler32"),a=o("./crc32"),c=o("./inffast"),l=o("./inftrees"),g=1,u=2,h=0,d=-2,_=1,m=852,p=592;function C(H){return(H>>>24&255)+(H>>>8&65280)+((65280&H)<<8)+((255&H)<<24)}function I(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new A.Buf16(320),this.work=new A.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function f(H){var G;return H&&H.state?(G=H.state,H.total_in=H.total_out=G.total=0,H.msg="",G.wrap&&(H.adler=1&G.wrap),G.mode=_,G.last=0,G.havedict=0,G.dmax=32768,G.head=null,G.hold=0,G.bits=0,G.lencode=G.lendyn=new A.Buf32(m),G.distcode=G.distdyn=new A.Buf32(p),G.sane=1,G.back=-1,h):d}function y(H){var G;return H&&H.state?((G=H.state).wsize=0,G.whave=0,G.wnext=0,f(H)):d}function x(H,G){var K,J;return H&&H.state?(J=H.state,G<0?(K=0,G=-G):(K=1+(G>>4),G<48&&(G&=15)),G&&(G<8||15<G)?d:(J.window!==null&&J.wbits!==G&&(J.window=null),J.wrap=K,J.wbits=G,y(H))):d}function B(H,G){var K,J;return H?(J=new I,(H.state=J).window=null,(K=x(H,G))!==h&&(H.state=null),K):d}var S,D,w=!0;function F(H){if(w){var G;for(S=new A.Buf32(512),D=new A.Buf32(32),G=0;G<144;)H.lens[G++]=8;for(;G<256;)H.lens[G++]=9;for(;G<280;)H.lens[G++]=7;for(;G<288;)H.lens[G++]=8;for(l(g,H.lens,0,288,S,0,H.work,{bits:9}),G=0;G<32;)H.lens[G++]=5;l(u,H.lens,0,32,D,0,H.work,{bits:5}),w=!1}H.lencode=S,H.lenbits=9,H.distcode=D,H.distbits=5}function R(H,G,K,J){var W,j=H.state;return j.window===null&&(j.wsize=1<<j.wbits,j.wnext=0,j.whave=0,j.window=new A.Buf8(j.wsize)),J>=j.wsize?(A.arraySet(j.window,G,K-j.wsize,j.wsize,0),j.wnext=0,j.whave=j.wsize):(J<(W=j.wsize-j.wnext)&&(W=J),A.arraySet(j.window,G,K-J,W,j.wnext),(J-=W)?(A.arraySet(j.window,G,K-J,J,0),j.wnext=J,j.whave=j.wsize):(j.wnext+=W,j.wnext===j.wsize&&(j.wnext=0),j.whave<j.wsize&&(j.whave+=W))),0}r.inflateReset=y,r.inflateReset2=x,r.inflateResetKeep=f,r.inflateInit=function(H){return B(H,15)},r.inflateInit2=B,r.inflate=function(H,G){var K,J,W,j,se,Ae,ee,oe,ae,ie,le,fe,xe,Qe,he,be,me,Ke,Je,et,Ce,Ze,Oe,Ye,qe=0,He=new A.Buf8(4),Pe=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!H||!H.state||!H.output||!H.input&&H.avail_in!==0)return d;(K=H.state).mode===12&&(K.mode=13),se=H.next_out,W=H.output,ee=H.avail_out,j=H.next_in,J=H.input,Ae=H.avail_in,oe=K.hold,ae=K.bits,ie=Ae,le=ee,Ze=h;e:for(;;)switch(K.mode){case _:if(K.wrap===0){K.mode=13;break}for(;ae<16;){if(Ae===0)break e;Ae--,oe+=J[j++]<<ae,ae+=8}if(2&K.wrap&&oe===35615){He[K.check=0]=255&oe,He[1]=oe>>>8&255,K.check=a(K.check,He,2,0),ae=oe=0,K.mode=2;break}if(K.flags=0,K.head&&(K.head.done=!1),!(1&K.wrap)||(((255&oe)<<8)+(oe>>8))%31){H.msg="incorrect header check",K.mode=30;break}if((15&oe)!=8){H.msg="unknown compression method",K.mode=30;break}if(ae-=4,Ce=8+(15&(oe>>>=4)),K.wbits===0)K.wbits=Ce;else if(Ce>K.wbits){H.msg="invalid window size",K.mode=30;break}K.dmax=1<<Ce,H.adler=K.check=1,K.mode=512&oe?10:12,ae=oe=0;break;case 2:for(;ae<16;){if(Ae===0)break e;Ae--,oe+=J[j++]<<ae,ae+=8}if(K.flags=oe,(255&K.flags)!=8){H.msg="unknown compression method",K.mode=30;break}if(57344&K.flags){H.msg="unknown header flags set",K.mode=30;break}K.head&&(K.head.text=oe>>8&1),512&K.flags&&(He[0]=255&oe,He[1]=oe>>>8&255,K.check=a(K.check,He,2,0)),ae=oe=0,K.mode=3;case 3:for(;ae<32;){if(Ae===0)break e;Ae--,oe+=J[j++]<<ae,ae+=8}K.head&&(K.head.time=oe),512&K.flags&&(He[0]=255&oe,He[1]=oe>>>8&255,He[2]=oe>>>16&255,He[3]=oe>>>24&255,K.check=a(K.check,He,4,0)),ae=oe=0,K.mode=4;case 4:for(;ae<16;){if(Ae===0)break e;Ae--,oe+=J[j++]<<ae,ae+=8}K.head&&(K.head.xflags=255&oe,K.head.os=oe>>8),512&K.flags&&(He[0]=255&oe,He[1]=oe>>>8&255,K.check=a(K.check,He,2,0)),ae=oe=0,K.mode=5;case 5:if(1024&K.flags){for(;ae<16;){if(Ae===0)break e;Ae--,oe+=J[j++]<<ae,ae+=8}K.length=oe,K.head&&(K.head.extra_len=oe),512&K.flags&&(He[0]=255&oe,He[1]=oe>>>8&255,K.check=a(K.check,He,2,0)),ae=oe=0}else K.head&&(K.head.extra=null);K.mode=6;case 6:if(1024&K.flags&&(Ae<(fe=K.length)&&(fe=Ae),fe&&(K.head&&(Ce=K.head.extra_len-K.length,K.head.extra||(K.head.extra=new Array(K.head.extra_len)),A.arraySet(K.head.extra,J,j,fe,Ce)),512&K.flags&&(K.check=a(K.check,J,fe,j)),Ae-=fe,j+=fe,K.length-=fe),K.length))break e;K.length=0,K.mode=7;case 7:if(2048&K.flags){if(Ae===0)break e;for(fe=0;Ce=J[j+fe++],K.head&&Ce&&K.length<65536&&(K.head.name+=String.fromCharCode(Ce)),Ce&&fe<Ae;);if(512&K.flags&&(K.check=a(K.check,J,fe,j)),Ae-=fe,j+=fe,Ce)break e}else K.head&&(K.head.name=null);K.length=0,K.mode=8;case 8:if(4096&K.flags){if(Ae===0)break e;for(fe=0;Ce=J[j+fe++],K.head&&Ce&&K.length<65536&&(K.head.comment+=String.fromCharCode(Ce)),Ce&&fe<Ae;);if(512&K.flags&&(K.check=a(K.check,J,fe,j)),Ae-=fe,j+=fe,Ce)break e}else K.head&&(K.head.comment=null);K.mode=9;case 9:if(512&K.flags){for(;ae<16;){if(Ae===0)break e;Ae--,oe+=J[j++]<<ae,ae+=8}if(oe!==(65535&K.check)){H.msg="header crc mismatch",K.mode=30;break}ae=oe=0}K.head&&(K.head.hcrc=K.flags>>9&1,K.head.done=!0),H.adler=K.check=0,K.mode=12;break;case 10:for(;ae<32;){if(Ae===0)break e;Ae--,oe+=J[j++]<<ae,ae+=8}H.adler=K.check=C(oe),ae=oe=0,K.mode=11;case 11:if(K.havedict===0)return H.next_out=se,H.avail_out=ee,H.next_in=j,H.avail_in=Ae,K.hold=oe,K.bits=ae,2;H.adler=K.check=1,K.mode=12;case 12:if(G===5||G===6)break e;case 13:if(K.last){oe>>>=7&ae,ae-=7&ae,K.mode=27;break}for(;ae<3;){if(Ae===0)break e;Ae--,oe+=J[j++]<<ae,ae+=8}switch(K.last=1&oe,ae-=1,3&(oe>>>=1)){case 0:K.mode=14;break;case 1:if(F(K),K.mode=20,G!==6)break;oe>>>=2,ae-=2;break e;case 2:K.mode=17;break;case 3:H.msg="invalid block type",K.mode=30}oe>>>=2,ae-=2;break;case 14:for(oe>>>=7&ae,ae-=7&ae;ae<32;){if(Ae===0)break e;Ae--,oe+=J[j++]<<ae,ae+=8}if((65535&oe)!=(oe>>>16^65535)){H.msg="invalid stored block lengths",K.mode=30;break}if(K.length=65535&oe,ae=oe=0,K.mode=15,G===6)break e;case 15:K.mode=16;case 16:if(fe=K.length){if(Ae<fe&&(fe=Ae),ee<fe&&(fe=ee),fe===0)break e;A.arraySet(W,J,j,fe,se),Ae-=fe,j+=fe,ee-=fe,se+=fe,K.length-=fe;break}K.mode=12;break;case 17:for(;ae<14;){if(Ae===0)break e;Ae--,oe+=J[j++]<<ae,ae+=8}if(K.nlen=257+(31&oe),oe>>>=5,ae-=5,K.ndist=1+(31&oe),oe>>>=5,ae-=5,K.ncode=4+(15&oe),oe>>>=4,ae-=4,286<K.nlen||30<K.ndist){H.msg="too many length or distance symbols",K.mode=30;break}K.have=0,K.mode=18;case 18:for(;K.have<K.ncode;){for(;ae<3;){if(Ae===0)break e;Ae--,oe+=J[j++]<<ae,ae+=8}K.lens[Pe[K.have++]]=7&oe,oe>>>=3,ae-=3}for(;K.have<19;)K.lens[Pe[K.have++]]=0;if(K.lencode=K.lendyn,K.lenbits=7,Oe={bits:K.lenbits},Ze=l(0,K.lens,0,19,K.lencode,0,K.work,Oe),K.lenbits=Oe.bits,Ze){H.msg="invalid code lengths set",K.mode=30;break}K.have=0,K.mode=19;case 19:for(;K.have<K.nlen+K.ndist;){for(;be=(qe=K.lencode[oe&(1<<K.lenbits)-1])>>>16&255,me=65535&qe,!((he=qe>>>24)<=ae);){if(Ae===0)break e;Ae--,oe+=J[j++]<<ae,ae+=8}if(me<16)oe>>>=he,ae-=he,K.lens[K.have++]=me;else{if(me===16){for(Ye=he+2;ae<Ye;){if(Ae===0)break e;Ae--,oe+=J[j++]<<ae,ae+=8}if(oe>>>=he,ae-=he,K.have===0){H.msg="invalid bit length repeat",K.mode=30;break}Ce=K.lens[K.have-1],fe=3+(3&oe),oe>>>=2,ae-=2}else if(me===17){for(Ye=he+3;ae<Ye;){if(Ae===0)break e;Ae--,oe+=J[j++]<<ae,ae+=8}ae-=he,Ce=0,fe=3+(7&(oe>>>=he)),oe>>>=3,ae-=3}else{for(Ye=he+7;ae<Ye;){if(Ae===0)break e;Ae--,oe+=J[j++]<<ae,ae+=8}ae-=he,Ce=0,fe=11+(127&(oe>>>=he)),oe>>>=7,ae-=7}if(K.have+fe>K.nlen+K.ndist){H.msg="invalid bit length repeat",K.mode=30;break}for(;fe--;)K.lens[K.have++]=Ce}}if(K.mode===30)break;if(K.lens[256]===0){H.msg="invalid code -- missing end-of-block",K.mode=30;break}if(K.lenbits=9,Oe={bits:K.lenbits},Ze=l(g,K.lens,0,K.nlen,K.lencode,0,K.work,Oe),K.lenbits=Oe.bits,Ze){H.msg="invalid literal/lengths set",K.mode=30;break}if(K.distbits=6,K.distcode=K.distdyn,Oe={bits:K.distbits},Ze=l(u,K.lens,K.nlen,K.ndist,K.distcode,0,K.work,Oe),K.distbits=Oe.bits,Ze){H.msg="invalid distances set",K.mode=30;break}if(K.mode=20,G===6)break e;case 20:K.mode=21;case 21:if(6<=Ae&&258<=ee){H.next_out=se,H.avail_out=ee,H.next_in=j,H.avail_in=Ae,K.hold=oe,K.bits=ae,c(H,le),se=H.next_out,W=H.output,ee=H.avail_out,j=H.next_in,J=H.input,Ae=H.avail_in,oe=K.hold,ae=K.bits,K.mode===12&&(K.back=-1);break}for(K.back=0;be=(qe=K.lencode[oe&(1<<K.lenbits)-1])>>>16&255,me=65535&qe,!((he=qe>>>24)<=ae);){if(Ae===0)break e;Ae--,oe+=J[j++]<<ae,ae+=8}if(be&&(240&be)==0){for(Ke=he,Je=be,et=me;be=(qe=K.lencode[et+((oe&(1<<Ke+Je)-1)>>Ke)])>>>16&255,me=65535&qe,!(Ke+(he=qe>>>24)<=ae);){if(Ae===0)break e;Ae--,oe+=J[j++]<<ae,ae+=8}oe>>>=Ke,ae-=Ke,K.back+=Ke}if(oe>>>=he,ae-=he,K.back+=he,K.length=me,be===0){K.mode=26;break}if(32&be){K.back=-1,K.mode=12;break}if(64&be){H.msg="invalid literal/length code",K.mode=30;break}K.extra=15&be,K.mode=22;case 22:if(K.extra){for(Ye=K.extra;ae<Ye;){if(Ae===0)break e;Ae--,oe+=J[j++]<<ae,ae+=8}K.length+=oe&(1<<K.extra)-1,oe>>>=K.extra,ae-=K.extra,K.back+=K.extra}K.was=K.length,K.mode=23;case 23:for(;be=(qe=K.distcode[oe&(1<<K.distbits)-1])>>>16&255,me=65535&qe,!((he=qe>>>24)<=ae);){if(Ae===0)break e;Ae--,oe+=J[j++]<<ae,ae+=8}if((240&be)==0){for(Ke=he,Je=be,et=me;be=(qe=K.distcode[et+((oe&(1<<Ke+Je)-1)>>Ke)])>>>16&255,me=65535&qe,!(Ke+(he=qe>>>24)<=ae);){if(Ae===0)break e;Ae--,oe+=J[j++]<<ae,ae+=8}oe>>>=Ke,ae-=Ke,K.back+=Ke}if(oe>>>=he,ae-=he,K.back+=he,64&be){H.msg="invalid distance code",K.mode=30;break}K.offset=me,K.extra=15&be,K.mode=24;case 24:if(K.extra){for(Ye=K.extra;ae<Ye;){if(Ae===0)break e;Ae--,oe+=J[j++]<<ae,ae+=8}K.offset+=oe&(1<<K.extra)-1,oe>>>=K.extra,ae-=K.extra,K.back+=K.extra}if(K.offset>K.dmax){H.msg="invalid distance too far back",K.mode=30;break}K.mode=25;case 25:if(ee===0)break e;if(fe=le-ee,K.offset>fe){if((fe=K.offset-fe)>K.whave&&K.sane){H.msg="invalid distance too far back",K.mode=30;break}xe=fe>K.wnext?(fe-=K.wnext,K.wsize-fe):K.wnext-fe,fe>K.length&&(fe=K.length),Qe=K.window}else Qe=W,xe=se-K.offset,fe=K.length;for(ee<fe&&(fe=ee),ee-=fe,K.length-=fe;W[se++]=Qe[xe++],--fe;);K.length===0&&(K.mode=21);break;case 26:if(ee===0)break e;W[se++]=K.length,ee--,K.mode=21;break;case 27:if(K.wrap){for(;ae<32;){if(Ae===0)break e;Ae--,oe|=J[j++]<<ae,ae+=8}if(le-=ee,H.total_out+=le,K.total+=le,le&&(H.adler=K.check=K.flags?a(K.check,W,le,se-le):s(K.check,W,le,se-le)),le=ee,(K.flags?oe:C(oe))!==K.check){H.msg="incorrect data check",K.mode=30;break}ae=oe=0}K.mode=28;case 28:if(K.wrap&&K.flags){for(;ae<32;){if(Ae===0)break e;Ae--,oe+=J[j++]<<ae,ae+=8}if(oe!==(4294967295&K.total)){H.msg="incorrect length check",K.mode=30;break}ae=oe=0}K.mode=29;case 29:Ze=1;break e;case 30:Ze=-3;break e;case 31:return-4;default:return d}return H.next_out=se,H.avail_out=ee,H.next_in=j,H.avail_in=Ae,K.hold=oe,K.bits=ae,(K.wsize||le!==H.avail_out&&K.mode<30&&(K.mode<27||G!==4))&&R(H,H.output,H.next_out,le-H.avail_out)?(K.mode=31,-4):(ie-=H.avail_in,le-=H.avail_out,H.total_in+=ie,H.total_out+=le,K.total+=le,K.wrap&&le&&(H.adler=K.check=K.flags?a(K.check,W,le,H.next_out-le):s(K.check,W,le,H.next_out-le)),H.data_type=K.bits+(K.last?64:0)+(K.mode===12?128:0)+(K.mode===20||K.mode===15?256:0),(ie==0&&le===0||G===4)&&Ze===h&&(Ze=-5),Ze)},r.inflateEnd=function(H){if(!H||!H.state)return d;var G=H.state;return G.window&&(G.window=null),H.state=null,h},r.inflateGetHeader=function(H,G){var K;return H&&H.state?(2&(K=H.state).wrap)==0?d:((K.head=G).done=!1,h):d},r.inflateSetDictionary=function(H,G){var K,J=G.length;return H&&H.state?(K=H.state).wrap!==0&&K.mode!==11?d:K.mode===11&&s(1,G,J,0)!==K.check?-3:R(H,G,J,J)?(K.mode=31,-4):(K.havedict=1,h):d},r.inflateInfo="pako inflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./inffast":48,"./inftrees":50}],50:[function(o,i,r){var A=o("../utils/common"),s=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0],a=[16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78],c=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0],l=[16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64];i.exports=function(g,u,h,d,_,m,p,C){var I,f,y,x,B,S,D,w,F,R=C.bits,H=0,G=0,K=0,J=0,W=0,j=0,se=0,Ae=0,ee=0,oe=0,ae=null,ie=0,le=new A.Buf16(16),fe=new A.Buf16(16),xe=null,Qe=0;for(H=0;H<=15;H++)le[H]=0;for(G=0;G<d;G++)le[u[h+G]]++;for(W=R,J=15;1<=J&&le[J]===0;J--);if(J<W&&(W=J),J===0)return _[m++]=20971520,_[m++]=20971520,C.bits=1,0;for(K=1;K<J&&le[K]===0;K++);for(W<K&&(W=K),H=Ae=1;H<=15;H++)if(Ae<<=1,(Ae-=le[H])<0)return-1;if(0<Ae&&(g===0||J!==1))return-1;for(fe[1]=0,H=1;H<15;H++)fe[H+1]=fe[H]+le[H];for(G=0;G<d;G++)u[h+G]!==0&&(p[fe[u[h+G]]++]=G);if(S=g===0?(ae=xe=p,19):g===1?(ae=s,ie-=257,xe=a,Qe-=257,256):(ae=c,xe=l,-1),H=K,B=m,se=G=oe=0,y=-1,x=(ee=1<<(j=W))-1,g===1&&852<ee||g===2&&592<ee)return 1;for(;;){for(D=H-se,F=p[G]<S?(w=0,p[G]):p[G]>S?(w=xe[Qe+p[G]],ae[ie+p[G]]):(w=96,0),I=1<<H-se,K=f=1<<j;_[B+(oe>>se)+(f-=I)]=D<<24|w<<16|F|0,f!==0;);for(I=1<<H-1;oe&I;)I>>=1;if(I!==0?(oe&=I-1,oe+=I):oe=0,G++,--le[H]==0){if(H===J)break;H=u[h+p[G]]}if(W<H&&(oe&x)!==y){for(se===0&&(se=W),B+=K,Ae=1<<(j=H-se);j+se<J&&!((Ae-=le[j+se])<=0);)j++,Ae<<=1;if(ee+=1<<j,g===1&&852<ee||g===2&&592<ee)return 1;_[y=oe&x]=W<<24|j<<16|B-m|0}}return oe!==0&&(_[B+oe]=H-se<<24|64<<16|0),C.bits=W,0}},{"../utils/common":41}],51:[function(o,i,r){i.exports={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"}},{}],52:[function(o,i,r){var A=o("../utils/common"),s=0,a=1;function c(qe){for(var He=qe.length;0<=--He;)qe[He]=0}var l=0,g=29,u=256,h=u+1+g,d=30,_=19,m=2*h+1,p=15,C=16,I=7,f=256,y=16,x=17,B=18,S=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0],D=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],w=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],F=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],R=new Array(2*(h+2));c(R);var H=new Array(2*d);c(H);var G=new Array(512);c(G);var K=new Array(256);c(K);var J=new Array(g);c(J);var W,j,se,Ae=new Array(d);function ee(qe,He,Pe,ve,De){this.static_tree=qe,this.extra_bits=He,this.extra_base=Pe,this.elems=ve,this.max_length=De,this.has_stree=qe&&qe.length}function oe(qe,He){this.dyn_tree=qe,this.max_code=0,this.stat_desc=He}function ae(qe){return qe<256?G[qe]:G[256+(qe>>>7)]}function ie(qe,He){qe.pending_buf[qe.pending++]=255&He,qe.pending_buf[qe.pending++]=He>>>8&255}function le(qe,He,Pe){qe.bi_valid>C-Pe?(qe.bi_buf|=He<<qe.bi_valid&65535,ie(qe,qe.bi_buf),qe.bi_buf=He>>C-qe.bi_valid,qe.bi_valid+=Pe-C):(qe.bi_buf|=He<<qe.bi_valid&65535,qe.bi_valid+=Pe)}function fe(qe,He,Pe){le(qe,Pe[2*He],Pe[2*He+1])}function xe(qe,He){for(var Pe=0;Pe|=1&qe,qe>>>=1,Pe<<=1,0<--He;);return Pe>>>1}function Qe(qe,He,Pe){var ve,De,ze=new Array(p+1),Xe=0;for(ve=1;ve<=p;ve++)ze[ve]=Xe=Xe+Pe[ve-1]<<1;for(De=0;De<=He;De++){var st=qe[2*De+1];st!==0&&(qe[2*De]=xe(ze[st]++,st))}}function he(qe){var He;for(He=0;He<h;He++)qe.dyn_ltree[2*He]=0;for(He=0;He<d;He++)qe.dyn_dtree[2*He]=0;for(He=0;He<_;He++)qe.bl_tree[2*He]=0;qe.dyn_ltree[2*f]=1,qe.opt_len=qe.static_len=0,qe.last_lit=qe.matches=0}function be(qe){8<qe.bi_valid?ie(qe,qe.bi_buf):0<qe.bi_valid&&(qe.pending_buf[qe.pending++]=qe.bi_buf),qe.bi_buf=0,qe.bi_valid=0}function me(qe,He,Pe,ve){var De=2*He,ze=2*Pe;return qe[De]<qe[ze]||qe[De]===qe[ze]&&ve[He]<=ve[Pe]}function Ke(qe,He,Pe){for(var ve=qe.heap[Pe],De=Pe<<1;De<=qe.heap_len&&(De<qe.heap_len&&me(He,qe.heap[De+1],qe.heap[De],qe.depth)&&De++,!me(He,ve,qe.heap[De],qe.depth));)qe.heap[Pe]=qe.heap[De],Pe=De,De<<=1;qe.heap[Pe]=ve}function Je(qe,He,Pe){var ve,De,ze,Xe,st=0;if(qe.last_lit!==0)for(;ve=qe.pending_buf[qe.d_buf+2*st]<<8|qe.pending_buf[qe.d_buf+2*st+1],De=qe.pending_buf[qe.l_buf+st],st++,ve===0?fe(qe,De,He):(fe(qe,(ze=K[De])+u+1,He),(Xe=S[ze])!==0&&le(qe,De-=J[ze],Xe),fe(qe,ze=ae(--ve),Pe),(Xe=D[ze])!==0&&le(qe,ve-=Ae[ze],Xe)),st<qe.last_lit;);fe(qe,f,He)}function et(qe,He){var Pe,ve,De,ze=He.dyn_tree,Xe=He.stat_desc.static_tree,st=He.stat_desc.has_stree,ct=He.stat_desc.elems,ut=-1;for(qe.heap_len=0,qe.heap_max=m,Pe=0;Pe<ct;Pe++)ze[2*Pe]!==0?(qe.heap[++qe.heap_len]=ut=Pe,qe.depth[Pe]=0):ze[2*Pe+1]=0;for(;qe.heap_len<2;)ze[2*(De=qe.heap[++qe.heap_len]=ut<2?++ut:0)]=1,qe.depth[De]=0,qe.opt_len--,st&&(qe.static_len-=Xe[2*De+1]);for(He.max_code=ut,Pe=qe.heap_len>>1;1<=Pe;Pe--)Ke(qe,ze,Pe);for(De=ct;Pe=qe.heap[1],qe.heap[1]=qe.heap[qe.heap_len--],Ke(qe,ze,1),ve=qe.heap[1],qe.heap[--qe.heap_max]=Pe,qe.heap[--qe.heap_max]=ve,ze[2*De]=ze[2*Pe]+ze[2*ve],qe.depth[De]=(qe.depth[Pe]>=qe.depth[ve]?qe.depth[Pe]:qe.depth[ve])+1,ze[2*Pe+1]=ze[2*ve+1]=De,qe.heap[1]=De++,Ke(qe,ze,1),2<=qe.heap_len;);qe.heap[--qe.heap_max]=qe.heap[1],(function(gt,Ct){var Dt,mt,Nt,Ht,gn,dn,Jt=Ct.dyn_tree,Ie=Ct.max_code,At=Ct.stat_desc.static_tree,ht=Ct.stat_desc.has_stree,_t=Ct.stat_desc.extra_bits,Gt=Ct.stat_desc.extra_base,Yt=Ct.stat_desc.max_length,un=0;for(Ht=0;Ht<=p;Ht++)gt.bl_count[Ht]=0;for(Jt[2*gt.heap[gt.heap_max]+1]=0,Dt=gt.heap_max+1;Dt<m;Dt++)Yt<(Ht=Jt[2*Jt[2*(mt=gt.heap[Dt])+1]+1]+1)&&(Ht=Yt,un++),Jt[2*mt+1]=Ht,Ie<mt||(gt.bl_count[Ht]++,gn=0,Gt<=mt&&(gn=_t[mt-Gt]),dn=Jt[2*mt],gt.opt_len+=dn*(Ht+gn),ht&&(gt.static_len+=dn*(At[2*mt+1]+gn)));if(un!==0){do{for(Ht=Yt-1;gt.bl_count[Ht]===0;)Ht--;gt.bl_count[Ht]--,gt.bl_count[Ht+1]+=2,gt.bl_count[Yt]--,un-=2}while(0<un);for(Ht=Yt;Ht!==0;Ht--)for(mt=gt.bl_count[Ht];mt!==0;)Ie<(Nt=gt.heap[--Dt])||(Jt[2*Nt+1]!==Ht&&(gt.opt_len+=(Ht-Jt[2*Nt+1])*Jt[2*Nt],Jt[2*Nt+1]=Ht),mt--)}})(qe,He),Qe(ze,ut,qe.bl_count)}function Ce(qe,He,Pe){var ve,De,ze=-1,Xe=He[1],st=0,ct=7,ut=4;for(Xe===0&&(ct=138,ut=3),He[2*(Pe+1)+1]=65535,ve=0;ve<=Pe;ve++)De=Xe,Xe=He[2*(ve+1)+1],++st<ct&&De===Xe||(st<ut?qe.bl_tree[2*De]+=st:De!==0?(De!==ze&&qe.bl_tree[2*De]++,qe.bl_tree[2*y]++):st<=10?qe.bl_tree[2*x]++:qe.bl_tree[2*B]++,ze=De,ut=(st=0)===Xe?(ct=138,3):De===Xe?(ct=6,3):(ct=7,4))}function Ze(qe,He,Pe){var ve,De,ze=-1,Xe=He[1],st=0,ct=7,ut=4;for(Xe===0&&(ct=138,ut=3),ve=0;ve<=Pe;ve++)if(De=Xe,Xe=He[2*(ve+1)+1],!(++st<ct&&De===Xe)){if(st<ut)for(;fe(qe,De,qe.bl_tree),--st!=0;);else De!==0?(De!==ze&&(fe(qe,De,qe.bl_tree),st--),fe(qe,y,qe.bl_tree),le(qe,st-3,2)):st<=10?(fe(qe,x,qe.bl_tree),le(qe,st-3,3)):(fe(qe,B,qe.bl_tree),le(qe,st-11,7));ze=De,ut=(st=0)===Xe?(ct=138,3):De===Xe?(ct=6,3):(ct=7,4)}}c(Ae);var Oe=!1;function Ye(qe,He,Pe,ve){le(qe,(l<<1)+(ve?1:0),3),(function(De,ze,Xe,st){be(De),ie(De,Xe),ie(De,~Xe),A.arraySet(De.pending_buf,De.window,ze,Xe,De.pending),De.pending+=Xe})(qe,He,Pe)}r._tr_init=function(qe){Oe||((function(){var He,Pe,ve,De,ze,Xe=new Array(p+1);for(De=ve=0;De<g-1;De++)for(J[De]=ve,He=0;He<1<<S[De];He++)K[ve++]=De;for(K[ve-1]=De,De=ze=0;De<16;De++)for(Ae[De]=ze,He=0;He<1<<D[De];He++)G[ze++]=De;for(ze>>=7;De<d;De++)for(Ae[De]=ze<<7,He=0;He<1<<D[De]-7;He++)G[256+ze++]=De;for(Pe=0;Pe<=p;Pe++)Xe[Pe]=0;for(He=0;He<=143;)R[2*He+1]=8,He++,Xe[8]++;for(;He<=255;)R[2*He+1]=9,He++,Xe[9]++;for(;He<=279;)R[2*He+1]=7,He++,Xe[7]++;for(;He<=287;)R[2*He+1]=8,He++,Xe[8]++;for(Qe(R,h+1,Xe),He=0;He<d;He++)H[2*He+1]=5,H[2*He]=xe(He,5);W=new ee(R,S,u+1,h,p),j=new ee(H,D,0,d,p),se=new ee(new Array(0),w,0,_,I)})(),Oe=!0),qe.l_desc=new oe(qe.dyn_ltree,W),qe.d_desc=new oe(qe.dyn_dtree,j),qe.bl_desc=new oe(qe.bl_tree,se),qe.bi_buf=0,qe.bi_valid=0,he(qe)},r._tr_stored_block=Ye,r._tr_flush_block=function(qe,He,Pe,ve){var De,ze,Xe=0;0<qe.level?(qe.strm.data_type===2&&(qe.strm.data_type=(function(st){var ct,ut=4093624447;for(ct=0;ct<=31;ct++,ut>>>=1)if(1&ut&&st.dyn_ltree[2*ct]!==0)return s;if(st.dyn_ltree[18]!==0||st.dyn_ltree[20]!==0||st.dyn_ltree[26]!==0)return a;for(ct=32;ct<u;ct++)if(st.dyn_ltree[2*ct]!==0)return a;return s})(qe)),et(qe,qe.l_desc),et(qe,qe.d_desc),Xe=(function(st){var ct;for(Ce(st,st.dyn_ltree,st.l_desc.max_code),Ce(st,st.dyn_dtree,st.d_desc.max_code),et(st,st.bl_desc),ct=_-1;3<=ct&&st.bl_tree[2*F[ct]+1]===0;ct--);return st.opt_len+=3*(ct+1)+5+5+4,ct})(qe),De=qe.opt_len+3+7>>>3,(ze=qe.static_len+3+7>>>3)<=De&&(De=ze)):De=ze=Pe+5,Pe+4<=De&&He!==-1?Ye(qe,He,Pe,ve):qe.strategy===4||ze===De?(le(qe,2+(ve?1:0),3),Je(qe,R,H)):(le(qe,4+(ve?1:0),3),(function(st,ct,ut,gt){var Ct;for(le(st,ct-257,5),le(st,ut-1,5),le(st,gt-4,4),Ct=0;Ct<gt;Ct++)le(st,st.bl_tree[2*F[Ct]+1],3);Ze(st,st.dyn_ltree,ct-1),Ze(st,st.dyn_dtree,ut-1)})(qe,qe.l_desc.max_code+1,qe.d_desc.max_code+1,Xe+1),Je(qe,qe.dyn_ltree,qe.dyn_dtree)),he(qe),ve&&be(qe)},r._tr_tally=function(qe,He,Pe){return qe.pending_buf[qe.d_buf+2*qe.last_lit]=He>>>8&255,qe.pending_buf[qe.d_buf+2*qe.last_lit+1]=255&He,qe.pending_buf[qe.l_buf+qe.last_lit]=255&Pe,qe.last_lit++,He===0?qe.dyn_ltree[2*Pe]++:(qe.matches++,He--,qe.dyn_ltree[2*(K[Pe]+u+1)]++,qe.dyn_dtree[2*ae(He)]++),qe.last_lit===qe.lit_bufsize-1},r._tr_align=function(qe){le(qe,2,3),fe(qe,f,R),(function(He){He.bi_valid===16?(ie(He,He.bi_buf),He.bi_buf=0,He.bi_valid=0):8<=He.bi_valid&&(He.pending_buf[He.pending++]=255&He.bi_buf,He.bi_buf>>=8,He.bi_valid-=8)})(qe)}},{"../utils/common":41}],53:[function(o,i,r){i.exports=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}},{}],54:[function(o,i,r){(function(A){(function(s,a){if(!s.setImmediate){var c,l,g,u,h=1,d={},_=!1,m=s.document,p=Object.getPrototypeOf&&Object.getPrototypeOf(s);p=p&&p.setTimeout?p:s,c={}.toString.call(s.process)==="[object process]"?function(y){n.nextTick(function(){I(y)})}:(function(){if(s.postMessage&&!s.importScripts){var y=!0,x=s.onmessage;return s.onmessage=function(){y=!1},s.postMessage("","*"),s.onmessage=x,y}})()?(u="setImmediate$"+Math.random()+"$",s.addEventListener?s.addEventListener("message",f,!1):s.attachEvent("onmessage",f),function(y){s.postMessage(u+y,"*")}):s.MessageChannel?((g=new MessageChannel).port1.onmessage=function(y){I(y.data)},function(y){g.port2.postMessage(y)}):m&&"onreadystatechange"in m.createElement("script")?(l=m.documentElement,function(y){var x=m.createElement("script");x.onreadystatechange=function(){I(y),x.onreadystatechange=null,l.removeChild(x),x=null},l.appendChild(x)}):function(y){setTimeout(I,0,y)},p.setImmediate=function(y){typeof y!="function"&&(y=new Function(""+y));for(var x=new Array(arguments.length-1),B=0;B<x.length;B++)x[B]=arguments[B+1];var S={callback:y,args:x};return d[h]=S,c(h),h++},p.clearImmediate=C}function C(y){delete d[y]}function I(y){if(_)setTimeout(I,0,y);else{var x=d[y];if(x){_=!0;try{(function(B){var S=B.callback,D=B.args;switch(D.length){case 0:S();break;case 1:S(D[0]);break;case 2:S(D[0],D[1]);break;case 3:S(D[0],D[1],D[2]);break;default:S.apply(a,D)}})(x)}finally{C(y),_=!1}}}}function f(y){y.source===s&&typeof y.data=="string"&&y.data.indexOf(u)===0&&I(+y.data.slice(u.length))}})(typeof self>"u"?A===void 0?this:A:self)}).call(this,typeof cf<"u"?cf:typeof self<"u"?self:typeof window<"u"?window:{})},{}]},{},[10])(10)})})(n6e)),n6e.exports}var ZKo=$Ko();const o6e=R1(ZKo),eUo=async({circuitJson:t,projectName:e})=>{await zA.promise((async()=>{const n=new o6e,[{stringifyGerberCommandLayers:o,convertSoupToGerberCommands:i,convertSoupToExcellonDrillCommands:r,stringifyExcellonDrill:A},{convertCircuitJsonToBomRows:s,convertBomRowsToCsv:a},{convertCircuitJsonToPickAndPlaceCsv:c}]=await Promise.all([DB("circuit-json-to-gerber"),DB("circuit-json-to-bom-csv"),DB("circuit-json-to-pnp-csv")]),l=t.filter(I=>!("error_type"in I)&&!("warning_type"in I)),g=i(l,{flip_y_axis:!1}),u=o(g);for(const[I,f]of Object.entries(u))n.file(`gerber/${I}.gbr`,f);const h=r({circuitJson:l,is_plated:!0,flip_y_axis:!1}),d=A(h);n.file("gerber/drill.drl",d);const _=await s({circuitJson:t}),m=await a(_);n.file("bom.csv",m);const p=await c(t,{supplier:"jlcpcb"});n.file("pick_and_place.csv",p);const C=await n.generateAsync({type:"blob"});wS(C,{fileName:`${e}_fabrication_files.zip`})})(),{loading:"Generating fabrication files...",success:"Fabrication ZIP ready",error:n=>`Failed to generate fabrication files: ${n instanceof Error?n.message:String(n)}`})},tUo=async({circuitJson:t,projectName:e})=>{let n;try{const{convertCircuitJsonToGltf:o}=await DB("circuit-json-to-gltf");console.log("convertCircuitJsonToGltf",o);const i=await o(t,{format:"glb",boardTextureResolution:1024});if(!i||!(i instanceof ArrayBuffer))throw new Error("Invalid GLB data returned from converter");n=new Blob([i],{type:"model/gltf-binary"})}catch(o){console.error("GLB Export Error:",o);return}wS(n,{fileName:`${e}.glb`})},nUo=async({circuitJson:t,libraryName:e})=>{const{CircuitJsonToKicadLibraryConverter:n}=await DB("circuit-json-to-kicad"),o=new n(t,{libraryName:e,footprintLibraryName:e});o.runUntilFinished();const i=o.getOutput(),r=new o6e;r.file(`${e}.kicad_sym`,i.kicadSymString);for(const A of i.footprints){const s=r.folder(`${e}.pretty`);s&&s.file(`${A.footprintName}.kicad_mod`,`${A.kicadModString}
|
|
5761
5761
|
`)}if(i.model3dSourcePaths.length>0){const A=r.folder(`${e}.3dshapes`);if(A)for(const s of i.model3dSourcePaths)try{const a=s.split("/").pop()||s,c=await fetch(s);if(c.ok){const l=await c.arrayBuffer();A.file(a,l)}}catch{}}return r.file("fp-lib-table",i.fpLibTableString),r.file("sym-lib-table",i.symLibTableString),r},oUo=async({circuitJson:t,projectName:e})=>{await zA.promise((async()=>{const o=await(await nUo({circuitJson:t,libraryName:e})).generateAsync({type:"blob"});wS(o,{fileName:`${e}_kicad_library.zip`})})(),{loading:"Generating KiCad library...",success:"KiCad library ZIP ready",error:n=>`Failed to generate KiCad library: ${n instanceof Error?n.message:String(n)}`})},iUo=async({circuitJson:t,projectName:e})=>{const{CircuitJsonToKicadPcbConverter:n,CircuitJsonToKicadSchConverter:o,CircuitJsonToKicadProConverter:i,resolveAndLoadKicad3dModelFiles:r}=await DB("circuit-json-to-kicad"),A=new o(t);A.runUntilFinished();const s=A.getOutputString(),a=new n(t,{includeBuiltin3dModels:!0,projectName:e});a.runUntilFinished();const c=a.getOutputString(),l=new i(t,{projectName:e,schematicFilename:`${e}.kicad_sch`,pcbFilename:`${e}.kicad_pcb`});l.runUntilFinished();const g=l.getOutputString(),u=new o6e;return u.file(`${e}.kicad_sch`,s),u.file(`${e}.kicad_pcb`,c),u.file(`${e}.kicad_pro`,g),await r({projectName:e,model3dSourcePaths:a.getModel3dSourcePaths(),fetch,onModelFile:({outputPath:h,content:d})=>{u.file(h,d)},onError:({sourcePath:h})=>{console.warn(`Failed to load 3D model from ${h}`)}}),u},rUo=async({circuitJson:t,projectName:e})=>{await zA.promise((async()=>{const o=await(await iUo({circuitJson:t,projectName:e})).generateAsync({type:"blob"});wS(o,{fileName:`${e}_kicad_project.zip`})})(),{loading:"Generating KiCad project...",success:"KiCad project ZIP ready",error:n=>`Failed to generate KiCad project: ${n instanceof Error?n.message:String(n)}`})},hTt=async({circuitJson:t,projectName:e,options:n={}})=>{try{const{convertCircuitJsonToLbrn:o}=await DB("circuit-json-to-lbrn"),r=(await o(t,{includeSilkscreen:n.includeSilkscreen??!1,includeOxidationCleaningLayer:n.includeOxidationCleaningLayer??!0})).toXml(),A=new Blob([r],{type:"application/lbrn"});wS(A,{fileName:`${e}.lbrn2`})}catch(o){const i=o instanceof Error?o.message:"Unknown error";zA.error(`Failed to export to LBRN format: ${i}`)}},AUo=async({circuitJson:t,projectName:e})=>{const{convertCircuitJsonToPinoutSvg:n}=await DB("circuit-to-svg"),o=n(t);wS(o,{fileName:`${e}-pinout.svg`,mimeType:"image/svg+xml"})},sUo=async({circuitJson:t,projectName:e})=>{const{circuitJsonToStep:n}=await DB("circuit-json-to-step"),o=t.find(c=>c.type==="pcb_board"),i=o&&"width"in o?o.width:void 0,r=o&&"height"in o?o.height:void 0,A=o&&"thickness"in o?o.thickness:void 0;if(i===void 0||r===void 0||A===void 0){zA.error("Board dimensions not found. Please add a pcb_board with width, height, and thickness to your circuit.");return}let s;try{s=await n(t,{boardWidth:i,boardHeight:r,boardThickness:A,productName:e,includeComponents:!0,includeExternalMeshes:!0})}catch(c){const l=c instanceof Error?c.message:"Unknown error";zA.error(`Failed to convert circuit to STEP format: ${l}`);return}const a=new Blob([s],{type:"application/step"});try{wS(a,{fileName:`${e}.step`})}catch(c){const l=c instanceof Error?c.message:"Unknown error";zA.error(`Failed to download STEP file: ${l}`)}},aUo=[{extension:"json",name:"Circuit JSON"},{extension:"json",name:"Simple Route 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"}],cUo=async({exportName:t,circuitJson:e,simpleRouteJson:n,projectName:o})=>{const i=fRt(o);if(t==="Fabrication Files"){await eUo({circuitJson:e,projectName:i});return}if(t==="KiCad Project"){await rUo({circuitJson:e,projectName:i});return}if(t==="KiCad Library"){await oUo({circuitJson:e,projectName:i});return}if(t==="Circuit JSON"){wS(JSON.stringify(e,null,2),{fileName:`${i}.circuit.json`,mimeType:"application/json"});return}if(t==="Simple Route JSON"){if(!n)throw new Error("No Simple Route JSON available to export");wS(JSON.stringify(n,null,2),{fileName:`${i}.simple-route.json`,mimeType:"application/json"});return}if(t==="GLB (Binary GLTF)"){await tUo({circuitJson:e,projectName:i});return}if(t==="Pinout SVG"){AUo({circuitJson:e,projectName:i});return}if(t==="STEP"){await sUo({circuitJson:e,projectName:i});return}if(t==="LightBurn"){await hTt({circuitJson:e,projectName:i});return}throw new Error(`Unsupported export type: "${t}"`)},lUo=({packageName:t,onSelectReview:e})=>{const n=zu(g=>g.fsMap),o=zu(g=>g.circuitJson),[i,r]=X.useState([]),[A,s]=X.useState(!1),[a,c]=X.useState(!1);X.useEffect(()=>{!t||!UZ()||(s(!0),RG.get("ai_reviews/list",{searchParams:{package_name:t}}).json().then(g=>r(g.ai_reviews)).catch(g=>{console.error("Failed to load AI reviews",g),zA.error("Failed to load AI reviews")}).finally(()=>s(!1)))},[t]);const l=async()=>{if(!o){zA.error("Need Circuit JSON to Request AI Review");return}if(!UZ()){zA.error("Missing registry token");return}c(!0);try{const{ai_review:g}=await RG.post("ai_reviews/create",{json:{package_name:t??"unknown",fs_map:Object.fromEntries(n),circuit_json:o}}).json();r(u=>[g,...u]),e(g),zA.success("AI review requested")}catch(g){console.error("Failed to create AI review",g),zA.error("Failed to request AI review")}finally{c(!1)}};return V.jsxs(V.Fragment,{children:[V.jsxs(t6,{children:[V.jsx(n6,{children:"AI Review"}),V.jsx(wT,{children:"Select an AI review or request a new one."})]}),V.jsx("div",{className:"rf-flex rf-gap-4 rf-mt-4",children:V.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:A?V.jsx("div",{className:"rf-text-sm",children:"Loading..."}):i.length>0?i.map(g=>V.jsx("div",{className:"rf-text-sm rf-p-2 rf-cursor-pointer rf-rounded hover:rf-bg-zinc-100",onClick:()=>e(g),children:new Date(g.created_at||"").toLocaleString()},g.ai_review_id)):V.jsx("div",{className:"rf-text-sm rf-text-muted-foreground",children:"No AI reviews found."})})}),V.jsx(iU,{className:"rf-mt-4",children:V.jsx(ta,{onClick:l,disabled:a,children:a?"Requesting...":"Review my Board"})})]})};function i6e(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var o6=i6e();function _Tt(t){o6=t}var sU={exec:()=>null};function ml(t,e=""){let n=typeof t=="string"?t:t.source;const o={replace:(i,r)=>{let A=typeof r=="string"?r:r.source;return A=A.replace(Gf.caret,"$1"),n=n.replace(i,A),o},getRegex:()=>new RegExp(n,e)};return o}var Gf={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")},gUo=/^(?:[ \t]*(?:\n|$))+/,uUo=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,dUo=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,aU=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,hUo=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,r6e=/(?:[*+-]|\d{1,9}[.)])/,pTt=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,mTt=ml(pTt).replace(/bull/g,r6e).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(),_Uo=ml(pTt).replace(/bull/g,r6e).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(),A6e=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,pUo=/^[^\n]+/,s6e=/(?!\s*\])(?:\\.|[^\[\]\\])+/,mUo=ml(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",s6e).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),IUo=ml(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,r6e).getRegex(),Gie="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",a6e=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,CUo=ml("^ {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",a6e).replace("tag",Gie).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),ITt=ml(A6e).replace("hr",aU).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",Gie).getRegex(),fUo=ml(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",ITt).getRegex(),c6e={blockquote:fUo,code:uUo,def:mUo,fences:dUo,heading:hUo,hr:aU,html:CUo,lheading:mTt,list:IUo,newline:gUo,paragraph:ITt,table:sU,text:pUo},CTt=ml("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",aU).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",Gie).getRegex(),yUo={...c6e,lheading:_Uo,table:CTt,paragraph:ml(A6e).replace("hr",aU).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",CTt).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",Gie).getRegex()},EUo={...c6e,html:ml(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",a6e).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:sU,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:ml(A6e).replace("hr",aU).replace("heading",` *#{1,6} *[^
|
|
5762
5762
|
]`).replace("lheading",mTt).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},xUo=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,BUo=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,fTt=/^( {2,}|\\)\n(?!\s*$)/,QUo=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,Oie=/[\p{P}\p{S}]/u,l6e=/[\s\p{P}\p{S}]/u,yTt=/[^\s\p{P}\p{S}]/u,SUo=ml(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,l6e).getRegex(),ETt=/(?!~)[\p{P}\p{S}]/u,bUo=/(?!~)[\s\p{P}\p{S}]/u,DUo=/(?:[^\s\p{P}\p{S}]|~)/u,MUo=/\[[^[\]]*?\]\((?:\\.|[^\\\(\)]|\((?:\\.|[^\\\(\)])*\))*\)|`[^`]*?`|<[^<>]*?>/g,xTt=/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,wUo=ml(xTt,"u").replace(/punct/g,Oie).getRegex(),PUo=ml(xTt,"u").replace(/punct/g,ETt).getRegex(),BTt="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",vUo=ml(BTt,"gu").replace(/notPunctSpace/g,yTt).replace(/punctSpace/g,l6e).replace(/punct/g,Oie).getRegex(),NUo=ml(BTt,"gu").replace(/notPunctSpace/g,DUo).replace(/punctSpace/g,bUo).replace(/punct/g,ETt).getRegex(),RUo=ml("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,yTt).replace(/punctSpace/g,l6e).replace(/punct/g,Oie).getRegex(),TUo=ml(/\\(punct)/,"gu").replace(/punct/g,Oie).getRegex(),kUo=ml(/^<(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(),FUo=ml(a6e).replace("(?:-->|$)","-->").getRegex(),LUo=ml("^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",FUo).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),Kie=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,HUo=ml(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]*(?:\n[ \t]*)?)(title))?\s*\)/).replace("label",Kie).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),QTt=ml(/^!?\[(label)\]\[(ref)\]/).replace("label",Kie).replace("ref",s6e).getRegex(),STt=ml(/^!?\[(ref)\](?:\[\])?/).replace("ref",s6e).getRegex(),GUo=ml("reflink|nolink(?!\\()","g").replace("reflink",QTt).replace("nolink",STt).getRegex(),g6e={_backpedal:sU,anyPunctuation:TUo,autolink:kUo,blockSkip:MUo,br:fTt,code:BUo,del:sU,emStrongLDelim:wUo,emStrongRDelimAst:vUo,emStrongRDelimUnd:RUo,escape:xUo,link:HUo,nolink:STt,punctuation:SUo,reflink:QTt,reflinkSearch:GUo,tag:LUo,text:QUo,url:sU},OUo={...g6e,link:ml(/^!?\[(label)\]\((.*?)\)/).replace("label",Kie).getRegex(),reflink:ml(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",Kie).getRegex()},u6e={...g6e,emStrongRDelimAst:NUo,emStrongLDelim:PUo,url:ml(/^((?: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.!#$%&'*+\/=?_`{\|}~-]+@)))/},KUo={...u6e,br:ml(fTt).replace("{2,}","*").getRegex(),text:ml(u6e.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},Uie={normal:c6e,gfm:yUo,pedantic:EUo},cU={normal:g6e,gfm:u6e,breaks:KUo,pedantic:OUo},UUo={"&":"&","<":"<",">":">",'"':""","'":"'"},bTt=t=>UUo[t];function vS(t,e){if(e){if(Gf.escapeTest.test(t))return t.replace(Gf.escapeReplace,bTt)}else if(Gf.escapeTestNoEncode.test(t))return t.replace(Gf.escapeReplaceNoEncode,bTt);return t}function DTt(t){try{t=encodeURI(t).replace(Gf.percentDecode,"%")}catch{return null}return t}function MTt(t,e){const n=t.replace(Gf.findPipe,(r,A,s)=>{let a=!1,c=A;for(;--c>=0&&s[c]==="\\";)a=!a;return a?"|":" |"}),o=n.split(Gf.splitPipe);let i=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(;i<o.length;i++)o[i]=o[i].trim().replace(Gf.slashPipe,"|");return o}function lU(t,e,n){const o=t.length;if(o===0)return"";let i=0;for(;i<o&&t.charAt(o-i-1)===e;)i++;return t.slice(0,o-i)}function YUo(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 wTt(t,e,n,o,i){const r=e.href,A=e.title||null,s=t[1].replace(i.other.outputLinkReplace,"$1");o.state.inLink=!0;const a={type:t[0].charAt(0)==="!"?"image":"link",raw:n,href:r,title:A,text:s,tokens:o.inlineTokens(s)};return o.state.inLink=!1,a}function zUo(t,e,n){const o=t.match(n.other.indentCodeCompensation);if(o===null)return e;const i=o[1];return e.split(`
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"main": "dist/index.js",
|
|
4
4
|
"types": "dist/index.d.ts",
|
|
5
5
|
"type": "module",
|
|
6
|
-
"version": "0.0.
|
|
6
|
+
"version": "0.0.2246-libonly",
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"repository": {
|
|
9
9
|
"type": "git",
|
|
@@ -66,7 +66,7 @@
|
|
|
66
66
|
"@tscircuit/miniflex": "^0.0.4",
|
|
67
67
|
"@tscircuit/ngspice-spice-engine": "^0.0.20",
|
|
68
68
|
"@tscircuit/props": "^0.0.612",
|
|
69
|
-
"@tscircuit/runframe": "^0.0.
|
|
69
|
+
"@tscircuit/runframe": "^0.0.2374",
|
|
70
70
|
"@tscircuit/schematic-match-adapt": "^0.0.18",
|
|
71
71
|
"@tscircuit/schematic-trace-solver": "^0.0.125",
|
|
72
72
|
"@tscircuit/simple-3d-svg": "^0.0.41",
|