@tscircuit/runframe 0.0.1803 → 0.0.1804
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.
|
@@ -5671,7 +5671,7 @@ test("${l} should solve problem correctly", () => {
|
|
|
5671
5671
|
// Add more specific assertions based on expected output
|
|
5672
5672
|
// expect(solver.netLabelPlacementSolver!.netLabelPlacements).toMatchInlineSnapshot()
|
|
5673
5673
|
})
|
|
5674
|
-
`,d=new Blob([u],{type:"text/plain"}),h=URL.createObjectURL(d),f=document.createElement("a");f.href=h,f.download=`${l}.test.ts`,f.click(),URL.revokeObjectURL(h)}catch(c){alert(`Error generating test.ts for ${t.constructor.name}: ${c instanceof Error?c.message:String(c)}`)}r(!1)};return G.jsxs("div",{className:`relative ${e}`,ref:i,children:[G.jsx("button",{className:"px-2 py-1 rounded text-xs cursor-pointer",onClick:()=>r(!n),title:`Download options for ${t.constructor.name}`,children:t.constructor.name}),n&&G.jsxs("div",{className:"absolute top-full left-0 mt-1 bg-white border border-gray-300 rounded shadow-lg z-10 min-w-[150px]",children:[G.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:o,children:"Download JSON"}),G.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:s,children:"Download page.tsx"}),G.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:a,children:"Download test.ts"})]})]})},f0t=t=>t.activeSubSolver?[t,...f0t(t.activeSubSolver)]:[t],mXn=({solver:t})=>{const e=f0t(t);return G.jsx("div",{className:"flex gap-1 items-center text-sm pt-1",children:e.map((n,r)=>G.jsxs("div",{className:"flex items-center",children:[r>0&&G.jsx("span",{className:"text-gray-400 mx-1",children:"→"}),G.jsx(fXn,{solver:n})]},n.constructor.name))})},yXn=({solver:t,triggerRender:e,animationSpeed:n=25,onSolverStarted:r,onSolverCompleted:i})=>{const[o,s]=te.useReducer(m=>!m,!1),a=te.useRef(void 0),c=()=>{!t.solved&&!t.failed&&(t.step(),e())},l=()=>{!t.solved&&!t.failed&&(r&&r(t),t.solve(),e(),i&&i(t))},u=()=>{o?(a.current&&(clearInterval(a.current),a.current=void 0),s()):(s(),a.current=setInterval(()=>{if(t.solved||t.failed){a.current&&(clearInterval(a.current),a.current=void 0),s(),e(),i&&t.solved&&i(t);return}t.step(),e()},n))},d=()=>{const m=t;if(m.getCurrentPhase&&!t.solved&&!t.failed){const g=m.getCurrentPhase();for(;m.getCurrentPhase()===g&&!t.solved&&!t.failed;)t.step();e()}},h=()=>{if(t.solved||t.failed||o)return;const m=window.prompt("Step until which iteration?",`${t.iterations}`);if(m===null)return;const g=Number(m);if(!Number.isFinite(g)){window.alert("Please enter a valid number for the iteration");return}for(;t.iterations<g&&!t.solved&&!t.failed;)t.step();e(),t.solved&&i&&i(t)};te.useEffect(()=>()=>{a.current&&clearInterval(a.current)},[]),te.useEffect(()=>{(t.solved||t.failed)&&o&&(a.current&&(clearInterval(a.current),a.current=void 0),s())},[t.solved,t.failed,o]);const f=t.getCurrentPhase!==void 0,p=f?t.getCurrentPhase():null;return G.jsxs("div",{className:"space-y-2 p-2 border-b",children:[G.jsx("div",{className:"flex items-center",children:G.jsx(mXn,{solver:t})}),G.jsxs("div",{className:"flex gap-2 items-center flex-wrap",children:[G.jsx("button",{onClick:c,disabled:t.solved||t.failed||o,className:"bg-blue-500 hover:bg-blue-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Step"}),G.jsx("button",{onClick:l,disabled:t.solved||t.failed||o,className:"bg-green-500 hover:bg-green-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Solve"}),G.jsx("button",{onClick:u,disabled:t.solved||t.failed,className:`px-3 py-1 rounded text-white text-sm ${o?"bg-red-500 hover:bg-red-600":"bg-yellow-500 hover:bg-yellow-600"} disabled:bg-gray-300`,children:o?"Stop":"Animate"}),G.jsx("button",{onClick:h,disabled:t.solved||t.failed||o,className:"bg-orange-500 hover:bg-orange-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Step Until Iteration"}),f&&G.jsx("button",{onClick:d,disabled:t.solved||t.failed||o,className:"bg-purple-500 hover:bg-purple-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Next Stage"}),G.jsxs("div",{className:"text-sm text-gray-600",children:["Iterations: ",t.iterations]}),t.timeToSolve!==void 0&&G.jsxs("div",{className:"text-sm text-gray-600",children:["Time: ",(t.timeToSolve/1e3).toFixed(3),"s"]}),p&&G.jsxs("div",{className:"text-sm text-gray-600",children:["Phase: ",G.jsx("span",{className:"font-medium",children:p})]}),t.solved&&G.jsx("div",{className:"px-2 py-1 bg-green-100 text-green-800 rounded text-sm",children:"Solved"}),t.failed&&G.jsx("div",{className:"px-2 py-1 bg-red-100 text-red-800 rounded text-sm",children:"Failed"})]}),t.error&&G.jsxs("div",{className:"text-red-600 text-sm",children:["Error: ",t.error]})]})},gXn=(t,e,n)=>{const r=t.currentPipelineStepIndex;return e<r?"Completed":e===r&&t.activeSubSolver?t.activeSubSolver.failed?"Failed":"In Progress":"Not Started"},_Xn=(t,e)=>{const r=t.pipelineDef[e].solverName,i=gXn(t,e),o=t[r],s=t.firstIterationOfPhase?.[r]??null,a=t.iterations;let c=0;if(i==="Completed"){const h=t.pipelineDef[e+1],f=h?t.firstIterationOfPhase?.[h.solverName]:void 0;f!==void 0&&s!==null?c=f-s:s!==null&&(c=a-s)}else i==="In Progress"&&s!==null&&(c=a-s);const l=t.timeSpentOnPhase?.[r]??0;let u=0;i==="Completed"?u=1:i==="In Progress"&&o&&(u=o.progress??0);const d=o?.stats??null;return{index:e,name:r,status:i,firstIteration:s,iterations:c,progress:u,timeSpent:l,stats:d&&Object.keys(d).length>0?d:null,solverInstance:o??null}},xXn=({status:t})=>{const e={"Not Started":"text-blue-600","In Progress":"text-yellow-600",Completed:"text-green-600",Failed:"text-red-600"};return G.jsx("span",{className:`font-medium ${e[t]}`,children:t})},bXn=({progress:t})=>{if(t===0)return null;const e=Math.round(t*100);return G.jsxs("div",{className:"flex items-center gap-2",children:[G.jsx("div",{className:"w-20 h-2 bg-gray-200 rounded overflow-hidden",children:G.jsx("div",{className:"h-full bg-blue-500 transition-all duration-200",style:{width:`${e}%`}})}),G.jsxs("span",{className:"text-xs text-gray-500",children:[e,"%"]})]})},vXn=t=>Object.entries(t).map(([e,n])=>`${e}: ${n}`).join(", "),wXn=({stats:t})=>{if(!t||Object.keys(t).length===0)return G.jsx("span",{children:"-"});const e=Object.entries(t),n=vXn(t);return G.jsxs("details",{className:"cursor-pointer",children:[G.jsx("summary",{className:"whitespace-nowrap overflow-hidden text-ellipsis max-w-[200px]",children:n}),G.jsx("div",{className:"mt-1 text-xs",children:e.map(([r,i])=>G.jsxs("div",{children:[r,": ",String(i)]},r))})]})},Z_e=t=>{if(t===null||typeof t!="object")return t;if(Array.isArray(t))return t.map(Z_e);const e={};for(const[n,r]of Object.entries(t))n.startsWith("_")||(e[n]=Z_e(r));return e},SXn=(t,e)=>{try{if(typeof t.getConstructorParams!="function"){alert(`getConstructorParams() is not implemented for ${e}`);return}const n=Z_e(t.getConstructorParams()),r=new Blob([JSON.stringify(n,null,2)],{type:"application/json"}),i=URL.createObjectURL(r),o=document.createElement("a");o.href=i,o.download=`${e}_input.json`,o.click(),URL.revokeObjectURL(i)}catch(n){alert(`Error downloading input for ${e}: ${n instanceof Error?n.message:String(n)}`)}},MXn=({solver:t,onStepUntilPhase:e,onDownloadInput:n})=>{const r=t.pipelineDef.map((a,c)=>_Xn(t,c)),i=a=>{e?.(a)},o=a=>{a.solverInstance&&(n?n(a.solverInstance,a.name):SXn(a.solverInstance,a.name))},s=a=>`${(a/1e3).toFixed(2)}s`;return G.jsxs("div",{className:"border-t border-gray-200",children:[G.jsx("div",{className:"px-4 py-2 bg-gray-50 border-b border-gray-200",children:G.jsx("h3",{className:"text-sm font-semibold text-gray-700",children:"Pipeline Steps"})}),G.jsx("div",{className:"overflow-x-auto",children:G.jsxs("table",{className:"w-full text-sm",children:[G.jsx("thead",{children:G.jsxs("tr",{className:"bg-gray-50 border-b border-gray-200",children:[G.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Step"}),G.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Status"}),G.jsxs("th",{className:"px-4 py-2 text-center font-semibold text-gray-700",children:["i",G.jsx("sub",{children:"0"})]}),G.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Iterations"}),G.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Progress"}),G.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Time"}),G.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Stats"}),G.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Input"})]})}),G.jsx("tbody",{children:r.map(a=>G.jsxs("tr",{className:`border-b border-gray-100 ${a.status==="In Progress"?"bg-yellow-50":""}`,children:[G.jsx("td",{className:"px-4 py-2",children:G.jsxs("div",{className:"flex items-center gap-2",children:[G.jsx("span",{className:"text-gray-400 w-6",children:String(a.index+1).padStart(2,"0")}),G.jsx("button",{onClick:()=>i(a.name),disabled:a.status==="Completed"||t.solved||t.failed,className:"text-blue-500 hover:text-blue-700 disabled:text-gray-300 disabled:cursor-not-allowed",title:`Step until ${a.name} completes`,children:G.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:G.jsx("path",{fillRule:"evenodd",d:"M4.5 5.653c0-1.426 1.529-2.33 2.779-1.643l11.54 6.348c1.295.712 1.295 2.573 0 3.285L7.28 19.991c-1.25.687-2.779-.217-2.779-1.643V5.653z",clipRule:"evenodd"})})}),G.jsx("span",{className:"font-medium text-gray-900",children:a.name})]})}),G.jsx("td",{className:"px-4 py-2",children:G.jsx(xXn,{status:a.status})}),G.jsx("td",{className:"px-4 py-2 text-center text-gray-600",children:a.firstIteration!==null?a.firstIteration:""}),G.jsx("td",{className:"px-4 py-2 text-gray-600",children:a.iterations}),G.jsx("td",{className:"px-4 py-2",children:G.jsx(bXn,{progress:a.progress})}),G.jsx("td",{className:"px-4 py-2 text-gray-600",children:s(a.timeSpent)}),G.jsx("td",{className:"px-4 py-2 text-gray-500",children:G.jsx(wXn,{stats:a.stats})}),G.jsx("td",{className:"px-4 py-2",children:a.solverInstance?G.jsxs("button",{onClick:()=>o(a),className:"flex items-center gap-1 text-blue-500 hover:text-blue-700",title:`Download input for ${a.name}`,children:[G.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:G.jsx("path",{fillRule:"evenodd",d:"M12 2.25a.75.75 0 01.75.75v11.69l3.22-3.22a.75.75 0 111.06 1.06l-4.5 4.5a.75.75 0 01-1.06 0l-4.5-4.5a.75.75 0 111.06-1.06l3.22 3.22V3a.75.75 0 01.75-.75zm-9 13.5a.75.75 0 01.75.75v2.25a1.5 1.5 0 001.5 1.5h13.5a1.5 1.5 0 001.5-1.5V16.5a.75.75 0 011.5 0v2.25a3 3 0 01-3 3H5.25a3 3 0 01-3-3V16.5a.75.75 0 01.75-.75z",clipRule:"evenodd"})}),G.jsx("span",{children:"Input"})]}):null})]},a.name))})]})})]})},TXn=class extends si.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 EXn({graphics:t}){const e=t.points??[],n=t.lines??[],r=t.rects??[],i=t.circles??[],o=t.texts??[];let s=Number.POSITIVE_INFINITY,a=Number.POSITIVE_INFINITY,c=Number.NEGATIVE_INFINITY,l=Number.NEGATIVE_INFINITY;const u=(g,y)=>{typeof g=="number"&&(g<s&&(s=g),g>c&&(c=g)),typeof y=="number"&&(y<a&&(a=y),y>l&&(l=y))};for(const g of e)u(g.x,g.y);for(const g of n){const y=g.points??[];for(const _ of y)u(_.x,_.y)}for(const g of r){const y=g.x??0,_=g.y??0,x=g.width??0,b=g.height??0;u(y,_),u(y+x,_+b)}for(const g of i){const y=g.x??0,_=g.y??0,x=g.radius??1;u(y-x,_-x),u(y+x,_+x)}for(const g of o)u(g.x,g.y);(!isFinite(s)||!isFinite(a)||!isFinite(c)||!isFinite(l))&&(s=-20,a=-20,c=20,l=20);const d=10,h=s-d,f=a-d,p=Math.max(1,c-s+2*d),m=Math.max(1,l-a+2*d);return G.jsxs("svg",{className:"w-full h-[400px] bg-white",viewBox:`${h} ${f} ${p} ${m}`,role:"img","aria-label":"Graphics fallback",children:[r.map((g,y)=>G.jsx("rect",{x:g.x??0,y:g.y??0,width:g.width??0,height:g.height??0,fill:"none",stroke:g.strokeColor??"black",strokeWidth:g.strokeWidth??1},`rect-${y}`)),n.map((g,y)=>G.jsx("polyline",{fill:"none",stroke:g.strokeColor??"black",strokeWidth:g.strokeWidth??1,points:(g.points??[]).map(_=>`${_.x??0},${_.y??0}`).join(" ")},`line-${y}`)),i.map((g,y)=>G.jsx("circle",{cx:g.x??0,cy:g.y??0,r:g.radius??1.5,fill:g.fillColor??"none",stroke:g.strokeColor??"black",strokeWidth:g.strokeWidth??1},`circle-${y}`)),e.map((g,y)=>G.jsx("circle",{cx:g.x??0,cy:g.y??0,r:g.radius??1.5,fill:g.color??"black"},`point-${y}`)),o.map((g,y)=>G.jsx("text",{x:g.x??0,y:g.y??0,fontSize:g.fontSize??10,fill:g.color??"black",children:g.text??""},`text-${y}`))]})}var CXn=({solver:t,animationSpeed:e=25,onSolverStarted:n,onSolverCompleted:r})=>{const[i,o]=te.useReducer(u=>u+1,0),s=te.useMemo(()=>{try{return t.visualize()||{points:[],lines:[],rects:[],circles:[]}}catch(u){return console.error("Visualization error:",u),{points:[],lines:[],rects:[],circles:[]}}},[t,i]),a=te.useMemo(()=>(s.rects?.length||0)===0&&(s.lines?.length||0)===0&&(s.points?.length||0)===0&&(s.circles?.length||0)===0,[s]);te.useEffect(()=>{if(!(typeof document>"u")&&!document.querySelector('script[src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4"]')){const u=document.createElement("script");u.src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4",document.head.appendChild(u)}},[]);const c=t.pipelineDef!==void 0,l=u=>{const d=t;if(!t.solved&&!t.failed){for(;!t.solved&&!t.failed&&d.currentPipelineStepIndex<=d.pipelineDef.findIndex(h=>h.solverName===u);)t.step();o()}};return G.jsxs("div",{children:[G.jsx(yXn,{solver:t,triggerRender:o,animationSpeed:e,onSolverStarted:n,onSolverCompleted:r}),a?G.jsx("div",{className:"p-4 text-gray-500",children:"No Graphics Yet"}):G.jsx(TXn,{fallback:G.jsx(EXn,{graphics:s}),children:G.jsx(pXn,{graphics:s})}),c&&G.jsx(MXn,{solver:t,onStepUntilPhase:l})]})};const PXn=()=>{te.useEffect(()=>{const t="tailwind-cdn-script";if(document.getElementById(t)||window.tailwind)return;const e=document.createElement("div");e.className="hidden",document.body.appendChild(e);const n=window.getComputedStyle(e).display==="none";if(document.body.removeChild(e),n)return;const r=document.createElement("script");r.id=t,r.src="https://cdn.tailwindcss.com",document.head.appendChild(r)},[])},AXn=t=>t.toLowerCase().includes("pack")?XMn:t.toLowerCase().includes("rout")?KMn:DMn,RXn=({solverEvents:t=[]})=>{const[e,n]=te.useState(null);PXn();const r=te.useMemo(()=>{const a=new Map;for(const c of t){const l=`${c.componentName}-${c.solverName}`;a.set(l,c)}return a},[t]),i=te.useMemo(()=>Array.from(r.keys()),[r]),o=e?r.get(e):null,s=te.useMemo(()=>{if(!o)return{instance:null,error:null,classFound:!1};const a=yae[o.solverName];if(!a)return{instance:null,error:`Solver class "${o.solverName}" not found in SOLVERS registry. Available: ${Object.keys(yae).join(", ")}`,classFound:!1};try{const c=o.solverParams,l=c?.input!==void 0?c.input:c;return{instance:new a(l),error:null,classFound:!0}}catch(c){const l=c instanceof Error?c.message:String(c);return console.error("Failed to reconstruct solver:",c),{instance:null,error:`Failed to instantiate solver: ${l}`,classFound:!0}}},[o]);return t.length===0?G.jsx("div",{className:"rf-p-4",children:G.jsx("div",{className:"rf-bg-gray-50 rf-rounded-md rf-border rf-border-gray-200",children:G.jsxs("div",{className:"rf-p-4",children:[G.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800 rf-mb-3",children:"No Solvers Detected"}),G.jsx("p",{className:"rf-text-sm rf-text-gray-600",children:"Solvers will appear here when the circuit runs. Solvers are used for tasks like component packing and autorouting."})]})})}):G.jsxs("div",{className:"rf-flex rf-h-full rf-overflow-hidden",children:[G.jsxs("div",{className:"rf-w-64 rf-border-r rf-border-gray-200 rf-overflow-y-auto rf-flex-shrink-0",children:[G.jsxs("div",{className:"rf-text-xs rf-font-semibold rf-text-gray-500 rf-px-3 rf-py-2 rf-bg-gray-50 rf-border-b rf-border-gray-200",children:[i.length," ",i.length===1?"Solver":"Solvers"]}),i.map(a=>{const c=r.get(a),l=e===a;return G.jsx("div",{className:`rf-px-3 rf-py-2 rf-cursor-pointer rf-border-b rf-border-gray-100 ${l?"rf-bg-blue-50 rf-border-l-2 rf-border-l-blue-500":"hover:rf-bg-gray-50"}`,onClick:()=>n(a),children:(()=>{const u=AXn(c.solverName);return G.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2",children:[G.jsx(u,{className:"rf-w-4 rf-h-4 rf-text-blue-500 rf-flex-shrink-0"}),G.jsxs("div",{className:"rf-flex-1 rf-min-w-0",children:[G.jsx("div",{className:"rf-text-sm rf-font-medium rf-text-gray-800 rf-truncate",children:c.componentName}),G.jsx("div",{className:"rf-text-xs rf-text-gray-500 rf-truncate",children:c.solverName})]})]})})()},a)})]}),G.jsx("div",{className:"rf-flex-1 rf-overflow-hidden",children:o?s.instance?G.jsx(Fb,{fallback:G.jsx("div",{className:"rf-p-4",children:G.jsxs("div",{className:"rf-bg-red-50 rf-rounded-md rf-border rf-border-red-200 rf-p-4",children:[G.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-red-800 rf-mb-2",children:"Error Loading Solver Debugger"}),G.jsxs("p",{className:"rf-text-sm rf-text-red-600",children:["Failed to render the solver debugger for"," ",o.solverName]})]})}),children:G.jsx(CXn,{solver:s.instance})}):G.jsxs("div",{className:"rf-p-4",children:[G.jsxs("div",{className:"rf-mb-4",children:[G.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800",children:o.solverName}),G.jsxs("p",{className:"rf-text-sm rf-text-gray-500",children:["Component: ",o.componentName]})]}),s.error&&G.jsx("div",{className:`rf-rounded-md rf-border rf-p-4 rf-mb-4 ${s.classFound?"rf-bg-red-50 rf-border-red-200":"rf-bg-yellow-50 rf-border-yellow-200"}`,children:G.jsx("p",{className:`rf-text-sm ${s.classFound?"rf-text-red-700":"rf-text-yellow-700"}`,children:s.error})}),G.jsxs("div",{className:"rf-border rf-border-gray-200 rf-rounded-md rf-overflow-hidden",children:[G.jsx("div",{className:"rf-px-3 rf-py-2 rf-bg-gray-50",children:G.jsx("span",{className:"rf-text-sm rf-font-medium rf-text-gray-700",children:"Solver Parameters"})}),G.jsx("div",{className:"rf-p-3 rf-bg-white rf-border-t rf-border-gray-200",children:G.jsx("pre",{className:"rf-text-xs rf-font-mono rf-text-gray-600 rf-whitespace-pre-wrap rf-overflow-x-auto",children:JSON.stringify(o.solverParams,null,2)})})]})]}):G.jsx("div",{className:"rf-flex rf-items-center rf-justify-center rf-h-full",children:G.jsx("p",{className:"rf-text-sm rf-text-gray-500",children:"Select a solver from the list to view details"})})})]})},m0t=({errorMessage:t,errorStack:e,circuitJsonErrors:n})=>{te.useEffect(()=>{if(t){const r=new Error(t);e&&(r.stack=e);try{iD.captureException(r)}catch{}}},[t,e]),te.useEffect(()=>{if(n&&n.length>0)for(const r of n){const i=new Error(r.message||"Circuit JSON Error");r.stack&&(i.stack=r.stack);try{iD.captureException(i,{error_type:r.type})}catch{}}},[n])},y0t="0.0.1802",IXn={version:y0t},K_e={BASE_URL:"/",DEV:!1,MODE:"production",PROD:!0,SSR:!1},Q_e=new Map,_G=t=>{const e=Q_e.get(t);return e?Object.fromEntries(Object.entries(e.stores).map(([n,r])=>[n,r.getState()])):{}},NXn=(t,e,n)=>{if(t===void 0)return{type:"untracked",connection:e.connect(n)};const r=Q_e.get(n.name);if(r)return{type:"tracked",store:t,...r};const i={connection:e.connect(n),stores:{}};return Q_e.set(n.name,i),{type:"tracked",store:t,...i}},g0t=(t,e={})=>(n,r,i)=>{const{enabled:o,anonymousActionType:s,store:a,...c}=e;let l;try{l=(o??(K_e?"production":void 0)!=="production")&&window.__REDUX_DEVTOOLS_EXTENSION__}catch{}if(!l)return(K_e?"production":void 0)!=="production"&&o&&console.warn("[zustand devtools middleware] Please install/enable Redux devtools extension"),t(n,r,i);const{connection:u,...d}=NXn(a,l,c);let h=!0;i.setState=(m,g,y)=>{const _=n(m,g);if(!h)return _;const x=y===void 0?{type:s||"anonymous"}:typeof y=="string"?{type:y}:y;return a===void 0?(u?.send(x,r()),_):(u?.send({...x,type:`${a}/${x.type}`},{..._G(c.name),[a]:i.getState()}),_)};const f=(...m)=>{const g=h;h=!1,n(...m),h=g},p=t(i.setState,r,i);if(d.type==="untracked"?u?.init(p):(d.stores[d.store]=i,u?.init(Object.fromEntries(Object.entries(d.stores).map(([m,g])=>[m,m===d.store?p:g.getState()])))),i.dispatchFromDevtools&&typeof i.dispatch=="function"){let m=!1;const g=i.dispatch;i.dispatch=(...y)=>{(K_e?"production":void 0)!=="production"&&y[0].type==="__setState"&&!m&&(console.warn('[zustand devtools middleware] "__setState" action type is reserved to set state from the devtools. Avoid using it.'),m=!0),g(...y)}}return u.subscribe(m=>{var g;switch(m.type){case"ACTION":if(typeof m.payload!="string"){console.error("[zustand devtools middleware] Unsupported action format");return}return J_e(m.payload,y=>{if(y.type==="__setState"){if(a===void 0){f(y.state);return}Object.keys(y.state).length!==1&&console.error(`
|
|
5674
|
+
`,d=new Blob([u],{type:"text/plain"}),h=URL.createObjectURL(d),f=document.createElement("a");f.href=h,f.download=`${l}.test.ts`,f.click(),URL.revokeObjectURL(h)}catch(c){alert(`Error generating test.ts for ${t.constructor.name}: ${c instanceof Error?c.message:String(c)}`)}r(!1)};return G.jsxs("div",{className:`relative ${e}`,ref:i,children:[G.jsx("button",{className:"px-2 py-1 rounded text-xs cursor-pointer",onClick:()=>r(!n),title:`Download options for ${t.constructor.name}`,children:t.constructor.name}),n&&G.jsxs("div",{className:"absolute top-full left-0 mt-1 bg-white border border-gray-300 rounded shadow-lg z-10 min-w-[150px]",children:[G.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:o,children:"Download JSON"}),G.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:s,children:"Download page.tsx"}),G.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:a,children:"Download test.ts"})]})]})},f0t=t=>t.activeSubSolver?[t,...f0t(t.activeSubSolver)]:[t],mXn=({solver:t})=>{const e=f0t(t);return G.jsx("div",{className:"flex gap-1 items-center text-sm pt-1",children:e.map((n,r)=>G.jsxs("div",{className:"flex items-center",children:[r>0&&G.jsx("span",{className:"text-gray-400 mx-1",children:"→"}),G.jsx(fXn,{solver:n})]},n.constructor.name))})},yXn=({solver:t,triggerRender:e,animationSpeed:n=25,onSolverStarted:r,onSolverCompleted:i})=>{const[o,s]=te.useReducer(m=>!m,!1),a=te.useRef(void 0),c=()=>{!t.solved&&!t.failed&&(t.step(),e())},l=()=>{!t.solved&&!t.failed&&(r&&r(t),t.solve(),e(),i&&i(t))},u=()=>{o?(a.current&&(clearInterval(a.current),a.current=void 0),s()):(s(),a.current=setInterval(()=>{if(t.solved||t.failed){a.current&&(clearInterval(a.current),a.current=void 0),s(),e(),i&&t.solved&&i(t);return}t.step(),e()},n))},d=()=>{const m=t;if(m.getCurrentPhase&&!t.solved&&!t.failed){const g=m.getCurrentPhase();for(;m.getCurrentPhase()===g&&!t.solved&&!t.failed;)t.step();e()}},h=()=>{if(t.solved||t.failed||o)return;const m=window.prompt("Step until which iteration?",`${t.iterations}`);if(m===null)return;const g=Number(m);if(!Number.isFinite(g)){window.alert("Please enter a valid number for the iteration");return}for(;t.iterations<g&&!t.solved&&!t.failed;)t.step();e(),t.solved&&i&&i(t)};te.useEffect(()=>()=>{a.current&&clearInterval(a.current)},[]),te.useEffect(()=>{(t.solved||t.failed)&&o&&(a.current&&(clearInterval(a.current),a.current=void 0),s())},[t.solved,t.failed,o]);const f=t.getCurrentPhase!==void 0,p=f?t.getCurrentPhase():null;return G.jsxs("div",{className:"space-y-2 p-2 border-b",children:[G.jsx("div",{className:"flex items-center",children:G.jsx(mXn,{solver:t})}),G.jsxs("div",{className:"flex gap-2 items-center flex-wrap",children:[G.jsx("button",{onClick:c,disabled:t.solved||t.failed||o,className:"bg-blue-500 hover:bg-blue-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Step"}),G.jsx("button",{onClick:l,disabled:t.solved||t.failed||o,className:"bg-green-500 hover:bg-green-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Solve"}),G.jsx("button",{onClick:u,disabled:t.solved||t.failed,className:`px-3 py-1 rounded text-white text-sm ${o?"bg-red-500 hover:bg-red-600":"bg-yellow-500 hover:bg-yellow-600"} disabled:bg-gray-300`,children:o?"Stop":"Animate"}),G.jsx("button",{onClick:h,disabled:t.solved||t.failed||o,className:"bg-orange-500 hover:bg-orange-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Step Until Iteration"}),f&&G.jsx("button",{onClick:d,disabled:t.solved||t.failed||o,className:"bg-purple-500 hover:bg-purple-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Next Stage"}),G.jsxs("div",{className:"text-sm text-gray-600",children:["Iterations: ",t.iterations]}),t.timeToSolve!==void 0&&G.jsxs("div",{className:"text-sm text-gray-600",children:["Time: ",(t.timeToSolve/1e3).toFixed(3),"s"]}),p&&G.jsxs("div",{className:"text-sm text-gray-600",children:["Phase: ",G.jsx("span",{className:"font-medium",children:p})]}),t.solved&&G.jsx("div",{className:"px-2 py-1 bg-green-100 text-green-800 rounded text-sm",children:"Solved"}),t.failed&&G.jsx("div",{className:"px-2 py-1 bg-red-100 text-red-800 rounded text-sm",children:"Failed"})]}),t.error&&G.jsxs("div",{className:"text-red-600 text-sm",children:["Error: ",t.error]})]})},gXn=(t,e,n)=>{const r=t.currentPipelineStepIndex;return e<r?"Completed":e===r&&t.activeSubSolver?t.activeSubSolver.failed?"Failed":"In Progress":"Not Started"},_Xn=(t,e)=>{const r=t.pipelineDef[e].solverName,i=gXn(t,e),o=t[r],s=t.firstIterationOfPhase?.[r]??null,a=t.iterations;let c=0;if(i==="Completed"){const h=t.pipelineDef[e+1],f=h?t.firstIterationOfPhase?.[h.solverName]:void 0;f!==void 0&&s!==null?c=f-s:s!==null&&(c=a-s)}else i==="In Progress"&&s!==null&&(c=a-s);const l=t.timeSpentOnPhase?.[r]??0;let u=0;i==="Completed"?u=1:i==="In Progress"&&o&&(u=o.progress??0);const d=o?.stats??null;return{index:e,name:r,status:i,firstIteration:s,iterations:c,progress:u,timeSpent:l,stats:d&&Object.keys(d).length>0?d:null,solverInstance:o??null}},xXn=({status:t})=>{const e={"Not Started":"text-blue-600","In Progress":"text-yellow-600",Completed:"text-green-600",Failed:"text-red-600"};return G.jsx("span",{className:`font-medium ${e[t]}`,children:t})},bXn=({progress:t})=>{if(t===0)return null;const e=Math.round(t*100);return G.jsxs("div",{className:"flex items-center gap-2",children:[G.jsx("div",{className:"w-20 h-2 bg-gray-200 rounded overflow-hidden",children:G.jsx("div",{className:"h-full bg-blue-500 transition-all duration-200",style:{width:`${e}%`}})}),G.jsxs("span",{className:"text-xs text-gray-500",children:[e,"%"]})]})},vXn=t=>Object.entries(t).map(([e,n])=>`${e}: ${n}`).join(", "),wXn=({stats:t})=>{if(!t||Object.keys(t).length===0)return G.jsx("span",{children:"-"});const e=Object.entries(t),n=vXn(t);return G.jsxs("details",{className:"cursor-pointer",children:[G.jsx("summary",{className:"whitespace-nowrap overflow-hidden text-ellipsis max-w-[200px]",children:n}),G.jsx("div",{className:"mt-1 text-xs",children:e.map(([r,i])=>G.jsxs("div",{children:[r,": ",String(i)]},r))})]})},Z_e=t=>{if(t===null||typeof t!="object")return t;if(Array.isArray(t))return t.map(Z_e);const e={};for(const[n,r]of Object.entries(t))n.startsWith("_")||(e[n]=Z_e(r));return e},SXn=(t,e)=>{try{if(typeof t.getConstructorParams!="function"){alert(`getConstructorParams() is not implemented for ${e}`);return}const n=Z_e(t.getConstructorParams()),r=new Blob([JSON.stringify(n,null,2)],{type:"application/json"}),i=URL.createObjectURL(r),o=document.createElement("a");o.href=i,o.download=`${e}_input.json`,o.click(),URL.revokeObjectURL(i)}catch(n){alert(`Error downloading input for ${e}: ${n instanceof Error?n.message:String(n)}`)}},MXn=({solver:t,onStepUntilPhase:e,onDownloadInput:n})=>{const r=t.pipelineDef.map((a,c)=>_Xn(t,c)),i=a=>{e?.(a)},o=a=>{a.solverInstance&&(n?n(a.solverInstance,a.name):SXn(a.solverInstance,a.name))},s=a=>`${(a/1e3).toFixed(2)}s`;return G.jsxs("div",{className:"border-t border-gray-200",children:[G.jsx("div",{className:"px-4 py-2 bg-gray-50 border-b border-gray-200",children:G.jsx("h3",{className:"text-sm font-semibold text-gray-700",children:"Pipeline Steps"})}),G.jsx("div",{className:"overflow-x-auto",children:G.jsxs("table",{className:"w-full text-sm",children:[G.jsx("thead",{children:G.jsxs("tr",{className:"bg-gray-50 border-b border-gray-200",children:[G.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Step"}),G.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Status"}),G.jsxs("th",{className:"px-4 py-2 text-center font-semibold text-gray-700",children:["i",G.jsx("sub",{children:"0"})]}),G.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Iterations"}),G.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Progress"}),G.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Time"}),G.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Stats"}),G.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Input"})]})}),G.jsx("tbody",{children:r.map(a=>G.jsxs("tr",{className:`border-b border-gray-100 ${a.status==="In Progress"?"bg-yellow-50":""}`,children:[G.jsx("td",{className:"px-4 py-2",children:G.jsxs("div",{className:"flex items-center gap-2",children:[G.jsx("span",{className:"text-gray-400 w-6",children:String(a.index+1).padStart(2,"0")}),G.jsx("button",{onClick:()=>i(a.name),disabled:a.status==="Completed"||t.solved||t.failed,className:"text-blue-500 hover:text-blue-700 disabled:text-gray-300 disabled:cursor-not-allowed",title:`Step until ${a.name} completes`,children:G.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:G.jsx("path",{fillRule:"evenodd",d:"M4.5 5.653c0-1.426 1.529-2.33 2.779-1.643l11.54 6.348c1.295.712 1.295 2.573 0 3.285L7.28 19.991c-1.25.687-2.779-.217-2.779-1.643V5.653z",clipRule:"evenodd"})})}),G.jsx("span",{className:"font-medium text-gray-900",children:a.name})]})}),G.jsx("td",{className:"px-4 py-2",children:G.jsx(xXn,{status:a.status})}),G.jsx("td",{className:"px-4 py-2 text-center text-gray-600",children:a.firstIteration!==null?a.firstIteration:""}),G.jsx("td",{className:"px-4 py-2 text-gray-600",children:a.iterations}),G.jsx("td",{className:"px-4 py-2",children:G.jsx(bXn,{progress:a.progress})}),G.jsx("td",{className:"px-4 py-2 text-gray-600",children:s(a.timeSpent)}),G.jsx("td",{className:"px-4 py-2 text-gray-500",children:G.jsx(wXn,{stats:a.stats})}),G.jsx("td",{className:"px-4 py-2",children:a.solverInstance?G.jsxs("button",{onClick:()=>o(a),className:"flex items-center gap-1 text-blue-500 hover:text-blue-700",title:`Download input for ${a.name}`,children:[G.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:G.jsx("path",{fillRule:"evenodd",d:"M12 2.25a.75.75 0 01.75.75v11.69l3.22-3.22a.75.75 0 111.06 1.06l-4.5 4.5a.75.75 0 01-1.06 0l-4.5-4.5a.75.75 0 111.06-1.06l3.22 3.22V3a.75.75 0 01.75-.75zm-9 13.5a.75.75 0 01.75.75v2.25a1.5 1.5 0 001.5 1.5h13.5a1.5 1.5 0 001.5-1.5V16.5a.75.75 0 011.5 0v2.25a3 3 0 01-3 3H5.25a3 3 0 01-3-3V16.5a.75.75 0 01.75-.75z",clipRule:"evenodd"})}),G.jsx("span",{children:"Input"})]}):null})]},a.name))})]})})]})},TXn=class extends si.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 EXn({graphics:t}){const e=t.points??[],n=t.lines??[],r=t.rects??[],i=t.circles??[],o=t.texts??[];let s=Number.POSITIVE_INFINITY,a=Number.POSITIVE_INFINITY,c=Number.NEGATIVE_INFINITY,l=Number.NEGATIVE_INFINITY;const u=(g,y)=>{typeof g=="number"&&(g<s&&(s=g),g>c&&(c=g)),typeof y=="number"&&(y<a&&(a=y),y>l&&(l=y))};for(const g of e)u(g.x,g.y);for(const g of n){const y=g.points??[];for(const _ of y)u(_.x,_.y)}for(const g of r){const y=g.x??0,_=g.y??0,x=g.width??0,b=g.height??0;u(y,_),u(y+x,_+b)}for(const g of i){const y=g.x??0,_=g.y??0,x=g.radius??1;u(y-x,_-x),u(y+x,_+x)}for(const g of o)u(g.x,g.y);(!isFinite(s)||!isFinite(a)||!isFinite(c)||!isFinite(l))&&(s=-20,a=-20,c=20,l=20);const d=10,h=s-d,f=a-d,p=Math.max(1,c-s+2*d),m=Math.max(1,l-a+2*d);return G.jsxs("svg",{className:"w-full h-[400px] bg-white",viewBox:`${h} ${f} ${p} ${m}`,role:"img","aria-label":"Graphics fallback",children:[r.map((g,y)=>G.jsx("rect",{x:g.x??0,y:g.y??0,width:g.width??0,height:g.height??0,fill:"none",stroke:g.strokeColor??"black",strokeWidth:g.strokeWidth??1},`rect-${y}`)),n.map((g,y)=>G.jsx("polyline",{fill:"none",stroke:g.strokeColor??"black",strokeWidth:g.strokeWidth??1,points:(g.points??[]).map(_=>`${_.x??0},${_.y??0}`).join(" ")},`line-${y}`)),i.map((g,y)=>G.jsx("circle",{cx:g.x??0,cy:g.y??0,r:g.radius??1.5,fill:g.fillColor??"none",stroke:g.strokeColor??"black",strokeWidth:g.strokeWidth??1},`circle-${y}`)),e.map((g,y)=>G.jsx("circle",{cx:g.x??0,cy:g.y??0,r:g.radius??1.5,fill:g.color??"black"},`point-${y}`)),o.map((g,y)=>G.jsx("text",{x:g.x??0,y:g.y??0,fontSize:g.fontSize??10,fill:g.color??"black",children:g.text??""},`text-${y}`))]})}var CXn=({solver:t,animationSpeed:e=25,onSolverStarted:n,onSolverCompleted:r})=>{const[i,o]=te.useReducer(u=>u+1,0),s=te.useMemo(()=>{try{return t.visualize()||{points:[],lines:[],rects:[],circles:[]}}catch(u){return console.error("Visualization error:",u),{points:[],lines:[],rects:[],circles:[]}}},[t,i]),a=te.useMemo(()=>(s.rects?.length||0)===0&&(s.lines?.length||0)===0&&(s.points?.length||0)===0&&(s.circles?.length||0)===0,[s]);te.useEffect(()=>{if(!(typeof document>"u")&&!document.querySelector('script[src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4"]')){const u=document.createElement("script");u.src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4",document.head.appendChild(u)}},[]);const c=t.pipelineDef!==void 0,l=u=>{const d=t;if(!t.solved&&!t.failed){for(;!t.solved&&!t.failed&&d.currentPipelineStepIndex<=d.pipelineDef.findIndex(h=>h.solverName===u);)t.step();o()}};return G.jsxs("div",{children:[G.jsx(yXn,{solver:t,triggerRender:o,animationSpeed:e,onSolverStarted:n,onSolverCompleted:r}),a?G.jsx("div",{className:"p-4 text-gray-500",children:"No Graphics Yet"}):G.jsx(TXn,{fallback:G.jsx(EXn,{graphics:s}),children:G.jsx(pXn,{graphics:s})}),c&&G.jsx(MXn,{solver:t,onStepUntilPhase:l})]})};const PXn=()=>{te.useEffect(()=>{const t="tailwind-cdn-script";if(document.getElementById(t)||window.tailwind)return;const e=document.createElement("div");e.className="hidden",document.body.appendChild(e);const n=window.getComputedStyle(e).display==="none";if(document.body.removeChild(e),n)return;const r=document.createElement("script");r.id=t,r.src="https://cdn.tailwindcss.com",document.head.appendChild(r)},[])},AXn=t=>t.toLowerCase().includes("pack")?XMn:t.toLowerCase().includes("rout")?KMn:DMn,RXn=({solverEvents:t=[]})=>{const[e,n]=te.useState(null);PXn();const r=te.useMemo(()=>{const a=new Map;for(const c of t){const l=`${c.componentName}-${c.solverName}`;a.set(l,c)}return a},[t]),i=te.useMemo(()=>Array.from(r.keys()),[r]),o=e?r.get(e):null,s=te.useMemo(()=>{if(!o)return{instance:null,error:null,classFound:!1};const a=yae[o.solverName];if(!a)return{instance:null,error:`Solver class "${o.solverName}" not found in SOLVERS registry. Available: ${Object.keys(yae).join(", ")}`,classFound:!1};try{const c=o.solverParams,l=c?.input!==void 0?c.input:c;return{instance:new a(l),error:null,classFound:!0}}catch(c){const l=c instanceof Error?c.message:String(c);return console.error("Failed to reconstruct solver:",c),{instance:null,error:`Failed to instantiate solver: ${l}`,classFound:!0}}},[o]);return t.length===0?G.jsx("div",{className:"rf-p-4",children:G.jsx("div",{className:"rf-bg-gray-50 rf-rounded-md rf-border rf-border-gray-200",children:G.jsxs("div",{className:"rf-p-4",children:[G.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800 rf-mb-3",children:"No Solvers Detected"}),G.jsx("p",{className:"rf-text-sm rf-text-gray-600",children:"Solvers will appear here when the circuit runs. Solvers are used for tasks like component packing and autorouting."})]})})}):G.jsxs("div",{className:"rf-flex rf-h-full rf-overflow-hidden",children:[G.jsxs("div",{className:"rf-w-64 rf-border-r rf-border-gray-200 rf-overflow-y-auto rf-flex-shrink-0",children:[G.jsxs("div",{className:"rf-text-xs rf-font-semibold rf-text-gray-500 rf-px-3 rf-py-2 rf-bg-gray-50 rf-border-b rf-border-gray-200",children:[i.length," ",i.length===1?"Solver":"Solvers"]}),i.map(a=>{const c=r.get(a),l=e===a;return G.jsx("div",{className:`rf-px-3 rf-py-2 rf-cursor-pointer rf-border-b rf-border-gray-100 ${l?"rf-bg-blue-50 rf-border-l-2 rf-border-l-blue-500":"hover:rf-bg-gray-50"}`,onClick:()=>n(a),children:(()=>{const u=AXn(c.solverName);return G.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2",children:[G.jsx(u,{className:"rf-w-4 rf-h-4 rf-text-blue-500 rf-flex-shrink-0"}),G.jsxs("div",{className:"rf-flex-1 rf-min-w-0",children:[G.jsx("div",{className:"rf-text-sm rf-font-medium rf-text-gray-800 rf-truncate",children:c.componentName}),G.jsx("div",{className:"rf-text-xs rf-text-gray-500 rf-truncate",children:c.solverName})]})]})})()},a)})]}),G.jsx("div",{className:"rf-flex-1 rf-overflow-hidden",children:o?s.instance?G.jsx(Fb,{fallback:G.jsx("div",{className:"rf-p-4",children:G.jsxs("div",{className:"rf-bg-red-50 rf-rounded-md rf-border rf-border-red-200 rf-p-4",children:[G.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-red-800 rf-mb-2",children:"Error Loading Solver Debugger"}),G.jsxs("p",{className:"rf-text-sm rf-text-red-600",children:["Failed to render the solver debugger for"," ",o.solverName]})]})}),children:G.jsx(CXn,{solver:s.instance})}):G.jsxs("div",{className:"rf-p-4",children:[G.jsxs("div",{className:"rf-mb-4",children:[G.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800",children:o.solverName}),G.jsxs("p",{className:"rf-text-sm rf-text-gray-500",children:["Component: ",o.componentName]})]}),s.error&&G.jsx("div",{className:`rf-rounded-md rf-border rf-p-4 rf-mb-4 ${s.classFound?"rf-bg-red-50 rf-border-red-200":"rf-bg-yellow-50 rf-border-yellow-200"}`,children:G.jsx("p",{className:`rf-text-sm ${s.classFound?"rf-text-red-700":"rf-text-yellow-700"}`,children:s.error})}),G.jsxs("div",{className:"rf-border rf-border-gray-200 rf-rounded-md rf-overflow-hidden",children:[G.jsx("div",{className:"rf-px-3 rf-py-2 rf-bg-gray-50",children:G.jsx("span",{className:"rf-text-sm rf-font-medium rf-text-gray-700",children:"Solver Parameters"})}),G.jsx("div",{className:"rf-p-3 rf-bg-white rf-border-t rf-border-gray-200",children:G.jsx("pre",{className:"rf-text-xs rf-font-mono rf-text-gray-600 rf-whitespace-pre-wrap rf-overflow-x-auto",children:JSON.stringify(o.solverParams,null,2)})})]})]}):G.jsx("div",{className:"rf-flex rf-items-center rf-justify-center rf-h-full",children:G.jsx("p",{className:"rf-text-sm rf-text-gray-500",children:"Select a solver from the list to view details"})})})]})},m0t=({errorMessage:t,errorStack:e,circuitJsonErrors:n})=>{te.useEffect(()=>{if(t){const r=new Error(t);e&&(r.stack=e);try{iD.captureException(r)}catch{}}},[t,e]),te.useEffect(()=>{if(n&&n.length>0)for(const r of n){const i=new Error(r.message||"Circuit JSON Error");r.stack&&(i.stack=r.stack);try{iD.captureException(i,{error_type:r.type})}catch{}}},[n])},y0t="0.0.1803",IXn={version:y0t},K_e={BASE_URL:"/",DEV:!1,MODE:"production",PROD:!0,SSR:!1},Q_e=new Map,_G=t=>{const e=Q_e.get(t);return e?Object.fromEntries(Object.entries(e.stores).map(([n,r])=>[n,r.getState()])):{}},NXn=(t,e,n)=>{if(t===void 0)return{type:"untracked",connection:e.connect(n)};const r=Q_e.get(n.name);if(r)return{type:"tracked",store:t,...r};const i={connection:e.connect(n),stores:{}};return Q_e.set(n.name,i),{type:"tracked",store:t,...i}},g0t=(t,e={})=>(n,r,i)=>{const{enabled:o,anonymousActionType:s,store:a,...c}=e;let l;try{l=(o??(K_e?"production":void 0)!=="production")&&window.__REDUX_DEVTOOLS_EXTENSION__}catch{}if(!l)return(K_e?"production":void 0)!=="production"&&o&&console.warn("[zustand devtools middleware] Please install/enable Redux devtools extension"),t(n,r,i);const{connection:u,...d}=NXn(a,l,c);let h=!0;i.setState=(m,g,y)=>{const _=n(m,g);if(!h)return _;const x=y===void 0?{type:s||"anonymous"}:typeof y=="string"?{type:y}:y;return a===void 0?(u?.send(x,r()),_):(u?.send({...x,type:`${a}/${x.type}`},{..._G(c.name),[a]:i.getState()}),_)};const f=(...m)=>{const g=h;h=!1,n(...m),h=g},p=t(i.setState,r,i);if(d.type==="untracked"?u?.init(p):(d.stores[d.store]=i,u?.init(Object.fromEntries(Object.entries(d.stores).map(([m,g])=>[m,m===d.store?p:g.getState()])))),i.dispatchFromDevtools&&typeof i.dispatch=="function"){let m=!1;const g=i.dispatch;i.dispatch=(...y)=>{(K_e?"production":void 0)!=="production"&&y[0].type==="__setState"&&!m&&(console.warn('[zustand devtools middleware] "__setState" action type is reserved to set state from the devtools. Avoid using it.'),m=!0),g(...y)}}return u.subscribe(m=>{var g;switch(m.type){case"ACTION":if(typeof m.payload!="string"){console.error("[zustand devtools middleware] Unsupported action format");return}return J_e(m.payload,y=>{if(y.type==="__setState"){if(a===void 0){f(y.state);return}Object.keys(y.state).length!==1&&console.error(`
|
|
5675
5675
|
[zustand devtools middleware] Unsupported __setState action format.
|
|
5676
5676
|
When using 'store' option in devtools(), the 'state' should have only one key, which is a value of 'store' that was passed in devtools(),
|
|
5677
5677
|
and value of this only key should be a state object. Example: { "type": "__setState", "state": { "abc123Store": { "foo": "bar" } } }
|
|
@@ -5685,7 +5685,7 @@ You can add a description to the \`${SP}\` by passing a \`${G0t}\` component as
|
|
|
5685
5685
|
|
|
5686
5686
|
Alternatively, you can use your own component as a description by assigning it an \`id\` and passing the same value to the \`aria-describedby\` prop in \`${SP}\`. If the description is confusing or duplicative for sighted users, you can use the \`@radix-ui/react-visually-hidden\` primitive as a wrapper around your description component.
|
|
5687
5687
|
|
|
5688
|
-
For more information, see https://radix-ui.com/primitives/docs/components/alert-dialog`;return te.useEffect(()=>{document.getElementById(t.current?.getAttribute("aria-describedby"))||console.warn(e)},[e,t]),null},mVn=j0t,yVn=U0t,Q0t=H0t,J0t=Y0t,edt=W0t,tdt=K0t,ndt=V0t,rdt=q0t;const idt=mVn,gVn=yVn,odt=te.forwardRef(({className:t,...e},n)=>G.jsx(Q0t,{className:go("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}));odt.displayName=Q0t.displayName;const l2e=te.forwardRef(({className:t,...e},n)=>G.jsxs(gVn,{children:[G.jsx(odt,{}),G.jsx(J0t,{ref:n,className:go("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})]}));l2e.displayName=J0t.displayName;const u2e=({className:t,...e})=>G.jsx("div",{className:go("rf-flex rf-flex-col rf-space-y-2 rf-text-center sm:rf-text-left",t),...e});u2e.displayName="AlertDialogHeader";const d2e=({className:t,...e})=>G.jsx("div",{className:go("rf-flex rf-flex-col-reverse sm:rf-flex-row sm:rf-justify-end sm:rf-space-x-2",t),...e});d2e.displayName="AlertDialogFooter";const h2e=te.forwardRef(({className:t,...e},n)=>G.jsx(ndt,{ref:n,className:go("rf-text-lg rf-font-semibold",t),...e}));h2e.displayName=ndt.displayName;const p2e=te.forwardRef(({className:t,...e},n)=>G.jsx(rdt,{ref:n,className:go("rf-text-sm rf-text-zinc-500 dark:rf-text-zinc-400",t),...e}));p2e.displayName=rdt.displayName;const _Vn=te.forwardRef(({className:t,...e},n)=>G.jsx(edt,{ref:n,className:go(XC(),t),...e}));_Vn.displayName=edt.displayName;const f2e=te.forwardRef(({className:t,...e},n)=>G.jsx(tdt,{ref:n,className:go(XC({variant:"outline"}),"rf-mt-2 sm:rf-mt-0",t),...e}));f2e.displayName=tdt.displayName;function xVn(t){const e=te.useRef({value:t,previous:t});return te.useMemo(()=>(e.current.value!==t&&(e.current.previous=e.current.value,e.current.value=t),e.current.previous),[t])}var vG="Checkbox",[bVn]=vv(vG),[vVn,m2e]=bVn(vG);function wVn(t){const{__scopeCheckbox:e,checked:n,children:r,defaultChecked:i,disabled:o,form:s,name:a,onCheckedChange:c,required:l,value:u="on",internal_do_not_use_render:d}=t,[h,f]=hM({prop:n,defaultProp:i??!1,onChange:c,caller:vG}),[p,m]=te.useState(null),[g,y]=te.useState(null),_=te.useRef(!1),x=p?!!s||!!p.closest("form"):!0,b={checked:h,disabled:o,setChecked:f,control:p,setControl:m,name:a,form:s,value:u,hasConsumerStoppedPropagationRef:_,required:l,defaultChecked:P8(i)?!1:i,isFormControl:x,bubbleInput:g,setBubbleInput:y};return G.jsx(vVn,{scope:e,...b,children:SVn(d)?d(b):r})}var sdt="CheckboxTrigger",adt=te.forwardRef(({__scopeCheckbox:t,onKeyDown:e,onClick:n,...r},i)=>{const{control:o,value:s,disabled:a,checked:c,required:l,setControl:u,setChecked:d,hasConsumerStoppedPropagationRef:h,isFormControl:f,bubbleInput:p}=m2e(sdt,t),m=_h(i,u),g=te.useRef(c);return te.useEffect(()=>{const y=o?.form;if(y){const _=()=>d(g.current);return y.addEventListener("reset",_),()=>y.removeEventListener("reset",_)}},[o,d]),G.jsx(jl.button,{type:"button",role:"checkbox","aria-checked":P8(c)?"mixed":c,"aria-required":l,"data-state":hdt(c),"data-disabled":a?"":void 0,disabled:a,value:s,...r,ref:m,onKeyDown:Qo(e,y=>{y.key==="Enter"&&y.preventDefault()}),onClick:Qo(n,y=>{d(_=>P8(_)?!0:!_),p&&f&&(h.current=y.isPropagationStopped(),h.current||y.stopPropagation())})})});adt.displayName=sdt;var y2e=te.forwardRef((t,e)=>{const{__scopeCheckbox:n,name:r,checked:i,defaultChecked:o,required:s,disabled:a,value:c,onCheckedChange:l,form:u,...d}=t;return G.jsx(wVn,{__scopeCheckbox:n,checked:i,defaultChecked:o,disabled:a,required:s,onCheckedChange:l,name:r,form:u,value:c,internal_do_not_use_render:({isFormControl:h})=>G.jsxs(G.Fragment,{children:[G.jsx(adt,{...d,ref:e,__scopeCheckbox:n}),h&&G.jsx(ddt,{__scopeCheckbox:n})]})})});y2e.displayName=vG;var cdt="CheckboxIndicator",ldt=te.forwardRef((t,e)=>{const{__scopeCheckbox:n,forceMount:r,...i}=t,o=m2e(cdt,n);return G.jsx(z4,{present:r||P8(o.checked)||o.checked===!0,children:G.jsx(jl.span,{"data-state":hdt(o.checked),"data-disabled":o.disabled?"":void 0,...i,ref:e,style:{pointerEvents:"none",...t.style}})})});ldt.displayName=cdt;var udt="CheckboxBubbleInput",ddt=te.forwardRef(({__scopeCheckbox:t,...e},n)=>{const{control:r,hasConsumerStoppedPropagationRef:i,checked:o,defaultChecked:s,required:a,disabled:c,name:l,value:u,form:d,bubbleInput:h,setBubbleInput:f}=m2e(udt,t),p=_h(n,f),m=xVn(o),g=mtt(r);te.useEffect(()=>{const _=h;if(!_)return;const x=window.HTMLInputElement.prototype,w=Object.getOwnPropertyDescriptor(x,"checked").set,S=!i.current;if(m!==o&&w){const T=new Event("click",{bubbles:S});_.indeterminate=P8(o),w.call(_,P8(o)?!1:o),_.dispatchEvent(T)}},[h,m,o,i]);const y=te.useRef(P8(o)?!1:o);return G.jsx(jl.input,{type:"checkbox","aria-hidden":!0,defaultChecked:s??y.current,required:a,disabled:c,name:l,value:u,form:d,...e,tabIndex:-1,ref:p,style:{...e.style,...g,position:"absolute",pointerEvents:"none",opacity:0,margin:0,transform:"translateX(-100%)"}})});ddt.displayName=udt;function SVn(t){return typeof t=="function"}function P8(t){return t==="indeterminate"}function hdt(t){return P8(t)?"indeterminate":t?"checked":"unchecked"}const TO=te.forwardRef(({className:t,...e},n)=>G.jsx(y2e,{ref:n,className:go("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:G.jsx(ldt,{className:go("rf-flex rf-items-center rf-justify-center rf-text-current"),children:G.jsx(H1e,{className:"rf-h-4 rf-w-4"})})}));TO.displayName=y2e.displayName;const EO=z0t,MVn=$0t,pdt=te.forwardRef(({className:t,...e},n)=>G.jsx(o2e,{className:go("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}));pdt.displayName=o2e.displayName;const MP=te.forwardRef(({className:t,children:e,showOverlay:n=!0,...r},i)=>G.jsxs(MVn,{children:[G.jsx(pdt,{className:go(n?"":"rf-hidden")}),G.jsx(s2e,{ref:i,className:go("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),...r,children:e})]}));MP.displayName=s2e.displayName;const TP=({className:t,...e})=>G.jsx("div",{className:go("rf-flex rf-flex-col rf-space-y-2 rf-text-center sm:rf-text-left",t),...e});TP.displayName="DialogHeader";const CO=({className:t,...e})=>G.jsx("div",{className:go("rf-flex rf-flex-col-reverse sm:rf-flex-row sm:rf-justify-end sm:rf-space-x-2",t),...e});CO.displayName="DialogFooter";const EP=te.forwardRef(({className:t,...e},n)=>G.jsx(a2e,{ref:n,className:go("rf-text-lg rf-font-semibold",t),...e}));EP.displayName=a2e.displayName;const PO=te.forwardRef(({className:t,...e},n)=>G.jsx(c2e,{ref:n,className:go("rf-text-sm rf-text-zinc-500 dark:rf-text-zinc-400",t),...e}));PO.displayName=c2e.displayName;const wG={"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"}},TVn="https://cdn.jsdelivr.net/npm/easyeda@latest/dist/browser/index.js";let g2e=null;const EVn=async()=>(g2e||(g2e=import(TVn)),g2e),CVn=async(t,e=10)=>{const n=encodeURIComponent(t),r=await fetch(`https://jlcsearch.tscircuit.com/api/search?limit=${e}&q=${n}`);if(!r.ok)throw new Error(`JLCPCB API error: ${r.status}`);return(await r.json()).components??[]},PVn=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}),AVn=async(t,e)=>{const{fetchEasyEDAComponent:n,convertRawEasyToTsx:r}=await EVn(),i=await n(t,{fetch:(o,s)=>fetch(`${e?.apiBase??j9}/proxy`,{...s,headers:{...s?.headers,"X-Target-Url":o.toString(),"X-Sender-Origin":s?.headers?.origin??"","X-Sender-Host":s?.headers?.host??"https://easyeda.com","X-Sender-Referer":s?.headers?.referer??"","X-Sender-User-Agent":s?.headers?.userAgent??"","X-Sender-Cookie":s?.headers?.cookie??"",authority:s?.headers?.authority??"","content-type":s?.headers?.["content-type"]??"",...e?.headers}})});return r({rawEasy:i})},RVn=({query:t,placeholder:e,isSearching:n,onQueryChange:r,onSubmit:i})=>{const o=te.useCallback(s=>{s.key==="Enter"&&(s.preventDefault(),i())},[i]);return G.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2 rf-mt-4",children:[G.jsxs("div",{className:"rf-relative rf-flex-grow",children:[G.jsx(Oet,{className:"rf-absolute rf-left-2 rf-top-2.5 rf-h-4 rf-w-4 rf-text-muted-foreground"}),G.jsx(Sge,{placeholder:e,className:"rf-pl-8",spellCheck:!1,autoComplete:"off",value:t,onChange:s=>r(s.target.value),onKeyDown:o})]}),G.jsx(Tu,{onClick:i,disabled:n||t.trim().length<1,className:"sm:rf-px-4 rf-px-3",children:n?G.jsx(o8,{className:"rf-h-4 rf-w-4 rf-animate-spin"}):G.jsxs(G.Fragment,{children:[G.jsx(Oet,{className:"rf-h-4 rf-w-4 sm:rf-hidden"}),G.jsx("span",{className:"rf-hidden sm:rf-inline",children:"Search"})]})})]})},IVn=new Intl.NumberFormat("en-US",{style:"currency",currency:"USD"}),NVn=t=>IVn.format(t),fdt=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"}},kVn=t=>{switch(t.source){case"tscircuit.com":return t.package.unscoped_name;case"jlcpcb":return t.component.manufacturer;case"kicad":return t.footprint.qualifiedName}},OVn=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}},LVn=t=>{switch(t.source){case"tscircuit.com":return t.package.name;case"jlcpcb":return t.component.partNumber;case"kicad":return}},DVn=({results:t,selected:e,onSelect:n,onShowDetails:r})=>{const i=e?fdt(e):null;return G.jsx("div",{className:"rf-divide-y rf-w-full rf-overflow-hidden",children:t.map(o=>{const s=fdt(o),a=i===s,c=kVn(o),l=OVn(o),u=LVn(o),d=o.source==="jlcpcb"?o.component.stock:null,h=o.source==="jlcpcb"?o.component.price:null,f=o.source==="jlcpcb"?o.component.isBasic:null;return G.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 ${a?"rf-bg-zinc-100":""}`,onClick:()=>n(o),children:[G.jsxs("div",{className:"rf-min-w-0 rf-overflow-hidden rf-w-full",children:[G.jsxs("div",{className:"rf-flex rf-items-start rf-gap-2 rf-min-w-0",children:[G.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:[c,o.source==="jlcpcb"&&f!=null&&G.jsx("span",{className:`rf-text-xs rf-px-1.5 rf-py-0.5 rf-rounded rf-font-medium rf-flex-shrink-0 ${f?"rf-bg-green-100 rf-text-green-700":"rf-bg-orange-100 rf-text-orange-700"}`,children:f?"Basic":"Extended"}),o.source==="tscircuit.com"&&o.package.is_private&&G.jsx(GMn,{className:"rf-ml-1 rf-h-3 rf-w-3 rf-text-zinc-400 rf-flex-shrink-0"})]}),o.source==="jlcpcb"&&d!=null?G.jsxs("div",{className:"rf-text-xs rf-text-zinc-500 rf-font-medium rf-whitespace-nowrap rf-flex-shrink-0 sm:rf-hidden",children:[d.toLocaleString()," in stock"]}):null]}),G.jsxs("div",{className:"rf-text-xs rf-text-zinc-500 rf-truncate rf-w-full",children:[u?G.jsx("span",{className:"rf-mr-2",children:u}):null,l]})]}),G.jsxs("div",{children:[o.source==="tscircuit.com"&&r?G.jsx("div",{className:"rf-flex-shrink-0 rf-w-full sm:rf-w-auto",children:G.jsx(Tu,{variant:"outline",size:"sm",className:"rf-text-xs rf-w-full sm:rf-w-auto",onClick:p=>{p.stopPropagation(),r(o)},children:"See Details"})}):o.source==="jlcpcb"&&d!=null?G.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:[d.toLocaleString()," in stock"]}):null,h!=null&&G.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:NVn(h)})]})]},s)})})},zVn=({packageResult:t,isOpen:e,onOpenChange:n,isLoading:r,details:i,previewTab:o,onPreviewTabChange:s,isSubmitting:a,onImport:c})=>{const l=t?.package??null,u=l?.latest_pcb_preview_image_url,d=l?.latest_sch_preview_image_url,h=l?.latest_cad_preview_image_url,f=l?.unscoped_name?.split("/").pop()??l?.unscoped_name,p=l?.org_owner_tscircuit_handle??void 0,m=p?`https://tscircuit.com/${p}`:void 0,g=p&&f?`https://tscircuit.com/${p}/${f}`:void 0;return G.jsx(EO,{open:e,onOpenChange:n,children:G.jsxs(MP,{showOverlay:!1,style:{width:"calc(100vw - 2rem)"},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:[G.jsx(TP,{className:"rf-pb-4 rf-border-b",children:G.jsx("div",{className:"rf-flex rf-items-start rf-justify-between rf-gap-4",children:G.jsxs("div",{className:"rf-flex-1 rf-min-w-0",children:[G.jsx(EP,{className:"rf-text-xl rf-font-semibold rf-truncate",children:f}),G.jsx(PO,{children:l?.description})]})})}),G.jsxs("div",{className:"rf-flex-1 rf-overflow-y-auto rf-py-4 rf-space-y-6",children:[p?G.jsxs("div",{children:[G.jsx("span",{className:"rf-text-xs rf-font-medium rf-text-gray-500 rf-uppercase rf-tracking-wide",children:"Created by"}),G.jsx("div",{className:"rf-mt-1 rf-text-sm rf-font-medium",children:m?G.jsx("a",{href:m,target:"_blank",rel:"noopener noreferrer",className:"rf-text-black hover:rf-underline",children:p}):p})]}):null,(h||u||d)&&G.jsx(G.Fragment,{children:G.jsxs("div",{children:[G.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-mb-4",children:"Preview"}),G.jsxs(KW,{value:o,onValueChange:y=>s(y),children:[G.jsxs(sD,{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:[u&&G.jsx(B4,{value:"pcb",children:"PCB"}),d&&G.jsx(B4,{value:"schematic",children:"Schematic"}),h&&G.jsx(B4,{value:"3d",children:"3D"})]}),G.jsxs("div",{className:"rf-mt-4",children:[G.jsx(K1,{value:"pcb",className:"rf-border rf-rounded-lg rf-overflow-hidden rf-bg-gray-50",children:u?G.jsx("img",{src:u,alt:`${f??"package"} PCB preview`,className:"rf-w-full rf-h-full rf-object-contain rf-bg-white rf-p-4"}):null}),G.jsx(K1,{value:"schematic",className:"rf-border rf-rounded-lg rf-overflow-hidden rf-bg-gray-50",children:d?G.jsx("img",{src:d,alt:`${f??"package"} schematic preview`,className:"rf-w-full rf-h-full rf-object-contain rf-bg-white rf-p-4"}):null}),G.jsx(K1,{value:"3d",className:"rf-border rf-rounded-lg rf-overflow-hidden rf-bg-gray-50",children:h?G.jsx("img",{src:h,alt:`${f??"package"} 3D preview`,className:"rf-w-full rf-h-full rf-object-contain rf-bg-white rf-p-4"}):null})]})]})]})}),i?.ai_description?G.jsxs("section",{children:[G.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-mb-3",children:"AI Description"}),G.jsx("div",{className:"rf-bg-gray-50 rf-border rf-border-gray-200 rf-rounded-lg rf-p-4",children:G.jsx("p",{className:"rf-text-sm rf-text-gray-700 rf-leading-relaxed",children:i.ai_description})})]}):null,i?.ai_usage_instructions?G.jsxs("section",{children:[G.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-mb-3",children:"Usage Instructions"}),G.jsx("div",{className:"rf-bg-gray-50 rf-border rf-border-gray-200 rf-rounded-lg rf-p-4",children:G.jsx("p",{className:"rf-text-sm rf-text-gray-700 rf-leading-relaxed rf-whitespace-pre-wrap",children:i.ai_usage_instructions})})]}):null,r?G.jsxs("div",{className:"rf-flex rf-justify-center rf-items-center rf-gap-2 rf-text-gray-500",children:[G.jsx(o8,{className:"rf-h-4 rf-w-4 rf-animate-spin"}),G.jsx("span",{className:"rf-text-sm",children:"Loading package details..."})]}):null]}),G.jsxs(CO,{className:"rf-pt-4 rf-border-t rf-flex rf-flex-col sm:rf-flex-row rf-justify-between rf-gap-2",children:[G.jsx("div",{className:"rf-flex-1",children:g?G.jsxs(Tu,{variant:"outline",size:"sm",className:"rf-gap-2 rf-w-full sm:rf-w-auto",onClick:()=>window.open(g,"_blank"),children:[G.jsx(HMn,{className:"rf-h-4 rf-w-4"}),"View on tscircuit.com"]}):null}),G.jsxs("div",{className:"rf-flex rf-flex-col sm:rf-flex-row rf-gap-2",children:[G.jsx(Tu,{variant:"outline",onClick:()=>n(!1),className:"rf-order-2 sm:rf-order-1",children:"Close"}),G.jsx(Tu,{onClick:c,disabled:a,className:"rf-bg-blue-600 hover:rf-bg-blue-700",children:a?G.jsx(o8,{className:"rf-h-4 rf-w-4 rf-animate-spin"}):"Import Component"})]})]})]})})},$Vn=()=>{const[t,e]=te.useState(null),[n,r]=te.useState(!1),i=te.useCallback(async(s,a)=>{r(!0);try{const c=await fetch(`https://api.tscircuit.com/packages/get?name=${encodeURIComponent(`${s}/${a}`)}`);if(!c.ok)throw new Error(`Failed to load package details: ${c.status}`);const l=await c.json();e(l.package??null)}catch(c){console.error("Failed to fetch package details",c),e(null)}finally{r(!1)}},[]),o=te.useCallback(()=>{e(null),r(!1)},[]);return{details:t,isLoading:n,fetchDetails:i,reset:o}},FVn=async(t,e)=>{const n={"Content-Type":"application/json"};e&&(n.Authorization=`Bearer ${e}`);const r=await fetch("https://registry-api.tscircuit.com/packages/search",{method:"POST",headers:n,body:JSON.stringify({query:t})});if(!r.ok)throw new Error(`tscircuit registry error: ${r.status}`);return(await r.json()).packages??[]},BVn=({sessionToken:t})=>{const[e,n]=te.useState([]),[r,i]=te.useState(!1),[o,s]=te.useState(null),[a,c]=te.useState(!1),l=te.useCallback(async d=>{const h=d.trim();if(!h)return[];i(!0),s(null);try{const p=(await FVn(h,t)).map(m=>({source:"tscircuit.com",package:m}));return n(p),p}catch(f){return console.error("Error searching tscircuit packages",f),n([]),s(f instanceof Error?f.message:"Failed to search tscircuit packages"),[]}finally{i(!1),c(!0)}},[t]),u=te.useCallback(()=>{n([]),i(!1),s(null),c(!1)},[]);return{results:e,isSearching:r,error:o,hasSearched:a,search:l,reset:u}},jVn=t=>{const e=t.trim();return/^C\d+/i.test(e)?e.replace(/^C/i,""):e},UVn=()=>{const[t,e]=te.useState([]),[n,r]=te.useState(!1),[i,o]=te.useState(null),[s,a]=te.useState(!1),c=te.useCallback(async u=>{const d=jVn(u);if(!d)return[];r(!0),o(null);try{const f=(await CVn(d,10)).map(p=>({source:"jlcpcb",component:PVn(p)}));return e(f),f}catch(h){return console.error("Error searching JLCPCB components",h),e([]),o(h instanceof Error?h.message:"Failed to search JLCPCB components"),[]}finally{r(!1),a(!0)}},[]),l=te.useCallback(()=>{e([]),r(!1),o(null),a(!1)},[]);return{results:t,isSearching:n,error:i,hasSearched:s,search:c,reset:l}};function H9(t){return Array.isArray?Array.isArray(t):gdt(t)==="[object Array]"}function HVn(t){if(typeof t=="string")return t;let e=t+"";return e=="0"&&1/t==-1/0?"-0":e}function YVn(t){return t==null?"":HVn(t)}function ov(t){return typeof t=="string"}function mdt(t){return typeof t=="number"}function XVn(t){return t===!0||t===!1||VVn(t)&&gdt(t)=="[object Boolean]"}function ydt(t){return typeof t=="object"}function VVn(t){return ydt(t)&&t!==null}function Y2(t){return t!=null}function _2e(t){return!t.trim().length}function gdt(t){return t==null?t===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(t)}const GVn="Incorrect 'index' type",qVn=t=>`Invalid value for key ${t}`,WVn=t=>`Pattern length exceeds max of ${t}.`,ZVn=t=>`Missing ${t} property in key`,KVn=t=>`Property 'weight' in key '${t}' must be a positive integer`,_dt=Object.prototype.hasOwnProperty;class QVn{constructor(e){this._keys=[],this._keyMap={};let n=0;e.forEach(r=>{let i=xdt(r);this._keys.push(i),this._keyMap[i.id]=i,n+=i.weight}),this._keys.forEach(r=>{r.weight/=n})}get(e){return this._keyMap[e]}keys(){return this._keys}toJSON(){return JSON.stringify(this._keys)}}function xdt(t){let e=null,n=null,r=null,i=1,o=null;if(ov(t)||H9(t))r=t,e=bdt(t),n=x2e(t);else{if(!_dt.call(t,"name"))throw new Error(ZVn("name"));const s=t.name;if(r=s,_dt.call(t,"weight")&&(i=t.weight,i<=0))throw new Error(KVn(s));e=bdt(s),n=x2e(s),o=t.getFn}return{path:e,id:n,weight:i,src:r,getFn:o}}function bdt(t){return H9(t)?t:t.split(".")}function x2e(t){return H9(t)?t.join("."):t}function JVn(t,e){let n=[],r=!1;const i=(o,s,a)=>{if(Y2(o))if(!s[a])n.push(o);else{let c=s[a];const l=o[c];if(!Y2(l))return;if(a===s.length-1&&(ov(l)||mdt(l)||XVn(l)))n.push(YVn(l));else if(H9(l)){r=!0;for(let u=0,d=l.length;u<d;u+=1)i(l[u],s,a+1)}else s.length&&i(l,s,a+1)}};return i(t,ov(e)?e.split("."):e,0),r?n:n[0]}var Lo={...{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,getFn:JVn,ignoreLocation:!1,ignoreFieldNorm:!1,fieldNormWeight:1}};const eGn=/[^ ]+/g;function tGn(t=1,e=3){const n=new Map,r=Math.pow(10,e);return{get(i){const o=i.match(eGn).length;if(n.has(o))return n.get(o);const s=1/Math.pow(o,.5*t),a=parseFloat(Math.round(s*r)/r);return n.set(o,a),a},clear(){n.clear()}}}class b2e{constructor({getFn:e=Lo.getFn,fieldNormWeight:n=Lo.fieldNormWeight}={}){this.norm=tGn(n,3),this.getFn=e,this.isCreated=!1,this.setIndexRecords()}setSources(e=[]){this.docs=e}setIndexRecords(e=[]){this.records=e}setKeys(e=[]){this.keys=e,this._keysMap={},e.forEach((n,r)=>{this._keysMap[n.id]=r})}create(){this.isCreated||!this.docs.length||(this.isCreated=!0,ov(this.docs[0])?this.docs.forEach((e,n)=>{this._addString(e,n)}):this.docs.forEach((e,n)=>{this._addObject(e,n)}),this.norm.clear())}add(e){const n=this.size();ov(e)?this._addString(e,n):this._addObject(e,n)}removeAt(e){this.records.splice(e,1);for(let n=e,r=this.size();n<r;n+=1)this.records[n].i-=1}getValueForItemAtKeyId(e,n){return e[this._keysMap[n]]}size(){return this.records.length}_addString(e,n){if(!Y2(e)||_2e(e))return;let r={v:e,i:n,n:this.norm.get(e)};this.records.push(r)}_addObject(e,n){let r={i:n,$:{}};this.keys.forEach((i,o)=>{let s=i.getFn?i.getFn(e):this.getFn(e,i.path);if(Y2(s)){if(H9(s)){let a=[];const c=[{nestedArrIndex:-1,value:s}];for(;c.length;){const{nestedArrIndex:l,value:u}=c.pop();if(Y2(u))if(ov(u)&&!_2e(u)){let d={v:u,i:l,n:this.norm.get(u)};a.push(d)}else H9(u)&&u.forEach((d,h)=>{c.push({nestedArrIndex:h,value:d})})}r.$[o]=a}else if(ov(s)&&!_2e(s)){let a={v:s,n:this.norm.get(s)};r.$[o]=a}}}),this.records.push(r)}toJSON(){return{keys:this.keys,records:this.records}}}function vdt(t,e,{getFn:n=Lo.getFn,fieldNormWeight:r=Lo.fieldNormWeight}={}){const i=new b2e({getFn:n,fieldNormWeight:r});return i.setKeys(t.map(xdt)),i.setSources(e),i.create(),i}function nGn(t,{getFn:e=Lo.getFn,fieldNormWeight:n=Lo.fieldNormWeight}={}){const{keys:r,records:i}=t,o=new b2e({getFn:e,fieldNormWeight:n});return o.setKeys(r),o.setIndexRecords(i),o}function SG(t,{errors:e=0,currentLocation:n=0,expectedLocation:r=0,distance:i=Lo.distance,ignoreLocation:o=Lo.ignoreLocation}={}){const s=e/t.length;if(o)return s;const a=Math.abs(r-n);return i?s+a/i:a?1:s}function rGn(t=[],e=Lo.minMatchCharLength){let n=[],r=-1,i=-1,o=0;for(let s=t.length;o<s;o+=1){let a=t[o];a&&r===-1?r=o:!a&&r!==-1&&(i=o-1,i-r+1>=e&&n.push([r,i]),r=-1)}return t[o-1]&&o-r>=e&&n.push([r,o-1]),n}const OS=32;function iGn(t,e,n,{location:r=Lo.location,distance:i=Lo.distance,threshold:o=Lo.threshold,findAllMatches:s=Lo.findAllMatches,minMatchCharLength:a=Lo.minMatchCharLength,includeMatches:c=Lo.includeMatches,ignoreLocation:l=Lo.ignoreLocation}={}){if(e.length>OS)throw new Error(WVn(OS));const u=e.length,d=t.length,h=Math.max(0,Math.min(r,d));let f=o,p=h;const m=a>1||c,g=m?Array(d):[];let y;for(;(y=t.indexOf(e,p))>-1;){let T=SG(e,{currentLocation:y,expectedLocation:h,distance:i,ignoreLocation:l});if(f=Math.min(T,f),p=y+u,m){let C=0;for(;C<u;)g[y+C]=1,C+=1}}p=-1;let _=[],x=1,b=u+d;const w=1<<u-1;for(let T=0;T<u;T+=1){let C=0,A=b;for(;C<A;)SG(e,{errors:T,currentLocation:h+A,expectedLocation:h,distance:i,ignoreLocation:l})<=f?C=A:b=A,A=Math.floor((b-C)/2+C);b=A;let R=Math.max(1,h-A+1),L=s?d:Math.min(h+A,d)+u,O=Array(L+2);O[L+1]=(1<<T)-1;for(let B=L;B>=R;B-=1){let j=B-1,V=n[t.charAt(j)];if(m&&(g[j]=+!!V),O[B]=(O[B+1]<<1|1)&V,T&&(O[B]|=(_[B+1]|_[B])<<1|1|_[B+1]),O[B]&w&&(x=SG(e,{errors:T,currentLocation:j,expectedLocation:h,distance:i,ignoreLocation:l}),x<=f)){if(f=x,p=j,p<=h)break;R=Math.max(1,2*h-p)}}if(SG(e,{errors:T+1,currentLocation:h,expectedLocation:h,distance:i,ignoreLocation:l})>f)break;_=O}const S={isMatch:p>=0,score:Math.max(.001,x)};if(m){const T=rGn(g,a);T.length?c&&(S.indices=T):S.isMatch=!1}return S}function oGn(t){let e={};for(let n=0,r=t.length;n<r;n+=1){const i=t.charAt(n);e[i]=(e[i]||0)|1<<r-n-1}return e}const MG=String.prototype.normalize?(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,"")):(t=>t);class wdt{constructor(e,{location:n=Lo.location,threshold:r=Lo.threshold,distance:i=Lo.distance,includeMatches:o=Lo.includeMatches,findAllMatches:s=Lo.findAllMatches,minMatchCharLength:a=Lo.minMatchCharLength,isCaseSensitive:c=Lo.isCaseSensitive,ignoreDiacritics:l=Lo.ignoreDiacritics,ignoreLocation:u=Lo.ignoreLocation}={}){if(this.options={location:n,threshold:r,distance:i,includeMatches:o,findAllMatches:s,minMatchCharLength:a,isCaseSensitive:c,ignoreDiacritics:l,ignoreLocation:u},e=c?e:e.toLowerCase(),e=l?MG(e):e,this.pattern=e,this.chunks=[],!this.pattern.length)return;const d=(f,p)=>{this.chunks.push({pattern:f,alphabet:oGn(f),startIndex:p})},h=this.pattern.length;if(h>OS){let f=0;const p=h%OS,m=h-p;for(;f<m;)d(this.pattern.substr(f,OS),f),f+=OS;if(p){const g=h-OS;d(this.pattern.substr(g),g)}}else d(this.pattern,0)}searchIn(e){const{isCaseSensitive:n,ignoreDiacritics:r,includeMatches:i}=this.options;if(e=n?e:e.toLowerCase(),e=r?MG(e):e,this.pattern===e){let m={isMatch:!0,score:0};return i&&(m.indices=[[0,e.length-1]]),m}const{location:o,distance:s,threshold:a,findAllMatches:c,minMatchCharLength:l,ignoreLocation:u}=this.options;let d=[],h=0,f=!1;this.chunks.forEach(({pattern:m,alphabet:g,startIndex:y})=>{const{isMatch:_,score:x,indices:b}=iGn(e,m,g,{location:o+y,distance:s,threshold:a,findAllMatches:c,minMatchCharLength:l,includeMatches:i,ignoreLocation:u});_&&(f=!0),h+=x,_&&b&&(d=[...d,...b])});let p={isMatch:f,score:f?h/this.chunks.length:1};return f&&i&&(p.indices=d),p}}class A8{constructor(e){this.pattern=e}static isMultiMatch(e){return Sdt(e,this.multiRegex)}static isSingleMatch(e){return Sdt(e,this.singleRegex)}search(){}}function Sdt(t,e){const n=t.match(e);return n?n[1]:null}class sGn extends A8{constructor(e){super(e)}static get type(){return"exact"}static get multiRegex(){return/^="(.*)"$/}static get singleRegex(){return/^=(.*)$/}search(e){const n=e===this.pattern;return{isMatch:n,score:n?0:1,indices:[0,this.pattern.length-1]}}}class aGn extends A8{constructor(e){super(e)}static get type(){return"inverse-exact"}static get multiRegex(){return/^!"(.*)"$/}static get singleRegex(){return/^!(.*)$/}search(e){const r=e.indexOf(this.pattern)===-1;return{isMatch:r,score:r?0:1,indices:[0,e.length-1]}}}class cGn extends A8{constructor(e){super(e)}static get type(){return"prefix-exact"}static get multiRegex(){return/^\^"(.*)"$/}static get singleRegex(){return/^\^(.*)$/}search(e){const n=e.startsWith(this.pattern);return{isMatch:n,score:n?0:1,indices:[0,this.pattern.length-1]}}}class lGn extends A8{constructor(e){super(e)}static get type(){return"inverse-prefix-exact"}static get multiRegex(){return/^!\^"(.*)"$/}static get singleRegex(){return/^!\^(.*)$/}search(e){const n=!e.startsWith(this.pattern);return{isMatch:n,score:n?0:1,indices:[0,e.length-1]}}}class uGn extends A8{constructor(e){super(e)}static get type(){return"suffix-exact"}static get multiRegex(){return/^"(.*)"\$$/}static get singleRegex(){return/^(.*)\$$/}search(e){const n=e.endsWith(this.pattern);return{isMatch:n,score:n?0:1,indices:[e.length-this.pattern.length,e.length-1]}}}class dGn extends A8{constructor(e){super(e)}static get type(){return"inverse-suffix-exact"}static get multiRegex(){return/^!"(.*)"\$$/}static get singleRegex(){return/^!(.*)\$$/}search(e){const n=!e.endsWith(this.pattern);return{isMatch:n,score:n?0:1,indices:[0,e.length-1]}}}class Mdt extends A8{constructor(e,{location:n=Lo.location,threshold:r=Lo.threshold,distance:i=Lo.distance,includeMatches:o=Lo.includeMatches,findAllMatches:s=Lo.findAllMatches,minMatchCharLength:a=Lo.minMatchCharLength,isCaseSensitive:c=Lo.isCaseSensitive,ignoreDiacritics:l=Lo.ignoreDiacritics,ignoreLocation:u=Lo.ignoreLocation}={}){super(e),this._bitapSearch=new wdt(e,{location:n,threshold:r,distance:i,includeMatches:o,findAllMatches:s,minMatchCharLength:a,isCaseSensitive:c,ignoreDiacritics:l,ignoreLocation:u})}static get type(){return"fuzzy"}static get multiRegex(){return/^"(.*)"$/}static get singleRegex(){return/^(.*)$/}search(e){return this._bitapSearch.searchIn(e)}}class Tdt extends A8{constructor(e){super(e)}static get type(){return"include"}static get multiRegex(){return/^'"(.*)"$/}static get singleRegex(){return/^'(.*)$/}search(e){let n=0,r;const i=[],o=this.pattern.length;for(;(r=e.indexOf(this.pattern,n))>-1;)n=r+o,i.push([r,n-1]);const s=!!i.length;return{isMatch:s,score:s?0:1,indices:i}}}const v2e=[sGn,Tdt,cGn,lGn,dGn,uGn,aGn,Mdt],Edt=v2e.length,hGn=/ +(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/,pGn="|";function fGn(t,e={}){return t.split(pGn).map(n=>{let r=n.trim().split(hGn).filter(o=>o&&!!o.trim()),i=[];for(let o=0,s=r.length;o<s;o+=1){const a=r[o];let c=!1,l=-1;for(;!c&&++l<Edt;){const u=v2e[l];let d=u.isMultiMatch(a);d&&(i.push(new u(d,e)),c=!0)}if(!c)for(l=-1;++l<Edt;){const u=v2e[l];let d=u.isSingleMatch(a);if(d){i.push(new u(d,e));break}}}return i})}const mGn=new Set([Mdt.type,Tdt.type]);class yGn{constructor(e,{isCaseSensitive:n=Lo.isCaseSensitive,ignoreDiacritics:r=Lo.ignoreDiacritics,includeMatches:i=Lo.includeMatches,minMatchCharLength:o=Lo.minMatchCharLength,ignoreLocation:s=Lo.ignoreLocation,findAllMatches:a=Lo.findAllMatches,location:c=Lo.location,threshold:l=Lo.threshold,distance:u=Lo.distance}={}){this.query=null,this.options={isCaseSensitive:n,ignoreDiacritics:r,includeMatches:i,minMatchCharLength:o,findAllMatches:a,ignoreLocation:s,location:c,threshold:l,distance:u},e=n?e:e.toLowerCase(),e=r?MG(e):e,this.pattern=e,this.query=fGn(this.pattern,this.options)}static condition(e,n){return n.useExtendedSearch}searchIn(e){const n=this.query;if(!n)return{isMatch:!1,score:1};const{includeMatches:r,isCaseSensitive:i,ignoreDiacritics:o}=this.options;e=i?e:e.toLowerCase(),e=o?MG(e):e;let s=0,a=[],c=0;for(let l=0,u=n.length;l<u;l+=1){const d=n[l];a.length=0,s=0;for(let h=0,f=d.length;h<f;h+=1){const p=d[h],{isMatch:m,indices:g,score:y}=p.search(e);if(m){if(s+=1,c+=y,r){const _=p.constructor.type;mGn.has(_)?a=[...a,...g]:a.push(g)}}else{c=0,s=0,a.length=0;break}}if(s){let h={isMatch:!0,score:c/s};return r&&(h.indices=a),h}}return{isMatch:!1,score:1}}}const w2e=[];function gGn(...t){w2e.push(...t)}function S2e(t,e){for(let n=0,r=w2e.length;n<r;n+=1){let i=w2e[n];if(i.condition(t,e))return new i(t,e)}return new wdt(t,e)}const TG={AND:"$and",OR:"$or"},M2e={PATH:"$path",PATTERN:"$val"},T2e=t=>!!(t[TG.AND]||t[TG.OR]),_Gn=t=>!!t[M2e.PATH],xGn=t=>!H9(t)&&ydt(t)&&!T2e(t),Cdt=t=>({[TG.AND]:Object.keys(t).map(e=>({[e]:t[e]}))});function Pdt(t,e,{auto:n=!0}={}){const r=i=>{let o=Object.keys(i);const s=_Gn(i);if(!s&&o.length>1&&!T2e(i))return r(Cdt(i));if(xGn(i)){const c=s?i[M2e.PATH]:o[0],l=s?i[M2e.PATTERN]:i[c];if(!ov(l))throw new Error(qVn(c));const u={keyId:x2e(c),pattern:l};return n&&(u.searcher=S2e(l,e)),u}let a={children:[],operator:o[0]};return o.forEach(c=>{const l=i[c];H9(l)&&l.forEach(u=>{a.children.push(r(u))})}),a};return T2e(t)||(t=Cdt(t)),r(t)}function bGn(t,{ignoreFieldNorm:e=Lo.ignoreFieldNorm}){t.forEach(n=>{let r=1;n.matches.forEach(({key:i,norm:o,score:s})=>{const a=i?i.weight:null;r*=Math.pow(s===0&&a?Number.EPSILON:s,(a||1)*(e?1:o))}),n.score=r})}function vGn(t,e){const n=t.matches;e.matches=[],Y2(n)&&n.forEach(r=>{if(!Y2(r.indices)||!r.indices.length)return;const{indices:i,value:o}=r;let s={indices:i,value:o};r.key&&(s.key=r.key.src),r.idx>-1&&(s.refIndex=r.idx),e.matches.push(s)})}function wGn(t,e){e.score=t.score}function SGn(t,e,{includeMatches:n=Lo.includeMatches,includeScore:r=Lo.includeScore}={}){const i=[];return n&&i.push(vGn),r&&i.push(wGn),t.map(o=>{const{idx:s}=o,a={item:e[s],refIndex:s};return i.length&&i.forEach(c=>{c(o,a)}),a})}class CP{constructor(e,n={},r){this.options={...Lo,...n},this.options.useExtendedSearch,this._keyStore=new QVn(this.options.keys),this.setCollection(e,r)}setCollection(e,n){if(this._docs=e,n&&!(n instanceof b2e))throw new Error(GVn);this._myIndex=n||vdt(this.options.keys,this._docs,{getFn:this.options.getFn,fieldNormWeight:this.options.fieldNormWeight})}add(e){Y2(e)&&(this._docs.push(e),this._myIndex.add(e))}remove(e=()=>!1){const n=[];for(let r=0,i=this._docs.length;r<i;r+=1){const o=this._docs[r];e(o,r)&&(this.removeAt(r),r-=1,i-=1,n.push(o))}return n}removeAt(e){this._docs.splice(e,1),this._myIndex.removeAt(e)}getIndex(){return this._myIndex}search(e,{limit:n=-1}={}){const{includeMatches:r,includeScore:i,shouldSort:o,sortFn:s,ignoreFieldNorm:a}=this.options;let c=ov(e)?ov(this._docs[0])?this._searchStringList(e):this._searchObjectList(e):this._searchLogical(e);return bGn(c,{ignoreFieldNorm:a}),o&&c.sort(s),mdt(n)&&n>-1&&(c=c.slice(0,n)),SGn(c,this._docs,{includeMatches:r,includeScore:i})}_searchStringList(e){const n=S2e(e,this.options),{records:r}=this._myIndex,i=[];return r.forEach(({v:o,i:s,n:a})=>{if(!Y2(o))return;const{isMatch:c,score:l,indices:u}=n.searchIn(o);c&&i.push({item:o,idx:s,matches:[{score:l,value:o,norm:a,indices:u}]})}),i}_searchLogical(e){const n=Pdt(e,this.options),r=(a,c,l)=>{if(!a.children){const{keyId:d,searcher:h}=a,f=this._findMatches({key:this._keyStore.get(d),value:this._myIndex.getValueForItemAtKeyId(c,d),searcher:h});return f&&f.length?[{idx:l,item:c,matches:f}]:[]}const u=[];for(let d=0,h=a.children.length;d<h;d+=1){const f=a.children[d],p=r(f,c,l);if(p.length)u.push(...p);else if(a.operator===TG.AND)return[]}return u},i=this._myIndex.records,o={},s=[];return i.forEach(({$:a,i:c})=>{if(Y2(a)){let l=r(n,a,c);l.length&&(o[c]||(o[c]={idx:c,item:a,matches:[]},s.push(o[c])),l.forEach(({matches:u})=>{o[c].matches.push(...u)}))}}),s}_searchObjectList(e){const n=S2e(e,this.options),{keys:r,records:i}=this._myIndex,o=[];return i.forEach(({$:s,i:a})=>{if(!Y2(s))return;let c=[];r.forEach((l,u)=>{c.push(...this._findMatches({key:l,value:s[u],searcher:n}))}),c.length&&o.push({idx:a,item:s,matches:c})}),o}_findMatches({key:e,value:n,searcher:r}){if(!Y2(n))return[];let i=[];if(H9(n))n.forEach(({v:o,i:s,n:a})=>{if(!Y2(o))return;const{isMatch:c,score:l,indices:u}=r.searchIn(o);c&&i.push({score:l,key:e,value:o,idx:s,norm:a,indices:u})});else{const{v:o,n:s}=n,{isMatch:a,score:c,indices:l}=r.searchIn(o);a&&i.push({score:c,key:e,value:o,norm:s,indices:l})}return i}}CP.version="7.1.0",CP.createIndex=vdt,CP.parseIndex=nGn,CP.config=Lo,CP.parseQuery=Pdt,gGn(yGn);let E2e=null,AO=null,C2e=null;const MGn=async()=>E2e||AO||(AO=fetch("https://kicad-mod-cache.tscircuit.com/kicad_files.json").then(t=>t.json()).then(t=>(E2e=t,AO=null,t)),AO),TGn=async(t,e=20)=>{const n=await MGn();return C2e||(C2e=new CP(n)),C2e.search(t).slice(0,e).map(r=>r.item)},EGn=t=>{const e=t.replace(".pretty/",":").replace(".kicad_mod",""),n=`kicad:${e}`;return{path:t,qualifiedName:n,description:e}},CGn=()=>{const[t,e]=te.useState([]),[n,r]=te.useState(!1),[i,o]=te.useState(null),[s,a]=te.useState(!1),c=te.useCallback(async u=>{const d=u.trim();if(!d)return[];r(!0),o(null);try{const f=(await TGn(d,20)).map(p=>({source:"kicad",footprint:EGn(p)}));return e(f),f}catch(h){return console.error("Error searching KiCad footprints",h),e([]),o(h instanceof Error?h.message:"Failed to search KiCad footprints"),[]}finally{r(!1),a(!0)}},[]),l=te.useCallback(()=>{e([]),r(!1),o(null),a(!1)},[]);return{results:t,isSearching:n,error:i,hasSearched:s,search:c,reset:l}},PGn={dialog:101},AGn=({onTscircuitPackageSelected:t,onJlcpcbComponentTsxLoaded:e,onKicadStringSelected:n})=>{const r=[];return t&&r.push("tscircuit.com"),e&&r.push("jlcpcb"),n&&r.push("kicad"),r},RGn=({isOpen:t,onClose:e,jlcpcbProxyRequestHeaders:n,onKicadStringSelected:r,onTscircuitPackageSelected:i,onJlcpcbComponentTsxLoaded:o,jlcpcbProxyApiBase:s,tscircuitSessionToken:a})=>{i0t();const c=te.useMemo(()=>AGn({onKicadStringSelected:r,onTscircuitPackageSelected:i,onJlcpcbComponentTsxLoaded:o}),[r,i,o]),l=c.length>0,u=c.length===1,[d,h]=te.useState(c[0]??"tscircuit.com"),[f,p]=te.useState(""),[m,g]=te.useState(null),{results:y,isSearching:_,error:x,hasSearched:b,search:w,reset:S}=BVn({sessionToken:a}),{results:T,isSearching:C,error:A,hasSearched:R,search:L,reset:O}=UVn(),{results:F,isSearching:B,error:j,hasSearched:V,search:q,reset:K}=CGn(),{details:ne,isLoading:le,fetchDetails:ee,reset:ie}=$Vn(),[ce,ue]=te.useState(null),[_e,Ce]=te.useState(!1),[Ae,ke]=te.useState("pcb"),[ye,Me]=te.useState(null),[fe,Ye]=te.useState(!1);te.useEffect(()=>{Me(null)},[m]);const He=te.useCallback(()=>{S(),O(),K(),g(null)},[O,K,S]);te.useEffect(()=>{t||(He(),p(""),Ce(!1),ue(null),Me(null))},[t,He]),te.useEffect(()=>{p(""),g(null),d==="tscircuit.com"?S():d==="jlcpcb"?O():d==="kicad"&&K()},[d,O,K,S]);const We=Be=>{g(Be),ue(Be),ke("pcb"),Ce(!0),ie();const Xe=Be.package.org_owner_tscircuit_handle,et=Be.package.unscoped_name;if(Xe&&et){const rt=et.split("/").pop()??et;ee(Xe,rt)}},ge=async()=>{f.trim()&&(g(null),d==="tscircuit.com"?await w(f):d==="jlcpcb"?await L(f):d==="kicad"&&await q(f))},Ke=async Be=>{try{if(Me(null),Ye(!0),Be.source==="kicad"){if(!r)throw new Error("KiCad handler not provided");await r({result:Be,footprint:Be.footprint.qualifiedName})}else if(Be.source==="jlcpcb"){if(!o)throw new Error("JLCPCB handler not provided");const Xe=await AVn(Be.component.partNumber,{headers:n,apiBase:s});await o({result:Be,tsx:Xe})}else if(Be.source==="tscircuit.com"){if(!i)throw new Error("tscircuit package handler not provided");const Xe=Be.package.org_owner_tscircuit_handle,et=Be.package.unscoped_name;if(!Xe||!et)throw new Error("Missing package metadata");const rt=et.split("/").pop()??et,at=`@tsci/${Xe}.${rt}`;await i({result:Be,fullPackageName:at})}return!0}catch(Xe){return console.error("Failed to import component",Xe),Me(Xe instanceof Error?Xe.message:"Failed to import component"),!1}finally{Ye(!1)}};let $e=[],Ne=!1,Ue=null,Ie=!1;d==="tscircuit.com"?($e=y,Ne=_,Ue=x,Ie=b):d==="jlcpcb"?($e=T,Ne=C,Ue=A,Ie=R):d==="kicad"&&($e=F,Ne=B,Ue=j,Ie=V);const we=async()=>{if(!m)return;await Ke(m)&&(e(),He(),p(""))},Ee=Be=>{Be||e()},Te=Be=>{Ce(Be),Be||ue(null)};return G.jsxs(EO,{open:t,onOpenChange:Ee,children:[G.jsxs(MP,{style:{width:"calc(100vw - 2rem)",zIndex:PGn.dialog},className:"rf-rounded-sm rf-max-h-[90vh] rf-overflow-y-auto rf-overflow-x-hidden rf-flex rf-flex-col",children:[G.jsxs(TP,{children:[G.jsxs(EP,{className:"rf-text-lg sm:rf-text-xl",children:["Import ",u?wG[d].label:""," ","Component"]}),G.jsx(PO,{className:"rf-text-sm",children:l?"Search for components from available sources.":"Import options are disabled because no handlers were provided."})]}),l?G.jsxs(KW,{value:d,onValueChange:Be=>h(Be),className:"rf-min-w-0 rf-w-full",children:[!u&&G.jsx(sD,{className:"rf-flex rf-w-full rf-gap-2",children:c.map(Be=>G.jsx(B4,{value:Be,className:"rf-flex-1 rf-text-xs sm:rf-text-sm",children:wG[Be].label},Be))}),G.jsx(RVn,{query:f,placeholder:wG[d].placeholder,isSearching:Ne,onQueryChange:p,onSubmit:ge}),G.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:Ne?G.jsxs("div",{className:"rf-p-8 rf-text-center rf-text-zinc-500",children:[G.jsx(o8,{className:"rf-h-8 rf-w-8 rf-animate-spin rf-mx-auto rf-mb-2"}),G.jsx("p",{children:"Searching..."})]}):$e.length>0?G.jsx(DVn,{results:$e,selected:m,onSelect:g,onShowDetails:d==="tscircuit.com"?We:void 0}):G.jsx("div",{className:"rf-p-8 rf-text-center rf-text-zinc-500",children:Ue?`Error: ${Ue}`:Ie?wG[d].emptyMessage:"Enter a search term to find components"})})]}):null,ye?G.jsx("div",{className:"rf-text-sm rf-text-red-600 rf-mt-2",children:ye}):null,G.jsxs(CO,{className:"rf-flex rf-flex-col sm:rf-flex-row rf-gap-2",children:[G.jsx(Tu,{variant:"outline",onClick:e,className:"rf-order-2 sm:rf-order-1",children:"Cancel"}),G.jsx(Tu,{onClick:we,disabled:!m||fe,className:"rf-order-1 sm:rf-order-2",children:fe?G.jsx(o8,{className:"rf-h-4 rf-w-4 rf-animate-spin"}):"Import"})]})]}),G.jsx(zVn,{packageResult:ce,isOpen:_e,onOpenChange:Te,isLoading:le,details:ne,previewTab:Ae,onPreviewTabChange:Be=>ke(Be),isSubmitting:fe,onImport:()=>{ce&&Ke(ce).then(Be=>{Be&&(Ce(!1),e(),He(),p(""))})}})]})},IGn=t=>{const e=t.match(/export const (\w+) =/);if(!e)throw new Error("Could not determine component name from TSX contents");return e[1]},Adt=t=>{const e=iv(s=>s.pushEvent),n=iv(s=>s.upsertFile),r=async({result:s,fullPackageName:a})=>{const l=s.package.unscoped_name??s.package.name;await Ps.promise(e({event_type:"INSTALL_PACKAGE",full_package_name:a}),{loading:`Requesting install for "${l}"`,success:`Install requested for "${l}"`,error:u=>`Failed to request install: ${u instanceof Error?u.message:String(u)}`})},i=async({footprint:s})=>{await Ps.promise(navigator.clipboard.writeText(s),{loading:`Copying "${s}"`,success:`Copied "${s}" to clipboard`,error:a=>`Failed to copy footprint: ${a instanceof Error?a.message:String(a)}`})},o=async({result:s,tsx:a})=>{const l=`imports/${IGn(a)}.tsx`;await Ps.promise(n(l,a),{loading:`Importing ${s.component.partNumber}`,success:`Imported to "${l}"`,error:u=>`Failed to import component: ${u instanceof Error?u.message:String(u)}`})};return G.jsx(RGn,{...t,onTscircuitPackageSelected:r,onKicadStringSelected:i,onJlcpcbComponentTsxLoaded:o})};Adt.displayName="ImportComponentDialogForCli";var P2e={exports:{}},Rdt;function NGn(){return Rdt||(Rdt=1,(function(t,e){var n={env:{},version:""};(function(r){t.exports=r()})(function(){return(function r(i,o,s){function a(u,d){if(!o[u]){if(!i[u]){var h=typeof o3=="function"&&o3;if(!d&&h)return h(u,!0);if(c)return c(u,!0);var f=new Error("Cannot find module '"+u+"'");throw f.code="MODULE_NOT_FOUND",f}var p=o[u]={exports:{}};i[u][0].call(p.exports,function(m){var g=i[u][1][m];return a(g||m)},p,p.exports,r,i,o,s)}return o[u].exports}for(var c=typeof o3=="function"&&o3,l=0;l<s.length;l++)a(s[l]);return a})({1:[function(r,i,o){var s=r("./utils"),a=r("./support"),c="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";o.encode=function(l){for(var u,d,h,f,p,m,g,y=[],_=0,x=l.length,b=x,w=s.getTypeOf(l)!=="string";_<l.length;)b=x-_,h=w?(u=l[_++],d=_<x?l[_++]:0,_<x?l[_++]:0):(u=l.charCodeAt(_++),d=_<x?l.charCodeAt(_++):0,_<x?l.charCodeAt(_++):0),f=u>>2,p=(3&u)<<4|d>>4,m=1<b?(15&d)<<2|h>>6:64,g=2<b?63&h:64,y.push(c.charAt(f)+c.charAt(p)+c.charAt(m)+c.charAt(g));return y.join("")},o.decode=function(l){var u,d,h,f,p,m,g=0,y=0,_="data:";if(l.substr(0,_.length)===_)throw new Error("Invalid base64 input, it looks like a data url.");var x,b=3*(l=l.replace(/[^A-Za-z0-9+/=]/g,"")).length/4;if(l.charAt(l.length-1)===c.charAt(64)&&b--,l.charAt(l.length-2)===c.charAt(64)&&b--,b%1!=0)throw new Error("Invalid base64 input, bad content length.");for(x=a.uint8array?new Uint8Array(0|b):new Array(0|b);g<l.length;)u=c.indexOf(l.charAt(g++))<<2|(f=c.indexOf(l.charAt(g++)))>>4,d=(15&f)<<4|(p=c.indexOf(l.charAt(g++)))>>2,h=(3&p)<<6|(m=c.indexOf(l.charAt(g++))),x[y++]=u,p!==64&&(x[y++]=d),m!==64&&(x[y++]=h);return x}},{"./support":30,"./utils":32}],2:[function(r,i,o){var s=r("./external"),a=r("./stream/DataWorker"),c=r("./stream/Crc32Probe"),l=r("./stream/DataLengthProbe");function u(d,h,f,p,m){this.compressedSize=d,this.uncompressedSize=h,this.crc32=f,this.compression=p,this.compressedContent=m}u.prototype={getContentWorker:function(){var d=new a(s.Promise.resolve(this.compressedContent)).pipe(this.compression.uncompressWorker()).pipe(new l("data_length")),h=this;return d.on("end",function(){if(this.streamInfo.data_length!==h.uncompressedSize)throw new Error("Bug : uncompressed data size mismatch")}),d},getCompressedWorker:function(){return new a(s.Promise.resolve(this.compressedContent)).withStreamInfo("compressedSize",this.compressedSize).withStreamInfo("uncompressedSize",this.uncompressedSize).withStreamInfo("crc32",this.crc32).withStreamInfo("compression",this.compression)}},u.createWorkerFrom=function(d,h,f){return d.pipe(new c).pipe(new l("uncompressedSize")).pipe(h.compressWorker(f)).pipe(new l("compressedSize")).withStreamInfo("compression",h)},i.exports=u},{"./external":6,"./stream/Crc32Probe":25,"./stream/DataLengthProbe":26,"./stream/DataWorker":27}],3:[function(r,i,o){var s=r("./stream/GenericWorker");o.STORE={magic:"\0\0",compressWorker:function(){return new s("STORE compression")},uncompressWorker:function(){return new s("STORE decompression")}},o.DEFLATE=r("./flate")},{"./flate":7,"./stream/GenericWorker":28}],4:[function(r,i,o){var s=r("./utils"),a=(function(){for(var c,l=[],u=0;u<256;u++){c=u;for(var d=0;d<8;d++)c=1&c?3988292384^c>>>1:c>>>1;l[u]=c}return l})();i.exports=function(c,l){return c!==void 0&&c.length?s.getTypeOf(c)!=="string"?(function(u,d,h,f){var p=a,m=f+h;u^=-1;for(var g=f;g<m;g++)u=u>>>8^p[255&(u^d[g])];return-1^u})(0|l,c,c.length,0):(function(u,d,h,f){var p=a,m=f+h;u^=-1;for(var g=f;g<m;g++)u=u>>>8^p[255&(u^d.charCodeAt(g))];return-1^u})(0|l,c,c.length,0):0}},{"./utils":32}],5:[function(r,i,o){o.base64=!1,o.binary=!1,o.dir=!1,o.createFolders=!0,o.date=null,o.compression=null,o.compressionOptions=null,o.comment=null,o.unixPermissions=null,o.dosPermissions=null},{}],6:[function(r,i,o){var s=null;s=typeof Promise<"u"?Promise:r("lie"),i.exports={Promise:s}},{lie:37}],7:[function(r,i,o){var s=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Uint32Array<"u",a=r("pako"),c=r("./utils"),l=r("./stream/GenericWorker"),u=s?"uint8array":"array";function d(h,f){l.call(this,"FlateWorker/"+h),this._pako=null,this._pakoAction=h,this._pakoOptions=f,this.meta={}}o.magic="\b\0",c.inherits(d,l),d.prototype.processChunk=function(h){this.meta=h.meta,this._pako===null&&this._createPako(),this._pako.push(c.transformTo(u,h.data),!1)},d.prototype.flush=function(){l.prototype.flush.call(this),this._pako===null&&this._createPako(),this._pako.push([],!0)},d.prototype.cleanUp=function(){l.prototype.cleanUp.call(this),this._pako=null},d.prototype._createPako=function(){this._pako=new a[this._pakoAction]({raw:!0,level:this._pakoOptions.level||-1});var h=this;this._pako.onData=function(f){h.push({data:f,meta:h.meta})}},o.compressWorker=function(h){return new d("Deflate",h)},o.uncompressWorker=function(){return new d("Inflate",{})}},{"./stream/GenericWorker":28,"./utils":32,pako:38}],8:[function(r,i,o){function s(p,m){var g,y="";for(g=0;g<m;g++)y+=String.fromCharCode(255&p),p>>>=8;return y}function a(p,m,g,y,_,x){var b,w,S=p.file,T=p.compression,C=x!==u.utf8encode,A=c.transformTo("string",x(S.name)),R=c.transformTo("string",u.utf8encode(S.name)),L=S.comment,O=c.transformTo("string",x(L)),F=c.transformTo("string",u.utf8encode(L)),B=R.length!==S.name.length,j=F.length!==L.length,V="",q="",K="",ne=S.dir,le=S.date,ee={crc32:0,compressedSize:0,uncompressedSize:0};m&&!g||(ee.crc32=p.crc32,ee.compressedSize=p.compressedSize,ee.uncompressedSize=p.uncompressedSize);var ie=0;m&&(ie|=8),C||!B&&!j||(ie|=2048);var ce=0,ue=0;ne&&(ce|=16),_==="UNIX"?(ue=798,ce|=(function(Ce,Ae){var ke=Ce;return Ce||(ke=Ae?16893:33204),(65535&ke)<<16})(S.unixPermissions,ne)):(ue=20,ce|=(function(Ce){return 63&(Ce||0)})(S.dosPermissions)),b=le.getUTCHours(),b<<=6,b|=le.getUTCMinutes(),b<<=5,b|=le.getUTCSeconds()/2,w=le.getUTCFullYear()-1980,w<<=4,w|=le.getUTCMonth()+1,w<<=5,w|=le.getUTCDate(),B&&(q=s(1,1)+s(d(A),4)+R,V+="up"+s(q.length,2)+q),j&&(K=s(1,1)+s(d(O),4)+F,V+="uc"+s(K.length,2)+K);var _e="";return _e+=`
|
|
5688
|
+
For more information, see https://radix-ui.com/primitives/docs/components/alert-dialog`;return te.useEffect(()=>{document.getElementById(t.current?.getAttribute("aria-describedby"))||console.warn(e)},[e,t]),null},mVn=j0t,yVn=U0t,Q0t=H0t,J0t=Y0t,edt=W0t,tdt=K0t,ndt=V0t,rdt=q0t;const idt=mVn,gVn=yVn,odt=te.forwardRef(({className:t,...e},n)=>G.jsx(Q0t,{className:go("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}));odt.displayName=Q0t.displayName;const l2e=te.forwardRef(({className:t,...e},n)=>G.jsxs(gVn,{children:[G.jsx(odt,{}),G.jsx(J0t,{ref:n,className:go("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})]}));l2e.displayName=J0t.displayName;const u2e=({className:t,...e})=>G.jsx("div",{className:go("rf-flex rf-flex-col rf-space-y-2 rf-text-center sm:rf-text-left",t),...e});u2e.displayName="AlertDialogHeader";const d2e=({className:t,...e})=>G.jsx("div",{className:go("rf-flex rf-flex-col-reverse sm:rf-flex-row sm:rf-justify-end sm:rf-space-x-2",t),...e});d2e.displayName="AlertDialogFooter";const h2e=te.forwardRef(({className:t,...e},n)=>G.jsx(ndt,{ref:n,className:go("rf-text-lg rf-font-semibold",t),...e}));h2e.displayName=ndt.displayName;const p2e=te.forwardRef(({className:t,...e},n)=>G.jsx(rdt,{ref:n,className:go("rf-text-sm rf-text-zinc-500 dark:rf-text-zinc-400",t),...e}));p2e.displayName=rdt.displayName;const _Vn=te.forwardRef(({className:t,...e},n)=>G.jsx(edt,{ref:n,className:go(XC(),t),...e}));_Vn.displayName=edt.displayName;const f2e=te.forwardRef(({className:t,...e},n)=>G.jsx(tdt,{ref:n,className:go(XC({variant:"outline"}),"rf-mt-2 sm:rf-mt-0",t),...e}));f2e.displayName=tdt.displayName;function xVn(t){const e=te.useRef({value:t,previous:t});return te.useMemo(()=>(e.current.value!==t&&(e.current.previous=e.current.value,e.current.value=t),e.current.previous),[t])}var vG="Checkbox",[bVn]=vv(vG),[vVn,m2e]=bVn(vG);function wVn(t){const{__scopeCheckbox:e,checked:n,children:r,defaultChecked:i,disabled:o,form:s,name:a,onCheckedChange:c,required:l,value:u="on",internal_do_not_use_render:d}=t,[h,f]=hM({prop:n,defaultProp:i??!1,onChange:c,caller:vG}),[p,m]=te.useState(null),[g,y]=te.useState(null),_=te.useRef(!1),x=p?!!s||!!p.closest("form"):!0,b={checked:h,disabled:o,setChecked:f,control:p,setControl:m,name:a,form:s,value:u,hasConsumerStoppedPropagationRef:_,required:l,defaultChecked:P8(i)?!1:i,isFormControl:x,bubbleInput:g,setBubbleInput:y};return G.jsx(vVn,{scope:e,...b,children:SVn(d)?d(b):r})}var sdt="CheckboxTrigger",adt=te.forwardRef(({__scopeCheckbox:t,onKeyDown:e,onClick:n,...r},i)=>{const{control:o,value:s,disabled:a,checked:c,required:l,setControl:u,setChecked:d,hasConsumerStoppedPropagationRef:h,isFormControl:f,bubbleInput:p}=m2e(sdt,t),m=_h(i,u),g=te.useRef(c);return te.useEffect(()=>{const y=o?.form;if(y){const _=()=>d(g.current);return y.addEventListener("reset",_),()=>y.removeEventListener("reset",_)}},[o,d]),G.jsx(jl.button,{type:"button",role:"checkbox","aria-checked":P8(c)?"mixed":c,"aria-required":l,"data-state":hdt(c),"data-disabled":a?"":void 0,disabled:a,value:s,...r,ref:m,onKeyDown:Qo(e,y=>{y.key==="Enter"&&y.preventDefault()}),onClick:Qo(n,y=>{d(_=>P8(_)?!0:!_),p&&f&&(h.current=y.isPropagationStopped(),h.current||y.stopPropagation())})})});adt.displayName=sdt;var y2e=te.forwardRef((t,e)=>{const{__scopeCheckbox:n,name:r,checked:i,defaultChecked:o,required:s,disabled:a,value:c,onCheckedChange:l,form:u,...d}=t;return G.jsx(wVn,{__scopeCheckbox:n,checked:i,defaultChecked:o,disabled:a,required:s,onCheckedChange:l,name:r,form:u,value:c,internal_do_not_use_render:({isFormControl:h})=>G.jsxs(G.Fragment,{children:[G.jsx(adt,{...d,ref:e,__scopeCheckbox:n}),h&&G.jsx(ddt,{__scopeCheckbox:n})]})})});y2e.displayName=vG;var cdt="CheckboxIndicator",ldt=te.forwardRef((t,e)=>{const{__scopeCheckbox:n,forceMount:r,...i}=t,o=m2e(cdt,n);return G.jsx(z4,{present:r||P8(o.checked)||o.checked===!0,children:G.jsx(jl.span,{"data-state":hdt(o.checked),"data-disabled":o.disabled?"":void 0,...i,ref:e,style:{pointerEvents:"none",...t.style}})})});ldt.displayName=cdt;var udt="CheckboxBubbleInput",ddt=te.forwardRef(({__scopeCheckbox:t,...e},n)=>{const{control:r,hasConsumerStoppedPropagationRef:i,checked:o,defaultChecked:s,required:a,disabled:c,name:l,value:u,form:d,bubbleInput:h,setBubbleInput:f}=m2e(udt,t),p=_h(n,f),m=xVn(o),g=mtt(r);te.useEffect(()=>{const _=h;if(!_)return;const x=window.HTMLInputElement.prototype,w=Object.getOwnPropertyDescriptor(x,"checked").set,S=!i.current;if(m!==o&&w){const T=new Event("click",{bubbles:S});_.indeterminate=P8(o),w.call(_,P8(o)?!1:o),_.dispatchEvent(T)}},[h,m,o,i]);const y=te.useRef(P8(o)?!1:o);return G.jsx(jl.input,{type:"checkbox","aria-hidden":!0,defaultChecked:s??y.current,required:a,disabled:c,name:l,value:u,form:d,...e,tabIndex:-1,ref:p,style:{...e.style,...g,position:"absolute",pointerEvents:"none",opacity:0,margin:0,transform:"translateX(-100%)"}})});ddt.displayName=udt;function SVn(t){return typeof t=="function"}function P8(t){return t==="indeterminate"}function hdt(t){return P8(t)?"indeterminate":t?"checked":"unchecked"}const TO=te.forwardRef(({className:t,...e},n)=>G.jsx(y2e,{ref:n,className:go("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:G.jsx(ldt,{className:go("rf-flex rf-items-center rf-justify-center rf-text-current"),children:G.jsx(H1e,{className:"rf-h-4 rf-w-4"})})}));TO.displayName=y2e.displayName;const EO=z0t,MVn=$0t,pdt=te.forwardRef(({className:t,...e},n)=>G.jsx(o2e,{className:go("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}));pdt.displayName=o2e.displayName;const MP=te.forwardRef(({className:t,children:e,showOverlay:n=!0,...r},i)=>G.jsxs(MVn,{children:[G.jsx(pdt,{className:go(n?"":"rf-hidden")}),G.jsx(s2e,{ref:i,className:go("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),...r,children:e})]}));MP.displayName=s2e.displayName;const TP=({className:t,...e})=>G.jsx("div",{className:go("rf-flex rf-flex-col rf-space-y-2 rf-text-center sm:rf-text-left",t),...e});TP.displayName="DialogHeader";const CO=({className:t,...e})=>G.jsx("div",{className:go("rf-flex rf-flex-col-reverse sm:rf-flex-row sm:rf-justify-end sm:rf-space-x-2",t),...e});CO.displayName="DialogFooter";const EP=te.forwardRef(({className:t,...e},n)=>G.jsx(a2e,{ref:n,className:go("rf-text-lg rf-font-semibold",t),...e}));EP.displayName=a2e.displayName;const PO=te.forwardRef(({className:t,...e},n)=>G.jsx(c2e,{ref:n,className:go("rf-text-sm rf-text-zinc-500 dark:rf-text-zinc-400",t),...e}));PO.displayName=c2e.displayName;const wG={"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"}},TVn="https://cdn.jsdelivr.net/npm/easyeda@latest/dist/browser/index.js";let g2e=null;const EVn=async()=>(g2e||(g2e=import(TVn)),g2e),CVn=async(t,e=10)=>{const n=encodeURIComponent(t),r=await fetch(`https://jlcsearch.tscircuit.com/api/search?limit=${e}&q=${n}`);if(!r.ok)throw new Error(`JLCPCB API error: ${r.status}`);return(await r.json()).components??[]},PVn=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}),AVn=async(t,e)=>{const{fetchEasyEDAComponent:n,convertRawEasyToTsx:r}=await EVn(),i=await n(t,{fetch:(o,s)=>fetch(`${e?.apiBase??j9}/proxy`,{...s,headers:{...s?.headers,"X-Target-Url":o.toString(),"X-Sender-Origin":s?.headers?.origin??"","X-Sender-Host":s?.headers?.host??"https://easyeda.com","X-Sender-Referer":s?.headers?.referer??"","X-Sender-User-Agent":s?.headers?.userAgent??"","X-Sender-Cookie":s?.headers?.cookie??"",authority:s?.headers?.authority??"","content-type":s?.headers?.["content-type"]??"",...e?.headers}})});return r({rawEasy:i})},RVn=({query:t,placeholder:e,isSearching:n,onQueryChange:r,onSubmit:i})=>{const o=te.useCallback(s=>{s.key==="Enter"&&(s.preventDefault(),i())},[i]);return G.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2 rf-mt-4",children:[G.jsxs("div",{className:"rf-relative rf-flex-grow",children:[G.jsx(Oet,{className:"rf-absolute rf-left-2 rf-top-2.5 rf-h-4 rf-w-4 rf-text-muted-foreground"}),G.jsx(Sge,{placeholder:e,className:"rf-pl-8",spellCheck:!1,autoComplete:"off",value:t,onChange:s=>r(s.target.value),onKeyDown:o})]}),G.jsx(Tu,{onClick:i,disabled:n||t.trim().length<1,className:"sm:rf-px-4 rf-px-3",children:n?G.jsx(o8,{className:"rf-h-4 rf-w-4 rf-animate-spin"}):G.jsxs(G.Fragment,{children:[G.jsx(Oet,{className:"rf-h-4 rf-w-4 sm:rf-hidden"}),G.jsx("span",{className:"rf-hidden sm:rf-inline",children:"Search"})]})})]})},IVn=new Intl.NumberFormat("en-US",{style:"currency",currency:"USD"}),NVn=t=>IVn.format(t),fdt=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"}},kVn=t=>{switch(t.source){case"tscircuit.com":return t.package.unscoped_name;case"jlcpcb":return t.component.manufacturer;case"kicad":return t.footprint.qualifiedName}},OVn=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}},LVn=t=>{switch(t.source){case"tscircuit.com":return t.package.name;case"jlcpcb":return t.component.partNumber;case"kicad":return}},DVn=({results:t,selected:e,onSelect:n,onShowDetails:r})=>{const i=e?fdt(e):null;return G.jsx("div",{className:"rf-divide-y rf-w-full rf-overflow-hidden",children:t.map(o=>{const s=fdt(o),a=i===s,c=kVn(o),l=OVn(o),u=LVn(o),d=o.source==="jlcpcb"?o.component.stock:null,h=o.source==="jlcpcb"?o.component.price:null,f=o.source==="jlcpcb"?o.component.isBasic:null;return G.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 ${a?"rf-bg-zinc-100":""}`,onClick:()=>n(o),children:[G.jsxs("div",{className:"rf-min-w-0 rf-overflow-hidden rf-w-full",children:[G.jsxs("div",{className:"rf-flex rf-items-start rf-gap-2 rf-min-w-0",children:[G.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:[c,o.source==="jlcpcb"&&f!=null&&G.jsx("span",{className:`rf-text-xs rf-px-1.5 rf-py-0.5 rf-rounded rf-font-medium rf-flex-shrink-0 ${f?"rf-bg-green-100 rf-text-green-700":"rf-bg-orange-100 rf-text-orange-700"}`,children:f?"Basic":"Extended"}),o.source==="tscircuit.com"&&o.package.is_private&&G.jsx(GMn,{className:"rf-ml-1 rf-h-3 rf-w-3 rf-text-zinc-400 rf-flex-shrink-0"})]}),o.source==="jlcpcb"&&d!=null?G.jsxs("div",{className:"rf-text-xs rf-text-zinc-500 rf-font-medium rf-whitespace-nowrap rf-flex-shrink-0 sm:rf-hidden",children:[d.toLocaleString()," in stock"]}):null]}),G.jsxs("div",{className:"rf-text-xs rf-text-zinc-500 rf-truncate rf-w-full",children:[u?G.jsx("span",{className:"rf-mr-2",children:u}):null,l]})]}),G.jsxs("div",{children:[o.source==="tscircuit.com"&&r?G.jsx("div",{className:"rf-flex-shrink-0 rf-w-full sm:rf-w-auto",children:G.jsx(Tu,{variant:"outline",size:"sm",className:"rf-text-xs rf-w-full sm:rf-w-auto",onClick:p=>{p.stopPropagation(),r(o)},children:"See Details"})}):o.source==="jlcpcb"&&d!=null?G.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:[d.toLocaleString()," in stock"]}):null,h!=null&&G.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:NVn(h)})]})]},s)})})},zVn=({packageResult:t,isOpen:e,onOpenChange:n,isLoading:r,details:i,previewTab:o,onPreviewTabChange:s,isSubmitting:a,onImport:c})=>{const l=t?.package??null,u=l?.latest_pcb_preview_image_url,d=l?.latest_sch_preview_image_url,h=l?.latest_cad_preview_image_url,f=l?.unscoped_name?.split("/").pop()??l?.unscoped_name,p=l?.org_owner_tscircuit_handle??void 0,m=p?`https://tscircuit.com/${p}`:void 0,g=p&&f?`https://tscircuit.com/${p}/${f}`:void 0;return G.jsx(EO,{open:e,onOpenChange:n,children:G.jsxs(MP,{showOverlay:!1,style:{width:"calc(100vw - 2rem)"},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:[G.jsx(TP,{className:"rf-pb-4 rf-border-b",children:G.jsx("div",{className:"rf-flex rf-items-start rf-justify-between rf-gap-4",children:G.jsxs("div",{className:"rf-flex-1 rf-min-w-0",children:[G.jsx(EP,{className:"rf-text-xl rf-font-semibold rf-truncate",children:f}),G.jsx(PO,{children:l?.description})]})})}),G.jsxs("div",{className:"rf-flex-1 rf-overflow-y-auto rf-py-4 rf-space-y-6",children:[p?G.jsxs("div",{children:[G.jsx("span",{className:"rf-text-xs rf-font-medium rf-text-gray-500 rf-uppercase rf-tracking-wide",children:"Created by"}),G.jsx("div",{className:"rf-mt-1 rf-text-sm rf-font-medium",children:m?G.jsx("a",{href:m,target:"_blank",rel:"noopener noreferrer",className:"rf-text-black hover:rf-underline",children:p}):p})]}):null,(h||u||d)&&G.jsx(G.Fragment,{children:G.jsxs("div",{children:[G.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-mb-4",children:"Preview"}),G.jsxs(KW,{value:o,onValueChange:y=>s(y),children:[G.jsxs(sD,{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:[u&&G.jsx(B4,{value:"pcb",children:"PCB"}),d&&G.jsx(B4,{value:"schematic",children:"Schematic"}),h&&G.jsx(B4,{value:"3d",children:"3D"})]}),G.jsxs("div",{className:"rf-mt-4",children:[G.jsx(K1,{value:"pcb",className:"rf-border rf-rounded-lg rf-overflow-hidden rf-bg-gray-50",children:u?G.jsx("img",{src:u,alt:`${f??"package"} PCB preview`,className:"rf-w-full rf-h-full rf-object-contain rf-bg-white rf-p-4"}):null}),G.jsx(K1,{value:"schematic",className:"rf-border rf-rounded-lg rf-overflow-hidden rf-bg-gray-50",children:d?G.jsx("img",{src:d,alt:`${f??"package"} schematic preview`,className:"rf-w-full rf-h-full rf-object-contain rf-bg-white rf-p-4"}):null}),G.jsx(K1,{value:"3d",className:"rf-border rf-rounded-lg rf-overflow-hidden rf-bg-gray-50",children:h?G.jsx("img",{src:h,alt:`${f??"package"} 3D preview`,className:"rf-w-full rf-h-full rf-object-contain rf-bg-white rf-p-4"}):null})]})]})]})}),i?.ai_description?G.jsxs("section",{children:[G.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-mb-3",children:"AI Description"}),G.jsx("div",{className:"rf-bg-gray-50 rf-border rf-border-gray-200 rf-rounded-lg rf-p-4",children:G.jsx("p",{className:"rf-text-sm rf-text-gray-700 rf-leading-relaxed",children:i.ai_description})})]}):null,i?.ai_usage_instructions?G.jsxs("section",{children:[G.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-mb-3",children:"Usage Instructions"}),G.jsx("div",{className:"rf-bg-gray-50 rf-border rf-border-gray-200 rf-rounded-lg rf-p-4",children:G.jsx("p",{className:"rf-text-sm rf-text-gray-700 rf-leading-relaxed rf-whitespace-pre-wrap",children:i.ai_usage_instructions})})]}):null,r?G.jsxs("div",{className:"rf-flex rf-justify-center rf-items-center rf-gap-2 rf-text-gray-500",children:[G.jsx(o8,{className:"rf-h-4 rf-w-4 rf-animate-spin"}),G.jsx("span",{className:"rf-text-sm",children:"Loading package details..."})]}):null]}),G.jsxs(CO,{className:"rf-pt-4 rf-border-t rf-flex rf-flex-col sm:rf-flex-row rf-justify-between rf-gap-2",children:[G.jsx("div",{className:"rf-flex-1",children:g?G.jsxs(Tu,{variant:"outline",size:"sm",className:"rf-gap-2 rf-w-full sm:rf-w-auto",onClick:()=>window.open(g,"_blank"),children:[G.jsx(HMn,{className:"rf-h-4 rf-w-4"}),"View on tscircuit.com"]}):null}),G.jsxs("div",{className:"rf-flex rf-flex-col sm:rf-flex-row rf-gap-2",children:[G.jsx(Tu,{variant:"outline",onClick:()=>n(!1),className:"rf-order-2 sm:rf-order-1",children:"Close"}),G.jsx(Tu,{onClick:c,disabled:a,className:"rf-bg-blue-600 hover:rf-bg-blue-700",children:a?G.jsx(o8,{className:"rf-h-4 rf-w-4 rf-animate-spin"}):"Import Component"})]})]})]})})},$Vn=()=>{const[t,e]=te.useState(null),[n,r]=te.useState(!1),i=te.useCallback(async(s,a)=>{r(!0);try{const c=await fetch(`https://api.tscircuit.com/packages/get?name=${encodeURIComponent(`${s}/${a}`)}`);if(!c.ok)throw new Error(`Failed to load package details: ${c.status}`);const l=await c.json();e(l.package??null)}catch(c){console.error("Failed to fetch package details",c),e(null)}finally{r(!1)}},[]),o=te.useCallback(()=>{e(null),r(!1)},[]);return{details:t,isLoading:n,fetchDetails:i,reset:o}},FVn=async(t,e)=>{const n={"Content-Type":"application/json"};e&&(n.Authorization=`Bearer ${e}`);const r=await fetch("https://registry-api.tscircuit.com/packages/search",{method:"POST",headers:n,body:JSON.stringify({query:t})});if(!r.ok)throw new Error(`tscircuit registry error: ${r.status}`);return(await r.json()).packages??[]},BVn=({sessionToken:t})=>{const[e,n]=te.useState([]),[r,i]=te.useState(!1),[o,s]=te.useState(null),[a,c]=te.useState(!1),l=te.useCallback(async d=>{const h=d.trim();if(!h)return[];i(!0),s(null);try{const p=(await FVn(h,t)).map(m=>({source:"tscircuit.com",package:m}));return n(p),p}catch(f){return console.error("Error searching tscircuit packages",f),n([]),s(f instanceof Error?f.message:"Failed to search tscircuit packages"),[]}finally{i(!1),c(!0)}},[t]),u=te.useCallback(()=>{n([]),i(!1),s(null),c(!1)},[]);return{results:e,isSearching:r,error:o,hasSearched:a,search:l,reset:u}},jVn=t=>{const e=t.trim();return/^C\d+/i.test(e)?e.replace(/^C/i,""):e},UVn=()=>{const[t,e]=te.useState([]),[n,r]=te.useState(!1),[i,o]=te.useState(null),[s,a]=te.useState(!1),c=te.useCallback(async u=>{const d=jVn(u);if(!d)return[];r(!0),o(null);try{const f=(await CVn(d,10)).map(p=>({source:"jlcpcb",component:PVn(p)}));return e(f),f}catch(h){return console.error("Error searching JLCPCB components",h),e([]),o(h instanceof Error?h.message:"Failed to search JLCPCB components"),[]}finally{r(!1),a(!0)}},[]),l=te.useCallback(()=>{e([]),r(!1),o(null),a(!1)},[]);return{results:t,isSearching:n,error:i,hasSearched:s,search:c,reset:l}};function H9(t){return Array.isArray?Array.isArray(t):gdt(t)==="[object Array]"}function HVn(t){if(typeof t=="string")return t;let e=t+"";return e=="0"&&1/t==-1/0?"-0":e}function YVn(t){return t==null?"":HVn(t)}function ov(t){return typeof t=="string"}function mdt(t){return typeof t=="number"}function XVn(t){return t===!0||t===!1||VVn(t)&&gdt(t)=="[object Boolean]"}function ydt(t){return typeof t=="object"}function VVn(t){return ydt(t)&&t!==null}function Y2(t){return t!=null}function _2e(t){return!t.trim().length}function gdt(t){return t==null?t===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(t)}const GVn="Incorrect 'index' type",qVn=t=>`Invalid value for key ${t}`,WVn=t=>`Pattern length exceeds max of ${t}.`,ZVn=t=>`Missing ${t} property in key`,KVn=t=>`Property 'weight' in key '${t}' must be a positive integer`,_dt=Object.prototype.hasOwnProperty;class QVn{constructor(e){this._keys=[],this._keyMap={};let n=0;e.forEach(r=>{let i=xdt(r);this._keys.push(i),this._keyMap[i.id]=i,n+=i.weight}),this._keys.forEach(r=>{r.weight/=n})}get(e){return this._keyMap[e]}keys(){return this._keys}toJSON(){return JSON.stringify(this._keys)}}function xdt(t){let e=null,n=null,r=null,i=1,o=null;if(ov(t)||H9(t))r=t,e=bdt(t),n=x2e(t);else{if(!_dt.call(t,"name"))throw new Error(ZVn("name"));const s=t.name;if(r=s,_dt.call(t,"weight")&&(i=t.weight,i<=0))throw new Error(KVn(s));e=bdt(s),n=x2e(s),o=t.getFn}return{path:e,id:n,weight:i,src:r,getFn:o}}function bdt(t){return H9(t)?t:t.split(".")}function x2e(t){return H9(t)?t.join("."):t}function JVn(t,e){let n=[],r=!1;const i=(o,s,a)=>{if(Y2(o))if(!s[a])n.push(o);else{let c=s[a];const l=o[c];if(!Y2(l))return;if(a===s.length-1&&(ov(l)||mdt(l)||XVn(l)))n.push(YVn(l));else if(H9(l)){r=!0;for(let u=0,d=l.length;u<d;u+=1)i(l[u],s,a+1)}else s.length&&i(l,s,a+1)}};return i(t,ov(e)?e.split("."):e,0),r?n:n[0]}var Lo={...{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,getFn:JVn,ignoreLocation:!1,ignoreFieldNorm:!1,fieldNormWeight:1}};const eGn=/[^ ]+/g;function tGn(t=1,e=3){const n=new Map,r=Math.pow(10,e);return{get(i){const o=i.match(eGn).length;if(n.has(o))return n.get(o);const s=1/Math.pow(o,.5*t),a=parseFloat(Math.round(s*r)/r);return n.set(o,a),a},clear(){n.clear()}}}class b2e{constructor({getFn:e=Lo.getFn,fieldNormWeight:n=Lo.fieldNormWeight}={}){this.norm=tGn(n,3),this.getFn=e,this.isCreated=!1,this.setIndexRecords()}setSources(e=[]){this.docs=e}setIndexRecords(e=[]){this.records=e}setKeys(e=[]){this.keys=e,this._keysMap={},e.forEach((n,r)=>{this._keysMap[n.id]=r})}create(){this.isCreated||!this.docs.length||(this.isCreated=!0,ov(this.docs[0])?this.docs.forEach((e,n)=>{this._addString(e,n)}):this.docs.forEach((e,n)=>{this._addObject(e,n)}),this.norm.clear())}add(e){const n=this.size();ov(e)?this._addString(e,n):this._addObject(e,n)}removeAt(e){this.records.splice(e,1);for(let n=e,r=this.size();n<r;n+=1)this.records[n].i-=1}getValueForItemAtKeyId(e,n){return e[this._keysMap[n]]}size(){return this.records.length}_addString(e,n){if(!Y2(e)||_2e(e))return;let r={v:e,i:n,n:this.norm.get(e)};this.records.push(r)}_addObject(e,n){let r={i:n,$:{}};this.keys.forEach((i,o)=>{let s=i.getFn?i.getFn(e):this.getFn(e,i.path);if(Y2(s)){if(H9(s)){let a=[];const c=[{nestedArrIndex:-1,value:s}];for(;c.length;){const{nestedArrIndex:l,value:u}=c.pop();if(Y2(u))if(ov(u)&&!_2e(u)){let d={v:u,i:l,n:this.norm.get(u)};a.push(d)}else H9(u)&&u.forEach((d,h)=>{c.push({nestedArrIndex:h,value:d})})}r.$[o]=a}else if(ov(s)&&!_2e(s)){let a={v:s,n:this.norm.get(s)};r.$[o]=a}}}),this.records.push(r)}toJSON(){return{keys:this.keys,records:this.records}}}function vdt(t,e,{getFn:n=Lo.getFn,fieldNormWeight:r=Lo.fieldNormWeight}={}){const i=new b2e({getFn:n,fieldNormWeight:r});return i.setKeys(t.map(xdt)),i.setSources(e),i.create(),i}function nGn(t,{getFn:e=Lo.getFn,fieldNormWeight:n=Lo.fieldNormWeight}={}){const{keys:r,records:i}=t,o=new b2e({getFn:e,fieldNormWeight:n});return o.setKeys(r),o.setIndexRecords(i),o}function SG(t,{errors:e=0,currentLocation:n=0,expectedLocation:r=0,distance:i=Lo.distance,ignoreLocation:o=Lo.ignoreLocation}={}){const s=e/t.length;if(o)return s;const a=Math.abs(r-n);return i?s+a/i:a?1:s}function rGn(t=[],e=Lo.minMatchCharLength){let n=[],r=-1,i=-1,o=0;for(let s=t.length;o<s;o+=1){let a=t[o];a&&r===-1?r=o:!a&&r!==-1&&(i=o-1,i-r+1>=e&&n.push([r,i]),r=-1)}return t[o-1]&&o-r>=e&&n.push([r,o-1]),n}const OS=32;function iGn(t,e,n,{location:r=Lo.location,distance:i=Lo.distance,threshold:o=Lo.threshold,findAllMatches:s=Lo.findAllMatches,minMatchCharLength:a=Lo.minMatchCharLength,includeMatches:c=Lo.includeMatches,ignoreLocation:l=Lo.ignoreLocation}={}){if(e.length>OS)throw new Error(WVn(OS));const u=e.length,d=t.length,h=Math.max(0,Math.min(r,d));let f=o,p=h;const m=a>1||c,g=m?Array(d):[];let y;for(;(y=t.indexOf(e,p))>-1;){let T=SG(e,{currentLocation:y,expectedLocation:h,distance:i,ignoreLocation:l});if(f=Math.min(T,f),p=y+u,m){let C=0;for(;C<u;)g[y+C]=1,C+=1}}p=-1;let _=[],x=1,b=u+d;const w=1<<u-1;for(let T=0;T<u;T+=1){let C=0,A=b;for(;C<A;)SG(e,{errors:T,currentLocation:h+A,expectedLocation:h,distance:i,ignoreLocation:l})<=f?C=A:b=A,A=Math.floor((b-C)/2+C);b=A;let R=Math.max(1,h-A+1),L=s?d:Math.min(h+A,d)+u,O=Array(L+2);O[L+1]=(1<<T)-1;for(let B=L;B>=R;B-=1){let j=B-1,V=n[t.charAt(j)];if(m&&(g[j]=+!!V),O[B]=(O[B+1]<<1|1)&V,T&&(O[B]|=(_[B+1]|_[B])<<1|1|_[B+1]),O[B]&w&&(x=SG(e,{errors:T,currentLocation:j,expectedLocation:h,distance:i,ignoreLocation:l}),x<=f)){if(f=x,p=j,p<=h)break;R=Math.max(1,2*h-p)}}if(SG(e,{errors:T+1,currentLocation:h,expectedLocation:h,distance:i,ignoreLocation:l})>f)break;_=O}const S={isMatch:p>=0,score:Math.max(.001,x)};if(m){const T=rGn(g,a);T.length?c&&(S.indices=T):S.isMatch=!1}return S}function oGn(t){let e={};for(let n=0,r=t.length;n<r;n+=1){const i=t.charAt(n);e[i]=(e[i]||0)|1<<r-n-1}return e}const MG=String.prototype.normalize?(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,"")):(t=>t);class wdt{constructor(e,{location:n=Lo.location,threshold:r=Lo.threshold,distance:i=Lo.distance,includeMatches:o=Lo.includeMatches,findAllMatches:s=Lo.findAllMatches,minMatchCharLength:a=Lo.minMatchCharLength,isCaseSensitive:c=Lo.isCaseSensitive,ignoreDiacritics:l=Lo.ignoreDiacritics,ignoreLocation:u=Lo.ignoreLocation}={}){if(this.options={location:n,threshold:r,distance:i,includeMatches:o,findAllMatches:s,minMatchCharLength:a,isCaseSensitive:c,ignoreDiacritics:l,ignoreLocation:u},e=c?e:e.toLowerCase(),e=l?MG(e):e,this.pattern=e,this.chunks=[],!this.pattern.length)return;const d=(f,p)=>{this.chunks.push({pattern:f,alphabet:oGn(f),startIndex:p})},h=this.pattern.length;if(h>OS){let f=0;const p=h%OS,m=h-p;for(;f<m;)d(this.pattern.substr(f,OS),f),f+=OS;if(p){const g=h-OS;d(this.pattern.substr(g),g)}}else d(this.pattern,0)}searchIn(e){const{isCaseSensitive:n,ignoreDiacritics:r,includeMatches:i}=this.options;if(e=n?e:e.toLowerCase(),e=r?MG(e):e,this.pattern===e){let m={isMatch:!0,score:0};return i&&(m.indices=[[0,e.length-1]]),m}const{location:o,distance:s,threshold:a,findAllMatches:c,minMatchCharLength:l,ignoreLocation:u}=this.options;let d=[],h=0,f=!1;this.chunks.forEach(({pattern:m,alphabet:g,startIndex:y})=>{const{isMatch:_,score:x,indices:b}=iGn(e,m,g,{location:o+y,distance:s,threshold:a,findAllMatches:c,minMatchCharLength:l,includeMatches:i,ignoreLocation:u});_&&(f=!0),h+=x,_&&b&&(d=[...d,...b])});let p={isMatch:f,score:f?h/this.chunks.length:1};return f&&i&&(p.indices=d),p}}class A8{constructor(e){this.pattern=e}static isMultiMatch(e){return Sdt(e,this.multiRegex)}static isSingleMatch(e){return Sdt(e,this.singleRegex)}search(){}}function Sdt(t,e){const n=t.match(e);return n?n[1]:null}class sGn extends A8{constructor(e){super(e)}static get type(){return"exact"}static get multiRegex(){return/^="(.*)"$/}static get singleRegex(){return/^=(.*)$/}search(e){const n=e===this.pattern;return{isMatch:n,score:n?0:1,indices:[0,this.pattern.length-1]}}}class aGn extends A8{constructor(e){super(e)}static get type(){return"inverse-exact"}static get multiRegex(){return/^!"(.*)"$/}static get singleRegex(){return/^!(.*)$/}search(e){const r=e.indexOf(this.pattern)===-1;return{isMatch:r,score:r?0:1,indices:[0,e.length-1]}}}class cGn extends A8{constructor(e){super(e)}static get type(){return"prefix-exact"}static get multiRegex(){return/^\^"(.*)"$/}static get singleRegex(){return/^\^(.*)$/}search(e){const n=e.startsWith(this.pattern);return{isMatch:n,score:n?0:1,indices:[0,this.pattern.length-1]}}}class lGn extends A8{constructor(e){super(e)}static get type(){return"inverse-prefix-exact"}static get multiRegex(){return/^!\^"(.*)"$/}static get singleRegex(){return/^!\^(.*)$/}search(e){const n=!e.startsWith(this.pattern);return{isMatch:n,score:n?0:1,indices:[0,e.length-1]}}}class uGn extends A8{constructor(e){super(e)}static get type(){return"suffix-exact"}static get multiRegex(){return/^"(.*)"\$$/}static get singleRegex(){return/^(.*)\$$/}search(e){const n=e.endsWith(this.pattern);return{isMatch:n,score:n?0:1,indices:[e.length-this.pattern.length,e.length-1]}}}class dGn extends A8{constructor(e){super(e)}static get type(){return"inverse-suffix-exact"}static get multiRegex(){return/^!"(.*)"\$$/}static get singleRegex(){return/^!(.*)\$$/}search(e){const n=!e.endsWith(this.pattern);return{isMatch:n,score:n?0:1,indices:[0,e.length-1]}}}class Mdt extends A8{constructor(e,{location:n=Lo.location,threshold:r=Lo.threshold,distance:i=Lo.distance,includeMatches:o=Lo.includeMatches,findAllMatches:s=Lo.findAllMatches,minMatchCharLength:a=Lo.minMatchCharLength,isCaseSensitive:c=Lo.isCaseSensitive,ignoreDiacritics:l=Lo.ignoreDiacritics,ignoreLocation:u=Lo.ignoreLocation}={}){super(e),this._bitapSearch=new wdt(e,{location:n,threshold:r,distance:i,includeMatches:o,findAllMatches:s,minMatchCharLength:a,isCaseSensitive:c,ignoreDiacritics:l,ignoreLocation:u})}static get type(){return"fuzzy"}static get multiRegex(){return/^"(.*)"$/}static get singleRegex(){return/^(.*)$/}search(e){return this._bitapSearch.searchIn(e)}}class Tdt extends A8{constructor(e){super(e)}static get type(){return"include"}static get multiRegex(){return/^'"(.*)"$/}static get singleRegex(){return/^'(.*)$/}search(e){let n=0,r;const i=[],o=this.pattern.length;for(;(r=e.indexOf(this.pattern,n))>-1;)n=r+o,i.push([r,n-1]);const s=!!i.length;return{isMatch:s,score:s?0:1,indices:i}}}const v2e=[sGn,Tdt,cGn,lGn,dGn,uGn,aGn,Mdt],Edt=v2e.length,hGn=/ +(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/,pGn="|";function fGn(t,e={}){return t.split(pGn).map(n=>{let r=n.trim().split(hGn).filter(o=>o&&!!o.trim()),i=[];for(let o=0,s=r.length;o<s;o+=1){const a=r[o];let c=!1,l=-1;for(;!c&&++l<Edt;){const u=v2e[l];let d=u.isMultiMatch(a);d&&(i.push(new u(d,e)),c=!0)}if(!c)for(l=-1;++l<Edt;){const u=v2e[l];let d=u.isSingleMatch(a);if(d){i.push(new u(d,e));break}}}return i})}const mGn=new Set([Mdt.type,Tdt.type]);class yGn{constructor(e,{isCaseSensitive:n=Lo.isCaseSensitive,ignoreDiacritics:r=Lo.ignoreDiacritics,includeMatches:i=Lo.includeMatches,minMatchCharLength:o=Lo.minMatchCharLength,ignoreLocation:s=Lo.ignoreLocation,findAllMatches:a=Lo.findAllMatches,location:c=Lo.location,threshold:l=Lo.threshold,distance:u=Lo.distance}={}){this.query=null,this.options={isCaseSensitive:n,ignoreDiacritics:r,includeMatches:i,minMatchCharLength:o,findAllMatches:a,ignoreLocation:s,location:c,threshold:l,distance:u},e=n?e:e.toLowerCase(),e=r?MG(e):e,this.pattern=e,this.query=fGn(this.pattern,this.options)}static condition(e,n){return n.useExtendedSearch}searchIn(e){const n=this.query;if(!n)return{isMatch:!1,score:1};const{includeMatches:r,isCaseSensitive:i,ignoreDiacritics:o}=this.options;e=i?e:e.toLowerCase(),e=o?MG(e):e;let s=0,a=[],c=0;for(let l=0,u=n.length;l<u;l+=1){const d=n[l];a.length=0,s=0;for(let h=0,f=d.length;h<f;h+=1){const p=d[h],{isMatch:m,indices:g,score:y}=p.search(e);if(m){if(s+=1,c+=y,r){const _=p.constructor.type;mGn.has(_)?a=[...a,...g]:a.push(g)}}else{c=0,s=0,a.length=0;break}}if(s){let h={isMatch:!0,score:c/s};return r&&(h.indices=a),h}}return{isMatch:!1,score:1}}}const w2e=[];function gGn(...t){w2e.push(...t)}function S2e(t,e){for(let n=0,r=w2e.length;n<r;n+=1){let i=w2e[n];if(i.condition(t,e))return new i(t,e)}return new wdt(t,e)}const TG={AND:"$and",OR:"$or"},M2e={PATH:"$path",PATTERN:"$val"},T2e=t=>!!(t[TG.AND]||t[TG.OR]),_Gn=t=>!!t[M2e.PATH],xGn=t=>!H9(t)&&ydt(t)&&!T2e(t),Cdt=t=>({[TG.AND]:Object.keys(t).map(e=>({[e]:t[e]}))});function Pdt(t,e,{auto:n=!0}={}){const r=i=>{let o=Object.keys(i);const s=_Gn(i);if(!s&&o.length>1&&!T2e(i))return r(Cdt(i));if(xGn(i)){const c=s?i[M2e.PATH]:o[0],l=s?i[M2e.PATTERN]:i[c];if(!ov(l))throw new Error(qVn(c));const u={keyId:x2e(c),pattern:l};return n&&(u.searcher=S2e(l,e)),u}let a={children:[],operator:o[0]};return o.forEach(c=>{const l=i[c];H9(l)&&l.forEach(u=>{a.children.push(r(u))})}),a};return T2e(t)||(t=Cdt(t)),r(t)}function bGn(t,{ignoreFieldNorm:e=Lo.ignoreFieldNorm}){t.forEach(n=>{let r=1;n.matches.forEach(({key:i,norm:o,score:s})=>{const a=i?i.weight:null;r*=Math.pow(s===0&&a?Number.EPSILON:s,(a||1)*(e?1:o))}),n.score=r})}function vGn(t,e){const n=t.matches;e.matches=[],Y2(n)&&n.forEach(r=>{if(!Y2(r.indices)||!r.indices.length)return;const{indices:i,value:o}=r;let s={indices:i,value:o};r.key&&(s.key=r.key.src),r.idx>-1&&(s.refIndex=r.idx),e.matches.push(s)})}function wGn(t,e){e.score=t.score}function SGn(t,e,{includeMatches:n=Lo.includeMatches,includeScore:r=Lo.includeScore}={}){const i=[];return n&&i.push(vGn),r&&i.push(wGn),t.map(o=>{const{idx:s}=o,a={item:e[s],refIndex:s};return i.length&&i.forEach(c=>{c(o,a)}),a})}class CP{constructor(e,n={},r){this.options={...Lo,...n},this.options.useExtendedSearch,this._keyStore=new QVn(this.options.keys),this.setCollection(e,r)}setCollection(e,n){if(this._docs=e,n&&!(n instanceof b2e))throw new Error(GVn);this._myIndex=n||vdt(this.options.keys,this._docs,{getFn:this.options.getFn,fieldNormWeight:this.options.fieldNormWeight})}add(e){Y2(e)&&(this._docs.push(e),this._myIndex.add(e))}remove(e=()=>!1){const n=[];for(let r=0,i=this._docs.length;r<i;r+=1){const o=this._docs[r];e(o,r)&&(this.removeAt(r),r-=1,i-=1,n.push(o))}return n}removeAt(e){this._docs.splice(e,1),this._myIndex.removeAt(e)}getIndex(){return this._myIndex}search(e,{limit:n=-1}={}){const{includeMatches:r,includeScore:i,shouldSort:o,sortFn:s,ignoreFieldNorm:a}=this.options;let c=ov(e)?ov(this._docs[0])?this._searchStringList(e):this._searchObjectList(e):this._searchLogical(e);return bGn(c,{ignoreFieldNorm:a}),o&&c.sort(s),mdt(n)&&n>-1&&(c=c.slice(0,n)),SGn(c,this._docs,{includeMatches:r,includeScore:i})}_searchStringList(e){const n=S2e(e,this.options),{records:r}=this._myIndex,i=[];return r.forEach(({v:o,i:s,n:a})=>{if(!Y2(o))return;const{isMatch:c,score:l,indices:u}=n.searchIn(o);c&&i.push({item:o,idx:s,matches:[{score:l,value:o,norm:a,indices:u}]})}),i}_searchLogical(e){const n=Pdt(e,this.options),r=(a,c,l)=>{if(!a.children){const{keyId:d,searcher:h}=a,f=this._findMatches({key:this._keyStore.get(d),value:this._myIndex.getValueForItemAtKeyId(c,d),searcher:h});return f&&f.length?[{idx:l,item:c,matches:f}]:[]}const u=[];for(let d=0,h=a.children.length;d<h;d+=1){const f=a.children[d],p=r(f,c,l);if(p.length)u.push(...p);else if(a.operator===TG.AND)return[]}return u},i=this._myIndex.records,o={},s=[];return i.forEach(({$:a,i:c})=>{if(Y2(a)){let l=r(n,a,c);l.length&&(o[c]||(o[c]={idx:c,item:a,matches:[]},s.push(o[c])),l.forEach(({matches:u})=>{o[c].matches.push(...u)}))}}),s}_searchObjectList(e){const n=S2e(e,this.options),{keys:r,records:i}=this._myIndex,o=[];return i.forEach(({$:s,i:a})=>{if(!Y2(s))return;let c=[];r.forEach((l,u)=>{c.push(...this._findMatches({key:l,value:s[u],searcher:n}))}),c.length&&o.push({idx:a,item:s,matches:c})}),o}_findMatches({key:e,value:n,searcher:r}){if(!Y2(n))return[];let i=[];if(H9(n))n.forEach(({v:o,i:s,n:a})=>{if(!Y2(o))return;const{isMatch:c,score:l,indices:u}=r.searchIn(o);c&&i.push({score:l,key:e,value:o,idx:s,norm:a,indices:u})});else{const{v:o,n:s}=n,{isMatch:a,score:c,indices:l}=r.searchIn(o);a&&i.push({score:c,key:e,value:o,norm:s,indices:l})}return i}}CP.version="7.1.0",CP.createIndex=vdt,CP.parseIndex=nGn,CP.config=Lo,CP.parseQuery=Pdt,gGn(yGn);let E2e=null,AO=null,C2e=null;const MGn=async()=>E2e||AO||(AO=fetch("https://kicad-mod-cache.tscircuit.com/kicad_files.json").then(t=>t.json()).then(t=>(E2e=t,AO=null,t)),AO),TGn=async(t,e=20)=>{const n=await MGn();return C2e||(C2e=new CP(n)),C2e.search(t).slice(0,e).map(r=>r.item)},EGn=t=>{const e=t.replace(".pretty/","/").replace(".kicad_mod",""),n=`kicad:${e}`;return{path:t,qualifiedName:n,description:e}},CGn=()=>{const[t,e]=te.useState([]),[n,r]=te.useState(!1),[i,o]=te.useState(null),[s,a]=te.useState(!1),c=te.useCallback(async u=>{const d=u.trim();if(!d)return[];r(!0),o(null);try{const f=(await TGn(d,20)).map(p=>({source:"kicad",footprint:EGn(p)}));return e(f),f}catch(h){return console.error("Error searching KiCad footprints",h),e([]),o(h instanceof Error?h.message:"Failed to search KiCad footprints"),[]}finally{r(!1),a(!0)}},[]),l=te.useCallback(()=>{e([]),r(!1),o(null),a(!1)},[]);return{results:t,isSearching:n,error:i,hasSearched:s,search:c,reset:l}},PGn={dialog:101},AGn=({onTscircuitPackageSelected:t,onJlcpcbComponentTsxLoaded:e,onKicadStringSelected:n})=>{const r=[];return t&&r.push("tscircuit.com"),e&&r.push("jlcpcb"),n&&r.push("kicad"),r},RGn=({isOpen:t,onClose:e,jlcpcbProxyRequestHeaders:n,onKicadStringSelected:r,onTscircuitPackageSelected:i,onJlcpcbComponentTsxLoaded:o,jlcpcbProxyApiBase:s,tscircuitSessionToken:a})=>{i0t();const c=te.useMemo(()=>AGn({onKicadStringSelected:r,onTscircuitPackageSelected:i,onJlcpcbComponentTsxLoaded:o}),[r,i,o]),l=c.length>0,u=c.length===1,[d,h]=te.useState(c[0]??"tscircuit.com"),[f,p]=te.useState(""),[m,g]=te.useState(null),{results:y,isSearching:_,error:x,hasSearched:b,search:w,reset:S}=BVn({sessionToken:a}),{results:T,isSearching:C,error:A,hasSearched:R,search:L,reset:O}=UVn(),{results:F,isSearching:B,error:j,hasSearched:V,search:q,reset:K}=CGn(),{details:ne,isLoading:le,fetchDetails:ee,reset:ie}=$Vn(),[ce,ue]=te.useState(null),[_e,Ce]=te.useState(!1),[Ae,ke]=te.useState("pcb"),[ye,Me]=te.useState(null),[fe,Ye]=te.useState(!1);te.useEffect(()=>{Me(null)},[m]);const He=te.useCallback(()=>{S(),O(),K(),g(null)},[O,K,S]);te.useEffect(()=>{t||(He(),p(""),Ce(!1),ue(null),Me(null))},[t,He]),te.useEffect(()=>{p(""),g(null),d==="tscircuit.com"?S():d==="jlcpcb"?O():d==="kicad"&&K()},[d,O,K,S]);const We=Be=>{g(Be),ue(Be),ke("pcb"),Ce(!0),ie();const Xe=Be.package.org_owner_tscircuit_handle,et=Be.package.unscoped_name;if(Xe&&et){const rt=et.split("/").pop()??et;ee(Xe,rt)}},ge=async()=>{f.trim()&&(g(null),d==="tscircuit.com"?await w(f):d==="jlcpcb"?await L(f):d==="kicad"&&await q(f))},Ke=async Be=>{try{if(Me(null),Ye(!0),Be.source==="kicad"){if(!r)throw new Error("KiCad handler not provided");await r({result:Be,footprint:Be.footprint.qualifiedName})}else if(Be.source==="jlcpcb"){if(!o)throw new Error("JLCPCB handler not provided");const Xe=await AVn(Be.component.partNumber,{headers:n,apiBase:s});await o({result:Be,tsx:Xe})}else if(Be.source==="tscircuit.com"){if(!i)throw new Error("tscircuit package handler not provided");const Xe=Be.package.org_owner_tscircuit_handle,et=Be.package.unscoped_name;if(!Xe||!et)throw new Error("Missing package metadata");const rt=et.split("/").pop()??et,at=`@tsci/${Xe}.${rt}`;await i({result:Be,fullPackageName:at})}return!0}catch(Xe){return console.error("Failed to import component",Xe),Me(Xe instanceof Error?Xe.message:"Failed to import component"),!1}finally{Ye(!1)}};let $e=[],Ne=!1,Ue=null,Ie=!1;d==="tscircuit.com"?($e=y,Ne=_,Ue=x,Ie=b):d==="jlcpcb"?($e=T,Ne=C,Ue=A,Ie=R):d==="kicad"&&($e=F,Ne=B,Ue=j,Ie=V);const we=async()=>{if(!m)return;await Ke(m)&&(e(),He(),p(""))},Ee=Be=>{Be||e()},Te=Be=>{Ce(Be),Be||ue(null)};return G.jsxs(EO,{open:t,onOpenChange:Ee,children:[G.jsxs(MP,{style:{width:"calc(100vw - 2rem)",zIndex:PGn.dialog},className:"rf-rounded-sm rf-max-h-[90vh] rf-overflow-y-auto rf-overflow-x-hidden rf-flex rf-flex-col",children:[G.jsxs(TP,{children:[G.jsxs(EP,{className:"rf-text-lg sm:rf-text-xl",children:["Import ",u?wG[d].label:""," ","Component"]}),G.jsx(PO,{className:"rf-text-sm",children:l?"Search for components from available sources.":"Import options are disabled because no handlers were provided."})]}),l?G.jsxs(KW,{value:d,onValueChange:Be=>h(Be),className:"rf-min-w-0 rf-w-full",children:[!u&&G.jsx(sD,{className:"rf-flex rf-w-full rf-gap-2",children:c.map(Be=>G.jsx(B4,{value:Be,className:"rf-flex-1 rf-text-xs sm:rf-text-sm",children:wG[Be].label},Be))}),G.jsx(RVn,{query:f,placeholder:wG[d].placeholder,isSearching:Ne,onQueryChange:p,onSubmit:ge}),G.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:Ne?G.jsxs("div",{className:"rf-p-8 rf-text-center rf-text-zinc-500",children:[G.jsx(o8,{className:"rf-h-8 rf-w-8 rf-animate-spin rf-mx-auto rf-mb-2"}),G.jsx("p",{children:"Searching..."})]}):$e.length>0?G.jsx(DVn,{results:$e,selected:m,onSelect:g,onShowDetails:d==="tscircuit.com"?We:void 0}):G.jsx("div",{className:"rf-p-8 rf-text-center rf-text-zinc-500",children:Ue?`Error: ${Ue}`:Ie?wG[d].emptyMessage:"Enter a search term to find components"})})]}):null,ye?G.jsx("div",{className:"rf-text-sm rf-text-red-600 rf-mt-2",children:ye}):null,G.jsxs(CO,{className:"rf-flex rf-flex-col sm:rf-flex-row rf-gap-2",children:[G.jsx(Tu,{variant:"outline",onClick:e,className:"rf-order-2 sm:rf-order-1",children:"Cancel"}),G.jsx(Tu,{onClick:we,disabled:!m||fe,className:"rf-order-1 sm:rf-order-2",children:fe?G.jsx(o8,{className:"rf-h-4 rf-w-4 rf-animate-spin"}):"Import"})]})]}),G.jsx(zVn,{packageResult:ce,isOpen:_e,onOpenChange:Te,isLoading:le,details:ne,previewTab:Ae,onPreviewTabChange:Be=>ke(Be),isSubmitting:fe,onImport:()=>{ce&&Ke(ce).then(Be=>{Be&&(Ce(!1),e(),He(),p(""))})}})]})},IGn=t=>{const e=t.match(/export const (\w+) =/);if(!e)throw new Error("Could not determine component name from TSX contents");return e[1]},Adt=t=>{const e=iv(s=>s.pushEvent),n=iv(s=>s.upsertFile),r=async({result:s,fullPackageName:a})=>{const l=s.package.unscoped_name??s.package.name;await Ps.promise(e({event_type:"INSTALL_PACKAGE",full_package_name:a}),{loading:`Requesting install for "${l}"`,success:`Install requested for "${l}"`,error:u=>`Failed to request install: ${u instanceof Error?u.message:String(u)}`})},i=async({footprint:s})=>{await Ps.promise(navigator.clipboard.writeText(s),{loading:`Copying "${s}"`,success:`Copied "${s}" to clipboard`,error:a=>`Failed to copy footprint: ${a instanceof Error?a.message:String(a)}`})},o=async({result:s,tsx:a})=>{const l=`imports/${IGn(a)}.tsx`;await Ps.promise(n(l,a),{loading:`Importing ${s.component.partNumber}`,success:`Imported to "${l}"`,error:u=>`Failed to import component: ${u instanceof Error?u.message:String(u)}`})};return G.jsx(RGn,{...t,onTscircuitPackageSelected:r,onKicadStringSelected:i,onJlcpcbComponentTsxLoaded:o})};Adt.displayName="ImportComponentDialogForCli";var P2e={exports:{}},Rdt;function NGn(){return Rdt||(Rdt=1,(function(t,e){var n={env:{},version:""};(function(r){t.exports=r()})(function(){return(function r(i,o,s){function a(u,d){if(!o[u]){if(!i[u]){var h=typeof o3=="function"&&o3;if(!d&&h)return h(u,!0);if(c)return c(u,!0);var f=new Error("Cannot find module '"+u+"'");throw f.code="MODULE_NOT_FOUND",f}var p=o[u]={exports:{}};i[u][0].call(p.exports,function(m){var g=i[u][1][m];return a(g||m)},p,p.exports,r,i,o,s)}return o[u].exports}for(var c=typeof o3=="function"&&o3,l=0;l<s.length;l++)a(s[l]);return a})({1:[function(r,i,o){var s=r("./utils"),a=r("./support"),c="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";o.encode=function(l){for(var u,d,h,f,p,m,g,y=[],_=0,x=l.length,b=x,w=s.getTypeOf(l)!=="string";_<l.length;)b=x-_,h=w?(u=l[_++],d=_<x?l[_++]:0,_<x?l[_++]:0):(u=l.charCodeAt(_++),d=_<x?l.charCodeAt(_++):0,_<x?l.charCodeAt(_++):0),f=u>>2,p=(3&u)<<4|d>>4,m=1<b?(15&d)<<2|h>>6:64,g=2<b?63&h:64,y.push(c.charAt(f)+c.charAt(p)+c.charAt(m)+c.charAt(g));return y.join("")},o.decode=function(l){var u,d,h,f,p,m,g=0,y=0,_="data:";if(l.substr(0,_.length)===_)throw new Error("Invalid base64 input, it looks like a data url.");var x,b=3*(l=l.replace(/[^A-Za-z0-9+/=]/g,"")).length/4;if(l.charAt(l.length-1)===c.charAt(64)&&b--,l.charAt(l.length-2)===c.charAt(64)&&b--,b%1!=0)throw new Error("Invalid base64 input, bad content length.");for(x=a.uint8array?new Uint8Array(0|b):new Array(0|b);g<l.length;)u=c.indexOf(l.charAt(g++))<<2|(f=c.indexOf(l.charAt(g++)))>>4,d=(15&f)<<4|(p=c.indexOf(l.charAt(g++)))>>2,h=(3&p)<<6|(m=c.indexOf(l.charAt(g++))),x[y++]=u,p!==64&&(x[y++]=d),m!==64&&(x[y++]=h);return x}},{"./support":30,"./utils":32}],2:[function(r,i,o){var s=r("./external"),a=r("./stream/DataWorker"),c=r("./stream/Crc32Probe"),l=r("./stream/DataLengthProbe");function u(d,h,f,p,m){this.compressedSize=d,this.uncompressedSize=h,this.crc32=f,this.compression=p,this.compressedContent=m}u.prototype={getContentWorker:function(){var d=new a(s.Promise.resolve(this.compressedContent)).pipe(this.compression.uncompressWorker()).pipe(new l("data_length")),h=this;return d.on("end",function(){if(this.streamInfo.data_length!==h.uncompressedSize)throw new Error("Bug : uncompressed data size mismatch")}),d},getCompressedWorker:function(){return new a(s.Promise.resolve(this.compressedContent)).withStreamInfo("compressedSize",this.compressedSize).withStreamInfo("uncompressedSize",this.uncompressedSize).withStreamInfo("crc32",this.crc32).withStreamInfo("compression",this.compression)}},u.createWorkerFrom=function(d,h,f){return d.pipe(new c).pipe(new l("uncompressedSize")).pipe(h.compressWorker(f)).pipe(new l("compressedSize")).withStreamInfo("compression",h)},i.exports=u},{"./external":6,"./stream/Crc32Probe":25,"./stream/DataLengthProbe":26,"./stream/DataWorker":27}],3:[function(r,i,o){var s=r("./stream/GenericWorker");o.STORE={magic:"\0\0",compressWorker:function(){return new s("STORE compression")},uncompressWorker:function(){return new s("STORE decompression")}},o.DEFLATE=r("./flate")},{"./flate":7,"./stream/GenericWorker":28}],4:[function(r,i,o){var s=r("./utils"),a=(function(){for(var c,l=[],u=0;u<256;u++){c=u;for(var d=0;d<8;d++)c=1&c?3988292384^c>>>1:c>>>1;l[u]=c}return l})();i.exports=function(c,l){return c!==void 0&&c.length?s.getTypeOf(c)!=="string"?(function(u,d,h,f){var p=a,m=f+h;u^=-1;for(var g=f;g<m;g++)u=u>>>8^p[255&(u^d[g])];return-1^u})(0|l,c,c.length,0):(function(u,d,h,f){var p=a,m=f+h;u^=-1;for(var g=f;g<m;g++)u=u>>>8^p[255&(u^d.charCodeAt(g))];return-1^u})(0|l,c,c.length,0):0}},{"./utils":32}],5:[function(r,i,o){o.base64=!1,o.binary=!1,o.dir=!1,o.createFolders=!0,o.date=null,o.compression=null,o.compressionOptions=null,o.comment=null,o.unixPermissions=null,o.dosPermissions=null},{}],6:[function(r,i,o){var s=null;s=typeof Promise<"u"?Promise:r("lie"),i.exports={Promise:s}},{lie:37}],7:[function(r,i,o){var s=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Uint32Array<"u",a=r("pako"),c=r("./utils"),l=r("./stream/GenericWorker"),u=s?"uint8array":"array";function d(h,f){l.call(this,"FlateWorker/"+h),this._pako=null,this._pakoAction=h,this._pakoOptions=f,this.meta={}}o.magic="\b\0",c.inherits(d,l),d.prototype.processChunk=function(h){this.meta=h.meta,this._pako===null&&this._createPako(),this._pako.push(c.transformTo(u,h.data),!1)},d.prototype.flush=function(){l.prototype.flush.call(this),this._pako===null&&this._createPako(),this._pako.push([],!0)},d.prototype.cleanUp=function(){l.prototype.cleanUp.call(this),this._pako=null},d.prototype._createPako=function(){this._pako=new a[this._pakoAction]({raw:!0,level:this._pakoOptions.level||-1});var h=this;this._pako.onData=function(f){h.push({data:f,meta:h.meta})}},o.compressWorker=function(h){return new d("Deflate",h)},o.uncompressWorker=function(){return new d("Inflate",{})}},{"./stream/GenericWorker":28,"./utils":32,pako:38}],8:[function(r,i,o){function s(p,m){var g,y="";for(g=0;g<m;g++)y+=String.fromCharCode(255&p),p>>>=8;return y}function a(p,m,g,y,_,x){var b,w,S=p.file,T=p.compression,C=x!==u.utf8encode,A=c.transformTo("string",x(S.name)),R=c.transformTo("string",u.utf8encode(S.name)),L=S.comment,O=c.transformTo("string",x(L)),F=c.transformTo("string",u.utf8encode(L)),B=R.length!==S.name.length,j=F.length!==L.length,V="",q="",K="",ne=S.dir,le=S.date,ee={crc32:0,compressedSize:0,uncompressedSize:0};m&&!g||(ee.crc32=p.crc32,ee.compressedSize=p.compressedSize,ee.uncompressedSize=p.uncompressedSize);var ie=0;m&&(ie|=8),C||!B&&!j||(ie|=2048);var ce=0,ue=0;ne&&(ce|=16),_==="UNIX"?(ue=798,ce|=(function(Ce,Ae){var ke=Ce;return Ce||(ke=Ae?16893:33204),(65535&ke)<<16})(S.unixPermissions,ne)):(ue=20,ce|=(function(Ce){return 63&(Ce||0)})(S.dosPermissions)),b=le.getUTCHours(),b<<=6,b|=le.getUTCMinutes(),b<<=5,b|=le.getUTCSeconds()/2,w=le.getUTCFullYear()-1980,w<<=4,w|=le.getUTCMonth()+1,w<<=5,w|=le.getUTCDate(),B&&(q=s(1,1)+s(d(A),4)+R,V+="up"+s(q.length,2)+q),j&&(K=s(1,1)+s(d(O),4)+F,V+="uc"+s(K.length,2)+K);var _e="";return _e+=`
|
|
5689
5689
|
\0`,_e+=s(ie,2),_e+=T.magic,_e+=s(b,2),_e+=s(w,2),_e+=s(ee.crc32,4),_e+=s(ee.compressedSize,4),_e+=s(ee.uncompressedSize,4),_e+=s(A.length,2),_e+=s(V.length,2),{fileRecord:h.LOCAL_FILE_HEADER+_e+A+V,dirRecord:h.CENTRAL_FILE_HEADER+s(ue,2)+_e+s(O.length,2)+"\0\0\0\0"+s(ce,4)+s(y,4)+A+V+O}}var c=r("../utils"),l=r("../stream/GenericWorker"),u=r("../utf8"),d=r("../crc32"),h=r("../signature");function f(p,m,g,y){l.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=m,this.zipPlatform=g,this.encodeFileName=y,this.streamFiles=p,this.accumulate=!1,this.contentBuffer=[],this.dirRecords=[],this.currentSourceOffset=0,this.entriesCount=0,this.currentFile=null,this._sources=[]}c.inherits(f,l),f.prototype.push=function(p){var m=p.meta.percent||0,g=this.entriesCount,y=this._sources.length;this.accumulate?this.contentBuffer.push(p):(this.bytesWritten+=p.data.length,l.prototype.push.call(this,{data:p.data,meta:{currentFile:this.currentFile,percent:g?(m+100*(g-y-1))/g:100}}))},f.prototype.openedSource=function(p){this.currentSourceOffset=this.bytesWritten,this.currentFile=p.file.name;var m=this.streamFiles&&!p.file.dir;if(m){var g=a(p,m,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:g.fileRecord,meta:{percent:0}})}else this.accumulate=!0},f.prototype.closedSource=function(p){this.accumulate=!1;var m=this.streamFiles&&!p.file.dir,g=a(p,m,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(g.dirRecord),m)this.push({data:(function(y){return h.DATA_DESCRIPTOR+s(y.crc32,4)+s(y.compressedSize,4)+s(y.uncompressedSize,4)})(p),meta:{percent:100}});else for(this.push({data:g.fileRecord,meta:{percent:0}});this.contentBuffer.length;)this.push(this.contentBuffer.shift());this.currentFile=null},f.prototype.flush=function(){for(var p=this.bytesWritten,m=0;m<this.dirRecords.length;m++)this.push({data:this.dirRecords[m],meta:{percent:100}});var g=this.bytesWritten-p,y=(function(_,x,b,w,S){var T=c.transformTo("string",S(w));return h.CENTRAL_DIRECTORY_END+"\0\0\0\0"+s(_,2)+s(_,2)+s(x,4)+s(b,4)+s(T.length,2)+T})(this.dirRecords.length,g,p,this.zipComment,this.encodeFileName);this.push({data:y,meta:{percent:100}})},f.prototype.prepareNextSource=function(){this.previous=this._sources.shift(),this.openedSource(this.previous.streamInfo),this.isPaused?this.previous.pause():this.previous.resume()},f.prototype.registerPrevious=function(p){this._sources.push(p);var m=this;return p.on("data",function(g){m.processChunk(g)}),p.on("end",function(){m.closedSource(m.previous.streamInfo),m._sources.length?m.prepareNextSource():m.end()}),p.on("error",function(g){m.error(g)}),this},f.prototype.resume=function(){return!!l.prototype.resume.call(this)&&(!this.previous&&this._sources.length?(this.prepareNextSource(),!0):this.previous||this._sources.length||this.generatedError?void 0:(this.end(),!0))},f.prototype.error=function(p){var m=this._sources;if(!l.prototype.error.call(this,p))return!1;for(var g=0;g<m.length;g++)try{m[g].error(p)}catch{}return!0},f.prototype.lock=function(){l.prototype.lock.call(this);for(var p=this._sources,m=0;m<p.length;m++)p[m].lock()},i.exports=f},{"../crc32":4,"../signature":23,"../stream/GenericWorker":28,"../utf8":31,"../utils":32}],9:[function(r,i,o){var s=r("../compressions"),a=r("./ZipFileWorker");o.generateWorker=function(c,l,u){var d=new a(l.streamFiles,u,l.platform,l.encodeFileName),h=0;try{c.forEach(function(f,p){h++;var m=(function(x,b){var w=x||b,S=s[w];if(!S)throw new Error(w+" is not a valid compression method !");return S})(p.options.compression,l.compression),g=p.options.compressionOptions||l.compressionOptions||{},y=p.dir,_=p.date;p._compressWorker(m,g).withStreamInfo("file",{name:f,dir:y,date:_,comment:p.comment||"",unixPermissions:p.unixPermissions,dosPermissions:p.dosPermissions}).pipe(d)}),d.entriesCount=h}catch(f){d.error(f)}return d}},{"../compressions":3,"./ZipFileWorker":8}],10:[function(r,i,o){function s(){if(!(this instanceof s))return new s;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 a=new s;for(var c in this)typeof this[c]!="function"&&(a[c]=this[c]);return a}}(s.prototype=r("./object")).loadAsync=r("./load"),s.support=r("./support"),s.defaults=r("./defaults"),s.version="3.10.1",s.loadAsync=function(a,c){return new s().loadAsync(a,c)},s.external=r("./external"),i.exports=s},{"./defaults":5,"./external":6,"./load":11,"./object":15,"./support":30}],11:[function(r,i,o){var s=r("./utils"),a=r("./external"),c=r("./utf8"),l=r("./zipEntries"),u=r("./stream/Crc32Probe"),d=r("./nodejsUtils");function h(f){return new a.Promise(function(p,m){var g=f.decompressed.getContentWorker().pipe(new u);g.on("error",function(y){m(y)}).on("end",function(){g.streamInfo.crc32!==f.decompressed.crc32?m(new Error("Corrupted zip : CRC32 mismatch")):p()}).resume()})}i.exports=function(f,p){var m=this;return p=s.extend(p||{},{base64:!1,checkCRC32:!1,optimizedBinaryString:!1,createFolders:!1,decodeFileName:c.utf8decode}),d.isNode&&d.isStream(f)?a.Promise.reject(new Error("JSZip can't accept a stream when loading a zip file.")):s.prepareContent("the loaded zip file",f,!0,p.optimizedBinaryString,p.base64).then(function(g){var y=new l(p);return y.load(g),y}).then(function(g){var y=[a.Promise.resolve(g)],_=g.files;if(p.checkCRC32)for(var x=0;x<_.length;x++)y.push(h(_[x]));return a.Promise.all(y)}).then(function(g){for(var y=g.shift(),_=y.files,x=0;x<_.length;x++){var b=_[x],w=b.fileNameStr,S=s.resolve(b.fileNameStr);m.file(S,b.decompressed,{binary:!0,optimizedBinaryString:!0,date:b.date,dir:b.dir,comment:b.fileCommentStr.length?b.fileCommentStr:null,unixPermissions:b.unixPermissions,dosPermissions:b.dosPermissions,createFolders:p.createFolders}),b.dir||(m.file(S).unsafeOriginalName=w)}return y.zipComment.length&&(m.comment=y.zipComment),m})}},{"./external":6,"./nodejsUtils":14,"./stream/Crc32Probe":25,"./utf8":31,"./utils":32,"./zipEntries":33}],12:[function(r,i,o){var s=r("../utils"),a=r("../stream/GenericWorker");function c(l,u){a.call(this,"Nodejs stream input adapter for "+l),this._upstreamEnded=!1,this._bindStream(u)}s.inherits(c,a),c.prototype._bindStream=function(l){var u=this;(this._stream=l).pause(),l.on("data",function(d){u.push({data:d,meta:{percent:0}})}).on("error",function(d){u.isPaused?this.generatedError=d:u.error(d)}).on("end",function(){u.isPaused?u._upstreamEnded=!0:u.end()})},c.prototype.pause=function(){return!!a.prototype.pause.call(this)&&(this._stream.pause(),!0)},c.prototype.resume=function(){return!!a.prototype.resume.call(this)&&(this._upstreamEnded?this.end():this._stream.resume(),!0)},i.exports=c},{"../stream/GenericWorker":28,"../utils":32}],13:[function(r,i,o){var s=r("readable-stream").Readable;function a(c,l,u){s.call(this,l),this._helper=c;var d=this;c.on("data",function(h,f){d.push(h)||d._helper.pause(),u&&u(f)}).on("error",function(h){d.emit("error",h)}).on("end",function(){d.push(null)})}r("../utils").inherits(a,s),a.prototype._read=function(){this._helper.resume()},i.exports=a},{"../utils":32,"readable-stream":16}],14:[function(r,i,o){i.exports={isNode:typeof Buffer<"u",newBufferFrom:function(s,a){if(Buffer.from&&Buffer.from!==Uint8Array.from)return Buffer.from(s,a);if(typeof s=="number")throw new Error('The "data" argument must not be a number');return new Buffer(s,a)},allocBuffer:function(s){if(Buffer.alloc)return Buffer.alloc(s);var a=new Buffer(s);return a.fill(0),a},isBuffer:function(s){return Buffer.isBuffer(s)},isStream:function(s){return s&&typeof s.on=="function"&&typeof s.pause=="function"&&typeof s.resume=="function"}}},{}],15:[function(r,i,o){function s(S,T,C){var A,R=c.getTypeOf(T),L=c.extend(C||{},d);L.date=L.date||new Date,L.compression!==null&&(L.compression=L.compression.toUpperCase()),typeof L.unixPermissions=="string"&&(L.unixPermissions=parseInt(L.unixPermissions,8)),L.unixPermissions&&16384&L.unixPermissions&&(L.dir=!0),L.dosPermissions&&16&L.dosPermissions&&(L.dir=!0),L.dir&&(S=_(S)),L.createFolders&&(A=y(S))&&x.call(this,A,!0);var O=R==="string"&&L.binary===!1&&L.base64===!1;C&&C.binary!==void 0||(L.binary=!O),(T instanceof h&&T.uncompressedSize===0||L.dir||!T||T.length===0)&&(L.base64=!1,L.binary=!0,T="",L.compression="STORE",R="string");var F=null;F=T instanceof h||T instanceof l?T:m.isNode&&m.isStream(T)?new g(S,T):c.prepareContent(S,T,L.binary,L.optimizedBinaryString,L.base64);var B=new f(S,F,L);this.files[S]=B}var a=r("./utf8"),c=r("./utils"),l=r("./stream/GenericWorker"),u=r("./stream/StreamHelper"),d=r("./defaults"),h=r("./compressedObject"),f=r("./zipObject"),p=r("./generate"),m=r("./nodejsUtils"),g=r("./nodejs/NodejsStreamInputAdapter"),y=function(S){S.slice(-1)==="/"&&(S=S.substring(0,S.length-1));var T=S.lastIndexOf("/");return 0<T?S.substring(0,T):""},_=function(S){return S.slice(-1)!=="/"&&(S+="/"),S},x=function(S,T){return T=T!==void 0?T:d.createFolders,S=_(S),this.files[S]||s.call(this,S,null,{dir:!0,createFolders:T}),this.files[S]};function b(S){return Object.prototype.toString.call(S)==="[object RegExp]"}var w={load:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},forEach:function(S){var T,C,A;for(T in this.files)A=this.files[T],(C=T.slice(this.root.length,T.length))&&T.slice(0,this.root.length)===this.root&&S(C,A)},filter:function(S){var T=[];return this.forEach(function(C,A){S(C,A)&&T.push(A)}),T},file:function(S,T,C){if(arguments.length!==1)return S=this.root+S,s.call(this,S,T,C),this;if(b(S)){var A=S;return this.filter(function(L,O){return!O.dir&&A.test(L)})}var R=this.files[this.root+S];return R&&!R.dir?R:null},folder:function(S){if(!S)return this;if(b(S))return this.filter(function(R,L){return L.dir&&S.test(R)});var T=this.root+S,C=x.call(this,T),A=this.clone();return A.root=C.name,A},remove:function(S){S=this.root+S;var T=this.files[S];if(T||(S.slice(-1)!=="/"&&(S+="/"),T=this.files[S]),T&&!T.dir)delete this.files[S];else for(var C=this.filter(function(R,L){return L.name.slice(0,S.length)===S}),A=0;A<C.length;A++)delete this.files[C[A].name];return this},generate:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},generateInternalStream:function(S){var T,C={};try{if((C=c.extend(S||{},{streamFiles:!1,compression:"STORE",compressionOptions:null,type:"",platform:"DOS",comment:null,mimeType:"application/zip",encodeFileName:a.utf8encode})).type=C.type.toLowerCase(),C.compression=C.compression.toUpperCase(),C.type==="binarystring"&&(C.type="string"),!C.type)throw new Error("No output type specified.");c.checkSupport(C.type),C.platform!=="darwin"&&C.platform!=="freebsd"&&C.platform!=="linux"&&C.platform!=="sunos"||(C.platform="UNIX"),C.platform==="win32"&&(C.platform="DOS");var A=C.comment||this.comment||"";T=p.generateWorker(this,C,A)}catch(R){(T=new l("error")).error(R)}return new u(T,C.type||"string",C.mimeType)},generateAsync:function(S,T){return this.generateInternalStream(S).accumulate(T)},generateNodeStream:function(S,T){return(S=S||{}).type||(S.type="nodebuffer"),this.generateInternalStream(S).toNodejsStream(T)}};i.exports=w},{"./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(r,i,o){i.exports=r("stream")},{stream:void 0}],17:[function(r,i,o){var s=r("./DataReader");function a(c){s.call(this,c);for(var l=0;l<this.data.length;l++)c[l]=255&c[l]}r("../utils").inherits(a,s),a.prototype.byteAt=function(c){return this.data[this.zero+c]},a.prototype.lastIndexOfSignature=function(c){for(var l=c.charCodeAt(0),u=c.charCodeAt(1),d=c.charCodeAt(2),h=c.charCodeAt(3),f=this.length-4;0<=f;--f)if(this.data[f]===l&&this.data[f+1]===u&&this.data[f+2]===d&&this.data[f+3]===h)return f-this.zero;return-1},a.prototype.readAndCheckSignature=function(c){var l=c.charCodeAt(0),u=c.charCodeAt(1),d=c.charCodeAt(2),h=c.charCodeAt(3),f=this.readData(4);return l===f[0]&&u===f[1]&&d===f[2]&&h===f[3]},a.prototype.readData=function(c){if(this.checkOffset(c),c===0)return[];var l=this.data.slice(this.zero+this.index,this.zero+this.index+c);return this.index+=c,l},i.exports=a},{"../utils":32,"./DataReader":18}],18:[function(r,i,o){var s=r("../utils");function a(c){this.data=c,this.length=c.length,this.index=0,this.zero=0}a.prototype={checkOffset:function(c){this.checkIndex(this.index+c)},checkIndex:function(c){if(this.length<this.zero+c||c<0)throw new Error("End of data reached (data length = "+this.length+", asked index = "+c+"). Corrupted zip ?")},setIndex:function(c){this.checkIndex(c),this.index=c},skip:function(c){this.setIndex(this.index+c)},byteAt:function(){},readInt:function(c){var l,u=0;for(this.checkOffset(c),l=this.index+c-1;l>=this.index;l--)u=(u<<8)+this.byteAt(l);return this.index+=c,u},readString:function(c){return s.transformTo("string",this.readData(c))},readData:function(){},lastIndexOfSignature:function(){},readAndCheckSignature:function(){},readDate:function(){var c=this.readInt(4);return new Date(Date.UTC(1980+(c>>25&127),(c>>21&15)-1,c>>16&31,c>>11&31,c>>5&63,(31&c)<<1))}},i.exports=a},{"../utils":32}],19:[function(r,i,o){var s=r("./Uint8ArrayReader");function a(c){s.call(this,c)}r("../utils").inherits(a,s),a.prototype.readData=function(c){this.checkOffset(c);var l=this.data.slice(this.zero+this.index,this.zero+this.index+c);return this.index+=c,l},i.exports=a},{"../utils":32,"./Uint8ArrayReader":21}],20:[function(r,i,o){var s=r("./DataReader");function a(c){s.call(this,c)}r("../utils").inherits(a,s),a.prototype.byteAt=function(c){return this.data.charCodeAt(this.zero+c)},a.prototype.lastIndexOfSignature=function(c){return this.data.lastIndexOf(c)-this.zero},a.prototype.readAndCheckSignature=function(c){return c===this.readData(4)},a.prototype.readData=function(c){this.checkOffset(c);var l=this.data.slice(this.zero+this.index,this.zero+this.index+c);return this.index+=c,l},i.exports=a},{"../utils":32,"./DataReader":18}],21:[function(r,i,o){var s=r("./ArrayReader");function a(c){s.call(this,c)}r("../utils").inherits(a,s),a.prototype.readData=function(c){if(this.checkOffset(c),c===0)return new Uint8Array(0);var l=this.data.subarray(this.zero+this.index,this.zero+this.index+c);return this.index+=c,l},i.exports=a},{"../utils":32,"./ArrayReader":17}],22:[function(r,i,o){var s=r("../utils"),a=r("../support"),c=r("./ArrayReader"),l=r("./StringReader"),u=r("./NodeBufferReader"),d=r("./Uint8ArrayReader");i.exports=function(h){var f=s.getTypeOf(h);return s.checkSupport(f),f!=="string"||a.uint8array?f==="nodebuffer"?new u(h):a.uint8array?new d(s.transformTo("uint8array",h)):new c(s.transformTo("array",h)):new l(h)}},{"../support":30,"../utils":32,"./ArrayReader":17,"./NodeBufferReader":19,"./StringReader":20,"./Uint8ArrayReader":21}],23:[function(r,i,o){o.LOCAL_FILE_HEADER="PK",o.CENTRAL_FILE_HEADER="PK",o.CENTRAL_DIRECTORY_END="PK",o.ZIP64_CENTRAL_DIRECTORY_LOCATOR="PK\x07",o.ZIP64_CENTRAL_DIRECTORY_END="PK",o.DATA_DESCRIPTOR="PK\x07\b"},{}],24:[function(r,i,o){var s=r("./GenericWorker"),a=r("../utils");function c(l){s.call(this,"ConvertWorker to "+l),this.destType=l}a.inherits(c,s),c.prototype.processChunk=function(l){this.push({data:a.transformTo(this.destType,l.data),meta:l.meta})},i.exports=c},{"../utils":32,"./GenericWorker":28}],25:[function(r,i,o){var s=r("./GenericWorker"),a=r("../crc32");function c(){s.call(this,"Crc32Probe"),this.withStreamInfo("crc32",0)}r("../utils").inherits(c,s),c.prototype.processChunk=function(l){this.streamInfo.crc32=a(l.data,this.streamInfo.crc32||0),this.push(l)},i.exports=c},{"../crc32":4,"../utils":32,"./GenericWorker":28}],26:[function(r,i,o){var s=r("../utils"),a=r("./GenericWorker");function c(l){a.call(this,"DataLengthProbe for "+l),this.propName=l,this.withStreamInfo(l,0)}s.inherits(c,a),c.prototype.processChunk=function(l){if(l){var u=this.streamInfo[this.propName]||0;this.streamInfo[this.propName]=u+l.data.length}a.prototype.processChunk.call(this,l)},i.exports=c},{"../utils":32,"./GenericWorker":28}],27:[function(r,i,o){var s=r("../utils"),a=r("./GenericWorker");function c(l){a.call(this,"DataWorker");var u=this;this.dataIsReady=!1,this.index=0,this.max=0,this.data=null,this.type="",this._tickScheduled=!1,l.then(function(d){u.dataIsReady=!0,u.data=d,u.max=d&&d.length||0,u.type=s.getTypeOf(d),u.isPaused||u._tickAndRepeat()},function(d){u.error(d)})}s.inherits(c,a),c.prototype.cleanUp=function(){a.prototype.cleanUp.call(this),this.data=null},c.prototype.resume=function(){return!!a.prototype.resume.call(this)&&(!this._tickScheduled&&this.dataIsReady&&(this._tickScheduled=!0,s.delay(this._tickAndRepeat,[],this)),!0)},c.prototype._tickAndRepeat=function(){this._tickScheduled=!1,this.isPaused||this.isFinished||(this._tick(),this.isFinished||(s.delay(this._tickAndRepeat,[],this),this._tickScheduled=!0))},c.prototype._tick=function(){if(this.isPaused||this.isFinished)return!1;var l=null,u=Math.min(this.max,this.index+16384);if(this.index>=this.max)return this.end();switch(this.type){case"string":l=this.data.substring(this.index,u);break;case"uint8array":l=this.data.subarray(this.index,u);break;case"array":case"nodebuffer":l=this.data.slice(this.index,u)}return this.index=u,this.push({data:l,meta:{percent:this.max?this.index/this.max*100:0}})},i.exports=c},{"../utils":32,"./GenericWorker":28}],28:[function(r,i,o){function s(a){this.name=a||"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}s.prototype={push:function(a){this.emit("data",a)},end:function(){if(this.isFinished)return!1;this.flush();try{this.emit("end"),this.cleanUp(),this.isFinished=!0}catch(a){this.emit("error",a)}return!0},error:function(a){return!this.isFinished&&(this.isPaused?this.generatedError=a:(this.isFinished=!0,this.emit("error",a),this.previous&&this.previous.error(a),this.cleanUp()),!0)},on:function(a,c){return this._listeners[a].push(c),this},cleanUp:function(){this.streamInfo=this.generatedError=this.extraStreamInfo=null,this._listeners=[]},emit:function(a,c){if(this._listeners[a])for(var l=0;l<this._listeners[a].length;l++)this._listeners[a][l].call(this,c)},pipe:function(a){return a.registerPrevious(this)},registerPrevious:function(a){if(this.isLocked)throw new Error("The stream '"+this+"' has already been used.");this.streamInfo=a.streamInfo,this.mergeStreamInfo(),this.previous=a;var c=this;return a.on("data",function(l){c.processChunk(l)}),a.on("end",function(){c.end()}),a.on("error",function(l){c.error(l)}),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 a=this.isPaused=!1;return this.generatedError&&(this.error(this.generatedError),a=!0),this.previous&&this.previous.resume(),!a},flush:function(){},processChunk:function(a){this.push(a)},withStreamInfo:function(a,c){return this.extraStreamInfo[a]=c,this.mergeStreamInfo(),this},mergeStreamInfo:function(){for(var a in this.extraStreamInfo)Object.prototype.hasOwnProperty.call(this.extraStreamInfo,a)&&(this.streamInfo[a]=this.extraStreamInfo[a])},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 a="Worker "+this.name;return this.previous?this.previous+" -> "+a:a}},i.exports=s},{}],29:[function(r,i,o){var s=r("../utils"),a=r("./ConvertWorker"),c=r("./GenericWorker"),l=r("../base64"),u=r("../support"),d=r("../external"),h=null;if(u.nodestream)try{h=r("../nodejs/NodejsStreamOutputAdapter")}catch{}function f(m,g){return new d.Promise(function(y,_){var x=[],b=m._internalType,w=m._outputType,S=m._mimeType;m.on("data",function(T,C){x.push(T),g&&g(C)}).on("error",function(T){x=[],_(T)}).on("end",function(){try{var T=(function(C,A,R){switch(C){case"blob":return s.newBlob(s.transformTo("arraybuffer",A),R);case"base64":return l.encode(A);default:return s.transformTo(C,A)}})(w,(function(C,A){var R,L=0,O=null,F=0;for(R=0;R<A.length;R++)F+=A[R].length;switch(C){case"string":return A.join("");case"array":return Array.prototype.concat.apply([],A);case"uint8array":for(O=new Uint8Array(F),R=0;R<A.length;R++)O.set(A[R],L),L+=A[R].length;return O;case"nodebuffer":return Buffer.concat(A);default:throw new Error("concat : unsupported type '"+C+"'")}})(b,x),S);y(T)}catch(C){_(C)}x=[]}).resume()})}function p(m,g,y){var _=g;switch(g){case"blob":case"arraybuffer":_="uint8array";break;case"base64":_="string"}try{this._internalType=_,this._outputType=g,this._mimeType=y,s.checkSupport(_),this._worker=m.pipe(new a(_)),m.lock()}catch(x){this._worker=new c("error"),this._worker.error(x)}}p.prototype={accumulate:function(m){return f(this,m)},on:function(m,g){var y=this;return m==="data"?this._worker.on(m,function(_){g.call(y,_.data,_.meta)}):this._worker.on(m,function(){s.delay(g,arguments,y)}),this},resume:function(){return s.delay(this._worker.resume,[],this._worker),this},pause:function(){return this._worker.pause(),this},toNodejsStream:function(m){if(s.checkSupport("nodestream"),this._outputType!=="nodebuffer")throw new Error(this._outputType+" is not supported by this method");return new h(this,{objectMode:this._outputType!=="nodebuffer"},m)}},i.exports=p},{"../base64":1,"../external":6,"../nodejs/NodejsStreamOutputAdapter":13,"../support":30,"../utils":32,"./ConvertWorker":24,"./GenericWorker":28}],30:[function(r,i,o){if(o.base64=!0,o.array=!0,o.string=!0,o.arraybuffer=typeof ArrayBuffer<"u"&&typeof Uint8Array<"u",o.nodebuffer=typeof Buffer<"u",o.uint8array=typeof Uint8Array<"u",typeof ArrayBuffer>"u")o.blob=!1;else{var s=new ArrayBuffer(0);try{o.blob=new Blob([s],{type:"application/zip"}).size===0}catch{try{var a=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);a.append(s),o.blob=a.getBlob("application/zip").size===0}catch{o.blob=!1}}}try{o.nodestream=!!r("readable-stream").Readable}catch{o.nodestream=!1}},{"readable-stream":16}],31:[function(r,i,o){for(var s=r("./utils"),a=r("./support"),c=r("./nodejsUtils"),l=r("./stream/GenericWorker"),u=new Array(256),d=0;d<256;d++)u[d]=252<=d?6:248<=d?5:240<=d?4:224<=d?3:192<=d?2:1;u[254]=u[254]=1;function h(){l.call(this,"utf-8 decode"),this.leftOver=null}function f(){l.call(this,"utf-8 encode")}o.utf8encode=function(p){return a.nodebuffer?c.newBufferFrom(p,"utf-8"):(function(m){var g,y,_,x,b,w=m.length,S=0;for(x=0;x<w;x++)(64512&(y=m.charCodeAt(x)))==55296&&x+1<w&&(64512&(_=m.charCodeAt(x+1)))==56320&&(y=65536+(y-55296<<10)+(_-56320),x++),S+=y<128?1:y<2048?2:y<65536?3:4;for(g=a.uint8array?new Uint8Array(S):new Array(S),x=b=0;b<S;x++)(64512&(y=m.charCodeAt(x)))==55296&&x+1<w&&(64512&(_=m.charCodeAt(x+1)))==56320&&(y=65536+(y-55296<<10)+(_-56320),x++),y<128?g[b++]=y:(y<2048?g[b++]=192|y>>>6:(y<65536?g[b++]=224|y>>>12:(g[b++]=240|y>>>18,g[b++]=128|y>>>12&63),g[b++]=128|y>>>6&63),g[b++]=128|63&y);return g})(p)},o.utf8decode=function(p){return a.nodebuffer?s.transformTo("nodebuffer",p).toString("utf-8"):(function(m){var g,y,_,x,b=m.length,w=new Array(2*b);for(g=y=0;g<b;)if((_=m[g++])<128)w[y++]=_;else if(4<(x=u[_]))w[y++]=65533,g+=x-1;else{for(_&=x===2?31:x===3?15:7;1<x&&g<b;)_=_<<6|63&m[g++],x--;1<x?w[y++]=65533:_<65536?w[y++]=_:(_-=65536,w[y++]=55296|_>>10&1023,w[y++]=56320|1023&_)}return w.length!==y&&(w.subarray?w=w.subarray(0,y):w.length=y),s.applyFromCharCode(w)})(p=s.transformTo(a.uint8array?"uint8array":"array",p))},s.inherits(h,l),h.prototype.processChunk=function(p){var m=s.transformTo(a.uint8array?"uint8array":"array",p.data);if(this.leftOver&&this.leftOver.length){if(a.uint8array){var g=m;(m=new Uint8Array(g.length+this.leftOver.length)).set(this.leftOver,0),m.set(g,this.leftOver.length)}else m=this.leftOver.concat(m);this.leftOver=null}var y=(function(x,b){var w;for((b=b||x.length)>x.length&&(b=x.length),w=b-1;0<=w&&(192&x[w])==128;)w--;return w<0||w===0?b:w+u[x[w]]>b?w:b})(m),_=m;y!==m.length&&(a.uint8array?(_=m.subarray(0,y),this.leftOver=m.subarray(y,m.length)):(_=m.slice(0,y),this.leftOver=m.slice(y,m.length))),this.push({data:o.utf8decode(_),meta:p.meta})},h.prototype.flush=function(){this.leftOver&&this.leftOver.length&&(this.push({data:o.utf8decode(this.leftOver),meta:{}}),this.leftOver=null)},o.Utf8DecodeWorker=h,s.inherits(f,l),f.prototype.processChunk=function(p){this.push({data:o.utf8encode(p.data),meta:p.meta})},o.Utf8EncodeWorker=f},{"./nodejsUtils":14,"./stream/GenericWorker":28,"./support":30,"./utils":32}],32:[function(r,i,o){var s=r("./support"),a=r("./base64"),c=r("./nodejsUtils"),l=r("./external");function u(g){return g}function d(g,y){for(var _=0;_<g.length;++_)y[_]=255&g.charCodeAt(_);return y}r("setimmediate"),o.newBlob=function(g,y){o.checkSupport("blob");try{return new Blob([g],{type:y})}catch{try{var _=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);return _.append(g),_.getBlob(y)}catch{throw new Error("Bug : can't construct the Blob.")}}};var h={stringifyByChunk:function(g,y,_){var x=[],b=0,w=g.length;if(w<=_)return String.fromCharCode.apply(null,g);for(;b<w;)y==="array"||y==="nodebuffer"?x.push(String.fromCharCode.apply(null,g.slice(b,Math.min(b+_,w)))):x.push(String.fromCharCode.apply(null,g.subarray(b,Math.min(b+_,w)))),b+=_;return x.join("")},stringifyByChar:function(g){for(var y="",_=0;_<g.length;_++)y+=String.fromCharCode(g[_]);return y},applyCanBeUsed:{uint8array:(function(){try{return s.uint8array&&String.fromCharCode.apply(null,new Uint8Array(1)).length===1}catch{return!1}})(),nodebuffer:(function(){try{return s.nodebuffer&&String.fromCharCode.apply(null,c.allocBuffer(1)).length===1}catch{return!1}})()}};function f(g){var y=65536,_=o.getTypeOf(g),x=!0;if(_==="uint8array"?x=h.applyCanBeUsed.uint8array:_==="nodebuffer"&&(x=h.applyCanBeUsed.nodebuffer),x)for(;1<y;)try{return h.stringifyByChunk(g,_,y)}catch{y=Math.floor(y/2)}return h.stringifyByChar(g)}function p(g,y){for(var _=0;_<g.length;_++)y[_]=g[_];return y}o.applyFromCharCode=f;var m={};m.string={string:u,array:function(g){return d(g,new Array(g.length))},arraybuffer:function(g){return m.string.uint8array(g).buffer},uint8array:function(g){return d(g,new Uint8Array(g.length))},nodebuffer:function(g){return d(g,c.allocBuffer(g.length))}},m.array={string:f,array:u,arraybuffer:function(g){return new Uint8Array(g).buffer},uint8array:function(g){return new Uint8Array(g)},nodebuffer:function(g){return c.newBufferFrom(g)}},m.arraybuffer={string:function(g){return f(new Uint8Array(g))},array:function(g){return p(new Uint8Array(g),new Array(g.byteLength))},arraybuffer:u,uint8array:function(g){return new Uint8Array(g)},nodebuffer:function(g){return c.newBufferFrom(new Uint8Array(g))}},m.uint8array={string:f,array:function(g){return p(g,new Array(g.length))},arraybuffer:function(g){return g.buffer},uint8array:u,nodebuffer:function(g){return c.newBufferFrom(g)}},m.nodebuffer={string:f,array:function(g){return p(g,new Array(g.length))},arraybuffer:function(g){return m.nodebuffer.uint8array(g).buffer},uint8array:function(g){return p(g,new Uint8Array(g.length))},nodebuffer:u},o.transformTo=function(g,y){if(y=y||"",!g)return y;o.checkSupport(g);var _=o.getTypeOf(y);return m[_][g](y)},o.resolve=function(g){for(var y=g.split("/"),_=[],x=0;x<y.length;x++){var b=y[x];b==="."||b===""&&x!==0&&x!==y.length-1||(b===".."?_.pop():_.push(b))}return _.join("/")},o.getTypeOf=function(g){return typeof g=="string"?"string":Object.prototype.toString.call(g)==="[object Array]"?"array":s.nodebuffer&&c.isBuffer(g)?"nodebuffer":s.uint8array&&g instanceof Uint8Array?"uint8array":s.arraybuffer&&g instanceof ArrayBuffer?"arraybuffer":void 0},o.checkSupport=function(g){if(!s[g.toLowerCase()])throw new Error(g+" is not supported by this platform")},o.MAX_VALUE_16BITS=65535,o.MAX_VALUE_32BITS=-1,o.pretty=function(g){var y,_,x="";for(_=0;_<(g||"").length;_++)x+="\\x"+((y=g.charCodeAt(_))<16?"0":"")+y.toString(16).toUpperCase();return x},o.delay=function(g,y,_){setImmediate(function(){g.apply(_||null,y||[])})},o.inherits=function(g,y){function _(){}_.prototype=y.prototype,g.prototype=new _},o.extend=function(){var g,y,_={};for(g=0;g<arguments.length;g++)for(y in arguments[g])Object.prototype.hasOwnProperty.call(arguments[g],y)&&_[y]===void 0&&(_[y]=arguments[g][y]);return _},o.prepareContent=function(g,y,_,x,b){return l.Promise.resolve(y).then(function(w){return s.blob&&(w instanceof Blob||["[object File]","[object Blob]"].indexOf(Object.prototype.toString.call(w))!==-1)&&typeof FileReader<"u"?new l.Promise(function(S,T){var C=new FileReader;C.onload=function(A){S(A.target.result)},C.onerror=function(A){T(A.target.error)},C.readAsArrayBuffer(w)}):w}).then(function(w){var S=o.getTypeOf(w);return S?(S==="arraybuffer"?w=o.transformTo("uint8array",w):S==="string"&&(b?w=a.decode(w):_&&x!==!0&&(w=(function(T){return d(T,s.uint8array?new Uint8Array(T.length):new Array(T.length))})(w))),w):l.Promise.reject(new Error("Can't read the data of '"+g+"'. Is it in a supported JavaScript type (String, Blob, ArrayBuffer, etc) ?"))})}},{"./base64":1,"./external":6,"./nodejsUtils":14,"./support":30,setimmediate:54}],33:[function(r,i,o){var s=r("./reader/readerFor"),a=r("./utils"),c=r("./signature"),l=r("./zipEntry"),u=r("./support");function d(h){this.files=[],this.loadOptions=h}d.prototype={checkSignature:function(h){if(!this.reader.readAndCheckSignature(h)){this.reader.index-=4;var f=this.reader.readString(4);throw new Error("Corrupted zip or bug: unexpected signature ("+a.pretty(f)+", expected "+a.pretty(h)+")")}},isSignature:function(h,f){var p=this.reader.index;this.reader.setIndex(h);var m=this.reader.readString(4)===f;return this.reader.setIndex(p),m},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 h=this.reader.readData(this.zipCommentLength),f=u.uint8array?"uint8array":"array",p=a.transformTo(f,h);this.zipComment=this.loadOptions.decodeFileName(p)},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 h,f,p,m=this.zip64EndOfCentralSize-44;0<m;)h=this.reader.readInt(2),f=this.reader.readInt(4),p=this.reader.readData(f),this.zip64ExtensibleData[h]={id:h,length:f,value:p}},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 h,f;for(h=0;h<this.files.length;h++)f=this.files[h],this.reader.setIndex(f.localHeaderOffset),this.checkSignature(c.LOCAL_FILE_HEADER),f.readLocalPart(this.reader),f.handleUTF8(),f.processAttributes()},readCentralDir:function(){var h;for(this.reader.setIndex(this.centralDirOffset);this.reader.readAndCheckSignature(c.CENTRAL_FILE_HEADER);)(h=new l({zip64:this.zip64},this.loadOptions)).readCentralPart(this.reader),this.files.push(h);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 h=this.reader.lastIndexOfSignature(c.CENTRAL_DIRECTORY_END);if(h<0)throw this.isSignature(0,c.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(h);var f=h;if(this.checkSignature(c.CENTRAL_DIRECTORY_END),this.readBlockEndOfCentral(),this.diskNumber===a.MAX_VALUE_16BITS||this.diskWithCentralDirStart===a.MAX_VALUE_16BITS||this.centralDirRecordsOnThisDisk===a.MAX_VALUE_16BITS||this.centralDirRecords===a.MAX_VALUE_16BITS||this.centralDirSize===a.MAX_VALUE_32BITS||this.centralDirOffset===a.MAX_VALUE_32BITS){if(this.zip64=!0,(h=this.reader.lastIndexOfSignature(c.ZIP64_CENTRAL_DIRECTORY_LOCATOR))<0)throw new Error("Corrupted zip: can't find the ZIP64 end of central directory locator");if(this.reader.setIndex(h),this.checkSignature(c.ZIP64_CENTRAL_DIRECTORY_LOCATOR),this.readBlockZip64EndOfCentralLocator(),!this.isSignature(this.relativeOffsetEndOfZip64CentralDir,c.ZIP64_CENTRAL_DIRECTORY_END)&&(this.relativeOffsetEndOfZip64CentralDir=this.reader.lastIndexOfSignature(c.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(c.ZIP64_CENTRAL_DIRECTORY_END),this.readBlockZip64EndOfCentral()}var p=this.centralDirOffset+this.centralDirSize;this.zip64&&(p+=20,p+=12+this.zip64EndOfCentralSize);var m=f-p;if(0<m)this.isSignature(f,c.CENTRAL_FILE_HEADER)||(this.reader.zero=m);else if(m<0)throw new Error("Corrupted zip: missing "+Math.abs(m)+" bytes.")},prepareReader:function(h){this.reader=s(h)},load:function(h){this.prepareReader(h),this.readEndOfCentral(),this.readCentralDir(),this.readLocalFiles()}},i.exports=d},{"./reader/readerFor":22,"./signature":23,"./support":30,"./utils":32,"./zipEntry":34}],34:[function(r,i,o){var s=r("./reader/readerFor"),a=r("./utils"),c=r("./compressedObject"),l=r("./crc32"),u=r("./utf8"),d=r("./compressions"),h=r("./support");function f(p,m){this.options=p,this.loadOptions=m}f.prototype={isEncrypted:function(){return(1&this.bitFlag)==1},useUTF8:function(){return(2048&this.bitFlag)==2048},readLocalPart:function(p){var m,g;if(p.skip(22),this.fileNameLength=p.readInt(2),g=p.readInt(2),this.fileName=p.readData(this.fileNameLength),p.skip(g),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((m=(function(y){for(var _ in d)if(Object.prototype.hasOwnProperty.call(d,_)&&d[_].magic===y)return d[_];return null})(this.compressionMethod))===null)throw new Error("Corrupted zip : compression "+a.pretty(this.compressionMethod)+" unknown (inner file : "+a.transformTo("string",this.fileName)+")");this.decompressed=new c(this.compressedSize,this.uncompressedSize,this.crc32,m,p.readData(this.compressedSize))},readCentralPart:function(p){this.versionMadeBy=p.readInt(2),p.skip(2),this.bitFlag=p.readInt(2),this.compressionMethod=p.readString(2),this.date=p.readDate(),this.crc32=p.readInt(4),this.compressedSize=p.readInt(4),this.uncompressedSize=p.readInt(4);var m=p.readInt(2);if(this.extraFieldsLength=p.readInt(2),this.fileCommentLength=p.readInt(2),this.diskNumberStart=p.readInt(2),this.internalFileAttributes=p.readInt(2),this.externalFileAttributes=p.readInt(4),this.localHeaderOffset=p.readInt(4),this.isEncrypted())throw new Error("Encrypted zip are not supported");p.skip(m),this.readExtraFields(p),this.parseZIP64ExtraField(p),this.fileComment=p.readData(this.fileCommentLength)},processAttributes:function(){this.unixPermissions=null,this.dosPermissions=null;var p=this.versionMadeBy>>8;this.dir=!!(16&this.externalFileAttributes),p==0&&(this.dosPermissions=63&this.externalFileAttributes),p==3&&(this.unixPermissions=this.externalFileAttributes>>16&65535),this.dir||this.fileNameStr.slice(-1)!=="/"||(this.dir=!0)},parseZIP64ExtraField:function(){if(this.extraFields[1]){var p=s(this.extraFields[1].value);this.uncompressedSize===a.MAX_VALUE_32BITS&&(this.uncompressedSize=p.readInt(8)),this.compressedSize===a.MAX_VALUE_32BITS&&(this.compressedSize=p.readInt(8)),this.localHeaderOffset===a.MAX_VALUE_32BITS&&(this.localHeaderOffset=p.readInt(8)),this.diskNumberStart===a.MAX_VALUE_32BITS&&(this.diskNumberStart=p.readInt(4))}},readExtraFields:function(p){var m,g,y,_=p.index+this.extraFieldsLength;for(this.extraFields||(this.extraFields={});p.index+4<_;)m=p.readInt(2),g=p.readInt(2),y=p.readData(g),this.extraFields[m]={id:m,length:g,value:y};p.setIndex(_)},handleUTF8:function(){var p=h.uint8array?"uint8array":"array";if(this.useUTF8())this.fileNameStr=u.utf8decode(this.fileName),this.fileCommentStr=u.utf8decode(this.fileComment);else{var m=this.findExtraFieldUnicodePath();if(m!==null)this.fileNameStr=m;else{var g=a.transformTo(p,this.fileName);this.fileNameStr=this.loadOptions.decodeFileName(g)}var y=this.findExtraFieldUnicodeComment();if(y!==null)this.fileCommentStr=y;else{var _=a.transformTo(p,this.fileComment);this.fileCommentStr=this.loadOptions.decodeFileName(_)}}},findExtraFieldUnicodePath:function(){var p=this.extraFields[28789];if(p){var m=s(p.value);return m.readInt(1)!==1||l(this.fileName)!==m.readInt(4)?null:u.utf8decode(m.readData(p.length-5))}return null},findExtraFieldUnicodeComment:function(){var p=this.extraFields[25461];if(p){var m=s(p.value);return m.readInt(1)!==1||l(this.fileComment)!==m.readInt(4)?null:u.utf8decode(m.readData(p.length-5))}return null}},i.exports=f},{"./compressedObject":2,"./compressions":3,"./crc32":4,"./reader/readerFor":22,"./support":30,"./utf8":31,"./utils":32}],35:[function(r,i,o){function s(m,g,y){this.name=m,this.dir=y.dir,this.date=y.date,this.comment=y.comment,this.unixPermissions=y.unixPermissions,this.dosPermissions=y.dosPermissions,this._data=g,this._dataBinary=y.binary,this.options={compression:y.compression,compressionOptions:y.compressionOptions}}var a=r("./stream/StreamHelper"),c=r("./stream/DataWorker"),l=r("./utf8"),u=r("./compressedObject"),d=r("./stream/GenericWorker");s.prototype={internalStream:function(m){var g=null,y="string";try{if(!m)throw new Error("No output type specified.");var _=(y=m.toLowerCase())==="string"||y==="text";y!=="binarystring"&&y!=="text"||(y="string"),g=this._decompressWorker();var x=!this._dataBinary;x&&!_&&(g=g.pipe(new l.Utf8EncodeWorker)),!x&&_&&(g=g.pipe(new l.Utf8DecodeWorker))}catch(b){(g=new d("error")).error(b)}return new a(g,y,"")},async:function(m,g){return this.internalStream(m).accumulate(g)},nodeStream:function(m,g){return this.internalStream(m||"nodebuffer").toNodejsStream(g)},_compressWorker:function(m,g){if(this._data instanceof u&&this._data.compression.magic===m.magic)return this._data.getCompressedWorker();var y=this._decompressWorker();return this._dataBinary||(y=y.pipe(new l.Utf8EncodeWorker)),u.createWorkerFrom(y,m,g)},_decompressWorker:function(){return this._data instanceof u?this._data.getContentWorker():this._data instanceof d?this._data:new c(this._data)}};for(var h=["asText","asBinary","asNodeBuffer","asUint8Array","asArrayBuffer"],f=function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},p=0;p<h.length;p++)s.prototype[h[p]]=f;i.exports=s},{"./compressedObject":2,"./stream/DataWorker":27,"./stream/GenericWorker":28,"./stream/StreamHelper":29,"./utf8":31}],36:[function(r,i,o){(function(s){var a,c,l=s.MutationObserver||s.WebKitMutationObserver;if(l){var u=0,d=new l(m),h=s.document.createTextNode("");d.observe(h,{characterData:!0}),a=function(){h.data=u=++u%2}}else if(s.setImmediate||s.MessageChannel===void 0)a="document"in s&&"onreadystatechange"in s.document.createElement("script")?function(){var g=s.document.createElement("script");g.onreadystatechange=function(){m(),g.onreadystatechange=null,g.parentNode.removeChild(g),g=null},s.document.documentElement.appendChild(g)}:function(){setTimeout(m,0)};else{var f=new s.MessageChannel;f.port1.onmessage=m,a=function(){f.port2.postMessage(0)}}var p=[];function m(){var g,y;c=!0;for(var _=p.length;_;){for(y=p,p=[],g=-1;++g<_;)y[g]();_=p.length}c=!1}i.exports=function(g){p.push(g)!==1||c||a()}}).call(this,typeof SL<"u"?SL:typeof self<"u"?self:typeof window<"u"?window:{})},{}],37:[function(r,i,o){var s=r("immediate");function a(){}var c={},l=["REJECTED"],u=["FULFILLED"],d=["PENDING"];function h(_){if(typeof _!="function")throw new TypeError("resolver must be a function");this.state=d,this.queue=[],this.outcome=void 0,_!==a&&g(this,_)}function f(_,x,b){this.promise=_,typeof x=="function"&&(this.onFulfilled=x,this.callFulfilled=this.otherCallFulfilled),typeof b=="function"&&(this.onRejected=b,this.callRejected=this.otherCallRejected)}function p(_,x,b){s(function(){var w;try{w=x(b)}catch(S){return c.reject(_,S)}w===_?c.reject(_,new TypeError("Cannot resolve promise with itself")):c.resolve(_,w)})}function m(_){var x=_&&_.then;if(_&&(typeof _=="object"||typeof _=="function")&&typeof x=="function")return function(){x.apply(_,arguments)}}function g(_,x){var b=!1;function w(C){b||(b=!0,c.reject(_,C))}function S(C){b||(b=!0,c.resolve(_,C))}var T=y(function(){x(S,w)});T.status==="error"&&w(T.value)}function y(_,x){var b={};try{b.value=_(x),b.status="success"}catch(w){b.status="error",b.value=w}return b}(i.exports=h).prototype.finally=function(_){if(typeof _!="function")return this;var x=this.constructor;return this.then(function(b){return x.resolve(_()).then(function(){return b})},function(b){return x.resolve(_()).then(function(){throw b})})},h.prototype.catch=function(_){return this.then(null,_)},h.prototype.then=function(_,x){if(typeof _!="function"&&this.state===u||typeof x!="function"&&this.state===l)return this;var b=new this.constructor(a);return this.state!==d?p(b,this.state===u?_:x,this.outcome):this.queue.push(new f(b,_,x)),b},f.prototype.callFulfilled=function(_){c.resolve(this.promise,_)},f.prototype.otherCallFulfilled=function(_){p(this.promise,this.onFulfilled,_)},f.prototype.callRejected=function(_){c.reject(this.promise,_)},f.prototype.otherCallRejected=function(_){p(this.promise,this.onRejected,_)},c.resolve=function(_,x){var b=y(m,x);if(b.status==="error")return c.reject(_,b.value);var w=b.value;if(w)g(_,w);else{_.state=u,_.outcome=x;for(var S=-1,T=_.queue.length;++S<T;)_.queue[S].callFulfilled(x)}return _},c.reject=function(_,x){_.state=l,_.outcome=x;for(var b=-1,w=_.queue.length;++b<w;)_.queue[b].callRejected(x);return _},h.resolve=function(_){return _ instanceof this?_:c.resolve(new this(a),_)},h.reject=function(_){var x=new this(a);return c.reject(x,_)},h.all=function(_){var x=this;if(Object.prototype.toString.call(_)!=="[object Array]")return this.reject(new TypeError("must be an array"));var b=_.length,w=!1;if(!b)return this.resolve([]);for(var S=new Array(b),T=0,C=-1,A=new this(a);++C<b;)R(_[C],C);return A;function R(L,O){x.resolve(L).then(function(F){S[O]=F,++T!==b||w||(w=!0,c.resolve(A,S))},function(F){w||(w=!0,c.reject(A,F))})}},h.race=function(_){var x=this;if(Object.prototype.toString.call(_)!=="[object Array]")return this.reject(new TypeError("must be an array"));var b=_.length,w=!1;if(!b)return this.resolve([]);for(var S=-1,T=new this(a);++S<b;)C=_[S],x.resolve(C).then(function(A){w||(w=!0,c.resolve(T,A))},function(A){w||(w=!0,c.reject(T,A))});var C;return T}},{immediate:36}],38:[function(r,i,o){var s={};(0,r("./lib/utils/common").assign)(s,r("./lib/deflate"),r("./lib/inflate"),r("./lib/zlib/constants")),i.exports=s},{"./lib/deflate":39,"./lib/inflate":40,"./lib/utils/common":41,"./lib/zlib/constants":44}],39:[function(r,i,o){var s=r("./zlib/deflate"),a=r("./utils/common"),c=r("./utils/strings"),l=r("./zlib/messages"),u=r("./zlib/zstream"),d=Object.prototype.toString,h=0,f=-1,p=0,m=8;function g(_){if(!(this instanceof g))return new g(_);this.options=a.assign({level:f,method:m,chunkSize:16384,windowBits:15,memLevel:8,strategy:p,to:""},_||{});var x=this.options;x.raw&&0<x.windowBits?x.windowBits=-x.windowBits:x.gzip&&0<x.windowBits&&x.windowBits<16&&(x.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new u,this.strm.avail_out=0;var b=s.deflateInit2(this.strm,x.level,x.method,x.windowBits,x.memLevel,x.strategy);if(b!==h)throw new Error(l[b]);if(x.header&&s.deflateSetHeader(this.strm,x.header),x.dictionary){var w;if(w=typeof x.dictionary=="string"?c.string2buf(x.dictionary):d.call(x.dictionary)==="[object ArrayBuffer]"?new Uint8Array(x.dictionary):x.dictionary,(b=s.deflateSetDictionary(this.strm,w))!==h)throw new Error(l[b]);this._dict_set=!0}}function y(_,x){var b=new g(x);if(b.push(_,!0),b.err)throw b.msg||l[b.err];return b.result}g.prototype.push=function(_,x){var b,w,S=this.strm,T=this.options.chunkSize;if(this.ended)return!1;w=x===~~x?x:x===!0?4:0,typeof _=="string"?S.input=c.string2buf(_):d.call(_)==="[object ArrayBuffer]"?S.input=new Uint8Array(_):S.input=_,S.next_in=0,S.avail_in=S.input.length;do{if(S.avail_out===0&&(S.output=new a.Buf8(T),S.next_out=0,S.avail_out=T),(b=s.deflate(S,w))!==1&&b!==h)return this.onEnd(b),!(this.ended=!0);S.avail_out!==0&&(S.avail_in!==0||w!==4&&w!==2)||(this.options.to==="string"?this.onData(c.buf2binstring(a.shrinkBuf(S.output,S.next_out))):this.onData(a.shrinkBuf(S.output,S.next_out)))}while((0<S.avail_in||S.avail_out===0)&&b!==1);return w===4?(b=s.deflateEnd(this.strm),this.onEnd(b),this.ended=!0,b===h):w!==2||(this.onEnd(h),!(S.avail_out=0))},g.prototype.onData=function(_){this.chunks.push(_)},g.prototype.onEnd=function(_){_===h&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=a.flattenChunks(this.chunks)),this.chunks=[],this.err=_,this.msg=this.strm.msg},o.Deflate=g,o.deflate=y,o.deflateRaw=function(_,x){return(x=x||{}).raw=!0,y(_,x)},o.gzip=function(_,x){return(x=x||{}).gzip=!0,y(_,x)}},{"./utils/common":41,"./utils/strings":42,"./zlib/deflate":46,"./zlib/messages":51,"./zlib/zstream":53}],40:[function(r,i,o){var s=r("./zlib/inflate"),a=r("./utils/common"),c=r("./utils/strings"),l=r("./zlib/constants"),u=r("./zlib/messages"),d=r("./zlib/zstream"),h=r("./zlib/gzheader"),f=Object.prototype.toString;function p(g){if(!(this instanceof p))return new p(g);this.options=a.assign({chunkSize:16384,windowBits:0,to:""},g||{});var y=this.options;y.raw&&0<=y.windowBits&&y.windowBits<16&&(y.windowBits=-y.windowBits,y.windowBits===0&&(y.windowBits=-15)),!(0<=y.windowBits&&y.windowBits<16)||g&&g.windowBits||(y.windowBits+=32),15<y.windowBits&&y.windowBits<48&&(15&y.windowBits)==0&&(y.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new d,this.strm.avail_out=0;var _=s.inflateInit2(this.strm,y.windowBits);if(_!==l.Z_OK)throw new Error(u[_]);this.header=new h,s.inflateGetHeader(this.strm,this.header)}function m(g,y){var _=new p(y);if(_.push(g,!0),_.err)throw _.msg||u[_.err];return _.result}p.prototype.push=function(g,y){var _,x,b,w,S,T,C=this.strm,A=this.options.chunkSize,R=this.options.dictionary,L=!1;if(this.ended)return!1;x=y===~~y?y:y===!0?l.Z_FINISH:l.Z_NO_FLUSH,typeof g=="string"?C.input=c.binstring2buf(g):f.call(g)==="[object ArrayBuffer]"?C.input=new Uint8Array(g):C.input=g,C.next_in=0,C.avail_in=C.input.length;do{if(C.avail_out===0&&(C.output=new a.Buf8(A),C.next_out=0,C.avail_out=A),(_=s.inflate(C,l.Z_NO_FLUSH))===l.Z_NEED_DICT&&R&&(T=typeof R=="string"?c.string2buf(R):f.call(R)==="[object ArrayBuffer]"?new Uint8Array(R):R,_=s.inflateSetDictionary(this.strm,T)),_===l.Z_BUF_ERROR&&L===!0&&(_=l.Z_OK,L=!1),_!==l.Z_STREAM_END&&_!==l.Z_OK)return this.onEnd(_),!(this.ended=!0);C.next_out&&(C.avail_out!==0&&_!==l.Z_STREAM_END&&(C.avail_in!==0||x!==l.Z_FINISH&&x!==l.Z_SYNC_FLUSH)||(this.options.to==="string"?(b=c.utf8border(C.output,C.next_out),w=C.next_out-b,S=c.buf2string(C.output,b),C.next_out=w,C.avail_out=A-w,w&&a.arraySet(C.output,C.output,b,w,0),this.onData(S)):this.onData(a.shrinkBuf(C.output,C.next_out)))),C.avail_in===0&&C.avail_out===0&&(L=!0)}while((0<C.avail_in||C.avail_out===0)&&_!==l.Z_STREAM_END);return _===l.Z_STREAM_END&&(x=l.Z_FINISH),x===l.Z_FINISH?(_=s.inflateEnd(this.strm),this.onEnd(_),this.ended=!0,_===l.Z_OK):x!==l.Z_SYNC_FLUSH||(this.onEnd(l.Z_OK),!(C.avail_out=0))},p.prototype.onData=function(g){this.chunks.push(g)},p.prototype.onEnd=function(g){g===l.Z_OK&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=a.flattenChunks(this.chunks)),this.chunks=[],this.err=g,this.msg=this.strm.msg},o.Inflate=p,o.inflate=m,o.inflateRaw=function(g,y){return(y=y||{}).raw=!0,m(g,y)},o.ungzip=m},{"./utils/common":41,"./utils/strings":42,"./zlib/constants":44,"./zlib/gzheader":47,"./zlib/inflate":49,"./zlib/messages":51,"./zlib/zstream":53}],41:[function(r,i,o){var s=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Int32Array<"u";o.assign=function(l){for(var u=Array.prototype.slice.call(arguments,1);u.length;){var d=u.shift();if(d){if(typeof d!="object")throw new TypeError(d+"must be non-object");for(var h in d)d.hasOwnProperty(h)&&(l[h]=d[h])}}return l},o.shrinkBuf=function(l,u){return l.length===u?l:l.subarray?l.subarray(0,u):(l.length=u,l)};var a={arraySet:function(l,u,d,h,f){if(u.subarray&&l.subarray)l.set(u.subarray(d,d+h),f);else for(var p=0;p<h;p++)l[f+p]=u[d+p]},flattenChunks:function(l){var u,d,h,f,p,m;for(u=h=0,d=l.length;u<d;u++)h+=l[u].length;for(m=new Uint8Array(h),u=f=0,d=l.length;u<d;u++)p=l[u],m.set(p,f),f+=p.length;return m}},c={arraySet:function(l,u,d,h,f){for(var p=0;p<h;p++)l[f+p]=u[d+p]},flattenChunks:function(l){return[].concat.apply([],l)}};o.setTyped=function(l){l?(o.Buf8=Uint8Array,o.Buf16=Uint16Array,o.Buf32=Int32Array,o.assign(o,a)):(o.Buf8=Array,o.Buf16=Array,o.Buf32=Array,o.assign(o,c))},o.setTyped(s)},{}],42:[function(r,i,o){var s=r("./common"),a=!0,c=!0;try{String.fromCharCode.apply(null,[0])}catch{a=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch{c=!1}for(var l=new s.Buf8(256),u=0;u<256;u++)l[u]=252<=u?6:248<=u?5:240<=u?4:224<=u?3:192<=u?2:1;function d(h,f){if(f<65537&&(h.subarray&&c||!h.subarray&&a))return String.fromCharCode.apply(null,s.shrinkBuf(h,f));for(var p="",m=0;m<f;m++)p+=String.fromCharCode(h[m]);return p}l[254]=l[254]=1,o.string2buf=function(h){var f,p,m,g,y,_=h.length,x=0;for(g=0;g<_;g++)(64512&(p=h.charCodeAt(g)))==55296&&g+1<_&&(64512&(m=h.charCodeAt(g+1)))==56320&&(p=65536+(p-55296<<10)+(m-56320),g++),x+=p<128?1:p<2048?2:p<65536?3:4;for(f=new s.Buf8(x),g=y=0;y<x;g++)(64512&(p=h.charCodeAt(g)))==55296&&g+1<_&&(64512&(m=h.charCodeAt(g+1)))==56320&&(p=65536+(p-55296<<10)+(m-56320),g++),p<128?f[y++]=p:(p<2048?f[y++]=192|p>>>6:(p<65536?f[y++]=224|p>>>12:(f[y++]=240|p>>>18,f[y++]=128|p>>>12&63),f[y++]=128|p>>>6&63),f[y++]=128|63&p);return f},o.buf2binstring=function(h){return d(h,h.length)},o.binstring2buf=function(h){for(var f=new s.Buf8(h.length),p=0,m=f.length;p<m;p++)f[p]=h.charCodeAt(p);return f},o.buf2string=function(h,f){var p,m,g,y,_=f||h.length,x=new Array(2*_);for(p=m=0;p<_;)if((g=h[p++])<128)x[m++]=g;else if(4<(y=l[g]))x[m++]=65533,p+=y-1;else{for(g&=y===2?31:y===3?15:7;1<y&&p<_;)g=g<<6|63&h[p++],y--;1<y?x[m++]=65533:g<65536?x[m++]=g:(g-=65536,x[m++]=55296|g>>10&1023,x[m++]=56320|1023&g)}return d(x,m)},o.utf8border=function(h,f){var p;for((f=f||h.length)>h.length&&(f=h.length),p=f-1;0<=p&&(192&h[p])==128;)p--;return p<0||p===0?f:p+l[h[p]]>f?p:f}},{"./common":41}],43:[function(r,i,o){i.exports=function(s,a,c,l){for(var u=65535&s|0,d=s>>>16&65535|0,h=0;c!==0;){for(c-=h=2e3<c?2e3:c;d=d+(u=u+a[l++]|0)|0,--h;);u%=65521,d%=65521}return u|d<<16|0}},{}],44:[function(r,i,o){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(r,i,o){var s=(function(){for(var a,c=[],l=0;l<256;l++){a=l;for(var u=0;u<8;u++)a=1&a?3988292384^a>>>1:a>>>1;c[l]=a}return c})();i.exports=function(a,c,l,u){var d=s,h=u+l;a^=-1;for(var f=u;f<h;f++)a=a>>>8^d[255&(a^c[f])];return-1^a}},{}],46:[function(r,i,o){var s,a=r("../utils/common"),c=r("./trees"),l=r("./adler32"),u=r("./crc32"),d=r("./messages"),h=0,f=4,p=0,m=-2,g=-1,y=4,_=2,x=8,b=9,w=286,S=30,T=19,C=2*w+1,A=15,R=3,L=258,O=L+R+1,F=42,B=113,j=1,V=2,q=3,K=4;function ne(ge,Ke){return ge.msg=d[Ke],Ke}function le(ge){return(ge<<1)-(4<ge?9:0)}function ee(ge){for(var Ke=ge.length;0<=--Ke;)ge[Ke]=0}function ie(ge){var Ke=ge.state,$e=Ke.pending;$e>ge.avail_out&&($e=ge.avail_out),$e!==0&&(a.arraySet(ge.output,Ke.pending_buf,Ke.pending_out,$e,ge.next_out),ge.next_out+=$e,Ke.pending_out+=$e,ge.total_out+=$e,ge.avail_out-=$e,Ke.pending-=$e,Ke.pending===0&&(Ke.pending_out=0))}function ce(ge,Ke){c._tr_flush_block(ge,0<=ge.block_start?ge.block_start:-1,ge.strstart-ge.block_start,Ke),ge.block_start=ge.strstart,ie(ge.strm)}function ue(ge,Ke){ge.pending_buf[ge.pending++]=Ke}function _e(ge,Ke){ge.pending_buf[ge.pending++]=Ke>>>8&255,ge.pending_buf[ge.pending++]=255&Ke}function Ce(ge,Ke){var $e,Ne,Ue=ge.max_chain_length,Ie=ge.strstart,we=ge.prev_length,Ee=ge.nice_match,Te=ge.strstart>ge.w_size-O?ge.strstart-(ge.w_size-O):0,Be=ge.window,Xe=ge.w_mask,et=ge.prev,rt=ge.strstart+L,at=Be[Ie+we-1],lt=Be[Ie+we];ge.prev_length>=ge.good_match&&(Ue>>=2),Ee>ge.lookahead&&(Ee=ge.lookahead);do if(Be[($e=Ke)+we]===lt&&Be[$e+we-1]===at&&Be[$e]===Be[Ie]&&Be[++$e]===Be[Ie+1]){Ie+=2,$e++;do;while(Be[++Ie]===Be[++$e]&&Be[++Ie]===Be[++$e]&&Be[++Ie]===Be[++$e]&&Be[++Ie]===Be[++$e]&&Be[++Ie]===Be[++$e]&&Be[++Ie]===Be[++$e]&&Be[++Ie]===Be[++$e]&&Be[++Ie]===Be[++$e]&&Ie<rt);if(Ne=L-(rt-Ie),Ie=rt-L,we<Ne){if(ge.match_start=Ke,Ee<=(we=Ne))break;at=Be[Ie+we-1],lt=Be[Ie+we]}}while((Ke=et[Ke&Xe])>Te&&--Ue!=0);return we<=ge.lookahead?we:ge.lookahead}function Ae(ge){var Ke,$e,Ne,Ue,Ie,we,Ee,Te,Be,Xe,et=ge.w_size;do{if(Ue=ge.window_size-ge.lookahead-ge.strstart,ge.strstart>=et+(et-O)){for(a.arraySet(ge.window,ge.window,et,et,0),ge.match_start-=et,ge.strstart-=et,ge.block_start-=et,Ke=$e=ge.hash_size;Ne=ge.head[--Ke],ge.head[Ke]=et<=Ne?Ne-et:0,--$e;);for(Ke=$e=et;Ne=ge.prev[--Ke],ge.prev[Ke]=et<=Ne?Ne-et:0,--$e;);Ue+=et}if(ge.strm.avail_in===0)break;if(we=ge.strm,Ee=ge.window,Te=ge.strstart+ge.lookahead,Be=Ue,Xe=void 0,Xe=we.avail_in,Be<Xe&&(Xe=Be),$e=Xe===0?0:(we.avail_in-=Xe,a.arraySet(Ee,we.input,we.next_in,Xe,Te),we.state.wrap===1?we.adler=l(we.adler,Ee,Xe,Te):we.state.wrap===2&&(we.adler=u(we.adler,Ee,Xe,Te)),we.next_in+=Xe,we.total_in+=Xe,Xe),ge.lookahead+=$e,ge.lookahead+ge.insert>=R)for(Ie=ge.strstart-ge.insert,ge.ins_h=ge.window[Ie],ge.ins_h=(ge.ins_h<<ge.hash_shift^ge.window[Ie+1])&ge.hash_mask;ge.insert&&(ge.ins_h=(ge.ins_h<<ge.hash_shift^ge.window[Ie+R-1])&ge.hash_mask,ge.prev[Ie&ge.w_mask]=ge.head[ge.ins_h],ge.head[ge.ins_h]=Ie,Ie++,ge.insert--,!(ge.lookahead+ge.insert<R)););}while(ge.lookahead<O&&ge.strm.avail_in!==0)}function ke(ge,Ke){for(var $e,Ne;;){if(ge.lookahead<O){if(Ae(ge),ge.lookahead<O&&Ke===h)return j;if(ge.lookahead===0)break}if($e=0,ge.lookahead>=R&&(ge.ins_h=(ge.ins_h<<ge.hash_shift^ge.window[ge.strstart+R-1])&ge.hash_mask,$e=ge.prev[ge.strstart&ge.w_mask]=ge.head[ge.ins_h],ge.head[ge.ins_h]=ge.strstart),$e!==0&&ge.strstart-$e<=ge.w_size-O&&(ge.match_length=Ce(ge,$e)),ge.match_length>=R)if(Ne=c._tr_tally(ge,ge.strstart-ge.match_start,ge.match_length-R),ge.lookahead-=ge.match_length,ge.match_length<=ge.max_lazy_match&&ge.lookahead>=R){for(ge.match_length--;ge.strstart++,ge.ins_h=(ge.ins_h<<ge.hash_shift^ge.window[ge.strstart+R-1])&ge.hash_mask,$e=ge.prev[ge.strstart&ge.w_mask]=ge.head[ge.ins_h],ge.head[ge.ins_h]=ge.strstart,--ge.match_length!=0;);ge.strstart++}else ge.strstart+=ge.match_length,ge.match_length=0,ge.ins_h=ge.window[ge.strstart],ge.ins_h=(ge.ins_h<<ge.hash_shift^ge.window[ge.strstart+1])&ge.hash_mask;else Ne=c._tr_tally(ge,0,ge.window[ge.strstart]),ge.lookahead--,ge.strstart++;if(Ne&&(ce(ge,!1),ge.strm.avail_out===0))return j}return ge.insert=ge.strstart<R-1?ge.strstart:R-1,Ke===f?(ce(ge,!0),ge.strm.avail_out===0?q:K):ge.last_lit&&(ce(ge,!1),ge.strm.avail_out===0)?j:V}function ye(ge,Ke){for(var $e,Ne,Ue;;){if(ge.lookahead<O){if(Ae(ge),ge.lookahead<O&&Ke===h)return j;if(ge.lookahead===0)break}if($e=0,ge.lookahead>=R&&(ge.ins_h=(ge.ins_h<<ge.hash_shift^ge.window[ge.strstart+R-1])&ge.hash_mask,$e=ge.prev[ge.strstart&ge.w_mask]=ge.head[ge.ins_h],ge.head[ge.ins_h]=ge.strstart),ge.prev_length=ge.match_length,ge.prev_match=ge.match_start,ge.match_length=R-1,$e!==0&&ge.prev_length<ge.max_lazy_match&&ge.strstart-$e<=ge.w_size-O&&(ge.match_length=Ce(ge,$e),ge.match_length<=5&&(ge.strategy===1||ge.match_length===R&&4096<ge.strstart-ge.match_start)&&(ge.match_length=R-1)),ge.prev_length>=R&&ge.match_length<=ge.prev_length){for(Ue=ge.strstart+ge.lookahead-R,Ne=c._tr_tally(ge,ge.strstart-1-ge.prev_match,ge.prev_length-R),ge.lookahead-=ge.prev_length-1,ge.prev_length-=2;++ge.strstart<=Ue&&(ge.ins_h=(ge.ins_h<<ge.hash_shift^ge.window[ge.strstart+R-1])&ge.hash_mask,$e=ge.prev[ge.strstart&ge.w_mask]=ge.head[ge.ins_h],ge.head[ge.ins_h]=ge.strstart),--ge.prev_length!=0;);if(ge.match_available=0,ge.match_length=R-1,ge.strstart++,Ne&&(ce(ge,!1),ge.strm.avail_out===0))return j}else if(ge.match_available){if((Ne=c._tr_tally(ge,0,ge.window[ge.strstart-1]))&&ce(ge,!1),ge.strstart++,ge.lookahead--,ge.strm.avail_out===0)return j}else ge.match_available=1,ge.strstart++,ge.lookahead--}return ge.match_available&&(Ne=c._tr_tally(ge,0,ge.window[ge.strstart-1]),ge.match_available=0),ge.insert=ge.strstart<R-1?ge.strstart:R-1,Ke===f?(ce(ge,!0),ge.strm.avail_out===0?q:K):ge.last_lit&&(ce(ge,!1),ge.strm.avail_out===0)?j:V}function Me(ge,Ke,$e,Ne,Ue){this.good_length=ge,this.max_lazy=Ke,this.nice_length=$e,this.max_chain=Ne,this.func=Ue}function fe(){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=x,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 a.Buf16(2*C),this.dyn_dtree=new a.Buf16(2*(2*S+1)),this.bl_tree=new a.Buf16(2*(2*T+1)),ee(this.dyn_ltree),ee(this.dyn_dtree),ee(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new a.Buf16(A+1),this.heap=new a.Buf16(2*w+1),ee(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new a.Buf16(2*w+1),ee(this.depth),this.l_buf=0,this.lit_bufsize=0,this.last_lit=0,this.d_buf=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}function Ye(ge){var Ke;return ge&&ge.state?(ge.total_in=ge.total_out=0,ge.data_type=_,(Ke=ge.state).pending=0,Ke.pending_out=0,Ke.wrap<0&&(Ke.wrap=-Ke.wrap),Ke.status=Ke.wrap?F:B,ge.adler=Ke.wrap===2?0:1,Ke.last_flush=h,c._tr_init(Ke),p):ne(ge,m)}function He(ge){var Ke=Ye(ge);return Ke===p&&(function($e){$e.window_size=2*$e.w_size,ee($e.head),$e.max_lazy_match=s[$e.level].max_lazy,$e.good_match=s[$e.level].good_length,$e.nice_match=s[$e.level].nice_length,$e.max_chain_length=s[$e.level].max_chain,$e.strstart=0,$e.block_start=0,$e.lookahead=0,$e.insert=0,$e.match_length=$e.prev_length=R-1,$e.match_available=0,$e.ins_h=0})(ge.state),Ke}function We(ge,Ke,$e,Ne,Ue,Ie){if(!ge)return m;var we=1;if(Ke===g&&(Ke=6),Ne<0?(we=0,Ne=-Ne):15<Ne&&(we=2,Ne-=16),Ue<1||b<Ue||$e!==x||Ne<8||15<Ne||Ke<0||9<Ke||Ie<0||y<Ie)return ne(ge,m);Ne===8&&(Ne=9);var Ee=new fe;return(ge.state=Ee).strm=ge,Ee.wrap=we,Ee.gzhead=null,Ee.w_bits=Ne,Ee.w_size=1<<Ee.w_bits,Ee.w_mask=Ee.w_size-1,Ee.hash_bits=Ue+7,Ee.hash_size=1<<Ee.hash_bits,Ee.hash_mask=Ee.hash_size-1,Ee.hash_shift=~~((Ee.hash_bits+R-1)/R),Ee.window=new a.Buf8(2*Ee.w_size),Ee.head=new a.Buf16(Ee.hash_size),Ee.prev=new a.Buf16(Ee.w_size),Ee.lit_bufsize=1<<Ue+6,Ee.pending_buf_size=4*Ee.lit_bufsize,Ee.pending_buf=new a.Buf8(Ee.pending_buf_size),Ee.d_buf=1*Ee.lit_bufsize,Ee.l_buf=3*Ee.lit_bufsize,Ee.level=Ke,Ee.strategy=Ie,Ee.method=$e,He(ge)}s=[new Me(0,0,0,0,function(ge,Ke){var $e=65535;for($e>ge.pending_buf_size-5&&($e=ge.pending_buf_size-5);;){if(ge.lookahead<=1){if(Ae(ge),ge.lookahead===0&&Ke===h)return j;if(ge.lookahead===0)break}ge.strstart+=ge.lookahead,ge.lookahead=0;var Ne=ge.block_start+$e;if((ge.strstart===0||ge.strstart>=Ne)&&(ge.lookahead=ge.strstart-Ne,ge.strstart=Ne,ce(ge,!1),ge.strm.avail_out===0)||ge.strstart-ge.block_start>=ge.w_size-O&&(ce(ge,!1),ge.strm.avail_out===0))return j}return ge.insert=0,Ke===f?(ce(ge,!0),ge.strm.avail_out===0?q:K):(ge.strstart>ge.block_start&&(ce(ge,!1),ge.strm.avail_out),j)}),new Me(4,4,8,4,ke),new Me(4,5,16,8,ke),new Me(4,6,32,32,ke),new Me(4,4,16,16,ye),new Me(8,16,32,32,ye),new Me(8,16,128,128,ye),new Me(8,32,128,256,ye),new Me(32,128,258,1024,ye),new Me(32,258,258,4096,ye)],o.deflateInit=function(ge,Ke){return We(ge,Ke,x,15,8,0)},o.deflateInit2=We,o.deflateReset=He,o.deflateResetKeep=Ye,o.deflateSetHeader=function(ge,Ke){return ge&&ge.state?ge.state.wrap!==2?m:(ge.state.gzhead=Ke,p):m},o.deflate=function(ge,Ke){var $e,Ne,Ue,Ie;if(!ge||!ge.state||5<Ke||Ke<0)return ge?ne(ge,m):m;if(Ne=ge.state,!ge.output||!ge.input&&ge.avail_in!==0||Ne.status===666&&Ke!==f)return ne(ge,ge.avail_out===0?-5:m);if(Ne.strm=ge,$e=Ne.last_flush,Ne.last_flush=Ke,Ne.status===F)if(Ne.wrap===2)ge.adler=0,ue(Ne,31),ue(Ne,139),ue(Ne,8),Ne.gzhead?(ue(Ne,(Ne.gzhead.text?1:0)+(Ne.gzhead.hcrc?2:0)+(Ne.gzhead.extra?4:0)+(Ne.gzhead.name?8:0)+(Ne.gzhead.comment?16:0)),ue(Ne,255&Ne.gzhead.time),ue(Ne,Ne.gzhead.time>>8&255),ue(Ne,Ne.gzhead.time>>16&255),ue(Ne,Ne.gzhead.time>>24&255),ue(Ne,Ne.level===9?2:2<=Ne.strategy||Ne.level<2?4:0),ue(Ne,255&Ne.gzhead.os),Ne.gzhead.extra&&Ne.gzhead.extra.length&&(ue(Ne,255&Ne.gzhead.extra.length),ue(Ne,Ne.gzhead.extra.length>>8&255)),Ne.gzhead.hcrc&&(ge.adler=u(ge.adler,Ne.pending_buf,Ne.pending,0)),Ne.gzindex=0,Ne.status=69):(ue(Ne,0),ue(Ne,0),ue(Ne,0),ue(Ne,0),ue(Ne,0),ue(Ne,Ne.level===9?2:2<=Ne.strategy||Ne.level<2?4:0),ue(Ne,3),Ne.status=B);else{var we=x+(Ne.w_bits-8<<4)<<8;we|=(2<=Ne.strategy||Ne.level<2?0:Ne.level<6?1:Ne.level===6?2:3)<<6,Ne.strstart!==0&&(we|=32),we+=31-we%31,Ne.status=B,_e(Ne,we),Ne.strstart!==0&&(_e(Ne,ge.adler>>>16),_e(Ne,65535&ge.adler)),ge.adler=1}if(Ne.status===69)if(Ne.gzhead.extra){for(Ue=Ne.pending;Ne.gzindex<(65535&Ne.gzhead.extra.length)&&(Ne.pending!==Ne.pending_buf_size||(Ne.gzhead.hcrc&&Ne.pending>Ue&&(ge.adler=u(ge.adler,Ne.pending_buf,Ne.pending-Ue,Ue)),ie(ge),Ue=Ne.pending,Ne.pending!==Ne.pending_buf_size));)ue(Ne,255&Ne.gzhead.extra[Ne.gzindex]),Ne.gzindex++;Ne.gzhead.hcrc&&Ne.pending>Ue&&(ge.adler=u(ge.adler,Ne.pending_buf,Ne.pending-Ue,Ue)),Ne.gzindex===Ne.gzhead.extra.length&&(Ne.gzindex=0,Ne.status=73)}else Ne.status=73;if(Ne.status===73)if(Ne.gzhead.name){Ue=Ne.pending;do{if(Ne.pending===Ne.pending_buf_size&&(Ne.gzhead.hcrc&&Ne.pending>Ue&&(ge.adler=u(ge.adler,Ne.pending_buf,Ne.pending-Ue,Ue)),ie(ge),Ue=Ne.pending,Ne.pending===Ne.pending_buf_size)){Ie=1;break}Ie=Ne.gzindex<Ne.gzhead.name.length?255&Ne.gzhead.name.charCodeAt(Ne.gzindex++):0,ue(Ne,Ie)}while(Ie!==0);Ne.gzhead.hcrc&&Ne.pending>Ue&&(ge.adler=u(ge.adler,Ne.pending_buf,Ne.pending-Ue,Ue)),Ie===0&&(Ne.gzindex=0,Ne.status=91)}else Ne.status=91;if(Ne.status===91)if(Ne.gzhead.comment){Ue=Ne.pending;do{if(Ne.pending===Ne.pending_buf_size&&(Ne.gzhead.hcrc&&Ne.pending>Ue&&(ge.adler=u(ge.adler,Ne.pending_buf,Ne.pending-Ue,Ue)),ie(ge),Ue=Ne.pending,Ne.pending===Ne.pending_buf_size)){Ie=1;break}Ie=Ne.gzindex<Ne.gzhead.comment.length?255&Ne.gzhead.comment.charCodeAt(Ne.gzindex++):0,ue(Ne,Ie)}while(Ie!==0);Ne.gzhead.hcrc&&Ne.pending>Ue&&(ge.adler=u(ge.adler,Ne.pending_buf,Ne.pending-Ue,Ue)),Ie===0&&(Ne.status=103)}else Ne.status=103;if(Ne.status===103&&(Ne.gzhead.hcrc?(Ne.pending+2>Ne.pending_buf_size&&ie(ge),Ne.pending+2<=Ne.pending_buf_size&&(ue(Ne,255&ge.adler),ue(Ne,ge.adler>>8&255),ge.adler=0,Ne.status=B)):Ne.status=B),Ne.pending!==0){if(ie(ge),ge.avail_out===0)return Ne.last_flush=-1,p}else if(ge.avail_in===0&&le(Ke)<=le($e)&&Ke!==f)return ne(ge,-5);if(Ne.status===666&&ge.avail_in!==0)return ne(ge,-5);if(ge.avail_in!==0||Ne.lookahead!==0||Ke!==h&&Ne.status!==666){var Ee=Ne.strategy===2?(function(Te,Be){for(var Xe;;){if(Te.lookahead===0&&(Ae(Te),Te.lookahead===0)){if(Be===h)return j;break}if(Te.match_length=0,Xe=c._tr_tally(Te,0,Te.window[Te.strstart]),Te.lookahead--,Te.strstart++,Xe&&(ce(Te,!1),Te.strm.avail_out===0))return j}return Te.insert=0,Be===f?(ce(Te,!0),Te.strm.avail_out===0?q:K):Te.last_lit&&(ce(Te,!1),Te.strm.avail_out===0)?j:V})(Ne,Ke):Ne.strategy===3?(function(Te,Be){for(var Xe,et,rt,at,lt=Te.window;;){if(Te.lookahead<=L){if(Ae(Te),Te.lookahead<=L&&Be===h)return j;if(Te.lookahead===0)break}if(Te.match_length=0,Te.lookahead>=R&&0<Te.strstart&&(et=lt[rt=Te.strstart-1])===lt[++rt]&&et===lt[++rt]&&et===lt[++rt]){at=Te.strstart+L;do;while(et===lt[++rt]&&et===lt[++rt]&&et===lt[++rt]&&et===lt[++rt]&&et===lt[++rt]&&et===lt[++rt]&&et===lt[++rt]&&et===lt[++rt]&&rt<at);Te.match_length=L-(at-rt),Te.match_length>Te.lookahead&&(Te.match_length=Te.lookahead)}if(Te.match_length>=R?(Xe=c._tr_tally(Te,1,Te.match_length-R),Te.lookahead-=Te.match_length,Te.strstart+=Te.match_length,Te.match_length=0):(Xe=c._tr_tally(Te,0,Te.window[Te.strstart]),Te.lookahead--,Te.strstart++),Xe&&(ce(Te,!1),Te.strm.avail_out===0))return j}return Te.insert=0,Be===f?(ce(Te,!0),Te.strm.avail_out===0?q:K):Te.last_lit&&(ce(Te,!1),Te.strm.avail_out===0)?j:V})(Ne,Ke):s[Ne.level].func(Ne,Ke);if(Ee!==q&&Ee!==K||(Ne.status=666),Ee===j||Ee===q)return ge.avail_out===0&&(Ne.last_flush=-1),p;if(Ee===V&&(Ke===1?c._tr_align(Ne):Ke!==5&&(c._tr_stored_block(Ne,0,0,!1),Ke===3&&(ee(Ne.head),Ne.lookahead===0&&(Ne.strstart=0,Ne.block_start=0,Ne.insert=0))),ie(ge),ge.avail_out===0))return Ne.last_flush=-1,p}return Ke!==f?p:Ne.wrap<=0?1:(Ne.wrap===2?(ue(Ne,255&ge.adler),ue(Ne,ge.adler>>8&255),ue(Ne,ge.adler>>16&255),ue(Ne,ge.adler>>24&255),ue(Ne,255&ge.total_in),ue(Ne,ge.total_in>>8&255),ue(Ne,ge.total_in>>16&255),ue(Ne,ge.total_in>>24&255)):(_e(Ne,ge.adler>>>16),_e(Ne,65535&ge.adler)),ie(ge),0<Ne.wrap&&(Ne.wrap=-Ne.wrap),Ne.pending!==0?p:1)},o.deflateEnd=function(ge){var Ke;return ge&&ge.state?(Ke=ge.state.status)!==F&&Ke!==69&&Ke!==73&&Ke!==91&&Ke!==103&&Ke!==B&&Ke!==666?ne(ge,m):(ge.state=null,Ke===B?ne(ge,-3):p):m},o.deflateSetDictionary=function(ge,Ke){var $e,Ne,Ue,Ie,we,Ee,Te,Be,Xe=Ke.length;if(!ge||!ge.state||(Ie=($e=ge.state).wrap)===2||Ie===1&&$e.status!==F||$e.lookahead)return m;for(Ie===1&&(ge.adler=l(ge.adler,Ke,Xe,0)),$e.wrap=0,Xe>=$e.w_size&&(Ie===0&&(ee($e.head),$e.strstart=0,$e.block_start=0,$e.insert=0),Be=new a.Buf8($e.w_size),a.arraySet(Be,Ke,Xe-$e.w_size,$e.w_size,0),Ke=Be,Xe=$e.w_size),we=ge.avail_in,Ee=ge.next_in,Te=ge.input,ge.avail_in=Xe,ge.next_in=0,ge.input=Ke,Ae($e);$e.lookahead>=R;){for(Ne=$e.strstart,Ue=$e.lookahead-(R-1);$e.ins_h=($e.ins_h<<$e.hash_shift^$e.window[Ne+R-1])&$e.hash_mask,$e.prev[Ne&$e.w_mask]=$e.head[$e.ins_h],$e.head[$e.ins_h]=Ne,Ne++,--Ue;);$e.strstart=Ne,$e.lookahead=R-1,Ae($e)}return $e.strstart+=$e.lookahead,$e.block_start=$e.strstart,$e.insert=$e.lookahead,$e.lookahead=0,$e.match_length=$e.prev_length=R-1,$e.match_available=0,ge.next_in=Ee,ge.input=Te,ge.avail_in=we,$e.wrap=Ie,p},o.deflateInfo="pako deflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./messages":51,"./trees":52}],47:[function(r,i,o){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(r,i,o){i.exports=function(s,a){var c,l,u,d,h,f,p,m,g,y,_,x,b,w,S,T,C,A,R,L,O,F,B,j,V;c=s.state,l=s.next_in,j=s.input,u=l+(s.avail_in-5),d=s.next_out,V=s.output,h=d-(a-s.avail_out),f=d+(s.avail_out-257),p=c.dmax,m=c.wsize,g=c.whave,y=c.wnext,_=c.window,x=c.hold,b=c.bits,w=c.lencode,S=c.distcode,T=(1<<c.lenbits)-1,C=(1<<c.distbits)-1;e:do{b<15&&(x+=j[l++]<<b,b+=8,x+=j[l++]<<b,b+=8),A=w[x&T];t:for(;;){if(x>>>=R=A>>>24,b-=R,(R=A>>>16&255)===0)V[d++]=65535&A;else{if(!(16&R)){if((64&R)==0){A=w[(65535&A)+(x&(1<<R)-1)];continue t}if(32&R){c.mode=12;break e}s.msg="invalid literal/length code",c.mode=30;break e}L=65535&A,(R&=15)&&(b<R&&(x+=j[l++]<<b,b+=8),L+=x&(1<<R)-1,x>>>=R,b-=R),b<15&&(x+=j[l++]<<b,b+=8,x+=j[l++]<<b,b+=8),A=S[x&C];n:for(;;){if(x>>>=R=A>>>24,b-=R,!(16&(R=A>>>16&255))){if((64&R)==0){A=S[(65535&A)+(x&(1<<R)-1)];continue n}s.msg="invalid distance code",c.mode=30;break e}if(O=65535&A,b<(R&=15)&&(x+=j[l++]<<b,(b+=8)<R&&(x+=j[l++]<<b,b+=8)),p<(O+=x&(1<<R)-1)){s.msg="invalid distance too far back",c.mode=30;break e}if(x>>>=R,b-=R,(R=d-h)<O){if(g<(R=O-R)&&c.sane){s.msg="invalid distance too far back",c.mode=30;break e}if(B=_,(F=0)===y){if(F+=m-R,R<L){for(L-=R;V[d++]=_[F++],--R;);F=d-O,B=V}}else if(y<R){if(F+=m+y-R,(R-=y)<L){for(L-=R;V[d++]=_[F++],--R;);if(F=0,y<L){for(L-=R=y;V[d++]=_[F++],--R;);F=d-O,B=V}}}else if(F+=y-R,R<L){for(L-=R;V[d++]=_[F++],--R;);F=d-O,B=V}for(;2<L;)V[d++]=B[F++],V[d++]=B[F++],V[d++]=B[F++],L-=3;L&&(V[d++]=B[F++],1<L&&(V[d++]=B[F++]))}else{for(F=d-O;V[d++]=V[F++],V[d++]=V[F++],V[d++]=V[F++],2<(L-=3););L&&(V[d++]=V[F++],1<L&&(V[d++]=V[F++]))}break}}break}}while(l<u&&d<f);l-=L=b>>3,x&=(1<<(b-=L<<3))-1,s.next_in=l,s.next_out=d,s.avail_in=l<u?u-l+5:5-(l-u),s.avail_out=d<f?f-d+257:257-(d-f),c.hold=x,c.bits=b}},{}],49:[function(r,i,o){var s=r("../utils/common"),a=r("./adler32"),c=r("./crc32"),l=r("./inffast"),u=r("./inftrees"),d=1,h=2,f=0,p=-2,m=1,g=852,y=592;function _(F){return(F>>>24&255)+(F>>>8&65280)+((65280&F)<<8)+((255&F)<<24)}function x(){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 s.Buf16(320),this.work=new s.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function b(F){var B;return F&&F.state?(B=F.state,F.total_in=F.total_out=B.total=0,F.msg="",B.wrap&&(F.adler=1&B.wrap),B.mode=m,B.last=0,B.havedict=0,B.dmax=32768,B.head=null,B.hold=0,B.bits=0,B.lencode=B.lendyn=new s.Buf32(g),B.distcode=B.distdyn=new s.Buf32(y),B.sane=1,B.back=-1,f):p}function w(F){var B;return F&&F.state?((B=F.state).wsize=0,B.whave=0,B.wnext=0,b(F)):p}function S(F,B){var j,V;return F&&F.state?(V=F.state,B<0?(j=0,B=-B):(j=1+(B>>4),B<48&&(B&=15)),B&&(B<8||15<B)?p:(V.window!==null&&V.wbits!==B&&(V.window=null),V.wrap=j,V.wbits=B,w(F))):p}function T(F,B){var j,V;return F?(V=new x,(F.state=V).window=null,(j=S(F,B))!==f&&(F.state=null),j):p}var C,A,R=!0;function L(F){if(R){var B;for(C=new s.Buf32(512),A=new s.Buf32(32),B=0;B<144;)F.lens[B++]=8;for(;B<256;)F.lens[B++]=9;for(;B<280;)F.lens[B++]=7;for(;B<288;)F.lens[B++]=8;for(u(d,F.lens,0,288,C,0,F.work,{bits:9}),B=0;B<32;)F.lens[B++]=5;u(h,F.lens,0,32,A,0,F.work,{bits:5}),R=!1}F.lencode=C,F.lenbits=9,F.distcode=A,F.distbits=5}function O(F,B,j,V){var q,K=F.state;return K.window===null&&(K.wsize=1<<K.wbits,K.wnext=0,K.whave=0,K.window=new s.Buf8(K.wsize)),V>=K.wsize?(s.arraySet(K.window,B,j-K.wsize,K.wsize,0),K.wnext=0,K.whave=K.wsize):(V<(q=K.wsize-K.wnext)&&(q=V),s.arraySet(K.window,B,j-V,q,K.wnext),(V-=q)?(s.arraySet(K.window,B,j-V,V,0),K.wnext=V,K.whave=K.wsize):(K.wnext+=q,K.wnext===K.wsize&&(K.wnext=0),K.whave<K.wsize&&(K.whave+=q))),0}o.inflateReset=w,o.inflateReset2=S,o.inflateResetKeep=b,o.inflateInit=function(F){return T(F,15)},o.inflateInit2=T,o.inflate=function(F,B){var j,V,q,K,ne,le,ee,ie,ce,ue,_e,Ce,Ae,ke,ye,Me,fe,Ye,He,We,ge,Ke,$e,Ne,Ue=0,Ie=new s.Buf8(4),we=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!F||!F.state||!F.output||!F.input&&F.avail_in!==0)return p;(j=F.state).mode===12&&(j.mode=13),ne=F.next_out,q=F.output,ee=F.avail_out,K=F.next_in,V=F.input,le=F.avail_in,ie=j.hold,ce=j.bits,ue=le,_e=ee,Ke=f;e:for(;;)switch(j.mode){case m:if(j.wrap===0){j.mode=13;break}for(;ce<16;){if(le===0)break e;le--,ie+=V[K++]<<ce,ce+=8}if(2&j.wrap&&ie===35615){Ie[j.check=0]=255&ie,Ie[1]=ie>>>8&255,j.check=c(j.check,Ie,2,0),ce=ie=0,j.mode=2;break}if(j.flags=0,j.head&&(j.head.done=!1),!(1&j.wrap)||(((255&ie)<<8)+(ie>>8))%31){F.msg="incorrect header check",j.mode=30;break}if((15&ie)!=8){F.msg="unknown compression method",j.mode=30;break}if(ce-=4,ge=8+(15&(ie>>>=4)),j.wbits===0)j.wbits=ge;else if(ge>j.wbits){F.msg="invalid window size",j.mode=30;break}j.dmax=1<<ge,F.adler=j.check=1,j.mode=512&ie?10:12,ce=ie=0;break;case 2:for(;ce<16;){if(le===0)break e;le--,ie+=V[K++]<<ce,ce+=8}if(j.flags=ie,(255&j.flags)!=8){F.msg="unknown compression method",j.mode=30;break}if(57344&j.flags){F.msg="unknown header flags set",j.mode=30;break}j.head&&(j.head.text=ie>>8&1),512&j.flags&&(Ie[0]=255&ie,Ie[1]=ie>>>8&255,j.check=c(j.check,Ie,2,0)),ce=ie=0,j.mode=3;case 3:for(;ce<32;){if(le===0)break e;le--,ie+=V[K++]<<ce,ce+=8}j.head&&(j.head.time=ie),512&j.flags&&(Ie[0]=255&ie,Ie[1]=ie>>>8&255,Ie[2]=ie>>>16&255,Ie[3]=ie>>>24&255,j.check=c(j.check,Ie,4,0)),ce=ie=0,j.mode=4;case 4:for(;ce<16;){if(le===0)break e;le--,ie+=V[K++]<<ce,ce+=8}j.head&&(j.head.xflags=255&ie,j.head.os=ie>>8),512&j.flags&&(Ie[0]=255&ie,Ie[1]=ie>>>8&255,j.check=c(j.check,Ie,2,0)),ce=ie=0,j.mode=5;case 5:if(1024&j.flags){for(;ce<16;){if(le===0)break e;le--,ie+=V[K++]<<ce,ce+=8}j.length=ie,j.head&&(j.head.extra_len=ie),512&j.flags&&(Ie[0]=255&ie,Ie[1]=ie>>>8&255,j.check=c(j.check,Ie,2,0)),ce=ie=0}else j.head&&(j.head.extra=null);j.mode=6;case 6:if(1024&j.flags&&(le<(Ce=j.length)&&(Ce=le),Ce&&(j.head&&(ge=j.head.extra_len-j.length,j.head.extra||(j.head.extra=new Array(j.head.extra_len)),s.arraySet(j.head.extra,V,K,Ce,ge)),512&j.flags&&(j.check=c(j.check,V,Ce,K)),le-=Ce,K+=Ce,j.length-=Ce),j.length))break e;j.length=0,j.mode=7;case 7:if(2048&j.flags){if(le===0)break e;for(Ce=0;ge=V[K+Ce++],j.head&&ge&&j.length<65536&&(j.head.name+=String.fromCharCode(ge)),ge&&Ce<le;);if(512&j.flags&&(j.check=c(j.check,V,Ce,K)),le-=Ce,K+=Ce,ge)break e}else j.head&&(j.head.name=null);j.length=0,j.mode=8;case 8:if(4096&j.flags){if(le===0)break e;for(Ce=0;ge=V[K+Ce++],j.head&&ge&&j.length<65536&&(j.head.comment+=String.fromCharCode(ge)),ge&&Ce<le;);if(512&j.flags&&(j.check=c(j.check,V,Ce,K)),le-=Ce,K+=Ce,ge)break e}else j.head&&(j.head.comment=null);j.mode=9;case 9:if(512&j.flags){for(;ce<16;){if(le===0)break e;le--,ie+=V[K++]<<ce,ce+=8}if(ie!==(65535&j.check)){F.msg="header crc mismatch",j.mode=30;break}ce=ie=0}j.head&&(j.head.hcrc=j.flags>>9&1,j.head.done=!0),F.adler=j.check=0,j.mode=12;break;case 10:for(;ce<32;){if(le===0)break e;le--,ie+=V[K++]<<ce,ce+=8}F.adler=j.check=_(ie),ce=ie=0,j.mode=11;case 11:if(j.havedict===0)return F.next_out=ne,F.avail_out=ee,F.next_in=K,F.avail_in=le,j.hold=ie,j.bits=ce,2;F.adler=j.check=1,j.mode=12;case 12:if(B===5||B===6)break e;case 13:if(j.last){ie>>>=7&ce,ce-=7&ce,j.mode=27;break}for(;ce<3;){if(le===0)break e;le--,ie+=V[K++]<<ce,ce+=8}switch(j.last=1&ie,ce-=1,3&(ie>>>=1)){case 0:j.mode=14;break;case 1:if(L(j),j.mode=20,B!==6)break;ie>>>=2,ce-=2;break e;case 2:j.mode=17;break;case 3:F.msg="invalid block type",j.mode=30}ie>>>=2,ce-=2;break;case 14:for(ie>>>=7&ce,ce-=7&ce;ce<32;){if(le===0)break e;le--,ie+=V[K++]<<ce,ce+=8}if((65535&ie)!=(ie>>>16^65535)){F.msg="invalid stored block lengths",j.mode=30;break}if(j.length=65535&ie,ce=ie=0,j.mode=15,B===6)break e;case 15:j.mode=16;case 16:if(Ce=j.length){if(le<Ce&&(Ce=le),ee<Ce&&(Ce=ee),Ce===0)break e;s.arraySet(q,V,K,Ce,ne),le-=Ce,K+=Ce,ee-=Ce,ne+=Ce,j.length-=Ce;break}j.mode=12;break;case 17:for(;ce<14;){if(le===0)break e;le--,ie+=V[K++]<<ce,ce+=8}if(j.nlen=257+(31&ie),ie>>>=5,ce-=5,j.ndist=1+(31&ie),ie>>>=5,ce-=5,j.ncode=4+(15&ie),ie>>>=4,ce-=4,286<j.nlen||30<j.ndist){F.msg="too many length or distance symbols",j.mode=30;break}j.have=0,j.mode=18;case 18:for(;j.have<j.ncode;){for(;ce<3;){if(le===0)break e;le--,ie+=V[K++]<<ce,ce+=8}j.lens[we[j.have++]]=7&ie,ie>>>=3,ce-=3}for(;j.have<19;)j.lens[we[j.have++]]=0;if(j.lencode=j.lendyn,j.lenbits=7,$e={bits:j.lenbits},Ke=u(0,j.lens,0,19,j.lencode,0,j.work,$e),j.lenbits=$e.bits,Ke){F.msg="invalid code lengths set",j.mode=30;break}j.have=0,j.mode=19;case 19:for(;j.have<j.nlen+j.ndist;){for(;Me=(Ue=j.lencode[ie&(1<<j.lenbits)-1])>>>16&255,fe=65535&Ue,!((ye=Ue>>>24)<=ce);){if(le===0)break e;le--,ie+=V[K++]<<ce,ce+=8}if(fe<16)ie>>>=ye,ce-=ye,j.lens[j.have++]=fe;else{if(fe===16){for(Ne=ye+2;ce<Ne;){if(le===0)break e;le--,ie+=V[K++]<<ce,ce+=8}if(ie>>>=ye,ce-=ye,j.have===0){F.msg="invalid bit length repeat",j.mode=30;break}ge=j.lens[j.have-1],Ce=3+(3&ie),ie>>>=2,ce-=2}else if(fe===17){for(Ne=ye+3;ce<Ne;){if(le===0)break e;le--,ie+=V[K++]<<ce,ce+=8}ce-=ye,ge=0,Ce=3+(7&(ie>>>=ye)),ie>>>=3,ce-=3}else{for(Ne=ye+7;ce<Ne;){if(le===0)break e;le--,ie+=V[K++]<<ce,ce+=8}ce-=ye,ge=0,Ce=11+(127&(ie>>>=ye)),ie>>>=7,ce-=7}if(j.have+Ce>j.nlen+j.ndist){F.msg="invalid bit length repeat",j.mode=30;break}for(;Ce--;)j.lens[j.have++]=ge}}if(j.mode===30)break;if(j.lens[256]===0){F.msg="invalid code -- missing end-of-block",j.mode=30;break}if(j.lenbits=9,$e={bits:j.lenbits},Ke=u(d,j.lens,0,j.nlen,j.lencode,0,j.work,$e),j.lenbits=$e.bits,Ke){F.msg="invalid literal/lengths set",j.mode=30;break}if(j.distbits=6,j.distcode=j.distdyn,$e={bits:j.distbits},Ke=u(h,j.lens,j.nlen,j.ndist,j.distcode,0,j.work,$e),j.distbits=$e.bits,Ke){F.msg="invalid distances set",j.mode=30;break}if(j.mode=20,B===6)break e;case 20:j.mode=21;case 21:if(6<=le&&258<=ee){F.next_out=ne,F.avail_out=ee,F.next_in=K,F.avail_in=le,j.hold=ie,j.bits=ce,l(F,_e),ne=F.next_out,q=F.output,ee=F.avail_out,K=F.next_in,V=F.input,le=F.avail_in,ie=j.hold,ce=j.bits,j.mode===12&&(j.back=-1);break}for(j.back=0;Me=(Ue=j.lencode[ie&(1<<j.lenbits)-1])>>>16&255,fe=65535&Ue,!((ye=Ue>>>24)<=ce);){if(le===0)break e;le--,ie+=V[K++]<<ce,ce+=8}if(Me&&(240&Me)==0){for(Ye=ye,He=Me,We=fe;Me=(Ue=j.lencode[We+((ie&(1<<Ye+He)-1)>>Ye)])>>>16&255,fe=65535&Ue,!(Ye+(ye=Ue>>>24)<=ce);){if(le===0)break e;le--,ie+=V[K++]<<ce,ce+=8}ie>>>=Ye,ce-=Ye,j.back+=Ye}if(ie>>>=ye,ce-=ye,j.back+=ye,j.length=fe,Me===0){j.mode=26;break}if(32&Me){j.back=-1,j.mode=12;break}if(64&Me){F.msg="invalid literal/length code",j.mode=30;break}j.extra=15&Me,j.mode=22;case 22:if(j.extra){for(Ne=j.extra;ce<Ne;){if(le===0)break e;le--,ie+=V[K++]<<ce,ce+=8}j.length+=ie&(1<<j.extra)-1,ie>>>=j.extra,ce-=j.extra,j.back+=j.extra}j.was=j.length,j.mode=23;case 23:for(;Me=(Ue=j.distcode[ie&(1<<j.distbits)-1])>>>16&255,fe=65535&Ue,!((ye=Ue>>>24)<=ce);){if(le===0)break e;le--,ie+=V[K++]<<ce,ce+=8}if((240&Me)==0){for(Ye=ye,He=Me,We=fe;Me=(Ue=j.distcode[We+((ie&(1<<Ye+He)-1)>>Ye)])>>>16&255,fe=65535&Ue,!(Ye+(ye=Ue>>>24)<=ce);){if(le===0)break e;le--,ie+=V[K++]<<ce,ce+=8}ie>>>=Ye,ce-=Ye,j.back+=Ye}if(ie>>>=ye,ce-=ye,j.back+=ye,64&Me){F.msg="invalid distance code",j.mode=30;break}j.offset=fe,j.extra=15&Me,j.mode=24;case 24:if(j.extra){for(Ne=j.extra;ce<Ne;){if(le===0)break e;le--,ie+=V[K++]<<ce,ce+=8}j.offset+=ie&(1<<j.extra)-1,ie>>>=j.extra,ce-=j.extra,j.back+=j.extra}if(j.offset>j.dmax){F.msg="invalid distance too far back",j.mode=30;break}j.mode=25;case 25:if(ee===0)break e;if(Ce=_e-ee,j.offset>Ce){if((Ce=j.offset-Ce)>j.whave&&j.sane){F.msg="invalid distance too far back",j.mode=30;break}Ae=Ce>j.wnext?(Ce-=j.wnext,j.wsize-Ce):j.wnext-Ce,Ce>j.length&&(Ce=j.length),ke=j.window}else ke=q,Ae=ne-j.offset,Ce=j.length;for(ee<Ce&&(Ce=ee),ee-=Ce,j.length-=Ce;q[ne++]=ke[Ae++],--Ce;);j.length===0&&(j.mode=21);break;case 26:if(ee===0)break e;q[ne++]=j.length,ee--,j.mode=21;break;case 27:if(j.wrap){for(;ce<32;){if(le===0)break e;le--,ie|=V[K++]<<ce,ce+=8}if(_e-=ee,F.total_out+=_e,j.total+=_e,_e&&(F.adler=j.check=j.flags?c(j.check,q,_e,ne-_e):a(j.check,q,_e,ne-_e)),_e=ee,(j.flags?ie:_(ie))!==j.check){F.msg="incorrect data check",j.mode=30;break}ce=ie=0}j.mode=28;case 28:if(j.wrap&&j.flags){for(;ce<32;){if(le===0)break e;le--,ie+=V[K++]<<ce,ce+=8}if(ie!==(4294967295&j.total)){F.msg="incorrect length check",j.mode=30;break}ce=ie=0}j.mode=29;case 29:Ke=1;break e;case 30:Ke=-3;break e;case 31:return-4;default:return p}return F.next_out=ne,F.avail_out=ee,F.next_in=K,F.avail_in=le,j.hold=ie,j.bits=ce,(j.wsize||_e!==F.avail_out&&j.mode<30&&(j.mode<27||B!==4))&&O(F,F.output,F.next_out,_e-F.avail_out)?(j.mode=31,-4):(ue-=F.avail_in,_e-=F.avail_out,F.total_in+=ue,F.total_out+=_e,j.total+=_e,j.wrap&&_e&&(F.adler=j.check=j.flags?c(j.check,q,_e,F.next_out-_e):a(j.check,q,_e,F.next_out-_e)),F.data_type=j.bits+(j.last?64:0)+(j.mode===12?128:0)+(j.mode===20||j.mode===15?256:0),(ue==0&&_e===0||B===4)&&Ke===f&&(Ke=-5),Ke)},o.inflateEnd=function(F){if(!F||!F.state)return p;var B=F.state;return B.window&&(B.window=null),F.state=null,f},o.inflateGetHeader=function(F,B){var j;return F&&F.state?(2&(j=F.state).wrap)==0?p:((j.head=B).done=!1,f):p},o.inflateSetDictionary=function(F,B){var j,V=B.length;return F&&F.state?(j=F.state).wrap!==0&&j.mode!==11?p:j.mode===11&&a(1,B,V,0)!==j.check?-3:O(F,B,V,V)?(j.mode=31,-4):(j.havedict=1,f):p},o.inflateInfo="pako inflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./inffast":48,"./inftrees":50}],50:[function(r,i,o){var s=r("../utils/common"),a=[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],c=[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],l=[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],u=[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(d,h,f,p,m,g,y,_){var x,b,w,S,T,C,A,R,L,O=_.bits,F=0,B=0,j=0,V=0,q=0,K=0,ne=0,le=0,ee=0,ie=0,ce=null,ue=0,_e=new s.Buf16(16),Ce=new s.Buf16(16),Ae=null,ke=0;for(F=0;F<=15;F++)_e[F]=0;for(B=0;B<p;B++)_e[h[f+B]]++;for(q=O,V=15;1<=V&&_e[V]===0;V--);if(V<q&&(q=V),V===0)return m[g++]=20971520,m[g++]=20971520,_.bits=1,0;for(j=1;j<V&&_e[j]===0;j++);for(q<j&&(q=j),F=le=1;F<=15;F++)if(le<<=1,(le-=_e[F])<0)return-1;if(0<le&&(d===0||V!==1))return-1;for(Ce[1]=0,F=1;F<15;F++)Ce[F+1]=Ce[F]+_e[F];for(B=0;B<p;B++)h[f+B]!==0&&(y[Ce[h[f+B]]++]=B);if(C=d===0?(ce=Ae=y,19):d===1?(ce=a,ue-=257,Ae=c,ke-=257,256):(ce=l,Ae=u,-1),F=j,T=g,ne=B=ie=0,w=-1,S=(ee=1<<(K=q))-1,d===1&&852<ee||d===2&&592<ee)return 1;for(;;){for(A=F-ne,L=y[B]<C?(R=0,y[B]):y[B]>C?(R=Ae[ke+y[B]],ce[ue+y[B]]):(R=96,0),x=1<<F-ne,j=b=1<<K;m[T+(ie>>ne)+(b-=x)]=A<<24|R<<16|L|0,b!==0;);for(x=1<<F-1;ie&x;)x>>=1;if(x!==0?(ie&=x-1,ie+=x):ie=0,B++,--_e[F]==0){if(F===V)break;F=h[f+y[B]]}if(q<F&&(ie&S)!==w){for(ne===0&&(ne=q),T+=j,le=1<<(K=F-ne);K+ne<V&&!((le-=_e[K+ne])<=0);)K++,le<<=1;if(ee+=1<<K,d===1&&852<ee||d===2&&592<ee)return 1;m[w=ie&S]=q<<24|K<<16|T-g|0}}return ie!==0&&(m[T+ie]=F-ne<<24|64<<16|0),_.bits=q,0}},{"../utils/common":41}],51:[function(r,i,o){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(r,i,o){var s=r("../utils/common"),a=0,c=1;function l(Ue){for(var Ie=Ue.length;0<=--Ie;)Ue[Ie]=0}var u=0,d=29,h=256,f=h+1+d,p=30,m=19,g=2*f+1,y=15,_=16,x=7,b=256,w=16,S=17,T=18,C=[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],A=[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],R=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],L=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],O=new Array(2*(f+2));l(O);var F=new Array(2*p);l(F);var B=new Array(512);l(B);var j=new Array(256);l(j);var V=new Array(d);l(V);var q,K,ne,le=new Array(p);function ee(Ue,Ie,we,Ee,Te){this.static_tree=Ue,this.extra_bits=Ie,this.extra_base=we,this.elems=Ee,this.max_length=Te,this.has_stree=Ue&&Ue.length}function ie(Ue,Ie){this.dyn_tree=Ue,this.max_code=0,this.stat_desc=Ie}function ce(Ue){return Ue<256?B[Ue]:B[256+(Ue>>>7)]}function ue(Ue,Ie){Ue.pending_buf[Ue.pending++]=255&Ie,Ue.pending_buf[Ue.pending++]=Ie>>>8&255}function _e(Ue,Ie,we){Ue.bi_valid>_-we?(Ue.bi_buf|=Ie<<Ue.bi_valid&65535,ue(Ue,Ue.bi_buf),Ue.bi_buf=Ie>>_-Ue.bi_valid,Ue.bi_valid+=we-_):(Ue.bi_buf|=Ie<<Ue.bi_valid&65535,Ue.bi_valid+=we)}function Ce(Ue,Ie,we){_e(Ue,we[2*Ie],we[2*Ie+1])}function Ae(Ue,Ie){for(var we=0;we|=1&Ue,Ue>>>=1,we<<=1,0<--Ie;);return we>>>1}function ke(Ue,Ie,we){var Ee,Te,Be=new Array(y+1),Xe=0;for(Ee=1;Ee<=y;Ee++)Be[Ee]=Xe=Xe+we[Ee-1]<<1;for(Te=0;Te<=Ie;Te++){var et=Ue[2*Te+1];et!==0&&(Ue[2*Te]=Ae(Be[et]++,et))}}function ye(Ue){var Ie;for(Ie=0;Ie<f;Ie++)Ue.dyn_ltree[2*Ie]=0;for(Ie=0;Ie<p;Ie++)Ue.dyn_dtree[2*Ie]=0;for(Ie=0;Ie<m;Ie++)Ue.bl_tree[2*Ie]=0;Ue.dyn_ltree[2*b]=1,Ue.opt_len=Ue.static_len=0,Ue.last_lit=Ue.matches=0}function Me(Ue){8<Ue.bi_valid?ue(Ue,Ue.bi_buf):0<Ue.bi_valid&&(Ue.pending_buf[Ue.pending++]=Ue.bi_buf),Ue.bi_buf=0,Ue.bi_valid=0}function fe(Ue,Ie,we,Ee){var Te=2*Ie,Be=2*we;return Ue[Te]<Ue[Be]||Ue[Te]===Ue[Be]&&Ee[Ie]<=Ee[we]}function Ye(Ue,Ie,we){for(var Ee=Ue.heap[we],Te=we<<1;Te<=Ue.heap_len&&(Te<Ue.heap_len&&fe(Ie,Ue.heap[Te+1],Ue.heap[Te],Ue.depth)&&Te++,!fe(Ie,Ee,Ue.heap[Te],Ue.depth));)Ue.heap[we]=Ue.heap[Te],we=Te,Te<<=1;Ue.heap[we]=Ee}function He(Ue,Ie,we){var Ee,Te,Be,Xe,et=0;if(Ue.last_lit!==0)for(;Ee=Ue.pending_buf[Ue.d_buf+2*et]<<8|Ue.pending_buf[Ue.d_buf+2*et+1],Te=Ue.pending_buf[Ue.l_buf+et],et++,Ee===0?Ce(Ue,Te,Ie):(Ce(Ue,(Be=j[Te])+h+1,Ie),(Xe=C[Be])!==0&&_e(Ue,Te-=V[Be],Xe),Ce(Ue,Be=ce(--Ee),we),(Xe=A[Be])!==0&&_e(Ue,Ee-=le[Be],Xe)),et<Ue.last_lit;);Ce(Ue,b,Ie)}function We(Ue,Ie){var we,Ee,Te,Be=Ie.dyn_tree,Xe=Ie.stat_desc.static_tree,et=Ie.stat_desc.has_stree,rt=Ie.stat_desc.elems,at=-1;for(Ue.heap_len=0,Ue.heap_max=g,we=0;we<rt;we++)Be[2*we]!==0?(Ue.heap[++Ue.heap_len]=at=we,Ue.depth[we]=0):Be[2*we+1]=0;for(;Ue.heap_len<2;)Be[2*(Te=Ue.heap[++Ue.heap_len]=at<2?++at:0)]=1,Ue.depth[Te]=0,Ue.opt_len--,et&&(Ue.static_len-=Xe[2*Te+1]);for(Ie.max_code=at,we=Ue.heap_len>>1;1<=we;we--)Ye(Ue,Be,we);for(Te=rt;we=Ue.heap[1],Ue.heap[1]=Ue.heap[Ue.heap_len--],Ye(Ue,Be,1),Ee=Ue.heap[1],Ue.heap[--Ue.heap_max]=we,Ue.heap[--Ue.heap_max]=Ee,Be[2*Te]=Be[2*we]+Be[2*Ee],Ue.depth[Te]=(Ue.depth[we]>=Ue.depth[Ee]?Ue.depth[we]:Ue.depth[Ee])+1,Be[2*we+1]=Be[2*Ee+1]=Te,Ue.heap[1]=Te++,Ye(Ue,Be,1),2<=Ue.heap_len;);Ue.heap[--Ue.heap_max]=Ue.heap[1],(function(lt,gt){var Mt,Dt,Ut,zt,At,Ht,Mn=gt.dyn_tree,me=gt.max_code,tt=gt.stat_desc.static_tree,ct=gt.stat_desc.has_stree,_t=gt.stat_desc.extra_bits,Nt=gt.stat_desc.extra_base,Ft=gt.stat_desc.max_length,nn=0;for(zt=0;zt<=y;zt++)lt.bl_count[zt]=0;for(Mn[2*lt.heap[lt.heap_max]+1]=0,Mt=lt.heap_max+1;Mt<g;Mt++)Ft<(zt=Mn[2*Mn[2*(Dt=lt.heap[Mt])+1]+1]+1)&&(zt=Ft,nn++),Mn[2*Dt+1]=zt,me<Dt||(lt.bl_count[zt]++,At=0,Nt<=Dt&&(At=_t[Dt-Nt]),Ht=Mn[2*Dt],lt.opt_len+=Ht*(zt+At),ct&&(lt.static_len+=Ht*(tt[2*Dt+1]+At)));if(nn!==0){do{for(zt=Ft-1;lt.bl_count[zt]===0;)zt--;lt.bl_count[zt]--,lt.bl_count[zt+1]+=2,lt.bl_count[Ft]--,nn-=2}while(0<nn);for(zt=Ft;zt!==0;zt--)for(Dt=lt.bl_count[zt];Dt!==0;)me<(Ut=lt.heap[--Mt])||(Mn[2*Ut+1]!==zt&&(lt.opt_len+=(zt-Mn[2*Ut+1])*Mn[2*Ut],Mn[2*Ut+1]=zt),Dt--)}})(Ue,Ie),ke(Be,at,Ue.bl_count)}function ge(Ue,Ie,we){var Ee,Te,Be=-1,Xe=Ie[1],et=0,rt=7,at=4;for(Xe===0&&(rt=138,at=3),Ie[2*(we+1)+1]=65535,Ee=0;Ee<=we;Ee++)Te=Xe,Xe=Ie[2*(Ee+1)+1],++et<rt&&Te===Xe||(et<at?Ue.bl_tree[2*Te]+=et:Te!==0?(Te!==Be&&Ue.bl_tree[2*Te]++,Ue.bl_tree[2*w]++):et<=10?Ue.bl_tree[2*S]++:Ue.bl_tree[2*T]++,Be=Te,at=(et=0)===Xe?(rt=138,3):Te===Xe?(rt=6,3):(rt=7,4))}function Ke(Ue,Ie,we){var Ee,Te,Be=-1,Xe=Ie[1],et=0,rt=7,at=4;for(Xe===0&&(rt=138,at=3),Ee=0;Ee<=we;Ee++)if(Te=Xe,Xe=Ie[2*(Ee+1)+1],!(++et<rt&&Te===Xe)){if(et<at)for(;Ce(Ue,Te,Ue.bl_tree),--et!=0;);else Te!==0?(Te!==Be&&(Ce(Ue,Te,Ue.bl_tree),et--),Ce(Ue,w,Ue.bl_tree),_e(Ue,et-3,2)):et<=10?(Ce(Ue,S,Ue.bl_tree),_e(Ue,et-3,3)):(Ce(Ue,T,Ue.bl_tree),_e(Ue,et-11,7));Be=Te,at=(et=0)===Xe?(rt=138,3):Te===Xe?(rt=6,3):(rt=7,4)}}l(le);var $e=!1;function Ne(Ue,Ie,we,Ee){_e(Ue,(u<<1)+(Ee?1:0),3),(function(Te,Be,Xe,et){Me(Te),ue(Te,Xe),ue(Te,~Xe),s.arraySet(Te.pending_buf,Te.window,Be,Xe,Te.pending),Te.pending+=Xe})(Ue,Ie,we)}o._tr_init=function(Ue){$e||((function(){var Ie,we,Ee,Te,Be,Xe=new Array(y+1);for(Te=Ee=0;Te<d-1;Te++)for(V[Te]=Ee,Ie=0;Ie<1<<C[Te];Ie++)j[Ee++]=Te;for(j[Ee-1]=Te,Te=Be=0;Te<16;Te++)for(le[Te]=Be,Ie=0;Ie<1<<A[Te];Ie++)B[Be++]=Te;for(Be>>=7;Te<p;Te++)for(le[Te]=Be<<7,Ie=0;Ie<1<<A[Te]-7;Ie++)B[256+Be++]=Te;for(we=0;we<=y;we++)Xe[we]=0;for(Ie=0;Ie<=143;)O[2*Ie+1]=8,Ie++,Xe[8]++;for(;Ie<=255;)O[2*Ie+1]=9,Ie++,Xe[9]++;for(;Ie<=279;)O[2*Ie+1]=7,Ie++,Xe[7]++;for(;Ie<=287;)O[2*Ie+1]=8,Ie++,Xe[8]++;for(ke(O,f+1,Xe),Ie=0;Ie<p;Ie++)F[2*Ie+1]=5,F[2*Ie]=Ae(Ie,5);q=new ee(O,C,h+1,f,y),K=new ee(F,A,0,p,y),ne=new ee(new Array(0),R,0,m,x)})(),$e=!0),Ue.l_desc=new ie(Ue.dyn_ltree,q),Ue.d_desc=new ie(Ue.dyn_dtree,K),Ue.bl_desc=new ie(Ue.bl_tree,ne),Ue.bi_buf=0,Ue.bi_valid=0,ye(Ue)},o._tr_stored_block=Ne,o._tr_flush_block=function(Ue,Ie,we,Ee){var Te,Be,Xe=0;0<Ue.level?(Ue.strm.data_type===2&&(Ue.strm.data_type=(function(et){var rt,at=4093624447;for(rt=0;rt<=31;rt++,at>>>=1)if(1&at&&et.dyn_ltree[2*rt]!==0)return a;if(et.dyn_ltree[18]!==0||et.dyn_ltree[20]!==0||et.dyn_ltree[26]!==0)return c;for(rt=32;rt<h;rt++)if(et.dyn_ltree[2*rt]!==0)return c;return a})(Ue)),We(Ue,Ue.l_desc),We(Ue,Ue.d_desc),Xe=(function(et){var rt;for(ge(et,et.dyn_ltree,et.l_desc.max_code),ge(et,et.dyn_dtree,et.d_desc.max_code),We(et,et.bl_desc),rt=m-1;3<=rt&&et.bl_tree[2*L[rt]+1]===0;rt--);return et.opt_len+=3*(rt+1)+5+5+4,rt})(Ue),Te=Ue.opt_len+3+7>>>3,(Be=Ue.static_len+3+7>>>3)<=Te&&(Te=Be)):Te=Be=we+5,we+4<=Te&&Ie!==-1?Ne(Ue,Ie,we,Ee):Ue.strategy===4||Be===Te?(_e(Ue,2+(Ee?1:0),3),He(Ue,O,F)):(_e(Ue,4+(Ee?1:0),3),(function(et,rt,at,lt){var gt;for(_e(et,rt-257,5),_e(et,at-1,5),_e(et,lt-4,4),gt=0;gt<lt;gt++)_e(et,et.bl_tree[2*L[gt]+1],3);Ke(et,et.dyn_ltree,rt-1),Ke(et,et.dyn_dtree,at-1)})(Ue,Ue.l_desc.max_code+1,Ue.d_desc.max_code+1,Xe+1),He(Ue,Ue.dyn_ltree,Ue.dyn_dtree)),ye(Ue),Ee&&Me(Ue)},o._tr_tally=function(Ue,Ie,we){return Ue.pending_buf[Ue.d_buf+2*Ue.last_lit]=Ie>>>8&255,Ue.pending_buf[Ue.d_buf+2*Ue.last_lit+1]=255&Ie,Ue.pending_buf[Ue.l_buf+Ue.last_lit]=255&we,Ue.last_lit++,Ie===0?Ue.dyn_ltree[2*we]++:(Ue.matches++,Ie--,Ue.dyn_ltree[2*(j[we]+h+1)]++,Ue.dyn_dtree[2*ce(Ie)]++),Ue.last_lit===Ue.lit_bufsize-1},o._tr_align=function(Ue){_e(Ue,2,3),Ce(Ue,b,O),(function(Ie){Ie.bi_valid===16?(ue(Ie,Ie.bi_buf),Ie.bi_buf=0,Ie.bi_valid=0):8<=Ie.bi_valid&&(Ie.pending_buf[Ie.pending++]=255&Ie.bi_buf,Ie.bi_buf>>=8,Ie.bi_valid-=8)})(Ue)}},{"../utils/common":41}],53:[function(r,i,o){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(r,i,o){(function(s){(function(a,c){if(!a.setImmediate){var l,u,d,h,f=1,p={},m=!1,g=a.document,y=Object.getPrototypeOf&&Object.getPrototypeOf(a);y=y&&y.setTimeout?y:a,l={}.toString.call(a.process)==="[object process]"?function(w){n.nextTick(function(){x(w)})}:(function(){if(a.postMessage&&!a.importScripts){var w=!0,S=a.onmessage;return a.onmessage=function(){w=!1},a.postMessage("","*"),a.onmessage=S,w}})()?(h="setImmediate$"+Math.random()+"$",a.addEventListener?a.addEventListener("message",b,!1):a.attachEvent("onmessage",b),function(w){a.postMessage(h+w,"*")}):a.MessageChannel?((d=new MessageChannel).port1.onmessage=function(w){x(w.data)},function(w){d.port2.postMessage(w)}):g&&"onreadystatechange"in g.createElement("script")?(u=g.documentElement,function(w){var S=g.createElement("script");S.onreadystatechange=function(){x(w),S.onreadystatechange=null,u.removeChild(S),S=null},u.appendChild(S)}):function(w){setTimeout(x,0,w)},y.setImmediate=function(w){typeof w!="function"&&(w=new Function(""+w));for(var S=new Array(arguments.length-1),T=0;T<S.length;T++)S[T]=arguments[T+1];var C={callback:w,args:S};return p[f]=C,l(f),f++},y.clearImmediate=_}function _(w){delete p[w]}function x(w){if(m)setTimeout(x,0,w);else{var S=p[w];if(S){m=!0;try{(function(T){var C=T.callback,A=T.args;switch(A.length){case 0:C();break;case 1:C(A[0]);break;case 2:C(A[0],A[1]);break;case 3:C(A[0],A[1],A[2]);break;default:C.apply(c,A)}})(S)}finally{_(w),m=!1}}}}function b(w){w.source===a&&typeof w.data=="string"&&w.data.indexOf(h)===0&&x(+w.data.slice(h.length))}})(typeof self>"u"?s===void 0?this:s:self)}).call(this,typeof SL<"u"?SL:typeof self<"u"?self:typeof window<"u"?window:{})},{}]},{},[10])(10)})})(P2e)),P2e.exports}var kGn=NGn();const A2e=Ax(kGn);var OGn=["circuit-json-to-bom-csv","circuit-json-to-bpc","circuit-json-to-connectivity-map","circuit-json-to-gerber","circuit-json-to-gltf","circuit-json-to-kicad","circuit-json-to-lbrn","circuit-json-to-pnp-csv","circuit-json-to-readable-netlist","circuit-json-to-simple-3d","circuit-json-to-spice","circuit-json-to-step","circuit-json-to-tscircuit","circuit-to-canvas","circuit-to-svg"],LGn=new Set(OGn),DGn=t=>{const e=t.indexOf("@");return e===-1?t:t.slice(0,e)},zGn=t=>{const e=DGn(t);if(!LGn.has(e))throw new Error(`Unsupported module: ${t}`);return`https://esm.run/${t}`};async function $Gn(t){return import(zGn(t))}var LS=$Gn,RO={},R2e={},Idt;function FGn(){return Idt||(Idt=1,(function(t){Object.defineProperty(t,"__esModule",{value:!0});var e=(function(){function o(s,a){var c=[],l=!0,u=!1,d=void 0;try{for(var h=s[Symbol.iterator](),f;!(l=(f=h.next()).done)&&(c.push(f.value),!(a&&c.length===a));l=!0);}catch(p){u=!0,d=p}finally{try{!l&&h.return&&h.return()}finally{if(u)throw d}}return c}return function(s,a){if(Array.isArray(s))return s;if(Symbol.iterator in Object(s))return o(s,a);throw new TypeError("Invalid attempt to destructure non-iterable instance")}})();t.default=r,t.parseUnitObj=i;var n=/-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/;function r(o){var s=parseFloat(o),a=o.match(n)||[],c=a.length>0?o.substr(a[0].length).trim():"";return[s,c]}function i(o){var s=r(o),a=e(s,2),c=a[0],l=a[1];return{val:c,unit:l}}})(R2e)),R2e}var Ndt;function BGn(){if(Ndt)return RO;Ndt=1,Object.defineProperty(RO,"__esModule",{value:!0});var t=(function(){function c(l,u){var d=[],h=!0,f=!1,p=void 0;try{for(var m=l[Symbol.iterator](),g;!(h=(g=m.next()).done)&&(d.push(g.value),!(u&&d.length===u));h=!0);}catch(y){f=!0,p=y}finally{try{!h&&m.return&&m.return()}finally{if(f)throw p}}return d}return function(l,u){if(Array.isArray(l))return l;if(Symbol.iterator in Object(l))return c(l,u);throw new TypeError("Invalid attempt to destructure non-iterable instance")}})();RO.formatSI=o,RO.unformatSI=a;function e(c){return c&&c.__esModule?c:{default:c}}var n=FGn(),r=e(n),i={24:"Y",21:"Z",18:"E",15:"P",12:"T",9:"G",6:"M",3:"k",0:"","-3":"m","-6":"µ","-9":"n","-12":"p","-15":"f","-18":"a","-21":"z","-24":"y"};function o(c){if(c===0)return"0";for(var l=Math.abs(c),u=0;l>=1e3&&u<24;)l/=1e3,u+=3;for(;l<1&&u>-24;)l*=1e3,u-=3;var d=c<0?"-":"";return l>1e3?d+l.toFixed(0)+i[u]:d+parseFloat(l.toPrecision(3))+i[u]}var s={Y:1e24,Z:1e21,E:1e18,P:1e15,T:1e12,G:1e9,M:1e6,k:1e3,"":1,m:.001,µ:1e-6,u:1e-6,n:1e-9,p:1e-12,f:1e-15,a:1e-18,z:1e-21,y:1e-24};function a(c){if(c==null||c==="")return NaN;var l=(0,r.default)(c),u=t(l,2),d=u[0],h=u[1],f=s[h];return d*f}return RO}var jGn=BGn(),EG={exports:{}};var UGn=EG.exports,kdt;function HGn(){return kdt||(kdt=1,(function(t,e){((n,r)=>{t.exports=r()})(UGn,function n(){var r=typeof self<"u"?self:typeof window<"u"?window:r!==void 0?r:{},i,o=!r.document&&!!r.postMessage,s=r.IS_PAPA_WORKER||!1,a={},c=0,l={};function u(C){this._handle=null,this._finished=!1,this._completed=!1,this._halted=!1,this._input=null,this._baseIndex=0,this._partialLine="",this._rowCount=0,this._start=0,this._nextChunk=null,this.isFirstChunk=!0,this._completeResults={data:[],errors:[],meta:{}},(function(A){var R=w(A);R.chunkSize=parseInt(R.chunkSize),A.step||A.chunk||(R.chunkSize=null),this._handle=new m(R),(this._handle.streamer=this)._config=R}).call(this,C),this.parseChunk=function(A,R){var L=parseInt(this._config.skipFirstNLines)||0;if(this.isFirstChunk&&0<L){let F=this._config.newline;F||(O=this._config.quoteChar||'"',F=this._handle.guessLineEndings(A,O)),A=[...A.split(F).slice(L)].join(F)}this.isFirstChunk&&T(this._config.beforeFirstChunk)&&(O=this._config.beforeFirstChunk(A))!==void 0&&(A=O),this.isFirstChunk=!1,this._halted=!1;var L=this._partialLine+A,O=(this._partialLine="",this._handle.parse(L,this._baseIndex,!this._finished));if(!this._handle.paused()&&!this._handle.aborted()){if(A=O.meta.cursor,L=(this._finished||(this._partialLine=L.substring(A-this._baseIndex),this._baseIndex=A),O&&O.data&&(this._rowCount+=O.data.length),this._finished||this._config.preview&&this._rowCount>=this._config.preview),s)r.postMessage({results:O,workerId:l.WORKER_ID,finished:L});else if(T(this._config.chunk)&&!R){if(this._config.chunk(O,this._handle),this._handle.paused()||this._handle.aborted())return void(this._halted=!0);this._completeResults=O=void 0}return this._config.step||this._config.chunk||(this._completeResults.data=this._completeResults.data.concat(O.data),this._completeResults.errors=this._completeResults.errors.concat(O.errors),this._completeResults.meta=O.meta),this._completed||!L||!T(this._config.complete)||O&&O.meta.aborted||(this._config.complete(this._completeResults,this._input),this._completed=!0),L||O&&O.meta.paused||this._nextChunk(),O}this._halted=!0},this._sendError=function(A){T(this._config.error)?this._config.error(A):s&&this._config.error&&r.postMessage({workerId:l.WORKER_ID,error:A,finished:!1})}}function d(C){var A;(C=C||{}).chunkSize||(C.chunkSize=l.RemoteChunkSize),u.call(this,C),this._nextChunk=o?function(){this._readChunk(),this._chunkLoaded()}:function(){this._readChunk()},this.stream=function(R){this._input=R,this._nextChunk()},this._readChunk=function(){if(this._finished)this._chunkLoaded();else{if(A=new XMLHttpRequest,this._config.withCredentials&&(A.withCredentials=this._config.withCredentials),o||(A.onload=S(this._chunkLoaded,this),A.onerror=S(this._chunkError,this)),A.open(this._config.downloadRequestBody?"POST":"GET",this._input,!o),this._config.downloadRequestHeaders){var R,L=this._config.downloadRequestHeaders;for(R in L)A.setRequestHeader(R,L[R])}var O;this._config.chunkSize&&(O=this._start+this._config.chunkSize-1,A.setRequestHeader("Range","bytes="+this._start+"-"+O));try{A.send(this._config.downloadRequestBody)}catch(F){this._chunkError(F.message)}o&&A.status===0&&this._chunkError()}},this._chunkLoaded=function(){A.readyState===4&&(A.status<200||400<=A.status?this._chunkError():(this._start+=this._config.chunkSize||A.responseText.length,this._finished=!this._config.chunkSize||this._start>=(R=>(R=R.getResponseHeader("Content-Range"))!==null?parseInt(R.substring(R.lastIndexOf("/")+1)):-1)(A),this.parseChunk(A.responseText)))},this._chunkError=function(R){R=A.statusText||R,this._sendError(new Error(R))}}function h(C){(C=C||{}).chunkSize||(C.chunkSize=l.LocalChunkSize),u.call(this,C);var A,R,L=typeof FileReader<"u";this.stream=function(O){this._input=O,R=O.slice||O.webkitSlice||O.mozSlice,L?((A=new FileReader).onload=S(this._chunkLoaded,this),A.onerror=S(this._chunkError,this)):A=new FileReaderSync,this._nextChunk()},this._nextChunk=function(){this._finished||this._config.preview&&!(this._rowCount<this._config.preview)||this._readChunk()},this._readChunk=function(){var O=this._input,F=(this._config.chunkSize&&(F=Math.min(this._start+this._config.chunkSize,this._input.size),O=R.call(O,this._start,F)),A.readAsText(O,this._config.encoding));L||this._chunkLoaded({target:{result:F}})},this._chunkLoaded=function(O){this._start+=this._config.chunkSize,this._finished=!this._config.chunkSize||this._start>=this._input.size,this.parseChunk(O.target.result)},this._chunkError=function(){this._sendError(A.error)}}function f(C){var A;u.call(this,C=C||{}),this.stream=function(R){return A=R,this._nextChunk()},this._nextChunk=function(){var R,L;if(!this._finished)return R=this._config.chunkSize,A=R?(L=A.substring(0,R),A.substring(R)):(L=A,""),this._finished=!A,this.parseChunk(L)}}function p(C){u.call(this,C=C||{});var A=[],R=!0,L=!1;this.pause=function(){u.prototype.pause.apply(this,arguments),this._input.pause()},this.resume=function(){u.prototype.resume.apply(this,arguments),this._input.resume()},this.stream=function(O){this._input=O,this._input.on("data",this._streamData),this._input.on("end",this._streamEnd),this._input.on("error",this._streamError)},this._checkIsFinished=function(){L&&A.length===1&&(this._finished=!0)},this._nextChunk=function(){this._checkIsFinished(),A.length?this.parseChunk(A.shift()):R=!0},this._streamData=S(function(O){try{A.push(typeof O=="string"?O:O.toString(this._config.encoding)),R&&(R=!1,this._checkIsFinished(),this.parseChunk(A.shift()))}catch(F){this._streamError(F)}},this),this._streamError=S(function(O){this._streamCleanUp(),this._sendError(O)},this),this._streamEnd=S(function(){this._streamCleanUp(),L=!0,this._streamData("")},this),this._streamCleanUp=S(function(){this._input.removeListener("data",this._streamData),this._input.removeListener("end",this._streamEnd),this._input.removeListener("error",this._streamError)},this)}function m(C){var A,R,L,O,F=Math.pow(2,53),B=-F,j=/^\s*-?(\d+\.?|\.\d+|\d+\.\d+)([eE][-+]?\d+)?\s*$/,V=/^((\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d\.\d+([+-][0-2]\d:[0-5]\d|Z))|(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d([+-][0-2]\d:[0-5]\d|Z))|(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d([+-][0-2]\d:[0-5]\d|Z)))$/,q=this,K=0,ne=0,le=!1,ee=!1,ie=[],ce={data:[],errors:[],meta:{}};function ue(ke){return C.skipEmptyLines==="greedy"?ke.join("").trim()==="":ke.length===1&&ke[0].length===0}function _e(){if(ce&&L&&(Ae("Delimiter","UndetectableDelimiter","Unable to auto-detect delimiting character; defaulted to '"+l.DefaultDelimiter+"'"),L=!1),C.skipEmptyLines&&(ce.data=ce.data.filter(function(fe){return!ue(fe)})),Ce()){let fe=function(Ye,He){T(C.transformHeader)&&(Ye=C.transformHeader(Ye,He)),ie.push(Ye)};if(ce)if(Array.isArray(ce.data[0])){for(var ke=0;Ce()&&ke<ce.data.length;ke++)ce.data[ke].forEach(fe);ce.data.splice(0,1)}else ce.data.forEach(fe)}function ye(fe,Ye){for(var He=C.header?{}:[],We=0;We<fe.length;We++){var ge=We,Ke=fe[We],Ke=(($e,Ne)=>(Ue=>(C.dynamicTypingFunction&&C.dynamicTyping[Ue]===void 0&&(C.dynamicTyping[Ue]=C.dynamicTypingFunction(Ue)),(C.dynamicTyping[Ue]||C.dynamicTyping)===!0))($e)?Ne==="true"||Ne==="TRUE"||Ne!=="false"&&Ne!=="FALSE"&&((Ue=>{if(j.test(Ue)&&(Ue=parseFloat(Ue),B<Ue&&Ue<F))return 1})(Ne)?parseFloat(Ne):V.test(Ne)?new Date(Ne):Ne===""?null:Ne):Ne)(ge=C.header?We>=ie.length?"__parsed_extra":ie[We]:ge,Ke=C.transform?C.transform(Ke,ge):Ke);ge==="__parsed_extra"?(He[ge]=He[ge]||[],He[ge].push(Ke)):He[ge]=Ke}return C.header&&(We>ie.length?Ae("FieldMismatch","TooManyFields","Too many fields: expected "+ie.length+" fields but parsed "+We,ne+Ye):We<ie.length&&Ae("FieldMismatch","TooFewFields","Too few fields: expected "+ie.length+" fields but parsed "+We,ne+Ye)),He}var Me;ce&&(C.header||C.dynamicTyping||C.transform)&&(Me=1,!ce.data.length||Array.isArray(ce.data[0])?(ce.data=ce.data.map(ye),Me=ce.data.length):ce.data=ye(ce.data,0),C.header&&ce.meta&&(ce.meta.fields=ie),ne+=Me)}function Ce(){return C.header&&ie.length===0}function Ae(ke,ye,Me,fe){ke={type:ke,code:ye,message:Me},fe!==void 0&&(ke.row=fe),ce.errors.push(ke)}T(C.step)&&(O=C.step,C.step=function(ke){ce=ke,Ce()?_e():(_e(),ce.data.length!==0&&(K+=ke.data.length,C.preview&&K>C.preview?R.abort():(ce.data=ce.data[0],O(ce,q))))}),this.parse=function(ke,ye,Me){var fe=C.quoteChar||'"',fe=(C.newline||(C.newline=this.guessLineEndings(ke,fe)),L=!1,C.delimiter?T(C.delimiter)&&(C.delimiter=C.delimiter(ke),ce.meta.delimiter=C.delimiter):((fe=((Ye,He,We,ge,Ke)=>{var $e,Ne,Ue,Ie;Ke=Ke||[","," ","|",";",l.RECORD_SEP,l.UNIT_SEP];for(var we=0;we<Ke.length;we++){for(var Ee,Te=Ke[we],Be=0,Xe=0,et=0,rt=(Ue=void 0,new y({comments:ge,delimiter:Te,newline:He,preview:10}).parse(Ye)),at=0;at<rt.data.length;at++)We&&ue(rt.data[at])?et++:(Ee=rt.data[at].length,Xe+=Ee,Ue===void 0?Ue=Ee:0<Ee&&(Be+=Math.abs(Ee-Ue),Ue=Ee));0<rt.data.length&&(Xe/=rt.data.length-et),(Ne===void 0||Be<=Ne)&&(Ie===void 0||Ie<Xe)&&1.99<Xe&&(Ne=Be,$e=Te,Ie=Xe)}return{successful:!!(C.delimiter=$e),bestDelimiter:$e}})(ke,C.newline,C.skipEmptyLines,C.comments,C.delimitersToGuess)).successful?C.delimiter=fe.bestDelimiter:(L=!0,C.delimiter=l.DefaultDelimiter),ce.meta.delimiter=C.delimiter),w(C));return C.preview&&C.header&&fe.preview++,A=ke,R=new y(fe),ce=R.parse(A,ye,Me),_e(),le?{meta:{paused:!0}}:ce||{meta:{paused:!1}}},this.paused=function(){return le},this.pause=function(){le=!0,R.abort(),A=T(C.chunk)?"":A.substring(R.getCharIndex())},this.resume=function(){q.streamer._halted?(le=!1,q.streamer.parseChunk(A,!0)):setTimeout(q.resume,3)},this.aborted=function(){return ee},this.abort=function(){ee=!0,R.abort(),ce.meta.aborted=!0,T(C.complete)&&C.complete(ce),A=""},this.guessLineEndings=function(Ye,fe){Ye=Ye.substring(0,1048576);var fe=new RegExp(g(fe)+"([^]*?)"+g(fe),"gm"),Me=(Ye=Ye.replace(fe,"")).split("\r"),fe=Ye.split(`
|
|
5690
5690
|
`),Ye=1<fe.length&&fe[0].length<Me[0].length;if(Me.length===1||Ye)return`
|
|
5691
5691
|
`;for(var He=0,We=0;We<Me.length;We++)Me[We][0]===`
|