@tscircuit/runframe 0.0.2213 → 0.0.2215

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.
@@ -5779,11 +5779,11 @@ test("${c} should solve problem correctly", () => {
5779
5779
  // Add more specific assertions based on expected output
5780
5780
  // expect(solver.netLabelPlacementSolver!.netLabelPlacements).toMatchInlineSnapshot()
5781
5781
  })
5782
- `,g=new Blob([l],{type:"text/plain"}),u=URL.createObjectURL(g),d=document.createElement("a");d.href=u,d.download=`${c}.test.ts`,d.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 q.jsxs("div",{className:`relative ${e}`,ref:i,children:[q.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&&q.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:[q.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:r,children:"Download JSON"}),q.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:A,children:"Download page.tsx"}),q.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:s,children:"Download test.ts"})]})]})},_Pt=t=>t.activeSubSolver?[t,..._Pt(t.activeSubSolver)]:[t],mMo=({solver:t})=>{const e=_Pt(t);return q.jsx("div",{className:"flex gap-1 items-center text-sm pt-1",children:e.map((n,o)=>q.jsxs("div",{className:"flex items-center",children:[o>0&&q.jsx("span",{className:"text-gray-400 mx-1",children:"→"}),q.jsx(_Mo,{solver:n})]},n.constructor.name))})},pMo=({solver:t,triggerRender:e,animationSpeed:n=25,onSolverStarted:o,onSolverCompleted:i})=>{const[r,A]=ee.useReducer(_=>!_,!1),s=ee.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 p=_.getCurrentPhase();for(;_.getCurrentPhase()===p&&!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 p=Number(_);if(!Number.isFinite(p)){window.alert("Please enter a valid number for the iteration");return}for(;t.iterations<p&&!t.solved&&!t.failed;)t.step();e(),t.solved&&i&&i(t)};ee.useEffect(()=>()=>{s.current&&clearInterval(s.current)},[]),ee.useEffect(()=>{(t.solved||t.failed)&&r&&(s.current&&(clearInterval(s.current),s.current=void 0),A())},[t.solved,t.failed,r]);const d=t.getCurrentPhase!==void 0,h=d?t.getCurrentPhase():null;return q.jsxs("div",{className:"space-y-2 p-2 border-b",children:[q.jsx("div",{className:"flex items-center",children:q.jsx(mMo,{solver:t})}),q.jsxs("div",{className:"flex gap-2 items-center flex-wrap",children:[q.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"}),q.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"}),q.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"}),q.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"}),d&&q.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"}),q.jsxs("div",{className:"text-sm text-gray-600",children:["Iterations: ",t.iterations]}),t.timeToSolve!==void 0&&q.jsxs("div",{className:"text-sm text-gray-600",children:["Time: ",(t.timeToSolve/1e3).toFixed(3),"s"]}),h&&q.jsxs("div",{className:"text-sm text-gray-600",children:["Phase: ",q.jsx("span",{className:"font-medium",children:h})]}),t.solved&&q.jsx("div",{className:"px-2 py-1 bg-green-100 text-green-800 rounded text-sm",children:"Solved"}),t.failed&&q.jsx("div",{className:"px-2 py-1 bg-red-100 text-red-800 rounded text-sm",children:"Failed"})]}),t.error&&q.jsxs("div",{className:"text-red-600 text-sm",children:["Error: ",t.error]})]})},IMo=(t,e,n)=>{const o=t.currentPipelineStepIndex;return e<o?"Completed":e===o&&t.activeSubSolver?t.activeSubSolver.failed?"Failed":"In Progress":"Not Started"},CMo=(t,e)=>{const o=t.pipelineDef[e].solverName,i=IMo(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],d=u?t.firstIterationOfPhase?.[u.solverName]:void 0;d!==void 0&&A!==null?a=d-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}},fMo=({status:t})=>{const e={"Not Started":"text-blue-600","In Progress":"text-yellow-600",Completed:"text-green-600",Failed:"text-red-600"};return q.jsx("span",{className:`font-medium ${e[t]}`,children:t})},yMo=({progress:t})=>{if(t===0)return null;const e=Math.round(t*100);return q.jsxs("div",{className:"flex items-center gap-2",children:[q.jsx("div",{className:"w-20 h-2 bg-gray-200 rounded overflow-hidden",children:q.jsx("div",{className:"h-full bg-blue-500 transition-all duration-200",style:{width:`${e}%`}})}),q.jsxs("span",{className:"text-xs text-gray-500",children:[e,"%"]})]})},EMo=t=>Object.entries(t).map(([e,n])=>`${e}: ${n}`).join(", "),BMo=({stats:t})=>{if(!t||Object.keys(t).length===0)return q.jsx("span",{children:"-"});const e=Object.entries(t),n=EMo(t);return q.jsxs("details",{className:"cursor-pointer",children:[q.jsx("summary",{className:"whitespace-nowrap overflow-hidden text-ellipsis max-w-[200px]",children:n}),q.jsx("div",{className:"mt-1 text-xs",children:e.map(([o,i])=>q.jsxs("div",{children:[o,": ",String(i)]},o))})]})},RDe=t=>{if(t===null||typeof t!="object")return t;if(Array.isArray(t))return t.map(RDe);const e={};for(const[n,o]of Object.entries(t))n.startsWith("_")||(e[n]=RDe(o));return e},xMo=(t,e)=>{try{if(typeof t.getConstructorParams!="function"){alert(`getConstructorParams() is not implemented for ${e}`);return}const n=RDe(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)}`)}},QMo=({solver:t,onStepUntilPhase:e,onDownloadInput:n})=>{const o=t.pipelineDef.map((s,a)=>CMo(t,a)),i=s=>{e?.(s)},r=s=>{s.solverInstance&&(n?n(s.solverInstance,s.name):xMo(s.solverInstance,s.name))},A=s=>`${(s/1e3).toFixed(2)}s`;return q.jsxs("div",{className:"border-t border-gray-200",children:[q.jsx("div",{className:"px-4 py-2 bg-gray-50 border-b border-gray-200",children:q.jsx("h3",{className:"text-sm font-semibold text-gray-700",children:"Pipeline Steps"})}),q.jsx("div",{className:"overflow-x-auto",children:q.jsxs("table",{className:"w-full text-sm",children:[q.jsx("thead",{children:q.jsxs("tr",{className:"bg-gray-50 border-b border-gray-200",children:[q.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Step"}),q.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Status"}),q.jsxs("th",{className:"px-4 py-2 text-center font-semibold text-gray-700",children:["i",q.jsx("sub",{children:"0"})]}),q.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Iterations"}),q.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Progress"}),q.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Time"}),q.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Stats"}),q.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Input"})]})}),q.jsx("tbody",{children:o.map(s=>q.jsxs("tr",{className:`border-b border-gray-100 ${s.status==="In Progress"?"bg-yellow-50":""}`,children:[q.jsx("td",{className:"px-4 py-2",children:q.jsxs("div",{className:"flex items-center gap-2",children:[q.jsx("span",{className:"text-gray-400 w-6",children:String(s.index+1).padStart(2,"0")}),q.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:q.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:q.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"})})}),q.jsx("span",{className:"font-medium text-gray-900",children:s.name})]})}),q.jsx("td",{className:"px-4 py-2",children:q.jsx(fMo,{status:s.status})}),q.jsx("td",{className:"px-4 py-2 text-center text-gray-600",children:s.firstIteration!==null?s.firstIteration:""}),q.jsx("td",{className:"px-4 py-2 text-gray-600",children:s.iterations}),q.jsx("td",{className:"px-4 py-2",children:q.jsx(yMo,{progress:s.progress})}),q.jsx("td",{className:"px-4 py-2 text-gray-600",children:A(s.timeSpent)}),q.jsx("td",{className:"px-4 py-2 text-gray-500",children:q.jsx(BMo,{stats:s.stats})}),q.jsx("td",{className:"px-4 py-2",children:s.solverInstance?q.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:[q.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:q.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"})}),q.jsx("span",{children:"Input"})]}):null})]},s.name))})]})})]})},SMo=class extends Vr.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 bMo({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=(p,m)=>{typeof p=="number"&&(p<A&&(A=p),p>a&&(a=p)),typeof m=="number"&&(m<s&&(s=m),m>c&&(c=m))};for(const p of e)l(p.x,p.y);for(const p of n){const m=p.points??[];for(const I of m)l(I.x,I.y)}for(const p of o){const m=p.x??0,I=p.y??0,C=p.width??0,f=p.height??0;l(m,I),l(m+C,I+f)}for(const p of i){const m=p.x??0,I=p.y??0,C=p.radius??1;l(m-C,I-C),l(m+C,I+C)}for(const p of r)l(p.x,p.y);(!isFinite(A)||!isFinite(s)||!isFinite(a)||!isFinite(c))&&(A=-20,s=-20,a=20,c=20);const g=10,u=A-g,d=s-g,h=Math.max(1,a-A+2*g),_=Math.max(1,c-s+2*g);return q.jsxs("svg",{className:"w-full h-[400px] bg-white",viewBox:`${u} ${d} ${h} ${_}`,role:"img","aria-label":"Graphics fallback",children:[o.map((p,m)=>q.jsx("rect",{x:p.x??0,y:p.y??0,width:p.width??0,height:p.height??0,fill:"none",stroke:p.strokeColor??"black",strokeWidth:p.strokeWidth??1},`rect-${m}`)),n.map((p,m)=>q.jsx("polyline",{fill:"none",stroke:p.strokeColor??"black",strokeWidth:p.strokeWidth??1,points:(p.points??[]).map(I=>`${I.x??0},${I.y??0}`).join(" ")},`line-${m}`)),i.map((p,m)=>q.jsx("circle",{cx:p.x??0,cy:p.y??0,r:p.radius??1.5,fill:p.fillColor??"none",stroke:p.strokeColor??"black",strokeWidth:p.strokeWidth??1},`circle-${m}`)),e.map((p,m)=>q.jsx("circle",{cx:p.x??0,cy:p.y??0,r:p.radius??1.5,fill:p.color??"black"},`point-${m}`)),r.map((p,m)=>q.jsx("text",{x:p.x??0,y:p.y??0,fontSize:p.fontSize??10,fill:p.color??"black",children:p.text??""},`text-${m}`))]})}var DMo=({solver:t,animationSpeed:e=25,onSolverStarted:n,onSolverCompleted:o})=>{const[i,r]=ee.useReducer(l=>l+1,0),A=ee.useMemo(()=>{try{return t.visualize()||{points:[],lines:[],rects:[],circles:[]}}catch(l){return console.error("Visualization error:",l),{points:[],lines:[],rects:[],circles:[]}}},[t,i]),s=ee.useMemo(()=>(A.rects?.length||0)===0&&(A.lines?.length||0)===0&&(A.points?.length||0)===0&&(A.circles?.length||0)===0,[A]);ee.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 q.jsxs("div",{children:[q.jsx(pMo,{solver:t,triggerRender:r,animationSpeed:e,onSolverStarted:n,onSolverCompleted:o}),s?q.jsx("div",{className:"p-4 text-gray-500",children:"No Graphics Yet"}):q.jsx(SMo,{fallback:q.jsx(bMo,{graphics:A}),children:q.jsx(dMo,{graphics:A})}),a&&q.jsx(QMo,{solver:t,onStepUntilPhase:c})]})};const MMo=()=>{ee.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)},[])},PMo=1e3,fQ=(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)},PMo)},mPt=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"},yQ="https://github.com/tscircuit/tscircuit-autorouter/issues/new",pPt="https://github.com/tscircuit/copper-pour-solver/issues/new",IPt="https://github.com/tscircuit/calculate-packing/issues/new",CPt="https://github.com/tscircuit/schematic-trace-solver/issues/new?template=json-bug-report.yml",wMo={PackSolver2:IPt,AutoroutingPipelineSolver:yQ,AssignableAutoroutingPipeline2:yQ,AssignableAutoroutingPipeline3:yQ,AutoroutingPipeline1_OriginalUnravel:yQ,AutoroutingPipelineSolver3_HgPortPointPathing:yQ,AutoroutingPipelineSolver4:yQ,AutoroutingPipelineSolver5:yQ,AutoroutingPipelineSolver7_MultiGraph:yQ,AutoroutingPipelineSolver8:yQ,CopperPourPipelineSolver:pPt,SchematicTracePipelineSolver:CPt},vMo=t=>t.toLowerCase().includes("pack")?$_o:t.toLowerCase().includes("rout")?rmo:V_o,fPt=t=>{const e=wMo[t];if(e)return e;const n=t.toLowerCase();return n.includes("autorout")?yQ:n.includes("schematic")&&n.includes("trace")?CPt:n.includes("copperpour")?pPt:n.includes("pack")?IPt:null},NMo=t=>`${mPt(`${t.componentName}-${t.solverName}`)}-solver-input.json`,yPt=t=>{fQ(JSON.stringify(t.solverParams,null,2),{fileName:NMo(t),mimeType:"application/json"})},RMo=({solverEvent:t})=>{const e=fPt(t.solverName);return q.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:[q.jsxs(cc,{type:"button",variant:"outline",size:"sm",onClick:()=>yPt(t),children:[q.jsx(z5e,{className:"rf-w-4 rf-h-4"}),"Download"]}),e?q.jsx(cc,{asChild:!0,variant:"outline",size:"sm",children:q.jsxs("a",{href:e,target:"_blank",rel:"noopener noreferrer",children:[q.jsx(TZ,{className:"rf-w-4 rf-h-4"}),"Report"]})}):q.jsxs(cc,{type:"button",variant:"outline",size:"sm",disabled:!0,title:"No report link configured for this solver",children:[q.jsx(TZ,{className:"rf-w-4 rf-h-4"}),"Report"]})]})},TMo=({solverEvent:t})=>{const e=fPt(t.solverName);return e?q.jsx(cc,{asChild:!0,variant:"ghost",size:"icon",className:"rf-h-8 rf-w-8",children:q.jsx("a",{href:e,target:"_blank",rel:"noopener noreferrer",title:"Report solver bug","aria-label":"Report solver bug",children:q.jsx(TZ,{className:"rf-w-4 rf-h-4"})})}):q.jsx(cc,{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:q.jsx(TZ,{className:"rf-w-4 rf-h-4"})})},kMo=({solverEvents:t=[]})=>{const[e,n]=ee.useState(null);MMo();const o=ee.useMemo(()=>{const s=new Map;for(const a of t){const c=`${a.componentName}-${a.solverName}`;s.set(c,a)}return s},[t]),i=ee.useMemo(()=>Array.from(o.keys()),[o]),r=e?o.get(e):null,A=ee.useMemo(()=>{if(!r)return{instance:null,error:null,classFound:!1};const s=XIe[r.solverName];if(!s)return{instance:null,error:`Solver class "${r.solverName}" not found in SOLVERS registry. Available: ${Object.keys(XIe).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?q.jsx("div",{className:"rf-p-4",children:q.jsx("div",{className:"rf-bg-gray-50 rf-rounded-md rf-border rf-border-gray-200",children:q.jsxs("div",{className:"rf-p-4",children:[q.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800 rf-mb-3",children:"No Solvers Detected"}),q.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."})]})})}):q.jsxs("div",{className:"rf-flex rf-h-full rf-overflow-hidden",children:[q.jsxs("div",{className:"rf-w-64 rf-border-r rf-border-gray-200 rf-overflow-y-auto rf-flex-shrink-0",children:[q.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 q.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=vMo(a.solverName);return q.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2",children:[q.jsx(l,{className:"rf-w-4 rf-h-4 rf-text-blue-500 rf-flex-shrink-0"}),q.jsxs("div",{className:"rf-flex-1 rf-min-w-0",children:[q.jsx("div",{className:"rf-text-sm rf-font-medium rf-text-gray-800 rf-truncate",children:a.componentName}),q.jsx("div",{className:"rf-text-xs rf-text-gray-500 rf-truncate",children:a.solverName})]})]})})()},s)})]}),q.jsx("div",{className:"rf-flex-1 rf-overflow-hidden",children:r?A.instance?q.jsxs("div",{className:"rf-flex rf-h-full rf-flex-col rf-overflow-y-auto",children:[q.jsx(RMo,{solverEvent:r}),q.jsx("div",{className:"rf-min-h-0 rf-flex-1",children:q.jsx(aQ,{fallback:q.jsx("div",{className:"rf-p-4",children:q.jsxs("div",{className:"rf-bg-red-50 rf-rounded-md rf-border rf-border-red-200 rf-p-4",children:[q.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-red-800 rf-mb-2",children:"Error Loading Solver Debugger"}),q.jsxs("p",{className:"rf-text-sm rf-text-red-600",children:["Failed to render the solver debugger for"," ",r.solverName]})]})}),children:q.jsx(DMo,{solver:A.instance})})})]}):q.jsxs("div",{className:"rf-p-4",children:[q.jsxs("div",{className:"rf-mb-4",children:[q.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800",children:r.solverName}),q.jsxs("p",{className:"rf-text-sm rf-text-gray-500",children:["Component: ",r.componentName]})]}),A.error&&q.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:q.jsx("p",{className:`rf-text-sm ${A.classFound?"rf-text-red-700":"rf-text-yellow-700"}`,children:A.error})}),q.jsxs("div",{className:"rf-border rf-border-gray-200 rf-rounded-md rf-overflow-hidden",children:[q.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:[q.jsx("span",{className:"rf-text-sm rf-font-medium rf-text-gray-700",children:"Solver Parameters"}),q.jsxs("div",{className:"rf-flex rf-items-center rf-gap-1",children:[q.jsx(TMo,{solverEvent:r}),q.jsx(cc,{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:()=>yPt(r),children:q.jsx(z5e,{className:"rf-w-4 rf-h-4"})})]})]}),q.jsx("div",{className:"rf-p-3 rf-bg-white rf-border-t rf-border-gray-200",children:q.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)})})]})]}):q.jsx("div",{className:"rf-flex rf-items-center rf-justify-center rf-h-full",children:q.jsx("p",{className:"rf-text-sm rf-text-gray-500",children:"Select a solver from the list to view details"})})})]})},EPt=({errorMessage:t,errorStack:e,circuitJsonErrors:n})=>{ee.useEffect(()=>{if(t){const o=new Error(t);e&&(o.stack=e);try{iv.captureException(o)}catch{}}},[t,e]),ee.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{iv.captureException(i,{error_type:o.type})}catch{}}},[n])},FMo=t=>{ee.useEffect(()=>{try{vTt(t)}catch{}},[t.source,t.component,t.isWebEmbedded,t.activeTab])},BPt="0.0.2212",LMo={version:BPt},TDe={BASE_URL:"/",DEV:!1,MODE:"production",PROD:!0,SSR:!1},kDe=new Map,mte=t=>{const e=kDe.get(t);return e?Object.fromEntries(Object.entries(e.stores).map(([n,o])=>[n,o.getState()])):{}},HMo=(t,e,n)=>{if(t===void 0)return{type:"untracked",connection:e.connect(n)};const o=kDe.get(n.name);if(o)return{type:"tracked",store:t,...o};const i={connection:e.connect(n),stores:{}};return kDe.set(n.name,i),{type:"tracked",store:t,...i}},xPt=(t,e={})=>(n,o,i)=>{const{enabled:r,anonymousActionType:A,store:s,...a}=e;let c;try{c=(r??(TDe?"production":void 0)!=="production")&&window.__REDUX_DEVTOOLS_EXTENSION__}catch{}if(!c)return(TDe?"production":void 0)!=="production"&&r&&console.warn("[zustand devtools middleware] Please install/enable Redux devtools extension"),t(n,o,i);const{connection:l,...g}=HMo(s,c,a);let u=!0;i.setState=(_,p,m)=>{const I=n(_,p);if(!u)return I;const C=m===void 0?{type:A||"anonymous"}:typeof m=="string"?{type:m}:m;return s===void 0?(l?.send(C,o()),I):(l?.send({...C,type:`${s}/${C.type}`},{...mte(a.name),[s]:i.getState()}),I)};const d=(..._)=>{const p=u;u=!1,n(..._),u=p},h=t(i.setState,o,i);if(g.type==="untracked"?l?.init(h):(g.stores[g.store]=i,l?.init(Object.fromEntries(Object.entries(g.stores).map(([_,p])=>[_,_===g.store?h:p.getState()])))),i.dispatchFromDevtools&&typeof i.dispatch=="function"){let _=!1;const p=i.dispatch;i.dispatch=(...m)=>{(TDe?"production":void 0)!=="production"&&m[0].type==="__setState"&&!_&&(console.warn('[zustand devtools middleware] "__setState" action type is reserved to set state from the devtools. Avoid using it.'),_=!0),p(...m)}}return l.subscribe(_=>{var p;switch(_.type){case"ACTION":if(typeof _.payload!="string"){console.error("[zustand devtools middleware] Unsupported action format");return}return FDe(_.payload,m=>{if(m.type==="__setState"){if(s===void 0){d(m.state);return}Object.keys(m.state).length!==1&&console.error(`
5782
+ `,g=new Blob([l],{type:"text/plain"}),u=URL.createObjectURL(g),d=document.createElement("a");d.href=u,d.download=`${c}.test.ts`,d.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 q.jsxs("div",{className:`relative ${e}`,ref:i,children:[q.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&&q.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:[q.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:r,children:"Download JSON"}),q.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:A,children:"Download page.tsx"}),q.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:s,children:"Download test.ts"})]})]})},_Pt=t=>t.activeSubSolver?[t,..._Pt(t.activeSubSolver)]:[t],mMo=({solver:t})=>{const e=_Pt(t);return q.jsx("div",{className:"flex gap-1 items-center text-sm pt-1",children:e.map((n,o)=>q.jsxs("div",{className:"flex items-center",children:[o>0&&q.jsx("span",{className:"text-gray-400 mx-1",children:"→"}),q.jsx(_Mo,{solver:n})]},n.constructor.name))})},pMo=({solver:t,triggerRender:e,animationSpeed:n=25,onSolverStarted:o,onSolverCompleted:i})=>{const[r,A]=ee.useReducer(_=>!_,!1),s=ee.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 p=_.getCurrentPhase();for(;_.getCurrentPhase()===p&&!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 p=Number(_);if(!Number.isFinite(p)){window.alert("Please enter a valid number for the iteration");return}for(;t.iterations<p&&!t.solved&&!t.failed;)t.step();e(),t.solved&&i&&i(t)};ee.useEffect(()=>()=>{s.current&&clearInterval(s.current)},[]),ee.useEffect(()=>{(t.solved||t.failed)&&r&&(s.current&&(clearInterval(s.current),s.current=void 0),A())},[t.solved,t.failed,r]);const d=t.getCurrentPhase!==void 0,h=d?t.getCurrentPhase():null;return q.jsxs("div",{className:"space-y-2 p-2 border-b",children:[q.jsx("div",{className:"flex items-center",children:q.jsx(mMo,{solver:t})}),q.jsxs("div",{className:"flex gap-2 items-center flex-wrap",children:[q.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"}),q.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"}),q.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"}),q.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"}),d&&q.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"}),q.jsxs("div",{className:"text-sm text-gray-600",children:["Iterations: ",t.iterations]}),t.timeToSolve!==void 0&&q.jsxs("div",{className:"text-sm text-gray-600",children:["Time: ",(t.timeToSolve/1e3).toFixed(3),"s"]}),h&&q.jsxs("div",{className:"text-sm text-gray-600",children:["Phase: ",q.jsx("span",{className:"font-medium",children:h})]}),t.solved&&q.jsx("div",{className:"px-2 py-1 bg-green-100 text-green-800 rounded text-sm",children:"Solved"}),t.failed&&q.jsx("div",{className:"px-2 py-1 bg-red-100 text-red-800 rounded text-sm",children:"Failed"})]}),t.error&&q.jsxs("div",{className:"text-red-600 text-sm",children:["Error: ",t.error]})]})},IMo=(t,e,n)=>{const o=t.currentPipelineStepIndex;return e<o?"Completed":e===o&&t.activeSubSolver?t.activeSubSolver.failed?"Failed":"In Progress":"Not Started"},CMo=(t,e)=>{const o=t.pipelineDef[e].solverName,i=IMo(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],d=u?t.firstIterationOfPhase?.[u.solverName]:void 0;d!==void 0&&A!==null?a=d-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}},fMo=({status:t})=>{const e={"Not Started":"text-blue-600","In Progress":"text-yellow-600",Completed:"text-green-600",Failed:"text-red-600"};return q.jsx("span",{className:`font-medium ${e[t]}`,children:t})},yMo=({progress:t})=>{if(t===0)return null;const e=Math.round(t*100);return q.jsxs("div",{className:"flex items-center gap-2",children:[q.jsx("div",{className:"w-20 h-2 bg-gray-200 rounded overflow-hidden",children:q.jsx("div",{className:"h-full bg-blue-500 transition-all duration-200",style:{width:`${e}%`}})}),q.jsxs("span",{className:"text-xs text-gray-500",children:[e,"%"]})]})},EMo=t=>Object.entries(t).map(([e,n])=>`${e}: ${n}`).join(", "),BMo=({stats:t})=>{if(!t||Object.keys(t).length===0)return q.jsx("span",{children:"-"});const e=Object.entries(t),n=EMo(t);return q.jsxs("details",{className:"cursor-pointer",children:[q.jsx("summary",{className:"whitespace-nowrap overflow-hidden text-ellipsis max-w-[200px]",children:n}),q.jsx("div",{className:"mt-1 text-xs",children:e.map(([o,i])=>q.jsxs("div",{children:[o,": ",String(i)]},o))})]})},RDe=t=>{if(t===null||typeof t!="object")return t;if(Array.isArray(t))return t.map(RDe);const e={};for(const[n,o]of Object.entries(t))n.startsWith("_")||(e[n]=RDe(o));return e},xMo=(t,e)=>{try{if(typeof t.getConstructorParams!="function"){alert(`getConstructorParams() is not implemented for ${e}`);return}const n=RDe(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)}`)}},QMo=({solver:t,onStepUntilPhase:e,onDownloadInput:n})=>{const o=t.pipelineDef.map((s,a)=>CMo(t,a)),i=s=>{e?.(s)},r=s=>{s.solverInstance&&(n?n(s.solverInstance,s.name):xMo(s.solverInstance,s.name))},A=s=>`${(s/1e3).toFixed(2)}s`;return q.jsxs("div",{className:"border-t border-gray-200",children:[q.jsx("div",{className:"px-4 py-2 bg-gray-50 border-b border-gray-200",children:q.jsx("h3",{className:"text-sm font-semibold text-gray-700",children:"Pipeline Steps"})}),q.jsx("div",{className:"overflow-x-auto",children:q.jsxs("table",{className:"w-full text-sm",children:[q.jsx("thead",{children:q.jsxs("tr",{className:"bg-gray-50 border-b border-gray-200",children:[q.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Step"}),q.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Status"}),q.jsxs("th",{className:"px-4 py-2 text-center font-semibold text-gray-700",children:["i",q.jsx("sub",{children:"0"})]}),q.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Iterations"}),q.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Progress"}),q.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Time"}),q.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Stats"}),q.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Input"})]})}),q.jsx("tbody",{children:o.map(s=>q.jsxs("tr",{className:`border-b border-gray-100 ${s.status==="In Progress"?"bg-yellow-50":""}`,children:[q.jsx("td",{className:"px-4 py-2",children:q.jsxs("div",{className:"flex items-center gap-2",children:[q.jsx("span",{className:"text-gray-400 w-6",children:String(s.index+1).padStart(2,"0")}),q.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:q.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:q.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"})})}),q.jsx("span",{className:"font-medium text-gray-900",children:s.name})]})}),q.jsx("td",{className:"px-4 py-2",children:q.jsx(fMo,{status:s.status})}),q.jsx("td",{className:"px-4 py-2 text-center text-gray-600",children:s.firstIteration!==null?s.firstIteration:""}),q.jsx("td",{className:"px-4 py-2 text-gray-600",children:s.iterations}),q.jsx("td",{className:"px-4 py-2",children:q.jsx(yMo,{progress:s.progress})}),q.jsx("td",{className:"px-4 py-2 text-gray-600",children:A(s.timeSpent)}),q.jsx("td",{className:"px-4 py-2 text-gray-500",children:q.jsx(BMo,{stats:s.stats})}),q.jsx("td",{className:"px-4 py-2",children:s.solverInstance?q.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:[q.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:q.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"})}),q.jsx("span",{children:"Input"})]}):null})]},s.name))})]})})]})},SMo=class extends Vr.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 bMo({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=(p,m)=>{typeof p=="number"&&(p<A&&(A=p),p>a&&(a=p)),typeof m=="number"&&(m<s&&(s=m),m>c&&(c=m))};for(const p of e)l(p.x,p.y);for(const p of n){const m=p.points??[];for(const I of m)l(I.x,I.y)}for(const p of o){const m=p.x??0,I=p.y??0,C=p.width??0,f=p.height??0;l(m,I),l(m+C,I+f)}for(const p of i){const m=p.x??0,I=p.y??0,C=p.radius??1;l(m-C,I-C),l(m+C,I+C)}for(const p of r)l(p.x,p.y);(!isFinite(A)||!isFinite(s)||!isFinite(a)||!isFinite(c))&&(A=-20,s=-20,a=20,c=20);const g=10,u=A-g,d=s-g,h=Math.max(1,a-A+2*g),_=Math.max(1,c-s+2*g);return q.jsxs("svg",{className:"w-full h-[400px] bg-white",viewBox:`${u} ${d} ${h} ${_}`,role:"img","aria-label":"Graphics fallback",children:[o.map((p,m)=>q.jsx("rect",{x:p.x??0,y:p.y??0,width:p.width??0,height:p.height??0,fill:"none",stroke:p.strokeColor??"black",strokeWidth:p.strokeWidth??1},`rect-${m}`)),n.map((p,m)=>q.jsx("polyline",{fill:"none",stroke:p.strokeColor??"black",strokeWidth:p.strokeWidth??1,points:(p.points??[]).map(I=>`${I.x??0},${I.y??0}`).join(" ")},`line-${m}`)),i.map((p,m)=>q.jsx("circle",{cx:p.x??0,cy:p.y??0,r:p.radius??1.5,fill:p.fillColor??"none",stroke:p.strokeColor??"black",strokeWidth:p.strokeWidth??1},`circle-${m}`)),e.map((p,m)=>q.jsx("circle",{cx:p.x??0,cy:p.y??0,r:p.radius??1.5,fill:p.color??"black"},`point-${m}`)),r.map((p,m)=>q.jsx("text",{x:p.x??0,y:p.y??0,fontSize:p.fontSize??10,fill:p.color??"black",children:p.text??""},`text-${m}`))]})}var DMo=({solver:t,animationSpeed:e=25,onSolverStarted:n,onSolverCompleted:o})=>{const[i,r]=ee.useReducer(l=>l+1,0),A=ee.useMemo(()=>{try{return t.visualize()||{points:[],lines:[],rects:[],circles:[]}}catch(l){return console.error("Visualization error:",l),{points:[],lines:[],rects:[],circles:[]}}},[t,i]),s=ee.useMemo(()=>(A.rects?.length||0)===0&&(A.lines?.length||0)===0&&(A.points?.length||0)===0&&(A.circles?.length||0)===0,[A]);ee.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 q.jsxs("div",{children:[q.jsx(pMo,{solver:t,triggerRender:r,animationSpeed:e,onSolverStarted:n,onSolverCompleted:o}),s?q.jsx("div",{className:"p-4 text-gray-500",children:"No Graphics Yet"}):q.jsx(SMo,{fallback:q.jsx(bMo,{graphics:A}),children:q.jsx(dMo,{graphics:A})}),a&&q.jsx(QMo,{solver:t,onStepUntilPhase:c})]})};const MMo=()=>{ee.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)},[])},PMo=1e3,fQ=(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)},PMo)},mPt=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"},yQ="https://github.com/tscircuit/tscircuit-autorouter/issues/new",pPt="https://github.com/tscircuit/copper-pour-solver/issues/new",IPt="https://github.com/tscircuit/calculate-packing/issues/new",CPt="https://github.com/tscircuit/schematic-trace-solver/issues/new?template=json-bug-report.yml",wMo={PackSolver2:IPt,AutoroutingPipelineSolver:yQ,AssignableAutoroutingPipeline2:yQ,AssignableAutoroutingPipeline3:yQ,AutoroutingPipeline1_OriginalUnravel:yQ,AutoroutingPipelineSolver3_HgPortPointPathing:yQ,AutoroutingPipelineSolver4:yQ,AutoroutingPipelineSolver5:yQ,AutoroutingPipelineSolver7_MultiGraph:yQ,AutoroutingPipelineSolver8:yQ,CopperPourPipelineSolver:pPt,SchematicTracePipelineSolver:CPt},vMo=t=>t.toLowerCase().includes("pack")?$_o:t.toLowerCase().includes("rout")?rmo:V_o,fPt=t=>{const e=wMo[t];if(e)return e;const n=t.toLowerCase();return n.includes("autorout")?yQ:n.includes("schematic")&&n.includes("trace")?CPt:n.includes("copperpour")?pPt:n.includes("pack")?IPt:null},NMo=t=>`${mPt(`${t.componentName}-${t.solverName}`)}-solver-input.json`,yPt=t=>{fQ(JSON.stringify(t.solverParams,null,2),{fileName:NMo(t),mimeType:"application/json"})},RMo=({solverEvent:t})=>{const e=fPt(t.solverName);return q.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:[q.jsxs(cc,{type:"button",variant:"outline",size:"sm",onClick:()=>yPt(t),children:[q.jsx(z5e,{className:"rf-w-4 rf-h-4"}),"Download"]}),e?q.jsx(cc,{asChild:!0,variant:"outline",size:"sm",children:q.jsxs("a",{href:e,target:"_blank",rel:"noopener noreferrer",children:[q.jsx(TZ,{className:"rf-w-4 rf-h-4"}),"Report"]})}):q.jsxs(cc,{type:"button",variant:"outline",size:"sm",disabled:!0,title:"No report link configured for this solver",children:[q.jsx(TZ,{className:"rf-w-4 rf-h-4"}),"Report"]})]})},TMo=({solverEvent:t})=>{const e=fPt(t.solverName);return e?q.jsx(cc,{asChild:!0,variant:"ghost",size:"icon",className:"rf-h-8 rf-w-8",children:q.jsx("a",{href:e,target:"_blank",rel:"noopener noreferrer",title:"Report solver bug","aria-label":"Report solver bug",children:q.jsx(TZ,{className:"rf-w-4 rf-h-4"})})}):q.jsx(cc,{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:q.jsx(TZ,{className:"rf-w-4 rf-h-4"})})},kMo=({solverEvents:t=[]})=>{const[e,n]=ee.useState(null);MMo();const o=ee.useMemo(()=>{const s=new Map;for(const a of t){const c=`${a.componentName}-${a.solverName}`;s.set(c,a)}return s},[t]),i=ee.useMemo(()=>Array.from(o.keys()),[o]),r=e?o.get(e):null,A=ee.useMemo(()=>{if(!r)return{instance:null,error:null,classFound:!1};const s=XIe[r.solverName];if(!s)return{instance:null,error:`Solver class "${r.solverName}" not found in SOLVERS registry. Available: ${Object.keys(XIe).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?q.jsx("div",{className:"rf-p-4",children:q.jsx("div",{className:"rf-bg-gray-50 rf-rounded-md rf-border rf-border-gray-200",children:q.jsxs("div",{className:"rf-p-4",children:[q.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800 rf-mb-3",children:"No Solvers Detected"}),q.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."})]})})}):q.jsxs("div",{className:"rf-flex rf-h-full rf-overflow-hidden",children:[q.jsxs("div",{className:"rf-w-64 rf-border-r rf-border-gray-200 rf-overflow-y-auto rf-flex-shrink-0",children:[q.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 q.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=vMo(a.solverName);return q.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2",children:[q.jsx(l,{className:"rf-w-4 rf-h-4 rf-text-blue-500 rf-flex-shrink-0"}),q.jsxs("div",{className:"rf-flex-1 rf-min-w-0",children:[q.jsx("div",{className:"rf-text-sm rf-font-medium rf-text-gray-800 rf-truncate",children:a.componentName}),q.jsx("div",{className:"rf-text-xs rf-text-gray-500 rf-truncate",children:a.solverName})]})]})})()},s)})]}),q.jsx("div",{className:"rf-flex-1 rf-overflow-hidden",children:r?A.instance?q.jsxs("div",{className:"rf-flex rf-h-full rf-flex-col rf-overflow-y-auto",children:[q.jsx(RMo,{solverEvent:r}),q.jsx("div",{className:"rf-min-h-0 rf-flex-1",children:q.jsx(aQ,{fallback:q.jsx("div",{className:"rf-p-4",children:q.jsxs("div",{className:"rf-bg-red-50 rf-rounded-md rf-border rf-border-red-200 rf-p-4",children:[q.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-red-800 rf-mb-2",children:"Error Loading Solver Debugger"}),q.jsxs("p",{className:"rf-text-sm rf-text-red-600",children:["Failed to render the solver debugger for"," ",r.solverName]})]})}),children:q.jsx(DMo,{solver:A.instance})})})]}):q.jsxs("div",{className:"rf-p-4",children:[q.jsxs("div",{className:"rf-mb-4",children:[q.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800",children:r.solverName}),q.jsxs("p",{className:"rf-text-sm rf-text-gray-500",children:["Component: ",r.componentName]})]}),A.error&&q.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:q.jsx("p",{className:`rf-text-sm ${A.classFound?"rf-text-red-700":"rf-text-yellow-700"}`,children:A.error})}),q.jsxs("div",{className:"rf-border rf-border-gray-200 rf-rounded-md rf-overflow-hidden",children:[q.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:[q.jsx("span",{className:"rf-text-sm rf-font-medium rf-text-gray-700",children:"Solver Parameters"}),q.jsxs("div",{className:"rf-flex rf-items-center rf-gap-1",children:[q.jsx(TMo,{solverEvent:r}),q.jsx(cc,{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:()=>yPt(r),children:q.jsx(z5e,{className:"rf-w-4 rf-h-4"})})]})]}),q.jsx("div",{className:"rf-p-3 rf-bg-white rf-border-t rf-border-gray-200",children:q.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)})})]})]}):q.jsx("div",{className:"rf-flex rf-items-center rf-justify-center rf-h-full",children:q.jsx("p",{className:"rf-text-sm rf-text-gray-500",children:"Select a solver from the list to view details"})})})]})},EPt=({errorMessage:t,errorStack:e,circuitJsonErrors:n})=>{ee.useEffect(()=>{if(t){const o=new Error(t);e&&(o.stack=e);try{iv.captureException(o)}catch{}}},[t,e]),ee.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{iv.captureException(i,{error_type:o.type})}catch{}}},[n])},FMo=t=>{ee.useEffect(()=>{try{vTt(t)}catch{}},[t.source,t.component,t.isWebEmbedded,t.activeTab])},BPt="0.0.2214",LMo={version:BPt},TDe={BASE_URL:"/",DEV:!1,MODE:"production",PROD:!0,SSR:!1},kDe=new Map,mte=t=>{const e=kDe.get(t);return e?Object.fromEntries(Object.entries(e.stores).map(([n,o])=>[n,o.getState()])):{}},HMo=(t,e,n)=>{if(t===void 0)return{type:"untracked",connection:e.connect(n)};const o=kDe.get(n.name);if(o)return{type:"tracked",store:t,...o};const i={connection:e.connect(n),stores:{}};return kDe.set(n.name,i),{type:"tracked",store:t,...i}},xPt=(t,e={})=>(n,o,i)=>{const{enabled:r,anonymousActionType:A,store:s,...a}=e;let c;try{c=(r??(TDe?"production":void 0)!=="production")&&window.__REDUX_DEVTOOLS_EXTENSION__}catch{}if(!c)return(TDe?"production":void 0)!=="production"&&r&&console.warn("[zustand devtools middleware] Please install/enable Redux devtools extension"),t(n,o,i);const{connection:l,...g}=HMo(s,c,a);let u=!0;i.setState=(_,p,m)=>{const I=n(_,p);if(!u)return I;const C=m===void 0?{type:A||"anonymous"}:typeof m=="string"?{type:m}:m;return s===void 0?(l?.send(C,o()),I):(l?.send({...C,type:`${s}/${C.type}`},{...mte(a.name),[s]:i.getState()}),I)};const d=(..._)=>{const p=u;u=!1,n(..._),u=p},h=t(i.setState,o,i);if(g.type==="untracked"?l?.init(h):(g.stores[g.store]=i,l?.init(Object.fromEntries(Object.entries(g.stores).map(([_,p])=>[_,_===g.store?h:p.getState()])))),i.dispatchFromDevtools&&typeof i.dispatch=="function"){let _=!1;const p=i.dispatch;i.dispatch=(...m)=>{(TDe?"production":void 0)!=="production"&&m[0].type==="__setState"&&!_&&(console.warn('[zustand devtools middleware] "__setState" action type is reserved to set state from the devtools. Avoid using it.'),_=!0),p(...m)}}return l.subscribe(_=>{var p;switch(_.type){case"ACTION":if(typeof _.payload!="string"){console.error("[zustand devtools middleware] Unsupported action format");return}return FDe(_.payload,m=>{if(m.type==="__setState"){if(s===void 0){d(m.state);return}Object.keys(m.state).length!==1&&console.error(`
5783
5783
  [zustand devtools middleware] Unsupported __setState action format.
5784
5784
  When using 'store' option in devtools(), the 'state' should have only one key, which is a value of 'store' that was passed in devtools(),
5785
5785
  and value of this only key should be a state object. Example: { "type": "__setState", "state": { "abc123Store": { "foo": "bar" } } }
5786
- `);const I=m.state[s];if(I==null)return;JSON.stringify(i.getState())!==JSON.stringify(I)&&d(I);return}i.dispatchFromDevtools&&typeof i.dispatch=="function"&&i.dispatch(m)});case"DISPATCH":switch(_.payload.type){case"RESET":return d(h),s===void 0?l?.init(i.getState()):l?.init(mte(a.name));case"COMMIT":if(s===void 0){l?.init(i.getState());return}return l?.init(mte(a.name));case"ROLLBACK":return FDe(_.state,m=>{if(s===void 0){d(m),l?.init(i.getState());return}d(m[s]),l?.init(mte(a.name))});case"JUMP_TO_STATE":case"JUMP_TO_ACTION":return FDe(_.state,m=>{if(s===void 0){d(m);return}JSON.stringify(i.getState())!==JSON.stringify(m[s])&&d(m[s])});case"IMPORT_STATE":{const{nextLiftedState:m}=_.payload,I=(p=m.computedStates.slice(-1)[0])==null?void 0:p.state;if(!I)return;d(s===void 0?I:I[s]),l?.send(null,m);return}case"PAUSE_RECORDING":return u=!u}return}}),h},FDe=(t,e)=>{let n;try{n=JSON.parse(t)}catch(o){console.error("[zustand devtools middleware] Could not parse the received json",o)}n!==void 0&&e(n)},LDe=sMt()(xPt(t=>({lastRunEvalVersion:void 0,setLastRunEvalVersion:e=>{t({lastRunEvalVersion:e})}}),{name:"runframe-runner-store"})),GMo=t=>{const[e,n]=ee.useState([]),[o,i]=ee.useState(null),[r,A]=ee.useState(""),[s,a]=uPt("eval-version-selection",null),c=LDe(d=>d.setLastRunEvalVersion),l=LDe(d=>d.lastRunEvalVersion);return ee.useEffect(()=>{t&&fetch("https://data.jsdelivr.com/v1/package/npm/@tscircuit/eval").then(d=>d.json()).then(d=>{if(Array.isArray(d?.versions)){let h=[...d.versions];d.tags?.latest&&(i(d.tags.latest),h=h.filter(_=>_!==d.tags.latest)),n(h)}}).catch(()=>{})},[t]),ee.useEffect(()=>{t&&(s?(window.TSCIRCUIT_LATEST_EVAL_VERSION=s,c(s)):o&&(window.TSCIRCUIT_LATEST_EVAL_VERSION=o,c(o)))},[t,s,o]),{versions:ee.useMemo(()=>e.filter(d=>d.includes(r)).slice(0,50),[e,r]),latestVersion:o,lastRunEvalVersion:l,search:r,setSearch:A,selectVersion:d=>{a(d),A("")}}},OMo=Bl("run-frame"),_5=window.TSCIRCUIT_FILESERVER_API_BASE_URL??"/api",KMo=[".tsx",".ts",".jsx",".js",".mjs",".json",".kicad_pcb",".kicad_sch",".kicad_prl",".kicad_pro"],HDe=t=>KMo.some(e=>t.endsWith(e)),OG=OMo.extend("store");async function QPt(t,e){return(await(await fetch(`${_5}/files/upsert`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({file_path:t,text_content:e})})).json()).file}async function GDe(t){return(await(await fetch(`${_5}/files/get?file_path=${encodeURIComponent(t)}`)).json()).file}async function UMo(t){const e=t?`${_5}/events/list?since=${encodeURIComponent(t)}`:`${_5}/events/list`;return(await(await fetch(e)).json()).event_list}async function YMo(){const t=await fetch(`${_5}/files/list`),{file_list:e}=await t.json(),n=new Map;for(const o of e){if(HDe(o.file_path)){const i=await GDe(o.file_path);n.set(o.file_path,i.text_content);continue}n.set(o.file_path,"__STATIC_ASSET__")}return n}const VMo=["manual-edits.json","manual_edits.json"],EQ=sMt()(xPt((t,e)=>({fsMap:new Map,lastEventTime:new Date().toISOString(),isPolling:!1,error:null,circuitJson:null,lastManualEditsChangeSentAt:0,recentEvents:[],simulateScenarioOrder:void 0,currentMainComponentPath:null,recentlySavedFiles:[],loadInitialFiles:async()=>{const n=await YMo();OG("loaded initial files",{fsMap:n}),t({fsMap:n})},upsertFile:async(n,o)=>{try{const i=await QPt(n,o);t(r=>({fsMap:new Map(r.fsMap).set(i.file_path,i.text_content)}))}catch(i){t({error:i})}},getFile:async n=>{try{const o=await GDe(n);t(i=>({fsMap:new Map(i.fsMap).set(o.file_path,o.text_content)}))}catch(o){t({error:o})}},setCircuitJson:n=>{n!==e().circuitJson&&t({circuitJson:n})},addRecentlySavedFile:n=>{t(o=>{if(VMo.includes(n)||!HDe(n))return o;const i=o.recentlySavedFiles.filter(r=>r!==n);return{recentlySavedFiles:[n,...i].slice(0,10)}})},startPolling:()=>{const n=async()=>{const o=e();if(o.isPolling){try{const i=await UMo(o.lastEventTime);if(i.length>0){const r=i[i.length-1].created_at;OG("received events",i.map(a=>a.event_type)),t(a=>({recentEvents:[...a.recentEvents,...i].slice(0,100),lastEventTime:r}));let A=0;const s=new Map(o.fsMap);for(const a of i)if(a.event_type==="FILE_UPDATED"){A++;const c=await GDe(a.file_path);if(a.file_path==="manual_edits.json"&&Date.now()-o.lastManualEditsChangeSentAt<1e3)continue;HDe(c.file_path)?s.set(c.file_path,c.text_content??""):s.set(c.file_path,"__STATIC_ASSET__"),e().addRecentlySavedFile(a.file_path)}else a.event_type==="FILE_DELETED"&&(A++,s.delete(a.file_path));A>0&&(OG("updating fsMap, fsUpdateCount:",A),t({fsMap:s}))}}catch(i){t({error:i})}setTimeout(n,1e3)}};t({isPolling:!0}),n()},stopPolling:()=>{t({isPolling:!1})},pushEvent:async n=>{await fetch(`${_5}/events/create`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)})},applyEditEventsAndUpdateManualEditsJson:async n=>{OG("applyEditEventsAndUpdateManualEditsJson",{editEvents:n});const o=e();if(!o.circuitJson)return;const i=o.fsMap.get("manual-edits.json"),r=i?JSON.parse(i):{},A=VFn({circuitJson:o.circuitJson,editEvents:n,manualEditsFile:r});OG("updatedManualEditsFileContent",A),t(s=>({lastManualEditsChangeSentAt:Date.now(),fsMap:new Map(s.fsMap).set("manual-edits.json",JSON.stringify(A))})),await QPt("manual-edits.json",JSON.stringify(A,null,2))},setSimulateScenarioOrder:n=>t({simulateScenarioOrder:n}),setCurrentMainComponentPath:n=>t({currentMainComponentPath:n})}),{name:"run-frame-store"})),zMo=({snippetNames:t,onSelect:e,onCancel:n,isOpen:o})=>{const[i,r]=ee.useState(""),[A,s]=ee.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 q.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:q.jsxs("div",{className:"rf-bg-white rf-rounded-lg rf-p-6 rf-w-96",children:[q.jsx("h2",{className:"rf-text-lg rf-font-semibold rf-mb-4",children:"Select Snippet"}),q.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}),q.jsxs("div",{className:"rf-h-60 rf-overflow-y-auto",children:[a.map(g=>q.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&&q.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,'"']})]}),q.jsxs("div",{className:"rf-mt-4 rf-flex rf-justify-end rf-gap-2",children:[q.jsx("button",{type:"button",className:"rf-px-4 rf-py-2 rf-text-gray-600 rf-hover:text-gray-800",onClick:n,children:"Cancel"}),q.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}`})]})]})})},JMo=t=>{const e=ee.useRef(null),n=EQ(o=>o.recentEvents);ee.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 pte="Dialog",[SPt,bPt]=qB(pte),[qMo,DB]=SPt(pte),ODe=t=>{const{__scopeDialog:e,children:n,open:o,defaultOpen:i,onOpenChange:r,modal:A=!0}=t,s=ee.useRef(null),a=ee.useRef(null),[c,l]=CM({prop:o,defaultProp:i??!1,onChange:r,caller:pte});return q.jsx(qMo,{scope:e,triggerRef:s,contentRef:a,contentId:jB(),titleId:jB(),descriptionId:jB(),open:c,onOpenChange:l,onOpenToggle:ee.useCallback(()=>l(g=>!g),[l]),modal:A,children:n})};ODe.displayName=pte;var DPt="DialogTrigger",MPt=ee.forwardRef((t,e)=>{const{__scopeDialog:n,...o}=t,i=DB(DPt,n),r=f0(e,i.triggerRef);return q.jsx(ml.button,{type:"button","aria-haspopup":"dialog","aria-expanded":i.open,"aria-controls":i.open?i.contentId:void 0,"data-state":VDe(i.open),...o,ref:r,onClick:Xr(t.onClick,i.onOpenToggle)})});MPt.displayName=DPt;var KDe="DialogPortal",[WMo,PPt]=SPt(KDe,{forceMount:void 0}),UDe=t=>{const{__scopeDialog:e,forceMount:n,children:o,container:i}=t,r=DB(KDe,e);return q.jsx(WMo,{scope:e,forceMount:n,children:ee.Children.map(o,A=>q.jsx(NE,{present:n||r.open,children:q.jsx(h4e,{asChild:!0,container:i,children:A})}))})};UDe.displayName=KDe;var Ite="DialogOverlay",Cte=ee.forwardRef((t,e)=>{const n=PPt(Ite,t.__scopeDialog),{forceMount:o=n.forceMount,...i}=t,r=DB(Ite,t.__scopeDialog);return r.modal?q.jsx(NE,{present:o||r.open,children:q.jsx(XMo,{...i,ref:e})}):null});Cte.displayName=Ite;var jMo=Fw("DialogOverlay.RemoveScroll"),XMo=ee.forwardRef((t,e)=>{const{__scopeDialog:n,...o}=t,i=DB(Ite,n),r=pmo(),A=f0(e,r);return q.jsx(C4e,{as:jMo,allowPinchZoom:!0,shards:[i.contentRef],children:q.jsx(ml.div,{"data-state":VDe(i.open),...o,ref:A,style:{pointerEvents:"auto",...o.style}})})}),hN="DialogContent",fte=ee.forwardRef((t,e)=>{const n=PPt(hN,t.__scopeDialog),{forceMount:o=n.forceMount,...i}=t,r=DB(hN,t.__scopeDialog);return q.jsx(NE,{present:o||r.open,children:r.modal?q.jsx($Mo,{...i,ref:e}):q.jsx(ZMo,{...i,ref:e})})});fte.displayName=hN;var $Mo=ee.forwardRef((t,e)=>{const n=DB(hN,t.__scopeDialog),o=ee.useRef(null),i=f0(e,n.contentRef,o);return ee.useEffect(()=>{const r=o.current;if(r)return Kxt(r)},[]),q.jsx(wPt,{...t,ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,onCloseAutoFocus:Xr(t.onCloseAutoFocus,r=>{r.preventDefault(),n.triggerRef.current?.focus()}),onPointerDownOutside:Xr(t.onPointerDownOutside,r=>{const A=r.detail.originalEvent,s=A.button===0&&A.ctrlKey===!0;(A.button===2||s)&&r.preventDefault()}),onFocusOutside:Xr(t.onFocusOutside,r=>r.preventDefault())})}),ZMo=ee.forwardRef((t,e)=>{const n=DB(hN,t.__scopeDialog),o=ee.useRef(!1),i=ee.useRef(!1);return q.jsx(wPt,{...t,ref:e,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:r=>{t.onCloseAutoFocus?.(r),r.defaultPrevented||(o.current||n.triggerRef.current?.focus(),r.preventDefault()),o.current=!1,i.current=!1},onInteractOutside:r=>{t.onInteractOutside?.(r),r.defaultPrevented||(o.current=!0,r.detail.originalEvent.type==="pointerdown"&&(i.current=!0));const A=r.target;n.triggerRef.current?.contains(A)&&r.preventDefault(),r.detail.originalEvent.type==="focusin"&&i.current&&r.preventDefault()}})}),wPt=ee.forwardRef((t,e)=>{const{__scopeDialog:n,trapFocus:o,onOpenAutoFocus:i,onCloseAutoFocus:r,...A}=t,s=DB(hN,n);return ext(),q.jsx(q.Fragment,{children:q.jsx(X5e,{asChild:!0,loop:!0,trapped:o,onMountAutoFocus:i,onUnmountAutoFocus:r,children:q.jsx(kZ,{role:"dialog",id:s.contentId,"aria-describedby":s.descriptionId,"aria-labelledby":s.titleId,"data-state":VDe(s.open),...A,ref:e,deferPointerDownOutside:!0,onDismiss:()=>s.onOpenChange(!1)})})})}),vPt="DialogTitle",yte=ee.forwardRef((t,e)=>{const{__scopeDialog:n,...o}=t,i=DB(vPt,n);return q.jsx(ml.h2,{id:i.titleId,...o,ref:e})});yte.displayName=vPt;var NPt="DialogDescription",Ete=ee.forwardRef((t,e)=>{const{__scopeDialog:n,...o}=t,i=DB(NPt,n);return q.jsx(ml.p,{id:i.descriptionId,...o,ref:e})});Ete.displayName=NPt;var RPt="DialogClose",YDe=ee.forwardRef((t,e)=>{const{__scopeDialog:n,...o}=t,i=DB(RPt,n);return q.jsx(ml.button,{type:"button",...o,ref:e,onClick:Xr(t.onClick,()=>i.onOpenChange(!1))})});YDe.displayName=RPt;function VDe(t){return t?"open":"closed"}var TPt="AlertDialog",[e3o]=qB(TPt,[bPt]),m5=bPt(),kPt=t=>{const{__scopeAlertDialog:e,...n}=t,o=m5(e);return q.jsx(ODe,{...o,...n,modal:!0})};kPt.displayName=TPt;var t3o="AlertDialogTrigger",n3o=ee.forwardRef((t,e)=>{const{__scopeAlertDialog:n,...o}=t,i=m5(n);return q.jsx(MPt,{...i,...o,ref:e})});n3o.displayName=t3o;var o3o="AlertDialogPortal",FPt=t=>{const{__scopeAlertDialog:e,...n}=t,o=m5(e);return q.jsx(UDe,{...o,...n})};FPt.displayName=o3o;var i3o="AlertDialogOverlay",LPt=ee.forwardRef((t,e)=>{const{__scopeAlertDialog:n,...o}=t,i=m5(n);return q.jsx(Cte,{...i,...o,ref:e})});LPt.displayName=i3o;var HPt="AlertDialogContent",[r3o,A3o]=e3o(HPt),GPt=ee.forwardRef((t,e)=>{const{__scopeAlertDialog:n,children:o,...i}=t,r=m5(n),A=ee.useRef(null),s=f0(e,A),a=ee.useRef(null);return q.jsx(r3o,{scope:n,cancelRef:a,children:q.jsx(fte,{role:"alertdialog",...r,...i,ref:s,onOpenAutoFocus:Xr(i.onOpenAutoFocus,c=>{c.preventDefault(),a.current?.focus({preventScroll:!0})}),onPointerDownOutside:c=>c.preventDefault(),onInteractOutside:c=>c.preventDefault(),children:o})})});GPt.displayName=HPt;var s3o="AlertDialogTitle",OPt=ee.forwardRef((t,e)=>{const{__scopeAlertDialog:n,...o}=t,i=m5(n);return q.jsx(yte,{...i,...o,ref:e})});OPt.displayName=s3o;var a3o="AlertDialogDescription",KPt=ee.forwardRef((t,e)=>{const{__scopeAlertDialog:n,...o}=t,i=m5(n);return q.jsx(Ete,{...i,...o,ref:e})});KPt.displayName=a3o;var c3o="AlertDialogAction",UPt=ee.forwardRef((t,e)=>{const{__scopeAlertDialog:n,...o}=t,i=m5(n);return q.jsx(YDe,{...i,...o,ref:e})});UPt.displayName=c3o;var YPt="AlertDialogCancel",VPt=ee.forwardRef((t,e)=>{const{__scopeAlertDialog:n,...o}=t,{cancelRef:i}=A3o(YPt,n),r=m5(n),A=f0(e,i);return q.jsx(YDe,{...r,...o,ref:A})});VPt.displayName=YPt;var l3o=kPt,g3o=FPt,zPt=LPt,JPt=GPt,qPt=UPt,WPt=VPt,jPt=OPt,XPt=KPt;const $Pt=l3o,u3o=g3o,ZPt=ee.forwardRef(({className:t,...e},n)=>q.jsx(zPt,{className:nA("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}));ZPt.displayName=zPt.displayName;const zDe=ee.forwardRef(({className:t,...e},n)=>q.jsxs(u3o,{children:[q.jsx(ZPt,{}),q.jsx(JPt,{ref:n,className:nA("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})]}));zDe.displayName=JPt.displayName;const JDe=({className:t,...e})=>q.jsx("div",{className:nA("rf-flex rf-flex-col rf-space-y-2 rf-text-center sm:rf-text-left",t),...e});JDe.displayName="AlertDialogHeader";const qDe=({className:t,...e})=>q.jsx("div",{className:nA("rf-flex rf-flex-col-reverse sm:rf-flex-row sm:rf-justify-end sm:rf-space-x-2",t),...e});qDe.displayName="AlertDialogFooter";const WDe=ee.forwardRef(({className:t,...e},n)=>q.jsx(jPt,{ref:n,className:nA("rf-text-lg rf-font-semibold",t),...e}));WDe.displayName=jPt.displayName;const jDe=ee.forwardRef(({className:t,...e},n)=>q.jsx(XPt,{ref:n,className:nA("rf-text-sm rf-text-zinc-500 dark:rf-text-zinc-400",t),...e}));jDe.displayName=XPt.displayName;const h3o=ee.forwardRef(({className:t,...e},n)=>q.jsx(qPt,{ref:n,className:nA(F7(),t),...e}));h3o.displayName=qPt.displayName;const XDe=ee.forwardRef(({className:t,...e},n)=>q.jsx(WPt,{ref:n,className:nA(F7({variant:"outline"}),"rf-mt-2 sm:rf-mt-0",t),...e}));XDe.displayName=WPt.displayName;function d3o(t){const e=ee.useRef({value:t,previous:t});return ee.useMemo(()=>(e.current.value!==t&&(e.current.previous=e.current.value,e.current.value=t),e.current.previous),[t])}var Bte="Checkbox",[_3o]=qB(Bte),[m3o,$De]=_3o(Bte);function p3o(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,d]=CM({prop:n,defaultProp:i??!1,onChange:a,caller:Bte}),[h,_]=ee.useState(null),[p,m]=ee.useState(null),I=ee.useRef(!1),C=h?!!A||!!h.closest("form"):!0,f={checked:u,disabled:r,setChecked:d,control:h,setControl:_,name:s,form:A,value:l,hasConsumerStoppedPropagationRef:I,required:c,defaultChecked:RD(i)?!1:i,isFormControl:C,bubbleInput:p,setBubbleInput:m};return q.jsx(m3o,{scope:e,...f,children:I3o(g)?g(f):o})}var ewt="CheckboxTrigger",twt=ee.forwardRef(({__scopeCheckbox:t,onKeyDown:e,onClick:n,...o},i)=>{const{control:r,value:A,disabled:s,checked:a,required:c,setControl:l,setChecked:g,hasConsumerStoppedPropagationRef:u,isFormControl:d,bubbleInput:h}=$De(ewt,t),_=f0(i,l),p=ee.useRef(a);return ee.useEffect(()=>{const m=r?.form;if(m){const I=()=>g(p.current);return m.addEventListener("reset",I),()=>m.removeEventListener("reset",I)}},[r,g]),q.jsx(ml.button,{type:"button",role:"checkbox","aria-checked":RD(a)?"mixed":a,"aria-required":c,"data-state":Awt(a),"data-disabled":s?"":void 0,disabled:s,value:A,...o,ref:_,onKeyDown:Xr(e,m=>{m.key==="Enter"&&m.preventDefault()}),onClick:Xr(n,m=>{g(I=>RD(I)?!0:!I),h&&d&&(u.current=m.isPropagationStopped(),u.current||m.stopPropagation())})})});twt.displayName=ewt;var ZDe=ee.forwardRef((t,e)=>{const{__scopeCheckbox:n,name:o,checked:i,defaultChecked:r,required:A,disabled:s,value:a,onCheckedChange:c,form:l,...g}=t;return q.jsx(p3o,{__scopeCheckbox:n,checked:i,defaultChecked:r,disabled:s,required:A,onCheckedChange:c,name:o,form:l,value:a,internal_do_not_use_render:({isFormControl:u})=>q.jsxs(q.Fragment,{children:[q.jsx(twt,{...g,ref:e,__scopeCheckbox:n}),u&&q.jsx(rwt,{__scopeCheckbox:n})]})})});ZDe.displayName=Bte;var nwt="CheckboxIndicator",owt=ee.forwardRef((t,e)=>{const{__scopeCheckbox:n,forceMount:o,...i}=t,r=$De(nwt,n);return q.jsx(NE,{present:o||RD(r.checked)||r.checked===!0,children:q.jsx(ml.span,{"data-state":Awt(r.checked),"data-disabled":r.disabled?"":void 0,...i,ref:e,style:{pointerEvents:"none",...t.style}})})});owt.displayName=nwt;var iwt="CheckboxBubbleInput",rwt=ee.forwardRef(({__scopeCheckbox:t,...e},n)=>{const{control:o,hasConsumerStoppedPropagationRef:i,checked:r,defaultChecked:A,required:s,disabled:a,name:c,value:l,form:g,bubbleInput:u,setBubbleInput:d}=$De(iwt,t),h=f0(n,d),_=d3o(r),p=Mxt(o);ee.useEffect(()=>{const I=u;if(!I)return;const C=window.HTMLInputElement.prototype,E=Object.getOwnPropertyDescriptor(C,"checked").set,B=!i.current;if(_!==r&&E){const x=new Event("click",{bubbles:B});I.indeterminate=RD(r),E.call(I,RD(r)?!1:r),I.dispatchEvent(x)}},[u,_,r,i]);const m=ee.useRef(RD(r)?!1:r);return q.jsx(ml.input,{type:"checkbox","aria-hidden":!0,defaultChecked:A??m.current,required:s,disabled:a,name:c,value:l,form:g,...e,tabIndex:-1,ref:h,style:{...e.style,...p,position:"absolute",pointerEvents:"none",opacity:0,margin:0,transform:"translateX(-100%)"}})});rwt.displayName=iwt;function I3o(t){return typeof t=="function"}function RD(t){return t==="indeterminate"}function Awt(t){return RD(t)?"indeterminate":t?"checked":"unchecked"}const KG=ee.forwardRef(({className:t,...e},n)=>q.jsx(ZDe,{ref:n,className:nA("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:q.jsx(owt,{className:nA("rf-flex rf-items-center rf-justify-center rf-text-current"),children:q.jsx(V5e,{className:"rf-h-4 rf-w-4"})})}));KG.displayName=ZDe.displayName;const UG=ODe,C3o=UDe,swt=ee.forwardRef(({className:t,...e},n)=>q.jsx(Cte,{className:nA("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}));swt.displayName=Cte.displayName;const dN=ee.forwardRef(({className:t,children:e,showOverlay:n=!0,...o},i)=>q.jsxs(C3o,{children:[q.jsx(swt,{className:nA(n?"":"rf-hidden")}),q.jsx(fte,{ref:i,className:nA("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})]}));dN.displayName=fte.displayName;const _N=({className:t,...e})=>q.jsx("div",{className:nA("rf-flex rf-flex-col rf-space-y-2 rf-text-center sm:rf-text-left",t),...e});_N.displayName="DialogHeader";const YG=({className:t,...e})=>q.jsx("div",{className:nA("rf-flex rf-flex-col-reverse sm:rf-flex-row sm:rf-justify-end sm:rf-space-x-2",t),...e});YG.displayName="DialogFooter";const mN=ee.forwardRef(({className:t,...e},n)=>q.jsx(yte,{ref:n,className:nA("rf-text-lg rf-font-semibold",t),...e}));mN.displayName=yte.displayName;const VG=ee.forwardRef(({className:t,...e},n)=>q.jsx(Ete,{ref:n,className:nA("rf-text-sm rf-text-zinc-500 dark:rf-text-zinc-400",t),...e}));VG.displayName=Ete.displayName;const xte={"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"}},f3o="https://cdn.jsdelivr.net/npm/easyeda@latest/dist/browser/index.js";let eMe=null;const tMe=async()=>(eMe||(eMe=import(f3o)),eMe),y3o=t=>(e,n)=>{const o=new Headers(n?.headers),i={};return o.forEach((r,A)=>{i[A]=r}),fetch(`${t?.apiBase??_5}/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}})},E3o=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??[]},B3o=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}),awt=async(t,e)=>{const{fetchEasyEDAComponent:n}=await tMe();return n(t,{fetch:y3o(e),includeModelMetadata:e?.includeModelMetadata})},x3o=async(t,e)=>{const{convertRawEasyToTsx:n}=await tMe(),o=await awt(t,e);return n({rawEasy:o})},Q3o=async(t,e)=>{const{EasyEdaJsonSchema:n,convertEasyEdaJsonToCircuitJson:o}=await tMe(),i=await awt(t,{...e,includeModelMetadata:!1}),r=n.parse(i);return o(r,{shouldRecenter:!0,showDesignator:!0,useModelCdn:!1})};function TD(t){return Array.isArray?Array.isArray(t):lwt(t)==="[object Array]"}function S3o(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 nMe(t){return t==null?"":S3o(t)}function jI(t){return typeof t=="string"}function Qte(t){return typeof t=="number"}function b3o(t){return t===!0||t===!1||D3o(t)&&lwt(t)=="[object Boolean]"}function cwt(t){return typeof t=="object"}function D3o(t){return cwt(t)&&t!==null}function Yy(t){return t!=null}function Ste(t){return!t.trim().length}function lwt(t){return t==null?t===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(t)}const M3o="Incorrect 'index' type",oMe="Invalid doc index: must be a non-negative integer within the bounds of the docs array",P3o=t=>`Invalid value for key ${t}`,w3o=t=>`Pattern length exceeds max of ${t}.`,v3o=t=>`Missing ${t} property in key`,N3o=t=>`Property 'weight' in key '${t}' must be a positive integer`,R3o="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.",gwt=Object.prototype.hasOwnProperty;var T3o=class{constructor(t){this._keys=[],this._keyMap={};let e=0;t.forEach(n=>{const o=uwt(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 uwt(t){let e=null,n=null,o=null,i=1,r=null;if(jI(t)||TD(t))o=t,e=hwt(t),n=bte(t);else{if(!gwt.call(t,"name"))throw new Error(v3o("name"));const A=t.name;if(o=A,gwt.call(t,"weight")&&t.weight!==void 0&&(i=t.weight,i<=0))throw new Error(N3o(bte(A)));e=hwt(A),n=bte(A),r=t.getFn??null}return{path:e,id:n,weight:i,src:o,getFn:r}}function hwt(t){return TD(t)?t:t.split(".")}function bte(t){return TD(t)?t.join("."):t}function k3o(t,e){const n=[];let o=!1;const i=(r,A,s,a)=>{if(Yy(r))if(!A[s])n.push(a!==void 0?{v:r,i:a}:r);else{const c=r[A[s]];if(!Yy(c))return;if(s===A.length-1&&(jI(c)||Qte(c)||b3o(c)||typeof c=="bigint"))n.push(a!==void 0?{v:nMe(c),i:a}:nMe(c));else if(TD(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,jI(e)?e.split("."):e,0),o?n:n[0]}const bA=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:k3o,ignoreLocation:!1,ignoreFieldNorm:!1,fieldNormWeight:1}});function F3o(t){return t>=9&&t<=13||t===32||t===160}function L3o(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++)F3o(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 iMe=class{constructor({getFn:t=bA.getFn,fieldNormWeight:e=bA.fieldNormWeight}={}){this.norm=L3o(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(jI(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(oMe);if(jI(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(oMe);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!Yy(t)||Ste(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(Yy(A)){if(TD(A)){const s=[];for(let a=0,c=A.length;a<c;a+=1){const l=A[a];if(Yy(l)){if(jI(l)){if(!Ste(l)){const g={v:l,i:a,n:this.norm.get(l)};s.push(g)}}else if(Yy(l.v)){const g=jI(l.v)?l.v:nMe(l.v);if(!Ste(g)){const u={v:g,i:l.i,n:this.norm.get(g)};s.push(u)}}}}n.$[o]=s}else if(jI(A)&&!Ste(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 dwt(t,e,{getFn:n=bA.getFn,fieldNormWeight:o=bA.fieldNormWeight}={}){const i=new iMe({getFn:n,fieldNormWeight:o});return i.setKeys(t.map(uwt)),i.setSources(e),i.create(),i}function H3o(t,{getFn:e=bA.getFn,fieldNormWeight:n=bA.fieldNormWeight}={}){const{keys:o,records:i}=t,r=new iMe({getFn:e,fieldNormWeight:n});return r.setKeys(o),r.setIndexRecords(i),r}function G3o(t=[],e=bA.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 O3o(t,e,n,{location:o=bA.location,distance:i=bA.distance,threshold:r=bA.threshold,findAllMatches:A=bA.findAllMatches,minMatchCharLength:s=bA.minMatchCharLength,includeMatches:a=bA.includeMatches,ignoreLocation:c=bA.ignoreLocation}={}){if(e.length>32)throw new Error(w3o(32));const l=e.length,g=t.length,u=Math.max(0,Math.min(o,g));let d=r,h=u;const _=(P,M)=>{const k=P/l;if(c)return k;const N=Math.abs(u-M);return i?k+N/i:N?1:k},p=s>1||a,m=p?Array(g):[];let I;for(;(I=t.indexOf(e,h))>-1;){const P=_(0,I);if(d=Math.min(P,d),h=I+l,p){let M=0;for(;M<l;)m[I+M]=1,M+=1}}h=-1;let C=[],f=1,E=0,B=l+g;const x=1<<l-1;for(let P=0;P<l;P+=1){let M=0,k=B;for(;M<k;)_(P,u+k)<=d?M=k:B=k,k=Math.floor((B-M)/2+M);B=k;let N=Math.max(1,u-k+1);const G=A?g:Math.min(u+k,g)+l,H=Array(G+2);H[G+1]=(1<<P)-1;for(let U=G;U>=N;U-=1){const J=U-1,W=n[t[J]];if(H[U]=(H[U+1]<<1|1)&W,P&&(H[U]|=(C[U+1]|C[U])<<1|1|C[U+1]),H[U]&x&&(f=_(P,J),f<=d)){if(d=f,h=J,E=P,h<=u)break;N=Math.max(1,2*u-h)}}if(_(P+1,u)>d)break;C=H}if(p&&h>=0){const P=Math.min(g-1,h+l-1+E);for(let M=h;M<=P;M+=1)n[t[M]]&&(m[M]=1)}const b={isMatch:h>=0,score:Math.max(.001,f)};if(p){const P=G3o(m,s);P.length?a&&(b.indices=P):b.isMatch=!1}return b}function K3o(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 rMe(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 _wt={ł:"l",Ł:"L",đ:"d",Đ:"D",ø:"o",Ø:"O",ħ:"h",Ħ:"H",ŧ:"t",Ŧ:"T",ı:"i",ß:"ss"},U3o=new RegExp("["+Object.keys(_wt).join("")+"]","g"),zG=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(U3o,e=>_wt[e]):t=>t;var AMe=class{constructor(t,{location:e=bA.location,threshold:n=bA.threshold,distance:o=bA.distance,includeMatches:i=bA.includeMatches,findAllMatches:r=bA.findAllMatches,minMatchCharLength:A=bA.minMatchCharLength,isCaseSensitive:s=bA.isCaseSensitive,ignoreDiacritics:a=bA.ignoreDiacritics,ignoreLocation:c=bA.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?zG(t):t,this.pattern=t,this.chunks=[],!this.pattern.length)return;const l=(u,d)=>{this.chunks.push({pattern:u,alphabet:K3o(u),startIndex:d})},g=this.pattern.length;if(g>32){let u=0;const d=g%32,h=g-d;for(;u<h;)l(this.pattern.substr(u,32),u),u+=32;if(d){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?zG(t):t,this.pattern===t){if(t.length<this.options.minMatchCharLength)return{isMatch:!1,score:1};const h={isMatch:!0,score:0};return o&&(h.indices=[[0,t.length-1]]),h}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:h,alphabet:_,startIndex:p})=>{const{isMatch:m,score:I,indices:C}=O3o(t,h,_,{location:i+p,distance:r,threshold:A,findAllMatches:s,minMatchCharLength:a,includeMatches:o,ignoreLocation:c});m&&(u=!0),g+=I,m&&C&&l.push(...C)});const d={isMatch:u,score:u?g/this.chunks.length:1};return u&&o&&(d.indices=rMe(l)),d}};const Y3o=new Set(["fuzzy","include"]);function V3o(t){return t.startsWith("inverse")}const sMe=[{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 AMe(t,{location:e.location??bA.location,threshold:e.threshold??bA.threshold,distance:e.distance??bA.distance,includeMatches:e.includeMatches??bA.includeMatches,findAllMatches:e.findAllMatches??bA.findAllMatches,minMatchCharLength:e.minMatchCharLength??bA.minMatchCharLength,isCaseSensitive:e.isCaseSensitive??bA.isCaseSensitive,ignoreDiacritics:e.ignoreDiacritics??bA.ignoreDiacritics,ignoreLocation:e.ignoreLocation??bA.ignoreLocation});return{type:"fuzzy",search(o){return n.searchIn(o)}}}}],mwt=sMe.length,z3o="\0",J3o="|";function q3o(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 pwt(t,e){const n=t.match(e);return n?n[1]:null}function W3o(t,e={}){return t.replace(/\\\|/g,z3o).split(J3o).map(n=>{const o=q3o(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<mwt;){const l=sMe[c],g=pwt(s,l.multiRegex);g&&(i.push(l.create(g,e)),a=!0)}if(!a)for(c=-1;++c<mwt;){const l=sMe[c],g=pwt(s,l.singleRegex);if(g){i.push(l.create(g,e));break}}}return i})}var j3o=class{constructor(t,{isCaseSensitive:e=bA.isCaseSensitive,ignoreDiacritics:n=bA.ignoreDiacritics,includeMatches:o=bA.includeMatches,minMatchCharLength:i=bA.minMatchCharLength,ignoreLocation:r=bA.ignoreLocation,findAllMatches:A=bA.findAllMatches,location:s=bA.location,threshold:a=bA.threshold,distance:c=bA.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?zG(t):t,this.pattern=t,this.query=W3o(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?zG(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,d=g.length;u<d;u+=1){const h=g[u],{isMatch:_,indices:p,score:m}=h.search(t);if(_)r+=1,s+=m,V3o(h.type)&&(a=!0),n&&(Y3o.has(h.type)?A.push(...p):A.push(p));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=rMe(A)),u}}return{isMatch:!1,score:1}}};const aMe=[];function cMe(...t){aMe.push(...t)}function Dte(t,e){for(let n=0,o=aMe.length;n<o;n+=1){const i=aMe[n];if(i.condition(t,e))return new i(t,e)}return new AMe(t,e)}const Mte={AND:"$and",OR:"$or"},lMe={PATH:"$path",PATTERN:"$val"},gMe=t=>!!(t[Mte.AND]||t[Mte.OR]),X3o=t=>!!t[lMe.PATH],$3o=t=>!TD(t)&&cwt(t)&&!gMe(t),Iwt=t=>({[Mte.AND]:Object.keys(t).map(e=>({[e]:t[e]}))});function Cwt(t,e,{auto:n=!0}={}){const o=i=>{if(jI(i)){const a={keyId:null,pattern:i};return n&&(a.searcher=Dte(i,e)),a}const r=Object.keys(i),A=X3o(i);if(!A&&r.length>1&&!gMe(i))return o(Iwt(i));if($3o(i)){const a=A?i[lMe.PATH]:r[0],c=A?i[lMe.PATTERN]:i[a];if(!jI(c))throw new Error(P3o(a));const l={keyId:bte(a),pattern:c};return n&&(l.searcher=Dte(c,e)),l}const s={children:[],operator:r[0]};return r.forEach(a=>{const c=i[a];TD(c)&&c.forEach(l=>{s.children.push(o(l))})}),s};return gMe(t)||(t=Iwt(t)),o(t)}function uMe(t,{ignoreFieldNorm:e=bA.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 Z3o(t,{ignoreFieldNorm:e=bA.ignoreFieldNorm}){t.forEach(n=>{n.score=uMe(n.matches,{ignoreFieldNorm:e})})}var ePo=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 tPo(t){const e=[];return t.matches.forEach(n=>{if(!Yy(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 nPo(t,e,{includeMatches:n=bA.includeMatches,includeScore:o=bA.includeScore}={}){return t.map(i=>{const{idx:r}=i,A={item:e[r],refIndex:r};return n&&(A.matches=tPo(i)),o&&(A.score=i.score),A})}const oPo=/[\p{L}\p{M}\p{N}_]+/gu,fwt=new WeakSet;function iPo(t){fwt.has(t)||(fwt.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 rPo(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||iPo(t),e=>e.match(t)||[]):e=>e.match(oPo)||[]}function hMe({isCaseSensitive:t=!1,ignoreDiacritics:e=!1,tokenize:n}={}){const o=rPo(n);return{tokenize(i){return t||(i=i.toLowerCase()),e&&(i=zG(i)),o(i)}}}var APo=class{static condition(t,e){return e.useTokenSearch}constructor(t,e){this.options=e,this.analyzer=hMe({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 AMe(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=rMe(e)),this.combineAll&&(this.useMask?a.matchedMask=r:a.matchedTerms=A,a.termCount=this.numTerms),a}};function dMe(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 ywt(t,e,n,o){const{i,v:r,$:A}=e;if(r!==void 0){dMe(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)dMe(t,c.v,i,o);else dMe(t,a.v,i,o)}}function sPo(t,e,n){const o={fieldCount:0,df:new Map,docFieldCount:new Map,docTermFieldHits:new Map};for(const i of t)ywt(o,i,e,n);return o}function aPo(t,e,n,o){ywt(t,e,n,o)}function cPo(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 Ewt(t,e){if(e.length===0)return;const n=Array.from(new Set(e)).sort((s,a)=>s-a);for(const s of n)cPo(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 kD=class{constructor(t,e,n){this.options={...bA,...e},this.options.useExtendedSearch,this.options.useTokenSearch,this._keyStore=new T3o(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=Dte(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 iMe))throw new Error(M3o);if(this._myIndex=e||dwt(this.options.keys,this._docs,{getFn:this.options.getFn,fieldNormWeight:this.options.fieldNormWeight}),this.options.useTokenSearch){const n=hMe({isCaseSensitive:this.options.isCaseSensitive,ignoreDiacritics:this.options.ignoreDiacritics,tokenize:this.options.tokenize});this._invertedIndex=sPo(this._myIndex.records,this._myIndex.keys.length,n)}this._invalidateSearcherCache()}add(t){if(!Yy(t))return;this._docs.push(t);const e=this._myIndex.add(t,this._docs.length-1);if(this._invertedIndex&&e){const n=hMe({isCaseSensitive:this.options.isCaseSensitive,ignoreDiacritics:this.options.ignoreDiacritics,tokenize:this.options.tokenize});aPo(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&&Ewt(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(oMe);this._invertedIndex&&Ewt(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(jI(t)&&!t.trim()){let u=this._docs.map((d,h)=>({item:d,refIndex:h}));return Qte(n)&&n>-1&&(u=u.slice(0,n)),u}const a=r&&Qte(n)&&n>0&&jI(t),c=A,l=(u,d)=>c(u,d)||u.idx-d.idx;let g;if(a){const u=new ePo(n,l);jI(this._docs[0])?this._searchStringList(t,{heap:u,ignoreFieldNorm:s}):this._searchObjectList(t,{heap:u,ignoreFieldNorm:s}),g=u.extractSorted()}else g=jI(t)?jI(this._docs[0])?this._searchStringList(t):this._searchObjectList(t):this._searchLogical(t),Z3o(g,{ignoreFieldNorm:s}),r&&g.sort(jI(t)?l:c),Qte(n)&&n>-1&&(g=g.slice(0,n));return nPo(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(!Yy(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 d={item:s,idx:a,matches:u};e?(d.score=uMe(d.matches,{ignoreFieldNorm:n}),e.insert(d)):A.push(d)}}}),A}_searchLogical(t){const e=Cwt(t,this.options),n=this._normalizedKeys(),o=(s,a,c)=>{if(!("children"in s)){const{keyId:d,searcher:h}=s;let _;return d===null?(_=[],n.forEach((p,m)=>{_.push(...this._findMatches({key:p,value:a[m],searcher:h}))})):_=this._findMatches({key:this._keyStore.get(d),value:this._myIndex.getValueForItemAtKeyId(a,d),searcher:h}),_&&_.length?[{idx:c,item:a,matches:_}]:[]}const{children:l,operator:g}=s,u=[];for(let d=0,h=l.length;d<h;d+=1){const _=l[d],p=o(_,a,c);if(p.length)u.push(...p);else if(g===Mte.AND)return[]}return u},i=this._myIndex.records,r=new Map,A=[];return i.forEach(({$:s,i:a})=>{if(Yy(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(!Yy(a))return;const l=[];let g=!1,u=!1;if(A.forEach((d,h)=>{const _=this._findMatches({key:d,value:a[h],searcher:o});_.length?(l.push(..._),_[0].hasInverse&&(u=!0)):g=!0}),!(u&&g)&&l.length&&(!i||this._coversAllTokens(l))){const d={idx:c,item:a,matches:l};e?(d.score=uMe(d.matches,{ignoreFieldNorm:n}),e.insert(d)):s.push(d)}}),s}_findMatches({key:t,value:e,searcher:n}){if(!Yy(e))return[];const o=[];if(TD(e))e.forEach(({v:i,i:r,n:A})=>{if(!Yy(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}};kD.version="7.5.0",kD.createIndex=dwt,kD.parseIndex=H3o,kD.config=bA,kD.match=function(t,e,n){if(n&&n.useTokenSearch)throw new Error(R3o);return Dte(t,{...bA,...n}).searchIn(e)},kD.parseQuery=Cwt,cMe(j3o),cMe(APo),kD.use=function(...t){t.forEach(e=>cMe(e))};var lPo=kD;const gPo="https://kicad-mod-cache.tscircuit.com";let _Me=null,JG=null,mMe=null;const uPo=async()=>_Me||JG||(JG=fetch("https://kicad-mod-cache.tscircuit.com/kicad_files.json").then(t=>t.json()).then(t=>(_Me=t,JG=null,t)),JG),hPo=async(t,e=20)=>{const n=await uPo();return mMe||(mMe=new lPo(n)),mMe.search(t).slice(0,e).map(o=>o.item)},dPo=t=>{const e=t.replace(".pretty/","/").replace(".kicad_mod",""),n=`kicad:${e}`;return{path:t,qualifiedName:n,description:e}},_Po=t=>t.replace(/^\/+/,"").split("/").map(e=>encodeURIComponent(e)).join("/"),mPo=async t=>{const e=await fetch(`${gPo}/${_Po(t)}`);if(!e.ok)throw new Error(`KiCad footprint fetch failed: ${e.status}`);const n=await e.text(),{KicadFootprintToCircuitJsonConverter:o}=await xB("kicad-to-circuit-json"),i=new o;return i.addFile(t.split("/").pop()??"selected-footprint.kicad_mod",n),i.runUntilFinished(),i.getOutput()},Bwt=t=>t?.source==="jlcpcb"||t?.source==="kicad",pPo=async(t,e)=>{if(t.source==="jlcpcb")return Q3o(t.component.partNumber,e?.jlcpcb);if(t.source==="kicad")return mPo(t.footprint.path);throw new Error("Footprint preview is not available for this source")},IPo=({query:t,placeholder:e,isSearching:n,onQueryChange:o,onSubmit:i})=>{const r=ee.useCallback(A=>{A.key==="Enter"&&(A.preventDefault(),i())},[i]);return q.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2 rf-mt-4",children:[q.jsxs("div",{className:"rf-relative rf-flex-grow",children:[q.jsx(jBt,{className:"rf-absolute rf-left-2 rf-top-2.5 rf-h-4 rf-w-4 rf-text-muted-foreground"}),q.jsx(cbe,{placeholder:e,className:"rf-pl-8",spellCheck:!1,autoComplete:"off",value:t,onChange:A=>o(A.target.value),onKeyDown:r})]}),q.jsx(cc,{onClick:i,disabled:n||t.trim().length<1,className:"sm:rf-px-4 rf-px-3",children:n?q.jsx(cQ,{className:"rf-h-4 rf-w-4 rf-animate-spin"}):q.jsxs(q.Fragment,{children:[q.jsx(jBt,{className:"rf-h-4 rf-w-4 sm:rf-hidden"}),q.jsx("span",{className:"rf-hidden sm:rf-inline",children:"Search"})]})})]})},CPo=new Intl.NumberFormat("en-US",{style:"currency",currency:"USD"}),fPo=t=>CPo.format(t),xwt=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"}},yPo=t=>{switch(t.source){case"tscircuit.com":return t.package.unscoped_name;case"jlcpcb":return t.component.manufacturer;case"kicad":return t.footprint.qualifiedName}},EPo=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}},BPo=t=>{switch(t.source){case"tscircuit.com":return t.package.name;case"jlcpcb":return t.component.partNumber;case"kicad":return}},xPo=({results:t,selected:e,onSelect:n,onShowDetails:o})=>{const i=e?xwt(e):null;return q.jsx("div",{className:"rf-divide-y rf-w-full rf-overflow-hidden",children:t.map(r=>{const A=xwt(r),s=i===A,a=yPo(r),c=EPo(r),l=BPo(r),g=r.source==="jlcpcb"?r.component.stock:null,u=r.source==="jlcpcb"?r.component.price:null,d=r.source==="jlcpcb"?r.component.isBasic:null;return q.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:[q.jsxs("div",{className:"rf-min-w-0 rf-overflow-hidden rf-w-full",children:[q.jsxs("div",{className:"rf-flex rf-items-start rf-gap-2 rf-min-w-0",children:[q.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"&&d!=null&&q.jsx("span",{className:`rf-text-xs rf-px-1.5 rf-py-0.5 rf-rounded rf-font-medium rf-flex-shrink-0 ${d?"rf-bg-green-100 rf-text-green-700":"rf-bg-orange-100 rf-text-orange-700"}`,children:d?"Basic":"Extended"}),r.source==="tscircuit.com"&&r.package.is_private&&q.jsx(emo,{className:"rf-ml-1 rf-h-3 rf-w-3 rf-text-zinc-400 rf-flex-shrink-0"})]}),r.source==="jlcpcb"&&g!=null?q.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]}),q.jsxs("div",{className:"rf-text-xs rf-text-zinc-500 rf-truncate rf-w-full",children:[l?q.jsx("span",{className:"rf-mr-2",children:l}):null,c]})]}),q.jsxs("div",{children:[r.source==="tscircuit.com"&&o?q.jsx("div",{className:"rf-flex-shrink-0 rf-w-full sm:rf-w-auto",children:q.jsx(cc,{variant:"outline",size:"sm",className:"rf-text-xs rf-w-full sm:rf-w-auto",onClick:h=>{h.stopPropagation(),o(r)},children:"See Details"})}):r.source==="jlcpcb"&&g!=null?q.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&&q.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:fPo(u)})]})]},A)})})},QPo=({circuitJson:t,error:e,isLoading:n,height:o})=>q.jsx("section",{className:"rf-flex rf-min-w-0 rf-items-center rf-justify-center",style:{height:o},children:n?q.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:[q.jsx(cQ,{className:"rf-h-4 rf-w-4 rf-animate-spin"}),"Loading preview..."]}):e?q.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:q.jsxs("div",{className:"rf-flex rf-max-w-[320px] rf-items-start rf-gap-2 rf-text-sm rf-text-zinc-300",children:[q.jsx(qBt,{className:"rf-mt-0.5 rf-h-4 rf-w-4 rf-flex-shrink-0"}),q.jsx("span",{children:e})]})}):t?q.jsx("div",{className:"rf-w-full rf-min-w-0 rf-overflow-hidden",children:q.jsx(lPt,{circuitJson:t,height:o,allowEditing:!1,clickToInteractEnabled:!1,focusOnHover:!1,disablePcbGroups:!0})}):q.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"})}),Qwt={importComponentDialog:101,importComponentDetailsDialog:102},SPo=({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,d=c?.unscoped_name?.split("/").pop()??c?.unscoped_name,h=c?.org_owner_tscircuit_handle??void 0,_=h?`https://tscircuit.com/${h}`:void 0,p=h&&d?`https://tscircuit.com/${h}/${d}`:void 0;return q.jsx(UG,{open:e,onOpenChange:n,children:q.jsxs(dN,{showOverlay:!1,style:{width:"calc(100vw - 2rem)",zIndex:Qwt.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:[q.jsx(_N,{className:"rf-pb-4 rf-border-b",children:q.jsx("div",{className:"rf-flex rf-items-start rf-justify-between rf-gap-4",children:q.jsxs("div",{className:"rf-flex-1 rf-min-w-0",children:[q.jsx(mN,{className:"rf-text-xl rf-font-semibold rf-truncate",children:d}),q.jsx(VG,{children:c?.description})]})})}),q.jsxs("div",{className:"rf-flex-1 rf-overflow-y-auto rf-py-4 rf-space-y-6",children:[h?q.jsxs("div",{children:[q.jsx("span",{className:"rf-text-xs rf-font-medium rf-text-gray-500 rf-uppercase rf-tracking-wide",children:"Created by"}),q.jsx("div",{className:"rf-mt-1 rf-text-sm rf-font-medium",children:_?q.jsx("a",{href:_,target:"_blank",rel:"noopener noreferrer",className:"rf-text-black hover:rf-underline",children:h}):h})]}):null,(u||l||g)&&q.jsx(q.Fragment,{children:q.jsxs("div",{children:[q.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-mb-4",children:"Preview"}),q.jsxs(Hie,{value:r,onValueChange:m=>A(m),children:[q.jsxs(YK,{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&&q.jsx(ox,{value:"pcb",children:"PCB"}),g&&q.jsx(ox,{value:"schematic",children:"Schematic"}),u&&q.jsx(ox,{value:"3d",children:"3D"})]}),q.jsxs("div",{className:"rf-mt-4",children:[q.jsx(DI,{value:"pcb",className:"rf-border rf-rounded-lg rf-overflow-hidden rf-bg-gray-50",children:l?q.jsx("img",{src:l,alt:`${d??"package"} PCB preview`,className:"rf-w-full rf-h-full rf-object-contain rf-bg-white rf-p-4"}):null}),q.jsx(DI,{value:"schematic",className:"rf-border rf-rounded-lg rf-overflow-hidden rf-bg-gray-50",children:g?q.jsx("img",{src:g,alt:`${d??"package"} schematic preview`,className:"rf-w-full rf-h-full rf-object-contain rf-bg-white rf-p-4"}):null}),q.jsx(DI,{value:"3d",className:"rf-border rf-rounded-lg rf-overflow-hidden rf-bg-gray-50",children:u?q.jsx("img",{src:u,alt:`${d??"package"} 3D preview`,className:"rf-w-full rf-h-full rf-object-contain rf-bg-white rf-p-4"}):null})]})]})]})}),i?.ai_description?q.jsxs("section",{children:[q.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-mb-3",children:"AI Description"}),q.jsx("div",{className:"rf-bg-gray-50 rf-border rf-border-gray-200 rf-rounded-lg rf-p-4",children:q.jsx("p",{className:"rf-text-sm rf-text-gray-700 rf-leading-relaxed",children:i.ai_description})})]}):null,i?.ai_usage_instructions?q.jsxs("section",{children:[q.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-mb-3",children:"Usage Instructions"}),q.jsx("div",{className:"rf-bg-gray-50 rf-border rf-border-gray-200 rf-rounded-lg rf-p-4",children:q.jsx("p",{className:"rf-text-sm rf-text-gray-700 rf-leading-relaxed rf-whitespace-pre-wrap",children:i.ai_usage_instructions})})]}):null,o?q.jsxs("div",{className:"rf-flex rf-justify-center rf-items-center rf-gap-2 rf-text-gray-500",children:[q.jsx(cQ,{className:"rf-h-4 rf-w-4 rf-animate-spin"}),q.jsx("span",{className:"rf-text-sm",children:"Loading package details..."})]}):null]}),q.jsxs(YG,{className:"rf-pt-4 rf-border-t rf-flex rf-flex-col sm:rf-flex-row rf-justify-between rf-gap-2",children:[q.jsx("div",{className:"rf-flex-1",children:p?q.jsxs(cc,{variant:"outline",size:"sm",className:"rf-gap-2 rf-w-full sm:rf-w-auto",onClick:()=>window.open(p,"_blank"),children:[q.jsx(j_o,{className:"rf-h-4 rf-w-4"}),"View on tscircuit.com"]}):null}),q.jsxs("div",{className:"rf-flex rf-flex-col sm:rf-flex-row rf-gap-2",children:[q.jsx(cc,{variant:"outline",onClick:()=>n(!1),className:"rf-order-2 sm:rf-order-1",children:"Close"}),q.jsx(cc,{onClick:a,disabled:s,className:"rf-bg-blue-600 hover:rf-bg-blue-700",children:s?q.jsx(cQ,{className:"rf-h-4 rf-w-4 rf-animate-spin"}):"Import Component"})]})]})]})})},bPo=()=>{const[t,e]=ee.useState(null),[n,o]=ee.useState(!1),i=ee.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=ee.useCallback(()=>{e(null),o(!1)},[]);return{details:t,isLoading:n,fetchDetails:i,reset:r}},DPo=(t,e)=>{const[n,o]=ee.useState({circuitJson:null,error:null,isLoading:!1});return ee.useEffect(()=>{if(!t||!Bwt(t)){o({circuitJson:null,error:null,isLoading:!1});return}let i=!1;return o({circuitJson:null,error:null,isLoading:!0}),pPo(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},MPo=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??[]},PPo=({sessionToken:t})=>{const[e,n]=ee.useState([]),[o,i]=ee.useState(!1),[r,A]=ee.useState(null),[s,a]=ee.useState(!1),c=ee.useCallback(async g=>{const u=g.trim();if(!u)return[];i(!0),A(null);try{const h=(await MPo(u,t)).map(_=>({source:"tscircuit.com",package:_}));return n(h),h}catch(d){return console.error("Error searching tscircuit packages",d),n([]),A(d instanceof Error?d.message:"Failed to search tscircuit packages"),[]}finally{i(!1),a(!0)}},[t]),l=ee.useCallback(()=>{n([]),i(!1),A(null),a(!1)},[]);return{results:e,isSearching:o,error:r,hasSearched:s,search:c,reset:l}},wPo=t=>{const e=t.trim();return/^C\d+/i.test(e)?e.replace(/^C/i,""):e},vPo=()=>{const[t,e]=ee.useState([]),[n,o]=ee.useState(!1),[i,r]=ee.useState(null),[A,s]=ee.useState(!1),a=ee.useCallback(async l=>{const g=wPo(l);if(!g)return[];o(!0),r(null);try{const d=(await E3o(g,10)).map(h=>({source:"jlcpcb",component:B3o(h)}));return e(d),d}catch(u){return console.error("Error searching JLCPCB components",u),e([]),r(u instanceof Error?u.message:"Failed to search JLCPCB components"),[]}finally{o(!1),s(!0)}},[]),c=ee.useCallback(()=>{e([]),o(!1),r(null),s(!1)},[]);return{results:t,isSearching:n,error:i,hasSearched:A,search:a,reset:c}},NPo=()=>{const[t,e]=ee.useState([]),[n,o]=ee.useState(!1),[i,r]=ee.useState(null),[A,s]=ee.useState(!1),a=ee.useCallback(async l=>{const g=l.trim();if(!g)return[];o(!0),r(null);try{const d=(await hPo(g,20)).map(h=>({source:"kicad",footprint:dPo(h)}));return e(d),d}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=ee.useCallback(()=>{e([]),o(!1),r(null),s(!1)},[]);return{results:t,isSearching:n,error:i,hasSearched:A,search:a,reset:c}},RPo=({onTscircuitPackageSelected:t,onJlcpcbComponentTsxLoaded:e,onKicadStringSelected:n})=>{const o=[];return t&&o.push("tscircuit.com"),e&&o.push("jlcpcb"),n&&o.push("kicad"),o},TPo=({isOpen:t,onClose:e,jlcpcbProxyRequestHeaders:n,onKicadStringSelected:o,onTscircuitPackageSelected:i,onJlcpcbComponentTsxLoaded:r,jlcpcbProxyApiBase:A,tscircuitSessionToken:s})=>{gPt();const a=ee.useMemo(()=>RPo({onKicadStringSelected:o,onTscircuitPackageSelected:i,onJlcpcbComponentTsxLoaded:r}),[o,i,r]),c=a.length>0,l=a.length===1,[g,u]=ee.useState(a[0]??"tscircuit.com"),[d,h]=ee.useState(""),[_,p]=ee.useState(null),{results:m,isSearching:I,error:C,hasSearched:f,search:E,reset:B}=PPo({sessionToken:s}),{results:x,isSearching:b,error:P,hasSearched:M,search:k,reset:N}=vPo(),{results:G,isSearching:H,error:U,hasSearched:J,search:W,reset:j}=NPo(),{details:oe,isLoading:ce,fetchDetails:ne,reset:re}=bPo(),[ae,se]=ee.useState(null),[ue,Be]=ee.useState(!1),[be,De]=ee.useState("pcb"),[me,Se]=ee.useState(null),[Ie,Ke]=ee.useState(!1),We=ee.useMemo(()=>({jlcpcb:{headers:n,apiBase:A}}),[A,n]),{circuitJson:tt,error:pe,isLoading:$e}=DPo(_,We),He=Bwt(_);ee.useEffect(()=>{Se(null)},[_]);const we=ee.useCallback(()=>{B(),N(),j(),p(null)},[N,j,B]);ee.useEffect(()=>{t||(we(),h(""),Be(!1),se(null),Se(null))},[t,we]),ee.useEffect(()=>{h(""),p(null),g==="tscircuit.com"?B():g==="jlcpcb"?N():g==="kicad"&&j()},[g,N,j,B]);const Ye=lt=>{p(lt),se(lt),De("pcb"),Be(!0),re();const Ct=lt.package.org_owner_tscircuit_handle,Dt=lt.package.unscoped_name;if(Ct&&Dt){const It=Dt.split("/").pop()??Dt;ne(Ct,It)}},Re=async()=>{d.trim()&&(p(null),g==="tscircuit.com"?await E(d):g==="jlcpcb"?await k(d):g==="kicad"&&await W(d))},xe=async lt=>{try{if(Se(null),Ke(!0),lt.source==="kicad"){if(!o)throw new Error("KiCad handler not provided");await o({result:lt,footprint:lt.footprint.qualifiedName})}else if(lt.source==="jlcpcb"){if(!r)throw new Error("JLCPCB handler not provided");const Ct=await x3o(lt.component.partNumber,{headers:n,apiBase:A});await r({result:lt,tsx:Ct})}else if(lt.source==="tscircuit.com"){if(!i)throw new Error("tscircuit package handler not provided");const Ct=lt.package.org_owner_tscircuit_handle,Dt=lt.package.unscoped_name;if(!Ct||!Dt)throw new Error("Missing package metadata");const It=Dt.split("/").pop()??Dt,Nt=`@tsci/${Ct}.${It}`;await i({result:lt,fullPackageName:Nt})}return!0}catch(Ct){return console.error("Failed to import component",Ct),Se(Ct instanceof Error?Ct.message:"Failed to import component"),!1}finally{Ke(!1)}};let Oe=[],Me=!1,ze=null,je=!1;g==="tscircuit.com"?(Oe=m,Me=I,ze=C,je=f):g==="jlcpcb"?(Oe=x,Me=b,ze=P,je=M):g==="kicad"&&(Oe=G,Me=H,ze=U,je=J);const st=async()=>{if(!_)return;await xe(_)&&(e(),we(),h(""))},ct=lt=>{lt||e()},ut=lt=>{Be(lt),lt||se(null)};return q.jsxs(UG,{open:t,onOpenChange:ct,children:[q.jsxs(dN,{style:{width:"calc(100vw - 2rem)",maxWidth:He?"min(1120px, calc(100vw - 2rem))":"min(672px, calc(100vw - 2rem))",zIndex:Qwt.importComponentDialog},className:"rf-rounded-sm rf-max-h-[90vh] rf-overflow-y-auto rf-overflow-x-hidden rf-flex rf-flex-col",children:[q.jsxs(_N,{children:[q.jsxs(mN,{className:"rf-text-lg sm:rf-text-xl",children:["Import ",l?xte[g].label:""," ","Component"]}),q.jsx(VG,{className:"rf-text-sm",children:c?"Search for components from available sources.":"Import options are disabled because no handlers were provided."})]}),c?q.jsxs(Hie,{value:g,onValueChange:lt=>u(lt),className:"rf-min-w-0 rf-w-full",children:[!l&&q.jsx(YK,{className:"rf-flex rf-w-full rf-gap-2",children:a.map(lt=>q.jsx(ox,{value:lt,className:"rf-flex-1 rf-text-xs sm:rf-text-sm",children:xte[lt].label},lt))}),q.jsxs("div",{className:"rf-min-w-0",style:He?{display:"grid",gridTemplateColumns:"minmax(0, 1fr) minmax(360px, 0.95fr)",gap:"1.5rem",alignItems:"start"}:void 0,children:[q.jsxs("div",{className:"rf-min-w-0",children:[q.jsx(IPo,{query:d,placeholder:xte[g].placeholder,isSearching:Me,onQueryChange:h,onSubmit:Re}),q.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:Me?q.jsxs("div",{className:"rf-p-8 rf-text-center rf-text-zinc-500",children:[q.jsx(cQ,{className:"rf-h-8 rf-w-8 rf-animate-spin rf-mx-auto rf-mb-2"}),q.jsx("p",{children:"Searching..."})]}):Oe.length>0?q.jsx(xPo,{results:Oe,selected:_,onSelect:p,onShowDetails:g==="tscircuit.com"?Ye:void 0}):q.jsx("div",{className:"rf-p-8 rf-text-center rf-text-zinc-500",children:ze?`Error: ${ze}`:je?xte[g].emptyMessage:"Enter a search term to find components"})})]}),He?q.jsx("div",{className:"rf-mt-4",children:q.jsx(QPo,{circuitJson:tt,error:pe,isLoading:$e,height:325})}):null]})]}):null,me?q.jsx("div",{className:"rf-text-sm rf-text-red-600 rf-mt-2",children:me}):null,q.jsxs(YG,{className:"rf-flex rf-flex-col sm:rf-flex-row rf-gap-2",children:[q.jsx(cc,{variant:"outline",onClick:e,className:"rf-order-2 sm:rf-order-1",children:"Cancel"}),q.jsx(cc,{onClick:st,disabled:!_||Ie,className:"rf-order-1 sm:rf-order-2",children:Ie?q.jsx(cQ,{className:"rf-h-4 rf-w-4 rf-animate-spin"}):"Import"})]})]}),q.jsx(SPo,{packageResult:ae,isOpen:ue,onOpenChange:ut,isLoading:ce,details:oe,previewTab:be,onPreviewTabChange:lt=>De(lt),isSubmitting:Ie,onImport:()=>{ae&&xe(ae).then(lt=>{lt&&(Be(!1),e(),we(),h(""))})}})]})},kPo=t=>{const e=t.match(/export const (\w+) =/);if(!e)throw new Error("Could not determine component name from TSX contents");return e[1]},Swt=t=>{const e=EQ(A=>A.pushEvent),n=EQ(A=>A.upsertFile),o=async({result:A,fullPackageName:s})=>{const c=A.package.unscoped_name??A.package.name;await ns.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 ns.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/${kPo(s)}.tsx`;await ns.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 q.jsx(TPo,{...t,onTscircuitPackageSelected:o,onKicadStringSelected:i,onJlcpcbComponentTsxLoaded:r})};Swt.displayName="ImportComponentDialogForCli";var pMe={exports:{}},bwt;function FPo(){return bwt||(bwt=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 k4=="function"&&k4;if(!g&&u)return u(l,!0);if(a)return a(l,!0);var d=new Error("Cannot find module '"+l+"'");throw d.code="MODULE_NOT_FOUND",d}var h=r[l]={exports:{}};i[l][0].call(h.exports,function(_){var p=i[l][1][_];return s(p||_)},h,h.exports,o,i,r,A)}return r[l].exports}for(var a=typeof k4=="function"&&k4,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,d,h,_,p,m=[],I=0,C=c.length,f=C,E=A.getTypeOf(c)!=="string";I<c.length;)f=C-I,u=E?(l=c[I++],g=I<C?c[I++]:0,I<C?c[I++]:0):(l=c.charCodeAt(I++),g=I<C?c.charCodeAt(I++):0,I<C?c.charCodeAt(I++):0),d=l>>2,h=(3&l)<<4|g>>4,_=1<f?(15&g)<<2|u>>6:64,p=2<f?63&u:64,m.push(a.charAt(d)+a.charAt(h)+a.charAt(_)+a.charAt(p));return m.join("")},r.decode=function(c){var l,g,u,d,h,_,p=0,m=0,I="data:";if(c.substr(0,I.length)===I)throw new Error("Invalid base64 input, it looks like a data url.");var C,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(C=s.uint8array?new Uint8Array(0|f):new Array(0|f);p<c.length;)l=a.indexOf(c.charAt(p++))<<2|(d=a.indexOf(c.charAt(p++)))>>4,g=(15&d)<<4|(h=a.indexOf(c.charAt(p++)))>>2,u=(3&h)<<6|(_=a.indexOf(c.charAt(p++))),C[m++]=l,h!==64&&(C[m++]=g),_!==64&&(C[m++]=u);return C}},{"./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,d,h,_){this.compressedSize=g,this.uncompressedSize=u,this.crc32=d,this.compression=h,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,d){return g.pipe(new a).pipe(new c("uncompressedSize")).pipe(u.compressWorker(d)).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,d){var h=s,_=d+u;l^=-1;for(var p=d;p<_;p++)l=l>>>8^h[255&(l^g[p])];return-1^l})(0|c,a,a.length,0):(function(l,g,u,d){var h=s,_=d+u;l^=-1;for(var p=d;p<_;p++)l=l>>>8^h[255&(l^g.charCodeAt(p))];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,d){c.call(this,"FlateWorker/"+u),this._pako=null,this._pakoAction=u,this._pakoOptions=d,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(d){u.push({data:d,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(h,_){var p,m="";for(p=0;p<_;p++)m+=String.fromCharCode(255&h),h>>>=8;return m}function s(h,_,p,m,I,C){var f,E,B=h.file,x=h.compression,b=C!==l.utf8encode,P=a.transformTo("string",C(B.name)),M=a.transformTo("string",l.utf8encode(B.name)),k=B.comment,N=a.transformTo("string",C(k)),G=a.transformTo("string",l.utf8encode(k)),H=M.length!==B.name.length,U=G.length!==k.length,J="",W="",j="",oe=B.dir,ce=B.date,ne={crc32:0,compressedSize:0,uncompressedSize:0};_&&!p||(ne.crc32=h.crc32,ne.compressedSize=h.compressedSize,ne.uncompressedSize=h.uncompressedSize);var re=0;_&&(re|=8),b||!H&&!U||(re|=2048);var ae=0,se=0;oe&&(ae|=16),I==="UNIX"?(se=798,ae|=(function(Be,be){var De=Be;return Be||(De=be?16893:33204),(65535&De)<<16})(B.unixPermissions,oe)):(se=20,ae|=(function(Be){return 63&(Be||0)})(B.dosPermissions)),f=ce.getUTCHours(),f<<=6,f|=ce.getUTCMinutes(),f<<=5,f|=ce.getUTCSeconds()/2,E=ce.getUTCFullYear()-1980,E<<=4,E|=ce.getUTCMonth()+1,E<<=5,E|=ce.getUTCDate(),H&&(W=A(1,1)+A(g(P),4)+M,J+="up"+A(W.length,2)+W),U&&(j=A(1,1)+A(g(N),4)+G,J+="uc"+A(j.length,2)+j);var ue="";return ue+=`
5786
+ `);const I=m.state[s];if(I==null)return;JSON.stringify(i.getState())!==JSON.stringify(I)&&d(I);return}i.dispatchFromDevtools&&typeof i.dispatch=="function"&&i.dispatch(m)});case"DISPATCH":switch(_.payload.type){case"RESET":return d(h),s===void 0?l?.init(i.getState()):l?.init(mte(a.name));case"COMMIT":if(s===void 0){l?.init(i.getState());return}return l?.init(mte(a.name));case"ROLLBACK":return FDe(_.state,m=>{if(s===void 0){d(m),l?.init(i.getState());return}d(m[s]),l?.init(mte(a.name))});case"JUMP_TO_STATE":case"JUMP_TO_ACTION":return FDe(_.state,m=>{if(s===void 0){d(m);return}JSON.stringify(i.getState())!==JSON.stringify(m[s])&&d(m[s])});case"IMPORT_STATE":{const{nextLiftedState:m}=_.payload,I=(p=m.computedStates.slice(-1)[0])==null?void 0:p.state;if(!I)return;d(s===void 0?I:I[s]),l?.send(null,m);return}case"PAUSE_RECORDING":return u=!u}return}}),h},FDe=(t,e)=>{let n;try{n=JSON.parse(t)}catch(o){console.error("[zustand devtools middleware] Could not parse the received json",o)}n!==void 0&&e(n)},LDe=sMt()(xPt(t=>({lastRunEvalVersion:void 0,setLastRunEvalVersion:e=>{t({lastRunEvalVersion:e})}}),{name:"runframe-runner-store"})),GMo=t=>{const[e,n]=ee.useState([]),[o,i]=ee.useState(null),[r,A]=ee.useState(""),[s,a]=uPt("eval-version-selection",null),c=LDe(d=>d.setLastRunEvalVersion),l=LDe(d=>d.lastRunEvalVersion);return ee.useEffect(()=>{t&&fetch("https://data.jsdelivr.com/v1/package/npm/@tscircuit/eval").then(d=>d.json()).then(d=>{if(Array.isArray(d?.versions)){let h=[...d.versions];d.tags?.latest&&(i(d.tags.latest),h=h.filter(_=>_!==d.tags.latest)),n(h)}}).catch(()=>{})},[t]),ee.useEffect(()=>{t&&(s?(window.TSCIRCUIT_LATEST_EVAL_VERSION=s,c(s)):o&&(window.TSCIRCUIT_LATEST_EVAL_VERSION=o,c(o)))},[t,s,o]),{versions:ee.useMemo(()=>e.filter(d=>d.includes(r)).slice(0,50),[e,r]),latestVersion:o,lastRunEvalVersion:l,search:r,setSearch:A,selectVersion:d=>{a(d),A("")}}},OMo=Bl("run-frame"),_5=window.TSCIRCUIT_FILESERVER_API_BASE_URL??"/api",KMo=[".tsx",".ts",".jsx",".js",".mjs",".json",".kicad_pcb",".kicad_sym",".kicad_sch",".kicad_prl",".kicad_pro"],HDe=t=>KMo.some(e=>t.endsWith(e)),OG=OMo.extend("store");async function QPt(t,e){return(await(await fetch(`${_5}/files/upsert`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({file_path:t,text_content:e})})).json()).file}async function GDe(t){return(await(await fetch(`${_5}/files/get?file_path=${encodeURIComponent(t)}`)).json()).file}async function UMo(t){const e=t?`${_5}/events/list?since=${encodeURIComponent(t)}`:`${_5}/events/list`;return(await(await fetch(e)).json()).event_list}async function YMo(){const t=await fetch(`${_5}/files/list`),{file_list:e}=await t.json(),n=new Map;for(const o of e){if(HDe(o.file_path)){const i=await GDe(o.file_path);n.set(o.file_path,i.text_content);continue}n.set(o.file_path,"__STATIC_ASSET__")}return n}const VMo=["manual-edits.json","manual_edits.json"],EQ=sMt()(xPt((t,e)=>({fsMap:new Map,lastEventTime:new Date().toISOString(),isPolling:!1,error:null,circuitJson:null,lastManualEditsChangeSentAt:0,recentEvents:[],simulateScenarioOrder:void 0,currentMainComponentPath:null,recentlySavedFiles:[],loadInitialFiles:async()=>{const n=await YMo();OG("loaded initial files",{fsMap:n}),t({fsMap:n})},upsertFile:async(n,o)=>{try{const i=await QPt(n,o);t(r=>({fsMap:new Map(r.fsMap).set(i.file_path,i.text_content)}))}catch(i){t({error:i})}},getFile:async n=>{try{const o=await GDe(n);t(i=>({fsMap:new Map(i.fsMap).set(o.file_path,o.text_content)}))}catch(o){t({error:o})}},setCircuitJson:n=>{n!==e().circuitJson&&t({circuitJson:n})},addRecentlySavedFile:n=>{t(o=>{if(VMo.includes(n)||!HDe(n))return o;const i=o.recentlySavedFiles.filter(r=>r!==n);return{recentlySavedFiles:[n,...i].slice(0,10)}})},startPolling:()=>{const n=async()=>{const o=e();if(o.isPolling){try{const i=await UMo(o.lastEventTime);if(i.length>0){const r=i[i.length-1].created_at;OG("received events",i.map(a=>a.event_type)),t(a=>({recentEvents:[...a.recentEvents,...i].slice(0,100),lastEventTime:r}));let A=0;const s=new Map(o.fsMap);for(const a of i)if(a.event_type==="FILE_UPDATED"){A++;const c=await GDe(a.file_path);if(a.file_path==="manual_edits.json"&&Date.now()-o.lastManualEditsChangeSentAt<1e3)continue;HDe(c.file_path)?s.set(c.file_path,c.text_content??""):s.set(c.file_path,"__STATIC_ASSET__"),e().addRecentlySavedFile(a.file_path)}else a.event_type==="FILE_DELETED"&&(A++,s.delete(a.file_path));A>0&&(OG("updating fsMap, fsUpdateCount:",A),t({fsMap:s}))}}catch(i){t({error:i})}setTimeout(n,1e3)}};t({isPolling:!0}),n()},stopPolling:()=>{t({isPolling:!1})},pushEvent:async n=>{await fetch(`${_5}/events/create`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)})},applyEditEventsAndUpdateManualEditsJson:async n=>{OG("applyEditEventsAndUpdateManualEditsJson",{editEvents:n});const o=e();if(!o.circuitJson)return;const i=o.fsMap.get("manual-edits.json"),r=i?JSON.parse(i):{},A=VFn({circuitJson:o.circuitJson,editEvents:n,manualEditsFile:r});OG("updatedManualEditsFileContent",A),t(s=>({lastManualEditsChangeSentAt:Date.now(),fsMap:new Map(s.fsMap).set("manual-edits.json",JSON.stringify(A))})),await QPt("manual-edits.json",JSON.stringify(A,null,2))},setSimulateScenarioOrder:n=>t({simulateScenarioOrder:n}),setCurrentMainComponentPath:n=>t({currentMainComponentPath:n})}),{name:"run-frame-store"})),zMo=({snippetNames:t,onSelect:e,onCancel:n,isOpen:o})=>{const[i,r]=ee.useState(""),[A,s]=ee.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 q.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:q.jsxs("div",{className:"rf-bg-white rf-rounded-lg rf-p-6 rf-w-96",children:[q.jsx("h2",{className:"rf-text-lg rf-font-semibold rf-mb-4",children:"Select Snippet"}),q.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}),q.jsxs("div",{className:"rf-h-60 rf-overflow-y-auto",children:[a.map(g=>q.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&&q.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,'"']})]}),q.jsxs("div",{className:"rf-mt-4 rf-flex rf-justify-end rf-gap-2",children:[q.jsx("button",{type:"button",className:"rf-px-4 rf-py-2 rf-text-gray-600 rf-hover:text-gray-800",onClick:n,children:"Cancel"}),q.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}`})]})]})})},JMo=t=>{const e=ee.useRef(null),n=EQ(o=>o.recentEvents);ee.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 pte="Dialog",[SPt,bPt]=qB(pte),[qMo,DB]=SPt(pte),ODe=t=>{const{__scopeDialog:e,children:n,open:o,defaultOpen:i,onOpenChange:r,modal:A=!0}=t,s=ee.useRef(null),a=ee.useRef(null),[c,l]=CM({prop:o,defaultProp:i??!1,onChange:r,caller:pte});return q.jsx(qMo,{scope:e,triggerRef:s,contentRef:a,contentId:jB(),titleId:jB(),descriptionId:jB(),open:c,onOpenChange:l,onOpenToggle:ee.useCallback(()=>l(g=>!g),[l]),modal:A,children:n})};ODe.displayName=pte;var DPt="DialogTrigger",MPt=ee.forwardRef((t,e)=>{const{__scopeDialog:n,...o}=t,i=DB(DPt,n),r=f0(e,i.triggerRef);return q.jsx(ml.button,{type:"button","aria-haspopup":"dialog","aria-expanded":i.open,"aria-controls":i.open?i.contentId:void 0,"data-state":VDe(i.open),...o,ref:r,onClick:Xr(t.onClick,i.onOpenToggle)})});MPt.displayName=DPt;var KDe="DialogPortal",[WMo,PPt]=SPt(KDe,{forceMount:void 0}),UDe=t=>{const{__scopeDialog:e,forceMount:n,children:o,container:i}=t,r=DB(KDe,e);return q.jsx(WMo,{scope:e,forceMount:n,children:ee.Children.map(o,A=>q.jsx(NE,{present:n||r.open,children:q.jsx(h4e,{asChild:!0,container:i,children:A})}))})};UDe.displayName=KDe;var Ite="DialogOverlay",Cte=ee.forwardRef((t,e)=>{const n=PPt(Ite,t.__scopeDialog),{forceMount:o=n.forceMount,...i}=t,r=DB(Ite,t.__scopeDialog);return r.modal?q.jsx(NE,{present:o||r.open,children:q.jsx(XMo,{...i,ref:e})}):null});Cte.displayName=Ite;var jMo=Fw("DialogOverlay.RemoveScroll"),XMo=ee.forwardRef((t,e)=>{const{__scopeDialog:n,...o}=t,i=DB(Ite,n),r=pmo(),A=f0(e,r);return q.jsx(C4e,{as:jMo,allowPinchZoom:!0,shards:[i.contentRef],children:q.jsx(ml.div,{"data-state":VDe(i.open),...o,ref:A,style:{pointerEvents:"auto",...o.style}})})}),hN="DialogContent",fte=ee.forwardRef((t,e)=>{const n=PPt(hN,t.__scopeDialog),{forceMount:o=n.forceMount,...i}=t,r=DB(hN,t.__scopeDialog);return q.jsx(NE,{present:o||r.open,children:r.modal?q.jsx($Mo,{...i,ref:e}):q.jsx(ZMo,{...i,ref:e})})});fte.displayName=hN;var $Mo=ee.forwardRef((t,e)=>{const n=DB(hN,t.__scopeDialog),o=ee.useRef(null),i=f0(e,n.contentRef,o);return ee.useEffect(()=>{const r=o.current;if(r)return Kxt(r)},[]),q.jsx(wPt,{...t,ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,onCloseAutoFocus:Xr(t.onCloseAutoFocus,r=>{r.preventDefault(),n.triggerRef.current?.focus()}),onPointerDownOutside:Xr(t.onPointerDownOutside,r=>{const A=r.detail.originalEvent,s=A.button===0&&A.ctrlKey===!0;(A.button===2||s)&&r.preventDefault()}),onFocusOutside:Xr(t.onFocusOutside,r=>r.preventDefault())})}),ZMo=ee.forwardRef((t,e)=>{const n=DB(hN,t.__scopeDialog),o=ee.useRef(!1),i=ee.useRef(!1);return q.jsx(wPt,{...t,ref:e,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:r=>{t.onCloseAutoFocus?.(r),r.defaultPrevented||(o.current||n.triggerRef.current?.focus(),r.preventDefault()),o.current=!1,i.current=!1},onInteractOutside:r=>{t.onInteractOutside?.(r),r.defaultPrevented||(o.current=!0,r.detail.originalEvent.type==="pointerdown"&&(i.current=!0));const A=r.target;n.triggerRef.current?.contains(A)&&r.preventDefault(),r.detail.originalEvent.type==="focusin"&&i.current&&r.preventDefault()}})}),wPt=ee.forwardRef((t,e)=>{const{__scopeDialog:n,trapFocus:o,onOpenAutoFocus:i,onCloseAutoFocus:r,...A}=t,s=DB(hN,n);return ext(),q.jsx(q.Fragment,{children:q.jsx(X5e,{asChild:!0,loop:!0,trapped:o,onMountAutoFocus:i,onUnmountAutoFocus:r,children:q.jsx(kZ,{role:"dialog",id:s.contentId,"aria-describedby":s.descriptionId,"aria-labelledby":s.titleId,"data-state":VDe(s.open),...A,ref:e,deferPointerDownOutside:!0,onDismiss:()=>s.onOpenChange(!1)})})})}),vPt="DialogTitle",yte=ee.forwardRef((t,e)=>{const{__scopeDialog:n,...o}=t,i=DB(vPt,n);return q.jsx(ml.h2,{id:i.titleId,...o,ref:e})});yte.displayName=vPt;var NPt="DialogDescription",Ete=ee.forwardRef((t,e)=>{const{__scopeDialog:n,...o}=t,i=DB(NPt,n);return q.jsx(ml.p,{id:i.descriptionId,...o,ref:e})});Ete.displayName=NPt;var RPt="DialogClose",YDe=ee.forwardRef((t,e)=>{const{__scopeDialog:n,...o}=t,i=DB(RPt,n);return q.jsx(ml.button,{type:"button",...o,ref:e,onClick:Xr(t.onClick,()=>i.onOpenChange(!1))})});YDe.displayName=RPt;function VDe(t){return t?"open":"closed"}var TPt="AlertDialog",[e3o]=qB(TPt,[bPt]),m5=bPt(),kPt=t=>{const{__scopeAlertDialog:e,...n}=t,o=m5(e);return q.jsx(ODe,{...o,...n,modal:!0})};kPt.displayName=TPt;var t3o="AlertDialogTrigger",n3o=ee.forwardRef((t,e)=>{const{__scopeAlertDialog:n,...o}=t,i=m5(n);return q.jsx(MPt,{...i,...o,ref:e})});n3o.displayName=t3o;var o3o="AlertDialogPortal",FPt=t=>{const{__scopeAlertDialog:e,...n}=t,o=m5(e);return q.jsx(UDe,{...o,...n})};FPt.displayName=o3o;var i3o="AlertDialogOverlay",LPt=ee.forwardRef((t,e)=>{const{__scopeAlertDialog:n,...o}=t,i=m5(n);return q.jsx(Cte,{...i,...o,ref:e})});LPt.displayName=i3o;var HPt="AlertDialogContent",[r3o,A3o]=e3o(HPt),GPt=ee.forwardRef((t,e)=>{const{__scopeAlertDialog:n,children:o,...i}=t,r=m5(n),A=ee.useRef(null),s=f0(e,A),a=ee.useRef(null);return q.jsx(r3o,{scope:n,cancelRef:a,children:q.jsx(fte,{role:"alertdialog",...r,...i,ref:s,onOpenAutoFocus:Xr(i.onOpenAutoFocus,c=>{c.preventDefault(),a.current?.focus({preventScroll:!0})}),onPointerDownOutside:c=>c.preventDefault(),onInteractOutside:c=>c.preventDefault(),children:o})})});GPt.displayName=HPt;var s3o="AlertDialogTitle",OPt=ee.forwardRef((t,e)=>{const{__scopeAlertDialog:n,...o}=t,i=m5(n);return q.jsx(yte,{...i,...o,ref:e})});OPt.displayName=s3o;var a3o="AlertDialogDescription",KPt=ee.forwardRef((t,e)=>{const{__scopeAlertDialog:n,...o}=t,i=m5(n);return q.jsx(Ete,{...i,...o,ref:e})});KPt.displayName=a3o;var c3o="AlertDialogAction",UPt=ee.forwardRef((t,e)=>{const{__scopeAlertDialog:n,...o}=t,i=m5(n);return q.jsx(YDe,{...i,...o,ref:e})});UPt.displayName=c3o;var YPt="AlertDialogCancel",VPt=ee.forwardRef((t,e)=>{const{__scopeAlertDialog:n,...o}=t,{cancelRef:i}=A3o(YPt,n),r=m5(n),A=f0(e,i);return q.jsx(YDe,{...r,...o,ref:A})});VPt.displayName=YPt;var l3o=kPt,g3o=FPt,zPt=LPt,JPt=GPt,qPt=UPt,WPt=VPt,jPt=OPt,XPt=KPt;const $Pt=l3o,u3o=g3o,ZPt=ee.forwardRef(({className:t,...e},n)=>q.jsx(zPt,{className:nA("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}));ZPt.displayName=zPt.displayName;const zDe=ee.forwardRef(({className:t,...e},n)=>q.jsxs(u3o,{children:[q.jsx(ZPt,{}),q.jsx(JPt,{ref:n,className:nA("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})]}));zDe.displayName=JPt.displayName;const JDe=({className:t,...e})=>q.jsx("div",{className:nA("rf-flex rf-flex-col rf-space-y-2 rf-text-center sm:rf-text-left",t),...e});JDe.displayName="AlertDialogHeader";const qDe=({className:t,...e})=>q.jsx("div",{className:nA("rf-flex rf-flex-col-reverse sm:rf-flex-row sm:rf-justify-end sm:rf-space-x-2",t),...e});qDe.displayName="AlertDialogFooter";const WDe=ee.forwardRef(({className:t,...e},n)=>q.jsx(jPt,{ref:n,className:nA("rf-text-lg rf-font-semibold",t),...e}));WDe.displayName=jPt.displayName;const jDe=ee.forwardRef(({className:t,...e},n)=>q.jsx(XPt,{ref:n,className:nA("rf-text-sm rf-text-zinc-500 dark:rf-text-zinc-400",t),...e}));jDe.displayName=XPt.displayName;const h3o=ee.forwardRef(({className:t,...e},n)=>q.jsx(qPt,{ref:n,className:nA(F7(),t),...e}));h3o.displayName=qPt.displayName;const XDe=ee.forwardRef(({className:t,...e},n)=>q.jsx(WPt,{ref:n,className:nA(F7({variant:"outline"}),"rf-mt-2 sm:rf-mt-0",t),...e}));XDe.displayName=WPt.displayName;function d3o(t){const e=ee.useRef({value:t,previous:t});return ee.useMemo(()=>(e.current.value!==t&&(e.current.previous=e.current.value,e.current.value=t),e.current.previous),[t])}var Bte="Checkbox",[_3o]=qB(Bte),[m3o,$De]=_3o(Bte);function p3o(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,d]=CM({prop:n,defaultProp:i??!1,onChange:a,caller:Bte}),[h,_]=ee.useState(null),[p,m]=ee.useState(null),I=ee.useRef(!1),C=h?!!A||!!h.closest("form"):!0,f={checked:u,disabled:r,setChecked:d,control:h,setControl:_,name:s,form:A,value:l,hasConsumerStoppedPropagationRef:I,required:c,defaultChecked:RD(i)?!1:i,isFormControl:C,bubbleInput:p,setBubbleInput:m};return q.jsx(m3o,{scope:e,...f,children:I3o(g)?g(f):o})}var ewt="CheckboxTrigger",twt=ee.forwardRef(({__scopeCheckbox:t,onKeyDown:e,onClick:n,...o},i)=>{const{control:r,value:A,disabled:s,checked:a,required:c,setControl:l,setChecked:g,hasConsumerStoppedPropagationRef:u,isFormControl:d,bubbleInput:h}=$De(ewt,t),_=f0(i,l),p=ee.useRef(a);return ee.useEffect(()=>{const m=r?.form;if(m){const I=()=>g(p.current);return m.addEventListener("reset",I),()=>m.removeEventListener("reset",I)}},[r,g]),q.jsx(ml.button,{type:"button",role:"checkbox","aria-checked":RD(a)?"mixed":a,"aria-required":c,"data-state":Awt(a),"data-disabled":s?"":void 0,disabled:s,value:A,...o,ref:_,onKeyDown:Xr(e,m=>{m.key==="Enter"&&m.preventDefault()}),onClick:Xr(n,m=>{g(I=>RD(I)?!0:!I),h&&d&&(u.current=m.isPropagationStopped(),u.current||m.stopPropagation())})})});twt.displayName=ewt;var ZDe=ee.forwardRef((t,e)=>{const{__scopeCheckbox:n,name:o,checked:i,defaultChecked:r,required:A,disabled:s,value:a,onCheckedChange:c,form:l,...g}=t;return q.jsx(p3o,{__scopeCheckbox:n,checked:i,defaultChecked:r,disabled:s,required:A,onCheckedChange:c,name:o,form:l,value:a,internal_do_not_use_render:({isFormControl:u})=>q.jsxs(q.Fragment,{children:[q.jsx(twt,{...g,ref:e,__scopeCheckbox:n}),u&&q.jsx(rwt,{__scopeCheckbox:n})]})})});ZDe.displayName=Bte;var nwt="CheckboxIndicator",owt=ee.forwardRef((t,e)=>{const{__scopeCheckbox:n,forceMount:o,...i}=t,r=$De(nwt,n);return q.jsx(NE,{present:o||RD(r.checked)||r.checked===!0,children:q.jsx(ml.span,{"data-state":Awt(r.checked),"data-disabled":r.disabled?"":void 0,...i,ref:e,style:{pointerEvents:"none",...t.style}})})});owt.displayName=nwt;var iwt="CheckboxBubbleInput",rwt=ee.forwardRef(({__scopeCheckbox:t,...e},n)=>{const{control:o,hasConsumerStoppedPropagationRef:i,checked:r,defaultChecked:A,required:s,disabled:a,name:c,value:l,form:g,bubbleInput:u,setBubbleInput:d}=$De(iwt,t),h=f0(n,d),_=d3o(r),p=Mxt(o);ee.useEffect(()=>{const I=u;if(!I)return;const C=window.HTMLInputElement.prototype,E=Object.getOwnPropertyDescriptor(C,"checked").set,B=!i.current;if(_!==r&&E){const x=new Event("click",{bubbles:B});I.indeterminate=RD(r),E.call(I,RD(r)?!1:r),I.dispatchEvent(x)}},[u,_,r,i]);const m=ee.useRef(RD(r)?!1:r);return q.jsx(ml.input,{type:"checkbox","aria-hidden":!0,defaultChecked:A??m.current,required:s,disabled:a,name:c,value:l,form:g,...e,tabIndex:-1,ref:h,style:{...e.style,...p,position:"absolute",pointerEvents:"none",opacity:0,margin:0,transform:"translateX(-100%)"}})});rwt.displayName=iwt;function I3o(t){return typeof t=="function"}function RD(t){return t==="indeterminate"}function Awt(t){return RD(t)?"indeterminate":t?"checked":"unchecked"}const KG=ee.forwardRef(({className:t,...e},n)=>q.jsx(ZDe,{ref:n,className:nA("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:q.jsx(owt,{className:nA("rf-flex rf-items-center rf-justify-center rf-text-current"),children:q.jsx(V5e,{className:"rf-h-4 rf-w-4"})})}));KG.displayName=ZDe.displayName;const UG=ODe,C3o=UDe,swt=ee.forwardRef(({className:t,...e},n)=>q.jsx(Cte,{className:nA("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}));swt.displayName=Cte.displayName;const dN=ee.forwardRef(({className:t,children:e,showOverlay:n=!0,...o},i)=>q.jsxs(C3o,{children:[q.jsx(swt,{className:nA(n?"":"rf-hidden")}),q.jsx(fte,{ref:i,className:nA("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})]}));dN.displayName=fte.displayName;const _N=({className:t,...e})=>q.jsx("div",{className:nA("rf-flex rf-flex-col rf-space-y-2 rf-text-center sm:rf-text-left",t),...e});_N.displayName="DialogHeader";const YG=({className:t,...e})=>q.jsx("div",{className:nA("rf-flex rf-flex-col-reverse sm:rf-flex-row sm:rf-justify-end sm:rf-space-x-2",t),...e});YG.displayName="DialogFooter";const mN=ee.forwardRef(({className:t,...e},n)=>q.jsx(yte,{ref:n,className:nA("rf-text-lg rf-font-semibold",t),...e}));mN.displayName=yte.displayName;const VG=ee.forwardRef(({className:t,...e},n)=>q.jsx(Ete,{ref:n,className:nA("rf-text-sm rf-text-zinc-500 dark:rf-text-zinc-400",t),...e}));VG.displayName=Ete.displayName;const xte={"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"}},f3o="https://cdn.jsdelivr.net/npm/easyeda@latest/dist/browser/index.js";let eMe=null;const tMe=async()=>(eMe||(eMe=import(f3o)),eMe),y3o=t=>(e,n)=>{const o=new Headers(n?.headers),i={};return o.forEach((r,A)=>{i[A]=r}),fetch(`${t?.apiBase??_5}/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}})},E3o=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??[]},B3o=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}),awt=async(t,e)=>{const{fetchEasyEDAComponent:n}=await tMe();return n(t,{fetch:y3o(e),includeModelMetadata:e?.includeModelMetadata})},x3o=async(t,e)=>{const{convertRawEasyToTsx:n}=await tMe(),o=await awt(t,e);return n({rawEasy:o})},Q3o=async(t,e)=>{const{EasyEdaJsonSchema:n,convertEasyEdaJsonToCircuitJson:o}=await tMe(),i=await awt(t,{...e,includeModelMetadata:!1}),r=n.parse(i);return o(r,{shouldRecenter:!0,showDesignator:!0,useModelCdn:!1})};function TD(t){return Array.isArray?Array.isArray(t):lwt(t)==="[object Array]"}function S3o(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 nMe(t){return t==null?"":S3o(t)}function jI(t){return typeof t=="string"}function Qte(t){return typeof t=="number"}function b3o(t){return t===!0||t===!1||D3o(t)&&lwt(t)=="[object Boolean]"}function cwt(t){return typeof t=="object"}function D3o(t){return cwt(t)&&t!==null}function Yy(t){return t!=null}function Ste(t){return!t.trim().length}function lwt(t){return t==null?t===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(t)}const M3o="Incorrect 'index' type",oMe="Invalid doc index: must be a non-negative integer within the bounds of the docs array",P3o=t=>`Invalid value for key ${t}`,w3o=t=>`Pattern length exceeds max of ${t}.`,v3o=t=>`Missing ${t} property in key`,N3o=t=>`Property 'weight' in key '${t}' must be a positive integer`,R3o="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.",gwt=Object.prototype.hasOwnProperty;var T3o=class{constructor(t){this._keys=[],this._keyMap={};let e=0;t.forEach(n=>{const o=uwt(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 uwt(t){let e=null,n=null,o=null,i=1,r=null;if(jI(t)||TD(t))o=t,e=hwt(t),n=bte(t);else{if(!gwt.call(t,"name"))throw new Error(v3o("name"));const A=t.name;if(o=A,gwt.call(t,"weight")&&t.weight!==void 0&&(i=t.weight,i<=0))throw new Error(N3o(bte(A)));e=hwt(A),n=bte(A),r=t.getFn??null}return{path:e,id:n,weight:i,src:o,getFn:r}}function hwt(t){return TD(t)?t:t.split(".")}function bte(t){return TD(t)?t.join("."):t}function k3o(t,e){const n=[];let o=!1;const i=(r,A,s,a)=>{if(Yy(r))if(!A[s])n.push(a!==void 0?{v:r,i:a}:r);else{const c=r[A[s]];if(!Yy(c))return;if(s===A.length-1&&(jI(c)||Qte(c)||b3o(c)||typeof c=="bigint"))n.push(a!==void 0?{v:nMe(c),i:a}:nMe(c));else if(TD(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,jI(e)?e.split("."):e,0),o?n:n[0]}const bA=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:k3o,ignoreLocation:!1,ignoreFieldNorm:!1,fieldNormWeight:1}});function F3o(t){return t>=9&&t<=13||t===32||t===160}function L3o(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++)F3o(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 iMe=class{constructor({getFn:t=bA.getFn,fieldNormWeight:e=bA.fieldNormWeight}={}){this.norm=L3o(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(jI(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(oMe);if(jI(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(oMe);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!Yy(t)||Ste(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(Yy(A)){if(TD(A)){const s=[];for(let a=0,c=A.length;a<c;a+=1){const l=A[a];if(Yy(l)){if(jI(l)){if(!Ste(l)){const g={v:l,i:a,n:this.norm.get(l)};s.push(g)}}else if(Yy(l.v)){const g=jI(l.v)?l.v:nMe(l.v);if(!Ste(g)){const u={v:g,i:l.i,n:this.norm.get(g)};s.push(u)}}}}n.$[o]=s}else if(jI(A)&&!Ste(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 dwt(t,e,{getFn:n=bA.getFn,fieldNormWeight:o=bA.fieldNormWeight}={}){const i=new iMe({getFn:n,fieldNormWeight:o});return i.setKeys(t.map(uwt)),i.setSources(e),i.create(),i}function H3o(t,{getFn:e=bA.getFn,fieldNormWeight:n=bA.fieldNormWeight}={}){const{keys:o,records:i}=t,r=new iMe({getFn:e,fieldNormWeight:n});return r.setKeys(o),r.setIndexRecords(i),r}function G3o(t=[],e=bA.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 O3o(t,e,n,{location:o=bA.location,distance:i=bA.distance,threshold:r=bA.threshold,findAllMatches:A=bA.findAllMatches,minMatchCharLength:s=bA.minMatchCharLength,includeMatches:a=bA.includeMatches,ignoreLocation:c=bA.ignoreLocation}={}){if(e.length>32)throw new Error(w3o(32));const l=e.length,g=t.length,u=Math.max(0,Math.min(o,g));let d=r,h=u;const _=(P,M)=>{const k=P/l;if(c)return k;const N=Math.abs(u-M);return i?k+N/i:N?1:k},p=s>1||a,m=p?Array(g):[];let I;for(;(I=t.indexOf(e,h))>-1;){const P=_(0,I);if(d=Math.min(P,d),h=I+l,p){let M=0;for(;M<l;)m[I+M]=1,M+=1}}h=-1;let C=[],f=1,E=0,B=l+g;const x=1<<l-1;for(let P=0;P<l;P+=1){let M=0,k=B;for(;M<k;)_(P,u+k)<=d?M=k:B=k,k=Math.floor((B-M)/2+M);B=k;let N=Math.max(1,u-k+1);const G=A?g:Math.min(u+k,g)+l,H=Array(G+2);H[G+1]=(1<<P)-1;for(let U=G;U>=N;U-=1){const J=U-1,W=n[t[J]];if(H[U]=(H[U+1]<<1|1)&W,P&&(H[U]|=(C[U+1]|C[U])<<1|1|C[U+1]),H[U]&x&&(f=_(P,J),f<=d)){if(d=f,h=J,E=P,h<=u)break;N=Math.max(1,2*u-h)}}if(_(P+1,u)>d)break;C=H}if(p&&h>=0){const P=Math.min(g-1,h+l-1+E);for(let M=h;M<=P;M+=1)n[t[M]]&&(m[M]=1)}const b={isMatch:h>=0,score:Math.max(.001,f)};if(p){const P=G3o(m,s);P.length?a&&(b.indices=P):b.isMatch=!1}return b}function K3o(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 rMe(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 _wt={ł:"l",Ł:"L",đ:"d",Đ:"D",ø:"o",Ø:"O",ħ:"h",Ħ:"H",ŧ:"t",Ŧ:"T",ı:"i",ß:"ss"},U3o=new RegExp("["+Object.keys(_wt).join("")+"]","g"),zG=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(U3o,e=>_wt[e]):t=>t;var AMe=class{constructor(t,{location:e=bA.location,threshold:n=bA.threshold,distance:o=bA.distance,includeMatches:i=bA.includeMatches,findAllMatches:r=bA.findAllMatches,minMatchCharLength:A=bA.minMatchCharLength,isCaseSensitive:s=bA.isCaseSensitive,ignoreDiacritics:a=bA.ignoreDiacritics,ignoreLocation:c=bA.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?zG(t):t,this.pattern=t,this.chunks=[],!this.pattern.length)return;const l=(u,d)=>{this.chunks.push({pattern:u,alphabet:K3o(u),startIndex:d})},g=this.pattern.length;if(g>32){let u=0;const d=g%32,h=g-d;for(;u<h;)l(this.pattern.substr(u,32),u),u+=32;if(d){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?zG(t):t,this.pattern===t){if(t.length<this.options.minMatchCharLength)return{isMatch:!1,score:1};const h={isMatch:!0,score:0};return o&&(h.indices=[[0,t.length-1]]),h}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:h,alphabet:_,startIndex:p})=>{const{isMatch:m,score:I,indices:C}=O3o(t,h,_,{location:i+p,distance:r,threshold:A,findAllMatches:s,minMatchCharLength:a,includeMatches:o,ignoreLocation:c});m&&(u=!0),g+=I,m&&C&&l.push(...C)});const d={isMatch:u,score:u?g/this.chunks.length:1};return u&&o&&(d.indices=rMe(l)),d}};const Y3o=new Set(["fuzzy","include"]);function V3o(t){return t.startsWith("inverse")}const sMe=[{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 AMe(t,{location:e.location??bA.location,threshold:e.threshold??bA.threshold,distance:e.distance??bA.distance,includeMatches:e.includeMatches??bA.includeMatches,findAllMatches:e.findAllMatches??bA.findAllMatches,minMatchCharLength:e.minMatchCharLength??bA.minMatchCharLength,isCaseSensitive:e.isCaseSensitive??bA.isCaseSensitive,ignoreDiacritics:e.ignoreDiacritics??bA.ignoreDiacritics,ignoreLocation:e.ignoreLocation??bA.ignoreLocation});return{type:"fuzzy",search(o){return n.searchIn(o)}}}}],mwt=sMe.length,z3o="\0",J3o="|";function q3o(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 pwt(t,e){const n=t.match(e);return n?n[1]:null}function W3o(t,e={}){return t.replace(/\\\|/g,z3o).split(J3o).map(n=>{const o=q3o(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<mwt;){const l=sMe[c],g=pwt(s,l.multiRegex);g&&(i.push(l.create(g,e)),a=!0)}if(!a)for(c=-1;++c<mwt;){const l=sMe[c],g=pwt(s,l.singleRegex);if(g){i.push(l.create(g,e));break}}}return i})}var j3o=class{constructor(t,{isCaseSensitive:e=bA.isCaseSensitive,ignoreDiacritics:n=bA.ignoreDiacritics,includeMatches:o=bA.includeMatches,minMatchCharLength:i=bA.minMatchCharLength,ignoreLocation:r=bA.ignoreLocation,findAllMatches:A=bA.findAllMatches,location:s=bA.location,threshold:a=bA.threshold,distance:c=bA.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?zG(t):t,this.pattern=t,this.query=W3o(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?zG(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,d=g.length;u<d;u+=1){const h=g[u],{isMatch:_,indices:p,score:m}=h.search(t);if(_)r+=1,s+=m,V3o(h.type)&&(a=!0),n&&(Y3o.has(h.type)?A.push(...p):A.push(p));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=rMe(A)),u}}return{isMatch:!1,score:1}}};const aMe=[];function cMe(...t){aMe.push(...t)}function Dte(t,e){for(let n=0,o=aMe.length;n<o;n+=1){const i=aMe[n];if(i.condition(t,e))return new i(t,e)}return new AMe(t,e)}const Mte={AND:"$and",OR:"$or"},lMe={PATH:"$path",PATTERN:"$val"},gMe=t=>!!(t[Mte.AND]||t[Mte.OR]),X3o=t=>!!t[lMe.PATH],$3o=t=>!TD(t)&&cwt(t)&&!gMe(t),Iwt=t=>({[Mte.AND]:Object.keys(t).map(e=>({[e]:t[e]}))});function Cwt(t,e,{auto:n=!0}={}){const o=i=>{if(jI(i)){const a={keyId:null,pattern:i};return n&&(a.searcher=Dte(i,e)),a}const r=Object.keys(i),A=X3o(i);if(!A&&r.length>1&&!gMe(i))return o(Iwt(i));if($3o(i)){const a=A?i[lMe.PATH]:r[0],c=A?i[lMe.PATTERN]:i[a];if(!jI(c))throw new Error(P3o(a));const l={keyId:bte(a),pattern:c};return n&&(l.searcher=Dte(c,e)),l}const s={children:[],operator:r[0]};return r.forEach(a=>{const c=i[a];TD(c)&&c.forEach(l=>{s.children.push(o(l))})}),s};return gMe(t)||(t=Iwt(t)),o(t)}function uMe(t,{ignoreFieldNorm:e=bA.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 Z3o(t,{ignoreFieldNorm:e=bA.ignoreFieldNorm}){t.forEach(n=>{n.score=uMe(n.matches,{ignoreFieldNorm:e})})}var ePo=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 tPo(t){const e=[];return t.matches.forEach(n=>{if(!Yy(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 nPo(t,e,{includeMatches:n=bA.includeMatches,includeScore:o=bA.includeScore}={}){return t.map(i=>{const{idx:r}=i,A={item:e[r],refIndex:r};return n&&(A.matches=tPo(i)),o&&(A.score=i.score),A})}const oPo=/[\p{L}\p{M}\p{N}_]+/gu,fwt=new WeakSet;function iPo(t){fwt.has(t)||(fwt.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 rPo(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||iPo(t),e=>e.match(t)||[]):e=>e.match(oPo)||[]}function hMe({isCaseSensitive:t=!1,ignoreDiacritics:e=!1,tokenize:n}={}){const o=rPo(n);return{tokenize(i){return t||(i=i.toLowerCase()),e&&(i=zG(i)),o(i)}}}var APo=class{static condition(t,e){return e.useTokenSearch}constructor(t,e){this.options=e,this.analyzer=hMe({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 AMe(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=rMe(e)),this.combineAll&&(this.useMask?a.matchedMask=r:a.matchedTerms=A,a.termCount=this.numTerms),a}};function dMe(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 ywt(t,e,n,o){const{i,v:r,$:A}=e;if(r!==void 0){dMe(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)dMe(t,c.v,i,o);else dMe(t,a.v,i,o)}}function sPo(t,e,n){const o={fieldCount:0,df:new Map,docFieldCount:new Map,docTermFieldHits:new Map};for(const i of t)ywt(o,i,e,n);return o}function aPo(t,e,n,o){ywt(t,e,n,o)}function cPo(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 Ewt(t,e){if(e.length===0)return;const n=Array.from(new Set(e)).sort((s,a)=>s-a);for(const s of n)cPo(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 kD=class{constructor(t,e,n){this.options={...bA,...e},this.options.useExtendedSearch,this.options.useTokenSearch,this._keyStore=new T3o(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=Dte(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 iMe))throw new Error(M3o);if(this._myIndex=e||dwt(this.options.keys,this._docs,{getFn:this.options.getFn,fieldNormWeight:this.options.fieldNormWeight}),this.options.useTokenSearch){const n=hMe({isCaseSensitive:this.options.isCaseSensitive,ignoreDiacritics:this.options.ignoreDiacritics,tokenize:this.options.tokenize});this._invertedIndex=sPo(this._myIndex.records,this._myIndex.keys.length,n)}this._invalidateSearcherCache()}add(t){if(!Yy(t))return;this._docs.push(t);const e=this._myIndex.add(t,this._docs.length-1);if(this._invertedIndex&&e){const n=hMe({isCaseSensitive:this.options.isCaseSensitive,ignoreDiacritics:this.options.ignoreDiacritics,tokenize:this.options.tokenize});aPo(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&&Ewt(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(oMe);this._invertedIndex&&Ewt(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(jI(t)&&!t.trim()){let u=this._docs.map((d,h)=>({item:d,refIndex:h}));return Qte(n)&&n>-1&&(u=u.slice(0,n)),u}const a=r&&Qte(n)&&n>0&&jI(t),c=A,l=(u,d)=>c(u,d)||u.idx-d.idx;let g;if(a){const u=new ePo(n,l);jI(this._docs[0])?this._searchStringList(t,{heap:u,ignoreFieldNorm:s}):this._searchObjectList(t,{heap:u,ignoreFieldNorm:s}),g=u.extractSorted()}else g=jI(t)?jI(this._docs[0])?this._searchStringList(t):this._searchObjectList(t):this._searchLogical(t),Z3o(g,{ignoreFieldNorm:s}),r&&g.sort(jI(t)?l:c),Qte(n)&&n>-1&&(g=g.slice(0,n));return nPo(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(!Yy(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 d={item:s,idx:a,matches:u};e?(d.score=uMe(d.matches,{ignoreFieldNorm:n}),e.insert(d)):A.push(d)}}}),A}_searchLogical(t){const e=Cwt(t,this.options),n=this._normalizedKeys(),o=(s,a,c)=>{if(!("children"in s)){const{keyId:d,searcher:h}=s;let _;return d===null?(_=[],n.forEach((p,m)=>{_.push(...this._findMatches({key:p,value:a[m],searcher:h}))})):_=this._findMatches({key:this._keyStore.get(d),value:this._myIndex.getValueForItemAtKeyId(a,d),searcher:h}),_&&_.length?[{idx:c,item:a,matches:_}]:[]}const{children:l,operator:g}=s,u=[];for(let d=0,h=l.length;d<h;d+=1){const _=l[d],p=o(_,a,c);if(p.length)u.push(...p);else if(g===Mte.AND)return[]}return u},i=this._myIndex.records,r=new Map,A=[];return i.forEach(({$:s,i:a})=>{if(Yy(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(!Yy(a))return;const l=[];let g=!1,u=!1;if(A.forEach((d,h)=>{const _=this._findMatches({key:d,value:a[h],searcher:o});_.length?(l.push(..._),_[0].hasInverse&&(u=!0)):g=!0}),!(u&&g)&&l.length&&(!i||this._coversAllTokens(l))){const d={idx:c,item:a,matches:l};e?(d.score=uMe(d.matches,{ignoreFieldNorm:n}),e.insert(d)):s.push(d)}}),s}_findMatches({key:t,value:e,searcher:n}){if(!Yy(e))return[];const o=[];if(TD(e))e.forEach(({v:i,i:r,n:A})=>{if(!Yy(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}};kD.version="7.5.0",kD.createIndex=dwt,kD.parseIndex=H3o,kD.config=bA,kD.match=function(t,e,n){if(n&&n.useTokenSearch)throw new Error(R3o);return Dte(t,{...bA,...n}).searchIn(e)},kD.parseQuery=Cwt,cMe(j3o),cMe(APo),kD.use=function(...t){t.forEach(e=>cMe(e))};var lPo=kD;const gPo="https://kicad-mod-cache.tscircuit.com";let _Me=null,JG=null,mMe=null;const uPo=async()=>_Me||JG||(JG=fetch("https://kicad-mod-cache.tscircuit.com/kicad_files.json").then(t=>t.json()).then(t=>(_Me=t,JG=null,t)),JG),hPo=async(t,e=20)=>{const n=await uPo();return mMe||(mMe=new lPo(n)),mMe.search(t).slice(0,e).map(o=>o.item)},dPo=t=>{const e=t.replace(".pretty/","/").replace(".kicad_mod",""),n=`kicad:${e}`;return{path:t,qualifiedName:n,description:e}},_Po=t=>t.replace(/^\/+/,"").split("/").map(e=>encodeURIComponent(e)).join("/"),mPo=async t=>{const e=await fetch(`${gPo}/${_Po(t)}`);if(!e.ok)throw new Error(`KiCad footprint fetch failed: ${e.status}`);const n=await e.text(),{KicadFootprintToCircuitJsonConverter:o}=await xB("kicad-to-circuit-json"),i=new o;return i.addFile(t.split("/").pop()??"selected-footprint.kicad_mod",n),i.runUntilFinished(),i.getOutput()},Bwt=t=>t?.source==="jlcpcb"||t?.source==="kicad",pPo=async(t,e)=>{if(t.source==="jlcpcb")return Q3o(t.component.partNumber,e?.jlcpcb);if(t.source==="kicad")return mPo(t.footprint.path);throw new Error("Footprint preview is not available for this source")},IPo=({query:t,placeholder:e,isSearching:n,onQueryChange:o,onSubmit:i})=>{const r=ee.useCallback(A=>{A.key==="Enter"&&(A.preventDefault(),i())},[i]);return q.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2 rf-mt-4",children:[q.jsxs("div",{className:"rf-relative rf-flex-grow",children:[q.jsx(jBt,{className:"rf-absolute rf-left-2 rf-top-2.5 rf-h-4 rf-w-4 rf-text-muted-foreground"}),q.jsx(cbe,{placeholder:e,className:"rf-pl-8",spellCheck:!1,autoComplete:"off",value:t,onChange:A=>o(A.target.value),onKeyDown:r})]}),q.jsx(cc,{onClick:i,disabled:n||t.trim().length<1,className:"sm:rf-px-4 rf-px-3",children:n?q.jsx(cQ,{className:"rf-h-4 rf-w-4 rf-animate-spin"}):q.jsxs(q.Fragment,{children:[q.jsx(jBt,{className:"rf-h-4 rf-w-4 sm:rf-hidden"}),q.jsx("span",{className:"rf-hidden sm:rf-inline",children:"Search"})]})})]})},CPo=new Intl.NumberFormat("en-US",{style:"currency",currency:"USD"}),fPo=t=>CPo.format(t),xwt=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"}},yPo=t=>{switch(t.source){case"tscircuit.com":return t.package.unscoped_name;case"jlcpcb":return t.component.manufacturer;case"kicad":return t.footprint.qualifiedName}},EPo=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}},BPo=t=>{switch(t.source){case"tscircuit.com":return t.package.name;case"jlcpcb":return t.component.partNumber;case"kicad":return}},xPo=({results:t,selected:e,onSelect:n,onShowDetails:o})=>{const i=e?xwt(e):null;return q.jsx("div",{className:"rf-divide-y rf-w-full rf-overflow-hidden",children:t.map(r=>{const A=xwt(r),s=i===A,a=yPo(r),c=EPo(r),l=BPo(r),g=r.source==="jlcpcb"?r.component.stock:null,u=r.source==="jlcpcb"?r.component.price:null,d=r.source==="jlcpcb"?r.component.isBasic:null;return q.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:[q.jsxs("div",{className:"rf-min-w-0 rf-overflow-hidden rf-w-full",children:[q.jsxs("div",{className:"rf-flex rf-items-start rf-gap-2 rf-min-w-0",children:[q.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"&&d!=null&&q.jsx("span",{className:`rf-text-xs rf-px-1.5 rf-py-0.5 rf-rounded rf-font-medium rf-flex-shrink-0 ${d?"rf-bg-green-100 rf-text-green-700":"rf-bg-orange-100 rf-text-orange-700"}`,children:d?"Basic":"Extended"}),r.source==="tscircuit.com"&&r.package.is_private&&q.jsx(emo,{className:"rf-ml-1 rf-h-3 rf-w-3 rf-text-zinc-400 rf-flex-shrink-0"})]}),r.source==="jlcpcb"&&g!=null?q.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]}),q.jsxs("div",{className:"rf-text-xs rf-text-zinc-500 rf-truncate rf-w-full",children:[l?q.jsx("span",{className:"rf-mr-2",children:l}):null,c]})]}),q.jsxs("div",{children:[r.source==="tscircuit.com"&&o?q.jsx("div",{className:"rf-flex-shrink-0 rf-w-full sm:rf-w-auto",children:q.jsx(cc,{variant:"outline",size:"sm",className:"rf-text-xs rf-w-full sm:rf-w-auto",onClick:h=>{h.stopPropagation(),o(r)},children:"See Details"})}):r.source==="jlcpcb"&&g!=null?q.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&&q.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:fPo(u)})]})]},A)})})},QPo=({circuitJson:t,error:e,isLoading:n,height:o})=>q.jsx("section",{className:"rf-flex rf-min-w-0 rf-items-center rf-justify-center",style:{height:o},children:n?q.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:[q.jsx(cQ,{className:"rf-h-4 rf-w-4 rf-animate-spin"}),"Loading preview..."]}):e?q.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:q.jsxs("div",{className:"rf-flex rf-max-w-[320px] rf-items-start rf-gap-2 rf-text-sm rf-text-zinc-300",children:[q.jsx(qBt,{className:"rf-mt-0.5 rf-h-4 rf-w-4 rf-flex-shrink-0"}),q.jsx("span",{children:e})]})}):t?q.jsx("div",{className:"rf-w-full rf-min-w-0 rf-overflow-hidden",children:q.jsx(lPt,{circuitJson:t,height:o,allowEditing:!1,clickToInteractEnabled:!1,focusOnHover:!1,disablePcbGroups:!0})}):q.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"})}),Qwt={importComponentDialog:101,importComponentDetailsDialog:102},SPo=({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,d=c?.unscoped_name?.split("/").pop()??c?.unscoped_name,h=c?.org_owner_tscircuit_handle??void 0,_=h?`https://tscircuit.com/${h}`:void 0,p=h&&d?`https://tscircuit.com/${h}/${d}`:void 0;return q.jsx(UG,{open:e,onOpenChange:n,children:q.jsxs(dN,{showOverlay:!1,style:{width:"calc(100vw - 2rem)",zIndex:Qwt.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:[q.jsx(_N,{className:"rf-pb-4 rf-border-b",children:q.jsx("div",{className:"rf-flex rf-items-start rf-justify-between rf-gap-4",children:q.jsxs("div",{className:"rf-flex-1 rf-min-w-0",children:[q.jsx(mN,{className:"rf-text-xl rf-font-semibold rf-truncate",children:d}),q.jsx(VG,{children:c?.description})]})})}),q.jsxs("div",{className:"rf-flex-1 rf-overflow-y-auto rf-py-4 rf-space-y-6",children:[h?q.jsxs("div",{children:[q.jsx("span",{className:"rf-text-xs rf-font-medium rf-text-gray-500 rf-uppercase rf-tracking-wide",children:"Created by"}),q.jsx("div",{className:"rf-mt-1 rf-text-sm rf-font-medium",children:_?q.jsx("a",{href:_,target:"_blank",rel:"noopener noreferrer",className:"rf-text-black hover:rf-underline",children:h}):h})]}):null,(u||l||g)&&q.jsx(q.Fragment,{children:q.jsxs("div",{children:[q.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-mb-4",children:"Preview"}),q.jsxs(Hie,{value:r,onValueChange:m=>A(m),children:[q.jsxs(YK,{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&&q.jsx(ox,{value:"pcb",children:"PCB"}),g&&q.jsx(ox,{value:"schematic",children:"Schematic"}),u&&q.jsx(ox,{value:"3d",children:"3D"})]}),q.jsxs("div",{className:"rf-mt-4",children:[q.jsx(DI,{value:"pcb",className:"rf-border rf-rounded-lg rf-overflow-hidden rf-bg-gray-50",children:l?q.jsx("img",{src:l,alt:`${d??"package"} PCB preview`,className:"rf-w-full rf-h-full rf-object-contain rf-bg-white rf-p-4"}):null}),q.jsx(DI,{value:"schematic",className:"rf-border rf-rounded-lg rf-overflow-hidden rf-bg-gray-50",children:g?q.jsx("img",{src:g,alt:`${d??"package"} schematic preview`,className:"rf-w-full rf-h-full rf-object-contain rf-bg-white rf-p-4"}):null}),q.jsx(DI,{value:"3d",className:"rf-border rf-rounded-lg rf-overflow-hidden rf-bg-gray-50",children:u?q.jsx("img",{src:u,alt:`${d??"package"} 3D preview`,className:"rf-w-full rf-h-full rf-object-contain rf-bg-white rf-p-4"}):null})]})]})]})}),i?.ai_description?q.jsxs("section",{children:[q.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-mb-3",children:"AI Description"}),q.jsx("div",{className:"rf-bg-gray-50 rf-border rf-border-gray-200 rf-rounded-lg rf-p-4",children:q.jsx("p",{className:"rf-text-sm rf-text-gray-700 rf-leading-relaxed",children:i.ai_description})})]}):null,i?.ai_usage_instructions?q.jsxs("section",{children:[q.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-mb-3",children:"Usage Instructions"}),q.jsx("div",{className:"rf-bg-gray-50 rf-border rf-border-gray-200 rf-rounded-lg rf-p-4",children:q.jsx("p",{className:"rf-text-sm rf-text-gray-700 rf-leading-relaxed rf-whitespace-pre-wrap",children:i.ai_usage_instructions})})]}):null,o?q.jsxs("div",{className:"rf-flex rf-justify-center rf-items-center rf-gap-2 rf-text-gray-500",children:[q.jsx(cQ,{className:"rf-h-4 rf-w-4 rf-animate-spin"}),q.jsx("span",{className:"rf-text-sm",children:"Loading package details..."})]}):null]}),q.jsxs(YG,{className:"rf-pt-4 rf-border-t rf-flex rf-flex-col sm:rf-flex-row rf-justify-between rf-gap-2",children:[q.jsx("div",{className:"rf-flex-1",children:p?q.jsxs(cc,{variant:"outline",size:"sm",className:"rf-gap-2 rf-w-full sm:rf-w-auto",onClick:()=>window.open(p,"_blank"),children:[q.jsx(j_o,{className:"rf-h-4 rf-w-4"}),"View on tscircuit.com"]}):null}),q.jsxs("div",{className:"rf-flex rf-flex-col sm:rf-flex-row rf-gap-2",children:[q.jsx(cc,{variant:"outline",onClick:()=>n(!1),className:"rf-order-2 sm:rf-order-1",children:"Close"}),q.jsx(cc,{onClick:a,disabled:s,className:"rf-bg-blue-600 hover:rf-bg-blue-700",children:s?q.jsx(cQ,{className:"rf-h-4 rf-w-4 rf-animate-spin"}):"Import Component"})]})]})]})})},bPo=()=>{const[t,e]=ee.useState(null),[n,o]=ee.useState(!1),i=ee.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=ee.useCallback(()=>{e(null),o(!1)},[]);return{details:t,isLoading:n,fetchDetails:i,reset:r}},DPo=(t,e)=>{const[n,o]=ee.useState({circuitJson:null,error:null,isLoading:!1});return ee.useEffect(()=>{if(!t||!Bwt(t)){o({circuitJson:null,error:null,isLoading:!1});return}let i=!1;return o({circuitJson:null,error:null,isLoading:!0}),pPo(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},MPo=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??[]},PPo=({sessionToken:t})=>{const[e,n]=ee.useState([]),[o,i]=ee.useState(!1),[r,A]=ee.useState(null),[s,a]=ee.useState(!1),c=ee.useCallback(async g=>{const u=g.trim();if(!u)return[];i(!0),A(null);try{const h=(await MPo(u,t)).map(_=>({source:"tscircuit.com",package:_}));return n(h),h}catch(d){return console.error("Error searching tscircuit packages",d),n([]),A(d instanceof Error?d.message:"Failed to search tscircuit packages"),[]}finally{i(!1),a(!0)}},[t]),l=ee.useCallback(()=>{n([]),i(!1),A(null),a(!1)},[]);return{results:e,isSearching:o,error:r,hasSearched:s,search:c,reset:l}},wPo=t=>{const e=t.trim();return/^C\d+/i.test(e)?e.replace(/^C/i,""):e},vPo=()=>{const[t,e]=ee.useState([]),[n,o]=ee.useState(!1),[i,r]=ee.useState(null),[A,s]=ee.useState(!1),a=ee.useCallback(async l=>{const g=wPo(l);if(!g)return[];o(!0),r(null);try{const d=(await E3o(g,10)).map(h=>({source:"jlcpcb",component:B3o(h)}));return e(d),d}catch(u){return console.error("Error searching JLCPCB components",u),e([]),r(u instanceof Error?u.message:"Failed to search JLCPCB components"),[]}finally{o(!1),s(!0)}},[]),c=ee.useCallback(()=>{e([]),o(!1),r(null),s(!1)},[]);return{results:t,isSearching:n,error:i,hasSearched:A,search:a,reset:c}},NPo=()=>{const[t,e]=ee.useState([]),[n,o]=ee.useState(!1),[i,r]=ee.useState(null),[A,s]=ee.useState(!1),a=ee.useCallback(async l=>{const g=l.trim();if(!g)return[];o(!0),r(null);try{const d=(await hPo(g,20)).map(h=>({source:"kicad",footprint:dPo(h)}));return e(d),d}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=ee.useCallback(()=>{e([]),o(!1),r(null),s(!1)},[]);return{results:t,isSearching:n,error:i,hasSearched:A,search:a,reset:c}},RPo=({onTscircuitPackageSelected:t,onJlcpcbComponentTsxLoaded:e,onKicadStringSelected:n})=>{const o=[];return t&&o.push("tscircuit.com"),e&&o.push("jlcpcb"),n&&o.push("kicad"),o},TPo=({isOpen:t,onClose:e,jlcpcbProxyRequestHeaders:n,onKicadStringSelected:o,onTscircuitPackageSelected:i,onJlcpcbComponentTsxLoaded:r,jlcpcbProxyApiBase:A,tscircuitSessionToken:s})=>{gPt();const a=ee.useMemo(()=>RPo({onKicadStringSelected:o,onTscircuitPackageSelected:i,onJlcpcbComponentTsxLoaded:r}),[o,i,r]),c=a.length>0,l=a.length===1,[g,u]=ee.useState(a[0]??"tscircuit.com"),[d,h]=ee.useState(""),[_,p]=ee.useState(null),{results:m,isSearching:I,error:C,hasSearched:f,search:E,reset:B}=PPo({sessionToken:s}),{results:x,isSearching:b,error:P,hasSearched:M,search:k,reset:N}=vPo(),{results:G,isSearching:H,error:U,hasSearched:J,search:W,reset:j}=NPo(),{details:oe,isLoading:ce,fetchDetails:ne,reset:re}=bPo(),[ae,se]=ee.useState(null),[ue,Be]=ee.useState(!1),[be,De]=ee.useState("pcb"),[me,Se]=ee.useState(null),[Ie,Ke]=ee.useState(!1),We=ee.useMemo(()=>({jlcpcb:{headers:n,apiBase:A}}),[A,n]),{circuitJson:tt,error:pe,isLoading:$e}=DPo(_,We),He=Bwt(_);ee.useEffect(()=>{Se(null)},[_]);const we=ee.useCallback(()=>{B(),N(),j(),p(null)},[N,j,B]);ee.useEffect(()=>{t||(we(),h(""),Be(!1),se(null),Se(null))},[t,we]),ee.useEffect(()=>{h(""),p(null),g==="tscircuit.com"?B():g==="jlcpcb"?N():g==="kicad"&&j()},[g,N,j,B]);const Ye=lt=>{p(lt),se(lt),De("pcb"),Be(!0),re();const Ct=lt.package.org_owner_tscircuit_handle,Dt=lt.package.unscoped_name;if(Ct&&Dt){const It=Dt.split("/").pop()??Dt;ne(Ct,It)}},Re=async()=>{d.trim()&&(p(null),g==="tscircuit.com"?await E(d):g==="jlcpcb"?await k(d):g==="kicad"&&await W(d))},xe=async lt=>{try{if(Se(null),Ke(!0),lt.source==="kicad"){if(!o)throw new Error("KiCad handler not provided");await o({result:lt,footprint:lt.footprint.qualifiedName})}else if(lt.source==="jlcpcb"){if(!r)throw new Error("JLCPCB handler not provided");const Ct=await x3o(lt.component.partNumber,{headers:n,apiBase:A});await r({result:lt,tsx:Ct})}else if(lt.source==="tscircuit.com"){if(!i)throw new Error("tscircuit package handler not provided");const Ct=lt.package.org_owner_tscircuit_handle,Dt=lt.package.unscoped_name;if(!Ct||!Dt)throw new Error("Missing package metadata");const It=Dt.split("/").pop()??Dt,Nt=`@tsci/${Ct}.${It}`;await i({result:lt,fullPackageName:Nt})}return!0}catch(Ct){return console.error("Failed to import component",Ct),Se(Ct instanceof Error?Ct.message:"Failed to import component"),!1}finally{Ke(!1)}};let Oe=[],Me=!1,ze=null,je=!1;g==="tscircuit.com"?(Oe=m,Me=I,ze=C,je=f):g==="jlcpcb"?(Oe=x,Me=b,ze=P,je=M):g==="kicad"&&(Oe=G,Me=H,ze=U,je=J);const st=async()=>{if(!_)return;await xe(_)&&(e(),we(),h(""))},ct=lt=>{lt||e()},ut=lt=>{Be(lt),lt||se(null)};return q.jsxs(UG,{open:t,onOpenChange:ct,children:[q.jsxs(dN,{style:{width:"calc(100vw - 2rem)",maxWidth:He?"min(1120px, calc(100vw - 2rem))":"min(672px, calc(100vw - 2rem))",zIndex:Qwt.importComponentDialog},className:"rf-rounded-sm rf-max-h-[90vh] rf-overflow-y-auto rf-overflow-x-hidden rf-flex rf-flex-col",children:[q.jsxs(_N,{children:[q.jsxs(mN,{className:"rf-text-lg sm:rf-text-xl",children:["Import ",l?xte[g].label:""," ","Component"]}),q.jsx(VG,{className:"rf-text-sm",children:c?"Search for components from available sources.":"Import options are disabled because no handlers were provided."})]}),c?q.jsxs(Hie,{value:g,onValueChange:lt=>u(lt),className:"rf-min-w-0 rf-w-full",children:[!l&&q.jsx(YK,{className:"rf-flex rf-w-full rf-gap-2",children:a.map(lt=>q.jsx(ox,{value:lt,className:"rf-flex-1 rf-text-xs sm:rf-text-sm",children:xte[lt].label},lt))}),q.jsxs("div",{className:"rf-min-w-0",style:He?{display:"grid",gridTemplateColumns:"minmax(0, 1fr) minmax(360px, 0.95fr)",gap:"1.5rem",alignItems:"start"}:void 0,children:[q.jsxs("div",{className:"rf-min-w-0",children:[q.jsx(IPo,{query:d,placeholder:xte[g].placeholder,isSearching:Me,onQueryChange:h,onSubmit:Re}),q.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:Me?q.jsxs("div",{className:"rf-p-8 rf-text-center rf-text-zinc-500",children:[q.jsx(cQ,{className:"rf-h-8 rf-w-8 rf-animate-spin rf-mx-auto rf-mb-2"}),q.jsx("p",{children:"Searching..."})]}):Oe.length>0?q.jsx(xPo,{results:Oe,selected:_,onSelect:p,onShowDetails:g==="tscircuit.com"?Ye:void 0}):q.jsx("div",{className:"rf-p-8 rf-text-center rf-text-zinc-500",children:ze?`Error: ${ze}`:je?xte[g].emptyMessage:"Enter a search term to find components"})})]}),He?q.jsx("div",{className:"rf-mt-4",children:q.jsx(QPo,{circuitJson:tt,error:pe,isLoading:$e,height:325})}):null]})]}):null,me?q.jsx("div",{className:"rf-text-sm rf-text-red-600 rf-mt-2",children:me}):null,q.jsxs(YG,{className:"rf-flex rf-flex-col sm:rf-flex-row rf-gap-2",children:[q.jsx(cc,{variant:"outline",onClick:e,className:"rf-order-2 sm:rf-order-1",children:"Cancel"}),q.jsx(cc,{onClick:st,disabled:!_||Ie,className:"rf-order-1 sm:rf-order-2",children:Ie?q.jsx(cQ,{className:"rf-h-4 rf-w-4 rf-animate-spin"}):"Import"})]})]}),q.jsx(SPo,{packageResult:ae,isOpen:ue,onOpenChange:ut,isLoading:ce,details:oe,previewTab:be,onPreviewTabChange:lt=>De(lt),isSubmitting:Ie,onImport:()=>{ae&&xe(ae).then(lt=>{lt&&(Be(!1),e(),we(),h(""))})}})]})},kPo=t=>{const e=t.match(/export const (\w+) =/);if(!e)throw new Error("Could not determine component name from TSX contents");return e[1]},Swt=t=>{const e=EQ(A=>A.pushEvent),n=EQ(A=>A.upsertFile),o=async({result:A,fullPackageName:s})=>{const c=A.package.unscoped_name??A.package.name;await ns.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 ns.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/${kPo(s)}.tsx`;await ns.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 q.jsx(TPo,{...t,onTscircuitPackageSelected:o,onKicadStringSelected:i,onJlcpcbComponentTsxLoaded:r})};Swt.displayName="ImportComponentDialogForCli";var pMe={exports:{}},bwt;function FPo(){return bwt||(bwt=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 k4=="function"&&k4;if(!g&&u)return u(l,!0);if(a)return a(l,!0);var d=new Error("Cannot find module '"+l+"'");throw d.code="MODULE_NOT_FOUND",d}var h=r[l]={exports:{}};i[l][0].call(h.exports,function(_){var p=i[l][1][_];return s(p||_)},h,h.exports,o,i,r,A)}return r[l].exports}for(var a=typeof k4=="function"&&k4,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,d,h,_,p,m=[],I=0,C=c.length,f=C,E=A.getTypeOf(c)!=="string";I<c.length;)f=C-I,u=E?(l=c[I++],g=I<C?c[I++]:0,I<C?c[I++]:0):(l=c.charCodeAt(I++),g=I<C?c.charCodeAt(I++):0,I<C?c.charCodeAt(I++):0),d=l>>2,h=(3&l)<<4|g>>4,_=1<f?(15&g)<<2|u>>6:64,p=2<f?63&u:64,m.push(a.charAt(d)+a.charAt(h)+a.charAt(_)+a.charAt(p));return m.join("")},r.decode=function(c){var l,g,u,d,h,_,p=0,m=0,I="data:";if(c.substr(0,I.length)===I)throw new Error("Invalid base64 input, it looks like a data url.");var C,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(C=s.uint8array?new Uint8Array(0|f):new Array(0|f);p<c.length;)l=a.indexOf(c.charAt(p++))<<2|(d=a.indexOf(c.charAt(p++)))>>4,g=(15&d)<<4|(h=a.indexOf(c.charAt(p++)))>>2,u=(3&h)<<6|(_=a.indexOf(c.charAt(p++))),C[m++]=l,h!==64&&(C[m++]=g),_!==64&&(C[m++]=u);return C}},{"./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,d,h,_){this.compressedSize=g,this.uncompressedSize=u,this.crc32=d,this.compression=h,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,d){return g.pipe(new a).pipe(new c("uncompressedSize")).pipe(u.compressWorker(d)).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,d){var h=s,_=d+u;l^=-1;for(var p=d;p<_;p++)l=l>>>8^h[255&(l^g[p])];return-1^l})(0|c,a,a.length,0):(function(l,g,u,d){var h=s,_=d+u;l^=-1;for(var p=d;p<_;p++)l=l>>>8^h[255&(l^g.charCodeAt(p))];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,d){c.call(this,"FlateWorker/"+u),this._pako=null,this._pakoAction=u,this._pakoOptions=d,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(d){u.push({data:d,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(h,_){var p,m="";for(p=0;p<_;p++)m+=String.fromCharCode(255&h),h>>>=8;return m}function s(h,_,p,m,I,C){var f,E,B=h.file,x=h.compression,b=C!==l.utf8encode,P=a.transformTo("string",C(B.name)),M=a.transformTo("string",l.utf8encode(B.name)),k=B.comment,N=a.transformTo("string",C(k)),G=a.transformTo("string",l.utf8encode(k)),H=M.length!==B.name.length,U=G.length!==k.length,J="",W="",j="",oe=B.dir,ce=B.date,ne={crc32:0,compressedSize:0,uncompressedSize:0};_&&!p||(ne.crc32=h.crc32,ne.compressedSize=h.compressedSize,ne.uncompressedSize=h.uncompressedSize);var re=0;_&&(re|=8),b||!H&&!U||(re|=2048);var ae=0,se=0;oe&&(ae|=16),I==="UNIX"?(se=798,ae|=(function(Be,be){var De=Be;return Be||(De=be?16893:33204),(65535&De)<<16})(B.unixPermissions,oe)):(se=20,ae|=(function(Be){return 63&(Be||0)})(B.dosPermissions)),f=ce.getUTCHours(),f<<=6,f|=ce.getUTCMinutes(),f<<=5,f|=ce.getUTCSeconds()/2,E=ce.getUTCFullYear()-1980,E<<=4,E|=ce.getUTCMonth()+1,E<<=5,E|=ce.getUTCDate(),H&&(W=A(1,1)+A(g(P),4)+M,J+="up"+A(W.length,2)+W),U&&(j=A(1,1)+A(g(N),4)+G,J+="uc"+A(j.length,2)+j);var ue="";return ue+=`
5787
5787
  \0`,ue+=A(re,2),ue+=x.magic,ue+=A(f,2),ue+=A(E,2),ue+=A(ne.crc32,4),ue+=A(ne.compressedSize,4),ue+=A(ne.uncompressedSize,4),ue+=A(P.length,2),ue+=A(J.length,2),{fileRecord:u.LOCAL_FILE_HEADER+ue+P+J,dirRecord:u.CENTRAL_FILE_HEADER+A(se,2)+ue+A(N.length,2)+"\0\0\0\0"+A(ae,4)+A(m,4)+P+J+N}}var a=o("../utils"),c=o("../stream/GenericWorker"),l=o("../utf8"),g=o("../crc32"),u=o("../signature");function d(h,_,p,m){c.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=_,this.zipPlatform=p,this.encodeFileName=m,this.streamFiles=h,this.accumulate=!1,this.contentBuffer=[],this.dirRecords=[],this.currentSourceOffset=0,this.entriesCount=0,this.currentFile=null,this._sources=[]}a.inherits(d,c),d.prototype.push=function(h){var _=h.meta.percent||0,p=this.entriesCount,m=this._sources.length;this.accumulate?this.contentBuffer.push(h):(this.bytesWritten+=h.data.length,c.prototype.push.call(this,{data:h.data,meta:{currentFile:this.currentFile,percent:p?(_+100*(p-m-1))/p:100}}))},d.prototype.openedSource=function(h){this.currentSourceOffset=this.bytesWritten,this.currentFile=h.file.name;var _=this.streamFiles&&!h.file.dir;if(_){var p=s(h,_,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:p.fileRecord,meta:{percent:0}})}else this.accumulate=!0},d.prototype.closedSource=function(h){this.accumulate=!1;var _=this.streamFiles&&!h.file.dir,p=s(h,_,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(p.dirRecord),_)this.push({data:(function(m){return u.DATA_DESCRIPTOR+A(m.crc32,4)+A(m.compressedSize,4)+A(m.uncompressedSize,4)})(h),meta:{percent:100}});else for(this.push({data:p.fileRecord,meta:{percent:0}});this.contentBuffer.length;)this.push(this.contentBuffer.shift());this.currentFile=null},d.prototype.flush=function(){for(var h=this.bytesWritten,_=0;_<this.dirRecords.length;_++)this.push({data:this.dirRecords[_],meta:{percent:100}});var p=this.bytesWritten-h,m=(function(I,C,f,E,B){var x=a.transformTo("string",B(E));return u.CENTRAL_DIRECTORY_END+"\0\0\0\0"+A(I,2)+A(I,2)+A(C,4)+A(f,4)+A(x.length,2)+x})(this.dirRecords.length,p,h,this.zipComment,this.encodeFileName);this.push({data:m,meta:{percent:100}})},d.prototype.prepareNextSource=function(){this.previous=this._sources.shift(),this.openedSource(this.previous.streamInfo),this.isPaused?this.previous.pause():this.previous.resume()},d.prototype.registerPrevious=function(h){this._sources.push(h);var _=this;return h.on("data",function(p){_.processChunk(p)}),h.on("end",function(){_.closedSource(_.previous.streamInfo),_._sources.length?_.prepareNextSource():_.end()}),h.on("error",function(p){_.error(p)}),this},d.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))},d.prototype.error=function(h){var _=this._sources;if(!c.prototype.error.call(this,h))return!1;for(var p=0;p<_.length;p++)try{_[p].error(h)}catch{}return!0},d.prototype.lock=function(){c.prototype.lock.call(this);for(var h=this._sources,_=0;_<h.length;_++)h[_].lock()},i.exports=d},{"../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(d,h){u++;var _=(function(C,f){var E=C||f,B=A[E];if(!B)throw new Error(E+" is not a valid compression method !");return B})(h.options.compression,c.compression),p=h.options.compressionOptions||c.compressionOptions||{},m=h.dir,I=h.date;h._compressWorker(_,p).withStreamInfo("file",{name:d,dir:m,date:I,comment:h.comment||"",unixPermissions:h.unixPermissions,dosPermissions:h.dosPermissions}).pipe(g)}),g.entriesCount=u}catch(d){g.error(d)}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(d){return new s.Promise(function(h,_){var p=d.decompressed.getContentWorker().pipe(new l);p.on("error",function(m){_(m)}).on("end",function(){p.streamInfo.crc32!==d.decompressed.crc32?_(new Error("Corrupted zip : CRC32 mismatch")):h()}).resume()})}i.exports=function(d,h){var _=this;return h=A.extend(h||{},{base64:!1,checkCRC32:!1,optimizedBinaryString:!1,createFolders:!1,decodeFileName:a.utf8decode}),g.isNode&&g.isStream(d)?s.Promise.reject(new Error("JSZip can't accept a stream when loading a zip file.")):A.prepareContent("the loaded zip file",d,!0,h.optimizedBinaryString,h.base64).then(function(p){var m=new c(h);return m.load(p),m}).then(function(p){var m=[s.Promise.resolve(p)],I=p.files;if(h.checkCRC32)for(var C=0;C<I.length;C++)m.push(u(I[C]));return s.Promise.all(m)}).then(function(p){for(var m=p.shift(),I=m.files,C=0;C<I.length;C++){var f=I[C],E=f.fileNameStr,B=A.resolve(f.fileNameStr);_.file(B,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:h.createFolders}),f.dir||(_.file(B).unsafeOriginalName=E)}return m.zipComment.length&&(_.comment=m.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,d){g.push(u)||g._helper.pause(),l&&l(d)}).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(B,x,b){var P,M=a.getTypeOf(x),k=a.extend(b||{},g);k.date=k.date||new Date,k.compression!==null&&(k.compression=k.compression.toUpperCase()),typeof k.unixPermissions=="string"&&(k.unixPermissions=parseInt(k.unixPermissions,8)),k.unixPermissions&&16384&k.unixPermissions&&(k.dir=!0),k.dosPermissions&&16&k.dosPermissions&&(k.dir=!0),k.dir&&(B=I(B)),k.createFolders&&(P=m(B))&&C.call(this,P,!0);var N=M==="string"&&k.binary===!1&&k.base64===!1;b&&b.binary!==void 0||(k.binary=!N),(x instanceof u&&x.uncompressedSize===0||k.dir||!x||x.length===0)&&(k.base64=!1,k.binary=!0,x="",k.compression="STORE",M="string");var G=null;G=x instanceof u||x instanceof c?x:_.isNode&&_.isStream(x)?new p(B,x):a.prepareContent(B,x,k.binary,k.optimizedBinaryString,k.base64);var H=new d(B,G,k);this.files[B]=H}var s=o("./utf8"),a=o("./utils"),c=o("./stream/GenericWorker"),l=o("./stream/StreamHelper"),g=o("./defaults"),u=o("./compressedObject"),d=o("./zipObject"),h=o("./generate"),_=o("./nodejsUtils"),p=o("./nodejs/NodejsStreamInputAdapter"),m=function(B){B.slice(-1)==="/"&&(B=B.substring(0,B.length-1));var x=B.lastIndexOf("/");return 0<x?B.substring(0,x):""},I=function(B){return B.slice(-1)!=="/"&&(B+="/"),B},C=function(B,x){return x=x!==void 0?x:g.createFolders,B=I(B),this.files[B]||A.call(this,B,null,{dir:!0,createFolders:x}),this.files[B]};function f(B){return Object.prototype.toString.call(B)==="[object RegExp]"}var E={load:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},forEach:function(B){var x,b,P;for(x in this.files)P=this.files[x],(b=x.slice(this.root.length,x.length))&&x.slice(0,this.root.length)===this.root&&B(b,P)},filter:function(B){var x=[];return this.forEach(function(b,P){B(b,P)&&x.push(P)}),x},file:function(B,x,b){if(arguments.length!==1)return B=this.root+B,A.call(this,B,x,b),this;if(f(B)){var P=B;return this.filter(function(k,N){return!N.dir&&P.test(k)})}var M=this.files[this.root+B];return M&&!M.dir?M:null},folder:function(B){if(!B)return this;if(f(B))return this.filter(function(M,k){return k.dir&&B.test(M)});var x=this.root+B,b=C.call(this,x),P=this.clone();return P.root=b.name,P},remove:function(B){B=this.root+B;var x=this.files[B];if(x||(B.slice(-1)!=="/"&&(B+="/"),x=this.files[B]),x&&!x.dir)delete this.files[B];else for(var b=this.filter(function(M,k){return k.name.slice(0,B.length)===B}),P=0;P<b.length;P++)delete this.files[b[P].name];return this},generate:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},generateInternalStream:function(B){var x,b={};try{if((b=a.extend(B||{},{streamFiles:!1,compression:"STORE",compressionOptions:null,type:"",platform:"DOS",comment:null,mimeType:"application/zip",encodeFileName:s.utf8encode})).type=b.type.toLowerCase(),b.compression=b.compression.toUpperCase(),b.type==="binarystring"&&(b.type="string"),!b.type)throw new Error("No output type specified.");a.checkSupport(b.type),b.platform!=="darwin"&&b.platform!=="freebsd"&&b.platform!=="linux"&&b.platform!=="sunos"||(b.platform="UNIX"),b.platform==="win32"&&(b.platform="DOS");var P=b.comment||this.comment||"";x=h.generateWorker(this,b,P)}catch(M){(x=new c("error")).error(M)}return new l(x,b.type||"string",b.mimeType)},generateAsync:function(B,x){return this.generateInternalStream(B).accumulate(x)},generateNodeStream:function(B,x){return(B=B||{}).type||(B.type="nodebuffer"),this.generateInternalStream(B).toNodejsStream(x)}};i.exports=E},{"./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),d=this.length-4;0<=d;--d)if(this.data[d]===c&&this.data[d+1]===l&&this.data[d+2]===g&&this.data[d+3]===u)return d-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),d=this.readData(4);return c===d[0]&&l===d[1]&&g===d[2]&&u===d[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 d=A.getTypeOf(u);return A.checkSupport(d),d!=="string"||s.uint8array?d==="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 d(_,p){return new g.Promise(function(m,I){var C=[],f=_._internalType,E=_._outputType,B=_._mimeType;_.on("data",function(x,b){C.push(x),p&&p(b)}).on("error",function(x){C=[],I(x)}).on("end",function(){try{var x=(function(b,P,M){switch(b){case"blob":return A.newBlob(A.transformTo("arraybuffer",P),M);case"base64":return c.encode(P);default:return A.transformTo(b,P)}})(E,(function(b,P){var M,k=0,N=null,G=0;for(M=0;M<P.length;M++)G+=P[M].length;switch(b){case"string":return P.join("");case"array":return Array.prototype.concat.apply([],P);case"uint8array":for(N=new Uint8Array(G),M=0;M<P.length;M++)N.set(P[M],k),k+=P[M].length;return N;case"nodebuffer":return Buffer.concat(P);default:throw new Error("concat : unsupported type '"+b+"'")}})(f,C),B);m(x)}catch(b){I(b)}C=[]}).resume()})}function h(_,p,m){var I=p;switch(p){case"blob":case"arraybuffer":I="uint8array";break;case"base64":I="string"}try{this._internalType=I,this._outputType=p,this._mimeType=m,A.checkSupport(I),this._worker=_.pipe(new s(I)),_.lock()}catch(C){this._worker=new a("error"),this._worker.error(C)}}h.prototype={accumulate:function(_){return d(this,_)},on:function(_,p){var m=this;return _==="data"?this._worker.on(_,function(I){p.call(m,I.data,I.meta)}):this._worker.on(_,function(){A.delay(p,arguments,m)}),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=h},{"../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 d(){c.call(this,"utf-8 encode")}r.utf8encode=function(h){return s.nodebuffer?a.newBufferFrom(h,"utf-8"):(function(_){var p,m,I,C,f,E=_.length,B=0;for(C=0;C<E;C++)(64512&(m=_.charCodeAt(C)))==55296&&C+1<E&&(64512&(I=_.charCodeAt(C+1)))==56320&&(m=65536+(m-55296<<10)+(I-56320),C++),B+=m<128?1:m<2048?2:m<65536?3:4;for(p=s.uint8array?new Uint8Array(B):new Array(B),C=f=0;f<B;C++)(64512&(m=_.charCodeAt(C)))==55296&&C+1<E&&(64512&(I=_.charCodeAt(C+1)))==56320&&(m=65536+(m-55296<<10)+(I-56320),C++),m<128?p[f++]=m:(m<2048?p[f++]=192|m>>>6:(m<65536?p[f++]=224|m>>>12:(p[f++]=240|m>>>18,p[f++]=128|m>>>12&63),p[f++]=128|m>>>6&63),p[f++]=128|63&m);return p})(h)},r.utf8decode=function(h){return s.nodebuffer?A.transformTo("nodebuffer",h).toString("utf-8"):(function(_){var p,m,I,C,f=_.length,E=new Array(2*f);for(p=m=0;p<f;)if((I=_[p++])<128)E[m++]=I;else if(4<(C=l[I]))E[m++]=65533,p+=C-1;else{for(I&=C===2?31:C===3?15:7;1<C&&p<f;)I=I<<6|63&_[p++],C--;1<C?E[m++]=65533:I<65536?E[m++]=I:(I-=65536,E[m++]=55296|I>>10&1023,E[m++]=56320|1023&I)}return E.length!==m&&(E.subarray?E=E.subarray(0,m):E.length=m),A.applyFromCharCode(E)})(h=A.transformTo(s.uint8array?"uint8array":"array",h))},A.inherits(u,c),u.prototype.processChunk=function(h){var _=A.transformTo(s.uint8array?"uint8array":"array",h.data);if(this.leftOver&&this.leftOver.length){if(s.uint8array){var p=_;(_=new Uint8Array(p.length+this.leftOver.length)).set(this.leftOver,0),_.set(p,this.leftOver.length)}else _=this.leftOver.concat(_);this.leftOver=null}var m=(function(C,f){var E;for((f=f||C.length)>C.length&&(f=C.length),E=f-1;0<=E&&(192&C[E])==128;)E--;return E<0||E===0?f:E+l[C[E]]>f?E:f})(_),I=_;m!==_.length&&(s.uint8array?(I=_.subarray(0,m),this.leftOver=_.subarray(m,_.length)):(I=_.slice(0,m),this.leftOver=_.slice(m,_.length))),this.push({data:r.utf8decode(I),meta:h.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(d,c),d.prototype.processChunk=function(h){this.push({data:r.utf8encode(h.data),meta:h.meta})},r.Utf8EncodeWorker=d},{"./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(p){return p}function g(p,m){for(var I=0;I<p.length;++I)m[I]=255&p.charCodeAt(I);return m}o("setimmediate"),r.newBlob=function(p,m){r.checkSupport("blob");try{return new Blob([p],{type:m})}catch{try{var I=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);return I.append(p),I.getBlob(m)}catch{throw new Error("Bug : can't construct the Blob.")}}};var u={stringifyByChunk:function(p,m,I){var C=[],f=0,E=p.length;if(E<=I)return String.fromCharCode.apply(null,p);for(;f<E;)m==="array"||m==="nodebuffer"?C.push(String.fromCharCode.apply(null,p.slice(f,Math.min(f+I,E)))):C.push(String.fromCharCode.apply(null,p.subarray(f,Math.min(f+I,E)))),f+=I;return C.join("")},stringifyByChar:function(p){for(var m="",I=0;I<p.length;I++)m+=String.fromCharCode(p[I]);return m},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 d(p){var m=65536,I=r.getTypeOf(p),C=!0;if(I==="uint8array"?C=u.applyCanBeUsed.uint8array:I==="nodebuffer"&&(C=u.applyCanBeUsed.nodebuffer),C)for(;1<m;)try{return u.stringifyByChunk(p,I,m)}catch{m=Math.floor(m/2)}return u.stringifyByChar(p)}function h(p,m){for(var I=0;I<p.length;I++)m[I]=p[I];return m}r.applyFromCharCode=d;var _={};_.string={string:l,array:function(p){return g(p,new Array(p.length))},arraybuffer:function(p){return _.string.uint8array(p).buffer},uint8array:function(p){return g(p,new Uint8Array(p.length))},nodebuffer:function(p){return g(p,a.allocBuffer(p.length))}},_.array={string:d,array:l,arraybuffer:function(p){return new Uint8Array(p).buffer},uint8array:function(p){return new Uint8Array(p)},nodebuffer:function(p){return a.newBufferFrom(p)}},_.arraybuffer={string:function(p){return d(new Uint8Array(p))},array:function(p){return h(new Uint8Array(p),new Array(p.byteLength))},arraybuffer:l,uint8array:function(p){return new Uint8Array(p)},nodebuffer:function(p){return a.newBufferFrom(new Uint8Array(p))}},_.uint8array={string:d,array:function(p){return h(p,new Array(p.length))},arraybuffer:function(p){return p.buffer},uint8array:l,nodebuffer:function(p){return a.newBufferFrom(p)}},_.nodebuffer={string:d,array:function(p){return h(p,new Array(p.length))},arraybuffer:function(p){return _.nodebuffer.uint8array(p).buffer},uint8array:function(p){return h(p,new Uint8Array(p.length))},nodebuffer:l},r.transformTo=function(p,m){if(m=m||"",!p)return m;r.checkSupport(p);var I=r.getTypeOf(m);return _[I][p](m)},r.resolve=function(p){for(var m=p.split("/"),I=[],C=0;C<m.length;C++){var f=m[C];f==="."||f===""&&C!==0&&C!==m.length-1||(f===".."?I.pop():I.push(f))}return I.join("/")},r.getTypeOf=function(p){return typeof p=="string"?"string":Object.prototype.toString.call(p)==="[object Array]"?"array":A.nodebuffer&&a.isBuffer(p)?"nodebuffer":A.uint8array&&p instanceof Uint8Array?"uint8array":A.arraybuffer&&p instanceof ArrayBuffer?"arraybuffer":void 0},r.checkSupport=function(p){if(!A[p.toLowerCase()])throw new Error(p+" is not supported by this platform")},r.MAX_VALUE_16BITS=65535,r.MAX_VALUE_32BITS=-1,r.pretty=function(p){var m,I,C="";for(I=0;I<(p||"").length;I++)C+="\\x"+((m=p.charCodeAt(I))<16?"0":"")+m.toString(16).toUpperCase();return C},r.delay=function(p,m,I){setImmediate(function(){p.apply(I||null,m||[])})},r.inherits=function(p,m){function I(){}I.prototype=m.prototype,p.prototype=new I},r.extend=function(){var p,m,I={};for(p=0;p<arguments.length;p++)for(m in arguments[p])Object.prototype.hasOwnProperty.call(arguments[p],m)&&I[m]===void 0&&(I[m]=arguments[p][m]);return I},r.prepareContent=function(p,m,I,C,f){return c.Promise.resolve(m).then(function(E){return A.blob&&(E instanceof Blob||["[object File]","[object Blob]"].indexOf(Object.prototype.toString.call(E))!==-1)&&typeof FileReader<"u"?new c.Promise(function(B,x){var b=new FileReader;b.onload=function(P){B(P.target.result)},b.onerror=function(P){x(P.target.error)},b.readAsArrayBuffer(E)}):E}).then(function(E){var B=r.getTypeOf(E);return B?(B==="arraybuffer"?E=r.transformTo("uint8array",E):B==="string"&&(f?E=s.decode(E):I&&C!==!0&&(E=(function(x){return g(x,A.uint8array?new Uint8Array(x.length):new Array(x.length))})(E))),E):c.Promise.reject(new Error("Can't read the data of '"+p+"'. 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 d=this.reader.readString(4);throw new Error("Corrupted zip or bug: unexpected signature ("+s.pretty(d)+", expected "+s.pretty(u)+")")}},isSignature:function(u,d){var h=this.reader.index;this.reader.setIndex(u);var _=this.reader.readString(4)===d;return this.reader.setIndex(h),_},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),d=l.uint8array?"uint8array":"array",h=s.transformTo(d,u);this.zipComment=this.loadOptions.decodeFileName(h)},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,d,h,_=this.zip64EndOfCentralSize-44;0<_;)u=this.reader.readInt(2),d=this.reader.readInt(4),h=this.reader.readData(d),this.zip64ExtensibleData[u]={id:u,length:d,value:h}},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,d;for(u=0;u<this.files.length;u++)d=this.files[u],this.reader.setIndex(d.localHeaderOffset),this.checkSignature(a.LOCAL_FILE_HEADER),d.readLocalPart(this.reader),d.handleUTF8(),d.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 d=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 h=this.centralDirOffset+this.centralDirSize;this.zip64&&(h+=20,h+=12+this.zip64EndOfCentralSize);var _=d-h;if(0<_)this.isSignature(d,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 d(h,_){this.options=h,this.loadOptions=_}d.prototype={isEncrypted:function(){return(1&this.bitFlag)==1},useUTF8:function(){return(2048&this.bitFlag)==2048},readLocalPart:function(h){var _,p;if(h.skip(22),this.fileNameLength=h.readInt(2),p=h.readInt(2),this.fileName=h.readData(this.fileNameLength),h.skip(p),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(m){for(var I in g)if(Object.prototype.hasOwnProperty.call(g,I)&&g[I].magic===m)return g[I];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,_,h.readData(this.compressedSize))},readCentralPart:function(h){this.versionMadeBy=h.readInt(2),h.skip(2),this.bitFlag=h.readInt(2),this.compressionMethod=h.readString(2),this.date=h.readDate(),this.crc32=h.readInt(4),this.compressedSize=h.readInt(4),this.uncompressedSize=h.readInt(4);var _=h.readInt(2);if(this.extraFieldsLength=h.readInt(2),this.fileCommentLength=h.readInt(2),this.diskNumberStart=h.readInt(2),this.internalFileAttributes=h.readInt(2),this.externalFileAttributes=h.readInt(4),this.localHeaderOffset=h.readInt(4),this.isEncrypted())throw new Error("Encrypted zip are not supported");h.skip(_),this.readExtraFields(h),this.parseZIP64ExtraField(h),this.fileComment=h.readData(this.fileCommentLength)},processAttributes:function(){this.unixPermissions=null,this.dosPermissions=null;var h=this.versionMadeBy>>8;this.dir=!!(16&this.externalFileAttributes),h==0&&(this.dosPermissions=63&this.externalFileAttributes),h==3&&(this.unixPermissions=this.externalFileAttributes>>16&65535),this.dir||this.fileNameStr.slice(-1)!=="/"||(this.dir=!0)},parseZIP64ExtraField:function(){if(this.extraFields[1]){var h=A(this.extraFields[1].value);this.uncompressedSize===s.MAX_VALUE_32BITS&&(this.uncompressedSize=h.readInt(8)),this.compressedSize===s.MAX_VALUE_32BITS&&(this.compressedSize=h.readInt(8)),this.localHeaderOffset===s.MAX_VALUE_32BITS&&(this.localHeaderOffset=h.readInt(8)),this.diskNumberStart===s.MAX_VALUE_32BITS&&(this.diskNumberStart=h.readInt(4))}},readExtraFields:function(h){var _,p,m,I=h.index+this.extraFieldsLength;for(this.extraFields||(this.extraFields={});h.index+4<I;)_=h.readInt(2),p=h.readInt(2),m=h.readData(p),this.extraFields[_]={id:_,length:p,value:m};h.setIndex(I)},handleUTF8:function(){var h=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 p=s.transformTo(h,this.fileName);this.fileNameStr=this.loadOptions.decodeFileName(p)}var m=this.findExtraFieldUnicodeComment();if(m!==null)this.fileCommentStr=m;else{var I=s.transformTo(h,this.fileComment);this.fileCommentStr=this.loadOptions.decodeFileName(I)}}},findExtraFieldUnicodePath:function(){var h=this.extraFields[28789];if(h){var _=A(h.value);return _.readInt(1)!==1||c(this.fileName)!==_.readInt(4)?null:l.utf8decode(_.readData(h.length-5))}return null},findExtraFieldUnicodeComment:function(){var h=this.extraFields[25461];if(h){var _=A(h.value);return _.readInt(1)!==1||c(this.fileComment)!==_.readInt(4)?null:l.utf8decode(_.readData(h.length-5))}return null}},i.exports=d},{"./compressedObject":2,"./compressions":3,"./crc32":4,"./reader/readerFor":22,"./support":30,"./utf8":31,"./utils":32}],35:[function(o,i,r){function A(_,p,m){this.name=_,this.dir=m.dir,this.date=m.date,this.comment=m.comment,this.unixPermissions=m.unixPermissions,this.dosPermissions=m.dosPermissions,this._data=p,this._dataBinary=m.binary,this.options={compression:m.compression,compressionOptions:m.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 p=null,m="string";try{if(!_)throw new Error("No output type specified.");var I=(m=_.toLowerCase())==="string"||m==="text";m!=="binarystring"&&m!=="text"||(m="string"),p=this._decompressWorker();var C=!this._dataBinary;C&&!I&&(p=p.pipe(new c.Utf8EncodeWorker)),!C&&I&&(p=p.pipe(new c.Utf8DecodeWorker))}catch(f){(p=new g("error")).error(f)}return new s(p,m,"")},async:function(_,p){return this.internalStream(_).accumulate(p)},nodeStream:function(_,p){return this.internalStream(_||"nodebuffer").toNodejsStream(p)},_compressWorker:function(_,p){if(this._data instanceof l&&this._data.compression.magic===_.magic)return this._data.getCompressedWorker();var m=this._decompressWorker();return this._dataBinary||(m=m.pipe(new c.Utf8EncodeWorker)),l.createWorkerFrom(m,_,p)},_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"],d=function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},h=0;h<u.length;h++)A.prototype[u[h]]=d;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 p=A.document.createElement("script");p.onreadystatechange=function(){_(),p.onreadystatechange=null,p.parentNode.removeChild(p),p=null},A.document.documentElement.appendChild(p)}:function(){setTimeout(_,0)};else{var d=new A.MessageChannel;d.port1.onmessage=_,s=function(){d.port2.postMessage(0)}}var h=[];function _(){var p,m;a=!0;for(var I=h.length;I;){for(m=h,h=[],p=-1;++p<I;)m[p]();I=h.length}a=!1}i.exports=function(p){h.push(p)!==1||a||s()}}).call(this,typeof KO<"u"?KO: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(I){if(typeof I!="function")throw new TypeError("resolver must be a function");this.state=g,this.queue=[],this.outcome=void 0,I!==s&&p(this,I)}function d(I,C,f){this.promise=I,typeof C=="function"&&(this.onFulfilled=C,this.callFulfilled=this.otherCallFulfilled),typeof f=="function"&&(this.onRejected=f,this.callRejected=this.otherCallRejected)}function h(I,C,f){A(function(){var E;try{E=C(f)}catch(B){return a.reject(I,B)}E===I?a.reject(I,new TypeError("Cannot resolve promise with itself")):a.resolve(I,E)})}function _(I){var C=I&&I.then;if(I&&(typeof I=="object"||typeof I=="function")&&typeof C=="function")return function(){C.apply(I,arguments)}}function p(I,C){var f=!1;function E(b){f||(f=!0,a.reject(I,b))}function B(b){f||(f=!0,a.resolve(I,b))}var x=m(function(){C(B,E)});x.status==="error"&&E(x.value)}function m(I,C){var f={};try{f.value=I(C),f.status="success"}catch(E){f.status="error",f.value=E}return f}(i.exports=u).prototype.finally=function(I){if(typeof I!="function")return this;var C=this.constructor;return this.then(function(f){return C.resolve(I()).then(function(){return f})},function(f){return C.resolve(I()).then(function(){throw f})})},u.prototype.catch=function(I){return this.then(null,I)},u.prototype.then=function(I,C){if(typeof I!="function"&&this.state===l||typeof C!="function"&&this.state===c)return this;var f=new this.constructor(s);return this.state!==g?h(f,this.state===l?I:C,this.outcome):this.queue.push(new d(f,I,C)),f},d.prototype.callFulfilled=function(I){a.resolve(this.promise,I)},d.prototype.otherCallFulfilled=function(I){h(this.promise,this.onFulfilled,I)},d.prototype.callRejected=function(I){a.reject(this.promise,I)},d.prototype.otherCallRejected=function(I){h(this.promise,this.onRejected,I)},a.resolve=function(I,C){var f=m(_,C);if(f.status==="error")return a.reject(I,f.value);var E=f.value;if(E)p(I,E);else{I.state=l,I.outcome=C;for(var B=-1,x=I.queue.length;++B<x;)I.queue[B].callFulfilled(C)}return I},a.reject=function(I,C){I.state=c,I.outcome=C;for(var f=-1,E=I.queue.length;++f<E;)I.queue[f].callRejected(C);return I},u.resolve=function(I){return I instanceof this?I:a.resolve(new this(s),I)},u.reject=function(I){var C=new this(s);return a.reject(C,I)},u.all=function(I){var C=this;if(Object.prototype.toString.call(I)!=="[object Array]")return this.reject(new TypeError("must be an array"));var f=I.length,E=!1;if(!f)return this.resolve([]);for(var B=new Array(f),x=0,b=-1,P=new this(s);++b<f;)M(I[b],b);return P;function M(k,N){C.resolve(k).then(function(G){B[N]=G,++x!==f||E||(E=!0,a.resolve(P,B))},function(G){E||(E=!0,a.reject(P,G))})}},u.race=function(I){var C=this;if(Object.prototype.toString.call(I)!=="[object Array]")return this.reject(new TypeError("must be an array"));var f=I.length,E=!1;if(!f)return this.resolve([]);for(var B=-1,x=new this(s);++B<f;)b=I[B],C.resolve(b).then(function(P){E||(E=!0,a.resolve(x,P))},function(P){E||(E=!0,a.reject(x,P))});var b;return x}},{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,d=-1,h=0,_=8;function p(I){if(!(this instanceof p))return new p(I);this.options=s.assign({level:d,method:_,chunkSize:16384,windowBits:15,memLevel:8,strategy:h,to:""},I||{});var C=this.options;C.raw&&0<C.windowBits?C.windowBits=-C.windowBits:C.gzip&&0<C.windowBits&&C.windowBits<16&&(C.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,C.level,C.method,C.windowBits,C.memLevel,C.strategy);if(f!==u)throw new Error(c[f]);if(C.header&&A.deflateSetHeader(this.strm,C.header),C.dictionary){var E;if(E=typeof C.dictionary=="string"?a.string2buf(C.dictionary):g.call(C.dictionary)==="[object ArrayBuffer]"?new Uint8Array(C.dictionary):C.dictionary,(f=A.deflateSetDictionary(this.strm,E))!==u)throw new Error(c[f]);this._dict_set=!0}}function m(I,C){var f=new p(C);if(f.push(I,!0),f.err)throw f.msg||c[f.err];return f.result}p.prototype.push=function(I,C){var f,E,B=this.strm,x=this.options.chunkSize;if(this.ended)return!1;E=C===~~C?C:C===!0?4:0,typeof I=="string"?B.input=a.string2buf(I):g.call(I)==="[object ArrayBuffer]"?B.input=new Uint8Array(I):B.input=I,B.next_in=0,B.avail_in=B.input.length;do{if(B.avail_out===0&&(B.output=new s.Buf8(x),B.next_out=0,B.avail_out=x),(f=A.deflate(B,E))!==1&&f!==u)return this.onEnd(f),!(this.ended=!0);B.avail_out!==0&&(B.avail_in!==0||E!==4&&E!==2)||(this.options.to==="string"?this.onData(a.buf2binstring(s.shrinkBuf(B.output,B.next_out))):this.onData(s.shrinkBuf(B.output,B.next_out)))}while((0<B.avail_in||B.avail_out===0)&&f!==1);return E===4?(f=A.deflateEnd(this.strm),this.onEnd(f),this.ended=!0,f===u):E!==2||(this.onEnd(u),!(B.avail_out=0))},p.prototype.onData=function(I){this.chunks.push(I)},p.prototype.onEnd=function(I){I===u&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=s.flattenChunks(this.chunks)),this.chunks=[],this.err=I,this.msg=this.strm.msg},r.Deflate=p,r.deflate=m,r.deflateRaw=function(I,C){return(C=C||{}).raw=!0,m(I,C)},r.gzip=function(I,C){return(C=C||{}).gzip=!0,m(I,C)}},{"./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"),d=Object.prototype.toString;function h(p){if(!(this instanceof h))return new h(p);this.options=s.assign({chunkSize:16384,windowBits:0,to:""},p||{});var m=this.options;m.raw&&0<=m.windowBits&&m.windowBits<16&&(m.windowBits=-m.windowBits,m.windowBits===0&&(m.windowBits=-15)),!(0<=m.windowBits&&m.windowBits<16)||p&&p.windowBits||(m.windowBits+=32),15<m.windowBits&&m.windowBits<48&&(15&m.windowBits)==0&&(m.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new g,this.strm.avail_out=0;var I=A.inflateInit2(this.strm,m.windowBits);if(I!==c.Z_OK)throw new Error(l[I]);this.header=new u,A.inflateGetHeader(this.strm,this.header)}function _(p,m){var I=new h(m);if(I.push(p,!0),I.err)throw I.msg||l[I.err];return I.result}h.prototype.push=function(p,m){var I,C,f,E,B,x,b=this.strm,P=this.options.chunkSize,M=this.options.dictionary,k=!1;if(this.ended)return!1;C=m===~~m?m:m===!0?c.Z_FINISH:c.Z_NO_FLUSH,typeof p=="string"?b.input=a.binstring2buf(p):d.call(p)==="[object ArrayBuffer]"?b.input=new Uint8Array(p):b.input=p,b.next_in=0,b.avail_in=b.input.length;do{if(b.avail_out===0&&(b.output=new s.Buf8(P),b.next_out=0,b.avail_out=P),(I=A.inflate(b,c.Z_NO_FLUSH))===c.Z_NEED_DICT&&M&&(x=typeof M=="string"?a.string2buf(M):d.call(M)==="[object ArrayBuffer]"?new Uint8Array(M):M,I=A.inflateSetDictionary(this.strm,x)),I===c.Z_BUF_ERROR&&k===!0&&(I=c.Z_OK,k=!1),I!==c.Z_STREAM_END&&I!==c.Z_OK)return this.onEnd(I),!(this.ended=!0);b.next_out&&(b.avail_out!==0&&I!==c.Z_STREAM_END&&(b.avail_in!==0||C!==c.Z_FINISH&&C!==c.Z_SYNC_FLUSH)||(this.options.to==="string"?(f=a.utf8border(b.output,b.next_out),E=b.next_out-f,B=a.buf2string(b.output,f),b.next_out=E,b.avail_out=P-E,E&&s.arraySet(b.output,b.output,f,E,0),this.onData(B)):this.onData(s.shrinkBuf(b.output,b.next_out)))),b.avail_in===0&&b.avail_out===0&&(k=!0)}while((0<b.avail_in||b.avail_out===0)&&I!==c.Z_STREAM_END);return I===c.Z_STREAM_END&&(C=c.Z_FINISH),C===c.Z_FINISH?(I=A.inflateEnd(this.strm),this.onEnd(I),this.ended=!0,I===c.Z_OK):C!==c.Z_SYNC_FLUSH||(this.onEnd(c.Z_OK),!(b.avail_out=0))},h.prototype.onData=function(p){this.chunks.push(p)},h.prototype.onEnd=function(p){p===c.Z_OK&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=s.flattenChunks(this.chunks)),this.chunks=[],this.err=p,this.msg=this.strm.msg},r.Inflate=h,r.inflate=_,r.inflateRaw=function(p,m){return(m=m||{}).raw=!0,_(p,m)},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,d){if(l.subarray&&c.subarray)c.set(l.subarray(g,g+u),d);else for(var h=0;h<u;h++)c[d+h]=l[g+h]},flattenChunks:function(c){var l,g,u,d,h,_;for(l=u=0,g=c.length;l<g;l++)u+=c[l].length;for(_=new Uint8Array(u),l=d=0,g=c.length;l<g;l++)h=c[l],_.set(h,d),d+=h.length;return _}},a={arraySet:function(c,l,g,u,d){for(var h=0;h<u;h++)c[d+h]=l[g+h]},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,d){if(d<65537&&(u.subarray&&a||!u.subarray&&s))return String.fromCharCode.apply(null,A.shrinkBuf(u,d));for(var h="",_=0;_<d;_++)h+=String.fromCharCode(u[_]);return h}c[254]=c[254]=1,r.string2buf=function(u){var d,h,_,p,m,I=u.length,C=0;for(p=0;p<I;p++)(64512&(h=u.charCodeAt(p)))==55296&&p+1<I&&(64512&(_=u.charCodeAt(p+1)))==56320&&(h=65536+(h-55296<<10)+(_-56320),p++),C+=h<128?1:h<2048?2:h<65536?3:4;for(d=new A.Buf8(C),p=m=0;m<C;p++)(64512&(h=u.charCodeAt(p)))==55296&&p+1<I&&(64512&(_=u.charCodeAt(p+1)))==56320&&(h=65536+(h-55296<<10)+(_-56320),p++),h<128?d[m++]=h:(h<2048?d[m++]=192|h>>>6:(h<65536?d[m++]=224|h>>>12:(d[m++]=240|h>>>18,d[m++]=128|h>>>12&63),d[m++]=128|h>>>6&63),d[m++]=128|63&h);return d},r.buf2binstring=function(u){return g(u,u.length)},r.binstring2buf=function(u){for(var d=new A.Buf8(u.length),h=0,_=d.length;h<_;h++)d[h]=u.charCodeAt(h);return d},r.buf2string=function(u,d){var h,_,p,m,I=d||u.length,C=new Array(2*I);for(h=_=0;h<I;)if((p=u[h++])<128)C[_++]=p;else if(4<(m=c[p]))C[_++]=65533,h+=m-1;else{for(p&=m===2?31:m===3?15:7;1<m&&h<I;)p=p<<6|63&u[h++],m--;1<m?C[_++]=65533:p<65536?C[_++]=p:(p-=65536,C[_++]=55296|p>>10&1023,C[_++]=56320|1023&p)}return g(C,_)},r.utf8border=function(u,d){var h;for((d=d||u.length)>u.length&&(d=u.length),h=d-1;0<=h&&(192&u[h])==128;)h--;return h<0||h===0?d:h+c[u[h]]>d?h:d}},{"./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 d=l;d<u;d++)s=s>>>8^g[255&(s^a[d])];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,d=4,h=0,_=-2,p=-1,m=4,I=2,C=8,f=9,E=286,B=30,x=19,b=2*E+1,P=15,M=3,k=258,N=k+M+1,G=42,H=113,U=1,J=2,W=3,j=4;function oe(pe,$e){return pe.msg=g[$e],$e}function ce(pe){return(pe<<1)-(4<pe?9:0)}function ne(pe){for(var $e=pe.length;0<=--$e;)pe[$e]=0}function re(pe){var $e=pe.state,He=$e.pending;He>pe.avail_out&&(He=pe.avail_out),He!==0&&(s.arraySet(pe.output,$e.pending_buf,$e.pending_out,He,pe.next_out),pe.next_out+=He,$e.pending_out+=He,pe.total_out+=He,pe.avail_out-=He,$e.pending-=He,$e.pending===0&&($e.pending_out=0))}function ae(pe,$e){a._tr_flush_block(pe,0<=pe.block_start?pe.block_start:-1,pe.strstart-pe.block_start,$e),pe.block_start=pe.strstart,re(pe.strm)}function se(pe,$e){pe.pending_buf[pe.pending++]=$e}function ue(pe,$e){pe.pending_buf[pe.pending++]=$e>>>8&255,pe.pending_buf[pe.pending++]=255&$e}function Be(pe,$e){var He,we,Ye=pe.max_chain_length,Re=pe.strstart,xe=pe.prev_length,Oe=pe.nice_match,Me=pe.strstart>pe.w_size-N?pe.strstart-(pe.w_size-N):0,ze=pe.window,je=pe.w_mask,st=pe.prev,ct=pe.strstart+k,ut=ze[Re+xe-1],lt=ze[Re+xe];pe.prev_length>=pe.good_match&&(Ye>>=2),Oe>pe.lookahead&&(Oe=pe.lookahead);do if(ze[(He=$e)+xe]===lt&&ze[He+xe-1]===ut&&ze[He]===ze[Re]&&ze[++He]===ze[Re+1]){Re+=2,He++;do;while(ze[++Re]===ze[++He]&&ze[++Re]===ze[++He]&&ze[++Re]===ze[++He]&&ze[++Re]===ze[++He]&&ze[++Re]===ze[++He]&&ze[++Re]===ze[++He]&&ze[++Re]===ze[++He]&&ze[++Re]===ze[++He]&&Re<ct);if(we=k-(ct-Re),Re=ct-k,xe<we){if(pe.match_start=$e,Oe<=(xe=we))break;ut=ze[Re+xe-1],lt=ze[Re+xe]}}while(($e=st[$e&je])>Me&&--Ye!=0);return xe<=pe.lookahead?xe:pe.lookahead}function be(pe){var $e,He,we,Ye,Re,xe,Oe,Me,ze,je,st=pe.w_size;do{if(Ye=pe.window_size-pe.lookahead-pe.strstart,pe.strstart>=st+(st-N)){for(s.arraySet(pe.window,pe.window,st,st,0),pe.match_start-=st,pe.strstart-=st,pe.block_start-=st,$e=He=pe.hash_size;we=pe.head[--$e],pe.head[$e]=st<=we?we-st:0,--He;);for($e=He=st;we=pe.prev[--$e],pe.prev[$e]=st<=we?we-st:0,--He;);Ye+=st}if(pe.strm.avail_in===0)break;if(xe=pe.strm,Oe=pe.window,Me=pe.strstart+pe.lookahead,ze=Ye,je=void 0,je=xe.avail_in,ze<je&&(je=ze),He=je===0?0:(xe.avail_in-=je,s.arraySet(Oe,xe.input,xe.next_in,je,Me),xe.state.wrap===1?xe.adler=c(xe.adler,Oe,je,Me):xe.state.wrap===2&&(xe.adler=l(xe.adler,Oe,je,Me)),xe.next_in+=je,xe.total_in+=je,je),pe.lookahead+=He,pe.lookahead+pe.insert>=M)for(Re=pe.strstart-pe.insert,pe.ins_h=pe.window[Re],pe.ins_h=(pe.ins_h<<pe.hash_shift^pe.window[Re+1])&pe.hash_mask;pe.insert&&(pe.ins_h=(pe.ins_h<<pe.hash_shift^pe.window[Re+M-1])&pe.hash_mask,pe.prev[Re&pe.w_mask]=pe.head[pe.ins_h],pe.head[pe.ins_h]=Re,Re++,pe.insert--,!(pe.lookahead+pe.insert<M)););}while(pe.lookahead<N&&pe.strm.avail_in!==0)}function De(pe,$e){for(var He,we;;){if(pe.lookahead<N){if(be(pe),pe.lookahead<N&&$e===u)return U;if(pe.lookahead===0)break}if(He=0,pe.lookahead>=M&&(pe.ins_h=(pe.ins_h<<pe.hash_shift^pe.window[pe.strstart+M-1])&pe.hash_mask,He=pe.prev[pe.strstart&pe.w_mask]=pe.head[pe.ins_h],pe.head[pe.ins_h]=pe.strstart),He!==0&&pe.strstart-He<=pe.w_size-N&&(pe.match_length=Be(pe,He)),pe.match_length>=M)if(we=a._tr_tally(pe,pe.strstart-pe.match_start,pe.match_length-M),pe.lookahead-=pe.match_length,pe.match_length<=pe.max_lazy_match&&pe.lookahead>=M){for(pe.match_length--;pe.strstart++,pe.ins_h=(pe.ins_h<<pe.hash_shift^pe.window[pe.strstart+M-1])&pe.hash_mask,He=pe.prev[pe.strstart&pe.w_mask]=pe.head[pe.ins_h],pe.head[pe.ins_h]=pe.strstart,--pe.match_length!=0;);pe.strstart++}else pe.strstart+=pe.match_length,pe.match_length=0,pe.ins_h=pe.window[pe.strstart],pe.ins_h=(pe.ins_h<<pe.hash_shift^pe.window[pe.strstart+1])&pe.hash_mask;else we=a._tr_tally(pe,0,pe.window[pe.strstart]),pe.lookahead--,pe.strstart++;if(we&&(ae(pe,!1),pe.strm.avail_out===0))return U}return pe.insert=pe.strstart<M-1?pe.strstart:M-1,$e===d?(ae(pe,!0),pe.strm.avail_out===0?W:j):pe.last_lit&&(ae(pe,!1),pe.strm.avail_out===0)?U:J}function me(pe,$e){for(var He,we,Ye;;){if(pe.lookahead<N){if(be(pe),pe.lookahead<N&&$e===u)return U;if(pe.lookahead===0)break}if(He=0,pe.lookahead>=M&&(pe.ins_h=(pe.ins_h<<pe.hash_shift^pe.window[pe.strstart+M-1])&pe.hash_mask,He=pe.prev[pe.strstart&pe.w_mask]=pe.head[pe.ins_h],pe.head[pe.ins_h]=pe.strstart),pe.prev_length=pe.match_length,pe.prev_match=pe.match_start,pe.match_length=M-1,He!==0&&pe.prev_length<pe.max_lazy_match&&pe.strstart-He<=pe.w_size-N&&(pe.match_length=Be(pe,He),pe.match_length<=5&&(pe.strategy===1||pe.match_length===M&&4096<pe.strstart-pe.match_start)&&(pe.match_length=M-1)),pe.prev_length>=M&&pe.match_length<=pe.prev_length){for(Ye=pe.strstart+pe.lookahead-M,we=a._tr_tally(pe,pe.strstart-1-pe.prev_match,pe.prev_length-M),pe.lookahead-=pe.prev_length-1,pe.prev_length-=2;++pe.strstart<=Ye&&(pe.ins_h=(pe.ins_h<<pe.hash_shift^pe.window[pe.strstart+M-1])&pe.hash_mask,He=pe.prev[pe.strstart&pe.w_mask]=pe.head[pe.ins_h],pe.head[pe.ins_h]=pe.strstart),--pe.prev_length!=0;);if(pe.match_available=0,pe.match_length=M-1,pe.strstart++,we&&(ae(pe,!1),pe.strm.avail_out===0))return U}else if(pe.match_available){if((we=a._tr_tally(pe,0,pe.window[pe.strstart-1]))&&ae(pe,!1),pe.strstart++,pe.lookahead--,pe.strm.avail_out===0)return U}else pe.match_available=1,pe.strstart++,pe.lookahead--}return pe.match_available&&(we=a._tr_tally(pe,0,pe.window[pe.strstart-1]),pe.match_available=0),pe.insert=pe.strstart<M-1?pe.strstart:M-1,$e===d?(ae(pe,!0),pe.strm.avail_out===0?W:j):pe.last_lit&&(ae(pe,!1),pe.strm.avail_out===0)?U:J}function Se(pe,$e,He,we,Ye){this.good_length=pe,this.max_lazy=$e,this.nice_length=He,this.max_chain=we,this.func=Ye}function Ie(){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=C,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*b),this.dyn_dtree=new s.Buf16(2*(2*B+1)),this.bl_tree=new s.Buf16(2*(2*x+1)),ne(this.dyn_ltree),ne(this.dyn_dtree),ne(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new s.Buf16(P+1),this.heap=new s.Buf16(2*E+1),ne(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new s.Buf16(2*E+1),ne(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(pe){var $e;return pe&&pe.state?(pe.total_in=pe.total_out=0,pe.data_type=I,($e=pe.state).pending=0,$e.pending_out=0,$e.wrap<0&&($e.wrap=-$e.wrap),$e.status=$e.wrap?G:H,pe.adler=$e.wrap===2?0:1,$e.last_flush=u,a._tr_init($e),h):oe(pe,_)}function We(pe){var $e=Ke(pe);return $e===h&&(function(He){He.window_size=2*He.w_size,ne(He.head),He.max_lazy_match=A[He.level].max_lazy,He.good_match=A[He.level].good_length,He.nice_match=A[He.level].nice_length,He.max_chain_length=A[He.level].max_chain,He.strstart=0,He.block_start=0,He.lookahead=0,He.insert=0,He.match_length=He.prev_length=M-1,He.match_available=0,He.ins_h=0})(pe.state),$e}function tt(pe,$e,He,we,Ye,Re){if(!pe)return _;var xe=1;if($e===p&&($e=6),we<0?(xe=0,we=-we):15<we&&(xe=2,we-=16),Ye<1||f<Ye||He!==C||we<8||15<we||$e<0||9<$e||Re<0||m<Re)return oe(pe,_);we===8&&(we=9);var Oe=new Ie;return(pe.state=Oe).strm=pe,Oe.wrap=xe,Oe.gzhead=null,Oe.w_bits=we,Oe.w_size=1<<Oe.w_bits,Oe.w_mask=Oe.w_size-1,Oe.hash_bits=Ye+7,Oe.hash_size=1<<Oe.hash_bits,Oe.hash_mask=Oe.hash_size-1,Oe.hash_shift=~~((Oe.hash_bits+M-1)/M),Oe.window=new s.Buf8(2*Oe.w_size),Oe.head=new s.Buf16(Oe.hash_size),Oe.prev=new s.Buf16(Oe.w_size),Oe.lit_bufsize=1<<Ye+6,Oe.pending_buf_size=4*Oe.lit_bufsize,Oe.pending_buf=new s.Buf8(Oe.pending_buf_size),Oe.d_buf=1*Oe.lit_bufsize,Oe.l_buf=3*Oe.lit_bufsize,Oe.level=$e,Oe.strategy=Re,Oe.method=He,We(pe)}A=[new Se(0,0,0,0,function(pe,$e){var He=65535;for(He>pe.pending_buf_size-5&&(He=pe.pending_buf_size-5);;){if(pe.lookahead<=1){if(be(pe),pe.lookahead===0&&$e===u)return U;if(pe.lookahead===0)break}pe.strstart+=pe.lookahead,pe.lookahead=0;var we=pe.block_start+He;if((pe.strstart===0||pe.strstart>=we)&&(pe.lookahead=pe.strstart-we,pe.strstart=we,ae(pe,!1),pe.strm.avail_out===0)||pe.strstart-pe.block_start>=pe.w_size-N&&(ae(pe,!1),pe.strm.avail_out===0))return U}return pe.insert=0,$e===d?(ae(pe,!0),pe.strm.avail_out===0?W:j):(pe.strstart>pe.block_start&&(ae(pe,!1),pe.strm.avail_out),U)}),new Se(4,4,8,4,De),new Se(4,5,16,8,De),new Se(4,6,32,32,De),new Se(4,4,16,16,me),new Se(8,16,32,32,me),new Se(8,16,128,128,me),new Se(8,32,128,256,me),new Se(32,128,258,1024,me),new Se(32,258,258,4096,me)],r.deflateInit=function(pe,$e){return tt(pe,$e,C,15,8,0)},r.deflateInit2=tt,r.deflateReset=We,r.deflateResetKeep=Ke,r.deflateSetHeader=function(pe,$e){return pe&&pe.state?pe.state.wrap!==2?_:(pe.state.gzhead=$e,h):_},r.deflate=function(pe,$e){var He,we,Ye,Re;if(!pe||!pe.state||5<$e||$e<0)return pe?oe(pe,_):_;if(we=pe.state,!pe.output||!pe.input&&pe.avail_in!==0||we.status===666&&$e!==d)return oe(pe,pe.avail_out===0?-5:_);if(we.strm=pe,He=we.last_flush,we.last_flush=$e,we.status===G)if(we.wrap===2)pe.adler=0,se(we,31),se(we,139),se(we,8),we.gzhead?(se(we,(we.gzhead.text?1:0)+(we.gzhead.hcrc?2:0)+(we.gzhead.extra?4:0)+(we.gzhead.name?8:0)+(we.gzhead.comment?16:0)),se(we,255&we.gzhead.time),se(we,we.gzhead.time>>8&255),se(we,we.gzhead.time>>16&255),se(we,we.gzhead.time>>24&255),se(we,we.level===9?2:2<=we.strategy||we.level<2?4:0),se(we,255&we.gzhead.os),we.gzhead.extra&&we.gzhead.extra.length&&(se(we,255&we.gzhead.extra.length),se(we,we.gzhead.extra.length>>8&255)),we.gzhead.hcrc&&(pe.adler=l(pe.adler,we.pending_buf,we.pending,0)),we.gzindex=0,we.status=69):(se(we,0),se(we,0),se(we,0),se(we,0),se(we,0),se(we,we.level===9?2:2<=we.strategy||we.level<2?4:0),se(we,3),we.status=H);else{var xe=C+(we.w_bits-8<<4)<<8;xe|=(2<=we.strategy||we.level<2?0:we.level<6?1:we.level===6?2:3)<<6,we.strstart!==0&&(xe|=32),xe+=31-xe%31,we.status=H,ue(we,xe),we.strstart!==0&&(ue(we,pe.adler>>>16),ue(we,65535&pe.adler)),pe.adler=1}if(we.status===69)if(we.gzhead.extra){for(Ye=we.pending;we.gzindex<(65535&we.gzhead.extra.length)&&(we.pending!==we.pending_buf_size||(we.gzhead.hcrc&&we.pending>Ye&&(pe.adler=l(pe.adler,we.pending_buf,we.pending-Ye,Ye)),re(pe),Ye=we.pending,we.pending!==we.pending_buf_size));)se(we,255&we.gzhead.extra[we.gzindex]),we.gzindex++;we.gzhead.hcrc&&we.pending>Ye&&(pe.adler=l(pe.adler,we.pending_buf,we.pending-Ye,Ye)),we.gzindex===we.gzhead.extra.length&&(we.gzindex=0,we.status=73)}else we.status=73;if(we.status===73)if(we.gzhead.name){Ye=we.pending;do{if(we.pending===we.pending_buf_size&&(we.gzhead.hcrc&&we.pending>Ye&&(pe.adler=l(pe.adler,we.pending_buf,we.pending-Ye,Ye)),re(pe),Ye=we.pending,we.pending===we.pending_buf_size)){Re=1;break}Re=we.gzindex<we.gzhead.name.length?255&we.gzhead.name.charCodeAt(we.gzindex++):0,se(we,Re)}while(Re!==0);we.gzhead.hcrc&&we.pending>Ye&&(pe.adler=l(pe.adler,we.pending_buf,we.pending-Ye,Ye)),Re===0&&(we.gzindex=0,we.status=91)}else we.status=91;if(we.status===91)if(we.gzhead.comment){Ye=we.pending;do{if(we.pending===we.pending_buf_size&&(we.gzhead.hcrc&&we.pending>Ye&&(pe.adler=l(pe.adler,we.pending_buf,we.pending-Ye,Ye)),re(pe),Ye=we.pending,we.pending===we.pending_buf_size)){Re=1;break}Re=we.gzindex<we.gzhead.comment.length?255&we.gzhead.comment.charCodeAt(we.gzindex++):0,se(we,Re)}while(Re!==0);we.gzhead.hcrc&&we.pending>Ye&&(pe.adler=l(pe.adler,we.pending_buf,we.pending-Ye,Ye)),Re===0&&(we.status=103)}else we.status=103;if(we.status===103&&(we.gzhead.hcrc?(we.pending+2>we.pending_buf_size&&re(pe),we.pending+2<=we.pending_buf_size&&(se(we,255&pe.adler),se(we,pe.adler>>8&255),pe.adler=0,we.status=H)):we.status=H),we.pending!==0){if(re(pe),pe.avail_out===0)return we.last_flush=-1,h}else if(pe.avail_in===0&&ce($e)<=ce(He)&&$e!==d)return oe(pe,-5);if(we.status===666&&pe.avail_in!==0)return oe(pe,-5);if(pe.avail_in!==0||we.lookahead!==0||$e!==u&&we.status!==666){var Oe=we.strategy===2?(function(Me,ze){for(var je;;){if(Me.lookahead===0&&(be(Me),Me.lookahead===0)){if(ze===u)return U;break}if(Me.match_length=0,je=a._tr_tally(Me,0,Me.window[Me.strstart]),Me.lookahead--,Me.strstart++,je&&(ae(Me,!1),Me.strm.avail_out===0))return U}return Me.insert=0,ze===d?(ae(Me,!0),Me.strm.avail_out===0?W:j):Me.last_lit&&(ae(Me,!1),Me.strm.avail_out===0)?U:J})(we,$e):we.strategy===3?(function(Me,ze){for(var je,st,ct,ut,lt=Me.window;;){if(Me.lookahead<=k){if(be(Me),Me.lookahead<=k&&ze===u)return U;if(Me.lookahead===0)break}if(Me.match_length=0,Me.lookahead>=M&&0<Me.strstart&&(st=lt[ct=Me.strstart-1])===lt[++ct]&&st===lt[++ct]&&st===lt[++ct]){ut=Me.strstart+k;do;while(st===lt[++ct]&&st===lt[++ct]&&st===lt[++ct]&&st===lt[++ct]&&st===lt[++ct]&&st===lt[++ct]&&st===lt[++ct]&&st===lt[++ct]&&ct<ut);Me.match_length=k-(ut-ct),Me.match_length>Me.lookahead&&(Me.match_length=Me.lookahead)}if(Me.match_length>=M?(je=a._tr_tally(Me,1,Me.match_length-M),Me.lookahead-=Me.match_length,Me.strstart+=Me.match_length,Me.match_length=0):(je=a._tr_tally(Me,0,Me.window[Me.strstart]),Me.lookahead--,Me.strstart++),je&&(ae(Me,!1),Me.strm.avail_out===0))return U}return Me.insert=0,ze===d?(ae(Me,!0),Me.strm.avail_out===0?W:j):Me.last_lit&&(ae(Me,!1),Me.strm.avail_out===0)?U:J})(we,$e):A[we.level].func(we,$e);if(Oe!==W&&Oe!==j||(we.status=666),Oe===U||Oe===W)return pe.avail_out===0&&(we.last_flush=-1),h;if(Oe===J&&($e===1?a._tr_align(we):$e!==5&&(a._tr_stored_block(we,0,0,!1),$e===3&&(ne(we.head),we.lookahead===0&&(we.strstart=0,we.block_start=0,we.insert=0))),re(pe),pe.avail_out===0))return we.last_flush=-1,h}return $e!==d?h:we.wrap<=0?1:(we.wrap===2?(se(we,255&pe.adler),se(we,pe.adler>>8&255),se(we,pe.adler>>16&255),se(we,pe.adler>>24&255),se(we,255&pe.total_in),se(we,pe.total_in>>8&255),se(we,pe.total_in>>16&255),se(we,pe.total_in>>24&255)):(ue(we,pe.adler>>>16),ue(we,65535&pe.adler)),re(pe),0<we.wrap&&(we.wrap=-we.wrap),we.pending!==0?h:1)},r.deflateEnd=function(pe){var $e;return pe&&pe.state?($e=pe.state.status)!==G&&$e!==69&&$e!==73&&$e!==91&&$e!==103&&$e!==H&&$e!==666?oe(pe,_):(pe.state=null,$e===H?oe(pe,-3):h):_},r.deflateSetDictionary=function(pe,$e){var He,we,Ye,Re,xe,Oe,Me,ze,je=$e.length;if(!pe||!pe.state||(Re=(He=pe.state).wrap)===2||Re===1&&He.status!==G||He.lookahead)return _;for(Re===1&&(pe.adler=c(pe.adler,$e,je,0)),He.wrap=0,je>=He.w_size&&(Re===0&&(ne(He.head),He.strstart=0,He.block_start=0,He.insert=0),ze=new s.Buf8(He.w_size),s.arraySet(ze,$e,je-He.w_size,He.w_size,0),$e=ze,je=He.w_size),xe=pe.avail_in,Oe=pe.next_in,Me=pe.input,pe.avail_in=je,pe.next_in=0,pe.input=$e,be(He);He.lookahead>=M;){for(we=He.strstart,Ye=He.lookahead-(M-1);He.ins_h=(He.ins_h<<He.hash_shift^He.window[we+M-1])&He.hash_mask,He.prev[we&He.w_mask]=He.head[He.ins_h],He.head[He.ins_h]=we,we++,--Ye;);He.strstart=we,He.lookahead=M-1,be(He)}return He.strstart+=He.lookahead,He.block_start=He.strstart,He.insert=He.lookahead,He.lookahead=0,He.match_length=He.prev_length=M-1,He.match_available=0,pe.next_in=Oe,pe.input=Me,pe.avail_in=xe,He.wrap=Re,h},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,d,h,_,p,m,I,C,f,E,B,x,b,P,M,k,N,G,H,U,J;a=A.state,c=A.next_in,U=A.input,l=c+(A.avail_in-5),g=A.next_out,J=A.output,u=g-(s-A.avail_out),d=g+(A.avail_out-257),h=a.dmax,_=a.wsize,p=a.whave,m=a.wnext,I=a.window,C=a.hold,f=a.bits,E=a.lencode,B=a.distcode,x=(1<<a.lenbits)-1,b=(1<<a.distbits)-1;e:do{f<15&&(C+=U[c++]<<f,f+=8,C+=U[c++]<<f,f+=8),P=E[C&x];t:for(;;){if(C>>>=M=P>>>24,f-=M,(M=P>>>16&255)===0)J[g++]=65535&P;else{if(!(16&M)){if((64&M)==0){P=E[(65535&P)+(C&(1<<M)-1)];continue t}if(32&M){a.mode=12;break e}A.msg="invalid literal/length code",a.mode=30;break e}k=65535&P,(M&=15)&&(f<M&&(C+=U[c++]<<f,f+=8),k+=C&(1<<M)-1,C>>>=M,f-=M),f<15&&(C+=U[c++]<<f,f+=8,C+=U[c++]<<f,f+=8),P=B[C&b];n:for(;;){if(C>>>=M=P>>>24,f-=M,!(16&(M=P>>>16&255))){if((64&M)==0){P=B[(65535&P)+(C&(1<<M)-1)];continue n}A.msg="invalid distance code",a.mode=30;break e}if(N=65535&P,f<(M&=15)&&(C+=U[c++]<<f,(f+=8)<M&&(C+=U[c++]<<f,f+=8)),h<(N+=C&(1<<M)-1)){A.msg="invalid distance too far back",a.mode=30;break e}if(C>>>=M,f-=M,(M=g-u)<N){if(p<(M=N-M)&&a.sane){A.msg="invalid distance too far back",a.mode=30;break e}if(H=I,(G=0)===m){if(G+=_-M,M<k){for(k-=M;J[g++]=I[G++],--M;);G=g-N,H=J}}else if(m<M){if(G+=_+m-M,(M-=m)<k){for(k-=M;J[g++]=I[G++],--M;);if(G=0,m<k){for(k-=M=m;J[g++]=I[G++],--M;);G=g-N,H=J}}}else if(G+=m-M,M<k){for(k-=M;J[g++]=I[G++],--M;);G=g-N,H=J}for(;2<k;)J[g++]=H[G++],J[g++]=H[G++],J[g++]=H[G++],k-=3;k&&(J[g++]=H[G++],1<k&&(J[g++]=H[G++]))}else{for(G=g-N;J[g++]=J[G++],J[g++]=J[G++],J[g++]=J[G++],2<(k-=3););k&&(J[g++]=J[G++],1<k&&(J[g++]=J[G++]))}break}}break}}while(c<l&&g<d);c-=k=f>>3,C&=(1<<(f-=k<<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<d?d-g+257:257-(g-d),a.hold=C,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,d=0,h=-2,_=1,p=852,m=592;function I(G){return(G>>>24&255)+(G>>>8&65280)+((65280&G)<<8)+((255&G)<<24)}function C(){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(G){var H;return G&&G.state?(H=G.state,G.total_in=G.total_out=H.total=0,G.msg="",H.wrap&&(G.adler=1&H.wrap),H.mode=_,H.last=0,H.havedict=0,H.dmax=32768,H.head=null,H.hold=0,H.bits=0,H.lencode=H.lendyn=new A.Buf32(p),H.distcode=H.distdyn=new A.Buf32(m),H.sane=1,H.back=-1,d):h}function E(G){var H;return G&&G.state?((H=G.state).wsize=0,H.whave=0,H.wnext=0,f(G)):h}function B(G,H){var U,J;return G&&G.state?(J=G.state,H<0?(U=0,H=-H):(U=1+(H>>4),H<48&&(H&=15)),H&&(H<8||15<H)?h:(J.window!==null&&J.wbits!==H&&(J.window=null),J.wrap=U,J.wbits=H,E(G))):h}function x(G,H){var U,J;return G?(J=new C,(G.state=J).window=null,(U=B(G,H))!==d&&(G.state=null),U):h}var b,P,M=!0;function k(G){if(M){var H;for(b=new A.Buf32(512),P=new A.Buf32(32),H=0;H<144;)G.lens[H++]=8;for(;H<256;)G.lens[H++]=9;for(;H<280;)G.lens[H++]=7;for(;H<288;)G.lens[H++]=8;for(l(g,G.lens,0,288,b,0,G.work,{bits:9}),H=0;H<32;)G.lens[H++]=5;l(u,G.lens,0,32,P,0,G.work,{bits:5}),M=!1}G.lencode=b,G.lenbits=9,G.distcode=P,G.distbits=5}function N(G,H,U,J){var W,j=G.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,H,U-j.wsize,j.wsize,0),j.wnext=0,j.whave=j.wsize):(J<(W=j.wsize-j.wnext)&&(W=J),A.arraySet(j.window,H,U-J,W,j.wnext),(J-=W)?(A.arraySet(j.window,H,U-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=E,r.inflateReset2=B,r.inflateResetKeep=f,r.inflateInit=function(G){return x(G,15)},r.inflateInit2=x,r.inflate=function(G,H){var U,J,W,j,oe,ce,ne,re,ae,se,ue,Be,be,De,me,Se,Ie,Ke,We,tt,pe,$e,He,we,Ye=0,Re=new A.Buf8(4),xe=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!G||!G.state||!G.output||!G.input&&G.avail_in!==0)return h;(U=G.state).mode===12&&(U.mode=13),oe=G.next_out,W=G.output,ne=G.avail_out,j=G.next_in,J=G.input,ce=G.avail_in,re=U.hold,ae=U.bits,se=ce,ue=ne,$e=d;e:for(;;)switch(U.mode){case _:if(U.wrap===0){U.mode=13;break}for(;ae<16;){if(ce===0)break e;ce--,re+=J[j++]<<ae,ae+=8}if(2&U.wrap&&re===35615){Re[U.check=0]=255&re,Re[1]=re>>>8&255,U.check=a(U.check,Re,2,0),ae=re=0,U.mode=2;break}if(U.flags=0,U.head&&(U.head.done=!1),!(1&U.wrap)||(((255&re)<<8)+(re>>8))%31){G.msg="incorrect header check",U.mode=30;break}if((15&re)!=8){G.msg="unknown compression method",U.mode=30;break}if(ae-=4,pe=8+(15&(re>>>=4)),U.wbits===0)U.wbits=pe;else if(pe>U.wbits){G.msg="invalid window size",U.mode=30;break}U.dmax=1<<pe,G.adler=U.check=1,U.mode=512&re?10:12,ae=re=0;break;case 2:for(;ae<16;){if(ce===0)break e;ce--,re+=J[j++]<<ae,ae+=8}if(U.flags=re,(255&U.flags)!=8){G.msg="unknown compression method",U.mode=30;break}if(57344&U.flags){G.msg="unknown header flags set",U.mode=30;break}U.head&&(U.head.text=re>>8&1),512&U.flags&&(Re[0]=255&re,Re[1]=re>>>8&255,U.check=a(U.check,Re,2,0)),ae=re=0,U.mode=3;case 3:for(;ae<32;){if(ce===0)break e;ce--,re+=J[j++]<<ae,ae+=8}U.head&&(U.head.time=re),512&U.flags&&(Re[0]=255&re,Re[1]=re>>>8&255,Re[2]=re>>>16&255,Re[3]=re>>>24&255,U.check=a(U.check,Re,4,0)),ae=re=0,U.mode=4;case 4:for(;ae<16;){if(ce===0)break e;ce--,re+=J[j++]<<ae,ae+=8}U.head&&(U.head.xflags=255&re,U.head.os=re>>8),512&U.flags&&(Re[0]=255&re,Re[1]=re>>>8&255,U.check=a(U.check,Re,2,0)),ae=re=0,U.mode=5;case 5:if(1024&U.flags){for(;ae<16;){if(ce===0)break e;ce--,re+=J[j++]<<ae,ae+=8}U.length=re,U.head&&(U.head.extra_len=re),512&U.flags&&(Re[0]=255&re,Re[1]=re>>>8&255,U.check=a(U.check,Re,2,0)),ae=re=0}else U.head&&(U.head.extra=null);U.mode=6;case 6:if(1024&U.flags&&(ce<(Be=U.length)&&(Be=ce),Be&&(U.head&&(pe=U.head.extra_len-U.length,U.head.extra||(U.head.extra=new Array(U.head.extra_len)),A.arraySet(U.head.extra,J,j,Be,pe)),512&U.flags&&(U.check=a(U.check,J,Be,j)),ce-=Be,j+=Be,U.length-=Be),U.length))break e;U.length=0,U.mode=7;case 7:if(2048&U.flags){if(ce===0)break e;for(Be=0;pe=J[j+Be++],U.head&&pe&&U.length<65536&&(U.head.name+=String.fromCharCode(pe)),pe&&Be<ce;);if(512&U.flags&&(U.check=a(U.check,J,Be,j)),ce-=Be,j+=Be,pe)break e}else U.head&&(U.head.name=null);U.length=0,U.mode=8;case 8:if(4096&U.flags){if(ce===0)break e;for(Be=0;pe=J[j+Be++],U.head&&pe&&U.length<65536&&(U.head.comment+=String.fromCharCode(pe)),pe&&Be<ce;);if(512&U.flags&&(U.check=a(U.check,J,Be,j)),ce-=Be,j+=Be,pe)break e}else U.head&&(U.head.comment=null);U.mode=9;case 9:if(512&U.flags){for(;ae<16;){if(ce===0)break e;ce--,re+=J[j++]<<ae,ae+=8}if(re!==(65535&U.check)){G.msg="header crc mismatch",U.mode=30;break}ae=re=0}U.head&&(U.head.hcrc=U.flags>>9&1,U.head.done=!0),G.adler=U.check=0,U.mode=12;break;case 10:for(;ae<32;){if(ce===0)break e;ce--,re+=J[j++]<<ae,ae+=8}G.adler=U.check=I(re),ae=re=0,U.mode=11;case 11:if(U.havedict===0)return G.next_out=oe,G.avail_out=ne,G.next_in=j,G.avail_in=ce,U.hold=re,U.bits=ae,2;G.adler=U.check=1,U.mode=12;case 12:if(H===5||H===6)break e;case 13:if(U.last){re>>>=7&ae,ae-=7&ae,U.mode=27;break}for(;ae<3;){if(ce===0)break e;ce--,re+=J[j++]<<ae,ae+=8}switch(U.last=1&re,ae-=1,3&(re>>>=1)){case 0:U.mode=14;break;case 1:if(k(U),U.mode=20,H!==6)break;re>>>=2,ae-=2;break e;case 2:U.mode=17;break;case 3:G.msg="invalid block type",U.mode=30}re>>>=2,ae-=2;break;case 14:for(re>>>=7&ae,ae-=7&ae;ae<32;){if(ce===0)break e;ce--,re+=J[j++]<<ae,ae+=8}if((65535&re)!=(re>>>16^65535)){G.msg="invalid stored block lengths",U.mode=30;break}if(U.length=65535&re,ae=re=0,U.mode=15,H===6)break e;case 15:U.mode=16;case 16:if(Be=U.length){if(ce<Be&&(Be=ce),ne<Be&&(Be=ne),Be===0)break e;A.arraySet(W,J,j,Be,oe),ce-=Be,j+=Be,ne-=Be,oe+=Be,U.length-=Be;break}U.mode=12;break;case 17:for(;ae<14;){if(ce===0)break e;ce--,re+=J[j++]<<ae,ae+=8}if(U.nlen=257+(31&re),re>>>=5,ae-=5,U.ndist=1+(31&re),re>>>=5,ae-=5,U.ncode=4+(15&re),re>>>=4,ae-=4,286<U.nlen||30<U.ndist){G.msg="too many length or distance symbols",U.mode=30;break}U.have=0,U.mode=18;case 18:for(;U.have<U.ncode;){for(;ae<3;){if(ce===0)break e;ce--,re+=J[j++]<<ae,ae+=8}U.lens[xe[U.have++]]=7&re,re>>>=3,ae-=3}for(;U.have<19;)U.lens[xe[U.have++]]=0;if(U.lencode=U.lendyn,U.lenbits=7,He={bits:U.lenbits},$e=l(0,U.lens,0,19,U.lencode,0,U.work,He),U.lenbits=He.bits,$e){G.msg="invalid code lengths set",U.mode=30;break}U.have=0,U.mode=19;case 19:for(;U.have<U.nlen+U.ndist;){for(;Se=(Ye=U.lencode[re&(1<<U.lenbits)-1])>>>16&255,Ie=65535&Ye,!((me=Ye>>>24)<=ae);){if(ce===0)break e;ce--,re+=J[j++]<<ae,ae+=8}if(Ie<16)re>>>=me,ae-=me,U.lens[U.have++]=Ie;else{if(Ie===16){for(we=me+2;ae<we;){if(ce===0)break e;ce--,re+=J[j++]<<ae,ae+=8}if(re>>>=me,ae-=me,U.have===0){G.msg="invalid bit length repeat",U.mode=30;break}pe=U.lens[U.have-1],Be=3+(3&re),re>>>=2,ae-=2}else if(Ie===17){for(we=me+3;ae<we;){if(ce===0)break e;ce--,re+=J[j++]<<ae,ae+=8}ae-=me,pe=0,Be=3+(7&(re>>>=me)),re>>>=3,ae-=3}else{for(we=me+7;ae<we;){if(ce===0)break e;ce--,re+=J[j++]<<ae,ae+=8}ae-=me,pe=0,Be=11+(127&(re>>>=me)),re>>>=7,ae-=7}if(U.have+Be>U.nlen+U.ndist){G.msg="invalid bit length repeat",U.mode=30;break}for(;Be--;)U.lens[U.have++]=pe}}if(U.mode===30)break;if(U.lens[256]===0){G.msg="invalid code -- missing end-of-block",U.mode=30;break}if(U.lenbits=9,He={bits:U.lenbits},$e=l(g,U.lens,0,U.nlen,U.lencode,0,U.work,He),U.lenbits=He.bits,$e){G.msg="invalid literal/lengths set",U.mode=30;break}if(U.distbits=6,U.distcode=U.distdyn,He={bits:U.distbits},$e=l(u,U.lens,U.nlen,U.ndist,U.distcode,0,U.work,He),U.distbits=He.bits,$e){G.msg="invalid distances set",U.mode=30;break}if(U.mode=20,H===6)break e;case 20:U.mode=21;case 21:if(6<=ce&&258<=ne){G.next_out=oe,G.avail_out=ne,G.next_in=j,G.avail_in=ce,U.hold=re,U.bits=ae,c(G,ue),oe=G.next_out,W=G.output,ne=G.avail_out,j=G.next_in,J=G.input,ce=G.avail_in,re=U.hold,ae=U.bits,U.mode===12&&(U.back=-1);break}for(U.back=0;Se=(Ye=U.lencode[re&(1<<U.lenbits)-1])>>>16&255,Ie=65535&Ye,!((me=Ye>>>24)<=ae);){if(ce===0)break e;ce--,re+=J[j++]<<ae,ae+=8}if(Se&&(240&Se)==0){for(Ke=me,We=Se,tt=Ie;Se=(Ye=U.lencode[tt+((re&(1<<Ke+We)-1)>>Ke)])>>>16&255,Ie=65535&Ye,!(Ke+(me=Ye>>>24)<=ae);){if(ce===0)break e;ce--,re+=J[j++]<<ae,ae+=8}re>>>=Ke,ae-=Ke,U.back+=Ke}if(re>>>=me,ae-=me,U.back+=me,U.length=Ie,Se===0){U.mode=26;break}if(32&Se){U.back=-1,U.mode=12;break}if(64&Se){G.msg="invalid literal/length code",U.mode=30;break}U.extra=15&Se,U.mode=22;case 22:if(U.extra){for(we=U.extra;ae<we;){if(ce===0)break e;ce--,re+=J[j++]<<ae,ae+=8}U.length+=re&(1<<U.extra)-1,re>>>=U.extra,ae-=U.extra,U.back+=U.extra}U.was=U.length,U.mode=23;case 23:for(;Se=(Ye=U.distcode[re&(1<<U.distbits)-1])>>>16&255,Ie=65535&Ye,!((me=Ye>>>24)<=ae);){if(ce===0)break e;ce--,re+=J[j++]<<ae,ae+=8}if((240&Se)==0){for(Ke=me,We=Se,tt=Ie;Se=(Ye=U.distcode[tt+((re&(1<<Ke+We)-1)>>Ke)])>>>16&255,Ie=65535&Ye,!(Ke+(me=Ye>>>24)<=ae);){if(ce===0)break e;ce--,re+=J[j++]<<ae,ae+=8}re>>>=Ke,ae-=Ke,U.back+=Ke}if(re>>>=me,ae-=me,U.back+=me,64&Se){G.msg="invalid distance code",U.mode=30;break}U.offset=Ie,U.extra=15&Se,U.mode=24;case 24:if(U.extra){for(we=U.extra;ae<we;){if(ce===0)break e;ce--,re+=J[j++]<<ae,ae+=8}U.offset+=re&(1<<U.extra)-1,re>>>=U.extra,ae-=U.extra,U.back+=U.extra}if(U.offset>U.dmax){G.msg="invalid distance too far back",U.mode=30;break}U.mode=25;case 25:if(ne===0)break e;if(Be=ue-ne,U.offset>Be){if((Be=U.offset-Be)>U.whave&&U.sane){G.msg="invalid distance too far back",U.mode=30;break}be=Be>U.wnext?(Be-=U.wnext,U.wsize-Be):U.wnext-Be,Be>U.length&&(Be=U.length),De=U.window}else De=W,be=oe-U.offset,Be=U.length;for(ne<Be&&(Be=ne),ne-=Be,U.length-=Be;W[oe++]=De[be++],--Be;);U.length===0&&(U.mode=21);break;case 26:if(ne===0)break e;W[oe++]=U.length,ne--,U.mode=21;break;case 27:if(U.wrap){for(;ae<32;){if(ce===0)break e;ce--,re|=J[j++]<<ae,ae+=8}if(ue-=ne,G.total_out+=ue,U.total+=ue,ue&&(G.adler=U.check=U.flags?a(U.check,W,ue,oe-ue):s(U.check,W,ue,oe-ue)),ue=ne,(U.flags?re:I(re))!==U.check){G.msg="incorrect data check",U.mode=30;break}ae=re=0}U.mode=28;case 28:if(U.wrap&&U.flags){for(;ae<32;){if(ce===0)break e;ce--,re+=J[j++]<<ae,ae+=8}if(re!==(4294967295&U.total)){G.msg="incorrect length check",U.mode=30;break}ae=re=0}U.mode=29;case 29:$e=1;break e;case 30:$e=-3;break e;case 31:return-4;default:return h}return G.next_out=oe,G.avail_out=ne,G.next_in=j,G.avail_in=ce,U.hold=re,U.bits=ae,(U.wsize||ue!==G.avail_out&&U.mode<30&&(U.mode<27||H!==4))&&N(G,G.output,G.next_out,ue-G.avail_out)?(U.mode=31,-4):(se-=G.avail_in,ue-=G.avail_out,G.total_in+=se,G.total_out+=ue,U.total+=ue,U.wrap&&ue&&(G.adler=U.check=U.flags?a(U.check,W,ue,G.next_out-ue):s(U.check,W,ue,G.next_out-ue)),G.data_type=U.bits+(U.last?64:0)+(U.mode===12?128:0)+(U.mode===20||U.mode===15?256:0),(se==0&&ue===0||H===4)&&$e===d&&($e=-5),$e)},r.inflateEnd=function(G){if(!G||!G.state)return h;var H=G.state;return H.window&&(H.window=null),G.state=null,d},r.inflateGetHeader=function(G,H){var U;return G&&G.state?(2&(U=G.state).wrap)==0?h:((U.head=H).done=!1,d):h},r.inflateSetDictionary=function(G,H){var U,J=H.length;return G&&G.state?(U=G.state).wrap!==0&&U.mode!==11?h:U.mode===11&&s(1,H,J,0)!==U.check?-3:N(G,H,J,J)?(U.mode=31,-4):(U.havedict=1,d):h},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,d,h,_,p,m,I){var C,f,E,B,x,b,P,M,k,N=I.bits,G=0,H=0,U=0,J=0,W=0,j=0,oe=0,ce=0,ne=0,re=0,ae=null,se=0,ue=new A.Buf16(16),Be=new A.Buf16(16),be=null,De=0;for(G=0;G<=15;G++)ue[G]=0;for(H=0;H<h;H++)ue[u[d+H]]++;for(W=N,J=15;1<=J&&ue[J]===0;J--);if(J<W&&(W=J),J===0)return _[p++]=20971520,_[p++]=20971520,I.bits=1,0;for(U=1;U<J&&ue[U]===0;U++);for(W<U&&(W=U),G=ce=1;G<=15;G++)if(ce<<=1,(ce-=ue[G])<0)return-1;if(0<ce&&(g===0||J!==1))return-1;for(Be[1]=0,G=1;G<15;G++)Be[G+1]=Be[G]+ue[G];for(H=0;H<h;H++)u[d+H]!==0&&(m[Be[u[d+H]]++]=H);if(b=g===0?(ae=be=m,19):g===1?(ae=s,se-=257,be=a,De-=257,256):(ae=c,be=l,-1),G=U,x=p,oe=H=re=0,E=-1,B=(ne=1<<(j=W))-1,g===1&&852<ne||g===2&&592<ne)return 1;for(;;){for(P=G-oe,k=m[H]<b?(M=0,m[H]):m[H]>b?(M=be[De+m[H]],ae[se+m[H]]):(M=96,0),C=1<<G-oe,U=f=1<<j;_[x+(re>>oe)+(f-=C)]=P<<24|M<<16|k|0,f!==0;);for(C=1<<G-1;re&C;)C>>=1;if(C!==0?(re&=C-1,re+=C):re=0,H++,--ue[G]==0){if(G===J)break;G=u[d+m[H]]}if(W<G&&(re&B)!==E){for(oe===0&&(oe=W),x+=U,ce=1<<(j=G-oe);j+oe<J&&!((ce-=ue[j+oe])<=0);)j++,ce<<=1;if(ne+=1<<j,g===1&&852<ne||g===2&&592<ne)return 1;_[E=re&B]=W<<24|j<<16|x-p|0}}return re!==0&&(_[x+re]=G-oe<<24|64<<16|0),I.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(Ye){for(var Re=Ye.length;0<=--Re;)Ye[Re]=0}var l=0,g=29,u=256,d=u+1+g,h=30,_=19,p=2*d+1,m=15,I=16,C=7,f=256,E=16,B=17,x=18,b=[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],P=[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],M=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],k=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],N=new Array(2*(d+2));c(N);var G=new Array(2*h);c(G);var H=new Array(512);c(H);var U=new Array(256);c(U);var J=new Array(g);c(J);var W,j,oe,ce=new Array(h);function ne(Ye,Re,xe,Oe,Me){this.static_tree=Ye,this.extra_bits=Re,this.extra_base=xe,this.elems=Oe,this.max_length=Me,this.has_stree=Ye&&Ye.length}function re(Ye,Re){this.dyn_tree=Ye,this.max_code=0,this.stat_desc=Re}function ae(Ye){return Ye<256?H[Ye]:H[256+(Ye>>>7)]}function se(Ye,Re){Ye.pending_buf[Ye.pending++]=255&Re,Ye.pending_buf[Ye.pending++]=Re>>>8&255}function ue(Ye,Re,xe){Ye.bi_valid>I-xe?(Ye.bi_buf|=Re<<Ye.bi_valid&65535,se(Ye,Ye.bi_buf),Ye.bi_buf=Re>>I-Ye.bi_valid,Ye.bi_valid+=xe-I):(Ye.bi_buf|=Re<<Ye.bi_valid&65535,Ye.bi_valid+=xe)}function Be(Ye,Re,xe){ue(Ye,xe[2*Re],xe[2*Re+1])}function be(Ye,Re){for(var xe=0;xe|=1&Ye,Ye>>>=1,xe<<=1,0<--Re;);return xe>>>1}function De(Ye,Re,xe){var Oe,Me,ze=new Array(m+1),je=0;for(Oe=1;Oe<=m;Oe++)ze[Oe]=je=je+xe[Oe-1]<<1;for(Me=0;Me<=Re;Me++){var st=Ye[2*Me+1];st!==0&&(Ye[2*Me]=be(ze[st]++,st))}}function me(Ye){var Re;for(Re=0;Re<d;Re++)Ye.dyn_ltree[2*Re]=0;for(Re=0;Re<h;Re++)Ye.dyn_dtree[2*Re]=0;for(Re=0;Re<_;Re++)Ye.bl_tree[2*Re]=0;Ye.dyn_ltree[2*f]=1,Ye.opt_len=Ye.static_len=0,Ye.last_lit=Ye.matches=0}function Se(Ye){8<Ye.bi_valid?se(Ye,Ye.bi_buf):0<Ye.bi_valid&&(Ye.pending_buf[Ye.pending++]=Ye.bi_buf),Ye.bi_buf=0,Ye.bi_valid=0}function Ie(Ye,Re,xe,Oe){var Me=2*Re,ze=2*xe;return Ye[Me]<Ye[ze]||Ye[Me]===Ye[ze]&&Oe[Re]<=Oe[xe]}function Ke(Ye,Re,xe){for(var Oe=Ye.heap[xe],Me=xe<<1;Me<=Ye.heap_len&&(Me<Ye.heap_len&&Ie(Re,Ye.heap[Me+1],Ye.heap[Me],Ye.depth)&&Me++,!Ie(Re,Oe,Ye.heap[Me],Ye.depth));)Ye.heap[xe]=Ye.heap[Me],xe=Me,Me<<=1;Ye.heap[xe]=Oe}function We(Ye,Re,xe){var Oe,Me,ze,je,st=0;if(Ye.last_lit!==0)for(;Oe=Ye.pending_buf[Ye.d_buf+2*st]<<8|Ye.pending_buf[Ye.d_buf+2*st+1],Me=Ye.pending_buf[Ye.l_buf+st],st++,Oe===0?Be(Ye,Me,Re):(Be(Ye,(ze=U[Me])+u+1,Re),(je=b[ze])!==0&&ue(Ye,Me-=J[ze],je),Be(Ye,ze=ae(--Oe),xe),(je=P[ze])!==0&&ue(Ye,Oe-=ce[ze],je)),st<Ye.last_lit;);Be(Ye,f,Re)}function tt(Ye,Re){var xe,Oe,Me,ze=Re.dyn_tree,je=Re.stat_desc.static_tree,st=Re.stat_desc.has_stree,ct=Re.stat_desc.elems,ut=-1;for(Ye.heap_len=0,Ye.heap_max=p,xe=0;xe<ct;xe++)ze[2*xe]!==0?(Ye.heap[++Ye.heap_len]=ut=xe,Ye.depth[xe]=0):ze[2*xe+1]=0;for(;Ye.heap_len<2;)ze[2*(Me=Ye.heap[++Ye.heap_len]=ut<2?++ut:0)]=1,Ye.depth[Me]=0,Ye.opt_len--,st&&(Ye.static_len-=je[2*Me+1]);for(Re.max_code=ut,xe=Ye.heap_len>>1;1<=xe;xe--)Ke(Ye,ze,xe);for(Me=ct;xe=Ye.heap[1],Ye.heap[1]=Ye.heap[Ye.heap_len--],Ke(Ye,ze,1),Oe=Ye.heap[1],Ye.heap[--Ye.heap_max]=xe,Ye.heap[--Ye.heap_max]=Oe,ze[2*Me]=ze[2*xe]+ze[2*Oe],Ye.depth[Me]=(Ye.depth[xe]>=Ye.depth[Oe]?Ye.depth[xe]:Ye.depth[Oe])+1,ze[2*xe+1]=ze[2*Oe+1]=Me,Ye.heap[1]=Me++,Ke(Ye,ze,1),2<=Ye.heap_len;);Ye.heap[--Ye.heap_max]=Ye.heap[1],(function(lt,Ct){var Dt,It,Nt,Lt,gn,un,Vt=Ct.dyn_tree,Ce=Ct.max_code,rt=Ct.stat_desc.static_tree,At=Ct.stat_desc.has_stree,Et=Ct.stat_desc.extra_bits,Ft=Ct.stat_desc.extra_base,Kt=Ct.stat_desc.max_length,ln=0;for(Lt=0;Lt<=m;Lt++)lt.bl_count[Lt]=0;for(Vt[2*lt.heap[lt.heap_max]+1]=0,Dt=lt.heap_max+1;Dt<p;Dt++)Kt<(Lt=Vt[2*Vt[2*(It=lt.heap[Dt])+1]+1]+1)&&(Lt=Kt,ln++),Vt[2*It+1]=Lt,Ce<It||(lt.bl_count[Lt]++,gn=0,Ft<=It&&(gn=Et[It-Ft]),un=Vt[2*It],lt.opt_len+=un*(Lt+gn),At&&(lt.static_len+=un*(rt[2*It+1]+gn)));if(ln!==0){do{for(Lt=Kt-1;lt.bl_count[Lt]===0;)Lt--;lt.bl_count[Lt]--,lt.bl_count[Lt+1]+=2,lt.bl_count[Kt]--,ln-=2}while(0<ln);for(Lt=Kt;Lt!==0;Lt--)for(It=lt.bl_count[Lt];It!==0;)Ce<(Nt=lt.heap[--Dt])||(Vt[2*Nt+1]!==Lt&&(lt.opt_len+=(Lt-Vt[2*Nt+1])*Vt[2*Nt],Vt[2*Nt+1]=Lt),It--)}})(Ye,Re),De(ze,ut,Ye.bl_count)}function pe(Ye,Re,xe){var Oe,Me,ze=-1,je=Re[1],st=0,ct=7,ut=4;for(je===0&&(ct=138,ut=3),Re[2*(xe+1)+1]=65535,Oe=0;Oe<=xe;Oe++)Me=je,je=Re[2*(Oe+1)+1],++st<ct&&Me===je||(st<ut?Ye.bl_tree[2*Me]+=st:Me!==0?(Me!==ze&&Ye.bl_tree[2*Me]++,Ye.bl_tree[2*E]++):st<=10?Ye.bl_tree[2*B]++:Ye.bl_tree[2*x]++,ze=Me,ut=(st=0)===je?(ct=138,3):Me===je?(ct=6,3):(ct=7,4))}function $e(Ye,Re,xe){var Oe,Me,ze=-1,je=Re[1],st=0,ct=7,ut=4;for(je===0&&(ct=138,ut=3),Oe=0;Oe<=xe;Oe++)if(Me=je,je=Re[2*(Oe+1)+1],!(++st<ct&&Me===je)){if(st<ut)for(;Be(Ye,Me,Ye.bl_tree),--st!=0;);else Me!==0?(Me!==ze&&(Be(Ye,Me,Ye.bl_tree),st--),Be(Ye,E,Ye.bl_tree),ue(Ye,st-3,2)):st<=10?(Be(Ye,B,Ye.bl_tree),ue(Ye,st-3,3)):(Be(Ye,x,Ye.bl_tree),ue(Ye,st-11,7));ze=Me,ut=(st=0)===je?(ct=138,3):Me===je?(ct=6,3):(ct=7,4)}}c(ce);var He=!1;function we(Ye,Re,xe,Oe){ue(Ye,(l<<1)+(Oe?1:0),3),(function(Me,ze,je,st){Se(Me),se(Me,je),se(Me,~je),A.arraySet(Me.pending_buf,Me.window,ze,je,Me.pending),Me.pending+=je})(Ye,Re,xe)}r._tr_init=function(Ye){He||((function(){var Re,xe,Oe,Me,ze,je=new Array(m+1);for(Me=Oe=0;Me<g-1;Me++)for(J[Me]=Oe,Re=0;Re<1<<b[Me];Re++)U[Oe++]=Me;for(U[Oe-1]=Me,Me=ze=0;Me<16;Me++)for(ce[Me]=ze,Re=0;Re<1<<P[Me];Re++)H[ze++]=Me;for(ze>>=7;Me<h;Me++)for(ce[Me]=ze<<7,Re=0;Re<1<<P[Me]-7;Re++)H[256+ze++]=Me;for(xe=0;xe<=m;xe++)je[xe]=0;for(Re=0;Re<=143;)N[2*Re+1]=8,Re++,je[8]++;for(;Re<=255;)N[2*Re+1]=9,Re++,je[9]++;for(;Re<=279;)N[2*Re+1]=7,Re++,je[7]++;for(;Re<=287;)N[2*Re+1]=8,Re++,je[8]++;for(De(N,d+1,je),Re=0;Re<h;Re++)G[2*Re+1]=5,G[2*Re]=be(Re,5);W=new ne(N,b,u+1,d,m),j=new ne(G,P,0,h,m),oe=new ne(new Array(0),M,0,_,C)})(),He=!0),Ye.l_desc=new re(Ye.dyn_ltree,W),Ye.d_desc=new re(Ye.dyn_dtree,j),Ye.bl_desc=new re(Ye.bl_tree,oe),Ye.bi_buf=0,Ye.bi_valid=0,me(Ye)},r._tr_stored_block=we,r._tr_flush_block=function(Ye,Re,xe,Oe){var Me,ze,je=0;0<Ye.level?(Ye.strm.data_type===2&&(Ye.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})(Ye)),tt(Ye,Ye.l_desc),tt(Ye,Ye.d_desc),je=(function(st){var ct;for(pe(st,st.dyn_ltree,st.l_desc.max_code),pe(st,st.dyn_dtree,st.d_desc.max_code),tt(st,st.bl_desc),ct=_-1;3<=ct&&st.bl_tree[2*k[ct]+1]===0;ct--);return st.opt_len+=3*(ct+1)+5+5+4,ct})(Ye),Me=Ye.opt_len+3+7>>>3,(ze=Ye.static_len+3+7>>>3)<=Me&&(Me=ze)):Me=ze=xe+5,xe+4<=Me&&Re!==-1?we(Ye,Re,xe,Oe):Ye.strategy===4||ze===Me?(ue(Ye,2+(Oe?1:0),3),We(Ye,N,G)):(ue(Ye,4+(Oe?1:0),3),(function(st,ct,ut,lt){var Ct;for(ue(st,ct-257,5),ue(st,ut-1,5),ue(st,lt-4,4),Ct=0;Ct<lt;Ct++)ue(st,st.bl_tree[2*k[Ct]+1],3);$e(st,st.dyn_ltree,ct-1),$e(st,st.dyn_dtree,ut-1)})(Ye,Ye.l_desc.max_code+1,Ye.d_desc.max_code+1,je+1),We(Ye,Ye.dyn_ltree,Ye.dyn_dtree)),me(Ye),Oe&&Se(Ye)},r._tr_tally=function(Ye,Re,xe){return Ye.pending_buf[Ye.d_buf+2*Ye.last_lit]=Re>>>8&255,Ye.pending_buf[Ye.d_buf+2*Ye.last_lit+1]=255&Re,Ye.pending_buf[Ye.l_buf+Ye.last_lit]=255&xe,Ye.last_lit++,Re===0?Ye.dyn_ltree[2*xe]++:(Ye.matches++,Re--,Ye.dyn_ltree[2*(U[xe]+u+1)]++,Ye.dyn_dtree[2*ae(Re)]++),Ye.last_lit===Ye.lit_bufsize-1},r._tr_align=function(Ye){ue(Ye,2,3),Be(Ye,f,N),(function(Re){Re.bi_valid===16?(se(Re,Re.bi_buf),Re.bi_buf=0,Re.bi_valid=0):8<=Re.bi_valid&&(Re.pending_buf[Re.pending++]=255&Re.bi_buf,Re.bi_buf>>=8,Re.bi_valid-=8)})(Ye)}},{"../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,d=1,h={},_=!1,p=s.document,m=Object.getPrototypeOf&&Object.getPrototypeOf(s);m=m&&m.setTimeout?m:s,c={}.toString.call(s.process)==="[object process]"?function(E){n.nextTick(function(){C(E)})}:(function(){if(s.postMessage&&!s.importScripts){var E=!0,B=s.onmessage;return s.onmessage=function(){E=!1},s.postMessage("","*"),s.onmessage=B,E}})()?(u="setImmediate$"+Math.random()+"$",s.addEventListener?s.addEventListener("message",f,!1):s.attachEvent("onmessage",f),function(E){s.postMessage(u+E,"*")}):s.MessageChannel?((g=new MessageChannel).port1.onmessage=function(E){C(E.data)},function(E){g.port2.postMessage(E)}):p&&"onreadystatechange"in p.createElement("script")?(l=p.documentElement,function(E){var B=p.createElement("script");B.onreadystatechange=function(){C(E),B.onreadystatechange=null,l.removeChild(B),B=null},l.appendChild(B)}):function(E){setTimeout(C,0,E)},m.setImmediate=function(E){typeof E!="function"&&(E=new Function(""+E));for(var B=new Array(arguments.length-1),x=0;x<B.length;x++)B[x]=arguments[x+1];var b={callback:E,args:B};return h[d]=b,c(d),d++},m.clearImmediate=I}function I(E){delete h[E]}function C(E){if(_)setTimeout(C,0,E);else{var B=h[E];if(B){_=!0;try{(function(x){var b=x.callback,P=x.args;switch(P.length){case 0:b();break;case 1:b(P[0]);break;case 2:b(P[0],P[1]);break;case 3:b(P[0],P[1],P[2]);break;default:b.apply(a,P)}})(B)}finally{I(E),_=!1}}}}function f(E){E.source===s&&typeof E.data=="string"&&E.data.indexOf(u)===0&&C(+E.data.slice(u.length))}})(typeof self>"u"?A===void 0?this:A:self)}).call(this,typeof KO<"u"?KO:typeof self<"u"?self:typeof window<"u"?window:{})},{}]},{},[10])(10)})})(pMe)),pMe.exports}var LPo=FPo();const IMe=vE(LPo),HPo=async({circuitJson:t,projectName:e})=>{await ns.promise((async()=>{const n=new IMe,[{stringifyGerberCommandLayers:o,convertSoupToGerberCommands:i,convertSoupToExcellonDrillCommands:r,stringifyExcellonDrill:A},{convertCircuitJsonToBomRows:s,convertBomRowsToCsv:a},{convertCircuitJsonToPickAndPlaceCsv:c}]=await Promise.all([xB("circuit-json-to-gerber"),xB("circuit-json-to-bom-csv"),xB("circuit-json-to-pnp-csv")]),l=t.filter(C=>!("error_type"in C)&&!("warning_type"in C)),g=i(l,{flip_y_axis:!1}),u=o(g);for(const[C,f]of Object.entries(u))n.file(`gerber/${C}.gbr`,f);const d=r({circuitJson:l,is_plated:!0,flip_y_axis:!1}),h=A(d);n.file("gerber/drill.drl",h);const _=await s({circuitJson:t}),p=await a(_);n.file("bom.csv",p);const m=await c(t);n.file("pick_and_place.csv",m);const I=await n.generateAsync({type:"blob"});fQ(I,{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)}`})},GPo=async({circuitJson:t,projectName:e})=>{let n;try{const{convertCircuitJsonToGltf:o}=await xB("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}fQ(n,{fileName:`${e}.glb`})},OPo=async({circuitJson:t,libraryName:e})=>{const{CircuitJsonToKicadLibraryConverter:n}=await xB("circuit-json-to-kicad"),o=new n(t,{libraryName:e,footprintLibraryName:e});o.runUntilFinished();const i=o.getOutput(),r=new IMe;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}
5788
5788
  `)}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},KPo=async({circuitJson:t,projectName:e})=>{await ns.promise((async()=>{const o=await(await OPo({circuitJson:t,libraryName:e})).generateAsync({type:"blob"});fQ(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)}`})},UPo=async({circuitJson:t,projectName:e})=>{const{CircuitJsonToKicadPcbConverter:n,CircuitJsonToKicadSchConverter:o,CircuitJsonToKicadProConverter:i,resolveAndLoadKicad3dModelFiles:r}=await xB("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 IMe;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:d,content:h})=>{u.file(d,h)},onError:({sourcePath:d})=>{console.warn(`Failed to load 3D model from ${d}`)}}),u},YPo=async({circuitJson:t,projectName:e})=>{await ns.promise((async()=>{const o=await(await UPo({circuitJson:t,projectName:e})).generateAsync({type:"blob"});fQ(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)}`})},Dwt=async({circuitJson:t,projectName:e,options:n={}})=>{try{const{convertCircuitJsonToLbrn:o}=await xB("circuit-json-to-lbrn"),r=(await o(t,{includeSilkscreen:n.includeSilkscreen??!1,includeOxidationCleaningLayer:n.includeOxidationCleaningLayer??!0})).toXml(),A=new Blob([r],{type:"application/lbrn"});fQ(A,{fileName:`${e}.lbrn2`})}catch(o){const i=o instanceof Error?o.message:"Unknown error";ns.error(`Failed to export to LBRN format: ${i}`)}},VPo=async({circuitJson:t,projectName:e})=>{const{convertCircuitJsonToPinoutSvg:n}=await xB("circuit-to-svg"),o=n(t);fQ(o,{fileName:`${e}-pinout.svg`,mimeType:"image/svg+xml"})},zPo=async({circuitJson:t,projectName:e})=>{const{circuitJsonToStep:n}=await xB("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){ns.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";ns.error(`Failed to convert circuit to STEP format: ${l}`);return}const a=new Blob([s],{type:"application/step"});try{fQ(a,{fileName:`${e}.step`})}catch(c){const l=c instanceof Error?c.message:"Unknown error";ns.error(`Failed to download STEP file: ${l}`)}},JPo=[{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"}],qPo=async({exportName:t,circuitJson:e,simpleRouteJson:n,projectName:o})=>{const i=mPt(o);if(t==="Fabrication Files"){await HPo({circuitJson:e,projectName:i});return}if(t==="KiCad Project"){await YPo({circuitJson:e,projectName:i});return}if(t==="KiCad Library"){await KPo({circuitJson:e,projectName:i});return}if(t==="Circuit JSON"){fQ(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");fQ(JSON.stringify(n,null,2),{fileName:`${i}.simple-route.json`,mimeType:"application/json"});return}if(t==="GLB (Binary GLTF)"){await GPo({circuitJson:e,projectName:i});return}if(t==="Pinout SVG"){VPo({circuitJson:e,projectName:i});return}if(t==="STEP"){await zPo({circuitJson:e,projectName:i});return}if(t==="LightBurn"){await Dwt({circuitJson:e,projectName:i});return}throw new Error(`Unsupported export type: "${t}"`)},WPo=({packageName:t,onSelectReview:e})=>{const n=EQ(g=>g.fsMap),o=EQ(g=>g.circuitJson),[i,r]=ee.useState([]),[A,s]=ee.useState(!1),[a,c]=ee.useState(!1);ee.useEffect(()=>{!t||!GK()||(s(!0),OK.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),ns.error("Failed to load AI reviews")}).finally(()=>s(!1)))},[t]);const l=async()=>{if(!o){ns.error("Need Circuit JSON to Request AI Review");return}if(!GK()){ns.error("Missing registry token");return}c(!0);try{const{ai_review:g}=await OK.post("ai_reviews/create",{json:{package_name:t??"unknown",fs_map:Object.fromEntries(n),circuit_json:o}}).json();r(u=>[g,...u]),e(g),ns.success("AI review requested")}catch(g){console.error("Failed to create AI review",g),ns.error("Failed to request AI review")}finally{c(!1)}};return q.jsxs(q.Fragment,{children:[q.jsxs(_N,{children:[q.jsx(mN,{children:"AI Review"}),q.jsx(VG,{children:"Select an AI review or request a new one."})]}),q.jsx("div",{className:"rf-flex rf-gap-4 rf-mt-4",children:q.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?q.jsx("div",{className:"rf-text-sm",children:"Loading..."}):i.length>0?i.map(g=>q.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)):q.jsx("div",{className:"rf-text-sm rf-text-muted-foreground",children:"No AI reviews found."})})}),q.jsx(YG,{className:"rf-mt-4",children:q.jsx(cc,{onClick:l,disabled:a,children:a?"Requesting...":"Review my Board"})})]})};function CMe(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var cw=CMe();function Mwt(t){cw=t}var qG={exec:()=>null};function el(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(nf.caret,"$1"),n=n.replace(i,A),o},getRegex:()=>new RegExp(n,e)};return o}var nf={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")},jPo=/^(?:[ \t]*(?:\n|$))+/,XPo=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,$Po=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,WG=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,ZPo=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,fMe=/(?:[*+-]|\d{1,9}[.)])/,Pwt=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,wwt=el(Pwt).replace(/bull/g,fMe).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(),ewo=el(Pwt).replace(/bull/g,fMe).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(),yMe=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,two=/^[^\n]+/,EMe=/(?!\s*\])(?:\\.|[^\[\]\\])+/,nwo=el(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",EMe).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),owo=el(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,fMe).getRegex(),Pte="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",BMe=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,iwo=el("^ {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",BMe).replace("tag",Pte).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),vwt=el(yMe).replace("hr",WG).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",Pte).getRegex(),rwo=el(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",vwt).getRegex(),xMe={blockquote:rwo,code:XPo,def:nwo,fences:$Po,heading:ZPo,hr:WG,html:iwo,lheading:wwt,list:owo,newline:jPo,paragraph:vwt,table:qG,text:two},Nwt=el("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",WG).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",Pte).getRegex(),Awo={...xMe,lheading:ewo,table:Nwt,paragraph:el(yMe).replace("hr",WG).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",Nwt).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",Pte).getRegex()},swo={...xMe,html:el(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",BMe).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:qG,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:el(yMe).replace("hr",WG).replace("heading",` *#{1,6} *[^
5789
5789
  ]`).replace("lheading",wwt).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},awo=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,cwo=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,Rwt=/^( {2,}|\\)\n(?!\s*$)/,lwo=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,wte=/[\p{P}\p{S}]/u,QMe=/[\s\p{P}\p{S}]/u,Twt=/[^\s\p{P}\p{S}]/u,gwo=el(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,QMe).getRegex(),kwt=/(?!~)[\p{P}\p{S}]/u,uwo=/(?!~)[\s\p{P}\p{S}]/u,hwo=/(?:[^\s\p{P}\p{S}]|~)/u,dwo=/\[[^[\]]*?\]\((?:\\.|[^\\\(\)]|\((?:\\.|[^\\\(\)])*\))*\)|`[^`]*?`|<[^<>]*?>/g,Fwt=/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,_wo=el(Fwt,"u").replace(/punct/g,wte).getRegex(),mwo=el(Fwt,"u").replace(/punct/g,kwt).getRegex(),Lwt="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",pwo=el(Lwt,"gu").replace(/notPunctSpace/g,Twt).replace(/punctSpace/g,QMe).replace(/punct/g,wte).getRegex(),Iwo=el(Lwt,"gu").replace(/notPunctSpace/g,hwo).replace(/punctSpace/g,uwo).replace(/punct/g,kwt).getRegex(),Cwo=el("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,Twt).replace(/punctSpace/g,QMe).replace(/punct/g,wte).getRegex(),fwo=el(/\\(punct)/,"gu").replace(/punct/g,wte).getRegex(),ywo=el(/^<(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(),Ewo=el(BMe).replace("(?:-->|$)","-->").getRegex(),Bwo=el("^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",Ewo).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),vte=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,xwo=el(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]*(?:\n[ \t]*)?)(title))?\s*\)/).replace("label",vte).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),Hwt=el(/^!?\[(label)\]\[(ref)\]/).replace("label",vte).replace("ref",EMe).getRegex(),Gwt=el(/^!?\[(ref)\](?:\[\])?/).replace("ref",EMe).getRegex(),Qwo=el("reflink|nolink(?!\\()","g").replace("reflink",Hwt).replace("nolink",Gwt).getRegex(),SMe={_backpedal:qG,anyPunctuation:fwo,autolink:ywo,blockSkip:dwo,br:Rwt,code:cwo,del:qG,emStrongLDelim:_wo,emStrongRDelimAst:pwo,emStrongRDelimUnd:Cwo,escape:awo,link:xwo,nolink:Gwt,punctuation:gwo,reflink:Hwt,reflinkSearch:Qwo,tag:Bwo,text:lwo,url:qG},Swo={...SMe,link:el(/^!?\[(label)\]\((.*?)\)/).replace("label",vte).getRegex(),reflink:el(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",vte).getRegex()},bMe={...SMe,emStrongRDelimAst:Iwo,emStrongLDelim:mwo,url:el(/^((?: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.!#$%&'*+\/=?_`{\|}~-]+@)))/},bwo={...bMe,br:el(Rwt).replace("{2,}","*").getRegex(),text:el(bMe.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},Nte={normal:xMe,gfm:Awo,pedantic:swo},jG={normal:SMe,gfm:bMe,breaks:bwo,pedantic:Swo},Dwo={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},Owt=t=>Dwo[t];function BQ(t,e){if(e){if(nf.escapeTest.test(t))return t.replace(nf.escapeReplace,Owt)}else if(nf.escapeTestNoEncode.test(t))return t.replace(nf.escapeReplaceNoEncode,Owt);return t}function Kwt(t){try{t=encodeURI(t).replace(nf.percentDecode,"%")}catch{return null}return t}function Uwt(t,e){const n=t.replace(nf.findPipe,(r,A,s)=>{let a=!1,c=A;for(;--c>=0&&s[c]==="\\";)a=!a;return a?"|":" |"}),o=n.split(nf.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(nf.slashPipe,"|");return o}function XG(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 Mwo(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 Ywt(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 Pwo(t,e,n){const o=t.match(n.other.indentCodeCompensation);if(o===null)return e;const i=o[1];return e.split(`