@tscircuit/runframe 0.0.1588 → 0.0.1589

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.
@@ -5382,9 +5382,9 @@ svg { font-family: 'Inter', 'Helvetica Neue', Arial, sans-serif; }
5382
5382
  `+a+` |
5383
5383
  `+o.line+" | "+g+`
5384
5384
  `+a+" | "+nfA("",n.column-1," ")+nfA("",I,"^")}else A+=`
5385
- at `+s}return A},B9.buildMessage=function(e,A){var t={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 t[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(e)+" but "+a(A)+" found."};const cJ=e=>typeof e=="number"&&!isNaN(e),kG=e=>typeof e=="string",Y0=e=>typeof e=="function",C9=e=>kG(e)||Y0(e)?e:null,ofA=e=>V.isValidElement(e)||kG(e)||Y0(e)||cJ(e);function _3e(e,A,t){t===void 0&&(t=300);const{scrollHeight:i,style:n}=e;requestAnimationFrame(()=>{n.minHeight="initial",n.height=i+"px",n.transition=`all ${t}ms`,requestAnimationFrame(()=>{n.height="0",n.padding="0",n.margin="0",setTimeout(A,t)})})}function Q9(e){let{enter:A,exit:t,appendPosition:i=!1,collapse:n=!0,collapseDuration:o=300}=e;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?`${t}--${a}`:t,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?_3e(E,c,o):c()};l||(g?u():(h.current=1,E.className+=` ${Q}`,E.addEventListener("animationend",u)))},[l]),en.createElement(en.Fragment,null,r)}}function kgt(e,A){return e!=null?{content:e.content,containerId:e.props.containerId,id:e.props.toastId,theme:e.props.theme,type:e.props.type,data:e.props.data||{},isLoading:e.props.isLoading,icon:e.props.icon,status:A}:{}}const Zd=new Map;let IJ=[];const sfA=new Set,k3e=e=>sfA.forEach(A=>A(e)),Fgt=()=>Zd.size>0;function Ggt(e,A){var t;if(A)return!((t=Zd.get(A))==null||!t.isToastActive(e));let i=!1;return Zd.forEach(n=>{n.isToastActive(e)&&(i=!0)}),i}function Rgt(e,A){ofA(e)&&(Fgt()||IJ.push({content:e,options:A}),Zd.forEach(t=>{t.buildToast(e,A)}))}function Mgt(e,A){Zd.forEach(t=>{A!=null&&A!=null&&A.containerId?A?.containerId===t.id&&t.toggle(e,A?.id):t.toggle(e,A?.id)})}function F3e(e){const{subscribe:A,getSnapshot:t,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(S=>S())},w=S=>{h=S==null?[]:h.filter(k=>k!==S),m()},D=S=>{const{toastId:k,onOpen:x,updateId:N,children:M}=S.props,L=N==null;S.staleId&&d.delete(S.staleId),d.set(k,S),h=[...h,S.props.toastId].filter(Y=>Y!==S.staleId),m(),l(kgt(S,L?"added":"updated")),L&&Y0(x)&&x(V.isValidElement(M)&&M.props)};return{id:c,props:u,observe:S=>(p.add(S),()=>p.delete(S)),toggle:(S,k)=>{d.forEach(x=>{k!=null&&k!==x.props.toastId||Y0(x.toggle)&&x.toggle(S)})},removeToast:w,toasts:d,clearQueue:()=>{C-=Q.length,Q=[]},buildToast:(S,k)=>{if((nA=>{let{containerId:rA,toastId:lA,updateId:fA}=nA;const bA=rA?rA!==c:c!==1,GA=d.has(lA)&&fA==null;return bA||GA})(k))return;const{toastId:x,updateId:N,data:M,staleId:L,delay:Y}=k,H=()=>{w(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:C9(k.className||u.toastClassName),bodyClassName:C9(k.bodyClassName||u.bodyClassName),progressClassName:C9(k.progressClassName||u.progressClassName),autoClose:!k.isLoading&&($=k.autoClose,eA=u.autoClose,$===!1||cJ($)&&$>0?$:eA),deleteToast(){const nA=d.get(x),{onClose:rA,children:lA}=nA.props;Y0(rA)&&rA(V.isValidElement(lA)&&lA.props),l(kgt(nA,"removed")),d.delete(x),C--,C<0&&(C=0),Q.length>0?D(Q.shift()):m()}};var $,eA;Z.closeButton=u.closeButton,k.closeButton===!1||ofA(k.closeButton)?Z.closeButton=k.closeButton:k.closeButton===!0&&(Z.closeButton=!ofA(u.closeButton)||u.closeButton);let aA=S;V.isValidElement(S)&&!kG(S.type)?aA=V.cloneElement(S,{closeToast:H,toastProps:Z,data:M}):Y0(S)&&(aA=S({closeToast:H,toastProps:Z,data:M}));const tA={content:aA,props:Z,staleId:L};u.limit&&u.limit>0&&C>u.limit&&O?Q.push(tA):cJ(Y)?setTimeout(()=>{D(tA)},Y):D(tA)},setProps(S){u=S},setToggle:(S,k)=>{d.get(S).toggle=k},isToastActive:S=>h.some(k=>k===S),getSnapshot:()=>E}})(s,o,k3e);Zd.set(s,a);const g=a.observe(r);return IJ.forEach(c=>Rgt(c.content,c.options)),IJ=[],()=>{g(),Zd.delete(s)}},setProps(r){var a;(a=Zd.get(s))==null||a.setProps(r)},getSnapshot(){var r;return(r=Zd.get(s))==null?void 0:r.getSnapshot()}}})(e)).current;i(e);const n=V.useSyncExternalStore(A,t,t);return{getToastToRender:function(o){if(!n)return[];const s=new Map;return e.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:Ggt,count:n?.length}}function G3e(e){const[A,t]=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}=e;var l,B;function C(){t(!0)}function Q(){t(!1)}function h(d){const p=o.current;s.canDrag&&p&&(s.didMove=!0,A&&Q(),s.delta=e.draggableDirection==="x"?d.clientX-s.start:d.clientY-s.start,s.start!==d.clientX&&(s.canCloseOnClick=!1),p.style.transform=`translate3d(${e.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),e.closeToast(),void e.collapseAll();d.style.transition="transform 0.2s, opacity 0.2s",d.style.removeProperty("transform"),d.style.removeProperty("opacity")}}(B=Zd.get((l={id:e.toastId,containerId:e.containerId,fn:t}).containerId||1))==null||B.setToggle(l.id,l.fn),V.useEffect(()=>{if(e.pauseOnFocusLoss)return document.hasFocus()||Q(),window.addEventListener("focus",C),window.addEventListener("blur",Q),()=>{window.removeEventListener("focus",C),window.removeEventListener("blur",Q)}},[e.pauseOnFocusLoss]);const u={onPointerDown:function(d){if(e.draggable===!0||e.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",e.draggableDirection==="x"?(s.start=d.clientX,s.removalDistance=p.offsetWidth*(e.draggablePercent/100)):(s.start=d.clientY,s.removalDistance=p.offsetHeight*(e.draggablePercent===80?1.5*e.draggablePercent:e.draggablePercent)/100)}},onPointerUp:function(d){const{top:p,bottom:m,left:w,right:D}=o.current.getBoundingClientRect();d.nativeEvent.type!=="touchend"&&e.pauseOnHover&&d.clientX>=w&&d.clientX<=D&&d.clientY>=p&&d.clientY<=m?Q():C()}};return r&&a&&(u.onMouseEnter=Q,e.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 R3e(e){let{delay:A,isRunning:t,closeToast:i,type:n="default",hide:o,className:s,style:r,controlledProgress:a,progress:g,rtl:c,isIn:I,theme:l}=e;const B=o||a&&g===0,C={...r,animationDuration:`${A}ms`,animationPlayState:t?"running":"paused"};a&&(C.transform=`scaleX(${g})`);const Q=Wm("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=Y0(s)?s({rtl:c,type:n,defaultClassName:Q}):Wm(Q,s),E={[a&&g>=1?"onTransitionEnd":"onAnimationEnd"]:a&&g<1?null:()=>{I&&i()}};return en.createElement("div",{className:"Toastify__progress-bar--wrp","data-hidden":B},en.createElement("div",{className:`Toastify__progress-bar--bg Toastify__progress-bar-theme--${l} Toastify__progress-bar--${n}`}),en.createElement("div",{role:"progressbar","aria-hidden":B?"true":"false","aria-label":"notification timer",className:h,style:C,...E}))}let M3e=1;const Ngt=()=>""+M3e++;function N3e(e){return e&&(kG(e.toastId)||cJ(e.toastId))?e.toastId:Ngt()}function lJ(e,A){return Rgt(e,A),A.toastId}function h9(e,A){return{...A,type:A&&A.type||e,toastId:N3e(A)}}function E9(e){return(A,t)=>lJ(A,h9(e,t))}function Xg(e,A){return lJ(e,h9("default",A))}Xg.loading=(e,A)=>lJ(e,h9("default",{isLoading:!0,autoClose:!1,closeOnClick:!1,closeButton:!1,draggable:!1,...A})),Xg.promise=function(e,A,t){let i,{pending:n,error:o,success:s}=A;n&&(i=kG(n)?Xg.loading(n,t):Xg.loading(n.render,{...t,...n}));const r={isLoading:null,autoClose:null,closeOnClick:null,closeButton:null,draggable:null},a=(c,I,l)=>{if(I==null)return void Xg.dismiss(i);const B={type:c,...r,...t,data:l},C=kG(I)?{render:I}:I;return i?Xg.update(i,{...B,...C}):Xg(C.render,{...B,...C}),l},g=Y0(e)?e():e;return g.then(c=>a("success",s,c)).catch(c=>a("error",o,c)),g},Xg.success=E9("success"),Xg.info=E9("info"),Xg.error=E9("error"),Xg.warning=E9("warning"),Xg.warn=Xg.warning,Xg.dark=(e,A)=>lJ(e,h9("default",{theme:"dark",...A})),Xg.dismiss=function(e){(function(A){var t;if(Fgt()){if(A==null||kG(t=A)||cJ(t))Zd.forEach(i=>{i.removeToast(A)});else if(A&&("containerId"in A||"id"in A)){const i=Zd.get(A.containerId);i?i.removeToast(A.id):Zd.forEach(n=>{n.removeToast(A.id)})}}else IJ=IJ.filter(i=>A!=null&&i.options.toastId!==A)})(e)},Xg.clearWaitingQueue=function(e){e===void 0&&(e={}),Zd.forEach(A=>{!A.props.limit||e.containerId&&A.id!==e.containerId||A.clearQueue()})},Xg.isActive=Ggt,Xg.update=function(e,A){A===void 0&&(A={});const t=((i,n)=>{var o;let{containerId:s}=n;return(o=Zd.get(s||1))==null?void 0:o.toasts.get(i)})(e,A);if(t){const{props:i,content:n}=t,o={delay:100,...i,...A,toastId:A.toastId||e,updateId:Ngt()};o.toastId!==e&&(o.staleId=e);const s=o.render||n;delete o.render,lJ(s,o)}},Xg.done=e=>{Xg.update(e,{progress:1})},Xg.onChange=function(e){return sfA.add(e),()=>{sfA.delete(e)}},Xg.play=e=>Mgt(!0,e),Xg.pause=e=>Mgt(!1,e);const v3e=typeof window<"u"?V.useLayoutEffect:V.useEffect,u9=e=>{let{theme:A,type:t,isLoading:i,...n}=e;return en.createElement("svg",{viewBox:"0 0 24 24",width:"100%",height:"100%",fill:A==="colored"?"currentColor":`var(--toastify-icon-color-${t})`,...n})},rfA={info:function(e){return en.createElement(u9,{...e},en.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(e){return en.createElement(u9,{...e},en.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(e){return en.createElement(u9,{...e},en.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(e){return en.createElement(u9,{...e},en.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 en.createElement("div",{className:"Toastify__spinner"})}},L3e=e=>{const{isRunning:A,preventExitTransition:t,toastRef:i,eventHandlers:n,playToast:o}=G3e(e),{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:w,progress:D,rtl:S,toastId:k,deleteToast:x,isIn:N,isLoading:M,closeOnClick:L,theme:Y}=e,H=Wm("Toastify__toast",`Toastify__toast-theme--${Y}`,`Toastify__toast--${c}`,{"Toastify__toast--rtl":S},{"Toastify__toast--close-on-click":L}),O=Y0(Q)?Q({rtl:S,position:C,type:c,defaultClassName:H}):Wm(H,Q),Z=(function(tA){let{theme:nA,type:rA,isLoading:lA,icon:fA}=tA,bA=null;const GA={theme:nA,type:rA};return fA===!1||(Y0(fA)?bA=fA({...GA,isLoading:lA}):V.isValidElement(fA)?bA=V.cloneElement(fA,GA):lA?bA=rfA.spinner():(YA=>YA in rfA)(rA)&&(bA=rfA[rA](GA))),bA})(e),$=!!D||!a,eA={closeToast:l,type:c,theme:Y};let aA=null;return s===!1||(aA=Y0(s)?s(eA):V.isValidElement(s)?V.cloneElement(s,eA):(function(tA){let{closeToast:nA,theme:rA,ariaLabel:lA="close"}=tA;return en.createElement("button",{className:`Toastify__close-button Toastify__close-button--${rA}`,type:"button",onClick:fA=>{fA.stopPropagation(),nA(fA)},"aria-label":lA},en.createElement("svg",{"aria-hidden":"true",viewBox:"0 0 14 16"},en.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"})))})(eA)),en.createElement(B,{isIn:N,done:x,position:C,preventExitTransition:t,nodeRef:i,playToast:o},en.createElement("div",{id:k,onClick:g,"data-in":N,className:O,...n,style:h,ref:i},en.createElement("div",{...N&&{role:w},className:Y0(E)?E({type:c}):Wm("Toastify__toast-body",E),style:u},Z!=null&&en.createElement("div",{className:Wm("Toastify__toast-icon",{"Toastify--animate-icon Toastify__zoom-enter":!M})},Z),en.createElement("div",null,r)),aA,en.createElement(R3e,{...m&&!$?{key:`pb-${m}`}:{},rtl:S,theme:Y,delay:a,isRunning:A,isIn:N,closeToast:l,hide:I,type:c,style:p,className:d,controlledProgress:$,progress:D||0})))},d9=function(e,A){return A===void 0&&(A=!1),{enter:`Toastify--animate Toastify__${e}-enter`,exit:`Toastify--animate Toastify__${e}-exit`,appendPosition:A}},U3e=Q9(d9("bounce",!0));Q9(d9("slide",!0)),Q9(d9("zoom")),Q9(d9("flip"));const H3e={position:"top-right",transition:U3e,autoClose:5e3,closeButton:!0,pauseOnHover:!0,pauseOnFocusLoss:!0,draggable:"touch",draggablePercent:80,draggableDirection:"x",role:"alert",theme:"light"};function Y3e(e){let A={...H3e,...e};const t=e.stacked,[i,n]=V.useState(!0),o=V.useRef(null),{getToastToRender:s,isToastActive:r,count:a}=F3e(A),{className:g,style:c,rtl:I,containerId:l}=A;function B(Q){const h=Wm("Toastify__toast-container",`Toastify__toast-container--${Q}`,{"Toastify__toast-container--rtl":I});return Y0(g)?g({position:Q,rtl:I,defaultClassName:h}):Wm(h,C9(g))}function C(){t&&(n(!0),Xg.play())}return v3e(()=>{if(t){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,w)=>{const D=m;D.classList.add("Toastify__toast--stacked"),w>0&&(D.dataset.collapsed=`${i}`),D.dataset.pos||(D.dataset.pos=u?"top":"bot");const S=d*(i?.2:1)+(i?0:E*w);D.style.setProperty("--y",`${u?S:-1*S}px`),D.style.setProperty("--g",`${E}`),D.style.setProperty("--s",""+(1-(i?p:0))),d+=D.offsetHeight,p+=.025})}},[i,a,t]),en.createElement("div",{ref:o,className:"Toastify",id:l,onMouseEnter:()=>{t&&(n(!1),Xg.pause())},onMouseLeave:C},s((Q,h)=>{const E=h.length?{...c}:{...c,pointerEvents:"none"};return en.createElement("div",{className:B(Q),style:E,key:`container-${Q}`},h.map(u=>{let{content:d,props:p}=u;return en.createElement(L3e,{...p,stacked:t,collapseAll:C,isIn:r(p.toastId,p.containerId),style:p.style,key:`toast-${p.key}`},d)}))}))}function J3e(){var e=':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=e,document.head.appendChild(A)}var afA={exports:{}},gfA,vgt;function Lgt(){return vgt||(vgt=1,gfA={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]}),gfA}var cfA={exports:{}},IfA,Ugt;function T3e(){return Ugt||(Ugt=1,IfA=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")}),IfA}var Hgt;function K3e(){if(Hgt)return cfA.exports;Hgt=1;var e=T3e(),A=Array.prototype.concat,t=Array.prototype.slice,i=cfA.exports=function(o){for(var s=[],r=0,a=o.length;r<a;r++){var g=o[r];e(g)?s=A.call(s,t.call(g)):s.push(g)}return s};return i.wrap=function(n){return function(){return n(i(arguments))}},cfA.exports}var Ygt;function P3e(){if(Ygt)return afA.exports;Ygt=1;var e=Lgt(),A=K3e(),t=Object.hasOwnProperty,i=Object.create(null);for(var n in e)t.call(e,n)&&(i[e[n]]=n);var o=afA.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]:t.call(e,Q[1])?(C=e[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 afA.exports}var lfA,Jgt;function Tgt(){if(Jgt)return lfA;Jgt=1;const e=Lgt(),A={};for(const n of Object.keys(e))A[e[n]]=n;const t={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"]}};lfA=t;for(const n of Object.keys(t)){if(!("channels"in t[n]))throw new Error("missing channels property: "+n);if(!("labels"in t[n]))throw new Error("missing channel labels property: "+n);if(t[n].labels.length!==t[n].channels)throw new Error("channel and label counts mismatch: "+n);const{channels:o,labels:s}=t[n];delete t[n].channels,delete t[n].labels,Object.defineProperty(t[n],"channels",{value:o}),Object.defineProperty(t[n],"labels",{value:s})}t.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]},t.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]},t.rgb.hwb=function(n){const o=n[0],s=n[1];let r=n[2];const a=t.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]},t.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 t.rgb.keyword=function(n){const o=A[n];if(o)return o;let s=1/0,r;for(const a of Object.keys(e)){const g=e[a],c=i(n,g);c<s&&(s=c,r=a)}return r},t.keyword.rgb=function(n){return e[n]},t.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]},t.rgb.lab=function(n){const o=t.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]},t.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},t.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]},t.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]}},t.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]},t.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]},t.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]},t.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]},t.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]},t.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]},t.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]},t.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]},t.rgb.ansi16=function(n,o=null){const[s,r,a]=n;let g=o===null?t.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},t.hsv.ansi16=function(n){return t.rgb.ansi16(t.hsv.rgb(n),n[2])},t.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)},t.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]},t.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]},t.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},t.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]},t.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]},t.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]},t.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]},t.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]},t.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]},t.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]},t.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]},t.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]},t.apple.rgb=function(n){return[n[0]/65535*255,n[1]/65535*255,n[2]/65535*255]},t.rgb.apple=function(n){return[n[0]/255*65535,n[1]/255*65535,n[2]/255*65535]},t.gray.rgb=function(n){return[n[0]/100*255,n[0]/100*255,n[0]/100*255]},t.gray.hsl=function(n){return[0,0,n[0]]},t.gray.hsv=t.gray.hsl,t.gray.hwb=function(n){return[0,100,n[0]]},t.gray.cmyk=function(n){return[0,0,0,n[0]]},t.gray.lab=function(n){return[n[0],0,0]},t.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},t.rgb.gray=function(n){return[(n[0]+n[1]+n[2])/3/255*100]},lfA}var BfA,Kgt;function q3e(){if(Kgt)return BfA;Kgt=1;const e=Tgt();function A(){const o={},s=Object.keys(e);for(let r=s.length,a=0;a<r;a++)o[s[a]]={distance:-1,parent:null};return o}function t(o){const s=A(),r=[o];for(s[o].distance=0;r.length;){const a=r.pop(),g=Object.keys(e[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=e[s[o].parent][o],g=s[o].parent;for(;s[g].parent;)r.unshift(s[g].parent),a=i(e[s[g].parent][g],a),g=s[g].parent;return a.conversion=r,a}return BfA=function(o){const s=t(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},BfA}var CfA,Pgt;function O3e(){if(Pgt)return CfA;Pgt=1;const e=Tgt(),A=q3e(),t={},i=Object.keys(e);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=>{t[s]={},Object.defineProperty(t[s],"channels",{value:e[s].channels}),Object.defineProperty(t[s],"labels",{value:e[s].labels});const r=A(s);Object.keys(r).forEach(g=>{const c=r[g];t[s][g]=o(c),t[s][g].raw=n(c)})}),CfA=t,CfA}var QfA,qgt;function W3e(){if(qgt)return QfA;qgt=1;const e=P3e(),A=O3e(),t=["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 t&&(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=e.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 e.to?this:this.rgb();B=B.round(typeof l=="number"?l:1);const C=B.valpha===1?B.color:[...B.color,this.valpha];return e.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 e.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):e.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),e.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(t.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 QfA=o,QfA}var Z3e=W3e();const Na=h0(Z3e);function Cn(e,A){return Array.isArray(A)?[e.a*A[0]+e.c*A[1]+e.e,e.b*A[0]+e.d*A[1]+e.f]:{x:e.a*A.x+e.c*A.y+e.e,y:e.b*A.x+e.d*A.y+e.f}}function V3e(){return{a:1,c:0,e:0,b:0,d:1,f:0}}function hfA(e){return typeof e>"u"}function p9(e,A=0){return{a:1,c:0,e,b:0,d:1,f:A}}function EfA(...e){e=Array.isArray(e[0])?e[0]:e;const A=(t,i)=>({a:t.a*i.a+t.c*i.b,c:t.a*i.c+t.c*i.d,e:t.a*i.e+t.c*i.f+t.e,b:t.b*i.a+t.d*i.b,d:t.b*i.c+t.d*i.d,f:t.b*i.e+t.d*i.f+t.f});switch(e.length){case 0:throw new Error("no matrices provided");case 1:return e[0];case 2:return A(e[0],e[1]);default:{const[t,i,...n]=e,o=A(t,i);return EfA(o,...n)}}}function j3e(...e){return EfA(...e)}function z3e(e,A=void 0,t=void 0,i=void 0){hfA(A)&&(A=e);const n={a:e,c:0,e:0,b:0,d:A,f:0};return hfA(t)||hfA(i)?n:EfA([p9(t,i),n,p9(-t,-i)])}function f9(e){const{ctx:A,points:t,fill:i,stroke:n,strokeWidth:o=1,realToCanvasMat:s,closePath:r=!1}=e;if(t.length<2)return;A.beginPath();const a=t.map(l=>Cn(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 bf(e){const{ctx:A,center:t,width:i,height:n,fill:o,realToCanvasMat:s,borderRadius:r=0,rotation:a=0,stroke:g,strokeWidth:c,isStrokeDashed:I=!1}=e,[l,B]=Cn(s,[t.x,t.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 X3e(e){const{ctx:A,board:t,realToCanvasMat:i,colorMap:n,drawBoardMaterial:o}=e,{width:s,height:r,center:a,outline:g}=t;if(g&&Array.isArray(g)&&g.length>=3){o&&f9({ctx:A,points:g.map(c=>({x:c.x,y:c.y})),fill:n.substrate,realToCanvasMat:i,closePath:!0}),f9({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&&bf({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}];f9({ctx:A,points:l,stroke:n.boardOutline,strokeWidth:.1,realToCanvasMat:i,closePath:!0})}}function i1(e){const{ctx:A,points:t,fill:i,realToCanvasMat:n}=e;if(t.length<3)return;A.beginPath();const o=t.map(g=>Cn(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 $3e(e,A){return A.copper[e]??A.copper.top}function AOe(e,A,t,i,n){if(Math.abs(n)<1e-10)return null;const o=t-e,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=(e+t)/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 ufA(e,A,t,i,n,o,s){if(Math.abs(o)<1e-10){const[p,m]=Cn(s,[i,n]);e.lineTo(p,m);return}const r=AOe(A,t,i,n,o);if(!r){const[p,m]=Cn(s,[i,n]);e.lineTo(p,m);return}const[a,g]=Cn(s,[A,t]),[c,I]=Cn(s,[i,n]),[l,B]=Cn(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;e.arc(l,B,C,Q,h,d)}function Ogt(e,A,t){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]=Cn(t,[s.x,s.y]);e.moveTo(a,g),ufA(e,s.x,s.y,r.x,r.y,1,t),ufA(e,r.x,r.y,s.x,s.y,1,t);return}}const i=A.vertices[0];if(!i)return;const[n,o]=Cn(t,[i.x,i.y]);e.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]=Cn(t,[g.x,g.y]);e.lineTo(I,l)}else ufA(e,r.x,r.y,g.x,g.y,c,t)}}function tOe(e){const{ctx:A,pour:t,realToCanvasMat:i,colorMap:n}=e,o=$3e(t.layer,n);if(A.save(),t.shape==="rect"){const[s,r]=Cn(i,[t.center.x,t.center.y]),a=t.width*Math.abs(i.a),g=t.height*Math.abs(i.a);A.translate(s,r),t.rotation&&A.rotate(-t.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(t.shape==="polygon"){if(t.points&&t.points.length>=3){const s=t.points.map(c=>Cn(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(t.shape==="brep"){if(A.beginPath(),Ogt(A,t.brep_shape.outer_ring,i),t.brep_shape.inner_rings)for(const s of t.brep_shape.inner_rings)Ogt(A,s,i);A.fillStyle=o,A.globalAlpha=.5,A.fill("evenodd"),A.restore();return}A.restore()}var eOe=.62,iOe=.3,nOe=1,oOe=.13,sOe=1.2;function y9(e,A){const t=A*eOe,i=t*iOe,n=t*nOe,o=Math.max(A*oOe,.35),s=A*sOe,r=e.replace(/\\n/g,`
5385
+ at `+s}return A},B9.buildMessage=function(e,A){var t={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 t[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(e)+" but "+a(A)+" found."};const cJ=e=>typeof e=="number"&&!isNaN(e),kG=e=>typeof e=="string",Y0=e=>typeof e=="function",C9=e=>kG(e)||Y0(e)?e:null,ofA=e=>V.isValidElement(e)||kG(e)||Y0(e)||cJ(e);function _3e(e,A,t){t===void 0&&(t=300);const{scrollHeight:i,style:n}=e;requestAnimationFrame(()=>{n.minHeight="initial",n.height=i+"px",n.transition=`all ${t}ms`,requestAnimationFrame(()=>{n.height="0",n.padding="0",n.margin="0",setTimeout(A,t)})})}function Q9(e){let{enter:A,exit:t,appendPosition:i=!1,collapse:n=!0,collapseDuration:o=300}=e;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?`${t}--${a}`:t,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?_3e(E,c,o):c()};l||(g?u():(h.current=1,E.className+=` ${Q}`,E.addEventListener("animationend",u)))},[l]),en.createElement(en.Fragment,null,r)}}function kgt(e,A){return e!=null?{content:e.content,containerId:e.props.containerId,id:e.props.toastId,theme:e.props.theme,type:e.props.type,data:e.props.data||{},isLoading:e.props.isLoading,icon:e.props.icon,status:A}:{}}const Zd=new Map;let IJ=[];const sfA=new Set,k3e=e=>sfA.forEach(A=>A(e)),Fgt=()=>Zd.size>0;function Ggt(e,A){var t;if(A)return!((t=Zd.get(A))==null||!t.isToastActive(e));let i=!1;return Zd.forEach(n=>{n.isToastActive(e)&&(i=!0)}),i}function Rgt(e,A){ofA(e)&&(Fgt()||IJ.push({content:e,options:A}),Zd.forEach(t=>{t.buildToast(e,A)}))}function Mgt(e,A){Zd.forEach(t=>{A!=null&&A!=null&&A.containerId?A?.containerId===t.id&&t.toggle(e,A?.id):t.toggle(e,A?.id)})}function F3e(e){const{subscribe:A,getSnapshot:t,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(S=>S())},w=S=>{h=S==null?[]:h.filter(k=>k!==S),m()},D=S=>{const{toastId:k,onOpen:x,updateId:N,children:M}=S.props,L=N==null;S.staleId&&d.delete(S.staleId),d.set(k,S),h=[...h,S.props.toastId].filter(Y=>Y!==S.staleId),m(),l(kgt(S,L?"added":"updated")),L&&Y0(x)&&x(V.isValidElement(M)&&M.props)};return{id:c,props:u,observe:S=>(p.add(S),()=>p.delete(S)),toggle:(S,k)=>{d.forEach(x=>{k!=null&&k!==x.props.toastId||Y0(x.toggle)&&x.toggle(S)})},removeToast:w,toasts:d,clearQueue:()=>{C-=Q.length,Q=[]},buildToast:(S,k)=>{if((nA=>{let{containerId:rA,toastId:lA,updateId:fA}=nA;const bA=rA?rA!==c:c!==1,GA=d.has(lA)&&fA==null;return bA||GA})(k))return;const{toastId:x,updateId:N,data:M,staleId:L,delay:Y}=k,H=()=>{w(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:C9(k.className||u.toastClassName),bodyClassName:C9(k.bodyClassName||u.bodyClassName),progressClassName:C9(k.progressClassName||u.progressClassName),autoClose:!k.isLoading&&($=k.autoClose,eA=u.autoClose,$===!1||cJ($)&&$>0?$:eA),deleteToast(){const nA=d.get(x),{onClose:rA,children:lA}=nA.props;Y0(rA)&&rA(V.isValidElement(lA)&&lA.props),l(kgt(nA,"removed")),d.delete(x),C--,C<0&&(C=0),Q.length>0?D(Q.shift()):m()}};var $,eA;Z.closeButton=u.closeButton,k.closeButton===!1||ofA(k.closeButton)?Z.closeButton=k.closeButton:k.closeButton===!0&&(Z.closeButton=!ofA(u.closeButton)||u.closeButton);let aA=S;V.isValidElement(S)&&!kG(S.type)?aA=V.cloneElement(S,{closeToast:H,toastProps:Z,data:M}):Y0(S)&&(aA=S({closeToast:H,toastProps:Z,data:M}));const tA={content:aA,props:Z,staleId:L};u.limit&&u.limit>0&&C>u.limit&&O?Q.push(tA):cJ(Y)?setTimeout(()=>{D(tA)},Y):D(tA)},setProps(S){u=S},setToggle:(S,k)=>{d.get(S).toggle=k},isToastActive:S=>h.some(k=>k===S),getSnapshot:()=>E}})(s,o,k3e);Zd.set(s,a);const g=a.observe(r);return IJ.forEach(c=>Rgt(c.content,c.options)),IJ=[],()=>{g(),Zd.delete(s)}},setProps(r){var a;(a=Zd.get(s))==null||a.setProps(r)},getSnapshot(){var r;return(r=Zd.get(s))==null?void 0:r.getSnapshot()}}})(e)).current;i(e);const n=V.useSyncExternalStore(A,t,t);return{getToastToRender:function(o){if(!n)return[];const s=new Map;return e.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:Ggt,count:n?.length}}function G3e(e){const[A,t]=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}=e;var l,B;function C(){t(!0)}function Q(){t(!1)}function h(d){const p=o.current;s.canDrag&&p&&(s.didMove=!0,A&&Q(),s.delta=e.draggableDirection==="x"?d.clientX-s.start:d.clientY-s.start,s.start!==d.clientX&&(s.canCloseOnClick=!1),p.style.transform=`translate3d(${e.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),e.closeToast(),void e.collapseAll();d.style.transition="transform 0.2s, opacity 0.2s",d.style.removeProperty("transform"),d.style.removeProperty("opacity")}}(B=Zd.get((l={id:e.toastId,containerId:e.containerId,fn:t}).containerId||1))==null||B.setToggle(l.id,l.fn),V.useEffect(()=>{if(e.pauseOnFocusLoss)return document.hasFocus()||Q(),window.addEventListener("focus",C),window.addEventListener("blur",Q),()=>{window.removeEventListener("focus",C),window.removeEventListener("blur",Q)}},[e.pauseOnFocusLoss]);const u={onPointerDown:function(d){if(e.draggable===!0||e.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",e.draggableDirection==="x"?(s.start=d.clientX,s.removalDistance=p.offsetWidth*(e.draggablePercent/100)):(s.start=d.clientY,s.removalDistance=p.offsetHeight*(e.draggablePercent===80?1.5*e.draggablePercent:e.draggablePercent)/100)}},onPointerUp:function(d){const{top:p,bottom:m,left:w,right:D}=o.current.getBoundingClientRect();d.nativeEvent.type!=="touchend"&&e.pauseOnHover&&d.clientX>=w&&d.clientX<=D&&d.clientY>=p&&d.clientY<=m?Q():C()}};return r&&a&&(u.onMouseEnter=Q,e.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 R3e(e){let{delay:A,isRunning:t,closeToast:i,type:n="default",hide:o,className:s,style:r,controlledProgress:a,progress:g,rtl:c,isIn:I,theme:l}=e;const B=o||a&&g===0,C={...r,animationDuration:`${A}ms`,animationPlayState:t?"running":"paused"};a&&(C.transform=`scaleX(${g})`);const Q=Wm("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=Y0(s)?s({rtl:c,type:n,defaultClassName:Q}):Wm(Q,s),E={[a&&g>=1?"onTransitionEnd":"onAnimationEnd"]:a&&g<1?null:()=>{I&&i()}};return en.createElement("div",{className:"Toastify__progress-bar--wrp","data-hidden":B},en.createElement("div",{className:`Toastify__progress-bar--bg Toastify__progress-bar-theme--${l} Toastify__progress-bar--${n}`}),en.createElement("div",{role:"progressbar","aria-hidden":B?"true":"false","aria-label":"notification timer",className:h,style:C,...E}))}let M3e=1;const Ngt=()=>""+M3e++;function N3e(e){return e&&(kG(e.toastId)||cJ(e.toastId))?e.toastId:Ngt()}function lJ(e,A){return Rgt(e,A),A.toastId}function h9(e,A){return{...A,type:A&&A.type||e,toastId:N3e(A)}}function E9(e){return(A,t)=>lJ(A,h9(e,t))}function Xg(e,A){return lJ(e,h9("default",A))}Xg.loading=(e,A)=>lJ(e,h9("default",{isLoading:!0,autoClose:!1,closeOnClick:!1,closeButton:!1,draggable:!1,...A})),Xg.promise=function(e,A,t){let i,{pending:n,error:o,success:s}=A;n&&(i=kG(n)?Xg.loading(n,t):Xg.loading(n.render,{...t,...n}));const r={isLoading:null,autoClose:null,closeOnClick:null,closeButton:null,draggable:null},a=(c,I,l)=>{if(I==null)return void Xg.dismiss(i);const B={type:c,...r,...t,data:l},C=kG(I)?{render:I}:I;return i?Xg.update(i,{...B,...C}):Xg(C.render,{...B,...C}),l},g=Y0(e)?e():e;return g.then(c=>a("success",s,c)).catch(c=>a("error",o,c)),g},Xg.success=E9("success"),Xg.info=E9("info"),Xg.error=E9("error"),Xg.warning=E9("warning"),Xg.warn=Xg.warning,Xg.dark=(e,A)=>lJ(e,h9("default",{theme:"dark",...A})),Xg.dismiss=function(e){(function(A){var t;if(Fgt()){if(A==null||kG(t=A)||cJ(t))Zd.forEach(i=>{i.removeToast(A)});else if(A&&("containerId"in A||"id"in A)){const i=Zd.get(A.containerId);i?i.removeToast(A.id):Zd.forEach(n=>{n.removeToast(A.id)})}}else IJ=IJ.filter(i=>A!=null&&i.options.toastId!==A)})(e)},Xg.clearWaitingQueue=function(e){e===void 0&&(e={}),Zd.forEach(A=>{!A.props.limit||e.containerId&&A.id!==e.containerId||A.clearQueue()})},Xg.isActive=Ggt,Xg.update=function(e,A){A===void 0&&(A={});const t=((i,n)=>{var o;let{containerId:s}=n;return(o=Zd.get(s||1))==null?void 0:o.toasts.get(i)})(e,A);if(t){const{props:i,content:n}=t,o={delay:100,...i,...A,toastId:A.toastId||e,updateId:Ngt()};o.toastId!==e&&(o.staleId=e);const s=o.render||n;delete o.render,lJ(s,o)}},Xg.done=e=>{Xg.update(e,{progress:1})},Xg.onChange=function(e){return sfA.add(e),()=>{sfA.delete(e)}},Xg.play=e=>Mgt(!0,e),Xg.pause=e=>Mgt(!1,e);const v3e=typeof window<"u"?V.useLayoutEffect:V.useEffect,u9=e=>{let{theme:A,type:t,isLoading:i,...n}=e;return en.createElement("svg",{viewBox:"0 0 24 24",width:"100%",height:"100%",fill:A==="colored"?"currentColor":`var(--toastify-icon-color-${t})`,...n})},rfA={info:function(e){return en.createElement(u9,{...e},en.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(e){return en.createElement(u9,{...e},en.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(e){return en.createElement(u9,{...e},en.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(e){return en.createElement(u9,{...e},en.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 en.createElement("div",{className:"Toastify__spinner"})}},L3e=e=>{const{isRunning:A,preventExitTransition:t,toastRef:i,eventHandlers:n,playToast:o}=G3e(e),{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:w,progress:D,rtl:S,toastId:k,deleteToast:x,isIn:N,isLoading:M,closeOnClick:L,theme:Y}=e,H=Wm("Toastify__toast",`Toastify__toast-theme--${Y}`,`Toastify__toast--${c}`,{"Toastify__toast--rtl":S},{"Toastify__toast--close-on-click":L}),O=Y0(Q)?Q({rtl:S,position:C,type:c,defaultClassName:H}):Wm(H,Q),Z=(function(tA){let{theme:nA,type:rA,isLoading:lA,icon:fA}=tA,bA=null;const GA={theme:nA,type:rA};return fA===!1||(Y0(fA)?bA=fA({...GA,isLoading:lA}):V.isValidElement(fA)?bA=V.cloneElement(fA,GA):lA?bA=rfA.spinner():(YA=>YA in rfA)(rA)&&(bA=rfA[rA](GA))),bA})(e),$=!!D||!a,eA={closeToast:l,type:c,theme:Y};let aA=null;return s===!1||(aA=Y0(s)?s(eA):V.isValidElement(s)?V.cloneElement(s,eA):(function(tA){let{closeToast:nA,theme:rA,ariaLabel:lA="close"}=tA;return en.createElement("button",{className:`Toastify__close-button Toastify__close-button--${rA}`,type:"button",onClick:fA=>{fA.stopPropagation(),nA(fA)},"aria-label":lA},en.createElement("svg",{"aria-hidden":"true",viewBox:"0 0 14 16"},en.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"})))})(eA)),en.createElement(B,{isIn:N,done:x,position:C,preventExitTransition:t,nodeRef:i,playToast:o},en.createElement("div",{id:k,onClick:g,"data-in":N,className:O,...n,style:h,ref:i},en.createElement("div",{...N&&{role:w},className:Y0(E)?E({type:c}):Wm("Toastify__toast-body",E),style:u},Z!=null&&en.createElement("div",{className:Wm("Toastify__toast-icon",{"Toastify--animate-icon Toastify__zoom-enter":!M})},Z),en.createElement("div",null,r)),aA,en.createElement(R3e,{...m&&!$?{key:`pb-${m}`}:{},rtl:S,theme:Y,delay:a,isRunning:A,isIn:N,closeToast:l,hide:I,type:c,style:p,className:d,controlledProgress:$,progress:D||0})))},d9=function(e,A){return A===void 0&&(A=!1),{enter:`Toastify--animate Toastify__${e}-enter`,exit:`Toastify--animate Toastify__${e}-exit`,appendPosition:A}},U3e=Q9(d9("bounce",!0));Q9(d9("slide",!0)),Q9(d9("zoom")),Q9(d9("flip"));const H3e={position:"top-right",transition:U3e,autoClose:5e3,closeButton:!0,pauseOnHover:!0,pauseOnFocusLoss:!0,draggable:"touch",draggablePercent:80,draggableDirection:"x",role:"alert",theme:"light"};function Y3e(e){let A={...H3e,...e};const t=e.stacked,[i,n]=V.useState(!0),o=V.useRef(null),{getToastToRender:s,isToastActive:r,count:a}=F3e(A),{className:g,style:c,rtl:I,containerId:l}=A;function B(Q){const h=Wm("Toastify__toast-container",`Toastify__toast-container--${Q}`,{"Toastify__toast-container--rtl":I});return Y0(g)?g({position:Q,rtl:I,defaultClassName:h}):Wm(h,C9(g))}function C(){t&&(n(!0),Xg.play())}return v3e(()=>{if(t){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,w)=>{const D=m;D.classList.add("Toastify__toast--stacked"),w>0&&(D.dataset.collapsed=`${i}`),D.dataset.pos||(D.dataset.pos=u?"top":"bot");const S=d*(i?.2:1)+(i?0:E*w);D.style.setProperty("--y",`${u?S:-1*S}px`),D.style.setProperty("--g",`${E}`),D.style.setProperty("--s",""+(1-(i?p:0))),d+=D.offsetHeight,p+=.025})}},[i,a,t]),en.createElement("div",{ref:o,className:"Toastify",id:l,onMouseEnter:()=>{t&&(n(!1),Xg.pause())},onMouseLeave:C},s((Q,h)=>{const E=h.length?{...c}:{...c,pointerEvents:"none"};return en.createElement("div",{className:B(Q),style:E,key:`container-${Q}`},h.map(u=>{let{content:d,props:p}=u;return en.createElement(L3e,{...p,stacked:t,collapseAll:C,isIn:r(p.toastId,p.containerId),style:p.style,key:`toast-${p.key}`},d)}))}))}function J3e(){var e=':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=e,document.head.appendChild(A)}var afA={exports:{}},gfA,vgt;function Lgt(){return vgt||(vgt=1,gfA={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]}),gfA}var cfA={exports:{}},IfA,Ugt;function T3e(){return Ugt||(Ugt=1,IfA=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")}),IfA}var Hgt;function K3e(){if(Hgt)return cfA.exports;Hgt=1;var e=T3e(),A=Array.prototype.concat,t=Array.prototype.slice,i=cfA.exports=function(o){for(var s=[],r=0,a=o.length;r<a;r++){var g=o[r];e(g)?s=A.call(s,t.call(g)):s.push(g)}return s};return i.wrap=function(n){return function(){return n(i(arguments))}},cfA.exports}var Ygt;function P3e(){if(Ygt)return afA.exports;Ygt=1;var e=Lgt(),A=K3e(),t=Object.hasOwnProperty,i=Object.create(null);for(var n in e)t.call(e,n)&&(i[e[n]]=n);var o=afA.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]:t.call(e,Q[1])?(C=e[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 afA.exports}var lfA,Jgt;function Tgt(){if(Jgt)return lfA;Jgt=1;const e=Lgt(),A={};for(const n of Object.keys(e))A[e[n]]=n;const t={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"]}};lfA=t;for(const n of Object.keys(t)){if(!("channels"in t[n]))throw new Error("missing channels property: "+n);if(!("labels"in t[n]))throw new Error("missing channel labels property: "+n);if(t[n].labels.length!==t[n].channels)throw new Error("channel and label counts mismatch: "+n);const{channels:o,labels:s}=t[n];delete t[n].channels,delete t[n].labels,Object.defineProperty(t[n],"channels",{value:o}),Object.defineProperty(t[n],"labels",{value:s})}t.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]},t.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]},t.rgb.hwb=function(n){const o=n[0],s=n[1];let r=n[2];const a=t.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]},t.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 t.rgb.keyword=function(n){const o=A[n];if(o)return o;let s=1/0,r;for(const a of Object.keys(e)){const g=e[a],c=i(n,g);c<s&&(s=c,r=a)}return r},t.keyword.rgb=function(n){return e[n]},t.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]},t.rgb.lab=function(n){const o=t.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]},t.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},t.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]},t.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]}},t.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]},t.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]},t.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]},t.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]},t.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]},t.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]},t.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]},t.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]},t.rgb.ansi16=function(n,o=null){const[s,r,a]=n;let g=o===null?t.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},t.hsv.ansi16=function(n){return t.rgb.ansi16(t.hsv.rgb(n),n[2])},t.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)},t.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]},t.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]},t.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},t.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]},t.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]},t.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]},t.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]},t.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]},t.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]},t.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]},t.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]},t.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]},t.apple.rgb=function(n){return[n[0]/65535*255,n[1]/65535*255,n[2]/65535*255]},t.rgb.apple=function(n){return[n[0]/255*65535,n[1]/255*65535,n[2]/255*65535]},t.gray.rgb=function(n){return[n[0]/100*255,n[0]/100*255,n[0]/100*255]},t.gray.hsl=function(n){return[0,0,n[0]]},t.gray.hsv=t.gray.hsl,t.gray.hwb=function(n){return[0,100,n[0]]},t.gray.cmyk=function(n){return[0,0,0,n[0]]},t.gray.lab=function(n){return[n[0],0,0]},t.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},t.rgb.gray=function(n){return[(n[0]+n[1]+n[2])/3/255*100]},lfA}var BfA,Kgt;function q3e(){if(Kgt)return BfA;Kgt=1;const e=Tgt();function A(){const o={},s=Object.keys(e);for(let r=s.length,a=0;a<r;a++)o[s[a]]={distance:-1,parent:null};return o}function t(o){const s=A(),r=[o];for(s[o].distance=0;r.length;){const a=r.pop(),g=Object.keys(e[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=e[s[o].parent][o],g=s[o].parent;for(;s[g].parent;)r.unshift(s[g].parent),a=i(e[s[g].parent][g],a),g=s[g].parent;return a.conversion=r,a}return BfA=function(o){const s=t(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},BfA}var CfA,Pgt;function O3e(){if(Pgt)return CfA;Pgt=1;const e=Tgt(),A=q3e(),t={},i=Object.keys(e);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=>{t[s]={},Object.defineProperty(t[s],"channels",{value:e[s].channels}),Object.defineProperty(t[s],"labels",{value:e[s].labels});const r=A(s);Object.keys(r).forEach(g=>{const c=r[g];t[s][g]=o(c),t[s][g].raw=n(c)})}),CfA=t,CfA}var QfA,qgt;function W3e(){if(qgt)return QfA;qgt=1;const e=P3e(),A=O3e(),t=["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 t&&(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=e.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 e.to?this:this.rgb();B=B.round(typeof l=="number"?l:1);const C=B.valpha===1?B.color:[...B.color,this.valpha];return e.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 e.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):e.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),e.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(t.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 QfA=o,QfA}var Z3e=W3e();const Na=h0(Z3e);function Cn(e,A){return Array.isArray(A)?[e.a*A[0]+e.c*A[1]+e.e,e.b*A[0]+e.d*A[1]+e.f]:{x:e.a*A.x+e.c*A.y+e.e,y:e.b*A.x+e.d*A.y+e.f}}function V3e(){return{a:1,c:0,e:0,b:0,d:1,f:0}}function hfA(e){return typeof e>"u"}function p9(e,A=0){return{a:1,c:0,e,b:0,d:1,f:A}}function EfA(...e){e=Array.isArray(e[0])?e[0]:e;const A=(t,i)=>({a:t.a*i.a+t.c*i.b,c:t.a*i.c+t.c*i.d,e:t.a*i.e+t.c*i.f+t.e,b:t.b*i.a+t.d*i.b,d:t.b*i.c+t.d*i.d,f:t.b*i.e+t.d*i.f+t.f});switch(e.length){case 0:throw new Error("no matrices provided");case 1:return e[0];case 2:return A(e[0],e[1]);default:{const[t,i,...n]=e,o=A(t,i);return EfA(o,...n)}}}function j3e(...e){return EfA(...e)}function z3e(e,A=void 0,t=void 0,i=void 0){hfA(A)&&(A=e);const n={a:e,c:0,e:0,b:0,d:A,f:0};return hfA(t)||hfA(i)?n:EfA([p9(t,i),n,p9(-t,-i)])}function f9(e){const{ctx:A,points:t,fill:i,stroke:n,strokeWidth:o=1,minStrokePx:s,realToCanvasMat:r,closePath:a=!1}=e;if(t.length<2)return;A.beginPath();const g=t.map(B=>Cn(r,[B.x,B.y])),c=g[0];if(!c)return;const[I,l]=c;A.moveTo(I,l);for(let B=1;B<g.length;B++){const C=g[B];if(!C)continue;const[Q,h]=C;A.lineTo(Q,h)}if(a&&A.closePath(),i&&(A.fillStyle=i,A.fill()),n){const B=o*Math.abs(r.a),C=s===void 0?B:Math.max(B,s);A.strokeStyle=n,A.lineWidth=C,A.stroke()}}function bf(e){const{ctx:A,center:t,width:i,height:n,fill:o,realToCanvasMat:s,borderRadius:r=0,rotation:a=0,stroke:g,strokeWidth:c,isStrokeDashed:I=!1}=e,[l,B]=Cn(s,[t.x,t.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 X3e(e){const{ctx:A,board:t,realToCanvasMat:i,colorMap:n,drawBoardMaterial:o,minBoardOutlineStrokePx:s}=e,{width:r,height:a,center:g,outline:c}=t;if(c&&Array.isArray(c)&&c.length>=3){o&&f9({ctx:A,points:c.map(I=>({x:I.x,y:I.y})),fill:n.substrate,realToCanvasMat:i,closePath:!0}),f9({ctx:A,points:c.map(I=>({x:I.x,y:I.y})),stroke:n.boardOutline,strokeWidth:.1,realToCanvasMat:i,closePath:!0,minStrokePx:s});return}if(r!==void 0&&a!==void 0&&g){o&&bf({ctx:A,center:g,width:r,height:a,fill:n.substrate,realToCanvasMat:i});const I=r/2,l=a/2,B=[{x:g.x-I,y:g.y-l},{x:g.x+I,y:g.y-l},{x:g.x+I,y:g.y+l},{x:g.x-I,y:g.y+l}];f9({ctx:A,points:B,stroke:n.boardOutline,strokeWidth:.1,realToCanvasMat:i,closePath:!0,minStrokePx:s})}}function i1(e){const{ctx:A,points:t,fill:i,realToCanvasMat:n}=e;if(t.length<3)return;A.beginPath();const o=t.map(g=>Cn(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 $3e(e,A){return A.copper[e]??A.copper.top}function AOe(e,A,t,i,n){if(Math.abs(n)<1e-10)return null;const o=t-e,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=(e+t)/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 ufA(e,A,t,i,n,o,s){if(Math.abs(o)<1e-10){const[p,m]=Cn(s,[i,n]);e.lineTo(p,m);return}const r=AOe(A,t,i,n,o);if(!r){const[p,m]=Cn(s,[i,n]);e.lineTo(p,m);return}const[a,g]=Cn(s,[A,t]),[c,I]=Cn(s,[i,n]),[l,B]=Cn(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;e.arc(l,B,C,Q,h,d)}function Ogt(e,A,t){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]=Cn(t,[s.x,s.y]);e.moveTo(a,g),ufA(e,s.x,s.y,r.x,r.y,1,t),ufA(e,r.x,r.y,s.x,s.y,1,t);return}}const i=A.vertices[0];if(!i)return;const[n,o]=Cn(t,[i.x,i.y]);e.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]=Cn(t,[g.x,g.y]);e.lineTo(I,l)}else ufA(e,r.x,r.y,g.x,g.y,c,t)}}function tOe(e){const{ctx:A,pour:t,realToCanvasMat:i,colorMap:n}=e,o=$3e(t.layer,n);if(A.save(),t.shape==="rect"){const[s,r]=Cn(i,[t.center.x,t.center.y]),a=t.width*Math.abs(i.a),g=t.height*Math.abs(i.a);A.translate(s,r),t.rotation&&A.rotate(-t.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(t.shape==="polygon"){if(t.points&&t.points.length>=3){const s=t.points.map(c=>Cn(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(t.shape==="brep"){if(A.beginPath(),Ogt(A,t.brep_shape.outer_ring,i),t.brep_shape.inner_rings)for(const s of t.brep_shape.inner_rings)Ogt(A,s,i);A.fillStyle=o,A.globalAlpha=.5,A.fill("evenodd"),A.restore();return}A.restore()}var eOe=.62,iOe=.3,nOe=1,oOe=.13,sOe=1.2;function y9(e,A){const t=A*eOe,i=t*iOe,n=t*nOe,o=Math.max(A*oOe,.35),s=A*sOe,r=e.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:t,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:t,letterSpacing:i,spaceWidth:n,strokeWidth:o,lineHeight:s,lines:r,lineWidths:a}}function dfA(e,A){const t=A.width+A.strokeWidth,i=A.height+A.strokeWidth;let n=0,o=0;return e==="center"||e==="top_center"||e==="bottom_center"?n=-t/2:e==="top_left"||e==="bottom_left"||e==="center_left"?n=0:e==="top_right"||e==="bottom_right"||e==="center_right"?n=-t:(e==="top_center"||e==="bottom_center")&&(n=-t/2),e==="center"||e==="center_left"||e==="center_right"?o=-i/2:e==="top_left"||e==="top_right"||e==="top_center"?o=0:(e==="bottom_left"||e==="bottom_right"||e==="bottom_center")&&(o=-i),{x:n,y:o}}function pfA(e){const{alignment:A,lineWidth:t,maxWidth:i,strokeWidth:n}=e,o=t+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 rOe=e=>uD[e]??uD[e.toUpperCase()];function ffA(e){const{ctx:A,line:t,fontSize:i,startX:n,startY:o,layout:s}=e,{glyphWidth:r,letterSpacing:a,spaceWidth:g,strokeWidth:c}=s,I=i,l=o,B=Array.from(t);let C=n+c/2;B.forEach((Q,h)=>{const E=rOe(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,w=C+d.x2*r,D=l+(1-d.y2)*I;A.moveTo(p,m),A.lineTo(w,D)}A.stroke()}C+=u,h<B.length-1&&(C+=a)})}function aOe(e){const{ctx:A,text:t,fontSize:i,startX:n,startY:o,anchorAlignment:s="center"}=e,r=y9(t,i),{lines:a,lineWidths:g,lineHeight:c,width:I,strokeWidth:l}=r;a.forEach((B,C)=>{const Q=n+pfA({alignment:s,lineWidth:g[C],maxWidth:I,strokeWidth:l}),h=o+C*c;ffA({ctx:A,line:B,fontSize:i,startX:Q,startY:h,layout:r})})}function yfA(e){const{ctx:A,text:t,x:i,y:n,fontSize:o,color:s,realToCanvasMat:r,anchorAlignment:a,rotation:g=0}=e;if(!t)return;const[c,I]=Cn(r,[i,n]),l=Math.abs(r.a),B=o*l,C=y9(t,B),Q=dfA(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,w)=>{const D=Q.x+pfA({alignment:a,lineWidth:E[w],maxWidth:d,strokeWidth:p}),S=Q.y+w*u;ffA({ctx:A,line:m,fontSize:B,startX:D,startY:S,layout:C})}),A.restore()}var gOe={left:.2,right:.2,top:.2,bottom:.2};function cOe(e){return e?e.includes("left")?"center_left":e.includes("right")?"center_right":"center":"center"}function IOe(e){const{ctx:A,text:t,realToCanvasMat:i,colorMap:n}=e,o=t.text??"";if(!o)return;const[s,r]=Cn(i,[t.anchor_position.x,t.anchor_position.y]),a=Math.abs(i.a),g=(t.font_size??1)*a,c=t.ccw_rotation??0,I={...gOe,...t.knockout_padding},l=n.copper[t.layer]??n.copper.top,B=y9(o,g),C=B.width+B.strokeWidth,Q=cOe(t.anchor_alignment),h=dfA(Q,B);if(A.save(),A.translate(s,r),t.is_mirrored&&A.scale(-1,1),c!==0&&A.rotate(-c*(Math.PI/180)),A.lineWidth=B.strokeWidth,A.lineCap="round",A.lineJoin="round",t.is_knockout){const E=I.left*a,u=I.right*a,d=I.top*a,p=I.bottom*a,m=h.x-E*4,w=h.y-d*4,D=C+E*2+u*2,S=B.height+B.strokeWidth+d*2+p*2;A.fillStyle=l,A.fillRect(m,w,D,S)}else A.strokeStyle=l;aOe({ctx:A,text:o,fontSize:g,startX:h.x,startY:h.y,anchorAlignment:Q}),A.restore()}function dw(e){const{ctx:A,center:t,radius:i,fill:n,realToCanvasMat:o,stroke:s,strokeWidth:r,isStrokeDashed:a=!1}=e,[g,c]=Cn(o,[t.x,t.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 lOe(e,A){return e==="bottom"?A.courtyard.bottom:A.courtyard.top}function BOe(e){const{ctx:A,circle:t,realToCanvasMat:i,colorMap:n}=e;dw({ctx:A,center:t.center,radius:t.radius,stroke:lOe(t.layer,n),strokeWidth:.05,realToCanvasMat:i})}function COe(e,A){return e==="bottom"?A.courtyard.bottom:A.courtyard.top}function QOe(e){const{ctx:A,rect:t,realToCanvasMat:i,colorMap:n}=e;bf({ctx:A,center:t.center,width:t.width,height:t.height,stroke:COe(t.layer,n),strokeWidth:.05,realToCanvasMat:i})}function hOe(e){const{ctx:A,cutout:t,realToCanvasMat:i,colorMap:n}=e;if(t.shape==="rect"){bf({ctx:A,center:t.center,width:t.width,height:t.height,fill:n.drill,realToCanvasMat:i,rotation:t.rotation??0,borderRadius:t.corner_radius??0});return}if(t.shape==="circle"){dw({ctx:A,center:t.center,radius:t.radius,fill:n.drill,realToCanvasMat:i});return}if(t.shape==="polygon"){t.points&&t.points.length>=3&&i1({ctx:A,points:t.points,fill:n.drill,realToCanvasMat:i});return}}var EOe=1.5,uOe=.6,dOe=.3;function mfA(e){const A=Math.hypot(e.x,e.y)||1;return{x:e.x/A,y:e.y/A}}function Wgt(e){const{ctx:A,from:t,to:i,realToCanvasMat:n,color:o,fontSize:s,arrowSize:r=1,strokeWidth:a,text:g,textRotation:c,offset:I}=e,l=mfA({x:i.x-t.x,y:i.y-t.y}),B={x:-l.y,y:l.x},C=I?.direction&&typeof I.direction.x=="number"&&typeof I.direction.y=="number",Q=C?mfA(I.direction):{x:0,y:0},h=I?.distance??0,E={x:Q.x*h,y:Q.y*h},u={x:t.x+E.x,y:t.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 w=a??r/5,D=o||"rgba(255,255,255,0.5)",S=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+S.x*k,y:Y.y+S.y*k},O=w/2,Z={x:-S.y,y:S.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*(w/2),y:p.y+B.y*(w/2)}),x.push({x:m.x+B.x*(w/2),y:m.y+B.y*(w/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*(w/2),y:m.y-B.y*(w/2)}),x.push({x:p.x-B.x*(w/2),y:p.y-B.y*(w/2)}),x.push({x:p.x-B.x*(r/2),y:p.y-B.y*(r/2)}),x.push(u);const M=x[0],L=Y=>{const H=N(Y);x.push(M),x.push(H[0]),x.push(...H),x.push(H[0]),x.push(M)};if(L(t),L(i),i1({ctx:A,points:x,fill:D,realToCanvasMat:n}),g){const Y={x:(t.x+i.x)/2+E.x,y:(t.y+i.y)/2+E.y},[H,O]=Cn(n,[u.x,u.y]),[Z,$]=Cn(n,[d.x,d.y]),eA=mfA({x:Z-H,y:$-O});let aA=Math.atan2(eA.y,eA.x)*180/Math.PI;(aA>90||aA<-90)&&(aA+=180);const tA=typeof c=="number"&&Number.isFinite(c)?aA-c:aA;let nA=0;if(g&&typeof c=="number"&&Number.isFinite(c)){const fA=g.length*s*uOe,bA=s,GA=c*Math.PI/180,YA=Math.abs(Math.sin(GA)),QA=Math.abs(Math.cos(GA)),_A=fA/2,dA=bA/2;nA=_A*YA+dA*QA+s*dOe}const rA=r*EOe+nA,lA={x:Y.x+B.x*rA,y:Y.y+B.y*rA};yfA({ctx:A,text:g,x:lA.x,y:lA.y,fontSize:s,color:D,realToCanvasMat:n,anchorAlignment:"center",rotation:-tA})}}function pOe(e){const{ctx:A,pcbFabricationNoteDimension:t,realToCanvasMat:i,colorMap:n}=e,o=t.color??n.fabricationNote;Wgt({ctx:A,from:t.from,to:t.to,realToCanvasMat:i,color:o,fontSize:t.font_size??1,arrowSize:t.arrow_size??1,text:t.text,textRotation:t.text_ccw_rotation,offset:t.offset_distance&&t.offset_direction?{distance:t.offset_distance,direction:t.offset_direction}:void 0})}function n1(e){const{ctx:A,start:t,end:i,strokeWidth:n,stroke:o,realToCanvasMat:s,lineCap:r="round"}=e,[a,g]=Cn(s,[t.x,t.y]),[c,I]=Cn(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 fOe(e){const{ctx:A,path:t,realToCanvasMat:i,colorMap:n}=e,o=n.fabricationNote,s=t.color??o;if(!(!t.route||t.route.length<2))for(let r=0;r<t.route.length-1;r++){const a=t.route[r],g=t.route[r+1];!a||!g||n1({ctx:A,start:{x:a.x,y:a.y},end:{x:g.x,y:g.y},strokeWidth:t.stroke_width??.1,stroke:s,realToCanvasMat:i})}}function yOe(e){const{ctx:A,rect:t,realToCanvasMat:i,colorMap:n}=e,o=n.fabricationNote,s=t.color??o,r=t.is_filled??!1,a=t.has_stroke??!0,g=t.is_stroke_dashed??!1;bf({ctx:A,center:t.center,width:t.width,height:t.height,fill:r?s:void 0,stroke:a?s:void 0,strokeWidth:a?t.stroke_width:void 0,borderRadius:t.corner_radius,realToCanvasMat:i,isStrokeDashed:g})}function mOe(e,A){return A.fabricationNote}function wOe(e){const{ctx:A,text:t,realToCanvasMat:i,colorMap:n}=e,o=mOe(t.layer,n),s=t.color??o,r=t.font_size;yfA({ctx:A,text:t.text,x:t.anchor_position.x,y:t.anchor_position.y,fontSize:r,color:s,realToCanvasMat:i,anchorAlignment:t.anchor_alignment})}function BJ(e){const{ctx:A,center:t,radius_x:i,radius_y:n,fill:o,stroke:s,strokeWidth:r=.1,realToCanvasMat:a,rotation:g=0}=e,[c,I]=Cn(a,[t.x,t.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 TD(e){const{ctx:A,center:t,width:i,height:n,fill:o,realToCanvasMat:s,rotation:r=0,stroke:a,strokeWidth:g}=e,[c,I]=Cn(s,[t.x,t.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 m9(e){return"ccw_rotation"in e&&typeof e.ccw_rotation=="number"?e.ccw_rotation:0}function DOe(e){const{ctx:A,hole:t,realToCanvasMat:i,colorMap:n,soldermaskMargin:o=0,drawSoldermask:s=!1}=e;if(s&&t.is_covered_with_solder_mask===!0)return;const r=o<0?Math.abs(o):0;if(t.hole_shape==="circle"){dw({ctx:A,center:{x:t.x,y:t.y},radius:t.hole_diameter/2-r,fill:n.drill,realToCanvasMat:i});return}if(t.hole_shape==="square"){const a=m9(t);bf({ctx:A,center:{x:t.x,y:t.y},width:t.hole_diameter-r*2,height:t.hole_diameter-r*2,fill:n.drill,realToCanvasMat:i,rotation:a});return}if(t.hole_shape==="oval"){const a=m9(t);BJ({ctx:A,center:{x:t.x,y:t.y},radius_x:t.hole_width/2-r,radius_y:t.hole_height/2-r,fill:n.drill,realToCanvasMat:i,rotation:a});return}if(t.hole_shape==="rect"){const a=m9(t);bf({ctx:A,center:{x:t.x,y:t.y},width:t.hole_width-r*2,height:t.hole_height-r*2,fill:n.drill,realToCanvasMat:i,rotation:a});return}if(t.hole_shape==="pill"||t.hole_shape==="rotated_pill"){const a=m9(t);TD({ctx:A,center:{x:t.x,y:t.y},width:t.hole_width-r*2,height:t.hole_height-r*2,fill:n.drill,realToCanvasMat:i,rotation:a});return}}function SOe(e,A){const t=parseInt(e.slice(1,3),16),i=parseInt(e.slice(3,5),16),n=parseInt(e.slice(5,7),16);return`rgba(${t}, ${i}, ${n}, ${A})`}function bOe(e){const{ctx:A,keepout:t,realToCanvasMat:i,colorMap:n}=e,o=n.keepout,s=SOe(n.keepout,.2),r=1;if(t.shape==="rect"){const[a,g]=Cn(i,[t.center.x,t.center.y]),c=t.width*Math.abs(i.a),I=t.height*Math.abs(i.a),l=t.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(t.shape==="circle"){const[a,g]=Cn(i,[t.center.x,t.center.y]),c=t.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 xOe="rgba(255,255,255,0.5)";function _Oe(e){const{ctx:A,pcbNoteDimension:t,realToCanvasMat:i}=e,n=t.color??xOe;Wgt({ctx:A,from:t.from,to:t.to,realToCanvasMat:i,color:n,fontSize:t.font_size,arrowSize:t.arrow_size,text:t.text,textRotation:t.text_ccw_rotation,offset:t.offset_distance&&t.offset_direction?{distance:t.offset_distance,direction:t.offset_direction}:void 0})}function kOe(e){const{ctx:A,line:t,realToCanvasMat:i}=e,o=t.color??"rgb(89, 148, 220)",s=t.stroke_width??.1,r=t.is_dashed??!1,[a,g]=Cn(i,[t.x1,t.y1]),[c,I]=Cn(i,[t.x2,t.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 FOe(e){const{ctx:A,path:t,realToCanvasMat:i}=e,o=t.color??"rgb(89, 148, 220)";if(!(!t.route||t.route.length<2))for(let s=0;s<t.route.length-1;s++){const r=t.route[s],a=t.route[s+1];!r||!a||n1({ctx:A,start:{x:r.x,y:r.y},end:{x:a.x,y:a.y},strokeWidth:t.stroke_width??.1,stroke:o,realToCanvasMat:i})}}function GOe(e){const{ctx:A,rect:t,realToCanvasMat:i}=e,o=t.color??"rgb(89, 148, 220)",s=t.is_filled??!1,r=t.has_stroke??!0,a=t.is_stroke_dashed??!1;bf({ctx:A,center:t.center,width:t.width,height:t.height,fill:s?o:void 0,stroke:r?o:void 0,strokeWidth:r?t.stroke_width:void 0,borderRadius:t.corner_radius,realToCanvasMat:i,isStrokeDashed:a})}var ROe="rgb(89, 148, 220)";function MOe(e){const{ctx:A,text:t,realToCanvasMat:i}=e,n=ROe,o=t.color??n,s=t.font_size??1;yfA({ctx:A,text:t.text??"",x:t.anchor_position.x,y:t.anchor_position.y,fontSize:s,color:o,realToCanvasMat:i,anchorAlignment:t.anchor_alignment??"center"})}function NOe(e){const{ctx:A,panel:t,realToCanvasMat:i,colorMap:n,drawBoardMaterial:o}=e,{width:s,height:r,center:a}=t;if(s!==void 0&&r!==void 0&&a){o&&bf({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}];f9({ctx:A,points:I,stroke:n.boardOutline,strokeWidth:.5,realToCanvasMat:i,closePath:!0})}}function CJ(e,A){if(e.length<3||A===0)return e;let t=0,i=0;for(const o of e)t+=o.x,i+=o.y;t/=e.length,i/=e.length;const n=[];for(const o of e){const s=o.x-t,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 vOe(e){const{ctx:A,hole:t,realToCanvasMat:i,colorMap:n,soldermaskMargin:o=0,drawSoldermask:s}=e;if(t.is_covered_with_solder_mask===!0&&s)return;const r=n.copper.top,a=o<0?Math.abs(o):0;if(t.shape==="circle"){dw({ctx:A,center:{x:t.x,y:t.y},radius:t.outer_diameter/2-a,fill:r,realToCanvasMat:i}),dw({ctx:A,center:{x:t.x,y:t.y},radius:t.hole_diameter/2,fill:n.drill,realToCanvasMat:i});return}if(t.shape==="oval"){BJ({ctx:A,center:{x:t.x,y:t.y},radius_x:t.outer_width/2-a,radius_y:t.outer_height/2-a,fill:r,realToCanvasMat:i,rotation:t.ccw_rotation}),BJ({ctx:A,center:{x:t.x,y:t.y},radius_x:t.hole_width/2,radius_y:t.hole_height/2,fill:n.drill,realToCanvasMat:i,rotation:t.ccw_rotation});return}if(t.shape==="pill"){TD({ctx:A,center:{x:t.x,y:t.y},width:t.outer_width-a*2,height:t.outer_height-a*2,fill:r,realToCanvasMat:i,rotation:t.ccw_rotation}),TD({ctx:A,center:{x:t.x,y:t.y},width:t.hole_width,height:t.hole_height,fill:n.drill,realToCanvasMat:i,rotation:t.ccw_rotation});return}if(t.shape==="circular_hole_with_rect_pad"){bf({ctx:A,center:{x:t.x,y:t.y},width:t.rect_pad_width-a*2,height:t.rect_pad_height-a*2,fill:r,realToCanvasMat:i,borderRadius:t.rect_border_radius?Math.max(0,t.rect_border_radius-a):0});const g=t.x+(t.hole_offset_x??0),c=t.y+(t.hole_offset_y??0);dw({ctx:A,center:{x:g,y:c},radius:t.hole_diameter/2,fill:n.drill,realToCanvasMat:i});return}if(t.shape==="pill_hole_with_rect_pad"){bf({ctx:A,center:{x:t.x,y:t.y},width:t.rect_pad_width-a*2,height:t.rect_pad_height-a*2,fill:r,realToCanvasMat:i,borderRadius:t.rect_border_radius?Math.max(0,t.rect_border_radius-a):0});const g=t.x+(t.hole_offset_x??0),c=t.y+(t.hole_offset_y??0);TD({ctx:A,center:{x:g,y:c},width:t.hole_width,height:t.hole_height,fill:n.drill,realToCanvasMat:i});return}if(t.shape==="rotated_pill_hole_with_rect_pad"){bf({ctx:A,center:{x:t.x,y:t.y},width:t.rect_pad_width-a*2,height:t.rect_pad_height-a*2,fill:r,realToCanvasMat:i,borderRadius:t.rect_border_radius?Math.max(0,t.rect_border_radius-a):0,rotation:t.rect_ccw_rotation});const g=t.x+(t.hole_offset_x??0),c=t.y+(t.hole_offset_y??0);TD({ctx:A,center:{x:g,y:c},width:t.hole_width,height:t.hole_height,fill:n.drill,realToCanvasMat:i,rotation:t.hole_ccw_rotation});return}if(t.shape==="hole_with_polygon_pad"){const g=t.pad_outline;if(g&&g.length>=3){const B=g.map(Q=>({x:t.x+Q.x,y:t.y+Q.y})),C=a>0?CJ(B,-a):B;C.length>=3&&i1({ctx:A,points:C,fill:r,realToCanvasMat:i})}const c=t.x+(t.hole_offset_x??0),I=t.y+(t.hole_offset_y??0),l=t.hole_shape;l==="circle"?dw({ctx:A,center:{x:c,y:I},radius:(t.hole_diameter??0)/2,fill:n.drill,realToCanvasMat:i}):l==="oval"?BJ({ctx:A,center:{x:c,y:I},radius_x:(t.hole_width??0)/2,radius_y:(t.hole_height??0)/2,fill:n.drill,realToCanvasMat:i}):l==="pill"?TD({ctx:A,center:{x:c,y:I},width:t.hole_width??0,height:t.hole_height??0,fill:n.drill,realToCanvasMat:i}):l==="rotated_pill"&&TD({ctx:A,center:{x:c,y:I},width:t.hole_width??0,height:t.hole_height??0,fill:n.drill,realToCanvasMat:i});return}}function LOe(e,A){return e==="bottom"?A.silkscreen.bottom:A.silkscreen.top}function UOe(e){const{ctx:A,circle:t,realToCanvasMat:i,colorMap:n}=e,o=LOe(t.layer,n);dw({ctx:A,center:t.center,radius:t.radius,stroke:o,strokeWidth:t.stroke_width,realToCanvasMat:i})}function HOe(e,A){return e==="bottom"?A.silkscreen.bottom:A.silkscreen.top}function YOe(e){const{ctx:A,line:t,realToCanvasMat:i,colorMap:n}=e,o=HOe(t.layer,n);n1({ctx:A,start:{x:t.x1,y:t.y1},end:{x:t.x2,y:t.y2},strokeWidth:t.stroke_width??.1,stroke:o,realToCanvasMat:i})}function JOe(e,A){return e==="bottom"?A.silkscreen.bottom:A.silkscreen.top}function TOe(e){const{ctx:A,oval:t,realToCanvasMat:i,colorMap:n}=e,o=JOe(t.layer,n);BJ({ctx:A,center:t.center,radius_x:t.radius_x,radius_y:t.radius_y,stroke:o,strokeWidth:.1,realToCanvasMat:i,rotation:t.ccw_rotation??0})}function KOe(e,A){return e==="bottom"?A.silkscreen.bottom:A.silkscreen.top}function POe(e){const{ctx:A,path:t,realToCanvasMat:i,colorMap:n}=e,o=KOe(t.layer,n);if(!(!t.route||t.route.length<2))for(let s=0;s<t.route.length-1;s++){const r=t.route[s],a=t.route[s+1];!r||!a||n1({ctx:A,start:{x:r.x,y:r.y},end:{x:a.x,y:a.y},strokeWidth:t.stroke_width??.1,stroke:o,realToCanvasMat:i})}}function qOe(e,A){return e==="bottom"?A.silkscreen.bottom:A.silkscreen.top}function OOe(e){const{ctx:A,pill:t,realToCanvasMat:i,colorMap:n}=e,o=qOe(t.layer,n);TD({ctx:A,center:t.center,width:t.width,height:t.height,stroke:o,strokeWidth:.2,realToCanvasMat:i})}function WOe(e,A){return e==="bottom"?A.silkscreen.bottom:A.silkscreen.top}function ZOe(e){const{ctx:A,rect:t,realToCanvasMat:i,colorMap:n}=e,o=WOe(t.layer,n);bf({ctx:A,center:t.center,width:t.width,height:t.height,fill:t.is_filled?o:"transparent",stroke:o,strokeWidth:t.stroke_width,realToCanvasMat:i})}function VOe(e,A){return e==="bottom"?A.silkscreen.bottom:A.silkscreen.top}function jOe(e){return e||"center"}function zOe(e){const{ctx:A,text:t,realToCanvasMat:i,colorMap:n}=e,o=t.text??"";if(!o)return;const s=VOe(t.layer,n),[r,a]=Cn(i,[t.anchor_position.x,t.anchor_position.y]),g=Math.abs(i.a),c=(t.font_size??1)*g,I=t.ccw_rotation??0,l=y9(o,c),B=jOe(t.anchor_alignment),C=dfA(B,l);A.save(),A.translate(r,a),I!==0&&A.rotate(-I*(Math.PI/180)),t.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 w=C.x+pfA({alignment:B,lineWidth:h[m],maxWidth:u,strokeWidth:d}),D=C.y+m*E;ffA({ctx:A,line:p,fontSize:c,startX:w,startY:D,layout:l})}),A.restore()}function XOe(e,A){return A.copper[e]??A.copper.top}function Zgt(e){return e.shape==="rect"||e.shape==="rotated_rect"?e.corner_radius??e.rect_border_radius??0:0}function $Oe(e){const{ctx:A,pad:t,realToCanvasMat:i,colorMap:n}=e,o=XOe(t.layer,n);if(t.shape==="rect"){bf({ctx:A,center:{x:t.x,y:t.y},width:t.width,height:t.height,fill:o,realToCanvasMat:i,borderRadius:Zgt(t)});return}if(t.shape==="rotated_rect"){bf({ctx:A,center:{x:t.x,y:t.y},width:t.width,height:t.height,fill:o,realToCanvasMat:i,borderRadius:Zgt(t),rotation:t.ccw_rotation??0});return}if(t.shape==="circle"){dw({ctx:A,center:{x:t.x,y:t.y},radius:t.radius,fill:o,realToCanvasMat:i});return}if(t.shape==="pill"){TD({ctx:A,center:{x:t.x,y:t.y},width:t.width,height:t.height,fill:o,realToCanvasMat:i});return}if(t.shape==="rotated_pill"){TD({ctx:A,center:{x:t.x,y:t.y},width:t.width,height:t.height,fill:o,realToCanvasMat:i,rotation:t.ccw_rotation??0});return}if(t.shape==="polygon"){t.points&&t.points.length>=3&&i1({ctx:A,points:t.points,fill:o,realToCanvasMat:i});return}}function $_(e){const{ctx:A,points:t}=e;if(t.length<3)return;const i=t[0];if(i){A.moveTo(i.x,i.y);for(let n=1;n<t.length;n++){const o=t[n];o&&A.lineTo(o.x,o.y)}A.closePath()}}function A5e(e){const{ctx:A,board:t,realToCanvasMat:i,soldermaskColor:n}=e,{width:o,height:s,center:r,outline:a}=t;if(a&&Array.isArray(a)&&a.length>=3){const g=a.map(c=>{const[I,l]=Cn(i,[c.x,c.y]);return{x:I,y:l}});A.beginPath(),$_({ctx:A,points:g}),A.fillStyle=n,A.fill()}else if(o!==void 0&&s!==void 0&&r){const[g,c]=Cn(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 Ak(e){const{ctx:A,cx:t,cy:i,width:n,height:o,radius:s}=e,r=t-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 t5e(e){const{ctx:A,cutout:t,realToCanvasMat:i,colorMap:n}=e;if(A.fillStyle=n.drill,t.shape==="rect"){const[o,s]=Cn(i,[t.center?.x??0,t.center?.y??0]),r=t.width*Math.abs(i.a),a=t.height*Math.abs(i.a),g=(t.corner_radius??0)*Math.abs(i.a);A.save(),A.translate(o,s),t.rotation&&A.rotate(-t.rotation*Math.PI/180),A.beginPath(),Ak({ctx:A,cx:0,cy:0,width:r,height:a,radius:g}),A.restore(),A.fill()}else if(t.shape==="circle"){const[o,s]=Cn(i,[t.center?.x??0,t.center?.y??0]),r=t.radius*Math.abs(i.a);A.beginPath(),A.arc(o,s,r,0,Math.PI*2),A.closePath(),A.fill()}else if(t.shape==="polygon"&&t.points&&t.points.length>=3){const o=t.points.map(s=>{const[r,a]=Cn(i,[s.x,s.y]);return{x:r,y:a}});A.beginPath(),$_({ctx:A,points:o}),A.fill()}}function Fb(e){const{ctx:A,cx:t,cy:i,width:n,height:o}=e;if(n>o){const s=o/2,r=n-o;A.moveTo(t-r/2,i-s),A.lineTo(t+r/2,i-s),A.arc(t+r/2,i,s,-Math.PI/2,Math.PI/2),A.lineTo(t-r/2,i+s),A.arc(t-r/2,i,s,Math.PI/2,-Math.PI/2)}else if(o>n){const s=n/2,r=o-n;A.moveTo(t+s,i-r/2),A.lineTo(t+s,i+r/2),A.arc(t,i+r/2,s,0,Math.PI),A.lineTo(t-s,i-r/2),A.arc(t,i-r/2,s,Math.PI,0)}else A.arc(t,i,n/2,0,Math.PI*2);A.closePath()}function e5e(e){const{ctx:A,hole:t,realToCanvasMat:i,colorMap:n,soldermaskOverCopperColor:o,drawSoldermask:s}=e,r=s&&t.is_covered_with_solder_mask===!0,a=s?t.soldermask_margin??0:0;r?(A.fillStyle=o,QJ({ctx:A,hole:t,realToCanvasMat:i,margin:0}),A.fill()):a<0?(A.fillStyle=n.drill,QJ({ctx:A,hole:t,realToCanvasMat:i,margin:0}),A.fill(),i5e({ctx:A,hole:t,realToCanvasMat:i,soldermaskOverCopperColor:o,margin:a})):a>0?(A.fillStyle=n.substrate,QJ({ctx:A,hole:t,realToCanvasMat:i,margin:a}),A.fill(),A.fillStyle=n.drill,QJ({ctx:A,hole:t,realToCanvasMat:i,margin:0}),A.fill()):(A.fillStyle=n.drill,QJ({ctx:A,hole:t,realToCanvasMat:i,margin:0}),A.fill())}function Vgt(e){return"ccw_rotation"in e&&typeof e.ccw_rotation=="number"?e.ccw_rotation:0}function QJ(e){const{ctx:A,hole:t,realToCanvasMat:i,margin:n}=e,o=Vgt(t);if(t.hole_shape==="circle"){const[s,r]=Cn(i,[t.x,t.y]),a=(t.hole_diameter/2+n)*Math.abs(i.a);A.beginPath(),A.arc(s,r,a,0,Math.PI*2),A.closePath()}else if(t.hole_shape==="square"){const[s,r]=Cn(i,[t.x,t.y]),a=(t.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(t.hole_shape==="oval"){const[s,r]=Cn(i,[t.x,t.y]),a=(t.hole_width/2+n)*Math.abs(i.a),g=(t.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(t.hole_shape==="rect"){const[s,r]=Cn(i,[t.x,t.y]),a=(t.hole_width+n*2)*Math.abs(i.a),g=(t.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(t.hole_shape==="pill"||t.hole_shape==="rotated_pill"){const[s,r]=Cn(i,[t.x,t.y]),a=(t.hole_width+n*2)*Math.abs(i.a),g=(t.hole_height+n*2)*Math.abs(i.a);A.save(),A.translate(s,r),o!==0&&A.rotate(-o*Math.PI/180),A.beginPath(),Fb({ctx:A,cx:0,cy:0,width:a,height:g}),A.restore()}}function i5e(e){const{ctx:A,hole:t,realToCanvasMat:i,soldermaskOverCopperColor:n,margin:o}=e,s=Math.abs(o),r=Vgt(t);if(A.fillStyle=n,t.hole_shape==="circle"){const[a,g]=Cn(i,[t.x,t.y]),c=t.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(t.hole_shape==="square"){const[a,g]=Cn(i,[t.x,t.y]),c=t.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(t.hole_shape==="oval"){const[a,g]=Cn(i,[t.x,t.y]),c=t.hole_width/2*Math.abs(i.a),I=t.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(t.hole_shape==="rect"){const[a,g]=Cn(i,[t.x,t.y]),c=t.hole_width*Math.abs(i.a),I=t.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(t.hole_shape==="pill"||t.hole_shape==="rotated_pill"){const[a,g]=Cn(i,[t.x,t.y]),c=t.hole_width*Math.abs(i.a),I=t.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(),Fb({ctx:A,cx:0,cy:0,width:c,height:I});const B=c-l*2,C=I-l*2;B>0&&C>0&&Fb({ctx:A,cx:0,cy:0,width:B,height:C}),A.fill("evenodd"),A.restore()}}function n5e(e){const{ctx:A,hole:t,realToCanvasMat:i,colorMap:n,soldermaskOverCopperColor:o,layer:s,drawSoldermask:r}=e;if(t.layers&&!t.layers.includes(s))return;const a=r&&t.is_covered_with_solder_mask===!0,g=r?t.soldermask_margin??0:0,c=n.copper.top;a?(A.fillStyle=o,hJ({ctx:A,hole:t,realToCanvasMat:i,margin:0}),A.fill()):g<0?(A.fillStyle=c,hJ({ctx:A,hole:t,realToCanvasMat:i,margin:0}),A.fill(),o5e({ctx:A,hole:t,realToCanvasMat:i,soldermaskOverCopperColor:o,margin:g})):g>0?(A.fillStyle=n.substrate,hJ({ctx:A,hole:t,realToCanvasMat:i,margin:g}),A.fill(),A.fillStyle=c,hJ({ctx:A,hole:t,realToCanvasMat:i,margin:0}),A.fill()):(A.fillStyle=c,hJ({ctx:A,hole:t,realToCanvasMat:i,margin:0}),A.fill())}function hJ(e){const{ctx:A,hole:t,realToCanvasMat:i,margin:n}=e;if(t.shape==="circle"){const[o,s]=Cn(i,[t.x,t.y]),r=(t.outer_diameter/2+n)*Math.abs(i.a);A.beginPath(),A.arc(o,s,r,0,Math.PI*2),A.closePath()}else if(t.shape==="oval"){const[o,s]=Cn(i,[t.x,t.y]),r=(t.outer_width/2+n)*Math.abs(i.a),a=(t.outer_height/2+n)*Math.abs(i.a);A.save(),A.translate(o,s),t.ccw_rotation&&t.ccw_rotation!==0&&A.rotate(-(t.ccw_rotation*Math.PI)/180),A.beginPath(),A.ellipse(0,0,r,a,0,0,Math.PI*2),A.closePath(),A.restore()}else if(t.shape==="pill"){const[o,s]=Cn(i,[t.x,t.y]),r=(t.outer_width+n*2)*Math.abs(i.a),a=(t.outer_height+n*2)*Math.abs(i.a);A.save(),A.translate(o,s),t.ccw_rotation&&t.ccw_rotation!==0&&A.rotate(-(t.ccw_rotation*Math.PI)/180),A.beginPath(),Fb({ctx:A,cx:0,cy:0,width:r,height:a}),A.restore()}else if(t.shape==="circular_hole_with_rect_pad"||t.shape==="pill_hole_with_rect_pad"){const[o,s]=Cn(i,[t.x,t.y]),r=(t.rect_pad_width+n*2)*Math.abs(i.a),a=(t.rect_pad_height+n*2)*Math.abs(i.a),g=(t.rect_border_radius??0)*Math.abs(i.a);A.beginPath(),Ak({ctx:A,cx:o,cy:s,width:r,height:a,radius:g})}else if(t.shape==="rotated_pill_hole_with_rect_pad"){const[o,s]=Cn(i,[t.x,t.y]),r=(t.rect_pad_width+n*2)*Math.abs(i.a),a=(t.rect_pad_height+n*2)*Math.abs(i.a),g=(t.rect_border_radius??0)*Math.abs(i.a);A.save(),A.translate(o,s),t.rect_ccw_rotation&&A.rotate(-t.rect_ccw_rotation*Math.PI/180),A.beginPath(),Ak({ctx:A,cx:0,cy:0,width:r,height:a,radius:g}),A.restore()}else if(t.shape==="hole_with_polygon_pad"&&t.pad_outline&&t.pad_outline.length>=3){const o=t.pad_outline.map(a=>({x:t.x+a.x,y:t.y+a.y})),r=(n!==0?CJ(o,n):o).map(a=>{const[g,c]=Cn(i,[a.x,a.y]);return{x:g,y:c}});A.beginPath(),$_({ctx:A,points:r})}}function o5e(e){const{ctx:A,hole:t,realToCanvasMat:i,soldermaskOverCopperColor:n,margin:o}=e,s=Math.abs(o);if(A.fillStyle=n,t.shape==="circle"){const[r,a]=Cn(i,[t.x,t.y]),g=t.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(t.shape==="oval"){const[r,a]=Cn(i,[t.x,t.y]),g=t.outer_width/2*Math.abs(i.a),c=t.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),t.ccw_rotation&&t.ccw_rotation!==0&&A.rotate(-(t.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(t.shape==="pill"){const[r,a]=Cn(i,[t.x,t.y]),g=t.outer_width*Math.abs(i.a),c=t.outer_height*Math.abs(i.a),I=s*Math.abs(i.a);A.save(),A.translate(r,a),t.ccw_rotation&&t.ccw_rotation!==0&&A.rotate(-(t.ccw_rotation*Math.PI)/180),A.beginPath(),Fb({ctx:A,cx:0,cy:0,width:g,height:c});const l=g-I*2,B=c-I*2;l>0&&B>0&&Fb({ctx:A,cx:0,cy:0,width:l,height:B}),A.fill("evenodd"),A.restore()}else if(t.shape==="circular_hole_with_rect_pad"||t.shape==="pill_hole_with_rect_pad"||t.shape==="rotated_pill_hole_with_rect_pad"){const[r,a]=Cn(i,[t.x,t.y]),g=t.rect_pad_width*Math.abs(i.a),c=t.rect_pad_height*Math.abs(i.a),I=s*Math.abs(i.a);A.save(),A.translate(r,a),t.shape==="rotated_pill_hole_with_rect_pad"&&t.rect_ccw_rotation&&A.rotate(-t.rect_ccw_rotation*Math.PI/180);const l=t.rect_border_radius?t.rect_border_radius*Math.abs(i.a):0;A.beginPath(),Ak({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);Ak({ctx:A,cx:0,cy:0,width:B,height:C,radius:Q})}A.fill("evenodd"),A.restore()}else if(t.shape==="hole_with_polygon_pad"&&t.pad_outline&&t.pad_outline.length>=3){const r=t.pad_outline.map(c=>({x:t.x+c.x,y:t.y+c.y}));A.save(),A.beginPath();const a=r.map(c=>{const[I,l]=Cn(i,[c.x,c.y]);return{x:I,y:l}});$_({ctx:A,points:a});const g=CJ(r,-s);if(g.length>=3){const c=g.map(I=>{const[l,B]=Cn(i,[I.x,I.y]);return{x:l,y:B}});$_({ctx:A,points:c})}A.fill("evenodd"),A.restore()}}function s5e(e){const{ctx:A,pad:t,realToCanvasMat:i,colorMap:n,soldermaskOverCopperColor:o,layer:s,drawSoldermask:r}=e;if(t.layer!==s)return;const a=r&&t.is_covered_with_solder_mask===!0,g=r?t.soldermask_margin??0:0;let c=g,I=g,l=g,B=g;(t.shape==="rect"||t.shape==="rotated_rect")&&(c=t.soldermask_margin_left??g,I=t.soldermask_margin_right??g,l=t.soldermask_margin_top??g,B=t.soldermask_margin_bottom??g);const C=n.copper[t.layer]||n.copper.top;a?(A.fillStyle=o,EJ({ctx:A,pad:t,realToCanvasMat:i,ml:0,mr:0,mt:0,mb:0}),A.fill()):c<0||I<0||l<0||B<0?(A.fillStyle=C,EJ({ctx:A,pad:t,realToCanvasMat:i,ml:0,mr:0,mt:0,mb:0}),A.fill(),r5e({ctx:A,pad:t,realToCanvasMat:i,soldermaskOverCopperColor:o,ml:c,mr:I,mt:l,mb:B})):c>0||I>0||l>0||B>0?(A.fillStyle=n.substrate,EJ({ctx:A,pad:t,realToCanvasMat:i,ml:c,mr:I,mt:l,mb:B}),A.fill(),A.fillStyle=C,EJ({ctx:A,pad:t,realToCanvasMat:i,ml:0,mr:0,mt:0,mb:0}),A.fill()):(A.fillStyle=C,EJ({ctx:A,pad:t,realToCanvasMat:i,ml:0,mr:0,mt:0,mb:0}),A.fill())}function EJ(e){const{ctx:A,pad:t,realToCanvasMat:i,ml:n,mr:o,mt:s,mb:r}=e,a=t.shape==="rotated_rect"||t.shape==="rotated_pill"?t.ccw_rotation??0:0;if(t.shape==="rect"||t.shape==="rotated_rect"){const g=t.corner_radius??t.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]=Cn(i,[t.x+B,t.y+C]),E=(t.width+n+o)*Math.abs(i.a),u=(t.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(),Ak({ctx:A,cx:0,cy:0,width:E,height:u,radius:d}),A.restore()}else if(t.shape==="circle"){const g=(n+o+s+r)/4,[c,I]=Cn(i,[t.x,t.y]),l=(t.radius+g)*Math.abs(i.a);A.beginPath(),A.arc(c,I,l,0,Math.PI*2),A.closePath()}else if(t.shape==="pill"||t.shape==="rotated_pill"){const g=(n+o)/2,[c,I]=Cn(i,[t.x,t.y]),l=(t.width+g*2)*Math.abs(i.a),B=(t.height+g*2)*Math.abs(i.a);A.save(),A.translate(c,I),a!==0&&A.rotate(-a*Math.PI/180),A.beginPath(),Fb({ctx:A,cx:0,cy:0,width:l,height:B}),A.restore()}else if(t.shape==="polygon"&&t.points&&t.points.length>=3){const g=(n+o+s+r)/4,I=(g!==0?CJ(t.points,g):t.points).map(l=>{const[B,C]=Cn(i,[l.x,l.y]);return{x:B,y:C}});A.beginPath(),$_({ctx:A,points:I})}}function r5e(e){const{ctx:A,pad:t,realToCanvasMat:i,soldermaskOverCopperColor:n,ml:o,mr:s,mt:r,mb:a}=e,g=t.shape==="rotated_rect"||t.shape==="rotated_pill"?t.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,t.shape==="rect"||t.shape==="rotated_rect"){const C=t.corner_radius??t.rect_border_radius??0,[Q,h]=Cn(i,[t.x,t.y]),E=t.width*Math.abs(i.a),u=t.height*Math.abs(i.a),d=C*Math.abs(i.a),p=c*Math.abs(i.a),m=I*Math.abs(i.a),w=l*Math.abs(i.a),D=B*Math.abs(i.a);A.save(),A.translate(Q,h),g!==0&&A.rotate(-g*Math.PI/180),A.beginPath(),Ak({ctx:A,cx:0,cy:0,width:E,height:u,radius:d});const S=E-p-m,k=u-w-D,x=(p-m)/2,N=(w-D)/2,M=Math.max(0,d-(p+m+w+D)/4);S>0&&k>0&&Ak({ctx:A,cx:x,cy:N,width:S,height:k,radius:M}),A.fill("evenodd"),A.restore()}else if(t.shape==="circle"){const C=Math.max(c,I,l,B),[Q,h]=Cn(i,[t.x,t.y]),E=t.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(t.shape==="pill"||t.shape==="rotated_pill"){const C=Math.max(c,I,l,B),[Q,h]=Cn(i,[t.x,t.y]),E=t.width*Math.abs(i.a),u=t.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(),Fb({ctx:A,cx:0,cy:0,width:E,height:u});const p=E-d*2,m=u-d*2;p>0&&m>0&&Fb({ctx:A,cx:0,cy:0,width:p,height:m}),A.fill("evenodd"),A.restore()}else if(t.shape==="polygon"&&t.points&&t.points.length>=3){const C=Math.max(c,I,l,B);A.save(),A.beginPath();const Q=t.points.map(E=>{const[u,d]=Cn(i,[E.x,E.y]);return{x:u,y:d}});$_({ctx:A,points:Q});const h=CJ(t.points,-C);if(h.length>=3){const E=h.map(u=>{const[d,p]=Cn(i,[u.x,u.y]);return{x:d,y:p}});$_({ctx:A,points:E})}A.fill("evenodd"),A.restore()}}function o1(e,A){const t=Math.hypot(e,A);return t<=Number.EPSILON?{x:0,y:0}:{x:e/t,y:A/t}}function a5e(e,A){const t=e.length;if(t<2)return{x:1,y:0};if(A<=0){const g=e[1],c=e[0];if(!g||!c)return{x:1,y:0};const I=o1(g.x-c.x,g.y-c.y);return I.x===0&&I.y===0?{x:1,y:0}:I}if(A>=t-1){const g=e[t-2],c=e[t-1];if(!g||!c)return{x:1,y:0};const I=o1(c.x-g.x,c.y-g.y);return I.x===0&&I.y===0?{x:1,y:0}:I}const i=e[A-1],n=e[A],o=e[A+1];if(!i||!n||!o)return{x:1,y:0};const s=o1(n.x-i.x,n.y-i.y),r=o1(o.x-n.x,o.y-n.y),a=o1(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 jgt(e){const A=[],t=[];for(let i=0;i<e.length;i++){const n=e[i];if(!n)continue;const o=a5e(e,i),s=o1(-o.y,o.x),r=n.width/2;A.push({x:n.x+s.x*r,y:n.y+s.y*r}),t.push({x:n.x-s.x*r,y:n.y-s.y*r})}return A.concat(t.reverse())}function zgt(e){const A=[];let t=[],i=null;for(const n of e??[]){if(!n||n.route_type!=="wire"){t.length>=2&&A.push(t),t=[],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&&(t.length>=2&&A.push(t),t=[]),i=o,t.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 t.length>=2&&A.push(t),A}function Xgt(e){if(e.length<2)return!1;const A=e[0]?.width;return typeof A!="number"?!1:e.some(t=>Math.abs(t.width-A)>Number.EPSILON)}function g5e(e){const{ctx:A,trace:t,realToCanvasMat:i,soldermaskOverCopperColor:n,layer:o,drawSoldermask:s}=e;if(!s||!t.route||!Array.isArray(t.route)||t.route.length<2)return;const r=zgt(t.route);for(const a of r)if(a[0]?.layer===o){if(Xgt(a)){const c=jgt(a);i1({ctx:A,points:c,fill:n,realToCanvasMat:i});continue}for(let c=0;c<a.length-1;c++){const I=a[c],l=a[c+1];!I||!l||n1({ctx:A,start:{x:I.x,y:I.y},end:{x:l.x,y:l.y},strokeWidth:I.width,stroke:n,realToCanvasMat:i,lineCap:"round"})}}}function c5e(e){const{ctx:A,via:t,realToCanvasMat:i,colorMap:n}=e,[o,s]=Cn(i,[t.x,t.y]),r=t.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 I5e(e){const{ctx:A,board:t,elements:i,realToCanvasMat:n,colorMap:o,layer:s,drawSoldermask:r}=e,a=o.soldermask[s]??o.soldermask.top,g=o.soldermaskOverCopper[s]??o.soldermaskOverCopper.top;if(r&&A5e({ctx:A,board:t,realToCanvasMat:n,soldermaskColor:a}),r)for(const c of i)c.type==="pcb_trace"&&g5e({ctx:A,trace:c,realToCanvasMat:n,soldermaskOverCopperColor:g,layer:s,drawSoldermask:r});for(const c of i)l5e({ctx:A,element:c,realToCanvasMat:n,colorMap:o,soldermaskOverCopperColor:g,layer:s,drawSoldermask:r})}function l5e(e){const{ctx:A,element:t,realToCanvasMat:i,colorMap:n,soldermaskOverCopperColor:o,layer:s,drawSoldermask:r}=e;if(t.type==="pcb_smtpad")s5e({ctx:A,pad:t,realToCanvasMat:i,colorMap:n,soldermaskOverCopperColor:o,layer:s,drawSoldermask:r});else if(t.type==="pcb_plated_hole")n5e({ctx:A,hole:t,realToCanvasMat:i,colorMap:n,soldermaskOverCopperColor:o,layer:s,drawSoldermask:r});else if(t.type==="pcb_hole")e5e({ctx:A,hole:t,realToCanvasMat:i,colorMap:n,soldermaskOverCopperColor:o,drawSoldermask:r});else if(t.type==="pcb_via")c5e({ctx:A,via:t,realToCanvasMat:i,colorMap:n});else if(t.type==="pcb_cutout")t5e({ctx:A,cutout:t,realToCanvasMat:i,colorMap:n});else if(t.type==="pcb_trace")return}function B5e(e,A){return A.copper[e]??A.copper.top}function C5e(e){const{ctx:A,trace:t,realToCanvasMat:i,colorMap:n}=e;if(!t.route||!Array.isArray(t.route)||t.route.length<2)return;const o=zgt(t.route);for(const s of o){const r=s[0]?.layer;if(!r)continue;const a=B5e(r,n);if(Xgt(s)){const g=jgt(s);i1({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||n1({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 Q5e(e){const{ctx:A,via:t,realToCanvasMat:i,colorMap:n}=e;dw({ctx:A,center:{x:t.x,y:t.y},radius:t.outer_diameter/2,fill:n.copper.top,realToCanvasMat:i}),dw({ctx:A,center:{x:t.x,y:t.y},radius:t.hole_diameter/2,fill:n.drill,realToCanvasMat:i})}function FG(e,A){if(!A.layers||A.layers.length===0)return!0;const t=m1A(e);return t.length===0?!0:t.some(i=>A.layers.includes(i))}var Vd={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:{top:"#FF00FF",bottom:"rgb(38, 233, 255)"},keepout:"#FF6B6B",fabricationNote:"rgba(255, 255, 255, 0.5)"},KC=class{ctx;colorMap;realToCanvasMat;constructor(e){if("getContext"in e&&typeof e.getContext=="function"){const A=e.getContext("2d");if(!A)throw new Error("Failed to get 2D rendering context from canvas");this.ctx=A}else this.ctx=e;this.colorMap={...Vd},this.realToCanvasMat=V3e()}configure(e){e.colorOverrides&&(this.colorMap={...this.colorMap,...e.colorOverrides,copper:{...this.colorMap.copper,...e.colorOverrides.copper},silkscreen:{...this.colorMap.silkscreen,...e.colorOverrides.silkscreen},soldermask:{...this.colorMap.soldermask,...e.colorOverrides.soldermask},soldermaskWithCopperUnderneath:{...this.colorMap.soldermaskWithCopperUnderneath,...e.colorOverrides.soldermaskWithCopperUnderneath},soldermaskOverCopper:{...this.colorMap.soldermaskOverCopper,...e.colorOverrides.soldermaskOverCopper}})}setCameraBounds(e){const A=this.ctx.canvas,t=A.width,i=A.height,n=e.maxX-e.minX,o=e.maxY-e.minY,s=t/n,r=i/o,a=Math.min(s,r),g=(t-n*a)/2,c=(i-o*a)/2;this.realToCanvasMat=j3e(p9(g,c),z3e(a,-a),p9(-e.minX,-e.maxY))}drawElements(e,A={}){const t=e.find(o=>o.type==="pcb_board"),i=e.find(o=>o.type==="pcb_panel");i&&NOe({ctx:this.ctx,panel:i,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap,drawBoardMaterial:A.drawBoardMaterial??!1}),t&&X3e({ctx:this.ctx,board:t,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap,drawBoardMaterial:A.drawBoardMaterial??!1});for(const o of e)FG(o,A)&&(o.type==="pcb_smtpad"&&$Oe({ctx:this.ctx,pad:o,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}),o.type==="pcb_copper_text"&&IOe({ctx:this.ctx,text:o,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}));const n=A.drawSoldermask??!1;t&&I5e({ctx:this.ctx,board:t,elements:e,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap,layer:"top",drawSoldermask:n});for(const o of e)FG(o,A)&&(o.type==="pcb_silkscreen_text"&&zOe({ctx:this.ctx,text:o,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}),o.type==="pcb_silkscreen_rect"&&ZOe({ctx:this.ctx,rect:o,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}),o.type==="pcb_silkscreen_circle"&&UOe({ctx:this.ctx,circle:o,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}),o.type==="pcb_silkscreen_line"&&YOe({ctx:this.ctx,line:o,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}),o.type==="pcb_silkscreen_path"&&POe({ctx:this.ctx,path:o,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}),o.type==="pcb_silkscreen_pill"&&OOe({ctx:this.ctx,pill:o,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}),o.type==="pcb_silkscreen_oval"&&TOe({ctx:this.ctx,oval:o,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}));for(const o of e)FG(o,A)&&(o.type==="pcb_copper_pour"&&tOe({ctx:this.ctx,pour:o,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}),o.type==="pcb_trace"&&(!n||!t)&&C5e({ctx:this.ctx,trace:o,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}));for(const o of e)FG(o,A)&&o.type==="pcb_hole"&&DOe({ctx:this.ctx,hole:o,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap,soldermaskMargin:n?o.soldermask_margin:void 0,drawSoldermask:n});for(const o of e)FG(o,A)&&(o.type==="pcb_plated_hole"&&vOe({ctx:this.ctx,hole:o,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap,soldermaskMargin:n?o.soldermask_margin:void 0,drawSoldermask:n}),o.type==="pcb_via"&&Q5e({ctx:this.ctx,via:o,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}));for(const o of e)FG(o,A)&&o.type==="pcb_cutout"&&hOe({ctx:this.ctx,cutout:o,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap});for(const o of e)FG(o,A)&&(o.type==="pcb_keepout"&&bOe({ctx:this.ctx,keepout:o,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}),o.type==="pcb_fabrication_note_text"&&wOe({ctx:this.ctx,text:o,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}),o.type==="pcb_fabrication_note_rect"&&yOe({ctx:this.ctx,rect:o,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}),o.type==="pcb_note_rect"&&GOe({realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap,ctx:this.ctx,rect:o}),o.type==="pcb_fabrication_note_path"&&fOe({ctx:this.ctx,path:o,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}),o.type==="pcb_note_path"&&FOe({ctx:this.ctx,path:o,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}),o.type==="pcb_note_text"&&MOe({ctx:this.ctx,text:o,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}),o.type==="pcb_note_line"&&kOe({ctx:this.ctx,line:o,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}),o.type==="pcb_note_dimension"&&_Oe({ctx:this.ctx,pcbNoteDimension:o,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}),o.type==="pcb_fabrication_note_dimension"&&pOe({ctx:this.ctx,pcbFabricationNoteDimension:o,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}),o.type==="pcb_courtyard_circle"&&BOe({ctx:this.ctx,circle:o,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}),o.type==="pcb_courtyard_rect"&&QOe({ctx:this.ctx,rect:o,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}))}};const h5e=zwt(eJt);var wfA,$gt;function E5e(){if($gt)return wfA;$gt=1;var e=Object.defineProperty,A=Object.getOwnPropertyDescriptor,t=Object.getOwnPropertyNames,i=Object.prototype.hasOwnProperty,n=(h,E)=>{for(var u in E)e(h,u,{get:E[u],enumerable:!0})},o=(h,E,u,d)=>{if(E&&typeof E=="object"||typeof E=="function")for(let p of t(E))!i.call(h,p)&&p!==u&&e(h,p,{get:()=>E[p],enumerable:!(d=A(E,p))||d.enumerable});return h},s=h=>o(e({},"__esModule",{value:!0}),h),r={};n(r,{SuperGrid:()=>Q,toMMSI:()=>C,toMeterSI:()=>B}),wfA=s(r);var a=E0(),g=h5e,c=LbA(),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:w="rgba(0,0,0,0.1)",textColor:D=(E=h.majorColor)!=null?E:"rgba(0,0,0,0.5)",width:S,height:k,screenSpaceCellSize:x=200,stringifyCoord:N=(H,O,Z)=>`${B(H,Z)}, ${B(O,Z)}`}=h,M=Math.ceil(S/x)+2,L=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,eA=x/10**Math.log10(h.transform.a)/O;function aA(_A,dA,PA){const JA=_A;let it,pA,tt;for(it=dA.x;it<=PA.x;it+=JA)pA=(0,g.applyToPoint)(h.transform,{x:it,y:dA.y}),tt=(0,g.applyToPoint)(h.transform,{x:it,y:PA.y}),H.beginPath(),H.moveTo(pA.x,pA.y),H.lineTo(tt.x,tt.y),H.stroke();const OA=I(dA.y,PA.y,JA*Z);for(const HA of OA)pA=(0,g.applyToPoint)(h.transform,{x:dA.x,y:HA}),tt=(0,g.applyToPoint)(h.transform,{x:PA.x,y:HA}),H.beginPath(),H.moveTo(pA.x,pA.y),H.lineTo(tt.x,tt.y),H.stroke()}function tA(_A,dA,PA){const JA=_A;let it;for(it=dA.x;it<=PA.x;it+=JA)for(const pA of I(dA.y,PA.y,JA*Z)){const tt=(0,g.applyToPoint)(h.transform,{x:it,y:pA});H.fillStyle=D,H.font="12px sans-serif",H.fillText(N(it,pA,_A),tt.x+2,tt.y-2)}}H.clearRect(0,0,S,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*L*Z},bA=O*5,GA={x:Math.floor((nA.x-bA)/bA)*bA,y:Math.floor((nA.y-bA)/bA+(Z==-1?2:0))*bA},YA={x:GA.x+bA*M,y:GA.y+bA*L*Z};H.globalAlpha=1,H.strokeStyle=m,aA(O,rA,lA),tA(bA,GA,YA),H.globalAlpha=1-eA,aA(bA/10,GA,YA),H.globalAlpha=1-eA,H.strokeStyle=w,aA(O/10,rA,lA),H.globalAlpha=Math.max(((1-eA)*10-5)/5,0),tA(bA/10,GA,YA),H.globalAlpha=1;const QA=(0,g.applyToPoint)(h.transform,d);H.font="12px sans-serif",H.fillStyle=D,H.fillText(N(d.x,d.y,O),QA.x+2,QA.y-2),H.strokeStyle=m,H.strokeRect(QA.x-5,QA.y-5,10,10)},[u,h.transform,d,S,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}),eA=l(O,$);p(eA)};return(0,c.jsx)("canvas",{onMouseUp:H=>{H.button===1&&Y(H)},onDoubleClick:Y,ref:u,width:h.width,height:h.height})};return wfA}var w9=E5e();function u5e(e){if(e.sheet)return e.sheet;for(var A=0;A<document.styleSheets.length;A++)if(document.styleSheets[A].ownerNode===e)return document.styleSheets[A]}function d5e(e){var A=document.createElement("style");return A.setAttribute("data-emotion",e.key),e.nonce!==void 0&&A.setAttribute("nonce",e.nonce),A.appendChild(document.createTextNode("")),A.setAttribute("data-s",""),A}var p5e=(function(){function e(t){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=t.speedy===void 0?!0:t.speedy,this.tags=[],this.ctr=0,this.nonce=t.nonce,this.key=t.key,this.container=t.container,this.prepend=t.prepend,this.insertionPoint=t.insertionPoint,this.before=null}var A=e.prototype;return A.hydrate=function(i){i.forEach(this._insertTag)},A.insert=function(i){this.ctr%(this.isSpeedy?65e3:1)===0&&this._insertTag(d5e(this));var n=this.tags[this.tags.length-1];if(this.isSpeedy){var o=u5e(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},e})(),Xu="-ms-",D9="-moz-",za="-webkit-",Act="comm",DfA="rule",SfA="decl",f5e="@import",tct="@keyframes",y5e="@layer",m5e=Math.abs,S9=String.fromCharCode,w5e=Object.assign;function D5e(e,A){return UE(e,0)^45?(((A<<2^UE(e,0))<<2^UE(e,1))<<2^UE(e,2))<<2^UE(e,3):0}function ect(e){return e.trim()}function S5e(e,A){return(e=A.exec(e))?e[0]:e}function Xa(e,A,t){return e.replace(A,t)}function bfA(e,A){return e.indexOf(A)}function UE(e,A){return e.charCodeAt(A)|0}function uJ(e,A,t){return e.slice(A,t)}function KD(e){return e.length}function xfA(e){return e.length}function b9(e,A){return A.push(e),e}function b5e(e,A){return e.map(A).join("")}var x9=1,s1=1,ict=0,xf=0,PC=0,r1="";function _9(e,A,t,i,n,o,s){return{value:e,root:A,parent:t,type:i,props:n,children:o,line:x9,column:s1,length:s,return:""}}function dJ(e,A){return w5e(_9("",null,null,"",null,null,0),e,{length:-e.length},A)}function x5e(){return PC}function _5e(){return PC=xf>0?UE(r1,--xf):0,s1--,PC===10&&(s1=1,x9--),PC}function J0(){return PC=xf<ict?UE(r1,xf++):0,s1++,PC===10&&(s1=1,x9++),PC}function PD(){return UE(r1,xf)}function k9(){return xf}function pJ(e,A){return uJ(r1,e,A)}function fJ(e){switch(e){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 nct(e){return x9=s1=1,ict=KD(r1=e),xf=0,[]}function oct(e){return r1="",e}function F9(e){return ect(pJ(xf-1,_fA(e===91?e+2:e===40?e+1:e)))}function k5e(e){for(;(PC=PD())&&PC<33;)J0();return fJ(e)>2||fJ(PC)>3?"":" "}function F5e(e,A){for(;--A&&J0()&&!(PC<48||PC>102||PC>57&&PC<65||PC>70&&PC<97););return pJ(e,k9()+(A<6&&PD()==32&&J0()==32))}function _fA(e){for(;J0();)switch(PC){case e:return xf;case 34:case 39:e!==34&&e!==39&&_fA(PC);break;case 40:e===41&&_fA(e);break;case 92:J0();break}return xf}function G5e(e,A){for(;J0()&&e+PC!==57;)if(e+PC===84&&PD()===47)break;return"/*"+pJ(A,xf-1)+"*"+S9(e===47?e:J0())}function R5e(e){for(;!fJ(PD());)J0();return pJ(e,xf)}function M5e(e){return oct(G9("",null,null,null,[""],e=nct(e),0,[0],e))}function G9(e,A,t,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,w=i,D=d;h;)switch(C=u,u=J0()){case 40:if(C!=108&&UE(D,I-1)==58){bfA(D+=Xa(F9(u),"&","&\f"),"&\f")!=-1&&(E=-1);break}case 34:case 39:case 91:D+=F9(u);break;case 9:case 10:case 13:case 32:D+=k5e(C);break;case 92:D+=F5e(k9()-1,7);continue;case 47:switch(PD()){case 42:case 47:b9(N5e(G5e(J0(),k9()),A,t),a);break;default:D+="/"}break;case 123*Q:r[g++]=KD(D)*E;case 125*Q:case 59:case 0:switch(u){case 0:case 125:h=0;case 59+c:E==-1&&(D=Xa(D,/\f/g,"")),B>0&&KD(D)-I&&b9(B>32?rct(D+";",i,t,I-1):rct(Xa(D," ","")+";",i,t,I-2),a);break;case 59:D+=";";default:if(b9(w=sct(D,A,t,g,c,n,r,d,p=[],m=[],I),o),u===123)if(c===0)G9(D,A,w,w,p,o,I,r,m);else switch(l===99&&UE(D,3)===110?100:l){case 100:case 108:case 109:case 115:G9(e,w,w,i&&b9(sct(e,w,w,0,0,n,r,d,n,p=[],I),m),n,m,I,r,i?p:m);break;default:G9(D,w,w,w,[""],m,0,r,m)}}g=c=B=0,Q=E=1,d=D="",I=s;break;case 58:I=1+KD(D),B=C;default:if(Q<1){if(u==123)--Q;else if(u==125&&Q++==0&&_5e()==125)continue}switch(D+=S9(u),u*Q){case 38:E=c>0?1:(D+="\f",-1);break;case 44:r[g++]=(KD(D)-1)*E,E=1;break;case 64:PD()===45&&(D+=F9(J0())),l=PD(),c=I=KD(d=D+=R5e(k9())),u++;break;case 45:C===45&&KD(D)==2&&(Q=0)}}return o}function sct(e,A,t,i,n,o,s,r,a,g,c){for(var I=n-1,l=n===0?o:[""],B=xfA(l),C=0,Q=0,h=0;C<i;++C)for(var E=0,u=uJ(e,I+1,I=m5e(Q=s[C])),d=e;E<B;++E)(d=ect(Q>0?l[E]+" "+u:Xa(u,/&\f/g,l[E])))&&(a[h++]=d);return _9(e,A,t,n===0?DfA:r,a,g,c)}function N5e(e,A,t){return _9(e,A,t,Act,S9(x5e()),uJ(e,2,-2),0)}function rct(e,A,t,i){return _9(e,A,t,SfA,uJ(e,0,i),uJ(e,i+1,-1),i)}function a1(e,A){for(var t="",i=xfA(e),n=0;n<i;n++)t+=A(e[n],n,e,A)||"";return t}function v5e(e,A,t,i){switch(e.type){case y5e:if(e.children.length)break;case f5e:case SfA:return e.return=e.return||e.value;case Act:return"";case tct:return e.return=e.value+"{"+a1(e.children,i)+"}";case DfA:e.value=e.props.join(",")}return KD(t=a1(e.children,i))?e.return=e.value+"{"+t+"}":""}function L5e(e){var A=xfA(e);return function(t,i,n,o){for(var s="",r=0;r<A;r++)s+=e[r](t,i,n,o)||"";return s}}function U5e(e){return function(A){A.root||(A=A.return)&&e(A)}}function H5e(e){var A=Object.create(null);return function(t){return A[t]===void 0&&(A[t]=e(t)),A[t]}}var Y5e=function(A,t,i){for(var n=0,o=0;n=o,o=PD(),n===38&&o===12&&(t[i]=1),!fJ(o);)J0();return pJ(A,xf)},J5e=function(A,t){var i=-1,n=44;do switch(fJ(n)){case 0:n===38&&PD()===12&&(t[i]=1),A[i]+=Y5e(xf-1,t,i);break;case 2:A[i]+=F9(n);break;case 4:if(n===44){A[++i]=PD()===58?"&\f":"",t[i]=A[i].length;break}default:A[i]+=S9(n)}while(n=J0());return A},T5e=function(A,t){return oct(J5e(nct(A),t))},act=new WeakMap,K5e=function(A){if(!(A.type!=="rule"||!A.parent||A.length<1)){for(var t=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&&t.charCodeAt(0)!==58&&!act.get(i))&&!n){act.set(A,!0);for(var o=[],s=T5e(t,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]}}},P5e=function(A){if(A.type==="decl"){var t=A.value;t.charCodeAt(0)===108&&t.charCodeAt(2)===98&&(A.return="",A.value="")}};function gct(e,A){switch(D5e(e,A)){case 5103:return za+"print-"+e+e;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 za+e+e;case 5349:case 4246:case 4810:case 6968:case 2756:return za+e+D9+e+Xu+e+e;case 6828:case 4268:return za+e+Xu+e+e;case 6165:return za+e+Xu+"flex-"+e+e;case 5187:return za+e+Xa(e,/(\w+).+(:[^]+)/,za+"box-$1$2"+Xu+"flex-$1$2")+e;case 5443:return za+e+Xu+"flex-item-"+Xa(e,/flex-|-self/,"")+e;case 4675:return za+e+Xu+"flex-line-pack"+Xa(e,/align-content|flex-|-self/,"")+e;case 5548:return za+e+Xu+Xa(e,"shrink","negative")+e;case 5292:return za+e+Xu+Xa(e,"basis","preferred-size")+e;case 6060:return za+"box-"+Xa(e,"-grow","")+za+e+Xu+Xa(e,"grow","positive")+e;case 4554:return za+Xa(e,/([^-])(transform)/g,"$1"+za+"$2")+e;case 6187:return Xa(Xa(Xa(e,/(zoom-|grab)/,za+"$1"),/(image-set)/,za+"$1"),e,"")+e;case 5495:case 3959:return Xa(e,/(image-set\([^]*)/,za+"$1$`$1");case 4968:return Xa(Xa(e,/(.+:)(flex-)?(.*)/,za+"box-pack:$3"+Xu+"flex-pack:$3"),/s.+-b[^;]+/,"justify")+za+e+e;case 4095:case 3583:case 4068:case 2532:return Xa(e,/(.+)-inline(.+)/,za+"$1$2")+e;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(KD(e)-1-A>6)switch(UE(e,A+1)){case 109:if(UE(e,A+4)!==45)break;case 102:return Xa(e,/(.+:)(.+)-([^]+)/,"$1"+za+"$2-$3$1"+D9+(UE(e,A+3)==108?"$3":"$2-$3"))+e;case 115:return~bfA(e,"stretch")?gct(Xa(e,"stretch","fill-available"),A)+e:e}break;case 4949:if(UE(e,A+1)!==115)break;case 6444:switch(UE(e,KD(e)-3-(~bfA(e,"!important")&&10))){case 107:return Xa(e,":",":"+za)+e;case 101:return Xa(e,/(.+:)([^;!]+)(;|!.+)?/,"$1"+za+(UE(e,14)===45?"inline-":"")+"box$3$1"+za+"$2$3$1"+Xu+"$2box$3")+e}break;case 5936:switch(UE(e,A+11)){case 114:return za+e+Xu+Xa(e,/[svh]\w+-[tblr]{2}/,"tb")+e;case 108:return za+e+Xu+Xa(e,/[svh]\w+-[tblr]{2}/,"tb-rl")+e;case 45:return za+e+Xu+Xa(e,/[svh]\w+-[tblr]{2}/,"lr")+e}return za+e+Xu+e+e}return e}var q5e=function(A,t,i,n){if(A.length>-1&&!A.return)switch(A.type){case SfA:A.return=gct(A.value,A.length);break;case tct:return a1([dJ(A,{value:Xa(A.value,"@","@"+za)})],n);case DfA:if(A.length)return b5e(A.props,function(o){switch(S5e(o,/(::plac\w+|:read-\w+)/)){case":read-only":case":read-write":return a1([dJ(A,{props:[Xa(o,/:(read-\w+)/,":"+D9+"$1")]})],n);case"::placeholder":return a1([dJ(A,{props:[Xa(o,/:(plac\w+)/,":"+za+"input-$1")]}),dJ(A,{props:[Xa(o,/:(plac\w+)/,":"+D9+"$1")]}),dJ(A,{props:[Xa(o,/:(plac\w+)/,Xu+"input-$1")]})],n)}return""})}},O5e=[q5e],W5e=function(A){var t=A.key;if(t==="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||O5e,o={},s,r=[];s=A.container||document.head,Array.prototype.forEach.call(document.querySelectorAll('style[data-emotion^="'+t+' "]'),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=[K5e,P5e];{var c,I=[v5e,U5e(function(Q){c.insert(Q)})],l=L5e(g.concat(n,I)),B=function(h){return a1(M5e(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:t,sheet:new p5e({key:t,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 Z5e(e){for(var A=0,t,i=0,n=e.length;n>=4;++i,n-=4)t=e.charCodeAt(i)&255|(e.charCodeAt(++i)&255)<<8|(e.charCodeAt(++i)&255)<<16|(e.charCodeAt(++i)&255)<<24,t=(t&65535)*1540483477+((t>>>16)*59797<<16),t^=t>>>24,A=(t&65535)*1540483477+((t>>>16)*59797<<16)^(A&65535)*1540483477+((A>>>16)*59797<<16);switch(n){case 3:A^=(e.charCodeAt(i+2)&255)<<16;case 2:A^=(e.charCodeAt(i+1)&255)<<8;case 1:A^=e.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 V5e={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},j5e=/[A-Z]|^ms/g,z5e=/_EMO_([^_]+?)_([^]*?)_EMO_/g,cct=function(A){return A.charCodeAt(1)===45},Ict=function(A){return A!=null&&typeof A!="boolean"},kfA=H5e(function(e){return cct(e)?e:e.replace(j5e,"-$&").toLowerCase()}),lct=function(A,t){switch(A){case"animation":case"animationName":if(typeof t=="string")return t.replace(z5e,function(i,n,o){return tk={name:n,styles:o,next:tk},n})}return V5e[A]!==1&&!cct(A)&&typeof t=="number"&&t!==0?t+"px":t};function R9(e,A,t){if(t==null)return"";var i=t;if(i.__emotion_styles!==void 0)return i;switch(typeof t){case"boolean":return"";case"object":{var n=t;if(n.anim===1)return tk={name:n.name,styles:n.styles,next:tk},n.name;var o=t;if(o.styles!==void 0){var s=o.next;if(s!==void 0)for(;s!==void 0;)tk={name:s.name,styles:s.styles,next:tk},s=s.next;var r=o.styles+";";return r}return X5e(e,A,t)}}var a=t;if(A==null)return a;var g=A[a];return g!==void 0?g:a}function X5e(e,A,t){var i="";if(Array.isArray(t))for(var n=0;n<t.length;n++)i+=R9(e,A,t[n])+";";else for(var o in t){var s=t[o];if(typeof s!="object"){var r=s;A!=null&&A[r]!==void 0?i+=o+"{"+A[r]+"}":Ict(r)&&(i+=kfA(o)+":"+lct(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++)Ict(s[a])&&(i+=kfA(o)+":"+lct(o,s[a])+";");else{var g=R9(e,A,s);switch(o){case"animation":case"animationName":{i+=kfA(o)+":"+g+";";break}default:i+=o+"{"+g+"}"}}}return i}var Bct=/label:\s*([^\s;{]+)\s*(;|$)/g,tk;function FfA(e,A,t){if(e.length===1&&typeof e[0]=="object"&&e[0]!==null&&e[0].styles!==void 0)return e[0];var i=!0,n="";tk=void 0;var o=e[0];if(o==null||o.raw===void 0)i=!1,n+=R9(t,A,o);else{var s=o;n+=s[0]}for(var r=1;r<e.length;r++)if(n+=R9(t,A,e[r]),i){var a=o;n+=a[r]}Bct.lastIndex=0;for(var g="",c;(c=Bct.exec(n))!==null;)g+="-"+c[1];var I=Z5e(n)+g;return{name:I,styles:n,next:tk}}function Cct(e,A,t){var i="";return t.split(" ").forEach(function(n){e[n]!==void 0?A.push(e[n]+";"):n&&(i+=n+" ")}),i}var $5e=function(A,t,i){var n=A.key+"-"+t.name;A.registered[n]===void 0&&(A.registered[n]=t.styles)},A8e=function(A,t,i){$5e(A,t);var n=A.key+"-"+t.name;if(A.inserted[t.name]===void 0){var o=t;do A.insert(t===o?"."+n:"",o,A.sheet,!0),o=o.next;while(o!==void 0)}};function Qct(e,A){if(e.inserted[A.name]===void 0)return e.insert("",A,e.sheet,!0)}function hct(e,A,t){var i=[],n=Cct(e,i,t);return i.length<2?t:n+A(i)}var t8e=function(A){var t=W5e(A);t.sheet.speedy=function(r){this.isSpeedy=r},t.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=FfA(g,t.registered,void 0);return A8e(t,I),t.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=FfA(g,t.registered),l="animation-"+I.name;return Qct(t,{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=FfA(g,t.registered);Qct(t,I)},s=function(){for(var a=arguments.length,g=new Array(a),c=0;c<a;c++)g[c]=arguments[c];return hct(t.registered,i,e8e(g))};return{css:i,cx:s,injectGlobal:o,keyframes:n,hydrate:function(a){a.forEach(function(g){t.inserted[g]=!0})},flush:function(){t.registered={},t.inserted={},t.sheet.flush()},sheet:t.sheet,cache:t,getRegisteredStyles:Cct.bind(null,t.registered),merge:hct.bind(null,t.registered,i)}},e8e=function e(A){for(var t="",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=e(n);else{o="";for(var s in n)n[s]&&s&&(o&&(o+=" "),o+=s)}break}default:o=n}o&&(t&&(t+=" "),t+=o)}}return t},i8e=t8e({key:"css"}),g1=i8e.css,n8e=Object.create,Ect=Object.defineProperty,o8e=Object.getOwnPropertyDescriptor,uct=Object.getOwnPropertyNames,s8e=Object.getPrototypeOf,r8e=Object.prototype.hasOwnProperty,va=(e,A)=>function(){return A||(0,e[uct(e)[0]])((A={exports:{}}).exports,A),A.exports},a8e=(e,A,t,i)=>{if(A&&typeof A=="object"||typeof A=="function")for(let n of uct(A))!r8e.call(e,n)&&n!==t&&Ect(e,n,{get:()=>A[n],enumerable:!(i=o8e(A,n))||i.enumerable});return e},dct=(e,A,t)=>(t=e!=null?n8e(s8e(e)):{},a8e(Ect(t,"default",{value:e,enumerable:!0}),e)),g8e=va({"node_modules/svgson/dist/svgson.umd.js"(e,A){(function(t,i){typeof e=="object"&&typeof A<"u"?A.exports=i():typeof define=="function"&&define.amd?define(i):(t=typeof globalThis<"u"?globalThis:t||self,t.svgson=i())})(e,function(){var t=function(tA){return tA!=null&&(i(tA)||n(tA)||!!tA._isBuffer)};function i(tA){return!!tA.constructor&&typeof tA.constructor.isBuffer=="function"&&tA.constructor.isBuffer(tA)}function n(tA){return typeof tA.readFloatLE=="function"&&typeof tA.slice=="function"&&i(tA.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":t(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(tA,nA){return nA={exports:{}},tA(nA,nA.exports),nA.exports}var a=r(function(tA){(function(){function nA(rA,lA){if(typeof lA!="function")return rA;var fA={};for(var bA in rA)Object.prototype.hasOwnProperty.call(rA,bA)&&(fA[lA(bA,rA[bA])||bA]=rA[bA]);return fA}tA.exports?tA.exports=nA:window.rename=nA})()}),g=function tA(nA,rA){var lA=s(nA);if(lA!=="object"&&lA!=="array")throw new Error("expected an object");var fA=[];lA==="object"&&(nA=a(nA,rA),fA={});for(var bA in nA)if(nA.hasOwnProperty(bA)){var GA=nA[bA];s(GA)==="object"||s(GA)==="array"?fA[bA]=tA(GA,rA):fA[bA]=GA}return fA},c=r(function(tA){var nA=Object.prototype.hasOwnProperty,rA="~";function lA(){}Object.create&&(lA.prototype=Object.create(null),new lA().__proto__||(rA=!1));function fA(GA,YA,QA){this.fn=GA,this.context=YA,this.once=QA||!1}function bA(){this._events=new lA,this._eventsCount=0}bA.prototype.eventNames=function(){var YA=[],QA,_A;if(this._eventsCount===0)return YA;for(_A in QA=this._events)nA.call(QA,_A)&&YA.push(rA?_A.slice(1):_A);return Object.getOwnPropertySymbols?YA.concat(Object.getOwnPropertySymbols(QA)):YA},bA.prototype.listeners=function(YA,QA){var _A=rA?rA+YA:YA,dA=this._events[_A];if(QA)return!!dA;if(!dA)return[];if(dA.fn)return[dA.fn];for(var PA=0,JA=dA.length,it=new Array(JA);PA<JA;PA++)it[PA]=dA[PA].fn;return it},bA.prototype.emit=function(YA,QA,_A,dA,PA,JA){var it=rA?rA+YA:YA;if(!this._events[it])return!1;var pA=this._events[it],tt=arguments.length,OA,HA;if(pA.fn){switch(pA.once&&this.removeListener(YA,pA.fn,void 0,!0),tt){case 1:return pA.fn.call(pA.context),!0;case 2:return pA.fn.call(pA.context,QA),!0;case 3:return pA.fn.call(pA.context,QA,_A),!0;case 4:return pA.fn.call(pA.context,QA,_A,dA),!0;case 5:return pA.fn.call(pA.context,QA,_A,dA,PA),!0;case 6:return pA.fn.call(pA.context,QA,_A,dA,PA,JA),!0}for(HA=1,OA=new Array(tt-1);HA<tt;HA++)OA[HA-1]=arguments[HA];pA.fn.apply(pA.context,OA)}else{var ZA=pA.length,xA;for(HA=0;HA<ZA;HA++)switch(pA[HA].once&&this.removeListener(YA,pA[HA].fn,void 0,!0),tt){case 1:pA[HA].fn.call(pA[HA].context);break;case 2:pA[HA].fn.call(pA[HA].context,QA);break;case 3:pA[HA].fn.call(pA[HA].context,QA,_A);break;case 4:pA[HA].fn.call(pA[HA].context,QA,_A,dA);break;default:if(!OA)for(xA=1,OA=new Array(tt-1);xA<tt;xA++)OA[xA-1]=arguments[xA];pA[HA].fn.apply(pA[HA].context,OA)}}return!0},bA.prototype.on=function(YA,QA,_A){var dA=new fA(QA,_A||this),PA=rA?rA+YA:YA;return this._events[PA]?this._events[PA].fn?this._events[PA]=[this._events[PA],dA]:this._events[PA].push(dA):(this._events[PA]=dA,this._eventsCount++),this},bA.prototype.once=function(YA,QA,_A){var dA=new fA(QA,_A||this,!0),PA=rA?rA+YA:YA;return this._events[PA]?this._events[PA].fn?this._events[PA]=[this._events[PA],dA]:this._events[PA].push(dA):(this._events[PA]=dA,this._eventsCount++),this},bA.prototype.removeListener=function(YA,QA,_A,dA){var PA=rA?rA+YA:YA;if(!this._events[PA])return this;if(!QA)return--this._eventsCount===0?this._events=new lA:delete this._events[PA],this;var JA=this._events[PA];if(JA.fn)JA.fn===QA&&(!dA||JA.once)&&(!_A||JA.context===_A)&&(--this._eventsCount===0?this._events=new lA:delete this._events[PA]);else{for(var it=0,pA=[],tt=JA.length;it<tt;it++)(JA[it].fn!==QA||dA&&!JA[it].once||_A&&JA[it].context!==_A)&&pA.push(JA[it]);pA.length?this._events[PA]=pA.length===1?pA[0]:pA:--this._eventsCount===0?this._events=new lA:delete this._events[PA]}return this},bA.prototype.removeAllListeners=function(YA){var QA;return YA?(QA=rA?rA+YA:YA,this._events[QA]&&(--this._eventsCount===0?this._events=new lA:delete this._events[QA])):(this._events=new lA,this._eventsCount=0),this},bA.prototype.off=bA.prototype.removeListener,bA.prototype.addListener=bA.prototype.on,bA.prototype.setMaxListeners=function(){return this},bA.prefixed=rA,bA.EventEmitter=bA,tA.exports=bA});function I(tA,nA,rA){return nA in tA?Object.defineProperty(tA,nA,{value:rA,enumerable:!0,configurable:!0,writable:!0}):tA[nA]=rA,tA}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,fA,bA,GA,YA,QA,_A,dA,PA;nA=Object.assign({debug:!1},nA);var JA=new c,it=B.data,pA="",tt="",OA="",HA="",ZA="",xA="",wA=function(KA,qA){if(!(tt[0]==="?"||tt[0]==="!")){var At={type:KA,value:qA};nA.debug&&console.log("emit:",At),JA.emit("data",At)}};JA.stateMachine=(PA={},I(PA,B.data,(rA={},I(rA,C.lt,function(){pA.trim()&&wA(Q.text,pA),tt="",ZA=!1,it=B.tagBegin}),I(rA,C.char,function(RA){pA+=RA}),rA)),I(PA,B.cdata,I({},C.char,function(RA){pA+=RA,pA.substr(-3)==="]]>"&&(wA(Q.text,pA.slice(0,-3)),pA="",it=B.data)})),I(PA,B.tagBegin,(lA={},I(lA,C.space,l),I(lA,C.char,function(RA){tt=RA,it=B.tagName}),I(lA,C.slash,function(){tt="",ZA=!0}),lA)),I(PA,B.tagName,(fA={},I(fA,C.space,function(){ZA?it=B.tagEnd:(it=B.attributeNameStart,wA(Q.openTag,tt))}),I(fA,C.gt,function(){wA(ZA?Q.closeTag:Q.openTag,tt),pA="",it=B.data}),I(fA,C.slash,function(){it=B.tagEnd,wA(Q.openTag,tt)}),I(fA,C.char,function(RA){tt+=RA,tt==="![CDATA["&&(it=B.cdata,pA="",tt="")}),fA)),I(PA,B.tagEnd,(bA={},I(bA,C.gt,function(){wA(Q.closeTag,tt),pA="",it=B.data}),I(bA,C.char,l),bA)),I(PA,B.attributeNameStart,(GA={},I(GA,C.char,function(RA){OA=RA,it=B.attributeName}),I(GA,C.gt,function(){pA="",it=B.data}),I(GA,C.space,l),I(GA,C.slash,function(){ZA=!0,it=B.tagEnd}),GA)),I(PA,B.attributeName,(YA={},I(YA,C.space,function(){it=B.attributeNameEnd}),I(YA,C.equal,function(){wA(Q.attributeName,OA),it=B.attributeValueBegin}),I(YA,C.gt,function(){HA="",wA(Q.attributeName,OA),wA(Q.attributeValue,HA),pA="",it=B.data}),I(YA,C.slash,function(){ZA=!0,HA="",wA(Q.attributeName,OA),wA(Q.attributeValue,HA),it=B.tagEnd}),I(YA,C.char,function(RA){OA+=RA}),YA)),I(PA,B.attributeNameEnd,(QA={},I(QA,C.space,l),I(QA,C.equal,function(){wA(Q.attributeName,OA),it=B.attributeValueBegin}),I(QA,C.gt,function(){HA="",wA(Q.attributeName,OA),wA(Q.attributeValue,HA),pA="",it=B.data}),I(QA,C.char,function(RA){HA="",wA(Q.attributeName,OA),wA(Q.attributeValue,HA),OA=RA,it=B.attributeName}),QA)),I(PA,B.attributeValueBegin,(_A={},I(_A,C.space,l),I(_A,C.quote,function(RA){xA=RA,HA="",it=B.attributeValue}),I(_A,C.gt,function(){HA="",wA(Q.attributeValue,HA),pA="",it=B.data}),I(_A,C.char,function(RA){xA="",HA=RA,it=B.attributeValue}),_A)),I(PA,B.attributeValue,(dA={},I(dA,C.space,function(RA){xA?HA+=RA:(wA(Q.attributeValue,HA),it=B.attributeNameStart)}),I(dA,C.quote,function(RA){xA===RA?(wA(Q.attributeValue,HA),it=B.attributeNameStart):HA+=RA}),I(dA,C.gt,function(RA){xA?HA+=RA:(wA(Q.attributeValue,HA),pA="",it=B.data)}),I(dA,C.slash,function(RA){xA?HA+=RA:(wA(Q.attributeValue,HA),ZA=!0,it=B.tagEnd)}),I(dA,C.char,function(RA){HA+=RA}),dA)),PA);var NA=function(KA){nA.debug&&console.log(it,KA);var qA=JA.stateMachine[it],At=qA[E(KA)]||qA[C.error]||qA[C.char];At(KA)};return JA.write=function(RA){for(var KA=RA.length,qA=0;qA<KA;qA++)NA(RA[qA])},JA},d={State:B,Action:C,Type:Q,create:u},p=d.Type,m={element:"element",text:"text"},w=function(nA){return Object.assign({name:"",type:m.element,value:"",parent:null,attributes:{},children:[]},nA)},D=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,fA=void 0,bA=void 0,GA=new c,YA=function(_A){switch(_A.type){case p.openTag:if(fA===null)fA=lA,fA.name=_A.value;else{var dA=w({name:_A.value,parent:fA});fA.children.push(dA),fA=dA}break;case p.closeTag:var PA=fA.parent;if(nA.parentNodes||(fA.parent=null),fA.name!==_A.value)break;nA.stream&&PA===lA&&(lA.children=[],fA.parent=null),(!nA.emitTopLevelOnly||PA===lA)&&(GA.emit(nA.tagPrefix+fA.name,fA),GA.emit("tag",fA.name,fA)),fA===lA&&(rA.removeAllListeners("data"),GA.emit(nA.doneEvent,fA),lA=null),fA=PA;break;case p.text:fA&&fA.children.push(w({type:m.text,value:_A.value,parent:nA.parentNodes?fA:null}));break;case p.attributeName:bA=_A.value,fA.attributes[bA]="";break;case p.attributeValue:fA.attributes[bA]=_A.value;break}};return GA.reset=function(){rA=d.create({debug:nA.debug}),rA.on("data",YA),lA=w(),fA=null,bA="",GA.parse=rA.write},GA.reset(),GA},S=function(nA,rA){rA=Object.assign({},rA,{stream:!1,tagPrefix:":"});var lA=D(rA),fA=void 0;return lA.on("done",function(bA){fA=bA}),lA.parse(nA),fA},k={parseSync:S},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(fA){return fA.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:L(rA)})},L=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,fA=lA===void 0?function(QA){return QA}:lA,bA=rA.camelcase,GA=bA===void 0?!1:bA,YA=function(_A){var dA;return dA=fA(_A),GA&&(dA=M(dA)),dA};return YA(N(nA))};function $(){for(var tA=arguments.length,nA=new Array(tA),rA=0;rA<tA;rA++)nA[rA]=arguments[rA];return new Promise(function(lA,fA){try{var bA=Z.apply(void 0,nA);lA(bA)}catch(GA){fA(GA)}})}var eA=function tA(nA){var rA=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},lA=rA.transformAttr,fA=lA===void 0?function(it,pA,tt){return"".concat(it,'="').concat(tt(pA),'"')}:lA,bA=rA.transformNode,GA=bA===void 0?function(it){return it}:bA,YA=rA.selfClose,QA=YA===void 0?!0:YA;if(Array.isArray(nA))return nA.map(function(it){return tA(it,{transformAttr:fA,selfClose:QA,transformNode:GA})}).join("");var _A=GA(nA);if(_A.type==="text")return H(_A.value);var dA="";for(var PA in _A.attributes){var JA=fA(PA,_A.attributes[PA],O,_A.name);dA+=JA?" ".concat(JA):""}return _A.children&&_A.children.length>0||!QA?"<".concat(_A.name).concat(dA,">").concat(tA(_A.children,{transformAttr:fA,transformNode:GA,selfClose:QA}),"</").concat(_A.name,">"):"<".concat(_A.name).concat(dA,"/>")},aA=Object.assign({},{parse:$,parseSync:Z,stringify:eA});return aA})}}),GfA=va({"node_modules/js-beautify/js/src/core/output.js"(e,A){function t(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=[]}t.prototype.clone_empty=function(){var o=new t(this.__parent);return o.set_indent(this.__indent_count,this.__alignment_count),o},t.prototype.item=function(o){return o<0?this.__items[this.__items.length+o]:this.__items[o]},t.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},t.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))},t.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)},t.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},t.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},t.prototype.is_empty=function(){return this.__items.length===0},t.prototype.last=function(){return this.is_empty()?null:this.__items[this.__items.length-1]},t.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:t,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:t,letterSpacing:i,spaceWidth:n,strokeWidth:o,lineHeight:s,lines:r,lineWidths:a}}function dfA(e,A){const t=A.width+A.strokeWidth,i=A.height+A.strokeWidth;let n=0,o=0;return e==="center"||e==="top_center"||e==="bottom_center"?n=-t/2:e==="top_left"||e==="bottom_left"||e==="center_left"?n=0:e==="top_right"||e==="bottom_right"||e==="center_right"?n=-t:(e==="top_center"||e==="bottom_center")&&(n=-t/2),e==="center"||e==="center_left"||e==="center_right"?o=-i/2:e==="top_left"||e==="top_right"||e==="top_center"?o=0:(e==="bottom_left"||e==="bottom_right"||e==="bottom_center")&&(o=-i),{x:n,y:o}}function pfA(e){const{alignment:A,lineWidth:t,maxWidth:i,strokeWidth:n}=e,o=t+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 rOe=e=>uD[e]??uD[e.toUpperCase()];function ffA(e){const{ctx:A,line:t,fontSize:i,startX:n,startY:o,layout:s}=e,{glyphWidth:r,letterSpacing:a,spaceWidth:g,strokeWidth:c}=s,I=i,l=o,B=Array.from(t);let C=n+c/2;B.forEach((Q,h)=>{const E=rOe(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,w=C+d.x2*r,D=l+(1-d.y2)*I;A.moveTo(p,m),A.lineTo(w,D)}A.stroke()}C+=u,h<B.length-1&&(C+=a)})}function aOe(e){const{ctx:A,text:t,fontSize:i,startX:n,startY:o,anchorAlignment:s="center"}=e,r=y9(t,i),{lines:a,lineWidths:g,lineHeight:c,width:I,strokeWidth:l}=r;a.forEach((B,C)=>{const Q=n+pfA({alignment:s,lineWidth:g[C],maxWidth:I,strokeWidth:l}),h=o+C*c;ffA({ctx:A,line:B,fontSize:i,startX:Q,startY:h,layout:r})})}function yfA(e){const{ctx:A,text:t,x:i,y:n,fontSize:o,color:s,realToCanvasMat:r,anchorAlignment:a,rotation:g=0}=e;if(!t)return;const[c,I]=Cn(r,[i,n]),l=Math.abs(r.a),B=o*l,C=y9(t,B),Q=dfA(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,w)=>{const D=Q.x+pfA({alignment:a,lineWidth:E[w],maxWidth:d,strokeWidth:p}),S=Q.y+w*u;ffA({ctx:A,line:m,fontSize:B,startX:D,startY:S,layout:C})}),A.restore()}var gOe={left:.2,right:.2,top:.2,bottom:.2};function cOe(e){return e?e.includes("left")?"center_left":e.includes("right")?"center_right":"center":"center"}function IOe(e){const{ctx:A,text:t,realToCanvasMat:i,colorMap:n}=e,o=t.text??"";if(!o)return;const[s,r]=Cn(i,[t.anchor_position.x,t.anchor_position.y]),a=Math.abs(i.a),g=(t.font_size??1)*a,c=t.ccw_rotation??0,I={...gOe,...t.knockout_padding},l=n.copper[t.layer]??n.copper.top,B=y9(o,g),C=B.width+B.strokeWidth,Q=cOe(t.anchor_alignment),h=dfA(Q,B);if(A.save(),A.translate(s,r),t.is_mirrored&&A.scale(-1,1),c!==0&&A.rotate(-c*(Math.PI/180)),A.lineWidth=B.strokeWidth,A.lineCap="round",A.lineJoin="round",t.is_knockout){const E=I.left*a,u=I.right*a,d=I.top*a,p=I.bottom*a,m=h.x-E*4,w=h.y-d*4,D=C+E*2+u*2,S=B.height+B.strokeWidth+d*2+p*2;A.fillStyle=l,A.fillRect(m,w,D,S)}else A.strokeStyle=l;aOe({ctx:A,text:o,fontSize:g,startX:h.x,startY:h.y,anchorAlignment:Q}),A.restore()}function dw(e){const{ctx:A,center:t,radius:i,fill:n,realToCanvasMat:o,stroke:s,strokeWidth:r,isStrokeDashed:a=!1}=e,[g,c]=Cn(o,[t.x,t.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 lOe(e,A){return e==="bottom"?A.courtyard.bottom:A.courtyard.top}function BOe(e){const{ctx:A,circle:t,realToCanvasMat:i,colorMap:n}=e;dw({ctx:A,center:t.center,radius:t.radius,stroke:lOe(t.layer,n),strokeWidth:.05,realToCanvasMat:i})}function COe(e,A){return e==="bottom"?A.courtyard.bottom:A.courtyard.top}function QOe(e){const{ctx:A,rect:t,realToCanvasMat:i,colorMap:n}=e;bf({ctx:A,center:t.center,width:t.width,height:t.height,stroke:COe(t.layer,n),strokeWidth:.05,realToCanvasMat:i})}function hOe(e){const{ctx:A,cutout:t,realToCanvasMat:i,colorMap:n}=e;if(t.shape==="rect"){bf({ctx:A,center:t.center,width:t.width,height:t.height,fill:n.drill,realToCanvasMat:i,rotation:t.rotation??0,borderRadius:t.corner_radius??0});return}if(t.shape==="circle"){dw({ctx:A,center:t.center,radius:t.radius,fill:n.drill,realToCanvasMat:i});return}if(t.shape==="polygon"){t.points&&t.points.length>=3&&i1({ctx:A,points:t.points,fill:n.drill,realToCanvasMat:i});return}}var EOe=1.5,uOe=.6,dOe=.3;function mfA(e){const A=Math.hypot(e.x,e.y)||1;return{x:e.x/A,y:e.y/A}}function Wgt(e){const{ctx:A,from:t,to:i,realToCanvasMat:n,color:o,fontSize:s,arrowSize:r=1,strokeWidth:a,text:g,textRotation:c,offset:I}=e,l=mfA({x:i.x-t.x,y:i.y-t.y}),B={x:-l.y,y:l.x},C=I?.direction&&typeof I.direction.x=="number"&&typeof I.direction.y=="number",Q=C?mfA(I.direction):{x:0,y:0},h=I?.distance??0,E={x:Q.x*h,y:Q.y*h},u={x:t.x+E.x,y:t.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 w=a??r/5,D=o||"rgba(255,255,255,0.5)",S=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+S.x*k,y:Y.y+S.y*k},O=w/2,Z={x:-S.y,y:S.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*(w/2),y:p.y+B.y*(w/2)}),x.push({x:m.x+B.x*(w/2),y:m.y+B.y*(w/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*(w/2),y:m.y-B.y*(w/2)}),x.push({x:p.x-B.x*(w/2),y:p.y-B.y*(w/2)}),x.push({x:p.x-B.x*(r/2),y:p.y-B.y*(r/2)}),x.push(u);const M=x[0],L=Y=>{const H=N(Y);x.push(M),x.push(H[0]),x.push(...H),x.push(H[0]),x.push(M)};if(L(t),L(i),i1({ctx:A,points:x,fill:D,realToCanvasMat:n}),g){const Y={x:(t.x+i.x)/2+E.x,y:(t.y+i.y)/2+E.y},[H,O]=Cn(n,[u.x,u.y]),[Z,$]=Cn(n,[d.x,d.y]),eA=mfA({x:Z-H,y:$-O});let aA=Math.atan2(eA.y,eA.x)*180/Math.PI;(aA>90||aA<-90)&&(aA+=180);const tA=typeof c=="number"&&Number.isFinite(c)?aA-c:aA;let nA=0;if(g&&typeof c=="number"&&Number.isFinite(c)){const fA=g.length*s*uOe,bA=s,GA=c*Math.PI/180,YA=Math.abs(Math.sin(GA)),QA=Math.abs(Math.cos(GA)),_A=fA/2,dA=bA/2;nA=_A*YA+dA*QA+s*dOe}const rA=r*EOe+nA,lA={x:Y.x+B.x*rA,y:Y.y+B.y*rA};yfA({ctx:A,text:g,x:lA.x,y:lA.y,fontSize:s,color:D,realToCanvasMat:n,anchorAlignment:"center",rotation:-tA})}}function pOe(e){const{ctx:A,pcbFabricationNoteDimension:t,realToCanvasMat:i,colorMap:n}=e,o=t.color??n.fabricationNote;Wgt({ctx:A,from:t.from,to:t.to,realToCanvasMat:i,color:o,fontSize:t.font_size??1,arrowSize:t.arrow_size??1,text:t.text,textRotation:t.text_ccw_rotation,offset:t.offset_distance&&t.offset_direction?{distance:t.offset_distance,direction:t.offset_direction}:void 0})}function n1(e){const{ctx:A,start:t,end:i,strokeWidth:n,stroke:o,realToCanvasMat:s,lineCap:r="round"}=e,[a,g]=Cn(s,[t.x,t.y]),[c,I]=Cn(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 fOe(e){const{ctx:A,path:t,realToCanvasMat:i,colorMap:n}=e,o=n.fabricationNote,s=t.color??o;if(!(!t.route||t.route.length<2))for(let r=0;r<t.route.length-1;r++){const a=t.route[r],g=t.route[r+1];!a||!g||n1({ctx:A,start:{x:a.x,y:a.y},end:{x:g.x,y:g.y},strokeWidth:t.stroke_width??.1,stroke:s,realToCanvasMat:i})}}function yOe(e){const{ctx:A,rect:t,realToCanvasMat:i,colorMap:n}=e,o=n.fabricationNote,s=t.color??o,r=t.is_filled??!1,a=t.has_stroke??!0,g=t.is_stroke_dashed??!1;bf({ctx:A,center:t.center,width:t.width,height:t.height,fill:r?s:void 0,stroke:a?s:void 0,strokeWidth:a?t.stroke_width:void 0,borderRadius:t.corner_radius,realToCanvasMat:i,isStrokeDashed:g})}function mOe(e,A){return A.fabricationNote}function wOe(e){const{ctx:A,text:t,realToCanvasMat:i,colorMap:n}=e,o=mOe(t.layer,n),s=t.color??o,r=t.font_size;yfA({ctx:A,text:t.text,x:t.anchor_position.x,y:t.anchor_position.y,fontSize:r,color:s,realToCanvasMat:i,anchorAlignment:t.anchor_alignment})}function BJ(e){const{ctx:A,center:t,radius_x:i,radius_y:n,fill:o,stroke:s,strokeWidth:r=.1,realToCanvasMat:a,rotation:g=0}=e,[c,I]=Cn(a,[t.x,t.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 TD(e){const{ctx:A,center:t,width:i,height:n,fill:o,realToCanvasMat:s,rotation:r=0,stroke:a,strokeWidth:g}=e,[c,I]=Cn(s,[t.x,t.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 m9(e){return"ccw_rotation"in e&&typeof e.ccw_rotation=="number"?e.ccw_rotation:0}function DOe(e){const{ctx:A,hole:t,realToCanvasMat:i,colorMap:n,soldermaskMargin:o=0,drawSoldermask:s=!1}=e;if(s&&t.is_covered_with_solder_mask===!0)return;const r=o<0?Math.abs(o):0;if(t.hole_shape==="circle"){dw({ctx:A,center:{x:t.x,y:t.y},radius:t.hole_diameter/2-r,fill:n.drill,realToCanvasMat:i});return}if(t.hole_shape==="square"){const a=m9(t);bf({ctx:A,center:{x:t.x,y:t.y},width:t.hole_diameter-r*2,height:t.hole_diameter-r*2,fill:n.drill,realToCanvasMat:i,rotation:a});return}if(t.hole_shape==="oval"){const a=m9(t);BJ({ctx:A,center:{x:t.x,y:t.y},radius_x:t.hole_width/2-r,radius_y:t.hole_height/2-r,fill:n.drill,realToCanvasMat:i,rotation:a});return}if(t.hole_shape==="rect"){const a=m9(t);bf({ctx:A,center:{x:t.x,y:t.y},width:t.hole_width-r*2,height:t.hole_height-r*2,fill:n.drill,realToCanvasMat:i,rotation:a});return}if(t.hole_shape==="pill"||t.hole_shape==="rotated_pill"){const a=m9(t);TD({ctx:A,center:{x:t.x,y:t.y},width:t.hole_width-r*2,height:t.hole_height-r*2,fill:n.drill,realToCanvasMat:i,rotation:a});return}}function SOe(e,A){const t=parseInt(e.slice(1,3),16),i=parseInt(e.slice(3,5),16),n=parseInt(e.slice(5,7),16);return`rgba(${t}, ${i}, ${n}, ${A})`}function bOe(e){const{ctx:A,keepout:t,realToCanvasMat:i,colorMap:n}=e,o=n.keepout,s=SOe(n.keepout,.2),r=1;if(t.shape==="rect"){const[a,g]=Cn(i,[t.center.x,t.center.y]),c=t.width*Math.abs(i.a),I=t.height*Math.abs(i.a),l=t.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(t.shape==="circle"){const[a,g]=Cn(i,[t.center.x,t.center.y]),c=t.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 xOe="rgba(255,255,255,0.5)";function _Oe(e){const{ctx:A,pcbNoteDimension:t,realToCanvasMat:i}=e,n=t.color??xOe;Wgt({ctx:A,from:t.from,to:t.to,realToCanvasMat:i,color:n,fontSize:t.font_size,arrowSize:t.arrow_size,text:t.text,textRotation:t.text_ccw_rotation,offset:t.offset_distance&&t.offset_direction?{distance:t.offset_distance,direction:t.offset_direction}:void 0})}function kOe(e){const{ctx:A,line:t,realToCanvasMat:i}=e,o=t.color??"rgb(89, 148, 220)",s=t.stroke_width??.1,r=t.is_dashed??!1,[a,g]=Cn(i,[t.x1,t.y1]),[c,I]=Cn(i,[t.x2,t.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 FOe(e){const{ctx:A,path:t,realToCanvasMat:i}=e,o=t.color??"rgb(89, 148, 220)";if(!(!t.route||t.route.length<2))for(let s=0;s<t.route.length-1;s++){const r=t.route[s],a=t.route[s+1];!r||!a||n1({ctx:A,start:{x:r.x,y:r.y},end:{x:a.x,y:a.y},strokeWidth:t.stroke_width??.1,stroke:o,realToCanvasMat:i})}}function GOe(e){const{ctx:A,rect:t,realToCanvasMat:i}=e,o=t.color??"rgb(89, 148, 220)",s=t.is_filled??!1,r=t.has_stroke??!0,a=t.is_stroke_dashed??!1;bf({ctx:A,center:t.center,width:t.width,height:t.height,fill:s?o:void 0,stroke:r?o:void 0,strokeWidth:r?t.stroke_width:void 0,borderRadius:t.corner_radius,realToCanvasMat:i,isStrokeDashed:a})}var ROe="rgb(89, 148, 220)";function MOe(e){const{ctx:A,text:t,realToCanvasMat:i}=e,n=ROe,o=t.color??n,s=t.font_size??1;yfA({ctx:A,text:t.text??"",x:t.anchor_position.x,y:t.anchor_position.y,fontSize:s,color:o,realToCanvasMat:i,anchorAlignment:t.anchor_alignment??"center"})}function NOe(e){const{ctx:A,panel:t,realToCanvasMat:i,colorMap:n,drawBoardMaterial:o}=e,{width:s,height:r,center:a}=t;if(s!==void 0&&r!==void 0&&a){o&&bf({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}];f9({ctx:A,points:I,stroke:n.boardOutline,strokeWidth:.5,realToCanvasMat:i,closePath:!0})}}function CJ(e,A){if(e.length<3||A===0)return e;let t=0,i=0;for(const o of e)t+=o.x,i+=o.y;t/=e.length,i/=e.length;const n=[];for(const o of e){const s=o.x-t,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 vOe(e){const{ctx:A,hole:t,realToCanvasMat:i,colorMap:n,soldermaskMargin:o=0,drawSoldermask:s}=e;if(t.is_covered_with_solder_mask===!0&&s)return;const r=n.copper.top,a=o<0?Math.abs(o):0;if(t.shape==="circle"){dw({ctx:A,center:{x:t.x,y:t.y},radius:t.outer_diameter/2-a,fill:r,realToCanvasMat:i}),dw({ctx:A,center:{x:t.x,y:t.y},radius:t.hole_diameter/2,fill:n.drill,realToCanvasMat:i});return}if(t.shape==="oval"){BJ({ctx:A,center:{x:t.x,y:t.y},radius_x:t.outer_width/2-a,radius_y:t.outer_height/2-a,fill:r,realToCanvasMat:i,rotation:t.ccw_rotation}),BJ({ctx:A,center:{x:t.x,y:t.y},radius_x:t.hole_width/2,radius_y:t.hole_height/2,fill:n.drill,realToCanvasMat:i,rotation:t.ccw_rotation});return}if(t.shape==="pill"){TD({ctx:A,center:{x:t.x,y:t.y},width:t.outer_width-a*2,height:t.outer_height-a*2,fill:r,realToCanvasMat:i,rotation:t.ccw_rotation}),TD({ctx:A,center:{x:t.x,y:t.y},width:t.hole_width,height:t.hole_height,fill:n.drill,realToCanvasMat:i,rotation:t.ccw_rotation});return}if(t.shape==="circular_hole_with_rect_pad"){bf({ctx:A,center:{x:t.x,y:t.y},width:t.rect_pad_width-a*2,height:t.rect_pad_height-a*2,fill:r,realToCanvasMat:i,borderRadius:t.rect_border_radius?Math.max(0,t.rect_border_radius-a):0});const g=t.x+(t.hole_offset_x??0),c=t.y+(t.hole_offset_y??0);dw({ctx:A,center:{x:g,y:c},radius:t.hole_diameter/2,fill:n.drill,realToCanvasMat:i});return}if(t.shape==="pill_hole_with_rect_pad"){bf({ctx:A,center:{x:t.x,y:t.y},width:t.rect_pad_width-a*2,height:t.rect_pad_height-a*2,fill:r,realToCanvasMat:i,borderRadius:t.rect_border_radius?Math.max(0,t.rect_border_radius-a):0});const g=t.x+(t.hole_offset_x??0),c=t.y+(t.hole_offset_y??0);TD({ctx:A,center:{x:g,y:c},width:t.hole_width,height:t.hole_height,fill:n.drill,realToCanvasMat:i});return}if(t.shape==="rotated_pill_hole_with_rect_pad"){bf({ctx:A,center:{x:t.x,y:t.y},width:t.rect_pad_width-a*2,height:t.rect_pad_height-a*2,fill:r,realToCanvasMat:i,borderRadius:t.rect_border_radius?Math.max(0,t.rect_border_radius-a):0,rotation:t.rect_ccw_rotation});const g=t.x+(t.hole_offset_x??0),c=t.y+(t.hole_offset_y??0);TD({ctx:A,center:{x:g,y:c},width:t.hole_width,height:t.hole_height,fill:n.drill,realToCanvasMat:i,rotation:t.hole_ccw_rotation});return}if(t.shape==="hole_with_polygon_pad"){const g=t.pad_outline;if(g&&g.length>=3){const B=g.map(Q=>({x:t.x+Q.x,y:t.y+Q.y})),C=a>0?CJ(B,-a):B;C.length>=3&&i1({ctx:A,points:C,fill:r,realToCanvasMat:i})}const c=t.x+(t.hole_offset_x??0),I=t.y+(t.hole_offset_y??0),l=t.hole_shape;l==="circle"?dw({ctx:A,center:{x:c,y:I},radius:(t.hole_diameter??0)/2,fill:n.drill,realToCanvasMat:i}):l==="oval"?BJ({ctx:A,center:{x:c,y:I},radius_x:(t.hole_width??0)/2,radius_y:(t.hole_height??0)/2,fill:n.drill,realToCanvasMat:i}):l==="pill"?TD({ctx:A,center:{x:c,y:I},width:t.hole_width??0,height:t.hole_height??0,fill:n.drill,realToCanvasMat:i}):l==="rotated_pill"&&TD({ctx:A,center:{x:c,y:I},width:t.hole_width??0,height:t.hole_height??0,fill:n.drill,realToCanvasMat:i});return}}function LOe(e,A){return e==="bottom"?A.silkscreen.bottom:A.silkscreen.top}function UOe(e){const{ctx:A,circle:t,realToCanvasMat:i,colorMap:n}=e,o=LOe(t.layer,n);dw({ctx:A,center:t.center,radius:t.radius,stroke:o,strokeWidth:t.stroke_width,realToCanvasMat:i})}function HOe(e,A){return e==="bottom"?A.silkscreen.bottom:A.silkscreen.top}function YOe(e){const{ctx:A,line:t,realToCanvasMat:i,colorMap:n}=e,o=HOe(t.layer,n);n1({ctx:A,start:{x:t.x1,y:t.y1},end:{x:t.x2,y:t.y2},strokeWidth:t.stroke_width??.1,stroke:o,realToCanvasMat:i})}function JOe(e,A){return e==="bottom"?A.silkscreen.bottom:A.silkscreen.top}function TOe(e){const{ctx:A,oval:t,realToCanvasMat:i,colorMap:n}=e,o=JOe(t.layer,n);BJ({ctx:A,center:t.center,radius_x:t.radius_x,radius_y:t.radius_y,stroke:o,strokeWidth:.1,realToCanvasMat:i,rotation:t.ccw_rotation??0})}function KOe(e,A){return e==="bottom"?A.silkscreen.bottom:A.silkscreen.top}function POe(e){const{ctx:A,path:t,realToCanvasMat:i,colorMap:n}=e,o=KOe(t.layer,n);if(!(!t.route||t.route.length<2))for(let s=0;s<t.route.length-1;s++){const r=t.route[s],a=t.route[s+1];!r||!a||n1({ctx:A,start:{x:r.x,y:r.y},end:{x:a.x,y:a.y},strokeWidth:t.stroke_width??.1,stroke:o,realToCanvasMat:i})}}function qOe(e,A){return e==="bottom"?A.silkscreen.bottom:A.silkscreen.top}function OOe(e){const{ctx:A,pill:t,realToCanvasMat:i,colorMap:n}=e,o=qOe(t.layer,n);TD({ctx:A,center:t.center,width:t.width,height:t.height,stroke:o,strokeWidth:.2,realToCanvasMat:i})}function WOe(e,A){return e==="bottom"?A.silkscreen.bottom:A.silkscreen.top}function ZOe(e){const{ctx:A,rect:t,realToCanvasMat:i,colorMap:n}=e,o=WOe(t.layer,n);bf({ctx:A,center:t.center,width:t.width,height:t.height,fill:t.is_filled?o:"transparent",stroke:o,strokeWidth:t.stroke_width,realToCanvasMat:i})}function VOe(e,A){return e==="bottom"?A.silkscreen.bottom:A.silkscreen.top}function jOe(e){return e||"center"}function zOe(e){const{ctx:A,text:t,realToCanvasMat:i,colorMap:n}=e,o=t.text??"";if(!o)return;const s=VOe(t.layer,n),[r,a]=Cn(i,[t.anchor_position.x,t.anchor_position.y]),g=Math.abs(i.a),c=(t.font_size??1)*g,I=t.ccw_rotation??0,l=y9(o,c),B=jOe(t.anchor_alignment),C=dfA(B,l);A.save(),A.translate(r,a),I!==0&&A.rotate(-I*(Math.PI/180)),t.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 w=C.x+pfA({alignment:B,lineWidth:h[m],maxWidth:u,strokeWidth:d}),D=C.y+m*E;ffA({ctx:A,line:p,fontSize:c,startX:w,startY:D,layout:l})}),A.restore()}function XOe(e,A){return A.copper[e]??A.copper.top}function Zgt(e){return e.shape==="rect"||e.shape==="rotated_rect"?e.corner_radius??e.rect_border_radius??0:0}function $Oe(e){const{ctx:A,pad:t,realToCanvasMat:i,colorMap:n}=e,o=XOe(t.layer,n);if(t.shape==="rect"){bf({ctx:A,center:{x:t.x,y:t.y},width:t.width,height:t.height,fill:o,realToCanvasMat:i,borderRadius:Zgt(t)});return}if(t.shape==="rotated_rect"){bf({ctx:A,center:{x:t.x,y:t.y},width:t.width,height:t.height,fill:o,realToCanvasMat:i,borderRadius:Zgt(t),rotation:t.ccw_rotation??0});return}if(t.shape==="circle"){dw({ctx:A,center:{x:t.x,y:t.y},radius:t.radius,fill:o,realToCanvasMat:i});return}if(t.shape==="pill"){TD({ctx:A,center:{x:t.x,y:t.y},width:t.width,height:t.height,fill:o,realToCanvasMat:i});return}if(t.shape==="rotated_pill"){TD({ctx:A,center:{x:t.x,y:t.y},width:t.width,height:t.height,fill:o,realToCanvasMat:i,rotation:t.ccw_rotation??0});return}if(t.shape==="polygon"){t.points&&t.points.length>=3&&i1({ctx:A,points:t.points,fill:o,realToCanvasMat:i});return}}function $_(e){const{ctx:A,points:t}=e;if(t.length<3)return;const i=t[0];if(i){A.moveTo(i.x,i.y);for(let n=1;n<t.length;n++){const o=t[n];o&&A.lineTo(o.x,o.y)}A.closePath()}}function A5e(e){const{ctx:A,board:t,realToCanvasMat:i,soldermaskColor:n}=e,{width:o,height:s,center:r,outline:a}=t;if(a&&Array.isArray(a)&&a.length>=3){const g=a.map(c=>{const[I,l]=Cn(i,[c.x,c.y]);return{x:I,y:l}});A.beginPath(),$_({ctx:A,points:g}),A.fillStyle=n,A.fill()}else if(o!==void 0&&s!==void 0&&r){const[g,c]=Cn(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 Ak(e){const{ctx:A,cx:t,cy:i,width:n,height:o,radius:s}=e,r=t-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 t5e(e){const{ctx:A,cutout:t,realToCanvasMat:i,colorMap:n}=e;if(A.fillStyle=n.drill,t.shape==="rect"){const[o,s]=Cn(i,[t.center?.x??0,t.center?.y??0]),r=t.width*Math.abs(i.a),a=t.height*Math.abs(i.a),g=(t.corner_radius??0)*Math.abs(i.a);A.save(),A.translate(o,s),t.rotation&&A.rotate(-t.rotation*Math.PI/180),A.beginPath(),Ak({ctx:A,cx:0,cy:0,width:r,height:a,radius:g}),A.restore(),A.fill()}else if(t.shape==="circle"){const[o,s]=Cn(i,[t.center?.x??0,t.center?.y??0]),r=t.radius*Math.abs(i.a);A.beginPath(),A.arc(o,s,r,0,Math.PI*2),A.closePath(),A.fill()}else if(t.shape==="polygon"&&t.points&&t.points.length>=3){const o=t.points.map(s=>{const[r,a]=Cn(i,[s.x,s.y]);return{x:r,y:a}});A.beginPath(),$_({ctx:A,points:o}),A.fill()}}function Fb(e){const{ctx:A,cx:t,cy:i,width:n,height:o}=e;if(n>o){const s=o/2,r=n-o;A.moveTo(t-r/2,i-s),A.lineTo(t+r/2,i-s),A.arc(t+r/2,i,s,-Math.PI/2,Math.PI/2),A.lineTo(t-r/2,i+s),A.arc(t-r/2,i,s,Math.PI/2,-Math.PI/2)}else if(o>n){const s=n/2,r=o-n;A.moveTo(t+s,i-r/2),A.lineTo(t+s,i+r/2),A.arc(t,i+r/2,s,0,Math.PI),A.lineTo(t-s,i-r/2),A.arc(t,i-r/2,s,Math.PI,0)}else A.arc(t,i,n/2,0,Math.PI*2);A.closePath()}function e5e(e){const{ctx:A,hole:t,realToCanvasMat:i,colorMap:n,soldermaskOverCopperColor:o,drawSoldermask:s}=e,r=s&&t.is_covered_with_solder_mask===!0,a=s?t.soldermask_margin??0:0;r?(A.fillStyle=o,QJ({ctx:A,hole:t,realToCanvasMat:i,margin:0}),A.fill()):a<0?(A.fillStyle=n.drill,QJ({ctx:A,hole:t,realToCanvasMat:i,margin:0}),A.fill(),i5e({ctx:A,hole:t,realToCanvasMat:i,soldermaskOverCopperColor:o,margin:a})):a>0?(A.fillStyle=n.substrate,QJ({ctx:A,hole:t,realToCanvasMat:i,margin:a}),A.fill(),A.fillStyle=n.drill,QJ({ctx:A,hole:t,realToCanvasMat:i,margin:0}),A.fill()):(A.fillStyle=n.drill,QJ({ctx:A,hole:t,realToCanvasMat:i,margin:0}),A.fill())}function Vgt(e){return"ccw_rotation"in e&&typeof e.ccw_rotation=="number"?e.ccw_rotation:0}function QJ(e){const{ctx:A,hole:t,realToCanvasMat:i,margin:n}=e,o=Vgt(t);if(t.hole_shape==="circle"){const[s,r]=Cn(i,[t.x,t.y]),a=(t.hole_diameter/2+n)*Math.abs(i.a);A.beginPath(),A.arc(s,r,a,0,Math.PI*2),A.closePath()}else if(t.hole_shape==="square"){const[s,r]=Cn(i,[t.x,t.y]),a=(t.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(t.hole_shape==="oval"){const[s,r]=Cn(i,[t.x,t.y]),a=(t.hole_width/2+n)*Math.abs(i.a),g=(t.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(t.hole_shape==="rect"){const[s,r]=Cn(i,[t.x,t.y]),a=(t.hole_width+n*2)*Math.abs(i.a),g=(t.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(t.hole_shape==="pill"||t.hole_shape==="rotated_pill"){const[s,r]=Cn(i,[t.x,t.y]),a=(t.hole_width+n*2)*Math.abs(i.a),g=(t.hole_height+n*2)*Math.abs(i.a);A.save(),A.translate(s,r),o!==0&&A.rotate(-o*Math.PI/180),A.beginPath(),Fb({ctx:A,cx:0,cy:0,width:a,height:g}),A.restore()}}function i5e(e){const{ctx:A,hole:t,realToCanvasMat:i,soldermaskOverCopperColor:n,margin:o}=e,s=Math.abs(o),r=Vgt(t);if(A.fillStyle=n,t.hole_shape==="circle"){const[a,g]=Cn(i,[t.x,t.y]),c=t.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(t.hole_shape==="square"){const[a,g]=Cn(i,[t.x,t.y]),c=t.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(t.hole_shape==="oval"){const[a,g]=Cn(i,[t.x,t.y]),c=t.hole_width/2*Math.abs(i.a),I=t.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(t.hole_shape==="rect"){const[a,g]=Cn(i,[t.x,t.y]),c=t.hole_width*Math.abs(i.a),I=t.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(t.hole_shape==="pill"||t.hole_shape==="rotated_pill"){const[a,g]=Cn(i,[t.x,t.y]),c=t.hole_width*Math.abs(i.a),I=t.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(),Fb({ctx:A,cx:0,cy:0,width:c,height:I});const B=c-l*2,C=I-l*2;B>0&&C>0&&Fb({ctx:A,cx:0,cy:0,width:B,height:C}),A.fill("evenodd"),A.restore()}}function n5e(e){const{ctx:A,hole:t,realToCanvasMat:i,colorMap:n,soldermaskOverCopperColor:o,layer:s,drawSoldermask:r}=e;if(t.layers&&!t.layers.includes(s))return;const a=r&&t.is_covered_with_solder_mask===!0,g=r?t.soldermask_margin??0:0,c=n.copper.top;a?(A.fillStyle=o,hJ({ctx:A,hole:t,realToCanvasMat:i,margin:0}),A.fill()):g<0?(A.fillStyle=c,hJ({ctx:A,hole:t,realToCanvasMat:i,margin:0}),A.fill(),o5e({ctx:A,hole:t,realToCanvasMat:i,soldermaskOverCopperColor:o,margin:g})):g>0?(A.fillStyle=n.substrate,hJ({ctx:A,hole:t,realToCanvasMat:i,margin:g}),A.fill(),A.fillStyle=c,hJ({ctx:A,hole:t,realToCanvasMat:i,margin:0}),A.fill()):(A.fillStyle=c,hJ({ctx:A,hole:t,realToCanvasMat:i,margin:0}),A.fill())}function hJ(e){const{ctx:A,hole:t,realToCanvasMat:i,margin:n}=e;if(t.shape==="circle"){const[o,s]=Cn(i,[t.x,t.y]),r=(t.outer_diameter/2+n)*Math.abs(i.a);A.beginPath(),A.arc(o,s,r,0,Math.PI*2),A.closePath()}else if(t.shape==="oval"){const[o,s]=Cn(i,[t.x,t.y]),r=(t.outer_width/2+n)*Math.abs(i.a),a=(t.outer_height/2+n)*Math.abs(i.a);A.save(),A.translate(o,s),t.ccw_rotation&&t.ccw_rotation!==0&&A.rotate(-(t.ccw_rotation*Math.PI)/180),A.beginPath(),A.ellipse(0,0,r,a,0,0,Math.PI*2),A.closePath(),A.restore()}else if(t.shape==="pill"){const[o,s]=Cn(i,[t.x,t.y]),r=(t.outer_width+n*2)*Math.abs(i.a),a=(t.outer_height+n*2)*Math.abs(i.a);A.save(),A.translate(o,s),t.ccw_rotation&&t.ccw_rotation!==0&&A.rotate(-(t.ccw_rotation*Math.PI)/180),A.beginPath(),Fb({ctx:A,cx:0,cy:0,width:r,height:a}),A.restore()}else if(t.shape==="circular_hole_with_rect_pad"||t.shape==="pill_hole_with_rect_pad"){const[o,s]=Cn(i,[t.x,t.y]),r=(t.rect_pad_width+n*2)*Math.abs(i.a),a=(t.rect_pad_height+n*2)*Math.abs(i.a),g=(t.rect_border_radius??0)*Math.abs(i.a);A.beginPath(),Ak({ctx:A,cx:o,cy:s,width:r,height:a,radius:g})}else if(t.shape==="rotated_pill_hole_with_rect_pad"){const[o,s]=Cn(i,[t.x,t.y]),r=(t.rect_pad_width+n*2)*Math.abs(i.a),a=(t.rect_pad_height+n*2)*Math.abs(i.a),g=(t.rect_border_radius??0)*Math.abs(i.a);A.save(),A.translate(o,s),t.rect_ccw_rotation&&A.rotate(-t.rect_ccw_rotation*Math.PI/180),A.beginPath(),Ak({ctx:A,cx:0,cy:0,width:r,height:a,radius:g}),A.restore()}else if(t.shape==="hole_with_polygon_pad"&&t.pad_outline&&t.pad_outline.length>=3){const o=t.pad_outline.map(a=>({x:t.x+a.x,y:t.y+a.y})),r=(n!==0?CJ(o,n):o).map(a=>{const[g,c]=Cn(i,[a.x,a.y]);return{x:g,y:c}});A.beginPath(),$_({ctx:A,points:r})}}function o5e(e){const{ctx:A,hole:t,realToCanvasMat:i,soldermaskOverCopperColor:n,margin:o}=e,s=Math.abs(o);if(A.fillStyle=n,t.shape==="circle"){const[r,a]=Cn(i,[t.x,t.y]),g=t.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(t.shape==="oval"){const[r,a]=Cn(i,[t.x,t.y]),g=t.outer_width/2*Math.abs(i.a),c=t.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),t.ccw_rotation&&t.ccw_rotation!==0&&A.rotate(-(t.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(t.shape==="pill"){const[r,a]=Cn(i,[t.x,t.y]),g=t.outer_width*Math.abs(i.a),c=t.outer_height*Math.abs(i.a),I=s*Math.abs(i.a);A.save(),A.translate(r,a),t.ccw_rotation&&t.ccw_rotation!==0&&A.rotate(-(t.ccw_rotation*Math.PI)/180),A.beginPath(),Fb({ctx:A,cx:0,cy:0,width:g,height:c});const l=g-I*2,B=c-I*2;l>0&&B>0&&Fb({ctx:A,cx:0,cy:0,width:l,height:B}),A.fill("evenodd"),A.restore()}else if(t.shape==="circular_hole_with_rect_pad"||t.shape==="pill_hole_with_rect_pad"||t.shape==="rotated_pill_hole_with_rect_pad"){const[r,a]=Cn(i,[t.x,t.y]),g=t.rect_pad_width*Math.abs(i.a),c=t.rect_pad_height*Math.abs(i.a),I=s*Math.abs(i.a);A.save(),A.translate(r,a),t.shape==="rotated_pill_hole_with_rect_pad"&&t.rect_ccw_rotation&&A.rotate(-t.rect_ccw_rotation*Math.PI/180);const l=t.rect_border_radius?t.rect_border_radius*Math.abs(i.a):0;A.beginPath(),Ak({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);Ak({ctx:A,cx:0,cy:0,width:B,height:C,radius:Q})}A.fill("evenodd"),A.restore()}else if(t.shape==="hole_with_polygon_pad"&&t.pad_outline&&t.pad_outline.length>=3){const r=t.pad_outline.map(c=>({x:t.x+c.x,y:t.y+c.y}));A.save(),A.beginPath();const a=r.map(c=>{const[I,l]=Cn(i,[c.x,c.y]);return{x:I,y:l}});$_({ctx:A,points:a});const g=CJ(r,-s);if(g.length>=3){const c=g.map(I=>{const[l,B]=Cn(i,[I.x,I.y]);return{x:l,y:B}});$_({ctx:A,points:c})}A.fill("evenodd"),A.restore()}}function s5e(e){const{ctx:A,pad:t,realToCanvasMat:i,colorMap:n,soldermaskOverCopperColor:o,layer:s,drawSoldermask:r}=e;if(t.layer!==s)return;const a=r&&t.is_covered_with_solder_mask===!0,g=r?t.soldermask_margin??0:0;let c=g,I=g,l=g,B=g;(t.shape==="rect"||t.shape==="rotated_rect")&&(c=t.soldermask_margin_left??g,I=t.soldermask_margin_right??g,l=t.soldermask_margin_top??g,B=t.soldermask_margin_bottom??g);const C=n.copper[t.layer]||n.copper.top;a?(A.fillStyle=o,EJ({ctx:A,pad:t,realToCanvasMat:i,ml:0,mr:0,mt:0,mb:0}),A.fill()):c<0||I<0||l<0||B<0?(A.fillStyle=C,EJ({ctx:A,pad:t,realToCanvasMat:i,ml:0,mr:0,mt:0,mb:0}),A.fill(),r5e({ctx:A,pad:t,realToCanvasMat:i,soldermaskOverCopperColor:o,ml:c,mr:I,mt:l,mb:B})):c>0||I>0||l>0||B>0?(A.fillStyle=n.substrate,EJ({ctx:A,pad:t,realToCanvasMat:i,ml:c,mr:I,mt:l,mb:B}),A.fill(),A.fillStyle=C,EJ({ctx:A,pad:t,realToCanvasMat:i,ml:0,mr:0,mt:0,mb:0}),A.fill()):(A.fillStyle=C,EJ({ctx:A,pad:t,realToCanvasMat:i,ml:0,mr:0,mt:0,mb:0}),A.fill())}function EJ(e){const{ctx:A,pad:t,realToCanvasMat:i,ml:n,mr:o,mt:s,mb:r}=e,a=t.shape==="rotated_rect"||t.shape==="rotated_pill"?t.ccw_rotation??0:0;if(t.shape==="rect"||t.shape==="rotated_rect"){const g=t.corner_radius??t.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]=Cn(i,[t.x+B,t.y+C]),E=(t.width+n+o)*Math.abs(i.a),u=(t.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(),Ak({ctx:A,cx:0,cy:0,width:E,height:u,radius:d}),A.restore()}else if(t.shape==="circle"){const g=(n+o+s+r)/4,[c,I]=Cn(i,[t.x,t.y]),l=(t.radius+g)*Math.abs(i.a);A.beginPath(),A.arc(c,I,l,0,Math.PI*2),A.closePath()}else if(t.shape==="pill"||t.shape==="rotated_pill"){const g=(n+o)/2,[c,I]=Cn(i,[t.x,t.y]),l=(t.width+g*2)*Math.abs(i.a),B=(t.height+g*2)*Math.abs(i.a);A.save(),A.translate(c,I),a!==0&&A.rotate(-a*Math.PI/180),A.beginPath(),Fb({ctx:A,cx:0,cy:0,width:l,height:B}),A.restore()}else if(t.shape==="polygon"&&t.points&&t.points.length>=3){const g=(n+o+s+r)/4,I=(g!==0?CJ(t.points,g):t.points).map(l=>{const[B,C]=Cn(i,[l.x,l.y]);return{x:B,y:C}});A.beginPath(),$_({ctx:A,points:I})}}function r5e(e){const{ctx:A,pad:t,realToCanvasMat:i,soldermaskOverCopperColor:n,ml:o,mr:s,mt:r,mb:a}=e,g=t.shape==="rotated_rect"||t.shape==="rotated_pill"?t.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,t.shape==="rect"||t.shape==="rotated_rect"){const C=t.corner_radius??t.rect_border_radius??0,[Q,h]=Cn(i,[t.x,t.y]),E=t.width*Math.abs(i.a),u=t.height*Math.abs(i.a),d=C*Math.abs(i.a),p=c*Math.abs(i.a),m=I*Math.abs(i.a),w=l*Math.abs(i.a),D=B*Math.abs(i.a);A.save(),A.translate(Q,h),g!==0&&A.rotate(-g*Math.PI/180),A.beginPath(),Ak({ctx:A,cx:0,cy:0,width:E,height:u,radius:d});const S=E-p-m,k=u-w-D,x=(p-m)/2,N=(w-D)/2,M=Math.max(0,d-(p+m+w+D)/4);S>0&&k>0&&Ak({ctx:A,cx:x,cy:N,width:S,height:k,radius:M}),A.fill("evenodd"),A.restore()}else if(t.shape==="circle"){const C=Math.max(c,I,l,B),[Q,h]=Cn(i,[t.x,t.y]),E=t.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(t.shape==="pill"||t.shape==="rotated_pill"){const C=Math.max(c,I,l,B),[Q,h]=Cn(i,[t.x,t.y]),E=t.width*Math.abs(i.a),u=t.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(),Fb({ctx:A,cx:0,cy:0,width:E,height:u});const p=E-d*2,m=u-d*2;p>0&&m>0&&Fb({ctx:A,cx:0,cy:0,width:p,height:m}),A.fill("evenodd"),A.restore()}else if(t.shape==="polygon"&&t.points&&t.points.length>=3){const C=Math.max(c,I,l,B);A.save(),A.beginPath();const Q=t.points.map(E=>{const[u,d]=Cn(i,[E.x,E.y]);return{x:u,y:d}});$_({ctx:A,points:Q});const h=CJ(t.points,-C);if(h.length>=3){const E=h.map(u=>{const[d,p]=Cn(i,[u.x,u.y]);return{x:d,y:p}});$_({ctx:A,points:E})}A.fill("evenodd"),A.restore()}}function o1(e,A){const t=Math.hypot(e,A);return t<=Number.EPSILON?{x:0,y:0}:{x:e/t,y:A/t}}function a5e(e,A){const t=e.length;if(t<2)return{x:1,y:0};if(A<=0){const g=e[1],c=e[0];if(!g||!c)return{x:1,y:0};const I=o1(g.x-c.x,g.y-c.y);return I.x===0&&I.y===0?{x:1,y:0}:I}if(A>=t-1){const g=e[t-2],c=e[t-1];if(!g||!c)return{x:1,y:0};const I=o1(c.x-g.x,c.y-g.y);return I.x===0&&I.y===0?{x:1,y:0}:I}const i=e[A-1],n=e[A],o=e[A+1];if(!i||!n||!o)return{x:1,y:0};const s=o1(n.x-i.x,n.y-i.y),r=o1(o.x-n.x,o.y-n.y),a=o1(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 jgt(e){const A=[],t=[];for(let i=0;i<e.length;i++){const n=e[i];if(!n)continue;const o=a5e(e,i),s=o1(-o.y,o.x),r=n.width/2;A.push({x:n.x+s.x*r,y:n.y+s.y*r}),t.push({x:n.x-s.x*r,y:n.y-s.y*r})}return A.concat(t.reverse())}function zgt(e){const A=[];let t=[],i=null;for(const n of e??[]){if(!n||n.route_type!=="wire"){t.length>=2&&A.push(t),t=[],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&&(t.length>=2&&A.push(t),t=[]),i=o,t.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 t.length>=2&&A.push(t),A}function Xgt(e){if(e.length<2)return!1;const A=e[0]?.width;return typeof A!="number"?!1:e.some(t=>Math.abs(t.width-A)>Number.EPSILON)}function g5e(e){const{ctx:A,trace:t,realToCanvasMat:i,soldermaskOverCopperColor:n,layer:o,drawSoldermask:s}=e;if(!s||!t.route||!Array.isArray(t.route)||t.route.length<2)return;const r=zgt(t.route);for(const a of r)if(a[0]?.layer===o){if(Xgt(a)){const c=jgt(a);i1({ctx:A,points:c,fill:n,realToCanvasMat:i});continue}for(let c=0;c<a.length-1;c++){const I=a[c],l=a[c+1];!I||!l||n1({ctx:A,start:{x:I.x,y:I.y},end:{x:l.x,y:l.y},strokeWidth:I.width,stroke:n,realToCanvasMat:i,lineCap:"round"})}}}function c5e(e){const{ctx:A,via:t,realToCanvasMat:i,colorMap:n}=e,[o,s]=Cn(i,[t.x,t.y]),r=t.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 I5e(e){const{ctx:A,board:t,elements:i,realToCanvasMat:n,colorMap:o,layer:s,drawSoldermask:r}=e,a=o.soldermask[s]??o.soldermask.top,g=o.soldermaskOverCopper[s]??o.soldermaskOverCopper.top;if(r&&A5e({ctx:A,board:t,realToCanvasMat:n,soldermaskColor:a}),r)for(const c of i)c.type==="pcb_trace"&&g5e({ctx:A,trace:c,realToCanvasMat:n,soldermaskOverCopperColor:g,layer:s,drawSoldermask:r});for(const c of i)l5e({ctx:A,element:c,realToCanvasMat:n,colorMap:o,soldermaskOverCopperColor:g,layer:s,drawSoldermask:r})}function l5e(e){const{ctx:A,element:t,realToCanvasMat:i,colorMap:n,soldermaskOverCopperColor:o,layer:s,drawSoldermask:r}=e;if(t.type==="pcb_smtpad")s5e({ctx:A,pad:t,realToCanvasMat:i,colorMap:n,soldermaskOverCopperColor:o,layer:s,drawSoldermask:r});else if(t.type==="pcb_plated_hole")n5e({ctx:A,hole:t,realToCanvasMat:i,colorMap:n,soldermaskOverCopperColor:o,layer:s,drawSoldermask:r});else if(t.type==="pcb_hole")e5e({ctx:A,hole:t,realToCanvasMat:i,colorMap:n,soldermaskOverCopperColor:o,drawSoldermask:r});else if(t.type==="pcb_via")c5e({ctx:A,via:t,realToCanvasMat:i,colorMap:n});else if(t.type==="pcb_cutout")t5e({ctx:A,cutout:t,realToCanvasMat:i,colorMap:n});else if(t.type==="pcb_trace")return}function B5e(e,A){return A.copper[e]??A.copper.top}function C5e(e){const{ctx:A,trace:t,realToCanvasMat:i,colorMap:n}=e;if(!t.route||!Array.isArray(t.route)||t.route.length<2)return;const o=zgt(t.route);for(const s of o){const r=s[0]?.layer;if(!r)continue;const a=B5e(r,n);if(Xgt(s)){const g=jgt(s);i1({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||n1({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 Q5e(e){const{ctx:A,via:t,realToCanvasMat:i,colorMap:n}=e;dw({ctx:A,center:{x:t.x,y:t.y},radius:t.outer_diameter/2,fill:n.copper.top,realToCanvasMat:i}),dw({ctx:A,center:{x:t.x,y:t.y},radius:t.hole_diameter/2,fill:n.drill,realToCanvasMat:i})}function FG(e,A){if(!A.layers||A.layers.length===0)return!0;const t=m1A(e);return t.length===0?!0:t.some(i=>A.layers.includes(i))}var Vd={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:{top:"#FF00FF",bottom:"rgb(38, 233, 255)"},keepout:"#FF6B6B",fabricationNote:"rgba(255, 255, 255, 0.5)"},KC=class{ctx;colorMap;realToCanvasMat;constructor(e){if("getContext"in e&&typeof e.getContext=="function"){const A=e.getContext("2d");if(!A)throw new Error("Failed to get 2D rendering context from canvas");this.ctx=A}else this.ctx=e;this.colorMap={...Vd},this.realToCanvasMat=V3e()}configure(e){e.colorOverrides&&(this.colorMap={...this.colorMap,...e.colorOverrides,copper:{...this.colorMap.copper,...e.colorOverrides.copper},silkscreen:{...this.colorMap.silkscreen,...e.colorOverrides.silkscreen},soldermask:{...this.colorMap.soldermask,...e.colorOverrides.soldermask},soldermaskWithCopperUnderneath:{...this.colorMap.soldermaskWithCopperUnderneath,...e.colorOverrides.soldermaskWithCopperUnderneath},soldermaskOverCopper:{...this.colorMap.soldermaskOverCopper,...e.colorOverrides.soldermaskOverCopper}})}setCameraBounds(e){const A=this.ctx.canvas,t=A.width,i=A.height,n=e.maxX-e.minX,o=e.maxY-e.minY,s=t/n,r=i/o,a=Math.min(s,r),g=(t-n*a)/2,c=(i-o*a)/2;this.realToCanvasMat=j3e(p9(g,c),z3e(a,-a),p9(-e.minX,-e.maxY))}drawElements(e,A={}){const t=e.find(o=>o.type==="pcb_board"),i=e.find(o=>o.type==="pcb_panel");i&&NOe({ctx:this.ctx,panel:i,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap,drawBoardMaterial:A.drawBoardMaterial??!1}),t&&X3e({ctx:this.ctx,board:t,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap,drawBoardMaterial:A.drawBoardMaterial??!1,minBoardOutlineStrokePx:A.minBoardOutlineStrokePx});for(const o of e)FG(o,A)&&(o.type==="pcb_smtpad"&&$Oe({ctx:this.ctx,pad:o,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}),o.type==="pcb_copper_text"&&IOe({ctx:this.ctx,text:o,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}));const n=A.drawSoldermask??!1;t&&I5e({ctx:this.ctx,board:t,elements:e,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap,layer:"top",drawSoldermask:n});for(const o of e)FG(o,A)&&(o.type==="pcb_silkscreen_text"&&zOe({ctx:this.ctx,text:o,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}),o.type==="pcb_silkscreen_rect"&&ZOe({ctx:this.ctx,rect:o,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}),o.type==="pcb_silkscreen_circle"&&UOe({ctx:this.ctx,circle:o,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}),o.type==="pcb_silkscreen_line"&&YOe({ctx:this.ctx,line:o,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}),o.type==="pcb_silkscreen_path"&&POe({ctx:this.ctx,path:o,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}),o.type==="pcb_silkscreen_pill"&&OOe({ctx:this.ctx,pill:o,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}),o.type==="pcb_silkscreen_oval"&&TOe({ctx:this.ctx,oval:o,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}));for(const o of e)FG(o,A)&&(o.type==="pcb_copper_pour"&&tOe({ctx:this.ctx,pour:o,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}),o.type==="pcb_trace"&&(!n||!t)&&C5e({ctx:this.ctx,trace:o,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}));for(const o of e)FG(o,A)&&o.type==="pcb_hole"&&DOe({ctx:this.ctx,hole:o,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap,soldermaskMargin:n?o.soldermask_margin:void 0,drawSoldermask:n});for(const o of e)FG(o,A)&&(o.type==="pcb_plated_hole"&&vOe({ctx:this.ctx,hole:o,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap,soldermaskMargin:n?o.soldermask_margin:void 0,drawSoldermask:n}),o.type==="pcb_via"&&Q5e({ctx:this.ctx,via:o,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}));for(const o of e)FG(o,A)&&o.type==="pcb_cutout"&&hOe({ctx:this.ctx,cutout:o,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap});for(const o of e)FG(o,A)&&(o.type==="pcb_keepout"&&bOe({ctx:this.ctx,keepout:o,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}),o.type==="pcb_fabrication_note_text"&&wOe({ctx:this.ctx,text:o,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}),o.type==="pcb_fabrication_note_rect"&&yOe({ctx:this.ctx,rect:o,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}),o.type==="pcb_note_rect"&&GOe({realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap,ctx:this.ctx,rect:o}),o.type==="pcb_fabrication_note_path"&&fOe({ctx:this.ctx,path:o,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}),o.type==="pcb_note_path"&&FOe({ctx:this.ctx,path:o,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}),o.type==="pcb_note_text"&&MOe({ctx:this.ctx,text:o,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}),o.type==="pcb_note_line"&&kOe({ctx:this.ctx,line:o,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}),o.type==="pcb_note_dimension"&&_Oe({ctx:this.ctx,pcbNoteDimension:o,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}),o.type==="pcb_fabrication_note_dimension"&&pOe({ctx:this.ctx,pcbFabricationNoteDimension:o,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}),o.type==="pcb_courtyard_circle"&&BOe({ctx:this.ctx,circle:o,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}),o.type==="pcb_courtyard_rect"&&QOe({ctx:this.ctx,rect:o,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}))}};const h5e=zwt(eJt);var wfA,$gt;function E5e(){if($gt)return wfA;$gt=1;var e=Object.defineProperty,A=Object.getOwnPropertyDescriptor,t=Object.getOwnPropertyNames,i=Object.prototype.hasOwnProperty,n=(h,E)=>{for(var u in E)e(h,u,{get:E[u],enumerable:!0})},o=(h,E,u,d)=>{if(E&&typeof E=="object"||typeof E=="function")for(let p of t(E))!i.call(h,p)&&p!==u&&e(h,p,{get:()=>E[p],enumerable:!(d=A(E,p))||d.enumerable});return h},s=h=>o(e({},"__esModule",{value:!0}),h),r={};n(r,{SuperGrid:()=>Q,toMMSI:()=>C,toMeterSI:()=>B}),wfA=s(r);var a=E0(),g=h5e,c=LbA(),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:w="rgba(0,0,0,0.1)",textColor:D=(E=h.majorColor)!=null?E:"rgba(0,0,0,0.5)",width:S,height:k,screenSpaceCellSize:x=200,stringifyCoord:N=(H,O,Z)=>`${B(H,Z)}, ${B(O,Z)}`}=h,M=Math.ceil(S/x)+2,L=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,eA=x/10**Math.log10(h.transform.a)/O;function aA(_A,dA,PA){const JA=_A;let it,pA,tt;for(it=dA.x;it<=PA.x;it+=JA)pA=(0,g.applyToPoint)(h.transform,{x:it,y:dA.y}),tt=(0,g.applyToPoint)(h.transform,{x:it,y:PA.y}),H.beginPath(),H.moveTo(pA.x,pA.y),H.lineTo(tt.x,tt.y),H.stroke();const OA=I(dA.y,PA.y,JA*Z);for(const HA of OA)pA=(0,g.applyToPoint)(h.transform,{x:dA.x,y:HA}),tt=(0,g.applyToPoint)(h.transform,{x:PA.x,y:HA}),H.beginPath(),H.moveTo(pA.x,pA.y),H.lineTo(tt.x,tt.y),H.stroke()}function tA(_A,dA,PA){const JA=_A;let it;for(it=dA.x;it<=PA.x;it+=JA)for(const pA of I(dA.y,PA.y,JA*Z)){const tt=(0,g.applyToPoint)(h.transform,{x:it,y:pA});H.fillStyle=D,H.font="12px sans-serif",H.fillText(N(it,pA,_A),tt.x+2,tt.y-2)}}H.clearRect(0,0,S,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*L*Z},bA=O*5,GA={x:Math.floor((nA.x-bA)/bA)*bA,y:Math.floor((nA.y-bA)/bA+(Z==-1?2:0))*bA},YA={x:GA.x+bA*M,y:GA.y+bA*L*Z};H.globalAlpha=1,H.strokeStyle=m,aA(O,rA,lA),tA(bA,GA,YA),H.globalAlpha=1-eA,aA(bA/10,GA,YA),H.globalAlpha=1-eA,H.strokeStyle=w,aA(O/10,rA,lA),H.globalAlpha=Math.max(((1-eA)*10-5)/5,0),tA(bA/10,GA,YA),H.globalAlpha=1;const QA=(0,g.applyToPoint)(h.transform,d);H.font="12px sans-serif",H.fillStyle=D,H.fillText(N(d.x,d.y,O),QA.x+2,QA.y-2),H.strokeStyle=m,H.strokeRect(QA.x-5,QA.y-5,10,10)},[u,h.transform,d,S,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}),eA=l(O,$);p(eA)};return(0,c.jsx)("canvas",{onMouseUp:H=>{H.button===1&&Y(H)},onDoubleClick:Y,ref:u,width:h.width,height:h.height})};return wfA}var w9=E5e();function u5e(e){if(e.sheet)return e.sheet;for(var A=0;A<document.styleSheets.length;A++)if(document.styleSheets[A].ownerNode===e)return document.styleSheets[A]}function d5e(e){var A=document.createElement("style");return A.setAttribute("data-emotion",e.key),e.nonce!==void 0&&A.setAttribute("nonce",e.nonce),A.appendChild(document.createTextNode("")),A.setAttribute("data-s",""),A}var p5e=(function(){function e(t){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=t.speedy===void 0?!0:t.speedy,this.tags=[],this.ctr=0,this.nonce=t.nonce,this.key=t.key,this.container=t.container,this.prepend=t.prepend,this.insertionPoint=t.insertionPoint,this.before=null}var A=e.prototype;return A.hydrate=function(i){i.forEach(this._insertTag)},A.insert=function(i){this.ctr%(this.isSpeedy?65e3:1)===0&&this._insertTag(d5e(this));var n=this.tags[this.tags.length-1];if(this.isSpeedy){var o=u5e(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},e})(),Xu="-ms-",D9="-moz-",za="-webkit-",Act="comm",DfA="rule",SfA="decl",f5e="@import",tct="@keyframes",y5e="@layer",m5e=Math.abs,S9=String.fromCharCode,w5e=Object.assign;function D5e(e,A){return UE(e,0)^45?(((A<<2^UE(e,0))<<2^UE(e,1))<<2^UE(e,2))<<2^UE(e,3):0}function ect(e){return e.trim()}function S5e(e,A){return(e=A.exec(e))?e[0]:e}function Xa(e,A,t){return e.replace(A,t)}function bfA(e,A){return e.indexOf(A)}function UE(e,A){return e.charCodeAt(A)|0}function uJ(e,A,t){return e.slice(A,t)}function KD(e){return e.length}function xfA(e){return e.length}function b9(e,A){return A.push(e),e}function b5e(e,A){return e.map(A).join("")}var x9=1,s1=1,ict=0,xf=0,PC=0,r1="";function _9(e,A,t,i,n,o,s){return{value:e,root:A,parent:t,type:i,props:n,children:o,line:x9,column:s1,length:s,return:""}}function dJ(e,A){return w5e(_9("",null,null,"",null,null,0),e,{length:-e.length},A)}function x5e(){return PC}function _5e(){return PC=xf>0?UE(r1,--xf):0,s1--,PC===10&&(s1=1,x9--),PC}function J0(){return PC=xf<ict?UE(r1,xf++):0,s1++,PC===10&&(s1=1,x9++),PC}function PD(){return UE(r1,xf)}function k9(){return xf}function pJ(e,A){return uJ(r1,e,A)}function fJ(e){switch(e){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 nct(e){return x9=s1=1,ict=KD(r1=e),xf=0,[]}function oct(e){return r1="",e}function F9(e){return ect(pJ(xf-1,_fA(e===91?e+2:e===40?e+1:e)))}function k5e(e){for(;(PC=PD())&&PC<33;)J0();return fJ(e)>2||fJ(PC)>3?"":" "}function F5e(e,A){for(;--A&&J0()&&!(PC<48||PC>102||PC>57&&PC<65||PC>70&&PC<97););return pJ(e,k9()+(A<6&&PD()==32&&J0()==32))}function _fA(e){for(;J0();)switch(PC){case e:return xf;case 34:case 39:e!==34&&e!==39&&_fA(PC);break;case 40:e===41&&_fA(e);break;case 92:J0();break}return xf}function G5e(e,A){for(;J0()&&e+PC!==57;)if(e+PC===84&&PD()===47)break;return"/*"+pJ(A,xf-1)+"*"+S9(e===47?e:J0())}function R5e(e){for(;!fJ(PD());)J0();return pJ(e,xf)}function M5e(e){return oct(G9("",null,null,null,[""],e=nct(e),0,[0],e))}function G9(e,A,t,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,w=i,D=d;h;)switch(C=u,u=J0()){case 40:if(C!=108&&UE(D,I-1)==58){bfA(D+=Xa(F9(u),"&","&\f"),"&\f")!=-1&&(E=-1);break}case 34:case 39:case 91:D+=F9(u);break;case 9:case 10:case 13:case 32:D+=k5e(C);break;case 92:D+=F5e(k9()-1,7);continue;case 47:switch(PD()){case 42:case 47:b9(N5e(G5e(J0(),k9()),A,t),a);break;default:D+="/"}break;case 123*Q:r[g++]=KD(D)*E;case 125*Q:case 59:case 0:switch(u){case 0:case 125:h=0;case 59+c:E==-1&&(D=Xa(D,/\f/g,"")),B>0&&KD(D)-I&&b9(B>32?rct(D+";",i,t,I-1):rct(Xa(D," ","")+";",i,t,I-2),a);break;case 59:D+=";";default:if(b9(w=sct(D,A,t,g,c,n,r,d,p=[],m=[],I),o),u===123)if(c===0)G9(D,A,w,w,p,o,I,r,m);else switch(l===99&&UE(D,3)===110?100:l){case 100:case 108:case 109:case 115:G9(e,w,w,i&&b9(sct(e,w,w,0,0,n,r,d,n,p=[],I),m),n,m,I,r,i?p:m);break;default:G9(D,w,w,w,[""],m,0,r,m)}}g=c=B=0,Q=E=1,d=D="",I=s;break;case 58:I=1+KD(D),B=C;default:if(Q<1){if(u==123)--Q;else if(u==125&&Q++==0&&_5e()==125)continue}switch(D+=S9(u),u*Q){case 38:E=c>0?1:(D+="\f",-1);break;case 44:r[g++]=(KD(D)-1)*E,E=1;break;case 64:PD()===45&&(D+=F9(J0())),l=PD(),c=I=KD(d=D+=R5e(k9())),u++;break;case 45:C===45&&KD(D)==2&&(Q=0)}}return o}function sct(e,A,t,i,n,o,s,r,a,g,c){for(var I=n-1,l=n===0?o:[""],B=xfA(l),C=0,Q=0,h=0;C<i;++C)for(var E=0,u=uJ(e,I+1,I=m5e(Q=s[C])),d=e;E<B;++E)(d=ect(Q>0?l[E]+" "+u:Xa(u,/&\f/g,l[E])))&&(a[h++]=d);return _9(e,A,t,n===0?DfA:r,a,g,c)}function N5e(e,A,t){return _9(e,A,t,Act,S9(x5e()),uJ(e,2,-2),0)}function rct(e,A,t,i){return _9(e,A,t,SfA,uJ(e,0,i),uJ(e,i+1,-1),i)}function a1(e,A){for(var t="",i=xfA(e),n=0;n<i;n++)t+=A(e[n],n,e,A)||"";return t}function v5e(e,A,t,i){switch(e.type){case y5e:if(e.children.length)break;case f5e:case SfA:return e.return=e.return||e.value;case Act:return"";case tct:return e.return=e.value+"{"+a1(e.children,i)+"}";case DfA:e.value=e.props.join(",")}return KD(t=a1(e.children,i))?e.return=e.value+"{"+t+"}":""}function L5e(e){var A=xfA(e);return function(t,i,n,o){for(var s="",r=0;r<A;r++)s+=e[r](t,i,n,o)||"";return s}}function U5e(e){return function(A){A.root||(A=A.return)&&e(A)}}function H5e(e){var A=Object.create(null);return function(t){return A[t]===void 0&&(A[t]=e(t)),A[t]}}var Y5e=function(A,t,i){for(var n=0,o=0;n=o,o=PD(),n===38&&o===12&&(t[i]=1),!fJ(o);)J0();return pJ(A,xf)},J5e=function(A,t){var i=-1,n=44;do switch(fJ(n)){case 0:n===38&&PD()===12&&(t[i]=1),A[i]+=Y5e(xf-1,t,i);break;case 2:A[i]+=F9(n);break;case 4:if(n===44){A[++i]=PD()===58?"&\f":"",t[i]=A[i].length;break}default:A[i]+=S9(n)}while(n=J0());return A},T5e=function(A,t){return oct(J5e(nct(A),t))},act=new WeakMap,K5e=function(A){if(!(A.type!=="rule"||!A.parent||A.length<1)){for(var t=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&&t.charCodeAt(0)!==58&&!act.get(i))&&!n){act.set(A,!0);for(var o=[],s=T5e(t,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]}}},P5e=function(A){if(A.type==="decl"){var t=A.value;t.charCodeAt(0)===108&&t.charCodeAt(2)===98&&(A.return="",A.value="")}};function gct(e,A){switch(D5e(e,A)){case 5103:return za+"print-"+e+e;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 za+e+e;case 5349:case 4246:case 4810:case 6968:case 2756:return za+e+D9+e+Xu+e+e;case 6828:case 4268:return za+e+Xu+e+e;case 6165:return za+e+Xu+"flex-"+e+e;case 5187:return za+e+Xa(e,/(\w+).+(:[^]+)/,za+"box-$1$2"+Xu+"flex-$1$2")+e;case 5443:return za+e+Xu+"flex-item-"+Xa(e,/flex-|-self/,"")+e;case 4675:return za+e+Xu+"flex-line-pack"+Xa(e,/align-content|flex-|-self/,"")+e;case 5548:return za+e+Xu+Xa(e,"shrink","negative")+e;case 5292:return za+e+Xu+Xa(e,"basis","preferred-size")+e;case 6060:return za+"box-"+Xa(e,"-grow","")+za+e+Xu+Xa(e,"grow","positive")+e;case 4554:return za+Xa(e,/([^-])(transform)/g,"$1"+za+"$2")+e;case 6187:return Xa(Xa(Xa(e,/(zoom-|grab)/,za+"$1"),/(image-set)/,za+"$1"),e,"")+e;case 5495:case 3959:return Xa(e,/(image-set\([^]*)/,za+"$1$`$1");case 4968:return Xa(Xa(e,/(.+:)(flex-)?(.*)/,za+"box-pack:$3"+Xu+"flex-pack:$3"),/s.+-b[^;]+/,"justify")+za+e+e;case 4095:case 3583:case 4068:case 2532:return Xa(e,/(.+)-inline(.+)/,za+"$1$2")+e;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(KD(e)-1-A>6)switch(UE(e,A+1)){case 109:if(UE(e,A+4)!==45)break;case 102:return Xa(e,/(.+:)(.+)-([^]+)/,"$1"+za+"$2-$3$1"+D9+(UE(e,A+3)==108?"$3":"$2-$3"))+e;case 115:return~bfA(e,"stretch")?gct(Xa(e,"stretch","fill-available"),A)+e:e}break;case 4949:if(UE(e,A+1)!==115)break;case 6444:switch(UE(e,KD(e)-3-(~bfA(e,"!important")&&10))){case 107:return Xa(e,":",":"+za)+e;case 101:return Xa(e,/(.+:)([^;!]+)(;|!.+)?/,"$1"+za+(UE(e,14)===45?"inline-":"")+"box$3$1"+za+"$2$3$1"+Xu+"$2box$3")+e}break;case 5936:switch(UE(e,A+11)){case 114:return za+e+Xu+Xa(e,/[svh]\w+-[tblr]{2}/,"tb")+e;case 108:return za+e+Xu+Xa(e,/[svh]\w+-[tblr]{2}/,"tb-rl")+e;case 45:return za+e+Xu+Xa(e,/[svh]\w+-[tblr]{2}/,"lr")+e}return za+e+Xu+e+e}return e}var q5e=function(A,t,i,n){if(A.length>-1&&!A.return)switch(A.type){case SfA:A.return=gct(A.value,A.length);break;case tct:return a1([dJ(A,{value:Xa(A.value,"@","@"+za)})],n);case DfA:if(A.length)return b5e(A.props,function(o){switch(S5e(o,/(::plac\w+|:read-\w+)/)){case":read-only":case":read-write":return a1([dJ(A,{props:[Xa(o,/:(read-\w+)/,":"+D9+"$1")]})],n);case"::placeholder":return a1([dJ(A,{props:[Xa(o,/:(plac\w+)/,":"+za+"input-$1")]}),dJ(A,{props:[Xa(o,/:(plac\w+)/,":"+D9+"$1")]}),dJ(A,{props:[Xa(o,/:(plac\w+)/,Xu+"input-$1")]})],n)}return""})}},O5e=[q5e],W5e=function(A){var t=A.key;if(t==="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||O5e,o={},s,r=[];s=A.container||document.head,Array.prototype.forEach.call(document.querySelectorAll('style[data-emotion^="'+t+' "]'),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=[K5e,P5e];{var c,I=[v5e,U5e(function(Q){c.insert(Q)})],l=L5e(g.concat(n,I)),B=function(h){return a1(M5e(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:t,sheet:new p5e({key:t,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 Z5e(e){for(var A=0,t,i=0,n=e.length;n>=4;++i,n-=4)t=e.charCodeAt(i)&255|(e.charCodeAt(++i)&255)<<8|(e.charCodeAt(++i)&255)<<16|(e.charCodeAt(++i)&255)<<24,t=(t&65535)*1540483477+((t>>>16)*59797<<16),t^=t>>>24,A=(t&65535)*1540483477+((t>>>16)*59797<<16)^(A&65535)*1540483477+((A>>>16)*59797<<16);switch(n){case 3:A^=(e.charCodeAt(i+2)&255)<<16;case 2:A^=(e.charCodeAt(i+1)&255)<<8;case 1:A^=e.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 V5e={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},j5e=/[A-Z]|^ms/g,z5e=/_EMO_([^_]+?)_([^]*?)_EMO_/g,cct=function(A){return A.charCodeAt(1)===45},Ict=function(A){return A!=null&&typeof A!="boolean"},kfA=H5e(function(e){return cct(e)?e:e.replace(j5e,"-$&").toLowerCase()}),lct=function(A,t){switch(A){case"animation":case"animationName":if(typeof t=="string")return t.replace(z5e,function(i,n,o){return tk={name:n,styles:o,next:tk},n})}return V5e[A]!==1&&!cct(A)&&typeof t=="number"&&t!==0?t+"px":t};function R9(e,A,t){if(t==null)return"";var i=t;if(i.__emotion_styles!==void 0)return i;switch(typeof t){case"boolean":return"";case"object":{var n=t;if(n.anim===1)return tk={name:n.name,styles:n.styles,next:tk},n.name;var o=t;if(o.styles!==void 0){var s=o.next;if(s!==void 0)for(;s!==void 0;)tk={name:s.name,styles:s.styles,next:tk},s=s.next;var r=o.styles+";";return r}return X5e(e,A,t)}}var a=t;if(A==null)return a;var g=A[a];return g!==void 0?g:a}function X5e(e,A,t){var i="";if(Array.isArray(t))for(var n=0;n<t.length;n++)i+=R9(e,A,t[n])+";";else for(var o in t){var s=t[o];if(typeof s!="object"){var r=s;A!=null&&A[r]!==void 0?i+=o+"{"+A[r]+"}":Ict(r)&&(i+=kfA(o)+":"+lct(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++)Ict(s[a])&&(i+=kfA(o)+":"+lct(o,s[a])+";");else{var g=R9(e,A,s);switch(o){case"animation":case"animationName":{i+=kfA(o)+":"+g+";";break}default:i+=o+"{"+g+"}"}}}return i}var Bct=/label:\s*([^\s;{]+)\s*(;|$)/g,tk;function FfA(e,A,t){if(e.length===1&&typeof e[0]=="object"&&e[0]!==null&&e[0].styles!==void 0)return e[0];var i=!0,n="";tk=void 0;var o=e[0];if(o==null||o.raw===void 0)i=!1,n+=R9(t,A,o);else{var s=o;n+=s[0]}for(var r=1;r<e.length;r++)if(n+=R9(t,A,e[r]),i){var a=o;n+=a[r]}Bct.lastIndex=0;for(var g="",c;(c=Bct.exec(n))!==null;)g+="-"+c[1];var I=Z5e(n)+g;return{name:I,styles:n,next:tk}}function Cct(e,A,t){var i="";return t.split(" ").forEach(function(n){e[n]!==void 0?A.push(e[n]+";"):n&&(i+=n+" ")}),i}var $5e=function(A,t,i){var n=A.key+"-"+t.name;A.registered[n]===void 0&&(A.registered[n]=t.styles)},A8e=function(A,t,i){$5e(A,t);var n=A.key+"-"+t.name;if(A.inserted[t.name]===void 0){var o=t;do A.insert(t===o?"."+n:"",o,A.sheet,!0),o=o.next;while(o!==void 0)}};function Qct(e,A){if(e.inserted[A.name]===void 0)return e.insert("",A,e.sheet,!0)}function hct(e,A,t){var i=[],n=Cct(e,i,t);return i.length<2?t:n+A(i)}var t8e=function(A){var t=W5e(A);t.sheet.speedy=function(r){this.isSpeedy=r},t.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=FfA(g,t.registered,void 0);return A8e(t,I),t.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=FfA(g,t.registered),l="animation-"+I.name;return Qct(t,{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=FfA(g,t.registered);Qct(t,I)},s=function(){for(var a=arguments.length,g=new Array(a),c=0;c<a;c++)g[c]=arguments[c];return hct(t.registered,i,e8e(g))};return{css:i,cx:s,injectGlobal:o,keyframes:n,hydrate:function(a){a.forEach(function(g){t.inserted[g]=!0})},flush:function(){t.registered={},t.inserted={},t.sheet.flush()},sheet:t.sheet,cache:t,getRegisteredStyles:Cct.bind(null,t.registered),merge:hct.bind(null,t.registered,i)}},e8e=function e(A){for(var t="",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=e(n);else{o="";for(var s in n)n[s]&&s&&(o&&(o+=" "),o+=s)}break}default:o=n}o&&(t&&(t+=" "),t+=o)}}return t},i8e=t8e({key:"css"}),g1=i8e.css,n8e=Object.create,Ect=Object.defineProperty,o8e=Object.getOwnPropertyDescriptor,uct=Object.getOwnPropertyNames,s8e=Object.getPrototypeOf,r8e=Object.prototype.hasOwnProperty,va=(e,A)=>function(){return A||(0,e[uct(e)[0]])((A={exports:{}}).exports,A),A.exports},a8e=(e,A,t,i)=>{if(A&&typeof A=="object"||typeof A=="function")for(let n of uct(A))!r8e.call(e,n)&&n!==t&&Ect(e,n,{get:()=>A[n],enumerable:!(i=o8e(A,n))||i.enumerable});return e},dct=(e,A,t)=>(t=e!=null?n8e(s8e(e)):{},a8e(Ect(t,"default",{value:e,enumerable:!0}),e)),g8e=va({"node_modules/svgson/dist/svgson.umd.js"(e,A){(function(t,i){typeof e=="object"&&typeof A<"u"?A.exports=i():typeof define=="function"&&define.amd?define(i):(t=typeof globalThis<"u"?globalThis:t||self,t.svgson=i())})(e,function(){var t=function(tA){return tA!=null&&(i(tA)||n(tA)||!!tA._isBuffer)};function i(tA){return!!tA.constructor&&typeof tA.constructor.isBuffer=="function"&&tA.constructor.isBuffer(tA)}function n(tA){return typeof tA.readFloatLE=="function"&&typeof tA.slice=="function"&&i(tA.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":t(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(tA,nA){return nA={exports:{}},tA(nA,nA.exports),nA.exports}var a=r(function(tA){(function(){function nA(rA,lA){if(typeof lA!="function")return rA;var fA={};for(var bA in rA)Object.prototype.hasOwnProperty.call(rA,bA)&&(fA[lA(bA,rA[bA])||bA]=rA[bA]);return fA}tA.exports?tA.exports=nA:window.rename=nA})()}),g=function tA(nA,rA){var lA=s(nA);if(lA!=="object"&&lA!=="array")throw new Error("expected an object");var fA=[];lA==="object"&&(nA=a(nA,rA),fA={});for(var bA in nA)if(nA.hasOwnProperty(bA)){var GA=nA[bA];s(GA)==="object"||s(GA)==="array"?fA[bA]=tA(GA,rA):fA[bA]=GA}return fA},c=r(function(tA){var nA=Object.prototype.hasOwnProperty,rA="~";function lA(){}Object.create&&(lA.prototype=Object.create(null),new lA().__proto__||(rA=!1));function fA(GA,YA,QA){this.fn=GA,this.context=YA,this.once=QA||!1}function bA(){this._events=new lA,this._eventsCount=0}bA.prototype.eventNames=function(){var YA=[],QA,_A;if(this._eventsCount===0)return YA;for(_A in QA=this._events)nA.call(QA,_A)&&YA.push(rA?_A.slice(1):_A);return Object.getOwnPropertySymbols?YA.concat(Object.getOwnPropertySymbols(QA)):YA},bA.prototype.listeners=function(YA,QA){var _A=rA?rA+YA:YA,dA=this._events[_A];if(QA)return!!dA;if(!dA)return[];if(dA.fn)return[dA.fn];for(var PA=0,JA=dA.length,it=new Array(JA);PA<JA;PA++)it[PA]=dA[PA].fn;return it},bA.prototype.emit=function(YA,QA,_A,dA,PA,JA){var it=rA?rA+YA:YA;if(!this._events[it])return!1;var pA=this._events[it],tt=arguments.length,OA,HA;if(pA.fn){switch(pA.once&&this.removeListener(YA,pA.fn,void 0,!0),tt){case 1:return pA.fn.call(pA.context),!0;case 2:return pA.fn.call(pA.context,QA),!0;case 3:return pA.fn.call(pA.context,QA,_A),!0;case 4:return pA.fn.call(pA.context,QA,_A,dA),!0;case 5:return pA.fn.call(pA.context,QA,_A,dA,PA),!0;case 6:return pA.fn.call(pA.context,QA,_A,dA,PA,JA),!0}for(HA=1,OA=new Array(tt-1);HA<tt;HA++)OA[HA-1]=arguments[HA];pA.fn.apply(pA.context,OA)}else{var ZA=pA.length,xA;for(HA=0;HA<ZA;HA++)switch(pA[HA].once&&this.removeListener(YA,pA[HA].fn,void 0,!0),tt){case 1:pA[HA].fn.call(pA[HA].context);break;case 2:pA[HA].fn.call(pA[HA].context,QA);break;case 3:pA[HA].fn.call(pA[HA].context,QA,_A);break;case 4:pA[HA].fn.call(pA[HA].context,QA,_A,dA);break;default:if(!OA)for(xA=1,OA=new Array(tt-1);xA<tt;xA++)OA[xA-1]=arguments[xA];pA[HA].fn.apply(pA[HA].context,OA)}}return!0},bA.prototype.on=function(YA,QA,_A){var dA=new fA(QA,_A||this),PA=rA?rA+YA:YA;return this._events[PA]?this._events[PA].fn?this._events[PA]=[this._events[PA],dA]:this._events[PA].push(dA):(this._events[PA]=dA,this._eventsCount++),this},bA.prototype.once=function(YA,QA,_A){var dA=new fA(QA,_A||this,!0),PA=rA?rA+YA:YA;return this._events[PA]?this._events[PA].fn?this._events[PA]=[this._events[PA],dA]:this._events[PA].push(dA):(this._events[PA]=dA,this._eventsCount++),this},bA.prototype.removeListener=function(YA,QA,_A,dA){var PA=rA?rA+YA:YA;if(!this._events[PA])return this;if(!QA)return--this._eventsCount===0?this._events=new lA:delete this._events[PA],this;var JA=this._events[PA];if(JA.fn)JA.fn===QA&&(!dA||JA.once)&&(!_A||JA.context===_A)&&(--this._eventsCount===0?this._events=new lA:delete this._events[PA]);else{for(var it=0,pA=[],tt=JA.length;it<tt;it++)(JA[it].fn!==QA||dA&&!JA[it].once||_A&&JA[it].context!==_A)&&pA.push(JA[it]);pA.length?this._events[PA]=pA.length===1?pA[0]:pA:--this._eventsCount===0?this._events=new lA:delete this._events[PA]}return this},bA.prototype.removeAllListeners=function(YA){var QA;return YA?(QA=rA?rA+YA:YA,this._events[QA]&&(--this._eventsCount===0?this._events=new lA:delete this._events[QA])):(this._events=new lA,this._eventsCount=0),this},bA.prototype.off=bA.prototype.removeListener,bA.prototype.addListener=bA.prototype.on,bA.prototype.setMaxListeners=function(){return this},bA.prefixed=rA,bA.EventEmitter=bA,tA.exports=bA});function I(tA,nA,rA){return nA in tA?Object.defineProperty(tA,nA,{value:rA,enumerable:!0,configurable:!0,writable:!0}):tA[nA]=rA,tA}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,fA,bA,GA,YA,QA,_A,dA,PA;nA=Object.assign({debug:!1},nA);var JA=new c,it=B.data,pA="",tt="",OA="",HA="",ZA="",xA="",wA=function(KA,qA){if(!(tt[0]==="?"||tt[0]==="!")){var At={type:KA,value:qA};nA.debug&&console.log("emit:",At),JA.emit("data",At)}};JA.stateMachine=(PA={},I(PA,B.data,(rA={},I(rA,C.lt,function(){pA.trim()&&wA(Q.text,pA),tt="",ZA=!1,it=B.tagBegin}),I(rA,C.char,function(RA){pA+=RA}),rA)),I(PA,B.cdata,I({},C.char,function(RA){pA+=RA,pA.substr(-3)==="]]>"&&(wA(Q.text,pA.slice(0,-3)),pA="",it=B.data)})),I(PA,B.tagBegin,(lA={},I(lA,C.space,l),I(lA,C.char,function(RA){tt=RA,it=B.tagName}),I(lA,C.slash,function(){tt="",ZA=!0}),lA)),I(PA,B.tagName,(fA={},I(fA,C.space,function(){ZA?it=B.tagEnd:(it=B.attributeNameStart,wA(Q.openTag,tt))}),I(fA,C.gt,function(){wA(ZA?Q.closeTag:Q.openTag,tt),pA="",it=B.data}),I(fA,C.slash,function(){it=B.tagEnd,wA(Q.openTag,tt)}),I(fA,C.char,function(RA){tt+=RA,tt==="![CDATA["&&(it=B.cdata,pA="",tt="")}),fA)),I(PA,B.tagEnd,(bA={},I(bA,C.gt,function(){wA(Q.closeTag,tt),pA="",it=B.data}),I(bA,C.char,l),bA)),I(PA,B.attributeNameStart,(GA={},I(GA,C.char,function(RA){OA=RA,it=B.attributeName}),I(GA,C.gt,function(){pA="",it=B.data}),I(GA,C.space,l),I(GA,C.slash,function(){ZA=!0,it=B.tagEnd}),GA)),I(PA,B.attributeName,(YA={},I(YA,C.space,function(){it=B.attributeNameEnd}),I(YA,C.equal,function(){wA(Q.attributeName,OA),it=B.attributeValueBegin}),I(YA,C.gt,function(){HA="",wA(Q.attributeName,OA),wA(Q.attributeValue,HA),pA="",it=B.data}),I(YA,C.slash,function(){ZA=!0,HA="",wA(Q.attributeName,OA),wA(Q.attributeValue,HA),it=B.tagEnd}),I(YA,C.char,function(RA){OA+=RA}),YA)),I(PA,B.attributeNameEnd,(QA={},I(QA,C.space,l),I(QA,C.equal,function(){wA(Q.attributeName,OA),it=B.attributeValueBegin}),I(QA,C.gt,function(){HA="",wA(Q.attributeName,OA),wA(Q.attributeValue,HA),pA="",it=B.data}),I(QA,C.char,function(RA){HA="",wA(Q.attributeName,OA),wA(Q.attributeValue,HA),OA=RA,it=B.attributeName}),QA)),I(PA,B.attributeValueBegin,(_A={},I(_A,C.space,l),I(_A,C.quote,function(RA){xA=RA,HA="",it=B.attributeValue}),I(_A,C.gt,function(){HA="",wA(Q.attributeValue,HA),pA="",it=B.data}),I(_A,C.char,function(RA){xA="",HA=RA,it=B.attributeValue}),_A)),I(PA,B.attributeValue,(dA={},I(dA,C.space,function(RA){xA?HA+=RA:(wA(Q.attributeValue,HA),it=B.attributeNameStart)}),I(dA,C.quote,function(RA){xA===RA?(wA(Q.attributeValue,HA),it=B.attributeNameStart):HA+=RA}),I(dA,C.gt,function(RA){xA?HA+=RA:(wA(Q.attributeValue,HA),pA="",it=B.data)}),I(dA,C.slash,function(RA){xA?HA+=RA:(wA(Q.attributeValue,HA),ZA=!0,it=B.tagEnd)}),I(dA,C.char,function(RA){HA+=RA}),dA)),PA);var NA=function(KA){nA.debug&&console.log(it,KA);var qA=JA.stateMachine[it],At=qA[E(KA)]||qA[C.error]||qA[C.char];At(KA)};return JA.write=function(RA){for(var KA=RA.length,qA=0;qA<KA;qA++)NA(RA[qA])},JA},d={State:B,Action:C,Type:Q,create:u},p=d.Type,m={element:"element",text:"text"},w=function(nA){return Object.assign({name:"",type:m.element,value:"",parent:null,attributes:{},children:[]},nA)},D=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,fA=void 0,bA=void 0,GA=new c,YA=function(_A){switch(_A.type){case p.openTag:if(fA===null)fA=lA,fA.name=_A.value;else{var dA=w({name:_A.value,parent:fA});fA.children.push(dA),fA=dA}break;case p.closeTag:var PA=fA.parent;if(nA.parentNodes||(fA.parent=null),fA.name!==_A.value)break;nA.stream&&PA===lA&&(lA.children=[],fA.parent=null),(!nA.emitTopLevelOnly||PA===lA)&&(GA.emit(nA.tagPrefix+fA.name,fA),GA.emit("tag",fA.name,fA)),fA===lA&&(rA.removeAllListeners("data"),GA.emit(nA.doneEvent,fA),lA=null),fA=PA;break;case p.text:fA&&fA.children.push(w({type:m.text,value:_A.value,parent:nA.parentNodes?fA:null}));break;case p.attributeName:bA=_A.value,fA.attributes[bA]="";break;case p.attributeValue:fA.attributes[bA]=_A.value;break}};return GA.reset=function(){rA=d.create({debug:nA.debug}),rA.on("data",YA),lA=w(),fA=null,bA="",GA.parse=rA.write},GA.reset(),GA},S=function(nA,rA){rA=Object.assign({},rA,{stream:!1,tagPrefix:":"});var lA=D(rA),fA=void 0;return lA.on("done",function(bA){fA=bA}),lA.parse(nA),fA},k={parseSync:S},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(fA){return fA.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:L(rA)})},L=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,fA=lA===void 0?function(QA){return QA}:lA,bA=rA.camelcase,GA=bA===void 0?!1:bA,YA=function(_A){var dA;return dA=fA(_A),GA&&(dA=M(dA)),dA};return YA(N(nA))};function $(){for(var tA=arguments.length,nA=new Array(tA),rA=0;rA<tA;rA++)nA[rA]=arguments[rA];return new Promise(function(lA,fA){try{var bA=Z.apply(void 0,nA);lA(bA)}catch(GA){fA(GA)}})}var eA=function tA(nA){var rA=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},lA=rA.transformAttr,fA=lA===void 0?function(it,pA,tt){return"".concat(it,'="').concat(tt(pA),'"')}:lA,bA=rA.transformNode,GA=bA===void 0?function(it){return it}:bA,YA=rA.selfClose,QA=YA===void 0?!0:YA;if(Array.isArray(nA))return nA.map(function(it){return tA(it,{transformAttr:fA,selfClose:QA,transformNode:GA})}).join("");var _A=GA(nA);if(_A.type==="text")return H(_A.value);var dA="";for(var PA in _A.attributes){var JA=fA(PA,_A.attributes[PA],O,_A.name);dA+=JA?" ".concat(JA):""}return _A.children&&_A.children.length>0||!QA?"<".concat(_A.name).concat(dA,">").concat(tA(_A.children,{transformAttr:fA,transformNode:GA,selfClose:QA}),"</").concat(_A.name,">"):"<".concat(_A.name).concat(dA,"/>")},aA=Object.assign({},{parse:$,parseSync:Z,stringify:eA});return aA})}}),GfA=va({"node_modules/js-beautify/js/src/core/output.js"(e,A){function t(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=[]}t.prototype.clone_empty=function(){var o=new t(this.__parent);return o.set_indent(this.__indent_count,this.__alignment_count),o},t.prototype.item=function(o){return o<0?this.__items[this.__items.length+o]:this.__items[o]},t.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},t.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))},t.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)},t.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},t.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},t.prototype.is_empty=function(){return this.__items.length===0},t.prototype.last=function(){return this.is_empty()?null:this.__items[this.__items.length-1]},t.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},t.prototype.pop=function(){var o=null;return this.is_empty()||(o=this.__items.pop(),this.__character_count-=o.length),o},t.prototype._remove_indent=function(){this.__indent_count>0&&(this.__indent_count-=1,this.__character_count-=this.__parent.indent_size)},t.prototype._remove_wrap_indent=function(){this.__wrap_point_indent_count>0&&(this.__wrap_point_indent_count-=1)},t.prototype.trim=function(){for(;this.last()===" ";)this.__items.pop(),this.__character_count-=1},t.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 t(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!==`
@@ -5430,7 +5430,7 @@ You passed in: '`+this.raw_options[o]+"'");return a},t.prototype._is_valid_selec
5430
5430
  `);break}}return s}}}),D8e=va({"node_modules/pretty/index.js"(e,A){var t=d8e(),i=w8e(),n=bct(),o={unformatted:["code","pre","em","strong","span"],indent_inner_html:!0,indent_char:" ",indent_size:2,sep:`
5431
5431
  `};A.exports=function(a,g){var c=n({},o,g);return a=t.html(a,c),c.ocd===!0?(c.newlines&&(c.sep=c.newlines),s(a,c)):a};function s(r,a){return i(r,a).replace(/^\s+/g,"").replace(/\s+$/g,`
5432
5432
  `).replace(/(\s*<!--)/g,`
5433
- $1`).replace(/>(\s*)(?=<!--\s*\/)/g,"> ")}}});function xct(e,A,t){if(!A||!t)return;let i=e.get(A);i||(i=new Set,e.set(A,i)),i.add(t);let n=e.get(t);n||(n=new Set,e.set(t,n)),n.add(A)}function S8e(e,A){if(!A.subcircuit_id&&!A.source_group_id)return[...e];const t=new Map;for(const s of e){const r=s[`${s.type}_id`];typeof r=="string"&&t.set(r,s)}const i=new Map;for(const s of e){const r=Object.entries(s);for(const[a,g]of r)if(a!=="parent_source_group_id"){if(a.endsWith("_id")&&typeof g=="string"){const c=t.get(g);xct(i,s,c)}else if(a.endsWith("_ids")&&Array.isArray(g)){for(const c of g)if(typeof c=="string"){const I=t.get(c);xct(i,s,I)}}}}const n=[],o=new Set;for(const s of e)(A.subcircuit_id&&s.subcircuit_id===A.subcircuit_id||A.source_group_id&&(s.source_group_id===A.source_group_id||Array.isArray(s.member_source_group_ids)&&s.member_source_group_ids.includes(A.source_group_id)))&&(n.push(s),o.add(s));for(;n.length>0;){const s=n.shift(),r=i.get(s);if(r)for(const a of r)o.has(a)||(o.add(a),n.push(a))}return e.filter(s=>o.has(s))}var L9=(e,A={})=>{const t=e;let i=t._internal_store;if(!i){i={counts:{},editCount:0},t._internal_store=i;for(const o of t){const s=o.type,r=o[`${s}_id`];if(!r)continue;const a=Number.parseInt(r.split("_").pop());Number.isNaN(a)||(i.counts[s]=Math.max(i.counts[s]??0,a))}}return new Proxy({},{get:(o,s)=>{if(s==="toArray")return()=>(t.editCount=i.editCount,t);if(s==="editCount")return i.editCount;if(s==="subtree")return a=>L9(S8e(t,a),A);const r=s;return{get:a=>t.find(g=>g.type===r&&g[`${r}_id`]===a),getUsing:a=>{const g=Object.keys(a);if(g.length!==1)throw new Error("getUsing requires exactly one key, e.g. { pcb_component_id }");const c=g[0],I=c.replace("_id",""),l=t.find(B=>B.type===I&&B[c]===a[c]);return l?t.find(B=>B.type===r&&B[`${r}_id`]===l[`${r}_id`]):null},getWhere:a=>{const g=Object.keys(a);return t.find(c=>c.type===r&&g.every(I=>c[I]===a[I]))},list:a=>{const g=a?Object.keys(a):[];return t.filter(c=>c.type===r&&g.every(I=>c[I]===a[I]))},insert:a=>{i.counts[r]??=-1,i.counts[r]++;const g=i.counts[r],c={type:r,[`${r}_id`]:`${r}_${g}`,...a};return A.validateInserts&&(_gt[r]??ifA).parse(c),t.push(c),i.editCount++,c},delete:a=>{const g=t.find(c=>c[`${r}_id`]===a);g&&(t.splice(t.indexOf(g),1),i.editCount++)},update:(a,g)=>{const c=t.find(I=>I.type===r&&I[`${r}_id`]===a);return c?(Object.assign(c,g),i.editCount++,c):null},select:a=>{if(r==="source_component")return t.find(g=>g.type==="source_component"&&g.name===a.replace(/\./g,""));if(r==="pcb_port"||r==="source_port"||r==="schematic_port"){const[g,c]=a.replace(/\./g,"").split(/[\s\>]+/),I=t.find(B=>B.type==="source_component"&&B.name===g);if(!I)return null;const l=t.find(B=>B.type==="source_port"&&B.source_component_id===I.source_component_id&&(B.name===c||(B.port_hints??[]).includes(c)));if(!l)return null;if(r==="source_port")return l;if(r==="pcb_port")return t.find(B=>B.type==="pcb_port"&&B.source_port_id===l.source_port_id);if(r==="schematic_port")return t.find(B=>B.type==="schematic_port"&&B.source_port_id===l.source_port_id)}}}}})};L9.unparsed=L9;var Gb=L9;function vfA(e){const A=e.type;return`${A}:${e[`${A}_id`]}`}var _ct=(e,A={})=>{let t=e._internal_store_indexed;if(!t){t={counts:{},editCount:0,indexes:{}};for(const s of e){const r=s.type,a=s[`${r}_id`];if(!a)continue;const g=Number.parseInt(a.split("_").pop()||"");Number.isNaN(g)||(t.counts[r]=Math.max(t.counts[r]??0,g))}const n=A.indexConfig||{},o=t.indexes;if(n.byId&&(o.byId=new Map),n.byType&&(o.byType=new Map),n.byRelation&&(o.byRelation=new Map),n.bySubcircuit&&(o.bySubcircuit=new Map),n.byCustomField&&n.byCustomField.length>0){o.byCustomField=new Map;for(const s of n.byCustomField)o.byCustomField.set(s,new Map)}for(const s of e){if(n.byId){const r=vfA(s);o.byId.set(r,s)}if(n.byType){const r=o.byType.get(s.type)||[];r.push(s),o.byType.set(s.type,r)}if(n.byRelation){const r=Object.entries(s);for(const[a,g]of r)if(a.endsWith("_id")&&a!==`${s.type}_id`&&typeof g=="string"){const c=o.byRelation.get(a)||new Map,I=c.get(g)||[];I.push(s),c.set(g,I),o.byRelation.set(a,c)}}if(n.bySubcircuit&&"subcircuit_id"in s){const r=s.subcircuit_id;if(r&&typeof r=="string"){const a=o.bySubcircuit.get(r)||[];a.push(s),o.bySubcircuit.set(r,a)}}if(n.byCustomField&&o.byCustomField){for(const r of n.byCustomField)if(r in s){const a=s[r];if(a!==void 0&&(typeof a=="string"||typeof a=="number")){const g=String(a),c=o.byCustomField.get(r),I=c.get(g)||[];I.push(s),c.set(g,I)}}}}e._internal_store_indexed=t}return new Proxy({},{get:(n,o)=>{if(o==="toArray")return()=>(e.editCount=t.editCount,e);if(o==="editCount")return t.editCount;const s=o;return{get:r=>{const a=A.indexConfig||{};return a.byId&&t.indexes.byId?t.indexes.byId.get(`${s}:${r}`)||null:a.byType&&t.indexes.byType?(t.indexes.byType.get(s)||[]).find(c=>c[`${s}_id`]===r)||null:e.find(g=>g.type===s&&g[`${s}_id`]===r)||null},getUsing:r=>{const a=A.indexConfig||{},g=Object.keys(r);if(g.length!==1)throw new Error("getUsing requires exactly one key, e.g. { pcb_component_id }");const c=g[0],I=c.replace("_id","");if(a.byRelation&&t.indexes.byRelation){const B=t.indexes.byRelation.get(c);if(B){const Q=(B.get(r[c])||[]).find(E=>E.type===I);if(!Q)return null;const h=Q[`${s}_id`];return a.byId&&t.indexes.byId?t.indexes.byId.get(`${s}:${h}`)||null:a.byType&&t.indexes.byType?(t.indexes.byType.get(s)||[]).find(u=>u[`${s}_id`]===h)||null:e.find(E=>E.type===s&&E[`${s}_id`]===h)||null}}const l=e.find(B=>B.type===I&&B[c]===r[c]);return l&&e.find(B=>B.type===s&&B[`${s}_id`]===l[`${s}_id`])||null},getWhere:r=>{const a=A.indexConfig||{},g=Object.keys(r);if(g.length===1&&a.byCustomField&&t.indexes.byCustomField){const c=g[0],I=t.indexes.byCustomField.get(c);if(I){const l=String(r[c]);return(I.get(l)||[]).find(C=>C.type===s)||null}}if("subcircuit_id"in r&&a.bySubcircuit&&t.indexes.bySubcircuit){const c=r.subcircuit_id;return(t.indexes.bySubcircuit.get(c)||[]).find(l=>l.type===s&&g.every(B=>l[B]===r[B]))||null}return a.byType&&t.indexes.byType?(t.indexes.byType.get(s)||[]).find(I=>g.every(l=>I[l]===r[l]))||null:e.find(c=>c.type===s&&g.every(I=>c[I]===r[I]))||null},list:r=>{const a=A.indexConfig||{},g=r?Object.keys(r):[];if(g.length===0&&a.byType&&t.indexes.byType)return t.indexes.byType.get(s)||[];if(g.length===1&&g[0]==="subcircuit_id"&&a.bySubcircuit&&t.indexes.bySubcircuit){const I=r.subcircuit_id;return(t.indexes.bySubcircuit.get(I)||[]).filter(B=>B.type===s)}let c;return a.byType&&t.indexes.byType?c=t.indexes.byType.get(s)||[]:c=e.filter(I=>I.type===s),g.length>0?c.filter(I=>g.every(l=>I[l]===r[l])):c},insert:r=>{t.counts[s]??=-1,t.counts[s]++;const a=t.counts[s],g={type:s,[`${s}_id`]:`${s}_${a}`,...r};A.validateInserts&&(_gt[s]??ifA).parse(g),e.push(g),t.editCount++;const c=A.indexConfig||{};if(c.byId&&t.indexes.byId){const I=vfA(g);t.indexes.byId.set(I,g)}if(c.byType&&t.indexes.byType){const I=t.indexes.byType.get(s)||[];I.push(g),t.indexes.byType.set(s,I)}if(c.byRelation&&t.indexes.byRelation){const I=Object.entries(g);for(const[l,B]of I)if(l.endsWith("_id")&&l!==`${g.type}_id`&&typeof B=="string"){const C=t.indexes.byRelation.get(l)||new Map,Q=C.get(B)||[];Q.push(g),C.set(B,Q),t.indexes.byRelation.set(l,C)}}if(c.bySubcircuit&&t.indexes.bySubcircuit&&"subcircuit_id"in g){const I=g.subcircuit_id;if(I&&typeof I=="string"){const l=t.indexes.bySubcircuit.get(I)||[];l.push(g),t.indexes.bySubcircuit.set(I,l)}}if(c.byCustomField&&t.indexes.byCustomField){for(const I of c.byCustomField)if(I in g){const l=g[I];if(l!==void 0&&(typeof l=="string"||typeof l=="number")){const B=String(l),C=t.indexes.byCustomField.get(I),Q=C.get(B)||[];Q.push(g),C.set(B,Q)}}}return g},delete:r=>{const a=A.indexConfig||{};let g;if(a.byId&&t.indexes.byId?g=t.indexes.byId.get(`${s}:${r}`):a.byType&&t.indexes.byType?g=(t.indexes.byType.get(s)||[]).find(l=>l[`${s}_id`]===r):g=e.find(I=>I[`${s}_id`]===r),!g)return;const c=e.indexOf(g);if(c>=0&&(e.splice(c,1),t.editCount++),a.byId&&t.indexes.byId){const I=vfA(g);t.indexes.byId.delete(I)}if(a.byType&&t.indexes.byType){const l=(t.indexes.byType.get(s)||[]).filter(B=>B[`${s}_id`]!==r);t.indexes.byType.set(s,l)}if(a.byRelation&&t.indexes.byRelation)for(const[I,l]of t.indexes.byRelation.entries())for(const[B,C]of l.entries()){const Q=C.filter(h=>h!==g);Q.length===0?l.delete(B):l.set(B,Q)}if(a.bySubcircuit&&t.indexes.bySubcircuit&&"subcircuit_id"in g){const I=g.subcircuit_id;if(I){const B=(t.indexes.bySubcircuit.get(I)||[]).filter(C=>C!==g);B.length===0?t.indexes.bySubcircuit.delete(I):t.indexes.bySubcircuit.set(I,B)}}if(a.byCustomField&&t.indexes.byCustomField)for(const I of t.indexes.byCustomField.values())for(const[l,B]of I.entries()){const C=B.filter(Q=>Q!==g);C.length===0?I.delete(l):I.set(l,C)}},update:(r,a)=>{const g=A.indexConfig||{};let c;if(g.byId&&t.indexes.byId?c=t.indexes.byId.get(`${s}:${r}`):g.byType&&t.indexes.byType?c=(t.indexes.byType.get(s)||[]).find(l=>l[`${s}_id`]===r):c=e.find(I=>I.type===s&&I[`${s}_id`]===r),!c)return null;if(g.byRelation&&t.indexes.byRelation){const I=Object.entries(c);for(const[l,B]of I)if(l.endsWith("_id")&&l!==`${c.type}_id`&&typeof B=="string"&&l in a&&a[l]!==B){const C=t.indexes.byRelation.get(l);if(C){const h=(C.get(B)||[]).filter(E=>E!==c);h.length===0?C.delete(B):C.set(B,h)}}}if(g.bySubcircuit&&t.indexes.bySubcircuit&&"subcircuit_id"in c&&"subcircuit_id"in a){const I=c.subcircuit_id,l=a.subcircuit_id;if(I!==l){const C=(t.indexes.bySubcircuit.get(I)||[]).filter(Q=>Q!==c);C.length===0?t.indexes.bySubcircuit.delete(I):t.indexes.bySubcircuit.set(I,C)}}if(g.byCustomField&&t.indexes.byCustomField){for(const I of g.byCustomField)if(I in c&&I in a&&c[I]!==a[I]){const l=t.indexes.byCustomField.get(I);if(l){const B=String(c[I]),Q=(l.get(B)||[]).filter(h=>h!==c);Q.length===0?l.delete(B):l.set(B,Q)}}}if(Object.assign(c,a),t.editCount++,g.byRelation&&t.indexes.byRelation){const I=Object.entries(c);for(const[l,B]of I)if(l.endsWith("_id")&&l!==`${c.type}_id`&&typeof B=="string"&&l in a){const C=t.indexes.byRelation.get(l)||new Map,Q=C.get(B)||[];Q.includes(c)||(Q.push(c),C.set(B,Q),t.indexes.byRelation.set(l,C))}}if(g.bySubcircuit&&t.indexes.bySubcircuit&&"subcircuit_id"in c&&"subcircuit_id"in a){const I=c.subcircuit_id;if(I&&typeof I=="string"){const l=t.indexes.bySubcircuit.get(I)||[];l.includes(c)||(l.push(c),t.indexes.bySubcircuit.set(I,l))}}if(g.byCustomField&&t.indexes.byCustomField){for(const I of g.byCustomField)if(I in c&&I in a){const l=c[I];if(l!==void 0&&(typeof l=="string"||typeof l=="number")){const B=String(l),C=t.indexes.byCustomField.get(I),Q=C.get(B)||[];Q.includes(c)||(Q.push(c),C.set(B,Q))}}}return c},select:r=>{if(s==="source_component")return e.find(a=>a.type==="source_component"&&a.name===r.replace(/\./g,""))||null;if(s==="pcb_port"||s==="source_port"||s==="schematic_port"){const[a,g]=r.replace(/\./g,"").split(/[\s\>]+/),c=e.find(l=>l.type==="source_component"&&l.name===a);if(!c)return null;const I=e.find(l=>l.type==="source_port"&&l.source_component_id===c.source_component_id&&(l.name===g||(l.port_hints??[]).includes(g)));if(!I)return null;if(s==="source_port")return I;if(s==="pcb_port")return e.find(l=>l.type==="pcb_port"&&l.source_port_id===I.source_port_id)||null;if(s==="schematic_port")return e.find(l=>l.type==="schematic_port"&&l.source_port_id===I.source_port_id)||null}return null}}}})};_ct.unparsed=_ct;var b8e=e=>{const A=e.type;return e[`${A}_id`]},LfA=e=>{let A=Number.POSITIVE_INFINITY,t=Number.POSITIVE_INFINITY,i=Number.NEGATIVE_INFINITY,n=Number.NEGATIVE_INFINITY;for(const o of e){if(!o.type.startsWith("pcb_"))continue;if(o.type==="pcb_smtpad"&&o.shape==="polygon"&&Array.isArray(o.points)){for(const c of o.points)A=Math.min(A,c.x),t=Math.min(t,c.y),i=Math.max(i,c.x),n=Math.max(n,c.y);continue}let s,r,a,g;if("x"in o&&"y"in o&&(s=Number(o.x),r=Number(o.y)),"outer_diameter"in o&&(a=Number(o.outer_diameter),g=Number(o.outer_diameter)),"width"in o&&(a=Number(o.width)),"height"in o&&(g=Number(o.height)),"center"in o&&(s=o.center.x,r=o.center.y),s!==void 0&&r!==void 0)A=Math.min(A,s),t=Math.min(t,r),i=Math.max(i,s),n=Math.max(n,r),a!==void 0&&g!==void 0&&(A=Math.min(A,s-a/2),t=Math.min(t,r-g/2),i=Math.max(i,s+a/2),n=Math.max(n,r+g/2)),"radius"in o&&(A=Math.min(A,s-o.radius),t=Math.min(t,r-o.radius),i=Math.max(i,s+o.radius),n=Math.max(n,r+o.radius));else if(o.type==="pcb_trace")for(const c of o.route)A=Math.min(A,c.x),t=Math.min(t,c.y),i=Math.max(i,c.x),n=Math.max(n,c.y)}return{minX:A,minY:t,maxX:i,maxY:n}};function x8e(e){let A=0;if(e.length==0)return A;for(var t=0;t<e.length;t++){var i=e.charCodeAt(t);A=(A<<5)-A+i,A=A&A}return Math.abs(A)}var kct=[["#69d2e7","#a7dbd8","#e0e4cc","#f38630","#fa6900"],["#fe4365","#fc9d9a","#f9cdad","#c8c8a9","#83af9b"],["#ecd078","#d95b43","#c02942","#542437","#53777a"],["#556270","#4ecdc4","#c7f464","#ff6b6b","#c44d58"],["#774f38","#e08e79","#f1d4af","#ece5ce","#c5e0dc"],["#e8ddcb","#cdb380","#036564","#033649","#031634"],["#490a3d","#bd1550","#e97f02","#f8ca00","#8a9b0f"],["#594f4f","#547980","#45ada8","#9de0ad","#e5fcc2"],["#00a0b0","#6a4a3c","#cc333f","#eb6841","#edc951"],["#e94e77","#d68189","#c6a49a","#c6e5d9","#f4ead5"],["#3fb8af","#7fc7af","#dad8a7","#ff9e9d","#ff3d7f"],["#d9ceb2","#948c75","#d5ded9","#7a6a53","#99b2b7"],["#ffffff","#cbe86b","#f2e9e1","#1c140d","#cbe86b"],["#efffcd","#dce9be","#555152","#2e2633","#99173c"],["#343838","#005f6b","#008c9e","#00b4cc","#00dffc"],["#413e4a","#73626e","#b38184","#f0b49e","#f7e4be"],["#ff4e50","#fc913a","#f9d423","#ede574","#e1f5c4"],["#99b898","#fecea8","#ff847c","#e84a5f","#2a363b"],["#655643","#80bca3","#f6f7bd","#e6ac27","#bf4d28"],["#00a8c6","#40c0cb","#f9f2e7","#aee239","#8fbe00"],["#351330","#424254","#64908a","#e8caa4","#cc2a41"],["#554236","#f77825","#d3ce3d","#f1efa5","#60b99a"],["#5d4157","#838689","#a8caba","#cad7b2","#ebe3aa"],["#8c2318","#5e8c6a","#88a65e","#bfb35a","#f2c45a"],["#fad089","#ff9c5b","#f5634a","#ed303c","#3b8183"],["#ff4242","#f4fad2","#d4ee5e","#e1edb9","#f0f2eb"],["#f8b195","#f67280","#c06c84","#6c5b7b","#355c7d"],["#d1e751","#ffffff","#000000","#4dbce9","#26ade4"],["#1b676b","#519548","#88c425","#bef202","#eafde6"],["#5e412f","#fcebb6","#78c0a8","#f07818","#f0a830"],["#bcbdac","#cfbe27","#f27435","#f02475","#3b2d38"],["#452632","#91204d","#e4844a","#e8bf56","#e2f7ce"],["#eee6ab","#c5bc8e","#696758","#45484b","#36393b"],["#f0d8a8","#3d1c00","#86b8b1","#f2d694","#fa2a00"],["#2a044a","#0b2e59","#0d6759","#7ab317","#a0c55f"],["#f04155","#ff823a","#f2f26f","#fff7bd","#95cfb7"],["#b9d7d9","#668284","#2a2829","#493736","#7b3b3b"],["#bbbb88","#ccc68d","#eedd99","#eec290","#eeaa88"],["#b3cc57","#ecf081","#ffbe40","#ef746f","#ab3e5b"],["#a3a948","#edb92e","#f85931","#ce1836","#009989"],["#300030","#480048","#601848","#c04848","#f07241"],["#67917a","#170409","#b8af03","#ccbf82","#e33258"],["#aab3ab","#c4cbb7","#ebefc9","#eee0b7","#e8caaf"],["#e8d5b7","#0e2430","#fc3a51","#f5b349","#e8d5b9"],["#ab526b","#bca297","#c5ceae","#f0e2a4","#f4ebc3"],["#607848","#789048","#c0d860","#f0f0d8","#604848"],["#b6d8c0","#c8d9bf","#dadabd","#ecdbbc","#fedcba"],["#a8e6ce","#dcedc2","#ffd3b5","#ffaaa6","#ff8c94"],["#3e4147","#fffedf","#dfba69","#5a2e2e","#2a2c31"],["#fc354c","#29221f","#13747d","#0abfbc","#fcf7c5"],["#cc0c39","#e6781e","#c8cf02","#f8fcc1","#1693a7"],["#1c2130","#028f76","#b3e099","#ffeaad","#d14334"],["#a7c5bd","#e5ddcb","#eb7b59","#cf4647","#524656"],["#dad6ca","#1bb0ce","#4f8699","#6a5e72","#563444"],["#5c323e","#a82743","#e15e32","#c0d23e","#e5f04c"],["#edebe6","#d6e1c7","#94c7b6","#403b33","#d3643b"],["#fdf1cc","#c6d6b8","#987f69","#e3ad40","#fcd036"],["#230f2b","#f21d41","#ebebbc","#bce3c5","#82b3ae"],["#b9d3b0","#81bda4","#b28774","#f88f79","#f6aa93"],["#3a111c","#574951","#83988e","#bcdea5","#e6f9bc"],["#5e3929","#cd8c52","#b7d1a3","#dee8be","#fcf7d3"],["#1c0113","#6b0103","#a30006","#c21a01","#f03c02"],["#000000","#9f111b","#b11623","#292c37","#cccccc"],["#382f32","#ffeaf2","#fcd9e5","#fbc5d8","#f1396d"],["#e3dfba","#c8d6bf","#93ccc6","#6cbdb5","#1a1f1e"],["#f6f6f6","#e8e8e8","#333333","#990100","#b90504"],["#1b325f","#9cc4e4","#e9f2f9","#3a89c9","#f26c4f"],["#a1dbb2","#fee5ad","#faca66","#f7a541","#f45d4c"],["#c1b398","#605951","#fbeec2","#61a6ab","#accec0"],["#5e9fa3","#dcd1b4","#fab87f","#f87e7b","#b05574"],["#951f2b","#f5f4d7","#e0dfb1","#a5a36c","#535233"],["#8dccad","#988864","#fea6a2","#f9d6ac","#ffe9af"],["#2d2d29","#215a6d","#3ca2a2","#92c7a3","#dfece6"],["#413d3d","#040004","#c8ff00","#fa023c","#4b000f"],["#eff3cd","#b2d5ba","#61ada0","#248f8d","#605063"],["#ffefd3","#fffee4","#d0ecea","#9fd6d2","#8b7a5e"],["#cfffdd","#b4dec1","#5c5863","#a85163","#ff1f4c"],["#9dc9ac","#fffec7","#f56218","#ff9d2e","#919167"],["#4e395d","#827085","#8ebe94","#ccfc8e","#dc5b3e"],["#a8a7a7","#cc527a","#e8175d","#474747","#363636"],["#f8edd1","#d88a8a","#474843","#9d9d93","#c5cfc6"],["#046d8b","#309292","#2fb8ac","#93a42a","#ecbe13"],["#f38a8a","#55443d","#a0cab5","#cde9ca","#f1edd0"],["#a70267","#f10c49","#fb6b41","#f6d86b","#339194"],["#ff003c","#ff8a00","#fabe28","#88c100","#00c176"],["#ffedbf","#f7803c","#f54828","#2e0d23","#f8e4c1"],["#4e4d4a","#353432","#94ba65","#2790b0","#2b4e72"],["#0ca5b0","#4e3f30","#fefeeb","#f8f4e4","#a5b3aa"],["#4d3b3b","#de6262","#ffb88c","#ffd0b3","#f5e0d3"],["#fffbb7","#a6f6af","#66b6ab","#5b7c8d","#4f2958"],["#edf6ee","#d1c089","#b3204d","#412e28","#151101"],["#9d7e79","#ccac95","#9a947c","#748b83","#5b756c"],["#fcfef5","#e9ffe1","#cdcfb7","#d6e6c3","#fafbe3"],["#9cddc8","#bfd8ad","#ddd9ab","#f7af63","#633d2e"],["#30261c","#403831","#36544f","#1f5f61","#0b8185"],["#aaff00","#ffaa00","#ff00aa","#aa00ff","#00aaff"],["#d1313d","#e5625c","#f9bf76","#8eb2c5","#615375"],["#ffe181","#eee9e5","#fad3b2","#ffba7f","#ff9c97"],["#73c8a9","#dee1b6","#e1b866","#bd5532","#373b44"],["#805841","#dcf7f3","#fffcdd","#ffd8d8","#f5a2a2"]],_8e=e=>{let{x:A,y:t,width:i,height:n}={...e,...e.size,...e.center,...e.position};if(e.x1!==void 0&&e.x2!==void 0&&e.y1!==void 0&&e.y2!==void 0&&(A=(e.x1+e.x2)/2,t=(e.y1+e.y2)/2,i=Math.abs(e.x1-e.x2),n=Math.abs(e.y1-e.y2)),e.points&&Array.isArray(e.points)&&e.points.length>0){const r=e.points.map(B=>B.x),a=e.points.map(B=>B.y),g=Math.min(...r),c=Math.max(...r),I=Math.min(...a),l=Math.max(...a);A=(g+c)/2,t=(I+l)/2,i=c-g,n=l-I}const o=e.text||e.name||e.source?.text||e.source?.name||"?",s=e;return A===void 0||t===void 0?null:(i===void 0&&"outer_diameter"in e&&(i=e.outer_diameter,n=e.outer_diameter),(i===void 0||n===void 0)&&(i=.1,n=.1),{x:A,y:t,width:i,height:n,title:o,content:s,bg_color:kct[x8e(e.type||o)%kct.length]?.[4]??"#f00"})},k8e=e=>!!e,F8e=e=>{const A=e.filter(g=>g.type.startsWith("pcb_")||g.type.startsWith("schematic_")).concat(e.filter(g=>g.type==="pcb_trace"||g.type==="schematic_trace").flatMap(g=>g.route)).map(g=>_8e(g)).filter(k8e);if(A.length===0)return{center:{x:0,y:0},width:0,height:0};let t=A[0].x-A[0].width/2,i=A[0].x+A[0].width/2,n=A[0].y-A[0].height/2,o=A[0].y+A[0].height/2;for(const g of A.slice(1))t=Math.min(t,g.x-g.width/2),i=Math.max(i,g.x+g.width/2),n=Math.min(n,g.y-g.height/2),o=Math.max(o,g.y+g.height/2);const s=i-t,r=o-n;return{center:{x:t+s/2,y:n+r/2},width:s,height:r}},qD={IS_SHOWING_PCB_GROUPS:"pcb_viewer_is_showing_pcb_groups",PCB_GROUP_VIEW_MODE:"pcb_viewer_group_view_mode",IS_SHOWING_COPPER_POURS:"pcb_viewer_is_showing_copper_pours",IS_SHOWING_GROUP_ANCHOR_OFFSETS:"pcb_viewer_is_showing_group_anchor_offsets",IS_SHOWING_SOLDER_MASK:"pcb_viewer_is_showing_solder_mask"},U9=(e,A)=>{if(typeof window>"u")return A;try{const t=localStorage.getItem(e);return t!==null?JSON.parse(t):A}catch{return A}},H9=(e,A)=>{if(!(typeof window>"u"))try{localStorage.setItem(e,JSON.stringify(A))}catch{}},G8e=(e,A)=>{if(typeof window>"u")return A;try{const t=localStorage.getItem(e);return t!==null?JSON.parse(t):A}catch{return A}},R8e=(e,A)=>{if(!(typeof window>"u"))try{localStorage.setItem(e,JSON.stringify(A))}catch{}},M8e="named_only",N8e=(e={},A=!1)=>EYA(t=>({selected_layer:"top",pcb_viewer_id:`pcb_viewer_${Math.random().toString().slice(2,10)}`,in_edit_mode:!1,in_move_footprint_mode:!1,in_draw_trace_mode:!1,is_moving_component:!1,is_drawing_trace:!1,is_mouse_over_container:!1,is_showing_multiple_traces_length:!1,is_showing_rats_nest:!1,is_showing_autorouting:!0,is_showing_drc_errors:!0,is_showing_copper_pours:U9(qD.IS_SHOWING_COPPER_POURS,!0),is_showing_pcb_groups:A?!1:U9(qD.IS_SHOWING_PCB_GROUPS,!0),is_showing_group_anchor_offsets:U9(qD.IS_SHOWING_GROUP_ANCHOR_OFFSETS,!0),is_showing_solder_mask:U9(qD.IS_SHOWING_SOLDER_MASK,!1),pcb_group_view_mode:A?"all":G8e(qD.PCB_GROUP_VIEW_MODE,M8e),hovered_error_id:null,...e,selectLayer:i=>t({selected_layer:i}),setEditMode:i=>t({in_edit_mode:i!=="off",in_move_footprint_mode:i==="move_footprint",in_draw_trace_mode:i==="draw_trace",is_moving_component:!1,is_drawing_trace:!1}),setIsShowingRatsNest:i=>t({is_showing_rats_nest:i}),setIsMovingComponent:i=>t({is_moving_component:i}),setIsDrawingTrace:i=>t({is_drawing_trace:i}),setIsMouseOverContainer:i=>t({is_mouse_over_container:i}),setIsShowingMultipleTracesLength:i=>t({is_showing_multiple_traces_length:i}),setIsShowingAutorouting:i=>t({is_showing_autorouting:i}),setIsShowingDrcErrors:i=>t({is_showing_drc_errors:i}),setIsShowingCopperPours:i=>{H9(qD.IS_SHOWING_COPPER_POURS,i),t({is_showing_copper_pours:i})},setIsShowingPcbGroups:i=>{A||(H9(qD.IS_SHOWING_PCB_GROUPS,i),t({is_showing_pcb_groups:i}))},setIsShowingGroupAnchorOffsets:i=>{H9(qD.IS_SHOWING_GROUP_ANCHOR_OFFSETS,i),t({is_showing_group_anchor_offsets:i})},setIsShowingSolderMask:i=>{H9(qD.IS_SHOWING_SOLDER_MASK,i),t({is_showing_solder_mask:i})},setPcbGroupViewMode:i=>{A||(R8e(qD.PCB_GROUP_VIEW_MODE,i),t({pcb_group_view_mode:i}))},setHoveredErrorId:i=>t({hovered_error_id:i})})),eC=e=>{const A=V.useContext(Fct);return bYA(A,e)},Fct=V.createContext(null),v8e=({children:e,initialState:A,disablePcbGroups:t})=>{const i=V.useMemo(()=>N8e(A,t),[t]);return W.jsx(Fct.Provider,{value:i,children:e})},L8e=()=>{const e=eC(t=>t.pcb_viewer_id),A=(t,i)=>Xg(t,{containerId:e,...i});return A.error=(t,i)=>Xg.error(t,{containerId:e,...i}),A.promise=Xg.promise,A},U8e=()=>{V.useEffect(()=>{J3e()},[]);const e=eC(A=>A.pcb_viewer_id);return W.jsx(Y3e,{position:"top-center",containerId:e})},H8e=function(){},Gct=typeof window<"u",Y8e=Gct?V.useLayoutEffect:V.useEffect,J8e=Y8e,Rct={x:0,y:0,width:0,height:0,top:0,left:0,bottom:0,right:0};function T8e(){var e=V.useState(null),A=e[0],t=e[1],i=V.useState(Rct),n=i[0],o=i[1],s=V.useMemo(function(){return new window.ResizeObserver(function(r){if(r[0]){var a=r[0].contentRect,g=a.x,c=a.y,I=a.width,l=a.height,B=a.top,C=a.left,Q=a.bottom,h=a.right;o({x:g,y:c,width:I,height:l,top:B,left:C,bottom:Q,right:h})}})},[]);return J8e(function(){if(A)return s.observe(A),function(){s.disconnect()}},[A]),[t,n]}var yJ=Gct&&typeof window.ResizeObserver<"u"?T8e:function(){return[H8e,Rct]},Mct=({initialTransform:e,initialTouch1:A,initialTouch2:t,finalTouch1:i,finalTouch2:n})=>{if(!i||!n)return e;const o={x:(A.x+t.x)/2,y:(A.y+t.y)/2},s={x:(i.x+n.x)/2,y:(i.y+n.y)/2},r=Math.hypot(t.x-A.x,t.y-A.y),a=Math.hypot(n.x-i.x,n.y-i.y),g=r===0?1:a/r,c=s.x-o.x,I=s.y-o.y;return im(lB(c,I),lB(o.x,o.y),gJ(g,g),lB(-o.x,-o.y),e)},K8e=(e={})=>{const A=V.useRef(null),[t,i]=V.useState(0),n=e.canvasElm??A.current,[o,s]=V.useState(e.initialTransform??_b()),[r,a]=V.useState(0),[g,c]=V.useReducer(d=>d+1,0),I=V.useCallback(d=>{e.onSetTransform&&e.onSetTransform(d),e.transform||s(d)},[e.onSetTransform,s]),l=V.useCallback(d=>{I(d),c()},[I]),B=e.transform??o,C=V.useCallback(()=>{i(Date.now())},[]),Q=V.useRef("none"),h=V.useRef(null),E=V.useRef(null);V.useEffect(()=>{const d=e.canvasElm??A.current;if(d&&!n){a(r+1);return}if(!d){const Z=setTimeout(()=>{a(r+1)},100);return()=>clearTimeout(Z)}let p=e.transform??o,m={x:0,y:0},w={x:0,y:0},D=!1;const S=Z=>({x:Z.pageX-d.getBoundingClientRect().left-window.scrollX,y:Z.pageY-d.getBoundingClientRect().top-window.scrollY});function k(Z){e.enabled!==!1&&(e.shouldDrag&&!e.shouldDrag(Z)||(m=S(Z),!(Date.now()-t<100)&&(D=!0,Z.preventDefault())))}function x(Z){if(!D||e.enabled===!1||e.shouldDrag&&!e.shouldDrag(Z))return;w=S(Z);const $=im(lB(w.x-m.x,w.y-m.y),p);I($),p=$,D=!1}function N(Z){if(S(Z),!D||e.enabled===!1||e.shouldDrag&&!e.shouldDrag(Z))return;w=S(Z);const $=im(lB(w.x-m.x,w.y-m.y),p);I($)}function M(Z){if(e.enabled===!1||e.shouldDrag&&!e.shouldDrag(Z))return;const $=S(Z),eA=im(lB($.x,$.y),gJ(1-Z.deltaY/1e3,1-Z.deltaY/1e3),lB(-$.x,-$.y),p);I(eA),p=eA,Z.preventDefault()}function L(Z){if(!D||e.shouldDrag&&!e.shouldDrag(Z))return;if(d){const eA=d.getBoundingClientRect();if(Z.clientX>=eA.left+10&&Z.clientX<=eA.right-10&&Z.clientY>=eA.top+10&&Z.clientY<=eA.bottom-10)return}D=!1,w=S(Z);const $=im(lB(w.x-m.x,w.y-m.y),p);I($),p=$}function Y(Z){if(Z.preventDefault(),e.enabled!==!1){if(Z.touches.length===1){Q.current="drag";const $=Z.touches[0];h.current={initialTransform:p,initialTouch:{x:$.clientX,y:$.clientY}}}else if(Z.touches.length===2){Q.current="pinch";const $=Z.touches[0],eA=Z.touches[1];E.current={initialTransform:p,initialTouch1:{x:$.clientX,y:$.clientY},initialTouch2:{x:eA.clientX,y:eA.clientY},finalTouch1:null,finalTouch2:null}}}}function H(Z){if(Z.preventDefault(),e.enabled!==!1){if(Q.current==="drag"&&Z.touches.length===1&&h.current){const $=Z.touches[0],eA={x:$.clientX,y:$.clientY},aA=eA.x-h.current.initialTouch.x,tA=eA.y-h.current.initialTouch.y,nA=im(lB(aA,tA),h.current.initialTransform);I(nA)}else if(Q.current==="pinch"&&Z.touches.length===2&&E.current){const $=Z.touches[0],eA=Z.touches[1];E.current.finalTouch1={x:$.clientX,y:$.clientY},E.current.finalTouch2={x:eA.clientX,y:eA.clientY};const aA=Mct(E.current);I(aA)}}}function O(Z){Z.preventDefault();const $=Z.changedTouches[0];if(Q.current==="drag"&&h.current&&$){const eA={x:$.clientX,y:$.clientY},aA=eA.x-h.current.initialTouch.x,tA=eA.y-h.current.initialTouch.y,nA=im(lB(aA,tA),h.current.initialTransform);I(nA),p=nA}else if(Q.current==="pinch"&&E.current){const eA=Mct(E.current);I(eA),p=eA}Q.current="none",h.current=null,E.current=null}return d.addEventListener("mousedown",k),d.addEventListener("mouseup",x),window.addEventListener("mousemove",N),d.addEventListener("mouseout",L),d.addEventListener("wheel",M),d.addEventListener("touchstart",Y,{passive:!1}),d.addEventListener("touchmove",H,{passive:!1}),d.addEventListener("touchend",O,{passive:!1}),d.addEventListener("touchcancel",O,{passive:!1}),()=>{d.removeEventListener("mousedown",k),d.removeEventListener("mouseup",x),window.removeEventListener("mousemove",N),d.removeEventListener("mouseout",L),d.removeEventListener("wheel",M),d.removeEventListener("touchstart",Y),d.removeEventListener("touchmove",H),d.removeEventListener("touchend",O),d.removeEventListener("touchcancel",O)}},[n,r,g,t,e.enabled,e.shouldDrag]);const u=V.useCallback(d=>qi(B,d),[B]);return{ref:A,transform:B,applyTransformToPoint:u,setTransform:l,cancelDrag:C}},P8e=K8e;function q8e(e){const A=new Map;let t=0;function i(n){for(const[,s]of A)if(s.has(n))return s;const o=new Set;return A.set(`connectivity_net${t++}`,o),o}for(const n of e){let o=null;for(const s of n){if(!o)o=i(s);else if(!o.has(s)){const r=i(s);if(r!==o){for(const a of r)o.add(a);A.delete(Array.from(A.entries()).find(([,a])=>a===r)[0])}}o.add(s)}}return Object.fromEntries(Array.from(A.entries()).map(([n,o])=>[n,Array.from(o)]))}var O8e=class{netMap;idToNetMap;constructor(e){this.netMap=e,this.idToNetMap={};for(const[A,t]of Object.entries(e))for(const i of t)this.idToNetMap[i]=A}addConnections(e){for(const A of e){const t=new Set;for(const n of A){const o=this.idToNetMap[n];o&&t.add(o)}let i;if(t.size===0)i=`connectivity_net${Object.keys(this.netMap).length}`,this.netMap[i]=[];else if(t.size===1)i=t.values().next().value??`connectivity_net${Object.keys(this.netMap).length}`;else{i=t.values().next().value??`connectivity_net${Object.keys(this.netMap).length}`;for(const n of t)if(n!==i){this.netMap[i].push(...this.netMap[n]),this.netMap[n]=this.netMap[i];for(const o of this.netMap[i])this.idToNetMap[o]=i}}for(const n of A)this.netMap[i].includes(n)||this.netMap[i].push(n),this.idToNetMap[n]=i}}getIdsConnectedToNet(e){return this.netMap[e]||[]}getNetConnectedToId(e){return this.idToNetMap[e]}areIdsConnected(e,A){if(e===A)return!0;const t=this.getNetConnectedToId(e);if(!t)return!1;const i=this.getNetConnectedToId(A);return i?t===i||i===e||i===e:!1}areAllIdsConnected(e){const A=this.getNetConnectedToId(e[0]);for(const t of e){const i=this.getNetConnectedToId(t);if(i===void 0||i!==A)return!1}return!0}},Nct=e=>{const A=[];for(const i of e)if(i.type==="source_trace")A.push([i.source_trace_id,...i.connected_source_port_ids??[],...i.connected_source_net_ids??[]].filter(Boolean));else if(i.type==="pcb_port"){const{pcb_port_id:n,source_port_id:o}=i;o&&n&&A.push([o,n])}else if(i.type==="pcb_smtpad"){const{pcb_smtpad_id:n,pcb_port_id:o}=i;o&&n&&A.push([n,o])}else if(i.type==="pcb_plated_hole"){const{pcb_plated_hole_id:n,pcb_port_id:o}=i;o&&n&&A.push([n,o])}else if(i.type==="pcb_trace"){const{pcb_trace_id:n,source_trace_id:o}=i,s=Array.isArray(i.route)?i.route.filter(r=>r&&r.route_type==="wire"):[];if(o&&n&&A.push([n,o]),Array.isArray(s)){const r=s.find(g=>g?.start_pcb_port_id)?.start_pcb_port_id,a=s.find(g=>g?.end_pcb_port_id)?.end_pcb_port_id;r&&n&&a&&A.push([r,n,a])}}else if(i.type==="pcb_via"){const{pcb_via_id:n,pcb_trace_id:o}=i;o&&n&&A.push([n,o])}else if(i.type==="source_component"&&i.internally_connected_source_port_ids)for(const n of i.internally_connected_source_port_ids)A.push(n);const t=q8e(A);return new O8e(t)};function W8e({primitivesWithoutInteractionMetadata:e,drawingObjectIdsWithMouseOver:A,primitiveIdsInMousedOverNet:t}){const i=[];for(const n of e){const o={...n};n?.layer==="drill"?(o.is_in_highlighted_net=!1,o.is_mouse_over=!1):A.has(n._pcb_drawing_object_id)?o.is_mouse_over=!0:n._element&&("pcb_trace_id"in n._element&&t.includes(n._element.pcb_trace_id)||"pcb_port_id"in n._element&&t.includes(n._element.pcb_port_id))?o.is_in_highlighted_net=!0:(o.is_in_highlighted_net=!1,o.is_mouse_over=!1),i.push(o)}return i}function Z8e(e,A){if(e.length<2)throw new Error("Stroke must have at least two points");const t=e.map(I=>Array.isArray(I)?{x:I[0],y:I[1]}:I),i=[],n=[];function o(I,l){const B=l.x-I.x,C=l.y-I.y,Q=Math.sqrt(B*B+C*C);return{x:-C/Q,y:B/Q}}function s(I,l,B,C){const Q=C/2,h={x:I.x+l.x*Q*B,y:I.y+l.y*Q*B};B>0?i.push(h):n.unshift(h)}const r=o(t[0],t[1]),a=t[0].trace_width??A;s(t[0],r,1,a),s(t[0],r,-1,a);for(let I=1;I<t.length-1;I++){const l=t[I-1],B=t[I],C=t[I+1],Q=o(l,B),h=o(B,C),E=Q.x+h.x,u=Q.y+h.y,d=Math.sqrt(E*E+u*u),p=B.trace_width??A;if(d/2>2*(p/2))s(B,Q,1,p),s(B,h,1,p),s(B,Q,-1,p),s(B,h,-1,p);else{const w=1/d;s(B,{x:E*w,y:u*w},1,p),s(B,{x:E*w,y:u*w},-1,p)}}const g=o(t[t.length-2],t[t.length-1]),c=t[t.length-1].trace_width??A;return s(t[t.length-1],g,1,c),s(t[t.length-1],g,-1,c),[...i,...n]}var V8e=(e,A)=>{const{x:t,y:i,width:n,height:o,layer:s,rect_border_radius:r}=e,a=e.corner_radius??r??0,g=[{_pcb_drawing_object_id:nm("rect"),pcb_drawing_type:"rect",x:t,y:i,w:n,h:o,layer:s||"top",_element:e,_parent_pcb_component:A._parent_pcb_component,_parent_source_component:A._parent_source_component,_source_port:A._source_port,roundness:a,...e.shape==="rotated_rect"&&e.ccw_rotation!==void 0?{ccw_rotation:e.ccw_rotation}:{}}];if(e.is_covered_with_solder_mask){const c=s==="bottom"?"soldermask_with_copper_bottom":"soldermask_with_copper_top",l={...{_pcb_drawing_object_id:nm("rect"),pcb_drawing_type:"rect",x:t,y:i,w:n,h:o,layer:c,_element:e,_parent_pcb_component:A._parent_pcb_component,_parent_source_component:A._parent_source_component,_source_port:A._source_port,roundness:a,...e.shape==="rotated_rect"&&e.ccw_rotation!==void 0?{ccw_rotation:e.ccw_rotation}:{}},..."solder_mask_color"in e&&e.solder_mask_color?{color:e.solder_mask_color}:{}};g.push(l)}return g},j8e=(e,A)=>{const{x:t,y:i,radius:n,layer:o}=e,s=[{_pcb_drawing_object_id:nm("circle"),pcb_drawing_type:"circle",x:t,y:i,r:n,layer:o||"top",_element:e,_parent_pcb_component:A._parent_pcb_component,_parent_source_component:A._parent_source_component,_source_port:A._source_port}];if(e.is_covered_with_solder_mask){const r=o==="bottom"?"soldermask_with_copper_bottom":"soldermask_with_copper_top",a={_pcb_drawing_object_id:nm("circle"),pcb_drawing_type:"circle",x:t,y:i,r:n,layer:r,_element:e,_parent_pcb_component:A._parent_pcb_component,_parent_source_component:A._parent_source_component,_source_port:A._source_port,..."solder_mask_color"in e&&e.solder_mask_color?{color:e.solder_mask_color}:{}};s.push(a)}return s},z8e=(e,A)=>{const{layer:t,points:i}=e,n=[{_pcb_drawing_object_id:nm("polygon"),pcb_drawing_type:"polygon",points:UfA(i),layer:t||"top",_element:e,_parent_pcb_component:A._parent_pcb_component,_parent_source_component:A._parent_source_component,_source_port:A._source_port}];if(e.is_covered_with_solder_mask){const o=t==="bottom"?"soldermask_with_copper_bottom":"soldermask_with_copper_top",s={_pcb_drawing_object_id:nm("polygon"),pcb_drawing_type:"polygon",points:UfA(i),layer:o,_element:e,_parent_pcb_component:A._parent_pcb_component,_parent_source_component:A._parent_source_component,_source_port:A._source_port,..."solder_mask_color"in e&&e.solder_mask_color?{color:e.solder_mask_color}:{}};n.push(s)}return n},X8e=(e,A)=>{const{x:t,y:i,width:n,height:o,layer:s}=e,r=[{_pcb_drawing_object_id:nm("pill"),pcb_drawing_type:"pill",x:t,y:i,w:n,h:o,layer:s||"top",_element:e,_parent_pcb_component:A._parent_pcb_component,_parent_source_component:A._parent_source_component,_source_port:A._source_port}];if(e.is_covered_with_solder_mask){const a=s==="bottom"?"soldermask_with_copper_bottom":"soldermask_with_copper_top",g={_pcb_drawing_object_id:nm("pill"),pcb_drawing_type:"pill",x:t,y:i,w:n,h:o,layer:a,_element:e,_parent_pcb_component:A._parent_pcb_component,_parent_source_component:A._parent_source_component,_source_port:A._source_port,..."solder_mask_color"in e&&e.solder_mask_color?{color:e.solder_mask_color}:{}};r.push(g)}return r},$8e=(e,A)=>{const{x:t,y:i,width:n,height:o,layer:s,ccw_rotation:r}=e,a=[{_pcb_drawing_object_id:nm("pill"),pcb_drawing_type:"pill",x:t,y:i,w:n,h:o,layer:s||"top",_element:e,_parent_pcb_component:A._parent_pcb_component,_parent_source_component:A._parent_source_component,_source_port:A._source_port,ccw_rotation:r}];if(e.is_covered_with_solder_mask){const g=s==="bottom"?"soldermask_with_copper_bottom":"soldermask_with_copper_top",c={_pcb_drawing_object_id:nm("pill"),pcb_drawing_type:"pill",x:t,y:i,w:n,h:o,layer:g,_element:e,_parent_pcb_component:A._parent_pcb_component,_parent_source_component:A._parent_source_component,_source_port:A._source_port,ccw_rotation:r,..."solder_mask_color"in e&&e.solder_mask_color?{color:e.solder_mask_color}:{}};a.push(c)}return a},AWe=(e,A)=>{const{_parent_pcb_component:t,_parent_source_component:i}=A,n=e,o=typeof n.font_size=="string"?he.parse(n.font_size):n.font_size??.2;let s;return n.knockout_padding&&(s={left:typeof n.knockout_padding.left=="string"?he.parse(n.knockout_padding.left):n.knockout_padding.left,top:typeof n.knockout_padding.top=="string"?he.parse(n.knockout_padding.top):n.knockout_padding.top,bottom:typeof n.knockout_padding.bottom=="string"?he.parse(n.knockout_padding.bottom):n.knockout_padding.bottom,right:typeof n.knockout_padding.right=="string"?he.parse(n.knockout_padding.right):n.knockout_padding.right}),[{_pcb_drawing_object_id:nm("text"),pcb_drawing_type:"text",x:n.anchor_position.x,y:n.anchor_position.y,layer:n.layer,align:n.anchor_alignment??"center",text:n.text,size:o,ccw_rotation:n.ccw_rotation,is_mirrored:n.is_mirrored,is_knockout:n.is_knockout,knockout_padding:s,_element:e,_parent_pcb_component:t,_parent_source_component:i}]},_I=0,nm=e=>`${e}_${_I++}`,UfA=e=>(e??[]).map(A=>({x:he.parse(A.x),y:he.parse(A.y)})),tWe=(e,A)=>{const t="pcb_component_id"in e?A.find(s=>s.type==="pcb_component"&&s.pcb_component_id===e.pcb_component_id):void 0,i=t&&"source_component_id"in t?A.find(s=>s.type==="source_component"&&s.source_component_id===t.source_component_id):void 0,n="source_port_id"in e?e.source_port_id:"pcb_port_id"in e?Gb(A).pcb_port.get(e.pcb_port_id)?.source_port_id:void 0,o=n?A.find(s=>s.type==="source_port"&&s.source_port_id===n):void 0;switch(e.type){case"pcb_smtpad":{const s={_parent_pcb_component:t,_parent_source_component:i,_source_port:o};return e.shape==="rect"||e.shape==="rotated_rect"?V8e(e,s):e.shape==="circle"?j8e(e,s):e.shape==="polygon"?z8e(e,s):e.shape==="pill"?X8e(e,s):e.shape==="rotated_pill"?$8e(e,s):[]}case"pcb_trace":{const s=[];if(e.route_thickness_mode==="interpolated"){const g=e.route.map(l=>({x:l.x,y:l.y,trace_width:l.route_type==="wire"?l.width:.5})),c=Z8e(g,.5),I=e.route[0].layer;return s.push({_pcb_drawing_object_id:`polygon_${_I++}`,_element:e,pcb_drawing_type:"polygon",points:c,layer:I}),e.route.forEach(l=>{l.route_type==="via"&&s.push({_pcb_drawing_object_id:`circle_${_I++}`,_element:e,pcb_drawing_type:"circle",x:l.x,y:l.y,r:l.outer_diameter/2,layer:l.from_layer})}),s}let r=null,a=null;for(const g of e.route)g.route_type==="wire"&&(r!==null&&a!==null&&s.push({_pcb_drawing_object_id:`line_${_I++}`,_element:e,pcb_drawing_type:"line",x1:r,y1:a,x2:g.x,y2:g.y,width:g.width,squareCap:!1,layer:g.layer}),r=g.x,a=g.y);return s}case"pcb_via":{const{x:s,y:r,outer_diameter:a,hole_diameter:g}=e,c=e.from_layer,I=e.to_layer,l=e.layers,B=[];c&&I?B.push(c,I):l&&Array.isArray(l)?B.push(...l):B.push("top","bottom");const C=[];for(const Q of B)C.push({_pcb_drawing_object_id:`circle_${_I++}`,pcb_drawing_type:"circle",x:s,y:r,r:a/2,layer:Q,_element:e,_parent_pcb_component:t,_parent_source_component:i});return C.push({_pcb_drawing_object_id:`circle_${_I++}`,pcb_drawing_type:"circle",x:s,y:r,r:g/2,layer:"drill",_element:e}),C}case"pcb_plated_hole":if(e.shape==="circle"){const{x:s,y:r,hole_diameter:a,outer_diameter:g}=e;return[{_pcb_drawing_object_id:`circle_${_I++}`,pcb_drawing_type:"circle",x:s,y:r,r:g/2,layer:"top",_element:e,_parent_pcb_component:t,_parent_source_component:i,_source_port:o},{_pcb_drawing_object_id:`circle_${_I++}`,pcb_drawing_type:"circle",x:s,y:r,r:a/2,layer:"drill",_element:e}]}else if(e.shape==="oval"){const{x:s,y:r,outer_height:a,outer_width:g,hole_height:c,hole_width:I}=e;return[{_pcb_drawing_object_id:`oval_${_I++}`,pcb_drawing_type:"oval",x:s,y:r,rX:g/2,rY:a/2,layer:"top",_element:e,_parent_pcb_component:t,_parent_source_component:i,_source_port:o},{_pcb_drawing_object_id:`oval_${_I++}`,_element:e,pcb_drawing_type:"oval",x:s,y:r,rX:I/2,rY:c/2,layer:"drill"}]}else if(e.shape==="pill"){const{x:s,y:r,outer_height:a,outer_width:g,hole_height:c,hole_width:I}=e;return[{_pcb_drawing_object_id:`pill_${_I++}`,pcb_drawing_type:"pill",x:s,y:r,w:g,h:a,layer:"top",_element:e,_parent_pcb_component:t,_parent_source_component:i,_source_port:o,ccw_rotation:e.ccw_rotation},{_pcb_drawing_object_id:`pill_${_I++}`,_element:e,pcb_drawing_type:"pill",x:s,y:r,w:I,h:c,layer:"drill",ccw_rotation:e.ccw_rotation}]}else if(e.shape==="circular_hole_with_rect_pad"){const{x:s,y:r,hole_diameter:a,rect_pad_width:g,rect_pad_height:c,rect_border_radius:I,hole_offset_x:l,hole_offset_y:B}=e,C=he.parse(l??0),Q=he.parse(B??0);return[{_pcb_drawing_object_id:`rect_${_I++}`,pcb_drawing_type:"rect",x:s,y:r,w:g,h:c,layer:"top",_element:e,_parent_pcb_component:t,_parent_source_component:i,_source_port:o,roundness:I},{_pcb_drawing_object_id:`rect_${_I++}`,pcb_drawing_type:"rect",x:s,y:r,w:g,h:c,layer:"bottom",_element:e,_parent_pcb_component:t,_parent_source_component:i,_source_port:o,roundness:I},{_pcb_drawing_object_id:`circle_${_I++}`,_element:e,pcb_drawing_type:"circle",x:s+C,y:r+Q,r:a/2,layer:"drill"}]}else if(e.shape==="pill_hole_with_rect_pad"){const{x:s,y:r,hole_width:a,hole_height:g,rect_pad_width:c,rect_pad_height:I,rect_border_radius:l}=e;return[{_pcb_drawing_object_id:`rect_${_I++}`,pcb_drawing_type:"rect",x:s,y:r,w:c,h:I,layer:"top",_element:e,_parent_pcb_component:t,_parent_source_component:i,_source_port:o,roundness:l},{_pcb_drawing_object_id:`rect_${_I++}`,pcb_drawing_type:"rect",x:s,y:r,w:c,h:I,layer:"bottom",_element:e,_parent_pcb_component:t,_parent_source_component:i,_source_port:o,roundness:l},{_pcb_drawing_object_id:`pill_${_I++}`,_element:e,pcb_drawing_type:"pill",x:s,y:r,w:a,h:g,layer:"drill"}]}else if(e.shape==="rotated_pill_hole_with_rect_pad"){const{x:s,y:r,hole_width:a,hole_height:g,hole_ccw_rotation:c,rect_pad_width:I,rect_pad_height:l,rect_ccw_rotation:B,rect_border_radius:C}=e;return[{_pcb_drawing_object_id:`rect_${_I++}`,pcb_drawing_type:"rect",x:s,y:r,w:I,h:l,layer:"top",_element:e,_parent_pcb_component:t,_parent_source_component:i,_source_port:o,ccw_rotation:B,roundness:C},{_pcb_drawing_object_id:`rect_${_I++}`,pcb_drawing_type:"rect",x:s,y:r,w:I,h:l,layer:"bottom",_element:e,_parent_pcb_component:t,_parent_source_component:i,_source_port:o,ccw_rotation:B,roundness:C},{_pcb_drawing_object_id:`pill_${_I++}`,_element:e,pcb_drawing_type:"pill",x:s,y:r,w:a,h:g,layer:"drill",ccw_rotation:c}]}else if(e.shape==="hole_with_polygon_pad"){const{x:s,y:r,pad_outline:a,hole_shape:g,hole_diameter:c,hole_width:I,hole_height:l,layers:B,hole_offset_x:C,hole_offset_y:Q}=e,h=he.parse(C??0),E=he.parse(Q??0),u=a,d=[];if(u&&Array.isArray(u)){const w=UfA(u).map(D=>({x:D.x+s,y:D.y+r}));for(const D of B||["top","bottom"])d.push({_pcb_drawing_object_id:`polygon_${_I++}`,pcb_drawing_type:"polygon",points:w,layer:D,_element:e,_parent_pcb_component:t,_parent_source_component:i,_source_port:o})}const p={x:s+h,y:r+E},m=[];return g==="circle"?m.push({_pcb_drawing_object_id:`circle_${_I++}`,pcb_drawing_type:"circle",x:p.x,y:p.y,r:(c??0)/2,layer:"drill",_element:e,_parent_pcb_component:t,_parent_source_component:i}):g==="oval"?m.push({_pcb_drawing_object_id:`oval_${_I++}`,pcb_drawing_type:"oval",x:p.x,y:p.y,rX:(I??0)/2,rY:(l??0)/2,layer:"drill",_element:e,_parent_pcb_component:t,_parent_source_component:i}):(g==="pill"||g==="rotated_pill")&&m.push({_pcb_drawing_object_id:`pill_${_I++}`,pcb_drawing_type:"pill",x:p.x,y:p.y,w:I??0,h:l??0,layer:"drill",_element:e,_parent_pcb_component:t,_parent_source_component:i,ccw_rotation:e.ccw_rotation}),[...d,...m]}else return[];case"pcb_copper_text":return AWe(e,{_parent_pcb_component:t,_parent_source_component:i})}return[]},ln={board:{anchor:"rgb(255, 38, 226)",aux_items:"rgb(255, 255, 255)",b_adhes:"rgb(0, 0, 132)",b_crtyd:"rgb(38, 233, 255)",b_fab:"rgb(88, 93, 132)",b_mask:"rgba(2, 255, 238, 0.400)",b_paste:"rgb(0, 194, 194)",b_silks:"rgb(242, 237, 161)",background:"rgb(0, 16, 35)",cmts_user:"rgb(89, 148, 220)",copper:{b:"rgb(77, 127, 196)",f:"rgb(200, 52, 52)",in1:"rgb(127, 200, 127)",in10:"rgb(237, 124, 51)",in11:"rgb(91, 195, 235)",in12:"rgb(247, 111, 142)",in13:"rgb(167, 165, 198)",in14:"rgb(40, 204, 217)",in15:"rgb(232, 178, 167)",in16:"rgb(242, 237, 161)",in17:"rgb(237, 124, 51)",in18:"rgb(91, 195, 235)",in19:"rgb(247, 111, 142)",in2:"rgb(206, 125, 44)",in20:"rgb(167, 165, 198)",in21:"rgb(40, 204, 217)",in22:"rgb(232, 178, 167)",in23:"rgb(242, 237, 161)",in24:"rgb(237, 124, 51)",in25:"rgb(91, 195, 235)",in26:"rgb(247, 111, 142)",in27:"rgb(167, 165, 198)",in28:"rgb(40, 204, 217)",in29:"rgb(232, 178, 167)",in3:"rgb(79, 203, 203)",in30:"rgb(242, 237, 161)",in4:"rgb(219, 98, 139)",in5:"rgb(167, 165, 198)",in6:"rgb(40, 204, 217)",in7:"rgb(232, 178, 167)",in8:"rgb(242, 237, 161)",in9:"rgb(141, 203, 129)"},cursor:"rgb(255, 255, 255)",drc:"rgb(194, 194, 194)",drc_error:"rgba(215, 91, 107, 0.800)",drc_exclusion:"rgb(255, 255, 255)",drc_warning:"rgba(255, 208, 66, 0.902)",dwgs_user:"rgb(194, 194, 194)",eco1_user:"rgb(180, 219, 210)",eco2_user:"rgb(216, 200, 82)",edge_cuts:"rgb(208, 210, 205)",f_adhes:"rgb(132, 0, 132)",f_crtyd:"rgb(255, 0, 245)",f_fab:"rgb(175, 175, 175)",f_mask:"rgba(216, 100, 255, 0.400)",f_paste:"rgba(180, 160, 154, 0.902)",f_silks:"rgb(242, 237, 161)",footprint_text_back:"rgb(0, 0, 132)",footprint_text_front:"rgb(194, 194, 194)",footprint_text_invisible:"rgb(132, 132, 132)",grid:"rgb(132, 132, 132)",grid_axes:"rgb(194, 194, 194)",margin:"rgb(255, 38, 226)",microvia:"rgb(0, 132, 132)",no_connect:"rgb(0, 0, 132)",pad_back:"rgb(77, 127, 196)",pad_front:"rgb(200, 52, 52)",pad_plated_hole:"rgb(194, 194, 0)",pad_through_hole:"rgb(227, 183, 46)",plated_hole:"rgb(26, 196, 210)",ratsnest:"rgba(245, 255, 213, 0.702)",select_overlay:"rgb(4, 255, 67)",soldermaskWithCopper:{top:"rgb(18, 82, 50)",bottom:"rgb(77, 127, 196)"},soldermask:{top:"rgb(12, 55, 33)",bottom:"rgb(12, 55, 33)"},through_via:"rgb(236, 236, 236)",user_1:"rgb(194, 194, 194)",user_2:"rgb(89, 148, 220)",user_3:"rgb(180, 219, 210)",user_4:"rgb(216, 200, 82)",user_5:"rgb(194, 194, 194)",user_6:"rgb(89, 148, 220)",user_7:"rgb(180, 219, 210)",user_8:"rgb(216, 200, 82)",user_9:"rgb(232, 178, 167)",via_blind_buried:"rgb(187, 151, 38)",via_hole:"rgb(227, 183, 46)",via_micro:"rgb(0, 132, 132)",via_through:"rgb(236, 236, 236)",worksheet:"rgb(200, 114, 171)"}},_f=(e,A=1)=>{if(Math.abs(e.a)!==Math.abs(e.d))throw new Error("Cannot scale non-uniformly");return A*Math.abs(e.a)},fc={elementOverlay:40,dimensionOverlay:40,editTraceHintOverlay:40,errorOverlay:40,pcbGroupOverlay:35,ratsNestOverlay:30,toolbarOverlay:70,warnings:30,topLayer:20,clickToInteractOverlay:100},Y9={red:"red",black:"black",green:"green",board:"rgb(255, 255, 255)",other:"#eee",top:ln.board.copper.f,inner1:ln.board.copper.in1,inner2:ln.board.copper.in2,inner3:ln.board.copper.in3,inner4:ln.board.copper.in4,inner5:ln.board.copper.in5,inner6:ln.board.copper.in6,inner7:ln.board.copper.in7,inner8:ln.board.copper.in8,bottom:ln.board.copper.b,drill:ln.board.anchor,keepout:ln.board.background,tkeepout:ln.board.b_crtyd,tplace:ln.board.b_silks,top_courtyard:ln.board.f_crtyd,bottom_courtyard:ln.board.b_crtyd,top_silkscreen:ln.board.f_silks,bottom_silkscreen:ln.board.b_silks,top_fabrication:ln.board.f_fab,bottom_fabrication:ln.board.b_fab,soldermask_top:ln.board.soldermask.top,soldermask_bottom:ln.board.soldermask.bottom,soldermask_with_copper_top:ln.board.soldermaskWithCopper.top,soldermask_with_copper_bottom:ln.board.soldermaskWithCopper.bottom,bottom_notes:ln.board.user_2,top_notes:ln.board.user_2,...ln.board},eWe=["inner6","inner5","inner4","inner3","inner2","inner1","bottom","soldermask_bottom","bottom_silkscreen","top","soldermask_top","soldermask_with_copper_bottom","soldermask_with_copper_top","bottom_courtyard","bottom_fabrication","top_courtyard","top_fabrication","edge_cuts","top_silkscreen","board"],iWe=class{canvasLayerMap;ctxLayerMap;aperture;transform;foregroundLayer="top";lastPoint;constructor(e){this.canvasLayerMap=e,this.ctxLayerMap=Object.fromEntries(Object.entries(e).map(([A,t])=>[A,t.getContext("2d")])),this.transform=_b(),this.transform.d*=-1,this.transform=im(this.transform,lB(0,-500)),this.lastPoint={x:0,y:0},this.equip({})}clear(){for(const e of Object.values(this.ctxLayerMap))e.clearRect(0,0,e.canvas.width,e.canvas.height)}equip(e){this.aperture={fontSize:0,shape:"circle",mode:"add",size:0,color:"red",layer:"top",opacity:this.foregroundLayer===e.color?1:.5,...e}}drawMeshPattern(e,A,t,i,n,o=45){const s=this.getLayerCtx(),[r,a]=qi(this.transform,[e,A]),[g,c]=qi(this.transform,[e+t,A+i]),I=_f(this.transform,n);s.lineWidth=1,s.strokeStyle=this.aperture.color;const l=B=>{const C=Math.sin(B),Q=Math.cos(B),h=Math.sqrt((g-r)**2+(c-a)**2);for(let E=-h;E<=h;E+=I)s.beginPath(),s.moveTo(r+E*Q-h*C,a+E*C+h*Q),s.lineTo(r+E*Q+h*C,a+E*C-h*Q),s.stroke()};l(o*Math.PI/180),l((o+90)*Math.PI/180)}rect({x:e,y:A,w:t,h:i,mesh_fill:n,is_filled:o=!0,has_stroke:s,is_stroke_dashed:r,stroke_width:a,roundness:g}){const[c,I]=qi(this.transform,[e-t/2,A-i/2]),[l,B]=qi(this.transform,[e+t/2,A+i/2]);this.applyAperture();const C=this.getLayerCtx(),Q=g?_f(this.transform,g):0,h=s===void 0?o===!1:s;if(n)C.save(),C.beginPath(),Q>0&&C.roundRect?C.roundRect(c,I,l-c,B-I,Q):C.rect(c,I,l-c,B-I),C.clip(),this.drawMeshPattern(e-t/2,A-i/2,t,i,.15),C.restore(),Q>0&&C.roundRect?(C.beginPath(),C.roundRect(c,I,l-c,B-I,Q),C.stroke()):C.strokeRect(c,I,l-c,B-I);else if(o!==!1&&(Q>0&&C.roundRect?(C.beginPath(),C.roundRect(c,I,l-c,B-I,Q),C.fill()):C.fillRect(c,I,l-c,B-I)),h){const E=C.lineWidth;if(a!==void 0&&(C.lineWidth=_f(this.transform,a)),r){let u=[];const d=Math.abs(this.transform.a);if(d>0){const m=.1*d,w=m*1.3;m>.5&&(u=[m,w])}C.setLineDash(u)}Q>0&&C.roundRect?(C.beginPath(),C.roundRect(c,I,l-c,B-I,Q),C.stroke()):C.strokeRect(c,I,l-c,B-I),r&&C.setLineDash([]),a!==void 0&&(C.lineWidth=E)}}rotatedRect(e,A,t,i,n,o,s){const r=this.getLayerCtx();this.applyAperture();const[a,g]=qi(this.transform,[e-t/2,A-i/2]),[c,I]=qi(this.transform,[e+t/2,A+i/2]),l=o?_f(this.transform,o):0;r.save();const[B,C]=qi(this.transform,[e,A]);r.translate(B,C);const Q=360-n;n&&r.rotate(Q*Math.PI/180),r.translate(-B,-C),s?(r.beginPath(),l>0&&r.roundRect?r.roundRect(a,g,c-a,I-g,l):r.rect(a,g,c-a,I-g),r.clip(),this.drawMeshPattern(e-t/2,A-i/2,t,i,.15),l>0&&r.roundRect?(r.beginPath(),r.roundRect(a,g,c-a,I-g,l),r.stroke()):r.strokeRect(a,g,c-a,I-g)):l>0&&r.roundRect?(r.beginPath(),r.roundRect(a,g,c-a,I-g,l),r.fill()):r.fillRect(a,g,c-a,I-g),r.restore()}rotatedPill(e,A,t,i,n){const o=this.getLayerCtx();this.applyAperture(),o.save();const[s,r]=qi(this.transform,[e,A]);o.translate(s,r);const a=360-n;n&&o.rotate(a*Math.PI/180),o.translate(-s,-r),this.pill(e,A,t,i),o.restore()}circle(e,A,t,i,n=!0){const o=_f(this.transform,t),[s,r]=qi(this.transform,[e,A]);this.applyAperture();const a=this.getLayerCtx();i?(a.save(),a.beginPath(),a.arc(s,r,o,0,2*Math.PI),a.clip(),this.drawMeshPattern(e-t,A-t,t*2,t*2,.15),a.restore(),a.beginPath(),a.arc(s,r,o,0,2*Math.PI),a.stroke()):(a.beginPath(),a.arc(s,r,o,0,2*Math.PI),a.fill())}oval(e,A,t,i){const n=_f(this.transform,t),o=_f(this.transform,i),[s,r]=qi(this.transform,[e,A]);this.applyAperture();const a=this.getLayerCtx();a.beginPath(),a.ellipse(s,r,n,o,0,0,2*Math.PI),a.fill(),a.closePath()}pill(e,A,t,i){const[n,o]=qi(this.transform,[e-t/2,A+i/2]),s=_f(this.transform,t),r=_f(this.transform,i),a=Math.min(s,r)/2;this.applyAperture();const g=this.getLayerCtx();g.beginPath(),g.arc(n+a,o+a,a,Math.PI,Math.PI*1.5),g.arc(n+s-a,o+a,a,Math.PI*1.5,0),g.arc(n+s-a,o+r-a,a,0,Math.PI*.5),g.arc(n+a,o+r-a,a,Math.PI*.5,Math.PI),g.fill(),g.closePath()}polygon(e){if(e.length<3)return;this.applyAperture();const A=this.getLayerCtx(),t=e.map(n=>qi(this.transform,[n.x,n.y]));A.beginPath(),A.moveTo(t[0][0],t[0][1]);for(let n=1;n<t.length;n++)A.lineTo(t[n][0],t[n][1]);A.closePath(),A.fill("evenodd");const i=_f(this.transform,this.aperture.size);i>0&&(A.lineWidth=i,A.stroke())}debugText(e,A,t){const[i,n]=qi(this.transform,[A,t]);this.applyAperture();const o=this.getLayerCtx();o.font="10px sans-serif",o.fillText(e,i,n)}getLayerCtx(){const e=this.ctxLayerMap[this.aperture.layer];if(!e)throw new Error(`No context for layer "${this.aperture.layer}"`);return e}orderAndFadeLayers(){const{canvasLayerMap:e,foregroundLayer:A}=this,t=A==="top"?"top_silkscreen":A==="bottom"?"bottom_silkscreen":void 0,i=A==="top"?"top_notes":A==="bottom"?"bottom_notes":void 0,n=A==="top"?"top_fabrication":A==="bottom"?"bottom_fabrication":void 0,o=A==="top"?"soldermask_with_copper_top":A==="bottom"?"soldermask_with_copper_bottom":void 0,s=new Set([A,"drill","edge_cuts","other","board",...t?[t]:[],...i?[i]:[],...n?[n]:[],...o?[o]:[]]),r=[A,"edge_cuts",...t?[t]:[],...i?[i]:[],...n?[n]:[],...o?[o]:[]],a=[...eWe.filter(g=>!r.includes(g)),A,...o?[o]:[],"edge_cuts","drill",...t?[t]:[],...i?[i]:[],...n?[n]:[]];a.forEach((g,c)=>{const I=e[g];I&&(I.style.zIndex=`${fc.topLayer-(a.length-c)}`,I.style.opacity=s.has(g)?"1":"0.5")})}applyAperture(){const{transform:e,aperture:A}=this;let{size:t,mode:i,color:n,fontSize:o,layer:s}=A;s in this.ctxLayerMap||(this.aperture.layer="other");const r=this.getLayerCtx();if(!r)throw new Error(`No context for layer "${this.foregroundLayer}"`);if(n||(n="undefined"),r.lineWidth=_f(e,t),r.lineCap="round",i==="add"){r.globalCompositeOperation="source-over";let a=Y9[n.toLowerCase()];if(!a)try{a=Na(n).rgb().toString()}catch{console.warn(`Invalid color format: '${n}'`),a="white"}r.fillStyle=a,r.strokeStyle=a}else r.globalCompositeOperation="destination-out",r.fillStyle="rgba(0,0,0,1)",r.strokeStyle="rgba(0,0,0,1)";r.font=`${_f(kb(e),o)}px sans-serif`}moveTo(e,A){this.lastPoint={x:e,y:A}}lineTo(e,A){const[t,i]=qi(this.transform,[e,A]),{size:n,shape:o,mode:s}=this.aperture,r=_f(this.transform,n),{lastPoint:a}=this,g=qi(this.transform,a);this.applyAperture();const c=this.getLayerCtx();o==="square"&&c.fillRect(g.x-r/2,g.y-r/2,r,r),c.beginPath(),c.moveTo(g.x,g.y),c.lineTo(t,i),c.stroke(),c.closePath(),o==="square"&&c.fillRect(t-r/2,i-r/2,r,r),this.lastPoint={x:e,y:A}}polygonWithArcs(e){const A=this.getLayerCtx(),t=i=>{if(i.vertices.length===0)return;const n=i.vertices[0],o=qi(this.transform,[n.x,n.y]);A.moveTo(o[0],o[1]);for(let s=0;s<i.vertices.length;s++){const r=i.vertices[s],a=i.vertices[(s+1)%i.vertices.length];if(r.bulge&&r.bulge!==0){const g=r.bulge,c=a.x-r.x,I=a.y-r.y,l=Math.sqrt(c*c+I*I);if(l<1e-9){const M=qi(this.transform,[a.x,a.y]);A.lineTo(M[0],M[1]);continue}const B=4*Math.atan(g),C=Math.abs(l/(2*Math.sin(B/2))),Q=(r.x+a.x)/2,h=(r.y+a.y)/2,E=c/l,d=-(I/l),p=E,m=Math.sqrt(Math.max(0,C*C-(l/2)**2)),w=Q+m*d*Math.sign(g),D=h+m*p*Math.sign(g),S=Math.atan2(r.y-D,r.x-w);let k=Math.atan2(a.y-D,a.x-w);g>0&&k<S?k+=2*Math.PI:g<0&&k>S&&(k-=2*Math.PI);const x=qi(this.transform,[w,D]),N=_f(this.transform,C);A.arc(x[0],x[1],N,-S,-k,g>0)}else{const g=qi(this.transform,[a.x,a.y]);A.lineTo(g[0],g[1])}}A.closePath()};if(A.beginPath(),t(e.outer_ring),e.inner_rings)for(const i of e.inner_rings)t(i);A.fill("evenodd")}};function nWe(e){return e.type==="pcb_copper_pour"}function J9({canvas:e,elements:A,layers:t,realToCanvasMat:i}){const n=A.filter(nWe);if(n.length===0)return;const o=new KC(e);o.realToCanvasMat=i,o.drawElements(n,{layers:t})}var oWe={...Vd,silkscreen:{top:ln.board.f_fab,bottom:ln.board.b_fab}};function sWe(e){return e.type.includes("pcb_fabrication_note")}function vct({canvas:e,elements:A,layers:t,realToCanvasMat:i}){const n=new KC(e);n.configure({colorOverrides:oWe}),n.realToCanvasMat=i;const o=A.filter(sWe);n.drawElements(o,{layers:t})}function rWe(e){return e.type==="pcb_hole"}function aWe({canvas:e,elements:A,layers:t,realToCanvasMat:i,drawSoldermask:n}){const o=new KC(e);o.realToCanvasMat=i;const s=A.filter(rWe);o.drawElements(s,{layers:t,drawSoldermask:n})}function gWe(e){return e.type==="pcb_board"}function cWe({canvas:e,elements:A,layers:t,realToCanvasMat:i,drawSoldermask:n}){const o=new KC(e);o.realToCanvasMat=i;const s=A.filter(gWe);for(const r of s)o.drawElements([r],{layers:t,drawSoldermask:n})}function IWe(e){return e.type==="pcb_cutout"}function lWe({canvas:e,elements:A,layers:t,realToCanvasMat:i}){const n=new KC(e);n.realToCanvasMat=i;const o=A.filter(IWe);n.drawElements(o,{layers:t})}function BWe(e){return e.type==="pcb_keepout"}function CWe({canvas:e,elements:A,layers:t,realToCanvasMat:i}){const n=A.filter(BWe);if(n.length===0)return;const o=new KC(e);o.realToCanvasMat=i,o.drawElements(n,{layers:[]})}function QWe(e){return e.type.startsWith("pcb_note_")}function Lct({canvas:e,elements:A,layers:t,realToCanvasMat:i}){const n=new KC(e);n.realToCanvasMat=i;const o=A.filter(QWe);n.drawElements(o,{layers:t})}function hWe(e){return e.type==="pcb_panel"}function EWe({canvas:e,elements:A,layers:t,realToCanvasMat:i,drawSoldermask:n}){const o=new KC(e);o.realToCanvasMat=i;const s=A.filter(hWe);for(const r of s)o.drawElements([r],{layers:t,drawSoldermask:n})}var uWe={...Vd,copper:{...Vd.copper,top:Na(ln.board.pad_front).lighten(.5).toString(),bottom:Na(ln.board.pad_back).lighten(.5).toString(),inner1:Na(ln.board.copper.in1).lighten(.5).toString(),inner2:Na(ln.board.copper.in2).lighten(.5).toString(),inner3:Na(ln.board.copper.in3).lighten(.5).toString(),inner4:Na(ln.board.copper.in4).lighten(.5).toString(),inner5:Na(ln.board.copper.in5).lighten(.5).toString(),inner6:Na(ln.board.copper.in6).lighten(.5).toString()}};function dWe(e){return e.type==="pcb_smtpad"}function pWe({canvas:e,elements:A,layers:t,realToCanvasMat:i,primitives:n,drawSoldermask:o}){const s=A.filter(dWe).filter(c=>{const I=c.layer;return t.some(l=>l==="top_copper"&&I==="top"||l==="bottom_copper"&&I==="bottom"||l==="inner1_copper"&&I==="inner1"||l==="inner2_copper"&&I==="inner2"||l==="inner3_copper"&&I==="inner3"||l==="inner4_copper"&&I==="inner4"||l==="inner5_copper"&&I==="inner5"||l==="inner6_copper"&&I==="inner6")});if(s.length===0)return;const r=new Set;if(n)for(const c of n)(c.is_mouse_over||c.is_in_highlighted_net)&&c._element?.type==="pcb_smtpad"&&r.add(c._element.pcb_smtpad_id);const a=s.filter(c=>r.has(c.pcb_smtpad_id)),g=s.filter(c=>!r.has(c.pcb_smtpad_id));if(g.length>0){const c=new KC(e);c.realToCanvasMat=i,c.drawElements(g,{layers:t,drawSoldermask:o})}if(a.length>0){const c=new KC(e);c.configure({colorOverrides:uWe}),c.realToCanvasMat=i,c.drawElements(a,{layers:t,drawSoldermask:o})}}var fWe={...Vd,copper:{...Vd.copper,top:Na(ln.board.pad_front).lighten(.5).toString(),bottom:Na(ln.board.pad_back).lighten(.5).toString(),inner1:Na(ln.board.copper.in1).lighten(.5).toString(),inner2:Na(ln.board.copper.in2).lighten(.5).toString(),inner3:Na(ln.board.copper.in3).lighten(.5).toString(),inner4:Na(ln.board.copper.in4).lighten(.5).toString(),inner5:Na(ln.board.copper.in5).lighten(.5).toString(),inner6:Na(ln.board.copper.in6).lighten(.5).toString()}};function yWe(e){return e.type==="pcb_trace"}var mWe=e=>e.map(A=>A.endsWith("_copper")?A.replace("_copper",""):A);function wWe({canvas:e,elements:A,layers:t,realToCanvasMat:i,primitives:n}){const o=new Set(mWe(t)),s=A.filter(yWe).filter(c=>c.route.some(I=>I.route_type==="wire"&&"layer"in I&&o.has(I.layer)));if(s.length===0)return;const r=new Set;if(n)for(const c of n)(c.is_mouse_over||c.is_in_highlighted_net)&&c._element?.type==="pcb_trace"&&r.add(c._element.pcb_trace_id);const a=s.filter(c=>r.has(c.pcb_trace_id)),g=s.filter(c=>!r.has(c.pcb_trace_id));if(g.length>0){const c=new KC(e);c.realToCanvasMat=i,c.drawElements(g,{layers:t})}if(a.length>0){const c=new KC(e);c.configure({colorOverrides:fWe}),c.realToCanvasMat=i,c.drawElements(a,{layers:t})}}var DWe={...Vd,copper:{...Vd.copper,top:Na(ln.board.pad_front).lighten(.5).toString(),bottom:Na(ln.board.pad_back).lighten(.5).toString()}};function SWe(e){return e.type==="pcb_plated_hole"}function Uct({canvas:e,elements:A,layers:t,realToCanvasMat:i,primitives:n,drawSoldermask:o}){const s=A.filter(SWe);if(s.length===0)return;const r=new Set;if(n)for(const c of n)(c.is_mouse_over||c.is_in_highlighted_net)&&c._element?.type==="pcb_plated_hole"&&r.add(c._element.pcb_plated_hole_id);const a=s.filter(c=>r.has(c.pcb_plated_hole_id)),g=s.filter(c=>!r.has(c.pcb_plated_hole_id));if(g.length>0){const c=new KC(e);c.realToCanvasMat=i,c.drawElements(g,{layers:t,drawSoldermask:o})}if(a.length>0){const c=new KC(e);c.configure({colorOverrides:DWe}),c.realToCanvasMat=i,c.drawElements(a,{layers:t,drawSoldermask:o})}}function Hct(e){const{lines:A,anchorPoint:t,ccwRotation:i}=e;if(!i)return A;const n=i*Math.PI/180,o=b3e(n),s=im(lB(t.x,t.y),o,lB(-t.x,-t.y));return qi(s,t),A.map(r=>({...r,x1:qi(s,{x:r.x1,y:r.y1}).x,y1:qi(s,{x:r.x1,y:r.y1}).y,x2:qi(s,{x:r.x2,y:r.y2}).x,y2:qi(s,{x:r.x2,y:r.y2}).y}))}var bWe=.6,Yct=.2,Jct=e=>{const A=e.size*.7,t=A*bWe,i=A*Yct,n=A*Yct,o=e.text.split(/\r?\n/),s=e.text.length>0&&A>0,r=s?o.length:0,a=s?o.map(I=>I.length===0?0:I.length*t+(I.length-1)*i):[],g=a.length>0?Math.max(...a):0,c=r>0?r*A+(r-1)*n:0;return{text_lines:o,line_count:r,line_widths:a,target_height:A,target_width_char:t,space_between_chars:i,space_between_lines:n,width:g,height:c}},Tct=e=>{const A=Jct(e);return{width:A.width,height:A.height,lineHeight:A.target_height,lineSpacing:A.space_between_lines,lineCount:A.line_count}},Kct=e=>{const{text_lines:A,line_count:t,line_widths:i,target_height:n,target_width_char:o,space_between_chars:s,space_between_lines:r,width:a}=Jct(e);if(n<=0||t===0)return[];const g=n/12,c=[];for(let I=0;I<t;I++){const l=-I*(n+r),B=i[I],C=(a-B)/2;let Q=e.x+C;for(let h=0;h<A[I].length;h++){const E=A[I][h],u=uD[E]??uD[E.toUpperCase()];if(!u){Q+=o+s;continue}for(const{x1:d,y1:p,x2:m,y2:w}of u)c.push({_pcb_drawing_object_id:nm("line"),pcb_drawing_type:"line",x1:Q+o*d,y1:e.y+l+n*p,x2:Q+o*m,y2:e.y+l+n*w,width:g,layer:e.layer,unit:e.unit,color:e.color});Q+=o+s}}return c};function OD(e){const t=e.color??Y9[e.layer];let i=Na(t);return e._element?.type==="pcb_copper_pour"&&(i=i.alpha(.7)),e.is_mouse_over||e.is_in_highlighted_net?i.lighten(.5).rgb().toString():i.rgb().toString()}var Pct=(e,A)=>{e.equip({size:A.zoomIndependent?A.width/e.transform.a:A.width,shape:A.squareCap?"square":"circle",color:OD(A),layer:A.layer}),e.moveTo(A.x1,A.y1),e.lineTo(A.x2,A.y2)},xWe=(e,A,t)=>{switch(t){case"top_left":return{x:0,y:-A};case"top_center":return{x:-e/2,y:-A};case"top_right":return{x:-e,y:-A};case"center_left":return{x:0,y:-A/2};case"center":return{x:-e/2,y:-A/2};case"center_right":return{x:-e,y:-A/2};case"bottom_left":return{x:0,y:0};case"bottom_center":return{x:-e/2,y:0};case"bottom_right":return{x:-e,y:0};default:return{x:0,y:0}}},qct=e=>e.layer==="bottom_silkscreen"||e.layer==="bottom"?e.is_mirrored!==!1:e.is_mirrored===!0,_We=(e,A)=>{e.equip({fontSize:A.size,color:OD(A),layer:A.layer});const{width:t,height:i}=Tct(A),n=xWe(t,i,A.align);A.x??=0,A.y??=0;const o={x:A.x,y:A.y};let s=Kct({...A,x:A.x+n.x,y:A.y+n.y});if(qct(A)&&(s=s.map(r=>({...r,x1:2*A.x-r.x1,x2:2*A.x-r.x2}))),A.ccw_rotation){const r={lines:s,anchorPoint:o,ccwRotation:A.ccw_rotation};s=Hct(r)}for(const r of s)Pct(e,r)},kWe=(e,A)=>{const{width:t,height:i,lineHeight:n}=Tct(A);A.x??=0,A.y??=0;const o=A.knockout_padding??{left:A.size*.5,right:A.size*.5,top:A.size*.3,bottom:A.size*.3},s=t+o.left+o.right,r=i+o.top+o.bottom,a=t/2,g=n-i/2,c=A.x-a,I=A.y-g,l={x:A.x,y:A.y},B={_pcb_drawing_object_id:`knockout_rect_${A._pcb_drawing_object_id}`,x:A.x,y:A.y,w:s,h:r,layer:A.layer,ccw_rotation:A.ccw_rotation};A.ccw_rotation?Wct(e,B):Oct(e,B);let C=Kct({...A,x:c,y:I});if(qct(A)&&(C=C.map(Q=>({...Q,x1:2*A.x-Q.x1,x2:2*A.x-Q.x2}))),A.ccw_rotation){const Q={lines:C,anchorPoint:l,ccwRotation:A.ccw_rotation};C=Hct(Q)}for(const Q of C)e.equip({size:Q.width,shape:"circle",color:"black",layer:A.layer,mode:"subtract"}),e.moveTo(Q.x1,Q.y1),e.lineTo(Q.x2,Q.y2);e.equip({mode:"add"})},Oct=(e,A)=>{e.equip({color:OD(A),layer:A.layer,size:A.stroke_width}),e.rect({x:A.x,y:A.y,w:A.w,h:A.h,mesh_fill:A.mesh_fill,is_filled:A.is_filled,has_stroke:A.has_stroke,is_stroke_dashed:A.is_stroke_dashed,stroke_width:A.stroke_width,roundness:A.roundness})},Wct=(e,A)=>{e.equip({color:OD(A),layer:A.layer}),e.rotatedRect(A.x,A.y,A.w,A.h,A.ccw_rotation,A.roundness,A.mesh_fill)},FWe=(e,A)=>{e.equip({color:OD(A),layer:A.layer}),e.rotatedPill(A.x,A.y,A.w,A.h,A.ccw_rotation)},GWe=(e,A)=>{e.equip({color:OD(A),layer:A.layer}),e.circle(A.x,A.y,A.r,A.mesh_fill)},RWe=(e,A)=>{e.equip({color:OD(A),layer:A.layer}),e.oval(A.x,A.y,A.rX,A.rY)},MWe=(e,A)=>{e.equip({color:OD(A),layer:A.layer}),e.pill(A.x,A.y,A.w,A.h)},NWe=(e,A)=>{e.equip({color:OD(A),layer:A.layer}),e.polygon(A.points)},vWe=(e,A)=>{e.equip({color:OD(A),layer:A.layer}),e.polygonWithArcs(A.brep_shape)},LWe=(e,A)=>{switch(A.pcb_drawing_type){case"line":return Pct(e,A);case"text":return A.is_knockout?kWe(e,A):_We(e,A);case"rect":return A.ccw_rotation?Wct(e,A):Oct(e,A);case"circle":return GWe(e,A);case"oval":return RWe(e,A);case"pill":return A.ccw_rotation?FWe(e,A):MWe(e,A);case"polygon":return NWe(e,A);case"polygon_with_arcs":return vWe(e,A)}},UWe=(e,A)=>{for(const t of A)LWe(e,t)},HWe={...Vd,copper:{...Vd.copper,top:Na(ln.board.pad_front).lighten(.5).toString(),bottom:Na(ln.board.pad_back).lighten(.5).toString(),inner1:Na(ln.board.copper.in1).lighten(.5).toString(),inner2:Na(ln.board.copper.in2).lighten(.5).toString(),inner3:Na(ln.board.copper.in3).lighten(.5).toString(),inner4:Na(ln.board.copper.in4).lighten(.5).toString(),inner5:Na(ln.board.copper.in5).lighten(.5).toString(),inner6:Na(ln.board.copper.in6).lighten(.5).toString()},soldermask:{...Vd.soldermask,top:Na(ln.board.soldermask.top).lighten(.35).toString(),bottom:Na(ln.board.soldermask.bottom).lighten(.35).toString()}};function T9({canvas:e,elements:A,layers:t,realToCanvasMat:i,primitives:n}){const o=new KC(e);if(o.realToCanvasMat=i,o.drawElements(A,{layers:t,drawSoldermask:!0}),!n)return;const s=new Set;for(const g of n){if(!(g.is_mouse_over||g.is_in_highlighted_net))continue;const c=g._element;c?.type==="pcb_smtpad"?s.add(c.pcb_smtpad_id):c?.type==="pcb_plated_hole"?s.add(c.pcb_plated_hole_id):c?.type==="pcb_via"&&s.add(c.pcb_via_id)}if(s.size===0)return;const r=A.filter(g=>g.type==="pcb_smtpad"?s.has(g.pcb_smtpad_id):g.type==="pcb_plated_hole"?s.has(g.pcb_plated_hole_id):g.type==="pcb_via"?s.has(g.pcb_via_id):!1);if(r.length===0)return;const a=new KC(e);a.configure({colorOverrides:HWe}),a.realToCanvasMat=i,a.drawElements(r,{layers:t,drawSoldermask:!0})}var YWe={...Vd,silkscreen:{top:ln.board.f_silks,bottom:ln.board.b_silks}};function JWe(e){return e.type.includes("pcb_silkscreen")}function Zct({canvas:e,elements:A,layers:t,realToCanvasMat:i}){const n=new KC(e);n.configure({colorOverrides:YWe}),n.realToCanvasMat=i;const o=A.filter(JWe);n.drawElements(o,{layers:t})}var TWe={...Vd,copper:{...Vd.copper,top:Na(ln.board.pad_front).lighten(.5).toString(),bottom:Na(ln.board.pad_back).lighten(.5).toString()}};function KWe(e){return e.type==="pcb_via"}function Vct({canvas:e,elements:A,layers:t,realToCanvasMat:i,primitives:n,drawSoldermask:o}){const s=A.filter(KWe).filter(c=>t.some(I=>I.includes("copper")));if(s.length===0)return;const r=new Set;if(n)for(const c of n)(c.is_mouse_over||c.is_in_highlighted_net)&&c._element?.type==="pcb_via"&&r.add(c._element.pcb_via_id);const a=s.filter(c=>r.has(c.pcb_via_id)),g=s.filter(c=>!r.has(c.pcb_via_id));if(g.length>0){const c=new KC(e);c.realToCanvasMat=i,c.drawElements(g,{layers:t,drawSoldermask:o})}if(a.length>0){const c=new KC(e);c.configure({colorOverrides:TWe}),c.realToCanvasMat=i,c.drawElements(a,{layers:t,drawSoldermask:o})}}var PWe={...Vd,courtyard:{top:ln.board.f_crtyd,bottom:ln.board.b_crtyd}};function qWe(e){return e.type==="pcb_courtyard_circle"||e.type==="pcb_courtyard_rect"}function jct({canvas:e,elements:A,layers:t,realToCanvasMat:i}){const n=new KC(e);n.configure({colorOverrides:PWe}),n.realToCanvasMat=i;const o=A.filter(qWe);n.drawElements(o,{layers:t})}var OWe=["board","bottom","soldermask_bottom","bottom_silkscreen","top","soldermask_top","soldermask_with_copper_bottom","soldermask_with_copper_top","top_fabrication","bottom_fabrication","inner1","inner2","inner3","inner4","inner5","inner6","drill","edge_cuts","bottom_notes","top_notes","top_silkscreen","bottom_silkscreen","top_courtyard","bottom_courtyard","other"],WWe=({primitives:e,elements:A,transform:t,grid:i,width:n=500,height:o=500})=>{const s=V.useRef({}),r=eC(g=>g.selected_layer),a=eC(g=>g.is_showing_solder_mask);return V.useEffect(()=>{if(!s.current||Object.keys(s.current).length===0)return;const g=Object.fromEntries(Object.entries(s.current).filter(([l,B])=>!(!B||!a&&l.includes("soldermask"))));if(Object.keys(g).length===0)return;const c=new iWe(g);t&&(c.transform=t),c.clear(),c.foregroundLayer=r;const I=e.filter(l=>a||!l.layer?.includes("soldermask")).filter(l=>l.layer!=="board").filter(l=>l._element?.type!=="pcb_smtpad").filter(l=>l._element?.type!=="pcb_plated_hole").filter(l=>l._element?.type!=="pcb_via").filter(l=>l._element?.type!=="pcb_trace");if(UWe(c,I),t){const l=s.current.top,B=s.current.bottom,C=s.current.inner1,Q=s.current.inner2,h=s.current.inner3,E=s.current.inner4,u=s.current.inner5,d=s.current.inner6,p=[{canvas:l,copperLayer:"top_copper"},{canvas:B,copperLayer:"bottom_copper"},{canvas:C,copperLayer:"inner1_copper"},{canvas:Q,copperLayer:"inner2_copper"},{canvas:h,copperLayer:"inner3_copper"},{canvas:E,copperLayer:"inner4_copper"},{canvas:u,copperLayer:"inner5_copper"},{canvas:d,copperLayer:"inner6_copper"}];for(const{canvas:Z,copperLayer:$}of p)Z&&wWe({canvas:Z,elements:A,layers:[$],realToCanvasMat:t,primitives:e});l&&Uct({canvas:l,elements:A,layers:["top_copper"],realToCanvasMat:t,primitives:e,drawSoldermask:a}),B&&Uct({canvas:B,elements:A,layers:["bottom_copper"],realToCanvasMat:t,primitives:e,drawSoldermask:a}),l&&J9({canvas:l,elements:A,layers:["top_copper"],realToCanvasMat:t}),B&&J9({canvas:B,elements:A,layers:["bottom_copper"],realToCanvasMat:t});for(const{canvas:Z,copperLayer:$}of p)Z&&(pWe({canvas:Z,elements:A,layers:[$],realToCanvasMat:t,primitives:e,drawSoldermask:a}),a&&T9({canvas:Z,elements:A,layers:[$],realToCanvasMat:t,primitives:e}));if(l&&Vct({canvas:l,elements:A,layers:["top_copper"],realToCanvasMat:t,primitives:e,drawSoldermask:a}),B&&Vct({canvas:B,elements:A,layers:["bottom_copper"],realToCanvasMat:t,primitives:e,drawSoldermask:a}),a){const Z=s.current.soldermask_top;Z&&T9({canvas:Z,elements:A,layers:["top_soldermask"],realToCanvasMat:t,primitives:e});const $=s.current.soldermask_bottom;$&&T9({canvas:$,elements:A,layers:["bottom_soldermask"],realToCanvasMat:t,primitives:e})}l&&J9({canvas:l,elements:A,layers:["top_copper"],realToCanvasMat:t}),B&&J9({canvas:B,elements:A,layers:["bottom_copper"],realToCanvasMat:t});const m=s.current.drill;m&&(aWe({canvas:m,elements:A,layers:["drill"],realToCanvasMat:t}),a&&T9({canvas:m,elements:A,layers:["drill"],realToCanvasMat:t,primitives:e}));const w=s.current.top_silkscreen;w&&Zct({canvas:w,elements:A,layers:["top_silkscreen"],realToCanvasMat:t});const D=s.current.bottom_silkscreen;D&&Zct({canvas:D,elements:A,layers:["bottom_silkscreen"],realToCanvasMat:t});const S=s.current.top_fabrication;S&&vct({canvas:S,elements:A,layers:["top_fabrication_note"],realToCanvasMat:t});const k=s.current.bottom_fabrication;k&&vct({canvas:k,elements:A,layers:["bottom_fabrication_note"],realToCanvasMat:t});const x=s.current.bottom_notes;x&&Lct({canvas:x,elements:A,layers:["bottom_user_note"],realToCanvasMat:t});const N=s.current.top_notes;N&&Lct({canvas:N,elements:A,layers:["top_user_note"],realToCanvasMat:t});const M=s.current.top_courtyard;M&&jct({canvas:M,elements:A,layers:["top_courtyard"],realToCanvasMat:t});const L=s.current.bottom_courtyard;L&&jct({canvas:L,elements:A,layers:["bottom_courtyard"],realToCanvasMat:t});const Y=s.current.board;Y&&(EWe({canvas:Y,elements:A,layers:[],realToCanvasMat:t,drawSoldermask:a}),cWe({canvas:Y,elements:A,layers:[],realToCanvasMat:t,drawSoldermask:a}));const H=s.current.edge_cuts;H&&lWe({canvas:H,elements:A,layers:["edge_cuts"],realToCanvasMat:t});const O=[{canvas:l,layer:"top"},{canvas:B,layer:"bottom"}];for(const{canvas:Z,layer:$}of O)Z&&CWe({canvas:Z,elements:A,layers:[$],realToCanvasMat:t})}c.orderAndFadeLayers()},[e,A,t,r,a]),W.jsxs("div",{style:{backgroundColor:"black",width:n,height:o,position:"relative"},children:[W.jsx(w9.SuperGrid,{textColor:"rgba(0,255,0,0.8)",majorColor:"rgba(0,255,0,0.4)",minorColor:"rgba(0,255,0,0.2)",screenSpaceCellSize:200,width:n,height:o,transform:t,stringifyCoord:(g,c,I)=>`${w9.toMMSI(g,I)}, ${w9.toMMSI(c,I)}`}),OWe.filter(g=>a?!0:!g.includes("soldermask")).map(g=>g.replace(/-/g,"")).map((g,c)=>W.jsx("canvas",{className:`pcb-layer-${g}`,ref:I=>{s.current??={},I?s.current[g]=I:delete s.current[g]},style:{position:"absolute",zIndex:c,left:0,top:0,pointerEvents:"none"},width:n,height:o},g))]})},ZWe=.6,VWe=1;dct(g8e()),dct(D8e());var K9=["rgba(239, 68, 68, 0.8)","rgba(249, 115, 22, 0.8)","rgba(245, 158, 11, 0.8)","rgba(234, 179, 8, 0.8)","rgba(132, 204, 22, 0.8)","rgba(34, 197, 94, 0.8)","rgba(16, 185, 129, 0.8)","rgba(20, 184, 166, 0.8)","rgba(6, 182, 212, 0.8)","rgba(14, 165, 233, 0.8)","rgba(59, 130, 246, 0.8)","rgba(99, 102, 241, 0.8)","rgba(139, 92, 246, 0.8)","rgba(168, 85, 247, 0.8)","rgba(217, 70, 239, 0.8)","rgba(236, 72, 153, 0.8)","rgba(249, 168, 212, 0.8)","rgba(161, 161, 170, 0.8)"];function zct(e,A,t,i={}){const n=i.padding??40,o=i.yFlip??!1;let s;if("center"in e){const c=e.width/2,I=e.height/2;s={minX:e.center.x-c,maxX:e.center.x+c,minY:e.center.y-I,maxY:e.center.y+I}}else s=e;const r=s.maxX-s.minX||1,a=s.maxY-s.minY||1,g=Math.min((A-2*n)/r,(t-2*n)/a);return im(lB(A/2,t/2),gJ(g,o?-g:g),lB(-(s.minX+r/2),-(s.minY+a/2)))}function jWe(e){const A=[...e.points||[],...(e.lines||[]).flatMap(t=>t.points),...(e.rects||[]).flatMap(t=>{const i=t.width/2,n=t.height/2;return[{x:t.center.x-i,y:t.center.y-n},{x:t.center.x+i,y:t.center.y-n},{x:t.center.x-i,y:t.center.y+n},{x:t.center.x+i,y:t.center.y+n}]}),...(e.circles||[]).flatMap(t=>[{x:t.center.x-t.radius,y:t.center.y},{x:t.center.x+t.radius,y:t.center.y},{x:t.center.x,y:t.center.y-t.radius},{x:t.center.x,y:t.center.y+t.radius}]),...(e.texts||[]).flatMap(t=>{const i=t.fontSize??12,n=t.text.length*i*ZWe,o=i*VWe,s=t.anchorSide??"center",r={top_left:{dx:0,dy:0},top_center:{dx:-n/2,dy:0},top_right:{dx:-n,dy:0},center_left:{dx:0,dy:-o/2},center:{dx:-n/2,dy:-o/2},center_right:{dx:-n,dy:-o/2},bottom_left:{dx:0,dy:-o},bottom_center:{dx:-n/2,dy:-o},bottom_right:{dx:-n,dy:-o}},{dx:a,dy:g}=r[s],c=t.x+a,I=t.y+g;return[{x:c,y:I},{x:c+n,y:I+o}]})];return A.length===0?{minX:-1,maxX:1,minY:-1,maxY:1}:A.reduce((t,i)=>({minX:Math.min(t.minX,i.x),maxX:Math.max(t.maxX,i.x),minY:Math.min(t.minY,i.y),maxY:Math.max(t.maxY,i.y)}),{minX:1/0,maxX:-1/0,minY:1/0,maxY:-1/0})}function zWe(e,A,t={}){const i=A instanceof HTMLCanvasElement?A.getContext("2d"):A;if(!i)throw new Error("Could not get 2D context from canvas");const n=A instanceof HTMLCanvasElement?A.width:A.canvas.width,o=A instanceof HTMLCanvasElement?A.height:A.canvas.height;let s;if(t.transform)s=t.transform;else if(t.viewbox)s=zct(t.viewbox,n,o,{padding:t.padding,yFlip:t.yFlip});else{const r=jWe(e),a=e.coordinateSystem==="cartesian";s=zct(r,n,o,{padding:t.padding??40,yFlip:a})}i.clearRect(0,0,n,o),i.save(),e.rects&&e.rects.length>0&&e.rects.forEach(r=>{const a=r.width/2,g=r.height/2,c=qi(s,{x:r.center.x-a,y:r.center.y-g}),I=qi(s,{x:r.center.x+a,y:r.center.y+g}),l=Math.abs(I.x-c.x),B=Math.abs(I.y-c.y);i.beginPath(),i.rect(Math.min(c.x,I.x),Math.min(c.y,I.y),l,B),r.fill&&(i.fillStyle=r.fill,i.fill()),r.stroke&&(i.strokeStyle=r.stroke,i.stroke())}),e.circles&&e.circles.length>0&&e.circles.forEach(r=>{const a=qi(s,r.center),g=r.radius*Math.abs(s.a);i.beginPath(),i.arc(a.x,a.y,g,0,2*Math.PI),r.fill&&(i.fillStyle=r.fill,i.fill()),r.stroke&&(i.strokeStyle=r.stroke??"transparent",i.stroke())}),e.lines&&e.lines.length>0&&e.lines.forEach((r,a)=>{if(r.points.length===0)return;i.beginPath();const g=qi(s,r.points[0]);i.moveTo(g.x,g.y);for(let c=1;c<r.points.length;c++){const I=qi(s,r.points[c]);i.lineTo(I.x,I.y)}if(i.strokeStyle=r.strokeColor||K9[a%K9.length],r.strokeWidth?i.lineWidth=r.strokeWidth*s.a:i.lineWidth=2,i.lineCap="round",r.strokeDash)if(typeof r.strokeDash=="string"){let c;if(r.strokeDash.includes(","))c=r.strokeDash.split(",").map(I=>parseFloat(I.trim())).filter(I=>!Number.isNaN(I));else{const I=parseFloat(r.strokeDash.trim());c=Number.isNaN(I)?[]:[I]}i.setLineDash(c)}else i.setLineDash(r.strokeDash.map(c=>c*Math.abs(s.a)));else i.setLineDash([]);i.stroke()}),e.points&&e.points.length>0&&e.points.forEach((r,a)=>{const g=qi(s,r);i.beginPath(),i.arc(g.x,g.y,3,0,2*Math.PI),i.fillStyle=r.color||K9[a%K9.length],i.fill(),r.label&&!t.disableLabels&&(i.fillStyle=r.color||"black",i.font="12px sans-serif",i.fillText(r.label,g.x+5,g.y-5))}),e.texts&&e.texts.length>0&&e.texts.forEach(r=>{const a=qi(s,{x:r.x,y:r.y});i.fillStyle=r.color||"black",i.font=`${(r.fontSize??12)*Math.abs(s.a)}px sans-serif`;const g=r.anchorSide??"center",c={top_left:"left",center_left:"left",bottom_left:"left",top_center:"center",center:"center",bottom_center:"center",top_right:"right",center_right:"right",bottom_right:"right"},I={top_left:"top",top_center:"top",top_right:"top",center_left:"middle",center:"middle",center_right:"middle",bottom_left:"bottom",bottom_center:"bottom",bottom_right:"bottom"};i.textAlign=c[g],i.textBaseline=I[g],i.fillText(r.text,a.x,a.y)}),i.restore()}var XWe=({children:e,transform:A,debugGraphics:t})=>{const i=V.useRef(null),[n,{width:o,height:s}]=yJ(),r=eC(a=>a.is_showing_autorouting);return V.useEffect(()=>{r&&i.current&&t&&o&&s&&(i.current.width=o,i.current.height=s,zWe(t,i.current,{transform:A,disableLabels:!0}))},[t,A,o,s,r]),r?W.jsxs("div",{ref:n,style:{position:"relative",width:"100%",height:"100%"},children:[e,W.jsx("canvas",{ref:i,style:{position:"absolute",top:0,left:0,opacity:.5,zIndex:100,width:"100%",height:"100%",pointerEvents:"none"}})]}):e},$We=({children:e,transform:A=_b(),elements:t=[]})=>{const[i,{width:n,height:o}]=yJ(),s=V.useRef(null);return V.useEffect(()=>{const r=s.current;if(!r||!n||!o)return;r.width=n,r.height=o;const a=r.getContext("2d");if(!a)return;a.clearRect(0,0,n,o);const g=t.filter(I=>I.type==="pcb_component"),c=t.filter(I=>I.type==="pcb_manual_edit_conflict_warning");a.strokeStyle=ln.board.drc_warning,a.lineWidth=2,c.forEach(I=>{const l=g.find(O=>O.pcb_component_id===I.pcb_component_id);if(!l)return;const{width:B,height:C,center:Q}=l,h=qi(A,Q),E=B*Math.abs(A.a),u=C*Math.abs(A.d),d=.1*Math.abs(A.a),p=E+d*2,m=u+d*2,w=h.x-p/2,D=h.y-m/2;a.beginPath(),a.rect(w,D,p,m),a.stroke();const S="Manual Edit Conflict",k=4,x=Math.max(8,Math.min(12,10*Math.abs(A.a)));a.font=`${x}px sans-serif`;const M=a.measureText(S).width+k*2,L=x+k*2,Y=w+(p-M)/2,H=D+m+5;a.fillStyle="rgba(0, 0, 0, 0.7)",a.beginPath(),a.roundRect(Y,H,M,L,3),a.fill(),a.fillStyle=ln.board.drc_warning,a.textAlign="center",a.textBaseline="middle",a.fillText(S,Y+M/2,H+L/2)})},[t,A,n,o]),W.jsxs("div",{ref:i,style:{position:"relative",width:"100%",height:"100%"},children:[e,W.jsx("canvas",{ref:s,style:{position:"absolute",top:0,left:0,pointerEvents:"none",zIndex:fc.warnings}})]})},P9=(e,A,t)=>t(e,A),Xct=(e,A,t,i,n)=>{const o=n*Math.PI/180,s=Math.cos(o),r=Math.sin(o),a=e-t,g=A-i,c=a*s-g*r,I=a*r+g*s;return{x:c+t,y:I+i}},mJ=e=>{if(e.length===0)return null;let A=e[0].x,t=e[0].x,i=e[0].y,n=e[0].y;for(const o of e)A=P9(A,o.x,Math.min),t=P9(t,o.x,Math.max),i=P9(i,o.y,Math.min),n=P9(n,o.y,Math.max);return{minX:A,maxX:t,minY:i,maxY:n}},AZe=(e,A)=>({minX:Math.min(e.minX,A.minX),maxX:Math.max(e.maxX,A.maxX),minY:Math.min(e.minY,A.minY),maxY:Math.max(e.maxY,A.maxY)}),tZe=(e,A)=>e?AZe(e,A):A,eZe=e=>{switch(e.pcb_drawing_type){case"line":{const A=(e.width??0)/2,t=[{x:e.x1,y:e.y1},{x:e.x2,y:e.y2}],i=mJ(t);return i?{minX:i.minX-A,maxX:i.maxX+A,minY:i.minY-A,maxY:i.maxY+A}:null}case"rect":{const A=e.w/2,t=e.h/2,i=[{x:e.x-A,y:e.y-t},{x:e.x+A,y:e.y-t},{x:e.x+A,y:e.y+t},{x:e.x-A,y:e.y+t}],n=e.ccw_rotation??0,o=n===0?i:i.map(s=>Xct(s.x,s.y,e.x,e.y,n));return mJ(o)}case"circle":return{minX:e.x-e.r,maxX:e.x+e.r,minY:e.y-e.r,maxY:e.y+e.r};case"oval":return{minX:e.x-e.rX,maxX:e.x+e.rX,minY:e.y-e.rY,maxY:e.y+e.rY};case"pill":{const A=e.w/2,t=e.h/2,i=[{x:e.x-A,y:e.y-t},{x:e.x+A,y:e.y-t},{x:e.x+A,y:e.y+t},{x:e.x-A,y:e.y+t}],n=e.ccw_rotation??0,o=n===0?i:i.map(s=>Xct(s.x,s.y,e.x,e.y,n));return mJ(o)}case"polygon":return mJ(e.points);case"polygon_with_arcs":{const A=e.brep_shape.outer_ring.vertices.map(t=>({x:t.x,y:t.y}));return mJ(A)}case"text":{const A=e.size??0,t=e.text?e.text.length*A*.6:0,i=A;if(t===0&&i===0)return{minX:e.x,maxX:e.x,minY:e.y,maxY:e.y};const n=t/2,o=i/2;return{minX:e.x-n,maxX:e.x+n,minY:e.y-o,maxY:e.y+o}}default:return null}};function iZe(e){const{dimensionStart:A,dimensionEnd:t,screenDimensionStart:i,screenDimensionEnd:n,flipX:o,flipY:s}=e,r=t.x-A.x,a=t.y-A.y,g=Math.sqrt(r*r+a*a),c=n.x-i.x,I=n.y-i.y,l=Math.sqrt(c*c+I*I),B=Math.atan2(I,c)*(180/Math.PI),C=Math.abs(B)%90,h=Math.min(C,90-C)>15,E=(i.x+n.x)/2,u=(i.y+n.y)/2,d=15,p=B+90;let m=Math.cos(p*Math.PI/180)*d,w=Math.sin(p*Math.PI/180)*d;const D=c>0&&I<0,S=c>0&&I>0,k=c<0&&I>0;o!==s&&!D&&(m=-m,w=-w),D&&(m+=Math.cos(p*Math.PI/180)*-45,w+=Math.sin(p*Math.PI/180)*-45),S&&(m+=Math.cos(p*Math.PI/180)+-20,w+=Math.sin(p*Math.PI/180)+-10),k&&(m+=Math.cos(p*Math.PI/180)*10,w+=Math.sin(p*Math.PI/180)*10);const x=E+m,N=u+w;return{distance:g,screenDistance:l,x,y:N,show:g>.01&&l>30&&h}}function nZe(e){const{dimensionStart:A,dimensionEnd:t,screenDimensionStart:i,screenDimensionEnd:n,flipX:o,flipY:s}=e;return V.useMemo(()=>iZe({dimensionStart:A,dimensionEnd:t,screenDimensionStart:i,screenDimensionEnd:n,flipX:o,flipY:s}),[A,t,i,n,o,s])}var oZe=(e,A,t)=>{const i=t*Math.PI/180,n=Math.cos(i),o=Math.sin(i),s=e.x-A.x,r=e.y-A.y,a=s*n-r*o,g=s*o+r*n;return{x:a+A.x,y:g+A.y}},$ct=(e,A,t,i)=>{const n={top_left:{x:e.x-A,y:e.y-t},top_center:{x:e.x,y:e.y-t},top_right:{x:e.x+A,y:e.y-t},center_left:{x:e.x-A,y:e.y},center:{x:e.x,y:e.y},center_right:{x:e.x+A,y:e.y},bottom_left:{x:e.x-A,y:e.y+t},bottom_center:{x:e.x,y:e.y+t},bottom_right:{x:e.x+A,y:e.y+t}};return i===0?Object.entries(n).map(([o,s])=>({anchor:o,point:s})):Object.entries(n).map(([o,s])=>({anchor:o,point:oZe(s,e,i)}))},sZe=e=>{switch(e.pcb_drawing_type){case"rect":{const A=e.ccw_rotation??0;return $ct({x:e.x,y:e.y},e.w/2,e.h/2,A)}case"pill":{const A=e.ccw_rotation??0;return $ct({x:e.x,y:e.y},e.w/2,e.h/2,A)}case"circle":return[{anchor:"circle_center",point:{x:e.x,y:e.y}},{anchor:"circle_right",point:{x:e.x+e.r,y:e.y}},{anchor:"circle_left",point:{x:e.x-e.r,y:e.y}},{anchor:"circle_top",point:{x:e.x,y:e.y-e.r}},{anchor:"circle_bottom",point:{x:e.x,y:e.y+e.r}}];case"oval":return[{anchor:"oval_center",point:{x:e.x,y:e.y}},{anchor:"oval_right",point:{x:e.x+e.rX,y:e.y}},{anchor:"oval_left",point:{x:e.x-e.rX,y:e.y}},{anchor:"oval_top",point:{x:e.x,y:e.y-e.rY}},{anchor:"oval_bottom",point:{x:e.x,y:e.y+e.rY}}];case"line":{const A={x:(e.x1+e.x2)/2,y:(e.y1+e.y2)/2};return[{anchor:"line_start",point:{x:e.x1,y:e.y1}},{anchor:"line_mid",point:A},{anchor:"line_end",point:{x:e.x2,y:e.y2}}]}case"polygon":return e.points.map((A,t)=>({anchor:`polygon_vertex_${t}`,point:A}));case"polygon_with_arcs":return e.brep_shape.outer_ring.vertices.map((A,t)=>({anchor:`polygon_with_arcs_vertex_${t}`,point:{x:A.x,y:A.y}}));default:return[]}},rZe=16,GG=5,AIt=e=>{if(e.pcb_drawing_type==="text")return!0;const A=e._element;if(!A||typeof A!="object")return!1;const t=typeof A.type=="string"?A.type:void 0;return t?!!(t.startsWith("pcb_silkscreen_")||t.startsWith("pcb_note_")||t==="pcb_text"||t.startsWith("pcb_fabrication_note_")&&t!=="pcb_fabrication_note_rect"):!1},aZe=({children:e,transform:A,focusOnHover:t=!1,primitives:i=[]})=>{A||(A=_b());const[n,o]=V.useState(!1),[s,r]=V.useState(!1),[a,g]=V.useState(!1),[c,I]=V.useState({start:null,end:null}),l=eC(H=>H.is_mouse_over_container),B=V.useCallback(()=>{a&&(g(!1),window.dispatchEvent(new Event("disarm-dimension-tool")))},[a]),[C,Q]=V.useState({x:0,y:0}),[h,E]=V.useState({x:0,y:0}),u=V.useRef({x:0,y:0}),d=V.useRef(null),m=d.current?.getBoundingClientRect(),w=V.useMemo(()=>{const H=new Map;for(const O of i){if(!O._element||AIt(O)||O.pcb_drawing_type==="pill"||O.pcb_drawing_type==="rect"&&O.ccw_rotation&&O.ccw_rotation!==0)continue;const Z=eZe(O);if(!Z)continue;const $=H.get(O._element);H.set(O._element,tZe($??void 0,Z))}return H},[i]),D=V.useMemo(()=>{const H=[];for(const O of i){if(!O._element||AIt(O))continue;const Z=sZe(O);if(Z.length!==0)for(const $ of Z)H.push({anchor:$.anchor,point:$.point,element:O._element})}return H},[i]),S=V.useMemo(()=>{const H=[];w.forEach((O,Z)=>{if(!O)return;const $=(O.minX+O.maxX)/2,eA=(O.minY+O.maxY)/2,aA={top_left:{x:O.minX,y:O.minY},top_center:{x:$,y:O.minY},top_right:{x:O.maxX,y:O.minY},center_left:{x:O.minX,y:eA},center:{x:$,y:eA},center_right:{x:O.maxX,y:eA},bottom_left:{x:O.minX,y:O.maxY},bottom_center:{x:$,y:O.maxY},bottom_right:{x:O.maxX,y:O.maxY}};for(const[tA,nA]of Object.entries(aA))H.push({anchor:tA,point:nA,element:Z})});for(const O of D)H.push(O);return H.push({anchor:"origin",point:{x:0,y:0},element:null}),H},[w,D]),k=V.useMemo(()=>S.map((H,O)=>({...H,id:`${O}-${H.anchor}`,screenPoint:qi(A,H.point)})),[S,A]),x=V.useCallback(H=>{if(k.length===0)return{point:H,id:null};const O=qi(A,H);let Z=null;for(const $ of k){const eA=$.screenPoint.x-O.x,aA=$.screenPoint.y-O.y,tA=Math.hypot(eA,aA);tA>rZe||(!Z||tA<Z.distance)&&(Z={distance:tA,id:$.id,point:$.point})}return Z?{point:Z.point,id:Z.id}:{point:H,id:null}},[k,A]);V.useEffect(()=>{const H=Z=>{const $=Z.target;if($.tagName==="INPUT"||$.tagName==="TEXTAREA"||$.isContentEditable)return;const eA=d.current?.contains(document.activeElement)||document.activeElement===d.current;if(!(!l&&!eA)){if(Z.key==="d"){const aA=x({x:u.current.x,y:u.current.y});Q({x:aA.point.x,y:aA.point.y}),E({x:aA.point.x,y:aA.point.y}),I({start:aA.id,end:aA.id}),n?(o(!1),r(!1),I({start:null,end:null})):(o(!0),r(!0)),B()}Z.key==="Escape"&&(o(!1),r(!1),I({start:null,end:null}),B())}},O=()=>{g(!0)};return window.addEventListener("keydown",H),window.addEventListener("arm-dimension-tool",O),()=>{window.removeEventListener("keydown",H),window.removeEventListener("arm-dimension-tool",O),B()}},[l,n,B,x]);const N=qi(A,C),M=qi(A,h),L={left:Math.min(N.x,M.x),right:Math.max(N.x,M.x),top:Math.min(N.y,M.y),bottom:Math.max(N.y,M.y),flipX:N.x>M.x,flipY:N.y>M.y,width:0,height:0};L.width=L.right-L.left,L.height=L.bottom-L.top;const Y=nZe({dimensionStart:C,dimensionEnd:h,screenDimensionStart:N,screenDimensionEnd:M,flipX:L.flipX,flipY:L.flipY});return W.jsxs("div",{ref:d,"data-pcb-viewer":!0,tabIndex:0,style:{position:"relative",outline:"none"},onMouseEnter:()=>{t&&d.current&&d.current.focus()},onMouseLeave:()=>{d.current&&d.current.blur()},onClick:()=>{d.current&&d.current.focus()},onMouseMove:H=>{const O=H.currentTarget.getBoundingClientRect(),Z=H.clientX-O.left,$=H.clientY-O.top,eA=qi(kb(A),{x:Z,y:$});if(u.current.x=eA.x,u.current.y=eA.y,s){const aA=x(eA);E({x:aA.point.x,y:aA.point.y}),I(tA=>({...tA,end:aA.id}))}},onMouseDown:H=>{const O=H.currentTarget.getBoundingClientRect(),Z=H.clientX-O.left,$=H.clientY-O.top,eA=qi(kb(A),{x:Z,y:$});if(a&&!n){const aA=x(eA);Q({x:aA.point.x,y:aA.point.y}),E({x:aA.point.x,y:aA.point.y}),I({start:aA.id,end:aA.id}),o(!0),r(!0),B()}else s?(r(!1),I(aA=>({...aA,end:null}))):n&&(o(!1),I({start:null,end:null}))},children:[e,n&&W.jsxs(W.Fragment,{children:[Y.show&&W.jsx("div",{style:{position:"absolute",left:Y.x,top:Y.y,color:"red",mixBlendMode:"difference",pointerEvents:"none",fontSize:12,fontFamily:"sans-serif",whiteSpace:"nowrap",zIndex:fc.dimensionOverlay},children:Y.distance.toFixed(2)}),W.jsx("div",{style:{position:"absolute",left:L.left,width:L.width,textAlign:"center",top:N.y+2,color:"red",mixBlendMode:"difference",pointerEvents:"none",marginTop:L.flipY?0:-20,fontSize:12,fontFamily:"sans-serif",zIndex:fc.dimensionOverlay},children:Math.abs(C.x-h.x).toFixed(2)}),W.jsx("div",{style:{position:"absolute",left:M.x,height:L.height,display:"flex",flexDirection:"column",justifyContent:"center",top:L.top,color:"red",pointerEvents:"none",mixBlendMode:"difference",fontSize:12,fontFamily:"sans-serif",zIndex:fc.dimensionOverlay},children:W.jsx("div",{style:{marginLeft:L.flipX?"-100%":4,paddingRight:4},children:Math.abs(C.y-h.y).toFixed(2)})}),W.jsxs("svg",{style:{position:"absolute",left:0,top:0,pointerEvents:"none",mixBlendMode:"difference",zIndex:fc.dimensionOverlay},width:m.width,height:m.height,children:[W.jsx("defs",{children:W.jsx("marker",{id:"head",orient:"auto",markerWidth:"3",markerHeight:"4",refX:"2",refY:"2",children:W.jsx("path",{d:"M0,0 V4 L2,2 Z",fill:"red"})})}),W.jsx("line",{x1:N.x,y1:N.y,x2:M.x,y2:M.y,markerEnd:"url(#head)",strokeWidth:1.5,fill:"none",stroke:"red"}),W.jsx("line",{x1:N.x,y1:N.y,x2:M.x,y2:N.y,strokeWidth:1.5,fill:"none",strokeDasharray:"2,2",stroke:"red"}),W.jsx("line",{x1:M.x,y1:N.y,x2:M.x,y2:M.y,strokeWidth:1.5,fill:"none",strokeDasharray:"2,2",stroke:"red"})]}),s&&k.map(H=>{const O=H.id===c.start||H.id===c.end,Z=GG/2;return W.jsxs("svg",{width:GG,height:GG,style:{position:"absolute",left:H.screenPoint.x-Z,top:H.screenPoint.y-Z,pointerEvents:"none",zIndex:fc.dimensionOverlay},children:[W.jsx("line",{x1:0,y1:0,x2:GG,y2:GG,stroke:O?"#66ccff":"white",strokeWidth:1}),W.jsx("line",{x1:GG,y1:0,x2:0,y2:GG,stroke:O?"#66ccff":"white",strokeWidth:1})]},H.id)}),W.jsxs("div",{style:{right:0,bottom:0,position:"absolute",color:"red",fontFamily:"sans-serif",fontSize:12,margin:4},children:["(",C.x.toFixed(2),",",C.y.toFixed(2),")",W.jsx("br",{}),"(",h.x.toFixed(2),",",h.y.toFixed(2),")",W.jsx("br",{}),"dist:"," ",Math.sqrt((h.x-C.x)**2+(h.y-C.y)**2).toFixed(2)]})]})]})},gZe=(e,A,t=0)=>{const i=e.width/2,n=e.height/2,o=e.center.x-i-t,s=e.center.x+i+t,r=e.center.y-n-t,a=e.center.y+n+t;return A.x>o&&A.x<s&&A.y>r&&A.y<a},cZe=({children:e,disabled:A,transform:t,soup:i,cancelPanDrag:n,onCreateEditEvent:o,onModifyEditEvent:s})=>{t||(t=_b());const r=V.useRef(null),[a,g]=V.useState(null),[c,I]=V.useState(null),l=a!==null;eC(h=>h.in_edit_mode);const B=eC(h=>h.in_move_footprint_mode),C=eC(h=>h.setIsMovingComponent),Q=A||!B;return W.jsxs("div",{ref:r,style:{position:"relative",overflow:"hidden"},onMouseDown:h=>{if(Q)return;const E=h.currentTarget.getBoundingClientRect(),u=h.clientX-E.left,d=h.clientY-E.top;if(Number.isNaN(u)||Number.isNaN(d))return;const p=qi(kb(t),{x:u,y:d});let m=!1;for(const w of i)if(w.type==="pcb_component"&&gZe(w,p,10/t.a)){n(),g(w.pcb_component_id),m=!0;const D=Math.random().toString();I({dragStart:p,originalCenter:w.center,dragEnd:p,edit_event_id:D}),o({edit_event_id:D,edit_event_type:"edit_pcb_component_location",pcb_edit_event_type:"edit_component_location",pcb_component_id:w.pcb_component_id,original_center:w.center,new_center:w.center,in_progress:!0,created_at:Date.now()}),C(!0);break}if(m||g(null),m)return h.preventDefault(),!1},onMouseMove:h=>{if(!a||!c)return;const E=h.currentTarget.getBoundingClientRect(),u=h.clientX-E.left,d=h.clientY-E.top;if(Number.isNaN(u)||Number.isNaN(d))return;const p=qi(kb(t),{x:u,y:d});I({...c,dragEnd:p}),s({edit_event_id:c.edit_event_id,new_center:{x:c.originalCenter.x+p.x-c.dragStart.x,y:c.originalCenter.y+p.y-c.dragStart.y}})},onMouseUp:h=>{a&&(g(null),C(!1),c&&(s({edit_event_id:c.edit_event_id,in_progress:!1}),I(null)))},children:[e,!Q&&i.filter(h=>h.type==="pcb_component").map(h=>{if(!h?.center)return null;const E=qi(t,h.center);return W.jsx("div",{style:{position:"absolute",pointerEvents:"none",left:E.x,top:E.y,width:h.width*t.a+20,height:h.height*t.a+20,transform:"translate(-50%, -50%)",background:l&&a===h.pcb_component_id?"rgba(255, 0, 0, 0.2)":""}},h.pcb_component_id)})]})},IZe=({hotkeys:e})=>(V.useEffect(()=>{const A=t=>{e.forEach(i=>{t.key===i.key&&i.onUse()})};return window.addEventListener("keydown",A),()=>{window.removeEventListener("keydown",A)}},[e]),W.jsx("div",{className:g1`
5433
+ $1`).replace(/>(\s*)(?=<!--\s*\/)/g,"> ")}}});function xct(e,A,t){if(!A||!t)return;let i=e.get(A);i||(i=new Set,e.set(A,i)),i.add(t);let n=e.get(t);n||(n=new Set,e.set(t,n)),n.add(A)}function S8e(e,A){if(!A.subcircuit_id&&!A.source_group_id)return[...e];const t=new Map;for(const s of e){const r=s[`${s.type}_id`];typeof r=="string"&&t.set(r,s)}const i=new Map;for(const s of e){const r=Object.entries(s);for(const[a,g]of r)if(a!=="parent_source_group_id"){if(a.endsWith("_id")&&typeof g=="string"){const c=t.get(g);xct(i,s,c)}else if(a.endsWith("_ids")&&Array.isArray(g)){for(const c of g)if(typeof c=="string"){const I=t.get(c);xct(i,s,I)}}}}const n=[],o=new Set;for(const s of e)(A.subcircuit_id&&s.subcircuit_id===A.subcircuit_id||A.source_group_id&&(s.source_group_id===A.source_group_id||Array.isArray(s.member_source_group_ids)&&s.member_source_group_ids.includes(A.source_group_id)))&&(n.push(s),o.add(s));for(;n.length>0;){const s=n.shift(),r=i.get(s);if(r)for(const a of r)o.has(a)||(o.add(a),n.push(a))}return e.filter(s=>o.has(s))}var L9=(e,A={})=>{const t=e;let i=t._internal_store;if(!i){i={counts:{},editCount:0},t._internal_store=i;for(const o of t){const s=o.type,r=o[`${s}_id`];if(!r)continue;const a=Number.parseInt(r.split("_").pop());Number.isNaN(a)||(i.counts[s]=Math.max(i.counts[s]??0,a))}}return new Proxy({},{get:(o,s)=>{if(s==="toArray")return()=>(t.editCount=i.editCount,t);if(s==="editCount")return i.editCount;if(s==="subtree")return a=>L9(S8e(t,a),A);const r=s;return{get:a=>t.find(g=>g.type===r&&g[`${r}_id`]===a),getUsing:a=>{const g=Object.keys(a);if(g.length!==1)throw new Error("getUsing requires exactly one key, e.g. { pcb_component_id }");const c=g[0],I=c.replace("_id",""),l=t.find(B=>B.type===I&&B[c]===a[c]);return l?t.find(B=>B.type===r&&B[`${r}_id`]===l[`${r}_id`]):null},getWhere:a=>{const g=Object.keys(a);return t.find(c=>c.type===r&&g.every(I=>c[I]===a[I]))},list:a=>{const g=a?Object.keys(a):[];return t.filter(c=>c.type===r&&g.every(I=>c[I]===a[I]))},insert:a=>{i.counts[r]??=-1,i.counts[r]++;const g=i.counts[r],c={type:r,[`${r}_id`]:`${r}_${g}`,...a};return A.validateInserts&&(_gt[r]??ifA).parse(c),t.push(c),i.editCount++,c},delete:a=>{const g=t.find(c=>c[`${r}_id`]===a);g&&(t.splice(t.indexOf(g),1),i.editCount++)},update:(a,g)=>{const c=t.find(I=>I.type===r&&I[`${r}_id`]===a);return c?(Object.assign(c,g),i.editCount++,c):null},select:a=>{if(r==="source_component")return t.find(g=>g.type==="source_component"&&g.name===a.replace(/\./g,""));if(r==="pcb_port"||r==="source_port"||r==="schematic_port"){const[g,c]=a.replace(/\./g,"").split(/[\s\>]+/),I=t.find(B=>B.type==="source_component"&&B.name===g);if(!I)return null;const l=t.find(B=>B.type==="source_port"&&B.source_component_id===I.source_component_id&&(B.name===c||(B.port_hints??[]).includes(c)));if(!l)return null;if(r==="source_port")return l;if(r==="pcb_port")return t.find(B=>B.type==="pcb_port"&&B.source_port_id===l.source_port_id);if(r==="schematic_port")return t.find(B=>B.type==="schematic_port"&&B.source_port_id===l.source_port_id)}}}}})};L9.unparsed=L9;var Gb=L9;function vfA(e){const A=e.type;return`${A}:${e[`${A}_id`]}`}var _ct=(e,A={})=>{let t=e._internal_store_indexed;if(!t){t={counts:{},editCount:0,indexes:{}};for(const s of e){const r=s.type,a=s[`${r}_id`];if(!a)continue;const g=Number.parseInt(a.split("_").pop()||"");Number.isNaN(g)||(t.counts[r]=Math.max(t.counts[r]??0,g))}const n=A.indexConfig||{},o=t.indexes;if(n.byId&&(o.byId=new Map),n.byType&&(o.byType=new Map),n.byRelation&&(o.byRelation=new Map),n.bySubcircuit&&(o.bySubcircuit=new Map),n.byCustomField&&n.byCustomField.length>0){o.byCustomField=new Map;for(const s of n.byCustomField)o.byCustomField.set(s,new Map)}for(const s of e){if(n.byId){const r=vfA(s);o.byId.set(r,s)}if(n.byType){const r=o.byType.get(s.type)||[];r.push(s),o.byType.set(s.type,r)}if(n.byRelation){const r=Object.entries(s);for(const[a,g]of r)if(a.endsWith("_id")&&a!==`${s.type}_id`&&typeof g=="string"){const c=o.byRelation.get(a)||new Map,I=c.get(g)||[];I.push(s),c.set(g,I),o.byRelation.set(a,c)}}if(n.bySubcircuit&&"subcircuit_id"in s){const r=s.subcircuit_id;if(r&&typeof r=="string"){const a=o.bySubcircuit.get(r)||[];a.push(s),o.bySubcircuit.set(r,a)}}if(n.byCustomField&&o.byCustomField){for(const r of n.byCustomField)if(r in s){const a=s[r];if(a!==void 0&&(typeof a=="string"||typeof a=="number")){const g=String(a),c=o.byCustomField.get(r),I=c.get(g)||[];I.push(s),c.set(g,I)}}}}e._internal_store_indexed=t}return new Proxy({},{get:(n,o)=>{if(o==="toArray")return()=>(e.editCount=t.editCount,e);if(o==="editCount")return t.editCount;const s=o;return{get:r=>{const a=A.indexConfig||{};return a.byId&&t.indexes.byId?t.indexes.byId.get(`${s}:${r}`)||null:a.byType&&t.indexes.byType?(t.indexes.byType.get(s)||[]).find(c=>c[`${s}_id`]===r)||null:e.find(g=>g.type===s&&g[`${s}_id`]===r)||null},getUsing:r=>{const a=A.indexConfig||{},g=Object.keys(r);if(g.length!==1)throw new Error("getUsing requires exactly one key, e.g. { pcb_component_id }");const c=g[0],I=c.replace("_id","");if(a.byRelation&&t.indexes.byRelation){const B=t.indexes.byRelation.get(c);if(B){const Q=(B.get(r[c])||[]).find(E=>E.type===I);if(!Q)return null;const h=Q[`${s}_id`];return a.byId&&t.indexes.byId?t.indexes.byId.get(`${s}:${h}`)||null:a.byType&&t.indexes.byType?(t.indexes.byType.get(s)||[]).find(u=>u[`${s}_id`]===h)||null:e.find(E=>E.type===s&&E[`${s}_id`]===h)||null}}const l=e.find(B=>B.type===I&&B[c]===r[c]);return l&&e.find(B=>B.type===s&&B[`${s}_id`]===l[`${s}_id`])||null},getWhere:r=>{const a=A.indexConfig||{},g=Object.keys(r);if(g.length===1&&a.byCustomField&&t.indexes.byCustomField){const c=g[0],I=t.indexes.byCustomField.get(c);if(I){const l=String(r[c]);return(I.get(l)||[]).find(C=>C.type===s)||null}}if("subcircuit_id"in r&&a.bySubcircuit&&t.indexes.bySubcircuit){const c=r.subcircuit_id;return(t.indexes.bySubcircuit.get(c)||[]).find(l=>l.type===s&&g.every(B=>l[B]===r[B]))||null}return a.byType&&t.indexes.byType?(t.indexes.byType.get(s)||[]).find(I=>g.every(l=>I[l]===r[l]))||null:e.find(c=>c.type===s&&g.every(I=>c[I]===r[I]))||null},list:r=>{const a=A.indexConfig||{},g=r?Object.keys(r):[];if(g.length===0&&a.byType&&t.indexes.byType)return t.indexes.byType.get(s)||[];if(g.length===1&&g[0]==="subcircuit_id"&&a.bySubcircuit&&t.indexes.bySubcircuit){const I=r.subcircuit_id;return(t.indexes.bySubcircuit.get(I)||[]).filter(B=>B.type===s)}let c;return a.byType&&t.indexes.byType?c=t.indexes.byType.get(s)||[]:c=e.filter(I=>I.type===s),g.length>0?c.filter(I=>g.every(l=>I[l]===r[l])):c},insert:r=>{t.counts[s]??=-1,t.counts[s]++;const a=t.counts[s],g={type:s,[`${s}_id`]:`${s}_${a}`,...r};A.validateInserts&&(_gt[s]??ifA).parse(g),e.push(g),t.editCount++;const c=A.indexConfig||{};if(c.byId&&t.indexes.byId){const I=vfA(g);t.indexes.byId.set(I,g)}if(c.byType&&t.indexes.byType){const I=t.indexes.byType.get(s)||[];I.push(g),t.indexes.byType.set(s,I)}if(c.byRelation&&t.indexes.byRelation){const I=Object.entries(g);for(const[l,B]of I)if(l.endsWith("_id")&&l!==`${g.type}_id`&&typeof B=="string"){const C=t.indexes.byRelation.get(l)||new Map,Q=C.get(B)||[];Q.push(g),C.set(B,Q),t.indexes.byRelation.set(l,C)}}if(c.bySubcircuit&&t.indexes.bySubcircuit&&"subcircuit_id"in g){const I=g.subcircuit_id;if(I&&typeof I=="string"){const l=t.indexes.bySubcircuit.get(I)||[];l.push(g),t.indexes.bySubcircuit.set(I,l)}}if(c.byCustomField&&t.indexes.byCustomField){for(const I of c.byCustomField)if(I in g){const l=g[I];if(l!==void 0&&(typeof l=="string"||typeof l=="number")){const B=String(l),C=t.indexes.byCustomField.get(I),Q=C.get(B)||[];Q.push(g),C.set(B,Q)}}}return g},delete:r=>{const a=A.indexConfig||{};let g;if(a.byId&&t.indexes.byId?g=t.indexes.byId.get(`${s}:${r}`):a.byType&&t.indexes.byType?g=(t.indexes.byType.get(s)||[]).find(l=>l[`${s}_id`]===r):g=e.find(I=>I[`${s}_id`]===r),!g)return;const c=e.indexOf(g);if(c>=0&&(e.splice(c,1),t.editCount++),a.byId&&t.indexes.byId){const I=vfA(g);t.indexes.byId.delete(I)}if(a.byType&&t.indexes.byType){const l=(t.indexes.byType.get(s)||[]).filter(B=>B[`${s}_id`]!==r);t.indexes.byType.set(s,l)}if(a.byRelation&&t.indexes.byRelation)for(const[I,l]of t.indexes.byRelation.entries())for(const[B,C]of l.entries()){const Q=C.filter(h=>h!==g);Q.length===0?l.delete(B):l.set(B,Q)}if(a.bySubcircuit&&t.indexes.bySubcircuit&&"subcircuit_id"in g){const I=g.subcircuit_id;if(I){const B=(t.indexes.bySubcircuit.get(I)||[]).filter(C=>C!==g);B.length===0?t.indexes.bySubcircuit.delete(I):t.indexes.bySubcircuit.set(I,B)}}if(a.byCustomField&&t.indexes.byCustomField)for(const I of t.indexes.byCustomField.values())for(const[l,B]of I.entries()){const C=B.filter(Q=>Q!==g);C.length===0?I.delete(l):I.set(l,C)}},update:(r,a)=>{const g=A.indexConfig||{};let c;if(g.byId&&t.indexes.byId?c=t.indexes.byId.get(`${s}:${r}`):g.byType&&t.indexes.byType?c=(t.indexes.byType.get(s)||[]).find(l=>l[`${s}_id`]===r):c=e.find(I=>I.type===s&&I[`${s}_id`]===r),!c)return null;if(g.byRelation&&t.indexes.byRelation){const I=Object.entries(c);for(const[l,B]of I)if(l.endsWith("_id")&&l!==`${c.type}_id`&&typeof B=="string"&&l in a&&a[l]!==B){const C=t.indexes.byRelation.get(l);if(C){const h=(C.get(B)||[]).filter(E=>E!==c);h.length===0?C.delete(B):C.set(B,h)}}}if(g.bySubcircuit&&t.indexes.bySubcircuit&&"subcircuit_id"in c&&"subcircuit_id"in a){const I=c.subcircuit_id,l=a.subcircuit_id;if(I!==l){const C=(t.indexes.bySubcircuit.get(I)||[]).filter(Q=>Q!==c);C.length===0?t.indexes.bySubcircuit.delete(I):t.indexes.bySubcircuit.set(I,C)}}if(g.byCustomField&&t.indexes.byCustomField){for(const I of g.byCustomField)if(I in c&&I in a&&c[I]!==a[I]){const l=t.indexes.byCustomField.get(I);if(l){const B=String(c[I]),Q=(l.get(B)||[]).filter(h=>h!==c);Q.length===0?l.delete(B):l.set(B,Q)}}}if(Object.assign(c,a),t.editCount++,g.byRelation&&t.indexes.byRelation){const I=Object.entries(c);for(const[l,B]of I)if(l.endsWith("_id")&&l!==`${c.type}_id`&&typeof B=="string"&&l in a){const C=t.indexes.byRelation.get(l)||new Map,Q=C.get(B)||[];Q.includes(c)||(Q.push(c),C.set(B,Q),t.indexes.byRelation.set(l,C))}}if(g.bySubcircuit&&t.indexes.bySubcircuit&&"subcircuit_id"in c&&"subcircuit_id"in a){const I=c.subcircuit_id;if(I&&typeof I=="string"){const l=t.indexes.bySubcircuit.get(I)||[];l.includes(c)||(l.push(c),t.indexes.bySubcircuit.set(I,l))}}if(g.byCustomField&&t.indexes.byCustomField){for(const I of g.byCustomField)if(I in c&&I in a){const l=c[I];if(l!==void 0&&(typeof l=="string"||typeof l=="number")){const B=String(l),C=t.indexes.byCustomField.get(I),Q=C.get(B)||[];Q.includes(c)||(Q.push(c),C.set(B,Q))}}}return c},select:r=>{if(s==="source_component")return e.find(a=>a.type==="source_component"&&a.name===r.replace(/\./g,""))||null;if(s==="pcb_port"||s==="source_port"||s==="schematic_port"){const[a,g]=r.replace(/\./g,"").split(/[\s\>]+/),c=e.find(l=>l.type==="source_component"&&l.name===a);if(!c)return null;const I=e.find(l=>l.type==="source_port"&&l.source_component_id===c.source_component_id&&(l.name===g||(l.port_hints??[]).includes(g)));if(!I)return null;if(s==="source_port")return I;if(s==="pcb_port")return e.find(l=>l.type==="pcb_port"&&l.source_port_id===I.source_port_id)||null;if(s==="schematic_port")return e.find(l=>l.type==="schematic_port"&&l.source_port_id===I.source_port_id)||null}return null}}}})};_ct.unparsed=_ct;var b8e=e=>{const A=e.type;return e[`${A}_id`]},LfA=e=>{let A=Number.POSITIVE_INFINITY,t=Number.POSITIVE_INFINITY,i=Number.NEGATIVE_INFINITY,n=Number.NEGATIVE_INFINITY;for(const o of e){if(!o.type.startsWith("pcb_"))continue;if(o.type==="pcb_smtpad"&&o.shape==="polygon"&&Array.isArray(o.points)){for(const c of o.points)A=Math.min(A,c.x),t=Math.min(t,c.y),i=Math.max(i,c.x),n=Math.max(n,c.y);continue}let s,r,a,g;if("x"in o&&"y"in o&&(s=Number(o.x),r=Number(o.y)),"outer_diameter"in o&&(a=Number(o.outer_diameter),g=Number(o.outer_diameter)),"width"in o&&(a=Number(o.width)),"height"in o&&(g=Number(o.height)),"center"in o&&(s=o.center.x,r=o.center.y),s!==void 0&&r!==void 0)A=Math.min(A,s),t=Math.min(t,r),i=Math.max(i,s),n=Math.max(n,r),a!==void 0&&g!==void 0&&(A=Math.min(A,s-a/2),t=Math.min(t,r-g/2),i=Math.max(i,s+a/2),n=Math.max(n,r+g/2)),"radius"in o&&(A=Math.min(A,s-o.radius),t=Math.min(t,r-o.radius),i=Math.max(i,s+o.radius),n=Math.max(n,r+o.radius));else if(o.type==="pcb_trace")for(const c of o.route)A=Math.min(A,c.x),t=Math.min(t,c.y),i=Math.max(i,c.x),n=Math.max(n,c.y)}return{minX:A,minY:t,maxX:i,maxY:n}};function x8e(e){let A=0;if(e.length==0)return A;for(var t=0;t<e.length;t++){var i=e.charCodeAt(t);A=(A<<5)-A+i,A=A&A}return Math.abs(A)}var kct=[["#69d2e7","#a7dbd8","#e0e4cc","#f38630","#fa6900"],["#fe4365","#fc9d9a","#f9cdad","#c8c8a9","#83af9b"],["#ecd078","#d95b43","#c02942","#542437","#53777a"],["#556270","#4ecdc4","#c7f464","#ff6b6b","#c44d58"],["#774f38","#e08e79","#f1d4af","#ece5ce","#c5e0dc"],["#e8ddcb","#cdb380","#036564","#033649","#031634"],["#490a3d","#bd1550","#e97f02","#f8ca00","#8a9b0f"],["#594f4f","#547980","#45ada8","#9de0ad","#e5fcc2"],["#00a0b0","#6a4a3c","#cc333f","#eb6841","#edc951"],["#e94e77","#d68189","#c6a49a","#c6e5d9","#f4ead5"],["#3fb8af","#7fc7af","#dad8a7","#ff9e9d","#ff3d7f"],["#d9ceb2","#948c75","#d5ded9","#7a6a53","#99b2b7"],["#ffffff","#cbe86b","#f2e9e1","#1c140d","#cbe86b"],["#efffcd","#dce9be","#555152","#2e2633","#99173c"],["#343838","#005f6b","#008c9e","#00b4cc","#00dffc"],["#413e4a","#73626e","#b38184","#f0b49e","#f7e4be"],["#ff4e50","#fc913a","#f9d423","#ede574","#e1f5c4"],["#99b898","#fecea8","#ff847c","#e84a5f","#2a363b"],["#655643","#80bca3","#f6f7bd","#e6ac27","#bf4d28"],["#00a8c6","#40c0cb","#f9f2e7","#aee239","#8fbe00"],["#351330","#424254","#64908a","#e8caa4","#cc2a41"],["#554236","#f77825","#d3ce3d","#f1efa5","#60b99a"],["#5d4157","#838689","#a8caba","#cad7b2","#ebe3aa"],["#8c2318","#5e8c6a","#88a65e","#bfb35a","#f2c45a"],["#fad089","#ff9c5b","#f5634a","#ed303c","#3b8183"],["#ff4242","#f4fad2","#d4ee5e","#e1edb9","#f0f2eb"],["#f8b195","#f67280","#c06c84","#6c5b7b","#355c7d"],["#d1e751","#ffffff","#000000","#4dbce9","#26ade4"],["#1b676b","#519548","#88c425","#bef202","#eafde6"],["#5e412f","#fcebb6","#78c0a8","#f07818","#f0a830"],["#bcbdac","#cfbe27","#f27435","#f02475","#3b2d38"],["#452632","#91204d","#e4844a","#e8bf56","#e2f7ce"],["#eee6ab","#c5bc8e","#696758","#45484b","#36393b"],["#f0d8a8","#3d1c00","#86b8b1","#f2d694","#fa2a00"],["#2a044a","#0b2e59","#0d6759","#7ab317","#a0c55f"],["#f04155","#ff823a","#f2f26f","#fff7bd","#95cfb7"],["#b9d7d9","#668284","#2a2829","#493736","#7b3b3b"],["#bbbb88","#ccc68d","#eedd99","#eec290","#eeaa88"],["#b3cc57","#ecf081","#ffbe40","#ef746f","#ab3e5b"],["#a3a948","#edb92e","#f85931","#ce1836","#009989"],["#300030","#480048","#601848","#c04848","#f07241"],["#67917a","#170409","#b8af03","#ccbf82","#e33258"],["#aab3ab","#c4cbb7","#ebefc9","#eee0b7","#e8caaf"],["#e8d5b7","#0e2430","#fc3a51","#f5b349","#e8d5b9"],["#ab526b","#bca297","#c5ceae","#f0e2a4","#f4ebc3"],["#607848","#789048","#c0d860","#f0f0d8","#604848"],["#b6d8c0","#c8d9bf","#dadabd","#ecdbbc","#fedcba"],["#a8e6ce","#dcedc2","#ffd3b5","#ffaaa6","#ff8c94"],["#3e4147","#fffedf","#dfba69","#5a2e2e","#2a2c31"],["#fc354c","#29221f","#13747d","#0abfbc","#fcf7c5"],["#cc0c39","#e6781e","#c8cf02","#f8fcc1","#1693a7"],["#1c2130","#028f76","#b3e099","#ffeaad","#d14334"],["#a7c5bd","#e5ddcb","#eb7b59","#cf4647","#524656"],["#dad6ca","#1bb0ce","#4f8699","#6a5e72","#563444"],["#5c323e","#a82743","#e15e32","#c0d23e","#e5f04c"],["#edebe6","#d6e1c7","#94c7b6","#403b33","#d3643b"],["#fdf1cc","#c6d6b8","#987f69","#e3ad40","#fcd036"],["#230f2b","#f21d41","#ebebbc","#bce3c5","#82b3ae"],["#b9d3b0","#81bda4","#b28774","#f88f79","#f6aa93"],["#3a111c","#574951","#83988e","#bcdea5","#e6f9bc"],["#5e3929","#cd8c52","#b7d1a3","#dee8be","#fcf7d3"],["#1c0113","#6b0103","#a30006","#c21a01","#f03c02"],["#000000","#9f111b","#b11623","#292c37","#cccccc"],["#382f32","#ffeaf2","#fcd9e5","#fbc5d8","#f1396d"],["#e3dfba","#c8d6bf","#93ccc6","#6cbdb5","#1a1f1e"],["#f6f6f6","#e8e8e8","#333333","#990100","#b90504"],["#1b325f","#9cc4e4","#e9f2f9","#3a89c9","#f26c4f"],["#a1dbb2","#fee5ad","#faca66","#f7a541","#f45d4c"],["#c1b398","#605951","#fbeec2","#61a6ab","#accec0"],["#5e9fa3","#dcd1b4","#fab87f","#f87e7b","#b05574"],["#951f2b","#f5f4d7","#e0dfb1","#a5a36c","#535233"],["#8dccad","#988864","#fea6a2","#f9d6ac","#ffe9af"],["#2d2d29","#215a6d","#3ca2a2","#92c7a3","#dfece6"],["#413d3d","#040004","#c8ff00","#fa023c","#4b000f"],["#eff3cd","#b2d5ba","#61ada0","#248f8d","#605063"],["#ffefd3","#fffee4","#d0ecea","#9fd6d2","#8b7a5e"],["#cfffdd","#b4dec1","#5c5863","#a85163","#ff1f4c"],["#9dc9ac","#fffec7","#f56218","#ff9d2e","#919167"],["#4e395d","#827085","#8ebe94","#ccfc8e","#dc5b3e"],["#a8a7a7","#cc527a","#e8175d","#474747","#363636"],["#f8edd1","#d88a8a","#474843","#9d9d93","#c5cfc6"],["#046d8b","#309292","#2fb8ac","#93a42a","#ecbe13"],["#f38a8a","#55443d","#a0cab5","#cde9ca","#f1edd0"],["#a70267","#f10c49","#fb6b41","#f6d86b","#339194"],["#ff003c","#ff8a00","#fabe28","#88c100","#00c176"],["#ffedbf","#f7803c","#f54828","#2e0d23","#f8e4c1"],["#4e4d4a","#353432","#94ba65","#2790b0","#2b4e72"],["#0ca5b0","#4e3f30","#fefeeb","#f8f4e4","#a5b3aa"],["#4d3b3b","#de6262","#ffb88c","#ffd0b3","#f5e0d3"],["#fffbb7","#a6f6af","#66b6ab","#5b7c8d","#4f2958"],["#edf6ee","#d1c089","#b3204d","#412e28","#151101"],["#9d7e79","#ccac95","#9a947c","#748b83","#5b756c"],["#fcfef5","#e9ffe1","#cdcfb7","#d6e6c3","#fafbe3"],["#9cddc8","#bfd8ad","#ddd9ab","#f7af63","#633d2e"],["#30261c","#403831","#36544f","#1f5f61","#0b8185"],["#aaff00","#ffaa00","#ff00aa","#aa00ff","#00aaff"],["#d1313d","#e5625c","#f9bf76","#8eb2c5","#615375"],["#ffe181","#eee9e5","#fad3b2","#ffba7f","#ff9c97"],["#73c8a9","#dee1b6","#e1b866","#bd5532","#373b44"],["#805841","#dcf7f3","#fffcdd","#ffd8d8","#f5a2a2"]],_8e=e=>{let{x:A,y:t,width:i,height:n}={...e,...e.size,...e.center,...e.position};if(e.x1!==void 0&&e.x2!==void 0&&e.y1!==void 0&&e.y2!==void 0&&(A=(e.x1+e.x2)/2,t=(e.y1+e.y2)/2,i=Math.abs(e.x1-e.x2),n=Math.abs(e.y1-e.y2)),e.points&&Array.isArray(e.points)&&e.points.length>0){const r=e.points.map(B=>B.x),a=e.points.map(B=>B.y),g=Math.min(...r),c=Math.max(...r),I=Math.min(...a),l=Math.max(...a);A=(g+c)/2,t=(I+l)/2,i=c-g,n=l-I}const o=e.text||e.name||e.source?.text||e.source?.name||"?",s=e;return A===void 0||t===void 0?null:(i===void 0&&"outer_diameter"in e&&(i=e.outer_diameter,n=e.outer_diameter),(i===void 0||n===void 0)&&(i=.1,n=.1),{x:A,y:t,width:i,height:n,title:o,content:s,bg_color:kct[x8e(e.type||o)%kct.length]?.[4]??"#f00"})},k8e=e=>!!e,F8e=e=>{const A=e.filter(g=>g.type.startsWith("pcb_")||g.type.startsWith("schematic_")).concat(e.filter(g=>g.type==="pcb_trace"||g.type==="schematic_trace").flatMap(g=>g.route)).map(g=>_8e(g)).filter(k8e);if(A.length===0)return{center:{x:0,y:0},width:0,height:0};let t=A[0].x-A[0].width/2,i=A[0].x+A[0].width/2,n=A[0].y-A[0].height/2,o=A[0].y+A[0].height/2;for(const g of A.slice(1))t=Math.min(t,g.x-g.width/2),i=Math.max(i,g.x+g.width/2),n=Math.min(n,g.y-g.height/2),o=Math.max(o,g.y+g.height/2);const s=i-t,r=o-n;return{center:{x:t+s/2,y:n+r/2},width:s,height:r}},qD={IS_SHOWING_PCB_GROUPS:"pcb_viewer_is_showing_pcb_groups",PCB_GROUP_VIEW_MODE:"pcb_viewer_group_view_mode",IS_SHOWING_COPPER_POURS:"pcb_viewer_is_showing_copper_pours",IS_SHOWING_GROUP_ANCHOR_OFFSETS:"pcb_viewer_is_showing_group_anchor_offsets",IS_SHOWING_SOLDER_MASK:"pcb_viewer_is_showing_solder_mask"},U9=(e,A)=>{if(typeof window>"u")return A;try{const t=localStorage.getItem(e);return t!==null?JSON.parse(t):A}catch{return A}},H9=(e,A)=>{if(!(typeof window>"u"))try{localStorage.setItem(e,JSON.stringify(A))}catch{}},G8e=(e,A)=>{if(typeof window>"u")return A;try{const t=localStorage.getItem(e);return t!==null?JSON.parse(t):A}catch{return A}},R8e=(e,A)=>{if(!(typeof window>"u"))try{localStorage.setItem(e,JSON.stringify(A))}catch{}},M8e="named_only",N8e=(e={},A=!1)=>EYA(t=>({selected_layer:"top",pcb_viewer_id:`pcb_viewer_${Math.random().toString().slice(2,10)}`,in_edit_mode:!1,in_move_footprint_mode:!1,in_draw_trace_mode:!1,is_moving_component:!1,is_drawing_trace:!1,is_mouse_over_container:!1,is_showing_multiple_traces_length:!1,is_showing_rats_nest:!1,is_showing_autorouting:!0,is_showing_drc_errors:!0,is_showing_copper_pours:U9(qD.IS_SHOWING_COPPER_POURS,!0),is_showing_pcb_groups:A?!1:U9(qD.IS_SHOWING_PCB_GROUPS,!0),is_showing_group_anchor_offsets:U9(qD.IS_SHOWING_GROUP_ANCHOR_OFFSETS,!0),is_showing_solder_mask:U9(qD.IS_SHOWING_SOLDER_MASK,!1),pcb_group_view_mode:A?"all":G8e(qD.PCB_GROUP_VIEW_MODE,M8e),hovered_error_id:null,...e,selectLayer:i=>t({selected_layer:i}),setEditMode:i=>t({in_edit_mode:i!=="off",in_move_footprint_mode:i==="move_footprint",in_draw_trace_mode:i==="draw_trace",is_moving_component:!1,is_drawing_trace:!1}),setIsShowingRatsNest:i=>t({is_showing_rats_nest:i}),setIsMovingComponent:i=>t({is_moving_component:i}),setIsDrawingTrace:i=>t({is_drawing_trace:i}),setIsMouseOverContainer:i=>t({is_mouse_over_container:i}),setIsShowingMultipleTracesLength:i=>t({is_showing_multiple_traces_length:i}),setIsShowingAutorouting:i=>t({is_showing_autorouting:i}),setIsShowingDrcErrors:i=>t({is_showing_drc_errors:i}),setIsShowingCopperPours:i=>{H9(qD.IS_SHOWING_COPPER_POURS,i),t({is_showing_copper_pours:i})},setIsShowingPcbGroups:i=>{A||(H9(qD.IS_SHOWING_PCB_GROUPS,i),t({is_showing_pcb_groups:i}))},setIsShowingGroupAnchorOffsets:i=>{H9(qD.IS_SHOWING_GROUP_ANCHOR_OFFSETS,i),t({is_showing_group_anchor_offsets:i})},setIsShowingSolderMask:i=>{H9(qD.IS_SHOWING_SOLDER_MASK,i),t({is_showing_solder_mask:i})},setPcbGroupViewMode:i=>{A||(R8e(qD.PCB_GROUP_VIEW_MODE,i),t({pcb_group_view_mode:i}))},setHoveredErrorId:i=>t({hovered_error_id:i})})),eC=e=>{const A=V.useContext(Fct);return bYA(A,e)},Fct=V.createContext(null),v8e=({children:e,initialState:A,disablePcbGroups:t})=>{const i=V.useMemo(()=>N8e(A,t),[t]);return W.jsx(Fct.Provider,{value:i,children:e})},L8e=()=>{const e=eC(t=>t.pcb_viewer_id),A=(t,i)=>Xg(t,{containerId:e,...i});return A.error=(t,i)=>Xg.error(t,{containerId:e,...i}),A.promise=Xg.promise,A},U8e=()=>{V.useEffect(()=>{J3e()},[]);const e=eC(A=>A.pcb_viewer_id);return W.jsx(Y3e,{position:"top-center",containerId:e})},H8e=function(){},Gct=typeof window<"u",Y8e=Gct?V.useLayoutEffect:V.useEffect,J8e=Y8e,Rct={x:0,y:0,width:0,height:0,top:0,left:0,bottom:0,right:0};function T8e(){var e=V.useState(null),A=e[0],t=e[1],i=V.useState(Rct),n=i[0],o=i[1],s=V.useMemo(function(){return new window.ResizeObserver(function(r){if(r[0]){var a=r[0].contentRect,g=a.x,c=a.y,I=a.width,l=a.height,B=a.top,C=a.left,Q=a.bottom,h=a.right;o({x:g,y:c,width:I,height:l,top:B,left:C,bottom:Q,right:h})}})},[]);return J8e(function(){if(A)return s.observe(A),function(){s.disconnect()}},[A]),[t,n]}var yJ=Gct&&typeof window.ResizeObserver<"u"?T8e:function(){return[H8e,Rct]},Mct=({initialTransform:e,initialTouch1:A,initialTouch2:t,finalTouch1:i,finalTouch2:n})=>{if(!i||!n)return e;const o={x:(A.x+t.x)/2,y:(A.y+t.y)/2},s={x:(i.x+n.x)/2,y:(i.y+n.y)/2},r=Math.hypot(t.x-A.x,t.y-A.y),a=Math.hypot(n.x-i.x,n.y-i.y),g=r===0?1:a/r,c=s.x-o.x,I=s.y-o.y;return im(lB(c,I),lB(o.x,o.y),gJ(g,g),lB(-o.x,-o.y),e)},K8e=(e={})=>{const A=V.useRef(null),[t,i]=V.useState(0),n=e.canvasElm??A.current,[o,s]=V.useState(e.initialTransform??_b()),[r,a]=V.useState(0),[g,c]=V.useReducer(d=>d+1,0),I=V.useCallback(d=>{e.onSetTransform&&e.onSetTransform(d),e.transform||s(d)},[e.onSetTransform,s]),l=V.useCallback(d=>{I(d),c()},[I]),B=e.transform??o,C=V.useCallback(()=>{i(Date.now())},[]),Q=V.useRef("none"),h=V.useRef(null),E=V.useRef(null);V.useEffect(()=>{const d=e.canvasElm??A.current;if(d&&!n){a(r+1);return}if(!d){const Z=setTimeout(()=>{a(r+1)},100);return()=>clearTimeout(Z)}let p=e.transform??o,m={x:0,y:0},w={x:0,y:0},D=!1;const S=Z=>({x:Z.pageX-d.getBoundingClientRect().left-window.scrollX,y:Z.pageY-d.getBoundingClientRect().top-window.scrollY});function k(Z){e.enabled!==!1&&(e.shouldDrag&&!e.shouldDrag(Z)||(m=S(Z),!(Date.now()-t<100)&&(D=!0,Z.preventDefault())))}function x(Z){if(!D||e.enabled===!1||e.shouldDrag&&!e.shouldDrag(Z))return;w=S(Z);const $=im(lB(w.x-m.x,w.y-m.y),p);I($),p=$,D=!1}function N(Z){if(S(Z),!D||e.enabled===!1||e.shouldDrag&&!e.shouldDrag(Z))return;w=S(Z);const $=im(lB(w.x-m.x,w.y-m.y),p);I($)}function M(Z){if(e.enabled===!1||e.shouldDrag&&!e.shouldDrag(Z))return;const $=S(Z),eA=im(lB($.x,$.y),gJ(1-Z.deltaY/1e3,1-Z.deltaY/1e3),lB(-$.x,-$.y),p);I(eA),p=eA,Z.preventDefault()}function L(Z){if(!D||e.shouldDrag&&!e.shouldDrag(Z))return;if(d){const eA=d.getBoundingClientRect();if(Z.clientX>=eA.left+10&&Z.clientX<=eA.right-10&&Z.clientY>=eA.top+10&&Z.clientY<=eA.bottom-10)return}D=!1,w=S(Z);const $=im(lB(w.x-m.x,w.y-m.y),p);I($),p=$}function Y(Z){if(Z.preventDefault(),e.enabled!==!1){if(Z.touches.length===1){Q.current="drag";const $=Z.touches[0];h.current={initialTransform:p,initialTouch:{x:$.clientX,y:$.clientY}}}else if(Z.touches.length===2){Q.current="pinch";const $=Z.touches[0],eA=Z.touches[1];E.current={initialTransform:p,initialTouch1:{x:$.clientX,y:$.clientY},initialTouch2:{x:eA.clientX,y:eA.clientY},finalTouch1:null,finalTouch2:null}}}}function H(Z){if(Z.preventDefault(),e.enabled!==!1){if(Q.current==="drag"&&Z.touches.length===1&&h.current){const $=Z.touches[0],eA={x:$.clientX,y:$.clientY},aA=eA.x-h.current.initialTouch.x,tA=eA.y-h.current.initialTouch.y,nA=im(lB(aA,tA),h.current.initialTransform);I(nA)}else if(Q.current==="pinch"&&Z.touches.length===2&&E.current){const $=Z.touches[0],eA=Z.touches[1];E.current.finalTouch1={x:$.clientX,y:$.clientY},E.current.finalTouch2={x:eA.clientX,y:eA.clientY};const aA=Mct(E.current);I(aA)}}}function O(Z){Z.preventDefault();const $=Z.changedTouches[0];if(Q.current==="drag"&&h.current&&$){const eA={x:$.clientX,y:$.clientY},aA=eA.x-h.current.initialTouch.x,tA=eA.y-h.current.initialTouch.y,nA=im(lB(aA,tA),h.current.initialTransform);I(nA),p=nA}else if(Q.current==="pinch"&&E.current){const eA=Mct(E.current);I(eA),p=eA}Q.current="none",h.current=null,E.current=null}return d.addEventListener("mousedown",k),d.addEventListener("mouseup",x),window.addEventListener("mousemove",N),d.addEventListener("mouseout",L),d.addEventListener("wheel",M),d.addEventListener("touchstart",Y,{passive:!1}),d.addEventListener("touchmove",H,{passive:!1}),d.addEventListener("touchend",O,{passive:!1}),d.addEventListener("touchcancel",O,{passive:!1}),()=>{d.removeEventListener("mousedown",k),d.removeEventListener("mouseup",x),window.removeEventListener("mousemove",N),d.removeEventListener("mouseout",L),d.removeEventListener("wheel",M),d.removeEventListener("touchstart",Y),d.removeEventListener("touchmove",H),d.removeEventListener("touchend",O),d.removeEventListener("touchcancel",O)}},[n,r,g,t,e.enabled,e.shouldDrag]);const u=V.useCallback(d=>qi(B,d),[B]);return{ref:A,transform:B,applyTransformToPoint:u,setTransform:l,cancelDrag:C}},P8e=K8e;function q8e(e){const A=new Map;let t=0;function i(n){for(const[,s]of A)if(s.has(n))return s;const o=new Set;return A.set(`connectivity_net${t++}`,o),o}for(const n of e){let o=null;for(const s of n){if(!o)o=i(s);else if(!o.has(s)){const r=i(s);if(r!==o){for(const a of r)o.add(a);A.delete(Array.from(A.entries()).find(([,a])=>a===r)[0])}}o.add(s)}}return Object.fromEntries(Array.from(A.entries()).map(([n,o])=>[n,Array.from(o)]))}var O8e=class{netMap;idToNetMap;constructor(e){this.netMap=e,this.idToNetMap={};for(const[A,t]of Object.entries(e))for(const i of t)this.idToNetMap[i]=A}addConnections(e){for(const A of e){const t=new Set;for(const n of A){const o=this.idToNetMap[n];o&&t.add(o)}let i;if(t.size===0)i=`connectivity_net${Object.keys(this.netMap).length}`,this.netMap[i]=[];else if(t.size===1)i=t.values().next().value??`connectivity_net${Object.keys(this.netMap).length}`;else{i=t.values().next().value??`connectivity_net${Object.keys(this.netMap).length}`;for(const n of t)if(n!==i){this.netMap[i].push(...this.netMap[n]),this.netMap[n]=this.netMap[i];for(const o of this.netMap[i])this.idToNetMap[o]=i}}for(const n of A)this.netMap[i].includes(n)||this.netMap[i].push(n),this.idToNetMap[n]=i}}getIdsConnectedToNet(e){return this.netMap[e]||[]}getNetConnectedToId(e){return this.idToNetMap[e]}areIdsConnected(e,A){if(e===A)return!0;const t=this.getNetConnectedToId(e);if(!t)return!1;const i=this.getNetConnectedToId(A);return i?t===i||i===e||i===e:!1}areAllIdsConnected(e){const A=this.getNetConnectedToId(e[0]);for(const t of e){const i=this.getNetConnectedToId(t);if(i===void 0||i!==A)return!1}return!0}},Nct=e=>{const A=[];for(const i of e)if(i.type==="source_trace")A.push([i.source_trace_id,...i.connected_source_port_ids??[],...i.connected_source_net_ids??[]].filter(Boolean));else if(i.type==="pcb_port"){const{pcb_port_id:n,source_port_id:o}=i;o&&n&&A.push([o,n])}else if(i.type==="pcb_smtpad"){const{pcb_smtpad_id:n,pcb_port_id:o}=i;o&&n&&A.push([n,o])}else if(i.type==="pcb_plated_hole"){const{pcb_plated_hole_id:n,pcb_port_id:o}=i;o&&n&&A.push([n,o])}else if(i.type==="pcb_trace"){const{pcb_trace_id:n,source_trace_id:o}=i,s=Array.isArray(i.route)?i.route.filter(r=>r&&r.route_type==="wire"):[];if(o&&n&&A.push([n,o]),Array.isArray(s)){const r=s.find(g=>g?.start_pcb_port_id)?.start_pcb_port_id,a=s.find(g=>g?.end_pcb_port_id)?.end_pcb_port_id;r&&n&&a&&A.push([r,n,a])}}else if(i.type==="pcb_via"){const{pcb_via_id:n,pcb_trace_id:o}=i;o&&n&&A.push([n,o])}else if(i.type==="source_component"&&i.internally_connected_source_port_ids)for(const n of i.internally_connected_source_port_ids)A.push(n);const t=q8e(A);return new O8e(t)};function W8e({primitivesWithoutInteractionMetadata:e,drawingObjectIdsWithMouseOver:A,primitiveIdsInMousedOverNet:t}){const i=[];for(const n of e){const o={...n};n?.layer==="drill"?(o.is_in_highlighted_net=!1,o.is_mouse_over=!1):A.has(n._pcb_drawing_object_id)?o.is_mouse_over=!0:n._element&&("pcb_trace_id"in n._element&&t.includes(n._element.pcb_trace_id)||"pcb_port_id"in n._element&&t.includes(n._element.pcb_port_id))?o.is_in_highlighted_net=!0:(o.is_in_highlighted_net=!1,o.is_mouse_over=!1),i.push(o)}return i}function Z8e(e,A){if(e.length<2)throw new Error("Stroke must have at least two points");const t=e.map(I=>Array.isArray(I)?{x:I[0],y:I[1]}:I),i=[],n=[];function o(I,l){const B=l.x-I.x,C=l.y-I.y,Q=Math.sqrt(B*B+C*C);return{x:-C/Q,y:B/Q}}function s(I,l,B,C){const Q=C/2,h={x:I.x+l.x*Q*B,y:I.y+l.y*Q*B};B>0?i.push(h):n.unshift(h)}const r=o(t[0],t[1]),a=t[0].trace_width??A;s(t[0],r,1,a),s(t[0],r,-1,a);for(let I=1;I<t.length-1;I++){const l=t[I-1],B=t[I],C=t[I+1],Q=o(l,B),h=o(B,C),E=Q.x+h.x,u=Q.y+h.y,d=Math.sqrt(E*E+u*u),p=B.trace_width??A;if(d/2>2*(p/2))s(B,Q,1,p),s(B,h,1,p),s(B,Q,-1,p),s(B,h,-1,p);else{const w=1/d;s(B,{x:E*w,y:u*w},1,p),s(B,{x:E*w,y:u*w},-1,p)}}const g=o(t[t.length-2],t[t.length-1]),c=t[t.length-1].trace_width??A;return s(t[t.length-1],g,1,c),s(t[t.length-1],g,-1,c),[...i,...n]}var V8e=(e,A)=>{const{x:t,y:i,width:n,height:o,layer:s,rect_border_radius:r}=e,a=e.corner_radius??r??0,g=[{_pcb_drawing_object_id:nm("rect"),pcb_drawing_type:"rect",x:t,y:i,w:n,h:o,layer:s||"top",_element:e,_parent_pcb_component:A._parent_pcb_component,_parent_source_component:A._parent_source_component,_source_port:A._source_port,roundness:a,...e.shape==="rotated_rect"&&e.ccw_rotation!==void 0?{ccw_rotation:e.ccw_rotation}:{}}];if(e.is_covered_with_solder_mask){const c=s==="bottom"?"soldermask_with_copper_bottom":"soldermask_with_copper_top",l={...{_pcb_drawing_object_id:nm("rect"),pcb_drawing_type:"rect",x:t,y:i,w:n,h:o,layer:c,_element:e,_parent_pcb_component:A._parent_pcb_component,_parent_source_component:A._parent_source_component,_source_port:A._source_port,roundness:a,...e.shape==="rotated_rect"&&e.ccw_rotation!==void 0?{ccw_rotation:e.ccw_rotation}:{}},..."solder_mask_color"in e&&e.solder_mask_color?{color:e.solder_mask_color}:{}};g.push(l)}return g},j8e=(e,A)=>{const{x:t,y:i,radius:n,layer:o}=e,s=[{_pcb_drawing_object_id:nm("circle"),pcb_drawing_type:"circle",x:t,y:i,r:n,layer:o||"top",_element:e,_parent_pcb_component:A._parent_pcb_component,_parent_source_component:A._parent_source_component,_source_port:A._source_port}];if(e.is_covered_with_solder_mask){const r=o==="bottom"?"soldermask_with_copper_bottom":"soldermask_with_copper_top",a={_pcb_drawing_object_id:nm("circle"),pcb_drawing_type:"circle",x:t,y:i,r:n,layer:r,_element:e,_parent_pcb_component:A._parent_pcb_component,_parent_source_component:A._parent_source_component,_source_port:A._source_port,..."solder_mask_color"in e&&e.solder_mask_color?{color:e.solder_mask_color}:{}};s.push(a)}return s},z8e=(e,A)=>{const{layer:t,points:i}=e,n=[{_pcb_drawing_object_id:nm("polygon"),pcb_drawing_type:"polygon",points:UfA(i),layer:t||"top",_element:e,_parent_pcb_component:A._parent_pcb_component,_parent_source_component:A._parent_source_component,_source_port:A._source_port}];if(e.is_covered_with_solder_mask){const o=t==="bottom"?"soldermask_with_copper_bottom":"soldermask_with_copper_top",s={_pcb_drawing_object_id:nm("polygon"),pcb_drawing_type:"polygon",points:UfA(i),layer:o,_element:e,_parent_pcb_component:A._parent_pcb_component,_parent_source_component:A._parent_source_component,_source_port:A._source_port,..."solder_mask_color"in e&&e.solder_mask_color?{color:e.solder_mask_color}:{}};n.push(s)}return n},X8e=(e,A)=>{const{x:t,y:i,width:n,height:o,layer:s}=e,r=[{_pcb_drawing_object_id:nm("pill"),pcb_drawing_type:"pill",x:t,y:i,w:n,h:o,layer:s||"top",_element:e,_parent_pcb_component:A._parent_pcb_component,_parent_source_component:A._parent_source_component,_source_port:A._source_port}];if(e.is_covered_with_solder_mask){const a=s==="bottom"?"soldermask_with_copper_bottom":"soldermask_with_copper_top",g={_pcb_drawing_object_id:nm("pill"),pcb_drawing_type:"pill",x:t,y:i,w:n,h:o,layer:a,_element:e,_parent_pcb_component:A._parent_pcb_component,_parent_source_component:A._parent_source_component,_source_port:A._source_port,..."solder_mask_color"in e&&e.solder_mask_color?{color:e.solder_mask_color}:{}};r.push(g)}return r},$8e=(e,A)=>{const{x:t,y:i,width:n,height:o,layer:s,ccw_rotation:r}=e,a=[{_pcb_drawing_object_id:nm("pill"),pcb_drawing_type:"pill",x:t,y:i,w:n,h:o,layer:s||"top",_element:e,_parent_pcb_component:A._parent_pcb_component,_parent_source_component:A._parent_source_component,_source_port:A._source_port,ccw_rotation:r}];if(e.is_covered_with_solder_mask){const g=s==="bottom"?"soldermask_with_copper_bottom":"soldermask_with_copper_top",c={_pcb_drawing_object_id:nm("pill"),pcb_drawing_type:"pill",x:t,y:i,w:n,h:o,layer:g,_element:e,_parent_pcb_component:A._parent_pcb_component,_parent_source_component:A._parent_source_component,_source_port:A._source_port,ccw_rotation:r,..."solder_mask_color"in e&&e.solder_mask_color?{color:e.solder_mask_color}:{}};a.push(c)}return a},AWe=(e,A)=>{const{_parent_pcb_component:t,_parent_source_component:i}=A,n=e,o=typeof n.font_size=="string"?he.parse(n.font_size):n.font_size??.2;let s;return n.knockout_padding&&(s={left:typeof n.knockout_padding.left=="string"?he.parse(n.knockout_padding.left):n.knockout_padding.left,top:typeof n.knockout_padding.top=="string"?he.parse(n.knockout_padding.top):n.knockout_padding.top,bottom:typeof n.knockout_padding.bottom=="string"?he.parse(n.knockout_padding.bottom):n.knockout_padding.bottom,right:typeof n.knockout_padding.right=="string"?he.parse(n.knockout_padding.right):n.knockout_padding.right}),[{_pcb_drawing_object_id:nm("text"),pcb_drawing_type:"text",x:n.anchor_position.x,y:n.anchor_position.y,layer:n.layer,align:n.anchor_alignment??"center",text:n.text,size:o,ccw_rotation:n.ccw_rotation,is_mirrored:n.is_mirrored,is_knockout:n.is_knockout,knockout_padding:s,_element:e,_parent_pcb_component:t,_parent_source_component:i}]},_I=0,nm=e=>`${e}_${_I++}`,UfA=e=>(e??[]).map(A=>({x:he.parse(A.x),y:he.parse(A.y)})),tWe=(e,A)=>{const t="pcb_component_id"in e?A.find(s=>s.type==="pcb_component"&&s.pcb_component_id===e.pcb_component_id):void 0,i=t&&"source_component_id"in t?A.find(s=>s.type==="source_component"&&s.source_component_id===t.source_component_id):void 0,n="source_port_id"in e?e.source_port_id:"pcb_port_id"in e?Gb(A).pcb_port.get(e.pcb_port_id)?.source_port_id:void 0,o=n?A.find(s=>s.type==="source_port"&&s.source_port_id===n):void 0;switch(e.type){case"pcb_smtpad":{const s={_parent_pcb_component:t,_parent_source_component:i,_source_port:o};return e.shape==="rect"||e.shape==="rotated_rect"?V8e(e,s):e.shape==="circle"?j8e(e,s):e.shape==="polygon"?z8e(e,s):e.shape==="pill"?X8e(e,s):e.shape==="rotated_pill"?$8e(e,s):[]}case"pcb_trace":{const s=[];if(e.route_thickness_mode==="interpolated"){const g=e.route.map(l=>({x:l.x,y:l.y,trace_width:l.route_type==="wire"?l.width:.5})),c=Z8e(g,.5),I=e.route[0].layer;return s.push({_pcb_drawing_object_id:`polygon_${_I++}`,_element:e,pcb_drawing_type:"polygon",points:c,layer:I}),e.route.forEach(l=>{l.route_type==="via"&&s.push({_pcb_drawing_object_id:`circle_${_I++}`,_element:e,pcb_drawing_type:"circle",x:l.x,y:l.y,r:l.outer_diameter/2,layer:l.from_layer})}),s}let r=null,a=null;for(const g of e.route)g.route_type==="wire"&&(r!==null&&a!==null&&s.push({_pcb_drawing_object_id:`line_${_I++}`,_element:e,pcb_drawing_type:"line",x1:r,y1:a,x2:g.x,y2:g.y,width:g.width,squareCap:!1,layer:g.layer}),r=g.x,a=g.y);return s}case"pcb_via":{const{x:s,y:r,outer_diameter:a,hole_diameter:g}=e,c=e.from_layer,I=e.to_layer,l=e.layers,B=[];c&&I?B.push(c,I):l&&Array.isArray(l)?B.push(...l):B.push("top","bottom");const C=[];for(const Q of B)C.push({_pcb_drawing_object_id:`circle_${_I++}`,pcb_drawing_type:"circle",x:s,y:r,r:a/2,layer:Q,_element:e,_parent_pcb_component:t,_parent_source_component:i});return C.push({_pcb_drawing_object_id:`circle_${_I++}`,pcb_drawing_type:"circle",x:s,y:r,r:g/2,layer:"drill",_element:e}),C}case"pcb_plated_hole":if(e.shape==="circle"){const{x:s,y:r,hole_diameter:a,outer_diameter:g}=e;return[{_pcb_drawing_object_id:`circle_${_I++}`,pcb_drawing_type:"circle",x:s,y:r,r:g/2,layer:"top",_element:e,_parent_pcb_component:t,_parent_source_component:i,_source_port:o},{_pcb_drawing_object_id:`circle_${_I++}`,pcb_drawing_type:"circle",x:s,y:r,r:a/2,layer:"drill",_element:e}]}else if(e.shape==="oval"){const{x:s,y:r,outer_height:a,outer_width:g,hole_height:c,hole_width:I}=e;return[{_pcb_drawing_object_id:`oval_${_I++}`,pcb_drawing_type:"oval",x:s,y:r,rX:g/2,rY:a/2,layer:"top",_element:e,_parent_pcb_component:t,_parent_source_component:i,_source_port:o},{_pcb_drawing_object_id:`oval_${_I++}`,_element:e,pcb_drawing_type:"oval",x:s,y:r,rX:I/2,rY:c/2,layer:"drill"}]}else if(e.shape==="pill"){const{x:s,y:r,outer_height:a,outer_width:g,hole_height:c,hole_width:I}=e;return[{_pcb_drawing_object_id:`pill_${_I++}`,pcb_drawing_type:"pill",x:s,y:r,w:g,h:a,layer:"top",_element:e,_parent_pcb_component:t,_parent_source_component:i,_source_port:o,ccw_rotation:e.ccw_rotation},{_pcb_drawing_object_id:`pill_${_I++}`,_element:e,pcb_drawing_type:"pill",x:s,y:r,w:I,h:c,layer:"drill",ccw_rotation:e.ccw_rotation}]}else if(e.shape==="circular_hole_with_rect_pad"){const{x:s,y:r,hole_diameter:a,rect_pad_width:g,rect_pad_height:c,rect_border_radius:I,hole_offset_x:l,hole_offset_y:B}=e,C=he.parse(l??0),Q=he.parse(B??0);return[{_pcb_drawing_object_id:`rect_${_I++}`,pcb_drawing_type:"rect",x:s,y:r,w:g,h:c,layer:"top",_element:e,_parent_pcb_component:t,_parent_source_component:i,_source_port:o,roundness:I},{_pcb_drawing_object_id:`rect_${_I++}`,pcb_drawing_type:"rect",x:s,y:r,w:g,h:c,layer:"bottom",_element:e,_parent_pcb_component:t,_parent_source_component:i,_source_port:o,roundness:I},{_pcb_drawing_object_id:`circle_${_I++}`,_element:e,pcb_drawing_type:"circle",x:s+C,y:r+Q,r:a/2,layer:"drill"}]}else if(e.shape==="pill_hole_with_rect_pad"){const{x:s,y:r,hole_width:a,hole_height:g,rect_pad_width:c,rect_pad_height:I,rect_border_radius:l}=e;return[{_pcb_drawing_object_id:`rect_${_I++}`,pcb_drawing_type:"rect",x:s,y:r,w:c,h:I,layer:"top",_element:e,_parent_pcb_component:t,_parent_source_component:i,_source_port:o,roundness:l},{_pcb_drawing_object_id:`rect_${_I++}`,pcb_drawing_type:"rect",x:s,y:r,w:c,h:I,layer:"bottom",_element:e,_parent_pcb_component:t,_parent_source_component:i,_source_port:o,roundness:l},{_pcb_drawing_object_id:`pill_${_I++}`,_element:e,pcb_drawing_type:"pill",x:s,y:r,w:a,h:g,layer:"drill"}]}else if(e.shape==="rotated_pill_hole_with_rect_pad"){const{x:s,y:r,hole_width:a,hole_height:g,hole_ccw_rotation:c,rect_pad_width:I,rect_pad_height:l,rect_ccw_rotation:B,rect_border_radius:C}=e;return[{_pcb_drawing_object_id:`rect_${_I++}`,pcb_drawing_type:"rect",x:s,y:r,w:I,h:l,layer:"top",_element:e,_parent_pcb_component:t,_parent_source_component:i,_source_port:o,ccw_rotation:B,roundness:C},{_pcb_drawing_object_id:`rect_${_I++}`,pcb_drawing_type:"rect",x:s,y:r,w:I,h:l,layer:"bottom",_element:e,_parent_pcb_component:t,_parent_source_component:i,_source_port:o,ccw_rotation:B,roundness:C},{_pcb_drawing_object_id:`pill_${_I++}`,_element:e,pcb_drawing_type:"pill",x:s,y:r,w:a,h:g,layer:"drill",ccw_rotation:c}]}else if(e.shape==="hole_with_polygon_pad"){const{x:s,y:r,pad_outline:a,hole_shape:g,hole_diameter:c,hole_width:I,hole_height:l,layers:B,hole_offset_x:C,hole_offset_y:Q}=e,h=he.parse(C??0),E=he.parse(Q??0),u=a,d=[];if(u&&Array.isArray(u)){const w=UfA(u).map(D=>({x:D.x+s,y:D.y+r}));for(const D of B||["top","bottom"])d.push({_pcb_drawing_object_id:`polygon_${_I++}`,pcb_drawing_type:"polygon",points:w,layer:D,_element:e,_parent_pcb_component:t,_parent_source_component:i,_source_port:o})}const p={x:s+h,y:r+E},m=[];return g==="circle"?m.push({_pcb_drawing_object_id:`circle_${_I++}`,pcb_drawing_type:"circle",x:p.x,y:p.y,r:(c??0)/2,layer:"drill",_element:e,_parent_pcb_component:t,_parent_source_component:i}):g==="oval"?m.push({_pcb_drawing_object_id:`oval_${_I++}`,pcb_drawing_type:"oval",x:p.x,y:p.y,rX:(I??0)/2,rY:(l??0)/2,layer:"drill",_element:e,_parent_pcb_component:t,_parent_source_component:i}):(g==="pill"||g==="rotated_pill")&&m.push({_pcb_drawing_object_id:`pill_${_I++}`,pcb_drawing_type:"pill",x:p.x,y:p.y,w:I??0,h:l??0,layer:"drill",_element:e,_parent_pcb_component:t,_parent_source_component:i,ccw_rotation:e.ccw_rotation}),[...d,...m]}else return[];case"pcb_copper_text":return AWe(e,{_parent_pcb_component:t,_parent_source_component:i})}return[]},ln={board:{anchor:"rgb(255, 38, 226)",aux_items:"rgb(255, 255, 255)",b_adhes:"rgb(0, 0, 132)",b_crtyd:"rgb(38, 233, 255)",b_fab:"rgb(88, 93, 132)",b_mask:"rgba(2, 255, 238, 0.400)",b_paste:"rgb(0, 194, 194)",b_silks:"rgb(242, 237, 161)",background:"rgb(0, 16, 35)",cmts_user:"rgb(89, 148, 220)",copper:{b:"rgb(77, 127, 196)",f:"rgb(200, 52, 52)",in1:"rgb(127, 200, 127)",in10:"rgb(237, 124, 51)",in11:"rgb(91, 195, 235)",in12:"rgb(247, 111, 142)",in13:"rgb(167, 165, 198)",in14:"rgb(40, 204, 217)",in15:"rgb(232, 178, 167)",in16:"rgb(242, 237, 161)",in17:"rgb(237, 124, 51)",in18:"rgb(91, 195, 235)",in19:"rgb(247, 111, 142)",in2:"rgb(206, 125, 44)",in20:"rgb(167, 165, 198)",in21:"rgb(40, 204, 217)",in22:"rgb(232, 178, 167)",in23:"rgb(242, 237, 161)",in24:"rgb(237, 124, 51)",in25:"rgb(91, 195, 235)",in26:"rgb(247, 111, 142)",in27:"rgb(167, 165, 198)",in28:"rgb(40, 204, 217)",in29:"rgb(232, 178, 167)",in3:"rgb(79, 203, 203)",in30:"rgb(242, 237, 161)",in4:"rgb(219, 98, 139)",in5:"rgb(167, 165, 198)",in6:"rgb(40, 204, 217)",in7:"rgb(232, 178, 167)",in8:"rgb(242, 237, 161)",in9:"rgb(141, 203, 129)"},cursor:"rgb(255, 255, 255)",drc:"rgb(194, 194, 194)",drc_error:"rgba(215, 91, 107, 0.800)",drc_exclusion:"rgb(255, 255, 255)",drc_warning:"rgba(255, 208, 66, 0.902)",dwgs_user:"rgb(194, 194, 194)",eco1_user:"rgb(180, 219, 210)",eco2_user:"rgb(216, 200, 82)",edge_cuts:"rgb(208, 210, 205)",f_adhes:"rgb(132, 0, 132)",f_crtyd:"rgb(255, 0, 245)",f_fab:"rgb(175, 175, 175)",f_mask:"rgba(216, 100, 255, 0.400)",f_paste:"rgba(180, 160, 154, 0.902)",f_silks:"rgb(242, 237, 161)",footprint_text_back:"rgb(0, 0, 132)",footprint_text_front:"rgb(194, 194, 194)",footprint_text_invisible:"rgb(132, 132, 132)",grid:"rgb(132, 132, 132)",grid_axes:"rgb(194, 194, 194)",margin:"rgb(255, 38, 226)",microvia:"rgb(0, 132, 132)",no_connect:"rgb(0, 0, 132)",pad_back:"rgb(77, 127, 196)",pad_front:"rgb(200, 52, 52)",pad_plated_hole:"rgb(194, 194, 0)",pad_through_hole:"rgb(227, 183, 46)",plated_hole:"rgb(26, 196, 210)",ratsnest:"rgba(245, 255, 213, 0.702)",select_overlay:"rgb(4, 255, 67)",soldermaskWithCopper:{top:"rgb(18, 82, 50)",bottom:"rgb(77, 127, 196)"},soldermask:{top:"rgb(12, 55, 33)",bottom:"rgb(12, 55, 33)"},through_via:"rgb(236, 236, 236)",user_1:"rgb(194, 194, 194)",user_2:"rgb(89, 148, 220)",user_3:"rgb(180, 219, 210)",user_4:"rgb(216, 200, 82)",user_5:"rgb(194, 194, 194)",user_6:"rgb(89, 148, 220)",user_7:"rgb(180, 219, 210)",user_8:"rgb(216, 200, 82)",user_9:"rgb(232, 178, 167)",via_blind_buried:"rgb(187, 151, 38)",via_hole:"rgb(227, 183, 46)",via_micro:"rgb(0, 132, 132)",via_through:"rgb(236, 236, 236)",worksheet:"rgb(200, 114, 171)"}},_f=(e,A=1)=>{if(Math.abs(e.a)!==Math.abs(e.d))throw new Error("Cannot scale non-uniformly");return A*Math.abs(e.a)},fc={elementOverlay:40,dimensionOverlay:40,editTraceHintOverlay:40,errorOverlay:40,pcbGroupOverlay:35,ratsNestOverlay:30,toolbarOverlay:70,warnings:30,topLayer:20,clickToInteractOverlay:100},Y9={red:"red",black:"black",green:"green",board:"rgb(255, 255, 255)",other:"#eee",top:ln.board.copper.f,inner1:ln.board.copper.in1,inner2:ln.board.copper.in2,inner3:ln.board.copper.in3,inner4:ln.board.copper.in4,inner5:ln.board.copper.in5,inner6:ln.board.copper.in6,inner7:ln.board.copper.in7,inner8:ln.board.copper.in8,bottom:ln.board.copper.b,drill:ln.board.anchor,keepout:ln.board.background,tkeepout:ln.board.b_crtyd,tplace:ln.board.b_silks,top_courtyard:ln.board.f_crtyd,bottom_courtyard:ln.board.b_crtyd,top_silkscreen:ln.board.f_silks,bottom_silkscreen:ln.board.b_silks,top_fabrication:ln.board.f_fab,bottom_fabrication:ln.board.b_fab,soldermask_top:ln.board.soldermask.top,soldermask_bottom:ln.board.soldermask.bottom,soldermask_with_copper_top:ln.board.soldermaskWithCopper.top,soldermask_with_copper_bottom:ln.board.soldermaskWithCopper.bottom,bottom_notes:ln.board.user_2,top_notes:ln.board.user_2,...ln.board},eWe=["inner6","inner5","inner4","inner3","inner2","inner1","bottom","soldermask_bottom","bottom_silkscreen","top","soldermask_top","soldermask_with_copper_bottom","soldermask_with_copper_top","bottom_courtyard","bottom_fabrication","top_courtyard","top_fabrication","edge_cuts","top_silkscreen","board"],iWe=class{canvasLayerMap;ctxLayerMap;aperture;transform;foregroundLayer="top";lastPoint;constructor(e){this.canvasLayerMap=e,this.ctxLayerMap=Object.fromEntries(Object.entries(e).map(([A,t])=>[A,t.getContext("2d")])),this.transform=_b(),this.transform.d*=-1,this.transform=im(this.transform,lB(0,-500)),this.lastPoint={x:0,y:0},this.equip({})}clear(){for(const e of Object.values(this.ctxLayerMap))e.clearRect(0,0,e.canvas.width,e.canvas.height)}equip(e){this.aperture={fontSize:0,shape:"circle",mode:"add",size:0,color:"red",layer:"top",opacity:this.foregroundLayer===e.color?1:.5,...e}}drawMeshPattern(e,A,t,i,n,o=45){const s=this.getLayerCtx(),[r,a]=qi(this.transform,[e,A]),[g,c]=qi(this.transform,[e+t,A+i]),I=_f(this.transform,n);s.lineWidth=1,s.strokeStyle=this.aperture.color;const l=B=>{const C=Math.sin(B),Q=Math.cos(B),h=Math.sqrt((g-r)**2+(c-a)**2);for(let E=-h;E<=h;E+=I)s.beginPath(),s.moveTo(r+E*Q-h*C,a+E*C+h*Q),s.lineTo(r+E*Q+h*C,a+E*C-h*Q),s.stroke()};l(o*Math.PI/180),l((o+90)*Math.PI/180)}rect({x:e,y:A,w:t,h:i,mesh_fill:n,is_filled:o=!0,has_stroke:s,is_stroke_dashed:r,stroke_width:a,roundness:g}){const[c,I]=qi(this.transform,[e-t/2,A-i/2]),[l,B]=qi(this.transform,[e+t/2,A+i/2]);this.applyAperture();const C=this.getLayerCtx(),Q=g?_f(this.transform,g):0,h=s===void 0?o===!1:s;if(n)C.save(),C.beginPath(),Q>0&&C.roundRect?C.roundRect(c,I,l-c,B-I,Q):C.rect(c,I,l-c,B-I),C.clip(),this.drawMeshPattern(e-t/2,A-i/2,t,i,.15),C.restore(),Q>0&&C.roundRect?(C.beginPath(),C.roundRect(c,I,l-c,B-I,Q),C.stroke()):C.strokeRect(c,I,l-c,B-I);else if(o!==!1&&(Q>0&&C.roundRect?(C.beginPath(),C.roundRect(c,I,l-c,B-I,Q),C.fill()):C.fillRect(c,I,l-c,B-I)),h){const E=C.lineWidth;if(a!==void 0&&(C.lineWidth=_f(this.transform,a)),r){let u=[];const d=Math.abs(this.transform.a);if(d>0){const m=.1*d,w=m*1.3;m>.5&&(u=[m,w])}C.setLineDash(u)}Q>0&&C.roundRect?(C.beginPath(),C.roundRect(c,I,l-c,B-I,Q),C.stroke()):C.strokeRect(c,I,l-c,B-I),r&&C.setLineDash([]),a!==void 0&&(C.lineWidth=E)}}rotatedRect(e,A,t,i,n,o,s){const r=this.getLayerCtx();this.applyAperture();const[a,g]=qi(this.transform,[e-t/2,A-i/2]),[c,I]=qi(this.transform,[e+t/2,A+i/2]),l=o?_f(this.transform,o):0;r.save();const[B,C]=qi(this.transform,[e,A]);r.translate(B,C);const Q=360-n;n&&r.rotate(Q*Math.PI/180),r.translate(-B,-C),s?(r.beginPath(),l>0&&r.roundRect?r.roundRect(a,g,c-a,I-g,l):r.rect(a,g,c-a,I-g),r.clip(),this.drawMeshPattern(e-t/2,A-i/2,t,i,.15),l>0&&r.roundRect?(r.beginPath(),r.roundRect(a,g,c-a,I-g,l),r.stroke()):r.strokeRect(a,g,c-a,I-g)):l>0&&r.roundRect?(r.beginPath(),r.roundRect(a,g,c-a,I-g,l),r.fill()):r.fillRect(a,g,c-a,I-g),r.restore()}rotatedPill(e,A,t,i,n){const o=this.getLayerCtx();this.applyAperture(),o.save();const[s,r]=qi(this.transform,[e,A]);o.translate(s,r);const a=360-n;n&&o.rotate(a*Math.PI/180),o.translate(-s,-r),this.pill(e,A,t,i),o.restore()}circle(e,A,t,i,n=!0){const o=_f(this.transform,t),[s,r]=qi(this.transform,[e,A]);this.applyAperture();const a=this.getLayerCtx();i?(a.save(),a.beginPath(),a.arc(s,r,o,0,2*Math.PI),a.clip(),this.drawMeshPattern(e-t,A-t,t*2,t*2,.15),a.restore(),a.beginPath(),a.arc(s,r,o,0,2*Math.PI),a.stroke()):(a.beginPath(),a.arc(s,r,o,0,2*Math.PI),a.fill())}oval(e,A,t,i){const n=_f(this.transform,t),o=_f(this.transform,i),[s,r]=qi(this.transform,[e,A]);this.applyAperture();const a=this.getLayerCtx();a.beginPath(),a.ellipse(s,r,n,o,0,0,2*Math.PI),a.fill(),a.closePath()}pill(e,A,t,i){const[n,o]=qi(this.transform,[e-t/2,A+i/2]),s=_f(this.transform,t),r=_f(this.transform,i),a=Math.min(s,r)/2;this.applyAperture();const g=this.getLayerCtx();g.beginPath(),g.arc(n+a,o+a,a,Math.PI,Math.PI*1.5),g.arc(n+s-a,o+a,a,Math.PI*1.5,0),g.arc(n+s-a,o+r-a,a,0,Math.PI*.5),g.arc(n+a,o+r-a,a,Math.PI*.5,Math.PI),g.fill(),g.closePath()}polygon(e){if(e.length<3)return;this.applyAperture();const A=this.getLayerCtx(),t=e.map(n=>qi(this.transform,[n.x,n.y]));A.beginPath(),A.moveTo(t[0][0],t[0][1]);for(let n=1;n<t.length;n++)A.lineTo(t[n][0],t[n][1]);A.closePath(),A.fill("evenodd");const i=_f(this.transform,this.aperture.size);i>0&&(A.lineWidth=i,A.stroke())}debugText(e,A,t){const[i,n]=qi(this.transform,[A,t]);this.applyAperture();const o=this.getLayerCtx();o.font="10px sans-serif",o.fillText(e,i,n)}getLayerCtx(){const e=this.ctxLayerMap[this.aperture.layer];if(!e)throw new Error(`No context for layer "${this.aperture.layer}"`);return e}orderAndFadeLayers(){const{canvasLayerMap:e,foregroundLayer:A}=this,t=A==="top"?"top_silkscreen":A==="bottom"?"bottom_silkscreen":void 0,i=A==="top"?"top_notes":A==="bottom"?"bottom_notes":void 0,n=A==="top"?"top_fabrication":A==="bottom"?"bottom_fabrication":void 0,o=A==="top"?"soldermask_with_copper_top":A==="bottom"?"soldermask_with_copper_bottom":void 0,s=new Set([A,"drill","edge_cuts","other","board",...t?[t]:[],...i?[i]:[],...n?[n]:[],...o?[o]:[]]),r=[A,"edge_cuts",...t?[t]:[],...i?[i]:[],...n?[n]:[],...o?[o]:[]],a=[...eWe.filter(g=>!r.includes(g)),A,...o?[o]:[],"edge_cuts","drill",...t?[t]:[],...i?[i]:[],...n?[n]:[]];a.forEach((g,c)=>{const I=e[g];I&&(I.style.zIndex=`${fc.topLayer-(a.length-c)}`,I.style.opacity=s.has(g)?"1":"0.5")})}applyAperture(){const{transform:e,aperture:A}=this;let{size:t,mode:i,color:n,fontSize:o,layer:s}=A;s in this.ctxLayerMap||(this.aperture.layer="other");const r=this.getLayerCtx();if(!r)throw new Error(`No context for layer "${this.foregroundLayer}"`);if(n||(n="undefined"),r.lineWidth=_f(e,t),r.lineCap="round",i==="add"){r.globalCompositeOperation="source-over";let a=Y9[n.toLowerCase()];if(!a)try{a=Na(n).rgb().toString()}catch{console.warn(`Invalid color format: '${n}'`),a="white"}r.fillStyle=a,r.strokeStyle=a}else r.globalCompositeOperation="destination-out",r.fillStyle="rgba(0,0,0,1)",r.strokeStyle="rgba(0,0,0,1)";r.font=`${_f(kb(e),o)}px sans-serif`}moveTo(e,A){this.lastPoint={x:e,y:A}}lineTo(e,A){const[t,i]=qi(this.transform,[e,A]),{size:n,shape:o,mode:s}=this.aperture,r=_f(this.transform,n),{lastPoint:a}=this,g=qi(this.transform,a);this.applyAperture();const c=this.getLayerCtx();o==="square"&&c.fillRect(g.x-r/2,g.y-r/2,r,r),c.beginPath(),c.moveTo(g.x,g.y),c.lineTo(t,i),c.stroke(),c.closePath(),o==="square"&&c.fillRect(t-r/2,i-r/2,r,r),this.lastPoint={x:e,y:A}}polygonWithArcs(e){const A=this.getLayerCtx(),t=i=>{if(i.vertices.length===0)return;const n=i.vertices[0],o=qi(this.transform,[n.x,n.y]);A.moveTo(o[0],o[1]);for(let s=0;s<i.vertices.length;s++){const r=i.vertices[s],a=i.vertices[(s+1)%i.vertices.length];if(r.bulge&&r.bulge!==0){const g=r.bulge,c=a.x-r.x,I=a.y-r.y,l=Math.sqrt(c*c+I*I);if(l<1e-9){const M=qi(this.transform,[a.x,a.y]);A.lineTo(M[0],M[1]);continue}const B=4*Math.atan(g),C=Math.abs(l/(2*Math.sin(B/2))),Q=(r.x+a.x)/2,h=(r.y+a.y)/2,E=c/l,d=-(I/l),p=E,m=Math.sqrt(Math.max(0,C*C-(l/2)**2)),w=Q+m*d*Math.sign(g),D=h+m*p*Math.sign(g),S=Math.atan2(r.y-D,r.x-w);let k=Math.atan2(a.y-D,a.x-w);g>0&&k<S?k+=2*Math.PI:g<0&&k>S&&(k-=2*Math.PI);const x=qi(this.transform,[w,D]),N=_f(this.transform,C);A.arc(x[0],x[1],N,-S,-k,g>0)}else{const g=qi(this.transform,[a.x,a.y]);A.lineTo(g[0],g[1])}}A.closePath()};if(A.beginPath(),t(e.outer_ring),e.inner_rings)for(const i of e.inner_rings)t(i);A.fill("evenodd")}};function nWe(e){return e.type==="pcb_copper_pour"}function J9({canvas:e,elements:A,layers:t,realToCanvasMat:i}){const n=A.filter(nWe);if(n.length===0)return;const o=new KC(e);o.realToCanvasMat=i,o.drawElements(n,{layers:t})}var oWe={...Vd,silkscreen:{top:ln.board.f_fab,bottom:ln.board.b_fab}};function sWe(e){return e.type.includes("pcb_fabrication_note")}function vct({canvas:e,elements:A,layers:t,realToCanvasMat:i}){const n=new KC(e);n.configure({colorOverrides:oWe}),n.realToCanvasMat=i;const o=A.filter(sWe);n.drawElements(o,{layers:t})}function rWe(e){return e.type==="pcb_hole"}function aWe({canvas:e,elements:A,layers:t,realToCanvasMat:i,drawSoldermask:n}){const o=new KC(e);o.realToCanvasMat=i;const s=A.filter(rWe);o.drawElements(s,{layers:t,drawSoldermask:n})}function gWe(e){return e.type==="pcb_board"}function cWe({canvas:e,elements:A,layers:t,realToCanvasMat:i,drawSoldermask:n}){const o=new KC(e);o.realToCanvasMat=i;const s=A.filter(gWe);for(const r of s)o.drawElements([r],{layers:t,drawSoldermask:n,minBoardOutlineStrokePx:2})}function IWe(e){return e.type==="pcb_cutout"}function lWe({canvas:e,elements:A,layers:t,realToCanvasMat:i}){const n=new KC(e);n.realToCanvasMat=i;const o=A.filter(IWe);n.drawElements(o,{layers:t})}function BWe(e){return e.type==="pcb_keepout"}function CWe({canvas:e,elements:A,layers:t,realToCanvasMat:i}){const n=A.filter(BWe);if(n.length===0)return;const o=new KC(e);o.realToCanvasMat=i,o.drawElements(n,{layers:[]})}function QWe(e){return e.type.startsWith("pcb_note_")}function Lct({canvas:e,elements:A,layers:t,realToCanvasMat:i}){const n=new KC(e);n.realToCanvasMat=i;const o=A.filter(QWe);n.drawElements(o,{layers:t})}function hWe(e){return e.type==="pcb_panel"}function EWe({canvas:e,elements:A,layers:t,realToCanvasMat:i,drawSoldermask:n}){const o=new KC(e);o.realToCanvasMat=i;const s=A.filter(hWe);for(const r of s)o.drawElements([r],{layers:t,drawSoldermask:n})}var uWe={...Vd,copper:{...Vd.copper,top:Na(ln.board.pad_front).lighten(.5).toString(),bottom:Na(ln.board.pad_back).lighten(.5).toString(),inner1:Na(ln.board.copper.in1).lighten(.5).toString(),inner2:Na(ln.board.copper.in2).lighten(.5).toString(),inner3:Na(ln.board.copper.in3).lighten(.5).toString(),inner4:Na(ln.board.copper.in4).lighten(.5).toString(),inner5:Na(ln.board.copper.in5).lighten(.5).toString(),inner6:Na(ln.board.copper.in6).lighten(.5).toString()}};function dWe(e){return e.type==="pcb_smtpad"}function pWe({canvas:e,elements:A,layers:t,realToCanvasMat:i,primitives:n,drawSoldermask:o}){const s=A.filter(dWe).filter(c=>{const I=c.layer;return t.some(l=>l==="top_copper"&&I==="top"||l==="bottom_copper"&&I==="bottom"||l==="inner1_copper"&&I==="inner1"||l==="inner2_copper"&&I==="inner2"||l==="inner3_copper"&&I==="inner3"||l==="inner4_copper"&&I==="inner4"||l==="inner5_copper"&&I==="inner5"||l==="inner6_copper"&&I==="inner6")});if(s.length===0)return;const r=new Set;if(n)for(const c of n)(c.is_mouse_over||c.is_in_highlighted_net)&&c._element?.type==="pcb_smtpad"&&r.add(c._element.pcb_smtpad_id);const a=s.filter(c=>r.has(c.pcb_smtpad_id)),g=s.filter(c=>!r.has(c.pcb_smtpad_id));if(g.length>0){const c=new KC(e);c.realToCanvasMat=i,c.drawElements(g,{layers:t,drawSoldermask:o})}if(a.length>0){const c=new KC(e);c.configure({colorOverrides:uWe}),c.realToCanvasMat=i,c.drawElements(a,{layers:t,drawSoldermask:o})}}var fWe={...Vd,copper:{...Vd.copper,top:Na(ln.board.pad_front).lighten(.5).toString(),bottom:Na(ln.board.pad_back).lighten(.5).toString(),inner1:Na(ln.board.copper.in1).lighten(.5).toString(),inner2:Na(ln.board.copper.in2).lighten(.5).toString(),inner3:Na(ln.board.copper.in3).lighten(.5).toString(),inner4:Na(ln.board.copper.in4).lighten(.5).toString(),inner5:Na(ln.board.copper.in5).lighten(.5).toString(),inner6:Na(ln.board.copper.in6).lighten(.5).toString()}};function yWe(e){return e.type==="pcb_trace"}var mWe=e=>e.map(A=>A.endsWith("_copper")?A.replace("_copper",""):A);function wWe({canvas:e,elements:A,layers:t,realToCanvasMat:i,primitives:n}){const o=new Set(mWe(t)),s=A.filter(yWe).filter(c=>c.route.some(I=>I.route_type==="wire"&&"layer"in I&&o.has(I.layer)));if(s.length===0)return;const r=new Set;if(n)for(const c of n)(c.is_mouse_over||c.is_in_highlighted_net)&&c._element?.type==="pcb_trace"&&r.add(c._element.pcb_trace_id);const a=s.filter(c=>r.has(c.pcb_trace_id)),g=s.filter(c=>!r.has(c.pcb_trace_id));if(g.length>0){const c=new KC(e);c.realToCanvasMat=i,c.drawElements(g,{layers:t})}if(a.length>0){const c=new KC(e);c.configure({colorOverrides:fWe}),c.realToCanvasMat=i,c.drawElements(a,{layers:t})}}var DWe={...Vd,copper:{...Vd.copper,top:Na(ln.board.pad_front).lighten(.5).toString(),bottom:Na(ln.board.pad_back).lighten(.5).toString()}};function SWe(e){return e.type==="pcb_plated_hole"}function Uct({canvas:e,elements:A,layers:t,realToCanvasMat:i,primitives:n,drawSoldermask:o}){const s=A.filter(SWe);if(s.length===0)return;const r=new Set;if(n)for(const c of n)(c.is_mouse_over||c.is_in_highlighted_net)&&c._element?.type==="pcb_plated_hole"&&r.add(c._element.pcb_plated_hole_id);const a=s.filter(c=>r.has(c.pcb_plated_hole_id)),g=s.filter(c=>!r.has(c.pcb_plated_hole_id));if(g.length>0){const c=new KC(e);c.realToCanvasMat=i,c.drawElements(g,{layers:t,drawSoldermask:o})}if(a.length>0){const c=new KC(e);c.configure({colorOverrides:DWe}),c.realToCanvasMat=i,c.drawElements(a,{layers:t,drawSoldermask:o})}}function Hct(e){const{lines:A,anchorPoint:t,ccwRotation:i}=e;if(!i)return A;const n=i*Math.PI/180,o=b3e(n),s=im(lB(t.x,t.y),o,lB(-t.x,-t.y));return qi(s,t),A.map(r=>({...r,x1:qi(s,{x:r.x1,y:r.y1}).x,y1:qi(s,{x:r.x1,y:r.y1}).y,x2:qi(s,{x:r.x2,y:r.y2}).x,y2:qi(s,{x:r.x2,y:r.y2}).y}))}var bWe=.6,Yct=.2,Jct=e=>{const A=e.size*.7,t=A*bWe,i=A*Yct,n=A*Yct,o=e.text.split(/\r?\n/),s=e.text.length>0&&A>0,r=s?o.length:0,a=s?o.map(I=>I.length===0?0:I.length*t+(I.length-1)*i):[],g=a.length>0?Math.max(...a):0,c=r>0?r*A+(r-1)*n:0;return{text_lines:o,line_count:r,line_widths:a,target_height:A,target_width_char:t,space_between_chars:i,space_between_lines:n,width:g,height:c}},Tct=e=>{const A=Jct(e);return{width:A.width,height:A.height,lineHeight:A.target_height,lineSpacing:A.space_between_lines,lineCount:A.line_count}},Kct=e=>{const{text_lines:A,line_count:t,line_widths:i,target_height:n,target_width_char:o,space_between_chars:s,space_between_lines:r,width:a}=Jct(e);if(n<=0||t===0)return[];const g=n/12,c=[];for(let I=0;I<t;I++){const l=-I*(n+r),B=i[I],C=(a-B)/2;let Q=e.x+C;for(let h=0;h<A[I].length;h++){const E=A[I][h],u=uD[E]??uD[E.toUpperCase()];if(!u){Q+=o+s;continue}for(const{x1:d,y1:p,x2:m,y2:w}of u)c.push({_pcb_drawing_object_id:nm("line"),pcb_drawing_type:"line",x1:Q+o*d,y1:e.y+l+n*p,x2:Q+o*m,y2:e.y+l+n*w,width:g,layer:e.layer,unit:e.unit,color:e.color});Q+=o+s}}return c};function OD(e){const t=e.color??Y9[e.layer];let i=Na(t);return e._element?.type==="pcb_copper_pour"&&(i=i.alpha(.7)),e.is_mouse_over||e.is_in_highlighted_net?i.lighten(.5).rgb().toString():i.rgb().toString()}var Pct=(e,A)=>{e.equip({size:A.zoomIndependent?A.width/e.transform.a:A.width,shape:A.squareCap?"square":"circle",color:OD(A),layer:A.layer}),e.moveTo(A.x1,A.y1),e.lineTo(A.x2,A.y2)},xWe=(e,A,t)=>{switch(t){case"top_left":return{x:0,y:-A};case"top_center":return{x:-e/2,y:-A};case"top_right":return{x:-e,y:-A};case"center_left":return{x:0,y:-A/2};case"center":return{x:-e/2,y:-A/2};case"center_right":return{x:-e,y:-A/2};case"bottom_left":return{x:0,y:0};case"bottom_center":return{x:-e/2,y:0};case"bottom_right":return{x:-e,y:0};default:return{x:0,y:0}}},qct=e=>e.layer==="bottom_silkscreen"||e.layer==="bottom"?e.is_mirrored!==!1:e.is_mirrored===!0,_We=(e,A)=>{e.equip({fontSize:A.size,color:OD(A),layer:A.layer});const{width:t,height:i}=Tct(A),n=xWe(t,i,A.align);A.x??=0,A.y??=0;const o={x:A.x,y:A.y};let s=Kct({...A,x:A.x+n.x,y:A.y+n.y});if(qct(A)&&(s=s.map(r=>({...r,x1:2*A.x-r.x1,x2:2*A.x-r.x2}))),A.ccw_rotation){const r={lines:s,anchorPoint:o,ccwRotation:A.ccw_rotation};s=Hct(r)}for(const r of s)Pct(e,r)},kWe=(e,A)=>{const{width:t,height:i,lineHeight:n}=Tct(A);A.x??=0,A.y??=0;const o=A.knockout_padding??{left:A.size*.5,right:A.size*.5,top:A.size*.3,bottom:A.size*.3},s=t+o.left+o.right,r=i+o.top+o.bottom,a=t/2,g=n-i/2,c=A.x-a,I=A.y-g,l={x:A.x,y:A.y},B={_pcb_drawing_object_id:`knockout_rect_${A._pcb_drawing_object_id}`,x:A.x,y:A.y,w:s,h:r,layer:A.layer,ccw_rotation:A.ccw_rotation};A.ccw_rotation?Wct(e,B):Oct(e,B);let C=Kct({...A,x:c,y:I});if(qct(A)&&(C=C.map(Q=>({...Q,x1:2*A.x-Q.x1,x2:2*A.x-Q.x2}))),A.ccw_rotation){const Q={lines:C,anchorPoint:l,ccwRotation:A.ccw_rotation};C=Hct(Q)}for(const Q of C)e.equip({size:Q.width,shape:"circle",color:"black",layer:A.layer,mode:"subtract"}),e.moveTo(Q.x1,Q.y1),e.lineTo(Q.x2,Q.y2);e.equip({mode:"add"})},Oct=(e,A)=>{e.equip({color:OD(A),layer:A.layer,size:A.stroke_width}),e.rect({x:A.x,y:A.y,w:A.w,h:A.h,mesh_fill:A.mesh_fill,is_filled:A.is_filled,has_stroke:A.has_stroke,is_stroke_dashed:A.is_stroke_dashed,stroke_width:A.stroke_width,roundness:A.roundness})},Wct=(e,A)=>{e.equip({color:OD(A),layer:A.layer}),e.rotatedRect(A.x,A.y,A.w,A.h,A.ccw_rotation,A.roundness,A.mesh_fill)},FWe=(e,A)=>{e.equip({color:OD(A),layer:A.layer}),e.rotatedPill(A.x,A.y,A.w,A.h,A.ccw_rotation)},GWe=(e,A)=>{e.equip({color:OD(A),layer:A.layer}),e.circle(A.x,A.y,A.r,A.mesh_fill)},RWe=(e,A)=>{e.equip({color:OD(A),layer:A.layer}),e.oval(A.x,A.y,A.rX,A.rY)},MWe=(e,A)=>{e.equip({color:OD(A),layer:A.layer}),e.pill(A.x,A.y,A.w,A.h)},NWe=(e,A)=>{e.equip({color:OD(A),layer:A.layer}),e.polygon(A.points)},vWe=(e,A)=>{e.equip({color:OD(A),layer:A.layer}),e.polygonWithArcs(A.brep_shape)},LWe=(e,A)=>{switch(A.pcb_drawing_type){case"line":return Pct(e,A);case"text":return A.is_knockout?kWe(e,A):_We(e,A);case"rect":return A.ccw_rotation?Wct(e,A):Oct(e,A);case"circle":return GWe(e,A);case"oval":return RWe(e,A);case"pill":return A.ccw_rotation?FWe(e,A):MWe(e,A);case"polygon":return NWe(e,A);case"polygon_with_arcs":return vWe(e,A)}},UWe=(e,A)=>{for(const t of A)LWe(e,t)},HWe={...Vd,copper:{...Vd.copper,top:Na(ln.board.pad_front).lighten(.5).toString(),bottom:Na(ln.board.pad_back).lighten(.5).toString(),inner1:Na(ln.board.copper.in1).lighten(.5).toString(),inner2:Na(ln.board.copper.in2).lighten(.5).toString(),inner3:Na(ln.board.copper.in3).lighten(.5).toString(),inner4:Na(ln.board.copper.in4).lighten(.5).toString(),inner5:Na(ln.board.copper.in5).lighten(.5).toString(),inner6:Na(ln.board.copper.in6).lighten(.5).toString()},soldermask:{...Vd.soldermask,top:Na(ln.board.soldermask.top).lighten(.35).toString(),bottom:Na(ln.board.soldermask.bottom).lighten(.35).toString()}};function T9({canvas:e,elements:A,layers:t,realToCanvasMat:i,primitives:n}){const o=new KC(e);if(o.realToCanvasMat=i,o.drawElements(A,{layers:t,drawSoldermask:!0}),!n)return;const s=new Set;for(const g of n){if(!(g.is_mouse_over||g.is_in_highlighted_net))continue;const c=g._element;c?.type==="pcb_smtpad"?s.add(c.pcb_smtpad_id):c?.type==="pcb_plated_hole"?s.add(c.pcb_plated_hole_id):c?.type==="pcb_via"&&s.add(c.pcb_via_id)}if(s.size===0)return;const r=A.filter(g=>g.type==="pcb_smtpad"?s.has(g.pcb_smtpad_id):g.type==="pcb_plated_hole"?s.has(g.pcb_plated_hole_id):g.type==="pcb_via"?s.has(g.pcb_via_id):!1);if(r.length===0)return;const a=new KC(e);a.configure({colorOverrides:HWe}),a.realToCanvasMat=i,a.drawElements(r,{layers:t,drawSoldermask:!0})}var YWe={...Vd,silkscreen:{top:ln.board.f_silks,bottom:ln.board.b_silks}};function JWe(e){return e.type.includes("pcb_silkscreen")}function Zct({canvas:e,elements:A,layers:t,realToCanvasMat:i}){const n=new KC(e);n.configure({colorOverrides:YWe}),n.realToCanvasMat=i;const o=A.filter(JWe);n.drawElements(o,{layers:t})}var TWe={...Vd,copper:{...Vd.copper,top:Na(ln.board.pad_front).lighten(.5).toString(),bottom:Na(ln.board.pad_back).lighten(.5).toString()}};function KWe(e){return e.type==="pcb_via"}function Vct({canvas:e,elements:A,layers:t,realToCanvasMat:i,primitives:n,drawSoldermask:o}){const s=A.filter(KWe).filter(c=>t.some(I=>I.includes("copper")));if(s.length===0)return;const r=new Set;if(n)for(const c of n)(c.is_mouse_over||c.is_in_highlighted_net)&&c._element?.type==="pcb_via"&&r.add(c._element.pcb_via_id);const a=s.filter(c=>r.has(c.pcb_via_id)),g=s.filter(c=>!r.has(c.pcb_via_id));if(g.length>0){const c=new KC(e);c.realToCanvasMat=i,c.drawElements(g,{layers:t,drawSoldermask:o})}if(a.length>0){const c=new KC(e);c.configure({colorOverrides:TWe}),c.realToCanvasMat=i,c.drawElements(a,{layers:t,drawSoldermask:o})}}var PWe={...Vd,courtyard:{top:ln.board.f_crtyd,bottom:ln.board.b_crtyd}};function qWe(e){return e.type==="pcb_courtyard_circle"||e.type==="pcb_courtyard_rect"}function jct({canvas:e,elements:A,layers:t,realToCanvasMat:i}){const n=new KC(e);n.configure({colorOverrides:PWe}),n.realToCanvasMat=i;const o=A.filter(qWe);n.drawElements(o,{layers:t})}var OWe=["board","bottom","soldermask_bottom","bottom_silkscreen","top","soldermask_top","soldermask_with_copper_bottom","soldermask_with_copper_top","top_fabrication","bottom_fabrication","inner1","inner2","inner3","inner4","inner5","inner6","drill","edge_cuts","bottom_notes","top_notes","top_silkscreen","bottom_silkscreen","top_courtyard","bottom_courtyard","other"],WWe=({primitives:e,elements:A,transform:t,grid:i,width:n=500,height:o=500})=>{const s=V.useRef({}),r=eC(g=>g.selected_layer),a=eC(g=>g.is_showing_solder_mask);return V.useEffect(()=>{if(!s.current||Object.keys(s.current).length===0)return;const g=Object.fromEntries(Object.entries(s.current).filter(([l,B])=>!(!B||!a&&l.includes("soldermask"))));if(Object.keys(g).length===0)return;const c=new iWe(g);t&&(c.transform=t),c.clear(),c.foregroundLayer=r;const I=e.filter(l=>a||!l.layer?.includes("soldermask")).filter(l=>l.layer!=="board").filter(l=>l._element?.type!=="pcb_smtpad").filter(l=>l._element?.type!=="pcb_plated_hole").filter(l=>l._element?.type!=="pcb_via").filter(l=>l._element?.type!=="pcb_trace");if(UWe(c,I),t){const l=s.current.top,B=s.current.bottom,C=s.current.inner1,Q=s.current.inner2,h=s.current.inner3,E=s.current.inner4,u=s.current.inner5,d=s.current.inner6,p=[{canvas:l,copperLayer:"top_copper"},{canvas:B,copperLayer:"bottom_copper"},{canvas:C,copperLayer:"inner1_copper"},{canvas:Q,copperLayer:"inner2_copper"},{canvas:h,copperLayer:"inner3_copper"},{canvas:E,copperLayer:"inner4_copper"},{canvas:u,copperLayer:"inner5_copper"},{canvas:d,copperLayer:"inner6_copper"}];for(const{canvas:Z,copperLayer:$}of p)Z&&wWe({canvas:Z,elements:A,layers:[$],realToCanvasMat:t,primitives:e});l&&Uct({canvas:l,elements:A,layers:["top_copper"],realToCanvasMat:t,primitives:e,drawSoldermask:a}),B&&Uct({canvas:B,elements:A,layers:["bottom_copper"],realToCanvasMat:t,primitives:e,drawSoldermask:a}),l&&J9({canvas:l,elements:A,layers:["top_copper"],realToCanvasMat:t}),B&&J9({canvas:B,elements:A,layers:["bottom_copper"],realToCanvasMat:t});for(const{canvas:Z,copperLayer:$}of p)Z&&(pWe({canvas:Z,elements:A,layers:[$],realToCanvasMat:t,primitives:e,drawSoldermask:a}),a&&T9({canvas:Z,elements:A,layers:[$],realToCanvasMat:t,primitives:e}));if(l&&Vct({canvas:l,elements:A,layers:["top_copper"],realToCanvasMat:t,primitives:e,drawSoldermask:a}),B&&Vct({canvas:B,elements:A,layers:["bottom_copper"],realToCanvasMat:t,primitives:e,drawSoldermask:a}),a){const Z=s.current.soldermask_top;Z&&T9({canvas:Z,elements:A,layers:["top_soldermask"],realToCanvasMat:t,primitives:e});const $=s.current.soldermask_bottom;$&&T9({canvas:$,elements:A,layers:["bottom_soldermask"],realToCanvasMat:t,primitives:e})}l&&J9({canvas:l,elements:A,layers:["top_copper"],realToCanvasMat:t}),B&&J9({canvas:B,elements:A,layers:["bottom_copper"],realToCanvasMat:t});const m=s.current.drill;m&&(aWe({canvas:m,elements:A,layers:["drill"],realToCanvasMat:t}),a&&T9({canvas:m,elements:A,layers:["drill"],realToCanvasMat:t,primitives:e}));const w=s.current.top_silkscreen;w&&Zct({canvas:w,elements:A,layers:["top_silkscreen"],realToCanvasMat:t});const D=s.current.bottom_silkscreen;D&&Zct({canvas:D,elements:A,layers:["bottom_silkscreen"],realToCanvasMat:t});const S=s.current.top_fabrication;S&&vct({canvas:S,elements:A,layers:["top_fabrication_note"],realToCanvasMat:t});const k=s.current.bottom_fabrication;k&&vct({canvas:k,elements:A,layers:["bottom_fabrication_note"],realToCanvasMat:t});const x=s.current.bottom_notes;x&&Lct({canvas:x,elements:A,layers:["bottom_user_note"],realToCanvasMat:t});const N=s.current.top_notes;N&&Lct({canvas:N,elements:A,layers:["top_user_note"],realToCanvasMat:t});const M=s.current.top_courtyard;M&&jct({canvas:M,elements:A,layers:["top_courtyard"],realToCanvasMat:t});const L=s.current.bottom_courtyard;L&&jct({canvas:L,elements:A,layers:["bottom_courtyard"],realToCanvasMat:t});const Y=s.current.board;Y&&(EWe({canvas:Y,elements:A,layers:[],realToCanvasMat:t,drawSoldermask:a}),cWe({canvas:Y,elements:A,layers:[],realToCanvasMat:t,drawSoldermask:a}));const H=s.current.edge_cuts;H&&lWe({canvas:H,elements:A,layers:["edge_cuts"],realToCanvasMat:t});const O=[{canvas:l,layer:"top"},{canvas:B,layer:"bottom"}];for(const{canvas:Z,layer:$}of O)Z&&CWe({canvas:Z,elements:A,layers:[$],realToCanvasMat:t})}c.orderAndFadeLayers()},[e,A,t,r,a]),W.jsxs("div",{style:{backgroundColor:"black",width:n,height:o,position:"relative"},children:[W.jsx(w9.SuperGrid,{textColor:"rgba(0,255,0,0.8)",majorColor:"rgba(0,255,0,0.4)",minorColor:"rgba(0,255,0,0.2)",screenSpaceCellSize:200,width:n,height:o,transform:t,stringifyCoord:(g,c,I)=>`${w9.toMMSI(g,I)}, ${w9.toMMSI(c,I)}`}),OWe.filter(g=>a?!0:!g.includes("soldermask")).map(g=>g.replace(/-/g,"")).map((g,c)=>W.jsx("canvas",{className:`pcb-layer-${g}`,ref:I=>{s.current??={},I?s.current[g]=I:delete s.current[g]},style:{position:"absolute",zIndex:c,left:0,top:0,pointerEvents:"none"},width:n,height:o},g))]})},ZWe=.6,VWe=1;dct(g8e()),dct(D8e());var K9=["rgba(239, 68, 68, 0.8)","rgba(249, 115, 22, 0.8)","rgba(245, 158, 11, 0.8)","rgba(234, 179, 8, 0.8)","rgba(132, 204, 22, 0.8)","rgba(34, 197, 94, 0.8)","rgba(16, 185, 129, 0.8)","rgba(20, 184, 166, 0.8)","rgba(6, 182, 212, 0.8)","rgba(14, 165, 233, 0.8)","rgba(59, 130, 246, 0.8)","rgba(99, 102, 241, 0.8)","rgba(139, 92, 246, 0.8)","rgba(168, 85, 247, 0.8)","rgba(217, 70, 239, 0.8)","rgba(236, 72, 153, 0.8)","rgba(249, 168, 212, 0.8)","rgba(161, 161, 170, 0.8)"];function zct(e,A,t,i={}){const n=i.padding??40,o=i.yFlip??!1;let s;if("center"in e){const c=e.width/2,I=e.height/2;s={minX:e.center.x-c,maxX:e.center.x+c,minY:e.center.y-I,maxY:e.center.y+I}}else s=e;const r=s.maxX-s.minX||1,a=s.maxY-s.minY||1,g=Math.min((A-2*n)/r,(t-2*n)/a);return im(lB(A/2,t/2),gJ(g,o?-g:g),lB(-(s.minX+r/2),-(s.minY+a/2)))}function jWe(e){const A=[...e.points||[],...(e.lines||[]).flatMap(t=>t.points),...(e.rects||[]).flatMap(t=>{const i=t.width/2,n=t.height/2;return[{x:t.center.x-i,y:t.center.y-n},{x:t.center.x+i,y:t.center.y-n},{x:t.center.x-i,y:t.center.y+n},{x:t.center.x+i,y:t.center.y+n}]}),...(e.circles||[]).flatMap(t=>[{x:t.center.x-t.radius,y:t.center.y},{x:t.center.x+t.radius,y:t.center.y},{x:t.center.x,y:t.center.y-t.radius},{x:t.center.x,y:t.center.y+t.radius}]),...(e.texts||[]).flatMap(t=>{const i=t.fontSize??12,n=t.text.length*i*ZWe,o=i*VWe,s=t.anchorSide??"center",r={top_left:{dx:0,dy:0},top_center:{dx:-n/2,dy:0},top_right:{dx:-n,dy:0},center_left:{dx:0,dy:-o/2},center:{dx:-n/2,dy:-o/2},center_right:{dx:-n,dy:-o/2},bottom_left:{dx:0,dy:-o},bottom_center:{dx:-n/2,dy:-o},bottom_right:{dx:-n,dy:-o}},{dx:a,dy:g}=r[s],c=t.x+a,I=t.y+g;return[{x:c,y:I},{x:c+n,y:I+o}]})];return A.length===0?{minX:-1,maxX:1,minY:-1,maxY:1}:A.reduce((t,i)=>({minX:Math.min(t.minX,i.x),maxX:Math.max(t.maxX,i.x),minY:Math.min(t.minY,i.y),maxY:Math.max(t.maxY,i.y)}),{minX:1/0,maxX:-1/0,minY:1/0,maxY:-1/0})}function zWe(e,A,t={}){const i=A instanceof HTMLCanvasElement?A.getContext("2d"):A;if(!i)throw new Error("Could not get 2D context from canvas");const n=A instanceof HTMLCanvasElement?A.width:A.canvas.width,o=A instanceof HTMLCanvasElement?A.height:A.canvas.height;let s;if(t.transform)s=t.transform;else if(t.viewbox)s=zct(t.viewbox,n,o,{padding:t.padding,yFlip:t.yFlip});else{const r=jWe(e),a=e.coordinateSystem==="cartesian";s=zct(r,n,o,{padding:t.padding??40,yFlip:a})}i.clearRect(0,0,n,o),i.save(),e.rects&&e.rects.length>0&&e.rects.forEach(r=>{const a=r.width/2,g=r.height/2,c=qi(s,{x:r.center.x-a,y:r.center.y-g}),I=qi(s,{x:r.center.x+a,y:r.center.y+g}),l=Math.abs(I.x-c.x),B=Math.abs(I.y-c.y);i.beginPath(),i.rect(Math.min(c.x,I.x),Math.min(c.y,I.y),l,B),r.fill&&(i.fillStyle=r.fill,i.fill()),r.stroke&&(i.strokeStyle=r.stroke,i.stroke())}),e.circles&&e.circles.length>0&&e.circles.forEach(r=>{const a=qi(s,r.center),g=r.radius*Math.abs(s.a);i.beginPath(),i.arc(a.x,a.y,g,0,2*Math.PI),r.fill&&(i.fillStyle=r.fill,i.fill()),r.stroke&&(i.strokeStyle=r.stroke??"transparent",i.stroke())}),e.lines&&e.lines.length>0&&e.lines.forEach((r,a)=>{if(r.points.length===0)return;i.beginPath();const g=qi(s,r.points[0]);i.moveTo(g.x,g.y);for(let c=1;c<r.points.length;c++){const I=qi(s,r.points[c]);i.lineTo(I.x,I.y)}if(i.strokeStyle=r.strokeColor||K9[a%K9.length],r.strokeWidth?i.lineWidth=r.strokeWidth*s.a:i.lineWidth=2,i.lineCap="round",r.strokeDash)if(typeof r.strokeDash=="string"){let c;if(r.strokeDash.includes(","))c=r.strokeDash.split(",").map(I=>parseFloat(I.trim())).filter(I=>!Number.isNaN(I));else{const I=parseFloat(r.strokeDash.trim());c=Number.isNaN(I)?[]:[I]}i.setLineDash(c)}else i.setLineDash(r.strokeDash.map(c=>c*Math.abs(s.a)));else i.setLineDash([]);i.stroke()}),e.points&&e.points.length>0&&e.points.forEach((r,a)=>{const g=qi(s,r);i.beginPath(),i.arc(g.x,g.y,3,0,2*Math.PI),i.fillStyle=r.color||K9[a%K9.length],i.fill(),r.label&&!t.disableLabels&&(i.fillStyle=r.color||"black",i.font="12px sans-serif",i.fillText(r.label,g.x+5,g.y-5))}),e.texts&&e.texts.length>0&&e.texts.forEach(r=>{const a=qi(s,{x:r.x,y:r.y});i.fillStyle=r.color||"black",i.font=`${(r.fontSize??12)*Math.abs(s.a)}px sans-serif`;const g=r.anchorSide??"center",c={top_left:"left",center_left:"left",bottom_left:"left",top_center:"center",center:"center",bottom_center:"center",top_right:"right",center_right:"right",bottom_right:"right"},I={top_left:"top",top_center:"top",top_right:"top",center_left:"middle",center:"middle",center_right:"middle",bottom_left:"bottom",bottom_center:"bottom",bottom_right:"bottom"};i.textAlign=c[g],i.textBaseline=I[g],i.fillText(r.text,a.x,a.y)}),i.restore()}var XWe=({children:e,transform:A,debugGraphics:t})=>{const i=V.useRef(null),[n,{width:o,height:s}]=yJ(),r=eC(a=>a.is_showing_autorouting);return V.useEffect(()=>{r&&i.current&&t&&o&&s&&(i.current.width=o,i.current.height=s,zWe(t,i.current,{transform:A,disableLabels:!0}))},[t,A,o,s,r]),r?W.jsxs("div",{ref:n,style:{position:"relative",width:"100%",height:"100%"},children:[e,W.jsx("canvas",{ref:i,style:{position:"absolute",top:0,left:0,opacity:.5,zIndex:100,width:"100%",height:"100%",pointerEvents:"none"}})]}):e},$We=({children:e,transform:A=_b(),elements:t=[]})=>{const[i,{width:n,height:o}]=yJ(),s=V.useRef(null);return V.useEffect(()=>{const r=s.current;if(!r||!n||!o)return;r.width=n,r.height=o;const a=r.getContext("2d");if(!a)return;a.clearRect(0,0,n,o);const g=t.filter(I=>I.type==="pcb_component"),c=t.filter(I=>I.type==="pcb_manual_edit_conflict_warning");a.strokeStyle=ln.board.drc_warning,a.lineWidth=2,c.forEach(I=>{const l=g.find(O=>O.pcb_component_id===I.pcb_component_id);if(!l)return;const{width:B,height:C,center:Q}=l,h=qi(A,Q),E=B*Math.abs(A.a),u=C*Math.abs(A.d),d=.1*Math.abs(A.a),p=E+d*2,m=u+d*2,w=h.x-p/2,D=h.y-m/2;a.beginPath(),a.rect(w,D,p,m),a.stroke();const S="Manual Edit Conflict",k=4,x=Math.max(8,Math.min(12,10*Math.abs(A.a)));a.font=`${x}px sans-serif`;const M=a.measureText(S).width+k*2,L=x+k*2,Y=w+(p-M)/2,H=D+m+5;a.fillStyle="rgba(0, 0, 0, 0.7)",a.beginPath(),a.roundRect(Y,H,M,L,3),a.fill(),a.fillStyle=ln.board.drc_warning,a.textAlign="center",a.textBaseline="middle",a.fillText(S,Y+M/2,H+L/2)})},[t,A,n,o]),W.jsxs("div",{ref:i,style:{position:"relative",width:"100%",height:"100%"},children:[e,W.jsx("canvas",{ref:s,style:{position:"absolute",top:0,left:0,pointerEvents:"none",zIndex:fc.warnings}})]})},P9=(e,A,t)=>t(e,A),Xct=(e,A,t,i,n)=>{const o=n*Math.PI/180,s=Math.cos(o),r=Math.sin(o),a=e-t,g=A-i,c=a*s-g*r,I=a*r+g*s;return{x:c+t,y:I+i}},mJ=e=>{if(e.length===0)return null;let A=e[0].x,t=e[0].x,i=e[0].y,n=e[0].y;for(const o of e)A=P9(A,o.x,Math.min),t=P9(t,o.x,Math.max),i=P9(i,o.y,Math.min),n=P9(n,o.y,Math.max);return{minX:A,maxX:t,minY:i,maxY:n}},AZe=(e,A)=>({minX:Math.min(e.minX,A.minX),maxX:Math.max(e.maxX,A.maxX),minY:Math.min(e.minY,A.minY),maxY:Math.max(e.maxY,A.maxY)}),tZe=(e,A)=>e?AZe(e,A):A,eZe=e=>{switch(e.pcb_drawing_type){case"line":{const A=(e.width??0)/2,t=[{x:e.x1,y:e.y1},{x:e.x2,y:e.y2}],i=mJ(t);return i?{minX:i.minX-A,maxX:i.maxX+A,minY:i.minY-A,maxY:i.maxY+A}:null}case"rect":{const A=e.w/2,t=e.h/2,i=[{x:e.x-A,y:e.y-t},{x:e.x+A,y:e.y-t},{x:e.x+A,y:e.y+t},{x:e.x-A,y:e.y+t}],n=e.ccw_rotation??0,o=n===0?i:i.map(s=>Xct(s.x,s.y,e.x,e.y,n));return mJ(o)}case"circle":return{minX:e.x-e.r,maxX:e.x+e.r,minY:e.y-e.r,maxY:e.y+e.r};case"oval":return{minX:e.x-e.rX,maxX:e.x+e.rX,minY:e.y-e.rY,maxY:e.y+e.rY};case"pill":{const A=e.w/2,t=e.h/2,i=[{x:e.x-A,y:e.y-t},{x:e.x+A,y:e.y-t},{x:e.x+A,y:e.y+t},{x:e.x-A,y:e.y+t}],n=e.ccw_rotation??0,o=n===0?i:i.map(s=>Xct(s.x,s.y,e.x,e.y,n));return mJ(o)}case"polygon":return mJ(e.points);case"polygon_with_arcs":{const A=e.brep_shape.outer_ring.vertices.map(t=>({x:t.x,y:t.y}));return mJ(A)}case"text":{const A=e.size??0,t=e.text?e.text.length*A*.6:0,i=A;if(t===0&&i===0)return{minX:e.x,maxX:e.x,minY:e.y,maxY:e.y};const n=t/2,o=i/2;return{minX:e.x-n,maxX:e.x+n,minY:e.y-o,maxY:e.y+o}}default:return null}};function iZe(e){const{dimensionStart:A,dimensionEnd:t,screenDimensionStart:i,screenDimensionEnd:n,flipX:o,flipY:s}=e,r=t.x-A.x,a=t.y-A.y,g=Math.sqrt(r*r+a*a),c=n.x-i.x,I=n.y-i.y,l=Math.sqrt(c*c+I*I),B=Math.atan2(I,c)*(180/Math.PI),C=Math.abs(B)%90,h=Math.min(C,90-C)>15,E=(i.x+n.x)/2,u=(i.y+n.y)/2,d=15,p=B+90;let m=Math.cos(p*Math.PI/180)*d,w=Math.sin(p*Math.PI/180)*d;const D=c>0&&I<0,S=c>0&&I>0,k=c<0&&I>0;o!==s&&!D&&(m=-m,w=-w),D&&(m+=Math.cos(p*Math.PI/180)*-45,w+=Math.sin(p*Math.PI/180)*-45),S&&(m+=Math.cos(p*Math.PI/180)+-20,w+=Math.sin(p*Math.PI/180)+-10),k&&(m+=Math.cos(p*Math.PI/180)*10,w+=Math.sin(p*Math.PI/180)*10);const x=E+m,N=u+w;return{distance:g,screenDistance:l,x,y:N,show:g>.01&&l>30&&h}}function nZe(e){const{dimensionStart:A,dimensionEnd:t,screenDimensionStart:i,screenDimensionEnd:n,flipX:o,flipY:s}=e;return V.useMemo(()=>iZe({dimensionStart:A,dimensionEnd:t,screenDimensionStart:i,screenDimensionEnd:n,flipX:o,flipY:s}),[A,t,i,n,o,s])}var oZe=(e,A,t)=>{const i=t*Math.PI/180,n=Math.cos(i),o=Math.sin(i),s=e.x-A.x,r=e.y-A.y,a=s*n-r*o,g=s*o+r*n;return{x:a+A.x,y:g+A.y}},$ct=(e,A,t,i)=>{const n={top_left:{x:e.x-A,y:e.y-t},top_center:{x:e.x,y:e.y-t},top_right:{x:e.x+A,y:e.y-t},center_left:{x:e.x-A,y:e.y},center:{x:e.x,y:e.y},center_right:{x:e.x+A,y:e.y},bottom_left:{x:e.x-A,y:e.y+t},bottom_center:{x:e.x,y:e.y+t},bottom_right:{x:e.x+A,y:e.y+t}};return i===0?Object.entries(n).map(([o,s])=>({anchor:o,point:s})):Object.entries(n).map(([o,s])=>({anchor:o,point:oZe(s,e,i)}))},sZe=e=>{switch(e.pcb_drawing_type){case"rect":{const A=e.ccw_rotation??0;return $ct({x:e.x,y:e.y},e.w/2,e.h/2,A)}case"pill":{const A=e.ccw_rotation??0;return $ct({x:e.x,y:e.y},e.w/2,e.h/2,A)}case"circle":return[{anchor:"circle_center",point:{x:e.x,y:e.y}},{anchor:"circle_right",point:{x:e.x+e.r,y:e.y}},{anchor:"circle_left",point:{x:e.x-e.r,y:e.y}},{anchor:"circle_top",point:{x:e.x,y:e.y-e.r}},{anchor:"circle_bottom",point:{x:e.x,y:e.y+e.r}}];case"oval":return[{anchor:"oval_center",point:{x:e.x,y:e.y}},{anchor:"oval_right",point:{x:e.x+e.rX,y:e.y}},{anchor:"oval_left",point:{x:e.x-e.rX,y:e.y}},{anchor:"oval_top",point:{x:e.x,y:e.y-e.rY}},{anchor:"oval_bottom",point:{x:e.x,y:e.y+e.rY}}];case"line":{const A={x:(e.x1+e.x2)/2,y:(e.y1+e.y2)/2};return[{anchor:"line_start",point:{x:e.x1,y:e.y1}},{anchor:"line_mid",point:A},{anchor:"line_end",point:{x:e.x2,y:e.y2}}]}case"polygon":return e.points.map((A,t)=>({anchor:`polygon_vertex_${t}`,point:A}));case"polygon_with_arcs":return e.brep_shape.outer_ring.vertices.map((A,t)=>({anchor:`polygon_with_arcs_vertex_${t}`,point:{x:A.x,y:A.y}}));default:return[]}},rZe=16,GG=5,AIt=e=>{if(e.pcb_drawing_type==="text")return!0;const A=e._element;if(!A||typeof A!="object")return!1;const t=typeof A.type=="string"?A.type:void 0;return t?!!(t.startsWith("pcb_silkscreen_")||t.startsWith("pcb_note_")||t==="pcb_text"||t.startsWith("pcb_fabrication_note_")&&t!=="pcb_fabrication_note_rect"):!1},aZe=({children:e,transform:A,focusOnHover:t=!1,primitives:i=[]})=>{A||(A=_b());const[n,o]=V.useState(!1),[s,r]=V.useState(!1),[a,g]=V.useState(!1),[c,I]=V.useState({start:null,end:null}),l=eC(H=>H.is_mouse_over_container),B=V.useCallback(()=>{a&&(g(!1),window.dispatchEvent(new Event("disarm-dimension-tool")))},[a]),[C,Q]=V.useState({x:0,y:0}),[h,E]=V.useState({x:0,y:0}),u=V.useRef({x:0,y:0}),d=V.useRef(null),m=d.current?.getBoundingClientRect(),w=V.useMemo(()=>{const H=new Map;for(const O of i){if(!O._element||AIt(O)||O.pcb_drawing_type==="pill"||O.pcb_drawing_type==="rect"&&O.ccw_rotation&&O.ccw_rotation!==0)continue;const Z=eZe(O);if(!Z)continue;const $=H.get(O._element);H.set(O._element,tZe($??void 0,Z))}return H},[i]),D=V.useMemo(()=>{const H=[];for(const O of i){if(!O._element||AIt(O))continue;const Z=sZe(O);if(Z.length!==0)for(const $ of Z)H.push({anchor:$.anchor,point:$.point,element:O._element})}return H},[i]),S=V.useMemo(()=>{const H=[];w.forEach((O,Z)=>{if(!O)return;const $=(O.minX+O.maxX)/2,eA=(O.minY+O.maxY)/2,aA={top_left:{x:O.minX,y:O.minY},top_center:{x:$,y:O.minY},top_right:{x:O.maxX,y:O.minY},center_left:{x:O.minX,y:eA},center:{x:$,y:eA},center_right:{x:O.maxX,y:eA},bottom_left:{x:O.minX,y:O.maxY},bottom_center:{x:$,y:O.maxY},bottom_right:{x:O.maxX,y:O.maxY}};for(const[tA,nA]of Object.entries(aA))H.push({anchor:tA,point:nA,element:Z})});for(const O of D)H.push(O);return H.push({anchor:"origin",point:{x:0,y:0},element:null}),H},[w,D]),k=V.useMemo(()=>S.map((H,O)=>({...H,id:`${O}-${H.anchor}`,screenPoint:qi(A,H.point)})),[S,A]),x=V.useCallback(H=>{if(k.length===0)return{point:H,id:null};const O=qi(A,H);let Z=null;for(const $ of k){const eA=$.screenPoint.x-O.x,aA=$.screenPoint.y-O.y,tA=Math.hypot(eA,aA);tA>rZe||(!Z||tA<Z.distance)&&(Z={distance:tA,id:$.id,point:$.point})}return Z?{point:Z.point,id:Z.id}:{point:H,id:null}},[k,A]);V.useEffect(()=>{const H=Z=>{const $=Z.target;if($.tagName==="INPUT"||$.tagName==="TEXTAREA"||$.isContentEditable)return;const eA=d.current?.contains(document.activeElement)||document.activeElement===d.current;if(!(!l&&!eA)){if(Z.key==="d"){const aA=x({x:u.current.x,y:u.current.y});Q({x:aA.point.x,y:aA.point.y}),E({x:aA.point.x,y:aA.point.y}),I({start:aA.id,end:aA.id}),n?(o(!1),r(!1),I({start:null,end:null})):(o(!0),r(!0)),B()}Z.key==="Escape"&&(o(!1),r(!1),I({start:null,end:null}),B())}},O=()=>{g(!0)};return window.addEventListener("keydown",H),window.addEventListener("arm-dimension-tool",O),()=>{window.removeEventListener("keydown",H),window.removeEventListener("arm-dimension-tool",O),B()}},[l,n,B,x]);const N=qi(A,C),M=qi(A,h),L={left:Math.min(N.x,M.x),right:Math.max(N.x,M.x),top:Math.min(N.y,M.y),bottom:Math.max(N.y,M.y),flipX:N.x>M.x,flipY:N.y>M.y,width:0,height:0};L.width=L.right-L.left,L.height=L.bottom-L.top;const Y=nZe({dimensionStart:C,dimensionEnd:h,screenDimensionStart:N,screenDimensionEnd:M,flipX:L.flipX,flipY:L.flipY});return W.jsxs("div",{ref:d,"data-pcb-viewer":!0,tabIndex:0,style:{position:"relative",outline:"none"},onMouseEnter:()=>{t&&d.current&&d.current.focus()},onMouseLeave:()=>{d.current&&d.current.blur()},onClick:()=>{d.current&&d.current.focus()},onMouseMove:H=>{const O=H.currentTarget.getBoundingClientRect(),Z=H.clientX-O.left,$=H.clientY-O.top,eA=qi(kb(A),{x:Z,y:$});if(u.current.x=eA.x,u.current.y=eA.y,s){const aA=x(eA);E({x:aA.point.x,y:aA.point.y}),I(tA=>({...tA,end:aA.id}))}},onMouseDown:H=>{const O=H.currentTarget.getBoundingClientRect(),Z=H.clientX-O.left,$=H.clientY-O.top,eA=qi(kb(A),{x:Z,y:$});if(a&&!n){const aA=x(eA);Q({x:aA.point.x,y:aA.point.y}),E({x:aA.point.x,y:aA.point.y}),I({start:aA.id,end:aA.id}),o(!0),r(!0),B()}else s?(r(!1),I(aA=>({...aA,end:null}))):n&&(o(!1),I({start:null,end:null}))},children:[e,n&&W.jsxs(W.Fragment,{children:[Y.show&&W.jsx("div",{style:{position:"absolute",left:Y.x,top:Y.y,color:"red",mixBlendMode:"difference",pointerEvents:"none",fontSize:12,fontFamily:"sans-serif",whiteSpace:"nowrap",zIndex:fc.dimensionOverlay},children:Y.distance.toFixed(2)}),W.jsx("div",{style:{position:"absolute",left:L.left,width:L.width,textAlign:"center",top:N.y+2,color:"red",mixBlendMode:"difference",pointerEvents:"none",marginTop:L.flipY?0:-20,fontSize:12,fontFamily:"sans-serif",zIndex:fc.dimensionOverlay},children:Math.abs(C.x-h.x).toFixed(2)}),W.jsx("div",{style:{position:"absolute",left:M.x,height:L.height,display:"flex",flexDirection:"column",justifyContent:"center",top:L.top,color:"red",pointerEvents:"none",mixBlendMode:"difference",fontSize:12,fontFamily:"sans-serif",zIndex:fc.dimensionOverlay},children:W.jsx("div",{style:{marginLeft:L.flipX?"-100%":4,paddingRight:4},children:Math.abs(C.y-h.y).toFixed(2)})}),W.jsxs("svg",{style:{position:"absolute",left:0,top:0,pointerEvents:"none",mixBlendMode:"difference",zIndex:fc.dimensionOverlay},width:m.width,height:m.height,children:[W.jsx("defs",{children:W.jsx("marker",{id:"head",orient:"auto",markerWidth:"3",markerHeight:"4",refX:"2",refY:"2",children:W.jsx("path",{d:"M0,0 V4 L2,2 Z",fill:"red"})})}),W.jsx("line",{x1:N.x,y1:N.y,x2:M.x,y2:M.y,markerEnd:"url(#head)",strokeWidth:1.5,fill:"none",stroke:"red"}),W.jsx("line",{x1:N.x,y1:N.y,x2:M.x,y2:N.y,strokeWidth:1.5,fill:"none",strokeDasharray:"2,2",stroke:"red"}),W.jsx("line",{x1:M.x,y1:N.y,x2:M.x,y2:M.y,strokeWidth:1.5,fill:"none",strokeDasharray:"2,2",stroke:"red"})]}),s&&k.map(H=>{const O=H.id===c.start||H.id===c.end,Z=GG/2;return W.jsxs("svg",{width:GG,height:GG,style:{position:"absolute",left:H.screenPoint.x-Z,top:H.screenPoint.y-Z,pointerEvents:"none",zIndex:fc.dimensionOverlay},children:[W.jsx("line",{x1:0,y1:0,x2:GG,y2:GG,stroke:O?"#66ccff":"white",strokeWidth:1}),W.jsx("line",{x1:GG,y1:0,x2:0,y2:GG,stroke:O?"#66ccff":"white",strokeWidth:1})]},H.id)}),W.jsxs("div",{style:{right:0,bottom:0,position:"absolute",color:"red",fontFamily:"sans-serif",fontSize:12,margin:4},children:["(",C.x.toFixed(2),",",C.y.toFixed(2),")",W.jsx("br",{}),"(",h.x.toFixed(2),",",h.y.toFixed(2),")",W.jsx("br",{}),"dist:"," ",Math.sqrt((h.x-C.x)**2+(h.y-C.y)**2).toFixed(2)]})]})]})},gZe=(e,A,t=0)=>{const i=e.width/2,n=e.height/2,o=e.center.x-i-t,s=e.center.x+i+t,r=e.center.y-n-t,a=e.center.y+n+t;return A.x>o&&A.x<s&&A.y>r&&A.y<a},cZe=({children:e,disabled:A,transform:t,soup:i,cancelPanDrag:n,onCreateEditEvent:o,onModifyEditEvent:s})=>{t||(t=_b());const r=V.useRef(null),[a,g]=V.useState(null),[c,I]=V.useState(null),l=a!==null;eC(h=>h.in_edit_mode);const B=eC(h=>h.in_move_footprint_mode),C=eC(h=>h.setIsMovingComponent),Q=A||!B;return W.jsxs("div",{ref:r,style:{position:"relative",overflow:"hidden"},onMouseDown:h=>{if(Q)return;const E=h.currentTarget.getBoundingClientRect(),u=h.clientX-E.left,d=h.clientY-E.top;if(Number.isNaN(u)||Number.isNaN(d))return;const p=qi(kb(t),{x:u,y:d});let m=!1;for(const w of i)if(w.type==="pcb_component"&&gZe(w,p,10/t.a)){n(),g(w.pcb_component_id),m=!0;const D=Math.random().toString();I({dragStart:p,originalCenter:w.center,dragEnd:p,edit_event_id:D}),o({edit_event_id:D,edit_event_type:"edit_pcb_component_location",pcb_edit_event_type:"edit_component_location",pcb_component_id:w.pcb_component_id,original_center:w.center,new_center:w.center,in_progress:!0,created_at:Date.now()}),C(!0);break}if(m||g(null),m)return h.preventDefault(),!1},onMouseMove:h=>{if(!a||!c)return;const E=h.currentTarget.getBoundingClientRect(),u=h.clientX-E.left,d=h.clientY-E.top;if(Number.isNaN(u)||Number.isNaN(d))return;const p=qi(kb(t),{x:u,y:d});I({...c,dragEnd:p}),s({edit_event_id:c.edit_event_id,new_center:{x:c.originalCenter.x+p.x-c.dragStart.x,y:c.originalCenter.y+p.y-c.dragStart.y}})},onMouseUp:h=>{a&&(g(null),C(!1),c&&(s({edit_event_id:c.edit_event_id,in_progress:!1}),I(null)))},children:[e,!Q&&i.filter(h=>h.type==="pcb_component").map(h=>{if(!h?.center)return null;const E=qi(t,h.center);return W.jsx("div",{style:{position:"absolute",pointerEvents:"none",left:E.x,top:E.y,width:h.width*t.a+20,height:h.height*t.a+20,transform:"translate(-50%, -50%)",background:l&&a===h.pcb_component_id?"rgba(255, 0, 0, 0.2)":""}},h.pcb_component_id)})]})},IZe=({hotkeys:e})=>(V.useEffect(()=>{const A=t=>{e.forEach(i=>{t.key===i.key&&i.onUse()})};return window.addEventListener("keydown",A),()=>{window.removeEventListener("keydown",A)}},[e]),W.jsx("div",{className:g1`
5434
5434
  display: flex;
5435
5435
  flex-direction: column;
5436
5436
  font-family: sans-serif;
@@ -5469,7 +5469,7 @@ $1`).replace(/>(\s*)(?=<!--\s*\/)/g,"> ")}}});function xct(e,A,t){if(!A||!t)retu
5469
5469
  transition: opacity 0.2s;
5470
5470
  margin-bottom: 10px;
5471
5471
  color: red;
5472
- `,EZe=({children:e,transform:A=_b(),elements:t})=>{const i=V.useRef(null),{isShowingDRCErrors:n,hoveredErrorId:o}=eC(g=>({isShowingDRCErrors:g.is_showing_drc_errors,hoveredErrorId:g.hovered_error_id}));if(!t)return W.jsx("div",{style:{position:"relative"},ref:i,children:e});const s=t.filter(g=>g.type==="pcb_trace_error"),r=t.filter(g=>g.type==="pcb_trace_error"&&g.message?.includes("Multiple components found with name")),a=new Map;return t.forEach(g=>{g.type==="pcb_port"&&a.set(g.pcb_port_id,g)}),W.jsxs("div",{style:{position:"relative"},ref:i,children:[e,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=t?Gb(t).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=qi(A,{x:B.x,y:B.y}),d=qi(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 w=HfA(m,i);return W.jsxs(V.Fragment,{children:[W.jsx(QZe,{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:fc.errorOverlay+5,cursor:"pointer",borderRadius:"50%"},onMouseEnter:D=>{const S=D.currentTarget.nextElementSibling;if(S){const k=S.querySelector(".error-message");k&&(k.style.opacity="1")}},onMouseLeave:D=>{if(!E){const S=D.currentTarget.nextElementSibling;if(S){const k=S.querySelector(".error-message");k&&(k.style.opacity="0")}}}}),W.jsx("div",{style:{position:"absolute",zIndex:E?200:100,left:w.left,top:w.top,color:E?"#ff4444":"red",textAlign:"center",fontFamily:"sans-serif",fontSize:12,display:n||E?"flex":"none",flexDirection:"column",alignItems:"center",pointerEvents:"none",transform:w.transform},children:W.jsx("div",{className:`error-message ${YfA}`,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(w=>qi(A,{x:w.x,y:w.y}));if(u.some(w=>isNaN(w.x)||isNaN(w.y)))return null;const d=Math.floor(u.length/2),p=u[d],m=HfA(p,i);return W.jsxs(V.Fragment,{children:[W.jsx(hZe,{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:fc.errorOverlay+5,cursor:"pointer",borderRadius:"50%"},onMouseEnter:w=>{const D=w.currentTarget.nextElementSibling;if(D){const S=D.querySelector(".error-message");S&&(S.style.opacity="1")}},onMouseLeave:w=>{if(!E){const D=w.currentTarget.nextElementSibling;if(D){const S=D.querySelector(".error-message");S&&(S.style.opacity="0")}}}}),W.jsx("div",{style:{position:"absolute",zIndex:E?fc.errorOverlay+10:fc.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 ${YfA}`,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=t?.filter(Q=>Q.type==="source_component"&&Q.name===I||Q.type==="pcb_component"&&t?.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=t?.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=qi(A,E);if(isNaN(u.x)||isNaN(u.y))return null;const d=Math.abs(A.a),D=Math.max(8,Math.min(30,.5*d)),S=HfA(u,i);return W.jsxs(V.Fragment,{children:[W.jsx("svg",{style:{position:"absolute",left:0,top:0,pointerEvents:"none",mixBlendMode:"difference",zIndex:fc.errorOverlay},width:"100%",height:"100%",children:C?W.jsx("polygon",{points:`${u.x},${u.y-D*1.25} ${u.x+D},${u.y} ${u.x},${u.y+D*1.25} ${u.x-D},${u.y}`,fill:"#ff4444"}):W.jsx("circle",{cx:u.x,cy:u.y,r:D,fill:"none",stroke:C?"#ff4444":"red",strokeWidth:C?Math.max(2,D*.15):Math.max(1,D*.1),opacity:1})}),W.jsx("div",{style:{position:"absolute",left:u.x-(D+10),top:u.y-(D+10),width:(D+10)*2,height:(D+10)*2,zIndex:fc.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?fc.errorOverlay+20:fc.errorOverlay+10,left:S.left,top:S.top,color:C?"#ff4444":"red",textAlign:"center",fontFamily:"sans-serif",fontSize:12,display:n||C?"flex":"none",flexDirection:"column",alignItems:"center",pointerEvents:"none",transform:S.transform},children:W.jsx("div",{className:`error-message ${YfA}`,style:{opacity:C?1:0,border:`1px solid ${C?"#ff4444":"red"}`},children:g.message})})]},`${B}_${h}`)})})]})};function uZe(e,A){return e.size!==A.size?!1:Array.from(e).every(t=>A.has(t))}function dZe({primitiveElement:e,elements:A}){let t=e.trace_length?`${e.trace_length.toFixed(3)}`:"";const i=Gb(A).source_trace.get(e?.source_trace_id);if(i?.display_name&&(i?.max_length?t+=` / ${i.max_length}mm `:t+=" mm ",t+=`(${i.display_name})`),!t)return null;const n=e.trace_length&&i?.max_length&&e.trace_length>i.max_length;return{text:t,isOverLength:n}}function pZe(e){const{primitives:A,is_showing_multiple_traces_length:t,elements:i}=e,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(!t)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 fZe={position:"absolute",left:0,top:0,pointerEvents:"none",color:"red",fontFamily:"sans-serif",fontSize:12,textShadow:"0 0 2px black"},yZe=e=>{const{_element:A,_parent_pcb_component:t,_parent_source_component:i,_source_port:n}=e;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""}},mZe={top:"red",bottom:"aqua"},wZe=({primitive:e,mousePos:A,elements:t})=>{const[i,n]=V.useState(!1),o=e._element;V.useEffect(()=>{setTimeout(()=>{n(!0)},100)},[]);const[s,r,a,g]=[e.screen_x,e.screen_y,e.screen_w,e.screen_h],c=e.same_space_index??0,I=26,l=mZe[e?._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 e||o.type==="pcb_plated_hole"&&(o?.shape==="pill"||o?.shape==="oval")&&"ccw_rotation"in e)&&(B=o.ccw_rotation??0),o.type==="pcb_trace"){const h=dZe({primitiveElement:o,elements:t});if(!h)return null;const E=A.y-35;return W.jsx("div",{style:{zIndex:fc.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=yZe(e);return C.trim().length===0?null:W.jsx("div",{style:{zIndex:fc.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})})})},DZe=({highlightedPrimitives:e,mousePos:A,elements:t})=>{const[i,n]=eC(r=>[r.is_moving_component,r.is_showing_multiple_traces_length]),o=e.some(r=>r._element.type==="pcb_smtpad")&&e.some(r=>r._element.type==="pcb_trace");let s=e;return o&&(s=s.filter(r=>r._element.type==="pcb_smtpad")),s=pZe({primitives:s,is_showing_multiple_traces_length:n,elements:t}),W.jsx("div",{style:fZe,children:!i&&s.map((r,a)=>W.jsx(wZe,{primitive:r,mousePos:A,elements:t},a))})},ek=e=>e?.type==="pcb_component",tIt=e=>e?.type==="pcb_group",SZe=e=>e?.type==="pcb_panel",JfA=e=>e?.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},T0={OFFSET_LINE:"white",COMPONENT_MARKER_FILL:"#66ccff",COMPONENT_MARKER_STROKE:"white",LABEL_TEXT:"white"},TfA=({targets:e,transform:A,containerWidth:t,containerHeight:i})=>{if(e.length===0)return null;const n={color:T0.LABEL_TEXT,mixBlendMode:"difference",pointerEvents:"none",fontSize:zc.LABEL_FONT_SIZE,fontFamily:"monospace",fontWeight:"bold"},o=new Map;return e.forEach(s=>{if(!o.has(s.anchor_id)){const r=qi(A,s.anchor);o.set(s.anchor_id,r)}}),W.jsx("div",{style:{position:"absolute",left:0,top:0,width:t,height:i,overflow:"hidden",pointerEvents:"none",zIndex:fc.dimensionOverlay},children:W.jsxs("svg",{style:{position:"absolute",left:0,top:0,pointerEvents:"none"},width:t,height:i,children:[e.map(s=>{const r=s.anchor,a=s.anchor_id,g=s.target,c=o.get(a),I=qi(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,w=`${s.display_offset_x??l.toFixed(2)}mm`,D=`${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:T0.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:T0.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:T0.COMPONENT_MARKER_FILL,stroke:T0.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:T0.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:T0.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:w})}),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:D})})]},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:T0.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:T0.OFFSET_LINE,strokeWidth:zc.ANCHOR_MARKER_STROKE_WIDTH})]},`anchor-${s}`))]})})},bZe=({elements:e,highlightedPrimitives:A,transform:t,containerWidth:i,containerHeight:n})=>{const o=e.filter(E=>JfA(E)),s=e.filter(E=>ek(E)),r=e.filter(E=>tIt(E)),a=A.map(E=>ek(E._parent_pcb_component)?E._parent_pcb_component.pcb_component_id:ek(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)}),!eC(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(TfA,{targets:h,transform:t,containerWidth:i,containerHeight:n})},xZe=({elements:e,highlightedPrimitives:A,transform:t,containerWidth:i,containerHeight:n})=>{const o=e.filter(E=>tIt(E)),s=e.filter(E=>ek(E)),r=A.map(E=>ek(E._parent_pcb_component)?E._parent_pcb_component.pcb_component_id:ek(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))}),!eC(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(TfA,{targets:h,transform:t,containerWidth:i,containerHeight:n})},_Ze=(e,A)=>{const t=e.pcb_component_id,i=A.filter(n=>(n.type==="pcb_smtpad"||n.type==="pcb_plated_hole")&&n.pcb_component_id===t||n.type==="pcb_hole"&&n.pcb_component_id===t);return i.length===0?LfA([e]):LfA(i)},kZe=({elements:e,highlightedPrimitives:A,transform:t,containerWidth:i,containerHeight:n})=>{const o=new Map;for(const r of A)ek(r._parent_pcb_component)&&o.set(r._parent_pcb_component.pcb_component_id,r._parent_pcb_component),ek(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=_Ze(r,e);if(!a)continue;const g=r.positioned_relative_to_pcb_group_id??r.pcb_group_id,c=g?Gb(e).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:fc.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=qi(t,{x:a.minX,y:a.maxY}),I=qi(t,{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=qi(t,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:T0.COMPONENT_MARKER_STROKE,strokeWidth:1.5}),W.jsx("line",{x1:C.x,y1:C.y-6,x2:C.x,y2:C.y+6,stroke:T0.COMPONENT_MARKER_STROKE,strokeWidth:1.5}),W.jsx("circle",{cx:C.x,cy:C.y,r:zc.COMPONENT_MARKER_RADIUS,fill:T0.COMPONENT_MARKER_FILL,stroke:T0.COMPONENT_MARKER_STROKE,strokeWidth:1})]},r.pcb_component_id)})})})},FZe=({elements:e,highlightedPrimitives:A,transform:t,containerWidth:i,containerHeight:n})=>{const o=e.filter(B=>SZe(B)),s=e.filter(B=>JfA(B)),r=A.map(B=>JfA(B._element)?B._element.pcb_board_id:null).filter(B=>!!B);if(!eC(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(TfA,{targets:l,transform:t,containerWidth:i,containerHeight:n})},q9=e=>{if(e.length===0)return null;let A=e[0].x,t=e[0].y,i=e[0].x,n=e[0].y;for(const o of e)o.x<A&&(A=o.x),o.y<t&&(t=o.y),o.x>i&&(i=o.x),o.y>n&&(n=o.y);return{center:{x:(A+i)/2,y:(t+n)/2},width:i-A,height:n-t}},eIt=(e,A)=>{if(A.length<3)return!1;let t=!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>e.y!=a>e.y&&e.x<(r-o)*(e.y-s)/(a-s||Number.EPSILON)+o&&(t=!t)}return t},GZe=(e,A,t)=>{const i=[];for(const n of e){if(!n._element)continue;if("x1"in n&&n._element?.type==="pcb_trace"){const r=wE({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)/t.a;r<g&&i.push(n);continue}if(n.pcb_drawing_type==="polygon"){const r=n.points.map(g=>({x:he.parse(g.x),y:he.parse(g.y)})),a=q9(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;eIt(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:he.parse(g.x),y:he.parse(g.y)})),a=q9(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;eIt(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},RZe=({elements:e,children:A,transform:t,primitives:i,onMouseHoverOverPrimitives:n})=>{const[o,s]=V.useState([]),[r,a]=V.useState({x:0,y:0}),[g,{width:c,height:I}]=yJ(),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 w=q9(Q.points);if(!w)continue;h=w.center,E=w.width,u=w.height}else if(Q.pcb_drawing_type==="polygon_with_arcs"){const w=Q.brep_shape.outer_ring.vertices.map(S=>({x:S.x,y:S.y})),D=q9(w);if(!D)continue;h=D.center,E=D.width,u=D.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=qi(t,h),p={w:E*t.a,h:u*t.a},m=C.filter(w=>d.x===w.screen_x&&d.y===w.screen_y&&p.w===w.screen_w&&p.h===w.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,t]),B=(C,Q,h,E)=>{a({x:C,y:Q});const u=qi(kb(h),{x:C,y:Q}),d=GZe(E,u,h);uZe(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(t){const Q=C.currentTarget.getBoundingClientRect(),h=C.clientX-Q.left,E=C.clientY-Q.top;B(h,E,t,i)}},onTouchStart:C=>{if(t){const Q=C.touches[0],h=C.currentTarget.getBoundingClientRect(),E=Q.clientX-h.left,u=Q.clientY-h.top;B(E,u,t,i)}},children:[A,W.jsx(DZe,{elements:e,mousePos:r,highlightedPrimitives:l}),t&&W.jsxs(W.Fragment,{children:[W.jsx(bZe,{elements:e,highlightedPrimitives:l,transform:t,containerWidth:c,containerHeight:I}),W.jsx(xZe,{elements:e,highlightedPrimitives:l,transform:t,containerWidth:c,containerHeight:I}),W.jsx(kZe,{elements:e,highlightedPrimitives:l,transform:t,containerWidth:c,containerHeight:I}),W.jsx(FZe,{elements:e,highlightedPrimitives:l,transform:t,containerWidth:c,containerHeight:I})]})]})},iIt=["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)"],MZe=({children:e,transform:A=_b(),elements:t=[],hoveredComponentIds:i=[]})=>{const[n,{width:o,height:s}]=yJ(),r=V.useRef(null),{is_showing_pcb_groups:a,pcb_group_view_mode:g,is_showing_group_anchor_offsets:c}=eC(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=t.filter(w=>w.type==="pcb_group"),C=t.filter(w=>w.type==="pcb_component"),Q=t.filter(w=>w.type==="source_group"),h=new Map(Q.map(w=>[w.source_group_id,w])),E=B.filter(w=>{if(g==="all")return!0;if(!w.source_group_id)return!1;const D=h.get(w.source_group_id);return D?D.was_automatically_named!==!0:!1}),u=new Map;Q.forEach(w=>{const D=w;if(D.parent_source_group_id){const S=u.get(D.parent_source_group_id)||[];S.push(w.source_group_id),u.set(D.parent_source_group_id,S)}});const d=w=>{const D=[],S=u.get(w)||[];for(const k of S)D.push(k),D.push(...d(k));return D},p=w=>{const D=Q.find(S=>S.source_group_id===w);return D?.parent_source_group_id?1+p(D.parent_source_group_id):0},m=new Set;if(i.length>0)for(const w of C){if(!i.includes(w.pcb_component_id))continue;const D=w.positioned_relative_to_pcb_group_id??w.pcb_group_id;D&&m.add(D)}E.forEach((w,D)=>{let S=C.filter(HA=>HA.pcb_group_id===w.pcb_group_id);if(w.source_group_id){const HA=d(w.source_group_id),ZA=B.filter(xA=>xA.source_group_id&&HA.includes(xA.source_group_id));for(const xA of ZA){const wA=C.filter(NA=>NA.pcb_group_id===xA.pcb_group_id);S=[...S,...wA]}}let k,x,N,M,L=!1;if(w.center&&w.width&&w.height){L=!0;const HA=w.width/2,ZA=w.height/2;k=w.center.x-HA,N=w.center.x+HA,x=w.center.y-ZA,M=w.center.y+ZA}else if(S.length===0||(k=1/0,x=1/0,N=-1/0,M=-1/0,S.forEach(HA=>{if(HA.center&&typeof HA.width=="number"&&typeof HA.height=="number"){const ZA=HA.center.x-HA.width/2,xA=HA.center.x+HA.width/2,wA=HA.center.y+HA.height/2,NA=HA.center.y-HA.height/2;k=Math.min(k,ZA),N=Math.max(N,xA),x=Math.min(x,NA),M=Math.max(M,wA)}}),k===1/0||N===-1/0))return;const Y=w.source_group_id?p(w.source_group_id):0,H=w.source_group_id?d(w.source_group_id).length>0:!1;if(!L){const xA=1+(H?.5:0);k-=xA,N+=xA,x-=xA,M+=xA}const O=qi(A,{x:k,y:M}),Z=qi(A,{x:N,y:M}),$=qi(A,{x:k,y:x}),eA=qi(A,{x:N,y:x}),aA=iIt[D%iIt.length];l.strokeStyle=aA,l.lineWidth=2;const tA=Math.max(4,Math.min(12,8*Math.abs(A.a))),nA=Math.max(2,Math.min(6,4*Math.abs(A.a))),lA=tA*(H?1.3:1),fA=nA;l.setLineDash([lA,fA]),l.beginPath(),l.moveTo(O.x,O.y),l.lineTo(Z.x,Z.y),l.lineTo(eA.x,eA.y),l.lineTo($.x,$.y),l.closePath(),l.stroke();const bA=Math.max(8,Math.min(12,10*Math.abs(A.a))),GA=Y==0||Y==1?0:Y*.11,YA=bA*(1-GA),QA=4,_A=w.name||`Group ${D+1}`;l.font=`${YA}px sans-serif`,l.setLineDash([]);const PA=l.measureText(_A).width+QA*2,JA=YA+QA*2,it=O.x-5,pA=O.y-5,tt=3;if(l.fillStyle="rgba(0, 0, 0, 0.8)",l.beginPath(),l.roundRect(it,pA-JA,PA,JA,tt),l.fill(),l.fillStyle=aA,l.textAlign="left",l.textBaseline="middle",l.fillText(_A,it+QA,pA-JA/2),c&&m.has(w.pcb_group_id)&&!!w.anchor_position&&w.anchor_position){const HA=Array.isArray(w.anchor_position)?{x:w.anchor_position[0]??0,y:w.anchor_position[1]??0}:{x:w.anchor_position.x,y:w.anchor_position.y},ZA=qi(A,HA);l.strokeStyle="white",l.lineWidth=1.5,l.setLineDash([]);const xA=Math.max(4,Math.min(8,6*Math.abs(A.a)));l.beginPath(),l.moveTo(ZA.x-xA,ZA.y),l.lineTo(ZA.x+xA,ZA.y),l.stroke(),l.beginPath(),l.moveTo(ZA.x,ZA.y-xA),l.lineTo(ZA.x,ZA.y+xA),l.stroke()}})},[t,A,o,s,a,g,c,i]),W.jsxs("div",{ref:n,style:{position:"relative",width:"100%",height:"100%"},children:[e,W.jsx("canvas",{ref:r,style:{position:"absolute",top:0,left:0,pointerEvents:"none",zIndex:fc.pcbGroupOverlay,display:a?"block":"none"}})]})},NZe=({transform:e,soup:A,children:t})=>{const i=eC(r=>r.is_showing_rats_nest),{netMap:n,idToNetMap:o}=V.useMemo(()=>Nct(A||[]),[A]),s=V.useMemo(()=>{if(!A||!i)return[];const r=l=>{const B=Gb(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=Gb(A).pcb_port.list(),c=Gb(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?t:(e||(e=_b()),W.jsxs("div",{style:{position:"relative"},children:[t,W.jsx("svg",{style:{position:"absolute",left:0,top:0,width:"100%",height:"100%",pointerEvents:"none",opacity:.5,zIndex:fc.ratsNestOverlay},children:s.map(({key:r,startPoint:a,endPoint:g,isInNet:c})=>{const I=qi(e,a),l=qi(e,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)})})]}))},vZe={version:"1.11.333"},ik=(e,A,t)=>{const i=eC(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(!e)return;const s=r=>{const a=r.target;if(a.tagName==="INPUT"||a.tagName==="TEXTAREA"||a.isContentEditable)return;const g=e.split("+"),c=g.includes("ctrl"),I=g.includes("shift"),l=g.includes("alt"),B=g.includes("meta"),C=g[g.length-1],Q=t?.current?t.current.contains(document.activeElement)||document.activeElement===t.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)}},[e])},LZe=()=>{const[e,A]=V.useState(!1);return V.useEffect(()=>{const t=()=>{A(window.innerWidth<=768)};return t(),window.addEventListener("resize",t),()=>window.removeEventListener("resize",t)},[]),e},UZe=({name:e,selected:A,onClick:t})=>W.jsxs("div",{className:g1`
5472
+ `,EZe=({children:e,transform:A=_b(),elements:t})=>{const i=V.useRef(null),{isShowingDRCErrors:n,hoveredErrorId:o}=eC(g=>({isShowingDRCErrors:g.is_showing_drc_errors,hoveredErrorId:g.hovered_error_id}));if(!t)return W.jsx("div",{style:{position:"relative"},ref:i,children:e});const s=t.filter(g=>g.type==="pcb_trace_error"),r=t.filter(g=>g.type==="pcb_trace_error"&&g.message?.includes("Multiple components found with name")),a=new Map;return t.forEach(g=>{g.type==="pcb_port"&&a.set(g.pcb_port_id,g)}),W.jsxs("div",{style:{position:"relative"},ref:i,children:[e,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=t?Gb(t).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=qi(A,{x:B.x,y:B.y}),d=qi(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 w=HfA(m,i);return W.jsxs(V.Fragment,{children:[W.jsx(QZe,{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:fc.errorOverlay+5,cursor:"pointer",borderRadius:"50%"},onMouseEnter:D=>{const S=D.currentTarget.nextElementSibling;if(S){const k=S.querySelector(".error-message");k&&(k.style.opacity="1")}},onMouseLeave:D=>{if(!E){const S=D.currentTarget.nextElementSibling;if(S){const k=S.querySelector(".error-message");k&&(k.style.opacity="0")}}}}),W.jsx("div",{style:{position:"absolute",zIndex:E?200:100,left:w.left,top:w.top,color:E?"#ff4444":"red",textAlign:"center",fontFamily:"sans-serif",fontSize:12,display:n||E?"flex":"none",flexDirection:"column",alignItems:"center",pointerEvents:"none",transform:w.transform},children:W.jsx("div",{className:`error-message ${YfA}`,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(w=>qi(A,{x:w.x,y:w.y}));if(u.some(w=>isNaN(w.x)||isNaN(w.y)))return null;const d=Math.floor(u.length/2),p=u[d],m=HfA(p,i);return W.jsxs(V.Fragment,{children:[W.jsx(hZe,{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:fc.errorOverlay+5,cursor:"pointer",borderRadius:"50%"},onMouseEnter:w=>{const D=w.currentTarget.nextElementSibling;if(D){const S=D.querySelector(".error-message");S&&(S.style.opacity="1")}},onMouseLeave:w=>{if(!E){const D=w.currentTarget.nextElementSibling;if(D){const S=D.querySelector(".error-message");S&&(S.style.opacity="0")}}}}),W.jsx("div",{style:{position:"absolute",zIndex:E?fc.errorOverlay+10:fc.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 ${YfA}`,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=t?.filter(Q=>Q.type==="source_component"&&Q.name===I||Q.type==="pcb_component"&&t?.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=t?.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=qi(A,E);if(isNaN(u.x)||isNaN(u.y))return null;const d=Math.abs(A.a),D=Math.max(8,Math.min(30,.5*d)),S=HfA(u,i);return W.jsxs(V.Fragment,{children:[W.jsx("svg",{style:{position:"absolute",left:0,top:0,pointerEvents:"none",mixBlendMode:"difference",zIndex:fc.errorOverlay},width:"100%",height:"100%",children:C?W.jsx("polygon",{points:`${u.x},${u.y-D*1.25} ${u.x+D},${u.y} ${u.x},${u.y+D*1.25} ${u.x-D},${u.y}`,fill:"#ff4444"}):W.jsx("circle",{cx:u.x,cy:u.y,r:D,fill:"none",stroke:C?"#ff4444":"red",strokeWidth:C?Math.max(2,D*.15):Math.max(1,D*.1),opacity:1})}),W.jsx("div",{style:{position:"absolute",left:u.x-(D+10),top:u.y-(D+10),width:(D+10)*2,height:(D+10)*2,zIndex:fc.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?fc.errorOverlay+20:fc.errorOverlay+10,left:S.left,top:S.top,color:C?"#ff4444":"red",textAlign:"center",fontFamily:"sans-serif",fontSize:12,display:n||C?"flex":"none",flexDirection:"column",alignItems:"center",pointerEvents:"none",transform:S.transform},children:W.jsx("div",{className:`error-message ${YfA}`,style:{opacity:C?1:0,border:`1px solid ${C?"#ff4444":"red"}`},children:g.message})})]},`${B}_${h}`)})})]})};function uZe(e,A){return e.size!==A.size?!1:Array.from(e).every(t=>A.has(t))}function dZe({primitiveElement:e,elements:A}){let t=e.trace_length?`${e.trace_length.toFixed(3)}`:"";const i=Gb(A).source_trace.get(e?.source_trace_id);if(i?.display_name&&(i?.max_length?t+=` / ${i.max_length}mm `:t+=" mm ",t+=`(${i.display_name})`),!t)return null;const n=e.trace_length&&i?.max_length&&e.trace_length>i.max_length;return{text:t,isOverLength:n}}function pZe(e){const{primitives:A,is_showing_multiple_traces_length:t,elements:i}=e,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(!t)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 fZe={position:"absolute",left:0,top:0,pointerEvents:"none",color:"red",fontFamily:"sans-serif",fontSize:12,textShadow:"0 0 2px black"},yZe=e=>{const{_element:A,_parent_pcb_component:t,_parent_source_component:i,_source_port:n}=e;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""}},mZe={top:"red",bottom:"aqua"},wZe=({primitive:e,mousePos:A,elements:t})=>{const[i,n]=V.useState(!1),o=e._element;V.useEffect(()=>{setTimeout(()=>{n(!0)},100)},[]);const[s,r,a,g]=[e.screen_x,e.screen_y,e.screen_w,e.screen_h],c=e.same_space_index??0,I=26,l=mZe[e?._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 e||o.type==="pcb_plated_hole"&&(o?.shape==="pill"||o?.shape==="oval")&&"ccw_rotation"in e)&&(B=o.ccw_rotation??0),o.type==="pcb_trace"){const h=dZe({primitiveElement:o,elements:t});if(!h)return null;const E=A.y-35;return W.jsx("div",{style:{zIndex:fc.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=yZe(e);return C.trim().length===0?null:W.jsx("div",{style:{zIndex:fc.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})})})},DZe=({highlightedPrimitives:e,mousePos:A,elements:t})=>{const[i,n]=eC(r=>[r.is_moving_component,r.is_showing_multiple_traces_length]),o=e.some(r=>r._element.type==="pcb_smtpad")&&e.some(r=>r._element.type==="pcb_trace");let s=e;return o&&(s=s.filter(r=>r._element.type==="pcb_smtpad")),s=pZe({primitives:s,is_showing_multiple_traces_length:n,elements:t}),W.jsx("div",{style:fZe,children:!i&&s.map((r,a)=>W.jsx(wZe,{primitive:r,mousePos:A,elements:t},a))})},ek=e=>e?.type==="pcb_component",tIt=e=>e?.type==="pcb_group",SZe=e=>e?.type==="pcb_panel",JfA=e=>e?.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},T0={OFFSET_LINE:"white",COMPONENT_MARKER_FILL:"#66ccff",COMPONENT_MARKER_STROKE:"white",LABEL_TEXT:"white"},TfA=({targets:e,transform:A,containerWidth:t,containerHeight:i})=>{if(e.length===0)return null;const n={color:T0.LABEL_TEXT,mixBlendMode:"difference",pointerEvents:"none",fontSize:zc.LABEL_FONT_SIZE,fontFamily:"monospace",fontWeight:"bold"},o=new Map;return e.forEach(s=>{if(!o.has(s.anchor_id)){const r=qi(A,s.anchor);o.set(s.anchor_id,r)}}),W.jsx("div",{style:{position:"absolute",left:0,top:0,width:t,height:i,overflow:"hidden",pointerEvents:"none",zIndex:fc.dimensionOverlay},children:W.jsxs("svg",{style:{position:"absolute",left:0,top:0,pointerEvents:"none"},width:t,height:i,children:[e.map(s=>{const r=s.anchor,a=s.anchor_id,g=s.target,c=o.get(a),I=qi(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,w=`${s.display_offset_x??l.toFixed(2)}mm`,D=`${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:T0.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:T0.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:T0.COMPONENT_MARKER_FILL,stroke:T0.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:T0.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:T0.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:w})}),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:D})})]},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:T0.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:T0.OFFSET_LINE,strokeWidth:zc.ANCHOR_MARKER_STROKE_WIDTH})]},`anchor-${s}`))]})})},bZe=({elements:e,highlightedPrimitives:A,transform:t,containerWidth:i,containerHeight:n})=>{const o=e.filter(E=>JfA(E)),s=e.filter(E=>ek(E)),r=e.filter(E=>tIt(E)),a=A.map(E=>ek(E._parent_pcb_component)?E._parent_pcb_component.pcb_component_id:ek(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)}),!eC(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(TfA,{targets:h,transform:t,containerWidth:i,containerHeight:n})},xZe=({elements:e,highlightedPrimitives:A,transform:t,containerWidth:i,containerHeight:n})=>{const o=e.filter(E=>tIt(E)),s=e.filter(E=>ek(E)),r=A.map(E=>ek(E._parent_pcb_component)?E._parent_pcb_component.pcb_component_id:ek(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))}),!eC(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(TfA,{targets:h,transform:t,containerWidth:i,containerHeight:n})},_Ze=(e,A)=>{const t=e.pcb_component_id,i=A.filter(n=>(n.type==="pcb_smtpad"||n.type==="pcb_plated_hole")&&n.pcb_component_id===t||n.type==="pcb_hole"&&n.pcb_component_id===t);return i.length===0?LfA([e]):LfA(i)},kZe=({elements:e,highlightedPrimitives:A,transform:t,containerWidth:i,containerHeight:n})=>{const o=new Map;for(const r of A)ek(r._parent_pcb_component)&&o.set(r._parent_pcb_component.pcb_component_id,r._parent_pcb_component),ek(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=_Ze(r,e);if(!a)continue;const g=r.positioned_relative_to_pcb_group_id??r.pcb_group_id,c=g?Gb(e).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:fc.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=qi(t,{x:a.minX,y:a.maxY}),I=qi(t,{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=qi(t,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:T0.COMPONENT_MARKER_STROKE,strokeWidth:1.5}),W.jsx("line",{x1:C.x,y1:C.y-6,x2:C.x,y2:C.y+6,stroke:T0.COMPONENT_MARKER_STROKE,strokeWidth:1.5}),W.jsx("circle",{cx:C.x,cy:C.y,r:zc.COMPONENT_MARKER_RADIUS,fill:T0.COMPONENT_MARKER_FILL,stroke:T0.COMPONENT_MARKER_STROKE,strokeWidth:1})]},r.pcb_component_id)})})})},FZe=({elements:e,highlightedPrimitives:A,transform:t,containerWidth:i,containerHeight:n})=>{const o=e.filter(B=>SZe(B)),s=e.filter(B=>JfA(B)),r=A.map(B=>JfA(B._element)?B._element.pcb_board_id:null).filter(B=>!!B);if(!eC(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(TfA,{targets:l,transform:t,containerWidth:i,containerHeight:n})},q9=e=>{if(e.length===0)return null;let A=e[0].x,t=e[0].y,i=e[0].x,n=e[0].y;for(const o of e)o.x<A&&(A=o.x),o.y<t&&(t=o.y),o.x>i&&(i=o.x),o.y>n&&(n=o.y);return{center:{x:(A+i)/2,y:(t+n)/2},width:i-A,height:n-t}},eIt=(e,A)=>{if(A.length<3)return!1;let t=!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>e.y!=a>e.y&&e.x<(r-o)*(e.y-s)/(a-s||Number.EPSILON)+o&&(t=!t)}return t},GZe=(e,A,t)=>{const i=[];for(const n of e){if(!n._element)continue;if("x1"in n&&n._element?.type==="pcb_trace"){const r=wE({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)/t.a;r<g&&i.push(n);continue}if(n.pcb_drawing_type==="polygon"){const r=n.points.map(g=>({x:he.parse(g.x),y:he.parse(g.y)})),a=q9(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;eIt(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:he.parse(g.x),y:he.parse(g.y)})),a=q9(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;eIt(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},RZe=({elements:e,children:A,transform:t,primitives:i,onMouseHoverOverPrimitives:n})=>{const[o,s]=V.useState([]),[r,a]=V.useState({x:0,y:0}),[g,{width:c,height:I}]=yJ(),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 w=q9(Q.points);if(!w)continue;h=w.center,E=w.width,u=w.height}else if(Q.pcb_drawing_type==="polygon_with_arcs"){const w=Q.brep_shape.outer_ring.vertices.map(S=>({x:S.x,y:S.y})),D=q9(w);if(!D)continue;h=D.center,E=D.width,u=D.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=qi(t,h),p={w:E*t.a,h:u*t.a},m=C.filter(w=>d.x===w.screen_x&&d.y===w.screen_y&&p.w===w.screen_w&&p.h===w.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,t]),B=(C,Q,h,E)=>{a({x:C,y:Q});const u=qi(kb(h),{x:C,y:Q}),d=GZe(E,u,h);uZe(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(t){const Q=C.currentTarget.getBoundingClientRect(),h=C.clientX-Q.left,E=C.clientY-Q.top;B(h,E,t,i)}},onTouchStart:C=>{if(t){const Q=C.touches[0],h=C.currentTarget.getBoundingClientRect(),E=Q.clientX-h.left,u=Q.clientY-h.top;B(E,u,t,i)}},children:[A,W.jsx(DZe,{elements:e,mousePos:r,highlightedPrimitives:l}),t&&W.jsxs(W.Fragment,{children:[W.jsx(bZe,{elements:e,highlightedPrimitives:l,transform:t,containerWidth:c,containerHeight:I}),W.jsx(xZe,{elements:e,highlightedPrimitives:l,transform:t,containerWidth:c,containerHeight:I}),W.jsx(kZe,{elements:e,highlightedPrimitives:l,transform:t,containerWidth:c,containerHeight:I}),W.jsx(FZe,{elements:e,highlightedPrimitives:l,transform:t,containerWidth:c,containerHeight:I})]})]})},iIt=["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)"],MZe=({children:e,transform:A=_b(),elements:t=[],hoveredComponentIds:i=[]})=>{const[n,{width:o,height:s}]=yJ(),r=V.useRef(null),{is_showing_pcb_groups:a,pcb_group_view_mode:g,is_showing_group_anchor_offsets:c}=eC(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=t.filter(w=>w.type==="pcb_group"),C=t.filter(w=>w.type==="pcb_component"),Q=t.filter(w=>w.type==="source_group"),h=new Map(Q.map(w=>[w.source_group_id,w])),E=B.filter(w=>{if(g==="all")return!0;if(!w.source_group_id)return!1;const D=h.get(w.source_group_id);return D?D.was_automatically_named!==!0:!1}),u=new Map;Q.forEach(w=>{const D=w;if(D.parent_source_group_id){const S=u.get(D.parent_source_group_id)||[];S.push(w.source_group_id),u.set(D.parent_source_group_id,S)}});const d=w=>{const D=[],S=u.get(w)||[];for(const k of S)D.push(k),D.push(...d(k));return D},p=w=>{const D=Q.find(S=>S.source_group_id===w);return D?.parent_source_group_id?1+p(D.parent_source_group_id):0},m=new Set;if(i.length>0)for(const w of C){if(!i.includes(w.pcb_component_id))continue;const D=w.positioned_relative_to_pcb_group_id??w.pcb_group_id;D&&m.add(D)}E.forEach((w,D)=>{let S=C.filter(HA=>HA.pcb_group_id===w.pcb_group_id);if(w.source_group_id){const HA=d(w.source_group_id),ZA=B.filter(xA=>xA.source_group_id&&HA.includes(xA.source_group_id));for(const xA of ZA){const wA=C.filter(NA=>NA.pcb_group_id===xA.pcb_group_id);S=[...S,...wA]}}let k,x,N,M,L=!1;if(w.center&&w.width&&w.height){L=!0;const HA=w.width/2,ZA=w.height/2;k=w.center.x-HA,N=w.center.x+HA,x=w.center.y-ZA,M=w.center.y+ZA}else if(S.length===0||(k=1/0,x=1/0,N=-1/0,M=-1/0,S.forEach(HA=>{if(HA.center&&typeof HA.width=="number"&&typeof HA.height=="number"){const ZA=HA.center.x-HA.width/2,xA=HA.center.x+HA.width/2,wA=HA.center.y+HA.height/2,NA=HA.center.y-HA.height/2;k=Math.min(k,ZA),N=Math.max(N,xA),x=Math.min(x,NA),M=Math.max(M,wA)}}),k===1/0||N===-1/0))return;const Y=w.source_group_id?p(w.source_group_id):0,H=w.source_group_id?d(w.source_group_id).length>0:!1;if(!L){const xA=1+(H?.5:0);k-=xA,N+=xA,x-=xA,M+=xA}const O=qi(A,{x:k,y:M}),Z=qi(A,{x:N,y:M}),$=qi(A,{x:k,y:x}),eA=qi(A,{x:N,y:x}),aA=iIt[D%iIt.length];l.strokeStyle=aA,l.lineWidth=2;const tA=Math.max(4,Math.min(12,8*Math.abs(A.a))),nA=Math.max(2,Math.min(6,4*Math.abs(A.a))),lA=tA*(H?1.3:1),fA=nA;l.setLineDash([lA,fA]),l.beginPath(),l.moveTo(O.x,O.y),l.lineTo(Z.x,Z.y),l.lineTo(eA.x,eA.y),l.lineTo($.x,$.y),l.closePath(),l.stroke();const bA=Math.max(8,Math.min(12,10*Math.abs(A.a))),GA=Y==0||Y==1?0:Y*.11,YA=bA*(1-GA),QA=4,_A=w.name||`Group ${D+1}`;l.font=`${YA}px sans-serif`,l.setLineDash([]);const PA=l.measureText(_A).width+QA*2,JA=YA+QA*2,it=O.x-5,pA=O.y-5,tt=3;if(l.fillStyle="rgba(0, 0, 0, 0.8)",l.beginPath(),l.roundRect(it,pA-JA,PA,JA,tt),l.fill(),l.fillStyle=aA,l.textAlign="left",l.textBaseline="middle",l.fillText(_A,it+QA,pA-JA/2),c&&m.has(w.pcb_group_id)&&!!w.anchor_position&&w.anchor_position){const HA=Array.isArray(w.anchor_position)?{x:w.anchor_position[0]??0,y:w.anchor_position[1]??0}:{x:w.anchor_position.x,y:w.anchor_position.y},ZA=qi(A,HA);l.strokeStyle="white",l.lineWidth=1.5,l.setLineDash([]);const xA=Math.max(4,Math.min(8,6*Math.abs(A.a)));l.beginPath(),l.moveTo(ZA.x-xA,ZA.y),l.lineTo(ZA.x+xA,ZA.y),l.stroke(),l.beginPath(),l.moveTo(ZA.x,ZA.y-xA),l.lineTo(ZA.x,ZA.y+xA),l.stroke()}})},[t,A,o,s,a,g,c,i]),W.jsxs("div",{ref:n,style:{position:"relative",width:"100%",height:"100%"},children:[e,W.jsx("canvas",{ref:r,style:{position:"absolute",top:0,left:0,pointerEvents:"none",zIndex:fc.pcbGroupOverlay,display:a?"block":"none"}})]})},NZe=({transform:e,soup:A,children:t})=>{const i=eC(r=>r.is_showing_rats_nest),{netMap:n,idToNetMap:o}=V.useMemo(()=>Nct(A||[]),[A]),s=V.useMemo(()=>{if(!A||!i)return[];const r=l=>{const B=Gb(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=Gb(A).pcb_port.list(),c=Gb(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?t:(e||(e=_b()),W.jsxs("div",{style:{position:"relative"},children:[t,W.jsx("svg",{style:{position:"absolute",left:0,top:0,width:"100%",height:"100%",pointerEvents:"none",opacity:.5,zIndex:fc.ratsNestOverlay},children:s.map(({key:r,startPoint:a,endPoint:g,isInNet:c})=>{const I=qi(e,a),l=qi(e,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)})})]}))},vZe={version:"1.11.334"},ik=(e,A,t)=>{const i=eC(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(!e)return;const s=r=>{const a=r.target;if(a.tagName==="INPUT"||a.tagName==="TEXTAREA"||a.isContentEditable)return;const g=e.split("+"),c=g.includes("ctrl"),I=g.includes("shift"),l=g.includes("alt"),B=g.includes("meta"),C=g[g.length-1],Q=t?.current?t.current.contains(document.activeElement)||document.activeElement===t.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)}},[e])},LZe=()=>{const[e,A]=V.useState(!1);return V.useEffect(()=>{const t=()=>{A(window.innerWidth<=768)};return t(),window.addEventListener("resize",t),()=>window.removeEventListener("resize",t)},[]),e},UZe=({name:e,selected:A,onClick:t})=>W.jsxs("div",{className:g1`
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 ${e.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(!t),title:`Download options for ${e.constructor.name}`,children:e.constructor.name}),t&&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"})]})]})},lIt=e=>e.activeSubSolver?[e,...lIt(e.activeSubSolver)]:[e],c9e=({solver:e})=>{const A=lIt(e);return W.jsx("div",{className:"flex gap-1 items-center text-sm pt-1",children:A.map((t,i)=>W.jsxs("div",{className:"flex items-center",children:[i>0&&W.jsx("span",{className:"text-gray-400 mx-1",children:"→"}),W.jsx(g9e,{solver:t})]},t.constructor.name))})},I9e=({solver:e,triggerRender:A,animationSpeed:t=25,onSolverStarted:i,onSolverCompleted:n})=>{const[o,s]=V.useReducer(Q=>!Q,!1),r=V.useRef(void 0),a=()=>{!e.solved&&!e.failed&&(e.step(),A())},g=()=>{!e.solved&&!e.failed&&(i&&i(e),e.solve(),A(),n&&n(e))},c=()=>{o?(r.current&&(clearInterval(r.current),r.current=void 0),s()):(s(),r.current=setInterval(()=>{if(e.solved||e.failed){r.current&&(clearInterval(r.current),r.current=void 0),s(),A(),n&&e.solved&&n(e);return}e.step(),A()},t))},I=()=>{const Q=e;if(Q.getCurrentPhase&&!e.solved&&!e.failed){const h=Q.getCurrentPhase();for(;Q.getCurrentPhase()===h&&!e.solved&&!e.failed;)e.step();A()}},l=()=>{if(e.solved||e.failed||o)return;const Q=window.prompt("Step until which iteration?",`${e.iterations}`);if(Q===null)return;const h=Number(Q);if(!Number.isFinite(h)){window.alert("Please enter a valid number for the iteration");return}for(;e.iterations<h&&!e.solved&&!e.failed;)e.step();A(),e.solved&&n&&n(e)};V.useEffect(()=>()=>{r.current&&clearInterval(r.current)},[]),V.useEffect(()=>{(e.solved||e.failed)&&o&&(r.current&&(clearInterval(r.current),r.current=void 0),s())},[e.solved,e.failed,o]);const B=e.getCurrentPhase!==void 0,C=B?e.getCurrentPhase():null;return W.jsxs("div",{className:"space-y-2 p-2 border-b",children:[W.jsx("div",{className:"flex items-center",children:W.jsx(c9e,{solver:e})}),W.jsxs("div",{className:"flex gap-2 items-center flex-wrap",children:[W.jsx("button",{onClick:a,disabled:e.solved||e.failed||o,className:"bg-blue-500 hover:bg-blue-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Step"}),W.jsx("button",{onClick:g,disabled:e.solved||e.failed||o,className:"bg-green-500 hover:bg-green-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Solve"}),W.jsx("button",{onClick:c,disabled:e.solved||e.failed,className:`px-3 py-1 rounded text-white text-sm ${o?"bg-red-500 hover:bg-red-600":"bg-yellow-500 hover:bg-yellow-600"} disabled:bg-gray-300`,children:o?"Stop":"Animate"}),W.jsx("button",{onClick:l,disabled:e.solved||e.failed||o,className:"bg-orange-500 hover:bg-orange-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Step Until Iteration"}),B&&W.jsx("button",{onClick:I,disabled:e.solved||e.failed||o,className:"bg-purple-500 hover:bg-purple-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Next Stage"}),W.jsxs("div",{className:"text-sm text-gray-600",children:["Iterations: ",e.iterations]}),e.timeToSolve!==void 0&&W.jsxs("div",{className:"text-sm text-gray-600",children:["Time: ",(e.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})]}),e.solved&&W.jsx("div",{className:"px-2 py-1 bg-green-100 text-green-800 rounded text-sm",children:"Solved"}),e.failed&&W.jsx("div",{className:"px-2 py-1 bg-red-100 text-red-800 rounded text-sm",children:"Failed"})]}),e.error&&W.jsxs("div",{className:"text-red-600 text-sm",children:["Error: ",e.error]})]})},l9e=(e,A,t)=>{const i=e.currentPipelineStepIndex;return A<i?"Completed":A===i&&e.activeSubSolver?e.activeSubSolver.failed?"Failed":"In Progress":"Not Started"},B9e=(e,A)=>{const i=e.pipelineDef[A].solverName,n=l9e(e,A),o=e[i],s=e.firstIterationOfPhase?.[i]??null,r=e.iterations;let a=0;if(n==="Completed"){const l=e.pipelineDef[A+1],B=l?e.firstIterationOfPhase?.[l.solverName]:void 0;B!==void 0&&s!==null?a=B-s:s!==null&&(a=r-s)}else n==="In Progress"&&s!==null&&(a=r-s);const g=e.timeSpentOnPhase?.[i]??0;let c=0;n==="Completed"?c=1:n==="In Progress"&&o&&(c=o.progress??0);const I=o?.stats??null;return{index:A,name:i,status:n,firstIteration:s,iterations:a,progress:c,timeSpent:g,stats:I&&Object.keys(I).length>0?I:null,solverInstance:o??null}},C9e=({status:e})=>{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[e]}`,children:e})},Q9e=({progress:e})=>{if(e===0)return null;const A=Math.round(e*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,"%"]})]})},h9e=e=>Object.entries(e).map(([A,t])=>`${A}: ${t}`).join(", "),E9e=({stats:e})=>{if(!e||Object.keys(e).length===0)return W.jsx("span",{children:"-"});const A=Object.entries(e),t=h9e(e);return W.jsxs("details",{className:"cursor-pointer",children:[W.jsx("summary",{className:"whitespace-nowrap overflow-hidden text-ellipsis max-w-[200px]",children:t}),W.jsx("div",{className:"mt-1 text-xs",children:A.map(([i,n])=>W.jsxs("div",{children:[i,": ",String(n)]},i))})]})},jfA=e=>{if(e===null||typeof e!="object")return e;if(Array.isArray(e))return e.map(jfA);const A={};for(const[t,i]of Object.entries(e))t.startsWith("_")||(A[t]=jfA(i));return A},u9e=(e,A)=>{try{if(typeof e.getConstructorParams!="function"){alert(`getConstructorParams() is not implemented for ${A}`);return}const t=jfA(e.getConstructorParams()),i=new Blob([JSON.stringify(t,null,2)],{type:"application/json"}),n=URL.createObjectURL(i),o=document.createElement("a");o.href=n,o.download=`${A}_input.json`,o.click(),URL.revokeObjectURL(n)}catch(t){alert(`Error downloading input for ${A}: ${t instanceof Error?t.message:String(t)}`)}},d9e=({solver:e,onStepUntilPhase:A,onDownloadInput:t})=>{const i=e.pipelineDef.map((r,a)=>B9e(e,a)),n=r=>{A?.(r)},o=r=>{r.solverInstance&&(t?t(r.solverInstance,r.name):u9e(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"||e.solved||e.failed,className:"text-blue-500 hover:text-blue-700 disabled:text-gray-300 disabled:cursor-not-allowed",title:`Step until ${r.name} completes`,children: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(C9e,{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(Q9e,{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(E9e,{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))})]})})]})},p9e=class extends en.Component{constructor(e){super(e),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(e){console.error("InteractiveGraphics render error:",e)}render(){return this.state.hasError?this.props.fallback:this.props.children}};function f9e({graphics:e}){const A=e.points??[],t=e.lines??[],i=e.rects??[],n=e.circles??[],o=e.texts??[];let s=Number.POSITIVE_INFINITY,r=Number.POSITIVE_INFINITY,a=Number.NEGATIVE_INFINITY,g=Number.NEGATIVE_INFINITY;const c=(h,E)=>{typeof h=="number"&&(h<s&&(s=h),h>a&&(a=h)),typeof E=="number"&&(E<r&&(r=E),E>g&&(g=E))};for(const h of A)c(h.x,h.y);for(const h of t){const E=h.points??[];for(const u of E)c(u.x,u.y)}for(const h of i){const E=h.x??0,u=h.y??0,d=h.width??0,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}`)),t.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 y9e=({solver:e,animationSpeed:A=25,onSolverStarted:t,onSolverCompleted:i})=>{const[n,o]=V.useReducer(c=>c+1,0),s=V.useMemo(()=>{try{return e.visualize()||{points:[],lines:[],rects:[],circles:[]}}catch(c){return console.error("Visualization error:",c),{points:[],lines:[],rects:[],circles:[]}}},[e,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=e.pipelineDef!==void 0,g=c=>{const I=e;if(!e.solved&&!e.failed){for(;!e.solved&&!e.failed&&I.currentPipelineStepIndex<=I.pipelineDef.findIndex(l=>l.solverName===c);)e.step();o()}};return W.jsxs("div",{children:[W.jsx(I9e,{solver:e,triggerRender:o,animationSpeed:A,onSolverStarted:t,onSolverCompleted:i}),r?W.jsx("div",{className:"p-4 text-gray-500",children:"No Graphics Yet"}):W.jsx(p9e,{fallback:W.jsx(f9e,{graphics:s}),children:W.jsx(a9e,{graphics:s})}),a&&W.jsx(d9e,{solver:e,onStepUntilPhase:g})]})};const m9e=()=>{V.useEffect(()=>{const e="tailwind-cdn-script";if(document.getElementById(e)||window.tailwind)return;const A=document.createElement("div");A.className="hidden",document.body.appendChild(A);const t=window.getComputedStyle(A).display==="none";if(document.body.removeChild(A),t)return;const i=document.createElement("script");i.id=e,i.src="https://cdn.tailwindcss.com",document.head.appendChild(i)},[])},w9e=e=>e.toLowerCase().includes("pack")?NMe:e.toLowerCase().includes("rout")?YMe:pMe,D9e=({solverEvents:e=[]})=>{const[A,t]=V.useState(null);m9e();const i=V.useMemo(()=>{const r=new Map;for(const a of e){const g=`${a.componentName}-${a.solverName}`;r.set(g,a)}return r},[e]),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=AoA[o.solverName];if(!r)return{instance:null,error:`Solver class "${o.solverName}" not found in SOLVERS registry. Available: ${Object.keys(AoA).join(", ")}`,classFound:!1};try{const a=o.solverParams,g=a?.input!==void 0?a.input:a;return{instance:new r(g),error:null,classFound:!0}}catch(a){const g=a instanceof Error?a.message:String(a);return console.error("Failed to reconstruct solver:",a),{instance:null,error:`Failed to instantiate solver: ${g}`,classFound:!0}}},[o]);return e.length===0?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:()=>t(r),children:(()=>{const c=w9e(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(qy,{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(y9e,{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"})})})]})},BIt=({errorMessage:e,errorStack:A,circuitJsonErrors:t})=>{V.useEffect(()=>{if(e){const i=new Error(e);A&&(i.stack=A);try{J5.captureException(i)}catch{}}},[e,A]),V.useEffect(()=>{if(t&&t.length>0)for(const i of t){const n=new Error(i.message||"Circuit JSON Error");i.stack&&(n.stack=i.stack);try{J5.captureException(n,{error_type:i.type})}catch{}}},[t])},CIt="0.0.1587",S9e={version:CIt},z9=xYA()(_YA(e=>({lastRunEvalVersion:void 0,setLastRunEvalVersion:A=>{e({lastRunEvalVersion:A})}}),{name:"runframe-runner-store"})),b9e=e=>{const[A,t]=V.useState([]),[i,n]=V.useState(null),[o,s]=V.useState(""),[r,a]=c1("eval-version-selection",null),g=z9(B=>B.setLastRunEvalVersion),c=z9(B=>B.lastRunEvalVersion);return V.useEffect(()=>{e&&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)),t(C)}}).catch(()=>{})},[e]),V.useEffect(()=>{e&&(r?(window.TSCIRCUIT_LATEST_EVAL_VERSION=r,g(r)):i&&(window.TSCIRCUIT_LATEST_EVAL_VERSION=i,g(i)))},[e,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("")}}},x9e=({snippetNames:e,onSelect:A,onCancel:t,isOpen:i})=>{const[n,o]=V.useState(""),[s,r]=V.useState("");if(!i)return null;const a=e.filter(I=>I.toLowerCase().includes(s.toLowerCase())),g=s&&!e.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:t,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}`})]})]})})},_9e=e=>{const A=V.useRef(null),t=VI(i=>i.recentEvents);V.useEffect(()=>{if(t.length===0)return;const i=t[0];i.event_id!==A.current&&(e(i),A.current=i.event_id)},[t,e])};function k9e(e){const A=F9e(e),t=V.forwardRef((i,n)=>{const{children:o,...s}=i,r=V.Children.toArray(o),a=r.find(R9e);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 t.displayName=`${e}.Slot`,t}function F9e(e){const A=V.forwardRef((t,i)=>{const{children:n,...o}=t;if(V.isValidElement(n)){const s=N9e(n),r=M9e(o,n.props);return n.type!==V.Fragment&&(r.ref=i?Bf(i,s):s),V.cloneElement(n,r)}return V.Children.count(n)>1?V.Children.only(null):null});return A.displayName=`${e}.SlotClone`,A}var G9e=Symbol("radix.slottable");function R9e(e){return V.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===G9e}function M9e(e,A){const t={...A};for(const i in A){const n=e[i],o=A[i];/^on[A-Z]/.test(i)?n&&o?t[i]=(...r)=>{const a=o(...r);return n(...r),a}:n&&(t[i]=n):i==="style"?t[i]={...n,...o}:i==="className"&&(t[i]=[n,o].filter(Boolean).join(" "))}return{...e,...t}}function N9e(e){let A=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,t=A&&"isReactWarning"in A&&A.isReactWarning;return t?e.ref:(A=Object.getOwnPropertyDescriptor(e,"ref")?.get,t=A&&"isReactWarning"in A&&A.isReactWarning,t?e.props.ref:e.props.ref||e.ref)}var X9="Dialog",[QIt,hIt]=Om(X9),[v9e,pw]=QIt(X9),EIt=e=>{const{__scopeDialog:A,children:t,open:i,defaultOpen:n,onOpenChange:o,modal:s=!0}=e,r=V.useRef(null),a=V.useRef(null),[g,c]=qx({prop:i,defaultProp:n??!1,onChange:o,caller:X9});return W.jsx(v9e,{scope:A,triggerRef:r,contentRef:a,contentId:_E(),titleId:_E(),descriptionId:_E(),open:g,onOpenChange:c,onOpenToggle:V.useCallback(()=>c(I=>!I),[c]),modal:s,children:t})};EIt.displayName=X9;var uIt="DialogTrigger",dIt=V.forwardRef((e,A)=>{const{__scopeDialog:t,...i}=e,n=pw(uIt,t),o=fI(A,n.triggerRef);return W.jsx(Wa.button,{type:"button","aria-haspopup":"dialog","aria-expanded":n.open,"aria-controls":n.contentId,"data-state":$fA(n.open),...i,ref:o,onClick:Hn(e.onClick,n.onOpenToggle)})});dIt.displayName=uIt;var zfA="DialogPortal",[L9e,pIt]=QIt(zfA,{forceMount:void 0}),fIt=e=>{const{__scopeDialog:A,forceMount:t,children:i,container:n}=e,o=pw(zfA,A);return W.jsx(L9e,{scope:A,forceMount:t,children:V.Children.map(i,s=>W.jsx(w0,{present:t||o.open,children:W.jsx(VZ,{asChild:!0,container:n,children:s})}))})};fIt.displayName=zfA;var $9="DialogOverlay",yIt=V.forwardRef((e,A)=>{const t=pIt($9,e.__scopeDialog),{forceMount:i=t.forceMount,...n}=e,o=pw($9,e.__scopeDialog);return o.modal?W.jsx(w0,{present:i||o.open,children:W.jsx(H9e,{...n,ref:A})}):null});yIt.displayName=$9;var U9e=k9e("DialogOverlay.RemoveScroll"),H9e=V.forwardRef((e,A)=>{const{__scopeDialog:t,...i}=e,n=pw($9,t);return W.jsx(iV,{as:U9e,allowPinchZoom:!0,shards:[n.contentRef],children:W.jsx(Wa.div,{"data-state":$fA(n.open),...i,ref:A,style:{pointerEvents:"auto",...i.style}})})}),UG="DialogContent",mIt=V.forwardRef((e,A)=>{const t=pIt(UG,e.__scopeDialog),{forceMount:i=t.forceMount,...n}=e,o=pw(UG,e.__scopeDialog);return W.jsx(w0,{present:i||o.open,children:o.modal?W.jsx(Y9e,{...n,ref:A}):W.jsx(J9e,{...n,ref:A})})});mIt.displayName=UG;var Y9e=V.forwardRef((e,A)=>{const t=pw(UG,e.__scopeDialog),i=V.useRef(null),n=fI(A,t.contentRef,i);return V.useEffect(()=>{const o=i.current;if(o)return zuA(o)},[]),W.jsx(wIt,{...e,ref:n,trapFocus:t.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Hn(e.onCloseAutoFocus,o=>{o.preventDefault(),t.triggerRef.current?.focus()}),onPointerDownOutside:Hn(e.onPointerDownOutside,o=>{const s=o.detail.originalEvent,r=s.button===0&&s.ctrlKey===!0;(s.button===2||r)&&o.preventDefault()}),onFocusOutside:Hn(e.onFocusOutside,o=>o.preventDefault())})}),J9e=V.forwardRef((e,A)=>{const t=pw(UG,e.__scopeDialog),i=V.useRef(!1),n=V.useRef(!1);return W.jsx(wIt,{...e,ref:A,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:o=>{e.onCloseAutoFocus?.(o),o.defaultPrevented||(i.current||t.triggerRef.current?.focus(),o.preventDefault()),i.current=!1,n.current=!1},onInteractOutside:o=>{e.onInteractOutside?.(o),o.defaultPrevented||(i.current=!0,o.detail.originalEvent.type==="pointerdown"&&(n.current=!0));const s=o.target;t.triggerRef.current?.contains(s)&&o.preventDefault(),o.detail.originalEvent.type==="focusin"&&n.current&&o.preventDefault()}})}),wIt=V.forwardRef((e,A)=>{const{__scopeDialog:t,trapFocus:i,onOpenAutoFocus:n,onCloseAutoFocus:o,...s}=e,r=pw(UG,t),a=V.useRef(null),g=fI(A,a);return GuA(),W.jsxs(W.Fragment,{children:[W.jsx(vZ,{asChild:!0,loop:!0,trapped:i,onMountAutoFocus:n,onUnmountAutoFocus:o,children:W.jsx(sY,{role:"dialog",id:r.contentId,"aria-describedby":r.descriptionId,"aria-labelledby":r.titleId,"data-state":$fA(r.open),...s,ref:g,onDismiss:()=>r.onOpenChange(!1)})}),W.jsxs(W.Fragment,{children:[W.jsx(K9e,{titleId:r.titleId}),W.jsx(q9e,{contentRef:a,descriptionId:r.descriptionId})]})]})}),XfA="DialogTitle",DIt=V.forwardRef((e,A)=>{const{__scopeDialog:t,...i}=e,n=pw(XfA,t);return W.jsx(Wa.h2,{id:n.titleId,...i,ref:A})});DIt.displayName=XfA;var SIt="DialogDescription",bIt=V.forwardRef((e,A)=>{const{__scopeDialog:t,...i}=e,n=pw(SIt,t);return W.jsx(Wa.p,{id:n.descriptionId,...i,ref:A})});bIt.displayName=SIt;var xIt="DialogClose",_It=V.forwardRef((e,A)=>{const{__scopeDialog:t,...i}=e,n=pw(xIt,t);return W.jsx(Wa.button,{type:"button",...i,ref:A,onClick:Hn(e.onClick,()=>n.onOpenChange(!1))})});_It.displayName=xIt;function $fA(e){return e?"open":"closed"}var kIt="DialogTitleWarning",[T9e,FIt]=r6t(kIt,{contentName:UG,titleName:XfA,docsSlug:"dialog"}),K9e=({titleId:e})=>{const A=FIt(kIt),t=`\`${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 ${e.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(!t),title:`Download options for ${e.constructor.name}`,children:e.constructor.name}),t&&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"})]})]})},lIt=e=>e.activeSubSolver?[e,...lIt(e.activeSubSolver)]:[e],c9e=({solver:e})=>{const A=lIt(e);return W.jsx("div",{className:"flex gap-1 items-center text-sm pt-1",children:A.map((t,i)=>W.jsxs("div",{className:"flex items-center",children:[i>0&&W.jsx("span",{className:"text-gray-400 mx-1",children:"→"}),W.jsx(g9e,{solver:t})]},t.constructor.name))})},I9e=({solver:e,triggerRender:A,animationSpeed:t=25,onSolverStarted:i,onSolverCompleted:n})=>{const[o,s]=V.useReducer(Q=>!Q,!1),r=V.useRef(void 0),a=()=>{!e.solved&&!e.failed&&(e.step(),A())},g=()=>{!e.solved&&!e.failed&&(i&&i(e),e.solve(),A(),n&&n(e))},c=()=>{o?(r.current&&(clearInterval(r.current),r.current=void 0),s()):(s(),r.current=setInterval(()=>{if(e.solved||e.failed){r.current&&(clearInterval(r.current),r.current=void 0),s(),A(),n&&e.solved&&n(e);return}e.step(),A()},t))},I=()=>{const Q=e;if(Q.getCurrentPhase&&!e.solved&&!e.failed){const h=Q.getCurrentPhase();for(;Q.getCurrentPhase()===h&&!e.solved&&!e.failed;)e.step();A()}},l=()=>{if(e.solved||e.failed||o)return;const Q=window.prompt("Step until which iteration?",`${e.iterations}`);if(Q===null)return;const h=Number(Q);if(!Number.isFinite(h)){window.alert("Please enter a valid number for the iteration");return}for(;e.iterations<h&&!e.solved&&!e.failed;)e.step();A(),e.solved&&n&&n(e)};V.useEffect(()=>()=>{r.current&&clearInterval(r.current)},[]),V.useEffect(()=>{(e.solved||e.failed)&&o&&(r.current&&(clearInterval(r.current),r.current=void 0),s())},[e.solved,e.failed,o]);const B=e.getCurrentPhase!==void 0,C=B?e.getCurrentPhase():null;return W.jsxs("div",{className:"space-y-2 p-2 border-b",children:[W.jsx("div",{className:"flex items-center",children:W.jsx(c9e,{solver:e})}),W.jsxs("div",{className:"flex gap-2 items-center flex-wrap",children:[W.jsx("button",{onClick:a,disabled:e.solved||e.failed||o,className:"bg-blue-500 hover:bg-blue-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Step"}),W.jsx("button",{onClick:g,disabled:e.solved||e.failed||o,className:"bg-green-500 hover:bg-green-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Solve"}),W.jsx("button",{onClick:c,disabled:e.solved||e.failed,className:`px-3 py-1 rounded text-white text-sm ${o?"bg-red-500 hover:bg-red-600":"bg-yellow-500 hover:bg-yellow-600"} disabled:bg-gray-300`,children:o?"Stop":"Animate"}),W.jsx("button",{onClick:l,disabled:e.solved||e.failed||o,className:"bg-orange-500 hover:bg-orange-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Step Until Iteration"}),B&&W.jsx("button",{onClick:I,disabled:e.solved||e.failed||o,className:"bg-purple-500 hover:bg-purple-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Next Stage"}),W.jsxs("div",{className:"text-sm text-gray-600",children:["Iterations: ",e.iterations]}),e.timeToSolve!==void 0&&W.jsxs("div",{className:"text-sm text-gray-600",children:["Time: ",(e.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})]}),e.solved&&W.jsx("div",{className:"px-2 py-1 bg-green-100 text-green-800 rounded text-sm",children:"Solved"}),e.failed&&W.jsx("div",{className:"px-2 py-1 bg-red-100 text-red-800 rounded text-sm",children:"Failed"})]}),e.error&&W.jsxs("div",{className:"text-red-600 text-sm",children:["Error: ",e.error]})]})},l9e=(e,A,t)=>{const i=e.currentPipelineStepIndex;return A<i?"Completed":A===i&&e.activeSubSolver?e.activeSubSolver.failed?"Failed":"In Progress":"Not Started"},B9e=(e,A)=>{const i=e.pipelineDef[A].solverName,n=l9e(e,A),o=e[i],s=e.firstIterationOfPhase?.[i]??null,r=e.iterations;let a=0;if(n==="Completed"){const l=e.pipelineDef[A+1],B=l?e.firstIterationOfPhase?.[l.solverName]:void 0;B!==void 0&&s!==null?a=B-s:s!==null&&(a=r-s)}else n==="In Progress"&&s!==null&&(a=r-s);const g=e.timeSpentOnPhase?.[i]??0;let c=0;n==="Completed"?c=1:n==="In Progress"&&o&&(c=o.progress??0);const I=o?.stats??null;return{index:A,name:i,status:n,firstIteration:s,iterations:a,progress:c,timeSpent:g,stats:I&&Object.keys(I).length>0?I:null,solverInstance:o??null}},C9e=({status:e})=>{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[e]}`,children:e})},Q9e=({progress:e})=>{if(e===0)return null;const A=Math.round(e*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,"%"]})]})},h9e=e=>Object.entries(e).map(([A,t])=>`${A}: ${t}`).join(", "),E9e=({stats:e})=>{if(!e||Object.keys(e).length===0)return W.jsx("span",{children:"-"});const A=Object.entries(e),t=h9e(e);return W.jsxs("details",{className:"cursor-pointer",children:[W.jsx("summary",{className:"whitespace-nowrap overflow-hidden text-ellipsis max-w-[200px]",children:t}),W.jsx("div",{className:"mt-1 text-xs",children:A.map(([i,n])=>W.jsxs("div",{children:[i,": ",String(n)]},i))})]})},jfA=e=>{if(e===null||typeof e!="object")return e;if(Array.isArray(e))return e.map(jfA);const A={};for(const[t,i]of Object.entries(e))t.startsWith("_")||(A[t]=jfA(i));return A},u9e=(e,A)=>{try{if(typeof e.getConstructorParams!="function"){alert(`getConstructorParams() is not implemented for ${A}`);return}const t=jfA(e.getConstructorParams()),i=new Blob([JSON.stringify(t,null,2)],{type:"application/json"}),n=URL.createObjectURL(i),o=document.createElement("a");o.href=n,o.download=`${A}_input.json`,o.click(),URL.revokeObjectURL(n)}catch(t){alert(`Error downloading input for ${A}: ${t instanceof Error?t.message:String(t)}`)}},d9e=({solver:e,onStepUntilPhase:A,onDownloadInput:t})=>{const i=e.pipelineDef.map((r,a)=>B9e(e,a)),n=r=>{A?.(r)},o=r=>{r.solverInstance&&(t?t(r.solverInstance,r.name):u9e(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"||e.solved||e.failed,className:"text-blue-500 hover:text-blue-700 disabled:text-gray-300 disabled:cursor-not-allowed",title:`Step until ${r.name} completes`,children: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(C9e,{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(Q9e,{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(E9e,{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))})]})})]})},p9e=class extends en.Component{constructor(e){super(e),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(e){console.error("InteractiveGraphics render error:",e)}render(){return this.state.hasError?this.props.fallback:this.props.children}};function f9e({graphics:e}){const A=e.points??[],t=e.lines??[],i=e.rects??[],n=e.circles??[],o=e.texts??[];let s=Number.POSITIVE_INFINITY,r=Number.POSITIVE_INFINITY,a=Number.NEGATIVE_INFINITY,g=Number.NEGATIVE_INFINITY;const c=(h,E)=>{typeof h=="number"&&(h<s&&(s=h),h>a&&(a=h)),typeof E=="number"&&(E<r&&(r=E),E>g&&(g=E))};for(const h of A)c(h.x,h.y);for(const h of t){const E=h.points??[];for(const u of E)c(u.x,u.y)}for(const h of i){const E=h.x??0,u=h.y??0,d=h.width??0,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}`)),t.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 y9e=({solver:e,animationSpeed:A=25,onSolverStarted:t,onSolverCompleted:i})=>{const[n,o]=V.useReducer(c=>c+1,0),s=V.useMemo(()=>{try{return e.visualize()||{points:[],lines:[],rects:[],circles:[]}}catch(c){return console.error("Visualization error:",c),{points:[],lines:[],rects:[],circles:[]}}},[e,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=e.pipelineDef!==void 0,g=c=>{const I=e;if(!e.solved&&!e.failed){for(;!e.solved&&!e.failed&&I.currentPipelineStepIndex<=I.pipelineDef.findIndex(l=>l.solverName===c);)e.step();o()}};return W.jsxs("div",{children:[W.jsx(I9e,{solver:e,triggerRender:o,animationSpeed:A,onSolverStarted:t,onSolverCompleted:i}),r?W.jsx("div",{className:"p-4 text-gray-500",children:"No Graphics Yet"}):W.jsx(p9e,{fallback:W.jsx(f9e,{graphics:s}),children:W.jsx(a9e,{graphics:s})}),a&&W.jsx(d9e,{solver:e,onStepUntilPhase:g})]})};const m9e=()=>{V.useEffect(()=>{const e="tailwind-cdn-script";if(document.getElementById(e)||window.tailwind)return;const A=document.createElement("div");A.className="hidden",document.body.appendChild(A);const t=window.getComputedStyle(A).display==="none";if(document.body.removeChild(A),t)return;const i=document.createElement("script");i.id=e,i.src="https://cdn.tailwindcss.com",document.head.appendChild(i)},[])},w9e=e=>e.toLowerCase().includes("pack")?NMe:e.toLowerCase().includes("rout")?YMe:pMe,D9e=({solverEvents:e=[]})=>{const[A,t]=V.useState(null);m9e();const i=V.useMemo(()=>{const r=new Map;for(const a of e){const g=`${a.componentName}-${a.solverName}`;r.set(g,a)}return r},[e]),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=AoA[o.solverName];if(!r)return{instance:null,error:`Solver class "${o.solverName}" not found in SOLVERS registry. Available: ${Object.keys(AoA).join(", ")}`,classFound:!1};try{const a=o.solverParams,g=a?.input!==void 0?a.input:a;return{instance:new r(g),error:null,classFound:!0}}catch(a){const g=a instanceof Error?a.message:String(a);return console.error("Failed to reconstruct solver:",a),{instance:null,error:`Failed to instantiate solver: ${g}`,classFound:!0}}},[o]);return e.length===0?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:()=>t(r),children:(()=>{const c=w9e(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(qy,{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(y9e,{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"})})})]})},BIt=({errorMessage:e,errorStack:A,circuitJsonErrors:t})=>{V.useEffect(()=>{if(e){const i=new Error(e);A&&(i.stack=A);try{J5.captureException(i)}catch{}}},[e,A]),V.useEffect(()=>{if(t&&t.length>0)for(const i of t){const n=new Error(i.message||"Circuit JSON Error");i.stack&&(n.stack=i.stack);try{J5.captureException(n,{error_type:i.type})}catch{}}},[t])},CIt="0.0.1588",S9e={version:CIt},z9=xYA()(_YA(e=>({lastRunEvalVersion:void 0,setLastRunEvalVersion:A=>{e({lastRunEvalVersion:A})}}),{name:"runframe-runner-store"})),b9e=e=>{const[A,t]=V.useState([]),[i,n]=V.useState(null),[o,s]=V.useState(""),[r,a]=c1("eval-version-selection",null),g=z9(B=>B.setLastRunEvalVersion),c=z9(B=>B.lastRunEvalVersion);return V.useEffect(()=>{e&&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)),t(C)}}).catch(()=>{})},[e]),V.useEffect(()=>{e&&(r?(window.TSCIRCUIT_LATEST_EVAL_VERSION=r,g(r)):i&&(window.TSCIRCUIT_LATEST_EVAL_VERSION=i,g(i)))},[e,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("")}}},x9e=({snippetNames:e,onSelect:A,onCancel:t,isOpen:i})=>{const[n,o]=V.useState(""),[s,r]=V.useState("");if(!i)return null;const a=e.filter(I=>I.toLowerCase().includes(s.toLowerCase())),g=s&&!e.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:t,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}`})]})]})})},_9e=e=>{const A=V.useRef(null),t=VI(i=>i.recentEvents);V.useEffect(()=>{if(t.length===0)return;const i=t[0];i.event_id!==A.current&&(e(i),A.current=i.event_id)},[t,e])};function k9e(e){const A=F9e(e),t=V.forwardRef((i,n)=>{const{children:o,...s}=i,r=V.Children.toArray(o),a=r.find(R9e);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 t.displayName=`${e}.Slot`,t}function F9e(e){const A=V.forwardRef((t,i)=>{const{children:n,...o}=t;if(V.isValidElement(n)){const s=N9e(n),r=M9e(o,n.props);return n.type!==V.Fragment&&(r.ref=i?Bf(i,s):s),V.cloneElement(n,r)}return V.Children.count(n)>1?V.Children.only(null):null});return A.displayName=`${e}.SlotClone`,A}var G9e=Symbol("radix.slottable");function R9e(e){return V.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===G9e}function M9e(e,A){const t={...A};for(const i in A){const n=e[i],o=A[i];/^on[A-Z]/.test(i)?n&&o?t[i]=(...r)=>{const a=o(...r);return n(...r),a}:n&&(t[i]=n):i==="style"?t[i]={...n,...o}:i==="className"&&(t[i]=[n,o].filter(Boolean).join(" "))}return{...e,...t}}function N9e(e){let A=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,t=A&&"isReactWarning"in A&&A.isReactWarning;return t?e.ref:(A=Object.getOwnPropertyDescriptor(e,"ref")?.get,t=A&&"isReactWarning"in A&&A.isReactWarning,t?e.props.ref:e.props.ref||e.ref)}var X9="Dialog",[QIt,hIt]=Om(X9),[v9e,pw]=QIt(X9),EIt=e=>{const{__scopeDialog:A,children:t,open:i,defaultOpen:n,onOpenChange:o,modal:s=!0}=e,r=V.useRef(null),a=V.useRef(null),[g,c]=qx({prop:i,defaultProp:n??!1,onChange:o,caller:X9});return W.jsx(v9e,{scope:A,triggerRef:r,contentRef:a,contentId:_E(),titleId:_E(),descriptionId:_E(),open:g,onOpenChange:c,onOpenToggle:V.useCallback(()=>c(I=>!I),[c]),modal:s,children:t})};EIt.displayName=X9;var uIt="DialogTrigger",dIt=V.forwardRef((e,A)=>{const{__scopeDialog:t,...i}=e,n=pw(uIt,t),o=fI(A,n.triggerRef);return W.jsx(Wa.button,{type:"button","aria-haspopup":"dialog","aria-expanded":n.open,"aria-controls":n.contentId,"data-state":$fA(n.open),...i,ref:o,onClick:Hn(e.onClick,n.onOpenToggle)})});dIt.displayName=uIt;var zfA="DialogPortal",[L9e,pIt]=QIt(zfA,{forceMount:void 0}),fIt=e=>{const{__scopeDialog:A,forceMount:t,children:i,container:n}=e,o=pw(zfA,A);return W.jsx(L9e,{scope:A,forceMount:t,children:V.Children.map(i,s=>W.jsx(w0,{present:t||o.open,children:W.jsx(VZ,{asChild:!0,container:n,children:s})}))})};fIt.displayName=zfA;var $9="DialogOverlay",yIt=V.forwardRef((e,A)=>{const t=pIt($9,e.__scopeDialog),{forceMount:i=t.forceMount,...n}=e,o=pw($9,e.__scopeDialog);return o.modal?W.jsx(w0,{present:i||o.open,children:W.jsx(H9e,{...n,ref:A})}):null});yIt.displayName=$9;var U9e=k9e("DialogOverlay.RemoveScroll"),H9e=V.forwardRef((e,A)=>{const{__scopeDialog:t,...i}=e,n=pw($9,t);return W.jsx(iV,{as:U9e,allowPinchZoom:!0,shards:[n.contentRef],children:W.jsx(Wa.div,{"data-state":$fA(n.open),...i,ref:A,style:{pointerEvents:"auto",...i.style}})})}),UG="DialogContent",mIt=V.forwardRef((e,A)=>{const t=pIt(UG,e.__scopeDialog),{forceMount:i=t.forceMount,...n}=e,o=pw(UG,e.__scopeDialog);return W.jsx(w0,{present:i||o.open,children:o.modal?W.jsx(Y9e,{...n,ref:A}):W.jsx(J9e,{...n,ref:A})})});mIt.displayName=UG;var Y9e=V.forwardRef((e,A)=>{const t=pw(UG,e.__scopeDialog),i=V.useRef(null),n=fI(A,t.contentRef,i);return V.useEffect(()=>{const o=i.current;if(o)return zuA(o)},[]),W.jsx(wIt,{...e,ref:n,trapFocus:t.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Hn(e.onCloseAutoFocus,o=>{o.preventDefault(),t.triggerRef.current?.focus()}),onPointerDownOutside:Hn(e.onPointerDownOutside,o=>{const s=o.detail.originalEvent,r=s.button===0&&s.ctrlKey===!0;(s.button===2||r)&&o.preventDefault()}),onFocusOutside:Hn(e.onFocusOutside,o=>o.preventDefault())})}),J9e=V.forwardRef((e,A)=>{const t=pw(UG,e.__scopeDialog),i=V.useRef(!1),n=V.useRef(!1);return W.jsx(wIt,{...e,ref:A,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:o=>{e.onCloseAutoFocus?.(o),o.defaultPrevented||(i.current||t.triggerRef.current?.focus(),o.preventDefault()),i.current=!1,n.current=!1},onInteractOutside:o=>{e.onInteractOutside?.(o),o.defaultPrevented||(i.current=!0,o.detail.originalEvent.type==="pointerdown"&&(n.current=!0));const s=o.target;t.triggerRef.current?.contains(s)&&o.preventDefault(),o.detail.originalEvent.type==="focusin"&&n.current&&o.preventDefault()}})}),wIt=V.forwardRef((e,A)=>{const{__scopeDialog:t,trapFocus:i,onOpenAutoFocus:n,onCloseAutoFocus:o,...s}=e,r=pw(UG,t),a=V.useRef(null),g=fI(A,a);return GuA(),W.jsxs(W.Fragment,{children:[W.jsx(vZ,{asChild:!0,loop:!0,trapped:i,onMountAutoFocus:n,onUnmountAutoFocus:o,children:W.jsx(sY,{role:"dialog",id:r.contentId,"aria-describedby":r.descriptionId,"aria-labelledby":r.titleId,"data-state":$fA(r.open),...s,ref:g,onDismiss:()=>r.onOpenChange(!1)})}),W.jsxs(W.Fragment,{children:[W.jsx(K9e,{titleId:r.titleId}),W.jsx(q9e,{contentRef:a,descriptionId:r.descriptionId})]})]})}),XfA="DialogTitle",DIt=V.forwardRef((e,A)=>{const{__scopeDialog:t,...i}=e,n=pw(XfA,t);return W.jsx(Wa.h2,{id:n.titleId,...i,ref:A})});DIt.displayName=XfA;var SIt="DialogDescription",bIt=V.forwardRef((e,A)=>{const{__scopeDialog:t,...i}=e,n=pw(SIt,t);return W.jsx(Wa.p,{id:n.descriptionId,...i,ref:A})});bIt.displayName=SIt;var xIt="DialogClose",_It=V.forwardRef((e,A)=>{const{__scopeDialog:t,...i}=e,n=pw(xIt,t);return W.jsx(Wa.button,{type:"button",...i,ref:A,onClick:Hn(e.onClick,()=>n.onOpenChange(!1))})});_It.displayName=xIt;function $fA(e){return e?"open":"closed"}var kIt="DialogTitleWarning",[T9e,FIt]=r6t(kIt,{contentName:UG,titleName:XfA,docsSlug:"dialog"}),K9e=({titleId:e})=>{const A=FIt(kIt),t=`\`${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