@tscircuit/runframe 0.0.1729 → 0.0.1730

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.
@@ -5387,7 +5387,7 @@ svg { font-family: 'Inter', 'Helvetica Neue', Arial, sans-serif; }
5387
5387
  `);let D=-1;for(let b=w.length-1;b>=0;b--)if(w[b].trim().toLowerCase().startsWith(m)){D=b;break}const S=[...g,B,f].filter(Boolean);let _;if(D!==-1){const b=w.slice(0,D),N=w.slice(D);_=[...b,...S,...N]}else _=[...w,...S,m];return _.join(`
5388
5388
  `)},Vzt=(t,A)=>{if(typeof window>"u")return A;try{const e=localStorage.getItem(t);return e!==null?JSON.parse(e):A}catch{return A}},jzt=(t,A)=>{if(!(typeof window>"u"))try{localStorage.setItem(t,JSON.stringify(A))}catch{}},syA=V.createContext(null),zzt=5,Xzt=(t,A)=>!t&&!A?!0:!t||!A?!1:t.minX===A.minX&&t.maxX===A.maxX&&t.minY===A.minY&&t.maxY===A.maxY,$zt=({children:t})=>{if(V.useContext(syA))return W.jsx(W.Fragment,{children:t});const e=V.useRef({pointer:null,boundingBoxes:new Map,hoveringIds:new Set,subscribers:new Set,mouseDownPosition:null}),i=V.useCallback(()=>{for(const I of e.current.subscribers)I()},[]),n=V.useCallback(()=>{const I=e.current.pointer,l=new Set;if(I)for(const[C,Q]of e.current.boundingBoxes){const h=Q.bounds;h&&I.x>=h.minX&&I.x<=h.maxX&&I.y>=h.minY&&I.y<=h.maxY&&l.add(C)}const B=e.current.hoveringIds;l.size===B.size&&[...l].every(C=>B.has(C))||(e.current.hoveringIds=l,i())},[i]),o=V.useCallback((I,l)=>{e.current.boundingBoxes.set(I,l),n()},[n]),s=V.useCallback((I,l)=>{const B=e.current.boundingBoxes.get(I);B&&Xzt(B.bounds,l.bounds)&&B.onClick===l.onClick||(e.current.boundingBoxes.set(I,l),n())},[n]),r=V.useCallback(I=>{e.current.boundingBoxes.delete(I)&&n()},[n]),a=V.useCallback(I=>(e.current.subscribers.add(I),()=>{e.current.subscribers.delete(I)}),[]),g=V.useCallback(I=>e.current.hoveringIds.has(I),[]);V.useEffect(()=>{const I=Q=>{const{clientX:h,clientY:E}=Q,u=e.current.pointer;u&&u.x===h&&u.y===E||(e.current.pointer={x:h,y:E},n())},l=()=>{e.current.pointer!==null&&(e.current.pointer=null,e.current.mouseDownPosition=null,n())},B=Q=>{e.current.mouseDownPosition={x:Q.clientX,y:Q.clientY}},C=Q=>{const{clientX:h,clientY:E}=Q,u=e.current.mouseDownPosition;if(u&&Math.sqrt(Math.pow(h-u.x,2)+Math.pow(E-u.y,2))>zzt){e.current.mouseDownPosition=null;return}e.current.mouseDownPosition=null;for(const d of e.current.boundingBoxes.values()){const f=d.bounds;f&&h>=f.minX&&h<=f.maxX&&E>=f.minY&&E<=f.maxY&&d.onClick?.(Q)}};return window.addEventListener("pointermove",I,{passive:!0}),window.addEventListener("pointerdown",I,{passive:!0}),window.addEventListener("pointerup",I,{passive:!0}),window.addEventListener("pointerleave",l),window.addEventListener("pointercancel",l),window.addEventListener("blur",l),window.addEventListener("mousedown",B,{passive:!0}),window.addEventListener("click",C,{passive:!0}),()=>{window.removeEventListener("pointermove",I),window.removeEventListener("pointerdown",I),window.removeEventListener("pointerup",I),window.removeEventListener("pointerleave",l),window.removeEventListener("pointercancel",l),window.removeEventListener("blur",l),window.removeEventListener("mousedown",B),window.removeEventListener("click",C)}},[n]);const c=V.useMemo(()=>({registerBoundingBox:o,updateBoundingBox:s,unregisterBoundingBox:r,subscribe:a,isHovering:g}),[o,s,r,a,g]);return W.jsx(syA.Provider,{value:c,children:t})},tle=t=>{const A=V.useContext(syA);if(!A)throw new Error("useMouseEventsOverBoundingBox must be used within a MouseTracker");const e=V.useId(),i=V.useRef(t);i.current=t;const n=V.useMemo(()=>s=>{i.current.onClick?.(s)},[]);return V.useEffect(()=>(A.registerBoundingBox(e,{bounds:i.current.bounds,onClick:i.current.onClick?n:void 0}),()=>{A.unregisterBoundingBox(e)}),[A,n,e]),V.useEffect(()=>{A.updateBoundingBox(e,{bounds:i.current.bounds,onClick:i.current.onClick?n:void 0})},[A,n,e,t.bounds?.minX,t.bounds?.maxX,t.bounds?.minY,t.bounds?.maxY,t.onClick]),{hovering:V.useSyncExternalStore(A.subscribe,()=>A.isHovering(e),()=>!1)}},AXt=(t,A)=>!t&&!A?!0:!t||!A?!1:Math.abs(t.bounds.minX-A.bounds.minX)<.5&&Math.abs(t.bounds.maxX-A.bounds.maxX)<.5&&Math.abs(t.bounds.minY-A.bounds.minY)<.5&&Math.abs(t.bounds.maxY-A.bounds.maxY)<.5&&Math.abs(t.rect.left-A.rect.left)<.5&&Math.abs(t.rect.top-A.rect.top)<.5&&Math.abs(t.rect.width-A.rect.width)<.5&&Math.abs(t.rect.height-A.rect.height)<.5,eXt=({componentId:t,svgDivRef:A,containerRef:e,onComponentClick:i,onHoverChange:n,showOutline:o,circuitJsonKey:s})=>{const[r,a]=V.useState(null),g=V.useRef(null),c=V.useCallback(()=>{g.current=null;const h=A.current,E=e.current;if(!h||!E){a(w=>w&&null);return}const u=h.querySelector(`[data-schematic-component-id="${t}"]`);if(!u){a(w=>w&&null);return}const d=u.getBoundingClientRect(),f=E.getBoundingClientRect(),m={bounds:{minX:d.left,maxX:d.right,minY:d.top,maxY:d.bottom},rect:{left:d.left-f.left,top:d.top-f.top,width:d.width,height:d.height}};a(w=>AXt(w,m)?w:m)},[t,e,A]),I=V.useCallback(()=>{g.current===null&&(g.current=window.requestAnimationFrame(c))},[c]);V.useEffect(()=>{I()},[I,s]),V.useEffect(()=>{I();const h=A.current,E=e.current;if(!h||!E)return;const u=typeof ResizeObserver<"u"?new ResizeObserver(()=>{I()}):null;u?.observe(E),u?.observe(h);const d=typeof MutationObserver<"u"?new MutationObserver(()=>{I()}):null;return d?.observe(h,{attributes:!0,attributeFilter:["style","transform"],subtree:!0,childList:!0}),window.addEventListener("scroll",I,!0),window.addEventListener("resize",I),()=>{u?.disconnect(),d?.disconnect(),window.removeEventListener("scroll",I,!0),window.removeEventListener("resize",I),g.current!==null&&(cancelAnimationFrame(g.current),g.current=null)}},[I,A,e]);const l=V.useCallback(h=>{i&&i(t,h)},[t,i]),B=r?.bounds??null,{hovering:C}=tle({bounds:B,onClick:i?l:void 0});if(V.useEffect(()=>{n&&n(t,C)},[C,t,n]),!r||!C||!o)return null;const Q=r.rect;return W.jsx("div",{style:{position:"absolute",left:Q.left,top:Q.top,width:Q.width,height:Q.height,border:"1.5px solid rgba(51, 153, 255, 0.9)",pointerEvents:"none",zIndex:hS.schematicComponentHoverOutline}})},tXt=(t,A)=>!t&&!A?!0:!t||!A?!1:Math.abs(t.bounds.minX-A.bounds.minX)<.5&&Math.abs(t.bounds.maxX-A.bounds.maxX)<.5&&Math.abs(t.bounds.minY-A.bounds.minY)<.5&&Math.abs(t.bounds.maxY-A.bounds.maxY)<.5&&Math.abs(t.rect.left-A.rect.left)<.5&&Math.abs(t.rect.top-A.rect.top)<.5&&Math.abs(t.rect.width-A.rect.width)<.5&&Math.abs(t.rect.height-A.rect.height)<.5,iXt=({portId:t,portLabel:A,svgDivRef:e,containerRef:i,onPortClick:n,onHoverChange:o,showOutline:s,circuitJsonKey:r})=>{const[a,g]=V.useState(null),c=V.useRef(null),I=V.useCallback(()=>{c.current=null;const E=e.current,u=i.current;if(!E||!u){g(S=>S&&null);return}const d=E.querySelector(`[data-schematic-port-id="${t}"]`);if(!d){g(S=>S&&null);return}const f=d.getBoundingClientRect(),m=u.getBoundingClientRect(),w=4,D={bounds:{minX:f.left-w,maxX:f.right+w,minY:f.top-w,maxY:f.bottom+w},rect:{left:f.left-m.left-w,top:f.top-m.top-w,width:f.width+w*2,height:f.height+w*2}};g(S=>tXt(S,D)?S:D)},[t,i,e]),l=V.useCallback(()=>{c.current===null&&(c.current=window.requestAnimationFrame(I))},[I]);V.useEffect(()=>{l()},[l,r]),V.useEffect(()=>{l();const E=e.current,u=i.current;if(!E||!u)return;const d=typeof ResizeObserver<"u"?new ResizeObserver(()=>{l()}):null;d?.observe(u),d?.observe(E);const f=typeof MutationObserver<"u"?new MutationObserver(()=>{l()}):null;return f?.observe(E,{attributes:!0,attributeFilter:["style","transform"],subtree:!0,childList:!0}),window.addEventListener("scroll",l,!0),window.addEventListener("resize",l),()=>{d?.disconnect(),f?.disconnect(),window.removeEventListener("scroll",l,!0),window.removeEventListener("resize",l),c.current!==null&&(cancelAnimationFrame(c.current),c.current=null)}},[l,e,i]);const B=V.useCallback(E=>{n&&n(t,E)},[t,n]),C=a?.bounds??null,{hovering:Q}=tle({bounds:C,onClick:n?B:void 0});if(V.useEffect(()=>{o&&o(t,Q)},[Q,t,o]),!a||!s)return null;const h=a.rect;return W.jsxs(W.Fragment,{children:[W.jsx("div",{style:{position:"absolute",left:h.left,top:h.top,width:h.width,height:h.height,border:Q?"1.5px solid rgba(255, 153, 51, 0.9)":"1.5px solid rgba(255, 153, 51, 0.3)",backgroundColor:Q?"rgba(255, 153, 51, 0.15)":"rgba(255, 153, 51, 0.05)",borderRadius:"50%",pointerEvents:"none",zIndex:hS.schematicPortHoverOutline,transition:"border-color 0.15s, background-color 0.15s"}}),Q&&A&&W.jsx("div",{style:{position:"absolute",left:h.left+h.width/2,top:h.top-24,transform:"translateX(-50%)",backgroundColor:"rgba(0, 0, 0, 0.85)",color:"white",padding:"4px 8px",borderRadius:"4px",fontSize:"12px",fontFamily:"monospace",whiteSpace:"nowrap",pointerEvents:"none",zIndex:hS.schematicPortHoverOutline+1},children:A})]})},nXt=({circuitJson:t,containerStyle:A,editEvents:e=[],onEditEvent:i,defaultEditMode:n=!1,debugGrid:o=!1,editingEnabled:s=!1,debug:r=!1,clickToInteractEnabled:a=!1,colorOverrides:g,spiceSimulationEnabled:c=!1,disableGroups:I=!1,onSchematicComponentClicked:l,showSchematicPorts:B=!1,onSchematicPortClicked:C})=>{r&&vzt();const[Q,h]=V.useState(!1),[E,u]=V.useState({showVoltage:!0,showCurrent:!1,startTime:0,duration:20}),d=EA=>`${EA?.length||0}_${EA?.editCount||0}`,f=V.useMemo(()=>d(t),[t]),m=V.useMemo(()=>{if(!c)return null;try{return Zzt(t,E)}catch(EA){return console.error("Failed to generate SPICE string",EA),null}},[f,c,E.startTime,E.duration]),[w,D]=V.useState(!1);V.useEffect(()=>{D(!1)},[f]);const{plotData:S,nodes:_,isLoading:b,error:N}=Wzt(w?m:null),[F,L]=V.useState(n),[Y,J]=V.useState(!0),[q,Z]=V.useState(!1),X=o||q,[eA,gA]=V.useState(!a),[iA,tA]=V.useState(!1),[sA,aA]=V.useState(()=>I?!1:Vzt("schematic_viewer_show_groups",!1)),[hA,bA]=V.useState(!1),_A=V.useRef(new Set),HA=V.useCallback((EA,oe)=>{oe?_A.current.add(EA):_A.current.delete(EA),bA(_A.current.size>0)},[]),[QA,xA]=V.useState(!1),dA=V.useRef(new Set),qA=V.useCallback((EA,oe)=>{oe?dA.current.add(EA):dA.current.delete(EA),xA(dA.current.size>0)},[]),VA=V.useRef(null),ce=V.useRef(null),fA=V.useMemo(()=>{try{return YE(t).schematic_component?.list()?.map(EA=>EA.schematic_component_id)??[]}catch(EA){return console.error("Failed to derive schematic component ids",EA),[]}},[f,t]),ge=V.useMemo(()=>{if(!B)return[];try{return(YE(t).schematic_port?.list()??[]).map(oe=>{const Be=YE(t).source_port.get(oe.source_port_id),Le=(Be?.source_component_id?YE(t).source_component.get(Be.source_component_id):null)?.name??"?",Te=oe.display_pin_label??Be?.pin_number??Be?.name??"?";return{portId:oe.source_port_id,label:`${Le}.${Te}`}})}catch(EA){return console.error("Failed to derive schematic port info",EA),[]}},[f,t,B]),TA=EA=>{const oe=EA.touches[0];ce.current={x:oe.clientX,y:oe.clientY}},YA=EA=>{const oe=EA.changedTouches[0],Be=ce.current;if(!Be)return;const ye=Math.abs(oe.clientX-Be.x),Le=Math.abs(oe.clientY-Be.y);ye<10&&Le<10&&(EA.preventDefault(),gA(!0)),ce.current=null},[jA,kA]=V.useState([]),wA=V.useRef(t);V.useEffect(()=>{const EA=d(t),oe=d(wA.current);EA!==oe&&(kA([]),wA.current=t)},[t]);const{ref:GA,cancelDrag:MA,transform:KA}=cT({onSetTransform(EA){VA.current&&(VA.current.style.transform=zd(EA))},enabled:eA&&!Q}),{containerWidth:ZA,containerHeight:ne}=Ale(GA),SA=V.useMemo(()=>!ZA||!ne?"":uj(t,{width:ZA,height:ne||720,grid:X?{cellSize:1,labelCells:!0}:void 0,colorOverrides:g}),[f,ZA,ne,X]),CA=V.useMemo(()=>SA.match(/<svg[^>]*style="[^"]*background-color:\s*([^;\"]+)/i)?.[1]??"transparent",[SA]),uA=V.useMemo(()=>{if(!SA)return xa();const EA=SA.match(/data-real-to-screen-transform="([^"]+)"/)?.[1];try{return Oq(EA)}catch(oe){return console.error(oe),xa()}},[SA]),PA=EA=>{kA(oe=>[...oe,EA]),i&&i(EA)},re=V.useMemo(()=>[...e,...jA],[e,jA]),{handleMouseDown:Qe,handleTouchStart:me,isDragging:_e,activeEditEvent:ke}=Rzt({onEditEvent:PA,cancelDrag:MA,realToSvgProjection:uA,svgToScreenProjection:KA,circuitJson:t,editEvents:re,enabled:F&&eA&&!Q,snapToGrid:Y});Szt({svgDivRef:VA,editEvents:re,realToSvgProjection:uA,svgToScreenProjection:KA,activeEditEvent:ke}),bzt({svgDivRef:VA,circuitJson:t,activeEditEvent:ke,editEvents:re}),xzt({svgDivRef:VA,circuitJson:t,circuitJsonKey:f,showGroups:sA&&!I});const Pe=V.useRef(me);V.useEffect(()=>{Pe.current=me},[me]);const lt=V.useMemo(()=>W.jsx("div",{ref:VA,style:{pointerEvents:a?eA?"auto":"none":"auto",transformOrigin:"0 0"},className:l?"schematic-component-clickable":void 0,onTouchStart:EA=>{F&&eA&&!Q&&Pe.current(EA)},dangerouslySetInnerHTML:{__html:SA}}),[SA,eA,a,F,Q]);return W.jsxs($zt,{children:[l&&W.jsx("style",{children:".schematic-component-clickable [data-schematic-component-id]:hover { cursor: pointer !important; }"}),C&&W.jsx("style",{children:"[data-schematic-port-id]:hover { cursor: pointer !important; }"}),W.jsxs("div",{ref:GA,style:{position:"relative",backgroundColor:CA,overflow:"hidden",cursor:Q?"auto":_e?"grabbing":a&&!eA||hA&&l||QA&&C?"pointer":"grab",minHeight:"300px",...A},onWheelCapture:EA=>{Q&&EA.stopPropagation()},onMouseDown:EA=>{if(a&&!eA){EA.preventDefault(),EA.stopPropagation();return}Qe(EA)},onMouseDownCapture:EA=>{if(a&&!eA){EA.preventDefault(),EA.stopPropagation();return}},onTouchStart:EA=>{Q||TA(EA)},onTouchEnd:EA=>{Q||YA(EA)},children:[!eA&&a&&W.jsx("div",{onClick:EA=>{EA.preventDefault(),EA.stopPropagation(),gA(!0)},style:{position:"absolute",inset:0,cursor:"pointer",zIndex:hS.clickToInteractOverlay,display:"flex",alignItems:"center",justifyContent:"center",pointerEvents:"all",touchAction:"pan-x pan-y pinch-zoom"},children:W.jsx("div",{style:{backgroundColor:"rgba(0, 0, 0, 0.8)",color:"white",padding:"12px 24px",borderRadius:"8px",fontSize:"16px",fontFamily:"sans-serif",pointerEvents:"none"},children:typeof window<"u"&&("ontouchstart"in window||navigator.maxTouchPoints>0)?"Touch to Interact":"Click to Interact"})}),W.jsx(Lzt,{active:iA,onClick:()=>tA(!iA)}),s&&W.jsx(Nzt,{active:F,onClick:()=>L(!F)}),s&&F&&W.jsx(Gzt,{active:Y,onClick:()=>J(!Y)}),W.jsx(Hzt,{circuitJson:t,circuitJsonKey:f,isVisible:iA,onClose:()=>tA(!1),showGroups:sA,onToggleGroups:EA=>{I||(aA(EA),jzt("schematic_viewer_show_groups",EA))},showGrid:X,onToggleGrid:Z}),c&&W.jsx(Jzt,{onClick:()=>h(!0)}),Q&&W.jsx(Pzt,{spiceString:m,onClose:()=>h(!1),plotData:S,nodes:_,isLoading:b,error:N,simOptions:E,onSimOptionsChange:EA=>{D(!0),u(EA)},hasRun:w}),l&&fA.map(EA=>W.jsx(eXt,{componentId:EA,svgDivRef:VA,containerRef:GA,showOutline:!0,circuitJsonKey:f,onHoverChange:HA,onComponentClick:(oe,Be)=>{l?.({schematicComponentId:oe,event:Be})}},EA)),lt,B&&ge.map(({portId:EA,label:oe})=>W.jsx(iXt,{portId:EA,portLabel:oe,svgDivRef:VA,containerRef:GA,showOutline:!0,circuitJsonKey:f,onHoverChange:qA,onPortClick:C?(Be,ye)=>{C?.({schematicPortId:Be,event:ye})}:void 0},EA))]})]})},oXt=({circuitJson:t,containerStyle:A,colorOverrides:e,width:i,height:n,className:o})=>{const[s,r]=V.useState(null),[a,g]=V.useState(!0),[c,I]=V.useState(null),[l,B]=V.useState(null),C=V.useRef(null),Q=V.useRef(null),{containerWidth:h,containerHeight:E}=Ale(C),[u,d]=V.useState(!1),{ref:f}=cT({onSetTransform(L){Q.current&&(Q.current.style.transform=zd(L))}}),m=i||h||1e3,w=n||E||600;V.useEffect(()=>{g(!0),I(null),r(t),g(!1)},[t]);const D=V.useMemo(()=>s&&s.find(Y=>Y.type==="simulation_experiment")?.simulation_experiment_id||null,[s]),S=V.useMemo(()=>s?s.filter(L=>L.type==="simulation_transient_voltage_graph").map(L=>L.simulation_transient_voltage_graph_id):[],[s]),_=V.useMemo(()=>{if(!s||!m||!w||!D)return"";try{return Oge({circuitJson:s,simulation_experiment_id:D,simulation_transient_voltage_graph_ids:S,width:m,height:w,schematicOptions:{colorOverrides:e}})}catch(L){return console.error("Failed to generate fallback schematic SVG:",L),""}},[s,m,w,e,D,S]);V.useEffect(()=>{if(!_){B(null);return}try{const L=new Blob([_],{type:"image/svg+xml"}),Y=URL.createObjectURL(L);return B(Y),()=>{URL.revokeObjectURL(Y)}}catch(L){console.error("Failed to create SVG object URL:",L),B(null)}},[_]);const b=V.useMemo(()=>_?_.match(/<svg[^>]*style="[^"]*background-color:\s*([^;\"]+)/i)?.[1]??"transparent":"transparent",[_]),N=L=>{d(!0)},F=L=>{d(!0)};return V.useEffect(()=>{const L=()=>{d(!1)},Y=()=>{d(!1)};return window.addEventListener("mouseup",L),window.addEventListener("touchend",Y),()=>{window.removeEventListener("mouseup",L),window.removeEventListener("touchend",Y)}},[]),a?W.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:"#f5f5f5",minHeight:"300px",fontFamily:"sans-serif",fontSize:"16px",color:"#666",...A},className:o,children:"Loading circuit..."}):c?W.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:"#fef2f2",minHeight:"300px",fontFamily:"sans-serif",fontSize:"16px",color:"#dc2626",...A},className:o,children:W.jsxs("div",{style:{textAlign:"center",padding:"20px"},children:[W.jsx("div",{style:{fontWeight:"bold",marginBottom:"8px"},children:"Circuit Conversion Error"}),W.jsx("div",{style:{fontSize:"14px"},children:c})]})}):_?W.jsx("div",{ref:L=>{C.current=L,f.current=L},style:{position:"relative",backgroundColor:b,overflow:"hidden",minHeight:"300px",cursor:u?"grabbing":"grab",...A},className:o,onMouseDown:N,onTouchStart:F,children:l?W.jsx("img",{ref:Q,src:l,alt:"Circuit Simulation",style:{transformOrigin:"0 0",width:"100%",height:"100%",display:"block",objectFit:"contain"}}):W.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",height:"100%",minHeight:"300px",color:"#666",fontFamily:"sans-serif"},children:"Failed to render SVG"})}):W.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",backgroundColor:"#f8fafc",minHeight:"300px",fontFamily:"sans-serif",gap:"12px",...A},className:o,children:[W.jsx("div",{style:{fontSize:"16px",color:"#475569",fontWeight:500},children:"No Simulation Found"}),W.jsxs("div",{style:{fontSize:"14px",color:"#64748b"},children:["Use"," ",W.jsx("code",{style:{backgroundColor:"#e2e8f0",padding:"2px 6px",borderRadius:"4px",fontFamily:"monospace",fontSize:"13px"},children:"<analogsimulation />"})," ","to create simulations"]})]})},ile=t=>{const[A,e]=V.useState(0),[i,n]=V.useState(0);return V.useEffect(()=>{if(!t.current)return;const o=()=>{const r=t.current?.getBoundingClientRect();e(r?.width||0),n(r?.height||0)};o();const s=new ResizeObserver(o);return s.observe(t.current),window.addEventListener("resize",o),()=>{s.disconnect(),window.removeEventListener("resize",o)}},[]),{containerWidth:A,containerHeight:i}};ba("assembly-viewer");var nle=()=>{ba.enable("assembly-viewer*")},sXt=({circuitJson:t,containerStyle:A,debugGrid:e=!1,debug:i=!1})=>{i&&nle();const n=V.useRef(null),{ref:o}=cT({onSetTransform(c){n.current&&(n.current.style.transform=zd(c))}}),{containerWidth:s,containerHeight:r}=ile(o),a=V.useMemo(()=>!s||!r?"":yge(t,{width:s,height:r||720}),[t,s,r]);V.useMemo(()=>{if(!a)return xa();const c=a.match(/data-real-to-screen-transform="([^"]+)"/)?.[1];try{return Oq(c)}catch(I){return console.error(I),xa()}},[a]);const g=V.useMemo(()=>W.jsx("div",{ref:n,style:{pointerEvents:"auto",transformOrigin:"0 0"},dangerouslySetInnerHTML:{__html:a}}),[a]);return W.jsx("div",{ref:o,style:{position:"relative",backgroundColor:"#FFFFFF",overflow:"hidden",minHeight:"300px",...A},children:g})},rXt=({circuitJson:t,containerStyle:A,debugGrid:e=!1,debug:i=!1})=>{i&&nle();const n=V.useRef(null),{ref:o}=cT({onSetTransform(c){n.current&&(n.current.style.transform=zd(c))}}),{containerWidth:s,containerHeight:r}=ile(o),a=V.useMemo(()=>!s||!r?"":f0A(t,{width:s,height:r||720}),[t,s,r]);V.useMemo(()=>{if(!a)return xa();const c=a.match(/data-real-to-screen-transform="([^"]+)"/)?.[1];try{return Oq(c)}catch(I){return console.error(I),xa()}},[a]);const g=V.useMemo(()=>W.jsx("div",{ref:n,style:{pointerEvents:"auto",transformOrigin:"0 0"},dangerouslySetInnerHTML:{__html:a}}),[a]);return W.jsx("div",{ref:o,style:{position:"relative",backgroundColor:"#FFFFFF",overflow:"hidden",minHeight:"300px",...A},children:g})};const ole=["Initialize a tscircuit project using [tsci init](https://github.com/tscircuit/cli) before adding components.","Define reusable modules with cached routes using [<subcircuit />](https://docs.tscircuit.com/elements/subcircuit)","Run `tsci dev` on the command line to preview your boards before export",'Use units like mm or mils consistently across your designs (e.g. pcbX="10mm")',"Quickly set footprints with the [footprint prop](https://docs.tscircuit.com/footprints/footprinter-strings)","Check out the guide on [ordering prototypes](https://docs.tscircuit.com/building-electronics/ordering-prototypes)","Use [net labels](https://docs.tscircuit.com/elements/net) and [group elements](https://docs.tscircuit.com/elements/group) to organize complex schematics.","You can manually drag components on the PCB and Schematic using [manual edits](https://docs.tscircuit.com/guides/manual-edits)","Every tscircuit module can export to [Circuit JSON](https://github.com/tscircuit/circuit-json), Gerbers, Pick'n'Place CSV files, Bill of Materials CSV and more","You can import components from [JLCPCB](https://docs.tscircuit.com/guides/importing-modules-and-chips/importing-from-jlcpcb) or [KiCad](https://docs.tscircuit.com/guides/importing-modules-and-chips/importing-from-kicad)","Any module you push to the [registry](https://tscircuit.com/trending) will have [simple image urls](https://docs.tscircuit.com/web-apis/image-generation-api) you can use display images on a website","The default [Parts Engine](https://docs.tscircuit.com/guides/platform-configuration) will automatically find parts from common vendors for your BOM",'[Pin selectors](https://docs.tscircuit.com/guides/using-sel-references) are similar to CSS selectors, ".R1 > .pin1" means "connect to the first pin of the component R1"',"You can use the [sel](https://docs.tscircuit.com/guides/using-sel-references) object to select pins in a type-safe way","Publish modules via the [registry](https://tscircuit.com/trending) for working with a team or sharing your work","[Explore tutorials](https://docs.tscircuit.com/category/tutorials) for real-world circuit design examples.","Upload your Circuit JSON to [circuitjson.com](https://circuitjson.com) for a quick preview.","You can display Circuit JSON in 3D, PCB or Schematic mode with the [<CircuitJsonPreview />](https://docs.tscircuit.com/guides/running-tscircuit/displaying-circuit-json-on-a-webpage#react-display-all-available-previews-with-circuitjsonpreview-) React component","Use a [<group />](https://docs.tscircuit.com/elements/group) element to move multiple components at once in a schematic or PCB layout.","Check out the [GitHub Discussions page](https://github.com/tscircuit/tscircuit/discussions) to upvote features","You can customize the autorouter using the [autorouter prop](https://docs.tscircuit.com/elements/board#setting-the-autorouter)","Use the [<constraint />](https://docs.tscircuit.com/footprints/constraint) element to enforce geometric relationships in PCB designs.","When working on component placement and circuit design, autorouting can slow down your iteration cycle. Use [routingDisabled](https://docs.tscircuit.com/elements/board#disabling-routing-with-routingdisabled) on the <board /> element to disable autorouting temporarily.","Join the [Discord server](https://tscircuit.com/join) to discuss issues and get help directly from the community."],aXt=(()=>{let t=ole[Math.floor(Math.random()*ole.length)];return t=t.replace(/</g,"&lt;"),t=t.replace(/>/g,"&gt;"),t=t.replace(new RegExp('(?<!href=")(?<!\\()(?<!\\]\\()(https?:\\/\\/[^\\s\\)\\]]+)',"g"),(A,e)=>`<a class="rf-text-blue-500 rf-underline" href="${A}" target="_blank">${A}</a>`),t=t.replace(/\[([^\]]+)\]\((https?:\/\/[^\)]+)\)/g,'<a class="rf-text-blue-500 rf-underline" href="$2" target="_blank">$1</a>'),t})(),ex=({onRunClicked:t})=>W.jsxs("div",{className:"rf-flex rf-flex-col rf-items-center rf-justify-center rf-h-full rf-bg-gray-50 rf-text-gray-500 rf-p-4",children:[W.jsx(zKt,{className:"rf-size-14 rf-mb-4"}),W.jsxs("p",{className:"rf-text-md rf-break-words rf-max-w-xl rf-text-center",children:["Tip: ",W.jsx("span",{dangerouslySetInnerHTML:{__html:aXt}})]}),t&&W.jsxs(Ta,{className:"rf-mt-4 rf-bg-blue-600 rf-hover:bg-blue-500",onClick:t,children:["Run Code",W.jsx(Xse,{className:"rf-w-3 rf-h-3 rf-ml-2"})]})]}),Zj=({text:t,onClick:A})=>W.jsx("span",{className:"rf-cursor-pointer rf-underline rf-text-blue-600 rf-mx-2",onClick:A,children:t}),Vj=t=>W.jsxs("div",{className:"rf-leading-5",children:[W.jsx("div",{className:"rf-py-2 rf-font-bold",children:t.column.name}),W.jsx("div",{children:t.field?.()??W.jsx("input",{type:"text",className:"rf-border rf-rounded rf-p-1 rf-w-full",onChange:A=>{t.onTextChange?.(A.target.value)}})})]}),gXt=({open:t,children:A,title:e,onClose:i})=>t?W.jsx("div",{className:"rf-fixed rf-inset-0 rf-bg-black rf-bg-opacity-50 rf-flex rf-justify-center rf-items-center rf-z-50",onClick:i,children:W.jsxs("div",{className:"rf-bg-white rf-p-5 rf-rounded-lg rf-relative rf-w-11/12 rf-max-w-2xl",onClick:n=>{n.preventDefault(),n.stopPropagation()},children:[W.jsx("h2",{className:"rf-mt-0 rf-text-md rf-pb-4",children:e}),W.jsx("button",{type:"button",className:"rf-absolute rf-top-2 rf-right-4 rf-text-2xl rf-font-bold",onClick:i,children:"×"}),A]})}):null,cXt=({elements:t})=>{const[A,e]=V.useState({open:!1}),[i,n]=V.useReducer((c,I)=>({...c,...I}),{}),o=[...new Set(t.map(c=>c.type))],s=t.map(c=>{const I=c[`${c.type}_id`],l=Object.fromEntries(Object.entries(c).filter(([C])=>!(C===`${c.type}_id`||!C.endsWith("_id")))),B=Object.fromEntries(Object.entries(c).filter(([C])=>!C.endsWith("_id")));return{primary_id:I,other_ids:l,...B,_og_elm:c}}),r=s.map(c=>{let I="";const l=B=>{const C=Object.keys(B.other_ids).find(E=>E.startsWith("source_"));if(!C)return`.${B.name}`;const Q=C.slice(0,-3),h=s.find(E=>E.type===Q&&E.primary_id===B.other_ids[C]);return h?"name"in h?`${l(h)} > .${B.name}`:`#${h.primary_id} > .${B.name}`:`??? > .${B.name}`};return"name"in c&&(I=l(c)),{...c,selector_path:I}}),a=[{key:"primary_id",name:"primary_id",renderCell:c=>W.jsxs("div",{className:"rf-flex rf-items-center",children:[W.jsx(Zj,{text:c.primary_id,onClick:()=>n({focused_id:c.primary_id,id_search:void 0,selector_search:void 0})}),W.jsx("span",{className:"rf-flex-grow"}),W.jsx(Zj,{text:"(JSON)",onClick:()=>e({open:!0,element:c._og_elm,title:c.primary_id})})]}),renderHeaderCell:c=>W.jsx(Vj,{column:c,onTextChange:I=>n({id_search:I}),field:i.focused_id?()=>W.jsxs("div",{children:["Focus:"," ",W.jsx("span",{className:"rf-underline",children:i.focused_id}),W.jsx(Zj,{text:"(unfocus)",onClick:()=>n({focused_id:void 0})})]}):void 0})},{key:"type",name:"type",renderHeaderCell:c=>W.jsx(Vj,{column:c,field:()=>W.jsxs("select",{onChange:I=>n({component_type_filter:I.target.value}),className:"rf-border rf-rounded rf-p-1 rf-w-full",children:[W.jsx("option",{value:"any",children:"any"},"any"),W.jsx("option",{value:"source",children:"source"},"source"),W.jsx("option",{value:"source/pcb",children:"source/pcb"},"source/pcb"),W.jsx("option",{value:"source/schematic",children:"source/schematic"},"source/schematic"),o.map(I=>W.jsx("option",{value:I,children:I},I))]})})},{key:"name",name:"name",renderHeaderCell:c=>W.jsx(Vj,{column:c,onTextChange:I=>n({name_search:I})})},{key:"selector_path",name:"selector_path",renderHeaderCell:c=>W.jsx(Vj,{column:c,onTextChange:I=>n({selector_search:I})})},{key:"other_ids",name:"other_ids",renderCell:c=>W.jsx("div",{className:"rf-space-x-2",children:Object.entries(c.other_ids).map(([I,l])=>W.jsx(Zj,{text:l,onClick:()=>n({focused_id:l})},l))})}],g=r.filter(c=>i.name_search?c.name?.toLowerCase()?.includes(i.name_search.toLowerCase()):!0).filter(c=>!i.component_type_filter||i.component_type_filter==="any"?!0:i.component_type_filter==="source"?c.type.startsWith("source_"):i.component_type_filter==="source/pcb"?c.type.startsWith("source_")||c.type.startsWith("pcb_"):i.component_type_filter==="source/schematic"?c.type.startsWith("source_")||c.type.startsWith("schematic_"):c.type?.includes(i.component_type_filter)).filter(c=>i.selector_search?i.selector_search.split(" ").filter(l=>l.length>0).every(l=>c.selector_path?.includes(l)):!0).filter(c=>i.id_search?c.primary_id?.includes(i.id_search):!0).filter(c=>!!(!i.focused_id||c.primary_id===i.focused_id||Object.values(c.other_ids).includes(i.focused_id)));return W.jsxs("div",{className:"rf-font-mono rf-text-xs rf-bg-white",children:[W.jsx("div",{className:"rf-overflow-x-auto",children:W.jsxs("table",{className:"rf-table-auto rf-w-full rf-text-left",children:[W.jsx("thead",{children:W.jsx("tr",{children:a.map(c=>W.jsx("th",{className:"rf-px-4 rf-py-2 rf-border-b",children:c.renderHeaderCell?c.renderHeaderCell(c):c.name},c.key))})}),W.jsx("tbody",{children:g.map((c,I)=>W.jsx("tr",{className:"rf-hover:bg-gray-100",children:a.map(l=>W.jsx("td",{className:"rf-px-4 rf-py-2 rf-border-b",children:l.renderCell?l.renderCell(c):c[l.key]},l.key))},I))})]})}),W.jsx(gXt,{open:A.open,onClose:()=>e({open:!1}),title:A.open?A.title:"",children:W.jsx("div",{className:"rf-bg-gray-800 rf-p-3 rf-text-white rf-rounded",children:W.jsx("pre",{className:"rf-whitespace-pre-wrap",children:A.open?JSON.stringify(A.element,null,2):""})})})]})},IXt=(t,A)=>t==="jlcpcb"?W.jsx("a",{className:"rf-underline rf-text-blue-500",target:"_blank",rel:"noreferrer",href:`https://jlcpcb.com/partdetail/${A}`,children:A}):A,lXt=({circuitJson:t})=>{const A=t.filter(i=>i.type==="source_component"),e=new Set;for(const i of A)if(i.supplier_part_numbers)for(const n of Object.keys(i.supplier_part_numbers))e.add(n);return W.jsx("div",{className:"rf-overflow-x-auto",children:W.jsxs("table",{className:"rf-w-full rf-text-left rf-text-sm",children:[W.jsx("thead",{children:W.jsxs("tr",{className:"rf-border-b",children:[W.jsx("th",{className:"rf-p-2",children:"Name"}),Array.from(e).map(i=>W.jsx("th",{className:"rf-p-2 rf-capitalize",children:i},i))]})}),W.jsx("tbody",{children:A.map(i=>W.jsxs("tr",{className:"rf-border-b",children:[W.jsx("td",{className:"rf-p-2",children:i.name}),Array.from(e).map(n=>W.jsx("td",{className:"rf-p-2",children:IXt(n,i.supplier_part_numbers?.[n]?.[0]||"")},n))]},i.source_component_id))})]})})},ryA=V.forwardRef(({className:t,type:A,...e},i)=>W.jsx("input",{type:A,className:Qn("rf-flex rf-h-9 rf-w-full rf-rounded-md rf-border rf-border-zinc-200 rf-bg-white rf-px-3 rf-py-1 rf-text-sm rf-shadow-sm rf-transition-colors file:rf-border-0 file:rf-bg-transparent file:rf-text-sm file:rf-font-medium placeholder:rf-text-zinc-500 focus-visible:rf-outline-none focus-visible:rf-ring-1 focus-visible:rf-ring-zinc-950 disabled:rf-cursor-not-allowed disabled:rf-opacity-50 dark:rf-border-zinc-800 dark:rf-bg-zinc-950 dark:rf-placeholder-zinc-400 dark:focus-visible:rf-ring-zinc-300",t),ref:i,...e}));ryA.displayName="Input";var sle={Hz:{baseUnit:"Hz",variants:{MHz:1e6,kHz:1e3,Hz:1}},g:{baseUnit:"g",variants:{kg:1e3,g:1}},Ω:{baseUnit:"Ω",variants:{mΩ:.001,Ω:1,kΩ:1e3,KΩ:1e3,kohm:1e3,MΩ:1e6,GΩ:1e9,TΩ:1e12}},V:{baseUnit:"V",variants:{mV:.001,V:1,kV:1e3,KV:1e3,MV:1e6,GV:1e9,TV:1e12}},A:{baseUnit:"A",variants:{µA:1e-6,mA:.001,ma:.001,A:1,kA:1e3,MA:1e6}},F:{baseUnit:"F",variants:{pF:1e-12,nF:1e-9,µF:1e-6,uF:1e-6,mF:.001,F:1}},ml:{baseUnit:"ml",variants:{ml:1,mL:1,l:1e3,L:1e3}},deg:{baseUnit:"deg",variants:{rad:180/Math.PI}},ms:{baseUnit:"ms",variants:{fs:1e-12,ps:1e-9,ns:1e-6,us:.001,µs:.001,ms:1,s:1e3}},mm:{baseUnit:"mm",variants:{nm:1e-6,µm:.001,um:.001,mm:1,cm:10,dm:100,m:1e3,km:1e6,in:25.4,ft:304.8,IN:25.4,FT:304.8,yd:914.4,mi:1609344,mil:.0254}}},ayA=new Set;for(const[t,A]of Object.entries(sle)){ayA.add(t);for(const e of Object.keys(A.variants))ayA.add(e)}function BXt(t){for(const[A,e]of Object.entries(sle))if(t in e.variants)return{baseUnit:e.baseUnit,conversionFactor:e.variants[t]};return{baseUnit:t,conversionFactor:1}}var rle={tera:1e12,T:1e12,giga:1e9,G:1e9,mega:1e6,M:1e6,kilo:1e3,k:1e3,deci:.1,d:.1,centi:.01,c:.01,milli:.001,m:.001,micro:1e-6,u:1e-6,µ:1e-6,nano:1e-9,n:1e-9,pico:1e-12,p:1e-12};function Jw(t){if(t==null)return{parsedUnit:null,unitOfValue:null,value:null};if(typeof t=="string"&&t.match(/^-?[\d\.]+$/))return{value:Number.parseFloat(t),parsedUnit:null,unitOfValue:null};if(typeof t=="number")return{value:t,parsedUnit:null,unitOfValue:null};if(typeof t=="object"&&"x"in t&&"y"in t){const{parsedUnit:r,unitOfValue:a}=Jw(t.x),g=Jw(t.x),c=Jw(t.y);return g.value===null||c.value===null?{parsedUnit:null,unitOfValue:null,value:null}:{parsedUnit:r,unitOfValue:a,value:{x:g.value,y:c.value}}}const e=t.toString().split("").reverse().join("").match(/[^\d\s]+/)?.[0];if(!e)throw new Error(`Could not determine unit: "${t}"`);const i=e.split("").reverse().join(""),n=t.slice(0,-i.length);if(i in rle&&!ayA.has(i)){const r=rle[i];return{parsedUnit:null,unitOfValue:null,value:Number.parseFloat(n)*r}}const{baseUnit:o,conversionFactor:s}=BXt(i);return{parsedUnit:i,unitOfValue:o,value:s*Number.parseFloat(n)}}var jj=H().or(WA()).transform(t=>Jw(t).value),gyA=H().or(WA()).transform(t=>Jw(t).value).transform(t=>Number.parseFloat(t.toPrecision(12))),ale=H().or(WA()).transform(t=>Jw(t).value),tx=H().or(WA()).transform(t=>Jw(t).value),rn=H().or(WA()).transform(t=>Jw(t).value),FM=H().or(WA()).transform(t=>Jw(t).value),Et=rn,h2=H().or(WA()).transform(t=>Jw(t).value),vT=H().or(WA()).transform(t=>Jw(t).value),CXt=vT,MM=vT,gle=H().datetime(),AQ=H().or(WA()).transform(t=>typeof t=="number"?t:t.endsWith("deg")?Number.parseFloat(t.split("deg")[0]):t.endsWith("rad")?Number.parseFloat(t.split("rad")[0])*180/Math.PI:Number.parseFloat(t)),cle=WA().or(H().endsWith("mAh")).transform(t=>{if(typeof t=="string"){const A=t.replace("mAh",""),e=Number.parseFloat(A);if(Number.isNaN(e))throw new Error("Invalid capacity");return e}return t}).describe("Battery capacity in mAh"),fn=te({x:Et,y:Et}),QXt=fn,Nk=te({x:Et,y:Et,z:Et}),hXt=Nk,cyA=te({width:WA(),height:WA()}),EXt=t=>{const A="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";return Array.from({length:t},()=>A[Math.floor(Math.random()*A.length)]).join("")},Xt=t=>H().optional().default(()=>`${t}_${EXt(10)}`),Gk=et(["top_left","top_center","top_right","center_left","center","center_right","bottom_left","bottom_center","bottom_right"]),uXt=et(["top_silkscreen","bottom_silkscreen","top_copper","bottom_copper","top_soldermask","bottom_soldermask","top_fabrication_note","bottom_fabrication_note","top_user_note","bottom_user_note","top_courtyard","bottom_courtyard","inner1_copper","inner2_copper","inner3_copper","inner4_copper","inner5_copper","inner6_copper","edge_cuts","drill"]),Ile=te({project_relative_path:H(),url:H(),mimetype:H()}),zj=fn.extend({rotation:AQ.optional()}),IyA=te({size:fn.optional(),thickness:Et.optional()}),lle=te({font:IyA.optional()}),FT=te({value:H(),at:zj.optional(),layer:H().optional(),uuid:H().optional(),hide:OA().optional(),effects:lle.optional()}),Ble=te({Reference:FT.optional(),Value:FT.optional(),Datasheet:FT.optional(),Description:FT.optional()}),Cle=te({through_hole:OA().optional(),smd:OA().optional(),exclude_from_pos_files:OA().optional(),exclude_from_bom:OA().optional()}),Qle=te({name:H(),type:H(),shape:H().optional(),at:zj.optional(),size:fn.optional(),drill:Et.optional(),layers:be(H()).optional(),removeUnusedLayers:OA().optional(),uuid:H().optional()}),hle=te({path:H(),offset:Nk.optional(),scale:Nk.optional(),rotate:Nk.optional()}),Ele=te({footprintName:H().optional(),version:Nt([WA(),H()]).optional(),generator:H().optional(),generatorVersion:Nt([WA(),H()]).optional(),layer:H().optional(),properties:Ble.optional(),attributes:Cle.optional(),pads:be(Qle).optional(),embeddedFonts:OA().optional(),model:hle.optional()}),ule=te({hide:OA().optional()}),dle=te({offset:Et.optional(),hide:OA().optional()}),ple=te({font:IyA.optional(),justify:Nt([H(),be(H())]).optional(),hide:OA().optional()}),Lk=te({value:H(),id:Nt([WA(),H()]).optional(),at:zj.optional(),effects:ple.optional()}),fle=te({Reference:Lk.optional(),Value:Lk.optional(),Footprint:Lk.optional(),Datasheet:Lk.optional(),Description:Lk.optional(),ki_keywords:Lk.optional(),ki_fp_filters:Lk.optional()}),yle=te({symbolName:H().optional(),extends:H().optional(),pinNumbers:ule.optional(),pinNames:dle.optional(),excludeFromSim:OA().optional(),inBom:OA().optional(),onBoard:OA().optional(),properties:fle.optional(),embeddedFonts:OA().optional()}),JI=te({error_type:H(),message:H(),is_fatal:OA().optional()}),mle=et(["jlcpcb","macrofab","pcbway","digikey","mouser","lcsc"]),sI=te({type:vA("source_component"),ftype:H().optional(),source_component_id:H(),name:H(),manufacturer_part_number:H().optional(),supplier_part_numbers:Sa(mle,be(H())).optional(),display_value:H().optional(),display_name:H().optional(),are_pins_interchangeable:OA().optional(),internally_connected_source_port_ids:be(be(H())).optional(),source_group_id:H().optional(),subcircuit_id:H().optional()}),lyA=sI.extend({ftype:vA("simple_capacitor"),capacitance:gyA,max_voltage_rating:tx.optional(),display_capacitance:H().optional(),max_decoupling_trace_length:Et.optional()}),ByA=sI.extend({ftype:vA("simple_resistor"),resistance:jj,display_resistance:H().optional()}),Xj=sI.extend({ftype:vA("simple_diode")}),wle=sI.extend({ftype:vA("simple_fiducial")}),CyA=Xj.extend({ftype:vA("simple_led"),color:H().optional(),wavelength:H().optional()}),Dle=sI.extend({ftype:vA("simple_ground")}),QyA=sI.extend({ftype:vA("simple_chip")}),hyA=sI.extend({ftype:vA("simple_power_source"),voltage:tx}),Sle=sI.extend({ftype:vA("simple_current_source"),current:h2,frequency:FM.optional(),peak_to_peak_current:h2.optional(),wave_shape:et(["sine","square","triangle","sawtooth","dc"]).optional().default("dc"),phase:WA().optional(),duty_cycle:WA().min(0).max(1).optional()}),dXt=sI.extend({ftype:vA("simple_fuse"),current_rating_amps:WA().describe("Nominal current in amps the fuse is rated for"),voltage_rating_volts:WA().describe("Voltage rating in volts, e.g. ±5V would be 5")}),EyA=sI.extend({ftype:vA("simple_battery"),capacity:cle}),uyA=sI.extend({ftype:vA("simple_inductor"),inductance:ale,max_current_rating:WA().optional()}),dyA=sI.extend({ftype:vA("simple_push_button")}),pyA=sI.extend({ftype:vA("simple_potentiometer"),max_resistance:jj,display_max_resistance:H().optional()}),ble=sI.extend({ftype:vA("simple_crystal"),frequency:WA().describe("Frequency in Hz"),load_capacitance:WA().optional().describe("Load capacitance in pF"),pin_variant:et(["two_pin","four_pin"]).optional()}),fyA=sI.extend({ftype:vA("simple_pin_header"),pin_count:WA(),gender:et(["male","female"]).optional().default("male")}),yyA=sI.extend({ftype:vA("simple_pinout")}),myA=sI.extend({ftype:vA("simple_resonator"),load_capacitance:gyA,equivalent_series_resistance:jj.optional(),frequency:FM}),wyA=sI.extend({ftype:vA("simple_transistor"),transistor_type:et(["npn","pnp"])}),DyA=sI.extend({ftype:vA("simple_test_point"),footprint_variant:et(["pad","through_hole"]).optional(),pad_shape:et(["rect","circle"]).optional(),pad_diameter:Nt([WA(),H()]).optional(),hole_diameter:Nt([WA(),H()]).optional(),width:Nt([WA(),H()]).optional(),height:Nt([WA(),H()]).optional()}),SyA=sI.extend({ftype:vA("simple_mosfet"),channel_type:et(["n","p"]),mosfet_mode:et(["enhancement","depletion"])}),byA=sI.extend({ftype:vA("simple_op_amp")}),xyA=sI.extend({ftype:vA("simple_switch")}),_yA=te({type:vA("source_project_metadata"),name:H().optional(),software_used_string:H().optional(),project_url:H().optional(),created_at:gle.optional()}),xle=JI.extend({type:vA("source_missing_property_error"),source_missing_property_error_id:Xt("source_missing_property_error"),source_component_id:H(),property_name:H(),subcircuit_id:H().optional(),error_type:vA("source_missing_property_error").default("source_missing_property_error")}).describe("The source code is missing a property"),_le=JI.extend({type:vA("source_failed_to_create_component_error"),source_failed_to_create_component_error_id:Xt("source_failed_to_create_component_error"),error_type:vA("source_failed_to_create_component_error").default("source_failed_to_create_component_error"),component_name:H().optional(),subcircuit_id:H().optional(),parent_source_component_id:H().optional(),pcb_center:te({x:WA().optional(),y:WA().optional()}).optional(),schematic_center:te({x:WA().optional(),y:WA().optional()}).optional()}).describe("Error emitted when a component fails to be constructed"),kyA=JI.extend({type:vA("source_trace_not_connected_error"),source_trace_not_connected_error_id:Xt("source_trace_not_connected_error"),error_type:vA("source_trace_not_connected_error").default("source_trace_not_connected_error"),subcircuit_id:H().optional(),source_group_id:H().optional(),source_trace_id:H().optional(),connected_source_port_ids:be(H()).optional(),selectors_not_found:be(H()).optional()}).describe("Occurs when a source trace selector does not match any ports"),kle=te({type:vA("source_property_ignored_warning"),source_property_ignored_warning_id:Xt("source_property_ignored_warning"),source_component_id:H(),property_name:H(),subcircuit_id:H().optional(),error_type:vA("source_property_ignored_warning").default("source_property_ignored_warning"),message:H()}).describe("The source property was ignored"),vyA=te({type:vA("source_pin_missing_trace_warning"),source_pin_missing_trace_warning_id:Xt("source_pin_missing_trace_warning"),warning_type:vA("source_pin_missing_trace_warning").default("source_pin_missing_trace_warning"),message:H(),source_component_id:H(),source_port_id:H(),subcircuit_id:H().optional()}).describe("Warning emitted when a source component pin is missing a trace connection"),vle=sI.extend({ftype:vA("simple_voltage_probe")}),Fle=sI.extend({ftype:vA("interconnect")}),FyA=JI.extend({type:vA("source_i2c_misconfigured_error"),source_i2c_misconfigured_error_id:Xt("source_i2c_misconfigured_error"),error_type:vA("source_i2c_misconfigured_error").default("source_i2c_misconfigured_error"),source_port_ids:be(H())}).describe("Error emitted when incompatible I2C pins (e.g. SDA and SCL) are connected to the same net"),Mle=sI.extend({ftype:vA("simple_voltage_source"),voltage:tx,frequency:FM.optional(),peak_to_peak_voltage:tx.optional(),wave_shape:et(["sinewave","square","triangle","sawtooth"]).optional(),phase:AQ.optional(),duty_cycle:WA().optional().describe("Duty cycle as a fraction (0 to 1)")}),Rle=Nt([ByA,lyA,Xj,wle,CyA,Dle,QyA,hyA,Sle,EyA,uyA,dyA,pyA,ble,fyA,yyA,myA,xyA,wyA,DyA,SyA,byA,dXt,vle,Fle,Mle,_yA,xle,_le,kyA,kle,vyA,FyA]),Nle=te({type:vA("source_port"),pin_number:WA().optional(),port_hints:be(H()).optional(),name:H(),source_port_id:H(),source_component_id:H().optional(),source_group_id:H().optional(),most_frequently_referenced_by_name:H().optional(),subcircuit_id:H().optional(),subcircuit_connectivity_map_key:H().optional(),must_be_connected:OA().optional(),is_configured_for_i2c_sda:OA().optional(),is_configured_for_i2c_scl:OA().optional(),is_configured_for_spi_mosi:OA().optional(),is_configured_for_spi_miso:OA().optional(),is_configured_for_spi_sck:OA().optional(),is_configured_for_spi_cs:OA().optional(),is_configured_for_uart_tx:OA().optional(),is_configured_for_uart_rx:OA().optional(),supports_i2c_sda:OA().optional(),supports_i2c_scl:OA().optional(),supports_spi_mosi:OA().optional(),supports_spi_miso:OA().optional(),supports_spi_sck:OA().optional(),supports_spi_cs:OA().optional(),supports_uart_tx:OA().optional(),supports_uart_rx:OA().optional()}),Gle=te({type:vA("source_component_internal_connection"),source_component_internal_connection_id:H(),source_component_id:H(),source_port_ids:be(H()),subcircuit_id:H().optional()}),Lle=te({type:vA("source_trace"),source_trace_id:H(),connected_source_port_ids:be(H()),connected_source_net_ids:be(H()),subcircuit_id:H().optional(),subcircuit_connectivity_map_key:H().optional(),max_length:WA().optional(),min_trace_thickness:WA().optional(),display_name:H().optional()}),Ule=te({type:vA("source_group"),source_group_id:H(),subcircuit_id:H().optional(),parent_subcircuit_id:H().optional(),parent_source_group_id:H().optional(),is_subcircuit:OA().optional(),show_as_schematic_box:OA().optional(),name:H().optional(),was_automatically_named:OA().optional()}),Hle=te({type:vA("source_net"),source_net_id:H(),name:H(),member_source_group_ids:be(H()),is_power:OA().optional(),is_ground:OA().optional(),is_digital_signal:OA().optional(),is_analog_signal:OA().optional(),is_positive_voltage_source:OA().optional(),trace_width:WA().optional(),subcircuit_id:H().optional(),subcircuit_connectivity_map_key:H().optional()}),Yle=te({type:vA("source_board"),source_board_id:H(),source_group_id:H(),title:H().optional()}).describe("Defines a board in the source domain"),Jle=te({type:vA("source_pcb_ground_plane"),source_pcb_ground_plane_id:H(),source_group_id:H(),source_net_id:H(),subcircuit_id:H().optional()}).describe("Defines a ground plane in the source domain"),Tle=["top","bottom","inner1","inner2","inner3","inner4","inner5","inner6"],MyA=et(Tle),Hr=MyA.or(te({name:MyA})).transform(t=>typeof t=="string"?t:t.name),km=et(["top","bottom"]),Ple=te({type:vA("source_manually_placed_via"),source_manually_placed_via_id:H(),source_group_id:H(),source_net_id:H(),subcircuit_id:H().optional(),source_trace_id:H().optional()}).describe("Defines a via that is manually placed in the source domain"),Kle=JI.extend({type:vA("source_pin_must_be_connected_error"),source_pin_must_be_connected_error_id:Xt("source_pin_must_be_connected_error"),error_type:vA("source_pin_must_be_connected_error").default("source_pin_must_be_connected_error"),source_component_id:H(),source_port_id:H(),subcircuit_id:H().optional()}).describe("Error emitted when a pin with mustBeConnected attribute is not connected to any trace"),qle=JI.extend({type:vA("unknown_error_finding_part"),unknown_error_finding_part_id:Xt("unknown_error_finding_part"),error_type:vA("unknown_error_finding_part").default("unknown_error_finding_part"),source_component_id:H().optional(),subcircuit_id:H().optional()}).describe("Error emitted when an unexpected error occurs while finding a part"),Ole=te({type:vA("schematic_box"),schematic_component_id:H().optional(),schematic_symbol_id:H().optional(),width:Et,height:Et,is_dashed:OA().default(!1),x:Et,y:Et,subcircuit_id:H().optional()}).describe("Draws a box on the schematic"),Wle=te({type:vA("schematic_path"),schematic_path_id:Xt("schematic_path"),schematic_component_id:H().optional(),schematic_symbol_id:H().optional(),fill_color:H().optional(),is_filled:OA().optional(),stroke_width:Et.nullable().optional(),stroke_color:H().optional(),points:be(fn),subcircuit_id:H().optional()}),Zle=Sa(te({left_margin:rn.optional(),right_margin:rn.optional(),top_margin:rn.optional(),bottom_margin:rn.optional()})),Vle=te({left_size:WA(),right_size:WA(),top_size:WA().optional(),bottom_size:WA().optional()}),jle=te({left_side:te({pins:be(WA()),direction:et(["top-to-bottom","bottom-to-top"]).optional()}).optional(),right_side:te({pins:be(WA()),direction:et(["top-to-bottom","bottom-to-top"]).optional()}).optional(),top_side:te({pins:be(WA()),direction:et(["left-to-right","right-to-left"]).optional()}).optional(),bottom_side:te({pins:be(WA()),direction:et(["left-to-right","right-to-left"]).optional()}).optional()}),zle=Nt([Vle,jle]),Xle=te({type:vA("schematic_component"),size:cyA,center:fn,source_component_id:H().optional(),schematic_component_id:H(),schematic_symbol_id:H().optional(),pin_spacing:rn.optional(),pin_styles:Zle.optional(),box_width:rn.optional(),symbol_name:H().optional(),port_arrangement:zle.optional(),port_labels:Sa(H()).optional(),symbol_display_value:H().optional(),subcircuit_id:H().optional(),schematic_group_id:H().optional(),is_schematic_group:OA().optional(),source_group_id:H().optional(),is_box_with_pins:OA().optional().default(!0)}),pXt=te({kicad_symbol:yle.optional()}).catchall(W7()),$le=te({type:vA("schematic_symbol"),schematic_symbol_id:H(),name:H().optional(),metadata:pXt.optional()}).describe("Defines a named schematic symbol that can be referenced by components."),ABe=te({type:vA("schematic_line"),schematic_line_id:Xt("schematic_line"),schematic_component_id:H().optional(),schematic_symbol_id:H().optional(),x1:Et,y1:Et,x2:Et,y2:Et,stroke_width:Et.nullable().optional(),color:H().default("#000000"),is_dashed:OA().default(!1),subcircuit_id:H().optional()}).describe("Draws a styled line on the schematic"),eBe=te({type:vA("schematic_rect"),schematic_rect_id:Xt("schematic_rect"),schematic_component_id:H().optional(),schematic_symbol_id:H().optional(),center:fn,width:Et,height:Et,rotation:AQ.default(0),stroke_width:Et.nullable().optional(),color:H().default("#000000"),is_filled:OA().default(!1),fill_color:H().optional(),is_dashed:OA().default(!1),subcircuit_id:H().optional()}).describe("Draws a styled rectangle on the schematic"),tBe=te({type:vA("schematic_circle"),schematic_circle_id:Xt("schematic_circle"),schematic_component_id:H().optional(),schematic_symbol_id:H().optional(),center:fn,radius:Et,stroke_width:Et.nullable().optional(),color:H().default("#000000"),is_filled:OA().default(!1),fill_color:H().optional(),is_dashed:OA().default(!1),subcircuit_id:H().optional()}).describe("Draws a styled circle on the schematic"),iBe=te({type:vA("schematic_arc"),schematic_arc_id:Xt("schematic_arc"),schematic_component_id:H().optional(),schematic_symbol_id:H().optional(),center:fn,radius:Et,start_angle_degrees:AQ,end_angle_degrees:AQ,direction:et(["clockwise","counterclockwise"]).default("counterclockwise"),stroke_width:Et.nullable().optional(),color:H().default("#000000"),is_dashed:OA().default(!1),subcircuit_id:H().optional()}).describe("Draws a styled arc on the schematic"),nBe=te({type:vA("schematic_trace"),schematic_trace_id:H(),source_trace_id:H().optional(),junctions:be(te({x:WA(),y:WA()})),edges:be(te({from:te({x:WA(),y:WA()}),to:te({x:WA(),y:WA()}),is_crossing:OA().optional(),from_schematic_port_id:H().optional(),to_schematic_port_id:H().optional()})),subcircuit_id:H().optional(),subcircuit_connectivity_map_key:H().optional()}),fXt=et(["center","left","right","top","bottom"]),oBe=te({type:vA("schematic_text"),schematic_component_id:H().optional(),schematic_symbol_id:H().optional(),schematic_text_id:H(),text:H(),font_size:WA().default(.18),position:te({x:Et,y:Et}),rotation:WA().default(0),anchor:Nt([fXt.describe("legacy"),Gk]).default("center"),color:H().default("#000000"),subcircuit_id:H().optional()}),sBe=te({type:vA("schematic_port"),schematic_port_id:H(),source_port_id:H(),schematic_component_id:H().optional(),center:fn,facing_direction:et(["up","down","left","right"]).optional(),distance_from_component_edge:WA().optional(),side_of_component:et(["top","bottom","left","right"]).optional(),true_ccw_index:WA().optional(),pin_number:WA().optional(),display_pin_label:H().optional(),subcircuit_id:H().optional(),is_connected:OA().optional(),has_input_arrow:OA().optional(),has_output_arrow:OA().optional(),is_drawn_with_inversion_circle:OA().optional()}).describe("Defines a port on a schematic component"),rBe=te({type:vA("schematic_net_label"),schematic_net_label_id:Xt("schematic_net_label"),schematic_trace_id:H().optional(),source_trace_id:H().optional(),source_net_id:H(),center:fn,anchor_position:fn.optional(),anchor_side:et(["top","bottom","left","right"]),text:H(),symbol_name:H().optional(),is_movable:OA().optional(),subcircuit_id:H().optional()}),aBe=JI.extend({type:vA("schematic_error"),schematic_error_id:H(),error_type:vA("schematic_port_not_found").default("schematic_port_not_found"),subcircuit_id:H().optional()}).describe("Defines a schematic error on the schematic"),gBe=JI.extend({type:vA("schematic_layout_error"),schematic_layout_error_id:Xt("schematic_layout_error"),error_type:vA("schematic_layout_error").default("schematic_layout_error"),source_group_id:H(),schematic_group_id:H(),subcircuit_id:H().optional()}).describe("Error emitted when schematic layout fails for a group"),$j=te({type:vA("schematic_debug_object"),label:H().optional(),subcircuit_id:H().optional()}),cBe=$j.extend({shape:vA("rect"),center:fn,size:cyA}),IBe=$j.extend({shape:vA("line"),start:fn,end:fn}),lBe=$j.extend({shape:vA("point"),center:fn}),BBe=hf("shape",[cBe,IBe,lBe]),CBe=te({type:vA("schematic_voltage_probe"),schematic_voltage_probe_id:H(),source_component_id:H().optional(),name:H().optional(),position:fn,schematic_trace_id:H(),voltage:tx.optional(),subcircuit_id:H().optional(),color:H().optional(),label_alignment:Gk.optional()}).describe("Defines a voltage probe measurement point on a schematic trace"),QBe=te({type:vA("schematic_manual_edit_conflict_warning"),schematic_manual_edit_conflict_warning_id:Xt("schematic_manual_edit_conflict_warning"),warning_type:vA("schematic_manual_edit_conflict_warning").default("schematic_manual_edit_conflict_warning"),message:H(),schematic_component_id:H(),schematic_group_id:H().optional(),subcircuit_id:H().optional(),source_component_id:H()}).describe("Warning emitted when a component has both manual placement and explicit schX/schY coordinates"),hBe=te({type:vA("schematic_group"),schematic_group_id:Xt("schematic_group"),source_group_id:H(),is_subcircuit:OA().optional(),subcircuit_id:H().optional(),width:rn,height:rn,center:fn,schematic_component_ids:be(H()),show_as_schematic_box:OA().optional(),name:H().optional(),description:H().optional()}).describe("Defines a group of components on the schematic"),EBe=te({type:vA("schematic_table"),schematic_table_id:Xt("schematic_table"),anchor_position:fn,column_widths:be(Et),row_heights:be(Et),cell_padding:Et.optional(),border_width:Et.optional(),subcircuit_id:H().optional(),schematic_component_id:H().optional(),anchor:Gk.optional()}).describe("Defines a table on the schematic"),uBe=te({type:vA("schematic_table_cell"),schematic_table_cell_id:Xt("schematic_table_cell"),schematic_table_id:H(),start_row_index:WA(),end_row_index:WA(),start_column_index:WA(),end_column_index:WA(),text:H().optional(),center:fn,width:Et,height:Et,horizontal_align:et(["left","center","right"]).optional(),vertical_align:et(["top","middle","bottom"]).optional(),font_size:Et.optional(),subcircuit_id:H().optional()}).describe("Defines a cell within a schematic_table"),dBe=te({type:vA("schematic_sheet"),schematic_sheet_id:Xt("schematic_sheet"),name:H().optional(),subcircuit_id:H().optional()}).describe("Defines a schematic sheet or page that components can be placed on"),pBe=te({x:Et,y:Et,bulge:WA().optional()}),RyA=te({vertices:be(pBe)}),fBe=te({outer_ring:RyA,inner_rings:be(RyA).default([])}),yBe=te({x:Et,y:Et,via:OA().optional(),via_to_layer:Hr.optional()}),yXt=be(yBe),mBe=te({x:Et,y:Et,via:OA().optional(),to_layer:Hr.optional(),trace_width:Et.optional()}),wBe=te({type:vA("pcb_component"),pcb_component_id:Xt("pcb_component"),source_component_id:H(),center:fn,layer:Hr,rotation:AQ,display_offset_x:H().optional().describe("How to display the x offset for this part, usually corresponding with how the user specified it"),display_offset_y:H().optional().describe("How to display the y offset for this part, usually corresponding with how the user specified it"),width:rn,height:rn,do_not_place:OA().optional(),is_allowed_to_be_off_board:OA().optional(),subcircuit_id:H().optional(),pcb_group_id:H().optional(),position_mode:et(["packed","relative_to_group_anchor","none"]).optional(),positioned_relative_to_pcb_group_id:H().optional(),positioned_relative_to_pcb_board_id:H().optional(),metadata:te({kicad_footprint:Ele.optional()}).optional(),obstructs_within_bounds:OA().default(!0).describe("Does this component take up all the space within its bounds on a layer. This is generally true except for when separated pin headers are being represented by a single component (in which case, chips can be placed between the pin headers) or for tall modules where chips fit underneath")}).describe("Defines a component on the PCB"),DBe=te({type:vA("pcb_hole"),pcb_hole_id:Xt("pcb_hole"),pcb_group_id:H().optional(),subcircuit_id:H().optional(),pcb_component_id:H().optional(),hole_shape:vA("circle"),hole_diameter:WA(),x:Et,y:Et,is_covered_with_solder_mask:OA().optional(),soldermask_margin:WA().optional()}),mXt=DBe.describe("Defines a circular hole on the PCB"),SBe=te({type:vA("pcb_hole"),pcb_hole_id:Xt("pcb_hole"),pcb_group_id:H().optional(),subcircuit_id:H().optional(),pcb_component_id:H().optional(),hole_shape:vA("rect"),hole_width:WA(),hole_height:WA(),x:Et,y:Et,is_covered_with_solder_mask:OA().optional(),soldermask_margin:WA().optional()}),wXt=SBe.describe("Defines a rectangular (square-capable) hole on the PCB. Use equal width/height for square."),bBe=te({type:vA("pcb_hole"),pcb_hole_id:Xt("pcb_hole"),pcb_group_id:H().optional(),subcircuit_id:H().optional(),pcb_component_id:H().optional(),hole_shape:et(["circle","square"]),hole_diameter:WA(),x:Et,y:Et,is_covered_with_solder_mask:OA().optional(),soldermask_margin:WA().optional()}),DXt=bBe.describe("Defines a circular or square hole on the PCB"),xBe=te({type:vA("pcb_hole"),pcb_hole_id:Xt("pcb_hole"),pcb_group_id:H().optional(),subcircuit_id:H().optional(),pcb_component_id:H().optional(),hole_shape:vA("oval"),hole_width:WA(),hole_height:WA(),x:Et,y:Et,is_covered_with_solder_mask:OA().optional(),soldermask_margin:WA().optional()}),SXt=xBe.describe("Defines an oval hole on the PCB"),_Be=te({type:vA("pcb_hole"),pcb_hole_id:Xt("pcb_hole"),pcb_group_id:H().optional(),subcircuit_id:H().optional(),pcb_component_id:H().optional(),hole_shape:vA("pill"),hole_width:WA(),hole_height:WA(),x:Et,y:Et,is_covered_with_solder_mask:OA().optional(),soldermask_margin:WA().optional()}),bXt=_Be.describe("Defines a pill-shaped hole on the PCB"),kBe=te({type:vA("pcb_hole"),pcb_hole_id:Xt("pcb_hole"),pcb_group_id:H().optional(),subcircuit_id:H().optional(),pcb_component_id:H().optional(),hole_shape:vA("rotated_pill"),hole_width:WA(),hole_height:WA(),x:Et,y:Et,ccw_rotation:AQ,is_covered_with_solder_mask:OA().optional(),soldermask_margin:WA().optional()}),xXt=kBe.describe("Defines a rotated pill-shaped hole on the PCB"),vBe=bBe.or(xBe).or(_Be).or(kBe).or(DBe).or(SBe),_Xt=te({type:vA("pcb_plated_hole"),shape:vA("circle"),pcb_group_id:H().optional(),subcircuit_id:H().optional(),outer_diameter:WA(),hole_diameter:WA(),is_covered_with_solder_mask:OA().optional(),x:Et,y:Et,layers:be(Hr),port_hints:be(H()).optional(),pcb_component_id:H().optional(),pcb_port_id:H().optional(),pcb_plated_hole_id:Xt("pcb_plated_hole"),soldermask_margin:WA().optional()}),kXt=te({type:vA("pcb_plated_hole"),shape:et(["oval","pill"]),pcb_group_id:H().optional(),subcircuit_id:H().optional(),outer_width:WA(),outer_height:WA(),hole_width:WA(),hole_height:WA(),is_covered_with_solder_mask:OA().optional(),x:Et,y:Et,ccw_rotation:AQ,layers:be(Hr),port_hints:be(H()).optional(),pcb_component_id:H().optional(),pcb_port_id:H().optional(),pcb_plated_hole_id:Xt("pcb_plated_hole"),soldermask_margin:WA().optional()}),vXt=te({type:vA("pcb_plated_hole"),shape:vA("circular_hole_with_rect_pad"),pcb_group_id:H().optional(),subcircuit_id:H().optional(),hole_shape:vA("circle"),pad_shape:vA("rect"),hole_diameter:WA(),rect_pad_width:WA(),rect_pad_height:WA(),rect_border_radius:WA().optional(),hole_offset_x:Et.default(0),hole_offset_y:Et.default(0),is_covered_with_solder_mask:OA().optional(),x:Et,y:Et,layers:be(Hr),port_hints:be(H()).optional(),pcb_component_id:H().optional(),pcb_port_id:H().optional(),pcb_plated_hole_id:Xt("pcb_plated_hole"),soldermask_margin:WA().optional(),rect_ccw_rotation:AQ.optional()}),FXt=te({type:vA("pcb_plated_hole"),shape:vA("pill_hole_with_rect_pad"),pcb_group_id:H().optional(),subcircuit_id:H().optional(),hole_shape:vA("pill"),pad_shape:vA("rect"),hole_width:WA(),hole_height:WA(),rect_pad_width:WA(),rect_pad_height:WA(),rect_border_radius:WA().optional(),hole_offset_x:Et.default(0),hole_offset_y:Et.default(0),is_covered_with_solder_mask:OA().optional(),x:Et,y:Et,layers:be(Hr),port_hints:be(H()).optional(),pcb_component_id:H().optional(),pcb_port_id:H().optional(),pcb_plated_hole_id:Xt("pcb_plated_hole"),soldermask_margin:WA().optional()}),MXt=te({type:vA("pcb_plated_hole"),shape:vA("rotated_pill_hole_with_rect_pad"),pcb_group_id:H().optional(),subcircuit_id:H().optional(),hole_shape:vA("rotated_pill"),pad_shape:vA("rect"),hole_width:WA(),hole_height:WA(),hole_ccw_rotation:AQ,rect_pad_width:WA(),rect_pad_height:WA(),rect_border_radius:WA().optional(),rect_ccw_rotation:AQ,hole_offset_x:Et.default(0),hole_offset_y:Et.default(0),is_covered_with_solder_mask:OA().optional(),x:Et,y:Et,layers:be(Hr),port_hints:be(H()).optional(),pcb_component_id:H().optional(),pcb_port_id:H().optional(),pcb_plated_hole_id:Xt("pcb_plated_hole"),soldermask_margin:WA().optional()}),RXt=te({type:vA("pcb_plated_hole"),shape:vA("hole_with_polygon_pad"),pcb_group_id:H().optional(),subcircuit_id:H().optional(),hole_shape:et(["circle","oval","pill","rotated_pill"]),hole_diameter:WA().optional(),hole_width:WA().optional(),hole_height:WA().optional(),pad_outline:be(te({x:Et,y:Et})).min(3),hole_offset_x:Et.default(0),hole_offset_y:Et.default(0),is_covered_with_solder_mask:OA().optional(),x:Et,y:Et,layers:be(Hr),port_hints:be(H()).optional(),pcb_component_id:H().optional(),pcb_port_id:H().optional(),pcb_plated_hole_id:Xt("pcb_plated_hole"),soldermask_margin:WA().optional(),ccw_rotation:AQ.optional()}),FBe=Nt([_Xt,kXt,vXt,FXt,MXt,RXt]),MBe=te({type:vA("pcb_port"),pcb_port_id:Xt("pcb_port"),pcb_group_id:H().optional(),subcircuit_id:H().optional(),source_port_id:H(),pcb_component_id:H().optional(),x:Et,y:Et,layers:be(Hr),is_board_pinout:OA().optional()}).describe("Defines a port on the PCB"),NXt=te({type:vA("pcb_smtpad"),shape:vA("circle"),pcb_smtpad_id:Xt("pcb_smtpad"),pcb_group_id:H().optional(),subcircuit_id:H().optional(),x:Et,y:Et,radius:WA(),layer:Hr,port_hints:be(H()).optional(),pcb_component_id:H().optional(),pcb_port_id:H().optional(),is_covered_with_solder_mask:OA().optional(),soldermask_margin:WA().optional()}),GXt=te({type:vA("pcb_smtpad"),shape:vA("rect"),pcb_smtpad_id:Xt("pcb_smtpad"),pcb_group_id:H().optional(),subcircuit_id:H().optional(),x:Et,y:Et,width:WA(),height:WA(),rect_border_radius:WA().optional(),corner_radius:WA().optional(),layer:Hr,port_hints:be(H()).optional(),pcb_component_id:H().optional(),pcb_port_id:H().optional(),is_covered_with_solder_mask:OA().optional(),soldermask_margin:WA().optional(),soldermask_margin_left:WA().optional(),soldermask_margin_top:WA().optional(),soldermask_margin_right:WA().optional(),soldermask_margin_bottom:WA().optional()}),LXt=te({type:vA("pcb_smtpad"),shape:vA("rotated_rect"),pcb_smtpad_id:Xt("pcb_smtpad"),pcb_group_id:H().optional(),subcircuit_id:H().optional(),x:Et,y:Et,width:WA(),height:WA(),rect_border_radius:WA().optional(),corner_radius:WA().optional(),ccw_rotation:AQ,layer:Hr,port_hints:be(H()).optional(),pcb_component_id:H().optional(),pcb_port_id:H().optional(),is_covered_with_solder_mask:OA().optional(),soldermask_margin:WA().optional(),soldermask_margin_left:WA().optional(),soldermask_margin_top:WA().optional(),soldermask_margin_right:WA().optional(),soldermask_margin_bottom:WA().optional()}),RBe=te({type:vA("pcb_smtpad"),shape:vA("pill"),pcb_smtpad_id:Xt("pcb_smtpad"),pcb_group_id:H().optional(),subcircuit_id:H().optional(),x:Et,y:Et,width:WA(),height:WA(),radius:WA(),layer:Hr,port_hints:be(H()).optional(),pcb_component_id:H().optional(),pcb_port_id:H().optional(),is_covered_with_solder_mask:OA().optional(),soldermask_margin:WA().optional()}),UXt=te({type:vA("pcb_smtpad"),shape:vA("rotated_pill"),pcb_smtpad_id:Xt("pcb_smtpad"),pcb_group_id:H().optional(),subcircuit_id:H().optional(),x:Et,y:Et,width:WA(),height:WA(),radius:WA(),ccw_rotation:AQ,layer:Hr,port_hints:be(H()).optional(),pcb_component_id:H().optional(),pcb_port_id:H().optional(),is_covered_with_solder_mask:OA().optional(),soldermask_margin:WA().optional()}),HXt=te({type:vA("pcb_smtpad"),shape:vA("polygon"),pcb_smtpad_id:Xt("pcb_smtpad"),pcb_group_id:H().optional(),subcircuit_id:H().optional(),points:be(fn),layer:Hr,port_hints:be(H()).optional(),pcb_component_id:H().optional(),pcb_port_id:H().optional(),is_covered_with_solder_mask:OA().optional(),soldermask_margin:WA().optional()}),NBe=hf("shape",[NXt,GXt,LXt,UXt,RBe,HXt]).describe("Defines an SMT pad on the PCB"),YXt=te({type:vA("pcb_solder_paste"),shape:vA("circle"),pcb_solder_paste_id:Xt("pcb_solder_paste"),pcb_group_id:H().optional(),subcircuit_id:H().optional(),x:Et,y:Et,radius:WA(),layer:Hr,pcb_component_id:H().optional(),pcb_smtpad_id:H().optional()}),JXt=te({type:vA("pcb_solder_paste"),shape:vA("rect"),pcb_solder_paste_id:Xt("pcb_solder_paste"),pcb_group_id:H().optional(),subcircuit_id:H().optional(),x:Et,y:Et,width:WA(),height:WA(),layer:Hr,pcb_component_id:H().optional(),pcb_smtpad_id:H().optional()}),TXt=te({type:vA("pcb_solder_paste"),shape:vA("pill"),pcb_solder_paste_id:Xt("pcb_solder_paste"),pcb_group_id:H().optional(),subcircuit_id:H().optional(),x:Et,y:Et,width:WA(),height:WA(),radius:WA(),layer:Hr,pcb_component_id:H().optional(),pcb_smtpad_id:H().optional()}),PXt=te({type:vA("pcb_solder_paste"),shape:vA("rotated_rect"),pcb_solder_paste_id:Xt("pcb_solder_paste"),pcb_group_id:H().optional(),subcircuit_id:H().optional(),x:Et,y:Et,width:WA(),height:WA(),ccw_rotation:Et,layer:Hr,pcb_component_id:H().optional(),pcb_smtpad_id:H().optional()}),KXt=te({type:vA("pcb_solder_paste"),shape:vA("oval"),pcb_solder_paste_id:Xt("pcb_solder_paste"),pcb_group_id:H().optional(),subcircuit_id:H().optional(),x:Et,y:Et,width:WA(),height:WA(),layer:Hr,pcb_component_id:H().optional(),pcb_smtpad_id:H().optional()}),GBe=Nt([YXt,JXt,TXt,PXt,KXt]).describe("Defines solderpaste on the PCB"),LBe=te({type:vA("pcb_text"),pcb_text_id:Xt("pcb_text"),pcb_group_id:H().optional(),subcircuit_id:H().optional(),text:H(),center:fn,layer:Hr,width:rn,height:rn,lines:WA(),align:et(["bottom-left"])}).describe("Defines text on the PCB"),UBe=te({route_type:vA("wire"),x:Et,y:Et,width:Et,start_pcb_port_id:H().optional(),end_pcb_port_id:H().optional(),layer:Hr}),HBe=te({route_type:vA("via"),x:Et,y:Et,hole_diameter:Et.optional(),outer_diameter:Et.optional(),from_layer:H(),to_layer:H()}),YBe=Nt([UBe,HBe]),JBe=te({type:vA("pcb_trace"),source_trace_id:H().optional(),pcb_component_id:H().optional(),pcb_trace_id:Xt("pcb_trace"),pcb_group_id:H().optional(),subcircuit_id:H().optional(),route_thickness_mode:et(["constant","interpolated"]).default("constant").optional(),route_order_index:WA().optional(),should_round_corners:OA().optional(),trace_length:WA().optional(),highlight_color:H().optional(),route:be(YBe)}).describe("Defines a trace on the PCB"),TBe=JI.extend({type:vA("pcb_trace_error"),pcb_trace_error_id:Xt("pcb_trace_error"),error_type:vA("pcb_trace_error").default("pcb_trace_error"),center:fn.optional(),pcb_trace_id:H(),source_trace_id:H(),pcb_component_ids:be(H()),pcb_port_ids:be(H()),subcircuit_id:H().optional()}).describe("Defines a trace error on the PCB"),PBe=JI.extend({type:vA("pcb_trace_missing_error"),pcb_trace_missing_error_id:Xt("pcb_trace_missing_error"),error_type:vA("pcb_trace_missing_error").default("pcb_trace_missing_error"),center:fn.optional(),source_trace_id:H(),pcb_component_ids:be(H()),pcb_port_ids:be(H()),subcircuit_id:H().optional()}).describe("Defines an error when a source trace has no corresponding PCB trace"),KBe=JI.extend({type:vA("pcb_port_not_matched_error"),pcb_error_id:Xt("pcb_error"),error_type:vA("pcb_port_not_matched_error").default("pcb_port_not_matched_error"),pcb_component_ids:be(H()),subcircuit_id:H().optional()}).describe("Defines a trace error on the PCB where a port is not matched"),qBe=JI.extend({type:vA("pcb_port_not_connected_error"),pcb_port_not_connected_error_id:Xt("pcb_port_not_connected_error"),error_type:vA("pcb_port_not_connected_error").default("pcb_port_not_connected_error"),pcb_port_ids:be(H()),pcb_component_ids:be(H()),subcircuit_id:H().optional()}).describe("Defines an error when a pcb port is not connected to any trace"),OBe=te({type:vA("pcb_net"),pcb_net_id:Xt("pcb_net"),source_net_id:H().optional(),highlight_color:H().optional()}).describe("Defines a net on the PCB"),WBe=te({type:vA("pcb_via"),pcb_via_id:Xt("pcb_via"),pcb_group_id:H().optional(),subcircuit_id:H().optional(),subcircuit_connectivity_map_key:H().optional(),x:Et,y:Et,outer_diameter:Et.default("0.6mm"),hole_diameter:Et.default("0.25mm"),from_layer:Hr.optional(),to_layer:Hr.optional(),layers:be(Hr),pcb_trace_id:H().optional(),net_is_assignable:OA().optional(),net_assigned:OA().optional(),is_tented:OA().optional()}).describe("Defines a via on the PCB"),ZBe=te({type:vA("pcb_board"),pcb_board_id:Xt("pcb_board"),pcb_panel_id:H().optional(),carrier_pcb_board_id:H().optional(),is_subcircuit:OA().optional(),subcircuit_id:H().optional(),is_mounted_to_carrier_board:OA().optional(),width:rn.optional(),height:rn.optional(),center:fn,display_offset_x:H().optional().describe("How to display the x offset for this board, usually corresponding with how the user specified it"),display_offset_y:H().optional().describe("How to display the y offset for this board, usually corresponding with how the user specified it"),thickness:rn.optional().default(1.4),num_layers:WA().optional().default(4),outline:be(fn).optional(),shape:et(["rect","polygon"]).optional(),material:et(["fr4","fr1"]).default("fr4"),anchor_position:fn.optional(),anchor_alignment:Gk.optional(),position_mode:et(["relative_to_panel_anchor","none"]).optional()}).describe("Defines the board outline of the PCB"),VBe=te({type:vA("pcb_panel"),pcb_panel_id:Xt("pcb_panel"),width:rn,height:rn,center:fn,covered_with_solder_mask:OA().optional().default(!0)}).describe("Defines a PCB panel that can contain multiple boards"),jBe=JI.extend({type:vA("pcb_placement_error"),pcb_placement_error_id:Xt("pcb_placement_error"),error_type:vA("pcb_placement_error").default("pcb_placement_error"),subcircuit_id:H().optional()}).describe("Defines a placement error on the PCB"),zBe=JI.extend({type:vA("pcb_panelization_placement_error"),pcb_panelization_placement_error_id:Xt("pcb_panelization_placement_error"),error_type:vA("pcb_panelization_placement_error").default("pcb_panelization_placement_error"),pcb_panel_id:H().optional(),pcb_board_id:H().optional(),subcircuit_id:H().optional()}).describe("Defines a panelization placement error on the PCB"),XBe=te({type:vA("pcb_trace_hint"),pcb_trace_hint_id:Xt("pcb_trace_hint"),pcb_port_id:H(),pcb_component_id:H(),route:be(mBe),subcircuit_id:H().optional()}).describe("A hint that can be used during generation of a PCB trace"),$Be=te({type:vA("pcb_silkscreen_line"),pcb_silkscreen_line_id:Xt("pcb_silkscreen_line"),pcb_component_id:H(),pcb_group_id:H().optional(),subcircuit_id:H().optional(),stroke_width:Et.default("0.1mm"),x1:Et,y1:Et,x2:Et,y2:Et,layer:km}).describe("Defines a silkscreen line on the PCB"),ACe=te({type:vA("pcb_silkscreen_path"),pcb_silkscreen_path_id:Xt("pcb_silkscreen_path"),pcb_component_id:H(),pcb_group_id:H().optional(),subcircuit_id:H().optional(),layer:km,route:be(fn),stroke_width:rn}).describe("Defines a silkscreen path on the PCB"),eCe=te({type:vA("pcb_silkscreen_text"),pcb_silkscreen_text_id:Xt("pcb_silkscreen_text"),pcb_group_id:H().optional(),subcircuit_id:H().optional(),font:vA("tscircuit2024").default("tscircuit2024"),font_size:Et.default("0.2mm"),pcb_component_id:H(),text:H(),is_knockout:OA().default(!1).optional(),knockout_padding:te({left:rn,top:rn,bottom:rn,right:rn}).default({left:"0.2mm",top:"0.2mm",bottom:"0.2mm",right:"0.2mm"}).optional(),ccw_rotation:WA().optional(),layer:Hr,is_mirrored:OA().default(!1).optional(),anchor_position:fn.default({x:0,y:0}),anchor_alignment:Gk.default("center")}).describe("Defines silkscreen text on the PCB"),tCe=te({type:vA("pcb_copper_text"),pcb_copper_text_id:Xt("pcb_copper_text"),pcb_group_id:H().optional(),subcircuit_id:H().optional(),font:vA("tscircuit2024").default("tscircuit2024"),font_size:Et.default("0.2mm"),pcb_component_id:H(),text:H(),is_knockout:OA().default(!1).optional(),knockout_padding:te({left:rn,top:rn,bottom:rn,right:rn}).default({left:"0.2mm",top:"0.2mm",bottom:"0.2mm",right:"0.2mm"}).optional(),ccw_rotation:WA().optional(),layer:Hr,is_mirrored:OA().default(!1).optional(),anchor_position:fn.default({x:0,y:0}),anchor_alignment:Gk.default("center")}).describe("Defines copper text on the PCB"),iCe=te({type:vA("pcb_silkscreen_rect"),pcb_silkscreen_rect_id:Xt("pcb_silkscreen_rect"),pcb_component_id:H(),pcb_group_id:H().optional(),subcircuit_id:H().optional(),center:fn,width:rn,height:rn,layer:Hr,stroke_width:rn.default("1mm"),corner_radius:rn.optional(),is_filled:OA().default(!0).optional(),has_stroke:OA().optional(),is_stroke_dashed:OA().optional(),ccw_rotation:WA().optional()}).describe("Defines a silkscreen rect on the PCB"),nCe=te({type:vA("pcb_silkscreen_circle"),pcb_silkscreen_circle_id:Xt("pcb_silkscreen_circle"),pcb_component_id:H(),pcb_group_id:H().optional(),subcircuit_id:H().optional(),center:fn,radius:rn,layer:km,stroke_width:rn.default("1mm")}).describe("Defines a silkscreen circle on the PCB"),oCe=te({type:vA("pcb_silkscreen_oval"),pcb_silkscreen_oval_id:Xt("pcb_silkscreen_oval"),pcb_component_id:H(),pcb_group_id:H().optional(),subcircuit_id:H().optional(),center:fn,radius_x:Et,radius_y:Et,layer:km,ccw_rotation:AQ.optional()}).describe("Defines a silkscreen oval on the PCB"),sCe=te({type:vA("pcb_silkscreen_pill"),pcb_silkscreen_pill_id:Xt("pcb_silkscreen_pill"),pcb_component_id:H(),pcb_group_id:H().optional(),subcircuit_id:H().optional(),center:fn,width:rn,height:rn,layer:Hr,ccw_rotation:WA().optional()}).describe("Defines a silkscreen pill on the PCB"),rCe=te({type:vA("pcb_fabrication_note_text"),pcb_fabrication_note_text_id:Xt("pcb_fabrication_note_text"),subcircuit_id:H().optional(),pcb_group_id:H().optional(),font:vA("tscircuit2024").default("tscircuit2024"),font_size:Et.default("1mm"),pcb_component_id:H(),text:H(),layer:km,anchor_position:fn.default({x:0,y:0}),anchor_alignment:et(["center","top_left","top_right","bottom_left","bottom_right"]).default("center"),color:H().optional()}).describe("Defines a fabrication note in text on the PCB, useful for leaving notes for assemblers or fabricators"),aCe=te({type:vA("pcb_fabrication_note_path"),pcb_fabrication_note_path_id:Xt("pcb_fabrication_note_path"),pcb_component_id:H(),subcircuit_id:H().optional(),layer:Hr,route:be(fn),stroke_width:rn,color:H().optional()}).describe("Defines a fabrication path on the PCB for fabricators or assemblers"),gCe=te({type:vA("pcb_fabrication_note_rect"),pcb_fabrication_note_rect_id:Xt("pcb_fabrication_note_rect"),pcb_component_id:H(),pcb_group_id:H().optional(),subcircuit_id:H().optional(),center:fn,width:rn,height:rn,layer:km,stroke_width:rn.default("0.1mm"),corner_radius:rn.optional(),is_filled:OA().optional(),has_stroke:OA().optional(),is_stroke_dashed:OA().optional(),color:H().optional()}).describe("Defines a fabrication note rectangle on the PCB"),cCe=te({type:vA("pcb_fabrication_note_dimension"),pcb_fabrication_note_dimension_id:Xt("pcb_fabrication_note_dimension"),pcb_component_id:H(),pcb_group_id:H().optional(),subcircuit_id:H().optional(),layer:km,from:fn,to:fn,text:H().optional(),text_ccw_rotation:WA().optional(),offset:rn.optional(),offset_distance:rn.optional(),offset_direction:te({x:WA(),y:WA()}).optional(),font:vA("tscircuit2024").default("tscircuit2024"),font_size:rn.default("1mm"),color:H().optional(),arrow_size:rn.default("1mm")}).describe("Defines a measurement annotation within PCB fabrication notes"),ICe=te({type:vA("pcb_note_text"),pcb_note_text_id:Xt("pcb_note_text"),pcb_component_id:H().optional(),pcb_group_id:H().optional(),subcircuit_id:H().optional(),name:H().optional(),font:vA("tscircuit2024").default("tscircuit2024"),font_size:Et.default("1mm"),text:H().optional(),anchor_position:fn.default({x:0,y:0}),anchor_alignment:et(["center","top_left","top_right","bottom_left","bottom_right"]).default("center"),color:H().optional()}).describe("Defines a documentation note in text on the PCB"),lCe=te({type:vA("pcb_note_rect"),pcb_note_rect_id:Xt("pcb_note_rect"),pcb_component_id:H().optional(),pcb_group_id:H().optional(),subcircuit_id:H().optional(),name:H().optional(),text:H().optional(),center:fn,width:rn,height:rn,stroke_width:rn.default("0.1mm"),corner_radius:rn.optional(),is_filled:OA().optional(),has_stroke:OA().optional(),is_stroke_dashed:OA().optional(),color:H().optional()}).describe("Defines a rectangular documentation note on the PCB"),BCe=te({type:vA("pcb_note_path"),pcb_note_path_id:Xt("pcb_note_path"),pcb_component_id:H().optional(),pcb_group_id:H().optional(),subcircuit_id:H().optional(),name:H().optional(),text:H().optional(),route:be(fn),stroke_width:rn.default("0.1mm"),color:H().optional()}).describe("Defines a polyline documentation note on the PCB"),CCe=te({type:vA("pcb_note_line"),pcb_note_line_id:Xt("pcb_note_line"),pcb_component_id:H().optional(),pcb_group_id:H().optional(),subcircuit_id:H().optional(),name:H().optional(),text:H().optional(),x1:Et,y1:Et,x2:Et,y2:Et,stroke_width:Et.default("0.1mm"),color:H().optional(),is_dashed:OA().optional()}).describe("Defines a straight documentation note line on the PCB"),QCe=te({type:vA("pcb_note_dimension"),pcb_note_dimension_id:Xt("pcb_note_dimension"),pcb_component_id:H().optional(),pcb_group_id:H().optional(),subcircuit_id:H().optional(),name:H().optional(),from:fn,to:fn,text:H().optional(),text_ccw_rotation:WA().optional(),offset_distance:rn.optional(),offset_direction:te({x:WA(),y:WA()}).optional(),font:vA("tscircuit2024").default("tscircuit2024"),font_size:rn.default("1mm"),color:H().optional(),arrow_size:rn.default("1mm")}).describe("Defines a measurement annotation within PCB documentation notes"),hCe=JI.extend({type:vA("pcb_footprint_overlap_error"),pcb_error_id:Xt("pcb_error"),error_type:vA("pcb_footprint_overlap_error").default("pcb_footprint_overlap_error"),pcb_smtpad_ids:be(H()).optional(),pcb_plated_hole_ids:be(H()).optional(),pcb_hole_ids:be(H()).optional(),pcb_keepout_ids:be(H()).optional()}).describe("Error emitted when a pcb footprint overlaps with another element"),ECe=te({type:vA("pcb_keepout"),shape:vA("rect"),pcb_group_id:H().optional(),subcircuit_id:H().optional(),center:fn,width:Et,height:Et,pcb_keepout_id:H(),layers:be(H()),description:H().optional()}).or(te({type:vA("pcb_keepout"),shape:vA("circle"),pcb_group_id:H().optional(),subcircuit_id:H().optional(),center:fn,radius:Et,pcb_keepout_id:H(),layers:be(H()),description:H().optional()})),Az=te({type:vA("pcb_cutout"),pcb_cutout_id:Xt("pcb_cutout"),pcb_group_id:H().optional(),subcircuit_id:H().optional(),pcb_board_id:H().optional(),pcb_panel_id:H().optional()}),uCe=Az.extend({shape:vA("rect"),center:fn,width:rn,height:rn,rotation:AQ.optional(),corner_radius:rn.optional()}),dCe=Az.extend({shape:vA("circle"),center:fn,radius:rn}),pCe=Az.extend({shape:vA("polygon"),points:be(fn)}),fCe=Az.extend({shape:vA("path"),route:be(fn),slot_width:rn,slot_length:rn.optional(),space_between_slots:rn.optional(),slot_corner_radius:rn.optional()}),yCe=hf("shape",[uCe,dCe,pCe,fCe]).describe("Defines a cutout on the PCB, removing board material."),mCe=JI.extend({type:vA("pcb_missing_footprint_error"),pcb_missing_footprint_error_id:Xt("pcb_missing_footprint_error"),pcb_group_id:H().optional(),subcircuit_id:H().optional(),error_type:vA("pcb_missing_footprint_error").default("pcb_missing_footprint_error"),source_component_id:H()}).describe("Defines a missing footprint error on the PCB"),wCe=JI.extend({type:vA("external_footprint_load_error"),external_footprint_load_error_id:Xt("external_footprint_load_error"),pcb_component_id:H(),source_component_id:H(),pcb_group_id:H().optional(),subcircuit_id:H().optional(),footprinter_string:H().optional(),error_type:vA("external_footprint_load_error").default("external_footprint_load_error")}).describe("Defines an error when an external footprint fails to load"),DCe=JI.extend({type:vA("circuit_json_footprint_load_error"),circuit_json_footprint_load_error_id:Xt("circuit_json_footprint_load_error"),pcb_component_id:H(),source_component_id:H(),pcb_group_id:H().optional(),subcircuit_id:H().optional(),error_type:vA("circuit_json_footprint_load_error").default("circuit_json_footprint_load_error"),circuit_json:be(Xc()).optional()}).describe("Defines an error when a circuit JSON footprint fails to load"),SCe=te({type:vA("pcb_group"),pcb_group_id:Xt("pcb_group"),source_group_id:H(),is_subcircuit:OA().optional(),subcircuit_id:H().optional(),width:rn.optional(),height:rn.optional(),center:fn,display_offset_x:H().optional().describe("How to display the x offset for this group, usually corresponding with how the user specified it"),display_offset_y:H().optional().describe("How to display the y offset for this group, usually corresponding with how the user specified it"),outline:be(fn).optional(),anchor_position:fn.optional(),anchor_alignment:Gk.default("center"),position_mode:et(["packed","relative_to_group_anchor","none"]).optional(),positioned_relative_to_pcb_group_id:H().optional(),positioned_relative_to_pcb_board_id:H().optional(),pcb_component_ids:be(H()),child_layout_mode:et(["packed","none"]).optional(),name:H().optional(),description:H().optional(),layout_mode:H().optional(),autorouter_configuration:te({trace_clearance:rn}).optional(),autorouter_used_string:H().optional()}).describe("Defines a group of components on the PCB"),bCe=JI.extend({type:vA("pcb_autorouting_error"),pcb_error_id:Xt("pcb_autorouting_error"),error_type:vA("pcb_autorouting_error").default("pcb_autorouting_error"),subcircuit_id:H().optional()}).describe("The autorouting has failed to route a portion of the board"),xCe=te({type:vA("pcb_manual_edit_conflict_warning"),pcb_manual_edit_conflict_warning_id:Xt("pcb_manual_edit_conflict_warning"),warning_type:vA("pcb_manual_edit_conflict_warning").default("pcb_manual_edit_conflict_warning"),message:H(),pcb_component_id:H(),pcb_group_id:H().optional(),subcircuit_id:H().optional(),source_component_id:H()}).describe("Warning emitted when a component has both manual placement and explicit pcbX/pcbY coordinates"),_Ce=te({type:vA("pcb_breakout_point"),pcb_breakout_point_id:Xt("pcb_breakout_point"),pcb_group_id:H(),subcircuit_id:H().optional(),source_trace_id:H().optional(),source_port_id:H().optional(),source_net_id:H().optional(),x:Et,y:Et}).describe("Defines a routing target within a pcb_group for a source_trace or source_net"),kCe=te({type:vA("pcb_ground_plane"),pcb_ground_plane_id:Xt("pcb_ground_plane"),source_pcb_ground_plane_id:H(),source_net_id:H(),pcb_group_id:H().optional(),subcircuit_id:H().optional()}).describe("Defines a ground plane on the PCB"),vCe=te({type:vA("pcb_ground_plane_region"),pcb_ground_plane_region_id:Xt("pcb_ground_plane_region"),pcb_ground_plane_id:H(),pcb_group_id:H().optional(),subcircuit_id:H().optional(),layer:Hr,points:be(fn)}).describe("Defines a polygon region of a ground plane"),FCe=te({type:vA("pcb_thermal_spoke"),pcb_thermal_spoke_id:Xt("pcb_thermal_spoke"),pcb_ground_plane_id:H(),shape:H(),spoke_count:WA(),spoke_thickness:Et,spoke_inner_diameter:Et,spoke_outer_diameter:Et,pcb_plated_hole_id:H().optional(),subcircuit_id:H().optional()}).describe("Pattern for connecting a ground plane to a plated hole"),NyA=te({type:vA("pcb_copper_pour"),pcb_copper_pour_id:Xt("pcb_copper_pour"),pcb_group_id:H().optional(),subcircuit_id:H().optional(),layer:Hr,source_net_id:H().optional(),covered_with_solder_mask:OA().optional().default(!0)}),MCe=NyA.extend({shape:vA("rect"),center:fn,width:rn,height:rn,rotation:AQ.optional()}),RCe=NyA.extend({shape:vA("brep"),brep_shape:fBe}),NCe=NyA.extend({shape:vA("polygon"),points:be(fn)}),GCe=hf("shape",[MCe,RCe,NCe]).describe("Defines a copper pour on the PCB."),LCe=JI.extend({type:vA("pcb_component_outside_board_error"),pcb_component_outside_board_error_id:Xt("pcb_component_outside_board_error"),error_type:vA("pcb_component_outside_board_error").default("pcb_component_outside_board_error"),pcb_component_id:H(),pcb_board_id:H(),component_center:fn,component_bounds:te({min_x:WA(),max_x:WA(),min_y:WA(),max_y:WA()}),subcircuit_id:H().optional(),source_component_id:H().optional()}).describe("Error emitted when a PCB component is placed outside the board boundaries"),UCe=JI.extend({type:vA("pcb_component_not_on_board_edge_error"),pcb_component_not_on_board_edge_error_id:Xt("pcb_component_not_on_board_edge_error"),error_type:vA("pcb_component_not_on_board_edge_error").default("pcb_component_not_on_board_edge_error"),pcb_component_id:H(),pcb_board_id:H(),component_center:fn,pad_to_nearest_board_edge_distance:WA(),source_component_id:H().optional(),subcircuit_id:H().optional()}).describe("Error emitted when a component that must be placed on the board edge is centered away from the edge"),HCe=JI.extend({type:vA("pcb_component_invalid_layer_error"),pcb_component_invalid_layer_error_id:Xt("pcb_component_invalid_layer_error"),error_type:vA("pcb_component_invalid_layer_error").default("pcb_component_invalid_layer_error"),pcb_component_id:H().optional(),source_component_id:H(),layer:Hr,subcircuit_id:H().optional()}).describe("Error emitted when a component is placed on an invalid layer (components can only be on 'top' or 'bottom' layers)"),YCe=JI.extend({type:vA("pcb_via_clearance_error"),pcb_error_id:Xt("pcb_error"),error_type:vA("pcb_via_clearance_error").default("pcb_via_clearance_error"),pcb_via_ids:be(H()).min(2),minimum_clearance:Et.optional(),actual_clearance:Et.optional(),pcb_center:te({x:WA().optional(),y:WA().optional()}).optional(),subcircuit_id:H().optional()}).describe("Error emitted when vias are closer than the allowed clearance"),JCe=te({type:vA("pcb_courtyard_rect"),pcb_courtyard_rect_id:Xt("pcb_courtyard_rect"),pcb_component_id:H(),pcb_group_id:H().optional(),subcircuit_id:H().optional(),center:fn,width:rn,height:rn,layer:km,color:H().optional()}).describe("Defines a courtyard rectangle on the PCB"),TCe=te({type:vA("pcb_courtyard_outline"),pcb_courtyard_outline_id:Xt("pcb_courtyard_outline"),pcb_component_id:H(),pcb_group_id:H().optional(),subcircuit_id:H().optional(),layer:km,outline:be(fn).min(2)}).describe("Defines a courtyard outline on the PCB"),PCe=te({type:vA("pcb_courtyard_polygon"),pcb_courtyard_polygon_id:Xt("pcb_courtyard_polygon"),pcb_component_id:H(),pcb_group_id:H().optional(),subcircuit_id:H().optional(),layer:km,points:be(fn).min(3),color:H().optional()}).describe("Defines a courtyard polygon on the PCB"),KCe=te({type:vA("pcb_courtyard_circle"),pcb_courtyard_circle_id:Xt("pcb_courtyard_circle"),pcb_component_id:H(),pcb_group_id:H().optional(),subcircuit_id:H().optional(),center:fn,radius:rn,layer:km,color:H().optional()}).describe("Defines a courtyard circle on the PCB"),qCe=te({type:vA("cad_component"),cad_component_id:H(),pcb_component_id:H(),source_component_id:H(),position:Nk,rotation:Nk.optional(),size:Nk.optional(),layer:Hr.optional(),subcircuit_id:H().optional(),footprinter_string:H().optional(),model_obj_url:H().optional(),model_stl_url:H().optional(),model_3mf_url:H().optional(),model_gltf_url:H().optional(),model_glb_url:H().optional(),model_step_url:H().optional(),model_wrl_url:H().optional(),model_asset:Ile.optional(),model_unit_to_mm_scale_factor:WA().optional(),model_jscad:Xc().optional(),show_as_translucent_model:OA().optional(),anchor_alignment:et(["center","xy_center_z_board"]).optional().default("center")}).describe("Defines a component on the PCB"),GyA=et(["sinewave","square","triangle","sawtooth"]),qXt=Nt([H(),WA()]).transform(t=>typeof t=="string"?t.endsWith("%")?parseFloat(t.slice(0,-1))/100:parseFloat(t):t).pipe(WA().min(0,"Duty cycle must be non-negative").max(1,"Duty cycle cannot be greater than 100%")),OCe=te({type:vA("simulation_voltage_source"),simulation_voltage_source_id:Xt("simulation_voltage_source"),is_dc_source:vA(!0).optional().default(!0),positive_source_port_id:H().optional(),negative_source_port_id:H().optional(),positive_source_net_id:H().optional(),negative_source_net_id:H().optional(),voltage:tx}).describe("Defines a DC voltage source for simulation"),WCe=te({type:vA("simulation_voltage_source"),simulation_voltage_source_id:Xt("simulation_voltage_source"),is_dc_source:vA(!1),terminal1_source_port_id:H().optional(),terminal2_source_port_id:H().optional(),terminal1_source_net_id:H().optional(),terminal2_source_net_id:H().optional(),voltage:tx.optional(),frequency:FM.optional(),peak_to_peak_voltage:tx.optional(),wave_shape:GyA.optional(),phase:AQ.optional(),duty_cycle:qXt.optional()}).describe("Defines an AC voltage source for simulation"),ZCe=Nt([OCe,WCe]).describe("Defines a voltage source for simulation"),OXt=Nt([H(),WA()]).transform(t=>typeof t=="string"?t.endsWith("%")?parseFloat(t.slice(0,-1))/100:parseFloat(t):t).pipe(WA().min(0,"Duty cycle must be non-negative").max(1,"Duty cycle cannot be greater than 100%")),VCe=te({type:vA("simulation_current_source"),simulation_current_source_id:Xt("simulation_current_source"),is_dc_source:vA(!0).optional().default(!0),positive_source_port_id:H().optional(),negative_source_port_id:H().optional(),positive_source_net_id:H().optional(),negative_source_net_id:H().optional(),current:h2}).describe("Defines a DC current source for simulation"),jCe=te({type:vA("simulation_current_source"),simulation_current_source_id:Xt("simulation_current_source"),is_dc_source:vA(!1),terminal1_source_port_id:H().optional(),terminal2_source_port_id:H().optional(),terminal1_source_net_id:H().optional(),terminal2_source_net_id:H().optional(),current:h2.optional(),frequency:FM.optional(),peak_to_peak_current:h2.optional(),wave_shape:GyA.optional(),phase:AQ.optional(),duty_cycle:OXt.optional()}).describe("Defines an AC current source for simulation"),zCe=Nt([VCe,jCe]).describe("Defines a current source for simulation"),XCe=Nt([vA("spice_dc_sweep"),vA("spice_dc_operating_point"),vA("spice_transient_analysis"),vA("spice_ac_analysis")]),$Ce=te({type:vA("simulation_experiment"),simulation_experiment_id:Xt("simulation_experiment"),name:H(),experiment_type:XCe,time_per_step:vT.optional(),start_time_ms:MM.optional(),end_time_ms:MM.optional()}).describe("Defines a simulation experiment configuration"),AQe=te({type:vA("simulation_transient_voltage_graph"),simulation_transient_voltage_graph_id:Xt("simulation_transient_voltage_graph"),simulation_experiment_id:H(),timestamps_ms:be(WA()).optional(),voltage_levels:be(WA()),source_component_id:H().optional(),subcircuit_connectivity_map_key:H().optional(),time_per_step:vT,start_time_ms:MM,end_time_ms:MM,name:H().optional(),color:H().optional()}).describe("Stores voltage measurements over time for a simulation"),eQe=te({type:vA("simulation_switch"),simulation_switch_id:Xt("simulation_switch"),source_component_id:H().optional(),closes_at:MM.optional(),opens_at:MM.optional(),starts_closed:OA().optional(),switching_frequency:FM.optional()}).describe("Defines a switch for simulation timing control"),tQe=te({type:vA("simulation_voltage_probe"),simulation_voltage_probe_id:Xt("simulation_voltage_probe"),source_component_id:H().optional(),name:H().optional(),signal_input_source_port_id:H().optional(),signal_input_source_net_id:H().optional(),reference_input_source_port_id:H().optional(),reference_input_source_net_id:H().optional(),subcircuit_id:H().optional(),color:H().optional()}).describe("Defines a voltage probe for simulation. If a reference input is not provided, it measures against ground. If a reference input is provided, it measures the differential voltage between two points.").superRefine((t,A)=>{if(t.reference_input_source_port_id||t.reference_input_source_net_id){const i=!!t.signal_input_source_port_id||!!t.reference_input_source_port_id,n=!!t.signal_input_source_net_id||!!t.reference_input_source_net_id;i&&n?A.addIssue({code:jt.custom,message:"Cannot mix port and net connections in a differential probe."}):i?(!t.signal_input_source_port_id||!t.reference_input_source_port_id)&&A.addIssue({code:jt.custom,message:"Differential port probe requires both signal_input_source_port_id and reference_input_source_port_id."}):n&&(!t.signal_input_source_net_id||!t.reference_input_source_net_id)&&A.addIssue({code:jt.custom,message:"Differential net probe requires both signal_input_source_net_id and reference_input_source_net_id."})}else!!t.signal_input_source_port_id==!!t.signal_input_source_net_id&&A.addIssue({code:jt.custom,message:"A voltage probe must have exactly one of signal_input_source_port_id or signal_input_source_net_id."})}),iQe=JI.extend({type:vA("simulation_unknown_experiment_error"),simulation_unknown_experiment_error_id:Xt("simulation_unknown_experiment_error"),error_type:vA("simulation_unknown_experiment_error").default("simulation_unknown_experiment_error"),simulation_experiment_id:H().optional(),subcircuit_id:H().optional()}).describe("An unknown error occurred during the simulation experiment."),nQe=te({type:vA("simulation_op_amp"),simulation_op_amp_id:Xt("simulation_op_amp"),source_component_id:H().optional(),inverting_input_source_port_id:H(),non_inverting_input_source_port_id:H(),output_source_port_id:H(),positive_supply_source_port_id:H(),negative_supply_source_port_id:H()}).describe("Defines a simple ideal operational amplifier for simulation"),oQe=Nt([Lle,Nle,Gle,Rle,Hle,Ule,QyA,lyA,Xj,CyA,ByA,hyA,EyA,uyA,fyA,yyA,myA,xyA,wyA,DyA,SyA,byA,pyA,dyA,Jle,Ple,Yle,_yA,kyA,vyA,Kle,qle,FyA,wBe,vBe,mCe,wCe,DCe,xCe,FBe,ECe,MBe,OBe,LBe,JBe,WBe,NBe,GBe,ZBe,VBe,SCe,XBe,$Be,ACe,eCe,sCe,tCe,iCe,nCe,oCe,TBe,PBe,jBe,zBe,KBe,qBe,YCe,aCe,rCe,gCe,cCe,ICe,lCe,BCe,CCe,QCe,bCe,hCe,_Ce,yCe,kCe,vCe,FCe,GCe,LCe,UCe,HCe,JCe,TCe,PCe,KCe,Ole,oBe,ABe,eBe,tBe,iBe,Xle,$le,sBe,nBe,Wle,aBe,gBe,rBe,BBe,CBe,QBe,hBe,dBe,EBe,uBe,qCe,ZCe,zCe,$Ce,AQe,eQe,tQe,iQe,nQe]),LyA=oQe;const sQe=Object.freeze(Object.defineProperty({__proto__:null,all_layers:Tle,any_circuit_element:oQe,any_soup_element:LyA,any_source_component:Rle,asset:Ile,base_circuit_json_error:JI,battery_capacity:cle,brep_shape:fBe,cad_component:qCe,capacitance:gyA,circuit_json_footprint_load_error:DCe,current:h2,distance:Et,duration_ms:vT,experiment_type:XCe,external_footprint_load_error:wCe,frequency:FM,getZodPrefixedIdWithDefault:Xt,inductance:ale,kicadAt:zj,kicadEffects:lle,kicadFont:IyA,kicadFootprintAttributes:Cle,kicadFootprintMetadata:Ele,kicadFootprintModel:hle,kicadFootprintPad:Qle,kicadFootprintProperties:Ble,kicadProperty:FT,kicadSymbolEffects:ple,kicadSymbolMetadata:yle,kicadSymbolPinNames:dle,kicadSymbolPinNumbers:ule,kicadSymbolProperties:fle,kicadSymbolProperty:Lk,layer_ref:Hr,layer_string:MyA,length:rn,ms:MM,ninePointAnchor:Gk,pcbRenderLayer:uXt,pcb_autorouting_error:bCe,pcb_board:ZBe,pcb_breakout_point:_Ce,pcb_component:wBe,pcb_component_invalid_layer_error:HCe,pcb_component_not_on_board_edge_error:UCe,pcb_component_outside_board_error:LCe,pcb_copper_pour:GCe,pcb_copper_pour_brep:RCe,pcb_copper_pour_polygon:NCe,pcb_copper_pour_rect:MCe,pcb_copper_text:tCe,pcb_courtyard_circle:KCe,pcb_courtyard_outline:TCe,pcb_courtyard_polygon:PCe,pcb_courtyard_rect:JCe,pcb_cutout:yCe,pcb_cutout_circle:dCe,pcb_cutout_path:fCe,pcb_cutout_polygon:pCe,pcb_cutout_rect:uCe,pcb_fabrication_note_dimension:cCe,pcb_fabrication_note_path:aCe,pcb_fabrication_note_rect:gCe,pcb_fabrication_note_text:rCe,pcb_footprint_overlap_error:hCe,pcb_ground_plane:kCe,pcb_ground_plane_region:vCe,pcb_group:SCe,pcb_hole:vBe,pcb_hole_circle_or_square_shape:DXt,pcb_hole_circle_shape:mXt,pcb_hole_oval_shape:SXt,pcb_hole_pill_shape:bXt,pcb_hole_rect_shape:wXt,pcb_hole_rotated_pill_shape:xXt,pcb_keepout:ECe,pcb_manual_edit_conflict_warning:xCe,pcb_missing_footprint_error:mCe,pcb_net:OBe,pcb_note_dimension:QCe,pcb_note_line:CCe,pcb_note_path:BCe,pcb_note_rect:lCe,pcb_note_text:ICe,pcb_panel:VBe,pcb_panelization_placement_error:zBe,pcb_placement_error:jBe,pcb_plated_hole:FBe,pcb_port:MBe,pcb_port_not_connected_error:qBe,pcb_port_not_matched_error:KBe,pcb_route_hint:yBe,pcb_route_hints:yXt,pcb_silkscreen_circle:nCe,pcb_silkscreen_line:$Be,pcb_silkscreen_oval:oCe,pcb_silkscreen_path:ACe,pcb_silkscreen_pill:sCe,pcb_silkscreen_rect:iCe,pcb_silkscreen_text:eCe,pcb_smtpad:NBe,pcb_smtpad_pill:RBe,pcb_solder_paste:GBe,pcb_text:LBe,pcb_thermal_spoke:FCe,pcb_trace:JBe,pcb_trace_error:TBe,pcb_trace_hint:XBe,pcb_trace_missing_error:PBe,pcb_trace_route_point:YBe,pcb_trace_route_point_via:HBe,pcb_trace_route_point_wire:UBe,pcb_via:WBe,pcb_via_clearance_error:YCe,point:fn,point3:Nk,point_with_bulge:pBe,port_arrangement:zle,position:QXt,position3:hXt,resistance:jj,ring:RyA,rotation:AQ,route_hint_point:mBe,schematic_arc:iBe,schematic_box:Ole,schematic_circle:tBe,schematic_component:Xle,schematic_component_port_arrangement_by_sides:jle,schematic_component_port_arrangement_by_size:Vle,schematic_debug_line:IBe,schematic_debug_object:BBe,schematic_debug_object_base:$j,schematic_debug_point:lBe,schematic_debug_rect:cBe,schematic_error:aBe,schematic_group:hBe,schematic_layout_error:gBe,schematic_line:ABe,schematic_manual_edit_conflict_warning:QBe,schematic_net_label:rBe,schematic_path:Wle,schematic_pin_styles:Zle,schematic_port:sBe,schematic_rect:eBe,schematic_sheet:dBe,schematic_symbol:$le,schematic_table:EBe,schematic_table_cell:uBe,schematic_text:oBe,schematic_trace:nBe,schematic_voltage_probe:CBe,simulation_ac_current_source:jCe,simulation_ac_voltage_source:WCe,simulation_current_source:zCe,simulation_dc_current_source:VCe,simulation_dc_voltage_source:OCe,simulation_experiment:$Ce,simulation_op_amp:nQe,simulation_switch:eQe,simulation_transient_voltage_graph:AQe,simulation_unknown_experiment_error:iQe,simulation_voltage_probe:tQe,simulation_voltage_source:ZCe,size:cyA,source_board:Yle,source_component_base:sI,source_component_internal_connection:Gle,source_failed_to_create_component_error:_le,source_group:Ule,source_i2c_misconfigured_error:FyA,source_interconnect:Fle,source_manually_placed_via:Ple,source_missing_property_error:xle,source_net:Hle,source_pcb_ground_plane:Jle,source_pin_missing_trace_warning:vyA,source_pin_must_be_connected_error:Kle,source_port:Nle,source_project_metadata:_yA,source_property_ignored_warning:kle,source_simple_battery:EyA,source_simple_capacitor:lyA,source_simple_chip:QyA,source_simple_crystal:ble,source_simple_current_source:Sle,source_simple_diode:Xj,source_simple_fiducial:wle,source_simple_ground:Dle,source_simple_inductor:uyA,source_simple_led:CyA,source_simple_mosfet:SyA,source_simple_op_amp:byA,source_simple_pin_header:fyA,source_simple_pinout:yyA,source_simple_potentiometer:pyA,source_simple_power_source:hyA,source_simple_push_button:dyA,source_simple_resistor:ByA,source_simple_resonator:myA,source_simple_switch:xyA,source_simple_test_point:DyA,source_simple_transistor:wyA,source_simple_voltage_probe:vle,source_simple_voltage_source:Mle,source_trace:Lle,source_trace_not_connected_error:kyA,supplier_name:mle,time:CXt,timestamp:gle,unknown_error_finding_part:qle,visible_layer:km,voltage:tx,wave_shape:GyA},Symbol.toStringTag,{value:"Module"})),MT=t=>typeof t=="number"&&!isNaN(t),RM=t=>typeof t=="string",sy=t=>typeof t=="function",ez=t=>RM(t)||sy(t)?t:null,UyA=t=>V.isValidElement(t)||RM(t)||sy(t)||MT(t);function WXt(t,A,e){e===void 0&&(e=300);const{scrollHeight:i,style:n}=t;requestAnimationFrame(()=>{n.minHeight="initial",n.height=i+"px",n.transition=`all ${e}ms`,requestAnimationFrame(()=>{n.height="0",n.padding="0",n.margin="0",setTimeout(A,e)})})}function tz(t){let{enter:A,exit:e,appendPosition:i=!1,collapse:n=!0,collapseDuration:o=300}=t;return function(s){let{children:r,position:a,preventExitTransition:g,done:c,nodeRef:I,isIn:l,playToast:B}=s;const C=i?`${A}--${a}`:A,Q=i?`${e}--${a}`:e,h=V.useRef(0);return V.useLayoutEffect(()=>{const E=I.current,u=C.split(" "),d=f=>{f.target===I.current&&(B(),E.removeEventListener("animationend",d),E.removeEventListener("animationcancel",d),h.current===0&&f.type!=="animationcancel"&&E.classList.remove(...u))};E.classList.add(...u),E.addEventListener("animationend",d),E.addEventListener("animationcancel",d)},[]),V.useEffect(()=>{const E=I.current,u=()=>{E.removeEventListener("animationend",u),n?WXt(E,c,o):c()};l||(g?u():(h.current=1,E.className+=` ${Q}`,E.addEventListener("animationend",u)))},[l]),Cn.createElement(Cn.Fragment,null,r)}}function rQe(t,A){return t!=null?{content:t.content,containerId:t.props.containerId,id:t.props.toastId,theme:t.props.theme,type:t.props.type,data:t.props.data||{},isLoading:t.props.isLoading,icon:t.props.icon,status:A}:{}}const rp=new Map;let RT=[];const HyA=new Set,ZXt=t=>HyA.forEach(A=>A(t)),aQe=()=>rp.size>0;function gQe(t,A){var e;if(A)return!((e=rp.get(A))==null||!e.isToastActive(t));let i=!1;return rp.forEach(n=>{n.isToastActive(t)&&(i=!0)}),i}function cQe(t,A){UyA(t)&&(aQe()||RT.push({content:t,options:A}),rp.forEach(e=>{e.buildToast(t,A)}))}function IQe(t,A){rp.forEach(e=>{A!=null&&A!=null&&A.containerId?A?.containerId===e.id&&e.toggle(t,A?.id):e.toggle(t,A?.id)})}function VXt(t){const{subscribe:A,getSnapshot:e,setProps:i}=V.useRef((function(o){const s=o.containerId||1;return{subscribe(r){const a=(function(c,I,l){let B=1,C=0,Q=[],h=[],E=[],u=I;const d=new Map,f=new Set,m=()=>{E=Array.from(d.values()),f.forEach(S=>S())},w=S=>{h=S==null?[]:h.filter(_=>_!==S),m()},D=S=>{const{toastId:_,onOpen:b,updateId:N,children:F}=S.props,L=N==null;S.staleId&&d.delete(S.staleId),d.set(_,S),h=[...h,S.props.toastId].filter(Y=>Y!==S.staleId),m(),l(rQe(S,L?"added":"updated")),L&&sy(b)&&b(V.isValidElement(F)&&F.props)};return{id:c,props:u,observe:S=>(f.add(S),()=>f.delete(S)),toggle:(S,_)=>{d.forEach(b=>{_!=null&&_!==b.props.toastId||sy(b.toggle)&&b.toggle(S)})},removeToast:w,toasts:d,clearQueue:()=>{C-=Q.length,Q=[]},buildToast:(S,_)=>{if((tA=>{let{containerId:sA,toastId:aA,updateId:hA}=tA;const bA=sA?sA!==c:c!==1,_A=d.has(aA)&&hA==null;return bA||_A})(_))return;const{toastId:b,updateId:N,data:F,staleId:L,delay:Y}=_,J=()=>{w(b)},q=N==null;q&&C++;const Z={...u,style:u.toastStyle,key:B++,...Object.fromEntries(Object.entries(_).filter(tA=>{let[sA,aA]=tA;return aA!=null})),toastId:b,updateId:N,data:F,closeToast:J,isIn:!1,className:ez(_.className||u.toastClassName),bodyClassName:ez(_.bodyClassName||u.bodyClassName),progressClassName:ez(_.progressClassName||u.progressClassName),autoClose:!_.isLoading&&(X=_.autoClose,eA=u.autoClose,X===!1||MT(X)&&X>0?X:eA),deleteToast(){const tA=d.get(b),{onClose:sA,children:aA}=tA.props;sy(sA)&&sA(V.isValidElement(aA)&&aA.props),l(rQe(tA,"removed")),d.delete(b),C--,C<0&&(C=0),Q.length>0?D(Q.shift()):m()}};var X,eA;Z.closeButton=u.closeButton,_.closeButton===!1||UyA(_.closeButton)?Z.closeButton=_.closeButton:_.closeButton===!0&&(Z.closeButton=!UyA(u.closeButton)||u.closeButton);let gA=S;V.isValidElement(S)&&!RM(S.type)?gA=V.cloneElement(S,{closeToast:J,toastProps:Z,data:F}):sy(S)&&(gA=S({closeToast:J,toastProps:Z,data:F}));const iA={content:gA,props:Z,staleId:L};u.limit&&u.limit>0&&C>u.limit&&q?Q.push(iA):MT(Y)?setTimeout(()=>{D(iA)},Y):D(iA)},setProps(S){u=S},setToggle:(S,_)=>{d.get(S).toggle=_},isToastActive:S=>h.some(_=>_===S),getSnapshot:()=>E}})(s,o,ZXt);rp.set(s,a);const g=a.observe(r);return RT.forEach(c=>cQe(c.content,c.options)),RT=[],()=>{g(),rp.delete(s)}},setProps(r){var a;(a=rp.get(s))==null||a.setProps(r)},getSnapshot(){var r;return(r=rp.get(s))==null?void 0:r.getSnapshot()}}})(t)).current;i(t);const n=V.useSyncExternalStore(A,e,e);return{getToastToRender:function(o){if(!n)return[];const s=new Map;return t.newestOnTop&&n.reverse(),n.forEach(r=>{const{position:a}=r.props;s.has(a)||s.set(a,[]),s.get(a).push(r)}),Array.from(s,r=>o(r[0],r[1]))},isToastActive:gQe,count:n?.length}}function jXt(t){const[A,e]=V.useState(!1),[i,n]=V.useState(!1),o=V.useRef(null),s=V.useRef({start:0,delta:0,removalDistance:0,canCloseOnClick:!0,canDrag:!1,didMove:!1}).current,{autoClose:r,pauseOnHover:a,closeToast:g,onClick:c,closeOnClick:I}=t;var l,B;function C(){e(!0)}function Q(){e(!1)}function h(d){const f=o.current;s.canDrag&&f&&(s.didMove=!0,A&&Q(),s.delta=t.draggableDirection==="x"?d.clientX-s.start:d.clientY-s.start,s.start!==d.clientX&&(s.canCloseOnClick=!1),f.style.transform=`translate3d(${t.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 E(){document.removeEventListener("pointermove",h),document.removeEventListener("pointerup",E);const d=o.current;if(s.canDrag&&s.didMove&&d){if(s.canDrag=!1,Math.abs(s.delta)>s.removalDistance)return n(!0),t.closeToast(),void t.collapseAll();d.style.transition="transform 0.2s, opacity 0.2s",d.style.removeProperty("transform"),d.style.removeProperty("opacity")}}(B=rp.get((l={id:t.toastId,containerId:t.containerId,fn:e}).containerId||1))==null||B.setToggle(l.id,l.fn),V.useEffect(()=>{if(t.pauseOnFocusLoss)return document.hasFocus()||Q(),window.addEventListener("focus",C),window.addEventListener("blur",Q),()=>{window.removeEventListener("focus",C),window.removeEventListener("blur",Q)}},[t.pauseOnFocusLoss]);const u={onPointerDown:function(d){if(t.draggable===!0||t.draggable===d.pointerType){s.didMove=!1,document.addEventListener("pointermove",h),document.addEventListener("pointerup",E);const f=o.current;s.canCloseOnClick=!0,s.canDrag=!0,f.style.transition="none",t.draggableDirection==="x"?(s.start=d.clientX,s.removalDistance=f.offsetWidth*(t.draggablePercent/100)):(s.start=d.clientY,s.removalDistance=f.offsetHeight*(t.draggablePercent===80?1.5*t.draggablePercent:t.draggablePercent)/100)}},onPointerUp:function(d){const{top:f,bottom:m,left:w,right:D}=o.current.getBoundingClientRect();d.nativeEvent.type!=="touchend"&&t.pauseOnHover&&d.clientX>=w&&d.clientX<=D&&d.clientY>=f&&d.clientY<=m?Q():C()}};return r&&a&&(u.onMouseEnter=Q,t.stacked||(u.onMouseLeave=C)),I&&(u.onClick=d=>{c&&c(d),s.canCloseOnClick&&g()}),{playToast:C,pauseToast:Q,isRunning:A,preventExitTransition:i,toastRef:o,eventHandlers:u}}function zXt(t){let{delay:A,isRunning:e,closeToast:i,type:n="default",hide:o,className:s,style:r,controlledProgress:a,progress:g,rtl:c,isIn:I,theme:l}=t;const B=o||a&&g===0,C={...r,animationDuration:`${A}ms`,animationPlayState:e?"running":"paused"};a&&(C.transform=`scaleX(${g})`);const Q=uw("Toastify__progress-bar",a?"Toastify__progress-bar--controlled":"Toastify__progress-bar--animated",`Toastify__progress-bar-theme--${l}`,`Toastify__progress-bar--${n}`,{"Toastify__progress-bar--rtl":c}),h=sy(s)?s({rtl:c,type:n,defaultClassName:Q}):uw(Q,s),E={[a&&g>=1?"onTransitionEnd":"onAnimationEnd"]:a&&g<1?null:()=>{I&&i()}};return Cn.createElement("div",{className:"Toastify__progress-bar--wrp","data-hidden":B},Cn.createElement("div",{className:`Toastify__progress-bar--bg Toastify__progress-bar-theme--${l} Toastify__progress-bar--${n}`}),Cn.createElement("div",{role:"progressbar","aria-hidden":B?"true":"false","aria-label":"notification timer",className:h,style:C,...E}))}let XXt=1;const lQe=()=>""+XXt++;function $Xt(t){return t&&(RM(t.toastId)||MT(t.toastId))?t.toastId:lQe()}function NT(t,A){return cQe(t,A),A.toastId}function iz(t,A){return{...A,type:A&&A.type||t,toastId:$Xt(A)}}function nz(t){return(A,e)=>NT(A,iz(t,e))}function nc(t,A){return NT(t,iz("default",A))}nc.loading=(t,A)=>NT(t,iz("default",{isLoading:!0,autoClose:!1,closeOnClick:!1,closeButton:!1,draggable:!1,...A})),nc.promise=function(t,A,e){let i,{pending:n,error:o,success:s}=A;n&&(i=RM(n)?nc.loading(n,e):nc.loading(n.render,{...e,...n}));const r={isLoading:null,autoClose:null,closeOnClick:null,closeButton:null,draggable:null},a=(c,I,l)=>{if(I==null)return void nc.dismiss(i);const B={type:c,...r,...e,data:l},C=RM(I)?{render:I}:I;return i?nc.update(i,{...B,...C}):nc(C.render,{...B,...C}),l},g=sy(t)?t():t;return g.then(c=>a("success",s,c)).catch(c=>a("error",o,c)),g},nc.success=nz("success"),nc.info=nz("info"),nc.error=nz("error"),nc.warning=nz("warning"),nc.warn=nc.warning,nc.dark=(t,A)=>NT(t,iz("default",{theme:"dark",...A})),nc.dismiss=function(t){(function(A){var e;if(aQe()){if(A==null||RM(e=A)||MT(e))rp.forEach(i=>{i.removeToast(A)});else if(A&&("containerId"in A||"id"in A)){const i=rp.get(A.containerId);i?i.removeToast(A.id):rp.forEach(n=>{n.removeToast(A.id)})}}else RT=RT.filter(i=>A!=null&&i.options.toastId!==A)})(t)},nc.clearWaitingQueue=function(t){t===void 0&&(t={}),rp.forEach(A=>{!A.props.limit||t.containerId&&A.id!==t.containerId||A.clearQueue()})},nc.isActive=gQe,nc.update=function(t,A){A===void 0&&(A={});const e=((i,n)=>{var o;let{containerId:s}=n;return(o=rp.get(s||1))==null?void 0:o.toasts.get(i)})(t,A);if(e){const{props:i,content:n}=e,o={delay:100,...i,...A,toastId:A.toastId||t,updateId:lQe()};o.toastId!==t&&(o.staleId=t);const s=o.render||n;delete o.render,NT(s,o)}},nc.done=t=>{nc.update(t,{progress:1})},nc.onChange=function(t){return HyA.add(t),()=>{HyA.delete(t)}},nc.play=t=>IQe(!0,t),nc.pause=t=>IQe(!1,t);const A6t=typeof window<"u"?V.useLayoutEffect:V.useEffect,oz=t=>{let{theme:A,type:e,isLoading:i,...n}=t;return Cn.createElement("svg",{viewBox:"0 0 24 24",width:"100%",height:"100%",fill:A==="colored"?"currentColor":`var(--toastify-icon-color-${e})`,...n})},YyA={info:function(t){return Cn.createElement(oz,{...t},Cn.createElement("path",{d:"M12 0a12 12 0 1012 12A12.013 12.013 0 0012 0zm.25 5a1.5 1.5 0 11-1.5 1.5 1.5 1.5 0 011.5-1.5zm2.25 13.5h-4a1 1 0 010-2h.75a.25.25 0 00.25-.25v-4.5a.25.25 0 00-.25-.25h-.75a1 1 0 010-2h1a2 2 0 012 2v4.75a.25.25 0 00.25.25h.75a1 1 0 110 2z"}))},warning:function(t){return Cn.createElement(oz,{...t},Cn.createElement("path",{d:"M23.32 17.191L15.438 2.184C14.728.833 13.416 0 11.996 0c-1.42 0-2.733.833-3.443 2.184L.533 17.448a4.744 4.744 0 000 4.368C1.243 23.167 2.555 24 3.975 24h16.05C22.22 24 24 22.044 24 19.632c0-.904-.251-1.746-.68-2.44zm-9.622 1.46c0 1.033-.724 1.823-1.698 1.823s-1.698-.79-1.698-1.822v-.043c0-1.028.724-1.822 1.698-1.822s1.698.79 1.698 1.822v.043zm.039-12.285l-.84 8.06c-.057.581-.408.943-.897.943-.49 0-.84-.367-.896-.942l-.84-8.065c-.057-.624.25-1.095.779-1.095h1.91c.528.005.84.476.784 1.1z"}))},success:function(t){return Cn.createElement(oz,{...t},Cn.createElement("path",{d:"M12 0a12 12 0 1012 12A12.014 12.014 0 0012 0zm6.927 8.2l-6.845 9.289a1.011 1.011 0 01-1.43.188l-4.888-3.908a1 1 0 111.25-1.562l4.076 3.261 6.227-8.451a1 1 0 111.61 1.183z"}))},error:function(t){return Cn.createElement(oz,{...t},Cn.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 Cn.createElement("div",{className:"Toastify__spinner"})}},e6t=t=>{const{isRunning:A,preventExitTransition:e,toastRef:i,eventHandlers:n,playToast:o}=jXt(t),{closeButton:s,children:r,autoClose:a,onClick:g,type:c,hideProgressBar:I,closeToast:l,transition:B,position:C,className:Q,style:h,bodyClassName:E,bodyStyle:u,progressClassName:d,progressStyle:f,updateId:m,role:w,progress:D,rtl:S,toastId:_,deleteToast:b,isIn:N,isLoading:F,closeOnClick:L,theme:Y}=t,J=uw("Toastify__toast",`Toastify__toast-theme--${Y}`,`Toastify__toast--${c}`,{"Toastify__toast--rtl":S},{"Toastify__toast--close-on-click":L}),q=sy(Q)?Q({rtl:S,position:C,type:c,defaultClassName:J}):uw(J,Q),Z=(function(iA){let{theme:tA,type:sA,isLoading:aA,icon:hA}=iA,bA=null;const _A={theme:tA,type:sA};return hA===!1||(sy(hA)?bA=hA({..._A,isLoading:aA}):V.isValidElement(hA)?bA=V.cloneElement(hA,_A):aA?bA=YyA.spinner():(HA=>HA in YyA)(sA)&&(bA=YyA[sA](_A))),bA})(t),X=!!D||!a,eA={closeToast:l,type:c,theme:Y};let gA=null;return s===!1||(gA=sy(s)?s(eA):V.isValidElement(s)?V.cloneElement(s,eA):(function(iA){let{closeToast:tA,theme:sA,ariaLabel:aA="close"}=iA;return Cn.createElement("button",{className:`Toastify__close-button Toastify__close-button--${sA}`,type:"button",onClick:hA=>{hA.stopPropagation(),tA(hA)},"aria-label":aA},Cn.createElement("svg",{"aria-hidden":"true",viewBox:"0 0 14 16"},Cn.createElement("path",{fillRule:"evenodd",d:"M7.71 8.23l3.75 3.75-1.48 1.48-3.75-3.75-3.75 3.75L1 11.98l3.75-3.75L1 4.48 2.48 3l3.75 3.75L9.98 3l1.48 1.48-3.75 3.75z"})))})(eA)),Cn.createElement(B,{isIn:N,done:b,position:C,preventExitTransition:e,nodeRef:i,playToast:o},Cn.createElement("div",{id:_,onClick:g,"data-in":N,className:q,...n,style:h,ref:i},Cn.createElement("div",{...N&&{role:w},className:sy(E)?E({type:c}):uw("Toastify__toast-body",E),style:u},Z!=null&&Cn.createElement("div",{className:uw("Toastify__toast-icon",{"Toastify--animate-icon Toastify__zoom-enter":!F})},Z),Cn.createElement("div",null,r)),gA,Cn.createElement(zXt,{...m&&!X?{key:`pb-${m}`}:{},rtl:S,theme:Y,delay:a,isRunning:A,isIn:N,closeToast:l,hide:I,type:c,style:f,className:d,controlledProgress:X,progress:D||0})))},sz=function(t,A){return A===void 0&&(A=!1),{enter:`Toastify--animate Toastify__${t}-enter`,exit:`Toastify--animate Toastify__${t}-exit`,appendPosition:A}},t6t=tz(sz("bounce",!0));tz(sz("slide",!0)),tz(sz("zoom")),tz(sz("flip"));const i6t={position:"top-right",transition:t6t,autoClose:5e3,closeButton:!0,pauseOnHover:!0,pauseOnFocusLoss:!0,draggable:"touch",draggablePercent:80,draggableDirection:"x",role:"alert",theme:"light"};function n6t(t){let A={...i6t,...t};const e=t.stacked,[i,n]=V.useState(!0),o=V.useRef(null),{getToastToRender:s,isToastActive:r,count:a}=VXt(A),{className:g,style:c,rtl:I,containerId:l}=A;function B(Q){const h=uw("Toastify__toast-container",`Toastify__toast-container--${Q}`,{"Toastify__toast-container--rtl":I});return sy(g)?g({position:Q,rtl:I,defaultClassName:h}):uw(h,ez(g))}function C(){e&&(n(!0),nc.play())}return A6t(()=>{if(e){var Q;const h=o.current.querySelectorAll('[data-in="true"]'),E=12,u=(Q=A.position)==null?void 0:Q.includes("top");let d=0,f=0;Array.from(h).reverse().forEach((m,w)=>{const D=m;D.classList.add("Toastify__toast--stacked"),w>0&&(D.dataset.collapsed=`${i}`),D.dataset.pos||(D.dataset.pos=u?"top":"bot");const S=d*(i?.2:1)+(i?0:E*w);D.style.setProperty("--y",`${u?S:-1*S}px`),D.style.setProperty("--g",`${E}`),D.style.setProperty("--s",""+(1-(i?f:0))),d+=D.offsetHeight,f+=.025})}},[i,a,e]),Cn.createElement("div",{ref:o,className:"Toastify",id:l,onMouseEnter:()=>{e&&(n(!1),nc.pause())},onMouseLeave:C},s((Q,h)=>{const E=h.length?{...c}:{...c,pointerEvents:"none"};return Cn.createElement("div",{className:B(Q),style:E,key:`container-${Q}`},h.map(u=>{let{content:d,props:f}=u;return Cn.createElement(e6t,{...f,stacked:e,collapseAll:C,isIn:r(f.toastId,f.containerId),style:f.style,key:`toast-${f.key}`},d)}))}))}function o6t(){var t=':root{--toastify-color-light:#fff;--toastify-color-dark:#121212;--toastify-color-info:#3498db;--toastify-color-success:#07bc0c;--toastify-color-warning:#f1c40f;--toastify-color-error:#e74c3c;--toastify-color-transparent:hsla(0,0%,100%,.7);--toastify-icon-color-info:var(--toastify-color-info);--toastify-icon-color-success:var(--toastify-color-success);--toastify-icon-color-warning:var(--toastify-color-warning);--toastify-icon-color-error:var(--toastify-color-error);--toastify-toast-width:320px;--toastify-toast-offset:16px;--toastify-toast-top:max(var(--toastify-toast-offset),env(safe-area-inset-top));--toastify-toast-right:max(var(--toastify-toast-offset),env(safe-area-inset-right));--toastify-toast-left:max(var(--toastify-toast-offset),env(safe-area-inset-left));--toastify-toast-bottom:max(var(--toastify-toast-offset),env(safe-area-inset-bottom));--toastify-toast-background:#fff;--toastify-toast-min-height:64px;--toastify-toast-max-height:800px;--toastify-toast-bd-radius:6px;--toastify-font-family:sans-serif;--toastify-z-index:9999;--toastify-text-color-light:#757575;--toastify-text-color-dark:#fff;--toastify-text-color-info:#fff;--toastify-text-color-success:#fff;--toastify-text-color-warning:#fff;--toastify-text-color-error:#fff;--toastify-spinner-color:#616161;--toastify-spinner-color-empty-area:#e0e0e0;--toastify-color-progress-light:linear-gradient(90deg,#4cd964,#5ac8fa,#007aff,#34aadc,#5856d6,#ff2d55);--toastify-color-progress-dark:#bb86fc;--toastify-color-progress-info:var(--toastify-color-info);--toastify-color-progress-success:var(--toastify-color-success);--toastify-color-progress-warning:var(--toastify-color-warning);--toastify-color-progress-error:var(--toastify-color-error);--toastify-color-progress-bgo:0.2}.Toastify__toast-container{z-index:var(--toastify-z-index);-webkit-transform:translateZ(var(--toastify-z-index));position:fixed;padding:4px;width:var(--toastify-toast-width);box-sizing:border-box;color:#fff}.Toastify__toast-container--top-left{top:var(--toastify-toast-top);left:var(--toastify-toast-left)}.Toastify__toast-container--top-center{top:var(--toastify-toast-top);left:50%;transform:translateX(-50%)}.Toastify__toast-container--top-right{top:var(--toastify-toast-top);right:var(--toastify-toast-right)}.Toastify__toast-container--bottom-left{bottom:var(--toastify-toast-bottom);left:var(--toastify-toast-left)}.Toastify__toast-container--bottom-center{bottom:var(--toastify-toast-bottom);left:50%;transform:translateX(-50%)}.Toastify__toast-container--bottom-right{bottom:var(--toastify-toast-bottom);right:var(--toastify-toast-right)}@media only screen and (max-width:480px){.Toastify__toast-container{width:100vw;padding:0;left:env(safe-area-inset-left);margin:0}.Toastify__toast-container--top-center,.Toastify__toast-container--top-left,.Toastify__toast-container--top-right{top:env(safe-area-inset-top);transform:translateX(0)}.Toastify__toast-container--bottom-center,.Toastify__toast-container--bottom-left,.Toastify__toast-container--bottom-right{bottom:env(safe-area-inset-bottom);transform:translateX(0)}.Toastify__toast-container--rtl{right:env(safe-area-inset-right);left:auto}}.Toastify__toast{--y:0;position:relative;-ms-touch-action:none;touch-action:none;min-height:var(--toastify-toast-min-height);box-sizing:border-box;margin-bottom:1rem;padding:8px;border-radius:var(--toastify-toast-bd-radius);box-shadow:0 4px 12px rgba(0,0,0,.1);display:-ms-flexbox;display:flex;-ms-flex-pack:justify;justify-content:space-between;max-height:var(--toastify-toast-max-height);font-family:var(--toastify-font-family);cursor:default;direction:ltr;z-index:0;overflow:hidden}.Toastify__toast--stacked{position:absolute;width:100%;transform:translate3d(0,var(--y),0) scale(var(--s));transition:transform .3s}.Toastify__toast--stacked[data-collapsed] .Toastify__close-button,.Toastify__toast--stacked[data-collapsed] .Toastify__toast-body{transition:opacity .1s}.Toastify__toast--stacked[data-collapsed=false]{overflow:visible}.Toastify__toast--stacked[data-collapsed=true]:not(:last-child)>*{opacity:0}.Toastify__toast--stacked:after{content:"";position:absolute;left:0;right:0;height:calc(var(--g) * 1px);bottom:100%}.Toastify__toast--stacked[data-pos=top]{top:0}.Toastify__toast--stacked[data-pos=bot]{bottom:0}.Toastify__toast--stacked[data-pos=bot].Toastify__toast--stacked:before{transform-origin:top}.Toastify__toast--stacked[data-pos=top].Toastify__toast--stacked:before{transform-origin:bottom}.Toastify__toast--stacked:before{content:"";position:absolute;left:0;right:0;bottom:0;height:100%;transform:scaleY(3);z-index:-1}.Toastify__toast--rtl{direction:rtl}.Toastify__toast--close-on-click{cursor:pointer}.Toastify__toast-body{margin:auto 0;-ms-flex:1 1 auto;flex:1 1 auto;padding:6px;display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center}.Toastify__toast-body>div:last-child{word-break:break-word;-ms-flex:1;flex:1}.Toastify__toast-icon{-webkit-margin-end:10px;margin-inline-end:10px;width:20px;-ms-flex-negative:0;flex-shrink:0;display:-ms-flexbox;display:flex}.Toastify--animate{animation-fill-mode:both;animation-duration:.5s}.Toastify--animate-icon{animation-fill-mode:both;animation-duration:.3s}@media only screen and (max-width:480px){.Toastify__toast{margin-bottom:0;border-radius:0}}.Toastify__toast-theme--dark{background:var(--toastify-color-dark);color:var(--toastify-text-color-dark)}.Toastify__toast-theme--colored.Toastify__toast--default,.Toastify__toast-theme--light{background:var(--toastify-color-light);color:var(--toastify-text-color-light)}.Toastify__toast-theme--colored.Toastify__toast--info{color:var(--toastify-text-color-info);background:var(--toastify-color-info)}.Toastify__toast-theme--colored.Toastify__toast--success{color:var(--toastify-text-color-success);background:var(--toastify-color-success)}.Toastify__toast-theme--colored.Toastify__toast--warning{color:var(--toastify-text-color-warning);background:var(--toastify-color-warning)}.Toastify__toast-theme--colored.Toastify__toast--error{color:var(--toastify-text-color-error);background:var(--toastify-color-error)}.Toastify__progress-bar-theme--light{background:var(--toastify-color-progress-light)}.Toastify__progress-bar-theme--dark{background:var(--toastify-color-progress-dark)}.Toastify__progress-bar--info{background:var(--toastify-color-progress-info)}.Toastify__progress-bar--success{background:var(--toastify-color-progress-success)}.Toastify__progress-bar--warning{background:var(--toastify-color-progress-warning)}.Toastify__progress-bar--error{background:var(--toastify-color-progress-error)}.Toastify__progress-bar-theme--colored.Toastify__progress-bar--error,.Toastify__progress-bar-theme--colored.Toastify__progress-bar--info,.Toastify__progress-bar-theme--colored.Toastify__progress-bar--success,.Toastify__progress-bar-theme--colored.Toastify__progress-bar--warning{background:var(--toastify-color-transparent)}.Toastify__close-button{color:#fff;background:transparent;outline:none;border:none;padding:0;cursor:pointer;opacity:.7;transition:.3s ease;-ms-flex-item-align:start;align-self:flex-start;z-index:1}.Toastify__close-button--light{color:#000;opacity:.3}.Toastify__close-button>svg{fill:currentColor;height:16px;width:14px}.Toastify__close-button:focus,.Toastify__close-button:hover{opacity:1}@keyframes Toastify__trackProgress{0%{transform:scaleX(1)}to{transform:scaleX(0)}}.Toastify__progress-bar{position:absolute;bottom:0;left:0;width:100%;height:100%;z-index:var(--toastify-z-index);opacity:.7;transform-origin:left;border-bottom-left-radius:var(--toastify-toast-bd-radius)}.Toastify__progress-bar--animated{animation:Toastify__trackProgress linear 1 forwards}.Toastify__progress-bar--controlled{transition:transform .2s}.Toastify__progress-bar--rtl{right:0;left:auto;transform-origin:right;border-bottom-left-radius:0;border-bottom-right-radius:var(--toastify-toast-bd-radius)}.Toastify__progress-bar--wrp{position:absolute;bottom:0;left:0;width:100%;height:5px;border-bottom-left-radius:var(--toastify-toast-bd-radius)}.Toastify__progress-bar--wrp[data-hidden=true]{opacity:0}.Toastify__progress-bar--bg{opacity:var(--toastify-color-progress-bgo);width:100%;height:100%}.Toastify__spinner{width:20px;height:20px;box-sizing:border-box;border:2px solid;border-radius:100%;border-color:var(--toastify-spinner-color-empty-area);border-right-color:var(--toastify-spinner-color);animation:Toastify__spin .65s linear infinite}@keyframes Toastify__bounceInRight{0%,60%,75%,90%,to{animation-timing-function:cubic-bezier(.215,.61,.355,1)}0%{opacity:0;transform:translate3d(3000px,0,0)}60%{opacity:1;transform:translate3d(-25px,0,0)}75%{transform:translate3d(10px,0,0)}90%{transform:translate3d(-5px,0,0)}to{transform:none}}@keyframes Toastify__bounceOutRight{20%{opacity:1;transform:translate3d(-20px,var(--y),0)}to{opacity:0;transform:translate3d(2000px,var(--y),0)}}@keyframes Toastify__bounceInLeft{0%,60%,75%,90%,to{animation-timing-function:cubic-bezier(.215,.61,.355,1)}0%{opacity:0;transform:translate3d(-3000px,0,0)}60%{opacity:1;transform:translate3d(25px,0,0)}75%{transform:translate3d(-10px,0,0)}90%{transform:translate3d(5px,0,0)}to{transform:none}}@keyframes Toastify__bounceOutLeft{20%{opacity:1;transform:translate3d(20px,var(--y),0)}to{opacity:0;transform:translate3d(-2000px,var(--y),0)}}@keyframes Toastify__bounceInUp{0%,60%,75%,90%,to{animation-timing-function:cubic-bezier(.215,.61,.355,1)}0%{opacity:0;transform:translate3d(0,3000px,0)}60%{opacity:1;transform:translate3d(0,-20px,0)}75%{transform:translate3d(0,10px,0)}90%{transform:translate3d(0,-5px,0)}to{transform:translateZ(0)}}@keyframes Toastify__bounceOutUp{20%{transform:translate3d(0,calc(var(--y) - 10px),0)}40%,45%{opacity:1;transform:translate3d(0,calc(var(--y) + 20px),0)}to{opacity:0;transform:translate3d(0,-2000px,0)}}@keyframes Toastify__bounceInDown{0%,60%,75%,90%,to{animation-timing-function:cubic-bezier(.215,.61,.355,1)}0%{opacity:0;transform:translate3d(0,-3000px,0)}60%{opacity:1;transform:translate3d(0,25px,0)}75%{transform:translate3d(0,-10px,0)}90%{transform:translate3d(0,5px,0)}to{transform:none}}@keyframes Toastify__bounceOutDown{20%{transform:translate3d(0,calc(var(--y) - 10px),0)}40%,45%{opacity:1;transform:translate3d(0,calc(var(--y) + 20px),0)}to{opacity:0;transform:translate3d(0,2000px,0)}}.Toastify__bounce-enter--bottom-left,.Toastify__bounce-enter--top-left{animation-name:Toastify__bounceInLeft}.Toastify__bounce-enter--bottom-right,.Toastify__bounce-enter--top-right{animation-name:Toastify__bounceInRight}.Toastify__bounce-enter--top-center{animation-name:Toastify__bounceInDown}.Toastify__bounce-enter--bottom-center{animation-name:Toastify__bounceInUp}.Toastify__bounce-exit--bottom-left,.Toastify__bounce-exit--top-left{animation-name:Toastify__bounceOutLeft}.Toastify__bounce-exit--bottom-right,.Toastify__bounce-exit--top-right{animation-name:Toastify__bounceOutRight}.Toastify__bounce-exit--top-center{animation-name:Toastify__bounceOutUp}.Toastify__bounce-exit--bottom-center{animation-name:Toastify__bounceOutDown}@keyframes Toastify__zoomIn{0%{opacity:0;transform:scale3d(.3,.3,.3)}50%{opacity:1}}@keyframes Toastify__zoomOut{0%{opacity:1}50%{opacity:0;transform:translate3d(0,var(--y),0) scale3d(.3,.3,.3)}to{opacity:0}}.Toastify__zoom-enter{animation-name:Toastify__zoomIn}.Toastify__zoom-exit{animation-name:Toastify__zoomOut}@keyframes Toastify__flipIn{0%{transform:perspective(400px) rotateX(90deg);animation-timing-function:ease-in;opacity:0}40%{transform:perspective(400px) rotateX(-20deg);animation-timing-function:ease-in}60%{transform:perspective(400px) rotateX(10deg);opacity:1}80%{transform:perspective(400px) rotateX(-5deg)}to{transform:perspective(400px)}}@keyframes Toastify__flipOut{0%{transform:translate3d(0,var(--y),0) perspective(400px)}30%{transform:translate3d(0,var(--y),0) perspective(400px) rotateX(-20deg);opacity:1}to{transform:translate3d(0,var(--y),0) perspective(400px) rotateX(90deg);opacity:0}}.Toastify__flip-enter{animation-name:Toastify__flipIn}.Toastify__flip-exit{animation-name:Toastify__flipOut}@keyframes Toastify__slideInRight{0%{transform:translate3d(110%,0,0);visibility:visible}to{transform:translate3d(0,var(--y),0)}}@keyframes Toastify__slideInLeft{0%{transform:translate3d(-110%,0,0);visibility:visible}to{transform:translate3d(0,var(--y),0)}}@keyframes Toastify__slideInUp{0%{transform:translate3d(0,110%,0);visibility:visible}to{transform:translate3d(0,var(--y),0)}}@keyframes Toastify__slideInDown{0%{transform:translate3d(0,-110%,0);visibility:visible}to{transform:translate3d(0,var(--y),0)}}@keyframes Toastify__slideOutRight{0%{transform:translate3d(0,var(--y),0)}to{visibility:hidden;transform:translate3d(110%,var(--y),0)}}@keyframes Toastify__slideOutLeft{0%{transform:translate3d(0,var(--y),0)}to{visibility:hidden;transform:translate3d(-110%,var(--y),0)}}@keyframes Toastify__slideOutDown{0%{transform:translate3d(0,var(--y),0)}to{visibility:hidden;transform:translate3d(0,500px,0)}}@keyframes Toastify__slideOutUp{0%{transform:translate3d(0,var(--y),0)}to{visibility:hidden;transform:translate3d(0,-500px,0)}}.Toastify__slide-enter--bottom-left,.Toastify__slide-enter--top-left{animation-name:Toastify__slideInLeft}.Toastify__slide-enter--bottom-right,.Toastify__slide-enter--top-right{animation-name:Toastify__slideInRight}.Toastify__slide-enter--top-center{animation-name:Toastify__slideInDown}.Toastify__slide-enter--bottom-center{animation-name:Toastify__slideInUp}.Toastify__slide-exit--bottom-left,.Toastify__slide-exit--top-left{animation-name:Toastify__slideOutLeft;animation-timing-function:ease-in;animation-duration:.3s}.Toastify__slide-exit--bottom-right,.Toastify__slide-exit--top-right{animation-name:Toastify__slideOutRight;animation-timing-function:ease-in;animation-duration:.3s}.Toastify__slide-exit--top-center{animation-name:Toastify__slideOutUp;animation-timing-function:ease-in;animation-duration:.3s}.Toastify__slide-exit--bottom-center{animation-name:Toastify__slideOutDown;animation-timing-function:ease-in;animation-duration:.3s}@keyframes Toastify__spin{0%{transform:rotate(0deg)}to{transform:rotate(1turn)}}',A=document.createElement("style");A.innerText=t,document.head.appendChild(A)}var JyA={exports:{}},TyA,BQe;function CQe(){return BQe||(BQe=1,TyA={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]}),TyA}var PyA={exports:{}},KyA,QQe;function s6t(){return QQe||(QQe=1,KyA=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")}),KyA}var hQe;function r6t(){if(hQe)return PyA.exports;hQe=1;var t=s6t(),A=Array.prototype.concat,e=Array.prototype.slice,i=PyA.exports=function(o){for(var s=[],r=0,a=o.length;r<a;r++){var g=o[r];t(g)?s=A.call(s,e.call(g)):s.push(g)}return s};return i.wrap=function(n){return function(){return n(i(arguments))}},PyA.exports}var EQe;function a6t(){if(EQe)return JyA.exports;EQe=1;var t=CQe(),A=r6t(),e=Object.hasOwnProperty,i=Object.create(null);for(var n in t)e.call(t,n)&&(i[t[n]]=n);var o=JyA.exports={to:{},get:{}};o.get=function(a){var g=a.substring(0,3).toLowerCase(),c,I;switch(g){case"hsl":c=o.get.hsl(a),I="hsl";break;case"hwb":c=o.get.hwb(a),I="hwb";break;default:c=o.get.rgb(a),I="rgb";break}return c?{model:I,value:c}:null},o.get.rgb=function(a){if(!a)return null;var g=/^#([a-f0-9]{3,4})$/i,c=/^#([a-f0-9]{6})([a-f0-9]{2})?$/i,I=/^rgba?\(\s*([+-]?\d+)(?=[\s,])\s*(?:,\s*)?([+-]?\d+)(?=[\s,])\s*(?:,\s*)?([+-]?\d+)\s*(?:[,|\/]\s*([+-]?[\d\.]+)(%?)\s*)?\)$/,l=/^rgba?\(\s*([+-]?[\d\.]+)\%\s*,?\s*([+-]?[\d\.]+)\%\s*,?\s*([+-]?[\d\.]+)\%\s*(?:[,|\/]\s*([+-]?[\d\.]+)(%?)\s*)?\)$/,B=/^(\w+)$/,C=[0,0,0,1],Q,h,E;if(Q=a.match(c)){for(E=Q[2],Q=Q[1],h=0;h<3;h++){var u=h*2;C[h]=parseInt(Q.slice(u,u+2),16)}E&&(C[3]=parseInt(E,16)/255)}else if(Q=a.match(g)){for(Q=Q[1],E=Q[3],h=0;h<3;h++)C[h]=parseInt(Q[h]+Q[h],16);E&&(C[3]=parseInt(E+E,16)/255)}else if(Q=a.match(I)){for(h=0;h<3;h++)C[h]=parseInt(Q[h+1],0);Q[4]&&(Q[5]?C[3]=parseFloat(Q[4])*.01:C[3]=parseFloat(Q[4]))}else if(Q=a.match(l)){for(h=0;h<3;h++)C[h]=Math.round(parseFloat(Q[h+1])*2.55);Q[4]&&(Q[5]?C[3]=parseFloat(Q[4])*.01:C[3]=parseFloat(Q[4]))}else return(Q=a.match(B))?Q[1]==="transparent"?[0,0,0,0]:e.call(t,Q[1])?(C=t[Q[1]],C[3]=1,C):null:null;for(h=0;h<3;h++)C[h]=s(C[h],0,255);return C[3]=s(C[3],0,1),C},o.get.hsl=function(a){if(!a)return null;var g=/^hsla?\(\s*([+-]?(?:\d{0,3}\.)?\d+)(?:deg)?\s*,?\s*([+-]?[\d\.]+)%\s*,?\s*([+-]?[\d\.]+)%\s*(?:[,|\/]\s*([+-]?(?=\.\d|\d)(?:0|[1-9]\d*)?(?:\.\d*)?(?:[eE][+-]?\d+)?)\s*)?\)$/,c=a.match(g);if(c){var I=parseFloat(c[4]),l=(parseFloat(c[1])%360+360)%360,B=s(parseFloat(c[2]),0,100),C=s(parseFloat(c[3]),0,100),Q=s(isNaN(I)?1:I,0,1);return[l,B,C,Q]}return null},o.get.hwb=function(a){if(!a)return null;var g=/^hwb\(\s*([+-]?\d{0,3}(?:\.\d+)?)(?:deg)?\s*,\s*([+-]?[\d\.]+)%\s*,\s*([+-]?[\d\.]+)%\s*(?:,\s*([+-]?(?=\.\d|\d)(?:0|[1-9]\d*)?(?:\.\d*)?(?:[eE][+-]?\d+)?)\s*)?\)$/,c=a.match(g);if(c){var I=parseFloat(c[4]),l=(parseFloat(c[1])%360+360)%360,B=s(parseFloat(c[2]),0,100),C=s(parseFloat(c[3]),0,100),Q=s(isNaN(I)?1:I,0,1);return[l,B,C,Q]}return null},o.to.hex=function(){var a=A(arguments);return"#"+r(a[0])+r(a[1])+r(a[2])+(a[3]<1?r(Math.round(a[3]*255)):"")},o.to.rgb=function(){var a=A(arguments);return a.length<4||a[3]===1?"rgb("+Math.round(a[0])+", "+Math.round(a[1])+", "+Math.round(a[2])+")":"rgba("+Math.round(a[0])+", "+Math.round(a[1])+", "+Math.round(a[2])+", "+a[3]+")"},o.to.rgb.percent=function(){var a=A(arguments),g=Math.round(a[0]/255*100),c=Math.round(a[1]/255*100),I=Math.round(a[2]/255*100);return a.length<4||a[3]===1?"rgb("+g+"%, "+c+"%, "+I+"%)":"rgba("+g+"%, "+c+"%, "+I+"%, "+a[3]+")"},o.to.hsl=function(){var a=A(arguments);return a.length<4||a[3]===1?"hsl("+a[0]+", "+a[1]+"%, "+a[2]+"%)":"hsla("+a[0]+", "+a[1]+"%, "+a[2]+"%, "+a[3]+")"},o.to.hwb=function(){var a=A(arguments),g="";return a.length>=4&&a[3]!==1&&(g=", "+a[3]),"hwb("+a[0]+", "+a[1]+"%, "+a[2]+"%"+g+")"},o.to.keyword=function(a){return i[a.slice(0,3)]};function s(a,g,c){return Math.min(Math.max(g,a),c)}function r(a){var g=Math.round(a).toString(16).toUpperCase();return g.length<2?"0"+g:g}return JyA.exports}var qyA,uQe;function dQe(){if(uQe)return qyA;uQe=1;const t=CQe(),A={};for(const n of Object.keys(t))A[t[n]]=n;const e={rgb:{channels:3,labels:"rgb"},hsl:{channels:3,labels:"hsl"},hsv:{channels:3,labels:"hsv"},hwb:{channels:3,labels:"hwb"},cmyk:{channels:4,labels:"cmyk"},xyz:{channels:3,labels:"xyz"},lab:{channels:3,labels:"lab"},lch:{channels:3,labels:"lch"},hex:{channels:1,labels:["hex"]},keyword:{channels:1,labels:["keyword"]},ansi16:{channels:1,labels:["ansi16"]},ansi256:{channels:1,labels:["ansi256"]},hcg:{channels:3,labels:["h","c","g"]},apple:{channels:3,labels:["r16","g16","b16"]},gray:{channels:1,labels:["gray"]}};qyA=e;for(const n of Object.keys(e)){if(!("channels"in e[n]))throw new Error("missing channels property: "+n);if(!("labels"in e[n]))throw new Error("missing channel labels property: "+n);if(e[n].labels.length!==e[n].channels)throw new Error("channel and label counts mismatch: "+n);const{channels:o,labels:s}=e[n];delete e[n].channels,delete e[n].labels,Object.defineProperty(e[n],"channels",{value:o}),Object.defineProperty(e[n],"labels",{value:s})}e.rgb.hsl=function(n){const o=n[0]/255,s=n[1]/255,r=n[2]/255,a=Math.min(o,s,r),g=Math.max(o,s,r),c=g-a;let I,l;g===a?I=0:o===g?I=(s-r)/c:s===g?I=2+(r-o)/c:r===g&&(I=4+(o-s)/c),I=Math.min(I*60,360),I<0&&(I+=360);const B=(a+g)/2;return g===a?l=0:B<=.5?l=c/(g+a):l=c/(2-g-a),[I,l*100,B*100]},e.rgb.hsv=function(n){let o,s,r,a,g;const c=n[0]/255,I=n[1]/255,l=n[2]/255,B=Math.max(c,I,l),C=B-Math.min(c,I,l),Q=function(h){return(B-h)/6/C+1/2};return C===0?(a=0,g=0):(g=C/B,o=Q(c),s=Q(I),r=Q(l),c===B?a=r-s:I===B?a=1/3+o-r:l===B&&(a=2/3+s-o),a<0?a+=1:a>1&&(a-=1)),[a*360,g*100,B*100]},e.rgb.hwb=function(n){const o=n[0],s=n[1];let r=n[2];const a=e.rgb.hsl(n)[0],g=1/255*Math.min(o,Math.min(s,r));return r=1-1/255*Math.max(o,Math.max(s,r)),[a,g*100,r*100]},e.rgb.cmyk=function(n){const o=n[0]/255,s=n[1]/255,r=n[2]/255,a=Math.min(1-o,1-s,1-r),g=(1-o-a)/(1-a)||0,c=(1-s-a)/(1-a)||0,I=(1-r-a)/(1-a)||0;return[g*100,c*100,I*100,a*100]};function i(n,o){return(n[0]-o[0])**2+(n[1]-o[1])**2+(n[2]-o[2])**2}return e.rgb.keyword=function(n){const o=A[n];if(o)return o;let s=1/0,r;for(const a of Object.keys(t)){const g=t[a],c=i(n,g);c<s&&(s=c,r=a)}return r},e.keyword.rgb=function(n){return t[n]},e.rgb.xyz=function(n){let o=n[0]/255,s=n[1]/255,r=n[2]/255;o=o>.04045?((o+.055)/1.055)**2.4:o/12.92,s=s>.04045?((s+.055)/1.055)**2.4:s/12.92,r=r>.04045?((r+.055)/1.055)**2.4:r/12.92;const a=o*.4124+s*.3576+r*.1805,g=o*.2126+s*.7152+r*.0722,c=o*.0193+s*.1192+r*.9505;return[a*100,g*100,c*100]},e.rgb.lab=function(n){const o=e.rgb.xyz(n);let s=o[0],r=o[1],a=o[2];s/=95.047,r/=100,a/=108.883,s=s>.008856?s**(1/3):7.787*s+16/116,r=r>.008856?r**(1/3):7.787*r+16/116,a=a>.008856?a**(1/3):7.787*a+16/116;const g=116*r-16,c=500*(s-r),I=200*(r-a);return[g,c,I]},e.hsl.rgb=function(n){const o=n[0]/360,s=n[1]/100,r=n[2]/100;let a,g,c;if(s===0)return c=r*255,[c,c,c];r<.5?a=r*(1+s):a=r+s-r*s;const I=2*r-a,l=[0,0,0];for(let B=0;B<3;B++)g=o+1/3*-(B-1),g<0&&g++,g>1&&g--,6*g<1?c=I+(a-I)*6*g:2*g<1?c=a:3*g<2?c=I+(a-I)*(2/3-g)*6:c=I,l[B]=c*255;return l},e.hsl.hsv=function(n){const o=n[0];let s=n[1]/100,r=n[2]/100,a=s;const g=Math.max(r,.01);r*=2,s*=r<=1?r:2-r,a*=g<=1?g:2-g;const c=(r+s)/2,I=r===0?2*a/(g+a):2*s/(r+s);return[o,I*100,c*100]},e.hsv.rgb=function(n){const o=n[0]/60,s=n[1]/100;let r=n[2]/100;const a=Math.floor(o)%6,g=o-Math.floor(o),c=255*r*(1-s),I=255*r*(1-s*g),l=255*r*(1-s*(1-g));switch(r*=255,a){case 0:return[r,l,c];case 1:return[I,r,c];case 2:return[c,r,l];case 3:return[c,I,r];case 4:return[l,c,r];case 5:return[r,c,I]}},e.hsv.hsl=function(n){const o=n[0],s=n[1]/100,r=n[2]/100,a=Math.max(r,.01);let g,c;c=(2-s)*r;const I=(2-s)*a;return g=s*a,g/=I<=1?I:2-I,g=g||0,c/=2,[o,g*100,c*100]},e.hwb.rgb=function(n){const o=n[0]/360;let s=n[1]/100,r=n[2]/100;const a=s+r;let g;a>1&&(s/=a,r/=a);const c=Math.floor(6*o),I=1-r;g=6*o-c,(c&1)!==0&&(g=1-g);const l=s+g*(I-s);let B,C,Q;switch(c){default:case 6:case 0:B=I,C=l,Q=s;break;case 1:B=l,C=I,Q=s;break;case 2:B=s,C=I,Q=l;break;case 3:B=s,C=l,Q=I;break;case 4:B=l,C=s,Q=I;break;case 5:B=I,C=s,Q=l;break}return[B*255,C*255,Q*255]},e.cmyk.rgb=function(n){const o=n[0]/100,s=n[1]/100,r=n[2]/100,a=n[3]/100,g=1-Math.min(1,o*(1-a)+a),c=1-Math.min(1,s*(1-a)+a),I=1-Math.min(1,r*(1-a)+a);return[g*255,c*255,I*255]},e.xyz.rgb=function(n){const o=n[0]/100,s=n[1]/100,r=n[2]/100;let a,g,c;return a=o*3.2406+s*-1.5372+r*-.4986,g=o*-.9689+s*1.8758+r*.0415,c=o*.0557+s*-.204+r*1.057,a=a>.0031308?1.055*a**(1/2.4)-.055:a*12.92,g=g>.0031308?1.055*g**(1/2.4)-.055:g*12.92,c=c>.0031308?1.055*c**(1/2.4)-.055:c*12.92,a=Math.min(Math.max(0,a),1),g=Math.min(Math.max(0,g),1),c=Math.min(Math.max(0,c),1),[a*255,g*255,c*255]},e.xyz.lab=function(n){let o=n[0],s=n[1],r=n[2];o/=95.047,s/=100,r/=108.883,o=o>.008856?o**(1/3):7.787*o+16/116,s=s>.008856?s**(1/3):7.787*s+16/116,r=r>.008856?r**(1/3):7.787*r+16/116;const a=116*s-16,g=500*(o-s),c=200*(s-r);return[a,g,c]},e.lab.xyz=function(n){const o=n[0],s=n[1],r=n[2];let a,g,c;g=(o+16)/116,a=s/500+g,c=g-r/200;const I=g**3,l=a**3,B=c**3;return g=I>.008856?I:(g-16/116)/7.787,a=l>.008856?l:(a-16/116)/7.787,c=B>.008856?B:(c-16/116)/7.787,a*=95.047,g*=100,c*=108.883,[a,g,c]},e.lab.lch=function(n){const o=n[0],s=n[1],r=n[2];let a;a=Math.atan2(r,s)*360/2/Math.PI,a<0&&(a+=360);const c=Math.sqrt(s*s+r*r);return[o,c,a]},e.lch.lab=function(n){const o=n[0],s=n[1],a=n[2]/360*2*Math.PI,g=s*Math.cos(a),c=s*Math.sin(a);return[o,g,c]},e.rgb.ansi16=function(n,o=null){const[s,r,a]=n;let g=o===null?e.rgb.hsv(n)[2]:o;if(g=Math.round(g/50),g===0)return 30;let c=30+(Math.round(a/255)<<2|Math.round(r/255)<<1|Math.round(s/255));return g===2&&(c+=60),c},e.hsv.ansi16=function(n){return e.rgb.ansi16(e.hsv.rgb(n),n[2])},e.rgb.ansi256=function(n){const o=n[0],s=n[1],r=n[2];return o===s&&s===r?o<8?16:o>248?231:Math.round((o-8)/247*24)+232:16+36*Math.round(o/255*5)+6*Math.round(s/255*5)+Math.round(r/255*5)},e.ansi16.rgb=function(n){let o=n%10;if(o===0||o===7)return n>50&&(o+=3.5),o=o/10.5*255,[o,o,o];const s=(~~(n>50)+1)*.5,r=(o&1)*s*255,a=(o>>1&1)*s*255,g=(o>>2&1)*s*255;return[r,a,g]},e.ansi256.rgb=function(n){if(n>=232){const g=(n-232)*10+8;return[g,g,g]}n-=16;let o;const s=Math.floor(n/36)/5*255,r=Math.floor((o=n%36)/6)/5*255,a=o%6/5*255;return[s,r,a]},e.rgb.hex=function(n){const s=(((Math.round(n[0])&255)<<16)+((Math.round(n[1])&255)<<8)+(Math.round(n[2])&255)).toString(16).toUpperCase();return"000000".substring(s.length)+s},e.hex.rgb=function(n){const o=n.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i);if(!o)return[0,0,0];let s=o[0];o[0].length===3&&(s=s.split("").map(I=>I+I).join(""));const r=parseInt(s,16),a=r>>16&255,g=r>>8&255,c=r&255;return[a,g,c]},e.rgb.hcg=function(n){const o=n[0]/255,s=n[1]/255,r=n[2]/255,a=Math.max(Math.max(o,s),r),g=Math.min(Math.min(o,s),r),c=a-g;let I,l;return c<1?I=g/(1-c):I=0,c<=0?l=0:a===o?l=(s-r)/c%6:a===s?l=2+(r-o)/c:l=4+(o-s)/c,l/=6,l%=1,[l*360,c*100,I*100]},e.hsl.hcg=function(n){const o=n[1]/100,s=n[2]/100,r=s<.5?2*o*s:2*o*(1-s);let a=0;return r<1&&(a=(s-.5*r)/(1-r)),[n[0],r*100,a*100]},e.hsv.hcg=function(n){const o=n[1]/100,s=n[2]/100,r=o*s;let a=0;return r<1&&(a=(s-r)/(1-r)),[n[0],r*100,a*100]},e.hcg.rgb=function(n){const o=n[0]/360,s=n[1]/100,r=n[2]/100;if(s===0)return[r*255,r*255,r*255];const a=[0,0,0],g=o%1*6,c=g%1,I=1-c;let l=0;switch(Math.floor(g)){case 0:a[0]=1,a[1]=c,a[2]=0;break;case 1:a[0]=I,a[1]=1,a[2]=0;break;case 2:a[0]=0,a[1]=1,a[2]=c;break;case 3:a[0]=0,a[1]=I,a[2]=1;break;case 4:a[0]=c,a[1]=0,a[2]=1;break;default:a[0]=1,a[1]=0,a[2]=I}return l=(1-s)*r,[(s*a[0]+l)*255,(s*a[1]+l)*255,(s*a[2]+l)*255]},e.hcg.hsv=function(n){const o=n[1]/100,s=n[2]/100,r=o+s*(1-o);let a=0;return r>0&&(a=o/r),[n[0],a*100,r*100]},e.hcg.hsl=function(n){const o=n[1]/100,r=n[2]/100*(1-o)+.5*o;let a=0;return r>0&&r<.5?a=o/(2*r):r>=.5&&r<1&&(a=o/(2*(1-r))),[n[0],a*100,r*100]},e.hcg.hwb=function(n){const o=n[1]/100,s=n[2]/100,r=o+s*(1-o);return[n[0],(r-o)*100,(1-r)*100]},e.hwb.hcg=function(n){const o=n[1]/100,r=1-n[2]/100,a=r-o;let g=0;return a<1&&(g=(r-a)/(1-a)),[n[0],a*100,g*100]},e.apple.rgb=function(n){return[n[0]/65535*255,n[1]/65535*255,n[2]/65535*255]},e.rgb.apple=function(n){return[n[0]/255*65535,n[1]/255*65535,n[2]/255*65535]},e.gray.rgb=function(n){return[n[0]/100*255,n[0]/100*255,n[0]/100*255]},e.gray.hsl=function(n){return[0,0,n[0]]},e.gray.hsv=e.gray.hsl,e.gray.hwb=function(n){return[0,100,n[0]]},e.gray.cmyk=function(n){return[0,0,0,n[0]]},e.gray.lab=function(n){return[n[0],0,0]},e.gray.hex=function(n){const o=Math.round(n[0]/100*255)&255,r=((o<<16)+(o<<8)+o).toString(16).toUpperCase();return"000000".substring(r.length)+r},e.rgb.gray=function(n){return[(n[0]+n[1]+n[2])/3/255*100]},qyA}var OyA,pQe;function g6t(){if(pQe)return OyA;pQe=1;const t=dQe();function A(){const o={},s=Object.keys(t);for(let r=s.length,a=0;a<r;a++)o[s[a]]={distance:-1,parent:null};return o}function e(o){const s=A(),r=[o];for(s[o].distance=0;r.length;){const a=r.pop(),g=Object.keys(t[a]);for(let c=g.length,I=0;I<c;I++){const l=g[I],B=s[l];B.distance===-1&&(B.distance=s[a].distance+1,B.parent=a,r.unshift(l))}}return s}function i(o,s){return function(r){return s(o(r))}}function n(o,s){const r=[s[o].parent,o];let a=t[s[o].parent][o],g=s[o].parent;for(;s[g].parent;)r.unshift(s[g].parent),a=i(t[s[g].parent][g],a),g=s[g].parent;return a.conversion=r,a}return OyA=function(o){const s=e(o),r={},a=Object.keys(s);for(let g=a.length,c=0;c<g;c++){const I=a[c];s[I].parent!==null&&(r[I]=n(I,s))}return r},OyA}var WyA,fQe;function c6t(){if(fQe)return WyA;fQe=1;const t=dQe(),A=g6t(),e={},i=Object.keys(t);function n(s){const r=function(...a){const g=a[0];return g==null?g:(g.length>1&&(a=g),s(a))};return"conversion"in s&&(r.conversion=s.conversion),r}function o(s){const r=function(...a){const g=a[0];if(g==null)return g;g.length>1&&(a=g);const c=s(a);if(typeof c=="object")for(let I=c.length,l=0;l<I;l++)c[l]=Math.round(c[l]);return c};return"conversion"in s&&(r.conversion=s.conversion),r}return i.forEach(s=>{e[s]={},Object.defineProperty(e[s],"channels",{value:t[s].channels}),Object.defineProperty(e[s],"labels",{value:t[s].labels});const r=A(s);Object.keys(r).forEach(g=>{const c=r[g];e[s][g]=o(c),e[s][g].raw=n(c)})}),WyA=e,WyA}var ZyA,yQe;function I6t(){if(yQe)return ZyA;yQe=1;const t=a6t(),A=c6t(),e=["keyword","gray","hex"],i={};for(const l of Object.keys(A))i[[...A[l].labels].sort().join("")]=l;const n={};function o(l,B){if(!(this instanceof o))return new o(l,B);if(B&&B in e&&(B=null),B&&!(B in A))throw new Error("Unknown model: "+B);let C,Q;if(l==null)this.model="rgb",this.color=[0,0,0],this.valpha=1;else if(l instanceof o)this.model=l.model,this.color=[...l.color],this.valpha=l.valpha;else if(typeof l=="string"){const h=t.get(l);if(h===null)throw new Error("Unable to parse color from string: "+l);this.model=h.model,Q=A[this.model].channels,this.color=h.value.slice(0,Q),this.valpha=typeof h.value[Q]=="number"?h.value[Q]:1}else if(l.length>0){this.model=B||"rgb",Q=A[this.model].channels;const h=Array.prototype.slice.call(l,0,Q);this.color=I(h,Q),this.valpha=typeof l[Q]=="number"?l[Q]:1}else if(typeof l=="number")this.model="rgb",this.color=[l>>16&255,l>>8&255,l&255],this.valpha=1;else{this.valpha=1;const h=Object.keys(l);"alpha"in l&&(h.splice(h.indexOf("alpha"),1),this.valpha=typeof l.alpha=="number"?l.alpha:0);const E=h.sort().join("");if(!(E in i))throw new Error("Unable to parse color from object: "+JSON.stringify(l));this.model=i[E];const{labels:u}=A[this.model],d=[];for(C=0;C<u.length;C++)d.push(l[u[C]]);this.color=I(d)}if(n[this.model])for(Q=A[this.model].channels,C=0;C<Q;C++){const h=n[this.model][C];h&&(this.color[C]=h(this.color[C]))}this.valpha=Math.max(0,Math.min(1,this.valpha)),Object.freeze&&Object.freeze(this)}o.prototype={toString(){return this.string()},toJSON(){return this[this.model]()},string(l){let B=this.model in t.to?this:this.rgb();B=B.round(typeof l=="number"?l:1);const C=B.valpha===1?B.color:[...B.color,this.valpha];return t.to[B.model](C)},percentString(l){const B=this.rgb().round(typeof l=="number"?l:1),C=B.valpha===1?B.color:[...B.color,this.valpha];return t.to.rgb.percent(C)},array(){return this.valpha===1?[...this.color]:[...this.color,this.valpha]},object(){const l={},{channels:B}=A[this.model],{labels:C}=A[this.model];for(let Q=0;Q<B;Q++)l[C[Q]]=this.color[Q];return this.valpha!==1&&(l.alpha=this.valpha),l},unitArray(){const l=this.rgb().color;return l[0]/=255,l[1]/=255,l[2]/=255,this.valpha!==1&&l.push(this.valpha),l},unitObject(){const l=this.rgb().object();return l.r/=255,l.g/=255,l.b/=255,this.valpha!==1&&(l.alpha=this.valpha),l},round(l){return l=Math.max(l||0,0),new o([...this.color.map(r(l)),this.valpha],this.model)},alpha(l){return l!==void 0?new o([...this.color,Math.max(0,Math.min(1,l))],this.model):this.valpha},red:a("rgb",0,g(255)),green:a("rgb",1,g(255)),blue:a("rgb",2,g(255)),hue:a(["hsl","hsv","hsl","hwb","hcg"],0,l=>(l%360+360)%360),saturationl:a("hsl",1,g(100)),lightness:a("hsl",2,g(100)),saturationv:a("hsv",1,g(100)),value:a("hsv",2,g(100)),chroma:a("hcg",1,g(100)),gray:a("hcg",2,g(100)),white:a("hwb",1,g(100)),wblack:a("hwb",2,g(100)),cyan:a("cmyk",0,g(100)),magenta:a("cmyk",1,g(100)),yellow:a("cmyk",2,g(100)),black:a("cmyk",3,g(100)),x:a("xyz",0,g(95.047)),y:a("xyz",1,g(100)),z:a("xyz",2,g(108.833)),l:a("lab",0,g(100)),a:a("lab",1),b:a("lab",2),keyword(l){return l!==void 0?new o(l):A[this.model].keyword(this.color)},hex(l){return l!==void 0?new o(l):t.to.hex(this.rgb().round().color)},hexa(l){if(l!==void 0)return new o(l);const B=this.rgb().round().color;let C=Math.round(this.valpha*255).toString(16).toUpperCase();return C.length===1&&(C="0"+C),t.to.hex(B)+C},rgbNumber(){const l=this.rgb().color;return(l[0]&255)<<16|(l[1]&255)<<8|l[2]&255},luminosity(){const l=this.rgb().color,B=[];for(const[C,Q]of l.entries()){const h=Q/255;B[C]=h<=.04045?h/12.92:((h+.055)/1.055)**2.4}return .2126*B[0]+.7152*B[1]+.0722*B[2]},contrast(l){const B=this.luminosity(),C=l.luminosity();return B>C?(B+.05)/(C+.05):(C+.05)/(B+.05)},level(l){const B=this.contrast(l);return B>=7?"AAA":B>=4.5?"AA":""},isDark(){const l=this.rgb().color;return(l[0]*2126+l[1]*7152+l[2]*722)/1e4<128},isLight(){return!this.isDark()},negate(){const l=this.rgb();for(let B=0;B<3;B++)l.color[B]=255-l.color[B];return l},lighten(l){const B=this.hsl();return B.color[2]+=B.color[2]*l,B},darken(l){const B=this.hsl();return B.color[2]-=B.color[2]*l,B},saturate(l){const B=this.hsl();return B.color[1]+=B.color[1]*l,B},desaturate(l){const B=this.hsl();return B.color[1]-=B.color[1]*l,B},whiten(l){const B=this.hwb();return B.color[1]+=B.color[1]*l,B},blacken(l){const B=this.hwb();return B.color[2]+=B.color[2]*l,B},grayscale(){const l=this.rgb().color,B=l[0]*.3+l[1]*.59+l[2]*.11;return o.rgb(B,B,B)},fade(l){return this.alpha(this.valpha-this.valpha*l)},opaquer(l){return this.alpha(this.valpha+this.valpha*l)},rotate(l){const B=this.hsl();let C=B.color[0];return C=(C+l)%360,C=C<0?360+C:C,B.color[0]=C,B},mix(l,B){if(!l||!l.rgb)throw new Error('Argument to "mix" was not a Color instance, but rather an instance of '+typeof l);const C=l.rgb(),Q=this.rgb(),h=B===void 0?.5:B,E=2*h-1,u=C.alpha()-Q.alpha(),d=((E*u===-1?E:(E+u)/(1+E*u))+1)/2,f=1-d;return o.rgb(d*C.red()+f*Q.red(),d*C.green()+f*Q.green(),d*C.blue()+f*Q.blue(),C.alpha()*h+Q.alpha()*(1-h))}};for(const l of Object.keys(A)){if(e.includes(l))continue;const{channels:B}=A[l];o.prototype[l]=function(...C){return this.model===l?new o(this):C.length>0?new o(C,l):new o([...c(A[this.model][l].raw(this.color)),this.valpha],l)},o[l]=function(...C){let Q=C[0];return typeof Q=="number"&&(Q=I(C,B)),new o(Q,l)}}function s(l,B){return Number(l.toFixed(B))}function r(l){return function(B){return s(B,l)}}function a(l,B,C){l=Array.isArray(l)?l:[l];for(const Q of l)(n[Q]||(n[Q]=[]))[B]=C;return l=l[0],function(Q){let h;return Q!==void 0?(C&&(Q=C(Q)),h=this[l](),h.color[B]=Q,h):(h=this[l]().color[B],C&&(h=C(h)),h)}}function g(l){return function(B){return Math.max(0,Math.min(l,B))}}function c(l){return Array.isArray(l)?l:[l]}function I(l,B){for(let C=0;C<B;C++)typeof l[C]!="number"&&(l[C]=0);return l}return ZyA=o,ZyA}var l6t=I6t();const Pa=R0(l6t);function ai(t,A){return Array.isArray(A)?[t.a*A[0]+t.c*A[1]+t.e,t.b*A[0]+t.d*A[1]+t.f]:{x:t.a*A.x+t.c*A.y+t.e,y:t.b*A.x+t.d*A.y+t.f}}function B6t(){return{a:1,c:0,e:0,b:0,d:1,f:0}}function GT(t){return typeof t>"u"}function Uk(t,A=0){return{a:1,c:0,e:t,b:0,d:1,f:A}}function rz(...t){t=Array.isArray(t[0])?t[0]:t;const A=(e,i)=>({a:e.a*i.a+e.c*i.b,c:e.a*i.c+e.c*i.d,e:e.a*i.e+e.c*i.f+e.e,b:e.b*i.a+e.d*i.b,d:e.b*i.c+e.d*i.d,f:e.b*i.e+e.d*i.f+e.f});switch(t.length){case 0:throw new Error("no matrices provided");case 1:return t[0];case 2:return A(t[0],t[1]);default:{const[e,i,...n]=t,o=A(e,i);return rz(o,...n)}}}function VyA(...t){return rz(...t)}const{cos:C6t,sin:Q6t}=Math;function mQe(t,A,e){const i=C6t(t),n=Q6t(t),o={a:i,c:-n,e:0,b:n,d:i,f:0};return GT(A)||GT(e)?o:rz([Uk(A,e),o,Uk(-A,-e)])}function h6t(t,A=void 0,e=void 0,i=void 0){GT(A)&&(A=t);const n={a:t,c:0,e:0,b:0,d:A,f:0};return GT(e)||GT(i)?n:rz([Uk(e,i),n,Uk(-e,-i)])}function az(t){const{ctx:A,points:e,fill:i,stroke:n,strokeWidth:o=1,minStrokePx:s,realToCanvasMat:r,closePath:a=!1}=t;if(e.length<2)return;A.beginPath();const g=e.map(B=>ai(r,[B.x,B.y])),c=g[0];if(!c)return;const[I,l]=c;A.moveTo(I,l);for(let B=1;B<g.length;B++){const C=g[B];if(!C)continue;const[Q,h]=C;A.lineTo(Q,h)}if(a&&A.closePath(),i&&(A.fillStyle=i,A.fill()),n){const B=o*Math.abs(r.a),C=s===void 0?B:Math.max(B,s);A.strokeStyle=n,A.lineWidth=C,A.stroke()}}function eQ(t){const{ctx:A,center:e,width:i,height:n,fill:o,realToCanvasMat:s,borderRadius:r=0,ccwRotationDegrees:a=0,stroke:g,strokeWidth:c,isStrokeDashed:I=!1}=t,[l,B]=ai(s,[e.x,e.y]),C=i*Math.abs(s.a),Q=n*Math.abs(s.a),h=r*Math.abs(s.a),E=c?c*Math.abs(s.a):void 0;if(A.save(),A.translate(l,B),a!==0&&A.rotate(-a*(Math.PI/180)),A.beginPath(),h>0){const u=-C/2,d=-Q/2,f=Math.min(h,C/2,Q/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+Q-f),A.arcTo(u+C,d+Q,u+C-f,d+Q,f),A.lineTo(u+f,d+Q),A.arcTo(u,d+Q,u,d+Q-f,f),A.lineTo(u,d+f),A.arcTo(u,d,u+f,d,f)}else A.rect(-C/2,-Q/2,C,Q);o&&(A.fillStyle=o,A.fill()),g&&E&&(I?A.setLineDash([E*3,E*2]):A.setLineDash([]),A.strokeStyle=g,A.lineWidth=E,A.stroke()),A.restore()}function E6t(t){const{ctx:A,board:e,realToCanvasMat:i,colorMap:n,drawBoardMaterial:o,minBoardOutlineStrokePx:s}=t,{width:r,height:a,center:g,outline:c}=e;if(c&&Array.isArray(c)&&c.length>=3){o&&az({ctx:A,points:c.map(I=>({x:I.x,y:I.y})),fill:n.substrate,realToCanvasMat:i,closePath:!0}),az({ctx:A,points:c.map(I=>({x:I.x,y:I.y})),stroke:n.boardOutline,strokeWidth:.1,realToCanvasMat:i,closePath:!0,minStrokePx:s});return}if(r!==void 0&&a!==void 0&&g){o&&eQ({ctx:A,center:g,width:r,height:a,fill:n.substrate,realToCanvasMat:i});const I=r/2,l=a/2,B=[{x:g.x-I,y:g.y-l},{x:g.x+I,y:g.y-l},{x:g.x+I,y:g.y+l},{x:g.x-I,y:g.y+l}];az({ctx:A,points:B,stroke:n.boardOutline,strokeWidth:.1,realToCanvasMat:i,closePath:!0,minStrokePx:s})}}function Hk(t){const{ctx:A,points:e,fill:i,realToCanvasMat:n}=t;if(e.length<3)return;A.beginPath();const o=e.map(g=>ai(n,[g.x,g.y])),s=o[0];if(!s)return;const[r,a]=s;A.moveTo(r,a);for(let g=1;g<o.length;g++){const c=o[g];if(!c)continue;const[I,l]=c;A.lineTo(I,l)}A.closePath(),A.fillStyle=i,A.fill()}function u6t(t,A){return A.copper[t]??A.copper.top}function d6t(t){return t==="top"||t==="bottom"?.5:1}function p6t(t,A,e,i,n){if(Math.abs(n)<1e-10)return null;const o=e-t,s=i-A,r=Math.hypot(o,s);if(r<1e-10)return null;const a=Math.abs(n)*(r/2),g=r/2,c=(a*a+g*g)/(2*a),I=c-a,l=(t+e)/2,B=(A+i)/2,C=-s/r,Q=o/r,h=n>0?-1:1,E=l+h*C*I,u=B+h*Q*I;return{centerX:E,centerY:u,radius:c}}function jyA(t,A,e,i,n,o,s){if(Math.abs(o)<1e-10){const[f,m]=ai(s,[i,n]);t.lineTo(f,m);return}const r=p6t(A,e,i,n,o);if(!r){const[f,m]=ai(s,[i,n]);t.lineTo(f,m);return}const[a,g]=ai(s,[A,e]),[c,I]=ai(s,[i,n]),[l,B]=ai(s,[r.centerX,r.centerY]),C=Math.hypot(a-l,g-B),Q=Math.atan2(g-B,a-l),h=Math.atan2(I-B,c-l),u=s.a*s.d-s.b*s.c<0,d=o>0?!u:u;t.arc(l,B,C,Q,h,d)}function wQe(t,A,e){if(A.vertices.length<2)return;if(A.vertices.length===2){const s=A.vertices[0],r=A.vertices[1];if(s&&r&&Math.abs((s.bulge??0)-1)<1e-10&&Math.abs((r.bulge??0)-1)<1e-10){const[a,g]=ai(e,[s.x,s.y]);t.moveTo(a,g),jyA(t,s.x,s.y,r.x,r.y,1,e),jyA(t,r.x,r.y,s.x,s.y,1,e);return}}const i=A.vertices[0];if(!i)return;const[n,o]=ai(e,[i.x,i.y]);t.moveTo(n,o);for(let s=0;s<A.vertices.length;s++){const r=A.vertices[s],a=(s+1)%A.vertices.length,g=A.vertices[a];if(!r||!g)continue;const c=r.bulge??0;if(Math.abs(c)<1e-10){const[I,l]=ai(e,[g.x,g.y]);t.lineTo(I,l)}else jyA(t,r.x,r.y,g.x,g.y,c,e)}}function f6t(t){const{ctx:A,pour:e,realToCanvasMat:i,colorMap:n}=t,o=u6t(e.layer,n),s=d6t(e.layer);if(A.save(),A.globalAlpha=s,e.shape==="rect"){const[r,a]=ai(i,[e.center.x,e.center.y]),g=e.width*Math.abs(i.a),c=e.height*Math.abs(i.a);A.translate(r,a),e.rotation&&A.rotate(-e.rotation*(Math.PI/180)),A.beginPath(),A.rect(-g/2,-c/2,g,c),A.fillStyle=o,A.fill(),A.restore();return}if(e.shape==="polygon"){if(e.points&&e.points.length>=3){const r=e.points.map(I=>ai(i,[I.x,I.y])),a=r[0];if(!a){A.restore();return}A.beginPath();const[g,c]=a;A.moveTo(g,c);for(let I=1;I<r.length;I++){const l=r[I];if(!l)continue;const[B,C]=l;A.lineTo(B,C)}A.closePath(),A.fillStyle=o,A.fill()}A.restore();return}if(e.shape==="brep"){if(A.beginPath(),wQe(A,e.brep_shape.outer_ring,i),e.brep_shape.inner_rings)for(const r of e.brep_shape.inner_rings)wQe(A,r,i);A.fillStyle=o,A.fill("evenodd"),A.restore();return}A.restore()}var y6t=t=>Bee[t]??(t===" "?sd.spaceWidthRatio:sd.glyphWidthRatio);function DQe(t,A,e){const i=y6t(t),n=A?sd.letterSpacingRatio:0,o=A?Cee[t]?.[A]??0:0;return e*(i+n+o)}function zyA(t,A){const e=A*sd.glyphWidthRatio,i=A*sd.letterSpacingRatio,n=A*sd.spaceWidthRatio,o=A*sd.strokeWidthRatio,s=A*sd.lineHeightRatio,r=t.replace(/\\n/g,`
5389
5389
  `).split(`
5390
- `),a=r.map(I=>{const l=Array.from(I);return l.reduce((B,C,Q)=>B+DQe(C,l[Q+1],A),0)}),g=a.reduce((I,l)=>Math.max(I,l),0),c=r.length>1?A+(r.length-1)*s:A;return{width:g,height:c,glyphWidth:e,letterSpacing:i,spaceWidth:n,strokeWidth:o,lineHeight:s,lines:r,lineWidths:a}}function SQe(t,A){const e=A.width+A.strokeWidth,i=A.height+A.strokeWidth;let n=0,o=0;return t==="center"||t==="top_center"||t==="bottom_center"?n=-e/2:t==="top_left"||t==="bottom_left"||t==="center_left"?n=0:t==="top_right"||t==="bottom_right"||t==="center_right"?n=-e:(t==="top_center"||t==="bottom_center")&&(n=-e/2),t==="center"||t==="center_left"||t==="center_right"?o=-i/2:t==="top_left"||t==="top_right"||t==="top_center"?o=0:(t==="bottom_left"||t==="bottom_right"||t==="bottom_center")&&(o=-i),{x:n,y:o}}function bQe(t){const{alignment:A,lineWidth:e,maxWidth:i,strokeWidth:n}=t,o=e+n,s=i+n;return A==="top_left"||A==="bottom_left"||A==="center_left"?0:A==="top_right"||A==="bottom_right"||A==="center_right"?s-o:(s-o)/2}var m6t=t=>lee[t];function xQe(t){const{ctx:A,line:e,fontSize:i,startX:n,startY:o,layout:s}=t,{strokeWidth:r}=s,a=i,g=i,c=o,I=Array.from(e);let l=n+r/2;I.forEach((B,C)=>{const Q=m6t(B);if(Q?.length){A.beginPath();for(const h of Q){const E=l+h.x1*g,u=c+(1-h.y1)*a,d=l+h.x2*g,f=c+(1-h.y2)*a;A.moveTo(E,u),A.lineTo(d,f)}A.stroke()}l+=DQe(B,I[C+1],i)})}function w6t(t){const{ctx:A,text:e,fontSize:i,startX:n,startY:o,anchorAlignment:s="center"}=t,r=zyA(e,i),{lines:a,lineWidths:g,lineHeight:c,width:I,strokeWidth:l}=r;a.forEach((B,C)=>{const Q=n+bQe({alignment:s,lineWidth:g[C],maxWidth:I,strokeWidth:l}),h=o+C*c;xQe({ctx:A,line:B,fontSize:i,startX:Q,startY:h,layout:r})})}var D6t={left:.2,right:.2,top:.2,bottom:.2};function gz(t){const{ctx:A,text:e,x:i,y:n,fontSize:o,color:s,realToCanvasMat:r,anchorAlignment:a,rotation:g=0,mirrorX:c=!1,knockout:I=!1,knockoutPadding:l={}}=t;if(!e)return;const[B,C]=ai(r,[i,n]),Q=Math.abs(r.a),h=o*Q,E=zyA(e,h),u=SQe(a,E);if(A.save(),A.translate(B,C),g!==0&&A.rotate(-g*(Math.PI/180)),c&&A.scale(-1,1),I){const S={...D6t,...l},_=S.left*Q,b=S.right*Q,N=S.top*Q,F=S.bottom*Q,L=E.width+E.strokeWidth,Y=u.x-_*4,J=u.y-N*4,q=L+_*2+b*2,Z=E.height+E.strokeWidth+N*2+F*2;A.fillStyle=s,A.fillRect(Y,J,q,Z)}else A.strokeStyle=s;A.lineWidth=E.strokeWidth,A.lineCap="round",A.lineJoin="round";const{lines:d,lineWidths:f,lineHeight:m,width:w,strokeWidth:D}=E;d.forEach((S,_)=>{const b=u.x+bQe({alignment:a,lineWidth:f[_],maxWidth:w,strokeWidth:D}),N=u.y+_*m;xQe({ctx:A,line:S,fontSize:h,startX:b,startY:N,layout:E})}),A.restore()}var S6t={left:.2,right:.2,top:.2,bottom:.2};function b6t(t){return t?t.includes("left")?"center_left":t.includes("right")?"center_right":"center":"center"}function x6t(t){const{ctx:A,text:e,realToCanvasMat:i,colorMap:n}=t,o=e.text??"";if(!o)return;const[s,r]=ai(i,[e.anchor_position.x,e.anchor_position.y]),a=Math.abs(i.a),g=(e.font_size??1)*a,c=e.ccw_rotation??0,I={...S6t,...e.knockout_padding},l=n.copper[e.layer]??n.copper.top,B=zyA(o,g),C=B.width+B.strokeWidth,Q=b6t(e.anchor_alignment),h=SQe(Q,B);if(A.save(),A.translate(s,r),e.is_mirrored&&A.scale(-1,1),c!==0&&A.rotate(-c*(Math.PI/180)),A.lineWidth=B.strokeWidth,A.lineCap="round",A.lineJoin="round",e.is_knockout){const E=I.left*a,u=I.right*a,d=I.top*a,f=I.bottom*a,m=h.x-E*4,w=h.y-d*4,D=C+E*2+u*2,S=B.height+B.strokeWidth+d*2+f*2;A.fillStyle=l,A.fillRect(m,w,D,S)}else A.strokeStyle=l;w6t({ctx:A,text:o,fontSize:g,startX:h.x,startY:h.y,anchorAlignment:Q}),A.restore()}function tQ(t){const{ctx:A,center:e,radius:i,fill:n,realToCanvasMat:o,stroke:s,strokeWidth:r,isStrokeDashed:a=!1}=t,[g,c]=ai(o,[e.x,e.y]),I=i*Math.abs(o.a),l=r?r*Math.abs(o.a):void 0;A.beginPath(),A.arc(g,c,I,0,Math.PI*2),n&&(A.fillStyle=n,A.fill()),s&&l&&(a?A.setLineDash([l*3,l*2]):A.setLineDash([]),A.strokeStyle=s,A.lineWidth=l,A.stroke())}function _6t(t,A){return t==="bottom"?A.courtyard.bottom:A.courtyard.top}function k6t(t){const{ctx:A,circle:e,realToCanvasMat:i,colorMap:n}=t;tQ({ctx:A,center:e.center,radius:e.radius,stroke:_6t(e.layer,n),strokeWidth:.05,realToCanvasMat:i})}function v6t(t,A){return t==="bottom"?A.courtyard.bottom:A.courtyard.top}function F6t(t){const{ctx:A,outline:e,realToCanvasMat:i,colorMap:n}=t;if(!e.outline||e.outline.length<2)return;A.beginPath();const o=ai(i,e.outline[0]);A.moveTo(o.x,o.y);for(let s=1;s<e.outline.length;s++){const r=ai(i,e.outline[s]);A.lineTo(r.x,r.y)}A.closePath(),A.lineWidth=.05*Math.abs(i.a),A.strokeStyle=v6t(e.layer,n),A.stroke()}function M6t(t,A){return t==="bottom"?A.courtyard.bottom:A.courtyard.top}function R6t(t){const{ctx:A,rect:e,realToCanvasMat:i,colorMap:n}=t;eQ({ctx:A,center:e.center,width:e.width,height:e.height,stroke:M6t(e.layer,n),strokeWidth:.05,realToCanvasMat:i})}function N6t(t){const{ctx:A,cutout:e,realToCanvasMat:i,colorMap:n}=t;if(e.shape==="rect"){eQ({ctx:A,center:e.center,width:e.width,height:e.height,fill:n.drill,realToCanvasMat:i,ccwRotationDegrees:e.rotation??0,borderRadius:e.corner_radius??0});return}if(e.shape==="circle"){tQ({ctx:A,center:e.center,radius:e.radius,fill:n.drill,realToCanvasMat:i});return}if(e.shape==="polygon"){e.points&&e.points.length>=3&&Hk({ctx:A,points:e.points,fill:n.drill,realToCanvasMat:i});return}}var G6t=1.5,L6t=.6,U6t=.3;function XyA(t){const A=Math.hypot(t.x,t.y)||1;return{x:t.x/A,y:t.y/A}}function _Qe(t){const{ctx:A,from:e,to:i,realToCanvasMat:n,color:o,fontSize:s,arrowSize:r=1,strokeWidth:a,text:g,textRotation:c,offset:I}=t,l=XyA({x:i.x-e.x,y:i.y-e.y}),B={x:-l.y,y:l.x},C=I?.direction&&typeof I.direction.x=="number"&&typeof I.direction.y=="number",Q=C?XyA(I.direction):{x:0,y:0},h=I?.distance??0,E={x:Q.x*h,y:Q.y*h},u={x:e.x+E.x,y:e.y+E.y},d={x:i.x+E.x,y:i.y+E.y},f={x:u.x+l.x*r,y:u.y+l.y*r},m={x:d.x-l.x*r,y:d.y-l.y*r};Math.abs(n.a);const w=a??r/5,D=o||"rgba(255,255,255,0.5)",S=C&&(Math.abs(Q.x)>Number.EPSILON||Math.abs(Q.y)>Number.EPSILON)?Q:B,_=h+.5,b=[],N=Y=>{const J={x:Y.x+S.x*_,y:Y.y+S.y*_},q=w/2,Z={x:-S.y,y:S.x};return[{x:Y.x+Z.x*q,y:Y.y+Z.y*q},{x:Y.x-Z.x*q,y:Y.y-Z.y*q},{x:J.x-Z.x*q,y:J.y-Z.y*q},{x:J.x+Z.x*q,y:J.y+Z.y*q}]};b.push(u),b.push({x:f.x+B.x*(r/2),y:f.y+B.y*(r/2)}),b.push({x:f.x+B.x*(w/2),y:f.y+B.y*(w/2)}),b.push({x:m.x+B.x*(w/2),y:m.y+B.y*(w/2)}),b.push({x:m.x+B.x*(r/2),y:m.y+B.y*(r/2)}),b.push(d),b.push({x:m.x-B.x*(r/2),y:m.y-B.y*(r/2)}),b.push({x:m.x-B.x*(w/2),y:m.y-B.y*(w/2)}),b.push({x:f.x-B.x*(w/2),y:f.y-B.y*(w/2)}),b.push({x:f.x-B.x*(r/2),y:f.y-B.y*(r/2)}),b.push(u);const F=b[0],L=Y=>{const J=N(Y);b.push(F),b.push(J[0]),b.push(...J),b.push(J[0]),b.push(F)};if(L(e),L(i),Hk({ctx:A,points:b,fill:D,realToCanvasMat:n}),g){const Y={x:(e.x+i.x)/2+E.x,y:(e.y+i.y)/2+E.y},[J,q]=ai(n,[u.x,u.y]),[Z,X]=ai(n,[d.x,d.y]),eA=XyA({x:Z-J,y:X-q});let gA=Math.atan2(eA.y,eA.x)*180/Math.PI;(gA>90||gA<-90)&&(gA+=180);const iA=typeof c=="number"&&Number.isFinite(c)?gA-c:gA;let tA=0;if(g&&typeof c=="number"&&Number.isFinite(c)){const hA=g.length*s*L6t,bA=s,_A=c*Math.PI/180,HA=Math.abs(Math.sin(_A)),QA=Math.abs(Math.cos(_A)),xA=hA/2,dA=bA/2;tA=xA*HA+dA*QA+s*U6t}const sA=r*G6t+tA,aA={x:Y.x+B.x*sA,y:Y.y+B.y*sA};gz({ctx:A,text:g,x:aA.x,y:aA.y,fontSize:s,color:D,realToCanvasMat:n,anchorAlignment:"center",rotation:-iA})}}function H6t(t){const{ctx:A,pcbFabricationNoteDimension:e,realToCanvasMat:i,colorMap:n}=t,o=e.color??n.fabricationNote;_Qe({ctx:A,from:e.from,to:e.to,realToCanvasMat:i,color:o,fontSize:e.font_size??1,arrowSize:e.arrow_size??1,text:e.text,textRotation:e.text_ccw_rotation,offset:e.offset_distance&&e.offset_direction?{distance:e.offset_distance,direction:e.offset_direction}:void 0})}function E2(t){const{ctx:A,start:e,end:i,strokeWidth:n,stroke:o,realToCanvasMat:s,lineCap:r="round"}=t,[a,g]=ai(s,[e.x,e.y]),[c,I]=ai(s,[i.x,i.y]),l=n*Math.abs(s.a);A.beginPath(),A.moveTo(a,g),A.lineTo(c,I),A.lineWidth=l,A.strokeStyle=o,A.lineCap=r,A.stroke()}function Y6t(t){const{ctx:A,path:e,realToCanvasMat:i,colorMap:n}=t,o=n.fabricationNote,s=e.color??o;if(!(!e.route||e.route.length<2))for(let r=0;r<e.route.length-1;r++){const a=e.route[r],g=e.route[r+1];!a||!g||E2({ctx:A,start:{x:a.x,y:a.y},end:{x:g.x,y:g.y},strokeWidth:e.stroke_width??.1,stroke:s,realToCanvasMat:i})}}function J6t(t){const{ctx:A,rect:e,realToCanvasMat:i,colorMap:n}=t,o=n.fabricationNote,s=e.color??o,r=e.is_filled??!1,a=e.has_stroke??!0,g=e.is_stroke_dashed??!1;eQ({ctx:A,center:e.center,width:e.width,height:e.height,fill:r?s:void 0,stroke:a?s:void 0,strokeWidth:a?e.stroke_width:void 0,borderRadius:e.corner_radius,realToCanvasMat:i,isStrokeDashed:g})}function T6t(t,A){return A.fabricationNote}function P6t(t){const{ctx:A,text:e,realToCanvasMat:i,colorMap:n}=t,o=T6t(e.layer,n),s=e.color??o,r=e.font_size;gz({ctx:A,text:e.text,x:e.anchor_position.x,y:e.anchor_position.y,fontSize:r,color:s,realToCanvasMat:i,anchorAlignment:e.anchor_alignment})}function ES(t){const{ctx:A,center:e,radius_x:i,radius_y:n,fill:o,stroke:s,strokeWidth:r=.1,realToCanvasMat:a,rotation:g=0}=t,[c,I]=ai(a,[e.x,e.y]),l=i*Math.abs(a.a),B=n*Math.abs(a.a),C=r*Math.abs(a.a);A.save(),A.translate(c,I),g!==0&&A.rotate(-g*(Math.PI/180)),A.beginPath(),A.ellipse(0,0,l,B,0,0,Math.PI*2),o&&(A.fillStyle=o,A.fill()),s&&(A.strokeStyle=s,A.lineWidth=C,A.stroke()),A.restore()}function eh(t){const{ctx:A,center:e,width:i,height:n,fill:o,realToCanvasMat:s,rotation:r=0,stroke:a,strokeWidth:g}=t,[c,I]=ai(s,[e.x,e.y]),l=i*Math.abs(s.a),B=n*Math.abs(s.a),C=g?g*Math.abs(s.a):void 0;if(A.save(),A.translate(c,I),r!==0&&A.rotate(-r*(Math.PI/180)),A.beginPath(),l>B){const Q=B/2,h=l-B;A.moveTo(-h/2,-Q),A.lineTo(h/2,-Q),A.arc(h/2,0,Q,-Math.PI/2,Math.PI/2),A.lineTo(-h/2,Q),A.arc(-h/2,0,Q,Math.PI/2,-Math.PI/2)}else if(B>l){const Q=l/2,h=B-l;A.moveTo(Q,-h/2),A.lineTo(Q,h/2),A.arc(0,h/2,Q,0,Math.PI),A.lineTo(-Q,-h/2),A.arc(0,-h/2,Q,Math.PI,0)}else A.arc(0,0,l/2,0,Math.PI*2);A.closePath(),o&&(A.fillStyle=o,A.fill()),a&&C&&(A.strokeStyle=a,A.lineWidth=C,A.stroke()),A.restore()}function cz(t){return"ccw_rotation"in t&&typeof t.ccw_rotation=="number"?t.ccw_rotation:0}function kQe(t){const{ctx:A,hole:e,realToCanvasMat:i,colorMap:n,soldermaskMargin:o=0,drawSoldermask:s=!1}=t;if(s&&e.is_covered_with_solder_mask===!0)return;const r=o<0?Math.abs(o):0;if(e.hole_shape==="circle"){tQ({ctx:A,center:{x:e.x,y:e.y},radius:e.hole_diameter/2-r,fill:n.drill,realToCanvasMat:i});return}if(e.hole_shape==="square"){const a=cz(e);eQ({ctx:A,center:{x:e.x,y:e.y},width:e.hole_diameter-r*2,height:e.hole_diameter-r*2,fill:n.drill,realToCanvasMat:i,ccwRotationDegrees:a});return}if(e.hole_shape==="oval"){const a=cz(e);ES({ctx:A,center:{x:e.x,y:e.y},radius_x:e.hole_width/2-r,radius_y:e.hole_height/2-r,fill:n.drill,realToCanvasMat:i,rotation:a});return}if(e.hole_shape==="rect"){const a=cz(e);eQ({ctx:A,center:{x:e.x,y:e.y},width:e.hole_width-r*2,height:e.hole_height-r*2,fill:n.drill,realToCanvasMat:i,ccwRotationDegrees:a});return}if(e.hole_shape==="pill"||e.hole_shape==="rotated_pill"){const a=cz(e);eh({ctx:A,center:{x:e.x,y:e.y},width:e.hole_width-r*2,height:e.hole_height-r*2,fill:n.drill,realToCanvasMat:i,rotation:a});return}}function K6t(t,A){const e=parseInt(t.slice(1,3),16),i=parseInt(t.slice(3,5),16),n=parseInt(t.slice(5,7),16);return`rgba(${e}, ${i}, ${n}, ${A})`}function q6t(t){const{ctx:A,keepout:e,realToCanvasMat:i,colorMap:n}=t,o=n.keepout,s=K6t(n.keepout,.2),r=1;if(e.shape==="rect"){const[a,g]=ai(i,[e.center.x,e.center.y]),c=e.width*Math.abs(i.a),I=e.height*Math.abs(i.a),l=e.rotation??0;A.save(),A.translate(a,g),l!==0&&A.rotate(-l*(Math.PI/180)),A.beginPath(),A.rect(-c/2,-I/2,c,I),A.fillStyle=s,A.fill(),A.beginPath(),A.rect(-c/2,-I/2,c,I),A.clip();const B=r*Math.abs(i.a),C=Math.sqrt(c*c+I*I),Q=c/2,h=I/2;A.strokeStyle=o,A.lineWidth=.15*Math.abs(i.a),A.setLineDash([]);for(let E=-C;E<C*2;E+=B){A.beginPath();const u=-Q+E,d=-h,f=-Q+E+C,m=-h+C;A.moveTo(u,d),A.lineTo(f,m),A.stroke()}A.restore();return}if(e.shape==="circle"){const[a,g]=ai(i,[e.center.x,e.center.y]),c=e.radius*Math.abs(i.a),I=r*Math.abs(i.a);A.save(),A.translate(a,g),A.beginPath(),A.arc(0,0,c,0,Math.PI*2),A.fillStyle=s,A.fill(),A.beginPath(),A.arc(0,0,c,0,Math.PI*2),A.clip();const l=c*2;A.strokeStyle=o,A.lineWidth=.15*Math.abs(i.a),A.setLineDash([]);for(let B=-l;B<l*2;B+=I)A.beginPath(),A.moveTo(B-l,-l),A.lineTo(B+l,l),A.stroke();A.restore();return}}var O6t="rgba(255,255,255,0.5)";function W6t(t){const{ctx:A,pcbNoteDimension:e,realToCanvasMat:i}=t,n=e.color??O6t;_Qe({ctx:A,from:e.from,to:e.to,realToCanvasMat:i,color:n,fontSize:e.font_size,arrowSize:e.arrow_size,text:e.text,textRotation:e.text_ccw_rotation,offset:e.offset_distance&&e.offset_direction?{distance:e.offset_distance,direction:e.offset_direction}:void 0})}function Z6t(t){const{ctx:A,line:e,realToCanvasMat:i}=t,o=e.color??"rgb(89, 148, 220)",s=e.stroke_width??.1,r=e.is_dashed??!1,[a,g]=ai(i,[e.x1,e.y1]),[c,I]=ai(i,[e.x2,e.y2]),l=s*Math.abs(i.a);A.save(),r?A.setLineDash([l*2,l*2]):A.setLineDash([]),A.beginPath(),A.moveTo(a,g),A.lineTo(c,I),A.lineWidth=l,A.strokeStyle=o,A.lineCap="round",A.stroke(),A.restore()}function V6t(t){const{ctx:A,path:e,realToCanvasMat:i}=t,o=e.color??"rgb(89, 148, 220)";if(!(!e.route||e.route.length<2))for(let s=0;s<e.route.length-1;s++){const r=e.route[s],a=e.route[s+1];!r||!a||E2({ctx:A,start:{x:r.x,y:r.y},end:{x:a.x,y:a.y},strokeWidth:e.stroke_width??.1,stroke:o,realToCanvasMat:i})}}function j6t(t){const{ctx:A,rect:e,realToCanvasMat:i}=t,o=e.color??"rgb(89, 148, 220)",s=e.is_filled??!1,r=e.has_stroke??!0,a=e.is_stroke_dashed??!1;eQ({ctx:A,center:e.center,width:e.width,height:e.height,fill:s?o:void 0,stroke:r?o:void 0,strokeWidth:r?e.stroke_width:void 0,borderRadius:e.corner_radius,realToCanvasMat:i,isStrokeDashed:a})}var z6t="rgb(89, 148, 220)";function X6t(t){const{ctx:A,text:e,realToCanvasMat:i}=t,n=z6t,o=e.color??n,s=e.font_size??1;gz({ctx:A,text:e.text??"",x:e.anchor_position.x,y:e.anchor_position.y,fontSize:s,color:o,realToCanvasMat:i,anchorAlignment:e.anchor_alignment??"center"})}function $6t(t){const{ctx:A,panel:e,realToCanvasMat:i,colorMap:n}=t,{width:o,height:s,center:r}=e;if(o!==void 0&&s!==void 0&&r){const a=o/2,g=s/2,c=[{x:r.x-a,y:r.y-g},{x:r.x+a,y:r.y-g},{x:r.x+a,y:r.y+g},{x:r.x-a,y:r.y+g}];az({ctx:A,points:c,stroke:n.boardOutline,strokeWidth:.5,realToCanvasMat:i,closePath:!0})}}function LT(t,A){if(t.length<3||A===0)return t;let e=0,i=0;for(const o of t)e+=o.x,i+=o.y;e/=t.length,i/=t.length;const n=[];for(const o of t){const s=o.x-e,r=o.y-i,a=Math.sqrt(s*s+r*r);if(a>0){const g=s/a,c=r/a;n.push({x:o.x+g*A,y:o.y+c*A})}else n.push({x:o.x+A,y:o.y})}return n}function vQe(t){const{ctx:A,hole:e,realToCanvasMat:i,colorMap:n,soldermaskMargin:o=0,drawSoldermask:s}=t;if(e.is_covered_with_solder_mask===!0&&s)return;const r=n.copper[t.layer??"top"],a=o<0?Math.abs(o):0;if(e.shape==="circle"){tQ({ctx:A,center:{x:e.x,y:e.y},radius:e.outer_diameter/2-a,fill:r,realToCanvasMat:i}),uS(A,()=>{tQ({ctx:A,center:{x:e.x,y:e.y},radius:e.hole_diameter/2,fill:"#000",realToCanvasMat:i})}),tQ({ctx:A,center:{x:e.x,y:e.y},radius:e.hole_diameter/2,fill:n.drill,realToCanvasMat:i});return}if(e.shape==="oval"){ES({ctx:A,center:{x:e.x,y:e.y},radius_x:e.outer_width/2-a,radius_y:e.outer_height/2-a,fill:r,realToCanvasMat:i,rotation:e.ccw_rotation}),uS(A,()=>{ES({ctx:A,center:{x:e.x,y:e.y},radius_x:e.hole_width/2,radius_y:e.hole_height/2,fill:"#000",realToCanvasMat:i,rotation:e.ccw_rotation})}),ES({ctx:A,center:{x:e.x,y:e.y},radius_x:e.hole_width/2,radius_y:e.hole_height/2,fill:n.drill,realToCanvasMat:i,rotation:e.ccw_rotation});return}if(e.shape==="pill"){eh({ctx:A,center:{x:e.x,y:e.y},width:e.outer_width-a*2,height:e.outer_height-a*2,fill:r,realToCanvasMat:i,rotation:e.ccw_rotation}),uS(A,()=>{eh({ctx:A,center:{x:e.x,y:e.y},width:e.hole_width,height:e.hole_height,fill:"#000",realToCanvasMat:i,rotation:e.ccw_rotation})}),eh({ctx:A,center:{x:e.x,y:e.y},width:e.hole_width,height:e.hole_height,fill:n.drill,realToCanvasMat:i,rotation:e.ccw_rotation});return}if(e.shape==="circular_hole_with_rect_pad"){eQ({ctx:A,center:{x:e.x,y:e.y},width:e.rect_pad_width-a*2,height:e.rect_pad_height-a*2,fill:r,realToCanvasMat:i,borderRadius:e.rect_border_radius?Math.max(0,e.rect_border_radius-a):0,ccwRotationDegrees:e.rect_ccw_rotation});const g=e.x+(e.hole_offset_x??0),c=e.y+(e.hole_offset_y??0);uS(A,()=>{tQ({ctx:A,center:{x:g,y:c},radius:e.hole_diameter/2,fill:"#000",realToCanvasMat:i})}),tQ({ctx:A,center:{x:g,y:c},radius:e.hole_diameter/2,fill:n.drill,realToCanvasMat:i});return}if(e.shape==="pill_hole_with_rect_pad"){eQ({ctx:A,center:{x:e.x,y:e.y},width:e.rect_pad_width-a*2,height:e.rect_pad_height-a*2,fill:r,realToCanvasMat:i,borderRadius:e.rect_border_radius?Math.max(0,e.rect_border_radius-a):0});const g=e.x+(e.hole_offset_x??0),c=e.y+(e.hole_offset_y??0);uS(A,()=>{eh({ctx:A,center:{x:g,y:c},width:e.hole_width,height:e.hole_height,fill:"#000",realToCanvasMat:i})}),eh({ctx:A,center:{x:g,y:c},width:e.hole_width,height:e.hole_height,fill:n.drill,realToCanvasMat:i});return}if(e.shape==="rotated_pill_hole_with_rect_pad"){eQ({ctx:A,center:{x:e.x,y:e.y},width:e.rect_pad_width-a*2,height:e.rect_pad_height-a*2,fill:r,realToCanvasMat:i,borderRadius:e.rect_border_radius?Math.max(0,e.rect_border_radius-a):0,ccwRotationDegrees:e.rect_ccw_rotation});const g=e.x+(e.hole_offset_x??0),c=e.y+(e.hole_offset_y??0);uS(A,()=>{eh({ctx:A,center:{x:g,y:c},width:e.hole_width,height:e.hole_height,fill:"#000",realToCanvasMat:i,rotation:e.hole_ccw_rotation})}),eh({ctx:A,center:{x:g,y:c},width:e.hole_width,height:e.hole_height,fill:n.drill,realToCanvasMat:i,rotation:e.hole_ccw_rotation});return}if(e.shape==="hole_with_polygon_pad"){const g=e.pad_outline;if(g&&g.length>=3){const B=g.map(Q=>({x:e.x+Q.x,y:e.y+Q.y})),C=a>0?LT(B,-a):B;C.length>=3&&Hk({ctx:A,points:C,fill:r,realToCanvasMat:i})}const c=e.x+(e.hole_offset_x??0),I=e.y+(e.hole_offset_y??0),l=e.hole_shape;l==="circle"?(uS(A,()=>{tQ({ctx:A,center:{x:c,y:I},radius:(e.hole_diameter??0)/2,fill:"#000",realToCanvasMat:i})}),tQ({ctx:A,center:{x:c,y:I},radius:(e.hole_diameter??0)/2,fill:n.drill,realToCanvasMat:i})):l==="oval"?(uS(A,()=>{ES({ctx:A,center:{x:c,y:I},radius_x:(e.hole_width??0)/2,radius_y:(e.hole_height??0)/2,fill:"#000",realToCanvasMat:i})}),ES({ctx:A,center:{x:c,y:I},radius_x:(e.hole_width??0)/2,radius_y:(e.hole_height??0)/2,fill:n.drill,realToCanvasMat:i})):l==="pill"?(uS(A,()=>{eh({ctx:A,center:{x:c,y:I},width:e.hole_width??0,height:e.hole_height??0,fill:"#000",realToCanvasMat:i})}),eh({ctx:A,center:{x:c,y:I},width:e.hole_width??0,height:e.hole_height??0,fill:n.drill,realToCanvasMat:i})):l==="rotated_pill"&&(uS(A,()=>{eh({ctx:A,center:{x:c,y:I},width:e.hole_width??0,height:e.hole_height??0,fill:"#000",realToCanvasMat:i})}),eh({ctx:A,center:{x:c,y:I},width:e.hole_width??0,height:e.hole_height??0,fill:n.drill,realToCanvasMat:i}));return}}function uS(t,A){t.save(),t.globalCompositeOperation="destination-out",A(),t.restore()}function A7t(t,A){return t==="bottom"?A.silkscreen.bottom:A.silkscreen.top}function e7t(t){const{ctx:A,circle:e,realToCanvasMat:i,colorMap:n}=t,o=A7t(e.layer,n);tQ({ctx:A,center:e.center,radius:e.radius,stroke:o,strokeWidth:e.stroke_width,realToCanvasMat:i})}function t7t(t,A){return t==="bottom"?A.silkscreen.bottom:A.silkscreen.top}function i7t(t){const{ctx:A,line:e,realToCanvasMat:i,colorMap:n}=t,o=t7t(e.layer,n);E2({ctx:A,start:{x:e.x1,y:e.y1},end:{x:e.x2,y:e.y2},strokeWidth:e.stroke_width??.1,stroke:o,realToCanvasMat:i})}function n7t(t,A){return t==="bottom"?A.silkscreen.bottom:A.silkscreen.top}function o7t(t){const{ctx:A,oval:e,realToCanvasMat:i,colorMap:n}=t,o=n7t(e.layer,n);ES({ctx:A,center:e.center,radius_x:e.radius_x,radius_y:e.radius_y,stroke:o,strokeWidth:.1,realToCanvasMat:i,rotation:e.ccw_rotation??0})}function s7t(t,A){return t==="bottom"?A.silkscreen.bottom:A.silkscreen.top}function r7t(t){const{ctx:A,path:e,realToCanvasMat:i,colorMap:n}=t,o=s7t(e.layer,n);if(!(!e.route||e.route.length<2))for(let s=0;s<e.route.length-1;s++){const r=e.route[s],a=e.route[s+1];!r||!a||E2({ctx:A,start:{x:r.x,y:r.y},end:{x:a.x,y:a.y},strokeWidth:e.stroke_width??.1,stroke:o,realToCanvasMat:i})}}function a7t(t,A){return t==="bottom"?A.silkscreen.bottom:A.silkscreen.top}function g7t(t){const{ctx:A,pill:e,realToCanvasMat:i,colorMap:n}=t,o=a7t(e.layer,n);eh({ctx:A,center:e.center,width:e.width,height:e.height,stroke:o,strokeWidth:.2,realToCanvasMat:i})}function c7t(t,A){return t==="bottom"?A.silkscreen.bottom:A.silkscreen.top}function I7t(t){const{ctx:A,rect:e,realToCanvasMat:i,colorMap:n}=t,o=c7t(e.layer,n);eQ({ctx:A,center:e.center,width:e.width,height:e.height,fill:e.is_filled?o:"transparent",stroke:o,strokeWidth:e.stroke_width,realToCanvasMat:i})}function l7t(t,A){return t==="bottom"?A.silkscreen.bottom:A.silkscreen.top}function B7t(t){return t||"center"}function C7t(t){const{ctx:A,text:e,realToCanvasMat:i,colorMap:n}=t,o=e.text??"";if(!o)return;const s=l7t(e.layer,n),r=B7t(e.anchor_alignment),a=e.font_size??1;gz({ctx:A,text:o,x:e.anchor_position.x,y:e.anchor_position.y,fontSize:a,color:s,realToCanvasMat:i,anchorAlignment:r,rotation:e.ccw_rotation??0,mirrorX:e.layer==="bottom",knockout:e.is_knockout,knockoutPadding:e.is_knockout?e.knockout_padding:void 0})}function Q7t(t,A){return A.copper[t]??A.copper.top}function FQe(t){return t.shape==="rect"||t.shape==="rotated_rect"?t.corner_radius??t.rect_border_radius??0:0}function h7t(t){const{ctx:A,pad:e,realToCanvasMat:i,colorMap:n}=t,o=Q7t(e.layer,n);if(e.shape==="rect"){eQ({ctx:A,center:{x:e.x,y:e.y},width:e.width,height:e.height,fill:o,realToCanvasMat:i,borderRadius:FQe(e)});return}if(e.shape==="rotated_rect"){eQ({ctx:A,center:{x:e.x,y:e.y},width:e.width,height:e.height,fill:o,realToCanvasMat:i,borderRadius:FQe(e),ccwRotationDegrees:e.ccw_rotation??0});return}if(e.shape==="circle"){tQ({ctx:A,center:{x:e.x,y:e.y},radius:e.radius,fill:o,realToCanvasMat:i});return}if(e.shape==="pill"){eh({ctx:A,center:{x:e.x,y:e.y},width:e.width,height:e.height,fill:o,realToCanvasMat:i});return}if(e.shape==="rotated_pill"){eh({ctx:A,center:{x:e.x,y:e.y},width:e.width,height:e.height,fill:o,realToCanvasMat:i,rotation:e.ccw_rotation??0});return}if(e.shape==="polygon"){e.points&&e.points.length>=3&&Hk({ctx:A,points:e.points,fill:o,realToCanvasMat:i});return}}function Yk(t){const{ctx:A,points:e}=t;if(e.length<3)return;const i=e[0];if(i){A.moveTo(i.x,i.y);for(let n=1;n<e.length;n++){const o=e[n];o&&A.lineTo(o.x,o.y)}A.closePath()}}function MQe(t){const{ctx:A,board:e,realToCanvasMat:i,soldermaskColor:n}=t,{width:o,height:s,center:r,outline:a}=e;if(a&&Array.isArray(a)&&a.length>=3){const g=a.map(c=>{const[I,l]=ai(i,[c.x,c.y]);return{x:I,y:l}});A.beginPath(),Yk({ctx:A,points:g}),A.fillStyle=n,A.fill()}else if(o!==void 0&&s!==void 0&&r){const[g,c]=ai(i,[r.x,r.y]),I=o*Math.abs(i.a),l=s*Math.abs(i.a);A.fillStyle=n,A.fillRect(g-I/2,c-l/2,I,l)}}function E7t(t){return"createPattern"in t&&typeof Reflect.get(t,"createPattern")=="function"}function u7t(t,A){if(t===A||A.canvas.width<=0||A.canvas.height<=0||!E7t(t))return;let e=null;try{e=t.createPattern(A.canvas,"no-repeat")}catch{return}e&&(t.save(),t.globalCompositeOperation="source-over",t.fillStyle=e,t.fillRect(0,0,A.canvas.width,A.canvas.height),t.restore())}function d7t(t){return typeof t=="function"}function p7t(t,A,e){if(A<=0||e<=0)return null;const i=globalThis;let n=null;if("OffscreenCanvas"in i&&typeof i.OffscreenCanvas=="function")n=new i.OffscreenCanvas(A,e);else if("document"in i&&i.document&&typeof i.document.createElement=="function"){const o=i.document.createElement("canvas");o.width=A,o.height=e,n=o}else{const o=t.canvas.constructor;if(d7t(o))try{n=new o(A,e)}catch{return null}}return n?n.getContext("2d"):null}function f7t(t){const{ctx:A,panel:e,realToCanvasMat:i,soldermaskColor:n}=t,{width:o,height:s,center:r}=e;if(o===void 0||s===void 0||!r)return;const[a,g]=ai(i,[r.x,r.y]),c=o*Math.abs(i.a),I=s*Math.abs(i.a);A.fillStyle=n,A.fillRect(a-c/2,g-I/2,c,I)}function ry(t){const{ctx:A,cx:e,cy:i,width:n,height:o,radius:s,ccwRotationDegrees:r=0}=t,a=r*Math.PI/180,g=VyA(Uk(e,i),mQe(-a)),c=n/2,I=o/2,l=Math.min(s,c,I);if(l>0){const B=ai(g,{x:-c,y:-I}),C=ai(g,{x:c,y:-I}),Q=ai(g,{x:c,y:I}),h=ai(g,{x:-c,y:I}),E=ai(g,{x:-c,y:0});A.moveTo(E.x,E.y),A.arcTo(B.x,B.y,C.x,C.y,l),A.arcTo(C.x,C.y,Q.x,Q.y,l),A.arcTo(Q.x,Q.y,h.x,h.y,l),A.arcTo(h.x,h.y,B.x,B.y,l)}else{const B=ai(g,{x:-c,y:-I}),C=ai(g,{x:c,y:-I}),Q=ai(g,{x:c,y:I}),h=ai(g,{x:-c,y:I});A.moveTo(B.x,B.y),A.lineTo(C.x,C.y),A.lineTo(Q.x,Q.y),A.lineTo(h.x,h.y)}A.closePath()}function ay(t){t.save(),t.globalCompositeOperation="destination-out",t.fill(),t.restore()}function y7t(t){const{ctx:A,cutout:e,realToCanvasMat:i}=t;if(e.shape==="rect"){const[n,o]=ai(i,[e.center?.x??0,e.center?.y??0]),s=e.width*Math.abs(i.a),r=e.height*Math.abs(i.a),a=(e.corner_radius??0)*Math.abs(i.a);A.save(),A.translate(n,o),e.rotation&&A.rotate(-e.rotation*Math.PI/180),A.beginPath(),ry({ctx:A,cx:0,cy:0,width:s,height:r,radius:a}),A.restore(),ay(A)}else if(e.shape==="circle"){const[n,o]=ai(i,[e.center?.x??0,e.center?.y??0]),s=e.radius*Math.abs(i.a);A.beginPath(),A.arc(n,o,s,0,Math.PI*2),A.closePath(),ay(A)}else if(e.shape==="polygon"&&e.points&&e.points.length>=3){const n=e.points.map(o=>{const[s,r]=ai(i,[o.x,o.y]);return{x:s,y:r}});A.beginPath(),Yk({ctx:A,points:n}),ay(A)}}var Xh="rgba(255, 255, 255, 1)";function $yA(t){const{ctx:A,elements:e,layer:i,realToCanvasMat:n}=t;A.save(),A.globalCompositeOperation="destination-out";for(const o of e){if(o.type==="pcb_smtpad"){if(o.layer!==i||o.is_covered_with_solder_mask===!0)continue;m7t({ctx:A,pad:o,realToCanvasMat:n});continue}if(o.type==="pcb_plated_hole"){if(o.layers&&!o.layers.includes(i)||o.is_covered_with_solder_mask===!0)continue;w7t({ctx:A,hole:o,realToCanvasMat:n});continue}if(o.type==="pcb_via"){if(o.layers&&!o.layers.includes(i))continue;tQ({ctx:A,center:{x:o.x,y:o.y},radius:o.outer_diameter/2,fill:Xh,realToCanvasMat:n});continue}if(o.type==="pcb_hole"){if(o.is_covered_with_solder_mask===!0)continue;D7t({ctx:A,hole:o,realToCanvasMat:n})}}A.restore()}function m7t(t){const{ctx:A,pad:e,realToCanvasMat:i}=t;if(e.shape==="rect"){eQ({ctx:A,center:{x:e.x,y:e.y},width:e.width,height:e.height,borderRadius:e.corner_radius??e.rect_border_radius??0,fill:Xh,realToCanvasMat:i});return}if(e.shape==="rotated_rect"){eQ({ctx:A,center:{x:e.x,y:e.y},width:e.width,height:e.height,borderRadius:e.corner_radius??e.rect_border_radius??0,ccwRotationDegrees:e.ccw_rotation??0,fill:Xh,realToCanvasMat:i});return}if(e.shape==="circle"){tQ({ctx:A,center:{x:e.x,y:e.y},radius:e.radius,fill:Xh,realToCanvasMat:i});return}if(e.shape==="pill"||e.shape==="rotated_pill"){eh({ctx:A,center:{x:e.x,y:e.y},width:e.width,height:e.height,rotation:e.shape==="rotated_pill"?e.ccw_rotation??0:0,fill:Xh,realToCanvasMat:i});return}e.shape==="polygon"&&e.points&&e.points.length>=3&&Hk({ctx:A,points:e.points,fill:Xh,realToCanvasMat:i})}function w7t(t){const{ctx:A,hole:e,realToCanvasMat:i}=t;if(e.shape==="circle"){tQ({ctx:A,center:{x:e.x,y:e.y},radius:e.outer_diameter/2,fill:Xh,realToCanvasMat:i});return}if(e.shape==="oval"){ES({ctx:A,center:{x:e.x,y:e.y},radius_x:e.outer_width/2,radius_y:e.outer_height/2,rotation:e.ccw_rotation,fill:Xh,realToCanvasMat:i});return}if(e.shape==="pill"){eh({ctx:A,center:{x:e.x,y:e.y},width:e.outer_width,height:e.outer_height,rotation:e.ccw_rotation,fill:Xh,realToCanvasMat:i});return}if(e.shape==="circular_hole_with_rect_pad"){eQ({ctx:A,center:{x:e.x,y:e.y},width:e.rect_pad_width,height:e.rect_pad_height,borderRadius:e.rect_border_radius??0,ccwRotationDegrees:e.rect_ccw_rotation,fill:Xh,realToCanvasMat:i});return}if(e.shape==="pill_hole_with_rect_pad"){eQ({ctx:A,center:{x:e.x,y:e.y},width:e.rect_pad_width,height:e.rect_pad_height,borderRadius:e.rect_border_radius??0,fill:Xh,realToCanvasMat:i});return}if(e.shape==="rotated_pill_hole_with_rect_pad"){eQ({ctx:A,center:{x:e.x,y:e.y},width:e.rect_pad_width,height:e.rect_pad_height,borderRadius:e.rect_border_radius??0,ccwRotationDegrees:e.rect_ccw_rotation,fill:Xh,realToCanvasMat:i});return}e.shape==="hole_with_polygon_pad"&&e.pad_outline&&e.pad_outline.length>=3&&Hk({ctx:A,points:e.pad_outline.map(n=>({x:e.x+n.x,y:e.y+n.y})),fill:Xh,realToCanvasMat:i})}function D7t(t){const{ctx:A,hole:e,realToCanvasMat:i}=t,n="ccw_rotation"in e&&typeof e.ccw_rotation=="number"?e.ccw_rotation:0;if(e.hole_shape==="circle"){tQ({ctx:A,center:{x:e.x,y:e.y},radius:e.hole_diameter/2,fill:Xh,realToCanvasMat:i});return}if(e.hole_shape==="square"){eQ({ctx:A,center:{x:e.x,y:e.y},width:e.hole_diameter,height:e.hole_diameter,ccwRotationDegrees:n,fill:Xh,realToCanvasMat:i});return}if(e.hole_shape==="oval"){ES({ctx:A,center:{x:e.x,y:e.y},radius_x:e.hole_width/2,radius_y:e.hole_height/2,rotation:n,fill:Xh,realToCanvasMat:i});return}if(e.hole_shape==="rect"){eQ({ctx:A,center:{x:e.x,y:e.y},width:e.hole_width,height:e.hole_height,ccwRotationDegrees:n,fill:Xh,realToCanvasMat:i});return}(e.hole_shape==="pill"||e.hole_shape==="rotated_pill")&&eh({ctx:A,center:{x:e.x,y:e.y},width:e.hole_width,height:e.hole_height,rotation:n,fill:Xh,realToCanvasMat:i})}function S7t(t,A,e,i,n){if(Math.abs(n)<1e-10)return null;const o=e-t,s=i-A,r=Math.hypot(o,s);if(r<1e-10)return null;const a=Math.abs(n)*(r/2),g=r/2,c=(a*a+g*g)/(2*a),I=c-a,l=(t+e)/2,B=(A+i)/2,C=-s/r,Q=o/r,h=n>0?-1:1;return{centerX:l+h*C*I,centerY:B+h*Q*I,radius:c}}function AmA(t,A,e,i,n,o,s){if(Math.abs(o)<1e-10){const[f,m]=ai(s,[i,n]);t.lineTo(f,m);return}const r=S7t(A,e,i,n,o);if(!r){const[f,m]=ai(s,[i,n]);t.lineTo(f,m);return}const[a,g]=ai(s,[A,e]),[c,I]=ai(s,[i,n]),[l,B]=ai(s,[r.centerX,r.centerY]),C=Math.hypot(a-l,g-B),Q=Math.atan2(g-B,a-l),h=Math.atan2(I-B,c-l),u=s.a*s.d-s.b*s.c<0,d=o>0?!u:u;t.arc(l,B,C,Q,h,d)}function RQe(t,A,e){if(A.vertices.length<2)return;if(A.vertices.length===2){const s=A.vertices[0],r=A.vertices[1];if(s&&r&&Math.abs((s.bulge??0)-1)<1e-10&&Math.abs((r.bulge??0)-1)<1e-10){const[a,g]=ai(e,[s.x,s.y]);t.moveTo(a,g),AmA(t,s.x,s.y,r.x,r.y,1,e),AmA(t,r.x,r.y,s.x,s.y,1,e);return}}const i=A.vertices[0];if(!i)return;const[n,o]=ai(e,[i.x,i.y]);t.moveTo(n,o);for(let s=0;s<A.vertices.length;s++){const r=A.vertices[s],a=A.vertices[(s+1)%A.vertices.length];if(!r||!a)continue;const g=r.bulge??0;if(Math.abs(g)<1e-10){const[c,I]=ai(e,[a.x,a.y]);t.lineTo(c,I)}else AmA(t,r.x,r.y,a.x,a.y,g,e)}}function b7t(t){const{ctx:A,pour:e,realToCanvasMat:i,soldermaskOverCopperColor:n,layer:o,elements:s}=t;if(e.layer===o&&e.covered_with_solder_mask===!0){if(A.save(),A.fillStyle=n,e.shape==="rect"){const[r,a]=ai(i,[e.center.x,e.center.y]),g=e.width*Math.abs(i.a),c=e.height*Math.abs(i.a);A.translate(r,a),e.rotation&&A.rotate(-e.rotation*(Math.PI/180)),A.beginPath(),A.rect(-g/2,-c/2,g,c),A.fill(),A.restore(),$yA({ctx:A,elements:s,layer:o,realToCanvasMat:i});return}if(e.shape==="polygon"){if(e.points&&e.points.length>=3){const r=e.points.map(g=>ai(i,[g.x,g.y])),a=r[0];if(a){A.beginPath();const[g,c]=a;A.moveTo(g,c);for(let I=1;I<r.length;I++){const l=r[I];if(!l)continue;const[B,C]=l;A.lineTo(B,C)}A.closePath(),A.fill(),$yA({ctx:A,elements:s,layer:o,realToCanvasMat:i})}}A.restore();return}if(e.shape==="brep"){if(A.beginPath(),RQe(A,e.brep_shape.outer_ring,i),e.brep_shape.inner_rings)for(const r of e.brep_shape.inner_rings)RQe(A,r,i);A.fill("evenodd"),$yA({ctx:A,elements:s,layer:o,realToCanvasMat:i}),A.restore();return}A.restore()}}function ix(t){const{ctx:A,cx:e,cy:i,width:n,height:o,ccwRotationDegrees:s=0}=t,r=s*Math.PI/180,a=VyA(Uk(e,i),mQe(-r));if(n>o){const g=o/2,c=(n-o)/2,I=ai(a,{x:-c,y:0}),l=ai(a,{x:c,y:0}),B=ai(a,{x:c,y:-g});A.moveTo(B.x,B.y),A.arc(l.x,l.y,g,-r-Math.PI/2,-r+Math.PI/2),A.arc(I.x,I.y,g,-r+Math.PI/2,-r-Math.PI/2)}else if(o>n){const g=n/2,c=(o-n)/2,I=ai(a,{x:0,y:-c}),l=ai(a,{x:0,y:c}),B=ai(a,{x:g,y:c});A.moveTo(B.x,B.y),A.arc(l.x,l.y,g,-r,-r+Math.PI),A.arc(I.x,I.y,g,-r+Math.PI,-r)}else{const g=n/2;A.moveTo(e+g,i),A.arc(e,i,g,0,Math.PI*2)}A.closePath()}function x7t(t){const{ctx:A,hole:e,realToCanvasMat:i,soldermaskOverCopperColor:n}=t,o=e.is_covered_with_solder_mask===!0,s=e.soldermask_margin??0;o?(A.fillStyle=n,Iz({ctx:A,hole:e,realToCanvasMat:i,margin:0}),A.fill()):s<0?(Iz({ctx:A,hole:e,realToCanvasMat:i,margin:s}),ay(A),_7t({ctx:A,hole:e,realToCanvasMat:i,soldermaskOverCopperColor:n,margin:s})):s>0?(Iz({ctx:A,hole:e,realToCanvasMat:i,margin:s}),ay(A)):(Iz({ctx:A,hole:e,realToCanvasMat:i,margin:0}),ay(A))}function NQe(t){return"ccw_rotation"in t&&typeof t.ccw_rotation=="number"?t.ccw_rotation:0}function Iz(t){const{ctx:A,hole:e,realToCanvasMat:i,margin:n}=t,o=NQe(e);if(e.hole_shape==="circle"){const[s,r]=ai(i,[e.x,e.y]),a=(e.hole_diameter/2+n)*Math.abs(i.a);A.beginPath(),A.arc(s,r,a,0,Math.PI*2),A.closePath()}else if(e.hole_shape==="square"){const[s,r]=ai(i,[e.x,e.y]),a=(e.hole_diameter+n*2)*Math.abs(i.a);A.save(),A.translate(s,r),o!==0&&A.rotate(-o*Math.PI/180),A.beginPath(),A.rect(-a/2,-a/2,a,a),A.closePath(),A.restore()}else if(e.hole_shape==="oval"){const[s,r]=ai(i,[e.x,e.y]),a=(e.hole_width/2+n)*Math.abs(i.a),g=(e.hole_height/2+n)*Math.abs(i.a);A.save(),A.translate(s,r),o!==0&&A.rotate(-o*Math.PI/180),A.beginPath(),A.ellipse(0,0,a,g,0,0,Math.PI*2),A.closePath(),A.restore()}else if(e.hole_shape==="rect"){const[s,r]=ai(i,[e.x,e.y]),a=(e.hole_width+n*2)*Math.abs(i.a),g=(e.hole_height+n*2)*Math.abs(i.a);A.save(),A.translate(s,r),o!==0&&A.rotate(-o*Math.PI/180),A.beginPath(),A.rect(-a/2,-g/2,a,g),A.closePath(),A.restore()}else if(e.hole_shape==="pill"||e.hole_shape==="rotated_pill"){const[s,r]=ai(i,[e.x,e.y]),a=(e.hole_width+n*2)*Math.abs(i.a),g=(e.hole_height+n*2)*Math.abs(i.a);A.save(),A.translate(s,r),o!==0&&A.rotate(-o*Math.PI/180),A.beginPath(),ix({ctx:A,cx:0,cy:0,width:a,height:g}),A.restore()}}function _7t(t){const{ctx:A,hole:e,realToCanvasMat:i,soldermaskOverCopperColor:n,margin:o}=t,s=Math.abs(o),r=NQe(e);if(A.fillStyle=n,e.hole_shape==="circle"){const[a,g]=ai(i,[e.x,e.y]),c=e.hole_diameter/2*Math.abs(i.a),I=s*Math.abs(i.a),l=Math.max(0,c-I);A.save(),A.beginPath(),A.arc(a,g,c,0,Math.PI*2),l>0&&A.arc(a,g,l,0,Math.PI*2,!0),A.fill("evenodd"),A.restore()}else if(e.hole_shape==="square"){const[a,g]=ai(i,[e.x,e.y]),c=e.hole_diameter*Math.abs(i.a),I=s*Math.abs(i.a),l=Math.max(0,c-I*2);A.save(),A.translate(a,g),r!==0&&A.rotate(-r*Math.PI/180),A.beginPath(),A.rect(-c/2,-c/2,c,c),l>0&&A.rect(-l/2,-l/2,l,l),A.fill("evenodd"),A.restore()}else if(e.hole_shape==="oval"){const[a,g]=ai(i,[e.x,e.y]),c=e.hole_width/2*Math.abs(i.a),I=e.hole_height/2*Math.abs(i.a),l=s*Math.abs(i.a),B=Math.max(0,c-l),C=Math.max(0,I-l);A.save(),A.translate(a,g),r!==0&&A.rotate(-r*Math.PI/180),A.beginPath(),A.ellipse(0,0,c,I,0,0,Math.PI*2),B>0&&C>0&&(A.moveTo(B,0),A.ellipse(0,0,B,C,0,0,Math.PI*2)),A.fill("evenodd"),A.restore()}else if(e.hole_shape==="rect"){const[a,g]=ai(i,[e.x,e.y]),c=e.hole_width*Math.abs(i.a),I=e.hole_height*Math.abs(i.a),l=s*Math.abs(i.a),B=Math.max(0,c-l*2),C=Math.max(0,I-l*2);A.save(),A.translate(a,g),r!==0&&A.rotate(-r*Math.PI/180),A.beginPath(),A.rect(-c/2,-I/2,c,I),B>0&&C>0&&A.rect(-B/2,-C/2,B,C),A.fill("evenodd"),A.restore()}else if(e.hole_shape==="pill"||e.hole_shape==="rotated_pill"){const[a,g]=ai(i,[e.x,e.y]),c=e.hole_width*Math.abs(i.a),I=e.hole_height*Math.abs(i.a),l=s*Math.abs(i.a);A.save(),A.translate(a,g),r!==0&&A.rotate(-r*Math.PI/180),A.beginPath(),ix({ctx:A,cx:0,cy:0,width:c,height:I});const B=c-l*2,C=I-l*2;B>0&&C>0&&ix({ctx:A,cx:0,cy:0,width:B,height:C}),A.fill("evenodd"),A.restore()}}function k7t(t){const{ctx:A,hole:e,realToCanvasMat:i,soldermaskOverCopperColor:n,layer:o}=t;if(e.layers&&!e.layers.includes(o))return;const s=e.is_covered_with_solder_mask===!0,r=e.soldermask_margin??0;s?(A.fillStyle=n,lz({ctx:A,hole:e,realToCanvasMat:i,margin:0}),A.fill()):r<0?(lz({ctx:A,hole:e,realToCanvasMat:i,margin:r}),ay(A),v7t({ctx:A,hole:e,realToCanvasMat:i,soldermaskOverCopperColor:n,margin:r})):r>0?(lz({ctx:A,hole:e,realToCanvasMat:i,margin:r}),ay(A)):(lz({ctx:A,hole:e,realToCanvasMat:i,margin:0}),ay(A))}function lz(t){const{ctx:A,hole:e,realToCanvasMat:i,margin:n}=t;if(e.shape==="circle"){const[o,s]=ai(i,[e.x,e.y]),r=(e.outer_diameter/2+n)*Math.abs(i.a);A.beginPath(),A.arc(o,s,r,0,Math.PI*2),A.closePath()}else if(e.shape==="oval"){const[o,s]=ai(i,[e.x,e.y]),r=(e.outer_width/2+n)*Math.abs(i.a),a=(e.outer_height/2+n)*Math.abs(i.a);A.beginPath(),A.ellipse(o,s,r,a,-((e.ccw_rotation??0)*Math.PI)/180,0,Math.PI*2),A.closePath()}else if(e.shape==="pill"){const[o,s]=ai(i,[e.x,e.y]),r=(e.outer_width+n*2)*Math.abs(i.a),a=(e.outer_height+n*2)*Math.abs(i.a);A.beginPath(),ix({ctx:A,cx:o,cy:s,width:r,height:a,ccwRotationDegrees:e.ccw_rotation})}else if(e.shape==="circular_hole_with_rect_pad"){const[o,s]=ai(i,[e.x,e.y]),r=(e.rect_pad_width+n*2)*Math.abs(i.a),a=(e.rect_pad_height+n*2)*Math.abs(i.a),g=(e.rect_border_radius??0)*Math.abs(i.a);A.beginPath(),ry({ctx:A,cx:o,cy:s,width:r,height:a,radius:g,ccwRotationDegrees:e.rect_ccw_rotation})}else if(e.shape==="pill_hole_with_rect_pad"){const[o,s]=ai(i,[e.x,e.y]),r=(e.rect_pad_width+n*2)*Math.abs(i.a),a=(e.rect_pad_height+n*2)*Math.abs(i.a),g=(e.rect_border_radius??0)*Math.abs(i.a);A.beginPath(),ry({ctx:A,cx:o,cy:s,width:r,height:a,radius:g})}else if(e.shape==="rotated_pill_hole_with_rect_pad"){const[o,s]=ai(i,[e.x,e.y]),r=(e.rect_pad_width+n*2)*Math.abs(i.a),a=(e.rect_pad_height+n*2)*Math.abs(i.a),g=(e.rect_border_radius??0)*Math.abs(i.a);A.beginPath(),ry({ctx:A,cx:o,cy:s,width:r,height:a,radius:g,ccwRotationDegrees:e.rect_ccw_rotation})}else if(e.shape==="hole_with_polygon_pad"&&e.pad_outline&&e.pad_outline.length>=3){const o=e.pad_outline.map(a=>({x:e.x+a.x,y:e.y+a.y})),r=(n!==0?LT(o,n):o).map(a=>{const[g,c]=ai(i,[a.x,a.y]);return{x:g,y:c}});A.beginPath(),Yk({ctx:A,points:r})}}function v7t(t){const{ctx:A,hole:e,realToCanvasMat:i,soldermaskOverCopperColor:n,margin:o}=t,s=Math.abs(o);if(A.fillStyle=n,e.shape==="circle"){const[r,a]=ai(i,[e.x,e.y]),g=e.outer_diameter/2*Math.abs(i.a),c=s*Math.abs(i.a),I=Math.max(0,g-c);A.beginPath(),A.arc(r,a,g,0,Math.PI*2),I>0&&A.arc(r,a,I,0,Math.PI*2,!0),A.fill("evenodd")}else if(e.shape==="oval"){const[r,a]=ai(i,[e.x,e.y]),g=e.outer_width/2*Math.abs(i.a),c=e.outer_height/2*Math.abs(i.a),I=s*Math.abs(i.a),l=Math.max(0,g-I),B=Math.max(0,c-I),C=-((e.ccw_rotation??0)*Math.PI)/180;if(A.beginPath(),A.ellipse(r,a,g,c,C,0,Math.PI*2),l>0&&B>0){const Q=r+l*Math.cos(C),h=a+l*Math.sin(C);A.moveTo(Q,h),A.ellipse(r,a,l,B,C,0,Math.PI*2)}A.fill("evenodd")}else if(e.shape==="pill"){const[r,a]=ai(i,[e.x,e.y]),g=e.outer_width*Math.abs(i.a),c=e.outer_height*Math.abs(i.a),I=s*Math.abs(i.a);A.beginPath(),ix({ctx:A,cx:r,cy:a,width:g,height:c,ccwRotationDegrees:e.ccw_rotation});const l=g-I*2,B=c-I*2;l>0&&B>0&&ix({ctx:A,cx:r,cy:a,width:l,height:B,ccwRotationDegrees:e.ccw_rotation}),A.fill("evenodd")}else if(e.shape==="circular_hole_with_rect_pad"){const[r,a]=ai(i,[e.x,e.y]),g=e.rect_pad_width*Math.abs(i.a),c=e.rect_pad_height*Math.abs(i.a),I=s*Math.abs(i.a),l=e.rect_border_radius?e.rect_border_radius*Math.abs(i.a):0;A.beginPath(),ry({ctx:A,cx:r,cy:a,width:g,height:c,radius:l,ccwRotationDegrees:e.rect_ccw_rotation});const B=g-I*2,C=c-I*2;if(B>0&&C>0){const Q=Math.max(0,l-I);ry({ctx:A,cx:r,cy:a,width:B,height:C,radius:Q,ccwRotationDegrees:e.rect_ccw_rotation})}A.fill("evenodd")}else if(e.shape==="pill_hole_with_rect_pad"){const[r,a]=ai(i,[e.x,e.y]),g=e.rect_pad_width*Math.abs(i.a),c=e.rect_pad_height*Math.abs(i.a),I=s*Math.abs(i.a),l=e.rect_border_radius?e.rect_border_radius*Math.abs(i.a):0;A.beginPath(),ry({ctx:A,cx:r,cy:a,width:g,height:c,radius:l});const B=g-I*2,C=c-I*2;if(B>0&&C>0){const Q=Math.max(0,l-I);ry({ctx:A,cx:r,cy:a,width:B,height:C,radius:Q})}A.fill("evenodd")}else if(e.shape==="rotated_pill_hole_with_rect_pad"){const[r,a]=ai(i,[e.x,e.y]),g=e.rect_pad_width*Math.abs(i.a),c=e.rect_pad_height*Math.abs(i.a),I=s*Math.abs(i.a),l=e.rect_border_radius?e.rect_border_radius*Math.abs(i.a):0;A.beginPath(),ry({ctx:A,cx:r,cy:a,width:g,height:c,radius:l,ccwRotationDegrees:e.rect_ccw_rotation});const B=g-I*2,C=c-I*2;if(B>0&&C>0){const Q=Math.max(0,l-I);ry({ctx:A,cx:r,cy:a,width:B,height:C,radius:Q,ccwRotationDegrees:e.rect_ccw_rotation})}A.fill("evenodd")}else if(e.shape==="hole_with_polygon_pad"&&e.pad_outline&&e.pad_outline.length>=3){const r=e.pad_outline.map(c=>({x:e.x+c.x,y:e.y+c.y}));A.beginPath();const a=r.map(c=>{const[I,l]=ai(i,[c.x,c.y]);return{x:I,y:l}});Yk({ctx:A,points:a});const g=LT(r,-s);if(g.length>=3){const c=g.map(I=>{const[l,B]=ai(i,[I.x,I.y]);return{x:l,y:B}});Yk({ctx:A,points:c})}A.fill("evenodd")}}function F7t(t){const{ctx:A,pad:e,realToCanvasMat:i,soldermaskOverCopperColor:n,layer:o}=t;if(e.layer!==o)return;const s=e.is_covered_with_solder_mask===!0,r=e.soldermask_margin??0;let a=r,g=r,c=r,I=r;(e.shape==="rect"||e.shape==="rotated_rect")&&(a=e.soldermask_margin_left??r,g=e.soldermask_margin_right??r,c=e.soldermask_margin_top??r,I=e.soldermask_margin_bottom??r),s?(A.fillStyle=n,Bz({ctx:A,pad:e,realToCanvasMat:i,ml:0,mr:0,mt:0,mb:0}),A.fill()):a<0||g<0||c<0||I<0?(Bz({ctx:A,pad:e,realToCanvasMat:i,ml:a,mr:g,mt:c,mb:I}),ay(A),M7t({ctx:A,pad:e,realToCanvasMat:i,soldermaskOverCopperColor:n,ml:a,mr:g,mt:c,mb:I})):a>0||g>0||c>0||I>0?(Bz({ctx:A,pad:e,realToCanvasMat:i,ml:a,mr:g,mt:c,mb:I}),ay(A)):(Bz({ctx:A,pad:e,realToCanvasMat:i,ml:0,mr:0,mt:0,mb:0}),ay(A))}function Bz(t){const{ctx:A,pad:e,realToCanvasMat:i,ml:n,mr:o,mt:s,mb:r}=t,a=e.shape==="rotated_rect"||e.shape==="rotated_pill"?e.ccw_rotation??0:0;if(e.shape==="rect"||e.shape==="rotated_rect"){const g=e.corner_radius??e.rect_border_radius??0,c=a*Math.PI/180,I=(o-n)/2,l=(s-r)/2,B=I*Math.cos(c)-l*Math.sin(c),C=I*Math.sin(c)+l*Math.cos(c),[Q,h]=ai(i,[e.x+B,e.y+C]),E=(e.width+n+o)*Math.abs(i.a),u=(e.height+s+r)*Math.abs(i.a),d=g*Math.abs(i.a);A.save(),A.translate(Q,h),a!==0&&A.rotate(-a*Math.PI/180),A.beginPath(),ry({ctx:A,cx:0,cy:0,width:E,height:u,radius:d}),A.restore()}else if(e.shape==="circle"){const g=(n+o+s+r)/4,[c,I]=ai(i,[e.x,e.y]),l=(e.radius+g)*Math.abs(i.a);A.beginPath(),A.arc(c,I,l,0,Math.PI*2),A.closePath()}else if(e.shape==="pill"||e.shape==="rotated_pill"){const g=(n+o)/2,[c,I]=ai(i,[e.x,e.y]),l=(e.width+g*2)*Math.abs(i.a),B=(e.height+g*2)*Math.abs(i.a);A.save(),A.translate(c,I),a!==0&&A.rotate(-a*Math.PI/180),A.beginPath(),ix({ctx:A,cx:0,cy:0,width:l,height:B}),A.restore()}else if(e.shape==="polygon"&&e.points&&e.points.length>=3){const g=(n+o+s+r)/4,I=(g!==0?LT(e.points,g):e.points).map(l=>{const[B,C]=ai(i,[l.x,l.y]);return{x:B,y:C}});A.beginPath(),Yk({ctx:A,points:I})}}function M7t(t){const{ctx:A,pad:e,realToCanvasMat:i,soldermaskOverCopperColor:n,ml:o,mr:s,mt:r,mb:a}=t,g=e.shape==="rotated_rect"||e.shape==="rotated_pill"?e.ccw_rotation??0:0,c=Math.max(0,-o),I=Math.max(0,-s),l=Math.max(0,-r),B=Math.max(0,-a);if(A.fillStyle=n,e.shape==="rect"||e.shape==="rotated_rect"){const C=e.corner_radius??e.rect_border_radius??0,[Q,h]=ai(i,[e.x,e.y]),E=e.width*Math.abs(i.a),u=e.height*Math.abs(i.a),d=C*Math.abs(i.a),f=c*Math.abs(i.a),m=I*Math.abs(i.a),w=l*Math.abs(i.a),D=B*Math.abs(i.a);A.save(),A.translate(Q,h),g!==0&&A.rotate(-g*Math.PI/180),A.beginPath(),ry({ctx:A,cx:0,cy:0,width:E,height:u,radius:d});const S=E-f-m,_=u-w-D,b=(f-m)/2,N=(w-D)/2,F=Math.max(0,d-(f+m+w+D)/4);S>0&&_>0&&ry({ctx:A,cx:b,cy:N,width:S,height:_,radius:F}),A.fill("evenodd"),A.restore()}else if(e.shape==="circle"){const C=Math.max(c,I,l,B),[Q,h]=ai(i,[e.x,e.y]),E=e.radius*Math.abs(i.a),u=C*Math.abs(i.a),d=Math.max(0,E-u);A.save(),A.beginPath(),A.arc(Q,h,E,0,Math.PI*2),d>0&&A.arc(Q,h,d,0,Math.PI*2,!0),A.fill("evenodd"),A.restore()}else if(e.shape==="pill"||e.shape==="rotated_pill"){const C=Math.max(c,I,l,B),[Q,h]=ai(i,[e.x,e.y]),E=e.width*Math.abs(i.a),u=e.height*Math.abs(i.a),d=C*Math.abs(i.a);A.save(),A.translate(Q,h),g!==0&&A.rotate(-g*Math.PI/180),A.beginPath(),ix({ctx:A,cx:0,cy:0,width:E,height:u});const f=E-d*2,m=u-d*2;f>0&&m>0&&ix({ctx:A,cx:0,cy:0,width:f,height:m}),A.fill("evenodd"),A.restore()}else if(e.shape==="polygon"&&e.points&&e.points.length>=3){const C=Math.max(c,I,l,B);A.save(),A.beginPath();const Q=e.points.map(E=>{const[u,d]=ai(i,[E.x,E.y]);return{x:u,y:d}});Yk({ctx:A,points:Q});const h=LT(e.points,-C);if(h.length>=3){const E=h.map(u=>{const[d,f]=ai(i,[u.x,u.y]);return{x:d,y:f}});Yk({ctx:A,points:E})}A.fill("evenodd"),A.restore()}}function u2(t,A){const e=Math.hypot(t,A);return e<=Number.EPSILON?{x:0,y:0}:{x:t/e,y:A/e}}function R7t(t,A){const e=t.length;if(e<2)return{x:1,y:0};if(A<=0){const g=t[1],c=t[0];if(!g||!c)return{x:1,y:0};const I=u2(g.x-c.x,g.y-c.y);return I.x===0&&I.y===0?{x:1,y:0}:I}if(A>=e-1){const g=t[e-2],c=t[e-1];if(!g||!c)return{x:1,y:0};const I=u2(c.x-g.x,c.y-g.y);return I.x===0&&I.y===0?{x:1,y:0}:I}const i=t[A-1],n=t[A],o=t[A+1];if(!i||!n||!o)return{x:1,y:0};const s=u2(n.x-i.x,n.y-i.y),r=u2(o.x-n.x,o.y-n.y),a=u2(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 GQe(t){const A=[],e=[];for(let i=0;i<t.length;i++){const n=t[i];if(!n)continue;const o=R7t(t,i),s=u2(-o.y,o.x),r=n.width/2;A.push({x:n.x+s.x*r,y:n.y+s.y*r}),e.push({x:n.x-s.x*r,y:n.y-s.y*r})}return A.concat(e.reverse())}function emA(t){const A=[];let e=[],i=null;for(const n of t??[]){if(!n||n.route_type!=="wire"){e.length>=2&&A.push(e),e=[],i=null;continue}const o=n.layer??i;if(!o)continue;const s=n.x,r=n.y;if(typeof s!="number"||typeof r!="number"||typeof n.width!="number")continue;const a=n.width;i&&o!==i&&(e.length>=2&&A.push(e),e=[]),i=o,e.push({route_type:"wire",x:s,y:r,width:a,layer:o,start_pcb_port_id:"start_pcb_port_id"in n?n.start_pcb_port_id:void 0,end_pcb_port_id:"end_pcb_port_id"in n?n.end_pcb_port_id:void 0})}return e.length>=2&&A.push(e),A}var LQe=1e-6;function UQe(t){const{ctx:A,trace:e,realToCanvasMat:i,vias:n,platedHoles:o,layer:s}=t;if(!e.route||e.route.length<2)return;const r=emA(e.route);if(r.length===0)return;const a=new Map;for(const g of r){const c=g[0]?.layer,I=g[g.length-1];if(!(!c||!I)&&!(s&&c!==s)){for(const l of n){if(l.layers&&Array.isArray(l.layers)&&!l.layers.includes(c)||!HQe(I.x,I.y,l.x,l.y))continue;const B=l.hole_diameter/2;if(B<=0)continue;const C={shape:"circle",x:l.x,y:l.y,radius:B};a.set(YQe(C),C)}for(const l of o){if(l.layers&&Array.isArray(l.layers)&&!l.layers.includes(c))continue;const B=N7t(l);B&&HQe(I.x,I.y,B.x,B.y)&&a.set(YQe(B),B)}}}if(a.size!==0){A.save(),A.globalCompositeOperation="destination-out";for(const g of a.values()){if(g.shape==="circle"){tQ({ctx:A,center:{x:g.x,y:g.y},radius:g.radius,fill:"#000",realToCanvasMat:i});continue}if(g.shape==="oval"){ES({ctx:A,center:{x:g.x,y:g.y},radius_x:g.radiusX,radius_y:g.radiusY,fill:"#000",realToCanvasMat:i,rotation:g.rotation});continue}eh({ctx:A,center:{x:g.x,y:g.y},width:g.width,height:g.height,fill:"#000",realToCanvasMat:i,rotation:g.rotation})}A.restore()}}function N7t(t){if(t.shape==="circle"){const n=t.hole_diameter/2;return n<=0?void 0:{shape:"circle",x:t.x,y:t.y,radius:n}}if(t.shape==="oval"){const n=t.hole_width/2,o=t.hole_height/2;return n<=0||o<=0?void 0:{shape:"oval",x:t.x,y:t.y,radiusX:n,radiusY:o,rotation:t.ccw_rotation}}if(t.shape==="pill")return t.hole_width<=0||t.hole_height<=0?void 0:{shape:"pill",x:t.x,y:t.y,width:t.hole_width,height:t.hole_height,rotation:t.ccw_rotation};if(t.shape==="circular_hole_with_rect_pad"){const n=t.hole_diameter/2;return n<=0?void 0:{shape:"circle",x:t.x+(t.hole_offset_x??0),y:t.y+(t.hole_offset_y??0),radius:n}}if(t.shape==="pill_hole_with_rect_pad")return t.hole_width<=0||t.hole_height<=0?void 0:{shape:"pill",x:t.x+(t.hole_offset_x??0),y:t.y+(t.hole_offset_y??0),width:t.hole_width,height:t.hole_height};if(t.shape==="rotated_pill_hole_with_rect_pad")return t.hole_width<=0||t.hole_height<=0?void 0:{shape:"pill",x:t.x+(t.hole_offset_x??0),y:t.y+(t.hole_offset_y??0),width:t.hole_width,height:t.hole_height,rotation:t.hole_ccw_rotation};if(t.shape!=="hole_with_polygon_pad")return;const A=t.x+(t.hole_offset_x??0),e=t.y+(t.hole_offset_y??0),i=t.hole_shape;if(i==="circle"){const n=(t.hole_diameter??0)/2;return n<=0?void 0:{shape:"circle",x:A,y:e,radius:n}}if(i==="oval"){const n=(t.hole_width??0)/2,o=(t.hole_height??0)/2;return n<=0||o<=0?void 0:{shape:"oval",x:A,y:e,radiusX:n,radiusY:o}}if(i==="pill"||i==="rotated_pill"){const n=t.hole_width??0,o=t.hole_height??0;return n<=0||o<=0?void 0:{shape:"pill",x:A,y:e,width:n,height:o,rotation:i==="rotated_pill"?t.ccw_rotation:0}}}function HQe(t,A,e,i){return Math.abs(t-e)<=LQe&&Math.abs(A-i)<=LQe}function YQe(t){return t.shape==="circle"?`circle:${t.x}:${t.y}:${t.radius}`:t.shape==="oval"?`oval:${t.x}:${t.y}:${t.radiusX}:${t.radiusY}:${t.rotation??0}`:`pill:${t.x}:${t.y}:${t.width}:${t.height}:${t.rotation??0}`}function JQe(t){if(t.length<2)return!1;const A=t[0]?.width;return typeof A!="number"?!1:t.some(e=>Math.abs(e.width-A)>Number.EPSILON)}function G7t(t){const{ctx:A,trace:e,realToCanvasMat:i,soldermaskOverCopperColor:n,layer:o}=t;if(!e.route||!Array.isArray(e.route)||e.route.length<2)return;const s=emA(e.route);for(const r of s)if(r[0]?.layer===o){if(JQe(r)){const g=GQe(r);Hk({ctx:A,points:g,fill:n,realToCanvasMat:i});continue}for(let g=0;g<r.length-1;g++){const c=r[g],I=r[g+1];!c||!I||E2({ctx:A,start:{x:c.x,y:c.y},end:{x:I.x,y:I.y},strokeWidth:c.width,stroke:n,realToCanvasMat:i,lineCap:"round"})}}UQe({ctx:A,trace:e,realToCanvasMat:i,layer:o,vias:t.vias,platedHoles:t.platedHoles})}function L7t(t){const{ctx:A,via:e,realToCanvasMat:i}=t,[n,o]=ai(i,[e.x,e.y]),s=e.outer_diameter/2*Math.abs(i.a);A.beginPath(),A.arc(n,o,s,0,Math.PI*2),A.closePath(),ay(A)}function TQe(t){const{ctx:A,elements:e,realToCanvasMat:i,colorMap:n,layer:o,drawSoldermask:s}=t;if(!s||A.canvas.width<=0||A.canvas.height<=0)return;const r=e.filter(C=>C.type==="pcb_board"),a=e.find(C=>C.type==="pcb_panel");if(r.length===0&&!a)return;const g=n.soldermask[o]??n.soldermask.top,c=n.soldermaskOverCopper[o]??n.soldermaskOverCopper.top,I=e.filter(C=>C.type==="pcb_via"),l=e.filter(C=>C.type==="pcb_plated_hole"),B=p7t(A,A.canvas.width,A.canvas.height)??A;if(a&&f7t({ctx:B,panel:a,realToCanvasMat:i,soldermaskColor:g}),a&&r.length>0){B.save(),B.globalCompositeOperation="destination-out";for(const C of r)MQe({ctx:B,board:C,realToCanvasMat:i,soldermaskColor:"#000"});B.restore()}for(const C of r)MQe({ctx:B,board:C,realToCanvasMat:i,soldermaskColor:g});for(const C of e)C.type==="pcb_trace"?G7t({ctx:B,trace:C,realToCanvasMat:i,soldermaskOverCopperColor:c,layer:o,vias:I,platedHoles:l}):C.type==="pcb_copper_pour"&&b7t({ctx:B,pour:C,realToCanvasMat:i,soldermaskOverCopperColor:c,layer:o,elements:e});for(const C of e)U7t({ctx:B,element:C,realToCanvasMat:i,soldermaskOverCopperColor:c,layer:o});u7t(A,B)}function U7t(t){const{ctx:A,element:e,realToCanvasMat:i,soldermaskOverCopperColor:n,layer:o}=t;if(e.type==="pcb_smtpad")F7t({ctx:A,pad:e,realToCanvasMat:i,soldermaskOverCopperColor:n,layer:o});else if(e.type==="pcb_plated_hole")k7t({ctx:A,hole:e,realToCanvasMat:i,soldermaskOverCopperColor:n,layer:o});else if(e.type==="pcb_hole")x7t({ctx:A,hole:e,realToCanvasMat:i,soldermaskOverCopperColor:n});else if(e.type==="pcb_via")L7t({ctx:A,via:e,realToCanvasMat:i});else if(e.type==="pcb_cutout")y7t({ctx:A,cutout:e,realToCanvasMat:i});else{if(e.type==="pcb_copper_pour")return;if(e.type==="pcb_trace")return}}function H7t(t,A){return A.copper[t]??A.copper.top}function PQe(t){const{ctx:A,trace:e,realToCanvasMat:i,colorMap:n}=t;if(!e.route||!Array.isArray(e.route)||e.route.length<2)return;const o=emA(e.route);for(const s of o){const r=s[0]?.layer;if(!r)continue;const a=H7t(r,n);if(JQe(s)){const g=GQe(s);Hk({ctx:A,points:g,fill:a,realToCanvasMat:i});continue}for(let g=0;g<s.length-1;g++){const c=s[g],I=s[g+1];!c||!I||E2({ctx:A,start:{x:c.x,y:c.y},end:{x:I.x,y:I.y},strokeWidth:c.width,stroke:a,realToCanvasMat:i,lineCap:"round"})}}UQe({ctx:A,trace:e,realToCanvasMat:i,vias:t.vias??[],platedHoles:t.platedHoles??[]})}function KQe(t){const{ctx:A,via:e,realToCanvasMat:i,colorMap:n,layer:o}=t;tQ({ctx:A,center:{x:e.x,y:e.y},radius:e.outer_diameter/2,fill:n.copper[o??"top"],realToCanvasMat:i}),A.save(),A.globalCompositeOperation="destination-out",tQ({ctx:A,center:{x:e.x,y:e.y},radius:e.hole_diameter/2,fill:"#000",realToCanvasMat:i}),A.restore(),tQ({ctx:A,center:{x:e.x,y:e.y},radius:e.hole_diameter/2,fill:n.drill,realToCanvasMat:i})}function vm(t,A){if(!A.layers||A.layers.length===0)return!0;const e=DnA(t);return e.length===0?!0:e.some(i=>A.layers.includes(i))}var ap={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)"},copperPour:{top:"rgb(230, 95, 95)",bottom:"rgb(122, 162, 222)"},soldermaskWithCopperUnderneath:{top:"rgb(18, 82, 50)",bottom:"rgb(77, 127, 196)"},soldermask:{top:"rgb(12, 55, 33)",bottom:"rgb(12, 55, 33)"},soldermaskOverCopper:{top:"rgb(52, 135, 73)",bottom:"rgb(52, 135, 73)"},substrate:"rgb(201, 162, 110)",drill:"#FF26E2",silkscreen:{top:"#f2eda1",bottom:"#5da9e9"},boardOutline:"rgba(255, 255, 255, 0.5)",courtyard:{top:"#FF00FF",bottom:"rgb(38, 233, 255)"},keepout:"#FF6B6B",fabricationNote:"rgba(255, 255, 255, 0.5)"};function Y7t(t){return!t||t.length===0?"top":t.some(e=>e.startsWith("bottom"))?"bottom":"top"}var iQ=class{ctx;colorMap;realToCanvasMat;constructor(t){if("getContext"in t&&typeof t.getContext=="function"){const A=t.getContext("2d");if(!A)throw new Error("Failed to get 2D rendering context from canvas");this.ctx=A}else this.ctx=t;this.colorMap={...ap},this.realToCanvasMat=B6t()}configure(t){t.colorOverrides&&(this.colorMap={...this.colorMap,...t.colorOverrides,copper:{...this.colorMap.copper,...t.colorOverrides.copper},copperPour:{...this.colorMap.copperPour,...t.colorOverrides.copperPour},silkscreen:{...this.colorMap.silkscreen,...t.colorOverrides.silkscreen},soldermask:{...this.colorMap.soldermask,...t.colorOverrides.soldermask},soldermaskWithCopperUnderneath:{...this.colorMap.soldermaskWithCopperUnderneath,...t.colorOverrides.soldermaskWithCopperUnderneath},soldermaskOverCopper:{...this.colorMap.soldermaskOverCopper,...t.colorOverrides.soldermaskOverCopper}})}setCameraBounds(t){const A=this.ctx.canvas,e=A.width,i=A.height,n=t.maxX-t.minX,o=t.maxY-t.minY,s=e/n,r=i/o,a=Math.min(s,r),g=(e-n*a)/2,c=(i-o*a)/2;this.realToCanvasMat=VyA(Uk(g,c),h6t(a,-a),Uk(-t.minX,-t.maxY))}drawElements(t,A={}){const e=Y7t(A.layers),i=t.find(l=>l.type==="pcb_board"),n=t.find(l=>l.type==="pcb_panel");n&&$6t({ctx:this.ctx,panel:n,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap});const o=A.drawBoardMaterial??!1,s=A.drawSoldermask??!1,r=A.drawSoldermaskTop!==void 0||A.drawSoldermaskBottom!==void 0,a=s&&(i!==void 0||n!==void 0)&&(A.drawSoldermaskTop??!r),g=s&&(i!==void 0||n!==void 0)&&(A.drawSoldermaskBottom??!1),c=t.filter(l=>vm(l,A)&&l.type==="pcb_via"),I=t.filter(l=>vm(l,A)&&l.type==="pcb_plated_hole");i&&E6t({ctx:this.ctx,board:i,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap,drawBoardMaterial:o,minBoardOutlineStrokePx:A.minBoardOutlineStrokePx});for(const l of t)vm(l,A)&&l.type==="pcb_copper_pour"&&f6t({ctx:this.ctx,pour:l,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap});for(const l of t)vm(l,A)&&(l.type==="pcb_smtpad"&&h7t({ctx:this.ctx,pad:l,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}),l.type==="pcb_copper_text"&&x6t({ctx:this.ctx,text:l,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}));if(a){for(const l of t)vm(l,A)&&l.type==="pcb_trace"&&PQe({ctx:this.ctx,trace:l,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap,vias:c,platedHoles:I});for(const l of t)vm(l,A)&&(l.type==="pcb_hole"&&kQe({ctx:this.ctx,hole:l,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap,soldermaskMargin:l.soldermask_margin,drawSoldermask:a}),l.type==="pcb_plated_hole"&&vQe({ctx:this.ctx,hole:l,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap,soldermaskMargin:l.soldermask_margin,drawSoldermask:a,layer:e}),l.type==="pcb_via"&&KQe({ctx:this.ctx,via:l,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap,layer:e}))}a&&TQe({ctx:this.ctx,elements:t,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap,layer:"top",drawSoldermask:!0});for(const l of t)vm(l,A)&&(l.type==="pcb_silkscreen_text"&&C7t({ctx:this.ctx,text:l,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}),l.type==="pcb_silkscreen_rect"&&I7t({ctx:this.ctx,rect:l,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}),l.type==="pcb_silkscreen_circle"&&e7t({ctx:this.ctx,circle:l,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}),l.type==="pcb_silkscreen_line"&&i7t({ctx:this.ctx,line:l,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}),l.type==="pcb_silkscreen_path"&&r7t({ctx:this.ctx,path:l,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}),l.type==="pcb_silkscreen_pill"&&g7t({ctx:this.ctx,pill:l,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}),l.type==="pcb_silkscreen_oval"&&o7t({ctx:this.ctx,oval:l,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}));for(const l of t)vm(l,A)&&l.type==="pcb_trace"&&!a&&PQe({ctx:this.ctx,trace:l,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap,vias:c,platedHoles:I});for(const l of t)vm(l,A)&&l.type==="pcb_hole"&&!a&&kQe({ctx:this.ctx,hole:l,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap,soldermaskMargin:a?l.soldermask_margin:void 0,drawSoldermask:a});for(const l of t)vm(l,A)&&(l.type==="pcb_plated_hole"&&!a&&vQe({ctx:this.ctx,hole:l,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap,soldermaskMargin:a?l.soldermask_margin:void 0,drawSoldermask:a,layer:e}),l.type==="pcb_via"&&!a&&KQe({ctx:this.ctx,via:l,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap,layer:e}));g&&TQe({ctx:this.ctx,elements:t,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap,layer:"bottom",drawSoldermask:!0});for(const l of t)vm(l,A)&&l.type==="pcb_cutout"&&N6t({ctx:this.ctx,cutout:l,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap});for(const l of t){if(!vm(l,A))continue;l.type==="pcb_keepout"&&q6t({ctx:this.ctx,keepout:l,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}),l.type==="pcb_fabrication_note_text"&&P6t({ctx:this.ctx,text:l,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}),l.type==="pcb_fabrication_note_rect"&&J6t({ctx:this.ctx,rect:l,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap});const B=A.showPcbNotes??!0;B&&l.type==="pcb_note_rect"&&j6t({realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap,ctx:this.ctx,rect:l}),l.type==="pcb_fabrication_note_path"&&Y6t({ctx:this.ctx,path:l,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}),B&&l.type==="pcb_note_path"&&V6t({ctx:this.ctx,path:l,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}),B&&l.type==="pcb_note_text"&&X6t({ctx:this.ctx,text:l,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}),B&&l.type==="pcb_note_line"&&Z6t({ctx:this.ctx,line:l,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}),B&&l.type==="pcb_note_dimension"&&W6t({ctx:this.ctx,pcbNoteDimension:l,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}),l.type==="pcb_fabrication_note_dimension"&&H6t({ctx:this.ctx,pcbFabricationNoteDimension:l,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}),l.type==="pcb_courtyard_circle"&&k6t({ctx:this.ctx,circle:l,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}),l.type==="pcb_courtyard_rect"&&R6t({ctx:this.ctx,rect:l,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}),l.type==="pcb_courtyard_outline"&&F6t({ctx:this.ctx,outline:l,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap})}}};const J7t=Vke(H1e);var tmA,qQe;function T7t(){if(qQe)return tmA;qQe=1;var t=Object.defineProperty,A=Object.getOwnPropertyDescriptor,e=Object.getOwnPropertyNames,i=Object.prototype.hasOwnProperty,n=(h,E)=>{for(var u in E)t(h,u,{get:E[u],enumerable:!0})},o=(h,E,u,d)=>{if(E&&typeof E=="object"||typeof E=="function")for(let f of e(E))!i.call(h,f)&&f!==u&&t(h,f,{get:()=>E[f],enumerable:!(d=A(E,f))||d.enumerable});return h},s=h=>o(t({},"__esModule",{value:!0}),h),r={};n(r,{SuperGrid:()=>Q,toMMSI:()=>C,toMeterSI:()=>B}),tmA=s(r);var a=N0(),g=J7t,c=pkA(),I=(h,E,u)=>{const d=[];if(E<h)for(let f=h;f>=E;f-=Math.abs(u))d.push(f);else for(let f=h;f<=E;f+=Math.abs(u))d.push(f);return d};function l(h,E){return{x:Math.round(E.x/h)*h,y:Math.round(E.y/h)*h}}function B(h,E=1){return h<0?"-"+B(-h):h<1e-6?"0m":h>1e3?Math.floor(h/1e3)+"km":h>1&&E>1?Math.round(h)+"m":h>1&&E<=1?h.toFixed(Math.ceil(-Math.log10(E)))+"m":h<1&&E>=1/1e3?Math.round(h*1e3)+"mm":h<1&&E<1/1e3?(h*1e3).toFixed(Math.ceil(-Math.log10(E*1e3)))+"mm":""}function C(h,E=1){return B(h/1e3,E/1e3)}var Q=h=>{var E;const u=(0,a.useRef)(null),[d,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=(E=h.majorColor)!=null?E:"rgba(0,0,0,0.5)",width:S,height:_,screenSpaceCellSize:b=200,stringifyCoord:N=(J,q,Z)=>`${B(J,Z)}, ${B(q,Z)}`}=h,F=Math.ceil(S/b)+2,L=Math.ceil(_/b)+2;(0,a.useEffect)(()=>{if(!u.current)return;const J=u.current.getContext("2d");if(!J)return;const q=b/10**Math.floor(Math.log10(h.transform.a)),Z=h.transform.d<0?-1:1,eA=b/10**Math.log10(h.transform.a)/q;function gA(xA,dA,qA){const VA=xA;let ce,fA,ge;for(ce=dA.x;ce<=qA.x;ce+=VA)fA=(0,g.applyToPoint)(h.transform,{x:ce,y:dA.y}),ge=(0,g.applyToPoint)(h.transform,{x:ce,y:qA.y}),J.beginPath(),J.moveTo(fA.x,fA.y),J.lineTo(ge.x,ge.y),J.stroke();const TA=I(dA.y,qA.y,VA*Z);for(const YA of TA)fA=(0,g.applyToPoint)(h.transform,{x:dA.x,y:YA}),ge=(0,g.applyToPoint)(h.transform,{x:qA.x,y:YA}),J.beginPath(),J.moveTo(fA.x,fA.y),J.lineTo(ge.x,ge.y),J.stroke()}function iA(xA,dA,qA){const VA=xA;let ce;for(ce=dA.x;ce<=qA.x;ce+=VA)for(const fA of I(dA.y,qA.y,VA*Z)){const ge=(0,g.applyToPoint)(h.transform,{x:ce,y:fA});J.fillStyle=D,J.font="12px sans-serif",J.fillText(N(ce,fA,xA),ge.x+2,ge.y-2)}}J.clearRect(0,0,S,_);const tA=(0,g.applyToPoint)((0,g.inverse)(h.transform),{x:0,y:0}),sA={x:Math.floor((tA.x-q)/q)*q,y:Math.floor((tA.y-q)/q+(Z==-1?2:0))*q},aA={x:sA.x+q*F,y:sA.y+q*L*Z},bA=q*5,_A={x:Math.floor((tA.x-bA)/bA)*bA,y:Math.floor((tA.y-bA)/bA+(Z==-1?2:0))*bA},HA={x:_A.x+bA*F,y:_A.y+bA*L*Z};J.globalAlpha=1,J.strokeStyle=m,gA(q,sA,aA),iA(bA,_A,HA),J.globalAlpha=1-eA,gA(bA/10,_A,HA),J.globalAlpha=1-eA,J.strokeStyle=w,gA(q/10,sA,aA),J.globalAlpha=Math.max(((1-eA)*10-5)/5,0),iA(bA/10,_A,HA),J.globalAlpha=1;const QA=(0,g.applyToPoint)(h.transform,d);J.font="12px sans-serif",J.fillStyle=D,J.fillText(N(d.x,d.y,q),QA.x+2,QA.y-2),J.strokeStyle=m,J.strokeRect(QA.x-5,QA.y-5,10,10)},[u,h.transform,d,S,_]);const Y=J=>{if(!u.current)return;const q=b/10/10**Math.floor(Math.log10(h.transform.a)),Z=u.current.getBoundingClientRect(),X=(0,g.applyToPoint)((0,g.inverse)(h.transform),{x:J.clientX-Z.left,y:J.clientY-Z.top}),eA=l(q,X);f(eA)};return(0,c.jsx)("canvas",{onMouseUp:J=>{J.button===1&&Y(J)},onDoubleClick:Y,ref:u,width:h.width,height:h.height})};return tmA}var Cz=T7t();function P7t(t){if(t.sheet)return t.sheet;for(var A=0;A<document.styleSheets.length;A++)if(document.styleSheets[A].ownerNode===t)return document.styleSheets[A]}function K7t(t){var A=document.createElement("style");return A.setAttribute("data-emotion",t.key),t.nonce!==void 0&&A.setAttribute("nonce",t.nonce),A.appendChild(document.createTextNode("")),A.setAttribute("data-s",""),A}var q7t=(function(){function t(e){var i=this;this._insertTag=function(n){var o;i.tags.length===0?i.insertionPoint?o=i.insertionPoint.nextSibling:i.prepend?o=i.container.firstChild:o=i.before:o=i.tags[i.tags.length-1].nextSibling,i.container.insertBefore(n,o),i.tags.push(n)},this.isSpeedy=e.speedy===void 0?!0:e.speedy,this.tags=[],this.ctr=0,this.nonce=e.nonce,this.key=e.key,this.container=e.container,this.prepend=e.prepend,this.insertionPoint=e.insertionPoint,this.before=null}var A=t.prototype;return A.hydrate=function(i){i.forEach(this._insertTag)},A.insert=function(i){this.ctr%(this.isSpeedy?65e3:1)===0&&this._insertTag(K7t(this));var n=this.tags[this.tags.length-1];if(this.isSpeedy){var o=P7t(n);try{o.insertRule(i,o.cssRules.length)}catch{}}else n.appendChild(document.createTextNode(i));this.ctr++},A.flush=function(){this.tags.forEach(function(i){var n;return(n=i.parentNode)==null?void 0:n.removeChild(i)}),this.tags=[],this.ctr=0},t})(),Bd="-ms-",Qz="-moz-",ng="-webkit-",OQe="comm",imA="rule",nmA="decl",O7t="@import",WQe="@keyframes",W7t="@layer",Z7t=Math.abs,hz=String.fromCharCode,V7t=Object.assign;function j7t(t,A){return Au(t,0)^45?(((A<<2^Au(t,0))<<2^Au(t,1))<<2^Au(t,2))<<2^Au(t,3):0}function ZQe(t){return t.trim()}function z7t(t,A){return(t=A.exec(t))?t[0]:t}function og(t,A,e){return t.replace(A,e)}function omA(t,A){return t.indexOf(A)}function Au(t,A){return t.charCodeAt(A)|0}function UT(t,A,e){return t.slice(A,e)}function dS(t){return t.length}function smA(t){return t.length}function Ez(t,A){return A.push(t),t}function X7t(t,A){return t.map(A).join("")}var uz=1,d2=1,VQe=0,Jf=0,nQ=0,p2="";function dz(t,A,e,i,n,o,s){return{value:t,root:A,parent:e,type:i,props:n,children:o,line:uz,column:d2,length:s,return:""}}function HT(t,A){return V7t(dz("",null,null,"",null,null,0),t,{length:-t.length},A)}function $7t(){return nQ}function A$t(){return nQ=Jf>0?Au(p2,--Jf):0,d2--,nQ===10&&(d2=1,uz--),nQ}function gy(){return nQ=Jf<VQe?Au(p2,Jf++):0,d2++,nQ===10&&(d2=1,uz++),nQ}function pS(){return Au(p2,Jf)}function pz(){return Jf}function YT(t,A){return UT(p2,t,A)}function JT(t){switch(t){case 0:case 9:case 10:case 13:case 32:return 5;case 33:case 43:case 44:case 47:case 62:case 64:case 126:case 59:case 123:case 125:return 4;case 58:return 3;case 34:case 39:case 40:case 91:return 2;case 41:case 93:return 1}return 0}function jQe(t){return uz=d2=1,VQe=dS(p2=t),Jf=0,[]}function zQe(t){return p2="",t}function fz(t){return ZQe(YT(Jf-1,rmA(t===91?t+2:t===40?t+1:t)))}function e$t(t){for(;(nQ=pS())&&nQ<33;)gy();return JT(t)>2||JT(nQ)>3?"":" "}function t$t(t,A){for(;--A&&gy()&&!(nQ<48||nQ>102||nQ>57&&nQ<65||nQ>70&&nQ<97););return YT(t,pz()+(A<6&&pS()==32&&gy()==32))}function rmA(t){for(;gy();)switch(nQ){case t:return Jf;case 34:case 39:t!==34&&t!==39&&rmA(nQ);break;case 40:t===41&&rmA(t);break;case 92:gy();break}return Jf}function i$t(t,A){for(;gy()&&t+nQ!==57;)if(t+nQ===84&&pS()===47)break;return"/*"+YT(A,Jf-1)+"*"+hz(t===47?t:gy())}function n$t(t){for(;!JT(pS());)gy();return YT(t,Jf)}function o$t(t){return zQe(yz("",null,null,null,[""],t=jQe(t),0,[0],t))}function yz(t,A,e,i,n,o,s,r,a){for(var g=0,c=0,I=s,l=0,B=0,C=0,Q=1,h=1,E=1,u=0,d="",f=n,m=o,w=i,D=d;h;)switch(C=u,u=gy()){case 40:if(C!=108&&Au(D,I-1)==58){omA(D+=og(fz(u),"&","&\f"),"&\f")!=-1&&(E=-1);break}case 34:case 39:case 91:D+=fz(u);break;case 9:case 10:case 13:case 32:D+=e$t(C);break;case 92:D+=t$t(pz()-1,7);continue;case 47:switch(pS()){case 42:case 47:Ez(s$t(i$t(gy(),pz()),A,e),a);break;default:D+="/"}break;case 123*Q:r[g++]=dS(D)*E;case 125*Q:case 59:case 0:switch(u){case 0:case 125:h=0;case 59+c:E==-1&&(D=og(D,/\f/g,"")),B>0&&dS(D)-I&&Ez(B>32?$Qe(D+";",i,e,I-1):$Qe(og(D," ","")+";",i,e,I-2),a);break;case 59:D+=";";default:if(Ez(w=XQe(D,A,e,g,c,n,r,d,f=[],m=[],I),o),u===123)if(c===0)yz(D,A,w,w,f,o,I,r,m);else switch(l===99&&Au(D,3)===110?100:l){case 100:case 108:case 109:case 115:yz(t,w,w,i&&Ez(XQe(t,w,w,0,0,n,r,d,n,f=[],I),m),n,m,I,r,i?f:m);break;default:yz(D,w,w,w,[""],m,0,r,m)}}g=c=B=0,Q=E=1,d=D="",I=s;break;case 58:I=1+dS(D),B=C;default:if(Q<1){if(u==123)--Q;else if(u==125&&Q++==0&&A$t()==125)continue}switch(D+=hz(u),u*Q){case 38:E=c>0?1:(D+="\f",-1);break;case 44:r[g++]=(dS(D)-1)*E,E=1;break;case 64:pS()===45&&(D+=fz(gy())),l=pS(),c=I=dS(d=D+=n$t(pz())),u++;break;case 45:C===45&&dS(D)==2&&(Q=0)}}return o}function XQe(t,A,e,i,n,o,s,r,a,g,c){for(var I=n-1,l=n===0?o:[""],B=smA(l),C=0,Q=0,h=0;C<i;++C)for(var E=0,u=UT(t,I+1,I=Z7t(Q=s[C])),d=t;E<B;++E)(d=ZQe(Q>0?l[E]+" "+u:og(u,/&\f/g,l[E])))&&(a[h++]=d);return dz(t,A,e,n===0?imA:r,a,g,c)}function s$t(t,A,e){return dz(t,A,e,OQe,hz($7t()),UT(t,2,-2),0)}function $Qe(t,A,e,i){return dz(t,A,e,nmA,UT(t,0,i),UT(t,i+1,-1),i)}function f2(t,A){for(var e="",i=smA(t),n=0;n<i;n++)e+=A(t[n],n,t,A)||"";return e}function r$t(t,A,e,i){switch(t.type){case W7t:if(t.children.length)break;case O7t:case nmA:return t.return=t.return||t.value;case OQe:return"";case WQe:return t.return=t.value+"{"+f2(t.children,i)+"}";case imA:t.value=t.props.join(",")}return dS(e=f2(t.children,i))?t.return=t.value+"{"+e+"}":""}function a$t(t){var A=smA(t);return function(e,i,n,o){for(var s="",r=0;r<A;r++)s+=t[r](e,i,n,o)||"";return s}}function g$t(t){return function(A){A.root||(A=A.return)&&t(A)}}function c$t(t){var A=Object.create(null);return function(e){return A[e]===void 0&&(A[e]=t(e)),A[e]}}var I$t=function(A,e,i){for(var n=0,o=0;n=o,o=pS(),n===38&&o===12&&(e[i]=1),!JT(o);)gy();return YT(A,Jf)},l$t=function(A,e){var i=-1,n=44;do switch(JT(n)){case 0:n===38&&pS()===12&&(e[i]=1),A[i]+=I$t(Jf-1,e,i);break;case 2:A[i]+=fz(n);break;case 4:if(n===44){A[++i]=pS()===58?"&\f":"",e[i]=A[i].length;break}default:A[i]+=hz(n)}while(n=gy());return A},B$t=function(A,e){return zQe(l$t(jQe(A),e))},Ahe=new WeakMap,C$t=function(A){if(!(A.type!=="rule"||!A.parent||A.length<1)){for(var e=A.value,i=A.parent,n=A.column===i.column&&A.line===i.line;i.type!=="rule";)if(i=i.parent,!i)return;if(!(A.props.length===1&&e.charCodeAt(0)!==58&&!Ahe.get(i))&&!n){Ahe.set(A,!0);for(var o=[],s=B$t(e,o),r=i.props,a=0,g=0;a<s.length;a++)for(var c=0;c<r.length;c++,g++)A.props[g]=o[a]?s[a].replace(/&\f/g,r[c]):r[c]+" "+s[a]}}},Q$t=function(A){if(A.type==="decl"){var e=A.value;e.charCodeAt(0)===108&&e.charCodeAt(2)===98&&(A.return="",A.value="")}};function ehe(t,A){switch(j7t(t,A)){case 5103:return ng+"print-"+t+t;case 5737:case 4201:case 3177:case 3433:case 1641:case 4457:case 2921:case 5572:case 6356:case 5844:case 3191:case 6645:case 3005:case 6391:case 5879:case 5623:case 6135:case 4599:case 4855:case 4215:case 6389:case 5109:case 5365:case 5621:case 3829:return ng+t+t;case 5349:case 4246:case 4810:case 6968:case 2756:return ng+t+Qz+t+Bd+t+t;case 6828:case 4268:return ng+t+Bd+t+t;case 6165:return ng+t+Bd+"flex-"+t+t;case 5187:return ng+t+og(t,/(\w+).+(:[^]+)/,ng+"box-$1$2"+Bd+"flex-$1$2")+t;case 5443:return ng+t+Bd+"flex-item-"+og(t,/flex-|-self/,"")+t;case 4675:return ng+t+Bd+"flex-line-pack"+og(t,/align-content|flex-|-self/,"")+t;case 5548:return ng+t+Bd+og(t,"shrink","negative")+t;case 5292:return ng+t+Bd+og(t,"basis","preferred-size")+t;case 6060:return ng+"box-"+og(t,"-grow","")+ng+t+Bd+og(t,"grow","positive")+t;case 4554:return ng+og(t,/([^-])(transform)/g,"$1"+ng+"$2")+t;case 6187:return og(og(og(t,/(zoom-|grab)/,ng+"$1"),/(image-set)/,ng+"$1"),t,"")+t;case 5495:case 3959:return og(t,/(image-set\([^]*)/,ng+"$1$`$1");case 4968:return og(og(t,/(.+:)(flex-)?(.*)/,ng+"box-pack:$3"+Bd+"flex-pack:$3"),/s.+-b[^;]+/,"justify")+ng+t+t;case 4095:case 3583:case 4068:case 2532:return og(t,/(.+)-inline(.+)/,ng+"$1$2")+t;case 8116:case 7059:case 5753:case 5535:case 5445:case 5701:case 4933:case 4677:case 5533:case 5789:case 5021:case 4765:if(dS(t)-1-A>6)switch(Au(t,A+1)){case 109:if(Au(t,A+4)!==45)break;case 102:return og(t,/(.+:)(.+)-([^]+)/,"$1"+ng+"$2-$3$1"+Qz+(Au(t,A+3)==108?"$3":"$2-$3"))+t;case 115:return~omA(t,"stretch")?ehe(og(t,"stretch","fill-available"),A)+t:t}break;case 4949:if(Au(t,A+1)!==115)break;case 6444:switch(Au(t,dS(t)-3-(~omA(t,"!important")&&10))){case 107:return og(t,":",":"+ng)+t;case 101:return og(t,/(.+:)([^;!]+)(;|!.+)?/,"$1"+ng+(Au(t,14)===45?"inline-":"")+"box$3$1"+ng+"$2$3$1"+Bd+"$2box$3")+t}break;case 5936:switch(Au(t,A+11)){case 114:return ng+t+Bd+og(t,/[svh]\w+-[tblr]{2}/,"tb")+t;case 108:return ng+t+Bd+og(t,/[svh]\w+-[tblr]{2}/,"tb-rl")+t;case 45:return ng+t+Bd+og(t,/[svh]\w+-[tblr]{2}/,"lr")+t}return ng+t+Bd+t+t}return t}var h$t=function(A,e,i,n){if(A.length>-1&&!A.return)switch(A.type){case nmA:A.return=ehe(A.value,A.length);break;case WQe:return f2([HT(A,{value:og(A.value,"@","@"+ng)})],n);case imA:if(A.length)return X7t(A.props,function(o){switch(z7t(o,/(::plac\w+|:read-\w+)/)){case":read-only":case":read-write":return f2([HT(A,{props:[og(o,/:(read-\w+)/,":"+Qz+"$1")]})],n);case"::placeholder":return f2([HT(A,{props:[og(o,/:(plac\w+)/,":"+ng+"input-$1")]}),HT(A,{props:[og(o,/:(plac\w+)/,":"+Qz+"$1")]}),HT(A,{props:[og(o,/:(plac\w+)/,Bd+"input-$1")]})],n)}return""})}},E$t=[h$t],u$t=function(A){var e=A.key;if(e==="css"){var i=document.querySelectorAll("style[data-emotion]:not([data-s])");Array.prototype.forEach.call(i,function(Q){var h=Q.getAttribute("data-emotion");h.indexOf(" ")!==-1&&(document.head.appendChild(Q),Q.setAttribute("data-s",""))})}var n=A.stylisPlugins||E$t,o={},s,r=[];s=A.container||document.head,Array.prototype.forEach.call(document.querySelectorAll('style[data-emotion^="'+e+' "]'),function(Q){for(var h=Q.getAttribute("data-emotion").split(" "),E=1;E<h.length;E++)o[h[E]]=!0;r.push(Q)});var a,g=[C$t,Q$t];{var c,I=[r$t,g$t(function(Q){c.insert(Q)})],l=a$t(g.concat(n,I)),B=function(h){return f2(o$t(h),l)};a=function(h,E,u,d){c=u,B(h?h+"{"+E.styles+"}":E.styles),d&&(C.inserted[E.name]=!0)}}var C={key:e,sheet:new q7t({key:e,container:s,nonce:A.nonce,speedy:A.speedy,prepend:A.prepend,insertionPoint:A.insertionPoint}),nonce:A.nonce,inserted:o,registered:{},insert:a};return C.sheet.hydrate(r),C};function d$t(t){for(var A=0,e,i=0,n=t.length;n>=4;++i,n-=4)e=t.charCodeAt(i)&255|(t.charCodeAt(++i)&255)<<8|(t.charCodeAt(++i)&255)<<16|(t.charCodeAt(++i)&255)<<24,e=(e&65535)*1540483477+((e>>>16)*59797<<16),e^=e>>>24,A=(e&65535)*1540483477+((e>>>16)*59797<<16)^(A&65535)*1540483477+((A>>>16)*59797<<16);switch(n){case 3:A^=(t.charCodeAt(i+2)&255)<<16;case 2:A^=(t.charCodeAt(i+1)&255)<<8;case 1:A^=t.charCodeAt(i)&255,A=(A&65535)*1540483477+((A>>>16)*59797<<16)}return A^=A>>>13,A=(A&65535)*1540483477+((A>>>16)*59797<<16),((A^A>>>15)>>>0).toString(36)}var p$t={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},f$t=/[A-Z]|^ms/g,y$t=/_EMO_([^_]+?)_([^]*?)_EMO_/g,the=function(A){return A.charCodeAt(1)===45},ihe=function(A){return A!=null&&typeof A!="boolean"},amA=c$t(function(t){return the(t)?t:t.replace(f$t,"-$&").toLowerCase()}),nhe=function(A,e){switch(A){case"animation":case"animationName":if(typeof e=="string")return e.replace(y$t,function(i,n,o){return Jk={name:n,styles:o,next:Jk},n})}return p$t[A]!==1&&!the(A)&&typeof e=="number"&&e!==0?e+"px":e};function mz(t,A,e){if(e==null)return"";var i=e;if(i.__emotion_styles!==void 0)return i;switch(typeof e){case"boolean":return"";case"object":{var n=e;if(n.anim===1)return Jk={name:n.name,styles:n.styles,next:Jk},n.name;var o=e;if(o.styles!==void 0){var s=o.next;if(s!==void 0)for(;s!==void 0;)Jk={name:s.name,styles:s.styles,next:Jk},s=s.next;var r=o.styles+";";return r}return m$t(t,A,e)}}var a=e;if(A==null)return a;var g=A[a];return g!==void 0?g:a}function m$t(t,A,e){var i="";if(Array.isArray(e))for(var n=0;n<e.length;n++)i+=mz(t,A,e[n])+";";else for(var o in e){var s=e[o];if(typeof s!="object"){var r=s;A!=null&&A[r]!==void 0?i+=o+"{"+A[r]+"}":ihe(r)&&(i+=amA(o)+":"+nhe(o,r)+";")}else if(Array.isArray(s)&&typeof s[0]=="string"&&(A==null||A[s[0]]===void 0))for(var a=0;a<s.length;a++)ihe(s[a])&&(i+=amA(o)+":"+nhe(o,s[a])+";");else{var g=mz(t,A,s);switch(o){case"animation":case"animationName":{i+=amA(o)+":"+g+";";break}default:i+=o+"{"+g+"}"}}}return i}var ohe=/label:\s*([^\s;{]+)\s*(;|$)/g,Jk;function gmA(t,A,e){if(t.length===1&&typeof t[0]=="object"&&t[0]!==null&&t[0].styles!==void 0)return t[0];var i=!0,n="";Jk=void 0;var o=t[0];if(o==null||o.raw===void 0)i=!1,n+=mz(e,A,o);else{var s=o;n+=s[0]}for(var r=1;r<t.length;r++)if(n+=mz(e,A,t[r]),i){var a=o;n+=a[r]}ohe.lastIndex=0;for(var g="",c;(c=ohe.exec(n))!==null;)g+="-"+c[1];var I=d$t(n)+g;return{name:I,styles:n,next:Jk}}function she(t,A,e){var i="";return e.split(" ").forEach(function(n){t[n]!==void 0?A.push(t[n]+";"):n&&(i+=n+" ")}),i}var w$t=function(A,e,i){var n=A.key+"-"+e.name;A.registered[n]===void 0&&(A.registered[n]=e.styles)},D$t=function(A,e,i){w$t(A,e);var n=A.key+"-"+e.name;if(A.inserted[e.name]===void 0){var o=e;do A.insert(e===o?"."+n:"",o,A.sheet,!0),o=o.next;while(o!==void 0)}};function rhe(t,A){if(t.inserted[A.name]===void 0)return t.insert("",A,t.sheet,!0)}function ahe(t,A,e){var i=[],n=she(t,i,e);return i.length<2?e:n+A(i)}var S$t=function(A){var e=u$t(A);e.sheet.speedy=function(r){this.isSpeedy=r},e.compat=!0;var i=function(){for(var a=arguments.length,g=new Array(a),c=0;c<a;c++)g[c]=arguments[c];var I=gmA(g,e.registered,void 0);return D$t(e,I),e.key+"-"+I.name},n=function(){for(var a=arguments.length,g=new Array(a),c=0;c<a;c++)g[c]=arguments[c];var I=gmA(g,e.registered),l="animation-"+I.name;return rhe(e,{name:I.name,styles:"@keyframes "+l+"{"+I.styles+"}"}),l},o=function(){for(var a=arguments.length,g=new Array(a),c=0;c<a;c++)g[c]=arguments[c];var I=gmA(g,e.registered);rhe(e,I)},s=function(){for(var a=arguments.length,g=new Array(a),c=0;c<a;c++)g[c]=arguments[c];return ahe(e.registered,i,b$t(g))};return{css:i,cx:s,injectGlobal:o,keyframes:n,hydrate:function(a){a.forEach(function(g){e.inserted[g]=!0})},flush:function(){e.registered={},e.inserted={},e.sheet.flush()},sheet:e.sheet,cache:e,getRegisteredStyles:she.bind(null,e.registered),merge:ahe.bind(null,e.registered,i)}},b$t=function t(A){for(var e="",i=0;i<A.length;i++){var n=A[i];if(n!=null){var o=void 0;switch(typeof n){case"boolean":break;case"object":{if(Array.isArray(n))o=t(n);else{o="";for(var s in n)n[s]&&s&&(o&&(o+=" "),o+=s)}break}default:o=n}o&&(e&&(e+=" "),e+=o)}}return e},x$t=S$t({key:"css"}),y2=x$t.css,_$t=Object.create,ghe=Object.defineProperty,k$t=Object.getOwnPropertyDescriptor,che=Object.getOwnPropertyNames,v$t=Object.getPrototypeOf,F$t=Object.prototype.hasOwnProperty,ha=(t,A)=>function(){return A||(0,t[che(t)[0]])((A={exports:{}}).exports,A),A.exports},M$t=(t,A,e,i)=>{if(A&&typeof A=="object"||typeof A=="function")for(let n of che(A))!F$t.call(t,n)&&n!==e&&ghe(t,n,{get:()=>A[n],enumerable:!(i=k$t(A,n))||i.enumerable});return t},cmA=(t,A,e)=>(e=t!=null?_$t(v$t(t)):{},M$t(A||!t||!t.__esModule?ghe(e,"default",{value:t,enumerable:!0}):e,t)),R$t=ha({"node_modules/toggle-selection/index.js"(t,A){A.exports=function(){var e=document.getSelection();if(!e.rangeCount)return function(){};for(var i=document.activeElement,n=[],o=0;o<e.rangeCount;o++)n.push(e.getRangeAt(o));switch(i.tagName.toUpperCase()){case"INPUT":case"TEXTAREA":i.blur();break;default:i=null;break}return e.removeAllRanges(),function(){e.type==="Caret"&&e.removeAllRanges(),e.rangeCount||n.forEach(function(s){e.addRange(s)}),i&&i.focus()}}}}),N$t=ha({"node_modules/copy-to-clipboard/index.js"(t,A){var e=R$t(),i={"text/plain":"Text","text/html":"Url",default:"Text"},n="Copy to clipboard: #{key}, Enter";function o(r){var a=(/mac os x/i.test(navigator.userAgent)?"⌘":"Ctrl")+"+C";return r.replace(/#{\s*key\s*}/g,a)}function s(r,a){var g,c,I,l,B,C,Q=!1;a||(a={}),g=a.debug||!1;try{I=e(),l=document.createRange(),B=document.getSelection(),C=document.createElement("span"),C.textContent=r,C.ariaHidden="true",C.style.all="unset",C.style.position="fixed",C.style.top=0,C.style.clip="rect(0, 0, 0, 0)",C.style.whiteSpace="pre",C.style.webkitUserSelect="text",C.style.MozUserSelect="text",C.style.msUserSelect="text",C.style.userSelect="text",C.addEventListener("copy",function(E){if(E.stopPropagation(),a.format)if(E.preventDefault(),typeof E.clipboardData>"u"){g&&console.warn("unable to use e.clipboardData"),g&&console.warn("trying IE specific stuff"),window.clipboardData.clearData();var u=i[a.format]||i.default;window.clipboardData.setData(u,r)}else E.clipboardData.clearData(),E.clipboardData.setData(a.format,r);a.onCopy&&(E.preventDefault(),a.onCopy(E.clipboardData))}),document.body.appendChild(C),l.selectNodeContents(C),B.addRange(l);var h=document.execCommand("copy");if(!h)throw new Error("copy command was unsuccessful");Q=!0}catch(E){g&&console.error("unable to copy using execCommand: ",E),g&&console.warn("trying IE specific stuff");try{window.clipboardData.setData(a.format||"text",r),a.onCopy&&a.onCopy(window.clipboardData),Q=!0}catch(u){g&&console.error("unable to copy using clipboardData: ",u),g&&console.error("falling back to prompt"),c=o("message"in a?a.message:n),window.prompt(c,r)}}finally{B&&(typeof B.removeRange=="function"?B.removeRange(l):B.removeAllRanges()),C&&document.body.removeChild(C),I()}return Q}A.exports=s}}),G$t=ha({"node_modules/svgson/dist/svgson.umd.js"(t,A){(function(e,i){typeof t=="object"&&typeof A<"u"?A.exports=i():typeof define=="function"&&define.amd?define(i):(e=typeof globalThis<"u"?globalThis:e||self,e.svgson=i())})(t,function(){var e=function(iA){return iA!=null&&(i(iA)||n(iA)||!!iA._isBuffer)};function i(iA){return!!iA.constructor&&typeof iA.constructor.isBuffer=="function"&&iA.constructor.isBuffer(iA)}function n(iA){return typeof iA.readFloatLE=="function"&&typeof iA.slice=="function"&&i(iA.slice(0,0))}var o=Object.prototype.toString,s=function(tA){if(typeof tA>"u")return"undefined";if(tA===null)return"null";if(tA===!0||tA===!1||tA instanceof Boolean)return"boolean";if(typeof tA=="string"||tA instanceof String)return"string";if(typeof tA=="number"||tA instanceof Number)return"number";if(typeof tA=="function"||tA instanceof Function)return"function";if(typeof Array.isArray<"u"&&Array.isArray(tA))return"array";if(tA instanceof RegExp)return"regexp";if(tA instanceof Date)return"date";var sA=o.call(tA);return sA==="[object RegExp]"?"regexp":sA==="[object Date]"?"date":sA==="[object Arguments]"?"arguments":sA==="[object Error]"?"error":e(tA)?"buffer":sA==="[object Set]"?"set":sA==="[object WeakSet]"?"weakset":sA==="[object Map]"?"map":sA==="[object WeakMap]"?"weakmap":sA==="[object Symbol]"?"symbol":sA==="[object Int8Array]"?"int8array":sA==="[object Uint8Array]"?"uint8array":sA==="[object Uint8ClampedArray]"?"uint8clampedarray":sA==="[object Int16Array]"?"int16array":sA==="[object Uint16Array]"?"uint16array":sA==="[object Int32Array]"?"int32array":sA==="[object Uint32Array]"?"uint32array":sA==="[object Float32Array]"?"float32array":sA==="[object Float64Array]"?"float64array":"object"};function r(iA,tA){return tA={exports:{}},iA(tA,tA.exports),tA.exports}var a=r(function(iA){(function(){function tA(sA,aA){if(typeof aA!="function")return sA;var hA={};for(var bA in sA)Object.prototype.hasOwnProperty.call(sA,bA)&&(hA[aA(bA,sA[bA])||bA]=sA[bA]);return hA}iA.exports?iA.exports=tA:window.rename=tA})()}),g=function iA(tA,sA){var aA=s(tA);if(aA!=="object"&&aA!=="array")throw new Error("expected an object");var hA=[];aA==="object"&&(tA=a(tA,sA),hA={});for(var bA in tA)if(tA.hasOwnProperty(bA)){var _A=tA[bA];s(_A)==="object"||s(_A)==="array"?hA[bA]=iA(_A,sA):hA[bA]=_A}return hA},c=r(function(iA){var tA=Object.prototype.hasOwnProperty,sA="~";function aA(){}Object.create&&(aA.prototype=Object.create(null),new aA().__proto__||(sA=!1));function hA(_A,HA,QA){this.fn=_A,this.context=HA,this.once=QA||!1}function bA(){this._events=new aA,this._eventsCount=0}bA.prototype.eventNames=function(){var HA=[],QA,xA;if(this._eventsCount===0)return HA;for(xA in QA=this._events)tA.call(QA,xA)&&HA.push(sA?xA.slice(1):xA);return Object.getOwnPropertySymbols?HA.concat(Object.getOwnPropertySymbols(QA)):HA},bA.prototype.listeners=function(HA,QA){var xA=sA?sA+HA:HA,dA=this._events[xA];if(QA)return!!dA;if(!dA)return[];if(dA.fn)return[dA.fn];for(var qA=0,VA=dA.length,ce=new Array(VA);qA<VA;qA++)ce[qA]=dA[qA].fn;return ce},bA.prototype.emit=function(HA,QA,xA,dA,qA,VA){var ce=sA?sA+HA:HA;if(!this._events[ce])return!1;var fA=this._events[ce],ge=arguments.length,TA,YA;if(fA.fn){switch(fA.once&&this.removeListener(HA,fA.fn,void 0,!0),ge){case 1:return fA.fn.call(fA.context),!0;case 2:return fA.fn.call(fA.context,QA),!0;case 3:return fA.fn.call(fA.context,QA,xA),!0;case 4:return fA.fn.call(fA.context,QA,xA,dA),!0;case 5:return fA.fn.call(fA.context,QA,xA,dA,qA),!0;case 6:return fA.fn.call(fA.context,QA,xA,dA,qA,VA),!0}for(YA=1,TA=new Array(ge-1);YA<ge;YA++)TA[YA-1]=arguments[YA];fA.fn.apply(fA.context,TA)}else{var jA=fA.length,kA;for(YA=0;YA<jA;YA++)switch(fA[YA].once&&this.removeListener(HA,fA[YA].fn,void 0,!0),ge){case 1:fA[YA].fn.call(fA[YA].context);break;case 2:fA[YA].fn.call(fA[YA].context,QA);break;case 3:fA[YA].fn.call(fA[YA].context,QA,xA);break;case 4:fA[YA].fn.call(fA[YA].context,QA,xA,dA);break;default:if(!TA)for(kA=1,TA=new Array(ge-1);kA<ge;kA++)TA[kA-1]=arguments[kA];fA[YA].fn.apply(fA[YA].context,TA)}}return!0},bA.prototype.on=function(HA,QA,xA){var dA=new hA(QA,xA||this),qA=sA?sA+HA:HA;return this._events[qA]?this._events[qA].fn?this._events[qA]=[this._events[qA],dA]:this._events[qA].push(dA):(this._events[qA]=dA,this._eventsCount++),this},bA.prototype.once=function(HA,QA,xA){var dA=new hA(QA,xA||this,!0),qA=sA?sA+HA:HA;return this._events[qA]?this._events[qA].fn?this._events[qA]=[this._events[qA],dA]:this._events[qA].push(dA):(this._events[qA]=dA,this._eventsCount++),this},bA.prototype.removeListener=function(HA,QA,xA,dA){var qA=sA?sA+HA:HA;if(!this._events[qA])return this;if(!QA)return--this._eventsCount===0?this._events=new aA:delete this._events[qA],this;var VA=this._events[qA];if(VA.fn)VA.fn===QA&&(!dA||VA.once)&&(!xA||VA.context===xA)&&(--this._eventsCount===0?this._events=new aA:delete this._events[qA]);else{for(var ce=0,fA=[],ge=VA.length;ce<ge;ce++)(VA[ce].fn!==QA||dA&&!VA[ce].once||xA&&VA[ce].context!==xA)&&fA.push(VA[ce]);fA.length?this._events[qA]=fA.length===1?fA[0]:fA:--this._eventsCount===0?this._events=new aA:delete this._events[qA]}return this},bA.prototype.removeAllListeners=function(HA){var QA;return HA?(QA=sA?sA+HA:HA,this._events[QA]&&(--this._eventsCount===0?this._events=new aA:delete this._events[QA])):(this._events=new aA,this._eventsCount=0),this},bA.prototype.off=bA.prototype.removeListener,bA.prototype.addListener=bA.prototype.on,bA.prototype.setMaxListeners=function(){return this},bA.prefixed=sA,bA.EventEmitter=bA,iA.exports=bA});function I(iA,tA,sA){return tA in iA?Object.defineProperty(iA,tA,{value:sA,enumerable:!0,configurable:!0,writable:!0}):iA[tA]=sA,iA}var l=function(){},B={data:"state-data",cdata:"state-cdata",tagBegin:"state-tag-begin",tagName:"state-tag-name",tagEnd:"state-tag-end",attributeNameStart:"state-attribute-name-start",attributeName:"state-attribute-name",attributeNameEnd:"state-attribute-name-end",attributeValueBegin:"state-attribute-value-begin",attributeValue:"state-attribute-value"},C={lt:"action-lt",gt:"action-gt",space:"action-space",equal:"action-equal",quote:"action-quote",slash:"action-slash",char:"action-char",error:"action-error"},Q={text:"text",openTag:"open-tag",closeTag:"close-tag",attributeName:"attribute-name",attributeValue:"attribute-value"},h={" ":C.space," ":C.space,"\n":C.space,"\r":C.space,"<":C.lt,">":C.gt,'"':C.quote,"'":C.quote,"=":C.equal,"/":C.slash},E=function(tA){return h[tA]||C.char},u=function(tA){var sA,aA,hA,bA,_A,HA,QA,xA,dA,qA;tA=Object.assign({debug:!1},tA);var VA=new c,ce=B.data,fA="",ge="",TA="",YA="",jA="",kA="",wA=function(KA,ZA){if(!(ge[0]==="?"||ge[0]==="!")){var ne={type:KA,value:ZA};tA.debug&&console.log("emit:",ne),VA.emit("data",ne)}};VA.stateMachine=(qA={},I(qA,B.data,(sA={},I(sA,C.lt,function(){fA.trim()&&wA(Q.text,fA),ge="",jA=!1,ce=B.tagBegin}),I(sA,C.char,function(MA){fA+=MA}),sA)),I(qA,B.cdata,I({},C.char,function(MA){fA+=MA,fA.substr(-3)==="]]>"&&(wA(Q.text,fA.slice(0,-3)),fA="",ce=B.data)})),I(qA,B.tagBegin,(aA={},I(aA,C.space,l),I(aA,C.char,function(MA){ge=MA,ce=B.tagName}),I(aA,C.slash,function(){ge="",jA=!0}),aA)),I(qA,B.tagName,(hA={},I(hA,C.space,function(){jA?ce=B.tagEnd:(ce=B.attributeNameStart,wA(Q.openTag,ge))}),I(hA,C.gt,function(){wA(jA?Q.closeTag:Q.openTag,ge),fA="",ce=B.data}),I(hA,C.slash,function(){ce=B.tagEnd,wA(Q.openTag,ge)}),I(hA,C.char,function(MA){ge+=MA,ge==="![CDATA["&&(ce=B.cdata,fA="",ge="")}),hA)),I(qA,B.tagEnd,(bA={},I(bA,C.gt,function(){wA(Q.closeTag,ge),fA="",ce=B.data}),I(bA,C.char,l),bA)),I(qA,B.attributeNameStart,(_A={},I(_A,C.char,function(MA){TA=MA,ce=B.attributeName}),I(_A,C.gt,function(){fA="",ce=B.data}),I(_A,C.space,l),I(_A,C.slash,function(){jA=!0,ce=B.tagEnd}),_A)),I(qA,B.attributeName,(HA={},I(HA,C.space,function(){ce=B.attributeNameEnd}),I(HA,C.equal,function(){wA(Q.attributeName,TA),ce=B.attributeValueBegin}),I(HA,C.gt,function(){YA="",wA(Q.attributeName,TA),wA(Q.attributeValue,YA),fA="",ce=B.data}),I(HA,C.slash,function(){jA=!0,YA="",wA(Q.attributeName,TA),wA(Q.attributeValue,YA),ce=B.tagEnd}),I(HA,C.char,function(MA){TA+=MA}),HA)),I(qA,B.attributeNameEnd,(QA={},I(QA,C.space,l),I(QA,C.equal,function(){wA(Q.attributeName,TA),ce=B.attributeValueBegin}),I(QA,C.gt,function(){YA="",wA(Q.attributeName,TA),wA(Q.attributeValue,YA),fA="",ce=B.data}),I(QA,C.char,function(MA){YA="",wA(Q.attributeName,TA),wA(Q.attributeValue,YA),TA=MA,ce=B.attributeName}),QA)),I(qA,B.attributeValueBegin,(xA={},I(xA,C.space,l),I(xA,C.quote,function(MA){kA=MA,YA="",ce=B.attributeValue}),I(xA,C.gt,function(){YA="",wA(Q.attributeValue,YA),fA="",ce=B.data}),I(xA,C.char,function(MA){kA="",YA=MA,ce=B.attributeValue}),xA)),I(qA,B.attributeValue,(dA={},I(dA,C.space,function(MA){kA?YA+=MA:(wA(Q.attributeValue,YA),ce=B.attributeNameStart)}),I(dA,C.quote,function(MA){kA===MA?(wA(Q.attributeValue,YA),ce=B.attributeNameStart):YA+=MA}),I(dA,C.gt,function(MA){kA?YA+=MA:(wA(Q.attributeValue,YA),fA="",ce=B.data)}),I(dA,C.slash,function(MA){kA?YA+=MA:(wA(Q.attributeValue,YA),jA=!0,ce=B.tagEnd)}),I(dA,C.char,function(MA){YA+=MA}),dA)),qA);var GA=function(KA){tA.debug&&console.log(ce,KA);var ZA=VA.stateMachine[ce],ne=ZA[E(KA)]||ZA[C.error]||ZA[C.char];ne(KA)};return VA.write=function(MA){for(var KA=MA.length,ZA=0;ZA<KA;ZA++)GA(MA[ZA])},VA},d={State:B,Action:C,Type:Q,create:u},f=d.Type,m={element:"element",text:"text"},w=function(tA){return Object.assign({name:"",type:m.element,value:"",parent:null,attributes:{},children:[]},tA)},D=function(tA){tA=Object.assign({stream:!1,parentNodes:!0,doneEvent:"done",tagPrefix:"tag:",emitTopLevelOnly:!1,debug:!1},tA);var sA=void 0,aA=void 0,hA=void 0,bA=void 0,_A=new c,HA=function(xA){switch(xA.type){case f.openTag:if(hA===null)hA=aA,hA.name=xA.value;else{var dA=w({name:xA.value,parent:hA});hA.children.push(dA),hA=dA}break;case f.closeTag:var qA=hA.parent;if(tA.parentNodes||(hA.parent=null),hA.name!==xA.value)break;tA.stream&&qA===aA&&(aA.children=[],hA.parent=null),(!tA.emitTopLevelOnly||qA===aA)&&(_A.emit(tA.tagPrefix+hA.name,hA),_A.emit("tag",hA.name,hA)),hA===aA&&(sA.removeAllListeners("data"),_A.emit(tA.doneEvent,hA),aA=null),hA=qA;break;case f.text:hA&&hA.children.push(w({type:m.text,value:xA.value,parent:tA.parentNodes?hA:null}));break;case f.attributeName:bA=xA.value,hA.attributes[bA]="";break;case f.attributeValue:hA.attributes[bA]=xA.value;break}};return _A.reset=function(){sA=d.create({debug:tA.debug}),sA.on("data",HA),aA=w(),hA=null,bA="",_A.parse=sA.write},_A.reset(),_A},S=function(tA,sA){sA=Object.assign({},sA,{stream:!1,tagPrefix:":"});var aA=D(sA),hA=void 0;return aA.on("done",function(bA){hA=bA}),aA.parse(tA),hA},_={parseSync:S},b=_.parseSync,N=function(tA){var sA=b("<root>".concat(tA,"</root>"),{parentNodes:!1}),aA=sA.children&&sA.children.length>0&&sA.children.every(function(hA){return hA.name==="svg"});if(aA)return sA.children.length===1?sA.children[0]:sA.children;throw Error("nothing to parse")},F=function(tA){return g(tA,function(sA){return Y(sA)?sA:L(sA)})},L=function(tA){return tA.replace(/[-|:]([a-z])/gi,function(sA,aA){return aA.toUpperCase()})},Y=function(tA){return/^(data|aria)(-\w+)/.test(tA)},J=function(tA){if(tA){var sA=String(tA);return/[&<>]/.test(sA)?"<![CDATA[".concat(sA.replace(/]]>/,"]]]]><![CDATA[>"),"]]>"):sA}return""},q=function(tA){return String(tA).replace(/&/g,"&amp;").replace(/'/g,"&apos;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")},Z=function(tA){var sA=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},aA=sA.transformNode,hA=aA===void 0?function(QA){return QA}:aA,bA=sA.camelcase,_A=bA===void 0?!1:bA,HA=function(xA){var dA;return dA=hA(xA),_A&&(dA=F(dA)),dA};return HA(N(tA))};function X(){for(var iA=arguments.length,tA=new Array(iA),sA=0;sA<iA;sA++)tA[sA]=arguments[sA];return new Promise(function(aA,hA){try{var bA=Z.apply(void 0,tA);aA(bA)}catch(_A){hA(_A)}})}var eA=function iA(tA){var sA=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},aA=sA.transformAttr,hA=aA===void 0?function(ce,fA,ge){return"".concat(ce,'="').concat(ge(fA),'"')}:aA,bA=sA.transformNode,_A=bA===void 0?function(ce){return ce}:bA,HA=sA.selfClose,QA=HA===void 0?!0:HA;if(Array.isArray(tA))return tA.map(function(ce){return iA(ce,{transformAttr:hA,selfClose:QA,transformNode:_A})}).join("");var xA=_A(tA);if(xA.type==="text")return J(xA.value);var dA="";for(var qA in xA.attributes){var VA=hA(qA,xA.attributes[qA],q,xA.name);dA+=VA?" ".concat(VA):""}return xA.children&&xA.children.length>0||!QA?"<".concat(xA.name).concat(dA,">").concat(iA(xA.children,{transformAttr:hA,transformNode:_A,selfClose:QA}),"</").concat(xA.name,">"):"<".concat(xA.name).concat(dA,"/>")},gA=Object.assign({},{parse:X,parseSync:Z,stringify:eA});return gA})}}),ImA=ha({"node_modules/js-beautify/js/src/core/output.js"(t,A){function e(o){this.__parent=o,this.__character_count=0,this.__indent_count=-1,this.__alignment_count=0,this.__wrap_point_index=0,this.__wrap_point_character_count=0,this.__wrap_point_indent_count=-1,this.__wrap_point_alignment_count=0,this.__items=[]}e.prototype.clone_empty=function(){var o=new e(this.__parent);return o.set_indent(this.__indent_count,this.__alignment_count),o},e.prototype.item=function(o){return o<0?this.__items[this.__items.length+o]:this.__items[o]},e.prototype.has_match=function(o){for(var s=this.__items.length-1;s>=0;s--)if(this.__items[s].match(o))return!0;return!1},e.prototype.set_indent=function(o,s){this.is_empty()&&(this.__indent_count=o||0,this.__alignment_count=s||0,this.__character_count=this.__parent.get_indent_size(this.__indent_count,this.__alignment_count))},e.prototype._set_wrap_point=function(){this.__parent.wrap_line_length&&(this.__wrap_point_index=this.__items.length,this.__wrap_point_character_count=this.__character_count,this.__wrap_point_indent_count=this.__parent.next_line.__indent_count,this.__wrap_point_alignment_count=this.__parent.next_line.__alignment_count)},e.prototype._should_wrap=function(){return this.__wrap_point_index&&this.__character_count>this.__parent.wrap_line_length&&this.__wrap_point_character_count>this.__parent.next_line.__character_count},e.prototype._allow_wrap=function(){if(this._should_wrap()){this.__parent.add_new_line();var o=this.__parent.current_line;return o.set_indent(this.__wrap_point_indent_count,this.__wrap_point_alignment_count),o.__items=this.__items.slice(this.__wrap_point_index),this.__items=this.__items.slice(0,this.__wrap_point_index),o.__character_count+=this.__character_count-this.__wrap_point_character_count,this.__character_count=this.__wrap_point_character_count,o.__items[0]===" "&&(o.__items.splice(0,1),o.__character_count-=1),!0}return!1},e.prototype.is_empty=function(){return this.__items.length===0},e.prototype.last=function(){return this.is_empty()?null:this.__items[this.__items.length-1]},e.prototype.push=function(o){this.__items.push(o);var s=o.lastIndexOf(`
5390
+ `),a=r.map(I=>{const l=Array.from(I);return l.reduce((B,C,Q)=>B+DQe(C,l[Q+1],A),0)}),g=a.reduce((I,l)=>Math.max(I,l),0),c=r.length>1?A+(r.length-1)*s:A;return{width:g,height:c,glyphWidth:e,letterSpacing:i,spaceWidth:n,strokeWidth:o,lineHeight:s,lines:r,lineWidths:a}}function SQe(t,A){const e=A.width+A.strokeWidth,i=A.height+A.strokeWidth;let n=0,o=0;return t==="center"||t==="top_center"||t==="bottom_center"?n=-e/2:t==="top_left"||t==="bottom_left"||t==="center_left"?n=0:t==="top_right"||t==="bottom_right"||t==="center_right"?n=-e:(t==="top_center"||t==="bottom_center")&&(n=-e/2),t==="center"||t==="center_left"||t==="center_right"?o=-i/2:t==="top_left"||t==="top_right"||t==="top_center"?o=0:(t==="bottom_left"||t==="bottom_right"||t==="bottom_center")&&(o=-i),{x:n,y:o}}function bQe(t){const{alignment:A,lineWidth:e,maxWidth:i,strokeWidth:n}=t,o=e+n,s=i+n;return A==="top_left"||A==="bottom_left"||A==="center_left"?0:A==="top_right"||A==="bottom_right"||A==="center_right"?s-o:(s-o)/2}var m6t=t=>lee[t];function xQe(t){const{ctx:A,line:e,fontSize:i,startX:n,startY:o,layout:s}=t,{strokeWidth:r}=s,a=i,g=i,c=o,I=Array.from(e);let l=n+r/2;I.forEach((B,C)=>{const Q=m6t(B);if(Q?.length){A.beginPath();for(const h of Q){const E=l+h.x1*g,u=c+(1-h.y1)*a,d=l+h.x2*g,f=c+(1-h.y2)*a;A.moveTo(E,u),A.lineTo(d,f)}A.stroke()}l+=DQe(B,I[C+1],i)})}function w6t(t){const{ctx:A,text:e,fontSize:i,startX:n,startY:o,anchorAlignment:s="center"}=t,r=zyA(e,i),{lines:a,lineWidths:g,lineHeight:c,width:I,strokeWidth:l}=r;a.forEach((B,C)=>{const Q=n+bQe({alignment:s,lineWidth:g[C],maxWidth:I,strokeWidth:l}),h=o+C*c;xQe({ctx:A,line:B,fontSize:i,startX:Q,startY:h,layout:r})})}var D6t={left:.2,right:.2,top:.2,bottom:.2};function gz(t){const{ctx:A,text:e,x:i,y:n,fontSize:o,color:s,realToCanvasMat:r,anchorAlignment:a,rotation:g=0,mirrorX:c=!1,knockout:I=!1,knockoutPadding:l={}}=t;if(!e)return;const[B,C]=ai(r,[i,n]),Q=Math.abs(r.a),h=o*Q,E=zyA(e,h),u=SQe(a,E);if(A.save(),A.translate(B,C),g!==0&&A.rotate(-g*(Math.PI/180)),c&&A.scale(-1,1),I){const S={...D6t,...l},_=S.left*Q,b=S.right*Q,N=S.top*Q,F=S.bottom*Q,L=E.width+E.strokeWidth,Y=u.x-_*4,J=u.y-N*4,q=L+_*2+b*2,Z=E.height+E.strokeWidth+N*2+F*2;A.fillStyle=s,A.fillRect(Y,J,q,Z)}else A.strokeStyle=s;A.lineWidth=E.strokeWidth,A.lineCap="round",A.lineJoin="round";const{lines:d,lineWidths:f,lineHeight:m,width:w,strokeWidth:D}=E;d.forEach((S,_)=>{const b=u.x+bQe({alignment:a,lineWidth:f[_],maxWidth:w,strokeWidth:D}),N=u.y+_*m;xQe({ctx:A,line:S,fontSize:h,startX:b,startY:N,layout:E})}),A.restore()}var S6t={left:.2,right:.2,top:.2,bottom:.2};function b6t(t){return t?t.includes("left")?"center_left":t.includes("right")?"center_right":"center":"center"}function x6t(t){const{ctx:A,text:e,realToCanvasMat:i,colorMap:n}=t,o=e.text??"";if(!o)return;const[s,r]=ai(i,[e.anchor_position.x,e.anchor_position.y]),a=Math.abs(i.a),g=(e.font_size??1)*a,c=e.ccw_rotation??0,I={...S6t,...e.knockout_padding},l=n.copper[e.layer]??n.copper.top,B=zyA(o,g),C=B.width+B.strokeWidth,Q=b6t(e.anchor_alignment),h=SQe(Q,B);if(A.save(),A.translate(s,r),e.is_mirrored&&A.scale(-1,1),c!==0&&A.rotate(-c*(Math.PI/180)),A.lineWidth=B.strokeWidth,A.lineCap="round",A.lineJoin="round",e.is_knockout){const E=I.left*a,u=I.right*a,d=I.top*a,f=I.bottom*a,m=h.x-E*4,w=h.y-d*4,D=C+E*2+u*2,S=B.height+B.strokeWidth+d*2+f*2;A.fillStyle=l,A.fillRect(m,w,D,S)}else A.strokeStyle=l;w6t({ctx:A,text:o,fontSize:g,startX:h.x,startY:h.y,anchorAlignment:Q}),A.restore()}function tQ(t){const{ctx:A,center:e,radius:i,fill:n,realToCanvasMat:o,stroke:s,strokeWidth:r,isStrokeDashed:a=!1}=t,[g,c]=ai(o,[e.x,e.y]),I=i*Math.abs(o.a),l=r?r*Math.abs(o.a):void 0;A.beginPath(),A.arc(g,c,I,0,Math.PI*2),n&&(A.fillStyle=n,A.fill()),s&&l&&(a?A.setLineDash([l*3,l*2]):A.setLineDash([]),A.strokeStyle=s,A.lineWidth=l,A.stroke())}function _6t(t,A){return t==="bottom"?A.courtyard.bottom:A.courtyard.top}function k6t(t){const{ctx:A,circle:e,realToCanvasMat:i,colorMap:n}=t;tQ({ctx:A,center:e.center,radius:e.radius,stroke:_6t(e.layer,n),strokeWidth:.05,realToCanvasMat:i})}function v6t(t,A){return t==="bottom"?A.courtyard.bottom:A.courtyard.top}function F6t(t){const{ctx:A,outline:e,realToCanvasMat:i,colorMap:n}=t;if(!e.outline||e.outline.length<2)return;A.beginPath();const o=ai(i,e.outline[0]);A.moveTo(o.x,o.y);for(let s=1;s<e.outline.length;s++){const r=ai(i,e.outline[s]);A.lineTo(r.x,r.y)}A.closePath(),A.lineWidth=.05*Math.abs(i.a),A.strokeStyle=v6t(e.layer,n),A.stroke()}function M6t(t,A){return t==="bottom"?A.courtyard.bottom:A.courtyard.top}function R6t(t){const{ctx:A,rect:e,realToCanvasMat:i,colorMap:n}=t;eQ({ctx:A,center:e.center,width:e.width,height:e.height,stroke:M6t(e.layer,n),strokeWidth:.05,realToCanvasMat:i})}function N6t(t){const{ctx:A,cutout:e,realToCanvasMat:i,colorMap:n}=t;if(e.shape==="rect"){eQ({ctx:A,center:e.center,width:e.width,height:e.height,fill:n.drill,realToCanvasMat:i,ccwRotationDegrees:e.rotation??0,borderRadius:e.corner_radius??0});return}if(e.shape==="circle"){tQ({ctx:A,center:e.center,radius:e.radius,fill:n.drill,realToCanvasMat:i});return}if(e.shape==="polygon"){e.points&&e.points.length>=3&&Hk({ctx:A,points:e.points,fill:n.drill,realToCanvasMat:i});return}}var G6t=1.5,L6t=.6,U6t=.3;function XyA(t){const A=Math.hypot(t.x,t.y)||1;return{x:t.x/A,y:t.y/A}}function _Qe(t){const{ctx:A,from:e,to:i,realToCanvasMat:n,color:o,fontSize:s,arrowSize:r=1,strokeWidth:a,text:g,textRotation:c,offset:I}=t,l=XyA({x:i.x-e.x,y:i.y-e.y}),B={x:-l.y,y:l.x},C=I?.direction&&typeof I.direction.x=="number"&&typeof I.direction.y=="number",Q=C?XyA(I.direction):{x:0,y:0},h=I?.distance??0,E={x:Q.x*h,y:Q.y*h},u={x:e.x+E.x,y:e.y+E.y},d={x:i.x+E.x,y:i.y+E.y},f={x:u.x+l.x*r,y:u.y+l.y*r},m={x:d.x-l.x*r,y:d.y-l.y*r};Math.abs(n.a);const w=a??r/5,D=o||"rgba(255,255,255,0.5)",S=C&&(Math.abs(Q.x)>Number.EPSILON||Math.abs(Q.y)>Number.EPSILON)?Q:B,_=h+.5,b=[],N=Y=>{const J={x:Y.x+S.x*_,y:Y.y+S.y*_},q=w/2,Z={x:-S.y,y:S.x};return[{x:Y.x+Z.x*q,y:Y.y+Z.y*q},{x:Y.x-Z.x*q,y:Y.y-Z.y*q},{x:J.x-Z.x*q,y:J.y-Z.y*q},{x:J.x+Z.x*q,y:J.y+Z.y*q}]};b.push(u),b.push({x:f.x+B.x*(r/2),y:f.y+B.y*(r/2)}),b.push({x:f.x+B.x*(w/2),y:f.y+B.y*(w/2)}),b.push({x:m.x+B.x*(w/2),y:m.y+B.y*(w/2)}),b.push({x:m.x+B.x*(r/2),y:m.y+B.y*(r/2)}),b.push(d),b.push({x:m.x-B.x*(r/2),y:m.y-B.y*(r/2)}),b.push({x:m.x-B.x*(w/2),y:m.y-B.y*(w/2)}),b.push({x:f.x-B.x*(w/2),y:f.y-B.y*(w/2)}),b.push({x:f.x-B.x*(r/2),y:f.y-B.y*(r/2)}),b.push(u);const F=b[0],L=Y=>{const J=N(Y);b.push(F),b.push(J[0]),b.push(...J),b.push(J[0]),b.push(F)};if(L(e),L(i),Hk({ctx:A,points:b,fill:D,realToCanvasMat:n}),g){const Y={x:(e.x+i.x)/2+E.x,y:(e.y+i.y)/2+E.y},[J,q]=ai(n,[u.x,u.y]),[Z,X]=ai(n,[d.x,d.y]),eA=XyA({x:Z-J,y:X-q});let gA=Math.atan2(eA.y,eA.x)*180/Math.PI;(gA>90||gA<-90)&&(gA+=180);const iA=typeof c=="number"&&Number.isFinite(c)?gA-c:gA;let tA=0;if(g&&typeof c=="number"&&Number.isFinite(c)){const hA=g.length*s*L6t,bA=s,_A=c*Math.PI/180,HA=Math.abs(Math.sin(_A)),QA=Math.abs(Math.cos(_A)),xA=hA/2,dA=bA/2;tA=xA*HA+dA*QA+s*U6t}const sA=r*G6t+tA,aA={x:Y.x+B.x*sA,y:Y.y+B.y*sA};gz({ctx:A,text:g,x:aA.x,y:aA.y,fontSize:s,color:D,realToCanvasMat:n,anchorAlignment:"center",rotation:-iA})}}function H6t(t){const{ctx:A,pcbFabricationNoteDimension:e,realToCanvasMat:i,colorMap:n}=t,o=e.color??n.fabricationNote;_Qe({ctx:A,from:e.from,to:e.to,realToCanvasMat:i,color:o,fontSize:e.font_size??1,arrowSize:e.arrow_size??1,text:e.text,textRotation:e.text_ccw_rotation,offset:e.offset_distance&&e.offset_direction?{distance:e.offset_distance,direction:e.offset_direction}:void 0})}function E2(t){const{ctx:A,start:e,end:i,strokeWidth:n,stroke:o,realToCanvasMat:s,lineCap:r="round"}=t,[a,g]=ai(s,[e.x,e.y]),[c,I]=ai(s,[i.x,i.y]),l=n*Math.abs(s.a);A.beginPath(),A.moveTo(a,g),A.lineTo(c,I),A.lineWidth=l,A.strokeStyle=o,A.lineCap=r,A.stroke()}function Y6t(t){const{ctx:A,path:e,realToCanvasMat:i,colorMap:n}=t,o=n.fabricationNote,s=e.color??o;if(!(!e.route||e.route.length<2))for(let r=0;r<e.route.length-1;r++){const a=e.route[r],g=e.route[r+1];!a||!g||E2({ctx:A,start:{x:a.x,y:a.y},end:{x:g.x,y:g.y},strokeWidth:e.stroke_width??.1,stroke:s,realToCanvasMat:i})}}function J6t(t){const{ctx:A,rect:e,realToCanvasMat:i,colorMap:n}=t,o=n.fabricationNote,s=e.color??o,r=e.is_filled??!1,a=e.has_stroke??!0,g=e.is_stroke_dashed??!1;eQ({ctx:A,center:e.center,width:e.width,height:e.height,fill:r?s:void 0,stroke:a?s:void 0,strokeWidth:a?e.stroke_width:void 0,borderRadius:e.corner_radius,realToCanvasMat:i,isStrokeDashed:g})}function T6t(t,A){return A.fabricationNote}function P6t(t){const{ctx:A,text:e,realToCanvasMat:i,colorMap:n}=t,o=T6t(e.layer,n),s=e.color??o,r=e.font_size;gz({ctx:A,text:e.text,x:e.anchor_position.x,y:e.anchor_position.y,fontSize:r,color:s,realToCanvasMat:i,anchorAlignment:e.anchor_alignment})}function ES(t){const{ctx:A,center:e,radius_x:i,radius_y:n,fill:o,stroke:s,strokeWidth:r=.1,realToCanvasMat:a,rotation:g=0}=t,[c,I]=ai(a,[e.x,e.y]),l=i*Math.abs(a.a),B=n*Math.abs(a.a),C=r*Math.abs(a.a);A.save(),A.translate(c,I),g!==0&&A.rotate(-g*(Math.PI/180)),A.beginPath(),A.ellipse(0,0,l,B,0,0,Math.PI*2),o&&(A.fillStyle=o,A.fill()),s&&(A.strokeStyle=s,A.lineWidth=C,A.stroke()),A.restore()}function eh(t){const{ctx:A,center:e,width:i,height:n,fill:o,realToCanvasMat:s,rotation:r=0,stroke:a,strokeWidth:g}=t,[c,I]=ai(s,[e.x,e.y]),l=i*Math.abs(s.a),B=n*Math.abs(s.a),C=g?g*Math.abs(s.a):void 0;if(A.save(),A.translate(c,I),r!==0&&A.rotate(-r*(Math.PI/180)),A.beginPath(),l>B){const Q=B/2,h=l-B;A.moveTo(-h/2,-Q),A.lineTo(h/2,-Q),A.arc(h/2,0,Q,-Math.PI/2,Math.PI/2),A.lineTo(-h/2,Q),A.arc(-h/2,0,Q,Math.PI/2,-Math.PI/2)}else if(B>l){const Q=l/2,h=B-l;A.moveTo(Q,-h/2),A.lineTo(Q,h/2),A.arc(0,h/2,Q,0,Math.PI),A.lineTo(-Q,-h/2),A.arc(0,-h/2,Q,Math.PI,0)}else A.arc(0,0,l/2,0,Math.PI*2);A.closePath(),o&&(A.fillStyle=o,A.fill()),a&&C&&(A.strokeStyle=a,A.lineWidth=C,A.stroke()),A.restore()}function cz(t){return"ccw_rotation"in t&&typeof t.ccw_rotation=="number"?t.ccw_rotation:0}function kQe(t){const{ctx:A,hole:e,realToCanvasMat:i,colorMap:n,soldermaskMargin:o=0,drawSoldermask:s=!1}=t;if(s&&e.is_covered_with_solder_mask===!0)return;const r=o<0?Math.abs(o):0;if(e.hole_shape==="circle"){tQ({ctx:A,center:{x:e.x,y:e.y},radius:e.hole_diameter/2-r,fill:n.drill,realToCanvasMat:i});return}if(e.hole_shape==="square"){const a=cz(e);eQ({ctx:A,center:{x:e.x,y:e.y},width:e.hole_diameter-r*2,height:e.hole_diameter-r*2,fill:n.drill,realToCanvasMat:i,ccwRotationDegrees:a});return}if(e.hole_shape==="oval"){const a=cz(e);ES({ctx:A,center:{x:e.x,y:e.y},radius_x:e.hole_width/2-r,radius_y:e.hole_height/2-r,fill:n.drill,realToCanvasMat:i,rotation:a});return}if(e.hole_shape==="rect"){const a=cz(e);eQ({ctx:A,center:{x:e.x,y:e.y},width:e.hole_width-r*2,height:e.hole_height-r*2,fill:n.drill,realToCanvasMat:i,ccwRotationDegrees:a});return}if(e.hole_shape==="pill"||e.hole_shape==="rotated_pill"){const a=cz(e);eh({ctx:A,center:{x:e.x,y:e.y},width:e.hole_width-r*2,height:e.hole_height-r*2,fill:n.drill,realToCanvasMat:i,rotation:a});return}}function K6t(t,A){const e=parseInt(t.slice(1,3),16),i=parseInt(t.slice(3,5),16),n=parseInt(t.slice(5,7),16);return`rgba(${e}, ${i}, ${n}, ${A})`}function q6t(t){const{ctx:A,keepout:e,realToCanvasMat:i,colorMap:n}=t,o=n.keepout,s=K6t(n.keepout,.2),r=1;if(e.shape==="rect"){const[a,g]=ai(i,[e.center.x,e.center.y]),c=e.width*Math.abs(i.a),I=e.height*Math.abs(i.a),l=e.rotation??0;A.save(),A.translate(a,g),l!==0&&A.rotate(-l*(Math.PI/180)),A.beginPath(),A.rect(-c/2,-I/2,c,I),A.fillStyle=s,A.fill(),A.beginPath(),A.rect(-c/2,-I/2,c,I),A.clip();const B=r*Math.abs(i.a),C=Math.sqrt(c*c+I*I),Q=c/2,h=I/2;A.strokeStyle=o,A.lineWidth=.15*Math.abs(i.a),A.setLineDash([]);for(let E=-C;E<C*2;E+=B){A.beginPath();const u=-Q+E,d=-h,f=-Q+E+C,m=-h+C;A.moveTo(u,d),A.lineTo(f,m),A.stroke()}A.restore();return}if(e.shape==="circle"){const[a,g]=ai(i,[e.center.x,e.center.y]),c=e.radius*Math.abs(i.a),I=r*Math.abs(i.a);A.save(),A.translate(a,g),A.beginPath(),A.arc(0,0,c,0,Math.PI*2),A.fillStyle=s,A.fill(),A.beginPath(),A.arc(0,0,c,0,Math.PI*2),A.clip();const l=c*2;A.strokeStyle=o,A.lineWidth=.15*Math.abs(i.a),A.setLineDash([]);for(let B=-l;B<l*2;B+=I)A.beginPath(),A.moveTo(B-l,-l),A.lineTo(B+l,l),A.stroke();A.restore();return}}var O6t="rgba(255,255,255,0.5)";function W6t(t){const{ctx:A,pcbNoteDimension:e,realToCanvasMat:i}=t,n=e.color??O6t;_Qe({ctx:A,from:e.from,to:e.to,realToCanvasMat:i,color:n,fontSize:e.font_size,arrowSize:e.arrow_size,text:e.text,textRotation:e.text_ccw_rotation,offset:e.offset_distance&&e.offset_direction?{distance:e.offset_distance,direction:e.offset_direction}:void 0})}function Z6t(t){const{ctx:A,line:e,realToCanvasMat:i}=t,o=e.color??"rgb(89, 148, 220)",s=e.stroke_width??.1,r=e.is_dashed??!1,[a,g]=ai(i,[e.x1,e.y1]),[c,I]=ai(i,[e.x2,e.y2]),l=s*Math.abs(i.a);A.save(),r?A.setLineDash([l*2,l*2]):A.setLineDash([]),A.beginPath(),A.moveTo(a,g),A.lineTo(c,I),A.lineWidth=l,A.strokeStyle=o,A.lineCap="round",A.stroke(),A.restore()}function V6t(t){const{ctx:A,path:e,realToCanvasMat:i}=t,o=e.color??"rgb(89, 148, 220)";if(!(!e.route||e.route.length<2))for(let s=0;s<e.route.length-1;s++){const r=e.route[s],a=e.route[s+1];!r||!a||E2({ctx:A,start:{x:r.x,y:r.y},end:{x:a.x,y:a.y},strokeWidth:e.stroke_width??.1,stroke:o,realToCanvasMat:i})}}function j6t(t){const{ctx:A,rect:e,realToCanvasMat:i}=t,o=e.color??"rgb(89, 148, 220)",s=e.is_filled??!1,r=e.has_stroke??!0,a=e.is_stroke_dashed??!1;eQ({ctx:A,center:e.center,width:e.width,height:e.height,fill:s?o:void 0,stroke:r?o:void 0,strokeWidth:r?e.stroke_width:void 0,borderRadius:e.corner_radius,realToCanvasMat:i,isStrokeDashed:a})}var z6t="rgb(89, 148, 220)";function X6t(t){const{ctx:A,text:e,realToCanvasMat:i}=t,n=z6t,o=e.color??n,s=e.font_size??1;gz({ctx:A,text:e.text??"",x:e.anchor_position.x,y:e.anchor_position.y,fontSize:s,color:o,realToCanvasMat:i,anchorAlignment:e.anchor_alignment??"center"})}function $6t(t){const{ctx:A,panel:e,realToCanvasMat:i,colorMap:n}=t,{width:o,height:s,center:r}=e;if(o!==void 0&&s!==void 0&&r){const a=o/2,g=s/2,c=[{x:r.x-a,y:r.y-g},{x:r.x+a,y:r.y-g},{x:r.x+a,y:r.y+g},{x:r.x-a,y:r.y+g}];az({ctx:A,points:c,stroke:n.boardOutline,strokeWidth:.5,realToCanvasMat:i,closePath:!0})}}function LT(t,A){if(t.length<3||A===0)return t;let e=0,i=0;for(const o of t)e+=o.x,i+=o.y;e/=t.length,i/=t.length;const n=[];for(const o of t){const s=o.x-e,r=o.y-i,a=Math.sqrt(s*s+r*r);if(a>0){const g=s/a,c=r/a;n.push({x:o.x+g*A,y:o.y+c*A})}else n.push({x:o.x+A,y:o.y})}return n}function vQe(t){const{ctx:A,hole:e,realToCanvasMat:i,colorMap:n,soldermaskMargin:o=0,drawSoldermask:s}=t;if(e.is_covered_with_solder_mask===!0&&s)return;const r=n.copper[t.layer??"top"],a=o<0?Math.abs(o):0;if(e.shape==="circle"){tQ({ctx:A,center:{x:e.x,y:e.y},radius:e.outer_diameter/2-a,fill:r,realToCanvasMat:i}),uS(A,()=>{tQ({ctx:A,center:{x:e.x,y:e.y},radius:e.hole_diameter/2,fill:"#000",realToCanvasMat:i})}),tQ({ctx:A,center:{x:e.x,y:e.y},radius:e.hole_diameter/2,fill:n.drill,realToCanvasMat:i});return}if(e.shape==="oval"){ES({ctx:A,center:{x:e.x,y:e.y},radius_x:e.outer_width/2-a,radius_y:e.outer_height/2-a,fill:r,realToCanvasMat:i,rotation:e.ccw_rotation}),uS(A,()=>{ES({ctx:A,center:{x:e.x,y:e.y},radius_x:e.hole_width/2,radius_y:e.hole_height/2,fill:"#000",realToCanvasMat:i,rotation:e.ccw_rotation})}),ES({ctx:A,center:{x:e.x,y:e.y},radius_x:e.hole_width/2,radius_y:e.hole_height/2,fill:n.drill,realToCanvasMat:i,rotation:e.ccw_rotation});return}if(e.shape==="pill"){eh({ctx:A,center:{x:e.x,y:e.y},width:e.outer_width-a*2,height:e.outer_height-a*2,fill:r,realToCanvasMat:i,rotation:e.ccw_rotation}),uS(A,()=>{eh({ctx:A,center:{x:e.x,y:e.y},width:e.hole_width,height:e.hole_height,fill:"#000",realToCanvasMat:i,rotation:e.ccw_rotation})}),eh({ctx:A,center:{x:e.x,y:e.y},width:e.hole_width,height:e.hole_height,fill:n.drill,realToCanvasMat:i,rotation:e.ccw_rotation});return}if(e.shape==="circular_hole_with_rect_pad"){eQ({ctx:A,center:{x:e.x,y:e.y},width:e.rect_pad_width-a*2,height:e.rect_pad_height-a*2,fill:r,realToCanvasMat:i,borderRadius:e.rect_border_radius?Math.max(0,e.rect_border_radius-a):0,ccwRotationDegrees:e.rect_ccw_rotation});const g=e.x+(e.hole_offset_x??0),c=e.y+(e.hole_offset_y??0);uS(A,()=>{tQ({ctx:A,center:{x:g,y:c},radius:e.hole_diameter/2,fill:"#000",realToCanvasMat:i})}),tQ({ctx:A,center:{x:g,y:c},radius:e.hole_diameter/2,fill:n.drill,realToCanvasMat:i});return}if(e.shape==="pill_hole_with_rect_pad"){eQ({ctx:A,center:{x:e.x,y:e.y},width:e.rect_pad_width-a*2,height:e.rect_pad_height-a*2,fill:r,realToCanvasMat:i,borderRadius:e.rect_border_radius?Math.max(0,e.rect_border_radius-a):0});const g=e.x+(e.hole_offset_x??0),c=e.y+(e.hole_offset_y??0);uS(A,()=>{eh({ctx:A,center:{x:g,y:c},width:e.hole_width,height:e.hole_height,fill:"#000",realToCanvasMat:i})}),eh({ctx:A,center:{x:g,y:c},width:e.hole_width,height:e.hole_height,fill:n.drill,realToCanvasMat:i});return}if(e.shape==="rotated_pill_hole_with_rect_pad"){eQ({ctx:A,center:{x:e.x,y:e.y},width:e.rect_pad_width-a*2,height:e.rect_pad_height-a*2,fill:r,realToCanvasMat:i,borderRadius:e.rect_border_radius?Math.max(0,e.rect_border_radius-a):0,ccwRotationDegrees:e.rect_ccw_rotation});const g=e.x+(e.hole_offset_x??0),c=e.y+(e.hole_offset_y??0);uS(A,()=>{eh({ctx:A,center:{x:g,y:c},width:e.hole_width,height:e.hole_height,fill:"#000",realToCanvasMat:i,rotation:e.hole_ccw_rotation})}),eh({ctx:A,center:{x:g,y:c},width:e.hole_width,height:e.hole_height,fill:n.drill,realToCanvasMat:i,rotation:e.hole_ccw_rotation});return}if(e.shape==="hole_with_polygon_pad"){const g=e.pad_outline;if(g&&g.length>=3){const B=g.map(Q=>({x:e.x+Q.x,y:e.y+Q.y})),C=a>0?LT(B,-a):B;C.length>=3&&Hk({ctx:A,points:C,fill:r,realToCanvasMat:i})}const c=e.x+(e.hole_offset_x??0),I=e.y+(e.hole_offset_y??0),l=e.hole_shape;l==="circle"?(uS(A,()=>{tQ({ctx:A,center:{x:c,y:I},radius:(e.hole_diameter??0)/2,fill:"#000",realToCanvasMat:i})}),tQ({ctx:A,center:{x:c,y:I},radius:(e.hole_diameter??0)/2,fill:n.drill,realToCanvasMat:i})):l==="oval"?(uS(A,()=>{ES({ctx:A,center:{x:c,y:I},radius_x:(e.hole_width??0)/2,radius_y:(e.hole_height??0)/2,fill:"#000",realToCanvasMat:i})}),ES({ctx:A,center:{x:c,y:I},radius_x:(e.hole_width??0)/2,radius_y:(e.hole_height??0)/2,fill:n.drill,realToCanvasMat:i})):l==="pill"?(uS(A,()=>{eh({ctx:A,center:{x:c,y:I},width:e.hole_width??0,height:e.hole_height??0,fill:"#000",realToCanvasMat:i})}),eh({ctx:A,center:{x:c,y:I},width:e.hole_width??0,height:e.hole_height??0,fill:n.drill,realToCanvasMat:i})):l==="rotated_pill"&&(uS(A,()=>{eh({ctx:A,center:{x:c,y:I},width:e.hole_width??0,height:e.hole_height??0,fill:"#000",realToCanvasMat:i})}),eh({ctx:A,center:{x:c,y:I},width:e.hole_width??0,height:e.hole_height??0,fill:n.drill,realToCanvasMat:i}));return}}function uS(t,A){t.save(),t.globalCompositeOperation="destination-out",A(),t.restore()}function A7t(t,A){return t==="bottom"?A.silkscreen.bottom:A.silkscreen.top}function e7t(t){const{ctx:A,circle:e,realToCanvasMat:i,colorMap:n}=t,o=A7t(e.layer,n);tQ({ctx:A,center:e.center,radius:e.radius,stroke:o,strokeWidth:e.stroke_width,realToCanvasMat:i})}function t7t(t,A){return t==="bottom"?A.silkscreen.bottom:A.silkscreen.top}function i7t(t){const{ctx:A,line:e,realToCanvasMat:i,colorMap:n}=t,o=t7t(e.layer,n);E2({ctx:A,start:{x:e.x1,y:e.y1},end:{x:e.x2,y:e.y2},strokeWidth:e.stroke_width??.1,stroke:o,realToCanvasMat:i})}function n7t(t,A){return t==="bottom"?A.silkscreen.bottom:A.silkscreen.top}function o7t(t){const{ctx:A,oval:e,realToCanvasMat:i,colorMap:n}=t,o=n7t(e.layer,n);ES({ctx:A,center:e.center,radius_x:e.radius_x,radius_y:e.radius_y,stroke:o,strokeWidth:.1,realToCanvasMat:i,rotation:e.ccw_rotation??0})}function s7t(t,A){return t==="bottom"?A.silkscreen.bottom:A.silkscreen.top}function r7t(t){const{ctx:A,path:e,realToCanvasMat:i,colorMap:n}=t,o=s7t(e.layer,n);if(!(!e.route||e.route.length<2))for(let s=0;s<e.route.length-1;s++){const r=e.route[s],a=e.route[s+1];!r||!a||E2({ctx:A,start:{x:r.x,y:r.y},end:{x:a.x,y:a.y},strokeWidth:e.stroke_width??.1,stroke:o,realToCanvasMat:i})}}function a7t(t,A){return t==="bottom"?A.silkscreen.bottom:A.silkscreen.top}function g7t(t){const{ctx:A,pill:e,realToCanvasMat:i,colorMap:n}=t,o=a7t(e.layer,n);eh({ctx:A,center:e.center,width:e.width,height:e.height,stroke:o,strokeWidth:.2,realToCanvasMat:i})}function c7t(t,A){return t==="bottom"?A.silkscreen.bottom:A.silkscreen.top}function I7t(t){const{ctx:A,rect:e,realToCanvasMat:i,colorMap:n}=t,o=c7t(e.layer,n);eQ({ctx:A,center:e.center,width:e.width,height:e.height,fill:e.is_filled?o:"transparent",stroke:o,strokeWidth:e.stroke_width,realToCanvasMat:i})}function l7t(t,A){return t==="bottom"?A.silkscreen.bottom:A.silkscreen.top}function B7t(t){return t||"center"}function C7t(t){const{ctx:A,text:e,realToCanvasMat:i,colorMap:n}=t,o=e.text??"";if(!o)return;const s=l7t(e.layer,n),r=B7t(e.anchor_alignment),a=e.font_size??1;gz({ctx:A,text:o,x:e.anchor_position.x,y:e.anchor_position.y,fontSize:a,color:s,realToCanvasMat:i,anchorAlignment:r,rotation:e.ccw_rotation??0,mirrorX:e.layer==="bottom",knockout:e.is_knockout,knockoutPadding:e.is_knockout?e.knockout_padding:void 0})}function Q7t(t,A){return A.copper[t]??A.copper.top}function FQe(t){return t.shape==="rect"||t.shape==="rotated_rect"?t.corner_radius??t.rect_border_radius??0:0}function h7t(t){const{ctx:A,pad:e,realToCanvasMat:i,colorMap:n}=t,o=Q7t(e.layer,n);if(e.shape==="rect"){eQ({ctx:A,center:{x:e.x,y:e.y},width:e.width,height:e.height,fill:o,realToCanvasMat:i,borderRadius:FQe(e)});return}if(e.shape==="rotated_rect"){eQ({ctx:A,center:{x:e.x,y:e.y},width:e.width,height:e.height,fill:o,realToCanvasMat:i,borderRadius:FQe(e),ccwRotationDegrees:e.ccw_rotation??0});return}if(e.shape==="circle"){tQ({ctx:A,center:{x:e.x,y:e.y},radius:e.radius,fill:o,realToCanvasMat:i});return}if(e.shape==="pill"){eh({ctx:A,center:{x:e.x,y:e.y},width:e.width,height:e.height,fill:o,realToCanvasMat:i});return}if(e.shape==="rotated_pill"){eh({ctx:A,center:{x:e.x,y:e.y},width:e.width,height:e.height,fill:o,realToCanvasMat:i,rotation:e.ccw_rotation??0});return}if(e.shape==="polygon"){e.points&&e.points.length>=3&&Hk({ctx:A,points:e.points,fill:o,realToCanvasMat:i});return}}function Yk(t){const{ctx:A,points:e}=t;if(e.length<3)return;const i=e[0];if(i){A.moveTo(i.x,i.y);for(let n=1;n<e.length;n++){const o=e[n];o&&A.lineTo(o.x,o.y)}A.closePath()}}function MQe(t){const{ctx:A,board:e,realToCanvasMat:i,soldermaskColor:n}=t,{width:o,height:s,center:r,outline:a}=e;if(a&&Array.isArray(a)&&a.length>=3){const g=a.map(c=>{const[I,l]=ai(i,[c.x,c.y]);return{x:I,y:l}});A.beginPath(),Yk({ctx:A,points:g}),A.fillStyle=n,A.fill()}else if(o!==void 0&&s!==void 0&&r){const[g,c]=ai(i,[r.x,r.y]),I=o*Math.abs(i.a),l=s*Math.abs(i.a);A.fillStyle=n,A.fillRect(g-I/2,c-l/2,I,l)}}function E7t(t){return"createPattern"in t&&typeof Reflect.get(t,"createPattern")=="function"}function u7t(t,A){if(t===A||A.canvas.width<=0||A.canvas.height<=0||!E7t(t))return;let e=null;try{e=t.createPattern(A.canvas,"no-repeat")}catch{return}e&&(t.save(),t.globalCompositeOperation="source-over",t.fillStyle=e,t.fillRect(0,0,A.canvas.width,A.canvas.height),t.restore())}function d7t(t){return typeof t=="function"}function p7t(t,A,e){if(A<=0||e<=0)return null;const i=globalThis;let n=null;if("OffscreenCanvas"in i&&typeof i.OffscreenCanvas=="function")n=new i.OffscreenCanvas(A,e);else if("document"in i&&i.document&&typeof i.document.createElement=="function"){const o=i.document.createElement("canvas");o.width=A,o.height=e,n=o}else{const o=t.canvas.constructor;if(d7t(o))try{n=new o(A,e)}catch{return null}}return n?n.getContext("2d"):null}function f7t(t){const{ctx:A,panel:e,realToCanvasMat:i,soldermaskColor:n}=t,{width:o,height:s,center:r}=e;if(o===void 0||s===void 0||!r)return;const[a,g]=ai(i,[r.x,r.y]),c=o*Math.abs(i.a),I=s*Math.abs(i.a);A.fillStyle=n,A.fillRect(a-c/2,g-I/2,c,I)}function ry(t){const{ctx:A,cx:e,cy:i,width:n,height:o,radius:s,ccwRotationDegrees:r=0}=t,a=r*Math.PI/180,g=VyA(Uk(e,i),mQe(-a)),c=n/2,I=o/2,l=Math.min(s,c,I);if(l>0){const B=ai(g,{x:-c,y:-I}),C=ai(g,{x:c,y:-I}),Q=ai(g,{x:c,y:I}),h=ai(g,{x:-c,y:I}),E=ai(g,{x:-c,y:0});A.moveTo(E.x,E.y),A.arcTo(B.x,B.y,C.x,C.y,l),A.arcTo(C.x,C.y,Q.x,Q.y,l),A.arcTo(Q.x,Q.y,h.x,h.y,l),A.arcTo(h.x,h.y,B.x,B.y,l)}else{const B=ai(g,{x:-c,y:-I}),C=ai(g,{x:c,y:-I}),Q=ai(g,{x:c,y:I}),h=ai(g,{x:-c,y:I});A.moveTo(B.x,B.y),A.lineTo(C.x,C.y),A.lineTo(Q.x,Q.y),A.lineTo(h.x,h.y)}A.closePath()}function ay(t){t.save(),t.globalCompositeOperation="destination-out",t.fill(),t.restore()}function y7t(t){const{ctx:A,cutout:e,realToCanvasMat:i}=t;if(e.shape==="rect"){const[n,o]=ai(i,[e.center?.x??0,e.center?.y??0]),s=e.width*Math.abs(i.a),r=e.height*Math.abs(i.a),a=(e.corner_radius??0)*Math.abs(i.a);A.save(),A.translate(n,o),e.rotation&&A.rotate(-e.rotation*Math.PI/180),A.beginPath(),ry({ctx:A,cx:0,cy:0,width:s,height:r,radius:a}),A.restore(),ay(A)}else if(e.shape==="circle"){const[n,o]=ai(i,[e.center?.x??0,e.center?.y??0]),s=e.radius*Math.abs(i.a);A.beginPath(),A.arc(n,o,s,0,Math.PI*2),A.closePath(),ay(A)}else if(e.shape==="polygon"&&e.points&&e.points.length>=3){const n=e.points.map(o=>{const[s,r]=ai(i,[o.x,o.y]);return{x:s,y:r}});A.beginPath(),Yk({ctx:A,points:n}),ay(A)}}var Xh="rgba(255, 255, 255, 1)";function $yA(t){const{ctx:A,elements:e,layer:i,realToCanvasMat:n}=t;A.save(),A.globalCompositeOperation="destination-out";for(const o of e){if(o.type==="pcb_smtpad"){if(o.layer!==i||o.is_covered_with_solder_mask===!0)continue;m7t({ctx:A,pad:o,realToCanvasMat:n});continue}if(o.type==="pcb_plated_hole"){if(o.layers&&!o.layers.includes(i)||o.is_covered_with_solder_mask===!0)continue;w7t({ctx:A,hole:o,realToCanvasMat:n});continue}if(o.type==="pcb_via"){if(o.layers&&!o.layers.includes(i))continue;tQ({ctx:A,center:{x:o.x,y:o.y},radius:o.outer_diameter/2,fill:Xh,realToCanvasMat:n});continue}if(o.type==="pcb_hole"){if(o.is_covered_with_solder_mask===!0)continue;D7t({ctx:A,hole:o,realToCanvasMat:n})}}A.restore()}function m7t(t){const{ctx:A,pad:e,realToCanvasMat:i}=t;if(e.shape==="rect"){eQ({ctx:A,center:{x:e.x,y:e.y},width:e.width,height:e.height,borderRadius:e.corner_radius??e.rect_border_radius??0,fill:Xh,realToCanvasMat:i});return}if(e.shape==="rotated_rect"){eQ({ctx:A,center:{x:e.x,y:e.y},width:e.width,height:e.height,borderRadius:e.corner_radius??e.rect_border_radius??0,ccwRotationDegrees:e.ccw_rotation??0,fill:Xh,realToCanvasMat:i});return}if(e.shape==="circle"){tQ({ctx:A,center:{x:e.x,y:e.y},radius:e.radius,fill:Xh,realToCanvasMat:i});return}if(e.shape==="pill"||e.shape==="rotated_pill"){eh({ctx:A,center:{x:e.x,y:e.y},width:e.width,height:e.height,rotation:e.shape==="rotated_pill"?e.ccw_rotation??0:0,fill:Xh,realToCanvasMat:i});return}e.shape==="polygon"&&e.points&&e.points.length>=3&&Hk({ctx:A,points:e.points,fill:Xh,realToCanvasMat:i})}function w7t(t){const{ctx:A,hole:e,realToCanvasMat:i}=t;if(e.shape==="circle"){tQ({ctx:A,center:{x:e.x,y:e.y},radius:e.outer_diameter/2,fill:Xh,realToCanvasMat:i});return}if(e.shape==="oval"){ES({ctx:A,center:{x:e.x,y:e.y},radius_x:e.outer_width/2,radius_y:e.outer_height/2,rotation:e.ccw_rotation,fill:Xh,realToCanvasMat:i});return}if(e.shape==="pill"){eh({ctx:A,center:{x:e.x,y:e.y},width:e.outer_width,height:e.outer_height,rotation:e.ccw_rotation,fill:Xh,realToCanvasMat:i});return}if(e.shape==="circular_hole_with_rect_pad"){eQ({ctx:A,center:{x:e.x,y:e.y},width:e.rect_pad_width,height:e.rect_pad_height,borderRadius:e.rect_border_radius??0,ccwRotationDegrees:e.rect_ccw_rotation,fill:Xh,realToCanvasMat:i});return}if(e.shape==="pill_hole_with_rect_pad"){eQ({ctx:A,center:{x:e.x,y:e.y},width:e.rect_pad_width,height:e.rect_pad_height,borderRadius:e.rect_border_radius??0,fill:Xh,realToCanvasMat:i});return}if(e.shape==="rotated_pill_hole_with_rect_pad"){eQ({ctx:A,center:{x:e.x,y:e.y},width:e.rect_pad_width,height:e.rect_pad_height,borderRadius:e.rect_border_radius??0,ccwRotationDegrees:e.rect_ccw_rotation,fill:Xh,realToCanvasMat:i});return}e.shape==="hole_with_polygon_pad"&&e.pad_outline&&e.pad_outline.length>=3&&Hk({ctx:A,points:e.pad_outline.map(n=>({x:e.x+n.x,y:e.y+n.y})),fill:Xh,realToCanvasMat:i})}function D7t(t){const{ctx:A,hole:e,realToCanvasMat:i}=t,n="ccw_rotation"in e&&typeof e.ccw_rotation=="number"?e.ccw_rotation:0;if(e.hole_shape==="circle"){tQ({ctx:A,center:{x:e.x,y:e.y},radius:e.hole_diameter/2,fill:Xh,realToCanvasMat:i});return}if(e.hole_shape==="square"){eQ({ctx:A,center:{x:e.x,y:e.y},width:e.hole_diameter,height:e.hole_diameter,ccwRotationDegrees:n,fill:Xh,realToCanvasMat:i});return}if(e.hole_shape==="oval"){ES({ctx:A,center:{x:e.x,y:e.y},radius_x:e.hole_width/2,radius_y:e.hole_height/2,rotation:n,fill:Xh,realToCanvasMat:i});return}if(e.hole_shape==="rect"){eQ({ctx:A,center:{x:e.x,y:e.y},width:e.hole_width,height:e.hole_height,ccwRotationDegrees:n,fill:Xh,realToCanvasMat:i});return}(e.hole_shape==="pill"||e.hole_shape==="rotated_pill")&&eh({ctx:A,center:{x:e.x,y:e.y},width:e.hole_width,height:e.hole_height,rotation:n,fill:Xh,realToCanvasMat:i})}function S7t(t,A,e,i,n){if(Math.abs(n)<1e-10)return null;const o=e-t,s=i-A,r=Math.hypot(o,s);if(r<1e-10)return null;const a=Math.abs(n)*(r/2),g=r/2,c=(a*a+g*g)/(2*a),I=c-a,l=(t+e)/2,B=(A+i)/2,C=-s/r,Q=o/r,h=n>0?-1:1;return{centerX:l+h*C*I,centerY:B+h*Q*I,radius:c}}function AmA(t,A,e,i,n,o,s){if(Math.abs(o)<1e-10){const[f,m]=ai(s,[i,n]);t.lineTo(f,m);return}const r=S7t(A,e,i,n,o);if(!r){const[f,m]=ai(s,[i,n]);t.lineTo(f,m);return}const[a,g]=ai(s,[A,e]),[c,I]=ai(s,[i,n]),[l,B]=ai(s,[r.centerX,r.centerY]),C=Math.hypot(a-l,g-B),Q=Math.atan2(g-B,a-l),h=Math.atan2(I-B,c-l),u=s.a*s.d-s.b*s.c<0,d=o>0?!u:u;t.arc(l,B,C,Q,h,d)}function RQe(t,A,e){if(A.vertices.length<2)return;if(A.vertices.length===2){const s=A.vertices[0],r=A.vertices[1];if(s&&r&&Math.abs((s.bulge??0)-1)<1e-10&&Math.abs((r.bulge??0)-1)<1e-10){const[a,g]=ai(e,[s.x,s.y]);t.moveTo(a,g),AmA(t,s.x,s.y,r.x,r.y,1,e),AmA(t,r.x,r.y,s.x,s.y,1,e);return}}const i=A.vertices[0];if(!i)return;const[n,o]=ai(e,[i.x,i.y]);t.moveTo(n,o);for(let s=0;s<A.vertices.length;s++){const r=A.vertices[s],a=A.vertices[(s+1)%A.vertices.length];if(!r||!a)continue;const g=r.bulge??0;if(Math.abs(g)<1e-10){const[c,I]=ai(e,[a.x,a.y]);t.lineTo(c,I)}else AmA(t,r.x,r.y,a.x,a.y,g,e)}}function b7t(t){const{ctx:A,pour:e,realToCanvasMat:i,soldermaskOverCopperColor:n,layer:o,elements:s}=t;if(e.layer===o&&e.covered_with_solder_mask===!0){if(A.save(),A.fillStyle=n,e.shape==="rect"){const[r,a]=ai(i,[e.center.x,e.center.y]),g=e.width*Math.abs(i.a),c=e.height*Math.abs(i.a);A.translate(r,a),e.rotation&&A.rotate(-e.rotation*(Math.PI/180)),A.beginPath(),A.rect(-g/2,-c/2,g,c),A.fill(),A.restore(),$yA({ctx:A,elements:s,layer:o,realToCanvasMat:i});return}if(e.shape==="polygon"){if(e.points&&e.points.length>=3){const r=e.points.map(g=>ai(i,[g.x,g.y])),a=r[0];if(a){A.beginPath();const[g,c]=a;A.moveTo(g,c);for(let I=1;I<r.length;I++){const l=r[I];if(!l)continue;const[B,C]=l;A.lineTo(B,C)}A.closePath(),A.fill(),$yA({ctx:A,elements:s,layer:o,realToCanvasMat:i})}}A.restore();return}if(e.shape==="brep"){if(A.beginPath(),RQe(A,e.brep_shape.outer_ring,i),e.brep_shape.inner_rings)for(const r of e.brep_shape.inner_rings)RQe(A,r,i);A.fill("evenodd"),$yA({ctx:A,elements:s,layer:o,realToCanvasMat:i}),A.restore();return}A.restore()}}function ix(t){const{ctx:A,cx:e,cy:i,width:n,height:o,ccwRotationDegrees:s=0}=t,r=s*Math.PI/180,a=VyA(Uk(e,i),mQe(-r));if(n>o){const g=o/2,c=(n-o)/2,I=ai(a,{x:-c,y:0}),l=ai(a,{x:c,y:0}),B=ai(a,{x:c,y:-g});A.moveTo(B.x,B.y),A.arc(l.x,l.y,g,-r-Math.PI/2,-r+Math.PI/2),A.arc(I.x,I.y,g,-r+Math.PI/2,-r-Math.PI/2)}else if(o>n){const g=n/2,c=(o-n)/2,I=ai(a,{x:0,y:-c}),l=ai(a,{x:0,y:c}),B=ai(a,{x:g,y:c});A.moveTo(B.x,B.y),A.arc(l.x,l.y,g,-r,-r+Math.PI),A.arc(I.x,I.y,g,-r+Math.PI,-r)}else{const g=n/2;A.moveTo(e+g,i),A.arc(e,i,g,0,Math.PI*2)}A.closePath()}function x7t(t){const{ctx:A,hole:e,realToCanvasMat:i,soldermaskOverCopperColor:n}=t,o=e.is_covered_with_solder_mask===!0,s=e.soldermask_margin??0;o?(A.fillStyle=n,Iz({ctx:A,hole:e,realToCanvasMat:i,margin:0}),A.fill()):s<0?(Iz({ctx:A,hole:e,realToCanvasMat:i,margin:s}),ay(A),_7t({ctx:A,hole:e,realToCanvasMat:i,soldermaskOverCopperColor:n,margin:s})):s>0?(Iz({ctx:A,hole:e,realToCanvasMat:i,margin:s}),ay(A)):(Iz({ctx:A,hole:e,realToCanvasMat:i,margin:0}),ay(A))}function NQe(t){return"ccw_rotation"in t&&typeof t.ccw_rotation=="number"?t.ccw_rotation:0}function Iz(t){const{ctx:A,hole:e,realToCanvasMat:i,margin:n}=t,o=NQe(e);if(e.hole_shape==="circle"){const[s,r]=ai(i,[e.x,e.y]),a=(e.hole_diameter/2+n)*Math.abs(i.a);A.beginPath(),A.arc(s,r,a,0,Math.PI*2),A.closePath()}else if(e.hole_shape==="square"){const[s,r]=ai(i,[e.x,e.y]),a=(e.hole_diameter+n*2)*Math.abs(i.a);A.save(),A.translate(s,r),o!==0&&A.rotate(-o*Math.PI/180),A.beginPath(),A.rect(-a/2,-a/2,a,a),A.closePath(),A.restore()}else if(e.hole_shape==="oval"){const[s,r]=ai(i,[e.x,e.y]),a=(e.hole_width/2+n)*Math.abs(i.a),g=(e.hole_height/2+n)*Math.abs(i.a);A.save(),A.translate(s,r),o!==0&&A.rotate(-o*Math.PI/180),A.beginPath(),A.ellipse(0,0,a,g,0,0,Math.PI*2),A.closePath(),A.restore()}else if(e.hole_shape==="rect"){const[s,r]=ai(i,[e.x,e.y]),a=(e.hole_width+n*2)*Math.abs(i.a),g=(e.hole_height+n*2)*Math.abs(i.a);A.save(),A.translate(s,r),o!==0&&A.rotate(-o*Math.PI/180),A.beginPath(),A.rect(-a/2,-g/2,a,g),A.closePath(),A.restore()}else if(e.hole_shape==="pill"||e.hole_shape==="rotated_pill"){const[s,r]=ai(i,[e.x,e.y]),a=(e.hole_width+n*2)*Math.abs(i.a),g=(e.hole_height+n*2)*Math.abs(i.a);A.save(),A.translate(s,r),o!==0&&A.rotate(-o*Math.PI/180),A.beginPath(),ix({ctx:A,cx:0,cy:0,width:a,height:g}),A.restore()}}function _7t(t){const{ctx:A,hole:e,realToCanvasMat:i,soldermaskOverCopperColor:n,margin:o}=t,s=Math.abs(o),r=NQe(e);if(A.fillStyle=n,e.hole_shape==="circle"){const[a,g]=ai(i,[e.x,e.y]),c=e.hole_diameter/2*Math.abs(i.a),I=s*Math.abs(i.a),l=Math.max(0,c-I);A.save(),A.beginPath(),A.arc(a,g,c,0,Math.PI*2),l>0&&A.arc(a,g,l,0,Math.PI*2,!0),A.fill("evenodd"),A.restore()}else if(e.hole_shape==="square"){const[a,g]=ai(i,[e.x,e.y]),c=e.hole_diameter*Math.abs(i.a),I=s*Math.abs(i.a),l=Math.max(0,c-I*2);A.save(),A.translate(a,g),r!==0&&A.rotate(-r*Math.PI/180),A.beginPath(),A.rect(-c/2,-c/2,c,c),l>0&&A.rect(-l/2,-l/2,l,l),A.fill("evenodd"),A.restore()}else if(e.hole_shape==="oval"){const[a,g]=ai(i,[e.x,e.y]),c=e.hole_width/2*Math.abs(i.a),I=e.hole_height/2*Math.abs(i.a),l=s*Math.abs(i.a),B=Math.max(0,c-l),C=Math.max(0,I-l);A.save(),A.translate(a,g),r!==0&&A.rotate(-r*Math.PI/180),A.beginPath(),A.ellipse(0,0,c,I,0,0,Math.PI*2),B>0&&C>0&&(A.moveTo(B,0),A.ellipse(0,0,B,C,0,0,Math.PI*2)),A.fill("evenodd"),A.restore()}else if(e.hole_shape==="rect"){const[a,g]=ai(i,[e.x,e.y]),c=e.hole_width*Math.abs(i.a),I=e.hole_height*Math.abs(i.a),l=s*Math.abs(i.a),B=Math.max(0,c-l*2),C=Math.max(0,I-l*2);A.save(),A.translate(a,g),r!==0&&A.rotate(-r*Math.PI/180),A.beginPath(),A.rect(-c/2,-I/2,c,I),B>0&&C>0&&A.rect(-B/2,-C/2,B,C),A.fill("evenodd"),A.restore()}else if(e.hole_shape==="pill"||e.hole_shape==="rotated_pill"){const[a,g]=ai(i,[e.x,e.y]),c=e.hole_width*Math.abs(i.a),I=e.hole_height*Math.abs(i.a),l=s*Math.abs(i.a);A.save(),A.translate(a,g),r!==0&&A.rotate(-r*Math.PI/180),A.beginPath(),ix({ctx:A,cx:0,cy:0,width:c,height:I});const B=c-l*2,C=I-l*2;B>0&&C>0&&ix({ctx:A,cx:0,cy:0,width:B,height:C}),A.fill("evenodd"),A.restore()}}function k7t(t){const{ctx:A,hole:e,realToCanvasMat:i,soldermaskOverCopperColor:n,layer:o}=t;if(e.layers&&!e.layers.includes(o))return;const s=e.is_covered_with_solder_mask===!0,r=e.soldermask_margin??0;s?(A.fillStyle=n,lz({ctx:A,hole:e,realToCanvasMat:i,margin:0}),A.fill()):r<0?(lz({ctx:A,hole:e,realToCanvasMat:i,margin:r}),ay(A),v7t({ctx:A,hole:e,realToCanvasMat:i,soldermaskOverCopperColor:n,margin:r})):r>0?(lz({ctx:A,hole:e,realToCanvasMat:i,margin:r}),ay(A)):(lz({ctx:A,hole:e,realToCanvasMat:i,margin:0}),ay(A))}function lz(t){const{ctx:A,hole:e,realToCanvasMat:i,margin:n}=t;if(e.shape==="circle"){const[o,s]=ai(i,[e.x,e.y]),r=(e.outer_diameter/2+n)*Math.abs(i.a);A.beginPath(),A.arc(o,s,r,0,Math.PI*2),A.closePath()}else if(e.shape==="oval"){const[o,s]=ai(i,[e.x,e.y]),r=(e.outer_width/2+n)*Math.abs(i.a),a=(e.outer_height/2+n)*Math.abs(i.a);A.beginPath(),A.ellipse(o,s,r,a,-((e.ccw_rotation??0)*Math.PI)/180,0,Math.PI*2),A.closePath()}else if(e.shape==="pill"){const[o,s]=ai(i,[e.x,e.y]),r=(e.outer_width+n*2)*Math.abs(i.a),a=(e.outer_height+n*2)*Math.abs(i.a);A.beginPath(),ix({ctx:A,cx:o,cy:s,width:r,height:a,ccwRotationDegrees:e.ccw_rotation})}else if(e.shape==="circular_hole_with_rect_pad"){const[o,s]=ai(i,[e.x,e.y]),r=(e.rect_pad_width+n*2)*Math.abs(i.a),a=(e.rect_pad_height+n*2)*Math.abs(i.a),g=(e.rect_border_radius??0)*Math.abs(i.a);A.beginPath(),ry({ctx:A,cx:o,cy:s,width:r,height:a,radius:g,ccwRotationDegrees:e.rect_ccw_rotation})}else if(e.shape==="pill_hole_with_rect_pad"){const[o,s]=ai(i,[e.x,e.y]),r=(e.rect_pad_width+n*2)*Math.abs(i.a),a=(e.rect_pad_height+n*2)*Math.abs(i.a),g=(e.rect_border_radius??0)*Math.abs(i.a);A.beginPath(),ry({ctx:A,cx:o,cy:s,width:r,height:a,radius:g})}else if(e.shape==="rotated_pill_hole_with_rect_pad"){const[o,s]=ai(i,[e.x,e.y]),r=(e.rect_pad_width+n*2)*Math.abs(i.a),a=(e.rect_pad_height+n*2)*Math.abs(i.a),g=(e.rect_border_radius??0)*Math.abs(i.a);A.beginPath(),ry({ctx:A,cx:o,cy:s,width:r,height:a,radius:g,ccwRotationDegrees:e.rect_ccw_rotation})}else if(e.shape==="hole_with_polygon_pad"&&e.pad_outline&&e.pad_outline.length>=3){const o=e.pad_outline.map(a=>({x:e.x+a.x,y:e.y+a.y})),r=(n!==0?LT(o,n):o).map(a=>{const[g,c]=ai(i,[a.x,a.y]);return{x:g,y:c}});A.beginPath(),Yk({ctx:A,points:r})}}function v7t(t){const{ctx:A,hole:e,realToCanvasMat:i,soldermaskOverCopperColor:n,margin:o}=t,s=Math.abs(o);if(A.fillStyle=n,e.shape==="circle"){const[r,a]=ai(i,[e.x,e.y]),g=e.outer_diameter/2*Math.abs(i.a),c=s*Math.abs(i.a),I=Math.max(0,g-c);A.beginPath(),A.arc(r,a,g,0,Math.PI*2),I>0&&A.arc(r,a,I,0,Math.PI*2,!0),A.fill("evenodd")}else if(e.shape==="oval"){const[r,a]=ai(i,[e.x,e.y]),g=e.outer_width/2*Math.abs(i.a),c=e.outer_height/2*Math.abs(i.a),I=s*Math.abs(i.a),l=Math.max(0,g-I),B=Math.max(0,c-I),C=-((e.ccw_rotation??0)*Math.PI)/180;if(A.beginPath(),A.ellipse(r,a,g,c,C,0,Math.PI*2),l>0&&B>0){const Q=r+l*Math.cos(C),h=a+l*Math.sin(C);A.moveTo(Q,h),A.ellipse(r,a,l,B,C,0,Math.PI*2)}A.fill("evenodd")}else if(e.shape==="pill"){const[r,a]=ai(i,[e.x,e.y]),g=e.outer_width*Math.abs(i.a),c=e.outer_height*Math.abs(i.a),I=s*Math.abs(i.a);A.beginPath(),ix({ctx:A,cx:r,cy:a,width:g,height:c,ccwRotationDegrees:e.ccw_rotation});const l=g-I*2,B=c-I*2;l>0&&B>0&&ix({ctx:A,cx:r,cy:a,width:l,height:B,ccwRotationDegrees:e.ccw_rotation}),A.fill("evenodd")}else if(e.shape==="circular_hole_with_rect_pad"){const[r,a]=ai(i,[e.x,e.y]),g=e.rect_pad_width*Math.abs(i.a),c=e.rect_pad_height*Math.abs(i.a),I=s*Math.abs(i.a),l=e.rect_border_radius?e.rect_border_radius*Math.abs(i.a):0;A.beginPath(),ry({ctx:A,cx:r,cy:a,width:g,height:c,radius:l,ccwRotationDegrees:e.rect_ccw_rotation});const B=g-I*2,C=c-I*2;if(B>0&&C>0){const Q=Math.max(0,l-I);ry({ctx:A,cx:r,cy:a,width:B,height:C,radius:Q,ccwRotationDegrees:e.rect_ccw_rotation})}A.fill("evenodd")}else if(e.shape==="pill_hole_with_rect_pad"){const[r,a]=ai(i,[e.x,e.y]),g=e.rect_pad_width*Math.abs(i.a),c=e.rect_pad_height*Math.abs(i.a),I=s*Math.abs(i.a),l=e.rect_border_radius?e.rect_border_radius*Math.abs(i.a):0;A.beginPath(),ry({ctx:A,cx:r,cy:a,width:g,height:c,radius:l});const B=g-I*2,C=c-I*2;if(B>0&&C>0){const Q=Math.max(0,l-I);ry({ctx:A,cx:r,cy:a,width:B,height:C,radius:Q})}A.fill("evenodd")}else if(e.shape==="rotated_pill_hole_with_rect_pad"){const[r,a]=ai(i,[e.x,e.y]),g=e.rect_pad_width*Math.abs(i.a),c=e.rect_pad_height*Math.abs(i.a),I=s*Math.abs(i.a),l=e.rect_border_radius?e.rect_border_radius*Math.abs(i.a):0;A.beginPath(),ry({ctx:A,cx:r,cy:a,width:g,height:c,radius:l,ccwRotationDegrees:e.rect_ccw_rotation});const B=g-I*2,C=c-I*2;if(B>0&&C>0){const Q=Math.max(0,l-I);ry({ctx:A,cx:r,cy:a,width:B,height:C,radius:Q,ccwRotationDegrees:e.rect_ccw_rotation})}A.fill("evenodd")}else if(e.shape==="hole_with_polygon_pad"&&e.pad_outline&&e.pad_outline.length>=3){const r=e.pad_outline.map(c=>({x:e.x+c.x,y:e.y+c.y}));A.beginPath();const a=r.map(c=>{const[I,l]=ai(i,[c.x,c.y]);return{x:I,y:l}});Yk({ctx:A,points:a});const g=LT(r,-s);if(g.length>=3){const c=g.map(I=>{const[l,B]=ai(i,[I.x,I.y]);return{x:l,y:B}});Yk({ctx:A,points:c})}A.fill("evenodd")}}function F7t(t){const{ctx:A,pad:e,realToCanvasMat:i,soldermaskOverCopperColor:n,layer:o}=t;if(e.layer!==o)return;const s=e.is_covered_with_solder_mask===!0,r=e.soldermask_margin??0;let a=r,g=r,c=r,I=r;(e.shape==="rect"||e.shape==="rotated_rect")&&(a=e.soldermask_margin_left??r,g=e.soldermask_margin_right??r,c=e.soldermask_margin_top??r,I=e.soldermask_margin_bottom??r),s?(A.fillStyle=n,Bz({ctx:A,pad:e,realToCanvasMat:i,ml:0,mr:0,mt:0,mb:0}),A.fill()):a<0||g<0||c<0||I<0?(Bz({ctx:A,pad:e,realToCanvasMat:i,ml:a,mr:g,mt:c,mb:I}),ay(A),M7t({ctx:A,pad:e,realToCanvasMat:i,soldermaskOverCopperColor:n,ml:a,mr:g,mt:c,mb:I})):a>0||g>0||c>0||I>0?(Bz({ctx:A,pad:e,realToCanvasMat:i,ml:a,mr:g,mt:c,mb:I}),ay(A)):(Bz({ctx:A,pad:e,realToCanvasMat:i,ml:0,mr:0,mt:0,mb:0}),ay(A))}function Bz(t){const{ctx:A,pad:e,realToCanvasMat:i,ml:n,mr:o,mt:s,mb:r}=t,a=e.shape==="rotated_rect"||e.shape==="rotated_pill"?e.ccw_rotation??0:0;if(e.shape==="rect"||e.shape==="rotated_rect"){const g=e.corner_radius??e.rect_border_radius??0,c=a*Math.PI/180,I=(o-n)/2,l=(s-r)/2,B=I*Math.cos(c)-l*Math.sin(c),C=I*Math.sin(c)+l*Math.cos(c),[Q,h]=ai(i,[e.x+B,e.y+C]),E=(e.width+n+o)*Math.abs(i.a),u=(e.height+s+r)*Math.abs(i.a),d=g*Math.abs(i.a);A.save(),A.translate(Q,h),a!==0&&A.rotate(-a*Math.PI/180),A.beginPath(),ry({ctx:A,cx:0,cy:0,width:E,height:u,radius:d}),A.restore()}else if(e.shape==="circle"){const g=(n+o+s+r)/4,[c,I]=ai(i,[e.x,e.y]),l=(e.radius+g)*Math.abs(i.a);A.beginPath(),A.arc(c,I,l,0,Math.PI*2),A.closePath()}else if(e.shape==="pill"||e.shape==="rotated_pill"){const g=(n+o)/2,[c,I]=ai(i,[e.x,e.y]),l=(e.width+g*2)*Math.abs(i.a),B=(e.height+g*2)*Math.abs(i.a);A.save(),A.translate(c,I),a!==0&&A.rotate(-a*Math.PI/180),A.beginPath(),ix({ctx:A,cx:0,cy:0,width:l,height:B}),A.restore()}else if(e.shape==="polygon"&&e.points&&e.points.length>=3){const g=(n+o+s+r)/4,I=(g!==0?LT(e.points,g):e.points).map(l=>{const[B,C]=ai(i,[l.x,l.y]);return{x:B,y:C}});A.beginPath(),Yk({ctx:A,points:I})}}function M7t(t){const{ctx:A,pad:e,realToCanvasMat:i,soldermaskOverCopperColor:n,ml:o,mr:s,mt:r,mb:a}=t,g=e.shape==="rotated_rect"||e.shape==="rotated_pill"?e.ccw_rotation??0:0,c=Math.max(0,-o),I=Math.max(0,-s),l=Math.max(0,-r),B=Math.max(0,-a);if(A.fillStyle=n,e.shape==="rect"||e.shape==="rotated_rect"){const C=e.corner_radius??e.rect_border_radius??0,[Q,h]=ai(i,[e.x,e.y]),E=e.width*Math.abs(i.a),u=e.height*Math.abs(i.a),d=C*Math.abs(i.a),f=c*Math.abs(i.a),m=I*Math.abs(i.a),w=l*Math.abs(i.a),D=B*Math.abs(i.a);A.save(),A.translate(Q,h),g!==0&&A.rotate(-g*Math.PI/180),A.beginPath(),ry({ctx:A,cx:0,cy:0,width:E,height:u,radius:d});const S=E-f-m,_=u-w-D,b=(f-m)/2,N=(w-D)/2,F=Math.max(0,d-(f+m+w+D)/4);S>0&&_>0&&ry({ctx:A,cx:b,cy:N,width:S,height:_,radius:F}),A.fill("evenodd"),A.restore()}else if(e.shape==="circle"){const C=Math.max(c,I,l,B),[Q,h]=ai(i,[e.x,e.y]),E=e.radius*Math.abs(i.a),u=C*Math.abs(i.a),d=Math.max(0,E-u);A.save(),A.beginPath(),A.arc(Q,h,E,0,Math.PI*2),d>0&&A.arc(Q,h,d,0,Math.PI*2,!0),A.fill("evenodd"),A.restore()}else if(e.shape==="pill"||e.shape==="rotated_pill"){const C=Math.max(c,I,l,B),[Q,h]=ai(i,[e.x,e.y]),E=e.width*Math.abs(i.a),u=e.height*Math.abs(i.a),d=C*Math.abs(i.a);A.save(),A.translate(Q,h),g!==0&&A.rotate(-g*Math.PI/180),A.beginPath(),ix({ctx:A,cx:0,cy:0,width:E,height:u});const f=E-d*2,m=u-d*2;f>0&&m>0&&ix({ctx:A,cx:0,cy:0,width:f,height:m}),A.fill("evenodd"),A.restore()}else if(e.shape==="polygon"&&e.points&&e.points.length>=3){const C=Math.max(c,I,l,B);A.save(),A.beginPath();const Q=e.points.map(E=>{const[u,d]=ai(i,[E.x,E.y]);return{x:u,y:d}});Yk({ctx:A,points:Q});const h=LT(e.points,-C);if(h.length>=3){const E=h.map(u=>{const[d,f]=ai(i,[u.x,u.y]);return{x:d,y:f}});Yk({ctx:A,points:E})}A.fill("evenodd"),A.restore()}}function u2(t,A){const e=Math.hypot(t,A);return e<=Number.EPSILON?{x:0,y:0}:{x:t/e,y:A/e}}function R7t(t,A){const e=t.length;if(e<2)return{x:1,y:0};if(A<=0){const g=t[1],c=t[0];if(!g||!c)return{x:1,y:0};const I=u2(g.x-c.x,g.y-c.y);return I.x===0&&I.y===0?{x:1,y:0}:I}if(A>=e-1){const g=t[e-2],c=t[e-1];if(!g||!c)return{x:1,y:0};const I=u2(c.x-g.x,c.y-g.y);return I.x===0&&I.y===0?{x:1,y:0}:I}const i=t[A-1],n=t[A],o=t[A+1];if(!i||!n||!o)return{x:1,y:0};const s=u2(n.x-i.x,n.y-i.y),r=u2(o.x-n.x,o.y-n.y),a=u2(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 GQe(t){const A=[],e=[];for(let i=0;i<t.length;i++){const n=t[i];if(!n)continue;const o=R7t(t,i),s=u2(-o.y,o.x),r=n.width/2;A.push({x:n.x+s.x*r,y:n.y+s.y*r}),e.push({x:n.x-s.x*r,y:n.y-s.y*r})}return A.concat(e.reverse())}function emA(t){const A=[];let e=[],i=null;for(const n of t??[]){if(!n||n.route_type!=="wire"){e.length>=2&&A.push(e),e=[],i=null;continue}const o=n.layer??i;if(!o)continue;const s=n.x,r=n.y;typeof s!="number"||typeof r!="number"||typeof n.width=="number"&&(n.width,i&&o!==i&&(e.length>=2&&A.push(e),e=[]),i=o,e.push(n))}return e.length>=2&&A.push(e),A}var LQe=1e-6;function UQe(t){const{ctx:A,trace:e,realToCanvasMat:i,vias:n,platedHoles:o,layer:s}=t;if(!e.route||e.route.length<2)return;const r=emA(e.route);if(r.length===0)return;const a=new Map;for(const g of r){const c=g[0]?.layer,I=g[g.length-1];if(!(!c||!I)&&!(s&&c!==s)){for(const l of n){if(l.layers&&Array.isArray(l.layers)&&!l.layers.includes(c)||!HQe(I.x,I.y,l.x,l.y))continue;const B=l.hole_diameter/2;if(B<=0)continue;const C={shape:"circle",x:l.x,y:l.y,radius:B};a.set(YQe(C),C)}for(const l of o){if(l.layers&&Array.isArray(l.layers)&&!l.layers.includes(c))continue;const B=N7t(l);B&&HQe(I.x,I.y,B.x,B.y)&&a.set(YQe(B),B)}}}if(a.size!==0){A.save(),A.globalCompositeOperation="destination-out";for(const g of a.values()){if(g.shape==="circle"){tQ({ctx:A,center:{x:g.x,y:g.y},radius:g.radius,fill:"#000",realToCanvasMat:i});continue}if(g.shape==="oval"){ES({ctx:A,center:{x:g.x,y:g.y},radius_x:g.radiusX,radius_y:g.radiusY,fill:"#000",realToCanvasMat:i,rotation:g.rotation});continue}eh({ctx:A,center:{x:g.x,y:g.y},width:g.width,height:g.height,fill:"#000",realToCanvasMat:i,rotation:g.rotation})}A.restore()}}function N7t(t){if(t.shape==="circle"){const n=t.hole_diameter/2;return n<=0?void 0:{shape:"circle",x:t.x,y:t.y,radius:n}}if(t.shape==="oval"){const n=t.hole_width/2,o=t.hole_height/2;return n<=0||o<=0?void 0:{shape:"oval",x:t.x,y:t.y,radiusX:n,radiusY:o,rotation:t.ccw_rotation}}if(t.shape==="pill")return t.hole_width<=0||t.hole_height<=0?void 0:{shape:"pill",x:t.x,y:t.y,width:t.hole_width,height:t.hole_height,rotation:t.ccw_rotation};if(t.shape==="circular_hole_with_rect_pad"){const n=t.hole_diameter/2;return n<=0?void 0:{shape:"circle",x:t.x+(t.hole_offset_x??0),y:t.y+(t.hole_offset_y??0),radius:n}}if(t.shape==="pill_hole_with_rect_pad")return t.hole_width<=0||t.hole_height<=0?void 0:{shape:"pill",x:t.x+(t.hole_offset_x??0),y:t.y+(t.hole_offset_y??0),width:t.hole_width,height:t.hole_height};if(t.shape==="rotated_pill_hole_with_rect_pad")return t.hole_width<=0||t.hole_height<=0?void 0:{shape:"pill",x:t.x+(t.hole_offset_x??0),y:t.y+(t.hole_offset_y??0),width:t.hole_width,height:t.hole_height,rotation:t.hole_ccw_rotation};if(t.shape!=="hole_with_polygon_pad")return;const A=t.x+(t.hole_offset_x??0),e=t.y+(t.hole_offset_y??0),i=t.hole_shape;if(i==="circle"){const n=(t.hole_diameter??0)/2;return n<=0?void 0:{shape:"circle",x:A,y:e,radius:n}}if(i==="oval"){const n=(t.hole_width??0)/2,o=(t.hole_height??0)/2;return n<=0||o<=0?void 0:{shape:"oval",x:A,y:e,radiusX:n,radiusY:o}}if(i==="pill"||i==="rotated_pill"){const n=t.hole_width??0,o=t.hole_height??0;return n<=0||o<=0?void 0:{shape:"pill",x:A,y:e,width:n,height:o,rotation:i==="rotated_pill"?t.ccw_rotation:0}}}function HQe(t,A,e,i){return Math.abs(t-e)<=LQe&&Math.abs(A-i)<=LQe}function YQe(t){return t.shape==="circle"?`circle:${t.x}:${t.y}:${t.radius}`:t.shape==="oval"?`oval:${t.x}:${t.y}:${t.radiusX}:${t.radiusY}:${t.rotation??0}`:`pill:${t.x}:${t.y}:${t.width}:${t.height}:${t.rotation??0}`}function JQe(t){if(t.length<2)return!1;const A=t[0]?.width;return typeof A!="number"?!1:t.some(e=>Math.abs(e.width-A)>Number.EPSILON)}function G7t(t){const{ctx:A,trace:e,realToCanvasMat:i,soldermaskOverCopperColor:n,layer:o}=t;if(!e.route||!Array.isArray(e.route)||e.route.length<2)return;const s=emA(e.route);for(const r of s)if(r[0]?.layer===o){if(JQe(r)){const g=GQe(r);Hk({ctx:A,points:g,fill:n,realToCanvasMat:i});continue}for(let g=0;g<r.length-1;g++){const c=r[g],I=r[g+1];!c||!I||E2({ctx:A,start:{x:c.x,y:c.y},end:{x:I.x,y:I.y},strokeWidth:c.width,stroke:n,realToCanvasMat:i,lineCap:"round"})}}UQe({ctx:A,trace:e,realToCanvasMat:i,layer:o,vias:t.vias,platedHoles:t.platedHoles})}function L7t(t){const{ctx:A,via:e,realToCanvasMat:i}=t,[n,o]=ai(i,[e.x,e.y]),s=e.outer_diameter/2*Math.abs(i.a);A.beginPath(),A.arc(n,o,s,0,Math.PI*2),A.closePath(),ay(A)}function TQe(t){const{ctx:A,elements:e,realToCanvasMat:i,colorMap:n,layer:o,drawSoldermask:s}=t;if(!s||A.canvas.width<=0||A.canvas.height<=0)return;const r=e.filter(C=>C.type==="pcb_board"),a=e.find(C=>C.type==="pcb_panel");if(r.length===0&&!a)return;const g=n.soldermask[o]??n.soldermask.top,c=n.soldermaskOverCopper[o]??n.soldermaskOverCopper.top,I=e.filter(C=>C.type==="pcb_via"),l=e.filter(C=>C.type==="pcb_plated_hole"),B=p7t(A,A.canvas.width,A.canvas.height)??A;if(a&&f7t({ctx:B,panel:a,realToCanvasMat:i,soldermaskColor:g}),a&&r.length>0){B.save(),B.globalCompositeOperation="destination-out";for(const C of r)MQe({ctx:B,board:C,realToCanvasMat:i,soldermaskColor:"#000"});B.restore()}for(const C of r)MQe({ctx:B,board:C,realToCanvasMat:i,soldermaskColor:g});for(const C of e)C.type==="pcb_trace"?G7t({ctx:B,trace:C,realToCanvasMat:i,soldermaskOverCopperColor:c,layer:o,vias:I,platedHoles:l}):C.type==="pcb_copper_pour"&&b7t({ctx:B,pour:C,realToCanvasMat:i,soldermaskOverCopperColor:c,layer:o,elements:e});for(const C of e)U7t({ctx:B,element:C,realToCanvasMat:i,soldermaskOverCopperColor:c,layer:o});u7t(A,B)}function U7t(t){const{ctx:A,element:e,realToCanvasMat:i,soldermaskOverCopperColor:n,layer:o}=t;if(e.type==="pcb_smtpad")F7t({ctx:A,pad:e,realToCanvasMat:i,soldermaskOverCopperColor:n,layer:o});else if(e.type==="pcb_plated_hole")k7t({ctx:A,hole:e,realToCanvasMat:i,soldermaskOverCopperColor:n,layer:o});else if(e.type==="pcb_hole")x7t({ctx:A,hole:e,realToCanvasMat:i,soldermaskOverCopperColor:n});else if(e.type==="pcb_via")L7t({ctx:A,via:e,realToCanvasMat:i});else if(e.type==="pcb_cutout")y7t({ctx:A,cutout:e,realToCanvasMat:i});else{if(e.type==="pcb_copper_pour")return;if(e.type==="pcb_trace")return}}function H7t(t,A){return A.copper[t]??A.copper.top}function PQe(t){const{ctx:A,trace:e,realToCanvasMat:i,colorMap:n}=t;if(!e.route||!Array.isArray(e.route)||e.route.length<2)return;const o=emA(e.route);for(const s of o){const r=s[0]?.layer;if(!r)continue;const a=H7t(r,n);if(JQe(s)){const g=GQe(s);Hk({ctx:A,points:g,fill:a,realToCanvasMat:i});continue}for(let g=0;g<s.length-1;g++){const c=s[g],I=s[g+1];!c||!I||c.is_inside_copper_pour&&I.is_inside_copper_pour||E2({ctx:A,start:{x:c.x,y:c.y},end:{x:I.x,y:I.y},strokeWidth:c.width,stroke:a,realToCanvasMat:i,lineCap:"round"})}}UQe({ctx:A,trace:e,realToCanvasMat:i,vias:t.vias??[],platedHoles:t.platedHoles??[]})}function KQe(t){const{ctx:A,via:e,realToCanvasMat:i,colorMap:n,layer:o}=t;tQ({ctx:A,center:{x:e.x,y:e.y},radius:e.outer_diameter/2,fill:n.copper[o??"top"],realToCanvasMat:i}),A.save(),A.globalCompositeOperation="destination-out",tQ({ctx:A,center:{x:e.x,y:e.y},radius:e.hole_diameter/2,fill:"#000",realToCanvasMat:i}),A.restore(),tQ({ctx:A,center:{x:e.x,y:e.y},radius:e.hole_diameter/2,fill:n.drill,realToCanvasMat:i})}function vm(t,A){if(!A.layers||A.layers.length===0)return!0;const e=DnA(t);return e.length===0?!0:e.some(i=>A.layers.includes(i))}var ap={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)"},copperPour:{top:"rgb(230, 95, 95)",bottom:"rgb(122, 162, 222)"},soldermaskWithCopperUnderneath:{top:"rgb(18, 82, 50)",bottom:"rgb(77, 127, 196)"},soldermask:{top:"rgb(12, 55, 33)",bottom:"rgb(12, 55, 33)"},soldermaskOverCopper:{top:"rgb(52, 135, 73)",bottom:"rgb(52, 135, 73)"},substrate:"rgb(201, 162, 110)",drill:"#FF26E2",silkscreen:{top:"#f2eda1",bottom:"#5da9e9"},boardOutline:"rgba(255, 255, 255, 0.5)",courtyard:{top:"#FF00FF",bottom:"rgb(38, 233, 255)"},keepout:"#FF6B6B",fabricationNote:"rgba(255, 255, 255, 0.5)"};function Y7t(t){return!t||t.length===0?"top":t.some(e=>e.startsWith("bottom"))?"bottom":"top"}var iQ=class{ctx;colorMap;realToCanvasMat;constructor(t){if("getContext"in t&&typeof t.getContext=="function"){const A=t.getContext("2d");if(!A)throw new Error("Failed to get 2D rendering context from canvas");this.ctx=A}else this.ctx=t;this.colorMap={...ap},this.realToCanvasMat=B6t()}configure(t){t.colorOverrides&&(this.colorMap={...this.colorMap,...t.colorOverrides,copper:{...this.colorMap.copper,...t.colorOverrides.copper},copperPour:{...this.colorMap.copperPour,...t.colorOverrides.copperPour},silkscreen:{...this.colorMap.silkscreen,...t.colorOverrides.silkscreen},soldermask:{...this.colorMap.soldermask,...t.colorOverrides.soldermask},soldermaskWithCopperUnderneath:{...this.colorMap.soldermaskWithCopperUnderneath,...t.colorOverrides.soldermaskWithCopperUnderneath},soldermaskOverCopper:{...this.colorMap.soldermaskOverCopper,...t.colorOverrides.soldermaskOverCopper}})}setCameraBounds(t){const A=this.ctx.canvas,e=A.width,i=A.height,n=t.maxX-t.minX,o=t.maxY-t.minY,s=e/n,r=i/o,a=Math.min(s,r),g=(e-n*a)/2,c=(i-o*a)/2;this.realToCanvasMat=VyA(Uk(g,c),h6t(a,-a),Uk(-t.minX,-t.maxY))}drawElements(t,A={}){const e=Y7t(A.layers),i=t.find(l=>l.type==="pcb_board"),n=t.find(l=>l.type==="pcb_panel");n&&$6t({ctx:this.ctx,panel:n,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap});const o=A.drawBoardMaterial??!1,s=A.drawSoldermask??!1,r=A.drawSoldermaskTop!==void 0||A.drawSoldermaskBottom!==void 0,a=s&&(i!==void 0||n!==void 0)&&(A.drawSoldermaskTop??!r),g=s&&(i!==void 0||n!==void 0)&&(A.drawSoldermaskBottom??!1),c=t.filter(l=>vm(l,A)&&l.type==="pcb_via"),I=t.filter(l=>vm(l,A)&&l.type==="pcb_plated_hole");i&&E6t({ctx:this.ctx,board:i,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap,drawBoardMaterial:o,minBoardOutlineStrokePx:A.minBoardOutlineStrokePx});for(const l of t)vm(l,A)&&l.type==="pcb_copper_pour"&&f6t({ctx:this.ctx,pour:l,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap});for(const l of t)vm(l,A)&&(l.type==="pcb_smtpad"&&h7t({ctx:this.ctx,pad:l,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}),l.type==="pcb_copper_text"&&x6t({ctx:this.ctx,text:l,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}));if(a){for(const l of t)vm(l,A)&&l.type==="pcb_trace"&&PQe({ctx:this.ctx,trace:l,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap,vias:c,platedHoles:I});for(const l of t)vm(l,A)&&(l.type==="pcb_hole"&&kQe({ctx:this.ctx,hole:l,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap,soldermaskMargin:l.soldermask_margin,drawSoldermask:a}),l.type==="pcb_plated_hole"&&vQe({ctx:this.ctx,hole:l,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap,soldermaskMargin:l.soldermask_margin,drawSoldermask:a,layer:e}),l.type==="pcb_via"&&KQe({ctx:this.ctx,via:l,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap,layer:e}))}a&&TQe({ctx:this.ctx,elements:t,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap,layer:"top",drawSoldermask:!0});for(const l of t)vm(l,A)&&(l.type==="pcb_silkscreen_text"&&C7t({ctx:this.ctx,text:l,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}),l.type==="pcb_silkscreen_rect"&&I7t({ctx:this.ctx,rect:l,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}),l.type==="pcb_silkscreen_circle"&&e7t({ctx:this.ctx,circle:l,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}),l.type==="pcb_silkscreen_line"&&i7t({ctx:this.ctx,line:l,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}),l.type==="pcb_silkscreen_path"&&r7t({ctx:this.ctx,path:l,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}),l.type==="pcb_silkscreen_pill"&&g7t({ctx:this.ctx,pill:l,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}),l.type==="pcb_silkscreen_oval"&&o7t({ctx:this.ctx,oval:l,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}));for(const l of t)vm(l,A)&&l.type==="pcb_trace"&&!a&&PQe({ctx:this.ctx,trace:l,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap,vias:c,platedHoles:I});for(const l of t)vm(l,A)&&l.type==="pcb_hole"&&!a&&kQe({ctx:this.ctx,hole:l,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap,soldermaskMargin:a?l.soldermask_margin:void 0,drawSoldermask:a});for(const l of t)vm(l,A)&&(l.type==="pcb_plated_hole"&&!a&&vQe({ctx:this.ctx,hole:l,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap,soldermaskMargin:a?l.soldermask_margin:void 0,drawSoldermask:a,layer:e}),l.type==="pcb_via"&&!a&&KQe({ctx:this.ctx,via:l,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap,layer:e}));g&&TQe({ctx:this.ctx,elements:t,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap,layer:"bottom",drawSoldermask:!0});for(const l of t)vm(l,A)&&l.type==="pcb_cutout"&&N6t({ctx:this.ctx,cutout:l,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap});for(const l of t){if(!vm(l,A))continue;l.type==="pcb_keepout"&&q6t({ctx:this.ctx,keepout:l,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}),l.type==="pcb_fabrication_note_text"&&P6t({ctx:this.ctx,text:l,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}),l.type==="pcb_fabrication_note_rect"&&J6t({ctx:this.ctx,rect:l,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap});const B=A.showPcbNotes??!0;B&&l.type==="pcb_note_rect"&&j6t({realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap,ctx:this.ctx,rect:l}),l.type==="pcb_fabrication_note_path"&&Y6t({ctx:this.ctx,path:l,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}),B&&l.type==="pcb_note_path"&&V6t({ctx:this.ctx,path:l,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}),B&&l.type==="pcb_note_text"&&X6t({ctx:this.ctx,text:l,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}),B&&l.type==="pcb_note_line"&&Z6t({ctx:this.ctx,line:l,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}),B&&l.type==="pcb_note_dimension"&&W6t({ctx:this.ctx,pcbNoteDimension:l,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}),l.type==="pcb_fabrication_note_dimension"&&H6t({ctx:this.ctx,pcbFabricationNoteDimension:l,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}),l.type==="pcb_courtyard_circle"&&k6t({ctx:this.ctx,circle:l,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}),l.type==="pcb_courtyard_rect"&&R6t({ctx:this.ctx,rect:l,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}),l.type==="pcb_courtyard_outline"&&F6t({ctx:this.ctx,outline:l,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap})}}};const J7t=Vke(H1e);var tmA,qQe;function T7t(){if(qQe)return tmA;qQe=1;var t=Object.defineProperty,A=Object.getOwnPropertyDescriptor,e=Object.getOwnPropertyNames,i=Object.prototype.hasOwnProperty,n=(h,E)=>{for(var u in E)t(h,u,{get:E[u],enumerable:!0})},o=(h,E,u,d)=>{if(E&&typeof E=="object"||typeof E=="function")for(let f of e(E))!i.call(h,f)&&f!==u&&t(h,f,{get:()=>E[f],enumerable:!(d=A(E,f))||d.enumerable});return h},s=h=>o(t({},"__esModule",{value:!0}),h),r={};n(r,{SuperGrid:()=>Q,toMMSI:()=>C,toMeterSI:()=>B}),tmA=s(r);var a=N0(),g=J7t,c=pkA(),I=(h,E,u)=>{const d=[];if(E<h)for(let f=h;f>=E;f-=Math.abs(u))d.push(f);else for(let f=h;f<=E;f+=Math.abs(u))d.push(f);return d};function l(h,E){return{x:Math.round(E.x/h)*h,y:Math.round(E.y/h)*h}}function B(h,E=1){return h<0?"-"+B(-h):h<1e-6?"0m":h>1e3?Math.floor(h/1e3)+"km":h>1&&E>1?Math.round(h)+"m":h>1&&E<=1?h.toFixed(Math.ceil(-Math.log10(E)))+"m":h<1&&E>=1/1e3?Math.round(h*1e3)+"mm":h<1&&E<1/1e3?(h*1e3).toFixed(Math.ceil(-Math.log10(E*1e3)))+"mm":""}function C(h,E=1){return B(h/1e3,E/1e3)}var Q=h=>{var E;const u=(0,a.useRef)(null),[d,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=(E=h.majorColor)!=null?E:"rgba(0,0,0,0.5)",width:S,height:_,screenSpaceCellSize:b=200,stringifyCoord:N=(J,q,Z)=>`${B(J,Z)}, ${B(q,Z)}`}=h,F=Math.ceil(S/b)+2,L=Math.ceil(_/b)+2;(0,a.useEffect)(()=>{if(!u.current)return;const J=u.current.getContext("2d");if(!J)return;const q=b/10**Math.floor(Math.log10(h.transform.a)),Z=h.transform.d<0?-1:1,eA=b/10**Math.log10(h.transform.a)/q;function gA(xA,dA,qA){const VA=xA;let ce,fA,ge;for(ce=dA.x;ce<=qA.x;ce+=VA)fA=(0,g.applyToPoint)(h.transform,{x:ce,y:dA.y}),ge=(0,g.applyToPoint)(h.transform,{x:ce,y:qA.y}),J.beginPath(),J.moveTo(fA.x,fA.y),J.lineTo(ge.x,ge.y),J.stroke();const TA=I(dA.y,qA.y,VA*Z);for(const YA of TA)fA=(0,g.applyToPoint)(h.transform,{x:dA.x,y:YA}),ge=(0,g.applyToPoint)(h.transform,{x:qA.x,y:YA}),J.beginPath(),J.moveTo(fA.x,fA.y),J.lineTo(ge.x,ge.y),J.stroke()}function iA(xA,dA,qA){const VA=xA;let ce;for(ce=dA.x;ce<=qA.x;ce+=VA)for(const fA of I(dA.y,qA.y,VA*Z)){const ge=(0,g.applyToPoint)(h.transform,{x:ce,y:fA});J.fillStyle=D,J.font="12px sans-serif",J.fillText(N(ce,fA,xA),ge.x+2,ge.y-2)}}J.clearRect(0,0,S,_);const tA=(0,g.applyToPoint)((0,g.inverse)(h.transform),{x:0,y:0}),sA={x:Math.floor((tA.x-q)/q)*q,y:Math.floor((tA.y-q)/q+(Z==-1?2:0))*q},aA={x:sA.x+q*F,y:sA.y+q*L*Z},bA=q*5,_A={x:Math.floor((tA.x-bA)/bA)*bA,y:Math.floor((tA.y-bA)/bA+(Z==-1?2:0))*bA},HA={x:_A.x+bA*F,y:_A.y+bA*L*Z};J.globalAlpha=1,J.strokeStyle=m,gA(q,sA,aA),iA(bA,_A,HA),J.globalAlpha=1-eA,gA(bA/10,_A,HA),J.globalAlpha=1-eA,J.strokeStyle=w,gA(q/10,sA,aA),J.globalAlpha=Math.max(((1-eA)*10-5)/5,0),iA(bA/10,_A,HA),J.globalAlpha=1;const QA=(0,g.applyToPoint)(h.transform,d);J.font="12px sans-serif",J.fillStyle=D,J.fillText(N(d.x,d.y,q),QA.x+2,QA.y-2),J.strokeStyle=m,J.strokeRect(QA.x-5,QA.y-5,10,10)},[u,h.transform,d,S,_]);const Y=J=>{if(!u.current)return;const q=b/10/10**Math.floor(Math.log10(h.transform.a)),Z=u.current.getBoundingClientRect(),X=(0,g.applyToPoint)((0,g.inverse)(h.transform),{x:J.clientX-Z.left,y:J.clientY-Z.top}),eA=l(q,X);f(eA)};return(0,c.jsx)("canvas",{onMouseUp:J=>{J.button===1&&Y(J)},onDoubleClick:Y,ref:u,width:h.width,height:h.height})};return tmA}var Cz=T7t();function P7t(t){if(t.sheet)return t.sheet;for(var A=0;A<document.styleSheets.length;A++)if(document.styleSheets[A].ownerNode===t)return document.styleSheets[A]}function K7t(t){var A=document.createElement("style");return A.setAttribute("data-emotion",t.key),t.nonce!==void 0&&A.setAttribute("nonce",t.nonce),A.appendChild(document.createTextNode("")),A.setAttribute("data-s",""),A}var q7t=(function(){function t(e){var i=this;this._insertTag=function(n){var o;i.tags.length===0?i.insertionPoint?o=i.insertionPoint.nextSibling:i.prepend?o=i.container.firstChild:o=i.before:o=i.tags[i.tags.length-1].nextSibling,i.container.insertBefore(n,o),i.tags.push(n)},this.isSpeedy=e.speedy===void 0?!0:e.speedy,this.tags=[],this.ctr=0,this.nonce=e.nonce,this.key=e.key,this.container=e.container,this.prepend=e.prepend,this.insertionPoint=e.insertionPoint,this.before=null}var A=t.prototype;return A.hydrate=function(i){i.forEach(this._insertTag)},A.insert=function(i){this.ctr%(this.isSpeedy?65e3:1)===0&&this._insertTag(K7t(this));var n=this.tags[this.tags.length-1];if(this.isSpeedy){var o=P7t(n);try{o.insertRule(i,o.cssRules.length)}catch{}}else n.appendChild(document.createTextNode(i));this.ctr++},A.flush=function(){this.tags.forEach(function(i){var n;return(n=i.parentNode)==null?void 0:n.removeChild(i)}),this.tags=[],this.ctr=0},t})(),Bd="-ms-",Qz="-moz-",ng="-webkit-",OQe="comm",imA="rule",nmA="decl",O7t="@import",WQe="@keyframes",W7t="@layer",Z7t=Math.abs,hz=String.fromCharCode,V7t=Object.assign;function j7t(t,A){return Au(t,0)^45?(((A<<2^Au(t,0))<<2^Au(t,1))<<2^Au(t,2))<<2^Au(t,3):0}function ZQe(t){return t.trim()}function z7t(t,A){return(t=A.exec(t))?t[0]:t}function og(t,A,e){return t.replace(A,e)}function omA(t,A){return t.indexOf(A)}function Au(t,A){return t.charCodeAt(A)|0}function UT(t,A,e){return t.slice(A,e)}function dS(t){return t.length}function smA(t){return t.length}function Ez(t,A){return A.push(t),t}function X7t(t,A){return t.map(A).join("")}var uz=1,d2=1,VQe=0,Jf=0,nQ=0,p2="";function dz(t,A,e,i,n,o,s){return{value:t,root:A,parent:e,type:i,props:n,children:o,line:uz,column:d2,length:s,return:""}}function HT(t,A){return V7t(dz("",null,null,"",null,null,0),t,{length:-t.length},A)}function $7t(){return nQ}function A$t(){return nQ=Jf>0?Au(p2,--Jf):0,d2--,nQ===10&&(d2=1,uz--),nQ}function gy(){return nQ=Jf<VQe?Au(p2,Jf++):0,d2++,nQ===10&&(d2=1,uz++),nQ}function pS(){return Au(p2,Jf)}function pz(){return Jf}function YT(t,A){return UT(p2,t,A)}function JT(t){switch(t){case 0:case 9:case 10:case 13:case 32:return 5;case 33:case 43:case 44:case 47:case 62:case 64:case 126:case 59:case 123:case 125:return 4;case 58:return 3;case 34:case 39:case 40:case 91:return 2;case 41:case 93:return 1}return 0}function jQe(t){return uz=d2=1,VQe=dS(p2=t),Jf=0,[]}function zQe(t){return p2="",t}function fz(t){return ZQe(YT(Jf-1,rmA(t===91?t+2:t===40?t+1:t)))}function e$t(t){for(;(nQ=pS())&&nQ<33;)gy();return JT(t)>2||JT(nQ)>3?"":" "}function t$t(t,A){for(;--A&&gy()&&!(nQ<48||nQ>102||nQ>57&&nQ<65||nQ>70&&nQ<97););return YT(t,pz()+(A<6&&pS()==32&&gy()==32))}function rmA(t){for(;gy();)switch(nQ){case t:return Jf;case 34:case 39:t!==34&&t!==39&&rmA(nQ);break;case 40:t===41&&rmA(t);break;case 92:gy();break}return Jf}function i$t(t,A){for(;gy()&&t+nQ!==57;)if(t+nQ===84&&pS()===47)break;return"/*"+YT(A,Jf-1)+"*"+hz(t===47?t:gy())}function n$t(t){for(;!JT(pS());)gy();return YT(t,Jf)}function o$t(t){return zQe(yz("",null,null,null,[""],t=jQe(t),0,[0],t))}function yz(t,A,e,i,n,o,s,r,a){for(var g=0,c=0,I=s,l=0,B=0,C=0,Q=1,h=1,E=1,u=0,d="",f=n,m=o,w=i,D=d;h;)switch(C=u,u=gy()){case 40:if(C!=108&&Au(D,I-1)==58){omA(D+=og(fz(u),"&","&\f"),"&\f")!=-1&&(E=-1);break}case 34:case 39:case 91:D+=fz(u);break;case 9:case 10:case 13:case 32:D+=e$t(C);break;case 92:D+=t$t(pz()-1,7);continue;case 47:switch(pS()){case 42:case 47:Ez(s$t(i$t(gy(),pz()),A,e),a);break;default:D+="/"}break;case 123*Q:r[g++]=dS(D)*E;case 125*Q:case 59:case 0:switch(u){case 0:case 125:h=0;case 59+c:E==-1&&(D=og(D,/\f/g,"")),B>0&&dS(D)-I&&Ez(B>32?$Qe(D+";",i,e,I-1):$Qe(og(D," ","")+";",i,e,I-2),a);break;case 59:D+=";";default:if(Ez(w=XQe(D,A,e,g,c,n,r,d,f=[],m=[],I),o),u===123)if(c===0)yz(D,A,w,w,f,o,I,r,m);else switch(l===99&&Au(D,3)===110?100:l){case 100:case 108:case 109:case 115:yz(t,w,w,i&&Ez(XQe(t,w,w,0,0,n,r,d,n,f=[],I),m),n,m,I,r,i?f:m);break;default:yz(D,w,w,w,[""],m,0,r,m)}}g=c=B=0,Q=E=1,d=D="",I=s;break;case 58:I=1+dS(D),B=C;default:if(Q<1){if(u==123)--Q;else if(u==125&&Q++==0&&A$t()==125)continue}switch(D+=hz(u),u*Q){case 38:E=c>0?1:(D+="\f",-1);break;case 44:r[g++]=(dS(D)-1)*E,E=1;break;case 64:pS()===45&&(D+=fz(gy())),l=pS(),c=I=dS(d=D+=n$t(pz())),u++;break;case 45:C===45&&dS(D)==2&&(Q=0)}}return o}function XQe(t,A,e,i,n,o,s,r,a,g,c){for(var I=n-1,l=n===0?o:[""],B=smA(l),C=0,Q=0,h=0;C<i;++C)for(var E=0,u=UT(t,I+1,I=Z7t(Q=s[C])),d=t;E<B;++E)(d=ZQe(Q>0?l[E]+" "+u:og(u,/&\f/g,l[E])))&&(a[h++]=d);return dz(t,A,e,n===0?imA:r,a,g,c)}function s$t(t,A,e){return dz(t,A,e,OQe,hz($7t()),UT(t,2,-2),0)}function $Qe(t,A,e,i){return dz(t,A,e,nmA,UT(t,0,i),UT(t,i+1,-1),i)}function f2(t,A){for(var e="",i=smA(t),n=0;n<i;n++)e+=A(t[n],n,t,A)||"";return e}function r$t(t,A,e,i){switch(t.type){case W7t:if(t.children.length)break;case O7t:case nmA:return t.return=t.return||t.value;case OQe:return"";case WQe:return t.return=t.value+"{"+f2(t.children,i)+"}";case imA:t.value=t.props.join(",")}return dS(e=f2(t.children,i))?t.return=t.value+"{"+e+"}":""}function a$t(t){var A=smA(t);return function(e,i,n,o){for(var s="",r=0;r<A;r++)s+=t[r](e,i,n,o)||"";return s}}function g$t(t){return function(A){A.root||(A=A.return)&&t(A)}}function c$t(t){var A=Object.create(null);return function(e){return A[e]===void 0&&(A[e]=t(e)),A[e]}}var I$t=function(A,e,i){for(var n=0,o=0;n=o,o=pS(),n===38&&o===12&&(e[i]=1),!JT(o);)gy();return YT(A,Jf)},l$t=function(A,e){var i=-1,n=44;do switch(JT(n)){case 0:n===38&&pS()===12&&(e[i]=1),A[i]+=I$t(Jf-1,e,i);break;case 2:A[i]+=fz(n);break;case 4:if(n===44){A[++i]=pS()===58?"&\f":"",e[i]=A[i].length;break}default:A[i]+=hz(n)}while(n=gy());return A},B$t=function(A,e){return zQe(l$t(jQe(A),e))},Ahe=new WeakMap,C$t=function(A){if(!(A.type!=="rule"||!A.parent||A.length<1)){for(var e=A.value,i=A.parent,n=A.column===i.column&&A.line===i.line;i.type!=="rule";)if(i=i.parent,!i)return;if(!(A.props.length===1&&e.charCodeAt(0)!==58&&!Ahe.get(i))&&!n){Ahe.set(A,!0);for(var o=[],s=B$t(e,o),r=i.props,a=0,g=0;a<s.length;a++)for(var c=0;c<r.length;c++,g++)A.props[g]=o[a]?s[a].replace(/&\f/g,r[c]):r[c]+" "+s[a]}}},Q$t=function(A){if(A.type==="decl"){var e=A.value;e.charCodeAt(0)===108&&e.charCodeAt(2)===98&&(A.return="",A.value="")}};function ehe(t,A){switch(j7t(t,A)){case 5103:return ng+"print-"+t+t;case 5737:case 4201:case 3177:case 3433:case 1641:case 4457:case 2921:case 5572:case 6356:case 5844:case 3191:case 6645:case 3005:case 6391:case 5879:case 5623:case 6135:case 4599:case 4855:case 4215:case 6389:case 5109:case 5365:case 5621:case 3829:return ng+t+t;case 5349:case 4246:case 4810:case 6968:case 2756:return ng+t+Qz+t+Bd+t+t;case 6828:case 4268:return ng+t+Bd+t+t;case 6165:return ng+t+Bd+"flex-"+t+t;case 5187:return ng+t+og(t,/(\w+).+(:[^]+)/,ng+"box-$1$2"+Bd+"flex-$1$2")+t;case 5443:return ng+t+Bd+"flex-item-"+og(t,/flex-|-self/,"")+t;case 4675:return ng+t+Bd+"flex-line-pack"+og(t,/align-content|flex-|-self/,"")+t;case 5548:return ng+t+Bd+og(t,"shrink","negative")+t;case 5292:return ng+t+Bd+og(t,"basis","preferred-size")+t;case 6060:return ng+"box-"+og(t,"-grow","")+ng+t+Bd+og(t,"grow","positive")+t;case 4554:return ng+og(t,/([^-])(transform)/g,"$1"+ng+"$2")+t;case 6187:return og(og(og(t,/(zoom-|grab)/,ng+"$1"),/(image-set)/,ng+"$1"),t,"")+t;case 5495:case 3959:return og(t,/(image-set\([^]*)/,ng+"$1$`$1");case 4968:return og(og(t,/(.+:)(flex-)?(.*)/,ng+"box-pack:$3"+Bd+"flex-pack:$3"),/s.+-b[^;]+/,"justify")+ng+t+t;case 4095:case 3583:case 4068:case 2532:return og(t,/(.+)-inline(.+)/,ng+"$1$2")+t;case 8116:case 7059:case 5753:case 5535:case 5445:case 5701:case 4933:case 4677:case 5533:case 5789:case 5021:case 4765:if(dS(t)-1-A>6)switch(Au(t,A+1)){case 109:if(Au(t,A+4)!==45)break;case 102:return og(t,/(.+:)(.+)-([^]+)/,"$1"+ng+"$2-$3$1"+Qz+(Au(t,A+3)==108?"$3":"$2-$3"))+t;case 115:return~omA(t,"stretch")?ehe(og(t,"stretch","fill-available"),A)+t:t}break;case 4949:if(Au(t,A+1)!==115)break;case 6444:switch(Au(t,dS(t)-3-(~omA(t,"!important")&&10))){case 107:return og(t,":",":"+ng)+t;case 101:return og(t,/(.+:)([^;!]+)(;|!.+)?/,"$1"+ng+(Au(t,14)===45?"inline-":"")+"box$3$1"+ng+"$2$3$1"+Bd+"$2box$3")+t}break;case 5936:switch(Au(t,A+11)){case 114:return ng+t+Bd+og(t,/[svh]\w+-[tblr]{2}/,"tb")+t;case 108:return ng+t+Bd+og(t,/[svh]\w+-[tblr]{2}/,"tb-rl")+t;case 45:return ng+t+Bd+og(t,/[svh]\w+-[tblr]{2}/,"lr")+t}return ng+t+Bd+t+t}return t}var h$t=function(A,e,i,n){if(A.length>-1&&!A.return)switch(A.type){case nmA:A.return=ehe(A.value,A.length);break;case WQe:return f2([HT(A,{value:og(A.value,"@","@"+ng)})],n);case imA:if(A.length)return X7t(A.props,function(o){switch(z7t(o,/(::plac\w+|:read-\w+)/)){case":read-only":case":read-write":return f2([HT(A,{props:[og(o,/:(read-\w+)/,":"+Qz+"$1")]})],n);case"::placeholder":return f2([HT(A,{props:[og(o,/:(plac\w+)/,":"+ng+"input-$1")]}),HT(A,{props:[og(o,/:(plac\w+)/,":"+Qz+"$1")]}),HT(A,{props:[og(o,/:(plac\w+)/,Bd+"input-$1")]})],n)}return""})}},E$t=[h$t],u$t=function(A){var e=A.key;if(e==="css"){var i=document.querySelectorAll("style[data-emotion]:not([data-s])");Array.prototype.forEach.call(i,function(Q){var h=Q.getAttribute("data-emotion");h.indexOf(" ")!==-1&&(document.head.appendChild(Q),Q.setAttribute("data-s",""))})}var n=A.stylisPlugins||E$t,o={},s,r=[];s=A.container||document.head,Array.prototype.forEach.call(document.querySelectorAll('style[data-emotion^="'+e+' "]'),function(Q){for(var h=Q.getAttribute("data-emotion").split(" "),E=1;E<h.length;E++)o[h[E]]=!0;r.push(Q)});var a,g=[C$t,Q$t];{var c,I=[r$t,g$t(function(Q){c.insert(Q)})],l=a$t(g.concat(n,I)),B=function(h){return f2(o$t(h),l)};a=function(h,E,u,d){c=u,B(h?h+"{"+E.styles+"}":E.styles),d&&(C.inserted[E.name]=!0)}}var C={key:e,sheet:new q7t({key:e,container:s,nonce:A.nonce,speedy:A.speedy,prepend:A.prepend,insertionPoint:A.insertionPoint}),nonce:A.nonce,inserted:o,registered:{},insert:a};return C.sheet.hydrate(r),C};function d$t(t){for(var A=0,e,i=0,n=t.length;n>=4;++i,n-=4)e=t.charCodeAt(i)&255|(t.charCodeAt(++i)&255)<<8|(t.charCodeAt(++i)&255)<<16|(t.charCodeAt(++i)&255)<<24,e=(e&65535)*1540483477+((e>>>16)*59797<<16),e^=e>>>24,A=(e&65535)*1540483477+((e>>>16)*59797<<16)^(A&65535)*1540483477+((A>>>16)*59797<<16);switch(n){case 3:A^=(t.charCodeAt(i+2)&255)<<16;case 2:A^=(t.charCodeAt(i+1)&255)<<8;case 1:A^=t.charCodeAt(i)&255,A=(A&65535)*1540483477+((A>>>16)*59797<<16)}return A^=A>>>13,A=(A&65535)*1540483477+((A>>>16)*59797<<16),((A^A>>>15)>>>0).toString(36)}var p$t={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},f$t=/[A-Z]|^ms/g,y$t=/_EMO_([^_]+?)_([^]*?)_EMO_/g,the=function(A){return A.charCodeAt(1)===45},ihe=function(A){return A!=null&&typeof A!="boolean"},amA=c$t(function(t){return the(t)?t:t.replace(f$t,"-$&").toLowerCase()}),nhe=function(A,e){switch(A){case"animation":case"animationName":if(typeof e=="string")return e.replace(y$t,function(i,n,o){return Jk={name:n,styles:o,next:Jk},n})}return p$t[A]!==1&&!the(A)&&typeof e=="number"&&e!==0?e+"px":e};function mz(t,A,e){if(e==null)return"";var i=e;if(i.__emotion_styles!==void 0)return i;switch(typeof e){case"boolean":return"";case"object":{var n=e;if(n.anim===1)return Jk={name:n.name,styles:n.styles,next:Jk},n.name;var o=e;if(o.styles!==void 0){var s=o.next;if(s!==void 0)for(;s!==void 0;)Jk={name:s.name,styles:s.styles,next:Jk},s=s.next;var r=o.styles+";";return r}return m$t(t,A,e)}}var a=e;if(A==null)return a;var g=A[a];return g!==void 0?g:a}function m$t(t,A,e){var i="";if(Array.isArray(e))for(var n=0;n<e.length;n++)i+=mz(t,A,e[n])+";";else for(var o in e){var s=e[o];if(typeof s!="object"){var r=s;A!=null&&A[r]!==void 0?i+=o+"{"+A[r]+"}":ihe(r)&&(i+=amA(o)+":"+nhe(o,r)+";")}else if(Array.isArray(s)&&typeof s[0]=="string"&&(A==null||A[s[0]]===void 0))for(var a=0;a<s.length;a++)ihe(s[a])&&(i+=amA(o)+":"+nhe(o,s[a])+";");else{var g=mz(t,A,s);switch(o){case"animation":case"animationName":{i+=amA(o)+":"+g+";";break}default:i+=o+"{"+g+"}"}}}return i}var ohe=/label:\s*([^\s;{]+)\s*(;|$)/g,Jk;function gmA(t,A,e){if(t.length===1&&typeof t[0]=="object"&&t[0]!==null&&t[0].styles!==void 0)return t[0];var i=!0,n="";Jk=void 0;var o=t[0];if(o==null||o.raw===void 0)i=!1,n+=mz(e,A,o);else{var s=o;n+=s[0]}for(var r=1;r<t.length;r++)if(n+=mz(e,A,t[r]),i){var a=o;n+=a[r]}ohe.lastIndex=0;for(var g="",c;(c=ohe.exec(n))!==null;)g+="-"+c[1];var I=d$t(n)+g;return{name:I,styles:n,next:Jk}}function she(t,A,e){var i="";return e.split(" ").forEach(function(n){t[n]!==void 0?A.push(t[n]+";"):n&&(i+=n+" ")}),i}var w$t=function(A,e,i){var n=A.key+"-"+e.name;A.registered[n]===void 0&&(A.registered[n]=e.styles)},D$t=function(A,e,i){w$t(A,e);var n=A.key+"-"+e.name;if(A.inserted[e.name]===void 0){var o=e;do A.insert(e===o?"."+n:"",o,A.sheet,!0),o=o.next;while(o!==void 0)}};function rhe(t,A){if(t.inserted[A.name]===void 0)return t.insert("",A,t.sheet,!0)}function ahe(t,A,e){var i=[],n=she(t,i,e);return i.length<2?e:n+A(i)}var S$t=function(A){var e=u$t(A);e.sheet.speedy=function(r){this.isSpeedy=r},e.compat=!0;var i=function(){for(var a=arguments.length,g=new Array(a),c=0;c<a;c++)g[c]=arguments[c];var I=gmA(g,e.registered,void 0);return D$t(e,I),e.key+"-"+I.name},n=function(){for(var a=arguments.length,g=new Array(a),c=0;c<a;c++)g[c]=arguments[c];var I=gmA(g,e.registered),l="animation-"+I.name;return rhe(e,{name:I.name,styles:"@keyframes "+l+"{"+I.styles+"}"}),l},o=function(){for(var a=arguments.length,g=new Array(a),c=0;c<a;c++)g[c]=arguments[c];var I=gmA(g,e.registered);rhe(e,I)},s=function(){for(var a=arguments.length,g=new Array(a),c=0;c<a;c++)g[c]=arguments[c];return ahe(e.registered,i,b$t(g))};return{css:i,cx:s,injectGlobal:o,keyframes:n,hydrate:function(a){a.forEach(function(g){e.inserted[g]=!0})},flush:function(){e.registered={},e.inserted={},e.sheet.flush()},sheet:e.sheet,cache:e,getRegisteredStyles:she.bind(null,e.registered),merge:ahe.bind(null,e.registered,i)}},b$t=function t(A){for(var e="",i=0;i<A.length;i++){var n=A[i];if(n!=null){var o=void 0;switch(typeof n){case"boolean":break;case"object":{if(Array.isArray(n))o=t(n);else{o="";for(var s in n)n[s]&&s&&(o&&(o+=" "),o+=s)}break}default:o=n}o&&(e&&(e+=" "),e+=o)}}return e},x$t=S$t({key:"css"}),y2=x$t.css,_$t=Object.create,ghe=Object.defineProperty,k$t=Object.getOwnPropertyDescriptor,che=Object.getOwnPropertyNames,v$t=Object.getPrototypeOf,F$t=Object.prototype.hasOwnProperty,ha=(t,A)=>function(){return A||(0,t[che(t)[0]])((A={exports:{}}).exports,A),A.exports},M$t=(t,A,e,i)=>{if(A&&typeof A=="object"||typeof A=="function")for(let n of che(A))!F$t.call(t,n)&&n!==e&&ghe(t,n,{get:()=>A[n],enumerable:!(i=k$t(A,n))||i.enumerable});return t},cmA=(t,A,e)=>(e=t!=null?_$t(v$t(t)):{},M$t(A||!t||!t.__esModule?ghe(e,"default",{value:t,enumerable:!0}):e,t)),R$t=ha({"node_modules/toggle-selection/index.js"(t,A){A.exports=function(){var e=document.getSelection();if(!e.rangeCount)return function(){};for(var i=document.activeElement,n=[],o=0;o<e.rangeCount;o++)n.push(e.getRangeAt(o));switch(i.tagName.toUpperCase()){case"INPUT":case"TEXTAREA":i.blur();break;default:i=null;break}return e.removeAllRanges(),function(){e.type==="Caret"&&e.removeAllRanges(),e.rangeCount||n.forEach(function(s){e.addRange(s)}),i&&i.focus()}}}}),N$t=ha({"node_modules/copy-to-clipboard/index.js"(t,A){var e=R$t(),i={"text/plain":"Text","text/html":"Url",default:"Text"},n="Copy to clipboard: #{key}, Enter";function o(r){var a=(/mac os x/i.test(navigator.userAgent)?"⌘":"Ctrl")+"+C";return r.replace(/#{\s*key\s*}/g,a)}function s(r,a){var g,c,I,l,B,C,Q=!1;a||(a={}),g=a.debug||!1;try{I=e(),l=document.createRange(),B=document.getSelection(),C=document.createElement("span"),C.textContent=r,C.ariaHidden="true",C.style.all="unset",C.style.position="fixed",C.style.top=0,C.style.clip="rect(0, 0, 0, 0)",C.style.whiteSpace="pre",C.style.webkitUserSelect="text",C.style.MozUserSelect="text",C.style.msUserSelect="text",C.style.userSelect="text",C.addEventListener("copy",function(E){if(E.stopPropagation(),a.format)if(E.preventDefault(),typeof E.clipboardData>"u"){g&&console.warn("unable to use e.clipboardData"),g&&console.warn("trying IE specific stuff"),window.clipboardData.clearData();var u=i[a.format]||i.default;window.clipboardData.setData(u,r)}else E.clipboardData.clearData(),E.clipboardData.setData(a.format,r);a.onCopy&&(E.preventDefault(),a.onCopy(E.clipboardData))}),document.body.appendChild(C),l.selectNodeContents(C),B.addRange(l);var h=document.execCommand("copy");if(!h)throw new Error("copy command was unsuccessful");Q=!0}catch(E){g&&console.error("unable to copy using execCommand: ",E),g&&console.warn("trying IE specific stuff");try{window.clipboardData.setData(a.format||"text",r),a.onCopy&&a.onCopy(window.clipboardData),Q=!0}catch(u){g&&console.error("unable to copy using clipboardData: ",u),g&&console.error("falling back to prompt"),c=o("message"in a?a.message:n),window.prompt(c,r)}}finally{B&&(typeof B.removeRange=="function"?B.removeRange(l):B.removeAllRanges()),C&&document.body.removeChild(C),I()}return Q}A.exports=s}}),G$t=ha({"node_modules/svgson/dist/svgson.umd.js"(t,A){(function(e,i){typeof t=="object"&&typeof A<"u"?A.exports=i():typeof define=="function"&&define.amd?define(i):(e=typeof globalThis<"u"?globalThis:e||self,e.svgson=i())})(t,function(){var e=function(iA){return iA!=null&&(i(iA)||n(iA)||!!iA._isBuffer)};function i(iA){return!!iA.constructor&&typeof iA.constructor.isBuffer=="function"&&iA.constructor.isBuffer(iA)}function n(iA){return typeof iA.readFloatLE=="function"&&typeof iA.slice=="function"&&i(iA.slice(0,0))}var o=Object.prototype.toString,s=function(tA){if(typeof tA>"u")return"undefined";if(tA===null)return"null";if(tA===!0||tA===!1||tA instanceof Boolean)return"boolean";if(typeof tA=="string"||tA instanceof String)return"string";if(typeof tA=="number"||tA instanceof Number)return"number";if(typeof tA=="function"||tA instanceof Function)return"function";if(typeof Array.isArray<"u"&&Array.isArray(tA))return"array";if(tA instanceof RegExp)return"regexp";if(tA instanceof Date)return"date";var sA=o.call(tA);return sA==="[object RegExp]"?"regexp":sA==="[object Date]"?"date":sA==="[object Arguments]"?"arguments":sA==="[object Error]"?"error":e(tA)?"buffer":sA==="[object Set]"?"set":sA==="[object WeakSet]"?"weakset":sA==="[object Map]"?"map":sA==="[object WeakMap]"?"weakmap":sA==="[object Symbol]"?"symbol":sA==="[object Int8Array]"?"int8array":sA==="[object Uint8Array]"?"uint8array":sA==="[object Uint8ClampedArray]"?"uint8clampedarray":sA==="[object Int16Array]"?"int16array":sA==="[object Uint16Array]"?"uint16array":sA==="[object Int32Array]"?"int32array":sA==="[object Uint32Array]"?"uint32array":sA==="[object Float32Array]"?"float32array":sA==="[object Float64Array]"?"float64array":"object"};function r(iA,tA){return tA={exports:{}},iA(tA,tA.exports),tA.exports}var a=r(function(iA){(function(){function tA(sA,aA){if(typeof aA!="function")return sA;var hA={};for(var bA in sA)Object.prototype.hasOwnProperty.call(sA,bA)&&(hA[aA(bA,sA[bA])||bA]=sA[bA]);return hA}iA.exports?iA.exports=tA:window.rename=tA})()}),g=function iA(tA,sA){var aA=s(tA);if(aA!=="object"&&aA!=="array")throw new Error("expected an object");var hA=[];aA==="object"&&(tA=a(tA,sA),hA={});for(var bA in tA)if(tA.hasOwnProperty(bA)){var _A=tA[bA];s(_A)==="object"||s(_A)==="array"?hA[bA]=iA(_A,sA):hA[bA]=_A}return hA},c=r(function(iA){var tA=Object.prototype.hasOwnProperty,sA="~";function aA(){}Object.create&&(aA.prototype=Object.create(null),new aA().__proto__||(sA=!1));function hA(_A,HA,QA){this.fn=_A,this.context=HA,this.once=QA||!1}function bA(){this._events=new aA,this._eventsCount=0}bA.prototype.eventNames=function(){var HA=[],QA,xA;if(this._eventsCount===0)return HA;for(xA in QA=this._events)tA.call(QA,xA)&&HA.push(sA?xA.slice(1):xA);return Object.getOwnPropertySymbols?HA.concat(Object.getOwnPropertySymbols(QA)):HA},bA.prototype.listeners=function(HA,QA){var xA=sA?sA+HA:HA,dA=this._events[xA];if(QA)return!!dA;if(!dA)return[];if(dA.fn)return[dA.fn];for(var qA=0,VA=dA.length,ce=new Array(VA);qA<VA;qA++)ce[qA]=dA[qA].fn;return ce},bA.prototype.emit=function(HA,QA,xA,dA,qA,VA){var ce=sA?sA+HA:HA;if(!this._events[ce])return!1;var fA=this._events[ce],ge=arguments.length,TA,YA;if(fA.fn){switch(fA.once&&this.removeListener(HA,fA.fn,void 0,!0),ge){case 1:return fA.fn.call(fA.context),!0;case 2:return fA.fn.call(fA.context,QA),!0;case 3:return fA.fn.call(fA.context,QA,xA),!0;case 4:return fA.fn.call(fA.context,QA,xA,dA),!0;case 5:return fA.fn.call(fA.context,QA,xA,dA,qA),!0;case 6:return fA.fn.call(fA.context,QA,xA,dA,qA,VA),!0}for(YA=1,TA=new Array(ge-1);YA<ge;YA++)TA[YA-1]=arguments[YA];fA.fn.apply(fA.context,TA)}else{var jA=fA.length,kA;for(YA=0;YA<jA;YA++)switch(fA[YA].once&&this.removeListener(HA,fA[YA].fn,void 0,!0),ge){case 1:fA[YA].fn.call(fA[YA].context);break;case 2:fA[YA].fn.call(fA[YA].context,QA);break;case 3:fA[YA].fn.call(fA[YA].context,QA,xA);break;case 4:fA[YA].fn.call(fA[YA].context,QA,xA,dA);break;default:if(!TA)for(kA=1,TA=new Array(ge-1);kA<ge;kA++)TA[kA-1]=arguments[kA];fA[YA].fn.apply(fA[YA].context,TA)}}return!0},bA.prototype.on=function(HA,QA,xA){var dA=new hA(QA,xA||this),qA=sA?sA+HA:HA;return this._events[qA]?this._events[qA].fn?this._events[qA]=[this._events[qA],dA]:this._events[qA].push(dA):(this._events[qA]=dA,this._eventsCount++),this},bA.prototype.once=function(HA,QA,xA){var dA=new hA(QA,xA||this,!0),qA=sA?sA+HA:HA;return this._events[qA]?this._events[qA].fn?this._events[qA]=[this._events[qA],dA]:this._events[qA].push(dA):(this._events[qA]=dA,this._eventsCount++),this},bA.prototype.removeListener=function(HA,QA,xA,dA){var qA=sA?sA+HA:HA;if(!this._events[qA])return this;if(!QA)return--this._eventsCount===0?this._events=new aA:delete this._events[qA],this;var VA=this._events[qA];if(VA.fn)VA.fn===QA&&(!dA||VA.once)&&(!xA||VA.context===xA)&&(--this._eventsCount===0?this._events=new aA:delete this._events[qA]);else{for(var ce=0,fA=[],ge=VA.length;ce<ge;ce++)(VA[ce].fn!==QA||dA&&!VA[ce].once||xA&&VA[ce].context!==xA)&&fA.push(VA[ce]);fA.length?this._events[qA]=fA.length===1?fA[0]:fA:--this._eventsCount===0?this._events=new aA:delete this._events[qA]}return this},bA.prototype.removeAllListeners=function(HA){var QA;return HA?(QA=sA?sA+HA:HA,this._events[QA]&&(--this._eventsCount===0?this._events=new aA:delete this._events[QA])):(this._events=new aA,this._eventsCount=0),this},bA.prototype.off=bA.prototype.removeListener,bA.prototype.addListener=bA.prototype.on,bA.prototype.setMaxListeners=function(){return this},bA.prefixed=sA,bA.EventEmitter=bA,iA.exports=bA});function I(iA,tA,sA){return tA in iA?Object.defineProperty(iA,tA,{value:sA,enumerable:!0,configurable:!0,writable:!0}):iA[tA]=sA,iA}var l=function(){},B={data:"state-data",cdata:"state-cdata",tagBegin:"state-tag-begin",tagName:"state-tag-name",tagEnd:"state-tag-end",attributeNameStart:"state-attribute-name-start",attributeName:"state-attribute-name",attributeNameEnd:"state-attribute-name-end",attributeValueBegin:"state-attribute-value-begin",attributeValue:"state-attribute-value"},C={lt:"action-lt",gt:"action-gt",space:"action-space",equal:"action-equal",quote:"action-quote",slash:"action-slash",char:"action-char",error:"action-error"},Q={text:"text",openTag:"open-tag",closeTag:"close-tag",attributeName:"attribute-name",attributeValue:"attribute-value"},h={" ":C.space," ":C.space,"\n":C.space,"\r":C.space,"<":C.lt,">":C.gt,'"':C.quote,"'":C.quote,"=":C.equal,"/":C.slash},E=function(tA){return h[tA]||C.char},u=function(tA){var sA,aA,hA,bA,_A,HA,QA,xA,dA,qA;tA=Object.assign({debug:!1},tA);var VA=new c,ce=B.data,fA="",ge="",TA="",YA="",jA="",kA="",wA=function(KA,ZA){if(!(ge[0]==="?"||ge[0]==="!")){var ne={type:KA,value:ZA};tA.debug&&console.log("emit:",ne),VA.emit("data",ne)}};VA.stateMachine=(qA={},I(qA,B.data,(sA={},I(sA,C.lt,function(){fA.trim()&&wA(Q.text,fA),ge="",jA=!1,ce=B.tagBegin}),I(sA,C.char,function(MA){fA+=MA}),sA)),I(qA,B.cdata,I({},C.char,function(MA){fA+=MA,fA.substr(-3)==="]]>"&&(wA(Q.text,fA.slice(0,-3)),fA="",ce=B.data)})),I(qA,B.tagBegin,(aA={},I(aA,C.space,l),I(aA,C.char,function(MA){ge=MA,ce=B.tagName}),I(aA,C.slash,function(){ge="",jA=!0}),aA)),I(qA,B.tagName,(hA={},I(hA,C.space,function(){jA?ce=B.tagEnd:(ce=B.attributeNameStart,wA(Q.openTag,ge))}),I(hA,C.gt,function(){wA(jA?Q.closeTag:Q.openTag,ge),fA="",ce=B.data}),I(hA,C.slash,function(){ce=B.tagEnd,wA(Q.openTag,ge)}),I(hA,C.char,function(MA){ge+=MA,ge==="![CDATA["&&(ce=B.cdata,fA="",ge="")}),hA)),I(qA,B.tagEnd,(bA={},I(bA,C.gt,function(){wA(Q.closeTag,ge),fA="",ce=B.data}),I(bA,C.char,l),bA)),I(qA,B.attributeNameStart,(_A={},I(_A,C.char,function(MA){TA=MA,ce=B.attributeName}),I(_A,C.gt,function(){fA="",ce=B.data}),I(_A,C.space,l),I(_A,C.slash,function(){jA=!0,ce=B.tagEnd}),_A)),I(qA,B.attributeName,(HA={},I(HA,C.space,function(){ce=B.attributeNameEnd}),I(HA,C.equal,function(){wA(Q.attributeName,TA),ce=B.attributeValueBegin}),I(HA,C.gt,function(){YA="",wA(Q.attributeName,TA),wA(Q.attributeValue,YA),fA="",ce=B.data}),I(HA,C.slash,function(){jA=!0,YA="",wA(Q.attributeName,TA),wA(Q.attributeValue,YA),ce=B.tagEnd}),I(HA,C.char,function(MA){TA+=MA}),HA)),I(qA,B.attributeNameEnd,(QA={},I(QA,C.space,l),I(QA,C.equal,function(){wA(Q.attributeName,TA),ce=B.attributeValueBegin}),I(QA,C.gt,function(){YA="",wA(Q.attributeName,TA),wA(Q.attributeValue,YA),fA="",ce=B.data}),I(QA,C.char,function(MA){YA="",wA(Q.attributeName,TA),wA(Q.attributeValue,YA),TA=MA,ce=B.attributeName}),QA)),I(qA,B.attributeValueBegin,(xA={},I(xA,C.space,l),I(xA,C.quote,function(MA){kA=MA,YA="",ce=B.attributeValue}),I(xA,C.gt,function(){YA="",wA(Q.attributeValue,YA),fA="",ce=B.data}),I(xA,C.char,function(MA){kA="",YA=MA,ce=B.attributeValue}),xA)),I(qA,B.attributeValue,(dA={},I(dA,C.space,function(MA){kA?YA+=MA:(wA(Q.attributeValue,YA),ce=B.attributeNameStart)}),I(dA,C.quote,function(MA){kA===MA?(wA(Q.attributeValue,YA),ce=B.attributeNameStart):YA+=MA}),I(dA,C.gt,function(MA){kA?YA+=MA:(wA(Q.attributeValue,YA),fA="",ce=B.data)}),I(dA,C.slash,function(MA){kA?YA+=MA:(wA(Q.attributeValue,YA),jA=!0,ce=B.tagEnd)}),I(dA,C.char,function(MA){YA+=MA}),dA)),qA);var GA=function(KA){tA.debug&&console.log(ce,KA);var ZA=VA.stateMachine[ce],ne=ZA[E(KA)]||ZA[C.error]||ZA[C.char];ne(KA)};return VA.write=function(MA){for(var KA=MA.length,ZA=0;ZA<KA;ZA++)GA(MA[ZA])},VA},d={State:B,Action:C,Type:Q,create:u},f=d.Type,m={element:"element",text:"text"},w=function(tA){return Object.assign({name:"",type:m.element,value:"",parent:null,attributes:{},children:[]},tA)},D=function(tA){tA=Object.assign({stream:!1,parentNodes:!0,doneEvent:"done",tagPrefix:"tag:",emitTopLevelOnly:!1,debug:!1},tA);var sA=void 0,aA=void 0,hA=void 0,bA=void 0,_A=new c,HA=function(xA){switch(xA.type){case f.openTag:if(hA===null)hA=aA,hA.name=xA.value;else{var dA=w({name:xA.value,parent:hA});hA.children.push(dA),hA=dA}break;case f.closeTag:var qA=hA.parent;if(tA.parentNodes||(hA.parent=null),hA.name!==xA.value)break;tA.stream&&qA===aA&&(aA.children=[],hA.parent=null),(!tA.emitTopLevelOnly||qA===aA)&&(_A.emit(tA.tagPrefix+hA.name,hA),_A.emit("tag",hA.name,hA)),hA===aA&&(sA.removeAllListeners("data"),_A.emit(tA.doneEvent,hA),aA=null),hA=qA;break;case f.text:hA&&hA.children.push(w({type:m.text,value:xA.value,parent:tA.parentNodes?hA:null}));break;case f.attributeName:bA=xA.value,hA.attributes[bA]="";break;case f.attributeValue:hA.attributes[bA]=xA.value;break}};return _A.reset=function(){sA=d.create({debug:tA.debug}),sA.on("data",HA),aA=w(),hA=null,bA="",_A.parse=sA.write},_A.reset(),_A},S=function(tA,sA){sA=Object.assign({},sA,{stream:!1,tagPrefix:":"});var aA=D(sA),hA=void 0;return aA.on("done",function(bA){hA=bA}),aA.parse(tA),hA},_={parseSync:S},b=_.parseSync,N=function(tA){var sA=b("<root>".concat(tA,"</root>"),{parentNodes:!1}),aA=sA.children&&sA.children.length>0&&sA.children.every(function(hA){return hA.name==="svg"});if(aA)return sA.children.length===1?sA.children[0]:sA.children;throw Error("nothing to parse")},F=function(tA){return g(tA,function(sA){return Y(sA)?sA:L(sA)})},L=function(tA){return tA.replace(/[-|:]([a-z])/gi,function(sA,aA){return aA.toUpperCase()})},Y=function(tA){return/^(data|aria)(-\w+)/.test(tA)},J=function(tA){if(tA){var sA=String(tA);return/[&<>]/.test(sA)?"<![CDATA[".concat(sA.replace(/]]>/,"]]]]><![CDATA[>"),"]]>"):sA}return""},q=function(tA){return String(tA).replace(/&/g,"&amp;").replace(/'/g,"&apos;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")},Z=function(tA){var sA=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},aA=sA.transformNode,hA=aA===void 0?function(QA){return QA}:aA,bA=sA.camelcase,_A=bA===void 0?!1:bA,HA=function(xA){var dA;return dA=hA(xA),_A&&(dA=F(dA)),dA};return HA(N(tA))};function X(){for(var iA=arguments.length,tA=new Array(iA),sA=0;sA<iA;sA++)tA[sA]=arguments[sA];return new Promise(function(aA,hA){try{var bA=Z.apply(void 0,tA);aA(bA)}catch(_A){hA(_A)}})}var eA=function iA(tA){var sA=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},aA=sA.transformAttr,hA=aA===void 0?function(ce,fA,ge){return"".concat(ce,'="').concat(ge(fA),'"')}:aA,bA=sA.transformNode,_A=bA===void 0?function(ce){return ce}:bA,HA=sA.selfClose,QA=HA===void 0?!0:HA;if(Array.isArray(tA))return tA.map(function(ce){return iA(ce,{transformAttr:hA,selfClose:QA,transformNode:_A})}).join("");var xA=_A(tA);if(xA.type==="text")return J(xA.value);var dA="";for(var qA in xA.attributes){var VA=hA(qA,xA.attributes[qA],q,xA.name);dA+=VA?" ".concat(VA):""}return xA.children&&xA.children.length>0||!QA?"<".concat(xA.name).concat(dA,">").concat(iA(xA.children,{transformAttr:hA,transformNode:_A,selfClose:QA}),"</").concat(xA.name,">"):"<".concat(xA.name).concat(dA,"/>")},gA=Object.assign({},{parse:X,parseSync:Z,stringify:eA});return gA})}}),ImA=ha({"node_modules/js-beautify/js/src/core/output.js"(t,A){function e(o){this.__parent=o,this.__character_count=0,this.__indent_count=-1,this.__alignment_count=0,this.__wrap_point_index=0,this.__wrap_point_character_count=0,this.__wrap_point_indent_count=-1,this.__wrap_point_alignment_count=0,this.__items=[]}e.prototype.clone_empty=function(){var o=new e(this.__parent);return o.set_indent(this.__indent_count,this.__alignment_count),o},e.prototype.item=function(o){return o<0?this.__items[this.__items.length+o]:this.__items[o]},e.prototype.has_match=function(o){for(var s=this.__items.length-1;s>=0;s--)if(this.__items[s].match(o))return!0;return!1},e.prototype.set_indent=function(o,s){this.is_empty()&&(this.__indent_count=o||0,this.__alignment_count=s||0,this.__character_count=this.__parent.get_indent_size(this.__indent_count,this.__alignment_count))},e.prototype._set_wrap_point=function(){this.__parent.wrap_line_length&&(this.__wrap_point_index=this.__items.length,this.__wrap_point_character_count=this.__character_count,this.__wrap_point_indent_count=this.__parent.next_line.__indent_count,this.__wrap_point_alignment_count=this.__parent.next_line.__alignment_count)},e.prototype._should_wrap=function(){return this.__wrap_point_index&&this.__character_count>this.__parent.wrap_line_length&&this.__wrap_point_character_count>this.__parent.next_line.__character_count},e.prototype._allow_wrap=function(){if(this._should_wrap()){this.__parent.add_new_line();var o=this.__parent.current_line;return o.set_indent(this.__wrap_point_indent_count,this.__wrap_point_alignment_count),o.__items=this.__items.slice(this.__wrap_point_index),this.__items=this.__items.slice(0,this.__wrap_point_index),o.__character_count+=this.__character_count-this.__wrap_point_character_count,this.__character_count=this.__wrap_point_character_count,o.__items[0]===" "&&(o.__items.splice(0,1),o.__character_count-=1),!0}return!1},e.prototype.is_empty=function(){return this.__items.length===0},e.prototype.last=function(){return this.is_empty()?null:this.__items[this.__items.length-1]},e.prototype.push=function(o){this.__items.push(o);var s=o.lastIndexOf(`
5391
5391
  `);s!==-1?this.__character_count=o.length-s:this.__character_count+=o.length},e.prototype.pop=function(){var o=null;return this.is_empty()||(o=this.__items.pop(),this.__character_count-=o.length),o},e.prototype._remove_indent=function(){this.__indent_count>0&&(this.__indent_count-=1,this.__character_count-=this.__parent.indent_size)},e.prototype._remove_wrap_indent=function(){this.__wrap_point_indent_count>0&&(this.__wrap_point_indent_count-=1)},e.prototype.trim=function(){for(;this.last()===" ";)this.__items.pop(),this.__character_count-=1},e.prototype.toString=function(){var o="";return this.is_empty()?this.__parent.indent_empty_lines&&(o=this.__parent.get_indent_string(this.__indent_count)):(o=this.__parent.get_indent_string(this.__indent_count,this.__alignment_count),o+=this.__items.join("")),o};function i(o,s){this.__cache=[""],this.__indent_size=o.indent_size,this.__indent_string=o.indent_char,o.indent_with_tabs||(this.__indent_string=new Array(o.indent_size+1).join(o.indent_char)),s=s||"",o.indent_level>0&&(s=new Array(o.indent_level+1).join(this.__indent_string)),this.__base_string=s,this.__base_string_length=s.length}i.prototype.get_indent_size=function(o,s){var r=this.__base_string_length;return s=s||0,o<0&&(r=0),r+=o*this.__indent_size,r+=s,r},i.prototype.get_indent_string=function(o,s){var r=this.__base_string;return s=s||0,o<0&&(o=0,r=""),s+=o*this.__indent_size,this.__ensure_cache(s),r+=this.__cache[s],r},i.prototype.__ensure_cache=function(o){for(;o>=this.__cache.length;)this.__add_column()},i.prototype.__add_column=function(){var o=this.__cache.length,s=0,r="";this.__indent_size&&o>=this.__indent_size&&(s=Math.floor(o/this.__indent_size),o-=s*this.__indent_size,r=new Array(s+1).join(this.__indent_string)),o&&(r+=new Array(o+1).join(" ")),this.__cache.push(r)};function n(o,s){this.__indent_cache=new i(o,s),this.raw=!1,this._end_with_newline=o.end_with_newline,this.indent_size=o.indent_size,this.wrap_line_length=o.wrap_line_length,this.indent_empty_lines=o.indent_empty_lines,this.__lines=[],this.previous_line=null,this.current_line=null,this.next_line=new e(this),this.space_before_token=!1,this.non_breaking_space=!1,this.previous_token_wrapped=!1,this.__add_outputline()}n.prototype.__add_outputline=function(){this.previous_line=this.current_line,this.current_line=this.next_line.clone_empty(),this.__lines.push(this.current_line)},n.prototype.get_line_number=function(){return this.__lines.length},n.prototype.get_indent_string=function(o,s){return this.__indent_cache.get_indent_string(o,s)},n.prototype.get_indent_size=function(o,s){return this.__indent_cache.get_indent_size(o,s)},n.prototype.is_empty=function(){return!this.previous_line&&this.current_line.is_empty()},n.prototype.add_new_line=function(o){return this.is_empty()||!o&&this.just_added_newline()?!1:(this.raw||this.__add_outputline(),!0)},n.prototype.get_code=function(o){this.trim(!0);var s=this.current_line.pop();s&&(s[s.length-1]===`
5392
5392
  `&&(s=s.replace(/\n+$/g,"")),this.current_line.push(s)),this._end_with_newline&&this.__add_outputline();var r=this.__lines.join(`
5393
5393
  `);return o!==`
@@ -5472,7 +5472,7 @@ $1`).replace(/>(\s*)(?=<!--\s*\/)/g,"> ")}}});function dhe(t,A,e){if(!A||!e)retu
5472
5472
  transition: opacity 0.2s;
5473
5473
  margin-bottom: 10px;
5474
5474
  color: red;
5475
- `,zei=({children:t,transform:A=xa(),elements:e})=>{const i=V.useRef(null),{isShowingDRCErrors:n,hoveredErrorId:o}=mB(g=>({isShowingDRCErrors:g.is_showing_drc_errors,hoveredErrorId:g.hovered_error_id}));if(!e)return W.jsx("div",{style:{position:"relative"},ref:i,children:t});const s=e.filter(g=>g.type==="pcb_trace_error"),r=e.filter(g=>g.type==="pcb_trace_error"&&g.message?.includes("Multiple components found with name")),a=new Map;return e.forEach(g=>{g.type==="pcb_port"&&a.set(g.pcb_port_id,g)}),W.jsxs("div",{style:{position:"relative"},ref:i,children:[t,s.map((g,c)=>{const{pcb_port_ids:I,pcb_trace_id:l}=g,B=I?.[0]?a.get(I[0]):void 0,C=I?.[1]?a.get(I[1]):void 0,Q=e?nx(e).pcb_trace.get(l):void 0,h=g.pcb_trace_error_id||`error_${c}_${g.error_type}_${g.message?.slice(0,20)}`,E=o===h;if(B&&C){const u=Ce(A,{x:B.x,y:B.y}),d=Ce(A,{x:C.x,y:C.y});if(!n)return null;const 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=umA(m,i);return W.jsxs(V.Fragment,{children:[W.jsx(Vei,{screenPort1:u,screenPort2:d,errorCenter:m,canLineBeDrawn:f,isHighlighted:E}),W.jsx("div",{style:{position:"absolute",left:m.x-15,top:m.y-15,width:30,height:30,zIndex:xc.errorOverlay+5,cursor:"pointer",borderRadius:"50%"},onMouseEnter:D=>{const S=D.currentTarget.nextElementSibling;if(S){const _=S.querySelector(".error-message");_&&(_.style.opacity="1")}},onMouseLeave:D=>{if(!E){const S=D.currentTarget.nextElementSibling;if(S){const _=S.querySelector(".error-message");_&&(_.style.opacity="0")}}}}),W.jsx("div",{style:{position:"absolute",zIndex:E?200:100,left:w.left,top:w.top,color:E?"#ff4444":"red",textAlign:"center",fontFamily:"sans-serif",fontSize:12,display:n||E?"flex":"none",flexDirection:"column",alignItems:"center",pointerEvents:"none",transform:w.transform},children:W.jsx("div",{className:`error-message ${dmA}`,style:{opacity:E?1:0,border:`1px solid ${E?"#ff4444":"red"}`},children:g.message})})]},h)}if(Q?.route&&(n||E)){const u=Q.route.map(w=>Ce(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=umA(f,i);return W.jsxs(V.Fragment,{children:[W.jsx(jei,{points:u,errorCenter:f,isHighlighted:E}),W.jsx("div",{style:{position:"absolute",left:f.x-15,top:f.y-15,width:30,height:30,zIndex:xc.errorOverlay+5,cursor:"pointer",borderRadius:"50%"},onMouseEnter:w=>{const D=w.currentTarget.nextElementSibling;if(D){const S=D.querySelector(".error-message");S&&(S.style.opacity="1")}},onMouseLeave:w=>{if(!E){const D=w.currentTarget.nextElementSibling;if(D){const S=D.querySelector(".error-message");S&&(S.style.opacity="0")}}}}),W.jsx("div",{style:{position:"absolute",zIndex:E?xc.errorOverlay+10:xc.errorOverlay+1,left:m.left,top:m.top,color:E?"#ff4444":"red",textAlign:"center",fontFamily:"sans-serif",fontSize:12,display:"flex",flexDirection:"column",alignItems:"center",pointerEvents:"none",transform:m.transform},children:W.jsx("div",{className:`error-message ${dmA}`,style:{opacity:E?1:0,border:`1px solid ${E?"#ff4444":"red"}`},children:g.message})})]},h)}return null}),r.map((g,c)=>{const I=g.component_name||g.message?.match(/name "([^"]+)"/)?.[1];if(!I)return null;const l=e?.filter(Q=>Q.type==="source_component"&&Q.name===I||Q.type==="pcb_component"&&e?.find(h=>h.type==="source_component"&&h.source_component_id===Q.source_component_id&&h.name===I))||[],B=g.pcb_trace_error_id||`error_${c}_${g.error_type}_${g.message?.slice(0,20)}`,C=o===B;return!C&&!n?null:l.map((Q,h)=>{let E={x:0,y:0};if(Q.type==="pcb_component")E=Q.center||{x:0,y:0};else if(Q.type==="source_component"){const _=e?.find(b=>b.type==="pcb_component"&&b.source_component_id===Q.source_component_id);_&&_.type==="pcb_component"&&(E=_.center||{x:0,y:0})}const u=Ce(A,E);if(isNaN(u.x)||isNaN(u.y))return null;const d=Math.abs(A.a),D=Math.max(8,Math.min(30,.5*d)),S=umA(u,i);return W.jsxs(V.Fragment,{children:[W.jsx("svg",{style:{position:"absolute",left:0,top:0,pointerEvents:"none",mixBlendMode:"difference",zIndex:xc.errorOverlay},width:"100%",height:"100%",children:C?W.jsx("polygon",{points:`${u.x},${u.y-D*1.25} ${u.x+D},${u.y} ${u.x},${u.y+D*1.25} ${u.x-D},${u.y}`,fill:"#ff4444"}):W.jsx("circle",{cx:u.x,cy:u.y,r:D,fill:"none",stroke:C?"#ff4444":"red",strokeWidth:C?Math.max(2,D*.15):Math.max(1,D*.1),opacity:1})}),W.jsx("div",{style:{position:"absolute",left:u.x-(D+10),top:u.y-(D+10),width:(D+10)*2,height:(D+10)*2,zIndex:xc.errorOverlay+5,cursor:"pointer",borderRadius:"50%"},onMouseEnter:_=>{const b=_.currentTarget.nextElementSibling;if(b){const N=b.querySelector(".error-message");N&&(N.style.opacity="1")}},onMouseLeave:_=>{if(!C){const b=_.currentTarget.nextElementSibling;if(b){const N=b.querySelector(".error-message");N&&(N.style.opacity="0")}}}}),W.jsx("div",{style:{position:"absolute",zIndex:C?xc.errorOverlay+20:xc.errorOverlay+10,left:S.left,top:S.top,color:C?"#ff4444":"red",textAlign:"center",fontFamily:"sans-serif",fontSize:12,display:n||C?"flex":"none",flexDirection:"column",alignItems:"center",pointerEvents:"none",transform:S.transform},children:W.jsx("div",{className:`error-message ${dmA}`,style:{opacity:C?1:0,border:`1px solid ${C?"#ff4444":"red"}`},children:g.message})})]},`${B}_${h}`)})})]})};function Xei(t,A){return t.size!==A.size?!1:Array.from(t).every(e=>A.has(e))}function $ei({primitiveElement:t,elements:A}){let e=t.trace_length?`${t.trace_length.toFixed(3)}`:"";const i=nx(A).source_trace.get(t?.source_trace_id);if(i?.display_name&&(i?.max_length?e+=` / ${i.max_length}mm `:e+=" mm ",e+=`(${i.display_name})`),!e)return null;const n=t.trace_length&&i?.max_length&&t.trace_length>i.max_length;return{text:e,isOverLength:n}}function Ati(t){const{primitives:A,is_showing_multiple_traces_length:e,elements:i}=t,n=A.filter(a=>a._element.type==="pcb_trace"),o=i.filter(a=>a.type==="source_trace"),s=A.filter(a=>a._element.type!=="pcb_trace"),r=n.filter(a=>o.some(g=>a._element.type==="pcb_trace"&&a._element.source_trace_id===g.source_trace_id&&g.max_length!==void 0));if(!e)return[...s,...r];if(n.length>1){const a=n.reduce((g,c)=>{const I=g._element.trace_length;return c._element.trace_length<I?c:g},n[0]);return[...s,a]}return A}var eti={position:"absolute",left:0,top:0,pointerEvents:"none",color:"red",fontFamily:"sans-serif",fontSize:12,textShadow:"0 0 2px black"},tti=t=>{const{_element:A,_parent_pcb_component:e,_parent_source_component:i,_source_port:n}=t;switch(A.type){case"pcb_trace":return A.trace_length?`${A.trace_length.toFixed(3)}`:"";case"pcb_smtpad":case"pcb_plated_hole":{const o=[],s=Array.from(new Set((A.port_hints??[]).concat(n?.port_hints??[]))).filter(a=>!/^[0-9]+$/.test(a)).filter(a=>!a.includes("unnamed_")).sort((a,g)=>g.localeCompare(a)),r=i&&"name"in i&&i.name&&!i.name.includes("unnamed_")?i.name:null;return s.length>0?r?o.push(...s.map(a=>`${r}.${a}`)):o.push(...s):r&&o.push(r),o.join(", ")}default:return""}},iti={top:"red",bottom:"aqua"},nti=({primitive:t,mousePos:A,elements:e})=>{const[i,n]=V.useState(!1),o=t._element;V.useEffect(()=>{setTimeout(()=>{n(!0)},100)},[]);const[s,r,a,g]=[t.screen_x,t.screen_y,t.screen_w,t.screen_h],c=t.same_space_index??0,I=26,l=iti[t?._element?.layer]??"red";let B=0;if(o.type==="pcb_smtpad"&&o?.shape==="rotated_rect"?B=o?.ccw_rotation??0:(o.type==="pcb_smtpad"&&(o?.shape==="pill"||o?.shape==="rotated_pill")&&"ccw_rotation"in t||o.type==="pcb_plated_hole"&&(o?.shape==="pill"||o?.shape==="oval")&&"ccw_rotation"in t)&&(B=o.ccw_rotation??0),o.type==="pcb_trace"){const h=$ei({primitiveElement:o,elements:e});if(!h)return null;const E=A.y-35;return W.jsx("div",{style:{zIndex:xc.elementOverlay,position:"absolute",left:A.x,top:E,color:l,pointerEvents:"none",transform:"translateX(-50%)"},children:W.jsx("div",{style:{backgroundColor:"#f2efcc",color:h.isOverLength?"red":"black",textShadow:"none",WebkitFontSmoothing:"antialiased",MozOsxFontSmoothing:"grayscale",padding:"6px 6px",borderRadius:"6px",fontSize:"14px",minWidth:"45px",textAlign:"center",whiteSpace:"nowrap"},children:h.text})})}const C=tti(t);return C.trim().length===0?null:W.jsx("div",{style:{zIndex:xc.elementOverlay,position:"absolute",left:s-a/2-8,top:r-g/2-8,width:a+16,height:g+16,color:l,transform:`rotate(${-B}deg)`,transformOrigin:"center center"},children:W.jsx("div",{style:{width:i?`calc(100% + ${I*2*c}px)`:"100%",height:i?`calc(100% + ${I*2*c}px)`:"100%",marginLeft:i?`${-I*c}px`:0,marginTop:i?`${-I*c}px`:0,border:`1px solid ${l}`,opacity:i||c===0?1:0,transition:"width 0.2s, height 0.2s, margin-left 0.2s, margin-top 0.2s, opacity 0.2s"},children:W.jsx("div",{style:{position:"absolute",bottom:g+20+I*c,marginRight:i?`${-I*c}px`:0,marginBottom:i?0:-I*c,transition:"margin-right 0.2s, margin-bottom 0.2s",backgroundColor:"#f2efcc",color:"black",textShadow:"none",WebkitFontSmoothing:"antialiased",MozOsxFontSmoothing:"grayscale",padding:"6px 6px",borderRadius:"6px",fontSize:"14px",transform:`rotate(${B}deg)`,minWidth:"45px",textAlign:"center"},children:C})})})},oti=({highlightedPrimitives:t,mousePos:A,elements:e})=>{const[i,n]=mB(r=>[r.is_moving_component,r.is_showing_multiple_traces_length]),o=t.some(r=>r._element.type==="pcb_smtpad")&&t.some(r=>r._element.type==="pcb_trace");let s=t;return o&&(s=s.filter(r=>r._element.type==="pcb_smtpad")),s=Ati({primitives:s,is_showing_multiple_traces_length:n,elements:e}),W.jsx("div",{style:eti,children:!i&&s.map((r,a)=>W.jsx(nti,{primitive:r,mousePos:A,elements:e},a))})},Tk=t=>t?.type==="pcb_component",Whe=t=>t?.type==="pcb_group",sti=t=>t?.type==="pcb_panel",pmA=t=>t?.type==="pcb_board",rI={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},cy={OFFSET_LINE:"white",COMPONENT_MARKER_FILL:"#66ccff",COMPONENT_MARKER_STROKE:"white",LABEL_TEXT:"white"},fmA=({targets:t,transform:A,containerWidth:e,containerHeight:i})=>{if(t.length===0)return null;const n={color:cy.LABEL_TEXT,mixBlendMode:"difference",pointerEvents:"none",fontSize:rI.LABEL_FONT_SIZE,fontFamily:"monospace",fontWeight:"bold"},o=new Map;return t.forEach(s=>{if(!o.has(s.anchor_id)){const r=Ce(A,s.anchor);o.set(s.anchor_id,r)}}),W.jsx("div",{style:{position:"absolute",left:0,top:0,width:e,height:i,overflow:"hidden",pointerEvents:"none",zIndex:xc.dimensionOverlay},children:W.jsxs("svg",{style:{position:"absolute",left:0,top:0,pointerEvents:"none"},width:e,height:i,children:[t.map(s=>{const r=s.anchor,a=s.anchor_id,g=s.target,c=o.get(a),I=Ce(A,g),l=g.x-r.x,B=g.y-r.y,C=Math.abs(I.x-c.x),Q=Math.abs(I.y-c.y),h=I.y<c.y,E=I.x>c.x,u=h?rI.LABEL_OFFSET_ABOVE:rI.LABEL_OFFSET_BELOW,d=E?rI.LABEL_OFFSET_RIGHT:rI.LABEL_OFFSET_LEFT,f=C>rI.MIN_LINE_LENGTH_FOR_LABEL,m=Q>rI.MIN_LINE_LENGTH_FOR_LABEL,w=`${s.display_offset_x??l.toFixed(2)}mm`,D=`${s.display_offset_y??B.toFixed(2)}mm`;return W.jsxs("g",{children:[W.jsx("line",{x1:c.x,y1:c.y,x2:I.x,y2:c.y,stroke:cy.OFFSET_LINE,strokeWidth:rI.LINE_STROKE_WIDTH,strokeDasharray:rI.LINE_DASH_PATTERN}),W.jsx("line",{x1:I.x,y1:c.y,x2:I.x,y2:I.y,stroke:cy.OFFSET_LINE,strokeWidth:rI.LINE_STROKE_WIDTH,strokeDasharray:rI.LINE_DASH_PATTERN}),s.type==="component"||s.type==="board"?W.jsx("circle",{cx:I.x,cy:I.y,r:rI.COMPONENT_MARKER_RADIUS,fill:cy.COMPONENT_MARKER_FILL,stroke:cy.COMPONENT_MARKER_STROKE,strokeWidth:1}):W.jsxs(W.Fragment,{children:[W.jsx("line",{x1:I.x-rI.ANCHOR_MARKER_SIZE,y1:I.y,x2:I.x+rI.ANCHOR_MARKER_SIZE,y2:I.y,stroke:cy.OFFSET_LINE,strokeWidth:rI.ANCHOR_MARKER_STROKE_WIDTH}),W.jsx("line",{x1:I.x,y1:I.y-rI.ANCHOR_MARKER_SIZE,x2:I.x,y2:I.y+rI.ANCHOR_MARKER_SIZE,stroke:cy.OFFSET_LINE,strokeWidth:rI.ANCHOR_MARKER_STROKE_WIDTH})]}),f&&W.jsx("foreignObject",{x:Math.min(c.x,I.x),y:c.y+u,width:Math.abs(I.x-c.x),height:20,style:{overflow:"visible"},children:W.jsx("div",{style:{...n,textAlign:"center"},children:w})}),m&&W.jsx("foreignObject",{x:I.x+d,y:Math.min(c.y,I.y),width:rI.Y_LABEL_MIN_WIDTH,height:Math.abs(I.y-c.y),style:{overflow:"visible"},children:W.jsx("div",{style:{...n,display:"flex",alignItems:"center",justifyContent:E?"flex-start":"flex-end",whiteSpace:"nowrap",padding:"0 4px",height:"100%"},children:D})})]},s.id)}),Array.from(o.entries()).map(([s,r])=>W.jsxs("g",{children:[W.jsx("line",{x1:r.x-rI.ANCHOR_MARKER_SIZE,y1:r.y,x2:r.x+rI.ANCHOR_MARKER_SIZE,y2:r.y,stroke:cy.OFFSET_LINE,strokeWidth:rI.ANCHOR_MARKER_STROKE_WIDTH}),W.jsx("line",{x1:r.x,y1:r.y-rI.ANCHOR_MARKER_SIZE,x2:r.x,y2:r.y+rI.ANCHOR_MARKER_SIZE,stroke:cy.OFFSET_LINE,strokeWidth:rI.ANCHOR_MARKER_STROKE_WIDTH})]},`anchor-${s}`))]})})},rti=({elements:t,highlightedPrimitives:A,transform:e,containerWidth:i,containerHeight:n})=>{const o=t.filter(E=>pmA(E)),s=t.filter(E=>Tk(E)),r=t.filter(E=>Whe(E)),a=A.map(E=>Tk(E._parent_pcb_component)?E._parent_pcb_component.pcb_component_id:Tk(E._element)?E._element.pcb_component_id:null).filter(E=>!!E),g=new Set;if(a.forEach(E=>{const u=s.find(d=>d.pcb_component_id===E);u?.pcb_group_id&&g.add(u.pcb_group_id)}),!mB(E=>E.is_showing_group_anchor_offsets)&&a.length===0)return null;const I=s.map(E=>{const u=E.positioned_relative_to_pcb_board_id;if(!u)return null;const d=o.find(f=>f.pcb_board_id===u);return d?{component:E,board:d,type:"component"}:null}).filter(E=>!!E),l=r.map(E=>{const u=E.positioned_relative_to_pcb_board_id;if(!u||!E.center)return null;const d=o.find(f=>f.pcb_board_id===u);return d?{group:E,board:d,type:"group"}:null}).filter(E=>!!E),B=[...I,...l];if(B.length===0)return null;const C=a.length===0,Q=B.filter(E=>E.type==="component"?C||a.includes(E.component.pcb_component_id):C||g.has(E.group.pcb_group_id));if(Q.length===0)return null;const h=Q.map(E=>E.type==="component"?{id:`${E.board.pcb_board_id}-${E.component.pcb_component_id}-${E.type}`,anchor:E.board.center,anchor_id:E.board.pcb_board_id,target:E.component.center,type:"component",display_offset_x:E.component.display_offset_x,display_offset_y:E.component.display_offset_y}:{id:`${E.board.pcb_board_id}-${E.group.pcb_group_id}-${E.type}`,anchor:E.board.center,anchor_id:E.board.pcb_board_id,target:{x:E.group.anchor_position?.x??E.group.center.x,y:E.group.anchor_position?.y??E.group.center.y},type:"group",display_offset_x:E.group.display_offset_x,display_offset_y:E.group.display_offset_y}).filter(E=>!!E);return W.jsx(fmA,{targets:h,transform:e,containerWidth:i,containerHeight:n})},ati=({elements:t,highlightedPrimitives:A,transform:e,containerWidth:i,containerHeight:n})=>{const o=t.filter(E=>Whe(E)),s=t.filter(E=>Tk(E)),r=A.map(E=>Tk(E._parent_pcb_component)?E._parent_pcb_component.pcb_component_id:Tk(E._element)?E._element.pcb_component_id:null).filter(E=>!!E),a=(E,u)=>{if(u.has(E))return;u.add(E);const d=o.find(f=>f.pcb_group_id===E);d?.position_mode==="relative_to_group_anchor"&&d.positioned_relative_to_pcb_group_id&&a(d.positioned_relative_to_pcb_group_id,u)},g=new Set;if(r.forEach(E=>{const u=s.find(d=>d.pcb_component_id===E);u&&(u.position_mode==="relative_to_group_anchor"&&u.positioned_relative_to_pcb_group_id&&a(u.positioned_relative_to_pcb_group_id,g),u.pcb_group_id&&a(u.pcb_group_id,g))}),!mB(E=>E.is_showing_group_anchor_offsets)&&r.length===0)return null;const I=s.map(E=>{if(E.position_mode==="relative_to_group_anchor"&&E.positioned_relative_to_pcb_group_id){const u=o.find(d=>d.pcb_group_id===E.positioned_relative_to_pcb_group_id);return u&&u.anchor_position?{component:E,parentGroup:u,type:"component"}:null}if(E.pcb_group_id){const u=o.find(d=>d.pcb_group_id===E.pcb_group_id);return u&&u.anchor_position?{component:E,parentGroup:u,type:"component"}:null}return null}).filter(E=>!!E),l=o.map(E=>{if(E.position_mode==="relative_to_group_anchor"&&E.positioned_relative_to_pcb_group_id){const u=o.find(d=>d.pcb_group_id===E.positioned_relative_to_pcb_group_id);if(u&&u.anchor_position&&E.anchor_position)return{group:E,parentGroup:u,type:"group"}}return null}).filter(E=>!!E),B=[...I,...l];if(B.length===0)return null;const C=r.length===0,Q=B.filter(E=>E.type==="component"?C||r.includes(E.component.pcb_component_id):C||g.has(E.group.pcb_group_id)||g.has(E.parentGroup.pcb_group_id));if(Q.length===0)return null;const h=Q.map(E=>{const u=E.parentGroup.anchor_position;return u?E.type==="component"?E.component.center?{id:`${E.parentGroup.pcb_group_id}-${E.component.pcb_component_id}-${E.type}`,anchor:u,anchor_id:E.parentGroup.pcb_group_id,target:E.component.center,type:"component",display_offset_x:E.component.display_offset_x,display_offset_y:E.component.display_offset_y}:null:E.group.anchor_position?{id:`${E.parentGroup.pcb_group_id}-${E.group.pcb_group_id}-${E.type}`,anchor:u,anchor_id:E.parentGroup.pcb_group_id,target:E.group.anchor_position,type:"group",display_offset_x:E.group.display_offset_x,display_offset_y:E.group.display_offset_y}:null:null}).filter(E=>!!E);return W.jsx(fmA,{targets:h,transform:e,containerWidth:i,containerHeight:n})},gti=(t,A)=>{const e=t.pcb_component_id,i=A.filter(n=>(n.type==="pcb_smtpad"||n.type==="pcb_plated_hole")&&n.pcb_component_id===e||n.type==="pcb_hole"&&n.pcb_component_id===e);return i.length===0?hmA([t]):hmA(i)},cti=({elements:t,highlightedPrimitives:A,transform:e,containerWidth:i,containerHeight:n})=>{const o=new Map;for(const r of A)Tk(r._parent_pcb_component)&&o.set(r._parent_pcb_component.pcb_component_id,r._parent_pcb_component),Tk(r._element)&&o.set(r._element.pcb_component_id,r._element);if(o.size===0)return null;const s=[];for(const r of o.values()){const a=gti(r,t);if(!a)continue;const g=r.positioned_relative_to_pcb_group_id??r.pcb_group_id,c=g?nx(t).pcb_group.get(g):null;s.push({component:r,bbox:a,group:c})}return s.length===0?null:W.jsx("div",{style:{position:"absolute",left:0,top:0,width:i,height:n,overflow:"hidden",pointerEvents:"none",zIndex:xc.dimensionOverlay},children:W.jsx("svg",{style:{position:"absolute",left:0,top:0,pointerEvents:"none"},width:i,height:n,children:s.map(({component:r,bbox:a,group:g})=>{const c=Ce(e,{x:a.minX,y:a.maxY}),I=Ce(e,{x:a.maxX,y:a.minY}),l={x:Math.min(c.x,I.x),y:Math.min(c.y,I.y),width:Math.abs(I.x-c.x),height:Math.abs(I.y-c.y)},B=r.center??{x:(a.minX+a.maxX)/2,y:(a.minY+a.maxY)/2},C=Ce(e,B);return W.jsxs("g",{children:[W.jsx("rect",{x:l.x,y:l.y,width:l.width,height:l.height,fill:"none",stroke:"white",strokeWidth:1.5,strokeDasharray:"4,4"}),W.jsx("line",{x1:C.x-6,y1:C.y,x2:C.x+6,y2:C.y,stroke:cy.COMPONENT_MARKER_STROKE,strokeWidth:1.5}),W.jsx("line",{x1:C.x,y1:C.y-6,x2:C.x,y2:C.y+6,stroke:cy.COMPONENT_MARKER_STROKE,strokeWidth:1.5}),W.jsx("circle",{cx:C.x,cy:C.y,r:rI.COMPONENT_MARKER_RADIUS,fill:cy.COMPONENT_MARKER_FILL,stroke:cy.COMPONENT_MARKER_STROKE,strokeWidth:1})]},r.pcb_component_id)})})})},Iti=({elements:t,highlightedPrimitives:A,transform:e,containerWidth:i,containerHeight:n})=>{const o=t.filter(B=>sti(B)),s=t.filter(B=>pmA(B)),r=A.map(B=>pmA(B._element)?B._element.pcb_board_id:null).filter(B=>!!B);if(!mB(B=>B.is_showing_group_anchor_offsets)&&r.length===0)return null;const g=s.map(B=>{const C=B.pcb_panel_id,Q=B.position_mode;if(!C||Q!=="relative_to_panel_anchor")return null;const h=o.find(E=>E.pcb_panel_id===C);return h?{board:B,panel:h,type:"board"}:null}).filter(B=>!!B);if(g.length===0)return null;const c=r.length===0,I=g.filter(B=>c||r.includes(B.board.pcb_board_id));if(I.length===0)return null;const l=I.map(B=>B.board.center?{id:`${B.panel.pcb_panel_id}-${B.board.pcb_board_id}-${B.type}`,anchor:B.panel.center,anchor_id:B.panel.pcb_panel_id,target:B.board.center,type:"board",display_offset_x:B.board.display_offset_x,display_offset_y:B.board.display_offset_y}:null).filter(B=>!!B);return W.jsx(fmA,{targets:l,transform:e,containerWidth:i,containerHeight:n})},Fz=t=>{if(t.length===0)return null;let A=t[0].x,e=t[0].y,i=t[0].x,n=t[0].y;for(const o of t)o.x<A&&(A=o.x),o.y<e&&(e=o.y),o.x>i&&(i=o.x),o.y>n&&(n=o.y);return{center:{x:(A+i)/2,y:(e+n)/2},width:i-A,height:n-e}},Zhe=(t,A)=>{if(A.length<3)return!1;let e=!1;for(let i=0,n=A.length-1;i<A.length;n=i++){const o=A[i].x,s=A[i].y,r=A[n].x,a=A[n].y;s>t.y!=a>t.y&&t.x<(r-o)*(t.y-s)/(a-s||Number.EPSILON)+o&&(e=!e)}return e},lti=(t,A,e)=>{const i=[];for(const n of t){if(!n._element)continue;if("x1"in n&&n._element?.type==="pcb_trace"){const r=HE({x:A.x,y:A.y},{x:n.x1,y:n.y1},{x:n.x2,y:n.y2}),a=n.width||.5,g=Math.max(a*25,2)/e.a;r<g&&i.push(n);continue}if(n.pcb_drawing_type==="polygon"){const r=n.points.map(g=>({x:Et.parse(g.x),y:Et.parse(g.y)})),a=Fz(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;Zhe(A,r)&&i.push(n);continue}if(n.pcb_drawing_type==="polygon_with_arcs"){const r=n.brep_shape.outer_ring.vertices.map(g=>({x:Et.parse(g.x),y:Et.parse(g.y)})),a=Fz(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;Zhe(A,r)&&i.push(n);continue}if(!("x"in n&&"y"in n))continue;let o=0,s=0;if("w"in n&&"h"in n)o=n.w,s=n.h;else if("r"in n)o=n.r*2,s=n.r*2;else if("rX"in n&&"rY"in n)o=n.rX*2,s=n.rY*2;else continue;Math.abs(n.x-A.x)<o/2&&Math.abs(n.y-A.y)<s/2&&i.push(n)}return i},Bti=({elements:t,children:A,transform:e,primitives:i,onMouseHoverOverPrimitives:n})=>{const[o,s]=V.useState([]),[r,a]=V.useState({x:0,y:0}),[g,{width:c,height:I}]=KT(),l=V.useMemo(()=>{const C=[];for(const Q of o){if(Q._element?.type==="pcb_via"||Q._element?.type==="pcb_component"||Q?.layer==="drill")continue;let h=null,E=0,u=0;if(Q.pcb_drawing_type==="polygon"){const w=Fz(Q.points);if(!w)continue;h=w.center,E=w.width,u=w.height}else if(Q.pcb_drawing_type==="polygon_with_arcs"){const w=Q.brep_shape.outer_ring.vertices.map(S=>({x:S.x,y:S.y})),D=Fz(w);if(!D)continue;h=D.center,E=D.width,u=D.height}else"x"in Q&&"y"in Q&&(h={x:Q.x,y:Q.y},E="w"in Q?Q.w:"r"in Q?Q.r*2:"rX"in Q&&"rY"in Q?Q.rX*2:0,u="h"in Q?Q.h:"r"in Q?Q.r*2:"rX"in Q&&"rY"in Q?Q.rY*2:0);if(!h)continue;const d=Ce(e,h),f={w:E*e.a,h:u*e.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({...Q,x:h.x,y:h.y,w:E,h:u,screen_x:d.x,screen_y:d.y,screen_w:f.w,screen_h:f.h,same_space_index:m})}return C},[o,e]),B=(C,Q,h,E)=>{a({x:C,y:Q});const u=Ce(Am(h),{x:C,y:Q}),d=lti(E,u,h);Xei(new Set(d.map(f=>f._pcb_drawing_object_id)),new Set(o.map(f=>f._pcb_drawing_object_id)))||(s(d),n(d))};return W.jsxs("div",{ref:g,style:{position:"relative",width:"100%",height:"100%"},onMouseMove:C=>{if(e){const Q=C.currentTarget.getBoundingClientRect(),h=C.clientX-Q.left,E=C.clientY-Q.top;B(h,E,e,i)}},onTouchStart:C=>{if(e){const Q=C.touches[0],h=C.currentTarget.getBoundingClientRect(),E=Q.clientX-h.left,u=Q.clientY-h.top;B(E,u,e,i)}},children:[A,W.jsx(oti,{elements:t,mousePos:r,highlightedPrimitives:l}),e&&W.jsxs(W.Fragment,{children:[W.jsx(rti,{elements:t,highlightedPrimitives:l,transform:e,containerWidth:c,containerHeight:I}),W.jsx(ati,{elements:t,highlightedPrimitives:l,transform:e,containerWidth:c,containerHeight:I}),W.jsx(cti,{elements:t,highlightedPrimitives:l,transform:e,containerWidth:c,containerHeight:I}),W.jsx(Iti,{elements:t,highlightedPrimitives:l,transform:e,containerWidth:c,containerHeight:I})]})]})},Vhe=["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)"],Cti=({children:t,transform:A=xa(),elements:e=[],hoveredComponentIds:i=[]})=>{const[n,{width:o,height:s}]=KT(),r=V.useRef(null),{is_showing_pcb_groups:a,pcb_group_view_mode:g,is_showing_group_anchor_offsets:c}=mB(I=>({is_showing_pcb_groups:I.is_showing_pcb_groups,pcb_group_view_mode:I.pcb_group_view_mode,is_showing_group_anchor_offsets:I.is_showing_group_anchor_offsets}));return V.useEffect(()=>{const I=r.current;if(!I||!o||!s)return;I.width=o,I.height=s;const l=I.getContext("2d");if(!l||(l.clearRect(0,0,o,s),!a))return;const B=e.filter(w=>w.type==="pcb_group"),C=e.filter(w=>w.type==="pcb_component"),Q=e.filter(w=>w.type==="source_group"),h=new Map(Q.map(w=>[w.source_group_id,w])),E=B.filter(w=>{if(w.name?.toLowerCase().includes("subpanel"))return!1;if(g==="all")return!0;if(!w.source_group_id)return!1;const D=h.get(w.source_group_id);return D?D.was_automatically_named!==!0:!1}),u=new Map;Q.forEach(w=>{const D=w;if(D.parent_source_group_id){const S=u.get(D.parent_source_group_id)||[];S.push(w.source_group_id),u.set(D.parent_source_group_id,S)}});const d=w=>{const D=[],S=u.get(w)||[];for(const _ of S)D.push(_),D.push(...d(_));return D},f=w=>{const D=Q.find(S=>S.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)}E.forEach((w,D)=>{let S=C.filter(YA=>YA.pcb_group_id===w.pcb_group_id);if(w.source_group_id){const YA=d(w.source_group_id),jA=B.filter(kA=>kA.source_group_id&&YA.includes(kA.source_group_id));for(const kA of jA){const wA=C.filter(GA=>GA.pcb_group_id===kA.pcb_group_id);S=[...S,...wA]}}let _,b,N,F,L=!1;if(w.center&&w.width&&w.height){L=!0;const YA=w.width/2,jA=w.height/2;_=w.center.x-YA,N=w.center.x+YA,b=w.center.y-jA,F=w.center.y+jA}else if(S.length===0||(_=1/0,b=1/0,N=-1/0,F=-1/0,S.forEach(YA=>{if(YA.center&&typeof YA.width=="number"&&typeof YA.height=="number"){const jA=YA.center.x-YA.width/2,kA=YA.center.x+YA.width/2,wA=YA.center.y+YA.height/2,GA=YA.center.y-YA.height/2;_=Math.min(_,jA),N=Math.max(N,kA),b=Math.min(b,GA),F=Math.max(F,wA)}}),_===1/0||N===-1/0))return;const Y=w.source_group_id?f(w.source_group_id):0,J=w.source_group_id?d(w.source_group_id).length>0:!1;if(!L){const kA=1+(J?.5:0);_-=kA,N+=kA,b-=kA,F+=kA}const q=Ce(A,{x:_,y:F}),Z=Ce(A,{x:N,y:F}),X=Ce(A,{x:_,y:b}),eA=Ce(A,{x:N,y:b}),gA=Vhe[D%Vhe.length];l.strokeStyle=gA,l.lineWidth=2;const iA=Math.max(4,Math.min(12,8*Math.abs(A.a))),tA=Math.max(2,Math.min(6,4*Math.abs(A.a))),aA=iA*(J?1.3:1),hA=tA;l.setLineDash([aA,hA]),l.beginPath(),l.moveTo(q.x,q.y),l.lineTo(Z.x,Z.y),l.lineTo(eA.x,eA.y),l.lineTo(X.x,X.y),l.closePath(),l.stroke();const bA=Math.max(8,Math.min(12,10*Math.abs(A.a))),_A=Y==0||Y==1?0:Y*.11,HA=bA*(1-_A),QA=4,xA=w.name||`Group ${D+1}`;l.font=`${HA}px sans-serif`,l.setLineDash([]);const qA=l.measureText(xA).width+QA*2,VA=HA+QA*2,ce=q.x-5,fA=q.y-5,ge=3;if(l.fillStyle="rgba(0, 0, 0, 0.8)",l.beginPath(),l.roundRect(ce,fA-VA,qA,VA,ge),l.fill(),l.fillStyle=gA,l.textAlign="left",l.textBaseline="middle",l.fillText(xA,ce+QA,fA-VA/2),c&&m.has(w.pcb_group_id)&&!!w.anchor_position&&w.anchor_position){const YA=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},jA=Ce(A,YA);l.strokeStyle="white",l.lineWidth=1.5,l.setLineDash([]);const kA=Math.max(4,Math.min(8,6*Math.abs(A.a)));l.beginPath(),l.moveTo(jA.x-kA,jA.y),l.lineTo(jA.x+kA,jA.y),l.stroke(),l.beginPath(),l.moveTo(jA.x,jA.y-kA),l.lineTo(jA.x,jA.y+kA),l.stroke()}})},[e,A,o,s,a,g,c,i]),W.jsxs("div",{ref:n,style:{position:"relative",width:"100%",height:"100%"},children:[t,W.jsx("canvas",{ref:r,style:{position:"absolute",top:0,left:0,pointerEvents:"none",zIndex:xc.pcbGroupOverlay,display:a?"block":"none"}})]})},Qti=({transform:t,soup:A,children:e})=>{const i=mB(r=>r.is_showing_rats_nest),{netMap:n,idToNetMap:o}=V.useMemo(()=>She(A||[]),[A]),s=V.useMemo(()=>{if(!A||!i)return[];const r=l=>{const B=nx(A)[l.replace(/_\d+$/,"")].get(l);return B&&"x"in B&&"y"in B?{x:B.x,y:B.y}:null},a=(l,B)=>{const C=n[B]||[];let Q=null,h=1/0;return C.forEach(E=>{const u=r(E);if(u){const d=Math.sqrt((l.x-u.x)**2+(l.y-u.y)**2);d<h&&d>0&&(h=d,Q=u)}}),Q},g=nx(A).pcb_port.list(),c=nx(A).source_trace.list(),I=[];return g.forEach((l,B)=>{const C=o[l.pcb_port_id];let Q=!1;for(const u of c)u.connected_source_port_ids.includes(l.source_port_id)&&u.connected_source_net_ids.length>0&&(Q=!0);if(!C)return;const h={x:l.x,y:l.y},E=a(h,C);E&&I.push({key:`${l.pcb_port_id}-${B}`,startPoint:h,endPoint:E,isInNet:Q})}),I},[A,n,o,i]);return!A||!i?e:(t||(t=xa()),W.jsxs("div",{style:{position:"relative"},children:[e,W.jsx("svg",{style:{position:"absolute",left:0,top:0,width:"100%",height:"100%",pointerEvents:"none",opacity:.5,zIndex:xc.ratsNestOverlay},children:s.map(({key:r,startPoint:a,endPoint:g,isInNet:c})=>{const I=Ce(t,a),l=Ce(t,g);return W.jsx("line",{x1:I.x,y1:I.y,x2:l.x,y2:l.y,stroke:"white",strokeWidth:"1",strokeDasharray:c?"6,6":void 0},r)})})]}))},hti={version:"1.11.349"},Pk=(t,A,e)=>{const i=mB(s=>s.is_mouse_over_container),n=V.useRef(i),o=V.useRef(A);V.useEffect(()=>{n.current=i},[i]),V.useEffect(()=>{o.current=A},[A]),V.useEffect(()=>{if(!t)return;const s=r=>{const a=r.target;if(a.tagName==="INPUT"||a.tagName==="TEXTAREA"||a.isContentEditable)return;const g=t.split("+"),c=g.includes("ctrl"),I=g.includes("shift"),l=g.includes("alt"),B=g.includes("meta"),C=g[g.length-1],Q=e?.current?e.current.contains(document.activeElement)||document.activeElement===e.current:!1;(n.current||Q)&&(!c||r.ctrlKey)&&(!I||r.shiftKey)&&(!l||r.altKey)&&(!B||r.metaKey)&&r.key.toLowerCase()===C.toLowerCase()&&(r.preventDefault(),o.current())};return window.addEventListener("keydown",s),()=>{window.removeEventListener("keydown",s)}},[t])},Eti=()=>{const[t,A]=V.useState(!1);return V.useEffect(()=>{const e=()=>{A(window.innerWidth<=768)};return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]),t},OT=(t,A={stopPropagation:!0})=>{const e=V.useRef(0),i=V.useCallback(s=>{A.stopPropagation&&s.stopPropagation();const r=Date.now();r-e.current<300||(e.current=r,t?.(s))},[t,A.stopPropagation]),n=V.useCallback(s=>{s.preventDefault(),i(s)},[i]);return{onClick:i,onTouchEnd:n,style:{touchAction:"manipulation"}}},uti=({name:t,selected:A,onClick:e})=>{const{style:i,...n}=OT(e);return W.jsxs("div",{className:y2`
5475
+ `,zei=({children:t,transform:A=xa(),elements:e})=>{const i=V.useRef(null),{isShowingDRCErrors:n,hoveredErrorId:o}=mB(g=>({isShowingDRCErrors:g.is_showing_drc_errors,hoveredErrorId:g.hovered_error_id}));if(!e)return W.jsx("div",{style:{position:"relative"},ref:i,children:t});const s=e.filter(g=>g.type==="pcb_trace_error"),r=e.filter(g=>g.type==="pcb_trace_error"&&g.message?.includes("Multiple components found with name")),a=new Map;return e.forEach(g=>{g.type==="pcb_port"&&a.set(g.pcb_port_id,g)}),W.jsxs("div",{style:{position:"relative"},ref:i,children:[t,s.map((g,c)=>{const{pcb_port_ids:I,pcb_trace_id:l}=g,B=I?.[0]?a.get(I[0]):void 0,C=I?.[1]?a.get(I[1]):void 0,Q=e?nx(e).pcb_trace.get(l):void 0,h=g.pcb_trace_error_id||`error_${c}_${g.error_type}_${g.message?.slice(0,20)}`,E=o===h;if(B&&C){const u=Ce(A,{x:B.x,y:B.y}),d=Ce(A,{x:C.x,y:C.y});if(!n)return null;const 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=umA(m,i);return W.jsxs(V.Fragment,{children:[W.jsx(Vei,{screenPort1:u,screenPort2:d,errorCenter:m,canLineBeDrawn:f,isHighlighted:E}),W.jsx("div",{style:{position:"absolute",left:m.x-15,top:m.y-15,width:30,height:30,zIndex:xc.errorOverlay+5,cursor:"pointer",borderRadius:"50%"},onMouseEnter:D=>{const S=D.currentTarget.nextElementSibling;if(S){const _=S.querySelector(".error-message");_&&(_.style.opacity="1")}},onMouseLeave:D=>{if(!E){const S=D.currentTarget.nextElementSibling;if(S){const _=S.querySelector(".error-message");_&&(_.style.opacity="0")}}}}),W.jsx("div",{style:{position:"absolute",zIndex:E?200:100,left:w.left,top:w.top,color:E?"#ff4444":"red",textAlign:"center",fontFamily:"sans-serif",fontSize:12,display:n||E?"flex":"none",flexDirection:"column",alignItems:"center",pointerEvents:"none",transform:w.transform},children:W.jsx("div",{className:`error-message ${dmA}`,style:{opacity:E?1:0,border:`1px solid ${E?"#ff4444":"red"}`},children:g.message})})]},h)}if(Q?.route&&(n||E)){const u=Q.route.map(w=>Ce(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=umA(f,i);return W.jsxs(V.Fragment,{children:[W.jsx(jei,{points:u,errorCenter:f,isHighlighted:E}),W.jsx("div",{style:{position:"absolute",left:f.x-15,top:f.y-15,width:30,height:30,zIndex:xc.errorOverlay+5,cursor:"pointer",borderRadius:"50%"},onMouseEnter:w=>{const D=w.currentTarget.nextElementSibling;if(D){const S=D.querySelector(".error-message");S&&(S.style.opacity="1")}},onMouseLeave:w=>{if(!E){const D=w.currentTarget.nextElementSibling;if(D){const S=D.querySelector(".error-message");S&&(S.style.opacity="0")}}}}),W.jsx("div",{style:{position:"absolute",zIndex:E?xc.errorOverlay+10:xc.errorOverlay+1,left:m.left,top:m.top,color:E?"#ff4444":"red",textAlign:"center",fontFamily:"sans-serif",fontSize:12,display:"flex",flexDirection:"column",alignItems:"center",pointerEvents:"none",transform:m.transform},children:W.jsx("div",{className:`error-message ${dmA}`,style:{opacity:E?1:0,border:`1px solid ${E?"#ff4444":"red"}`},children:g.message})})]},h)}return null}),r.map((g,c)=>{const I=g.component_name||g.message?.match(/name "([^"]+)"/)?.[1];if(!I)return null;const l=e?.filter(Q=>Q.type==="source_component"&&Q.name===I||Q.type==="pcb_component"&&e?.find(h=>h.type==="source_component"&&h.source_component_id===Q.source_component_id&&h.name===I))||[],B=g.pcb_trace_error_id||`error_${c}_${g.error_type}_${g.message?.slice(0,20)}`,C=o===B;return!C&&!n?null:l.map((Q,h)=>{let E={x:0,y:0};if(Q.type==="pcb_component")E=Q.center||{x:0,y:0};else if(Q.type==="source_component"){const _=e?.find(b=>b.type==="pcb_component"&&b.source_component_id===Q.source_component_id);_&&_.type==="pcb_component"&&(E=_.center||{x:0,y:0})}const u=Ce(A,E);if(isNaN(u.x)||isNaN(u.y))return null;const d=Math.abs(A.a),D=Math.max(8,Math.min(30,.5*d)),S=umA(u,i);return W.jsxs(V.Fragment,{children:[W.jsx("svg",{style:{position:"absolute",left:0,top:0,pointerEvents:"none",mixBlendMode:"difference",zIndex:xc.errorOverlay},width:"100%",height:"100%",children:C?W.jsx("polygon",{points:`${u.x},${u.y-D*1.25} ${u.x+D},${u.y} ${u.x},${u.y+D*1.25} ${u.x-D},${u.y}`,fill:"#ff4444"}):W.jsx("circle",{cx:u.x,cy:u.y,r:D,fill:"none",stroke:C?"#ff4444":"red",strokeWidth:C?Math.max(2,D*.15):Math.max(1,D*.1),opacity:1})}),W.jsx("div",{style:{position:"absolute",left:u.x-(D+10),top:u.y-(D+10),width:(D+10)*2,height:(D+10)*2,zIndex:xc.errorOverlay+5,cursor:"pointer",borderRadius:"50%"},onMouseEnter:_=>{const b=_.currentTarget.nextElementSibling;if(b){const N=b.querySelector(".error-message");N&&(N.style.opacity="1")}},onMouseLeave:_=>{if(!C){const b=_.currentTarget.nextElementSibling;if(b){const N=b.querySelector(".error-message");N&&(N.style.opacity="0")}}}}),W.jsx("div",{style:{position:"absolute",zIndex:C?xc.errorOverlay+20:xc.errorOverlay+10,left:S.left,top:S.top,color:C?"#ff4444":"red",textAlign:"center",fontFamily:"sans-serif",fontSize:12,display:n||C?"flex":"none",flexDirection:"column",alignItems:"center",pointerEvents:"none",transform:S.transform},children:W.jsx("div",{className:`error-message ${dmA}`,style:{opacity:C?1:0,border:`1px solid ${C?"#ff4444":"red"}`},children:g.message})})]},`${B}_${h}`)})})]})};function Xei(t,A){return t.size!==A.size?!1:Array.from(t).every(e=>A.has(e))}function $ei({primitiveElement:t,elements:A}){let e=t.trace_length?`${t.trace_length.toFixed(3)}`:"";const i=nx(A).source_trace.get(t?.source_trace_id);if(i?.display_name&&(i?.max_length?e+=` / ${i.max_length}mm `:e+=" mm ",e+=`(${i.display_name})`),!e)return null;const n=t.trace_length&&i?.max_length&&t.trace_length>i.max_length;return{text:e,isOverLength:n}}function Ati(t){const{primitives:A,is_showing_multiple_traces_length:e,elements:i}=t,n=A.filter(a=>a._element.type==="pcb_trace"),o=i.filter(a=>a.type==="source_trace"),s=A.filter(a=>a._element.type!=="pcb_trace"),r=n.filter(a=>o.some(g=>a._element.type==="pcb_trace"&&a._element.source_trace_id===g.source_trace_id&&g.max_length!==void 0));if(!e)return[...s,...r];if(n.length>1){const a=n.reduce((g,c)=>{const I=g._element.trace_length;return c._element.trace_length<I?c:g},n[0]);return[...s,a]}return A}var eti={position:"absolute",left:0,top:0,pointerEvents:"none",color:"red",fontFamily:"sans-serif",fontSize:12,textShadow:"0 0 2px black"},tti=t=>{const{_element:A,_parent_pcb_component:e,_parent_source_component:i,_source_port:n}=t;switch(A.type){case"pcb_trace":return A.trace_length?`${A.trace_length.toFixed(3)}`:"";case"pcb_smtpad":case"pcb_plated_hole":{const o=[],s=Array.from(new Set((A.port_hints??[]).concat(n?.port_hints??[]))).filter(a=>!/^[0-9]+$/.test(a)).filter(a=>!a.includes("unnamed_")).sort((a,g)=>g.localeCompare(a)),r=i&&"name"in i&&i.name&&!i.name.includes("unnamed_")?i.name:null;return s.length>0?r?o.push(...s.map(a=>`${r}.${a}`)):o.push(...s):r&&o.push(r),o.join(", ")}default:return""}},iti={top:"red",bottom:"aqua"},nti=({primitive:t,mousePos:A,elements:e})=>{const[i,n]=V.useState(!1),o=t._element;V.useEffect(()=>{setTimeout(()=>{n(!0)},100)},[]);const[s,r,a,g]=[t.screen_x,t.screen_y,t.screen_w,t.screen_h],c=t.same_space_index??0,I=26,l=iti[t?._element?.layer]??"red";let B=0;if(o.type==="pcb_smtpad"&&o?.shape==="rotated_rect"?B=o?.ccw_rotation??0:(o.type==="pcb_smtpad"&&(o?.shape==="pill"||o?.shape==="rotated_pill")&&"ccw_rotation"in t||o.type==="pcb_plated_hole"&&(o?.shape==="pill"||o?.shape==="oval")&&"ccw_rotation"in t)&&(B=o.ccw_rotation??0),o.type==="pcb_trace"){const h=$ei({primitiveElement:o,elements:e});if(!h)return null;const E=A.y-35;return W.jsx("div",{style:{zIndex:xc.elementOverlay,position:"absolute",left:A.x,top:E,color:l,pointerEvents:"none",transform:"translateX(-50%)"},children:W.jsx("div",{style:{backgroundColor:"#f2efcc",color:h.isOverLength?"red":"black",textShadow:"none",WebkitFontSmoothing:"antialiased",MozOsxFontSmoothing:"grayscale",padding:"6px 6px",borderRadius:"6px",fontSize:"14px",minWidth:"45px",textAlign:"center",whiteSpace:"nowrap"},children:h.text})})}const C=tti(t);return C.trim().length===0?null:W.jsx("div",{style:{zIndex:xc.elementOverlay,position:"absolute",left:s-a/2-8,top:r-g/2-8,width:a+16,height:g+16,color:l,transform:`rotate(${-B}deg)`,transformOrigin:"center center"},children:W.jsx("div",{style:{width:i?`calc(100% + ${I*2*c}px)`:"100%",height:i?`calc(100% + ${I*2*c}px)`:"100%",marginLeft:i?`${-I*c}px`:0,marginTop:i?`${-I*c}px`:0,border:`1px solid ${l}`,opacity:i||c===0?1:0,transition:"width 0.2s, height 0.2s, margin-left 0.2s, margin-top 0.2s, opacity 0.2s"},children:W.jsx("div",{style:{position:"absolute",bottom:g+20+I*c,marginRight:i?`${-I*c}px`:0,marginBottom:i?0:-I*c,transition:"margin-right 0.2s, margin-bottom 0.2s",backgroundColor:"#f2efcc",color:"black",textShadow:"none",WebkitFontSmoothing:"antialiased",MozOsxFontSmoothing:"grayscale",padding:"6px 6px",borderRadius:"6px",fontSize:"14px",transform:`rotate(${B}deg)`,minWidth:"45px",textAlign:"center"},children:C})})})},oti=({highlightedPrimitives:t,mousePos:A,elements:e})=>{const[i,n]=mB(r=>[r.is_moving_component,r.is_showing_multiple_traces_length]),o=t.some(r=>r._element.type==="pcb_smtpad")&&t.some(r=>r._element.type==="pcb_trace");let s=t;return o&&(s=s.filter(r=>r._element.type==="pcb_smtpad")),s=Ati({primitives:s,is_showing_multiple_traces_length:n,elements:e}),W.jsx("div",{style:eti,children:!i&&s.map((r,a)=>W.jsx(nti,{primitive:r,mousePos:A,elements:e},a))})},Tk=t=>t?.type==="pcb_component",Whe=t=>t?.type==="pcb_group",sti=t=>t?.type==="pcb_panel",pmA=t=>t?.type==="pcb_board",rI={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},cy={OFFSET_LINE:"white",COMPONENT_MARKER_FILL:"#66ccff",COMPONENT_MARKER_STROKE:"white",LABEL_TEXT:"white"},fmA=({targets:t,transform:A,containerWidth:e,containerHeight:i})=>{if(t.length===0)return null;const n={color:cy.LABEL_TEXT,mixBlendMode:"difference",pointerEvents:"none",fontSize:rI.LABEL_FONT_SIZE,fontFamily:"monospace",fontWeight:"bold"},o=new Map;return t.forEach(s=>{if(!o.has(s.anchor_id)){const r=Ce(A,s.anchor);o.set(s.anchor_id,r)}}),W.jsx("div",{style:{position:"absolute",left:0,top:0,width:e,height:i,overflow:"hidden",pointerEvents:"none",zIndex:xc.dimensionOverlay},children:W.jsxs("svg",{style:{position:"absolute",left:0,top:0,pointerEvents:"none"},width:e,height:i,children:[t.map(s=>{const r=s.anchor,a=s.anchor_id,g=s.target,c=o.get(a),I=Ce(A,g),l=g.x-r.x,B=g.y-r.y,C=Math.abs(I.x-c.x),Q=Math.abs(I.y-c.y),h=I.y<c.y,E=I.x>c.x,u=h?rI.LABEL_OFFSET_ABOVE:rI.LABEL_OFFSET_BELOW,d=E?rI.LABEL_OFFSET_RIGHT:rI.LABEL_OFFSET_LEFT,f=C>rI.MIN_LINE_LENGTH_FOR_LABEL,m=Q>rI.MIN_LINE_LENGTH_FOR_LABEL,w=`${s.display_offset_x??l.toFixed(2)}mm`,D=`${s.display_offset_y??B.toFixed(2)}mm`;return W.jsxs("g",{children:[W.jsx("line",{x1:c.x,y1:c.y,x2:I.x,y2:c.y,stroke:cy.OFFSET_LINE,strokeWidth:rI.LINE_STROKE_WIDTH,strokeDasharray:rI.LINE_DASH_PATTERN}),W.jsx("line",{x1:I.x,y1:c.y,x2:I.x,y2:I.y,stroke:cy.OFFSET_LINE,strokeWidth:rI.LINE_STROKE_WIDTH,strokeDasharray:rI.LINE_DASH_PATTERN}),s.type==="component"||s.type==="board"?W.jsx("circle",{cx:I.x,cy:I.y,r:rI.COMPONENT_MARKER_RADIUS,fill:cy.COMPONENT_MARKER_FILL,stroke:cy.COMPONENT_MARKER_STROKE,strokeWidth:1}):W.jsxs(W.Fragment,{children:[W.jsx("line",{x1:I.x-rI.ANCHOR_MARKER_SIZE,y1:I.y,x2:I.x+rI.ANCHOR_MARKER_SIZE,y2:I.y,stroke:cy.OFFSET_LINE,strokeWidth:rI.ANCHOR_MARKER_STROKE_WIDTH}),W.jsx("line",{x1:I.x,y1:I.y-rI.ANCHOR_MARKER_SIZE,x2:I.x,y2:I.y+rI.ANCHOR_MARKER_SIZE,stroke:cy.OFFSET_LINE,strokeWidth:rI.ANCHOR_MARKER_STROKE_WIDTH})]}),f&&W.jsx("foreignObject",{x:Math.min(c.x,I.x),y:c.y+u,width:Math.abs(I.x-c.x),height:20,style:{overflow:"visible"},children:W.jsx("div",{style:{...n,textAlign:"center"},children:w})}),m&&W.jsx("foreignObject",{x:I.x+d,y:Math.min(c.y,I.y),width:rI.Y_LABEL_MIN_WIDTH,height:Math.abs(I.y-c.y),style:{overflow:"visible"},children:W.jsx("div",{style:{...n,display:"flex",alignItems:"center",justifyContent:E?"flex-start":"flex-end",whiteSpace:"nowrap",padding:"0 4px",height:"100%"},children:D})})]},s.id)}),Array.from(o.entries()).map(([s,r])=>W.jsxs("g",{children:[W.jsx("line",{x1:r.x-rI.ANCHOR_MARKER_SIZE,y1:r.y,x2:r.x+rI.ANCHOR_MARKER_SIZE,y2:r.y,stroke:cy.OFFSET_LINE,strokeWidth:rI.ANCHOR_MARKER_STROKE_WIDTH}),W.jsx("line",{x1:r.x,y1:r.y-rI.ANCHOR_MARKER_SIZE,x2:r.x,y2:r.y+rI.ANCHOR_MARKER_SIZE,stroke:cy.OFFSET_LINE,strokeWidth:rI.ANCHOR_MARKER_STROKE_WIDTH})]},`anchor-${s}`))]})})},rti=({elements:t,highlightedPrimitives:A,transform:e,containerWidth:i,containerHeight:n})=>{const o=t.filter(E=>pmA(E)),s=t.filter(E=>Tk(E)),r=t.filter(E=>Whe(E)),a=A.map(E=>Tk(E._parent_pcb_component)?E._parent_pcb_component.pcb_component_id:Tk(E._element)?E._element.pcb_component_id:null).filter(E=>!!E),g=new Set;if(a.forEach(E=>{const u=s.find(d=>d.pcb_component_id===E);u?.pcb_group_id&&g.add(u.pcb_group_id)}),!mB(E=>E.is_showing_group_anchor_offsets)&&a.length===0)return null;const I=s.map(E=>{const u=E.positioned_relative_to_pcb_board_id;if(!u)return null;const d=o.find(f=>f.pcb_board_id===u);return d?{component:E,board:d,type:"component"}:null}).filter(E=>!!E),l=r.map(E=>{const u=E.positioned_relative_to_pcb_board_id;if(!u||!E.center)return null;const d=o.find(f=>f.pcb_board_id===u);return d?{group:E,board:d,type:"group"}:null}).filter(E=>!!E),B=[...I,...l];if(B.length===0)return null;const C=a.length===0,Q=B.filter(E=>E.type==="component"?C||a.includes(E.component.pcb_component_id):C||g.has(E.group.pcb_group_id));if(Q.length===0)return null;const h=Q.map(E=>E.type==="component"?{id:`${E.board.pcb_board_id}-${E.component.pcb_component_id}-${E.type}`,anchor:E.board.center,anchor_id:E.board.pcb_board_id,target:E.component.center,type:"component",display_offset_x:E.component.display_offset_x,display_offset_y:E.component.display_offset_y}:{id:`${E.board.pcb_board_id}-${E.group.pcb_group_id}-${E.type}`,anchor:E.board.center,anchor_id:E.board.pcb_board_id,target:{x:E.group.anchor_position?.x??E.group.center.x,y:E.group.anchor_position?.y??E.group.center.y},type:"group",display_offset_x:E.group.display_offset_x,display_offset_y:E.group.display_offset_y}).filter(E=>!!E);return W.jsx(fmA,{targets:h,transform:e,containerWidth:i,containerHeight:n})},ati=({elements:t,highlightedPrimitives:A,transform:e,containerWidth:i,containerHeight:n})=>{const o=t.filter(E=>Whe(E)),s=t.filter(E=>Tk(E)),r=A.map(E=>Tk(E._parent_pcb_component)?E._parent_pcb_component.pcb_component_id:Tk(E._element)?E._element.pcb_component_id:null).filter(E=>!!E),a=(E,u)=>{if(u.has(E))return;u.add(E);const d=o.find(f=>f.pcb_group_id===E);d?.position_mode==="relative_to_group_anchor"&&d.positioned_relative_to_pcb_group_id&&a(d.positioned_relative_to_pcb_group_id,u)},g=new Set;if(r.forEach(E=>{const u=s.find(d=>d.pcb_component_id===E);u&&(u.position_mode==="relative_to_group_anchor"&&u.positioned_relative_to_pcb_group_id&&a(u.positioned_relative_to_pcb_group_id,g),u.pcb_group_id&&a(u.pcb_group_id,g))}),!mB(E=>E.is_showing_group_anchor_offsets)&&r.length===0)return null;const I=s.map(E=>{if(E.position_mode==="relative_to_group_anchor"&&E.positioned_relative_to_pcb_group_id){const u=o.find(d=>d.pcb_group_id===E.positioned_relative_to_pcb_group_id);return u&&u.anchor_position?{component:E,parentGroup:u,type:"component"}:null}if(E.pcb_group_id){const u=o.find(d=>d.pcb_group_id===E.pcb_group_id);return u&&u.anchor_position?{component:E,parentGroup:u,type:"component"}:null}return null}).filter(E=>!!E),l=o.map(E=>{if(E.position_mode==="relative_to_group_anchor"&&E.positioned_relative_to_pcb_group_id){const u=o.find(d=>d.pcb_group_id===E.positioned_relative_to_pcb_group_id);if(u&&u.anchor_position&&E.anchor_position)return{group:E,parentGroup:u,type:"group"}}return null}).filter(E=>!!E),B=[...I,...l];if(B.length===0)return null;const C=r.length===0,Q=B.filter(E=>E.type==="component"?C||r.includes(E.component.pcb_component_id):C||g.has(E.group.pcb_group_id)||g.has(E.parentGroup.pcb_group_id));if(Q.length===0)return null;const h=Q.map(E=>{const u=E.parentGroup.anchor_position;return u?E.type==="component"?E.component.center?{id:`${E.parentGroup.pcb_group_id}-${E.component.pcb_component_id}-${E.type}`,anchor:u,anchor_id:E.parentGroup.pcb_group_id,target:E.component.center,type:"component",display_offset_x:E.component.display_offset_x,display_offset_y:E.component.display_offset_y}:null:E.group.anchor_position?{id:`${E.parentGroup.pcb_group_id}-${E.group.pcb_group_id}-${E.type}`,anchor:u,anchor_id:E.parentGroup.pcb_group_id,target:E.group.anchor_position,type:"group",display_offset_x:E.group.display_offset_x,display_offset_y:E.group.display_offset_y}:null:null}).filter(E=>!!E);return W.jsx(fmA,{targets:h,transform:e,containerWidth:i,containerHeight:n})},gti=(t,A)=>{const e=t.pcb_component_id,i=A.filter(n=>(n.type==="pcb_smtpad"||n.type==="pcb_plated_hole")&&n.pcb_component_id===e||n.type==="pcb_hole"&&n.pcb_component_id===e);return i.length===0?hmA([t]):hmA(i)},cti=({elements:t,highlightedPrimitives:A,transform:e,containerWidth:i,containerHeight:n})=>{const o=new Map;for(const r of A)Tk(r._parent_pcb_component)&&o.set(r._parent_pcb_component.pcb_component_id,r._parent_pcb_component),Tk(r._element)&&o.set(r._element.pcb_component_id,r._element);if(o.size===0)return null;const s=[];for(const r of o.values()){const a=gti(r,t);if(!a)continue;const g=r.positioned_relative_to_pcb_group_id??r.pcb_group_id,c=g?nx(t).pcb_group.get(g):null;s.push({component:r,bbox:a,group:c})}return s.length===0?null:W.jsx("div",{style:{position:"absolute",left:0,top:0,width:i,height:n,overflow:"hidden",pointerEvents:"none",zIndex:xc.dimensionOverlay},children:W.jsx("svg",{style:{position:"absolute",left:0,top:0,pointerEvents:"none"},width:i,height:n,children:s.map(({component:r,bbox:a,group:g})=>{const c=Ce(e,{x:a.minX,y:a.maxY}),I=Ce(e,{x:a.maxX,y:a.minY}),l={x:Math.min(c.x,I.x),y:Math.min(c.y,I.y),width:Math.abs(I.x-c.x),height:Math.abs(I.y-c.y)},B=r.center??{x:(a.minX+a.maxX)/2,y:(a.minY+a.maxY)/2},C=Ce(e,B);return W.jsxs("g",{children:[W.jsx("rect",{x:l.x,y:l.y,width:l.width,height:l.height,fill:"none",stroke:"white",strokeWidth:1.5,strokeDasharray:"4,4"}),W.jsx("line",{x1:C.x-6,y1:C.y,x2:C.x+6,y2:C.y,stroke:cy.COMPONENT_MARKER_STROKE,strokeWidth:1.5}),W.jsx("line",{x1:C.x,y1:C.y-6,x2:C.x,y2:C.y+6,stroke:cy.COMPONENT_MARKER_STROKE,strokeWidth:1.5}),W.jsx("circle",{cx:C.x,cy:C.y,r:rI.COMPONENT_MARKER_RADIUS,fill:cy.COMPONENT_MARKER_FILL,stroke:cy.COMPONENT_MARKER_STROKE,strokeWidth:1})]},r.pcb_component_id)})})})},Iti=({elements:t,highlightedPrimitives:A,transform:e,containerWidth:i,containerHeight:n})=>{const o=t.filter(B=>sti(B)),s=t.filter(B=>pmA(B)),r=A.map(B=>pmA(B._element)?B._element.pcb_board_id:null).filter(B=>!!B);if(!mB(B=>B.is_showing_group_anchor_offsets)&&r.length===0)return null;const g=s.map(B=>{const C=B.pcb_panel_id,Q=B.position_mode;if(!C||Q!=="relative_to_panel_anchor")return null;const h=o.find(E=>E.pcb_panel_id===C);return h?{board:B,panel:h,type:"board"}:null}).filter(B=>!!B);if(g.length===0)return null;const c=r.length===0,I=g.filter(B=>c||r.includes(B.board.pcb_board_id));if(I.length===0)return null;const l=I.map(B=>B.board.center?{id:`${B.panel.pcb_panel_id}-${B.board.pcb_board_id}-${B.type}`,anchor:B.panel.center,anchor_id:B.panel.pcb_panel_id,target:B.board.center,type:"board",display_offset_x:B.board.display_offset_x,display_offset_y:B.board.display_offset_y}:null).filter(B=>!!B);return W.jsx(fmA,{targets:l,transform:e,containerWidth:i,containerHeight:n})},Fz=t=>{if(t.length===0)return null;let A=t[0].x,e=t[0].y,i=t[0].x,n=t[0].y;for(const o of t)o.x<A&&(A=o.x),o.y<e&&(e=o.y),o.x>i&&(i=o.x),o.y>n&&(n=o.y);return{center:{x:(A+i)/2,y:(e+n)/2},width:i-A,height:n-e}},Zhe=(t,A)=>{if(A.length<3)return!1;let e=!1;for(let i=0,n=A.length-1;i<A.length;n=i++){const o=A[i].x,s=A[i].y,r=A[n].x,a=A[n].y;s>t.y!=a>t.y&&t.x<(r-o)*(t.y-s)/(a-s||Number.EPSILON)+o&&(e=!e)}return e},lti=(t,A,e)=>{const i=[];for(const n of t){if(!n._element)continue;if("x1"in n&&n._element?.type==="pcb_trace"){const r=HE({x:A.x,y:A.y},{x:n.x1,y:n.y1},{x:n.x2,y:n.y2}),a=n.width||.5,g=Math.max(a*25,2)/e.a;r<g&&i.push(n);continue}if(n.pcb_drawing_type==="polygon"){const r=n.points.map(g=>({x:Et.parse(g.x),y:Et.parse(g.y)})),a=Fz(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;Zhe(A,r)&&i.push(n);continue}if(n.pcb_drawing_type==="polygon_with_arcs"){const r=n.brep_shape.outer_ring.vertices.map(g=>({x:Et.parse(g.x),y:Et.parse(g.y)})),a=Fz(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;Zhe(A,r)&&i.push(n);continue}if(!("x"in n&&"y"in n))continue;let o=0,s=0;if("w"in n&&"h"in n)o=n.w,s=n.h;else if("r"in n)o=n.r*2,s=n.r*2;else if("rX"in n&&"rY"in n)o=n.rX*2,s=n.rY*2;else continue;Math.abs(n.x-A.x)<o/2&&Math.abs(n.y-A.y)<s/2&&i.push(n)}return i},Bti=({elements:t,children:A,transform:e,primitives:i,onMouseHoverOverPrimitives:n})=>{const[o,s]=V.useState([]),[r,a]=V.useState({x:0,y:0}),[g,{width:c,height:I}]=KT(),l=V.useMemo(()=>{const C=[];for(const Q of o){if(Q._element?.type==="pcb_via"||Q._element?.type==="pcb_component"||Q?.layer==="drill")continue;let h=null,E=0,u=0;if(Q.pcb_drawing_type==="polygon"){const w=Fz(Q.points);if(!w)continue;h=w.center,E=w.width,u=w.height}else if(Q.pcb_drawing_type==="polygon_with_arcs"){const w=Q.brep_shape.outer_ring.vertices.map(S=>({x:S.x,y:S.y})),D=Fz(w);if(!D)continue;h=D.center,E=D.width,u=D.height}else"x"in Q&&"y"in Q&&(h={x:Q.x,y:Q.y},E="w"in Q?Q.w:"r"in Q?Q.r*2:"rX"in Q&&"rY"in Q?Q.rX*2:0,u="h"in Q?Q.h:"r"in Q?Q.r*2:"rX"in Q&&"rY"in Q?Q.rY*2:0);if(!h)continue;const d=Ce(e,h),f={w:E*e.a,h:u*e.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({...Q,x:h.x,y:h.y,w:E,h:u,screen_x:d.x,screen_y:d.y,screen_w:f.w,screen_h:f.h,same_space_index:m})}return C},[o,e]),B=(C,Q,h,E)=>{a({x:C,y:Q});const u=Ce(Am(h),{x:C,y:Q}),d=lti(E,u,h);Xei(new Set(d.map(f=>f._pcb_drawing_object_id)),new Set(o.map(f=>f._pcb_drawing_object_id)))||(s(d),n(d))};return W.jsxs("div",{ref:g,style:{position:"relative",width:"100%",height:"100%"},onMouseMove:C=>{if(e){const Q=C.currentTarget.getBoundingClientRect(),h=C.clientX-Q.left,E=C.clientY-Q.top;B(h,E,e,i)}},onTouchStart:C=>{if(e){const Q=C.touches[0],h=C.currentTarget.getBoundingClientRect(),E=Q.clientX-h.left,u=Q.clientY-h.top;B(E,u,e,i)}},children:[A,W.jsx(oti,{elements:t,mousePos:r,highlightedPrimitives:l}),e&&W.jsxs(W.Fragment,{children:[W.jsx(rti,{elements:t,highlightedPrimitives:l,transform:e,containerWidth:c,containerHeight:I}),W.jsx(ati,{elements:t,highlightedPrimitives:l,transform:e,containerWidth:c,containerHeight:I}),W.jsx(cti,{elements:t,highlightedPrimitives:l,transform:e,containerWidth:c,containerHeight:I}),W.jsx(Iti,{elements:t,highlightedPrimitives:l,transform:e,containerWidth:c,containerHeight:I})]})]})},Vhe=["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)"],Cti=({children:t,transform:A=xa(),elements:e=[],hoveredComponentIds:i=[]})=>{const[n,{width:o,height:s}]=KT(),r=V.useRef(null),{is_showing_pcb_groups:a,pcb_group_view_mode:g,is_showing_group_anchor_offsets:c}=mB(I=>({is_showing_pcb_groups:I.is_showing_pcb_groups,pcb_group_view_mode:I.pcb_group_view_mode,is_showing_group_anchor_offsets:I.is_showing_group_anchor_offsets}));return V.useEffect(()=>{const I=r.current;if(!I||!o||!s)return;I.width=o,I.height=s;const l=I.getContext("2d");if(!l||(l.clearRect(0,0,o,s),!a))return;const B=e.filter(w=>w.type==="pcb_group"),C=e.filter(w=>w.type==="pcb_component"),Q=e.filter(w=>w.type==="source_group"),h=new Map(Q.map(w=>[w.source_group_id,w])),E=B.filter(w=>{if(w.name?.toLowerCase().includes("subpanel"))return!1;if(g==="all")return!0;if(!w.source_group_id)return!1;const D=h.get(w.source_group_id);return D?D.was_automatically_named!==!0:!1}),u=new Map;Q.forEach(w=>{const D=w;if(D.parent_source_group_id){const S=u.get(D.parent_source_group_id)||[];S.push(w.source_group_id),u.set(D.parent_source_group_id,S)}});const d=w=>{const D=[],S=u.get(w)||[];for(const _ of S)D.push(_),D.push(...d(_));return D},f=w=>{const D=Q.find(S=>S.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)}E.forEach((w,D)=>{let S=C.filter(YA=>YA.pcb_group_id===w.pcb_group_id);if(w.source_group_id){const YA=d(w.source_group_id),jA=B.filter(kA=>kA.source_group_id&&YA.includes(kA.source_group_id));for(const kA of jA){const wA=C.filter(GA=>GA.pcb_group_id===kA.pcb_group_id);S=[...S,...wA]}}let _,b,N,F,L=!1;if(w.center&&w.width&&w.height){L=!0;const YA=w.width/2,jA=w.height/2;_=w.center.x-YA,N=w.center.x+YA,b=w.center.y-jA,F=w.center.y+jA}else if(S.length===0||(_=1/0,b=1/0,N=-1/0,F=-1/0,S.forEach(YA=>{if(YA.center&&typeof YA.width=="number"&&typeof YA.height=="number"){const jA=YA.center.x-YA.width/2,kA=YA.center.x+YA.width/2,wA=YA.center.y+YA.height/2,GA=YA.center.y-YA.height/2;_=Math.min(_,jA),N=Math.max(N,kA),b=Math.min(b,GA),F=Math.max(F,wA)}}),_===1/0||N===-1/0))return;const Y=w.source_group_id?f(w.source_group_id):0,J=w.source_group_id?d(w.source_group_id).length>0:!1;if(!L){const kA=1+(J?.5:0);_-=kA,N+=kA,b-=kA,F+=kA}const q=Ce(A,{x:_,y:F}),Z=Ce(A,{x:N,y:F}),X=Ce(A,{x:_,y:b}),eA=Ce(A,{x:N,y:b}),gA=Vhe[D%Vhe.length];l.strokeStyle=gA,l.lineWidth=2;const iA=Math.max(4,Math.min(12,8*Math.abs(A.a))),tA=Math.max(2,Math.min(6,4*Math.abs(A.a))),aA=iA*(J?1.3:1),hA=tA;l.setLineDash([aA,hA]),l.beginPath(),l.moveTo(q.x,q.y),l.lineTo(Z.x,Z.y),l.lineTo(eA.x,eA.y),l.lineTo(X.x,X.y),l.closePath(),l.stroke();const bA=Math.max(8,Math.min(12,10*Math.abs(A.a))),_A=Y==0||Y==1?0:Y*.11,HA=bA*(1-_A),QA=4,xA=w.name||`Group ${D+1}`;l.font=`${HA}px sans-serif`,l.setLineDash([]);const qA=l.measureText(xA).width+QA*2,VA=HA+QA*2,ce=q.x-5,fA=q.y-5,ge=3;if(l.fillStyle="rgba(0, 0, 0, 0.8)",l.beginPath(),l.roundRect(ce,fA-VA,qA,VA,ge),l.fill(),l.fillStyle=gA,l.textAlign="left",l.textBaseline="middle",l.fillText(xA,ce+QA,fA-VA/2),c&&m.has(w.pcb_group_id)&&!!w.anchor_position&&w.anchor_position){const YA=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},jA=Ce(A,YA);l.strokeStyle="white",l.lineWidth=1.5,l.setLineDash([]);const kA=Math.max(4,Math.min(8,6*Math.abs(A.a)));l.beginPath(),l.moveTo(jA.x-kA,jA.y),l.lineTo(jA.x+kA,jA.y),l.stroke(),l.beginPath(),l.moveTo(jA.x,jA.y-kA),l.lineTo(jA.x,jA.y+kA),l.stroke()}})},[e,A,o,s,a,g,c,i]),W.jsxs("div",{ref:n,style:{position:"relative",width:"100%",height:"100%"},children:[t,W.jsx("canvas",{ref:r,style:{position:"absolute",top:0,left:0,pointerEvents:"none",zIndex:xc.pcbGroupOverlay,display:a?"block":"none"}})]})},Qti=({transform:t,soup:A,children:e})=>{const i=mB(r=>r.is_showing_rats_nest),{netMap:n,idToNetMap:o}=V.useMemo(()=>She(A||[]),[A]),s=V.useMemo(()=>{if(!A||!i)return[];const r=l=>{const B=nx(A)[l.replace(/_\d+$/,"")].get(l);return B&&"x"in B&&"y"in B?{x:B.x,y:B.y}:null},a=(l,B)=>{const C=n[B]||[];let Q=null,h=1/0;return C.forEach(E=>{const u=r(E);if(u){const d=Math.sqrt((l.x-u.x)**2+(l.y-u.y)**2);d<h&&d>0&&(h=d,Q=u)}}),Q},g=nx(A).pcb_port.list(),c=nx(A).source_trace.list(),I=[];return g.forEach((l,B)=>{const C=o[l.pcb_port_id];let Q=!1;for(const u of c)u.connected_source_port_ids.includes(l.source_port_id)&&u.connected_source_net_ids.length>0&&(Q=!0);if(!C)return;const h={x:l.x,y:l.y},E=a(h,C);E&&I.push({key:`${l.pcb_port_id}-${B}`,startPoint:h,endPoint:E,isInNet:Q})}),I},[A,n,o,i]);return!A||!i?e:(t||(t=xa()),W.jsxs("div",{style:{position:"relative"},children:[e,W.jsx("svg",{style:{position:"absolute",left:0,top:0,width:"100%",height:"100%",pointerEvents:"none",opacity:.5,zIndex:xc.ratsNestOverlay},children:s.map(({key:r,startPoint:a,endPoint:g,isInNet:c})=>{const I=Ce(t,a),l=Ce(t,g);return W.jsx("line",{x1:I.x,y1:I.y,x2:l.x,y2:l.y,stroke:"white",strokeWidth:"1",strokeDasharray:c?"6,6":void 0},r)})})]}))},hti={version:"1.11.350"},Pk=(t,A,e)=>{const i=mB(s=>s.is_mouse_over_container),n=V.useRef(i),o=V.useRef(A);V.useEffect(()=>{n.current=i},[i]),V.useEffect(()=>{o.current=A},[A]),V.useEffect(()=>{if(!t)return;const s=r=>{const a=r.target;if(a.tagName==="INPUT"||a.tagName==="TEXTAREA"||a.isContentEditable)return;const g=t.split("+"),c=g.includes("ctrl"),I=g.includes("shift"),l=g.includes("alt"),B=g.includes("meta"),C=g[g.length-1],Q=e?.current?e.current.contains(document.activeElement)||document.activeElement===e.current:!1;(n.current||Q)&&(!c||r.ctrlKey)&&(!I||r.shiftKey)&&(!l||r.altKey)&&(!B||r.metaKey)&&r.key.toLowerCase()===C.toLowerCase()&&(r.preventDefault(),o.current())};return window.addEventListener("keydown",s),()=>{window.removeEventListener("keydown",s)}},[t])},Eti=()=>{const[t,A]=V.useState(!1);return V.useEffect(()=>{const e=()=>{A(window.innerWidth<=768)};return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]),t},OT=(t,A={stopPropagation:!0})=>{const e=V.useRef(0),i=V.useCallback(s=>{A.stopPropagation&&s.stopPropagation();const r=Date.now();r-e.current<300||(e.current=r,t?.(s))},[t,A.stopPropagation]),n=V.useCallback(s=>{s.preventDefault(),i(s)},[i]);return{onClick:i,onTouchEnd:n,style:{touchAction:"manipulation"}}},uti=({name:t,selected:A,onClick:e})=>{const{style:i,...n}=OT(e);return W.jsxs("div",{className:y2`
5476
5476
  margin-top: 2px;
5477
5477
  padding: 4px;
5478
5478
  padding-left: 8px;
@@ -5689,7 +5689,7 @@ test("${g} should solve problem correctly", () => {
5689
5689
  // Add more specific assertions based on expected output
5690
5690
  // expect(solver.netLabelPlacementSolver!.netLabelPlacements).toMatchInlineSnapshot()
5691
5691
  })
5692
- `,I=new Blob([c],{type:"text/plain"}),l=URL.createObjectURL(I),B=document.createElement("a");B.href=l,B.download=`${g}.test.ts`,B.click(),URL.revokeObjectURL(l)}catch(a){alert(`Error generating test.ts for ${t.constructor.name}: ${a instanceof Error?a.message:String(a)}`)}i(!1)};return W.jsxs("div",{className:`relative ${A}`,ref:n,children:[W.jsx("button",{className:"px-2 py-1 rounded text-xs cursor-pointer",onClick:()=>i(!e),title:`Download options for ${t.constructor.name}`,children:t.constructor.name}),e&&W.jsxs("div",{className:"absolute top-full left-0 mt-1 bg-white border border-gray-300 rounded shadow-lg z-10 min-w-[150px]",children:[W.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:o,children:"Download JSON"}),W.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:s,children:"Download page.tsx"}),W.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:r,children:"Download test.ts"})]})]})},nEe=t=>t.activeSubSolver?[t,...nEe(t.activeSubSolver)]:[t],qii=({solver:t})=>{const A=nEe(t);return W.jsx("div",{className:"flex gap-1 items-center text-sm pt-1",children:A.map((e,i)=>W.jsxs("div",{className:"flex items-center",children:[i>0&&W.jsx("span",{className:"text-gray-400 mx-1",children:"→"}),W.jsx(Kii,{solver:e})]},e.constructor.name))})},Oii=({solver:t,triggerRender:A,animationSpeed:e=25,onSolverStarted:i,onSolverCompleted:n})=>{const[o,s]=V.useReducer(Q=>!Q,!1),r=V.useRef(void 0),a=()=>{!t.solved&&!t.failed&&(t.step(),A())},g=()=>{!t.solved&&!t.failed&&(i&&i(t),t.solve(),A(),n&&n(t))},c=()=>{o?(r.current&&(clearInterval(r.current),r.current=void 0),s()):(s(),r.current=setInterval(()=>{if(t.solved||t.failed){r.current&&(clearInterval(r.current),r.current=void 0),s(),A(),n&&t.solved&&n(t);return}t.step(),A()},e))},I=()=>{const Q=t;if(Q.getCurrentPhase&&!t.solved&&!t.failed){const h=Q.getCurrentPhase();for(;Q.getCurrentPhase()===h&&!t.solved&&!t.failed;)t.step();A()}},l=()=>{if(t.solved||t.failed||o)return;const Q=window.prompt("Step until which iteration?",`${t.iterations}`);if(Q===null)return;const h=Number(Q);if(!Number.isFinite(h)){window.alert("Please enter a valid number for the iteration");return}for(;t.iterations<h&&!t.solved&&!t.failed;)t.step();A(),t.solved&&n&&n(t)};V.useEffect(()=>()=>{r.current&&clearInterval(r.current)},[]),V.useEffect(()=>{(t.solved||t.failed)&&o&&(r.current&&(clearInterval(r.current),r.current=void 0),s())},[t.solved,t.failed,o]);const B=t.getCurrentPhase!==void 0,C=B?t.getCurrentPhase():null;return W.jsxs("div",{className:"space-y-2 p-2 border-b",children:[W.jsx("div",{className:"flex items-center",children:W.jsx(qii,{solver:t})}),W.jsxs("div",{className:"flex gap-2 items-center flex-wrap",children:[W.jsx("button",{onClick:a,disabled:t.solved||t.failed||o,className:"bg-blue-500 hover:bg-blue-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Step"}),W.jsx("button",{onClick:g,disabled:t.solved||t.failed||o,className:"bg-green-500 hover:bg-green-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Solve"}),W.jsx("button",{onClick:c,disabled:t.solved||t.failed,className:`px-3 py-1 rounded text-white text-sm ${o?"bg-red-500 hover:bg-red-600":"bg-yellow-500 hover:bg-yellow-600"} disabled:bg-gray-300`,children:o?"Stop":"Animate"}),W.jsx("button",{onClick:l,disabled:t.solved||t.failed||o,className:"bg-orange-500 hover:bg-orange-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Step Until Iteration"}),B&&W.jsx("button",{onClick:I,disabled:t.solved||t.failed||o,className:"bg-purple-500 hover:bg-purple-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Next Stage"}),W.jsxs("div",{className:"text-sm text-gray-600",children:["Iterations: ",t.iterations]}),t.timeToSolve!==void 0&&W.jsxs("div",{className:"text-sm text-gray-600",children:["Time: ",(t.timeToSolve/1e3).toFixed(3),"s"]}),C&&W.jsxs("div",{className:"text-sm text-gray-600",children:["Phase: ",W.jsx("span",{className:"font-medium",children:C})]}),t.solved&&W.jsx("div",{className:"px-2 py-1 bg-green-100 text-green-800 rounded text-sm",children:"Solved"}),t.failed&&W.jsx("div",{className:"px-2 py-1 bg-red-100 text-red-800 rounded text-sm",children:"Failed"})]}),t.error&&W.jsxs("div",{className:"text-red-600 text-sm",children:["Error: ",t.error]})]})},Wii=(t,A,e)=>{const i=t.currentPipelineStepIndex;return A<i?"Completed":A===i&&t.activeSubSolver?t.activeSubSolver.failed?"Failed":"In Progress":"Not Started"},Zii=(t,A)=>{const i=t.pipelineDef[A].solverName,n=Wii(t,A),o=t[i],s=t.firstIterationOfPhase?.[i]??null,r=t.iterations;let a=0;if(n==="Completed"){const l=t.pipelineDef[A+1],B=l?t.firstIterationOfPhase?.[l.solverName]:void 0;B!==void 0&&s!==null?a=B-s:s!==null&&(a=r-s)}else n==="In Progress"&&s!==null&&(a=r-s);const g=t.timeSpentOnPhase?.[i]??0;let c=0;n==="Completed"?c=1:n==="In Progress"&&o&&(c=o.progress??0);const I=o?.stats??null;return{index:A,name:i,status:n,firstIteration:s,iterations:a,progress:c,timeSpent:g,stats:I&&Object.keys(I).length>0?I:null,solverInstance:o??null}},Vii=({status:t})=>{const A={"Not Started":"text-blue-600","In Progress":"text-yellow-600",Completed:"text-green-600",Failed:"text-red-600"};return W.jsx("span",{className:`font-medium ${A[t]}`,children:t})},jii=({progress:t})=>{if(t===0)return null;const A=Math.round(t*100);return W.jsxs("div",{className:"flex items-center gap-2",children:[W.jsx("div",{className:"w-20 h-2 bg-gray-200 rounded overflow-hidden",children:W.jsx("div",{className:"h-full bg-blue-500 transition-all duration-200",style:{width:`${A}%`}})}),W.jsxs("span",{className:"text-xs text-gray-500",children:[A,"%"]})]})},zii=t=>Object.entries(t).map(([A,e])=>`${A}: ${e}`).join(", "),Xii=({stats:t})=>{if(!t||Object.keys(t).length===0)return W.jsx("span",{children:"-"});const A=Object.entries(t),e=zii(t);return W.jsxs("details",{className:"cursor-pointer",children:[W.jsx("summary",{className:"whitespace-nowrap overflow-hidden text-ellipsis max-w-[200px]",children:e}),W.jsx("div",{className:"mt-1 text-xs",children:A.map(([i,n])=>W.jsxs("div",{children:[i,": ",String(n)]},i))})]})},_mA=t=>{if(t===null||typeof t!="object")return t;if(Array.isArray(t))return t.map(_mA);const A={};for(const[e,i]of Object.entries(t))e.startsWith("_")||(A[e]=_mA(i));return A},$ii=(t,A)=>{try{if(typeof t.getConstructorParams!="function"){alert(`getConstructorParams() is not implemented for ${A}`);return}const e=_mA(t.getConstructorParams()),i=new Blob([JSON.stringify(e,null,2)],{type:"application/json"}),n=URL.createObjectURL(i),o=document.createElement("a");o.href=n,o.download=`${A}_input.json`,o.click(),URL.revokeObjectURL(n)}catch(e){alert(`Error downloading input for ${A}: ${e instanceof Error?e.message:String(e)}`)}},Ani=({solver:t,onStepUntilPhase:A,onDownloadInput:e})=>{const i=t.pipelineDef.map((r,a)=>Zii(t,a)),n=r=>{A?.(r)},o=r=>{r.solverInstance&&(e?e(r.solverInstance,r.name):$ii(r.solverInstance,r.name))},s=r=>`${(r/1e3).toFixed(2)}s`;return W.jsxs("div",{className:"border-t border-gray-200",children:[W.jsx("div",{className:"px-4 py-2 bg-gray-50 border-b border-gray-200",children:W.jsx("h3",{className:"text-sm font-semibold text-gray-700",children:"Pipeline Steps"})}),W.jsx("div",{className:"overflow-x-auto",children:W.jsxs("table",{className:"w-full text-sm",children:[W.jsx("thead",{children:W.jsxs("tr",{className:"bg-gray-50 border-b border-gray-200",children:[W.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Step"}),W.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Status"}),W.jsxs("th",{className:"px-4 py-2 text-center font-semibold text-gray-700",children:["i",W.jsx("sub",{children:"0"})]}),W.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Iterations"}),W.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Progress"}),W.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Time"}),W.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Stats"}),W.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Input"})]})}),W.jsx("tbody",{children:i.map(r=>W.jsxs("tr",{className:`border-b border-gray-100 ${r.status==="In Progress"?"bg-yellow-50":""}`,children:[W.jsx("td",{className:"px-4 py-2",children:W.jsxs("div",{className:"flex items-center gap-2",children:[W.jsx("span",{className:"text-gray-400 w-6",children:String(r.index+1).padStart(2,"0")}),W.jsx("button",{onClick:()=>n(r.name),disabled:r.status==="Completed"||t.solved||t.failed,className:"text-blue-500 hover:text-blue-700 disabled:text-gray-300 disabled:cursor-not-allowed",title:`Step until ${r.name} completes`,children:W.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:W.jsx("path",{fillRule:"evenodd",d:"M4.5 5.653c0-1.426 1.529-2.33 2.779-1.643l11.54 6.348c1.295.712 1.295 2.573 0 3.285L7.28 19.991c-1.25.687-2.779-.217-2.779-1.643V5.653z",clipRule:"evenodd"})})}),W.jsx("span",{className:"font-medium text-gray-900",children:r.name})]})}),W.jsx("td",{className:"px-4 py-2",children:W.jsx(Vii,{status:r.status})}),W.jsx("td",{className:"px-4 py-2 text-center text-gray-600",children:r.firstIteration!==null?r.firstIteration:""}),W.jsx("td",{className:"px-4 py-2 text-gray-600",children:r.iterations}),W.jsx("td",{className:"px-4 py-2",children:W.jsx(jii,{progress:r.progress})}),W.jsx("td",{className:"px-4 py-2 text-gray-600",children:s(r.timeSpent)}),W.jsx("td",{className:"px-4 py-2 text-gray-500",children:W.jsx(Xii,{stats:r.stats})}),W.jsx("td",{className:"px-4 py-2",children:r.solverInstance?W.jsxs("button",{onClick:()=>o(r),className:"flex items-center gap-1 text-blue-500 hover:text-blue-700",title:`Download input for ${r.name}`,children:[W.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:W.jsx("path",{fillRule:"evenodd",d:"M12 2.25a.75.75 0 01.75.75v11.69l3.22-3.22a.75.75 0 111.06 1.06l-4.5 4.5a.75.75 0 01-1.06 0l-4.5-4.5a.75.75 0 111.06-1.06l3.22 3.22V3a.75.75 0 01.75-.75zm-9 13.5a.75.75 0 01.75.75v2.25a1.5 1.5 0 001.5 1.5h13.5a1.5 1.5 0 001.5-1.5V16.5a.75.75 0 011.5 0v2.25a3 3 0 01-3 3H5.25a3 3 0 01-3-3V16.5a.75.75 0 01.75-.75z",clipRule:"evenodd"})}),W.jsx("span",{children:"Input"})]}):null})]},r.name))})]})})]})},eni=class extends Cn.Component{constructor(t){super(t),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(t){console.error("InteractiveGraphics render error:",t)}render(){return this.state.hasError?this.props.fallback:this.props.children}};function tni({graphics:t}){const A=t.points??[],e=t.lines??[],i=t.rects??[],n=t.circles??[],o=t.texts??[];let s=Number.POSITIVE_INFINITY,r=Number.POSITIVE_INFINITY,a=Number.NEGATIVE_INFINITY,g=Number.NEGATIVE_INFINITY;const c=(h,E)=>{typeof h=="number"&&(h<s&&(s=h),h>a&&(a=h)),typeof E=="number"&&(E<r&&(r=E),E>g&&(g=E))};for(const h of A)c(h.x,h.y);for(const h of e){const E=h.points??[];for(const u of E)c(u.x,u.y)}for(const h of i){const E=h.x??0,u=h.y??0,d=h.width??0,f=h.height??0;c(E,u),c(E+d,u+f)}for(const h of n){const E=h.x??0,u=h.y??0,d=h.radius??1;c(E-d,u-d),c(E+d,u+d)}for(const h of o)c(h.x,h.y);(!isFinite(s)||!isFinite(r)||!isFinite(a)||!isFinite(g))&&(s=-20,r=-20,a=20,g=20);const I=10,l=s-I,B=r-I,C=Math.max(1,a-s+2*I),Q=Math.max(1,g-r+2*I);return W.jsxs("svg",{className:"w-full h-[400px] bg-white",viewBox:`${l} ${B} ${C} ${Q}`,role:"img","aria-label":"Graphics fallback",children:[i.map((h,E)=>W.jsx("rect",{x:h.x??0,y:h.y??0,width:h.width??0,height:h.height??0,fill:"none",stroke:h.strokeColor??"black",strokeWidth:h.strokeWidth??1},`rect-${E}`)),e.map((h,E)=>W.jsx("polyline",{fill:"none",stroke:h.strokeColor??"black",strokeWidth:h.strokeWidth??1,points:(h.points??[]).map(u=>`${u.x??0},${u.y??0}`).join(" ")},`line-${E}`)),n.map((h,E)=>W.jsx("circle",{cx:h.x??0,cy:h.y??0,r:h.radius??1.5,fill:h.fillColor??"none",stroke:h.strokeColor??"black",strokeWidth:h.strokeWidth??1},`circle-${E}`)),A.map((h,E)=>W.jsx("circle",{cx:h.x??0,cy:h.y??0,r:h.radius??1.5,fill:h.color??"black"},`point-${E}`)),o.map((h,E)=>W.jsx("text",{x:h.x??0,y:h.y??0,fontSize:h.fontSize??10,fill:h.color??"black",children:h.text??""},`text-${E}`))]})}var ini=({solver:t,animationSpeed:A=25,onSolverStarted:e,onSolverCompleted:i})=>{const[n,o]=V.useReducer(c=>c+1,0),s=V.useMemo(()=>{try{return t.visualize()||{points:[],lines:[],rects:[],circles:[]}}catch(c){return console.error("Visualization error:",c),{points:[],lines:[],rects:[],circles:[]}}},[t,n]),r=V.useMemo(()=>(s.rects?.length||0)===0&&(s.lines?.length||0)===0&&(s.points?.length||0)===0&&(s.circles?.length||0)===0,[s]);V.useEffect(()=>{if(!(typeof document>"u")&&!document.querySelector('script[src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4"]')){const c=document.createElement("script");c.src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4",document.head.appendChild(c)}},[]);const a=t.pipelineDef!==void 0,g=c=>{const I=t;if(!t.solved&&!t.failed){for(;!t.solved&&!t.failed&&I.currentPipelineStepIndex<=I.pipelineDef.findIndex(l=>l.solverName===c);)t.step();o()}};return W.jsxs("div",{children:[W.jsx(Oii,{solver:t,triggerRender:o,animationSpeed:A,onSolverStarted:e,onSolverCompleted:i}),r?W.jsx("div",{className:"p-4 text-gray-500",children:"No Graphics Yet"}):W.jsx(eni,{fallback:W.jsx(tni,{graphics:s}),children:W.jsx(Pii,{graphics:s})}),a&&W.jsx(Ani,{solver:t,onStepUntilPhase:g})]})};const nni=()=>{V.useEffect(()=>{const t="tailwind-cdn-script";if(document.getElementById(t)||window.tailwind)return;const A=document.createElement("div");A.className="hidden",document.body.appendChild(A);const e=window.getComputedStyle(A).display==="none";if(document.body.removeChild(A),e)return;const i=document.createElement("script");i.id=t,i.src="https://cdn.tailwindcss.com",document.head.appendChild(i)},[])},oni=t=>t.toLowerCase().includes("pack")?jKt:t.toLowerCase().includes("rout")?eqt:NKt,sni=({solverEvents:t=[]})=>{const[A,e]=V.useState(null);nni();const i=V.useMemo(()=>{const r=new Map;for(const a of t){const g=`${a.componentName}-${a.solverName}`;r.set(g,a)}return r},[t]),n=V.useMemo(()=>Array.from(i.keys()),[i]),o=A?i.get(A):null,s=V.useMemo(()=>{if(!o)return{instance:null,error:null,classFound:!1};const r=qrA[o.solverName];if(!r)return{instance:null,error:`Solver class "${o.solverName}" not found in SOLVERS registry. Available: ${Object.keys(qrA).join(", ")}`,classFound:!1};try{const a=o.solverParams,g=a?.input!==void 0?a.input:a;return{instance:new r(g),error:null,classFound:!0}}catch(a){const g=a instanceof Error?a.message:String(a);return console.error("Failed to reconstruct solver:",a),{instance:null,error:`Failed to instantiate solver: ${g}`,classFound:!0}}},[o]);return t.length===0?W.jsx("div",{className:"rf-p-4",children:W.jsx("div",{className:"rf-bg-gray-50 rf-rounded-md rf-border rf-border-gray-200",children:W.jsxs("div",{className:"rf-p-4",children:[W.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800 rf-mb-3",children:"No Solvers Detected"}),W.jsx("p",{className:"rf-text-sm rf-text-gray-600",children:"Solvers will appear here when the circuit runs. Solvers are used for tasks like component packing and autorouting."})]})})}):W.jsxs("div",{className:"rf-flex rf-h-full rf-overflow-hidden",children:[W.jsxs("div",{className:"rf-w-64 rf-border-r rf-border-gray-200 rf-overflow-y-auto rf-flex-shrink-0",children:[W.jsxs("div",{className:"rf-text-xs rf-font-semibold rf-text-gray-500 rf-px-3 rf-py-2 rf-bg-gray-50 rf-border-b rf-border-gray-200",children:[n.length," ",n.length===1?"Solver":"Solvers"]}),n.map(r=>{const a=i.get(r),g=A===r;return W.jsx("div",{className:`rf-px-3 rf-py-2 rf-cursor-pointer rf-border-b rf-border-gray-100 ${g?"rf-bg-blue-50 rf-border-l-2 rf-border-l-blue-500":"hover:rf-bg-gray-50"}`,onClick:()=>e(r),children:(()=>{const c=oni(a.solverName);return W.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2",children:[W.jsx(c,{className:"rf-w-4 rf-h-4 rf-text-blue-500 rf-flex-shrink-0"}),W.jsxs("div",{className:"rf-flex-1 rf-min-w-0",children:[W.jsx("div",{className:"rf-text-sm rf-font-medium rf-text-gray-800 rf-truncate",children:a.componentName}),W.jsx("div",{className:"rf-text-xs rf-text-gray-500 rf-truncate",children:a.solverName})]})]})})()},r)})]}),W.jsx("div",{className:"rf-flex-1 rf-overflow-hidden",children:o?s.instance?W.jsx(ym,{fallback:W.jsx("div",{className:"rf-p-4",children:W.jsxs("div",{className:"rf-bg-red-50 rf-rounded-md rf-border rf-border-red-200 rf-p-4",children:[W.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-red-800 rf-mb-2",children:"Error Loading Solver Debugger"}),W.jsxs("p",{className:"rf-text-sm rf-text-red-600",children:["Failed to render the solver debugger for"," ",o.solverName]})]})}),children:W.jsx(ini,{solver:s.instance})}):W.jsxs("div",{className:"rf-p-4",children:[W.jsxs("div",{className:"rf-mb-4",children:[W.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800",children:o.solverName}),W.jsxs("p",{className:"rf-text-sm rf-text-gray-500",children:["Component: ",o.componentName]})]}),s.error&&W.jsx("div",{className:`rf-rounded-md rf-border rf-p-4 rf-mb-4 ${s.classFound?"rf-bg-red-50 rf-border-red-200":"rf-bg-yellow-50 rf-border-yellow-200"}`,children:W.jsx("p",{className:`rf-text-sm ${s.classFound?"rf-text-red-700":"rf-text-yellow-700"}`,children:s.error})}),W.jsxs("div",{className:"rf-border rf-border-gray-200 rf-rounded-md rf-overflow-hidden",children:[W.jsx("div",{className:"rf-px-3 rf-py-2 rf-bg-gray-50",children:W.jsx("span",{className:"rf-text-sm rf-font-medium rf-text-gray-700",children:"Solver Parameters"})}),W.jsx("div",{className:"rf-p-3 rf-bg-white rf-border-t rf-border-gray-200",children:W.jsx("pre",{className:"rf-text-xs rf-font-mono rf-text-gray-600 rf-whitespace-pre-wrap rf-overflow-x-auto",children:JSON.stringify(o.solverParams,null,2)})})]})]}):W.jsx("div",{className:"rf-flex rf-items-center rf-justify-center rf-h-full",children:W.jsx("p",{className:"rf-text-sm rf-text-gray-500",children:"Select a solver from the list to view details"})})})]})},oEe=({errorMessage:t,errorStack:A,circuitJsonErrors:e})=>{V.useEffect(()=>{if(t){const i=new Error(t);A&&(i.stack=A);try{KW.captureException(i)}catch{}}},[t,A]),V.useEffect(()=>{if(e&&e.length>0)for(const i of e){const n=new Error(i.message||"Circuit JSON Error");i.stack&&(n.stack=i.stack);try{KW.captureException(n,{error_type:i.type})}catch{}}},[e])},sEe="0.0.1728",rni={version:sEe},Uz=b4A()(x4A(t=>({lastRunEvalVersion:void 0,setLastRunEvalVersion:A=>{t({lastRunEvalVersion:A})}}),{name:"runframe-runner-store"})),ani=t=>{const[A,e]=V.useState([]),[i,n]=V.useState(null),[o,s]=V.useState(""),[r,a]=sG("eval-version-selection",null),g=Uz(B=>B.setLastRunEvalVersion),c=Uz(B=>B.lastRunEvalVersion);return V.useEffect(()=>{t&&fetch("https://data.jsdelivr.com/v1/package/npm/@tscircuit/eval").then(B=>B.json()).then(B=>{if(Array.isArray(B?.versions)){let C=[...B.versions];B.tags?.latest&&(n(B.tags.latest),C=C.filter(Q=>Q!==B.tags.latest)),e(C)}}).catch(()=>{})},[t]),V.useEffect(()=>{t&&(r?(window.TSCIRCUIT_LATEST_EVAL_VERSION=r,g(r)):i&&(window.TSCIRCUIT_LATEST_EVAL_VERSION=i,g(i)))},[t,r,i]),{versions:V.useMemo(()=>A.filter(B=>B.includes(o)).slice(0,50),[A,o]),latestVersion:i,lastRunEvalVersion:c,search:o,setSearch:s,selectVersion:B=>{a(B),s("")}}},gni=({snippetNames:t,onSelect:A,onCancel:e,isOpen:i})=>{const[n,o]=V.useState(""),[s,r]=V.useState("");if(!i)return null;const a=t.filter(I=>I.toLowerCase().includes(s.toLowerCase())),g=s&&!t.includes(s),c=I=>{I.key==="Enter"&&(a.length===1?o(a[0]):g&&o(s))};return W.jsx("div",{className:"rf-fixed rf-inset-0 rf-bg-black rf-bg-opacity-50 rf-flex rf-items-center rf-justify-center rf-z-[100]",children:W.jsxs("div",{className:"rf-bg-white rf-rounded-lg rf-p-6 rf-w-96",children:[W.jsx("h2",{className:"rf-text-lg rf-font-semibold rf-mb-4",children:"Select Snippet"}),W.jsx("input",{type:"text",className:"rf-w-full rf-px-4 rf-py-2 rf-border rf-rounded rf-mb-4",placeholder:"Search snippets or new snippet name...",value:s,onChange:I=>r(I.target.value),onKeyDown:c}),W.jsxs("div",{className:"rf-h-60 rf-overflow-y-auto",children:[a.map(I=>W.jsx("button",{type:"button",className:`w-full text-left px-4 py-2 rounded hover:bg-gray-100 ${n===I?"bg-blue-50":""}`,onClick:()=>o(I),children:I},I)),g&&W.jsxs("button",{type:"button",className:`w-full text-left px-4 py-2 rounded hover:bg-gray-100 text-blue-500 ${n===s?"bg-blue-50":""}`,onClick:()=>o(s),children:['Create new "',s,'"']})]}),W.jsxs("div",{className:"rf-mt-4 rf-flex rf-justify-end rf-gap-2",children:[W.jsx("button",{type:"button",className:"rf-px-4 rf-py-2 rf-text-gray-600 rf-hover:text-gray-800",onClick:e,children:"Cancel"}),W.jsx("button",{type:"button",className:"rf-px-4 rf-py-2 rf-bg-blue-500 rf-text-white rf-rounded rf-hover:bg-blue-600 rf-disabled:opacity-50",onClick:()=>n&&A(n),disabled:!n,children:n===s?`Create "${n}"`:`Save to ${n}`})]})]})})},cni=t=>{const A=V.useRef(null),e=FI(i=>i.recentEvents);V.useEffect(()=>{if(e.length===0)return;const i=e[0];i.event_id!==A.current&&(t(i),A.current=i.event_id)},[e,t])};function Ini(t){const A=lni(t),e=V.forwardRef((i,n)=>{const{children:o,...s}=i,r=V.Children.toArray(o),a=r.find(Cni);if(a){const g=a.props.children,c=r.map(I=>I===a?V.Children.count(g)>1?V.Children.only(null):V.isValidElement(g)?g.props.children:null:I);return W.jsx(A,{...s,ref:n,children:V.isValidElement(g)?V.cloneElement(g,void 0,c):null})}return W.jsx(A,{...s,ref:n,children:o})});return e.displayName=`${t}.Slot`,e}function lni(t){const A=V.forwardRef((e,i)=>{const{children:n,...o}=e;if(V.isValidElement(n)){const s=hni(n),r=Qni(o,n.props);return n.type!==V.Fragment&&(r.ref=i?xf(i,s):s),V.cloneElement(n,r)}return V.Children.count(n)>1?V.Children.only(null):null});return A.displayName=`${t}.SlotClone`,A}var Bni=Symbol("radix.slottable");function Cni(t){return V.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===Bni}function Qni(t,A){const e={...A};for(const i in A){const n=t[i],o=A[i];/^on[A-Z]/.test(i)?n&&o?e[i]=(...r)=>{const a=o(...r);return n(...r),a}:n&&(e[i]=n):i==="style"?e[i]={...n,...o}:i==="className"&&(e[i]=[n,o].filter(Boolean).join(" "))}return{...t,...e}}function hni(t){let A=Object.getOwnPropertyDescriptor(t.props,"ref")?.get,e=A&&"isReactWarning"in A&&A.isReactWarning;return e?t.ref:(A=Object.getOwnPropertyDescriptor(t,"ref")?.get,e=A&&"isReactWarning"in A&&A.isReactWarning,e?t.props.ref:t.props.ref||t.ref)}var Hz="Dialog",[rEe,aEe]=Ew(Hz),[Eni,Tw]=rEe(Hz),gEe=t=>{const{__scopeDialog:A,children:e,open:i,defaultOpen:n,onOpenChange:o,modal:s=!0}=t,r=V.useRef(null),a=V.useRef(null),[g,c]=M_({prop:i,defaultProp:n??!1,onChange:o,caller:Hz});return W.jsx(Eni,{scope:A,triggerRef:r,contentRef:a,contentId:qE(),titleId:qE(),descriptionId:qE(),open:g,onOpenChange:c,onOpenToggle:V.useCallback(()=>c(I=>!I),[c]),modal:s,children:e})};gEe.displayName=Hz;var cEe="DialogTrigger",IEe=V.forwardRef((t,A)=>{const{__scopeDialog:e,...i}=t,n=Tw(cEe,e),o=MI(A,n.triggerRef);return W.jsx(eg.button,{type:"button","aria-haspopup":"dialog","aria-expanded":n.open,"aria-controls":n.contentId,"data-state":FmA(n.open),...i,ref:o,onClick:Vn(t.onClick,n.onOpenToggle)})});IEe.displayName=cEe;var kmA="DialogPortal",[uni,lEe]=rEe(kmA,{forceMount:void 0}),BEe=t=>{const{__scopeDialog:A,forceMount:e,children:i,container:n}=t,o=Tw(kmA,A);return W.jsx(uni,{scope:A,forceMount:e,children:V.Children.map(i,s=>W.jsx(K0,{present:e||o.open,children:W.jsx(X9,{asChild:!0,container:n,children:s})}))})};BEe.displayName=kmA;var Yz="DialogOverlay",CEe=V.forwardRef((t,A)=>{const e=lEe(Yz,t.__scopeDialog),{forceMount:i=e.forceMount,...n}=t,o=Tw(Yz,t.__scopeDialog);return o.modal?W.jsx(K0,{present:i||o.open,children:W.jsx(pni,{...n,ref:A})}):null});CEe.displayName=Yz;var dni=Ini("DialogOverlay.RemoveScroll"),pni=V.forwardRef((t,A)=>{const{__scopeDialog:e,...i}=t,n=Tw(Yz,e);return W.jsx(sj,{as:dni,allowPinchZoom:!0,shards:[n.contentRef],children:W.jsx(eg.div,{"data-state":FmA(n.open),...i,ref:A,style:{pointerEvents:"auto",...i.style}})})}),YM="DialogContent",QEe=V.forwardRef((t,A)=>{const e=lEe(YM,t.__scopeDialog),{forceMount:i=e.forceMount,...n}=t,o=Tw(YM,t.__scopeDialog);return W.jsx(K0,{present:i||o.open,children:o.modal?W.jsx(fni,{...n,ref:A}):W.jsx(yni,{...n,ref:A})})});QEe.displayName=YM;var fni=V.forwardRef((t,A)=>{const e=Tw(YM,t.__scopeDialog),i=V.useRef(null),n=MI(A,e.contentRef,i);return V.useEffect(()=>{const o=i.current;if(o)return WfA(o)},[]),W.jsx(hEe,{...t,ref:n,trapFocus:e.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Vn(t.onCloseAutoFocus,o=>{o.preventDefault(),e.triggerRef.current?.focus()}),onPointerDownOutside:Vn(t.onPointerDownOutside,o=>{const s=o.detail.originalEvent,r=s.button===0&&s.ctrlKey===!0;(s.button===2||r)&&o.preventDefault()}),onFocusOutside:Vn(t.onFocusOutside,o=>o.preventDefault())})}),yni=V.forwardRef((t,A)=>{const e=Tw(YM,t.__scopeDialog),i=V.useRef(!1),n=V.useRef(!1);return W.jsx(hEe,{...t,ref:A,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:o=>{t.onCloseAutoFocus?.(o),o.defaultPrevented||(i.current||e.triggerRef.current?.focus(),o.preventDefault()),i.current=!1,n.current=!1},onInteractOutside:o=>{t.onInteractOutside?.(o),o.defaultPrevented||(i.current=!0,o.detail.originalEvent.type==="pointerdown"&&(n.current=!0));const s=o.target;e.triggerRef.current?.contains(s)&&o.preventDefault(),o.detail.originalEvent.type==="focusin"&&n.current&&o.preventDefault()}})}),hEe=V.forwardRef((t,A)=>{const{__scopeDialog:e,trapFocus:i,onOpenAutoFocus:n,onCloseAutoFocus:o,...s}=t,r=Tw(YM,e),a=V.useRef(null),g=MI(A,a);return xfA(),W.jsxs(W.Fragment,{children:[W.jsx(H9,{asChild:!0,loop:!0,trapped:i,onMountAutoFocus:n,onUnmountAutoFocus:o,children:W.jsx(TJ,{role:"dialog",id:r.contentId,"aria-describedby":r.descriptionId,"aria-labelledby":r.titleId,"data-state":FmA(r.open),...s,ref:g,onDismiss:()=>r.onOpenChange(!1)})}),W.jsxs(W.Fragment,{children:[W.jsx(wni,{titleId:r.titleId}),W.jsx(Sni,{contentRef:a,descriptionId:r.descriptionId})]})]})}),vmA="DialogTitle",EEe=V.forwardRef((t,A)=>{const{__scopeDialog:e,...i}=t,n=Tw(vmA,e);return W.jsx(eg.h2,{id:n.titleId,...i,ref:A})});EEe.displayName=vmA;var uEe="DialogDescription",dEe=V.forwardRef((t,A)=>{const{__scopeDialog:e,...i}=t,n=Tw(uEe,e);return W.jsx(eg.p,{id:n.descriptionId,...i,ref:A})});dEe.displayName=uEe;var pEe="DialogClose",fEe=V.forwardRef((t,A)=>{const{__scopeDialog:e,...i}=t,n=Tw(pEe,e);return W.jsx(eg.button,{type:"button",...i,ref:A,onClick:Vn(t.onClick,()=>n.onOpenChange(!1))})});fEe.displayName=pEe;function FmA(t){return t?"open":"closed"}var yEe="DialogTitleWarning",[mni,mEe]=wat(yEe,{contentName:YM,titleName:vmA,docsSlug:"dialog"}),wni=({titleId:t})=>{const A=mEe(yEe),e=`\`${A.contentName}\` requires a \`${A.titleName}\` for the component to be accessible for screen reader users.
5692
+ `,I=new Blob([c],{type:"text/plain"}),l=URL.createObjectURL(I),B=document.createElement("a");B.href=l,B.download=`${g}.test.ts`,B.click(),URL.revokeObjectURL(l)}catch(a){alert(`Error generating test.ts for ${t.constructor.name}: ${a instanceof Error?a.message:String(a)}`)}i(!1)};return W.jsxs("div",{className:`relative ${A}`,ref:n,children:[W.jsx("button",{className:"px-2 py-1 rounded text-xs cursor-pointer",onClick:()=>i(!e),title:`Download options for ${t.constructor.name}`,children:t.constructor.name}),e&&W.jsxs("div",{className:"absolute top-full left-0 mt-1 bg-white border border-gray-300 rounded shadow-lg z-10 min-w-[150px]",children:[W.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:o,children:"Download JSON"}),W.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:s,children:"Download page.tsx"}),W.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:r,children:"Download test.ts"})]})]})},nEe=t=>t.activeSubSolver?[t,...nEe(t.activeSubSolver)]:[t],qii=({solver:t})=>{const A=nEe(t);return W.jsx("div",{className:"flex gap-1 items-center text-sm pt-1",children:A.map((e,i)=>W.jsxs("div",{className:"flex items-center",children:[i>0&&W.jsx("span",{className:"text-gray-400 mx-1",children:"→"}),W.jsx(Kii,{solver:e})]},e.constructor.name))})},Oii=({solver:t,triggerRender:A,animationSpeed:e=25,onSolverStarted:i,onSolverCompleted:n})=>{const[o,s]=V.useReducer(Q=>!Q,!1),r=V.useRef(void 0),a=()=>{!t.solved&&!t.failed&&(t.step(),A())},g=()=>{!t.solved&&!t.failed&&(i&&i(t),t.solve(),A(),n&&n(t))},c=()=>{o?(r.current&&(clearInterval(r.current),r.current=void 0),s()):(s(),r.current=setInterval(()=>{if(t.solved||t.failed){r.current&&(clearInterval(r.current),r.current=void 0),s(),A(),n&&t.solved&&n(t);return}t.step(),A()},e))},I=()=>{const Q=t;if(Q.getCurrentPhase&&!t.solved&&!t.failed){const h=Q.getCurrentPhase();for(;Q.getCurrentPhase()===h&&!t.solved&&!t.failed;)t.step();A()}},l=()=>{if(t.solved||t.failed||o)return;const Q=window.prompt("Step until which iteration?",`${t.iterations}`);if(Q===null)return;const h=Number(Q);if(!Number.isFinite(h)){window.alert("Please enter a valid number for the iteration");return}for(;t.iterations<h&&!t.solved&&!t.failed;)t.step();A(),t.solved&&n&&n(t)};V.useEffect(()=>()=>{r.current&&clearInterval(r.current)},[]),V.useEffect(()=>{(t.solved||t.failed)&&o&&(r.current&&(clearInterval(r.current),r.current=void 0),s())},[t.solved,t.failed,o]);const B=t.getCurrentPhase!==void 0,C=B?t.getCurrentPhase():null;return W.jsxs("div",{className:"space-y-2 p-2 border-b",children:[W.jsx("div",{className:"flex items-center",children:W.jsx(qii,{solver:t})}),W.jsxs("div",{className:"flex gap-2 items-center flex-wrap",children:[W.jsx("button",{onClick:a,disabled:t.solved||t.failed||o,className:"bg-blue-500 hover:bg-blue-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Step"}),W.jsx("button",{onClick:g,disabled:t.solved||t.failed||o,className:"bg-green-500 hover:bg-green-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Solve"}),W.jsx("button",{onClick:c,disabled:t.solved||t.failed,className:`px-3 py-1 rounded text-white text-sm ${o?"bg-red-500 hover:bg-red-600":"bg-yellow-500 hover:bg-yellow-600"} disabled:bg-gray-300`,children:o?"Stop":"Animate"}),W.jsx("button",{onClick:l,disabled:t.solved||t.failed||o,className:"bg-orange-500 hover:bg-orange-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Step Until Iteration"}),B&&W.jsx("button",{onClick:I,disabled:t.solved||t.failed||o,className:"bg-purple-500 hover:bg-purple-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Next Stage"}),W.jsxs("div",{className:"text-sm text-gray-600",children:["Iterations: ",t.iterations]}),t.timeToSolve!==void 0&&W.jsxs("div",{className:"text-sm text-gray-600",children:["Time: ",(t.timeToSolve/1e3).toFixed(3),"s"]}),C&&W.jsxs("div",{className:"text-sm text-gray-600",children:["Phase: ",W.jsx("span",{className:"font-medium",children:C})]}),t.solved&&W.jsx("div",{className:"px-2 py-1 bg-green-100 text-green-800 rounded text-sm",children:"Solved"}),t.failed&&W.jsx("div",{className:"px-2 py-1 bg-red-100 text-red-800 rounded text-sm",children:"Failed"})]}),t.error&&W.jsxs("div",{className:"text-red-600 text-sm",children:["Error: ",t.error]})]})},Wii=(t,A,e)=>{const i=t.currentPipelineStepIndex;return A<i?"Completed":A===i&&t.activeSubSolver?t.activeSubSolver.failed?"Failed":"In Progress":"Not Started"},Zii=(t,A)=>{const i=t.pipelineDef[A].solverName,n=Wii(t,A),o=t[i],s=t.firstIterationOfPhase?.[i]??null,r=t.iterations;let a=0;if(n==="Completed"){const l=t.pipelineDef[A+1],B=l?t.firstIterationOfPhase?.[l.solverName]:void 0;B!==void 0&&s!==null?a=B-s:s!==null&&(a=r-s)}else n==="In Progress"&&s!==null&&(a=r-s);const g=t.timeSpentOnPhase?.[i]??0;let c=0;n==="Completed"?c=1:n==="In Progress"&&o&&(c=o.progress??0);const I=o?.stats??null;return{index:A,name:i,status:n,firstIteration:s,iterations:a,progress:c,timeSpent:g,stats:I&&Object.keys(I).length>0?I:null,solverInstance:o??null}},Vii=({status:t})=>{const A={"Not Started":"text-blue-600","In Progress":"text-yellow-600",Completed:"text-green-600",Failed:"text-red-600"};return W.jsx("span",{className:`font-medium ${A[t]}`,children:t})},jii=({progress:t})=>{if(t===0)return null;const A=Math.round(t*100);return W.jsxs("div",{className:"flex items-center gap-2",children:[W.jsx("div",{className:"w-20 h-2 bg-gray-200 rounded overflow-hidden",children:W.jsx("div",{className:"h-full bg-blue-500 transition-all duration-200",style:{width:`${A}%`}})}),W.jsxs("span",{className:"text-xs text-gray-500",children:[A,"%"]})]})},zii=t=>Object.entries(t).map(([A,e])=>`${A}: ${e}`).join(", "),Xii=({stats:t})=>{if(!t||Object.keys(t).length===0)return W.jsx("span",{children:"-"});const A=Object.entries(t),e=zii(t);return W.jsxs("details",{className:"cursor-pointer",children:[W.jsx("summary",{className:"whitespace-nowrap overflow-hidden text-ellipsis max-w-[200px]",children:e}),W.jsx("div",{className:"mt-1 text-xs",children:A.map(([i,n])=>W.jsxs("div",{children:[i,": ",String(n)]},i))})]})},_mA=t=>{if(t===null||typeof t!="object")return t;if(Array.isArray(t))return t.map(_mA);const A={};for(const[e,i]of Object.entries(t))e.startsWith("_")||(A[e]=_mA(i));return A},$ii=(t,A)=>{try{if(typeof t.getConstructorParams!="function"){alert(`getConstructorParams() is not implemented for ${A}`);return}const e=_mA(t.getConstructorParams()),i=new Blob([JSON.stringify(e,null,2)],{type:"application/json"}),n=URL.createObjectURL(i),o=document.createElement("a");o.href=n,o.download=`${A}_input.json`,o.click(),URL.revokeObjectURL(n)}catch(e){alert(`Error downloading input for ${A}: ${e instanceof Error?e.message:String(e)}`)}},Ani=({solver:t,onStepUntilPhase:A,onDownloadInput:e})=>{const i=t.pipelineDef.map((r,a)=>Zii(t,a)),n=r=>{A?.(r)},o=r=>{r.solverInstance&&(e?e(r.solverInstance,r.name):$ii(r.solverInstance,r.name))},s=r=>`${(r/1e3).toFixed(2)}s`;return W.jsxs("div",{className:"border-t border-gray-200",children:[W.jsx("div",{className:"px-4 py-2 bg-gray-50 border-b border-gray-200",children:W.jsx("h3",{className:"text-sm font-semibold text-gray-700",children:"Pipeline Steps"})}),W.jsx("div",{className:"overflow-x-auto",children:W.jsxs("table",{className:"w-full text-sm",children:[W.jsx("thead",{children:W.jsxs("tr",{className:"bg-gray-50 border-b border-gray-200",children:[W.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Step"}),W.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Status"}),W.jsxs("th",{className:"px-4 py-2 text-center font-semibold text-gray-700",children:["i",W.jsx("sub",{children:"0"})]}),W.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Iterations"}),W.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Progress"}),W.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Time"}),W.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Stats"}),W.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Input"})]})}),W.jsx("tbody",{children:i.map(r=>W.jsxs("tr",{className:`border-b border-gray-100 ${r.status==="In Progress"?"bg-yellow-50":""}`,children:[W.jsx("td",{className:"px-4 py-2",children:W.jsxs("div",{className:"flex items-center gap-2",children:[W.jsx("span",{className:"text-gray-400 w-6",children:String(r.index+1).padStart(2,"0")}),W.jsx("button",{onClick:()=>n(r.name),disabled:r.status==="Completed"||t.solved||t.failed,className:"text-blue-500 hover:text-blue-700 disabled:text-gray-300 disabled:cursor-not-allowed",title:`Step until ${r.name} completes`,children:W.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:W.jsx("path",{fillRule:"evenodd",d:"M4.5 5.653c0-1.426 1.529-2.33 2.779-1.643l11.54 6.348c1.295.712 1.295 2.573 0 3.285L7.28 19.991c-1.25.687-2.779-.217-2.779-1.643V5.653z",clipRule:"evenodd"})})}),W.jsx("span",{className:"font-medium text-gray-900",children:r.name})]})}),W.jsx("td",{className:"px-4 py-2",children:W.jsx(Vii,{status:r.status})}),W.jsx("td",{className:"px-4 py-2 text-center text-gray-600",children:r.firstIteration!==null?r.firstIteration:""}),W.jsx("td",{className:"px-4 py-2 text-gray-600",children:r.iterations}),W.jsx("td",{className:"px-4 py-2",children:W.jsx(jii,{progress:r.progress})}),W.jsx("td",{className:"px-4 py-2 text-gray-600",children:s(r.timeSpent)}),W.jsx("td",{className:"px-4 py-2 text-gray-500",children:W.jsx(Xii,{stats:r.stats})}),W.jsx("td",{className:"px-4 py-2",children:r.solverInstance?W.jsxs("button",{onClick:()=>o(r),className:"flex items-center gap-1 text-blue-500 hover:text-blue-700",title:`Download input for ${r.name}`,children:[W.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:W.jsx("path",{fillRule:"evenodd",d:"M12 2.25a.75.75 0 01.75.75v11.69l3.22-3.22a.75.75 0 111.06 1.06l-4.5 4.5a.75.75 0 01-1.06 0l-4.5-4.5a.75.75 0 111.06-1.06l3.22 3.22V3a.75.75 0 01.75-.75zm-9 13.5a.75.75 0 01.75.75v2.25a1.5 1.5 0 001.5 1.5h13.5a1.5 1.5 0 001.5-1.5V16.5a.75.75 0 011.5 0v2.25a3 3 0 01-3 3H5.25a3 3 0 01-3-3V16.5a.75.75 0 01.75-.75z",clipRule:"evenodd"})}),W.jsx("span",{children:"Input"})]}):null})]},r.name))})]})})]})},eni=class extends Cn.Component{constructor(t){super(t),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(t){console.error("InteractiveGraphics render error:",t)}render(){return this.state.hasError?this.props.fallback:this.props.children}};function tni({graphics:t}){const A=t.points??[],e=t.lines??[],i=t.rects??[],n=t.circles??[],o=t.texts??[];let s=Number.POSITIVE_INFINITY,r=Number.POSITIVE_INFINITY,a=Number.NEGATIVE_INFINITY,g=Number.NEGATIVE_INFINITY;const c=(h,E)=>{typeof h=="number"&&(h<s&&(s=h),h>a&&(a=h)),typeof E=="number"&&(E<r&&(r=E),E>g&&(g=E))};for(const h of A)c(h.x,h.y);for(const h of e){const E=h.points??[];for(const u of E)c(u.x,u.y)}for(const h of i){const E=h.x??0,u=h.y??0,d=h.width??0,f=h.height??0;c(E,u),c(E+d,u+f)}for(const h of n){const E=h.x??0,u=h.y??0,d=h.radius??1;c(E-d,u-d),c(E+d,u+d)}for(const h of o)c(h.x,h.y);(!isFinite(s)||!isFinite(r)||!isFinite(a)||!isFinite(g))&&(s=-20,r=-20,a=20,g=20);const I=10,l=s-I,B=r-I,C=Math.max(1,a-s+2*I),Q=Math.max(1,g-r+2*I);return W.jsxs("svg",{className:"w-full h-[400px] bg-white",viewBox:`${l} ${B} ${C} ${Q}`,role:"img","aria-label":"Graphics fallback",children:[i.map((h,E)=>W.jsx("rect",{x:h.x??0,y:h.y??0,width:h.width??0,height:h.height??0,fill:"none",stroke:h.strokeColor??"black",strokeWidth:h.strokeWidth??1},`rect-${E}`)),e.map((h,E)=>W.jsx("polyline",{fill:"none",stroke:h.strokeColor??"black",strokeWidth:h.strokeWidth??1,points:(h.points??[]).map(u=>`${u.x??0},${u.y??0}`).join(" ")},`line-${E}`)),n.map((h,E)=>W.jsx("circle",{cx:h.x??0,cy:h.y??0,r:h.radius??1.5,fill:h.fillColor??"none",stroke:h.strokeColor??"black",strokeWidth:h.strokeWidth??1},`circle-${E}`)),A.map((h,E)=>W.jsx("circle",{cx:h.x??0,cy:h.y??0,r:h.radius??1.5,fill:h.color??"black"},`point-${E}`)),o.map((h,E)=>W.jsx("text",{x:h.x??0,y:h.y??0,fontSize:h.fontSize??10,fill:h.color??"black",children:h.text??""},`text-${E}`))]})}var ini=({solver:t,animationSpeed:A=25,onSolverStarted:e,onSolverCompleted:i})=>{const[n,o]=V.useReducer(c=>c+1,0),s=V.useMemo(()=>{try{return t.visualize()||{points:[],lines:[],rects:[],circles:[]}}catch(c){return console.error("Visualization error:",c),{points:[],lines:[],rects:[],circles:[]}}},[t,n]),r=V.useMemo(()=>(s.rects?.length||0)===0&&(s.lines?.length||0)===0&&(s.points?.length||0)===0&&(s.circles?.length||0)===0,[s]);V.useEffect(()=>{if(!(typeof document>"u")&&!document.querySelector('script[src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4"]')){const c=document.createElement("script");c.src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4",document.head.appendChild(c)}},[]);const a=t.pipelineDef!==void 0,g=c=>{const I=t;if(!t.solved&&!t.failed){for(;!t.solved&&!t.failed&&I.currentPipelineStepIndex<=I.pipelineDef.findIndex(l=>l.solverName===c);)t.step();o()}};return W.jsxs("div",{children:[W.jsx(Oii,{solver:t,triggerRender:o,animationSpeed:A,onSolverStarted:e,onSolverCompleted:i}),r?W.jsx("div",{className:"p-4 text-gray-500",children:"No Graphics Yet"}):W.jsx(eni,{fallback:W.jsx(tni,{graphics:s}),children:W.jsx(Pii,{graphics:s})}),a&&W.jsx(Ani,{solver:t,onStepUntilPhase:g})]})};const nni=()=>{V.useEffect(()=>{const t="tailwind-cdn-script";if(document.getElementById(t)||window.tailwind)return;const A=document.createElement("div");A.className="hidden",document.body.appendChild(A);const e=window.getComputedStyle(A).display==="none";if(document.body.removeChild(A),e)return;const i=document.createElement("script");i.id=t,i.src="https://cdn.tailwindcss.com",document.head.appendChild(i)},[])},oni=t=>t.toLowerCase().includes("pack")?jKt:t.toLowerCase().includes("rout")?eqt:NKt,sni=({solverEvents:t=[]})=>{const[A,e]=V.useState(null);nni();const i=V.useMemo(()=>{const r=new Map;for(const a of t){const g=`${a.componentName}-${a.solverName}`;r.set(g,a)}return r},[t]),n=V.useMemo(()=>Array.from(i.keys()),[i]),o=A?i.get(A):null,s=V.useMemo(()=>{if(!o)return{instance:null,error:null,classFound:!1};const r=qrA[o.solverName];if(!r)return{instance:null,error:`Solver class "${o.solverName}" not found in SOLVERS registry. Available: ${Object.keys(qrA).join(", ")}`,classFound:!1};try{const a=o.solverParams,g=a?.input!==void 0?a.input:a;return{instance:new r(g),error:null,classFound:!0}}catch(a){const g=a instanceof Error?a.message:String(a);return console.error("Failed to reconstruct solver:",a),{instance:null,error:`Failed to instantiate solver: ${g}`,classFound:!0}}},[o]);return t.length===0?W.jsx("div",{className:"rf-p-4",children:W.jsx("div",{className:"rf-bg-gray-50 rf-rounded-md rf-border rf-border-gray-200",children:W.jsxs("div",{className:"rf-p-4",children:[W.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800 rf-mb-3",children:"No Solvers Detected"}),W.jsx("p",{className:"rf-text-sm rf-text-gray-600",children:"Solvers will appear here when the circuit runs. Solvers are used for tasks like component packing and autorouting."})]})})}):W.jsxs("div",{className:"rf-flex rf-h-full rf-overflow-hidden",children:[W.jsxs("div",{className:"rf-w-64 rf-border-r rf-border-gray-200 rf-overflow-y-auto rf-flex-shrink-0",children:[W.jsxs("div",{className:"rf-text-xs rf-font-semibold rf-text-gray-500 rf-px-3 rf-py-2 rf-bg-gray-50 rf-border-b rf-border-gray-200",children:[n.length," ",n.length===1?"Solver":"Solvers"]}),n.map(r=>{const a=i.get(r),g=A===r;return W.jsx("div",{className:`rf-px-3 rf-py-2 rf-cursor-pointer rf-border-b rf-border-gray-100 ${g?"rf-bg-blue-50 rf-border-l-2 rf-border-l-blue-500":"hover:rf-bg-gray-50"}`,onClick:()=>e(r),children:(()=>{const c=oni(a.solverName);return W.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2",children:[W.jsx(c,{className:"rf-w-4 rf-h-4 rf-text-blue-500 rf-flex-shrink-0"}),W.jsxs("div",{className:"rf-flex-1 rf-min-w-0",children:[W.jsx("div",{className:"rf-text-sm rf-font-medium rf-text-gray-800 rf-truncate",children:a.componentName}),W.jsx("div",{className:"rf-text-xs rf-text-gray-500 rf-truncate",children:a.solverName})]})]})})()},r)})]}),W.jsx("div",{className:"rf-flex-1 rf-overflow-hidden",children:o?s.instance?W.jsx(ym,{fallback:W.jsx("div",{className:"rf-p-4",children:W.jsxs("div",{className:"rf-bg-red-50 rf-rounded-md rf-border rf-border-red-200 rf-p-4",children:[W.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-red-800 rf-mb-2",children:"Error Loading Solver Debugger"}),W.jsxs("p",{className:"rf-text-sm rf-text-red-600",children:["Failed to render the solver debugger for"," ",o.solverName]})]})}),children:W.jsx(ini,{solver:s.instance})}):W.jsxs("div",{className:"rf-p-4",children:[W.jsxs("div",{className:"rf-mb-4",children:[W.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800",children:o.solverName}),W.jsxs("p",{className:"rf-text-sm rf-text-gray-500",children:["Component: ",o.componentName]})]}),s.error&&W.jsx("div",{className:`rf-rounded-md rf-border rf-p-4 rf-mb-4 ${s.classFound?"rf-bg-red-50 rf-border-red-200":"rf-bg-yellow-50 rf-border-yellow-200"}`,children:W.jsx("p",{className:`rf-text-sm ${s.classFound?"rf-text-red-700":"rf-text-yellow-700"}`,children:s.error})}),W.jsxs("div",{className:"rf-border rf-border-gray-200 rf-rounded-md rf-overflow-hidden",children:[W.jsx("div",{className:"rf-px-3 rf-py-2 rf-bg-gray-50",children:W.jsx("span",{className:"rf-text-sm rf-font-medium rf-text-gray-700",children:"Solver Parameters"})}),W.jsx("div",{className:"rf-p-3 rf-bg-white rf-border-t rf-border-gray-200",children:W.jsx("pre",{className:"rf-text-xs rf-font-mono rf-text-gray-600 rf-whitespace-pre-wrap rf-overflow-x-auto",children:JSON.stringify(o.solverParams,null,2)})})]})]}):W.jsx("div",{className:"rf-flex rf-items-center rf-justify-center rf-h-full",children:W.jsx("p",{className:"rf-text-sm rf-text-gray-500",children:"Select a solver from the list to view details"})})})]})},oEe=({errorMessage:t,errorStack:A,circuitJsonErrors:e})=>{V.useEffect(()=>{if(t){const i=new Error(t);A&&(i.stack=A);try{KW.captureException(i)}catch{}}},[t,A]),V.useEffect(()=>{if(e&&e.length>0)for(const i of e){const n=new Error(i.message||"Circuit JSON Error");i.stack&&(n.stack=i.stack);try{KW.captureException(n,{error_type:i.type})}catch{}}},[e])},sEe="0.0.1729",rni={version:sEe},Uz=b4A()(x4A(t=>({lastRunEvalVersion:void 0,setLastRunEvalVersion:A=>{t({lastRunEvalVersion:A})}}),{name:"runframe-runner-store"})),ani=t=>{const[A,e]=V.useState([]),[i,n]=V.useState(null),[o,s]=V.useState(""),[r,a]=sG("eval-version-selection",null),g=Uz(B=>B.setLastRunEvalVersion),c=Uz(B=>B.lastRunEvalVersion);return V.useEffect(()=>{t&&fetch("https://data.jsdelivr.com/v1/package/npm/@tscircuit/eval").then(B=>B.json()).then(B=>{if(Array.isArray(B?.versions)){let C=[...B.versions];B.tags?.latest&&(n(B.tags.latest),C=C.filter(Q=>Q!==B.tags.latest)),e(C)}}).catch(()=>{})},[t]),V.useEffect(()=>{t&&(r?(window.TSCIRCUIT_LATEST_EVAL_VERSION=r,g(r)):i&&(window.TSCIRCUIT_LATEST_EVAL_VERSION=i,g(i)))},[t,r,i]),{versions:V.useMemo(()=>A.filter(B=>B.includes(o)).slice(0,50),[A,o]),latestVersion:i,lastRunEvalVersion:c,search:o,setSearch:s,selectVersion:B=>{a(B),s("")}}},gni=({snippetNames:t,onSelect:A,onCancel:e,isOpen:i})=>{const[n,o]=V.useState(""),[s,r]=V.useState("");if(!i)return null;const a=t.filter(I=>I.toLowerCase().includes(s.toLowerCase())),g=s&&!t.includes(s),c=I=>{I.key==="Enter"&&(a.length===1?o(a[0]):g&&o(s))};return W.jsx("div",{className:"rf-fixed rf-inset-0 rf-bg-black rf-bg-opacity-50 rf-flex rf-items-center rf-justify-center rf-z-[100]",children:W.jsxs("div",{className:"rf-bg-white rf-rounded-lg rf-p-6 rf-w-96",children:[W.jsx("h2",{className:"rf-text-lg rf-font-semibold rf-mb-4",children:"Select Snippet"}),W.jsx("input",{type:"text",className:"rf-w-full rf-px-4 rf-py-2 rf-border rf-rounded rf-mb-4",placeholder:"Search snippets or new snippet name...",value:s,onChange:I=>r(I.target.value),onKeyDown:c}),W.jsxs("div",{className:"rf-h-60 rf-overflow-y-auto",children:[a.map(I=>W.jsx("button",{type:"button",className:`w-full text-left px-4 py-2 rounded hover:bg-gray-100 ${n===I?"bg-blue-50":""}`,onClick:()=>o(I),children:I},I)),g&&W.jsxs("button",{type:"button",className:`w-full text-left px-4 py-2 rounded hover:bg-gray-100 text-blue-500 ${n===s?"bg-blue-50":""}`,onClick:()=>o(s),children:['Create new "',s,'"']})]}),W.jsxs("div",{className:"rf-mt-4 rf-flex rf-justify-end rf-gap-2",children:[W.jsx("button",{type:"button",className:"rf-px-4 rf-py-2 rf-text-gray-600 rf-hover:text-gray-800",onClick:e,children:"Cancel"}),W.jsx("button",{type:"button",className:"rf-px-4 rf-py-2 rf-bg-blue-500 rf-text-white rf-rounded rf-hover:bg-blue-600 rf-disabled:opacity-50",onClick:()=>n&&A(n),disabled:!n,children:n===s?`Create "${n}"`:`Save to ${n}`})]})]})})},cni=t=>{const A=V.useRef(null),e=FI(i=>i.recentEvents);V.useEffect(()=>{if(e.length===0)return;const i=e[0];i.event_id!==A.current&&(t(i),A.current=i.event_id)},[e,t])};function Ini(t){const A=lni(t),e=V.forwardRef((i,n)=>{const{children:o,...s}=i,r=V.Children.toArray(o),a=r.find(Cni);if(a){const g=a.props.children,c=r.map(I=>I===a?V.Children.count(g)>1?V.Children.only(null):V.isValidElement(g)?g.props.children:null:I);return W.jsx(A,{...s,ref:n,children:V.isValidElement(g)?V.cloneElement(g,void 0,c):null})}return W.jsx(A,{...s,ref:n,children:o})});return e.displayName=`${t}.Slot`,e}function lni(t){const A=V.forwardRef((e,i)=>{const{children:n,...o}=e;if(V.isValidElement(n)){const s=hni(n),r=Qni(o,n.props);return n.type!==V.Fragment&&(r.ref=i?xf(i,s):s),V.cloneElement(n,r)}return V.Children.count(n)>1?V.Children.only(null):null});return A.displayName=`${t}.SlotClone`,A}var Bni=Symbol("radix.slottable");function Cni(t){return V.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===Bni}function Qni(t,A){const e={...A};for(const i in A){const n=t[i],o=A[i];/^on[A-Z]/.test(i)?n&&o?e[i]=(...r)=>{const a=o(...r);return n(...r),a}:n&&(e[i]=n):i==="style"?e[i]={...n,...o}:i==="className"&&(e[i]=[n,o].filter(Boolean).join(" "))}return{...t,...e}}function hni(t){let A=Object.getOwnPropertyDescriptor(t.props,"ref")?.get,e=A&&"isReactWarning"in A&&A.isReactWarning;return e?t.ref:(A=Object.getOwnPropertyDescriptor(t,"ref")?.get,e=A&&"isReactWarning"in A&&A.isReactWarning,e?t.props.ref:t.props.ref||t.ref)}var Hz="Dialog",[rEe,aEe]=Ew(Hz),[Eni,Tw]=rEe(Hz),gEe=t=>{const{__scopeDialog:A,children:e,open:i,defaultOpen:n,onOpenChange:o,modal:s=!0}=t,r=V.useRef(null),a=V.useRef(null),[g,c]=M_({prop:i,defaultProp:n??!1,onChange:o,caller:Hz});return W.jsx(Eni,{scope:A,triggerRef:r,contentRef:a,contentId:qE(),titleId:qE(),descriptionId:qE(),open:g,onOpenChange:c,onOpenToggle:V.useCallback(()=>c(I=>!I),[c]),modal:s,children:e})};gEe.displayName=Hz;var cEe="DialogTrigger",IEe=V.forwardRef((t,A)=>{const{__scopeDialog:e,...i}=t,n=Tw(cEe,e),o=MI(A,n.triggerRef);return W.jsx(eg.button,{type:"button","aria-haspopup":"dialog","aria-expanded":n.open,"aria-controls":n.contentId,"data-state":FmA(n.open),...i,ref:o,onClick:Vn(t.onClick,n.onOpenToggle)})});IEe.displayName=cEe;var kmA="DialogPortal",[uni,lEe]=rEe(kmA,{forceMount:void 0}),BEe=t=>{const{__scopeDialog:A,forceMount:e,children:i,container:n}=t,o=Tw(kmA,A);return W.jsx(uni,{scope:A,forceMount:e,children:V.Children.map(i,s=>W.jsx(K0,{present:e||o.open,children:W.jsx(X9,{asChild:!0,container:n,children:s})}))})};BEe.displayName=kmA;var Yz="DialogOverlay",CEe=V.forwardRef((t,A)=>{const e=lEe(Yz,t.__scopeDialog),{forceMount:i=e.forceMount,...n}=t,o=Tw(Yz,t.__scopeDialog);return o.modal?W.jsx(K0,{present:i||o.open,children:W.jsx(pni,{...n,ref:A})}):null});CEe.displayName=Yz;var dni=Ini("DialogOverlay.RemoveScroll"),pni=V.forwardRef((t,A)=>{const{__scopeDialog:e,...i}=t,n=Tw(Yz,e);return W.jsx(sj,{as:dni,allowPinchZoom:!0,shards:[n.contentRef],children:W.jsx(eg.div,{"data-state":FmA(n.open),...i,ref:A,style:{pointerEvents:"auto",...i.style}})})}),YM="DialogContent",QEe=V.forwardRef((t,A)=>{const e=lEe(YM,t.__scopeDialog),{forceMount:i=e.forceMount,...n}=t,o=Tw(YM,t.__scopeDialog);return W.jsx(K0,{present:i||o.open,children:o.modal?W.jsx(fni,{...n,ref:A}):W.jsx(yni,{...n,ref:A})})});QEe.displayName=YM;var fni=V.forwardRef((t,A)=>{const e=Tw(YM,t.__scopeDialog),i=V.useRef(null),n=MI(A,e.contentRef,i);return V.useEffect(()=>{const o=i.current;if(o)return WfA(o)},[]),W.jsx(hEe,{...t,ref:n,trapFocus:e.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Vn(t.onCloseAutoFocus,o=>{o.preventDefault(),e.triggerRef.current?.focus()}),onPointerDownOutside:Vn(t.onPointerDownOutside,o=>{const s=o.detail.originalEvent,r=s.button===0&&s.ctrlKey===!0;(s.button===2||r)&&o.preventDefault()}),onFocusOutside:Vn(t.onFocusOutside,o=>o.preventDefault())})}),yni=V.forwardRef((t,A)=>{const e=Tw(YM,t.__scopeDialog),i=V.useRef(!1),n=V.useRef(!1);return W.jsx(hEe,{...t,ref:A,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:o=>{t.onCloseAutoFocus?.(o),o.defaultPrevented||(i.current||e.triggerRef.current?.focus(),o.preventDefault()),i.current=!1,n.current=!1},onInteractOutside:o=>{t.onInteractOutside?.(o),o.defaultPrevented||(i.current=!0,o.detail.originalEvent.type==="pointerdown"&&(n.current=!0));const s=o.target;e.triggerRef.current?.contains(s)&&o.preventDefault(),o.detail.originalEvent.type==="focusin"&&n.current&&o.preventDefault()}})}),hEe=V.forwardRef((t,A)=>{const{__scopeDialog:e,trapFocus:i,onOpenAutoFocus:n,onCloseAutoFocus:o,...s}=t,r=Tw(YM,e),a=V.useRef(null),g=MI(A,a);return xfA(),W.jsxs(W.Fragment,{children:[W.jsx(H9,{asChild:!0,loop:!0,trapped:i,onMountAutoFocus:n,onUnmountAutoFocus:o,children:W.jsx(TJ,{role:"dialog",id:r.contentId,"aria-describedby":r.descriptionId,"aria-labelledby":r.titleId,"data-state":FmA(r.open),...s,ref:g,onDismiss:()=>r.onOpenChange(!1)})}),W.jsxs(W.Fragment,{children:[W.jsx(wni,{titleId:r.titleId}),W.jsx(Sni,{contentRef:a,descriptionId:r.descriptionId})]})]})}),vmA="DialogTitle",EEe=V.forwardRef((t,A)=>{const{__scopeDialog:e,...i}=t,n=Tw(vmA,e);return W.jsx(eg.h2,{id:n.titleId,...i,ref:A})});EEe.displayName=vmA;var uEe="DialogDescription",dEe=V.forwardRef((t,A)=>{const{__scopeDialog:e,...i}=t,n=Tw(uEe,e);return W.jsx(eg.p,{id:n.descriptionId,...i,ref:A})});dEe.displayName=uEe;var pEe="DialogClose",fEe=V.forwardRef((t,A)=>{const{__scopeDialog:e,...i}=t,n=Tw(pEe,e);return W.jsx(eg.button,{type:"button",...i,ref:A,onClick:Vn(t.onClick,()=>n.onOpenChange(!1))})});fEe.displayName=pEe;function FmA(t){return t?"open":"closed"}var yEe="DialogTitleWarning",[mni,mEe]=wat(yEe,{contentName:YM,titleName:vmA,docsSlug:"dialog"}),wni=({titleId:t})=>{const A=mEe(yEe),e=`\`${A.contentName}\` requires a \`${A.titleName}\` for the component to be accessible for screen reader users.
5693
5693
 
5694
5694
  If you want to hide the \`${A.titleName}\`, you can wrap it with our VisuallyHidden component.
5695
5695