@tscircuit/runframe 0.0.1752 → 0.0.1753
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.
|
@@ -5685,7 +5685,7 @@ test("${g} should solve problem correctly", () => {
|
|
|
5685
5685
|
// Add more specific assertions based on expected output
|
|
5686
5686
|
// expect(solver.netLabelPlacementSolver!.netLabelPlacements).toMatchInlineSnapshot()
|
|
5687
5687
|
})
|
|
5688
|
-
`,I=new Blob([c],{type:"text/plain"}),l=URL.createObjectURL(I),B=document.createElement("a");B.href=l,B.download=`${g}.test.ts`,B.click(),URL.revokeObjectURL(l)}catch(a){alert(`Error generating test.ts for ${e.constructor.name}: ${a instanceof Error?a.message:String(a)}`)}i(!1)};return Z.jsxs("div",{className:`relative ${A}`,ref:n,children:[Z.jsx("button",{className:"px-2 py-1 rounded text-xs cursor-pointer",onClick:()=>i(!t),title:`Download options for ${e.constructor.name}`,children:e.constructor.name}),t&&Z.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:[Z.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:o,children:"Download JSON"}),Z.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:s,children:"Download page.tsx"}),Z.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:r,children:"Download test.ts"})]})]})},Aht=e=>e.activeSubSolver?[e,...Aht(e.activeSubSolver)]:[e],pti=({solver:e})=>{const A=Aht(e);return Z.jsx("div",{className:"flex gap-1 items-center text-sm pt-1",children:A.map((t,i)=>Z.jsxs("div",{className:"flex items-center",children:[i>0&&Z.jsx("span",{className:"text-gray-400 mx-1",children:"→"}),Z.jsx(dti,{solver:t})]},t.constructor.name))})},fti=({solver:e,triggerRender:A,animationSpeed:t=25,onSolverStarted:i,onSolverCompleted:n})=>{const[o,s]=AA.useReducer(Q=>!Q,!1),r=AA.useRef(void 0),a=()=>{!e.solved&&!e.failed&&(e.step(),A())},g=()=>{!e.solved&&!e.failed&&(i&&i(e),e.solve(),A(),n&&n(e))},c=()=>{o?(r.current&&(clearInterval(r.current),r.current=void 0),s()):(s(),r.current=setInterval(()=>{if(e.solved||e.failed){r.current&&(clearInterval(r.current),r.current=void 0),s(),A(),n&&e.solved&&n(e);return}e.step(),A()},t))},I=()=>{const Q=e;if(Q.getCurrentPhase&&!e.solved&&!e.failed){const h=Q.getCurrentPhase();for(;Q.getCurrentPhase()===h&&!e.solved&&!e.failed;)e.step();A()}},l=()=>{if(e.solved||e.failed||o)return;const Q=window.prompt("Step until which iteration?",`${e.iterations}`);if(Q===null)return;const h=Number(Q);if(!Number.isFinite(h)){window.alert("Please enter a valid number for the iteration");return}for(;e.iterations<h&&!e.solved&&!e.failed;)e.step();A(),e.solved&&n&&n(e)};AA.useEffect(()=>()=>{r.current&&clearInterval(r.current)},[]),AA.useEffect(()=>{(e.solved||e.failed)&&o&&(r.current&&(clearInterval(r.current),r.current=void 0),s())},[e.solved,e.failed,o]);const B=e.getCurrentPhase!==void 0,C=B?e.getCurrentPhase():null;return Z.jsxs("div",{className:"space-y-2 p-2 border-b",children:[Z.jsx("div",{className:"flex items-center",children:Z.jsx(pti,{solver:e})}),Z.jsxs("div",{className:"flex gap-2 items-center flex-wrap",children:[Z.jsx("button",{onClick:a,disabled:e.solved||e.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"}),Z.jsx("button",{onClick:g,disabled:e.solved||e.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"}),Z.jsx("button",{onClick:c,disabled:e.solved||e.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"}),Z.jsx("button",{onClick:l,disabled:e.solved||e.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"}),B&&Z.jsx("button",{onClick:I,disabled:e.solved||e.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"}),Z.jsxs("div",{className:"text-sm text-gray-600",children:["Iterations: ",e.iterations]}),e.timeToSolve!==void 0&&Z.jsxs("div",{className:"text-sm text-gray-600",children:["Time: ",(e.timeToSolve/1e3).toFixed(3),"s"]}),C&&Z.jsxs("div",{className:"text-sm text-gray-600",children:["Phase: ",Z.jsx("span",{className:"font-medium",children:C})]}),e.solved&&Z.jsx("div",{className:"px-2 py-1 bg-green-100 text-green-800 rounded text-sm",children:"Solved"}),e.failed&&Z.jsx("div",{className:"px-2 py-1 bg-red-100 text-red-800 rounded text-sm",children:"Failed"})]}),e.error&&Z.jsxs("div",{className:"text-red-600 text-sm",children:["Error: ",e.error]})]})},yti=(e,A,t)=>{const i=e.currentPipelineStepIndex;return A<i?"Completed":A===i&&e.activeSubSolver?e.activeSubSolver.failed?"Failed":"In Progress":"Not Started"},mti=(e,A)=>{const i=e.pipelineDef[A].solverName,n=yti(e,A),o=e[i],s=e.firstIterationOfPhase?.[i]??null,r=e.iterations;let a=0;if(n==="Completed"){const l=e.pipelineDef[A+1],B=l?e.firstIterationOfPhase?.[l.solverName]:void 0;B!==void 0&&s!==null?a=B-s:s!==null&&(a=r-s)}else n==="In Progress"&&s!==null&&(a=r-s);const g=e.timeSpentOnPhase?.[i]??0;let c=0;n==="Completed"?c=1:n==="In Progress"&&o&&(c=o.progress??0);const I=o?.stats??null;return{index:A,name:i,status:n,firstIteration:s,iterations:a,progress:c,timeSpent:g,stats:I&&Object.keys(I).length>0?I:null,solverInstance:o??null}},wti=({status:e})=>{const A={"Not Started":"text-blue-600","In Progress":"text-yellow-600",Completed:"text-green-600",Failed:"text-red-600"};return Z.jsx("span",{className:`font-medium ${A[e]}`,children:e})},Dti=({progress:e})=>{if(e===0)return null;const A=Math.round(e*100);return Z.jsxs("div",{className:"flex items-center gap-2",children:[Z.jsx("div",{className:"w-20 h-2 bg-gray-200 rounded overflow-hidden",children:Z.jsx("div",{className:"h-full bg-blue-500 transition-all duration-200",style:{width:`${A}%`}})}),Z.jsxs("span",{className:"text-xs text-gray-500",children:[A,"%"]})]})},Sti=e=>Object.entries(e).map(([A,t])=>`${A}: ${t}`).join(", "),bti=({stats:e})=>{if(!e||Object.keys(e).length===0)return Z.jsx("span",{children:"-"});const A=Object.entries(e),t=Sti(e);return Z.jsxs("details",{className:"cursor-pointer",children:[Z.jsx("summary",{className:"whitespace-nowrap overflow-hidden text-ellipsis max-w-[200px]",children:t}),Z.jsx("div",{className:"mt-1 text-xs",children:A.map(([i,n])=>Z.jsxs("div",{children:[i,": ",String(n)]},i))})]})},SyA=e=>{if(e===null||typeof e!="object")return e;if(Array.isArray(e))return e.map(SyA);const A={};for(const[t,i]of Object.entries(e))t.startsWith("_")||(A[t]=SyA(i));return A},xti=(e,A)=>{try{if(typeof e.getConstructorParams!="function"){alert(`getConstructorParams() is not implemented for ${A}`);return}const t=SyA(e.getConstructorParams()),i=new Blob([JSON.stringify(t,null,2)],{type:"application/json"}),n=URL.createObjectURL(i),o=document.createElement("a");o.href=n,o.download=`${A}_input.json`,o.click(),URL.revokeObjectURL(n)}catch(t){alert(`Error downloading input for ${A}: ${t instanceof Error?t.message:String(t)}`)}},_ti=({solver:e,onStepUntilPhase:A,onDownloadInput:t})=>{const i=e.pipelineDef.map((r,a)=>mti(e,a)),n=r=>{A?.(r)},o=r=>{r.solverInstance&&(t?t(r.solverInstance,r.name):xti(r.solverInstance,r.name))},s=r=>`${(r/1e3).toFixed(2)}s`;return Z.jsxs("div",{className:"border-t border-gray-200",children:[Z.jsx("div",{className:"px-4 py-2 bg-gray-50 border-b border-gray-200",children:Z.jsx("h3",{className:"text-sm font-semibold text-gray-700",children:"Pipeline Steps"})}),Z.jsx("div",{className:"overflow-x-auto",children:Z.jsxs("table",{className:"w-full text-sm",children:[Z.jsx("thead",{children:Z.jsxs("tr",{className:"bg-gray-50 border-b border-gray-200",children:[Z.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Step"}),Z.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Status"}),Z.jsxs("th",{className:"px-4 py-2 text-center font-semibold text-gray-700",children:["i",Z.jsx("sub",{children:"0"})]}),Z.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Iterations"}),Z.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Progress"}),Z.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Time"}),Z.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Stats"}),Z.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Input"})]})}),Z.jsx("tbody",{children:i.map(r=>Z.jsxs("tr",{className:`border-b border-gray-100 ${r.status==="In Progress"?"bg-yellow-50":""}`,children:[Z.jsx("td",{className:"px-4 py-2",children:Z.jsxs("div",{className:"flex items-center gap-2",children:[Z.jsx("span",{className:"text-gray-400 w-6",children:String(r.index+1).padStart(2,"0")}),Z.jsx("button",{onClick:()=>n(r.name),disabled:r.status==="Completed"||e.solved||e.failed,className:"text-blue-500 hover:text-blue-700 disabled:text-gray-300 disabled:cursor-not-allowed",title:`Step until ${r.name} completes`,children:Z.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:Z.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"})})}),Z.jsx("span",{className:"font-medium text-gray-900",children:r.name})]})}),Z.jsx("td",{className:"px-4 py-2",children:Z.jsx(wti,{status:r.status})}),Z.jsx("td",{className:"px-4 py-2 text-center text-gray-600",children:r.firstIteration!==null?r.firstIteration:""}),Z.jsx("td",{className:"px-4 py-2 text-gray-600",children:r.iterations}),Z.jsx("td",{className:"px-4 py-2",children:Z.jsx(Dti,{progress:r.progress})}),Z.jsx("td",{className:"px-4 py-2 text-gray-600",children:s(r.timeSpent)}),Z.jsx("td",{className:"px-4 py-2 text-gray-500",children:Z.jsx(bti,{stats:r.stats})}),Z.jsx("td",{className:"px-4 py-2",children:r.solverInstance?Z.jsxs("button",{onClick:()=>o(r),className:"flex items-center gap-1 text-blue-500 hover:text-blue-700",title:`Download input for ${r.name}`,children:[Z.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:Z.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"})}),Z.jsx("span",{children:"Input"})]}):null})]},r.name))})]})})]})},kti=class extends Qn.Component{constructor(e){super(e),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(e){console.error("InteractiveGraphics render error:",e)}render(){return this.state.hasError?this.props.fallback:this.props.children}};function vti({graphics:e}){const A=e.points??[],t=e.lines??[],i=e.rects??[],n=e.circles??[],o=e.texts??[];let s=Number.POSITIVE_INFINITY,r=Number.POSITIVE_INFINITY,a=Number.NEGATIVE_INFINITY,g=Number.NEGATIVE_INFINITY;const c=(h,E)=>{typeof h=="number"&&(h<s&&(s=h),h>a&&(a=h)),typeof E=="number"&&(E<r&&(r=E),E>g&&(g=E))};for(const h of A)c(h.x,h.y);for(const h of t){const E=h.points??[];for(const u of E)c(u.x,u.y)}for(const h of i){const E=h.x??0,u=h.y??0,d=h.width??0,f=h.height??0;c(E,u),c(E+d,u+f)}for(const h of n){const E=h.x??0,u=h.y??0,d=h.radius??1;c(E-d,u-d),c(E+d,u+d)}for(const h of o)c(h.x,h.y);(!isFinite(s)||!isFinite(r)||!isFinite(a)||!isFinite(g))&&(s=-20,r=-20,a=20,g=20);const I=10,l=s-I,B=r-I,C=Math.max(1,a-s+2*I),Q=Math.max(1,g-r+2*I);return Z.jsxs("svg",{className:"w-full h-[400px] bg-white",viewBox:`${l} ${B} ${C} ${Q}`,role:"img","aria-label":"Graphics fallback",children:[i.map((h,E)=>Z.jsx("rect",{x:h.x??0,y:h.y??0,width:h.width??0,height:h.height??0,fill:"none",stroke:h.strokeColor??"black",strokeWidth:h.strokeWidth??1},`rect-${E}`)),t.map((h,E)=>Z.jsx("polyline",{fill:"none",stroke:h.strokeColor??"black",strokeWidth:h.strokeWidth??1,points:(h.points??[]).map(u=>`${u.x??0},${u.y??0}`).join(" ")},`line-${E}`)),n.map((h,E)=>Z.jsx("circle",{cx:h.x??0,cy:h.y??0,r:h.radius??1.5,fill:h.fillColor??"none",stroke:h.strokeColor??"black",strokeWidth:h.strokeWidth??1},`circle-${E}`)),A.map((h,E)=>Z.jsx("circle",{cx:h.x??0,cy:h.y??0,r:h.radius??1.5,fill:h.color??"black"},`point-${E}`)),o.map((h,E)=>Z.jsx("text",{x:h.x??0,y:h.y??0,fontSize:h.fontSize??10,fill:h.color??"black",children:h.text??""},`text-${E}`))]})}var Fti=({solver:e,animationSpeed:A=25,onSolverStarted:t,onSolverCompleted:i})=>{const[n,o]=AA.useReducer(c=>c+1,0),s=AA.useMemo(()=>{try{return e.visualize()||{points:[],lines:[],rects:[],circles:[]}}catch(c){return console.error("Visualization error:",c),{points:[],lines:[],rects:[],circles:[]}}},[e,n]),r=AA.useMemo(()=>(s.rects?.length||0)===0&&(s.lines?.length||0)===0&&(s.points?.length||0)===0&&(s.circles?.length||0)===0,[s]);AA.useEffect(()=>{if(!(typeof document>"u")&&!document.querySelector('script[src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4"]')){const c=document.createElement("script");c.src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4",document.head.appendChild(c)}},[]);const a=e.pipelineDef!==void 0,g=c=>{const I=e;if(!e.solved&&!e.failed){for(;!e.solved&&!e.failed&&I.currentPipelineStepIndex<=I.pipelineDef.findIndex(l=>l.solverName===c);)e.step();o()}};return Z.jsxs("div",{children:[Z.jsx(fti,{solver:e,triggerRender:o,animationSpeed:A,onSolverStarted:t,onSolverCompleted:i}),r?Z.jsx("div",{className:"p-4 text-gray-500",children:"No Graphics Yet"}):Z.jsx(kti,{fallback:Z.jsx(vti,{graphics:s}),children:Z.jsx(uti,{graphics:s})}),a&&Z.jsx(_ti,{solver:e,onStepUntilPhase:g})]})};const Mti=()=>{AA.useEffect(()=>{const e="tailwind-cdn-script";if(document.getElementById(e)||window.tailwind)return;const A=document.createElement("div");A.className="hidden",document.body.appendChild(A);const t=window.getComputedStyle(A).display==="none";if(document.body.removeChild(A),t)return;const i=document.createElement("script");i.id=e,i.src="https://cdn.tailwindcss.com",document.head.appendChild(i)},[])},Gti=e=>e.toLowerCase().includes("pack")?gTe:e.toLowerCase().includes("rout")?QTe:ATe,Rti=({solverEvents:e=[]})=>{const[A,t]=AA.useState(null);Mti();const i=AA.useMemo(()=>{const r=new Map;for(const a of e){const g=`${a.componentName}-${a.solverName}`;r.set(g,a)}return r},[e]),n=AA.useMemo(()=>Array.from(i.keys()),[i]),o=A?i.get(A):null,s=AA.useMemo(()=>{if(!o)return{instance:null,error:null,classFound:!1};const r=ZgA[o.solverName];if(!r)return{instance:null,error:`Solver class "${o.solverName}" not found in SOLVERS registry. Available: ${Object.keys(ZgA).join(", ")}`,classFound:!1};try{const a=o.solverParams,g=a?.input!==void 0?a.input:a;return{instance:new r(g),error:null,classFound:!0}}catch(a){const g=a instanceof Error?a.message:String(a);return console.error("Failed to reconstruct solver:",a),{instance:null,error:`Failed to instantiate solver: ${g}`,classFound:!0}}},[o]);return e.length===0?Z.jsx("div",{className:"rf-p-4",children:Z.jsx("div",{className:"rf-bg-gray-50 rf-rounded-md rf-border rf-border-gray-200",children:Z.jsxs("div",{className:"rf-p-4",children:[Z.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800 rf-mb-3",children:"No Solvers Detected"}),Z.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."})]})})}):Z.jsxs("div",{className:"rf-flex rf-h-full rf-overflow-hidden",children:[Z.jsxs("div",{className:"rf-w-64 rf-border-r rf-border-gray-200 rf-overflow-y-auto rf-flex-shrink-0",children:[Z.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:[n.length," ",n.length===1?"Solver":"Solvers"]}),n.map(r=>{const a=i.get(r),g=A===r;return Z.jsx("div",{className:`rf-px-3 rf-py-2 rf-cursor-pointer rf-border-b rf-border-gray-100 ${g?"rf-bg-blue-50 rf-border-l-2 rf-border-l-blue-500":"hover:rf-bg-gray-50"}`,onClick:()=>t(r),children:(()=>{const c=Gti(a.solverName);return Z.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2",children:[Z.jsx(c,{className:"rf-w-4 rf-h-4 rf-text-blue-500 rf-flex-shrink-0"}),Z.jsxs("div",{className:"rf-flex-1 rf-min-w-0",children:[Z.jsx("div",{className:"rf-text-sm rf-font-medium rf-text-gray-800 rf-truncate",children:a.componentName}),Z.jsx("div",{className:"rf-text-xs rf-text-gray-500 rf-truncate",children:a.solverName})]})]})})()},r)})]}),Z.jsx("div",{className:"rf-flex-1 rf-overflow-hidden",children:o?s.instance?Z.jsx(jD,{fallback:Z.jsx("div",{className:"rf-p-4",children:Z.jsxs("div",{className:"rf-bg-red-50 rf-rounded-md rf-border rf-border-red-200 rf-p-4",children:[Z.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-red-800 rf-mb-2",children:"Error Loading Solver Debugger"}),Z.jsxs("p",{className:"rf-text-sm rf-text-red-600",children:["Failed to render the solver debugger for"," ",o.solverName]})]})}),children:Z.jsx(Fti,{solver:s.instance})}):Z.jsxs("div",{className:"rf-p-4",children:[Z.jsxs("div",{className:"rf-mb-4",children:[Z.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800",children:o.solverName}),Z.jsxs("p",{className:"rf-text-sm rf-text-gray-500",children:["Component: ",o.componentName]})]}),s.error&&Z.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:Z.jsx("p",{className:`rf-text-sm ${s.classFound?"rf-text-red-700":"rf-text-yellow-700"}`,children:s.error})}),Z.jsxs("div",{className:"rf-border rf-border-gray-200 rf-rounded-md rf-overflow-hidden",children:[Z.jsx("div",{className:"rf-px-3 rf-py-2 rf-bg-gray-50",children:Z.jsx("span",{className:"rf-text-sm rf-font-medium rf-text-gray-700",children:"Solver Parameters"})}),Z.jsx("div",{className:"rf-p-3 rf-bg-white rf-border-t rf-border-gray-200",children:Z.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)})})]})]}):Z.jsx("div",{className:"rf-flex rf-items-center rf-justify-center rf-h-full",children:Z.jsx("p",{className:"rf-text-sm rf-text-gray-500",children:"Select a solver from the list to view details"})})})]})},tht=({errorMessage:e,errorStack:A,circuitJsonErrors:t})=>{AA.useEffect(()=>{if(e){const i=new Error(e);A&&(i.stack=A);try{lq.captureException(i)}catch{}}},[e,A]),AA.useEffect(()=>{if(t&&t.length>0)for(const i of t){const n=new Error(i.message||"Circuit JSON Error");i.stack&&(n.stack=i.stack);try{lq.captureException(n,{error_type:i.type})}catch{}}},[t])},eht="0.0.1751",Nti={version:eht},byA={BASE_URL:"/",DEV:!1,MODE:"production",PROD:!0,SSR:!1},xyA=new Map,$j=e=>{const A=xyA.get(e);return A?Object.fromEntries(Object.entries(A.stores).map(([t,i])=>[t,i.getState()])):{}},Lti=(e,A,t)=>{if(e===void 0)return{type:"untracked",connection:A.connect(t)};const i=xyA.get(t.name);if(i)return{type:"tracked",store:e,...i};const n={connection:A.connect(t),stores:{}};return xyA.set(t.name,n),{type:"tracked",store:e,...n}},iht=(e,A={})=>(t,i,n)=>{const{enabled:o,anonymousActionType:s,store:r,...a}=A;let g;try{g=(o??(byA?"production":void 0)!=="production")&&window.__REDUX_DEVTOOLS_EXTENSION__}catch{}if(!g)return(byA?"production":void 0)!=="production"&&o&&console.warn("[zustand devtools middleware] Please install/enable Redux devtools extension"),e(t,i,n);const{connection:c,...I}=Lti(r,g,a);let l=!0;n.setState=(Q,h,E)=>{const u=t(Q,h);if(!l)return u;const d=E===void 0?{type:s||"anonymous"}:typeof E=="string"?{type:E}:E;return r===void 0?(c?.send(d,i()),u):(c?.send({...d,type:`${r}/${d.type}`},{...$j(a.name),[r]:n.getState()}),u)};const B=(...Q)=>{const h=l;l=!1,t(...Q),l=h},C=e(n.setState,i,n);if(I.type==="untracked"?c?.init(C):(I.stores[I.store]=n,c?.init(Object.fromEntries(Object.entries(I.stores).map(([Q,h])=>[Q,Q===I.store?C:h.getState()])))),n.dispatchFromDevtools&&typeof n.dispatch=="function"){let Q=!1;const h=n.dispatch;n.dispatch=(...E)=>{(byA?"production":void 0)!=="production"&&E[0].type==="__setState"&&!Q&&(console.warn('[zustand devtools middleware] "__setState" action type is reserved to set state from the devtools. Avoid using it.'),Q=!0),h(...E)}}return c.subscribe(Q=>{var h;switch(Q.type){case"ACTION":if(typeof Q.payload!="string"){console.error("[zustand devtools middleware] Unsupported action format");return}return _yA(Q.payload,E=>{if(E.type==="__setState"){if(r===void 0){B(E.state);return}Object.keys(E.state).length!==1&&console.error(`
|
|
5688
|
+
`,I=new Blob([c],{type:"text/plain"}),l=URL.createObjectURL(I),B=document.createElement("a");B.href=l,B.download=`${g}.test.ts`,B.click(),URL.revokeObjectURL(l)}catch(a){alert(`Error generating test.ts for ${e.constructor.name}: ${a instanceof Error?a.message:String(a)}`)}i(!1)};return Z.jsxs("div",{className:`relative ${A}`,ref:n,children:[Z.jsx("button",{className:"px-2 py-1 rounded text-xs cursor-pointer",onClick:()=>i(!t),title:`Download options for ${e.constructor.name}`,children:e.constructor.name}),t&&Z.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:[Z.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:o,children:"Download JSON"}),Z.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:s,children:"Download page.tsx"}),Z.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:r,children:"Download test.ts"})]})]})},Aht=e=>e.activeSubSolver?[e,...Aht(e.activeSubSolver)]:[e],pti=({solver:e})=>{const A=Aht(e);return Z.jsx("div",{className:"flex gap-1 items-center text-sm pt-1",children:A.map((t,i)=>Z.jsxs("div",{className:"flex items-center",children:[i>0&&Z.jsx("span",{className:"text-gray-400 mx-1",children:"→"}),Z.jsx(dti,{solver:t})]},t.constructor.name))})},fti=({solver:e,triggerRender:A,animationSpeed:t=25,onSolverStarted:i,onSolverCompleted:n})=>{const[o,s]=AA.useReducer(Q=>!Q,!1),r=AA.useRef(void 0),a=()=>{!e.solved&&!e.failed&&(e.step(),A())},g=()=>{!e.solved&&!e.failed&&(i&&i(e),e.solve(),A(),n&&n(e))},c=()=>{o?(r.current&&(clearInterval(r.current),r.current=void 0),s()):(s(),r.current=setInterval(()=>{if(e.solved||e.failed){r.current&&(clearInterval(r.current),r.current=void 0),s(),A(),n&&e.solved&&n(e);return}e.step(),A()},t))},I=()=>{const Q=e;if(Q.getCurrentPhase&&!e.solved&&!e.failed){const h=Q.getCurrentPhase();for(;Q.getCurrentPhase()===h&&!e.solved&&!e.failed;)e.step();A()}},l=()=>{if(e.solved||e.failed||o)return;const Q=window.prompt("Step until which iteration?",`${e.iterations}`);if(Q===null)return;const h=Number(Q);if(!Number.isFinite(h)){window.alert("Please enter a valid number for the iteration");return}for(;e.iterations<h&&!e.solved&&!e.failed;)e.step();A(),e.solved&&n&&n(e)};AA.useEffect(()=>()=>{r.current&&clearInterval(r.current)},[]),AA.useEffect(()=>{(e.solved||e.failed)&&o&&(r.current&&(clearInterval(r.current),r.current=void 0),s())},[e.solved,e.failed,o]);const B=e.getCurrentPhase!==void 0,C=B?e.getCurrentPhase():null;return Z.jsxs("div",{className:"space-y-2 p-2 border-b",children:[Z.jsx("div",{className:"flex items-center",children:Z.jsx(pti,{solver:e})}),Z.jsxs("div",{className:"flex gap-2 items-center flex-wrap",children:[Z.jsx("button",{onClick:a,disabled:e.solved||e.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"}),Z.jsx("button",{onClick:g,disabled:e.solved||e.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"}),Z.jsx("button",{onClick:c,disabled:e.solved||e.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"}),Z.jsx("button",{onClick:l,disabled:e.solved||e.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"}),B&&Z.jsx("button",{onClick:I,disabled:e.solved||e.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"}),Z.jsxs("div",{className:"text-sm text-gray-600",children:["Iterations: ",e.iterations]}),e.timeToSolve!==void 0&&Z.jsxs("div",{className:"text-sm text-gray-600",children:["Time: ",(e.timeToSolve/1e3).toFixed(3),"s"]}),C&&Z.jsxs("div",{className:"text-sm text-gray-600",children:["Phase: ",Z.jsx("span",{className:"font-medium",children:C})]}),e.solved&&Z.jsx("div",{className:"px-2 py-1 bg-green-100 text-green-800 rounded text-sm",children:"Solved"}),e.failed&&Z.jsx("div",{className:"px-2 py-1 bg-red-100 text-red-800 rounded text-sm",children:"Failed"})]}),e.error&&Z.jsxs("div",{className:"text-red-600 text-sm",children:["Error: ",e.error]})]})},yti=(e,A,t)=>{const i=e.currentPipelineStepIndex;return A<i?"Completed":A===i&&e.activeSubSolver?e.activeSubSolver.failed?"Failed":"In Progress":"Not Started"},mti=(e,A)=>{const i=e.pipelineDef[A].solverName,n=yti(e,A),o=e[i],s=e.firstIterationOfPhase?.[i]??null,r=e.iterations;let a=0;if(n==="Completed"){const l=e.pipelineDef[A+1],B=l?e.firstIterationOfPhase?.[l.solverName]:void 0;B!==void 0&&s!==null?a=B-s:s!==null&&(a=r-s)}else n==="In Progress"&&s!==null&&(a=r-s);const g=e.timeSpentOnPhase?.[i]??0;let c=0;n==="Completed"?c=1:n==="In Progress"&&o&&(c=o.progress??0);const I=o?.stats??null;return{index:A,name:i,status:n,firstIteration:s,iterations:a,progress:c,timeSpent:g,stats:I&&Object.keys(I).length>0?I:null,solverInstance:o??null}},wti=({status:e})=>{const A={"Not Started":"text-blue-600","In Progress":"text-yellow-600",Completed:"text-green-600",Failed:"text-red-600"};return Z.jsx("span",{className:`font-medium ${A[e]}`,children:e})},Dti=({progress:e})=>{if(e===0)return null;const A=Math.round(e*100);return Z.jsxs("div",{className:"flex items-center gap-2",children:[Z.jsx("div",{className:"w-20 h-2 bg-gray-200 rounded overflow-hidden",children:Z.jsx("div",{className:"h-full bg-blue-500 transition-all duration-200",style:{width:`${A}%`}})}),Z.jsxs("span",{className:"text-xs text-gray-500",children:[A,"%"]})]})},Sti=e=>Object.entries(e).map(([A,t])=>`${A}: ${t}`).join(", "),bti=({stats:e})=>{if(!e||Object.keys(e).length===0)return Z.jsx("span",{children:"-"});const A=Object.entries(e),t=Sti(e);return Z.jsxs("details",{className:"cursor-pointer",children:[Z.jsx("summary",{className:"whitespace-nowrap overflow-hidden text-ellipsis max-w-[200px]",children:t}),Z.jsx("div",{className:"mt-1 text-xs",children:A.map(([i,n])=>Z.jsxs("div",{children:[i,": ",String(n)]},i))})]})},SyA=e=>{if(e===null||typeof e!="object")return e;if(Array.isArray(e))return e.map(SyA);const A={};for(const[t,i]of Object.entries(e))t.startsWith("_")||(A[t]=SyA(i));return A},xti=(e,A)=>{try{if(typeof e.getConstructorParams!="function"){alert(`getConstructorParams() is not implemented for ${A}`);return}const t=SyA(e.getConstructorParams()),i=new Blob([JSON.stringify(t,null,2)],{type:"application/json"}),n=URL.createObjectURL(i),o=document.createElement("a");o.href=n,o.download=`${A}_input.json`,o.click(),URL.revokeObjectURL(n)}catch(t){alert(`Error downloading input for ${A}: ${t instanceof Error?t.message:String(t)}`)}},_ti=({solver:e,onStepUntilPhase:A,onDownloadInput:t})=>{const i=e.pipelineDef.map((r,a)=>mti(e,a)),n=r=>{A?.(r)},o=r=>{r.solverInstance&&(t?t(r.solverInstance,r.name):xti(r.solverInstance,r.name))},s=r=>`${(r/1e3).toFixed(2)}s`;return Z.jsxs("div",{className:"border-t border-gray-200",children:[Z.jsx("div",{className:"px-4 py-2 bg-gray-50 border-b border-gray-200",children:Z.jsx("h3",{className:"text-sm font-semibold text-gray-700",children:"Pipeline Steps"})}),Z.jsx("div",{className:"overflow-x-auto",children:Z.jsxs("table",{className:"w-full text-sm",children:[Z.jsx("thead",{children:Z.jsxs("tr",{className:"bg-gray-50 border-b border-gray-200",children:[Z.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Step"}),Z.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Status"}),Z.jsxs("th",{className:"px-4 py-2 text-center font-semibold text-gray-700",children:["i",Z.jsx("sub",{children:"0"})]}),Z.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Iterations"}),Z.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Progress"}),Z.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Time"}),Z.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Stats"}),Z.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Input"})]})}),Z.jsx("tbody",{children:i.map(r=>Z.jsxs("tr",{className:`border-b border-gray-100 ${r.status==="In Progress"?"bg-yellow-50":""}`,children:[Z.jsx("td",{className:"px-4 py-2",children:Z.jsxs("div",{className:"flex items-center gap-2",children:[Z.jsx("span",{className:"text-gray-400 w-6",children:String(r.index+1).padStart(2,"0")}),Z.jsx("button",{onClick:()=>n(r.name),disabled:r.status==="Completed"||e.solved||e.failed,className:"text-blue-500 hover:text-blue-700 disabled:text-gray-300 disabled:cursor-not-allowed",title:`Step until ${r.name} completes`,children:Z.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:Z.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"})})}),Z.jsx("span",{className:"font-medium text-gray-900",children:r.name})]})}),Z.jsx("td",{className:"px-4 py-2",children:Z.jsx(wti,{status:r.status})}),Z.jsx("td",{className:"px-4 py-2 text-center text-gray-600",children:r.firstIteration!==null?r.firstIteration:""}),Z.jsx("td",{className:"px-4 py-2 text-gray-600",children:r.iterations}),Z.jsx("td",{className:"px-4 py-2",children:Z.jsx(Dti,{progress:r.progress})}),Z.jsx("td",{className:"px-4 py-2 text-gray-600",children:s(r.timeSpent)}),Z.jsx("td",{className:"px-4 py-2 text-gray-500",children:Z.jsx(bti,{stats:r.stats})}),Z.jsx("td",{className:"px-4 py-2",children:r.solverInstance?Z.jsxs("button",{onClick:()=>o(r),className:"flex items-center gap-1 text-blue-500 hover:text-blue-700",title:`Download input for ${r.name}`,children:[Z.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:Z.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"})}),Z.jsx("span",{children:"Input"})]}):null})]},r.name))})]})})]})},kti=class extends Qn.Component{constructor(e){super(e),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(e){console.error("InteractiveGraphics render error:",e)}render(){return this.state.hasError?this.props.fallback:this.props.children}};function vti({graphics:e}){const A=e.points??[],t=e.lines??[],i=e.rects??[],n=e.circles??[],o=e.texts??[];let s=Number.POSITIVE_INFINITY,r=Number.POSITIVE_INFINITY,a=Number.NEGATIVE_INFINITY,g=Number.NEGATIVE_INFINITY;const c=(h,E)=>{typeof h=="number"&&(h<s&&(s=h),h>a&&(a=h)),typeof E=="number"&&(E<r&&(r=E),E>g&&(g=E))};for(const h of A)c(h.x,h.y);for(const h of t){const E=h.points??[];for(const u of E)c(u.x,u.y)}for(const h of i){const E=h.x??0,u=h.y??0,d=h.width??0,f=h.height??0;c(E,u),c(E+d,u+f)}for(const h of n){const E=h.x??0,u=h.y??0,d=h.radius??1;c(E-d,u-d),c(E+d,u+d)}for(const h of o)c(h.x,h.y);(!isFinite(s)||!isFinite(r)||!isFinite(a)||!isFinite(g))&&(s=-20,r=-20,a=20,g=20);const I=10,l=s-I,B=r-I,C=Math.max(1,a-s+2*I),Q=Math.max(1,g-r+2*I);return Z.jsxs("svg",{className:"w-full h-[400px] bg-white",viewBox:`${l} ${B} ${C} ${Q}`,role:"img","aria-label":"Graphics fallback",children:[i.map((h,E)=>Z.jsx("rect",{x:h.x??0,y:h.y??0,width:h.width??0,height:h.height??0,fill:"none",stroke:h.strokeColor??"black",strokeWidth:h.strokeWidth??1},`rect-${E}`)),t.map((h,E)=>Z.jsx("polyline",{fill:"none",stroke:h.strokeColor??"black",strokeWidth:h.strokeWidth??1,points:(h.points??[]).map(u=>`${u.x??0},${u.y??0}`).join(" ")},`line-${E}`)),n.map((h,E)=>Z.jsx("circle",{cx:h.x??0,cy:h.y??0,r:h.radius??1.5,fill:h.fillColor??"none",stroke:h.strokeColor??"black",strokeWidth:h.strokeWidth??1},`circle-${E}`)),A.map((h,E)=>Z.jsx("circle",{cx:h.x??0,cy:h.y??0,r:h.radius??1.5,fill:h.color??"black"},`point-${E}`)),o.map((h,E)=>Z.jsx("text",{x:h.x??0,y:h.y??0,fontSize:h.fontSize??10,fill:h.color??"black",children:h.text??""},`text-${E}`))]})}var Fti=({solver:e,animationSpeed:A=25,onSolverStarted:t,onSolverCompleted:i})=>{const[n,o]=AA.useReducer(c=>c+1,0),s=AA.useMemo(()=>{try{return e.visualize()||{points:[],lines:[],rects:[],circles:[]}}catch(c){return console.error("Visualization error:",c),{points:[],lines:[],rects:[],circles:[]}}},[e,n]),r=AA.useMemo(()=>(s.rects?.length||0)===0&&(s.lines?.length||0)===0&&(s.points?.length||0)===0&&(s.circles?.length||0)===0,[s]);AA.useEffect(()=>{if(!(typeof document>"u")&&!document.querySelector('script[src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4"]')){const c=document.createElement("script");c.src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4",document.head.appendChild(c)}},[]);const a=e.pipelineDef!==void 0,g=c=>{const I=e;if(!e.solved&&!e.failed){for(;!e.solved&&!e.failed&&I.currentPipelineStepIndex<=I.pipelineDef.findIndex(l=>l.solverName===c);)e.step();o()}};return Z.jsxs("div",{children:[Z.jsx(fti,{solver:e,triggerRender:o,animationSpeed:A,onSolverStarted:t,onSolverCompleted:i}),r?Z.jsx("div",{className:"p-4 text-gray-500",children:"No Graphics Yet"}):Z.jsx(kti,{fallback:Z.jsx(vti,{graphics:s}),children:Z.jsx(uti,{graphics:s})}),a&&Z.jsx(_ti,{solver:e,onStepUntilPhase:g})]})};const Mti=()=>{AA.useEffect(()=>{const e="tailwind-cdn-script";if(document.getElementById(e)||window.tailwind)return;const A=document.createElement("div");A.className="hidden",document.body.appendChild(A);const t=window.getComputedStyle(A).display==="none";if(document.body.removeChild(A),t)return;const i=document.createElement("script");i.id=e,i.src="https://cdn.tailwindcss.com",document.head.appendChild(i)},[])},Gti=e=>e.toLowerCase().includes("pack")?gTe:e.toLowerCase().includes("rout")?QTe:ATe,Rti=({solverEvents:e=[]})=>{const[A,t]=AA.useState(null);Mti();const i=AA.useMemo(()=>{const r=new Map;for(const a of e){const g=`${a.componentName}-${a.solverName}`;r.set(g,a)}return r},[e]),n=AA.useMemo(()=>Array.from(i.keys()),[i]),o=A?i.get(A):null,s=AA.useMemo(()=>{if(!o)return{instance:null,error:null,classFound:!1};const r=ZgA[o.solverName];if(!r)return{instance:null,error:`Solver class "${o.solverName}" not found in SOLVERS registry. Available: ${Object.keys(ZgA).join(", ")}`,classFound:!1};try{const a=o.solverParams,g=a?.input!==void 0?a.input:a;return{instance:new r(g),error:null,classFound:!0}}catch(a){const g=a instanceof Error?a.message:String(a);return console.error("Failed to reconstruct solver:",a),{instance:null,error:`Failed to instantiate solver: ${g}`,classFound:!0}}},[o]);return e.length===0?Z.jsx("div",{className:"rf-p-4",children:Z.jsx("div",{className:"rf-bg-gray-50 rf-rounded-md rf-border rf-border-gray-200",children:Z.jsxs("div",{className:"rf-p-4",children:[Z.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800 rf-mb-3",children:"No Solvers Detected"}),Z.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."})]})})}):Z.jsxs("div",{className:"rf-flex rf-h-full rf-overflow-hidden",children:[Z.jsxs("div",{className:"rf-w-64 rf-border-r rf-border-gray-200 rf-overflow-y-auto rf-flex-shrink-0",children:[Z.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:[n.length," ",n.length===1?"Solver":"Solvers"]}),n.map(r=>{const a=i.get(r),g=A===r;return Z.jsx("div",{className:`rf-px-3 rf-py-2 rf-cursor-pointer rf-border-b rf-border-gray-100 ${g?"rf-bg-blue-50 rf-border-l-2 rf-border-l-blue-500":"hover:rf-bg-gray-50"}`,onClick:()=>t(r),children:(()=>{const c=Gti(a.solverName);return Z.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2",children:[Z.jsx(c,{className:"rf-w-4 rf-h-4 rf-text-blue-500 rf-flex-shrink-0"}),Z.jsxs("div",{className:"rf-flex-1 rf-min-w-0",children:[Z.jsx("div",{className:"rf-text-sm rf-font-medium rf-text-gray-800 rf-truncate",children:a.componentName}),Z.jsx("div",{className:"rf-text-xs rf-text-gray-500 rf-truncate",children:a.solverName})]})]})})()},r)})]}),Z.jsx("div",{className:"rf-flex-1 rf-overflow-hidden",children:o?s.instance?Z.jsx(jD,{fallback:Z.jsx("div",{className:"rf-p-4",children:Z.jsxs("div",{className:"rf-bg-red-50 rf-rounded-md rf-border rf-border-red-200 rf-p-4",children:[Z.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-red-800 rf-mb-2",children:"Error Loading Solver Debugger"}),Z.jsxs("p",{className:"rf-text-sm rf-text-red-600",children:["Failed to render the solver debugger for"," ",o.solverName]})]})}),children:Z.jsx(Fti,{solver:s.instance})}):Z.jsxs("div",{className:"rf-p-4",children:[Z.jsxs("div",{className:"rf-mb-4",children:[Z.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800",children:o.solverName}),Z.jsxs("p",{className:"rf-text-sm rf-text-gray-500",children:["Component: ",o.componentName]})]}),s.error&&Z.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:Z.jsx("p",{className:`rf-text-sm ${s.classFound?"rf-text-red-700":"rf-text-yellow-700"}`,children:s.error})}),Z.jsxs("div",{className:"rf-border rf-border-gray-200 rf-rounded-md rf-overflow-hidden",children:[Z.jsx("div",{className:"rf-px-3 rf-py-2 rf-bg-gray-50",children:Z.jsx("span",{className:"rf-text-sm rf-font-medium rf-text-gray-700",children:"Solver Parameters"})}),Z.jsx("div",{className:"rf-p-3 rf-bg-white rf-border-t rf-border-gray-200",children:Z.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)})})]})]}):Z.jsx("div",{className:"rf-flex rf-items-center rf-justify-center rf-h-full",children:Z.jsx("p",{className:"rf-text-sm rf-text-gray-500",children:"Select a solver from the list to view details"})})})]})},tht=({errorMessage:e,errorStack:A,circuitJsonErrors:t})=>{AA.useEffect(()=>{if(e){const i=new Error(e);A&&(i.stack=A);try{lq.captureException(i)}catch{}}},[e,A]),AA.useEffect(()=>{if(t&&t.length>0)for(const i of t){const n=new Error(i.message||"Circuit JSON Error");i.stack&&(n.stack=i.stack);try{lq.captureException(n,{error_type:i.type})}catch{}}},[t])},eht="0.0.1752",Nti={version:eht},byA={BASE_URL:"/",DEV:!1,MODE:"production",PROD:!0,SSR:!1},xyA=new Map,$j=e=>{const A=xyA.get(e);return A?Object.fromEntries(Object.entries(A.stores).map(([t,i])=>[t,i.getState()])):{}},Lti=(e,A,t)=>{if(e===void 0)return{type:"untracked",connection:A.connect(t)};const i=xyA.get(t.name);if(i)return{type:"tracked",store:e,...i};const n={connection:A.connect(t),stores:{}};return xyA.set(t.name,n),{type:"tracked",store:e,...n}},iht=(e,A={})=>(t,i,n)=>{const{enabled:o,anonymousActionType:s,store:r,...a}=A;let g;try{g=(o??(byA?"production":void 0)!=="production")&&window.__REDUX_DEVTOOLS_EXTENSION__}catch{}if(!g)return(byA?"production":void 0)!=="production"&&o&&console.warn("[zustand devtools middleware] Please install/enable Redux devtools extension"),e(t,i,n);const{connection:c,...I}=Lti(r,g,a);let l=!0;n.setState=(Q,h,E)=>{const u=t(Q,h);if(!l)return u;const d=E===void 0?{type:s||"anonymous"}:typeof E=="string"?{type:E}:E;return r===void 0?(c?.send(d,i()),u):(c?.send({...d,type:`${r}/${d.type}`},{...$j(a.name),[r]:n.getState()}),u)};const B=(...Q)=>{const h=l;l=!1,t(...Q),l=h},C=e(n.setState,i,n);if(I.type==="untracked"?c?.init(C):(I.stores[I.store]=n,c?.init(Object.fromEntries(Object.entries(I.stores).map(([Q,h])=>[Q,Q===I.store?C:h.getState()])))),n.dispatchFromDevtools&&typeof n.dispatch=="function"){let Q=!1;const h=n.dispatch;n.dispatch=(...E)=>{(byA?"production":void 0)!=="production"&&E[0].type==="__setState"&&!Q&&(console.warn('[zustand devtools middleware] "__setState" action type is reserved to set state from the devtools. Avoid using it.'),Q=!0),h(...E)}}return c.subscribe(Q=>{var h;switch(Q.type){case"ACTION":if(typeof Q.payload!="string"){console.error("[zustand devtools middleware] Unsupported action format");return}return _yA(Q.payload,E=>{if(E.type==="__setState"){if(r===void 0){B(E.state);return}Object.keys(E.state).length!==1&&console.error(`
|
|
5689
5689
|
[zustand devtools middleware] Unsupported __setState action format.
|
|
5690
5690
|
When using 'store' option in devtools(), the 'state' should have only one key, which is a value of 'store' that was passed in devtools(),
|
|
5691
5691
|
and value of this only key should be a state object. Example: { "type": "__setState", "state": { "abc123Store": { "foo": "bar" } } }
|
|
@@ -5699,7 +5699,7 @@ You can add a description to the \`${c1}\` by passing a \`${Mht}\` component as
|
|
|
5699
5699
|
|
|
5700
5700
|
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 \`${c1}\`. 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.
|
|
5701
5701
|
|
|
5702
|
-
For more information, see https://radix-ui.com/primitives/docs/components/alert-dialog`;return AA.useEffect(()=>{document.getElementById(e.current?.getAttribute("aria-describedby"))||console.warn(A)},[A,e]),null},pei=bht,fei=xht,Uht=_ht,Hht=kht,Yht=Rht,Jht=Lht,Tht=Fht,Pht=Ght;const Kht=pei,yei=fei,qht=AA.forwardRef(({className:e,...A},t)=>Z.jsx(Uht,{className:bo("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",e),...A,ref:t}));qht.displayName=Uht.displayName;const HyA=AA.forwardRef(({className:e,...A},t)=>Z.jsxs(yei,{children:[Z.jsx(qht,{}),Z.jsx(Hht,{ref:t,className:bo("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",e),...A})]}));HyA.displayName=Hht.displayName;const YyA=({className:e,...A})=>Z.jsx("div",{className:bo("rf-flex rf-flex-col rf-space-y-2 rf-text-center sm:rf-text-left",e),...A});YyA.displayName="AlertDialogHeader";const JyA=({className:e,...A})=>Z.jsx("div",{className:bo("rf-flex rf-flex-col-reverse sm:rf-flex-row sm:rf-justify-end sm:rf-space-x-2",e),...A});JyA.displayName="AlertDialogFooter";const TyA=AA.forwardRef(({className:e,...A},t)=>Z.jsx(Tht,{ref:t,className:bo("rf-text-lg rf-font-semibold",e),...A}));TyA.displayName=Tht.displayName;const PyA=AA.forwardRef(({className:e,...A},t)=>Z.jsx(Pht,{ref:t,className:bo("rf-text-sm rf-text-zinc-500 dark:rf-text-zinc-400",e),...A}));PyA.displayName=Pht.displayName;const mei=AA.forwardRef(({className:e,...A},t)=>Z.jsx(Yht,{ref:t,className:bo(G2(),e),...A}));mei.displayName=Yht.displayName;const KyA=AA.forwardRef(({className:e,...A},t)=>Z.jsx(Jht,{ref:t,className:bo(G2({variant:"outline"}),"rf-mt-2 sm:rf-mt-0",e),...A}));KyA.displayName=Jht.displayName;function wei(e){const A=AA.useRef({value:e,previous:e});return AA.useMemo(()=>(A.current.value!==e&&(A.current.previous=A.current.value,A.current.value=e),A.current.previous),[e])}var ez="Checkbox",[Dei]=HS(ez),[Sei,qyA]=Dei(ez);function bei(e){const{__scopeCheckbox:A,checked:t,children:i,defaultChecked:n,disabled:o,form:s,name:r,onCheckedChange:a,required:g,value:c="on",internal_do_not_use_render:I}=e,[l,B]=pG({prop:t,defaultProp:n??!1,onChange:a,caller:ez}),[C,Q]=AA.useState(null),[h,E]=AA.useState(null),u=AA.useRef(!1),d=C?!!s||!!C.closest("form"):!0,f={checked:l,disabled:o,setChecked:B,control:C,setControl:Q,name:r,form:s,value:c,hasConsumerStoppedPropagationRef:u,required:g,defaultChecked:Hk(n)?!1:n,isFormControl:d,bubbleInput:h,setBubbleInput:E};return Z.jsx(Sei,{scope:A,...f,children:xei(I)?I(f):i})}var Oht="CheckboxTrigger",Wht=AA.forwardRef(({__scopeCheckbox:e,onKeyDown:A,onClick:t,...i},n)=>{const{control:o,value:s,disabled:r,checked:a,required:g,setControl:c,setChecked:I,hasConsumerStoppedPropagationRef:l,isFormControl:B,bubbleInput:C}=qyA(Oht,e),Q=oC(n,c),h=AA.useRef(a);return AA.useEffect(()=>{const E=o?.form;if(E){const u=()=>I(h.current);return E.addEventListener("reset",u),()=>E.removeEventListener("reset",u)}},[o,I]),Z.jsx(fc.button,{type:"button",role:"checkbox","aria-checked":Hk(a)?"mixed":a,"aria-required":g,"data-state":Xht(a),"data-disabled":r?"":void 0,disabled:r,value:s,...i,ref:Q,onKeyDown:Cs(A,E=>{E.key==="Enter"&&E.preventDefault()}),onClick:Cs(t,E=>{I(u=>Hk(u)?!0:!u),C&&B&&(l.current=E.isPropagationStopped(),l.current||E.stopPropagation())})})});Wht.displayName=Oht;var OyA=AA.forwardRef((e,A)=>{const{__scopeCheckbox:t,name:i,checked:n,defaultChecked:o,required:s,disabled:r,value:a,onCheckedChange:g,form:c,...I}=e;return Z.jsx(bei,{__scopeCheckbox:t,checked:n,defaultChecked:o,disabled:r,required:s,onCheckedChange:g,name:i,form:c,value:a,internal_do_not_use_render:({isFormControl:l})=>Z.jsxs(Z.Fragment,{children:[Z.jsx(Wht,{...I,ref:A,__scopeCheckbox:t}),l&&Z.jsx(zht,{__scopeCheckbox:t})]})})});OyA.displayName=ez;var Zht="CheckboxIndicator",Vht=AA.forwardRef((e,A)=>{const{__scopeCheckbox:t,forceMount:i,...n}=e,o=qyA(Zht,t);return Z.jsx(iD,{present:i||Hk(o.checked)||o.checked===!0,children:Z.jsx(fc.span,{"data-state":Xht(o.checked),"data-disabled":o.disabled?"":void 0,...n,ref:A,style:{pointerEvents:"none",...e.style}})})});Vht.displayName=Zht;var jht="CheckboxBubbleInput",zht=AA.forwardRef(({__scopeCheckbox:e,...A},t)=>{const{control:i,hasConsumerStoppedPropagationRef:n,checked:o,defaultChecked:s,required:r,disabled:a,name:g,value:c,form:I,bubbleInput:l,setBubbleInput:B}=qyA(jht,e),C=oC(t,B),Q=wei(o),h=Ast(i);AA.useEffect(()=>{const u=l;if(!u)return;const d=window.HTMLInputElement.prototype,m=Object.getOwnPropertyDescriptor(d,"checked").set,w=!n.current;if(Q!==o&&m){const D=new Event("click",{bubbles:w});u.indeterminate=Hk(o),m.call(u,Hk(o)?!1:o),u.dispatchEvent(D)}},[l,Q,o,n]);const E=AA.useRef(Hk(o)?!1:o);return Z.jsx(fc.input,{type:"checkbox","aria-hidden":!0,defaultChecked:s??E.current,required:r,disabled:a,name:g,value:c,form:I,...A,tabIndex:-1,ref:C,style:{...A.style,...h,position:"absolute",pointerEvents:"none",opacity:0,margin:0,transform:"translateX(-100%)"}})});zht.displayName=jht;function xei(e){return typeof e=="function"}function Hk(e){return e==="indeterminate"}function Xht(e){return Hk(e)?"indeterminate":e?"checked":"unchecked"}const _T=AA.forwardRef(({className:e,...A},t)=>Z.jsx(OyA,{ref:t,className:bo("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",e),...A,children:Z.jsx(Vht,{className:bo("rf-flex rf-items-center rf-justify-center rf-text-current"),children:Z.jsx(EpA,{className:"rf-h-4 rf-w-4"})})}));_T.displayName=OyA.displayName;const kT=mht,_ei=wht,$ht=AA.forwardRef(({className:e,...A},t)=>Z.jsx(RyA,{className:bo("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",e),...A,ref:t}));$ht.displayName=RyA.displayName;const I1=AA.forwardRef(({className:e,children:A,showOverlay:t=!0,...i},n)=>Z.jsxs(_ei,{children:[Z.jsx($ht,{className:bo(t?"":"rf-hidden")}),Z.jsx(NyA,{ref:n,className:bo("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",e),...i,children:A})]}));I1.displayName=NyA.displayName;const l1=({className:e,...A})=>Z.jsx("div",{className:bo("rf-flex rf-flex-col rf-space-y-2 rf-text-center sm:rf-text-left",e),...A});l1.displayName="DialogHeader";const vT=({className:e,...A})=>Z.jsx("div",{className:bo("rf-flex rf-flex-col-reverse sm:rf-flex-row sm:rf-justify-end sm:rf-space-x-2",e),...A});vT.displayName="DialogFooter";const B1=AA.forwardRef(({className:e,...A},t)=>Z.jsx(LyA,{ref:t,className:bo("rf-text-lg rf-font-semibold",e),...A}));B1.displayName=LyA.displayName;const FT=AA.forwardRef(({className:e,...A},t)=>Z.jsx(UyA,{ref:t,className:bo("rf-text-sm rf-text-zinc-500 dark:rf-text-zinc-400",e),...A}));FT.displayName=UyA.displayName;const iz={"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"}},kei="https://cdn.jsdelivr.net/npm/easyeda@latest/dist/browser/index.js";let WyA=null;const vei=async()=>(WyA||(WyA=import(kei)),WyA),Fei=async(e,A=10)=>{const t=encodeURIComponent(e),i=await fetch(`https://jlcsearch.tscircuit.com/api/search?limit=${A}&q=${t}`);if(!i.ok)throw new Error(`JLCPCB API error: ${i.status}`);return(await i.json()).components??[]},Mei=e=>({lcscId:e.lcsc,manufacturer:e.mfr,description:e.description,partNumber:`C${e.lcsc}`,package:e.package,price:e.price,stock:e.stock,isBasic:e.is_basic}),Gei=async(e,A)=>{const{fetchEasyEDAComponent:t,convertRawEasyToTsx:i}=await vei(),n=await t(e,{fetch:(o,s)=>fetch(`${A?.apiBase??$b}/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"]??"",...A?.headers}})});return i(n)},Rei=({query:e,placeholder:A,isSearching:t,onQueryChange:i,onSubmit:n})=>{const o=AA.useCallback(s=>{s.key==="Enter"&&(s.preventDefault(),n())},[n]);return Z.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2 rf-mt-4",children:[Z.jsxs("div",{className:"rf-relative rf-flex-grow",children:[Z.jsx(dot,{className:"rf-absolute rf-left-2 rf-top-2.5 rf-h-4 rf-w-4 rf-text-muted-foreground"}),Z.jsx($fA,{placeholder:A,className:"rf-pl-8",spellCheck:!1,autoComplete:"off",value:e,onChange:s=>i(s.target.value),onKeyDown:o})]}),Z.jsx(oI,{onClick:n,disabled:t||e.trim().length<1,className:"sm:rf-px-4 rf-px-3",children:t?Z.jsx(hk,{className:"rf-h-4 rf-w-4 rf-animate-spin"}):Z.jsxs(Z.Fragment,{children:[Z.jsx(dot,{className:"rf-h-4 rf-w-4 sm:rf-hidden"}),Z.jsx("span",{className:"rf-hidden sm:rf-inline",children:"Search"})]})})]})},Nei=new Intl.NumberFormat("en-US",{style:"currency",currency:"USD"}),Lei=e=>Nei.format(e),AEt=e=>{switch(e.source){case"tscircuit.com":{const A=e.package;return`tscircuit-${A.package_id??`${A.org_owner_tscircuit_handle??"unknown"}-${A.unscoped_name??A.name??"package"}`}`}case"jlcpcb":return`jlc-${e.component.lcscId}`;case"kicad":return`kicad-${e.footprint.path}`;default:return"unknown"}},Uei=e=>{switch(e.source){case"tscircuit.com":return e.package.unscoped_name;case"jlcpcb":return e.component.manufacturer;case"kicad":return e.footprint.qualifiedName}},Hei=e=>{switch(e.source){case"tscircuit.com":return e.package.description||(e.package.org_owner_tscircuit_handle?`Component by ${e.package.org_owner_tscircuit_handle}`:void 0);case"jlcpcb":return e.component.description;case"kicad":return e.footprint.description}},Yei=e=>{switch(e.source){case"tscircuit.com":return e.package.name;case"jlcpcb":return e.component.partNumber;case"kicad":return}},Jei=({results:e,selected:A,onSelect:t,onShowDetails:i})=>{const n=A?AEt(A):null;return Z.jsx("div",{className:"rf-divide-y rf-w-full rf-overflow-hidden",children:e.map(o=>{const s=AEt(o),r=n===s,a=Uei(o),g=Hei(o),c=Yei(o),I=o.source==="jlcpcb"?o.component.stock:null,l=o.source==="jlcpcb"?o.component.price:null,B=o.source==="jlcpcb"?o.component.isBasic:null;return Z.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 ${r?"rf-bg-zinc-100":""}`,onClick:()=>t(o),children:[Z.jsxs("div",{className:"rf-min-w-0 rf-overflow-hidden rf-w-full",children:[Z.jsxs("div",{className:"rf-flex rf-items-start rf-gap-2 rf-min-w-0",children:[Z.jsxs("div",{className:"rf-font-medium rf-text-sm rf-truncate rf-flex-1 rf-min-w-0 rf-flex rf-items-center rf-gap-1.5",children:[a,o.source==="jlcpcb"&&B!=null&&Z.jsx("span",{className:`rf-text-xs rf-px-1.5 rf-py-0.5 rf-rounded rf-font-medium rf-flex-shrink-0 ${B?"rf-bg-green-100 rf-text-green-700":"rf-bg-orange-100 rf-text-orange-700"}`,children:B?"Basic":"Extended"}),o.source==="tscircuit.com"&&o.package.is_private&&Z.jsx(ITe,{className:"rf-ml-1 rf-h-3 rf-w-3 rf-text-zinc-400 rf-flex-shrink-0"})]}),o.source==="jlcpcb"&&I!=null?Z.jsxs("div",{className:"rf-text-xs rf-text-zinc-500 rf-font-medium rf-whitespace-nowrap rf-flex-shrink-0 sm:rf-hidden",children:[I.toLocaleString()," in stock"]}):null]}),Z.jsxs("div",{className:"rf-text-xs rf-text-zinc-500 rf-truncate rf-w-full",children:[c?Z.jsx("span",{className:"rf-mr-2",children:c}):null,g]})]}),Z.jsxs("div",{children:[o.source==="tscircuit.com"&&i?Z.jsx("div",{className:"rf-flex-shrink-0 rf-w-full sm:rf-w-auto",children:Z.jsx(oI,{variant:"outline",size:"sm",className:"rf-text-xs rf-w-full sm:rf-w-auto",onClick:C=>{C.stopPropagation(),i(o)},children:"See Details"})}):o.source==="jlcpcb"&&I!=null?Z.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:[I.toLocaleString()," in stock"]}):null,l!=null&&Z.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:Lei(l)})]})]},s)})})},Tei=({packageResult:e,isOpen:A,onOpenChange:t,isLoading:i,details:n,previewTab:o,onPreviewTabChange:s,isSubmitting:r,onImport:a})=>{const g=e?.package??null,c=g?.latest_pcb_preview_image_url,I=g?.latest_sch_preview_image_url,l=g?.latest_cad_preview_image_url,B=g?.unscoped_name?.split("/").pop()??g?.unscoped_name,C=g?.org_owner_tscircuit_handle??void 0,Q=C?`https://tscircuit.com/${C}`:void 0,h=C&&B?`https://tscircuit.com/${C}/${B}`:void 0;return Z.jsx(kT,{open:A,onOpenChange:t,children:Z.jsxs(I1,{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:[Z.jsx(l1,{className:"rf-pb-4 rf-border-b",children:Z.jsx("div",{className:"rf-flex rf-items-start rf-justify-between rf-gap-4",children:Z.jsxs("div",{className:"rf-flex-1 rf-min-w-0",children:[Z.jsx(B1,{className:"rf-text-xl rf-font-semibold rf-truncate",children:B}),Z.jsx(FT,{children:g?.description})]})})}),Z.jsxs("div",{className:"rf-flex-1 rf-overflow-y-auto rf-py-4 rf-space-y-6",children:[C?Z.jsxs("div",{children:[Z.jsx("span",{className:"rf-text-xs rf-font-medium rf-text-gray-500 rf-uppercase rf-tracking-wide",children:"Created by"}),Z.jsx("div",{className:"rf-mt-1 rf-text-sm rf-font-medium",children:Q?Z.jsx("a",{href:Q,target:"_blank",rel:"noopener noreferrer",className:"rf-text-black hover:rf-underline",children:C}):C})]}):null,(l||c||I)&&Z.jsx(Z.Fragment,{children:Z.jsxs("div",{children:[Z.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-mb-4",children:"Preview"}),Z.jsxs($7,{value:o,onValueChange:E=>s(E),children:[Z.jsxs(Cq,{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:[c&&Z.jsx(sD,{value:"pcb",children:"PCB"}),I&&Z.jsx(sD,{value:"schematic",children:"Schematic"}),l&&Z.jsx(sD,{value:"3d",children:"3D"})]}),Z.jsxs("div",{className:"rf-mt-4",children:[Z.jsx(ju,{value:"pcb",className:"rf-border rf-rounded-lg rf-overflow-hidden rf-bg-gray-50",children:c?Z.jsx("img",{src:c,alt:`${B??"package"} PCB preview`,className:"rf-w-full rf-h-full rf-object-contain rf-bg-white rf-p-4"}):null}),Z.jsx(ju,{value:"schematic",className:"rf-border rf-rounded-lg rf-overflow-hidden rf-bg-gray-50",children:I?Z.jsx("img",{src:I,alt:`${B??"package"} schematic preview`,className:"rf-w-full rf-h-full rf-object-contain rf-bg-white rf-p-4"}):null}),Z.jsx(ju,{value:"3d",className:"rf-border rf-rounded-lg rf-overflow-hidden rf-bg-gray-50",children:l?Z.jsx("img",{src:l,alt:`${B??"package"} 3D preview`,className:"rf-w-full rf-h-full rf-object-contain rf-bg-white rf-p-4"}):null})]})]})]})}),n?.ai_description?Z.jsxs("section",{children:[Z.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-mb-3",children:"AI Description"}),Z.jsx("div",{className:"rf-bg-gray-50 rf-border rf-border-gray-200 rf-rounded-lg rf-p-4",children:Z.jsx("p",{className:"rf-text-sm rf-text-gray-700 rf-leading-relaxed",children:n.ai_description})})]}):null,n?.ai_usage_instructions?Z.jsxs("section",{children:[Z.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-mb-3",children:"Usage Instructions"}),Z.jsx("div",{className:"rf-bg-gray-50 rf-border rf-border-gray-200 rf-rounded-lg rf-p-4",children:Z.jsx("p",{className:"rf-text-sm rf-text-gray-700 rf-leading-relaxed rf-whitespace-pre-wrap",children:n.ai_usage_instructions})})]}):null,i?Z.jsxs("div",{className:"rf-flex rf-justify-center rf-items-center rf-gap-2 rf-text-gray-500",children:[Z.jsx(hk,{className:"rf-h-4 rf-w-4 rf-animate-spin"}),Z.jsx("span",{className:"rf-text-sm",children:"Loading package details..."})]}):null]}),Z.jsxs(vT,{className:"rf-pt-4 rf-border-t rf-flex rf-flex-col sm:rf-flex-row rf-justify-between rf-gap-2",children:[Z.jsx("div",{className:"rf-flex-1",children:h?Z.jsxs(oI,{variant:"outline",size:"sm",className:"rf-gap-2 rf-w-full sm:rf-w-auto",onClick:()=>window.open(h,"_blank"),children:[Z.jsx(rTe,{className:"rf-h-4 rf-w-4"}),"View on tscircuit.com"]}):null}),Z.jsxs("div",{className:"rf-flex rf-flex-col sm:rf-flex-row rf-gap-2",children:[Z.jsx(oI,{variant:"outline",onClick:()=>t(!1),className:"rf-order-2 sm:rf-order-1",children:"Close"}),Z.jsx(oI,{onClick:a,disabled:r,className:"rf-bg-blue-600 hover:rf-bg-blue-700",children:r?Z.jsx(hk,{className:"rf-h-4 rf-w-4 rf-animate-spin"}):"Import Component"})]})]})]})})},Pei=()=>{const[e,A]=AA.useState(null),[t,i]=AA.useState(!1),n=AA.useCallback(async(s,r)=>{i(!0);try{const a=await fetch(`https://api.tscircuit.com/packages/get?name=${encodeURIComponent(`${s}/${r}`)}`);if(!a.ok)throw new Error(`Failed to load package details: ${a.status}`);const g=await a.json();A(g.package??null)}catch(a){console.error("Failed to fetch package details",a),A(null)}finally{i(!1)}},[]),o=AA.useCallback(()=>{A(null),i(!1)},[]);return{details:e,isLoading:t,fetchDetails:n,reset:o}},Kei=async(e,A)=>{const t={"Content-Type":"application/json"};A&&(t.Authorization=`Bearer ${A}`);const i=await fetch("https://registry-api.tscircuit.com/packages/search",{method:"POST",headers:t,body:JSON.stringify({query:e})});if(!i.ok)throw new Error(`tscircuit registry error: ${i.status}`);return(await i.json()).packages??[]},qei=({sessionToken:e})=>{const[A,t]=AA.useState([]),[i,n]=AA.useState(!1),[o,s]=AA.useState(null),[r,a]=AA.useState(!1),g=AA.useCallback(async I=>{const l=I.trim();if(!l)return[];n(!0),s(null);try{const C=(await Kei(l,e)).map(Q=>({source:"tscircuit.com",package:Q}));return t(C),C}catch(B){return console.error("Error searching tscircuit packages",B),t([]),s(B instanceof Error?B.message:"Failed to search tscircuit packages"),[]}finally{n(!1),a(!0)}},[e]),c=AA.useCallback(()=>{t([]),n(!1),s(null),a(!1)},[]);return{results:A,isSearching:i,error:o,hasSearched:r,search:g,reset:c}},Oei=e=>{const A=e.trim();return/^C\d+/i.test(A)?A.replace(/^C/i,""):A},Wei=()=>{const[e,A]=AA.useState([]),[t,i]=AA.useState(!1),[n,o]=AA.useState(null),[s,r]=AA.useState(!1),a=AA.useCallback(async c=>{const I=Oei(c);if(!I)return[];i(!0),o(null);try{const B=(await Fei(I,10)).map(C=>({source:"jlcpcb",component:Mei(C)}));return A(B),B}catch(l){return console.error("Error searching JLCPCB components",l),A([]),o(l instanceof Error?l.message:"Failed to search JLCPCB components"),[]}finally{i(!1),r(!0)}},[]),g=AA.useCallback(()=>{A([]),i(!1),o(null),r(!1)},[]);return{results:e,isSearching:t,error:n,hasSearched:s,search:a,reset:g}};function tx(e){return Array.isArray?Array.isArray(e):iEt(e)==="[object Array]"}function Zei(e){if(typeof e=="string")return e;let A=e+"";return A=="0"&&1/e==-1/0?"-0":A}function Vei(e){return e==null?"":Zei(e)}function QS(e){return typeof e=="string"}function tEt(e){return typeof e=="number"}function jei(e){return e===!0||e===!1||zei(e)&&iEt(e)=="[object Boolean]"}function eEt(e){return typeof e=="object"}function zei(e){return eEt(e)&&e!==null}function ny(e){return e!=null}function ZyA(e){return!e.trim().length}function iEt(e){return e==null?e===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(e)}const Xei="Incorrect 'index' type",$ei=e=>`Invalid value for key ${e}`,Aii=e=>`Pattern length exceeds max of ${e}.`,tii=e=>`Missing ${e} property in key`,eii=e=>`Property 'weight' in key '${e}' must be a positive integer`,nEt=Object.prototype.hasOwnProperty;class iii{constructor(A){this._keys=[],this._keyMap={};let t=0;A.forEach(i=>{let n=oEt(i);this._keys.push(n),this._keyMap[n.id]=n,t+=n.weight}),this._keys.forEach(i=>{i.weight/=t})}get(A){return this._keyMap[A]}keys(){return this._keys}toJSON(){return JSON.stringify(this._keys)}}function oEt(e){let A=null,t=null,i=null,n=1,o=null;if(QS(e)||tx(e))i=e,A=sEt(e),t=VyA(e);else{if(!nEt.call(e,"name"))throw new Error(tii("name"));const s=e.name;if(i=s,nEt.call(e,"weight")&&(n=e.weight,n<=0))throw new Error(eii(s));A=sEt(s),t=VyA(s),o=e.getFn}return{path:A,id:t,weight:n,src:i,getFn:o}}function sEt(e){return tx(e)?e:e.split(".")}function VyA(e){return tx(e)?e.join("."):e}function nii(e,A){let t=[],i=!1;const n=(o,s,r)=>{if(ny(o))if(!s[r])t.push(o);else{let a=s[r];const g=o[a];if(!ny(g))return;if(r===s.length-1&&(QS(g)||tEt(g)||jei(g)))t.push(Vei(g));else if(tx(g)){i=!0;for(let c=0,I=g.length;c<I;c+=1)n(g[c],s,r+1)}else s.length&&n(g,s,r+1)}};return n(e,QS(A)?A.split("."):A,0),i?t:t[0]}var Wo={...{isCaseSensitive:!1,ignoreDiacritics:!1,includeScore:!1,keys:[],shouldSort:!0,sortFn:(e,A)=>e.score===A.score?e.idx<A.idx?-1:1:e.score<A.score?-1:1},...{includeMatches:!1,findAllMatches:!1,minMatchCharLength:1},...{location:0,threshold:.6,distance:100},...{useExtendedSearch:!1,getFn:nii,ignoreLocation:!1,ignoreFieldNorm:!1,fieldNormWeight:1}};const oii=/[^ ]+/g;function sii(e=1,A=3){const t=new Map,i=Math.pow(10,A);return{get(n){const o=n.match(oii).length;if(t.has(o))return t.get(o);const s=1/Math.pow(o,.5*e),r=parseFloat(Math.round(s*i)/i);return t.set(o,r),r},clear(){t.clear()}}}class jyA{constructor({getFn:A=Wo.getFn,fieldNormWeight:t=Wo.fieldNormWeight}={}){this.norm=sii(t,3),this.getFn=A,this.isCreated=!1,this.setIndexRecords()}setSources(A=[]){this.docs=A}setIndexRecords(A=[]){this.records=A}setKeys(A=[]){this.keys=A,this._keysMap={},A.forEach((t,i)=>{this._keysMap[t.id]=i})}create(){this.isCreated||!this.docs.length||(this.isCreated=!0,QS(this.docs[0])?this.docs.forEach((A,t)=>{this._addString(A,t)}):this.docs.forEach((A,t)=>{this._addObject(A,t)}),this.norm.clear())}add(A){const t=this.size();QS(A)?this._addString(A,t):this._addObject(A,t)}removeAt(A){this.records.splice(A,1);for(let t=A,i=this.size();t<i;t+=1)this.records[t].i-=1}getValueForItemAtKeyId(A,t){return A[this._keysMap[t]]}size(){return this.records.length}_addString(A,t){if(!ny(A)||ZyA(A))return;let i={v:A,i:t,n:this.norm.get(A)};this.records.push(i)}_addObject(A,t){let i={i:t,$:{}};this.keys.forEach((n,o)=>{let s=n.getFn?n.getFn(A):this.getFn(A,n.path);if(ny(s)){if(tx(s)){let r=[];const a=[{nestedArrIndex:-1,value:s}];for(;a.length;){const{nestedArrIndex:g,value:c}=a.pop();if(ny(c))if(QS(c)&&!ZyA(c)){let I={v:c,i:g,n:this.norm.get(c)};r.push(I)}else tx(c)&&c.forEach((I,l)=>{a.push({nestedArrIndex:l,value:I})})}i.$[o]=r}else if(QS(s)&&!ZyA(s)){let r={v:s,n:this.norm.get(s)};i.$[o]=r}}}),this.records.push(i)}toJSON(){return{keys:this.keys,records:this.records}}}function rEt(e,A,{getFn:t=Wo.getFn,fieldNormWeight:i=Wo.fieldNormWeight}={}){const n=new jyA({getFn:t,fieldNormWeight:i});return n.setKeys(e.map(oEt)),n.setSources(A),n.create(),n}function rii(e,{getFn:A=Wo.getFn,fieldNormWeight:t=Wo.fieldNormWeight}={}){const{keys:i,records:n}=e,o=new jyA({getFn:A,fieldNormWeight:t});return o.setKeys(i),o.setIndexRecords(n),o}function nz(e,{errors:A=0,currentLocation:t=0,expectedLocation:i=0,distance:n=Wo.distance,ignoreLocation:o=Wo.ignoreLocation}={}){const s=A/e.length;if(o)return s;const r=Math.abs(i-t);return n?s+r/n:r?1:s}function aii(e=[],A=Wo.minMatchCharLength){let t=[],i=-1,n=-1,o=0;for(let s=e.length;o<s;o+=1){let r=e[o];r&&i===-1?i=o:!r&&i!==-1&&(n=o-1,n-i+1>=A&&t.push([i,n]),i=-1)}return e[o-1]&&o-i>=A&&t.push([i,o-1]),t}const vM=32;function gii(e,A,t,{location:i=Wo.location,distance:n=Wo.distance,threshold:o=Wo.threshold,findAllMatches:s=Wo.findAllMatches,minMatchCharLength:r=Wo.minMatchCharLength,includeMatches:a=Wo.includeMatches,ignoreLocation:g=Wo.ignoreLocation}={}){if(A.length>vM)throw new Error(Aii(vM));const c=A.length,I=e.length,l=Math.max(0,Math.min(i,I));let B=o,C=l;const Q=r>1||a,h=Q?Array(I):[];let E;for(;(E=e.indexOf(A,C))>-1;){let D=nz(A,{currentLocation:E,expectedLocation:l,distance:n,ignoreLocation:g});if(B=Math.min(D,B),C=E+c,Q){let S=0;for(;S<c;)h[E+S]=1,S+=1}}C=-1;let u=[],d=1,f=c+I;const m=1<<c-1;for(let D=0;D<c;D+=1){let S=0,_=f;for(;S<_;)nz(A,{errors:D,currentLocation:l+_,expectedLocation:l,distance:n,ignoreLocation:g})<=B?S=_:f=_,_=Math.floor((f-S)/2+S);f=_;let b=Math.max(1,l-_+1),R=s?I:Math.min(l+_,I)+c,F=Array(R+2);F[R+1]=(1<<D)-1;for(let Y=R;Y>=b;Y-=1){let J=Y-1,O=t[e.charAt(J)];if(Q&&(h[J]=+!!O),F[Y]=(F[Y+1]<<1|1)&O,D&&(F[Y]|=(u[Y+1]|u[Y])<<1|1|u[Y+1]),F[Y]&m&&(d=nz(A,{errors:D,currentLocation:J,expectedLocation:l,distance:n,ignoreLocation:g}),d<=B)){if(B=d,C=J,C<=l)break;b=Math.max(1,2*l-C)}}if(nz(A,{errors:D+1,currentLocation:l,expectedLocation:l,distance:n,ignoreLocation:g})>B)break;u=F}const w={isMatch:C>=0,score:Math.max(.001,d)};if(Q){const D=aii(h,r);D.length?a&&(w.indices=D):w.isMatch=!1}return w}function cii(e){let A={};for(let t=0,i=e.length;t<i;t+=1){const n=e.charAt(t);A[n]=(A[n]||0)|1<<i-t-1}return A}const oz=String.prototype.normalize?(e=>e.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,"")):(e=>e);class aEt{constructor(A,{location:t=Wo.location,threshold:i=Wo.threshold,distance:n=Wo.distance,includeMatches:o=Wo.includeMatches,findAllMatches:s=Wo.findAllMatches,minMatchCharLength:r=Wo.minMatchCharLength,isCaseSensitive:a=Wo.isCaseSensitive,ignoreDiacritics:g=Wo.ignoreDiacritics,ignoreLocation:c=Wo.ignoreLocation}={}){if(this.options={location:t,threshold:i,distance:n,includeMatches:o,findAllMatches:s,minMatchCharLength:r,isCaseSensitive:a,ignoreDiacritics:g,ignoreLocation:c},A=a?A:A.toLowerCase(),A=g?oz(A):A,this.pattern=A,this.chunks=[],!this.pattern.length)return;const I=(B,C)=>{this.chunks.push({pattern:B,alphabet:cii(B),startIndex:C})},l=this.pattern.length;if(l>vM){let B=0;const C=l%vM,Q=l-C;for(;B<Q;)I(this.pattern.substr(B,vM),B),B+=vM;if(C){const h=l-vM;I(this.pattern.substr(h),h)}}else I(this.pattern,0)}searchIn(A){const{isCaseSensitive:t,ignoreDiacritics:i,includeMatches:n}=this.options;if(A=t?A:A.toLowerCase(),A=i?oz(A):A,this.pattern===A){let Q={isMatch:!0,score:0};return n&&(Q.indices=[[0,A.length-1]]),Q}const{location:o,distance:s,threshold:r,findAllMatches:a,minMatchCharLength:g,ignoreLocation:c}=this.options;let I=[],l=0,B=!1;this.chunks.forEach(({pattern:Q,alphabet:h,startIndex:E})=>{const{isMatch:u,score:d,indices:f}=gii(A,Q,h,{location:o+E,distance:s,threshold:r,findAllMatches:a,minMatchCharLength:g,includeMatches:n,ignoreLocation:c});u&&(B=!0),l+=d,u&&f&&(I=[...I,...f])});let C={isMatch:B,score:B?l/this.chunks.length:1};return B&&n&&(C.indices=I),C}}class Yk{constructor(A){this.pattern=A}static isMultiMatch(A){return gEt(A,this.multiRegex)}static isSingleMatch(A){return gEt(A,this.singleRegex)}search(){}}function gEt(e,A){const t=e.match(A);return t?t[1]:null}class Iii extends Yk{constructor(A){super(A)}static get type(){return"exact"}static get multiRegex(){return/^="(.*)"$/}static get singleRegex(){return/^=(.*)$/}search(A){const t=A===this.pattern;return{isMatch:t,score:t?0:1,indices:[0,this.pattern.length-1]}}}class lii extends Yk{constructor(A){super(A)}static get type(){return"inverse-exact"}static get multiRegex(){return/^!"(.*)"$/}static get singleRegex(){return/^!(.*)$/}search(A){const i=A.indexOf(this.pattern)===-1;return{isMatch:i,score:i?0:1,indices:[0,A.length-1]}}}class Bii extends Yk{constructor(A){super(A)}static get type(){return"prefix-exact"}static get multiRegex(){return/^\^"(.*)"$/}static get singleRegex(){return/^\^(.*)$/}search(A){const t=A.startsWith(this.pattern);return{isMatch:t,score:t?0:1,indices:[0,this.pattern.length-1]}}}class Cii extends Yk{constructor(A){super(A)}static get type(){return"inverse-prefix-exact"}static get multiRegex(){return/^!\^"(.*)"$/}static get singleRegex(){return/^!\^(.*)$/}search(A){const t=!A.startsWith(this.pattern);return{isMatch:t,score:t?0:1,indices:[0,A.length-1]}}}class Qii extends Yk{constructor(A){super(A)}static get type(){return"suffix-exact"}static get multiRegex(){return/^"(.*)"\$$/}static get singleRegex(){return/^(.*)\$$/}search(A){const t=A.endsWith(this.pattern);return{isMatch:t,score:t?0:1,indices:[A.length-this.pattern.length,A.length-1]}}}class hii extends Yk{constructor(A){super(A)}static get type(){return"inverse-suffix-exact"}static get multiRegex(){return/^!"(.*)"\$$/}static get singleRegex(){return/^!(.*)\$$/}search(A){const t=!A.endsWith(this.pattern);return{isMatch:t,score:t?0:1,indices:[0,A.length-1]}}}class cEt extends Yk{constructor(A,{location:t=Wo.location,threshold:i=Wo.threshold,distance:n=Wo.distance,includeMatches:o=Wo.includeMatches,findAllMatches:s=Wo.findAllMatches,minMatchCharLength:r=Wo.minMatchCharLength,isCaseSensitive:a=Wo.isCaseSensitive,ignoreDiacritics:g=Wo.ignoreDiacritics,ignoreLocation:c=Wo.ignoreLocation}={}){super(A),this._bitapSearch=new aEt(A,{location:t,threshold:i,distance:n,includeMatches:o,findAllMatches:s,minMatchCharLength:r,isCaseSensitive:a,ignoreDiacritics:g,ignoreLocation:c})}static get type(){return"fuzzy"}static get multiRegex(){return/^"(.*)"$/}static get singleRegex(){return/^(.*)$/}search(A){return this._bitapSearch.searchIn(A)}}class IEt extends Yk{constructor(A){super(A)}static get type(){return"include"}static get multiRegex(){return/^'"(.*)"$/}static get singleRegex(){return/^'(.*)$/}search(A){let t=0,i;const n=[],o=this.pattern.length;for(;(i=A.indexOf(this.pattern,t))>-1;)t=i+o,n.push([i,t-1]);const s=!!n.length;return{isMatch:s,score:s?0:1,indices:n}}}const zyA=[Iii,IEt,Bii,Cii,hii,Qii,lii,cEt],lEt=zyA.length,Eii=/ +(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/,uii="|";function dii(e,A={}){return e.split(uii).map(t=>{let i=t.trim().split(Eii).filter(o=>o&&!!o.trim()),n=[];for(let o=0,s=i.length;o<s;o+=1){const r=i[o];let a=!1,g=-1;for(;!a&&++g<lEt;){const c=zyA[g];let I=c.isMultiMatch(r);I&&(n.push(new c(I,A)),a=!0)}if(!a)for(g=-1;++g<lEt;){const c=zyA[g];let I=c.isSingleMatch(r);if(I){n.push(new c(I,A));break}}}return n})}const pii=new Set([cEt.type,IEt.type]);class fii{constructor(A,{isCaseSensitive:t=Wo.isCaseSensitive,ignoreDiacritics:i=Wo.ignoreDiacritics,includeMatches:n=Wo.includeMatches,minMatchCharLength:o=Wo.minMatchCharLength,ignoreLocation:s=Wo.ignoreLocation,findAllMatches:r=Wo.findAllMatches,location:a=Wo.location,threshold:g=Wo.threshold,distance:c=Wo.distance}={}){this.query=null,this.options={isCaseSensitive:t,ignoreDiacritics:i,includeMatches:n,minMatchCharLength:o,findAllMatches:r,ignoreLocation:s,location:a,threshold:g,distance:c},A=t?A:A.toLowerCase(),A=i?oz(A):A,this.pattern=A,this.query=dii(this.pattern,this.options)}static condition(A,t){return t.useExtendedSearch}searchIn(A){const t=this.query;if(!t)return{isMatch:!1,score:1};const{includeMatches:i,isCaseSensitive:n,ignoreDiacritics:o}=this.options;A=n?A:A.toLowerCase(),A=o?oz(A):A;let s=0,r=[],a=0;for(let g=0,c=t.length;g<c;g+=1){const I=t[g];r.length=0,s=0;for(let l=0,B=I.length;l<B;l+=1){const C=I[l],{isMatch:Q,indices:h,score:E}=C.search(A);if(Q){if(s+=1,a+=E,i){const u=C.constructor.type;pii.has(u)?r=[...r,...h]:r.push(h)}}else{a=0,s=0,r.length=0;break}}if(s){let l={isMatch:!0,score:a/s};return i&&(l.indices=r),l}}return{isMatch:!1,score:1}}}const XyA=[];function yii(...e){XyA.push(...e)}function $yA(e,A){for(let t=0,i=XyA.length;t<i;t+=1){let n=XyA[t];if(n.condition(e,A))return new n(e,A)}return new aEt(e,A)}const sz={AND:"$and",OR:"$or"},AmA={PATH:"$path",PATTERN:"$val"},tmA=e=>!!(e[sz.AND]||e[sz.OR]),mii=e=>!!e[AmA.PATH],wii=e=>!tx(e)&&eEt(e)&&!tmA(e),BEt=e=>({[sz.AND]:Object.keys(e).map(A=>({[A]:e[A]}))});function CEt(e,A,{auto:t=!0}={}){const i=n=>{let o=Object.keys(n);const s=mii(n);if(!s&&o.length>1&&!tmA(n))return i(BEt(n));if(wii(n)){const a=s?n[AmA.PATH]:o[0],g=s?n[AmA.PATTERN]:n[a];if(!QS(g))throw new Error($ei(a));const c={keyId:VyA(a),pattern:g};return t&&(c.searcher=$yA(g,A)),c}let r={children:[],operator:o[0]};return o.forEach(a=>{const g=n[a];tx(g)&&g.forEach(c=>{r.children.push(i(c))})}),r};return tmA(e)||(e=BEt(e)),i(e)}function Dii(e,{ignoreFieldNorm:A=Wo.ignoreFieldNorm}){e.forEach(t=>{let i=1;t.matches.forEach(({key:n,norm:o,score:s})=>{const r=n?n.weight:null;i*=Math.pow(s===0&&r?Number.EPSILON:s,(r||1)*(A?1:o))}),t.score=i})}function Sii(e,A){const t=e.matches;A.matches=[],ny(t)&&t.forEach(i=>{if(!ny(i.indices)||!i.indices.length)return;const{indices:n,value:o}=i;let s={indices:n,value:o};i.key&&(s.key=i.key.src),i.idx>-1&&(s.refIndex=i.idx),A.matches.push(s)})}function bii(e,A){A.score=e.score}function xii(e,A,{includeMatches:t=Wo.includeMatches,includeScore:i=Wo.includeScore}={}){const n=[];return t&&n.push(Sii),i&&n.push(bii),e.map(o=>{const{idx:s}=o,r={item:A[s],refIndex:s};return n.length&&n.forEach(a=>{a(o,r)}),r})}class C1{constructor(A,t={},i){this.options={...Wo,...t},this.options.useExtendedSearch,this._keyStore=new iii(this.options.keys),this.setCollection(A,i)}setCollection(A,t){if(this._docs=A,t&&!(t instanceof jyA))throw new Error(Xei);this._myIndex=t||rEt(this.options.keys,this._docs,{getFn:this.options.getFn,fieldNormWeight:this.options.fieldNormWeight})}add(A){ny(A)&&(this._docs.push(A),this._myIndex.add(A))}remove(A=()=>!1){const t=[];for(let i=0,n=this._docs.length;i<n;i+=1){const o=this._docs[i];A(o,i)&&(this.removeAt(i),i-=1,n-=1,t.push(o))}return t}removeAt(A){this._docs.splice(A,1),this._myIndex.removeAt(A)}getIndex(){return this._myIndex}search(A,{limit:t=-1}={}){const{includeMatches:i,includeScore:n,shouldSort:o,sortFn:s,ignoreFieldNorm:r}=this.options;let a=QS(A)?QS(this._docs[0])?this._searchStringList(A):this._searchObjectList(A):this._searchLogical(A);return Dii(a,{ignoreFieldNorm:r}),o&&a.sort(s),tEt(t)&&t>-1&&(a=a.slice(0,t)),xii(a,this._docs,{includeMatches:i,includeScore:n})}_searchStringList(A){const t=$yA(A,this.options),{records:i}=this._myIndex,n=[];return i.forEach(({v:o,i:s,n:r})=>{if(!ny(o))return;const{isMatch:a,score:g,indices:c}=t.searchIn(o);a&&n.push({item:o,idx:s,matches:[{score:g,value:o,norm:r,indices:c}]})}),n}_searchLogical(A){const t=CEt(A,this.options),i=(r,a,g)=>{if(!r.children){const{keyId:I,searcher:l}=r,B=this._findMatches({key:this._keyStore.get(I),value:this._myIndex.getValueForItemAtKeyId(a,I),searcher:l});return B&&B.length?[{idx:g,item:a,matches:B}]:[]}const c=[];for(let I=0,l=r.children.length;I<l;I+=1){const B=r.children[I],C=i(B,a,g);if(C.length)c.push(...C);else if(r.operator===sz.AND)return[]}return c},n=this._myIndex.records,o={},s=[];return n.forEach(({$:r,i:a})=>{if(ny(r)){let g=i(t,r,a);g.length&&(o[a]||(o[a]={idx:a,item:r,matches:[]},s.push(o[a])),g.forEach(({matches:c})=>{o[a].matches.push(...c)}))}}),s}_searchObjectList(A){const t=$yA(A,this.options),{keys:i,records:n}=this._myIndex,o=[];return n.forEach(({$:s,i:r})=>{if(!ny(s))return;let a=[];i.forEach((g,c)=>{a.push(...this._findMatches({key:g,value:s[c],searcher:t}))}),a.length&&o.push({idx:r,item:s,matches:a})}),o}_findMatches({key:A,value:t,searcher:i}){if(!ny(t))return[];let n=[];if(tx(t))t.forEach(({v:o,i:s,n:r})=>{if(!ny(o))return;const{isMatch:a,score:g,indices:c}=i.searchIn(o);a&&n.push({score:g,key:A,value:o,idx:s,norm:r,indices:c})});else{const{v:o,n:s}=t,{isMatch:r,score:a,indices:g}=i.searchIn(o);r&&n.push({score:a,key:A,value:o,norm:s,indices:g})}return n}}C1.version="7.1.0",C1.createIndex=rEt,C1.parseIndex=rii,C1.config=Wo,C1.parseQuery=CEt,yii(fii);let emA=null,MT=null,imA=null;const _ii=async()=>emA||MT||(MT=fetch("https://kicad-mod-cache.tscircuit.com/kicad_files.json").then(e=>e.json()).then(e=>(emA=e,MT=null,e)),MT),kii=async(e,A=20)=>{const t=await _ii();return imA||(imA=new C1(t)),imA.search(e).slice(0,A).map(i=>i.item)},vii=e=>{const A=e.replace(".pretty/",":").replace(".kicad_mod",""),t=`kicad:${A}`;return{path:e,qualifiedName:t,description:A}},Fii=()=>{const[e,A]=AA.useState([]),[t,i]=AA.useState(!1),[n,o]=AA.useState(null),[s,r]=AA.useState(!1),a=AA.useCallback(async c=>{const I=c.trim();if(!I)return[];i(!0),o(null);try{const B=(await kii(I,20)).map(C=>({source:"kicad",footprint:vii(C)}));return A(B),B}catch(l){return console.error("Error searching KiCad footprints",l),A([]),o(l instanceof Error?l.message:"Failed to search KiCad footprints"),[]}finally{i(!1),r(!0)}},[]),g=AA.useCallback(()=>{A([]),i(!1),o(null),r(!1)},[]);return{results:e,isSearching:t,error:n,hasSearched:s,search:a,reset:g}},Mii={dialog:101},Gii=({onTscircuitPackageSelected:e,onJlcpcbComponentTsxLoaded:A,onKicadStringSelected:t})=>{const i=[];return e&&i.push("tscircuit.com"),A&&i.push("jlcpcb"),t&&i.push("kicad"),i},Rii=({isOpen:e,onClose:A,jlcpcbProxyRequestHeaders:t,onKicadStringSelected:i,onTscircuitPackageSelected:n,onJlcpcbComponentTsxLoaded:o,jlcpcbProxyApiBase:s,tscircuitSessionToken:r})=>{qQt();const a=AA.useMemo(()=>Gii({onKicadStringSelected:i,onTscircuitPackageSelected:n,onJlcpcbComponentTsxLoaded:o}),[i,n,o]),g=a.length>0,c=a.length===1,[I,l]=AA.useState(a[0]??"tscircuit.com"),[B,C]=AA.useState(""),[Q,h]=AA.useState(null),{results:E,isSearching:u,error:d,hasSearched:f,search:m,reset:w}=qei({sessionToken:r}),{results:D,isSearching:S,error:_,hasSearched:b,search:R,reset:F}=Wei(),{results:H,isSearching:Y,error:J,hasSearched:O,search:W,reset:z}=Fii(),{details:tA,isLoading:aA,fetchDetails:eA,reset:oA}=Pei(),[rA,lA]=AA.useState(null),[pA,kA]=AA.useState(!1),[MA,YA]=AA.useState("pcb"),[EA,xA]=AA.useState(null),[dA,WA]=AA.useState(!1);AA.useEffect(()=>{xA(null)},[Q]);const jA=AA.useCallback(()=>{w(),F(),z(),h(null)},[F,z,w]);AA.useEffect(()=>{e||(jA(),C(""),kA(!1),lA(null),xA(null))},[e,jA]),AA.useEffect(()=>{C(""),h(null),I==="tscircuit.com"?w():I==="jlcpcb"?F():I==="kicad"&&z()},[I,F,z,w]);const It=KA=>{h(KA),lA(KA),YA("pcb"),kA(!0),oA();const ZA=KA.package.org_owner_tscircuit_handle,nt=KA.package.unscoped_name;if(ZA&&nt){const SA=nt.split("/").pop()??nt;eA(ZA,SA)}},mA=async()=>{B.trim()&&(h(null),I==="tscircuit.com"?await m(B):I==="jlcpcb"?await R(B):I==="kicad"&&await W(B))},gt=async KA=>{try{if(xA(null),WA(!0),KA.source==="kicad"){if(!i)throw new Error("KiCad handler not provided");await i({result:KA,footprint:KA.footprint.qualifiedName})}else if(KA.source==="jlcpcb"){if(!o)throw new Error("JLCPCB handler not provided");const ZA=await Gei(KA.component.partNumber,{headers:t,apiBase:s});await o({result:KA,tsx:ZA})}else if(KA.source==="tscircuit.com"){if(!n)throw new Error("tscircuit package handler not provided");const ZA=KA.package.org_owner_tscircuit_handle,nt=KA.package.unscoped_name;if(!ZA||!nt)throw new Error("Missing package metadata");const SA=nt.split("/").pop()??nt,CA=`@tsci/${ZA}.${SA}`;await n({result:KA,fullPackageName:CA})}return!0}catch(ZA){return console.error("Failed to import component",ZA),xA(ZA instanceof Error?ZA.message:"Failed to import component"),!1}finally{WA(!1)}};let VA=[],JA=!1,OA=null,_A=!1;I==="tscircuit.com"?(VA=E,JA=u,OA=d,_A=f):I==="jlcpcb"?(VA=D,JA=S,OA=_,_A=b):I==="kicad"&&(VA=H,JA=Y,OA=J,_A=O);const DA=async()=>{if(!Q)return;await gt(Q)&&(A(),jA(),C(""))},NA=KA=>{KA||A()},FA=KA=>{kA(KA),KA||lA(null)};return Z.jsxs(kT,{open:e,onOpenChange:NA,children:[Z.jsxs(I1,{style:{width:"calc(100vw - 2rem)",zIndex:Mii.dialog},className:"rf-rounded-sm rf-max-h-[90vh] rf-overflow-y-auto rf-overflow-x-hidden rf-flex rf-flex-col",children:[Z.jsxs(l1,{children:[Z.jsxs(B1,{className:"rf-text-lg sm:rf-text-xl",children:["Import ",c?iz[I].label:""," ","Component"]}),Z.jsx(FT,{className:"rf-text-sm",children:g?"Search for components from available sources.":"Import options are disabled because no handlers were provided."})]}),g?Z.jsxs($7,{value:I,onValueChange:KA=>l(KA),className:"rf-min-w-0 rf-w-full",children:[!c&&Z.jsx(Cq,{className:"rf-flex rf-w-full rf-gap-2",children:a.map(KA=>Z.jsx(sD,{value:KA,className:"rf-flex-1 rf-text-xs sm:rf-text-sm",children:iz[KA].label},KA))}),Z.jsx(Rei,{query:B,placeholder:iz[I].placeholder,isSearching:JA,onQueryChange:C,onSubmit:mA}),Z.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:JA?Z.jsxs("div",{className:"rf-p-8 rf-text-center rf-text-zinc-500",children:[Z.jsx(hk,{className:"rf-h-8 rf-w-8 rf-animate-spin rf-mx-auto rf-mb-2"}),Z.jsx("p",{children:"Searching..."})]}):VA.length>0?Z.jsx(Jei,{results:VA,selected:Q,onSelect:h,onShowDetails:I==="tscircuit.com"?It:void 0}):Z.jsx("div",{className:"rf-p-8 rf-text-center rf-text-zinc-500",children:OA?`Error: ${OA}`:_A?iz[I].emptyMessage:"Enter a search term to find components"})})]}):null,EA?Z.jsx("div",{className:"rf-text-sm rf-text-red-600 rf-mt-2",children:EA}):null,Z.jsxs(vT,{className:"rf-flex rf-flex-col sm:rf-flex-row rf-gap-2",children:[Z.jsx(oI,{variant:"outline",onClick:A,className:"rf-order-2 sm:rf-order-1",children:"Cancel"}),Z.jsx(oI,{onClick:DA,disabled:!Q||dA,className:"rf-order-1 sm:rf-order-2",children:dA?Z.jsx(hk,{className:"rf-h-4 rf-w-4 rf-animate-spin"}):"Import"})]})]}),Z.jsx(Tei,{packageResult:rA,isOpen:pA,onOpenChange:FA,isLoading:aA,details:tA,previewTab:MA,onPreviewTabChange:KA=>YA(KA),isSubmitting:dA,onImport:()=>{rA&>(rA).then(KA=>{KA&&(kA(!1),A(),jA(),C(""))})}})]})},Nii=e=>{const A=e.match(/export const (\w+) =/);if(!A)throw new Error("Could not determine component name from TSX contents");return A[1]},QEt=e=>{const A=CS(s=>s.pushEvent),t=CS(s=>s.upsertFile),i=async({result:s,fullPackageName:r})=>{const g=s.package.unscoped_name??s.package.name;await Zs.promise(A({event_type:"INSTALL_PACKAGE",full_package_name:r}),{loading:`Requesting install for "${g}"`,success:`Install requested for "${g}"`,error:c=>`Failed to request install: ${c instanceof Error?c.message:String(c)}`})},n=async({footprint:s})=>{await Zs.promise(navigator.clipboard.writeText(s),{loading:`Copying "${s}"`,success:`Copied "${s}" to clipboard`,error:r=>`Failed to copy footprint: ${r instanceof Error?r.message:String(r)}`})},o=async({result:s,tsx:r})=>{const g=`imports/${Nii(r)}.tsx`;await Zs.promise(t(g,r),{loading:`Importing ${s.component.partNumber}`,success:`Imported to "${g}"`,error:c=>`Failed to import component: ${c instanceof Error?c.message:String(c)}`})};return Z.jsx(Rii,{...e,onTscircuitPackageSelected:i,onKicadStringSelected:n,onJlcpcbComponentTsxLoaded:o})};QEt.displayName="ImportComponentDialogForCli";var nmA={exports:{}},hEt;function Lii(){return hEt||(hEt=1,(function(e,A){var t={env:{},version:""};(function(i){e.exports=i()})(function(){return(function i(n,o,s){function r(c,I){if(!o[c]){if(!n[c]){var l=typeof w_=="function"&&w_;if(!I&&l)return l(c,!0);if(a)return a(c,!0);var B=new Error("Cannot find module '"+c+"'");throw B.code="MODULE_NOT_FOUND",B}var C=o[c]={exports:{}};n[c][0].call(C.exports,function(Q){var h=n[c][1][Q];return r(h||Q)},C,C.exports,i,n,o,s)}return o[c].exports}for(var a=typeof w_=="function"&&w_,g=0;g<s.length;g++)r(s[g]);return r})({1:[function(i,n,o){var s=i("./utils"),r=i("./support"),a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";o.encode=function(g){for(var c,I,l,B,C,Q,h,E=[],u=0,d=g.length,f=d,m=s.getTypeOf(g)!=="string";u<g.length;)f=d-u,l=m?(c=g[u++],I=u<d?g[u++]:0,u<d?g[u++]:0):(c=g.charCodeAt(u++),I=u<d?g.charCodeAt(u++):0,u<d?g.charCodeAt(u++):0),B=c>>2,C=(3&c)<<4|I>>4,Q=1<f?(15&I)<<2|l>>6:64,h=2<f?63&l:64,E.push(a.charAt(B)+a.charAt(C)+a.charAt(Q)+a.charAt(h));return E.join("")},o.decode=function(g){var c,I,l,B,C,Q,h=0,E=0,u="data:";if(g.substr(0,u.length)===u)throw new Error("Invalid base64 input, it looks like a data url.");var d,f=3*(g=g.replace(/[^A-Za-z0-9+/=]/g,"")).length/4;if(g.charAt(g.length-1)===a.charAt(64)&&f--,g.charAt(g.length-2)===a.charAt(64)&&f--,f%1!=0)throw new Error("Invalid base64 input, bad content length.");for(d=r.uint8array?new Uint8Array(0|f):new Array(0|f);h<g.length;)c=a.indexOf(g.charAt(h++))<<2|(B=a.indexOf(g.charAt(h++)))>>4,I=(15&B)<<4|(C=a.indexOf(g.charAt(h++)))>>2,l=(3&C)<<6|(Q=a.indexOf(g.charAt(h++))),d[E++]=c,C!==64&&(d[E++]=I),Q!==64&&(d[E++]=l);return d}},{"./support":30,"./utils":32}],2:[function(i,n,o){var s=i("./external"),r=i("./stream/DataWorker"),a=i("./stream/Crc32Probe"),g=i("./stream/DataLengthProbe");function c(I,l,B,C,Q){this.compressedSize=I,this.uncompressedSize=l,this.crc32=B,this.compression=C,this.compressedContent=Q}c.prototype={getContentWorker:function(){var I=new r(s.Promise.resolve(this.compressedContent)).pipe(this.compression.uncompressWorker()).pipe(new g("data_length")),l=this;return I.on("end",function(){if(this.streamInfo.data_length!==l.uncompressedSize)throw new Error("Bug : uncompressed data size mismatch")}),I},getCompressedWorker:function(){return new r(s.Promise.resolve(this.compressedContent)).withStreamInfo("compressedSize",this.compressedSize).withStreamInfo("uncompressedSize",this.uncompressedSize).withStreamInfo("crc32",this.crc32).withStreamInfo("compression",this.compression)}},c.createWorkerFrom=function(I,l,B){return I.pipe(new a).pipe(new g("uncompressedSize")).pipe(l.compressWorker(B)).pipe(new g("compressedSize")).withStreamInfo("compression",l)},n.exports=c},{"./external":6,"./stream/Crc32Probe":25,"./stream/DataLengthProbe":26,"./stream/DataWorker":27}],3:[function(i,n,o){var s=i("./stream/GenericWorker");o.STORE={magic:"\0\0",compressWorker:function(){return new s("STORE compression")},uncompressWorker:function(){return new s("STORE decompression")}},o.DEFLATE=i("./flate")},{"./flate":7,"./stream/GenericWorker":28}],4:[function(i,n,o){var s=i("./utils"),r=(function(){for(var a,g=[],c=0;c<256;c++){a=c;for(var I=0;I<8;I++)a=1&a?3988292384^a>>>1:a>>>1;g[c]=a}return g})();n.exports=function(a,g){return a!==void 0&&a.length?s.getTypeOf(a)!=="string"?(function(c,I,l,B){var C=r,Q=B+l;c^=-1;for(var h=B;h<Q;h++)c=c>>>8^C[255&(c^I[h])];return-1^c})(0|g,a,a.length,0):(function(c,I,l,B){var C=r,Q=B+l;c^=-1;for(var h=B;h<Q;h++)c=c>>>8^C[255&(c^I.charCodeAt(h))];return-1^c})(0|g,a,a.length,0):0}},{"./utils":32}],5:[function(i,n,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(i,n,o){var s=null;s=typeof Promise<"u"?Promise:i("lie"),n.exports={Promise:s}},{lie:37}],7:[function(i,n,o){var s=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Uint32Array<"u",r=i("pako"),a=i("./utils"),g=i("./stream/GenericWorker"),c=s?"uint8array":"array";function I(l,B){g.call(this,"FlateWorker/"+l),this._pako=null,this._pakoAction=l,this._pakoOptions=B,this.meta={}}o.magic="\b\0",a.inherits(I,g),I.prototype.processChunk=function(l){this.meta=l.meta,this._pako===null&&this._createPako(),this._pako.push(a.transformTo(c,l.data),!1)},I.prototype.flush=function(){g.prototype.flush.call(this),this._pako===null&&this._createPako(),this._pako.push([],!0)},I.prototype.cleanUp=function(){g.prototype.cleanUp.call(this),this._pako=null},I.prototype._createPako=function(){this._pako=new r[this._pakoAction]({raw:!0,level:this._pakoOptions.level||-1});var l=this;this._pako.onData=function(B){l.push({data:B,meta:l.meta})}},o.compressWorker=function(l){return new I("Deflate",l)},o.uncompressWorker=function(){return new I("Inflate",{})}},{"./stream/GenericWorker":28,"./utils":32,pako:38}],8:[function(i,n,o){function s(C,Q){var h,E="";for(h=0;h<Q;h++)E+=String.fromCharCode(255&C),C>>>=8;return E}function r(C,Q,h,E,u,d){var f,m,w=C.file,D=C.compression,S=d!==c.utf8encode,_=a.transformTo("string",d(w.name)),b=a.transformTo("string",c.utf8encode(w.name)),R=w.comment,F=a.transformTo("string",d(R)),H=a.transformTo("string",c.utf8encode(R)),Y=b.length!==w.name.length,J=H.length!==R.length,O="",W="",z="",tA=w.dir,aA=w.date,eA={crc32:0,compressedSize:0,uncompressedSize:0};Q&&!h||(eA.crc32=C.crc32,eA.compressedSize=C.compressedSize,eA.uncompressedSize=C.uncompressedSize);var oA=0;Q&&(oA|=8),S||!Y&&!J||(oA|=2048);var rA=0,lA=0;tA&&(rA|=16),u==="UNIX"?(lA=798,rA|=(function(kA,MA){var YA=kA;return kA||(YA=MA?16893:33204),(65535&YA)<<16})(w.unixPermissions,tA)):(lA=20,rA|=(function(kA){return 63&(kA||0)})(w.dosPermissions)),f=aA.getUTCHours(),f<<=6,f|=aA.getUTCMinutes(),f<<=5,f|=aA.getUTCSeconds()/2,m=aA.getUTCFullYear()-1980,m<<=4,m|=aA.getUTCMonth()+1,m<<=5,m|=aA.getUTCDate(),Y&&(W=s(1,1)+s(I(_),4)+b,O+="up"+s(W.length,2)+W),J&&(z=s(1,1)+s(I(F),4)+H,O+="uc"+s(z.length,2)+z);var pA="";return pA+=`
|
|
5702
|
+
For more information, see https://radix-ui.com/primitives/docs/components/alert-dialog`;return AA.useEffect(()=>{document.getElementById(e.current?.getAttribute("aria-describedby"))||console.warn(A)},[A,e]),null},pei=bht,fei=xht,Uht=_ht,Hht=kht,Yht=Rht,Jht=Lht,Tht=Fht,Pht=Ght;const Kht=pei,yei=fei,qht=AA.forwardRef(({className:e,...A},t)=>Z.jsx(Uht,{className:bo("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",e),...A,ref:t}));qht.displayName=Uht.displayName;const HyA=AA.forwardRef(({className:e,...A},t)=>Z.jsxs(yei,{children:[Z.jsx(qht,{}),Z.jsx(Hht,{ref:t,className:bo("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",e),...A})]}));HyA.displayName=Hht.displayName;const YyA=({className:e,...A})=>Z.jsx("div",{className:bo("rf-flex rf-flex-col rf-space-y-2 rf-text-center sm:rf-text-left",e),...A});YyA.displayName="AlertDialogHeader";const JyA=({className:e,...A})=>Z.jsx("div",{className:bo("rf-flex rf-flex-col-reverse sm:rf-flex-row sm:rf-justify-end sm:rf-space-x-2",e),...A});JyA.displayName="AlertDialogFooter";const TyA=AA.forwardRef(({className:e,...A},t)=>Z.jsx(Tht,{ref:t,className:bo("rf-text-lg rf-font-semibold",e),...A}));TyA.displayName=Tht.displayName;const PyA=AA.forwardRef(({className:e,...A},t)=>Z.jsx(Pht,{ref:t,className:bo("rf-text-sm rf-text-zinc-500 dark:rf-text-zinc-400",e),...A}));PyA.displayName=Pht.displayName;const mei=AA.forwardRef(({className:e,...A},t)=>Z.jsx(Yht,{ref:t,className:bo(G2(),e),...A}));mei.displayName=Yht.displayName;const KyA=AA.forwardRef(({className:e,...A},t)=>Z.jsx(Jht,{ref:t,className:bo(G2({variant:"outline"}),"rf-mt-2 sm:rf-mt-0",e),...A}));KyA.displayName=Jht.displayName;function wei(e){const A=AA.useRef({value:e,previous:e});return AA.useMemo(()=>(A.current.value!==e&&(A.current.previous=A.current.value,A.current.value=e),A.current.previous),[e])}var ez="Checkbox",[Dei]=HS(ez),[Sei,qyA]=Dei(ez);function bei(e){const{__scopeCheckbox:A,checked:t,children:i,defaultChecked:n,disabled:o,form:s,name:r,onCheckedChange:a,required:g,value:c="on",internal_do_not_use_render:I}=e,[l,B]=pG({prop:t,defaultProp:n??!1,onChange:a,caller:ez}),[C,Q]=AA.useState(null),[h,E]=AA.useState(null),u=AA.useRef(!1),d=C?!!s||!!C.closest("form"):!0,f={checked:l,disabled:o,setChecked:B,control:C,setControl:Q,name:r,form:s,value:c,hasConsumerStoppedPropagationRef:u,required:g,defaultChecked:Hk(n)?!1:n,isFormControl:d,bubbleInput:h,setBubbleInput:E};return Z.jsx(Sei,{scope:A,...f,children:xei(I)?I(f):i})}var Oht="CheckboxTrigger",Wht=AA.forwardRef(({__scopeCheckbox:e,onKeyDown:A,onClick:t,...i},n)=>{const{control:o,value:s,disabled:r,checked:a,required:g,setControl:c,setChecked:I,hasConsumerStoppedPropagationRef:l,isFormControl:B,bubbleInput:C}=qyA(Oht,e),Q=oC(n,c),h=AA.useRef(a);return AA.useEffect(()=>{const E=o?.form;if(E){const u=()=>I(h.current);return E.addEventListener("reset",u),()=>E.removeEventListener("reset",u)}},[o,I]),Z.jsx(fc.button,{type:"button",role:"checkbox","aria-checked":Hk(a)?"mixed":a,"aria-required":g,"data-state":Xht(a),"data-disabled":r?"":void 0,disabled:r,value:s,...i,ref:Q,onKeyDown:Cs(A,E=>{E.key==="Enter"&&E.preventDefault()}),onClick:Cs(t,E=>{I(u=>Hk(u)?!0:!u),C&&B&&(l.current=E.isPropagationStopped(),l.current||E.stopPropagation())})})});Wht.displayName=Oht;var OyA=AA.forwardRef((e,A)=>{const{__scopeCheckbox:t,name:i,checked:n,defaultChecked:o,required:s,disabled:r,value:a,onCheckedChange:g,form:c,...I}=e;return Z.jsx(bei,{__scopeCheckbox:t,checked:n,defaultChecked:o,disabled:r,required:s,onCheckedChange:g,name:i,form:c,value:a,internal_do_not_use_render:({isFormControl:l})=>Z.jsxs(Z.Fragment,{children:[Z.jsx(Wht,{...I,ref:A,__scopeCheckbox:t}),l&&Z.jsx(zht,{__scopeCheckbox:t})]})})});OyA.displayName=ez;var Zht="CheckboxIndicator",Vht=AA.forwardRef((e,A)=>{const{__scopeCheckbox:t,forceMount:i,...n}=e,o=qyA(Zht,t);return Z.jsx(iD,{present:i||Hk(o.checked)||o.checked===!0,children:Z.jsx(fc.span,{"data-state":Xht(o.checked),"data-disabled":o.disabled?"":void 0,...n,ref:A,style:{pointerEvents:"none",...e.style}})})});Vht.displayName=Zht;var jht="CheckboxBubbleInput",zht=AA.forwardRef(({__scopeCheckbox:e,...A},t)=>{const{control:i,hasConsumerStoppedPropagationRef:n,checked:o,defaultChecked:s,required:r,disabled:a,name:g,value:c,form:I,bubbleInput:l,setBubbleInput:B}=qyA(jht,e),C=oC(t,B),Q=wei(o),h=Ast(i);AA.useEffect(()=>{const u=l;if(!u)return;const d=window.HTMLInputElement.prototype,m=Object.getOwnPropertyDescriptor(d,"checked").set,w=!n.current;if(Q!==o&&m){const D=new Event("click",{bubbles:w});u.indeterminate=Hk(o),m.call(u,Hk(o)?!1:o),u.dispatchEvent(D)}},[l,Q,o,n]);const E=AA.useRef(Hk(o)?!1:o);return Z.jsx(fc.input,{type:"checkbox","aria-hidden":!0,defaultChecked:s??E.current,required:r,disabled:a,name:g,value:c,form:I,...A,tabIndex:-1,ref:C,style:{...A.style,...h,position:"absolute",pointerEvents:"none",opacity:0,margin:0,transform:"translateX(-100%)"}})});zht.displayName=jht;function xei(e){return typeof e=="function"}function Hk(e){return e==="indeterminate"}function Xht(e){return Hk(e)?"indeterminate":e?"checked":"unchecked"}const _T=AA.forwardRef(({className:e,...A},t)=>Z.jsx(OyA,{ref:t,className:bo("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",e),...A,children:Z.jsx(Vht,{className:bo("rf-flex rf-items-center rf-justify-center rf-text-current"),children:Z.jsx(EpA,{className:"rf-h-4 rf-w-4"})})}));_T.displayName=OyA.displayName;const kT=mht,_ei=wht,$ht=AA.forwardRef(({className:e,...A},t)=>Z.jsx(RyA,{className:bo("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",e),...A,ref:t}));$ht.displayName=RyA.displayName;const I1=AA.forwardRef(({className:e,children:A,showOverlay:t=!0,...i},n)=>Z.jsxs(_ei,{children:[Z.jsx($ht,{className:bo(t?"":"rf-hidden")}),Z.jsx(NyA,{ref:n,className:bo("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",e),...i,children:A})]}));I1.displayName=NyA.displayName;const l1=({className:e,...A})=>Z.jsx("div",{className:bo("rf-flex rf-flex-col rf-space-y-2 rf-text-center sm:rf-text-left",e),...A});l1.displayName="DialogHeader";const vT=({className:e,...A})=>Z.jsx("div",{className:bo("rf-flex rf-flex-col-reverse sm:rf-flex-row sm:rf-justify-end sm:rf-space-x-2",e),...A});vT.displayName="DialogFooter";const B1=AA.forwardRef(({className:e,...A},t)=>Z.jsx(LyA,{ref:t,className:bo("rf-text-lg rf-font-semibold",e),...A}));B1.displayName=LyA.displayName;const FT=AA.forwardRef(({className:e,...A},t)=>Z.jsx(UyA,{ref:t,className:bo("rf-text-sm rf-text-zinc-500 dark:rf-text-zinc-400",e),...A}));FT.displayName=UyA.displayName;const iz={"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"}},kei="https://cdn.jsdelivr.net/npm/easyeda@latest/dist/browser/index.js";let WyA=null;const vei=async()=>(WyA||(WyA=import(kei)),WyA),Fei=async(e,A=10)=>{const t=encodeURIComponent(e),i=await fetch(`https://jlcsearch.tscircuit.com/api/search?limit=${A}&q=${t}`);if(!i.ok)throw new Error(`JLCPCB API error: ${i.status}`);return(await i.json()).components??[]},Mei=e=>({lcscId:e.lcsc,manufacturer:e.mfr,description:e.description,partNumber:`C${e.lcsc}`,package:e.package,price:e.price,stock:e.stock,isBasic:e.is_basic}),Gei=async(e,A)=>{const{fetchEasyEDAComponent:t,convertRawEasyToTsx:i}=await vei(),n=await t(e,{fetch:(o,s)=>fetch(`${A?.apiBase??$b}/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"]??"",...A?.headers}})});return i({rawEasy:n})},Rei=({query:e,placeholder:A,isSearching:t,onQueryChange:i,onSubmit:n})=>{const o=AA.useCallback(s=>{s.key==="Enter"&&(s.preventDefault(),n())},[n]);return Z.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2 rf-mt-4",children:[Z.jsxs("div",{className:"rf-relative rf-flex-grow",children:[Z.jsx(dot,{className:"rf-absolute rf-left-2 rf-top-2.5 rf-h-4 rf-w-4 rf-text-muted-foreground"}),Z.jsx($fA,{placeholder:A,className:"rf-pl-8",spellCheck:!1,autoComplete:"off",value:e,onChange:s=>i(s.target.value),onKeyDown:o})]}),Z.jsx(oI,{onClick:n,disabled:t||e.trim().length<1,className:"sm:rf-px-4 rf-px-3",children:t?Z.jsx(hk,{className:"rf-h-4 rf-w-4 rf-animate-spin"}):Z.jsxs(Z.Fragment,{children:[Z.jsx(dot,{className:"rf-h-4 rf-w-4 sm:rf-hidden"}),Z.jsx("span",{className:"rf-hidden sm:rf-inline",children:"Search"})]})})]})},Nei=new Intl.NumberFormat("en-US",{style:"currency",currency:"USD"}),Lei=e=>Nei.format(e),AEt=e=>{switch(e.source){case"tscircuit.com":{const A=e.package;return`tscircuit-${A.package_id??`${A.org_owner_tscircuit_handle??"unknown"}-${A.unscoped_name??A.name??"package"}`}`}case"jlcpcb":return`jlc-${e.component.lcscId}`;case"kicad":return`kicad-${e.footprint.path}`;default:return"unknown"}},Uei=e=>{switch(e.source){case"tscircuit.com":return e.package.unscoped_name;case"jlcpcb":return e.component.manufacturer;case"kicad":return e.footprint.qualifiedName}},Hei=e=>{switch(e.source){case"tscircuit.com":return e.package.description||(e.package.org_owner_tscircuit_handle?`Component by ${e.package.org_owner_tscircuit_handle}`:void 0);case"jlcpcb":return e.component.description;case"kicad":return e.footprint.description}},Yei=e=>{switch(e.source){case"tscircuit.com":return e.package.name;case"jlcpcb":return e.component.partNumber;case"kicad":return}},Jei=({results:e,selected:A,onSelect:t,onShowDetails:i})=>{const n=A?AEt(A):null;return Z.jsx("div",{className:"rf-divide-y rf-w-full rf-overflow-hidden",children:e.map(o=>{const s=AEt(o),r=n===s,a=Uei(o),g=Hei(o),c=Yei(o),I=o.source==="jlcpcb"?o.component.stock:null,l=o.source==="jlcpcb"?o.component.price:null,B=o.source==="jlcpcb"?o.component.isBasic:null;return Z.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 ${r?"rf-bg-zinc-100":""}`,onClick:()=>t(o),children:[Z.jsxs("div",{className:"rf-min-w-0 rf-overflow-hidden rf-w-full",children:[Z.jsxs("div",{className:"rf-flex rf-items-start rf-gap-2 rf-min-w-0",children:[Z.jsxs("div",{className:"rf-font-medium rf-text-sm rf-truncate rf-flex-1 rf-min-w-0 rf-flex rf-items-center rf-gap-1.5",children:[a,o.source==="jlcpcb"&&B!=null&&Z.jsx("span",{className:`rf-text-xs rf-px-1.5 rf-py-0.5 rf-rounded rf-font-medium rf-flex-shrink-0 ${B?"rf-bg-green-100 rf-text-green-700":"rf-bg-orange-100 rf-text-orange-700"}`,children:B?"Basic":"Extended"}),o.source==="tscircuit.com"&&o.package.is_private&&Z.jsx(ITe,{className:"rf-ml-1 rf-h-3 rf-w-3 rf-text-zinc-400 rf-flex-shrink-0"})]}),o.source==="jlcpcb"&&I!=null?Z.jsxs("div",{className:"rf-text-xs rf-text-zinc-500 rf-font-medium rf-whitespace-nowrap rf-flex-shrink-0 sm:rf-hidden",children:[I.toLocaleString()," in stock"]}):null]}),Z.jsxs("div",{className:"rf-text-xs rf-text-zinc-500 rf-truncate rf-w-full",children:[c?Z.jsx("span",{className:"rf-mr-2",children:c}):null,g]})]}),Z.jsxs("div",{children:[o.source==="tscircuit.com"&&i?Z.jsx("div",{className:"rf-flex-shrink-0 rf-w-full sm:rf-w-auto",children:Z.jsx(oI,{variant:"outline",size:"sm",className:"rf-text-xs rf-w-full sm:rf-w-auto",onClick:C=>{C.stopPropagation(),i(o)},children:"See Details"})}):o.source==="jlcpcb"&&I!=null?Z.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:[I.toLocaleString()," in stock"]}):null,l!=null&&Z.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:Lei(l)})]})]},s)})})},Tei=({packageResult:e,isOpen:A,onOpenChange:t,isLoading:i,details:n,previewTab:o,onPreviewTabChange:s,isSubmitting:r,onImport:a})=>{const g=e?.package??null,c=g?.latest_pcb_preview_image_url,I=g?.latest_sch_preview_image_url,l=g?.latest_cad_preview_image_url,B=g?.unscoped_name?.split("/").pop()??g?.unscoped_name,C=g?.org_owner_tscircuit_handle??void 0,Q=C?`https://tscircuit.com/${C}`:void 0,h=C&&B?`https://tscircuit.com/${C}/${B}`:void 0;return Z.jsx(kT,{open:A,onOpenChange:t,children:Z.jsxs(I1,{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:[Z.jsx(l1,{className:"rf-pb-4 rf-border-b",children:Z.jsx("div",{className:"rf-flex rf-items-start rf-justify-between rf-gap-4",children:Z.jsxs("div",{className:"rf-flex-1 rf-min-w-0",children:[Z.jsx(B1,{className:"rf-text-xl rf-font-semibold rf-truncate",children:B}),Z.jsx(FT,{children:g?.description})]})})}),Z.jsxs("div",{className:"rf-flex-1 rf-overflow-y-auto rf-py-4 rf-space-y-6",children:[C?Z.jsxs("div",{children:[Z.jsx("span",{className:"rf-text-xs rf-font-medium rf-text-gray-500 rf-uppercase rf-tracking-wide",children:"Created by"}),Z.jsx("div",{className:"rf-mt-1 rf-text-sm rf-font-medium",children:Q?Z.jsx("a",{href:Q,target:"_blank",rel:"noopener noreferrer",className:"rf-text-black hover:rf-underline",children:C}):C})]}):null,(l||c||I)&&Z.jsx(Z.Fragment,{children:Z.jsxs("div",{children:[Z.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-mb-4",children:"Preview"}),Z.jsxs($7,{value:o,onValueChange:E=>s(E),children:[Z.jsxs(Cq,{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:[c&&Z.jsx(sD,{value:"pcb",children:"PCB"}),I&&Z.jsx(sD,{value:"schematic",children:"Schematic"}),l&&Z.jsx(sD,{value:"3d",children:"3D"})]}),Z.jsxs("div",{className:"rf-mt-4",children:[Z.jsx(ju,{value:"pcb",className:"rf-border rf-rounded-lg rf-overflow-hidden rf-bg-gray-50",children:c?Z.jsx("img",{src:c,alt:`${B??"package"} PCB preview`,className:"rf-w-full rf-h-full rf-object-contain rf-bg-white rf-p-4"}):null}),Z.jsx(ju,{value:"schematic",className:"rf-border rf-rounded-lg rf-overflow-hidden rf-bg-gray-50",children:I?Z.jsx("img",{src:I,alt:`${B??"package"} schematic preview`,className:"rf-w-full rf-h-full rf-object-contain rf-bg-white rf-p-4"}):null}),Z.jsx(ju,{value:"3d",className:"rf-border rf-rounded-lg rf-overflow-hidden rf-bg-gray-50",children:l?Z.jsx("img",{src:l,alt:`${B??"package"} 3D preview`,className:"rf-w-full rf-h-full rf-object-contain rf-bg-white rf-p-4"}):null})]})]})]})}),n?.ai_description?Z.jsxs("section",{children:[Z.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-mb-3",children:"AI Description"}),Z.jsx("div",{className:"rf-bg-gray-50 rf-border rf-border-gray-200 rf-rounded-lg rf-p-4",children:Z.jsx("p",{className:"rf-text-sm rf-text-gray-700 rf-leading-relaxed",children:n.ai_description})})]}):null,n?.ai_usage_instructions?Z.jsxs("section",{children:[Z.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-mb-3",children:"Usage Instructions"}),Z.jsx("div",{className:"rf-bg-gray-50 rf-border rf-border-gray-200 rf-rounded-lg rf-p-4",children:Z.jsx("p",{className:"rf-text-sm rf-text-gray-700 rf-leading-relaxed rf-whitespace-pre-wrap",children:n.ai_usage_instructions})})]}):null,i?Z.jsxs("div",{className:"rf-flex rf-justify-center rf-items-center rf-gap-2 rf-text-gray-500",children:[Z.jsx(hk,{className:"rf-h-4 rf-w-4 rf-animate-spin"}),Z.jsx("span",{className:"rf-text-sm",children:"Loading package details..."})]}):null]}),Z.jsxs(vT,{className:"rf-pt-4 rf-border-t rf-flex rf-flex-col sm:rf-flex-row rf-justify-between rf-gap-2",children:[Z.jsx("div",{className:"rf-flex-1",children:h?Z.jsxs(oI,{variant:"outline",size:"sm",className:"rf-gap-2 rf-w-full sm:rf-w-auto",onClick:()=>window.open(h,"_blank"),children:[Z.jsx(rTe,{className:"rf-h-4 rf-w-4"}),"View on tscircuit.com"]}):null}),Z.jsxs("div",{className:"rf-flex rf-flex-col sm:rf-flex-row rf-gap-2",children:[Z.jsx(oI,{variant:"outline",onClick:()=>t(!1),className:"rf-order-2 sm:rf-order-1",children:"Close"}),Z.jsx(oI,{onClick:a,disabled:r,className:"rf-bg-blue-600 hover:rf-bg-blue-700",children:r?Z.jsx(hk,{className:"rf-h-4 rf-w-4 rf-animate-spin"}):"Import Component"})]})]})]})})},Pei=()=>{const[e,A]=AA.useState(null),[t,i]=AA.useState(!1),n=AA.useCallback(async(s,r)=>{i(!0);try{const a=await fetch(`https://api.tscircuit.com/packages/get?name=${encodeURIComponent(`${s}/${r}`)}`);if(!a.ok)throw new Error(`Failed to load package details: ${a.status}`);const g=await a.json();A(g.package??null)}catch(a){console.error("Failed to fetch package details",a),A(null)}finally{i(!1)}},[]),o=AA.useCallback(()=>{A(null),i(!1)},[]);return{details:e,isLoading:t,fetchDetails:n,reset:o}},Kei=async(e,A)=>{const t={"Content-Type":"application/json"};A&&(t.Authorization=`Bearer ${A}`);const i=await fetch("https://registry-api.tscircuit.com/packages/search",{method:"POST",headers:t,body:JSON.stringify({query:e})});if(!i.ok)throw new Error(`tscircuit registry error: ${i.status}`);return(await i.json()).packages??[]},qei=({sessionToken:e})=>{const[A,t]=AA.useState([]),[i,n]=AA.useState(!1),[o,s]=AA.useState(null),[r,a]=AA.useState(!1),g=AA.useCallback(async I=>{const l=I.trim();if(!l)return[];n(!0),s(null);try{const C=(await Kei(l,e)).map(Q=>({source:"tscircuit.com",package:Q}));return t(C),C}catch(B){return console.error("Error searching tscircuit packages",B),t([]),s(B instanceof Error?B.message:"Failed to search tscircuit packages"),[]}finally{n(!1),a(!0)}},[e]),c=AA.useCallback(()=>{t([]),n(!1),s(null),a(!1)},[]);return{results:A,isSearching:i,error:o,hasSearched:r,search:g,reset:c}},Oei=e=>{const A=e.trim();return/^C\d+/i.test(A)?A.replace(/^C/i,""):A},Wei=()=>{const[e,A]=AA.useState([]),[t,i]=AA.useState(!1),[n,o]=AA.useState(null),[s,r]=AA.useState(!1),a=AA.useCallback(async c=>{const I=Oei(c);if(!I)return[];i(!0),o(null);try{const B=(await Fei(I,10)).map(C=>({source:"jlcpcb",component:Mei(C)}));return A(B),B}catch(l){return console.error("Error searching JLCPCB components",l),A([]),o(l instanceof Error?l.message:"Failed to search JLCPCB components"),[]}finally{i(!1),r(!0)}},[]),g=AA.useCallback(()=>{A([]),i(!1),o(null),r(!1)},[]);return{results:e,isSearching:t,error:n,hasSearched:s,search:a,reset:g}};function tx(e){return Array.isArray?Array.isArray(e):iEt(e)==="[object Array]"}function Zei(e){if(typeof e=="string")return e;let A=e+"";return A=="0"&&1/e==-1/0?"-0":A}function Vei(e){return e==null?"":Zei(e)}function QS(e){return typeof e=="string"}function tEt(e){return typeof e=="number"}function jei(e){return e===!0||e===!1||zei(e)&&iEt(e)=="[object Boolean]"}function eEt(e){return typeof e=="object"}function zei(e){return eEt(e)&&e!==null}function ny(e){return e!=null}function ZyA(e){return!e.trim().length}function iEt(e){return e==null?e===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(e)}const Xei="Incorrect 'index' type",$ei=e=>`Invalid value for key ${e}`,Aii=e=>`Pattern length exceeds max of ${e}.`,tii=e=>`Missing ${e} property in key`,eii=e=>`Property 'weight' in key '${e}' must be a positive integer`,nEt=Object.prototype.hasOwnProperty;class iii{constructor(A){this._keys=[],this._keyMap={};let t=0;A.forEach(i=>{let n=oEt(i);this._keys.push(n),this._keyMap[n.id]=n,t+=n.weight}),this._keys.forEach(i=>{i.weight/=t})}get(A){return this._keyMap[A]}keys(){return this._keys}toJSON(){return JSON.stringify(this._keys)}}function oEt(e){let A=null,t=null,i=null,n=1,o=null;if(QS(e)||tx(e))i=e,A=sEt(e),t=VyA(e);else{if(!nEt.call(e,"name"))throw new Error(tii("name"));const s=e.name;if(i=s,nEt.call(e,"weight")&&(n=e.weight,n<=0))throw new Error(eii(s));A=sEt(s),t=VyA(s),o=e.getFn}return{path:A,id:t,weight:n,src:i,getFn:o}}function sEt(e){return tx(e)?e:e.split(".")}function VyA(e){return tx(e)?e.join("."):e}function nii(e,A){let t=[],i=!1;const n=(o,s,r)=>{if(ny(o))if(!s[r])t.push(o);else{let a=s[r];const g=o[a];if(!ny(g))return;if(r===s.length-1&&(QS(g)||tEt(g)||jei(g)))t.push(Vei(g));else if(tx(g)){i=!0;for(let c=0,I=g.length;c<I;c+=1)n(g[c],s,r+1)}else s.length&&n(g,s,r+1)}};return n(e,QS(A)?A.split("."):A,0),i?t:t[0]}var Wo={...{isCaseSensitive:!1,ignoreDiacritics:!1,includeScore:!1,keys:[],shouldSort:!0,sortFn:(e,A)=>e.score===A.score?e.idx<A.idx?-1:1:e.score<A.score?-1:1},...{includeMatches:!1,findAllMatches:!1,minMatchCharLength:1},...{location:0,threshold:.6,distance:100},...{useExtendedSearch:!1,getFn:nii,ignoreLocation:!1,ignoreFieldNorm:!1,fieldNormWeight:1}};const oii=/[^ ]+/g;function sii(e=1,A=3){const t=new Map,i=Math.pow(10,A);return{get(n){const o=n.match(oii).length;if(t.has(o))return t.get(o);const s=1/Math.pow(o,.5*e),r=parseFloat(Math.round(s*i)/i);return t.set(o,r),r},clear(){t.clear()}}}class jyA{constructor({getFn:A=Wo.getFn,fieldNormWeight:t=Wo.fieldNormWeight}={}){this.norm=sii(t,3),this.getFn=A,this.isCreated=!1,this.setIndexRecords()}setSources(A=[]){this.docs=A}setIndexRecords(A=[]){this.records=A}setKeys(A=[]){this.keys=A,this._keysMap={},A.forEach((t,i)=>{this._keysMap[t.id]=i})}create(){this.isCreated||!this.docs.length||(this.isCreated=!0,QS(this.docs[0])?this.docs.forEach((A,t)=>{this._addString(A,t)}):this.docs.forEach((A,t)=>{this._addObject(A,t)}),this.norm.clear())}add(A){const t=this.size();QS(A)?this._addString(A,t):this._addObject(A,t)}removeAt(A){this.records.splice(A,1);for(let t=A,i=this.size();t<i;t+=1)this.records[t].i-=1}getValueForItemAtKeyId(A,t){return A[this._keysMap[t]]}size(){return this.records.length}_addString(A,t){if(!ny(A)||ZyA(A))return;let i={v:A,i:t,n:this.norm.get(A)};this.records.push(i)}_addObject(A,t){let i={i:t,$:{}};this.keys.forEach((n,o)=>{let s=n.getFn?n.getFn(A):this.getFn(A,n.path);if(ny(s)){if(tx(s)){let r=[];const a=[{nestedArrIndex:-1,value:s}];for(;a.length;){const{nestedArrIndex:g,value:c}=a.pop();if(ny(c))if(QS(c)&&!ZyA(c)){let I={v:c,i:g,n:this.norm.get(c)};r.push(I)}else tx(c)&&c.forEach((I,l)=>{a.push({nestedArrIndex:l,value:I})})}i.$[o]=r}else if(QS(s)&&!ZyA(s)){let r={v:s,n:this.norm.get(s)};i.$[o]=r}}}),this.records.push(i)}toJSON(){return{keys:this.keys,records:this.records}}}function rEt(e,A,{getFn:t=Wo.getFn,fieldNormWeight:i=Wo.fieldNormWeight}={}){const n=new jyA({getFn:t,fieldNormWeight:i});return n.setKeys(e.map(oEt)),n.setSources(A),n.create(),n}function rii(e,{getFn:A=Wo.getFn,fieldNormWeight:t=Wo.fieldNormWeight}={}){const{keys:i,records:n}=e,o=new jyA({getFn:A,fieldNormWeight:t});return o.setKeys(i),o.setIndexRecords(n),o}function nz(e,{errors:A=0,currentLocation:t=0,expectedLocation:i=0,distance:n=Wo.distance,ignoreLocation:o=Wo.ignoreLocation}={}){const s=A/e.length;if(o)return s;const r=Math.abs(i-t);return n?s+r/n:r?1:s}function aii(e=[],A=Wo.minMatchCharLength){let t=[],i=-1,n=-1,o=0;for(let s=e.length;o<s;o+=1){let r=e[o];r&&i===-1?i=o:!r&&i!==-1&&(n=o-1,n-i+1>=A&&t.push([i,n]),i=-1)}return e[o-1]&&o-i>=A&&t.push([i,o-1]),t}const vM=32;function gii(e,A,t,{location:i=Wo.location,distance:n=Wo.distance,threshold:o=Wo.threshold,findAllMatches:s=Wo.findAllMatches,minMatchCharLength:r=Wo.minMatchCharLength,includeMatches:a=Wo.includeMatches,ignoreLocation:g=Wo.ignoreLocation}={}){if(A.length>vM)throw new Error(Aii(vM));const c=A.length,I=e.length,l=Math.max(0,Math.min(i,I));let B=o,C=l;const Q=r>1||a,h=Q?Array(I):[];let E;for(;(E=e.indexOf(A,C))>-1;){let D=nz(A,{currentLocation:E,expectedLocation:l,distance:n,ignoreLocation:g});if(B=Math.min(D,B),C=E+c,Q){let S=0;for(;S<c;)h[E+S]=1,S+=1}}C=-1;let u=[],d=1,f=c+I;const m=1<<c-1;for(let D=0;D<c;D+=1){let S=0,_=f;for(;S<_;)nz(A,{errors:D,currentLocation:l+_,expectedLocation:l,distance:n,ignoreLocation:g})<=B?S=_:f=_,_=Math.floor((f-S)/2+S);f=_;let b=Math.max(1,l-_+1),R=s?I:Math.min(l+_,I)+c,F=Array(R+2);F[R+1]=(1<<D)-1;for(let Y=R;Y>=b;Y-=1){let J=Y-1,O=t[e.charAt(J)];if(Q&&(h[J]=+!!O),F[Y]=(F[Y+1]<<1|1)&O,D&&(F[Y]|=(u[Y+1]|u[Y])<<1|1|u[Y+1]),F[Y]&m&&(d=nz(A,{errors:D,currentLocation:J,expectedLocation:l,distance:n,ignoreLocation:g}),d<=B)){if(B=d,C=J,C<=l)break;b=Math.max(1,2*l-C)}}if(nz(A,{errors:D+1,currentLocation:l,expectedLocation:l,distance:n,ignoreLocation:g})>B)break;u=F}const w={isMatch:C>=0,score:Math.max(.001,d)};if(Q){const D=aii(h,r);D.length?a&&(w.indices=D):w.isMatch=!1}return w}function cii(e){let A={};for(let t=0,i=e.length;t<i;t+=1){const n=e.charAt(t);A[n]=(A[n]||0)|1<<i-t-1}return A}const oz=String.prototype.normalize?(e=>e.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,"")):(e=>e);class aEt{constructor(A,{location:t=Wo.location,threshold:i=Wo.threshold,distance:n=Wo.distance,includeMatches:o=Wo.includeMatches,findAllMatches:s=Wo.findAllMatches,minMatchCharLength:r=Wo.minMatchCharLength,isCaseSensitive:a=Wo.isCaseSensitive,ignoreDiacritics:g=Wo.ignoreDiacritics,ignoreLocation:c=Wo.ignoreLocation}={}){if(this.options={location:t,threshold:i,distance:n,includeMatches:o,findAllMatches:s,minMatchCharLength:r,isCaseSensitive:a,ignoreDiacritics:g,ignoreLocation:c},A=a?A:A.toLowerCase(),A=g?oz(A):A,this.pattern=A,this.chunks=[],!this.pattern.length)return;const I=(B,C)=>{this.chunks.push({pattern:B,alphabet:cii(B),startIndex:C})},l=this.pattern.length;if(l>vM){let B=0;const C=l%vM,Q=l-C;for(;B<Q;)I(this.pattern.substr(B,vM),B),B+=vM;if(C){const h=l-vM;I(this.pattern.substr(h),h)}}else I(this.pattern,0)}searchIn(A){const{isCaseSensitive:t,ignoreDiacritics:i,includeMatches:n}=this.options;if(A=t?A:A.toLowerCase(),A=i?oz(A):A,this.pattern===A){let Q={isMatch:!0,score:0};return n&&(Q.indices=[[0,A.length-1]]),Q}const{location:o,distance:s,threshold:r,findAllMatches:a,minMatchCharLength:g,ignoreLocation:c}=this.options;let I=[],l=0,B=!1;this.chunks.forEach(({pattern:Q,alphabet:h,startIndex:E})=>{const{isMatch:u,score:d,indices:f}=gii(A,Q,h,{location:o+E,distance:s,threshold:r,findAllMatches:a,minMatchCharLength:g,includeMatches:n,ignoreLocation:c});u&&(B=!0),l+=d,u&&f&&(I=[...I,...f])});let C={isMatch:B,score:B?l/this.chunks.length:1};return B&&n&&(C.indices=I),C}}class Yk{constructor(A){this.pattern=A}static isMultiMatch(A){return gEt(A,this.multiRegex)}static isSingleMatch(A){return gEt(A,this.singleRegex)}search(){}}function gEt(e,A){const t=e.match(A);return t?t[1]:null}class Iii extends Yk{constructor(A){super(A)}static get type(){return"exact"}static get multiRegex(){return/^="(.*)"$/}static get singleRegex(){return/^=(.*)$/}search(A){const t=A===this.pattern;return{isMatch:t,score:t?0:1,indices:[0,this.pattern.length-1]}}}class lii extends Yk{constructor(A){super(A)}static get type(){return"inverse-exact"}static get multiRegex(){return/^!"(.*)"$/}static get singleRegex(){return/^!(.*)$/}search(A){const i=A.indexOf(this.pattern)===-1;return{isMatch:i,score:i?0:1,indices:[0,A.length-1]}}}class Bii extends Yk{constructor(A){super(A)}static get type(){return"prefix-exact"}static get multiRegex(){return/^\^"(.*)"$/}static get singleRegex(){return/^\^(.*)$/}search(A){const t=A.startsWith(this.pattern);return{isMatch:t,score:t?0:1,indices:[0,this.pattern.length-1]}}}class Cii extends Yk{constructor(A){super(A)}static get type(){return"inverse-prefix-exact"}static get multiRegex(){return/^!\^"(.*)"$/}static get singleRegex(){return/^!\^(.*)$/}search(A){const t=!A.startsWith(this.pattern);return{isMatch:t,score:t?0:1,indices:[0,A.length-1]}}}class Qii extends Yk{constructor(A){super(A)}static get type(){return"suffix-exact"}static get multiRegex(){return/^"(.*)"\$$/}static get singleRegex(){return/^(.*)\$$/}search(A){const t=A.endsWith(this.pattern);return{isMatch:t,score:t?0:1,indices:[A.length-this.pattern.length,A.length-1]}}}class hii extends Yk{constructor(A){super(A)}static get type(){return"inverse-suffix-exact"}static get multiRegex(){return/^!"(.*)"\$$/}static get singleRegex(){return/^!(.*)\$$/}search(A){const t=!A.endsWith(this.pattern);return{isMatch:t,score:t?0:1,indices:[0,A.length-1]}}}class cEt extends Yk{constructor(A,{location:t=Wo.location,threshold:i=Wo.threshold,distance:n=Wo.distance,includeMatches:o=Wo.includeMatches,findAllMatches:s=Wo.findAllMatches,minMatchCharLength:r=Wo.minMatchCharLength,isCaseSensitive:a=Wo.isCaseSensitive,ignoreDiacritics:g=Wo.ignoreDiacritics,ignoreLocation:c=Wo.ignoreLocation}={}){super(A),this._bitapSearch=new aEt(A,{location:t,threshold:i,distance:n,includeMatches:o,findAllMatches:s,minMatchCharLength:r,isCaseSensitive:a,ignoreDiacritics:g,ignoreLocation:c})}static get type(){return"fuzzy"}static get multiRegex(){return/^"(.*)"$/}static get singleRegex(){return/^(.*)$/}search(A){return this._bitapSearch.searchIn(A)}}class IEt extends Yk{constructor(A){super(A)}static get type(){return"include"}static get multiRegex(){return/^'"(.*)"$/}static get singleRegex(){return/^'(.*)$/}search(A){let t=0,i;const n=[],o=this.pattern.length;for(;(i=A.indexOf(this.pattern,t))>-1;)t=i+o,n.push([i,t-1]);const s=!!n.length;return{isMatch:s,score:s?0:1,indices:n}}}const zyA=[Iii,IEt,Bii,Cii,hii,Qii,lii,cEt],lEt=zyA.length,Eii=/ +(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/,uii="|";function dii(e,A={}){return e.split(uii).map(t=>{let i=t.trim().split(Eii).filter(o=>o&&!!o.trim()),n=[];for(let o=0,s=i.length;o<s;o+=1){const r=i[o];let a=!1,g=-1;for(;!a&&++g<lEt;){const c=zyA[g];let I=c.isMultiMatch(r);I&&(n.push(new c(I,A)),a=!0)}if(!a)for(g=-1;++g<lEt;){const c=zyA[g];let I=c.isSingleMatch(r);if(I){n.push(new c(I,A));break}}}return n})}const pii=new Set([cEt.type,IEt.type]);class fii{constructor(A,{isCaseSensitive:t=Wo.isCaseSensitive,ignoreDiacritics:i=Wo.ignoreDiacritics,includeMatches:n=Wo.includeMatches,minMatchCharLength:o=Wo.minMatchCharLength,ignoreLocation:s=Wo.ignoreLocation,findAllMatches:r=Wo.findAllMatches,location:a=Wo.location,threshold:g=Wo.threshold,distance:c=Wo.distance}={}){this.query=null,this.options={isCaseSensitive:t,ignoreDiacritics:i,includeMatches:n,minMatchCharLength:o,findAllMatches:r,ignoreLocation:s,location:a,threshold:g,distance:c},A=t?A:A.toLowerCase(),A=i?oz(A):A,this.pattern=A,this.query=dii(this.pattern,this.options)}static condition(A,t){return t.useExtendedSearch}searchIn(A){const t=this.query;if(!t)return{isMatch:!1,score:1};const{includeMatches:i,isCaseSensitive:n,ignoreDiacritics:o}=this.options;A=n?A:A.toLowerCase(),A=o?oz(A):A;let s=0,r=[],a=0;for(let g=0,c=t.length;g<c;g+=1){const I=t[g];r.length=0,s=0;for(let l=0,B=I.length;l<B;l+=1){const C=I[l],{isMatch:Q,indices:h,score:E}=C.search(A);if(Q){if(s+=1,a+=E,i){const u=C.constructor.type;pii.has(u)?r=[...r,...h]:r.push(h)}}else{a=0,s=0,r.length=0;break}}if(s){let l={isMatch:!0,score:a/s};return i&&(l.indices=r),l}}return{isMatch:!1,score:1}}}const XyA=[];function yii(...e){XyA.push(...e)}function $yA(e,A){for(let t=0,i=XyA.length;t<i;t+=1){let n=XyA[t];if(n.condition(e,A))return new n(e,A)}return new aEt(e,A)}const sz={AND:"$and",OR:"$or"},AmA={PATH:"$path",PATTERN:"$val"},tmA=e=>!!(e[sz.AND]||e[sz.OR]),mii=e=>!!e[AmA.PATH],wii=e=>!tx(e)&&eEt(e)&&!tmA(e),BEt=e=>({[sz.AND]:Object.keys(e).map(A=>({[A]:e[A]}))});function CEt(e,A,{auto:t=!0}={}){const i=n=>{let o=Object.keys(n);const s=mii(n);if(!s&&o.length>1&&!tmA(n))return i(BEt(n));if(wii(n)){const a=s?n[AmA.PATH]:o[0],g=s?n[AmA.PATTERN]:n[a];if(!QS(g))throw new Error($ei(a));const c={keyId:VyA(a),pattern:g};return t&&(c.searcher=$yA(g,A)),c}let r={children:[],operator:o[0]};return o.forEach(a=>{const g=n[a];tx(g)&&g.forEach(c=>{r.children.push(i(c))})}),r};return tmA(e)||(e=BEt(e)),i(e)}function Dii(e,{ignoreFieldNorm:A=Wo.ignoreFieldNorm}){e.forEach(t=>{let i=1;t.matches.forEach(({key:n,norm:o,score:s})=>{const r=n?n.weight:null;i*=Math.pow(s===0&&r?Number.EPSILON:s,(r||1)*(A?1:o))}),t.score=i})}function Sii(e,A){const t=e.matches;A.matches=[],ny(t)&&t.forEach(i=>{if(!ny(i.indices)||!i.indices.length)return;const{indices:n,value:o}=i;let s={indices:n,value:o};i.key&&(s.key=i.key.src),i.idx>-1&&(s.refIndex=i.idx),A.matches.push(s)})}function bii(e,A){A.score=e.score}function xii(e,A,{includeMatches:t=Wo.includeMatches,includeScore:i=Wo.includeScore}={}){const n=[];return t&&n.push(Sii),i&&n.push(bii),e.map(o=>{const{idx:s}=o,r={item:A[s],refIndex:s};return n.length&&n.forEach(a=>{a(o,r)}),r})}class C1{constructor(A,t={},i){this.options={...Wo,...t},this.options.useExtendedSearch,this._keyStore=new iii(this.options.keys),this.setCollection(A,i)}setCollection(A,t){if(this._docs=A,t&&!(t instanceof jyA))throw new Error(Xei);this._myIndex=t||rEt(this.options.keys,this._docs,{getFn:this.options.getFn,fieldNormWeight:this.options.fieldNormWeight})}add(A){ny(A)&&(this._docs.push(A),this._myIndex.add(A))}remove(A=()=>!1){const t=[];for(let i=0,n=this._docs.length;i<n;i+=1){const o=this._docs[i];A(o,i)&&(this.removeAt(i),i-=1,n-=1,t.push(o))}return t}removeAt(A){this._docs.splice(A,1),this._myIndex.removeAt(A)}getIndex(){return this._myIndex}search(A,{limit:t=-1}={}){const{includeMatches:i,includeScore:n,shouldSort:o,sortFn:s,ignoreFieldNorm:r}=this.options;let a=QS(A)?QS(this._docs[0])?this._searchStringList(A):this._searchObjectList(A):this._searchLogical(A);return Dii(a,{ignoreFieldNorm:r}),o&&a.sort(s),tEt(t)&&t>-1&&(a=a.slice(0,t)),xii(a,this._docs,{includeMatches:i,includeScore:n})}_searchStringList(A){const t=$yA(A,this.options),{records:i}=this._myIndex,n=[];return i.forEach(({v:o,i:s,n:r})=>{if(!ny(o))return;const{isMatch:a,score:g,indices:c}=t.searchIn(o);a&&n.push({item:o,idx:s,matches:[{score:g,value:o,norm:r,indices:c}]})}),n}_searchLogical(A){const t=CEt(A,this.options),i=(r,a,g)=>{if(!r.children){const{keyId:I,searcher:l}=r,B=this._findMatches({key:this._keyStore.get(I),value:this._myIndex.getValueForItemAtKeyId(a,I),searcher:l});return B&&B.length?[{idx:g,item:a,matches:B}]:[]}const c=[];for(let I=0,l=r.children.length;I<l;I+=1){const B=r.children[I],C=i(B,a,g);if(C.length)c.push(...C);else if(r.operator===sz.AND)return[]}return c},n=this._myIndex.records,o={},s=[];return n.forEach(({$:r,i:a})=>{if(ny(r)){let g=i(t,r,a);g.length&&(o[a]||(o[a]={idx:a,item:r,matches:[]},s.push(o[a])),g.forEach(({matches:c})=>{o[a].matches.push(...c)}))}}),s}_searchObjectList(A){const t=$yA(A,this.options),{keys:i,records:n}=this._myIndex,o=[];return n.forEach(({$:s,i:r})=>{if(!ny(s))return;let a=[];i.forEach((g,c)=>{a.push(...this._findMatches({key:g,value:s[c],searcher:t}))}),a.length&&o.push({idx:r,item:s,matches:a})}),o}_findMatches({key:A,value:t,searcher:i}){if(!ny(t))return[];let n=[];if(tx(t))t.forEach(({v:o,i:s,n:r})=>{if(!ny(o))return;const{isMatch:a,score:g,indices:c}=i.searchIn(o);a&&n.push({score:g,key:A,value:o,idx:s,norm:r,indices:c})});else{const{v:o,n:s}=t,{isMatch:r,score:a,indices:g}=i.searchIn(o);r&&n.push({score:a,key:A,value:o,norm:s,indices:g})}return n}}C1.version="7.1.0",C1.createIndex=rEt,C1.parseIndex=rii,C1.config=Wo,C1.parseQuery=CEt,yii(fii);let emA=null,MT=null,imA=null;const _ii=async()=>emA||MT||(MT=fetch("https://kicad-mod-cache.tscircuit.com/kicad_files.json").then(e=>e.json()).then(e=>(emA=e,MT=null,e)),MT),kii=async(e,A=20)=>{const t=await _ii();return imA||(imA=new C1(t)),imA.search(e).slice(0,A).map(i=>i.item)},vii=e=>{const A=e.replace(".pretty/",":").replace(".kicad_mod",""),t=`kicad:${A}`;return{path:e,qualifiedName:t,description:A}},Fii=()=>{const[e,A]=AA.useState([]),[t,i]=AA.useState(!1),[n,o]=AA.useState(null),[s,r]=AA.useState(!1),a=AA.useCallback(async c=>{const I=c.trim();if(!I)return[];i(!0),o(null);try{const B=(await kii(I,20)).map(C=>({source:"kicad",footprint:vii(C)}));return A(B),B}catch(l){return console.error("Error searching KiCad footprints",l),A([]),o(l instanceof Error?l.message:"Failed to search KiCad footprints"),[]}finally{i(!1),r(!0)}},[]),g=AA.useCallback(()=>{A([]),i(!1),o(null),r(!1)},[]);return{results:e,isSearching:t,error:n,hasSearched:s,search:a,reset:g}},Mii={dialog:101},Gii=({onTscircuitPackageSelected:e,onJlcpcbComponentTsxLoaded:A,onKicadStringSelected:t})=>{const i=[];return e&&i.push("tscircuit.com"),A&&i.push("jlcpcb"),t&&i.push("kicad"),i},Rii=({isOpen:e,onClose:A,jlcpcbProxyRequestHeaders:t,onKicadStringSelected:i,onTscircuitPackageSelected:n,onJlcpcbComponentTsxLoaded:o,jlcpcbProxyApiBase:s,tscircuitSessionToken:r})=>{qQt();const a=AA.useMemo(()=>Gii({onKicadStringSelected:i,onTscircuitPackageSelected:n,onJlcpcbComponentTsxLoaded:o}),[i,n,o]),g=a.length>0,c=a.length===1,[I,l]=AA.useState(a[0]??"tscircuit.com"),[B,C]=AA.useState(""),[Q,h]=AA.useState(null),{results:E,isSearching:u,error:d,hasSearched:f,search:m,reset:w}=qei({sessionToken:r}),{results:D,isSearching:S,error:_,hasSearched:b,search:R,reset:F}=Wei(),{results:H,isSearching:Y,error:J,hasSearched:O,search:W,reset:z}=Fii(),{details:tA,isLoading:aA,fetchDetails:eA,reset:oA}=Pei(),[rA,lA]=AA.useState(null),[pA,kA]=AA.useState(!1),[MA,YA]=AA.useState("pcb"),[EA,xA]=AA.useState(null),[dA,WA]=AA.useState(!1);AA.useEffect(()=>{xA(null)},[Q]);const jA=AA.useCallback(()=>{w(),F(),z(),h(null)},[F,z,w]);AA.useEffect(()=>{e||(jA(),C(""),kA(!1),lA(null),xA(null))},[e,jA]),AA.useEffect(()=>{C(""),h(null),I==="tscircuit.com"?w():I==="jlcpcb"?F():I==="kicad"&&z()},[I,F,z,w]);const It=KA=>{h(KA),lA(KA),YA("pcb"),kA(!0),oA();const ZA=KA.package.org_owner_tscircuit_handle,nt=KA.package.unscoped_name;if(ZA&&nt){const SA=nt.split("/").pop()??nt;eA(ZA,SA)}},mA=async()=>{B.trim()&&(h(null),I==="tscircuit.com"?await m(B):I==="jlcpcb"?await R(B):I==="kicad"&&await W(B))},gt=async KA=>{try{if(xA(null),WA(!0),KA.source==="kicad"){if(!i)throw new Error("KiCad handler not provided");await i({result:KA,footprint:KA.footprint.qualifiedName})}else if(KA.source==="jlcpcb"){if(!o)throw new Error("JLCPCB handler not provided");const ZA=await Gei(KA.component.partNumber,{headers:t,apiBase:s});await o({result:KA,tsx:ZA})}else if(KA.source==="tscircuit.com"){if(!n)throw new Error("tscircuit package handler not provided");const ZA=KA.package.org_owner_tscircuit_handle,nt=KA.package.unscoped_name;if(!ZA||!nt)throw new Error("Missing package metadata");const SA=nt.split("/").pop()??nt,CA=`@tsci/${ZA}.${SA}`;await n({result:KA,fullPackageName:CA})}return!0}catch(ZA){return console.error("Failed to import component",ZA),xA(ZA instanceof Error?ZA.message:"Failed to import component"),!1}finally{WA(!1)}};let VA=[],JA=!1,OA=null,_A=!1;I==="tscircuit.com"?(VA=E,JA=u,OA=d,_A=f):I==="jlcpcb"?(VA=D,JA=S,OA=_,_A=b):I==="kicad"&&(VA=H,JA=Y,OA=J,_A=O);const DA=async()=>{if(!Q)return;await gt(Q)&&(A(),jA(),C(""))},NA=KA=>{KA||A()},FA=KA=>{kA(KA),KA||lA(null)};return Z.jsxs(kT,{open:e,onOpenChange:NA,children:[Z.jsxs(I1,{style:{width:"calc(100vw - 2rem)",zIndex:Mii.dialog},className:"rf-rounded-sm rf-max-h-[90vh] rf-overflow-y-auto rf-overflow-x-hidden rf-flex rf-flex-col",children:[Z.jsxs(l1,{children:[Z.jsxs(B1,{className:"rf-text-lg sm:rf-text-xl",children:["Import ",c?iz[I].label:""," ","Component"]}),Z.jsx(FT,{className:"rf-text-sm",children:g?"Search for components from available sources.":"Import options are disabled because no handlers were provided."})]}),g?Z.jsxs($7,{value:I,onValueChange:KA=>l(KA),className:"rf-min-w-0 rf-w-full",children:[!c&&Z.jsx(Cq,{className:"rf-flex rf-w-full rf-gap-2",children:a.map(KA=>Z.jsx(sD,{value:KA,className:"rf-flex-1 rf-text-xs sm:rf-text-sm",children:iz[KA].label},KA))}),Z.jsx(Rei,{query:B,placeholder:iz[I].placeholder,isSearching:JA,onQueryChange:C,onSubmit:mA}),Z.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:JA?Z.jsxs("div",{className:"rf-p-8 rf-text-center rf-text-zinc-500",children:[Z.jsx(hk,{className:"rf-h-8 rf-w-8 rf-animate-spin rf-mx-auto rf-mb-2"}),Z.jsx("p",{children:"Searching..."})]}):VA.length>0?Z.jsx(Jei,{results:VA,selected:Q,onSelect:h,onShowDetails:I==="tscircuit.com"?It:void 0}):Z.jsx("div",{className:"rf-p-8 rf-text-center rf-text-zinc-500",children:OA?`Error: ${OA}`:_A?iz[I].emptyMessage:"Enter a search term to find components"})})]}):null,EA?Z.jsx("div",{className:"rf-text-sm rf-text-red-600 rf-mt-2",children:EA}):null,Z.jsxs(vT,{className:"rf-flex rf-flex-col sm:rf-flex-row rf-gap-2",children:[Z.jsx(oI,{variant:"outline",onClick:A,className:"rf-order-2 sm:rf-order-1",children:"Cancel"}),Z.jsx(oI,{onClick:DA,disabled:!Q||dA,className:"rf-order-1 sm:rf-order-2",children:dA?Z.jsx(hk,{className:"rf-h-4 rf-w-4 rf-animate-spin"}):"Import"})]})]}),Z.jsx(Tei,{packageResult:rA,isOpen:pA,onOpenChange:FA,isLoading:aA,details:tA,previewTab:MA,onPreviewTabChange:KA=>YA(KA),isSubmitting:dA,onImport:()=>{rA&>(rA).then(KA=>{KA&&(kA(!1),A(),jA(),C(""))})}})]})},Nii=e=>{const A=e.match(/export const (\w+) =/);if(!A)throw new Error("Could not determine component name from TSX contents");return A[1]},QEt=e=>{const A=CS(s=>s.pushEvent),t=CS(s=>s.upsertFile),i=async({result:s,fullPackageName:r})=>{const g=s.package.unscoped_name??s.package.name;await Zs.promise(A({event_type:"INSTALL_PACKAGE",full_package_name:r}),{loading:`Requesting install for "${g}"`,success:`Install requested for "${g}"`,error:c=>`Failed to request install: ${c instanceof Error?c.message:String(c)}`})},n=async({footprint:s})=>{await Zs.promise(navigator.clipboard.writeText(s),{loading:`Copying "${s}"`,success:`Copied "${s}" to clipboard`,error:r=>`Failed to copy footprint: ${r instanceof Error?r.message:String(r)}`})},o=async({result:s,tsx:r})=>{const g=`imports/${Nii(r)}.tsx`;await Zs.promise(t(g,r),{loading:`Importing ${s.component.partNumber}`,success:`Imported to "${g}"`,error:c=>`Failed to import component: ${c instanceof Error?c.message:String(c)}`})};return Z.jsx(Rii,{...e,onTscircuitPackageSelected:i,onKicadStringSelected:n,onJlcpcbComponentTsxLoaded:o})};QEt.displayName="ImportComponentDialogForCli";var nmA={exports:{}},hEt;function Lii(){return hEt||(hEt=1,(function(e,A){var t={env:{},version:""};(function(i){e.exports=i()})(function(){return(function i(n,o,s){function r(c,I){if(!o[c]){if(!n[c]){var l=typeof w_=="function"&&w_;if(!I&&l)return l(c,!0);if(a)return a(c,!0);var B=new Error("Cannot find module '"+c+"'");throw B.code="MODULE_NOT_FOUND",B}var C=o[c]={exports:{}};n[c][0].call(C.exports,function(Q){var h=n[c][1][Q];return r(h||Q)},C,C.exports,i,n,o,s)}return o[c].exports}for(var a=typeof w_=="function"&&w_,g=0;g<s.length;g++)r(s[g]);return r})({1:[function(i,n,o){var s=i("./utils"),r=i("./support"),a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";o.encode=function(g){for(var c,I,l,B,C,Q,h,E=[],u=0,d=g.length,f=d,m=s.getTypeOf(g)!=="string";u<g.length;)f=d-u,l=m?(c=g[u++],I=u<d?g[u++]:0,u<d?g[u++]:0):(c=g.charCodeAt(u++),I=u<d?g.charCodeAt(u++):0,u<d?g.charCodeAt(u++):0),B=c>>2,C=(3&c)<<4|I>>4,Q=1<f?(15&I)<<2|l>>6:64,h=2<f?63&l:64,E.push(a.charAt(B)+a.charAt(C)+a.charAt(Q)+a.charAt(h));return E.join("")},o.decode=function(g){var c,I,l,B,C,Q,h=0,E=0,u="data:";if(g.substr(0,u.length)===u)throw new Error("Invalid base64 input, it looks like a data url.");var d,f=3*(g=g.replace(/[^A-Za-z0-9+/=]/g,"")).length/4;if(g.charAt(g.length-1)===a.charAt(64)&&f--,g.charAt(g.length-2)===a.charAt(64)&&f--,f%1!=0)throw new Error("Invalid base64 input, bad content length.");for(d=r.uint8array?new Uint8Array(0|f):new Array(0|f);h<g.length;)c=a.indexOf(g.charAt(h++))<<2|(B=a.indexOf(g.charAt(h++)))>>4,I=(15&B)<<4|(C=a.indexOf(g.charAt(h++)))>>2,l=(3&C)<<6|(Q=a.indexOf(g.charAt(h++))),d[E++]=c,C!==64&&(d[E++]=I),Q!==64&&(d[E++]=l);return d}},{"./support":30,"./utils":32}],2:[function(i,n,o){var s=i("./external"),r=i("./stream/DataWorker"),a=i("./stream/Crc32Probe"),g=i("./stream/DataLengthProbe");function c(I,l,B,C,Q){this.compressedSize=I,this.uncompressedSize=l,this.crc32=B,this.compression=C,this.compressedContent=Q}c.prototype={getContentWorker:function(){var I=new r(s.Promise.resolve(this.compressedContent)).pipe(this.compression.uncompressWorker()).pipe(new g("data_length")),l=this;return I.on("end",function(){if(this.streamInfo.data_length!==l.uncompressedSize)throw new Error("Bug : uncompressed data size mismatch")}),I},getCompressedWorker:function(){return new r(s.Promise.resolve(this.compressedContent)).withStreamInfo("compressedSize",this.compressedSize).withStreamInfo("uncompressedSize",this.uncompressedSize).withStreamInfo("crc32",this.crc32).withStreamInfo("compression",this.compression)}},c.createWorkerFrom=function(I,l,B){return I.pipe(new a).pipe(new g("uncompressedSize")).pipe(l.compressWorker(B)).pipe(new g("compressedSize")).withStreamInfo("compression",l)},n.exports=c},{"./external":6,"./stream/Crc32Probe":25,"./stream/DataLengthProbe":26,"./stream/DataWorker":27}],3:[function(i,n,o){var s=i("./stream/GenericWorker");o.STORE={magic:"\0\0",compressWorker:function(){return new s("STORE compression")},uncompressWorker:function(){return new s("STORE decompression")}},o.DEFLATE=i("./flate")},{"./flate":7,"./stream/GenericWorker":28}],4:[function(i,n,o){var s=i("./utils"),r=(function(){for(var a,g=[],c=0;c<256;c++){a=c;for(var I=0;I<8;I++)a=1&a?3988292384^a>>>1:a>>>1;g[c]=a}return g})();n.exports=function(a,g){return a!==void 0&&a.length?s.getTypeOf(a)!=="string"?(function(c,I,l,B){var C=r,Q=B+l;c^=-1;for(var h=B;h<Q;h++)c=c>>>8^C[255&(c^I[h])];return-1^c})(0|g,a,a.length,0):(function(c,I,l,B){var C=r,Q=B+l;c^=-1;for(var h=B;h<Q;h++)c=c>>>8^C[255&(c^I.charCodeAt(h))];return-1^c})(0|g,a,a.length,0):0}},{"./utils":32}],5:[function(i,n,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(i,n,o){var s=null;s=typeof Promise<"u"?Promise:i("lie"),n.exports={Promise:s}},{lie:37}],7:[function(i,n,o){var s=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Uint32Array<"u",r=i("pako"),a=i("./utils"),g=i("./stream/GenericWorker"),c=s?"uint8array":"array";function I(l,B){g.call(this,"FlateWorker/"+l),this._pako=null,this._pakoAction=l,this._pakoOptions=B,this.meta={}}o.magic="\b\0",a.inherits(I,g),I.prototype.processChunk=function(l){this.meta=l.meta,this._pako===null&&this._createPako(),this._pako.push(a.transformTo(c,l.data),!1)},I.prototype.flush=function(){g.prototype.flush.call(this),this._pako===null&&this._createPako(),this._pako.push([],!0)},I.prototype.cleanUp=function(){g.prototype.cleanUp.call(this),this._pako=null},I.prototype._createPako=function(){this._pako=new r[this._pakoAction]({raw:!0,level:this._pakoOptions.level||-1});var l=this;this._pako.onData=function(B){l.push({data:B,meta:l.meta})}},o.compressWorker=function(l){return new I("Deflate",l)},o.uncompressWorker=function(){return new I("Inflate",{})}},{"./stream/GenericWorker":28,"./utils":32,pako:38}],8:[function(i,n,o){function s(C,Q){var h,E="";for(h=0;h<Q;h++)E+=String.fromCharCode(255&C),C>>>=8;return E}function r(C,Q,h,E,u,d){var f,m,w=C.file,D=C.compression,S=d!==c.utf8encode,_=a.transformTo("string",d(w.name)),b=a.transformTo("string",c.utf8encode(w.name)),R=w.comment,F=a.transformTo("string",d(R)),H=a.transformTo("string",c.utf8encode(R)),Y=b.length!==w.name.length,J=H.length!==R.length,O="",W="",z="",tA=w.dir,aA=w.date,eA={crc32:0,compressedSize:0,uncompressedSize:0};Q&&!h||(eA.crc32=C.crc32,eA.compressedSize=C.compressedSize,eA.uncompressedSize=C.uncompressedSize);var oA=0;Q&&(oA|=8),S||!Y&&!J||(oA|=2048);var rA=0,lA=0;tA&&(rA|=16),u==="UNIX"?(lA=798,rA|=(function(kA,MA){var YA=kA;return kA||(YA=MA?16893:33204),(65535&YA)<<16})(w.unixPermissions,tA)):(lA=20,rA|=(function(kA){return 63&(kA||0)})(w.dosPermissions)),f=aA.getUTCHours(),f<<=6,f|=aA.getUTCMinutes(),f<<=5,f|=aA.getUTCSeconds()/2,m=aA.getUTCFullYear()-1980,m<<=4,m|=aA.getUTCMonth()+1,m<<=5,m|=aA.getUTCDate(),Y&&(W=s(1,1)+s(I(_),4)+b,O+="up"+s(W.length,2)+W),J&&(z=s(1,1)+s(I(F),4)+H,O+="uc"+s(z.length,2)+z);var pA="";return pA+=`
|
|
5703
5703
|
\0`,pA+=s(oA,2),pA+=D.magic,pA+=s(f,2),pA+=s(m,2),pA+=s(eA.crc32,4),pA+=s(eA.compressedSize,4),pA+=s(eA.uncompressedSize,4),pA+=s(_.length,2),pA+=s(O.length,2),{fileRecord:l.LOCAL_FILE_HEADER+pA+_+O,dirRecord:l.CENTRAL_FILE_HEADER+s(lA,2)+pA+s(F.length,2)+"\0\0\0\0"+s(rA,4)+s(E,4)+_+O+F}}var a=i("../utils"),g=i("../stream/GenericWorker"),c=i("../utf8"),I=i("../crc32"),l=i("../signature");function B(C,Q,h,E){g.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=Q,this.zipPlatform=h,this.encodeFileName=E,this.streamFiles=C,this.accumulate=!1,this.contentBuffer=[],this.dirRecords=[],this.currentSourceOffset=0,this.entriesCount=0,this.currentFile=null,this._sources=[]}a.inherits(B,g),B.prototype.push=function(C){var Q=C.meta.percent||0,h=this.entriesCount,E=this._sources.length;this.accumulate?this.contentBuffer.push(C):(this.bytesWritten+=C.data.length,g.prototype.push.call(this,{data:C.data,meta:{currentFile:this.currentFile,percent:h?(Q+100*(h-E-1))/h:100}}))},B.prototype.openedSource=function(C){this.currentSourceOffset=this.bytesWritten,this.currentFile=C.file.name;var Q=this.streamFiles&&!C.file.dir;if(Q){var h=r(C,Q,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:h.fileRecord,meta:{percent:0}})}else this.accumulate=!0},B.prototype.closedSource=function(C){this.accumulate=!1;var Q=this.streamFiles&&!C.file.dir,h=r(C,Q,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(h.dirRecord),Q)this.push({data:(function(E){return l.DATA_DESCRIPTOR+s(E.crc32,4)+s(E.compressedSize,4)+s(E.uncompressedSize,4)})(C),meta:{percent:100}});else for(this.push({data:h.fileRecord,meta:{percent:0}});this.contentBuffer.length;)this.push(this.contentBuffer.shift());this.currentFile=null},B.prototype.flush=function(){for(var C=this.bytesWritten,Q=0;Q<this.dirRecords.length;Q++)this.push({data:this.dirRecords[Q],meta:{percent:100}});var h=this.bytesWritten-C,E=(function(u,d,f,m,w){var D=a.transformTo("string",w(m));return l.CENTRAL_DIRECTORY_END+"\0\0\0\0"+s(u,2)+s(u,2)+s(d,4)+s(f,4)+s(D.length,2)+D})(this.dirRecords.length,h,C,this.zipComment,this.encodeFileName);this.push({data:E,meta:{percent:100}})},B.prototype.prepareNextSource=function(){this.previous=this._sources.shift(),this.openedSource(this.previous.streamInfo),this.isPaused?this.previous.pause():this.previous.resume()},B.prototype.registerPrevious=function(C){this._sources.push(C);var Q=this;return C.on("data",function(h){Q.processChunk(h)}),C.on("end",function(){Q.closedSource(Q.previous.streamInfo),Q._sources.length?Q.prepareNextSource():Q.end()}),C.on("error",function(h){Q.error(h)}),this},B.prototype.resume=function(){return!!g.prototype.resume.call(this)&&(!this.previous&&this._sources.length?(this.prepareNextSource(),!0):this.previous||this._sources.length||this.generatedError?void 0:(this.end(),!0))},B.prototype.error=function(C){var Q=this._sources;if(!g.prototype.error.call(this,C))return!1;for(var h=0;h<Q.length;h++)try{Q[h].error(C)}catch{}return!0},B.prototype.lock=function(){g.prototype.lock.call(this);for(var C=this._sources,Q=0;Q<C.length;Q++)C[Q].lock()},n.exports=B},{"../crc32":4,"../signature":23,"../stream/GenericWorker":28,"../utf8":31,"../utils":32}],9:[function(i,n,o){var s=i("../compressions"),r=i("./ZipFileWorker");o.generateWorker=function(a,g,c){var I=new r(g.streamFiles,c,g.platform,g.encodeFileName),l=0;try{a.forEach(function(B,C){l++;var Q=(function(d,f){var m=d||f,w=s[m];if(!w)throw new Error(m+" is not a valid compression method !");return w})(C.options.compression,g.compression),h=C.options.compressionOptions||g.compressionOptions||{},E=C.dir,u=C.date;C._compressWorker(Q,h).withStreamInfo("file",{name:B,dir:E,date:u,comment:C.comment||"",unixPermissions:C.unixPermissions,dosPermissions:C.dosPermissions}).pipe(I)}),I.entriesCount=l}catch(B){I.error(B)}return I}},{"../compressions":3,"./ZipFileWorker":8}],10:[function(i,n,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 r=new s;for(var a in this)typeof this[a]!="function"&&(r[a]=this[a]);return r}}(s.prototype=i("./object")).loadAsync=i("./load"),s.support=i("./support"),s.defaults=i("./defaults"),s.version="3.10.1",s.loadAsync=function(r,a){return new s().loadAsync(r,a)},s.external=i("./external"),n.exports=s},{"./defaults":5,"./external":6,"./load":11,"./object":15,"./support":30}],11:[function(i,n,o){var s=i("./utils"),r=i("./external"),a=i("./utf8"),g=i("./zipEntries"),c=i("./stream/Crc32Probe"),I=i("./nodejsUtils");function l(B){return new r.Promise(function(C,Q){var h=B.decompressed.getContentWorker().pipe(new c);h.on("error",function(E){Q(E)}).on("end",function(){h.streamInfo.crc32!==B.decompressed.crc32?Q(new Error("Corrupted zip : CRC32 mismatch")):C()}).resume()})}n.exports=function(B,C){var Q=this;return C=s.extend(C||{},{base64:!1,checkCRC32:!1,optimizedBinaryString:!1,createFolders:!1,decodeFileName:a.utf8decode}),I.isNode&&I.isStream(B)?r.Promise.reject(new Error("JSZip can't accept a stream when loading a zip file.")):s.prepareContent("the loaded zip file",B,!0,C.optimizedBinaryString,C.base64).then(function(h){var E=new g(C);return E.load(h),E}).then(function(h){var E=[r.Promise.resolve(h)],u=h.files;if(C.checkCRC32)for(var d=0;d<u.length;d++)E.push(l(u[d]));return r.Promise.all(E)}).then(function(h){for(var E=h.shift(),u=E.files,d=0;d<u.length;d++){var f=u[d],m=f.fileNameStr,w=s.resolve(f.fileNameStr);Q.file(w,f.decompressed,{binary:!0,optimizedBinaryString:!0,date:f.date,dir:f.dir,comment:f.fileCommentStr.length?f.fileCommentStr:null,unixPermissions:f.unixPermissions,dosPermissions:f.dosPermissions,createFolders:C.createFolders}),f.dir||(Q.file(w).unsafeOriginalName=m)}return E.zipComment.length&&(Q.comment=E.zipComment),Q})}},{"./external":6,"./nodejsUtils":14,"./stream/Crc32Probe":25,"./utf8":31,"./utils":32,"./zipEntries":33}],12:[function(i,n,o){var s=i("../utils"),r=i("../stream/GenericWorker");function a(g,c){r.call(this,"Nodejs stream input adapter for "+g),this._upstreamEnded=!1,this._bindStream(c)}s.inherits(a,r),a.prototype._bindStream=function(g){var c=this;(this._stream=g).pause(),g.on("data",function(I){c.push({data:I,meta:{percent:0}})}).on("error",function(I){c.isPaused?this.generatedError=I:c.error(I)}).on("end",function(){c.isPaused?c._upstreamEnded=!0:c.end()})},a.prototype.pause=function(){return!!r.prototype.pause.call(this)&&(this._stream.pause(),!0)},a.prototype.resume=function(){return!!r.prototype.resume.call(this)&&(this._upstreamEnded?this.end():this._stream.resume(),!0)},n.exports=a},{"../stream/GenericWorker":28,"../utils":32}],13:[function(i,n,o){var s=i("readable-stream").Readable;function r(a,g,c){s.call(this,g),this._helper=a;var I=this;a.on("data",function(l,B){I.push(l)||I._helper.pause(),c&&c(B)}).on("error",function(l){I.emit("error",l)}).on("end",function(){I.push(null)})}i("../utils").inherits(r,s),r.prototype._read=function(){this._helper.resume()},n.exports=r},{"../utils":32,"readable-stream":16}],14:[function(i,n,o){n.exports={isNode:typeof Buffer<"u",newBufferFrom:function(s,r){if(Buffer.from&&Buffer.from!==Uint8Array.from)return Buffer.from(s,r);if(typeof s=="number")throw new Error('The "data" argument must not be a number');return new Buffer(s,r)},allocBuffer:function(s){if(Buffer.alloc)return Buffer.alloc(s);var r=new Buffer(s);return r.fill(0),r},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(i,n,o){function s(w,D,S){var _,b=a.getTypeOf(D),R=a.extend(S||{},I);R.date=R.date||new Date,R.compression!==null&&(R.compression=R.compression.toUpperCase()),typeof R.unixPermissions=="string"&&(R.unixPermissions=parseInt(R.unixPermissions,8)),R.unixPermissions&&16384&R.unixPermissions&&(R.dir=!0),R.dosPermissions&&16&R.dosPermissions&&(R.dir=!0),R.dir&&(w=u(w)),R.createFolders&&(_=E(w))&&d.call(this,_,!0);var F=b==="string"&&R.binary===!1&&R.base64===!1;S&&S.binary!==void 0||(R.binary=!F),(D instanceof l&&D.uncompressedSize===0||R.dir||!D||D.length===0)&&(R.base64=!1,R.binary=!0,D="",R.compression="STORE",b="string");var H=null;H=D instanceof l||D instanceof g?D:Q.isNode&&Q.isStream(D)?new h(w,D):a.prepareContent(w,D,R.binary,R.optimizedBinaryString,R.base64);var Y=new B(w,H,R);this.files[w]=Y}var r=i("./utf8"),a=i("./utils"),g=i("./stream/GenericWorker"),c=i("./stream/StreamHelper"),I=i("./defaults"),l=i("./compressedObject"),B=i("./zipObject"),C=i("./generate"),Q=i("./nodejsUtils"),h=i("./nodejs/NodejsStreamInputAdapter"),E=function(w){w.slice(-1)==="/"&&(w=w.substring(0,w.length-1));var D=w.lastIndexOf("/");return 0<D?w.substring(0,D):""},u=function(w){return w.slice(-1)!=="/"&&(w+="/"),w},d=function(w,D){return D=D!==void 0?D:I.createFolders,w=u(w),this.files[w]||s.call(this,w,null,{dir:!0,createFolders:D}),this.files[w]};function f(w){return Object.prototype.toString.call(w)==="[object RegExp]"}var m={load:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},forEach:function(w){var D,S,_;for(D in this.files)_=this.files[D],(S=D.slice(this.root.length,D.length))&&D.slice(0,this.root.length)===this.root&&w(S,_)},filter:function(w){var D=[];return this.forEach(function(S,_){w(S,_)&&D.push(_)}),D},file:function(w,D,S){if(arguments.length!==1)return w=this.root+w,s.call(this,w,D,S),this;if(f(w)){var _=w;return this.filter(function(R,F){return!F.dir&&_.test(R)})}var b=this.files[this.root+w];return b&&!b.dir?b:null},folder:function(w){if(!w)return this;if(f(w))return this.filter(function(b,R){return R.dir&&w.test(b)});var D=this.root+w,S=d.call(this,D),_=this.clone();return _.root=S.name,_},remove:function(w){w=this.root+w;var D=this.files[w];if(D||(w.slice(-1)!=="/"&&(w+="/"),D=this.files[w]),D&&!D.dir)delete this.files[w];else for(var S=this.filter(function(b,R){return R.name.slice(0,w.length)===w}),_=0;_<S.length;_++)delete this.files[S[_].name];return this},generate:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},generateInternalStream:function(w){var D,S={};try{if((S=a.extend(w||{},{streamFiles:!1,compression:"STORE",compressionOptions:null,type:"",platform:"DOS",comment:null,mimeType:"application/zip",encodeFileName:r.utf8encode})).type=S.type.toLowerCase(),S.compression=S.compression.toUpperCase(),S.type==="binarystring"&&(S.type="string"),!S.type)throw new Error("No output type specified.");a.checkSupport(S.type),S.platform!=="darwin"&&S.platform!=="freebsd"&&S.platform!=="linux"&&S.platform!=="sunos"||(S.platform="UNIX"),S.platform==="win32"&&(S.platform="DOS");var _=S.comment||this.comment||"";D=C.generateWorker(this,S,_)}catch(b){(D=new g("error")).error(b)}return new c(D,S.type||"string",S.mimeType)},generateAsync:function(w,D){return this.generateInternalStream(w).accumulate(D)},generateNodeStream:function(w,D){return(w=w||{}).type||(w.type="nodebuffer"),this.generateInternalStream(w).toNodejsStream(D)}};n.exports=m},{"./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(i,n,o){n.exports=i("stream")},{stream:void 0}],17:[function(i,n,o){var s=i("./DataReader");function r(a){s.call(this,a);for(var g=0;g<this.data.length;g++)a[g]=255&a[g]}i("../utils").inherits(r,s),r.prototype.byteAt=function(a){return this.data[this.zero+a]},r.prototype.lastIndexOfSignature=function(a){for(var g=a.charCodeAt(0),c=a.charCodeAt(1),I=a.charCodeAt(2),l=a.charCodeAt(3),B=this.length-4;0<=B;--B)if(this.data[B]===g&&this.data[B+1]===c&&this.data[B+2]===I&&this.data[B+3]===l)return B-this.zero;return-1},r.prototype.readAndCheckSignature=function(a){var g=a.charCodeAt(0),c=a.charCodeAt(1),I=a.charCodeAt(2),l=a.charCodeAt(3),B=this.readData(4);return g===B[0]&&c===B[1]&&I===B[2]&&l===B[3]},r.prototype.readData=function(a){if(this.checkOffset(a),a===0)return[];var g=this.data.slice(this.zero+this.index,this.zero+this.index+a);return this.index+=a,g},n.exports=r},{"../utils":32,"./DataReader":18}],18:[function(i,n,o){var s=i("../utils");function r(a){this.data=a,this.length=a.length,this.index=0,this.zero=0}r.prototype={checkOffset:function(a){this.checkIndex(this.index+a)},checkIndex:function(a){if(this.length<this.zero+a||a<0)throw new Error("End of data reached (data length = "+this.length+", asked index = "+a+"). Corrupted zip ?")},setIndex:function(a){this.checkIndex(a),this.index=a},skip:function(a){this.setIndex(this.index+a)},byteAt:function(){},readInt:function(a){var g,c=0;for(this.checkOffset(a),g=this.index+a-1;g>=this.index;g--)c=(c<<8)+this.byteAt(g);return this.index+=a,c},readString:function(a){return s.transformTo("string",this.readData(a))},readData:function(){},lastIndexOfSignature:function(){},readAndCheckSignature:function(){},readDate:function(){var a=this.readInt(4);return new Date(Date.UTC(1980+(a>>25&127),(a>>21&15)-1,a>>16&31,a>>11&31,a>>5&63,(31&a)<<1))}},n.exports=r},{"../utils":32}],19:[function(i,n,o){var s=i("./Uint8ArrayReader");function r(a){s.call(this,a)}i("../utils").inherits(r,s),r.prototype.readData=function(a){this.checkOffset(a);var g=this.data.slice(this.zero+this.index,this.zero+this.index+a);return this.index+=a,g},n.exports=r},{"../utils":32,"./Uint8ArrayReader":21}],20:[function(i,n,o){var s=i("./DataReader");function r(a){s.call(this,a)}i("../utils").inherits(r,s),r.prototype.byteAt=function(a){return this.data.charCodeAt(this.zero+a)},r.prototype.lastIndexOfSignature=function(a){return this.data.lastIndexOf(a)-this.zero},r.prototype.readAndCheckSignature=function(a){return a===this.readData(4)},r.prototype.readData=function(a){this.checkOffset(a);var g=this.data.slice(this.zero+this.index,this.zero+this.index+a);return this.index+=a,g},n.exports=r},{"../utils":32,"./DataReader":18}],21:[function(i,n,o){var s=i("./ArrayReader");function r(a){s.call(this,a)}i("../utils").inherits(r,s),r.prototype.readData=function(a){if(this.checkOffset(a),a===0)return new Uint8Array(0);var g=this.data.subarray(this.zero+this.index,this.zero+this.index+a);return this.index+=a,g},n.exports=r},{"../utils":32,"./ArrayReader":17}],22:[function(i,n,o){var s=i("../utils"),r=i("../support"),a=i("./ArrayReader"),g=i("./StringReader"),c=i("./NodeBufferReader"),I=i("./Uint8ArrayReader");n.exports=function(l){var B=s.getTypeOf(l);return s.checkSupport(B),B!=="string"||r.uint8array?B==="nodebuffer"?new c(l):r.uint8array?new I(s.transformTo("uint8array",l)):new a(s.transformTo("array",l)):new g(l)}},{"../support":30,"../utils":32,"./ArrayReader":17,"./NodeBufferReader":19,"./StringReader":20,"./Uint8ArrayReader":21}],23:[function(i,n,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(i,n,o){var s=i("./GenericWorker"),r=i("../utils");function a(g){s.call(this,"ConvertWorker to "+g),this.destType=g}r.inherits(a,s),a.prototype.processChunk=function(g){this.push({data:r.transformTo(this.destType,g.data),meta:g.meta})},n.exports=a},{"../utils":32,"./GenericWorker":28}],25:[function(i,n,o){var s=i("./GenericWorker"),r=i("../crc32");function a(){s.call(this,"Crc32Probe"),this.withStreamInfo("crc32",0)}i("../utils").inherits(a,s),a.prototype.processChunk=function(g){this.streamInfo.crc32=r(g.data,this.streamInfo.crc32||0),this.push(g)},n.exports=a},{"../crc32":4,"../utils":32,"./GenericWorker":28}],26:[function(i,n,o){var s=i("../utils"),r=i("./GenericWorker");function a(g){r.call(this,"DataLengthProbe for "+g),this.propName=g,this.withStreamInfo(g,0)}s.inherits(a,r),a.prototype.processChunk=function(g){if(g){var c=this.streamInfo[this.propName]||0;this.streamInfo[this.propName]=c+g.data.length}r.prototype.processChunk.call(this,g)},n.exports=a},{"../utils":32,"./GenericWorker":28}],27:[function(i,n,o){var s=i("../utils"),r=i("./GenericWorker");function a(g){r.call(this,"DataWorker");var c=this;this.dataIsReady=!1,this.index=0,this.max=0,this.data=null,this.type="",this._tickScheduled=!1,g.then(function(I){c.dataIsReady=!0,c.data=I,c.max=I&&I.length||0,c.type=s.getTypeOf(I),c.isPaused||c._tickAndRepeat()},function(I){c.error(I)})}s.inherits(a,r),a.prototype.cleanUp=function(){r.prototype.cleanUp.call(this),this.data=null},a.prototype.resume=function(){return!!r.prototype.resume.call(this)&&(!this._tickScheduled&&this.dataIsReady&&(this._tickScheduled=!0,s.delay(this._tickAndRepeat,[],this)),!0)},a.prototype._tickAndRepeat=function(){this._tickScheduled=!1,this.isPaused||this.isFinished||(this._tick(),this.isFinished||(s.delay(this._tickAndRepeat,[],this),this._tickScheduled=!0))},a.prototype._tick=function(){if(this.isPaused||this.isFinished)return!1;var g=null,c=Math.min(this.max,this.index+16384);if(this.index>=this.max)return this.end();switch(this.type){case"string":g=this.data.substring(this.index,c);break;case"uint8array":g=this.data.subarray(this.index,c);break;case"array":case"nodebuffer":g=this.data.slice(this.index,c)}return this.index=c,this.push({data:g,meta:{percent:this.max?this.index/this.max*100:0}})},n.exports=a},{"../utils":32,"./GenericWorker":28}],28:[function(i,n,o){function s(r){this.name=r||"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(r){this.emit("data",r)},end:function(){if(this.isFinished)return!1;this.flush();try{this.emit("end"),this.cleanUp(),this.isFinished=!0}catch(r){this.emit("error",r)}return!0},error:function(r){return!this.isFinished&&(this.isPaused?this.generatedError=r:(this.isFinished=!0,this.emit("error",r),this.previous&&this.previous.error(r),this.cleanUp()),!0)},on:function(r,a){return this._listeners[r].push(a),this},cleanUp:function(){this.streamInfo=this.generatedError=this.extraStreamInfo=null,this._listeners=[]},emit:function(r,a){if(this._listeners[r])for(var g=0;g<this._listeners[r].length;g++)this._listeners[r][g].call(this,a)},pipe:function(r){return r.registerPrevious(this)},registerPrevious:function(r){if(this.isLocked)throw new Error("The stream '"+this+"' has already been used.");this.streamInfo=r.streamInfo,this.mergeStreamInfo(),this.previous=r;var a=this;return r.on("data",function(g){a.processChunk(g)}),r.on("end",function(){a.end()}),r.on("error",function(g){a.error(g)}),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 r=this.isPaused=!1;return this.generatedError&&(this.error(this.generatedError),r=!0),this.previous&&this.previous.resume(),!r},flush:function(){},processChunk:function(r){this.push(r)},withStreamInfo:function(r,a){return this.extraStreamInfo[r]=a,this.mergeStreamInfo(),this},mergeStreamInfo:function(){for(var r in this.extraStreamInfo)Object.prototype.hasOwnProperty.call(this.extraStreamInfo,r)&&(this.streamInfo[r]=this.extraStreamInfo[r])},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 r="Worker "+this.name;return this.previous?this.previous+" -> "+r:r}},n.exports=s},{}],29:[function(i,n,o){var s=i("../utils"),r=i("./ConvertWorker"),a=i("./GenericWorker"),g=i("../base64"),c=i("../support"),I=i("../external"),l=null;if(c.nodestream)try{l=i("../nodejs/NodejsStreamOutputAdapter")}catch{}function B(Q,h){return new I.Promise(function(E,u){var d=[],f=Q._internalType,m=Q._outputType,w=Q._mimeType;Q.on("data",function(D,S){d.push(D),h&&h(S)}).on("error",function(D){d=[],u(D)}).on("end",function(){try{var D=(function(S,_,b){switch(S){case"blob":return s.newBlob(s.transformTo("arraybuffer",_),b);case"base64":return g.encode(_);default:return s.transformTo(S,_)}})(m,(function(S,_){var b,R=0,F=null,H=0;for(b=0;b<_.length;b++)H+=_[b].length;switch(S){case"string":return _.join("");case"array":return Array.prototype.concat.apply([],_);case"uint8array":for(F=new Uint8Array(H),b=0;b<_.length;b++)F.set(_[b],R),R+=_[b].length;return F;case"nodebuffer":return Buffer.concat(_);default:throw new Error("concat : unsupported type '"+S+"'")}})(f,d),w);E(D)}catch(S){u(S)}d=[]}).resume()})}function C(Q,h,E){var u=h;switch(h){case"blob":case"arraybuffer":u="uint8array";break;case"base64":u="string"}try{this._internalType=u,this._outputType=h,this._mimeType=E,s.checkSupport(u),this._worker=Q.pipe(new r(u)),Q.lock()}catch(d){this._worker=new a("error"),this._worker.error(d)}}C.prototype={accumulate:function(Q){return B(this,Q)},on:function(Q,h){var E=this;return Q==="data"?this._worker.on(Q,function(u){h.call(E,u.data,u.meta)}):this._worker.on(Q,function(){s.delay(h,arguments,E)}),this},resume:function(){return s.delay(this._worker.resume,[],this._worker),this},pause:function(){return this._worker.pause(),this},toNodejsStream:function(Q){if(s.checkSupport("nodestream"),this._outputType!=="nodebuffer")throw new Error(this._outputType+" is not supported by this method");return new l(this,{objectMode:this._outputType!=="nodebuffer"},Q)}},n.exports=C},{"../base64":1,"../external":6,"../nodejs/NodejsStreamOutputAdapter":13,"../support":30,"../utils":32,"./ConvertWorker":24,"./GenericWorker":28}],30:[function(i,n,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 r=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);r.append(s),o.blob=r.getBlob("application/zip").size===0}catch{o.blob=!1}}}try{o.nodestream=!!i("readable-stream").Readable}catch{o.nodestream=!1}},{"readable-stream":16}],31:[function(i,n,o){for(var s=i("./utils"),r=i("./support"),a=i("./nodejsUtils"),g=i("./stream/GenericWorker"),c=new Array(256),I=0;I<256;I++)c[I]=252<=I?6:248<=I?5:240<=I?4:224<=I?3:192<=I?2:1;c[254]=c[254]=1;function l(){g.call(this,"utf-8 decode"),this.leftOver=null}function B(){g.call(this,"utf-8 encode")}o.utf8encode=function(C){return r.nodebuffer?a.newBufferFrom(C,"utf-8"):(function(Q){var h,E,u,d,f,m=Q.length,w=0;for(d=0;d<m;d++)(64512&(E=Q.charCodeAt(d)))==55296&&d+1<m&&(64512&(u=Q.charCodeAt(d+1)))==56320&&(E=65536+(E-55296<<10)+(u-56320),d++),w+=E<128?1:E<2048?2:E<65536?3:4;for(h=r.uint8array?new Uint8Array(w):new Array(w),d=f=0;f<w;d++)(64512&(E=Q.charCodeAt(d)))==55296&&d+1<m&&(64512&(u=Q.charCodeAt(d+1)))==56320&&(E=65536+(E-55296<<10)+(u-56320),d++),E<128?h[f++]=E:(E<2048?h[f++]=192|E>>>6:(E<65536?h[f++]=224|E>>>12:(h[f++]=240|E>>>18,h[f++]=128|E>>>12&63),h[f++]=128|E>>>6&63),h[f++]=128|63&E);return h})(C)},o.utf8decode=function(C){return r.nodebuffer?s.transformTo("nodebuffer",C).toString("utf-8"):(function(Q){var h,E,u,d,f=Q.length,m=new Array(2*f);for(h=E=0;h<f;)if((u=Q[h++])<128)m[E++]=u;else if(4<(d=c[u]))m[E++]=65533,h+=d-1;else{for(u&=d===2?31:d===3?15:7;1<d&&h<f;)u=u<<6|63&Q[h++],d--;1<d?m[E++]=65533:u<65536?m[E++]=u:(u-=65536,m[E++]=55296|u>>10&1023,m[E++]=56320|1023&u)}return m.length!==E&&(m.subarray?m=m.subarray(0,E):m.length=E),s.applyFromCharCode(m)})(C=s.transformTo(r.uint8array?"uint8array":"array",C))},s.inherits(l,g),l.prototype.processChunk=function(C){var Q=s.transformTo(r.uint8array?"uint8array":"array",C.data);if(this.leftOver&&this.leftOver.length){if(r.uint8array){var h=Q;(Q=new Uint8Array(h.length+this.leftOver.length)).set(this.leftOver,0),Q.set(h,this.leftOver.length)}else Q=this.leftOver.concat(Q);this.leftOver=null}var E=(function(d,f){var m;for((f=f||d.length)>d.length&&(f=d.length),m=f-1;0<=m&&(192&d[m])==128;)m--;return m<0||m===0?f:m+c[d[m]]>f?m:f})(Q),u=Q;E!==Q.length&&(r.uint8array?(u=Q.subarray(0,E),this.leftOver=Q.subarray(E,Q.length)):(u=Q.slice(0,E),this.leftOver=Q.slice(E,Q.length))),this.push({data:o.utf8decode(u),meta:C.meta})},l.prototype.flush=function(){this.leftOver&&this.leftOver.length&&(this.push({data:o.utf8decode(this.leftOver),meta:{}}),this.leftOver=null)},o.Utf8DecodeWorker=l,s.inherits(B,g),B.prototype.processChunk=function(C){this.push({data:o.utf8encode(C.data),meta:C.meta})},o.Utf8EncodeWorker=B},{"./nodejsUtils":14,"./stream/GenericWorker":28,"./support":30,"./utils":32}],32:[function(i,n,o){var s=i("./support"),r=i("./base64"),a=i("./nodejsUtils"),g=i("./external");function c(h){return h}function I(h,E){for(var u=0;u<h.length;++u)E[u]=255&h.charCodeAt(u);return E}i("setimmediate"),o.newBlob=function(h,E){o.checkSupport("blob");try{return new Blob([h],{type:E})}catch{try{var u=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);return u.append(h),u.getBlob(E)}catch{throw new Error("Bug : can't construct the Blob.")}}};var l={stringifyByChunk:function(h,E,u){var d=[],f=0,m=h.length;if(m<=u)return String.fromCharCode.apply(null,h);for(;f<m;)E==="array"||E==="nodebuffer"?d.push(String.fromCharCode.apply(null,h.slice(f,Math.min(f+u,m)))):d.push(String.fromCharCode.apply(null,h.subarray(f,Math.min(f+u,m)))),f+=u;return d.join("")},stringifyByChar:function(h){for(var E="",u=0;u<h.length;u++)E+=String.fromCharCode(h[u]);return E},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,a.allocBuffer(1)).length===1}catch{return!1}})()}};function B(h){var E=65536,u=o.getTypeOf(h),d=!0;if(u==="uint8array"?d=l.applyCanBeUsed.uint8array:u==="nodebuffer"&&(d=l.applyCanBeUsed.nodebuffer),d)for(;1<E;)try{return l.stringifyByChunk(h,u,E)}catch{E=Math.floor(E/2)}return l.stringifyByChar(h)}function C(h,E){for(var u=0;u<h.length;u++)E[u]=h[u];return E}o.applyFromCharCode=B;var Q={};Q.string={string:c,array:function(h){return I(h,new Array(h.length))},arraybuffer:function(h){return Q.string.uint8array(h).buffer},uint8array:function(h){return I(h,new Uint8Array(h.length))},nodebuffer:function(h){return I(h,a.allocBuffer(h.length))}},Q.array={string:B,array:c,arraybuffer:function(h){return new Uint8Array(h).buffer},uint8array:function(h){return new Uint8Array(h)},nodebuffer:function(h){return a.newBufferFrom(h)}},Q.arraybuffer={string:function(h){return B(new Uint8Array(h))},array:function(h){return C(new Uint8Array(h),new Array(h.byteLength))},arraybuffer:c,uint8array:function(h){return new Uint8Array(h)},nodebuffer:function(h){return a.newBufferFrom(new Uint8Array(h))}},Q.uint8array={string:B,array:function(h){return C(h,new Array(h.length))},arraybuffer:function(h){return h.buffer},uint8array:c,nodebuffer:function(h){return a.newBufferFrom(h)}},Q.nodebuffer={string:B,array:function(h){return C(h,new Array(h.length))},arraybuffer:function(h){return Q.nodebuffer.uint8array(h).buffer},uint8array:function(h){return C(h,new Uint8Array(h.length))},nodebuffer:c},o.transformTo=function(h,E){if(E=E||"",!h)return E;o.checkSupport(h);var u=o.getTypeOf(E);return Q[u][h](E)},o.resolve=function(h){for(var E=h.split("/"),u=[],d=0;d<E.length;d++){var f=E[d];f==="."||f===""&&d!==0&&d!==E.length-1||(f===".."?u.pop():u.push(f))}return u.join("/")},o.getTypeOf=function(h){return typeof h=="string"?"string":Object.prototype.toString.call(h)==="[object Array]"?"array":s.nodebuffer&&a.isBuffer(h)?"nodebuffer":s.uint8array&&h instanceof Uint8Array?"uint8array":s.arraybuffer&&h instanceof ArrayBuffer?"arraybuffer":void 0},o.checkSupport=function(h){if(!s[h.toLowerCase()])throw new Error(h+" is not supported by this platform")},o.MAX_VALUE_16BITS=65535,o.MAX_VALUE_32BITS=-1,o.pretty=function(h){var E,u,d="";for(u=0;u<(h||"").length;u++)d+="\\x"+((E=h.charCodeAt(u))<16?"0":"")+E.toString(16).toUpperCase();return d},o.delay=function(h,E,u){setImmediate(function(){h.apply(u||null,E||[])})},o.inherits=function(h,E){function u(){}u.prototype=E.prototype,h.prototype=new u},o.extend=function(){var h,E,u={};for(h=0;h<arguments.length;h++)for(E in arguments[h])Object.prototype.hasOwnProperty.call(arguments[h],E)&&u[E]===void 0&&(u[E]=arguments[h][E]);return u},o.prepareContent=function(h,E,u,d,f){return g.Promise.resolve(E).then(function(m){return s.blob&&(m instanceof Blob||["[object File]","[object Blob]"].indexOf(Object.prototype.toString.call(m))!==-1)&&typeof FileReader<"u"?new g.Promise(function(w,D){var S=new FileReader;S.onload=function(_){w(_.target.result)},S.onerror=function(_){D(_.target.error)},S.readAsArrayBuffer(m)}):m}).then(function(m){var w=o.getTypeOf(m);return w?(w==="arraybuffer"?m=o.transformTo("uint8array",m):w==="string"&&(f?m=r.decode(m):u&&d!==!0&&(m=(function(D){return I(D,s.uint8array?new Uint8Array(D.length):new Array(D.length))})(m))),m):g.Promise.reject(new Error("Can't read the data of '"+h+"'. Is it in a supported JavaScript type (String, Blob, ArrayBuffer, etc) ?"))})}},{"./base64":1,"./external":6,"./nodejsUtils":14,"./support":30,setimmediate:54}],33:[function(i,n,o){var s=i("./reader/readerFor"),r=i("./utils"),a=i("./signature"),g=i("./zipEntry"),c=i("./support");function I(l){this.files=[],this.loadOptions=l}I.prototype={checkSignature:function(l){if(!this.reader.readAndCheckSignature(l)){this.reader.index-=4;var B=this.reader.readString(4);throw new Error("Corrupted zip or bug: unexpected signature ("+r.pretty(B)+", expected "+r.pretty(l)+")")}},isSignature:function(l,B){var C=this.reader.index;this.reader.setIndex(l);var Q=this.reader.readString(4)===B;return this.reader.setIndex(C),Q},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 l=this.reader.readData(this.zipCommentLength),B=c.uint8array?"uint8array":"array",C=r.transformTo(B,l);this.zipComment=this.loadOptions.decodeFileName(C)},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 l,B,C,Q=this.zip64EndOfCentralSize-44;0<Q;)l=this.reader.readInt(2),B=this.reader.readInt(4),C=this.reader.readData(B),this.zip64ExtensibleData[l]={id:l,length:B,value:C}},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 l,B;for(l=0;l<this.files.length;l++)B=this.files[l],this.reader.setIndex(B.localHeaderOffset),this.checkSignature(a.LOCAL_FILE_HEADER),B.readLocalPart(this.reader),B.handleUTF8(),B.processAttributes()},readCentralDir:function(){var l;for(this.reader.setIndex(this.centralDirOffset);this.reader.readAndCheckSignature(a.CENTRAL_FILE_HEADER);)(l=new g({zip64:this.zip64},this.loadOptions)).readCentralPart(this.reader),this.files.push(l);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 l=this.reader.lastIndexOfSignature(a.CENTRAL_DIRECTORY_END);if(l<0)throw this.isSignature(0,a.LOCAL_FILE_HEADER)?new Error("Corrupted zip: can't find end of central directory"):new Error("Can't find end of central directory : is this a zip file ? If it is, see https://stuk.github.io/jszip/documentation/howto/read_zip.html");this.reader.setIndex(l);var B=l;if(this.checkSignature(a.CENTRAL_DIRECTORY_END),this.readBlockEndOfCentral(),this.diskNumber===r.MAX_VALUE_16BITS||this.diskWithCentralDirStart===r.MAX_VALUE_16BITS||this.centralDirRecordsOnThisDisk===r.MAX_VALUE_16BITS||this.centralDirRecords===r.MAX_VALUE_16BITS||this.centralDirSize===r.MAX_VALUE_32BITS||this.centralDirOffset===r.MAX_VALUE_32BITS){if(this.zip64=!0,(l=this.reader.lastIndexOfSignature(a.ZIP64_CENTRAL_DIRECTORY_LOCATOR))<0)throw new Error("Corrupted zip: can't find the ZIP64 end of central directory locator");if(this.reader.setIndex(l),this.checkSignature(a.ZIP64_CENTRAL_DIRECTORY_LOCATOR),this.readBlockZip64EndOfCentralLocator(),!this.isSignature(this.relativeOffsetEndOfZip64CentralDir,a.ZIP64_CENTRAL_DIRECTORY_END)&&(this.relativeOffsetEndOfZip64CentralDir=this.reader.lastIndexOfSignature(a.ZIP64_CENTRAL_DIRECTORY_END),this.relativeOffsetEndOfZip64CentralDir<0))throw new Error("Corrupted zip: can't find the ZIP64 end of central directory");this.reader.setIndex(this.relativeOffsetEndOfZip64CentralDir),this.checkSignature(a.ZIP64_CENTRAL_DIRECTORY_END),this.readBlockZip64EndOfCentral()}var C=this.centralDirOffset+this.centralDirSize;this.zip64&&(C+=20,C+=12+this.zip64EndOfCentralSize);var Q=B-C;if(0<Q)this.isSignature(B,a.CENTRAL_FILE_HEADER)||(this.reader.zero=Q);else if(Q<0)throw new Error("Corrupted zip: missing "+Math.abs(Q)+" bytes.")},prepareReader:function(l){this.reader=s(l)},load:function(l){this.prepareReader(l),this.readEndOfCentral(),this.readCentralDir(),this.readLocalFiles()}},n.exports=I},{"./reader/readerFor":22,"./signature":23,"./support":30,"./utils":32,"./zipEntry":34}],34:[function(i,n,o){var s=i("./reader/readerFor"),r=i("./utils"),a=i("./compressedObject"),g=i("./crc32"),c=i("./utf8"),I=i("./compressions"),l=i("./support");function B(C,Q){this.options=C,this.loadOptions=Q}B.prototype={isEncrypted:function(){return(1&this.bitFlag)==1},useUTF8:function(){return(2048&this.bitFlag)==2048},readLocalPart:function(C){var Q,h;if(C.skip(22),this.fileNameLength=C.readInt(2),h=C.readInt(2),this.fileName=C.readData(this.fileNameLength),C.skip(h),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((Q=(function(E){for(var u in I)if(Object.prototype.hasOwnProperty.call(I,u)&&I[u].magic===E)return I[u];return null})(this.compressionMethod))===null)throw new Error("Corrupted zip : compression "+r.pretty(this.compressionMethod)+" unknown (inner file : "+r.transformTo("string",this.fileName)+")");this.decompressed=new a(this.compressedSize,this.uncompressedSize,this.crc32,Q,C.readData(this.compressedSize))},readCentralPart:function(C){this.versionMadeBy=C.readInt(2),C.skip(2),this.bitFlag=C.readInt(2),this.compressionMethod=C.readString(2),this.date=C.readDate(),this.crc32=C.readInt(4),this.compressedSize=C.readInt(4),this.uncompressedSize=C.readInt(4);var Q=C.readInt(2);if(this.extraFieldsLength=C.readInt(2),this.fileCommentLength=C.readInt(2),this.diskNumberStart=C.readInt(2),this.internalFileAttributes=C.readInt(2),this.externalFileAttributes=C.readInt(4),this.localHeaderOffset=C.readInt(4),this.isEncrypted())throw new Error("Encrypted zip are not supported");C.skip(Q),this.readExtraFields(C),this.parseZIP64ExtraField(C),this.fileComment=C.readData(this.fileCommentLength)},processAttributes:function(){this.unixPermissions=null,this.dosPermissions=null;var C=this.versionMadeBy>>8;this.dir=!!(16&this.externalFileAttributes),C==0&&(this.dosPermissions=63&this.externalFileAttributes),C==3&&(this.unixPermissions=this.externalFileAttributes>>16&65535),this.dir||this.fileNameStr.slice(-1)!=="/"||(this.dir=!0)},parseZIP64ExtraField:function(){if(this.extraFields[1]){var C=s(this.extraFields[1].value);this.uncompressedSize===r.MAX_VALUE_32BITS&&(this.uncompressedSize=C.readInt(8)),this.compressedSize===r.MAX_VALUE_32BITS&&(this.compressedSize=C.readInt(8)),this.localHeaderOffset===r.MAX_VALUE_32BITS&&(this.localHeaderOffset=C.readInt(8)),this.diskNumberStart===r.MAX_VALUE_32BITS&&(this.diskNumberStart=C.readInt(4))}},readExtraFields:function(C){var Q,h,E,u=C.index+this.extraFieldsLength;for(this.extraFields||(this.extraFields={});C.index+4<u;)Q=C.readInt(2),h=C.readInt(2),E=C.readData(h),this.extraFields[Q]={id:Q,length:h,value:E};C.setIndex(u)},handleUTF8:function(){var C=l.uint8array?"uint8array":"array";if(this.useUTF8())this.fileNameStr=c.utf8decode(this.fileName),this.fileCommentStr=c.utf8decode(this.fileComment);else{var Q=this.findExtraFieldUnicodePath();if(Q!==null)this.fileNameStr=Q;else{var h=r.transformTo(C,this.fileName);this.fileNameStr=this.loadOptions.decodeFileName(h)}var E=this.findExtraFieldUnicodeComment();if(E!==null)this.fileCommentStr=E;else{var u=r.transformTo(C,this.fileComment);this.fileCommentStr=this.loadOptions.decodeFileName(u)}}},findExtraFieldUnicodePath:function(){var C=this.extraFields[28789];if(C){var Q=s(C.value);return Q.readInt(1)!==1||g(this.fileName)!==Q.readInt(4)?null:c.utf8decode(Q.readData(C.length-5))}return null},findExtraFieldUnicodeComment:function(){var C=this.extraFields[25461];if(C){var Q=s(C.value);return Q.readInt(1)!==1||g(this.fileComment)!==Q.readInt(4)?null:c.utf8decode(Q.readData(C.length-5))}return null}},n.exports=B},{"./compressedObject":2,"./compressions":3,"./crc32":4,"./reader/readerFor":22,"./support":30,"./utf8":31,"./utils":32}],35:[function(i,n,o){function s(Q,h,E){this.name=Q,this.dir=E.dir,this.date=E.date,this.comment=E.comment,this.unixPermissions=E.unixPermissions,this.dosPermissions=E.dosPermissions,this._data=h,this._dataBinary=E.binary,this.options={compression:E.compression,compressionOptions:E.compressionOptions}}var r=i("./stream/StreamHelper"),a=i("./stream/DataWorker"),g=i("./utf8"),c=i("./compressedObject"),I=i("./stream/GenericWorker");s.prototype={internalStream:function(Q){var h=null,E="string";try{if(!Q)throw new Error("No output type specified.");var u=(E=Q.toLowerCase())==="string"||E==="text";E!=="binarystring"&&E!=="text"||(E="string"),h=this._decompressWorker();var d=!this._dataBinary;d&&!u&&(h=h.pipe(new g.Utf8EncodeWorker)),!d&&u&&(h=h.pipe(new g.Utf8DecodeWorker))}catch(f){(h=new I("error")).error(f)}return new r(h,E,"")},async:function(Q,h){return this.internalStream(Q).accumulate(h)},nodeStream:function(Q,h){return this.internalStream(Q||"nodebuffer").toNodejsStream(h)},_compressWorker:function(Q,h){if(this._data instanceof c&&this._data.compression.magic===Q.magic)return this._data.getCompressedWorker();var E=this._decompressWorker();return this._dataBinary||(E=E.pipe(new g.Utf8EncodeWorker)),c.createWorkerFrom(E,Q,h)},_decompressWorker:function(){return this._data instanceof c?this._data.getContentWorker():this._data instanceof I?this._data:new a(this._data)}};for(var l=["asText","asBinary","asNodeBuffer","asUint8Array","asArrayBuffer"],B=function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},C=0;C<l.length;C++)s.prototype[l[C]]=B;n.exports=s},{"./compressedObject":2,"./stream/DataWorker":27,"./stream/GenericWorker":28,"./stream/StreamHelper":29,"./utf8":31}],36:[function(i,n,o){(function(s){var r,a,g=s.MutationObserver||s.WebKitMutationObserver;if(g){var c=0,I=new g(Q),l=s.document.createTextNode("");I.observe(l,{characterData:!0}),r=function(){l.data=c=++c%2}}else if(s.setImmediate||s.MessageChannel===void 0)r="document"in s&&"onreadystatechange"in s.document.createElement("script")?function(){var h=s.document.createElement("script");h.onreadystatechange=function(){Q(),h.onreadystatechange=null,h.parentNode.removeChild(h),h=null},s.document.documentElement.appendChild(h)}:function(){setTimeout(Q,0)};else{var B=new s.MessageChannel;B.port1.onmessage=Q,r=function(){B.port2.postMessage(0)}}var C=[];function Q(){var h,E;a=!0;for(var u=C.length;u;){for(E=C,C=[],h=-1;++h<u;)E[h]();u=C.length}a=!1}n.exports=function(h){C.push(h)!==1||a||r()}}).call(this,typeof vK<"u"?vK:typeof self<"u"?self:typeof window<"u"?window:{})},{}],37:[function(i,n,o){var s=i("immediate");function r(){}var a={},g=["REJECTED"],c=["FULFILLED"],I=["PENDING"];function l(u){if(typeof u!="function")throw new TypeError("resolver must be a function");this.state=I,this.queue=[],this.outcome=void 0,u!==r&&h(this,u)}function B(u,d,f){this.promise=u,typeof d=="function"&&(this.onFulfilled=d,this.callFulfilled=this.otherCallFulfilled),typeof f=="function"&&(this.onRejected=f,this.callRejected=this.otherCallRejected)}function C(u,d,f){s(function(){var m;try{m=d(f)}catch(w){return a.reject(u,w)}m===u?a.reject(u,new TypeError("Cannot resolve promise with itself")):a.resolve(u,m)})}function Q(u){var d=u&&u.then;if(u&&(typeof u=="object"||typeof u=="function")&&typeof d=="function")return function(){d.apply(u,arguments)}}function h(u,d){var f=!1;function m(S){f||(f=!0,a.reject(u,S))}function w(S){f||(f=!0,a.resolve(u,S))}var D=E(function(){d(w,m)});D.status==="error"&&m(D.value)}function E(u,d){var f={};try{f.value=u(d),f.status="success"}catch(m){f.status="error",f.value=m}return f}(n.exports=l).prototype.finally=function(u){if(typeof u!="function")return this;var d=this.constructor;return this.then(function(f){return d.resolve(u()).then(function(){return f})},function(f){return d.resolve(u()).then(function(){throw f})})},l.prototype.catch=function(u){return this.then(null,u)},l.prototype.then=function(u,d){if(typeof u!="function"&&this.state===c||typeof d!="function"&&this.state===g)return this;var f=new this.constructor(r);return this.state!==I?C(f,this.state===c?u:d,this.outcome):this.queue.push(new B(f,u,d)),f},B.prototype.callFulfilled=function(u){a.resolve(this.promise,u)},B.prototype.otherCallFulfilled=function(u){C(this.promise,this.onFulfilled,u)},B.prototype.callRejected=function(u){a.reject(this.promise,u)},B.prototype.otherCallRejected=function(u){C(this.promise,this.onRejected,u)},a.resolve=function(u,d){var f=E(Q,d);if(f.status==="error")return a.reject(u,f.value);var m=f.value;if(m)h(u,m);else{u.state=c,u.outcome=d;for(var w=-1,D=u.queue.length;++w<D;)u.queue[w].callFulfilled(d)}return u},a.reject=function(u,d){u.state=g,u.outcome=d;for(var f=-1,m=u.queue.length;++f<m;)u.queue[f].callRejected(d);return u},l.resolve=function(u){return u instanceof this?u:a.resolve(new this(r),u)},l.reject=function(u){var d=new this(r);return a.reject(d,u)},l.all=function(u){var d=this;if(Object.prototype.toString.call(u)!=="[object Array]")return this.reject(new TypeError("must be an array"));var f=u.length,m=!1;if(!f)return this.resolve([]);for(var w=new Array(f),D=0,S=-1,_=new this(r);++S<f;)b(u[S],S);return _;function b(R,F){d.resolve(R).then(function(H){w[F]=H,++D!==f||m||(m=!0,a.resolve(_,w))},function(H){m||(m=!0,a.reject(_,H))})}},l.race=function(u){var d=this;if(Object.prototype.toString.call(u)!=="[object Array]")return this.reject(new TypeError("must be an array"));var f=u.length,m=!1;if(!f)return this.resolve([]);for(var w=-1,D=new this(r);++w<f;)S=u[w],d.resolve(S).then(function(_){m||(m=!0,a.resolve(D,_))},function(_){m||(m=!0,a.reject(D,_))});var S;return D}},{immediate:36}],38:[function(i,n,o){var s={};(0,i("./lib/utils/common").assign)(s,i("./lib/deflate"),i("./lib/inflate"),i("./lib/zlib/constants")),n.exports=s},{"./lib/deflate":39,"./lib/inflate":40,"./lib/utils/common":41,"./lib/zlib/constants":44}],39:[function(i,n,o){var s=i("./zlib/deflate"),r=i("./utils/common"),a=i("./utils/strings"),g=i("./zlib/messages"),c=i("./zlib/zstream"),I=Object.prototype.toString,l=0,B=-1,C=0,Q=8;function h(u){if(!(this instanceof h))return new h(u);this.options=r.assign({level:B,method:Q,chunkSize:16384,windowBits:15,memLevel:8,strategy:C,to:""},u||{});var d=this.options;d.raw&&0<d.windowBits?d.windowBits=-d.windowBits:d.gzip&&0<d.windowBits&&d.windowBits<16&&(d.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new c,this.strm.avail_out=0;var f=s.deflateInit2(this.strm,d.level,d.method,d.windowBits,d.memLevel,d.strategy);if(f!==l)throw new Error(g[f]);if(d.header&&s.deflateSetHeader(this.strm,d.header),d.dictionary){var m;if(m=typeof d.dictionary=="string"?a.string2buf(d.dictionary):I.call(d.dictionary)==="[object ArrayBuffer]"?new Uint8Array(d.dictionary):d.dictionary,(f=s.deflateSetDictionary(this.strm,m))!==l)throw new Error(g[f]);this._dict_set=!0}}function E(u,d){var f=new h(d);if(f.push(u,!0),f.err)throw f.msg||g[f.err];return f.result}h.prototype.push=function(u,d){var f,m,w=this.strm,D=this.options.chunkSize;if(this.ended)return!1;m=d===~~d?d:d===!0?4:0,typeof u=="string"?w.input=a.string2buf(u):I.call(u)==="[object ArrayBuffer]"?w.input=new Uint8Array(u):w.input=u,w.next_in=0,w.avail_in=w.input.length;do{if(w.avail_out===0&&(w.output=new r.Buf8(D),w.next_out=0,w.avail_out=D),(f=s.deflate(w,m))!==1&&f!==l)return this.onEnd(f),!(this.ended=!0);w.avail_out!==0&&(w.avail_in!==0||m!==4&&m!==2)||(this.options.to==="string"?this.onData(a.buf2binstring(r.shrinkBuf(w.output,w.next_out))):this.onData(r.shrinkBuf(w.output,w.next_out)))}while((0<w.avail_in||w.avail_out===0)&&f!==1);return m===4?(f=s.deflateEnd(this.strm),this.onEnd(f),this.ended=!0,f===l):m!==2||(this.onEnd(l),!(w.avail_out=0))},h.prototype.onData=function(u){this.chunks.push(u)},h.prototype.onEnd=function(u){u===l&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=r.flattenChunks(this.chunks)),this.chunks=[],this.err=u,this.msg=this.strm.msg},o.Deflate=h,o.deflate=E,o.deflateRaw=function(u,d){return(d=d||{}).raw=!0,E(u,d)},o.gzip=function(u,d){return(d=d||{}).gzip=!0,E(u,d)}},{"./utils/common":41,"./utils/strings":42,"./zlib/deflate":46,"./zlib/messages":51,"./zlib/zstream":53}],40:[function(i,n,o){var s=i("./zlib/inflate"),r=i("./utils/common"),a=i("./utils/strings"),g=i("./zlib/constants"),c=i("./zlib/messages"),I=i("./zlib/zstream"),l=i("./zlib/gzheader"),B=Object.prototype.toString;function C(h){if(!(this instanceof C))return new C(h);this.options=r.assign({chunkSize:16384,windowBits:0,to:""},h||{});var E=this.options;E.raw&&0<=E.windowBits&&E.windowBits<16&&(E.windowBits=-E.windowBits,E.windowBits===0&&(E.windowBits=-15)),!(0<=E.windowBits&&E.windowBits<16)||h&&h.windowBits||(E.windowBits+=32),15<E.windowBits&&E.windowBits<48&&(15&E.windowBits)==0&&(E.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new I,this.strm.avail_out=0;var u=s.inflateInit2(this.strm,E.windowBits);if(u!==g.Z_OK)throw new Error(c[u]);this.header=new l,s.inflateGetHeader(this.strm,this.header)}function Q(h,E){var u=new C(E);if(u.push(h,!0),u.err)throw u.msg||c[u.err];return u.result}C.prototype.push=function(h,E){var u,d,f,m,w,D,S=this.strm,_=this.options.chunkSize,b=this.options.dictionary,R=!1;if(this.ended)return!1;d=E===~~E?E:E===!0?g.Z_FINISH:g.Z_NO_FLUSH,typeof h=="string"?S.input=a.binstring2buf(h):B.call(h)==="[object ArrayBuffer]"?S.input=new Uint8Array(h):S.input=h,S.next_in=0,S.avail_in=S.input.length;do{if(S.avail_out===0&&(S.output=new r.Buf8(_),S.next_out=0,S.avail_out=_),(u=s.inflate(S,g.Z_NO_FLUSH))===g.Z_NEED_DICT&&b&&(D=typeof b=="string"?a.string2buf(b):B.call(b)==="[object ArrayBuffer]"?new Uint8Array(b):b,u=s.inflateSetDictionary(this.strm,D)),u===g.Z_BUF_ERROR&&R===!0&&(u=g.Z_OK,R=!1),u!==g.Z_STREAM_END&&u!==g.Z_OK)return this.onEnd(u),!(this.ended=!0);S.next_out&&(S.avail_out!==0&&u!==g.Z_STREAM_END&&(S.avail_in!==0||d!==g.Z_FINISH&&d!==g.Z_SYNC_FLUSH)||(this.options.to==="string"?(f=a.utf8border(S.output,S.next_out),m=S.next_out-f,w=a.buf2string(S.output,f),S.next_out=m,S.avail_out=_-m,m&&r.arraySet(S.output,S.output,f,m,0),this.onData(w)):this.onData(r.shrinkBuf(S.output,S.next_out)))),S.avail_in===0&&S.avail_out===0&&(R=!0)}while((0<S.avail_in||S.avail_out===0)&&u!==g.Z_STREAM_END);return u===g.Z_STREAM_END&&(d=g.Z_FINISH),d===g.Z_FINISH?(u=s.inflateEnd(this.strm),this.onEnd(u),this.ended=!0,u===g.Z_OK):d!==g.Z_SYNC_FLUSH||(this.onEnd(g.Z_OK),!(S.avail_out=0))},C.prototype.onData=function(h){this.chunks.push(h)},C.prototype.onEnd=function(h){h===g.Z_OK&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=r.flattenChunks(this.chunks)),this.chunks=[],this.err=h,this.msg=this.strm.msg},o.Inflate=C,o.inflate=Q,o.inflateRaw=function(h,E){return(E=E||{}).raw=!0,Q(h,E)},o.ungzip=Q},{"./utils/common":41,"./utils/strings":42,"./zlib/constants":44,"./zlib/gzheader":47,"./zlib/inflate":49,"./zlib/messages":51,"./zlib/zstream":53}],41:[function(i,n,o){var s=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Int32Array<"u";o.assign=function(g){for(var c=Array.prototype.slice.call(arguments,1);c.length;){var I=c.shift();if(I){if(typeof I!="object")throw new TypeError(I+"must be non-object");for(var l in I)I.hasOwnProperty(l)&&(g[l]=I[l])}}return g},o.shrinkBuf=function(g,c){return g.length===c?g:g.subarray?g.subarray(0,c):(g.length=c,g)};var r={arraySet:function(g,c,I,l,B){if(c.subarray&&g.subarray)g.set(c.subarray(I,I+l),B);else for(var C=0;C<l;C++)g[B+C]=c[I+C]},flattenChunks:function(g){var c,I,l,B,C,Q;for(c=l=0,I=g.length;c<I;c++)l+=g[c].length;for(Q=new Uint8Array(l),c=B=0,I=g.length;c<I;c++)C=g[c],Q.set(C,B),B+=C.length;return Q}},a={arraySet:function(g,c,I,l,B){for(var C=0;C<l;C++)g[B+C]=c[I+C]},flattenChunks:function(g){return[].concat.apply([],g)}};o.setTyped=function(g){g?(o.Buf8=Uint8Array,o.Buf16=Uint16Array,o.Buf32=Int32Array,o.assign(o,r)):(o.Buf8=Array,o.Buf16=Array,o.Buf32=Array,o.assign(o,a))},o.setTyped(s)},{}],42:[function(i,n,o){var s=i("./common"),r=!0,a=!0;try{String.fromCharCode.apply(null,[0])}catch{r=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch{a=!1}for(var g=new s.Buf8(256),c=0;c<256;c++)g[c]=252<=c?6:248<=c?5:240<=c?4:224<=c?3:192<=c?2:1;function I(l,B){if(B<65537&&(l.subarray&&a||!l.subarray&&r))return String.fromCharCode.apply(null,s.shrinkBuf(l,B));for(var C="",Q=0;Q<B;Q++)C+=String.fromCharCode(l[Q]);return C}g[254]=g[254]=1,o.string2buf=function(l){var B,C,Q,h,E,u=l.length,d=0;for(h=0;h<u;h++)(64512&(C=l.charCodeAt(h)))==55296&&h+1<u&&(64512&(Q=l.charCodeAt(h+1)))==56320&&(C=65536+(C-55296<<10)+(Q-56320),h++),d+=C<128?1:C<2048?2:C<65536?3:4;for(B=new s.Buf8(d),h=E=0;E<d;h++)(64512&(C=l.charCodeAt(h)))==55296&&h+1<u&&(64512&(Q=l.charCodeAt(h+1)))==56320&&(C=65536+(C-55296<<10)+(Q-56320),h++),C<128?B[E++]=C:(C<2048?B[E++]=192|C>>>6:(C<65536?B[E++]=224|C>>>12:(B[E++]=240|C>>>18,B[E++]=128|C>>>12&63),B[E++]=128|C>>>6&63),B[E++]=128|63&C);return B},o.buf2binstring=function(l){return I(l,l.length)},o.binstring2buf=function(l){for(var B=new s.Buf8(l.length),C=0,Q=B.length;C<Q;C++)B[C]=l.charCodeAt(C);return B},o.buf2string=function(l,B){var C,Q,h,E,u=B||l.length,d=new Array(2*u);for(C=Q=0;C<u;)if((h=l[C++])<128)d[Q++]=h;else if(4<(E=g[h]))d[Q++]=65533,C+=E-1;else{for(h&=E===2?31:E===3?15:7;1<E&&C<u;)h=h<<6|63&l[C++],E--;1<E?d[Q++]=65533:h<65536?d[Q++]=h:(h-=65536,d[Q++]=55296|h>>10&1023,d[Q++]=56320|1023&h)}return I(d,Q)},o.utf8border=function(l,B){var C;for((B=B||l.length)>l.length&&(B=l.length),C=B-1;0<=C&&(192&l[C])==128;)C--;return C<0||C===0?B:C+g[l[C]]>B?C:B}},{"./common":41}],43:[function(i,n,o){n.exports=function(s,r,a,g){for(var c=65535&s|0,I=s>>>16&65535|0,l=0;a!==0;){for(a-=l=2e3<a?2e3:a;I=I+(c=c+r[g++]|0)|0,--l;);c%=65521,I%=65521}return c|I<<16|0}},{}],44:[function(i,n,o){n.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(i,n,o){var s=(function(){for(var r,a=[],g=0;g<256;g++){r=g;for(var c=0;c<8;c++)r=1&r?3988292384^r>>>1:r>>>1;a[g]=r}return a})();n.exports=function(r,a,g,c){var I=s,l=c+g;r^=-1;for(var B=c;B<l;B++)r=r>>>8^I[255&(r^a[B])];return-1^r}},{}],46:[function(i,n,o){var s,r=i("../utils/common"),a=i("./trees"),g=i("./adler32"),c=i("./crc32"),I=i("./messages"),l=0,B=4,C=0,Q=-2,h=-1,E=4,u=2,d=8,f=9,m=286,w=30,D=19,S=2*m+1,_=15,b=3,R=258,F=R+b+1,H=42,Y=113,J=1,O=2,W=3,z=4;function tA(mA,gt){return mA.msg=I[gt],gt}function aA(mA){return(mA<<1)-(4<mA?9:0)}function eA(mA){for(var gt=mA.length;0<=--gt;)mA[gt]=0}function oA(mA){var gt=mA.state,VA=gt.pending;VA>mA.avail_out&&(VA=mA.avail_out),VA!==0&&(r.arraySet(mA.output,gt.pending_buf,gt.pending_out,VA,mA.next_out),mA.next_out+=VA,gt.pending_out+=VA,mA.total_out+=VA,mA.avail_out-=VA,gt.pending-=VA,gt.pending===0&&(gt.pending_out=0))}function rA(mA,gt){a._tr_flush_block(mA,0<=mA.block_start?mA.block_start:-1,mA.strstart-mA.block_start,gt),mA.block_start=mA.strstart,oA(mA.strm)}function lA(mA,gt){mA.pending_buf[mA.pending++]=gt}function pA(mA,gt){mA.pending_buf[mA.pending++]=gt>>>8&255,mA.pending_buf[mA.pending++]=255>}function kA(mA,gt){var VA,JA,OA=mA.max_chain_length,_A=mA.strstart,DA=mA.prev_length,NA=mA.nice_match,FA=mA.strstart>mA.w_size-F?mA.strstart-(mA.w_size-F):0,KA=mA.window,ZA=mA.w_mask,nt=mA.prev,SA=mA.strstart+R,CA=KA[_A+DA-1],hA=KA[_A+DA];mA.prev_length>=mA.good_match&&(OA>>=2),NA>mA.lookahead&&(NA=mA.lookahead);do if(KA[(VA=gt)+DA]===hA&&KA[VA+DA-1]===CA&&KA[VA]===KA[_A]&&KA[++VA]===KA[_A+1]){_A+=2,VA++;do;while(KA[++_A]===KA[++VA]&&KA[++_A]===KA[++VA]&&KA[++_A]===KA[++VA]&&KA[++_A]===KA[++VA]&&KA[++_A]===KA[++VA]&&KA[++_A]===KA[++VA]&&KA[++_A]===KA[++VA]&&KA[++_A]===KA[++VA]&&_A<SA);if(JA=R-(SA-_A),_A=SA-R,DA<JA){if(mA.match_start=gt,NA<=(DA=JA))break;CA=KA[_A+DA-1],hA=KA[_A+DA]}}while((gt=nt[gt&ZA])>FA&&--OA!=0);return DA<=mA.lookahead?DA:mA.lookahead}function MA(mA){var gt,VA,JA,OA,_A,DA,NA,FA,KA,ZA,nt=mA.w_size;do{if(OA=mA.window_size-mA.lookahead-mA.strstart,mA.strstart>=nt+(nt-F)){for(r.arraySet(mA.window,mA.window,nt,nt,0),mA.match_start-=nt,mA.strstart-=nt,mA.block_start-=nt,gt=VA=mA.hash_size;JA=mA.head[--gt],mA.head[gt]=nt<=JA?JA-nt:0,--VA;);for(gt=VA=nt;JA=mA.prev[--gt],mA.prev[gt]=nt<=JA?JA-nt:0,--VA;);OA+=nt}if(mA.strm.avail_in===0)break;if(DA=mA.strm,NA=mA.window,FA=mA.strstart+mA.lookahead,KA=OA,ZA=void 0,ZA=DA.avail_in,KA<ZA&&(ZA=KA),VA=ZA===0?0:(DA.avail_in-=ZA,r.arraySet(NA,DA.input,DA.next_in,ZA,FA),DA.state.wrap===1?DA.adler=g(DA.adler,NA,ZA,FA):DA.state.wrap===2&&(DA.adler=c(DA.adler,NA,ZA,FA)),DA.next_in+=ZA,DA.total_in+=ZA,ZA),mA.lookahead+=VA,mA.lookahead+mA.insert>=b)for(_A=mA.strstart-mA.insert,mA.ins_h=mA.window[_A],mA.ins_h=(mA.ins_h<<mA.hash_shift^mA.window[_A+1])&mA.hash_mask;mA.insert&&(mA.ins_h=(mA.ins_h<<mA.hash_shift^mA.window[_A+b-1])&mA.hash_mask,mA.prev[_A&mA.w_mask]=mA.head[mA.ins_h],mA.head[mA.ins_h]=_A,_A++,mA.insert--,!(mA.lookahead+mA.insert<b)););}while(mA.lookahead<F&&mA.strm.avail_in!==0)}function YA(mA,gt){for(var VA,JA;;){if(mA.lookahead<F){if(MA(mA),mA.lookahead<F&>===l)return J;if(mA.lookahead===0)break}if(VA=0,mA.lookahead>=b&&(mA.ins_h=(mA.ins_h<<mA.hash_shift^mA.window[mA.strstart+b-1])&mA.hash_mask,VA=mA.prev[mA.strstart&mA.w_mask]=mA.head[mA.ins_h],mA.head[mA.ins_h]=mA.strstart),VA!==0&&mA.strstart-VA<=mA.w_size-F&&(mA.match_length=kA(mA,VA)),mA.match_length>=b)if(JA=a._tr_tally(mA,mA.strstart-mA.match_start,mA.match_length-b),mA.lookahead-=mA.match_length,mA.match_length<=mA.max_lazy_match&&mA.lookahead>=b){for(mA.match_length--;mA.strstart++,mA.ins_h=(mA.ins_h<<mA.hash_shift^mA.window[mA.strstart+b-1])&mA.hash_mask,VA=mA.prev[mA.strstart&mA.w_mask]=mA.head[mA.ins_h],mA.head[mA.ins_h]=mA.strstart,--mA.match_length!=0;);mA.strstart++}else mA.strstart+=mA.match_length,mA.match_length=0,mA.ins_h=mA.window[mA.strstart],mA.ins_h=(mA.ins_h<<mA.hash_shift^mA.window[mA.strstart+1])&mA.hash_mask;else JA=a._tr_tally(mA,0,mA.window[mA.strstart]),mA.lookahead--,mA.strstart++;if(JA&&(rA(mA,!1),mA.strm.avail_out===0))return J}return mA.insert=mA.strstart<b-1?mA.strstart:b-1,gt===B?(rA(mA,!0),mA.strm.avail_out===0?W:z):mA.last_lit&&(rA(mA,!1),mA.strm.avail_out===0)?J:O}function EA(mA,gt){for(var VA,JA,OA;;){if(mA.lookahead<F){if(MA(mA),mA.lookahead<F&>===l)return J;if(mA.lookahead===0)break}if(VA=0,mA.lookahead>=b&&(mA.ins_h=(mA.ins_h<<mA.hash_shift^mA.window[mA.strstart+b-1])&mA.hash_mask,VA=mA.prev[mA.strstart&mA.w_mask]=mA.head[mA.ins_h],mA.head[mA.ins_h]=mA.strstart),mA.prev_length=mA.match_length,mA.prev_match=mA.match_start,mA.match_length=b-1,VA!==0&&mA.prev_length<mA.max_lazy_match&&mA.strstart-VA<=mA.w_size-F&&(mA.match_length=kA(mA,VA),mA.match_length<=5&&(mA.strategy===1||mA.match_length===b&&4096<mA.strstart-mA.match_start)&&(mA.match_length=b-1)),mA.prev_length>=b&&mA.match_length<=mA.prev_length){for(OA=mA.strstart+mA.lookahead-b,JA=a._tr_tally(mA,mA.strstart-1-mA.prev_match,mA.prev_length-b),mA.lookahead-=mA.prev_length-1,mA.prev_length-=2;++mA.strstart<=OA&&(mA.ins_h=(mA.ins_h<<mA.hash_shift^mA.window[mA.strstart+b-1])&mA.hash_mask,VA=mA.prev[mA.strstart&mA.w_mask]=mA.head[mA.ins_h],mA.head[mA.ins_h]=mA.strstart),--mA.prev_length!=0;);if(mA.match_available=0,mA.match_length=b-1,mA.strstart++,JA&&(rA(mA,!1),mA.strm.avail_out===0))return J}else if(mA.match_available){if((JA=a._tr_tally(mA,0,mA.window[mA.strstart-1]))&&rA(mA,!1),mA.strstart++,mA.lookahead--,mA.strm.avail_out===0)return J}else mA.match_available=1,mA.strstart++,mA.lookahead--}return mA.match_available&&(JA=a._tr_tally(mA,0,mA.window[mA.strstart-1]),mA.match_available=0),mA.insert=mA.strstart<b-1?mA.strstart:b-1,gt===B?(rA(mA,!0),mA.strm.avail_out===0?W:z):mA.last_lit&&(rA(mA,!1),mA.strm.avail_out===0)?J:O}function xA(mA,gt,VA,JA,OA){this.good_length=mA,this.max_lazy=gt,this.nice_length=VA,this.max_chain=JA,this.func=OA}function dA(){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=d,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 r.Buf16(2*S),this.dyn_dtree=new r.Buf16(2*(2*w+1)),this.bl_tree=new r.Buf16(2*(2*D+1)),eA(this.dyn_ltree),eA(this.dyn_dtree),eA(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new r.Buf16(_+1),this.heap=new r.Buf16(2*m+1),eA(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new r.Buf16(2*m+1),eA(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 WA(mA){var gt;return mA&&mA.state?(mA.total_in=mA.total_out=0,mA.data_type=u,(gt=mA.state).pending=0,gt.pending_out=0,gt.wrap<0&&(gt.wrap=-gt.wrap),gt.status=gt.wrap?H:Y,mA.adler=gt.wrap===2?0:1,gt.last_flush=l,a._tr_init(gt),C):tA(mA,Q)}function jA(mA){var gt=WA(mA);return gt===C&&(function(VA){VA.window_size=2*VA.w_size,eA(VA.head),VA.max_lazy_match=s[VA.level].max_lazy,VA.good_match=s[VA.level].good_length,VA.nice_match=s[VA.level].nice_length,VA.max_chain_length=s[VA.level].max_chain,VA.strstart=0,VA.block_start=0,VA.lookahead=0,VA.insert=0,VA.match_length=VA.prev_length=b-1,VA.match_available=0,VA.ins_h=0})(mA.state),gt}function It(mA,gt,VA,JA,OA,_A){if(!mA)return Q;var DA=1;if(gt===h&&(gt=6),JA<0?(DA=0,JA=-JA):15<JA&&(DA=2,JA-=16),OA<1||f<OA||VA!==d||JA<8||15<JA||gt<0||9<gt||_A<0||E<_A)return tA(mA,Q);JA===8&&(JA=9);var NA=new dA;return(mA.state=NA).strm=mA,NA.wrap=DA,NA.gzhead=null,NA.w_bits=JA,NA.w_size=1<<NA.w_bits,NA.w_mask=NA.w_size-1,NA.hash_bits=OA+7,NA.hash_size=1<<NA.hash_bits,NA.hash_mask=NA.hash_size-1,NA.hash_shift=~~((NA.hash_bits+b-1)/b),NA.window=new r.Buf8(2*NA.w_size),NA.head=new r.Buf16(NA.hash_size),NA.prev=new r.Buf16(NA.w_size),NA.lit_bufsize=1<<OA+6,NA.pending_buf_size=4*NA.lit_bufsize,NA.pending_buf=new r.Buf8(NA.pending_buf_size),NA.d_buf=1*NA.lit_bufsize,NA.l_buf=3*NA.lit_bufsize,NA.level=gt,NA.strategy=_A,NA.method=VA,jA(mA)}s=[new xA(0,0,0,0,function(mA,gt){var VA=65535;for(VA>mA.pending_buf_size-5&&(VA=mA.pending_buf_size-5);;){if(mA.lookahead<=1){if(MA(mA),mA.lookahead===0&>===l)return J;if(mA.lookahead===0)break}mA.strstart+=mA.lookahead,mA.lookahead=0;var JA=mA.block_start+VA;if((mA.strstart===0||mA.strstart>=JA)&&(mA.lookahead=mA.strstart-JA,mA.strstart=JA,rA(mA,!1),mA.strm.avail_out===0)||mA.strstart-mA.block_start>=mA.w_size-F&&(rA(mA,!1),mA.strm.avail_out===0))return J}return mA.insert=0,gt===B?(rA(mA,!0),mA.strm.avail_out===0?W:z):(mA.strstart>mA.block_start&&(rA(mA,!1),mA.strm.avail_out),J)}),new xA(4,4,8,4,YA),new xA(4,5,16,8,YA),new xA(4,6,32,32,YA),new xA(4,4,16,16,EA),new xA(8,16,32,32,EA),new xA(8,16,128,128,EA),new xA(8,32,128,256,EA),new xA(32,128,258,1024,EA),new xA(32,258,258,4096,EA)],o.deflateInit=function(mA,gt){return It(mA,gt,d,15,8,0)},o.deflateInit2=It,o.deflateReset=jA,o.deflateResetKeep=WA,o.deflateSetHeader=function(mA,gt){return mA&&mA.state?mA.state.wrap!==2?Q:(mA.state.gzhead=gt,C):Q},o.deflate=function(mA,gt){var VA,JA,OA,_A;if(!mA||!mA.state||5<gt||gt<0)return mA?tA(mA,Q):Q;if(JA=mA.state,!mA.output||!mA.input&&mA.avail_in!==0||JA.status===666&>!==B)return tA(mA,mA.avail_out===0?-5:Q);if(JA.strm=mA,VA=JA.last_flush,JA.last_flush=gt,JA.status===H)if(JA.wrap===2)mA.adler=0,lA(JA,31),lA(JA,139),lA(JA,8),JA.gzhead?(lA(JA,(JA.gzhead.text?1:0)+(JA.gzhead.hcrc?2:0)+(JA.gzhead.extra?4:0)+(JA.gzhead.name?8:0)+(JA.gzhead.comment?16:0)),lA(JA,255&JA.gzhead.time),lA(JA,JA.gzhead.time>>8&255),lA(JA,JA.gzhead.time>>16&255),lA(JA,JA.gzhead.time>>24&255),lA(JA,JA.level===9?2:2<=JA.strategy||JA.level<2?4:0),lA(JA,255&JA.gzhead.os),JA.gzhead.extra&&JA.gzhead.extra.length&&(lA(JA,255&JA.gzhead.extra.length),lA(JA,JA.gzhead.extra.length>>8&255)),JA.gzhead.hcrc&&(mA.adler=c(mA.adler,JA.pending_buf,JA.pending,0)),JA.gzindex=0,JA.status=69):(lA(JA,0),lA(JA,0),lA(JA,0),lA(JA,0),lA(JA,0),lA(JA,JA.level===9?2:2<=JA.strategy||JA.level<2?4:0),lA(JA,3),JA.status=Y);else{var DA=d+(JA.w_bits-8<<4)<<8;DA|=(2<=JA.strategy||JA.level<2?0:JA.level<6?1:JA.level===6?2:3)<<6,JA.strstart!==0&&(DA|=32),DA+=31-DA%31,JA.status=Y,pA(JA,DA),JA.strstart!==0&&(pA(JA,mA.adler>>>16),pA(JA,65535&mA.adler)),mA.adler=1}if(JA.status===69)if(JA.gzhead.extra){for(OA=JA.pending;JA.gzindex<(65535&JA.gzhead.extra.length)&&(JA.pending!==JA.pending_buf_size||(JA.gzhead.hcrc&&JA.pending>OA&&(mA.adler=c(mA.adler,JA.pending_buf,JA.pending-OA,OA)),oA(mA),OA=JA.pending,JA.pending!==JA.pending_buf_size));)lA(JA,255&JA.gzhead.extra[JA.gzindex]),JA.gzindex++;JA.gzhead.hcrc&&JA.pending>OA&&(mA.adler=c(mA.adler,JA.pending_buf,JA.pending-OA,OA)),JA.gzindex===JA.gzhead.extra.length&&(JA.gzindex=0,JA.status=73)}else JA.status=73;if(JA.status===73)if(JA.gzhead.name){OA=JA.pending;do{if(JA.pending===JA.pending_buf_size&&(JA.gzhead.hcrc&&JA.pending>OA&&(mA.adler=c(mA.adler,JA.pending_buf,JA.pending-OA,OA)),oA(mA),OA=JA.pending,JA.pending===JA.pending_buf_size)){_A=1;break}_A=JA.gzindex<JA.gzhead.name.length?255&JA.gzhead.name.charCodeAt(JA.gzindex++):0,lA(JA,_A)}while(_A!==0);JA.gzhead.hcrc&&JA.pending>OA&&(mA.adler=c(mA.adler,JA.pending_buf,JA.pending-OA,OA)),_A===0&&(JA.gzindex=0,JA.status=91)}else JA.status=91;if(JA.status===91)if(JA.gzhead.comment){OA=JA.pending;do{if(JA.pending===JA.pending_buf_size&&(JA.gzhead.hcrc&&JA.pending>OA&&(mA.adler=c(mA.adler,JA.pending_buf,JA.pending-OA,OA)),oA(mA),OA=JA.pending,JA.pending===JA.pending_buf_size)){_A=1;break}_A=JA.gzindex<JA.gzhead.comment.length?255&JA.gzhead.comment.charCodeAt(JA.gzindex++):0,lA(JA,_A)}while(_A!==0);JA.gzhead.hcrc&&JA.pending>OA&&(mA.adler=c(mA.adler,JA.pending_buf,JA.pending-OA,OA)),_A===0&&(JA.status=103)}else JA.status=103;if(JA.status===103&&(JA.gzhead.hcrc?(JA.pending+2>JA.pending_buf_size&&oA(mA),JA.pending+2<=JA.pending_buf_size&&(lA(JA,255&mA.adler),lA(JA,mA.adler>>8&255),mA.adler=0,JA.status=Y)):JA.status=Y),JA.pending!==0){if(oA(mA),mA.avail_out===0)return JA.last_flush=-1,C}else if(mA.avail_in===0&&aA(gt)<=aA(VA)&>!==B)return tA(mA,-5);if(JA.status===666&&mA.avail_in!==0)return tA(mA,-5);if(mA.avail_in!==0||JA.lookahead!==0||gt!==l&&JA.status!==666){var NA=JA.strategy===2?(function(FA,KA){for(var ZA;;){if(FA.lookahead===0&&(MA(FA),FA.lookahead===0)){if(KA===l)return J;break}if(FA.match_length=0,ZA=a._tr_tally(FA,0,FA.window[FA.strstart]),FA.lookahead--,FA.strstart++,ZA&&(rA(FA,!1),FA.strm.avail_out===0))return J}return FA.insert=0,KA===B?(rA(FA,!0),FA.strm.avail_out===0?W:z):FA.last_lit&&(rA(FA,!1),FA.strm.avail_out===0)?J:O})(JA,gt):JA.strategy===3?(function(FA,KA){for(var ZA,nt,SA,CA,hA=FA.window;;){if(FA.lookahead<=R){if(MA(FA),FA.lookahead<=R&&KA===l)return J;if(FA.lookahead===0)break}if(FA.match_length=0,FA.lookahead>=b&&0<FA.strstart&&(nt=hA[SA=FA.strstart-1])===hA[++SA]&&nt===hA[++SA]&&nt===hA[++SA]){CA=FA.strstart+R;do;while(nt===hA[++SA]&&nt===hA[++SA]&&nt===hA[++SA]&&nt===hA[++SA]&&nt===hA[++SA]&&nt===hA[++SA]&&nt===hA[++SA]&&nt===hA[++SA]&&SA<CA);FA.match_length=R-(CA-SA),FA.match_length>FA.lookahead&&(FA.match_length=FA.lookahead)}if(FA.match_length>=b?(ZA=a._tr_tally(FA,1,FA.match_length-b),FA.lookahead-=FA.match_length,FA.strstart+=FA.match_length,FA.match_length=0):(ZA=a._tr_tally(FA,0,FA.window[FA.strstart]),FA.lookahead--,FA.strstart++),ZA&&(rA(FA,!1),FA.strm.avail_out===0))return J}return FA.insert=0,KA===B?(rA(FA,!0),FA.strm.avail_out===0?W:z):FA.last_lit&&(rA(FA,!1),FA.strm.avail_out===0)?J:O})(JA,gt):s[JA.level].func(JA,gt);if(NA!==W&&NA!==z||(JA.status=666),NA===J||NA===W)return mA.avail_out===0&&(JA.last_flush=-1),C;if(NA===O&&(gt===1?a._tr_align(JA):gt!==5&&(a._tr_stored_block(JA,0,0,!1),gt===3&&(eA(JA.head),JA.lookahead===0&&(JA.strstart=0,JA.block_start=0,JA.insert=0))),oA(mA),mA.avail_out===0))return JA.last_flush=-1,C}return gt!==B?C:JA.wrap<=0?1:(JA.wrap===2?(lA(JA,255&mA.adler),lA(JA,mA.adler>>8&255),lA(JA,mA.adler>>16&255),lA(JA,mA.adler>>24&255),lA(JA,255&mA.total_in),lA(JA,mA.total_in>>8&255),lA(JA,mA.total_in>>16&255),lA(JA,mA.total_in>>24&255)):(pA(JA,mA.adler>>>16),pA(JA,65535&mA.adler)),oA(mA),0<JA.wrap&&(JA.wrap=-JA.wrap),JA.pending!==0?C:1)},o.deflateEnd=function(mA){var gt;return mA&&mA.state?(gt=mA.state.status)!==H&>!==69&>!==73&>!==91&>!==103&>!==Y&>!==666?tA(mA,Q):(mA.state=null,gt===Y?tA(mA,-3):C):Q},o.deflateSetDictionary=function(mA,gt){var VA,JA,OA,_A,DA,NA,FA,KA,ZA=gt.length;if(!mA||!mA.state||(_A=(VA=mA.state).wrap)===2||_A===1&&VA.status!==H||VA.lookahead)return Q;for(_A===1&&(mA.adler=g(mA.adler,gt,ZA,0)),VA.wrap=0,ZA>=VA.w_size&&(_A===0&&(eA(VA.head),VA.strstart=0,VA.block_start=0,VA.insert=0),KA=new r.Buf8(VA.w_size),r.arraySet(KA,gt,ZA-VA.w_size,VA.w_size,0),gt=KA,ZA=VA.w_size),DA=mA.avail_in,NA=mA.next_in,FA=mA.input,mA.avail_in=ZA,mA.next_in=0,mA.input=gt,MA(VA);VA.lookahead>=b;){for(JA=VA.strstart,OA=VA.lookahead-(b-1);VA.ins_h=(VA.ins_h<<VA.hash_shift^VA.window[JA+b-1])&VA.hash_mask,VA.prev[JA&VA.w_mask]=VA.head[VA.ins_h],VA.head[VA.ins_h]=JA,JA++,--OA;);VA.strstart=JA,VA.lookahead=b-1,MA(VA)}return VA.strstart+=VA.lookahead,VA.block_start=VA.strstart,VA.insert=VA.lookahead,VA.lookahead=0,VA.match_length=VA.prev_length=b-1,VA.match_available=0,mA.next_in=NA,mA.input=FA,mA.avail_in=DA,VA.wrap=_A,C},o.deflateInfo="pako deflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./messages":51,"./trees":52}],47:[function(i,n,o){n.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(i,n,o){n.exports=function(s,r){var a,g,c,I,l,B,C,Q,h,E,u,d,f,m,w,D,S,_,b,R,F,H,Y,J,O;a=s.state,g=s.next_in,J=s.input,c=g+(s.avail_in-5),I=s.next_out,O=s.output,l=I-(r-s.avail_out),B=I+(s.avail_out-257),C=a.dmax,Q=a.wsize,h=a.whave,E=a.wnext,u=a.window,d=a.hold,f=a.bits,m=a.lencode,w=a.distcode,D=(1<<a.lenbits)-1,S=(1<<a.distbits)-1;A:do{f<15&&(d+=J[g++]<<f,f+=8,d+=J[g++]<<f,f+=8),_=m[d&D];t:for(;;){if(d>>>=b=_>>>24,f-=b,(b=_>>>16&255)===0)O[I++]=65535&_;else{if(!(16&b)){if((64&b)==0){_=m[(65535&_)+(d&(1<<b)-1)];continue t}if(32&b){a.mode=12;break A}s.msg="invalid literal/length code",a.mode=30;break A}R=65535&_,(b&=15)&&(f<b&&(d+=J[g++]<<f,f+=8),R+=d&(1<<b)-1,d>>>=b,f-=b),f<15&&(d+=J[g++]<<f,f+=8,d+=J[g++]<<f,f+=8),_=w[d&S];e:for(;;){if(d>>>=b=_>>>24,f-=b,!(16&(b=_>>>16&255))){if((64&b)==0){_=w[(65535&_)+(d&(1<<b)-1)];continue e}s.msg="invalid distance code",a.mode=30;break A}if(F=65535&_,f<(b&=15)&&(d+=J[g++]<<f,(f+=8)<b&&(d+=J[g++]<<f,f+=8)),C<(F+=d&(1<<b)-1)){s.msg="invalid distance too far back",a.mode=30;break A}if(d>>>=b,f-=b,(b=I-l)<F){if(h<(b=F-b)&&a.sane){s.msg="invalid distance too far back",a.mode=30;break A}if(Y=u,(H=0)===E){if(H+=Q-b,b<R){for(R-=b;O[I++]=u[H++],--b;);H=I-F,Y=O}}else if(E<b){if(H+=Q+E-b,(b-=E)<R){for(R-=b;O[I++]=u[H++],--b;);if(H=0,E<R){for(R-=b=E;O[I++]=u[H++],--b;);H=I-F,Y=O}}}else if(H+=E-b,b<R){for(R-=b;O[I++]=u[H++],--b;);H=I-F,Y=O}for(;2<R;)O[I++]=Y[H++],O[I++]=Y[H++],O[I++]=Y[H++],R-=3;R&&(O[I++]=Y[H++],1<R&&(O[I++]=Y[H++]))}else{for(H=I-F;O[I++]=O[H++],O[I++]=O[H++],O[I++]=O[H++],2<(R-=3););R&&(O[I++]=O[H++],1<R&&(O[I++]=O[H++]))}break}}break}}while(g<c&&I<B);g-=R=f>>3,d&=(1<<(f-=R<<3))-1,s.next_in=g,s.next_out=I,s.avail_in=g<c?c-g+5:5-(g-c),s.avail_out=I<B?B-I+257:257-(I-B),a.hold=d,a.bits=f}},{}],49:[function(i,n,o){var s=i("../utils/common"),r=i("./adler32"),a=i("./crc32"),g=i("./inffast"),c=i("./inftrees"),I=1,l=2,B=0,C=-2,Q=1,h=852,E=592;function u(H){return(H>>>24&255)+(H>>>8&65280)+((65280&H)<<8)+((255&H)<<24)}function d(){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 f(H){var Y;return H&&H.state?(Y=H.state,H.total_in=H.total_out=Y.total=0,H.msg="",Y.wrap&&(H.adler=1&Y.wrap),Y.mode=Q,Y.last=0,Y.havedict=0,Y.dmax=32768,Y.head=null,Y.hold=0,Y.bits=0,Y.lencode=Y.lendyn=new s.Buf32(h),Y.distcode=Y.distdyn=new s.Buf32(E),Y.sane=1,Y.back=-1,B):C}function m(H){var Y;return H&&H.state?((Y=H.state).wsize=0,Y.whave=0,Y.wnext=0,f(H)):C}function w(H,Y){var J,O;return H&&H.state?(O=H.state,Y<0?(J=0,Y=-Y):(J=1+(Y>>4),Y<48&&(Y&=15)),Y&&(Y<8||15<Y)?C:(O.window!==null&&O.wbits!==Y&&(O.window=null),O.wrap=J,O.wbits=Y,m(H))):C}function D(H,Y){var J,O;return H?(O=new d,(H.state=O).window=null,(J=w(H,Y))!==B&&(H.state=null),J):C}var S,_,b=!0;function R(H){if(b){var Y;for(S=new s.Buf32(512),_=new s.Buf32(32),Y=0;Y<144;)H.lens[Y++]=8;for(;Y<256;)H.lens[Y++]=9;for(;Y<280;)H.lens[Y++]=7;for(;Y<288;)H.lens[Y++]=8;for(c(I,H.lens,0,288,S,0,H.work,{bits:9}),Y=0;Y<32;)H.lens[Y++]=5;c(l,H.lens,0,32,_,0,H.work,{bits:5}),b=!1}H.lencode=S,H.lenbits=9,H.distcode=_,H.distbits=5}function F(H,Y,J,O){var W,z=H.state;return z.window===null&&(z.wsize=1<<z.wbits,z.wnext=0,z.whave=0,z.window=new s.Buf8(z.wsize)),O>=z.wsize?(s.arraySet(z.window,Y,J-z.wsize,z.wsize,0),z.wnext=0,z.whave=z.wsize):(O<(W=z.wsize-z.wnext)&&(W=O),s.arraySet(z.window,Y,J-O,W,z.wnext),(O-=W)?(s.arraySet(z.window,Y,J-O,O,0),z.wnext=O,z.whave=z.wsize):(z.wnext+=W,z.wnext===z.wsize&&(z.wnext=0),z.whave<z.wsize&&(z.whave+=W))),0}o.inflateReset=m,o.inflateReset2=w,o.inflateResetKeep=f,o.inflateInit=function(H){return D(H,15)},o.inflateInit2=D,o.inflate=function(H,Y){var J,O,W,z,tA,aA,eA,oA,rA,lA,pA,kA,MA,YA,EA,xA,dA,WA,jA,It,mA,gt,VA,JA,OA=0,_A=new s.Buf8(4),DA=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!H||!H.state||!H.output||!H.input&&H.avail_in!==0)return C;(J=H.state).mode===12&&(J.mode=13),tA=H.next_out,W=H.output,eA=H.avail_out,z=H.next_in,O=H.input,aA=H.avail_in,oA=J.hold,rA=J.bits,lA=aA,pA=eA,gt=B;A:for(;;)switch(J.mode){case Q:if(J.wrap===0){J.mode=13;break}for(;rA<16;){if(aA===0)break A;aA--,oA+=O[z++]<<rA,rA+=8}if(2&J.wrap&&oA===35615){_A[J.check=0]=255&oA,_A[1]=oA>>>8&255,J.check=a(J.check,_A,2,0),rA=oA=0,J.mode=2;break}if(J.flags=0,J.head&&(J.head.done=!1),!(1&J.wrap)||(((255&oA)<<8)+(oA>>8))%31){H.msg="incorrect header check",J.mode=30;break}if((15&oA)!=8){H.msg="unknown compression method",J.mode=30;break}if(rA-=4,mA=8+(15&(oA>>>=4)),J.wbits===0)J.wbits=mA;else if(mA>J.wbits){H.msg="invalid window size",J.mode=30;break}J.dmax=1<<mA,H.adler=J.check=1,J.mode=512&oA?10:12,rA=oA=0;break;case 2:for(;rA<16;){if(aA===0)break A;aA--,oA+=O[z++]<<rA,rA+=8}if(J.flags=oA,(255&J.flags)!=8){H.msg="unknown compression method",J.mode=30;break}if(57344&J.flags){H.msg="unknown header flags set",J.mode=30;break}J.head&&(J.head.text=oA>>8&1),512&J.flags&&(_A[0]=255&oA,_A[1]=oA>>>8&255,J.check=a(J.check,_A,2,0)),rA=oA=0,J.mode=3;case 3:for(;rA<32;){if(aA===0)break A;aA--,oA+=O[z++]<<rA,rA+=8}J.head&&(J.head.time=oA),512&J.flags&&(_A[0]=255&oA,_A[1]=oA>>>8&255,_A[2]=oA>>>16&255,_A[3]=oA>>>24&255,J.check=a(J.check,_A,4,0)),rA=oA=0,J.mode=4;case 4:for(;rA<16;){if(aA===0)break A;aA--,oA+=O[z++]<<rA,rA+=8}J.head&&(J.head.xflags=255&oA,J.head.os=oA>>8),512&J.flags&&(_A[0]=255&oA,_A[1]=oA>>>8&255,J.check=a(J.check,_A,2,0)),rA=oA=0,J.mode=5;case 5:if(1024&J.flags){for(;rA<16;){if(aA===0)break A;aA--,oA+=O[z++]<<rA,rA+=8}J.length=oA,J.head&&(J.head.extra_len=oA),512&J.flags&&(_A[0]=255&oA,_A[1]=oA>>>8&255,J.check=a(J.check,_A,2,0)),rA=oA=0}else J.head&&(J.head.extra=null);J.mode=6;case 6:if(1024&J.flags&&(aA<(kA=J.length)&&(kA=aA),kA&&(J.head&&(mA=J.head.extra_len-J.length,J.head.extra||(J.head.extra=new Array(J.head.extra_len)),s.arraySet(J.head.extra,O,z,kA,mA)),512&J.flags&&(J.check=a(J.check,O,kA,z)),aA-=kA,z+=kA,J.length-=kA),J.length))break A;J.length=0,J.mode=7;case 7:if(2048&J.flags){if(aA===0)break A;for(kA=0;mA=O[z+kA++],J.head&&mA&&J.length<65536&&(J.head.name+=String.fromCharCode(mA)),mA&&kA<aA;);if(512&J.flags&&(J.check=a(J.check,O,kA,z)),aA-=kA,z+=kA,mA)break A}else J.head&&(J.head.name=null);J.length=0,J.mode=8;case 8:if(4096&J.flags){if(aA===0)break A;for(kA=0;mA=O[z+kA++],J.head&&mA&&J.length<65536&&(J.head.comment+=String.fromCharCode(mA)),mA&&kA<aA;);if(512&J.flags&&(J.check=a(J.check,O,kA,z)),aA-=kA,z+=kA,mA)break A}else J.head&&(J.head.comment=null);J.mode=9;case 9:if(512&J.flags){for(;rA<16;){if(aA===0)break A;aA--,oA+=O[z++]<<rA,rA+=8}if(oA!==(65535&J.check)){H.msg="header crc mismatch",J.mode=30;break}rA=oA=0}J.head&&(J.head.hcrc=J.flags>>9&1,J.head.done=!0),H.adler=J.check=0,J.mode=12;break;case 10:for(;rA<32;){if(aA===0)break A;aA--,oA+=O[z++]<<rA,rA+=8}H.adler=J.check=u(oA),rA=oA=0,J.mode=11;case 11:if(J.havedict===0)return H.next_out=tA,H.avail_out=eA,H.next_in=z,H.avail_in=aA,J.hold=oA,J.bits=rA,2;H.adler=J.check=1,J.mode=12;case 12:if(Y===5||Y===6)break A;case 13:if(J.last){oA>>>=7&rA,rA-=7&rA,J.mode=27;break}for(;rA<3;){if(aA===0)break A;aA--,oA+=O[z++]<<rA,rA+=8}switch(J.last=1&oA,rA-=1,3&(oA>>>=1)){case 0:J.mode=14;break;case 1:if(R(J),J.mode=20,Y!==6)break;oA>>>=2,rA-=2;break A;case 2:J.mode=17;break;case 3:H.msg="invalid block type",J.mode=30}oA>>>=2,rA-=2;break;case 14:for(oA>>>=7&rA,rA-=7&rA;rA<32;){if(aA===0)break A;aA--,oA+=O[z++]<<rA,rA+=8}if((65535&oA)!=(oA>>>16^65535)){H.msg="invalid stored block lengths",J.mode=30;break}if(J.length=65535&oA,rA=oA=0,J.mode=15,Y===6)break A;case 15:J.mode=16;case 16:if(kA=J.length){if(aA<kA&&(kA=aA),eA<kA&&(kA=eA),kA===0)break A;s.arraySet(W,O,z,kA,tA),aA-=kA,z+=kA,eA-=kA,tA+=kA,J.length-=kA;break}J.mode=12;break;case 17:for(;rA<14;){if(aA===0)break A;aA--,oA+=O[z++]<<rA,rA+=8}if(J.nlen=257+(31&oA),oA>>>=5,rA-=5,J.ndist=1+(31&oA),oA>>>=5,rA-=5,J.ncode=4+(15&oA),oA>>>=4,rA-=4,286<J.nlen||30<J.ndist){H.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(;rA<3;){if(aA===0)break A;aA--,oA+=O[z++]<<rA,rA+=8}J.lens[DA[J.have++]]=7&oA,oA>>>=3,rA-=3}for(;J.have<19;)J.lens[DA[J.have++]]=0;if(J.lencode=J.lendyn,J.lenbits=7,VA={bits:J.lenbits},gt=c(0,J.lens,0,19,J.lencode,0,J.work,VA),J.lenbits=VA.bits,gt){H.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(;xA=(OA=J.lencode[oA&(1<<J.lenbits)-1])>>>16&255,dA=65535&OA,!((EA=OA>>>24)<=rA);){if(aA===0)break A;aA--,oA+=O[z++]<<rA,rA+=8}if(dA<16)oA>>>=EA,rA-=EA,J.lens[J.have++]=dA;else{if(dA===16){for(JA=EA+2;rA<JA;){if(aA===0)break A;aA--,oA+=O[z++]<<rA,rA+=8}if(oA>>>=EA,rA-=EA,J.have===0){H.msg="invalid bit length repeat",J.mode=30;break}mA=J.lens[J.have-1],kA=3+(3&oA),oA>>>=2,rA-=2}else if(dA===17){for(JA=EA+3;rA<JA;){if(aA===0)break A;aA--,oA+=O[z++]<<rA,rA+=8}rA-=EA,mA=0,kA=3+(7&(oA>>>=EA)),oA>>>=3,rA-=3}else{for(JA=EA+7;rA<JA;){if(aA===0)break A;aA--,oA+=O[z++]<<rA,rA+=8}rA-=EA,mA=0,kA=11+(127&(oA>>>=EA)),oA>>>=7,rA-=7}if(J.have+kA>J.nlen+J.ndist){H.msg="invalid bit length repeat",J.mode=30;break}for(;kA--;)J.lens[J.have++]=mA}}if(J.mode===30)break;if(J.lens[256]===0){H.msg="invalid code -- missing end-of-block",J.mode=30;break}if(J.lenbits=9,VA={bits:J.lenbits},gt=c(I,J.lens,0,J.nlen,J.lencode,0,J.work,VA),J.lenbits=VA.bits,gt){H.msg="invalid literal/lengths set",J.mode=30;break}if(J.distbits=6,J.distcode=J.distdyn,VA={bits:J.distbits},gt=c(l,J.lens,J.nlen,J.ndist,J.distcode,0,J.work,VA),J.distbits=VA.bits,gt){H.msg="invalid distances set",J.mode=30;break}if(J.mode=20,Y===6)break A;case 20:J.mode=21;case 21:if(6<=aA&&258<=eA){H.next_out=tA,H.avail_out=eA,H.next_in=z,H.avail_in=aA,J.hold=oA,J.bits=rA,g(H,pA),tA=H.next_out,W=H.output,eA=H.avail_out,z=H.next_in,O=H.input,aA=H.avail_in,oA=J.hold,rA=J.bits,J.mode===12&&(J.back=-1);break}for(J.back=0;xA=(OA=J.lencode[oA&(1<<J.lenbits)-1])>>>16&255,dA=65535&OA,!((EA=OA>>>24)<=rA);){if(aA===0)break A;aA--,oA+=O[z++]<<rA,rA+=8}if(xA&&(240&xA)==0){for(WA=EA,jA=xA,It=dA;xA=(OA=J.lencode[It+((oA&(1<<WA+jA)-1)>>WA)])>>>16&255,dA=65535&OA,!(WA+(EA=OA>>>24)<=rA);){if(aA===0)break A;aA--,oA+=O[z++]<<rA,rA+=8}oA>>>=WA,rA-=WA,J.back+=WA}if(oA>>>=EA,rA-=EA,J.back+=EA,J.length=dA,xA===0){J.mode=26;break}if(32&xA){J.back=-1,J.mode=12;break}if(64&xA){H.msg="invalid literal/length code",J.mode=30;break}J.extra=15&xA,J.mode=22;case 22:if(J.extra){for(JA=J.extra;rA<JA;){if(aA===0)break A;aA--,oA+=O[z++]<<rA,rA+=8}J.length+=oA&(1<<J.extra)-1,oA>>>=J.extra,rA-=J.extra,J.back+=J.extra}J.was=J.length,J.mode=23;case 23:for(;xA=(OA=J.distcode[oA&(1<<J.distbits)-1])>>>16&255,dA=65535&OA,!((EA=OA>>>24)<=rA);){if(aA===0)break A;aA--,oA+=O[z++]<<rA,rA+=8}if((240&xA)==0){for(WA=EA,jA=xA,It=dA;xA=(OA=J.distcode[It+((oA&(1<<WA+jA)-1)>>WA)])>>>16&255,dA=65535&OA,!(WA+(EA=OA>>>24)<=rA);){if(aA===0)break A;aA--,oA+=O[z++]<<rA,rA+=8}oA>>>=WA,rA-=WA,J.back+=WA}if(oA>>>=EA,rA-=EA,J.back+=EA,64&xA){H.msg="invalid distance code",J.mode=30;break}J.offset=dA,J.extra=15&xA,J.mode=24;case 24:if(J.extra){for(JA=J.extra;rA<JA;){if(aA===0)break A;aA--,oA+=O[z++]<<rA,rA+=8}J.offset+=oA&(1<<J.extra)-1,oA>>>=J.extra,rA-=J.extra,J.back+=J.extra}if(J.offset>J.dmax){H.msg="invalid distance too far back",J.mode=30;break}J.mode=25;case 25:if(eA===0)break A;if(kA=pA-eA,J.offset>kA){if((kA=J.offset-kA)>J.whave&&J.sane){H.msg="invalid distance too far back",J.mode=30;break}MA=kA>J.wnext?(kA-=J.wnext,J.wsize-kA):J.wnext-kA,kA>J.length&&(kA=J.length),YA=J.window}else YA=W,MA=tA-J.offset,kA=J.length;for(eA<kA&&(kA=eA),eA-=kA,J.length-=kA;W[tA++]=YA[MA++],--kA;);J.length===0&&(J.mode=21);break;case 26:if(eA===0)break A;W[tA++]=J.length,eA--,J.mode=21;break;case 27:if(J.wrap){for(;rA<32;){if(aA===0)break A;aA--,oA|=O[z++]<<rA,rA+=8}if(pA-=eA,H.total_out+=pA,J.total+=pA,pA&&(H.adler=J.check=J.flags?a(J.check,W,pA,tA-pA):r(J.check,W,pA,tA-pA)),pA=eA,(J.flags?oA:u(oA))!==J.check){H.msg="incorrect data check",J.mode=30;break}rA=oA=0}J.mode=28;case 28:if(J.wrap&&J.flags){for(;rA<32;){if(aA===0)break A;aA--,oA+=O[z++]<<rA,rA+=8}if(oA!==(4294967295&J.total)){H.msg="incorrect length check",J.mode=30;break}rA=oA=0}J.mode=29;case 29:gt=1;break A;case 30:gt=-3;break A;case 31:return-4;default:return C}return H.next_out=tA,H.avail_out=eA,H.next_in=z,H.avail_in=aA,J.hold=oA,J.bits=rA,(J.wsize||pA!==H.avail_out&&J.mode<30&&(J.mode<27||Y!==4))&&F(H,H.output,H.next_out,pA-H.avail_out)?(J.mode=31,-4):(lA-=H.avail_in,pA-=H.avail_out,H.total_in+=lA,H.total_out+=pA,J.total+=pA,J.wrap&&pA&&(H.adler=J.check=J.flags?a(J.check,W,pA,H.next_out-pA):r(J.check,W,pA,H.next_out-pA)),H.data_type=J.bits+(J.last?64:0)+(J.mode===12?128:0)+(J.mode===20||J.mode===15?256:0),(lA==0&&pA===0||Y===4)&>===B&&(gt=-5),gt)},o.inflateEnd=function(H){if(!H||!H.state)return C;var Y=H.state;return Y.window&&(Y.window=null),H.state=null,B},o.inflateGetHeader=function(H,Y){var J;return H&&H.state?(2&(J=H.state).wrap)==0?C:((J.head=Y).done=!1,B):C},o.inflateSetDictionary=function(H,Y){var J,O=Y.length;return H&&H.state?(J=H.state).wrap!==0&&J.mode!==11?C:J.mode===11&&r(1,Y,O,0)!==J.check?-3:F(H,Y,O,O)?(J.mode=31,-4):(J.havedict=1,B):C},o.inflateInfo="pako inflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./inffast":48,"./inftrees":50}],50:[function(i,n,o){var s=i("../utils/common"),r=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0],a=[16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78],g=[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],c=[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];n.exports=function(I,l,B,C,Q,h,E,u){var d,f,m,w,D,S,_,b,R,F=u.bits,H=0,Y=0,J=0,O=0,W=0,z=0,tA=0,aA=0,eA=0,oA=0,rA=null,lA=0,pA=new s.Buf16(16),kA=new s.Buf16(16),MA=null,YA=0;for(H=0;H<=15;H++)pA[H]=0;for(Y=0;Y<C;Y++)pA[l[B+Y]]++;for(W=F,O=15;1<=O&&pA[O]===0;O--);if(O<W&&(W=O),O===0)return Q[h++]=20971520,Q[h++]=20971520,u.bits=1,0;for(J=1;J<O&&pA[J]===0;J++);for(W<J&&(W=J),H=aA=1;H<=15;H++)if(aA<<=1,(aA-=pA[H])<0)return-1;if(0<aA&&(I===0||O!==1))return-1;for(kA[1]=0,H=1;H<15;H++)kA[H+1]=kA[H]+pA[H];for(Y=0;Y<C;Y++)l[B+Y]!==0&&(E[kA[l[B+Y]]++]=Y);if(S=I===0?(rA=MA=E,19):I===1?(rA=r,lA-=257,MA=a,YA-=257,256):(rA=g,MA=c,-1),H=J,D=h,tA=Y=oA=0,m=-1,w=(eA=1<<(z=W))-1,I===1&&852<eA||I===2&&592<eA)return 1;for(;;){for(_=H-tA,R=E[Y]<S?(b=0,E[Y]):E[Y]>S?(b=MA[YA+E[Y]],rA[lA+E[Y]]):(b=96,0),d=1<<H-tA,J=f=1<<z;Q[D+(oA>>tA)+(f-=d)]=_<<24|b<<16|R|0,f!==0;);for(d=1<<H-1;oA&d;)d>>=1;if(d!==0?(oA&=d-1,oA+=d):oA=0,Y++,--pA[H]==0){if(H===O)break;H=l[B+E[Y]]}if(W<H&&(oA&w)!==m){for(tA===0&&(tA=W),D+=J,aA=1<<(z=H-tA);z+tA<O&&!((aA-=pA[z+tA])<=0);)z++,aA<<=1;if(eA+=1<<z,I===1&&852<eA||I===2&&592<eA)return 1;Q[m=oA&w]=W<<24|z<<16|D-h|0}}return oA!==0&&(Q[D+oA]=H-tA<<24|64<<16|0),u.bits=W,0}},{"../utils/common":41}],51:[function(i,n,o){n.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(i,n,o){var s=i("../utils/common"),r=0,a=1;function g(OA){for(var _A=OA.length;0<=--_A;)OA[_A]=0}var c=0,I=29,l=256,B=l+1+I,C=30,Q=19,h=2*B+1,E=15,u=16,d=7,f=256,m=16,w=17,D=18,S=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0],_=[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],b=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],R=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],F=new Array(2*(B+2));g(F);var H=new Array(2*C);g(H);var Y=new Array(512);g(Y);var J=new Array(256);g(J);var O=new Array(I);g(O);var W,z,tA,aA=new Array(C);function eA(OA,_A,DA,NA,FA){this.static_tree=OA,this.extra_bits=_A,this.extra_base=DA,this.elems=NA,this.max_length=FA,this.has_stree=OA&&OA.length}function oA(OA,_A){this.dyn_tree=OA,this.max_code=0,this.stat_desc=_A}function rA(OA){return OA<256?Y[OA]:Y[256+(OA>>>7)]}function lA(OA,_A){OA.pending_buf[OA.pending++]=255&_A,OA.pending_buf[OA.pending++]=_A>>>8&255}function pA(OA,_A,DA){OA.bi_valid>u-DA?(OA.bi_buf|=_A<<OA.bi_valid&65535,lA(OA,OA.bi_buf),OA.bi_buf=_A>>u-OA.bi_valid,OA.bi_valid+=DA-u):(OA.bi_buf|=_A<<OA.bi_valid&65535,OA.bi_valid+=DA)}function kA(OA,_A,DA){pA(OA,DA[2*_A],DA[2*_A+1])}function MA(OA,_A){for(var DA=0;DA|=1&OA,OA>>>=1,DA<<=1,0<--_A;);return DA>>>1}function YA(OA,_A,DA){var NA,FA,KA=new Array(E+1),ZA=0;for(NA=1;NA<=E;NA++)KA[NA]=ZA=ZA+DA[NA-1]<<1;for(FA=0;FA<=_A;FA++){var nt=OA[2*FA+1];nt!==0&&(OA[2*FA]=MA(KA[nt]++,nt))}}function EA(OA){var _A;for(_A=0;_A<B;_A++)OA.dyn_ltree[2*_A]=0;for(_A=0;_A<C;_A++)OA.dyn_dtree[2*_A]=0;for(_A=0;_A<Q;_A++)OA.bl_tree[2*_A]=0;OA.dyn_ltree[2*f]=1,OA.opt_len=OA.static_len=0,OA.last_lit=OA.matches=0}function xA(OA){8<OA.bi_valid?lA(OA,OA.bi_buf):0<OA.bi_valid&&(OA.pending_buf[OA.pending++]=OA.bi_buf),OA.bi_buf=0,OA.bi_valid=0}function dA(OA,_A,DA,NA){var FA=2*_A,KA=2*DA;return OA[FA]<OA[KA]||OA[FA]===OA[KA]&&NA[_A]<=NA[DA]}function WA(OA,_A,DA){for(var NA=OA.heap[DA],FA=DA<<1;FA<=OA.heap_len&&(FA<OA.heap_len&&dA(_A,OA.heap[FA+1],OA.heap[FA],OA.depth)&&FA++,!dA(_A,NA,OA.heap[FA],OA.depth));)OA.heap[DA]=OA.heap[FA],DA=FA,FA<<=1;OA.heap[DA]=NA}function jA(OA,_A,DA){var NA,FA,KA,ZA,nt=0;if(OA.last_lit!==0)for(;NA=OA.pending_buf[OA.d_buf+2*nt]<<8|OA.pending_buf[OA.d_buf+2*nt+1],FA=OA.pending_buf[OA.l_buf+nt],nt++,NA===0?kA(OA,FA,_A):(kA(OA,(KA=J[FA])+l+1,_A),(ZA=S[KA])!==0&&pA(OA,FA-=O[KA],ZA),kA(OA,KA=rA(--NA),DA),(ZA=_[KA])!==0&&pA(OA,NA-=aA[KA],ZA)),nt<OA.last_lit;);kA(OA,f,_A)}function It(OA,_A){var DA,NA,FA,KA=_A.dyn_tree,ZA=_A.stat_desc.static_tree,nt=_A.stat_desc.has_stree,SA=_A.stat_desc.elems,CA=-1;for(OA.heap_len=0,OA.heap_max=h,DA=0;DA<SA;DA++)KA[2*DA]!==0?(OA.heap[++OA.heap_len]=CA=DA,OA.depth[DA]=0):KA[2*DA+1]=0;for(;OA.heap_len<2;)KA[2*(FA=OA.heap[++OA.heap_len]=CA<2?++CA:0)]=1,OA.depth[FA]=0,OA.opt_len--,nt&&(OA.static_len-=ZA[2*FA+1]);for(_A.max_code=CA,DA=OA.heap_len>>1;1<=DA;DA--)WA(OA,KA,DA);for(FA=SA;DA=OA.heap[1],OA.heap[1]=OA.heap[OA.heap_len--],WA(OA,KA,1),NA=OA.heap[1],OA.heap[--OA.heap_max]=DA,OA.heap[--OA.heap_max]=NA,KA[2*FA]=KA[2*DA]+KA[2*NA],OA.depth[FA]=(OA.depth[DA]>=OA.depth[NA]?OA.depth[DA]:OA.depth[NA])+1,KA[2*DA+1]=KA[2*NA+1]=FA,OA.heap[1]=FA++,WA(OA,KA,1),2<=OA.heap_len;);OA.heap[--OA.heap_max]=OA.heap[1],(function(hA,TA){var rt,Qt,mt,_t,kt,Pt,le=TA.dyn_tree,QA=TA.max_code,ot=TA.stat_desc.static_tree,Bt=TA.stat_desc.has_stree,yt=TA.stat_desc.extra_bits,Lt=TA.stat_desc.extra_base,Tt=TA.stat_desc.max_length,ne=0;for(_t=0;_t<=E;_t++)hA.bl_count[_t]=0;for(le[2*hA.heap[hA.heap_max]+1]=0,rt=hA.heap_max+1;rt<h;rt++)Tt<(_t=le[2*le[2*(Qt=hA.heap[rt])+1]+1]+1)&&(_t=Tt,ne++),le[2*Qt+1]=_t,QA<Qt||(hA.bl_count[_t]++,kt=0,Lt<=Qt&&(kt=yt[Qt-Lt]),Pt=le[2*Qt],hA.opt_len+=Pt*(_t+kt),Bt&&(hA.static_len+=Pt*(ot[2*Qt+1]+kt)));if(ne!==0){do{for(_t=Tt-1;hA.bl_count[_t]===0;)_t--;hA.bl_count[_t]--,hA.bl_count[_t+1]+=2,hA.bl_count[Tt]--,ne-=2}while(0<ne);for(_t=Tt;_t!==0;_t--)for(Qt=hA.bl_count[_t];Qt!==0;)QA<(mt=hA.heap[--rt])||(le[2*mt+1]!==_t&&(hA.opt_len+=(_t-le[2*mt+1])*le[2*mt],le[2*mt+1]=_t),Qt--)}})(OA,_A),YA(KA,CA,OA.bl_count)}function mA(OA,_A,DA){var NA,FA,KA=-1,ZA=_A[1],nt=0,SA=7,CA=4;for(ZA===0&&(SA=138,CA=3),_A[2*(DA+1)+1]=65535,NA=0;NA<=DA;NA++)FA=ZA,ZA=_A[2*(NA+1)+1],++nt<SA&&FA===ZA||(nt<CA?OA.bl_tree[2*FA]+=nt:FA!==0?(FA!==KA&&OA.bl_tree[2*FA]++,OA.bl_tree[2*m]++):nt<=10?OA.bl_tree[2*w]++:OA.bl_tree[2*D]++,KA=FA,CA=(nt=0)===ZA?(SA=138,3):FA===ZA?(SA=6,3):(SA=7,4))}function gt(OA,_A,DA){var NA,FA,KA=-1,ZA=_A[1],nt=0,SA=7,CA=4;for(ZA===0&&(SA=138,CA=3),NA=0;NA<=DA;NA++)if(FA=ZA,ZA=_A[2*(NA+1)+1],!(++nt<SA&&FA===ZA)){if(nt<CA)for(;kA(OA,FA,OA.bl_tree),--nt!=0;);else FA!==0?(FA!==KA&&(kA(OA,FA,OA.bl_tree),nt--),kA(OA,m,OA.bl_tree),pA(OA,nt-3,2)):nt<=10?(kA(OA,w,OA.bl_tree),pA(OA,nt-3,3)):(kA(OA,D,OA.bl_tree),pA(OA,nt-11,7));KA=FA,CA=(nt=0)===ZA?(SA=138,3):FA===ZA?(SA=6,3):(SA=7,4)}}g(aA);var VA=!1;function JA(OA,_A,DA,NA){pA(OA,(c<<1)+(NA?1:0),3),(function(FA,KA,ZA,nt){xA(FA),lA(FA,ZA),lA(FA,~ZA),s.arraySet(FA.pending_buf,FA.window,KA,ZA,FA.pending),FA.pending+=ZA})(OA,_A,DA)}o._tr_init=function(OA){VA||((function(){var _A,DA,NA,FA,KA,ZA=new Array(E+1);for(FA=NA=0;FA<I-1;FA++)for(O[FA]=NA,_A=0;_A<1<<S[FA];_A++)J[NA++]=FA;for(J[NA-1]=FA,FA=KA=0;FA<16;FA++)for(aA[FA]=KA,_A=0;_A<1<<_[FA];_A++)Y[KA++]=FA;for(KA>>=7;FA<C;FA++)for(aA[FA]=KA<<7,_A=0;_A<1<<_[FA]-7;_A++)Y[256+KA++]=FA;for(DA=0;DA<=E;DA++)ZA[DA]=0;for(_A=0;_A<=143;)F[2*_A+1]=8,_A++,ZA[8]++;for(;_A<=255;)F[2*_A+1]=9,_A++,ZA[9]++;for(;_A<=279;)F[2*_A+1]=7,_A++,ZA[7]++;for(;_A<=287;)F[2*_A+1]=8,_A++,ZA[8]++;for(YA(F,B+1,ZA),_A=0;_A<C;_A++)H[2*_A+1]=5,H[2*_A]=MA(_A,5);W=new eA(F,S,l+1,B,E),z=new eA(H,_,0,C,E),tA=new eA(new Array(0),b,0,Q,d)})(),VA=!0),OA.l_desc=new oA(OA.dyn_ltree,W),OA.d_desc=new oA(OA.dyn_dtree,z),OA.bl_desc=new oA(OA.bl_tree,tA),OA.bi_buf=0,OA.bi_valid=0,EA(OA)},o._tr_stored_block=JA,o._tr_flush_block=function(OA,_A,DA,NA){var FA,KA,ZA=0;0<OA.level?(OA.strm.data_type===2&&(OA.strm.data_type=(function(nt){var SA,CA=4093624447;for(SA=0;SA<=31;SA++,CA>>>=1)if(1&CA&&nt.dyn_ltree[2*SA]!==0)return r;if(nt.dyn_ltree[18]!==0||nt.dyn_ltree[20]!==0||nt.dyn_ltree[26]!==0)return a;for(SA=32;SA<l;SA++)if(nt.dyn_ltree[2*SA]!==0)return a;return r})(OA)),It(OA,OA.l_desc),It(OA,OA.d_desc),ZA=(function(nt){var SA;for(mA(nt,nt.dyn_ltree,nt.l_desc.max_code),mA(nt,nt.dyn_dtree,nt.d_desc.max_code),It(nt,nt.bl_desc),SA=Q-1;3<=SA&&nt.bl_tree[2*R[SA]+1]===0;SA--);return nt.opt_len+=3*(SA+1)+5+5+4,SA})(OA),FA=OA.opt_len+3+7>>>3,(KA=OA.static_len+3+7>>>3)<=FA&&(FA=KA)):FA=KA=DA+5,DA+4<=FA&&_A!==-1?JA(OA,_A,DA,NA):OA.strategy===4||KA===FA?(pA(OA,2+(NA?1:0),3),jA(OA,F,H)):(pA(OA,4+(NA?1:0),3),(function(nt,SA,CA,hA){var TA;for(pA(nt,SA-257,5),pA(nt,CA-1,5),pA(nt,hA-4,4),TA=0;TA<hA;TA++)pA(nt,nt.bl_tree[2*R[TA]+1],3);gt(nt,nt.dyn_ltree,SA-1),gt(nt,nt.dyn_dtree,CA-1)})(OA,OA.l_desc.max_code+1,OA.d_desc.max_code+1,ZA+1),jA(OA,OA.dyn_ltree,OA.dyn_dtree)),EA(OA),NA&&xA(OA)},o._tr_tally=function(OA,_A,DA){return OA.pending_buf[OA.d_buf+2*OA.last_lit]=_A>>>8&255,OA.pending_buf[OA.d_buf+2*OA.last_lit+1]=255&_A,OA.pending_buf[OA.l_buf+OA.last_lit]=255&DA,OA.last_lit++,_A===0?OA.dyn_ltree[2*DA]++:(OA.matches++,_A--,OA.dyn_ltree[2*(J[DA]+l+1)]++,OA.dyn_dtree[2*rA(_A)]++),OA.last_lit===OA.lit_bufsize-1},o._tr_align=function(OA){pA(OA,2,3),kA(OA,f,F),(function(_A){_A.bi_valid===16?(lA(_A,_A.bi_buf),_A.bi_buf=0,_A.bi_valid=0):8<=_A.bi_valid&&(_A.pending_buf[_A.pending++]=255&_A.bi_buf,_A.bi_buf>>=8,_A.bi_valid-=8)})(OA)}},{"../utils/common":41}],53:[function(i,n,o){n.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(i,n,o){(function(s){(function(r,a){if(!r.setImmediate){var g,c,I,l,B=1,C={},Q=!1,h=r.document,E=Object.getPrototypeOf&&Object.getPrototypeOf(r);E=E&&E.setTimeout?E:r,g={}.toString.call(r.process)==="[object process]"?function(m){t.nextTick(function(){d(m)})}:(function(){if(r.postMessage&&!r.importScripts){var m=!0,w=r.onmessage;return r.onmessage=function(){m=!1},r.postMessage("","*"),r.onmessage=w,m}})()?(l="setImmediate$"+Math.random()+"$",r.addEventListener?r.addEventListener("message",f,!1):r.attachEvent("onmessage",f),function(m){r.postMessage(l+m,"*")}):r.MessageChannel?((I=new MessageChannel).port1.onmessage=function(m){d(m.data)},function(m){I.port2.postMessage(m)}):h&&"onreadystatechange"in h.createElement("script")?(c=h.documentElement,function(m){var w=h.createElement("script");w.onreadystatechange=function(){d(m),w.onreadystatechange=null,c.removeChild(w),w=null},c.appendChild(w)}):function(m){setTimeout(d,0,m)},E.setImmediate=function(m){typeof m!="function"&&(m=new Function(""+m));for(var w=new Array(arguments.length-1),D=0;D<w.length;D++)w[D]=arguments[D+1];var S={callback:m,args:w};return C[B]=S,g(B),B++},E.clearImmediate=u}function u(m){delete C[m]}function d(m){if(Q)setTimeout(d,0,m);else{var w=C[m];if(w){Q=!0;try{(function(D){var S=D.callback,_=D.args;switch(_.length){case 0:S();break;case 1:S(_[0]);break;case 2:S(_[0],_[1]);break;case 3:S(_[0],_[1],_[2]);break;default:S.apply(a,_)}})(w)}finally{u(m),Q=!1}}}}function f(m){m.source===r&&typeof m.data=="string"&&m.data.indexOf(l)===0&&d(+m.data.slice(l.length))}})(typeof self>"u"?s===void 0?this:s:self)}).call(this,typeof vK<"u"?vK:typeof self<"u"?self:typeof window<"u"?window:{})},{}]},{},[10])(10)})})(nmA)),nmA.exports}var Uii=Lii();const omA=b0(Uii);var smA,EEt;function Hii(){return EEt||(EEt=1,smA=function(e,A){A||(A={}),typeof A=="function"&&(A={cmp:A});var t=typeof A.cycles=="boolean"?A.cycles:!1,i=A.cmp&&(function(o){return function(s){return function(r,a){var g={key:r,value:s[r]},c={key:a,value:s[a]};return o(g,c)}}})(A.cmp),n=[];return(function o(s){if(s&&s.toJSON&&typeof s.toJSON=="function"&&(s=s.toJSON()),s!==void 0){if(typeof s=="number")return isFinite(s)?""+s:"null";if(typeof s!="object")return JSON.stringify(s);var r,a;if(Array.isArray(s)){for(a="[",r=0;r<s.length;r++)r&&(a+=","),a+=o(s[r])||"null";return a+"]"}if(s===null)return"null";if(n.indexOf(s)!==-1){if(t)return JSON.stringify("__cycle__");throw new TypeError("Converting circular structure to JSON")}var g=n.push(s)-1,c=Object.keys(s).sort(i&&i(s));for(a="",r=0;r<c.length;r++){var I=c[r],l=o(s[I]);l&&(a&&(a+=","),a+=JSON.stringify(I)+":"+l)}return n.splice(g,1),"{"+a+"}"}})(e)}),smA}var Yii=Hii();const Jii=b0(Yii);var uEt={0:"M0.4544564813877358 0L0.2723441540828736 0.03592830447352719L0.1086847233315459 0.14528754990019965L0.020630545837255005 0.3040632652221331L0 0.5395277421960205L0.049259221760993496 0.7369487828466779L0.18080513776237842 0.9005494166306564L0.37036887043974215 0.9872116270037247L0.5864663759301132 1L0.8148695622827444 0.9332890276148733L0.9326583645506394 0.8113052246023419L1 0.4031281830668562L0.833288960385582 0.09886798567812842L0.6801767918233781 0.02483708485091681L0.4544564813877358 0",1:"M 0.198 0.272 L 0.537 0 L 0.54 1",2:"M0.069593147751606 0.19461498231706575L0.1039380353319058 0.1224291500164194L0.20543361884368308 0.05510832064153169L0.3717712794432549 0.009452970962689482L0.4785344452623127 0L0.663238590738758 0.008714098643339864L0.8017933618843684 0.04769189395915288L0.8775637379550322 0.10746757678258442L0.9047778372591005 0.17693069668193287L0.9029710920770878 0.2231347105796246L0.8704496788008566 0.30047744598157516L0.7292906538577354 0.4508486051631194L0.3737955032119913 0.7369006417749693L0 1L1 1",3:"M0.03917438899874637 0.19855364635107545L0.15510940508963084 0.06745632622133718L0.37598645522339846 0L0.8486391893813088 0.0652271323161611L0.9782182415054349 0.21747394183735683L0.9213133780517754 0.3547560290117714L0.6504271515903481 0.4543436297681271L0.22975249764129613 0.48476611625264143L0.7659038682744629 0.5411919558122493L0.9258712987734741 0.6203185665660985L1 0.7458360609169667L0.8938813281118737 0.9059190913045964L0.6166890258875837 1L0.261528440153542 0.9874861530507921L0 0.8837289530851273",4:"M0.7328897338403042 0L0 0.6684672518568535L1 0.6684672518568535M0.7243346007604563 0.4530722484807562L0.7243346007604563 1",5:"M 0 0 L 0 0.4973 L 0.4262 0.4319 L 0.7305 0.4565 L 0.8516 0.5009 L 0.9357 0.5639 L 1 0.7356 L 0.9696 0.8248 L 0.8898 0.895 L 0.733 0.9602 L 0.5518 0.9945 L 0.3814 1 L 0.2379 0.9821 L 0.1219 0.947 L 0 0.8748 M 0 0 L 1 0",6:"M0.6964601700926856 0L0.3639239026215478 0.0743562375769351L0.1415931962925719 0.21735490179786915L0.009977939399608712 0.46336322325406004L0.00029622007592593224 0.7083131475173043L0.09408885043224748 0.8746809149767036L0.3379247445101846 0.9876686500961888L0.7109203869569624 1L0.9260852957913362 0.9103558029693921L1 0.7716571969091733L0.9824294723385016 0.6390635485705886L0.7446504992867332 0.4733643097729175L0.31028858071607296 0.47578021640899115L0.1208702146816024 0.5481452483973847L0 0.6616669755788906",7:"M0 0L1 0L0.9246479649697582 0.030539772727272752L0.8850302419354837 0.05075757575757579L0.7922946068548385 0.11079545454545457L0.7419268208165322 0.15213068181818185L0.6907258064516127 0.20202020202020204L0.6400666267641127 0.26122159090909086L0.5913243447580644 0.33049242424242414L0.5458740234374998 0.4105902777777778L0.5050907258064514 0.5022727272727272L0.4703495148689514 0.6062973484848484L0.43257456133442534 0.787133049242424L0.41612903225806447 1",8:"M0.5143001078924863 0L0.16007477667923162 0.10731570786949331L0.14924628550868277 0.3146018498698755L0.2939585848842112 0.41617921794558677L0.8648302624811545 0.5385163833653317L1 0.7775820770511038L0.8180842915260376 0.9505845566922285L0.41968938540525413 1L0.08062381919779889 0.882831681184498L0 0.6936376947135333L0.17150171673893433 0.5188652309607817L0.6529263782780712 0.4242818653203618L0.8650205888491803 0.29644027376796367L0.8702067371119496 0.09910067291661573L0.5143001078924863 0",9:"M1 0.25379591792994305L0.9514789771111742 0.11679361536614272L0.8702482473521467 0.05711741614054847L0.7327445265851579 0.015213872471965633L0.525248180711544 0L0.3292056884418538 0.012928195113745608L0.15997632037247655 0.058762870026191856L0.05266940041228321 0.12882439350476L0 0.2562067822770946L0.11316462894512366 0.4121335905917837L0.2403060136479954 0.4603365890068938L0.4097241967586011 0.4745978388276783L0.8642414300184816 0.420815170259988L0.9732054796346318 0.34537434075898393L1 0.25379591792994305M0.9647426784191072 0.35488595400360495L0.4756895081034974 1",A:"M0 1L0.4808333333333333 0L1 1M0.24250000000000002 0.6099439775910365L0.7341666666666666 0.6099439775910365",B:"M0 1L0 0.0117369978777208L0.30665717153513444 0L0.5874522807082946 0.03451403469442413L0.7766202217193218 0.15033936404895643L0.7471969743588041 0.31967962568332936L0.5246013359741988 0.4102978954282461L0.04378745314885416 0.44918617613783574L0.5112949594180156 0.469692928091109L0.8540266515643348 0.5552749498651879L1 0.6868463175009967L0.9880091196159324 0.8570018204672155L0.922301719975498 0.9321708046604659L0.7584266951758925 0.9932594737131338L0 1",C:"M1 0.23038928858890784L0.9328355511865092 0.12426412616785204L0.8096380839483327 0.04912601676267708L0.5763225801788256 0L0.4039037709527492 0.015028068281399815L0.2519579390951737 0.06533979308999706L0.10359458463139784 0.18146243506591617L0 0.4862728453971315L0.08129580872733055 0.792689266886982L0.20257034847159672 0.9160822255736587L0.3286572892798542 0.9738230826074175L0.5742878414421707 1L0.7883510303801312 0.9665431511195721L0.946851033994232 0.8689071500976585L1 0.7311049027121912",D:"M0 1L0.015604366822624637 0.020770988281483303L0.22564758265176144 0L0.3865476147957666 0.0024153386496795644L0.6479126635475078 0.051745644338731314L0.841191887805517 0.15827717679529366L0.9517008345536152 0.30172260586872185L0.9957536578687336 0.4504541551987709L1 0.5624359222498485L0.9798483279164735 0.6584121775234548L0.9386273319285215 0.7395945263504481L0.806292129480815 0.8624239259880274L0.6296239151398265 0.9406169638094516L0.3397492767598845 0.9954164354263132L0 1",E:"M0 0L0 1M0 0L1 0M0 0.5L0.7 0.5M0 1L1 1",F:"M0 0L0 1M0.011363636363636364 0.006802721088435374L1 0.006802721088435374M0.011363636363636364 0.4965986394557823L0.8409090909090909 0.4965986394557823",G:"M0.902666857540557 0.03860785012651126L0.6504261864675637 0L0.3838947267237336 0.015442305268228053L0.21293332876776194 0.07706794377239819L0.07799659974941617 0.1994951236187481L0 0.46380381528937314L0.04159964421546915 0.7502491408002389L0.13176692977834842 0.8535497868383203L0.2709176262273927 0.936767572377719L0.4386472596876406 0.9891638569283179L0.6145513562841309 1L0.7782254421419019 0.9585373611026471L0.9092650433859927 0.8540372997461425L1 0.5556012645283437L0.5583959277303046 0.55491741080559",H:"M0 0L0 1M0 0.4788732394366197L0.989010989010989 0.4788732394366197M1 0L1 1",I:"M0.5 0L0.5 1",J:"M0.9976457238788704 0L1 0.7396412315872798L0.9773931362096968 0.8322033314977973L0.9345115952458736 0.882296255506608L0.8743862896259549 0.9221331222466961L0.8024024079884948 0.9526431718061675L0.6443996712151668 0.9893997797356828L0.5035848940343224 1L0.3127211130319937 0.9877004749449337L0.17201910858386513 0.9539509911894274L0.10357419806379677 0.9212555066079295L0.053656568662899015 0.8816079295154184L0.020759483663648916 0.8360407488986785L0.003376206348523566 0.7855864537444934L0 0.7312775330396476",K:"M0 0L0 1M0.8787878787878788 0.06666666666666667L0 0.6148148148148148M0.3333333333333333 0.45925925925925926L1 0.9777777777777777",L:"M0 0L0 1L1 1",M:"M0 1L0 0L0.5 0.6512L1 0L1 1",N:"M0 1L0 0L1 1L0.9803729146221786 0",O:"M0.4718499217948183 1L0.2896765846490613 0.9606979309189402L0.12315162147934663 0.8411184486080473L0 0.4352399966492615L0.11730398524516283 0.13145645436014852L0.2612197451988078 0.04493357858878059L0.5104071592772554 0L0.7450113425917159 0.05393013710105273L0.882367950645524 0.15242300282020502L1 0.5224527406249126L0.9414597290654386 0.7560662329321755L0.8371289514446183 0.8910800547287298L0.6518259868433511 0.9830452628933628L0.4718499217948183 1",P:"M0 1L0 0.018871774228013626L0.29609603495819875 0L0.5609840637427541 0.011794858892508529L0.7332142696692472 0.04353904702296349L0.8102258645858864 0.0691965055027166L0.9330504315465442 0.14445061754775845L0.9876391714147118 0.22527816445836535L1 0.3434414070631638L0.9510549958116356 0.41772808046663146L0.8746646891596713 0.45879131862541683L0.7528523813396283 0.49171525113425024L0.5766919939969619 0.5153253033973054L0.33725744877712827 0.5284469008187558L0.025622667325582785 0.529905468802775",Q:"M0.4618887943546369 0.9755918167206952L0.28356128136544534 0.9372490397450218L0.12055179272160406 0.8205882753548176L0 0.4246165790405623L0.1148276047430244 0.12824784112887844L0.25570518844754375 0.043836831567190586L0.49963205786237674 0L0.7292835601228574 0.0526138004304122L0.8637404608452104 0.14870263423138746L0.9788892040030622 0.5097006183769648L0.9215847647858059 0.7376120297474734L0.8194564929275405 0.869330409436378L0.6380654214095985 0.9590509139448092L0.4618887943546369 0.9755918167206952M0.5824181120212351 0.6861805006946525L1 1",R:"M0 0.9928375167236815L0 0.02590227442068435L0.3611517274211098 0L0.6146286724700761 0.008660554424468435L0.7675462459194776 0.035269459580494614L0.831839975516866 0.056961676692569484L0.8847592491838954 0.08519560521497332L0.9238557535364527 0.120683646438422L0.9583303225312839 0.21691797435320384L0.955092470586235 0.3022616904894429L0.9198097669001631 0.3640573439322699L0.8564862239866702 0.40639258627024005L0.7691258543593579 0.43335506909190874L0.601775027203482 0.4539166070813109L0.023939064200217658 0.46997623755243123M0.5038084874863982 0.5108023922274467L1 1",S:"M0.8886929689221953 0.15146982162688968L0.7276173683050475 0.013780286031594946L0.34582323121005076 0L0.1318235250900008 0.09920162734298861L0.0444543935052531 0.2811287071349243L0.08064065829108809 0.3709571405906485L0.21603115127470426 0.4485505768228281L0.7525409135992945 0.5111160926769565L0.9330263665417677 0.5850732219351329L1 0.7129938124702524L0.9117772389978691 0.9130572743138187L0.6423187128058188 1L0.29586019579751677 0.9935291584506244L0.10638454191462794 0.9229845198431584L0 0.7570771288048773",T:"M0 0L1 0M0.5148514851485149 0L0.5148514851485149 1",U:"M0 0L0.0023103778751369115 0.5467447428390111L0.01823032542100219 0.6954785891481812L0.05895528135268338 0.8056480226151669L0.13703402031421133 0.8894445726483398L0.23918400876232196 0.9448524533417946L0.3917887458926616 0.9848674531975652L0.584341627875137 1L0.7194816196604602 0.9848501456716763L0.8303268115073934 0.9449411544119768L0.8966613970084885 0.898186315516197L0.9251437568455642 0.867453197565408L0.9687114937020809 0.7890904895145239L0.9890470974808324 0.6852857184065537L1 0.0014769088758762145",V:"M0 0L0.5348837209302325 1L1 0",W:"M0 0L0.23300090661831369 0.9873417721518988L0.49954669084315495 0.30081906180193585L0.7851314596554849 1L1 0.0215934475055845",X:"M0 0L0.9893617021276596 1M1 0L0.010638297872340425 1",Y:"M0 0L0.4860515021459227 0.44712562100780695M1 0.0014194464158977947L0.48927038626609437 0.44996451383960256L0.5075107296137339 1",Z:"M0 0L1 0L0 1L1 1",".":"M 0.49 1 L 0.41 1","*":"M 0.5 0.25 L 0.8 0.25 M 0.5 0.25 L 0.5927 0.4402 M 0.5 0.25 L 0.2573 0.3676 M 0.5 0.25 L 0.2573 0.1324 M 0.5 0.25 L 0.599 0.055","(":"M0.75 0L0.25 0.5L0.25 0.5L0.75 1",")":"M0.25 0L0.75 0.5L0.75 0.5L0.25 1","-":"M0 0.5L1 0.5","+":"M 0 0.5 L 1 0.5 M 0.5 0.125 L 0.5 0.875","=":"M0 0.25L1 0.25M0 0.75L1 0.75",_:"M0 1 L1 1","[":"M0.75 0L0.25 0L0.25 1L0.75 1","]":"M0.25 0L0.75 0L0.75 1L0.25 1","<":"M0.75 0L0.25 0.5L0.25 0.5L0.75 1",">":"M0.25 0L0.75 0.5L0.75 0.5L0.25 1","'":"M 0.5 0 L 0.5 0.5",'"':"M 0.25 0 L 0.25 0.5 M 0.75 0 L 0.75 0.5"},rmA={};for(const e in uEt){rmA[e]=[];const A=uEt[e].split("M").slice(1).map(t=>t.split("L").map(i=>i.trim().split(" ").map(parseFloat)));for(const t of A)for(let i=0;i<t.length-1;i++)rmA[e].push({x1:t[i][0],y1:1-t[i][1],x2:t[i+1][0],y2:1-t[i+1][1]})}function FM(e,A){return Array.isArray(A)?[e.a*A[0]+e.c*A[1]+e.e,e.b*A[0]+e.d*A[1]+e.f]:{x:e.a*A.x+e.c*A.y+e.e,y:e.b*A.x+e.d*A.y+e.f}}function dEt(){return{a:1,c:0,e:0,b:0,d:1,f:0}}function Q1(e,A=0){return{a:1,c:0,e,b:0,d:1,f:A}}function pEt(...e){e=Array.isArray(e[0])?e[0]:e;const A=(t,i)=>({a:t.a*i.a+t.c*i.b,c:t.a*i.c+t.c*i.d,e:t.a*i.e+t.c*i.f+t.e,b:t.b*i.a+t.d*i.b,d:t.b*i.c+t.d*i.d,f:t.b*i.e+t.d*i.f+t.f});switch(e.length){case 0:throw new Error("no matrices provided");case 1:return e[0];case 2:return A(e[0],e[1]);default:{const[t,i,...n]=e,o=A(t,i);return pEt(o,...n)}}}function amA(...e){return pEt(...e)}const{cos:Tii,sin:Pii}=Math;function gmA(e,A,t){const i=Tii(e),n=Pii(e);return{a:i,c:-n,e:0,b:n,d:i,f:0}}var nQ=({command_code:e,schema:A,stringify:t})=>({command_code:e,schema:A,stringify:t}),Kii=nQ({command_code:"FMAT",schema:et({command_code:bA("FMAT").default("FMAT"),format:qA()}),stringify:e=>`FMAT,${e.format}`}),qii=nQ({command_code:"G00",schema:et({command_code:bA("G00").default("G00")}),stringify:()=>"G00"}),Oii=nQ({command_code:"G01",schema:et({command_code:bA("G01").default("G01")}),stringify:()=>"G01"}),Wii=nQ({command_code:"G05",schema:et({command_code:bA("G05").default("G05")}),stringify:()=>"G05"}),Zii=nQ({command_code:"G85",schema:et({command_code:bA("G85").default("G85"),x:qA(),y:qA(),width:qA()}),stringify:({x:e,y:A})=>`G85X${e.toFixed(3)}Y${A.toFixed(3)}`}),Vii=nQ({command_code:"G90",schema:et({command_code:bA("G90").default("G90")}),stringify:()=>"G90"}),jii=nQ({command_code:"M15",schema:et({command_code:bA("M15").default("M15")}),stringify:()=>"M15"}),zii=nQ({command_code:"M16",schema:et({command_code:bA("M16").default("M16")}),stringify:()=>"M16"}),Xii=nQ({command_code:"M30",schema:et({command_code:bA("M30").default("M30")}),stringify:()=>"M30"}),$ii=nQ({command_code:"M48",schema:et({command_code:bA("M48").default("M48")}),stringify:()=>"M48"}),Ani=nQ({command_code:"M95",schema:et({command_code:bA("M95").default("M95")}),stringify:()=>"M95"}),fEt=nQ({command_code:"define_tool",schema:et({command_code:bA("define_tool").default("define_tool"),tool_number:qA(),diameter:qA()}),stringify:e=>`T${e.tool_number}C${e.diameter.toFixed(6)}`}),tni=nQ({command_code:"drill_at",schema:et({command_code:bA("drill_at").default("drill_at"),x:qA(),y:qA()}),stringify:e=>`X${e.x.toFixed(4)}Y${e.y.toFixed(4)}`}),eni=nQ({command_code:"header_attribute",schema:et({command_code:bA("header_attribute").default("header_attribute"),attribute_name:L(),attribute_value:L()}),stringify({attribute_name:e,attribute_value:A}){return`; #@! ${e},${A}`}}),ini=nQ({command_code:"header_comment",schema:et({command_code:bA("header_comment").default("header_comment"),text:L()}),stringify({text:e}){return`; ${e}`}}),nni=nQ({command_code:"rewind",schema:et({command_code:bA("rewind").default("rewind")}),stringify:()=>"%"}),oni=nQ({command_code:"unit_format",schema:et({command_code:bA("unit_format").default("unit_format"),unit:Ge([bA("INCH"),bA("METRIC")]),lz:Ge([bA("LZ"),bA("TZ")]).nullable().default(null)}),stringify(e){return`${e.unit}${e.lz?`,${e.lz}`:""}`}}),sni=nQ({command_code:"use_tool",schema:et({command_code:bA("use_tool").default("use_tool"),tool_number:qA()}),stringify:e=>`T${e.tool_number}`}),rni=nQ({command_code:"aper_function_header",schema:et({command_code:bA("aper_function_header").default("aper_function_header"),is_plated:PA()}),stringify({is_plated:e}){return e?"; #@! TA.AperFunction,Plated,PTH,ComponentDrill":"; #@! TA.AperFunction,NonPlated,NPTH,ComponentDrill"}}),ani=nQ({command_code:"percent_sign",schema:et({command_code:bA("percent_sign").default("percent_sign")}),stringify:()=>"%"}),yEt={G00:qii,G01:Oii,G85:Zii,M48:$ii,M95:Ani,FMAT:Kii,unit_format:oni,aper_function_header:rni,percent_sign:ani,T:fEt,define_tool:fEt,use_tool:sni,G90:Vii,G05:Wii,M15:jii,M16:zii,M30:Xii,drill_at:tni,header_comment:ini,header_attribute:eni,rewind:nni},gni=e=>e.map(A=>yEt[A.command_code].stringify(A)).join(`
|
|
5704
5704
|
`),cni=class{commands;constructor(){this.commands=[]}add(e,A){return this.commands.push({command_code:yEt[e].command_code,...A}),this}build(){return this.commands}},Ini=()=>new cni,lni=({circuitJson:e,is_plated:A,flip_y_axis:t=!1})=>{const i=Ini();i.add("M48",{});const n=new Date().toISOString();i.add("header_comment",{text:`DRILL file {tscircuit} date ${n}`}).add("header_comment",{text:"FORMAT={-:-/ absolute / metric / decimal}"}).add("header_attribute",{attribute_name:"TF.CreationDate",attribute_value:n}).add("header_attribute",{attribute_name:"TF.GenerationSoftware",attribute_value:"tscircuit"}).add("header_attribute",{attribute_name:"TF.FileFunction",attribute_value:"Plated,1,2,PTH"}).add("FMAT",{format:2}).add("unit_format",{unit:"METRIC",lz:null});let o=10;const s={};for(const r of e){if(r.type!=="pcb_plated_hole"&&r.type!=="pcb_hole"&&r.type!=="pcb_via")continue;const a="hole_diameter"in r&&typeof r.hole_diameter=="number"?r.hole_diameter:"hole_width"in r&&typeof r.hole_width=="number"&&"hole_height"in r&&typeof r.hole_height=="number"?Math.min(r.hole_width,r.hole_height):void 0;a&&(s[a]||(i.add("aper_function_header",{is_plated:A}),i.add("define_tool",{tool_number:o,diameter:a}),s[a]=o,o++))}i.add("percent_sign",{}),i.add("G90",{}),i.add("G05",{});for(let r=10;r<o;r++){i.add("use_tool",{tool_number:r});for(const a of e)if(a.type==="pcb_plated_hole"||a.type==="pcb_hole"||a.type==="pcb_via"){const g="hole_diameter"in a&&typeof a.hole_diameter=="number"?a.hole_diameter:"hole_width"in a&&typeof a.hole_width=="number"&&"hole_height"in a&&typeof a.hole_height=="number"?Math.min(a.hole_width,a.hole_height):void 0;if(!g||s[g]!==r)continue;const c="x"in a&&typeof a.x=="number"?a.x:0,I="y"in a&&typeof a.y=="number"?a.y:0,l="hole_offset_x"in a&&typeof a.hole_offset_x=="number"?a.hole_offset_x:0,B="hole_offset_y"in a&&typeof a.hole_offset_y=="number"?a.hole_offset_y:0,C=c+l,Q=I+B,h=t?-1:1;if("hole_width"in a&&typeof a.hole_width=="number"&&"hole_height"in a&&typeof a.hole_height=="number"){const E=a.hole_width,u=a.hole_height,d=Math.max(E,u),f=Math.min(E,u);if(Math.abs(d-f)<=1e-6){i.add("drill_at",{x:C,y:Q*h});continue}const w=("hole_ccw_rotation"in a&&typeof a.hole_ccw_rotation=="number"?a.hole_ccw_rotation:"ccw_rotation"in a&&typeof a.ccw_rotation=="number"?a.ccw_rotation:0)*Math.PI/180,D=Math.cos(w),S=Math.sin(w),_=E>=u,b=(d-f)/2,R=_?{x:-b,y:0}:{x:0,y:-b},F=_?{x:b,y:0}:{x:0,y:b},H=({x:aA,y:eA})=>({x:aA*D-eA*S,y:aA*S+eA*D}),Y=H(R),J=H(F),O=C+Y.x,W=(Q+Y.y)*h,z=C+J.x,tA=(Q+J.y)*h;i.add("drill_at",{x:O,y:W}).add("G85",{x:z,y:tA,width:f});continue}i.add("drill_at",{x:C,y:Q*h})}}return i.add("M30",{}),i.build()},al=({command_code:e,schema:A,stringify:t})=>({command_code:e,schema:A,stringify:t}),Bni=al({command_code:"TA",schema:et({command_code:bA("TA").default("TA"),attribute_name:L(),attribute_value:L()}).describe("Add attribute on aperture: Add an aperture attribute to the dictionary or modify it."),stringify:({attribute_name:e,attribute_value:A})=>`%TA${e},${A}*%`}),Cni=al({command_code:"TF",schema:et({command_code:bA("TF").default("TF"),attribute_name:L(),attribute_value:L()}).describe("Add attribute on file: Set a file attribute."),stringify:({attribute_name:e,attribute_value:A})=>`%TF.${e},${A}*%`}),Qni=al({command_code:"TO",schema:et({command_code:bA("TO").default("TO"),attribute_name:L(),attribute_value:L()}).describe("Add attribute on object: Add an object attribute to the dictionary or modify it."),stringify:({attribute_name:e,attribute_value:A})=>`%TO${e},${A}*%`}),hni=al({command_code:"AB",schema:et({command_code:bA("AB").default("AB"),block:L()}).describe("Aperture block: Opens a block aperture statement and assigns its aperture number or closes a block aperture statement"),stringify(){return""}}),Eni=al({command_code:"G04",schema:et({command_code:bA("G04").default("G04"),comment:L()}).describe("Comment: A human readable comment, does not affect the image. 4.1"),stringify:e=>`G04 ${e.comment}*`}),uni=al({command_code:"G75",schema:et({command_code:bA("G75").default("G75")}).describe("Create arc: A G75 must be called before creating the first arc."),stringify(){return"G75*"}}),dni=al({command_code:"AD",schema:et({command_code:bA("AD").default("AD"),aperture_code:L()}).describe("Aperture define: Defines a template-based aperture, assigns a D code to it. 4.3"),stringify(){return""}}),pni=al({command_code:"AM",schema:et({command_code:bA("AM").default("AM"),macro_name:L(),template_code:L()}).describe("Aperture macro: Defines a macro aperture template. 4.5"),stringify({macro_name:e,template_code:A}){return`%AM${e}*
|
|
5705
5705
|
${A}%`}}),fni=al({command_code:"TD",schema:et({command_code:bA("TD").default("TD"),attribute:L().optional()}).describe("Delete attribute: Attribute delete Delete one or all attributes in the dictionary."),stringify({attribute:e}){return e?`%TD${e}*%`:"%TD*%"}}),yni=al({command_code:"M02",schema:et({command_code:bA("M02").default("M02")}).describe("End of file: 4.13"),stringify(){return"M02*"}}),mni=al({command_code:"G37",schema:et({command_code:bA("G37").default("G37")}).describe("End region statement: Ends the region statement"),stringify(){return"G37*"}}),h1=e=>{const A=e*1e6;let t=A.toFixed(0);for(;t.length<9;)A<0?t=`-0${t.slice(1)}`:t=`0${t}`;return t},wni=al({command_code:"D03",schema:et({command_code:bA("D03").default("D03"),x:qA(),y:qA()}).describe("Flash operation: Creates a flash object with the current aperture. The current point is moved to the flash point."),stringify({x:e,y:A}){const[t,i]=[e,A].map(n=>h1(n));return`X${t}Y${i}D03*`}});et({command_code:bA("LM"),mirroring:L()}).describe("Load mirroring: Loads the mirror object transformation parameter."),et({command_code:bA("LP"),polarity:L()}).describe("Load polarity: Loads the polarity object transformation parameter.");var Dni=al({command_code:"LR",schema:et({command_code:bA("LR").default("LR"),rotation_degrees:qA()}).describe("Load rotation: Loads the rotation object transformation parameter."),stringify:({rotation_degrees:e})=>`%LR${e}*%`});et({command_code:bA("LS"),scaling:L()}).describe("Load scaling: Loads the scale object transformation parameter.");var Sni=al({command_code:"D02",schema:et({command_code:bA("D02").default("D02"),x:qA(),y:qA()}).describe("Move operation: D02 moves the current point to the coordinate in the command. It does not create an object."),stringify({x:e,y:A}){const[t,i]=[e,A].map(n=>h1(n));return`X${t}Y${i}D02*`}}),bni=al({command_code:"D01",schema:et({command_code:bA("D01").default("D01"),x:qA(),y:qA(),i:qA().optional(),j:qA().optional()}).describe("Plot operation: Outside a region statement D01 creates a draw or arc object with the current aperture. Inside it adds a draw/arc segment to the contour under construction. The current point is moved to draw/arc end point after the creation of the draw/arc."),stringify({x:e,y:A,i:t,j:i}){const n=h1(e),o=h1(A);let s=`X${n}Y${o}`;if(t!==void 0&&i!==void 0){const r=h1(t),a=h1(i);s+=`I${r}J${a}`}return`${s}D01*`}});et({command_code:bA("FS"),format:L()}).describe("Sets the coordinate format, e.g. the number of decimals."),et({command_code:bA("Dnn"),d_code:L()}).describe("(nn≥10) Sets the current aperture to D code nn. 4.6");var xni=al({command_code:"G02",schema:et({command_code:bA("G02").default("G02")}).describe("Set movement mode to clockwise circular: Sets linear/circular mode to clockwise circular."),stringify(){return"G02*"}}),_ni=al({command_code:"G03",schema:et({command_code:bA("G03").default("G03")}).describe("Set movement mode to counterclockwise circular: Sets linear/circular mode to counterclockwise circular."),stringify(){return"G03*"}}),kni=al({command_code:"G01",schema:et({command_code:bA("G01").default("G01")}).describe("Set movement mode to linear: Sets linear/circular mode to linear."),stringify(){return"G01*"}}),vni=al({command_code:"MO",schema:et({command_code:bA("MO").default("MO"),unit:Xt(["MM","in"])}).describe("Mode: Sets the unit to mm or inch. 4.2.1"),stringify({unit:e}){return`%MO${e}*%`}}),Fni=al({command_code:"G36",schema:et({command_code:bA("G36").default("G36")}).describe("Start region statement: Starts a region statement which creates a region by defining its contours."),stringify(){return"G36*"}});et({command_code:bA("SR"),statement:L()}).describe("Step and repeat: Open or closes a step and repeat statement.");var Mni=al({command_code:"FS",schema:et({command_code:bA("FS").default("FS"),zero_omission_mode:Ge([bA("L").describe("leading zeros omitted"),bA("T")]).nullable().default(null),coordinate_notation:Ge([bA("A").describe("absolute notation"),bA("I").describe("incremental notation")]).default("A"),x_integer_digits:qA().int().default(4),x_decimal_digits:qA().int().default(6),y_integer_digits:qA().int().default(4),y_decimal_digits:qA().int().default(6)}),stringify:()=>"%FSLAX46Y46*%"}),Gni=al({command_code:"LP",schema:et({command_code:bA("LP").default("LP"),polarity:Xt(["D","C"])}).describe("Layer Polarity: Sets the layer polarity to dark or clear. 4.2.1"),stringify({polarity:e}){return`%LP${e}*%`}}),Rni=et({standard_template_code:bA("C").describe("circle"),diameter:qA(),hole_diameter:qA().optional()}),Nni=et({standard_template_code:bA("R").describe("rectangle"),x_size:qA(),y_size:qA(),hole_diameter:qA().optional()}),Lni=et({standard_template_code:bA("O").describe("obround"),x_size:qA(),y_size:qA(),hole_diameter:qA().optional()}),Uni=et({standard_template_code:bA("P").describe("polygon"),outer_diameter:qA(),number_of_vertices:qA().int(),rotation:qA().optional(),hole_diameter:qA().optional()}),Hni=df("standard_template_code",[Rni,Nni,Lni,Uni]),Yni=et({macro_name:bA("HORZPILL"),x_size:qA(),y_size:qA(),circle_diameter:qA(),circle_center_offset:qA()}),Jni=et({macro_name:bA("VERTPILL"),x_size:qA(),y_size:qA(),circle_diameter:qA(),circle_center_offset:qA()}),Tni=et({macro_name:bA("ROUNDRECT"),corner_radius:qA(),corner_1_x:qA(),corner_1_y:qA(),corner_2_x:qA(),corner_2_y:qA(),corner_3_x:qA(),corner_3_y:qA(),corner_4_x:qA(),corner_4_y:qA()}),Pni=df("macro_name",[Yni,Jni,Tni]),Kni=Ge([Hni,Pni]),qni=al({command_code:"ADD",schema:Kni.and(et({command_code:bA("ADD").default("ADD"),aperture_number:qA().int()})),stringify(e){if("macro_name"in e){const{aperture_number:A,macro_name:t}=e;let i=`%ADD${A}${t},`;if(t==="HORZPILL"||t==="VERTPILL")i+=`${e.x_size.toFixed(6)}X${e.y_size.toFixed(6)}X${e.circle_diameter.toFixed(6)}X${e.circle_center_offset.toFixed(6)}`;else if(t==="ROUNDRECT")throw new Error("ROUNDRECT macro not implemented yet");return i+="*%",i}if("standard_template_code"in e){const{aperture_number:A,standard_template_code:t}=e;let i=`%ADD${A}${t},`;return t==="C"?i+=`${e.diameter.toFixed(6)}`:t==="R"||t==="O"?i+=`${e.x_size.toFixed(6)}X${e.y_size.toFixed(6)}`:t==="P"&&(i+=`${e.outer_diameter}X${e.number_of_vertices}X${e.rotation?`X${e.rotation}`:""}`),e.hole_diameter&&(i+=`X${e.hole_diameter.toFixed(6)}`),i+="*%",i}throw new Error(`Invalid aperture template config: ${JSON.stringify(e)}`)}}),Oni=al({command_code:"D",schema:et({command_code:bA("D").default("D"),aperture_number:qA().int()}),stringify({aperture_number:e}){return`D${e}*`}}),mEt={add_attribute_on_aperture:Bni,add_attribute_on_file:Cni,add_attribute_on_object:Qni,aperture_block:hni,comment:Eni,create_arc:uni,define_aperture:dni,define_macro_aperture_template:pni,delete_attribute:fni,end_of_file:yni,move_operation:Sni,flash_operation:wni,end_region_statement:mni,format_specification:Mni,load_rotation:Dni,plot_operation:bni,define_aperture_template:qni,set_movement_mode_to_clockwise_circular:xni,set_movement_mode_to_counterclockwise_circular:_ni,set_movement_mode_to_linear:kni,select_aperture:Oni,set_unit:vni,set_layer_polarity:Gni,start_region_statement:Fni},eg=()=>new Wni,Wni=class{commands;constructor(){this.commands=[]}$if(e,A){return e?A(this):this}add(e,A){return this.commands.push({command_code:mEt[e].command_code,...A}),this}build(){return this.commands}},Zni=e=>{const A=Object.values(mEt).find(t=>t.command_code===e.command_code);if(!A)throw new Error(`Command for command_code:"${e.command_code}" not found`);if(!A.stringify)throw new Error(`Command for command_code:"${e.command_code}" does not have a stringify method`);return A.stringify(e)},Vni=e=>{const A={};for(const t of Object.keys(e))A[t]=e[t].map(i=>Zni(i)).join(`
|