tscircuit 0.0.1248 → 0.0.1249

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.
@@ -5384,7 +5384,7 @@ svg { font-family: 'Inter', 'Helvetica Neue', Arial, sans-serif; }
5384
5384
  `+a+" | "+VpA("",n.column-1," ")+VpA("",I,"^")}else A+=`
5385
5385
  at `+s}return A},a9.buildMessage=function(t,A){var e={literal:function(g){return'"'+n(g.text)+'"'},class:function(g){var c=g.parts.map(function(I){return Array.isArray(I)?o(I[0])+"-"+o(I[1]):o(I)});return"["+(g.inverted?"^":"")+c.join("")+"]"},any:function(){return"any character"},end:function(){return"end of input"},other:function(g){return g.description}};function i(g){return g.charCodeAt(0).toString(16).toUpperCase()}function n(g){return g.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,function(c){return"\\x0"+i(c)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(c){return"\\x"+i(c)})}function o(g){return g.replace(/\\/g,"\\\\").replace(/\]/g,"\\]").replace(/\^/g,"\\^").replace(/-/g,"\\-").replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,function(c){return"\\x0"+i(c)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(c){return"\\x"+i(c)})}function s(g){return e[g.type](g)}function r(g){var c=g.map(s),I,l;if(c.sort(),c.length>0){for(I=1,l=1;I<c.length;I++)c[I-1]!==c[I]&&(c[l]=c[I],l++);c.length=l}switch(c.length){case 1:return c[0];case 2:return c[0]+" or "+c[1];default:return c.slice(0,-1).join(", ")+", or "+c[c.length-1]}}function a(g){return g?'"'+n(g)+'"':"end of input"}return"Expected "+r(t)+" but "+a(A)+" found."};const iJ=t=>typeof t=="number"&&!isNaN(t),wG=t=>typeof t=="string",R0=t=>typeof t=="function",g9=t=>wG(t)||R0(t)?t:null,jpA=t=>V.isValidElement(t)||wG(t)||R0(t)||iJ(t);function X4t(t,A,e){e===void 0&&(e=300);const{scrollHeight:i,style:n}=t;requestAnimationFrame(()=>{n.minHeight="initial",n.height=i+"px",n.transition=`all ${e}ms`,requestAnimationFrame(()=>{n.height="0",n.padding="0",n.margin="0",setTimeout(A,e)})})}function c9(t){let{enter:A,exit:e,appendPosition:i=!1,collapse:n=!0,collapseDuration:o=300}=t;return function(s){let{children:r,position:a,preventExitTransition:g,done:c,nodeRef:I,isIn:l,playToast:B}=s;const C=i?`${A}--${a}`:A,Q=i?`${e}--${a}`:e,h=V.useRef(0);return V.useLayoutEffect(()=>{const E=I.current,u=C.split(" "),d=p=>{p.target===I.current&&(B(),E.removeEventListener("animationend",d),E.removeEventListener("animationcancel",d),h.current===0&&p.type!=="animationcancel"&&E.classList.remove(...u))};E.classList.add(...u),E.addEventListener("animationend",d),E.addEventListener("animationcancel",d)},[]),V.useEffect(()=>{const E=I.current,u=()=>{E.removeEventListener("animationend",u),n?X4t(E,c,o):c()};l||(g?u():(h.current=1,E.className+=` ${Q}`,E.addEventListener("animationend",u)))},[l]),tn.createElement(tn.Fragment,null,r)}}function Ige(t,A){return t!=null?{content:t.content,containerId:t.props.containerId,id:t.props.toastId,theme:t.props.theme,type:t.props.type,data:t.props.data||{},isLoading:t.props.isLoading,icon:t.props.icon,status:A}:{}}const Kd=new Map;let nJ=[];const zpA=new Set,$4t=t=>zpA.forEach(A=>A(t)),lge=()=>Kd.size>0;function Bge(t,A){var e;if(A)return!((e=Kd.get(A))==null||!e.isToastActive(t));let i=!1;return Kd.forEach(n=>{n.isToastActive(t)&&(i=!0)}),i}function Cge(t,A){jpA(t)&&(lge()||nJ.push({content:t,options:A}),Kd.forEach(e=>{e.buildToast(t,A)}))}function Qge(t,A){Kd.forEach(e=>{A!=null&&A!=null&&A.containerId?A?.containerId===e.id&&e.toggle(t,A?.id):e.toggle(t,A?.id)})}function A3t(t){const{subscribe:A,getSnapshot:e,setProps:i}=V.useRef((function(o){const s=o.containerId||1;return{subscribe(r){const a=(function(c,I,l){let B=1,C=0,Q=[],h=[],E=[],u=I;const d=new Map,p=new Set,m=()=>{E=Array.from(d.values()),p.forEach(b=>b())},D=b=>{h=b==null?[]:h.filter(k=>k!==b),m()},w=b=>{const{toastId:k,onOpen:x,updateId:N,children:M}=b.props,U=N==null;b.staleId&&d.delete(b.staleId),d.set(k,b),h=[...h,b.props.toastId].filter(Y=>Y!==b.staleId),m(),l(Ige(b,U?"added":"updated")),U&&R0(x)&&x(V.isValidElement(M)&&M.props)};return{id:c,props:u,observe:b=>(p.add(b),()=>p.delete(b)),toggle:(b,k)=>{d.forEach(x=>{k!=null&&k!==x.props.toastId||R0(x.toggle)&&x.toggle(b)})},removeToast:D,toasts:d,clearQueue:()=>{C-=Q.length,Q=[]},buildToast:(b,k)=>{if((nA=>{let{containerId:rA,toastId:lA,updateId:pA}=nA;const xA=rA?rA!==c:c!==1,RA=d.has(lA)&&pA==null;return xA||RA})(k))return;const{toastId:x,updateId:N,data:M,staleId:U,delay:Y}=k,H=()=>{D(x)},O=N==null;O&&C++;const Z={...u,style:u.toastStyle,key:B++,...Object.fromEntries(Object.entries(k).filter(nA=>{let[rA,lA]=nA;return lA!=null})),toastId:x,updateId:N,data:M,closeToast:H,isIn:!1,className:g9(k.className||u.toastClassName),bodyClassName:g9(k.bodyClassName||u.bodyClassName),progressClassName:g9(k.progressClassName||u.progressClassName),autoClose:!k.isLoading&&($=k.autoClose,iA=u.autoClose,$===!1||iJ($)&&$>0?$:iA),deleteToast(){const nA=d.get(x),{onClose:rA,children:lA}=nA.props;R0(rA)&&rA(V.isValidElement(lA)&&lA.props),l(Ige(nA,"removed")),d.delete(x),C--,C<0&&(C=0),Q.length>0?w(Q.shift()):m()}};var $,iA;Z.closeButton=u.closeButton,k.closeButton===!1||jpA(k.closeButton)?Z.closeButton=k.closeButton:k.closeButton===!0&&(Z.closeButton=!jpA(u.closeButton)||u.closeButton);let aA=b;V.isValidElement(b)&&!wG(b.type)?aA=V.cloneElement(b,{closeToast:H,toastProps:Z,data:M}):R0(b)&&(aA=b({closeToast:H,toastProps:Z,data:M}));const eA={content:aA,props:Z,staleId:U};u.limit&&u.limit>0&&C>u.limit&&O?Q.push(eA):iJ(Y)?setTimeout(()=>{w(eA)},Y):w(eA)},setProps(b){u=b},setToggle:(b,k)=>{d.get(b).toggle=k},isToastActive:b=>h.some(k=>k===b),getSnapshot:()=>E}})(s,o,$4t);Kd.set(s,a);const g=a.observe(r);return nJ.forEach(c=>Cge(c.content,c.options)),nJ=[],()=>{g(),Kd.delete(s)}},setProps(r){var a;(a=Kd.get(s))==null||a.setProps(r)},getSnapshot(){var r;return(r=Kd.get(s))==null?void 0:r.getSnapshot()}}})(t)).current;i(t);const n=V.useSyncExternalStore(A,e,e);return{getToastToRender:function(o){if(!n)return[];const s=new Map;return t.newestOnTop&&n.reverse(),n.forEach(r=>{const{position:a}=r.props;s.has(a)||s.set(a,[]),s.get(a).push(r)}),Array.from(s,r=>o(r[0],r[1]))},isToastActive:Bge,count:n?.length}}function e3t(t){const[A,e]=V.useState(!1),[i,n]=V.useState(!1),o=V.useRef(null),s=V.useRef({start:0,delta:0,removalDistance:0,canCloseOnClick:!0,canDrag:!1,didMove:!1}).current,{autoClose:r,pauseOnHover:a,closeToast:g,onClick:c,closeOnClick:I}=t;var l,B;function C(){e(!0)}function Q(){e(!1)}function h(d){const p=o.current;s.canDrag&&p&&(s.didMove=!0,A&&Q(),s.delta=t.draggableDirection==="x"?d.clientX-s.start:d.clientY-s.start,s.start!==d.clientX&&(s.canCloseOnClick=!1),p.style.transform=`translate3d(${t.draggableDirection==="x"?`${s.delta}px, var(--y)`:`0, calc(${s.delta}px + var(--y))`},0)`,p.style.opacity=""+(1-Math.abs(s.delta/s.removalDistance)))}function E(){document.removeEventListener("pointermove",h),document.removeEventListener("pointerup",E);const d=o.current;if(s.canDrag&&s.didMove&&d){if(s.canDrag=!1,Math.abs(s.delta)>s.removalDistance)return n(!0),t.closeToast(),void t.collapseAll();d.style.transition="transform 0.2s, opacity 0.2s",d.style.removeProperty("transform"),d.style.removeProperty("opacity")}}(B=Kd.get((l={id:t.toastId,containerId:t.containerId,fn:e}).containerId||1))==null||B.setToggle(l.id,l.fn),V.useEffect(()=>{if(t.pauseOnFocusLoss)return document.hasFocus()||Q(),window.addEventListener("focus",C),window.addEventListener("blur",Q),()=>{window.removeEventListener("focus",C),window.removeEventListener("blur",Q)}},[t.pauseOnFocusLoss]);const u={onPointerDown:function(d){if(t.draggable===!0||t.draggable===d.pointerType){s.didMove=!1,document.addEventListener("pointermove",h),document.addEventListener("pointerup",E);const p=o.current;s.canCloseOnClick=!0,s.canDrag=!0,p.style.transition="none",t.draggableDirection==="x"?(s.start=d.clientX,s.removalDistance=p.offsetWidth*(t.draggablePercent/100)):(s.start=d.clientY,s.removalDistance=p.offsetHeight*(t.draggablePercent===80?1.5*t.draggablePercent:t.draggablePercent)/100)}},onPointerUp:function(d){const{top:p,bottom:m,left:D,right:w}=o.current.getBoundingClientRect();d.nativeEvent.type!=="touchend"&&t.pauseOnHover&&d.clientX>=D&&d.clientX<=w&&d.clientY>=p&&d.clientY<=m?Q():C()}};return r&&a&&(u.onMouseEnter=Q,t.stacked||(u.onMouseLeave=C)),I&&(u.onClick=d=>{c&&c(d),s.canCloseOnClick&&g()}),{playToast:C,pauseToast:Q,isRunning:A,preventExitTransition:i,toastRef:o,eventHandlers:u}}function t3t(t){let{delay:A,isRunning:e,closeToast:i,type:n="default",hide:o,className:s,style:r,controlledProgress:a,progress:g,rtl:c,isIn:I,theme:l}=t;const B=o||a&&g===0,C={...r,animationDuration:`${A}ms`,animationPlayState:e?"running":"paused"};a&&(C.transform=`scaleX(${g})`);const Q=Um("Toastify__progress-bar",a?"Toastify__progress-bar--controlled":"Toastify__progress-bar--animated",`Toastify__progress-bar-theme--${l}`,`Toastify__progress-bar--${n}`,{"Toastify__progress-bar--rtl":c}),h=R0(s)?s({rtl:c,type:n,defaultClassName:Q}):Um(Q,s),E={[a&&g>=1?"onTransitionEnd":"onAnimationEnd"]:a&&g<1?null:()=>{I&&i()}};return tn.createElement("div",{className:"Toastify__progress-bar--wrp","data-hidden":B},tn.createElement("div",{className:`Toastify__progress-bar--bg Toastify__progress-bar-theme--${l} Toastify__progress-bar--${n}`}),tn.createElement("div",{role:"progressbar","aria-hidden":B?"true":"false","aria-label":"notification timer",className:h,style:C,...E}))}let i3t=1;const hge=()=>""+i3t++;function n3t(t){return t&&(wG(t.toastId)||iJ(t.toastId))?t.toastId:hge()}function oJ(t,A){return Cge(t,A),A.toastId}function I9(t,A){return{...A,type:A&&A.type||t,toastId:n3t(A)}}function l9(t){return(A,e)=>oJ(A,I9(t,e))}function Vg(t,A){return oJ(t,I9("default",A))}Vg.loading=(t,A)=>oJ(t,I9("default",{isLoading:!0,autoClose:!1,closeOnClick:!1,closeButton:!1,draggable:!1,...A})),Vg.promise=function(t,A,e){let i,{pending:n,error:o,success:s}=A;n&&(i=wG(n)?Vg.loading(n,e):Vg.loading(n.render,{...e,...n}));const r={isLoading:null,autoClose:null,closeOnClick:null,closeButton:null,draggable:null},a=(c,I,l)=>{if(I==null)return void Vg.dismiss(i);const B={type:c,...r,...e,data:l},C=wG(I)?{render:I}:I;return i?Vg.update(i,{...B,...C}):Vg(C.render,{...B,...C}),l},g=R0(t)?t():t;return g.then(c=>a("success",s,c)).catch(c=>a("error",o,c)),g},Vg.success=l9("success"),Vg.info=l9("info"),Vg.error=l9("error"),Vg.warning=l9("warning"),Vg.warn=Vg.warning,Vg.dark=(t,A)=>oJ(t,I9("default",{theme:"dark",...A})),Vg.dismiss=function(t){(function(A){var e;if(lge()){if(A==null||wG(e=A)||iJ(e))Kd.forEach(i=>{i.removeToast(A)});else if(A&&("containerId"in A||"id"in A)){const i=Kd.get(A.containerId);i?i.removeToast(A.id):Kd.forEach(n=>{n.removeToast(A.id)})}}else nJ=nJ.filter(i=>A!=null&&i.options.toastId!==A)})(t)},Vg.clearWaitingQueue=function(t){t===void 0&&(t={}),Kd.forEach(A=>{!A.props.limit||t.containerId&&A.id!==t.containerId||A.clearQueue()})},Vg.isActive=Bge,Vg.update=function(t,A){A===void 0&&(A={});const e=((i,n)=>{var o;let{containerId:s}=n;return(o=Kd.get(s||1))==null?void 0:o.toasts.get(i)})(t,A);if(e){const{props:i,content:n}=e,o={delay:100,...i,...A,toastId:A.toastId||t,updateId:hge()};o.toastId!==t&&(o.staleId=t);const s=o.render||n;delete o.render,oJ(s,o)}},Vg.done=t=>{Vg.update(t,{progress:1})},Vg.onChange=function(t){return zpA.add(t),()=>{zpA.delete(t)}},Vg.play=t=>Qge(!0,t),Vg.pause=t=>Qge(!1,t);const o3t=typeof window<"u"?V.useLayoutEffect:V.useEffect,B9=t=>{let{theme:A,type:e,isLoading:i,...n}=t;return tn.createElement("svg",{viewBox:"0 0 24 24",width:"100%",height:"100%",fill:A==="colored"?"currentColor":`var(--toastify-icon-color-${e})`,...n})},XpA={info:function(t){return tn.createElement(B9,{...t},tn.createElement("path",{d:"M12 0a12 12 0 1012 12A12.013 12.013 0 0012 0zm.25 5a1.5 1.5 0 11-1.5 1.5 1.5 1.5 0 011.5-1.5zm2.25 13.5h-4a1 1 0 010-2h.75a.25.25 0 00.25-.25v-4.5a.25.25 0 00-.25-.25h-.75a1 1 0 010-2h1a2 2 0 012 2v4.75a.25.25 0 00.25.25h.75a1 1 0 110 2z"}))},warning:function(t){return tn.createElement(B9,{...t},tn.createElement("path",{d:"M23.32 17.191L15.438 2.184C14.728.833 13.416 0 11.996 0c-1.42 0-2.733.833-3.443 2.184L.533 17.448a4.744 4.744 0 000 4.368C1.243 23.167 2.555 24 3.975 24h16.05C22.22 24 24 22.044 24 19.632c0-.904-.251-1.746-.68-2.44zm-9.622 1.46c0 1.033-.724 1.823-1.698 1.823s-1.698-.79-1.698-1.822v-.043c0-1.028.724-1.822 1.698-1.822s1.698.79 1.698 1.822v.043zm.039-12.285l-.84 8.06c-.057.581-.408.943-.897.943-.49 0-.84-.367-.896-.942l-.84-8.065c-.057-.624.25-1.095.779-1.095h1.91c.528.005.84.476.784 1.1z"}))},success:function(t){return tn.createElement(B9,{...t},tn.createElement("path",{d:"M12 0a12 12 0 1012 12A12.014 12.014 0 0012 0zm6.927 8.2l-6.845 9.289a1.011 1.011 0 01-1.43.188l-4.888-3.908a1 1 0 111.25-1.562l4.076 3.261 6.227-8.451a1 1 0 111.61 1.183z"}))},error:function(t){return tn.createElement(B9,{...t},tn.createElement("path",{d:"M11.983 0a12.206 12.206 0 00-8.51 3.653A11.8 11.8 0 000 12.207 11.779 11.779 0 0011.8 24h.214A12.111 12.111 0 0024 11.791 11.766 11.766 0 0011.983 0zM10.5 16.542a1.476 1.476 0 011.449-1.53h.027a1.527 1.527 0 011.523 1.47 1.475 1.475 0 01-1.449 1.53h-.027a1.529 1.529 0 01-1.523-1.47zM11 12.5v-6a1 1 0 012 0v6a1 1 0 11-2 0z"}))},spinner:function(){return tn.createElement("div",{className:"Toastify__spinner"})}},s3t=t=>{const{isRunning:A,preventExitTransition:e,toastRef:i,eventHandlers:n,playToast:o}=e3t(t),{closeButton:s,children:r,autoClose:a,onClick:g,type:c,hideProgressBar:I,closeToast:l,transition:B,position:C,className:Q,style:h,bodyClassName:E,bodyStyle:u,progressClassName:d,progressStyle:p,updateId:m,role:D,progress:w,rtl:b,toastId:k,deleteToast:x,isIn:N,isLoading:M,closeOnClick:U,theme:Y}=t,H=Um("Toastify__toast",`Toastify__toast-theme--${Y}`,`Toastify__toast--${c}`,{"Toastify__toast--rtl":b},{"Toastify__toast--close-on-click":U}),O=R0(Q)?Q({rtl:b,position:C,type:c,defaultClassName:H}):Um(H,Q),Z=(function(eA){let{theme:nA,type:rA,isLoading:lA,icon:pA}=eA,xA=null;const RA={theme:nA,type:rA};return pA===!1||(R0(pA)?xA=pA({...RA,isLoading:lA}):V.isValidElement(pA)?xA=V.cloneElement(pA,RA):lA?xA=XpA.spinner():(YA=>YA in XpA)(rA)&&(xA=XpA[rA](RA))),xA})(t),$=!!w||!a,iA={closeToast:l,type:c,theme:Y};let aA=null;return s===!1||(aA=R0(s)?s(iA):V.isValidElement(s)?V.cloneElement(s,iA):(function(eA){let{closeToast:nA,theme:rA,ariaLabel:lA="close"}=eA;return tn.createElement("button",{className:`Toastify__close-button Toastify__close-button--${rA}`,type:"button",onClick:pA=>{pA.stopPropagation(),nA(pA)},"aria-label":lA},tn.createElement("svg",{"aria-hidden":"true",viewBox:"0 0 14 16"},tn.createElement("path",{fillRule:"evenodd",d:"M7.71 8.23l3.75 3.75-1.48 1.48-3.75-3.75-3.75 3.75L1 11.98l3.75-3.75L1 4.48 2.48 3l3.75 3.75L9.98 3l1.48 1.48-3.75 3.75z"})))})(iA)),tn.createElement(B,{isIn:N,done:x,position:C,preventExitTransition:e,nodeRef:i,playToast:o},tn.createElement("div",{id:k,onClick:g,"data-in":N,className:O,...n,style:h,ref:i},tn.createElement("div",{...N&&{role:D},className:R0(E)?E({type:c}):Um("Toastify__toast-body",E),style:u},Z!=null&&tn.createElement("div",{className:Um("Toastify__toast-icon",{"Toastify--animate-icon Toastify__zoom-enter":!M})},Z),tn.createElement("div",null,r)),aA,tn.createElement(t3t,{...m&&!$?{key:`pb-${m}`}:{},rtl:b,theme:Y,delay:a,isRunning:A,isIn:N,closeToast:l,hide:I,type:c,style:p,className:d,controlledProgress:$,progress:w||0})))},C9=function(t,A){return A===void 0&&(A=!1),{enter:`Toastify--animate Toastify__${t}-enter`,exit:`Toastify--animate Toastify__${t}-exit`,appendPosition:A}},r3t=c9(C9("bounce",!0));c9(C9("slide",!0)),c9(C9("zoom")),c9(C9("flip"));const a3t={position:"top-right",transition:r3t,autoClose:5e3,closeButton:!0,pauseOnHover:!0,pauseOnFocusLoss:!0,draggable:"touch",draggablePercent:80,draggableDirection:"x",role:"alert",theme:"light"};function g3t(t){let A={...a3t,...t};const e=t.stacked,[i,n]=V.useState(!0),o=V.useRef(null),{getToastToRender:s,isToastActive:r,count:a}=A3t(A),{className:g,style:c,rtl:I,containerId:l}=A;function B(Q){const h=Um("Toastify__toast-container",`Toastify__toast-container--${Q}`,{"Toastify__toast-container--rtl":I});return R0(g)?g({position:Q,rtl:I,defaultClassName:h}):Um(h,g9(g))}function C(){e&&(n(!0),Vg.play())}return o3t(()=>{if(e){var Q;const h=o.current.querySelectorAll('[data-in="true"]'),E=12,u=(Q=A.position)==null?void 0:Q.includes("top");let d=0,p=0;Array.from(h).reverse().forEach((m,D)=>{const w=m;w.classList.add("Toastify__toast--stacked"),D>0&&(w.dataset.collapsed=`${i}`),w.dataset.pos||(w.dataset.pos=u?"top":"bot");const b=d*(i?.2:1)+(i?0:E*D);w.style.setProperty("--y",`${u?b:-1*b}px`),w.style.setProperty("--g",`${E}`),w.style.setProperty("--s",""+(1-(i?p:0))),d+=w.offsetHeight,p+=.025})}},[i,a,e]),tn.createElement("div",{ref:o,className:"Toastify",id:l,onMouseEnter:()=>{e&&(n(!1),Vg.pause())},onMouseLeave:C},s((Q,h)=>{const E=h.length?{...c}:{...c,pointerEvents:"none"};return tn.createElement("div",{className:B(Q),style:E,key:`container-${Q}`},h.map(u=>{let{content:d,props:p}=u;return tn.createElement(s3t,{...p,stacked:e,collapseAll:C,isIn:r(p.toastId,p.containerId),style:p.style,key:`toast-${p.key}`},d)}))}))}function c3t(){var t=':root{--toastify-color-light:#fff;--toastify-color-dark:#121212;--toastify-color-info:#3498db;--toastify-color-success:#07bc0c;--toastify-color-warning:#f1c40f;--toastify-color-error:#e74c3c;--toastify-color-transparent:hsla(0,0%,100%,.7);--toastify-icon-color-info:var(--toastify-color-info);--toastify-icon-color-success:var(--toastify-color-success);--toastify-icon-color-warning:var(--toastify-color-warning);--toastify-icon-color-error:var(--toastify-color-error);--toastify-toast-width:320px;--toastify-toast-offset:16px;--toastify-toast-top:max(var(--toastify-toast-offset),env(safe-area-inset-top));--toastify-toast-right:max(var(--toastify-toast-offset),env(safe-area-inset-right));--toastify-toast-left:max(var(--toastify-toast-offset),env(safe-area-inset-left));--toastify-toast-bottom:max(var(--toastify-toast-offset),env(safe-area-inset-bottom));--toastify-toast-background:#fff;--toastify-toast-min-height:64px;--toastify-toast-max-height:800px;--toastify-toast-bd-radius:6px;--toastify-font-family:sans-serif;--toastify-z-index:9999;--toastify-text-color-light:#757575;--toastify-text-color-dark:#fff;--toastify-text-color-info:#fff;--toastify-text-color-success:#fff;--toastify-text-color-warning:#fff;--toastify-text-color-error:#fff;--toastify-spinner-color:#616161;--toastify-spinner-color-empty-area:#e0e0e0;--toastify-color-progress-light:linear-gradient(90deg,#4cd964,#5ac8fa,#007aff,#34aadc,#5856d6,#ff2d55);--toastify-color-progress-dark:#bb86fc;--toastify-color-progress-info:var(--toastify-color-info);--toastify-color-progress-success:var(--toastify-color-success);--toastify-color-progress-warning:var(--toastify-color-warning);--toastify-color-progress-error:var(--toastify-color-error);--toastify-color-progress-bgo:0.2}.Toastify__toast-container{z-index:var(--toastify-z-index);-webkit-transform:translateZ(var(--toastify-z-index));position:fixed;padding:4px;width:var(--toastify-toast-width);box-sizing:border-box;color:#fff}.Toastify__toast-container--top-left{top:var(--toastify-toast-top);left:var(--toastify-toast-left)}.Toastify__toast-container--top-center{top:var(--toastify-toast-top);left:50%;transform:translateX(-50%)}.Toastify__toast-container--top-right{top:var(--toastify-toast-top);right:var(--toastify-toast-right)}.Toastify__toast-container--bottom-left{bottom:var(--toastify-toast-bottom);left:var(--toastify-toast-left)}.Toastify__toast-container--bottom-center{bottom:var(--toastify-toast-bottom);left:50%;transform:translateX(-50%)}.Toastify__toast-container--bottom-right{bottom:var(--toastify-toast-bottom);right:var(--toastify-toast-right)}@media only screen and (max-width:480px){.Toastify__toast-container{width:100vw;padding:0;left:env(safe-area-inset-left);margin:0}.Toastify__toast-container--top-center,.Toastify__toast-container--top-left,.Toastify__toast-container--top-right{top:env(safe-area-inset-top);transform:translateX(0)}.Toastify__toast-container--bottom-center,.Toastify__toast-container--bottom-left,.Toastify__toast-container--bottom-right{bottom:env(safe-area-inset-bottom);transform:translateX(0)}.Toastify__toast-container--rtl{right:env(safe-area-inset-right);left:auto}}.Toastify__toast{--y:0;position:relative;-ms-touch-action:none;touch-action:none;min-height:var(--toastify-toast-min-height);box-sizing:border-box;margin-bottom:1rem;padding:8px;border-radius:var(--toastify-toast-bd-radius);box-shadow:0 4px 12px rgba(0,0,0,.1);display:-ms-flexbox;display:flex;-ms-flex-pack:justify;justify-content:space-between;max-height:var(--toastify-toast-max-height);font-family:var(--toastify-font-family);cursor:default;direction:ltr;z-index:0;overflow:hidden}.Toastify__toast--stacked{position:absolute;width:100%;transform:translate3d(0,var(--y),0) scale(var(--s));transition:transform .3s}.Toastify__toast--stacked[data-collapsed] .Toastify__close-button,.Toastify__toast--stacked[data-collapsed] .Toastify__toast-body{transition:opacity .1s}.Toastify__toast--stacked[data-collapsed=false]{overflow:visible}.Toastify__toast--stacked[data-collapsed=true]:not(:last-child)>*{opacity:0}.Toastify__toast--stacked:after{content:"";position:absolute;left:0;right:0;height:calc(var(--g) * 1px);bottom:100%}.Toastify__toast--stacked[data-pos=top]{top:0}.Toastify__toast--stacked[data-pos=bot]{bottom:0}.Toastify__toast--stacked[data-pos=bot].Toastify__toast--stacked:before{transform-origin:top}.Toastify__toast--stacked[data-pos=top].Toastify__toast--stacked:before{transform-origin:bottom}.Toastify__toast--stacked:before{content:"";position:absolute;left:0;right:0;bottom:0;height:100%;transform:scaleY(3);z-index:-1}.Toastify__toast--rtl{direction:rtl}.Toastify__toast--close-on-click{cursor:pointer}.Toastify__toast-body{margin:auto 0;-ms-flex:1 1 auto;flex:1 1 auto;padding:6px;display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center}.Toastify__toast-body>div:last-child{word-break:break-word;-ms-flex:1;flex:1}.Toastify__toast-icon{-webkit-margin-end:10px;margin-inline-end:10px;width:20px;-ms-flex-negative:0;flex-shrink:0;display:-ms-flexbox;display:flex}.Toastify--animate{animation-fill-mode:both;animation-duration:.5s}.Toastify--animate-icon{animation-fill-mode:both;animation-duration:.3s}@media only screen and (max-width:480px){.Toastify__toast{margin-bottom:0;border-radius:0}}.Toastify__toast-theme--dark{background:var(--toastify-color-dark);color:var(--toastify-text-color-dark)}.Toastify__toast-theme--colored.Toastify__toast--default,.Toastify__toast-theme--light{background:var(--toastify-color-light);color:var(--toastify-text-color-light)}.Toastify__toast-theme--colored.Toastify__toast--info{color:var(--toastify-text-color-info);background:var(--toastify-color-info)}.Toastify__toast-theme--colored.Toastify__toast--success{color:var(--toastify-text-color-success);background:var(--toastify-color-success)}.Toastify__toast-theme--colored.Toastify__toast--warning{color:var(--toastify-text-color-warning);background:var(--toastify-color-warning)}.Toastify__toast-theme--colored.Toastify__toast--error{color:var(--toastify-text-color-error);background:var(--toastify-color-error)}.Toastify__progress-bar-theme--light{background:var(--toastify-color-progress-light)}.Toastify__progress-bar-theme--dark{background:var(--toastify-color-progress-dark)}.Toastify__progress-bar--info{background:var(--toastify-color-progress-info)}.Toastify__progress-bar--success{background:var(--toastify-color-progress-success)}.Toastify__progress-bar--warning{background:var(--toastify-color-progress-warning)}.Toastify__progress-bar--error{background:var(--toastify-color-progress-error)}.Toastify__progress-bar-theme--colored.Toastify__progress-bar--error,.Toastify__progress-bar-theme--colored.Toastify__progress-bar--info,.Toastify__progress-bar-theme--colored.Toastify__progress-bar--success,.Toastify__progress-bar-theme--colored.Toastify__progress-bar--warning{background:var(--toastify-color-transparent)}.Toastify__close-button{color:#fff;background:transparent;outline:none;border:none;padding:0;cursor:pointer;opacity:.7;transition:.3s ease;-ms-flex-item-align:start;align-self:flex-start;z-index:1}.Toastify__close-button--light{color:#000;opacity:.3}.Toastify__close-button>svg{fill:currentColor;height:16px;width:14px}.Toastify__close-button:focus,.Toastify__close-button:hover{opacity:1}@keyframes Toastify__trackProgress{0%{transform:scaleX(1)}to{transform:scaleX(0)}}.Toastify__progress-bar{position:absolute;bottom:0;left:0;width:100%;height:100%;z-index:var(--toastify-z-index);opacity:.7;transform-origin:left;border-bottom-left-radius:var(--toastify-toast-bd-radius)}.Toastify__progress-bar--animated{animation:Toastify__trackProgress linear 1 forwards}.Toastify__progress-bar--controlled{transition:transform .2s}.Toastify__progress-bar--rtl{right:0;left:auto;transform-origin:right;border-bottom-left-radius:0;border-bottom-right-radius:var(--toastify-toast-bd-radius)}.Toastify__progress-bar--wrp{position:absolute;bottom:0;left:0;width:100%;height:5px;border-bottom-left-radius:var(--toastify-toast-bd-radius)}.Toastify__progress-bar--wrp[data-hidden=true]{opacity:0}.Toastify__progress-bar--bg{opacity:var(--toastify-color-progress-bgo);width:100%;height:100%}.Toastify__spinner{width:20px;height:20px;box-sizing:border-box;border:2px solid;border-radius:100%;border-color:var(--toastify-spinner-color-empty-area);border-right-color:var(--toastify-spinner-color);animation:Toastify__spin .65s linear infinite}@keyframes Toastify__bounceInRight{0%,60%,75%,90%,to{animation-timing-function:cubic-bezier(.215,.61,.355,1)}0%{opacity:0;transform:translate3d(3000px,0,0)}60%{opacity:1;transform:translate3d(-25px,0,0)}75%{transform:translate3d(10px,0,0)}90%{transform:translate3d(-5px,0,0)}to{transform:none}}@keyframes Toastify__bounceOutRight{20%{opacity:1;transform:translate3d(-20px,var(--y),0)}to{opacity:0;transform:translate3d(2000px,var(--y),0)}}@keyframes Toastify__bounceInLeft{0%,60%,75%,90%,to{animation-timing-function:cubic-bezier(.215,.61,.355,1)}0%{opacity:0;transform:translate3d(-3000px,0,0)}60%{opacity:1;transform:translate3d(25px,0,0)}75%{transform:translate3d(-10px,0,0)}90%{transform:translate3d(5px,0,0)}to{transform:none}}@keyframes Toastify__bounceOutLeft{20%{opacity:1;transform:translate3d(20px,var(--y),0)}to{opacity:0;transform:translate3d(-2000px,var(--y),0)}}@keyframes Toastify__bounceInUp{0%,60%,75%,90%,to{animation-timing-function:cubic-bezier(.215,.61,.355,1)}0%{opacity:0;transform:translate3d(0,3000px,0)}60%{opacity:1;transform:translate3d(0,-20px,0)}75%{transform:translate3d(0,10px,0)}90%{transform:translate3d(0,-5px,0)}to{transform:translateZ(0)}}@keyframes Toastify__bounceOutUp{20%{transform:translate3d(0,calc(var(--y) - 10px),0)}40%,45%{opacity:1;transform:translate3d(0,calc(var(--y) + 20px),0)}to{opacity:0;transform:translate3d(0,-2000px,0)}}@keyframes Toastify__bounceInDown{0%,60%,75%,90%,to{animation-timing-function:cubic-bezier(.215,.61,.355,1)}0%{opacity:0;transform:translate3d(0,-3000px,0)}60%{opacity:1;transform:translate3d(0,25px,0)}75%{transform:translate3d(0,-10px,0)}90%{transform:translate3d(0,5px,0)}to{transform:none}}@keyframes Toastify__bounceOutDown{20%{transform:translate3d(0,calc(var(--y) - 10px),0)}40%,45%{opacity:1;transform:translate3d(0,calc(var(--y) + 20px),0)}to{opacity:0;transform:translate3d(0,2000px,0)}}.Toastify__bounce-enter--bottom-left,.Toastify__bounce-enter--top-left{animation-name:Toastify__bounceInLeft}.Toastify__bounce-enter--bottom-right,.Toastify__bounce-enter--top-right{animation-name:Toastify__bounceInRight}.Toastify__bounce-enter--top-center{animation-name:Toastify__bounceInDown}.Toastify__bounce-enter--bottom-center{animation-name:Toastify__bounceInUp}.Toastify__bounce-exit--bottom-left,.Toastify__bounce-exit--top-left{animation-name:Toastify__bounceOutLeft}.Toastify__bounce-exit--bottom-right,.Toastify__bounce-exit--top-right{animation-name:Toastify__bounceOutRight}.Toastify__bounce-exit--top-center{animation-name:Toastify__bounceOutUp}.Toastify__bounce-exit--bottom-center{animation-name:Toastify__bounceOutDown}@keyframes Toastify__zoomIn{0%{opacity:0;transform:scale3d(.3,.3,.3)}50%{opacity:1}}@keyframes Toastify__zoomOut{0%{opacity:1}50%{opacity:0;transform:translate3d(0,var(--y),0) scale3d(.3,.3,.3)}to{opacity:0}}.Toastify__zoom-enter{animation-name:Toastify__zoomIn}.Toastify__zoom-exit{animation-name:Toastify__zoomOut}@keyframes Toastify__flipIn{0%{transform:perspective(400px) rotateX(90deg);animation-timing-function:ease-in;opacity:0}40%{transform:perspective(400px) rotateX(-20deg);animation-timing-function:ease-in}60%{transform:perspective(400px) rotateX(10deg);opacity:1}80%{transform:perspective(400px) rotateX(-5deg)}to{transform:perspective(400px)}}@keyframes Toastify__flipOut{0%{transform:translate3d(0,var(--y),0) perspective(400px)}30%{transform:translate3d(0,var(--y),0) perspective(400px) rotateX(-20deg);opacity:1}to{transform:translate3d(0,var(--y),0) perspective(400px) rotateX(90deg);opacity:0}}.Toastify__flip-enter{animation-name:Toastify__flipIn}.Toastify__flip-exit{animation-name:Toastify__flipOut}@keyframes Toastify__slideInRight{0%{transform:translate3d(110%,0,0);visibility:visible}to{transform:translate3d(0,var(--y),0)}}@keyframes Toastify__slideInLeft{0%{transform:translate3d(-110%,0,0);visibility:visible}to{transform:translate3d(0,var(--y),0)}}@keyframes Toastify__slideInUp{0%{transform:translate3d(0,110%,0);visibility:visible}to{transform:translate3d(0,var(--y),0)}}@keyframes Toastify__slideInDown{0%{transform:translate3d(0,-110%,0);visibility:visible}to{transform:translate3d(0,var(--y),0)}}@keyframes Toastify__slideOutRight{0%{transform:translate3d(0,var(--y),0)}to{visibility:hidden;transform:translate3d(110%,var(--y),0)}}@keyframes Toastify__slideOutLeft{0%{transform:translate3d(0,var(--y),0)}to{visibility:hidden;transform:translate3d(-110%,var(--y),0)}}@keyframes Toastify__slideOutDown{0%{transform:translate3d(0,var(--y),0)}to{visibility:hidden;transform:translate3d(0,500px,0)}}@keyframes Toastify__slideOutUp{0%{transform:translate3d(0,var(--y),0)}to{visibility:hidden;transform:translate3d(0,-500px,0)}}.Toastify__slide-enter--bottom-left,.Toastify__slide-enter--top-left{animation-name:Toastify__slideInLeft}.Toastify__slide-enter--bottom-right,.Toastify__slide-enter--top-right{animation-name:Toastify__slideInRight}.Toastify__slide-enter--top-center{animation-name:Toastify__slideInDown}.Toastify__slide-enter--bottom-center{animation-name:Toastify__slideInUp}.Toastify__slide-exit--bottom-left,.Toastify__slide-exit--top-left{animation-name:Toastify__slideOutLeft;animation-timing-function:ease-in;animation-duration:.3s}.Toastify__slide-exit--bottom-right,.Toastify__slide-exit--top-right{animation-name:Toastify__slideOutRight;animation-timing-function:ease-in;animation-duration:.3s}.Toastify__slide-exit--top-center{animation-name:Toastify__slideOutUp;animation-timing-function:ease-in;animation-duration:.3s}.Toastify__slide-exit--bottom-center{animation-name:Toastify__slideOutDown;animation-timing-function:ease-in;animation-duration:.3s}@keyframes Toastify__spin{0%{transform:rotate(0deg)}to{transform:rotate(1turn)}}',A=document.createElement("style");A.innerText=t,document.head.appendChild(A)}var $pA={exports:{}},AfA,Ege;function uge(){return Ege||(Ege=1,AfA={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]}),AfA}var efA={exports:{}},tfA,dge;function I3t(){return dge||(dge=1,tfA=function(A){return!A||typeof A=="string"?!1:A instanceof Array||Array.isArray(A)||A.length>=0&&(A.splice instanceof Function||Object.getOwnPropertyDescriptor(A,A.length-1)&&A.constructor.name!=="String")}),tfA}var pge;function l3t(){if(pge)return efA.exports;pge=1;var t=I3t(),A=Array.prototype.concat,e=Array.prototype.slice,i=efA.exports=function(o){for(var s=[],r=0,a=o.length;r<a;r++){var g=o[r];t(g)?s=A.call(s,e.call(g)):s.push(g)}return s};return i.wrap=function(n){return function(){return n(i(arguments))}},efA.exports}var fge;function B3t(){if(fge)return $pA.exports;fge=1;var t=uge(),A=l3t(),e=Object.hasOwnProperty,i=Object.create(null);for(var n in t)e.call(t,n)&&(i[t[n]]=n);var o=$pA.exports={to:{},get:{}};o.get=function(a){var g=a.substring(0,3).toLowerCase(),c,I;switch(g){case"hsl":c=o.get.hsl(a),I="hsl";break;case"hwb":c=o.get.hwb(a),I="hwb";break;default:c=o.get.rgb(a),I="rgb";break}return c?{model:I,value:c}:null},o.get.rgb=function(a){if(!a)return null;var g=/^#([a-f0-9]{3,4})$/i,c=/^#([a-f0-9]{6})([a-f0-9]{2})?$/i,I=/^rgba?\(\s*([+-]?\d+)(?=[\s,])\s*(?:,\s*)?([+-]?\d+)(?=[\s,])\s*(?:,\s*)?([+-]?\d+)\s*(?:[,|\/]\s*([+-]?[\d\.]+)(%?)\s*)?\)$/,l=/^rgba?\(\s*([+-]?[\d\.]+)\%\s*,?\s*([+-]?[\d\.]+)\%\s*,?\s*([+-]?[\d\.]+)\%\s*(?:[,|\/]\s*([+-]?[\d\.]+)(%?)\s*)?\)$/,B=/^(\w+)$/,C=[0,0,0,1],Q,h,E;if(Q=a.match(c)){for(E=Q[2],Q=Q[1],h=0;h<3;h++){var u=h*2;C[h]=parseInt(Q.slice(u,u+2),16)}E&&(C[3]=parseInt(E,16)/255)}else if(Q=a.match(g)){for(Q=Q[1],E=Q[3],h=0;h<3;h++)C[h]=parseInt(Q[h]+Q[h],16);E&&(C[3]=parseInt(E+E,16)/255)}else if(Q=a.match(I)){for(h=0;h<3;h++)C[h]=parseInt(Q[h+1],0);Q[4]&&(Q[5]?C[3]=parseFloat(Q[4])*.01:C[3]=parseFloat(Q[4]))}else if(Q=a.match(l)){for(h=0;h<3;h++)C[h]=Math.round(parseFloat(Q[h+1])*2.55);Q[4]&&(Q[5]?C[3]=parseFloat(Q[4])*.01:C[3]=parseFloat(Q[4]))}else return(Q=a.match(B))?Q[1]==="transparent"?[0,0,0,0]:e.call(t,Q[1])?(C=t[Q[1]],C[3]=1,C):null:null;for(h=0;h<3;h++)C[h]=s(C[h],0,255);return C[3]=s(C[3],0,1),C},o.get.hsl=function(a){if(!a)return null;var g=/^hsla?\(\s*([+-]?(?:\d{0,3}\.)?\d+)(?:deg)?\s*,?\s*([+-]?[\d\.]+)%\s*,?\s*([+-]?[\d\.]+)%\s*(?:[,|\/]\s*([+-]?(?=\.\d|\d)(?:0|[1-9]\d*)?(?:\.\d*)?(?:[eE][+-]?\d+)?)\s*)?\)$/,c=a.match(g);if(c){var I=parseFloat(c[4]),l=(parseFloat(c[1])%360+360)%360,B=s(parseFloat(c[2]),0,100),C=s(parseFloat(c[3]),0,100),Q=s(isNaN(I)?1:I,0,1);return[l,B,C,Q]}return null},o.get.hwb=function(a){if(!a)return null;var g=/^hwb\(\s*([+-]?\d{0,3}(?:\.\d+)?)(?:deg)?\s*,\s*([+-]?[\d\.]+)%\s*,\s*([+-]?[\d\.]+)%\s*(?:,\s*([+-]?(?=\.\d|\d)(?:0|[1-9]\d*)?(?:\.\d*)?(?:[eE][+-]?\d+)?)\s*)?\)$/,c=a.match(g);if(c){var I=parseFloat(c[4]),l=(parseFloat(c[1])%360+360)%360,B=s(parseFloat(c[2]),0,100),C=s(parseFloat(c[3]),0,100),Q=s(isNaN(I)?1:I,0,1);return[l,B,C,Q]}return null},o.to.hex=function(){var a=A(arguments);return"#"+r(a[0])+r(a[1])+r(a[2])+(a[3]<1?r(Math.round(a[3]*255)):"")},o.to.rgb=function(){var a=A(arguments);return a.length<4||a[3]===1?"rgb("+Math.round(a[0])+", "+Math.round(a[1])+", "+Math.round(a[2])+")":"rgba("+Math.round(a[0])+", "+Math.round(a[1])+", "+Math.round(a[2])+", "+a[3]+")"},o.to.rgb.percent=function(){var a=A(arguments),g=Math.round(a[0]/255*100),c=Math.round(a[1]/255*100),I=Math.round(a[2]/255*100);return a.length<4||a[3]===1?"rgb("+g+"%, "+c+"%, "+I+"%)":"rgba("+g+"%, "+c+"%, "+I+"%, "+a[3]+")"},o.to.hsl=function(){var a=A(arguments);return a.length<4||a[3]===1?"hsl("+a[0]+", "+a[1]+"%, "+a[2]+"%)":"hsla("+a[0]+", "+a[1]+"%, "+a[2]+"%, "+a[3]+")"},o.to.hwb=function(){var a=A(arguments),g="";return a.length>=4&&a[3]!==1&&(g=", "+a[3]),"hwb("+a[0]+", "+a[1]+"%, "+a[2]+"%"+g+")"},o.to.keyword=function(a){return i[a.slice(0,3)]};function s(a,g,c){return Math.min(Math.max(g,a),c)}function r(a){var g=Math.round(a).toString(16).toUpperCase();return g.length<2?"0"+g:g}return $pA.exports}var ifA,yge;function mge(){if(yge)return ifA;yge=1;const t=uge(),A={};for(const n of Object.keys(t))A[t[n]]=n;const e={rgb:{channels:3,labels:"rgb"},hsl:{channels:3,labels:"hsl"},hsv:{channels:3,labels:"hsv"},hwb:{channels:3,labels:"hwb"},cmyk:{channels:4,labels:"cmyk"},xyz:{channels:3,labels:"xyz"},lab:{channels:3,labels:"lab"},lch:{channels:3,labels:"lch"},hex:{channels:1,labels:["hex"]},keyword:{channels:1,labels:["keyword"]},ansi16:{channels:1,labels:["ansi16"]},ansi256:{channels:1,labels:["ansi256"]},hcg:{channels:3,labels:["h","c","g"]},apple:{channels:3,labels:["r16","g16","b16"]},gray:{channels:1,labels:["gray"]}};ifA=e;for(const n of Object.keys(e)){if(!("channels"in e[n]))throw new Error("missing channels property: "+n);if(!("labels"in e[n]))throw new Error("missing channel labels property: "+n);if(e[n].labels.length!==e[n].channels)throw new Error("channel and label counts mismatch: "+n);const{channels:o,labels:s}=e[n];delete e[n].channels,delete e[n].labels,Object.defineProperty(e[n],"channels",{value:o}),Object.defineProperty(e[n],"labels",{value:s})}e.rgb.hsl=function(n){const o=n[0]/255,s=n[1]/255,r=n[2]/255,a=Math.min(o,s,r),g=Math.max(o,s,r),c=g-a;let I,l;g===a?I=0:o===g?I=(s-r)/c:s===g?I=2+(r-o)/c:r===g&&(I=4+(o-s)/c),I=Math.min(I*60,360),I<0&&(I+=360);const B=(a+g)/2;return g===a?l=0:B<=.5?l=c/(g+a):l=c/(2-g-a),[I,l*100,B*100]},e.rgb.hsv=function(n){let o,s,r,a,g;const c=n[0]/255,I=n[1]/255,l=n[2]/255,B=Math.max(c,I,l),C=B-Math.min(c,I,l),Q=function(h){return(B-h)/6/C+1/2};return C===0?(a=0,g=0):(g=C/B,o=Q(c),s=Q(I),r=Q(l),c===B?a=r-s:I===B?a=1/3+o-r:l===B&&(a=2/3+s-o),a<0?a+=1:a>1&&(a-=1)),[a*360,g*100,B*100]},e.rgb.hwb=function(n){const o=n[0],s=n[1];let r=n[2];const a=e.rgb.hsl(n)[0],g=1/255*Math.min(o,Math.min(s,r));return r=1-1/255*Math.max(o,Math.max(s,r)),[a,g*100,r*100]},e.rgb.cmyk=function(n){const o=n[0]/255,s=n[1]/255,r=n[2]/255,a=Math.min(1-o,1-s,1-r),g=(1-o-a)/(1-a)||0,c=(1-s-a)/(1-a)||0,I=(1-r-a)/(1-a)||0;return[g*100,c*100,I*100,a*100]};function i(n,o){return(n[0]-o[0])**2+(n[1]-o[1])**2+(n[2]-o[2])**2}return e.rgb.keyword=function(n){const o=A[n];if(o)return o;let s=1/0,r;for(const a of Object.keys(t)){const g=t[a],c=i(n,g);c<s&&(s=c,r=a)}return r},e.keyword.rgb=function(n){return t[n]},e.rgb.xyz=function(n){let o=n[0]/255,s=n[1]/255,r=n[2]/255;o=o>.04045?((o+.055)/1.055)**2.4:o/12.92,s=s>.04045?((s+.055)/1.055)**2.4:s/12.92,r=r>.04045?((r+.055)/1.055)**2.4:r/12.92;const a=o*.4124+s*.3576+r*.1805,g=o*.2126+s*.7152+r*.0722,c=o*.0193+s*.1192+r*.9505;return[a*100,g*100,c*100]},e.rgb.lab=function(n){const o=e.rgb.xyz(n);let s=o[0],r=o[1],a=o[2];s/=95.047,r/=100,a/=108.883,s=s>.008856?s**(1/3):7.787*s+16/116,r=r>.008856?r**(1/3):7.787*r+16/116,a=a>.008856?a**(1/3):7.787*a+16/116;const g=116*r-16,c=500*(s-r),I=200*(r-a);return[g,c,I]},e.hsl.rgb=function(n){const o=n[0]/360,s=n[1]/100,r=n[2]/100;let a,g,c;if(s===0)return c=r*255,[c,c,c];r<.5?a=r*(1+s):a=r+s-r*s;const I=2*r-a,l=[0,0,0];for(let B=0;B<3;B++)g=o+1/3*-(B-1),g<0&&g++,g>1&&g--,6*g<1?c=I+(a-I)*6*g:2*g<1?c=a:3*g<2?c=I+(a-I)*(2/3-g)*6:c=I,l[B]=c*255;return l},e.hsl.hsv=function(n){const o=n[0];let s=n[1]/100,r=n[2]/100,a=s;const g=Math.max(r,.01);r*=2,s*=r<=1?r:2-r,a*=g<=1?g:2-g;const c=(r+s)/2,I=r===0?2*a/(g+a):2*s/(r+s);return[o,I*100,c*100]},e.hsv.rgb=function(n){const o=n[0]/60,s=n[1]/100;let r=n[2]/100;const a=Math.floor(o)%6,g=o-Math.floor(o),c=255*r*(1-s),I=255*r*(1-s*g),l=255*r*(1-s*(1-g));switch(r*=255,a){case 0:return[r,l,c];case 1:return[I,r,c];case 2:return[c,r,l];case 3:return[c,I,r];case 4:return[l,c,r];case 5:return[r,c,I]}},e.hsv.hsl=function(n){const o=n[0],s=n[1]/100,r=n[2]/100,a=Math.max(r,.01);let g,c;c=(2-s)*r;const I=(2-s)*a;return g=s*a,g/=I<=1?I:2-I,g=g||0,c/=2,[o,g*100,c*100]},e.hwb.rgb=function(n){const o=n[0]/360;let s=n[1]/100,r=n[2]/100;const a=s+r;let g;a>1&&(s/=a,r/=a);const c=Math.floor(6*o),I=1-r;g=6*o-c,(c&1)!==0&&(g=1-g);const l=s+g*(I-s);let B,C,Q;switch(c){default:case 6:case 0:B=I,C=l,Q=s;break;case 1:B=l,C=I,Q=s;break;case 2:B=s,C=I,Q=l;break;case 3:B=s,C=l,Q=I;break;case 4:B=l,C=s,Q=I;break;case 5:B=I,C=s,Q=l;break}return[B*255,C*255,Q*255]},e.cmyk.rgb=function(n){const o=n[0]/100,s=n[1]/100,r=n[2]/100,a=n[3]/100,g=1-Math.min(1,o*(1-a)+a),c=1-Math.min(1,s*(1-a)+a),I=1-Math.min(1,r*(1-a)+a);return[g*255,c*255,I*255]},e.xyz.rgb=function(n){const o=n[0]/100,s=n[1]/100,r=n[2]/100;let a,g,c;return a=o*3.2406+s*-1.5372+r*-.4986,g=o*-.9689+s*1.8758+r*.0415,c=o*.0557+s*-.204+r*1.057,a=a>.0031308?1.055*a**(1/2.4)-.055:a*12.92,g=g>.0031308?1.055*g**(1/2.4)-.055:g*12.92,c=c>.0031308?1.055*c**(1/2.4)-.055:c*12.92,a=Math.min(Math.max(0,a),1),g=Math.min(Math.max(0,g),1),c=Math.min(Math.max(0,c),1),[a*255,g*255,c*255]},e.xyz.lab=function(n){let o=n[0],s=n[1],r=n[2];o/=95.047,s/=100,r/=108.883,o=o>.008856?o**(1/3):7.787*o+16/116,s=s>.008856?s**(1/3):7.787*s+16/116,r=r>.008856?r**(1/3):7.787*r+16/116;const a=116*s-16,g=500*(o-s),c=200*(s-r);return[a,g,c]},e.lab.xyz=function(n){const o=n[0],s=n[1],r=n[2];let a,g,c;g=(o+16)/116,a=s/500+g,c=g-r/200;const I=g**3,l=a**3,B=c**3;return g=I>.008856?I:(g-16/116)/7.787,a=l>.008856?l:(a-16/116)/7.787,c=B>.008856?B:(c-16/116)/7.787,a*=95.047,g*=100,c*=108.883,[a,g,c]},e.lab.lch=function(n){const o=n[0],s=n[1],r=n[2];let a;a=Math.atan2(r,s)*360/2/Math.PI,a<0&&(a+=360);const c=Math.sqrt(s*s+r*r);return[o,c,a]},e.lch.lab=function(n){const o=n[0],s=n[1],a=n[2]/360*2*Math.PI,g=s*Math.cos(a),c=s*Math.sin(a);return[o,g,c]},e.rgb.ansi16=function(n,o=null){const[s,r,a]=n;let g=o===null?e.rgb.hsv(n)[2]:o;if(g=Math.round(g/50),g===0)return 30;let c=30+(Math.round(a/255)<<2|Math.round(r/255)<<1|Math.round(s/255));return g===2&&(c+=60),c},e.hsv.ansi16=function(n){return e.rgb.ansi16(e.hsv.rgb(n),n[2])},e.rgb.ansi256=function(n){const o=n[0],s=n[1],r=n[2];return o===s&&s===r?o<8?16:o>248?231:Math.round((o-8)/247*24)+232:16+36*Math.round(o/255*5)+6*Math.round(s/255*5)+Math.round(r/255*5)},e.ansi16.rgb=function(n){let o=n%10;if(o===0||o===7)return n>50&&(o+=3.5),o=o/10.5*255,[o,o,o];const s=(~~(n>50)+1)*.5,r=(o&1)*s*255,a=(o>>1&1)*s*255,g=(o>>2&1)*s*255;return[r,a,g]},e.ansi256.rgb=function(n){if(n>=232){const g=(n-232)*10+8;return[g,g,g]}n-=16;let o;const s=Math.floor(n/36)/5*255,r=Math.floor((o=n%36)/6)/5*255,a=o%6/5*255;return[s,r,a]},e.rgb.hex=function(n){const s=(((Math.round(n[0])&255)<<16)+((Math.round(n[1])&255)<<8)+(Math.round(n[2])&255)).toString(16).toUpperCase();return"000000".substring(s.length)+s},e.hex.rgb=function(n){const o=n.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i);if(!o)return[0,0,0];let s=o[0];o[0].length===3&&(s=s.split("").map(I=>I+I).join(""));const r=parseInt(s,16),a=r>>16&255,g=r>>8&255,c=r&255;return[a,g,c]},e.rgb.hcg=function(n){const o=n[0]/255,s=n[1]/255,r=n[2]/255,a=Math.max(Math.max(o,s),r),g=Math.min(Math.min(o,s),r),c=a-g;let I,l;return c<1?I=g/(1-c):I=0,c<=0?l=0:a===o?l=(s-r)/c%6:a===s?l=2+(r-o)/c:l=4+(o-s)/c,l/=6,l%=1,[l*360,c*100,I*100]},e.hsl.hcg=function(n){const o=n[1]/100,s=n[2]/100,r=s<.5?2*o*s:2*o*(1-s);let a=0;return r<1&&(a=(s-.5*r)/(1-r)),[n[0],r*100,a*100]},e.hsv.hcg=function(n){const o=n[1]/100,s=n[2]/100,r=o*s;let a=0;return r<1&&(a=(s-r)/(1-r)),[n[0],r*100,a*100]},e.hcg.rgb=function(n){const o=n[0]/360,s=n[1]/100,r=n[2]/100;if(s===0)return[r*255,r*255,r*255];const a=[0,0,0],g=o%1*6,c=g%1,I=1-c;let l=0;switch(Math.floor(g)){case 0:a[0]=1,a[1]=c,a[2]=0;break;case 1:a[0]=I,a[1]=1,a[2]=0;break;case 2:a[0]=0,a[1]=1,a[2]=c;break;case 3:a[0]=0,a[1]=I,a[2]=1;break;case 4:a[0]=c,a[1]=0,a[2]=1;break;default:a[0]=1,a[1]=0,a[2]=I}return l=(1-s)*r,[(s*a[0]+l)*255,(s*a[1]+l)*255,(s*a[2]+l)*255]},e.hcg.hsv=function(n){const o=n[1]/100,s=n[2]/100,r=o+s*(1-o);let a=0;return r>0&&(a=o/r),[n[0],a*100,r*100]},e.hcg.hsl=function(n){const o=n[1]/100,r=n[2]/100*(1-o)+.5*o;let a=0;return r>0&&r<.5?a=o/(2*r):r>=.5&&r<1&&(a=o/(2*(1-r))),[n[0],a*100,r*100]},e.hcg.hwb=function(n){const o=n[1]/100,s=n[2]/100,r=o+s*(1-o);return[n[0],(r-o)*100,(1-r)*100]},e.hwb.hcg=function(n){const o=n[1]/100,r=1-n[2]/100,a=r-o;let g=0;return a<1&&(g=(r-a)/(1-a)),[n[0],a*100,g*100]},e.apple.rgb=function(n){return[n[0]/65535*255,n[1]/65535*255,n[2]/65535*255]},e.rgb.apple=function(n){return[n[0]/255*65535,n[1]/255*65535,n[2]/255*65535]},e.gray.rgb=function(n){return[n[0]/100*255,n[0]/100*255,n[0]/100*255]},e.gray.hsl=function(n){return[0,0,n[0]]},e.gray.hsv=e.gray.hsl,e.gray.hwb=function(n){return[0,100,n[0]]},e.gray.cmyk=function(n){return[0,0,0,n[0]]},e.gray.lab=function(n){return[n[0],0,0]},e.gray.hex=function(n){const o=Math.round(n[0]/100*255)&255,r=((o<<16)+(o<<8)+o).toString(16).toUpperCase();return"000000".substring(r.length)+r},e.rgb.gray=function(n){return[(n[0]+n[1]+n[2])/3/255*100]},ifA}var nfA,wge;function C3t(){if(wge)return nfA;wge=1;const t=mge();function A(){const o={},s=Object.keys(t);for(let r=s.length,a=0;a<r;a++)o[s[a]]={distance:-1,parent:null};return o}function e(o){const s=A(),r=[o];for(s[o].distance=0;r.length;){const a=r.pop(),g=Object.keys(t[a]);for(let c=g.length,I=0;I<c;I++){const l=g[I],B=s[l];B.distance===-1&&(B.distance=s[a].distance+1,B.parent=a,r.unshift(l))}}return s}function i(o,s){return function(r){return s(o(r))}}function n(o,s){const r=[s[o].parent,o];let a=t[s[o].parent][o],g=s[o].parent;for(;s[g].parent;)r.unshift(s[g].parent),a=i(t[s[g].parent][g],a),g=s[g].parent;return a.conversion=r,a}return nfA=function(o){const s=e(o),r={},a=Object.keys(s);for(let g=a.length,c=0;c<g;c++){const I=a[c];s[I].parent!==null&&(r[I]=n(I,s))}return r},nfA}var ofA,Dge;function Q3t(){if(Dge)return ofA;Dge=1;const t=mge(),A=C3t(),e={},i=Object.keys(t);function n(s){const r=function(...a){const g=a[0];return g==null?g:(g.length>1&&(a=g),s(a))};return"conversion"in s&&(r.conversion=s.conversion),r}function o(s){const r=function(...a){const g=a[0];if(g==null)return g;g.length>1&&(a=g);const c=s(a);if(typeof c=="object")for(let I=c.length,l=0;l<I;l++)c[l]=Math.round(c[l]);return c};return"conversion"in s&&(r.conversion=s.conversion),r}return i.forEach(s=>{e[s]={},Object.defineProperty(e[s],"channels",{value:t[s].channels}),Object.defineProperty(e[s],"labels",{value:t[s].labels});const r=A(s);Object.keys(r).forEach(g=>{const c=r[g];e[s][g]=o(c),e[s][g].raw=n(c)})}),ofA=e,ofA}var sfA,Sge;function h3t(){if(Sge)return sfA;Sge=1;const t=B3t(),A=Q3t(),e=["keyword","gray","hex"],i={};for(const l of Object.keys(A))i[[...A[l].labels].sort().join("")]=l;const n={};function o(l,B){if(!(this instanceof o))return new o(l,B);if(B&&B in e&&(B=null),B&&!(B in A))throw new Error("Unknown model: "+B);let C,Q;if(l==null)this.model="rgb",this.color=[0,0,0],this.valpha=1;else if(l instanceof o)this.model=l.model,this.color=[...l.color],this.valpha=l.valpha;else if(typeof l=="string"){const h=t.get(l);if(h===null)throw new Error("Unable to parse color from string: "+l);this.model=h.model,Q=A[this.model].channels,this.color=h.value.slice(0,Q),this.valpha=typeof h.value[Q]=="number"?h.value[Q]:1}else if(l.length>0){this.model=B||"rgb",Q=A[this.model].channels;const h=Array.prototype.slice.call(l,0,Q);this.color=I(h,Q),this.valpha=typeof l[Q]=="number"?l[Q]:1}else if(typeof l=="number")this.model="rgb",this.color=[l>>16&255,l>>8&255,l&255],this.valpha=1;else{this.valpha=1;const h=Object.keys(l);"alpha"in l&&(h.splice(h.indexOf("alpha"),1),this.valpha=typeof l.alpha=="number"?l.alpha:0);const E=h.sort().join("");if(!(E in i))throw new Error("Unable to parse color from object: "+JSON.stringify(l));this.model=i[E];const{labels:u}=A[this.model],d=[];for(C=0;C<u.length;C++)d.push(l[u[C]]);this.color=I(d)}if(n[this.model])for(Q=A[this.model].channels,C=0;C<Q;C++){const h=n[this.model][C];h&&(this.color[C]=h(this.color[C]))}this.valpha=Math.max(0,Math.min(1,this.valpha)),Object.freeze&&Object.freeze(this)}o.prototype={toString(){return this.string()},toJSON(){return this[this.model]()},string(l){let B=this.model in t.to?this:this.rgb();B=B.round(typeof l=="number"?l:1);const C=B.valpha===1?B.color:[...B.color,this.valpha];return t.to[B.model](C)},percentString(l){const B=this.rgb().round(typeof l=="number"?l:1),C=B.valpha===1?B.color:[...B.color,this.valpha];return t.to.rgb.percent(C)},array(){return this.valpha===1?[...this.color]:[...this.color,this.valpha]},object(){const l={},{channels:B}=A[this.model],{labels:C}=A[this.model];for(let Q=0;Q<B;Q++)l[C[Q]]=this.color[Q];return this.valpha!==1&&(l.alpha=this.valpha),l},unitArray(){const l=this.rgb().color;return l[0]/=255,l[1]/=255,l[2]/=255,this.valpha!==1&&l.push(this.valpha),l},unitObject(){const l=this.rgb().object();return l.r/=255,l.g/=255,l.b/=255,this.valpha!==1&&(l.alpha=this.valpha),l},round(l){return l=Math.max(l||0,0),new o([...this.color.map(r(l)),this.valpha],this.model)},alpha(l){return l!==void 0?new o([...this.color,Math.max(0,Math.min(1,l))],this.model):this.valpha},red:a("rgb",0,g(255)),green:a("rgb",1,g(255)),blue:a("rgb",2,g(255)),hue:a(["hsl","hsv","hsl","hwb","hcg"],0,l=>(l%360+360)%360),saturationl:a("hsl",1,g(100)),lightness:a("hsl",2,g(100)),saturationv:a("hsv",1,g(100)),value:a("hsv",2,g(100)),chroma:a("hcg",1,g(100)),gray:a("hcg",2,g(100)),white:a("hwb",1,g(100)),wblack:a("hwb",2,g(100)),cyan:a("cmyk",0,g(100)),magenta:a("cmyk",1,g(100)),yellow:a("cmyk",2,g(100)),black:a("cmyk",3,g(100)),x:a("xyz",0,g(95.047)),y:a("xyz",1,g(100)),z:a("xyz",2,g(108.833)),l:a("lab",0,g(100)),a:a("lab",1),b:a("lab",2),keyword(l){return l!==void 0?new o(l):A[this.model].keyword(this.color)},hex(l){return l!==void 0?new o(l):t.to.hex(this.rgb().round().color)},hexa(l){if(l!==void 0)return new o(l);const B=this.rgb().round().color;let C=Math.round(this.valpha*255).toString(16).toUpperCase();return C.length===1&&(C="0"+C),t.to.hex(B)+C},rgbNumber(){const l=this.rgb().color;return(l[0]&255)<<16|(l[1]&255)<<8|l[2]&255},luminosity(){const l=this.rgb().color,B=[];for(const[C,Q]of l.entries()){const h=Q/255;B[C]=h<=.04045?h/12.92:((h+.055)/1.055)**2.4}return .2126*B[0]+.7152*B[1]+.0722*B[2]},contrast(l){const B=this.luminosity(),C=l.luminosity();return B>C?(B+.05)/(C+.05):(C+.05)/(B+.05)},level(l){const B=this.contrast(l);return B>=7?"AAA":B>=4.5?"AA":""},isDark(){const l=this.rgb().color;return(l[0]*2126+l[1]*7152+l[2]*722)/1e4<128},isLight(){return!this.isDark()},negate(){const l=this.rgb();for(let B=0;B<3;B++)l.color[B]=255-l.color[B];return l},lighten(l){const B=this.hsl();return B.color[2]+=B.color[2]*l,B},darken(l){const B=this.hsl();return B.color[2]-=B.color[2]*l,B},saturate(l){const B=this.hsl();return B.color[1]+=B.color[1]*l,B},desaturate(l){const B=this.hsl();return B.color[1]-=B.color[1]*l,B},whiten(l){const B=this.hwb();return B.color[1]+=B.color[1]*l,B},blacken(l){const B=this.hwb();return B.color[2]+=B.color[2]*l,B},grayscale(){const l=this.rgb().color,B=l[0]*.3+l[1]*.59+l[2]*.11;return o.rgb(B,B,B)},fade(l){return this.alpha(this.valpha-this.valpha*l)},opaquer(l){return this.alpha(this.valpha+this.valpha*l)},rotate(l){const B=this.hsl();let C=B.color[0];return C=(C+l)%360,C=C<0?360+C:C,B.color[0]=C,B},mix(l,B){if(!l||!l.rgb)throw new Error('Argument to "mix" was not a Color instance, but rather an instance of '+typeof l);const C=l.rgb(),Q=this.rgb(),h=B===void 0?.5:B,E=2*h-1,u=C.alpha()-Q.alpha(),d=((E*u===-1?E:(E+u)/(1+E*u))+1)/2,p=1-d;return o.rgb(d*C.red()+p*Q.red(),d*C.green()+p*Q.green(),d*C.blue()+p*Q.blue(),C.alpha()*h+Q.alpha()*(1-h))}};for(const l of Object.keys(A)){if(e.includes(l))continue;const{channels:B}=A[l];o.prototype[l]=function(...C){return this.model===l?new o(this):C.length>0?new o(C,l):new o([...c(A[this.model][l].raw(this.color)),this.valpha],l)},o[l]=function(...C){let Q=C[0];return typeof Q=="number"&&(Q=I(C,B)),new o(Q,l)}}function s(l,B){return Number(l.toFixed(B))}function r(l){return function(B){return s(B,l)}}function a(l,B,C){l=Array.isArray(l)?l:[l];for(const Q of l)(n[Q]||(n[Q]=[]))[B]=C;return l=l[0],function(Q){let h;return Q!==void 0?(C&&(Q=C(Q)),h=this[l](),h.color[B]=Q,h):(h=this[l]().color[B],C&&(h=C(h)),h)}}function g(l){return function(B){return Math.max(0,Math.min(l,B))}}function c(l){return Array.isArray(l)?l:[l]}function I(l,B){for(let C=0;C<B;C++)typeof l[C]!="number"&&(l[C]=0);return l}return sfA=o,sfA}var E3t=h3t();const Ra=g0(E3t);function Bn(t,A){return Array.isArray(A)?[t.a*A[0]+t.c*A[1]+t.e,t.b*A[0]+t.d*A[1]+t.f]:{x:t.a*A.x+t.c*A.y+t.e,y:t.b*A.x+t.d*A.y+t.f}}function u3t(){return{a:1,c:0,e:0,b:0,d:1,f:0}}function rfA(t){return typeof t>"u"}function Q9(t,A=0){return{a:1,c:0,e:t,b:0,d:1,f:A}}function afA(...t){t=Array.isArray(t[0])?t[0]:t;const A=(e,i)=>({a:e.a*i.a+e.c*i.b,c:e.a*i.c+e.c*i.d,e:e.a*i.e+e.c*i.f+e.e,b:e.b*i.a+e.d*i.b,d:e.b*i.c+e.d*i.d,f:e.b*i.e+e.d*i.f+e.f});switch(t.length){case 0:throw new Error("no matrices provided");case 1:return t[0];case 2:return A(t[0],t[1]);default:{const[e,i,...n]=t,o=A(e,i);return afA(o,...n)}}}function d3t(...t){return afA(...t)}function p3t(t,A=void 0,e=void 0,i=void 0){rfA(A)&&(A=t);const n={a:t,c:0,e:0,b:0,d:A,f:0};return rfA(e)||rfA(i)?n:afA([Q9(e,i),n,Q9(-e,-i)])}function h9(t){const{ctx:A,points:e,fill:i,stroke:n,strokeWidth:o=1,realToCanvasMat:s,closePath:r=!1}=t;if(e.length<2)return;A.beginPath();const a=e.map(l=>Bn(s,[l.x,l.y])),g=a[0];if(!g)return;const[c,I]=g;A.moveTo(c,I);for(let l=1;l<a.length;l++){const B=a[l];if(!B)continue;const[C,Q]=B;A.lineTo(C,Q)}if(r&&A.closePath(),i&&(A.fillStyle=i,A.fill()),n){const l=o*Math.abs(s.a);A.strokeStyle=n,A.lineWidth=l,A.stroke()}}function M0(t){const{ctx:A,center:e,width:i,height:n,fill:o,realToCanvasMat:s,borderRadius:r=0,rotation:a=0,stroke:g,strokeWidth:c,isStrokeDashed:I=!1}=t,[l,B]=Bn(s,[e.x,e.y]),C=i*Math.abs(s.a),Q=n*Math.abs(s.a),h=r*Math.abs(s.a),E=c?c*Math.abs(s.a):void 0;if(A.save(),A.translate(l,B),a!==0&&A.rotate(-a*(Math.PI/180)),A.beginPath(),h>0){const u=-C/2,d=-Q/2,p=Math.min(h,C/2,Q/2);A.moveTo(u+p,d),A.lineTo(u+C-p,d),A.arcTo(u+C,d,u+C,d+p,p),A.lineTo(u+C,d+Q-p),A.arcTo(u+C,d+Q,u+C-p,d+Q,p),A.lineTo(u+p,d+Q),A.arcTo(u,d+Q,u,d+Q-p,p),A.lineTo(u,d+p),A.arcTo(u,d,u+p,d,p)}else A.rect(-C/2,-Q/2,C,Q);o&&(A.fillStyle=o,A.fill()),g&&E&&(I?A.setLineDash([E*3,E*2]):A.setLineDash([]),A.strokeStyle=g,A.lineWidth=E,A.stroke()),A.restore()}function f3t(t){const{ctx:A,board:e,realToCanvasMat:i,colorMap:n,drawBoardMaterial:o}=t,{width:s,height:r,center:a,outline:g}=e;if(g&&Array.isArray(g)&&g.length>=3){o&&h9({ctx:A,points:g.map(c=>({x:c.x,y:c.y})),fill:n.substrate,realToCanvasMat:i,closePath:!0}),h9({ctx:A,points:g.map(c=>({x:c.x,y:c.y})),stroke:n.boardOutline,strokeWidth:.1,realToCanvasMat:i,closePath:!0});return}if(s!==void 0&&r!==void 0&&a){o&&M0({ctx:A,center:a,width:s,height:r,fill:n.substrate,realToCanvasMat:i});const c=s/2,I=r/2,l=[{x:a.x-c,y:a.y-I},{x:a.x+c,y:a.y-I},{x:a.x+c,y:a.y+I},{x:a.x-c,y:a.y+I}];h9({ctx:A,points:l,stroke:n.boardOutline,strokeWidth:.1,realToCanvasMat:i,closePath:!0})}}function sJ(t){const{ctx:A,points:e,fill:i,realToCanvasMat:n}=t;if(e.length<3)return;A.beginPath();const o=e.map(g=>Bn(n,[g.x,g.y])),s=o[0];if(!s)return;const[r,a]=s;A.moveTo(r,a);for(let g=1;g<o.length;g++){const c=o[g];if(!c)continue;const[I,l]=c;A.lineTo(I,l)}A.closePath(),A.fillStyle=i,A.fill()}function y3t(t,A){return A.copper[t]??A.copper.top}function m3t(t,A,e,i,n){if(Math.abs(n)<1e-10)return null;const o=e-t,s=i-A,r=Math.hypot(o,s);if(r<1e-10)return null;const a=Math.abs(n)*(r/2),g=r/2,c=(a*a+g*g)/(2*a),I=c-a,l=(t+e)/2,B=(A+i)/2,C=-s/r,Q=o/r,h=n>0?-1:1,E=l+h*C*I,u=B+h*Q*I;return{centerX:E,centerY:u,radius:c}}function gfA(t,A,e,i,n,o,s){if(Math.abs(o)<1e-10){const[p,m]=Bn(s,[i,n]);t.lineTo(p,m);return}const r=m3t(A,e,i,n,o);if(!r){const[p,m]=Bn(s,[i,n]);t.lineTo(p,m);return}const[a,g]=Bn(s,[A,e]),[c,I]=Bn(s,[i,n]),[l,B]=Bn(s,[r.centerX,r.centerY]),C=Math.hypot(a-l,g-B),Q=Math.atan2(g-B,a-l),h=Math.atan2(I-B,c-l),u=s.a*s.d-s.b*s.c<0,d=o>0?!u:u;t.arc(l,B,C,Q,h,d)}function bge(t,A,e){if(A.vertices.length<2)return;if(A.vertices.length===2){const s=A.vertices[0],r=A.vertices[1];if(s&&r&&Math.abs((s.bulge??0)-1)<1e-10&&Math.abs((r.bulge??0)-1)<1e-10){const[a,g]=Bn(e,[s.x,s.y]);t.moveTo(a,g),gfA(t,s.x,s.y,r.x,r.y,1,e),gfA(t,r.x,r.y,s.x,s.y,1,e);return}}const i=A.vertices[0];if(!i)return;const[n,o]=Bn(e,[i.x,i.y]);t.moveTo(n,o);for(let s=0;s<A.vertices.length;s++){const r=A.vertices[s],a=(s+1)%A.vertices.length,g=A.vertices[a];if(!r||!g)continue;const c=r.bulge??0;if(Math.abs(c)<1e-10){const[I,l]=Bn(e,[g.x,g.y]);t.lineTo(I,l)}else gfA(t,r.x,r.y,g.x,g.y,c,e)}}function w3t(t){const{ctx:A,pour:e,realToCanvasMat:i,colorMap:n}=t,o=y3t(e.layer,n);if(A.save(),e.shape==="rect"){const[s,r]=Bn(i,[e.center.x,e.center.y]),a=e.width*Math.abs(i.a),g=e.height*Math.abs(i.a);A.translate(s,r),e.rotation&&A.rotate(-e.rotation*(Math.PI/180)),A.beginPath(),A.rect(-a/2,-g/2,a,g),A.fillStyle=o,A.globalAlpha=.5,A.fill(),A.restore();return}if(e.shape==="polygon"){if(e.points&&e.points.length>=3){const s=e.points.map(c=>Bn(i,[c.x,c.y])),r=s[0];if(!r){A.restore();return}A.beginPath();const[a,g]=r;A.moveTo(a,g);for(let c=1;c<s.length;c++){const I=s[c];if(!I)continue;const[l,B]=I;A.lineTo(l,B)}A.closePath(),A.fillStyle=o,A.globalAlpha=.5,A.fill()}A.restore();return}if(e.shape==="brep"){if(A.beginPath(),bge(A,e.brep_shape.outer_ring,i),e.brep_shape.inner_rings)for(const s of e.brep_shape.inner_rings)bge(A,s,i);A.fillStyle=o,A.globalAlpha=.5,A.fill("evenodd"),A.restore();return}A.restore()}var D3t=.62,S3t=.3,b3t=1,x3t=.13,_3t=1.2;function E9(t,A){const e=A*D3t,i=e*S3t,n=e*b3t,o=Math.max(A*x3t,.35),s=A*_3t,r=t.replace(/\\n/g,`
5386
5386
  `).split(`
5387
- `),a=[];let g=0;for(const I of r){const l=Array.from(I);let B=0;l.forEach((C,Q)=>{B+=C===" "?n:e,Q<l.length-1&&(B+=i)}),a.push(B),B>g&&(g=B)}const c=r.length>1?A+(r.length-1)*s:A;return{width:g,height:c,glyphWidth:e,letterSpacing:i,spaceWidth:n,strokeWidth:o,lineHeight:s,lines:r,lineWidths:a}}function cfA(t,A){const e=A.width+A.strokeWidth,i=A.height+A.strokeWidth;let n=0,o=0;return t==="center"||t==="top_center"||t==="bottom_center"?n=-e/2:t==="top_left"||t==="bottom_left"||t==="center_left"?n=0:t==="top_right"||t==="bottom_right"||t==="center_right"?n=-e:(t==="top_center"||t==="bottom_center")&&(n=-e/2),t==="center"||t==="center_left"||t==="center_right"?o=-i/2:t==="top_left"||t==="top_right"||t==="top_center"?o=0:(t==="bottom_left"||t==="bottom_right"||t==="bottom_center")&&(o=-i),{x:n,y:o}}function IfA(t){const{alignment:A,lineWidth:e,maxWidth:i,strokeWidth:n}=t,o=e+n,s=i+n;return A==="top_left"||A==="bottom_left"||A==="center_left"?0:A==="top_right"||A==="bottom_right"||A==="center_right"?s-o:(s-o)/2}var k3t=t=>rD[t]??rD[t.toUpperCase()];function lfA(t){const{ctx:A,line:e,fontSize:i,startX:n,startY:o,layout:s}=t,{glyphWidth:r,letterSpacing:a,spaceWidth:g,strokeWidth:c}=s,I=i,l=o,B=Array.from(e);let C=n+c/2;B.forEach((Q,h)=>{const E=k3t(Q),u=Q===" "?g:r;if(E?.length){A.beginPath();for(const d of E){const p=C+d.x1*r,m=l+(1-d.y1)*I,D=C+d.x2*r,w=l+(1-d.y2)*I;A.moveTo(p,m),A.lineTo(D,w)}A.stroke()}C+=u,h<B.length-1&&(C+=a)})}function F3t(t){const{ctx:A,text:e,fontSize:i,startX:n,startY:o,anchorAlignment:s="center"}=t,r=E9(e,i),{lines:a,lineWidths:g,lineHeight:c,width:I,strokeWidth:l}=r;a.forEach((B,C)=>{const Q=n+IfA({alignment:s,lineWidth:g[C],maxWidth:I,strokeWidth:l}),h=o+C*c;lfA({ctx:A,line:B,fontSize:i,startX:Q,startY:h,layout:r})})}function BfA(t){const{ctx:A,text:e,x:i,y:n,fontSize:o,color:s,realToCanvasMat:r,anchorAlignment:a,rotation:g=0}=t;if(!e)return;const[c,I]=Bn(r,[i,n]),l=Math.abs(r.a),B=o*l,C=E9(e,B),Q=cfA(a,C);A.save(),A.translate(c,I),g!==0&&A.rotate(-g*(Math.PI/180)),A.lineWidth=C.strokeWidth,A.lineCap="round",A.lineJoin="round",A.strokeStyle=s;const{lines:h,lineWidths:E,lineHeight:u,width:d,strokeWidth:p}=C;h.forEach((m,D)=>{const w=Q.x+IfA({alignment:a,lineWidth:E[D],maxWidth:d,strokeWidth:p}),b=Q.y+D*u;lfA({ctx:A,line:m,fontSize:B,startX:w,startY:b,layout:C})}),A.restore()}var G3t={left:.2,right:.2,top:.2,bottom:.2};function R3t(t){return t?t.includes("left")?"center_left":t.includes("right")?"center_right":"center":"center"}function M3t(t){const{ctx:A,text:e,realToCanvasMat:i,colorMap:n}=t,o=e.text??"";if(!o)return;const[s,r]=Bn(i,[e.anchor_position.x,e.anchor_position.y]),a=Math.abs(i.a),g=(e.font_size??1)*a,c=e.ccw_rotation??0,I={...G3t,...e.knockout_padding},l=n.copper[e.layer]??n.copper.top,B=E9(o,g),C=B.width+B.strokeWidth,Q=R3t(e.anchor_alignment),h=cfA(Q,B);if(A.save(),A.translate(s,r),e.is_mirrored&&A.scale(-1,1),c!==0&&A.rotate(-c*(Math.PI/180)),A.lineWidth=B.strokeWidth,A.lineCap="round",A.lineJoin="round",e.is_knockout){const E=I.left*a,u=I.right*a,d=I.top*a,p=I.bottom*a,m=h.x-E*4,D=h.y-d*4,w=C+E*2+u*2,b=B.height+B.strokeWidth+d*2+p*2;A.fillStyle=l,A.fillRect(m,D,w,b)}else A.strokeStyle=l;F3t({ctx:A,text:o,fontSize:g,startX:h.x,startY:h.y,anchorAlignment:Q}),A.restore()}function FD(t){const{ctx:A,center:e,radius:i,fill:n,realToCanvasMat:o,stroke:s,strokeWidth:r,isStrokeDashed:a=!1}=t,[g,c]=Bn(o,[e.x,e.y]),I=i*Math.abs(o.a),l=r?r*Math.abs(o.a):void 0;A.beginPath(),A.arc(g,c,I,0,Math.PI*2),n&&(A.fillStyle=n,A.fill()),s&&l&&(a?A.setLineDash([l*3,l*2]):A.setLineDash([]),A.strokeStyle=s,A.lineWidth=l,A.stroke())}function N3t(t){const{ctx:A,cutout:e,realToCanvasMat:i,colorMap:n}=t;if(e.shape==="rect"){M0({ctx:A,center:e.center,width:e.width,height:e.height,fill:n.drill,realToCanvasMat:i,rotation:e.rotation??0,borderRadius:e.corner_radius??0});return}if(e.shape==="circle"){FD({ctx:A,center:e.center,radius:e.radius,fill:n.drill,realToCanvasMat:i});return}if(e.shape==="polygon"){e.points&&e.points.length>=3&&sJ({ctx:A,points:e.points,fill:n.drill,realToCanvasMat:i});return}}var v3t=1.5,L3t=.6,U3t=.3;function CfA(t){const A=Math.hypot(t.x,t.y)||1;return{x:t.x/A,y:t.y/A}}function xge(t){const{ctx:A,from:e,to:i,realToCanvasMat:n,color:o,fontSize:s,arrowSize:r=1,strokeWidth:a,text:g,textRotation:c,offset:I}=t,l=CfA({x:i.x-e.x,y:i.y-e.y}),B={x:-l.y,y:l.x},C=I?.direction&&typeof I.direction.x=="number"&&typeof I.direction.y=="number",Q=C?CfA(I.direction):{x:0,y:0},h=I?.distance??0,E={x:Q.x*h,y:Q.y*h},u={x:e.x+E.x,y:e.y+E.y},d={x:i.x+E.x,y:i.y+E.y},p={x:u.x+l.x*r,y:u.y+l.y*r},m={x:d.x-l.x*r,y:d.y-l.y*r};Math.abs(n.a);const D=a??r/5,w=o||"rgba(255,255,255,0.5)",b=C&&(Math.abs(Q.x)>Number.EPSILON||Math.abs(Q.y)>Number.EPSILON)?Q:B,k=h+.5,x=[],N=Y=>{const H={x:Y.x+b.x*k,y:Y.y+b.y*k},O=D/2,Z={x:-b.y,y:b.x};return[{x:Y.x+Z.x*O,y:Y.y+Z.y*O},{x:Y.x-Z.x*O,y:Y.y-Z.y*O},{x:H.x-Z.x*O,y:H.y-Z.y*O},{x:H.x+Z.x*O,y:H.y+Z.y*O}]};x.push(u),x.push({x:p.x+B.x*(r/2),y:p.y+B.y*(r/2)}),x.push({x:p.x+B.x*(D/2),y:p.y+B.y*(D/2)}),x.push({x:m.x+B.x*(D/2),y:m.y+B.y*(D/2)}),x.push({x:m.x+B.x*(r/2),y:m.y+B.y*(r/2)}),x.push(d),x.push({x:m.x-B.x*(r/2),y:m.y-B.y*(r/2)}),x.push({x:m.x-B.x*(D/2),y:m.y-B.y*(D/2)}),x.push({x:p.x-B.x*(D/2),y:p.y-B.y*(D/2)}),x.push({x:p.x-B.x*(r/2),y:p.y-B.y*(r/2)}),x.push(u);const M=x[0],U=Y=>{const H=N(Y);x.push(M),x.push(H[0]),x.push(...H),x.push(H[0]),x.push(M)};if(U(e),U(i),sJ({ctx:A,points:x,fill:w,realToCanvasMat:n}),g){const Y={x:(e.x+i.x)/2+E.x,y:(e.y+i.y)/2+E.y},[H,O]=Bn(n,[u.x,u.y]),[Z,$]=Bn(n,[d.x,d.y]),iA=CfA({x:Z-H,y:$-O});let aA=Math.atan2(iA.y,iA.x)*180/Math.PI;(aA>90||aA<-90)&&(aA+=180);const eA=typeof c=="number"&&Number.isFinite(c)?aA-c:aA;let nA=0;if(g&&typeof c=="number"&&Number.isFinite(c)){const pA=g.length*s*L3t,xA=s,RA=c*Math.PI/180,YA=Math.abs(Math.sin(RA)),CA=Math.abs(Math.cos(RA)),_A=pA/2,dA=xA/2;nA=_A*YA+dA*CA+s*U3t}const rA=r*v3t+nA,lA={x:Y.x+B.x*rA,y:Y.y+B.y*rA};BfA({ctx:A,text:g,x:lA.x,y:lA.y,fontSize:s,color:w,realToCanvasMat:n,anchorAlignment:"center",rotation:-eA})}}var H3t="rgba(255,255,255,0.5)";function Y3t(t){const{ctx:A,pcbFabricationNoteDimension:e,realToCanvasMat:i}=t,n=e.color??H3t;xge({ctx:A,from:e.from,to:e.to,realToCanvasMat:i,color:n,fontSize:e.font_size??1,arrowSize:e.arrow_size??1,text:e.text,textRotation:e.text_ccw_rotation,offset:e.offset_distance&&e.offset_direction?{distance:e.offset_distance,direction:e.offset_direction}:void 0})}function rJ(t){const{ctx:A,start:e,end:i,strokeWidth:n,stroke:o,realToCanvasMat:s,lineCap:r="round"}=t,[a,g]=Bn(s,[e.x,e.y]),[c,I]=Bn(s,[i.x,i.y]),l=n*Math.abs(s.a);A.beginPath(),A.moveTo(a,g),A.lineTo(c,I),A.lineWidth=l,A.strokeStyle=o,A.lineCap=r,A.stroke()}function J3t(t){const{ctx:A,path:e,realToCanvasMat:i}=t,o=e.color??"rgba(255,255,255,0.5)";if(!(!e.route||e.route.length<2))for(let s=0;s<e.route.length-1;s++){const r=e.route[s],a=e.route[s+1];!r||!a||rJ({ctx:A,start:{x:r.x,y:r.y},end:{x:a.x,y:a.y},strokeWidth:e.stroke_width??.1,stroke:o,realToCanvasMat:i})}}function T3t(t){const{ctx:A,rect:e,realToCanvasMat:i}=t,o=e.color??"rgba(255,255,255,0.5)",s=e.is_filled??!1,r=e.has_stroke??!0,a=e.is_stroke_dashed??!1;M0({ctx:A,center:e.center,width:e.width,height:e.height,fill:s?o:void 0,stroke:r?o:void 0,strokeWidth:r?e.stroke_width:void 0,borderRadius:e.corner_radius,realToCanvasMat:i,isStrokeDashed:a})}var K3t="rgba(255,255,255,0.5)";function P3t(t,A){return K3t}function q3t(t){const{ctx:A,text:e,realToCanvasMat:i}=t,n=P3t(e.layer),o=e.color??n,s=e.font_size;BfA({ctx:A,text:e.text,x:e.anchor_position.x,y:e.anchor_position.y,fontSize:s,color:o,realToCanvasMat:i,anchorAlignment:e.anchor_alignment})}function aJ(t){const{ctx:A,center:e,radius_x:i,radius_y:n,fill:o,stroke:s,strokeWidth:r=.1,realToCanvasMat:a,rotation:g=0}=t,[c,I]=Bn(a,[e.x,e.y]),l=i*Math.abs(a.a),B=n*Math.abs(a.a),C=r*Math.abs(a.a);A.save(),A.translate(c,I),g!==0&&A.rotate(-g*(Math.PI/180)),A.beginPath(),A.ellipse(0,0,l,B,0,0,Math.PI*2),o&&(A.fillStyle=o,A.fill()),s&&(A.strokeStyle=s,A.lineWidth=C,A.stroke()),A.restore()}function GD(t){const{ctx:A,center:e,width:i,height:n,fill:o,realToCanvasMat:s,rotation:r=0,stroke:a,strokeWidth:g}=t,[c,I]=Bn(s,[e.x,e.y]),l=i*Math.abs(s.a),B=n*Math.abs(s.a),C=g?g*Math.abs(s.a):void 0;if(A.save(),A.translate(c,I),r!==0&&A.rotate(-r*(Math.PI/180)),A.beginPath(),l>B){const Q=B/2,h=l-B;A.moveTo(-h/2,-Q),A.lineTo(h/2,-Q),A.arc(h/2,0,Q,-Math.PI/2,Math.PI/2),A.lineTo(-h/2,Q),A.arc(-h/2,0,Q,Math.PI/2,-Math.PI/2)}else if(B>l){const Q=l/2,h=B-l;A.moveTo(Q,-h/2),A.lineTo(Q,h/2),A.arc(0,h/2,Q,0,Math.PI),A.lineTo(-Q,-h/2),A.arc(0,-h/2,Q,Math.PI,0)}else A.arc(0,0,l/2,0,Math.PI*2);A.closePath(),o&&(A.fillStyle=o,A.fill()),a&&C&&(A.strokeStyle=a,A.lineWidth=C,A.stroke()),A.restore()}function u9(t){return"ccw_rotation"in t&&typeof t.ccw_rotation=="number"?t.ccw_rotation:0}function O3t(t){const{ctx:A,hole:e,realToCanvasMat:i,colorMap:n,soldermaskMargin:o=0}=t,s=o<0?Math.abs(o):0;if(e.hole_shape==="circle"){FD({ctx:A,center:{x:e.x,y:e.y},radius:e.hole_diameter/2-s,fill:n.drill,realToCanvasMat:i});return}if(e.hole_shape==="square"){const r=u9(e);M0({ctx:A,center:{x:e.x,y:e.y},width:e.hole_diameter-s*2,height:e.hole_diameter-s*2,fill:n.drill,realToCanvasMat:i,rotation:r});return}if(e.hole_shape==="oval"){const r=u9(e);aJ({ctx:A,center:{x:e.x,y:e.y},radius_x:e.hole_width/2-s,radius_y:e.hole_height/2-s,fill:n.drill,realToCanvasMat:i,rotation:r});return}if(e.hole_shape==="rect"){const r=u9(e);M0({ctx:A,center:{x:e.x,y:e.y},width:e.hole_width-s*2,height:e.hole_height-s*2,fill:n.drill,realToCanvasMat:i,rotation:r});return}if(e.hole_shape==="pill"||e.hole_shape==="rotated_pill"){const r=u9(e);GD({ctx:A,center:{x:e.x,y:e.y},width:e.hole_width-s*2,height:e.hole_height-s*2,fill:n.drill,realToCanvasMat:i,rotation:r});return}}function W3t(t,A){const e=parseInt(t.slice(1,3),16),i=parseInt(t.slice(3,5),16),n=parseInt(t.slice(5,7),16);return`rgba(${e}, ${i}, ${n}, ${A})`}function Z3t(t){const{ctx:A,keepout:e,realToCanvasMat:i,colorMap:n}=t,o=n.keepout,s=W3t(n.keepout,.2),r=1;if(e.shape==="rect"){const[a,g]=Bn(i,[e.center.x,e.center.y]),c=e.width*Math.abs(i.a),I=e.height*Math.abs(i.a),l=e.rotation??0;A.save(),A.translate(a,g),l!==0&&A.rotate(-l*(Math.PI/180)),A.beginPath(),A.rect(-c/2,-I/2,c,I),A.fillStyle=s,A.fill(),A.beginPath(),A.rect(-c/2,-I/2,c,I),A.clip();const B=r*Math.abs(i.a),C=Math.sqrt(c*c+I*I),Q=c/2,h=I/2;A.strokeStyle=o,A.lineWidth=.15*Math.abs(i.a),A.setLineDash([]);for(let E=-C;E<C*2;E+=B){A.beginPath();const u=-Q+E,d=-h,p=-Q+E+C,m=-h+C;A.moveTo(u,d),A.lineTo(p,m),A.stroke()}A.restore();return}if(e.shape==="circle"){const[a,g]=Bn(i,[e.center.x,e.center.y]),c=e.radius*Math.abs(i.a),I=r*Math.abs(i.a);A.save(),A.translate(a,g),A.beginPath(),A.arc(0,0,c,0,Math.PI*2),A.fillStyle=s,A.fill(),A.beginPath(),A.arc(0,0,c,0,Math.PI*2),A.clip();const l=c*2;A.strokeStyle=o,A.lineWidth=.15*Math.abs(i.a),A.setLineDash([]);for(let B=-l;B<l*2;B+=I)A.beginPath(),A.moveTo(B-l,-l),A.lineTo(B+l,l),A.stroke();A.restore();return}}var V3t="rgba(255,255,255,0.5)";function j3t(t){const{ctx:A,pcbNoteDimension:e,realToCanvasMat:i}=t,n=e.color??V3t;xge({ctx:A,from:e.from,to:e.to,realToCanvasMat:i,color:n,fontSize:e.font_size,arrowSize:e.arrow_size,text:e.text,textRotation:e.text_ccw_rotation,offset:e.offset_distance&&e.offset_direction?{distance:e.offset_distance,direction:e.offset_direction}:void 0})}function z3t(t){const{ctx:A,line:e,realToCanvasMat:i}=t,o=e.color??"rgb(89, 148, 220)",s=e.stroke_width??.1,r=e.is_dashed??!1,[a,g]=Bn(i,[e.x1,e.y1]),[c,I]=Bn(i,[e.x2,e.y2]),l=s*Math.abs(i.a);A.save(),r?A.setLineDash([l*2,l*2]):A.setLineDash([]),A.beginPath(),A.moveTo(a,g),A.lineTo(c,I),A.lineWidth=l,A.strokeStyle=o,A.lineCap="round",A.stroke(),A.restore()}function X3t(t){const{ctx:A,path:e,realToCanvasMat:i}=t,o=e.color??"rgb(89, 148, 220)";if(!(!e.route||e.route.length<2))for(let s=0;s<e.route.length-1;s++){const r=e.route[s],a=e.route[s+1];!r||!a||rJ({ctx:A,start:{x:r.x,y:r.y},end:{x:a.x,y:a.y},strokeWidth:e.stroke_width??.1,stroke:o,realToCanvasMat:i})}}function $3t(t){const{ctx:A,rect:e,realToCanvasMat:i}=t,o=e.color??"rgb(89, 148, 220)",s=e.is_filled??!1,r=e.has_stroke??!0,a=e.is_stroke_dashed??!1;M0({ctx:A,center:e.center,width:e.width,height:e.height,fill:s?o:void 0,stroke:r?o:void 0,strokeWidth:r?e.stroke_width:void 0,borderRadius:e.corner_radius,realToCanvasMat:i,isStrokeDashed:a})}var AOt="rgb(89, 148, 220)";function eOt(t){const{ctx:A,text:e,realToCanvasMat:i}=t,n=AOt,o=e.color??n,s=e.font_size??1;BfA({ctx:A,text:e.text??"",x:e.anchor_position.x,y:e.anchor_position.y,fontSize:s,color:o,realToCanvasMat:i,anchorAlignment:e.anchor_alignment??"center"})}function tOt(t){const{ctx:A,panel:e,realToCanvasMat:i,colorMap:n,drawBoardMaterial:o}=t,{width:s,height:r,center:a}=e;if(s!==void 0&&r!==void 0&&a){o&&M0({ctx:A,center:a,width:s,height:r,fill:n.substrate,realToCanvasMat:i});const g=s/2,c=r/2,I=[{x:a.x-g,y:a.y-c},{x:a.x+g,y:a.y-c},{x:a.x+g,y:a.y+c},{x:a.x-g,y:a.y+c}];h9({ctx:A,points:I,stroke:n.boardOutline,strokeWidth:.5,realToCanvasMat:i,closePath:!0})}}function gJ(t,A){if(t.length<3||A===0)return t;let e=0,i=0;for(const o of t)e+=o.x,i+=o.y;e/=t.length,i/=t.length;const n=[];for(const o of t){const s=o.x-e,r=o.y-i,a=Math.sqrt(s*s+r*r);if(a>0){const g=s/a,c=r/a;n.push({x:o.x+g*A,y:o.y+c*A})}else n.push({x:o.x+A,y:o.y})}return n}function iOt(t){const{ctx:A,hole:e,realToCanvasMat:i,colorMap:n,soldermaskMargin:o=0,drawSoldermask:s}=t;if(e.is_covered_with_solder_mask===!0&&s)return;const r=n.copper.top,a=o<0?Math.abs(o):0;if(e.shape==="circle"){FD({ctx:A,center:{x:e.x,y:e.y},radius:e.outer_diameter/2-a,fill:r,realToCanvasMat:i}),FD({ctx:A,center:{x:e.x,y:e.y},radius:e.hole_diameter/2,fill:n.drill,realToCanvasMat:i});return}if(e.shape==="oval"){aJ({ctx:A,center:{x:e.x,y:e.y},radius_x:e.outer_width/2-a,radius_y:e.outer_height/2-a,fill:r,realToCanvasMat:i,rotation:e.ccw_rotation}),aJ({ctx:A,center:{x:e.x,y:e.y},radius_x:e.hole_width/2,radius_y:e.hole_height/2,fill:n.drill,realToCanvasMat:i,rotation:e.ccw_rotation});return}if(e.shape==="pill"){GD({ctx:A,center:{x:e.x,y:e.y},width:e.outer_width-a*2,height:e.outer_height-a*2,fill:r,realToCanvasMat:i,rotation:e.ccw_rotation}),GD({ctx:A,center:{x:e.x,y:e.y},width:e.hole_width,height:e.hole_height,fill:n.drill,realToCanvasMat:i,rotation:e.ccw_rotation});return}if(e.shape==="circular_hole_with_rect_pad"){M0({ctx:A,center:{x:e.x,y:e.y},width:e.rect_pad_width-a*2,height:e.rect_pad_height-a*2,fill:r,realToCanvasMat:i,borderRadius:e.rect_border_radius?Math.max(0,e.rect_border_radius-a):0});const g=e.x+(e.hole_offset_x??0),c=e.y+(e.hole_offset_y??0);FD({ctx:A,center:{x:g,y:c},radius:e.hole_diameter/2,fill:n.drill,realToCanvasMat:i});return}if(e.shape==="pill_hole_with_rect_pad"){M0({ctx:A,center:{x:e.x,y:e.y},width:e.rect_pad_width-a*2,height:e.rect_pad_height-a*2,fill:r,realToCanvasMat:i,borderRadius:e.rect_border_radius?Math.max(0,e.rect_border_radius-a):0});const g=e.x+(e.hole_offset_x??0),c=e.y+(e.hole_offset_y??0);GD({ctx:A,center:{x:g,y:c},width:e.hole_width,height:e.hole_height,fill:n.drill,realToCanvasMat:i});return}if(e.shape==="rotated_pill_hole_with_rect_pad"){M0({ctx:A,center:{x:e.x,y:e.y},width:e.rect_pad_width-a*2,height:e.rect_pad_height-a*2,fill:r,realToCanvasMat:i,borderRadius:e.rect_border_radius?Math.max(0,e.rect_border_radius-a):0,rotation:e.rect_ccw_rotation});const g=e.x+(e.hole_offset_x??0),c=e.y+(e.hole_offset_y??0);GD({ctx:A,center:{x:g,y:c},width:e.hole_width,height:e.hole_height,fill:n.drill,realToCanvasMat:i,rotation:e.hole_ccw_rotation});return}if(e.shape==="hole_with_polygon_pad"){const g=e.pad_outline;if(g&&g.length>=3){const B=g.map(Q=>({x:e.x+Q.x,y:e.y+Q.y})),C=a>0?gJ(B,-a):B;C.length>=3&&sJ({ctx:A,points:C,fill:r,realToCanvasMat:i})}const c=e.x+(e.hole_offset_x??0),I=e.y+(e.hole_offset_y??0),l=e.hole_shape;l==="circle"?FD({ctx:A,center:{x:c,y:I},radius:(e.hole_diameter??0)/2,fill:n.drill,realToCanvasMat:i}):l==="oval"?aJ({ctx:A,center:{x:c,y:I},radius_x:(e.hole_width??0)/2,radius_y:(e.hole_height??0)/2,fill:n.drill,realToCanvasMat:i}):l==="pill"?GD({ctx:A,center:{x:c,y:I},width:e.hole_width??0,height:e.hole_height??0,fill:n.drill,realToCanvasMat:i}):l==="rotated_pill"&&GD({ctx:A,center:{x:c,y:I},width:e.hole_width??0,height:e.hole_height??0,fill:n.drill,realToCanvasMat:i});return}}function nOt(t,A){return t==="bottom"?A.silkscreen.bottom:A.silkscreen.top}function oOt(t){const{ctx:A,circle:e,realToCanvasMat:i,colorMap:n}=t,o=nOt(e.layer,n);FD({ctx:A,center:e.center,radius:e.radius,stroke:o,strokeWidth:e.stroke_width,realToCanvasMat:i})}function sOt(t,A){return t==="bottom"?A.silkscreen.bottom:A.silkscreen.top}function rOt(t){const{ctx:A,line:e,realToCanvasMat:i,colorMap:n}=t,o=sOt(e.layer,n);rJ({ctx:A,start:{x:e.x1,y:e.y1},end:{x:e.x2,y:e.y2},strokeWidth:e.stroke_width??.1,stroke:o,realToCanvasMat:i})}function aOt(t,A){return t==="bottom"?A.silkscreen.bottom:A.silkscreen.top}function gOt(t){const{ctx:A,oval:e,realToCanvasMat:i,colorMap:n}=t,o=aOt(e.layer,n);aJ({ctx:A,center:e.center,radius_x:e.radius_x,radius_y:e.radius_y,stroke:o,strokeWidth:.1,realToCanvasMat:i,rotation:e.ccw_rotation??0})}function cOt(t,A){return t==="bottom"?A.silkscreen.bottom:A.silkscreen.top}function IOt(t){const{ctx:A,path:e,realToCanvasMat:i,colorMap:n}=t,o=cOt(e.layer,n);if(!(!e.route||e.route.length<2))for(let s=0;s<e.route.length-1;s++){const r=e.route[s],a=e.route[s+1];!r||!a||rJ({ctx:A,start:{x:r.x,y:r.y},end:{x:a.x,y:a.y},strokeWidth:e.stroke_width??.1,stroke:o,realToCanvasMat:i})}}function lOt(t,A){return t==="bottom"?A.silkscreen.bottom:A.silkscreen.top}function BOt(t){const{ctx:A,pill:e,realToCanvasMat:i,colorMap:n}=t,o=lOt(e.layer,n);GD({ctx:A,center:e.center,width:e.width,height:e.height,stroke:o,strokeWidth:.2,realToCanvasMat:i})}function COt(t,A){return t==="bottom"?A.silkscreen.bottom:A.silkscreen.top}function QOt(t){const{ctx:A,rect:e,realToCanvasMat:i,colorMap:n}=t,o=COt(e.layer,n);M0({ctx:A,center:e.center,width:e.width,height:e.height,fill:e.is_filled?o:"transparent",stroke:o,strokeWidth:e.stroke_width,realToCanvasMat:i})}function hOt(t,A){return t==="bottom"?A.silkscreen.bottom:A.silkscreen.top}function EOt(t){return t||"center"}function uOt(t){const{ctx:A,text:e,realToCanvasMat:i,colorMap:n}=t,o=e.text??"";if(!o)return;const s=hOt(e.layer,n),[r,a]=Bn(i,[e.anchor_position.x,e.anchor_position.y]),g=Math.abs(i.a),c=(e.font_size??1)*g,I=e.ccw_rotation??0,l=E9(o,c),B=EOt(e.anchor_alignment),C=cfA(B,l);A.save(),A.translate(r,a),I!==0&&A.rotate(-I*(Math.PI/180)),e.layer==="bottom"&&A.scale(-1,1),A.lineWidth=l.strokeWidth,A.lineCap="round",A.lineJoin="round",A.strokeStyle=s;const{lines:Q,lineWidths:h,lineHeight:E,width:u,strokeWidth:d}=l;Q.forEach((p,m)=>{const D=C.x+IfA({alignment:B,lineWidth:h[m],maxWidth:u,strokeWidth:d}),w=C.y+m*E;lfA({ctx:A,line:p,fontSize:c,startX:D,startY:w,layout:l})}),A.restore()}function dOt(t,A){return A.copper[t]??A.copper.top}function _ge(t){return t.shape==="rect"||t.shape==="rotated_rect"?t.corner_radius??t.rect_border_radius??0:0}function pOt(t){const{ctx:A,pad:e,realToCanvasMat:i,colorMap:n}=t,o=dOt(e.layer,n);if(e.shape==="rect"){M0({ctx:A,center:{x:e.x,y:e.y},width:e.width,height:e.height,fill:o,realToCanvasMat:i,borderRadius:_ge(e)});return}if(e.shape==="rotated_rect"){M0({ctx:A,center:{x:e.x,y:e.y},width:e.width,height:e.height,fill:o,realToCanvasMat:i,borderRadius:_ge(e),rotation:e.ccw_rotation??0});return}if(e.shape==="circle"){FD({ctx:A,center:{x:e.x,y:e.y},radius:e.radius,fill:o,realToCanvasMat:i});return}if(e.shape==="pill"){GD({ctx:A,center:{x:e.x,y:e.y},width:e.width,height:e.height,fill:o,realToCanvasMat:i});return}if(e.shape==="rotated_pill"){GD({ctx:A,center:{x:e.x,y:e.y},width:e.width,height:e.height,fill:o,realToCanvasMat:i,rotation:e.ccw_rotation??0});return}if(e.shape==="polygon"){e.points&&e.points.length>=3&&sJ({ctx:A,points:e.points,fill:o,realToCanvasMat:i});return}}function P_(t){const{ctx:A,points:e}=t;if(e.length<3)return;const i=e[0];if(i){A.moveTo(i.x,i.y);for(let n=1;n<e.length;n++){const o=e[n];o&&A.lineTo(o.x,o.y)}A.closePath()}}function fOt(t){const{ctx:A,board:e,realToCanvasMat:i,soldermaskColor:n}=t,{width:o,height:s,center:r,outline:a}=e;if(a&&Array.isArray(a)&&a.length>=3){const g=a.map(c=>{const[I,l]=Bn(i,[c.x,c.y]);return{x:I,y:l}});A.beginPath(),P_({ctx:A,points:g}),A.fillStyle=n,A.fill()}else if(o!==void 0&&s!==void 0&&r){const[g,c]=Bn(i,[r.x,r.y]),I=o*Math.abs(i.a),l=s*Math.abs(i.a);A.fillStyle=n,A.fillRect(g-I/2,c-l/2,I,l)}}function q_(t){const{ctx:A,cx:e,cy:i,width:n,height:o,radius:s}=t,r=e-n/2,a=i-o/2,g=Math.min(s,n/2,o/2);g>0?(A.moveTo(r+g,a),A.lineTo(r+n-g,a),A.arcTo(r+n,a,r+n,a+g,g),A.lineTo(r+n,a+o-g),A.arcTo(r+n,a+o,r+n-g,a+o,g),A.lineTo(r+g,a+o),A.arcTo(r,a+o,r,a+o-g,g),A.lineTo(r,a+g),A.arcTo(r,a,r+g,a,g)):A.rect(r,a,n,o),A.closePath()}function yOt(t){const{ctx:A,cutout:e,realToCanvasMat:i,colorMap:n}=t;if(A.fillStyle=n.drill,e.shape==="rect"){const[o,s]=Bn(i,[e.center?.x??0,e.center?.y??0]),r=e.width*Math.abs(i.a),a=e.height*Math.abs(i.a),g=(e.corner_radius??0)*Math.abs(i.a);A.save(),A.translate(o,s),e.rotation&&A.rotate(-e.rotation*Math.PI/180),A.beginPath(),q_({ctx:A,cx:0,cy:0,width:r,height:a,radius:g}),A.restore(),A.fill()}else if(e.shape==="circle"){const[o,s]=Bn(i,[e.center?.x??0,e.center?.y??0]),r=e.radius*Math.abs(i.a);A.beginPath(),A.arc(o,s,r,0,Math.PI*2),A.closePath(),A.fill()}else if(e.shape==="polygon"&&e.points&&e.points.length>=3){const o=e.points.map(s=>{const[r,a]=Bn(i,[s.x,s.y]);return{x:r,y:a}});A.beginPath(),P_({ctx:A,points:o}),A.fill()}}function yb(t){const{ctx:A,cx:e,cy:i,width:n,height:o}=t;if(n>o){const s=o/2,r=n-o;A.moveTo(e-r/2,i-s),A.lineTo(e+r/2,i-s),A.arc(e+r/2,i,s,-Math.PI/2,Math.PI/2),A.lineTo(e-r/2,i+s),A.arc(e-r/2,i,s,Math.PI/2,-Math.PI/2)}else if(o>n){const s=n/2,r=o-n;A.moveTo(e+s,i-r/2),A.lineTo(e+s,i+r/2),A.arc(e,i+r/2,s,0,Math.PI),A.lineTo(e-s,i-r/2),A.arc(e,i-r/2,s,Math.PI,0)}else A.arc(e,i,n/2,0,Math.PI*2);A.closePath()}function mOt(t){const{ctx:A,hole:e,realToCanvasMat:i,colorMap:n,soldermaskOverCopperColor:o,drawSoldermask:s}=t,r=s&&e.is_covered_with_solder_mask===!0,a=s?e.soldermask_margin??0:0;r?(A.fillStyle=o,cJ({ctx:A,hole:e,realToCanvasMat:i,margin:0}),A.fill()):a<0?(A.fillStyle=n.drill,cJ({ctx:A,hole:e,realToCanvasMat:i,margin:0}),A.fill(),wOt({ctx:A,hole:e,realToCanvasMat:i,soldermaskOverCopperColor:o,margin:a})):a>0?(A.fillStyle=n.substrate,cJ({ctx:A,hole:e,realToCanvasMat:i,margin:a}),A.fill(),A.fillStyle=n.drill,cJ({ctx:A,hole:e,realToCanvasMat:i,margin:0}),A.fill()):(A.fillStyle=n.drill,cJ({ctx:A,hole:e,realToCanvasMat:i,margin:0}),A.fill())}function kge(t){return"ccw_rotation"in t&&typeof t.ccw_rotation=="number"?t.ccw_rotation:0}function cJ(t){const{ctx:A,hole:e,realToCanvasMat:i,margin:n}=t,o=kge(e);if(e.hole_shape==="circle"){const[s,r]=Bn(i,[e.x,e.y]),a=(e.hole_diameter/2+n)*Math.abs(i.a);A.beginPath(),A.arc(s,r,a,0,Math.PI*2),A.closePath()}else if(e.hole_shape==="square"){const[s,r]=Bn(i,[e.x,e.y]),a=(e.hole_diameter+n*2)*Math.abs(i.a);A.save(),A.translate(s,r),o!==0&&A.rotate(-o*Math.PI/180),A.beginPath(),A.rect(-a/2,-a/2,a,a),A.closePath(),A.restore()}else if(e.hole_shape==="oval"){const[s,r]=Bn(i,[e.x,e.y]),a=(e.hole_width/2+n)*Math.abs(i.a),g=(e.hole_height/2+n)*Math.abs(i.a);A.save(),A.translate(s,r),o!==0&&A.rotate(-o*Math.PI/180),A.beginPath(),A.ellipse(0,0,a,g,0,0,Math.PI*2),A.closePath(),A.restore()}else if(e.hole_shape==="rect"){const[s,r]=Bn(i,[e.x,e.y]),a=(e.hole_width+n*2)*Math.abs(i.a),g=(e.hole_height+n*2)*Math.abs(i.a);A.save(),A.translate(s,r),o!==0&&A.rotate(-o*Math.PI/180),A.beginPath(),A.rect(-a/2,-g/2,a,g),A.closePath(),A.restore()}else if(e.hole_shape==="pill"||e.hole_shape==="rotated_pill"){const[s,r]=Bn(i,[e.x,e.y]),a=(e.hole_width+n*2)*Math.abs(i.a),g=(e.hole_height+n*2)*Math.abs(i.a);A.save(),A.translate(s,r),o!==0&&A.rotate(-o*Math.PI/180),A.beginPath(),yb({ctx:A,cx:0,cy:0,width:a,height:g}),A.restore()}}function wOt(t){const{ctx:A,hole:e,realToCanvasMat:i,soldermaskOverCopperColor:n,margin:o}=t,s=Math.abs(o),r=kge(e);if(A.fillStyle=n,e.hole_shape==="circle"){const[a,g]=Bn(i,[e.x,e.y]),c=e.hole_diameter/2*Math.abs(i.a),I=s*Math.abs(i.a),l=Math.max(0,c-I);A.save(),A.beginPath(),A.arc(a,g,c,0,Math.PI*2),l>0&&A.arc(a,g,l,0,Math.PI*2,!0),A.fill("evenodd"),A.restore()}else if(e.hole_shape==="square"){const[a,g]=Bn(i,[e.x,e.y]),c=e.hole_diameter*Math.abs(i.a),I=s*Math.abs(i.a),l=Math.max(0,c-I*2);A.save(),A.translate(a,g),r!==0&&A.rotate(-r*Math.PI/180),A.beginPath(),A.rect(-c/2,-c/2,c,c),l>0&&A.rect(-l/2,-l/2,l,l),A.fill("evenodd"),A.restore()}else if(e.hole_shape==="oval"){const[a,g]=Bn(i,[e.x,e.y]),c=e.hole_width/2*Math.abs(i.a),I=e.hole_height/2*Math.abs(i.a),l=s*Math.abs(i.a),B=Math.max(0,c-l),C=Math.max(0,I-l);A.save(),A.translate(a,g),r!==0&&A.rotate(-r*Math.PI/180),A.beginPath(),A.ellipse(0,0,c,I,0,0,Math.PI*2),B>0&&C>0&&(A.moveTo(B,0),A.ellipse(0,0,B,C,0,0,Math.PI*2)),A.fill("evenodd"),A.restore()}else if(e.hole_shape==="rect"){const[a,g]=Bn(i,[e.x,e.y]),c=e.hole_width*Math.abs(i.a),I=e.hole_height*Math.abs(i.a),l=s*Math.abs(i.a),B=Math.max(0,c-l*2),C=Math.max(0,I-l*2);A.save(),A.translate(a,g),r!==0&&A.rotate(-r*Math.PI/180),A.beginPath(),A.rect(-c/2,-I/2,c,I),B>0&&C>0&&A.rect(-B/2,-C/2,B,C),A.fill("evenodd"),A.restore()}else if(e.hole_shape==="pill"||e.hole_shape==="rotated_pill"){const[a,g]=Bn(i,[e.x,e.y]),c=e.hole_width*Math.abs(i.a),I=e.hole_height*Math.abs(i.a),l=s*Math.abs(i.a);A.save(),A.translate(a,g),r!==0&&A.rotate(-r*Math.PI/180),A.beginPath(),yb({ctx:A,cx:0,cy:0,width:c,height:I});const B=c-l*2,C=I-l*2;B>0&&C>0&&yb({ctx:A,cx:0,cy:0,width:B,height:C}),A.fill("evenodd"),A.restore()}}function DOt(t){const{ctx:A,hole:e,realToCanvasMat:i,colorMap:n,soldermaskOverCopperColor:o,layer:s,drawSoldermask:r}=t;if(e.layers&&!e.layers.includes(s))return;const a=r&&e.is_covered_with_solder_mask===!0,g=r?e.soldermask_margin??0:0,c=n.copper.top;a?(A.fillStyle=o,IJ({ctx:A,hole:e,realToCanvasMat:i,margin:0}),A.fill()):g<0?(A.fillStyle=c,IJ({ctx:A,hole:e,realToCanvasMat:i,margin:0}),A.fill(),SOt({ctx:A,hole:e,realToCanvasMat:i,soldermaskOverCopperColor:o,margin:g})):g>0?(A.fillStyle=n.substrate,IJ({ctx:A,hole:e,realToCanvasMat:i,margin:g}),A.fill(),A.fillStyle=c,IJ({ctx:A,hole:e,realToCanvasMat:i,margin:0}),A.fill()):(A.fillStyle=c,IJ({ctx:A,hole:e,realToCanvasMat:i,margin:0}),A.fill())}function IJ(t){const{ctx:A,hole:e,realToCanvasMat:i,margin:n}=t;if(e.shape==="circle"){const[o,s]=Bn(i,[e.x,e.y]),r=(e.outer_diameter/2+n)*Math.abs(i.a);A.beginPath(),A.arc(o,s,r,0,Math.PI*2),A.closePath()}else if(e.shape==="oval"){const[o,s]=Bn(i,[e.x,e.y]),r=(e.outer_width/2+n)*Math.abs(i.a),a=(e.outer_height/2+n)*Math.abs(i.a);A.save(),A.translate(o,s),e.ccw_rotation&&e.ccw_rotation!==0&&A.rotate(-(e.ccw_rotation*Math.PI)/180),A.beginPath(),A.ellipse(0,0,r,a,0,0,Math.PI*2),A.closePath(),A.restore()}else if(e.shape==="pill"){const[o,s]=Bn(i,[e.x,e.y]),r=(e.outer_width+n*2)*Math.abs(i.a),a=(e.outer_height+n*2)*Math.abs(i.a);A.save(),A.translate(o,s),e.ccw_rotation&&e.ccw_rotation!==0&&A.rotate(-(e.ccw_rotation*Math.PI)/180),A.beginPath(),yb({ctx:A,cx:0,cy:0,width:r,height:a}),A.restore()}else if(e.shape==="circular_hole_with_rect_pad"||e.shape==="pill_hole_with_rect_pad"){const[o,s]=Bn(i,[e.x,e.y]),r=(e.rect_pad_width+n*2)*Math.abs(i.a),a=(e.rect_pad_height+n*2)*Math.abs(i.a),g=(e.rect_border_radius??0)*Math.abs(i.a);A.beginPath(),q_({ctx:A,cx:o,cy:s,width:r,height:a,radius:g})}else if(e.shape==="rotated_pill_hole_with_rect_pad"){const[o,s]=Bn(i,[e.x,e.y]),r=(e.rect_pad_width+n*2)*Math.abs(i.a),a=(e.rect_pad_height+n*2)*Math.abs(i.a),g=(e.rect_border_radius??0)*Math.abs(i.a);A.save(),A.translate(o,s),e.rect_ccw_rotation&&A.rotate(-e.rect_ccw_rotation*Math.PI/180),A.beginPath(),q_({ctx:A,cx:0,cy:0,width:r,height:a,radius:g}),A.restore()}else if(e.shape==="hole_with_polygon_pad"&&e.pad_outline&&e.pad_outline.length>=3){const o=e.pad_outline.map(a=>({x:e.x+a.x,y:e.y+a.y})),r=(n!==0?gJ(o,n):o).map(a=>{const[g,c]=Bn(i,[a.x,a.y]);return{x:g,y:c}});A.beginPath(),P_({ctx:A,points:r})}}function SOt(t){const{ctx:A,hole:e,realToCanvasMat:i,soldermaskOverCopperColor:n,margin:o}=t,s=Math.abs(o);if(A.fillStyle=n,e.shape==="circle"){const[r,a]=Bn(i,[e.x,e.y]),g=e.outer_diameter/2*Math.abs(i.a),c=s*Math.abs(i.a),I=Math.max(0,g-c);A.save(),A.beginPath(),A.arc(r,a,g,0,Math.PI*2),I>0&&A.arc(r,a,I,0,Math.PI*2,!0),A.fill("evenodd"),A.restore()}else if(e.shape==="oval"){const[r,a]=Bn(i,[e.x,e.y]),g=e.outer_width/2*Math.abs(i.a),c=e.outer_height/2*Math.abs(i.a),I=s*Math.abs(i.a),l=Math.max(0,g-I),B=Math.max(0,c-I);A.save(),A.translate(r,a),e.ccw_rotation&&e.ccw_rotation!==0&&A.rotate(-(e.ccw_rotation*Math.PI)/180),A.beginPath(),A.ellipse(0,0,g,c,0,0,Math.PI*2),l>0&&B>0&&(A.moveTo(l,0),A.ellipse(0,0,l,B,0,0,Math.PI*2)),A.fill("evenodd"),A.restore()}else if(e.shape==="pill"){const[r,a]=Bn(i,[e.x,e.y]),g=e.outer_width*Math.abs(i.a),c=e.outer_height*Math.abs(i.a),I=s*Math.abs(i.a);A.save(),A.translate(r,a),e.ccw_rotation&&e.ccw_rotation!==0&&A.rotate(-(e.ccw_rotation*Math.PI)/180),A.beginPath(),yb({ctx:A,cx:0,cy:0,width:g,height:c});const l=g-I*2,B=c-I*2;l>0&&B>0&&yb({ctx:A,cx:0,cy:0,width:l,height:B}),A.fill("evenodd"),A.restore()}else if(e.shape==="circular_hole_with_rect_pad"||e.shape==="pill_hole_with_rect_pad"||e.shape==="rotated_pill_hole_with_rect_pad"){const[r,a]=Bn(i,[e.x,e.y]),g=e.rect_pad_width*Math.abs(i.a),c=e.rect_pad_height*Math.abs(i.a),I=s*Math.abs(i.a);A.save(),A.translate(r,a),e.shape==="rotated_pill_hole_with_rect_pad"&&e.rect_ccw_rotation&&A.rotate(-e.rect_ccw_rotation*Math.PI/180);const l=e.rect_border_radius?e.rect_border_radius*Math.abs(i.a):0;A.beginPath(),q_({ctx:A,cx:0,cy:0,width:g,height:c,radius:l});const B=g-I*2,C=c-I*2;if(B>0&&C>0){const Q=Math.max(0,l-I);q_({ctx:A,cx:0,cy:0,width:B,height:C,radius:Q})}A.fill("evenodd"),A.restore()}else if(e.shape==="hole_with_polygon_pad"&&e.pad_outline&&e.pad_outline.length>=3){const r=e.pad_outline.map(c=>({x:e.x+c.x,y:e.y+c.y}));A.save(),A.beginPath();const a=r.map(c=>{const[I,l]=Bn(i,[c.x,c.y]);return{x:I,y:l}});P_({ctx:A,points:a});const g=gJ(r,-s);if(g.length>=3){const c=g.map(I=>{const[l,B]=Bn(i,[I.x,I.y]);return{x:l,y:B}});P_({ctx:A,points:c})}A.fill("evenodd"),A.restore()}}function bOt(t){const{ctx:A,pad:e,realToCanvasMat:i,colorMap:n,soldermaskOverCopperColor:o,layer:s,drawSoldermask:r}=t;if(e.layer!==s)return;const a=r&&e.is_covered_with_solder_mask===!0,g=r?e.soldermask_margin??0:0;let c=g,I=g,l=g,B=g;(e.shape==="rect"||e.shape==="rotated_rect")&&(c=e.soldermask_margin_left??g,I=e.soldermask_margin_right??g,l=e.soldermask_margin_top??g,B=e.soldermask_margin_bottom??g);const C=n.copper[e.layer]||n.copper.top;a?(A.fillStyle=o,lJ({ctx:A,pad:e,realToCanvasMat:i,ml:0,mr:0,mt:0,mb:0}),A.fill()):c<0||I<0||l<0||B<0?(A.fillStyle=C,lJ({ctx:A,pad:e,realToCanvasMat:i,ml:0,mr:0,mt:0,mb:0}),A.fill(),xOt({ctx:A,pad:e,realToCanvasMat:i,soldermaskOverCopperColor:o,ml:c,mr:I,mt:l,mb:B})):c>0||I>0||l>0||B>0?(A.fillStyle=n.substrate,lJ({ctx:A,pad:e,realToCanvasMat:i,ml:c,mr:I,mt:l,mb:B}),A.fill(),A.fillStyle=C,lJ({ctx:A,pad:e,realToCanvasMat:i,ml:0,mr:0,mt:0,mb:0}),A.fill()):(A.fillStyle=C,lJ({ctx:A,pad:e,realToCanvasMat:i,ml:0,mr:0,mt:0,mb:0}),A.fill())}function lJ(t){const{ctx:A,pad:e,realToCanvasMat:i,ml:n,mr:o,mt:s,mb:r}=t,a=e.shape==="rotated_rect"||e.shape==="rotated_pill"?e.ccw_rotation??0:0;if(e.shape==="rect"||e.shape==="rotated_rect"){const g=e.corner_radius??e.rect_border_radius??0,c=a*Math.PI/180,I=(o-n)/2,l=(s-r)/2,B=I*Math.cos(c)-l*Math.sin(c),C=I*Math.sin(c)+l*Math.cos(c),[Q,h]=Bn(i,[e.x+B,e.y+C]),E=(e.width+n+o)*Math.abs(i.a),u=(e.height+s+r)*Math.abs(i.a),d=g*Math.abs(i.a);A.save(),A.translate(Q,h),a!==0&&A.rotate(-a*Math.PI/180),A.beginPath(),q_({ctx:A,cx:0,cy:0,width:E,height:u,radius:d}),A.restore()}else if(e.shape==="circle"){const g=(n+o+s+r)/4,[c,I]=Bn(i,[e.x,e.y]),l=(e.radius+g)*Math.abs(i.a);A.beginPath(),A.arc(c,I,l,0,Math.PI*2),A.closePath()}else if(e.shape==="pill"||e.shape==="rotated_pill"){const g=(n+o)/2,[c,I]=Bn(i,[e.x,e.y]),l=(e.width+g*2)*Math.abs(i.a),B=(e.height+g*2)*Math.abs(i.a);A.save(),A.translate(c,I),a!==0&&A.rotate(-a*Math.PI/180),A.beginPath(),yb({ctx:A,cx:0,cy:0,width:l,height:B}),A.restore()}else if(e.shape==="polygon"&&e.points&&e.points.length>=3){const g=(n+o+s+r)/4,I=(g!==0?gJ(e.points,g):e.points).map(l=>{const[B,C]=Bn(i,[l.x,l.y]);return{x:B,y:C}});A.beginPath(),P_({ctx:A,points:I})}}function xOt(t){const{ctx:A,pad:e,realToCanvasMat:i,soldermaskOverCopperColor:n,ml:o,mr:s,mt:r,mb:a}=t,g=e.shape==="rotated_rect"||e.shape==="rotated_pill"?e.ccw_rotation??0:0,c=Math.max(0,-o),I=Math.max(0,-s),l=Math.max(0,-r),B=Math.max(0,-a);if(A.fillStyle=n,e.shape==="rect"||e.shape==="rotated_rect"){const C=e.corner_radius??e.rect_border_radius??0,[Q,h]=Bn(i,[e.x,e.y]),E=e.width*Math.abs(i.a),u=e.height*Math.abs(i.a),d=C*Math.abs(i.a),p=c*Math.abs(i.a),m=I*Math.abs(i.a),D=l*Math.abs(i.a),w=B*Math.abs(i.a);A.save(),A.translate(Q,h),g!==0&&A.rotate(-g*Math.PI/180),A.beginPath(),q_({ctx:A,cx:0,cy:0,width:E,height:u,radius:d});const b=E-p-m,k=u-D-w,x=(p-m)/2,N=(D-w)/2,M=Math.max(0,d-(p+m+D+w)/4);b>0&&k>0&&q_({ctx:A,cx:x,cy:N,width:b,height:k,radius:M}),A.fill("evenodd"),A.restore()}else if(e.shape==="circle"){const C=Math.max(c,I,l,B),[Q,h]=Bn(i,[e.x,e.y]),E=e.radius*Math.abs(i.a),u=C*Math.abs(i.a),d=Math.max(0,E-u);A.save(),A.beginPath(),A.arc(Q,h,E,0,Math.PI*2),d>0&&A.arc(Q,h,d,0,Math.PI*2,!0),A.fill("evenodd"),A.restore()}else if(e.shape==="pill"||e.shape==="rotated_pill"){const C=Math.max(c,I,l,B),[Q,h]=Bn(i,[e.x,e.y]),E=e.width*Math.abs(i.a),u=e.height*Math.abs(i.a),d=C*Math.abs(i.a);A.save(),A.translate(Q,h),g!==0&&A.rotate(-g*Math.PI/180),A.beginPath(),yb({ctx:A,cx:0,cy:0,width:E,height:u});const p=E-d*2,m=u-d*2;p>0&&m>0&&yb({ctx:A,cx:0,cy:0,width:p,height:m}),A.fill("evenodd"),A.restore()}else if(e.shape==="polygon"&&e.points&&e.points.length>=3){const C=Math.max(c,I,l,B);A.save(),A.beginPath();const Q=e.points.map(E=>{const[u,d]=Bn(i,[E.x,E.y]);return{x:u,y:d}});P_({ctx:A,points:Q});const h=gJ(e.points,-C);if(h.length>=3){const E=h.map(u=>{const[d,p]=Bn(i,[u.x,u.y]);return{x:d,y:p}});P_({ctx:A,points:E})}A.fill("evenodd"),A.restore()}}function _Ot(t){const{ctx:A,via:e,realToCanvasMat:i,colorMap:n}=t,[o,s]=Bn(i,[e.x,e.y]),r=e.outer_diameter/2*Math.abs(i.a);A.fillStyle=n.substrate,A.beginPath(),A.arc(o,s,r,0,Math.PI*2),A.closePath(),A.fill()}function kOt(t){const{ctx:A,board:e,elements:i,realToCanvasMat:n,colorMap:o,layer:s,drawSoldermask:r}=t,a=o.soldermask[s]??o.soldermask.top,g=o.soldermaskOverCopper[s]??o.soldermaskOverCopper.top;r&&fOt({ctx:A,board:e,realToCanvasMat:n,soldermaskColor:a});for(const c of i)FOt({ctx:A,element:c,realToCanvasMat:n,colorMap:o,soldermaskOverCopperColor:g,layer:s,drawSoldermask:r})}function FOt(t){const{ctx:A,element:e,realToCanvasMat:i,colorMap:n,soldermaskOverCopperColor:o,layer:s,drawSoldermask:r}=t;e.type==="pcb_smtpad"?bOt({ctx:A,pad:e,realToCanvasMat:i,colorMap:n,soldermaskOverCopperColor:o,layer:s,drawSoldermask:r}):e.type==="pcb_plated_hole"?DOt({ctx:A,hole:e,realToCanvasMat:i,colorMap:n,soldermaskOverCopperColor:o,layer:s,drawSoldermask:r}):e.type==="pcb_hole"?mOt({ctx:A,hole:e,realToCanvasMat:i,colorMap:n,soldermaskOverCopperColor:o,drawSoldermask:r}):e.type==="pcb_via"?_Ot({ctx:A,via:e,realToCanvasMat:i,colorMap:n}):e.type==="pcb_cutout"&&yOt({ctx:A,cutout:e,realToCanvasMat:i,colorMap:n})}function jv(t,A){const e=Math.hypot(t,A);return e<=Number.EPSILON?{x:0,y:0}:{x:t/e,y:A/e}}function GOt(t,A){const e=t.length;if(e<2)return{x:1,y:0};if(A<=0){const g=t[1],c=t[0];if(!g||!c)return{x:1,y:0};const I=jv(g.x-c.x,g.y-c.y);return I.x===0&&I.y===0?{x:1,y:0}:I}if(A>=e-1){const g=t[e-2],c=t[e-1];if(!g||!c)return{x:1,y:0};const I=jv(c.x-g.x,c.y-g.y);return I.x===0&&I.y===0?{x:1,y:0}:I}const i=t[A-1],n=t[A],o=t[A+1];if(!i||!n||!o)return{x:1,y:0};const s=jv(n.x-i.x,n.y-i.y),r=jv(o.x-n.x,o.y-n.y),a=jv(s.x+r.x,s.y+r.y);return a.x===0&&a.y===0?s.x!==0||s.y!==0?s:r.x!==0||r.y!==0?r:{x:1,y:0}:a}function ROt(t){const A=[],e=[];for(let i=0;i<t.length;i++){const n=t[i];if(!n)continue;const o=GOt(t,i),s=jv(-o.y,o.x),r=n.width/2;A.push({x:n.x+s.x*r,y:n.y+s.y*r}),e.push({x:n.x-s.x*r,y:n.y-s.y*r})}return A.concat(e.reverse())}function MOt(t){const A=[];let e=[],i=null;for(const n of t??[]){if(!n||n.route_type!=="wire"){e.length>=2&&A.push(e),e=[],i=null;continue}const o=n.layer??i;if(!o)continue;const s=n.x,r=n.y;if(typeof s!="number"||typeof r!="number"||typeof n.width!="number")continue;const a=n.width;i&&o!==i&&(e.length>=2&&A.push(e),e=[]),i=o,e.push({route_type:"wire",x:s,y:r,width:a,layer:o,start_pcb_port_id:"start_pcb_port_id"in n?n.start_pcb_port_id:void 0,end_pcb_port_id:"end_pcb_port_id"in n?n.end_pcb_port_id:void 0})}return e.length>=2&&A.push(e),A}function NOt(t){if(t.length<2)return!1;const A=t[0]?.width;return typeof A!="number"?!1:t.some(e=>Math.abs(e.width-A)>Number.EPSILON)}function vOt(t,A){return A.copper[t]??A.copper.top}function LOt(t){const{ctx:A,trace:e,realToCanvasMat:i,colorMap:n}=t;if(!e.route||!Array.isArray(e.route)||e.route.length<2)return;const o=MOt(e.route);for(const s of o){const r=s[0]?.layer;if(!r)continue;const a=vOt(r,n);if(NOt(s)){const g=ROt(s);sJ({ctx:A,points:g,fill:a,realToCanvasMat:i});continue}for(let g=0;g<s.length-1;g++){const c=s[g],I=s[g+1];!c||!I||rJ({ctx:A,start:{x:c.x,y:c.y},end:{x:I.x,y:I.y},strokeWidth:c.width,stroke:a,realToCanvasMat:i,lineCap:"round"})}}}function UOt(t){const{ctx:A,via:e,realToCanvasMat:i,colorMap:n}=t;FD({ctx:A,center:{x:e.x,y:e.y},radius:e.outer_diameter/2,fill:n.copper.top,realToCanvasMat:i}),FD({ctx:A,center:{x:e.x,y:e.y},radius:e.hole_diameter/2,fill:n.drill,realToCanvasMat:i})}function DG(t,A){if(!A.layers||A.layers.length===0)return!0;const e=C1A(t);return e.length===0?!0:e.some(i=>A.layers.includes(i))}var pf={copper:{top:"rgb(200, 52, 52)",inner1:"rgb(255, 140, 0)",inner2:"rgb(255, 215, 0)",inner3:"rgb(50, 205, 50)",inner4:"rgb(64, 224, 208)",inner5:"rgb(138, 43, 226)",inner6:"rgb(255, 105, 180)",bottom:"rgb(77, 127, 196)"},soldermaskWithCopperUnderneath:{top:"rgb(18, 82, 50)",bottom:"rgb(77, 127, 196)"},soldermask:{top:"rgb(12, 55, 33)",bottom:"rgb(12, 55, 33)"},soldermaskOverCopper:{top:"rgb(52, 135, 73)",bottom:"rgb(52, 135, 73)"},substrate:"rgb(201, 162, 110)",drill:"#FF26E2",silkscreen:{top:"#f2eda1",bottom:"#5da9e9"},boardOutline:"rgba(255, 255, 255, 0.5)",courtyard:"#FF00FF",keepout:"#FF6B6B"},RQ=class{ctx;colorMap;realToCanvasMat;constructor(t){if("getContext"in t&&typeof t.getContext=="function"){const A=t.getContext("2d");if(!A)throw new Error("Failed to get 2D rendering context from canvas");this.ctx=A}else this.ctx=t;this.colorMap={...pf},this.realToCanvasMat=u3t()}configure(t){t.colorOverrides&&(this.colorMap={...this.colorMap,...t.colorOverrides,copper:{...this.colorMap.copper,...t.colorOverrides.copper},silkscreen:{...this.colorMap.silkscreen,...t.colorOverrides.silkscreen},soldermask:{...this.colorMap.soldermask,...t.colorOverrides.soldermask},soldermaskWithCopperUnderneath:{...this.colorMap.soldermaskWithCopperUnderneath,...t.colorOverrides.soldermaskWithCopperUnderneath},soldermaskOverCopper:{...this.colorMap.soldermaskOverCopper,...t.colorOverrides.soldermaskOverCopper}})}setCameraBounds(t){const A=this.ctx.canvas,e=A.width,i=A.height,n=t.maxX-t.minX,o=t.maxY-t.minY,s=e/n,r=i/o,a=Math.min(s,r),g=(e-n*a)/2,c=(i-o*a)/2;this.realToCanvasMat=d3t(Q9(g,c),p3t(a,-a),Q9(-t.minX,-t.maxY))}drawElements(t,A={}){const e=t.find(o=>o.type==="pcb_board"),i=t.find(o=>o.type==="pcb_panel");i&&tOt({ctx:this.ctx,panel:i,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap,drawBoardMaterial:A.drawBoardMaterial??!1}),e&&f3t({ctx:this.ctx,board:e,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap,drawBoardMaterial:A.drawBoardMaterial??!1});for(const o of t)DG(o,A)&&(o.type==="pcb_smtpad"&&pOt({ctx:this.ctx,pad:o,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}),o.type==="pcb_copper_text"&&M3t({ctx:this.ctx,text:o,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}));const n=A.drawSoldermask??!1;for(const o of t)DG(o,A)&&o.type==="pcb_hole"&&O3t({ctx:this.ctx,hole:o,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap,soldermaskMargin:n?o.soldermask_margin:void 0});e&&kOt({ctx:this.ctx,board:e,elements:t,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap,layer:"top",drawSoldermask:n});for(const o of t)DG(o,A)&&(o.type==="pcb_silkscreen_text"&&uOt({ctx:this.ctx,text:o,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}),o.type==="pcb_silkscreen_rect"&&QOt({ctx:this.ctx,rect:o,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}),o.type==="pcb_silkscreen_circle"&&oOt({ctx:this.ctx,circle:o,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}),o.type==="pcb_silkscreen_line"&&rOt({ctx:this.ctx,line:o,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}),o.type==="pcb_silkscreen_path"&&IOt({ctx:this.ctx,path:o,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}),o.type==="pcb_silkscreen_pill"&&BOt({ctx:this.ctx,pill:o,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}),o.type==="pcb_silkscreen_oval"&&gOt({ctx:this.ctx,oval:o,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}));for(const o of t)DG(o,A)&&(o.type==="pcb_copper_pour"&&w3t({ctx:this.ctx,pour:o,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}),o.type==="pcb_trace"&&LOt({ctx:this.ctx,trace:o,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}));for(const o of t)DG(o,A)&&(o.type==="pcb_plated_hole"&&iOt({ctx:this.ctx,hole:o,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap,soldermaskMargin:n?o.soldermask_margin:void 0,drawSoldermask:n}),o.type==="pcb_via"&&UOt({ctx:this.ctx,via:o,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}));for(const o of t)DG(o,A)&&o.type==="pcb_cutout"&&N3t({ctx:this.ctx,cutout:o,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap});for(const o of t)DG(o,A)&&(o.type==="pcb_keepout"&&Z3t({ctx:this.ctx,keepout:o,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}),o.type==="pcb_fabrication_note_text"&&q3t({ctx:this.ctx,text:o,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}),o.type==="pcb_fabrication_note_rect"&&T3t({ctx:this.ctx,rect:o,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}),o.type==="pcb_note_rect"&&$3t({realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap,ctx:this.ctx,rect:o}),o.type==="pcb_fabrication_note_path"&&J3t({ctx:this.ctx,path:o,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}),o.type==="pcb_note_path"&&X3t({ctx:this.ctx,path:o,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}),o.type==="pcb_note_text"&&eOt({ctx:this.ctx,text:o,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}),o.type==="pcb_note_line"&&z3t({ctx:this.ctx,line:o,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}),o.type==="pcb_note_dimension"&&j3t({ctx:this.ctx,pcbNoteDimension:o,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}),o.type==="pcb_fabrication_note_dimension"&&Y3t({ctx:this.ctx,pcbFabricationNoteDimension:o,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}))}};const HOt=Swe(FYe);var QfA,Fge;function YOt(){if(Fge)return QfA;Fge=1;var t=Object.defineProperty,A=Object.getOwnPropertyDescriptor,e=Object.getOwnPropertyNames,i=Object.prototype.hasOwnProperty,n=(h,E)=>{for(var u in E)t(h,u,{get:E[u],enumerable:!0})},o=(h,E,u,d)=>{if(E&&typeof E=="object"||typeof E=="function")for(let p of e(E))!i.call(h,p)&&p!==u&&t(h,p,{get:()=>E[p],enumerable:!(d=A(E,p))||d.enumerable});return h},s=h=>o(t({},"__esModule",{value:!0}),h),r={};n(r,{SuperGrid:()=>Q,toMMSI:()=>C,toMeterSI:()=>B}),QfA=s(r);var a=c0(),g=HOt,c=xbA(),I=(h,E,u)=>{const d=[];if(E<h)for(let p=h;p>=E;p-=Math.abs(u))d.push(p);else for(let p=h;p<=E;p+=Math.abs(u))d.push(p);return d};function l(h,E){return{x:Math.round(E.x/h)*h,y:Math.round(E.y/h)*h}}function B(h,E=1){return h<0?"-"+B(-h):h<1e-6?"0m":h>1e3?Math.floor(h/1e3)+"km":h>1&&E>1?Math.round(h)+"m":h>1&&E<=1?h.toFixed(Math.ceil(-Math.log10(E)))+"m":h<1&&E>=1/1e3?Math.round(h*1e3)+"mm":h<1&&E<1/1e3?(h*1e3).toFixed(Math.ceil(-Math.log10(E*1e3)))+"mm":""}function C(h,E=1){return B(h/1e3,E/1e3)}var Q=h=>{var E;const u=(0,a.useRef)(null),[d,p]=(0,a.useState)({x:0,y:0}),{majorColor:m="rgba(0,0,0,0.2)",minorColor:D="rgba(0,0,0,0.1)",textColor:w=(E=h.majorColor)!=null?E:"rgba(0,0,0,0.5)",width:b,height:k,screenSpaceCellSize:x=200,stringifyCoord:N=(H,O,Z)=>`${B(H,Z)}, ${B(O,Z)}`}=h,M=Math.ceil(b/x)+2,U=Math.ceil(k/x)+2;(0,a.useEffect)(()=>{if(!u.current)return;const H=u.current.getContext("2d");if(!H)return;const O=x/10**Math.floor(Math.log10(h.transform.a)),Z=h.transform.d<0?-1:1,iA=x/10**Math.log10(h.transform.a)/O;function aA(_A,dA,KA){const TA=_A;let ie,fA,$A;for(ie=dA.x;ie<=KA.x;ie+=TA)fA=(0,g.applyToPoint)(h.transform,{x:ie,y:dA.y}),$A=(0,g.applyToPoint)(h.transform,{x:ie,y:KA.y}),H.beginPath(),H.moveTo(fA.x,fA.y),H.lineTo($A.x,$A.y),H.stroke();const qA=I(dA.y,KA.y,TA*Z);for(const HA of qA)fA=(0,g.applyToPoint)(h.transform,{x:dA.x,y:HA}),$A=(0,g.applyToPoint)(h.transform,{x:KA.x,y:HA}),H.beginPath(),H.moveTo(fA.x,fA.y),H.lineTo($A.x,$A.y),H.stroke()}function eA(_A,dA,KA){const TA=_A;let ie;for(ie=dA.x;ie<=KA.x;ie+=TA)for(const fA of I(dA.y,KA.y,TA*Z)){const $A=(0,g.applyToPoint)(h.transform,{x:ie,y:fA});H.fillStyle=w,H.font="12px sans-serif",H.fillText(N(ie,fA,_A),$A.x+2,$A.y-2)}}H.clearRect(0,0,b,k);const nA=(0,g.applyToPoint)((0,g.inverse)(h.transform),{x:0,y:0}),rA={x:Math.floor((nA.x-O)/O)*O,y:Math.floor((nA.y-O)/O+(Z==-1?2:0))*O},lA={x:rA.x+O*M,y:rA.y+O*U*Z},xA=O*5,RA={x:Math.floor((nA.x-xA)/xA)*xA,y:Math.floor((nA.y-xA)/xA+(Z==-1?2:0))*xA},YA={x:RA.x+xA*M,y:RA.y+xA*U*Z};H.globalAlpha=1,H.strokeStyle=m,aA(O,rA,lA),eA(xA,RA,YA),H.globalAlpha=1-iA,aA(xA/10,RA,YA),H.globalAlpha=1-iA,H.strokeStyle=D,aA(O/10,rA,lA),H.globalAlpha=Math.max(((1-iA)*10-5)/5,0),eA(xA/10,RA,YA),H.globalAlpha=1;const CA=(0,g.applyToPoint)(h.transform,d);H.font="12px sans-serif",H.fillStyle=w,H.fillText(N(d.x,d.y,O),CA.x+2,CA.y-2),H.strokeStyle=m,H.strokeRect(CA.x-5,CA.y-5,10,10)},[u,h.transform,d,b,k]);const Y=H=>{if(!u.current)return;const O=x/10/10**Math.floor(Math.log10(h.transform.a)),Z=u.current.getBoundingClientRect(),$=(0,g.applyToPoint)((0,g.inverse)(h.transform),{x:H.clientX-Z.left,y:H.clientY-Z.top}),iA=l(O,$);p(iA)};return(0,c.jsx)("canvas",{onMouseUp:H=>{H.button===1&&Y(H)},onDoubleClick:Y,ref:u,width:h.width,height:h.height})};return QfA}var d9=YOt();function JOt(t){if(t.sheet)return t.sheet;for(var A=0;A<document.styleSheets.length;A++)if(document.styleSheets[A].ownerNode===t)return document.styleSheets[A]}function TOt(t){var A=document.createElement("style");return A.setAttribute("data-emotion",t.key),t.nonce!==void 0&&A.setAttribute("nonce",t.nonce),A.appendChild(document.createTextNode("")),A.setAttribute("data-s",""),A}var KOt=(function(){function t(e){var i=this;this._insertTag=function(n){var o;i.tags.length===0?i.insertionPoint?o=i.insertionPoint.nextSibling:i.prepend?o=i.container.firstChild:o=i.before:o=i.tags[i.tags.length-1].nextSibling,i.container.insertBefore(n,o),i.tags.push(n)},this.isSpeedy=e.speedy===void 0?!0:e.speedy,this.tags=[],this.ctr=0,this.nonce=e.nonce,this.key=e.key,this.container=e.container,this.prepend=e.prepend,this.insertionPoint=e.insertionPoint,this.before=null}var A=t.prototype;return A.hydrate=function(i){i.forEach(this._insertTag)},A.insert=function(i){this.ctr%(this.isSpeedy?65e3:1)===0&&this._insertTag(TOt(this));var n=this.tags[this.tags.length-1];if(this.isSpeedy){var o=JOt(n);try{o.insertRule(i,o.cssRules.length)}catch{}}else n.appendChild(document.createTextNode(i));this.ctr++},A.flush=function(){this.tags.forEach(function(i){var n;return(n=i.parentNode)==null?void 0:n.removeChild(i)}),this.tags=[],this.ctr=0},t})(),Ou="-ms-",p9="-moz-",Va="-webkit-",Gge="comm",hfA="rule",EfA="decl",POt="@import",Rge="@keyframes",qOt="@layer",OOt=Math.abs,f9=String.fromCharCode,WOt=Object.assign;function ZOt(t,A){return GE(t,0)^45?(((A<<2^GE(t,0))<<2^GE(t,1))<<2^GE(t,2))<<2^GE(t,3):0}function Mge(t){return t.trim()}function VOt(t,A){return(t=A.exec(t))?t[0]:t}function ja(t,A,e){return t.replace(A,e)}function ufA(t,A){return t.indexOf(A)}function GE(t,A){return t.charCodeAt(A)|0}function BJ(t,A,e){return t.slice(A,e)}function RD(t){return t.length}function dfA(t){return t.length}function y9(t,A){return A.push(t),t}function jOt(t,A){return t.map(A).join("")}var m9=1,zv=1,Nge=0,ff=0,LC=0,Xv="";function w9(t,A,e,i,n,o,s){return{value:t,root:A,parent:e,type:i,props:n,children:o,line:m9,column:zv,length:s,return:""}}function CJ(t,A){return WOt(w9("",null,null,"",null,null,0),t,{length:-t.length},A)}function zOt(){return LC}function XOt(){return LC=ff>0?GE(Xv,--ff):0,zv--,LC===10&&(zv=1,m9--),LC}function N0(){return LC=ff<Nge?GE(Xv,ff++):0,zv++,LC===10&&(zv=1,m9++),LC}function MD(){return GE(Xv,ff)}function D9(){return ff}function QJ(t,A){return BJ(Xv,t,A)}function hJ(t){switch(t){case 0:case 9:case 10:case 13:case 32:return 5;case 33:case 43:case 44:case 47:case 62:case 64:case 126:case 59:case 123:case 125:return 4;case 58:return 3;case 34:case 39:case 40:case 91:return 2;case 41:case 93:return 1}return 0}function vge(t){return m9=zv=1,Nge=RD(Xv=t),ff=0,[]}function Lge(t){return Xv="",t}function S9(t){return Mge(QJ(ff-1,pfA(t===91?t+2:t===40?t+1:t)))}function $Ot(t){for(;(LC=MD())&&LC<33;)N0();return hJ(t)>2||hJ(LC)>3?"":" "}function A5t(t,A){for(;--A&&N0()&&!(LC<48||LC>102||LC>57&&LC<65||LC>70&&LC<97););return QJ(t,D9()+(A<6&&MD()==32&&N0()==32))}function pfA(t){for(;N0();)switch(LC){case t:return ff;case 34:case 39:t!==34&&t!==39&&pfA(LC);break;case 40:t===41&&pfA(t);break;case 92:N0();break}return ff}function e5t(t,A){for(;N0()&&t+LC!==57;)if(t+LC===84&&MD()===47)break;return"/*"+QJ(A,ff-1)+"*"+f9(t===47?t:N0())}function t5t(t){for(;!hJ(MD());)N0();return QJ(t,ff)}function i5t(t){return Lge(b9("",null,null,null,[""],t=vge(t),0,[0],t))}function b9(t,A,e,i,n,o,s,r,a){for(var g=0,c=0,I=s,l=0,B=0,C=0,Q=1,h=1,E=1,u=0,d="",p=n,m=o,D=i,w=d;h;)switch(C=u,u=N0()){case 40:if(C!=108&&GE(w,I-1)==58){ufA(w+=ja(S9(u),"&","&\f"),"&\f")!=-1&&(E=-1);break}case 34:case 39:case 91:w+=S9(u);break;case 9:case 10:case 13:case 32:w+=$Ot(C);break;case 92:w+=A5t(D9()-1,7);continue;case 47:switch(MD()){case 42:case 47:y9(n5t(e5t(N0(),D9()),A,e),a);break;default:w+="/"}break;case 123*Q:r[g++]=RD(w)*E;case 125*Q:case 59:case 0:switch(u){case 0:case 125:h=0;case 59+c:E==-1&&(w=ja(w,/\f/g,"")),B>0&&RD(w)-I&&y9(B>32?Hge(w+";",i,e,I-1):Hge(ja(w," ","")+";",i,e,I-2),a);break;case 59:w+=";";default:if(y9(D=Uge(w,A,e,g,c,n,r,d,p=[],m=[],I),o),u===123)if(c===0)b9(w,A,D,D,p,o,I,r,m);else switch(l===99&&GE(w,3)===110?100:l){case 100:case 108:case 109:case 115:b9(t,D,D,i&&y9(Uge(t,D,D,0,0,n,r,d,n,p=[],I),m),n,m,I,r,i?p:m);break;default:b9(w,D,D,D,[""],m,0,r,m)}}g=c=B=0,Q=E=1,d=w="",I=s;break;case 58:I=1+RD(w),B=C;default:if(Q<1){if(u==123)--Q;else if(u==125&&Q++==0&&XOt()==125)continue}switch(w+=f9(u),u*Q){case 38:E=c>0?1:(w+="\f",-1);break;case 44:r[g++]=(RD(w)-1)*E,E=1;break;case 64:MD()===45&&(w+=S9(N0())),l=MD(),c=I=RD(d=w+=t5t(D9())),u++;break;case 45:C===45&&RD(w)==2&&(Q=0)}}return o}function Uge(t,A,e,i,n,o,s,r,a,g,c){for(var I=n-1,l=n===0?o:[""],B=dfA(l),C=0,Q=0,h=0;C<i;++C)for(var E=0,u=BJ(t,I+1,I=OOt(Q=s[C])),d=t;E<B;++E)(d=Mge(Q>0?l[E]+" "+u:ja(u,/&\f/g,l[E])))&&(a[h++]=d);return w9(t,A,e,n===0?hfA:r,a,g,c)}function n5t(t,A,e){return w9(t,A,e,Gge,f9(zOt()),BJ(t,2,-2),0)}function Hge(t,A,e,i){return w9(t,A,e,EfA,BJ(t,0,i),BJ(t,i+1,-1),i)}function $v(t,A){for(var e="",i=dfA(t),n=0;n<i;n++)e+=A(t[n],n,t,A)||"";return e}function o5t(t,A,e,i){switch(t.type){case qOt:if(t.children.length)break;case POt:case EfA:return t.return=t.return||t.value;case Gge:return"";case Rge:return t.return=t.value+"{"+$v(t.children,i)+"}";case hfA:t.value=t.props.join(",")}return RD(e=$v(t.children,i))?t.return=t.value+"{"+e+"}":""}function s5t(t){var A=dfA(t);return function(e,i,n,o){for(var s="",r=0;r<A;r++)s+=t[r](e,i,n,o)||"";return s}}function r5t(t){return function(A){A.root||(A=A.return)&&t(A)}}function a5t(t){var A=Object.create(null);return function(e){return A[e]===void 0&&(A[e]=t(e)),A[e]}}var g5t=function(A,e,i){for(var n=0,o=0;n=o,o=MD(),n===38&&o===12&&(e[i]=1),!hJ(o);)N0();return QJ(A,ff)},c5t=function(A,e){var i=-1,n=44;do switch(hJ(n)){case 0:n===38&&MD()===12&&(e[i]=1),A[i]+=g5t(ff-1,e,i);break;case 2:A[i]+=S9(n);break;case 4:if(n===44){A[++i]=MD()===58?"&\f":"",e[i]=A[i].length;break}default:A[i]+=f9(n)}while(n=N0());return A},I5t=function(A,e){return Lge(c5t(vge(A),e))},Yge=new WeakMap,l5t=function(A){if(!(A.type!=="rule"||!A.parent||A.length<1)){for(var e=A.value,i=A.parent,n=A.column===i.column&&A.line===i.line;i.type!=="rule";)if(i=i.parent,!i)return;if(!(A.props.length===1&&e.charCodeAt(0)!==58&&!Yge.get(i))&&!n){Yge.set(A,!0);for(var o=[],s=I5t(e,o),r=i.props,a=0,g=0;a<s.length;a++)for(var c=0;c<r.length;c++,g++)A.props[g]=o[a]?s[a].replace(/&\f/g,r[c]):r[c]+" "+s[a]}}},B5t=function(A){if(A.type==="decl"){var e=A.value;e.charCodeAt(0)===108&&e.charCodeAt(2)===98&&(A.return="",A.value="")}};function Jge(t,A){switch(ZOt(t,A)){case 5103:return Va+"print-"+t+t;case 5737:case 4201:case 3177:case 3433:case 1641:case 4457:case 2921:case 5572:case 6356:case 5844:case 3191:case 6645:case 3005:case 6391:case 5879:case 5623:case 6135:case 4599:case 4855:case 4215:case 6389:case 5109:case 5365:case 5621:case 3829:return Va+t+t;case 5349:case 4246:case 4810:case 6968:case 2756:return Va+t+p9+t+Ou+t+t;case 6828:case 4268:return Va+t+Ou+t+t;case 6165:return Va+t+Ou+"flex-"+t+t;case 5187:return Va+t+ja(t,/(\w+).+(:[^]+)/,Va+"box-$1$2"+Ou+"flex-$1$2")+t;case 5443:return Va+t+Ou+"flex-item-"+ja(t,/flex-|-self/,"")+t;case 4675:return Va+t+Ou+"flex-line-pack"+ja(t,/align-content|flex-|-self/,"")+t;case 5548:return Va+t+Ou+ja(t,"shrink","negative")+t;case 5292:return Va+t+Ou+ja(t,"basis","preferred-size")+t;case 6060:return Va+"box-"+ja(t,"-grow","")+Va+t+Ou+ja(t,"grow","positive")+t;case 4554:return Va+ja(t,/([^-])(transform)/g,"$1"+Va+"$2")+t;case 6187:return ja(ja(ja(t,/(zoom-|grab)/,Va+"$1"),/(image-set)/,Va+"$1"),t,"")+t;case 5495:case 3959:return ja(t,/(image-set\([^]*)/,Va+"$1$`$1");case 4968:return ja(ja(t,/(.+:)(flex-)?(.*)/,Va+"box-pack:$3"+Ou+"flex-pack:$3"),/s.+-b[^;]+/,"justify")+Va+t+t;case 4095:case 3583:case 4068:case 2532:return ja(t,/(.+)-inline(.+)/,Va+"$1$2")+t;case 8116:case 7059:case 5753:case 5535:case 5445:case 5701:case 4933:case 4677:case 5533:case 5789:case 5021:case 4765:if(RD(t)-1-A>6)switch(GE(t,A+1)){case 109:if(GE(t,A+4)!==45)break;case 102:return ja(t,/(.+:)(.+)-([^]+)/,"$1"+Va+"$2-$3$1"+p9+(GE(t,A+3)==108?"$3":"$2-$3"))+t;case 115:return~ufA(t,"stretch")?Jge(ja(t,"stretch","fill-available"),A)+t:t}break;case 4949:if(GE(t,A+1)!==115)break;case 6444:switch(GE(t,RD(t)-3-(~ufA(t,"!important")&&10))){case 107:return ja(t,":",":"+Va)+t;case 101:return ja(t,/(.+:)([^;!]+)(;|!.+)?/,"$1"+Va+(GE(t,14)===45?"inline-":"")+"box$3$1"+Va+"$2$3$1"+Ou+"$2box$3")+t}break;case 5936:switch(GE(t,A+11)){case 114:return Va+t+Ou+ja(t,/[svh]\w+-[tblr]{2}/,"tb")+t;case 108:return Va+t+Ou+ja(t,/[svh]\w+-[tblr]{2}/,"tb-rl")+t;case 45:return Va+t+Ou+ja(t,/[svh]\w+-[tblr]{2}/,"lr")+t}return Va+t+Ou+t+t}return t}var C5t=function(A,e,i,n){if(A.length>-1&&!A.return)switch(A.type){case EfA:A.return=Jge(A.value,A.length);break;case Rge:return $v([CJ(A,{value:ja(A.value,"@","@"+Va)})],n);case hfA:if(A.length)return jOt(A.props,function(o){switch(VOt(o,/(::plac\w+|:read-\w+)/)){case":read-only":case":read-write":return $v([CJ(A,{props:[ja(o,/:(read-\w+)/,":"+p9+"$1")]})],n);case"::placeholder":return $v([CJ(A,{props:[ja(o,/:(plac\w+)/,":"+Va+"input-$1")]}),CJ(A,{props:[ja(o,/:(plac\w+)/,":"+p9+"$1")]}),CJ(A,{props:[ja(o,/:(plac\w+)/,Ou+"input-$1")]})],n)}return""})}},Q5t=[C5t],h5t=function(A){var e=A.key;if(e==="css"){var i=document.querySelectorAll("style[data-emotion]:not([data-s])");Array.prototype.forEach.call(i,function(Q){var h=Q.getAttribute("data-emotion");h.indexOf(" ")!==-1&&(document.head.appendChild(Q),Q.setAttribute("data-s",""))})}var n=A.stylisPlugins||Q5t,o={},s,r=[];s=A.container||document.head,Array.prototype.forEach.call(document.querySelectorAll('style[data-emotion^="'+e+' "]'),function(Q){for(var h=Q.getAttribute("data-emotion").split(" "),E=1;E<h.length;E++)o[h[E]]=!0;r.push(Q)});var a,g=[l5t,B5t];{var c,I=[o5t,r5t(function(Q){c.insert(Q)})],l=s5t(g.concat(n,I)),B=function(h){return $v(i5t(h),l)};a=function(h,E,u,d){c=u,B(h?h+"{"+E.styles+"}":E.styles),d&&(C.inserted[E.name]=!0)}}var C={key:e,sheet:new KOt({key:e,container:s,nonce:A.nonce,speedy:A.speedy,prepend:A.prepend,insertionPoint:A.insertionPoint}),nonce:A.nonce,inserted:o,registered:{},insert:a};return C.sheet.hydrate(r),C};function E5t(t){for(var A=0,e,i=0,n=t.length;n>=4;++i,n-=4)e=t.charCodeAt(i)&255|(t.charCodeAt(++i)&255)<<8|(t.charCodeAt(++i)&255)<<16|(t.charCodeAt(++i)&255)<<24,e=(e&65535)*1540483477+((e>>>16)*59797<<16),e^=e>>>24,A=(e&65535)*1540483477+((e>>>16)*59797<<16)^(A&65535)*1540483477+((A>>>16)*59797<<16);switch(n){case 3:A^=(t.charCodeAt(i+2)&255)<<16;case 2:A^=(t.charCodeAt(i+1)&255)<<8;case 1:A^=t.charCodeAt(i)&255,A=(A&65535)*1540483477+((A>>>16)*59797<<16)}return A^=A>>>13,A=(A&65535)*1540483477+((A>>>16)*59797<<16),((A^A>>>15)>>>0).toString(36)}var u5t={animationIterationCount:1,aspectRatio:1,borderImageOutset:1,borderImageSlice:1,borderImageWidth:1,boxFlex:1,boxFlexGroup:1,boxOrdinalGroup:1,columnCount:1,columns:1,flex:1,flexGrow:1,flexPositive:1,flexShrink:1,flexNegative:1,flexOrder:1,gridRow:1,gridRowEnd:1,gridRowSpan:1,gridRowStart:1,gridColumn:1,gridColumnEnd:1,gridColumnSpan:1,gridColumnStart:1,msGridRow:1,msGridRowSpan:1,msGridColumn:1,msGridColumnSpan:1,fontWeight:1,lineHeight:1,opacity:1,order:1,orphans:1,scale:1,tabSize:1,widows:1,zIndex:1,zoom:1,WebkitLineClamp:1,fillOpacity:1,floodOpacity:1,stopOpacity:1,strokeDasharray:1,strokeDashoffset:1,strokeMiterlimit:1,strokeOpacity:1,strokeWidth:1},d5t=/[A-Z]|^ms/g,p5t=/_EMO_([^_]+?)_([^]*?)_EMO_/g,Tge=function(A){return A.charCodeAt(1)===45},Kge=function(A){return A!=null&&typeof A!="boolean"},ffA=a5t(function(t){return Tge(t)?t:t.replace(d5t,"-$&").toLowerCase()}),Pge=function(A,e){switch(A){case"animation":case"animationName":if(typeof e=="string")return e.replace(p5t,function(i,n,o){return O_={name:n,styles:o,next:O_},n})}return u5t[A]!==1&&!Tge(A)&&typeof e=="number"&&e!==0?e+"px":e};function x9(t,A,e){if(e==null)return"";var i=e;if(i.__emotion_styles!==void 0)return i;switch(typeof e){case"boolean":return"";case"object":{var n=e;if(n.anim===1)return O_={name:n.name,styles:n.styles,next:O_},n.name;var o=e;if(o.styles!==void 0){var s=o.next;if(s!==void 0)for(;s!==void 0;)O_={name:s.name,styles:s.styles,next:O_},s=s.next;var r=o.styles+";";return r}return f5t(t,A,e)}}var a=e;if(A==null)return a;var g=A[a];return g!==void 0?g:a}function f5t(t,A,e){var i="";if(Array.isArray(e))for(var n=0;n<e.length;n++)i+=x9(t,A,e[n])+";";else for(var o in e){var s=e[o];if(typeof s!="object"){var r=s;A!=null&&A[r]!==void 0?i+=o+"{"+A[r]+"}":Kge(r)&&(i+=ffA(o)+":"+Pge(o,r)+";")}else if(Array.isArray(s)&&typeof s[0]=="string"&&(A==null||A[s[0]]===void 0))for(var a=0;a<s.length;a++)Kge(s[a])&&(i+=ffA(o)+":"+Pge(o,s[a])+";");else{var g=x9(t,A,s);switch(o){case"animation":case"animationName":{i+=ffA(o)+":"+g+";";break}default:i+=o+"{"+g+"}"}}}return i}var qge=/label:\s*([^\s;{]+)\s*(;|$)/g,O_;function yfA(t,A,e){if(t.length===1&&typeof t[0]=="object"&&t[0]!==null&&t[0].styles!==void 0)return t[0];var i=!0,n="";O_=void 0;var o=t[0];if(o==null||o.raw===void 0)i=!1,n+=x9(e,A,o);else{var s=o;n+=s[0]}for(var r=1;r<t.length;r++)if(n+=x9(e,A,t[r]),i){var a=o;n+=a[r]}qge.lastIndex=0;for(var g="",c;(c=qge.exec(n))!==null;)g+="-"+c[1];var I=E5t(n)+g;return{name:I,styles:n,next:O_}}function Oge(t,A,e){var i="";return e.split(" ").forEach(function(n){t[n]!==void 0?A.push(t[n]+";"):n&&(i+=n+" ")}),i}var y5t=function(A,e,i){var n=A.key+"-"+e.name;A.registered[n]===void 0&&(A.registered[n]=e.styles)},m5t=function(A,e,i){y5t(A,e);var n=A.key+"-"+e.name;if(A.inserted[e.name]===void 0){var o=e;do A.insert(e===o?"."+n:"",o,A.sheet,!0),o=o.next;while(o!==void 0)}};function Wge(t,A){if(t.inserted[A.name]===void 0)return t.insert("",A,t.sheet,!0)}function Zge(t,A,e){var i=[],n=Oge(t,i,e);return i.length<2?e:n+A(i)}var w5t=function(A){var e=h5t(A);e.sheet.speedy=function(r){this.isSpeedy=r},e.compat=!0;var i=function(){for(var a=arguments.length,g=new Array(a),c=0;c<a;c++)g[c]=arguments[c];var I=yfA(g,e.registered,void 0);return m5t(e,I),e.key+"-"+I.name},n=function(){for(var a=arguments.length,g=new Array(a),c=0;c<a;c++)g[c]=arguments[c];var I=yfA(g,e.registered),l="animation-"+I.name;return Wge(e,{name:I.name,styles:"@keyframes "+l+"{"+I.styles+"}"}),l},o=function(){for(var a=arguments.length,g=new Array(a),c=0;c<a;c++)g[c]=arguments[c];var I=yfA(g,e.registered);Wge(e,I)},s=function(){for(var a=arguments.length,g=new Array(a),c=0;c<a;c++)g[c]=arguments[c];return Zge(e.registered,i,D5t(g))};return{css:i,cx:s,injectGlobal:o,keyframes:n,hydrate:function(a){a.forEach(function(g){e.inserted[g]=!0})},flush:function(){e.registered={},e.inserted={},e.sheet.flush()},sheet:e.sheet,cache:e,getRegisteredStyles:Oge.bind(null,e.registered),merge:Zge.bind(null,e.registered,i)}},D5t=function t(A){for(var e="",i=0;i<A.length;i++){var n=A[i];if(n!=null){var o=void 0;switch(typeof n){case"boolean":break;case"object":{if(Array.isArray(n))o=t(n);else{o="";for(var s in n)n[s]&&s&&(o&&(o+=" "),o+=s)}break}default:o=n}o&&(e&&(e+=" "),e+=o)}}return e},S5t=w5t({key:"css"}),A1=S5t.css,b5t=Object.create,Vge=Object.defineProperty,x5t=Object.getOwnPropertyDescriptor,jge=Object.getOwnPropertyNames,_5t=Object.getPrototypeOf,k5t=Object.prototype.hasOwnProperty,Ma=(t,A)=>function(){return A||(0,t[jge(t)[0]])((A={exports:{}}).exports,A),A.exports},F5t=(t,A,e,i)=>{if(A&&typeof A=="object"||typeof A=="function")for(let n of jge(A))!k5t.call(t,n)&&n!==e&&Vge(t,n,{get:()=>A[n],enumerable:!(i=x5t(A,n))||i.enumerable});return t},zge=(t,A,e)=>(e=t!=null?b5t(_5t(t)):{},F5t(Vge(e,"default",{value:t,enumerable:!0}),t)),G5t=Ma({"node_modules/svgson/dist/svgson.umd.js"(t,A){(function(e,i){typeof t=="object"&&typeof A<"u"?A.exports=i():typeof define=="function"&&define.amd?define(i):(e=typeof globalThis<"u"?globalThis:e||self,e.svgson=i())})(t,function(){var e=function(eA){return eA!=null&&(i(eA)||n(eA)||!!eA._isBuffer)};function i(eA){return!!eA.constructor&&typeof eA.constructor.isBuffer=="function"&&eA.constructor.isBuffer(eA)}function n(eA){return typeof eA.readFloatLE=="function"&&typeof eA.slice=="function"&&i(eA.slice(0,0))}var o=Object.prototype.toString,s=function(nA){if(typeof nA>"u")return"undefined";if(nA===null)return"null";if(nA===!0||nA===!1||nA instanceof Boolean)return"boolean";if(typeof nA=="string"||nA instanceof String)return"string";if(typeof nA=="number"||nA instanceof Number)return"number";if(typeof nA=="function"||nA instanceof Function)return"function";if(typeof Array.isArray<"u"&&Array.isArray(nA))return"array";if(nA instanceof RegExp)return"regexp";if(nA instanceof Date)return"date";var rA=o.call(nA);return rA==="[object RegExp]"?"regexp":rA==="[object Date]"?"date":rA==="[object Arguments]"?"arguments":rA==="[object Error]"?"error":e(nA)?"buffer":rA==="[object Set]"?"set":rA==="[object WeakSet]"?"weakset":rA==="[object Map]"?"map":rA==="[object WeakMap]"?"weakmap":rA==="[object Symbol]"?"symbol":rA==="[object Int8Array]"?"int8array":rA==="[object Uint8Array]"?"uint8array":rA==="[object Uint8ClampedArray]"?"uint8clampedarray":rA==="[object Int16Array]"?"int16array":rA==="[object Uint16Array]"?"uint16array":rA==="[object Int32Array]"?"int32array":rA==="[object Uint32Array]"?"uint32array":rA==="[object Float32Array]"?"float32array":rA==="[object Float64Array]"?"float64array":"object"};function r(eA,nA){return nA={exports:{}},eA(nA,nA.exports),nA.exports}var a=r(function(eA){(function(){function nA(rA,lA){if(typeof lA!="function")return rA;var pA={};for(var xA in rA)Object.prototype.hasOwnProperty.call(rA,xA)&&(pA[lA(xA,rA[xA])||xA]=rA[xA]);return pA}eA.exports?eA.exports=nA:window.rename=nA})()}),g=function eA(nA,rA){var lA=s(nA);if(lA!=="object"&&lA!=="array")throw new Error("expected an object");var pA=[];lA==="object"&&(nA=a(nA,rA),pA={});for(var xA in nA)if(nA.hasOwnProperty(xA)){var RA=nA[xA];s(RA)==="object"||s(RA)==="array"?pA[xA]=eA(RA,rA):pA[xA]=RA}return pA},c=r(function(eA){var nA=Object.prototype.hasOwnProperty,rA="~";function lA(){}Object.create&&(lA.prototype=Object.create(null),new lA().__proto__||(rA=!1));function pA(RA,YA,CA){this.fn=RA,this.context=YA,this.once=CA||!1}function xA(){this._events=new lA,this._eventsCount=0}xA.prototype.eventNames=function(){var YA=[],CA,_A;if(this._eventsCount===0)return YA;for(_A in CA=this._events)nA.call(CA,_A)&&YA.push(rA?_A.slice(1):_A);return Object.getOwnPropertySymbols?YA.concat(Object.getOwnPropertySymbols(CA)):YA},xA.prototype.listeners=function(YA,CA){var _A=rA?rA+YA:YA,dA=this._events[_A];if(CA)return!!dA;if(!dA)return[];if(dA.fn)return[dA.fn];for(var KA=0,TA=dA.length,ie=new Array(TA);KA<TA;KA++)ie[KA]=dA[KA].fn;return ie},xA.prototype.emit=function(YA,CA,_A,dA,KA,TA){var ie=rA?rA+YA:YA;if(!this._events[ie])return!1;var fA=this._events[ie],$A=arguments.length,qA,HA;if(fA.fn){switch(fA.once&&this.removeListener(YA,fA.fn,void 0,!0),$A){case 1:return fA.fn.call(fA.context),!0;case 2:return fA.fn.call(fA.context,CA),!0;case 3:return fA.fn.call(fA.context,CA,_A),!0;case 4:return fA.fn.call(fA.context,CA,_A,dA),!0;case 5:return fA.fn.call(fA.context,CA,_A,dA,KA),!0;case 6:return fA.fn.call(fA.context,CA,_A,dA,KA,TA),!0}for(HA=1,qA=new Array($A-1);HA<$A;HA++)qA[HA-1]=arguments[HA];fA.fn.apply(fA.context,qA)}else{var ZA=fA.length,kA;for(HA=0;HA<ZA;HA++)switch(fA[HA].once&&this.removeListener(YA,fA[HA].fn,void 0,!0),$A){case 1:fA[HA].fn.call(fA[HA].context);break;case 2:fA[HA].fn.call(fA[HA].context,CA);break;case 3:fA[HA].fn.call(fA[HA].context,CA,_A);break;case 4:fA[HA].fn.call(fA[HA].context,CA,_A,dA);break;default:if(!qA)for(kA=1,qA=new Array($A-1);kA<$A;kA++)qA[kA-1]=arguments[kA];fA[HA].fn.apply(fA[HA].context,qA)}}return!0},xA.prototype.on=function(YA,CA,_A){var dA=new pA(CA,_A||this),KA=rA?rA+YA:YA;return this._events[KA]?this._events[KA].fn?this._events[KA]=[this._events[KA],dA]:this._events[KA].push(dA):(this._events[KA]=dA,this._eventsCount++),this},xA.prototype.once=function(YA,CA,_A){var dA=new pA(CA,_A||this,!0),KA=rA?rA+YA:YA;return this._events[KA]?this._events[KA].fn?this._events[KA]=[this._events[KA],dA]:this._events[KA].push(dA):(this._events[KA]=dA,this._eventsCount++),this},xA.prototype.removeListener=function(YA,CA,_A,dA){var KA=rA?rA+YA:YA;if(!this._events[KA])return this;if(!CA)return--this._eventsCount===0?this._events=new lA:delete this._events[KA],this;var TA=this._events[KA];if(TA.fn)TA.fn===CA&&(!dA||TA.once)&&(!_A||TA.context===_A)&&(--this._eventsCount===0?this._events=new lA:delete this._events[KA]);else{for(var ie=0,fA=[],$A=TA.length;ie<$A;ie++)(TA[ie].fn!==CA||dA&&!TA[ie].once||_A&&TA[ie].context!==_A)&&fA.push(TA[ie]);fA.length?this._events[KA]=fA.length===1?fA[0]:fA:--this._eventsCount===0?this._events=new lA:delete this._events[KA]}return this},xA.prototype.removeAllListeners=function(YA){var CA;return YA?(CA=rA?rA+YA:YA,this._events[CA]&&(--this._eventsCount===0?this._events=new lA:delete this._events[CA])):(this._events=new lA,this._eventsCount=0),this},xA.prototype.off=xA.prototype.removeListener,xA.prototype.addListener=xA.prototype.on,xA.prototype.setMaxListeners=function(){return this},xA.prefixed=rA,xA.EventEmitter=xA,eA.exports=xA});function I(eA,nA,rA){return nA in eA?Object.defineProperty(eA,nA,{value:rA,enumerable:!0,configurable:!0,writable:!0}):eA[nA]=rA,eA}var l=function(){},B={data:"state-data",cdata:"state-cdata",tagBegin:"state-tag-begin",tagName:"state-tag-name",tagEnd:"state-tag-end",attributeNameStart:"state-attribute-name-start",attributeName:"state-attribute-name",attributeNameEnd:"state-attribute-name-end",attributeValueBegin:"state-attribute-value-begin",attributeValue:"state-attribute-value"},C={lt:"action-lt",gt:"action-gt",space:"action-space",equal:"action-equal",quote:"action-quote",slash:"action-slash",char:"action-char",error:"action-error"},Q={text:"text",openTag:"open-tag",closeTag:"close-tag",attributeName:"attribute-name",attributeValue:"attribute-value"},h={" ":C.space," ":C.space,"\n":C.space,"\r":C.space,"<":C.lt,">":C.gt,'"':C.quote,"'":C.quote,"=":C.equal,"/":C.slash},E=function(nA){return h[nA]||C.char},u=function(nA){var rA,lA,pA,xA,RA,YA,CA,_A,dA,KA;nA=Object.assign({debug:!1},nA);var TA=new c,ie=B.data,fA="",$A="",qA="",HA="",ZA="",kA="",wA=function(PA,OA){if(!($A[0]==="?"||$A[0]==="!")){var Ae={type:PA,value:OA};nA.debug&&console.log("emit:",Ae),TA.emit("data",Ae)}};TA.stateMachine=(KA={},I(KA,B.data,(rA={},I(rA,C.lt,function(){fA.trim()&&wA(Q.text,fA),$A="",ZA=!1,ie=B.tagBegin}),I(rA,C.char,function(bA){fA+=bA}),rA)),I(KA,B.cdata,I({},C.char,function(bA){fA+=bA,fA.substr(-3)==="]]>"&&(wA(Q.text,fA.slice(0,-3)),fA="",ie=B.data)})),I(KA,B.tagBegin,(lA={},I(lA,C.space,l),I(lA,C.char,function(bA){$A=bA,ie=B.tagName}),I(lA,C.slash,function(){$A="",ZA=!0}),lA)),I(KA,B.tagName,(pA={},I(pA,C.space,function(){ZA?ie=B.tagEnd:(ie=B.attributeNameStart,wA(Q.openTag,$A))}),I(pA,C.gt,function(){wA(ZA?Q.closeTag:Q.openTag,$A),fA="",ie=B.data}),I(pA,C.slash,function(){ie=B.tagEnd,wA(Q.openTag,$A)}),I(pA,C.char,function(bA){$A+=bA,$A==="![CDATA["&&(ie=B.cdata,fA="",$A="")}),pA)),I(KA,B.tagEnd,(xA={},I(xA,C.gt,function(){wA(Q.closeTag,$A),fA="",ie=B.data}),I(xA,C.char,l),xA)),I(KA,B.attributeNameStart,(RA={},I(RA,C.char,function(bA){qA=bA,ie=B.attributeName}),I(RA,C.gt,function(){fA="",ie=B.data}),I(RA,C.space,l),I(RA,C.slash,function(){ZA=!0,ie=B.tagEnd}),RA)),I(KA,B.attributeName,(YA={},I(YA,C.space,function(){ie=B.attributeNameEnd}),I(YA,C.equal,function(){wA(Q.attributeName,qA),ie=B.attributeValueBegin}),I(YA,C.gt,function(){HA="",wA(Q.attributeName,qA),wA(Q.attributeValue,HA),fA="",ie=B.data}),I(YA,C.slash,function(){ZA=!0,HA="",wA(Q.attributeName,qA),wA(Q.attributeValue,HA),ie=B.tagEnd}),I(YA,C.char,function(bA){qA+=bA}),YA)),I(KA,B.attributeNameEnd,(CA={},I(CA,C.space,l),I(CA,C.equal,function(){wA(Q.attributeName,qA),ie=B.attributeValueBegin}),I(CA,C.gt,function(){HA="",wA(Q.attributeName,qA),wA(Q.attributeValue,HA),fA="",ie=B.data}),I(CA,C.char,function(bA){HA="",wA(Q.attributeName,qA),wA(Q.attributeValue,HA),qA=bA,ie=B.attributeName}),CA)),I(KA,B.attributeValueBegin,(_A={},I(_A,C.space,l),I(_A,C.quote,function(bA){kA=bA,HA="",ie=B.attributeValue}),I(_A,C.gt,function(){HA="",wA(Q.attributeValue,HA),fA="",ie=B.data}),I(_A,C.char,function(bA){kA="",HA=bA,ie=B.attributeValue}),_A)),I(KA,B.attributeValue,(dA={},I(dA,C.space,function(bA){kA?HA+=bA:(wA(Q.attributeValue,HA),ie=B.attributeNameStart)}),I(dA,C.quote,function(bA){kA===bA?(wA(Q.attributeValue,HA),ie=B.attributeNameStart):HA+=bA}),I(dA,C.gt,function(bA){kA?HA+=bA:(wA(Q.attributeValue,HA),fA="",ie=B.data)}),I(dA,C.slash,function(bA){kA?HA+=bA:(wA(Q.attributeValue,HA),ZA=!0,ie=B.tagEnd)}),I(dA,C.char,function(bA){HA+=bA}),dA)),KA);var UA=function(PA){nA.debug&&console.log(ie,PA);var OA=TA.stateMachine[ie],Ae=OA[E(PA)]||OA[C.error]||OA[C.char];Ae(PA)};return TA.write=function(bA){for(var PA=bA.length,OA=0;OA<PA;OA++)UA(bA[OA])},TA},d={State:B,Action:C,Type:Q,create:u},p=d.Type,m={element:"element",text:"text"},D=function(nA){return Object.assign({name:"",type:m.element,value:"",parent:null,attributes:{},children:[]},nA)},w=function(nA){nA=Object.assign({stream:!1,parentNodes:!0,doneEvent:"done",tagPrefix:"tag:",emitTopLevelOnly:!1,debug:!1},nA);var rA=void 0,lA=void 0,pA=void 0,xA=void 0,RA=new c,YA=function(_A){switch(_A.type){case p.openTag:if(pA===null)pA=lA,pA.name=_A.value;else{var dA=D({name:_A.value,parent:pA});pA.children.push(dA),pA=dA}break;case p.closeTag:var KA=pA.parent;if(nA.parentNodes||(pA.parent=null),pA.name!==_A.value)break;nA.stream&&KA===lA&&(lA.children=[],pA.parent=null),(!nA.emitTopLevelOnly||KA===lA)&&(RA.emit(nA.tagPrefix+pA.name,pA),RA.emit("tag",pA.name,pA)),pA===lA&&(rA.removeAllListeners("data"),RA.emit(nA.doneEvent,pA),lA=null),pA=KA;break;case p.text:pA&&pA.children.push(D({type:m.text,value:_A.value,parent:nA.parentNodes?pA:null}));break;case p.attributeName:xA=_A.value,pA.attributes[xA]="";break;case p.attributeValue:pA.attributes[xA]=_A.value;break}};return RA.reset=function(){rA=d.create({debug:nA.debug}),rA.on("data",YA),lA=D(),pA=null,xA="",RA.parse=rA.write},RA.reset(),RA},b=function(nA,rA){rA=Object.assign({},rA,{stream:!1,tagPrefix:":"});var lA=w(rA),pA=void 0;return lA.on("done",function(xA){pA=xA}),lA.parse(nA),pA},k={parseSync:b},x=k.parseSync,N=function(nA){var rA=x("<root>".concat(nA,"</root>"),{parentNodes:!1}),lA=rA.children&&rA.children.length>0&&rA.children.every(function(pA){return pA.name==="svg"});if(lA)return rA.children.length===1?rA.children[0]:rA.children;throw Error("nothing to parse")},M=function(nA){return g(nA,function(rA){return Y(rA)?rA:U(rA)})},U=function(nA){return nA.replace(/[-|:]([a-z])/gi,function(rA,lA){return lA.toUpperCase()})},Y=function(nA){return/^(data|aria)(-\w+)/.test(nA)},H=function(nA){if(nA){var rA=String(nA);return/[&<>]/.test(rA)?"<![CDATA[".concat(rA.replace(/]]>/,"]]]]><![CDATA[>"),"]]>"):rA}return""},O=function(nA){return String(nA).replace(/&/g,"&amp;").replace(/'/g,"&apos;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")},Z=function(nA){var rA=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},lA=rA.transformNode,pA=lA===void 0?function(CA){return CA}:lA,xA=rA.camelcase,RA=xA===void 0?!1:xA,YA=function(_A){var dA;return dA=pA(_A),RA&&(dA=M(dA)),dA};return YA(N(nA))};function $(){for(var eA=arguments.length,nA=new Array(eA),rA=0;rA<eA;rA++)nA[rA]=arguments[rA];return new Promise(function(lA,pA){try{var xA=Z.apply(void 0,nA);lA(xA)}catch(RA){pA(RA)}})}var iA=function eA(nA){var rA=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},lA=rA.transformAttr,pA=lA===void 0?function(ie,fA,$A){return"".concat(ie,'="').concat($A(fA),'"')}:lA,xA=rA.transformNode,RA=xA===void 0?function(ie){return ie}:xA,YA=rA.selfClose,CA=YA===void 0?!0:YA;if(Array.isArray(nA))return nA.map(function(ie){return eA(ie,{transformAttr:pA,selfClose:CA,transformNode:RA})}).join("");var _A=RA(nA);if(_A.type==="text")return H(_A.value);var dA="";for(var KA in _A.attributes){var TA=pA(KA,_A.attributes[KA],O,_A.name);dA+=TA?" ".concat(TA):""}return _A.children&&_A.children.length>0||!CA?"<".concat(_A.name).concat(dA,">").concat(eA(_A.children,{transformAttr:pA,transformNode:RA,selfClose:CA}),"</").concat(_A.name,">"):"<".concat(_A.name).concat(dA,"/>")},aA=Object.assign({},{parse:$,parseSync:Z,stringify:iA});return aA})}}),mfA=Ma({"node_modules/js-beautify/js/src/core/output.js"(t,A){function e(o){this.__parent=o,this.__character_count=0,this.__indent_count=-1,this.__alignment_count=0,this.__wrap_point_index=0,this.__wrap_point_character_count=0,this.__wrap_point_indent_count=-1,this.__wrap_point_alignment_count=0,this.__items=[]}e.prototype.clone_empty=function(){var o=new e(this.__parent);return o.set_indent(this.__indent_count,this.__alignment_count),o},e.prototype.item=function(o){return o<0?this.__items[this.__items.length+o]:this.__items[o]},e.prototype.has_match=function(o){for(var s=this.__items.length-1;s>=0;s--)if(this.__items[s].match(o))return!0;return!1},e.prototype.set_indent=function(o,s){this.is_empty()&&(this.__indent_count=o||0,this.__alignment_count=s||0,this.__character_count=this.__parent.get_indent_size(this.__indent_count,this.__alignment_count))},e.prototype._set_wrap_point=function(){this.__parent.wrap_line_length&&(this.__wrap_point_index=this.__items.length,this.__wrap_point_character_count=this.__character_count,this.__wrap_point_indent_count=this.__parent.next_line.__indent_count,this.__wrap_point_alignment_count=this.__parent.next_line.__alignment_count)},e.prototype._should_wrap=function(){return this.__wrap_point_index&&this.__character_count>this.__parent.wrap_line_length&&this.__wrap_point_character_count>this.__parent.next_line.__character_count},e.prototype._allow_wrap=function(){if(this._should_wrap()){this.__parent.add_new_line();var o=this.__parent.current_line;return o.set_indent(this.__wrap_point_indent_count,this.__wrap_point_alignment_count),o.__items=this.__items.slice(this.__wrap_point_index),this.__items=this.__items.slice(0,this.__wrap_point_index),o.__character_count+=this.__character_count-this.__wrap_point_character_count,this.__character_count=this.__wrap_point_character_count,o.__items[0]===" "&&(o.__items.splice(0,1),o.__character_count-=1),!0}return!1},e.prototype.is_empty=function(){return this.__items.length===0},e.prototype.last=function(){return this.is_empty()?null:this.__items[this.__items.length-1]},e.prototype.push=function(o){this.__items.push(o);var s=o.lastIndexOf(`
5387
+ `),a=[];let g=0;for(const I of r){const l=Array.from(I);let B=0;l.forEach((C,Q)=>{B+=C===" "?n:e,Q<l.length-1&&(B+=i)}),a.push(B),B>g&&(g=B)}const c=r.length>1?A+(r.length-1)*s:A;return{width:g,height:c,glyphWidth:e,letterSpacing:i,spaceWidth:n,strokeWidth:o,lineHeight:s,lines:r,lineWidths:a}}function cfA(t,A){const e=A.width+A.strokeWidth,i=A.height+A.strokeWidth;let n=0,o=0;return t==="center"||t==="top_center"||t==="bottom_center"?n=-e/2:t==="top_left"||t==="bottom_left"||t==="center_left"?n=0:t==="top_right"||t==="bottom_right"||t==="center_right"?n=-e:(t==="top_center"||t==="bottom_center")&&(n=-e/2),t==="center"||t==="center_left"||t==="center_right"?o=-i/2:t==="top_left"||t==="top_right"||t==="top_center"?o=0:(t==="bottom_left"||t==="bottom_right"||t==="bottom_center")&&(o=-i),{x:n,y:o}}function IfA(t){const{alignment:A,lineWidth:e,maxWidth:i,strokeWidth:n}=t,o=e+n,s=i+n;return A==="top_left"||A==="bottom_left"||A==="center_left"?0:A==="top_right"||A==="bottom_right"||A==="center_right"?s-o:(s-o)/2}var k3t=t=>rD[t]??rD[t.toUpperCase()];function lfA(t){const{ctx:A,line:e,fontSize:i,startX:n,startY:o,layout:s}=t,{glyphWidth:r,letterSpacing:a,spaceWidth:g,strokeWidth:c}=s,I=i,l=o,B=Array.from(e);let C=n+c/2;B.forEach((Q,h)=>{const E=k3t(Q),u=Q===" "?g:r;if(E?.length){A.beginPath();for(const d of E){const p=C+d.x1*r,m=l+(1-d.y1)*I,D=C+d.x2*r,w=l+(1-d.y2)*I;A.moveTo(p,m),A.lineTo(D,w)}A.stroke()}C+=u,h<B.length-1&&(C+=a)})}function F3t(t){const{ctx:A,text:e,fontSize:i,startX:n,startY:o,anchorAlignment:s="center"}=t,r=E9(e,i),{lines:a,lineWidths:g,lineHeight:c,width:I,strokeWidth:l}=r;a.forEach((B,C)=>{const Q=n+IfA({alignment:s,lineWidth:g[C],maxWidth:I,strokeWidth:l}),h=o+C*c;lfA({ctx:A,line:B,fontSize:i,startX:Q,startY:h,layout:r})})}function BfA(t){const{ctx:A,text:e,x:i,y:n,fontSize:o,color:s,realToCanvasMat:r,anchorAlignment:a,rotation:g=0}=t;if(!e)return;const[c,I]=Bn(r,[i,n]),l=Math.abs(r.a),B=o*l,C=E9(e,B),Q=cfA(a,C);A.save(),A.translate(c,I),g!==0&&A.rotate(-g*(Math.PI/180)),A.lineWidth=C.strokeWidth,A.lineCap="round",A.lineJoin="round",A.strokeStyle=s;const{lines:h,lineWidths:E,lineHeight:u,width:d,strokeWidth:p}=C;h.forEach((m,D)=>{const w=Q.x+IfA({alignment:a,lineWidth:E[D],maxWidth:d,strokeWidth:p}),b=Q.y+D*u;lfA({ctx:A,line:m,fontSize:B,startX:w,startY:b,layout:C})}),A.restore()}var G3t={left:.2,right:.2,top:.2,bottom:.2};function R3t(t){return t?t.includes("left")?"center_left":t.includes("right")?"center_right":"center":"center"}function M3t(t){const{ctx:A,text:e,realToCanvasMat:i,colorMap:n}=t,o=e.text??"";if(!o)return;const[s,r]=Bn(i,[e.anchor_position.x,e.anchor_position.y]),a=Math.abs(i.a),g=(e.font_size??1)*a,c=e.ccw_rotation??0,I={...G3t,...e.knockout_padding},l=n.copper[e.layer]??n.copper.top,B=E9(o,g),C=B.width+B.strokeWidth,Q=R3t(e.anchor_alignment),h=cfA(Q,B);if(A.save(),A.translate(s,r),e.is_mirrored&&A.scale(-1,1),c!==0&&A.rotate(-c*(Math.PI/180)),A.lineWidth=B.strokeWidth,A.lineCap="round",A.lineJoin="round",e.is_knockout){const E=I.left*a,u=I.right*a,d=I.top*a,p=I.bottom*a,m=h.x-E*4,D=h.y-d*4,w=C+E*2+u*2,b=B.height+B.strokeWidth+d*2+p*2;A.fillStyle=l,A.fillRect(m,D,w,b)}else A.strokeStyle=l;F3t({ctx:A,text:o,fontSize:g,startX:h.x,startY:h.y,anchorAlignment:Q}),A.restore()}function FD(t){const{ctx:A,center:e,radius:i,fill:n,realToCanvasMat:o,stroke:s,strokeWidth:r,isStrokeDashed:a=!1}=t,[g,c]=Bn(o,[e.x,e.y]),I=i*Math.abs(o.a),l=r?r*Math.abs(o.a):void 0;A.beginPath(),A.arc(g,c,I,0,Math.PI*2),n&&(A.fillStyle=n,A.fill()),s&&l&&(a?A.setLineDash([l*3,l*2]):A.setLineDash([]),A.strokeStyle=s,A.lineWidth=l,A.stroke())}function N3t(t){const{ctx:A,cutout:e,realToCanvasMat:i,colorMap:n}=t;if(e.shape==="rect"){M0({ctx:A,center:e.center,width:e.width,height:e.height,fill:n.drill,realToCanvasMat:i,rotation:e.rotation??0,borderRadius:e.corner_radius??0});return}if(e.shape==="circle"){FD({ctx:A,center:e.center,radius:e.radius,fill:n.drill,realToCanvasMat:i});return}if(e.shape==="polygon"){e.points&&e.points.length>=3&&sJ({ctx:A,points:e.points,fill:n.drill,realToCanvasMat:i});return}}var v3t=1.5,L3t=.6,U3t=.3;function CfA(t){const A=Math.hypot(t.x,t.y)||1;return{x:t.x/A,y:t.y/A}}function xge(t){const{ctx:A,from:e,to:i,realToCanvasMat:n,color:o,fontSize:s,arrowSize:r=1,strokeWidth:a,text:g,textRotation:c,offset:I}=t,l=CfA({x:i.x-e.x,y:i.y-e.y}),B={x:-l.y,y:l.x},C=I?.direction&&typeof I.direction.x=="number"&&typeof I.direction.y=="number",Q=C?CfA(I.direction):{x:0,y:0},h=I?.distance??0,E={x:Q.x*h,y:Q.y*h},u={x:e.x+E.x,y:e.y+E.y},d={x:i.x+E.x,y:i.y+E.y},p={x:u.x+l.x*r,y:u.y+l.y*r},m={x:d.x-l.x*r,y:d.y-l.y*r};Math.abs(n.a);const D=a??r/5,w=o||"rgba(255,255,255,0.5)",b=C&&(Math.abs(Q.x)>Number.EPSILON||Math.abs(Q.y)>Number.EPSILON)?Q:B,k=h+.5,x=[],N=Y=>{const H={x:Y.x+b.x*k,y:Y.y+b.y*k},O=D/2,Z={x:-b.y,y:b.x};return[{x:Y.x+Z.x*O,y:Y.y+Z.y*O},{x:Y.x-Z.x*O,y:Y.y-Z.y*O},{x:H.x-Z.x*O,y:H.y-Z.y*O},{x:H.x+Z.x*O,y:H.y+Z.y*O}]};x.push(u),x.push({x:p.x+B.x*(r/2),y:p.y+B.y*(r/2)}),x.push({x:p.x+B.x*(D/2),y:p.y+B.y*(D/2)}),x.push({x:m.x+B.x*(D/2),y:m.y+B.y*(D/2)}),x.push({x:m.x+B.x*(r/2),y:m.y+B.y*(r/2)}),x.push(d),x.push({x:m.x-B.x*(r/2),y:m.y-B.y*(r/2)}),x.push({x:m.x-B.x*(D/2),y:m.y-B.y*(D/2)}),x.push({x:p.x-B.x*(D/2),y:p.y-B.y*(D/2)}),x.push({x:p.x-B.x*(r/2),y:p.y-B.y*(r/2)}),x.push(u);const M=x[0],U=Y=>{const H=N(Y);x.push(M),x.push(H[0]),x.push(...H),x.push(H[0]),x.push(M)};if(U(e),U(i),sJ({ctx:A,points:x,fill:w,realToCanvasMat:n}),g){const Y={x:(e.x+i.x)/2+E.x,y:(e.y+i.y)/2+E.y},[H,O]=Bn(n,[u.x,u.y]),[Z,$]=Bn(n,[d.x,d.y]),iA=CfA({x:Z-H,y:$-O});let aA=Math.atan2(iA.y,iA.x)*180/Math.PI;(aA>90||aA<-90)&&(aA+=180);const eA=typeof c=="number"&&Number.isFinite(c)?aA-c:aA;let nA=0;if(g&&typeof c=="number"&&Number.isFinite(c)){const pA=g.length*s*L3t,xA=s,RA=c*Math.PI/180,YA=Math.abs(Math.sin(RA)),CA=Math.abs(Math.cos(RA)),_A=pA/2,dA=xA/2;nA=_A*YA+dA*CA+s*U3t}const rA=r*v3t+nA,lA={x:Y.x+B.x*rA,y:Y.y+B.y*rA};BfA({ctx:A,text:g,x:lA.x,y:lA.y,fontSize:s,color:w,realToCanvasMat:n,anchorAlignment:"center",rotation:-eA})}}var H3t="rgba(255,255,255,0.5)";function Y3t(t){const{ctx:A,pcbFabricationNoteDimension:e,realToCanvasMat:i}=t,n=e.color??H3t;xge({ctx:A,from:e.from,to:e.to,realToCanvasMat:i,color:n,fontSize:e.font_size??1,arrowSize:e.arrow_size??1,text:e.text,textRotation:e.text_ccw_rotation,offset:e.offset_distance&&e.offset_direction?{distance:e.offset_distance,direction:e.offset_direction}:void 0})}function rJ(t){const{ctx:A,start:e,end:i,strokeWidth:n,stroke:o,realToCanvasMat:s,lineCap:r="round"}=t,[a,g]=Bn(s,[e.x,e.y]),[c,I]=Bn(s,[i.x,i.y]),l=n*Math.abs(s.a);A.beginPath(),A.moveTo(a,g),A.lineTo(c,I),A.lineWidth=l,A.strokeStyle=o,A.lineCap=r,A.stroke()}function J3t(t){const{ctx:A,path:e,realToCanvasMat:i}=t,o=e.color??"rgba(255,255,255,0.5)";if(!(!e.route||e.route.length<2))for(let s=0;s<e.route.length-1;s++){const r=e.route[s],a=e.route[s+1];!r||!a||rJ({ctx:A,start:{x:r.x,y:r.y},end:{x:a.x,y:a.y},strokeWidth:e.stroke_width??.1,stroke:o,realToCanvasMat:i})}}function T3t(t){const{ctx:A,rect:e,realToCanvasMat:i}=t,o=e.color??"rgba(255,255,255,0.5)",s=e.is_filled??!1,r=e.has_stroke??!0,a=e.is_stroke_dashed??!1;M0({ctx:A,center:e.center,width:e.width,height:e.height,fill:s?o:void 0,stroke:r?o:void 0,strokeWidth:r?e.stroke_width:void 0,borderRadius:e.corner_radius,realToCanvasMat:i,isStrokeDashed:a})}var K3t="rgba(255,255,255,0.5)";function P3t(t,A){return K3t}function q3t(t){const{ctx:A,text:e,realToCanvasMat:i}=t,n=P3t(e.layer),o=e.color??n,s=e.font_size;BfA({ctx:A,text:e.text,x:e.anchor_position.x,y:e.anchor_position.y,fontSize:s,color:o,realToCanvasMat:i,anchorAlignment:e.anchor_alignment})}function aJ(t){const{ctx:A,center:e,radius_x:i,radius_y:n,fill:o,stroke:s,strokeWidth:r=.1,realToCanvasMat:a,rotation:g=0}=t,[c,I]=Bn(a,[e.x,e.y]),l=i*Math.abs(a.a),B=n*Math.abs(a.a),C=r*Math.abs(a.a);A.save(),A.translate(c,I),g!==0&&A.rotate(-g*(Math.PI/180)),A.beginPath(),A.ellipse(0,0,l,B,0,0,Math.PI*2),o&&(A.fillStyle=o,A.fill()),s&&(A.strokeStyle=s,A.lineWidth=C,A.stroke()),A.restore()}function GD(t){const{ctx:A,center:e,width:i,height:n,fill:o,realToCanvasMat:s,rotation:r=0,stroke:a,strokeWidth:g}=t,[c,I]=Bn(s,[e.x,e.y]),l=i*Math.abs(s.a),B=n*Math.abs(s.a),C=g?g*Math.abs(s.a):void 0;if(A.save(),A.translate(c,I),r!==0&&A.rotate(-r*(Math.PI/180)),A.beginPath(),l>B){const Q=B/2,h=l-B;A.moveTo(-h/2,-Q),A.lineTo(h/2,-Q),A.arc(h/2,0,Q,-Math.PI/2,Math.PI/2),A.lineTo(-h/2,Q),A.arc(-h/2,0,Q,Math.PI/2,-Math.PI/2)}else if(B>l){const Q=l/2,h=B-l;A.moveTo(Q,-h/2),A.lineTo(Q,h/2),A.arc(0,h/2,Q,0,Math.PI),A.lineTo(-Q,-h/2),A.arc(0,-h/2,Q,Math.PI,0)}else A.arc(0,0,l/2,0,Math.PI*2);A.closePath(),o&&(A.fillStyle=o,A.fill()),a&&C&&(A.strokeStyle=a,A.lineWidth=C,A.stroke()),A.restore()}function u9(t){return"ccw_rotation"in t&&typeof t.ccw_rotation=="number"?t.ccw_rotation:0}function O3t(t){const{ctx:A,hole:e,realToCanvasMat:i,colorMap:n,soldermaskMargin:o=0,drawSoldermask:s=!1}=t;if(s&&e.is_covered_with_solder_mask===!0)return;const r=o<0?Math.abs(o):0;if(e.hole_shape==="circle"){FD({ctx:A,center:{x:e.x,y:e.y},radius:e.hole_diameter/2-r,fill:n.drill,realToCanvasMat:i});return}if(e.hole_shape==="square"){const a=u9(e);M0({ctx:A,center:{x:e.x,y:e.y},width:e.hole_diameter-r*2,height:e.hole_diameter-r*2,fill:n.drill,realToCanvasMat:i,rotation:a});return}if(e.hole_shape==="oval"){const a=u9(e);aJ({ctx:A,center:{x:e.x,y:e.y},radius_x:e.hole_width/2-r,radius_y:e.hole_height/2-r,fill:n.drill,realToCanvasMat:i,rotation:a});return}if(e.hole_shape==="rect"){const a=u9(e);M0({ctx:A,center:{x:e.x,y:e.y},width:e.hole_width-r*2,height:e.hole_height-r*2,fill:n.drill,realToCanvasMat:i,rotation:a});return}if(e.hole_shape==="pill"||e.hole_shape==="rotated_pill"){const a=u9(e);GD({ctx:A,center:{x:e.x,y:e.y},width:e.hole_width-r*2,height:e.hole_height-r*2,fill:n.drill,realToCanvasMat:i,rotation:a});return}}function W3t(t,A){const e=parseInt(t.slice(1,3),16),i=parseInt(t.slice(3,5),16),n=parseInt(t.slice(5,7),16);return`rgba(${e}, ${i}, ${n}, ${A})`}function Z3t(t){const{ctx:A,keepout:e,realToCanvasMat:i,colorMap:n}=t,o=n.keepout,s=W3t(n.keepout,.2),r=1;if(e.shape==="rect"){const[a,g]=Bn(i,[e.center.x,e.center.y]),c=e.width*Math.abs(i.a),I=e.height*Math.abs(i.a),l=e.rotation??0;A.save(),A.translate(a,g),l!==0&&A.rotate(-l*(Math.PI/180)),A.beginPath(),A.rect(-c/2,-I/2,c,I),A.fillStyle=s,A.fill(),A.beginPath(),A.rect(-c/2,-I/2,c,I),A.clip();const B=r*Math.abs(i.a),C=Math.sqrt(c*c+I*I),Q=c/2,h=I/2;A.strokeStyle=o,A.lineWidth=.15*Math.abs(i.a),A.setLineDash([]);for(let E=-C;E<C*2;E+=B){A.beginPath();const u=-Q+E,d=-h,p=-Q+E+C,m=-h+C;A.moveTo(u,d),A.lineTo(p,m),A.stroke()}A.restore();return}if(e.shape==="circle"){const[a,g]=Bn(i,[e.center.x,e.center.y]),c=e.radius*Math.abs(i.a),I=r*Math.abs(i.a);A.save(),A.translate(a,g),A.beginPath(),A.arc(0,0,c,0,Math.PI*2),A.fillStyle=s,A.fill(),A.beginPath(),A.arc(0,0,c,0,Math.PI*2),A.clip();const l=c*2;A.strokeStyle=o,A.lineWidth=.15*Math.abs(i.a),A.setLineDash([]);for(let B=-l;B<l*2;B+=I)A.beginPath(),A.moveTo(B-l,-l),A.lineTo(B+l,l),A.stroke();A.restore();return}}var V3t="rgba(255,255,255,0.5)";function j3t(t){const{ctx:A,pcbNoteDimension:e,realToCanvasMat:i}=t,n=e.color??V3t;xge({ctx:A,from:e.from,to:e.to,realToCanvasMat:i,color:n,fontSize:e.font_size,arrowSize:e.arrow_size,text:e.text,textRotation:e.text_ccw_rotation,offset:e.offset_distance&&e.offset_direction?{distance:e.offset_distance,direction:e.offset_direction}:void 0})}function z3t(t){const{ctx:A,line:e,realToCanvasMat:i}=t,o=e.color??"rgb(89, 148, 220)",s=e.stroke_width??.1,r=e.is_dashed??!1,[a,g]=Bn(i,[e.x1,e.y1]),[c,I]=Bn(i,[e.x2,e.y2]),l=s*Math.abs(i.a);A.save(),r?A.setLineDash([l*2,l*2]):A.setLineDash([]),A.beginPath(),A.moveTo(a,g),A.lineTo(c,I),A.lineWidth=l,A.strokeStyle=o,A.lineCap="round",A.stroke(),A.restore()}function X3t(t){const{ctx:A,path:e,realToCanvasMat:i}=t,o=e.color??"rgb(89, 148, 220)";if(!(!e.route||e.route.length<2))for(let s=0;s<e.route.length-1;s++){const r=e.route[s],a=e.route[s+1];!r||!a||rJ({ctx:A,start:{x:r.x,y:r.y},end:{x:a.x,y:a.y},strokeWidth:e.stroke_width??.1,stroke:o,realToCanvasMat:i})}}function $3t(t){const{ctx:A,rect:e,realToCanvasMat:i}=t,o=e.color??"rgb(89, 148, 220)",s=e.is_filled??!1,r=e.has_stroke??!0,a=e.is_stroke_dashed??!1;M0({ctx:A,center:e.center,width:e.width,height:e.height,fill:s?o:void 0,stroke:r?o:void 0,strokeWidth:r?e.stroke_width:void 0,borderRadius:e.corner_radius,realToCanvasMat:i,isStrokeDashed:a})}var AOt="rgb(89, 148, 220)";function eOt(t){const{ctx:A,text:e,realToCanvasMat:i}=t,n=AOt,o=e.color??n,s=e.font_size??1;BfA({ctx:A,text:e.text??"",x:e.anchor_position.x,y:e.anchor_position.y,fontSize:s,color:o,realToCanvasMat:i,anchorAlignment:e.anchor_alignment??"center"})}function tOt(t){const{ctx:A,panel:e,realToCanvasMat:i,colorMap:n,drawBoardMaterial:o}=t,{width:s,height:r,center:a}=e;if(s!==void 0&&r!==void 0&&a){o&&M0({ctx:A,center:a,width:s,height:r,fill:n.substrate,realToCanvasMat:i});const g=s/2,c=r/2,I=[{x:a.x-g,y:a.y-c},{x:a.x+g,y:a.y-c},{x:a.x+g,y:a.y+c},{x:a.x-g,y:a.y+c}];h9({ctx:A,points:I,stroke:n.boardOutline,strokeWidth:.5,realToCanvasMat:i,closePath:!0})}}function gJ(t,A){if(t.length<3||A===0)return t;let e=0,i=0;for(const o of t)e+=o.x,i+=o.y;e/=t.length,i/=t.length;const n=[];for(const o of t){const s=o.x-e,r=o.y-i,a=Math.sqrt(s*s+r*r);if(a>0){const g=s/a,c=r/a;n.push({x:o.x+g*A,y:o.y+c*A})}else n.push({x:o.x+A,y:o.y})}return n}function iOt(t){const{ctx:A,hole:e,realToCanvasMat:i,colorMap:n,soldermaskMargin:o=0,drawSoldermask:s}=t;if(e.is_covered_with_solder_mask===!0&&s)return;const r=n.copper.top,a=o<0?Math.abs(o):0;if(e.shape==="circle"){FD({ctx:A,center:{x:e.x,y:e.y},radius:e.outer_diameter/2-a,fill:r,realToCanvasMat:i}),FD({ctx:A,center:{x:e.x,y:e.y},radius:e.hole_diameter/2,fill:n.drill,realToCanvasMat:i});return}if(e.shape==="oval"){aJ({ctx:A,center:{x:e.x,y:e.y},radius_x:e.outer_width/2-a,radius_y:e.outer_height/2-a,fill:r,realToCanvasMat:i,rotation:e.ccw_rotation}),aJ({ctx:A,center:{x:e.x,y:e.y},radius_x:e.hole_width/2,radius_y:e.hole_height/2,fill:n.drill,realToCanvasMat:i,rotation:e.ccw_rotation});return}if(e.shape==="pill"){GD({ctx:A,center:{x:e.x,y:e.y},width:e.outer_width-a*2,height:e.outer_height-a*2,fill:r,realToCanvasMat:i,rotation:e.ccw_rotation}),GD({ctx:A,center:{x:e.x,y:e.y},width:e.hole_width,height:e.hole_height,fill:n.drill,realToCanvasMat:i,rotation:e.ccw_rotation});return}if(e.shape==="circular_hole_with_rect_pad"){M0({ctx:A,center:{x:e.x,y:e.y},width:e.rect_pad_width-a*2,height:e.rect_pad_height-a*2,fill:r,realToCanvasMat:i,borderRadius:e.rect_border_radius?Math.max(0,e.rect_border_radius-a):0});const g=e.x+(e.hole_offset_x??0),c=e.y+(e.hole_offset_y??0);FD({ctx:A,center:{x:g,y:c},radius:e.hole_diameter/2,fill:n.drill,realToCanvasMat:i});return}if(e.shape==="pill_hole_with_rect_pad"){M0({ctx:A,center:{x:e.x,y:e.y},width:e.rect_pad_width-a*2,height:e.rect_pad_height-a*2,fill:r,realToCanvasMat:i,borderRadius:e.rect_border_radius?Math.max(0,e.rect_border_radius-a):0});const g=e.x+(e.hole_offset_x??0),c=e.y+(e.hole_offset_y??0);GD({ctx:A,center:{x:g,y:c},width:e.hole_width,height:e.hole_height,fill:n.drill,realToCanvasMat:i});return}if(e.shape==="rotated_pill_hole_with_rect_pad"){M0({ctx:A,center:{x:e.x,y:e.y},width:e.rect_pad_width-a*2,height:e.rect_pad_height-a*2,fill:r,realToCanvasMat:i,borderRadius:e.rect_border_radius?Math.max(0,e.rect_border_radius-a):0,rotation:e.rect_ccw_rotation});const g=e.x+(e.hole_offset_x??0),c=e.y+(e.hole_offset_y??0);GD({ctx:A,center:{x:g,y:c},width:e.hole_width,height:e.hole_height,fill:n.drill,realToCanvasMat:i,rotation:e.hole_ccw_rotation});return}if(e.shape==="hole_with_polygon_pad"){const g=e.pad_outline;if(g&&g.length>=3){const B=g.map(Q=>({x:e.x+Q.x,y:e.y+Q.y})),C=a>0?gJ(B,-a):B;C.length>=3&&sJ({ctx:A,points:C,fill:r,realToCanvasMat:i})}const c=e.x+(e.hole_offset_x??0),I=e.y+(e.hole_offset_y??0),l=e.hole_shape;l==="circle"?FD({ctx:A,center:{x:c,y:I},radius:(e.hole_diameter??0)/2,fill:n.drill,realToCanvasMat:i}):l==="oval"?aJ({ctx:A,center:{x:c,y:I},radius_x:(e.hole_width??0)/2,radius_y:(e.hole_height??0)/2,fill:n.drill,realToCanvasMat:i}):l==="pill"?GD({ctx:A,center:{x:c,y:I},width:e.hole_width??0,height:e.hole_height??0,fill:n.drill,realToCanvasMat:i}):l==="rotated_pill"&&GD({ctx:A,center:{x:c,y:I},width:e.hole_width??0,height:e.hole_height??0,fill:n.drill,realToCanvasMat:i});return}}function nOt(t,A){return t==="bottom"?A.silkscreen.bottom:A.silkscreen.top}function oOt(t){const{ctx:A,circle:e,realToCanvasMat:i,colorMap:n}=t,o=nOt(e.layer,n);FD({ctx:A,center:e.center,radius:e.radius,stroke:o,strokeWidth:e.stroke_width,realToCanvasMat:i})}function sOt(t,A){return t==="bottom"?A.silkscreen.bottom:A.silkscreen.top}function rOt(t){const{ctx:A,line:e,realToCanvasMat:i,colorMap:n}=t,o=sOt(e.layer,n);rJ({ctx:A,start:{x:e.x1,y:e.y1},end:{x:e.x2,y:e.y2},strokeWidth:e.stroke_width??.1,stroke:o,realToCanvasMat:i})}function aOt(t,A){return t==="bottom"?A.silkscreen.bottom:A.silkscreen.top}function gOt(t){const{ctx:A,oval:e,realToCanvasMat:i,colorMap:n}=t,o=aOt(e.layer,n);aJ({ctx:A,center:e.center,radius_x:e.radius_x,radius_y:e.radius_y,stroke:o,strokeWidth:.1,realToCanvasMat:i,rotation:e.ccw_rotation??0})}function cOt(t,A){return t==="bottom"?A.silkscreen.bottom:A.silkscreen.top}function IOt(t){const{ctx:A,path:e,realToCanvasMat:i,colorMap:n}=t,o=cOt(e.layer,n);if(!(!e.route||e.route.length<2))for(let s=0;s<e.route.length-1;s++){const r=e.route[s],a=e.route[s+1];!r||!a||rJ({ctx:A,start:{x:r.x,y:r.y},end:{x:a.x,y:a.y},strokeWidth:e.stroke_width??.1,stroke:o,realToCanvasMat:i})}}function lOt(t,A){return t==="bottom"?A.silkscreen.bottom:A.silkscreen.top}function BOt(t){const{ctx:A,pill:e,realToCanvasMat:i,colorMap:n}=t,o=lOt(e.layer,n);GD({ctx:A,center:e.center,width:e.width,height:e.height,stroke:o,strokeWidth:.2,realToCanvasMat:i})}function COt(t,A){return t==="bottom"?A.silkscreen.bottom:A.silkscreen.top}function QOt(t){const{ctx:A,rect:e,realToCanvasMat:i,colorMap:n}=t,o=COt(e.layer,n);M0({ctx:A,center:e.center,width:e.width,height:e.height,fill:e.is_filled?o:"transparent",stroke:o,strokeWidth:e.stroke_width,realToCanvasMat:i})}function hOt(t,A){return t==="bottom"?A.silkscreen.bottom:A.silkscreen.top}function EOt(t){return t||"center"}function uOt(t){const{ctx:A,text:e,realToCanvasMat:i,colorMap:n}=t,o=e.text??"";if(!o)return;const s=hOt(e.layer,n),[r,a]=Bn(i,[e.anchor_position.x,e.anchor_position.y]),g=Math.abs(i.a),c=(e.font_size??1)*g,I=e.ccw_rotation??0,l=E9(o,c),B=EOt(e.anchor_alignment),C=cfA(B,l);A.save(),A.translate(r,a),I!==0&&A.rotate(-I*(Math.PI/180)),e.layer==="bottom"&&A.scale(-1,1),A.lineWidth=l.strokeWidth,A.lineCap="round",A.lineJoin="round",A.strokeStyle=s;const{lines:Q,lineWidths:h,lineHeight:E,width:u,strokeWidth:d}=l;Q.forEach((p,m)=>{const D=C.x+IfA({alignment:B,lineWidth:h[m],maxWidth:u,strokeWidth:d}),w=C.y+m*E;lfA({ctx:A,line:p,fontSize:c,startX:D,startY:w,layout:l})}),A.restore()}function dOt(t,A){return A.copper[t]??A.copper.top}function _ge(t){return t.shape==="rect"||t.shape==="rotated_rect"?t.corner_radius??t.rect_border_radius??0:0}function pOt(t){const{ctx:A,pad:e,realToCanvasMat:i,colorMap:n}=t,o=dOt(e.layer,n);if(e.shape==="rect"){M0({ctx:A,center:{x:e.x,y:e.y},width:e.width,height:e.height,fill:o,realToCanvasMat:i,borderRadius:_ge(e)});return}if(e.shape==="rotated_rect"){M0({ctx:A,center:{x:e.x,y:e.y},width:e.width,height:e.height,fill:o,realToCanvasMat:i,borderRadius:_ge(e),rotation:e.ccw_rotation??0});return}if(e.shape==="circle"){FD({ctx:A,center:{x:e.x,y:e.y},radius:e.radius,fill:o,realToCanvasMat:i});return}if(e.shape==="pill"){GD({ctx:A,center:{x:e.x,y:e.y},width:e.width,height:e.height,fill:o,realToCanvasMat:i});return}if(e.shape==="rotated_pill"){GD({ctx:A,center:{x:e.x,y:e.y},width:e.width,height:e.height,fill:o,realToCanvasMat:i,rotation:e.ccw_rotation??0});return}if(e.shape==="polygon"){e.points&&e.points.length>=3&&sJ({ctx:A,points:e.points,fill:o,realToCanvasMat:i});return}}function P_(t){const{ctx:A,points:e}=t;if(e.length<3)return;const i=e[0];if(i){A.moveTo(i.x,i.y);for(let n=1;n<e.length;n++){const o=e[n];o&&A.lineTo(o.x,o.y)}A.closePath()}}function fOt(t){const{ctx:A,board:e,realToCanvasMat:i,soldermaskColor:n}=t,{width:o,height:s,center:r,outline:a}=e;if(a&&Array.isArray(a)&&a.length>=3){const g=a.map(c=>{const[I,l]=Bn(i,[c.x,c.y]);return{x:I,y:l}});A.beginPath(),P_({ctx:A,points:g}),A.fillStyle=n,A.fill()}else if(o!==void 0&&s!==void 0&&r){const[g,c]=Bn(i,[r.x,r.y]),I=o*Math.abs(i.a),l=s*Math.abs(i.a);A.fillStyle=n,A.fillRect(g-I/2,c-l/2,I,l)}}function q_(t){const{ctx:A,cx:e,cy:i,width:n,height:o,radius:s}=t,r=e-n/2,a=i-o/2,g=Math.min(s,n/2,o/2);g>0?(A.moveTo(r+g,a),A.lineTo(r+n-g,a),A.arcTo(r+n,a,r+n,a+g,g),A.lineTo(r+n,a+o-g),A.arcTo(r+n,a+o,r+n-g,a+o,g),A.lineTo(r+g,a+o),A.arcTo(r,a+o,r,a+o-g,g),A.lineTo(r,a+g),A.arcTo(r,a,r+g,a,g)):A.rect(r,a,n,o),A.closePath()}function yOt(t){const{ctx:A,cutout:e,realToCanvasMat:i,colorMap:n}=t;if(A.fillStyle=n.drill,e.shape==="rect"){const[o,s]=Bn(i,[e.center?.x??0,e.center?.y??0]),r=e.width*Math.abs(i.a),a=e.height*Math.abs(i.a),g=(e.corner_radius??0)*Math.abs(i.a);A.save(),A.translate(o,s),e.rotation&&A.rotate(-e.rotation*Math.PI/180),A.beginPath(),q_({ctx:A,cx:0,cy:0,width:r,height:a,radius:g}),A.restore(),A.fill()}else if(e.shape==="circle"){const[o,s]=Bn(i,[e.center?.x??0,e.center?.y??0]),r=e.radius*Math.abs(i.a);A.beginPath(),A.arc(o,s,r,0,Math.PI*2),A.closePath(),A.fill()}else if(e.shape==="polygon"&&e.points&&e.points.length>=3){const o=e.points.map(s=>{const[r,a]=Bn(i,[s.x,s.y]);return{x:r,y:a}});A.beginPath(),P_({ctx:A,points:o}),A.fill()}}function yb(t){const{ctx:A,cx:e,cy:i,width:n,height:o}=t;if(n>o){const s=o/2,r=n-o;A.moveTo(e-r/2,i-s),A.lineTo(e+r/2,i-s),A.arc(e+r/2,i,s,-Math.PI/2,Math.PI/2),A.lineTo(e-r/2,i+s),A.arc(e-r/2,i,s,Math.PI/2,-Math.PI/2)}else if(o>n){const s=n/2,r=o-n;A.moveTo(e+s,i-r/2),A.lineTo(e+s,i+r/2),A.arc(e,i+r/2,s,0,Math.PI),A.lineTo(e-s,i-r/2),A.arc(e,i-r/2,s,Math.PI,0)}else A.arc(e,i,n/2,0,Math.PI*2);A.closePath()}function mOt(t){const{ctx:A,hole:e,realToCanvasMat:i,colorMap:n,soldermaskOverCopperColor:o,drawSoldermask:s}=t,r=s&&e.is_covered_with_solder_mask===!0,a=s?e.soldermask_margin??0:0;r?(A.fillStyle=o,cJ({ctx:A,hole:e,realToCanvasMat:i,margin:0}),A.fill()):a<0?(A.fillStyle=n.drill,cJ({ctx:A,hole:e,realToCanvasMat:i,margin:0}),A.fill(),wOt({ctx:A,hole:e,realToCanvasMat:i,soldermaskOverCopperColor:o,margin:a})):a>0?(A.fillStyle=n.substrate,cJ({ctx:A,hole:e,realToCanvasMat:i,margin:a}),A.fill(),A.fillStyle=n.drill,cJ({ctx:A,hole:e,realToCanvasMat:i,margin:0}),A.fill()):(A.fillStyle=n.drill,cJ({ctx:A,hole:e,realToCanvasMat:i,margin:0}),A.fill())}function kge(t){return"ccw_rotation"in t&&typeof t.ccw_rotation=="number"?t.ccw_rotation:0}function cJ(t){const{ctx:A,hole:e,realToCanvasMat:i,margin:n}=t,o=kge(e);if(e.hole_shape==="circle"){const[s,r]=Bn(i,[e.x,e.y]),a=(e.hole_diameter/2+n)*Math.abs(i.a);A.beginPath(),A.arc(s,r,a,0,Math.PI*2),A.closePath()}else if(e.hole_shape==="square"){const[s,r]=Bn(i,[e.x,e.y]),a=(e.hole_diameter+n*2)*Math.abs(i.a);A.save(),A.translate(s,r),o!==0&&A.rotate(-o*Math.PI/180),A.beginPath(),A.rect(-a/2,-a/2,a,a),A.closePath(),A.restore()}else if(e.hole_shape==="oval"){const[s,r]=Bn(i,[e.x,e.y]),a=(e.hole_width/2+n)*Math.abs(i.a),g=(e.hole_height/2+n)*Math.abs(i.a);A.save(),A.translate(s,r),o!==0&&A.rotate(-o*Math.PI/180),A.beginPath(),A.ellipse(0,0,a,g,0,0,Math.PI*2),A.closePath(),A.restore()}else if(e.hole_shape==="rect"){const[s,r]=Bn(i,[e.x,e.y]),a=(e.hole_width+n*2)*Math.abs(i.a),g=(e.hole_height+n*2)*Math.abs(i.a);A.save(),A.translate(s,r),o!==0&&A.rotate(-o*Math.PI/180),A.beginPath(),A.rect(-a/2,-g/2,a,g),A.closePath(),A.restore()}else if(e.hole_shape==="pill"||e.hole_shape==="rotated_pill"){const[s,r]=Bn(i,[e.x,e.y]),a=(e.hole_width+n*2)*Math.abs(i.a),g=(e.hole_height+n*2)*Math.abs(i.a);A.save(),A.translate(s,r),o!==0&&A.rotate(-o*Math.PI/180),A.beginPath(),yb({ctx:A,cx:0,cy:0,width:a,height:g}),A.restore()}}function wOt(t){const{ctx:A,hole:e,realToCanvasMat:i,soldermaskOverCopperColor:n,margin:o}=t,s=Math.abs(o),r=kge(e);if(A.fillStyle=n,e.hole_shape==="circle"){const[a,g]=Bn(i,[e.x,e.y]),c=e.hole_diameter/2*Math.abs(i.a),I=s*Math.abs(i.a),l=Math.max(0,c-I);A.save(),A.beginPath(),A.arc(a,g,c,0,Math.PI*2),l>0&&A.arc(a,g,l,0,Math.PI*2,!0),A.fill("evenodd"),A.restore()}else if(e.hole_shape==="square"){const[a,g]=Bn(i,[e.x,e.y]),c=e.hole_diameter*Math.abs(i.a),I=s*Math.abs(i.a),l=Math.max(0,c-I*2);A.save(),A.translate(a,g),r!==0&&A.rotate(-r*Math.PI/180),A.beginPath(),A.rect(-c/2,-c/2,c,c),l>0&&A.rect(-l/2,-l/2,l,l),A.fill("evenodd"),A.restore()}else if(e.hole_shape==="oval"){const[a,g]=Bn(i,[e.x,e.y]),c=e.hole_width/2*Math.abs(i.a),I=e.hole_height/2*Math.abs(i.a),l=s*Math.abs(i.a),B=Math.max(0,c-l),C=Math.max(0,I-l);A.save(),A.translate(a,g),r!==0&&A.rotate(-r*Math.PI/180),A.beginPath(),A.ellipse(0,0,c,I,0,0,Math.PI*2),B>0&&C>0&&(A.moveTo(B,0),A.ellipse(0,0,B,C,0,0,Math.PI*2)),A.fill("evenodd"),A.restore()}else if(e.hole_shape==="rect"){const[a,g]=Bn(i,[e.x,e.y]),c=e.hole_width*Math.abs(i.a),I=e.hole_height*Math.abs(i.a),l=s*Math.abs(i.a),B=Math.max(0,c-l*2),C=Math.max(0,I-l*2);A.save(),A.translate(a,g),r!==0&&A.rotate(-r*Math.PI/180),A.beginPath(),A.rect(-c/2,-I/2,c,I),B>0&&C>0&&A.rect(-B/2,-C/2,B,C),A.fill("evenodd"),A.restore()}else if(e.hole_shape==="pill"||e.hole_shape==="rotated_pill"){const[a,g]=Bn(i,[e.x,e.y]),c=e.hole_width*Math.abs(i.a),I=e.hole_height*Math.abs(i.a),l=s*Math.abs(i.a);A.save(),A.translate(a,g),r!==0&&A.rotate(-r*Math.PI/180),A.beginPath(),yb({ctx:A,cx:0,cy:0,width:c,height:I});const B=c-l*2,C=I-l*2;B>0&&C>0&&yb({ctx:A,cx:0,cy:0,width:B,height:C}),A.fill("evenodd"),A.restore()}}function DOt(t){const{ctx:A,hole:e,realToCanvasMat:i,colorMap:n,soldermaskOverCopperColor:o,layer:s,drawSoldermask:r}=t;if(e.layers&&!e.layers.includes(s))return;const a=r&&e.is_covered_with_solder_mask===!0,g=r?e.soldermask_margin??0:0,c=n.copper.top;a?(A.fillStyle=o,IJ({ctx:A,hole:e,realToCanvasMat:i,margin:0}),A.fill()):g<0?(A.fillStyle=c,IJ({ctx:A,hole:e,realToCanvasMat:i,margin:0}),A.fill(),SOt({ctx:A,hole:e,realToCanvasMat:i,soldermaskOverCopperColor:o,margin:g})):g>0?(A.fillStyle=n.substrate,IJ({ctx:A,hole:e,realToCanvasMat:i,margin:g}),A.fill(),A.fillStyle=c,IJ({ctx:A,hole:e,realToCanvasMat:i,margin:0}),A.fill()):(A.fillStyle=c,IJ({ctx:A,hole:e,realToCanvasMat:i,margin:0}),A.fill())}function IJ(t){const{ctx:A,hole:e,realToCanvasMat:i,margin:n}=t;if(e.shape==="circle"){const[o,s]=Bn(i,[e.x,e.y]),r=(e.outer_diameter/2+n)*Math.abs(i.a);A.beginPath(),A.arc(o,s,r,0,Math.PI*2),A.closePath()}else if(e.shape==="oval"){const[o,s]=Bn(i,[e.x,e.y]),r=(e.outer_width/2+n)*Math.abs(i.a),a=(e.outer_height/2+n)*Math.abs(i.a);A.save(),A.translate(o,s),e.ccw_rotation&&e.ccw_rotation!==0&&A.rotate(-(e.ccw_rotation*Math.PI)/180),A.beginPath(),A.ellipse(0,0,r,a,0,0,Math.PI*2),A.closePath(),A.restore()}else if(e.shape==="pill"){const[o,s]=Bn(i,[e.x,e.y]),r=(e.outer_width+n*2)*Math.abs(i.a),a=(e.outer_height+n*2)*Math.abs(i.a);A.save(),A.translate(o,s),e.ccw_rotation&&e.ccw_rotation!==0&&A.rotate(-(e.ccw_rotation*Math.PI)/180),A.beginPath(),yb({ctx:A,cx:0,cy:0,width:r,height:a}),A.restore()}else if(e.shape==="circular_hole_with_rect_pad"||e.shape==="pill_hole_with_rect_pad"){const[o,s]=Bn(i,[e.x,e.y]),r=(e.rect_pad_width+n*2)*Math.abs(i.a),a=(e.rect_pad_height+n*2)*Math.abs(i.a),g=(e.rect_border_radius??0)*Math.abs(i.a);A.beginPath(),q_({ctx:A,cx:o,cy:s,width:r,height:a,radius:g})}else if(e.shape==="rotated_pill_hole_with_rect_pad"){const[o,s]=Bn(i,[e.x,e.y]),r=(e.rect_pad_width+n*2)*Math.abs(i.a),a=(e.rect_pad_height+n*2)*Math.abs(i.a),g=(e.rect_border_radius??0)*Math.abs(i.a);A.save(),A.translate(o,s),e.rect_ccw_rotation&&A.rotate(-e.rect_ccw_rotation*Math.PI/180),A.beginPath(),q_({ctx:A,cx:0,cy:0,width:r,height:a,radius:g}),A.restore()}else if(e.shape==="hole_with_polygon_pad"&&e.pad_outline&&e.pad_outline.length>=3){const o=e.pad_outline.map(a=>({x:e.x+a.x,y:e.y+a.y})),r=(n!==0?gJ(o,n):o).map(a=>{const[g,c]=Bn(i,[a.x,a.y]);return{x:g,y:c}});A.beginPath(),P_({ctx:A,points:r})}}function SOt(t){const{ctx:A,hole:e,realToCanvasMat:i,soldermaskOverCopperColor:n,margin:o}=t,s=Math.abs(o);if(A.fillStyle=n,e.shape==="circle"){const[r,a]=Bn(i,[e.x,e.y]),g=e.outer_diameter/2*Math.abs(i.a),c=s*Math.abs(i.a),I=Math.max(0,g-c);A.save(),A.beginPath(),A.arc(r,a,g,0,Math.PI*2),I>0&&A.arc(r,a,I,0,Math.PI*2,!0),A.fill("evenodd"),A.restore()}else if(e.shape==="oval"){const[r,a]=Bn(i,[e.x,e.y]),g=e.outer_width/2*Math.abs(i.a),c=e.outer_height/2*Math.abs(i.a),I=s*Math.abs(i.a),l=Math.max(0,g-I),B=Math.max(0,c-I);A.save(),A.translate(r,a),e.ccw_rotation&&e.ccw_rotation!==0&&A.rotate(-(e.ccw_rotation*Math.PI)/180),A.beginPath(),A.ellipse(0,0,g,c,0,0,Math.PI*2),l>0&&B>0&&(A.moveTo(l,0),A.ellipse(0,0,l,B,0,0,Math.PI*2)),A.fill("evenodd"),A.restore()}else if(e.shape==="pill"){const[r,a]=Bn(i,[e.x,e.y]),g=e.outer_width*Math.abs(i.a),c=e.outer_height*Math.abs(i.a),I=s*Math.abs(i.a);A.save(),A.translate(r,a),e.ccw_rotation&&e.ccw_rotation!==0&&A.rotate(-(e.ccw_rotation*Math.PI)/180),A.beginPath(),yb({ctx:A,cx:0,cy:0,width:g,height:c});const l=g-I*2,B=c-I*2;l>0&&B>0&&yb({ctx:A,cx:0,cy:0,width:l,height:B}),A.fill("evenodd"),A.restore()}else if(e.shape==="circular_hole_with_rect_pad"||e.shape==="pill_hole_with_rect_pad"||e.shape==="rotated_pill_hole_with_rect_pad"){const[r,a]=Bn(i,[e.x,e.y]),g=e.rect_pad_width*Math.abs(i.a),c=e.rect_pad_height*Math.abs(i.a),I=s*Math.abs(i.a);A.save(),A.translate(r,a),e.shape==="rotated_pill_hole_with_rect_pad"&&e.rect_ccw_rotation&&A.rotate(-e.rect_ccw_rotation*Math.PI/180);const l=e.rect_border_radius?e.rect_border_radius*Math.abs(i.a):0;A.beginPath(),q_({ctx:A,cx:0,cy:0,width:g,height:c,radius:l});const B=g-I*2,C=c-I*2;if(B>0&&C>0){const Q=Math.max(0,l-I);q_({ctx:A,cx:0,cy:0,width:B,height:C,radius:Q})}A.fill("evenodd"),A.restore()}else if(e.shape==="hole_with_polygon_pad"&&e.pad_outline&&e.pad_outline.length>=3){const r=e.pad_outline.map(c=>({x:e.x+c.x,y:e.y+c.y}));A.save(),A.beginPath();const a=r.map(c=>{const[I,l]=Bn(i,[c.x,c.y]);return{x:I,y:l}});P_({ctx:A,points:a});const g=gJ(r,-s);if(g.length>=3){const c=g.map(I=>{const[l,B]=Bn(i,[I.x,I.y]);return{x:l,y:B}});P_({ctx:A,points:c})}A.fill("evenodd"),A.restore()}}function bOt(t){const{ctx:A,pad:e,realToCanvasMat:i,colorMap:n,soldermaskOverCopperColor:o,layer:s,drawSoldermask:r}=t;if(e.layer!==s)return;const a=r&&e.is_covered_with_solder_mask===!0,g=r?e.soldermask_margin??0:0;let c=g,I=g,l=g,B=g;(e.shape==="rect"||e.shape==="rotated_rect")&&(c=e.soldermask_margin_left??g,I=e.soldermask_margin_right??g,l=e.soldermask_margin_top??g,B=e.soldermask_margin_bottom??g);const C=n.copper[e.layer]||n.copper.top;a?(A.fillStyle=o,lJ({ctx:A,pad:e,realToCanvasMat:i,ml:0,mr:0,mt:0,mb:0}),A.fill()):c<0||I<0||l<0||B<0?(A.fillStyle=C,lJ({ctx:A,pad:e,realToCanvasMat:i,ml:0,mr:0,mt:0,mb:0}),A.fill(),xOt({ctx:A,pad:e,realToCanvasMat:i,soldermaskOverCopperColor:o,ml:c,mr:I,mt:l,mb:B})):c>0||I>0||l>0||B>0?(A.fillStyle=n.substrate,lJ({ctx:A,pad:e,realToCanvasMat:i,ml:c,mr:I,mt:l,mb:B}),A.fill(),A.fillStyle=C,lJ({ctx:A,pad:e,realToCanvasMat:i,ml:0,mr:0,mt:0,mb:0}),A.fill()):(A.fillStyle=C,lJ({ctx:A,pad:e,realToCanvasMat:i,ml:0,mr:0,mt:0,mb:0}),A.fill())}function lJ(t){const{ctx:A,pad:e,realToCanvasMat:i,ml:n,mr:o,mt:s,mb:r}=t,a=e.shape==="rotated_rect"||e.shape==="rotated_pill"?e.ccw_rotation??0:0;if(e.shape==="rect"||e.shape==="rotated_rect"){const g=e.corner_radius??e.rect_border_radius??0,c=a*Math.PI/180,I=(o-n)/2,l=(s-r)/2,B=I*Math.cos(c)-l*Math.sin(c),C=I*Math.sin(c)+l*Math.cos(c),[Q,h]=Bn(i,[e.x+B,e.y+C]),E=(e.width+n+o)*Math.abs(i.a),u=(e.height+s+r)*Math.abs(i.a),d=g*Math.abs(i.a);A.save(),A.translate(Q,h),a!==0&&A.rotate(-a*Math.PI/180),A.beginPath(),q_({ctx:A,cx:0,cy:0,width:E,height:u,radius:d}),A.restore()}else if(e.shape==="circle"){const g=(n+o+s+r)/4,[c,I]=Bn(i,[e.x,e.y]),l=(e.radius+g)*Math.abs(i.a);A.beginPath(),A.arc(c,I,l,0,Math.PI*2),A.closePath()}else if(e.shape==="pill"||e.shape==="rotated_pill"){const g=(n+o)/2,[c,I]=Bn(i,[e.x,e.y]),l=(e.width+g*2)*Math.abs(i.a),B=(e.height+g*2)*Math.abs(i.a);A.save(),A.translate(c,I),a!==0&&A.rotate(-a*Math.PI/180),A.beginPath(),yb({ctx:A,cx:0,cy:0,width:l,height:B}),A.restore()}else if(e.shape==="polygon"&&e.points&&e.points.length>=3){const g=(n+o+s+r)/4,I=(g!==0?gJ(e.points,g):e.points).map(l=>{const[B,C]=Bn(i,[l.x,l.y]);return{x:B,y:C}});A.beginPath(),P_({ctx:A,points:I})}}function xOt(t){const{ctx:A,pad:e,realToCanvasMat:i,soldermaskOverCopperColor:n,ml:o,mr:s,mt:r,mb:a}=t,g=e.shape==="rotated_rect"||e.shape==="rotated_pill"?e.ccw_rotation??0:0,c=Math.max(0,-o),I=Math.max(0,-s),l=Math.max(0,-r),B=Math.max(0,-a);if(A.fillStyle=n,e.shape==="rect"||e.shape==="rotated_rect"){const C=e.corner_radius??e.rect_border_radius??0,[Q,h]=Bn(i,[e.x,e.y]),E=e.width*Math.abs(i.a),u=e.height*Math.abs(i.a),d=C*Math.abs(i.a),p=c*Math.abs(i.a),m=I*Math.abs(i.a),D=l*Math.abs(i.a),w=B*Math.abs(i.a);A.save(),A.translate(Q,h),g!==0&&A.rotate(-g*Math.PI/180),A.beginPath(),q_({ctx:A,cx:0,cy:0,width:E,height:u,radius:d});const b=E-p-m,k=u-D-w,x=(p-m)/2,N=(D-w)/2,M=Math.max(0,d-(p+m+D+w)/4);b>0&&k>0&&q_({ctx:A,cx:x,cy:N,width:b,height:k,radius:M}),A.fill("evenodd"),A.restore()}else if(e.shape==="circle"){const C=Math.max(c,I,l,B),[Q,h]=Bn(i,[e.x,e.y]),E=e.radius*Math.abs(i.a),u=C*Math.abs(i.a),d=Math.max(0,E-u);A.save(),A.beginPath(),A.arc(Q,h,E,0,Math.PI*2),d>0&&A.arc(Q,h,d,0,Math.PI*2,!0),A.fill("evenodd"),A.restore()}else if(e.shape==="pill"||e.shape==="rotated_pill"){const C=Math.max(c,I,l,B),[Q,h]=Bn(i,[e.x,e.y]),E=e.width*Math.abs(i.a),u=e.height*Math.abs(i.a),d=C*Math.abs(i.a);A.save(),A.translate(Q,h),g!==0&&A.rotate(-g*Math.PI/180),A.beginPath(),yb({ctx:A,cx:0,cy:0,width:E,height:u});const p=E-d*2,m=u-d*2;p>0&&m>0&&yb({ctx:A,cx:0,cy:0,width:p,height:m}),A.fill("evenodd"),A.restore()}else if(e.shape==="polygon"&&e.points&&e.points.length>=3){const C=Math.max(c,I,l,B);A.save(),A.beginPath();const Q=e.points.map(E=>{const[u,d]=Bn(i,[E.x,E.y]);return{x:u,y:d}});P_({ctx:A,points:Q});const h=gJ(e.points,-C);if(h.length>=3){const E=h.map(u=>{const[d,p]=Bn(i,[u.x,u.y]);return{x:d,y:p}});P_({ctx:A,points:E})}A.fill("evenodd"),A.restore()}}function _Ot(t){const{ctx:A,via:e,realToCanvasMat:i,colorMap:n}=t,[o,s]=Bn(i,[e.x,e.y]),r=e.outer_diameter/2*Math.abs(i.a);A.fillStyle=n.substrate,A.beginPath(),A.arc(o,s,r,0,Math.PI*2),A.closePath(),A.fill()}function kOt(t){const{ctx:A,board:e,elements:i,realToCanvasMat:n,colorMap:o,layer:s,drawSoldermask:r}=t,a=o.soldermask[s]??o.soldermask.top,g=o.soldermaskOverCopper[s]??o.soldermaskOverCopper.top;r&&fOt({ctx:A,board:e,realToCanvasMat:n,soldermaskColor:a});for(const c of i)FOt({ctx:A,element:c,realToCanvasMat:n,colorMap:o,soldermaskOverCopperColor:g,layer:s,drawSoldermask:r})}function FOt(t){const{ctx:A,element:e,realToCanvasMat:i,colorMap:n,soldermaskOverCopperColor:o,layer:s,drawSoldermask:r}=t;e.type==="pcb_smtpad"?bOt({ctx:A,pad:e,realToCanvasMat:i,colorMap:n,soldermaskOverCopperColor:o,layer:s,drawSoldermask:r}):e.type==="pcb_plated_hole"?DOt({ctx:A,hole:e,realToCanvasMat:i,colorMap:n,soldermaskOverCopperColor:o,layer:s,drawSoldermask:r}):e.type==="pcb_hole"?mOt({ctx:A,hole:e,realToCanvasMat:i,colorMap:n,soldermaskOverCopperColor:o,drawSoldermask:r}):e.type==="pcb_via"?_Ot({ctx:A,via:e,realToCanvasMat:i,colorMap:n}):e.type==="pcb_cutout"&&yOt({ctx:A,cutout:e,realToCanvasMat:i,colorMap:n})}function jv(t,A){const e=Math.hypot(t,A);return e<=Number.EPSILON?{x:0,y:0}:{x:t/e,y:A/e}}function GOt(t,A){const e=t.length;if(e<2)return{x:1,y:0};if(A<=0){const g=t[1],c=t[0];if(!g||!c)return{x:1,y:0};const I=jv(g.x-c.x,g.y-c.y);return I.x===0&&I.y===0?{x:1,y:0}:I}if(A>=e-1){const g=t[e-2],c=t[e-1];if(!g||!c)return{x:1,y:0};const I=jv(c.x-g.x,c.y-g.y);return I.x===0&&I.y===0?{x:1,y:0}:I}const i=t[A-1],n=t[A],o=t[A+1];if(!i||!n||!o)return{x:1,y:0};const s=jv(n.x-i.x,n.y-i.y),r=jv(o.x-n.x,o.y-n.y),a=jv(s.x+r.x,s.y+r.y);return a.x===0&&a.y===0?s.x!==0||s.y!==0?s:r.x!==0||r.y!==0?r:{x:1,y:0}:a}function ROt(t){const A=[],e=[];for(let i=0;i<t.length;i++){const n=t[i];if(!n)continue;const o=GOt(t,i),s=jv(-o.y,o.x),r=n.width/2;A.push({x:n.x+s.x*r,y:n.y+s.y*r}),e.push({x:n.x-s.x*r,y:n.y-s.y*r})}return A.concat(e.reverse())}function MOt(t){const A=[];let e=[],i=null;for(const n of t??[]){if(!n||n.route_type!=="wire"){e.length>=2&&A.push(e),e=[],i=null;continue}const o=n.layer??i;if(!o)continue;const s=n.x,r=n.y;if(typeof s!="number"||typeof r!="number"||typeof n.width!="number")continue;const a=n.width;i&&o!==i&&(e.length>=2&&A.push(e),e=[]),i=o,e.push({route_type:"wire",x:s,y:r,width:a,layer:o,start_pcb_port_id:"start_pcb_port_id"in n?n.start_pcb_port_id:void 0,end_pcb_port_id:"end_pcb_port_id"in n?n.end_pcb_port_id:void 0})}return e.length>=2&&A.push(e),A}function NOt(t){if(t.length<2)return!1;const A=t[0]?.width;return typeof A!="number"?!1:t.some(e=>Math.abs(e.width-A)>Number.EPSILON)}function vOt(t,A){return A.copper[t]??A.copper.top}function LOt(t){const{ctx:A,trace:e,realToCanvasMat:i,colorMap:n}=t;if(!e.route||!Array.isArray(e.route)||e.route.length<2)return;const o=MOt(e.route);for(const s of o){const r=s[0]?.layer;if(!r)continue;const a=vOt(r,n);if(NOt(s)){const g=ROt(s);sJ({ctx:A,points:g,fill:a,realToCanvasMat:i});continue}for(let g=0;g<s.length-1;g++){const c=s[g],I=s[g+1];!c||!I||rJ({ctx:A,start:{x:c.x,y:c.y},end:{x:I.x,y:I.y},strokeWidth:c.width,stroke:a,realToCanvasMat:i,lineCap:"round"})}}}function UOt(t){const{ctx:A,via:e,realToCanvasMat:i,colorMap:n}=t;FD({ctx:A,center:{x:e.x,y:e.y},radius:e.outer_diameter/2,fill:n.copper.top,realToCanvasMat:i}),FD({ctx:A,center:{x:e.x,y:e.y},radius:e.hole_diameter/2,fill:n.drill,realToCanvasMat:i})}function DG(t,A){if(!A.layers||A.layers.length===0)return!0;const e=C1A(t);return e.length===0?!0:e.some(i=>A.layers.includes(i))}var pf={copper:{top:"rgb(200, 52, 52)",inner1:"rgb(255, 140, 0)",inner2:"rgb(255, 215, 0)",inner3:"rgb(50, 205, 50)",inner4:"rgb(64, 224, 208)",inner5:"rgb(138, 43, 226)",inner6:"rgb(255, 105, 180)",bottom:"rgb(77, 127, 196)"},soldermaskWithCopperUnderneath:{top:"rgb(18, 82, 50)",bottom:"rgb(77, 127, 196)"},soldermask:{top:"rgb(12, 55, 33)",bottom:"rgb(12, 55, 33)"},soldermaskOverCopper:{top:"rgb(52, 135, 73)",bottom:"rgb(52, 135, 73)"},substrate:"rgb(201, 162, 110)",drill:"#FF26E2",silkscreen:{top:"#f2eda1",bottom:"#5da9e9"},boardOutline:"rgba(255, 255, 255, 0.5)",courtyard:"#FF00FF",keepout:"#FF6B6B"},RQ=class{ctx;colorMap;realToCanvasMat;constructor(t){if("getContext"in t&&typeof t.getContext=="function"){const A=t.getContext("2d");if(!A)throw new Error("Failed to get 2D rendering context from canvas");this.ctx=A}else this.ctx=t;this.colorMap={...pf},this.realToCanvasMat=u3t()}configure(t){t.colorOverrides&&(this.colorMap={...this.colorMap,...t.colorOverrides,copper:{...this.colorMap.copper,...t.colorOverrides.copper},silkscreen:{...this.colorMap.silkscreen,...t.colorOverrides.silkscreen},soldermask:{...this.colorMap.soldermask,...t.colorOverrides.soldermask},soldermaskWithCopperUnderneath:{...this.colorMap.soldermaskWithCopperUnderneath,...t.colorOverrides.soldermaskWithCopperUnderneath},soldermaskOverCopper:{...this.colorMap.soldermaskOverCopper,...t.colorOverrides.soldermaskOverCopper}})}setCameraBounds(t){const A=this.ctx.canvas,e=A.width,i=A.height,n=t.maxX-t.minX,o=t.maxY-t.minY,s=e/n,r=i/o,a=Math.min(s,r),g=(e-n*a)/2,c=(i-o*a)/2;this.realToCanvasMat=d3t(Q9(g,c),p3t(a,-a),Q9(-t.minX,-t.maxY))}drawElements(t,A={}){const e=t.find(o=>o.type==="pcb_board"),i=t.find(o=>o.type==="pcb_panel");i&&tOt({ctx:this.ctx,panel:i,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap,drawBoardMaterial:A.drawBoardMaterial??!1}),e&&f3t({ctx:this.ctx,board:e,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap,drawBoardMaterial:A.drawBoardMaterial??!1});for(const o of t)DG(o,A)&&(o.type==="pcb_smtpad"&&pOt({ctx:this.ctx,pad:o,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}),o.type==="pcb_copper_text"&&M3t({ctx:this.ctx,text:o,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}));const n=A.drawSoldermask??!1;e&&kOt({ctx:this.ctx,board:e,elements:t,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap,layer:"top",drawSoldermask:n});for(const o of t)DG(o,A)&&(o.type==="pcb_silkscreen_text"&&uOt({ctx:this.ctx,text:o,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}),o.type==="pcb_silkscreen_rect"&&QOt({ctx:this.ctx,rect:o,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}),o.type==="pcb_silkscreen_circle"&&oOt({ctx:this.ctx,circle:o,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}),o.type==="pcb_silkscreen_line"&&rOt({ctx:this.ctx,line:o,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}),o.type==="pcb_silkscreen_path"&&IOt({ctx:this.ctx,path:o,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}),o.type==="pcb_silkscreen_pill"&&BOt({ctx:this.ctx,pill:o,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}),o.type==="pcb_silkscreen_oval"&&gOt({ctx:this.ctx,oval:o,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}));for(const o of t)DG(o,A)&&(o.type==="pcb_copper_pour"&&w3t({ctx:this.ctx,pour:o,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}),o.type==="pcb_trace"&&LOt({ctx:this.ctx,trace:o,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}));for(const o of t)DG(o,A)&&o.type==="pcb_hole"&&O3t({ctx:this.ctx,hole:o,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap,soldermaskMargin:n?o.soldermask_margin:void 0,drawSoldermask:n});for(const o of t)DG(o,A)&&(o.type==="pcb_plated_hole"&&iOt({ctx:this.ctx,hole:o,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap,soldermaskMargin:n?o.soldermask_margin:void 0,drawSoldermask:n}),o.type==="pcb_via"&&UOt({ctx:this.ctx,via:o,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}));for(const o of t)DG(o,A)&&o.type==="pcb_cutout"&&N3t({ctx:this.ctx,cutout:o,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap});for(const o of t)DG(o,A)&&(o.type==="pcb_keepout"&&Z3t({ctx:this.ctx,keepout:o,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}),o.type==="pcb_fabrication_note_text"&&q3t({ctx:this.ctx,text:o,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}),o.type==="pcb_fabrication_note_rect"&&T3t({ctx:this.ctx,rect:o,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}),o.type==="pcb_note_rect"&&$3t({realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap,ctx:this.ctx,rect:o}),o.type==="pcb_fabrication_note_path"&&J3t({ctx:this.ctx,path:o,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}),o.type==="pcb_note_path"&&X3t({ctx:this.ctx,path:o,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}),o.type==="pcb_note_text"&&eOt({ctx:this.ctx,text:o,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}),o.type==="pcb_note_line"&&z3t({ctx:this.ctx,line:o,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}),o.type==="pcb_note_dimension"&&j3t({ctx:this.ctx,pcbNoteDimension:o,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}),o.type==="pcb_fabrication_note_dimension"&&Y3t({ctx:this.ctx,pcbFabricationNoteDimension:o,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}))}};const HOt=Swe(FYe);var QfA,Fge;function YOt(){if(Fge)return QfA;Fge=1;var t=Object.defineProperty,A=Object.getOwnPropertyDescriptor,e=Object.getOwnPropertyNames,i=Object.prototype.hasOwnProperty,n=(h,E)=>{for(var u in E)t(h,u,{get:E[u],enumerable:!0})},o=(h,E,u,d)=>{if(E&&typeof E=="object"||typeof E=="function")for(let p of e(E))!i.call(h,p)&&p!==u&&t(h,p,{get:()=>E[p],enumerable:!(d=A(E,p))||d.enumerable});return h},s=h=>o(t({},"__esModule",{value:!0}),h),r={};n(r,{SuperGrid:()=>Q,toMMSI:()=>C,toMeterSI:()=>B}),QfA=s(r);var a=c0(),g=HOt,c=xbA(),I=(h,E,u)=>{const d=[];if(E<h)for(let p=h;p>=E;p-=Math.abs(u))d.push(p);else for(let p=h;p<=E;p+=Math.abs(u))d.push(p);return d};function l(h,E){return{x:Math.round(E.x/h)*h,y:Math.round(E.y/h)*h}}function B(h,E=1){return h<0?"-"+B(-h):h<1e-6?"0m":h>1e3?Math.floor(h/1e3)+"km":h>1&&E>1?Math.round(h)+"m":h>1&&E<=1?h.toFixed(Math.ceil(-Math.log10(E)))+"m":h<1&&E>=1/1e3?Math.round(h*1e3)+"mm":h<1&&E<1/1e3?(h*1e3).toFixed(Math.ceil(-Math.log10(E*1e3)))+"mm":""}function C(h,E=1){return B(h/1e3,E/1e3)}var Q=h=>{var E;const u=(0,a.useRef)(null),[d,p]=(0,a.useState)({x:0,y:0}),{majorColor:m="rgba(0,0,0,0.2)",minorColor:D="rgba(0,0,0,0.1)",textColor:w=(E=h.majorColor)!=null?E:"rgba(0,0,0,0.5)",width:b,height:k,screenSpaceCellSize:x=200,stringifyCoord:N=(H,O,Z)=>`${B(H,Z)}, ${B(O,Z)}`}=h,M=Math.ceil(b/x)+2,U=Math.ceil(k/x)+2;(0,a.useEffect)(()=>{if(!u.current)return;const H=u.current.getContext("2d");if(!H)return;const O=x/10**Math.floor(Math.log10(h.transform.a)),Z=h.transform.d<0?-1:1,iA=x/10**Math.log10(h.transform.a)/O;function aA(_A,dA,KA){const TA=_A;let ie,fA,$A;for(ie=dA.x;ie<=KA.x;ie+=TA)fA=(0,g.applyToPoint)(h.transform,{x:ie,y:dA.y}),$A=(0,g.applyToPoint)(h.transform,{x:ie,y:KA.y}),H.beginPath(),H.moveTo(fA.x,fA.y),H.lineTo($A.x,$A.y),H.stroke();const qA=I(dA.y,KA.y,TA*Z);for(const HA of qA)fA=(0,g.applyToPoint)(h.transform,{x:dA.x,y:HA}),$A=(0,g.applyToPoint)(h.transform,{x:KA.x,y:HA}),H.beginPath(),H.moveTo(fA.x,fA.y),H.lineTo($A.x,$A.y),H.stroke()}function eA(_A,dA,KA){const TA=_A;let ie;for(ie=dA.x;ie<=KA.x;ie+=TA)for(const fA of I(dA.y,KA.y,TA*Z)){const $A=(0,g.applyToPoint)(h.transform,{x:ie,y:fA});H.fillStyle=w,H.font="12px sans-serif",H.fillText(N(ie,fA,_A),$A.x+2,$A.y-2)}}H.clearRect(0,0,b,k);const nA=(0,g.applyToPoint)((0,g.inverse)(h.transform),{x:0,y:0}),rA={x:Math.floor((nA.x-O)/O)*O,y:Math.floor((nA.y-O)/O+(Z==-1?2:0))*O},lA={x:rA.x+O*M,y:rA.y+O*U*Z},xA=O*5,RA={x:Math.floor((nA.x-xA)/xA)*xA,y:Math.floor((nA.y-xA)/xA+(Z==-1?2:0))*xA},YA={x:RA.x+xA*M,y:RA.y+xA*U*Z};H.globalAlpha=1,H.strokeStyle=m,aA(O,rA,lA),eA(xA,RA,YA),H.globalAlpha=1-iA,aA(xA/10,RA,YA),H.globalAlpha=1-iA,H.strokeStyle=D,aA(O/10,rA,lA),H.globalAlpha=Math.max(((1-iA)*10-5)/5,0),eA(xA/10,RA,YA),H.globalAlpha=1;const CA=(0,g.applyToPoint)(h.transform,d);H.font="12px sans-serif",H.fillStyle=w,H.fillText(N(d.x,d.y,O),CA.x+2,CA.y-2),H.strokeStyle=m,H.strokeRect(CA.x-5,CA.y-5,10,10)},[u,h.transform,d,b,k]);const Y=H=>{if(!u.current)return;const O=x/10/10**Math.floor(Math.log10(h.transform.a)),Z=u.current.getBoundingClientRect(),$=(0,g.applyToPoint)((0,g.inverse)(h.transform),{x:H.clientX-Z.left,y:H.clientY-Z.top}),iA=l(O,$);p(iA)};return(0,c.jsx)("canvas",{onMouseUp:H=>{H.button===1&&Y(H)},onDoubleClick:Y,ref:u,width:h.width,height:h.height})};return QfA}var d9=YOt();function JOt(t){if(t.sheet)return t.sheet;for(var A=0;A<document.styleSheets.length;A++)if(document.styleSheets[A].ownerNode===t)return document.styleSheets[A]}function TOt(t){var A=document.createElement("style");return A.setAttribute("data-emotion",t.key),t.nonce!==void 0&&A.setAttribute("nonce",t.nonce),A.appendChild(document.createTextNode("")),A.setAttribute("data-s",""),A}var KOt=(function(){function t(e){var i=this;this._insertTag=function(n){var o;i.tags.length===0?i.insertionPoint?o=i.insertionPoint.nextSibling:i.prepend?o=i.container.firstChild:o=i.before:o=i.tags[i.tags.length-1].nextSibling,i.container.insertBefore(n,o),i.tags.push(n)},this.isSpeedy=e.speedy===void 0?!0:e.speedy,this.tags=[],this.ctr=0,this.nonce=e.nonce,this.key=e.key,this.container=e.container,this.prepend=e.prepend,this.insertionPoint=e.insertionPoint,this.before=null}var A=t.prototype;return A.hydrate=function(i){i.forEach(this._insertTag)},A.insert=function(i){this.ctr%(this.isSpeedy?65e3:1)===0&&this._insertTag(TOt(this));var n=this.tags[this.tags.length-1];if(this.isSpeedy){var o=JOt(n);try{o.insertRule(i,o.cssRules.length)}catch{}}else n.appendChild(document.createTextNode(i));this.ctr++},A.flush=function(){this.tags.forEach(function(i){var n;return(n=i.parentNode)==null?void 0:n.removeChild(i)}),this.tags=[],this.ctr=0},t})(),Ou="-ms-",p9="-moz-",Va="-webkit-",Gge="comm",hfA="rule",EfA="decl",POt="@import",Rge="@keyframes",qOt="@layer",OOt=Math.abs,f9=String.fromCharCode,WOt=Object.assign;function ZOt(t,A){return GE(t,0)^45?(((A<<2^GE(t,0))<<2^GE(t,1))<<2^GE(t,2))<<2^GE(t,3):0}function Mge(t){return t.trim()}function VOt(t,A){return(t=A.exec(t))?t[0]:t}function ja(t,A,e){return t.replace(A,e)}function ufA(t,A){return t.indexOf(A)}function GE(t,A){return t.charCodeAt(A)|0}function BJ(t,A,e){return t.slice(A,e)}function RD(t){return t.length}function dfA(t){return t.length}function y9(t,A){return A.push(t),t}function jOt(t,A){return t.map(A).join("")}var m9=1,zv=1,Nge=0,ff=0,LC=0,Xv="";function w9(t,A,e,i,n,o,s){return{value:t,root:A,parent:e,type:i,props:n,children:o,line:m9,column:zv,length:s,return:""}}function CJ(t,A){return WOt(w9("",null,null,"",null,null,0),t,{length:-t.length},A)}function zOt(){return LC}function XOt(){return LC=ff>0?GE(Xv,--ff):0,zv--,LC===10&&(zv=1,m9--),LC}function N0(){return LC=ff<Nge?GE(Xv,ff++):0,zv++,LC===10&&(zv=1,m9++),LC}function MD(){return GE(Xv,ff)}function D9(){return ff}function QJ(t,A){return BJ(Xv,t,A)}function hJ(t){switch(t){case 0:case 9:case 10:case 13:case 32:return 5;case 33:case 43:case 44:case 47:case 62:case 64:case 126:case 59:case 123:case 125:return 4;case 58:return 3;case 34:case 39:case 40:case 91:return 2;case 41:case 93:return 1}return 0}function vge(t){return m9=zv=1,Nge=RD(Xv=t),ff=0,[]}function Lge(t){return Xv="",t}function S9(t){return Mge(QJ(ff-1,pfA(t===91?t+2:t===40?t+1:t)))}function $Ot(t){for(;(LC=MD())&&LC<33;)N0();return hJ(t)>2||hJ(LC)>3?"":" "}function A5t(t,A){for(;--A&&N0()&&!(LC<48||LC>102||LC>57&&LC<65||LC>70&&LC<97););return QJ(t,D9()+(A<6&&MD()==32&&N0()==32))}function pfA(t){for(;N0();)switch(LC){case t:return ff;case 34:case 39:t!==34&&t!==39&&pfA(LC);break;case 40:t===41&&pfA(t);break;case 92:N0();break}return ff}function e5t(t,A){for(;N0()&&t+LC!==57;)if(t+LC===84&&MD()===47)break;return"/*"+QJ(A,ff-1)+"*"+f9(t===47?t:N0())}function t5t(t){for(;!hJ(MD());)N0();return QJ(t,ff)}function i5t(t){return Lge(b9("",null,null,null,[""],t=vge(t),0,[0],t))}function b9(t,A,e,i,n,o,s,r,a){for(var g=0,c=0,I=s,l=0,B=0,C=0,Q=1,h=1,E=1,u=0,d="",p=n,m=o,D=i,w=d;h;)switch(C=u,u=N0()){case 40:if(C!=108&&GE(w,I-1)==58){ufA(w+=ja(S9(u),"&","&\f"),"&\f")!=-1&&(E=-1);break}case 34:case 39:case 91:w+=S9(u);break;case 9:case 10:case 13:case 32:w+=$Ot(C);break;case 92:w+=A5t(D9()-1,7);continue;case 47:switch(MD()){case 42:case 47:y9(n5t(e5t(N0(),D9()),A,e),a);break;default:w+="/"}break;case 123*Q:r[g++]=RD(w)*E;case 125*Q:case 59:case 0:switch(u){case 0:case 125:h=0;case 59+c:E==-1&&(w=ja(w,/\f/g,"")),B>0&&RD(w)-I&&y9(B>32?Hge(w+";",i,e,I-1):Hge(ja(w," ","")+";",i,e,I-2),a);break;case 59:w+=";";default:if(y9(D=Uge(w,A,e,g,c,n,r,d,p=[],m=[],I),o),u===123)if(c===0)b9(w,A,D,D,p,o,I,r,m);else switch(l===99&&GE(w,3)===110?100:l){case 100:case 108:case 109:case 115:b9(t,D,D,i&&y9(Uge(t,D,D,0,0,n,r,d,n,p=[],I),m),n,m,I,r,i?p:m);break;default:b9(w,D,D,D,[""],m,0,r,m)}}g=c=B=0,Q=E=1,d=w="",I=s;break;case 58:I=1+RD(w),B=C;default:if(Q<1){if(u==123)--Q;else if(u==125&&Q++==0&&XOt()==125)continue}switch(w+=f9(u),u*Q){case 38:E=c>0?1:(w+="\f",-1);break;case 44:r[g++]=(RD(w)-1)*E,E=1;break;case 64:MD()===45&&(w+=S9(N0())),l=MD(),c=I=RD(d=w+=t5t(D9())),u++;break;case 45:C===45&&RD(w)==2&&(Q=0)}}return o}function Uge(t,A,e,i,n,o,s,r,a,g,c){for(var I=n-1,l=n===0?o:[""],B=dfA(l),C=0,Q=0,h=0;C<i;++C)for(var E=0,u=BJ(t,I+1,I=OOt(Q=s[C])),d=t;E<B;++E)(d=Mge(Q>0?l[E]+" "+u:ja(u,/&\f/g,l[E])))&&(a[h++]=d);return w9(t,A,e,n===0?hfA:r,a,g,c)}function n5t(t,A,e){return w9(t,A,e,Gge,f9(zOt()),BJ(t,2,-2),0)}function Hge(t,A,e,i){return w9(t,A,e,EfA,BJ(t,0,i),BJ(t,i+1,-1),i)}function $v(t,A){for(var e="",i=dfA(t),n=0;n<i;n++)e+=A(t[n],n,t,A)||"";return e}function o5t(t,A,e,i){switch(t.type){case qOt:if(t.children.length)break;case POt:case EfA:return t.return=t.return||t.value;case Gge:return"";case Rge:return t.return=t.value+"{"+$v(t.children,i)+"}";case hfA:t.value=t.props.join(",")}return RD(e=$v(t.children,i))?t.return=t.value+"{"+e+"}":""}function s5t(t){var A=dfA(t);return function(e,i,n,o){for(var s="",r=0;r<A;r++)s+=t[r](e,i,n,o)||"";return s}}function r5t(t){return function(A){A.root||(A=A.return)&&t(A)}}function a5t(t){var A=Object.create(null);return function(e){return A[e]===void 0&&(A[e]=t(e)),A[e]}}var g5t=function(A,e,i){for(var n=0,o=0;n=o,o=MD(),n===38&&o===12&&(e[i]=1),!hJ(o);)N0();return QJ(A,ff)},c5t=function(A,e){var i=-1,n=44;do switch(hJ(n)){case 0:n===38&&MD()===12&&(e[i]=1),A[i]+=g5t(ff-1,e,i);break;case 2:A[i]+=S9(n);break;case 4:if(n===44){A[++i]=MD()===58?"&\f":"",e[i]=A[i].length;break}default:A[i]+=f9(n)}while(n=N0());return A},I5t=function(A,e){return Lge(c5t(vge(A),e))},Yge=new WeakMap,l5t=function(A){if(!(A.type!=="rule"||!A.parent||A.length<1)){for(var e=A.value,i=A.parent,n=A.column===i.column&&A.line===i.line;i.type!=="rule";)if(i=i.parent,!i)return;if(!(A.props.length===1&&e.charCodeAt(0)!==58&&!Yge.get(i))&&!n){Yge.set(A,!0);for(var o=[],s=I5t(e,o),r=i.props,a=0,g=0;a<s.length;a++)for(var c=0;c<r.length;c++,g++)A.props[g]=o[a]?s[a].replace(/&\f/g,r[c]):r[c]+" "+s[a]}}},B5t=function(A){if(A.type==="decl"){var e=A.value;e.charCodeAt(0)===108&&e.charCodeAt(2)===98&&(A.return="",A.value="")}};function Jge(t,A){switch(ZOt(t,A)){case 5103:return Va+"print-"+t+t;case 5737:case 4201:case 3177:case 3433:case 1641:case 4457:case 2921:case 5572:case 6356:case 5844:case 3191:case 6645:case 3005:case 6391:case 5879:case 5623:case 6135:case 4599:case 4855:case 4215:case 6389:case 5109:case 5365:case 5621:case 3829:return Va+t+t;case 5349:case 4246:case 4810:case 6968:case 2756:return Va+t+p9+t+Ou+t+t;case 6828:case 4268:return Va+t+Ou+t+t;case 6165:return Va+t+Ou+"flex-"+t+t;case 5187:return Va+t+ja(t,/(\w+).+(:[^]+)/,Va+"box-$1$2"+Ou+"flex-$1$2")+t;case 5443:return Va+t+Ou+"flex-item-"+ja(t,/flex-|-self/,"")+t;case 4675:return Va+t+Ou+"flex-line-pack"+ja(t,/align-content|flex-|-self/,"")+t;case 5548:return Va+t+Ou+ja(t,"shrink","negative")+t;case 5292:return Va+t+Ou+ja(t,"basis","preferred-size")+t;case 6060:return Va+"box-"+ja(t,"-grow","")+Va+t+Ou+ja(t,"grow","positive")+t;case 4554:return Va+ja(t,/([^-])(transform)/g,"$1"+Va+"$2")+t;case 6187:return ja(ja(ja(t,/(zoom-|grab)/,Va+"$1"),/(image-set)/,Va+"$1"),t,"")+t;case 5495:case 3959:return ja(t,/(image-set\([^]*)/,Va+"$1$`$1");case 4968:return ja(ja(t,/(.+:)(flex-)?(.*)/,Va+"box-pack:$3"+Ou+"flex-pack:$3"),/s.+-b[^;]+/,"justify")+Va+t+t;case 4095:case 3583:case 4068:case 2532:return ja(t,/(.+)-inline(.+)/,Va+"$1$2")+t;case 8116:case 7059:case 5753:case 5535:case 5445:case 5701:case 4933:case 4677:case 5533:case 5789:case 5021:case 4765:if(RD(t)-1-A>6)switch(GE(t,A+1)){case 109:if(GE(t,A+4)!==45)break;case 102:return ja(t,/(.+:)(.+)-([^]+)/,"$1"+Va+"$2-$3$1"+p9+(GE(t,A+3)==108?"$3":"$2-$3"))+t;case 115:return~ufA(t,"stretch")?Jge(ja(t,"stretch","fill-available"),A)+t:t}break;case 4949:if(GE(t,A+1)!==115)break;case 6444:switch(GE(t,RD(t)-3-(~ufA(t,"!important")&&10))){case 107:return ja(t,":",":"+Va)+t;case 101:return ja(t,/(.+:)([^;!]+)(;|!.+)?/,"$1"+Va+(GE(t,14)===45?"inline-":"")+"box$3$1"+Va+"$2$3$1"+Ou+"$2box$3")+t}break;case 5936:switch(GE(t,A+11)){case 114:return Va+t+Ou+ja(t,/[svh]\w+-[tblr]{2}/,"tb")+t;case 108:return Va+t+Ou+ja(t,/[svh]\w+-[tblr]{2}/,"tb-rl")+t;case 45:return Va+t+Ou+ja(t,/[svh]\w+-[tblr]{2}/,"lr")+t}return Va+t+Ou+t+t}return t}var C5t=function(A,e,i,n){if(A.length>-1&&!A.return)switch(A.type){case EfA:A.return=Jge(A.value,A.length);break;case Rge:return $v([CJ(A,{value:ja(A.value,"@","@"+Va)})],n);case hfA:if(A.length)return jOt(A.props,function(o){switch(VOt(o,/(::plac\w+|:read-\w+)/)){case":read-only":case":read-write":return $v([CJ(A,{props:[ja(o,/:(read-\w+)/,":"+p9+"$1")]})],n);case"::placeholder":return $v([CJ(A,{props:[ja(o,/:(plac\w+)/,":"+Va+"input-$1")]}),CJ(A,{props:[ja(o,/:(plac\w+)/,":"+p9+"$1")]}),CJ(A,{props:[ja(o,/:(plac\w+)/,Ou+"input-$1")]})],n)}return""})}},Q5t=[C5t],h5t=function(A){var e=A.key;if(e==="css"){var i=document.querySelectorAll("style[data-emotion]:not([data-s])");Array.prototype.forEach.call(i,function(Q){var h=Q.getAttribute("data-emotion");h.indexOf(" ")!==-1&&(document.head.appendChild(Q),Q.setAttribute("data-s",""))})}var n=A.stylisPlugins||Q5t,o={},s,r=[];s=A.container||document.head,Array.prototype.forEach.call(document.querySelectorAll('style[data-emotion^="'+e+' "]'),function(Q){for(var h=Q.getAttribute("data-emotion").split(" "),E=1;E<h.length;E++)o[h[E]]=!0;r.push(Q)});var a,g=[l5t,B5t];{var c,I=[o5t,r5t(function(Q){c.insert(Q)})],l=s5t(g.concat(n,I)),B=function(h){return $v(i5t(h),l)};a=function(h,E,u,d){c=u,B(h?h+"{"+E.styles+"}":E.styles),d&&(C.inserted[E.name]=!0)}}var C={key:e,sheet:new KOt({key:e,container:s,nonce:A.nonce,speedy:A.speedy,prepend:A.prepend,insertionPoint:A.insertionPoint}),nonce:A.nonce,inserted:o,registered:{},insert:a};return C.sheet.hydrate(r),C};function E5t(t){for(var A=0,e,i=0,n=t.length;n>=4;++i,n-=4)e=t.charCodeAt(i)&255|(t.charCodeAt(++i)&255)<<8|(t.charCodeAt(++i)&255)<<16|(t.charCodeAt(++i)&255)<<24,e=(e&65535)*1540483477+((e>>>16)*59797<<16),e^=e>>>24,A=(e&65535)*1540483477+((e>>>16)*59797<<16)^(A&65535)*1540483477+((A>>>16)*59797<<16);switch(n){case 3:A^=(t.charCodeAt(i+2)&255)<<16;case 2:A^=(t.charCodeAt(i+1)&255)<<8;case 1:A^=t.charCodeAt(i)&255,A=(A&65535)*1540483477+((A>>>16)*59797<<16)}return A^=A>>>13,A=(A&65535)*1540483477+((A>>>16)*59797<<16),((A^A>>>15)>>>0).toString(36)}var u5t={animationIterationCount:1,aspectRatio:1,borderImageOutset:1,borderImageSlice:1,borderImageWidth:1,boxFlex:1,boxFlexGroup:1,boxOrdinalGroup:1,columnCount:1,columns:1,flex:1,flexGrow:1,flexPositive:1,flexShrink:1,flexNegative:1,flexOrder:1,gridRow:1,gridRowEnd:1,gridRowSpan:1,gridRowStart:1,gridColumn:1,gridColumnEnd:1,gridColumnSpan:1,gridColumnStart:1,msGridRow:1,msGridRowSpan:1,msGridColumn:1,msGridColumnSpan:1,fontWeight:1,lineHeight:1,opacity:1,order:1,orphans:1,scale:1,tabSize:1,widows:1,zIndex:1,zoom:1,WebkitLineClamp:1,fillOpacity:1,floodOpacity:1,stopOpacity:1,strokeDasharray:1,strokeDashoffset:1,strokeMiterlimit:1,strokeOpacity:1,strokeWidth:1},d5t=/[A-Z]|^ms/g,p5t=/_EMO_([^_]+?)_([^]*?)_EMO_/g,Tge=function(A){return A.charCodeAt(1)===45},Kge=function(A){return A!=null&&typeof A!="boolean"},ffA=a5t(function(t){return Tge(t)?t:t.replace(d5t,"-$&").toLowerCase()}),Pge=function(A,e){switch(A){case"animation":case"animationName":if(typeof e=="string")return e.replace(p5t,function(i,n,o){return O_={name:n,styles:o,next:O_},n})}return u5t[A]!==1&&!Tge(A)&&typeof e=="number"&&e!==0?e+"px":e};function x9(t,A,e){if(e==null)return"";var i=e;if(i.__emotion_styles!==void 0)return i;switch(typeof e){case"boolean":return"";case"object":{var n=e;if(n.anim===1)return O_={name:n.name,styles:n.styles,next:O_},n.name;var o=e;if(o.styles!==void 0){var s=o.next;if(s!==void 0)for(;s!==void 0;)O_={name:s.name,styles:s.styles,next:O_},s=s.next;var r=o.styles+";";return r}return f5t(t,A,e)}}var a=e;if(A==null)return a;var g=A[a];return g!==void 0?g:a}function f5t(t,A,e){var i="";if(Array.isArray(e))for(var n=0;n<e.length;n++)i+=x9(t,A,e[n])+";";else for(var o in e){var s=e[o];if(typeof s!="object"){var r=s;A!=null&&A[r]!==void 0?i+=o+"{"+A[r]+"}":Kge(r)&&(i+=ffA(o)+":"+Pge(o,r)+";")}else if(Array.isArray(s)&&typeof s[0]=="string"&&(A==null||A[s[0]]===void 0))for(var a=0;a<s.length;a++)Kge(s[a])&&(i+=ffA(o)+":"+Pge(o,s[a])+";");else{var g=x9(t,A,s);switch(o){case"animation":case"animationName":{i+=ffA(o)+":"+g+";";break}default:i+=o+"{"+g+"}"}}}return i}var qge=/label:\s*([^\s;{]+)\s*(;|$)/g,O_;function yfA(t,A,e){if(t.length===1&&typeof t[0]=="object"&&t[0]!==null&&t[0].styles!==void 0)return t[0];var i=!0,n="";O_=void 0;var o=t[0];if(o==null||o.raw===void 0)i=!1,n+=x9(e,A,o);else{var s=o;n+=s[0]}for(var r=1;r<t.length;r++)if(n+=x9(e,A,t[r]),i){var a=o;n+=a[r]}qge.lastIndex=0;for(var g="",c;(c=qge.exec(n))!==null;)g+="-"+c[1];var I=E5t(n)+g;return{name:I,styles:n,next:O_}}function Oge(t,A,e){var i="";return e.split(" ").forEach(function(n){t[n]!==void 0?A.push(t[n]+";"):n&&(i+=n+" ")}),i}var y5t=function(A,e,i){var n=A.key+"-"+e.name;A.registered[n]===void 0&&(A.registered[n]=e.styles)},m5t=function(A,e,i){y5t(A,e);var n=A.key+"-"+e.name;if(A.inserted[e.name]===void 0){var o=e;do A.insert(e===o?"."+n:"",o,A.sheet,!0),o=o.next;while(o!==void 0)}};function Wge(t,A){if(t.inserted[A.name]===void 0)return t.insert("",A,t.sheet,!0)}function Zge(t,A,e){var i=[],n=Oge(t,i,e);return i.length<2?e:n+A(i)}var w5t=function(A){var e=h5t(A);e.sheet.speedy=function(r){this.isSpeedy=r},e.compat=!0;var i=function(){for(var a=arguments.length,g=new Array(a),c=0;c<a;c++)g[c]=arguments[c];var I=yfA(g,e.registered,void 0);return m5t(e,I),e.key+"-"+I.name},n=function(){for(var a=arguments.length,g=new Array(a),c=0;c<a;c++)g[c]=arguments[c];var I=yfA(g,e.registered),l="animation-"+I.name;return Wge(e,{name:I.name,styles:"@keyframes "+l+"{"+I.styles+"}"}),l},o=function(){for(var a=arguments.length,g=new Array(a),c=0;c<a;c++)g[c]=arguments[c];var I=yfA(g,e.registered);Wge(e,I)},s=function(){for(var a=arguments.length,g=new Array(a),c=0;c<a;c++)g[c]=arguments[c];return Zge(e.registered,i,D5t(g))};return{css:i,cx:s,injectGlobal:o,keyframes:n,hydrate:function(a){a.forEach(function(g){e.inserted[g]=!0})},flush:function(){e.registered={},e.inserted={},e.sheet.flush()},sheet:e.sheet,cache:e,getRegisteredStyles:Oge.bind(null,e.registered),merge:Zge.bind(null,e.registered,i)}},D5t=function t(A){for(var e="",i=0;i<A.length;i++){var n=A[i];if(n!=null){var o=void 0;switch(typeof n){case"boolean":break;case"object":{if(Array.isArray(n))o=t(n);else{o="";for(var s in n)n[s]&&s&&(o&&(o+=" "),o+=s)}break}default:o=n}o&&(e&&(e+=" "),e+=o)}}return e},S5t=w5t({key:"css"}),A1=S5t.css,b5t=Object.create,Vge=Object.defineProperty,x5t=Object.getOwnPropertyDescriptor,jge=Object.getOwnPropertyNames,_5t=Object.getPrototypeOf,k5t=Object.prototype.hasOwnProperty,Ma=(t,A)=>function(){return A||(0,t[jge(t)[0]])((A={exports:{}}).exports,A),A.exports},F5t=(t,A,e,i)=>{if(A&&typeof A=="object"||typeof A=="function")for(let n of jge(A))!k5t.call(t,n)&&n!==e&&Vge(t,n,{get:()=>A[n],enumerable:!(i=x5t(A,n))||i.enumerable});return t},zge=(t,A,e)=>(e=t!=null?b5t(_5t(t)):{},F5t(Vge(e,"default",{value:t,enumerable:!0}),t)),G5t=Ma({"node_modules/svgson/dist/svgson.umd.js"(t,A){(function(e,i){typeof t=="object"&&typeof A<"u"?A.exports=i():typeof define=="function"&&define.amd?define(i):(e=typeof globalThis<"u"?globalThis:e||self,e.svgson=i())})(t,function(){var e=function(eA){return eA!=null&&(i(eA)||n(eA)||!!eA._isBuffer)};function i(eA){return!!eA.constructor&&typeof eA.constructor.isBuffer=="function"&&eA.constructor.isBuffer(eA)}function n(eA){return typeof eA.readFloatLE=="function"&&typeof eA.slice=="function"&&i(eA.slice(0,0))}var o=Object.prototype.toString,s=function(nA){if(typeof nA>"u")return"undefined";if(nA===null)return"null";if(nA===!0||nA===!1||nA instanceof Boolean)return"boolean";if(typeof nA=="string"||nA instanceof String)return"string";if(typeof nA=="number"||nA instanceof Number)return"number";if(typeof nA=="function"||nA instanceof Function)return"function";if(typeof Array.isArray<"u"&&Array.isArray(nA))return"array";if(nA instanceof RegExp)return"regexp";if(nA instanceof Date)return"date";var rA=o.call(nA);return rA==="[object RegExp]"?"regexp":rA==="[object Date]"?"date":rA==="[object Arguments]"?"arguments":rA==="[object Error]"?"error":e(nA)?"buffer":rA==="[object Set]"?"set":rA==="[object WeakSet]"?"weakset":rA==="[object Map]"?"map":rA==="[object WeakMap]"?"weakmap":rA==="[object Symbol]"?"symbol":rA==="[object Int8Array]"?"int8array":rA==="[object Uint8Array]"?"uint8array":rA==="[object Uint8ClampedArray]"?"uint8clampedarray":rA==="[object Int16Array]"?"int16array":rA==="[object Uint16Array]"?"uint16array":rA==="[object Int32Array]"?"int32array":rA==="[object Uint32Array]"?"uint32array":rA==="[object Float32Array]"?"float32array":rA==="[object Float64Array]"?"float64array":"object"};function r(eA,nA){return nA={exports:{}},eA(nA,nA.exports),nA.exports}var a=r(function(eA){(function(){function nA(rA,lA){if(typeof lA!="function")return rA;var pA={};for(var xA in rA)Object.prototype.hasOwnProperty.call(rA,xA)&&(pA[lA(xA,rA[xA])||xA]=rA[xA]);return pA}eA.exports?eA.exports=nA:window.rename=nA})()}),g=function eA(nA,rA){var lA=s(nA);if(lA!=="object"&&lA!=="array")throw new Error("expected an object");var pA=[];lA==="object"&&(nA=a(nA,rA),pA={});for(var xA in nA)if(nA.hasOwnProperty(xA)){var RA=nA[xA];s(RA)==="object"||s(RA)==="array"?pA[xA]=eA(RA,rA):pA[xA]=RA}return pA},c=r(function(eA){var nA=Object.prototype.hasOwnProperty,rA="~";function lA(){}Object.create&&(lA.prototype=Object.create(null),new lA().__proto__||(rA=!1));function pA(RA,YA,CA){this.fn=RA,this.context=YA,this.once=CA||!1}function xA(){this._events=new lA,this._eventsCount=0}xA.prototype.eventNames=function(){var YA=[],CA,_A;if(this._eventsCount===0)return YA;for(_A in CA=this._events)nA.call(CA,_A)&&YA.push(rA?_A.slice(1):_A);return Object.getOwnPropertySymbols?YA.concat(Object.getOwnPropertySymbols(CA)):YA},xA.prototype.listeners=function(YA,CA){var _A=rA?rA+YA:YA,dA=this._events[_A];if(CA)return!!dA;if(!dA)return[];if(dA.fn)return[dA.fn];for(var KA=0,TA=dA.length,ie=new Array(TA);KA<TA;KA++)ie[KA]=dA[KA].fn;return ie},xA.prototype.emit=function(YA,CA,_A,dA,KA,TA){var ie=rA?rA+YA:YA;if(!this._events[ie])return!1;var fA=this._events[ie],$A=arguments.length,qA,HA;if(fA.fn){switch(fA.once&&this.removeListener(YA,fA.fn,void 0,!0),$A){case 1:return fA.fn.call(fA.context),!0;case 2:return fA.fn.call(fA.context,CA),!0;case 3:return fA.fn.call(fA.context,CA,_A),!0;case 4:return fA.fn.call(fA.context,CA,_A,dA),!0;case 5:return fA.fn.call(fA.context,CA,_A,dA,KA),!0;case 6:return fA.fn.call(fA.context,CA,_A,dA,KA,TA),!0}for(HA=1,qA=new Array($A-1);HA<$A;HA++)qA[HA-1]=arguments[HA];fA.fn.apply(fA.context,qA)}else{var ZA=fA.length,kA;for(HA=0;HA<ZA;HA++)switch(fA[HA].once&&this.removeListener(YA,fA[HA].fn,void 0,!0),$A){case 1:fA[HA].fn.call(fA[HA].context);break;case 2:fA[HA].fn.call(fA[HA].context,CA);break;case 3:fA[HA].fn.call(fA[HA].context,CA,_A);break;case 4:fA[HA].fn.call(fA[HA].context,CA,_A,dA);break;default:if(!qA)for(kA=1,qA=new Array($A-1);kA<$A;kA++)qA[kA-1]=arguments[kA];fA[HA].fn.apply(fA[HA].context,qA)}}return!0},xA.prototype.on=function(YA,CA,_A){var dA=new pA(CA,_A||this),KA=rA?rA+YA:YA;return this._events[KA]?this._events[KA].fn?this._events[KA]=[this._events[KA],dA]:this._events[KA].push(dA):(this._events[KA]=dA,this._eventsCount++),this},xA.prototype.once=function(YA,CA,_A){var dA=new pA(CA,_A||this,!0),KA=rA?rA+YA:YA;return this._events[KA]?this._events[KA].fn?this._events[KA]=[this._events[KA],dA]:this._events[KA].push(dA):(this._events[KA]=dA,this._eventsCount++),this},xA.prototype.removeListener=function(YA,CA,_A,dA){var KA=rA?rA+YA:YA;if(!this._events[KA])return this;if(!CA)return--this._eventsCount===0?this._events=new lA:delete this._events[KA],this;var TA=this._events[KA];if(TA.fn)TA.fn===CA&&(!dA||TA.once)&&(!_A||TA.context===_A)&&(--this._eventsCount===0?this._events=new lA:delete this._events[KA]);else{for(var ie=0,fA=[],$A=TA.length;ie<$A;ie++)(TA[ie].fn!==CA||dA&&!TA[ie].once||_A&&TA[ie].context!==_A)&&fA.push(TA[ie]);fA.length?this._events[KA]=fA.length===1?fA[0]:fA:--this._eventsCount===0?this._events=new lA:delete this._events[KA]}return this},xA.prototype.removeAllListeners=function(YA){var CA;return YA?(CA=rA?rA+YA:YA,this._events[CA]&&(--this._eventsCount===0?this._events=new lA:delete this._events[CA])):(this._events=new lA,this._eventsCount=0),this},xA.prototype.off=xA.prototype.removeListener,xA.prototype.addListener=xA.prototype.on,xA.prototype.setMaxListeners=function(){return this},xA.prefixed=rA,xA.EventEmitter=xA,eA.exports=xA});function I(eA,nA,rA){return nA in eA?Object.defineProperty(eA,nA,{value:rA,enumerable:!0,configurable:!0,writable:!0}):eA[nA]=rA,eA}var l=function(){},B={data:"state-data",cdata:"state-cdata",tagBegin:"state-tag-begin",tagName:"state-tag-name",tagEnd:"state-tag-end",attributeNameStart:"state-attribute-name-start",attributeName:"state-attribute-name",attributeNameEnd:"state-attribute-name-end",attributeValueBegin:"state-attribute-value-begin",attributeValue:"state-attribute-value"},C={lt:"action-lt",gt:"action-gt",space:"action-space",equal:"action-equal",quote:"action-quote",slash:"action-slash",char:"action-char",error:"action-error"},Q={text:"text",openTag:"open-tag",closeTag:"close-tag",attributeName:"attribute-name",attributeValue:"attribute-value"},h={" ":C.space," ":C.space,"\n":C.space,"\r":C.space,"<":C.lt,">":C.gt,'"':C.quote,"'":C.quote,"=":C.equal,"/":C.slash},E=function(nA){return h[nA]||C.char},u=function(nA){var rA,lA,pA,xA,RA,YA,CA,_A,dA,KA;nA=Object.assign({debug:!1},nA);var TA=new c,ie=B.data,fA="",$A="",qA="",HA="",ZA="",kA="",wA=function(PA,OA){if(!($A[0]==="?"||$A[0]==="!")){var Ae={type:PA,value:OA};nA.debug&&console.log("emit:",Ae),TA.emit("data",Ae)}};TA.stateMachine=(KA={},I(KA,B.data,(rA={},I(rA,C.lt,function(){fA.trim()&&wA(Q.text,fA),$A="",ZA=!1,ie=B.tagBegin}),I(rA,C.char,function(bA){fA+=bA}),rA)),I(KA,B.cdata,I({},C.char,function(bA){fA+=bA,fA.substr(-3)==="]]>"&&(wA(Q.text,fA.slice(0,-3)),fA="",ie=B.data)})),I(KA,B.tagBegin,(lA={},I(lA,C.space,l),I(lA,C.char,function(bA){$A=bA,ie=B.tagName}),I(lA,C.slash,function(){$A="",ZA=!0}),lA)),I(KA,B.tagName,(pA={},I(pA,C.space,function(){ZA?ie=B.tagEnd:(ie=B.attributeNameStart,wA(Q.openTag,$A))}),I(pA,C.gt,function(){wA(ZA?Q.closeTag:Q.openTag,$A),fA="",ie=B.data}),I(pA,C.slash,function(){ie=B.tagEnd,wA(Q.openTag,$A)}),I(pA,C.char,function(bA){$A+=bA,$A==="![CDATA["&&(ie=B.cdata,fA="",$A="")}),pA)),I(KA,B.tagEnd,(xA={},I(xA,C.gt,function(){wA(Q.closeTag,$A),fA="",ie=B.data}),I(xA,C.char,l),xA)),I(KA,B.attributeNameStart,(RA={},I(RA,C.char,function(bA){qA=bA,ie=B.attributeName}),I(RA,C.gt,function(){fA="",ie=B.data}),I(RA,C.space,l),I(RA,C.slash,function(){ZA=!0,ie=B.tagEnd}),RA)),I(KA,B.attributeName,(YA={},I(YA,C.space,function(){ie=B.attributeNameEnd}),I(YA,C.equal,function(){wA(Q.attributeName,qA),ie=B.attributeValueBegin}),I(YA,C.gt,function(){HA="",wA(Q.attributeName,qA),wA(Q.attributeValue,HA),fA="",ie=B.data}),I(YA,C.slash,function(){ZA=!0,HA="",wA(Q.attributeName,qA),wA(Q.attributeValue,HA),ie=B.tagEnd}),I(YA,C.char,function(bA){qA+=bA}),YA)),I(KA,B.attributeNameEnd,(CA={},I(CA,C.space,l),I(CA,C.equal,function(){wA(Q.attributeName,qA),ie=B.attributeValueBegin}),I(CA,C.gt,function(){HA="",wA(Q.attributeName,qA),wA(Q.attributeValue,HA),fA="",ie=B.data}),I(CA,C.char,function(bA){HA="",wA(Q.attributeName,qA),wA(Q.attributeValue,HA),qA=bA,ie=B.attributeName}),CA)),I(KA,B.attributeValueBegin,(_A={},I(_A,C.space,l),I(_A,C.quote,function(bA){kA=bA,HA="",ie=B.attributeValue}),I(_A,C.gt,function(){HA="",wA(Q.attributeValue,HA),fA="",ie=B.data}),I(_A,C.char,function(bA){kA="",HA=bA,ie=B.attributeValue}),_A)),I(KA,B.attributeValue,(dA={},I(dA,C.space,function(bA){kA?HA+=bA:(wA(Q.attributeValue,HA),ie=B.attributeNameStart)}),I(dA,C.quote,function(bA){kA===bA?(wA(Q.attributeValue,HA),ie=B.attributeNameStart):HA+=bA}),I(dA,C.gt,function(bA){kA?HA+=bA:(wA(Q.attributeValue,HA),fA="",ie=B.data)}),I(dA,C.slash,function(bA){kA?HA+=bA:(wA(Q.attributeValue,HA),ZA=!0,ie=B.tagEnd)}),I(dA,C.char,function(bA){HA+=bA}),dA)),KA);var UA=function(PA){nA.debug&&console.log(ie,PA);var OA=TA.stateMachine[ie],Ae=OA[E(PA)]||OA[C.error]||OA[C.char];Ae(PA)};return TA.write=function(bA){for(var PA=bA.length,OA=0;OA<PA;OA++)UA(bA[OA])},TA},d={State:B,Action:C,Type:Q,create:u},p=d.Type,m={element:"element",text:"text"},D=function(nA){return Object.assign({name:"",type:m.element,value:"",parent:null,attributes:{},children:[]},nA)},w=function(nA){nA=Object.assign({stream:!1,parentNodes:!0,doneEvent:"done",tagPrefix:"tag:",emitTopLevelOnly:!1,debug:!1},nA);var rA=void 0,lA=void 0,pA=void 0,xA=void 0,RA=new c,YA=function(_A){switch(_A.type){case p.openTag:if(pA===null)pA=lA,pA.name=_A.value;else{var dA=D({name:_A.value,parent:pA});pA.children.push(dA),pA=dA}break;case p.closeTag:var KA=pA.parent;if(nA.parentNodes||(pA.parent=null),pA.name!==_A.value)break;nA.stream&&KA===lA&&(lA.children=[],pA.parent=null),(!nA.emitTopLevelOnly||KA===lA)&&(RA.emit(nA.tagPrefix+pA.name,pA),RA.emit("tag",pA.name,pA)),pA===lA&&(rA.removeAllListeners("data"),RA.emit(nA.doneEvent,pA),lA=null),pA=KA;break;case p.text:pA&&pA.children.push(D({type:m.text,value:_A.value,parent:nA.parentNodes?pA:null}));break;case p.attributeName:xA=_A.value,pA.attributes[xA]="";break;case p.attributeValue:pA.attributes[xA]=_A.value;break}};return RA.reset=function(){rA=d.create({debug:nA.debug}),rA.on("data",YA),lA=D(),pA=null,xA="",RA.parse=rA.write},RA.reset(),RA},b=function(nA,rA){rA=Object.assign({},rA,{stream:!1,tagPrefix:":"});var lA=w(rA),pA=void 0;return lA.on("done",function(xA){pA=xA}),lA.parse(nA),pA},k={parseSync:b},x=k.parseSync,N=function(nA){var rA=x("<root>".concat(nA,"</root>"),{parentNodes:!1}),lA=rA.children&&rA.children.length>0&&rA.children.every(function(pA){return pA.name==="svg"});if(lA)return rA.children.length===1?rA.children[0]:rA.children;throw Error("nothing to parse")},M=function(nA){return g(nA,function(rA){return Y(rA)?rA:U(rA)})},U=function(nA){return nA.replace(/[-|:]([a-z])/gi,function(rA,lA){return lA.toUpperCase()})},Y=function(nA){return/^(data|aria)(-\w+)/.test(nA)},H=function(nA){if(nA){var rA=String(nA);return/[&<>]/.test(rA)?"<![CDATA[".concat(rA.replace(/]]>/,"]]]]><![CDATA[>"),"]]>"):rA}return""},O=function(nA){return String(nA).replace(/&/g,"&amp;").replace(/'/g,"&apos;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")},Z=function(nA){var rA=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},lA=rA.transformNode,pA=lA===void 0?function(CA){return CA}:lA,xA=rA.camelcase,RA=xA===void 0?!1:xA,YA=function(_A){var dA;return dA=pA(_A),RA&&(dA=M(dA)),dA};return YA(N(nA))};function $(){for(var eA=arguments.length,nA=new Array(eA),rA=0;rA<eA;rA++)nA[rA]=arguments[rA];return new Promise(function(lA,pA){try{var xA=Z.apply(void 0,nA);lA(xA)}catch(RA){pA(RA)}})}var iA=function eA(nA){var rA=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},lA=rA.transformAttr,pA=lA===void 0?function(ie,fA,$A){return"".concat(ie,'="').concat($A(fA),'"')}:lA,xA=rA.transformNode,RA=xA===void 0?function(ie){return ie}:xA,YA=rA.selfClose,CA=YA===void 0?!0:YA;if(Array.isArray(nA))return nA.map(function(ie){return eA(ie,{transformAttr:pA,selfClose:CA,transformNode:RA})}).join("");var _A=RA(nA);if(_A.type==="text")return H(_A.value);var dA="";for(var KA in _A.attributes){var TA=pA(KA,_A.attributes[KA],O,_A.name);dA+=TA?" ".concat(TA):""}return _A.children&&_A.children.length>0||!CA?"<".concat(_A.name).concat(dA,">").concat(eA(_A.children,{transformAttr:pA,transformNode:RA,selfClose:CA}),"</").concat(_A.name,">"):"<".concat(_A.name).concat(dA,"/>")},aA=Object.assign({},{parse:$,parseSync:Z,stringify:iA});return aA})}}),mfA=Ma({"node_modules/js-beautify/js/src/core/output.js"(t,A){function e(o){this.__parent=o,this.__character_count=0,this.__indent_count=-1,this.__alignment_count=0,this.__wrap_point_index=0,this.__wrap_point_character_count=0,this.__wrap_point_indent_count=-1,this.__wrap_point_alignment_count=0,this.__items=[]}e.prototype.clone_empty=function(){var o=new e(this.__parent);return o.set_indent(this.__indent_count,this.__alignment_count),o},e.prototype.item=function(o){return o<0?this.__items[this.__items.length+o]:this.__items[o]},e.prototype.has_match=function(o){for(var s=this.__items.length-1;s>=0;s--)if(this.__items[s].match(o))return!0;return!1},e.prototype.set_indent=function(o,s){this.is_empty()&&(this.__indent_count=o||0,this.__alignment_count=s||0,this.__character_count=this.__parent.get_indent_size(this.__indent_count,this.__alignment_count))},e.prototype._set_wrap_point=function(){this.__parent.wrap_line_length&&(this.__wrap_point_index=this.__items.length,this.__wrap_point_character_count=this.__character_count,this.__wrap_point_indent_count=this.__parent.next_line.__indent_count,this.__wrap_point_alignment_count=this.__parent.next_line.__alignment_count)},e.prototype._should_wrap=function(){return this.__wrap_point_index&&this.__character_count>this.__parent.wrap_line_length&&this.__wrap_point_character_count>this.__parent.next_line.__character_count},e.prototype._allow_wrap=function(){if(this._should_wrap()){this.__parent.add_new_line();var o=this.__parent.current_line;return o.set_indent(this.__wrap_point_indent_count,this.__wrap_point_alignment_count),o.__items=this.__items.slice(this.__wrap_point_index),this.__items=this.__items.slice(0,this.__wrap_point_index),o.__character_count+=this.__character_count-this.__wrap_point_character_count,this.__character_count=this.__wrap_point_character_count,o.__items[0]===" "&&(o.__items.splice(0,1),o.__character_count-=1),!0}return!1},e.prototype.is_empty=function(){return this.__items.length===0},e.prototype.last=function(){return this.is_empty()?null:this.__items[this.__items.length-1]},e.prototype.push=function(o){this.__items.push(o);var s=o.lastIndexOf(`
5388
5388
  `);s!==-1?this.__character_count=o.length-s:this.__character_count+=o.length},e.prototype.pop=function(){var o=null;return this.is_empty()||(o=this.__items.pop(),this.__character_count-=o.length),o},e.prototype._remove_indent=function(){this.__indent_count>0&&(this.__indent_count-=1,this.__character_count-=this.__parent.indent_size)},e.prototype._remove_wrap_indent=function(){this.__wrap_point_indent_count>0&&(this.__wrap_point_indent_count-=1)},e.prototype.trim=function(){for(;this.last()===" ";)this.__items.pop(),this.__character_count-=1},e.prototype.toString=function(){var o="";return this.is_empty()?this.__parent.indent_empty_lines&&(o=this.__parent.get_indent_string(this.__indent_count)):(o=this.__parent.get_indent_string(this.__indent_count,this.__alignment_count),o+=this.__items.join("")),o};function i(o,s){this.__cache=[""],this.__indent_size=o.indent_size,this.__indent_string=o.indent_char,o.indent_with_tabs||(this.__indent_string=new Array(o.indent_size+1).join(o.indent_char)),s=s||"",o.indent_level>0&&(s=new Array(o.indent_level+1).join(this.__indent_string)),this.__base_string=s,this.__base_string_length=s.length}i.prototype.get_indent_size=function(o,s){var r=this.__base_string_length;return s=s||0,o<0&&(r=0),r+=o*this.__indent_size,r+=s,r},i.prototype.get_indent_string=function(o,s){var r=this.__base_string;return s=s||0,o<0&&(o=0,r=""),s+=o*this.__indent_size,this.__ensure_cache(s),r+=this.__cache[s],r},i.prototype.__ensure_cache=function(o){for(;o>=this.__cache.length;)this.__add_column()},i.prototype.__add_column=function(){var o=this.__cache.length,s=0,r="";this.__indent_size&&o>=this.__indent_size&&(s=Math.floor(o/this.__indent_size),o-=s*this.__indent_size,r=new Array(s+1).join(this.__indent_string)),o&&(r+=new Array(o+1).join(" ")),this.__cache.push(r)};function n(o,s){this.__indent_cache=new i(o,s),this.raw=!1,this._end_with_newline=o.end_with_newline,this.indent_size=o.indent_size,this.wrap_line_length=o.wrap_line_length,this.indent_empty_lines=o.indent_empty_lines,this.__lines=[],this.previous_line=null,this.current_line=null,this.next_line=new e(this),this.space_before_token=!1,this.non_breaking_space=!1,this.previous_token_wrapped=!1,this.__add_outputline()}n.prototype.__add_outputline=function(){this.previous_line=this.current_line,this.current_line=this.next_line.clone_empty(),this.__lines.push(this.current_line)},n.prototype.get_line_number=function(){return this.__lines.length},n.prototype.get_indent_string=function(o,s){return this.__indent_cache.get_indent_string(o,s)},n.prototype.get_indent_size=function(o,s){return this.__indent_cache.get_indent_size(o,s)},n.prototype.is_empty=function(){return!this.previous_line&&this.current_line.is_empty()},n.prototype.add_new_line=function(o){return this.is_empty()||!o&&this.just_added_newline()?!1:(this.raw||this.__add_outputline(),!0)},n.prototype.get_code=function(o){this.trim(!0);var s=this.current_line.pop();s&&(s[s.length-1]===`
5389
5389
  `&&(s=s.replace(/\n+$/g,"")),this.current_line.push(s)),this._end_with_newline&&this.__add_outputline();var r=this.__lines.join(`
5390
5390
  `);return o!==`
@@ -5469,7 +5469,7 @@ $1`).replace(/>(\s*)(?=<!--\s*\/)/g,"> ")}}});function sce(t,A,e){if(!A||!e)retu
5469
5469
  transition: opacity 0.2s;
5470
5470
  margin-bottom: 10px;
5471
5471
  color: red;
5472
- `,UWt=({children:t,transform:A=pb(),elements:e})=>{const i=V.useRef(null),{isShowingDRCErrors:n,hoveredErrorId:o}=jB(g=>({isShowingDRCErrors:g.is_showing_drc_errors,hoveredErrorId:g.hovered_error_id}));if(!e)return W.jsx("div",{style:{position:"relative"},ref:i,children:t});const s=e.filter(g=>g.type==="pcb_trace_error"),r=e.filter(g=>g.type==="pcb_trace_error"&&g.message?.includes("Multiple components found with name")),a=new Map;return e.forEach(g=>{g.type==="pcb_port"&&a.set(g.pcb_port_id,g)}),W.jsxs("div",{style:{position:"relative"},ref:i,children:[t,s.map((g,c)=>{const{pcb_port_ids:I,pcb_trace_id:l}=g,B=I?.[0]?a.get(I[0]):void 0,C=I?.[1]?a.get(I[1]):void 0,Q=e?mb(e).pcb_trace.get(l):void 0,h=g.pcb_trace_error_id||`error_${c}_${g.error_type}_${g.message?.slice(0,20)}`,E=o===h;if(B&&C){const u=Pi(A,{x:B.x,y:B.y}),d=Pi(A,{x:C.x,y:C.y}),p=!(isNaN(u.x)||isNaN(u.y)||isNaN(d.x)||isNaN(d.y)),m={x:(u.x+d.x)/2,y:(u.y+d.y)/2};if(isNaN(m.x)||isNaN(m.y))return null;const D=kfA(m,i);return W.jsxs(V.Fragment,{children:[W.jsx(vWt,{screenPort1:u,screenPort2:d,errorCenter:m,canLineBeDrawn:p,isHighlighted:E}),W.jsx("div",{style:{position:"absolute",left:m.x-15,top:m.y-15,width:30,height:30,zIndex:uc.errorOverlay+5,cursor:"pointer",borderRadius:"50%"},onMouseEnter:w=>{const b=w.currentTarget.nextElementSibling;if(b){const k=b.querySelector(".error-message");k&&(k.style.opacity="1")}},onMouseLeave:w=>{if(!E){const b=w.currentTarget.nextElementSibling;if(b){const k=b.querySelector(".error-message");k&&(k.style.opacity="0")}}}}),W.jsx("div",{style:{position:"absolute",zIndex:E?200:100,left:D.left,top:D.top,color:E?"#ff4444":"red",textAlign:"center",fontFamily:"sans-serif",fontSize:12,display:n||E?"flex":"none",flexDirection:"column",alignItems:"center",pointerEvents:"none",transform:D.transform},children:W.jsx("div",{className:`error-message ${FfA}`,style:{opacity:E?1:0,border:`1px solid ${E?"#ff4444":"red"}`},children:g.message})})]},h)}if(Q?.route&&(n||E)){const u=Q.route.map(D=>Pi(A,{x:D.x,y:D.y}));if(u.some(D=>isNaN(D.x)||isNaN(D.y)))return null;const d=Math.floor(u.length/2),p=u[d],m=kfA(p,i);return W.jsxs(V.Fragment,{children:[W.jsx(LWt,{points:u,errorCenter:p,isHighlighted:E}),W.jsx("div",{style:{position:"absolute",left:p.x-15,top:p.y-15,width:30,height:30,zIndex:uc.errorOverlay+5,cursor:"pointer",borderRadius:"50%"},onMouseEnter:D=>{const w=D.currentTarget.nextElementSibling;if(w){const b=w.querySelector(".error-message");b&&(b.style.opacity="1")}},onMouseLeave:D=>{if(!E){const w=D.currentTarget.nextElementSibling;if(w){const b=w.querySelector(".error-message");b&&(b.style.opacity="0")}}}}),W.jsx("div",{style:{position:"absolute",zIndex:E?uc.errorOverlay+10:uc.errorOverlay+1,left:m.left,top:m.top,color:E?"#ff4444":"red",textAlign:"center",fontFamily:"sans-serif",fontSize:12,display:"flex",flexDirection:"column",alignItems:"center",pointerEvents:"none",transform:m.transform},children:W.jsx("div",{className:`error-message ${FfA}`,style:{opacity:E?1:0,border:`1px solid ${E?"#ff4444":"red"}`},children:g.message})})]},h)}return null}),r.map((g,c)=>{const I=g.component_name||g.message?.match(/name "([^"]+)"/)?.[1];if(!I)return null;const l=e?.filter(Q=>Q.type==="source_component"&&Q.name===I||Q.type==="pcb_component"&&e?.find(h=>h.type==="source_component"&&h.source_component_id===Q.source_component_id&&h.name===I))||[],B=g.pcb_trace_error_id||`error_${c}_${g.error_type}_${g.message?.slice(0,20)}`,C=o===B;return!C&&!n?null:l.map((Q,h)=>{let E={x:0,y:0};if(Q.type==="pcb_component")E=Q.center||{x:0,y:0};else if(Q.type==="source_component"){const k=e?.find(x=>x.type==="pcb_component"&&x.source_component_id===Q.source_component_id);k&&k.type==="pcb_component"&&(E=k.center||{x:0,y:0})}const u=Pi(A,E);if(isNaN(u.x)||isNaN(u.y))return null;const d=Math.abs(A.a),w=Math.max(8,Math.min(30,.5*d)),b=kfA(u,i);return W.jsxs(V.Fragment,{children:[W.jsx("svg",{style:{position:"absolute",left:0,top:0,pointerEvents:"none",mixBlendMode:"difference",zIndex:uc.errorOverlay},width:"100%",height:"100%",children:C?W.jsx("polygon",{points:`${u.x},${u.y-w*1.25} ${u.x+w},${u.y} ${u.x},${u.y+w*1.25} ${u.x-w},${u.y}`,fill:"#ff4444"}):W.jsx("circle",{cx:u.x,cy:u.y,r:w,fill:"none",stroke:C?"#ff4444":"red",strokeWidth:C?Math.max(2,w*.15):Math.max(1,w*.1),opacity:1})}),W.jsx("div",{style:{position:"absolute",left:u.x-(w+10),top:u.y-(w+10),width:(w+10)*2,height:(w+10)*2,zIndex:uc.errorOverlay+5,cursor:"pointer",borderRadius:"50%"},onMouseEnter:k=>{const x=k.currentTarget.nextElementSibling;if(x){const N=x.querySelector(".error-message");N&&(N.style.opacity="1")}},onMouseLeave:k=>{if(!C){const x=k.currentTarget.nextElementSibling;if(x){const N=x.querySelector(".error-message");N&&(N.style.opacity="0")}}}}),W.jsx("div",{style:{position:"absolute",zIndex:C?uc.errorOverlay+20:uc.errorOverlay+10,left:b.left,top:b.top,color:C?"#ff4444":"red",textAlign:"center",fontFamily:"sans-serif",fontSize:12,display:n||C?"flex":"none",flexDirection:"column",alignItems:"center",pointerEvents:"none",transform:b.transform},children:W.jsx("div",{className:`error-message ${FfA}`,style:{opacity:C?1:0,border:`1px solid ${C?"#ff4444":"red"}`},children:g.message})})]},`${B}_${h}`)})})]})};function HWt(t,A){return t.size!==A.size?!1:Array.from(t).every(e=>A.has(e))}function YWt({primitiveElement:t,elements:A}){let e=t.trace_length?`${t.trace_length.toFixed(3)}`:"";const i=mb(A).source_trace.get(t?.source_trace_id);if(i?.display_name&&(i?.max_length?e+=` / ${i.max_length}mm `:e+=" mm ",e+=`(${i.display_name})`),!e)return null;const n=t.trace_length&&i?.max_length&&t.trace_length>i.max_length;return{text:e,isOverLength:n}}function JWt(t){const{primitives:A,is_showing_multiple_traces_length:e,elements:i}=t,n=A.filter(a=>a._element.type==="pcb_trace"),o=i.filter(a=>a.type==="source_trace"),s=A.filter(a=>a._element.type!=="pcb_trace"),r=n.filter(a=>o.some(g=>a._element.type==="pcb_trace"&&a._element.source_trace_id===g.source_trace_id&&g.max_length!==void 0));if(!e)return[...s,...r];if(n.length>1){const a=n.reduce((g,c)=>{const I=g._element.trace_length;return c._element.trace_length<I?c:g},n[0]);return[...s,a]}return A}var TWt={position:"absolute",left:0,top:0,pointerEvents:"none",color:"red",fontFamily:"sans-serif",fontSize:12,textShadow:"0 0 2px black"},KWt=t=>{const{_element:A,_parent_pcb_component:e,_parent_source_component:i,_source_port:n}=t;switch(A.type){case"pcb_trace":return A.trace_length?`${A.trace_length.toFixed(3)}`:"";case"pcb_smtpad":case"pcb_plated_hole":{const o=[],s=Array.from(new Set((A.port_hints??[]).concat(n?.port_hints??[]))).filter(a=>!/^[0-9]+$/.test(a)).filter(a=>!a.includes("unnamed_")).sort((a,g)=>g.localeCompare(a)),r=i&&"name"in i&&i.name&&!i.name.includes("unnamed_")?i.name:null;return s.length>0?r?o.push(...s.map(a=>`${r}.${a}`)):o.push(...s):r&&o.push(r),o.join(", ")}default:return""}},PWt={top:"red",bottom:"aqua"},qWt=({primitive:t,mousePos:A,elements:e})=>{const[i,n]=V.useState(!1),o=t._element;V.useEffect(()=>{setTimeout(()=>{n(!0)},100)},[]);const[s,r,a,g]=[t.screen_x,t.screen_y,t.screen_w,t.screen_h],c=t.same_space_index??0,I=26,l=PWt[t?._element?.layer]??"red";let B=0;if(o.type==="pcb_smtpad"&&o?.shape==="rotated_rect"?B=o?.ccw_rotation??0:(o.type==="pcb_smtpad"&&(o?.shape==="pill"||o?.shape==="rotated_pill")&&"ccw_rotation"in t||o.type==="pcb_plated_hole"&&(o?.shape==="pill"||o?.shape==="oval")&&"ccw_rotation"in t)&&(B=o.ccw_rotation??0),o.type==="pcb_trace"){const h=YWt({primitiveElement:o,elements:e});if(!h)return null;const E=A.y-35;return W.jsx("div",{style:{zIndex:uc.elementOverlay,position:"absolute",left:A.x,top:E,color:l,pointerEvents:"none",transform:"translateX(-50%)"},children:W.jsx("div",{style:{backgroundColor:"#f2efcc",color:h.isOverLength?"red":"black",textShadow:"none",WebkitFontSmoothing:"antialiased",MozOsxFontSmoothing:"grayscale",padding:"6px 6px",borderRadius:"6px",fontSize:"14px",minWidth:"45px",textAlign:"center",whiteSpace:"nowrap"},children:h.text})})}const C=KWt(t);return C.trim().length===0?null:W.jsx("div",{style:{zIndex:uc.elementOverlay,position:"absolute",left:s-a/2-8,top:r-g/2-8,width:a+16,height:g+16,color:l,transform:`rotate(${-B}deg)`,transformOrigin:"center center"},children:W.jsx("div",{style:{width:i?`calc(100% + ${I*2*c}px)`:"100%",height:i?`calc(100% + ${I*2*c}px)`:"100%",marginLeft:i?`${-I*c}px`:0,marginTop:i?`${-I*c}px`:0,border:`1px solid ${l}`,opacity:i||c===0?1:0,transition:"width 0.2s, height 0.2s, margin-left 0.2s, margin-top 0.2s, opacity 0.2s"},children:W.jsx("div",{style:{position:"absolute",bottom:g+20+I*c,marginRight:i?`${-I*c}px`:0,marginBottom:i?0:-I*c,transition:"margin-right 0.2s, margin-bottom 0.2s",backgroundColor:"#f2efcc",color:"black",textShadow:"none",WebkitFontSmoothing:"antialiased",MozOsxFontSmoothing:"grayscale",padding:"6px 6px",borderRadius:"6px",fontSize:"14px",transform:`rotate(${B}deg)`,minWidth:"45px",textAlign:"center"},children:C})})})},OWt=({highlightedPrimitives:t,mousePos:A,elements:e})=>{const[i,n]=jB(r=>[r.is_moving_component,r.is_showing_multiple_traces_length]),o=t.some(r=>r._element.type==="pcb_smtpad")&&t.some(r=>r._element.type==="pcb_trace");let s=t;return o&&(s=s.filter(r=>r._element.type==="pcb_smtpad")),s=JWt({primitives:s,is_showing_multiple_traces_length:n,elements:e}),W.jsx("div",{style:TWt,children:!i&&s.map((r,a)=>W.jsx(qWt,{primitive:r,mousePos:A,elements:e},a))})},W_=t=>t?.type==="pcb_component",Gce=t=>t?.type==="pcb_group",WWt=t=>t?.type==="pcb_panel",GfA=t=>t?.type==="pcb_board",Zc={MIN_LINE_LENGTH_FOR_LABEL:40,LABEL_OFFSET_ABOVE:2,LABEL_OFFSET_BELOW:-18,LABEL_OFFSET_RIGHT:8,LABEL_OFFSET_LEFT:-120,Y_LABEL_MIN_WIDTH:110,LINE_STROKE_WIDTH:1.5,LINE_DASH_PATTERN:"4,4",COMPONENT_MARKER_RADIUS:3,LABEL_FONT_SIZE:11,ANCHOR_MARKER_SIZE:6,ANCHOR_MARKER_STROKE_WIDTH:1.5},v0={OFFSET_LINE:"white",COMPONENT_MARKER_FILL:"#66ccff",COMPONENT_MARKER_STROKE:"white",LABEL_TEXT:"white"},RfA=({targets:t,transform:A,containerWidth:e,containerHeight:i})=>{if(t.length===0)return null;const n={color:v0.LABEL_TEXT,mixBlendMode:"difference",pointerEvents:"none",fontSize:Zc.LABEL_FONT_SIZE,fontFamily:"monospace",fontWeight:"bold"},o=new Map;return t.forEach(s=>{if(!o.has(s.anchor_id)){const r=Pi(A,s.anchor);o.set(s.anchor_id,r)}}),W.jsx("div",{style:{position:"absolute",left:0,top:0,width:e,height:i,overflow:"hidden",pointerEvents:"none",zIndex:uc.dimensionOverlay},children:W.jsxs("svg",{style:{position:"absolute",left:0,top:0,pointerEvents:"none"},width:e,height:i,children:[t.map(s=>{const r=s.anchor,a=s.anchor_id,g=s.target,c=o.get(a),I=Pi(A,g),l=g.x-r.x,B=g.y-r.y,C=Math.abs(I.x-c.x),Q=Math.abs(I.y-c.y),h=I.y<c.y,E=I.x>c.x,u=h?Zc.LABEL_OFFSET_ABOVE:Zc.LABEL_OFFSET_BELOW,d=E?Zc.LABEL_OFFSET_RIGHT:Zc.LABEL_OFFSET_LEFT,p=C>Zc.MIN_LINE_LENGTH_FOR_LABEL,m=Q>Zc.MIN_LINE_LENGTH_FOR_LABEL,D=`${s.display_offset_x??l.toFixed(2)}mm`,w=`${s.display_offset_y??B.toFixed(2)}mm`;return W.jsxs("g",{children:[W.jsx("line",{x1:c.x,y1:c.y,x2:I.x,y2:c.y,stroke:v0.OFFSET_LINE,strokeWidth:Zc.LINE_STROKE_WIDTH,strokeDasharray:Zc.LINE_DASH_PATTERN}),W.jsx("line",{x1:I.x,y1:c.y,x2:I.x,y2:I.y,stroke:v0.OFFSET_LINE,strokeWidth:Zc.LINE_STROKE_WIDTH,strokeDasharray:Zc.LINE_DASH_PATTERN}),s.type==="component"||s.type==="board"?W.jsx("circle",{cx:I.x,cy:I.y,r:Zc.COMPONENT_MARKER_RADIUS,fill:v0.COMPONENT_MARKER_FILL,stroke:v0.COMPONENT_MARKER_STROKE,strokeWidth:1}):W.jsxs(W.Fragment,{children:[W.jsx("line",{x1:I.x-Zc.ANCHOR_MARKER_SIZE,y1:I.y,x2:I.x+Zc.ANCHOR_MARKER_SIZE,y2:I.y,stroke:v0.OFFSET_LINE,strokeWidth:Zc.ANCHOR_MARKER_STROKE_WIDTH}),W.jsx("line",{x1:I.x,y1:I.y-Zc.ANCHOR_MARKER_SIZE,x2:I.x,y2:I.y+Zc.ANCHOR_MARKER_SIZE,stroke:v0.OFFSET_LINE,strokeWidth:Zc.ANCHOR_MARKER_STROKE_WIDTH})]}),p&&W.jsx("foreignObject",{x:Math.min(c.x,I.x),y:c.y+u,width:Math.abs(I.x-c.x),height:20,style:{overflow:"visible"},children:W.jsx("div",{style:{...n,textAlign:"center"},children:D})}),m&&W.jsx("foreignObject",{x:I.x+d,y:Math.min(c.y,I.y),width:Zc.Y_LABEL_MIN_WIDTH,height:Math.abs(I.y-c.y),style:{overflow:"visible"},children:W.jsx("div",{style:{...n,display:"flex",alignItems:"center",justifyContent:E?"flex-start":"flex-end",whiteSpace:"nowrap",padding:"0 4px",height:"100%"},children:w})})]},s.id)}),Array.from(o.entries()).map(([s,r])=>W.jsxs("g",{children:[W.jsx("line",{x1:r.x-Zc.ANCHOR_MARKER_SIZE,y1:r.y,x2:r.x+Zc.ANCHOR_MARKER_SIZE,y2:r.y,stroke:v0.OFFSET_LINE,strokeWidth:Zc.ANCHOR_MARKER_STROKE_WIDTH}),W.jsx("line",{x1:r.x,y1:r.y-Zc.ANCHOR_MARKER_SIZE,x2:r.x,y2:r.y+Zc.ANCHOR_MARKER_SIZE,stroke:v0.OFFSET_LINE,strokeWidth:Zc.ANCHOR_MARKER_STROKE_WIDTH})]},`anchor-${s}`))]})})},ZWt=({elements:t,highlightedPrimitives:A,transform:e,containerWidth:i,containerHeight:n})=>{const o=t.filter(E=>GfA(E)),s=t.filter(E=>W_(E)),r=t.filter(E=>Gce(E)),a=A.map(E=>W_(E._parent_pcb_component)?E._parent_pcb_component.pcb_component_id:W_(E._element)?E._element.pcb_component_id:null).filter(E=>!!E),g=new Set;if(a.forEach(E=>{const u=s.find(d=>d.pcb_component_id===E);u?.pcb_group_id&&g.add(u.pcb_group_id)}),!jB(E=>E.is_showing_group_anchor_offsets)&&a.length===0)return null;const I=s.map(E=>{const u=E.positioned_relative_to_pcb_board_id;if(!u)return null;const d=o.find(p=>p.pcb_board_id===u);return d?{component:E,board:d,type:"component"}:null}).filter(E=>!!E),l=r.map(E=>{const u=E.positioned_relative_to_pcb_board_id;if(!u||!E.center)return null;const d=o.find(p=>p.pcb_board_id===u);return d?{group:E,board:d,type:"group"}:null}).filter(E=>!!E),B=[...I,...l];if(B.length===0)return null;const C=a.length===0,Q=B.filter(E=>E.type==="component"?C||a.includes(E.component.pcb_component_id):C||g.has(E.group.pcb_group_id));if(Q.length===0)return null;const h=Q.map(E=>E.type==="component"?{id:`${E.board.pcb_board_id}-${E.component.pcb_component_id}-${E.type}`,anchor:E.board.center,anchor_id:E.board.pcb_board_id,target:E.component.center,type:"component",display_offset_x:E.component.display_offset_x,display_offset_y:E.component.display_offset_y}:{id:`${E.board.pcb_board_id}-${E.group.pcb_group_id}-${E.type}`,anchor:E.board.center,anchor_id:E.board.pcb_board_id,target:{x:E.group.anchor_position?.x??E.group.center.x,y:E.group.anchor_position?.y??E.group.center.y},type:"group",display_offset_x:E.group.display_offset_x,display_offset_y:E.group.display_offset_y}).filter(E=>!!E);return W.jsx(RfA,{targets:h,transform:e,containerWidth:i,containerHeight:n})},VWt=({elements:t,highlightedPrimitives:A,transform:e,containerWidth:i,containerHeight:n})=>{const o=t.filter(E=>Gce(E)),s=t.filter(E=>W_(E)),r=A.map(E=>W_(E._parent_pcb_component)?E._parent_pcb_component.pcb_component_id:W_(E._element)?E._element.pcb_component_id:null).filter(E=>!!E),a=(E,u)=>{if(u.has(E))return;u.add(E);const d=o.find(p=>p.pcb_group_id===E);d?.position_mode==="relative_to_group_anchor"&&d.positioned_relative_to_pcb_group_id&&a(d.positioned_relative_to_pcb_group_id,u)},g=new Set;if(r.forEach(E=>{const u=s.find(d=>d.pcb_component_id===E);u&&(u.position_mode==="relative_to_group_anchor"&&u.positioned_relative_to_pcb_group_id&&a(u.positioned_relative_to_pcb_group_id,g),u.pcb_group_id&&a(u.pcb_group_id,g))}),!jB(E=>E.is_showing_group_anchor_offsets)&&r.length===0)return null;const I=s.map(E=>{if(E.position_mode==="relative_to_group_anchor"&&E.positioned_relative_to_pcb_group_id){const u=o.find(d=>d.pcb_group_id===E.positioned_relative_to_pcb_group_id);return u&&u.anchor_position?{component:E,parentGroup:u,type:"component"}:null}if(E.pcb_group_id){const u=o.find(d=>d.pcb_group_id===E.pcb_group_id);return u&&u.anchor_position?{component:E,parentGroup:u,type:"component"}:null}return null}).filter(E=>!!E),l=o.map(E=>{if(E.position_mode==="relative_to_group_anchor"&&E.positioned_relative_to_pcb_group_id){const u=o.find(d=>d.pcb_group_id===E.positioned_relative_to_pcb_group_id);if(u&&u.anchor_position&&E.anchor_position)return{group:E,parentGroup:u,type:"group"}}return null}).filter(E=>!!E),B=[...I,...l];if(B.length===0)return null;const C=r.length===0,Q=B.filter(E=>E.type==="component"?C||r.includes(E.component.pcb_component_id):C||g.has(E.group.pcb_group_id)||g.has(E.parentGroup.pcb_group_id));if(Q.length===0)return null;const h=Q.map(E=>{const u=E.parentGroup.anchor_position;return u?E.type==="component"?E.component.center?{id:`${E.parentGroup.pcb_group_id}-${E.component.pcb_component_id}-${E.type}`,anchor:u,anchor_id:E.parentGroup.pcb_group_id,target:E.component.center,type:"component",display_offset_x:E.component.display_offset_x,display_offset_y:E.component.display_offset_y}:null:E.group.anchor_position?{id:`${E.parentGroup.pcb_group_id}-${E.group.pcb_group_id}-${E.type}`,anchor:u,anchor_id:E.parentGroup.pcb_group_id,target:E.group.anchor_position,type:"group",display_offset_x:E.group.display_offset_x,display_offset_y:E.group.display_offset_y}:null:null}).filter(E=>!!E);return W.jsx(RfA,{targets:h,transform:e,containerWidth:i,containerHeight:n})},jWt=(t,A)=>{const e=t.pcb_component_id,i=A.filter(n=>(n.type==="pcb_smtpad"||n.type==="pcb_plated_hole")&&n.pcb_component_id===e||n.type==="pcb_hole"&&n.pcb_component_id===e);return i.length===0?xfA([t]):xfA(i)},zWt=({elements:t,highlightedPrimitives:A,transform:e,containerWidth:i,containerHeight:n})=>{const o=new Map;for(const r of A)W_(r._parent_pcb_component)&&o.set(r._parent_pcb_component.pcb_component_id,r._parent_pcb_component),W_(r._element)&&o.set(r._element.pcb_component_id,r._element);if(o.size===0)return null;const s=[];for(const r of o.values()){const a=jWt(r,t);if(!a)continue;const g=r.positioned_relative_to_pcb_group_id??r.pcb_group_id,c=g?mb(t).pcb_group.get(g):null;s.push({component:r,bbox:a,group:c})}return s.length===0?null:W.jsx("div",{style:{position:"absolute",left:0,top:0,width:i,height:n,overflow:"hidden",pointerEvents:"none",zIndex:uc.dimensionOverlay},children:W.jsx("svg",{style:{position:"absolute",left:0,top:0,pointerEvents:"none"},width:i,height:n,children:s.map(({component:r,bbox:a,group:g})=>{const c=Pi(e,{x:a.minX,y:a.maxY}),I=Pi(e,{x:a.maxX,y:a.minY}),l={x:Math.min(c.x,I.x),y:Math.min(c.y,I.y),width:Math.abs(I.x-c.x),height:Math.abs(I.y-c.y)},B=r.center??{x:(a.minX+a.maxX)/2,y:(a.minY+a.maxY)/2},C=Pi(e,B);return W.jsxs("g",{children:[W.jsx("rect",{x:l.x,y:l.y,width:l.width,height:l.height,fill:"none",stroke:"white",strokeWidth:1.5,strokeDasharray:"4,4"}),W.jsx("line",{x1:C.x-6,y1:C.y,x2:C.x+6,y2:C.y,stroke:v0.COMPONENT_MARKER_STROKE,strokeWidth:1.5}),W.jsx("line",{x1:C.x,y1:C.y-6,x2:C.x,y2:C.y+6,stroke:v0.COMPONENT_MARKER_STROKE,strokeWidth:1.5}),W.jsx("circle",{cx:C.x,cy:C.y,r:Zc.COMPONENT_MARKER_RADIUS,fill:v0.COMPONENT_MARKER_FILL,stroke:v0.COMPONENT_MARKER_STROKE,strokeWidth:1})]},r.pcb_component_id)})})})},XWt=({elements:t,highlightedPrimitives:A,transform:e,containerWidth:i,containerHeight:n})=>{const o=t.filter(B=>WWt(B)),s=t.filter(B=>GfA(B)),r=A.map(B=>GfA(B._element)?B._element.pcb_board_id:null).filter(B=>!!B);if(!jB(B=>B.is_showing_group_anchor_offsets)&&r.length===0)return null;const g=s.map(B=>{const C=B.pcb_panel_id,Q=B.position_mode;if(!C||Q!=="relative_to_panel_anchor")return null;const h=o.find(E=>E.pcb_panel_id===C);return h?{board:B,panel:h,type:"board"}:null}).filter(B=>!!B);if(g.length===0)return null;const c=r.length===0,I=g.filter(B=>c||r.includes(B.board.pcb_board_id));if(I.length===0)return null;const l=I.map(B=>B.board.center?{id:`${B.panel.pcb_panel_id}-${B.board.pcb_board_id}-${B.type}`,anchor:B.panel.center,anchor_id:B.panel.pcb_panel_id,target:B.board.center,type:"board",display_offset_x:B.board.display_offset_x,display_offset_y:B.board.display_offset_y}:null).filter(B=>!!B);return W.jsx(RfA,{targets:l,transform:e,containerWidth:i,containerHeight:n})},Y9=t=>{if(t.length===0)return null;let A=t[0].x,e=t[0].y,i=t[0].x,n=t[0].y;for(const o of t)o.x<A&&(A=o.x),o.y<e&&(e=o.y),o.x>i&&(i=o.x),o.y>n&&(n=o.y);return{center:{x:(A+i)/2,y:(e+n)/2},width:i-A,height:n-e}},Rce=(t,A)=>{if(A.length<3)return!1;let e=!1;for(let i=0,n=A.length-1;i<A.length;n=i++){const o=A[i].x,s=A[i].y,r=A[n].x,a=A[n].y;s>t.y!=a>t.y&&t.x<(r-o)*(t.y-s)/(a-s||Number.EPSILON)+o&&(e=!e)}return e},$Wt=(t,A,e)=>{const i=[];for(const n of t){if(!n._element)continue;if("x1"in n&&n._element?.type==="pcb_trace"){const r=EE({x:A.x,y:A.y},{x:n.x1,y:n.y1},{x:n.x2,y:n.y2}),a=n.width||.5,g=Math.max(a*25,2)/e.a;r<g&&i.push(n);continue}if(n.pcb_drawing_type==="polygon"){const r=n.points.map(g=>({x:ut.parse(g.x),y:ut.parse(g.y)})),a=Y9(r);if(!a||A.x<a.center.x-a.width/2||A.x>a.center.x+a.width/2||A.y<a.center.y-a.height/2||A.y>a.center.y+a.height/2)continue;Rce(A,r)&&i.push(n);continue}if(n.pcb_drawing_type==="polygon_with_arcs"){const r=n.brep_shape.outer_ring.vertices.map(g=>({x:ut.parse(g.x),y:ut.parse(g.y)})),a=Y9(r);if(!a||A.x<a.center.x-a.width/2||A.x>a.center.x+a.width/2||A.y<a.center.y-a.height/2||A.y>a.center.y+a.height/2)continue;Rce(A,r)&&i.push(n);continue}if(!("x"in n&&"y"in n))continue;let o=0,s=0;if("w"in n&&"h"in n)o=n.w,s=n.h;else if("r"in n)o=n.r*2,s=n.r*2;else if("rX"in n&&"rY"in n)o=n.rX*2,s=n.rY*2;else continue;Math.abs(n.x-A.x)<o/2&&Math.abs(n.y-A.y)<s/2&&i.push(n)}return i},AZt=({elements:t,children:A,transform:e,primitives:i,onMouseHoverOverPrimitives:n})=>{const[o,s]=V.useState([]),[r,a]=V.useState({x:0,y:0}),[g,{width:c,height:I}]=EJ(),l=V.useMemo(()=>{const C=[];for(const Q of o){if(Q._element?.type==="pcb_via"||Q._element?.type==="pcb_component"||Q?.layer==="drill")continue;let h=null,E=0,u=0;if(Q.pcb_drawing_type==="polygon"){const D=Y9(Q.points);if(!D)continue;h=D.center,E=D.width,u=D.height}else if(Q.pcb_drawing_type==="polygon_with_arcs"){const D=Q.brep_shape.outer_ring.vertices.map(b=>({x:b.x,y:b.y})),w=Y9(D);if(!w)continue;h=w.center,E=w.width,u=w.height}else"x"in Q&&"y"in Q&&(h={x:Q.x,y:Q.y},E="w"in Q?Q.w:"r"in Q?Q.r*2:"rX"in Q&&"rY"in Q?Q.rX*2:0,u="h"in Q?Q.h:"r"in Q?Q.r*2:"rX"in Q&&"rY"in Q?Q.rY*2:0);if(!h)continue;const d=Pi(e,h),p={w:E*e.a,h:u*e.a},m=C.filter(D=>d.x===D.screen_x&&d.y===D.screen_y&&p.w===D.screen_w&&p.h===D.screen_h).length;C.push({...Q,x:h.x,y:h.y,w:E,h:u,screen_x:d.x,screen_y:d.y,screen_w:p.w,screen_h:p.h,same_space_index:m})}return C},[o,e]),B=(C,Q,h,E)=>{a({x:C,y:Q});const u=Pi(fb(h),{x:C,y:Q}),d=$Wt(E,u,h);HWt(new Set(d.map(p=>p._pcb_drawing_object_id)),new Set(o.map(p=>p._pcb_drawing_object_id)))||(s(d),n(d))};return W.jsxs("div",{ref:g,style:{position:"relative",width:"100%",height:"100%"},onMouseMove:C=>{if(e){const Q=C.currentTarget.getBoundingClientRect(),h=C.clientX-Q.left,E=C.clientY-Q.top;B(h,E,e,i)}},onTouchStart:C=>{if(e){const Q=C.touches[0],h=C.currentTarget.getBoundingClientRect(),E=Q.clientX-h.left,u=Q.clientY-h.top;B(E,u,e,i)}},children:[A,W.jsx(OWt,{elements:t,mousePos:r,highlightedPrimitives:l}),e&&W.jsxs(W.Fragment,{children:[W.jsx(ZWt,{elements:t,highlightedPrimitives:l,transform:e,containerWidth:c,containerHeight:I}),W.jsx(VWt,{elements:t,highlightedPrimitives:l,transform:e,containerWidth:c,containerHeight:I}),W.jsx(zWt,{elements:t,highlightedPrimitives:l,transform:e,containerWidth:c,containerHeight:I}),W.jsx(XWt,{elements:t,highlightedPrimitives:l,transform:e,containerWidth:c,containerHeight:I})]})]})},Mce=["rgb(255, 100, 100)","rgb(100, 255, 100)","rgb(100, 100, 255)","rgb(255, 255, 100)","rgb(255, 100, 255)","rgb(100, 255, 255)","rgb(255, 150, 100)","rgb(150, 100, 255)","rgb(100, 255, 150)","rgb(255, 100, 150)"],eZt=({children:t,transform:A=pb(),elements:e=[],hoveredComponentIds:i=[]})=>{const[n,{width:o,height:s}]=EJ(),r=V.useRef(null),{is_showing_pcb_groups:a,pcb_group_view_mode:g,is_showing_group_anchor_offsets:c}=jB(I=>({is_showing_pcb_groups:I.is_showing_pcb_groups,pcb_group_view_mode:I.pcb_group_view_mode,is_showing_group_anchor_offsets:I.is_showing_group_anchor_offsets}));return V.useEffect(()=>{const I=r.current;if(!I||!o||!s)return;I.width=o,I.height=s;const l=I.getContext("2d");if(!l||(l.clearRect(0,0,o,s),!a))return;const B=e.filter(D=>D.type==="pcb_group"),C=e.filter(D=>D.type==="pcb_component"),Q=e.filter(D=>D.type==="source_group"),h=new Map(Q.map(D=>[D.source_group_id,D])),E=B.filter(D=>{if(g==="all")return!0;if(!D.source_group_id)return!1;const w=h.get(D.source_group_id);return w?w.was_automatically_named!==!0:!1}),u=new Map;Q.forEach(D=>{const w=D;if(w.parent_source_group_id){const b=u.get(w.parent_source_group_id)||[];b.push(D.source_group_id),u.set(w.parent_source_group_id,b)}});const d=D=>{const w=[],b=u.get(D)||[];for(const k of b)w.push(k),w.push(...d(k));return w},p=D=>{const w=Q.find(b=>b.source_group_id===D);return w?.parent_source_group_id?1+p(w.parent_source_group_id):0},m=new Set;if(i.length>0)for(const D of C){if(!i.includes(D.pcb_component_id))continue;const w=D.positioned_relative_to_pcb_group_id??D.pcb_group_id;w&&m.add(w)}E.forEach((D,w)=>{let b=C.filter(HA=>HA.pcb_group_id===D.pcb_group_id);if(D.source_group_id){const HA=d(D.source_group_id),ZA=B.filter(kA=>kA.source_group_id&&HA.includes(kA.source_group_id));for(const kA of ZA){const wA=C.filter(UA=>UA.pcb_group_id===kA.pcb_group_id);b=[...b,...wA]}}let k,x,N,M,U=!1;if(D.center&&D.width&&D.height){U=!0;const HA=D.width/2,ZA=D.height/2;k=D.center.x-HA,N=D.center.x+HA,x=D.center.y-ZA,M=D.center.y+ZA}else if(b.length===0||(k=1/0,x=1/0,N=-1/0,M=-1/0,b.forEach(HA=>{if(HA.center&&typeof HA.width=="number"&&typeof HA.height=="number"){const ZA=HA.center.x-HA.width/2,kA=HA.center.x+HA.width/2,wA=HA.center.y+HA.height/2,UA=HA.center.y-HA.height/2;k=Math.min(k,ZA),N=Math.max(N,kA),x=Math.min(x,UA),M=Math.max(M,wA)}}),k===1/0||N===-1/0))return;const Y=D.source_group_id?p(D.source_group_id):0,H=D.source_group_id?d(D.source_group_id).length>0:!1;if(!U){const kA=1+(H?.5:0);k-=kA,N+=kA,x-=kA,M+=kA}const O=Pi(A,{x:k,y:M}),Z=Pi(A,{x:N,y:M}),$=Pi(A,{x:k,y:x}),iA=Pi(A,{x:N,y:x}),aA=Mce[w%Mce.length];l.strokeStyle=aA,l.lineWidth=2;const eA=Math.max(4,Math.min(12,8*Math.abs(A.a))),nA=Math.max(2,Math.min(6,4*Math.abs(A.a))),lA=eA*(H?1.3:1),pA=nA;l.setLineDash([lA,pA]),l.beginPath(),l.moveTo(O.x,O.y),l.lineTo(Z.x,Z.y),l.lineTo(iA.x,iA.y),l.lineTo($.x,$.y),l.closePath(),l.stroke();const xA=Math.max(8,Math.min(12,10*Math.abs(A.a))),RA=Y==0||Y==1?0:Y*.11,YA=xA*(1-RA),CA=4,_A=D.name||`Group ${w+1}`;l.font=`${YA}px sans-serif`,l.setLineDash([]);const KA=l.measureText(_A).width+CA*2,TA=YA+CA*2,ie=O.x-5,fA=O.y-5,$A=3;if(l.fillStyle="rgba(0, 0, 0, 0.8)",l.beginPath(),l.roundRect(ie,fA-TA,KA,TA,$A),l.fill(),l.fillStyle=aA,l.textAlign="left",l.textBaseline="middle",l.fillText(_A,ie+CA,fA-TA/2),c&&m.has(D.pcb_group_id)&&!!D.anchor_position&&D.anchor_position){const HA=Array.isArray(D.anchor_position)?{x:D.anchor_position[0]??0,y:D.anchor_position[1]??0}:{x:D.anchor_position.x,y:D.anchor_position.y},ZA=Pi(A,HA);l.strokeStyle="white",l.lineWidth=1.5,l.setLineDash([]);const kA=Math.max(4,Math.min(8,6*Math.abs(A.a)));l.beginPath(),l.moveTo(ZA.x-kA,ZA.y),l.lineTo(ZA.x+kA,ZA.y),l.stroke(),l.beginPath(),l.moveTo(ZA.x,ZA.y-kA),l.lineTo(ZA.x,ZA.y+kA),l.stroke()}})},[e,A,o,s,a,g,c,i]),W.jsxs("div",{ref:n,style:{position:"relative",width:"100%",height:"100%"},children:[t,W.jsx("canvas",{ref:r,style:{position:"absolute",top:0,left:0,pointerEvents:"none",zIndex:uc.pcbGroupOverlay,display:a?"block":"none"}})]})},tZt=({transform:t,soup:A,children:e})=>{const i=jB(r=>r.is_showing_rats_nest),{netMap:n,idToNetMap:o}=V.useMemo(()=>Bce(A||[]),[A]),s=V.useMemo(()=>{if(!A||!i)return[];const r=l=>{const B=mb(A)[l.replace(/_\d+$/,"")].get(l);return B&&"x"in B&&"y"in B?{x:B.x,y:B.y}:null},a=(l,B)=>{const C=n[B]||[];let Q=null,h=1/0;return C.forEach(E=>{const u=r(E);if(u){const d=Math.sqrt((l.x-u.x)**2+(l.y-u.y)**2);d<h&&d>0&&(h=d,Q=u)}}),Q},g=mb(A).pcb_port.list(),c=mb(A).source_trace.list(),I=[];return g.forEach((l,B)=>{const C=o[l.pcb_port_id];let Q=!1;for(const u of c)u.connected_source_port_ids.includes(l.source_port_id)&&u.connected_source_net_ids.length>0&&(Q=!0);if(!C)return;const h={x:l.x,y:l.y},E=a(h,C);E&&I.push({key:`${l.pcb_port_id}-${B}`,startPoint:h,endPoint:E,isInNet:Q})}),I},[A,n,o,i]);return!A||!i?e:(t||(t=pb()),W.jsxs("div",{style:{position:"relative"},children:[e,W.jsx("svg",{style:{position:"absolute",left:0,top:0,width:"100%",height:"100%",pointerEvents:"none",opacity:.5,zIndex:uc.ratsNestOverlay},children:s.map(({key:r,startPoint:a,endPoint:g,isInNet:c})=>{const I=Pi(t,a),l=Pi(t,g);return W.jsx("line",{x1:I.x,y1:I.y,x2:l.x,y2:l.y,stroke:"white",strokeWidth:"1",strokeDasharray:c?"6,6":void 0},r)})})]}))},iZt={version:"1.11.325"},Z_=(t,A,e)=>{const i=jB(s=>s.is_mouse_over_container),n=V.useRef(i),o=V.useRef(A);V.useEffect(()=>{n.current=i},[i]),V.useEffect(()=>{o.current=A},[A]),V.useEffect(()=>{if(!t)return;const s=r=>{const a=r.target;if(a.tagName==="INPUT"||a.tagName==="TEXTAREA"||a.isContentEditable)return;const g=t.split("+"),c=g.includes("ctrl"),I=g.includes("shift"),l=g.includes("alt"),B=g.includes("meta"),C=g[g.length-1],Q=e?.current?e.current.contains(document.activeElement)||document.activeElement===e.current:!1;(n.current||Q)&&(!c||r.ctrlKey)&&(!I||r.shiftKey)&&(!l||r.altKey)&&(!B||r.metaKey)&&r.key.toLowerCase()===C.toLowerCase()&&(r.preventDefault(),o.current())};return window.addEventListener("keydown",s),()=>{window.removeEventListener("keydown",s)}},[t])},nZt=()=>{const[t,A]=V.useState(!1);return V.useEffect(()=>{const e=()=>{A(window.innerWidth<=768)};return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]),t},oZt=({name:t,selected:A,onClick:e})=>W.jsxs("div",{className:A1`
5472
+ `,UWt=({children:t,transform:A=pb(),elements:e})=>{const i=V.useRef(null),{isShowingDRCErrors:n,hoveredErrorId:o}=jB(g=>({isShowingDRCErrors:g.is_showing_drc_errors,hoveredErrorId:g.hovered_error_id}));if(!e)return W.jsx("div",{style:{position:"relative"},ref:i,children:t});const s=e.filter(g=>g.type==="pcb_trace_error"),r=e.filter(g=>g.type==="pcb_trace_error"&&g.message?.includes("Multiple components found with name")),a=new Map;return e.forEach(g=>{g.type==="pcb_port"&&a.set(g.pcb_port_id,g)}),W.jsxs("div",{style:{position:"relative"},ref:i,children:[t,s.map((g,c)=>{const{pcb_port_ids:I,pcb_trace_id:l}=g,B=I?.[0]?a.get(I[0]):void 0,C=I?.[1]?a.get(I[1]):void 0,Q=e?mb(e).pcb_trace.get(l):void 0,h=g.pcb_trace_error_id||`error_${c}_${g.error_type}_${g.message?.slice(0,20)}`,E=o===h;if(B&&C){const u=Pi(A,{x:B.x,y:B.y}),d=Pi(A,{x:C.x,y:C.y}),p=!(isNaN(u.x)||isNaN(u.y)||isNaN(d.x)||isNaN(d.y)),m={x:(u.x+d.x)/2,y:(u.y+d.y)/2};if(isNaN(m.x)||isNaN(m.y))return null;const D=kfA(m,i);return W.jsxs(V.Fragment,{children:[W.jsx(vWt,{screenPort1:u,screenPort2:d,errorCenter:m,canLineBeDrawn:p,isHighlighted:E}),W.jsx("div",{style:{position:"absolute",left:m.x-15,top:m.y-15,width:30,height:30,zIndex:uc.errorOverlay+5,cursor:"pointer",borderRadius:"50%"},onMouseEnter:w=>{const b=w.currentTarget.nextElementSibling;if(b){const k=b.querySelector(".error-message");k&&(k.style.opacity="1")}},onMouseLeave:w=>{if(!E){const b=w.currentTarget.nextElementSibling;if(b){const k=b.querySelector(".error-message");k&&(k.style.opacity="0")}}}}),W.jsx("div",{style:{position:"absolute",zIndex:E?200:100,left:D.left,top:D.top,color:E?"#ff4444":"red",textAlign:"center",fontFamily:"sans-serif",fontSize:12,display:n||E?"flex":"none",flexDirection:"column",alignItems:"center",pointerEvents:"none",transform:D.transform},children:W.jsx("div",{className:`error-message ${FfA}`,style:{opacity:E?1:0,border:`1px solid ${E?"#ff4444":"red"}`},children:g.message})})]},h)}if(Q?.route&&(n||E)){const u=Q.route.map(D=>Pi(A,{x:D.x,y:D.y}));if(u.some(D=>isNaN(D.x)||isNaN(D.y)))return null;const d=Math.floor(u.length/2),p=u[d],m=kfA(p,i);return W.jsxs(V.Fragment,{children:[W.jsx(LWt,{points:u,errorCenter:p,isHighlighted:E}),W.jsx("div",{style:{position:"absolute",left:p.x-15,top:p.y-15,width:30,height:30,zIndex:uc.errorOverlay+5,cursor:"pointer",borderRadius:"50%"},onMouseEnter:D=>{const w=D.currentTarget.nextElementSibling;if(w){const b=w.querySelector(".error-message");b&&(b.style.opacity="1")}},onMouseLeave:D=>{if(!E){const w=D.currentTarget.nextElementSibling;if(w){const b=w.querySelector(".error-message");b&&(b.style.opacity="0")}}}}),W.jsx("div",{style:{position:"absolute",zIndex:E?uc.errorOverlay+10:uc.errorOverlay+1,left:m.left,top:m.top,color:E?"#ff4444":"red",textAlign:"center",fontFamily:"sans-serif",fontSize:12,display:"flex",flexDirection:"column",alignItems:"center",pointerEvents:"none",transform:m.transform},children:W.jsx("div",{className:`error-message ${FfA}`,style:{opacity:E?1:0,border:`1px solid ${E?"#ff4444":"red"}`},children:g.message})})]},h)}return null}),r.map((g,c)=>{const I=g.component_name||g.message?.match(/name "([^"]+)"/)?.[1];if(!I)return null;const l=e?.filter(Q=>Q.type==="source_component"&&Q.name===I||Q.type==="pcb_component"&&e?.find(h=>h.type==="source_component"&&h.source_component_id===Q.source_component_id&&h.name===I))||[],B=g.pcb_trace_error_id||`error_${c}_${g.error_type}_${g.message?.slice(0,20)}`,C=o===B;return!C&&!n?null:l.map((Q,h)=>{let E={x:0,y:0};if(Q.type==="pcb_component")E=Q.center||{x:0,y:0};else if(Q.type==="source_component"){const k=e?.find(x=>x.type==="pcb_component"&&x.source_component_id===Q.source_component_id);k&&k.type==="pcb_component"&&(E=k.center||{x:0,y:0})}const u=Pi(A,E);if(isNaN(u.x)||isNaN(u.y))return null;const d=Math.abs(A.a),w=Math.max(8,Math.min(30,.5*d)),b=kfA(u,i);return W.jsxs(V.Fragment,{children:[W.jsx("svg",{style:{position:"absolute",left:0,top:0,pointerEvents:"none",mixBlendMode:"difference",zIndex:uc.errorOverlay},width:"100%",height:"100%",children:C?W.jsx("polygon",{points:`${u.x},${u.y-w*1.25} ${u.x+w},${u.y} ${u.x},${u.y+w*1.25} ${u.x-w},${u.y}`,fill:"#ff4444"}):W.jsx("circle",{cx:u.x,cy:u.y,r:w,fill:"none",stroke:C?"#ff4444":"red",strokeWidth:C?Math.max(2,w*.15):Math.max(1,w*.1),opacity:1})}),W.jsx("div",{style:{position:"absolute",left:u.x-(w+10),top:u.y-(w+10),width:(w+10)*2,height:(w+10)*2,zIndex:uc.errorOverlay+5,cursor:"pointer",borderRadius:"50%"},onMouseEnter:k=>{const x=k.currentTarget.nextElementSibling;if(x){const N=x.querySelector(".error-message");N&&(N.style.opacity="1")}},onMouseLeave:k=>{if(!C){const x=k.currentTarget.nextElementSibling;if(x){const N=x.querySelector(".error-message");N&&(N.style.opacity="0")}}}}),W.jsx("div",{style:{position:"absolute",zIndex:C?uc.errorOverlay+20:uc.errorOverlay+10,left:b.left,top:b.top,color:C?"#ff4444":"red",textAlign:"center",fontFamily:"sans-serif",fontSize:12,display:n||C?"flex":"none",flexDirection:"column",alignItems:"center",pointerEvents:"none",transform:b.transform},children:W.jsx("div",{className:`error-message ${FfA}`,style:{opacity:C?1:0,border:`1px solid ${C?"#ff4444":"red"}`},children:g.message})})]},`${B}_${h}`)})})]})};function HWt(t,A){return t.size!==A.size?!1:Array.from(t).every(e=>A.has(e))}function YWt({primitiveElement:t,elements:A}){let e=t.trace_length?`${t.trace_length.toFixed(3)}`:"";const i=mb(A).source_trace.get(t?.source_trace_id);if(i?.display_name&&(i?.max_length?e+=` / ${i.max_length}mm `:e+=" mm ",e+=`(${i.display_name})`),!e)return null;const n=t.trace_length&&i?.max_length&&t.trace_length>i.max_length;return{text:e,isOverLength:n}}function JWt(t){const{primitives:A,is_showing_multiple_traces_length:e,elements:i}=t,n=A.filter(a=>a._element.type==="pcb_trace"),o=i.filter(a=>a.type==="source_trace"),s=A.filter(a=>a._element.type!=="pcb_trace"),r=n.filter(a=>o.some(g=>a._element.type==="pcb_trace"&&a._element.source_trace_id===g.source_trace_id&&g.max_length!==void 0));if(!e)return[...s,...r];if(n.length>1){const a=n.reduce((g,c)=>{const I=g._element.trace_length;return c._element.trace_length<I?c:g},n[0]);return[...s,a]}return A}var TWt={position:"absolute",left:0,top:0,pointerEvents:"none",color:"red",fontFamily:"sans-serif",fontSize:12,textShadow:"0 0 2px black"},KWt=t=>{const{_element:A,_parent_pcb_component:e,_parent_source_component:i,_source_port:n}=t;switch(A.type){case"pcb_trace":return A.trace_length?`${A.trace_length.toFixed(3)}`:"";case"pcb_smtpad":case"pcb_plated_hole":{const o=[],s=Array.from(new Set((A.port_hints??[]).concat(n?.port_hints??[]))).filter(a=>!/^[0-9]+$/.test(a)).filter(a=>!a.includes("unnamed_")).sort((a,g)=>g.localeCompare(a)),r=i&&"name"in i&&i.name&&!i.name.includes("unnamed_")?i.name:null;return s.length>0?r?o.push(...s.map(a=>`${r}.${a}`)):o.push(...s):r&&o.push(r),o.join(", ")}default:return""}},PWt={top:"red",bottom:"aqua"},qWt=({primitive:t,mousePos:A,elements:e})=>{const[i,n]=V.useState(!1),o=t._element;V.useEffect(()=>{setTimeout(()=>{n(!0)},100)},[]);const[s,r,a,g]=[t.screen_x,t.screen_y,t.screen_w,t.screen_h],c=t.same_space_index??0,I=26,l=PWt[t?._element?.layer]??"red";let B=0;if(o.type==="pcb_smtpad"&&o?.shape==="rotated_rect"?B=o?.ccw_rotation??0:(o.type==="pcb_smtpad"&&(o?.shape==="pill"||o?.shape==="rotated_pill")&&"ccw_rotation"in t||o.type==="pcb_plated_hole"&&(o?.shape==="pill"||o?.shape==="oval")&&"ccw_rotation"in t)&&(B=o.ccw_rotation??0),o.type==="pcb_trace"){const h=YWt({primitiveElement:o,elements:e});if(!h)return null;const E=A.y-35;return W.jsx("div",{style:{zIndex:uc.elementOverlay,position:"absolute",left:A.x,top:E,color:l,pointerEvents:"none",transform:"translateX(-50%)"},children:W.jsx("div",{style:{backgroundColor:"#f2efcc",color:h.isOverLength?"red":"black",textShadow:"none",WebkitFontSmoothing:"antialiased",MozOsxFontSmoothing:"grayscale",padding:"6px 6px",borderRadius:"6px",fontSize:"14px",minWidth:"45px",textAlign:"center",whiteSpace:"nowrap"},children:h.text})})}const C=KWt(t);return C.trim().length===0?null:W.jsx("div",{style:{zIndex:uc.elementOverlay,position:"absolute",left:s-a/2-8,top:r-g/2-8,width:a+16,height:g+16,color:l,transform:`rotate(${-B}deg)`,transformOrigin:"center center"},children:W.jsx("div",{style:{width:i?`calc(100% + ${I*2*c}px)`:"100%",height:i?`calc(100% + ${I*2*c}px)`:"100%",marginLeft:i?`${-I*c}px`:0,marginTop:i?`${-I*c}px`:0,border:`1px solid ${l}`,opacity:i||c===0?1:0,transition:"width 0.2s, height 0.2s, margin-left 0.2s, margin-top 0.2s, opacity 0.2s"},children:W.jsx("div",{style:{position:"absolute",bottom:g+20+I*c,marginRight:i?`${-I*c}px`:0,marginBottom:i?0:-I*c,transition:"margin-right 0.2s, margin-bottom 0.2s",backgroundColor:"#f2efcc",color:"black",textShadow:"none",WebkitFontSmoothing:"antialiased",MozOsxFontSmoothing:"grayscale",padding:"6px 6px",borderRadius:"6px",fontSize:"14px",transform:`rotate(${B}deg)`,minWidth:"45px",textAlign:"center"},children:C})})})},OWt=({highlightedPrimitives:t,mousePos:A,elements:e})=>{const[i,n]=jB(r=>[r.is_moving_component,r.is_showing_multiple_traces_length]),o=t.some(r=>r._element.type==="pcb_smtpad")&&t.some(r=>r._element.type==="pcb_trace");let s=t;return o&&(s=s.filter(r=>r._element.type==="pcb_smtpad")),s=JWt({primitives:s,is_showing_multiple_traces_length:n,elements:e}),W.jsx("div",{style:TWt,children:!i&&s.map((r,a)=>W.jsx(qWt,{primitive:r,mousePos:A,elements:e},a))})},W_=t=>t?.type==="pcb_component",Gce=t=>t?.type==="pcb_group",WWt=t=>t?.type==="pcb_panel",GfA=t=>t?.type==="pcb_board",Zc={MIN_LINE_LENGTH_FOR_LABEL:40,LABEL_OFFSET_ABOVE:2,LABEL_OFFSET_BELOW:-18,LABEL_OFFSET_RIGHT:8,LABEL_OFFSET_LEFT:-120,Y_LABEL_MIN_WIDTH:110,LINE_STROKE_WIDTH:1.5,LINE_DASH_PATTERN:"4,4",COMPONENT_MARKER_RADIUS:3,LABEL_FONT_SIZE:11,ANCHOR_MARKER_SIZE:6,ANCHOR_MARKER_STROKE_WIDTH:1.5},v0={OFFSET_LINE:"white",COMPONENT_MARKER_FILL:"#66ccff",COMPONENT_MARKER_STROKE:"white",LABEL_TEXT:"white"},RfA=({targets:t,transform:A,containerWidth:e,containerHeight:i})=>{if(t.length===0)return null;const n={color:v0.LABEL_TEXT,mixBlendMode:"difference",pointerEvents:"none",fontSize:Zc.LABEL_FONT_SIZE,fontFamily:"monospace",fontWeight:"bold"},o=new Map;return t.forEach(s=>{if(!o.has(s.anchor_id)){const r=Pi(A,s.anchor);o.set(s.anchor_id,r)}}),W.jsx("div",{style:{position:"absolute",left:0,top:0,width:e,height:i,overflow:"hidden",pointerEvents:"none",zIndex:uc.dimensionOverlay},children:W.jsxs("svg",{style:{position:"absolute",left:0,top:0,pointerEvents:"none"},width:e,height:i,children:[t.map(s=>{const r=s.anchor,a=s.anchor_id,g=s.target,c=o.get(a),I=Pi(A,g),l=g.x-r.x,B=g.y-r.y,C=Math.abs(I.x-c.x),Q=Math.abs(I.y-c.y),h=I.y<c.y,E=I.x>c.x,u=h?Zc.LABEL_OFFSET_ABOVE:Zc.LABEL_OFFSET_BELOW,d=E?Zc.LABEL_OFFSET_RIGHT:Zc.LABEL_OFFSET_LEFT,p=C>Zc.MIN_LINE_LENGTH_FOR_LABEL,m=Q>Zc.MIN_LINE_LENGTH_FOR_LABEL,D=`${s.display_offset_x??l.toFixed(2)}mm`,w=`${s.display_offset_y??B.toFixed(2)}mm`;return W.jsxs("g",{children:[W.jsx("line",{x1:c.x,y1:c.y,x2:I.x,y2:c.y,stroke:v0.OFFSET_LINE,strokeWidth:Zc.LINE_STROKE_WIDTH,strokeDasharray:Zc.LINE_DASH_PATTERN}),W.jsx("line",{x1:I.x,y1:c.y,x2:I.x,y2:I.y,stroke:v0.OFFSET_LINE,strokeWidth:Zc.LINE_STROKE_WIDTH,strokeDasharray:Zc.LINE_DASH_PATTERN}),s.type==="component"||s.type==="board"?W.jsx("circle",{cx:I.x,cy:I.y,r:Zc.COMPONENT_MARKER_RADIUS,fill:v0.COMPONENT_MARKER_FILL,stroke:v0.COMPONENT_MARKER_STROKE,strokeWidth:1}):W.jsxs(W.Fragment,{children:[W.jsx("line",{x1:I.x-Zc.ANCHOR_MARKER_SIZE,y1:I.y,x2:I.x+Zc.ANCHOR_MARKER_SIZE,y2:I.y,stroke:v0.OFFSET_LINE,strokeWidth:Zc.ANCHOR_MARKER_STROKE_WIDTH}),W.jsx("line",{x1:I.x,y1:I.y-Zc.ANCHOR_MARKER_SIZE,x2:I.x,y2:I.y+Zc.ANCHOR_MARKER_SIZE,stroke:v0.OFFSET_LINE,strokeWidth:Zc.ANCHOR_MARKER_STROKE_WIDTH})]}),p&&W.jsx("foreignObject",{x:Math.min(c.x,I.x),y:c.y+u,width:Math.abs(I.x-c.x),height:20,style:{overflow:"visible"},children:W.jsx("div",{style:{...n,textAlign:"center"},children:D})}),m&&W.jsx("foreignObject",{x:I.x+d,y:Math.min(c.y,I.y),width:Zc.Y_LABEL_MIN_WIDTH,height:Math.abs(I.y-c.y),style:{overflow:"visible"},children:W.jsx("div",{style:{...n,display:"flex",alignItems:"center",justifyContent:E?"flex-start":"flex-end",whiteSpace:"nowrap",padding:"0 4px",height:"100%"},children:w})})]},s.id)}),Array.from(o.entries()).map(([s,r])=>W.jsxs("g",{children:[W.jsx("line",{x1:r.x-Zc.ANCHOR_MARKER_SIZE,y1:r.y,x2:r.x+Zc.ANCHOR_MARKER_SIZE,y2:r.y,stroke:v0.OFFSET_LINE,strokeWidth:Zc.ANCHOR_MARKER_STROKE_WIDTH}),W.jsx("line",{x1:r.x,y1:r.y-Zc.ANCHOR_MARKER_SIZE,x2:r.x,y2:r.y+Zc.ANCHOR_MARKER_SIZE,stroke:v0.OFFSET_LINE,strokeWidth:Zc.ANCHOR_MARKER_STROKE_WIDTH})]},`anchor-${s}`))]})})},ZWt=({elements:t,highlightedPrimitives:A,transform:e,containerWidth:i,containerHeight:n})=>{const o=t.filter(E=>GfA(E)),s=t.filter(E=>W_(E)),r=t.filter(E=>Gce(E)),a=A.map(E=>W_(E._parent_pcb_component)?E._parent_pcb_component.pcb_component_id:W_(E._element)?E._element.pcb_component_id:null).filter(E=>!!E),g=new Set;if(a.forEach(E=>{const u=s.find(d=>d.pcb_component_id===E);u?.pcb_group_id&&g.add(u.pcb_group_id)}),!jB(E=>E.is_showing_group_anchor_offsets)&&a.length===0)return null;const I=s.map(E=>{const u=E.positioned_relative_to_pcb_board_id;if(!u)return null;const d=o.find(p=>p.pcb_board_id===u);return d?{component:E,board:d,type:"component"}:null}).filter(E=>!!E),l=r.map(E=>{const u=E.positioned_relative_to_pcb_board_id;if(!u||!E.center)return null;const d=o.find(p=>p.pcb_board_id===u);return d?{group:E,board:d,type:"group"}:null}).filter(E=>!!E),B=[...I,...l];if(B.length===0)return null;const C=a.length===0,Q=B.filter(E=>E.type==="component"?C||a.includes(E.component.pcb_component_id):C||g.has(E.group.pcb_group_id));if(Q.length===0)return null;const h=Q.map(E=>E.type==="component"?{id:`${E.board.pcb_board_id}-${E.component.pcb_component_id}-${E.type}`,anchor:E.board.center,anchor_id:E.board.pcb_board_id,target:E.component.center,type:"component",display_offset_x:E.component.display_offset_x,display_offset_y:E.component.display_offset_y}:{id:`${E.board.pcb_board_id}-${E.group.pcb_group_id}-${E.type}`,anchor:E.board.center,anchor_id:E.board.pcb_board_id,target:{x:E.group.anchor_position?.x??E.group.center.x,y:E.group.anchor_position?.y??E.group.center.y},type:"group",display_offset_x:E.group.display_offset_x,display_offset_y:E.group.display_offset_y}).filter(E=>!!E);return W.jsx(RfA,{targets:h,transform:e,containerWidth:i,containerHeight:n})},VWt=({elements:t,highlightedPrimitives:A,transform:e,containerWidth:i,containerHeight:n})=>{const o=t.filter(E=>Gce(E)),s=t.filter(E=>W_(E)),r=A.map(E=>W_(E._parent_pcb_component)?E._parent_pcb_component.pcb_component_id:W_(E._element)?E._element.pcb_component_id:null).filter(E=>!!E),a=(E,u)=>{if(u.has(E))return;u.add(E);const d=o.find(p=>p.pcb_group_id===E);d?.position_mode==="relative_to_group_anchor"&&d.positioned_relative_to_pcb_group_id&&a(d.positioned_relative_to_pcb_group_id,u)},g=new Set;if(r.forEach(E=>{const u=s.find(d=>d.pcb_component_id===E);u&&(u.position_mode==="relative_to_group_anchor"&&u.positioned_relative_to_pcb_group_id&&a(u.positioned_relative_to_pcb_group_id,g),u.pcb_group_id&&a(u.pcb_group_id,g))}),!jB(E=>E.is_showing_group_anchor_offsets)&&r.length===0)return null;const I=s.map(E=>{if(E.position_mode==="relative_to_group_anchor"&&E.positioned_relative_to_pcb_group_id){const u=o.find(d=>d.pcb_group_id===E.positioned_relative_to_pcb_group_id);return u&&u.anchor_position?{component:E,parentGroup:u,type:"component"}:null}if(E.pcb_group_id){const u=o.find(d=>d.pcb_group_id===E.pcb_group_id);return u&&u.anchor_position?{component:E,parentGroup:u,type:"component"}:null}return null}).filter(E=>!!E),l=o.map(E=>{if(E.position_mode==="relative_to_group_anchor"&&E.positioned_relative_to_pcb_group_id){const u=o.find(d=>d.pcb_group_id===E.positioned_relative_to_pcb_group_id);if(u&&u.anchor_position&&E.anchor_position)return{group:E,parentGroup:u,type:"group"}}return null}).filter(E=>!!E),B=[...I,...l];if(B.length===0)return null;const C=r.length===0,Q=B.filter(E=>E.type==="component"?C||r.includes(E.component.pcb_component_id):C||g.has(E.group.pcb_group_id)||g.has(E.parentGroup.pcb_group_id));if(Q.length===0)return null;const h=Q.map(E=>{const u=E.parentGroup.anchor_position;return u?E.type==="component"?E.component.center?{id:`${E.parentGroup.pcb_group_id}-${E.component.pcb_component_id}-${E.type}`,anchor:u,anchor_id:E.parentGroup.pcb_group_id,target:E.component.center,type:"component",display_offset_x:E.component.display_offset_x,display_offset_y:E.component.display_offset_y}:null:E.group.anchor_position?{id:`${E.parentGroup.pcb_group_id}-${E.group.pcb_group_id}-${E.type}`,anchor:u,anchor_id:E.parentGroup.pcb_group_id,target:E.group.anchor_position,type:"group",display_offset_x:E.group.display_offset_x,display_offset_y:E.group.display_offset_y}:null:null}).filter(E=>!!E);return W.jsx(RfA,{targets:h,transform:e,containerWidth:i,containerHeight:n})},jWt=(t,A)=>{const e=t.pcb_component_id,i=A.filter(n=>(n.type==="pcb_smtpad"||n.type==="pcb_plated_hole")&&n.pcb_component_id===e||n.type==="pcb_hole"&&n.pcb_component_id===e);return i.length===0?xfA([t]):xfA(i)},zWt=({elements:t,highlightedPrimitives:A,transform:e,containerWidth:i,containerHeight:n})=>{const o=new Map;for(const r of A)W_(r._parent_pcb_component)&&o.set(r._parent_pcb_component.pcb_component_id,r._parent_pcb_component),W_(r._element)&&o.set(r._element.pcb_component_id,r._element);if(o.size===0)return null;const s=[];for(const r of o.values()){const a=jWt(r,t);if(!a)continue;const g=r.positioned_relative_to_pcb_group_id??r.pcb_group_id,c=g?mb(t).pcb_group.get(g):null;s.push({component:r,bbox:a,group:c})}return s.length===0?null:W.jsx("div",{style:{position:"absolute",left:0,top:0,width:i,height:n,overflow:"hidden",pointerEvents:"none",zIndex:uc.dimensionOverlay},children:W.jsx("svg",{style:{position:"absolute",left:0,top:0,pointerEvents:"none"},width:i,height:n,children:s.map(({component:r,bbox:a,group:g})=>{const c=Pi(e,{x:a.minX,y:a.maxY}),I=Pi(e,{x:a.maxX,y:a.minY}),l={x:Math.min(c.x,I.x),y:Math.min(c.y,I.y),width:Math.abs(I.x-c.x),height:Math.abs(I.y-c.y)},B=r.center??{x:(a.minX+a.maxX)/2,y:(a.minY+a.maxY)/2},C=Pi(e,B);return W.jsxs("g",{children:[W.jsx("rect",{x:l.x,y:l.y,width:l.width,height:l.height,fill:"none",stroke:"white",strokeWidth:1.5,strokeDasharray:"4,4"}),W.jsx("line",{x1:C.x-6,y1:C.y,x2:C.x+6,y2:C.y,stroke:v0.COMPONENT_MARKER_STROKE,strokeWidth:1.5}),W.jsx("line",{x1:C.x,y1:C.y-6,x2:C.x,y2:C.y+6,stroke:v0.COMPONENT_MARKER_STROKE,strokeWidth:1.5}),W.jsx("circle",{cx:C.x,cy:C.y,r:Zc.COMPONENT_MARKER_RADIUS,fill:v0.COMPONENT_MARKER_FILL,stroke:v0.COMPONENT_MARKER_STROKE,strokeWidth:1})]},r.pcb_component_id)})})})},XWt=({elements:t,highlightedPrimitives:A,transform:e,containerWidth:i,containerHeight:n})=>{const o=t.filter(B=>WWt(B)),s=t.filter(B=>GfA(B)),r=A.map(B=>GfA(B._element)?B._element.pcb_board_id:null).filter(B=>!!B);if(!jB(B=>B.is_showing_group_anchor_offsets)&&r.length===0)return null;const g=s.map(B=>{const C=B.pcb_panel_id,Q=B.position_mode;if(!C||Q!=="relative_to_panel_anchor")return null;const h=o.find(E=>E.pcb_panel_id===C);return h?{board:B,panel:h,type:"board"}:null}).filter(B=>!!B);if(g.length===0)return null;const c=r.length===0,I=g.filter(B=>c||r.includes(B.board.pcb_board_id));if(I.length===0)return null;const l=I.map(B=>B.board.center?{id:`${B.panel.pcb_panel_id}-${B.board.pcb_board_id}-${B.type}`,anchor:B.panel.center,anchor_id:B.panel.pcb_panel_id,target:B.board.center,type:"board",display_offset_x:B.board.display_offset_x,display_offset_y:B.board.display_offset_y}:null).filter(B=>!!B);return W.jsx(RfA,{targets:l,transform:e,containerWidth:i,containerHeight:n})},Y9=t=>{if(t.length===0)return null;let A=t[0].x,e=t[0].y,i=t[0].x,n=t[0].y;for(const o of t)o.x<A&&(A=o.x),o.y<e&&(e=o.y),o.x>i&&(i=o.x),o.y>n&&(n=o.y);return{center:{x:(A+i)/2,y:(e+n)/2},width:i-A,height:n-e}},Rce=(t,A)=>{if(A.length<3)return!1;let e=!1;for(let i=0,n=A.length-1;i<A.length;n=i++){const o=A[i].x,s=A[i].y,r=A[n].x,a=A[n].y;s>t.y!=a>t.y&&t.x<(r-o)*(t.y-s)/(a-s||Number.EPSILON)+o&&(e=!e)}return e},$Wt=(t,A,e)=>{const i=[];for(const n of t){if(!n._element)continue;if("x1"in n&&n._element?.type==="pcb_trace"){const r=EE({x:A.x,y:A.y},{x:n.x1,y:n.y1},{x:n.x2,y:n.y2}),a=n.width||.5,g=Math.max(a*25,2)/e.a;r<g&&i.push(n);continue}if(n.pcb_drawing_type==="polygon"){const r=n.points.map(g=>({x:ut.parse(g.x),y:ut.parse(g.y)})),a=Y9(r);if(!a||A.x<a.center.x-a.width/2||A.x>a.center.x+a.width/2||A.y<a.center.y-a.height/2||A.y>a.center.y+a.height/2)continue;Rce(A,r)&&i.push(n);continue}if(n.pcb_drawing_type==="polygon_with_arcs"){const r=n.brep_shape.outer_ring.vertices.map(g=>({x:ut.parse(g.x),y:ut.parse(g.y)})),a=Y9(r);if(!a||A.x<a.center.x-a.width/2||A.x>a.center.x+a.width/2||A.y<a.center.y-a.height/2||A.y>a.center.y+a.height/2)continue;Rce(A,r)&&i.push(n);continue}if(!("x"in n&&"y"in n))continue;let o=0,s=0;if("w"in n&&"h"in n)o=n.w,s=n.h;else if("r"in n)o=n.r*2,s=n.r*2;else if("rX"in n&&"rY"in n)o=n.rX*2,s=n.rY*2;else continue;Math.abs(n.x-A.x)<o/2&&Math.abs(n.y-A.y)<s/2&&i.push(n)}return i},AZt=({elements:t,children:A,transform:e,primitives:i,onMouseHoverOverPrimitives:n})=>{const[o,s]=V.useState([]),[r,a]=V.useState({x:0,y:0}),[g,{width:c,height:I}]=EJ(),l=V.useMemo(()=>{const C=[];for(const Q of o){if(Q._element?.type==="pcb_via"||Q._element?.type==="pcb_component"||Q?.layer==="drill")continue;let h=null,E=0,u=0;if(Q.pcb_drawing_type==="polygon"){const D=Y9(Q.points);if(!D)continue;h=D.center,E=D.width,u=D.height}else if(Q.pcb_drawing_type==="polygon_with_arcs"){const D=Q.brep_shape.outer_ring.vertices.map(b=>({x:b.x,y:b.y})),w=Y9(D);if(!w)continue;h=w.center,E=w.width,u=w.height}else"x"in Q&&"y"in Q&&(h={x:Q.x,y:Q.y},E="w"in Q?Q.w:"r"in Q?Q.r*2:"rX"in Q&&"rY"in Q?Q.rX*2:0,u="h"in Q?Q.h:"r"in Q?Q.r*2:"rX"in Q&&"rY"in Q?Q.rY*2:0);if(!h)continue;const d=Pi(e,h),p={w:E*e.a,h:u*e.a},m=C.filter(D=>d.x===D.screen_x&&d.y===D.screen_y&&p.w===D.screen_w&&p.h===D.screen_h).length;C.push({...Q,x:h.x,y:h.y,w:E,h:u,screen_x:d.x,screen_y:d.y,screen_w:p.w,screen_h:p.h,same_space_index:m})}return C},[o,e]),B=(C,Q,h,E)=>{a({x:C,y:Q});const u=Pi(fb(h),{x:C,y:Q}),d=$Wt(E,u,h);HWt(new Set(d.map(p=>p._pcb_drawing_object_id)),new Set(o.map(p=>p._pcb_drawing_object_id)))||(s(d),n(d))};return W.jsxs("div",{ref:g,style:{position:"relative",width:"100%",height:"100%"},onMouseMove:C=>{if(e){const Q=C.currentTarget.getBoundingClientRect(),h=C.clientX-Q.left,E=C.clientY-Q.top;B(h,E,e,i)}},onTouchStart:C=>{if(e){const Q=C.touches[0],h=C.currentTarget.getBoundingClientRect(),E=Q.clientX-h.left,u=Q.clientY-h.top;B(E,u,e,i)}},children:[A,W.jsx(OWt,{elements:t,mousePos:r,highlightedPrimitives:l}),e&&W.jsxs(W.Fragment,{children:[W.jsx(ZWt,{elements:t,highlightedPrimitives:l,transform:e,containerWidth:c,containerHeight:I}),W.jsx(VWt,{elements:t,highlightedPrimitives:l,transform:e,containerWidth:c,containerHeight:I}),W.jsx(zWt,{elements:t,highlightedPrimitives:l,transform:e,containerWidth:c,containerHeight:I}),W.jsx(XWt,{elements:t,highlightedPrimitives:l,transform:e,containerWidth:c,containerHeight:I})]})]})},Mce=["rgb(255, 100, 100)","rgb(100, 255, 100)","rgb(100, 100, 255)","rgb(255, 255, 100)","rgb(255, 100, 255)","rgb(100, 255, 255)","rgb(255, 150, 100)","rgb(150, 100, 255)","rgb(100, 255, 150)","rgb(255, 100, 150)"],eZt=({children:t,transform:A=pb(),elements:e=[],hoveredComponentIds:i=[]})=>{const[n,{width:o,height:s}]=EJ(),r=V.useRef(null),{is_showing_pcb_groups:a,pcb_group_view_mode:g,is_showing_group_anchor_offsets:c}=jB(I=>({is_showing_pcb_groups:I.is_showing_pcb_groups,pcb_group_view_mode:I.pcb_group_view_mode,is_showing_group_anchor_offsets:I.is_showing_group_anchor_offsets}));return V.useEffect(()=>{const I=r.current;if(!I||!o||!s)return;I.width=o,I.height=s;const l=I.getContext("2d");if(!l||(l.clearRect(0,0,o,s),!a))return;const B=e.filter(D=>D.type==="pcb_group"),C=e.filter(D=>D.type==="pcb_component"),Q=e.filter(D=>D.type==="source_group"),h=new Map(Q.map(D=>[D.source_group_id,D])),E=B.filter(D=>{if(g==="all")return!0;if(!D.source_group_id)return!1;const w=h.get(D.source_group_id);return w?w.was_automatically_named!==!0:!1}),u=new Map;Q.forEach(D=>{const w=D;if(w.parent_source_group_id){const b=u.get(w.parent_source_group_id)||[];b.push(D.source_group_id),u.set(w.parent_source_group_id,b)}});const d=D=>{const w=[],b=u.get(D)||[];for(const k of b)w.push(k),w.push(...d(k));return w},p=D=>{const w=Q.find(b=>b.source_group_id===D);return w?.parent_source_group_id?1+p(w.parent_source_group_id):0},m=new Set;if(i.length>0)for(const D of C){if(!i.includes(D.pcb_component_id))continue;const w=D.positioned_relative_to_pcb_group_id??D.pcb_group_id;w&&m.add(w)}E.forEach((D,w)=>{let b=C.filter(HA=>HA.pcb_group_id===D.pcb_group_id);if(D.source_group_id){const HA=d(D.source_group_id),ZA=B.filter(kA=>kA.source_group_id&&HA.includes(kA.source_group_id));for(const kA of ZA){const wA=C.filter(UA=>UA.pcb_group_id===kA.pcb_group_id);b=[...b,...wA]}}let k,x,N,M,U=!1;if(D.center&&D.width&&D.height){U=!0;const HA=D.width/2,ZA=D.height/2;k=D.center.x-HA,N=D.center.x+HA,x=D.center.y-ZA,M=D.center.y+ZA}else if(b.length===0||(k=1/0,x=1/0,N=-1/0,M=-1/0,b.forEach(HA=>{if(HA.center&&typeof HA.width=="number"&&typeof HA.height=="number"){const ZA=HA.center.x-HA.width/2,kA=HA.center.x+HA.width/2,wA=HA.center.y+HA.height/2,UA=HA.center.y-HA.height/2;k=Math.min(k,ZA),N=Math.max(N,kA),x=Math.min(x,UA),M=Math.max(M,wA)}}),k===1/0||N===-1/0))return;const Y=D.source_group_id?p(D.source_group_id):0,H=D.source_group_id?d(D.source_group_id).length>0:!1;if(!U){const kA=1+(H?.5:0);k-=kA,N+=kA,x-=kA,M+=kA}const O=Pi(A,{x:k,y:M}),Z=Pi(A,{x:N,y:M}),$=Pi(A,{x:k,y:x}),iA=Pi(A,{x:N,y:x}),aA=Mce[w%Mce.length];l.strokeStyle=aA,l.lineWidth=2;const eA=Math.max(4,Math.min(12,8*Math.abs(A.a))),nA=Math.max(2,Math.min(6,4*Math.abs(A.a))),lA=eA*(H?1.3:1),pA=nA;l.setLineDash([lA,pA]),l.beginPath(),l.moveTo(O.x,O.y),l.lineTo(Z.x,Z.y),l.lineTo(iA.x,iA.y),l.lineTo($.x,$.y),l.closePath(),l.stroke();const xA=Math.max(8,Math.min(12,10*Math.abs(A.a))),RA=Y==0||Y==1?0:Y*.11,YA=xA*(1-RA),CA=4,_A=D.name||`Group ${w+1}`;l.font=`${YA}px sans-serif`,l.setLineDash([]);const KA=l.measureText(_A).width+CA*2,TA=YA+CA*2,ie=O.x-5,fA=O.y-5,$A=3;if(l.fillStyle="rgba(0, 0, 0, 0.8)",l.beginPath(),l.roundRect(ie,fA-TA,KA,TA,$A),l.fill(),l.fillStyle=aA,l.textAlign="left",l.textBaseline="middle",l.fillText(_A,ie+CA,fA-TA/2),c&&m.has(D.pcb_group_id)&&!!D.anchor_position&&D.anchor_position){const HA=Array.isArray(D.anchor_position)?{x:D.anchor_position[0]??0,y:D.anchor_position[1]??0}:{x:D.anchor_position.x,y:D.anchor_position.y},ZA=Pi(A,HA);l.strokeStyle="white",l.lineWidth=1.5,l.setLineDash([]);const kA=Math.max(4,Math.min(8,6*Math.abs(A.a)));l.beginPath(),l.moveTo(ZA.x-kA,ZA.y),l.lineTo(ZA.x+kA,ZA.y),l.stroke(),l.beginPath(),l.moveTo(ZA.x,ZA.y-kA),l.lineTo(ZA.x,ZA.y+kA),l.stroke()}})},[e,A,o,s,a,g,c,i]),W.jsxs("div",{ref:n,style:{position:"relative",width:"100%",height:"100%"},children:[t,W.jsx("canvas",{ref:r,style:{position:"absolute",top:0,left:0,pointerEvents:"none",zIndex:uc.pcbGroupOverlay,display:a?"block":"none"}})]})},tZt=({transform:t,soup:A,children:e})=>{const i=jB(r=>r.is_showing_rats_nest),{netMap:n,idToNetMap:o}=V.useMemo(()=>Bce(A||[]),[A]),s=V.useMemo(()=>{if(!A||!i)return[];const r=l=>{const B=mb(A)[l.replace(/_\d+$/,"")].get(l);return B&&"x"in B&&"y"in B?{x:B.x,y:B.y}:null},a=(l,B)=>{const C=n[B]||[];let Q=null,h=1/0;return C.forEach(E=>{const u=r(E);if(u){const d=Math.sqrt((l.x-u.x)**2+(l.y-u.y)**2);d<h&&d>0&&(h=d,Q=u)}}),Q},g=mb(A).pcb_port.list(),c=mb(A).source_trace.list(),I=[];return g.forEach((l,B)=>{const C=o[l.pcb_port_id];let Q=!1;for(const u of c)u.connected_source_port_ids.includes(l.source_port_id)&&u.connected_source_net_ids.length>0&&(Q=!0);if(!C)return;const h={x:l.x,y:l.y},E=a(h,C);E&&I.push({key:`${l.pcb_port_id}-${B}`,startPoint:h,endPoint:E,isInNet:Q})}),I},[A,n,o,i]);return!A||!i?e:(t||(t=pb()),W.jsxs("div",{style:{position:"relative"},children:[e,W.jsx("svg",{style:{position:"absolute",left:0,top:0,width:"100%",height:"100%",pointerEvents:"none",opacity:.5,zIndex:uc.ratsNestOverlay},children:s.map(({key:r,startPoint:a,endPoint:g,isInNet:c})=>{const I=Pi(t,a),l=Pi(t,g);return W.jsx("line",{x1:I.x,y1:I.y,x2:l.x,y2:l.y,stroke:"white",strokeWidth:"1",strokeDasharray:c?"6,6":void 0},r)})})]}))},iZt={version:"1.11.326"},Z_=(t,A,e)=>{const i=jB(s=>s.is_mouse_over_container),n=V.useRef(i),o=V.useRef(A);V.useEffect(()=>{n.current=i},[i]),V.useEffect(()=>{o.current=A},[A]),V.useEffect(()=>{if(!t)return;const s=r=>{const a=r.target;if(a.tagName==="INPUT"||a.tagName==="TEXTAREA"||a.isContentEditable)return;const g=t.split("+"),c=g.includes("ctrl"),I=g.includes("shift"),l=g.includes("alt"),B=g.includes("meta"),C=g[g.length-1],Q=e?.current?e.current.contains(document.activeElement)||document.activeElement===e.current:!1;(n.current||Q)&&(!c||r.ctrlKey)&&(!I||r.shiftKey)&&(!l||r.altKey)&&(!B||r.metaKey)&&r.key.toLowerCase()===C.toLowerCase()&&(r.preventDefault(),o.current())};return window.addEventListener("keydown",s),()=>{window.removeEventListener("keydown",s)}},[t])},nZt=()=>{const[t,A]=V.useState(!1);return V.useEffect(()=>{const e=()=>{A(window.innerWidth<=768)};return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]),t},oZt=({name:t,selected:A,onClick:e})=>W.jsxs("div",{className:A1`
5473
5473
  margin-top: 2px;
5474
5474
  padding: 4px;
5475
5475
  padding-left: 8px;
@@ -5686,7 +5686,7 @@ test("${g} should solve problem correctly", () => {
5686
5686
  // Add more specific assertions based on expected output
5687
5687
  // expect(solver.netLabelPlacementSolver!.netLabelPlacements).toMatchInlineSnapshot()
5688
5688
  })
5689
- `,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 ${t.constructor.name}: ${a instanceof Error?a.message:String(a)}`)}i(!1)};return W.jsxs("div",{className:`relative ${A}`,ref:n,children:[W.jsx("button",{className:"px-2 py-1 rounded text-xs cursor-pointer",onClick:()=>i(!e),title:`Download options for ${t.constructor.name}`,children:t.constructor.name}),e&&W.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:[W.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:o,children:"Download JSON"}),W.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:s,children:"Download page.tsx"}),W.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:r,children:"Download test.ts"})]})]})},Kce=t=>t.activeSubSolver?[t,...Kce(t.activeSubSolver)]:[t],FVt=({solver:t})=>{const A=Kce(t);return W.jsx("div",{className:"flex gap-1 items-center text-sm pt-1",children:A.map((e,i)=>W.jsxs("div",{className:"flex items-center",children:[i>0&&W.jsx("span",{className:"text-gray-400 mx-1",children:"→"}),W.jsx(kVt,{solver:e})]},e.constructor.name))})},GVt=({solver:t,triggerRender:A,animationSpeed:e=25,onSolverStarted:i,onSolverCompleted:n})=>{const[o,s]=V.useReducer(Q=>!Q,!1),r=V.useRef(void 0),a=()=>{!t.solved&&!t.failed&&(t.step(),A())},g=()=>{!t.solved&&!t.failed&&(i&&i(t),t.solve(),A(),n&&n(t))},c=()=>{o?(r.current&&(clearInterval(r.current),r.current=void 0),s()):(s(),r.current=setInterval(()=>{if(t.solved||t.failed){r.current&&(clearInterval(r.current),r.current=void 0),s(),A(),n&&t.solved&&n(t);return}t.step(),A()},e))},I=()=>{const Q=t;if(Q.getCurrentPhase&&!t.solved&&!t.failed){const h=Q.getCurrentPhase();for(;Q.getCurrentPhase()===h&&!t.solved&&!t.failed;)t.step();A()}},l=()=>{if(t.solved||t.failed||o)return;const Q=window.prompt("Step until which iteration?",`${t.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(;t.iterations<h&&!t.solved&&!t.failed;)t.step();A(),t.solved&&n&&n(t)};V.useEffect(()=>()=>{r.current&&clearInterval(r.current)},[]),V.useEffect(()=>{(t.solved||t.failed)&&o&&(r.current&&(clearInterval(r.current),r.current=void 0),s())},[t.solved,t.failed,o]);const B=t.getCurrentPhase!==void 0,C=B?t.getCurrentPhase():null;return W.jsxs("div",{className:"space-y-2 p-2 border-b",children:[W.jsx("div",{className:"flex items-center",children:W.jsx(FVt,{solver:t})}),W.jsxs("div",{className:"flex gap-2 items-center flex-wrap",children:[W.jsx("button",{onClick:a,disabled:t.solved||t.failed||o,className:"bg-blue-500 hover:bg-blue-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Step"}),W.jsx("button",{onClick:g,disabled:t.solved||t.failed||o,className:"bg-green-500 hover:bg-green-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Solve"}),W.jsx("button",{onClick:c,disabled:t.solved||t.failed,className:`px-3 py-1 rounded text-white text-sm ${o?"bg-red-500 hover:bg-red-600":"bg-yellow-500 hover:bg-yellow-600"} disabled:bg-gray-300`,children:o?"Stop":"Animate"}),W.jsx("button",{onClick:l,disabled:t.solved||t.failed||o,className:"bg-orange-500 hover:bg-orange-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Step Until Iteration"}),B&&W.jsx("button",{onClick:I,disabled:t.solved||t.failed||o,className:"bg-purple-500 hover:bg-purple-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Next Stage"}),W.jsxs("div",{className:"text-sm text-gray-600",children:["Iterations: ",t.iterations]}),t.timeToSolve!==void 0&&W.jsxs("div",{className:"text-sm text-gray-600",children:["Time: ",(t.timeToSolve/1e3).toFixed(3),"s"]}),C&&W.jsxs("div",{className:"text-sm text-gray-600",children:["Phase: ",W.jsx("span",{className:"font-medium",children:C})]}),t.solved&&W.jsx("div",{className:"px-2 py-1 bg-green-100 text-green-800 rounded text-sm",children:"Solved"}),t.failed&&W.jsx("div",{className:"px-2 py-1 bg-red-100 text-red-800 rounded text-sm",children:"Failed"})]}),t.error&&W.jsxs("div",{className:"text-red-600 text-sm",children:["Error: ",t.error]})]})},RVt=(t,A,e)=>{const i=t.currentPipelineStepIndex;return A<i?"Completed":A===i&&t.activeSubSolver?t.activeSubSolver.failed?"Failed":"In Progress":"Not Started"},MVt=(t,A)=>{const i=t.pipelineDef[A].solverName,n=RVt(t,A),o=t[i],s=t.firstIterationOfPhase?.[i]??null,r=t.iterations;let a=0;if(n==="Completed"){const l=t.pipelineDef[A+1],B=l?t.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=t.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}},NVt=({status:t})=>{const A={"Not Started":"text-blue-600","In Progress":"text-yellow-600",Completed:"text-green-600",Failed:"text-red-600"};return W.jsx("span",{className:`font-medium ${A[t]}`,children:t})},vVt=({progress:t})=>{if(t===0)return null;const A=Math.round(t*100);return W.jsxs("div",{className:"flex items-center gap-2",children:[W.jsx("div",{className:"w-20 h-2 bg-gray-200 rounded overflow-hidden",children:W.jsx("div",{className:"h-full bg-blue-500 transition-all duration-200",style:{width:`${A}%`}})}),W.jsxs("span",{className:"text-xs text-gray-500",children:[A,"%"]})]})},LVt=t=>Object.entries(t).map(([A,e])=>`${A}: ${e}`).join(", "),UVt=({stats:t})=>{if(!t||Object.keys(t).length===0)return W.jsx("span",{children:"-"});const A=Object.entries(t),e=LVt(t);return W.jsxs("details",{className:"cursor-pointer",children:[W.jsx("summary",{className:"whitespace-nowrap overflow-hidden text-ellipsis max-w-[200px]",children:e}),W.jsx("div",{className:"mt-1 text-xs",children:A.map(([i,n])=>W.jsxs("div",{children:[i,": ",String(n)]},i))})]})},JfA=t=>{if(t===null||typeof t!="object")return t;if(Array.isArray(t))return t.map(JfA);const A={};for(const[e,i]of Object.entries(t))e.startsWith("_")||(A[e]=JfA(i));return A},HVt=(t,A)=>{try{if(typeof t.getConstructorParams!="function"){alert(`getConstructorParams() is not implemented for ${A}`);return}const e=JfA(t.getConstructorParams()),i=new Blob([JSON.stringify(e,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(e){alert(`Error downloading input for ${A}: ${e instanceof Error?e.message:String(e)}`)}},YVt=({solver:t,onStepUntilPhase:A,onDownloadInput:e})=>{const i=t.pipelineDef.map((r,a)=>MVt(t,a)),n=r=>{A?.(r)},o=r=>{r.solverInstance&&(e?e(r.solverInstance,r.name):HVt(r.solverInstance,r.name))},s=r=>`${(r/1e3).toFixed(2)}s`;return W.jsxs("div",{className:"border-t border-gray-200",children:[W.jsx("div",{className:"px-4 py-2 bg-gray-50 border-b border-gray-200",children:W.jsx("h3",{className:"text-sm font-semibold text-gray-700",children:"Pipeline Steps"})}),W.jsx("div",{className:"overflow-x-auto",children:W.jsxs("table",{className:"w-full text-sm",children:[W.jsx("thead",{children:W.jsxs("tr",{className:"bg-gray-50 border-b border-gray-200",children:[W.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Step"}),W.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Status"}),W.jsxs("th",{className:"px-4 py-2 text-center font-semibold text-gray-700",children:["i",W.jsx("sub",{children:"0"})]}),W.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Iterations"}),W.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Progress"}),W.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Time"}),W.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Stats"}),W.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Input"})]})}),W.jsx("tbody",{children:i.map(r=>W.jsxs("tr",{className:`border-b border-gray-100 ${r.status==="In Progress"?"bg-yellow-50":""}`,children:[W.jsx("td",{className:"px-4 py-2",children:W.jsxs("div",{className:"flex items-center gap-2",children:[W.jsx("span",{className:"text-gray-400 w-6",children:String(r.index+1).padStart(2,"0")}),W.jsx("button",{onClick:()=>n(r.name),disabled:r.status==="Completed"||t.solved||t.failed,className:"text-blue-500 hover:text-blue-700 disabled:text-gray-300 disabled:cursor-not-allowed",title:`Step until ${r.name} completes`,children:W.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:W.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"})})}),W.jsx("span",{className:"font-medium text-gray-900",children:r.name})]})}),W.jsx("td",{className:"px-4 py-2",children:W.jsx(NVt,{status:r.status})}),W.jsx("td",{className:"px-4 py-2 text-center text-gray-600",children:r.firstIteration!==null?r.firstIteration:""}),W.jsx("td",{className:"px-4 py-2 text-gray-600",children:r.iterations}),W.jsx("td",{className:"px-4 py-2",children:W.jsx(vVt,{progress:r.progress})}),W.jsx("td",{className:"px-4 py-2 text-gray-600",children:s(r.timeSpent)}),W.jsx("td",{className:"px-4 py-2 text-gray-500",children:W.jsx(UVt,{stats:r.stats})}),W.jsx("td",{className:"px-4 py-2",children:r.solverInstance?W.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:[W.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:W.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"})}),W.jsx("span",{children:"Input"})]}):null})]},r.name))})]})})]})},JVt=class extends tn.Component{constructor(t){super(t),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(t){console.error("InteractiveGraphics render error:",t)}render(){return this.state.hasError?this.props.fallback:this.props.children}};function TVt({graphics:t}){const A=t.points??[],e=t.lines??[],i=t.rects??[],n=t.circles??[],o=t.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 e){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,p=h.height??0;c(E,u),c(E+d,u+p)}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 W.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)=>W.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}`)),e.map((h,E)=>W.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)=>W.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)=>W.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)=>W.jsx("text",{x:h.x??0,y:h.y??0,fontSize:h.fontSize??10,fill:h.color??"black",children:h.text??""},`text-${E}`))]})}var KVt=({solver:t,animationSpeed:A=25,onSolverStarted:e,onSolverCompleted:i})=>{const[n,o]=V.useReducer(c=>c+1,0),s=V.useMemo(()=>{try{return t.visualize()||{points:[],lines:[],rects:[],circles:[]}}catch(c){return console.error("Visualization error:",c),{points:[],lines:[],rects:[],circles:[]}}},[t,n]),r=V.useMemo(()=>(s.rects?.length||0)===0&&(s.lines?.length||0)===0&&(s.points?.length||0)===0&&(s.circles?.length||0)===0,[s]);V.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=t.pipelineDef!==void 0,g=c=>{const I=t;if(!t.solved&&!t.failed){for(;!t.solved&&!t.failed&&I.currentPipelineStepIndex<=I.pipelineDef.findIndex(l=>l.solverName===c);)t.step();o()}};return W.jsxs("div",{children:[W.jsx(GVt,{solver:t,triggerRender:o,animationSpeed:A,onSolverStarted:e,onSolverCompleted:i}),r?W.jsx("div",{className:"p-4 text-gray-500",children:"No Graphics Yet"}):W.jsx(JVt,{fallback:W.jsx(TVt,{graphics:s}),children:W.jsx(_Vt,{graphics:s})}),a&&W.jsx(YVt,{solver:t,onStepUntilPhase:g})]})};const PVt=()=>{V.useEffect(()=>{const t="tailwind-cdn-script";if(document.getElementById(t)||window.tailwind)return;const A=document.createElement("div");A.className="hidden",document.body.appendChild(A);const e=window.getComputedStyle(A).display==="none";if(document.body.removeChild(A),e)return;const i=document.createElement("script");i.id=t,i.src="https://cdn.tailwindcss.com",document.head.appendChild(i)},[])},qVt=t=>t.toLowerCase().includes("pack")?nMt:t.toLowerCase().includes("rout")?gMt:KRt,OVt=({solverEvents:t=[]})=>{const[A,e]=V.useState(null);PVt();const i=V.useMemo(()=>{const r=new Map;for(const a of t){const g=`${a.componentName}-${a.solverName}`;r.set(g,a)}return r},[t]),n=V.useMemo(()=>Array.from(i.keys()),[i]),o=A?i.get(A):null,s=V.useMemo(()=>{if(!o)return{instance:null,error:null,classFound:!1};const r=PnA[o.solverName];if(!r)return{instance:null,error:`Solver class "${o.solverName}" not found in SOLVERS registry. Available: ${Object.keys(PnA).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 t.length===0?W.jsx("div",{className:"rf-p-4",children:W.jsx("div",{className:"rf-bg-gray-50 rf-rounded-md rf-border rf-border-gray-200",children:W.jsxs("div",{className:"rf-p-4",children:[W.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800 rf-mb-3",children:"No Solvers Detected"}),W.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."})]})})}):W.jsxs("div",{className:"rf-flex rf-h-full rf-overflow-hidden",children:[W.jsxs("div",{className:"rf-w-64 rf-border-r rf-border-gray-200 rf-overflow-y-auto rf-flex-shrink-0",children:[W.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 W.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:()=>e(r),children:(()=>{const c=qVt(a.solverName);return W.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2",children:[W.jsx(c,{className:"rf-w-4 rf-h-4 rf-text-blue-500 rf-flex-shrink-0"}),W.jsxs("div",{className:"rf-flex-1 rf-min-w-0",children:[W.jsx("div",{className:"rf-text-sm rf-font-medium rf-text-gray-800 rf-truncate",children:a.componentName}),W.jsx("div",{className:"rf-text-xs rf-text-gray-500 rf-truncate",children:a.solverName})]})]})})()},r)})]}),W.jsx("div",{className:"rf-flex-1 rf-overflow-hidden",children:o?s.instance?W.jsx(Yy,{fallback:W.jsx("div",{className:"rf-p-4",children:W.jsxs("div",{className:"rf-bg-red-50 rf-rounded-md rf-border rf-border-red-200 rf-p-4",children:[W.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-red-800 rf-mb-2",children:"Error Loading Solver Debugger"}),W.jsxs("p",{className:"rf-text-sm rf-text-red-600",children:["Failed to render the solver debugger for"," ",o.solverName]})]})}),children:W.jsx(KVt,{solver:s.instance})}):W.jsxs("div",{className:"rf-p-4",children:[W.jsxs("div",{className:"rf-mb-4",children:[W.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800",children:o.solverName}),W.jsxs("p",{className:"rf-text-sm rf-text-gray-500",children:["Component: ",o.componentName]})]}),s.error&&W.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:W.jsx("p",{className:`rf-text-sm ${s.classFound?"rf-text-red-700":"rf-text-yellow-700"}`,children:s.error})}),W.jsxs("div",{className:"rf-border rf-border-gray-200 rf-rounded-md rf-overflow-hidden",children:[W.jsx("div",{className:"rf-px-3 rf-py-2 rf-bg-gray-50",children:W.jsx("span",{className:"rf-text-sm rf-font-medium rf-text-gray-700",children:"Solver Parameters"})}),W.jsx("div",{className:"rf-p-3 rf-bg-white rf-border-t rf-border-gray-200",children:W.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)})})]})]}):W.jsx("div",{className:"rf-flex rf-items-center rf-justify-center rf-h-full",children:W.jsx("p",{className:"rf-text-sm rf-text-gray-500",children:"Select a solver from the list to view details"})})})]})},Pce=({errorMessage:t,errorStack:A,circuitJsonErrors:e})=>{V.useEffect(()=>{if(t){const i=new Error(t);A&&(i.stack=A);try{v5.captureException(i)}catch{}}},[t,A]),V.useEffect(()=>{if(e&&e.length>0)for(const i of e){const n=new Error(i.message||"Circuit JSON Error");i.stack&&(n.stack=i.stack);try{v5.captureException(n,{error_type:i.type})}catch{}}},[e])},qce="0.0.1555",WVt={version:qce},O9=dYA()(pYA(t=>({lastRunEvalVersion:void 0,setLastRunEvalVersion:A=>{t({lastRunEvalVersion:A})}}),{name:"runframe-runner-store"})),ZVt=t=>{const[A,e]=V.useState([]),[i,n]=V.useState(null),[o,s]=V.useState(""),[r,a]=e1("eval-version-selection",null),g=O9(B=>B.setLastRunEvalVersion),c=O9(B=>B.lastRunEvalVersion);return V.useEffect(()=>{t&&fetch("https://data.jsdelivr.com/v1/package/npm/@tscircuit/eval").then(B=>B.json()).then(B=>{if(Array.isArray(B?.versions)){let C=[...B.versions];B.tags?.latest&&(n(B.tags.latest),C=C.filter(Q=>Q!==B.tags.latest)),e(C)}}).catch(()=>{})},[t]),V.useEffect(()=>{t&&(r?(window.TSCIRCUIT_LATEST_EVAL_VERSION=r,g(r)):i&&(window.TSCIRCUIT_LATEST_EVAL_VERSION=i,g(i)))},[t,r,i]),{versions:V.useMemo(()=>A.filter(B=>B.includes(o)).slice(0,50),[A,o]),latestVersion:i,lastRunEvalVersion:c,search:o,setSearch:s,selectVersion:B=>{a(B),s("")}}},VVt=({snippetNames:t,onSelect:A,onCancel:e,isOpen:i})=>{const[n,o]=V.useState(""),[s,r]=V.useState("");if(!i)return null;const a=t.filter(I=>I.toLowerCase().includes(s.toLowerCase())),g=s&&!t.includes(s),c=I=>{I.key==="Enter"&&(a.length===1?o(a[0]):g&&o(s))};return W.jsx("div",{className:"rf-fixed rf-inset-0 rf-bg-black rf-bg-opacity-50 rf-flex rf-items-center rf-justify-center rf-z-[100]",children:W.jsxs("div",{className:"rf-bg-white rf-rounded-lg rf-p-6 rf-w-96",children:[W.jsx("h2",{className:"rf-text-lg rf-font-semibold rf-mb-4",children:"Select Snippet"}),W.jsx("input",{type:"text",className:"rf-w-full rf-px-4 rf-py-2 rf-border rf-rounded rf-mb-4",placeholder:"Search snippets or new snippet name...",value:s,onChange:I=>r(I.target.value),onKeyDown:c}),W.jsxs("div",{className:"rf-h-60 rf-overflow-y-auto",children:[a.map(I=>W.jsx("button",{type:"button",className:`w-full text-left px-4 py-2 rounded hover:bg-gray-100 ${n===I?"bg-blue-50":""}`,onClick:()=>o(I),children:I},I)),g&&W.jsxs("button",{type:"button",className:`w-full text-left px-4 py-2 rounded hover:bg-gray-100 text-blue-500 ${n===s?"bg-blue-50":""}`,onClick:()=>o(s),children:['Create new "',s,'"']})]}),W.jsxs("div",{className:"rf-mt-4 rf-flex rf-justify-end rf-gap-2",children:[W.jsx("button",{type:"button",className:"rf-px-4 rf-py-2 rf-text-gray-600 rf-hover:text-gray-800",onClick:e,children:"Cancel"}),W.jsx("button",{type:"button",className:"rf-px-4 rf-py-2 rf-bg-blue-500 rf-text-white rf-rounded rf-hover:bg-blue-600 rf-disabled:opacity-50",onClick:()=>n&&A(n),disabled:!n,children:n===s?`Create "${n}"`:`Save to ${n}`})]})]})})},jVt=t=>{const A=V.useRef(null),e=qI(i=>i.recentEvents);V.useEffect(()=>{if(e.length===0)return;const i=e[0];i.event_id!==A.current&&(t(i),A.current=i.event_id)},[e,t])};function zVt(t){const A=XVt(t),e=V.forwardRef((i,n)=>{const{children:o,...s}=i,r=V.Children.toArray(o),a=r.find(A9t);if(a){const g=a.props.children,c=r.map(I=>I===a?V.Children.count(g)>1?V.Children.only(null):V.isValidElement(g)?g.props.children:null:I);return W.jsx(A,{...s,ref:n,children:V.isValidElement(g)?V.cloneElement(g,void 0,c):null})}return W.jsx(A,{...s,ref:n,children:o})});return e.displayName=`${t}.Slot`,e}function XVt(t){const A=V.forwardRef((e,i)=>{const{children:n,...o}=e;if(V.isValidElement(n)){const s=t9t(n),r=e9t(o,n.props);return n.type!==V.Fragment&&(r.ref=i?of(i,s):s),V.cloneElement(n,r)}return V.Children.count(n)>1?V.Children.only(null):null});return A.displayName=`${t}.SlotClone`,A}var $Vt=Symbol("radix.slottable");function A9t(t){return V.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===$Vt}function e9t(t,A){const e={...A};for(const i in A){const n=t[i],o=A[i];/^on[A-Z]/.test(i)?n&&o?e[i]=(...r)=>{const a=o(...r);return n(...r),a}:n&&(e[i]=n):i==="style"?e[i]={...n,...o}:i==="className"&&(e[i]=[n,o].filter(Boolean).join(" "))}return{...t,...e}}function t9t(t){let A=Object.getOwnPropertyDescriptor(t.props,"ref")?.get,e=A&&"isReactWarning"in A&&A.isReactWarning;return e?t.ref:(A=Object.getOwnPropertyDescriptor(t,"ref")?.get,e=A&&"isReactWarning"in A&&A.isReactWarning,e?t.props.ref:t.props.ref||t.ref)}var W9="Dialog",[Oce,Wce]=Lm(W9),[i9t,cw]=Oce(W9),Zce=t=>{const{__scopeDialog:A,children:e,open:i,defaultOpen:n,onOpenChange:o,modal:s=!0}=t,r=V.useRef(null),a=V.useRef(null),[g,c]=Lx({prop:i,defaultProp:n??!1,onChange:o,caller:W9});return W.jsx(i9t,{scope:A,triggerRef:r,contentRef:a,contentId:yE(),titleId:yE(),descriptionId:yE(),open:g,onOpenChange:c,onOpenToggle:V.useCallback(()=>c(I=>!I),[c]),modal:s,children:e})};Zce.displayName=W9;var Vce="DialogTrigger",jce=V.forwardRef((t,A)=>{const{__scopeDialog:e,...i}=t,n=cw(Vce,e),o=EI(A,n.triggerRef);return W.jsx(qa.button,{type:"button","aria-haspopup":"dialog","aria-expanded":n.open,"aria-controls":n.contentId,"data-state":PfA(n.open),...i,ref:o,onClick:Un(t.onClick,n.onOpenToggle)})});jce.displayName=Vce;var TfA="DialogPortal",[n9t,zce]=Oce(TfA,{forceMount:void 0}),Xce=t=>{const{__scopeDialog:A,forceMount:e,children:i,container:n}=t,o=cw(TfA,A);return W.jsx(n9t,{scope:A,forceMount:e,children:V.Children.map(i,s=>W.jsx(E0,{present:e||o.open,children:W.jsx(KZ,{asChild:!0,container:n,children:s})}))})};Xce.displayName=TfA;var Z9="DialogOverlay",$ce=V.forwardRef((t,A)=>{const e=zce(Z9,t.__scopeDialog),{forceMount:i=e.forceMount,...n}=t,o=cw(Z9,t.__scopeDialog);return o.modal?W.jsx(E0,{present:i||o.open,children:W.jsx(s9t,{...n,ref:A})}):null});$ce.displayName=Z9;var o9t=zVt("DialogOverlay.RemoveScroll"),s9t=V.forwardRef((t,A)=>{const{__scopeDialog:e,...i}=t,n=cw(Z9,e);return W.jsx(zZ,{as:o9t,allowPinchZoom:!0,shards:[n.contentRef],children:W.jsx(qa.div,{"data-state":PfA(n.open),...i,ref:A,style:{pointerEvents:"auto",...i.style}})})}),GG="DialogContent",AIe=V.forwardRef((t,A)=>{const e=zce(GG,t.__scopeDialog),{forceMount:i=e.forceMount,...n}=t,o=cw(GG,t.__scopeDialog);return W.jsx(E0,{present:i||o.open,children:o.modal?W.jsx(r9t,{...n,ref:A}):W.jsx(a9t,{...n,ref:A})})});AIe.displayName=GG;var r9t=V.forwardRef((t,A)=>{const e=cw(GG,t.__scopeDialog),i=V.useRef(null),n=EI(A,e.contentRef,i);return V.useEffect(()=>{const o=i.current;if(o)return TuA(o)},[]),W.jsx(eIe,{...t,ref:n,trapFocus:e.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Un(t.onCloseAutoFocus,o=>{o.preventDefault(),e.triggerRef.current?.focus()}),onPointerDownOutside:Un(t.onPointerDownOutside,o=>{const s=o.detail.originalEvent,r=s.button===0&&s.ctrlKey===!0;(s.button===2||r)&&o.preventDefault()}),onFocusOutside:Un(t.onFocusOutside,o=>o.preventDefault())})}),a9t=V.forwardRef((t,A)=>{const e=cw(GG,t.__scopeDialog),i=V.useRef(!1),n=V.useRef(!1);return W.jsx(eIe,{...t,ref:A,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:o=>{t.onCloseAutoFocus?.(o),o.defaultPrevented||(i.current||e.triggerRef.current?.focus(),o.preventDefault()),i.current=!1,n.current=!1},onInteractOutside:o=>{t.onInteractOutside?.(o),o.defaultPrevented||(i.current=!0,o.detail.originalEvent.type==="pointerdown"&&(n.current=!0));const s=o.target;e.triggerRef.current?.contains(s)&&o.preventDefault(),o.detail.originalEvent.type==="focusin"&&n.current&&o.preventDefault()}})}),eIe=V.forwardRef((t,A)=>{const{__scopeDialog:e,trapFocus:i,onOpenAutoFocus:n,onCloseAutoFocus:o,...s}=t,r=cw(GG,e),a=V.useRef(null),g=EI(A,a);return muA(),W.jsxs(W.Fragment,{children:[W.jsx(kZ,{asChild:!0,loop:!0,trapped:i,onMountAutoFocus:n,onUnmountAutoFocus:o,children:W.jsx(XH,{role:"dialog",id:r.contentId,"aria-describedby":r.descriptionId,"aria-labelledby":r.titleId,"data-state":PfA(r.open),...s,ref:g,onDismiss:()=>r.onOpenChange(!1)})}),W.jsxs(W.Fragment,{children:[W.jsx(c9t,{titleId:r.titleId}),W.jsx(l9t,{contentRef:a,descriptionId:r.descriptionId})]})]})}),KfA="DialogTitle",tIe=V.forwardRef((t,A)=>{const{__scopeDialog:e,...i}=t,n=cw(KfA,e);return W.jsx(qa.h2,{id:n.titleId,...i,ref:A})});tIe.displayName=KfA;var iIe="DialogDescription",nIe=V.forwardRef((t,A)=>{const{__scopeDialog:e,...i}=t,n=cw(iIe,e);return W.jsx(qa.p,{id:n.descriptionId,...i,ref:A})});nIe.displayName=iIe;var oIe="DialogClose",sIe=V.forwardRef((t,A)=>{const{__scopeDialog:e,...i}=t,n=cw(oIe,e);return W.jsx(qa.button,{type:"button",...i,ref:A,onClick:Un(t.onClick,()=>n.onOpenChange(!1))})});sIe.displayName=oIe;function PfA(t){return t?"open":"closed"}var rIe="DialogTitleWarning",[g9t,aIe]=vXe(rIe,{contentName:GG,titleName:KfA,docsSlug:"dialog"}),c9t=({titleId:t})=>{const A=aIe(rIe),e=`\`${A.contentName}\` requires a \`${A.titleName}\` for the component to be accessible for screen reader users.
5689
+ `,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 ${t.constructor.name}: ${a instanceof Error?a.message:String(a)}`)}i(!1)};return W.jsxs("div",{className:`relative ${A}`,ref:n,children:[W.jsx("button",{className:"px-2 py-1 rounded text-xs cursor-pointer",onClick:()=>i(!e),title:`Download options for ${t.constructor.name}`,children:t.constructor.name}),e&&W.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:[W.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:o,children:"Download JSON"}),W.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:s,children:"Download page.tsx"}),W.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:r,children:"Download test.ts"})]})]})},Kce=t=>t.activeSubSolver?[t,...Kce(t.activeSubSolver)]:[t],FVt=({solver:t})=>{const A=Kce(t);return W.jsx("div",{className:"flex gap-1 items-center text-sm pt-1",children:A.map((e,i)=>W.jsxs("div",{className:"flex items-center",children:[i>0&&W.jsx("span",{className:"text-gray-400 mx-1",children:"→"}),W.jsx(kVt,{solver:e})]},e.constructor.name))})},GVt=({solver:t,triggerRender:A,animationSpeed:e=25,onSolverStarted:i,onSolverCompleted:n})=>{const[o,s]=V.useReducer(Q=>!Q,!1),r=V.useRef(void 0),a=()=>{!t.solved&&!t.failed&&(t.step(),A())},g=()=>{!t.solved&&!t.failed&&(i&&i(t),t.solve(),A(),n&&n(t))},c=()=>{o?(r.current&&(clearInterval(r.current),r.current=void 0),s()):(s(),r.current=setInterval(()=>{if(t.solved||t.failed){r.current&&(clearInterval(r.current),r.current=void 0),s(),A(),n&&t.solved&&n(t);return}t.step(),A()},e))},I=()=>{const Q=t;if(Q.getCurrentPhase&&!t.solved&&!t.failed){const h=Q.getCurrentPhase();for(;Q.getCurrentPhase()===h&&!t.solved&&!t.failed;)t.step();A()}},l=()=>{if(t.solved||t.failed||o)return;const Q=window.prompt("Step until which iteration?",`${t.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(;t.iterations<h&&!t.solved&&!t.failed;)t.step();A(),t.solved&&n&&n(t)};V.useEffect(()=>()=>{r.current&&clearInterval(r.current)},[]),V.useEffect(()=>{(t.solved||t.failed)&&o&&(r.current&&(clearInterval(r.current),r.current=void 0),s())},[t.solved,t.failed,o]);const B=t.getCurrentPhase!==void 0,C=B?t.getCurrentPhase():null;return W.jsxs("div",{className:"space-y-2 p-2 border-b",children:[W.jsx("div",{className:"flex items-center",children:W.jsx(FVt,{solver:t})}),W.jsxs("div",{className:"flex gap-2 items-center flex-wrap",children:[W.jsx("button",{onClick:a,disabled:t.solved||t.failed||o,className:"bg-blue-500 hover:bg-blue-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Step"}),W.jsx("button",{onClick:g,disabled:t.solved||t.failed||o,className:"bg-green-500 hover:bg-green-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Solve"}),W.jsx("button",{onClick:c,disabled:t.solved||t.failed,className:`px-3 py-1 rounded text-white text-sm ${o?"bg-red-500 hover:bg-red-600":"bg-yellow-500 hover:bg-yellow-600"} disabled:bg-gray-300`,children:o?"Stop":"Animate"}),W.jsx("button",{onClick:l,disabled:t.solved||t.failed||o,className:"bg-orange-500 hover:bg-orange-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Step Until Iteration"}),B&&W.jsx("button",{onClick:I,disabled:t.solved||t.failed||o,className:"bg-purple-500 hover:bg-purple-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Next Stage"}),W.jsxs("div",{className:"text-sm text-gray-600",children:["Iterations: ",t.iterations]}),t.timeToSolve!==void 0&&W.jsxs("div",{className:"text-sm text-gray-600",children:["Time: ",(t.timeToSolve/1e3).toFixed(3),"s"]}),C&&W.jsxs("div",{className:"text-sm text-gray-600",children:["Phase: ",W.jsx("span",{className:"font-medium",children:C})]}),t.solved&&W.jsx("div",{className:"px-2 py-1 bg-green-100 text-green-800 rounded text-sm",children:"Solved"}),t.failed&&W.jsx("div",{className:"px-2 py-1 bg-red-100 text-red-800 rounded text-sm",children:"Failed"})]}),t.error&&W.jsxs("div",{className:"text-red-600 text-sm",children:["Error: ",t.error]})]})},RVt=(t,A,e)=>{const i=t.currentPipelineStepIndex;return A<i?"Completed":A===i&&t.activeSubSolver?t.activeSubSolver.failed?"Failed":"In Progress":"Not Started"},MVt=(t,A)=>{const i=t.pipelineDef[A].solverName,n=RVt(t,A),o=t[i],s=t.firstIterationOfPhase?.[i]??null,r=t.iterations;let a=0;if(n==="Completed"){const l=t.pipelineDef[A+1],B=l?t.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=t.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}},NVt=({status:t})=>{const A={"Not Started":"text-blue-600","In Progress":"text-yellow-600",Completed:"text-green-600",Failed:"text-red-600"};return W.jsx("span",{className:`font-medium ${A[t]}`,children:t})},vVt=({progress:t})=>{if(t===0)return null;const A=Math.round(t*100);return W.jsxs("div",{className:"flex items-center gap-2",children:[W.jsx("div",{className:"w-20 h-2 bg-gray-200 rounded overflow-hidden",children:W.jsx("div",{className:"h-full bg-blue-500 transition-all duration-200",style:{width:`${A}%`}})}),W.jsxs("span",{className:"text-xs text-gray-500",children:[A,"%"]})]})},LVt=t=>Object.entries(t).map(([A,e])=>`${A}: ${e}`).join(", "),UVt=({stats:t})=>{if(!t||Object.keys(t).length===0)return W.jsx("span",{children:"-"});const A=Object.entries(t),e=LVt(t);return W.jsxs("details",{className:"cursor-pointer",children:[W.jsx("summary",{className:"whitespace-nowrap overflow-hidden text-ellipsis max-w-[200px]",children:e}),W.jsx("div",{className:"mt-1 text-xs",children:A.map(([i,n])=>W.jsxs("div",{children:[i,": ",String(n)]},i))})]})},JfA=t=>{if(t===null||typeof t!="object")return t;if(Array.isArray(t))return t.map(JfA);const A={};for(const[e,i]of Object.entries(t))e.startsWith("_")||(A[e]=JfA(i));return A},HVt=(t,A)=>{try{if(typeof t.getConstructorParams!="function"){alert(`getConstructorParams() is not implemented for ${A}`);return}const e=JfA(t.getConstructorParams()),i=new Blob([JSON.stringify(e,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(e){alert(`Error downloading input for ${A}: ${e instanceof Error?e.message:String(e)}`)}},YVt=({solver:t,onStepUntilPhase:A,onDownloadInput:e})=>{const i=t.pipelineDef.map((r,a)=>MVt(t,a)),n=r=>{A?.(r)},o=r=>{r.solverInstance&&(e?e(r.solverInstance,r.name):HVt(r.solverInstance,r.name))},s=r=>`${(r/1e3).toFixed(2)}s`;return W.jsxs("div",{className:"border-t border-gray-200",children:[W.jsx("div",{className:"px-4 py-2 bg-gray-50 border-b border-gray-200",children:W.jsx("h3",{className:"text-sm font-semibold text-gray-700",children:"Pipeline Steps"})}),W.jsx("div",{className:"overflow-x-auto",children:W.jsxs("table",{className:"w-full text-sm",children:[W.jsx("thead",{children:W.jsxs("tr",{className:"bg-gray-50 border-b border-gray-200",children:[W.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Step"}),W.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Status"}),W.jsxs("th",{className:"px-4 py-2 text-center font-semibold text-gray-700",children:["i",W.jsx("sub",{children:"0"})]}),W.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Iterations"}),W.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Progress"}),W.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Time"}),W.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Stats"}),W.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Input"})]})}),W.jsx("tbody",{children:i.map(r=>W.jsxs("tr",{className:`border-b border-gray-100 ${r.status==="In Progress"?"bg-yellow-50":""}`,children:[W.jsx("td",{className:"px-4 py-2",children:W.jsxs("div",{className:"flex items-center gap-2",children:[W.jsx("span",{className:"text-gray-400 w-6",children:String(r.index+1).padStart(2,"0")}),W.jsx("button",{onClick:()=>n(r.name),disabled:r.status==="Completed"||t.solved||t.failed,className:"text-blue-500 hover:text-blue-700 disabled:text-gray-300 disabled:cursor-not-allowed",title:`Step until ${r.name} completes`,children:W.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:W.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"})})}),W.jsx("span",{className:"font-medium text-gray-900",children:r.name})]})}),W.jsx("td",{className:"px-4 py-2",children:W.jsx(NVt,{status:r.status})}),W.jsx("td",{className:"px-4 py-2 text-center text-gray-600",children:r.firstIteration!==null?r.firstIteration:""}),W.jsx("td",{className:"px-4 py-2 text-gray-600",children:r.iterations}),W.jsx("td",{className:"px-4 py-2",children:W.jsx(vVt,{progress:r.progress})}),W.jsx("td",{className:"px-4 py-2 text-gray-600",children:s(r.timeSpent)}),W.jsx("td",{className:"px-4 py-2 text-gray-500",children:W.jsx(UVt,{stats:r.stats})}),W.jsx("td",{className:"px-4 py-2",children:r.solverInstance?W.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:[W.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:W.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"})}),W.jsx("span",{children:"Input"})]}):null})]},r.name))})]})})]})},JVt=class extends tn.Component{constructor(t){super(t),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(t){console.error("InteractiveGraphics render error:",t)}render(){return this.state.hasError?this.props.fallback:this.props.children}};function TVt({graphics:t}){const A=t.points??[],e=t.lines??[],i=t.rects??[],n=t.circles??[],o=t.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 e){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,p=h.height??0;c(E,u),c(E+d,u+p)}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 W.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)=>W.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}`)),e.map((h,E)=>W.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)=>W.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)=>W.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)=>W.jsx("text",{x:h.x??0,y:h.y??0,fontSize:h.fontSize??10,fill:h.color??"black",children:h.text??""},`text-${E}`))]})}var KVt=({solver:t,animationSpeed:A=25,onSolverStarted:e,onSolverCompleted:i})=>{const[n,o]=V.useReducer(c=>c+1,0),s=V.useMemo(()=>{try{return t.visualize()||{points:[],lines:[],rects:[],circles:[]}}catch(c){return console.error("Visualization error:",c),{points:[],lines:[],rects:[],circles:[]}}},[t,n]),r=V.useMemo(()=>(s.rects?.length||0)===0&&(s.lines?.length||0)===0&&(s.points?.length||0)===0&&(s.circles?.length||0)===0,[s]);V.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=t.pipelineDef!==void 0,g=c=>{const I=t;if(!t.solved&&!t.failed){for(;!t.solved&&!t.failed&&I.currentPipelineStepIndex<=I.pipelineDef.findIndex(l=>l.solverName===c);)t.step();o()}};return W.jsxs("div",{children:[W.jsx(GVt,{solver:t,triggerRender:o,animationSpeed:A,onSolverStarted:e,onSolverCompleted:i}),r?W.jsx("div",{className:"p-4 text-gray-500",children:"No Graphics Yet"}):W.jsx(JVt,{fallback:W.jsx(TVt,{graphics:s}),children:W.jsx(_Vt,{graphics:s})}),a&&W.jsx(YVt,{solver:t,onStepUntilPhase:g})]})};const PVt=()=>{V.useEffect(()=>{const t="tailwind-cdn-script";if(document.getElementById(t)||window.tailwind)return;const A=document.createElement("div");A.className="hidden",document.body.appendChild(A);const e=window.getComputedStyle(A).display==="none";if(document.body.removeChild(A),e)return;const i=document.createElement("script");i.id=t,i.src="https://cdn.tailwindcss.com",document.head.appendChild(i)},[])},qVt=t=>t.toLowerCase().includes("pack")?nMt:t.toLowerCase().includes("rout")?gMt:KRt,OVt=({solverEvents:t=[]})=>{const[A,e]=V.useState(null);PVt();const i=V.useMemo(()=>{const r=new Map;for(const a of t){const g=`${a.componentName}-${a.solverName}`;r.set(g,a)}return r},[t]),n=V.useMemo(()=>Array.from(i.keys()),[i]),o=A?i.get(A):null,s=V.useMemo(()=>{if(!o)return{instance:null,error:null,classFound:!1};const r=PnA[o.solverName];if(!r)return{instance:null,error:`Solver class "${o.solverName}" not found in SOLVERS registry. Available: ${Object.keys(PnA).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 t.length===0?W.jsx("div",{className:"rf-p-4",children:W.jsx("div",{className:"rf-bg-gray-50 rf-rounded-md rf-border rf-border-gray-200",children:W.jsxs("div",{className:"rf-p-4",children:[W.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800 rf-mb-3",children:"No Solvers Detected"}),W.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."})]})})}):W.jsxs("div",{className:"rf-flex rf-h-full rf-overflow-hidden",children:[W.jsxs("div",{className:"rf-w-64 rf-border-r rf-border-gray-200 rf-overflow-y-auto rf-flex-shrink-0",children:[W.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 W.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:()=>e(r),children:(()=>{const c=qVt(a.solverName);return W.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2",children:[W.jsx(c,{className:"rf-w-4 rf-h-4 rf-text-blue-500 rf-flex-shrink-0"}),W.jsxs("div",{className:"rf-flex-1 rf-min-w-0",children:[W.jsx("div",{className:"rf-text-sm rf-font-medium rf-text-gray-800 rf-truncate",children:a.componentName}),W.jsx("div",{className:"rf-text-xs rf-text-gray-500 rf-truncate",children:a.solverName})]})]})})()},r)})]}),W.jsx("div",{className:"rf-flex-1 rf-overflow-hidden",children:o?s.instance?W.jsx(Yy,{fallback:W.jsx("div",{className:"rf-p-4",children:W.jsxs("div",{className:"rf-bg-red-50 rf-rounded-md rf-border rf-border-red-200 rf-p-4",children:[W.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-red-800 rf-mb-2",children:"Error Loading Solver Debugger"}),W.jsxs("p",{className:"rf-text-sm rf-text-red-600",children:["Failed to render the solver debugger for"," ",o.solverName]})]})}),children:W.jsx(KVt,{solver:s.instance})}):W.jsxs("div",{className:"rf-p-4",children:[W.jsxs("div",{className:"rf-mb-4",children:[W.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800",children:o.solverName}),W.jsxs("p",{className:"rf-text-sm rf-text-gray-500",children:["Component: ",o.componentName]})]}),s.error&&W.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:W.jsx("p",{className:`rf-text-sm ${s.classFound?"rf-text-red-700":"rf-text-yellow-700"}`,children:s.error})}),W.jsxs("div",{className:"rf-border rf-border-gray-200 rf-rounded-md rf-overflow-hidden",children:[W.jsx("div",{className:"rf-px-3 rf-py-2 rf-bg-gray-50",children:W.jsx("span",{className:"rf-text-sm rf-font-medium rf-text-gray-700",children:"Solver Parameters"})}),W.jsx("div",{className:"rf-p-3 rf-bg-white rf-border-t rf-border-gray-200",children:W.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)})})]})]}):W.jsx("div",{className:"rf-flex rf-items-center rf-justify-center rf-h-full",children:W.jsx("p",{className:"rf-text-sm rf-text-gray-500",children:"Select a solver from the list to view details"})})})]})},Pce=({errorMessage:t,errorStack:A,circuitJsonErrors:e})=>{V.useEffect(()=>{if(t){const i=new Error(t);A&&(i.stack=A);try{v5.captureException(i)}catch{}}},[t,A]),V.useEffect(()=>{if(e&&e.length>0)for(const i of e){const n=new Error(i.message||"Circuit JSON Error");i.stack&&(n.stack=i.stack);try{v5.captureException(n,{error_type:i.type})}catch{}}},[e])},qce="0.0.1556",WVt={version:qce},O9=dYA()(pYA(t=>({lastRunEvalVersion:void 0,setLastRunEvalVersion:A=>{t({lastRunEvalVersion:A})}}),{name:"runframe-runner-store"})),ZVt=t=>{const[A,e]=V.useState([]),[i,n]=V.useState(null),[o,s]=V.useState(""),[r,a]=e1("eval-version-selection",null),g=O9(B=>B.setLastRunEvalVersion),c=O9(B=>B.lastRunEvalVersion);return V.useEffect(()=>{t&&fetch("https://data.jsdelivr.com/v1/package/npm/@tscircuit/eval").then(B=>B.json()).then(B=>{if(Array.isArray(B?.versions)){let C=[...B.versions];B.tags?.latest&&(n(B.tags.latest),C=C.filter(Q=>Q!==B.tags.latest)),e(C)}}).catch(()=>{})},[t]),V.useEffect(()=>{t&&(r?(window.TSCIRCUIT_LATEST_EVAL_VERSION=r,g(r)):i&&(window.TSCIRCUIT_LATEST_EVAL_VERSION=i,g(i)))},[t,r,i]),{versions:V.useMemo(()=>A.filter(B=>B.includes(o)).slice(0,50),[A,o]),latestVersion:i,lastRunEvalVersion:c,search:o,setSearch:s,selectVersion:B=>{a(B),s("")}}},VVt=({snippetNames:t,onSelect:A,onCancel:e,isOpen:i})=>{const[n,o]=V.useState(""),[s,r]=V.useState("");if(!i)return null;const a=t.filter(I=>I.toLowerCase().includes(s.toLowerCase())),g=s&&!t.includes(s),c=I=>{I.key==="Enter"&&(a.length===1?o(a[0]):g&&o(s))};return W.jsx("div",{className:"rf-fixed rf-inset-0 rf-bg-black rf-bg-opacity-50 rf-flex rf-items-center rf-justify-center rf-z-[100]",children:W.jsxs("div",{className:"rf-bg-white rf-rounded-lg rf-p-6 rf-w-96",children:[W.jsx("h2",{className:"rf-text-lg rf-font-semibold rf-mb-4",children:"Select Snippet"}),W.jsx("input",{type:"text",className:"rf-w-full rf-px-4 rf-py-2 rf-border rf-rounded rf-mb-4",placeholder:"Search snippets or new snippet name...",value:s,onChange:I=>r(I.target.value),onKeyDown:c}),W.jsxs("div",{className:"rf-h-60 rf-overflow-y-auto",children:[a.map(I=>W.jsx("button",{type:"button",className:`w-full text-left px-4 py-2 rounded hover:bg-gray-100 ${n===I?"bg-blue-50":""}`,onClick:()=>o(I),children:I},I)),g&&W.jsxs("button",{type:"button",className:`w-full text-left px-4 py-2 rounded hover:bg-gray-100 text-blue-500 ${n===s?"bg-blue-50":""}`,onClick:()=>o(s),children:['Create new "',s,'"']})]}),W.jsxs("div",{className:"rf-mt-4 rf-flex rf-justify-end rf-gap-2",children:[W.jsx("button",{type:"button",className:"rf-px-4 rf-py-2 rf-text-gray-600 rf-hover:text-gray-800",onClick:e,children:"Cancel"}),W.jsx("button",{type:"button",className:"rf-px-4 rf-py-2 rf-bg-blue-500 rf-text-white rf-rounded rf-hover:bg-blue-600 rf-disabled:opacity-50",onClick:()=>n&&A(n),disabled:!n,children:n===s?`Create "${n}"`:`Save to ${n}`})]})]})})},jVt=t=>{const A=V.useRef(null),e=qI(i=>i.recentEvents);V.useEffect(()=>{if(e.length===0)return;const i=e[0];i.event_id!==A.current&&(t(i),A.current=i.event_id)},[e,t])};function zVt(t){const A=XVt(t),e=V.forwardRef((i,n)=>{const{children:o,...s}=i,r=V.Children.toArray(o),a=r.find(A9t);if(a){const g=a.props.children,c=r.map(I=>I===a?V.Children.count(g)>1?V.Children.only(null):V.isValidElement(g)?g.props.children:null:I);return W.jsx(A,{...s,ref:n,children:V.isValidElement(g)?V.cloneElement(g,void 0,c):null})}return W.jsx(A,{...s,ref:n,children:o})});return e.displayName=`${t}.Slot`,e}function XVt(t){const A=V.forwardRef((e,i)=>{const{children:n,...o}=e;if(V.isValidElement(n)){const s=t9t(n),r=e9t(o,n.props);return n.type!==V.Fragment&&(r.ref=i?of(i,s):s),V.cloneElement(n,r)}return V.Children.count(n)>1?V.Children.only(null):null});return A.displayName=`${t}.SlotClone`,A}var $Vt=Symbol("radix.slottable");function A9t(t){return V.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===$Vt}function e9t(t,A){const e={...A};for(const i in A){const n=t[i],o=A[i];/^on[A-Z]/.test(i)?n&&o?e[i]=(...r)=>{const a=o(...r);return n(...r),a}:n&&(e[i]=n):i==="style"?e[i]={...n,...o}:i==="className"&&(e[i]=[n,o].filter(Boolean).join(" "))}return{...t,...e}}function t9t(t){let A=Object.getOwnPropertyDescriptor(t.props,"ref")?.get,e=A&&"isReactWarning"in A&&A.isReactWarning;return e?t.ref:(A=Object.getOwnPropertyDescriptor(t,"ref")?.get,e=A&&"isReactWarning"in A&&A.isReactWarning,e?t.props.ref:t.props.ref||t.ref)}var W9="Dialog",[Oce,Wce]=Lm(W9),[i9t,cw]=Oce(W9),Zce=t=>{const{__scopeDialog:A,children:e,open:i,defaultOpen:n,onOpenChange:o,modal:s=!0}=t,r=V.useRef(null),a=V.useRef(null),[g,c]=Lx({prop:i,defaultProp:n??!1,onChange:o,caller:W9});return W.jsx(i9t,{scope:A,triggerRef:r,contentRef:a,contentId:yE(),titleId:yE(),descriptionId:yE(),open:g,onOpenChange:c,onOpenToggle:V.useCallback(()=>c(I=>!I),[c]),modal:s,children:e})};Zce.displayName=W9;var Vce="DialogTrigger",jce=V.forwardRef((t,A)=>{const{__scopeDialog:e,...i}=t,n=cw(Vce,e),o=EI(A,n.triggerRef);return W.jsx(qa.button,{type:"button","aria-haspopup":"dialog","aria-expanded":n.open,"aria-controls":n.contentId,"data-state":PfA(n.open),...i,ref:o,onClick:Un(t.onClick,n.onOpenToggle)})});jce.displayName=Vce;var TfA="DialogPortal",[n9t,zce]=Oce(TfA,{forceMount:void 0}),Xce=t=>{const{__scopeDialog:A,forceMount:e,children:i,container:n}=t,o=cw(TfA,A);return W.jsx(n9t,{scope:A,forceMount:e,children:V.Children.map(i,s=>W.jsx(E0,{present:e||o.open,children:W.jsx(KZ,{asChild:!0,container:n,children:s})}))})};Xce.displayName=TfA;var Z9="DialogOverlay",$ce=V.forwardRef((t,A)=>{const e=zce(Z9,t.__scopeDialog),{forceMount:i=e.forceMount,...n}=t,o=cw(Z9,t.__scopeDialog);return o.modal?W.jsx(E0,{present:i||o.open,children:W.jsx(s9t,{...n,ref:A})}):null});$ce.displayName=Z9;var o9t=zVt("DialogOverlay.RemoveScroll"),s9t=V.forwardRef((t,A)=>{const{__scopeDialog:e,...i}=t,n=cw(Z9,e);return W.jsx(zZ,{as:o9t,allowPinchZoom:!0,shards:[n.contentRef],children:W.jsx(qa.div,{"data-state":PfA(n.open),...i,ref:A,style:{pointerEvents:"auto",...i.style}})})}),GG="DialogContent",AIe=V.forwardRef((t,A)=>{const e=zce(GG,t.__scopeDialog),{forceMount:i=e.forceMount,...n}=t,o=cw(GG,t.__scopeDialog);return W.jsx(E0,{present:i||o.open,children:o.modal?W.jsx(r9t,{...n,ref:A}):W.jsx(a9t,{...n,ref:A})})});AIe.displayName=GG;var r9t=V.forwardRef((t,A)=>{const e=cw(GG,t.__scopeDialog),i=V.useRef(null),n=EI(A,e.contentRef,i);return V.useEffect(()=>{const o=i.current;if(o)return TuA(o)},[]),W.jsx(eIe,{...t,ref:n,trapFocus:e.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Un(t.onCloseAutoFocus,o=>{o.preventDefault(),e.triggerRef.current?.focus()}),onPointerDownOutside:Un(t.onPointerDownOutside,o=>{const s=o.detail.originalEvent,r=s.button===0&&s.ctrlKey===!0;(s.button===2||r)&&o.preventDefault()}),onFocusOutside:Un(t.onFocusOutside,o=>o.preventDefault())})}),a9t=V.forwardRef((t,A)=>{const e=cw(GG,t.__scopeDialog),i=V.useRef(!1),n=V.useRef(!1);return W.jsx(eIe,{...t,ref:A,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:o=>{t.onCloseAutoFocus?.(o),o.defaultPrevented||(i.current||e.triggerRef.current?.focus(),o.preventDefault()),i.current=!1,n.current=!1},onInteractOutside:o=>{t.onInteractOutside?.(o),o.defaultPrevented||(i.current=!0,o.detail.originalEvent.type==="pointerdown"&&(n.current=!0));const s=o.target;e.triggerRef.current?.contains(s)&&o.preventDefault(),o.detail.originalEvent.type==="focusin"&&n.current&&o.preventDefault()}})}),eIe=V.forwardRef((t,A)=>{const{__scopeDialog:e,trapFocus:i,onOpenAutoFocus:n,onCloseAutoFocus:o,...s}=t,r=cw(GG,e),a=V.useRef(null),g=EI(A,a);return muA(),W.jsxs(W.Fragment,{children:[W.jsx(kZ,{asChild:!0,loop:!0,trapped:i,onMountAutoFocus:n,onUnmountAutoFocus:o,children:W.jsx(XH,{role:"dialog",id:r.contentId,"aria-describedby":r.descriptionId,"aria-labelledby":r.titleId,"data-state":PfA(r.open),...s,ref:g,onDismiss:()=>r.onOpenChange(!1)})}),W.jsxs(W.Fragment,{children:[W.jsx(c9t,{titleId:r.titleId}),W.jsx(l9t,{contentRef:a,descriptionId:r.descriptionId})]})]})}),KfA="DialogTitle",tIe=V.forwardRef((t,A)=>{const{__scopeDialog:e,...i}=t,n=cw(KfA,e);return W.jsx(qa.h2,{id:n.titleId,...i,ref:A})});tIe.displayName=KfA;var iIe="DialogDescription",nIe=V.forwardRef((t,A)=>{const{__scopeDialog:e,...i}=t,n=cw(iIe,e);return W.jsx(qa.p,{id:n.descriptionId,...i,ref:A})});nIe.displayName=iIe;var oIe="DialogClose",sIe=V.forwardRef((t,A)=>{const{__scopeDialog:e,...i}=t,n=cw(oIe,e);return W.jsx(qa.button,{type:"button",...i,ref:A,onClick:Un(t.onClick,()=>n.onOpenChange(!1))})});sIe.displayName=oIe;function PfA(t){return t?"open":"closed"}var rIe="DialogTitleWarning",[g9t,aIe]=vXe(rIe,{contentName:GG,titleName:KfA,docsSlug:"dialog"}),c9t=({titleId:t})=>{const A=aIe(rIe),e=`\`${A.contentName}\` requires a \`${A.titleName}\` for the component to be accessible for screen reader users.
5690
5690
 
5691
5691
  If you want to hide the \`${A.titleName}\`, you can wrap it with our VisuallyHidden component.
5692
5692
 
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "main": "dist/index.js",
4
4
  "types": "dist/index.d.ts",
5
5
  "type": "module",
6
- "version": "0.0.1248",
6
+ "version": "0.0.1249",
7
7
  "repository": {
8
8
  "type": "git",
9
9
  "url": "https://github.com/tscircuit/tscircuit"
@@ -54,9 +54,9 @@
54
54
  "@tscircuit/checks": "^0.0.87",
55
55
  "@tscircuit/circuit-json-flex": "^0.0.3",
56
56
  "@tscircuit/circuit-json-util": "^0.0.77",
57
- "@tscircuit/cli": "^0.1.861",
58
- "@tscircuit/copper-pour-solver": "^0.0.14",
59
- "@tscircuit/core": "^0.0.1002",
57
+ "@tscircuit/cli": "^0.1.862",
58
+ "@tscircuit/copper-pour-solver": "^0.0.20",
59
+ "@tscircuit/core": "^0.0.1004",
60
60
  "@tscircuit/eval": "^0.0.618",
61
61
  "@tscircuit/footprinter": "^0.0.288",
62
62
  "@tscircuit/infgrid-ijump-astar": "^0.0.35",
@@ -65,7 +65,7 @@
65
65
  "@tscircuit/miniflex": "^0.0.4",
66
66
  "@tscircuit/ngspice-spice-engine": "^0.0.8",
67
67
  "@tscircuit/props": "^0.0.457",
68
- "@tscircuit/runframe": "^0.0.1556",
68
+ "@tscircuit/runframe": "^0.0.1557",
69
69
  "@tscircuit/schematic-match-adapt": "^0.0.16",
70
70
  "@tscircuit/schematic-trace-solver": "^v0.0.45",
71
71
  "@tscircuit/simple-3d-svg": "^0.0.41",