@tscircuit/runframe 0.0.1556 → 0.0.1557

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.
@@ -5380,7 +5380,7 @@ svg { font-family: 'Inter', 'Helvetica Neue', Arial, sans-serif; }
5380
5380
  `+a+" | "+YdA("",o.column-1," ")+YdA("",c,"^")}else A+=`
5381
5381
  at `+s}return A},pV.buildMessage=function(e,A){var t={literal:function(g){return'"'+o(g.text)+'"'},class:function(g){var I=g.parts.map(function(c){return Array.isArray(c)?n(c[0])+"-"+n(c[1]):n(c)});return"["+(g.inverted?"^":"")+I.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 o(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(I){return"\\x0"+i(I)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(I){return"\\x"+i(I)})}function n(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(I){return"\\x0"+i(I)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(I){return"\\x"+i(I)})}function s(g){return t[g.type](g)}function r(g){var I=g.map(s),c,B;if(I.sort(),I.length>0){for(c=1,B=1;c<I.length;c++)I[c-1]!==I[c]&&(I[B]=I[c],B++);I.length=B}switch(I.length){case 1:return I[0];case 2:return I[0]+" or "+I[1];default:return I.slice(0,-1).join(", ")+", or "+I[I.length-1]}}function a(g){return g?'"'+o(g)+'"':"end of input"}return"Expected "+r(e)+" but "+a(A)+" found."};const KKe={},Grt=e=>{let A;const t=new Set,i=(I,c)=>{const B=typeof I=="function"?I(A):I;if(!Object.is(B,A)){const l=A;A=c??(typeof B!="object"||B===null)?B:Object.assign({},A,B),t.forEach(C=>C(A,l))}},o=()=>A,a={setState:i,getState:o,getInitialState:()=>g,subscribe:I=>(t.add(I),()=>t.delete(I)),destroy:()=>{(KKe?"production":void 0)!=="production"&&console.warn("[DEPRECATED] The `destroy` method will be unsupported in a future version. Instead use unsubscribe function returned by subscribe. Everything will be garbage-collected if store is garbage-collected."),t.clear()}},g=A=e(i,o,a);return a},Frt=e=>e?Grt(e):Grt;var fV={exports:{}},JdA={},yV={exports:{}},TdA={};var Rrt;function PKe(){if(Rrt)return TdA;Rrt=1;var e=e0();function A(c,B){return c===B&&(c!==0||1/c===1/B)||c!==c&&B!==B}var t=typeof Object.is=="function"?Object.is:A,i=e.useState,o=e.useEffect,n=e.useLayoutEffect,s=e.useDebugValue;function r(c,B){var l=B(),C=i({inst:{value:l,getSnapshot:B}}),E=C[0].inst,Q=C[1];return n(function(){E.value=l,E.getSnapshot=B,a(E)&&Q({inst:E})},[c,l,B]),o(function(){return a(E)&&Q({inst:E}),c(function(){a(E)&&Q({inst:E})})},[c]),s(l),l}function a(c){var B=c.getSnapshot;c=c.value;try{var l=B();return!t(c,l)}catch{return!0}}function g(c,B){return B()}var I=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?g:r;return TdA.useSyncExternalStore=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:I,TdA}var KdA={},Mrt;function qKe(){if(Mrt)return KdA;Mrt=1;var e={env:{}};return e.env.NODE_ENV!=="production"&&(function(){function A(C,E){return C===E&&(C!==0||1/C===1/E)||C!==C&&E!==E}function t(C,E){c||n.startTransition===void 0||(c=!0,console.error("You are using an outdated, pre-release alpha of React 18 that does not support useSyncExternalStore. The use-sync-external-store shim will not work correctly. Upgrade to a newer pre-release."));var Q=E();if(!B){var h=E();s(Q,h)||(console.error("The result of getSnapshot should be cached to avoid an infinite loop"),B=!0)}h=r({inst:{value:Q,getSnapshot:E}});var u=h[0].inst,d=h[1];return g(function(){u.value=Q,u.getSnapshot=E,i(u)&&d({inst:u})},[C,Q,E]),a(function(){return i(u)&&d({inst:u}),C(function(){i(u)&&d({inst:u})})},[C]),I(Q),Q}function i(C){var E=C.getSnapshot;C=C.value;try{var Q=E();return!s(C,Q)}catch{return!0}}function o(C,E){return E()}typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());var n=e0(),s=typeof Object.is=="function"?Object.is:A,r=n.useState,a=n.useEffect,g=n.useLayoutEffect,I=n.useDebugValue,c=!1,B=!1,l=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?o:t;KdA.useSyncExternalStore=n.useSyncExternalStore!==void 0?n.useSyncExternalStore:l,typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error())})(),KdA}var Nrt;function vrt(){if(Nrt)return yV.exports;Nrt=1;var e={env:{}};return e.env.NODE_ENV==="production"?yV.exports=PKe():yV.exports=qKe(),yV.exports}var Lrt;function OKe(){if(Lrt)return JdA;Lrt=1;var e=e0(),A=vrt();function t(g,I){return g===I&&(g!==0||1/g===1/I)||g!==g&&I!==I}var i=typeof Object.is=="function"?Object.is:t,o=A.useSyncExternalStore,n=e.useRef,s=e.useEffect,r=e.useMemo,a=e.useDebugValue;return JdA.useSyncExternalStoreWithSelector=function(g,I,c,B,l){var C=n(null);if(C.current===null){var E={hasValue:!1,value:null};C.current=E}else E=C.current;C=r(function(){function h(w){if(!u){if(u=!0,d=w,w=B(w),l!==void 0&&E.hasValue){var D=E.value;if(l(D,w))return f=D}return f=w}if(D=f,i(d,w))return D;var b=B(w);return l!==void 0&&l(D,b)?(d=w,D):(d=w,f=b)}var u=!1,d,f,m=c===void 0?null:c;return[function(){return h(I())},m===null?void 0:function(){return h(m())}]},[I,c,B,l]);var Q=o(g,C[0],C[1]);return s(function(){E.hasValue=!0,E.value=Q},[Q]),a(Q),Q},JdA}var PdA={},Urt;function WKe(){if(Urt)return PdA;Urt=1;var e={env:{}};return e.env.NODE_ENV!=="production"&&(function(){function A(I,c){return I===c&&(I!==0||1/I===1/c)||I!==I&&c!==c}typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());var t=e0(),i=vrt(),o=typeof Object.is=="function"?Object.is:A,n=i.useSyncExternalStore,s=t.useRef,r=t.useEffect,a=t.useMemo,g=t.useDebugValue;PdA.useSyncExternalStoreWithSelector=function(I,c,B,l,C){var E=s(null);if(E.current===null){var Q={hasValue:!1,value:null};E.current=Q}else Q=E.current;E=a(function(){function u(D){if(!d){if(d=!0,f=D,D=l(D),C!==void 0&&Q.hasValue){var b=Q.value;if(C(b,D))return m=b}return m=D}if(b=m,o(f,D))return b;var k=l(D);return C!==void 0&&C(b,k)?(f=D,b):(f=D,m=k)}var d=!1,f,m,w=B===void 0?null:B;return[function(){return u(c())},w===null?void 0:function(){return u(w())}]},[c,B,l,C]);var h=n(I,E[0],E[1]);return r(function(){Q.hasValue=!0,Q.value=h},[h]),g(h),h},typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error())})(),PdA}var Hrt;function ZKe(){if(Hrt)return fV.exports;Hrt=1;var e={env:{}};return e.env.NODE_ENV==="production"?fV.exports=OKe():fV.exports=WKe(),fV.exports}var VKe=ZKe();const jKe=t0(VKe),Yrt={},{useDebugValue:zKe}=eo,{useSyncExternalStoreWithSelector:XKe}=jKe;let Jrt=!1;const $Ke=e=>e;function Trt(e,A=$Ke,t){(Yrt?"production":void 0)!=="production"&&t&&!Jrt&&(console.warn("[DEPRECATED] Use `createWithEqualityFn` instead of `create` or use `useStoreWithEqualityFn` instead of `useStore`. They can be imported from 'zustand/traditional'. https://github.com/pmndrs/zustand/discussions/1937"),Jrt=!0);const i=XKe(e.subscribe,e.getState,e.getServerState||e.getInitialState,A,t);return zKe(i),i}const APe=e=>{(Yrt?"production":void 0)!=="production"&&typeof e!="function"&&console.warn("[DEPRECATED] Passing a vanilla store will be unsupported in a future version. Instead use `import { useStore } from 'zustand'`.");const A=typeof e=="function"?Frt(e):e,t=(i,o)=>Trt(A,i,o);return Object.assign(t,A),t},Krt=e=>APe,MY=e=>typeof e=="number"&&!isNaN(e),cF=e=>typeof e=="string",m0=e=>typeof e=="function",mV=e=>cF(e)||m0(e)?e:null,qdA=e=>AA.isValidElement(e)||cF(e)||m0(e)||MY(e);function tPe(e,A,t){t===void 0&&(t=300);const{scrollHeight:i,style:o}=e;requestAnimationFrame(()=>{o.minHeight="initial",o.height=i+"px",o.transition=`all ${t}ms`,requestAnimationFrame(()=>{o.height="0",o.padding="0",o.margin="0",setTimeout(A,t)})})}function wV(e){let{enter:A,exit:t,appendPosition:i=!1,collapse:o=!0,collapseDuration:n=300}=e;return function(s){let{children:r,position:a,preventExitTransition:g,done:I,nodeRef:c,isIn:B,playToast:l}=s;const C=i?`${A}--${a}`:A,E=i?`${t}--${a}`:t,Q=AA.useRef(0);return AA.useLayoutEffect(()=>{const h=c.current,u=C.split(" "),d=f=>{f.target===c.current&&(l(),h.removeEventListener("animationend",d),h.removeEventListener("animationcancel",d),Q.current===0&&f.type!=="animationcancel"&&h.classList.remove(...u))};h.classList.add(...u),h.addEventListener("animationend",d),h.addEventListener("animationcancel",d)},[]),AA.useEffect(()=>{const h=c.current,u=()=>{h.removeEventListener("animationend",u),o?tPe(h,I,n):I()};B||(g?u():(Q.current=1,h.className+=` ${E}`,h.addEventListener("animationend",u)))},[B]),eo.createElement(eo.Fragment,null,r)}}function Prt(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 Yd=new Map;let NY=[];const OdA=new Set,ePe=e=>OdA.forEach(A=>A(e)),qrt=()=>Yd.size>0;function Ort(e,A){var t;if(A)return!((t=Yd.get(A))==null||!t.isToastActive(e));let i=!1;return Yd.forEach(o=>{o.isToastActive(e)&&(i=!0)}),i}function Wrt(e,A){qdA(e)&&(qrt()||NY.push({content:e,options:A}),Yd.forEach(t=>{t.buildToast(e,A)}))}function Zrt(e,A){Yd.forEach(t=>{A!=null&&A!=null&&A.containerId?A?.containerId===t.id&&t.toggle(e,A?.id):t.toggle(e,A?.id)})}function iPe(e){const{subscribe:A,getSnapshot:t,setProps:i}=AA.useRef((function(n){const s=n.containerId||1;return{subscribe(r){const a=(function(I,c,B){let l=1,C=0,E=[],Q=[],h=[],u=c;const d=new Map,f=new Set,m=()=>{h=Array.from(d.values()),f.forEach(b=>b())},w=b=>{Q=b==null?[]:Q.filter(k=>k!==b),m()},D=b=>{const{toastId:k,onOpen:x,updateId:N,children:M}=b.props,U=N==null;b.staleId&&d.delete(b.staleId),d.set(k,b),Q=[...Q,b.props.toastId].filter(J=>J!==b.staleId),m(),B(Prt(b,U?"added":"updated")),U&&m0(x)&&x(AA.isValidElement(M)&&M.props)};return{id:I,props:u,observe:b=>(f.add(b),()=>f.delete(b)),toggle:(b,k)=>{d.forEach(x=>{k!=null&&k!==x.props.toastId||m0(x.toggle)&&x.toggle(b)})},removeToast:w,toasts:d,clearQueue:()=>{C-=E.length,E=[]},buildToast:(b,k)=>{if((nA=>{let{containerId:rA,toastId:QA,updateId:SA}=nA;const FA=rA?rA!==I:I!==1,MA=d.has(QA)&&SA==null;return FA||MA})(k))return;const{toastId:x,updateId:N,data:M,staleId:U,delay:J}=k,H=()=>{w(x)},O=N==null;O&&C++;const W={...u,style:u.toastStyle,key:l++,...Object.fromEntries(Object.entries(k).filter(nA=>{let[rA,QA]=nA;return QA!=null})),toastId:x,updateId:N,data:M,closeToast:H,isIn:!1,className:mV(k.className||u.toastClassName),bodyClassName:mV(k.bodyClassName||u.bodyClassName),progressClassName:mV(k.progressClassName||u.progressClassName),autoClose:!k.isLoading&&($=k.autoClose,iA=u.autoClose,$===!1||MY($)&&$>0?$:iA),deleteToast(){const nA=d.get(x),{onClose:rA,children:QA}=nA.props;m0(rA)&&rA(AA.isValidElement(QA)&&QA.props),B(Prt(nA,"removed")),d.delete(x),C--,C<0&&(C=0),E.length>0?D(E.shift()):m()}};var $,iA;W.closeButton=u.closeButton,k.closeButton===!1||qdA(k.closeButton)?W.closeButton=k.closeButton:k.closeButton===!0&&(W.closeButton=!qdA(u.closeButton)||u.closeButton);let gA=b;AA.isValidElement(b)&&!cF(b.type)?gA=AA.cloneElement(b,{closeToast:H,toastProps:W,data:M}):m0(b)&&(gA=b({closeToast:H,toastProps:W,data:M}));const tA={content:gA,props:W,staleId:U};u.limit&&u.limit>0&&C>u.limit&&O?E.push(tA):MY(J)?setTimeout(()=>{D(tA)},J):D(tA)},setProps(b){u=b},setToggle:(b,k)=>{d.get(b).toggle=k},isToastActive:b=>Q.some(k=>k===b),getSnapshot:()=>h}})(s,n,ePe);Yd.set(s,a);const g=a.observe(r);return NY.forEach(I=>Wrt(I.content,I.options)),NY=[],()=>{g(),Yd.delete(s)}},setProps(r){var a;(a=Yd.get(s))==null||a.setProps(r)},getSnapshot(){var r;return(r=Yd.get(s))==null?void 0:r.getSnapshot()}}})(e)).current;i(e);const o=AA.useSyncExternalStore(A,t,t);return{getToastToRender:function(n){if(!o)return[];const s=new Map;return e.newestOnTop&&o.reverse(),o.forEach(r=>{const{position:a}=r.props;s.has(a)||s.set(a,[]),s.get(a).push(r)}),Array.from(s,r=>n(r[0],r[1]))},isToastActive:Ort,count:o?.length}}function oPe(e){const[A,t]=AA.useState(!1),[i,o]=AA.useState(!1),n=AA.useRef(null),s=AA.useRef({start:0,delta:0,removalDistance:0,canCloseOnClick:!0,canDrag:!1,didMove:!1}).current,{autoClose:r,pauseOnHover:a,closeToast:g,onClick:I,closeOnClick:c}=e;var B,l;function C(){t(!0)}function E(){t(!1)}function Q(d){const f=n.current;s.canDrag&&f&&(s.didMove=!0,A&&E(),s.delta=e.draggableDirection==="x"?d.clientX-s.start:d.clientY-s.start,s.start!==d.clientX&&(s.canCloseOnClick=!1),f.style.transform=`translate3d(${e.draggableDirection==="x"?`${s.delta}px, var(--y)`:`0, calc(${s.delta}px + var(--y))`},0)`,f.style.opacity=""+(1-Math.abs(s.delta/s.removalDistance)))}function h(){document.removeEventListener("pointermove",Q),document.removeEventListener("pointerup",h);const d=n.current;if(s.canDrag&&s.didMove&&d){if(s.canDrag=!1,Math.abs(s.delta)>s.removalDistance)return o(!0),e.closeToast(),void e.collapseAll();d.style.transition="transform 0.2s, opacity 0.2s",d.style.removeProperty("transform"),d.style.removeProperty("opacity")}}(l=Yd.get((B={id:e.toastId,containerId:e.containerId,fn:t}).containerId||1))==null||l.setToggle(B.id,B.fn),AA.useEffect(()=>{if(e.pauseOnFocusLoss)return document.hasFocus()||E(),window.addEventListener("focus",C),window.addEventListener("blur",E),()=>{window.removeEventListener("focus",C),window.removeEventListener("blur",E)}},[e.pauseOnFocusLoss]);const u={onPointerDown:function(d){if(e.draggable===!0||e.draggable===d.pointerType){s.didMove=!1,document.addEventListener("pointermove",Q),document.addEventListener("pointerup",h);const f=n.current;s.canCloseOnClick=!0,s.canDrag=!0,f.style.transition="none",e.draggableDirection==="x"?(s.start=d.clientX,s.removalDistance=f.offsetWidth*(e.draggablePercent/100)):(s.start=d.clientY,s.removalDistance=f.offsetHeight*(e.draggablePercent===80?1.5*e.draggablePercent:e.draggablePercent)/100)}},onPointerUp:function(d){const{top:f,bottom:m,left:w,right:D}=n.current.getBoundingClientRect();d.nativeEvent.type!=="touchend"&&e.pauseOnHover&&d.clientX>=w&&d.clientX<=D&&d.clientY>=f&&d.clientY<=m?E():C()}};return r&&a&&(u.onMouseEnter=E,e.stacked||(u.onMouseLeave=C)),c&&(u.onClick=d=>{I&&I(d),s.canCloseOnClick&&g()}),{playToast:C,pauseToast:E,isRunning:A,preventExitTransition:i,toastRef:n,eventHandlers:u}}function nPe(e){let{delay:A,isRunning:t,closeToast:i,type:o="default",hide:n,className:s,style:r,controlledProgress:a,progress:g,rtl:I,isIn:c,theme:B}=e;const l=n||a&&g===0,C={...r,animationDuration:`${A}ms`,animationPlayState:t?"running":"paused"};a&&(C.transform=`scaleX(${g})`);const E=Bm("Toastify__progress-bar",a?"Toastify__progress-bar--controlled":"Toastify__progress-bar--animated",`Toastify__progress-bar-theme--${B}`,`Toastify__progress-bar--${o}`,{"Toastify__progress-bar--rtl":I}),Q=m0(s)?s({rtl:I,type:o,defaultClassName:E}):Bm(E,s),h={[a&&g>=1?"onTransitionEnd":"onAnimationEnd"]:a&&g<1?null:()=>{c&&i()}};return eo.createElement("div",{className:"Toastify__progress-bar--wrp","data-hidden":l},eo.createElement("div",{className:`Toastify__progress-bar--bg Toastify__progress-bar-theme--${B} Toastify__progress-bar--${o}`}),eo.createElement("div",{role:"progressbar","aria-hidden":l?"true":"false","aria-label":"notification timer",className:Q,style:C,...h}))}let sPe=1;const Vrt=()=>""+sPe++;function rPe(e){return e&&(cF(e.toastId)||MY(e.toastId))?e.toastId:Vrt()}function vY(e,A){return Wrt(e,A),A.toastId}function DV(e,A){return{...A,type:A&&A.type||e,toastId:rPe(A)}}function SV(e){return(A,t)=>vY(A,DV(e,t))}function qg(e,A){return vY(e,DV("default",A))}qg.loading=(e,A)=>vY(e,DV("default",{isLoading:!0,autoClose:!1,closeOnClick:!1,closeButton:!1,draggable:!1,...A})),qg.promise=function(e,A,t){let i,{pending:o,error:n,success:s}=A;o&&(i=cF(o)?qg.loading(o,t):qg.loading(o.render,{...t,...o}));const r={isLoading:null,autoClose:null,closeOnClick:null,closeButton:null,draggable:null},a=(I,c,B)=>{if(c==null)return void qg.dismiss(i);const l={type:I,...r,...t,data:B},C=cF(c)?{render:c}:c;return i?qg.update(i,{...l,...C}):qg(C.render,{...l,...C}),B},g=m0(e)?e():e;return g.then(I=>a("success",s,I)).catch(I=>a("error",n,I)),g},qg.success=SV("success"),qg.info=SV("info"),qg.error=SV("error"),qg.warning=SV("warning"),qg.warn=qg.warning,qg.dark=(e,A)=>vY(e,DV("default",{theme:"dark",...A})),qg.dismiss=function(e){(function(A){var t;if(qrt()){if(A==null||cF(t=A)||MY(t))Yd.forEach(i=>{i.removeToast(A)});else if(A&&("containerId"in A||"id"in A)){const i=Yd.get(A.containerId);i?i.removeToast(A.id):Yd.forEach(o=>{o.removeToast(A.id)})}}else NY=NY.filter(i=>A!=null&&i.options.toastId!==A)})(e)},qg.clearWaitingQueue=function(e){e===void 0&&(e={}),Yd.forEach(A=>{!A.props.limit||e.containerId&&A.id!==e.containerId||A.clearQueue()})},qg.isActive=Ort,qg.update=function(e,A){A===void 0&&(A={});const t=((i,o)=>{var n;let{containerId:s}=o;return(n=Yd.get(s||1))==null?void 0:n.toasts.get(i)})(e,A);if(t){const{props:i,content:o}=t,n={delay:100,...i,...A,toastId:A.toastId||e,updateId:Vrt()};n.toastId!==e&&(n.staleId=e);const s=n.render||o;delete n.render,vY(s,n)}},qg.done=e=>{qg.update(e,{progress:1})},qg.onChange=function(e){return OdA.add(e),()=>{OdA.delete(e)}},qg.play=e=>Zrt(!0,e),qg.pause=e=>Zrt(!1,e);const aPe=typeof window<"u"?AA.useLayoutEffect:AA.useEffect,bV=e=>{let{theme:A,type:t,isLoading:i,...o}=e;return eo.createElement("svg",{viewBox:"0 0 24 24",width:"100%",height:"100%",fill:A==="colored"?"currentColor":`var(--toastify-icon-color-${t})`,...o})},WdA={info:function(e){return eo.createElement(bV,{...e},eo.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 eo.createElement(bV,{...e},eo.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 eo.createElement(bV,{...e},eo.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 eo.createElement(bV,{...e},eo.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 eo.createElement("div",{className:"Toastify__spinner"})}},gPe=e=>{const{isRunning:A,preventExitTransition:t,toastRef:i,eventHandlers:o,playToast:n}=oPe(e),{closeButton:s,children:r,autoClose:a,onClick:g,type:I,hideProgressBar:c,closeToast:B,transition:l,position:C,className:E,style:Q,bodyClassName:h,bodyStyle:u,progressClassName:d,progressStyle:f,updateId:m,role:w,progress:D,rtl:b,toastId:k,deleteToast:x,isIn:N,isLoading:M,closeOnClick:U,theme:J}=e,H=Bm("Toastify__toast",`Toastify__toast-theme--${J}`,`Toastify__toast--${I}`,{"Toastify__toast--rtl":b},{"Toastify__toast--close-on-click":U}),O=m0(E)?E({rtl:b,position:C,type:I,defaultClassName:H}):Bm(H,E),W=(function(tA){let{theme:nA,type:rA,isLoading:QA,icon:SA}=tA,FA=null;const MA={theme:nA,type:rA};return SA===!1||(m0(SA)?FA=SA({...MA,isLoading:QA}):AA.isValidElement(SA)?FA=AA.cloneElement(SA,MA):QA?FA=WdA.spinner():(TA=>TA in WdA)(rA)&&(FA=WdA[rA](MA))),FA})(e),$=!!D||!a,iA={closeToast:B,type:I,theme:J};let gA=null;return s===!1||(gA=m0(s)?s(iA):AA.isValidElement(s)?AA.cloneElement(s,iA):(function(tA){let{closeToast:nA,theme:rA,ariaLabel:QA="close"}=tA;return eo.createElement("button",{className:`Toastify__close-button Toastify__close-button--${rA}`,type:"button",onClick:SA=>{SA.stopPropagation(),nA(SA)},"aria-label":QA},eo.createElement("svg",{"aria-hidden":"true",viewBox:"0 0 14 16"},eo.createElement("path",{fillRule:"evenodd",d:"M7.71 8.23l3.75 3.75-1.48 1.48-3.75-3.75-3.75 3.75L1 11.98l3.75-3.75L1 4.48 2.48 3l3.75 3.75L9.98 3l1.48 1.48-3.75 3.75z"})))})(iA)),eo.createElement(l,{isIn:N,done:x,position:C,preventExitTransition:t,nodeRef:i,playToast:n},eo.createElement("div",{id:k,onClick:g,"data-in":N,className:O,...o,style:Q,ref:i},eo.createElement("div",{...N&&{role:w},className:m0(h)?h({type:I}):Bm("Toastify__toast-body",h),style:u},W!=null&&eo.createElement("div",{className:Bm("Toastify__toast-icon",{"Toastify--animate-icon Toastify__zoom-enter":!M})},W),eo.createElement("div",null,r)),gA,eo.createElement(nPe,{...m&&!$?{key:`pb-${m}`}:{},rtl:b,theme:J,delay:a,isRunning:A,isIn:N,closeToast:B,hide:c,type:I,style:f,className:d,controlledProgress:$,progress:D||0})))},xV=function(e,A){return A===void 0&&(A=!1),{enter:`Toastify--animate Toastify__${e}-enter`,exit:`Toastify--animate Toastify__${e}-exit`,appendPosition:A}},IPe=wV(xV("bounce",!0));wV(xV("slide",!0)),wV(xV("zoom")),wV(xV("flip"));const cPe={position:"top-right",transition:IPe,autoClose:5e3,closeButton:!0,pauseOnHover:!0,pauseOnFocusLoss:!0,draggable:"touch",draggablePercent:80,draggableDirection:"x",role:"alert",theme:"light"};function BPe(e){let A={...cPe,...e};const t=e.stacked,[i,o]=AA.useState(!0),n=AA.useRef(null),{getToastToRender:s,isToastActive:r,count:a}=iPe(A),{className:g,style:I,rtl:c,containerId:B}=A;function l(E){const Q=Bm("Toastify__toast-container",`Toastify__toast-container--${E}`,{"Toastify__toast-container--rtl":c});return m0(g)?g({position:E,rtl:c,defaultClassName:Q}):Bm(Q,mV(g))}function C(){t&&(o(!0),qg.play())}return aPe(()=>{if(t){var E;const Q=n.current.querySelectorAll('[data-in="true"]'),h=12,u=(E=A.position)==null?void 0:E.includes("top");let d=0,f=0;Array.from(Q).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 b=d*(i?.2:1)+(i?0:h*w);D.style.setProperty("--y",`${u?b:-1*b}px`),D.style.setProperty("--g",`${h}`),D.style.setProperty("--s",""+(1-(i?f:0))),d+=D.offsetHeight,f+=.025})}},[i,a,t]),eo.createElement("div",{ref:n,className:"Toastify",id:B,onMouseEnter:()=>{t&&(o(!1),qg.pause())},onMouseLeave:C},s((E,Q)=>{const h=Q.length?{...I}:{...I,pointerEvents:"none"};return eo.createElement("div",{className:l(E),style:h,key:`container-${E}`},Q.map(u=>{let{content:d,props:f}=u;return eo.createElement(gPe,{...f,stacked:t,collapseAll:C,isIn:r(f.toastId,f.containerId),style:f.style,key:`toast-${f.key}`},d)}))}))}function lPe(){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 ZdA={exports:{}},VdA,jrt;function zrt(){return jrt||(jrt=1,VdA={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]}),VdA}var jdA={exports:{}},zdA,Xrt;function CPe(){return Xrt||(Xrt=1,zdA=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")}),zdA}var $rt;function QPe(){if($rt)return jdA.exports;$rt=1;var e=CPe(),A=Array.prototype.concat,t=Array.prototype.slice,i=jdA.exports=function(n){for(var s=[],r=0,a=n.length;r<a;r++){var g=n[r];e(g)?s=A.call(s,t.call(g)):s.push(g)}return s};return i.wrap=function(o){return function(){return o(i(arguments))}},jdA.exports}var Aat;function EPe(){if(Aat)return ZdA.exports;Aat=1;var e=zrt(),A=QPe(),t=Object.hasOwnProperty,i=Object.create(null);for(var o in e)t.call(e,o)&&(i[e[o]]=o);var n=ZdA.exports={to:{},get:{}};n.get=function(a){var g=a.substring(0,3).toLowerCase(),I,c;switch(g){case"hsl":I=n.get.hsl(a),c="hsl";break;case"hwb":I=n.get.hwb(a),c="hwb";break;default:I=n.get.rgb(a),c="rgb";break}return I?{model:c,value:I}:null},n.get.rgb=function(a){if(!a)return null;var g=/^#([a-f0-9]{3,4})$/i,I=/^#([a-f0-9]{6})([a-f0-9]{2})?$/i,c=/^rgba?\(\s*([+-]?\d+)(?=[\s,])\s*(?:,\s*)?([+-]?\d+)(?=[\s,])\s*(?:,\s*)?([+-]?\d+)\s*(?:[,|\/]\s*([+-]?[\d\.]+)(%?)\s*)?\)$/,B=/^rgba?\(\s*([+-]?[\d\.]+)\%\s*,?\s*([+-]?[\d\.]+)\%\s*,?\s*([+-]?[\d\.]+)\%\s*(?:[,|\/]\s*([+-]?[\d\.]+)(%?)\s*)?\)$/,l=/^(\w+)$/,C=[0,0,0,1],E,Q,h;if(E=a.match(I)){for(h=E[2],E=E[1],Q=0;Q<3;Q++){var u=Q*2;C[Q]=parseInt(E.slice(u,u+2),16)}h&&(C[3]=parseInt(h,16)/255)}else if(E=a.match(g)){for(E=E[1],h=E[3],Q=0;Q<3;Q++)C[Q]=parseInt(E[Q]+E[Q],16);h&&(C[3]=parseInt(h+h,16)/255)}else if(E=a.match(c)){for(Q=0;Q<3;Q++)C[Q]=parseInt(E[Q+1],0);E[4]&&(E[5]?C[3]=parseFloat(E[4])*.01:C[3]=parseFloat(E[4]))}else if(E=a.match(B)){for(Q=0;Q<3;Q++)C[Q]=Math.round(parseFloat(E[Q+1])*2.55);E[4]&&(E[5]?C[3]=parseFloat(E[4])*.01:C[3]=parseFloat(E[4]))}else return(E=a.match(l))?E[1]==="transparent"?[0,0,0,0]:t.call(e,E[1])?(C=e[E[1]],C[3]=1,C):null:null;for(Q=0;Q<3;Q++)C[Q]=s(C[Q],0,255);return C[3]=s(C[3],0,1),C},n.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*)?\)$/,I=a.match(g);if(I){var c=parseFloat(I[4]),B=(parseFloat(I[1])%360+360)%360,l=s(parseFloat(I[2]),0,100),C=s(parseFloat(I[3]),0,100),E=s(isNaN(c)?1:c,0,1);return[B,l,C,E]}return null},n.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*)?\)$/,I=a.match(g);if(I){var c=parseFloat(I[4]),B=(parseFloat(I[1])%360+360)%360,l=s(parseFloat(I[2]),0,100),C=s(parseFloat(I[3]),0,100),E=s(isNaN(c)?1:c,0,1);return[B,l,C,E]}return null},n.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)):"")},n.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]+")"},n.to.rgb.percent=function(){var a=A(arguments),g=Math.round(a[0]/255*100),I=Math.round(a[1]/255*100),c=Math.round(a[2]/255*100);return a.length<4||a[3]===1?"rgb("+g+"%, "+I+"%, "+c+"%)":"rgba("+g+"%, "+I+"%, "+c+"%, "+a[3]+")"},n.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]+")"},n.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+")"},n.to.keyword=function(a){return i[a.slice(0,3)]};function s(a,g,I){return Math.min(Math.max(g,a),I)}function r(a){var g=Math.round(a).toString(16).toUpperCase();return g.length<2?"0"+g:g}return ZdA.exports}var XdA,tat;function eat(){if(tat)return XdA;tat=1;const e=zrt(),A={};for(const o of Object.keys(e))A[e[o]]=o;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"]}};XdA=t;for(const o of Object.keys(t)){if(!("channels"in t[o]))throw new Error("missing channels property: "+o);if(!("labels"in t[o]))throw new Error("missing channel labels property: "+o);if(t[o].labels.length!==t[o].channels)throw new Error("channel and label counts mismatch: "+o);const{channels:n,labels:s}=t[o];delete t[o].channels,delete t[o].labels,Object.defineProperty(t[o],"channels",{value:n}),Object.defineProperty(t[o],"labels",{value:s})}t.rgb.hsl=function(o){const n=o[0]/255,s=o[1]/255,r=o[2]/255,a=Math.min(n,s,r),g=Math.max(n,s,r),I=g-a;let c,B;g===a?c=0:n===g?c=(s-r)/I:s===g?c=2+(r-n)/I:r===g&&(c=4+(n-s)/I),c=Math.min(c*60,360),c<0&&(c+=360);const l=(a+g)/2;return g===a?B=0:l<=.5?B=I/(g+a):B=I/(2-g-a),[c,B*100,l*100]},t.rgb.hsv=function(o){let n,s,r,a,g;const I=o[0]/255,c=o[1]/255,B=o[2]/255,l=Math.max(I,c,B),C=l-Math.min(I,c,B),E=function(Q){return(l-Q)/6/C+1/2};return C===0?(a=0,g=0):(g=C/l,n=E(I),s=E(c),r=E(B),I===l?a=r-s:c===l?a=1/3+n-r:B===l&&(a=2/3+s-n),a<0?a+=1:a>1&&(a-=1)),[a*360,g*100,l*100]},t.rgb.hwb=function(o){const n=o[0],s=o[1];let r=o[2];const a=t.rgb.hsl(o)[0],g=1/255*Math.min(n,Math.min(s,r));return r=1-1/255*Math.max(n,Math.max(s,r)),[a,g*100,r*100]},t.rgb.cmyk=function(o){const n=o[0]/255,s=o[1]/255,r=o[2]/255,a=Math.min(1-n,1-s,1-r),g=(1-n-a)/(1-a)||0,I=(1-s-a)/(1-a)||0,c=(1-r-a)/(1-a)||0;return[g*100,I*100,c*100,a*100]};function i(o,n){return(o[0]-n[0])**2+(o[1]-n[1])**2+(o[2]-n[2])**2}return t.rgb.keyword=function(o){const n=A[o];if(n)return n;let s=1/0,r;for(const a of Object.keys(e)){const g=e[a],I=i(o,g);I<s&&(s=I,r=a)}return r},t.keyword.rgb=function(o){return e[o]},t.rgb.xyz=function(o){let n=o[0]/255,s=o[1]/255,r=o[2]/255;n=n>.04045?((n+.055)/1.055)**2.4:n/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=n*.4124+s*.3576+r*.1805,g=n*.2126+s*.7152+r*.0722,I=n*.0193+s*.1192+r*.9505;return[a*100,g*100,I*100]},t.rgb.lab=function(o){const n=t.rgb.xyz(o);let s=n[0],r=n[1],a=n[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,I=500*(s-r),c=200*(r-a);return[g,I,c]},t.hsl.rgb=function(o){const n=o[0]/360,s=o[1]/100,r=o[2]/100;let a,g,I;if(s===0)return I=r*255,[I,I,I];r<.5?a=r*(1+s):a=r+s-r*s;const c=2*r-a,B=[0,0,0];for(let l=0;l<3;l++)g=n+1/3*-(l-1),g<0&&g++,g>1&&g--,6*g<1?I=c+(a-c)*6*g:2*g<1?I=a:3*g<2?I=c+(a-c)*(2/3-g)*6:I=c,B[l]=I*255;return B},t.hsl.hsv=function(o){const n=o[0];let s=o[1]/100,r=o[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 I=(r+s)/2,c=r===0?2*a/(g+a):2*s/(r+s);return[n,c*100,I*100]},t.hsv.rgb=function(o){const n=o[0]/60,s=o[1]/100;let r=o[2]/100;const a=Math.floor(n)%6,g=n-Math.floor(n),I=255*r*(1-s),c=255*r*(1-s*g),B=255*r*(1-s*(1-g));switch(r*=255,a){case 0:return[r,B,I];case 1:return[c,r,I];case 2:return[I,r,B];case 3:return[I,c,r];case 4:return[B,I,r];case 5:return[r,I,c]}},t.hsv.hsl=function(o){const n=o[0],s=o[1]/100,r=o[2]/100,a=Math.max(r,.01);let g,I;I=(2-s)*r;const c=(2-s)*a;return g=s*a,g/=c<=1?c:2-c,g=g||0,I/=2,[n,g*100,I*100]},t.hwb.rgb=function(o){const n=o[0]/360;let s=o[1]/100,r=o[2]/100;const a=s+r;let g;a>1&&(s/=a,r/=a);const I=Math.floor(6*n),c=1-r;g=6*n-I,(I&1)!==0&&(g=1-g);const B=s+g*(c-s);let l,C,E;switch(I){default:case 6:case 0:l=c,C=B,E=s;break;case 1:l=B,C=c,E=s;break;case 2:l=s,C=c,E=B;break;case 3:l=s,C=B,E=c;break;case 4:l=B,C=s,E=c;break;case 5:l=c,C=s,E=B;break}return[l*255,C*255,E*255]},t.cmyk.rgb=function(o){const n=o[0]/100,s=o[1]/100,r=o[2]/100,a=o[3]/100,g=1-Math.min(1,n*(1-a)+a),I=1-Math.min(1,s*(1-a)+a),c=1-Math.min(1,r*(1-a)+a);return[g*255,I*255,c*255]},t.xyz.rgb=function(o){const n=o[0]/100,s=o[1]/100,r=o[2]/100;let a,g,I;return a=n*3.2406+s*-1.5372+r*-.4986,g=n*-.9689+s*1.8758+r*.0415,I=n*.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,I=I>.0031308?1.055*I**(1/2.4)-.055:I*12.92,a=Math.min(Math.max(0,a),1),g=Math.min(Math.max(0,g),1),I=Math.min(Math.max(0,I),1),[a*255,g*255,I*255]},t.xyz.lab=function(o){let n=o[0],s=o[1],r=o[2];n/=95.047,s/=100,r/=108.883,n=n>.008856?n**(1/3):7.787*n+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*(n-s),I=200*(s-r);return[a,g,I]},t.lab.xyz=function(o){const n=o[0],s=o[1],r=o[2];let a,g,I;g=(n+16)/116,a=s/500+g,I=g-r/200;const c=g**3,B=a**3,l=I**3;return g=c>.008856?c:(g-16/116)/7.787,a=B>.008856?B:(a-16/116)/7.787,I=l>.008856?l:(I-16/116)/7.787,a*=95.047,g*=100,I*=108.883,[a,g,I]},t.lab.lch=function(o){const n=o[0],s=o[1],r=o[2];let a;a=Math.atan2(r,s)*360/2/Math.PI,a<0&&(a+=360);const I=Math.sqrt(s*s+r*r);return[n,I,a]},t.lch.lab=function(o){const n=o[0],s=o[1],a=o[2]/360*2*Math.PI,g=s*Math.cos(a),I=s*Math.sin(a);return[n,g,I]},t.rgb.ansi16=function(o,n=null){const[s,r,a]=o;let g=n===null?t.rgb.hsv(o)[2]:n;if(g=Math.round(g/50),g===0)return 30;let I=30+(Math.round(a/255)<<2|Math.round(r/255)<<1|Math.round(s/255));return g===2&&(I+=60),I},t.hsv.ansi16=function(o){return t.rgb.ansi16(t.hsv.rgb(o),o[2])},t.rgb.ansi256=function(o){const n=o[0],s=o[1],r=o[2];return n===s&&s===r?n<8?16:n>248?231:Math.round((n-8)/247*24)+232:16+36*Math.round(n/255*5)+6*Math.round(s/255*5)+Math.round(r/255*5)},t.ansi16.rgb=function(o){let n=o%10;if(n===0||n===7)return o>50&&(n+=3.5),n=n/10.5*255,[n,n,n];const s=(~~(o>50)+1)*.5,r=(n&1)*s*255,a=(n>>1&1)*s*255,g=(n>>2&1)*s*255;return[r,a,g]},t.ansi256.rgb=function(o){if(o>=232){const g=(o-232)*10+8;return[g,g,g]}o-=16;let n;const s=Math.floor(o/36)/5*255,r=Math.floor((n=o%36)/6)/5*255,a=n%6/5*255;return[s,r,a]},t.rgb.hex=function(o){const s=(((Math.round(o[0])&255)<<16)+((Math.round(o[1])&255)<<8)+(Math.round(o[2])&255)).toString(16).toUpperCase();return"000000".substring(s.length)+s},t.hex.rgb=function(o){const n=o.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i);if(!n)return[0,0,0];let s=n[0];n[0].length===3&&(s=s.split("").map(c=>c+c).join(""));const r=parseInt(s,16),a=r>>16&255,g=r>>8&255,I=r&255;return[a,g,I]},t.rgb.hcg=function(o){const n=o[0]/255,s=o[1]/255,r=o[2]/255,a=Math.max(Math.max(n,s),r),g=Math.min(Math.min(n,s),r),I=a-g;let c,B;return I<1?c=g/(1-I):c=0,I<=0?B=0:a===n?B=(s-r)/I%6:a===s?B=2+(r-n)/I:B=4+(n-s)/I,B/=6,B%=1,[B*360,I*100,c*100]},t.hsl.hcg=function(o){const n=o[1]/100,s=o[2]/100,r=s<.5?2*n*s:2*n*(1-s);let a=0;return r<1&&(a=(s-.5*r)/(1-r)),[o[0],r*100,a*100]},t.hsv.hcg=function(o){const n=o[1]/100,s=o[2]/100,r=n*s;let a=0;return r<1&&(a=(s-r)/(1-r)),[o[0],r*100,a*100]},t.hcg.rgb=function(o){const n=o[0]/360,s=o[1]/100,r=o[2]/100;if(s===0)return[r*255,r*255,r*255];const a=[0,0,0],g=n%1*6,I=g%1,c=1-I;let B=0;switch(Math.floor(g)){case 0:a[0]=1,a[1]=I,a[2]=0;break;case 1:a[0]=c,a[1]=1,a[2]=0;break;case 2:a[0]=0,a[1]=1,a[2]=I;break;case 3:a[0]=0,a[1]=c,a[2]=1;break;case 4:a[0]=I,a[1]=0,a[2]=1;break;default:a[0]=1,a[1]=0,a[2]=c}return B=(1-s)*r,[(s*a[0]+B)*255,(s*a[1]+B)*255,(s*a[2]+B)*255]},t.hcg.hsv=function(o){const n=o[1]/100,s=o[2]/100,r=n+s*(1-n);let a=0;return r>0&&(a=n/r),[o[0],a*100,r*100]},t.hcg.hsl=function(o){const n=o[1]/100,r=o[2]/100*(1-n)+.5*n;let a=0;return r>0&&r<.5?a=n/(2*r):r>=.5&&r<1&&(a=n/(2*(1-r))),[o[0],a*100,r*100]},t.hcg.hwb=function(o){const n=o[1]/100,s=o[2]/100,r=n+s*(1-n);return[o[0],(r-n)*100,(1-r)*100]},t.hwb.hcg=function(o){const n=o[1]/100,r=1-o[2]/100,a=r-n;let g=0;return a<1&&(g=(r-a)/(1-a)),[o[0],a*100,g*100]},t.apple.rgb=function(o){return[o[0]/65535*255,o[1]/65535*255,o[2]/65535*255]},t.rgb.apple=function(o){return[o[0]/255*65535,o[1]/255*65535,o[2]/255*65535]},t.gray.rgb=function(o){return[o[0]/100*255,o[0]/100*255,o[0]/100*255]},t.gray.hsl=function(o){return[0,0,o[0]]},t.gray.hsv=t.gray.hsl,t.gray.hwb=function(o){return[0,100,o[0]]},t.gray.cmyk=function(o){return[0,0,0,o[0]]},t.gray.lab=function(o){return[o[0],0,0]},t.gray.hex=function(o){const n=Math.round(o[0]/100*255)&255,r=((n<<16)+(n<<8)+n).toString(16).toUpperCase();return"000000".substring(r.length)+r},t.rgb.gray=function(o){return[(o[0]+o[1]+o[2])/3/255*100]},XdA}var $dA,iat;function hPe(){if(iat)return $dA;iat=1;const e=eat();function A(){const n={},s=Object.keys(e);for(let r=s.length,a=0;a<r;a++)n[s[a]]={distance:-1,parent:null};return n}function t(n){const s=A(),r=[n];for(s[n].distance=0;r.length;){const a=r.pop(),g=Object.keys(e[a]);for(let I=g.length,c=0;c<I;c++){const B=g[c],l=s[B];l.distance===-1&&(l.distance=s[a].distance+1,l.parent=a,r.unshift(B))}}return s}function i(n,s){return function(r){return s(n(r))}}function o(n,s){const r=[s[n].parent,n];let a=e[s[n].parent][n],g=s[n].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 $dA=function(n){const s=t(n),r={},a=Object.keys(s);for(let g=a.length,I=0;I<g;I++){const c=a[I];s[c].parent!==null&&(r[c]=o(c,s))}return r},$dA}var ApA,oat;function uPe(){if(oat)return ApA;oat=1;const e=eat(),A=hPe(),t={},i=Object.keys(e);function o(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 n(s){const r=function(...a){const g=a[0];if(g==null)return g;g.length>1&&(a=g);const I=s(a);if(typeof I=="object")for(let c=I.length,B=0;B<c;B++)I[B]=Math.round(I[B]);return I};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 I=r[g];t[s][g]=n(I),t[s][g].raw=o(I)})}),ApA=t,ApA}var tpA,nat;function dPe(){if(nat)return tpA;nat=1;const e=EPe(),A=uPe(),t=["keyword","gray","hex"],i={};for(const B of Object.keys(A))i[[...A[B].labels].sort().join("")]=B;const o={};function n(B,l){if(!(this instanceof n))return new n(B,l);if(l&&l in t&&(l=null),l&&!(l in A))throw new Error("Unknown model: "+l);let C,E;if(B==null)this.model="rgb",this.color=[0,0,0],this.valpha=1;else if(B instanceof n)this.model=B.model,this.color=[...B.color],this.valpha=B.valpha;else if(typeof B=="string"){const Q=e.get(B);if(Q===null)throw new Error("Unable to parse color from string: "+B);this.model=Q.model,E=A[this.model].channels,this.color=Q.value.slice(0,E),this.valpha=typeof Q.value[E]=="number"?Q.value[E]:1}else if(B.length>0){this.model=l||"rgb",E=A[this.model].channels;const Q=Array.prototype.slice.call(B,0,E);this.color=c(Q,E),this.valpha=typeof B[E]=="number"?B[E]:1}else if(typeof B=="number")this.model="rgb",this.color=[B>>16&255,B>>8&255,B&255],this.valpha=1;else{this.valpha=1;const Q=Object.keys(B);"alpha"in B&&(Q.splice(Q.indexOf("alpha"),1),this.valpha=typeof B.alpha=="number"?B.alpha:0);const h=Q.sort().join("");if(!(h in i))throw new Error("Unable to parse color from object: "+JSON.stringify(B));this.model=i[h];const{labels:u}=A[this.model],d=[];for(C=0;C<u.length;C++)d.push(B[u[C]]);this.color=c(d)}if(o[this.model])for(E=A[this.model].channels,C=0;C<E;C++){const Q=o[this.model][C];Q&&(this.color[C]=Q(this.color[C]))}this.valpha=Math.max(0,Math.min(1,this.valpha)),Object.freeze&&Object.freeze(this)}n.prototype={toString(){return this.string()},toJSON(){return this[this.model]()},string(B){let l=this.model in e.to?this:this.rgb();l=l.round(typeof B=="number"?B:1);const C=l.valpha===1?l.color:[...l.color,this.valpha];return e.to[l.model](C)},percentString(B){const l=this.rgb().round(typeof B=="number"?B:1),C=l.valpha===1?l.color:[...l.color,this.valpha];return e.to.rgb.percent(C)},array(){return this.valpha===1?[...this.color]:[...this.color,this.valpha]},object(){const B={},{channels:l}=A[this.model],{labels:C}=A[this.model];for(let E=0;E<l;E++)B[C[E]]=this.color[E];return this.valpha!==1&&(B.alpha=this.valpha),B},unitArray(){const B=this.rgb().color;return B[0]/=255,B[1]/=255,B[2]/=255,this.valpha!==1&&B.push(this.valpha),B},unitObject(){const B=this.rgb().object();return B.r/=255,B.g/=255,B.b/=255,this.valpha!==1&&(B.alpha=this.valpha),B},round(B){return B=Math.max(B||0,0),new n([...this.color.map(r(B)),this.valpha],this.model)},alpha(B){return B!==void 0?new n([...this.color,Math.max(0,Math.min(1,B))],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,B=>(B%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(B){return B!==void 0?new n(B):A[this.model].keyword(this.color)},hex(B){return B!==void 0?new n(B):e.to.hex(this.rgb().round().color)},hexa(B){if(B!==void 0)return new n(B);const l=this.rgb().round().color;let C=Math.round(this.valpha*255).toString(16).toUpperCase();return C.length===1&&(C="0"+C),e.to.hex(l)+C},rgbNumber(){const B=this.rgb().color;return(B[0]&255)<<16|(B[1]&255)<<8|B[2]&255},luminosity(){const B=this.rgb().color,l=[];for(const[C,E]of B.entries()){const Q=E/255;l[C]=Q<=.04045?Q/12.92:((Q+.055)/1.055)**2.4}return .2126*l[0]+.7152*l[1]+.0722*l[2]},contrast(B){const l=this.luminosity(),C=B.luminosity();return l>C?(l+.05)/(C+.05):(C+.05)/(l+.05)},level(B){const l=this.contrast(B);return l>=7?"AAA":l>=4.5?"AA":""},isDark(){const B=this.rgb().color;return(B[0]*2126+B[1]*7152+B[2]*722)/1e4<128},isLight(){return!this.isDark()},negate(){const B=this.rgb();for(let l=0;l<3;l++)B.color[l]=255-B.color[l];return B},lighten(B){const l=this.hsl();return l.color[2]+=l.color[2]*B,l},darken(B){const l=this.hsl();return l.color[2]-=l.color[2]*B,l},saturate(B){const l=this.hsl();return l.color[1]+=l.color[1]*B,l},desaturate(B){const l=this.hsl();return l.color[1]-=l.color[1]*B,l},whiten(B){const l=this.hwb();return l.color[1]+=l.color[1]*B,l},blacken(B){const l=this.hwb();return l.color[2]+=l.color[2]*B,l},grayscale(){const B=this.rgb().color,l=B[0]*.3+B[1]*.59+B[2]*.11;return n.rgb(l,l,l)},fade(B){return this.alpha(this.valpha-this.valpha*B)},opaquer(B){return this.alpha(this.valpha+this.valpha*B)},rotate(B){const l=this.hsl();let C=l.color[0];return C=(C+B)%360,C=C<0?360+C:C,l.color[0]=C,l},mix(B,l){if(!B||!B.rgb)throw new Error('Argument to "mix" was not a Color instance, but rather an instance of '+typeof B);const C=B.rgb(),E=this.rgb(),Q=l===void 0?.5:l,h=2*Q-1,u=C.alpha()-E.alpha(),d=((h*u===-1?h:(h+u)/(1+h*u))+1)/2,f=1-d;return n.rgb(d*C.red()+f*E.red(),d*C.green()+f*E.green(),d*C.blue()+f*E.blue(),C.alpha()*Q+E.alpha()*(1-Q))}};for(const B of Object.keys(A)){if(t.includes(B))continue;const{channels:l}=A[B];n.prototype[B]=function(...C){return this.model===B?new n(this):C.length>0?new n(C,B):new n([...I(A[this.model][B].raw(this.color)),this.valpha],B)},n[B]=function(...C){let E=C[0];return typeof E=="number"&&(E=c(C,l)),new n(E,B)}}function s(B,l){return Number(B.toFixed(l))}function r(B){return function(l){return s(l,B)}}function a(B,l,C){B=Array.isArray(B)?B:[B];for(const E of B)(o[E]||(o[E]=[]))[l]=C;return B=B[0],function(E){let Q;return E!==void 0?(C&&(E=C(E)),Q=this[B](),Q.color[l]=E,Q):(Q=this[B]().color[l],C&&(Q=C(Q)),Q)}}function g(B){return function(l){return Math.max(0,Math.min(B,l))}}function I(B){return Array.isArray(B)?B:[B]}function c(B,l){for(let C=0;C<l;C++)typeof B[C]!="number"&&(B[C]=0);return B}return tpA=n,tpA}var pPe=dPe();const ka=t0(pPe);function Io(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 fPe(){return{a:1,c:0,e:0,b:0,d:1,f:0}}function epA(e){return typeof e>"u"}function _V(e,A=0){return{a:1,c:0,e,b:0,d:1,f:A}}function ipA(...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,...o]=e,n=A(t,i);return ipA(n,...o)}}}function yPe(...e){return ipA(...e)}function mPe(e,A=void 0,t=void 0,i=void 0){epA(A)&&(A=e);const o={a:e,c:0,e:0,b:0,d:A,f:0};return epA(t)||epA(i)?o:ipA([_V(t,i),o,_V(-t,-i)])}function kV(e){const{ctx:A,points:t,fill:i,stroke:o,strokeWidth:n=1,realToCanvasMat:s,closePath:r=!1}=e;if(t.length<2)return;A.beginPath();const a=t.map(B=>Io(s,[B.x,B.y])),g=a[0];if(!g)return;const[I,c]=g;A.moveTo(I,c);for(let B=1;B<a.length;B++){const l=a[B];if(!l)continue;const[C,E]=l;A.lineTo(C,E)}if(r&&A.closePath(),i&&(A.fillStyle=i,A.fill()),o){const B=n*Math.abs(s.a);A.strokeStyle=o,A.lineWidth=B,A.stroke()}}function w0(e){const{ctx:A,center:t,width:i,height:o,fill:n,realToCanvasMat:s,borderRadius:r=0,rotation:a=0,stroke:g,strokeWidth:I,isStrokeDashed:c=!1}=e,[B,l]=Io(s,[t.x,t.y]),C=i*Math.abs(s.a),E=o*Math.abs(s.a),Q=r*Math.abs(s.a),h=I?I*Math.abs(s.a):void 0;if(A.save(),A.translate(B,l),a!==0&&A.rotate(-a*(Math.PI/180)),A.beginPath(),Q>0){const u=-C/2,d=-E/2,f=Math.min(Q,C/2,E/2);A.moveTo(u+f,d),A.lineTo(u+C-f,d),A.arcTo(u+C,d,u+C,d+f,f),A.lineTo(u+C,d+E-f),A.arcTo(u+C,d+E,u+C-f,d+E,f),A.lineTo(u+f,d+E),A.arcTo(u,d+E,u,d+E-f,f),A.lineTo(u,d+f),A.arcTo(u,d,u+f,d,f)}else A.rect(-C/2,-E/2,C,E);n&&(A.fillStyle=n,A.fill()),g&&h&&(c?A.setLineDash([h*3,h*2]):A.setLineDash([]),A.strokeStyle=g,A.lineWidth=h,A.stroke()),A.restore()}function wPe(e){const{ctx:A,board:t,realToCanvasMat:i,colorMap:o,drawBoardMaterial:n}=e,{width:s,height:r,center:a,outline:g}=t;if(g&&Array.isArray(g)&&g.length>=3){n&&kV({ctx:A,points:g.map(I=>({x:I.x,y:I.y})),fill:o.substrate,realToCanvasMat:i,closePath:!0}),kV({ctx:A,points:g.map(I=>({x:I.x,y:I.y})),stroke:o.boardOutline,strokeWidth:.1,realToCanvasMat:i,closePath:!0});return}if(s!==void 0&&r!==void 0&&a){n&&w0({ctx:A,center:a,width:s,height:r,fill:o.substrate,realToCanvasMat:i});const I=s/2,c=r/2,B=[{x:a.x-I,y:a.y-c},{x:a.x+I,y:a.y-c},{x:a.x+I,y:a.y+c},{x:a.x-I,y:a.y+c}];kV({ctx:A,points:B,stroke:o.boardOutline,strokeWidth:.1,realToCanvasMat:i,closePath:!0})}}function LY(e){const{ctx:A,points:t,fill:i,realToCanvasMat:o}=e;if(t.length<3)return;A.beginPath();const n=t.map(g=>Io(o,[g.x,g.y])),s=n[0];if(!s)return;const[r,a]=s;A.moveTo(r,a);for(let g=1;g<n.length;g++){const I=n[g];if(!I)continue;const[c,B]=I;A.lineTo(c,B)}A.closePath(),A.fillStyle=i,A.fill()}function DPe(e,A){return A.copper[e]??A.copper.top}function SPe(e,A,t,i,o){if(Math.abs(o)<1e-10)return null;const n=t-e,s=i-A,r=Math.hypot(n,s);if(r<1e-10)return null;const a=Math.abs(o)*(r/2),g=r/2,I=(a*a+g*g)/(2*a),c=I-a,B=(e+t)/2,l=(A+i)/2,C=-s/r,E=n/r,Q=o>0?-1:1,h=B+Q*C*c,u=l+Q*E*c;return{centerX:h,centerY:u,radius:I}}function opA(e,A,t,i,o,n,s){if(Math.abs(n)<1e-10){const[f,m]=Io(s,[i,o]);e.lineTo(f,m);return}const r=SPe(A,t,i,o,n);if(!r){const[f,m]=Io(s,[i,o]);e.lineTo(f,m);return}const[a,g]=Io(s,[A,t]),[I,c]=Io(s,[i,o]),[B,l]=Io(s,[r.centerX,r.centerY]),C=Math.hypot(a-B,g-l),E=Math.atan2(g-l,a-B),Q=Math.atan2(c-l,I-B),u=s.a*s.d-s.b*s.c<0,d=n>0?!u:u;e.arc(B,l,C,E,Q,d)}function sat(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]=Io(t,[s.x,s.y]);e.moveTo(a,g),opA(e,s.x,s.y,r.x,r.y,1,t),opA(e,r.x,r.y,s.x,s.y,1,t);return}}const i=A.vertices[0];if(!i)return;const[o,n]=Io(t,[i.x,i.y]);e.moveTo(o,n);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 I=r.bulge??0;if(Math.abs(I)<1e-10){const[c,B]=Io(t,[g.x,g.y]);e.lineTo(c,B)}else opA(e,r.x,r.y,g.x,g.y,I,t)}}function bPe(e){const{ctx:A,pour:t,realToCanvasMat:i,colorMap:o}=e,n=DPe(t.layer,o);if(A.save(),t.shape==="rect"){const[s,r]=Io(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=n,A.globalAlpha=.5,A.fill(),A.restore();return}if(t.shape==="polygon"){if(t.points&&t.points.length>=3){const s=t.points.map(I=>Io(i,[I.x,I.y])),r=s[0];if(!r){A.restore();return}A.beginPath();const[a,g]=r;A.moveTo(a,g);for(let I=1;I<s.length;I++){const c=s[I];if(!c)continue;const[B,l]=c;A.lineTo(B,l)}A.closePath(),A.fillStyle=n,A.globalAlpha=.5,A.fill()}A.restore();return}if(t.shape==="brep"){if(A.beginPath(),sat(A,t.brep_shape.outer_ring,i),t.brep_shape.inner_rings)for(const s of t.brep_shape.inner_rings)sat(A,s,i);A.fillStyle=n,A.globalAlpha=.5,A.fill("evenodd"),A.restore();return}A.restore()}var xPe=.62,_Pe=.3,kPe=1,GPe=.13,FPe=1.2;function GV(e,A){const t=A*xPe,i=t*_Pe,o=t*kPe,n=Math.max(A*GPe,.35),s=A*FPe,r=e.replace(/\\n/g,`
5382
5382
  `).split(`
5383
- `),a=[];let g=0;for(const c of r){const B=Array.from(c);let l=0;B.forEach((C,E)=>{l+=C===" "?o:t,E<B.length-1&&(l+=i)}),a.push(l),l>g&&(g=l)}const I=r.length>1?A+(r.length-1)*s:A;return{width:g,height:I,glyphWidth:t,letterSpacing:i,spaceWidth:o,strokeWidth:n,lineHeight:s,lines:r,lineWidths:a}}function npA(e,A){const t=A.width+A.strokeWidth,i=A.height+A.strokeWidth;let o=0,n=0;return e==="center"||e==="top_center"||e==="bottom_center"?o=-t/2:e==="top_left"||e==="bottom_left"||e==="center_left"?o=0:e==="top_right"||e==="bottom_right"||e==="center_right"?o=-t:(e==="top_center"||e==="bottom_center")&&(o=-t/2),e==="center"||e==="center_left"||e==="center_right"?n=-i/2:e==="top_left"||e==="top_right"||e==="top_center"?n=0:(e==="bottom_left"||e==="bottom_right"||e==="bottom_center")&&(n=-i),{x:o,y:n}}function spA(e){const{alignment:A,lineWidth:t,maxWidth:i,strokeWidth:o}=e,n=t+o,s=i+o;return A==="top_left"||A==="bottom_left"||A==="center_left"?0:A==="top_right"||A==="bottom_right"||A==="center_right"?s-n:(s-n)/2}var RPe=e=>Vw[e]??Vw[e.toUpperCase()];function rpA(e){const{ctx:A,line:t,fontSize:i,startX:o,startY:n,layout:s}=e,{glyphWidth:r,letterSpacing:a,spaceWidth:g,strokeWidth:I}=s,c=i,B=n,l=Array.from(t);let C=o+I/2;l.forEach((E,Q)=>{const h=RPe(E),u=E===" "?g:r;if(h?.length){A.beginPath();for(const d of h){const f=C+d.x1*r,m=B+(1-d.y1)*c,w=C+d.x2*r,D=B+(1-d.y2)*c;A.moveTo(f,m),A.lineTo(w,D)}A.stroke()}C+=u,Q<l.length-1&&(C+=a)})}function MPe(e){const{ctx:A,text:t,fontSize:i,startX:o,startY:n,anchorAlignment:s="center"}=e,r=GV(t,i),{lines:a,lineWidths:g,lineHeight:I,width:c,strokeWidth:B}=r;a.forEach((l,C)=>{const E=o+spA({alignment:s,lineWidth:g[C],maxWidth:c,strokeWidth:B}),Q=n+C*I;rpA({ctx:A,line:l,fontSize:i,startX:E,startY:Q,layout:r})})}function apA(e){const{ctx:A,text:t,x:i,y:o,fontSize:n,color:s,realToCanvasMat:r,anchorAlignment:a,rotation:g=0}=e;if(!t)return;const[I,c]=Io(r,[i,o]),B=Math.abs(r.a),l=n*B,C=GV(t,l),E=npA(a,C);A.save(),A.translate(I,c),g!==0&&A.rotate(-g*(Math.PI/180)),A.lineWidth=C.strokeWidth,A.lineCap="round",A.lineJoin="round",A.strokeStyle=s;const{lines:Q,lineWidths:h,lineHeight:u,width:d,strokeWidth:f}=C;Q.forEach((m,w)=>{const D=E.x+spA({alignment:a,lineWidth:h[w],maxWidth:d,strokeWidth:f}),b=E.y+w*u;rpA({ctx:A,line:m,fontSize:l,startX:D,startY:b,layout:C})}),A.restore()}var NPe={left:.2,right:.2,top:.2,bottom:.2};function vPe(e){return e?e.includes("left")?"center_left":e.includes("right")?"center_right":"center":"center"}function LPe(e){const{ctx:A,text:t,realToCanvasMat:i,colorMap:o}=e,n=t.text??"";if(!n)return;const[s,r]=Io(i,[t.anchor_position.x,t.anchor_position.y]),a=Math.abs(i.a),g=(t.font_size??1)*a,I=t.ccw_rotation??0,c={...NPe,...t.knockout_padding},B=o.copper[t.layer]??o.copper.top,l=GV(n,g),C=l.width+l.strokeWidth,E=vPe(t.anchor_alignment),Q=npA(E,l);if(A.save(),A.translate(s,r),t.is_mirrored&&A.scale(-1,1),I!==0&&A.rotate(-I*(Math.PI/180)),A.lineWidth=l.strokeWidth,A.lineCap="round",A.lineJoin="round",t.is_knockout){const h=c.left*a,u=c.right*a,d=c.top*a,f=c.bottom*a,m=Q.x-h*4,w=Q.y-d*4,D=C+h*2+u*2,b=l.height+l.strokeWidth+d*2+f*2;A.fillStyle=B,A.fillRect(m,w,D,b)}else A.strokeStyle=B;MPe({ctx:A,text:n,fontSize:g,startX:Q.x,startY:Q.y,anchorAlignment:E}),A.restore()}function pD(e){const{ctx:A,center:t,radius:i,fill:o,realToCanvasMat:n,stroke:s,strokeWidth:r,isStrokeDashed:a=!1}=e,[g,I]=Io(n,[t.x,t.y]),c=i*Math.abs(n.a),B=r?r*Math.abs(n.a):void 0;A.beginPath(),A.arc(g,I,c,0,Math.PI*2),o&&(A.fillStyle=o,A.fill()),s&&B&&(a?A.setLineDash([B*3,B*2]):A.setLineDash([]),A.strokeStyle=s,A.lineWidth=B,A.stroke())}function UPe(e){const{ctx:A,cutout:t,realToCanvasMat:i,colorMap:o}=e;if(t.shape==="rect"){w0({ctx:A,center:t.center,width:t.width,height:t.height,fill:o.drill,realToCanvasMat:i,rotation:t.rotation??0,borderRadius:t.corner_radius??0});return}if(t.shape==="circle"){pD({ctx:A,center:t.center,radius:t.radius,fill:o.drill,realToCanvasMat:i});return}if(t.shape==="polygon"){t.points&&t.points.length>=3&&LY({ctx:A,points:t.points,fill:o.drill,realToCanvasMat:i});return}}var HPe=1.5,YPe=.6,JPe=.3;function gpA(e){const A=Math.hypot(e.x,e.y)||1;return{x:e.x/A,y:e.y/A}}function rat(e){const{ctx:A,from:t,to:i,realToCanvasMat:o,color:n,fontSize:s,arrowSize:r=1,strokeWidth:a,text:g,textRotation:I,offset:c}=e,B=gpA({x:i.x-t.x,y:i.y-t.y}),l={x:-B.y,y:B.x},C=c?.direction&&typeof c.direction.x=="number"&&typeof c.direction.y=="number",E=C?gpA(c.direction):{x:0,y:0},Q=c?.distance??0,h={x:E.x*Q,y:E.y*Q},u={x:t.x+h.x,y:t.y+h.y},d={x:i.x+h.x,y:i.y+h.y},f={x:u.x+B.x*r,y:u.y+B.y*r},m={x:d.x-B.x*r,y:d.y-B.y*r};Math.abs(o.a);const w=a??r/5,D=n||"rgba(255,255,255,0.5)",b=C&&(Math.abs(E.x)>Number.EPSILON||Math.abs(E.y)>Number.EPSILON)?E:l,k=Q+.5,x=[],N=J=>{const H={x:J.x+b.x*k,y:J.y+b.y*k},O=w/2,W={x:-b.y,y:b.x};return[{x:J.x+W.x*O,y:J.y+W.y*O},{x:J.x-W.x*O,y:J.y-W.y*O},{x:H.x-W.x*O,y:H.y-W.y*O},{x:H.x+W.x*O,y:H.y+W.y*O}]};x.push(u),x.push({x:f.x+l.x*(r/2),y:f.y+l.y*(r/2)}),x.push({x:f.x+l.x*(w/2),y:f.y+l.y*(w/2)}),x.push({x:m.x+l.x*(w/2),y:m.y+l.y*(w/2)}),x.push({x:m.x+l.x*(r/2),y:m.y+l.y*(r/2)}),x.push(d),x.push({x:m.x-l.x*(r/2),y:m.y-l.y*(r/2)}),x.push({x:m.x-l.x*(w/2),y:m.y-l.y*(w/2)}),x.push({x:f.x-l.x*(w/2),y:f.y-l.y*(w/2)}),x.push({x:f.x-l.x*(r/2),y:f.y-l.y*(r/2)}),x.push(u);const M=x[0],U=J=>{const H=N(J);x.push(M),x.push(H[0]),x.push(...H),x.push(H[0]),x.push(M)};if(U(t),U(i),LY({ctx:A,points:x,fill:D,realToCanvasMat:o}),g){const J={x:(t.x+i.x)/2+h.x,y:(t.y+i.y)/2+h.y},[H,O]=Io(o,[u.x,u.y]),[W,$]=Io(o,[d.x,d.y]),iA=gpA({x:W-H,y:$-O});let gA=Math.atan2(iA.y,iA.x)*180/Math.PI;(gA>90||gA<-90)&&(gA+=180);const tA=typeof I=="number"&&Number.isFinite(I)?gA-I:gA;let nA=0;if(g&&typeof I=="number"&&Number.isFinite(I)){const SA=g.length*s*YPe,FA=s,MA=I*Math.PI/180,TA=Math.abs(Math.sin(MA)),EA=Math.abs(Math.cos(MA)),GA=SA/2,dA=FA/2;nA=GA*TA+dA*EA+s*JPe}const rA=r*HPe+nA,QA={x:J.x+l.x*rA,y:J.y+l.y*rA};apA({ctx:A,text:g,x:QA.x,y:QA.y,fontSize:s,color:D,realToCanvasMat:o,anchorAlignment:"center",rotation:-tA})}}var TPe="rgba(255,255,255,0.5)";function KPe(e){const{ctx:A,pcbFabricationNoteDimension:t,realToCanvasMat:i}=e,o=t.color??TPe;rat({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 UY(e){const{ctx:A,start:t,end:i,strokeWidth:o,stroke:n,realToCanvasMat:s,lineCap:r="round"}=e,[a,g]=Io(s,[t.x,t.y]),[I,c]=Io(s,[i.x,i.y]),B=o*Math.abs(s.a);A.beginPath(),A.moveTo(a,g),A.lineTo(I,c),A.lineWidth=B,A.strokeStyle=n,A.lineCap=r,A.stroke()}function PPe(e){const{ctx:A,path:t,realToCanvasMat:i}=e,n=t.color??"rgba(255,255,255,0.5)";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||UY({ctx:A,start:{x:r.x,y:r.y},end:{x:a.x,y:a.y},strokeWidth:t.stroke_width??.1,stroke:n,realToCanvasMat:i})}}function qPe(e){const{ctx:A,rect:t,realToCanvasMat:i}=e,n=t.color??"rgba(255,255,255,0.5)",s=t.is_filled??!1,r=t.has_stroke??!0,a=t.is_stroke_dashed??!1;w0({ctx:A,center:t.center,width:t.width,height:t.height,fill:s?n:void 0,stroke:r?n:void 0,strokeWidth:r?t.stroke_width:void 0,borderRadius:t.corner_radius,realToCanvasMat:i,isStrokeDashed:a})}var OPe="rgba(255,255,255,0.5)";function WPe(e,A){return OPe}function ZPe(e){const{ctx:A,text:t,realToCanvasMat:i}=e,o=WPe(t.layer),n=t.color??o,s=t.font_size;apA({ctx:A,text:t.text,x:t.anchor_position.x,y:t.anchor_position.y,fontSize:s,color:n,realToCanvasMat:i,anchorAlignment:t.anchor_alignment})}function HY(e){const{ctx:A,center:t,radius_x:i,radius_y:o,fill:n,stroke:s,strokeWidth:r=.1,realToCanvasMat:a,rotation:g=0}=e,[I,c]=Io(a,[t.x,t.y]),B=i*Math.abs(a.a),l=o*Math.abs(a.a),C=r*Math.abs(a.a);A.save(),A.translate(I,c),g!==0&&A.rotate(-g*(Math.PI/180)),A.beginPath(),A.ellipse(0,0,B,l,0,0,Math.PI*2),n&&(A.fillStyle=n,A.fill()),s&&(A.strokeStyle=s,A.lineWidth=C,A.stroke()),A.restore()}function fD(e){const{ctx:A,center:t,width:i,height:o,fill:n,realToCanvasMat:s,rotation:r=0,stroke:a,strokeWidth:g}=e,[I,c]=Io(s,[t.x,t.y]),B=i*Math.abs(s.a),l=o*Math.abs(s.a),C=g?g*Math.abs(s.a):void 0;if(A.save(),A.translate(I,c),r!==0&&A.rotate(-r*(Math.PI/180)),A.beginPath(),B>l){const E=l/2,Q=B-l;A.moveTo(-Q/2,-E),A.lineTo(Q/2,-E),A.arc(Q/2,0,E,-Math.PI/2,Math.PI/2),A.lineTo(-Q/2,E),A.arc(-Q/2,0,E,Math.PI/2,-Math.PI/2)}else if(l>B){const E=B/2,Q=l-B;A.moveTo(E,-Q/2),A.lineTo(E,Q/2),A.arc(0,Q/2,E,0,Math.PI),A.lineTo(-E,-Q/2),A.arc(0,-Q/2,E,Math.PI,0)}else A.arc(0,0,B/2,0,Math.PI*2);A.closePath(),n&&(A.fillStyle=n,A.fill()),a&&C&&(A.strokeStyle=a,A.lineWidth=C,A.stroke()),A.restore()}function FV(e){return"ccw_rotation"in e&&typeof e.ccw_rotation=="number"?e.ccw_rotation:0}function VPe(e){const{ctx:A,hole:t,realToCanvasMat:i,colorMap:o,soldermaskMargin:n=0}=e,s=n<0?Math.abs(n):0;if(t.hole_shape==="circle"){pD({ctx:A,center:{x:t.x,y:t.y},radius:t.hole_diameter/2-s,fill:o.drill,realToCanvasMat:i});return}if(t.hole_shape==="square"){const r=FV(t);w0({ctx:A,center:{x:t.x,y:t.y},width:t.hole_diameter-s*2,height:t.hole_diameter-s*2,fill:o.drill,realToCanvasMat:i,rotation:r});return}if(t.hole_shape==="oval"){const r=FV(t);HY({ctx:A,center:{x:t.x,y:t.y},radius_x:t.hole_width/2-s,radius_y:t.hole_height/2-s,fill:o.drill,realToCanvasMat:i,rotation:r});return}if(t.hole_shape==="rect"){const r=FV(t);w0({ctx:A,center:{x:t.x,y:t.y},width:t.hole_width-s*2,height:t.hole_height-s*2,fill:o.drill,realToCanvasMat:i,rotation:r});return}if(t.hole_shape==="pill"||t.hole_shape==="rotated_pill"){const r=FV(t);fD({ctx:A,center:{x:t.x,y:t.y},width:t.hole_width-s*2,height:t.hole_height-s*2,fill:o.drill,realToCanvasMat:i,rotation:r});return}}function jPe(e,A){const t=parseInt(e.slice(1,3),16),i=parseInt(e.slice(3,5),16),o=parseInt(e.slice(5,7),16);return`rgba(${t}, ${i}, ${o}, ${A})`}function zPe(e){const{ctx:A,keepout:t,realToCanvasMat:i,colorMap:o}=e,n=o.keepout,s=jPe(o.keepout,.2),r=1;if(t.shape==="rect"){const[a,g]=Io(i,[t.center.x,t.center.y]),I=t.width*Math.abs(i.a),c=t.height*Math.abs(i.a),B=t.rotation??0;A.save(),A.translate(a,g),B!==0&&A.rotate(-B*(Math.PI/180)),A.beginPath(),A.rect(-I/2,-c/2,I,c),A.fillStyle=s,A.fill(),A.beginPath(),A.rect(-I/2,-c/2,I,c),A.clip();const l=r*Math.abs(i.a),C=Math.sqrt(I*I+c*c),E=I/2,Q=c/2;A.strokeStyle=n,A.lineWidth=.15*Math.abs(i.a),A.setLineDash([]);for(let h=-C;h<C*2;h+=l){A.beginPath();const u=-E+h,d=-Q,f=-E+h+C,m=-Q+C;A.moveTo(u,d),A.lineTo(f,m),A.stroke()}A.restore();return}if(t.shape==="circle"){const[a,g]=Io(i,[t.center.x,t.center.y]),I=t.radius*Math.abs(i.a),c=r*Math.abs(i.a);A.save(),A.translate(a,g),A.beginPath(),A.arc(0,0,I,0,Math.PI*2),A.fillStyle=s,A.fill(),A.beginPath(),A.arc(0,0,I,0,Math.PI*2),A.clip();const B=I*2;A.strokeStyle=n,A.lineWidth=.15*Math.abs(i.a),A.setLineDash([]);for(let l=-B;l<B*2;l+=c)A.beginPath(),A.moveTo(l-B,-B),A.lineTo(l+B,B),A.stroke();A.restore();return}}var XPe="rgba(255,255,255,0.5)";function $Pe(e){const{ctx:A,pcbNoteDimension:t,realToCanvasMat:i}=e,o=t.color??XPe;rat({ctx:A,from:t.from,to:t.to,realToCanvasMat:i,color:o,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 Aqe(e){const{ctx:A,line:t,realToCanvasMat:i}=e,n=t.color??"rgb(89, 148, 220)",s=t.stroke_width??.1,r=t.is_dashed??!1,[a,g]=Io(i,[t.x1,t.y1]),[I,c]=Io(i,[t.x2,t.y2]),B=s*Math.abs(i.a);A.save(),r?A.setLineDash([B*2,B*2]):A.setLineDash([]),A.beginPath(),A.moveTo(a,g),A.lineTo(I,c),A.lineWidth=B,A.strokeStyle=n,A.lineCap="round",A.stroke(),A.restore()}function tqe(e){const{ctx:A,path:t,realToCanvasMat:i}=e,n=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||UY({ctx:A,start:{x:r.x,y:r.y},end:{x:a.x,y:a.y},strokeWidth:t.stroke_width??.1,stroke:n,realToCanvasMat:i})}}function eqe(e){const{ctx:A,rect:t,realToCanvasMat:i}=e,n=t.color??"rgb(89, 148, 220)",s=t.is_filled??!1,r=t.has_stroke??!0,a=t.is_stroke_dashed??!1;w0({ctx:A,center:t.center,width:t.width,height:t.height,fill:s?n:void 0,stroke:r?n:void 0,strokeWidth:r?t.stroke_width:void 0,borderRadius:t.corner_radius,realToCanvasMat:i,isStrokeDashed:a})}var iqe="rgb(89, 148, 220)";function oqe(e){const{ctx:A,text:t,realToCanvasMat:i}=e,o=iqe,n=t.color??o,s=t.font_size??1;apA({ctx:A,text:t.text??"",x:t.anchor_position.x,y:t.anchor_position.y,fontSize:s,color:n,realToCanvasMat:i,anchorAlignment:t.anchor_alignment??"center"})}function nqe(e){const{ctx:A,panel:t,realToCanvasMat:i,colorMap:o,drawBoardMaterial:n}=e,{width:s,height:r,center:a}=t;if(s!==void 0&&r!==void 0&&a){n&&w0({ctx:A,center:a,width:s,height:r,fill:o.substrate,realToCanvasMat:i});const g=s/2,I=r/2,c=[{x:a.x-g,y:a.y-I},{x:a.x+g,y:a.y-I},{x:a.x+g,y:a.y+I},{x:a.x-g,y:a.y+I}];kV({ctx:A,points:c,stroke:o.boardOutline,strokeWidth:.5,realToCanvasMat:i,closePath:!0})}}function YY(e,A){if(e.length<3||A===0)return e;let t=0,i=0;for(const n of e)t+=n.x,i+=n.y;t/=e.length,i/=e.length;const o=[];for(const n of e){const s=n.x-t,r=n.y-i,a=Math.sqrt(s*s+r*r);if(a>0){const g=s/a,I=r/a;o.push({x:n.x+g*A,y:n.y+I*A})}else o.push({x:n.x+A,y:n.y})}return o}function sqe(e){const{ctx:A,hole:t,realToCanvasMat:i,colorMap:o,soldermaskMargin:n=0,drawSoldermask:s}=e;if(t.is_covered_with_solder_mask===!0&&s)return;const r=o.copper.top,a=n<0?Math.abs(n):0;if(t.shape==="circle"){pD({ctx:A,center:{x:t.x,y:t.y},radius:t.outer_diameter/2-a,fill:r,realToCanvasMat:i}),pD({ctx:A,center:{x:t.x,y:t.y},radius:t.hole_diameter/2,fill:o.drill,realToCanvasMat:i});return}if(t.shape==="oval"){HY({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}),HY({ctx:A,center:{x:t.x,y:t.y},radius_x:t.hole_width/2,radius_y:t.hole_height/2,fill:o.drill,realToCanvasMat:i,rotation:t.ccw_rotation});return}if(t.shape==="pill"){fD({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}),fD({ctx:A,center:{x:t.x,y:t.y},width:t.hole_width,height:t.hole_height,fill:o.drill,realToCanvasMat:i,rotation:t.ccw_rotation});return}if(t.shape==="circular_hole_with_rect_pad"){w0({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),I=t.y+(t.hole_offset_y??0);pD({ctx:A,center:{x:g,y:I},radius:t.hole_diameter/2,fill:o.drill,realToCanvasMat:i});return}if(t.shape==="pill_hole_with_rect_pad"){w0({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),I=t.y+(t.hole_offset_y??0);fD({ctx:A,center:{x:g,y:I},width:t.hole_width,height:t.hole_height,fill:o.drill,realToCanvasMat:i});return}if(t.shape==="rotated_pill_hole_with_rect_pad"){w0({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),I=t.y+(t.hole_offset_y??0);fD({ctx:A,center:{x:g,y:I},width:t.hole_width,height:t.hole_height,fill:o.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 l=g.map(E=>({x:t.x+E.x,y:t.y+E.y})),C=a>0?YY(l,-a):l;C.length>=3&&LY({ctx:A,points:C,fill:r,realToCanvasMat:i})}const I=t.x+(t.hole_offset_x??0),c=t.y+(t.hole_offset_y??0),B=t.hole_shape;B==="circle"?pD({ctx:A,center:{x:I,y:c},radius:(t.hole_diameter??0)/2,fill:o.drill,realToCanvasMat:i}):B==="oval"?HY({ctx:A,center:{x:I,y:c},radius_x:(t.hole_width??0)/2,radius_y:(t.hole_height??0)/2,fill:o.drill,realToCanvasMat:i}):B==="pill"?fD({ctx:A,center:{x:I,y:c},width:t.hole_width??0,height:t.hole_height??0,fill:o.drill,realToCanvasMat:i}):B==="rotated_pill"&&fD({ctx:A,center:{x:I,y:c},width:t.hole_width??0,height:t.hole_height??0,fill:o.drill,realToCanvasMat:i});return}}function rqe(e,A){return e==="bottom"?A.silkscreen.bottom:A.silkscreen.top}function aqe(e){const{ctx:A,circle:t,realToCanvasMat:i,colorMap:o}=e,n=rqe(t.layer,o);pD({ctx:A,center:t.center,radius:t.radius,stroke:n,strokeWidth:t.stroke_width,realToCanvasMat:i})}function gqe(e,A){return e==="bottom"?A.silkscreen.bottom:A.silkscreen.top}function Iqe(e){const{ctx:A,line:t,realToCanvasMat:i,colorMap:o}=e,n=gqe(t.layer,o);UY({ctx:A,start:{x:t.x1,y:t.y1},end:{x:t.x2,y:t.y2},strokeWidth:t.stroke_width??.1,stroke:n,realToCanvasMat:i})}function cqe(e,A){return e==="bottom"?A.silkscreen.bottom:A.silkscreen.top}function Bqe(e){const{ctx:A,oval:t,realToCanvasMat:i,colorMap:o}=e,n=cqe(t.layer,o);HY({ctx:A,center:t.center,radius_x:t.radius_x,radius_y:t.radius_y,stroke:n,strokeWidth:.1,realToCanvasMat:i,rotation:t.ccw_rotation??0})}function lqe(e,A){return e==="bottom"?A.silkscreen.bottom:A.silkscreen.top}function Cqe(e){const{ctx:A,path:t,realToCanvasMat:i,colorMap:o}=e,n=lqe(t.layer,o);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||UY({ctx:A,start:{x:r.x,y:r.y},end:{x:a.x,y:a.y},strokeWidth:t.stroke_width??.1,stroke:n,realToCanvasMat:i})}}function Qqe(e,A){return e==="bottom"?A.silkscreen.bottom:A.silkscreen.top}function Eqe(e){const{ctx:A,pill:t,realToCanvasMat:i,colorMap:o}=e,n=Qqe(t.layer,o);fD({ctx:A,center:t.center,width:t.width,height:t.height,stroke:n,strokeWidth:.2,realToCanvasMat:i})}function hqe(e,A){return e==="bottom"?A.silkscreen.bottom:A.silkscreen.top}function uqe(e){const{ctx:A,rect:t,realToCanvasMat:i,colorMap:o}=e,n=hqe(t.layer,o);w0({ctx:A,center:t.center,width:t.width,height:t.height,fill:t.is_filled?n:"transparent",stroke:n,strokeWidth:t.stroke_width,realToCanvasMat:i})}function dqe(e,A){return e==="bottom"?A.silkscreen.bottom:A.silkscreen.top}function pqe(e){return e||"center"}function fqe(e){const{ctx:A,text:t,realToCanvasMat:i,colorMap:o}=e,n=t.text??"";if(!n)return;const s=dqe(t.layer,o),[r,a]=Io(i,[t.anchor_position.x,t.anchor_position.y]),g=Math.abs(i.a),I=(t.font_size??1)*g,c=t.ccw_rotation??0,B=GV(n,I),l=pqe(t.anchor_alignment),C=npA(l,B);A.save(),A.translate(r,a),c!==0&&A.rotate(-c*(Math.PI/180)),t.layer==="bottom"&&A.scale(-1,1),A.lineWidth=B.strokeWidth,A.lineCap="round",A.lineJoin="round",A.strokeStyle=s;const{lines:E,lineWidths:Q,lineHeight:h,width:u,strokeWidth:d}=B;E.forEach((f,m)=>{const w=C.x+spA({alignment:l,lineWidth:Q[m],maxWidth:u,strokeWidth:d}),D=C.y+m*h;rpA({ctx:A,line:f,fontSize:I,startX:w,startY:D,layout:B})}),A.restore()}function yqe(e,A){return A.copper[e]??A.copper.top}function aat(e){return e.shape==="rect"||e.shape==="rotated_rect"?e.corner_radius??e.rect_border_radius??0:0}function mqe(e){const{ctx:A,pad:t,realToCanvasMat:i,colorMap:o}=e,n=yqe(t.layer,o);if(t.shape==="rect"){w0({ctx:A,center:{x:t.x,y:t.y},width:t.width,height:t.height,fill:n,realToCanvasMat:i,borderRadius:aat(t)});return}if(t.shape==="rotated_rect"){w0({ctx:A,center:{x:t.x,y:t.y},width:t.width,height:t.height,fill:n,realToCanvasMat:i,borderRadius:aat(t),rotation:t.ccw_rotation??0});return}if(t.shape==="circle"){pD({ctx:A,center:{x:t.x,y:t.y},radius:t.radius,fill:n,realToCanvasMat:i});return}if(t.shape==="pill"){fD({ctx:A,center:{x:t.x,y:t.y},width:t.width,height:t.height,fill:n,realToCanvasMat:i});return}if(t.shape==="rotated_pill"){fD({ctx:A,center:{x:t.x,y:t.y},width:t.width,height:t.height,fill:n,realToCanvasMat:i,rotation:t.ccw_rotation??0});return}if(t.shape==="polygon"){t.points&&t.points.length>=3&&LY({ctx:A,points:t.points,fill:n,realToCanvasMat:i});return}}function L_(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 o=1;o<t.length;o++){const n=t[o];n&&A.lineTo(n.x,n.y)}A.closePath()}}function wqe(e){const{ctx:A,board:t,realToCanvasMat:i,soldermaskColor:o}=e,{width:n,height:s,center:r,outline:a}=t;if(a&&Array.isArray(a)&&a.length>=3){const g=a.map(I=>{const[c,B]=Io(i,[I.x,I.y]);return{x:c,y:B}});A.beginPath(),L_({ctx:A,points:g}),A.fillStyle=o,A.fill()}else if(n!==void 0&&s!==void 0&&r){const[g,I]=Io(i,[r.x,r.y]),c=n*Math.abs(i.a),B=s*Math.abs(i.a);A.fillStyle=o,A.fillRect(g-c/2,I-B/2,c,B)}}function U_(e){const{ctx:A,cx:t,cy:i,width:o,height:n,radius:s}=e,r=t-o/2,a=i-n/2,g=Math.min(s,o/2,n/2);g>0?(A.moveTo(r+g,a),A.lineTo(r+o-g,a),A.arcTo(r+o,a,r+o,a+g,g),A.lineTo(r+o,a+n-g),A.arcTo(r+o,a+n,r+o-g,a+n,g),A.lineTo(r+g,a+n),A.arcTo(r,a+n,r,a+n-g,g),A.lineTo(r,a+g),A.arcTo(r,a,r+g,a,g)):A.rect(r,a,o,n),A.closePath()}function Dqe(e){const{ctx:A,cutout:t,realToCanvasMat:i,colorMap:o}=e;if(A.fillStyle=o.drill,t.shape==="rect"){const[n,s]=Io(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(n,s),t.rotation&&A.rotate(-t.rotation*Math.PI/180),A.beginPath(),U_({ctx:A,cx:0,cy:0,width:r,height:a,radius:g}),A.restore(),A.fill()}else if(t.shape==="circle"){const[n,s]=Io(i,[t.center?.x??0,t.center?.y??0]),r=t.radius*Math.abs(i.a);A.beginPath(),A.arc(n,s,r,0,Math.PI*2),A.closePath(),A.fill()}else if(t.shape==="polygon"&&t.points&&t.points.length>=3){const n=t.points.map(s=>{const[r,a]=Io(i,[s.x,s.y]);return{x:r,y:a}});A.beginPath(),L_({ctx:A,points:n}),A.fill()}}function lb(e){const{ctx:A,cx:t,cy:i,width:o,height:n}=e;if(o>n){const s=n/2,r=o-n;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(n>o){const s=o/2,r=n-o;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,o/2,0,Math.PI*2);A.closePath()}function Sqe(e){const{ctx:A,hole:t,realToCanvasMat:i,colorMap:o,soldermaskOverCopperColor:n,drawSoldermask:s}=e,r=s&&t.is_covered_with_solder_mask===!0,a=s?t.soldermask_margin??0:0;r?(A.fillStyle=n,JY({ctx:A,hole:t,realToCanvasMat:i,margin:0}),A.fill()):a<0?(A.fillStyle=o.drill,JY({ctx:A,hole:t,realToCanvasMat:i,margin:0}),A.fill(),bqe({ctx:A,hole:t,realToCanvasMat:i,soldermaskOverCopperColor:n,margin:a})):a>0?(A.fillStyle=o.substrate,JY({ctx:A,hole:t,realToCanvasMat:i,margin:a}),A.fill(),A.fillStyle=o.drill,JY({ctx:A,hole:t,realToCanvasMat:i,margin:0}),A.fill()):(A.fillStyle=o.drill,JY({ctx:A,hole:t,realToCanvasMat:i,margin:0}),A.fill())}function gat(e){return"ccw_rotation"in e&&typeof e.ccw_rotation=="number"?e.ccw_rotation:0}function JY(e){const{ctx:A,hole:t,realToCanvasMat:i,margin:o}=e,n=gat(t);if(t.hole_shape==="circle"){const[s,r]=Io(i,[t.x,t.y]),a=(t.hole_diameter/2+o)*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]=Io(i,[t.x,t.y]),a=(t.hole_diameter+o*2)*Math.abs(i.a);A.save(),A.translate(s,r),n!==0&&A.rotate(-n*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]=Io(i,[t.x,t.y]),a=(t.hole_width/2+o)*Math.abs(i.a),g=(t.hole_height/2+o)*Math.abs(i.a);A.save(),A.translate(s,r),n!==0&&A.rotate(-n*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]=Io(i,[t.x,t.y]),a=(t.hole_width+o*2)*Math.abs(i.a),g=(t.hole_height+o*2)*Math.abs(i.a);A.save(),A.translate(s,r),n!==0&&A.rotate(-n*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]=Io(i,[t.x,t.y]),a=(t.hole_width+o*2)*Math.abs(i.a),g=(t.hole_height+o*2)*Math.abs(i.a);A.save(),A.translate(s,r),n!==0&&A.rotate(-n*Math.PI/180),A.beginPath(),lb({ctx:A,cx:0,cy:0,width:a,height:g}),A.restore()}}function bqe(e){const{ctx:A,hole:t,realToCanvasMat:i,soldermaskOverCopperColor:o,margin:n}=e,s=Math.abs(n),r=gat(t);if(A.fillStyle=o,t.hole_shape==="circle"){const[a,g]=Io(i,[t.x,t.y]),I=t.hole_diameter/2*Math.abs(i.a),c=s*Math.abs(i.a),B=Math.max(0,I-c);A.save(),A.beginPath(),A.arc(a,g,I,0,Math.PI*2),B>0&&A.arc(a,g,B,0,Math.PI*2,!0),A.fill("evenodd"),A.restore()}else if(t.hole_shape==="square"){const[a,g]=Io(i,[t.x,t.y]),I=t.hole_diameter*Math.abs(i.a),c=s*Math.abs(i.a),B=Math.max(0,I-c*2);A.save(),A.translate(a,g),r!==0&&A.rotate(-r*Math.PI/180),A.beginPath(),A.rect(-I/2,-I/2,I,I),B>0&&A.rect(-B/2,-B/2,B,B),A.fill("evenodd"),A.restore()}else if(t.hole_shape==="oval"){const[a,g]=Io(i,[t.x,t.y]),I=t.hole_width/2*Math.abs(i.a),c=t.hole_height/2*Math.abs(i.a),B=s*Math.abs(i.a),l=Math.max(0,I-B),C=Math.max(0,c-B);A.save(),A.translate(a,g),r!==0&&A.rotate(-r*Math.PI/180),A.beginPath(),A.ellipse(0,0,I,c,0,0,Math.PI*2),l>0&&C>0&&(A.moveTo(l,0),A.ellipse(0,0,l,C,0,0,Math.PI*2)),A.fill("evenodd"),A.restore()}else if(t.hole_shape==="rect"){const[a,g]=Io(i,[t.x,t.y]),I=t.hole_width*Math.abs(i.a),c=t.hole_height*Math.abs(i.a),B=s*Math.abs(i.a),l=Math.max(0,I-B*2),C=Math.max(0,c-B*2);A.save(),A.translate(a,g),r!==0&&A.rotate(-r*Math.PI/180),A.beginPath(),A.rect(-I/2,-c/2,I,c),l>0&&C>0&&A.rect(-l/2,-C/2,l,C),A.fill("evenodd"),A.restore()}else if(t.hole_shape==="pill"||t.hole_shape==="rotated_pill"){const[a,g]=Io(i,[t.x,t.y]),I=t.hole_width*Math.abs(i.a),c=t.hole_height*Math.abs(i.a),B=s*Math.abs(i.a);A.save(),A.translate(a,g),r!==0&&A.rotate(-r*Math.PI/180),A.beginPath(),lb({ctx:A,cx:0,cy:0,width:I,height:c});const l=I-B*2,C=c-B*2;l>0&&C>0&&lb({ctx:A,cx:0,cy:0,width:l,height:C}),A.fill("evenodd"),A.restore()}}function xqe(e){const{ctx:A,hole:t,realToCanvasMat:i,colorMap:o,soldermaskOverCopperColor:n,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,I=o.copper.top;a?(A.fillStyle=n,TY({ctx:A,hole:t,realToCanvasMat:i,margin:0}),A.fill()):g<0?(A.fillStyle=I,TY({ctx:A,hole:t,realToCanvasMat:i,margin:0}),A.fill(),_qe({ctx:A,hole:t,realToCanvasMat:i,soldermaskOverCopperColor:n,margin:g})):g>0?(A.fillStyle=o.substrate,TY({ctx:A,hole:t,realToCanvasMat:i,margin:g}),A.fill(),A.fillStyle=I,TY({ctx:A,hole:t,realToCanvasMat:i,margin:0}),A.fill()):(A.fillStyle=I,TY({ctx:A,hole:t,realToCanvasMat:i,margin:0}),A.fill())}function TY(e){const{ctx:A,hole:t,realToCanvasMat:i,margin:o}=e;if(t.shape==="circle"){const[n,s]=Io(i,[t.x,t.y]),r=(t.outer_diameter/2+o)*Math.abs(i.a);A.beginPath(),A.arc(n,s,r,0,Math.PI*2),A.closePath()}else if(t.shape==="oval"){const[n,s]=Io(i,[t.x,t.y]),r=(t.outer_width/2+o)*Math.abs(i.a),a=(t.outer_height/2+o)*Math.abs(i.a);A.save(),A.translate(n,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[n,s]=Io(i,[t.x,t.y]),r=(t.outer_width+o*2)*Math.abs(i.a),a=(t.outer_height+o*2)*Math.abs(i.a);A.save(),A.translate(n,s),t.ccw_rotation&&t.ccw_rotation!==0&&A.rotate(-(t.ccw_rotation*Math.PI)/180),A.beginPath(),lb({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[n,s]=Io(i,[t.x,t.y]),r=(t.rect_pad_width+o*2)*Math.abs(i.a),a=(t.rect_pad_height+o*2)*Math.abs(i.a),g=(t.rect_border_radius??0)*Math.abs(i.a);A.beginPath(),U_({ctx:A,cx:n,cy:s,width:r,height:a,radius:g})}else if(t.shape==="rotated_pill_hole_with_rect_pad"){const[n,s]=Io(i,[t.x,t.y]),r=(t.rect_pad_width+o*2)*Math.abs(i.a),a=(t.rect_pad_height+o*2)*Math.abs(i.a),g=(t.rect_border_radius??0)*Math.abs(i.a);A.save(),A.translate(n,s),t.rect_ccw_rotation&&A.rotate(-t.rect_ccw_rotation*Math.PI/180),A.beginPath(),U_({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 n=t.pad_outline.map(a=>({x:t.x+a.x,y:t.y+a.y})),r=(o!==0?YY(n,o):n).map(a=>{const[g,I]=Io(i,[a.x,a.y]);return{x:g,y:I}});A.beginPath(),L_({ctx:A,points:r})}}function _qe(e){const{ctx:A,hole:t,realToCanvasMat:i,soldermaskOverCopperColor:o,margin:n}=e,s=Math.abs(n);if(A.fillStyle=o,t.shape==="circle"){const[r,a]=Io(i,[t.x,t.y]),g=t.outer_diameter/2*Math.abs(i.a),I=s*Math.abs(i.a),c=Math.max(0,g-I);A.save(),A.beginPath(),A.arc(r,a,g,0,Math.PI*2),c>0&&A.arc(r,a,c,0,Math.PI*2,!0),A.fill("evenodd"),A.restore()}else if(t.shape==="oval"){const[r,a]=Io(i,[t.x,t.y]),g=t.outer_width/2*Math.abs(i.a),I=t.outer_height/2*Math.abs(i.a),c=s*Math.abs(i.a),B=Math.max(0,g-c),l=Math.max(0,I-c);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,I,0,0,Math.PI*2),B>0&&l>0&&(A.moveTo(B,0),A.ellipse(0,0,B,l,0,0,Math.PI*2)),A.fill("evenodd"),A.restore()}else if(t.shape==="pill"){const[r,a]=Io(i,[t.x,t.y]),g=t.outer_width*Math.abs(i.a),I=t.outer_height*Math.abs(i.a),c=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(),lb({ctx:A,cx:0,cy:0,width:g,height:I});const B=g-c*2,l=I-c*2;B>0&&l>0&&lb({ctx:A,cx:0,cy:0,width:B,height:l}),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]=Io(i,[t.x,t.y]),g=t.rect_pad_width*Math.abs(i.a),I=t.rect_pad_height*Math.abs(i.a),c=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 B=t.rect_border_radius?t.rect_border_radius*Math.abs(i.a):0;A.beginPath(),U_({ctx:A,cx:0,cy:0,width:g,height:I,radius:B});const l=g-c*2,C=I-c*2;if(l>0&&C>0){const E=Math.max(0,B-c);U_({ctx:A,cx:0,cy:0,width:l,height:C,radius:E})}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(I=>({x:t.x+I.x,y:t.y+I.y}));A.save(),A.beginPath();const a=r.map(I=>{const[c,B]=Io(i,[I.x,I.y]);return{x:c,y:B}});L_({ctx:A,points:a});const g=YY(r,-s);if(g.length>=3){const I=g.map(c=>{const[B,l]=Io(i,[c.x,c.y]);return{x:B,y:l}});L_({ctx:A,points:I})}A.fill("evenodd"),A.restore()}}function kqe(e){const{ctx:A,pad:t,realToCanvasMat:i,colorMap:o,soldermaskOverCopperColor:n,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 I=g,c=g,B=g,l=g;(t.shape==="rect"||t.shape==="rotated_rect")&&(I=t.soldermask_margin_left??g,c=t.soldermask_margin_right??g,B=t.soldermask_margin_top??g,l=t.soldermask_margin_bottom??g);const C=o.copper[t.layer]||o.copper.top;a?(A.fillStyle=n,KY({ctx:A,pad:t,realToCanvasMat:i,ml:0,mr:0,mt:0,mb:0}),A.fill()):I<0||c<0||B<0||l<0?(A.fillStyle=C,KY({ctx:A,pad:t,realToCanvasMat:i,ml:0,mr:0,mt:0,mb:0}),A.fill(),Gqe({ctx:A,pad:t,realToCanvasMat:i,soldermaskOverCopperColor:n,ml:I,mr:c,mt:B,mb:l})):I>0||c>0||B>0||l>0?(A.fillStyle=o.substrate,KY({ctx:A,pad:t,realToCanvasMat:i,ml:I,mr:c,mt:B,mb:l}),A.fill(),A.fillStyle=C,KY({ctx:A,pad:t,realToCanvasMat:i,ml:0,mr:0,mt:0,mb:0}),A.fill()):(A.fillStyle=C,KY({ctx:A,pad:t,realToCanvasMat:i,ml:0,mr:0,mt:0,mb:0}),A.fill())}function KY(e){const{ctx:A,pad:t,realToCanvasMat:i,ml:o,mr:n,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,I=a*Math.PI/180,c=(n-o)/2,B=(s-r)/2,l=c*Math.cos(I)-B*Math.sin(I),C=c*Math.sin(I)+B*Math.cos(I),[E,Q]=Io(i,[t.x+l,t.y+C]),h=(t.width+o+n)*Math.abs(i.a),u=(t.height+s+r)*Math.abs(i.a),d=g*Math.abs(i.a);A.save(),A.translate(E,Q),a!==0&&A.rotate(-a*Math.PI/180),A.beginPath(),U_({ctx:A,cx:0,cy:0,width:h,height:u,radius:d}),A.restore()}else if(t.shape==="circle"){const g=(o+n+s+r)/4,[I,c]=Io(i,[t.x,t.y]),B=(t.radius+g)*Math.abs(i.a);A.beginPath(),A.arc(I,c,B,0,Math.PI*2),A.closePath()}else if(t.shape==="pill"||t.shape==="rotated_pill"){const g=(o+n)/2,[I,c]=Io(i,[t.x,t.y]),B=(t.width+g*2)*Math.abs(i.a),l=(t.height+g*2)*Math.abs(i.a);A.save(),A.translate(I,c),a!==0&&A.rotate(-a*Math.PI/180),A.beginPath(),lb({ctx:A,cx:0,cy:0,width:B,height:l}),A.restore()}else if(t.shape==="polygon"&&t.points&&t.points.length>=3){const g=(o+n+s+r)/4,c=(g!==0?YY(t.points,g):t.points).map(B=>{const[l,C]=Io(i,[B.x,B.y]);return{x:l,y:C}});A.beginPath(),L_({ctx:A,points:c})}}function Gqe(e){const{ctx:A,pad:t,realToCanvasMat:i,soldermaskOverCopperColor:o,ml:n,mr:s,mt:r,mb:a}=e,g=t.shape==="rotated_rect"||t.shape==="rotated_pill"?t.ccw_rotation??0:0,I=Math.max(0,-n),c=Math.max(0,-s),B=Math.max(0,-r),l=Math.max(0,-a);if(A.fillStyle=o,t.shape==="rect"||t.shape==="rotated_rect"){const C=t.corner_radius??t.rect_border_radius??0,[E,Q]=Io(i,[t.x,t.y]),h=t.width*Math.abs(i.a),u=t.height*Math.abs(i.a),d=C*Math.abs(i.a),f=I*Math.abs(i.a),m=c*Math.abs(i.a),w=B*Math.abs(i.a),D=l*Math.abs(i.a);A.save(),A.translate(E,Q),g!==0&&A.rotate(-g*Math.PI/180),A.beginPath(),U_({ctx:A,cx:0,cy:0,width:h,height:u,radius:d});const b=h-f-m,k=u-w-D,x=(f-m)/2,N=(w-D)/2,M=Math.max(0,d-(f+m+w+D)/4);b>0&&k>0&&U_({ctx:A,cx:x,cy:N,width:b,height:k,radius:M}),A.fill("evenodd"),A.restore()}else if(t.shape==="circle"){const C=Math.max(I,c,B,l),[E,Q]=Io(i,[t.x,t.y]),h=t.radius*Math.abs(i.a),u=C*Math.abs(i.a),d=Math.max(0,h-u);A.save(),A.beginPath(),A.arc(E,Q,h,0,Math.PI*2),d>0&&A.arc(E,Q,d,0,Math.PI*2,!0),A.fill("evenodd"),A.restore()}else if(t.shape==="pill"||t.shape==="rotated_pill"){const C=Math.max(I,c,B,l),[E,Q]=Io(i,[t.x,t.y]),h=t.width*Math.abs(i.a),u=t.height*Math.abs(i.a),d=C*Math.abs(i.a);A.save(),A.translate(E,Q),g!==0&&A.rotate(-g*Math.PI/180),A.beginPath(),lb({ctx:A,cx:0,cy:0,width:h,height:u});const f=h-d*2,m=u-d*2;f>0&&m>0&&lb({ctx:A,cx:0,cy:0,width:f,height:m}),A.fill("evenodd"),A.restore()}else if(t.shape==="polygon"&&t.points&&t.points.length>=3){const C=Math.max(I,c,B,l);A.save(),A.beginPath();const E=t.points.map(h=>{const[u,d]=Io(i,[h.x,h.y]);return{x:u,y:d}});L_({ctx:A,points:E});const Q=YY(t.points,-C);if(Q.length>=3){const h=Q.map(u=>{const[d,f]=Io(i,[u.x,u.y]);return{x:d,y:f}});L_({ctx:A,points:h})}A.fill("evenodd"),A.restore()}}function Fqe(e){const{ctx:A,via:t,realToCanvasMat:i,colorMap:o}=e,[n,s]=Io(i,[t.x,t.y]),r=t.outer_diameter/2*Math.abs(i.a);A.fillStyle=o.substrate,A.beginPath(),A.arc(n,s,r,0,Math.PI*2),A.closePath(),A.fill()}function Rqe(e){const{ctx:A,board:t,elements:i,realToCanvasMat:o,colorMap:n,layer:s,drawSoldermask:r}=e,a=n.soldermask[s]??n.soldermask.top,g=n.soldermaskOverCopper[s]??n.soldermaskOverCopper.top;r&&wqe({ctx:A,board:t,realToCanvasMat:o,soldermaskColor:a});for(const I of i)Mqe({ctx:A,element:I,realToCanvasMat:o,colorMap:n,soldermaskOverCopperColor:g,layer:s,drawSoldermask:r})}function Mqe(e){const{ctx:A,element:t,realToCanvasMat:i,colorMap:o,soldermaskOverCopperColor:n,layer:s,drawSoldermask:r}=e;t.type==="pcb_smtpad"?kqe({ctx:A,pad:t,realToCanvasMat:i,colorMap:o,soldermaskOverCopperColor:n,layer:s,drawSoldermask:r}):t.type==="pcb_plated_hole"?xqe({ctx:A,hole:t,realToCanvasMat:i,colorMap:o,soldermaskOverCopperColor:n,layer:s,drawSoldermask:r}):t.type==="pcb_hole"?Sqe({ctx:A,hole:t,realToCanvasMat:i,colorMap:o,soldermaskOverCopperColor:n,drawSoldermask:r}):t.type==="pcb_via"?Fqe({ctx:A,via:t,realToCanvasMat:i,colorMap:o}):t.type==="pcb_cutout"&&Dqe({ctx:A,cutout:t,realToCanvasMat:i,colorMap:o})}function Mv(e,A){const t=Math.hypot(e,A);return t<=Number.EPSILON?{x:0,y:0}:{x:e/t,y:A/t}}function Nqe(e,A){const t=e.length;if(t<2)return{x:1,y:0};if(A<=0){const g=e[1],I=e[0];if(!g||!I)return{x:1,y:0};const c=Mv(g.x-I.x,g.y-I.y);return c.x===0&&c.y===0?{x:1,y:0}:c}if(A>=t-1){const g=e[t-2],I=e[t-1];if(!g||!I)return{x:1,y:0};const c=Mv(I.x-g.x,I.y-g.y);return c.x===0&&c.y===0?{x:1,y:0}:c}const i=e[A-1],o=e[A],n=e[A+1];if(!i||!o||!n)return{x:1,y:0};const s=Mv(o.x-i.x,o.y-i.y),r=Mv(n.x-o.x,n.y-o.y),a=Mv(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 vqe(e){const A=[],t=[];for(let i=0;i<e.length;i++){const o=e[i];if(!o)continue;const n=Nqe(e,i),s=Mv(-n.y,n.x),r=o.width/2;A.push({x:o.x+s.x*r,y:o.y+s.y*r}),t.push({x:o.x-s.x*r,y:o.y-s.y*r})}return A.concat(t.reverse())}function Lqe(e){const A=[];let t=[],i=null;for(const o of e??[]){if(!o||o.route_type!=="wire"){t.length>=2&&A.push(t),t=[],i=null;continue}const n=o.layer??i;if(!n)continue;const s=o.x,r=o.y;if(typeof s!="number"||typeof r!="number"||typeof o.width!="number")continue;const a=o.width;i&&n!==i&&(t.length>=2&&A.push(t),t=[]),i=n,t.push({route_type:"wire",x:s,y:r,width:a,layer:n,start_pcb_port_id:"start_pcb_port_id"in o?o.start_pcb_port_id:void 0,end_pcb_port_id:"end_pcb_port_id"in o?o.end_pcb_port_id:void 0})}return t.length>=2&&A.push(t),A}function Uqe(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 Hqe(e,A){return A.copper[e]??A.copper.top}function Yqe(e){const{ctx:A,trace:t,realToCanvasMat:i,colorMap:o}=e;if(!t.route||!Array.isArray(t.route)||t.route.length<2)return;const n=Lqe(t.route);for(const s of n){const r=s[0]?.layer;if(!r)continue;const a=Hqe(r,o);if(Uqe(s)){const g=vqe(s);LY({ctx:A,points:g,fill:a,realToCanvasMat:i});continue}for(let g=0;g<s.length-1;g++){const I=s[g],c=s[g+1];!I||!c||UY({ctx:A,start:{x:I.x,y:I.y},end:{x:c.x,y:c.y},strokeWidth:I.width,stroke:a,realToCanvasMat:i,lineCap:"round"})}}}function Jqe(e){const{ctx:A,via:t,realToCanvasMat:i,colorMap:o}=e;pD({ctx:A,center:{x:t.x,y:t.y},radius:t.outer_diameter/2,fill:o.copper.top,realToCanvasMat:i}),pD({ctx:A,center:{x:t.x,y:t.y},radius:t.hole_diameter/2,fill:o.drill,realToCanvasMat:i})}function BF(e,A){if(!A.layers||A.layers.length===0)return!0;const t=nNA(e);return t.length===0?!0:t.some(i=>A.layers.includes(i))}var Cf={copper:{top:"rgb(200, 52, 52)",inner1:"rgb(255, 140, 0)",inner2:"rgb(255, 215, 0)",inner3:"rgb(50, 205, 50)",inner4:"rgb(64, 224, 208)",inner5:"rgb(138, 43, 226)",inner6:"rgb(255, 105, 180)",bottom:"rgb(77, 127, 196)"},soldermaskWithCopperUnderneath:{top:"rgb(18, 82, 50)",bottom:"rgb(77, 127, 196)"},soldermask:{top:"rgb(12, 55, 33)",bottom:"rgb(12, 55, 33)"},soldermaskOverCopper:{top:"rgb(52, 135, 73)",bottom:"rgb(52, 135, 73)"},substrate:"rgb(201, 162, 110)",drill:"#FF26E2",silkscreen:{top:"#f2eda1",bottom:"#5da9e9"},boardOutline:"rgba(255, 255, 255, 0.5)",courtyard:"#FF00FF",keepout:"#FF6B6B"},FQ=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={...Cf},this.realToCanvasMat=fPe()}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,o=e.maxX-e.minX,n=e.maxY-e.minY,s=t/o,r=i/n,a=Math.min(s,r),g=(t-o*a)/2,I=(i-n*a)/2;this.realToCanvasMat=yPe(_V(g,I),mPe(a,-a),_V(-e.minX,-e.maxY))}drawElements(e,A={}){const t=e.find(n=>n.type==="pcb_board"),i=e.find(n=>n.type==="pcb_panel");i&&nqe({ctx:this.ctx,panel:i,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap,drawBoardMaterial:A.drawBoardMaterial??!1}),t&&wPe({ctx:this.ctx,board:t,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap,drawBoardMaterial:A.drawBoardMaterial??!1});for(const n of e)BF(n,A)&&(n.type==="pcb_smtpad"&&mqe({ctx:this.ctx,pad:n,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}),n.type==="pcb_copper_text"&&LPe({ctx:this.ctx,text:n,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}));const o=A.drawSoldermask??!1;for(const n of e)BF(n,A)&&n.type==="pcb_hole"&&VPe({ctx:this.ctx,hole:n,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap,soldermaskMargin:o?n.soldermask_margin:void 0});t&&Rqe({ctx:this.ctx,board:t,elements:e,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap,layer:"top",drawSoldermask:o});for(const n of e)BF(n,A)&&(n.type==="pcb_silkscreen_text"&&fqe({ctx:this.ctx,text:n,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}),n.type==="pcb_silkscreen_rect"&&uqe({ctx:this.ctx,rect:n,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}),n.type==="pcb_silkscreen_circle"&&aqe({ctx:this.ctx,circle:n,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}),n.type==="pcb_silkscreen_line"&&Iqe({ctx:this.ctx,line:n,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}),n.type==="pcb_silkscreen_path"&&Cqe({ctx:this.ctx,path:n,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}),n.type==="pcb_silkscreen_pill"&&Eqe({ctx:this.ctx,pill:n,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}),n.type==="pcb_silkscreen_oval"&&Bqe({ctx:this.ctx,oval:n,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}));for(const n of e)BF(n,A)&&(n.type==="pcb_copper_pour"&&bPe({ctx:this.ctx,pour:n,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}),n.type==="pcb_trace"&&Yqe({ctx:this.ctx,trace:n,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}));for(const n of e)BF(n,A)&&(n.type==="pcb_plated_hole"&&sqe({ctx:this.ctx,hole:n,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap,soldermaskMargin:o?n.soldermask_margin:void 0,drawSoldermask:o}),n.type==="pcb_via"&&Jqe({ctx:this.ctx,via:n,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}));for(const n of e)BF(n,A)&&n.type==="pcb_cutout"&&UPe({ctx:this.ctx,cutout:n,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap});for(const n of e)BF(n,A)&&(n.type==="pcb_keepout"&&zPe({ctx:this.ctx,keepout:n,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}),n.type==="pcb_fabrication_note_text"&&ZPe({ctx:this.ctx,text:n,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}),n.type==="pcb_fabrication_note_rect"&&qPe({ctx:this.ctx,rect:n,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}),n.type==="pcb_note_rect"&&eqe({realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap,ctx:this.ctx,rect:n}),n.type==="pcb_fabrication_note_path"&&PPe({ctx:this.ctx,path:n,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}),n.type==="pcb_note_path"&&tqe({ctx:this.ctx,path:n,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}),n.type==="pcb_note_text"&&oqe({ctx:this.ctx,text:n,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}),n.type==="pcb_note_line"&&Aqe({ctx:this.ctx,line:n,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}),n.type==="pcb_note_dimension"&&$Pe({ctx:this.ctx,pcbNoteDimension:n,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}),n.type==="pcb_fabrication_note_dimension"&&KPe({ctx:this.ctx,pcbFabricationNoteDimension:n,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}))}};const Tqe=P0t(sMt);var IpA,Iat;function Kqe(){if(Iat)return IpA;Iat=1;var e=Object.defineProperty,A=Object.getOwnPropertyDescriptor,t=Object.getOwnPropertyNames,i=Object.prototype.hasOwnProperty,o=(Q,h)=>{for(var u in h)e(Q,u,{get:h[u],enumerable:!0})},n=(Q,h,u,d)=>{if(h&&typeof h=="object"||typeof h=="function")for(let f of t(h))!i.call(Q,f)&&f!==u&&e(Q,f,{get:()=>h[f],enumerable:!(d=A(h,f))||d.enumerable});return Q},s=Q=>n(e({},"__esModule",{value:!0}),Q),r={};o(r,{SuperGrid:()=>E,toMMSI:()=>C,toMeterSI:()=>l}),IpA=s(r);var a=e0(),g=Tqe,I=nSA(),c=(Q,h,u)=>{const d=[];if(h<Q)for(let f=Q;f>=h;f-=Math.abs(u))d.push(f);else for(let f=Q;f<=h;f+=Math.abs(u))d.push(f);return d};function B(Q,h){return{x:Math.round(h.x/Q)*Q,y:Math.round(h.y/Q)*Q}}function l(Q,h=1){return Q<0?"-"+l(-Q):Q<1e-6?"0m":Q>1e3?Math.floor(Q/1e3)+"km":Q>1&&h>1?Math.round(Q)+"m":Q>1&&h<=1?Q.toFixed(Math.ceil(-Math.log10(h)))+"m":Q<1&&h>=1/1e3?Math.round(Q*1e3)+"mm":Q<1&&h<1/1e3?(Q*1e3).toFixed(Math.ceil(-Math.log10(h*1e3)))+"mm":""}function C(Q,h=1){return l(Q/1e3,h/1e3)}var E=Q=>{var h;const u=(0,a.useRef)(null),[d,f]=(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=(h=Q.majorColor)!=null?h:"rgba(0,0,0,0.5)",width:b,height:k,screenSpaceCellSize:x=200,stringifyCoord:N=(H,O,W)=>`${l(H,W)}, ${l(O,W)}`}=Q,M=Math.ceil(b/x)+2,U=Math.ceil(k/x)+2;(0,a.useEffect)(()=>{if(!u.current)return;const H=u.current.getContext("2d");if(!H)return;const O=x/10**Math.floor(Math.log10(Q.transform.a)),W=Q.transform.d<0?-1:1,iA=x/10**Math.log10(Q.transform.a)/O;function gA(GA,dA,PA){const JA=GA;let it,yA,tt;for(it=dA.x;it<=PA.x;it+=JA)yA=(0,g.applyToPoint)(Q.transform,{x:it,y:dA.y}),tt=(0,g.applyToPoint)(Q.transform,{x:it,y:PA.y}),H.beginPath(),H.moveTo(yA.x,yA.y),H.lineTo(tt.x,tt.y),H.stroke();const qA=c(dA.y,PA.y,JA*W);for(const UA of qA)yA=(0,g.applyToPoint)(Q.transform,{x:dA.x,y:UA}),tt=(0,g.applyToPoint)(Q.transform,{x:PA.x,y:UA}),H.beginPath(),H.moveTo(yA.x,yA.y),H.lineTo(tt.x,tt.y),H.stroke()}function tA(GA,dA,PA){const JA=GA;let it;for(it=dA.x;it<=PA.x;it+=JA)for(const yA of c(dA.y,PA.y,JA*W)){const tt=(0,g.applyToPoint)(Q.transform,{x:it,y:yA});H.fillStyle=D,H.font="12px sans-serif",H.fillText(N(it,yA,GA),tt.x+2,tt.y-2)}}H.clearRect(0,0,b,k);const nA=(0,g.applyToPoint)((0,g.inverse)(Q.transform),{x:0,y:0}),rA={x:Math.floor((nA.x-O)/O)*O,y:Math.floor((nA.y-O)/O+(W==-1?2:0))*O},QA={x:rA.x+O*M,y:rA.y+O*U*W},FA=O*5,MA={x:Math.floor((nA.x-FA)/FA)*FA,y:Math.floor((nA.y-FA)/FA+(W==-1?2:0))*FA},TA={x:MA.x+FA*M,y:MA.y+FA*U*W};H.globalAlpha=1,H.strokeStyle=m,gA(O,rA,QA),tA(FA,MA,TA),H.globalAlpha=1-iA,gA(FA/10,MA,TA),H.globalAlpha=1-iA,H.strokeStyle=w,gA(O/10,rA,QA),H.globalAlpha=Math.max(((1-iA)*10-5)/5,0),tA(FA/10,MA,TA),H.globalAlpha=1;const EA=(0,g.applyToPoint)(Q.transform,d);H.font="12px sans-serif",H.fillStyle=D,H.fillText(N(d.x,d.y,O),EA.x+2,EA.y-2),H.strokeStyle=m,H.strokeRect(EA.x-5,EA.y-5,10,10)},[u,Q.transform,d,b,k]);const J=H=>{if(!u.current)return;const O=x/10/10**Math.floor(Math.log10(Q.transform.a)),W=u.current.getBoundingClientRect(),$=(0,g.applyToPoint)((0,g.inverse)(Q.transform),{x:H.clientX-W.left,y:H.clientY-W.top}),iA=B(O,$);f(iA)};return(0,I.jsx)("canvas",{onMouseUp:H=>{H.button===1&&J(H)},onDoubleClick:J,ref:u,width:Q.width,height:Q.height})};return IpA}var RV=Kqe();function Pqe(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 qqe(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 Oqe=(function(){function e(t){var i=this;this._insertTag=function(o){var n;i.tags.length===0?i.insertionPoint?n=i.insertionPoint.nextSibling:i.prepend?n=i.container.firstChild:n=i.before:n=i.tags[i.tags.length-1].nextSibling,i.container.insertBefore(o,n),i.tags.push(o)},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(qqe(this));var o=this.tags[this.tags.length-1];if(this.isSpeedy){var n=Pqe(o);try{n.insertRule(i,n.cssRules.length)}catch{}}else o.appendChild(document.createTextNode(i));this.ctr++},A.flush=function(){this.tags.forEach(function(i){var o;return(o=i.parentNode)==null?void 0:o.removeChild(i)}),this.tags=[],this.ctr=0},e})(),Ku="-ms-",MV="-moz-",qa="-webkit-",cat="comm",cpA="rule",BpA="decl",Wqe="@import",Bat="@keyframes",Zqe="@layer",Vqe=Math.abs,NV=String.fromCharCode,jqe=Object.assign;function zqe(e,A){return kh(e,0)^45?(((A<<2^kh(e,0))<<2^kh(e,1))<<2^kh(e,2))<<2^kh(e,3):0}function lat(e){return e.trim()}function Xqe(e,A){return(e=A.exec(e))?e[0]:e}function Oa(e,A,t){return e.replace(A,t)}function lpA(e,A){return e.indexOf(A)}function kh(e,A){return e.charCodeAt(A)|0}function PY(e,A,t){return e.slice(A,t)}function yD(e){return e.length}function CpA(e){return e.length}function vV(e,A){return A.push(e),e}function $qe(e,A){return e.map(A).join("")}var LV=1,Nv=1,Cat=0,Qf=0,vC=0,vv="";function UV(e,A,t,i,o,n,s){return{value:e,root:A,parent:t,type:i,props:o,children:n,line:LV,column:Nv,length:s,return:""}}function qY(e,A){return jqe(UV("",null,null,"",null,null,0),e,{length:-e.length},A)}function A4e(){return vC}function t4e(){return vC=Qf>0?kh(vv,--Qf):0,Nv--,vC===10&&(Nv=1,LV--),vC}function D0(){return vC=Qf<Cat?kh(vv,Qf++):0,Nv++,vC===10&&(Nv=1,LV++),vC}function mD(){return kh(vv,Qf)}function HV(){return Qf}function OY(e,A){return PY(vv,e,A)}function WY(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 Qat(e){return LV=Nv=1,Cat=yD(vv=e),Qf=0,[]}function Eat(e){return vv="",e}function YV(e){return lat(OY(Qf-1,QpA(e===91?e+2:e===40?e+1:e)))}function e4e(e){for(;(vC=mD())&&vC<33;)D0();return WY(e)>2||WY(vC)>3?"":" "}function i4e(e,A){for(;--A&&D0()&&!(vC<48||vC>102||vC>57&&vC<65||vC>70&&vC<97););return OY(e,HV()+(A<6&&mD()==32&&D0()==32))}function QpA(e){for(;D0();)switch(vC){case e:return Qf;case 34:case 39:e!==34&&e!==39&&QpA(vC);break;case 40:e===41&&QpA(e);break;case 92:D0();break}return Qf}function o4e(e,A){for(;D0()&&e+vC!==57;)if(e+vC===84&&mD()===47)break;return"/*"+OY(A,Qf-1)+"*"+NV(e===47?e:D0())}function n4e(e){for(;!WY(mD());)D0();return OY(e,Qf)}function s4e(e){return Eat(JV("",null,null,null,[""],e=Qat(e),0,[0],e))}function JV(e,A,t,i,o,n,s,r,a){for(var g=0,I=0,c=s,B=0,l=0,C=0,E=1,Q=1,h=1,u=0,d="",f=o,m=n,w=i,D=d;Q;)switch(C=u,u=D0()){case 40:if(C!=108&&kh(D,c-1)==58){lpA(D+=Oa(YV(u),"&","&\f"),"&\f")!=-1&&(h=-1);break}case 34:case 39:case 91:D+=YV(u);break;case 9:case 10:case 13:case 32:D+=e4e(C);break;case 92:D+=i4e(HV()-1,7);continue;case 47:switch(mD()){case 42:case 47:vV(r4e(o4e(D0(),HV()),A,t),a);break;default:D+="/"}break;case 123*E:r[g++]=yD(D)*h;case 125*E:case 59:case 0:switch(u){case 0:case 125:Q=0;case 59+I:h==-1&&(D=Oa(D,/\f/g,"")),l>0&&yD(D)-c&&vV(l>32?uat(D+";",i,t,c-1):uat(Oa(D," ","")+";",i,t,c-2),a);break;case 59:D+=";";default:if(vV(w=hat(D,A,t,g,I,o,r,d,f=[],m=[],c),n),u===123)if(I===0)JV(D,A,w,w,f,n,c,r,m);else switch(B===99&&kh(D,3)===110?100:B){case 100:case 108:case 109:case 115:JV(e,w,w,i&&vV(hat(e,w,w,0,0,o,r,d,o,f=[],c),m),o,m,c,r,i?f:m);break;default:JV(D,w,w,w,[""],m,0,r,m)}}g=I=l=0,E=h=1,d=D="",c=s;break;case 58:c=1+yD(D),l=C;default:if(E<1){if(u==123)--E;else if(u==125&&E++==0&&t4e()==125)continue}switch(D+=NV(u),u*E){case 38:h=I>0?1:(D+="\f",-1);break;case 44:r[g++]=(yD(D)-1)*h,h=1;break;case 64:mD()===45&&(D+=YV(D0())),B=mD(),I=c=yD(d=D+=n4e(HV())),u++;break;case 45:C===45&&yD(D)==2&&(E=0)}}return n}function hat(e,A,t,i,o,n,s,r,a,g,I){for(var c=o-1,B=o===0?n:[""],l=CpA(B),C=0,E=0,Q=0;C<i;++C)for(var h=0,u=PY(e,c+1,c=Vqe(E=s[C])),d=e;h<l;++h)(d=lat(E>0?B[h]+" "+u:Oa(u,/&\f/g,B[h])))&&(a[Q++]=d);return UV(e,A,t,o===0?cpA:r,a,g,I)}function r4e(e,A,t){return UV(e,A,t,cat,NV(A4e()),PY(e,2,-2),0)}function uat(e,A,t,i){return UV(e,A,t,BpA,PY(e,0,i),PY(e,i+1,-1),i)}function Lv(e,A){for(var t="",i=CpA(e),o=0;o<i;o++)t+=A(e[o],o,e,A)||"";return t}function a4e(e,A,t,i){switch(e.type){case Zqe:if(e.children.length)break;case Wqe:case BpA:return e.return=e.return||e.value;case cat:return"";case Bat:return e.return=e.value+"{"+Lv(e.children,i)+"}";case cpA:e.value=e.props.join(",")}return yD(t=Lv(e.children,i))?e.return=e.value+"{"+t+"}":""}function g4e(e){var A=CpA(e);return function(t,i,o,n){for(var s="",r=0;r<A;r++)s+=e[r](t,i,o,n)||"";return s}}function I4e(e){return function(A){A.root||(A=A.return)&&e(A)}}function c4e(e){var A=Object.create(null);return function(t){return A[t]===void 0&&(A[t]=e(t)),A[t]}}var B4e=function(A,t,i){for(var o=0,n=0;o=n,n=mD(),o===38&&n===12&&(t[i]=1),!WY(n);)D0();return OY(A,Qf)},l4e=function(A,t){var i=-1,o=44;do switch(WY(o)){case 0:o===38&&mD()===12&&(t[i]=1),A[i]+=B4e(Qf-1,t,i);break;case 2:A[i]+=YV(o);break;case 4:if(o===44){A[++i]=mD()===58?"&\f":"",t[i]=A[i].length;break}default:A[i]+=NV(o)}while(o=D0());return A},C4e=function(A,t){return Eat(l4e(Qat(A),t))},dat=new WeakMap,Q4e=function(A){if(!(A.type!=="rule"||!A.parent||A.length<1)){for(var t=A.value,i=A.parent,o=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&&!dat.get(i))&&!o){dat.set(A,!0);for(var n=[],s=C4e(t,n),r=i.props,a=0,g=0;a<s.length;a++)for(var I=0;I<r.length;I++,g++)A.props[g]=n[a]?s[a].replace(/&\f/g,r[I]):r[I]+" "+s[a]}}},E4e=function(A){if(A.type==="decl"){var t=A.value;t.charCodeAt(0)===108&&t.charCodeAt(2)===98&&(A.return="",A.value="")}};function pat(e,A){switch(zqe(e,A)){case 5103:return qa+"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 qa+e+e;case 5349:case 4246:case 4810:case 6968:case 2756:return qa+e+MV+e+Ku+e+e;case 6828:case 4268:return qa+e+Ku+e+e;case 6165:return qa+e+Ku+"flex-"+e+e;case 5187:return qa+e+Oa(e,/(\w+).+(:[^]+)/,qa+"box-$1$2"+Ku+"flex-$1$2")+e;case 5443:return qa+e+Ku+"flex-item-"+Oa(e,/flex-|-self/,"")+e;case 4675:return qa+e+Ku+"flex-line-pack"+Oa(e,/align-content|flex-|-self/,"")+e;case 5548:return qa+e+Ku+Oa(e,"shrink","negative")+e;case 5292:return qa+e+Ku+Oa(e,"basis","preferred-size")+e;case 6060:return qa+"box-"+Oa(e,"-grow","")+qa+e+Ku+Oa(e,"grow","positive")+e;case 4554:return qa+Oa(e,/([^-])(transform)/g,"$1"+qa+"$2")+e;case 6187:return Oa(Oa(Oa(e,/(zoom-|grab)/,qa+"$1"),/(image-set)/,qa+"$1"),e,"")+e;case 5495:case 3959:return Oa(e,/(image-set\([^]*)/,qa+"$1$`$1");case 4968:return Oa(Oa(e,/(.+:)(flex-)?(.*)/,qa+"box-pack:$3"+Ku+"flex-pack:$3"),/s.+-b[^;]+/,"justify")+qa+e+e;case 4095:case 3583:case 4068:case 2532:return Oa(e,/(.+)-inline(.+)/,qa+"$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(yD(e)-1-A>6)switch(kh(e,A+1)){case 109:if(kh(e,A+4)!==45)break;case 102:return Oa(e,/(.+:)(.+)-([^]+)/,"$1"+qa+"$2-$3$1"+MV+(kh(e,A+3)==108?"$3":"$2-$3"))+e;case 115:return~lpA(e,"stretch")?pat(Oa(e,"stretch","fill-available"),A)+e:e}break;case 4949:if(kh(e,A+1)!==115)break;case 6444:switch(kh(e,yD(e)-3-(~lpA(e,"!important")&&10))){case 107:return Oa(e,":",":"+qa)+e;case 101:return Oa(e,/(.+:)([^;!]+)(;|!.+)?/,"$1"+qa+(kh(e,14)===45?"inline-":"")+"box$3$1"+qa+"$2$3$1"+Ku+"$2box$3")+e}break;case 5936:switch(kh(e,A+11)){case 114:return qa+e+Ku+Oa(e,/[svh]\w+-[tblr]{2}/,"tb")+e;case 108:return qa+e+Ku+Oa(e,/[svh]\w+-[tblr]{2}/,"tb-rl")+e;case 45:return qa+e+Ku+Oa(e,/[svh]\w+-[tblr]{2}/,"lr")+e}return qa+e+Ku+e+e}return e}var h4e=function(A,t,i,o){if(A.length>-1&&!A.return)switch(A.type){case BpA:A.return=pat(A.value,A.length);break;case Bat:return Lv([qY(A,{value:Oa(A.value,"@","@"+qa)})],o);case cpA:if(A.length)return $qe(A.props,function(n){switch(Xqe(n,/(::plac\w+|:read-\w+)/)){case":read-only":case":read-write":return Lv([qY(A,{props:[Oa(n,/:(read-\w+)/,":"+MV+"$1")]})],o);case"::placeholder":return Lv([qY(A,{props:[Oa(n,/:(plac\w+)/,":"+qa+"input-$1")]}),qY(A,{props:[Oa(n,/:(plac\w+)/,":"+MV+"$1")]}),qY(A,{props:[Oa(n,/:(plac\w+)/,Ku+"input-$1")]})],o)}return""})}},u4e=[h4e],d4e=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(E){var Q=E.getAttribute("data-emotion");Q.indexOf(" ")!==-1&&(document.head.appendChild(E),E.setAttribute("data-s",""))})}var o=A.stylisPlugins||u4e,n={},s,r=[];s=A.container||document.head,Array.prototype.forEach.call(document.querySelectorAll('style[data-emotion^="'+t+' "]'),function(E){for(var Q=E.getAttribute("data-emotion").split(" "),h=1;h<Q.length;h++)n[Q[h]]=!0;r.push(E)});var a,g=[Q4e,E4e];{var I,c=[a4e,I4e(function(E){I.insert(E)})],B=g4e(g.concat(o,c)),l=function(Q){return Lv(s4e(Q),B)};a=function(Q,h,u,d){I=u,l(Q?Q+"{"+h.styles+"}":h.styles),d&&(C.inserted[h.name]=!0)}}var C={key:t,sheet:new Oqe({key:t,container:s,nonce:A.nonce,speedy:A.speedy,prepend:A.prepend,insertionPoint:A.insertionPoint}),nonce:A.nonce,inserted:n,registered:{},insert:a};return C.sheet.hydrate(r),C};function p4e(e){for(var A=0,t,i=0,o=e.length;o>=4;++i,o-=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(o){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 f4e={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},y4e=/[A-Z]|^ms/g,m4e=/_EMO_([^_]+?)_([^]*?)_EMO_/g,fat=function(A){return A.charCodeAt(1)===45},yat=function(A){return A!=null&&typeof A!="boolean"},EpA=c4e(function(e){return fat(e)?e:e.replace(y4e,"-$&").toLowerCase()}),mat=function(A,t){switch(A){case"animation":case"animationName":if(typeof t=="string")return t.replace(m4e,function(i,o,n){return H_={name:o,styles:n,next:H_},o})}return f4e[A]!==1&&!fat(A)&&typeof t=="number"&&t!==0?t+"px":t};function TV(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 o=t;if(o.anim===1)return H_={name:o.name,styles:o.styles,next:H_},o.name;var n=t;if(n.styles!==void 0){var s=n.next;if(s!==void 0)for(;s!==void 0;)H_={name:s.name,styles:s.styles,next:H_},s=s.next;var r=n.styles+";";return r}return w4e(e,A,t)}}var a=t;if(A==null)return a;var g=A[a];return g!==void 0?g:a}function w4e(e,A,t){var i="";if(Array.isArray(t))for(var o=0;o<t.length;o++)i+=TV(e,A,t[o])+";";else for(var n in t){var s=t[n];if(typeof s!="object"){var r=s;A!=null&&A[r]!==void 0?i+=n+"{"+A[r]+"}":yat(r)&&(i+=EpA(n)+":"+mat(n,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++)yat(s[a])&&(i+=EpA(n)+":"+mat(n,s[a])+";");else{var g=TV(e,A,s);switch(n){case"animation":case"animationName":{i+=EpA(n)+":"+g+";";break}default:i+=n+"{"+g+"}"}}}return i}var wat=/label:\s*([^\s;{]+)\s*(;|$)/g,H_;function hpA(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,o="";H_=void 0;var n=e[0];if(n==null||n.raw===void 0)i=!1,o+=TV(t,A,n);else{var s=n;o+=s[0]}for(var r=1;r<e.length;r++)if(o+=TV(t,A,e[r]),i){var a=n;o+=a[r]}wat.lastIndex=0;for(var g="",I;(I=wat.exec(o))!==null;)g+="-"+I[1];var c=p4e(o)+g;return{name:c,styles:o,next:H_}}function Dat(e,A,t){var i="";return t.split(" ").forEach(function(o){e[o]!==void 0?A.push(e[o]+";"):o&&(i+=o+" ")}),i}var D4e=function(A,t,i){var o=A.key+"-"+t.name;A.registered[o]===void 0&&(A.registered[o]=t.styles)},S4e=function(A,t,i){D4e(A,t);var o=A.key+"-"+t.name;if(A.inserted[t.name]===void 0){var n=t;do A.insert(t===n?"."+o:"",n,A.sheet,!0),n=n.next;while(n!==void 0)}};function Sat(e,A){if(e.inserted[A.name]===void 0)return e.insert("",A,e.sheet,!0)}function bat(e,A,t){var i=[],o=Dat(e,i,t);return i.length<2?t:o+A(i)}var b4e=function(A){var t=d4e(A);t.sheet.speedy=function(r){this.isSpeedy=r},t.compat=!0;var i=function(){for(var a=arguments.length,g=new Array(a),I=0;I<a;I++)g[I]=arguments[I];var c=hpA(g,t.registered,void 0);return S4e(t,c),t.key+"-"+c.name},o=function(){for(var a=arguments.length,g=new Array(a),I=0;I<a;I++)g[I]=arguments[I];var c=hpA(g,t.registered),B="animation-"+c.name;return Sat(t,{name:c.name,styles:"@keyframes "+B+"{"+c.styles+"}"}),B},n=function(){for(var a=arguments.length,g=new Array(a),I=0;I<a;I++)g[I]=arguments[I];var c=hpA(g,t.registered);Sat(t,c)},s=function(){for(var a=arguments.length,g=new Array(a),I=0;I<a;I++)g[I]=arguments[I];return bat(t.registered,i,x4e(g))};return{css:i,cx:s,injectGlobal:n,keyframes:o,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:Dat.bind(null,t.registered),merge:bat.bind(null,t.registered,i)}},x4e=function e(A){for(var t="",i=0;i<A.length;i++){var o=A[i];if(o!=null){var n=void 0;switch(typeof o){case"boolean":break;case"object":{if(Array.isArray(o))n=e(o);else{n="";for(var s in o)o[s]&&s&&(n&&(n+=" "),n+=s)}break}default:n=o}n&&(t&&(t+=" "),t+=n)}}return t},_4e=b4e({key:"css"}),Uv=_4e.css,k4e=Object.create,xat=Object.defineProperty,G4e=Object.getOwnPropertyDescriptor,_at=Object.getOwnPropertyNames,F4e=Object.getPrototypeOf,R4e=Object.prototype.hasOwnProperty,Ga=(e,A)=>function(){return A||(0,e[_at(e)[0]])((A={exports:{}}).exports,A),A.exports},M4e=(e,A,t,i)=>{if(A&&typeof A=="object"||typeof A=="function")for(let o of _at(A))!R4e.call(e,o)&&o!==t&&xat(e,o,{get:()=>A[o],enumerable:!(i=G4e(A,o))||i.enumerable});return e},kat=(e,A,t)=>(t=e!=null?k4e(F4e(e)):{},M4e(xat(t,"default",{value:e,enumerable:!0}),e)),N4e=Ga({"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)||o(tA)||!!tA._isBuffer)};function i(tA){return!!tA.constructor&&typeof tA.constructor.isBuffer=="function"&&tA.constructor.isBuffer(tA)}function o(tA){return typeof tA.readFloatLE=="function"&&typeof tA.slice=="function"&&i(tA.slice(0,0))}var n=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=n.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,QA){if(typeof QA!="function")return rA;var SA={};for(var FA in rA)Object.prototype.hasOwnProperty.call(rA,FA)&&(SA[QA(FA,rA[FA])||FA]=rA[FA]);return SA}tA.exports?tA.exports=nA:window.rename=nA})()}),g=function tA(nA,rA){var QA=s(nA);if(QA!=="object"&&QA!=="array")throw new Error("expected an object");var SA=[];QA==="object"&&(nA=a(nA,rA),SA={});for(var FA in nA)if(nA.hasOwnProperty(FA)){var MA=nA[FA];s(MA)==="object"||s(MA)==="array"?SA[FA]=tA(MA,rA):SA[FA]=MA}return SA},I=r(function(tA){var nA=Object.prototype.hasOwnProperty,rA="~";function QA(){}Object.create&&(QA.prototype=Object.create(null),new QA().__proto__||(rA=!1));function SA(MA,TA,EA){this.fn=MA,this.context=TA,this.once=EA||!1}function FA(){this._events=new QA,this._eventsCount=0}FA.prototype.eventNames=function(){var TA=[],EA,GA;if(this._eventsCount===0)return TA;for(GA in EA=this._events)nA.call(EA,GA)&&TA.push(rA?GA.slice(1):GA);return Object.getOwnPropertySymbols?TA.concat(Object.getOwnPropertySymbols(EA)):TA},FA.prototype.listeners=function(TA,EA){var GA=rA?rA+TA:TA,dA=this._events[GA];if(EA)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},FA.prototype.emit=function(TA,EA,GA,dA,PA,JA){var it=rA?rA+TA:TA;if(!this._events[it])return!1;var yA=this._events[it],tt=arguments.length,qA,UA;if(yA.fn){switch(yA.once&&this.removeListener(TA,yA.fn,void 0,!0),tt){case 1:return yA.fn.call(yA.context),!0;case 2:return yA.fn.call(yA.context,EA),!0;case 3:return yA.fn.call(yA.context,EA,GA),!0;case 4:return yA.fn.call(yA.context,EA,GA,dA),!0;case 5:return yA.fn.call(yA.context,EA,GA,dA,PA),!0;case 6:return yA.fn.call(yA.context,EA,GA,dA,PA,JA),!0}for(UA=1,qA=new Array(tt-1);UA<tt;UA++)qA[UA-1]=arguments[UA];yA.fn.apply(yA.context,qA)}else{var ZA=yA.length,kA;for(UA=0;UA<ZA;UA++)switch(yA[UA].once&&this.removeListener(TA,yA[UA].fn,void 0,!0),tt){case 1:yA[UA].fn.call(yA[UA].context);break;case 2:yA[UA].fn.call(yA[UA].context,EA);break;case 3:yA[UA].fn.call(yA[UA].context,EA,GA);break;case 4:yA[UA].fn.call(yA[UA].context,EA,GA,dA);break;default:if(!qA)for(kA=1,qA=new Array(tt-1);kA<tt;kA++)qA[kA-1]=arguments[kA];yA[UA].fn.apply(yA[UA].context,qA)}}return!0},FA.prototype.on=function(TA,EA,GA){var dA=new SA(EA,GA||this),PA=rA?rA+TA:TA;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},FA.prototype.once=function(TA,EA,GA){var dA=new SA(EA,GA||this,!0),PA=rA?rA+TA:TA;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},FA.prototype.removeListener=function(TA,EA,GA,dA){var PA=rA?rA+TA:TA;if(!this._events[PA])return this;if(!EA)return--this._eventsCount===0?this._events=new QA:delete this._events[PA],this;var JA=this._events[PA];if(JA.fn)JA.fn===EA&&(!dA||JA.once)&&(!GA||JA.context===GA)&&(--this._eventsCount===0?this._events=new QA:delete this._events[PA]);else{for(var it=0,yA=[],tt=JA.length;it<tt;it++)(JA[it].fn!==EA||dA&&!JA[it].once||GA&&JA[it].context!==GA)&&yA.push(JA[it]);yA.length?this._events[PA]=yA.length===1?yA[0]:yA:--this._eventsCount===0?this._events=new QA:delete this._events[PA]}return this},FA.prototype.removeAllListeners=function(TA){var EA;return TA?(EA=rA?rA+TA:TA,this._events[EA]&&(--this._eventsCount===0?this._events=new QA:delete this._events[EA])):(this._events=new QA,this._eventsCount=0),this},FA.prototype.off=FA.prototype.removeListener,FA.prototype.addListener=FA.prototype.on,FA.prototype.setMaxListeners=function(){return this},FA.prefixed=rA,FA.EventEmitter=FA,tA.exports=FA});function c(tA,nA,rA){return nA in tA?Object.defineProperty(tA,nA,{value:rA,enumerable:!0,configurable:!0,writable:!0}):tA[nA]=rA,tA}var B=function(){},l={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"},E={text:"text",openTag:"open-tag",closeTag:"close-tag",attributeName:"attribute-name",attributeValue:"attribute-value"},Q={" ":C.space," ":C.space,"\n":C.space,"\r":C.space,"<":C.lt,">":C.gt,'"':C.quote,"'":C.quote,"=":C.equal,"/":C.slash},h=function(nA){return Q[nA]||C.char},u=function(nA){var rA,QA,SA,FA,MA,TA,EA,GA,dA,PA;nA=Object.assign({debug:!1},nA);var JA=new I,it=l.data,yA="",tt="",qA="",UA="",ZA="",kA="",DA=function(KA,OA){if(!(tt[0]==="?"||tt[0]==="!")){var $A={type:KA,value:OA};nA.debug&&console.log("emit:",$A),JA.emit("data",$A)}};JA.stateMachine=(PA={},c(PA,l.data,(rA={},c(rA,C.lt,function(){yA.trim()&&DA(E.text,yA),tt="",ZA=!1,it=l.tagBegin}),c(rA,C.char,function(bA){yA+=bA}),rA)),c(PA,l.cdata,c({},C.char,function(bA){yA+=bA,yA.substr(-3)==="]]>"&&(DA(E.text,yA.slice(0,-3)),yA="",it=l.data)})),c(PA,l.tagBegin,(QA={},c(QA,C.space,B),c(QA,C.char,function(bA){tt=bA,it=l.tagName}),c(QA,C.slash,function(){tt="",ZA=!0}),QA)),c(PA,l.tagName,(SA={},c(SA,C.space,function(){ZA?it=l.tagEnd:(it=l.attributeNameStart,DA(E.openTag,tt))}),c(SA,C.gt,function(){DA(ZA?E.closeTag:E.openTag,tt),yA="",it=l.data}),c(SA,C.slash,function(){it=l.tagEnd,DA(E.openTag,tt)}),c(SA,C.char,function(bA){tt+=bA,tt==="![CDATA["&&(it=l.cdata,yA="",tt="")}),SA)),c(PA,l.tagEnd,(FA={},c(FA,C.gt,function(){DA(E.closeTag,tt),yA="",it=l.data}),c(FA,C.char,B),FA)),c(PA,l.attributeNameStart,(MA={},c(MA,C.char,function(bA){qA=bA,it=l.attributeName}),c(MA,C.gt,function(){yA="",it=l.data}),c(MA,C.space,B),c(MA,C.slash,function(){ZA=!0,it=l.tagEnd}),MA)),c(PA,l.attributeName,(TA={},c(TA,C.space,function(){it=l.attributeNameEnd}),c(TA,C.equal,function(){DA(E.attributeName,qA),it=l.attributeValueBegin}),c(TA,C.gt,function(){UA="",DA(E.attributeName,qA),DA(E.attributeValue,UA),yA="",it=l.data}),c(TA,C.slash,function(){ZA=!0,UA="",DA(E.attributeName,qA),DA(E.attributeValue,UA),it=l.tagEnd}),c(TA,C.char,function(bA){qA+=bA}),TA)),c(PA,l.attributeNameEnd,(EA={},c(EA,C.space,B),c(EA,C.equal,function(){DA(E.attributeName,qA),it=l.attributeValueBegin}),c(EA,C.gt,function(){UA="",DA(E.attributeName,qA),DA(E.attributeValue,UA),yA="",it=l.data}),c(EA,C.char,function(bA){UA="",DA(E.attributeName,qA),DA(E.attributeValue,UA),qA=bA,it=l.attributeName}),EA)),c(PA,l.attributeValueBegin,(GA={},c(GA,C.space,B),c(GA,C.quote,function(bA){kA=bA,UA="",it=l.attributeValue}),c(GA,C.gt,function(){UA="",DA(E.attributeValue,UA),yA="",it=l.data}),c(GA,C.char,function(bA){kA="",UA=bA,it=l.attributeValue}),GA)),c(PA,l.attributeValue,(dA={},c(dA,C.space,function(bA){kA?UA+=bA:(DA(E.attributeValue,UA),it=l.attributeNameStart)}),c(dA,C.quote,function(bA){kA===bA?(DA(E.attributeValue,UA),it=l.attributeNameStart):UA+=bA}),c(dA,C.gt,function(bA){kA?UA+=bA:(DA(E.attributeValue,UA),yA="",it=l.data)}),c(dA,C.slash,function(bA){kA?UA+=bA:(DA(E.attributeValue,UA),ZA=!0,it=l.tagEnd)}),c(dA,C.char,function(bA){UA+=bA}),dA)),PA);var HA=function(KA){nA.debug&&console.log(it,KA);var OA=JA.stateMachine[it],$A=OA[h(KA)]||OA[C.error]||OA[C.char];$A(KA)};return JA.write=function(bA){for(var KA=bA.length,OA=0;OA<KA;OA++)HA(bA[OA])},JA},d={State:l,Action:C,Type:E,create:u},f=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,QA=void 0,SA=void 0,FA=void 0,MA=new I,TA=function(GA){switch(GA.type){case f.openTag:if(SA===null)SA=QA,SA.name=GA.value;else{var dA=w({name:GA.value,parent:SA});SA.children.push(dA),SA=dA}break;case f.closeTag:var PA=SA.parent;if(nA.parentNodes||(SA.parent=null),SA.name!==GA.value)break;nA.stream&&PA===QA&&(QA.children=[],SA.parent=null),(!nA.emitTopLevelOnly||PA===QA)&&(MA.emit(nA.tagPrefix+SA.name,SA),MA.emit("tag",SA.name,SA)),SA===QA&&(rA.removeAllListeners("data"),MA.emit(nA.doneEvent,SA),QA=null),SA=PA;break;case f.text:SA&&SA.children.push(w({type:m.text,value:GA.value,parent:nA.parentNodes?SA:null}));break;case f.attributeName:FA=GA.value,SA.attributes[FA]="";break;case f.attributeValue:SA.attributes[FA]=GA.value;break}};return MA.reset=function(){rA=d.create({debug:nA.debug}),rA.on("data",TA),QA=w(),SA=null,FA="",MA.parse=rA.write},MA.reset(),MA},b=function(nA,rA){rA=Object.assign({},rA,{stream:!1,tagPrefix:":"});var QA=D(rA),SA=void 0;return QA.on("done",function(FA){SA=FA}),QA.parse(nA),SA},k={parseSync:b},x=k.parseSync,N=function(nA){var rA=x("<root>".concat(nA,"</root>"),{parentNodes:!1}),QA=rA.children&&rA.children.length>0&&rA.children.every(function(SA){return SA.name==="svg"});if(QA)return rA.children.length===1?rA.children[0]:rA.children;throw Error("nothing to parse")},M=function(nA){return g(nA,function(rA){return J(rA)?rA:U(rA)})},U=function(nA){return nA.replace(/[-|:]([a-z])/gi,function(rA,QA){return QA.toUpperCase()})},J=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;")},W=function(nA){var rA=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},QA=rA.transformNode,SA=QA===void 0?function(EA){return EA}:QA,FA=rA.camelcase,MA=FA===void 0?!1:FA,TA=function(GA){var dA;return dA=SA(GA),MA&&(dA=M(dA)),dA};return TA(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(QA,SA){try{var FA=W.apply(void 0,nA);QA(FA)}catch(MA){SA(MA)}})}var iA=function tA(nA){var rA=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},QA=rA.transformAttr,SA=QA===void 0?function(it,yA,tt){return"".concat(it,'="').concat(tt(yA),'"')}:QA,FA=rA.transformNode,MA=FA===void 0?function(it){return it}:FA,TA=rA.selfClose,EA=TA===void 0?!0:TA;if(Array.isArray(nA))return nA.map(function(it){return tA(it,{transformAttr:SA,selfClose:EA,transformNode:MA})}).join("");var GA=MA(nA);if(GA.type==="text")return H(GA.value);var dA="";for(var PA in GA.attributes){var JA=SA(PA,GA.attributes[PA],O,GA.name);dA+=JA?" ".concat(JA):""}return GA.children&&GA.children.length>0||!EA?"<".concat(GA.name).concat(dA,">").concat(tA(GA.children,{transformAttr:SA,transformNode:MA,selfClose:EA}),"</").concat(GA.name,">"):"<".concat(GA.name).concat(dA,"/>")},gA=Object.assign({},{parse:$,parseSync:W,stringify:iA});return gA})}}),upA=Ga({"node_modules/js-beautify/js/src/core/output.js"(e,A){function t(n){this.__parent=n,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 n=new t(this.__parent);return n.set_indent(this.__indent_count,this.__alignment_count),n},t.prototype.item=function(n){return n<0?this.__items[this.__items.length+n]:this.__items[n]},t.prototype.has_match=function(n){for(var s=this.__items.length-1;s>=0;s--)if(this.__items[s].match(n))return!0;return!1},t.prototype.set_indent=function(n,s){this.is_empty()&&(this.__indent_count=n||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 n=this.__parent.current_line;return n.set_indent(this.__wrap_point_indent_count,this.__wrap_point_alignment_count),n.__items=this.__items.slice(this.__wrap_point_index),this.__items=this.__items.slice(0,this.__wrap_point_index),n.__character_count+=this.__character_count-this.__wrap_point_character_count,this.__character_count=this.__wrap_point_character_count,n.__items[0]===" "&&(n.__items.splice(0,1),n.__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(n){this.__items.push(n);var s=n.lastIndexOf(`
5383
+ `),a=[];let g=0;for(const c of r){const B=Array.from(c);let l=0;B.forEach((C,E)=>{l+=C===" "?o:t,E<B.length-1&&(l+=i)}),a.push(l),l>g&&(g=l)}const I=r.length>1?A+(r.length-1)*s:A;return{width:g,height:I,glyphWidth:t,letterSpacing:i,spaceWidth:o,strokeWidth:n,lineHeight:s,lines:r,lineWidths:a}}function npA(e,A){const t=A.width+A.strokeWidth,i=A.height+A.strokeWidth;let o=0,n=0;return e==="center"||e==="top_center"||e==="bottom_center"?o=-t/2:e==="top_left"||e==="bottom_left"||e==="center_left"?o=0:e==="top_right"||e==="bottom_right"||e==="center_right"?o=-t:(e==="top_center"||e==="bottom_center")&&(o=-t/2),e==="center"||e==="center_left"||e==="center_right"?n=-i/2:e==="top_left"||e==="top_right"||e==="top_center"?n=0:(e==="bottom_left"||e==="bottom_right"||e==="bottom_center")&&(n=-i),{x:o,y:n}}function spA(e){const{alignment:A,lineWidth:t,maxWidth:i,strokeWidth:o}=e,n=t+o,s=i+o;return A==="top_left"||A==="bottom_left"||A==="center_left"?0:A==="top_right"||A==="bottom_right"||A==="center_right"?s-n:(s-n)/2}var RPe=e=>Vw[e]??Vw[e.toUpperCase()];function rpA(e){const{ctx:A,line:t,fontSize:i,startX:o,startY:n,layout:s}=e,{glyphWidth:r,letterSpacing:a,spaceWidth:g,strokeWidth:I}=s,c=i,B=n,l=Array.from(t);let C=o+I/2;l.forEach((E,Q)=>{const h=RPe(E),u=E===" "?g:r;if(h?.length){A.beginPath();for(const d of h){const f=C+d.x1*r,m=B+(1-d.y1)*c,w=C+d.x2*r,D=B+(1-d.y2)*c;A.moveTo(f,m),A.lineTo(w,D)}A.stroke()}C+=u,Q<l.length-1&&(C+=a)})}function MPe(e){const{ctx:A,text:t,fontSize:i,startX:o,startY:n,anchorAlignment:s="center"}=e,r=GV(t,i),{lines:a,lineWidths:g,lineHeight:I,width:c,strokeWidth:B}=r;a.forEach((l,C)=>{const E=o+spA({alignment:s,lineWidth:g[C],maxWidth:c,strokeWidth:B}),Q=n+C*I;rpA({ctx:A,line:l,fontSize:i,startX:E,startY:Q,layout:r})})}function apA(e){const{ctx:A,text:t,x:i,y:o,fontSize:n,color:s,realToCanvasMat:r,anchorAlignment:a,rotation:g=0}=e;if(!t)return;const[I,c]=Io(r,[i,o]),B=Math.abs(r.a),l=n*B,C=GV(t,l),E=npA(a,C);A.save(),A.translate(I,c),g!==0&&A.rotate(-g*(Math.PI/180)),A.lineWidth=C.strokeWidth,A.lineCap="round",A.lineJoin="round",A.strokeStyle=s;const{lines:Q,lineWidths:h,lineHeight:u,width:d,strokeWidth:f}=C;Q.forEach((m,w)=>{const D=E.x+spA({alignment:a,lineWidth:h[w],maxWidth:d,strokeWidth:f}),b=E.y+w*u;rpA({ctx:A,line:m,fontSize:l,startX:D,startY:b,layout:C})}),A.restore()}var NPe={left:.2,right:.2,top:.2,bottom:.2};function vPe(e){return e?e.includes("left")?"center_left":e.includes("right")?"center_right":"center":"center"}function LPe(e){const{ctx:A,text:t,realToCanvasMat:i,colorMap:o}=e,n=t.text??"";if(!n)return;const[s,r]=Io(i,[t.anchor_position.x,t.anchor_position.y]),a=Math.abs(i.a),g=(t.font_size??1)*a,I=t.ccw_rotation??0,c={...NPe,...t.knockout_padding},B=o.copper[t.layer]??o.copper.top,l=GV(n,g),C=l.width+l.strokeWidth,E=vPe(t.anchor_alignment),Q=npA(E,l);if(A.save(),A.translate(s,r),t.is_mirrored&&A.scale(-1,1),I!==0&&A.rotate(-I*(Math.PI/180)),A.lineWidth=l.strokeWidth,A.lineCap="round",A.lineJoin="round",t.is_knockout){const h=c.left*a,u=c.right*a,d=c.top*a,f=c.bottom*a,m=Q.x-h*4,w=Q.y-d*4,D=C+h*2+u*2,b=l.height+l.strokeWidth+d*2+f*2;A.fillStyle=B,A.fillRect(m,w,D,b)}else A.strokeStyle=B;MPe({ctx:A,text:n,fontSize:g,startX:Q.x,startY:Q.y,anchorAlignment:E}),A.restore()}function pD(e){const{ctx:A,center:t,radius:i,fill:o,realToCanvasMat:n,stroke:s,strokeWidth:r,isStrokeDashed:a=!1}=e,[g,I]=Io(n,[t.x,t.y]),c=i*Math.abs(n.a),B=r?r*Math.abs(n.a):void 0;A.beginPath(),A.arc(g,I,c,0,Math.PI*2),o&&(A.fillStyle=o,A.fill()),s&&B&&(a?A.setLineDash([B*3,B*2]):A.setLineDash([]),A.strokeStyle=s,A.lineWidth=B,A.stroke())}function UPe(e){const{ctx:A,cutout:t,realToCanvasMat:i,colorMap:o}=e;if(t.shape==="rect"){w0({ctx:A,center:t.center,width:t.width,height:t.height,fill:o.drill,realToCanvasMat:i,rotation:t.rotation??0,borderRadius:t.corner_radius??0});return}if(t.shape==="circle"){pD({ctx:A,center:t.center,radius:t.radius,fill:o.drill,realToCanvasMat:i});return}if(t.shape==="polygon"){t.points&&t.points.length>=3&&LY({ctx:A,points:t.points,fill:o.drill,realToCanvasMat:i});return}}var HPe=1.5,YPe=.6,JPe=.3;function gpA(e){const A=Math.hypot(e.x,e.y)||1;return{x:e.x/A,y:e.y/A}}function rat(e){const{ctx:A,from:t,to:i,realToCanvasMat:o,color:n,fontSize:s,arrowSize:r=1,strokeWidth:a,text:g,textRotation:I,offset:c}=e,B=gpA({x:i.x-t.x,y:i.y-t.y}),l={x:-B.y,y:B.x},C=c?.direction&&typeof c.direction.x=="number"&&typeof c.direction.y=="number",E=C?gpA(c.direction):{x:0,y:0},Q=c?.distance??0,h={x:E.x*Q,y:E.y*Q},u={x:t.x+h.x,y:t.y+h.y},d={x:i.x+h.x,y:i.y+h.y},f={x:u.x+B.x*r,y:u.y+B.y*r},m={x:d.x-B.x*r,y:d.y-B.y*r};Math.abs(o.a);const w=a??r/5,D=n||"rgba(255,255,255,0.5)",b=C&&(Math.abs(E.x)>Number.EPSILON||Math.abs(E.y)>Number.EPSILON)?E:l,k=Q+.5,x=[],N=J=>{const H={x:J.x+b.x*k,y:J.y+b.y*k},O=w/2,W={x:-b.y,y:b.x};return[{x:J.x+W.x*O,y:J.y+W.y*O},{x:J.x-W.x*O,y:J.y-W.y*O},{x:H.x-W.x*O,y:H.y-W.y*O},{x:H.x+W.x*O,y:H.y+W.y*O}]};x.push(u),x.push({x:f.x+l.x*(r/2),y:f.y+l.y*(r/2)}),x.push({x:f.x+l.x*(w/2),y:f.y+l.y*(w/2)}),x.push({x:m.x+l.x*(w/2),y:m.y+l.y*(w/2)}),x.push({x:m.x+l.x*(r/2),y:m.y+l.y*(r/2)}),x.push(d),x.push({x:m.x-l.x*(r/2),y:m.y-l.y*(r/2)}),x.push({x:m.x-l.x*(w/2),y:m.y-l.y*(w/2)}),x.push({x:f.x-l.x*(w/2),y:f.y-l.y*(w/2)}),x.push({x:f.x-l.x*(r/2),y:f.y-l.y*(r/2)}),x.push(u);const M=x[0],U=J=>{const H=N(J);x.push(M),x.push(H[0]),x.push(...H),x.push(H[0]),x.push(M)};if(U(t),U(i),LY({ctx:A,points:x,fill:D,realToCanvasMat:o}),g){const J={x:(t.x+i.x)/2+h.x,y:(t.y+i.y)/2+h.y},[H,O]=Io(o,[u.x,u.y]),[W,$]=Io(o,[d.x,d.y]),iA=gpA({x:W-H,y:$-O});let gA=Math.atan2(iA.y,iA.x)*180/Math.PI;(gA>90||gA<-90)&&(gA+=180);const tA=typeof I=="number"&&Number.isFinite(I)?gA-I:gA;let nA=0;if(g&&typeof I=="number"&&Number.isFinite(I)){const SA=g.length*s*YPe,FA=s,MA=I*Math.PI/180,TA=Math.abs(Math.sin(MA)),EA=Math.abs(Math.cos(MA)),GA=SA/2,dA=FA/2;nA=GA*TA+dA*EA+s*JPe}const rA=r*HPe+nA,QA={x:J.x+l.x*rA,y:J.y+l.y*rA};apA({ctx:A,text:g,x:QA.x,y:QA.y,fontSize:s,color:D,realToCanvasMat:o,anchorAlignment:"center",rotation:-tA})}}var TPe="rgba(255,255,255,0.5)";function KPe(e){const{ctx:A,pcbFabricationNoteDimension:t,realToCanvasMat:i}=e,o=t.color??TPe;rat({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 UY(e){const{ctx:A,start:t,end:i,strokeWidth:o,stroke:n,realToCanvasMat:s,lineCap:r="round"}=e,[a,g]=Io(s,[t.x,t.y]),[I,c]=Io(s,[i.x,i.y]),B=o*Math.abs(s.a);A.beginPath(),A.moveTo(a,g),A.lineTo(I,c),A.lineWidth=B,A.strokeStyle=n,A.lineCap=r,A.stroke()}function PPe(e){const{ctx:A,path:t,realToCanvasMat:i}=e,n=t.color??"rgba(255,255,255,0.5)";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||UY({ctx:A,start:{x:r.x,y:r.y},end:{x:a.x,y:a.y},strokeWidth:t.stroke_width??.1,stroke:n,realToCanvasMat:i})}}function qPe(e){const{ctx:A,rect:t,realToCanvasMat:i}=e,n=t.color??"rgba(255,255,255,0.5)",s=t.is_filled??!1,r=t.has_stroke??!0,a=t.is_stroke_dashed??!1;w0({ctx:A,center:t.center,width:t.width,height:t.height,fill:s?n:void 0,stroke:r?n:void 0,strokeWidth:r?t.stroke_width:void 0,borderRadius:t.corner_radius,realToCanvasMat:i,isStrokeDashed:a})}var OPe="rgba(255,255,255,0.5)";function WPe(e,A){return OPe}function ZPe(e){const{ctx:A,text:t,realToCanvasMat:i}=e,o=WPe(t.layer),n=t.color??o,s=t.font_size;apA({ctx:A,text:t.text,x:t.anchor_position.x,y:t.anchor_position.y,fontSize:s,color:n,realToCanvasMat:i,anchorAlignment:t.anchor_alignment})}function HY(e){const{ctx:A,center:t,radius_x:i,radius_y:o,fill:n,stroke:s,strokeWidth:r=.1,realToCanvasMat:a,rotation:g=0}=e,[I,c]=Io(a,[t.x,t.y]),B=i*Math.abs(a.a),l=o*Math.abs(a.a),C=r*Math.abs(a.a);A.save(),A.translate(I,c),g!==0&&A.rotate(-g*(Math.PI/180)),A.beginPath(),A.ellipse(0,0,B,l,0,0,Math.PI*2),n&&(A.fillStyle=n,A.fill()),s&&(A.strokeStyle=s,A.lineWidth=C,A.stroke()),A.restore()}function fD(e){const{ctx:A,center:t,width:i,height:o,fill:n,realToCanvasMat:s,rotation:r=0,stroke:a,strokeWidth:g}=e,[I,c]=Io(s,[t.x,t.y]),B=i*Math.abs(s.a),l=o*Math.abs(s.a),C=g?g*Math.abs(s.a):void 0;if(A.save(),A.translate(I,c),r!==0&&A.rotate(-r*(Math.PI/180)),A.beginPath(),B>l){const E=l/2,Q=B-l;A.moveTo(-Q/2,-E),A.lineTo(Q/2,-E),A.arc(Q/2,0,E,-Math.PI/2,Math.PI/2),A.lineTo(-Q/2,E),A.arc(-Q/2,0,E,Math.PI/2,-Math.PI/2)}else if(l>B){const E=B/2,Q=l-B;A.moveTo(E,-Q/2),A.lineTo(E,Q/2),A.arc(0,Q/2,E,0,Math.PI),A.lineTo(-E,-Q/2),A.arc(0,-Q/2,E,Math.PI,0)}else A.arc(0,0,B/2,0,Math.PI*2);A.closePath(),n&&(A.fillStyle=n,A.fill()),a&&C&&(A.strokeStyle=a,A.lineWidth=C,A.stroke()),A.restore()}function FV(e){return"ccw_rotation"in e&&typeof e.ccw_rotation=="number"?e.ccw_rotation:0}function VPe(e){const{ctx:A,hole:t,realToCanvasMat:i,colorMap:o,soldermaskMargin:n=0,drawSoldermask:s=!1}=e;if(s&&t.is_covered_with_solder_mask===!0)return;const r=n<0?Math.abs(n):0;if(t.hole_shape==="circle"){pD({ctx:A,center:{x:t.x,y:t.y},radius:t.hole_diameter/2-r,fill:o.drill,realToCanvasMat:i});return}if(t.hole_shape==="square"){const a=FV(t);w0({ctx:A,center:{x:t.x,y:t.y},width:t.hole_diameter-r*2,height:t.hole_diameter-r*2,fill:o.drill,realToCanvasMat:i,rotation:a});return}if(t.hole_shape==="oval"){const a=FV(t);HY({ctx:A,center:{x:t.x,y:t.y},radius_x:t.hole_width/2-r,radius_y:t.hole_height/2-r,fill:o.drill,realToCanvasMat:i,rotation:a});return}if(t.hole_shape==="rect"){const a=FV(t);w0({ctx:A,center:{x:t.x,y:t.y},width:t.hole_width-r*2,height:t.hole_height-r*2,fill:o.drill,realToCanvasMat:i,rotation:a});return}if(t.hole_shape==="pill"||t.hole_shape==="rotated_pill"){const a=FV(t);fD({ctx:A,center:{x:t.x,y:t.y},width:t.hole_width-r*2,height:t.hole_height-r*2,fill:o.drill,realToCanvasMat:i,rotation:a});return}}function jPe(e,A){const t=parseInt(e.slice(1,3),16),i=parseInt(e.slice(3,5),16),o=parseInt(e.slice(5,7),16);return`rgba(${t}, ${i}, ${o}, ${A})`}function zPe(e){const{ctx:A,keepout:t,realToCanvasMat:i,colorMap:o}=e,n=o.keepout,s=jPe(o.keepout,.2),r=1;if(t.shape==="rect"){const[a,g]=Io(i,[t.center.x,t.center.y]),I=t.width*Math.abs(i.a),c=t.height*Math.abs(i.a),B=t.rotation??0;A.save(),A.translate(a,g),B!==0&&A.rotate(-B*(Math.PI/180)),A.beginPath(),A.rect(-I/2,-c/2,I,c),A.fillStyle=s,A.fill(),A.beginPath(),A.rect(-I/2,-c/2,I,c),A.clip();const l=r*Math.abs(i.a),C=Math.sqrt(I*I+c*c),E=I/2,Q=c/2;A.strokeStyle=n,A.lineWidth=.15*Math.abs(i.a),A.setLineDash([]);for(let h=-C;h<C*2;h+=l){A.beginPath();const u=-E+h,d=-Q,f=-E+h+C,m=-Q+C;A.moveTo(u,d),A.lineTo(f,m),A.stroke()}A.restore();return}if(t.shape==="circle"){const[a,g]=Io(i,[t.center.x,t.center.y]),I=t.radius*Math.abs(i.a),c=r*Math.abs(i.a);A.save(),A.translate(a,g),A.beginPath(),A.arc(0,0,I,0,Math.PI*2),A.fillStyle=s,A.fill(),A.beginPath(),A.arc(0,0,I,0,Math.PI*2),A.clip();const B=I*2;A.strokeStyle=n,A.lineWidth=.15*Math.abs(i.a),A.setLineDash([]);for(let l=-B;l<B*2;l+=c)A.beginPath(),A.moveTo(l-B,-B),A.lineTo(l+B,B),A.stroke();A.restore();return}}var XPe="rgba(255,255,255,0.5)";function $Pe(e){const{ctx:A,pcbNoteDimension:t,realToCanvasMat:i}=e,o=t.color??XPe;rat({ctx:A,from:t.from,to:t.to,realToCanvasMat:i,color:o,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 Aqe(e){const{ctx:A,line:t,realToCanvasMat:i}=e,n=t.color??"rgb(89, 148, 220)",s=t.stroke_width??.1,r=t.is_dashed??!1,[a,g]=Io(i,[t.x1,t.y1]),[I,c]=Io(i,[t.x2,t.y2]),B=s*Math.abs(i.a);A.save(),r?A.setLineDash([B*2,B*2]):A.setLineDash([]),A.beginPath(),A.moveTo(a,g),A.lineTo(I,c),A.lineWidth=B,A.strokeStyle=n,A.lineCap="round",A.stroke(),A.restore()}function tqe(e){const{ctx:A,path:t,realToCanvasMat:i}=e,n=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||UY({ctx:A,start:{x:r.x,y:r.y},end:{x:a.x,y:a.y},strokeWidth:t.stroke_width??.1,stroke:n,realToCanvasMat:i})}}function eqe(e){const{ctx:A,rect:t,realToCanvasMat:i}=e,n=t.color??"rgb(89, 148, 220)",s=t.is_filled??!1,r=t.has_stroke??!0,a=t.is_stroke_dashed??!1;w0({ctx:A,center:t.center,width:t.width,height:t.height,fill:s?n:void 0,stroke:r?n:void 0,strokeWidth:r?t.stroke_width:void 0,borderRadius:t.corner_radius,realToCanvasMat:i,isStrokeDashed:a})}var iqe="rgb(89, 148, 220)";function oqe(e){const{ctx:A,text:t,realToCanvasMat:i}=e,o=iqe,n=t.color??o,s=t.font_size??1;apA({ctx:A,text:t.text??"",x:t.anchor_position.x,y:t.anchor_position.y,fontSize:s,color:n,realToCanvasMat:i,anchorAlignment:t.anchor_alignment??"center"})}function nqe(e){const{ctx:A,panel:t,realToCanvasMat:i,colorMap:o,drawBoardMaterial:n}=e,{width:s,height:r,center:a}=t;if(s!==void 0&&r!==void 0&&a){n&&w0({ctx:A,center:a,width:s,height:r,fill:o.substrate,realToCanvasMat:i});const g=s/2,I=r/2,c=[{x:a.x-g,y:a.y-I},{x:a.x+g,y:a.y-I},{x:a.x+g,y:a.y+I},{x:a.x-g,y:a.y+I}];kV({ctx:A,points:c,stroke:o.boardOutline,strokeWidth:.5,realToCanvasMat:i,closePath:!0})}}function YY(e,A){if(e.length<3||A===0)return e;let t=0,i=0;for(const n of e)t+=n.x,i+=n.y;t/=e.length,i/=e.length;const o=[];for(const n of e){const s=n.x-t,r=n.y-i,a=Math.sqrt(s*s+r*r);if(a>0){const g=s/a,I=r/a;o.push({x:n.x+g*A,y:n.y+I*A})}else o.push({x:n.x+A,y:n.y})}return o}function sqe(e){const{ctx:A,hole:t,realToCanvasMat:i,colorMap:o,soldermaskMargin:n=0,drawSoldermask:s}=e;if(t.is_covered_with_solder_mask===!0&&s)return;const r=o.copper.top,a=n<0?Math.abs(n):0;if(t.shape==="circle"){pD({ctx:A,center:{x:t.x,y:t.y},radius:t.outer_diameter/2-a,fill:r,realToCanvasMat:i}),pD({ctx:A,center:{x:t.x,y:t.y},radius:t.hole_diameter/2,fill:o.drill,realToCanvasMat:i});return}if(t.shape==="oval"){HY({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}),HY({ctx:A,center:{x:t.x,y:t.y},radius_x:t.hole_width/2,radius_y:t.hole_height/2,fill:o.drill,realToCanvasMat:i,rotation:t.ccw_rotation});return}if(t.shape==="pill"){fD({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}),fD({ctx:A,center:{x:t.x,y:t.y},width:t.hole_width,height:t.hole_height,fill:o.drill,realToCanvasMat:i,rotation:t.ccw_rotation});return}if(t.shape==="circular_hole_with_rect_pad"){w0({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),I=t.y+(t.hole_offset_y??0);pD({ctx:A,center:{x:g,y:I},radius:t.hole_diameter/2,fill:o.drill,realToCanvasMat:i});return}if(t.shape==="pill_hole_with_rect_pad"){w0({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),I=t.y+(t.hole_offset_y??0);fD({ctx:A,center:{x:g,y:I},width:t.hole_width,height:t.hole_height,fill:o.drill,realToCanvasMat:i});return}if(t.shape==="rotated_pill_hole_with_rect_pad"){w0({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),I=t.y+(t.hole_offset_y??0);fD({ctx:A,center:{x:g,y:I},width:t.hole_width,height:t.hole_height,fill:o.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 l=g.map(E=>({x:t.x+E.x,y:t.y+E.y})),C=a>0?YY(l,-a):l;C.length>=3&&LY({ctx:A,points:C,fill:r,realToCanvasMat:i})}const I=t.x+(t.hole_offset_x??0),c=t.y+(t.hole_offset_y??0),B=t.hole_shape;B==="circle"?pD({ctx:A,center:{x:I,y:c},radius:(t.hole_diameter??0)/2,fill:o.drill,realToCanvasMat:i}):B==="oval"?HY({ctx:A,center:{x:I,y:c},radius_x:(t.hole_width??0)/2,radius_y:(t.hole_height??0)/2,fill:o.drill,realToCanvasMat:i}):B==="pill"?fD({ctx:A,center:{x:I,y:c},width:t.hole_width??0,height:t.hole_height??0,fill:o.drill,realToCanvasMat:i}):B==="rotated_pill"&&fD({ctx:A,center:{x:I,y:c},width:t.hole_width??0,height:t.hole_height??0,fill:o.drill,realToCanvasMat:i});return}}function rqe(e,A){return e==="bottom"?A.silkscreen.bottom:A.silkscreen.top}function aqe(e){const{ctx:A,circle:t,realToCanvasMat:i,colorMap:o}=e,n=rqe(t.layer,o);pD({ctx:A,center:t.center,radius:t.radius,stroke:n,strokeWidth:t.stroke_width,realToCanvasMat:i})}function gqe(e,A){return e==="bottom"?A.silkscreen.bottom:A.silkscreen.top}function Iqe(e){const{ctx:A,line:t,realToCanvasMat:i,colorMap:o}=e,n=gqe(t.layer,o);UY({ctx:A,start:{x:t.x1,y:t.y1},end:{x:t.x2,y:t.y2},strokeWidth:t.stroke_width??.1,stroke:n,realToCanvasMat:i})}function cqe(e,A){return e==="bottom"?A.silkscreen.bottom:A.silkscreen.top}function Bqe(e){const{ctx:A,oval:t,realToCanvasMat:i,colorMap:o}=e,n=cqe(t.layer,o);HY({ctx:A,center:t.center,radius_x:t.radius_x,radius_y:t.radius_y,stroke:n,strokeWidth:.1,realToCanvasMat:i,rotation:t.ccw_rotation??0})}function lqe(e,A){return e==="bottom"?A.silkscreen.bottom:A.silkscreen.top}function Cqe(e){const{ctx:A,path:t,realToCanvasMat:i,colorMap:o}=e,n=lqe(t.layer,o);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||UY({ctx:A,start:{x:r.x,y:r.y},end:{x:a.x,y:a.y},strokeWidth:t.stroke_width??.1,stroke:n,realToCanvasMat:i})}}function Qqe(e,A){return e==="bottom"?A.silkscreen.bottom:A.silkscreen.top}function Eqe(e){const{ctx:A,pill:t,realToCanvasMat:i,colorMap:o}=e,n=Qqe(t.layer,o);fD({ctx:A,center:t.center,width:t.width,height:t.height,stroke:n,strokeWidth:.2,realToCanvasMat:i})}function hqe(e,A){return e==="bottom"?A.silkscreen.bottom:A.silkscreen.top}function uqe(e){const{ctx:A,rect:t,realToCanvasMat:i,colorMap:o}=e,n=hqe(t.layer,o);w0({ctx:A,center:t.center,width:t.width,height:t.height,fill:t.is_filled?n:"transparent",stroke:n,strokeWidth:t.stroke_width,realToCanvasMat:i})}function dqe(e,A){return e==="bottom"?A.silkscreen.bottom:A.silkscreen.top}function pqe(e){return e||"center"}function fqe(e){const{ctx:A,text:t,realToCanvasMat:i,colorMap:o}=e,n=t.text??"";if(!n)return;const s=dqe(t.layer,o),[r,a]=Io(i,[t.anchor_position.x,t.anchor_position.y]),g=Math.abs(i.a),I=(t.font_size??1)*g,c=t.ccw_rotation??0,B=GV(n,I),l=pqe(t.anchor_alignment),C=npA(l,B);A.save(),A.translate(r,a),c!==0&&A.rotate(-c*(Math.PI/180)),t.layer==="bottom"&&A.scale(-1,1),A.lineWidth=B.strokeWidth,A.lineCap="round",A.lineJoin="round",A.strokeStyle=s;const{lines:E,lineWidths:Q,lineHeight:h,width:u,strokeWidth:d}=B;E.forEach((f,m)=>{const w=C.x+spA({alignment:l,lineWidth:Q[m],maxWidth:u,strokeWidth:d}),D=C.y+m*h;rpA({ctx:A,line:f,fontSize:I,startX:w,startY:D,layout:B})}),A.restore()}function yqe(e,A){return A.copper[e]??A.copper.top}function aat(e){return e.shape==="rect"||e.shape==="rotated_rect"?e.corner_radius??e.rect_border_radius??0:0}function mqe(e){const{ctx:A,pad:t,realToCanvasMat:i,colorMap:o}=e,n=yqe(t.layer,o);if(t.shape==="rect"){w0({ctx:A,center:{x:t.x,y:t.y},width:t.width,height:t.height,fill:n,realToCanvasMat:i,borderRadius:aat(t)});return}if(t.shape==="rotated_rect"){w0({ctx:A,center:{x:t.x,y:t.y},width:t.width,height:t.height,fill:n,realToCanvasMat:i,borderRadius:aat(t),rotation:t.ccw_rotation??0});return}if(t.shape==="circle"){pD({ctx:A,center:{x:t.x,y:t.y},radius:t.radius,fill:n,realToCanvasMat:i});return}if(t.shape==="pill"){fD({ctx:A,center:{x:t.x,y:t.y},width:t.width,height:t.height,fill:n,realToCanvasMat:i});return}if(t.shape==="rotated_pill"){fD({ctx:A,center:{x:t.x,y:t.y},width:t.width,height:t.height,fill:n,realToCanvasMat:i,rotation:t.ccw_rotation??0});return}if(t.shape==="polygon"){t.points&&t.points.length>=3&&LY({ctx:A,points:t.points,fill:n,realToCanvasMat:i});return}}function L_(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 o=1;o<t.length;o++){const n=t[o];n&&A.lineTo(n.x,n.y)}A.closePath()}}function wqe(e){const{ctx:A,board:t,realToCanvasMat:i,soldermaskColor:o}=e,{width:n,height:s,center:r,outline:a}=t;if(a&&Array.isArray(a)&&a.length>=3){const g=a.map(I=>{const[c,B]=Io(i,[I.x,I.y]);return{x:c,y:B}});A.beginPath(),L_({ctx:A,points:g}),A.fillStyle=o,A.fill()}else if(n!==void 0&&s!==void 0&&r){const[g,I]=Io(i,[r.x,r.y]),c=n*Math.abs(i.a),B=s*Math.abs(i.a);A.fillStyle=o,A.fillRect(g-c/2,I-B/2,c,B)}}function U_(e){const{ctx:A,cx:t,cy:i,width:o,height:n,radius:s}=e,r=t-o/2,a=i-n/2,g=Math.min(s,o/2,n/2);g>0?(A.moveTo(r+g,a),A.lineTo(r+o-g,a),A.arcTo(r+o,a,r+o,a+g,g),A.lineTo(r+o,a+n-g),A.arcTo(r+o,a+n,r+o-g,a+n,g),A.lineTo(r+g,a+n),A.arcTo(r,a+n,r,a+n-g,g),A.lineTo(r,a+g),A.arcTo(r,a,r+g,a,g)):A.rect(r,a,o,n),A.closePath()}function Dqe(e){const{ctx:A,cutout:t,realToCanvasMat:i,colorMap:o}=e;if(A.fillStyle=o.drill,t.shape==="rect"){const[n,s]=Io(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(n,s),t.rotation&&A.rotate(-t.rotation*Math.PI/180),A.beginPath(),U_({ctx:A,cx:0,cy:0,width:r,height:a,radius:g}),A.restore(),A.fill()}else if(t.shape==="circle"){const[n,s]=Io(i,[t.center?.x??0,t.center?.y??0]),r=t.radius*Math.abs(i.a);A.beginPath(),A.arc(n,s,r,0,Math.PI*2),A.closePath(),A.fill()}else if(t.shape==="polygon"&&t.points&&t.points.length>=3){const n=t.points.map(s=>{const[r,a]=Io(i,[s.x,s.y]);return{x:r,y:a}});A.beginPath(),L_({ctx:A,points:n}),A.fill()}}function lb(e){const{ctx:A,cx:t,cy:i,width:o,height:n}=e;if(o>n){const s=n/2,r=o-n;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(n>o){const s=o/2,r=n-o;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,o/2,0,Math.PI*2);A.closePath()}function Sqe(e){const{ctx:A,hole:t,realToCanvasMat:i,colorMap:o,soldermaskOverCopperColor:n,drawSoldermask:s}=e,r=s&&t.is_covered_with_solder_mask===!0,a=s?t.soldermask_margin??0:0;r?(A.fillStyle=n,JY({ctx:A,hole:t,realToCanvasMat:i,margin:0}),A.fill()):a<0?(A.fillStyle=o.drill,JY({ctx:A,hole:t,realToCanvasMat:i,margin:0}),A.fill(),bqe({ctx:A,hole:t,realToCanvasMat:i,soldermaskOverCopperColor:n,margin:a})):a>0?(A.fillStyle=o.substrate,JY({ctx:A,hole:t,realToCanvasMat:i,margin:a}),A.fill(),A.fillStyle=o.drill,JY({ctx:A,hole:t,realToCanvasMat:i,margin:0}),A.fill()):(A.fillStyle=o.drill,JY({ctx:A,hole:t,realToCanvasMat:i,margin:0}),A.fill())}function gat(e){return"ccw_rotation"in e&&typeof e.ccw_rotation=="number"?e.ccw_rotation:0}function JY(e){const{ctx:A,hole:t,realToCanvasMat:i,margin:o}=e,n=gat(t);if(t.hole_shape==="circle"){const[s,r]=Io(i,[t.x,t.y]),a=(t.hole_diameter/2+o)*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]=Io(i,[t.x,t.y]),a=(t.hole_diameter+o*2)*Math.abs(i.a);A.save(),A.translate(s,r),n!==0&&A.rotate(-n*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]=Io(i,[t.x,t.y]),a=(t.hole_width/2+o)*Math.abs(i.a),g=(t.hole_height/2+o)*Math.abs(i.a);A.save(),A.translate(s,r),n!==0&&A.rotate(-n*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]=Io(i,[t.x,t.y]),a=(t.hole_width+o*2)*Math.abs(i.a),g=(t.hole_height+o*2)*Math.abs(i.a);A.save(),A.translate(s,r),n!==0&&A.rotate(-n*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]=Io(i,[t.x,t.y]),a=(t.hole_width+o*2)*Math.abs(i.a),g=(t.hole_height+o*2)*Math.abs(i.a);A.save(),A.translate(s,r),n!==0&&A.rotate(-n*Math.PI/180),A.beginPath(),lb({ctx:A,cx:0,cy:0,width:a,height:g}),A.restore()}}function bqe(e){const{ctx:A,hole:t,realToCanvasMat:i,soldermaskOverCopperColor:o,margin:n}=e,s=Math.abs(n),r=gat(t);if(A.fillStyle=o,t.hole_shape==="circle"){const[a,g]=Io(i,[t.x,t.y]),I=t.hole_diameter/2*Math.abs(i.a),c=s*Math.abs(i.a),B=Math.max(0,I-c);A.save(),A.beginPath(),A.arc(a,g,I,0,Math.PI*2),B>0&&A.arc(a,g,B,0,Math.PI*2,!0),A.fill("evenodd"),A.restore()}else if(t.hole_shape==="square"){const[a,g]=Io(i,[t.x,t.y]),I=t.hole_diameter*Math.abs(i.a),c=s*Math.abs(i.a),B=Math.max(0,I-c*2);A.save(),A.translate(a,g),r!==0&&A.rotate(-r*Math.PI/180),A.beginPath(),A.rect(-I/2,-I/2,I,I),B>0&&A.rect(-B/2,-B/2,B,B),A.fill("evenodd"),A.restore()}else if(t.hole_shape==="oval"){const[a,g]=Io(i,[t.x,t.y]),I=t.hole_width/2*Math.abs(i.a),c=t.hole_height/2*Math.abs(i.a),B=s*Math.abs(i.a),l=Math.max(0,I-B),C=Math.max(0,c-B);A.save(),A.translate(a,g),r!==0&&A.rotate(-r*Math.PI/180),A.beginPath(),A.ellipse(0,0,I,c,0,0,Math.PI*2),l>0&&C>0&&(A.moveTo(l,0),A.ellipse(0,0,l,C,0,0,Math.PI*2)),A.fill("evenodd"),A.restore()}else if(t.hole_shape==="rect"){const[a,g]=Io(i,[t.x,t.y]),I=t.hole_width*Math.abs(i.a),c=t.hole_height*Math.abs(i.a),B=s*Math.abs(i.a),l=Math.max(0,I-B*2),C=Math.max(0,c-B*2);A.save(),A.translate(a,g),r!==0&&A.rotate(-r*Math.PI/180),A.beginPath(),A.rect(-I/2,-c/2,I,c),l>0&&C>0&&A.rect(-l/2,-C/2,l,C),A.fill("evenodd"),A.restore()}else if(t.hole_shape==="pill"||t.hole_shape==="rotated_pill"){const[a,g]=Io(i,[t.x,t.y]),I=t.hole_width*Math.abs(i.a),c=t.hole_height*Math.abs(i.a),B=s*Math.abs(i.a);A.save(),A.translate(a,g),r!==0&&A.rotate(-r*Math.PI/180),A.beginPath(),lb({ctx:A,cx:0,cy:0,width:I,height:c});const l=I-B*2,C=c-B*2;l>0&&C>0&&lb({ctx:A,cx:0,cy:0,width:l,height:C}),A.fill("evenodd"),A.restore()}}function xqe(e){const{ctx:A,hole:t,realToCanvasMat:i,colorMap:o,soldermaskOverCopperColor:n,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,I=o.copper.top;a?(A.fillStyle=n,TY({ctx:A,hole:t,realToCanvasMat:i,margin:0}),A.fill()):g<0?(A.fillStyle=I,TY({ctx:A,hole:t,realToCanvasMat:i,margin:0}),A.fill(),_qe({ctx:A,hole:t,realToCanvasMat:i,soldermaskOverCopperColor:n,margin:g})):g>0?(A.fillStyle=o.substrate,TY({ctx:A,hole:t,realToCanvasMat:i,margin:g}),A.fill(),A.fillStyle=I,TY({ctx:A,hole:t,realToCanvasMat:i,margin:0}),A.fill()):(A.fillStyle=I,TY({ctx:A,hole:t,realToCanvasMat:i,margin:0}),A.fill())}function TY(e){const{ctx:A,hole:t,realToCanvasMat:i,margin:o}=e;if(t.shape==="circle"){const[n,s]=Io(i,[t.x,t.y]),r=(t.outer_diameter/2+o)*Math.abs(i.a);A.beginPath(),A.arc(n,s,r,0,Math.PI*2),A.closePath()}else if(t.shape==="oval"){const[n,s]=Io(i,[t.x,t.y]),r=(t.outer_width/2+o)*Math.abs(i.a),a=(t.outer_height/2+o)*Math.abs(i.a);A.save(),A.translate(n,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[n,s]=Io(i,[t.x,t.y]),r=(t.outer_width+o*2)*Math.abs(i.a),a=(t.outer_height+o*2)*Math.abs(i.a);A.save(),A.translate(n,s),t.ccw_rotation&&t.ccw_rotation!==0&&A.rotate(-(t.ccw_rotation*Math.PI)/180),A.beginPath(),lb({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[n,s]=Io(i,[t.x,t.y]),r=(t.rect_pad_width+o*2)*Math.abs(i.a),a=(t.rect_pad_height+o*2)*Math.abs(i.a),g=(t.rect_border_radius??0)*Math.abs(i.a);A.beginPath(),U_({ctx:A,cx:n,cy:s,width:r,height:a,radius:g})}else if(t.shape==="rotated_pill_hole_with_rect_pad"){const[n,s]=Io(i,[t.x,t.y]),r=(t.rect_pad_width+o*2)*Math.abs(i.a),a=(t.rect_pad_height+o*2)*Math.abs(i.a),g=(t.rect_border_radius??0)*Math.abs(i.a);A.save(),A.translate(n,s),t.rect_ccw_rotation&&A.rotate(-t.rect_ccw_rotation*Math.PI/180),A.beginPath(),U_({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 n=t.pad_outline.map(a=>({x:t.x+a.x,y:t.y+a.y})),r=(o!==0?YY(n,o):n).map(a=>{const[g,I]=Io(i,[a.x,a.y]);return{x:g,y:I}});A.beginPath(),L_({ctx:A,points:r})}}function _qe(e){const{ctx:A,hole:t,realToCanvasMat:i,soldermaskOverCopperColor:o,margin:n}=e,s=Math.abs(n);if(A.fillStyle=o,t.shape==="circle"){const[r,a]=Io(i,[t.x,t.y]),g=t.outer_diameter/2*Math.abs(i.a),I=s*Math.abs(i.a),c=Math.max(0,g-I);A.save(),A.beginPath(),A.arc(r,a,g,0,Math.PI*2),c>0&&A.arc(r,a,c,0,Math.PI*2,!0),A.fill("evenodd"),A.restore()}else if(t.shape==="oval"){const[r,a]=Io(i,[t.x,t.y]),g=t.outer_width/2*Math.abs(i.a),I=t.outer_height/2*Math.abs(i.a),c=s*Math.abs(i.a),B=Math.max(0,g-c),l=Math.max(0,I-c);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,I,0,0,Math.PI*2),B>0&&l>0&&(A.moveTo(B,0),A.ellipse(0,0,B,l,0,0,Math.PI*2)),A.fill("evenodd"),A.restore()}else if(t.shape==="pill"){const[r,a]=Io(i,[t.x,t.y]),g=t.outer_width*Math.abs(i.a),I=t.outer_height*Math.abs(i.a),c=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(),lb({ctx:A,cx:0,cy:0,width:g,height:I});const B=g-c*2,l=I-c*2;B>0&&l>0&&lb({ctx:A,cx:0,cy:0,width:B,height:l}),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]=Io(i,[t.x,t.y]),g=t.rect_pad_width*Math.abs(i.a),I=t.rect_pad_height*Math.abs(i.a),c=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 B=t.rect_border_radius?t.rect_border_radius*Math.abs(i.a):0;A.beginPath(),U_({ctx:A,cx:0,cy:0,width:g,height:I,radius:B});const l=g-c*2,C=I-c*2;if(l>0&&C>0){const E=Math.max(0,B-c);U_({ctx:A,cx:0,cy:0,width:l,height:C,radius:E})}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(I=>({x:t.x+I.x,y:t.y+I.y}));A.save(),A.beginPath();const a=r.map(I=>{const[c,B]=Io(i,[I.x,I.y]);return{x:c,y:B}});L_({ctx:A,points:a});const g=YY(r,-s);if(g.length>=3){const I=g.map(c=>{const[B,l]=Io(i,[c.x,c.y]);return{x:B,y:l}});L_({ctx:A,points:I})}A.fill("evenodd"),A.restore()}}function kqe(e){const{ctx:A,pad:t,realToCanvasMat:i,colorMap:o,soldermaskOverCopperColor:n,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 I=g,c=g,B=g,l=g;(t.shape==="rect"||t.shape==="rotated_rect")&&(I=t.soldermask_margin_left??g,c=t.soldermask_margin_right??g,B=t.soldermask_margin_top??g,l=t.soldermask_margin_bottom??g);const C=o.copper[t.layer]||o.copper.top;a?(A.fillStyle=n,KY({ctx:A,pad:t,realToCanvasMat:i,ml:0,mr:0,mt:0,mb:0}),A.fill()):I<0||c<0||B<0||l<0?(A.fillStyle=C,KY({ctx:A,pad:t,realToCanvasMat:i,ml:0,mr:0,mt:0,mb:0}),A.fill(),Gqe({ctx:A,pad:t,realToCanvasMat:i,soldermaskOverCopperColor:n,ml:I,mr:c,mt:B,mb:l})):I>0||c>0||B>0||l>0?(A.fillStyle=o.substrate,KY({ctx:A,pad:t,realToCanvasMat:i,ml:I,mr:c,mt:B,mb:l}),A.fill(),A.fillStyle=C,KY({ctx:A,pad:t,realToCanvasMat:i,ml:0,mr:0,mt:0,mb:0}),A.fill()):(A.fillStyle=C,KY({ctx:A,pad:t,realToCanvasMat:i,ml:0,mr:0,mt:0,mb:0}),A.fill())}function KY(e){const{ctx:A,pad:t,realToCanvasMat:i,ml:o,mr:n,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,I=a*Math.PI/180,c=(n-o)/2,B=(s-r)/2,l=c*Math.cos(I)-B*Math.sin(I),C=c*Math.sin(I)+B*Math.cos(I),[E,Q]=Io(i,[t.x+l,t.y+C]),h=(t.width+o+n)*Math.abs(i.a),u=(t.height+s+r)*Math.abs(i.a),d=g*Math.abs(i.a);A.save(),A.translate(E,Q),a!==0&&A.rotate(-a*Math.PI/180),A.beginPath(),U_({ctx:A,cx:0,cy:0,width:h,height:u,radius:d}),A.restore()}else if(t.shape==="circle"){const g=(o+n+s+r)/4,[I,c]=Io(i,[t.x,t.y]),B=(t.radius+g)*Math.abs(i.a);A.beginPath(),A.arc(I,c,B,0,Math.PI*2),A.closePath()}else if(t.shape==="pill"||t.shape==="rotated_pill"){const g=(o+n)/2,[I,c]=Io(i,[t.x,t.y]),B=(t.width+g*2)*Math.abs(i.a),l=(t.height+g*2)*Math.abs(i.a);A.save(),A.translate(I,c),a!==0&&A.rotate(-a*Math.PI/180),A.beginPath(),lb({ctx:A,cx:0,cy:0,width:B,height:l}),A.restore()}else if(t.shape==="polygon"&&t.points&&t.points.length>=3){const g=(o+n+s+r)/4,c=(g!==0?YY(t.points,g):t.points).map(B=>{const[l,C]=Io(i,[B.x,B.y]);return{x:l,y:C}});A.beginPath(),L_({ctx:A,points:c})}}function Gqe(e){const{ctx:A,pad:t,realToCanvasMat:i,soldermaskOverCopperColor:o,ml:n,mr:s,mt:r,mb:a}=e,g=t.shape==="rotated_rect"||t.shape==="rotated_pill"?t.ccw_rotation??0:0,I=Math.max(0,-n),c=Math.max(0,-s),B=Math.max(0,-r),l=Math.max(0,-a);if(A.fillStyle=o,t.shape==="rect"||t.shape==="rotated_rect"){const C=t.corner_radius??t.rect_border_radius??0,[E,Q]=Io(i,[t.x,t.y]),h=t.width*Math.abs(i.a),u=t.height*Math.abs(i.a),d=C*Math.abs(i.a),f=I*Math.abs(i.a),m=c*Math.abs(i.a),w=B*Math.abs(i.a),D=l*Math.abs(i.a);A.save(),A.translate(E,Q),g!==0&&A.rotate(-g*Math.PI/180),A.beginPath(),U_({ctx:A,cx:0,cy:0,width:h,height:u,radius:d});const b=h-f-m,k=u-w-D,x=(f-m)/2,N=(w-D)/2,M=Math.max(0,d-(f+m+w+D)/4);b>0&&k>0&&U_({ctx:A,cx:x,cy:N,width:b,height:k,radius:M}),A.fill("evenodd"),A.restore()}else if(t.shape==="circle"){const C=Math.max(I,c,B,l),[E,Q]=Io(i,[t.x,t.y]),h=t.radius*Math.abs(i.a),u=C*Math.abs(i.a),d=Math.max(0,h-u);A.save(),A.beginPath(),A.arc(E,Q,h,0,Math.PI*2),d>0&&A.arc(E,Q,d,0,Math.PI*2,!0),A.fill("evenodd"),A.restore()}else if(t.shape==="pill"||t.shape==="rotated_pill"){const C=Math.max(I,c,B,l),[E,Q]=Io(i,[t.x,t.y]),h=t.width*Math.abs(i.a),u=t.height*Math.abs(i.a),d=C*Math.abs(i.a);A.save(),A.translate(E,Q),g!==0&&A.rotate(-g*Math.PI/180),A.beginPath(),lb({ctx:A,cx:0,cy:0,width:h,height:u});const f=h-d*2,m=u-d*2;f>0&&m>0&&lb({ctx:A,cx:0,cy:0,width:f,height:m}),A.fill("evenodd"),A.restore()}else if(t.shape==="polygon"&&t.points&&t.points.length>=3){const C=Math.max(I,c,B,l);A.save(),A.beginPath();const E=t.points.map(h=>{const[u,d]=Io(i,[h.x,h.y]);return{x:u,y:d}});L_({ctx:A,points:E});const Q=YY(t.points,-C);if(Q.length>=3){const h=Q.map(u=>{const[d,f]=Io(i,[u.x,u.y]);return{x:d,y:f}});L_({ctx:A,points:h})}A.fill("evenodd"),A.restore()}}function Fqe(e){const{ctx:A,via:t,realToCanvasMat:i,colorMap:o}=e,[n,s]=Io(i,[t.x,t.y]),r=t.outer_diameter/2*Math.abs(i.a);A.fillStyle=o.substrate,A.beginPath(),A.arc(n,s,r,0,Math.PI*2),A.closePath(),A.fill()}function Rqe(e){const{ctx:A,board:t,elements:i,realToCanvasMat:o,colorMap:n,layer:s,drawSoldermask:r}=e,a=n.soldermask[s]??n.soldermask.top,g=n.soldermaskOverCopper[s]??n.soldermaskOverCopper.top;r&&wqe({ctx:A,board:t,realToCanvasMat:o,soldermaskColor:a});for(const I of i)Mqe({ctx:A,element:I,realToCanvasMat:o,colorMap:n,soldermaskOverCopperColor:g,layer:s,drawSoldermask:r})}function Mqe(e){const{ctx:A,element:t,realToCanvasMat:i,colorMap:o,soldermaskOverCopperColor:n,layer:s,drawSoldermask:r}=e;t.type==="pcb_smtpad"?kqe({ctx:A,pad:t,realToCanvasMat:i,colorMap:o,soldermaskOverCopperColor:n,layer:s,drawSoldermask:r}):t.type==="pcb_plated_hole"?xqe({ctx:A,hole:t,realToCanvasMat:i,colorMap:o,soldermaskOverCopperColor:n,layer:s,drawSoldermask:r}):t.type==="pcb_hole"?Sqe({ctx:A,hole:t,realToCanvasMat:i,colorMap:o,soldermaskOverCopperColor:n,drawSoldermask:r}):t.type==="pcb_via"?Fqe({ctx:A,via:t,realToCanvasMat:i,colorMap:o}):t.type==="pcb_cutout"&&Dqe({ctx:A,cutout:t,realToCanvasMat:i,colorMap:o})}function Mv(e,A){const t=Math.hypot(e,A);return t<=Number.EPSILON?{x:0,y:0}:{x:e/t,y:A/t}}function Nqe(e,A){const t=e.length;if(t<2)return{x:1,y:0};if(A<=0){const g=e[1],I=e[0];if(!g||!I)return{x:1,y:0};const c=Mv(g.x-I.x,g.y-I.y);return c.x===0&&c.y===0?{x:1,y:0}:c}if(A>=t-1){const g=e[t-2],I=e[t-1];if(!g||!I)return{x:1,y:0};const c=Mv(I.x-g.x,I.y-g.y);return c.x===0&&c.y===0?{x:1,y:0}:c}const i=e[A-1],o=e[A],n=e[A+1];if(!i||!o||!n)return{x:1,y:0};const s=Mv(o.x-i.x,o.y-i.y),r=Mv(n.x-o.x,n.y-o.y),a=Mv(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 vqe(e){const A=[],t=[];for(let i=0;i<e.length;i++){const o=e[i];if(!o)continue;const n=Nqe(e,i),s=Mv(-n.y,n.x),r=o.width/2;A.push({x:o.x+s.x*r,y:o.y+s.y*r}),t.push({x:o.x-s.x*r,y:o.y-s.y*r})}return A.concat(t.reverse())}function Lqe(e){const A=[];let t=[],i=null;for(const o of e??[]){if(!o||o.route_type!=="wire"){t.length>=2&&A.push(t),t=[],i=null;continue}const n=o.layer??i;if(!n)continue;const s=o.x,r=o.y;if(typeof s!="number"||typeof r!="number"||typeof o.width!="number")continue;const a=o.width;i&&n!==i&&(t.length>=2&&A.push(t),t=[]),i=n,t.push({route_type:"wire",x:s,y:r,width:a,layer:n,start_pcb_port_id:"start_pcb_port_id"in o?o.start_pcb_port_id:void 0,end_pcb_port_id:"end_pcb_port_id"in o?o.end_pcb_port_id:void 0})}return t.length>=2&&A.push(t),A}function Uqe(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 Hqe(e,A){return A.copper[e]??A.copper.top}function Yqe(e){const{ctx:A,trace:t,realToCanvasMat:i,colorMap:o}=e;if(!t.route||!Array.isArray(t.route)||t.route.length<2)return;const n=Lqe(t.route);for(const s of n){const r=s[0]?.layer;if(!r)continue;const a=Hqe(r,o);if(Uqe(s)){const g=vqe(s);LY({ctx:A,points:g,fill:a,realToCanvasMat:i});continue}for(let g=0;g<s.length-1;g++){const I=s[g],c=s[g+1];!I||!c||UY({ctx:A,start:{x:I.x,y:I.y},end:{x:c.x,y:c.y},strokeWidth:I.width,stroke:a,realToCanvasMat:i,lineCap:"round"})}}}function Jqe(e){const{ctx:A,via:t,realToCanvasMat:i,colorMap:o}=e;pD({ctx:A,center:{x:t.x,y:t.y},radius:t.outer_diameter/2,fill:o.copper.top,realToCanvasMat:i}),pD({ctx:A,center:{x:t.x,y:t.y},radius:t.hole_diameter/2,fill:o.drill,realToCanvasMat:i})}function BF(e,A){if(!A.layers||A.layers.length===0)return!0;const t=nNA(e);return t.length===0?!0:t.some(i=>A.layers.includes(i))}var Cf={copper:{top:"rgb(200, 52, 52)",inner1:"rgb(255, 140, 0)",inner2:"rgb(255, 215, 0)",inner3:"rgb(50, 205, 50)",inner4:"rgb(64, 224, 208)",inner5:"rgb(138, 43, 226)",inner6:"rgb(255, 105, 180)",bottom:"rgb(77, 127, 196)"},soldermaskWithCopperUnderneath:{top:"rgb(18, 82, 50)",bottom:"rgb(77, 127, 196)"},soldermask:{top:"rgb(12, 55, 33)",bottom:"rgb(12, 55, 33)"},soldermaskOverCopper:{top:"rgb(52, 135, 73)",bottom:"rgb(52, 135, 73)"},substrate:"rgb(201, 162, 110)",drill:"#FF26E2",silkscreen:{top:"#f2eda1",bottom:"#5da9e9"},boardOutline:"rgba(255, 255, 255, 0.5)",courtyard:"#FF00FF",keepout:"#FF6B6B"},FQ=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={...Cf},this.realToCanvasMat=fPe()}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,o=e.maxX-e.minX,n=e.maxY-e.minY,s=t/o,r=i/n,a=Math.min(s,r),g=(t-o*a)/2,I=(i-n*a)/2;this.realToCanvasMat=yPe(_V(g,I),mPe(a,-a),_V(-e.minX,-e.maxY))}drawElements(e,A={}){const t=e.find(n=>n.type==="pcb_board"),i=e.find(n=>n.type==="pcb_panel");i&&nqe({ctx:this.ctx,panel:i,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap,drawBoardMaterial:A.drawBoardMaterial??!1}),t&&wPe({ctx:this.ctx,board:t,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap,drawBoardMaterial:A.drawBoardMaterial??!1});for(const n of e)BF(n,A)&&(n.type==="pcb_smtpad"&&mqe({ctx:this.ctx,pad:n,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}),n.type==="pcb_copper_text"&&LPe({ctx:this.ctx,text:n,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}));const o=A.drawSoldermask??!1;t&&Rqe({ctx:this.ctx,board:t,elements:e,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap,layer:"top",drawSoldermask:o});for(const n of e)BF(n,A)&&(n.type==="pcb_silkscreen_text"&&fqe({ctx:this.ctx,text:n,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}),n.type==="pcb_silkscreen_rect"&&uqe({ctx:this.ctx,rect:n,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}),n.type==="pcb_silkscreen_circle"&&aqe({ctx:this.ctx,circle:n,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}),n.type==="pcb_silkscreen_line"&&Iqe({ctx:this.ctx,line:n,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}),n.type==="pcb_silkscreen_path"&&Cqe({ctx:this.ctx,path:n,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}),n.type==="pcb_silkscreen_pill"&&Eqe({ctx:this.ctx,pill:n,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}),n.type==="pcb_silkscreen_oval"&&Bqe({ctx:this.ctx,oval:n,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}));for(const n of e)BF(n,A)&&(n.type==="pcb_copper_pour"&&bPe({ctx:this.ctx,pour:n,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}),n.type==="pcb_trace"&&Yqe({ctx:this.ctx,trace:n,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}));for(const n of e)BF(n,A)&&n.type==="pcb_hole"&&VPe({ctx:this.ctx,hole:n,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap,soldermaskMargin:o?n.soldermask_margin:void 0,drawSoldermask:o});for(const n of e)BF(n,A)&&(n.type==="pcb_plated_hole"&&sqe({ctx:this.ctx,hole:n,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap,soldermaskMargin:o?n.soldermask_margin:void 0,drawSoldermask:o}),n.type==="pcb_via"&&Jqe({ctx:this.ctx,via:n,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}));for(const n of e)BF(n,A)&&n.type==="pcb_cutout"&&UPe({ctx:this.ctx,cutout:n,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap});for(const n of e)BF(n,A)&&(n.type==="pcb_keepout"&&zPe({ctx:this.ctx,keepout:n,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}),n.type==="pcb_fabrication_note_text"&&ZPe({ctx:this.ctx,text:n,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}),n.type==="pcb_fabrication_note_rect"&&qPe({ctx:this.ctx,rect:n,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}),n.type==="pcb_note_rect"&&eqe({realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap,ctx:this.ctx,rect:n}),n.type==="pcb_fabrication_note_path"&&PPe({ctx:this.ctx,path:n,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}),n.type==="pcb_note_path"&&tqe({ctx:this.ctx,path:n,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}),n.type==="pcb_note_text"&&oqe({ctx:this.ctx,text:n,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}),n.type==="pcb_note_line"&&Aqe({ctx:this.ctx,line:n,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}),n.type==="pcb_note_dimension"&&$Pe({ctx:this.ctx,pcbNoteDimension:n,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}),n.type==="pcb_fabrication_note_dimension"&&KPe({ctx:this.ctx,pcbFabricationNoteDimension:n,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}))}};const Tqe=P0t(sMt);var IpA,Iat;function Kqe(){if(Iat)return IpA;Iat=1;var e=Object.defineProperty,A=Object.getOwnPropertyDescriptor,t=Object.getOwnPropertyNames,i=Object.prototype.hasOwnProperty,o=(Q,h)=>{for(var u in h)e(Q,u,{get:h[u],enumerable:!0})},n=(Q,h,u,d)=>{if(h&&typeof h=="object"||typeof h=="function")for(let f of t(h))!i.call(Q,f)&&f!==u&&e(Q,f,{get:()=>h[f],enumerable:!(d=A(h,f))||d.enumerable});return Q},s=Q=>n(e({},"__esModule",{value:!0}),Q),r={};o(r,{SuperGrid:()=>E,toMMSI:()=>C,toMeterSI:()=>l}),IpA=s(r);var a=e0(),g=Tqe,I=nSA(),c=(Q,h,u)=>{const d=[];if(h<Q)for(let f=Q;f>=h;f-=Math.abs(u))d.push(f);else for(let f=Q;f<=h;f+=Math.abs(u))d.push(f);return d};function B(Q,h){return{x:Math.round(h.x/Q)*Q,y:Math.round(h.y/Q)*Q}}function l(Q,h=1){return Q<0?"-"+l(-Q):Q<1e-6?"0m":Q>1e3?Math.floor(Q/1e3)+"km":Q>1&&h>1?Math.round(Q)+"m":Q>1&&h<=1?Q.toFixed(Math.ceil(-Math.log10(h)))+"m":Q<1&&h>=1/1e3?Math.round(Q*1e3)+"mm":Q<1&&h<1/1e3?(Q*1e3).toFixed(Math.ceil(-Math.log10(h*1e3)))+"mm":""}function C(Q,h=1){return l(Q/1e3,h/1e3)}var E=Q=>{var h;const u=(0,a.useRef)(null),[d,f]=(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=(h=Q.majorColor)!=null?h:"rgba(0,0,0,0.5)",width:b,height:k,screenSpaceCellSize:x=200,stringifyCoord:N=(H,O,W)=>`${l(H,W)}, ${l(O,W)}`}=Q,M=Math.ceil(b/x)+2,U=Math.ceil(k/x)+2;(0,a.useEffect)(()=>{if(!u.current)return;const H=u.current.getContext("2d");if(!H)return;const O=x/10**Math.floor(Math.log10(Q.transform.a)),W=Q.transform.d<0?-1:1,iA=x/10**Math.log10(Q.transform.a)/O;function gA(GA,dA,PA){const JA=GA;let it,yA,tt;for(it=dA.x;it<=PA.x;it+=JA)yA=(0,g.applyToPoint)(Q.transform,{x:it,y:dA.y}),tt=(0,g.applyToPoint)(Q.transform,{x:it,y:PA.y}),H.beginPath(),H.moveTo(yA.x,yA.y),H.lineTo(tt.x,tt.y),H.stroke();const qA=c(dA.y,PA.y,JA*W);for(const UA of qA)yA=(0,g.applyToPoint)(Q.transform,{x:dA.x,y:UA}),tt=(0,g.applyToPoint)(Q.transform,{x:PA.x,y:UA}),H.beginPath(),H.moveTo(yA.x,yA.y),H.lineTo(tt.x,tt.y),H.stroke()}function tA(GA,dA,PA){const JA=GA;let it;for(it=dA.x;it<=PA.x;it+=JA)for(const yA of c(dA.y,PA.y,JA*W)){const tt=(0,g.applyToPoint)(Q.transform,{x:it,y:yA});H.fillStyle=D,H.font="12px sans-serif",H.fillText(N(it,yA,GA),tt.x+2,tt.y-2)}}H.clearRect(0,0,b,k);const nA=(0,g.applyToPoint)((0,g.inverse)(Q.transform),{x:0,y:0}),rA={x:Math.floor((nA.x-O)/O)*O,y:Math.floor((nA.y-O)/O+(W==-1?2:0))*O},QA={x:rA.x+O*M,y:rA.y+O*U*W},FA=O*5,MA={x:Math.floor((nA.x-FA)/FA)*FA,y:Math.floor((nA.y-FA)/FA+(W==-1?2:0))*FA},TA={x:MA.x+FA*M,y:MA.y+FA*U*W};H.globalAlpha=1,H.strokeStyle=m,gA(O,rA,QA),tA(FA,MA,TA),H.globalAlpha=1-iA,gA(FA/10,MA,TA),H.globalAlpha=1-iA,H.strokeStyle=w,gA(O/10,rA,QA),H.globalAlpha=Math.max(((1-iA)*10-5)/5,0),tA(FA/10,MA,TA),H.globalAlpha=1;const EA=(0,g.applyToPoint)(Q.transform,d);H.font="12px sans-serif",H.fillStyle=D,H.fillText(N(d.x,d.y,O),EA.x+2,EA.y-2),H.strokeStyle=m,H.strokeRect(EA.x-5,EA.y-5,10,10)},[u,Q.transform,d,b,k]);const J=H=>{if(!u.current)return;const O=x/10/10**Math.floor(Math.log10(Q.transform.a)),W=u.current.getBoundingClientRect(),$=(0,g.applyToPoint)((0,g.inverse)(Q.transform),{x:H.clientX-W.left,y:H.clientY-W.top}),iA=B(O,$);f(iA)};return(0,I.jsx)("canvas",{onMouseUp:H=>{H.button===1&&J(H)},onDoubleClick:J,ref:u,width:Q.width,height:Q.height})};return IpA}var RV=Kqe();function Pqe(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 qqe(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 Oqe=(function(){function e(t){var i=this;this._insertTag=function(o){var n;i.tags.length===0?i.insertionPoint?n=i.insertionPoint.nextSibling:i.prepend?n=i.container.firstChild:n=i.before:n=i.tags[i.tags.length-1].nextSibling,i.container.insertBefore(o,n),i.tags.push(o)},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(qqe(this));var o=this.tags[this.tags.length-1];if(this.isSpeedy){var n=Pqe(o);try{n.insertRule(i,n.cssRules.length)}catch{}}else o.appendChild(document.createTextNode(i));this.ctr++},A.flush=function(){this.tags.forEach(function(i){var o;return(o=i.parentNode)==null?void 0:o.removeChild(i)}),this.tags=[],this.ctr=0},e})(),Ku="-ms-",MV="-moz-",qa="-webkit-",cat="comm",cpA="rule",BpA="decl",Wqe="@import",Bat="@keyframes",Zqe="@layer",Vqe=Math.abs,NV=String.fromCharCode,jqe=Object.assign;function zqe(e,A){return kh(e,0)^45?(((A<<2^kh(e,0))<<2^kh(e,1))<<2^kh(e,2))<<2^kh(e,3):0}function lat(e){return e.trim()}function Xqe(e,A){return(e=A.exec(e))?e[0]:e}function Oa(e,A,t){return e.replace(A,t)}function lpA(e,A){return e.indexOf(A)}function kh(e,A){return e.charCodeAt(A)|0}function PY(e,A,t){return e.slice(A,t)}function yD(e){return e.length}function CpA(e){return e.length}function vV(e,A){return A.push(e),e}function $qe(e,A){return e.map(A).join("")}var LV=1,Nv=1,Cat=0,Qf=0,vC=0,vv="";function UV(e,A,t,i,o,n,s){return{value:e,root:A,parent:t,type:i,props:o,children:n,line:LV,column:Nv,length:s,return:""}}function qY(e,A){return jqe(UV("",null,null,"",null,null,0),e,{length:-e.length},A)}function A4e(){return vC}function t4e(){return vC=Qf>0?kh(vv,--Qf):0,Nv--,vC===10&&(Nv=1,LV--),vC}function D0(){return vC=Qf<Cat?kh(vv,Qf++):0,Nv++,vC===10&&(Nv=1,LV++),vC}function mD(){return kh(vv,Qf)}function HV(){return Qf}function OY(e,A){return PY(vv,e,A)}function WY(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 Qat(e){return LV=Nv=1,Cat=yD(vv=e),Qf=0,[]}function Eat(e){return vv="",e}function YV(e){return lat(OY(Qf-1,QpA(e===91?e+2:e===40?e+1:e)))}function e4e(e){for(;(vC=mD())&&vC<33;)D0();return WY(e)>2||WY(vC)>3?"":" "}function i4e(e,A){for(;--A&&D0()&&!(vC<48||vC>102||vC>57&&vC<65||vC>70&&vC<97););return OY(e,HV()+(A<6&&mD()==32&&D0()==32))}function QpA(e){for(;D0();)switch(vC){case e:return Qf;case 34:case 39:e!==34&&e!==39&&QpA(vC);break;case 40:e===41&&QpA(e);break;case 92:D0();break}return Qf}function o4e(e,A){for(;D0()&&e+vC!==57;)if(e+vC===84&&mD()===47)break;return"/*"+OY(A,Qf-1)+"*"+NV(e===47?e:D0())}function n4e(e){for(;!WY(mD());)D0();return OY(e,Qf)}function s4e(e){return Eat(JV("",null,null,null,[""],e=Qat(e),0,[0],e))}function JV(e,A,t,i,o,n,s,r,a){for(var g=0,I=0,c=s,B=0,l=0,C=0,E=1,Q=1,h=1,u=0,d="",f=o,m=n,w=i,D=d;Q;)switch(C=u,u=D0()){case 40:if(C!=108&&kh(D,c-1)==58){lpA(D+=Oa(YV(u),"&","&\f"),"&\f")!=-1&&(h=-1);break}case 34:case 39:case 91:D+=YV(u);break;case 9:case 10:case 13:case 32:D+=e4e(C);break;case 92:D+=i4e(HV()-1,7);continue;case 47:switch(mD()){case 42:case 47:vV(r4e(o4e(D0(),HV()),A,t),a);break;default:D+="/"}break;case 123*E:r[g++]=yD(D)*h;case 125*E:case 59:case 0:switch(u){case 0:case 125:Q=0;case 59+I:h==-1&&(D=Oa(D,/\f/g,"")),l>0&&yD(D)-c&&vV(l>32?uat(D+";",i,t,c-1):uat(Oa(D," ","")+";",i,t,c-2),a);break;case 59:D+=";";default:if(vV(w=hat(D,A,t,g,I,o,r,d,f=[],m=[],c),n),u===123)if(I===0)JV(D,A,w,w,f,n,c,r,m);else switch(B===99&&kh(D,3)===110?100:B){case 100:case 108:case 109:case 115:JV(e,w,w,i&&vV(hat(e,w,w,0,0,o,r,d,o,f=[],c),m),o,m,c,r,i?f:m);break;default:JV(D,w,w,w,[""],m,0,r,m)}}g=I=l=0,E=h=1,d=D="",c=s;break;case 58:c=1+yD(D),l=C;default:if(E<1){if(u==123)--E;else if(u==125&&E++==0&&t4e()==125)continue}switch(D+=NV(u),u*E){case 38:h=I>0?1:(D+="\f",-1);break;case 44:r[g++]=(yD(D)-1)*h,h=1;break;case 64:mD()===45&&(D+=YV(D0())),B=mD(),I=c=yD(d=D+=n4e(HV())),u++;break;case 45:C===45&&yD(D)==2&&(E=0)}}return n}function hat(e,A,t,i,o,n,s,r,a,g,I){for(var c=o-1,B=o===0?n:[""],l=CpA(B),C=0,E=0,Q=0;C<i;++C)for(var h=0,u=PY(e,c+1,c=Vqe(E=s[C])),d=e;h<l;++h)(d=lat(E>0?B[h]+" "+u:Oa(u,/&\f/g,B[h])))&&(a[Q++]=d);return UV(e,A,t,o===0?cpA:r,a,g,I)}function r4e(e,A,t){return UV(e,A,t,cat,NV(A4e()),PY(e,2,-2),0)}function uat(e,A,t,i){return UV(e,A,t,BpA,PY(e,0,i),PY(e,i+1,-1),i)}function Lv(e,A){for(var t="",i=CpA(e),o=0;o<i;o++)t+=A(e[o],o,e,A)||"";return t}function a4e(e,A,t,i){switch(e.type){case Zqe:if(e.children.length)break;case Wqe:case BpA:return e.return=e.return||e.value;case cat:return"";case Bat:return e.return=e.value+"{"+Lv(e.children,i)+"}";case cpA:e.value=e.props.join(",")}return yD(t=Lv(e.children,i))?e.return=e.value+"{"+t+"}":""}function g4e(e){var A=CpA(e);return function(t,i,o,n){for(var s="",r=0;r<A;r++)s+=e[r](t,i,o,n)||"";return s}}function I4e(e){return function(A){A.root||(A=A.return)&&e(A)}}function c4e(e){var A=Object.create(null);return function(t){return A[t]===void 0&&(A[t]=e(t)),A[t]}}var B4e=function(A,t,i){for(var o=0,n=0;o=n,n=mD(),o===38&&n===12&&(t[i]=1),!WY(n);)D0();return OY(A,Qf)},l4e=function(A,t){var i=-1,o=44;do switch(WY(o)){case 0:o===38&&mD()===12&&(t[i]=1),A[i]+=B4e(Qf-1,t,i);break;case 2:A[i]+=YV(o);break;case 4:if(o===44){A[++i]=mD()===58?"&\f":"",t[i]=A[i].length;break}default:A[i]+=NV(o)}while(o=D0());return A},C4e=function(A,t){return Eat(l4e(Qat(A),t))},dat=new WeakMap,Q4e=function(A){if(!(A.type!=="rule"||!A.parent||A.length<1)){for(var t=A.value,i=A.parent,o=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&&!dat.get(i))&&!o){dat.set(A,!0);for(var n=[],s=C4e(t,n),r=i.props,a=0,g=0;a<s.length;a++)for(var I=0;I<r.length;I++,g++)A.props[g]=n[a]?s[a].replace(/&\f/g,r[I]):r[I]+" "+s[a]}}},E4e=function(A){if(A.type==="decl"){var t=A.value;t.charCodeAt(0)===108&&t.charCodeAt(2)===98&&(A.return="",A.value="")}};function pat(e,A){switch(zqe(e,A)){case 5103:return qa+"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 qa+e+e;case 5349:case 4246:case 4810:case 6968:case 2756:return qa+e+MV+e+Ku+e+e;case 6828:case 4268:return qa+e+Ku+e+e;case 6165:return qa+e+Ku+"flex-"+e+e;case 5187:return qa+e+Oa(e,/(\w+).+(:[^]+)/,qa+"box-$1$2"+Ku+"flex-$1$2")+e;case 5443:return qa+e+Ku+"flex-item-"+Oa(e,/flex-|-self/,"")+e;case 4675:return qa+e+Ku+"flex-line-pack"+Oa(e,/align-content|flex-|-self/,"")+e;case 5548:return qa+e+Ku+Oa(e,"shrink","negative")+e;case 5292:return qa+e+Ku+Oa(e,"basis","preferred-size")+e;case 6060:return qa+"box-"+Oa(e,"-grow","")+qa+e+Ku+Oa(e,"grow","positive")+e;case 4554:return qa+Oa(e,/([^-])(transform)/g,"$1"+qa+"$2")+e;case 6187:return Oa(Oa(Oa(e,/(zoom-|grab)/,qa+"$1"),/(image-set)/,qa+"$1"),e,"")+e;case 5495:case 3959:return Oa(e,/(image-set\([^]*)/,qa+"$1$`$1");case 4968:return Oa(Oa(e,/(.+:)(flex-)?(.*)/,qa+"box-pack:$3"+Ku+"flex-pack:$3"),/s.+-b[^;]+/,"justify")+qa+e+e;case 4095:case 3583:case 4068:case 2532:return Oa(e,/(.+)-inline(.+)/,qa+"$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(yD(e)-1-A>6)switch(kh(e,A+1)){case 109:if(kh(e,A+4)!==45)break;case 102:return Oa(e,/(.+:)(.+)-([^]+)/,"$1"+qa+"$2-$3$1"+MV+(kh(e,A+3)==108?"$3":"$2-$3"))+e;case 115:return~lpA(e,"stretch")?pat(Oa(e,"stretch","fill-available"),A)+e:e}break;case 4949:if(kh(e,A+1)!==115)break;case 6444:switch(kh(e,yD(e)-3-(~lpA(e,"!important")&&10))){case 107:return Oa(e,":",":"+qa)+e;case 101:return Oa(e,/(.+:)([^;!]+)(;|!.+)?/,"$1"+qa+(kh(e,14)===45?"inline-":"")+"box$3$1"+qa+"$2$3$1"+Ku+"$2box$3")+e}break;case 5936:switch(kh(e,A+11)){case 114:return qa+e+Ku+Oa(e,/[svh]\w+-[tblr]{2}/,"tb")+e;case 108:return qa+e+Ku+Oa(e,/[svh]\w+-[tblr]{2}/,"tb-rl")+e;case 45:return qa+e+Ku+Oa(e,/[svh]\w+-[tblr]{2}/,"lr")+e}return qa+e+Ku+e+e}return e}var h4e=function(A,t,i,o){if(A.length>-1&&!A.return)switch(A.type){case BpA:A.return=pat(A.value,A.length);break;case Bat:return Lv([qY(A,{value:Oa(A.value,"@","@"+qa)})],o);case cpA:if(A.length)return $qe(A.props,function(n){switch(Xqe(n,/(::plac\w+|:read-\w+)/)){case":read-only":case":read-write":return Lv([qY(A,{props:[Oa(n,/:(read-\w+)/,":"+MV+"$1")]})],o);case"::placeholder":return Lv([qY(A,{props:[Oa(n,/:(plac\w+)/,":"+qa+"input-$1")]}),qY(A,{props:[Oa(n,/:(plac\w+)/,":"+MV+"$1")]}),qY(A,{props:[Oa(n,/:(plac\w+)/,Ku+"input-$1")]})],o)}return""})}},u4e=[h4e],d4e=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(E){var Q=E.getAttribute("data-emotion");Q.indexOf(" ")!==-1&&(document.head.appendChild(E),E.setAttribute("data-s",""))})}var o=A.stylisPlugins||u4e,n={},s,r=[];s=A.container||document.head,Array.prototype.forEach.call(document.querySelectorAll('style[data-emotion^="'+t+' "]'),function(E){for(var Q=E.getAttribute("data-emotion").split(" "),h=1;h<Q.length;h++)n[Q[h]]=!0;r.push(E)});var a,g=[Q4e,E4e];{var I,c=[a4e,I4e(function(E){I.insert(E)})],B=g4e(g.concat(o,c)),l=function(Q){return Lv(s4e(Q),B)};a=function(Q,h,u,d){I=u,l(Q?Q+"{"+h.styles+"}":h.styles),d&&(C.inserted[h.name]=!0)}}var C={key:t,sheet:new Oqe({key:t,container:s,nonce:A.nonce,speedy:A.speedy,prepend:A.prepend,insertionPoint:A.insertionPoint}),nonce:A.nonce,inserted:n,registered:{},insert:a};return C.sheet.hydrate(r),C};function p4e(e){for(var A=0,t,i=0,o=e.length;o>=4;++i,o-=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(o){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 f4e={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},y4e=/[A-Z]|^ms/g,m4e=/_EMO_([^_]+?)_([^]*?)_EMO_/g,fat=function(A){return A.charCodeAt(1)===45},yat=function(A){return A!=null&&typeof A!="boolean"},EpA=c4e(function(e){return fat(e)?e:e.replace(y4e,"-$&").toLowerCase()}),mat=function(A,t){switch(A){case"animation":case"animationName":if(typeof t=="string")return t.replace(m4e,function(i,o,n){return H_={name:o,styles:n,next:H_},o})}return f4e[A]!==1&&!fat(A)&&typeof t=="number"&&t!==0?t+"px":t};function TV(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 o=t;if(o.anim===1)return H_={name:o.name,styles:o.styles,next:H_},o.name;var n=t;if(n.styles!==void 0){var s=n.next;if(s!==void 0)for(;s!==void 0;)H_={name:s.name,styles:s.styles,next:H_},s=s.next;var r=n.styles+";";return r}return w4e(e,A,t)}}var a=t;if(A==null)return a;var g=A[a];return g!==void 0?g:a}function w4e(e,A,t){var i="";if(Array.isArray(t))for(var o=0;o<t.length;o++)i+=TV(e,A,t[o])+";";else for(var n in t){var s=t[n];if(typeof s!="object"){var r=s;A!=null&&A[r]!==void 0?i+=n+"{"+A[r]+"}":yat(r)&&(i+=EpA(n)+":"+mat(n,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++)yat(s[a])&&(i+=EpA(n)+":"+mat(n,s[a])+";");else{var g=TV(e,A,s);switch(n){case"animation":case"animationName":{i+=EpA(n)+":"+g+";";break}default:i+=n+"{"+g+"}"}}}return i}var wat=/label:\s*([^\s;{]+)\s*(;|$)/g,H_;function hpA(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,o="";H_=void 0;var n=e[0];if(n==null||n.raw===void 0)i=!1,o+=TV(t,A,n);else{var s=n;o+=s[0]}for(var r=1;r<e.length;r++)if(o+=TV(t,A,e[r]),i){var a=n;o+=a[r]}wat.lastIndex=0;for(var g="",I;(I=wat.exec(o))!==null;)g+="-"+I[1];var c=p4e(o)+g;return{name:c,styles:o,next:H_}}function Dat(e,A,t){var i="";return t.split(" ").forEach(function(o){e[o]!==void 0?A.push(e[o]+";"):o&&(i+=o+" ")}),i}var D4e=function(A,t,i){var o=A.key+"-"+t.name;A.registered[o]===void 0&&(A.registered[o]=t.styles)},S4e=function(A,t,i){D4e(A,t);var o=A.key+"-"+t.name;if(A.inserted[t.name]===void 0){var n=t;do A.insert(t===n?"."+o:"",n,A.sheet,!0),n=n.next;while(n!==void 0)}};function Sat(e,A){if(e.inserted[A.name]===void 0)return e.insert("",A,e.sheet,!0)}function bat(e,A,t){var i=[],o=Dat(e,i,t);return i.length<2?t:o+A(i)}var b4e=function(A){var t=d4e(A);t.sheet.speedy=function(r){this.isSpeedy=r},t.compat=!0;var i=function(){for(var a=arguments.length,g=new Array(a),I=0;I<a;I++)g[I]=arguments[I];var c=hpA(g,t.registered,void 0);return S4e(t,c),t.key+"-"+c.name},o=function(){for(var a=arguments.length,g=new Array(a),I=0;I<a;I++)g[I]=arguments[I];var c=hpA(g,t.registered),B="animation-"+c.name;return Sat(t,{name:c.name,styles:"@keyframes "+B+"{"+c.styles+"}"}),B},n=function(){for(var a=arguments.length,g=new Array(a),I=0;I<a;I++)g[I]=arguments[I];var c=hpA(g,t.registered);Sat(t,c)},s=function(){for(var a=arguments.length,g=new Array(a),I=0;I<a;I++)g[I]=arguments[I];return bat(t.registered,i,x4e(g))};return{css:i,cx:s,injectGlobal:n,keyframes:o,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:Dat.bind(null,t.registered),merge:bat.bind(null,t.registered,i)}},x4e=function e(A){for(var t="",i=0;i<A.length;i++){var o=A[i];if(o!=null){var n=void 0;switch(typeof o){case"boolean":break;case"object":{if(Array.isArray(o))n=e(o);else{n="";for(var s in o)o[s]&&s&&(n&&(n+=" "),n+=s)}break}default:n=o}n&&(t&&(t+=" "),t+=n)}}return t},_4e=b4e({key:"css"}),Uv=_4e.css,k4e=Object.create,xat=Object.defineProperty,G4e=Object.getOwnPropertyDescriptor,_at=Object.getOwnPropertyNames,F4e=Object.getPrototypeOf,R4e=Object.prototype.hasOwnProperty,Ga=(e,A)=>function(){return A||(0,e[_at(e)[0]])((A={exports:{}}).exports,A),A.exports},M4e=(e,A,t,i)=>{if(A&&typeof A=="object"||typeof A=="function")for(let o of _at(A))!R4e.call(e,o)&&o!==t&&xat(e,o,{get:()=>A[o],enumerable:!(i=G4e(A,o))||i.enumerable});return e},kat=(e,A,t)=>(t=e!=null?k4e(F4e(e)):{},M4e(xat(t,"default",{value:e,enumerable:!0}),e)),N4e=Ga({"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)||o(tA)||!!tA._isBuffer)};function i(tA){return!!tA.constructor&&typeof tA.constructor.isBuffer=="function"&&tA.constructor.isBuffer(tA)}function o(tA){return typeof tA.readFloatLE=="function"&&typeof tA.slice=="function"&&i(tA.slice(0,0))}var n=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=n.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,QA){if(typeof QA!="function")return rA;var SA={};for(var FA in rA)Object.prototype.hasOwnProperty.call(rA,FA)&&(SA[QA(FA,rA[FA])||FA]=rA[FA]);return SA}tA.exports?tA.exports=nA:window.rename=nA})()}),g=function tA(nA,rA){var QA=s(nA);if(QA!=="object"&&QA!=="array")throw new Error("expected an object");var SA=[];QA==="object"&&(nA=a(nA,rA),SA={});for(var FA in nA)if(nA.hasOwnProperty(FA)){var MA=nA[FA];s(MA)==="object"||s(MA)==="array"?SA[FA]=tA(MA,rA):SA[FA]=MA}return SA},I=r(function(tA){var nA=Object.prototype.hasOwnProperty,rA="~";function QA(){}Object.create&&(QA.prototype=Object.create(null),new QA().__proto__||(rA=!1));function SA(MA,TA,EA){this.fn=MA,this.context=TA,this.once=EA||!1}function FA(){this._events=new QA,this._eventsCount=0}FA.prototype.eventNames=function(){var TA=[],EA,GA;if(this._eventsCount===0)return TA;for(GA in EA=this._events)nA.call(EA,GA)&&TA.push(rA?GA.slice(1):GA);return Object.getOwnPropertySymbols?TA.concat(Object.getOwnPropertySymbols(EA)):TA},FA.prototype.listeners=function(TA,EA){var GA=rA?rA+TA:TA,dA=this._events[GA];if(EA)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},FA.prototype.emit=function(TA,EA,GA,dA,PA,JA){var it=rA?rA+TA:TA;if(!this._events[it])return!1;var yA=this._events[it],tt=arguments.length,qA,UA;if(yA.fn){switch(yA.once&&this.removeListener(TA,yA.fn,void 0,!0),tt){case 1:return yA.fn.call(yA.context),!0;case 2:return yA.fn.call(yA.context,EA),!0;case 3:return yA.fn.call(yA.context,EA,GA),!0;case 4:return yA.fn.call(yA.context,EA,GA,dA),!0;case 5:return yA.fn.call(yA.context,EA,GA,dA,PA),!0;case 6:return yA.fn.call(yA.context,EA,GA,dA,PA,JA),!0}for(UA=1,qA=new Array(tt-1);UA<tt;UA++)qA[UA-1]=arguments[UA];yA.fn.apply(yA.context,qA)}else{var ZA=yA.length,kA;for(UA=0;UA<ZA;UA++)switch(yA[UA].once&&this.removeListener(TA,yA[UA].fn,void 0,!0),tt){case 1:yA[UA].fn.call(yA[UA].context);break;case 2:yA[UA].fn.call(yA[UA].context,EA);break;case 3:yA[UA].fn.call(yA[UA].context,EA,GA);break;case 4:yA[UA].fn.call(yA[UA].context,EA,GA,dA);break;default:if(!qA)for(kA=1,qA=new Array(tt-1);kA<tt;kA++)qA[kA-1]=arguments[kA];yA[UA].fn.apply(yA[UA].context,qA)}}return!0},FA.prototype.on=function(TA,EA,GA){var dA=new SA(EA,GA||this),PA=rA?rA+TA:TA;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},FA.prototype.once=function(TA,EA,GA){var dA=new SA(EA,GA||this,!0),PA=rA?rA+TA:TA;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},FA.prototype.removeListener=function(TA,EA,GA,dA){var PA=rA?rA+TA:TA;if(!this._events[PA])return this;if(!EA)return--this._eventsCount===0?this._events=new QA:delete this._events[PA],this;var JA=this._events[PA];if(JA.fn)JA.fn===EA&&(!dA||JA.once)&&(!GA||JA.context===GA)&&(--this._eventsCount===0?this._events=new QA:delete this._events[PA]);else{for(var it=0,yA=[],tt=JA.length;it<tt;it++)(JA[it].fn!==EA||dA&&!JA[it].once||GA&&JA[it].context!==GA)&&yA.push(JA[it]);yA.length?this._events[PA]=yA.length===1?yA[0]:yA:--this._eventsCount===0?this._events=new QA:delete this._events[PA]}return this},FA.prototype.removeAllListeners=function(TA){var EA;return TA?(EA=rA?rA+TA:TA,this._events[EA]&&(--this._eventsCount===0?this._events=new QA:delete this._events[EA])):(this._events=new QA,this._eventsCount=0),this},FA.prototype.off=FA.prototype.removeListener,FA.prototype.addListener=FA.prototype.on,FA.prototype.setMaxListeners=function(){return this},FA.prefixed=rA,FA.EventEmitter=FA,tA.exports=FA});function c(tA,nA,rA){return nA in tA?Object.defineProperty(tA,nA,{value:rA,enumerable:!0,configurable:!0,writable:!0}):tA[nA]=rA,tA}var B=function(){},l={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"},E={text:"text",openTag:"open-tag",closeTag:"close-tag",attributeName:"attribute-name",attributeValue:"attribute-value"},Q={" ":C.space," ":C.space,"\n":C.space,"\r":C.space,"<":C.lt,">":C.gt,'"':C.quote,"'":C.quote,"=":C.equal,"/":C.slash},h=function(nA){return Q[nA]||C.char},u=function(nA){var rA,QA,SA,FA,MA,TA,EA,GA,dA,PA;nA=Object.assign({debug:!1},nA);var JA=new I,it=l.data,yA="",tt="",qA="",UA="",ZA="",kA="",DA=function(KA,OA){if(!(tt[0]==="?"||tt[0]==="!")){var $A={type:KA,value:OA};nA.debug&&console.log("emit:",$A),JA.emit("data",$A)}};JA.stateMachine=(PA={},c(PA,l.data,(rA={},c(rA,C.lt,function(){yA.trim()&&DA(E.text,yA),tt="",ZA=!1,it=l.tagBegin}),c(rA,C.char,function(bA){yA+=bA}),rA)),c(PA,l.cdata,c({},C.char,function(bA){yA+=bA,yA.substr(-3)==="]]>"&&(DA(E.text,yA.slice(0,-3)),yA="",it=l.data)})),c(PA,l.tagBegin,(QA={},c(QA,C.space,B),c(QA,C.char,function(bA){tt=bA,it=l.tagName}),c(QA,C.slash,function(){tt="",ZA=!0}),QA)),c(PA,l.tagName,(SA={},c(SA,C.space,function(){ZA?it=l.tagEnd:(it=l.attributeNameStart,DA(E.openTag,tt))}),c(SA,C.gt,function(){DA(ZA?E.closeTag:E.openTag,tt),yA="",it=l.data}),c(SA,C.slash,function(){it=l.tagEnd,DA(E.openTag,tt)}),c(SA,C.char,function(bA){tt+=bA,tt==="![CDATA["&&(it=l.cdata,yA="",tt="")}),SA)),c(PA,l.tagEnd,(FA={},c(FA,C.gt,function(){DA(E.closeTag,tt),yA="",it=l.data}),c(FA,C.char,B),FA)),c(PA,l.attributeNameStart,(MA={},c(MA,C.char,function(bA){qA=bA,it=l.attributeName}),c(MA,C.gt,function(){yA="",it=l.data}),c(MA,C.space,B),c(MA,C.slash,function(){ZA=!0,it=l.tagEnd}),MA)),c(PA,l.attributeName,(TA={},c(TA,C.space,function(){it=l.attributeNameEnd}),c(TA,C.equal,function(){DA(E.attributeName,qA),it=l.attributeValueBegin}),c(TA,C.gt,function(){UA="",DA(E.attributeName,qA),DA(E.attributeValue,UA),yA="",it=l.data}),c(TA,C.slash,function(){ZA=!0,UA="",DA(E.attributeName,qA),DA(E.attributeValue,UA),it=l.tagEnd}),c(TA,C.char,function(bA){qA+=bA}),TA)),c(PA,l.attributeNameEnd,(EA={},c(EA,C.space,B),c(EA,C.equal,function(){DA(E.attributeName,qA),it=l.attributeValueBegin}),c(EA,C.gt,function(){UA="",DA(E.attributeName,qA),DA(E.attributeValue,UA),yA="",it=l.data}),c(EA,C.char,function(bA){UA="",DA(E.attributeName,qA),DA(E.attributeValue,UA),qA=bA,it=l.attributeName}),EA)),c(PA,l.attributeValueBegin,(GA={},c(GA,C.space,B),c(GA,C.quote,function(bA){kA=bA,UA="",it=l.attributeValue}),c(GA,C.gt,function(){UA="",DA(E.attributeValue,UA),yA="",it=l.data}),c(GA,C.char,function(bA){kA="",UA=bA,it=l.attributeValue}),GA)),c(PA,l.attributeValue,(dA={},c(dA,C.space,function(bA){kA?UA+=bA:(DA(E.attributeValue,UA),it=l.attributeNameStart)}),c(dA,C.quote,function(bA){kA===bA?(DA(E.attributeValue,UA),it=l.attributeNameStart):UA+=bA}),c(dA,C.gt,function(bA){kA?UA+=bA:(DA(E.attributeValue,UA),yA="",it=l.data)}),c(dA,C.slash,function(bA){kA?UA+=bA:(DA(E.attributeValue,UA),ZA=!0,it=l.tagEnd)}),c(dA,C.char,function(bA){UA+=bA}),dA)),PA);var HA=function(KA){nA.debug&&console.log(it,KA);var OA=JA.stateMachine[it],$A=OA[h(KA)]||OA[C.error]||OA[C.char];$A(KA)};return JA.write=function(bA){for(var KA=bA.length,OA=0;OA<KA;OA++)HA(bA[OA])},JA},d={State:l,Action:C,Type:E,create:u},f=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,QA=void 0,SA=void 0,FA=void 0,MA=new I,TA=function(GA){switch(GA.type){case f.openTag:if(SA===null)SA=QA,SA.name=GA.value;else{var dA=w({name:GA.value,parent:SA});SA.children.push(dA),SA=dA}break;case f.closeTag:var PA=SA.parent;if(nA.parentNodes||(SA.parent=null),SA.name!==GA.value)break;nA.stream&&PA===QA&&(QA.children=[],SA.parent=null),(!nA.emitTopLevelOnly||PA===QA)&&(MA.emit(nA.tagPrefix+SA.name,SA),MA.emit("tag",SA.name,SA)),SA===QA&&(rA.removeAllListeners("data"),MA.emit(nA.doneEvent,SA),QA=null),SA=PA;break;case f.text:SA&&SA.children.push(w({type:m.text,value:GA.value,parent:nA.parentNodes?SA:null}));break;case f.attributeName:FA=GA.value,SA.attributes[FA]="";break;case f.attributeValue:SA.attributes[FA]=GA.value;break}};return MA.reset=function(){rA=d.create({debug:nA.debug}),rA.on("data",TA),QA=w(),SA=null,FA="",MA.parse=rA.write},MA.reset(),MA},b=function(nA,rA){rA=Object.assign({},rA,{stream:!1,tagPrefix:":"});var QA=D(rA),SA=void 0;return QA.on("done",function(FA){SA=FA}),QA.parse(nA),SA},k={parseSync:b},x=k.parseSync,N=function(nA){var rA=x("<root>".concat(nA,"</root>"),{parentNodes:!1}),QA=rA.children&&rA.children.length>0&&rA.children.every(function(SA){return SA.name==="svg"});if(QA)return rA.children.length===1?rA.children[0]:rA.children;throw Error("nothing to parse")},M=function(nA){return g(nA,function(rA){return J(rA)?rA:U(rA)})},U=function(nA){return nA.replace(/[-|:]([a-z])/gi,function(rA,QA){return QA.toUpperCase()})},J=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;")},W=function(nA){var rA=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},QA=rA.transformNode,SA=QA===void 0?function(EA){return EA}:QA,FA=rA.camelcase,MA=FA===void 0?!1:FA,TA=function(GA){var dA;return dA=SA(GA),MA&&(dA=M(dA)),dA};return TA(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(QA,SA){try{var FA=W.apply(void 0,nA);QA(FA)}catch(MA){SA(MA)}})}var iA=function tA(nA){var rA=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},QA=rA.transformAttr,SA=QA===void 0?function(it,yA,tt){return"".concat(it,'="').concat(tt(yA),'"')}:QA,FA=rA.transformNode,MA=FA===void 0?function(it){return it}:FA,TA=rA.selfClose,EA=TA===void 0?!0:TA;if(Array.isArray(nA))return nA.map(function(it){return tA(it,{transformAttr:SA,selfClose:EA,transformNode:MA})}).join("");var GA=MA(nA);if(GA.type==="text")return H(GA.value);var dA="";for(var PA in GA.attributes){var JA=SA(PA,GA.attributes[PA],O,GA.name);dA+=JA?" ".concat(JA):""}return GA.children&&GA.children.length>0||!EA?"<".concat(GA.name).concat(dA,">").concat(tA(GA.children,{transformAttr:SA,transformNode:MA,selfClose:EA}),"</").concat(GA.name,">"):"<".concat(GA.name).concat(dA,"/>")},gA=Object.assign({},{parse:$,parseSync:W,stringify:iA});return gA})}}),upA=Ga({"node_modules/js-beautify/js/src/core/output.js"(e,A){function t(n){this.__parent=n,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 n=new t(this.__parent);return n.set_indent(this.__indent_count,this.__alignment_count),n},t.prototype.item=function(n){return n<0?this.__items[this.__items.length+n]:this.__items[n]},t.prototype.has_match=function(n){for(var s=this.__items.length-1;s>=0;s--)if(this.__items[s].match(n))return!0;return!1},t.prototype.set_indent=function(n,s){this.is_empty()&&(this.__indent_count=n||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 n=this.__parent.current_line;return n.set_indent(this.__wrap_point_indent_count,this.__wrap_point_alignment_count),n.__items=this.__items.slice(this.__wrap_point_index),this.__items=this.__items.slice(0,this.__wrap_point_index),n.__character_count+=this.__character_count-this.__wrap_point_character_count,this.__character_count=this.__wrap_point_character_count,n.__items[0]===" "&&(n.__items.splice(0,1),n.__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(n){this.__items.push(n);var s=n.lastIndexOf(`
5384
5384
  `);s!==-1?this.__character_count=n.length-s:this.__character_count+=n.length},t.prototype.pop=function(){var n=null;return this.is_empty()||(n=this.__items.pop(),this.__character_count-=n.length),n},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 n="";return this.is_empty()?this.__parent.indent_empty_lines&&(n=this.__parent.get_indent_string(this.__indent_count)):(n=this.__parent.get_indent_string(this.__indent_count,this.__alignment_count),n+=this.__items.join("")),n};function i(n,s){this.__cache=[""],this.__indent_size=n.indent_size,this.__indent_string=n.indent_char,n.indent_with_tabs||(this.__indent_string=new Array(n.indent_size+1).join(n.indent_char)),s=s||"",n.indent_level>0&&(s=new Array(n.indent_level+1).join(this.__indent_string)),this.__base_string=s,this.__base_string_length=s.length}i.prototype.get_indent_size=function(n,s){var r=this.__base_string_length;return s=s||0,n<0&&(r=0),r+=n*this.__indent_size,r+=s,r},i.prototype.get_indent_string=function(n,s){var r=this.__base_string;return s=s||0,n<0&&(n=0,r=""),s+=n*this.__indent_size,this.__ensure_cache(s),r+=this.__cache[s],r},i.prototype.__ensure_cache=function(n){for(;n>=this.__cache.length;)this.__add_column()},i.prototype.__add_column=function(){var n=this.__cache.length,s=0,r="";this.__indent_size&&n>=this.__indent_size&&(s=Math.floor(n/this.__indent_size),n-=s*this.__indent_size,r=new Array(s+1).join(this.__indent_string)),n&&(r+=new Array(n+1).join(" ")),this.__cache.push(r)};function o(n,s){this.__indent_cache=new i(n,s),this.raw=!1,this._end_with_newline=n.end_with_newline,this.indent_size=n.indent_size,this.wrap_line_length=n.wrap_line_length,this.indent_empty_lines=n.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()}o.prototype.__add_outputline=function(){this.previous_line=this.current_line,this.current_line=this.next_line.clone_empty(),this.__lines.push(this.current_line)},o.prototype.get_line_number=function(){return this.__lines.length},o.prototype.get_indent_string=function(n,s){return this.__indent_cache.get_indent_string(n,s)},o.prototype.get_indent_size=function(n,s){return this.__indent_cache.get_indent_size(n,s)},o.prototype.is_empty=function(){return!this.previous_line&&this.current_line.is_empty()},o.prototype.add_new_line=function(n){return this.is_empty()||!n&&this.just_added_newline()?!1:(this.raw||this.__add_outputline(),!0)},o.prototype.get_code=function(n){this.trim(!0);var s=this.current_line.pop();s&&(s[s.length-1]===`
5385
5385
  `&&(s=s.replace(/\n+$/g,"")),this.current_line.push(s)),this._end_with_newline&&this.__add_outputline();var r=this.__lines.join(`
5386
5386
  `);return n!==`
@@ -5465,7 +5465,7 @@ $1`).replace(/>(\s*)(?=<!--\s*\/)/g,"> ")}}});function Hat(e,A,t){if(!A||!t)retu
5465
5465
  transition: opacity 0.2s;
5466
5466
  margin-bottom: 10px;
5467
5467
  color: red;
5468
- `,JOe=({children:e,transform:A=cb(),elements:t})=>{const i=AA.useRef(null),{isShowingDRCErrors:o,hoveredErrorId:n}=Vl(g=>({isShowingDRCErrors:g.is_showing_drc_errors,hoveredErrorId:g.hovered_error_id}));if(!t)return Z.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)}),Z.jsxs("div",{style:{position:"relative"},ref:i,children:[e,s.map((g,I)=>{const{pcb_port_ids:c,pcb_trace_id:B}=g,l=c?.[0]?a.get(c[0]):void 0,C=c?.[1]?a.get(c[1]):void 0,E=t?Cb(t).pcb_trace.get(B):void 0,Q=g.pcb_trace_error_id||`error_${I}_${g.error_type}_${g.message?.slice(0,20)}`,h=n===Q;if(l&&C){const u=Pi(A,{x:l.x,y:l.y}),d=Pi(A,{x:C.x,y:C.y}),f=!(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=DpA(m,i);return Z.jsxs(AA.Fragment,{children:[Z.jsx(HOe,{screenPort1:u,screenPort2:d,errorCenter:m,canLineBeDrawn:f,isHighlighted:h}),Z.jsx("div",{style:{position:"absolute",left:m.x-15,top:m.y-15,width:30,height:30,zIndex:EI.errorOverlay+5,cursor:"pointer",borderRadius:"50%"},onMouseEnter:D=>{const b=D.currentTarget.nextElementSibling;if(b){const k=b.querySelector(".error-message");k&&(k.style.opacity="1")}},onMouseLeave:D=>{if(!h){const b=D.currentTarget.nextElementSibling;if(b){const k=b.querySelector(".error-message");k&&(k.style.opacity="0")}}}}),Z.jsx("div",{style:{position:"absolute",zIndex:h?200:100,left:w.left,top:w.top,color:h?"#ff4444":"red",textAlign:"center",fontFamily:"sans-serif",fontSize:12,display:o||h?"flex":"none",flexDirection:"column",alignItems:"center",pointerEvents:"none",transform:w.transform},children:Z.jsx("div",{className:`error-message ${SpA}`,style:{opacity:h?1:0,border:`1px solid ${h?"#ff4444":"red"}`},children:g.message})})]},Q)}if(E?.route&&(o||h)){const u=E.route.map(w=>Pi(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),f=u[d],m=DpA(f,i);return Z.jsxs(AA.Fragment,{children:[Z.jsx(YOe,{points:u,errorCenter:f,isHighlighted:h}),Z.jsx("div",{style:{position:"absolute",left:f.x-15,top:f.y-15,width:30,height:30,zIndex:EI.errorOverlay+5,cursor:"pointer",borderRadius:"50%"},onMouseEnter:w=>{const D=w.currentTarget.nextElementSibling;if(D){const b=D.querySelector(".error-message");b&&(b.style.opacity="1")}},onMouseLeave:w=>{if(!h){const D=w.currentTarget.nextElementSibling;if(D){const b=D.querySelector(".error-message");b&&(b.style.opacity="0")}}}}),Z.jsx("div",{style:{position:"absolute",zIndex:h?EI.errorOverlay+10:EI.errorOverlay+1,left:m.left,top:m.top,color:h?"#ff4444":"red",textAlign:"center",fontFamily:"sans-serif",fontSize:12,display:"flex",flexDirection:"column",alignItems:"center",pointerEvents:"none",transform:m.transform},children:Z.jsx("div",{className:`error-message ${SpA}`,style:{opacity:h?1:0,border:`1px solid ${h?"#ff4444":"red"}`},children:g.message})})]},Q)}return null}),r.map((g,I)=>{const c=g.component_name||g.message?.match(/name "([^"]+)"/)?.[1];if(!c)return null;const B=t?.filter(E=>E.type==="source_component"&&E.name===c||E.type==="pcb_component"&&t?.find(Q=>Q.type==="source_component"&&Q.source_component_id===E.source_component_id&&Q.name===c))||[],l=g.pcb_trace_error_id||`error_${I}_${g.error_type}_${g.message?.slice(0,20)}`,C=n===l;return!C&&!o?null:B.map((E,Q)=>{let h={x:0,y:0};if(E.type==="pcb_component")h=E.center||{x:0,y:0};else if(E.type==="source_component"){const k=t?.find(x=>x.type==="pcb_component"&&x.source_component_id===E.source_component_id);k&&k.type==="pcb_component"&&(h=k.center||{x:0,y:0})}const u=Pi(A,h);if(isNaN(u.x)||isNaN(u.y))return null;const d=Math.abs(A.a),D=Math.max(8,Math.min(30,.5*d)),b=DpA(u,i);return Z.jsxs(AA.Fragment,{children:[Z.jsx("svg",{style:{position:"absolute",left:0,top:0,pointerEvents:"none",mixBlendMode:"difference",zIndex:EI.errorOverlay},width:"100%",height:"100%",children:C?Z.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"}):Z.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})}),Z.jsx("div",{style:{position:"absolute",left:u.x-(D+10),top:u.y-(D+10),width:(D+10)*2,height:(D+10)*2,zIndex:EI.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")}}}}),Z.jsx("div",{style:{position:"absolute",zIndex:C?EI.errorOverlay+20:EI.errorOverlay+10,left:b.left,top:b.top,color:C?"#ff4444":"red",textAlign:"center",fontFamily:"sans-serif",fontSize:12,display:o||C?"flex":"none",flexDirection:"column",alignItems:"center",pointerEvents:"none",transform:b.transform},children:Z.jsx("div",{className:`error-message ${SpA}`,style:{opacity:C?1:0,border:`1px solid ${C?"#ff4444":"red"}`},children:g.message})})]},`${l}_${Q}`)})})]})};function TOe(e,A){return e.size!==A.size?!1:Array.from(e).every(t=>A.has(t))}function KOe({primitiveElement:e,elements:A}){let t=e.trace_length?`${e.trace_length.toFixed(3)}`:"";const i=Cb(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 o=e.trace_length&&i?.max_length&&e.trace_length>i.max_length;return{text:t,isOverLength:o}}function POe(e){const{primitives:A,is_showing_multiple_traces_length:t,elements:i}=e,o=A.filter(a=>a._element.type==="pcb_trace"),n=i.filter(a=>a.type==="source_trace"),s=A.filter(a=>a._element.type!=="pcb_trace"),r=o.filter(a=>n.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(o.length>1){const a=o.reduce((g,I)=>{const c=g._element.trace_length;return I._element.trace_length<c?I:g},o[0]);return[...s,a]}return A}var qOe={position:"absolute",left:0,top:0,pointerEvents:"none",color:"red",fontFamily:"sans-serif",fontSize:12,textShadow:"0 0 2px black"},OOe=e=>{const{_element:A,_parent_pcb_component:t,_parent_source_component:i,_source_port:o}=e;switch(A.type){case"pcb_trace":return A.trace_length?`${A.trace_length.toFixed(3)}`:"";case"pcb_smtpad":case"pcb_plated_hole":{const n=[],s=Array.from(new Set((A.port_hints??[]).concat(o?.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?n.push(...s.map(a=>`${r}.${a}`)):n.push(...s):r&&n.push(r),n.join(", ")}default:return""}},WOe={top:"red",bottom:"aqua"},ZOe=({primitive:e,mousePos:A,elements:t})=>{const[i,o]=AA.useState(!1),n=e._element;AA.useEffect(()=>{setTimeout(()=>{o(!0)},100)},[]);const[s,r,a,g]=[e.screen_x,e.screen_y,e.screen_w,e.screen_h],I=e.same_space_index??0,c=26,B=WOe[e?._element?.layer]??"red";let l=0;if(n.type==="pcb_smtpad"&&n?.shape==="rotated_rect"?l=n?.ccw_rotation??0:(n.type==="pcb_smtpad"&&(n?.shape==="pill"||n?.shape==="rotated_pill")&&"ccw_rotation"in e||n.type==="pcb_plated_hole"&&(n?.shape==="pill"||n?.shape==="oval")&&"ccw_rotation"in e)&&(l=n.ccw_rotation??0),n.type==="pcb_trace"){const Q=KOe({primitiveElement:n,elements:t});if(!Q)return null;const h=A.y-35;return Z.jsx("div",{style:{zIndex:EI.elementOverlay,position:"absolute",left:A.x,top:h,color:B,pointerEvents:"none",transform:"translateX(-50%)"},children:Z.jsx("div",{style:{backgroundColor:"#f2efcc",color:Q.isOverLength?"red":"black",textShadow:"none",WebkitFontSmoothing:"antialiased",MozOsxFontSmoothing:"grayscale",padding:"6px 6px",borderRadius:"6px",fontSize:"14px",minWidth:"45px",textAlign:"center",whiteSpace:"nowrap"},children:Q.text})})}const C=OOe(e);return C.trim().length===0?null:Z.jsx("div",{style:{zIndex:EI.elementOverlay,position:"absolute",left:s-a/2-8,top:r-g/2-8,width:a+16,height:g+16,color:B,transform:`rotate(${-l}deg)`,transformOrigin:"center center"},children:Z.jsx("div",{style:{width:i?`calc(100% + ${c*2*I}px)`:"100%",height:i?`calc(100% + ${c*2*I}px)`:"100%",marginLeft:i?`${-c*I}px`:0,marginTop:i?`${-c*I}px`:0,border:`1px solid ${B}`,opacity:i||I===0?1:0,transition:"width 0.2s, height 0.2s, margin-left 0.2s, margin-top 0.2s, opacity 0.2s"},children:Z.jsx("div",{style:{position:"absolute",bottom:g+20+c*I,marginRight:i?`${-c*I}px`:0,marginBottom:i?0:-c*I,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(${l}deg)`,minWidth:"45px",textAlign:"center"},children:C})})})},VOe=({highlightedPrimitives:e,mousePos:A,elements:t})=>{const[i,o]=Vl(r=>[r.is_moving_component,r.is_showing_multiple_traces_length]),n=e.some(r=>r._element.type==="pcb_smtpad")&&e.some(r=>r._element.type==="pcb_trace");let s=e;return n&&(s=s.filter(r=>r._element.type==="pcb_smtpad")),s=POe({primitives:s,is_showing_multiple_traces_length:o,elements:t}),Z.jsx("div",{style:qOe,children:!i&&s.map((r,a)=>Z.jsx(ZOe,{primitive:r,mousePos:A,elements:t},a))})},Y_=e=>e?.type==="pcb_component",cgt=e=>e?.type==="pcb_group",jOe=e=>e?.type==="pcb_panel",bpA=e=>e?.type==="pcb_board",WI={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},S0={OFFSET_LINE:"white",COMPONENT_MARKER_FILL:"#66ccff",COMPONENT_MARKER_STROKE:"white",LABEL_TEXT:"white"},xpA=({targets:e,transform:A,containerWidth:t,containerHeight:i})=>{if(e.length===0)return null;const o={color:S0.LABEL_TEXT,mixBlendMode:"difference",pointerEvents:"none",fontSize:WI.LABEL_FONT_SIZE,fontFamily:"monospace",fontWeight:"bold"},n=new Map;return e.forEach(s=>{if(!n.has(s.anchor_id)){const r=Pi(A,s.anchor);n.set(s.anchor_id,r)}}),Z.jsx("div",{style:{position:"absolute",left:0,top:0,width:t,height:i,overflow:"hidden",pointerEvents:"none",zIndex:EI.dimensionOverlay},children:Z.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,I=n.get(a),c=Pi(A,g),B=g.x-r.x,l=g.y-r.y,C=Math.abs(c.x-I.x),E=Math.abs(c.y-I.y),Q=c.y<I.y,h=c.x>I.x,u=Q?WI.LABEL_OFFSET_ABOVE:WI.LABEL_OFFSET_BELOW,d=h?WI.LABEL_OFFSET_RIGHT:WI.LABEL_OFFSET_LEFT,f=C>WI.MIN_LINE_LENGTH_FOR_LABEL,m=E>WI.MIN_LINE_LENGTH_FOR_LABEL,w=`${s.display_offset_x??B.toFixed(2)}mm`,D=`${s.display_offset_y??l.toFixed(2)}mm`;return Z.jsxs("g",{children:[Z.jsx("line",{x1:I.x,y1:I.y,x2:c.x,y2:I.y,stroke:S0.OFFSET_LINE,strokeWidth:WI.LINE_STROKE_WIDTH,strokeDasharray:WI.LINE_DASH_PATTERN}),Z.jsx("line",{x1:c.x,y1:I.y,x2:c.x,y2:c.y,stroke:S0.OFFSET_LINE,strokeWidth:WI.LINE_STROKE_WIDTH,strokeDasharray:WI.LINE_DASH_PATTERN}),s.type==="component"||s.type==="board"?Z.jsx("circle",{cx:c.x,cy:c.y,r:WI.COMPONENT_MARKER_RADIUS,fill:S0.COMPONENT_MARKER_FILL,stroke:S0.COMPONENT_MARKER_STROKE,strokeWidth:1}):Z.jsxs(Z.Fragment,{children:[Z.jsx("line",{x1:c.x-WI.ANCHOR_MARKER_SIZE,y1:c.y,x2:c.x+WI.ANCHOR_MARKER_SIZE,y2:c.y,stroke:S0.OFFSET_LINE,strokeWidth:WI.ANCHOR_MARKER_STROKE_WIDTH}),Z.jsx("line",{x1:c.x,y1:c.y-WI.ANCHOR_MARKER_SIZE,x2:c.x,y2:c.y+WI.ANCHOR_MARKER_SIZE,stroke:S0.OFFSET_LINE,strokeWidth:WI.ANCHOR_MARKER_STROKE_WIDTH})]}),f&&Z.jsx("foreignObject",{x:Math.min(I.x,c.x),y:I.y+u,width:Math.abs(c.x-I.x),height:20,style:{overflow:"visible"},children:Z.jsx("div",{style:{...o,textAlign:"center"},children:w})}),m&&Z.jsx("foreignObject",{x:c.x+d,y:Math.min(I.y,c.y),width:WI.Y_LABEL_MIN_WIDTH,height:Math.abs(c.y-I.y),style:{overflow:"visible"},children:Z.jsx("div",{style:{...o,display:"flex",alignItems:"center",justifyContent:h?"flex-start":"flex-end",whiteSpace:"nowrap",padding:"0 4px",height:"100%"},children:D})})]},s.id)}),Array.from(n.entries()).map(([s,r])=>Z.jsxs("g",{children:[Z.jsx("line",{x1:r.x-WI.ANCHOR_MARKER_SIZE,y1:r.y,x2:r.x+WI.ANCHOR_MARKER_SIZE,y2:r.y,stroke:S0.OFFSET_LINE,strokeWidth:WI.ANCHOR_MARKER_STROKE_WIDTH}),Z.jsx("line",{x1:r.x,y1:r.y-WI.ANCHOR_MARKER_SIZE,x2:r.x,y2:r.y+WI.ANCHOR_MARKER_SIZE,stroke:S0.OFFSET_LINE,strokeWidth:WI.ANCHOR_MARKER_STROKE_WIDTH})]},`anchor-${s}`))]})})},zOe=({elements:e,highlightedPrimitives:A,transform:t,containerWidth:i,containerHeight:o})=>{const n=e.filter(h=>bpA(h)),s=e.filter(h=>Y_(h)),r=e.filter(h=>cgt(h)),a=A.map(h=>Y_(h._parent_pcb_component)?h._parent_pcb_component.pcb_component_id:Y_(h._element)?h._element.pcb_component_id:null).filter(h=>!!h),g=new Set;if(a.forEach(h=>{const u=s.find(d=>d.pcb_component_id===h);u?.pcb_group_id&&g.add(u.pcb_group_id)}),!Vl(h=>h.is_showing_group_anchor_offsets)&&a.length===0)return null;const c=s.map(h=>{const u=h.positioned_relative_to_pcb_board_id;if(!u)return null;const d=n.find(f=>f.pcb_board_id===u);return d?{component:h,board:d,type:"component"}:null}).filter(h=>!!h),B=r.map(h=>{const u=h.positioned_relative_to_pcb_board_id;if(!u||!h.center)return null;const d=n.find(f=>f.pcb_board_id===u);return d?{group:h,board:d,type:"group"}:null}).filter(h=>!!h),l=[...c,...B];if(l.length===0)return null;const C=a.length===0,E=l.filter(h=>h.type==="component"?C||a.includes(h.component.pcb_component_id):C||g.has(h.group.pcb_group_id));if(E.length===0)return null;const Q=E.map(h=>h.type==="component"?{id:`${h.board.pcb_board_id}-${h.component.pcb_component_id}-${h.type}`,anchor:h.board.center,anchor_id:h.board.pcb_board_id,target:h.component.center,type:"component",display_offset_x:h.component.display_offset_x,display_offset_y:h.component.display_offset_y}:{id:`${h.board.pcb_board_id}-${h.group.pcb_group_id}-${h.type}`,anchor:h.board.center,anchor_id:h.board.pcb_board_id,target:{x:h.group.anchor_position?.x??h.group.center.x,y:h.group.anchor_position?.y??h.group.center.y},type:"group",display_offset_x:h.group.display_offset_x,display_offset_y:h.group.display_offset_y}).filter(h=>!!h);return Z.jsx(xpA,{targets:Q,transform:t,containerWidth:i,containerHeight:o})},XOe=({elements:e,highlightedPrimitives:A,transform:t,containerWidth:i,containerHeight:o})=>{const n=e.filter(h=>cgt(h)),s=e.filter(h=>Y_(h)),r=A.map(h=>Y_(h._parent_pcb_component)?h._parent_pcb_component.pcb_component_id:Y_(h._element)?h._element.pcb_component_id:null).filter(h=>!!h),a=(h,u)=>{if(u.has(h))return;u.add(h);const d=n.find(f=>f.pcb_group_id===h);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(h=>{const u=s.find(d=>d.pcb_component_id===h);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))}),!Vl(h=>h.is_showing_group_anchor_offsets)&&r.length===0)return null;const c=s.map(h=>{if(h.position_mode==="relative_to_group_anchor"&&h.positioned_relative_to_pcb_group_id){const u=n.find(d=>d.pcb_group_id===h.positioned_relative_to_pcb_group_id);return u&&u.anchor_position?{component:h,parentGroup:u,type:"component"}:null}if(h.pcb_group_id){const u=n.find(d=>d.pcb_group_id===h.pcb_group_id);return u&&u.anchor_position?{component:h,parentGroup:u,type:"component"}:null}return null}).filter(h=>!!h),B=n.map(h=>{if(h.position_mode==="relative_to_group_anchor"&&h.positioned_relative_to_pcb_group_id){const u=n.find(d=>d.pcb_group_id===h.positioned_relative_to_pcb_group_id);if(u&&u.anchor_position&&h.anchor_position)return{group:h,parentGroup:u,type:"group"}}return null}).filter(h=>!!h),l=[...c,...B];if(l.length===0)return null;const C=r.length===0,E=l.filter(h=>h.type==="component"?C||r.includes(h.component.pcb_component_id):C||g.has(h.group.pcb_group_id)||g.has(h.parentGroup.pcb_group_id));if(E.length===0)return null;const Q=E.map(h=>{const u=h.parentGroup.anchor_position;return u?h.type==="component"?h.component.center?{id:`${h.parentGroup.pcb_group_id}-${h.component.pcb_component_id}-${h.type}`,anchor:u,anchor_id:h.parentGroup.pcb_group_id,target:h.component.center,type:"component",display_offset_x:h.component.display_offset_x,display_offset_y:h.component.display_offset_y}:null:h.group.anchor_position?{id:`${h.parentGroup.pcb_group_id}-${h.group.pcb_group_id}-${h.type}`,anchor:u,anchor_id:h.parentGroup.pcb_group_id,target:h.group.anchor_position,type:"group",display_offset_x:h.group.display_offset_x,display_offset_y:h.group.display_offset_y}:null:null}).filter(h=>!!h);return Z.jsx(xpA,{targets:Q,transform:t,containerWidth:i,containerHeight:o})},$Oe=(e,A)=>{const t=e.pcb_component_id,i=A.filter(o=>(o.type==="pcb_smtpad"||o.type==="pcb_plated_hole")&&o.pcb_component_id===t||o.type==="pcb_hole"&&o.pcb_component_id===t);return i.length===0?mpA([e]):mpA(i)},A5e=({elements:e,highlightedPrimitives:A,transform:t,containerWidth:i,containerHeight:o})=>{const n=new Map;for(const r of A)Y_(r._parent_pcb_component)&&n.set(r._parent_pcb_component.pcb_component_id,r._parent_pcb_component),Y_(r._element)&&n.set(r._element.pcb_component_id,r._element);if(n.size===0)return null;const s=[];for(const r of n.values()){const a=$Oe(r,e);if(!a)continue;const g=r.positioned_relative_to_pcb_group_id??r.pcb_group_id,I=g?Cb(e).pcb_group.get(g):null;s.push({component:r,bbox:a,group:I})}return s.length===0?null:Z.jsx("div",{style:{position:"absolute",left:0,top:0,width:i,height:o,overflow:"hidden",pointerEvents:"none",zIndex:EI.dimensionOverlay},children:Z.jsx("svg",{style:{position:"absolute",left:0,top:0,pointerEvents:"none"},width:i,height:o,children:s.map(({component:r,bbox:a,group:g})=>{const I=Pi(t,{x:a.minX,y:a.maxY}),c=Pi(t,{x:a.maxX,y:a.minY}),B={x:Math.min(I.x,c.x),y:Math.min(I.y,c.y),width:Math.abs(c.x-I.x),height:Math.abs(c.y-I.y)},l=r.center??{x:(a.minX+a.maxX)/2,y:(a.minY+a.maxY)/2},C=Pi(t,l);return Z.jsxs("g",{children:[Z.jsx("rect",{x:B.x,y:B.y,width:B.width,height:B.height,fill:"none",stroke:"white",strokeWidth:1.5,strokeDasharray:"4,4"}),Z.jsx("line",{x1:C.x-6,y1:C.y,x2:C.x+6,y2:C.y,stroke:S0.COMPONENT_MARKER_STROKE,strokeWidth:1.5}),Z.jsx("line",{x1:C.x,y1:C.y-6,x2:C.x,y2:C.y+6,stroke:S0.COMPONENT_MARKER_STROKE,strokeWidth:1.5}),Z.jsx("circle",{cx:C.x,cy:C.y,r:WI.COMPONENT_MARKER_RADIUS,fill:S0.COMPONENT_MARKER_FILL,stroke:S0.COMPONENT_MARKER_STROKE,strokeWidth:1})]},r.pcb_component_id)})})})},t5e=({elements:e,highlightedPrimitives:A,transform:t,containerWidth:i,containerHeight:o})=>{const n=e.filter(l=>jOe(l)),s=e.filter(l=>bpA(l)),r=A.map(l=>bpA(l._element)?l._element.pcb_board_id:null).filter(l=>!!l);if(!Vl(l=>l.is_showing_group_anchor_offsets)&&r.length===0)return null;const g=s.map(l=>{const C=l.pcb_panel_id,E=l.position_mode;if(!C||E!=="relative_to_panel_anchor")return null;const Q=n.find(h=>h.pcb_panel_id===C);return Q?{board:l,panel:Q,type:"board"}:null}).filter(l=>!!l);if(g.length===0)return null;const I=r.length===0,c=g.filter(l=>I||r.includes(l.board.pcb_board_id));if(c.length===0)return null;const B=c.map(l=>l.board.center?{id:`${l.panel.pcb_panel_id}-${l.board.pcb_board_id}-${l.type}`,anchor:l.panel.center,anchor_id:l.panel.pcb_panel_id,target:l.board.center,type:"board",display_offset_x:l.board.display_offset_x,display_offset_y:l.board.display_offset_y}:null).filter(l=>!!l);return Z.jsx(xpA,{targets:B,transform:t,containerWidth:i,containerHeight:o})},A9=e=>{if(e.length===0)return null;let A=e[0].x,t=e[0].y,i=e[0].x,o=e[0].y;for(const n of e)n.x<A&&(A=n.x),n.y<t&&(t=n.y),n.x>i&&(i=n.x),n.y>o&&(o=n.y);return{center:{x:(A+i)/2,y:(t+o)/2},width:i-A,height:o-t}},Bgt=(e,A)=>{if(A.length<3)return!1;let t=!1;for(let i=0,o=A.length-1;i<A.length;o=i++){const n=A[i].x,s=A[i].y,r=A[o].x,a=A[o].y;s>e.y!=a>e.y&&e.x<(r-n)*(e.y-s)/(a-s||Number.EPSILON)+n&&(t=!t)}return t},e5e=(e,A,t)=>{const i=[];for(const o of e){if(!o._element)continue;if("x1"in o&&o._element?.type==="pcb_trace"){const r=yh({x:A.x,y:A.y},{x:o.x1,y:o.y1},{x:o.x2,y:o.y2}),a=o.width||.5,g=Math.max(a*25,2)/t.a;r<g&&i.push(o);continue}if(o.pcb_drawing_type==="polygon"){const r=o.points.map(g=>({x:ue.parse(g.x),y:ue.parse(g.y)})),a=A9(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;Bgt(A,r)&&i.push(o);continue}if(o.pcb_drawing_type==="polygon_with_arcs"){const r=o.brep_shape.outer_ring.vertices.map(g=>({x:ue.parse(g.x),y:ue.parse(g.y)})),a=A9(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;Bgt(A,r)&&i.push(o);continue}if(!("x"in o&&"y"in o))continue;let n=0,s=0;if("w"in o&&"h"in o)n=o.w,s=o.h;else if("r"in o)n=o.r*2,s=o.r*2;else if("rX"in o&&"rY"in o)n=o.rX*2,s=o.rY*2;else continue;Math.abs(o.x-A.x)<n/2&&Math.abs(o.y-A.y)<s/2&&i.push(o)}return i},i5e=({elements:e,children:A,transform:t,primitives:i,onMouseHoverOverPrimitives:o})=>{const[n,s]=AA.useState([]),[r,a]=AA.useState({x:0,y:0}),[g,{width:I,height:c}]=ZY(),B=AA.useMemo(()=>{const C=[];for(const E of n){if(E._element?.type==="pcb_via"||E._element?.type==="pcb_component"||E?.layer==="drill")continue;let Q=null,h=0,u=0;if(E.pcb_drawing_type==="polygon"){const w=A9(E.points);if(!w)continue;Q=w.center,h=w.width,u=w.height}else if(E.pcb_drawing_type==="polygon_with_arcs"){const w=E.brep_shape.outer_ring.vertices.map(b=>({x:b.x,y:b.y})),D=A9(w);if(!D)continue;Q=D.center,h=D.width,u=D.height}else"x"in E&&"y"in E&&(Q={x:E.x,y:E.y},h="w"in E?E.w:"r"in E?E.r*2:"rX"in E&&"rY"in E?E.rX*2:0,u="h"in E?E.h:"r"in E?E.r*2:"rX"in E&&"rY"in E?E.rY*2:0);if(!Q)continue;const d=Pi(t,Q),f={w:h*t.a,h:u*t.a},m=C.filter(w=>d.x===w.screen_x&&d.y===w.screen_y&&f.w===w.screen_w&&f.h===w.screen_h).length;C.push({...E,x:Q.x,y:Q.y,w:h,h:u,screen_x:d.x,screen_y:d.y,screen_w:f.w,screen_h:f.h,same_space_index:m})}return C},[n,t]),l=(C,E,Q,h)=>{a({x:C,y:E});const u=Pi(Bb(Q),{x:C,y:E}),d=e5e(h,u,Q);TOe(new Set(d.map(f=>f._pcb_drawing_object_id)),new Set(n.map(f=>f._pcb_drawing_object_id)))||(s(d),o(d))};return Z.jsxs("div",{ref:g,style:{position:"relative",width:"100%",height:"100%"},onMouseMove:C=>{if(t){const E=C.currentTarget.getBoundingClientRect(),Q=C.clientX-E.left,h=C.clientY-E.top;l(Q,h,t,i)}},onTouchStart:C=>{if(t){const E=C.touches[0],Q=C.currentTarget.getBoundingClientRect(),h=E.clientX-Q.left,u=E.clientY-Q.top;l(h,u,t,i)}},children:[A,Z.jsx(VOe,{elements:e,mousePos:r,highlightedPrimitives:B}),t&&Z.jsxs(Z.Fragment,{children:[Z.jsx(zOe,{elements:e,highlightedPrimitives:B,transform:t,containerWidth:I,containerHeight:c}),Z.jsx(XOe,{elements:e,highlightedPrimitives:B,transform:t,containerWidth:I,containerHeight:c}),Z.jsx(A5e,{elements:e,highlightedPrimitives:B,transform:t,containerWidth:I,containerHeight:c}),Z.jsx(t5e,{elements:e,highlightedPrimitives:B,transform:t,containerWidth:I,containerHeight:c})]})]})},lgt=["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)"],o5e=({children:e,transform:A=cb(),elements:t=[],hoveredComponentIds:i=[]})=>{const[o,{width:n,height:s}]=ZY(),r=AA.useRef(null),{is_showing_pcb_groups:a,pcb_group_view_mode:g,is_showing_group_anchor_offsets:I}=Vl(c=>({is_showing_pcb_groups:c.is_showing_pcb_groups,pcb_group_view_mode:c.pcb_group_view_mode,is_showing_group_anchor_offsets:c.is_showing_group_anchor_offsets}));return AA.useEffect(()=>{const c=r.current;if(!c||!n||!s)return;c.width=n,c.height=s;const B=c.getContext("2d");if(!B||(B.clearRect(0,0,n,s),!a))return;const l=t.filter(w=>w.type==="pcb_group"),C=t.filter(w=>w.type==="pcb_component"),E=t.filter(w=>w.type==="source_group"),Q=new Map(E.map(w=>[w.source_group_id,w])),h=l.filter(w=>{if(g==="all")return!0;if(!w.source_group_id)return!1;const D=Q.get(w.source_group_id);return D?D.was_automatically_named!==!0:!1}),u=new Map;E.forEach(w=>{const D=w;if(D.parent_source_group_id){const b=u.get(D.parent_source_group_id)||[];b.push(w.source_group_id),u.set(D.parent_source_group_id,b)}});const d=w=>{const D=[],b=u.get(w)||[];for(const k of b)D.push(k),D.push(...d(k));return D},f=w=>{const D=E.find(b=>b.source_group_id===w);return D?.parent_source_group_id?1+f(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)}h.forEach((w,D)=>{let b=C.filter(UA=>UA.pcb_group_id===w.pcb_group_id);if(w.source_group_id){const UA=d(w.source_group_id),ZA=l.filter(kA=>kA.source_group_id&&UA.includes(kA.source_group_id));for(const kA of ZA){const DA=C.filter(HA=>HA.pcb_group_id===kA.pcb_group_id);b=[...b,...DA]}}let k,x,N,M,U=!1;if(w.center&&w.width&&w.height){U=!0;const UA=w.width/2,ZA=w.height/2;k=w.center.x-UA,N=w.center.x+UA,x=w.center.y-ZA,M=w.center.y+ZA}else if(b.length===0||(k=1/0,x=1/0,N=-1/0,M=-1/0,b.forEach(UA=>{if(UA.center&&typeof UA.width=="number"&&typeof UA.height=="number"){const ZA=UA.center.x-UA.width/2,kA=UA.center.x+UA.width/2,DA=UA.center.y+UA.height/2,HA=UA.center.y-UA.height/2;k=Math.min(k,ZA),N=Math.max(N,kA),x=Math.min(x,HA),M=Math.max(M,DA)}}),k===1/0||N===-1/0))return;const J=w.source_group_id?f(w.source_group_id):0,H=w.source_group_id?d(w.source_group_id).length>0:!1;if(!U){const kA=1+(H?.5:0);k-=kA,N+=kA,x-=kA,M+=kA}const O=Pi(A,{x:k,y:M}),W=Pi(A,{x:N,y:M}),$=Pi(A,{x:k,y:x}),iA=Pi(A,{x:N,y:x}),gA=lgt[D%lgt.length];B.strokeStyle=gA,B.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))),QA=tA*(H?1.3:1),SA=nA;B.setLineDash([QA,SA]),B.beginPath(),B.moveTo(O.x,O.y),B.lineTo(W.x,W.y),B.lineTo(iA.x,iA.y),B.lineTo($.x,$.y),B.closePath(),B.stroke();const FA=Math.max(8,Math.min(12,10*Math.abs(A.a))),MA=J==0||J==1?0:J*.11,TA=FA*(1-MA),EA=4,GA=w.name||`Group ${D+1}`;B.font=`${TA}px sans-serif`,B.setLineDash([]);const PA=B.measureText(GA).width+EA*2,JA=TA+EA*2,it=O.x-5,yA=O.y-5,tt=3;if(B.fillStyle="rgba(0, 0, 0, 0.8)",B.beginPath(),B.roundRect(it,yA-JA,PA,JA,tt),B.fill(),B.fillStyle=gA,B.textAlign="left",B.textBaseline="middle",B.fillText(GA,it+EA,yA-JA/2),I&&m.has(w.pcb_group_id)&&!!w.anchor_position&&w.anchor_position){const UA=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=Pi(A,UA);B.strokeStyle="white",B.lineWidth=1.5,B.setLineDash([]);const kA=Math.max(4,Math.min(8,6*Math.abs(A.a)));B.beginPath(),B.moveTo(ZA.x-kA,ZA.y),B.lineTo(ZA.x+kA,ZA.y),B.stroke(),B.beginPath(),B.moveTo(ZA.x,ZA.y-kA),B.lineTo(ZA.x,ZA.y+kA),B.stroke()}})},[t,A,n,s,a,g,I,i]),Z.jsxs("div",{ref:o,style:{position:"relative",width:"100%",height:"100%"},children:[e,Z.jsx("canvas",{ref:r,style:{position:"absolute",top:0,left:0,pointerEvents:"none",zIndex:EI.pcbGroupOverlay,display:a?"block":"none"}})]})},n5e=({transform:e,soup:A,children:t})=>{const i=Vl(r=>r.is_showing_rats_nest),{netMap:o,idToNetMap:n}=AA.useMemo(()=>Oat(A||[]),[A]),s=AA.useMemo(()=>{if(!A||!i)return[];const r=B=>{const l=Cb(A)[B.replace(/_\d+$/,"")].get(B);return l&&"x"in l&&"y"in l?{x:l.x,y:l.y}:null},a=(B,l)=>{const C=o[l]||[];let E=null,Q=1/0;return C.forEach(h=>{const u=r(h);if(u){const d=Math.sqrt((B.x-u.x)**2+(B.y-u.y)**2);d<Q&&d>0&&(Q=d,E=u)}}),E},g=Cb(A).pcb_port.list(),I=Cb(A).source_trace.list(),c=[];return g.forEach((B,l)=>{const C=n[B.pcb_port_id];let E=!1;for(const u of I)u.connected_source_port_ids.includes(B.source_port_id)&&u.connected_source_net_ids.length>0&&(E=!0);if(!C)return;const Q={x:B.x,y:B.y},h=a(Q,C);h&&c.push({key:`${B.pcb_port_id}-${l}`,startPoint:Q,endPoint:h,isInNet:E})}),c},[A,o,n,i]);return!A||!i?t:(e||(e=cb()),Z.jsxs("div",{style:{position:"relative"},children:[t,Z.jsx("svg",{style:{position:"absolute",left:0,top:0,width:"100%",height:"100%",pointerEvents:"none",opacity:.5,zIndex:EI.ratsNestOverlay},children:s.map(({key:r,startPoint:a,endPoint:g,isInNet:I})=>{const c=Pi(e,a),B=Pi(e,g);return Z.jsx("line",{x1:c.x,y1:c.y,x2:B.x,y2:B.y,stroke:"white",strokeWidth:"1",strokeDasharray:I?"6,6":void 0},r)})})]}))},s5e={version:"1.11.325"},J_=(e,A,t)=>{const i=Vl(s=>s.is_mouse_over_container),o=AA.useRef(i),n=AA.useRef(A);AA.useEffect(()=>{o.current=i},[i]),AA.useEffect(()=>{n.current=A},[A]),AA.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("+"),I=g.includes("ctrl"),c=g.includes("shift"),B=g.includes("alt"),l=g.includes("meta"),C=g[g.length-1],E=t?.current?t.current.contains(document.activeElement)||document.activeElement===t.current:!1;(o.current||E)&&(!I||r.ctrlKey)&&(!c||r.shiftKey)&&(!B||r.altKey)&&(!l||r.metaKey)&&r.key.toLowerCase()===C.toLowerCase()&&(r.preventDefault(),n.current())};return window.addEventListener("keydown",s),()=>{window.removeEventListener("keydown",s)}},[e])},r5e=()=>{const[e,A]=AA.useState(!1);return AA.useEffect(()=>{const t=()=>{A(window.innerWidth<=768)};return t(),window.addEventListener("resize",t),()=>window.removeEventListener("resize",t)},[]),e},a5e=({name:e,selected:A,onClick:t})=>Z.jsxs("div",{className:Uv`
5468
+ `,JOe=({children:e,transform:A=cb(),elements:t})=>{const i=AA.useRef(null),{isShowingDRCErrors:o,hoveredErrorId:n}=Vl(g=>({isShowingDRCErrors:g.is_showing_drc_errors,hoveredErrorId:g.hovered_error_id}));if(!t)return Z.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)}),Z.jsxs("div",{style:{position:"relative"},ref:i,children:[e,s.map((g,I)=>{const{pcb_port_ids:c,pcb_trace_id:B}=g,l=c?.[0]?a.get(c[0]):void 0,C=c?.[1]?a.get(c[1]):void 0,E=t?Cb(t).pcb_trace.get(B):void 0,Q=g.pcb_trace_error_id||`error_${I}_${g.error_type}_${g.message?.slice(0,20)}`,h=n===Q;if(l&&C){const u=Pi(A,{x:l.x,y:l.y}),d=Pi(A,{x:C.x,y:C.y}),f=!(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=DpA(m,i);return Z.jsxs(AA.Fragment,{children:[Z.jsx(HOe,{screenPort1:u,screenPort2:d,errorCenter:m,canLineBeDrawn:f,isHighlighted:h}),Z.jsx("div",{style:{position:"absolute",left:m.x-15,top:m.y-15,width:30,height:30,zIndex:EI.errorOverlay+5,cursor:"pointer",borderRadius:"50%"},onMouseEnter:D=>{const b=D.currentTarget.nextElementSibling;if(b){const k=b.querySelector(".error-message");k&&(k.style.opacity="1")}},onMouseLeave:D=>{if(!h){const b=D.currentTarget.nextElementSibling;if(b){const k=b.querySelector(".error-message");k&&(k.style.opacity="0")}}}}),Z.jsx("div",{style:{position:"absolute",zIndex:h?200:100,left:w.left,top:w.top,color:h?"#ff4444":"red",textAlign:"center",fontFamily:"sans-serif",fontSize:12,display:o||h?"flex":"none",flexDirection:"column",alignItems:"center",pointerEvents:"none",transform:w.transform},children:Z.jsx("div",{className:`error-message ${SpA}`,style:{opacity:h?1:0,border:`1px solid ${h?"#ff4444":"red"}`},children:g.message})})]},Q)}if(E?.route&&(o||h)){const u=E.route.map(w=>Pi(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),f=u[d],m=DpA(f,i);return Z.jsxs(AA.Fragment,{children:[Z.jsx(YOe,{points:u,errorCenter:f,isHighlighted:h}),Z.jsx("div",{style:{position:"absolute",left:f.x-15,top:f.y-15,width:30,height:30,zIndex:EI.errorOverlay+5,cursor:"pointer",borderRadius:"50%"},onMouseEnter:w=>{const D=w.currentTarget.nextElementSibling;if(D){const b=D.querySelector(".error-message");b&&(b.style.opacity="1")}},onMouseLeave:w=>{if(!h){const D=w.currentTarget.nextElementSibling;if(D){const b=D.querySelector(".error-message");b&&(b.style.opacity="0")}}}}),Z.jsx("div",{style:{position:"absolute",zIndex:h?EI.errorOverlay+10:EI.errorOverlay+1,left:m.left,top:m.top,color:h?"#ff4444":"red",textAlign:"center",fontFamily:"sans-serif",fontSize:12,display:"flex",flexDirection:"column",alignItems:"center",pointerEvents:"none",transform:m.transform},children:Z.jsx("div",{className:`error-message ${SpA}`,style:{opacity:h?1:0,border:`1px solid ${h?"#ff4444":"red"}`},children:g.message})})]},Q)}return null}),r.map((g,I)=>{const c=g.component_name||g.message?.match(/name "([^"]+)"/)?.[1];if(!c)return null;const B=t?.filter(E=>E.type==="source_component"&&E.name===c||E.type==="pcb_component"&&t?.find(Q=>Q.type==="source_component"&&Q.source_component_id===E.source_component_id&&Q.name===c))||[],l=g.pcb_trace_error_id||`error_${I}_${g.error_type}_${g.message?.slice(0,20)}`,C=n===l;return!C&&!o?null:B.map((E,Q)=>{let h={x:0,y:0};if(E.type==="pcb_component")h=E.center||{x:0,y:0};else if(E.type==="source_component"){const k=t?.find(x=>x.type==="pcb_component"&&x.source_component_id===E.source_component_id);k&&k.type==="pcb_component"&&(h=k.center||{x:0,y:0})}const u=Pi(A,h);if(isNaN(u.x)||isNaN(u.y))return null;const d=Math.abs(A.a),D=Math.max(8,Math.min(30,.5*d)),b=DpA(u,i);return Z.jsxs(AA.Fragment,{children:[Z.jsx("svg",{style:{position:"absolute",left:0,top:0,pointerEvents:"none",mixBlendMode:"difference",zIndex:EI.errorOverlay},width:"100%",height:"100%",children:C?Z.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"}):Z.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})}),Z.jsx("div",{style:{position:"absolute",left:u.x-(D+10),top:u.y-(D+10),width:(D+10)*2,height:(D+10)*2,zIndex:EI.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")}}}}),Z.jsx("div",{style:{position:"absolute",zIndex:C?EI.errorOverlay+20:EI.errorOverlay+10,left:b.left,top:b.top,color:C?"#ff4444":"red",textAlign:"center",fontFamily:"sans-serif",fontSize:12,display:o||C?"flex":"none",flexDirection:"column",alignItems:"center",pointerEvents:"none",transform:b.transform},children:Z.jsx("div",{className:`error-message ${SpA}`,style:{opacity:C?1:0,border:`1px solid ${C?"#ff4444":"red"}`},children:g.message})})]},`${l}_${Q}`)})})]})};function TOe(e,A){return e.size!==A.size?!1:Array.from(e).every(t=>A.has(t))}function KOe({primitiveElement:e,elements:A}){let t=e.trace_length?`${e.trace_length.toFixed(3)}`:"";const i=Cb(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 o=e.trace_length&&i?.max_length&&e.trace_length>i.max_length;return{text:t,isOverLength:o}}function POe(e){const{primitives:A,is_showing_multiple_traces_length:t,elements:i}=e,o=A.filter(a=>a._element.type==="pcb_trace"),n=i.filter(a=>a.type==="source_trace"),s=A.filter(a=>a._element.type!=="pcb_trace"),r=o.filter(a=>n.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(o.length>1){const a=o.reduce((g,I)=>{const c=g._element.trace_length;return I._element.trace_length<c?I:g},o[0]);return[...s,a]}return A}var qOe={position:"absolute",left:0,top:0,pointerEvents:"none",color:"red",fontFamily:"sans-serif",fontSize:12,textShadow:"0 0 2px black"},OOe=e=>{const{_element:A,_parent_pcb_component:t,_parent_source_component:i,_source_port:o}=e;switch(A.type){case"pcb_trace":return A.trace_length?`${A.trace_length.toFixed(3)}`:"";case"pcb_smtpad":case"pcb_plated_hole":{const n=[],s=Array.from(new Set((A.port_hints??[]).concat(o?.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?n.push(...s.map(a=>`${r}.${a}`)):n.push(...s):r&&n.push(r),n.join(", ")}default:return""}},WOe={top:"red",bottom:"aqua"},ZOe=({primitive:e,mousePos:A,elements:t})=>{const[i,o]=AA.useState(!1),n=e._element;AA.useEffect(()=>{setTimeout(()=>{o(!0)},100)},[]);const[s,r,a,g]=[e.screen_x,e.screen_y,e.screen_w,e.screen_h],I=e.same_space_index??0,c=26,B=WOe[e?._element?.layer]??"red";let l=0;if(n.type==="pcb_smtpad"&&n?.shape==="rotated_rect"?l=n?.ccw_rotation??0:(n.type==="pcb_smtpad"&&(n?.shape==="pill"||n?.shape==="rotated_pill")&&"ccw_rotation"in e||n.type==="pcb_plated_hole"&&(n?.shape==="pill"||n?.shape==="oval")&&"ccw_rotation"in e)&&(l=n.ccw_rotation??0),n.type==="pcb_trace"){const Q=KOe({primitiveElement:n,elements:t});if(!Q)return null;const h=A.y-35;return Z.jsx("div",{style:{zIndex:EI.elementOverlay,position:"absolute",left:A.x,top:h,color:B,pointerEvents:"none",transform:"translateX(-50%)"},children:Z.jsx("div",{style:{backgroundColor:"#f2efcc",color:Q.isOverLength?"red":"black",textShadow:"none",WebkitFontSmoothing:"antialiased",MozOsxFontSmoothing:"grayscale",padding:"6px 6px",borderRadius:"6px",fontSize:"14px",minWidth:"45px",textAlign:"center",whiteSpace:"nowrap"},children:Q.text})})}const C=OOe(e);return C.trim().length===0?null:Z.jsx("div",{style:{zIndex:EI.elementOverlay,position:"absolute",left:s-a/2-8,top:r-g/2-8,width:a+16,height:g+16,color:B,transform:`rotate(${-l}deg)`,transformOrigin:"center center"},children:Z.jsx("div",{style:{width:i?`calc(100% + ${c*2*I}px)`:"100%",height:i?`calc(100% + ${c*2*I}px)`:"100%",marginLeft:i?`${-c*I}px`:0,marginTop:i?`${-c*I}px`:0,border:`1px solid ${B}`,opacity:i||I===0?1:0,transition:"width 0.2s, height 0.2s, margin-left 0.2s, margin-top 0.2s, opacity 0.2s"},children:Z.jsx("div",{style:{position:"absolute",bottom:g+20+c*I,marginRight:i?`${-c*I}px`:0,marginBottom:i?0:-c*I,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(${l}deg)`,minWidth:"45px",textAlign:"center"},children:C})})})},VOe=({highlightedPrimitives:e,mousePos:A,elements:t})=>{const[i,o]=Vl(r=>[r.is_moving_component,r.is_showing_multiple_traces_length]),n=e.some(r=>r._element.type==="pcb_smtpad")&&e.some(r=>r._element.type==="pcb_trace");let s=e;return n&&(s=s.filter(r=>r._element.type==="pcb_smtpad")),s=POe({primitives:s,is_showing_multiple_traces_length:o,elements:t}),Z.jsx("div",{style:qOe,children:!i&&s.map((r,a)=>Z.jsx(ZOe,{primitive:r,mousePos:A,elements:t},a))})},Y_=e=>e?.type==="pcb_component",cgt=e=>e?.type==="pcb_group",jOe=e=>e?.type==="pcb_panel",bpA=e=>e?.type==="pcb_board",WI={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},S0={OFFSET_LINE:"white",COMPONENT_MARKER_FILL:"#66ccff",COMPONENT_MARKER_STROKE:"white",LABEL_TEXT:"white"},xpA=({targets:e,transform:A,containerWidth:t,containerHeight:i})=>{if(e.length===0)return null;const o={color:S0.LABEL_TEXT,mixBlendMode:"difference",pointerEvents:"none",fontSize:WI.LABEL_FONT_SIZE,fontFamily:"monospace",fontWeight:"bold"},n=new Map;return e.forEach(s=>{if(!n.has(s.anchor_id)){const r=Pi(A,s.anchor);n.set(s.anchor_id,r)}}),Z.jsx("div",{style:{position:"absolute",left:0,top:0,width:t,height:i,overflow:"hidden",pointerEvents:"none",zIndex:EI.dimensionOverlay},children:Z.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,I=n.get(a),c=Pi(A,g),B=g.x-r.x,l=g.y-r.y,C=Math.abs(c.x-I.x),E=Math.abs(c.y-I.y),Q=c.y<I.y,h=c.x>I.x,u=Q?WI.LABEL_OFFSET_ABOVE:WI.LABEL_OFFSET_BELOW,d=h?WI.LABEL_OFFSET_RIGHT:WI.LABEL_OFFSET_LEFT,f=C>WI.MIN_LINE_LENGTH_FOR_LABEL,m=E>WI.MIN_LINE_LENGTH_FOR_LABEL,w=`${s.display_offset_x??B.toFixed(2)}mm`,D=`${s.display_offset_y??l.toFixed(2)}mm`;return Z.jsxs("g",{children:[Z.jsx("line",{x1:I.x,y1:I.y,x2:c.x,y2:I.y,stroke:S0.OFFSET_LINE,strokeWidth:WI.LINE_STROKE_WIDTH,strokeDasharray:WI.LINE_DASH_PATTERN}),Z.jsx("line",{x1:c.x,y1:I.y,x2:c.x,y2:c.y,stroke:S0.OFFSET_LINE,strokeWidth:WI.LINE_STROKE_WIDTH,strokeDasharray:WI.LINE_DASH_PATTERN}),s.type==="component"||s.type==="board"?Z.jsx("circle",{cx:c.x,cy:c.y,r:WI.COMPONENT_MARKER_RADIUS,fill:S0.COMPONENT_MARKER_FILL,stroke:S0.COMPONENT_MARKER_STROKE,strokeWidth:1}):Z.jsxs(Z.Fragment,{children:[Z.jsx("line",{x1:c.x-WI.ANCHOR_MARKER_SIZE,y1:c.y,x2:c.x+WI.ANCHOR_MARKER_SIZE,y2:c.y,stroke:S0.OFFSET_LINE,strokeWidth:WI.ANCHOR_MARKER_STROKE_WIDTH}),Z.jsx("line",{x1:c.x,y1:c.y-WI.ANCHOR_MARKER_SIZE,x2:c.x,y2:c.y+WI.ANCHOR_MARKER_SIZE,stroke:S0.OFFSET_LINE,strokeWidth:WI.ANCHOR_MARKER_STROKE_WIDTH})]}),f&&Z.jsx("foreignObject",{x:Math.min(I.x,c.x),y:I.y+u,width:Math.abs(c.x-I.x),height:20,style:{overflow:"visible"},children:Z.jsx("div",{style:{...o,textAlign:"center"},children:w})}),m&&Z.jsx("foreignObject",{x:c.x+d,y:Math.min(I.y,c.y),width:WI.Y_LABEL_MIN_WIDTH,height:Math.abs(c.y-I.y),style:{overflow:"visible"},children:Z.jsx("div",{style:{...o,display:"flex",alignItems:"center",justifyContent:h?"flex-start":"flex-end",whiteSpace:"nowrap",padding:"0 4px",height:"100%"},children:D})})]},s.id)}),Array.from(n.entries()).map(([s,r])=>Z.jsxs("g",{children:[Z.jsx("line",{x1:r.x-WI.ANCHOR_MARKER_SIZE,y1:r.y,x2:r.x+WI.ANCHOR_MARKER_SIZE,y2:r.y,stroke:S0.OFFSET_LINE,strokeWidth:WI.ANCHOR_MARKER_STROKE_WIDTH}),Z.jsx("line",{x1:r.x,y1:r.y-WI.ANCHOR_MARKER_SIZE,x2:r.x,y2:r.y+WI.ANCHOR_MARKER_SIZE,stroke:S0.OFFSET_LINE,strokeWidth:WI.ANCHOR_MARKER_STROKE_WIDTH})]},`anchor-${s}`))]})})},zOe=({elements:e,highlightedPrimitives:A,transform:t,containerWidth:i,containerHeight:o})=>{const n=e.filter(h=>bpA(h)),s=e.filter(h=>Y_(h)),r=e.filter(h=>cgt(h)),a=A.map(h=>Y_(h._parent_pcb_component)?h._parent_pcb_component.pcb_component_id:Y_(h._element)?h._element.pcb_component_id:null).filter(h=>!!h),g=new Set;if(a.forEach(h=>{const u=s.find(d=>d.pcb_component_id===h);u?.pcb_group_id&&g.add(u.pcb_group_id)}),!Vl(h=>h.is_showing_group_anchor_offsets)&&a.length===0)return null;const c=s.map(h=>{const u=h.positioned_relative_to_pcb_board_id;if(!u)return null;const d=n.find(f=>f.pcb_board_id===u);return d?{component:h,board:d,type:"component"}:null}).filter(h=>!!h),B=r.map(h=>{const u=h.positioned_relative_to_pcb_board_id;if(!u||!h.center)return null;const d=n.find(f=>f.pcb_board_id===u);return d?{group:h,board:d,type:"group"}:null}).filter(h=>!!h),l=[...c,...B];if(l.length===0)return null;const C=a.length===0,E=l.filter(h=>h.type==="component"?C||a.includes(h.component.pcb_component_id):C||g.has(h.group.pcb_group_id));if(E.length===0)return null;const Q=E.map(h=>h.type==="component"?{id:`${h.board.pcb_board_id}-${h.component.pcb_component_id}-${h.type}`,anchor:h.board.center,anchor_id:h.board.pcb_board_id,target:h.component.center,type:"component",display_offset_x:h.component.display_offset_x,display_offset_y:h.component.display_offset_y}:{id:`${h.board.pcb_board_id}-${h.group.pcb_group_id}-${h.type}`,anchor:h.board.center,anchor_id:h.board.pcb_board_id,target:{x:h.group.anchor_position?.x??h.group.center.x,y:h.group.anchor_position?.y??h.group.center.y},type:"group",display_offset_x:h.group.display_offset_x,display_offset_y:h.group.display_offset_y}).filter(h=>!!h);return Z.jsx(xpA,{targets:Q,transform:t,containerWidth:i,containerHeight:o})},XOe=({elements:e,highlightedPrimitives:A,transform:t,containerWidth:i,containerHeight:o})=>{const n=e.filter(h=>cgt(h)),s=e.filter(h=>Y_(h)),r=A.map(h=>Y_(h._parent_pcb_component)?h._parent_pcb_component.pcb_component_id:Y_(h._element)?h._element.pcb_component_id:null).filter(h=>!!h),a=(h,u)=>{if(u.has(h))return;u.add(h);const d=n.find(f=>f.pcb_group_id===h);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(h=>{const u=s.find(d=>d.pcb_component_id===h);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))}),!Vl(h=>h.is_showing_group_anchor_offsets)&&r.length===0)return null;const c=s.map(h=>{if(h.position_mode==="relative_to_group_anchor"&&h.positioned_relative_to_pcb_group_id){const u=n.find(d=>d.pcb_group_id===h.positioned_relative_to_pcb_group_id);return u&&u.anchor_position?{component:h,parentGroup:u,type:"component"}:null}if(h.pcb_group_id){const u=n.find(d=>d.pcb_group_id===h.pcb_group_id);return u&&u.anchor_position?{component:h,parentGroup:u,type:"component"}:null}return null}).filter(h=>!!h),B=n.map(h=>{if(h.position_mode==="relative_to_group_anchor"&&h.positioned_relative_to_pcb_group_id){const u=n.find(d=>d.pcb_group_id===h.positioned_relative_to_pcb_group_id);if(u&&u.anchor_position&&h.anchor_position)return{group:h,parentGroup:u,type:"group"}}return null}).filter(h=>!!h),l=[...c,...B];if(l.length===0)return null;const C=r.length===0,E=l.filter(h=>h.type==="component"?C||r.includes(h.component.pcb_component_id):C||g.has(h.group.pcb_group_id)||g.has(h.parentGroup.pcb_group_id));if(E.length===0)return null;const Q=E.map(h=>{const u=h.parentGroup.anchor_position;return u?h.type==="component"?h.component.center?{id:`${h.parentGroup.pcb_group_id}-${h.component.pcb_component_id}-${h.type}`,anchor:u,anchor_id:h.parentGroup.pcb_group_id,target:h.component.center,type:"component",display_offset_x:h.component.display_offset_x,display_offset_y:h.component.display_offset_y}:null:h.group.anchor_position?{id:`${h.parentGroup.pcb_group_id}-${h.group.pcb_group_id}-${h.type}`,anchor:u,anchor_id:h.parentGroup.pcb_group_id,target:h.group.anchor_position,type:"group",display_offset_x:h.group.display_offset_x,display_offset_y:h.group.display_offset_y}:null:null}).filter(h=>!!h);return Z.jsx(xpA,{targets:Q,transform:t,containerWidth:i,containerHeight:o})},$Oe=(e,A)=>{const t=e.pcb_component_id,i=A.filter(o=>(o.type==="pcb_smtpad"||o.type==="pcb_plated_hole")&&o.pcb_component_id===t||o.type==="pcb_hole"&&o.pcb_component_id===t);return i.length===0?mpA([e]):mpA(i)},A5e=({elements:e,highlightedPrimitives:A,transform:t,containerWidth:i,containerHeight:o})=>{const n=new Map;for(const r of A)Y_(r._parent_pcb_component)&&n.set(r._parent_pcb_component.pcb_component_id,r._parent_pcb_component),Y_(r._element)&&n.set(r._element.pcb_component_id,r._element);if(n.size===0)return null;const s=[];for(const r of n.values()){const a=$Oe(r,e);if(!a)continue;const g=r.positioned_relative_to_pcb_group_id??r.pcb_group_id,I=g?Cb(e).pcb_group.get(g):null;s.push({component:r,bbox:a,group:I})}return s.length===0?null:Z.jsx("div",{style:{position:"absolute",left:0,top:0,width:i,height:o,overflow:"hidden",pointerEvents:"none",zIndex:EI.dimensionOverlay},children:Z.jsx("svg",{style:{position:"absolute",left:0,top:0,pointerEvents:"none"},width:i,height:o,children:s.map(({component:r,bbox:a,group:g})=>{const I=Pi(t,{x:a.minX,y:a.maxY}),c=Pi(t,{x:a.maxX,y:a.minY}),B={x:Math.min(I.x,c.x),y:Math.min(I.y,c.y),width:Math.abs(c.x-I.x),height:Math.abs(c.y-I.y)},l=r.center??{x:(a.minX+a.maxX)/2,y:(a.minY+a.maxY)/2},C=Pi(t,l);return Z.jsxs("g",{children:[Z.jsx("rect",{x:B.x,y:B.y,width:B.width,height:B.height,fill:"none",stroke:"white",strokeWidth:1.5,strokeDasharray:"4,4"}),Z.jsx("line",{x1:C.x-6,y1:C.y,x2:C.x+6,y2:C.y,stroke:S0.COMPONENT_MARKER_STROKE,strokeWidth:1.5}),Z.jsx("line",{x1:C.x,y1:C.y-6,x2:C.x,y2:C.y+6,stroke:S0.COMPONENT_MARKER_STROKE,strokeWidth:1.5}),Z.jsx("circle",{cx:C.x,cy:C.y,r:WI.COMPONENT_MARKER_RADIUS,fill:S0.COMPONENT_MARKER_FILL,stroke:S0.COMPONENT_MARKER_STROKE,strokeWidth:1})]},r.pcb_component_id)})})})},t5e=({elements:e,highlightedPrimitives:A,transform:t,containerWidth:i,containerHeight:o})=>{const n=e.filter(l=>jOe(l)),s=e.filter(l=>bpA(l)),r=A.map(l=>bpA(l._element)?l._element.pcb_board_id:null).filter(l=>!!l);if(!Vl(l=>l.is_showing_group_anchor_offsets)&&r.length===0)return null;const g=s.map(l=>{const C=l.pcb_panel_id,E=l.position_mode;if(!C||E!=="relative_to_panel_anchor")return null;const Q=n.find(h=>h.pcb_panel_id===C);return Q?{board:l,panel:Q,type:"board"}:null}).filter(l=>!!l);if(g.length===0)return null;const I=r.length===0,c=g.filter(l=>I||r.includes(l.board.pcb_board_id));if(c.length===0)return null;const B=c.map(l=>l.board.center?{id:`${l.panel.pcb_panel_id}-${l.board.pcb_board_id}-${l.type}`,anchor:l.panel.center,anchor_id:l.panel.pcb_panel_id,target:l.board.center,type:"board",display_offset_x:l.board.display_offset_x,display_offset_y:l.board.display_offset_y}:null).filter(l=>!!l);return Z.jsx(xpA,{targets:B,transform:t,containerWidth:i,containerHeight:o})},A9=e=>{if(e.length===0)return null;let A=e[0].x,t=e[0].y,i=e[0].x,o=e[0].y;for(const n of e)n.x<A&&(A=n.x),n.y<t&&(t=n.y),n.x>i&&(i=n.x),n.y>o&&(o=n.y);return{center:{x:(A+i)/2,y:(t+o)/2},width:i-A,height:o-t}},Bgt=(e,A)=>{if(A.length<3)return!1;let t=!1;for(let i=0,o=A.length-1;i<A.length;o=i++){const n=A[i].x,s=A[i].y,r=A[o].x,a=A[o].y;s>e.y!=a>e.y&&e.x<(r-n)*(e.y-s)/(a-s||Number.EPSILON)+n&&(t=!t)}return t},e5e=(e,A,t)=>{const i=[];for(const o of e){if(!o._element)continue;if("x1"in o&&o._element?.type==="pcb_trace"){const r=yh({x:A.x,y:A.y},{x:o.x1,y:o.y1},{x:o.x2,y:o.y2}),a=o.width||.5,g=Math.max(a*25,2)/t.a;r<g&&i.push(o);continue}if(o.pcb_drawing_type==="polygon"){const r=o.points.map(g=>({x:ue.parse(g.x),y:ue.parse(g.y)})),a=A9(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;Bgt(A,r)&&i.push(o);continue}if(o.pcb_drawing_type==="polygon_with_arcs"){const r=o.brep_shape.outer_ring.vertices.map(g=>({x:ue.parse(g.x),y:ue.parse(g.y)})),a=A9(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;Bgt(A,r)&&i.push(o);continue}if(!("x"in o&&"y"in o))continue;let n=0,s=0;if("w"in o&&"h"in o)n=o.w,s=o.h;else if("r"in o)n=o.r*2,s=o.r*2;else if("rX"in o&&"rY"in o)n=o.rX*2,s=o.rY*2;else continue;Math.abs(o.x-A.x)<n/2&&Math.abs(o.y-A.y)<s/2&&i.push(o)}return i},i5e=({elements:e,children:A,transform:t,primitives:i,onMouseHoverOverPrimitives:o})=>{const[n,s]=AA.useState([]),[r,a]=AA.useState({x:0,y:0}),[g,{width:I,height:c}]=ZY(),B=AA.useMemo(()=>{const C=[];for(const E of n){if(E._element?.type==="pcb_via"||E._element?.type==="pcb_component"||E?.layer==="drill")continue;let Q=null,h=0,u=0;if(E.pcb_drawing_type==="polygon"){const w=A9(E.points);if(!w)continue;Q=w.center,h=w.width,u=w.height}else if(E.pcb_drawing_type==="polygon_with_arcs"){const w=E.brep_shape.outer_ring.vertices.map(b=>({x:b.x,y:b.y})),D=A9(w);if(!D)continue;Q=D.center,h=D.width,u=D.height}else"x"in E&&"y"in E&&(Q={x:E.x,y:E.y},h="w"in E?E.w:"r"in E?E.r*2:"rX"in E&&"rY"in E?E.rX*2:0,u="h"in E?E.h:"r"in E?E.r*2:"rX"in E&&"rY"in E?E.rY*2:0);if(!Q)continue;const d=Pi(t,Q),f={w:h*t.a,h:u*t.a},m=C.filter(w=>d.x===w.screen_x&&d.y===w.screen_y&&f.w===w.screen_w&&f.h===w.screen_h).length;C.push({...E,x:Q.x,y:Q.y,w:h,h:u,screen_x:d.x,screen_y:d.y,screen_w:f.w,screen_h:f.h,same_space_index:m})}return C},[n,t]),l=(C,E,Q,h)=>{a({x:C,y:E});const u=Pi(Bb(Q),{x:C,y:E}),d=e5e(h,u,Q);TOe(new Set(d.map(f=>f._pcb_drawing_object_id)),new Set(n.map(f=>f._pcb_drawing_object_id)))||(s(d),o(d))};return Z.jsxs("div",{ref:g,style:{position:"relative",width:"100%",height:"100%"},onMouseMove:C=>{if(t){const E=C.currentTarget.getBoundingClientRect(),Q=C.clientX-E.left,h=C.clientY-E.top;l(Q,h,t,i)}},onTouchStart:C=>{if(t){const E=C.touches[0],Q=C.currentTarget.getBoundingClientRect(),h=E.clientX-Q.left,u=E.clientY-Q.top;l(h,u,t,i)}},children:[A,Z.jsx(VOe,{elements:e,mousePos:r,highlightedPrimitives:B}),t&&Z.jsxs(Z.Fragment,{children:[Z.jsx(zOe,{elements:e,highlightedPrimitives:B,transform:t,containerWidth:I,containerHeight:c}),Z.jsx(XOe,{elements:e,highlightedPrimitives:B,transform:t,containerWidth:I,containerHeight:c}),Z.jsx(A5e,{elements:e,highlightedPrimitives:B,transform:t,containerWidth:I,containerHeight:c}),Z.jsx(t5e,{elements:e,highlightedPrimitives:B,transform:t,containerWidth:I,containerHeight:c})]})]})},lgt=["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)"],o5e=({children:e,transform:A=cb(),elements:t=[],hoveredComponentIds:i=[]})=>{const[o,{width:n,height:s}]=ZY(),r=AA.useRef(null),{is_showing_pcb_groups:a,pcb_group_view_mode:g,is_showing_group_anchor_offsets:I}=Vl(c=>({is_showing_pcb_groups:c.is_showing_pcb_groups,pcb_group_view_mode:c.pcb_group_view_mode,is_showing_group_anchor_offsets:c.is_showing_group_anchor_offsets}));return AA.useEffect(()=>{const c=r.current;if(!c||!n||!s)return;c.width=n,c.height=s;const B=c.getContext("2d");if(!B||(B.clearRect(0,0,n,s),!a))return;const l=t.filter(w=>w.type==="pcb_group"),C=t.filter(w=>w.type==="pcb_component"),E=t.filter(w=>w.type==="source_group"),Q=new Map(E.map(w=>[w.source_group_id,w])),h=l.filter(w=>{if(g==="all")return!0;if(!w.source_group_id)return!1;const D=Q.get(w.source_group_id);return D?D.was_automatically_named!==!0:!1}),u=new Map;E.forEach(w=>{const D=w;if(D.parent_source_group_id){const b=u.get(D.parent_source_group_id)||[];b.push(w.source_group_id),u.set(D.parent_source_group_id,b)}});const d=w=>{const D=[],b=u.get(w)||[];for(const k of b)D.push(k),D.push(...d(k));return D},f=w=>{const D=E.find(b=>b.source_group_id===w);return D?.parent_source_group_id?1+f(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)}h.forEach((w,D)=>{let b=C.filter(UA=>UA.pcb_group_id===w.pcb_group_id);if(w.source_group_id){const UA=d(w.source_group_id),ZA=l.filter(kA=>kA.source_group_id&&UA.includes(kA.source_group_id));for(const kA of ZA){const DA=C.filter(HA=>HA.pcb_group_id===kA.pcb_group_id);b=[...b,...DA]}}let k,x,N,M,U=!1;if(w.center&&w.width&&w.height){U=!0;const UA=w.width/2,ZA=w.height/2;k=w.center.x-UA,N=w.center.x+UA,x=w.center.y-ZA,M=w.center.y+ZA}else if(b.length===0||(k=1/0,x=1/0,N=-1/0,M=-1/0,b.forEach(UA=>{if(UA.center&&typeof UA.width=="number"&&typeof UA.height=="number"){const ZA=UA.center.x-UA.width/2,kA=UA.center.x+UA.width/2,DA=UA.center.y+UA.height/2,HA=UA.center.y-UA.height/2;k=Math.min(k,ZA),N=Math.max(N,kA),x=Math.min(x,HA),M=Math.max(M,DA)}}),k===1/0||N===-1/0))return;const J=w.source_group_id?f(w.source_group_id):0,H=w.source_group_id?d(w.source_group_id).length>0:!1;if(!U){const kA=1+(H?.5:0);k-=kA,N+=kA,x-=kA,M+=kA}const O=Pi(A,{x:k,y:M}),W=Pi(A,{x:N,y:M}),$=Pi(A,{x:k,y:x}),iA=Pi(A,{x:N,y:x}),gA=lgt[D%lgt.length];B.strokeStyle=gA,B.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))),QA=tA*(H?1.3:1),SA=nA;B.setLineDash([QA,SA]),B.beginPath(),B.moveTo(O.x,O.y),B.lineTo(W.x,W.y),B.lineTo(iA.x,iA.y),B.lineTo($.x,$.y),B.closePath(),B.stroke();const FA=Math.max(8,Math.min(12,10*Math.abs(A.a))),MA=J==0||J==1?0:J*.11,TA=FA*(1-MA),EA=4,GA=w.name||`Group ${D+1}`;B.font=`${TA}px sans-serif`,B.setLineDash([]);const PA=B.measureText(GA).width+EA*2,JA=TA+EA*2,it=O.x-5,yA=O.y-5,tt=3;if(B.fillStyle="rgba(0, 0, 0, 0.8)",B.beginPath(),B.roundRect(it,yA-JA,PA,JA,tt),B.fill(),B.fillStyle=gA,B.textAlign="left",B.textBaseline="middle",B.fillText(GA,it+EA,yA-JA/2),I&&m.has(w.pcb_group_id)&&!!w.anchor_position&&w.anchor_position){const UA=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=Pi(A,UA);B.strokeStyle="white",B.lineWidth=1.5,B.setLineDash([]);const kA=Math.max(4,Math.min(8,6*Math.abs(A.a)));B.beginPath(),B.moveTo(ZA.x-kA,ZA.y),B.lineTo(ZA.x+kA,ZA.y),B.stroke(),B.beginPath(),B.moveTo(ZA.x,ZA.y-kA),B.lineTo(ZA.x,ZA.y+kA),B.stroke()}})},[t,A,n,s,a,g,I,i]),Z.jsxs("div",{ref:o,style:{position:"relative",width:"100%",height:"100%"},children:[e,Z.jsx("canvas",{ref:r,style:{position:"absolute",top:0,left:0,pointerEvents:"none",zIndex:EI.pcbGroupOverlay,display:a?"block":"none"}})]})},n5e=({transform:e,soup:A,children:t})=>{const i=Vl(r=>r.is_showing_rats_nest),{netMap:o,idToNetMap:n}=AA.useMemo(()=>Oat(A||[]),[A]),s=AA.useMemo(()=>{if(!A||!i)return[];const r=B=>{const l=Cb(A)[B.replace(/_\d+$/,"")].get(B);return l&&"x"in l&&"y"in l?{x:l.x,y:l.y}:null},a=(B,l)=>{const C=o[l]||[];let E=null,Q=1/0;return C.forEach(h=>{const u=r(h);if(u){const d=Math.sqrt((B.x-u.x)**2+(B.y-u.y)**2);d<Q&&d>0&&(Q=d,E=u)}}),E},g=Cb(A).pcb_port.list(),I=Cb(A).source_trace.list(),c=[];return g.forEach((B,l)=>{const C=n[B.pcb_port_id];let E=!1;for(const u of I)u.connected_source_port_ids.includes(B.source_port_id)&&u.connected_source_net_ids.length>0&&(E=!0);if(!C)return;const Q={x:B.x,y:B.y},h=a(Q,C);h&&c.push({key:`${B.pcb_port_id}-${l}`,startPoint:Q,endPoint:h,isInNet:E})}),c},[A,o,n,i]);return!A||!i?t:(e||(e=cb()),Z.jsxs("div",{style:{position:"relative"},children:[t,Z.jsx("svg",{style:{position:"absolute",left:0,top:0,width:"100%",height:"100%",pointerEvents:"none",opacity:.5,zIndex:EI.ratsNestOverlay},children:s.map(({key:r,startPoint:a,endPoint:g,isInNet:I})=>{const c=Pi(e,a),B=Pi(e,g);return Z.jsx("line",{x1:c.x,y1:c.y,x2:B.x,y2:B.y,stroke:"white",strokeWidth:"1",strokeDasharray:I?"6,6":void 0},r)})})]}))},s5e={version:"1.11.326"},J_=(e,A,t)=>{const i=Vl(s=>s.is_mouse_over_container),o=AA.useRef(i),n=AA.useRef(A);AA.useEffect(()=>{o.current=i},[i]),AA.useEffect(()=>{n.current=A},[A]),AA.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("+"),I=g.includes("ctrl"),c=g.includes("shift"),B=g.includes("alt"),l=g.includes("meta"),C=g[g.length-1],E=t?.current?t.current.contains(document.activeElement)||document.activeElement===t.current:!1;(o.current||E)&&(!I||r.ctrlKey)&&(!c||r.shiftKey)&&(!B||r.altKey)&&(!l||r.metaKey)&&r.key.toLowerCase()===C.toLowerCase()&&(r.preventDefault(),n.current())};return window.addEventListener("keydown",s),()=>{window.removeEventListener("keydown",s)}},[e])},r5e=()=>{const[e,A]=AA.useState(!1);return AA.useEffect(()=>{const t=()=>{A(window.innerWidth<=768)};return t(),window.addEventListener("resize",t),()=>window.removeEventListener("resize",t)},[]),e},a5e=({name:e,selected:A,onClick:t})=>Z.jsxs("div",{className:Uv`
5469
5469
  margin-top: 2px;
5470
5470
  padding: 4px;
5471
5471
  padding-left: 8px;
@@ -5682,7 +5682,7 @@ test("${g} should solve problem correctly", () => {
5682
5682
  // Add more specific assertions based on expected output
5683
5683
  // expect(solver.netLabelPlacementSolver!.netLabelPlacements).toMatchInlineSnapshot()
5684
5684
  })
5685
- `,c=new Blob([I],{type:"text/plain"}),B=URL.createObjectURL(c),l=document.createElement("a");l.href=B,l.download=`${g}.test.ts`,l.click(),URL.revokeObjectURL(B)}catch(a){alert(`Error generating test.ts for ${e.constructor.name}: ${a instanceof Error?a.message:String(a)}`)}i(!1)};return Z.jsxs("div",{className:`relative ${A}`,ref:o,children:[Z.jsx("button",{className:"px-2 py-1 rounded text-xs cursor-pointer",onClick:()=>i(!t),title:`Download options for ${e.constructor.name}`,children:e.constructor.name}),t&&Z.jsxs("div",{className:"absolute top-full left-0 mt-1 bg-white border border-gray-300 rounded shadow-lg z-10 min-w-[150px]",children:[Z.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:n,children:"Download JSON"}),Z.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:s,children:"Download page.tsx"}),Z.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:r,children:"Download test.ts"})]})]})},wgt=e=>e.activeSubSolver?[e,...wgt(e.activeSubSolver)]:[e],M8e=({solver:e})=>{const A=wgt(e);return Z.jsx("div",{className:"flex gap-1 items-center text-sm pt-1",children:A.map((t,i)=>Z.jsxs("div",{className:"flex items-center",children:[i>0&&Z.jsx("span",{className:"text-gray-400 mx-1",children:"→"}),Z.jsx(R8e,{solver:t})]},t.constructor.name))})},N8e=({solver:e,triggerRender:A,animationSpeed:t=25,onSolverStarted:i,onSolverCompleted:o})=>{const[n,s]=AA.useReducer(E=>!E,!1),r=AA.useRef(void 0),a=()=>{!e.solved&&!e.failed&&(e.step(),A())},g=()=>{!e.solved&&!e.failed&&(i&&i(e),e.solve(),A(),o&&o(e))},I=()=>{n?(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(),o&&e.solved&&o(e);return}e.step(),A()},t))},c=()=>{const E=e;if(E.getCurrentPhase&&!e.solved&&!e.failed){const Q=E.getCurrentPhase();for(;E.getCurrentPhase()===Q&&!e.solved&&!e.failed;)e.step();A()}},B=()=>{if(e.solved||e.failed||n)return;const E=window.prompt("Step until which iteration?",`${e.iterations}`);if(E===null)return;const Q=Number(E);if(!Number.isFinite(Q)){window.alert("Please enter a valid number for the iteration");return}for(;e.iterations<Q&&!e.solved&&!e.failed;)e.step();A(),e.solved&&o&&o(e)};AA.useEffect(()=>()=>{r.current&&clearInterval(r.current)},[]),AA.useEffect(()=>{(e.solved||e.failed)&&n&&(r.current&&(clearInterval(r.current),r.current=void 0),s())},[e.solved,e.failed,n]);const l=e.getCurrentPhase!==void 0,C=l?e.getCurrentPhase():null;return Z.jsxs("div",{className:"space-y-2 p-2 border-b",children:[Z.jsx("div",{className:"flex items-center",children:Z.jsx(M8e,{solver:e})}),Z.jsxs("div",{className:"flex gap-2 items-center flex-wrap",children:[Z.jsx("button",{onClick:a,disabled:e.solved||e.failed||n,className:"bg-blue-500 hover:bg-blue-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Step"}),Z.jsx("button",{onClick:g,disabled:e.solved||e.failed||n,className:"bg-green-500 hover:bg-green-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Solve"}),Z.jsx("button",{onClick:I,disabled:e.solved||e.failed,className:`px-3 py-1 rounded text-white text-sm ${n?"bg-red-500 hover:bg-red-600":"bg-yellow-500 hover:bg-yellow-600"} disabled:bg-gray-300`,children:n?"Stop":"Animate"}),Z.jsx("button",{onClick:B,disabled:e.solved||e.failed||n,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"}),l&&Z.jsx("button",{onClick:c,disabled:e.solved||e.failed||n,className:"bg-purple-500 hover:bg-purple-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Next Stage"}),Z.jsxs("div",{className:"text-sm text-gray-600",children:["Iterations: ",e.iterations]}),e.timeToSolve!==void 0&&Z.jsxs("div",{className:"text-sm text-gray-600",children:["Time: ",(e.timeToSolve/1e3).toFixed(3),"s"]}),C&&Z.jsxs("div",{className:"text-sm text-gray-600",children:["Phase: ",Z.jsx("span",{className:"font-medium",children:C})]}),e.solved&&Z.jsx("div",{className:"px-2 py-1 bg-green-100 text-green-800 rounded text-sm",children:"Solved"}),e.failed&&Z.jsx("div",{className:"px-2 py-1 bg-red-100 text-red-800 rounded text-sm",children:"Failed"})]}),e.error&&Z.jsxs("div",{className:"text-red-600 text-sm",children:["Error: ",e.error]})]})},v8e=(e,A,t)=>{const i=e.currentPipelineStepIndex;return A<i?"Completed":A===i&&e.activeSubSolver?e.activeSubSolver.failed?"Failed":"In Progress":"Not Started"},L8e=(e,A)=>{const i=e.pipelineDef[A].solverName,o=v8e(e,A),n=e[i],s=e.firstIterationOfPhase?.[i]??null,r=e.iterations;let a=0;if(o==="Completed"){const B=e.pipelineDef[A+1],l=B?e.firstIterationOfPhase?.[B.solverName]:void 0;l!==void 0&&s!==null?a=l-s:s!==null&&(a=r-s)}else o==="In Progress"&&s!==null&&(a=r-s);const g=e.timeSpentOnPhase?.[i]??0;let I=0;o==="Completed"?I=1:o==="In Progress"&&n&&(I=n.progress??0);const c=n?.stats??null;return{index:A,name:i,status:o,firstIteration:s,iterations:a,progress:I,timeSpent:g,stats:c&&Object.keys(c).length>0?c:null,solverInstance:n??null}},U8e=({status:e})=>{const A={"Not Started":"text-blue-600","In Progress":"text-yellow-600",Completed:"text-green-600",Failed:"text-red-600"};return Z.jsx("span",{className:`font-medium ${A[e]}`,children:e})},H8e=({progress:e})=>{if(e===0)return null;const A=Math.round(e*100);return Z.jsxs("div",{className:"flex items-center gap-2",children:[Z.jsx("div",{className:"w-20 h-2 bg-gray-200 rounded overflow-hidden",children:Z.jsx("div",{className:"h-full bg-blue-500 transition-all duration-200",style:{width:`${A}%`}})}),Z.jsxs("span",{className:"text-xs text-gray-500",children:[A,"%"]})]})},Y8e=e=>Object.entries(e).map(([A,t])=>`${A}: ${t}`).join(", "),J8e=({stats:e})=>{if(!e||Object.keys(e).length===0)return Z.jsx("span",{children:"-"});const A=Object.entries(e),t=Y8e(e);return Z.jsxs("details",{className:"cursor-pointer",children:[Z.jsx("summary",{className:"whitespace-nowrap overflow-hidden text-ellipsis max-w-[200px]",children:t}),Z.jsx("div",{className:"mt-1 text-xs",children:A.map(([i,o])=>Z.jsxs("div",{children:[i,": ",String(o)]},i))})]})},vpA=e=>{if(e===null||typeof e!="object")return e;if(Array.isArray(e))return e.map(vpA);const A={};for(const[t,i]of Object.entries(e))t.startsWith("_")||(A[t]=vpA(i));return A},T8e=(e,A)=>{try{if(typeof e.getConstructorParams!="function"){alert(`getConstructorParams() is not implemented for ${A}`);return}const t=vpA(e.getConstructorParams()),i=new Blob([JSON.stringify(t,null,2)],{type:"application/json"}),o=URL.createObjectURL(i),n=document.createElement("a");n.href=o,n.download=`${A}_input.json`,n.click(),URL.revokeObjectURL(o)}catch(t){alert(`Error downloading input for ${A}: ${t instanceof Error?t.message:String(t)}`)}},K8e=({solver:e,onStepUntilPhase:A,onDownloadInput:t})=>{const i=e.pipelineDef.map((r,a)=>L8e(e,a)),o=r=>{A?.(r)},n=r=>{r.solverInstance&&(t?t(r.solverInstance,r.name):T8e(r.solverInstance,r.name))},s=r=>`${(r/1e3).toFixed(2)}s`;return Z.jsxs("div",{className:"border-t border-gray-200",children:[Z.jsx("div",{className:"px-4 py-2 bg-gray-50 border-b border-gray-200",children:Z.jsx("h3",{className:"text-sm font-semibold text-gray-700",children:"Pipeline Steps"})}),Z.jsx("div",{className:"overflow-x-auto",children:Z.jsxs("table",{className:"w-full text-sm",children:[Z.jsx("thead",{children:Z.jsxs("tr",{className:"bg-gray-50 border-b border-gray-200",children:[Z.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Step"}),Z.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Status"}),Z.jsxs("th",{className:"px-4 py-2 text-center font-semibold text-gray-700",children:["i",Z.jsx("sub",{children:"0"})]}),Z.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Iterations"}),Z.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Progress"}),Z.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Time"}),Z.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Stats"}),Z.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Input"})]})}),Z.jsx("tbody",{children:i.map(r=>Z.jsxs("tr",{className:`border-b border-gray-100 ${r.status==="In Progress"?"bg-yellow-50":""}`,children:[Z.jsx("td",{className:"px-4 py-2",children:Z.jsxs("div",{className:"flex items-center gap-2",children:[Z.jsx("span",{className:"text-gray-400 w-6",children:String(r.index+1).padStart(2,"0")}),Z.jsx("button",{onClick:()=>o(r.name),disabled:r.status==="Completed"||e.solved||e.failed,className:"text-blue-500 hover:text-blue-700 disabled:text-gray-300 disabled:cursor-not-allowed",title:`Step until ${r.name} completes`,children:Z.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:Z.jsx("path",{fillRule:"evenodd",d:"M4.5 5.653c0-1.426 1.529-2.33 2.779-1.643l11.54 6.348c1.295.712 1.295 2.573 0 3.285L7.28 19.991c-1.25.687-2.779-.217-2.779-1.643V5.653z",clipRule:"evenodd"})})}),Z.jsx("span",{className:"font-medium text-gray-900",children:r.name})]})}),Z.jsx("td",{className:"px-4 py-2",children:Z.jsx(U8e,{status:r.status})}),Z.jsx("td",{className:"px-4 py-2 text-center text-gray-600",children:r.firstIteration!==null?r.firstIteration:""}),Z.jsx("td",{className:"px-4 py-2 text-gray-600",children:r.iterations}),Z.jsx("td",{className:"px-4 py-2",children:Z.jsx(H8e,{progress:r.progress})}),Z.jsx("td",{className:"px-4 py-2 text-gray-600",children:s(r.timeSpent)}),Z.jsx("td",{className:"px-4 py-2 text-gray-500",children:Z.jsx(J8e,{stats:r.stats})}),Z.jsx("td",{className:"px-4 py-2",children:r.solverInstance?Z.jsxs("button",{onClick:()=>n(r),className:"flex items-center gap-1 text-blue-500 hover:text-blue-700",title:`Download input for ${r.name}`,children:[Z.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:Z.jsx("path",{fillRule:"evenodd",d:"M12 2.25a.75.75 0 01.75.75v11.69l3.22-3.22a.75.75 0 111.06 1.06l-4.5 4.5a.75.75 0 01-1.06 0l-4.5-4.5a.75.75 0 111.06-1.06l3.22 3.22V3a.75.75 0 01.75-.75zm-9 13.5a.75.75 0 01.75.75v2.25a1.5 1.5 0 001.5 1.5h13.5a1.5 1.5 0 001.5-1.5V16.5a.75.75 0 011.5 0v2.25a3 3 0 01-3 3H5.25a3 3 0 01-3-3V16.5a.75.75 0 01.75-.75z",clipRule:"evenodd"})}),Z.jsx("span",{children:"Input"})]}):null})]},r.name))})]})})]})},P8e=class extends eo.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 q8e({graphics:e}){const A=e.points??[],t=e.lines??[],i=e.rects??[],o=e.circles??[],n=e.texts??[];let s=Number.POSITIVE_INFINITY,r=Number.POSITIVE_INFINITY,a=Number.NEGATIVE_INFINITY,g=Number.NEGATIVE_INFINITY;const I=(Q,h)=>{typeof Q=="number"&&(Q<s&&(s=Q),Q>a&&(a=Q)),typeof h=="number"&&(h<r&&(r=h),h>g&&(g=h))};for(const Q of A)I(Q.x,Q.y);for(const Q of t){const h=Q.points??[];for(const u of h)I(u.x,u.y)}for(const Q of i){const h=Q.x??0,u=Q.y??0,d=Q.width??0,f=Q.height??0;I(h,u),I(h+d,u+f)}for(const Q of o){const h=Q.x??0,u=Q.y??0,d=Q.radius??1;I(h-d,u-d),I(h+d,u+d)}for(const Q of n)I(Q.x,Q.y);(!isFinite(s)||!isFinite(r)||!isFinite(a)||!isFinite(g))&&(s=-20,r=-20,a=20,g=20);const c=10,B=s-c,l=r-c,C=Math.max(1,a-s+2*c),E=Math.max(1,g-r+2*c);return Z.jsxs("svg",{className:"w-full h-[400px] bg-white",viewBox:`${B} ${l} ${C} ${E}`,role:"img","aria-label":"Graphics fallback",children:[i.map((Q,h)=>Z.jsx("rect",{x:Q.x??0,y:Q.y??0,width:Q.width??0,height:Q.height??0,fill:"none",stroke:Q.strokeColor??"black",strokeWidth:Q.strokeWidth??1},`rect-${h}`)),t.map((Q,h)=>Z.jsx("polyline",{fill:"none",stroke:Q.strokeColor??"black",strokeWidth:Q.strokeWidth??1,points:(Q.points??[]).map(u=>`${u.x??0},${u.y??0}`).join(" ")},`line-${h}`)),o.map((Q,h)=>Z.jsx("circle",{cx:Q.x??0,cy:Q.y??0,r:Q.radius??1.5,fill:Q.fillColor??"none",stroke:Q.strokeColor??"black",strokeWidth:Q.strokeWidth??1},`circle-${h}`)),A.map((Q,h)=>Z.jsx("circle",{cx:Q.x??0,cy:Q.y??0,r:Q.radius??1.5,fill:Q.color??"black"},`point-${h}`)),n.map((Q,h)=>Z.jsx("text",{x:Q.x??0,y:Q.y??0,fontSize:Q.fontSize??10,fill:Q.color??"black",children:Q.text??""},`text-${h}`))]})}var O8e=({solver:e,animationSpeed:A=25,onSolverStarted:t,onSolverCompleted:i})=>{const[o,n]=AA.useReducer(I=>I+1,0),s=AA.useMemo(()=>{try{return e.visualize()||{points:[],lines:[],rects:[],circles:[]}}catch(I){return console.error("Visualization error:",I),{points:[],lines:[],rects:[],circles:[]}}},[e,o]),r=AA.useMemo(()=>(s.rects?.length||0)===0&&(s.lines?.length||0)===0&&(s.points?.length||0)===0&&(s.circles?.length||0)===0,[s]);AA.useEffect(()=>{if(!(typeof document>"u")&&!document.querySelector('script[src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4"]')){const I=document.createElement("script");I.src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4",document.head.appendChild(I)}},[]);const a=e.pipelineDef!==void 0,g=I=>{const c=e;if(!e.solved&&!e.failed){for(;!e.solved&&!e.failed&&c.currentPipelineStepIndex<=c.pipelineDef.findIndex(B=>B.solverName===I);)e.step();n()}};return Z.jsxs("div",{children:[Z.jsx(N8e,{solver:e,triggerRender:n,animationSpeed:A,onSolverStarted:t,onSolverCompleted:i}),r?Z.jsx("div",{className:"p-4 text-gray-500",children:"No Graphics Yet"}):Z.jsx(P8e,{fallback:Z.jsx(q8e,{graphics:s}),children:Z.jsx(F8e,{graphics:s})}),a&&Z.jsx(K8e,{solver:e,onStepUntilPhase:g})]})};const W8e=()=>{AA.useEffect(()=>{const e="tailwind-cdn-script";if(document.getElementById(e)||window.tailwind)return;const A=document.createElement("div");A.className="hidden",document.body.appendChild(A);const t=window.getComputedStyle(A).display==="none";if(document.body.removeChild(A),t)return;const i=document.createElement("script");i.id=e,i.src="https://cdn.tailwindcss.com",document.head.appendChild(i)},[])},Z8e=e=>e.toLowerCase().includes("pack")?Zke:e.toLowerCase().includes("rout")?AGe:Hke,V8e=({solverEvents:e=[]})=>{const[A,t]=AA.useState(null);W8e();const i=AA.useMemo(()=>{const r=new Map;for(const a of e){const g=`${a.componentName}-${a.solverName}`;r.set(g,a)}return r},[e]),o=AA.useMemo(()=>Array.from(i.keys()),[i]),n=A?i.get(A):null,s=AA.useMemo(()=>{if(!n)return{instance:null,error:null,classFound:!1};const r=WsA[n.solverName];if(!r)return{instance:null,error:`Solver class "${n.solverName}" not found in SOLVERS registry. Available: ${Object.keys(WsA).join(", ")}`,classFound:!1};try{const a=n.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}}},[n]);return e.length===0?Z.jsx("div",{className:"rf-p-4",children:Z.jsx("div",{className:"rf-bg-gray-50 rf-rounded-md rf-border rf-border-gray-200",children:Z.jsxs("div",{className:"rf-p-4",children:[Z.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800 rf-mb-3",children:"No Solvers Detected"}),Z.jsx("p",{className:"rf-text-sm rf-text-gray-600",children:"Solvers will appear here when the circuit runs. Solvers are used for tasks like component packing and autorouting."})]})})}):Z.jsxs("div",{className:"rf-flex rf-h-full rf-overflow-hidden",children:[Z.jsxs("div",{className:"rf-w-64 rf-border-r rf-border-gray-200 rf-overflow-y-auto rf-flex-shrink-0",children:[Z.jsxs("div",{className:"rf-text-xs rf-font-semibold rf-text-gray-500 rf-px-3 rf-py-2 rf-bg-gray-50 rf-border-b rf-border-gray-200",children:[o.length," ",o.length===1?"Solver":"Solvers"]}),o.map(r=>{const a=i.get(r),g=A===r;return Z.jsx("div",{className:`rf-px-3 rf-py-2 rf-cursor-pointer rf-border-b rf-border-gray-100 ${g?"rf-bg-blue-50 rf-border-l-2 rf-border-l-blue-500":"hover:rf-bg-gray-50"}`,onClick:()=>t(r),children:(()=>{const I=Z8e(a.solverName);return Z.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2",children:[Z.jsx(I,{className:"rf-w-4 rf-h-4 rf-text-blue-500 rf-flex-shrink-0"}),Z.jsxs("div",{className:"rf-flex-1 rf-min-w-0",children:[Z.jsx("div",{className:"rf-text-sm rf-font-medium rf-text-gray-800 rf-truncate",children:a.componentName}),Z.jsx("div",{className:"rf-text-xs rf-text-gray-500 rf-truncate",children:a.solverName})]})]})})()},r)})]}),Z.jsx("div",{className:"rf-flex-1 rf-overflow-hidden",children:n?s.instance?Z.jsx(aD,{fallback:Z.jsx("div",{className:"rf-p-4",children:Z.jsxs("div",{className:"rf-bg-red-50 rf-rounded-md rf-border rf-border-red-200 rf-p-4",children:[Z.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-red-800 rf-mb-2",children:"Error Loading Solver Debugger"}),Z.jsxs("p",{className:"rf-text-sm rf-text-red-600",children:["Failed to render the solver debugger for"," ",n.solverName]})]})}),children:Z.jsx(O8e,{solver:s.instance})}):Z.jsxs("div",{className:"rf-p-4",children:[Z.jsxs("div",{className:"rf-mb-4",children:[Z.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800",children:n.solverName}),Z.jsxs("p",{className:"rf-text-sm rf-text-gray-500",children:["Component: ",n.componentName]})]}),s.error&&Z.jsx("div",{className:`rf-rounded-md rf-border rf-p-4 rf-mb-4 ${s.classFound?"rf-bg-red-50 rf-border-red-200":"rf-bg-yellow-50 rf-border-yellow-200"}`,children:Z.jsx("p",{className:`rf-text-sm ${s.classFound?"rf-text-red-700":"rf-text-yellow-700"}`,children:s.error})}),Z.jsxs("div",{className:"rf-border rf-border-gray-200 rf-rounded-md rf-overflow-hidden",children:[Z.jsx("div",{className:"rf-px-3 rf-py-2 rf-bg-gray-50",children:Z.jsx("span",{className:"rf-text-sm rf-font-medium rf-text-gray-700",children:"Solver Parameters"})}),Z.jsx("div",{className:"rf-p-3 rf-bg-white rf-border-t rf-border-gray-200",children:Z.jsx("pre",{className:"rf-text-xs rf-font-mono rf-text-gray-600 rf-whitespace-pre-wrap rf-overflow-x-auto",children:JSON.stringify(n.solverParams,null,2)})})]})]}):Z.jsx("div",{className:"rf-flex rf-items-center rf-justify-center rf-h-full",children:Z.jsx("p",{className:"rf-text-sm rf-text-gray-500",children:"Select a solver from the list to view details"})})})]})},Dgt=({errorMessage:e,errorStack:A,circuitJsonErrors:t})=>{AA.useEffect(()=>{if(e){const i=new Error(e);A&&(i.stack=A);try{RK.captureException(i)}catch{}}},[e,A]),AA.useEffect(()=>{if(t&&t.length>0)for(const i of t){const o=new Error(i.message||"Circuit JSON Error");i.stack&&(o.stack=i.stack);try{RK.captureException(o,{error_type:i.type})}catch{}}},[t])},Sgt="0.0.1555",j8e={version:Sgt},LpA={BASE_URL:"/",DEV:!1,MODE:"production",PROD:!0,SSR:!1},UpA=new Map,n9=e=>{const A=UpA.get(e);return A?Object.fromEntries(Object.entries(A.stores).map(([t,i])=>[t,i.getState()])):{}},z8e=(e,A,t)=>{if(e===void 0)return{type:"untracked",connection:A.connect(t)};const i=UpA.get(t.name);if(i)return{type:"tracked",store:e,...i};const o={connection:A.connect(t),stores:{}};return UpA.set(t.name,o),{type:"tracked",store:e,...o}},bgt=(e,A={})=>(t,i,o)=>{const{enabled:n,anonymousActionType:s,store:r,...a}=A;let g;try{g=(n??(LpA?"production":void 0)!=="production")&&window.__REDUX_DEVTOOLS_EXTENSION__}catch{}if(!g)return(LpA?"production":void 0)!=="production"&&n&&console.warn("[zustand devtools middleware] Please install/enable Redux devtools extension"),e(t,i,o);const{connection:I,...c}=z8e(r,g,a);let B=!0;o.setState=(E,Q,h)=>{const u=t(E,Q);if(!B)return u;const d=h===void 0?{type:s||"anonymous"}:typeof h=="string"?{type:h}:h;return r===void 0?(I?.send(d,i()),u):(I?.send({...d,type:`${r}/${d.type}`},{...n9(a.name),[r]:o.getState()}),u)};const l=(...E)=>{const Q=B;B=!1,t(...E),B=Q},C=e(o.setState,i,o);if(c.type==="untracked"?I?.init(C):(c.stores[c.store]=o,I?.init(Object.fromEntries(Object.entries(c.stores).map(([E,Q])=>[E,E===c.store?C:Q.getState()])))),o.dispatchFromDevtools&&typeof o.dispatch=="function"){let E=!1;const Q=o.dispatch;o.dispatch=(...h)=>{(LpA?"production":void 0)!=="production"&&h[0].type==="__setState"&&!E&&(console.warn('[zustand devtools middleware] "__setState" action type is reserved to set state from the devtools. Avoid using it.'),E=!0),Q(...h)}}return I.subscribe(E=>{var Q;switch(E.type){case"ACTION":if(typeof E.payload!="string"){console.error("[zustand devtools middleware] Unsupported action format");return}return HpA(E.payload,h=>{if(h.type==="__setState"){if(r===void 0){l(h.state);return}Object.keys(h.state).length!==1&&console.error(`
5685
+ `,c=new Blob([I],{type:"text/plain"}),B=URL.createObjectURL(c),l=document.createElement("a");l.href=B,l.download=`${g}.test.ts`,l.click(),URL.revokeObjectURL(B)}catch(a){alert(`Error generating test.ts for ${e.constructor.name}: ${a instanceof Error?a.message:String(a)}`)}i(!1)};return Z.jsxs("div",{className:`relative ${A}`,ref:o,children:[Z.jsx("button",{className:"px-2 py-1 rounded text-xs cursor-pointer",onClick:()=>i(!t),title:`Download options for ${e.constructor.name}`,children:e.constructor.name}),t&&Z.jsxs("div",{className:"absolute top-full left-0 mt-1 bg-white border border-gray-300 rounded shadow-lg z-10 min-w-[150px]",children:[Z.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:n,children:"Download JSON"}),Z.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:s,children:"Download page.tsx"}),Z.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:r,children:"Download test.ts"})]})]})},wgt=e=>e.activeSubSolver?[e,...wgt(e.activeSubSolver)]:[e],M8e=({solver:e})=>{const A=wgt(e);return Z.jsx("div",{className:"flex gap-1 items-center text-sm pt-1",children:A.map((t,i)=>Z.jsxs("div",{className:"flex items-center",children:[i>0&&Z.jsx("span",{className:"text-gray-400 mx-1",children:"→"}),Z.jsx(R8e,{solver:t})]},t.constructor.name))})},N8e=({solver:e,triggerRender:A,animationSpeed:t=25,onSolverStarted:i,onSolverCompleted:o})=>{const[n,s]=AA.useReducer(E=>!E,!1),r=AA.useRef(void 0),a=()=>{!e.solved&&!e.failed&&(e.step(),A())},g=()=>{!e.solved&&!e.failed&&(i&&i(e),e.solve(),A(),o&&o(e))},I=()=>{n?(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(),o&&e.solved&&o(e);return}e.step(),A()},t))},c=()=>{const E=e;if(E.getCurrentPhase&&!e.solved&&!e.failed){const Q=E.getCurrentPhase();for(;E.getCurrentPhase()===Q&&!e.solved&&!e.failed;)e.step();A()}},B=()=>{if(e.solved||e.failed||n)return;const E=window.prompt("Step until which iteration?",`${e.iterations}`);if(E===null)return;const Q=Number(E);if(!Number.isFinite(Q)){window.alert("Please enter a valid number for the iteration");return}for(;e.iterations<Q&&!e.solved&&!e.failed;)e.step();A(),e.solved&&o&&o(e)};AA.useEffect(()=>()=>{r.current&&clearInterval(r.current)},[]),AA.useEffect(()=>{(e.solved||e.failed)&&n&&(r.current&&(clearInterval(r.current),r.current=void 0),s())},[e.solved,e.failed,n]);const l=e.getCurrentPhase!==void 0,C=l?e.getCurrentPhase():null;return Z.jsxs("div",{className:"space-y-2 p-2 border-b",children:[Z.jsx("div",{className:"flex items-center",children:Z.jsx(M8e,{solver:e})}),Z.jsxs("div",{className:"flex gap-2 items-center flex-wrap",children:[Z.jsx("button",{onClick:a,disabled:e.solved||e.failed||n,className:"bg-blue-500 hover:bg-blue-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Step"}),Z.jsx("button",{onClick:g,disabled:e.solved||e.failed||n,className:"bg-green-500 hover:bg-green-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Solve"}),Z.jsx("button",{onClick:I,disabled:e.solved||e.failed,className:`px-3 py-1 rounded text-white text-sm ${n?"bg-red-500 hover:bg-red-600":"bg-yellow-500 hover:bg-yellow-600"} disabled:bg-gray-300`,children:n?"Stop":"Animate"}),Z.jsx("button",{onClick:B,disabled:e.solved||e.failed||n,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"}),l&&Z.jsx("button",{onClick:c,disabled:e.solved||e.failed||n,className:"bg-purple-500 hover:bg-purple-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Next Stage"}),Z.jsxs("div",{className:"text-sm text-gray-600",children:["Iterations: ",e.iterations]}),e.timeToSolve!==void 0&&Z.jsxs("div",{className:"text-sm text-gray-600",children:["Time: ",(e.timeToSolve/1e3).toFixed(3),"s"]}),C&&Z.jsxs("div",{className:"text-sm text-gray-600",children:["Phase: ",Z.jsx("span",{className:"font-medium",children:C})]}),e.solved&&Z.jsx("div",{className:"px-2 py-1 bg-green-100 text-green-800 rounded text-sm",children:"Solved"}),e.failed&&Z.jsx("div",{className:"px-2 py-1 bg-red-100 text-red-800 rounded text-sm",children:"Failed"})]}),e.error&&Z.jsxs("div",{className:"text-red-600 text-sm",children:["Error: ",e.error]})]})},v8e=(e,A,t)=>{const i=e.currentPipelineStepIndex;return A<i?"Completed":A===i&&e.activeSubSolver?e.activeSubSolver.failed?"Failed":"In Progress":"Not Started"},L8e=(e,A)=>{const i=e.pipelineDef[A].solverName,o=v8e(e,A),n=e[i],s=e.firstIterationOfPhase?.[i]??null,r=e.iterations;let a=0;if(o==="Completed"){const B=e.pipelineDef[A+1],l=B?e.firstIterationOfPhase?.[B.solverName]:void 0;l!==void 0&&s!==null?a=l-s:s!==null&&(a=r-s)}else o==="In Progress"&&s!==null&&(a=r-s);const g=e.timeSpentOnPhase?.[i]??0;let I=0;o==="Completed"?I=1:o==="In Progress"&&n&&(I=n.progress??0);const c=n?.stats??null;return{index:A,name:i,status:o,firstIteration:s,iterations:a,progress:I,timeSpent:g,stats:c&&Object.keys(c).length>0?c:null,solverInstance:n??null}},U8e=({status:e})=>{const A={"Not Started":"text-blue-600","In Progress":"text-yellow-600",Completed:"text-green-600",Failed:"text-red-600"};return Z.jsx("span",{className:`font-medium ${A[e]}`,children:e})},H8e=({progress:e})=>{if(e===0)return null;const A=Math.round(e*100);return Z.jsxs("div",{className:"flex items-center gap-2",children:[Z.jsx("div",{className:"w-20 h-2 bg-gray-200 rounded overflow-hidden",children:Z.jsx("div",{className:"h-full bg-blue-500 transition-all duration-200",style:{width:`${A}%`}})}),Z.jsxs("span",{className:"text-xs text-gray-500",children:[A,"%"]})]})},Y8e=e=>Object.entries(e).map(([A,t])=>`${A}: ${t}`).join(", "),J8e=({stats:e})=>{if(!e||Object.keys(e).length===0)return Z.jsx("span",{children:"-"});const A=Object.entries(e),t=Y8e(e);return Z.jsxs("details",{className:"cursor-pointer",children:[Z.jsx("summary",{className:"whitespace-nowrap overflow-hidden text-ellipsis max-w-[200px]",children:t}),Z.jsx("div",{className:"mt-1 text-xs",children:A.map(([i,o])=>Z.jsxs("div",{children:[i,": ",String(o)]},i))})]})},vpA=e=>{if(e===null||typeof e!="object")return e;if(Array.isArray(e))return e.map(vpA);const A={};for(const[t,i]of Object.entries(e))t.startsWith("_")||(A[t]=vpA(i));return A},T8e=(e,A)=>{try{if(typeof e.getConstructorParams!="function"){alert(`getConstructorParams() is not implemented for ${A}`);return}const t=vpA(e.getConstructorParams()),i=new Blob([JSON.stringify(t,null,2)],{type:"application/json"}),o=URL.createObjectURL(i),n=document.createElement("a");n.href=o,n.download=`${A}_input.json`,n.click(),URL.revokeObjectURL(o)}catch(t){alert(`Error downloading input for ${A}: ${t instanceof Error?t.message:String(t)}`)}},K8e=({solver:e,onStepUntilPhase:A,onDownloadInput:t})=>{const i=e.pipelineDef.map((r,a)=>L8e(e,a)),o=r=>{A?.(r)},n=r=>{r.solverInstance&&(t?t(r.solverInstance,r.name):T8e(r.solverInstance,r.name))},s=r=>`${(r/1e3).toFixed(2)}s`;return Z.jsxs("div",{className:"border-t border-gray-200",children:[Z.jsx("div",{className:"px-4 py-2 bg-gray-50 border-b border-gray-200",children:Z.jsx("h3",{className:"text-sm font-semibold text-gray-700",children:"Pipeline Steps"})}),Z.jsx("div",{className:"overflow-x-auto",children:Z.jsxs("table",{className:"w-full text-sm",children:[Z.jsx("thead",{children:Z.jsxs("tr",{className:"bg-gray-50 border-b border-gray-200",children:[Z.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Step"}),Z.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Status"}),Z.jsxs("th",{className:"px-4 py-2 text-center font-semibold text-gray-700",children:["i",Z.jsx("sub",{children:"0"})]}),Z.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Iterations"}),Z.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Progress"}),Z.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Time"}),Z.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Stats"}),Z.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Input"})]})}),Z.jsx("tbody",{children:i.map(r=>Z.jsxs("tr",{className:`border-b border-gray-100 ${r.status==="In Progress"?"bg-yellow-50":""}`,children:[Z.jsx("td",{className:"px-4 py-2",children:Z.jsxs("div",{className:"flex items-center gap-2",children:[Z.jsx("span",{className:"text-gray-400 w-6",children:String(r.index+1).padStart(2,"0")}),Z.jsx("button",{onClick:()=>o(r.name),disabled:r.status==="Completed"||e.solved||e.failed,className:"text-blue-500 hover:text-blue-700 disabled:text-gray-300 disabled:cursor-not-allowed",title:`Step until ${r.name} completes`,children:Z.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:Z.jsx("path",{fillRule:"evenodd",d:"M4.5 5.653c0-1.426 1.529-2.33 2.779-1.643l11.54 6.348c1.295.712 1.295 2.573 0 3.285L7.28 19.991c-1.25.687-2.779-.217-2.779-1.643V5.653z",clipRule:"evenodd"})})}),Z.jsx("span",{className:"font-medium text-gray-900",children:r.name})]})}),Z.jsx("td",{className:"px-4 py-2",children:Z.jsx(U8e,{status:r.status})}),Z.jsx("td",{className:"px-4 py-2 text-center text-gray-600",children:r.firstIteration!==null?r.firstIteration:""}),Z.jsx("td",{className:"px-4 py-2 text-gray-600",children:r.iterations}),Z.jsx("td",{className:"px-4 py-2",children:Z.jsx(H8e,{progress:r.progress})}),Z.jsx("td",{className:"px-4 py-2 text-gray-600",children:s(r.timeSpent)}),Z.jsx("td",{className:"px-4 py-2 text-gray-500",children:Z.jsx(J8e,{stats:r.stats})}),Z.jsx("td",{className:"px-4 py-2",children:r.solverInstance?Z.jsxs("button",{onClick:()=>n(r),className:"flex items-center gap-1 text-blue-500 hover:text-blue-700",title:`Download input for ${r.name}`,children:[Z.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:Z.jsx("path",{fillRule:"evenodd",d:"M12 2.25a.75.75 0 01.75.75v11.69l3.22-3.22a.75.75 0 111.06 1.06l-4.5 4.5a.75.75 0 01-1.06 0l-4.5-4.5a.75.75 0 111.06-1.06l3.22 3.22V3a.75.75 0 01.75-.75zm-9 13.5a.75.75 0 01.75.75v2.25a1.5 1.5 0 001.5 1.5h13.5a1.5 1.5 0 001.5-1.5V16.5a.75.75 0 011.5 0v2.25a3 3 0 01-3 3H5.25a3 3 0 01-3-3V16.5a.75.75 0 01.75-.75z",clipRule:"evenodd"})}),Z.jsx("span",{children:"Input"})]}):null})]},r.name))})]})})]})},P8e=class extends eo.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 q8e({graphics:e}){const A=e.points??[],t=e.lines??[],i=e.rects??[],o=e.circles??[],n=e.texts??[];let s=Number.POSITIVE_INFINITY,r=Number.POSITIVE_INFINITY,a=Number.NEGATIVE_INFINITY,g=Number.NEGATIVE_INFINITY;const I=(Q,h)=>{typeof Q=="number"&&(Q<s&&(s=Q),Q>a&&(a=Q)),typeof h=="number"&&(h<r&&(r=h),h>g&&(g=h))};for(const Q of A)I(Q.x,Q.y);for(const Q of t){const h=Q.points??[];for(const u of h)I(u.x,u.y)}for(const Q of i){const h=Q.x??0,u=Q.y??0,d=Q.width??0,f=Q.height??0;I(h,u),I(h+d,u+f)}for(const Q of o){const h=Q.x??0,u=Q.y??0,d=Q.radius??1;I(h-d,u-d),I(h+d,u+d)}for(const Q of n)I(Q.x,Q.y);(!isFinite(s)||!isFinite(r)||!isFinite(a)||!isFinite(g))&&(s=-20,r=-20,a=20,g=20);const c=10,B=s-c,l=r-c,C=Math.max(1,a-s+2*c),E=Math.max(1,g-r+2*c);return Z.jsxs("svg",{className:"w-full h-[400px] bg-white",viewBox:`${B} ${l} ${C} ${E}`,role:"img","aria-label":"Graphics fallback",children:[i.map((Q,h)=>Z.jsx("rect",{x:Q.x??0,y:Q.y??0,width:Q.width??0,height:Q.height??0,fill:"none",stroke:Q.strokeColor??"black",strokeWidth:Q.strokeWidth??1},`rect-${h}`)),t.map((Q,h)=>Z.jsx("polyline",{fill:"none",stroke:Q.strokeColor??"black",strokeWidth:Q.strokeWidth??1,points:(Q.points??[]).map(u=>`${u.x??0},${u.y??0}`).join(" ")},`line-${h}`)),o.map((Q,h)=>Z.jsx("circle",{cx:Q.x??0,cy:Q.y??0,r:Q.radius??1.5,fill:Q.fillColor??"none",stroke:Q.strokeColor??"black",strokeWidth:Q.strokeWidth??1},`circle-${h}`)),A.map((Q,h)=>Z.jsx("circle",{cx:Q.x??0,cy:Q.y??0,r:Q.radius??1.5,fill:Q.color??"black"},`point-${h}`)),n.map((Q,h)=>Z.jsx("text",{x:Q.x??0,y:Q.y??0,fontSize:Q.fontSize??10,fill:Q.color??"black",children:Q.text??""},`text-${h}`))]})}var O8e=({solver:e,animationSpeed:A=25,onSolverStarted:t,onSolverCompleted:i})=>{const[o,n]=AA.useReducer(I=>I+1,0),s=AA.useMemo(()=>{try{return e.visualize()||{points:[],lines:[],rects:[],circles:[]}}catch(I){return console.error("Visualization error:",I),{points:[],lines:[],rects:[],circles:[]}}},[e,o]),r=AA.useMemo(()=>(s.rects?.length||0)===0&&(s.lines?.length||0)===0&&(s.points?.length||0)===0&&(s.circles?.length||0)===0,[s]);AA.useEffect(()=>{if(!(typeof document>"u")&&!document.querySelector('script[src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4"]')){const I=document.createElement("script");I.src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4",document.head.appendChild(I)}},[]);const a=e.pipelineDef!==void 0,g=I=>{const c=e;if(!e.solved&&!e.failed){for(;!e.solved&&!e.failed&&c.currentPipelineStepIndex<=c.pipelineDef.findIndex(B=>B.solverName===I);)e.step();n()}};return Z.jsxs("div",{children:[Z.jsx(N8e,{solver:e,triggerRender:n,animationSpeed:A,onSolverStarted:t,onSolverCompleted:i}),r?Z.jsx("div",{className:"p-4 text-gray-500",children:"No Graphics Yet"}):Z.jsx(P8e,{fallback:Z.jsx(q8e,{graphics:s}),children:Z.jsx(F8e,{graphics:s})}),a&&Z.jsx(K8e,{solver:e,onStepUntilPhase:g})]})};const W8e=()=>{AA.useEffect(()=>{const e="tailwind-cdn-script";if(document.getElementById(e)||window.tailwind)return;const A=document.createElement("div");A.className="hidden",document.body.appendChild(A);const t=window.getComputedStyle(A).display==="none";if(document.body.removeChild(A),t)return;const i=document.createElement("script");i.id=e,i.src="https://cdn.tailwindcss.com",document.head.appendChild(i)},[])},Z8e=e=>e.toLowerCase().includes("pack")?Zke:e.toLowerCase().includes("rout")?AGe:Hke,V8e=({solverEvents:e=[]})=>{const[A,t]=AA.useState(null);W8e();const i=AA.useMemo(()=>{const r=new Map;for(const a of e){const g=`${a.componentName}-${a.solverName}`;r.set(g,a)}return r},[e]),o=AA.useMemo(()=>Array.from(i.keys()),[i]),n=A?i.get(A):null,s=AA.useMemo(()=>{if(!n)return{instance:null,error:null,classFound:!1};const r=WsA[n.solverName];if(!r)return{instance:null,error:`Solver class "${n.solverName}" not found in SOLVERS registry. Available: ${Object.keys(WsA).join(", ")}`,classFound:!1};try{const a=n.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}}},[n]);return e.length===0?Z.jsx("div",{className:"rf-p-4",children:Z.jsx("div",{className:"rf-bg-gray-50 rf-rounded-md rf-border rf-border-gray-200",children:Z.jsxs("div",{className:"rf-p-4",children:[Z.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800 rf-mb-3",children:"No Solvers Detected"}),Z.jsx("p",{className:"rf-text-sm rf-text-gray-600",children:"Solvers will appear here when the circuit runs. Solvers are used for tasks like component packing and autorouting."})]})})}):Z.jsxs("div",{className:"rf-flex rf-h-full rf-overflow-hidden",children:[Z.jsxs("div",{className:"rf-w-64 rf-border-r rf-border-gray-200 rf-overflow-y-auto rf-flex-shrink-0",children:[Z.jsxs("div",{className:"rf-text-xs rf-font-semibold rf-text-gray-500 rf-px-3 rf-py-2 rf-bg-gray-50 rf-border-b rf-border-gray-200",children:[o.length," ",o.length===1?"Solver":"Solvers"]}),o.map(r=>{const a=i.get(r),g=A===r;return Z.jsx("div",{className:`rf-px-3 rf-py-2 rf-cursor-pointer rf-border-b rf-border-gray-100 ${g?"rf-bg-blue-50 rf-border-l-2 rf-border-l-blue-500":"hover:rf-bg-gray-50"}`,onClick:()=>t(r),children:(()=>{const I=Z8e(a.solverName);return Z.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2",children:[Z.jsx(I,{className:"rf-w-4 rf-h-4 rf-text-blue-500 rf-flex-shrink-0"}),Z.jsxs("div",{className:"rf-flex-1 rf-min-w-0",children:[Z.jsx("div",{className:"rf-text-sm rf-font-medium rf-text-gray-800 rf-truncate",children:a.componentName}),Z.jsx("div",{className:"rf-text-xs rf-text-gray-500 rf-truncate",children:a.solverName})]})]})})()},r)})]}),Z.jsx("div",{className:"rf-flex-1 rf-overflow-hidden",children:n?s.instance?Z.jsx(aD,{fallback:Z.jsx("div",{className:"rf-p-4",children:Z.jsxs("div",{className:"rf-bg-red-50 rf-rounded-md rf-border rf-border-red-200 rf-p-4",children:[Z.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-red-800 rf-mb-2",children:"Error Loading Solver Debugger"}),Z.jsxs("p",{className:"rf-text-sm rf-text-red-600",children:["Failed to render the solver debugger for"," ",n.solverName]})]})}),children:Z.jsx(O8e,{solver:s.instance})}):Z.jsxs("div",{className:"rf-p-4",children:[Z.jsxs("div",{className:"rf-mb-4",children:[Z.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800",children:n.solverName}),Z.jsxs("p",{className:"rf-text-sm rf-text-gray-500",children:["Component: ",n.componentName]})]}),s.error&&Z.jsx("div",{className:`rf-rounded-md rf-border rf-p-4 rf-mb-4 ${s.classFound?"rf-bg-red-50 rf-border-red-200":"rf-bg-yellow-50 rf-border-yellow-200"}`,children:Z.jsx("p",{className:`rf-text-sm ${s.classFound?"rf-text-red-700":"rf-text-yellow-700"}`,children:s.error})}),Z.jsxs("div",{className:"rf-border rf-border-gray-200 rf-rounded-md rf-overflow-hidden",children:[Z.jsx("div",{className:"rf-px-3 rf-py-2 rf-bg-gray-50",children:Z.jsx("span",{className:"rf-text-sm rf-font-medium rf-text-gray-700",children:"Solver Parameters"})}),Z.jsx("div",{className:"rf-p-3 rf-bg-white rf-border-t rf-border-gray-200",children:Z.jsx("pre",{className:"rf-text-xs rf-font-mono rf-text-gray-600 rf-whitespace-pre-wrap rf-overflow-x-auto",children:JSON.stringify(n.solverParams,null,2)})})]})]}):Z.jsx("div",{className:"rf-flex rf-items-center rf-justify-center rf-h-full",children:Z.jsx("p",{className:"rf-text-sm rf-text-gray-500",children:"Select a solver from the list to view details"})})})]})},Dgt=({errorMessage:e,errorStack:A,circuitJsonErrors:t})=>{AA.useEffect(()=>{if(e){const i=new Error(e);A&&(i.stack=A);try{RK.captureException(i)}catch{}}},[e,A]),AA.useEffect(()=>{if(t&&t.length>0)for(const i of t){const o=new Error(i.message||"Circuit JSON Error");i.stack&&(o.stack=i.stack);try{RK.captureException(o,{error_type:i.type})}catch{}}},[t])},Sgt="0.0.1556",j8e={version:Sgt},LpA={BASE_URL:"/",DEV:!1,MODE:"production",PROD:!0,SSR:!1},UpA=new Map,n9=e=>{const A=UpA.get(e);return A?Object.fromEntries(Object.entries(A.stores).map(([t,i])=>[t,i.getState()])):{}},z8e=(e,A,t)=>{if(e===void 0)return{type:"untracked",connection:A.connect(t)};const i=UpA.get(t.name);if(i)return{type:"tracked",store:e,...i};const o={connection:A.connect(t),stores:{}};return UpA.set(t.name,o),{type:"tracked",store:e,...o}},bgt=(e,A={})=>(t,i,o)=>{const{enabled:n,anonymousActionType:s,store:r,...a}=A;let g;try{g=(n??(LpA?"production":void 0)!=="production")&&window.__REDUX_DEVTOOLS_EXTENSION__}catch{}if(!g)return(LpA?"production":void 0)!=="production"&&n&&console.warn("[zustand devtools middleware] Please install/enable Redux devtools extension"),e(t,i,o);const{connection:I,...c}=z8e(r,g,a);let B=!0;o.setState=(E,Q,h)=>{const u=t(E,Q);if(!B)return u;const d=h===void 0?{type:s||"anonymous"}:typeof h=="string"?{type:h}:h;return r===void 0?(I?.send(d,i()),u):(I?.send({...d,type:`${r}/${d.type}`},{...n9(a.name),[r]:o.getState()}),u)};const l=(...E)=>{const Q=B;B=!1,t(...E),B=Q},C=e(o.setState,i,o);if(c.type==="untracked"?I?.init(C):(c.stores[c.store]=o,I?.init(Object.fromEntries(Object.entries(c.stores).map(([E,Q])=>[E,E===c.store?C:Q.getState()])))),o.dispatchFromDevtools&&typeof o.dispatch=="function"){let E=!1;const Q=o.dispatch;o.dispatch=(...h)=>{(LpA?"production":void 0)!=="production"&&h[0].type==="__setState"&&!E&&(console.warn('[zustand devtools middleware] "__setState" action type is reserved to set state from the devtools. Avoid using it.'),E=!0),Q(...h)}}return I.subscribe(E=>{var Q;switch(E.type){case"ACTION":if(typeof E.payload!="string"){console.error("[zustand devtools middleware] Unsupported action format");return}return HpA(E.payload,h=>{if(h.type==="__setState"){if(r===void 0){l(h.state);return}Object.keys(h.state).length!==1&&console.error(`
5686
5686
  [zustand devtools middleware] Unsupported __setState action format.
5687
5687
  When using 'store' option in devtools(), the 'state' should have only one key, which is a value of 'store' that was passed in devtools(),
5688
5688
  and value of this only key should be a state object. Example: { "type": "__setState", "state": { "abc123Store": { "foo": "bar" } } }