@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.
|
@@ -5383,7 +5383,7 @@ svg { font-family: 'Inter', 'Helvetica Neue', Arial, sans-serif; }
|
|
|
5383
5383
|
`);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),R=w.slice(D);_=[...b,...S,...R]}else _=[...w,...S,m];return _.join(`
|
|
5384
5384
|
`)},YVe=(e,A)=>{if(typeof window>"u")return A;try{const t=localStorage.getItem(e);return t!==null?JSON.parse(t):A}catch{return A}},JVe=(e,A)=>{if(!(typeof window>"u"))try{localStorage.setItem(e,JSON.stringify(A))}catch{}},VfA=AA.createContext(null),TVe=5,PVe=(e,A)=>!e&&!A?!0:!e||!A?!1:e.minX===A.minX&&e.maxX===A.maxX&&e.minY===A.minY&&e.maxY===A.maxY,KVe=({children:e})=>{if(AA.useContext(VfA))return Z.jsx(Z.Fragment,{children:e});const t=AA.useRef({pointer:null,boundingBoxes:new Map,hoveringIds:new Set,subscribers:new Set,mouseDownPosition:null}),i=AA.useCallback(()=>{for(const I of t.current.subscribers)I()},[]),n=AA.useCallback(()=>{const I=t.current.pointer,l=new Set;if(I)for(const[C,Q]of t.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=t.current.hoveringIds;l.size===B.size&&[...l].every(C=>B.has(C))||(t.current.hoveringIds=l,i())},[i]),o=AA.useCallback((I,l)=>{t.current.boundingBoxes.set(I,l),n()},[n]),s=AA.useCallback((I,l)=>{const B=t.current.boundingBoxes.get(I);B&&PVe(B.bounds,l.bounds)&&B.onClick===l.onClick||(t.current.boundingBoxes.set(I,l),n())},[n]),r=AA.useCallback(I=>{t.current.boundingBoxes.delete(I)&&n()},[n]),a=AA.useCallback(I=>(t.current.subscribers.add(I),()=>{t.current.subscribers.delete(I)}),[]),g=AA.useCallback(I=>t.current.hoveringIds.has(I),[]);AA.useEffect(()=>{const I=Q=>{const{clientX:h,clientY:E}=Q,u=t.current.pointer;u&&u.x===h&&u.y===E||(t.current.pointer={x:h,y:E},n())},l=()=>{t.current.pointer!==null&&(t.current.pointer=null,t.current.mouseDownPosition=null,n())},B=Q=>{t.current.mouseDownPosition={x:Q.clientX,y:Q.clientY}},C=Q=>{const{clientX:h,clientY:E}=Q,u=t.current.mouseDownPosition;if(u&&Math.sqrt(Math.pow(h-u.x,2)+Math.pow(E-u.y,2))>TVe){t.current.mouseDownPosition=null;return}t.current.mouseDownPosition=null;for(const d of t.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=AA.useMemo(()=>({registerBoundingBox:o,updateBoundingBox:s,unregisterBoundingBox:r,subscribe:a,isHovering:g}),[o,s,r,a,g]);return Z.jsx(VfA.Provider,{value:c,children:e})},fct=e=>{const A=AA.useContext(VfA);if(!A)throw new Error("useMouseEventsOverBoundingBox must be used within a MouseTracker");const t=AA.useId(),i=AA.useRef(e);i.current=e;const n=AA.useMemo(()=>s=>{i.current.onClick?.(s)},[]);return AA.useEffect(()=>(A.registerBoundingBox(t,{bounds:i.current.bounds,onClick:i.current.onClick?n:void 0}),()=>{A.unregisterBoundingBox(t)}),[A,n,t]),AA.useEffect(()=>{A.updateBoundingBox(t,{bounds:i.current.bounds,onClick:i.current.onClick?n:void 0})},[A,n,t,e.bounds?.minX,e.bounds?.maxX,e.bounds?.minY,e.bounds?.maxY,e.onClick]),{hovering:AA.useSyncExternalStore(A.subscribe,()=>A.isHovering(t),()=>!1)}},qVe=(e,A)=>!e&&!A?!0:!e||!A?!1:Math.abs(e.bounds.minX-A.bounds.minX)<.5&&Math.abs(e.bounds.maxX-A.bounds.maxX)<.5&&Math.abs(e.bounds.minY-A.bounds.minY)<.5&&Math.abs(e.bounds.maxY-A.bounds.maxY)<.5&&Math.abs(e.rect.left-A.rect.left)<.5&&Math.abs(e.rect.top-A.rect.top)<.5&&Math.abs(e.rect.width-A.rect.width)<.5&&Math.abs(e.rect.height-A.rect.height)<.5,OVe=({componentId:e,svgDivRef:A,containerRef:t,onComponentClick:i,onHoverChange:n,showOutline:o,circuitJsonKey:s})=>{const[r,a]=AA.useState(null),g=AA.useRef(null),c=AA.useCallback(()=>{g.current=null;const h=A.current,E=t.current;if(!h||!E){a(w=>w&&null);return}const u=h.querySelector(`[data-schematic-component-id="${e}"]`);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=>qVe(w,m)?w:m)},[e,t,A]),I=AA.useCallback(()=>{g.current===null&&(g.current=window.requestAnimationFrame(c))},[c]);AA.useEffect(()=>{I()},[I,s]),AA.useEffect(()=>{I();const h=A.current,E=t.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,t]);const l=AA.useCallback(h=>{i&&i(e,h)},[e,i]),B=r?.bounds??null,{hovering:C}=fct({bounds:B,onClick:i?l:void 0});if(AA.useEffect(()=>{n&&n(e,C)},[C,e,n]),!r||!C||!o)return null;const Q=r.rect;return Z.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:oS.schematicComponentHoverOutline}})},WVe=(e,A)=>!e&&!A?!0:!e||!A?!1:Math.abs(e.bounds.minX-A.bounds.minX)<.5&&Math.abs(e.bounds.maxX-A.bounds.maxX)<.5&&Math.abs(e.bounds.minY-A.bounds.minY)<.5&&Math.abs(e.bounds.maxY-A.bounds.maxY)<.5&&Math.abs(e.rect.left-A.rect.left)<.5&&Math.abs(e.rect.top-A.rect.top)<.5&&Math.abs(e.rect.width-A.rect.width)<.5&&Math.abs(e.rect.height-A.rect.height)<.5,ZVe=({portId:e,portLabel:A,svgDivRef:t,containerRef:i,onPortClick:n,onHoverChange:o,showOutline:s,circuitJsonKey:r})=>{const[a,g]=AA.useState(null),c=AA.useRef(null),I=AA.useCallback(()=>{c.current=null;const E=t.current,u=i.current;if(!E||!u){g(S=>S&&null);return}const d=E.querySelector(`[data-schematic-port-id="${e}"]`);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=>WVe(S,D)?S:D)},[e,i,t]),l=AA.useCallback(()=>{c.current===null&&(c.current=window.requestAnimationFrame(I))},[I]);AA.useEffect(()=>{l()},[l,r]),AA.useEffect(()=>{l();const E=t.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,t,i]);const B=AA.useCallback(E=>{n&&n(e,E)},[e,n]),C=a?.bounds??null,{hovering:Q}=fct({bounds:C,onClick:n?B:void 0});if(AA.useEffect(()=>{o&&o(e,Q)},[Q,e,o]),!a||!s)return null;const h=a.rect;return Z.jsxs(Z.Fragment,{children:[Z.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:oS.schematicPortHoverOutline,transition:"border-color 0.15s, background-color 0.15s"}}),Q&&A&&Z.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:oS.schematicPortHoverOutline+1},children:A})]})},VVe=({circuitJson:e,containerStyle:A,editEvents:t=[],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&&yVe();const[Q,h]=AA.useState(!1),[E,u]=AA.useState({showVoltage:!0,showCurrent:!1,startTime:0,duration:20}),d=QA=>`${QA?.length||0}_${QA?.editCount||0}`,f=AA.useMemo(()=>d(e),[e]),m=AA.useMemo(()=>{if(!c)return null;try{return HVe(e,E)}catch(QA){return console.error("Failed to generate SPICE string",QA),null}},[f,c,E.startTime,E.duration]),[w,D]=AA.useState(!1);AA.useEffect(()=>{D(!1)},[f]);const{plotData:S,nodes:_,isLoading:b,error:R}=UVe(w?m:null),[F,H]=AA.useState(n),[Y,J]=AA.useState(!0),[O,W]=AA.useState(!1),z=o||O,[tA,aA]=AA.useState(!a),[eA,oA]=AA.useState(!1),[rA,BA]=AA.useState(()=>I?!1:YVe("schematic_viewer_show_groups",!1)),[pA,kA]=AA.useState(!1),MA=AA.useRef(new Set),TA=AA.useCallback((QA,ot)=>{ot?MA.current.add(QA):MA.current.delete(QA),kA(MA.current.size>0)},[]),[EA,_A]=AA.useState(!1),dA=AA.useRef(new Set),WA=AA.useCallback((QA,ot)=>{ot?dA.current.add(QA):dA.current.delete(QA),_A(dA.current.size>0)},[]),VA=AA.useRef(null),It=AA.useRef(null),mA=AA.useMemo(()=>{try{return qE(e).schematic_component?.list()?.map(QA=>QA.schematic_component_id)??[]}catch(QA){return console.error("Failed to derive schematic component ids",QA),[]}},[f,e]),gt=AA.useMemo(()=>{if(!B)return[];try{return(qE(e).schematic_port?.list()??[]).map(ot=>{const Bt=qE(e).source_port.get(ot.source_port_id),Lt=(Bt?.source_component_id?qE(e).source_component.get(Bt.source_component_id):null)?.name??"?",Tt=ot.display_pin_label??Bt?.pin_number??Bt?.name??"?";return{portId:ot.source_port_id,label:`${Lt}.${Tt}`}})}catch(QA){return console.error("Failed to derive schematic port info",QA),[]}},[f,e,B]),PA=QA=>{const ot=QA.touches[0];It.current={x:ot.clientX,y:ot.clientY}},UA=QA=>{const ot=QA.changedTouches[0],Bt=It.current;if(!Bt)return;const yt=Math.abs(ot.clientX-Bt.x),Lt=Math.abs(ot.clientY-Bt.y);yt<10&&Lt<10&&(QA.preventDefault(),aA(!0)),It.current=null},[jA,xA]=AA.useState([]),DA=AA.useRef(e);AA.useEffect(()=>{const QA=d(e),ot=d(DA.current);QA!==ot&&(xA([]),DA.current=e)},[e]);const{ref:HA,cancelDrag:FA,transform:KA}=JJ({onSetTransform(QA){VA.current&&(VA.current.style.transform=$d(QA))},enabled:tA&&!Q}),{containerWidth:ZA,containerHeight:nt}=dct(HA),SA=AA.useMemo(()=>!ZA||!nt?"":_9(e,{width:ZA,height:nt||720,grid:z?{cellSize:1,labelCells:!0}:void 0,colorOverrides:g}),[f,ZA,nt,z]),CA=AA.useMemo(()=>SA.match(/<svg[^>]*style="[^"]*background-color:\s*([^;\"]+)/i)?.[1]??"transparent",[SA]),hA=AA.useMemo(()=>{if(!SA)return ba();const QA=SA.match(/data-real-to-screen-transform="([^"]+)"/)?.[1];try{return v4(QA)}catch(ot){return console.error(ot),ba()}},[SA]),JA=QA=>{xA(ot=>[...ot,QA]),i&&i(QA)},rt=AA.useMemo(()=>[...t,...jA],[t,jA]),{handleMouseDown:Qt,handleTouchStart:mt,isDragging:_t,activeEditEvent:kt}=DVe({onEditEvent:JA,cancelDrag:FA,realToSvgProjection:hA,svgToScreenProjection:KA,circuitJson:e,editEvents:rt,enabled:F&&tA&&!Q,snapToGrid:Y});EVe({svgDivRef:VA,editEvents:rt,realToSvgProjection:hA,svgToScreenProjection:KA,activeEditEvent:kt}),uVe({svgDivRef:VA,circuitJson:e,activeEditEvent:kt,editEvents:rt}),dVe({svgDivRef:VA,circuitJson:e,circuitJsonKey:f,showGroups:rA&&!I});const Pt=AA.useRef(mt);AA.useEffect(()=>{Pt.current=mt},[mt]);const le=AA.useMemo(()=>Z.jsx("div",{ref:VA,style:{pointerEvents:a?tA?"auto":"none":"auto",transformOrigin:"0 0"},className:l?"schematic-component-clickable":void 0,onTouchStart:QA=>{F&&tA&&!Q&&Pt.current(QA)},dangerouslySetInnerHTML:{__html:SA}}),[SA,tA,a,F,Q]);return Z.jsxs(KVe,{children:[l&&Z.jsx("style",{children:".schematic-component-clickable [data-schematic-component-id]:hover { cursor: pointer !important; }"}),C&&Z.jsx("style",{children:"[data-schematic-port-id]:hover { cursor: pointer !important; }"}),Z.jsxs("div",{ref:HA,style:{position:"relative",backgroundColor:CA,overflow:"hidden",cursor:Q?"auto":_t?"grabbing":a&&!tA||pA&&l||EA&&C?"pointer":"grab",minHeight:"300px",...A},onWheelCapture:QA=>{Q&&QA.stopPropagation()},onMouseDown:QA=>{if(a&&!tA){QA.preventDefault(),QA.stopPropagation();return}Qt(QA)},onMouseDownCapture:QA=>{if(a&&!tA){QA.preventDefault(),QA.stopPropagation();return}},onTouchStart:QA=>{Q||PA(QA)},onTouchEnd:QA=>{Q||UA(QA)},children:[!tA&&a&&Z.jsx("div",{onClick:QA=>{QA.preventDefault(),QA.stopPropagation(),aA(!0)},style:{position:"absolute",inset:0,cursor:"pointer",zIndex:oS.clickToInteractOverlay,display:"flex",alignItems:"center",justifyContent:"center",pointerEvents:"all",touchAction:"pan-x pan-y pinch-zoom"},children:Z.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"})}),Z.jsx(xVe,{active:eA,onClick:()=>oA(!eA)}),s&&Z.jsx(SVe,{active:F,onClick:()=>H(!F)}),s&&F&&Z.jsx(bVe,{active:Y,onClick:()=>J(!Y)}),Z.jsx(kVe,{circuitJson:e,circuitJsonKey:f,isVisible:eA,onClose:()=>oA(!1),showGroups:rA,onToggleGroups:QA=>{I||(BA(QA),JVe("schematic_viewer_show_groups",QA))},showGrid:z,onToggleGrid:W}),c&&Z.jsx(FVe,{onClick:()=>h(!0)}),Q&&Z.jsx(GVe,{spiceString:m,onClose:()=>h(!1),plotData:S,nodes:_,isLoading:b,error:R,simOptions:E,onSimOptionsChange:QA=>{D(!0),u(QA)},hasRun:w}),l&&mA.map(QA=>Z.jsx(OVe,{componentId:QA,svgDivRef:VA,containerRef:HA,showOutline:!0,circuitJsonKey:f,onHoverChange:TA,onComponentClick:(ot,Bt)=>{l?.({schematicComponentId:ot,event:Bt})}},QA)),le,B&>.map(({portId:QA,label:ot})=>Z.jsx(ZVe,{portId:QA,portLabel:ot,svgDivRef:VA,containerRef:HA,showOutline:!0,circuitJsonKey:f,onHoverChange:WA,onPortClick:C?(Bt,yt)=>{C?.({schematicPortId:Bt,event:yt})}:void 0},QA))]})]})},jVe=({circuitJson:e,containerStyle:A,colorOverrides:t,width:i,height:n,className:o})=>{const[s,r]=AA.useState(null),[a,g]=AA.useState(!0),[c,I]=AA.useState(null),[l,B]=AA.useState(null),C=AA.useRef(null),Q=AA.useRef(null),{containerWidth:h,containerHeight:E}=dct(C),[u,d]=AA.useState(!1),{ref:f}=JJ({onSetTransform(H){Q.current&&(Q.current.style.transform=$d(H))}}),m=i||h||1e3,w=n||E||600;AA.useEffect(()=>{g(!0),I(null),r(e),g(!1)},[e]);const D=AA.useMemo(()=>s&&s.find(Y=>Y.type==="simulation_experiment")?.simulation_experiment_id||null,[s]),S=AA.useMemo(()=>s?s.filter(H=>H.type==="simulation_transient_voltage_graph").map(H=>H.simulation_transient_voltage_graph_id):[],[s]),_=AA.useMemo(()=>{if(!s||!m||!w||!D)return"";try{return Iat({circuitJson:s,simulation_experiment_id:D,simulation_transient_voltage_graph_ids:S,width:m,height:w,schematicOptions:{colorOverrides:t}})}catch(H){return console.error("Failed to generate fallback schematic SVG:",H),""}},[s,m,w,t,D,S]);AA.useEffect(()=>{if(!_){B(null);return}try{const H=new Blob([_],{type:"image/svg+xml"}),Y=URL.createObjectURL(H);return B(Y),()=>{URL.revokeObjectURL(Y)}}catch(H){console.error("Failed to create SVG object URL:",H),B(null)}},[_]);const b=AA.useMemo(()=>_?_.match(/<svg[^>]*style="[^"]*background-color:\s*([^;\"]+)/i)?.[1]??"transparent":"transparent",[_]),R=H=>{d(!0)},F=H=>{d(!0)};return AA.useEffect(()=>{const H=()=>{d(!1)},Y=()=>{d(!1)};return window.addEventListener("mouseup",H),window.addEventListener("touchend",Y),()=>{window.removeEventListener("mouseup",H),window.removeEventListener("touchend",Y)}},[]),a?Z.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?Z.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:"#fef2f2",minHeight:"300px",fontFamily:"sans-serif",fontSize:"16px",color:"#dc2626",...A},className:o,children:Z.jsxs("div",{style:{textAlign:"center",padding:"20px"},children:[Z.jsx("div",{style:{fontWeight:"bold",marginBottom:"8px"},children:"Circuit Conversion Error"}),Z.jsx("div",{style:{fontSize:"14px"},children:c})]})}):_?Z.jsx("div",{ref:H=>{C.current=H,f.current=H},style:{position:"relative",backgroundColor:b,overflow:"hidden",minHeight:"300px",cursor:u?"grabbing":"grab",...A},className:o,onMouseDown:R,onTouchStart:F,children:l?Z.jsx("img",{ref:Q,src:l,alt:"Circuit Simulation",style:{transformOrigin:"0 0",width:"100%",height:"100%",display:"block",objectFit:"contain"}}):Z.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",height:"100%",minHeight:"300px",color:"#666",fontFamily:"sans-serif"},children:"Failed to render SVG"})}):Z.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",backgroundColor:"#f8fafc",minHeight:"300px",fontFamily:"sans-serif",gap:"12px",...A},className:o,children:[Z.jsx("div",{style:{fontSize:"16px",color:"#475569",fontWeight:500},children:"No Simulation Found"}),Z.jsxs("div",{style:{fontSize:"14px",color:"#64748b"},children:["Use"," ",Z.jsx("code",{style:{backgroundColor:"#e2e8f0",padding:"2px 6px",borderRadius:"4px",fontFamily:"monospace",fontSize:"13px"},children:"<analogsimulation />"})," ","to create simulations"]})]})},yct=e=>{const[A,t]=AA.useState(0),[i,n]=AA.useState(0);return AA.useEffect(()=>{if(!e.current)return;const o=()=>{const r=e.current?.getBoundingClientRect();t(r?.width||0),n(r?.height||0)};o();const s=new ResizeObserver(o);return s.observe(e.current),window.addEventListener("resize",o),()=>{s.disconnect(),window.removeEventListener("resize",o)}},[]),{containerWidth:A,containerHeight:i}};wc("assembly-viewer");var mct=()=>{wc.enable("assembly-viewer*")},zVe=({circuitJson:e,containerStyle:A,debugGrid:t=!1,debug:i=!1})=>{i&&mct();const n=AA.useRef(null),{ref:o}=JJ({onSetTransform(c){n.current&&(n.current.style.transform=$d(c))}}),{containerWidth:s,containerHeight:r}=yct(o),a=AA.useMemo(()=>!s||!r?"":Jrt(e,{width:s,height:r||720}),[e,s,r]);AA.useMemo(()=>{if(!a)return ba();const c=a.match(/data-real-to-screen-transform="([^"]+)"/)?.[1];try{return v4(c)}catch(I){return console.error(I),ba()}},[a]);const g=AA.useMemo(()=>Z.jsx("div",{ref:n,style:{pointerEvents:"auto",transformOrigin:"0 0"},dangerouslySetInnerHTML:{__html:a}}),[a]);return Z.jsx("div",{ref:o,style:{position:"relative",backgroundColor:"#FFFFFF",overflow:"hidden",minHeight:"300px",...A},children:g})},XVe=({circuitJson:e,containerStyle:A,debugGrid:t=!1,debug:i=!1})=>{i&&mct();const n=AA.useRef(null),{ref:o}=JJ({onSetTransform(c){n.current&&(n.current.style.transform=$d(c))}}),{containerWidth:s,containerHeight:r}=yct(o),a=AA.useMemo(()=>!s||!r?"":cfA(e,{width:s,height:r||720}),[e,s,r]);AA.useMemo(()=>{if(!a)return ba();const c=a.match(/data-real-to-screen-transform="([^"]+)"/)?.[1];try{return v4(c)}catch(I){return console.error(I),ba()}},[a]);const g=AA.useMemo(()=>Z.jsx("div",{ref:n,style:{pointerEvents:"auto",transformOrigin:"0 0"},dangerouslySetInnerHTML:{__html:a}}),[a]);return Z.jsx("div",{ref:o,style:{position:"relative",backgroundColor:"#FFFFFF",overflow:"hidden",minHeight:"300px",...A},children:g})};const wct=["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."],$Ve=(()=>{let e=wct[Math.floor(Math.random()*wct.length)];return e=e.replace(/</g,"<"),e=e.replace(/>/g,">"),e=e.replace(new RegExp('(?<!href=")(?<!\\()(?<!\\]\\()(https?:\\/\\/[^\\s\\)\\]]+)',"g"),(A,t)=>`<a class="rf-text-blue-500 rf-underline" href="${A}" target="_blank">${A}</a>`),e=e.replace(/\[([^\]]+)\]\((https?:\/\/[^\)]+)\)/g,'<a class="rf-text-blue-500 rf-underline" href="$2" target="_blank">$1</a>'),e})(),Ob=({onRunClicked:e})=>Z.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:[Z.jsx(JJe,{className:"rf-size-14 rf-mb-4"}),Z.jsxs("p",{className:"rf-text-md rf-break-words rf-max-w-xl rf-text-center",children:["Tip: ",Z.jsx("span",{dangerouslySetInnerHTML:{__html:$Ve}})]}),e&&Z.jsxs(iI,{className:"rf-mt-4 rf-bg-blue-600 rf-hover:bg-blue-500",onClick:e,children:["Run Code",Z.jsx(qJe,{className:"rf-w-3 rf-h-3 rf-ml-2"})]})]}),oj=({text:e,onClick:A})=>Z.jsx("span",{className:"rf-cursor-pointer rf-underline rf-text-blue-600 rf-mx-2",onClick:A,children:e}),sj=e=>Z.jsxs("div",{className:"rf-leading-5",children:[Z.jsx("div",{className:"rf-py-2 rf-font-bold",children:e.column.name}),Z.jsx("div",{children:e.field?.()??Z.jsx("input",{type:"text",className:"rf-border rf-rounded rf-p-1 rf-w-full",onChange:A=>{e.onTextChange?.(A.target.value)}})})]}),A9e=({open:e,children:A,title:t,onClose:i})=>e?Z.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:Z.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:[Z.jsx("h2",{className:"rf-mt-0 rf-text-md rf-pb-4",children:t}),Z.jsx("button",{type:"button",className:"rf-absolute rf-top-2 rf-right-4 rf-text-2xl rf-font-bold",onClick:i,children:"×"}),A]})}):null,t9e=({elements:e})=>{const[A,t]=AA.useState({open:!1}),[i,n]=AA.useReducer((c,I)=>({...c,...I}),{}),o=[...new Set(e.map(c=>c.type))],s=e.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=>Z.jsxs("div",{className:"rf-flex rf-items-center",children:[Z.jsx(oj,{text:c.primary_id,onClick:()=>n({focused_id:c.primary_id,id_search:void 0,selector_search:void 0})}),Z.jsx("span",{className:"rf-flex-grow"}),Z.jsx(oj,{text:"(JSON)",onClick:()=>t({open:!0,element:c._og_elm,title:c.primary_id})})]}),renderHeaderCell:c=>Z.jsx(sj,{column:c,onTextChange:I=>n({id_search:I}),field:i.focused_id?()=>Z.jsxs("div",{children:["Focus:"," ",Z.jsx("span",{className:"rf-underline",children:i.focused_id}),Z.jsx(oj,{text:"(unfocus)",onClick:()=>n({focused_id:void 0})})]}):void 0})},{key:"type",name:"type",renderHeaderCell:c=>Z.jsx(sj,{column:c,field:()=>Z.jsxs("select",{onChange:I=>n({component_type_filter:I.target.value}),className:"rf-border rf-rounded rf-p-1 rf-w-full",children:[Z.jsx("option",{value:"any",children:"any"},"any"),Z.jsx("option",{value:"source",children:"source"},"source"),Z.jsx("option",{value:"source/pcb",children:"source/pcb"},"source/pcb"),Z.jsx("option",{value:"source/schematic",children:"source/schematic"},"source/schematic"),o.map(I=>Z.jsx("option",{value:I,children:I},I))]})})},{key:"name",name:"name",renderHeaderCell:c=>Z.jsx(sj,{column:c,onTextChange:I=>n({name_search:I})})},{key:"selector_path",name:"selector_path",renderHeaderCell:c=>Z.jsx(sj,{column:c,onTextChange:I=>n({selector_search:I})})},{key:"other_ids",name:"other_ids",renderCell:c=>Z.jsx("div",{className:"rf-space-x-2",children:Object.entries(c.other_ids).map(([I,l])=>Z.jsx(oj,{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 Z.jsxs("div",{className:"rf-font-mono rf-text-xs rf-bg-white",children:[Z.jsx("div",{className:"rf-overflow-x-auto",children:Z.jsxs("table",{className:"rf-table-auto rf-w-full rf-text-left",children:[Z.jsx("thead",{children:Z.jsx("tr",{children:a.map(c=>Z.jsx("th",{className:"rf-px-4 rf-py-2 rf-border-b",children:c.renderHeaderCell?c.renderHeaderCell(c):c.name},c.key))})}),Z.jsx("tbody",{children:g.map((c,I)=>Z.jsx("tr",{className:"rf-hover:bg-gray-100",children:a.map(l=>Z.jsx("td",{className:"rf-px-4 rf-py-2 rf-border-b",children:l.renderCell?l.renderCell(c):c[l.key]},l.key))},I))})]})}),Z.jsx(A9e,{open:A.open,onClose:()=>t({open:!1}),title:A.open?A.title:"",children:Z.jsx("div",{className:"rf-bg-gray-800 rf-p-3 rf-text-white rf-rounded",children:Z.jsx("pre",{className:"rf-whitespace-pre-wrap",children:A.open?JSON.stringify(A.element,null,2):""})})})]})},e9e=(e,A)=>e==="jlcpcb"?Z.jsx("a",{className:"rf-underline rf-text-blue-500",target:"_blank",rel:"noreferrer",href:`https://jlcpcb.com/partdetail/${A}`,children:A}):A,i9e=({circuitJson:e})=>{const A=e.filter(i=>i.type==="source_component"),t=new Set;for(const i of A)if(i.supplier_part_numbers)for(const n of Object.keys(i.supplier_part_numbers))t.add(n);return Z.jsx("div",{className:"rf-overflow-x-auto",children:Z.jsxs("table",{className:"rf-w-full rf-text-left rf-text-sm",children:[Z.jsx("thead",{children:Z.jsxs("tr",{className:"rf-border-b",children:[Z.jsx("th",{className:"rf-p-2",children:"Name"}),Array.from(t).map(i=>Z.jsx("th",{className:"rf-p-2 rf-capitalize",children:i},i))]})}),Z.jsx("tbody",{children:A.map(i=>Z.jsxs("tr",{className:"rf-border-b",children:[Z.jsx("td",{className:"rf-p-2",children:i.name}),Array.from(t).map(n=>Z.jsx("td",{className:"rf-p-2",children:e9e(n,i.supplier_part_numbers?.[n]?.[0]||"")},n))]},i.source_component_id))})]})})},jfA=AA.forwardRef(({className:e,type:A,...t},i)=>Z.jsx("input",{type:A,className:bo("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",e),ref:i,...t}));jfA.displayName="Input";var Dct={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}}},zfA=new Set;for(const[e,A]of Object.entries(Dct)){zfA.add(e);for(const t of Object.keys(A.variants))zfA.add(t)}function n9e(e){for(const[A,t]of Object.entries(Dct))if(e in t.variants)return{baseUnit:t.baseUnit,conversionFactor:t.variants[e]};return{baseUnit:e,conversionFactor:1}}var Sct={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 xw(e){if(e==null)return{parsedUnit:null,unitOfValue:null,value:null};if(typeof e=="string"&&e.match(/^-?[\d\.]+$/))return{value:Number.parseFloat(e),parsedUnit:null,unitOfValue:null};if(typeof e=="number")return{value:e,parsedUnit:null,unitOfValue:null};if(typeof e=="object"&&"x"in e&&"y"in e){const{parsedUnit:r,unitOfValue:a}=xw(e.x),g=xw(e.x),c=xw(e.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 t=e.toString().split("").reverse().join("").match(/[^\d\s]+/)?.[0];if(!t)throw new Error(`Could not determine unit: "${e}"`);const i=t.split("").reverse().join(""),n=e.slice(0,-i.length);if(i in Sct&&!zfA.has(i)){const r=Sct[i];return{parsedUnit:null,unitOfValue:null,value:Number.parseFloat(n)*r}}const{baseUnit:o,conversionFactor:s}=n9e(i);return{parsedUnit:i,unitOfValue:o,value:s*Number.parseFloat(n)}}var rj=U().or(OA()).transform(e=>xw(e).value),XfA=U().or(OA()).transform(e=>xw(e).value).transform(e=>Number.parseFloat(e.toPrecision(12))),bct=U().or(OA()).transform(e=>xw(e).value),Wb=U().or(OA()).transform(e=>xw(e).value),rn=U().or(OA()).transform(e=>xw(e).value),dM=U().or(OA()).transform(e=>xw(e).value),Ee=rn,$2=U().or(OA()).transform(e=>xw(e).value),aT=U().or(OA()).transform(e=>xw(e).value),o9e=aT,pM=aT,xct=U().datetime(),$C=U().or(OA()).transform(e=>typeof e=="number"?e:e.endsWith("deg")?Number.parseFloat(e.split("deg")[0]):e.endsWith("rad")?Number.parseFloat(e.split("rad")[0])*180/Math.PI:Number.parseFloat(e)),_ct=OA().or(U().endsWith("mAh")).transform(e=>{if(typeof e=="string"){const A=e.replace("mAh",""),t=Number.parseFloat(A);if(Number.isNaN(t))throw new Error("Invalid capacity");return t}return e}).describe("Battery capacity in mAh"),dn=et({x:Ee,y:Ee}),s9e=dn,xk=et({x:Ee,y:Ee,z:Ee}),r9e=xk,$fA=et({width:OA(),height:OA()}),a9e=e=>{const A="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";return Array.from({length:e},()=>A[Math.floor(Math.random()*A.length)]).join("")},Xe=e=>U().optional().default(()=>`${e}_${a9e(10)}`),_k=te(["top_left","top_center","top_right","center_left","center","center_right","bottom_left","bottom_center","bottom_right"]),g9e=te(["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"]),kct=et({project_relative_path:U(),url:U(),mimetype:U()}),aj=dn.extend({rotation:$C.optional()}),A0A=et({size:dn.optional(),thickness:Ee.optional()}),vct=et({font:A0A.optional()}),gT=et({value:U(),at:aj.optional(),layer:U().optional(),uuid:U().optional(),hide:qA().optional(),effects:vct.optional()}),Fct=et({Reference:gT.optional(),Value:gT.optional(),Datasheet:gT.optional(),Description:gT.optional()}),Mct=et({through_hole:qA().optional(),smd:qA().optional(),exclude_from_pos_files:qA().optional(),exclude_from_bom:qA().optional()}),Gct=et({name:U(),type:U(),shape:U().optional(),at:aj.optional(),size:dn.optional(),drill:Ee.optional(),layers:bt(U()).optional(),removeUnusedLayers:qA().optional(),uuid:U().optional()}),Rct=et({path:U(),offset:xk.optional(),scale:xk.optional(),rotate:xk.optional()}),Nct=et({footprintName:U().optional(),version:Re([OA(),U()]).optional(),generator:U().optional(),generatorVersion:Re([OA(),U()]).optional(),layer:U().optional(),properties:Fct.optional(),attributes:Mct.optional(),pads:bt(Gct).optional(),embeddedFonts:qA().optional(),model:Rct.optional()}),Lct=et({hide:qA().optional()}),Uct=et({offset:Ee.optional(),hide:qA().optional()}),Hct=et({font:A0A.optional(),justify:Re([U(),bt(U())]).optional(),hide:qA().optional()}),kk=et({value:U(),id:Re([OA(),U()]).optional(),at:aj.optional(),effects:Hct.optional()}),Yct=et({Reference:kk.optional(),Value:kk.optional(),Footprint:kk.optional(),Datasheet:kk.optional(),Description:kk.optional(),ki_keywords:kk.optional(),ki_fp_filters:kk.optional()}),Jct=et({symbolName:U().optional(),extends:U().optional(),pinNumbers:Lct.optional(),pinNames:Uct.optional(),excludeFromSim:qA().optional(),inBom:qA().optional(),onBoard:qA().optional(),properties:Yct.optional(),embeddedFonts:qA().optional()}),UI=et({error_type:U(),message:U(),is_fatal:qA().optional()}),Tct=te(["jlcpcb","macrofab","pcbway","digikey","mouser","lcsc"]),oI=et({type:bA("source_component"),ftype:U().optional(),source_component_id:U(),name:U(),manufacturer_part_number:U().optional(),supplier_part_numbers:Sa(Tct,bt(U())).optional(),display_value:U().optional(),display_name:U().optional(),are_pins_interchangeable:qA().optional(),internally_connected_source_port_ids:bt(bt(U())).optional(),source_group_id:U().optional(),subcircuit_id:U().optional()}),t0A=oI.extend({ftype:bA("simple_capacitor"),capacitance:XfA,max_voltage_rating:Wb.optional(),display_capacitance:U().optional(),max_decoupling_trace_length:Ee.optional()}),e0A=oI.extend({ftype:bA("simple_resistor"),resistance:rj,display_resistance:U().optional()}),gj=oI.extend({ftype:bA("simple_diode")}),Pct=oI.extend({ftype:bA("simple_fiducial")}),i0A=gj.extend({ftype:bA("simple_led"),color:U().optional(),wavelength:U().optional()}),Kct=oI.extend({ftype:bA("simple_ground")}),n0A=oI.extend({ftype:bA("simple_chip")}),o0A=oI.extend({ftype:bA("simple_power_source"),voltage:Wb}),qct=oI.extend({ftype:bA("simple_current_source"),current:$2,frequency:dM.optional(),peak_to_peak_current:$2.optional(),wave_shape:te(["sine","square","triangle","sawtooth","dc"]).optional().default("dc"),phase:OA().optional(),duty_cycle:OA().min(0).max(1).optional()}),c9e=oI.extend({ftype:bA("simple_fuse"),current_rating_amps:OA().describe("Nominal current in amps the fuse is rated for"),voltage_rating_volts:OA().describe("Voltage rating in volts, e.g. ±5V would be 5")}),s0A=oI.extend({ftype:bA("simple_battery"),capacity:_ct}),r0A=oI.extend({ftype:bA("simple_inductor"),inductance:bct,max_current_rating:OA().optional()}),a0A=oI.extend({ftype:bA("simple_push_button")}),g0A=oI.extend({ftype:bA("simple_potentiometer"),max_resistance:rj,display_max_resistance:U().optional()}),Oct=oI.extend({ftype:bA("simple_crystal"),frequency:OA().describe("Frequency in Hz"),load_capacitance:OA().optional().describe("Load capacitance in pF"),pin_variant:te(["two_pin","four_pin"]).optional()}),c0A=oI.extend({ftype:bA("simple_pin_header"),pin_count:OA(),gender:te(["male","female"]).optional().default("male")}),I0A=oI.extend({ftype:bA("simple_pinout")}),l0A=oI.extend({ftype:bA("simple_resonator"),load_capacitance:XfA,equivalent_series_resistance:rj.optional(),frequency:dM}),B0A=oI.extend({ftype:bA("simple_transistor"),transistor_type:te(["npn","pnp"])}),C0A=oI.extend({ftype:bA("simple_test_point"),footprint_variant:te(["pad","through_hole"]).optional(),pad_shape:te(["rect","circle"]).optional(),pad_diameter:Re([OA(),U()]).optional(),hole_diameter:Re([OA(),U()]).optional(),width:Re([OA(),U()]).optional(),height:Re([OA(),U()]).optional()}),Q0A=oI.extend({ftype:bA("simple_mosfet"),channel_type:te(["n","p"]),mosfet_mode:te(["enhancement","depletion"])}),h0A=oI.extend({ftype:bA("simple_op_amp")}),E0A=oI.extend({ftype:bA("simple_switch")}),u0A=et({type:bA("source_project_metadata"),name:U().optional(),software_used_string:U().optional(),project_url:U().optional(),created_at:xct.optional()}),Wct=UI.extend({type:bA("source_missing_property_error"),source_missing_property_error_id:Xe("source_missing_property_error"),source_component_id:U(),property_name:U(),subcircuit_id:U().optional(),error_type:bA("source_missing_property_error").default("source_missing_property_error")}).describe("The source code is missing a property"),Zct=UI.extend({type:bA("source_failed_to_create_component_error"),source_failed_to_create_component_error_id:Xe("source_failed_to_create_component_error"),error_type:bA("source_failed_to_create_component_error").default("source_failed_to_create_component_error"),component_name:U().optional(),subcircuit_id:U().optional(),parent_source_component_id:U().optional(),pcb_center:et({x:OA().optional(),y:OA().optional()}).optional(),schematic_center:et({x:OA().optional(),y:OA().optional()}).optional()}).describe("Error emitted when a component fails to be constructed"),d0A=UI.extend({type:bA("source_trace_not_connected_error"),source_trace_not_connected_error_id:Xe("source_trace_not_connected_error"),error_type:bA("source_trace_not_connected_error").default("source_trace_not_connected_error"),subcircuit_id:U().optional(),source_group_id:U().optional(),source_trace_id:U().optional(),connected_source_port_ids:bt(U()).optional(),selectors_not_found:bt(U()).optional()}).describe("Occurs when a source trace selector does not match any ports"),Vct=et({type:bA("source_property_ignored_warning"),source_property_ignored_warning_id:Xe("source_property_ignored_warning"),source_component_id:U(),property_name:U(),subcircuit_id:U().optional(),error_type:bA("source_property_ignored_warning").default("source_property_ignored_warning"),message:U()}).describe("The source property was ignored"),p0A=et({type:bA("source_pin_missing_trace_warning"),source_pin_missing_trace_warning_id:Xe("source_pin_missing_trace_warning"),warning_type:bA("source_pin_missing_trace_warning").default("source_pin_missing_trace_warning"),message:U(),source_component_id:U(),source_port_id:U(),subcircuit_id:U().optional()}).describe("Warning emitted when a source component pin is missing a trace connection"),jct=oI.extend({ftype:bA("simple_voltage_probe")}),zct=oI.extend({ftype:bA("interconnect")}),f0A=UI.extend({type:bA("source_i2c_misconfigured_error"),source_i2c_misconfigured_error_id:Xe("source_i2c_misconfigured_error"),error_type:bA("source_i2c_misconfigured_error").default("source_i2c_misconfigured_error"),source_port_ids:bt(U())}).describe("Error emitted when incompatible I2C pins (e.g. SDA and SCL) are connected to the same net"),Xct=oI.extend({ftype:bA("simple_voltage_source"),voltage:Wb,frequency:dM.optional(),peak_to_peak_voltage:Wb.optional(),wave_shape:te(["sinewave","square","triangle","sawtooth"]).optional(),phase:$C.optional(),duty_cycle:OA().optional().describe("Duty cycle as a fraction (0 to 1)")}),$ct=Re([e0A,t0A,gj,Pct,i0A,Kct,n0A,o0A,qct,s0A,r0A,a0A,g0A,Oct,c0A,I0A,l0A,E0A,B0A,C0A,Q0A,h0A,c9e,jct,zct,Xct,u0A,Wct,Zct,d0A,Vct,p0A,f0A]),AIt=et({type:bA("source_port"),pin_number:OA().optional(),port_hints:bt(U()).optional(),name:U(),source_port_id:U(),source_component_id:U().optional(),source_group_id:U().optional(),most_frequently_referenced_by_name:U().optional(),subcircuit_id:U().optional(),subcircuit_connectivity_map_key:U().optional(),must_be_connected:qA().optional(),is_configured_for_i2c_sda:qA().optional(),is_configured_for_i2c_scl:qA().optional(),is_configured_for_spi_mosi:qA().optional(),is_configured_for_spi_miso:qA().optional(),is_configured_for_spi_sck:qA().optional(),is_configured_for_spi_cs:qA().optional(),is_configured_for_uart_tx:qA().optional(),is_configured_for_uart_rx:qA().optional(),supports_i2c_sda:qA().optional(),supports_i2c_scl:qA().optional(),supports_spi_mosi:qA().optional(),supports_spi_miso:qA().optional(),supports_spi_sck:qA().optional(),supports_spi_cs:qA().optional(),supports_uart_tx:qA().optional(),supports_uart_rx:qA().optional()}),tIt=et({type:bA("source_component_internal_connection"),source_component_internal_connection_id:U(),source_component_id:U(),source_port_ids:bt(U()),subcircuit_id:U().optional()}),eIt=et({type:bA("source_trace"),source_trace_id:U(),connected_source_port_ids:bt(U()),connected_source_net_ids:bt(U()),subcircuit_id:U().optional(),subcircuit_connectivity_map_key:U().optional(),max_length:OA().optional(),min_trace_thickness:OA().optional(),display_name:U().optional()}),iIt=et({type:bA("source_group"),source_group_id:U(),subcircuit_id:U().optional(),parent_subcircuit_id:U().optional(),parent_source_group_id:U().optional(),is_subcircuit:qA().optional(),show_as_schematic_box:qA().optional(),name:U().optional(),was_automatically_named:qA().optional()}),nIt=et({type:bA("source_net"),source_net_id:U(),name:U(),member_source_group_ids:bt(U()),is_power:qA().optional(),is_ground:qA().optional(),is_digital_signal:qA().optional(),is_analog_signal:qA().optional(),is_positive_voltage_source:qA().optional(),trace_width:OA().optional(),subcircuit_id:U().optional(),subcircuit_connectivity_map_key:U().optional()}),oIt=et({type:bA("source_board"),source_board_id:U(),source_group_id:U(),title:U().optional()}).describe("Defines a board in the source domain"),sIt=et({type:bA("source_pcb_ground_plane"),source_pcb_ground_plane_id:U(),source_group_id:U(),source_net_id:U(),subcircuit_id:U().optional()}).describe("Defines a ground plane in the source domain"),rIt=["top","bottom","inner1","inner2","inner3","inner4","inner5","inner6"],y0A=te(rIt),Hr=y0A.or(et({name:y0A})).transform(e=>typeof e=="string"?e:e.name),dm=te(["top","bottom"]),aIt=et({type:bA("source_manually_placed_via"),source_manually_placed_via_id:U(),source_group_id:U(),source_net_id:U(),subcircuit_id:U().optional(),source_trace_id:U().optional()}).describe("Defines a via that is manually placed in the source domain"),gIt=UI.extend({type:bA("source_pin_must_be_connected_error"),source_pin_must_be_connected_error_id:Xe("source_pin_must_be_connected_error"),error_type:bA("source_pin_must_be_connected_error").default("source_pin_must_be_connected_error"),source_component_id:U(),source_port_id:U(),subcircuit_id:U().optional()}).describe("Error emitted when a pin with mustBeConnected attribute is not connected to any trace"),cIt=UI.extend({type:bA("unknown_error_finding_part"),unknown_error_finding_part_id:Xe("unknown_error_finding_part"),error_type:bA("unknown_error_finding_part").default("unknown_error_finding_part"),source_component_id:U().optional(),subcircuit_id:U().optional()}).describe("Error emitted when an unexpected error occurs while finding a part"),IIt=et({type:bA("schematic_box"),schematic_component_id:U().optional(),schematic_symbol_id:U().optional(),width:Ee,height:Ee,is_dashed:qA().default(!1),x:Ee,y:Ee,subcircuit_id:U().optional()}).describe("Draws a box on the schematic"),lIt=et({type:bA("schematic_path"),schematic_path_id:Xe("schematic_path"),schematic_component_id:U().optional(),schematic_symbol_id:U().optional(),fill_color:U().optional(),is_filled:qA().optional(),stroke_width:Ee.nullable().optional(),stroke_color:U().optional(),points:bt(dn),subcircuit_id:U().optional()}),BIt=Sa(et({left_margin:rn.optional(),right_margin:rn.optional(),top_margin:rn.optional(),bottom_margin:rn.optional()})),CIt=et({left_size:OA(),right_size:OA(),top_size:OA().optional(),bottom_size:OA().optional()}),QIt=et({left_side:et({pins:bt(OA()),direction:te(["top-to-bottom","bottom-to-top"]).optional()}).optional(),right_side:et({pins:bt(OA()),direction:te(["top-to-bottom","bottom-to-top"]).optional()}).optional(),top_side:et({pins:bt(OA()),direction:te(["left-to-right","right-to-left"]).optional()}).optional(),bottom_side:et({pins:bt(OA()),direction:te(["left-to-right","right-to-left"]).optional()}).optional()}),hIt=Re([CIt,QIt]),EIt=et({type:bA("schematic_component"),size:$fA,center:dn,source_component_id:U().optional(),schematic_component_id:U(),schematic_symbol_id:U().optional(),pin_spacing:rn.optional(),pin_styles:BIt.optional(),box_width:rn.optional(),symbol_name:U().optional(),port_arrangement:hIt.optional(),port_labels:Sa(U()).optional(),symbol_display_value:U().optional(),subcircuit_id:U().optional(),schematic_group_id:U().optional(),is_schematic_group:qA().optional(),source_group_id:U().optional(),is_box_with_pins:qA().optional().default(!0)}),I9e=et({kicad_symbol:Jct.optional()}).catchall(DAA()),uIt=et({type:bA("schematic_symbol"),schematic_symbol_id:U(),name:U().optional(),metadata:I9e.optional()}).describe("Defines a named schematic symbol that can be referenced by components."),dIt=et({type:bA("schematic_line"),schematic_line_id:Xe("schematic_line"),schematic_component_id:U().optional(),schematic_symbol_id:U().optional(),x1:Ee,y1:Ee,x2:Ee,y2:Ee,stroke_width:Ee.nullable().optional(),color:U().default("#000000"),is_dashed:qA().default(!1),subcircuit_id:U().optional()}).describe("Draws a styled line on the schematic"),pIt=et({type:bA("schematic_rect"),schematic_rect_id:Xe("schematic_rect"),schematic_component_id:U().optional(),schematic_symbol_id:U().optional(),center:dn,width:Ee,height:Ee,rotation:$C.default(0),stroke_width:Ee.nullable().optional(),color:U().default("#000000"),is_filled:qA().default(!1),fill_color:U().optional(),is_dashed:qA().default(!1),subcircuit_id:U().optional()}).describe("Draws a styled rectangle on the schematic"),fIt=et({type:bA("schematic_circle"),schematic_circle_id:Xe("schematic_circle"),schematic_component_id:U().optional(),schematic_symbol_id:U().optional(),center:dn,radius:Ee,stroke_width:Ee.nullable().optional(),color:U().default("#000000"),is_filled:qA().default(!1),fill_color:U().optional(),is_dashed:qA().default(!1),subcircuit_id:U().optional()}).describe("Draws a styled circle on the schematic"),yIt=et({type:bA("schematic_arc"),schematic_arc_id:Xe("schematic_arc"),schematic_component_id:U().optional(),schematic_symbol_id:U().optional(),center:dn,radius:Ee,start_angle_degrees:$C,end_angle_degrees:$C,direction:te(["clockwise","counterclockwise"]).default("counterclockwise"),stroke_width:Ee.nullable().optional(),color:U().default("#000000"),is_dashed:qA().default(!1),subcircuit_id:U().optional()}).describe("Draws a styled arc on the schematic"),mIt=et({type:bA("schematic_trace"),schematic_trace_id:U(),source_trace_id:U().optional(),junctions:bt(et({x:OA(),y:OA()})),edges:bt(et({from:et({x:OA(),y:OA()}),to:et({x:OA(),y:OA()}),is_crossing:qA().optional(),from_schematic_port_id:U().optional(),to_schematic_port_id:U().optional()})),subcircuit_id:U().optional(),subcircuit_connectivity_map_key:U().optional()}),l9e=te(["center","left","right","top","bottom"]),wIt=et({type:bA("schematic_text"),schematic_component_id:U().optional(),schematic_symbol_id:U().optional(),schematic_text_id:U(),text:U(),font_size:OA().default(.18),position:et({x:Ee,y:Ee}),rotation:OA().default(0),anchor:Re([l9e.describe("legacy"),_k]).default("center"),color:U().default("#000000"),subcircuit_id:U().optional()}),DIt=et({type:bA("schematic_port"),schematic_port_id:U(),source_port_id:U(),schematic_component_id:U().optional(),center:dn,facing_direction:te(["up","down","left","right"]).optional(),distance_from_component_edge:OA().optional(),side_of_component:te(["top","bottom","left","right"]).optional(),true_ccw_index:OA().optional(),pin_number:OA().optional(),display_pin_label:U().optional(),subcircuit_id:U().optional(),is_connected:qA().optional(),has_input_arrow:qA().optional(),has_output_arrow:qA().optional(),is_drawn_with_inversion_circle:qA().optional()}).describe("Defines a port on a schematic component"),SIt=et({type:bA("schematic_net_label"),schematic_net_label_id:Xe("schematic_net_label"),schematic_trace_id:U().optional(),source_trace_id:U().optional(),source_net_id:U(),center:dn,anchor_position:dn.optional(),anchor_side:te(["top","bottom","left","right"]),text:U(),symbol_name:U().optional(),is_movable:qA().optional(),subcircuit_id:U().optional()}),bIt=UI.extend({type:bA("schematic_error"),schematic_error_id:U(),error_type:bA("schematic_port_not_found").default("schematic_port_not_found"),subcircuit_id:U().optional()}).describe("Defines a schematic error on the schematic"),xIt=UI.extend({type:bA("schematic_layout_error"),schematic_layout_error_id:Xe("schematic_layout_error"),error_type:bA("schematic_layout_error").default("schematic_layout_error"),source_group_id:U(),schematic_group_id:U(),subcircuit_id:U().optional()}).describe("Error emitted when schematic layout fails for a group"),cj=et({type:bA("schematic_debug_object"),label:U().optional(),subcircuit_id:U().optional()}),_It=cj.extend({shape:bA("rect"),center:dn,size:$fA}),kIt=cj.extend({shape:bA("line"),start:dn,end:dn}),vIt=cj.extend({shape:bA("point"),center:dn}),FIt=uf("shape",[_It,kIt,vIt]),MIt=et({type:bA("schematic_voltage_probe"),schematic_voltage_probe_id:U(),source_component_id:U().optional(),name:U().optional(),position:dn,schematic_trace_id:U(),voltage:Wb.optional(),subcircuit_id:U().optional(),color:U().optional(),label_alignment:_k.optional()}).describe("Defines a voltage probe measurement point on a schematic trace"),GIt=et({type:bA("schematic_manual_edit_conflict_warning"),schematic_manual_edit_conflict_warning_id:Xe("schematic_manual_edit_conflict_warning"),warning_type:bA("schematic_manual_edit_conflict_warning").default("schematic_manual_edit_conflict_warning"),message:U(),schematic_component_id:U(),schematic_group_id:U().optional(),subcircuit_id:U().optional(),source_component_id:U()}).describe("Warning emitted when a component has both manual placement and explicit schX/schY coordinates"),RIt=et({type:bA("schematic_group"),schematic_group_id:Xe("schematic_group"),source_group_id:U(),is_subcircuit:qA().optional(),subcircuit_id:U().optional(),width:rn,height:rn,center:dn,schematic_component_ids:bt(U()),show_as_schematic_box:qA().optional(),name:U().optional(),description:U().optional()}).describe("Defines a group of components on the schematic"),NIt=et({type:bA("schematic_table"),schematic_table_id:Xe("schematic_table"),anchor_position:dn,column_widths:bt(Ee),row_heights:bt(Ee),cell_padding:Ee.optional(),border_width:Ee.optional(),subcircuit_id:U().optional(),schematic_component_id:U().optional(),anchor:_k.optional()}).describe("Defines a table on the schematic"),LIt=et({type:bA("schematic_table_cell"),schematic_table_cell_id:Xe("schematic_table_cell"),schematic_table_id:U(),start_row_index:OA(),end_row_index:OA(),start_column_index:OA(),end_column_index:OA(),text:U().optional(),center:dn,width:Ee,height:Ee,horizontal_align:te(["left","center","right"]).optional(),vertical_align:te(["top","middle","bottom"]).optional(),font_size:Ee.optional(),subcircuit_id:U().optional()}).describe("Defines a cell within a schematic_table"),UIt=et({type:bA("schematic_sheet"),schematic_sheet_id:Xe("schematic_sheet"),name:U().optional(),subcircuit_id:U().optional()}).describe("Defines a schematic sheet or page that components can be placed on"),HIt=et({x:Ee,y:Ee,bulge:OA().optional()}),m0A=et({vertices:bt(HIt)}),YIt=et({outer_ring:m0A,inner_rings:bt(m0A).default([])}),JIt=et({x:Ee,y:Ee,via:qA().optional(),via_to_layer:Hr.optional()}),B9e=bt(JIt),TIt=et({x:Ee,y:Ee,via:qA().optional(),to_layer:Hr.optional(),trace_width:Ee.optional()}),PIt=et({type:bA("pcb_component"),pcb_component_id:Xe("pcb_component"),source_component_id:U(),center:dn,layer:Hr,rotation:$C,display_offset_x:U().optional().describe("How to display the x offset for this part, usually corresponding with how the user specified it"),display_offset_y:U().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:qA().optional(),is_allowed_to_be_off_board:qA().optional(),subcircuit_id:U().optional(),pcb_group_id:U().optional(),position_mode:te(["packed","relative_to_group_anchor","none"]).optional(),positioned_relative_to_pcb_group_id:U().optional(),positioned_relative_to_pcb_board_id:U().optional(),metadata:et({kicad_footprint:Nct.optional()}).optional(),obstructs_within_bounds:qA().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"),KIt=et({type:bA("pcb_hole"),pcb_hole_id:Xe("pcb_hole"),pcb_group_id:U().optional(),subcircuit_id:U().optional(),pcb_component_id:U().optional(),hole_shape:bA("circle"),hole_diameter:OA(),x:Ee,y:Ee,is_covered_with_solder_mask:qA().optional(),soldermask_margin:OA().optional()}),C9e=KIt.describe("Defines a circular hole on the PCB"),qIt=et({type:bA("pcb_hole"),pcb_hole_id:Xe("pcb_hole"),pcb_group_id:U().optional(),subcircuit_id:U().optional(),pcb_component_id:U().optional(),hole_shape:bA("rect"),hole_width:OA(),hole_height:OA(),x:Ee,y:Ee,is_covered_with_solder_mask:qA().optional(),soldermask_margin:OA().optional()}),Q9e=qIt.describe("Defines a rectangular (square-capable) hole on the PCB. Use equal width/height for square."),OIt=et({type:bA("pcb_hole"),pcb_hole_id:Xe("pcb_hole"),pcb_group_id:U().optional(),subcircuit_id:U().optional(),pcb_component_id:U().optional(),hole_shape:te(["circle","square"]),hole_diameter:OA(),x:Ee,y:Ee,is_covered_with_solder_mask:qA().optional(),soldermask_margin:OA().optional()}),h9e=OIt.describe("Defines a circular or square hole on the PCB"),WIt=et({type:bA("pcb_hole"),pcb_hole_id:Xe("pcb_hole"),pcb_group_id:U().optional(),subcircuit_id:U().optional(),pcb_component_id:U().optional(),hole_shape:bA("oval"),hole_width:OA(),hole_height:OA(),x:Ee,y:Ee,is_covered_with_solder_mask:qA().optional(),soldermask_margin:OA().optional()}),E9e=WIt.describe("Defines an oval hole on the PCB"),ZIt=et({type:bA("pcb_hole"),pcb_hole_id:Xe("pcb_hole"),pcb_group_id:U().optional(),subcircuit_id:U().optional(),pcb_component_id:U().optional(),hole_shape:bA("pill"),hole_width:OA(),hole_height:OA(),x:Ee,y:Ee,is_covered_with_solder_mask:qA().optional(),soldermask_margin:OA().optional()}),u9e=ZIt.describe("Defines a pill-shaped hole on the PCB"),VIt=et({type:bA("pcb_hole"),pcb_hole_id:Xe("pcb_hole"),pcb_group_id:U().optional(),subcircuit_id:U().optional(),pcb_component_id:U().optional(),hole_shape:bA("rotated_pill"),hole_width:OA(),hole_height:OA(),x:Ee,y:Ee,ccw_rotation:$C,is_covered_with_solder_mask:qA().optional(),soldermask_margin:OA().optional()}),d9e=VIt.describe("Defines a rotated pill-shaped hole on the PCB"),jIt=OIt.or(WIt).or(ZIt).or(VIt).or(KIt).or(qIt),p9e=et({type:bA("pcb_plated_hole"),shape:bA("circle"),pcb_group_id:U().optional(),subcircuit_id:U().optional(),outer_diameter:OA(),hole_diameter:OA(),is_covered_with_solder_mask:qA().optional(),x:Ee,y:Ee,layers:bt(Hr),port_hints:bt(U()).optional(),pcb_component_id:U().optional(),pcb_port_id:U().optional(),pcb_plated_hole_id:Xe("pcb_plated_hole"),soldermask_margin:OA().optional()}),f9e=et({type:bA("pcb_plated_hole"),shape:te(["oval","pill"]),pcb_group_id:U().optional(),subcircuit_id:U().optional(),outer_width:OA(),outer_height:OA(),hole_width:OA(),hole_height:OA(),is_covered_with_solder_mask:qA().optional(),x:Ee,y:Ee,ccw_rotation:$C,layers:bt(Hr),port_hints:bt(U()).optional(),pcb_component_id:U().optional(),pcb_port_id:U().optional(),pcb_plated_hole_id:Xe("pcb_plated_hole"),soldermask_margin:OA().optional()}),y9e=et({type:bA("pcb_plated_hole"),shape:bA("circular_hole_with_rect_pad"),pcb_group_id:U().optional(),subcircuit_id:U().optional(),hole_shape:bA("circle"),pad_shape:bA("rect"),hole_diameter:OA(),rect_pad_width:OA(),rect_pad_height:OA(),rect_border_radius:OA().optional(),hole_offset_x:Ee.default(0),hole_offset_y:Ee.default(0),is_covered_with_solder_mask:qA().optional(),x:Ee,y:Ee,layers:bt(Hr),port_hints:bt(U()).optional(),pcb_component_id:U().optional(),pcb_port_id:U().optional(),pcb_plated_hole_id:Xe("pcb_plated_hole"),soldermask_margin:OA().optional(),rect_ccw_rotation:$C.optional()}),m9e=et({type:bA("pcb_plated_hole"),shape:bA("pill_hole_with_rect_pad"),pcb_group_id:U().optional(),subcircuit_id:U().optional(),hole_shape:bA("pill"),pad_shape:bA("rect"),hole_width:OA(),hole_height:OA(),rect_pad_width:OA(),rect_pad_height:OA(),rect_border_radius:OA().optional(),hole_offset_x:Ee.default(0),hole_offset_y:Ee.default(0),is_covered_with_solder_mask:qA().optional(),x:Ee,y:Ee,layers:bt(Hr),port_hints:bt(U()).optional(),pcb_component_id:U().optional(),pcb_port_id:U().optional(),pcb_plated_hole_id:Xe("pcb_plated_hole"),soldermask_margin:OA().optional()}),w9e=et({type:bA("pcb_plated_hole"),shape:bA("rotated_pill_hole_with_rect_pad"),pcb_group_id:U().optional(),subcircuit_id:U().optional(),hole_shape:bA("rotated_pill"),pad_shape:bA("rect"),hole_width:OA(),hole_height:OA(),hole_ccw_rotation:$C,rect_pad_width:OA(),rect_pad_height:OA(),rect_border_radius:OA().optional(),rect_ccw_rotation:$C,hole_offset_x:Ee.default(0),hole_offset_y:Ee.default(0),is_covered_with_solder_mask:qA().optional(),x:Ee,y:Ee,layers:bt(Hr),port_hints:bt(U()).optional(),pcb_component_id:U().optional(),pcb_port_id:U().optional(),pcb_plated_hole_id:Xe("pcb_plated_hole"),soldermask_margin:OA().optional()}),D9e=et({type:bA("pcb_plated_hole"),shape:bA("hole_with_polygon_pad"),pcb_group_id:U().optional(),subcircuit_id:U().optional(),hole_shape:te(["circle","oval","pill","rotated_pill"]),hole_diameter:OA().optional(),hole_width:OA().optional(),hole_height:OA().optional(),pad_outline:bt(et({x:Ee,y:Ee})).min(3),hole_offset_x:Ee.default(0),hole_offset_y:Ee.default(0),is_covered_with_solder_mask:qA().optional(),x:Ee,y:Ee,layers:bt(Hr),port_hints:bt(U()).optional(),pcb_component_id:U().optional(),pcb_port_id:U().optional(),pcb_plated_hole_id:Xe("pcb_plated_hole"),soldermask_margin:OA().optional(),ccw_rotation:$C.optional()}),zIt=Re([p9e,f9e,y9e,m9e,w9e,D9e]),XIt=et({type:bA("pcb_port"),pcb_port_id:Xe("pcb_port"),pcb_group_id:U().optional(),subcircuit_id:U().optional(),source_port_id:U(),pcb_component_id:U().optional(),x:Ee,y:Ee,layers:bt(Hr),is_board_pinout:qA().optional()}).describe("Defines a port on the PCB"),S9e=et({type:bA("pcb_smtpad"),shape:bA("circle"),pcb_smtpad_id:Xe("pcb_smtpad"),pcb_group_id:U().optional(),subcircuit_id:U().optional(),x:Ee,y:Ee,radius:OA(),layer:Hr,port_hints:bt(U()).optional(),pcb_component_id:U().optional(),pcb_port_id:U().optional(),is_covered_with_solder_mask:qA().optional(),soldermask_margin:OA().optional()}),b9e=et({type:bA("pcb_smtpad"),shape:bA("rect"),pcb_smtpad_id:Xe("pcb_smtpad"),pcb_group_id:U().optional(),subcircuit_id:U().optional(),x:Ee,y:Ee,width:OA(),height:OA(),rect_border_radius:OA().optional(),corner_radius:OA().optional(),layer:Hr,port_hints:bt(U()).optional(),pcb_component_id:U().optional(),pcb_port_id:U().optional(),is_covered_with_solder_mask:qA().optional(),soldermask_margin:OA().optional(),soldermask_margin_left:OA().optional(),soldermask_margin_top:OA().optional(),soldermask_margin_right:OA().optional(),soldermask_margin_bottom:OA().optional()}),x9e=et({type:bA("pcb_smtpad"),shape:bA("rotated_rect"),pcb_smtpad_id:Xe("pcb_smtpad"),pcb_group_id:U().optional(),subcircuit_id:U().optional(),x:Ee,y:Ee,width:OA(),height:OA(),rect_border_radius:OA().optional(),corner_radius:OA().optional(),ccw_rotation:$C,layer:Hr,port_hints:bt(U()).optional(),pcb_component_id:U().optional(),pcb_port_id:U().optional(),is_covered_with_solder_mask:qA().optional(),soldermask_margin:OA().optional(),soldermask_margin_left:OA().optional(),soldermask_margin_top:OA().optional(),soldermask_margin_right:OA().optional(),soldermask_margin_bottom:OA().optional()}),$It=et({type:bA("pcb_smtpad"),shape:bA("pill"),pcb_smtpad_id:Xe("pcb_smtpad"),pcb_group_id:U().optional(),subcircuit_id:U().optional(),x:Ee,y:Ee,width:OA(),height:OA(),radius:OA(),layer:Hr,port_hints:bt(U()).optional(),pcb_component_id:U().optional(),pcb_port_id:U().optional(),is_covered_with_solder_mask:qA().optional(),soldermask_margin:OA().optional()}),_9e=et({type:bA("pcb_smtpad"),shape:bA("rotated_pill"),pcb_smtpad_id:Xe("pcb_smtpad"),pcb_group_id:U().optional(),subcircuit_id:U().optional(),x:Ee,y:Ee,width:OA(),height:OA(),radius:OA(),ccw_rotation:$C,layer:Hr,port_hints:bt(U()).optional(),pcb_component_id:U().optional(),pcb_port_id:U().optional(),is_covered_with_solder_mask:qA().optional(),soldermask_margin:OA().optional()}),k9e=et({type:bA("pcb_smtpad"),shape:bA("polygon"),pcb_smtpad_id:Xe("pcb_smtpad"),pcb_group_id:U().optional(),subcircuit_id:U().optional(),points:bt(dn),layer:Hr,port_hints:bt(U()).optional(),pcb_component_id:U().optional(),pcb_port_id:U().optional(),is_covered_with_solder_mask:qA().optional(),soldermask_margin:OA().optional()}),Alt=uf("shape",[S9e,b9e,x9e,_9e,$It,k9e]).describe("Defines an SMT pad on the PCB"),v9e=et({type:bA("pcb_solder_paste"),shape:bA("circle"),pcb_solder_paste_id:Xe("pcb_solder_paste"),pcb_group_id:U().optional(),subcircuit_id:U().optional(),x:Ee,y:Ee,radius:OA(),layer:Hr,pcb_component_id:U().optional(),pcb_smtpad_id:U().optional()}),F9e=et({type:bA("pcb_solder_paste"),shape:bA("rect"),pcb_solder_paste_id:Xe("pcb_solder_paste"),pcb_group_id:U().optional(),subcircuit_id:U().optional(),x:Ee,y:Ee,width:OA(),height:OA(),layer:Hr,pcb_component_id:U().optional(),pcb_smtpad_id:U().optional()}),M9e=et({type:bA("pcb_solder_paste"),shape:bA("pill"),pcb_solder_paste_id:Xe("pcb_solder_paste"),pcb_group_id:U().optional(),subcircuit_id:U().optional(),x:Ee,y:Ee,width:OA(),height:OA(),radius:OA(),layer:Hr,pcb_component_id:U().optional(),pcb_smtpad_id:U().optional()}),G9e=et({type:bA("pcb_solder_paste"),shape:bA("rotated_rect"),pcb_solder_paste_id:Xe("pcb_solder_paste"),pcb_group_id:U().optional(),subcircuit_id:U().optional(),x:Ee,y:Ee,width:OA(),height:OA(),ccw_rotation:Ee,layer:Hr,pcb_component_id:U().optional(),pcb_smtpad_id:U().optional()}),R9e=et({type:bA("pcb_solder_paste"),shape:bA("oval"),pcb_solder_paste_id:Xe("pcb_solder_paste"),pcb_group_id:U().optional(),subcircuit_id:U().optional(),x:Ee,y:Ee,width:OA(),height:OA(),layer:Hr,pcb_component_id:U().optional(),pcb_smtpad_id:U().optional()}),tlt=Re([v9e,F9e,M9e,G9e,R9e]).describe("Defines solderpaste on the PCB"),elt=et({type:bA("pcb_text"),pcb_text_id:Xe("pcb_text"),pcb_group_id:U().optional(),subcircuit_id:U().optional(),text:U(),center:dn,layer:Hr,width:rn,height:rn,lines:OA(),align:te(["bottom-left"])}).describe("Defines text on the PCB"),ilt=et({route_type:bA("wire"),x:Ee,y:Ee,width:Ee,start_pcb_port_id:U().optional(),end_pcb_port_id:U().optional(),layer:Hr}),nlt=et({route_type:bA("via"),x:Ee,y:Ee,hole_diameter:Ee.optional(),outer_diameter:Ee.optional(),from_layer:U(),to_layer:U()}),olt=Re([ilt,nlt]),slt=et({type:bA("pcb_trace"),source_trace_id:U().optional(),pcb_component_id:U().optional(),pcb_trace_id:Xe("pcb_trace"),pcb_group_id:U().optional(),subcircuit_id:U().optional(),route_thickness_mode:te(["constant","interpolated"]).default("constant").optional(),route_order_index:OA().optional(),should_round_corners:qA().optional(),trace_length:OA().optional(),highlight_color:U().optional(),route:bt(olt)}).describe("Defines a trace on the PCB"),rlt=UI.extend({type:bA("pcb_trace_error"),pcb_trace_error_id:Xe("pcb_trace_error"),error_type:bA("pcb_trace_error").default("pcb_trace_error"),center:dn.optional(),pcb_trace_id:U(),source_trace_id:U(),pcb_component_ids:bt(U()),pcb_port_ids:bt(U()),subcircuit_id:U().optional()}).describe("Defines a trace error on the PCB"),alt=UI.extend({type:bA("pcb_trace_missing_error"),pcb_trace_missing_error_id:Xe("pcb_trace_missing_error"),error_type:bA("pcb_trace_missing_error").default("pcb_trace_missing_error"),center:dn.optional(),source_trace_id:U(),pcb_component_ids:bt(U()),pcb_port_ids:bt(U()),subcircuit_id:U().optional()}).describe("Defines an error when a source trace has no corresponding PCB trace"),glt=UI.extend({type:bA("pcb_port_not_matched_error"),pcb_error_id:Xe("pcb_error"),error_type:bA("pcb_port_not_matched_error").default("pcb_port_not_matched_error"),pcb_component_ids:bt(U()),subcircuit_id:U().optional()}).describe("Defines a trace error on the PCB where a port is not matched"),clt=UI.extend({type:bA("pcb_port_not_connected_error"),pcb_port_not_connected_error_id:Xe("pcb_port_not_connected_error"),error_type:bA("pcb_port_not_connected_error").default("pcb_port_not_connected_error"),pcb_port_ids:bt(U()),pcb_component_ids:bt(U()),subcircuit_id:U().optional()}).describe("Defines an error when a pcb port is not connected to any trace"),Ilt=et({type:bA("pcb_net"),pcb_net_id:Xe("pcb_net"),source_net_id:U().optional(),highlight_color:U().optional()}).describe("Defines a net on the PCB"),llt=et({type:bA("pcb_via"),pcb_via_id:Xe("pcb_via"),pcb_group_id:U().optional(),subcircuit_id:U().optional(),subcircuit_connectivity_map_key:U().optional(),x:Ee,y:Ee,outer_diameter:Ee.default("0.6mm"),hole_diameter:Ee.default("0.25mm"),from_layer:Hr.optional(),to_layer:Hr.optional(),layers:bt(Hr),pcb_trace_id:U().optional(),net_is_assignable:qA().optional(),net_assigned:qA().optional(),is_tented:qA().optional()}).describe("Defines a via on the PCB"),Blt=et({type:bA("pcb_board"),pcb_board_id:Xe("pcb_board"),pcb_panel_id:U().optional(),carrier_pcb_board_id:U().optional(),is_subcircuit:qA().optional(),subcircuit_id:U().optional(),is_mounted_to_carrier_board:qA().optional(),width:rn.optional(),height:rn.optional(),center:dn,display_offset_x:U().optional().describe("How to display the x offset for this board, usually corresponding with how the user specified it"),display_offset_y:U().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:OA().optional().default(4),outline:bt(dn).optional(),shape:te(["rect","polygon"]).optional(),material:te(["fr4","fr1"]).default("fr4"),anchor_position:dn.optional(),anchor_alignment:_k.optional(),position_mode:te(["relative_to_panel_anchor","none"]).optional()}).describe("Defines the board outline of the PCB"),Clt=et({type:bA("pcb_panel"),pcb_panel_id:Xe("pcb_panel"),width:rn,height:rn,center:dn,covered_with_solder_mask:qA().optional().default(!0)}).describe("Defines a PCB panel that can contain multiple boards"),Qlt=UI.extend({type:bA("pcb_placement_error"),pcb_placement_error_id:Xe("pcb_placement_error"),error_type:bA("pcb_placement_error").default("pcb_placement_error"),subcircuit_id:U().optional()}).describe("Defines a placement error on the PCB"),hlt=UI.extend({type:bA("pcb_panelization_placement_error"),pcb_panelization_placement_error_id:Xe("pcb_panelization_placement_error"),error_type:bA("pcb_panelization_placement_error").default("pcb_panelization_placement_error"),pcb_panel_id:U().optional(),pcb_board_id:U().optional(),subcircuit_id:U().optional()}).describe("Defines a panelization placement error on the PCB"),Elt=et({type:bA("pcb_trace_hint"),pcb_trace_hint_id:Xe("pcb_trace_hint"),pcb_port_id:U(),pcb_component_id:U(),route:bt(TIt),subcircuit_id:U().optional()}).describe("A hint that can be used during generation of a PCB trace"),ult=et({type:bA("pcb_silkscreen_line"),pcb_silkscreen_line_id:Xe("pcb_silkscreen_line"),pcb_component_id:U(),pcb_group_id:U().optional(),subcircuit_id:U().optional(),stroke_width:Ee.default("0.1mm"),x1:Ee,y1:Ee,x2:Ee,y2:Ee,layer:dm}).describe("Defines a silkscreen line on the PCB"),dlt=et({type:bA("pcb_silkscreen_path"),pcb_silkscreen_path_id:Xe("pcb_silkscreen_path"),pcb_component_id:U(),pcb_group_id:U().optional(),subcircuit_id:U().optional(),layer:dm,route:bt(dn),stroke_width:rn}).describe("Defines a silkscreen path on the PCB"),plt=et({type:bA("pcb_silkscreen_text"),pcb_silkscreen_text_id:Xe("pcb_silkscreen_text"),pcb_group_id:U().optional(),subcircuit_id:U().optional(),font:bA("tscircuit2024").default("tscircuit2024"),font_size:Ee.default("0.2mm"),pcb_component_id:U(),text:U(),is_knockout:qA().default(!1).optional(),knockout_padding:et({left:rn,top:rn,bottom:rn,right:rn}).default({left:"0.2mm",top:"0.2mm",bottom:"0.2mm",right:"0.2mm"}).optional(),ccw_rotation:OA().optional(),layer:Hr,is_mirrored:qA().default(!1).optional(),anchor_position:dn.default({x:0,y:0}),anchor_alignment:_k.default("center")}).describe("Defines silkscreen text on the PCB"),flt=et({type:bA("pcb_copper_text"),pcb_copper_text_id:Xe("pcb_copper_text"),pcb_group_id:U().optional(),subcircuit_id:U().optional(),font:bA("tscircuit2024").default("tscircuit2024"),font_size:Ee.default("0.2mm"),pcb_component_id:U(),text:U(),is_knockout:qA().default(!1).optional(),knockout_padding:et({left:rn,top:rn,bottom:rn,right:rn}).default({left:"0.2mm",top:"0.2mm",bottom:"0.2mm",right:"0.2mm"}).optional(),ccw_rotation:OA().optional(),layer:Hr,is_mirrored:qA().default(!1).optional(),anchor_position:dn.default({x:0,y:0}),anchor_alignment:_k.default("center")}).describe("Defines copper text on the PCB"),ylt=et({type:bA("pcb_silkscreen_rect"),pcb_silkscreen_rect_id:Xe("pcb_silkscreen_rect"),pcb_component_id:U(),pcb_group_id:U().optional(),subcircuit_id:U().optional(),center:dn,width:rn,height:rn,layer:Hr,stroke_width:rn.default("1mm"),corner_radius:rn.optional(),is_filled:qA().default(!0).optional(),has_stroke:qA().optional(),is_stroke_dashed:qA().optional(),ccw_rotation:OA().optional()}).describe("Defines a silkscreen rect on the PCB"),mlt=et({type:bA("pcb_silkscreen_circle"),pcb_silkscreen_circle_id:Xe("pcb_silkscreen_circle"),pcb_component_id:U(),pcb_group_id:U().optional(),subcircuit_id:U().optional(),center:dn,radius:rn,layer:dm,stroke_width:rn.default("1mm")}).describe("Defines a silkscreen circle on the PCB"),wlt=et({type:bA("pcb_silkscreen_oval"),pcb_silkscreen_oval_id:Xe("pcb_silkscreen_oval"),pcb_component_id:U(),pcb_group_id:U().optional(),subcircuit_id:U().optional(),center:dn,radius_x:Ee,radius_y:Ee,layer:dm,ccw_rotation:$C.optional()}).describe("Defines a silkscreen oval on the PCB"),Dlt=et({type:bA("pcb_silkscreen_pill"),pcb_silkscreen_pill_id:Xe("pcb_silkscreen_pill"),pcb_component_id:U(),pcb_group_id:U().optional(),subcircuit_id:U().optional(),center:dn,width:rn,height:rn,layer:Hr,ccw_rotation:OA().optional()}).describe("Defines a silkscreen pill on the PCB"),Slt=et({type:bA("pcb_fabrication_note_text"),pcb_fabrication_note_text_id:Xe("pcb_fabrication_note_text"),subcircuit_id:U().optional(),pcb_group_id:U().optional(),font:bA("tscircuit2024").default("tscircuit2024"),font_size:Ee.default("1mm"),pcb_component_id:U(),text:U(),layer:dm,anchor_position:dn.default({x:0,y:0}),anchor_alignment:te(["center","top_left","top_right","bottom_left","bottom_right"]).default("center"),color:U().optional()}).describe("Defines a fabrication note in text on the PCB, useful for leaving notes for assemblers or fabricators"),blt=et({type:bA("pcb_fabrication_note_path"),pcb_fabrication_note_path_id:Xe("pcb_fabrication_note_path"),pcb_component_id:U(),subcircuit_id:U().optional(),layer:Hr,route:bt(dn),stroke_width:rn,color:U().optional()}).describe("Defines a fabrication path on the PCB for fabricators or assemblers"),xlt=et({type:bA("pcb_fabrication_note_rect"),pcb_fabrication_note_rect_id:Xe("pcb_fabrication_note_rect"),pcb_component_id:U(),pcb_group_id:U().optional(),subcircuit_id:U().optional(),center:dn,width:rn,height:rn,layer:dm,stroke_width:rn.default("0.1mm"),corner_radius:rn.optional(),is_filled:qA().optional(),has_stroke:qA().optional(),is_stroke_dashed:qA().optional(),color:U().optional()}).describe("Defines a fabrication note rectangle on the PCB"),_lt=et({type:bA("pcb_fabrication_note_dimension"),pcb_fabrication_note_dimension_id:Xe("pcb_fabrication_note_dimension"),pcb_component_id:U(),pcb_group_id:U().optional(),subcircuit_id:U().optional(),layer:dm,from:dn,to:dn,text:U().optional(),text_ccw_rotation:OA().optional(),offset:rn.optional(),offset_distance:rn.optional(),offset_direction:et({x:OA(),y:OA()}).optional(),font:bA("tscircuit2024").default("tscircuit2024"),font_size:rn.default("1mm"),color:U().optional(),arrow_size:rn.default("1mm")}).describe("Defines a measurement annotation within PCB fabrication notes"),klt=et({type:bA("pcb_note_text"),pcb_note_text_id:Xe("pcb_note_text"),pcb_component_id:U().optional(),pcb_group_id:U().optional(),subcircuit_id:U().optional(),name:U().optional(),font:bA("tscircuit2024").default("tscircuit2024"),font_size:Ee.default("1mm"),text:U().optional(),anchor_position:dn.default({x:0,y:0}),anchor_alignment:te(["center","top_left","top_right","bottom_left","bottom_right"]).default("center"),color:U().optional()}).describe("Defines a documentation note in text on the PCB"),vlt=et({type:bA("pcb_note_rect"),pcb_note_rect_id:Xe("pcb_note_rect"),pcb_component_id:U().optional(),pcb_group_id:U().optional(),subcircuit_id:U().optional(),name:U().optional(),text:U().optional(),center:dn,width:rn,height:rn,stroke_width:rn.default("0.1mm"),corner_radius:rn.optional(),is_filled:qA().optional(),has_stroke:qA().optional(),is_stroke_dashed:qA().optional(),color:U().optional()}).describe("Defines a rectangular documentation note on the PCB"),Flt=et({type:bA("pcb_note_path"),pcb_note_path_id:Xe("pcb_note_path"),pcb_component_id:U().optional(),pcb_group_id:U().optional(),subcircuit_id:U().optional(),name:U().optional(),text:U().optional(),route:bt(dn),stroke_width:rn.default("0.1mm"),color:U().optional()}).describe("Defines a polyline documentation note on the PCB"),Mlt=et({type:bA("pcb_note_line"),pcb_note_line_id:Xe("pcb_note_line"),pcb_component_id:U().optional(),pcb_group_id:U().optional(),subcircuit_id:U().optional(),name:U().optional(),text:U().optional(),x1:Ee,y1:Ee,x2:Ee,y2:Ee,stroke_width:Ee.default("0.1mm"),color:U().optional(),is_dashed:qA().optional()}).describe("Defines a straight documentation note line on the PCB"),Glt=et({type:bA("pcb_note_dimension"),pcb_note_dimension_id:Xe("pcb_note_dimension"),pcb_component_id:U().optional(),pcb_group_id:U().optional(),subcircuit_id:U().optional(),name:U().optional(),from:dn,to:dn,text:U().optional(),text_ccw_rotation:OA().optional(),offset_distance:rn.optional(),offset_direction:et({x:OA(),y:OA()}).optional(),font:bA("tscircuit2024").default("tscircuit2024"),font_size:rn.default("1mm"),color:U().optional(),arrow_size:rn.default("1mm")}).describe("Defines a measurement annotation within PCB documentation notes"),Rlt=UI.extend({type:bA("pcb_footprint_overlap_error"),pcb_error_id:Xe("pcb_error"),error_type:bA("pcb_footprint_overlap_error").default("pcb_footprint_overlap_error"),pcb_smtpad_ids:bt(U()).optional(),pcb_plated_hole_ids:bt(U()).optional(),pcb_hole_ids:bt(U()).optional(),pcb_keepout_ids:bt(U()).optional()}).describe("Error emitted when a pcb footprint overlaps with another element"),Nlt=et({type:bA("pcb_keepout"),shape:bA("rect"),pcb_group_id:U().optional(),subcircuit_id:U().optional(),center:dn,width:Ee,height:Ee,pcb_keepout_id:U(),layers:bt(U()),description:U().optional()}).or(et({type:bA("pcb_keepout"),shape:bA("circle"),pcb_group_id:U().optional(),subcircuit_id:U().optional(),center:dn,radius:Ee,pcb_keepout_id:U(),layers:bt(U()),description:U().optional()})),Ij=et({type:bA("pcb_cutout"),pcb_cutout_id:Xe("pcb_cutout"),pcb_group_id:U().optional(),subcircuit_id:U().optional(),pcb_board_id:U().optional(),pcb_panel_id:U().optional()}),Llt=Ij.extend({shape:bA("rect"),center:dn,width:rn,height:rn,rotation:$C.optional(),corner_radius:rn.optional()}),Ult=Ij.extend({shape:bA("circle"),center:dn,radius:rn}),Hlt=Ij.extend({shape:bA("polygon"),points:bt(dn)}),Ylt=Ij.extend({shape:bA("path"),route:bt(dn),slot_width:rn,slot_length:rn.optional(),space_between_slots:rn.optional(),slot_corner_radius:rn.optional()}),Jlt=uf("shape",[Llt,Ult,Hlt,Ylt]).describe("Defines a cutout on the PCB, removing board material."),Tlt=UI.extend({type:bA("pcb_missing_footprint_error"),pcb_missing_footprint_error_id:Xe("pcb_missing_footprint_error"),pcb_group_id:U().optional(),subcircuit_id:U().optional(),error_type:bA("pcb_missing_footprint_error").default("pcb_missing_footprint_error"),source_component_id:U()}).describe("Defines a missing footprint error on the PCB"),Plt=UI.extend({type:bA("external_footprint_load_error"),external_footprint_load_error_id:Xe("external_footprint_load_error"),pcb_component_id:U(),source_component_id:U(),pcb_group_id:U().optional(),subcircuit_id:U().optional(),footprinter_string:U().optional(),error_type:bA("external_footprint_load_error").default("external_footprint_load_error")}).describe("Defines an error when an external footprint fails to load"),Klt=UI.extend({type:bA("circuit_json_footprint_load_error"),circuit_json_footprint_load_error_id:Xe("circuit_json_footprint_load_error"),pcb_component_id:U(),source_component_id:U(),pcb_group_id:U().optional(),subcircuit_id:U().optional(),error_type:bA("circuit_json_footprint_load_error").default("circuit_json_footprint_load_error"),circuit_json:bt(Xc()).optional()}).describe("Defines an error when a circuit JSON footprint fails to load"),qlt=et({type:bA("pcb_group"),pcb_group_id:Xe("pcb_group"),source_group_id:U(),is_subcircuit:qA().optional(),subcircuit_id:U().optional(),width:rn.optional(),height:rn.optional(),center:dn,display_offset_x:U().optional().describe("How to display the x offset for this group, usually corresponding with how the user specified it"),display_offset_y:U().optional().describe("How to display the y offset for this group, usually corresponding with how the user specified it"),outline:bt(dn).optional(),anchor_position:dn.optional(),anchor_alignment:_k.default("center"),position_mode:te(["packed","relative_to_group_anchor","none"]).optional(),positioned_relative_to_pcb_group_id:U().optional(),positioned_relative_to_pcb_board_id:U().optional(),pcb_component_ids:bt(U()),child_layout_mode:te(["packed","none"]).optional(),name:U().optional(),description:U().optional(),layout_mode:U().optional(),autorouter_configuration:et({trace_clearance:rn}).optional(),autorouter_used_string:U().optional()}).describe("Defines a group of components on the PCB"),Olt=UI.extend({type:bA("pcb_autorouting_error"),pcb_error_id:Xe("pcb_autorouting_error"),error_type:bA("pcb_autorouting_error").default("pcb_autorouting_error"),subcircuit_id:U().optional()}).describe("The autorouting has failed to route a portion of the board"),Wlt=et({type:bA("pcb_manual_edit_conflict_warning"),pcb_manual_edit_conflict_warning_id:Xe("pcb_manual_edit_conflict_warning"),warning_type:bA("pcb_manual_edit_conflict_warning").default("pcb_manual_edit_conflict_warning"),message:U(),pcb_component_id:U(),pcb_group_id:U().optional(),subcircuit_id:U().optional(),source_component_id:U()}).describe("Warning emitted when a component has both manual placement and explicit pcbX/pcbY coordinates"),Zlt=et({type:bA("pcb_breakout_point"),pcb_breakout_point_id:Xe("pcb_breakout_point"),pcb_group_id:U(),subcircuit_id:U().optional(),source_trace_id:U().optional(),source_port_id:U().optional(),source_net_id:U().optional(),x:Ee,y:Ee}).describe("Defines a routing target within a pcb_group for a source_trace or source_net"),Vlt=et({type:bA("pcb_ground_plane"),pcb_ground_plane_id:Xe("pcb_ground_plane"),source_pcb_ground_plane_id:U(),source_net_id:U(),pcb_group_id:U().optional(),subcircuit_id:U().optional()}).describe("Defines a ground plane on the PCB"),jlt=et({type:bA("pcb_ground_plane_region"),pcb_ground_plane_region_id:Xe("pcb_ground_plane_region"),pcb_ground_plane_id:U(),pcb_group_id:U().optional(),subcircuit_id:U().optional(),layer:Hr,points:bt(dn)}).describe("Defines a polygon region of a ground plane"),zlt=et({type:bA("pcb_thermal_spoke"),pcb_thermal_spoke_id:Xe("pcb_thermal_spoke"),pcb_ground_plane_id:U(),shape:U(),spoke_count:OA(),spoke_thickness:Ee,spoke_inner_diameter:Ee,spoke_outer_diameter:Ee,pcb_plated_hole_id:U().optional(),subcircuit_id:U().optional()}).describe("Pattern for connecting a ground plane to a plated hole"),w0A=et({type:bA("pcb_copper_pour"),pcb_copper_pour_id:Xe("pcb_copper_pour"),pcb_group_id:U().optional(),subcircuit_id:U().optional(),layer:Hr,source_net_id:U().optional(),covered_with_solder_mask:qA().optional().default(!0)}),Xlt=w0A.extend({shape:bA("rect"),center:dn,width:rn,height:rn,rotation:$C.optional()}),$lt=w0A.extend({shape:bA("brep"),brep_shape:YIt}),ABt=w0A.extend({shape:bA("polygon"),points:bt(dn)}),tBt=uf("shape",[Xlt,$lt,ABt]).describe("Defines a copper pour on the PCB."),eBt=UI.extend({type:bA("pcb_component_outside_board_error"),pcb_component_outside_board_error_id:Xe("pcb_component_outside_board_error"),error_type:bA("pcb_component_outside_board_error").default("pcb_component_outside_board_error"),pcb_component_id:U(),pcb_board_id:U(),component_center:dn,component_bounds:et({min_x:OA(),max_x:OA(),min_y:OA(),max_y:OA()}),subcircuit_id:U().optional(),source_component_id:U().optional()}).describe("Error emitted when a PCB component is placed outside the board boundaries"),iBt=UI.extend({type:bA("pcb_component_not_on_board_edge_error"),pcb_component_not_on_board_edge_error_id:Xe("pcb_component_not_on_board_edge_error"),error_type:bA("pcb_component_not_on_board_edge_error").default("pcb_component_not_on_board_edge_error"),pcb_component_id:U(),pcb_board_id:U(),component_center:dn,pad_to_nearest_board_edge_distance:OA(),source_component_id:U().optional(),subcircuit_id:U().optional()}).describe("Error emitted when a component that must be placed on the board edge is centered away from the edge"),nBt=UI.extend({type:bA("pcb_component_invalid_layer_error"),pcb_component_invalid_layer_error_id:Xe("pcb_component_invalid_layer_error"),error_type:bA("pcb_component_invalid_layer_error").default("pcb_component_invalid_layer_error"),pcb_component_id:U().optional(),source_component_id:U(),layer:Hr,subcircuit_id:U().optional()}).describe("Error emitted when a component is placed on an invalid layer (components can only be on 'top' or 'bottom' layers)"),oBt=UI.extend({type:bA("pcb_via_clearance_error"),pcb_error_id:Xe("pcb_error"),error_type:bA("pcb_via_clearance_error").default("pcb_via_clearance_error"),pcb_via_ids:bt(U()).min(2),minimum_clearance:Ee.optional(),actual_clearance:Ee.optional(),pcb_center:et({x:OA().optional(),y:OA().optional()}).optional(),subcircuit_id:U().optional()}).describe("Error emitted when vias are closer than the allowed clearance"),sBt=et({type:bA("pcb_courtyard_rect"),pcb_courtyard_rect_id:Xe("pcb_courtyard_rect"),pcb_component_id:U(),pcb_group_id:U().optional(),subcircuit_id:U().optional(),center:dn,width:rn,height:rn,layer:dm,color:U().optional()}).describe("Defines a courtyard rectangle on the PCB"),rBt=et({type:bA("pcb_courtyard_outline"),pcb_courtyard_outline_id:Xe("pcb_courtyard_outline"),pcb_component_id:U(),pcb_group_id:U().optional(),subcircuit_id:U().optional(),layer:dm,outline:bt(dn).min(2)}).describe("Defines a courtyard outline on the PCB"),aBt=et({type:bA("pcb_courtyard_polygon"),pcb_courtyard_polygon_id:Xe("pcb_courtyard_polygon"),pcb_component_id:U(),pcb_group_id:U().optional(),subcircuit_id:U().optional(),layer:dm,points:bt(dn).min(3),color:U().optional()}).describe("Defines a courtyard polygon on the PCB"),gBt=et({type:bA("pcb_courtyard_circle"),pcb_courtyard_circle_id:Xe("pcb_courtyard_circle"),pcb_component_id:U(),pcb_group_id:U().optional(),subcircuit_id:U().optional(),center:dn,radius:rn,layer:dm,color:U().optional()}).describe("Defines a courtyard circle on the PCB"),cBt=et({type:bA("cad_component"),cad_component_id:U(),pcb_component_id:U(),source_component_id:U(),position:xk,rotation:xk.optional(),size:xk.optional(),layer:Hr.optional(),subcircuit_id:U().optional(),footprinter_string:U().optional(),model_obj_url:U().optional(),model_stl_url:U().optional(),model_3mf_url:U().optional(),model_gltf_url:U().optional(),model_glb_url:U().optional(),model_step_url:U().optional(),model_wrl_url:U().optional(),model_asset:kct.optional(),model_unit_to_mm_scale_factor:OA().optional(),model_jscad:Xc().optional(),show_as_translucent_model:qA().optional(),anchor_alignment:te(["center","xy_center_z_board"]).optional().default("center")}).describe("Defines a component on the PCB"),D0A=te(["sinewave","square","triangle","sawtooth"]),N9e=Re([U(),OA()]).transform(e=>typeof e=="string"?e.endsWith("%")?parseFloat(e.slice(0,-1))/100:parseFloat(e):e).pipe(OA().min(0,"Duty cycle must be non-negative").max(1,"Duty cycle cannot be greater than 100%")),IBt=et({type:bA("simulation_voltage_source"),simulation_voltage_source_id:Xe("simulation_voltage_source"),is_dc_source:bA(!0).optional().default(!0),positive_source_port_id:U().optional(),negative_source_port_id:U().optional(),positive_source_net_id:U().optional(),negative_source_net_id:U().optional(),voltage:Wb}).describe("Defines a DC voltage source for simulation"),lBt=et({type:bA("simulation_voltage_source"),simulation_voltage_source_id:Xe("simulation_voltage_source"),is_dc_source:bA(!1),terminal1_source_port_id:U().optional(),terminal2_source_port_id:U().optional(),terminal1_source_net_id:U().optional(),terminal2_source_net_id:U().optional(),voltage:Wb.optional(),frequency:dM.optional(),peak_to_peak_voltage:Wb.optional(),wave_shape:D0A.optional(),phase:$C.optional(),duty_cycle:N9e.optional()}).describe("Defines an AC voltage source for simulation"),BBt=Re([IBt,lBt]).describe("Defines a voltage source for simulation"),L9e=Re([U(),OA()]).transform(e=>typeof e=="string"?e.endsWith("%")?parseFloat(e.slice(0,-1))/100:parseFloat(e):e).pipe(OA().min(0,"Duty cycle must be non-negative").max(1,"Duty cycle cannot be greater than 100%")),CBt=et({type:bA("simulation_current_source"),simulation_current_source_id:Xe("simulation_current_source"),is_dc_source:bA(!0).optional().default(!0),positive_source_port_id:U().optional(),negative_source_port_id:U().optional(),positive_source_net_id:U().optional(),negative_source_net_id:U().optional(),current:$2}).describe("Defines a DC current source for simulation"),QBt=et({type:bA("simulation_current_source"),simulation_current_source_id:Xe("simulation_current_source"),is_dc_source:bA(!1),terminal1_source_port_id:U().optional(),terminal2_source_port_id:U().optional(),terminal1_source_net_id:U().optional(),terminal2_source_net_id:U().optional(),current:$2.optional(),frequency:dM.optional(),peak_to_peak_current:$2.optional(),wave_shape:D0A.optional(),phase:$C.optional(),duty_cycle:L9e.optional()}).describe("Defines an AC current source for simulation"),hBt=Re([CBt,QBt]).describe("Defines a current source for simulation"),EBt=Re([bA("spice_dc_sweep"),bA("spice_dc_operating_point"),bA("spice_transient_analysis"),bA("spice_ac_analysis")]),uBt=et({type:bA("simulation_experiment"),simulation_experiment_id:Xe("simulation_experiment"),name:U(),experiment_type:EBt,time_per_step:aT.optional(),start_time_ms:pM.optional(),end_time_ms:pM.optional()}).describe("Defines a simulation experiment configuration"),dBt=et({type:bA("simulation_transient_voltage_graph"),simulation_transient_voltage_graph_id:Xe("simulation_transient_voltage_graph"),simulation_experiment_id:U(),timestamps_ms:bt(OA()).optional(),voltage_levels:bt(OA()),source_component_id:U().optional(),subcircuit_connectivity_map_key:U().optional(),time_per_step:aT,start_time_ms:pM,end_time_ms:pM,name:U().optional(),color:U().optional()}).describe("Stores voltage measurements over time for a simulation"),pBt=et({type:bA("simulation_switch"),simulation_switch_id:Xe("simulation_switch"),source_component_id:U().optional(),closes_at:pM.optional(),opens_at:pM.optional(),starts_closed:qA().optional(),switching_frequency:dM.optional()}).describe("Defines a switch for simulation timing control"),fBt=et({type:bA("simulation_voltage_probe"),simulation_voltage_probe_id:Xe("simulation_voltage_probe"),source_component_id:U().optional(),name:U().optional(),signal_input_source_port_id:U().optional(),signal_input_source_net_id:U().optional(),reference_input_source_port_id:U().optional(),reference_input_source_net_id:U().optional(),subcircuit_id:U().optional(),color:U().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((e,A)=>{if(e.reference_input_source_port_id||e.reference_input_source_net_id){const i=!!e.signal_input_source_port_id||!!e.reference_input_source_port_id,n=!!e.signal_input_source_net_id||!!e.reference_input_source_net_id;i&&n?A.addIssue({code:je.custom,message:"Cannot mix port and net connections in a differential probe."}):i?(!e.signal_input_source_port_id||!e.reference_input_source_port_id)&&A.addIssue({code:je.custom,message:"Differential port probe requires both signal_input_source_port_id and reference_input_source_port_id."}):n&&(!e.signal_input_source_net_id||!e.reference_input_source_net_id)&&A.addIssue({code:je.custom,message:"Differential net probe requires both signal_input_source_net_id and reference_input_source_net_id."})}else!!e.signal_input_source_port_id==!!e.signal_input_source_net_id&&A.addIssue({code:je.custom,message:"A voltage probe must have exactly one of signal_input_source_port_id or signal_input_source_net_id."})}),yBt=UI.extend({type:bA("simulation_unknown_experiment_error"),simulation_unknown_experiment_error_id:Xe("simulation_unknown_experiment_error"),error_type:bA("simulation_unknown_experiment_error").default("simulation_unknown_experiment_error"),simulation_experiment_id:U().optional(),subcircuit_id:U().optional()}).describe("An unknown error occurred during the simulation experiment."),mBt=et({type:bA("simulation_op_amp"),simulation_op_amp_id:Xe("simulation_op_amp"),source_component_id:U().optional(),inverting_input_source_port_id:U(),non_inverting_input_source_port_id:U(),output_source_port_id:U(),positive_supply_source_port_id:U(),negative_supply_source_port_id:U()}).describe("Defines a simple ideal operational amplifier for simulation"),wBt=Re([eIt,AIt,tIt,$ct,nIt,iIt,n0A,t0A,gj,i0A,e0A,o0A,s0A,r0A,c0A,I0A,l0A,E0A,B0A,C0A,Q0A,h0A,g0A,a0A,sIt,aIt,oIt,u0A,d0A,p0A,gIt,cIt,f0A,PIt,jIt,Tlt,Plt,Klt,Wlt,zIt,Nlt,XIt,Ilt,elt,slt,llt,Alt,tlt,Blt,Clt,qlt,Elt,ult,dlt,plt,Dlt,flt,ylt,mlt,wlt,rlt,alt,Qlt,hlt,glt,clt,oBt,blt,Slt,xlt,_lt,klt,vlt,Flt,Mlt,Glt,Olt,Rlt,Zlt,Jlt,Vlt,jlt,zlt,tBt,eBt,iBt,nBt,sBt,rBt,aBt,gBt,IIt,wIt,dIt,pIt,fIt,yIt,EIt,uIt,DIt,mIt,lIt,bIt,xIt,SIt,FIt,MIt,GIt,RIt,UIt,NIt,LIt,cBt,BBt,hBt,uBt,dBt,pBt,fBt,yBt,mBt]),S0A=wBt;const DBt=Object.freeze(Object.defineProperty({__proto__:null,all_layers:rIt,any_circuit_element:wBt,any_soup_element:S0A,any_source_component:$ct,asset:kct,base_circuit_json_error:UI,battery_capacity:_ct,brep_shape:YIt,cad_component:cBt,capacitance:XfA,circuit_json_footprint_load_error:Klt,current:$2,distance:Ee,duration_ms:aT,experiment_type:EBt,external_footprint_load_error:Plt,frequency:dM,getZodPrefixedIdWithDefault:Xe,inductance:bct,kicadAt:aj,kicadEffects:vct,kicadFont:A0A,kicadFootprintAttributes:Mct,kicadFootprintMetadata:Nct,kicadFootprintModel:Rct,kicadFootprintPad:Gct,kicadFootprintProperties:Fct,kicadProperty:gT,kicadSymbolEffects:Hct,kicadSymbolMetadata:Jct,kicadSymbolPinNames:Uct,kicadSymbolPinNumbers:Lct,kicadSymbolProperties:Yct,kicadSymbolProperty:kk,layer_ref:Hr,layer_string:y0A,length:rn,ms:pM,ninePointAnchor:_k,pcbRenderLayer:g9e,pcb_autorouting_error:Olt,pcb_board:Blt,pcb_breakout_point:Zlt,pcb_component:PIt,pcb_component_invalid_layer_error:nBt,pcb_component_not_on_board_edge_error:iBt,pcb_component_outside_board_error:eBt,pcb_copper_pour:tBt,pcb_copper_pour_brep:$lt,pcb_copper_pour_polygon:ABt,pcb_copper_pour_rect:Xlt,pcb_copper_text:flt,pcb_courtyard_circle:gBt,pcb_courtyard_outline:rBt,pcb_courtyard_polygon:aBt,pcb_courtyard_rect:sBt,pcb_cutout:Jlt,pcb_cutout_circle:Ult,pcb_cutout_path:Ylt,pcb_cutout_polygon:Hlt,pcb_cutout_rect:Llt,pcb_fabrication_note_dimension:_lt,pcb_fabrication_note_path:blt,pcb_fabrication_note_rect:xlt,pcb_fabrication_note_text:Slt,pcb_footprint_overlap_error:Rlt,pcb_ground_plane:Vlt,pcb_ground_plane_region:jlt,pcb_group:qlt,pcb_hole:jIt,pcb_hole_circle_or_square_shape:h9e,pcb_hole_circle_shape:C9e,pcb_hole_oval_shape:E9e,pcb_hole_pill_shape:u9e,pcb_hole_rect_shape:Q9e,pcb_hole_rotated_pill_shape:d9e,pcb_keepout:Nlt,pcb_manual_edit_conflict_warning:Wlt,pcb_missing_footprint_error:Tlt,pcb_net:Ilt,pcb_note_dimension:Glt,pcb_note_line:Mlt,pcb_note_path:Flt,pcb_note_rect:vlt,pcb_note_text:klt,pcb_panel:Clt,pcb_panelization_placement_error:hlt,pcb_placement_error:Qlt,pcb_plated_hole:zIt,pcb_port:XIt,pcb_port_not_connected_error:clt,pcb_port_not_matched_error:glt,pcb_route_hint:JIt,pcb_route_hints:B9e,pcb_silkscreen_circle:mlt,pcb_silkscreen_line:ult,pcb_silkscreen_oval:wlt,pcb_silkscreen_path:dlt,pcb_silkscreen_pill:Dlt,pcb_silkscreen_rect:ylt,pcb_silkscreen_text:plt,pcb_smtpad:Alt,pcb_smtpad_pill:$It,pcb_solder_paste:tlt,pcb_text:elt,pcb_thermal_spoke:zlt,pcb_trace:slt,pcb_trace_error:rlt,pcb_trace_hint:Elt,pcb_trace_missing_error:alt,pcb_trace_route_point:olt,pcb_trace_route_point_via:nlt,pcb_trace_route_point_wire:ilt,pcb_via:llt,pcb_via_clearance_error:oBt,point:dn,point3:xk,point_with_bulge:HIt,port_arrangement:hIt,position:s9e,position3:r9e,resistance:rj,ring:m0A,rotation:$C,route_hint_point:TIt,schematic_arc:yIt,schematic_box:IIt,schematic_circle:fIt,schematic_component:EIt,schematic_component_port_arrangement_by_sides:QIt,schematic_component_port_arrangement_by_size:CIt,schematic_debug_line:kIt,schematic_debug_object:FIt,schematic_debug_object_base:cj,schematic_debug_point:vIt,schematic_debug_rect:_It,schematic_error:bIt,schematic_group:RIt,schematic_layout_error:xIt,schematic_line:dIt,schematic_manual_edit_conflict_warning:GIt,schematic_net_label:SIt,schematic_path:lIt,schematic_pin_styles:BIt,schematic_port:DIt,schematic_rect:pIt,schematic_sheet:UIt,schematic_symbol:uIt,schematic_table:NIt,schematic_table_cell:LIt,schematic_text:wIt,schematic_trace:mIt,schematic_voltage_probe:MIt,simulation_ac_current_source:QBt,simulation_ac_voltage_source:lBt,simulation_current_source:hBt,simulation_dc_current_source:CBt,simulation_dc_voltage_source:IBt,simulation_experiment:uBt,simulation_op_amp:mBt,simulation_switch:pBt,simulation_transient_voltage_graph:dBt,simulation_unknown_experiment_error:yBt,simulation_voltage_probe:fBt,simulation_voltage_source:BBt,size:$fA,source_board:oIt,source_component_base:oI,source_component_internal_connection:tIt,source_failed_to_create_component_error:Zct,source_group:iIt,source_i2c_misconfigured_error:f0A,source_interconnect:zct,source_manually_placed_via:aIt,source_missing_property_error:Wct,source_net:nIt,source_pcb_ground_plane:sIt,source_pin_missing_trace_warning:p0A,source_pin_must_be_connected_error:gIt,source_port:AIt,source_project_metadata:u0A,source_property_ignored_warning:Vct,source_simple_battery:s0A,source_simple_capacitor:t0A,source_simple_chip:n0A,source_simple_crystal:Oct,source_simple_current_source:qct,source_simple_diode:gj,source_simple_fiducial:Pct,source_simple_ground:Kct,source_simple_inductor:r0A,source_simple_led:i0A,source_simple_mosfet:Q0A,source_simple_op_amp:h0A,source_simple_pin_header:c0A,source_simple_pinout:I0A,source_simple_potentiometer:g0A,source_simple_power_source:o0A,source_simple_push_button:a0A,source_simple_resistor:e0A,source_simple_resonator:l0A,source_simple_switch:E0A,source_simple_test_point:C0A,source_simple_transistor:B0A,source_simple_voltage_probe:jct,source_simple_voltage_source:Xct,source_trace:eIt,source_trace_not_connected_error:d0A,supplier_name:Tct,time:o9e,timestamp:xct,unknown_error_finding_part:cIt,visible_layer:dm,voltage:Wb,wave_shape:D0A},Symbol.toStringTag,{value:"Module"})),U9e={},SBt=e=>{let A;const t=new Set,i=(c,I)=>{const l=typeof c=="function"?c(A):c;if(!Object.is(l,A)){const B=A;A=I??(typeof l!="object"||l===null)?l:Object.assign({},A,l),t.forEach(C=>C(A,B))}},n=()=>A,a={setState:i,getState:n,getInitialState:()=>g,subscribe:c=>(t.add(c),()=>t.delete(c)),destroy:()=>{(U9e?"production":void 0)!=="production"&&console.warn("[DEPRECATED] The `destroy` method will be unsupported in a future version. Instead use unsubscribe function returned by subscribe. Everything will be garbage-collected if store is garbage-collected."),t.clear()}},g=A=e(i,n,a);return a},bBt=e=>e?SBt(e):SBt;var lj={exports:{}},b0A={},Bj={exports:{}},x0A={};var xBt;function H9e(){if(xBt)return x0A;xBt=1;var e=b0();function A(I,l){return I===l&&(I!==0||1/I===1/l)||I!==I&&l!==l}var t=typeof Object.is=="function"?Object.is:A,i=e.useState,n=e.useEffect,o=e.useLayoutEffect,s=e.useDebugValue;function r(I,l){var B=l(),C=i({inst:{value:B,getSnapshot:l}}),Q=C[0].inst,h=C[1];return o(function(){Q.value=B,Q.getSnapshot=l,a(Q)&&h({inst:Q})},[I,B,l]),n(function(){return a(Q)&&h({inst:Q}),I(function(){a(Q)&&h({inst:Q})})},[I]),s(B),B}function a(I){var l=I.getSnapshot;I=I.value;try{var B=l();return!t(I,B)}catch{return!0}}function g(I,l){return l()}var c=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?g:r;return x0A.useSyncExternalStore=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:c,x0A}var _0A={},_Bt;function Y9e(){if(_Bt)return _0A;_Bt=1;var e={env:{}};return e.env.NODE_ENV!=="production"&&(function(){function A(C,Q){return C===Q&&(C!==0||1/C===1/Q)||C!==C&&Q!==Q}function t(C,Q){I||o.startTransition===void 0||(I=!0,console.error("You are using an outdated, pre-release alpha of React 18 that does not support useSyncExternalStore. The use-sync-external-store shim will not work correctly. Upgrade to a newer pre-release."));var h=Q();if(!l){var E=Q();s(h,E)||(console.error("The result of getSnapshot should be cached to avoid an infinite loop"),l=!0)}E=r({inst:{value:h,getSnapshot:Q}});var u=E[0].inst,d=E[1];return g(function(){u.value=h,u.getSnapshot=Q,i(u)&&d({inst:u})},[C,h,Q]),a(function(){return i(u)&&d({inst:u}),C(function(){i(u)&&d({inst:u})})},[C]),c(h),h}function i(C){var Q=C.getSnapshot;C=C.value;try{var h=Q();return!s(C,h)}catch{return!0}}function n(C,Q){return Q()}typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());var o=b0(),s=typeof Object.is=="function"?Object.is:A,r=o.useState,a=o.useEffect,g=o.useLayoutEffect,c=o.useDebugValue,I=!1,l=!1,B=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?n:t;_0A.useSyncExternalStore=o.useSyncExternalStore!==void 0?o.useSyncExternalStore:B,typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error())})(),_0A}var kBt;function vBt(){if(kBt)return Bj.exports;kBt=1;var e={env:{}};return e.env.NODE_ENV==="production"?Bj.exports=H9e():Bj.exports=Y9e(),Bj.exports}var FBt;function J9e(){if(FBt)return b0A;FBt=1;var e=b0(),A=vBt();function t(g,c){return g===c&&(g!==0||1/g===1/c)||g!==g&&c!==c}var i=typeof Object.is=="function"?Object.is:t,n=A.useSyncExternalStore,o=e.useRef,s=e.useEffect,r=e.useMemo,a=e.useDebugValue;return b0A.useSyncExternalStoreWithSelector=function(g,c,I,l,B){var C=o(null);if(C.current===null){var Q={hasValue:!1,value:null};C.current=Q}else Q=C.current;C=r(function(){function E(w){if(!u){if(u=!0,d=w,w=l(w),B!==void 0&&Q.hasValue){var D=Q.value;if(B(D,w))return f=D}return f=w}if(D=f,i(d,w))return D;var S=l(w);return B!==void 0&&B(D,S)?(d=w,D):(d=w,f=S)}var u=!1,d,f,m=I===void 0?null:I;return[function(){return E(c())},m===null?void 0:function(){return E(m())}]},[c,I,l,B]);var h=n(g,C[0],C[1]);return s(function(){Q.hasValue=!0,Q.value=h},[h]),a(h),h},b0A}var k0A={},MBt;function T9e(){if(MBt)return k0A;MBt=1;var e={env:{}};return e.env.NODE_ENV!=="production"&&(function(){function A(c,I){return c===I&&(c!==0||1/c===1/I)||c!==c&&I!==I}typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());var t=b0(),i=vBt(),n=typeof Object.is=="function"?Object.is:A,o=i.useSyncExternalStore,s=t.useRef,r=t.useEffect,a=t.useMemo,g=t.useDebugValue;k0A.useSyncExternalStoreWithSelector=function(c,I,l,B,C){var Q=s(null);if(Q.current===null){var h={hasValue:!1,value:null};Q.current=h}else h=Q.current;Q=a(function(){function u(D){if(!d){if(d=!0,f=D,D=B(D),C!==void 0&&h.hasValue){var S=h.value;if(C(S,D))return m=S}return m=D}if(S=m,n(f,D))return S;var _=B(D);return C!==void 0&&C(S,_)?(f=D,S):(f=D,m=_)}var d=!1,f,m,w=l===void 0?null:l;return[function(){return u(I())},w===null?void 0:function(){return u(w())}]},[I,l,B,C]);var E=o(c,Q[0],Q[1]);return r(function(){h.hasValue=!0,h.value=E},[E]),g(E),E},typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error())})(),k0A}var GBt;function P9e(){if(GBt)return lj.exports;GBt=1;var e={env:{}};return e.env.NODE_ENV==="production"?lj.exports=J9e():lj.exports=T9e(),lj.exports}var K9e=P9e();const q9e=S0(K9e),RBt={},{useDebugValue:O9e}=Cn,{useSyncExternalStoreWithSelector:W9e}=q9e;let NBt=!1;const Z9e=e=>e;function LBt(e,A=Z9e,t){(RBt?"production":void 0)!=="production"&&t&&!NBt&&(console.warn("[DEPRECATED] Use `createWithEqualityFn` instead of `create` or use `useStoreWithEqualityFn` instead of `useStore`. They can be imported from 'zustand/traditional'. https://github.com/pmndrs/zustand/discussions/1937"),NBt=!0);const i=W9e(e.subscribe,e.getState,e.getServerState||e.getInitialState,A,t);return O9e(i),i}const V9e=e=>{(RBt?"production":void 0)!=="production"&&typeof e!="function"&&console.warn("[DEPRECATED] Passing a vanilla store will be unsupported in a future version. Instead use `import { useStore } from 'zustand'`.");const A=typeof e=="function"?bBt(e):e,t=(i,n)=>LBt(A,i,n);return Object.assign(t,A),t},UBt=e=>V9e,cT=e=>typeof e=="number"&&!isNaN(e),fM=e=>typeof e=="string",j0=e=>typeof e=="function",Cj=e=>fM(e)||j0(e)?e:null,v0A=e=>AA.isValidElement(e)||fM(e)||j0(e)||cT(e);function j9e(e,A,t){t===void 0&&(t=300);const{scrollHeight:i,style:n}=e;requestAnimationFrame(()=>{n.minHeight="initial",n.height=i+"px",n.transition=`all ${t}ms`,requestAnimationFrame(()=>{n.height="0",n.padding="0",n.margin="0",setTimeout(A,t)})})}function Qj(e){let{enter:A,exit:t,appendPosition:i=!1,collapse:n=!0,collapseDuration:o=300}=e;return function(s){let{children:r,position:a,preventExitTransition:g,done:c,nodeRef:I,isIn:l,playToast:B}=s;const C=i?`${A}--${a}`:A,Q=i?`${t}--${a}`:t,h=AA.useRef(0);return AA.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)},[]),AA.useEffect(()=>{const E=I.current,u=()=>{E.removeEventListener("animationend",u),n?j9e(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 HBt(e,A){return e!=null?{content:e.content,containerId:e.props.containerId,id:e.props.toastId,theme:e.props.theme,type:e.props.type,data:e.props.data||{},isLoading:e.props.isLoading,icon:e.props.icon,status:A}:{}}const np=new Map;let IT=[];const F0A=new Set,z9e=e=>F0A.forEach(A=>A(e)),YBt=()=>np.size>0;function JBt(e,A){var t;if(A)return!((t=np.get(A))==null||!t.isToastActive(e));let i=!1;return np.forEach(n=>{n.isToastActive(e)&&(i=!0)}),i}function TBt(e,A){v0A(e)&&(YBt()||IT.push({content:e,options:A}),np.forEach(t=>{t.buildToast(e,A)}))}function PBt(e,A){np.forEach(t=>{A!=null&&A!=null&&A.containerId?A?.containerId===t.id&&t.toggle(e,A?.id):t.toggle(e,A?.id)})}function X9e(e){const{subscribe:A,getSnapshot:t,setProps:i}=AA.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:R,children:F}=S.props,H=R==null;S.staleId&&d.delete(S.staleId),d.set(_,S),h=[...h,S.props.toastId].filter(Y=>Y!==S.staleId),m(),l(HBt(S,H?"added":"updated")),H&&j0(b)&&b(AA.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||j0(b.toggle)&&b.toggle(S)})},removeToast:w,toasts:d,clearQueue:()=>{C-=Q.length,Q=[]},buildToast:(S,_)=>{if((oA=>{let{containerId:rA,toastId:BA,updateId:pA}=oA;const kA=rA?rA!==c:c!==1,MA=d.has(BA)&&pA==null;return kA||MA})(_))return;const{toastId:b,updateId:R,data:F,staleId:H,delay:Y}=_,J=()=>{w(b)},O=R==null;O&&C++;const W={...u,style:u.toastStyle,key:B++,...Object.fromEntries(Object.entries(_).filter(oA=>{let[rA,BA]=oA;return BA!=null})),toastId:b,updateId:R,data:F,closeToast:J,isIn:!1,className:Cj(_.className||u.toastClassName),bodyClassName:Cj(_.bodyClassName||u.bodyClassName),progressClassName:Cj(_.progressClassName||u.progressClassName),autoClose:!_.isLoading&&(z=_.autoClose,tA=u.autoClose,z===!1||cT(z)&&z>0?z:tA),deleteToast(){const oA=d.get(b),{onClose:rA,children:BA}=oA.props;j0(rA)&&rA(AA.isValidElement(BA)&&BA.props),l(HBt(oA,"removed")),d.delete(b),C--,C<0&&(C=0),Q.length>0?D(Q.shift()):m()}};var z,tA;W.closeButton=u.closeButton,_.closeButton===!1||v0A(_.closeButton)?W.closeButton=_.closeButton:_.closeButton===!0&&(W.closeButton=!v0A(u.closeButton)||u.closeButton);let aA=S;AA.isValidElement(S)&&!fM(S.type)?aA=AA.cloneElement(S,{closeToast:J,toastProps:W,data:F}):j0(S)&&(aA=S({closeToast:J,toastProps:W,data:F}));const eA={content:aA,props:W,staleId:H};u.limit&&u.limit>0&&C>u.limit&&O?Q.push(eA):cT(Y)?setTimeout(()=>{D(eA)},Y):D(eA)},setProps(S){u=S},setToggle:(S,_)=>{d.get(S).toggle=_},isToastActive:S=>h.some(_=>_===S),getSnapshot:()=>E}})(s,o,z9e);np.set(s,a);const g=a.observe(r);return IT.forEach(c=>TBt(c.content,c.options)),IT=[],()=>{g(),np.delete(s)}},setProps(r){var a;(a=np.get(s))==null||a.setProps(r)},getSnapshot(){var r;return(r=np.get(s))==null?void 0:r.getSnapshot()}}})(e)).current;i(e);const n=AA.useSyncExternalStore(A,t,t);return{getToastToRender:function(o){if(!n)return[];const s=new Map;return e.newestOnTop&&n.reverse(),n.forEach(r=>{const{position:a}=r.props;s.has(a)||s.set(a,[]),s.get(a).push(r)}),Array.from(s,r=>o(r[0],r[1]))},isToastActive:JBt,count:n?.length}}function $9e(e){const[A,t]=AA.useState(!1),[i,n]=AA.useState(!1),o=AA.useRef(null),s=AA.useRef({start:0,delta:0,removalDistance:0,canCloseOnClick:!0,canDrag:!1,didMove:!1}).current,{autoClose:r,pauseOnHover:a,closeToast:g,onClick:c,closeOnClick:I}=e;var l,B;function C(){t(!0)}function Q(){t(!1)}function h(d){const f=o.current;s.canDrag&&f&&(s.didMove=!0,A&&Q(),s.delta=e.draggableDirection==="x"?d.clientX-s.start:d.clientY-s.start,s.start!==d.clientX&&(s.canCloseOnClick=!1),f.style.transform=`translate3d(${e.draggableDirection==="x"?`${s.delta}px, var(--y)`:`0, calc(${s.delta}px + var(--y))`},0)`,f.style.opacity=""+(1-Math.abs(s.delta/s.removalDistance)))}function E(){document.removeEventListener("pointermove",h),document.removeEventListener("pointerup",E);const d=o.current;if(s.canDrag&&s.didMove&&d){if(s.canDrag=!1,Math.abs(s.delta)>s.removalDistance)return n(!0),e.closeToast(),void e.collapseAll();d.style.transition="transform 0.2s, opacity 0.2s",d.style.removeProperty("transform"),d.style.removeProperty("opacity")}}(B=np.get((l={id:e.toastId,containerId:e.containerId,fn:t}).containerId||1))==null||B.setToggle(l.id,l.fn),AA.useEffect(()=>{if(e.pauseOnFocusLoss)return document.hasFocus()||Q(),window.addEventListener("focus",C),window.addEventListener("blur",Q),()=>{window.removeEventListener("focus",C),window.removeEventListener("blur",Q)}},[e.pauseOnFocusLoss]);const u={onPointerDown:function(d){if(e.draggable===!0||e.draggable===d.pointerType){s.didMove=!1,document.addEventListener("pointermove",h),document.addEventListener("pointerup",E);const f=o.current;s.canCloseOnClick=!0,s.canDrag=!0,f.style.transition="none",e.draggableDirection==="x"?(s.start=d.clientX,s.removalDistance=f.offsetWidth*(e.draggablePercent/100)):(s.start=d.clientY,s.removalDistance=f.offsetHeight*(e.draggablePercent===80?1.5*e.draggablePercent:e.draggablePercent)/100)}},onPointerUp:function(d){const{top:f,bottom:m,left:w,right:D}=o.current.getBoundingClientRect();d.nativeEvent.type!=="touchend"&&e.pauseOnHover&&d.clientX>=w&&d.clientX<=D&&d.clientY>=f&&d.clientY<=m?Q():C()}};return r&&a&&(u.onMouseEnter=Q,e.stacked||(u.onMouseLeave=C)),I&&(u.onClick=d=>{c&&c(d),s.canCloseOnClick&&g()}),{playToast:C,pauseToast:Q,isRunning:A,preventExitTransition:i,toastRef:o,eventHandlers:u}}function Aje(e){let{delay:A,isRunning:t,closeToast:i,type:n="default",hide:o,className:s,style:r,controlledProgress:a,progress:g,rtl:c,isIn:I,theme:l}=e;const B=o||a&&g===0,C={...r,animationDuration:`${A}ms`,animationPlayState:t?"running":"paused"};a&&(C.transform=`scaleX(${g})`);const Q=Om("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=j0(s)?s({rtl:c,type:n,defaultClassName:Q}):Om(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 tje=1;const KBt=()=>""+tje++;function eje(e){return e&&(fM(e.toastId)||cT(e.toastId))?e.toastId:KBt()}function lT(e,A){return TBt(e,A),A.toastId}function hj(e,A){return{...A,type:A&&A.type||e,toastId:eje(A)}}function Ej(e){return(A,t)=>lT(A,hj(e,t))}function Ac(e,A){return lT(e,hj("default",A))}Ac.loading=(e,A)=>lT(e,hj("default",{isLoading:!0,autoClose:!1,closeOnClick:!1,closeButton:!1,draggable:!1,...A})),Ac.promise=function(e,A,t){let i,{pending:n,error:o,success:s}=A;n&&(i=fM(n)?Ac.loading(n,t):Ac.loading(n.render,{...t,...n}));const r={isLoading:null,autoClose:null,closeOnClick:null,closeButton:null,draggable:null},a=(c,I,l)=>{if(I==null)return void Ac.dismiss(i);const B={type:c,...r,...t,data:l},C=fM(I)?{render:I}:I;return i?Ac.update(i,{...B,...C}):Ac(C.render,{...B,...C}),l},g=j0(e)?e():e;return g.then(c=>a("success",s,c)).catch(c=>a("error",o,c)),g},Ac.success=Ej("success"),Ac.info=Ej("info"),Ac.error=Ej("error"),Ac.warning=Ej("warning"),Ac.warn=Ac.warning,Ac.dark=(e,A)=>lT(e,hj("default",{theme:"dark",...A})),Ac.dismiss=function(e){(function(A){var t;if(YBt()){if(A==null||fM(t=A)||cT(t))np.forEach(i=>{i.removeToast(A)});else if(A&&("containerId"in A||"id"in A)){const i=np.get(A.containerId);i?i.removeToast(A.id):np.forEach(n=>{n.removeToast(A.id)})}}else IT=IT.filter(i=>A!=null&&i.options.toastId!==A)})(e)},Ac.clearWaitingQueue=function(e){e===void 0&&(e={}),np.forEach(A=>{!A.props.limit||e.containerId&&A.id!==e.containerId||A.clearQueue()})},Ac.isActive=JBt,Ac.update=function(e,A){A===void 0&&(A={});const t=((i,n)=>{var o;let{containerId:s}=n;return(o=np.get(s||1))==null?void 0:o.toasts.get(i)})(e,A);if(t){const{props:i,content:n}=t,o={delay:100,...i,...A,toastId:A.toastId||e,updateId:KBt()};o.toastId!==e&&(o.staleId=e);const s=o.render||n;delete o.render,lT(s,o)}},Ac.done=e=>{Ac.update(e,{progress:1})},Ac.onChange=function(e){return F0A.add(e),()=>{F0A.delete(e)}},Ac.play=e=>PBt(!0,e),Ac.pause=e=>PBt(!1,e);const ije=typeof window<"u"?AA.useLayoutEffect:AA.useEffect,uj=e=>{let{theme:A,type:t,isLoading:i,...n}=e;return Cn.createElement("svg",{viewBox:"0 0 24 24",width:"100%",height:"100%",fill:A==="colored"?"currentColor":`var(--toastify-icon-color-${t})`,...n})},M0A={info:function(e){return Cn.createElement(uj,{...e},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(e){return Cn.createElement(uj,{...e},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(e){return Cn.createElement(uj,{...e},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(e){return Cn.createElement(uj,{...e},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"})}},nje=e=>{const{isRunning:A,preventExitTransition:t,toastRef:i,eventHandlers:n,playToast:o}=$9e(e),{closeButton:s,children:r,autoClose:a,onClick:g,type:c,hideProgressBar:I,closeToast:l,transition:B,position:C,className:Q,style:h,bodyClassName:E,bodyStyle:u,progressClassName:d,progressStyle:f,updateId:m,role:w,progress:D,rtl:S,toastId:_,deleteToast:b,isIn:R,isLoading:F,closeOnClick:H,theme:Y}=e,J=Om("Toastify__toast",`Toastify__toast-theme--${Y}`,`Toastify__toast--${c}`,{"Toastify__toast--rtl":S},{"Toastify__toast--close-on-click":H}),O=j0(Q)?Q({rtl:S,position:C,type:c,defaultClassName:J}):Om(J,Q),W=(function(eA){let{theme:oA,type:rA,isLoading:BA,icon:pA}=eA,kA=null;const MA={theme:oA,type:rA};return pA===!1||(j0(pA)?kA=pA({...MA,isLoading:BA}):AA.isValidElement(pA)?kA=AA.cloneElement(pA,MA):BA?kA=M0A.spinner():(TA=>TA in M0A)(rA)&&(kA=M0A[rA](MA))),kA})(e),z=!!D||!a,tA={closeToast:l,type:c,theme:Y};let aA=null;return s===!1||(aA=j0(s)?s(tA):AA.isValidElement(s)?AA.cloneElement(s,tA):(function(eA){let{closeToast:oA,theme:rA,ariaLabel:BA="close"}=eA;return Cn.createElement("button",{className:`Toastify__close-button Toastify__close-button--${rA}`,type:"button",onClick:pA=>{pA.stopPropagation(),oA(pA)},"aria-label":BA},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"})))})(tA)),Cn.createElement(B,{isIn:R,done:b,position:C,preventExitTransition:t,nodeRef:i,playToast:o},Cn.createElement("div",{id:_,onClick:g,"data-in":R,className:O,...n,style:h,ref:i},Cn.createElement("div",{...R&&{role:w},className:j0(E)?E({type:c}):Om("Toastify__toast-body",E),style:u},W!=null&&Cn.createElement("div",{className:Om("Toastify__toast-icon",{"Toastify--animate-icon Toastify__zoom-enter":!F})},W),Cn.createElement("div",null,r)),aA,Cn.createElement(Aje,{...m&&!z?{key:`pb-${m}`}:{},rtl:S,theme:Y,delay:a,isRunning:A,isIn:R,closeToast:l,hide:I,type:c,style:f,className:d,controlledProgress:z,progress:D||0})))},dj=function(e,A){return A===void 0&&(A=!1),{enter:`Toastify--animate Toastify__${e}-enter`,exit:`Toastify--animate Toastify__${e}-exit`,appendPosition:A}},oje=Qj(dj("bounce",!0));Qj(dj("slide",!0)),Qj(dj("zoom")),Qj(dj("flip"));const sje={position:"top-right",transition:oje,autoClose:5e3,closeButton:!0,pauseOnHover:!0,pauseOnFocusLoss:!0,draggable:"touch",draggablePercent:80,draggableDirection:"x",role:"alert",theme:"light"};function rje(e){let A={...sje,...e};const t=e.stacked,[i,n]=AA.useState(!0),o=AA.useRef(null),{getToastToRender:s,isToastActive:r,count:a}=X9e(A),{className:g,style:c,rtl:I,containerId:l}=A;function B(Q){const h=Om("Toastify__toast-container",`Toastify__toast-container--${Q}`,{"Toastify__toast-container--rtl":I});return j0(g)?g({position:Q,rtl:I,defaultClassName:h}):Om(h,Cj(g))}function C(){t&&(n(!0),Ac.play())}return ije(()=>{if(t){var Q;const h=o.current.querySelectorAll('[data-in="true"]'),E=12,u=(Q=A.position)==null?void 0:Q.includes("top");let d=0,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,t]),Cn.createElement("div",{ref:o,className:"Toastify",id:l,onMouseEnter:()=>{t&&(n(!1),Ac.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(nje,{...f,stacked:t,collapseAll:C,isIn:r(f.toastId,f.containerId),style:f.style,key:`toast-${f.key}`},d)}))}))}function aje(){var e=':root{--toastify-color-light:#fff;--toastify-color-dark:#121212;--toastify-color-info:#3498db;--toastify-color-success:#07bc0c;--toastify-color-warning:#f1c40f;--toastify-color-error:#e74c3c;--toastify-color-transparent:hsla(0,0%,100%,.7);--toastify-icon-color-info:var(--toastify-color-info);--toastify-icon-color-success:var(--toastify-color-success);--toastify-icon-color-warning:var(--toastify-color-warning);--toastify-icon-color-error:var(--toastify-color-error);--toastify-toast-width:320px;--toastify-toast-offset:16px;--toastify-toast-top:max(var(--toastify-toast-offset),env(safe-area-inset-top));--toastify-toast-right:max(var(--toastify-toast-offset),env(safe-area-inset-right));--toastify-toast-left:max(var(--toastify-toast-offset),env(safe-area-inset-left));--toastify-toast-bottom:max(var(--toastify-toast-offset),env(safe-area-inset-bottom));--toastify-toast-background:#fff;--toastify-toast-min-height:64px;--toastify-toast-max-height:800px;--toastify-toast-bd-radius:6px;--toastify-font-family:sans-serif;--toastify-z-index:9999;--toastify-text-color-light:#757575;--toastify-text-color-dark:#fff;--toastify-text-color-info:#fff;--toastify-text-color-success:#fff;--toastify-text-color-warning:#fff;--toastify-text-color-error:#fff;--toastify-spinner-color:#616161;--toastify-spinner-color-empty-area:#e0e0e0;--toastify-color-progress-light:linear-gradient(90deg,#4cd964,#5ac8fa,#007aff,#34aadc,#5856d6,#ff2d55);--toastify-color-progress-dark:#bb86fc;--toastify-color-progress-info:var(--toastify-color-info);--toastify-color-progress-success:var(--toastify-color-success);--toastify-color-progress-warning:var(--toastify-color-warning);--toastify-color-progress-error:var(--toastify-color-error);--toastify-color-progress-bgo:0.2}.Toastify__toast-container{z-index:var(--toastify-z-index);-webkit-transform:translateZ(var(--toastify-z-index));position:fixed;padding:4px;width:var(--toastify-toast-width);box-sizing:border-box;color:#fff}.Toastify__toast-container--top-left{top:var(--toastify-toast-top);left:var(--toastify-toast-left)}.Toastify__toast-container--top-center{top:var(--toastify-toast-top);left:50%;transform:translateX(-50%)}.Toastify__toast-container--top-right{top:var(--toastify-toast-top);right:var(--toastify-toast-right)}.Toastify__toast-container--bottom-left{bottom:var(--toastify-toast-bottom);left:var(--toastify-toast-left)}.Toastify__toast-container--bottom-center{bottom:var(--toastify-toast-bottom);left:50%;transform:translateX(-50%)}.Toastify__toast-container--bottom-right{bottom:var(--toastify-toast-bottom);right:var(--toastify-toast-right)}@media only screen and (max-width:480px){.Toastify__toast-container{width:100vw;padding:0;left:env(safe-area-inset-left);margin:0}.Toastify__toast-container--top-center,.Toastify__toast-container--top-left,.Toastify__toast-container--top-right{top:env(safe-area-inset-top);transform:translateX(0)}.Toastify__toast-container--bottom-center,.Toastify__toast-container--bottom-left,.Toastify__toast-container--bottom-right{bottom:env(safe-area-inset-bottom);transform:translateX(0)}.Toastify__toast-container--rtl{right:env(safe-area-inset-right);left:auto}}.Toastify__toast{--y:0;position:relative;-ms-touch-action:none;touch-action:none;min-height:var(--toastify-toast-min-height);box-sizing:border-box;margin-bottom:1rem;padding:8px;border-radius:var(--toastify-toast-bd-radius);box-shadow:0 4px 12px rgba(0,0,0,.1);display:-ms-flexbox;display:flex;-ms-flex-pack:justify;justify-content:space-between;max-height:var(--toastify-toast-max-height);font-family:var(--toastify-font-family);cursor:default;direction:ltr;z-index:0;overflow:hidden}.Toastify__toast--stacked{position:absolute;width:100%;transform:translate3d(0,var(--y),0) scale(var(--s));transition:transform .3s}.Toastify__toast--stacked[data-collapsed] .Toastify__close-button,.Toastify__toast--stacked[data-collapsed] .Toastify__toast-body{transition:opacity .1s}.Toastify__toast--stacked[data-collapsed=false]{overflow:visible}.Toastify__toast--stacked[data-collapsed=true]:not(:last-child)>*{opacity:0}.Toastify__toast--stacked:after{content:"";position:absolute;left:0;right:0;height:calc(var(--g) * 1px);bottom:100%}.Toastify__toast--stacked[data-pos=top]{top:0}.Toastify__toast--stacked[data-pos=bot]{bottom:0}.Toastify__toast--stacked[data-pos=bot].Toastify__toast--stacked:before{transform-origin:top}.Toastify__toast--stacked[data-pos=top].Toastify__toast--stacked:before{transform-origin:bottom}.Toastify__toast--stacked:before{content:"";position:absolute;left:0;right:0;bottom:0;height:100%;transform:scaleY(3);z-index:-1}.Toastify__toast--rtl{direction:rtl}.Toastify__toast--close-on-click{cursor:pointer}.Toastify__toast-body{margin:auto 0;-ms-flex:1 1 auto;flex:1 1 auto;padding:6px;display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center}.Toastify__toast-body>div:last-child{word-break:break-word;-ms-flex:1;flex:1}.Toastify__toast-icon{-webkit-margin-end:10px;margin-inline-end:10px;width:20px;-ms-flex-negative:0;flex-shrink:0;display:-ms-flexbox;display:flex}.Toastify--animate{animation-fill-mode:both;animation-duration:.5s}.Toastify--animate-icon{animation-fill-mode:both;animation-duration:.3s}@media only screen and (max-width:480px){.Toastify__toast{margin-bottom:0;border-radius:0}}.Toastify__toast-theme--dark{background:var(--toastify-color-dark);color:var(--toastify-text-color-dark)}.Toastify__toast-theme--colored.Toastify__toast--default,.Toastify__toast-theme--light{background:var(--toastify-color-light);color:var(--toastify-text-color-light)}.Toastify__toast-theme--colored.Toastify__toast--info{color:var(--toastify-text-color-info);background:var(--toastify-color-info)}.Toastify__toast-theme--colored.Toastify__toast--success{color:var(--toastify-text-color-success);background:var(--toastify-color-success)}.Toastify__toast-theme--colored.Toastify__toast--warning{color:var(--toastify-text-color-warning);background:var(--toastify-color-warning)}.Toastify__toast-theme--colored.Toastify__toast--error{color:var(--toastify-text-color-error);background:var(--toastify-color-error)}.Toastify__progress-bar-theme--light{background:var(--toastify-color-progress-light)}.Toastify__progress-bar-theme--dark{background:var(--toastify-color-progress-dark)}.Toastify__progress-bar--info{background:var(--toastify-color-progress-info)}.Toastify__progress-bar--success{background:var(--toastify-color-progress-success)}.Toastify__progress-bar--warning{background:var(--toastify-color-progress-warning)}.Toastify__progress-bar--error{background:var(--toastify-color-progress-error)}.Toastify__progress-bar-theme--colored.Toastify__progress-bar--error,.Toastify__progress-bar-theme--colored.Toastify__progress-bar--info,.Toastify__progress-bar-theme--colored.Toastify__progress-bar--success,.Toastify__progress-bar-theme--colored.Toastify__progress-bar--warning{background:var(--toastify-color-transparent)}.Toastify__close-button{color:#fff;background:transparent;outline:none;border:none;padding:0;cursor:pointer;opacity:.7;transition:.3s ease;-ms-flex-item-align:start;align-self:flex-start;z-index:1}.Toastify__close-button--light{color:#000;opacity:.3}.Toastify__close-button>svg{fill:currentColor;height:16px;width:14px}.Toastify__close-button:focus,.Toastify__close-button:hover{opacity:1}@keyframes Toastify__trackProgress{0%{transform:scaleX(1)}to{transform:scaleX(0)}}.Toastify__progress-bar{position:absolute;bottom:0;left:0;width:100%;height:100%;z-index:var(--toastify-z-index);opacity:.7;transform-origin:left;border-bottom-left-radius:var(--toastify-toast-bd-radius)}.Toastify__progress-bar--animated{animation:Toastify__trackProgress linear 1 forwards}.Toastify__progress-bar--controlled{transition:transform .2s}.Toastify__progress-bar--rtl{right:0;left:auto;transform-origin:right;border-bottom-left-radius:0;border-bottom-right-radius:var(--toastify-toast-bd-radius)}.Toastify__progress-bar--wrp{position:absolute;bottom:0;left:0;width:100%;height:5px;border-bottom-left-radius:var(--toastify-toast-bd-radius)}.Toastify__progress-bar--wrp[data-hidden=true]{opacity:0}.Toastify__progress-bar--bg{opacity:var(--toastify-color-progress-bgo);width:100%;height:100%}.Toastify__spinner{width:20px;height:20px;box-sizing:border-box;border:2px solid;border-radius:100%;border-color:var(--toastify-spinner-color-empty-area);border-right-color:var(--toastify-spinner-color);animation:Toastify__spin .65s linear infinite}@keyframes Toastify__bounceInRight{0%,60%,75%,90%,to{animation-timing-function:cubic-bezier(.215,.61,.355,1)}0%{opacity:0;transform:translate3d(3000px,0,0)}60%{opacity:1;transform:translate3d(-25px,0,0)}75%{transform:translate3d(10px,0,0)}90%{transform:translate3d(-5px,0,0)}to{transform:none}}@keyframes Toastify__bounceOutRight{20%{opacity:1;transform:translate3d(-20px,var(--y),0)}to{opacity:0;transform:translate3d(2000px,var(--y),0)}}@keyframes Toastify__bounceInLeft{0%,60%,75%,90%,to{animation-timing-function:cubic-bezier(.215,.61,.355,1)}0%{opacity:0;transform:translate3d(-3000px,0,0)}60%{opacity:1;transform:translate3d(25px,0,0)}75%{transform:translate3d(-10px,0,0)}90%{transform:translate3d(5px,0,0)}to{transform:none}}@keyframes Toastify__bounceOutLeft{20%{opacity:1;transform:translate3d(20px,var(--y),0)}to{opacity:0;transform:translate3d(-2000px,var(--y),0)}}@keyframes Toastify__bounceInUp{0%,60%,75%,90%,to{animation-timing-function:cubic-bezier(.215,.61,.355,1)}0%{opacity:0;transform:translate3d(0,3000px,0)}60%{opacity:1;transform:translate3d(0,-20px,0)}75%{transform:translate3d(0,10px,0)}90%{transform:translate3d(0,-5px,0)}to{transform:translateZ(0)}}@keyframes Toastify__bounceOutUp{20%{transform:translate3d(0,calc(var(--y) - 10px),0)}40%,45%{opacity:1;transform:translate3d(0,calc(var(--y) + 20px),0)}to{opacity:0;transform:translate3d(0,-2000px,0)}}@keyframes Toastify__bounceInDown{0%,60%,75%,90%,to{animation-timing-function:cubic-bezier(.215,.61,.355,1)}0%{opacity:0;transform:translate3d(0,-3000px,0)}60%{opacity:1;transform:translate3d(0,25px,0)}75%{transform:translate3d(0,-10px,0)}90%{transform:translate3d(0,5px,0)}to{transform:none}}@keyframes Toastify__bounceOutDown{20%{transform:translate3d(0,calc(var(--y) - 10px),0)}40%,45%{opacity:1;transform:translate3d(0,calc(var(--y) + 20px),0)}to{opacity:0;transform:translate3d(0,2000px,0)}}.Toastify__bounce-enter--bottom-left,.Toastify__bounce-enter--top-left{animation-name:Toastify__bounceInLeft}.Toastify__bounce-enter--bottom-right,.Toastify__bounce-enter--top-right{animation-name:Toastify__bounceInRight}.Toastify__bounce-enter--top-center{animation-name:Toastify__bounceInDown}.Toastify__bounce-enter--bottom-center{animation-name:Toastify__bounceInUp}.Toastify__bounce-exit--bottom-left,.Toastify__bounce-exit--top-left{animation-name:Toastify__bounceOutLeft}.Toastify__bounce-exit--bottom-right,.Toastify__bounce-exit--top-right{animation-name:Toastify__bounceOutRight}.Toastify__bounce-exit--top-center{animation-name:Toastify__bounceOutUp}.Toastify__bounce-exit--bottom-center{animation-name:Toastify__bounceOutDown}@keyframes Toastify__zoomIn{0%{opacity:0;transform:scale3d(.3,.3,.3)}50%{opacity:1}}@keyframes Toastify__zoomOut{0%{opacity:1}50%{opacity:0;transform:translate3d(0,var(--y),0) scale3d(.3,.3,.3)}to{opacity:0}}.Toastify__zoom-enter{animation-name:Toastify__zoomIn}.Toastify__zoom-exit{animation-name:Toastify__zoomOut}@keyframes Toastify__flipIn{0%{transform:perspective(400px) rotateX(90deg);animation-timing-function:ease-in;opacity:0}40%{transform:perspective(400px) rotateX(-20deg);animation-timing-function:ease-in}60%{transform:perspective(400px) rotateX(10deg);opacity:1}80%{transform:perspective(400px) rotateX(-5deg)}to{transform:perspective(400px)}}@keyframes Toastify__flipOut{0%{transform:translate3d(0,var(--y),0) perspective(400px)}30%{transform:translate3d(0,var(--y),0) perspective(400px) rotateX(-20deg);opacity:1}to{transform:translate3d(0,var(--y),0) perspective(400px) rotateX(90deg);opacity:0}}.Toastify__flip-enter{animation-name:Toastify__flipIn}.Toastify__flip-exit{animation-name:Toastify__flipOut}@keyframes Toastify__slideInRight{0%{transform:translate3d(110%,0,0);visibility:visible}to{transform:translate3d(0,var(--y),0)}}@keyframes Toastify__slideInLeft{0%{transform:translate3d(-110%,0,0);visibility:visible}to{transform:translate3d(0,var(--y),0)}}@keyframes Toastify__slideInUp{0%{transform:translate3d(0,110%,0);visibility:visible}to{transform:translate3d(0,var(--y),0)}}@keyframes Toastify__slideInDown{0%{transform:translate3d(0,-110%,0);visibility:visible}to{transform:translate3d(0,var(--y),0)}}@keyframes Toastify__slideOutRight{0%{transform:translate3d(0,var(--y),0)}to{visibility:hidden;transform:translate3d(110%,var(--y),0)}}@keyframes Toastify__slideOutLeft{0%{transform:translate3d(0,var(--y),0)}to{visibility:hidden;transform:translate3d(-110%,var(--y),0)}}@keyframes Toastify__slideOutDown{0%{transform:translate3d(0,var(--y),0)}to{visibility:hidden;transform:translate3d(0,500px,0)}}@keyframes Toastify__slideOutUp{0%{transform:translate3d(0,var(--y),0)}to{visibility:hidden;transform:translate3d(0,-500px,0)}}.Toastify__slide-enter--bottom-left,.Toastify__slide-enter--top-left{animation-name:Toastify__slideInLeft}.Toastify__slide-enter--bottom-right,.Toastify__slide-enter--top-right{animation-name:Toastify__slideInRight}.Toastify__slide-enter--top-center{animation-name:Toastify__slideInDown}.Toastify__slide-enter--bottom-center{animation-name:Toastify__slideInUp}.Toastify__slide-exit--bottom-left,.Toastify__slide-exit--top-left{animation-name:Toastify__slideOutLeft;animation-timing-function:ease-in;animation-duration:.3s}.Toastify__slide-exit--bottom-right,.Toastify__slide-exit--top-right{animation-name:Toastify__slideOutRight;animation-timing-function:ease-in;animation-duration:.3s}.Toastify__slide-exit--top-center{animation-name:Toastify__slideOutUp;animation-timing-function:ease-in;animation-duration:.3s}.Toastify__slide-exit--bottom-center{animation-name:Toastify__slideOutDown;animation-timing-function:ease-in;animation-duration:.3s}@keyframes Toastify__spin{0%{transform:rotate(0deg)}to{transform:rotate(1turn)}}',A=document.createElement("style");A.innerText=e,document.head.appendChild(A)}var G0A={exports:{}},R0A,qBt;function OBt(){return qBt||(qBt=1,R0A={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]}),R0A}var N0A={exports:{}},L0A,WBt;function gje(){return WBt||(WBt=1,L0A=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")}),L0A}var ZBt;function cje(){if(ZBt)return N0A.exports;ZBt=1;var e=gje(),A=Array.prototype.concat,t=Array.prototype.slice,i=N0A.exports=function(o){for(var s=[],r=0,a=o.length;r<a;r++){var g=o[r];e(g)?s=A.call(s,t.call(g)):s.push(g)}return s};return i.wrap=function(n){return function(){return n(i(arguments))}},N0A.exports}var VBt;function Ije(){if(VBt)return G0A.exports;VBt=1;var e=OBt(),A=cje(),t=Object.hasOwnProperty,i=Object.create(null);for(var n in e)t.call(e,n)&&(i[e[n]]=n);var o=G0A.exports={to:{},get:{}};o.get=function(a){var g=a.substring(0,3).toLowerCase(),c,I;switch(g){case"hsl":c=o.get.hsl(a),I="hsl";break;case"hwb":c=o.get.hwb(a),I="hwb";break;default:c=o.get.rgb(a),I="rgb";break}return c?{model:I,value:c}:null},o.get.rgb=function(a){if(!a)return null;var g=/^#([a-f0-9]{3,4})$/i,c=/^#([a-f0-9]{6})([a-f0-9]{2})?$/i,I=/^rgba?\(\s*([+-]?\d+)(?=[\s,])\s*(?:,\s*)?([+-]?\d+)(?=[\s,])\s*(?:,\s*)?([+-]?\d+)\s*(?:[,|\/]\s*([+-]?[\d\.]+)(%?)\s*)?\)$/,l=/^rgba?\(\s*([+-]?[\d\.]+)\%\s*,?\s*([+-]?[\d\.]+)\%\s*,?\s*([+-]?[\d\.]+)\%\s*(?:[,|\/]\s*([+-]?[\d\.]+)(%?)\s*)?\)$/,B=/^(\w+)$/,C=[0,0,0,1],Q,h,E;if(Q=a.match(c)){for(E=Q[2],Q=Q[1],h=0;h<3;h++){var u=h*2;C[h]=parseInt(Q.slice(u,u+2),16)}E&&(C[3]=parseInt(E,16)/255)}else if(Q=a.match(g)){for(Q=Q[1],E=Q[3],h=0;h<3;h++)C[h]=parseInt(Q[h]+Q[h],16);E&&(C[3]=parseInt(E+E,16)/255)}else if(Q=a.match(I)){for(h=0;h<3;h++)C[h]=parseInt(Q[h+1],0);Q[4]&&(Q[5]?C[3]=parseFloat(Q[4])*.01:C[3]=parseFloat(Q[4]))}else if(Q=a.match(l)){for(h=0;h<3;h++)C[h]=Math.round(parseFloat(Q[h+1])*2.55);Q[4]&&(Q[5]?C[3]=parseFloat(Q[4])*.01:C[3]=parseFloat(Q[4]))}else return(Q=a.match(B))?Q[1]==="transparent"?[0,0,0,0]:t.call(e,Q[1])?(C=e[Q[1]],C[3]=1,C):null:null;for(h=0;h<3;h++)C[h]=s(C[h],0,255);return C[3]=s(C[3],0,1),C},o.get.hsl=function(a){if(!a)return null;var g=/^hsla?\(\s*([+-]?(?:\d{0,3}\.)?\d+)(?:deg)?\s*,?\s*([+-]?[\d\.]+)%\s*,?\s*([+-]?[\d\.]+)%\s*(?:[,|\/]\s*([+-]?(?=\.\d|\d)(?:0|[1-9]\d*)?(?:\.\d*)?(?:[eE][+-]?\d+)?)\s*)?\)$/,c=a.match(g);if(c){var I=parseFloat(c[4]),l=(parseFloat(c[1])%360+360)%360,B=s(parseFloat(c[2]),0,100),C=s(parseFloat(c[3]),0,100),Q=s(isNaN(I)?1:I,0,1);return[l,B,C,Q]}return null},o.get.hwb=function(a){if(!a)return null;var g=/^hwb\(\s*([+-]?\d{0,3}(?:\.\d+)?)(?:deg)?\s*,\s*([+-]?[\d\.]+)%\s*,\s*([+-]?[\d\.]+)%\s*(?:,\s*([+-]?(?=\.\d|\d)(?:0|[1-9]\d*)?(?:\.\d*)?(?:[eE][+-]?\d+)?)\s*)?\)$/,c=a.match(g);if(c){var I=parseFloat(c[4]),l=(parseFloat(c[1])%360+360)%360,B=s(parseFloat(c[2]),0,100),C=s(parseFloat(c[3]),0,100),Q=s(isNaN(I)?1:I,0,1);return[l,B,C,Q]}return null},o.to.hex=function(){var a=A(arguments);return"#"+r(a[0])+r(a[1])+r(a[2])+(a[3]<1?r(Math.round(a[3]*255)):"")},o.to.rgb=function(){var a=A(arguments);return a.length<4||a[3]===1?"rgb("+Math.round(a[0])+", "+Math.round(a[1])+", "+Math.round(a[2])+")":"rgba("+Math.round(a[0])+", "+Math.round(a[1])+", "+Math.round(a[2])+", "+a[3]+")"},o.to.rgb.percent=function(){var a=A(arguments),g=Math.round(a[0]/255*100),c=Math.round(a[1]/255*100),I=Math.round(a[2]/255*100);return a.length<4||a[3]===1?"rgb("+g+"%, "+c+"%, "+I+"%)":"rgba("+g+"%, "+c+"%, "+I+"%, "+a[3]+")"},o.to.hsl=function(){var a=A(arguments);return a.length<4||a[3]===1?"hsl("+a[0]+", "+a[1]+"%, "+a[2]+"%)":"hsla("+a[0]+", "+a[1]+"%, "+a[2]+"%, "+a[3]+")"},o.to.hwb=function(){var a=A(arguments),g="";return a.length>=4&&a[3]!==1&&(g=", "+a[3]),"hwb("+a[0]+", "+a[1]+"%, "+a[2]+"%"+g+")"},o.to.keyword=function(a){return i[a.slice(0,3)]};function s(a,g,c){return Math.min(Math.max(g,a),c)}function r(a){var g=Math.round(a).toString(16).toUpperCase();return g.length<2?"0"+g:g}return G0A.exports}var U0A,jBt;function zBt(){if(jBt)return U0A;jBt=1;const e=OBt(),A={};for(const n of Object.keys(e))A[e[n]]=n;const t={rgb:{channels:3,labels:"rgb"},hsl:{channels:3,labels:"hsl"},hsv:{channels:3,labels:"hsv"},hwb:{channels:3,labels:"hwb"},cmyk:{channels:4,labels:"cmyk"},xyz:{channels:3,labels:"xyz"},lab:{channels:3,labels:"lab"},lch:{channels:3,labels:"lch"},hex:{channels:1,labels:["hex"]},keyword:{channels:1,labels:["keyword"]},ansi16:{channels:1,labels:["ansi16"]},ansi256:{channels:1,labels:["ansi256"]},hcg:{channels:3,labels:["h","c","g"]},apple:{channels:3,labels:["r16","g16","b16"]},gray:{channels:1,labels:["gray"]}};U0A=t;for(const n of Object.keys(t)){if(!("channels"in t[n]))throw new Error("missing channels property: "+n);if(!("labels"in t[n]))throw new Error("missing channel labels property: "+n);if(t[n].labels.length!==t[n].channels)throw new Error("channel and label counts mismatch: "+n);const{channels:o,labels:s}=t[n];delete t[n].channels,delete t[n].labels,Object.defineProperty(t[n],"channels",{value:o}),Object.defineProperty(t[n],"labels",{value:s})}t.rgb.hsl=function(n){const o=n[0]/255,s=n[1]/255,r=n[2]/255,a=Math.min(o,s,r),g=Math.max(o,s,r),c=g-a;let I,l;g===a?I=0:o===g?I=(s-r)/c:s===g?I=2+(r-o)/c:r===g&&(I=4+(o-s)/c),I=Math.min(I*60,360),I<0&&(I+=360);const B=(a+g)/2;return g===a?l=0:B<=.5?l=c/(g+a):l=c/(2-g-a),[I,l*100,B*100]},t.rgb.hsv=function(n){let o,s,r,a,g;const c=n[0]/255,I=n[1]/255,l=n[2]/255,B=Math.max(c,I,l),C=B-Math.min(c,I,l),Q=function(h){return(B-h)/6/C+1/2};return C===0?(a=0,g=0):(g=C/B,o=Q(c),s=Q(I),r=Q(l),c===B?a=r-s:I===B?a=1/3+o-r:l===B&&(a=2/3+s-o),a<0?a+=1:a>1&&(a-=1)),[a*360,g*100,B*100]},t.rgb.hwb=function(n){const o=n[0],s=n[1];let r=n[2];const a=t.rgb.hsl(n)[0],g=1/255*Math.min(o,Math.min(s,r));return r=1-1/255*Math.max(o,Math.max(s,r)),[a,g*100,r*100]},t.rgb.cmyk=function(n){const o=n[0]/255,s=n[1]/255,r=n[2]/255,a=Math.min(1-o,1-s,1-r),g=(1-o-a)/(1-a)||0,c=(1-s-a)/(1-a)||0,I=(1-r-a)/(1-a)||0;return[g*100,c*100,I*100,a*100]};function i(n,o){return(n[0]-o[0])**2+(n[1]-o[1])**2+(n[2]-o[2])**2}return t.rgb.keyword=function(n){const o=A[n];if(o)return o;let s=1/0,r;for(const a of Object.keys(e)){const g=e[a],c=i(n,g);c<s&&(s=c,r=a)}return r},t.keyword.rgb=function(n){return e[n]},t.rgb.xyz=function(n){let o=n[0]/255,s=n[1]/255,r=n[2]/255;o=o>.04045?((o+.055)/1.055)**2.4:o/12.92,s=s>.04045?((s+.055)/1.055)**2.4:s/12.92,r=r>.04045?((r+.055)/1.055)**2.4:r/12.92;const a=o*.4124+s*.3576+r*.1805,g=o*.2126+s*.7152+r*.0722,c=o*.0193+s*.1192+r*.9505;return[a*100,g*100,c*100]},t.rgb.lab=function(n){const o=t.rgb.xyz(n);let s=o[0],r=o[1],a=o[2];s/=95.047,r/=100,a/=108.883,s=s>.008856?s**(1/3):7.787*s+16/116,r=r>.008856?r**(1/3):7.787*r+16/116,a=a>.008856?a**(1/3):7.787*a+16/116;const g=116*r-16,c=500*(s-r),I=200*(r-a);return[g,c,I]},t.hsl.rgb=function(n){const o=n[0]/360,s=n[1]/100,r=n[2]/100;let a,g,c;if(s===0)return c=r*255,[c,c,c];r<.5?a=r*(1+s):a=r+s-r*s;const I=2*r-a,l=[0,0,0];for(let B=0;B<3;B++)g=o+1/3*-(B-1),g<0&&g++,g>1&&g--,6*g<1?c=I+(a-I)*6*g:2*g<1?c=a:3*g<2?c=I+(a-I)*(2/3-g)*6:c=I,l[B]=c*255;return l},t.hsl.hsv=function(n){const o=n[0];let s=n[1]/100,r=n[2]/100,a=s;const g=Math.max(r,.01);r*=2,s*=r<=1?r:2-r,a*=g<=1?g:2-g;const c=(r+s)/2,I=r===0?2*a/(g+a):2*s/(r+s);return[o,I*100,c*100]},t.hsv.rgb=function(n){const o=n[0]/60,s=n[1]/100;let r=n[2]/100;const a=Math.floor(o)%6,g=o-Math.floor(o),c=255*r*(1-s),I=255*r*(1-s*g),l=255*r*(1-s*(1-g));switch(r*=255,a){case 0:return[r,l,c];case 1:return[I,r,c];case 2:return[c,r,l];case 3:return[c,I,r];case 4:return[l,c,r];case 5:return[r,c,I]}},t.hsv.hsl=function(n){const o=n[0],s=n[1]/100,r=n[2]/100,a=Math.max(r,.01);let g,c;c=(2-s)*r;const I=(2-s)*a;return g=s*a,g/=I<=1?I:2-I,g=g||0,c/=2,[o,g*100,c*100]},t.hwb.rgb=function(n){const o=n[0]/360;let s=n[1]/100,r=n[2]/100;const a=s+r;let g;a>1&&(s/=a,r/=a);const c=Math.floor(6*o),I=1-r;g=6*o-c,(c&1)!==0&&(g=1-g);const l=s+g*(I-s);let B,C,Q;switch(c){default:case 6:case 0:B=I,C=l,Q=s;break;case 1:B=l,C=I,Q=s;break;case 2:B=s,C=I,Q=l;break;case 3:B=s,C=l,Q=I;break;case 4:B=l,C=s,Q=I;break;case 5:B=I,C=s,Q=l;break}return[B*255,C*255,Q*255]},t.cmyk.rgb=function(n){const o=n[0]/100,s=n[1]/100,r=n[2]/100,a=n[3]/100,g=1-Math.min(1,o*(1-a)+a),c=1-Math.min(1,s*(1-a)+a),I=1-Math.min(1,r*(1-a)+a);return[g*255,c*255,I*255]},t.xyz.rgb=function(n){const o=n[0]/100,s=n[1]/100,r=n[2]/100;let a,g,c;return a=o*3.2406+s*-1.5372+r*-.4986,g=o*-.9689+s*1.8758+r*.0415,c=o*.0557+s*-.204+r*1.057,a=a>.0031308?1.055*a**(1/2.4)-.055:a*12.92,g=g>.0031308?1.055*g**(1/2.4)-.055:g*12.92,c=c>.0031308?1.055*c**(1/2.4)-.055:c*12.92,a=Math.min(Math.max(0,a),1),g=Math.min(Math.max(0,g),1),c=Math.min(Math.max(0,c),1),[a*255,g*255,c*255]},t.xyz.lab=function(n){let o=n[0],s=n[1],r=n[2];o/=95.047,s/=100,r/=108.883,o=o>.008856?o**(1/3):7.787*o+16/116,s=s>.008856?s**(1/3):7.787*s+16/116,r=r>.008856?r**(1/3):7.787*r+16/116;const a=116*s-16,g=500*(o-s),c=200*(s-r);return[a,g,c]},t.lab.xyz=function(n){const o=n[0],s=n[1],r=n[2];let a,g,c;g=(o+16)/116,a=s/500+g,c=g-r/200;const I=g**3,l=a**3,B=c**3;return g=I>.008856?I:(g-16/116)/7.787,a=l>.008856?l:(a-16/116)/7.787,c=B>.008856?B:(c-16/116)/7.787,a*=95.047,g*=100,c*=108.883,[a,g,c]},t.lab.lch=function(n){const o=n[0],s=n[1],r=n[2];let a;a=Math.atan2(r,s)*360/2/Math.PI,a<0&&(a+=360);const c=Math.sqrt(s*s+r*r);return[o,c,a]},t.lch.lab=function(n){const o=n[0],s=n[1],a=n[2]/360*2*Math.PI,g=s*Math.cos(a),c=s*Math.sin(a);return[o,g,c]},t.rgb.ansi16=function(n,o=null){const[s,r,a]=n;let g=o===null?t.rgb.hsv(n)[2]:o;if(g=Math.round(g/50),g===0)return 30;let c=30+(Math.round(a/255)<<2|Math.round(r/255)<<1|Math.round(s/255));return g===2&&(c+=60),c},t.hsv.ansi16=function(n){return t.rgb.ansi16(t.hsv.rgb(n),n[2])},t.rgb.ansi256=function(n){const o=n[0],s=n[1],r=n[2];return o===s&&s===r?o<8?16:o>248?231:Math.round((o-8)/247*24)+232:16+36*Math.round(o/255*5)+6*Math.round(s/255*5)+Math.round(r/255*5)},t.ansi16.rgb=function(n){let o=n%10;if(o===0||o===7)return n>50&&(o+=3.5),o=o/10.5*255,[o,o,o];const s=(~~(n>50)+1)*.5,r=(o&1)*s*255,a=(o>>1&1)*s*255,g=(o>>2&1)*s*255;return[r,a,g]},t.ansi256.rgb=function(n){if(n>=232){const g=(n-232)*10+8;return[g,g,g]}n-=16;let o;const s=Math.floor(n/36)/5*255,r=Math.floor((o=n%36)/6)/5*255,a=o%6/5*255;return[s,r,a]},t.rgb.hex=function(n){const s=(((Math.round(n[0])&255)<<16)+((Math.round(n[1])&255)<<8)+(Math.round(n[2])&255)).toString(16).toUpperCase();return"000000".substring(s.length)+s},t.hex.rgb=function(n){const o=n.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i);if(!o)return[0,0,0];let s=o[0];o[0].length===3&&(s=s.split("").map(I=>I+I).join(""));const r=parseInt(s,16),a=r>>16&255,g=r>>8&255,c=r&255;return[a,g,c]},t.rgb.hcg=function(n){const o=n[0]/255,s=n[1]/255,r=n[2]/255,a=Math.max(Math.max(o,s),r),g=Math.min(Math.min(o,s),r),c=a-g;let I,l;return c<1?I=g/(1-c):I=0,c<=0?l=0:a===o?l=(s-r)/c%6:a===s?l=2+(r-o)/c:l=4+(o-s)/c,l/=6,l%=1,[l*360,c*100,I*100]},t.hsl.hcg=function(n){const o=n[1]/100,s=n[2]/100,r=s<.5?2*o*s:2*o*(1-s);let a=0;return r<1&&(a=(s-.5*r)/(1-r)),[n[0],r*100,a*100]},t.hsv.hcg=function(n){const o=n[1]/100,s=n[2]/100,r=o*s;let a=0;return r<1&&(a=(s-r)/(1-r)),[n[0],r*100,a*100]},t.hcg.rgb=function(n){const o=n[0]/360,s=n[1]/100,r=n[2]/100;if(s===0)return[r*255,r*255,r*255];const a=[0,0,0],g=o%1*6,c=g%1,I=1-c;let l=0;switch(Math.floor(g)){case 0:a[0]=1,a[1]=c,a[2]=0;break;case 1:a[0]=I,a[1]=1,a[2]=0;break;case 2:a[0]=0,a[1]=1,a[2]=c;break;case 3:a[0]=0,a[1]=I,a[2]=1;break;case 4:a[0]=c,a[1]=0,a[2]=1;break;default:a[0]=1,a[1]=0,a[2]=I}return l=(1-s)*r,[(s*a[0]+l)*255,(s*a[1]+l)*255,(s*a[2]+l)*255]},t.hcg.hsv=function(n){const o=n[1]/100,s=n[2]/100,r=o+s*(1-o);let a=0;return r>0&&(a=o/r),[n[0],a*100,r*100]},t.hcg.hsl=function(n){const o=n[1]/100,r=n[2]/100*(1-o)+.5*o;let a=0;return r>0&&r<.5?a=o/(2*r):r>=.5&&r<1&&(a=o/(2*(1-r))),[n[0],a*100,r*100]},t.hcg.hwb=function(n){const o=n[1]/100,s=n[2]/100,r=o+s*(1-o);return[n[0],(r-o)*100,(1-r)*100]},t.hwb.hcg=function(n){const o=n[1]/100,r=1-n[2]/100,a=r-o;let g=0;return a<1&&(g=(r-a)/(1-a)),[n[0],a*100,g*100]},t.apple.rgb=function(n){return[n[0]/65535*255,n[1]/65535*255,n[2]/65535*255]},t.rgb.apple=function(n){return[n[0]/255*65535,n[1]/255*65535,n[2]/255*65535]},t.gray.rgb=function(n){return[n[0]/100*255,n[0]/100*255,n[0]/100*255]},t.gray.hsl=function(n){return[0,0,n[0]]},t.gray.hsv=t.gray.hsl,t.gray.hwb=function(n){return[0,100,n[0]]},t.gray.cmyk=function(n){return[0,0,0,n[0]]},t.gray.lab=function(n){return[n[0],0,0]},t.gray.hex=function(n){const o=Math.round(n[0]/100*255)&255,r=((o<<16)+(o<<8)+o).toString(16).toUpperCase();return"000000".substring(r.length)+r},t.rgb.gray=function(n){return[(n[0]+n[1]+n[2])/3/255*100]},U0A}var H0A,XBt;function lje(){if(XBt)return H0A;XBt=1;const e=zBt();function A(){const o={},s=Object.keys(e);for(let r=s.length,a=0;a<r;a++)o[s[a]]={distance:-1,parent:null};return o}function t(o){const s=A(),r=[o];for(s[o].distance=0;r.length;){const a=r.pop(),g=Object.keys(e[a]);for(let c=g.length,I=0;I<c;I++){const l=g[I],B=s[l];B.distance===-1&&(B.distance=s[a].distance+1,B.parent=a,r.unshift(l))}}return s}function i(o,s){return function(r){return s(o(r))}}function n(o,s){const r=[s[o].parent,o];let a=e[s[o].parent][o],g=s[o].parent;for(;s[g].parent;)r.unshift(s[g].parent),a=i(e[s[g].parent][g],a),g=s[g].parent;return a.conversion=r,a}return H0A=function(o){const s=t(o),r={},a=Object.keys(s);for(let g=a.length,c=0;c<g;c++){const I=a[c];s[I].parent!==null&&(r[I]=n(I,s))}return r},H0A}var Y0A,$Bt;function Bje(){if($Bt)return Y0A;$Bt=1;const e=zBt(),A=lje(),t={},i=Object.keys(e);function n(s){const r=function(...a){const g=a[0];return g==null?g:(g.length>1&&(a=g),s(a))};return"conversion"in s&&(r.conversion=s.conversion),r}function o(s){const r=function(...a){const g=a[0];if(g==null)return g;g.length>1&&(a=g);const c=s(a);if(typeof c=="object")for(let I=c.length,l=0;l<I;l++)c[l]=Math.round(c[l]);return c};return"conversion"in s&&(r.conversion=s.conversion),r}return i.forEach(s=>{t[s]={},Object.defineProperty(t[s],"channels",{value:e[s].channels}),Object.defineProperty(t[s],"labels",{value:e[s].labels});const r=A(s);Object.keys(r).forEach(g=>{const c=r[g];t[s][g]=o(c),t[s][g].raw=n(c)})}),Y0A=t,Y0A}var J0A,ACt;function Cje(){if(ACt)return J0A;ACt=1;const e=Ije(),A=Bje(),t=["keyword","gray","hex"],i={};for(const l of Object.keys(A))i[[...A[l].labels].sort().join("")]=l;const n={};function o(l,B){if(!(this instanceof o))return new o(l,B);if(B&&B in t&&(B=null),B&&!(B in A))throw new Error("Unknown model: "+B);let C,Q;if(l==null)this.model="rgb",this.color=[0,0,0],this.valpha=1;else if(l instanceof o)this.model=l.model,this.color=[...l.color],this.valpha=l.valpha;else if(typeof l=="string"){const h=e.get(l);if(h===null)throw new Error("Unable to parse color from string: "+l);this.model=h.model,Q=A[this.model].channels,this.color=h.value.slice(0,Q),this.valpha=typeof h.value[Q]=="number"?h.value[Q]:1}else if(l.length>0){this.model=B||"rgb",Q=A[this.model].channels;const h=Array.prototype.slice.call(l,0,Q);this.color=I(h,Q),this.valpha=typeof l[Q]=="number"?l[Q]:1}else if(typeof l=="number")this.model="rgb",this.color=[l>>16&255,l>>8&255,l&255],this.valpha=1;else{this.valpha=1;const h=Object.keys(l);"alpha"in l&&(h.splice(h.indexOf("alpha"),1),this.valpha=typeof l.alpha=="number"?l.alpha:0);const E=h.sort().join("");if(!(E in i))throw new Error("Unable to parse color from object: "+JSON.stringify(l));this.model=i[E];const{labels:u}=A[this.model],d=[];for(C=0;C<u.length;C++)d.push(l[u[C]]);this.color=I(d)}if(n[this.model])for(Q=A[this.model].channels,C=0;C<Q;C++){const h=n[this.model][C];h&&(this.color[C]=h(this.color[C]))}this.valpha=Math.max(0,Math.min(1,this.valpha)),Object.freeze&&Object.freeze(this)}o.prototype={toString(){return this.string()},toJSON(){return this[this.model]()},string(l){let B=this.model in e.to?this:this.rgb();B=B.round(typeof l=="number"?l:1);const C=B.valpha===1?B.color:[...B.color,this.valpha];return e.to[B.model](C)},percentString(l){const B=this.rgb().round(typeof l=="number"?l:1),C=B.valpha===1?B.color:[...B.color,this.valpha];return e.to.rgb.percent(C)},array(){return this.valpha===1?[...this.color]:[...this.color,this.valpha]},object(){const l={},{channels:B}=A[this.model],{labels:C}=A[this.model];for(let Q=0;Q<B;Q++)l[C[Q]]=this.color[Q];return this.valpha!==1&&(l.alpha=this.valpha),l},unitArray(){const l=this.rgb().color;return l[0]/=255,l[1]/=255,l[2]/=255,this.valpha!==1&&l.push(this.valpha),l},unitObject(){const l=this.rgb().object();return l.r/=255,l.g/=255,l.b/=255,this.valpha!==1&&(l.alpha=this.valpha),l},round(l){return l=Math.max(l||0,0),new o([...this.color.map(r(l)),this.valpha],this.model)},alpha(l){return l!==void 0?new o([...this.color,Math.max(0,Math.min(1,l))],this.model):this.valpha},red:a("rgb",0,g(255)),green:a("rgb",1,g(255)),blue:a("rgb",2,g(255)),hue:a(["hsl","hsv","hsl","hwb","hcg"],0,l=>(l%360+360)%360),saturationl:a("hsl",1,g(100)),lightness:a("hsl",2,g(100)),saturationv:a("hsv",1,g(100)),value:a("hsv",2,g(100)),chroma:a("hcg",1,g(100)),gray:a("hcg",2,g(100)),white:a("hwb",1,g(100)),wblack:a("hwb",2,g(100)),cyan:a("cmyk",0,g(100)),magenta:a("cmyk",1,g(100)),yellow:a("cmyk",2,g(100)),black:a("cmyk",3,g(100)),x:a("xyz",0,g(95.047)),y:a("xyz",1,g(100)),z:a("xyz",2,g(108.833)),l:a("lab",0,g(100)),a:a("lab",1),b:a("lab",2),keyword(l){return l!==void 0?new o(l):A[this.model].keyword(this.color)},hex(l){return l!==void 0?new o(l):e.to.hex(this.rgb().round().color)},hexa(l){if(l!==void 0)return new o(l);const B=this.rgb().round().color;let C=Math.round(this.valpha*255).toString(16).toUpperCase();return C.length===1&&(C="0"+C),e.to.hex(B)+C},rgbNumber(){const l=this.rgb().color;return(l[0]&255)<<16|(l[1]&255)<<8|l[2]&255},luminosity(){const l=this.rgb().color,B=[];for(const[C,Q]of l.entries()){const h=Q/255;B[C]=h<=.04045?h/12.92:((h+.055)/1.055)**2.4}return .2126*B[0]+.7152*B[1]+.0722*B[2]},contrast(l){const B=this.luminosity(),C=l.luminosity();return B>C?(B+.05)/(C+.05):(C+.05)/(B+.05)},level(l){const B=this.contrast(l);return B>=7?"AAA":B>=4.5?"AA":""},isDark(){const l=this.rgb().color;return(l[0]*2126+l[1]*7152+l[2]*722)/1e4<128},isLight(){return!this.isDark()},negate(){const l=this.rgb();for(let B=0;B<3;B++)l.color[B]=255-l.color[B];return l},lighten(l){const B=this.hsl();return B.color[2]+=B.color[2]*l,B},darken(l){const B=this.hsl();return B.color[2]-=B.color[2]*l,B},saturate(l){const B=this.hsl();return B.color[1]+=B.color[1]*l,B},desaturate(l){const B=this.hsl();return B.color[1]-=B.color[1]*l,B},whiten(l){const B=this.hwb();return B.color[1]+=B.color[1]*l,B},blacken(l){const B=this.hwb();return B.color[2]+=B.color[2]*l,B},grayscale(){const l=this.rgb().color,B=l[0]*.3+l[1]*.59+l[2]*.11;return o.rgb(B,B,B)},fade(l){return this.alpha(this.valpha-this.valpha*l)},opaquer(l){return this.alpha(this.valpha+this.valpha*l)},rotate(l){const B=this.hsl();let C=B.color[0];return C=(C+l)%360,C=C<0?360+C:C,B.color[0]=C,B},mix(l,B){if(!l||!l.rgb)throw new Error('Argument to "mix" was not a Color instance, but rather an instance of '+typeof l);const C=l.rgb(),Q=this.rgb(),h=B===void 0?.5:B,E=2*h-1,u=C.alpha()-Q.alpha(),d=((E*u===-1?E:(E+u)/(1+E*u))+1)/2,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(t.includes(l))continue;const{channels:B}=A[l];o.prototype[l]=function(...C){return this.model===l?new o(this):C.length>0?new o(C,l):new o([...c(A[this.model][l].raw(this.color)),this.valpha],l)},o[l]=function(...C){let Q=C[0];return typeof Q=="number"&&(Q=I(C,B)),new o(Q,l)}}function s(l,B){return Number(l.toFixed(B))}function r(l){return function(B){return s(B,l)}}function a(l,B,C){l=Array.isArray(l)?l:[l];for(const Q of l)(n[Q]||(n[Q]=[]))[B]=C;return l=l[0],function(Q){let h;return Q!==void 0?(C&&(Q=C(Q)),h=this[l](),h.color[B]=Q,h):(h=this[l]().color[B],C&&(h=C(h)),h)}}function g(l){return function(B){return Math.max(0,Math.min(l,B))}}function c(l){return Array.isArray(l)?l:[l]}function I(l,B){for(let C=0;C<B;C++)typeof l[C]!="number"&&(l[C]=0);return l}return J0A=o,J0A}var Qje=Cje();const Ya=S0(Qje);function ai(e,A){return Array.isArray(A)?[e.a*A[0]+e.c*A[1]+e.e,e.b*A[0]+e.d*A[1]+e.f]:{x:e.a*A.x+e.c*A.y+e.e,y:e.b*A.x+e.d*A.y+e.f}}function hje(){return{a:1,c:0,e:0,b:0,d:1,f:0}}function BT(e){return typeof e>"u"}function vk(e,A=0){return{a:1,c:0,e,b:0,d:1,f:A}}function pj(...e){e=Array.isArray(e[0])?e[0]:e;const A=(t,i)=>({a:t.a*i.a+t.c*i.b,c:t.a*i.c+t.c*i.d,e:t.a*i.e+t.c*i.f+t.e,b:t.b*i.a+t.d*i.b,d:t.b*i.c+t.d*i.d,f:t.b*i.e+t.d*i.f+t.f});switch(e.length){case 0:throw new Error("no matrices provided");case 1:return e[0];case 2:return A(e[0],e[1]);default:{const[t,i,...n]=e,o=A(t,i);return pj(o,...n)}}}function T0A(...e){return pj(...e)}const{cos:Eje,sin:uje}=Math;function tCt(e,A,t){const i=Eje(e),n=uje(e),o={a:i,c:-n,e:0,b:n,d:i,f:0};return BT(A)||BT(t)?o:pj([vk(A,t),o,vk(-A,-t)])}function dje(e,A=void 0,t=void 0,i=void 0){BT(A)&&(A=e);const n={a:e,c:0,e:0,b:0,d:A,f:0};return BT(t)||BT(i)?n:pj([vk(t,i),n,vk(-t,-i)])}function fj(e){const{ctx:A,points:t,fill:i,stroke:n,strokeWidth:o=1,minStrokePx:s,realToCanvasMat:r,closePath:a=!1}=e;if(t.length<2)return;A.beginPath();const g=t.map(B=>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 AQ(e){const{ctx:A,center:t,width:i,height:n,fill:o,realToCanvasMat:s,borderRadius:r=0,ccwRotationDegrees:a=0,stroke:g,strokeWidth:c,isStrokeDashed:I=!1}=e,[l,B]=ai(s,[t.x,t.y]),C=i*Math.abs(s.a),Q=n*Math.abs(s.a),h=r*Math.abs(s.a),E=c?c*Math.abs(s.a):void 0;if(A.save(),A.translate(l,B),a!==0&&A.rotate(-a*(Math.PI/180)),A.beginPath(),h>0){const u=-C/2,d=-Q/2,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 pje(e){const{ctx:A,board:t,realToCanvasMat:i,colorMap:n,drawBoardMaterial:o,minBoardOutlineStrokePx:s}=e,{width:r,height:a,center:g,outline:c}=t;if(c&&Array.isArray(c)&&c.length>=3){o&&fj({ctx:A,points:c.map(I=>({x:I.x,y:I.y})),fill:n.substrate,realToCanvasMat:i,closePath:!0}),fj({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&&AQ({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}];fj({ctx:A,points:B,stroke:n.boardOutline,strokeWidth:.1,realToCanvasMat:i,closePath:!0,minStrokePx:s})}}function Fk(e){const{ctx:A,points:t,fill:i,realToCanvasMat:n}=e;if(t.length<3)return;A.beginPath();const o=t.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 fje(e,A){return A.copper[e]??A.copper.top}function yje(e){return e==="top"||e==="bottom"?.5:1}function mje(e,A,t,i,n){if(Math.abs(n)<1e-10)return null;const o=t-e,s=i-A,r=Math.hypot(o,s);if(r<1e-10)return null;const a=Math.abs(n)*(r/2),g=r/2,c=(a*a+g*g)/(2*a),I=c-a,l=(e+t)/2,B=(A+i)/2,C=-s/r,Q=o/r,h=n>0?-1:1,E=l+h*C*I,u=B+h*Q*I;return{centerX:E,centerY:u,radius:c}}function P0A(e,A,t,i,n,o,s){if(Math.abs(o)<1e-10){const[f,m]=ai(s,[i,n]);e.lineTo(f,m);return}const r=mje(A,t,i,n,o);if(!r){const[f,m]=ai(s,[i,n]);e.lineTo(f,m);return}const[a,g]=ai(s,[A,t]),[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;e.arc(l,B,C,Q,h,d)}function eCt(e,A,t){if(A.vertices.length<2)return;if(A.vertices.length===2){const s=A.vertices[0],r=A.vertices[1];if(s&&r&&Math.abs((s.bulge??0)-1)<1e-10&&Math.abs((r.bulge??0)-1)<1e-10){const[a,g]=ai(t,[s.x,s.y]);e.moveTo(a,g),P0A(e,s.x,s.y,r.x,r.y,1,t),P0A(e,r.x,r.y,s.x,s.y,1,t);return}}const i=A.vertices[0];if(!i)return;const[n,o]=ai(t,[i.x,i.y]);e.moveTo(n,o);for(let s=0;s<A.vertices.length;s++){const r=A.vertices[s],a=(s+1)%A.vertices.length,g=A.vertices[a];if(!r||!g)continue;const c=r.bulge??0;if(Math.abs(c)<1e-10){const[I,l]=ai(t,[g.x,g.y]);e.lineTo(I,l)}else P0A(e,r.x,r.y,g.x,g.y,c,t)}}function wje(e){const{ctx:A,pour:t,realToCanvasMat:i,colorMap:n}=e,o=fje(t.layer,n),s=yje(t.layer);if(A.save(),A.globalAlpha=s,t.shape==="rect"){const[r,a]=ai(i,[t.center.x,t.center.y]),g=t.width*Math.abs(i.a),c=t.height*Math.abs(i.a);A.translate(r,a),t.rotation&&A.rotate(-t.rotation*(Math.PI/180)),A.beginPath(),A.rect(-g/2,-c/2,g,c),A.fillStyle=o,A.fill(),A.restore();return}if(t.shape==="polygon"){if(t.points&&t.points.length>=3){const r=t.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(t.shape==="brep"){if(A.beginPath(),eCt(A,t.brep_shape.outer_ring,i),t.brep_shape.inner_rings)for(const r of t.brep_shape.inner_rings)eCt(A,r,i);A.fillStyle=o,A.fill("evenodd"),A.restore();return}A.restore()}var Dje=e=>S$A[e]??(e===" "?id.spaceWidthRatio:id.glyphWidthRatio);function iCt(e,A,t){const i=Dje(e),n=A?id.letterSpacingRatio:0,o=A?b$A[e]?.[A]??0:0;return t*(i+n+o)}function K0A(e,A){const t=A*id.glyphWidthRatio,i=A*id.letterSpacingRatio,n=A*id.spaceWidthRatio,o=A*id.strokeWidthRatio,s=A*id.lineHeightRatio,r=e.replace(/\\n/g,`
|
|
5385
5385
|
`).split(`
|
|
5386
|
-
`),a=r.map(I=>{const l=Array.from(I);return l.reduce((B,C,Q)=>B+iCt(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:t,letterSpacing:i,spaceWidth:n,strokeWidth:o,lineHeight:s,lines:r,lineWidths:a}}function nCt(e,A){const t=A.width+A.strokeWidth,i=A.height+A.strokeWidth;let n=0,o=0;return e==="center"||e==="top_center"||e==="bottom_center"?n=-t/2:e==="top_left"||e==="bottom_left"||e==="center_left"?n=0:e==="top_right"||e==="bottom_right"||e==="center_right"?n=-t:(e==="top_center"||e==="bottom_center")&&(n=-t/2),e==="center"||e==="center_left"||e==="center_right"?o=-i/2:e==="top_left"||e==="top_right"||e==="top_center"?o=0:(e==="bottom_left"||e==="bottom_right"||e==="bottom_center")&&(o=-i),{x:n,y:o}}function oCt(e){const{alignment:A,lineWidth:t,maxWidth:i,strokeWidth:n}=e,o=t+n,s=i+n;return A==="top_left"||A==="bottom_left"||A==="center_left"?0:A==="top_right"||A==="bottom_right"||A==="center_right"?s-o:(s-o)/2}var Sje=e=>D$A[e];function sCt(e){const{ctx:A,line:t,fontSize:i,startX:n,startY:o,layout:s}=e,{strokeWidth:r}=s,a=i,g=i,c=o,I=Array.from(t);let l=n+r/2;I.forEach((B,C)=>{const Q=Sje(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+=iCt(B,I[C+1],i)})}function bje(e){const{ctx:A,text:t,fontSize:i,startX:n,startY:o,anchorAlignment:s="center"}=e,r=K0A(t,i),{lines:a,lineWidths:g,lineHeight:c,width:I,strokeWidth:l}=r;a.forEach((B,C)=>{const Q=n+oCt({alignment:s,lineWidth:g[C],maxWidth:I,strokeWidth:l}),h=o+C*c;sCt({ctx:A,line:B,fontSize:i,startX:Q,startY:h,layout:r})})}var xje={left:.2,right:.2,top:.2,bottom:.2};function yj(e){const{ctx:A,text:t,x:i,y:n,fontSize:o,color:s,realToCanvasMat:r,anchorAlignment:a,rotation:g=0,mirrorX:c=!1,knockout:I=!1,knockoutPadding:l={}}=e;if(!t)return;const[B,C]=ai(r,[i,n]),Q=Math.abs(r.a),h=o*Q,E=K0A(t,h),u=nCt(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={...xje,...l},_=S.left*Q,b=S.right*Q,R=S.top*Q,F=S.bottom*Q,H=E.width+E.strokeWidth,Y=u.x-_*4,J=u.y-R*4,O=H+_*2+b*2,W=E.height+E.strokeWidth+R*2+F*2;A.fillStyle=s,A.fillRect(Y,J,O,W)}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+oCt({alignment:a,lineWidth:f[_],maxWidth:w,strokeWidth:D}),R=u.y+_*m;sCt({ctx:A,line:S,fontSize:h,startX:b,startY:R,layout:E})}),A.restore()}var _je={left:.2,right:.2,top:.2,bottom:.2};function kje(e){return e?e.includes("left")?"center_left":e.includes("right")?"center_right":"center":"center"}function vje(e){const{ctx:A,text:t,realToCanvasMat:i,colorMap:n}=e,o=t.text??"";if(!o)return;const[s,r]=ai(i,[t.anchor_position.x,t.anchor_position.y]),a=Math.abs(i.a),g=(t.font_size??1)*a,c=t.ccw_rotation??0,I={..._je,...t.knockout_padding},l=n.copper[t.layer]??n.copper.top,B=K0A(o,g),C=B.width+B.strokeWidth,Q=kje(t.anchor_alignment),h=nCt(Q,B);if(A.save(),A.translate(s,r),t.is_mirrored&&A.scale(-1,1),c!==0&&A.rotate(-c*(Math.PI/180)),A.lineWidth=B.strokeWidth,A.lineCap="round",A.lineJoin="round",t.is_knockout){const E=I.left*a,u=I.right*a,d=I.top*a,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;bje({ctx:A,text:o,fontSize:g,startX:h.x,startY:h.y,anchorAlignment:Q}),A.restore()}function tQ(e){const{ctx:A,center:t,radius:i,fill:n,realToCanvasMat:o,stroke:s,strokeWidth:r,isStrokeDashed:a=!1}=e,[g,c]=ai(o,[t.x,t.y]),I=i*Math.abs(o.a),l=r?r*Math.abs(o.a):void 0;A.beginPath(),A.arc(g,c,I,0,Math.PI*2),n&&(A.fillStyle=n,A.fill()),s&&l&&(a?A.setLineDash([l*3,l*2]):A.setLineDash([]),A.strokeStyle=s,A.lineWidth=l,A.stroke())}function Fje(e,A){return e==="bottom"?A.courtyard.bottom:A.courtyard.top}function Mje(e){const{ctx:A,circle:t,realToCanvasMat:i,colorMap:n}=e;tQ({ctx:A,center:t.center,radius:t.radius,stroke:Fje(t.layer,n),strokeWidth:.05,realToCanvasMat:i})}function Gje(e,A){return e==="bottom"?A.courtyard.bottom:A.courtyard.top}function Rje(e){const{ctx:A,outline:t,realToCanvasMat:i,colorMap:n}=e;if(!t.outline||t.outline.length<2)return;A.beginPath();const o=ai(i,t.outline[0]);A.moveTo(o.x,o.y);for(let s=1;s<t.outline.length;s++){const r=ai(i,t.outline[s]);A.lineTo(r.x,r.y)}A.closePath(),A.lineWidth=.05*Math.abs(i.a),A.strokeStyle=Gje(t.layer,n),A.stroke()}function Nje(e,A){return e==="bottom"?A.courtyard.bottom:A.courtyard.top}function Lje(e){const{ctx:A,rect:t,realToCanvasMat:i,colorMap:n}=e;AQ({ctx:A,center:t.center,width:t.width,height:t.height,stroke:Nje(t.layer,n),strokeWidth:.05,realToCanvasMat:i})}function Uje(e){const{ctx:A,cutout:t,realToCanvasMat:i,colorMap:n}=e;if(t.shape==="rect"){AQ({ctx:A,center:t.center,width:t.width,height:t.height,fill:n.drill,realToCanvasMat:i,ccwRotationDegrees:t.rotation??0,borderRadius:t.corner_radius??0});return}if(t.shape==="circle"){tQ({ctx:A,center:t.center,radius:t.radius,fill:n.drill,realToCanvasMat:i});return}if(t.shape==="polygon"){t.points&&t.points.length>=3&&Fk({ctx:A,points:t.points,fill:n.drill,realToCanvasMat:i});return}}var Hje=1.5,Yje=.6,Jje=.3;function q0A(e){const A=Math.hypot(e.x,e.y)||1;return{x:e.x/A,y:e.y/A}}function rCt(e){const{ctx:A,from:t,to:i,realToCanvasMat:n,color:o,fontSize:s,arrowSize:r=1,strokeWidth:a,text:g,textRotation:c,offset:I}=e,l=q0A({x:i.x-t.x,y:i.y-t.y}),B={x:-l.y,y:l.x},C=I?.direction&&typeof I.direction.x=="number"&&typeof I.direction.y=="number",Q=C?q0A(I.direction):{x:0,y:0},h=I?.distance??0,E={x:Q.x*h,y:Q.y*h},u={x:t.x+E.x,y:t.y+E.y},d={x:i.x+E.x,y:i.y+E.y},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=[],R=Y=>{const J={x:Y.x+S.x*_,y:Y.y+S.y*_},O=w/2,W={x:-S.y,y:S.x};return[{x:Y.x+W.x*O,y:Y.y+W.y*O},{x:Y.x-W.x*O,y:Y.y-W.y*O},{x:J.x-W.x*O,y:J.y-W.y*O},{x:J.x+W.x*O,y:J.y+W.y*O}]};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],H=Y=>{const J=R(Y);b.push(F),b.push(J[0]),b.push(...J),b.push(J[0]),b.push(F)};if(H(t),H(i),Fk({ctx:A,points:b,fill:D,realToCanvasMat:n}),g){const Y={x:(t.x+i.x)/2+E.x,y:(t.y+i.y)/2+E.y},[J,O]=ai(n,[u.x,u.y]),[W,z]=ai(n,[d.x,d.y]),tA=q0A({x:W-J,y:z-O});let aA=Math.atan2(tA.y,tA.x)*180/Math.PI;(aA>90||aA<-90)&&(aA+=180);const eA=typeof c=="number"&&Number.isFinite(c)?aA-c:aA;let oA=0;if(g&&typeof c=="number"&&Number.isFinite(c)){const pA=g.length*s*Yje,kA=s,MA=c*Math.PI/180,TA=Math.abs(Math.sin(MA)),EA=Math.abs(Math.cos(MA)),_A=pA/2,dA=kA/2;oA=_A*TA+dA*EA+s*Jje}const rA=r*Hje+oA,BA={x:Y.x+B.x*rA,y:Y.y+B.y*rA};yj({ctx:A,text:g,x:BA.x,y:BA.y,fontSize:s,color:D,realToCanvasMat:n,anchorAlignment:"center",rotation:-eA})}}function Tje(e){const{ctx:A,pcbFabricationNoteDimension:t,realToCanvasMat:i,colorMap:n}=e,o=t.color??n.fabricationNote;rCt({ctx:A,from:t.from,to:t.to,realToCanvasMat:i,color:o,fontSize:t.font_size??1,arrowSize:t.arrow_size??1,text:t.text,textRotation:t.text_ccw_rotation,offset:t.offset_distance&&t.offset_direction?{distance:t.offset_distance,direction:t.offset_direction}:void 0})}function A1(e){const{ctx:A,start:t,end:i,strokeWidth:n,stroke:o,realToCanvasMat:s,lineCap:r="round"}=e,[a,g]=ai(s,[t.x,t.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 Pje(e){const{ctx:A,path:t,realToCanvasMat:i,colorMap:n}=e,o=n.fabricationNote,s=t.color??o;if(!(!t.route||t.route.length<2))for(let r=0;r<t.route.length-1;r++){const a=t.route[r],g=t.route[r+1];!a||!g||A1({ctx:A,start:{x:a.x,y:a.y},end:{x:g.x,y:g.y},strokeWidth:t.stroke_width??.1,stroke:s,realToCanvasMat:i})}}function Kje(e){const{ctx:A,rect:t,realToCanvasMat:i,colorMap:n}=e,o=n.fabricationNote,s=t.color??o,r=t.is_filled??!1,a=t.has_stroke??!0,g=t.is_stroke_dashed??!1;AQ({ctx:A,center:t.center,width:t.width,height:t.height,fill:r?s:void 0,stroke:a?s:void 0,strokeWidth:a?t.stroke_width:void 0,borderRadius:t.corner_radius,realToCanvasMat:i,isStrokeDashed:g})}function qje(e,A){return A.fabricationNote}function Oje(e){const{ctx:A,text:t,realToCanvasMat:i,colorMap:n}=e,o=qje(t.layer,n),s=t.color??o,r=t.font_size;yj({ctx:A,text:t.text,x:t.anchor_position.x,y:t.anchor_position.y,fontSize:r,color:s,realToCanvasMat:i,anchorAlignment:t.anchor_alignment})}function sS(e){const{ctx:A,center:t,radius_x:i,radius_y:n,fill:o,stroke:s,strokeWidth:r=.1,realToCanvasMat:a,rotation:g=0}=e,[c,I]=ai(a,[t.x,t.y]),l=i*Math.abs(a.a),B=n*Math.abs(a.a),C=r*Math.abs(a.a);A.save(),A.translate(c,I),g!==0&&A.rotate(-g*(Math.PI/180)),A.beginPath(),A.ellipse(0,0,l,B,0,0,Math.PI*2),o&&(A.fillStyle=o,A.fill()),s&&(A.strokeStyle=s,A.lineWidth=C,A.stroke()),A.restore()}function Ah(e){const{ctx:A,center:t,width:i,height:n,fill:o,realToCanvasMat:s,rotation:r=0,stroke:a,strokeWidth:g}=e,[c,I]=ai(s,[t.x,t.y]),l=i*Math.abs(s.a),B=n*Math.abs(s.a),C=g?g*Math.abs(s.a):void 0;if(A.save(),A.translate(c,I),r!==0&&A.rotate(-r*(Math.PI/180)),A.beginPath(),l>B){const Q=B/2,h=l-B;A.moveTo(-h/2,-Q),A.lineTo(h/2,-Q),A.arc(h/2,0,Q,-Math.PI/2,Math.PI/2),A.lineTo(-h/2,Q),A.arc(-h/2,0,Q,Math.PI/2,-Math.PI/2)}else if(B>l){const Q=l/2,h=B-l;A.moveTo(Q,-h/2),A.lineTo(Q,h/2),A.arc(0,h/2,Q,0,Math.PI),A.lineTo(-Q,-h/2),A.arc(0,-h/2,Q,Math.PI,0)}else A.arc(0,0,l/2,0,Math.PI*2);A.closePath(),o&&(A.fillStyle=o,A.fill()),a&&C&&(A.strokeStyle=a,A.lineWidth=C,A.stroke()),A.restore()}function mj(e){return"ccw_rotation"in e&&typeof e.ccw_rotation=="number"?e.ccw_rotation:0}function aCt(e){const{ctx:A,hole:t,realToCanvasMat:i,colorMap:n,soldermaskMargin:o=0,drawSoldermask:s=!1}=e;if(s&&t.is_covered_with_solder_mask===!0)return;const r=o<0?Math.abs(o):0;if(t.hole_shape==="circle"){tQ({ctx:A,center:{x:t.x,y:t.y},radius:t.hole_diameter/2-r,fill:n.drill,realToCanvasMat:i});return}if(t.hole_shape==="square"){const a=mj(t);AQ({ctx:A,center:{x:t.x,y:t.y},width:t.hole_diameter-r*2,height:t.hole_diameter-r*2,fill:n.drill,realToCanvasMat:i,ccwRotationDegrees:a});return}if(t.hole_shape==="oval"){const a=mj(t);sS({ctx:A,center:{x:t.x,y:t.y},radius_x:t.hole_width/2-r,radius_y:t.hole_height/2-r,fill:n.drill,realToCanvasMat:i,rotation:a});return}if(t.hole_shape==="rect"){const a=mj(t);AQ({ctx:A,center:{x:t.x,y:t.y},width:t.hole_width-r*2,height:t.hole_height-r*2,fill:n.drill,realToCanvasMat:i,ccwRotationDegrees:a});return}if(t.hole_shape==="pill"||t.hole_shape==="rotated_pill"){const a=mj(t);Ah({ctx:A,center:{x:t.x,y:t.y},width:t.hole_width-r*2,height:t.hole_height-r*2,fill:n.drill,realToCanvasMat:i,rotation:a});return}}function Wje(e,A){const t=parseInt(e.slice(1,3),16),i=parseInt(e.slice(3,5),16),n=parseInt(e.slice(5,7),16);return`rgba(${t}, ${i}, ${n}, ${A})`}function Zje(e){const{ctx:A,keepout:t,realToCanvasMat:i,colorMap:n}=e,o=n.keepout,s=Wje(n.keepout,.2),r=1;if(t.shape==="rect"){const[a,g]=ai(i,[t.center.x,t.center.y]),c=t.width*Math.abs(i.a),I=t.height*Math.abs(i.a),l=t.rotation??0;A.save(),A.translate(a,g),l!==0&&A.rotate(-l*(Math.PI/180)),A.beginPath(),A.rect(-c/2,-I/2,c,I),A.fillStyle=s,A.fill(),A.beginPath(),A.rect(-c/2,-I/2,c,I),A.clip();const B=r*Math.abs(i.a),C=Math.sqrt(c*c+I*I),Q=c/2,h=I/2;A.strokeStyle=o,A.lineWidth=.15*Math.abs(i.a),A.setLineDash([]);for(let E=-C;E<C*2;E+=B){A.beginPath();const u=-Q+E,d=-h,f=-Q+E+C,m=-h+C;A.moveTo(u,d),A.lineTo(f,m),A.stroke()}A.restore();return}if(t.shape==="circle"){const[a,g]=ai(i,[t.center.x,t.center.y]),c=t.radius*Math.abs(i.a),I=r*Math.abs(i.a);A.save(),A.translate(a,g),A.beginPath(),A.arc(0,0,c,0,Math.PI*2),A.fillStyle=s,A.fill(),A.beginPath(),A.arc(0,0,c,0,Math.PI*2),A.clip();const l=c*2;A.strokeStyle=o,A.lineWidth=.15*Math.abs(i.a),A.setLineDash([]);for(let B=-l;B<l*2;B+=I)A.beginPath(),A.moveTo(B-l,-l),A.lineTo(B+l,l),A.stroke();A.restore();return}}var Vje="rgba(255,255,255,0.5)";function jje(e){const{ctx:A,pcbNoteDimension:t,realToCanvasMat:i}=e,n=t.color??Vje;rCt({ctx:A,from:t.from,to:t.to,realToCanvasMat:i,color:n,fontSize:t.font_size,arrowSize:t.arrow_size,text:t.text,textRotation:t.text_ccw_rotation,offset:t.offset_distance&&t.offset_direction?{distance:t.offset_distance,direction:t.offset_direction}:void 0})}function zje(e){const{ctx:A,line:t,realToCanvasMat:i}=e,o=t.color??"rgb(89, 148, 220)",s=t.stroke_width??.1,r=t.is_dashed??!1,[a,g]=ai(i,[t.x1,t.y1]),[c,I]=ai(i,[t.x2,t.y2]),l=s*Math.abs(i.a);A.save(),r?A.setLineDash([l*2,l*2]):A.setLineDash([]),A.beginPath(),A.moveTo(a,g),A.lineTo(c,I),A.lineWidth=l,A.strokeStyle=o,A.lineCap="round",A.stroke(),A.restore()}function Xje(e){const{ctx:A,path:t,realToCanvasMat:i}=e,o=t.color??"rgb(89, 148, 220)";if(!(!t.route||t.route.length<2))for(let s=0;s<t.route.length-1;s++){const r=t.route[s],a=t.route[s+1];!r||!a||A1({ctx:A,start:{x:r.x,y:r.y},end:{x:a.x,y:a.y},strokeWidth:t.stroke_width??.1,stroke:o,realToCanvasMat:i})}}function $je(e){const{ctx:A,rect:t,realToCanvasMat:i}=e,o=t.color??"rgb(89, 148, 220)",s=t.is_filled??!1,r=t.has_stroke??!0,a=t.is_stroke_dashed??!1;AQ({ctx:A,center:t.center,width:t.width,height:t.height,fill:s?o:void 0,stroke:r?o:void 0,strokeWidth:r?t.stroke_width:void 0,borderRadius:t.corner_radius,realToCanvasMat:i,isStrokeDashed:a})}var Aze="rgb(89, 148, 220)";function tze(e){const{ctx:A,text:t,realToCanvasMat:i}=e,n=Aze,o=t.color??n,s=t.font_size??1;yj({ctx:A,text:t.text??"",x:t.anchor_position.x,y:t.anchor_position.y,fontSize:s,color:o,realToCanvasMat:i,anchorAlignment:t.anchor_alignment??"center"})}function eze(e){const{ctx:A,panel:t,realToCanvasMat:i,colorMap:n}=e,{width:o,height:s,center:r}=t;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}];fj({ctx:A,points:c,stroke:n.boardOutline,strokeWidth:.5,realToCanvasMat:i,closePath:!0})}}function CT(e,A){if(e.length<3||A===0)return e;let t=0,i=0;for(const o of e)t+=o.x,i+=o.y;t/=e.length,i/=e.length;const n=[];for(const o of e){const s=o.x-t,r=o.y-i,a=Math.sqrt(s*s+r*r);if(a>0){const g=s/a,c=r/a;n.push({x:o.x+g*A,y:o.y+c*A})}else n.push({x:o.x+A,y:o.y})}return n}function gCt(e){const{ctx:A,hole:t,realToCanvasMat:i,colorMap:n,soldermaskMargin:o=0,drawSoldermask:s}=e;if(t.is_covered_with_solder_mask===!0&&s)return;const r=n.copper[e.layer??"top"],a=o<0?Math.abs(o):0;if(t.shape==="circle"){tQ({ctx:A,center:{x:t.x,y:t.y},radius:t.outer_diameter/2-a,fill:r,realToCanvasMat:i}),rS(A,()=>{tQ({ctx:A,center:{x:t.x,y:t.y},radius:t.hole_diameter/2,fill:"#000",realToCanvasMat:i})}),tQ({ctx:A,center:{x:t.x,y:t.y},radius:t.hole_diameter/2,fill:n.drill,realToCanvasMat:i});return}if(t.shape==="oval"){sS({ctx:A,center:{x:t.x,y:t.y},radius_x:t.outer_width/2-a,radius_y:t.outer_height/2-a,fill:r,realToCanvasMat:i,rotation:t.ccw_rotation}),rS(A,()=>{sS({ctx:A,center:{x:t.x,y:t.y},radius_x:t.hole_width/2,radius_y:t.hole_height/2,fill:"#000",realToCanvasMat:i,rotation:t.ccw_rotation})}),sS({ctx:A,center:{x:t.x,y:t.y},radius_x:t.hole_width/2,radius_y:t.hole_height/2,fill:n.drill,realToCanvasMat:i,rotation:t.ccw_rotation});return}if(t.shape==="pill"){Ah({ctx:A,center:{x:t.x,y:t.y},width:t.outer_width-a*2,height:t.outer_height-a*2,fill:r,realToCanvasMat:i,rotation:t.ccw_rotation}),rS(A,()=>{Ah({ctx:A,center:{x:t.x,y:t.y},width:t.hole_width,height:t.hole_height,fill:"#000",realToCanvasMat:i,rotation:t.ccw_rotation})}),Ah({ctx:A,center:{x:t.x,y:t.y},width:t.hole_width,height:t.hole_height,fill:n.drill,realToCanvasMat:i,rotation:t.ccw_rotation});return}if(t.shape==="circular_hole_with_rect_pad"){AQ({ctx:A,center:{x:t.x,y:t.y},width:t.rect_pad_width-a*2,height:t.rect_pad_height-a*2,fill:r,realToCanvasMat:i,borderRadius:t.rect_border_radius?Math.max(0,t.rect_border_radius-a):0,ccwRotationDegrees:t.rect_ccw_rotation});const g=t.x+(t.hole_offset_x??0),c=t.y+(t.hole_offset_y??0);rS(A,()=>{tQ({ctx:A,center:{x:g,y:c},radius:t.hole_diameter/2,fill:"#000",realToCanvasMat:i})}),tQ({ctx:A,center:{x:g,y:c},radius:t.hole_diameter/2,fill:n.drill,realToCanvasMat:i});return}if(t.shape==="pill_hole_with_rect_pad"){AQ({ctx:A,center:{x:t.x,y:t.y},width:t.rect_pad_width-a*2,height:t.rect_pad_height-a*2,fill:r,realToCanvasMat:i,borderRadius:t.rect_border_radius?Math.max(0,t.rect_border_radius-a):0});const g=t.x+(t.hole_offset_x??0),c=t.y+(t.hole_offset_y??0);rS(A,()=>{Ah({ctx:A,center:{x:g,y:c},width:t.hole_width,height:t.hole_height,fill:"#000",realToCanvasMat:i})}),Ah({ctx:A,center:{x:g,y:c},width:t.hole_width,height:t.hole_height,fill:n.drill,realToCanvasMat:i});return}if(t.shape==="rotated_pill_hole_with_rect_pad"){AQ({ctx:A,center:{x:t.x,y:t.y},width:t.rect_pad_width-a*2,height:t.rect_pad_height-a*2,fill:r,realToCanvasMat:i,borderRadius:t.rect_border_radius?Math.max(0,t.rect_border_radius-a):0,ccwRotationDegrees:t.rect_ccw_rotation});const g=t.x+(t.hole_offset_x??0),c=t.y+(t.hole_offset_y??0);rS(A,()=>{Ah({ctx:A,center:{x:g,y:c},width:t.hole_width,height:t.hole_height,fill:"#000",realToCanvasMat:i,rotation:t.hole_ccw_rotation})}),Ah({ctx:A,center:{x:g,y:c},width:t.hole_width,height:t.hole_height,fill:n.drill,realToCanvasMat:i,rotation:t.hole_ccw_rotation});return}if(t.shape==="hole_with_polygon_pad"){const g=t.pad_outline;if(g&&g.length>=3){const B=g.map(Q=>({x:t.x+Q.x,y:t.y+Q.y})),C=a>0?CT(B,-a):B;C.length>=3&&Fk({ctx:A,points:C,fill:r,realToCanvasMat:i})}const c=t.x+(t.hole_offset_x??0),I=t.y+(t.hole_offset_y??0),l=t.hole_shape;l==="circle"?(rS(A,()=>{tQ({ctx:A,center:{x:c,y:I},radius:(t.hole_diameter??0)/2,fill:"#000",realToCanvasMat:i})}),tQ({ctx:A,center:{x:c,y:I},radius:(t.hole_diameter??0)/2,fill:n.drill,realToCanvasMat:i})):l==="oval"?(rS(A,()=>{sS({ctx:A,center:{x:c,y:I},radius_x:(t.hole_width??0)/2,radius_y:(t.hole_height??0)/2,fill:"#000",realToCanvasMat:i})}),sS({ctx:A,center:{x:c,y:I},radius_x:(t.hole_width??0)/2,radius_y:(t.hole_height??0)/2,fill:n.drill,realToCanvasMat:i})):l==="pill"?(rS(A,()=>{Ah({ctx:A,center:{x:c,y:I},width:t.hole_width??0,height:t.hole_height??0,fill:"#000",realToCanvasMat:i})}),Ah({ctx:A,center:{x:c,y:I},width:t.hole_width??0,height:t.hole_height??0,fill:n.drill,realToCanvasMat:i})):l==="rotated_pill"&&(rS(A,()=>{Ah({ctx:A,center:{x:c,y:I},width:t.hole_width??0,height:t.hole_height??0,fill:"#000",realToCanvasMat:i})}),Ah({ctx:A,center:{x:c,y:I},width:t.hole_width??0,height:t.hole_height??0,fill:n.drill,realToCanvasMat:i}));return}}function rS(e,A){e.save(),e.globalCompositeOperation="destination-out",A(),e.restore()}function ize(e,A){return e==="bottom"?A.silkscreen.bottom:A.silkscreen.top}function nze(e){const{ctx:A,circle:t,realToCanvasMat:i,colorMap:n}=e,o=ize(t.layer,n);tQ({ctx:A,center:t.center,radius:t.radius,stroke:o,strokeWidth:t.stroke_width,realToCanvasMat:i})}function oze(e,A){return e==="bottom"?A.silkscreen.bottom:A.silkscreen.top}function sze(e){const{ctx:A,line:t,realToCanvasMat:i,colorMap:n}=e,o=oze(t.layer,n);A1({ctx:A,start:{x:t.x1,y:t.y1},end:{x:t.x2,y:t.y2},strokeWidth:t.stroke_width??.1,stroke:o,realToCanvasMat:i})}function rze(e,A){return e==="bottom"?A.silkscreen.bottom:A.silkscreen.top}function aze(e){const{ctx:A,oval:t,realToCanvasMat:i,colorMap:n}=e,o=rze(t.layer,n);sS({ctx:A,center:t.center,radius_x:t.radius_x,radius_y:t.radius_y,stroke:o,strokeWidth:.1,realToCanvasMat:i,rotation:t.ccw_rotation??0})}function gze(e,A){return e==="bottom"?A.silkscreen.bottom:A.silkscreen.top}function cze(e){const{ctx:A,path:t,realToCanvasMat:i,colorMap:n}=e,o=gze(t.layer,n);if(!(!t.route||t.route.length<2))for(let s=0;s<t.route.length-1;s++){const r=t.route[s],a=t.route[s+1];!r||!a||A1({ctx:A,start:{x:r.x,y:r.y},end:{x:a.x,y:a.y},strokeWidth:t.stroke_width??.1,stroke:o,realToCanvasMat:i})}}function Ize(e,A){return e==="bottom"?A.silkscreen.bottom:A.silkscreen.top}function lze(e){const{ctx:A,pill:t,realToCanvasMat:i,colorMap:n}=e,o=Ize(t.layer,n);Ah({ctx:A,center:t.center,width:t.width,height:t.height,stroke:o,strokeWidth:.2,realToCanvasMat:i})}function Bze(e,A){return e==="bottom"?A.silkscreen.bottom:A.silkscreen.top}function Cze(e){const{ctx:A,rect:t,realToCanvasMat:i,colorMap:n}=e,o=Bze(t.layer,n);AQ({ctx:A,center:t.center,width:t.width,height:t.height,fill:t.is_filled?o:"transparent",stroke:o,strokeWidth:t.stroke_width,realToCanvasMat:i})}function Qze(e,A){return e==="bottom"?A.silkscreen.bottom:A.silkscreen.top}function hze(e){return e||"center"}function Eze(e){const{ctx:A,text:t,realToCanvasMat:i,colorMap:n}=e,o=t.text??"";if(!o)return;const s=Qze(t.layer,n),r=hze(t.anchor_alignment),a=t.font_size??1;yj({ctx:A,text:o,x:t.anchor_position.x,y:t.anchor_position.y,fontSize:a,color:s,realToCanvasMat:i,anchorAlignment:r,rotation:t.ccw_rotation??0,mirrorX:t.layer==="bottom",knockout:t.is_knockout,knockoutPadding:t.is_knockout?t.knockout_padding:void 0})}function uze(e,A){return A.copper[e]??A.copper.top}function cCt(e){return e.shape==="rect"||e.shape==="rotated_rect"?e.corner_radius??e.rect_border_radius??0:0}function dze(e){const{ctx:A,pad:t,realToCanvasMat:i,colorMap:n}=e,o=uze(t.layer,n);if(t.shape==="rect"){AQ({ctx:A,center:{x:t.x,y:t.y},width:t.width,height:t.height,fill:o,realToCanvasMat:i,borderRadius:cCt(t)});return}if(t.shape==="rotated_rect"){AQ({ctx:A,center:{x:t.x,y:t.y},width:t.width,height:t.height,fill:o,realToCanvasMat:i,borderRadius:cCt(t),ccwRotationDegrees:t.ccw_rotation??0});return}if(t.shape==="circle"){tQ({ctx:A,center:{x:t.x,y:t.y},radius:t.radius,fill:o,realToCanvasMat:i});return}if(t.shape==="pill"){Ah({ctx:A,center:{x:t.x,y:t.y},width:t.width,height:t.height,fill:o,realToCanvasMat:i});return}if(t.shape==="rotated_pill"){Ah({ctx:A,center:{x:t.x,y:t.y},width:t.width,height:t.height,fill:o,realToCanvasMat:i,rotation:t.ccw_rotation??0});return}if(t.shape==="polygon"){t.points&&t.points.length>=3&&Fk({ctx:A,points:t.points,fill:o,realToCanvasMat:i});return}}function Mk(e){const{ctx:A,points:t}=e;if(t.length<3)return;const i=t[0];if(i){A.moveTo(i.x,i.y);for(let n=1;n<t.length;n++){const o=t[n];o&&A.lineTo(o.x,o.y)}A.closePath()}}function ICt(e){const{ctx:A,board:t,realToCanvasMat:i,soldermaskColor:n}=e,{width:o,height:s,center:r,outline:a}=t;if(a&&Array.isArray(a)&&a.length>=3){const g=a.map(c=>{const[I,l]=ai(i,[c.x,c.y]);return{x:I,y:l}});A.beginPath(),Mk({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 pze(e){return"createPattern"in e&&typeof Reflect.get(e,"createPattern")=="function"}function fze(e,A){if(e===A||A.canvas.width<=0||A.canvas.height<=0||!pze(e))return;let t=null;try{t=e.createPattern(A.canvas,"no-repeat")}catch{return}t&&(e.save(),e.globalCompositeOperation="source-over",e.fillStyle=t,e.fillRect(0,0,A.canvas.width,A.canvas.height),e.restore())}function yze(e){return typeof e=="function"}function mze(e,A,t){if(A<=0||t<=0)return null;const i=globalThis;let n=null;if("OffscreenCanvas"in i&&typeof i.OffscreenCanvas=="function")n=new i.OffscreenCanvas(A,t);else if("document"in i&&i.document&&typeof i.document.createElement=="function"){const o=i.document.createElement("canvas");o.width=A,o.height=t,n=o}else{const o=e.canvas.constructor;if(yze(o))try{n=new o(A,t)}catch{return null}}return n?n.getContext("2d"):null}function wze(e){const{ctx:A,panel:t,realToCanvasMat:i,soldermaskColor:n}=e,{width:o,height:s,center:r}=t;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 z0(e){const{ctx:A,cx:t,cy:i,width:n,height:o,radius:s,ccwRotationDegrees:r=0}=e,a=r*Math.PI/180,g=T0A(vk(t,i),tCt(-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 X0(e){e.save(),e.globalCompositeOperation="destination-out",e.fill(),e.restore()}function Dze(e){const{ctx:A,cutout:t,realToCanvasMat:i}=e;if(t.shape==="rect"){const[n,o]=ai(i,[t.center?.x??0,t.center?.y??0]),s=t.width*Math.abs(i.a),r=t.height*Math.abs(i.a),a=(t.corner_radius??0)*Math.abs(i.a);A.save(),A.translate(n,o),t.rotation&&A.rotate(-t.rotation*Math.PI/180),A.beginPath(),z0({ctx:A,cx:0,cy:0,width:s,height:r,radius:a}),A.restore(),X0(A)}else if(t.shape==="circle"){const[n,o]=ai(i,[t.center?.x??0,t.center?.y??0]),s=t.radius*Math.abs(i.a);A.beginPath(),A.arc(n,o,s,0,Math.PI*2),A.closePath(),X0(A)}else if(t.shape==="polygon"&&t.points&&t.points.length>=3){const n=t.points.map(o=>{const[s,r]=ai(i,[o.x,o.y]);return{x:s,y:r}});A.beginPath(),Mk({ctx:A,points:n}),X0(A)}}var zh="rgba(255, 255, 255, 1)";function O0A(e){const{ctx:A,elements:t,layer:i,realToCanvasMat:n}=e;A.save(),A.globalCompositeOperation="destination-out";for(const o of t){if(o.type==="pcb_smtpad"){if(o.layer!==i||o.is_covered_with_solder_mask===!0)continue;Sze({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;bze({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:zh,realToCanvasMat:n});continue}if(o.type==="pcb_hole"){if(o.is_covered_with_solder_mask===!0)continue;xze({ctx:A,hole:o,realToCanvasMat:n})}}A.restore()}function Sze(e){const{ctx:A,pad:t,realToCanvasMat:i}=e;if(t.shape==="rect"){AQ({ctx:A,center:{x:t.x,y:t.y},width:t.width,height:t.height,borderRadius:t.corner_radius??t.rect_border_radius??0,fill:zh,realToCanvasMat:i});return}if(t.shape==="rotated_rect"){AQ({ctx:A,center:{x:t.x,y:t.y},width:t.width,height:t.height,borderRadius:t.corner_radius??t.rect_border_radius??0,ccwRotationDegrees:t.ccw_rotation??0,fill:zh,realToCanvasMat:i});return}if(t.shape==="circle"){tQ({ctx:A,center:{x:t.x,y:t.y},radius:t.radius,fill:zh,realToCanvasMat:i});return}if(t.shape==="pill"||t.shape==="rotated_pill"){Ah({ctx:A,center:{x:t.x,y:t.y},width:t.width,height:t.height,rotation:t.shape==="rotated_pill"?t.ccw_rotation??0:0,fill:zh,realToCanvasMat:i});return}t.shape==="polygon"&&t.points&&t.points.length>=3&&Fk({ctx:A,points:t.points,fill:zh,realToCanvasMat:i})}function bze(e){const{ctx:A,hole:t,realToCanvasMat:i}=e;if(t.shape==="circle"){tQ({ctx:A,center:{x:t.x,y:t.y},radius:t.outer_diameter/2,fill:zh,realToCanvasMat:i});return}if(t.shape==="oval"){sS({ctx:A,center:{x:t.x,y:t.y},radius_x:t.outer_width/2,radius_y:t.outer_height/2,rotation:t.ccw_rotation,fill:zh,realToCanvasMat:i});return}if(t.shape==="pill"){Ah({ctx:A,center:{x:t.x,y:t.y},width:t.outer_width,height:t.outer_height,rotation:t.ccw_rotation,fill:zh,realToCanvasMat:i});return}if(t.shape==="circular_hole_with_rect_pad"){AQ({ctx:A,center:{x:t.x,y:t.y},width:t.rect_pad_width,height:t.rect_pad_height,borderRadius:t.rect_border_radius??0,ccwRotationDegrees:t.rect_ccw_rotation,fill:zh,realToCanvasMat:i});return}if(t.shape==="pill_hole_with_rect_pad"){AQ({ctx:A,center:{x:t.x,y:t.y},width:t.rect_pad_width,height:t.rect_pad_height,borderRadius:t.rect_border_radius??0,fill:zh,realToCanvasMat:i});return}if(t.shape==="rotated_pill_hole_with_rect_pad"){AQ({ctx:A,center:{x:t.x,y:t.y},width:t.rect_pad_width,height:t.rect_pad_height,borderRadius:t.rect_border_radius??0,ccwRotationDegrees:t.rect_ccw_rotation,fill:zh,realToCanvasMat:i});return}t.shape==="hole_with_polygon_pad"&&t.pad_outline&&t.pad_outline.length>=3&&Fk({ctx:A,points:t.pad_outline.map(n=>({x:t.x+n.x,y:t.y+n.y})),fill:zh,realToCanvasMat:i})}function xze(e){const{ctx:A,hole:t,realToCanvasMat:i}=e,n="ccw_rotation"in t&&typeof t.ccw_rotation=="number"?t.ccw_rotation:0;if(t.hole_shape==="circle"){tQ({ctx:A,center:{x:t.x,y:t.y},radius:t.hole_diameter/2,fill:zh,realToCanvasMat:i});return}if(t.hole_shape==="square"){AQ({ctx:A,center:{x:t.x,y:t.y},width:t.hole_diameter,height:t.hole_diameter,ccwRotationDegrees:n,fill:zh,realToCanvasMat:i});return}if(t.hole_shape==="oval"){sS({ctx:A,center:{x:t.x,y:t.y},radius_x:t.hole_width/2,radius_y:t.hole_height/2,rotation:n,fill:zh,realToCanvasMat:i});return}if(t.hole_shape==="rect"){AQ({ctx:A,center:{x:t.x,y:t.y},width:t.hole_width,height:t.hole_height,ccwRotationDegrees:n,fill:zh,realToCanvasMat:i});return}(t.hole_shape==="pill"||t.hole_shape==="rotated_pill")&&Ah({ctx:A,center:{x:t.x,y:t.y},width:t.hole_width,height:t.hole_height,rotation:n,fill:zh,realToCanvasMat:i})}function _ze(e,A,t,i,n){if(Math.abs(n)<1e-10)return null;const o=t-e,s=i-A,r=Math.hypot(o,s);if(r<1e-10)return null;const a=Math.abs(n)*(r/2),g=r/2,c=(a*a+g*g)/(2*a),I=c-a,l=(e+t)/2,B=(A+i)/2,C=-s/r,Q=o/r,h=n>0?-1:1;return{centerX:l+h*C*I,centerY:B+h*Q*I,radius:c}}function W0A(e,A,t,i,n,o,s){if(Math.abs(o)<1e-10){const[f,m]=ai(s,[i,n]);e.lineTo(f,m);return}const r=_ze(A,t,i,n,o);if(!r){const[f,m]=ai(s,[i,n]);e.lineTo(f,m);return}const[a,g]=ai(s,[A,t]),[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;e.arc(l,B,C,Q,h,d)}function lCt(e,A,t){if(A.vertices.length<2)return;if(A.vertices.length===2){const s=A.vertices[0],r=A.vertices[1];if(s&&r&&Math.abs((s.bulge??0)-1)<1e-10&&Math.abs((r.bulge??0)-1)<1e-10){const[a,g]=ai(t,[s.x,s.y]);e.moveTo(a,g),W0A(e,s.x,s.y,r.x,r.y,1,t),W0A(e,r.x,r.y,s.x,s.y,1,t);return}}const i=A.vertices[0];if(!i)return;const[n,o]=ai(t,[i.x,i.y]);e.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(t,[a.x,a.y]);e.lineTo(c,I)}else W0A(e,r.x,r.y,a.x,a.y,g,t)}}function kze(e){const{ctx:A,pour:t,realToCanvasMat:i,soldermaskOverCopperColor:n,layer:o,elements:s}=e;if(t.layer===o&&t.covered_with_solder_mask===!0){if(A.save(),A.fillStyle=n,t.shape==="rect"){const[r,a]=ai(i,[t.center.x,t.center.y]),g=t.width*Math.abs(i.a),c=t.height*Math.abs(i.a);A.translate(r,a),t.rotation&&A.rotate(-t.rotation*(Math.PI/180)),A.beginPath(),A.rect(-g/2,-c/2,g,c),A.fill(),A.restore(),O0A({ctx:A,elements:s,layer:o,realToCanvasMat:i});return}if(t.shape==="polygon"){if(t.points&&t.points.length>=3){const r=t.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(),O0A({ctx:A,elements:s,layer:o,realToCanvasMat:i})}}A.restore();return}if(t.shape==="brep"){if(A.beginPath(),lCt(A,t.brep_shape.outer_ring,i),t.brep_shape.inner_rings)for(const r of t.brep_shape.inner_rings)lCt(A,r,i);A.fill("evenodd"),O0A({ctx:A,elements:s,layer:o,realToCanvasMat:i}),A.restore();return}A.restore()}}function Zb(e){const{ctx:A,cx:t,cy:i,width:n,height:o,ccwRotationDegrees:s=0}=e,r=s*Math.PI/180,a=T0A(vk(t,i),tCt(-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(t+g,i),A.arc(t,i,g,0,Math.PI*2)}A.closePath()}function vze(e){const{ctx:A,hole:t,realToCanvasMat:i,soldermaskOverCopperColor:n}=e,o=t.is_covered_with_solder_mask===!0,s=t.soldermask_margin??0;o?(A.fillStyle=n,wj({ctx:A,hole:t,realToCanvasMat:i,margin:0}),A.fill()):s<0?(wj({ctx:A,hole:t,realToCanvasMat:i,margin:s}),X0(A),Fze({ctx:A,hole:t,realToCanvasMat:i,soldermaskOverCopperColor:n,margin:s})):s>0?(wj({ctx:A,hole:t,realToCanvasMat:i,margin:s}),X0(A)):(wj({ctx:A,hole:t,realToCanvasMat:i,margin:0}),X0(A))}function BCt(e){return"ccw_rotation"in e&&typeof e.ccw_rotation=="number"?e.ccw_rotation:0}function wj(e){const{ctx:A,hole:t,realToCanvasMat:i,margin:n}=e,o=BCt(t);if(t.hole_shape==="circle"){const[s,r]=ai(i,[t.x,t.y]),a=(t.hole_diameter/2+n)*Math.abs(i.a);A.beginPath(),A.arc(s,r,a,0,Math.PI*2),A.closePath()}else if(t.hole_shape==="square"){const[s,r]=ai(i,[t.x,t.y]),a=(t.hole_diameter+n*2)*Math.abs(i.a);A.save(),A.translate(s,r),o!==0&&A.rotate(-o*Math.PI/180),A.beginPath(),A.rect(-a/2,-a/2,a,a),A.closePath(),A.restore()}else if(t.hole_shape==="oval"){const[s,r]=ai(i,[t.x,t.y]),a=(t.hole_width/2+n)*Math.abs(i.a),g=(t.hole_height/2+n)*Math.abs(i.a);A.save(),A.translate(s,r),o!==0&&A.rotate(-o*Math.PI/180),A.beginPath(),A.ellipse(0,0,a,g,0,0,Math.PI*2),A.closePath(),A.restore()}else if(t.hole_shape==="rect"){const[s,r]=ai(i,[t.x,t.y]),a=(t.hole_width+n*2)*Math.abs(i.a),g=(t.hole_height+n*2)*Math.abs(i.a);A.save(),A.translate(s,r),o!==0&&A.rotate(-o*Math.PI/180),A.beginPath(),A.rect(-a/2,-g/2,a,g),A.closePath(),A.restore()}else if(t.hole_shape==="pill"||t.hole_shape==="rotated_pill"){const[s,r]=ai(i,[t.x,t.y]),a=(t.hole_width+n*2)*Math.abs(i.a),g=(t.hole_height+n*2)*Math.abs(i.a);A.save(),A.translate(s,r),o!==0&&A.rotate(-o*Math.PI/180),A.beginPath(),Zb({ctx:A,cx:0,cy:0,width:a,height:g}),A.restore()}}function Fze(e){const{ctx:A,hole:t,realToCanvasMat:i,soldermaskOverCopperColor:n,margin:o}=e,s=Math.abs(o),r=BCt(t);if(A.fillStyle=n,t.hole_shape==="circle"){const[a,g]=ai(i,[t.x,t.y]),c=t.hole_diameter/2*Math.abs(i.a),I=s*Math.abs(i.a),l=Math.max(0,c-I);A.save(),A.beginPath(),A.arc(a,g,c,0,Math.PI*2),l>0&&A.arc(a,g,l,0,Math.PI*2,!0),A.fill("evenodd"),A.restore()}else if(t.hole_shape==="square"){const[a,g]=ai(i,[t.x,t.y]),c=t.hole_diameter*Math.abs(i.a),I=s*Math.abs(i.a),l=Math.max(0,c-I*2);A.save(),A.translate(a,g),r!==0&&A.rotate(-r*Math.PI/180),A.beginPath(),A.rect(-c/2,-c/2,c,c),l>0&&A.rect(-l/2,-l/2,l,l),A.fill("evenodd"),A.restore()}else if(t.hole_shape==="oval"){const[a,g]=ai(i,[t.x,t.y]),c=t.hole_width/2*Math.abs(i.a),I=t.hole_height/2*Math.abs(i.a),l=s*Math.abs(i.a),B=Math.max(0,c-l),C=Math.max(0,I-l);A.save(),A.translate(a,g),r!==0&&A.rotate(-r*Math.PI/180),A.beginPath(),A.ellipse(0,0,c,I,0,0,Math.PI*2),B>0&&C>0&&(A.moveTo(B,0),A.ellipse(0,0,B,C,0,0,Math.PI*2)),A.fill("evenodd"),A.restore()}else if(t.hole_shape==="rect"){const[a,g]=ai(i,[t.x,t.y]),c=t.hole_width*Math.abs(i.a),I=t.hole_height*Math.abs(i.a),l=s*Math.abs(i.a),B=Math.max(0,c-l*2),C=Math.max(0,I-l*2);A.save(),A.translate(a,g),r!==0&&A.rotate(-r*Math.PI/180),A.beginPath(),A.rect(-c/2,-I/2,c,I),B>0&&C>0&&A.rect(-B/2,-C/2,B,C),A.fill("evenodd"),A.restore()}else if(t.hole_shape==="pill"||t.hole_shape==="rotated_pill"){const[a,g]=ai(i,[t.x,t.y]),c=t.hole_width*Math.abs(i.a),I=t.hole_height*Math.abs(i.a),l=s*Math.abs(i.a);A.save(),A.translate(a,g),r!==0&&A.rotate(-r*Math.PI/180),A.beginPath(),Zb({ctx:A,cx:0,cy:0,width:c,height:I});const B=c-l*2,C=I-l*2;B>0&&C>0&&Zb({ctx:A,cx:0,cy:0,width:B,height:C}),A.fill("evenodd"),A.restore()}}function Mze(e){const{ctx:A,hole:t,realToCanvasMat:i,soldermaskOverCopperColor:n,layer:o}=e;if(t.layers&&!t.layers.includes(o))return;const s=t.is_covered_with_solder_mask===!0,r=t.soldermask_margin??0;s?(A.fillStyle=n,Dj({ctx:A,hole:t,realToCanvasMat:i,margin:0}),A.fill()):r<0?(Dj({ctx:A,hole:t,realToCanvasMat:i,margin:r}),X0(A),Gze({ctx:A,hole:t,realToCanvasMat:i,soldermaskOverCopperColor:n,margin:r})):r>0?(Dj({ctx:A,hole:t,realToCanvasMat:i,margin:r}),X0(A)):(Dj({ctx:A,hole:t,realToCanvasMat:i,margin:0}),X0(A))}function Dj(e){const{ctx:A,hole:t,realToCanvasMat:i,margin:n}=e;if(t.shape==="circle"){const[o,s]=ai(i,[t.x,t.y]),r=(t.outer_diameter/2+n)*Math.abs(i.a);A.beginPath(),A.arc(o,s,r,0,Math.PI*2),A.closePath()}else if(t.shape==="oval"){const[o,s]=ai(i,[t.x,t.y]),r=(t.outer_width/2+n)*Math.abs(i.a),a=(t.outer_height/2+n)*Math.abs(i.a);A.beginPath(),A.ellipse(o,s,r,a,-((t.ccw_rotation??0)*Math.PI)/180,0,Math.PI*2),A.closePath()}else if(t.shape==="pill"){const[o,s]=ai(i,[t.x,t.y]),r=(t.outer_width+n*2)*Math.abs(i.a),a=(t.outer_height+n*2)*Math.abs(i.a);A.beginPath(),Zb({ctx:A,cx:o,cy:s,width:r,height:a,ccwRotationDegrees:t.ccw_rotation})}else if(t.shape==="circular_hole_with_rect_pad"){const[o,s]=ai(i,[t.x,t.y]),r=(t.rect_pad_width+n*2)*Math.abs(i.a),a=(t.rect_pad_height+n*2)*Math.abs(i.a),g=(t.rect_border_radius??0)*Math.abs(i.a);A.beginPath(),z0({ctx:A,cx:o,cy:s,width:r,height:a,radius:g,ccwRotationDegrees:t.rect_ccw_rotation})}else if(t.shape==="pill_hole_with_rect_pad"){const[o,s]=ai(i,[t.x,t.y]),r=(t.rect_pad_width+n*2)*Math.abs(i.a),a=(t.rect_pad_height+n*2)*Math.abs(i.a),g=(t.rect_border_radius??0)*Math.abs(i.a);A.beginPath(),z0({ctx:A,cx:o,cy:s,width:r,height:a,radius:g})}else if(t.shape==="rotated_pill_hole_with_rect_pad"){const[o,s]=ai(i,[t.x,t.y]),r=(t.rect_pad_width+n*2)*Math.abs(i.a),a=(t.rect_pad_height+n*2)*Math.abs(i.a),g=(t.rect_border_radius??0)*Math.abs(i.a);A.beginPath(),z0({ctx:A,cx:o,cy:s,width:r,height:a,radius:g,ccwRotationDegrees:t.rect_ccw_rotation})}else if(t.shape==="hole_with_polygon_pad"&&t.pad_outline&&t.pad_outline.length>=3){const o=t.pad_outline.map(a=>({x:t.x+a.x,y:t.y+a.y})),r=(n!==0?CT(o,n):o).map(a=>{const[g,c]=ai(i,[a.x,a.y]);return{x:g,y:c}});A.beginPath(),Mk({ctx:A,points:r})}}function Gze(e){const{ctx:A,hole:t,realToCanvasMat:i,soldermaskOverCopperColor:n,margin:o}=e,s=Math.abs(o);if(A.fillStyle=n,t.shape==="circle"){const[r,a]=ai(i,[t.x,t.y]),g=t.outer_diameter/2*Math.abs(i.a),c=s*Math.abs(i.a),I=Math.max(0,g-c);A.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(t.shape==="oval"){const[r,a]=ai(i,[t.x,t.y]),g=t.outer_width/2*Math.abs(i.a),c=t.outer_height/2*Math.abs(i.a),I=s*Math.abs(i.a),l=Math.max(0,g-I),B=Math.max(0,c-I),C=-((t.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(t.shape==="pill"){const[r,a]=ai(i,[t.x,t.y]),g=t.outer_width*Math.abs(i.a),c=t.outer_height*Math.abs(i.a),I=s*Math.abs(i.a);A.beginPath(),Zb({ctx:A,cx:r,cy:a,width:g,height:c,ccwRotationDegrees:t.ccw_rotation});const l=g-I*2,B=c-I*2;l>0&&B>0&&Zb({ctx:A,cx:r,cy:a,width:l,height:B,ccwRotationDegrees:t.ccw_rotation}),A.fill("evenodd")}else if(t.shape==="circular_hole_with_rect_pad"){const[r,a]=ai(i,[t.x,t.y]),g=t.rect_pad_width*Math.abs(i.a),c=t.rect_pad_height*Math.abs(i.a),I=s*Math.abs(i.a),l=t.rect_border_radius?t.rect_border_radius*Math.abs(i.a):0;A.beginPath(),z0({ctx:A,cx:r,cy:a,width:g,height:c,radius:l,ccwRotationDegrees:t.rect_ccw_rotation});const B=g-I*2,C=c-I*2;if(B>0&&C>0){const Q=Math.max(0,l-I);z0({ctx:A,cx:r,cy:a,width:B,height:C,radius:Q,ccwRotationDegrees:t.rect_ccw_rotation})}A.fill("evenodd")}else if(t.shape==="pill_hole_with_rect_pad"){const[r,a]=ai(i,[t.x,t.y]),g=t.rect_pad_width*Math.abs(i.a),c=t.rect_pad_height*Math.abs(i.a),I=s*Math.abs(i.a),l=t.rect_border_radius?t.rect_border_radius*Math.abs(i.a):0;A.beginPath(),z0({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);z0({ctx:A,cx:r,cy:a,width:B,height:C,radius:Q})}A.fill("evenodd")}else if(t.shape==="rotated_pill_hole_with_rect_pad"){const[r,a]=ai(i,[t.x,t.y]),g=t.rect_pad_width*Math.abs(i.a),c=t.rect_pad_height*Math.abs(i.a),I=s*Math.abs(i.a),l=t.rect_border_radius?t.rect_border_radius*Math.abs(i.a):0;A.beginPath(),z0({ctx:A,cx:r,cy:a,width:g,height:c,radius:l,ccwRotationDegrees:t.rect_ccw_rotation});const B=g-I*2,C=c-I*2;if(B>0&&C>0){const Q=Math.max(0,l-I);z0({ctx:A,cx:r,cy:a,width:B,height:C,radius:Q,ccwRotationDegrees:t.rect_ccw_rotation})}A.fill("evenodd")}else if(t.shape==="hole_with_polygon_pad"&&t.pad_outline&&t.pad_outline.length>=3){const r=t.pad_outline.map(c=>({x:t.x+c.x,y:t.y+c.y}));A.beginPath();const a=r.map(c=>{const[I,l]=ai(i,[c.x,c.y]);return{x:I,y:l}});Mk({ctx:A,points:a});const g=CT(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}});Mk({ctx:A,points:c})}A.fill("evenodd")}}function Rze(e){const{ctx:A,pad:t,realToCanvasMat:i,soldermaskOverCopperColor:n,layer:o}=e;if(t.layer!==o)return;const s=t.is_covered_with_solder_mask===!0,r=t.soldermask_margin??0;let a=r,g=r,c=r,I=r;(t.shape==="rect"||t.shape==="rotated_rect")&&(a=t.soldermask_margin_left??r,g=t.soldermask_margin_right??r,c=t.soldermask_margin_top??r,I=t.soldermask_margin_bottom??r),s?(A.fillStyle=n,Sj({ctx:A,pad:t,realToCanvasMat:i,ml:0,mr:0,mt:0,mb:0}),A.fill()):a<0||g<0||c<0||I<0?(Sj({ctx:A,pad:t,realToCanvasMat:i,ml:a,mr:g,mt:c,mb:I}),X0(A),Nze({ctx:A,pad:t,realToCanvasMat:i,soldermaskOverCopperColor:n,ml:a,mr:g,mt:c,mb:I})):a>0||g>0||c>0||I>0?(Sj({ctx:A,pad:t,realToCanvasMat:i,ml:a,mr:g,mt:c,mb:I}),X0(A)):(Sj({ctx:A,pad:t,realToCanvasMat:i,ml:0,mr:0,mt:0,mb:0}),X0(A))}function Sj(e){const{ctx:A,pad:t,realToCanvasMat:i,ml:n,mr:o,mt:s,mb:r}=e,a=t.shape==="rotated_rect"||t.shape==="rotated_pill"?t.ccw_rotation??0:0;if(t.shape==="rect"||t.shape==="rotated_rect"){const g=t.corner_radius??t.rect_border_radius??0,c=a*Math.PI/180,I=(o-n)/2,l=(s-r)/2,B=I*Math.cos(c)-l*Math.sin(c),C=I*Math.sin(c)+l*Math.cos(c),[Q,h]=ai(i,[t.x+B,t.y+C]),E=(t.width+n+o)*Math.abs(i.a),u=(t.height+s+r)*Math.abs(i.a),d=g*Math.abs(i.a);A.save(),A.translate(Q,h),a!==0&&A.rotate(-a*Math.PI/180),A.beginPath(),z0({ctx:A,cx:0,cy:0,width:E,height:u,radius:d}),A.restore()}else if(t.shape==="circle"){const g=(n+o+s+r)/4,[c,I]=ai(i,[t.x,t.y]),l=(t.radius+g)*Math.abs(i.a);A.beginPath(),A.arc(c,I,l,0,Math.PI*2),A.closePath()}else if(t.shape==="pill"||t.shape==="rotated_pill"){const g=(n+o)/2,[c,I]=ai(i,[t.x,t.y]),l=(t.width+g*2)*Math.abs(i.a),B=(t.height+g*2)*Math.abs(i.a);A.save(),A.translate(c,I),a!==0&&A.rotate(-a*Math.PI/180),A.beginPath(),Zb({ctx:A,cx:0,cy:0,width:l,height:B}),A.restore()}else if(t.shape==="polygon"&&t.points&&t.points.length>=3){const g=(n+o+s+r)/4,I=(g!==0?CT(t.points,g):t.points).map(l=>{const[B,C]=ai(i,[l.x,l.y]);return{x:B,y:C}});A.beginPath(),Mk({ctx:A,points:I})}}function Nze(e){const{ctx:A,pad:t,realToCanvasMat:i,soldermaskOverCopperColor:n,ml:o,mr:s,mt:r,mb:a}=e,g=t.shape==="rotated_rect"||t.shape==="rotated_pill"?t.ccw_rotation??0:0,c=Math.max(0,-o),I=Math.max(0,-s),l=Math.max(0,-r),B=Math.max(0,-a);if(A.fillStyle=n,t.shape==="rect"||t.shape==="rotated_rect"){const C=t.corner_radius??t.rect_border_radius??0,[Q,h]=ai(i,[t.x,t.y]),E=t.width*Math.abs(i.a),u=t.height*Math.abs(i.a),d=C*Math.abs(i.a),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(),z0({ctx:A,cx:0,cy:0,width:E,height:u,radius:d});const S=E-f-m,_=u-w-D,b=(f-m)/2,R=(w-D)/2,F=Math.max(0,d-(f+m+w+D)/4);S>0&&_>0&&z0({ctx:A,cx:b,cy:R,width:S,height:_,radius:F}),A.fill("evenodd"),A.restore()}else if(t.shape==="circle"){const C=Math.max(c,I,l,B),[Q,h]=ai(i,[t.x,t.y]),E=t.radius*Math.abs(i.a),u=C*Math.abs(i.a),d=Math.max(0,E-u);A.save(),A.beginPath(),A.arc(Q,h,E,0,Math.PI*2),d>0&&A.arc(Q,h,d,0,Math.PI*2,!0),A.fill("evenodd"),A.restore()}else if(t.shape==="pill"||t.shape==="rotated_pill"){const C=Math.max(c,I,l,B),[Q,h]=ai(i,[t.x,t.y]),E=t.width*Math.abs(i.a),u=t.height*Math.abs(i.a),d=C*Math.abs(i.a);A.save(),A.translate(Q,h),g!==0&&A.rotate(-g*Math.PI/180),A.beginPath(),Zb({ctx:A,cx:0,cy:0,width:E,height:u});const f=E-d*2,m=u-d*2;f>0&&m>0&&Zb({ctx:A,cx:0,cy:0,width:f,height:m}),A.fill("evenodd"),A.restore()}else if(t.shape==="polygon"&&t.points&&t.points.length>=3){const C=Math.max(c,I,l,B);A.save(),A.beginPath();const Q=t.points.map(E=>{const[u,d]=ai(i,[E.x,E.y]);return{x:u,y:d}});Mk({ctx:A,points:Q});const h=CT(t.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}});Mk({ctx:A,points:E})}A.fill("evenodd"),A.restore()}}function t1(e,A){const t=Math.hypot(e,A);return t<=Number.EPSILON?{x:0,y:0}:{x:e/t,y:A/t}}function Lze(e,A){const t=e.length;if(t<2)return{x:1,y:0};if(A<=0){const g=e[1],c=e[0];if(!g||!c)return{x:1,y:0};const I=t1(g.x-c.x,g.y-c.y);return I.x===0&&I.y===0?{x:1,y:0}:I}if(A>=t-1){const g=e[t-2],c=e[t-1];if(!g||!c)return{x:1,y:0};const I=t1(c.x-g.x,c.y-g.y);return I.x===0&&I.y===0?{x:1,y:0}:I}const i=e[A-1],n=e[A],o=e[A+1];if(!i||!n||!o)return{x:1,y:0};const s=t1(n.x-i.x,n.y-i.y),r=t1(o.x-n.x,o.y-n.y),a=t1(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 CCt(e){const A=[],t=[];for(let i=0;i<e.length;i++){const n=e[i];if(!n)continue;const o=Lze(e,i),s=t1(-o.y,o.x),r=n.width/2;A.push({x:n.x+s.x*r,y:n.y+s.y*r}),t.push({x:n.x-s.x*r,y:n.y-s.y*r})}return A.concat(t.reverse())}function Z0A(e){const A=[];let t=[],i=null;for(const n of e??[]){if(!n||n.route_type!=="wire"){t.length>=2&&A.push(t),t=[],i=null;continue}const o=n.layer??i;if(!o)continue;const s=n.x,r=n.y;if(typeof s!="number"||typeof r!="number"||typeof n.width!="number")continue;const a=n.width;i&&o!==i&&(t.length>=2&&A.push(t),t=[]),i=o,t.push({route_type:"wire",x:s,y:r,width:a,layer:o,start_pcb_port_id:"start_pcb_port_id"in n?n.start_pcb_port_id:void 0,end_pcb_port_id:"end_pcb_port_id"in n?n.end_pcb_port_id:void 0})}return t.length>=2&&A.push(t),A}var QCt=1e-6;function hCt(e){const{ctx:A,trace:t,realToCanvasMat:i,vias:n,platedHoles:o,layer:s}=e;if(!t.route||t.route.length<2)return;const r=Z0A(t.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)||!ECt(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(uCt(C),C)}for(const l of o){if(l.layers&&Array.isArray(l.layers)&&!l.layers.includes(c))continue;const B=Uze(l);B&&ECt(I.x,I.y,B.x,B.y)&&a.set(uCt(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"){sS({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}Ah({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 Uze(e){if(e.shape==="circle"){const n=e.hole_diameter/2;return n<=0?void 0:{shape:"circle",x:e.x,y:e.y,radius:n}}if(e.shape==="oval"){const n=e.hole_width/2,o=e.hole_height/2;return n<=0||o<=0?void 0:{shape:"oval",x:e.x,y:e.y,radiusX:n,radiusY:o,rotation:e.ccw_rotation}}if(e.shape==="pill")return e.hole_width<=0||e.hole_height<=0?void 0:{shape:"pill",x:e.x,y:e.y,width:e.hole_width,height:e.hole_height,rotation:e.ccw_rotation};if(e.shape==="circular_hole_with_rect_pad"){const n=e.hole_diameter/2;return n<=0?void 0:{shape:"circle",x:e.x+(e.hole_offset_x??0),y:e.y+(e.hole_offset_y??0),radius:n}}if(e.shape==="pill_hole_with_rect_pad")return e.hole_width<=0||e.hole_height<=0?void 0:{shape:"pill",x:e.x+(e.hole_offset_x??0),y:e.y+(e.hole_offset_y??0),width:e.hole_width,height:e.hole_height};if(e.shape==="rotated_pill_hole_with_rect_pad")return e.hole_width<=0||e.hole_height<=0?void 0:{shape:"pill",x:e.x+(e.hole_offset_x??0),y:e.y+(e.hole_offset_y??0),width:e.hole_width,height:e.hole_height,rotation:e.hole_ccw_rotation};if(e.shape!=="hole_with_polygon_pad")return;const A=e.x+(e.hole_offset_x??0),t=e.y+(e.hole_offset_y??0),i=e.hole_shape;if(i==="circle"){const n=(e.hole_diameter??0)/2;return n<=0?void 0:{shape:"circle",x:A,y:t,radius:n}}if(i==="oval"){const n=(e.hole_width??0)/2,o=(e.hole_height??0)/2;return n<=0||o<=0?void 0:{shape:"oval",x:A,y:t,radiusX:n,radiusY:o}}if(i==="pill"||i==="rotated_pill"){const n=e.hole_width??0,o=e.hole_height??0;return n<=0||o<=0?void 0:{shape:"pill",x:A,y:t,width:n,height:o,rotation:i==="rotated_pill"?e.ccw_rotation:0}}}function ECt(e,A,t,i){return Math.abs(e-t)<=QCt&&Math.abs(A-i)<=QCt}function uCt(e){return e.shape==="circle"?`circle:${e.x}:${e.y}:${e.radius}`:e.shape==="oval"?`oval:${e.x}:${e.y}:${e.radiusX}:${e.radiusY}:${e.rotation??0}`:`pill:${e.x}:${e.y}:${e.width}:${e.height}:${e.rotation??0}`}function dCt(e){if(e.length<2)return!1;const A=e[0]?.width;return typeof A!="number"?!1:e.some(t=>Math.abs(t.width-A)>Number.EPSILON)}function Hze(e){const{ctx:A,trace:t,realToCanvasMat:i,soldermaskOverCopperColor:n,layer:o}=e;if(!t.route||!Array.isArray(t.route)||t.route.length<2)return;const s=Z0A(t.route);for(const r of s)if(r[0]?.layer===o){if(dCt(r)){const g=CCt(r);Fk({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||A1({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"})}}hCt({ctx:A,trace:t,realToCanvasMat:i,layer:o,vias:e.vias,platedHoles:e.platedHoles})}function Yze(e){const{ctx:A,via:t,realToCanvasMat:i}=e,[n,o]=ai(i,[t.x,t.y]),s=t.outer_diameter/2*Math.abs(i.a);A.beginPath(),A.arc(n,o,s,0,Math.PI*2),A.closePath(),X0(A)}function pCt(e){const{ctx:A,elements:t,realToCanvasMat:i,colorMap:n,layer:o,drawSoldermask:s}=e;if(!s||A.canvas.width<=0||A.canvas.height<=0)return;const r=t.filter(C=>C.type==="pcb_board"),a=t.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=t.filter(C=>C.type==="pcb_via"),l=t.filter(C=>C.type==="pcb_plated_hole"),B=mze(A,A.canvas.width,A.canvas.height)??A;if(a&&wze({ctx:B,panel:a,realToCanvasMat:i,soldermaskColor:g}),a&&r.length>0){B.save(),B.globalCompositeOperation="destination-out";for(const C of r)ICt({ctx:B,board:C,realToCanvasMat:i,soldermaskColor:"#000"});B.restore()}for(const C of r)ICt({ctx:B,board:C,realToCanvasMat:i,soldermaskColor:g});for(const C of t)C.type==="pcb_trace"?Hze({ctx:B,trace:C,realToCanvasMat:i,soldermaskOverCopperColor:c,layer:o,vias:I,platedHoles:l}):C.type==="pcb_copper_pour"&&kze({ctx:B,pour:C,realToCanvasMat:i,soldermaskOverCopperColor:c,layer:o,elements:t});for(const C of t)Jze({ctx:B,element:C,realToCanvasMat:i,soldermaskOverCopperColor:c,layer:o});fze(A,B)}function Jze(e){const{ctx:A,element:t,realToCanvasMat:i,soldermaskOverCopperColor:n,layer:o}=e;if(t.type==="pcb_smtpad")Rze({ctx:A,pad:t,realToCanvasMat:i,soldermaskOverCopperColor:n,layer:o});else if(t.type==="pcb_plated_hole")Mze({ctx:A,hole:t,realToCanvasMat:i,soldermaskOverCopperColor:n,layer:o});else if(t.type==="pcb_hole")vze({ctx:A,hole:t,realToCanvasMat:i,soldermaskOverCopperColor:n});else if(t.type==="pcb_via")Yze({ctx:A,via:t,realToCanvasMat:i});else if(t.type==="pcb_cutout")Dze({ctx:A,cutout:t,realToCanvasMat:i});else{if(t.type==="pcb_copper_pour")return;if(t.type==="pcb_trace")return}}function Tze(e,A){return A.copper[e]??A.copper.top}function fCt(e){const{ctx:A,trace:t,realToCanvasMat:i,colorMap:n}=e;if(!t.route||!Array.isArray(t.route)||t.route.length<2)return;const o=Z0A(t.route);for(const s of o){const r=s[0]?.layer;if(!r)continue;const a=Tze(r,n);if(dCt(s)){const g=CCt(s);Fk({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||A1({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"})}}hCt({ctx:A,trace:t,realToCanvasMat:i,vias:e.vias??[],platedHoles:e.platedHoles??[]})}function yCt(e){const{ctx:A,via:t,realToCanvasMat:i,colorMap:n,layer:o}=e;tQ({ctx:A,center:{x:t.x,y:t.y},radius:t.outer_diameter/2,fill:n.copper[o??"top"],realToCanvasMat:i}),A.save(),A.globalCompositeOperation="destination-out",tQ({ctx:A,center:{x:t.x,y:t.y},radius:t.hole_diameter/2,fill:"#000",realToCanvasMat:i}),A.restore(),tQ({ctx:A,center:{x:t.x,y:t.y},radius:t.hole_diameter/2,fill:n.drill,realToCanvasMat:i})}function pm(e,A){if(!A.layers||A.layers.length===0)return!0;const t=ltA(e);return t.length===0?!0:t.some(i=>A.layers.includes(i))}var op={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 Pze(e){return!e||e.length===0?"top":e.some(t=>t.startsWith("bottom"))?"bottom":"top"}var eQ=class{ctx;colorMap;realToCanvasMat;constructor(e){if("getContext"in e&&typeof e.getContext=="function"){const A=e.getContext("2d");if(!A)throw new Error("Failed to get 2D rendering context from canvas");this.ctx=A}else this.ctx=e;this.colorMap={...op},this.realToCanvasMat=hje()}configure(e){e.colorOverrides&&(this.colorMap={...this.colorMap,...e.colorOverrides,copper:{...this.colorMap.copper,...e.colorOverrides.copper},copperPour:{...this.colorMap.copperPour,...e.colorOverrides.copperPour},silkscreen:{...this.colorMap.silkscreen,...e.colorOverrides.silkscreen},soldermask:{...this.colorMap.soldermask,...e.colorOverrides.soldermask},soldermaskWithCopperUnderneath:{...this.colorMap.soldermaskWithCopperUnderneath,...e.colorOverrides.soldermaskWithCopperUnderneath},soldermaskOverCopper:{...this.colorMap.soldermaskOverCopper,...e.colorOverrides.soldermaskOverCopper}})}setCameraBounds(e){const A=this.ctx.canvas,t=A.width,i=A.height,n=e.maxX-e.minX,o=e.maxY-e.minY,s=t/n,r=i/o,a=Math.min(s,r),g=(t-n*a)/2,c=(i-o*a)/2;this.realToCanvasMat=T0A(vk(g,c),dje(a,-a),vk(-e.minX,-e.maxY))}drawElements(e,A={}){const t=Pze(A.layers),i=e.find(l=>l.type==="pcb_board"),n=e.find(l=>l.type==="pcb_panel");n&&eze({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=e.filter(l=>pm(l,A)&&l.type==="pcb_via"),I=e.filter(l=>pm(l,A)&&l.type==="pcb_plated_hole");i&&pje({ctx:this.ctx,board:i,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap,drawBoardMaterial:o,minBoardOutlineStrokePx:A.minBoardOutlineStrokePx});for(const l of e)pm(l,A)&&l.type==="pcb_copper_pour"&&wje({ctx:this.ctx,pour:l,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap});for(const l of e)pm(l,A)&&(l.type==="pcb_smtpad"&&dze({ctx:this.ctx,pad:l,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}),l.type==="pcb_copper_text"&&vje({ctx:this.ctx,text:l,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}));if(a){for(const l of e)pm(l,A)&&l.type==="pcb_trace"&&fCt({ctx:this.ctx,trace:l,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap,vias:c,platedHoles:I});for(const l of e)pm(l,A)&&(l.type==="pcb_hole"&&aCt({ctx:this.ctx,hole:l,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap,soldermaskMargin:l.soldermask_margin,drawSoldermask:a}),l.type==="pcb_plated_hole"&&gCt({ctx:this.ctx,hole:l,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap,soldermaskMargin:l.soldermask_margin,drawSoldermask:a,layer:t}),l.type==="pcb_via"&&yCt({ctx:this.ctx,via:l,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap,layer:t}))}a&&pCt({ctx:this.ctx,elements:e,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap,layer:"top",drawSoldermask:!0});for(const l of e)pm(l,A)&&(l.type==="pcb_silkscreen_text"&&Eze({ctx:this.ctx,text:l,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}),l.type==="pcb_silkscreen_rect"&&Cze({ctx:this.ctx,rect:l,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}),l.type==="pcb_silkscreen_circle"&&nze({ctx:this.ctx,circle:l,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}),l.type==="pcb_silkscreen_line"&&sze({ctx:this.ctx,line:l,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}),l.type==="pcb_silkscreen_path"&&cze({ctx:this.ctx,path:l,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}),l.type==="pcb_silkscreen_pill"&&lze({ctx:this.ctx,pill:l,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}),l.type==="pcb_silkscreen_oval"&&aze({ctx:this.ctx,oval:l,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}));for(const l of e)pm(l,A)&&l.type==="pcb_trace"&&!a&&fCt({ctx:this.ctx,trace:l,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap,vias:c,platedHoles:I});for(const l of e)pm(l,A)&&l.type==="pcb_hole"&&!a&&aCt({ctx:this.ctx,hole:l,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap,soldermaskMargin:a?l.soldermask_margin:void 0,drawSoldermask:a});for(const l of e)pm(l,A)&&(l.type==="pcb_plated_hole"&&!a&&gCt({ctx:this.ctx,hole:l,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap,soldermaskMargin:a?l.soldermask_margin:void 0,drawSoldermask:a,layer:t}),l.type==="pcb_via"&&!a&&yCt({ctx:this.ctx,via:l,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap,layer:t}));g&&pCt({ctx:this.ctx,elements:e,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap,layer:"bottom",drawSoldermask:!0});for(const l of e)pm(l,A)&&l.type==="pcb_cutout"&&Uje({ctx:this.ctx,cutout:l,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap});for(const l of e){if(!pm(l,A))continue;l.type==="pcb_keepout"&&Zje({ctx:this.ctx,keepout:l,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}),l.type==="pcb_fabrication_note_text"&&Oje({ctx:this.ctx,text:l,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}),l.type==="pcb_fabrication_note_rect"&&Kje({ctx:this.ctx,rect:l,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap});const B=A.showPcbNotes??!0;B&&l.type==="pcb_note_rect"&&$je({realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap,ctx:this.ctx,rect:l}),l.type==="pcb_fabrication_note_path"&&Pje({ctx:this.ctx,path:l,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}),B&&l.type==="pcb_note_path"&&Xje({ctx:this.ctx,path:l,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}),B&&l.type==="pcb_note_text"&&tze({ctx:this.ctx,text:l,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}),B&&l.type==="pcb_note_line"&&zje({ctx:this.ctx,line:l,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}),B&&l.type==="pcb_note_dimension"&&jje({ctx:this.ctx,pcbNoteDimension:l,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}),l.type==="pcb_fabrication_note_dimension"&&Tje({ctx:this.ctx,pcbFabricationNoteDimension:l,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}),l.type==="pcb_courtyard_circle"&&Mje({ctx:this.ctx,circle:l,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}),l.type==="pcb_courtyard_rect"&&Lje({ctx:this.ctx,rect:l,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}),l.type==="pcb_courtyard_outline"&&Rje({ctx:this.ctx,outline:l,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap})}}};const Kze=lxt(DUt);var V0A,mCt;function qze(){if(mCt)return V0A;mCt=1;var e=Object.defineProperty,A=Object.getOwnPropertyDescriptor,t=Object.getOwnPropertyNames,i=Object.prototype.hasOwnProperty,n=(h,E)=>{for(var u in E)e(h,u,{get:E[u],enumerable:!0})},o=(h,E,u,d)=>{if(E&&typeof E=="object"||typeof E=="function")for(let f of t(E))!i.call(h,f)&&f!==u&&e(h,f,{get:()=>E[f],enumerable:!(d=A(E,f))||d.enumerable});return h},s=h=>o(e({},"__esModule",{value:!0}),h),r={};n(r,{SuperGrid:()=>Q,toMMSI:()=>C,toMeterSI:()=>B}),V0A=s(r);var a=b0(),g=Kze,c=jxA(),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:R=(J,O,W)=>`${B(J,W)}, ${B(O,W)}`}=h,F=Math.ceil(S/b)+2,H=Math.ceil(_/b)+2;(0,a.useEffect)(()=>{if(!u.current)return;const J=u.current.getContext("2d");if(!J)return;const O=b/10**Math.floor(Math.log10(h.transform.a)),W=h.transform.d<0?-1:1,tA=b/10**Math.log10(h.transform.a)/O;function aA(_A,dA,WA){const VA=_A;let It,mA,gt;for(It=dA.x;It<=WA.x;It+=VA)mA=(0,g.applyToPoint)(h.transform,{x:It,y:dA.y}),gt=(0,g.applyToPoint)(h.transform,{x:It,y:WA.y}),J.beginPath(),J.moveTo(mA.x,mA.y),J.lineTo(gt.x,gt.y),J.stroke();const PA=I(dA.y,WA.y,VA*W);for(const UA of PA)mA=(0,g.applyToPoint)(h.transform,{x:dA.x,y:UA}),gt=(0,g.applyToPoint)(h.transform,{x:WA.x,y:UA}),J.beginPath(),J.moveTo(mA.x,mA.y),J.lineTo(gt.x,gt.y),J.stroke()}function eA(_A,dA,WA){const VA=_A;let It;for(It=dA.x;It<=WA.x;It+=VA)for(const mA of I(dA.y,WA.y,VA*W)){const gt=(0,g.applyToPoint)(h.transform,{x:It,y:mA});J.fillStyle=D,J.font="12px sans-serif",J.fillText(R(It,mA,_A),gt.x+2,gt.y-2)}}J.clearRect(0,0,S,_);const oA=(0,g.applyToPoint)((0,g.inverse)(h.transform),{x:0,y:0}),rA={x:Math.floor((oA.x-O)/O)*O,y:Math.floor((oA.y-O)/O+(W==-1?2:0))*O},BA={x:rA.x+O*F,y:rA.y+O*H*W},kA=O*5,MA={x:Math.floor((oA.x-kA)/kA)*kA,y:Math.floor((oA.y-kA)/kA+(W==-1?2:0))*kA},TA={x:MA.x+kA*F,y:MA.y+kA*H*W};J.globalAlpha=1,J.strokeStyle=m,aA(O,rA,BA),eA(kA,MA,TA),J.globalAlpha=1-tA,aA(kA/10,MA,TA),J.globalAlpha=1-tA,J.strokeStyle=w,aA(O/10,rA,BA),J.globalAlpha=Math.max(((1-tA)*10-5)/5,0),eA(kA/10,MA,TA),J.globalAlpha=1;const EA=(0,g.applyToPoint)(h.transform,d);J.font="12px sans-serif",J.fillStyle=D,J.fillText(R(d.x,d.y,O),EA.x+2,EA.y-2),J.strokeStyle=m,J.strokeRect(EA.x-5,EA.y-5,10,10)},[u,h.transform,d,S,_]);const Y=J=>{if(!u.current)return;const O=b/10/10**Math.floor(Math.log10(h.transform.a)),W=u.current.getBoundingClientRect(),z=(0,g.applyToPoint)((0,g.inverse)(h.transform),{x:J.clientX-W.left,y:J.clientY-W.top}),tA=l(O,z);f(tA)};return(0,c.jsx)("canvas",{onMouseUp:J=>{J.button===1&&Y(J)},onDoubleClick:Y,ref:u,width:h.width,height:h.height})};return V0A}var bj=qze();function Oze(e){if(e.sheet)return e.sheet;for(var A=0;A<document.styleSheets.length;A++)if(document.styleSheets[A].ownerNode===e)return document.styleSheets[A]}function Wze(e){var A=document.createElement("style");return A.setAttribute("data-emotion",e.key),e.nonce!==void 0&&A.setAttribute("nonce",e.nonce),A.appendChild(document.createTextNode("")),A.setAttribute("data-s",""),A}var Zze=(function(){function e(t){var i=this;this._insertTag=function(n){var o;i.tags.length===0?i.insertionPoint?o=i.insertionPoint.nextSibling:i.prepend?o=i.container.firstChild:o=i.before:o=i.tags[i.tags.length-1].nextSibling,i.container.insertBefore(n,o),i.tags.push(n)},this.isSpeedy=t.speedy===void 0?!0:t.speedy,this.tags=[],this.ctr=0,this.nonce=t.nonce,this.key=t.key,this.container=t.container,this.prepend=t.prepend,this.insertionPoint=t.insertionPoint,this.before=null}var A=e.prototype;return A.hydrate=function(i){i.forEach(this._insertTag)},A.insert=function(i){this.ctr%(this.isSpeedy?65e3:1)===0&&this._insertTag(Wze(this));var n=this.tags[this.tags.length-1];if(this.isSpeedy){var o=Oze(n);try{o.insertRule(i,o.cssRules.length)}catch{}}else n.appendChild(document.createTextNode(i));this.ctr++},A.flush=function(){this.tags.forEach(function(i){var n;return(n=i.parentNode)==null?void 0:n.removeChild(i)}),this.tags=[],this.ctr=0},e})(),cd="-ms-",xj="-moz-",Ag="-webkit-",wCt="comm",j0A="rule",z0A="decl",Vze="@import",DCt="@keyframes",jze="@layer",zze=Math.abs,_j=String.fromCharCode,Xze=Object.assign;function $ze(e,A){return XE(e,0)^45?(((A<<2^XE(e,0))<<2^XE(e,1))<<2^XE(e,2))<<2^XE(e,3):0}function SCt(e){return e.trim()}function AXe(e,A){return(e=A.exec(e))?e[0]:e}function tg(e,A,t){return e.replace(A,t)}function X0A(e,A){return e.indexOf(A)}function XE(e,A){return e.charCodeAt(A)|0}function QT(e,A,t){return e.slice(A,t)}function aS(e){return e.length}function $0A(e){return e.length}function kj(e,A){return A.push(e),e}function tXe(e,A){return e.map(A).join("")}var vj=1,e1=1,bCt=0,Rf=0,iQ=0,i1="";function Fj(e,A,t,i,n,o,s){return{value:e,root:A,parent:t,type:i,props:n,children:o,line:vj,column:e1,length:s,return:""}}function hT(e,A){return Xze(Fj("",null,null,"",null,null,0),e,{length:-e.length},A)}function eXe(){return iQ}function iXe(){return iQ=Rf>0?XE(i1,--Rf):0,e1--,iQ===10&&(e1=1,vj--),iQ}function $0(){return iQ=Rf<bCt?XE(i1,Rf++):0,e1++,iQ===10&&(e1=1,vj++),iQ}function gS(){return XE(i1,Rf)}function Mj(){return Rf}function ET(e,A){return QT(i1,e,A)}function uT(e){switch(e){case 0:case 9:case 10:case 13:case 32:return 5;case 33:case 43:case 44:case 47:case 62:case 64:case 126:case 59:case 123:case 125:return 4;case 58:return 3;case 34:case 39:case 40:case 91:return 2;case 41:case 93:return 1}return 0}function xCt(e){return vj=e1=1,bCt=aS(i1=e),Rf=0,[]}function _Ct(e){return i1="",e}function Gj(e){return SCt(ET(Rf-1,AyA(e===91?e+2:e===40?e+1:e)))}function nXe(e){for(;(iQ=gS())&&iQ<33;)$0();return uT(e)>2||uT(iQ)>3?"":" "}function oXe(e,A){for(;--A&&$0()&&!(iQ<48||iQ>102||iQ>57&&iQ<65||iQ>70&&iQ<97););return ET(e,Mj()+(A<6&&gS()==32&&$0()==32))}function AyA(e){for(;$0();)switch(iQ){case e:return Rf;case 34:case 39:e!==34&&e!==39&&AyA(iQ);break;case 40:e===41&&AyA(e);break;case 92:$0();break}return Rf}function sXe(e,A){for(;$0()&&e+iQ!==57;)if(e+iQ===84&&gS()===47)break;return"/*"+ET(A,Rf-1)+"*"+_j(e===47?e:$0())}function rXe(e){for(;!uT(gS());)$0();return ET(e,Rf)}function aXe(e){return _Ct(Rj("",null,null,null,[""],e=xCt(e),0,[0],e))}function Rj(e,A,t,i,n,o,s,r,a){for(var g=0,c=0,I=s,l=0,B=0,C=0,Q=1,h=1,E=1,u=0,d="",f=n,m=o,w=i,D=d;h;)switch(C=u,u=$0()){case 40:if(C!=108&&XE(D,I-1)==58){X0A(D+=tg(Gj(u),"&","&\f"),"&\f")!=-1&&(E=-1);break}case 34:case 39:case 91:D+=Gj(u);break;case 9:case 10:case 13:case 32:D+=nXe(C);break;case 92:D+=oXe(Mj()-1,7);continue;case 47:switch(gS()){case 42:case 47:kj(gXe(sXe($0(),Mj()),A,t),a);break;default:D+="/"}break;case 123*Q:r[g++]=aS(D)*E;case 125*Q:case 59:case 0:switch(u){case 0:case 125:h=0;case 59+c:E==-1&&(D=tg(D,/\f/g,"")),B>0&&aS(D)-I&&kj(B>32?vCt(D+";",i,t,I-1):vCt(tg(D," ","")+";",i,t,I-2),a);break;case 59:D+=";";default:if(kj(w=kCt(D,A,t,g,c,n,r,d,f=[],m=[],I),o),u===123)if(c===0)Rj(D,A,w,w,f,o,I,r,m);else switch(l===99&&XE(D,3)===110?100:l){case 100:case 108:case 109:case 115:Rj(e,w,w,i&&kj(kCt(e,w,w,0,0,n,r,d,n,f=[],I),m),n,m,I,r,i?f:m);break;default:Rj(D,w,w,w,[""],m,0,r,m)}}g=c=B=0,Q=E=1,d=D="",I=s;break;case 58:I=1+aS(D),B=C;default:if(Q<1){if(u==123)--Q;else if(u==125&&Q++==0&&iXe()==125)continue}switch(D+=_j(u),u*Q){case 38:E=c>0?1:(D+="\f",-1);break;case 44:r[g++]=(aS(D)-1)*E,E=1;break;case 64:gS()===45&&(D+=Gj($0())),l=gS(),c=I=aS(d=D+=rXe(Mj())),u++;break;case 45:C===45&&aS(D)==2&&(Q=0)}}return o}function kCt(e,A,t,i,n,o,s,r,a,g,c){for(var I=n-1,l=n===0?o:[""],B=$0A(l),C=0,Q=0,h=0;C<i;++C)for(var E=0,u=QT(e,I+1,I=zze(Q=s[C])),d=e;E<B;++E)(d=SCt(Q>0?l[E]+" "+u:tg(u,/&\f/g,l[E])))&&(a[h++]=d);return Fj(e,A,t,n===0?j0A:r,a,g,c)}function gXe(e,A,t){return Fj(e,A,t,wCt,_j(eXe()),QT(e,2,-2),0)}function vCt(e,A,t,i){return Fj(e,A,t,z0A,QT(e,0,i),QT(e,i+1,-1),i)}function n1(e,A){for(var t="",i=$0A(e),n=0;n<i;n++)t+=A(e[n],n,e,A)||"";return t}function cXe(e,A,t,i){switch(e.type){case jze:if(e.children.length)break;case Vze:case z0A:return e.return=e.return||e.value;case wCt:return"";case DCt:return e.return=e.value+"{"+n1(e.children,i)+"}";case j0A:e.value=e.props.join(",")}return aS(t=n1(e.children,i))?e.return=e.value+"{"+t+"}":""}function IXe(e){var A=$0A(e);return function(t,i,n,o){for(var s="",r=0;r<A;r++)s+=e[r](t,i,n,o)||"";return s}}function lXe(e){return function(A){A.root||(A=A.return)&&e(A)}}function BXe(e){var A=Object.create(null);return function(t){return A[t]===void 0&&(A[t]=e(t)),A[t]}}var CXe=function(A,t,i){for(var n=0,o=0;n=o,o=gS(),n===38&&o===12&&(t[i]=1),!uT(o);)$0();return ET(A,Rf)},QXe=function(A,t){var i=-1,n=44;do switch(uT(n)){case 0:n===38&&gS()===12&&(t[i]=1),A[i]+=CXe(Rf-1,t,i);break;case 2:A[i]+=Gj(n);break;case 4:if(n===44){A[++i]=gS()===58?"&\f":"",t[i]=A[i].length;break}default:A[i]+=_j(n)}while(n=$0());return A},hXe=function(A,t){return _Ct(QXe(xCt(A),t))},FCt=new WeakMap,EXe=function(A){if(!(A.type!=="rule"||!A.parent||A.length<1)){for(var t=A.value,i=A.parent,n=A.column===i.column&&A.line===i.line;i.type!=="rule";)if(i=i.parent,!i)return;if(!(A.props.length===1&&t.charCodeAt(0)!==58&&!FCt.get(i))&&!n){FCt.set(A,!0);for(var o=[],s=hXe(t,o),r=i.props,a=0,g=0;a<s.length;a++)for(var c=0;c<r.length;c++,g++)A.props[g]=o[a]?s[a].replace(/&\f/g,r[c]):r[c]+" "+s[a]}}},uXe=function(A){if(A.type==="decl"){var t=A.value;t.charCodeAt(0)===108&&t.charCodeAt(2)===98&&(A.return="",A.value="")}};function MCt(e,A){switch($ze(e,A)){case 5103:return Ag+"print-"+e+e;case 5737:case 4201:case 3177:case 3433:case 1641:case 4457:case 2921:case 5572:case 6356:case 5844:case 3191:case 6645:case 3005:case 6391:case 5879:case 5623:case 6135:case 4599:case 4855:case 4215:case 6389:case 5109:case 5365:case 5621:case 3829:return Ag+e+e;case 5349:case 4246:case 4810:case 6968:case 2756:return Ag+e+xj+e+cd+e+e;case 6828:case 4268:return Ag+e+cd+e+e;case 6165:return Ag+e+cd+"flex-"+e+e;case 5187:return Ag+e+tg(e,/(\w+).+(:[^]+)/,Ag+"box-$1$2"+cd+"flex-$1$2")+e;case 5443:return Ag+e+cd+"flex-item-"+tg(e,/flex-|-self/,"")+e;case 4675:return Ag+e+cd+"flex-line-pack"+tg(e,/align-content|flex-|-self/,"")+e;case 5548:return Ag+e+cd+tg(e,"shrink","negative")+e;case 5292:return Ag+e+cd+tg(e,"basis","preferred-size")+e;case 6060:return Ag+"box-"+tg(e,"-grow","")+Ag+e+cd+tg(e,"grow","positive")+e;case 4554:return Ag+tg(e,/([^-])(transform)/g,"$1"+Ag+"$2")+e;case 6187:return tg(tg(tg(e,/(zoom-|grab)/,Ag+"$1"),/(image-set)/,Ag+"$1"),e,"")+e;case 5495:case 3959:return tg(e,/(image-set\([^]*)/,Ag+"$1$`$1");case 4968:return tg(tg(e,/(.+:)(flex-)?(.*)/,Ag+"box-pack:$3"+cd+"flex-pack:$3"),/s.+-b[^;]+/,"justify")+Ag+e+e;case 4095:case 3583:case 4068:case 2532:return tg(e,/(.+)-inline(.+)/,Ag+"$1$2")+e;case 8116:case 7059:case 5753:case 5535:case 5445:case 5701:case 4933:case 4677:case 5533:case 5789:case 5021:case 4765:if(aS(e)-1-A>6)switch(XE(e,A+1)){case 109:if(XE(e,A+4)!==45)break;case 102:return tg(e,/(.+:)(.+)-([^]+)/,"$1"+Ag+"$2-$3$1"+xj+(XE(e,A+3)==108?"$3":"$2-$3"))+e;case 115:return~X0A(e,"stretch")?MCt(tg(e,"stretch","fill-available"),A)+e:e}break;case 4949:if(XE(e,A+1)!==115)break;case 6444:switch(XE(e,aS(e)-3-(~X0A(e,"!important")&&10))){case 107:return tg(e,":",":"+Ag)+e;case 101:return tg(e,/(.+:)([^;!]+)(;|!.+)?/,"$1"+Ag+(XE(e,14)===45?"inline-":"")+"box$3$1"+Ag+"$2$3$1"+cd+"$2box$3")+e}break;case 5936:switch(XE(e,A+11)){case 114:return Ag+e+cd+tg(e,/[svh]\w+-[tblr]{2}/,"tb")+e;case 108:return Ag+e+cd+tg(e,/[svh]\w+-[tblr]{2}/,"tb-rl")+e;case 45:return Ag+e+cd+tg(e,/[svh]\w+-[tblr]{2}/,"lr")+e}return Ag+e+cd+e+e}return e}var dXe=function(A,t,i,n){if(A.length>-1&&!A.return)switch(A.type){case z0A:A.return=MCt(A.value,A.length);break;case DCt:return n1([hT(A,{value:tg(A.value,"@","@"+Ag)})],n);case j0A:if(A.length)return tXe(A.props,function(o){switch(AXe(o,/(::plac\w+|:read-\w+)/)){case":read-only":case":read-write":return n1([hT(A,{props:[tg(o,/:(read-\w+)/,":"+xj+"$1")]})],n);case"::placeholder":return n1([hT(A,{props:[tg(o,/:(plac\w+)/,":"+Ag+"input-$1")]}),hT(A,{props:[tg(o,/:(plac\w+)/,":"+xj+"$1")]}),hT(A,{props:[tg(o,/:(plac\w+)/,cd+"input-$1")]})],n)}return""})}},pXe=[dXe],fXe=function(A){var t=A.key;if(t==="css"){var i=document.querySelectorAll("style[data-emotion]:not([data-s])");Array.prototype.forEach.call(i,function(Q){var h=Q.getAttribute("data-emotion");h.indexOf(" ")!==-1&&(document.head.appendChild(Q),Q.setAttribute("data-s",""))})}var n=A.stylisPlugins||pXe,o={},s,r=[];s=A.container||document.head,Array.prototype.forEach.call(document.querySelectorAll('style[data-emotion^="'+t+' "]'),function(Q){for(var h=Q.getAttribute("data-emotion").split(" "),E=1;E<h.length;E++)o[h[E]]=!0;r.push(Q)});var a,g=[EXe,uXe];{var c,I=[cXe,lXe(function(Q){c.insert(Q)})],l=IXe(g.concat(n,I)),B=function(h){return n1(aXe(h),l)};a=function(h,E,u,d){c=u,B(h?h+"{"+E.styles+"}":E.styles),d&&(C.inserted[E.name]=!0)}}var C={key:t,sheet:new Zze({key:t,container:s,nonce:A.nonce,speedy:A.speedy,prepend:A.prepend,insertionPoint:A.insertionPoint}),nonce:A.nonce,inserted:o,registered:{},insert:a};return C.sheet.hydrate(r),C};function yXe(e){for(var A=0,t,i=0,n=e.length;n>=4;++i,n-=4)t=e.charCodeAt(i)&255|(e.charCodeAt(++i)&255)<<8|(e.charCodeAt(++i)&255)<<16|(e.charCodeAt(++i)&255)<<24,t=(t&65535)*1540483477+((t>>>16)*59797<<16),t^=t>>>24,A=(t&65535)*1540483477+((t>>>16)*59797<<16)^(A&65535)*1540483477+((A>>>16)*59797<<16);switch(n){case 3:A^=(e.charCodeAt(i+2)&255)<<16;case 2:A^=(e.charCodeAt(i+1)&255)<<8;case 1:A^=e.charCodeAt(i)&255,A=(A&65535)*1540483477+((A>>>16)*59797<<16)}return A^=A>>>13,A=(A&65535)*1540483477+((A>>>16)*59797<<16),((A^A>>>15)>>>0).toString(36)}var mXe={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},wXe=/[A-Z]|^ms/g,DXe=/_EMO_([^_]+?)_([^]*?)_EMO_/g,GCt=function(A){return A.charCodeAt(1)===45},RCt=function(A){return A!=null&&typeof A!="boolean"},tyA=BXe(function(e){return GCt(e)?e:e.replace(wXe,"-$&").toLowerCase()}),NCt=function(A,t){switch(A){case"animation":case"animationName":if(typeof t=="string")return t.replace(DXe,function(i,n,o){return Gk={name:n,styles:o,next:Gk},n})}return mXe[A]!==1&&!GCt(A)&&typeof t=="number"&&t!==0?t+"px":t};function Nj(e,A,t){if(t==null)return"";var i=t;if(i.__emotion_styles!==void 0)return i;switch(typeof t){case"boolean":return"";case"object":{var n=t;if(n.anim===1)return Gk={name:n.name,styles:n.styles,next:Gk},n.name;var o=t;if(o.styles!==void 0){var s=o.next;if(s!==void 0)for(;s!==void 0;)Gk={name:s.name,styles:s.styles,next:Gk},s=s.next;var r=o.styles+";";return r}return SXe(e,A,t)}}var a=t;if(A==null)return a;var g=A[a];return g!==void 0?g:a}function SXe(e,A,t){var i="";if(Array.isArray(t))for(var n=0;n<t.length;n++)i+=Nj(e,A,t[n])+";";else for(var o in t){var s=t[o];if(typeof s!="object"){var r=s;A!=null&&A[r]!==void 0?i+=o+"{"+A[r]+"}":RCt(r)&&(i+=tyA(o)+":"+NCt(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++)RCt(s[a])&&(i+=tyA(o)+":"+NCt(o,s[a])+";");else{var g=Nj(e,A,s);switch(o){case"animation":case"animationName":{i+=tyA(o)+":"+g+";";break}default:i+=o+"{"+g+"}"}}}return i}var LCt=/label:\s*([^\s;{]+)\s*(;|$)/g,Gk;function eyA(e,A,t){if(e.length===1&&typeof e[0]=="object"&&e[0]!==null&&e[0].styles!==void 0)return e[0];var i=!0,n="";Gk=void 0;var o=e[0];if(o==null||o.raw===void 0)i=!1,n+=Nj(t,A,o);else{var s=o;n+=s[0]}for(var r=1;r<e.length;r++)if(n+=Nj(t,A,e[r]),i){var a=o;n+=a[r]}LCt.lastIndex=0;for(var g="",c;(c=LCt.exec(n))!==null;)g+="-"+c[1];var I=yXe(n)+g;return{name:I,styles:n,next:Gk}}function UCt(e,A,t){var i="";return t.split(" ").forEach(function(n){e[n]!==void 0?A.push(e[n]+";"):n&&(i+=n+" ")}),i}var bXe=function(A,t,i){var n=A.key+"-"+t.name;A.registered[n]===void 0&&(A.registered[n]=t.styles)},xXe=function(A,t,i){bXe(A,t);var n=A.key+"-"+t.name;if(A.inserted[t.name]===void 0){var o=t;do A.insert(t===o?"."+n:"",o,A.sheet,!0),o=o.next;while(o!==void 0)}};function HCt(e,A){if(e.inserted[A.name]===void 0)return e.insert("",A,e.sheet,!0)}function YCt(e,A,t){var i=[],n=UCt(e,i,t);return i.length<2?t:n+A(i)}var _Xe=function(A){var t=fXe(A);t.sheet.speedy=function(r){this.isSpeedy=r},t.compat=!0;var i=function(){for(var a=arguments.length,g=new Array(a),c=0;c<a;c++)g[c]=arguments[c];var I=eyA(g,t.registered,void 0);return xXe(t,I),t.key+"-"+I.name},n=function(){for(var a=arguments.length,g=new Array(a),c=0;c<a;c++)g[c]=arguments[c];var I=eyA(g,t.registered),l="animation-"+I.name;return HCt(t,{name:I.name,styles:"@keyframes "+l+"{"+I.styles+"}"}),l},o=function(){for(var a=arguments.length,g=new Array(a),c=0;c<a;c++)g[c]=arguments[c];var I=eyA(g,t.registered);HCt(t,I)},s=function(){for(var a=arguments.length,g=new Array(a),c=0;c<a;c++)g[c]=arguments[c];return YCt(t.registered,i,kXe(g))};return{css:i,cx:s,injectGlobal:o,keyframes:n,hydrate:function(a){a.forEach(function(g){t.inserted[g]=!0})},flush:function(){t.registered={},t.inserted={},t.sheet.flush()},sheet:t.sheet,cache:t,getRegisteredStyles:UCt.bind(null,t.registered),merge:YCt.bind(null,t.registered,i)}},kXe=function e(A){for(var t="",i=0;i<A.length;i++){var n=A[i];if(n!=null){var o=void 0;switch(typeof n){case"boolean":break;case"object":{if(Array.isArray(n))o=e(n);else{o="";for(var s in n)n[s]&&s&&(o&&(o+=" "),o+=s)}break}default:o=n}o&&(t&&(t+=" "),t+=o)}}return t},vXe=_Xe({key:"css"}),o1=vXe.css,FXe=Object.create,JCt=Object.defineProperty,MXe=Object.getOwnPropertyDescriptor,TCt=Object.getOwnPropertyNames,GXe=Object.getPrototypeOf,RXe=Object.prototype.hasOwnProperty,Qa=(e,A)=>function(){return A||(0,e[TCt(e)[0]])((A={exports:{}}).exports,A),A.exports},NXe=(e,A,t,i)=>{if(A&&typeof A=="object"||typeof A=="function")for(let n of TCt(A))!RXe.call(e,n)&&n!==t&&JCt(e,n,{get:()=>A[n],enumerable:!(i=MXe(A,n))||i.enumerable});return e},iyA=(e,A,t)=>(t=e!=null?FXe(GXe(e)):{},NXe(A||!e||!e.__esModule?JCt(t,"default",{value:e,enumerable:!0}):t,e)),LXe=Qa({"node_modules/toggle-selection/index.js"(e,A){A.exports=function(){var t=document.getSelection();if(!t.rangeCount)return function(){};for(var i=document.activeElement,n=[],o=0;o<t.rangeCount;o++)n.push(t.getRangeAt(o));switch(i.tagName.toUpperCase()){case"INPUT":case"TEXTAREA":i.blur();break;default:i=null;break}return t.removeAllRanges(),function(){t.type==="Caret"&&t.removeAllRanges(),t.rangeCount||n.forEach(function(s){t.addRange(s)}),i&&i.focus()}}}}),UXe=Qa({"node_modules/copy-to-clipboard/index.js"(e,A){var t=LXe(),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=t(),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}}),HXe=Qa({"node_modules/svgson/dist/svgson.umd.js"(e,A){(function(t,i){typeof e=="object"&&typeof A<"u"?A.exports=i():typeof define=="function"&&define.amd?define(i):(t=typeof globalThis<"u"?globalThis:t||self,t.svgson=i())})(e,function(){var t=function(eA){return eA!=null&&(i(eA)||n(eA)||!!eA._isBuffer)};function i(eA){return!!eA.constructor&&typeof eA.constructor.isBuffer=="function"&&eA.constructor.isBuffer(eA)}function n(eA){return typeof eA.readFloatLE=="function"&&typeof eA.slice=="function"&&i(eA.slice(0,0))}var o=Object.prototype.toString,s=function(oA){if(typeof oA>"u")return"undefined";if(oA===null)return"null";if(oA===!0||oA===!1||oA instanceof Boolean)return"boolean";if(typeof oA=="string"||oA instanceof String)return"string";if(typeof oA=="number"||oA instanceof Number)return"number";if(typeof oA=="function"||oA instanceof Function)return"function";if(typeof Array.isArray<"u"&&Array.isArray(oA))return"array";if(oA instanceof RegExp)return"regexp";if(oA instanceof Date)return"date";var rA=o.call(oA);return rA==="[object RegExp]"?"regexp":rA==="[object Date]"?"date":rA==="[object Arguments]"?"arguments":rA==="[object Error]"?"error":t(oA)?"buffer":rA==="[object Set]"?"set":rA==="[object WeakSet]"?"weakset":rA==="[object Map]"?"map":rA==="[object WeakMap]"?"weakmap":rA==="[object Symbol]"?"symbol":rA==="[object Int8Array]"?"int8array":rA==="[object Uint8Array]"?"uint8array":rA==="[object Uint8ClampedArray]"?"uint8clampedarray":rA==="[object Int16Array]"?"int16array":rA==="[object Uint16Array]"?"uint16array":rA==="[object Int32Array]"?"int32array":rA==="[object Uint32Array]"?"uint32array":rA==="[object Float32Array]"?"float32array":rA==="[object Float64Array]"?"float64array":"object"};function r(eA,oA){return oA={exports:{}},eA(oA,oA.exports),oA.exports}var a=r(function(eA){(function(){function oA(rA,BA){if(typeof BA!="function")return rA;var pA={};for(var kA in rA)Object.prototype.hasOwnProperty.call(rA,kA)&&(pA[BA(kA,rA[kA])||kA]=rA[kA]);return pA}eA.exports?eA.exports=oA:window.rename=oA})()}),g=function eA(oA,rA){var BA=s(oA);if(BA!=="object"&&BA!=="array")throw new Error("expected an object");var pA=[];BA==="object"&&(oA=a(oA,rA),pA={});for(var kA in oA)if(oA.hasOwnProperty(kA)){var MA=oA[kA];s(MA)==="object"||s(MA)==="array"?pA[kA]=eA(MA,rA):pA[kA]=MA}return pA},c=r(function(eA){var oA=Object.prototype.hasOwnProperty,rA="~";function BA(){}Object.create&&(BA.prototype=Object.create(null),new BA().__proto__||(rA=!1));function pA(MA,TA,EA){this.fn=MA,this.context=TA,this.once=EA||!1}function kA(){this._events=new BA,this._eventsCount=0}kA.prototype.eventNames=function(){var TA=[],EA,_A;if(this._eventsCount===0)return TA;for(_A in EA=this._events)oA.call(EA,_A)&&TA.push(rA?_A.slice(1):_A);return Object.getOwnPropertySymbols?TA.concat(Object.getOwnPropertySymbols(EA)):TA},kA.prototype.listeners=function(TA,EA){var _A=rA?rA+TA:TA,dA=this._events[_A];if(EA)return!!dA;if(!dA)return[];if(dA.fn)return[dA.fn];for(var WA=0,VA=dA.length,It=new Array(VA);WA<VA;WA++)It[WA]=dA[WA].fn;return It},kA.prototype.emit=function(TA,EA,_A,dA,WA,VA){var It=rA?rA+TA:TA;if(!this._events[It])return!1;var mA=this._events[It],gt=arguments.length,PA,UA;if(mA.fn){switch(mA.once&&this.removeListener(TA,mA.fn,void 0,!0),gt){case 1:return mA.fn.call(mA.context),!0;case 2:return mA.fn.call(mA.context,EA),!0;case 3:return mA.fn.call(mA.context,EA,_A),!0;case 4:return mA.fn.call(mA.context,EA,_A,dA),!0;case 5:return mA.fn.call(mA.context,EA,_A,dA,WA),!0;case 6:return mA.fn.call(mA.context,EA,_A,dA,WA,VA),!0}for(UA=1,PA=new Array(gt-1);UA<gt;UA++)PA[UA-1]=arguments[UA];mA.fn.apply(mA.context,PA)}else{var jA=mA.length,xA;for(UA=0;UA<jA;UA++)switch(mA[UA].once&&this.removeListener(TA,mA[UA].fn,void 0,!0),gt){case 1:mA[UA].fn.call(mA[UA].context);break;case 2:mA[UA].fn.call(mA[UA].context,EA);break;case 3:mA[UA].fn.call(mA[UA].context,EA,_A);break;case 4:mA[UA].fn.call(mA[UA].context,EA,_A,dA);break;default:if(!PA)for(xA=1,PA=new Array(gt-1);xA<gt;xA++)PA[xA-1]=arguments[xA];mA[UA].fn.apply(mA[UA].context,PA)}}return!0},kA.prototype.on=function(TA,EA,_A){var dA=new pA(EA,_A||this),WA=rA?rA+TA:TA;return this._events[WA]?this._events[WA].fn?this._events[WA]=[this._events[WA],dA]:this._events[WA].push(dA):(this._events[WA]=dA,this._eventsCount++),this},kA.prototype.once=function(TA,EA,_A){var dA=new pA(EA,_A||this,!0),WA=rA?rA+TA:TA;return this._events[WA]?this._events[WA].fn?this._events[WA]=[this._events[WA],dA]:this._events[WA].push(dA):(this._events[WA]=dA,this._eventsCount++),this},kA.prototype.removeListener=function(TA,EA,_A,dA){var WA=rA?rA+TA:TA;if(!this._events[WA])return this;if(!EA)return--this._eventsCount===0?this._events=new BA:delete this._events[WA],this;var VA=this._events[WA];if(VA.fn)VA.fn===EA&&(!dA||VA.once)&&(!_A||VA.context===_A)&&(--this._eventsCount===0?this._events=new BA:delete this._events[WA]);else{for(var It=0,mA=[],gt=VA.length;It<gt;It++)(VA[It].fn!==EA||dA&&!VA[It].once||_A&&VA[It].context!==_A)&&mA.push(VA[It]);mA.length?this._events[WA]=mA.length===1?mA[0]:mA:--this._eventsCount===0?this._events=new BA:delete this._events[WA]}return this},kA.prototype.removeAllListeners=function(TA){var EA;return TA?(EA=rA?rA+TA:TA,this._events[EA]&&(--this._eventsCount===0?this._events=new BA:delete this._events[EA])):(this._events=new BA,this._eventsCount=0),this},kA.prototype.off=kA.prototype.removeListener,kA.prototype.addListener=kA.prototype.on,kA.prototype.setMaxListeners=function(){return this},kA.prefixed=rA,kA.EventEmitter=kA,eA.exports=kA});function I(eA,oA,rA){return oA in eA?Object.defineProperty(eA,oA,{value:rA,enumerable:!0,configurable:!0,writable:!0}):eA[oA]=rA,eA}var l=function(){},B={data:"state-data",cdata:"state-cdata",tagBegin:"state-tag-begin",tagName:"state-tag-name",tagEnd:"state-tag-end",attributeNameStart:"state-attribute-name-start",attributeName:"state-attribute-name",attributeNameEnd:"state-attribute-name-end",attributeValueBegin:"state-attribute-value-begin",attributeValue:"state-attribute-value"},C={lt:"action-lt",gt:"action-gt",space:"action-space",equal:"action-equal",quote:"action-quote",slash:"action-slash",char:"action-char",error:"action-error"},Q={text:"text",openTag:"open-tag",closeTag:"close-tag",attributeName:"attribute-name",attributeValue:"attribute-value"},h={" ":C.space," ":C.space,"\n":C.space,"\r":C.space,"<":C.lt,">":C.gt,'"':C.quote,"'":C.quote,"=":C.equal,"/":C.slash},E=function(oA){return h[oA]||C.char},u=function(oA){var rA,BA,pA,kA,MA,TA,EA,_A,dA,WA;oA=Object.assign({debug:!1},oA);var VA=new c,It=B.data,mA="",gt="",PA="",UA="",jA="",xA="",DA=function(KA,ZA){if(!(gt[0]==="?"||gt[0]==="!")){var nt={type:KA,value:ZA};oA.debug&&console.log("emit:",nt),VA.emit("data",nt)}};VA.stateMachine=(WA={},I(WA,B.data,(rA={},I(rA,C.lt,function(){mA.trim()&&DA(Q.text,mA),gt="",jA=!1,It=B.tagBegin}),I(rA,C.char,function(FA){mA+=FA}),rA)),I(WA,B.cdata,I({},C.char,function(FA){mA+=FA,mA.substr(-3)==="]]>"&&(DA(Q.text,mA.slice(0,-3)),mA="",It=B.data)})),I(WA,B.tagBegin,(BA={},I(BA,C.space,l),I(BA,C.char,function(FA){gt=FA,It=B.tagName}),I(BA,C.slash,function(){gt="",jA=!0}),BA)),I(WA,B.tagName,(pA={},I(pA,C.space,function(){jA?It=B.tagEnd:(It=B.attributeNameStart,DA(Q.openTag,gt))}),I(pA,C.gt,function(){DA(jA?Q.closeTag:Q.openTag,gt),mA="",It=B.data}),I(pA,C.slash,function(){It=B.tagEnd,DA(Q.openTag,gt)}),I(pA,C.char,function(FA){gt+=FA,gt==="![CDATA["&&(It=B.cdata,mA="",gt="")}),pA)),I(WA,B.tagEnd,(kA={},I(kA,C.gt,function(){DA(Q.closeTag,gt),mA="",It=B.data}),I(kA,C.char,l),kA)),I(WA,B.attributeNameStart,(MA={},I(MA,C.char,function(FA){PA=FA,It=B.attributeName}),I(MA,C.gt,function(){mA="",It=B.data}),I(MA,C.space,l),I(MA,C.slash,function(){jA=!0,It=B.tagEnd}),MA)),I(WA,B.attributeName,(TA={},I(TA,C.space,function(){It=B.attributeNameEnd}),I(TA,C.equal,function(){DA(Q.attributeName,PA),It=B.attributeValueBegin}),I(TA,C.gt,function(){UA="",DA(Q.attributeName,PA),DA(Q.attributeValue,UA),mA="",It=B.data}),I(TA,C.slash,function(){jA=!0,UA="",DA(Q.attributeName,PA),DA(Q.attributeValue,UA),It=B.tagEnd}),I(TA,C.char,function(FA){PA+=FA}),TA)),I(WA,B.attributeNameEnd,(EA={},I(EA,C.space,l),I(EA,C.equal,function(){DA(Q.attributeName,PA),It=B.attributeValueBegin}),I(EA,C.gt,function(){UA="",DA(Q.attributeName,PA),DA(Q.attributeValue,UA),mA="",It=B.data}),I(EA,C.char,function(FA){UA="",DA(Q.attributeName,PA),DA(Q.attributeValue,UA),PA=FA,It=B.attributeName}),EA)),I(WA,B.attributeValueBegin,(_A={},I(_A,C.space,l),I(_A,C.quote,function(FA){xA=FA,UA="",It=B.attributeValue}),I(_A,C.gt,function(){UA="",DA(Q.attributeValue,UA),mA="",It=B.data}),I(_A,C.char,function(FA){xA="",UA=FA,It=B.attributeValue}),_A)),I(WA,B.attributeValue,(dA={},I(dA,C.space,function(FA){xA?UA+=FA:(DA(Q.attributeValue,UA),It=B.attributeNameStart)}),I(dA,C.quote,function(FA){xA===FA?(DA(Q.attributeValue,UA),It=B.attributeNameStart):UA+=FA}),I(dA,C.gt,function(FA){xA?UA+=FA:(DA(Q.attributeValue,UA),mA="",It=B.data)}),I(dA,C.slash,function(FA){xA?UA+=FA:(DA(Q.attributeValue,UA),jA=!0,It=B.tagEnd)}),I(dA,C.char,function(FA){UA+=FA}),dA)),WA);var HA=function(KA){oA.debug&&console.log(It,KA);var ZA=VA.stateMachine[It],nt=ZA[E(KA)]||ZA[C.error]||ZA[C.char];nt(KA)};return VA.write=function(FA){for(var KA=FA.length,ZA=0;ZA<KA;ZA++)HA(FA[ZA])},VA},d={State:B,Action:C,Type:Q,create:u},f=d.Type,m={element:"element",text:"text"},w=function(oA){return Object.assign({name:"",type:m.element,value:"",parent:null,attributes:{},children:[]},oA)},D=function(oA){oA=Object.assign({stream:!1,parentNodes:!0,doneEvent:"done",tagPrefix:"tag:",emitTopLevelOnly:!1,debug:!1},oA);var rA=void 0,BA=void 0,pA=void 0,kA=void 0,MA=new c,TA=function(_A){switch(_A.type){case f.openTag:if(pA===null)pA=BA,pA.name=_A.value;else{var dA=w({name:_A.value,parent:pA});pA.children.push(dA),pA=dA}break;case f.closeTag:var WA=pA.parent;if(oA.parentNodes||(pA.parent=null),pA.name!==_A.value)break;oA.stream&&WA===BA&&(BA.children=[],pA.parent=null),(!oA.emitTopLevelOnly||WA===BA)&&(MA.emit(oA.tagPrefix+pA.name,pA),MA.emit("tag",pA.name,pA)),pA===BA&&(rA.removeAllListeners("data"),MA.emit(oA.doneEvent,pA),BA=null),pA=WA;break;case f.text:pA&&pA.children.push(w({type:m.text,value:_A.value,parent:oA.parentNodes?pA:null}));break;case f.attributeName:kA=_A.value,pA.attributes[kA]="";break;case f.attributeValue:pA.attributes[kA]=_A.value;break}};return MA.reset=function(){rA=d.create({debug:oA.debug}),rA.on("data",TA),BA=w(),pA=null,kA="",MA.parse=rA.write},MA.reset(),MA},S=function(oA,rA){rA=Object.assign({},rA,{stream:!1,tagPrefix:":"});var BA=D(rA),pA=void 0;return BA.on("done",function(kA){pA=kA}),BA.parse(oA),pA},_={parseSync:S},b=_.parseSync,R=function(oA){var rA=b("<root>".concat(oA,"</root>"),{parentNodes:!1}),BA=rA.children&&rA.children.length>0&&rA.children.every(function(pA){return pA.name==="svg"});if(BA)return rA.children.length===1?rA.children[0]:rA.children;throw Error("nothing to parse")},F=function(oA){return g(oA,function(rA){return Y(rA)?rA:H(rA)})},H=function(oA){return oA.replace(/[-|:]([a-z])/gi,function(rA,BA){return BA.toUpperCase()})},Y=function(oA){return/^(data|aria)(-\w+)/.test(oA)},J=function(oA){if(oA){var rA=String(oA);return/[&<>]/.test(rA)?"<![CDATA[".concat(rA.replace(/]]>/,"]]]]><![CDATA[>"),"]]>"):rA}return""},O=function(oA){return String(oA).replace(/&/g,"&").replace(/'/g,"'").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")},W=function(oA){var rA=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},BA=rA.transformNode,pA=BA===void 0?function(EA){return EA}:BA,kA=rA.camelcase,MA=kA===void 0?!1:kA,TA=function(_A){var dA;return dA=pA(_A),MA&&(dA=F(dA)),dA};return TA(R(oA))};function z(){for(var eA=arguments.length,oA=new Array(eA),rA=0;rA<eA;rA++)oA[rA]=arguments[rA];return new Promise(function(BA,pA){try{var kA=W.apply(void 0,oA);BA(kA)}catch(MA){pA(MA)}})}var tA=function eA(oA){var rA=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},BA=rA.transformAttr,pA=BA===void 0?function(It,mA,gt){return"".concat(It,'="').concat(gt(mA),'"')}:BA,kA=rA.transformNode,MA=kA===void 0?function(It){return It}:kA,TA=rA.selfClose,EA=TA===void 0?!0:TA;if(Array.isArray(oA))return oA.map(function(It){return eA(It,{transformAttr:pA,selfClose:EA,transformNode:MA})}).join("");var _A=MA(oA);if(_A.type==="text")return J(_A.value);var dA="";for(var WA in _A.attributes){var VA=pA(WA,_A.attributes[WA],O,_A.name);dA+=VA?" ".concat(VA):""}return _A.children&&_A.children.length>0||!EA?"<".concat(_A.name).concat(dA,">").concat(eA(_A.children,{transformAttr:pA,transformNode:MA,selfClose:EA}),"</").concat(_A.name,">"):"<".concat(_A.name).concat(dA,"/>")},aA=Object.assign({},{parse:z,parseSync:W,stringify:tA});return aA})}}),nyA=Qa({"node_modules/js-beautify/js/src/core/output.js"(e,A){function t(o){this.__parent=o,this.__character_count=0,this.__indent_count=-1,this.__alignment_count=0,this.__wrap_point_index=0,this.__wrap_point_character_count=0,this.__wrap_point_indent_count=-1,this.__wrap_point_alignment_count=0,this.__items=[]}t.prototype.clone_empty=function(){var o=new t(this.__parent);return o.set_indent(this.__indent_count,this.__alignment_count),o},t.prototype.item=function(o){return o<0?this.__items[this.__items.length+o]:this.__items[o]},t.prototype.has_match=function(o){for(var s=this.__items.length-1;s>=0;s--)if(this.__items[s].match(o))return!0;return!1},t.prototype.set_indent=function(o,s){this.is_empty()&&(this.__indent_count=o||0,this.__alignment_count=s||0,this.__character_count=this.__parent.get_indent_size(this.__indent_count,this.__alignment_count))},t.prototype._set_wrap_point=function(){this.__parent.wrap_line_length&&(this.__wrap_point_index=this.__items.length,this.__wrap_point_character_count=this.__character_count,this.__wrap_point_indent_count=this.__parent.next_line.__indent_count,this.__wrap_point_alignment_count=this.__parent.next_line.__alignment_count)},t.prototype._should_wrap=function(){return this.__wrap_point_index&&this.__character_count>this.__parent.wrap_line_length&&this.__wrap_point_character_count>this.__parent.next_line.__character_count},t.prototype._allow_wrap=function(){if(this._should_wrap()){this.__parent.add_new_line();var o=this.__parent.current_line;return o.set_indent(this.__wrap_point_indent_count,this.__wrap_point_alignment_count),o.__items=this.__items.slice(this.__wrap_point_index),this.__items=this.__items.slice(0,this.__wrap_point_index),o.__character_count+=this.__character_count-this.__wrap_point_character_count,this.__character_count=this.__wrap_point_character_count,o.__items[0]===" "&&(o.__items.splice(0,1),o.__character_count-=1),!0}return!1},t.prototype.is_empty=function(){return this.__items.length===0},t.prototype.last=function(){return this.is_empty()?null:this.__items[this.__items.length-1]},t.prototype.push=function(o){this.__items.push(o);var s=o.lastIndexOf(`
|
|
5386
|
+
`),a=r.map(I=>{const l=Array.from(I);return l.reduce((B,C,Q)=>B+iCt(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:t,letterSpacing:i,spaceWidth:n,strokeWidth:o,lineHeight:s,lines:r,lineWidths:a}}function nCt(e,A){const t=A.width+A.strokeWidth,i=A.height+A.strokeWidth;let n=0,o=0;return e==="center"||e==="top_center"||e==="bottom_center"?n=-t/2:e==="top_left"||e==="bottom_left"||e==="center_left"?n=0:e==="top_right"||e==="bottom_right"||e==="center_right"?n=-t:(e==="top_center"||e==="bottom_center")&&(n=-t/2),e==="center"||e==="center_left"||e==="center_right"?o=-i/2:e==="top_left"||e==="top_right"||e==="top_center"?o=0:(e==="bottom_left"||e==="bottom_right"||e==="bottom_center")&&(o=-i),{x:n,y:o}}function oCt(e){const{alignment:A,lineWidth:t,maxWidth:i,strokeWidth:n}=e,o=t+n,s=i+n;return A==="top_left"||A==="bottom_left"||A==="center_left"?0:A==="top_right"||A==="bottom_right"||A==="center_right"?s-o:(s-o)/2}var Sje=e=>D$A[e];function sCt(e){const{ctx:A,line:t,fontSize:i,startX:n,startY:o,layout:s}=e,{strokeWidth:r}=s,a=i,g=i,c=o,I=Array.from(t);let l=n+r/2;I.forEach((B,C)=>{const Q=Sje(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+=iCt(B,I[C+1],i)})}function bje(e){const{ctx:A,text:t,fontSize:i,startX:n,startY:o,anchorAlignment:s="center"}=e,r=K0A(t,i),{lines:a,lineWidths:g,lineHeight:c,width:I,strokeWidth:l}=r;a.forEach((B,C)=>{const Q=n+oCt({alignment:s,lineWidth:g[C],maxWidth:I,strokeWidth:l}),h=o+C*c;sCt({ctx:A,line:B,fontSize:i,startX:Q,startY:h,layout:r})})}var xje={left:.2,right:.2,top:.2,bottom:.2};function yj(e){const{ctx:A,text:t,x:i,y:n,fontSize:o,color:s,realToCanvasMat:r,anchorAlignment:a,rotation:g=0,mirrorX:c=!1,knockout:I=!1,knockoutPadding:l={}}=e;if(!t)return;const[B,C]=ai(r,[i,n]),Q=Math.abs(r.a),h=o*Q,E=K0A(t,h),u=nCt(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={...xje,...l},_=S.left*Q,b=S.right*Q,R=S.top*Q,F=S.bottom*Q,H=E.width+E.strokeWidth,Y=u.x-_*4,J=u.y-R*4,O=H+_*2+b*2,W=E.height+E.strokeWidth+R*2+F*2;A.fillStyle=s,A.fillRect(Y,J,O,W)}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+oCt({alignment:a,lineWidth:f[_],maxWidth:w,strokeWidth:D}),R=u.y+_*m;sCt({ctx:A,line:S,fontSize:h,startX:b,startY:R,layout:E})}),A.restore()}var _je={left:.2,right:.2,top:.2,bottom:.2};function kje(e){return e?e.includes("left")?"center_left":e.includes("right")?"center_right":"center":"center"}function vje(e){const{ctx:A,text:t,realToCanvasMat:i,colorMap:n}=e,o=t.text??"";if(!o)return;const[s,r]=ai(i,[t.anchor_position.x,t.anchor_position.y]),a=Math.abs(i.a),g=(t.font_size??1)*a,c=t.ccw_rotation??0,I={..._je,...t.knockout_padding},l=n.copper[t.layer]??n.copper.top,B=K0A(o,g),C=B.width+B.strokeWidth,Q=kje(t.anchor_alignment),h=nCt(Q,B);if(A.save(),A.translate(s,r),t.is_mirrored&&A.scale(-1,1),c!==0&&A.rotate(-c*(Math.PI/180)),A.lineWidth=B.strokeWidth,A.lineCap="round",A.lineJoin="round",t.is_knockout){const E=I.left*a,u=I.right*a,d=I.top*a,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;bje({ctx:A,text:o,fontSize:g,startX:h.x,startY:h.y,anchorAlignment:Q}),A.restore()}function tQ(e){const{ctx:A,center:t,radius:i,fill:n,realToCanvasMat:o,stroke:s,strokeWidth:r,isStrokeDashed:a=!1}=e,[g,c]=ai(o,[t.x,t.y]),I=i*Math.abs(o.a),l=r?r*Math.abs(o.a):void 0;A.beginPath(),A.arc(g,c,I,0,Math.PI*2),n&&(A.fillStyle=n,A.fill()),s&&l&&(a?A.setLineDash([l*3,l*2]):A.setLineDash([]),A.strokeStyle=s,A.lineWidth=l,A.stroke())}function Fje(e,A){return e==="bottom"?A.courtyard.bottom:A.courtyard.top}function Mje(e){const{ctx:A,circle:t,realToCanvasMat:i,colorMap:n}=e;tQ({ctx:A,center:t.center,radius:t.radius,stroke:Fje(t.layer,n),strokeWidth:.05,realToCanvasMat:i})}function Gje(e,A){return e==="bottom"?A.courtyard.bottom:A.courtyard.top}function Rje(e){const{ctx:A,outline:t,realToCanvasMat:i,colorMap:n}=e;if(!t.outline||t.outline.length<2)return;A.beginPath();const o=ai(i,t.outline[0]);A.moveTo(o.x,o.y);for(let s=1;s<t.outline.length;s++){const r=ai(i,t.outline[s]);A.lineTo(r.x,r.y)}A.closePath(),A.lineWidth=.05*Math.abs(i.a),A.strokeStyle=Gje(t.layer,n),A.stroke()}function Nje(e,A){return e==="bottom"?A.courtyard.bottom:A.courtyard.top}function Lje(e){const{ctx:A,rect:t,realToCanvasMat:i,colorMap:n}=e;AQ({ctx:A,center:t.center,width:t.width,height:t.height,stroke:Nje(t.layer,n),strokeWidth:.05,realToCanvasMat:i})}function Uje(e){const{ctx:A,cutout:t,realToCanvasMat:i,colorMap:n}=e;if(t.shape==="rect"){AQ({ctx:A,center:t.center,width:t.width,height:t.height,fill:n.drill,realToCanvasMat:i,ccwRotationDegrees:t.rotation??0,borderRadius:t.corner_radius??0});return}if(t.shape==="circle"){tQ({ctx:A,center:t.center,radius:t.radius,fill:n.drill,realToCanvasMat:i});return}if(t.shape==="polygon"){t.points&&t.points.length>=3&&Fk({ctx:A,points:t.points,fill:n.drill,realToCanvasMat:i});return}}var Hje=1.5,Yje=.6,Jje=.3;function q0A(e){const A=Math.hypot(e.x,e.y)||1;return{x:e.x/A,y:e.y/A}}function rCt(e){const{ctx:A,from:t,to:i,realToCanvasMat:n,color:o,fontSize:s,arrowSize:r=1,strokeWidth:a,text:g,textRotation:c,offset:I}=e,l=q0A({x:i.x-t.x,y:i.y-t.y}),B={x:-l.y,y:l.x},C=I?.direction&&typeof I.direction.x=="number"&&typeof I.direction.y=="number",Q=C?q0A(I.direction):{x:0,y:0},h=I?.distance??0,E={x:Q.x*h,y:Q.y*h},u={x:t.x+E.x,y:t.y+E.y},d={x:i.x+E.x,y:i.y+E.y},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=[],R=Y=>{const J={x:Y.x+S.x*_,y:Y.y+S.y*_},O=w/2,W={x:-S.y,y:S.x};return[{x:Y.x+W.x*O,y:Y.y+W.y*O},{x:Y.x-W.x*O,y:Y.y-W.y*O},{x:J.x-W.x*O,y:J.y-W.y*O},{x:J.x+W.x*O,y:J.y+W.y*O}]};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],H=Y=>{const J=R(Y);b.push(F),b.push(J[0]),b.push(...J),b.push(J[0]),b.push(F)};if(H(t),H(i),Fk({ctx:A,points:b,fill:D,realToCanvasMat:n}),g){const Y={x:(t.x+i.x)/2+E.x,y:(t.y+i.y)/2+E.y},[J,O]=ai(n,[u.x,u.y]),[W,z]=ai(n,[d.x,d.y]),tA=q0A({x:W-J,y:z-O});let aA=Math.atan2(tA.y,tA.x)*180/Math.PI;(aA>90||aA<-90)&&(aA+=180);const eA=typeof c=="number"&&Number.isFinite(c)?aA-c:aA;let oA=0;if(g&&typeof c=="number"&&Number.isFinite(c)){const pA=g.length*s*Yje,kA=s,MA=c*Math.PI/180,TA=Math.abs(Math.sin(MA)),EA=Math.abs(Math.cos(MA)),_A=pA/2,dA=kA/2;oA=_A*TA+dA*EA+s*Jje}const rA=r*Hje+oA,BA={x:Y.x+B.x*rA,y:Y.y+B.y*rA};yj({ctx:A,text:g,x:BA.x,y:BA.y,fontSize:s,color:D,realToCanvasMat:n,anchorAlignment:"center",rotation:-eA})}}function Tje(e){const{ctx:A,pcbFabricationNoteDimension:t,realToCanvasMat:i,colorMap:n}=e,o=t.color??n.fabricationNote;rCt({ctx:A,from:t.from,to:t.to,realToCanvasMat:i,color:o,fontSize:t.font_size??1,arrowSize:t.arrow_size??1,text:t.text,textRotation:t.text_ccw_rotation,offset:t.offset_distance&&t.offset_direction?{distance:t.offset_distance,direction:t.offset_direction}:void 0})}function A1(e){const{ctx:A,start:t,end:i,strokeWidth:n,stroke:o,realToCanvasMat:s,lineCap:r="round"}=e,[a,g]=ai(s,[t.x,t.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 Pje(e){const{ctx:A,path:t,realToCanvasMat:i,colorMap:n}=e,o=n.fabricationNote,s=t.color??o;if(!(!t.route||t.route.length<2))for(let r=0;r<t.route.length-1;r++){const a=t.route[r],g=t.route[r+1];!a||!g||A1({ctx:A,start:{x:a.x,y:a.y},end:{x:g.x,y:g.y},strokeWidth:t.stroke_width??.1,stroke:s,realToCanvasMat:i})}}function Kje(e){const{ctx:A,rect:t,realToCanvasMat:i,colorMap:n}=e,o=n.fabricationNote,s=t.color??o,r=t.is_filled??!1,a=t.has_stroke??!0,g=t.is_stroke_dashed??!1;AQ({ctx:A,center:t.center,width:t.width,height:t.height,fill:r?s:void 0,stroke:a?s:void 0,strokeWidth:a?t.stroke_width:void 0,borderRadius:t.corner_radius,realToCanvasMat:i,isStrokeDashed:g})}function qje(e,A){return A.fabricationNote}function Oje(e){const{ctx:A,text:t,realToCanvasMat:i,colorMap:n}=e,o=qje(t.layer,n),s=t.color??o,r=t.font_size;yj({ctx:A,text:t.text,x:t.anchor_position.x,y:t.anchor_position.y,fontSize:r,color:s,realToCanvasMat:i,anchorAlignment:t.anchor_alignment})}function sS(e){const{ctx:A,center:t,radius_x:i,radius_y:n,fill:o,stroke:s,strokeWidth:r=.1,realToCanvasMat:a,rotation:g=0}=e,[c,I]=ai(a,[t.x,t.y]),l=i*Math.abs(a.a),B=n*Math.abs(a.a),C=r*Math.abs(a.a);A.save(),A.translate(c,I),g!==0&&A.rotate(-g*(Math.PI/180)),A.beginPath(),A.ellipse(0,0,l,B,0,0,Math.PI*2),o&&(A.fillStyle=o,A.fill()),s&&(A.strokeStyle=s,A.lineWidth=C,A.stroke()),A.restore()}function Ah(e){const{ctx:A,center:t,width:i,height:n,fill:o,realToCanvasMat:s,rotation:r=0,stroke:a,strokeWidth:g}=e,[c,I]=ai(s,[t.x,t.y]),l=i*Math.abs(s.a),B=n*Math.abs(s.a),C=g?g*Math.abs(s.a):void 0;if(A.save(),A.translate(c,I),r!==0&&A.rotate(-r*(Math.PI/180)),A.beginPath(),l>B){const Q=B/2,h=l-B;A.moveTo(-h/2,-Q),A.lineTo(h/2,-Q),A.arc(h/2,0,Q,-Math.PI/2,Math.PI/2),A.lineTo(-h/2,Q),A.arc(-h/2,0,Q,Math.PI/2,-Math.PI/2)}else if(B>l){const Q=l/2,h=B-l;A.moveTo(Q,-h/2),A.lineTo(Q,h/2),A.arc(0,h/2,Q,0,Math.PI),A.lineTo(-Q,-h/2),A.arc(0,-h/2,Q,Math.PI,0)}else A.arc(0,0,l/2,0,Math.PI*2);A.closePath(),o&&(A.fillStyle=o,A.fill()),a&&C&&(A.strokeStyle=a,A.lineWidth=C,A.stroke()),A.restore()}function mj(e){return"ccw_rotation"in e&&typeof e.ccw_rotation=="number"?e.ccw_rotation:0}function aCt(e){const{ctx:A,hole:t,realToCanvasMat:i,colorMap:n,soldermaskMargin:o=0,drawSoldermask:s=!1}=e;if(s&&t.is_covered_with_solder_mask===!0)return;const r=o<0?Math.abs(o):0;if(t.hole_shape==="circle"){tQ({ctx:A,center:{x:t.x,y:t.y},radius:t.hole_diameter/2-r,fill:n.drill,realToCanvasMat:i});return}if(t.hole_shape==="square"){const a=mj(t);AQ({ctx:A,center:{x:t.x,y:t.y},width:t.hole_diameter-r*2,height:t.hole_diameter-r*2,fill:n.drill,realToCanvasMat:i,ccwRotationDegrees:a});return}if(t.hole_shape==="oval"){const a=mj(t);sS({ctx:A,center:{x:t.x,y:t.y},radius_x:t.hole_width/2-r,radius_y:t.hole_height/2-r,fill:n.drill,realToCanvasMat:i,rotation:a});return}if(t.hole_shape==="rect"){const a=mj(t);AQ({ctx:A,center:{x:t.x,y:t.y},width:t.hole_width-r*2,height:t.hole_height-r*2,fill:n.drill,realToCanvasMat:i,ccwRotationDegrees:a});return}if(t.hole_shape==="pill"||t.hole_shape==="rotated_pill"){const a=mj(t);Ah({ctx:A,center:{x:t.x,y:t.y},width:t.hole_width-r*2,height:t.hole_height-r*2,fill:n.drill,realToCanvasMat:i,rotation:a});return}}function Wje(e,A){const t=parseInt(e.slice(1,3),16),i=parseInt(e.slice(3,5),16),n=parseInt(e.slice(5,7),16);return`rgba(${t}, ${i}, ${n}, ${A})`}function Zje(e){const{ctx:A,keepout:t,realToCanvasMat:i,colorMap:n}=e,o=n.keepout,s=Wje(n.keepout,.2),r=1;if(t.shape==="rect"){const[a,g]=ai(i,[t.center.x,t.center.y]),c=t.width*Math.abs(i.a),I=t.height*Math.abs(i.a),l=t.rotation??0;A.save(),A.translate(a,g),l!==0&&A.rotate(-l*(Math.PI/180)),A.beginPath(),A.rect(-c/2,-I/2,c,I),A.fillStyle=s,A.fill(),A.beginPath(),A.rect(-c/2,-I/2,c,I),A.clip();const B=r*Math.abs(i.a),C=Math.sqrt(c*c+I*I),Q=c/2,h=I/2;A.strokeStyle=o,A.lineWidth=.15*Math.abs(i.a),A.setLineDash([]);for(let E=-C;E<C*2;E+=B){A.beginPath();const u=-Q+E,d=-h,f=-Q+E+C,m=-h+C;A.moveTo(u,d),A.lineTo(f,m),A.stroke()}A.restore();return}if(t.shape==="circle"){const[a,g]=ai(i,[t.center.x,t.center.y]),c=t.radius*Math.abs(i.a),I=r*Math.abs(i.a);A.save(),A.translate(a,g),A.beginPath(),A.arc(0,0,c,0,Math.PI*2),A.fillStyle=s,A.fill(),A.beginPath(),A.arc(0,0,c,0,Math.PI*2),A.clip();const l=c*2;A.strokeStyle=o,A.lineWidth=.15*Math.abs(i.a),A.setLineDash([]);for(let B=-l;B<l*2;B+=I)A.beginPath(),A.moveTo(B-l,-l),A.lineTo(B+l,l),A.stroke();A.restore();return}}var Vje="rgba(255,255,255,0.5)";function jje(e){const{ctx:A,pcbNoteDimension:t,realToCanvasMat:i}=e,n=t.color??Vje;rCt({ctx:A,from:t.from,to:t.to,realToCanvasMat:i,color:n,fontSize:t.font_size,arrowSize:t.arrow_size,text:t.text,textRotation:t.text_ccw_rotation,offset:t.offset_distance&&t.offset_direction?{distance:t.offset_distance,direction:t.offset_direction}:void 0})}function zje(e){const{ctx:A,line:t,realToCanvasMat:i}=e,o=t.color??"rgb(89, 148, 220)",s=t.stroke_width??.1,r=t.is_dashed??!1,[a,g]=ai(i,[t.x1,t.y1]),[c,I]=ai(i,[t.x2,t.y2]),l=s*Math.abs(i.a);A.save(),r?A.setLineDash([l*2,l*2]):A.setLineDash([]),A.beginPath(),A.moveTo(a,g),A.lineTo(c,I),A.lineWidth=l,A.strokeStyle=o,A.lineCap="round",A.stroke(),A.restore()}function Xje(e){const{ctx:A,path:t,realToCanvasMat:i}=e,o=t.color??"rgb(89, 148, 220)";if(!(!t.route||t.route.length<2))for(let s=0;s<t.route.length-1;s++){const r=t.route[s],a=t.route[s+1];!r||!a||A1({ctx:A,start:{x:r.x,y:r.y},end:{x:a.x,y:a.y},strokeWidth:t.stroke_width??.1,stroke:o,realToCanvasMat:i})}}function $je(e){const{ctx:A,rect:t,realToCanvasMat:i}=e,o=t.color??"rgb(89, 148, 220)",s=t.is_filled??!1,r=t.has_stroke??!0,a=t.is_stroke_dashed??!1;AQ({ctx:A,center:t.center,width:t.width,height:t.height,fill:s?o:void 0,stroke:r?o:void 0,strokeWidth:r?t.stroke_width:void 0,borderRadius:t.corner_radius,realToCanvasMat:i,isStrokeDashed:a})}var Aze="rgb(89, 148, 220)";function tze(e){const{ctx:A,text:t,realToCanvasMat:i}=e,n=Aze,o=t.color??n,s=t.font_size??1;yj({ctx:A,text:t.text??"",x:t.anchor_position.x,y:t.anchor_position.y,fontSize:s,color:o,realToCanvasMat:i,anchorAlignment:t.anchor_alignment??"center"})}function eze(e){const{ctx:A,panel:t,realToCanvasMat:i,colorMap:n}=e,{width:o,height:s,center:r}=t;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}];fj({ctx:A,points:c,stroke:n.boardOutline,strokeWidth:.5,realToCanvasMat:i,closePath:!0})}}function CT(e,A){if(e.length<3||A===0)return e;let t=0,i=0;for(const o of e)t+=o.x,i+=o.y;t/=e.length,i/=e.length;const n=[];for(const o of e){const s=o.x-t,r=o.y-i,a=Math.sqrt(s*s+r*r);if(a>0){const g=s/a,c=r/a;n.push({x:o.x+g*A,y:o.y+c*A})}else n.push({x:o.x+A,y:o.y})}return n}function gCt(e){const{ctx:A,hole:t,realToCanvasMat:i,colorMap:n,soldermaskMargin:o=0,drawSoldermask:s}=e;if(t.is_covered_with_solder_mask===!0&&s)return;const r=n.copper[e.layer??"top"],a=o<0?Math.abs(o):0;if(t.shape==="circle"){tQ({ctx:A,center:{x:t.x,y:t.y},radius:t.outer_diameter/2-a,fill:r,realToCanvasMat:i}),rS(A,()=>{tQ({ctx:A,center:{x:t.x,y:t.y},radius:t.hole_diameter/2,fill:"#000",realToCanvasMat:i})}),tQ({ctx:A,center:{x:t.x,y:t.y},radius:t.hole_diameter/2,fill:n.drill,realToCanvasMat:i});return}if(t.shape==="oval"){sS({ctx:A,center:{x:t.x,y:t.y},radius_x:t.outer_width/2-a,radius_y:t.outer_height/2-a,fill:r,realToCanvasMat:i,rotation:t.ccw_rotation}),rS(A,()=>{sS({ctx:A,center:{x:t.x,y:t.y},radius_x:t.hole_width/2,radius_y:t.hole_height/2,fill:"#000",realToCanvasMat:i,rotation:t.ccw_rotation})}),sS({ctx:A,center:{x:t.x,y:t.y},radius_x:t.hole_width/2,radius_y:t.hole_height/2,fill:n.drill,realToCanvasMat:i,rotation:t.ccw_rotation});return}if(t.shape==="pill"){Ah({ctx:A,center:{x:t.x,y:t.y},width:t.outer_width-a*2,height:t.outer_height-a*2,fill:r,realToCanvasMat:i,rotation:t.ccw_rotation}),rS(A,()=>{Ah({ctx:A,center:{x:t.x,y:t.y},width:t.hole_width,height:t.hole_height,fill:"#000",realToCanvasMat:i,rotation:t.ccw_rotation})}),Ah({ctx:A,center:{x:t.x,y:t.y},width:t.hole_width,height:t.hole_height,fill:n.drill,realToCanvasMat:i,rotation:t.ccw_rotation});return}if(t.shape==="circular_hole_with_rect_pad"){AQ({ctx:A,center:{x:t.x,y:t.y},width:t.rect_pad_width-a*2,height:t.rect_pad_height-a*2,fill:r,realToCanvasMat:i,borderRadius:t.rect_border_radius?Math.max(0,t.rect_border_radius-a):0,ccwRotationDegrees:t.rect_ccw_rotation});const g=t.x+(t.hole_offset_x??0),c=t.y+(t.hole_offset_y??0);rS(A,()=>{tQ({ctx:A,center:{x:g,y:c},radius:t.hole_diameter/2,fill:"#000",realToCanvasMat:i})}),tQ({ctx:A,center:{x:g,y:c},radius:t.hole_diameter/2,fill:n.drill,realToCanvasMat:i});return}if(t.shape==="pill_hole_with_rect_pad"){AQ({ctx:A,center:{x:t.x,y:t.y},width:t.rect_pad_width-a*2,height:t.rect_pad_height-a*2,fill:r,realToCanvasMat:i,borderRadius:t.rect_border_radius?Math.max(0,t.rect_border_radius-a):0});const g=t.x+(t.hole_offset_x??0),c=t.y+(t.hole_offset_y??0);rS(A,()=>{Ah({ctx:A,center:{x:g,y:c},width:t.hole_width,height:t.hole_height,fill:"#000",realToCanvasMat:i})}),Ah({ctx:A,center:{x:g,y:c},width:t.hole_width,height:t.hole_height,fill:n.drill,realToCanvasMat:i});return}if(t.shape==="rotated_pill_hole_with_rect_pad"){AQ({ctx:A,center:{x:t.x,y:t.y},width:t.rect_pad_width-a*2,height:t.rect_pad_height-a*2,fill:r,realToCanvasMat:i,borderRadius:t.rect_border_radius?Math.max(0,t.rect_border_radius-a):0,ccwRotationDegrees:t.rect_ccw_rotation});const g=t.x+(t.hole_offset_x??0),c=t.y+(t.hole_offset_y??0);rS(A,()=>{Ah({ctx:A,center:{x:g,y:c},width:t.hole_width,height:t.hole_height,fill:"#000",realToCanvasMat:i,rotation:t.hole_ccw_rotation})}),Ah({ctx:A,center:{x:g,y:c},width:t.hole_width,height:t.hole_height,fill:n.drill,realToCanvasMat:i,rotation:t.hole_ccw_rotation});return}if(t.shape==="hole_with_polygon_pad"){const g=t.pad_outline;if(g&&g.length>=3){const B=g.map(Q=>({x:t.x+Q.x,y:t.y+Q.y})),C=a>0?CT(B,-a):B;C.length>=3&&Fk({ctx:A,points:C,fill:r,realToCanvasMat:i})}const c=t.x+(t.hole_offset_x??0),I=t.y+(t.hole_offset_y??0),l=t.hole_shape;l==="circle"?(rS(A,()=>{tQ({ctx:A,center:{x:c,y:I},radius:(t.hole_diameter??0)/2,fill:"#000",realToCanvasMat:i})}),tQ({ctx:A,center:{x:c,y:I},radius:(t.hole_diameter??0)/2,fill:n.drill,realToCanvasMat:i})):l==="oval"?(rS(A,()=>{sS({ctx:A,center:{x:c,y:I},radius_x:(t.hole_width??0)/2,radius_y:(t.hole_height??0)/2,fill:"#000",realToCanvasMat:i})}),sS({ctx:A,center:{x:c,y:I},radius_x:(t.hole_width??0)/2,radius_y:(t.hole_height??0)/2,fill:n.drill,realToCanvasMat:i})):l==="pill"?(rS(A,()=>{Ah({ctx:A,center:{x:c,y:I},width:t.hole_width??0,height:t.hole_height??0,fill:"#000",realToCanvasMat:i})}),Ah({ctx:A,center:{x:c,y:I},width:t.hole_width??0,height:t.hole_height??0,fill:n.drill,realToCanvasMat:i})):l==="rotated_pill"&&(rS(A,()=>{Ah({ctx:A,center:{x:c,y:I},width:t.hole_width??0,height:t.hole_height??0,fill:"#000",realToCanvasMat:i})}),Ah({ctx:A,center:{x:c,y:I},width:t.hole_width??0,height:t.hole_height??0,fill:n.drill,realToCanvasMat:i}));return}}function rS(e,A){e.save(),e.globalCompositeOperation="destination-out",A(),e.restore()}function ize(e,A){return e==="bottom"?A.silkscreen.bottom:A.silkscreen.top}function nze(e){const{ctx:A,circle:t,realToCanvasMat:i,colorMap:n}=e,o=ize(t.layer,n);tQ({ctx:A,center:t.center,radius:t.radius,stroke:o,strokeWidth:t.stroke_width,realToCanvasMat:i})}function oze(e,A){return e==="bottom"?A.silkscreen.bottom:A.silkscreen.top}function sze(e){const{ctx:A,line:t,realToCanvasMat:i,colorMap:n}=e,o=oze(t.layer,n);A1({ctx:A,start:{x:t.x1,y:t.y1},end:{x:t.x2,y:t.y2},strokeWidth:t.stroke_width??.1,stroke:o,realToCanvasMat:i})}function rze(e,A){return e==="bottom"?A.silkscreen.bottom:A.silkscreen.top}function aze(e){const{ctx:A,oval:t,realToCanvasMat:i,colorMap:n}=e,o=rze(t.layer,n);sS({ctx:A,center:t.center,radius_x:t.radius_x,radius_y:t.radius_y,stroke:o,strokeWidth:.1,realToCanvasMat:i,rotation:t.ccw_rotation??0})}function gze(e,A){return e==="bottom"?A.silkscreen.bottom:A.silkscreen.top}function cze(e){const{ctx:A,path:t,realToCanvasMat:i,colorMap:n}=e,o=gze(t.layer,n);if(!(!t.route||t.route.length<2))for(let s=0;s<t.route.length-1;s++){const r=t.route[s],a=t.route[s+1];!r||!a||A1({ctx:A,start:{x:r.x,y:r.y},end:{x:a.x,y:a.y},strokeWidth:t.stroke_width??.1,stroke:o,realToCanvasMat:i})}}function Ize(e,A){return e==="bottom"?A.silkscreen.bottom:A.silkscreen.top}function lze(e){const{ctx:A,pill:t,realToCanvasMat:i,colorMap:n}=e,o=Ize(t.layer,n);Ah({ctx:A,center:t.center,width:t.width,height:t.height,stroke:o,strokeWidth:.2,realToCanvasMat:i})}function Bze(e,A){return e==="bottom"?A.silkscreen.bottom:A.silkscreen.top}function Cze(e){const{ctx:A,rect:t,realToCanvasMat:i,colorMap:n}=e,o=Bze(t.layer,n);AQ({ctx:A,center:t.center,width:t.width,height:t.height,fill:t.is_filled?o:"transparent",stroke:o,strokeWidth:t.stroke_width,realToCanvasMat:i})}function Qze(e,A){return e==="bottom"?A.silkscreen.bottom:A.silkscreen.top}function hze(e){return e||"center"}function Eze(e){const{ctx:A,text:t,realToCanvasMat:i,colorMap:n}=e,o=t.text??"";if(!o)return;const s=Qze(t.layer,n),r=hze(t.anchor_alignment),a=t.font_size??1;yj({ctx:A,text:o,x:t.anchor_position.x,y:t.anchor_position.y,fontSize:a,color:s,realToCanvasMat:i,anchorAlignment:r,rotation:t.ccw_rotation??0,mirrorX:t.layer==="bottom",knockout:t.is_knockout,knockoutPadding:t.is_knockout?t.knockout_padding:void 0})}function uze(e,A){return A.copper[e]??A.copper.top}function cCt(e){return e.shape==="rect"||e.shape==="rotated_rect"?e.corner_radius??e.rect_border_radius??0:0}function dze(e){const{ctx:A,pad:t,realToCanvasMat:i,colorMap:n}=e,o=uze(t.layer,n);if(t.shape==="rect"){AQ({ctx:A,center:{x:t.x,y:t.y},width:t.width,height:t.height,fill:o,realToCanvasMat:i,borderRadius:cCt(t)});return}if(t.shape==="rotated_rect"){AQ({ctx:A,center:{x:t.x,y:t.y},width:t.width,height:t.height,fill:o,realToCanvasMat:i,borderRadius:cCt(t),ccwRotationDegrees:t.ccw_rotation??0});return}if(t.shape==="circle"){tQ({ctx:A,center:{x:t.x,y:t.y},radius:t.radius,fill:o,realToCanvasMat:i});return}if(t.shape==="pill"){Ah({ctx:A,center:{x:t.x,y:t.y},width:t.width,height:t.height,fill:o,realToCanvasMat:i});return}if(t.shape==="rotated_pill"){Ah({ctx:A,center:{x:t.x,y:t.y},width:t.width,height:t.height,fill:o,realToCanvasMat:i,rotation:t.ccw_rotation??0});return}if(t.shape==="polygon"){t.points&&t.points.length>=3&&Fk({ctx:A,points:t.points,fill:o,realToCanvasMat:i});return}}function Mk(e){const{ctx:A,points:t}=e;if(t.length<3)return;const i=t[0];if(i){A.moveTo(i.x,i.y);for(let n=1;n<t.length;n++){const o=t[n];o&&A.lineTo(o.x,o.y)}A.closePath()}}function ICt(e){const{ctx:A,board:t,realToCanvasMat:i,soldermaskColor:n}=e,{width:o,height:s,center:r,outline:a}=t;if(a&&Array.isArray(a)&&a.length>=3){const g=a.map(c=>{const[I,l]=ai(i,[c.x,c.y]);return{x:I,y:l}});A.beginPath(),Mk({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 pze(e){return"createPattern"in e&&typeof Reflect.get(e,"createPattern")=="function"}function fze(e,A){if(e===A||A.canvas.width<=0||A.canvas.height<=0||!pze(e))return;let t=null;try{t=e.createPattern(A.canvas,"no-repeat")}catch{return}t&&(e.save(),e.globalCompositeOperation="source-over",e.fillStyle=t,e.fillRect(0,0,A.canvas.width,A.canvas.height),e.restore())}function yze(e){return typeof e=="function"}function mze(e,A,t){if(A<=0||t<=0)return null;const i=globalThis;let n=null;if("OffscreenCanvas"in i&&typeof i.OffscreenCanvas=="function")n=new i.OffscreenCanvas(A,t);else if("document"in i&&i.document&&typeof i.document.createElement=="function"){const o=i.document.createElement("canvas");o.width=A,o.height=t,n=o}else{const o=e.canvas.constructor;if(yze(o))try{n=new o(A,t)}catch{return null}}return n?n.getContext("2d"):null}function wze(e){const{ctx:A,panel:t,realToCanvasMat:i,soldermaskColor:n}=e,{width:o,height:s,center:r}=t;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 z0(e){const{ctx:A,cx:t,cy:i,width:n,height:o,radius:s,ccwRotationDegrees:r=0}=e,a=r*Math.PI/180,g=T0A(vk(t,i),tCt(-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 X0(e){e.save(),e.globalCompositeOperation="destination-out",e.fill(),e.restore()}function Dze(e){const{ctx:A,cutout:t,realToCanvasMat:i}=e;if(t.shape==="rect"){const[n,o]=ai(i,[t.center?.x??0,t.center?.y??0]),s=t.width*Math.abs(i.a),r=t.height*Math.abs(i.a),a=(t.corner_radius??0)*Math.abs(i.a);A.save(),A.translate(n,o),t.rotation&&A.rotate(-t.rotation*Math.PI/180),A.beginPath(),z0({ctx:A,cx:0,cy:0,width:s,height:r,radius:a}),A.restore(),X0(A)}else if(t.shape==="circle"){const[n,o]=ai(i,[t.center?.x??0,t.center?.y??0]),s=t.radius*Math.abs(i.a);A.beginPath(),A.arc(n,o,s,0,Math.PI*2),A.closePath(),X0(A)}else if(t.shape==="polygon"&&t.points&&t.points.length>=3){const n=t.points.map(o=>{const[s,r]=ai(i,[o.x,o.y]);return{x:s,y:r}});A.beginPath(),Mk({ctx:A,points:n}),X0(A)}}var zh="rgba(255, 255, 255, 1)";function O0A(e){const{ctx:A,elements:t,layer:i,realToCanvasMat:n}=e;A.save(),A.globalCompositeOperation="destination-out";for(const o of t){if(o.type==="pcb_smtpad"){if(o.layer!==i||o.is_covered_with_solder_mask===!0)continue;Sze({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;bze({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:zh,realToCanvasMat:n});continue}if(o.type==="pcb_hole"){if(o.is_covered_with_solder_mask===!0)continue;xze({ctx:A,hole:o,realToCanvasMat:n})}}A.restore()}function Sze(e){const{ctx:A,pad:t,realToCanvasMat:i}=e;if(t.shape==="rect"){AQ({ctx:A,center:{x:t.x,y:t.y},width:t.width,height:t.height,borderRadius:t.corner_radius??t.rect_border_radius??0,fill:zh,realToCanvasMat:i});return}if(t.shape==="rotated_rect"){AQ({ctx:A,center:{x:t.x,y:t.y},width:t.width,height:t.height,borderRadius:t.corner_radius??t.rect_border_radius??0,ccwRotationDegrees:t.ccw_rotation??0,fill:zh,realToCanvasMat:i});return}if(t.shape==="circle"){tQ({ctx:A,center:{x:t.x,y:t.y},radius:t.radius,fill:zh,realToCanvasMat:i});return}if(t.shape==="pill"||t.shape==="rotated_pill"){Ah({ctx:A,center:{x:t.x,y:t.y},width:t.width,height:t.height,rotation:t.shape==="rotated_pill"?t.ccw_rotation??0:0,fill:zh,realToCanvasMat:i});return}t.shape==="polygon"&&t.points&&t.points.length>=3&&Fk({ctx:A,points:t.points,fill:zh,realToCanvasMat:i})}function bze(e){const{ctx:A,hole:t,realToCanvasMat:i}=e;if(t.shape==="circle"){tQ({ctx:A,center:{x:t.x,y:t.y},radius:t.outer_diameter/2,fill:zh,realToCanvasMat:i});return}if(t.shape==="oval"){sS({ctx:A,center:{x:t.x,y:t.y},radius_x:t.outer_width/2,radius_y:t.outer_height/2,rotation:t.ccw_rotation,fill:zh,realToCanvasMat:i});return}if(t.shape==="pill"){Ah({ctx:A,center:{x:t.x,y:t.y},width:t.outer_width,height:t.outer_height,rotation:t.ccw_rotation,fill:zh,realToCanvasMat:i});return}if(t.shape==="circular_hole_with_rect_pad"){AQ({ctx:A,center:{x:t.x,y:t.y},width:t.rect_pad_width,height:t.rect_pad_height,borderRadius:t.rect_border_radius??0,ccwRotationDegrees:t.rect_ccw_rotation,fill:zh,realToCanvasMat:i});return}if(t.shape==="pill_hole_with_rect_pad"){AQ({ctx:A,center:{x:t.x,y:t.y},width:t.rect_pad_width,height:t.rect_pad_height,borderRadius:t.rect_border_radius??0,fill:zh,realToCanvasMat:i});return}if(t.shape==="rotated_pill_hole_with_rect_pad"){AQ({ctx:A,center:{x:t.x,y:t.y},width:t.rect_pad_width,height:t.rect_pad_height,borderRadius:t.rect_border_radius??0,ccwRotationDegrees:t.rect_ccw_rotation,fill:zh,realToCanvasMat:i});return}t.shape==="hole_with_polygon_pad"&&t.pad_outline&&t.pad_outline.length>=3&&Fk({ctx:A,points:t.pad_outline.map(n=>({x:t.x+n.x,y:t.y+n.y})),fill:zh,realToCanvasMat:i})}function xze(e){const{ctx:A,hole:t,realToCanvasMat:i}=e,n="ccw_rotation"in t&&typeof t.ccw_rotation=="number"?t.ccw_rotation:0;if(t.hole_shape==="circle"){tQ({ctx:A,center:{x:t.x,y:t.y},radius:t.hole_diameter/2,fill:zh,realToCanvasMat:i});return}if(t.hole_shape==="square"){AQ({ctx:A,center:{x:t.x,y:t.y},width:t.hole_diameter,height:t.hole_diameter,ccwRotationDegrees:n,fill:zh,realToCanvasMat:i});return}if(t.hole_shape==="oval"){sS({ctx:A,center:{x:t.x,y:t.y},radius_x:t.hole_width/2,radius_y:t.hole_height/2,rotation:n,fill:zh,realToCanvasMat:i});return}if(t.hole_shape==="rect"){AQ({ctx:A,center:{x:t.x,y:t.y},width:t.hole_width,height:t.hole_height,ccwRotationDegrees:n,fill:zh,realToCanvasMat:i});return}(t.hole_shape==="pill"||t.hole_shape==="rotated_pill")&&Ah({ctx:A,center:{x:t.x,y:t.y},width:t.hole_width,height:t.hole_height,rotation:n,fill:zh,realToCanvasMat:i})}function _ze(e,A,t,i,n){if(Math.abs(n)<1e-10)return null;const o=t-e,s=i-A,r=Math.hypot(o,s);if(r<1e-10)return null;const a=Math.abs(n)*(r/2),g=r/2,c=(a*a+g*g)/(2*a),I=c-a,l=(e+t)/2,B=(A+i)/2,C=-s/r,Q=o/r,h=n>0?-1:1;return{centerX:l+h*C*I,centerY:B+h*Q*I,radius:c}}function W0A(e,A,t,i,n,o,s){if(Math.abs(o)<1e-10){const[f,m]=ai(s,[i,n]);e.lineTo(f,m);return}const r=_ze(A,t,i,n,o);if(!r){const[f,m]=ai(s,[i,n]);e.lineTo(f,m);return}const[a,g]=ai(s,[A,t]),[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;e.arc(l,B,C,Q,h,d)}function lCt(e,A,t){if(A.vertices.length<2)return;if(A.vertices.length===2){const s=A.vertices[0],r=A.vertices[1];if(s&&r&&Math.abs((s.bulge??0)-1)<1e-10&&Math.abs((r.bulge??0)-1)<1e-10){const[a,g]=ai(t,[s.x,s.y]);e.moveTo(a,g),W0A(e,s.x,s.y,r.x,r.y,1,t),W0A(e,r.x,r.y,s.x,s.y,1,t);return}}const i=A.vertices[0];if(!i)return;const[n,o]=ai(t,[i.x,i.y]);e.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(t,[a.x,a.y]);e.lineTo(c,I)}else W0A(e,r.x,r.y,a.x,a.y,g,t)}}function kze(e){const{ctx:A,pour:t,realToCanvasMat:i,soldermaskOverCopperColor:n,layer:o,elements:s}=e;if(t.layer===o&&t.covered_with_solder_mask===!0){if(A.save(),A.fillStyle=n,t.shape==="rect"){const[r,a]=ai(i,[t.center.x,t.center.y]),g=t.width*Math.abs(i.a),c=t.height*Math.abs(i.a);A.translate(r,a),t.rotation&&A.rotate(-t.rotation*(Math.PI/180)),A.beginPath(),A.rect(-g/2,-c/2,g,c),A.fill(),A.restore(),O0A({ctx:A,elements:s,layer:o,realToCanvasMat:i});return}if(t.shape==="polygon"){if(t.points&&t.points.length>=3){const r=t.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(),O0A({ctx:A,elements:s,layer:o,realToCanvasMat:i})}}A.restore();return}if(t.shape==="brep"){if(A.beginPath(),lCt(A,t.brep_shape.outer_ring,i),t.brep_shape.inner_rings)for(const r of t.brep_shape.inner_rings)lCt(A,r,i);A.fill("evenodd"),O0A({ctx:A,elements:s,layer:o,realToCanvasMat:i}),A.restore();return}A.restore()}}function Zb(e){const{ctx:A,cx:t,cy:i,width:n,height:o,ccwRotationDegrees:s=0}=e,r=s*Math.PI/180,a=T0A(vk(t,i),tCt(-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(t+g,i),A.arc(t,i,g,0,Math.PI*2)}A.closePath()}function vze(e){const{ctx:A,hole:t,realToCanvasMat:i,soldermaskOverCopperColor:n}=e,o=t.is_covered_with_solder_mask===!0,s=t.soldermask_margin??0;o?(A.fillStyle=n,wj({ctx:A,hole:t,realToCanvasMat:i,margin:0}),A.fill()):s<0?(wj({ctx:A,hole:t,realToCanvasMat:i,margin:s}),X0(A),Fze({ctx:A,hole:t,realToCanvasMat:i,soldermaskOverCopperColor:n,margin:s})):s>0?(wj({ctx:A,hole:t,realToCanvasMat:i,margin:s}),X0(A)):(wj({ctx:A,hole:t,realToCanvasMat:i,margin:0}),X0(A))}function BCt(e){return"ccw_rotation"in e&&typeof e.ccw_rotation=="number"?e.ccw_rotation:0}function wj(e){const{ctx:A,hole:t,realToCanvasMat:i,margin:n}=e,o=BCt(t);if(t.hole_shape==="circle"){const[s,r]=ai(i,[t.x,t.y]),a=(t.hole_diameter/2+n)*Math.abs(i.a);A.beginPath(),A.arc(s,r,a,0,Math.PI*2),A.closePath()}else if(t.hole_shape==="square"){const[s,r]=ai(i,[t.x,t.y]),a=(t.hole_diameter+n*2)*Math.abs(i.a);A.save(),A.translate(s,r),o!==0&&A.rotate(-o*Math.PI/180),A.beginPath(),A.rect(-a/2,-a/2,a,a),A.closePath(),A.restore()}else if(t.hole_shape==="oval"){const[s,r]=ai(i,[t.x,t.y]),a=(t.hole_width/2+n)*Math.abs(i.a),g=(t.hole_height/2+n)*Math.abs(i.a);A.save(),A.translate(s,r),o!==0&&A.rotate(-o*Math.PI/180),A.beginPath(),A.ellipse(0,0,a,g,0,0,Math.PI*2),A.closePath(),A.restore()}else if(t.hole_shape==="rect"){const[s,r]=ai(i,[t.x,t.y]),a=(t.hole_width+n*2)*Math.abs(i.a),g=(t.hole_height+n*2)*Math.abs(i.a);A.save(),A.translate(s,r),o!==0&&A.rotate(-o*Math.PI/180),A.beginPath(),A.rect(-a/2,-g/2,a,g),A.closePath(),A.restore()}else if(t.hole_shape==="pill"||t.hole_shape==="rotated_pill"){const[s,r]=ai(i,[t.x,t.y]),a=(t.hole_width+n*2)*Math.abs(i.a),g=(t.hole_height+n*2)*Math.abs(i.a);A.save(),A.translate(s,r),o!==0&&A.rotate(-o*Math.PI/180),A.beginPath(),Zb({ctx:A,cx:0,cy:0,width:a,height:g}),A.restore()}}function Fze(e){const{ctx:A,hole:t,realToCanvasMat:i,soldermaskOverCopperColor:n,margin:o}=e,s=Math.abs(o),r=BCt(t);if(A.fillStyle=n,t.hole_shape==="circle"){const[a,g]=ai(i,[t.x,t.y]),c=t.hole_diameter/2*Math.abs(i.a),I=s*Math.abs(i.a),l=Math.max(0,c-I);A.save(),A.beginPath(),A.arc(a,g,c,0,Math.PI*2),l>0&&A.arc(a,g,l,0,Math.PI*2,!0),A.fill("evenodd"),A.restore()}else if(t.hole_shape==="square"){const[a,g]=ai(i,[t.x,t.y]),c=t.hole_diameter*Math.abs(i.a),I=s*Math.abs(i.a),l=Math.max(0,c-I*2);A.save(),A.translate(a,g),r!==0&&A.rotate(-r*Math.PI/180),A.beginPath(),A.rect(-c/2,-c/2,c,c),l>0&&A.rect(-l/2,-l/2,l,l),A.fill("evenodd"),A.restore()}else if(t.hole_shape==="oval"){const[a,g]=ai(i,[t.x,t.y]),c=t.hole_width/2*Math.abs(i.a),I=t.hole_height/2*Math.abs(i.a),l=s*Math.abs(i.a),B=Math.max(0,c-l),C=Math.max(0,I-l);A.save(),A.translate(a,g),r!==0&&A.rotate(-r*Math.PI/180),A.beginPath(),A.ellipse(0,0,c,I,0,0,Math.PI*2),B>0&&C>0&&(A.moveTo(B,0),A.ellipse(0,0,B,C,0,0,Math.PI*2)),A.fill("evenodd"),A.restore()}else if(t.hole_shape==="rect"){const[a,g]=ai(i,[t.x,t.y]),c=t.hole_width*Math.abs(i.a),I=t.hole_height*Math.abs(i.a),l=s*Math.abs(i.a),B=Math.max(0,c-l*2),C=Math.max(0,I-l*2);A.save(),A.translate(a,g),r!==0&&A.rotate(-r*Math.PI/180),A.beginPath(),A.rect(-c/2,-I/2,c,I),B>0&&C>0&&A.rect(-B/2,-C/2,B,C),A.fill("evenodd"),A.restore()}else if(t.hole_shape==="pill"||t.hole_shape==="rotated_pill"){const[a,g]=ai(i,[t.x,t.y]),c=t.hole_width*Math.abs(i.a),I=t.hole_height*Math.abs(i.a),l=s*Math.abs(i.a);A.save(),A.translate(a,g),r!==0&&A.rotate(-r*Math.PI/180),A.beginPath(),Zb({ctx:A,cx:0,cy:0,width:c,height:I});const B=c-l*2,C=I-l*2;B>0&&C>0&&Zb({ctx:A,cx:0,cy:0,width:B,height:C}),A.fill("evenodd"),A.restore()}}function Mze(e){const{ctx:A,hole:t,realToCanvasMat:i,soldermaskOverCopperColor:n,layer:o}=e;if(t.layers&&!t.layers.includes(o))return;const s=t.is_covered_with_solder_mask===!0,r=t.soldermask_margin??0;s?(A.fillStyle=n,Dj({ctx:A,hole:t,realToCanvasMat:i,margin:0}),A.fill()):r<0?(Dj({ctx:A,hole:t,realToCanvasMat:i,margin:r}),X0(A),Gze({ctx:A,hole:t,realToCanvasMat:i,soldermaskOverCopperColor:n,margin:r})):r>0?(Dj({ctx:A,hole:t,realToCanvasMat:i,margin:r}),X0(A)):(Dj({ctx:A,hole:t,realToCanvasMat:i,margin:0}),X0(A))}function Dj(e){const{ctx:A,hole:t,realToCanvasMat:i,margin:n}=e;if(t.shape==="circle"){const[o,s]=ai(i,[t.x,t.y]),r=(t.outer_diameter/2+n)*Math.abs(i.a);A.beginPath(),A.arc(o,s,r,0,Math.PI*2),A.closePath()}else if(t.shape==="oval"){const[o,s]=ai(i,[t.x,t.y]),r=(t.outer_width/2+n)*Math.abs(i.a),a=(t.outer_height/2+n)*Math.abs(i.a);A.beginPath(),A.ellipse(o,s,r,a,-((t.ccw_rotation??0)*Math.PI)/180,0,Math.PI*2),A.closePath()}else if(t.shape==="pill"){const[o,s]=ai(i,[t.x,t.y]),r=(t.outer_width+n*2)*Math.abs(i.a),a=(t.outer_height+n*2)*Math.abs(i.a);A.beginPath(),Zb({ctx:A,cx:o,cy:s,width:r,height:a,ccwRotationDegrees:t.ccw_rotation})}else if(t.shape==="circular_hole_with_rect_pad"){const[o,s]=ai(i,[t.x,t.y]),r=(t.rect_pad_width+n*2)*Math.abs(i.a),a=(t.rect_pad_height+n*2)*Math.abs(i.a),g=(t.rect_border_radius??0)*Math.abs(i.a);A.beginPath(),z0({ctx:A,cx:o,cy:s,width:r,height:a,radius:g,ccwRotationDegrees:t.rect_ccw_rotation})}else if(t.shape==="pill_hole_with_rect_pad"){const[o,s]=ai(i,[t.x,t.y]),r=(t.rect_pad_width+n*2)*Math.abs(i.a),a=(t.rect_pad_height+n*2)*Math.abs(i.a),g=(t.rect_border_radius??0)*Math.abs(i.a);A.beginPath(),z0({ctx:A,cx:o,cy:s,width:r,height:a,radius:g})}else if(t.shape==="rotated_pill_hole_with_rect_pad"){const[o,s]=ai(i,[t.x,t.y]),r=(t.rect_pad_width+n*2)*Math.abs(i.a),a=(t.rect_pad_height+n*2)*Math.abs(i.a),g=(t.rect_border_radius??0)*Math.abs(i.a);A.beginPath(),z0({ctx:A,cx:o,cy:s,width:r,height:a,radius:g,ccwRotationDegrees:t.rect_ccw_rotation})}else if(t.shape==="hole_with_polygon_pad"&&t.pad_outline&&t.pad_outline.length>=3){const o=t.pad_outline.map(a=>({x:t.x+a.x,y:t.y+a.y})),r=(n!==0?CT(o,n):o).map(a=>{const[g,c]=ai(i,[a.x,a.y]);return{x:g,y:c}});A.beginPath(),Mk({ctx:A,points:r})}}function Gze(e){const{ctx:A,hole:t,realToCanvasMat:i,soldermaskOverCopperColor:n,margin:o}=e,s=Math.abs(o);if(A.fillStyle=n,t.shape==="circle"){const[r,a]=ai(i,[t.x,t.y]),g=t.outer_diameter/2*Math.abs(i.a),c=s*Math.abs(i.a),I=Math.max(0,g-c);A.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(t.shape==="oval"){const[r,a]=ai(i,[t.x,t.y]),g=t.outer_width/2*Math.abs(i.a),c=t.outer_height/2*Math.abs(i.a),I=s*Math.abs(i.a),l=Math.max(0,g-I),B=Math.max(0,c-I),C=-((t.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(t.shape==="pill"){const[r,a]=ai(i,[t.x,t.y]),g=t.outer_width*Math.abs(i.a),c=t.outer_height*Math.abs(i.a),I=s*Math.abs(i.a);A.beginPath(),Zb({ctx:A,cx:r,cy:a,width:g,height:c,ccwRotationDegrees:t.ccw_rotation});const l=g-I*2,B=c-I*2;l>0&&B>0&&Zb({ctx:A,cx:r,cy:a,width:l,height:B,ccwRotationDegrees:t.ccw_rotation}),A.fill("evenodd")}else if(t.shape==="circular_hole_with_rect_pad"){const[r,a]=ai(i,[t.x,t.y]),g=t.rect_pad_width*Math.abs(i.a),c=t.rect_pad_height*Math.abs(i.a),I=s*Math.abs(i.a),l=t.rect_border_radius?t.rect_border_radius*Math.abs(i.a):0;A.beginPath(),z0({ctx:A,cx:r,cy:a,width:g,height:c,radius:l,ccwRotationDegrees:t.rect_ccw_rotation});const B=g-I*2,C=c-I*2;if(B>0&&C>0){const Q=Math.max(0,l-I);z0({ctx:A,cx:r,cy:a,width:B,height:C,radius:Q,ccwRotationDegrees:t.rect_ccw_rotation})}A.fill("evenodd")}else if(t.shape==="pill_hole_with_rect_pad"){const[r,a]=ai(i,[t.x,t.y]),g=t.rect_pad_width*Math.abs(i.a),c=t.rect_pad_height*Math.abs(i.a),I=s*Math.abs(i.a),l=t.rect_border_radius?t.rect_border_radius*Math.abs(i.a):0;A.beginPath(),z0({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);z0({ctx:A,cx:r,cy:a,width:B,height:C,radius:Q})}A.fill("evenodd")}else if(t.shape==="rotated_pill_hole_with_rect_pad"){const[r,a]=ai(i,[t.x,t.y]),g=t.rect_pad_width*Math.abs(i.a),c=t.rect_pad_height*Math.abs(i.a),I=s*Math.abs(i.a),l=t.rect_border_radius?t.rect_border_radius*Math.abs(i.a):0;A.beginPath(),z0({ctx:A,cx:r,cy:a,width:g,height:c,radius:l,ccwRotationDegrees:t.rect_ccw_rotation});const B=g-I*2,C=c-I*2;if(B>0&&C>0){const Q=Math.max(0,l-I);z0({ctx:A,cx:r,cy:a,width:B,height:C,radius:Q,ccwRotationDegrees:t.rect_ccw_rotation})}A.fill("evenodd")}else if(t.shape==="hole_with_polygon_pad"&&t.pad_outline&&t.pad_outline.length>=3){const r=t.pad_outline.map(c=>({x:t.x+c.x,y:t.y+c.y}));A.beginPath();const a=r.map(c=>{const[I,l]=ai(i,[c.x,c.y]);return{x:I,y:l}});Mk({ctx:A,points:a});const g=CT(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}});Mk({ctx:A,points:c})}A.fill("evenodd")}}function Rze(e){const{ctx:A,pad:t,realToCanvasMat:i,soldermaskOverCopperColor:n,layer:o}=e;if(t.layer!==o)return;const s=t.is_covered_with_solder_mask===!0,r=t.soldermask_margin??0;let a=r,g=r,c=r,I=r;(t.shape==="rect"||t.shape==="rotated_rect")&&(a=t.soldermask_margin_left??r,g=t.soldermask_margin_right??r,c=t.soldermask_margin_top??r,I=t.soldermask_margin_bottom??r),s?(A.fillStyle=n,Sj({ctx:A,pad:t,realToCanvasMat:i,ml:0,mr:0,mt:0,mb:0}),A.fill()):a<0||g<0||c<0||I<0?(Sj({ctx:A,pad:t,realToCanvasMat:i,ml:a,mr:g,mt:c,mb:I}),X0(A),Nze({ctx:A,pad:t,realToCanvasMat:i,soldermaskOverCopperColor:n,ml:a,mr:g,mt:c,mb:I})):a>0||g>0||c>0||I>0?(Sj({ctx:A,pad:t,realToCanvasMat:i,ml:a,mr:g,mt:c,mb:I}),X0(A)):(Sj({ctx:A,pad:t,realToCanvasMat:i,ml:0,mr:0,mt:0,mb:0}),X0(A))}function Sj(e){const{ctx:A,pad:t,realToCanvasMat:i,ml:n,mr:o,mt:s,mb:r}=e,a=t.shape==="rotated_rect"||t.shape==="rotated_pill"?t.ccw_rotation??0:0;if(t.shape==="rect"||t.shape==="rotated_rect"){const g=t.corner_radius??t.rect_border_radius??0,c=a*Math.PI/180,I=(o-n)/2,l=(s-r)/2,B=I*Math.cos(c)-l*Math.sin(c),C=I*Math.sin(c)+l*Math.cos(c),[Q,h]=ai(i,[t.x+B,t.y+C]),E=(t.width+n+o)*Math.abs(i.a),u=(t.height+s+r)*Math.abs(i.a),d=g*Math.abs(i.a);A.save(),A.translate(Q,h),a!==0&&A.rotate(-a*Math.PI/180),A.beginPath(),z0({ctx:A,cx:0,cy:0,width:E,height:u,radius:d}),A.restore()}else if(t.shape==="circle"){const g=(n+o+s+r)/4,[c,I]=ai(i,[t.x,t.y]),l=(t.radius+g)*Math.abs(i.a);A.beginPath(),A.arc(c,I,l,0,Math.PI*2),A.closePath()}else if(t.shape==="pill"||t.shape==="rotated_pill"){const g=(n+o)/2,[c,I]=ai(i,[t.x,t.y]),l=(t.width+g*2)*Math.abs(i.a),B=(t.height+g*2)*Math.abs(i.a);A.save(),A.translate(c,I),a!==0&&A.rotate(-a*Math.PI/180),A.beginPath(),Zb({ctx:A,cx:0,cy:0,width:l,height:B}),A.restore()}else if(t.shape==="polygon"&&t.points&&t.points.length>=3){const g=(n+o+s+r)/4,I=(g!==0?CT(t.points,g):t.points).map(l=>{const[B,C]=ai(i,[l.x,l.y]);return{x:B,y:C}});A.beginPath(),Mk({ctx:A,points:I})}}function Nze(e){const{ctx:A,pad:t,realToCanvasMat:i,soldermaskOverCopperColor:n,ml:o,mr:s,mt:r,mb:a}=e,g=t.shape==="rotated_rect"||t.shape==="rotated_pill"?t.ccw_rotation??0:0,c=Math.max(0,-o),I=Math.max(0,-s),l=Math.max(0,-r),B=Math.max(0,-a);if(A.fillStyle=n,t.shape==="rect"||t.shape==="rotated_rect"){const C=t.corner_radius??t.rect_border_radius??0,[Q,h]=ai(i,[t.x,t.y]),E=t.width*Math.abs(i.a),u=t.height*Math.abs(i.a),d=C*Math.abs(i.a),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(),z0({ctx:A,cx:0,cy:0,width:E,height:u,radius:d});const S=E-f-m,_=u-w-D,b=(f-m)/2,R=(w-D)/2,F=Math.max(0,d-(f+m+w+D)/4);S>0&&_>0&&z0({ctx:A,cx:b,cy:R,width:S,height:_,radius:F}),A.fill("evenodd"),A.restore()}else if(t.shape==="circle"){const C=Math.max(c,I,l,B),[Q,h]=ai(i,[t.x,t.y]),E=t.radius*Math.abs(i.a),u=C*Math.abs(i.a),d=Math.max(0,E-u);A.save(),A.beginPath(),A.arc(Q,h,E,0,Math.PI*2),d>0&&A.arc(Q,h,d,0,Math.PI*2,!0),A.fill("evenodd"),A.restore()}else if(t.shape==="pill"||t.shape==="rotated_pill"){const C=Math.max(c,I,l,B),[Q,h]=ai(i,[t.x,t.y]),E=t.width*Math.abs(i.a),u=t.height*Math.abs(i.a),d=C*Math.abs(i.a);A.save(),A.translate(Q,h),g!==0&&A.rotate(-g*Math.PI/180),A.beginPath(),Zb({ctx:A,cx:0,cy:0,width:E,height:u});const f=E-d*2,m=u-d*2;f>0&&m>0&&Zb({ctx:A,cx:0,cy:0,width:f,height:m}),A.fill("evenodd"),A.restore()}else if(t.shape==="polygon"&&t.points&&t.points.length>=3){const C=Math.max(c,I,l,B);A.save(),A.beginPath();const Q=t.points.map(E=>{const[u,d]=ai(i,[E.x,E.y]);return{x:u,y:d}});Mk({ctx:A,points:Q});const h=CT(t.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}});Mk({ctx:A,points:E})}A.fill("evenodd"),A.restore()}}function t1(e,A){const t=Math.hypot(e,A);return t<=Number.EPSILON?{x:0,y:0}:{x:e/t,y:A/t}}function Lze(e,A){const t=e.length;if(t<2)return{x:1,y:0};if(A<=0){const g=e[1],c=e[0];if(!g||!c)return{x:1,y:0};const I=t1(g.x-c.x,g.y-c.y);return I.x===0&&I.y===0?{x:1,y:0}:I}if(A>=t-1){const g=e[t-2],c=e[t-1];if(!g||!c)return{x:1,y:0};const I=t1(c.x-g.x,c.y-g.y);return I.x===0&&I.y===0?{x:1,y:0}:I}const i=e[A-1],n=e[A],o=e[A+1];if(!i||!n||!o)return{x:1,y:0};const s=t1(n.x-i.x,n.y-i.y),r=t1(o.x-n.x,o.y-n.y),a=t1(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 CCt(e){const A=[],t=[];for(let i=0;i<e.length;i++){const n=e[i];if(!n)continue;const o=Lze(e,i),s=t1(-o.y,o.x),r=n.width/2;A.push({x:n.x+s.x*r,y:n.y+s.y*r}),t.push({x:n.x-s.x*r,y:n.y-s.y*r})}return A.concat(t.reverse())}function Z0A(e){const A=[];let t=[],i=null;for(const n of e??[]){if(!n||n.route_type!=="wire"){t.length>=2&&A.push(t),t=[],i=null;continue}const o=n.layer??i;if(!o)continue;const s=n.x,r=n.y;typeof s!="number"||typeof r!="number"||typeof n.width=="number"&&(n.width,i&&o!==i&&(t.length>=2&&A.push(t),t=[]),i=o,t.push(n))}return t.length>=2&&A.push(t),A}var QCt=1e-6;function hCt(e){const{ctx:A,trace:t,realToCanvasMat:i,vias:n,platedHoles:o,layer:s}=e;if(!t.route||t.route.length<2)return;const r=Z0A(t.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)||!ECt(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(uCt(C),C)}for(const l of o){if(l.layers&&Array.isArray(l.layers)&&!l.layers.includes(c))continue;const B=Uze(l);B&&ECt(I.x,I.y,B.x,B.y)&&a.set(uCt(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"){sS({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}Ah({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 Uze(e){if(e.shape==="circle"){const n=e.hole_diameter/2;return n<=0?void 0:{shape:"circle",x:e.x,y:e.y,radius:n}}if(e.shape==="oval"){const n=e.hole_width/2,o=e.hole_height/2;return n<=0||o<=0?void 0:{shape:"oval",x:e.x,y:e.y,radiusX:n,radiusY:o,rotation:e.ccw_rotation}}if(e.shape==="pill")return e.hole_width<=0||e.hole_height<=0?void 0:{shape:"pill",x:e.x,y:e.y,width:e.hole_width,height:e.hole_height,rotation:e.ccw_rotation};if(e.shape==="circular_hole_with_rect_pad"){const n=e.hole_diameter/2;return n<=0?void 0:{shape:"circle",x:e.x+(e.hole_offset_x??0),y:e.y+(e.hole_offset_y??0),radius:n}}if(e.shape==="pill_hole_with_rect_pad")return e.hole_width<=0||e.hole_height<=0?void 0:{shape:"pill",x:e.x+(e.hole_offset_x??0),y:e.y+(e.hole_offset_y??0),width:e.hole_width,height:e.hole_height};if(e.shape==="rotated_pill_hole_with_rect_pad")return e.hole_width<=0||e.hole_height<=0?void 0:{shape:"pill",x:e.x+(e.hole_offset_x??0),y:e.y+(e.hole_offset_y??0),width:e.hole_width,height:e.hole_height,rotation:e.hole_ccw_rotation};if(e.shape!=="hole_with_polygon_pad")return;const A=e.x+(e.hole_offset_x??0),t=e.y+(e.hole_offset_y??0),i=e.hole_shape;if(i==="circle"){const n=(e.hole_diameter??0)/2;return n<=0?void 0:{shape:"circle",x:A,y:t,radius:n}}if(i==="oval"){const n=(e.hole_width??0)/2,o=(e.hole_height??0)/2;return n<=0||o<=0?void 0:{shape:"oval",x:A,y:t,radiusX:n,radiusY:o}}if(i==="pill"||i==="rotated_pill"){const n=e.hole_width??0,o=e.hole_height??0;return n<=0||o<=0?void 0:{shape:"pill",x:A,y:t,width:n,height:o,rotation:i==="rotated_pill"?e.ccw_rotation:0}}}function ECt(e,A,t,i){return Math.abs(e-t)<=QCt&&Math.abs(A-i)<=QCt}function uCt(e){return e.shape==="circle"?`circle:${e.x}:${e.y}:${e.radius}`:e.shape==="oval"?`oval:${e.x}:${e.y}:${e.radiusX}:${e.radiusY}:${e.rotation??0}`:`pill:${e.x}:${e.y}:${e.width}:${e.height}:${e.rotation??0}`}function dCt(e){if(e.length<2)return!1;const A=e[0]?.width;return typeof A!="number"?!1:e.some(t=>Math.abs(t.width-A)>Number.EPSILON)}function Hze(e){const{ctx:A,trace:t,realToCanvasMat:i,soldermaskOverCopperColor:n,layer:o}=e;if(!t.route||!Array.isArray(t.route)||t.route.length<2)return;const s=Z0A(t.route);for(const r of s)if(r[0]?.layer===o){if(dCt(r)){const g=CCt(r);Fk({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||A1({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"})}}hCt({ctx:A,trace:t,realToCanvasMat:i,layer:o,vias:e.vias,platedHoles:e.platedHoles})}function Yze(e){const{ctx:A,via:t,realToCanvasMat:i}=e,[n,o]=ai(i,[t.x,t.y]),s=t.outer_diameter/2*Math.abs(i.a);A.beginPath(),A.arc(n,o,s,0,Math.PI*2),A.closePath(),X0(A)}function pCt(e){const{ctx:A,elements:t,realToCanvasMat:i,colorMap:n,layer:o,drawSoldermask:s}=e;if(!s||A.canvas.width<=0||A.canvas.height<=0)return;const r=t.filter(C=>C.type==="pcb_board"),a=t.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=t.filter(C=>C.type==="pcb_via"),l=t.filter(C=>C.type==="pcb_plated_hole"),B=mze(A,A.canvas.width,A.canvas.height)??A;if(a&&wze({ctx:B,panel:a,realToCanvasMat:i,soldermaskColor:g}),a&&r.length>0){B.save(),B.globalCompositeOperation="destination-out";for(const C of r)ICt({ctx:B,board:C,realToCanvasMat:i,soldermaskColor:"#000"});B.restore()}for(const C of r)ICt({ctx:B,board:C,realToCanvasMat:i,soldermaskColor:g});for(const C of t)C.type==="pcb_trace"?Hze({ctx:B,trace:C,realToCanvasMat:i,soldermaskOverCopperColor:c,layer:o,vias:I,platedHoles:l}):C.type==="pcb_copper_pour"&&kze({ctx:B,pour:C,realToCanvasMat:i,soldermaskOverCopperColor:c,layer:o,elements:t});for(const C of t)Jze({ctx:B,element:C,realToCanvasMat:i,soldermaskOverCopperColor:c,layer:o});fze(A,B)}function Jze(e){const{ctx:A,element:t,realToCanvasMat:i,soldermaskOverCopperColor:n,layer:o}=e;if(t.type==="pcb_smtpad")Rze({ctx:A,pad:t,realToCanvasMat:i,soldermaskOverCopperColor:n,layer:o});else if(t.type==="pcb_plated_hole")Mze({ctx:A,hole:t,realToCanvasMat:i,soldermaskOverCopperColor:n,layer:o});else if(t.type==="pcb_hole")vze({ctx:A,hole:t,realToCanvasMat:i,soldermaskOverCopperColor:n});else if(t.type==="pcb_via")Yze({ctx:A,via:t,realToCanvasMat:i});else if(t.type==="pcb_cutout")Dze({ctx:A,cutout:t,realToCanvasMat:i});else{if(t.type==="pcb_copper_pour")return;if(t.type==="pcb_trace")return}}function Tze(e,A){return A.copper[e]??A.copper.top}function fCt(e){const{ctx:A,trace:t,realToCanvasMat:i,colorMap:n}=e;if(!t.route||!Array.isArray(t.route)||t.route.length<2)return;const o=Z0A(t.route);for(const s of o){const r=s[0]?.layer;if(!r)continue;const a=Tze(r,n);if(dCt(s)){const g=CCt(s);Fk({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||A1({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"})}}hCt({ctx:A,trace:t,realToCanvasMat:i,vias:e.vias??[],platedHoles:e.platedHoles??[]})}function yCt(e){const{ctx:A,via:t,realToCanvasMat:i,colorMap:n,layer:o}=e;tQ({ctx:A,center:{x:t.x,y:t.y},radius:t.outer_diameter/2,fill:n.copper[o??"top"],realToCanvasMat:i}),A.save(),A.globalCompositeOperation="destination-out",tQ({ctx:A,center:{x:t.x,y:t.y},radius:t.hole_diameter/2,fill:"#000",realToCanvasMat:i}),A.restore(),tQ({ctx:A,center:{x:t.x,y:t.y},radius:t.hole_diameter/2,fill:n.drill,realToCanvasMat:i})}function pm(e,A){if(!A.layers||A.layers.length===0)return!0;const t=ltA(e);return t.length===0?!0:t.some(i=>A.layers.includes(i))}var op={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 Pze(e){return!e||e.length===0?"top":e.some(t=>t.startsWith("bottom"))?"bottom":"top"}var eQ=class{ctx;colorMap;realToCanvasMat;constructor(e){if("getContext"in e&&typeof e.getContext=="function"){const A=e.getContext("2d");if(!A)throw new Error("Failed to get 2D rendering context from canvas");this.ctx=A}else this.ctx=e;this.colorMap={...op},this.realToCanvasMat=hje()}configure(e){e.colorOverrides&&(this.colorMap={...this.colorMap,...e.colorOverrides,copper:{...this.colorMap.copper,...e.colorOverrides.copper},copperPour:{...this.colorMap.copperPour,...e.colorOverrides.copperPour},silkscreen:{...this.colorMap.silkscreen,...e.colorOverrides.silkscreen},soldermask:{...this.colorMap.soldermask,...e.colorOverrides.soldermask},soldermaskWithCopperUnderneath:{...this.colorMap.soldermaskWithCopperUnderneath,...e.colorOverrides.soldermaskWithCopperUnderneath},soldermaskOverCopper:{...this.colorMap.soldermaskOverCopper,...e.colorOverrides.soldermaskOverCopper}})}setCameraBounds(e){const A=this.ctx.canvas,t=A.width,i=A.height,n=e.maxX-e.minX,o=e.maxY-e.minY,s=t/n,r=i/o,a=Math.min(s,r),g=(t-n*a)/2,c=(i-o*a)/2;this.realToCanvasMat=T0A(vk(g,c),dje(a,-a),vk(-e.minX,-e.maxY))}drawElements(e,A={}){const t=Pze(A.layers),i=e.find(l=>l.type==="pcb_board"),n=e.find(l=>l.type==="pcb_panel");n&&eze({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=e.filter(l=>pm(l,A)&&l.type==="pcb_via"),I=e.filter(l=>pm(l,A)&&l.type==="pcb_plated_hole");i&&pje({ctx:this.ctx,board:i,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap,drawBoardMaterial:o,minBoardOutlineStrokePx:A.minBoardOutlineStrokePx});for(const l of e)pm(l,A)&&l.type==="pcb_copper_pour"&&wje({ctx:this.ctx,pour:l,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap});for(const l of e)pm(l,A)&&(l.type==="pcb_smtpad"&&dze({ctx:this.ctx,pad:l,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}),l.type==="pcb_copper_text"&&vje({ctx:this.ctx,text:l,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}));if(a){for(const l of e)pm(l,A)&&l.type==="pcb_trace"&&fCt({ctx:this.ctx,trace:l,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap,vias:c,platedHoles:I});for(const l of e)pm(l,A)&&(l.type==="pcb_hole"&&aCt({ctx:this.ctx,hole:l,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap,soldermaskMargin:l.soldermask_margin,drawSoldermask:a}),l.type==="pcb_plated_hole"&&gCt({ctx:this.ctx,hole:l,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap,soldermaskMargin:l.soldermask_margin,drawSoldermask:a,layer:t}),l.type==="pcb_via"&&yCt({ctx:this.ctx,via:l,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap,layer:t}))}a&&pCt({ctx:this.ctx,elements:e,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap,layer:"top",drawSoldermask:!0});for(const l of e)pm(l,A)&&(l.type==="pcb_silkscreen_text"&&Eze({ctx:this.ctx,text:l,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}),l.type==="pcb_silkscreen_rect"&&Cze({ctx:this.ctx,rect:l,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}),l.type==="pcb_silkscreen_circle"&&nze({ctx:this.ctx,circle:l,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}),l.type==="pcb_silkscreen_line"&&sze({ctx:this.ctx,line:l,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}),l.type==="pcb_silkscreen_path"&&cze({ctx:this.ctx,path:l,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}),l.type==="pcb_silkscreen_pill"&&lze({ctx:this.ctx,pill:l,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}),l.type==="pcb_silkscreen_oval"&&aze({ctx:this.ctx,oval:l,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}));for(const l of e)pm(l,A)&&l.type==="pcb_trace"&&!a&&fCt({ctx:this.ctx,trace:l,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap,vias:c,platedHoles:I});for(const l of e)pm(l,A)&&l.type==="pcb_hole"&&!a&&aCt({ctx:this.ctx,hole:l,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap,soldermaskMargin:a?l.soldermask_margin:void 0,drawSoldermask:a});for(const l of e)pm(l,A)&&(l.type==="pcb_plated_hole"&&!a&&gCt({ctx:this.ctx,hole:l,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap,soldermaskMargin:a?l.soldermask_margin:void 0,drawSoldermask:a,layer:t}),l.type==="pcb_via"&&!a&&yCt({ctx:this.ctx,via:l,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap,layer:t}));g&&pCt({ctx:this.ctx,elements:e,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap,layer:"bottom",drawSoldermask:!0});for(const l of e)pm(l,A)&&l.type==="pcb_cutout"&&Uje({ctx:this.ctx,cutout:l,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap});for(const l of e){if(!pm(l,A))continue;l.type==="pcb_keepout"&&Zje({ctx:this.ctx,keepout:l,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}),l.type==="pcb_fabrication_note_text"&&Oje({ctx:this.ctx,text:l,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}),l.type==="pcb_fabrication_note_rect"&&Kje({ctx:this.ctx,rect:l,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap});const B=A.showPcbNotes??!0;B&&l.type==="pcb_note_rect"&&$je({realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap,ctx:this.ctx,rect:l}),l.type==="pcb_fabrication_note_path"&&Pje({ctx:this.ctx,path:l,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}),B&&l.type==="pcb_note_path"&&Xje({ctx:this.ctx,path:l,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}),B&&l.type==="pcb_note_text"&&tze({ctx:this.ctx,text:l,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}),B&&l.type==="pcb_note_line"&&zje({ctx:this.ctx,line:l,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}),B&&l.type==="pcb_note_dimension"&&jje({ctx:this.ctx,pcbNoteDimension:l,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}),l.type==="pcb_fabrication_note_dimension"&&Tje({ctx:this.ctx,pcbFabricationNoteDimension:l,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}),l.type==="pcb_courtyard_circle"&&Mje({ctx:this.ctx,circle:l,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}),l.type==="pcb_courtyard_rect"&&Lje({ctx:this.ctx,rect:l,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap}),l.type==="pcb_courtyard_outline"&&Rje({ctx:this.ctx,outline:l,realToCanvasMat:this.realToCanvasMat,colorMap:this.colorMap})}}};const Kze=lxt(DUt);var V0A,mCt;function qze(){if(mCt)return V0A;mCt=1;var e=Object.defineProperty,A=Object.getOwnPropertyDescriptor,t=Object.getOwnPropertyNames,i=Object.prototype.hasOwnProperty,n=(h,E)=>{for(var u in E)e(h,u,{get:E[u],enumerable:!0})},o=(h,E,u,d)=>{if(E&&typeof E=="object"||typeof E=="function")for(let f of t(E))!i.call(h,f)&&f!==u&&e(h,f,{get:()=>E[f],enumerable:!(d=A(E,f))||d.enumerable});return h},s=h=>o(e({},"__esModule",{value:!0}),h),r={};n(r,{SuperGrid:()=>Q,toMMSI:()=>C,toMeterSI:()=>B}),V0A=s(r);var a=b0(),g=Kze,c=jxA(),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:R=(J,O,W)=>`${B(J,W)}, ${B(O,W)}`}=h,F=Math.ceil(S/b)+2,H=Math.ceil(_/b)+2;(0,a.useEffect)(()=>{if(!u.current)return;const J=u.current.getContext("2d");if(!J)return;const O=b/10**Math.floor(Math.log10(h.transform.a)),W=h.transform.d<0?-1:1,tA=b/10**Math.log10(h.transform.a)/O;function aA(_A,dA,WA){const VA=_A;let It,mA,gt;for(It=dA.x;It<=WA.x;It+=VA)mA=(0,g.applyToPoint)(h.transform,{x:It,y:dA.y}),gt=(0,g.applyToPoint)(h.transform,{x:It,y:WA.y}),J.beginPath(),J.moveTo(mA.x,mA.y),J.lineTo(gt.x,gt.y),J.stroke();const PA=I(dA.y,WA.y,VA*W);for(const UA of PA)mA=(0,g.applyToPoint)(h.transform,{x:dA.x,y:UA}),gt=(0,g.applyToPoint)(h.transform,{x:WA.x,y:UA}),J.beginPath(),J.moveTo(mA.x,mA.y),J.lineTo(gt.x,gt.y),J.stroke()}function eA(_A,dA,WA){const VA=_A;let It;for(It=dA.x;It<=WA.x;It+=VA)for(const mA of I(dA.y,WA.y,VA*W)){const gt=(0,g.applyToPoint)(h.transform,{x:It,y:mA});J.fillStyle=D,J.font="12px sans-serif",J.fillText(R(It,mA,_A),gt.x+2,gt.y-2)}}J.clearRect(0,0,S,_);const oA=(0,g.applyToPoint)((0,g.inverse)(h.transform),{x:0,y:0}),rA={x:Math.floor((oA.x-O)/O)*O,y:Math.floor((oA.y-O)/O+(W==-1?2:0))*O},BA={x:rA.x+O*F,y:rA.y+O*H*W},kA=O*5,MA={x:Math.floor((oA.x-kA)/kA)*kA,y:Math.floor((oA.y-kA)/kA+(W==-1?2:0))*kA},TA={x:MA.x+kA*F,y:MA.y+kA*H*W};J.globalAlpha=1,J.strokeStyle=m,aA(O,rA,BA),eA(kA,MA,TA),J.globalAlpha=1-tA,aA(kA/10,MA,TA),J.globalAlpha=1-tA,J.strokeStyle=w,aA(O/10,rA,BA),J.globalAlpha=Math.max(((1-tA)*10-5)/5,0),eA(kA/10,MA,TA),J.globalAlpha=1;const EA=(0,g.applyToPoint)(h.transform,d);J.font="12px sans-serif",J.fillStyle=D,J.fillText(R(d.x,d.y,O),EA.x+2,EA.y-2),J.strokeStyle=m,J.strokeRect(EA.x-5,EA.y-5,10,10)},[u,h.transform,d,S,_]);const Y=J=>{if(!u.current)return;const O=b/10/10**Math.floor(Math.log10(h.transform.a)),W=u.current.getBoundingClientRect(),z=(0,g.applyToPoint)((0,g.inverse)(h.transform),{x:J.clientX-W.left,y:J.clientY-W.top}),tA=l(O,z);f(tA)};return(0,c.jsx)("canvas",{onMouseUp:J=>{J.button===1&&Y(J)},onDoubleClick:Y,ref:u,width:h.width,height:h.height})};return V0A}var bj=qze();function Oze(e){if(e.sheet)return e.sheet;for(var A=0;A<document.styleSheets.length;A++)if(document.styleSheets[A].ownerNode===e)return document.styleSheets[A]}function Wze(e){var A=document.createElement("style");return A.setAttribute("data-emotion",e.key),e.nonce!==void 0&&A.setAttribute("nonce",e.nonce),A.appendChild(document.createTextNode("")),A.setAttribute("data-s",""),A}var Zze=(function(){function e(t){var i=this;this._insertTag=function(n){var o;i.tags.length===0?i.insertionPoint?o=i.insertionPoint.nextSibling:i.prepend?o=i.container.firstChild:o=i.before:o=i.tags[i.tags.length-1].nextSibling,i.container.insertBefore(n,o),i.tags.push(n)},this.isSpeedy=t.speedy===void 0?!0:t.speedy,this.tags=[],this.ctr=0,this.nonce=t.nonce,this.key=t.key,this.container=t.container,this.prepend=t.prepend,this.insertionPoint=t.insertionPoint,this.before=null}var A=e.prototype;return A.hydrate=function(i){i.forEach(this._insertTag)},A.insert=function(i){this.ctr%(this.isSpeedy?65e3:1)===0&&this._insertTag(Wze(this));var n=this.tags[this.tags.length-1];if(this.isSpeedy){var o=Oze(n);try{o.insertRule(i,o.cssRules.length)}catch{}}else n.appendChild(document.createTextNode(i));this.ctr++},A.flush=function(){this.tags.forEach(function(i){var n;return(n=i.parentNode)==null?void 0:n.removeChild(i)}),this.tags=[],this.ctr=0},e})(),cd="-ms-",xj="-moz-",Ag="-webkit-",wCt="comm",j0A="rule",z0A="decl",Vze="@import",DCt="@keyframes",jze="@layer",zze=Math.abs,_j=String.fromCharCode,Xze=Object.assign;function $ze(e,A){return XE(e,0)^45?(((A<<2^XE(e,0))<<2^XE(e,1))<<2^XE(e,2))<<2^XE(e,3):0}function SCt(e){return e.trim()}function AXe(e,A){return(e=A.exec(e))?e[0]:e}function tg(e,A,t){return e.replace(A,t)}function X0A(e,A){return e.indexOf(A)}function XE(e,A){return e.charCodeAt(A)|0}function QT(e,A,t){return e.slice(A,t)}function aS(e){return e.length}function $0A(e){return e.length}function kj(e,A){return A.push(e),e}function tXe(e,A){return e.map(A).join("")}var vj=1,e1=1,bCt=0,Rf=0,iQ=0,i1="";function Fj(e,A,t,i,n,o,s){return{value:e,root:A,parent:t,type:i,props:n,children:o,line:vj,column:e1,length:s,return:""}}function hT(e,A){return Xze(Fj("",null,null,"",null,null,0),e,{length:-e.length},A)}function eXe(){return iQ}function iXe(){return iQ=Rf>0?XE(i1,--Rf):0,e1--,iQ===10&&(e1=1,vj--),iQ}function $0(){return iQ=Rf<bCt?XE(i1,Rf++):0,e1++,iQ===10&&(e1=1,vj++),iQ}function gS(){return XE(i1,Rf)}function Mj(){return Rf}function ET(e,A){return QT(i1,e,A)}function uT(e){switch(e){case 0:case 9:case 10:case 13:case 32:return 5;case 33:case 43:case 44:case 47:case 62:case 64:case 126:case 59:case 123:case 125:return 4;case 58:return 3;case 34:case 39:case 40:case 91:return 2;case 41:case 93:return 1}return 0}function xCt(e){return vj=e1=1,bCt=aS(i1=e),Rf=0,[]}function _Ct(e){return i1="",e}function Gj(e){return SCt(ET(Rf-1,AyA(e===91?e+2:e===40?e+1:e)))}function nXe(e){for(;(iQ=gS())&&iQ<33;)$0();return uT(e)>2||uT(iQ)>3?"":" "}function oXe(e,A){for(;--A&&$0()&&!(iQ<48||iQ>102||iQ>57&&iQ<65||iQ>70&&iQ<97););return ET(e,Mj()+(A<6&&gS()==32&&$0()==32))}function AyA(e){for(;$0();)switch(iQ){case e:return Rf;case 34:case 39:e!==34&&e!==39&&AyA(iQ);break;case 40:e===41&&AyA(e);break;case 92:$0();break}return Rf}function sXe(e,A){for(;$0()&&e+iQ!==57;)if(e+iQ===84&&gS()===47)break;return"/*"+ET(A,Rf-1)+"*"+_j(e===47?e:$0())}function rXe(e){for(;!uT(gS());)$0();return ET(e,Rf)}function aXe(e){return _Ct(Rj("",null,null,null,[""],e=xCt(e),0,[0],e))}function Rj(e,A,t,i,n,o,s,r,a){for(var g=0,c=0,I=s,l=0,B=0,C=0,Q=1,h=1,E=1,u=0,d="",f=n,m=o,w=i,D=d;h;)switch(C=u,u=$0()){case 40:if(C!=108&&XE(D,I-1)==58){X0A(D+=tg(Gj(u),"&","&\f"),"&\f")!=-1&&(E=-1);break}case 34:case 39:case 91:D+=Gj(u);break;case 9:case 10:case 13:case 32:D+=nXe(C);break;case 92:D+=oXe(Mj()-1,7);continue;case 47:switch(gS()){case 42:case 47:kj(gXe(sXe($0(),Mj()),A,t),a);break;default:D+="/"}break;case 123*Q:r[g++]=aS(D)*E;case 125*Q:case 59:case 0:switch(u){case 0:case 125:h=0;case 59+c:E==-1&&(D=tg(D,/\f/g,"")),B>0&&aS(D)-I&&kj(B>32?vCt(D+";",i,t,I-1):vCt(tg(D," ","")+";",i,t,I-2),a);break;case 59:D+=";";default:if(kj(w=kCt(D,A,t,g,c,n,r,d,f=[],m=[],I),o),u===123)if(c===0)Rj(D,A,w,w,f,o,I,r,m);else switch(l===99&&XE(D,3)===110?100:l){case 100:case 108:case 109:case 115:Rj(e,w,w,i&&kj(kCt(e,w,w,0,0,n,r,d,n,f=[],I),m),n,m,I,r,i?f:m);break;default:Rj(D,w,w,w,[""],m,0,r,m)}}g=c=B=0,Q=E=1,d=D="",I=s;break;case 58:I=1+aS(D),B=C;default:if(Q<1){if(u==123)--Q;else if(u==125&&Q++==0&&iXe()==125)continue}switch(D+=_j(u),u*Q){case 38:E=c>0?1:(D+="\f",-1);break;case 44:r[g++]=(aS(D)-1)*E,E=1;break;case 64:gS()===45&&(D+=Gj($0())),l=gS(),c=I=aS(d=D+=rXe(Mj())),u++;break;case 45:C===45&&aS(D)==2&&(Q=0)}}return o}function kCt(e,A,t,i,n,o,s,r,a,g,c){for(var I=n-1,l=n===0?o:[""],B=$0A(l),C=0,Q=0,h=0;C<i;++C)for(var E=0,u=QT(e,I+1,I=zze(Q=s[C])),d=e;E<B;++E)(d=SCt(Q>0?l[E]+" "+u:tg(u,/&\f/g,l[E])))&&(a[h++]=d);return Fj(e,A,t,n===0?j0A:r,a,g,c)}function gXe(e,A,t){return Fj(e,A,t,wCt,_j(eXe()),QT(e,2,-2),0)}function vCt(e,A,t,i){return Fj(e,A,t,z0A,QT(e,0,i),QT(e,i+1,-1),i)}function n1(e,A){for(var t="",i=$0A(e),n=0;n<i;n++)t+=A(e[n],n,e,A)||"";return t}function cXe(e,A,t,i){switch(e.type){case jze:if(e.children.length)break;case Vze:case z0A:return e.return=e.return||e.value;case wCt:return"";case DCt:return e.return=e.value+"{"+n1(e.children,i)+"}";case j0A:e.value=e.props.join(",")}return aS(t=n1(e.children,i))?e.return=e.value+"{"+t+"}":""}function IXe(e){var A=$0A(e);return function(t,i,n,o){for(var s="",r=0;r<A;r++)s+=e[r](t,i,n,o)||"";return s}}function lXe(e){return function(A){A.root||(A=A.return)&&e(A)}}function BXe(e){var A=Object.create(null);return function(t){return A[t]===void 0&&(A[t]=e(t)),A[t]}}var CXe=function(A,t,i){for(var n=0,o=0;n=o,o=gS(),n===38&&o===12&&(t[i]=1),!uT(o);)$0();return ET(A,Rf)},QXe=function(A,t){var i=-1,n=44;do switch(uT(n)){case 0:n===38&&gS()===12&&(t[i]=1),A[i]+=CXe(Rf-1,t,i);break;case 2:A[i]+=Gj(n);break;case 4:if(n===44){A[++i]=gS()===58?"&\f":"",t[i]=A[i].length;break}default:A[i]+=_j(n)}while(n=$0());return A},hXe=function(A,t){return _Ct(QXe(xCt(A),t))},FCt=new WeakMap,EXe=function(A){if(!(A.type!=="rule"||!A.parent||A.length<1)){for(var t=A.value,i=A.parent,n=A.column===i.column&&A.line===i.line;i.type!=="rule";)if(i=i.parent,!i)return;if(!(A.props.length===1&&t.charCodeAt(0)!==58&&!FCt.get(i))&&!n){FCt.set(A,!0);for(var o=[],s=hXe(t,o),r=i.props,a=0,g=0;a<s.length;a++)for(var c=0;c<r.length;c++,g++)A.props[g]=o[a]?s[a].replace(/&\f/g,r[c]):r[c]+" "+s[a]}}},uXe=function(A){if(A.type==="decl"){var t=A.value;t.charCodeAt(0)===108&&t.charCodeAt(2)===98&&(A.return="",A.value="")}};function MCt(e,A){switch($ze(e,A)){case 5103:return Ag+"print-"+e+e;case 5737:case 4201:case 3177:case 3433:case 1641:case 4457:case 2921:case 5572:case 6356:case 5844:case 3191:case 6645:case 3005:case 6391:case 5879:case 5623:case 6135:case 4599:case 4855:case 4215:case 6389:case 5109:case 5365:case 5621:case 3829:return Ag+e+e;case 5349:case 4246:case 4810:case 6968:case 2756:return Ag+e+xj+e+cd+e+e;case 6828:case 4268:return Ag+e+cd+e+e;case 6165:return Ag+e+cd+"flex-"+e+e;case 5187:return Ag+e+tg(e,/(\w+).+(:[^]+)/,Ag+"box-$1$2"+cd+"flex-$1$2")+e;case 5443:return Ag+e+cd+"flex-item-"+tg(e,/flex-|-self/,"")+e;case 4675:return Ag+e+cd+"flex-line-pack"+tg(e,/align-content|flex-|-self/,"")+e;case 5548:return Ag+e+cd+tg(e,"shrink","negative")+e;case 5292:return Ag+e+cd+tg(e,"basis","preferred-size")+e;case 6060:return Ag+"box-"+tg(e,"-grow","")+Ag+e+cd+tg(e,"grow","positive")+e;case 4554:return Ag+tg(e,/([^-])(transform)/g,"$1"+Ag+"$2")+e;case 6187:return tg(tg(tg(e,/(zoom-|grab)/,Ag+"$1"),/(image-set)/,Ag+"$1"),e,"")+e;case 5495:case 3959:return tg(e,/(image-set\([^]*)/,Ag+"$1$`$1");case 4968:return tg(tg(e,/(.+:)(flex-)?(.*)/,Ag+"box-pack:$3"+cd+"flex-pack:$3"),/s.+-b[^;]+/,"justify")+Ag+e+e;case 4095:case 3583:case 4068:case 2532:return tg(e,/(.+)-inline(.+)/,Ag+"$1$2")+e;case 8116:case 7059:case 5753:case 5535:case 5445:case 5701:case 4933:case 4677:case 5533:case 5789:case 5021:case 4765:if(aS(e)-1-A>6)switch(XE(e,A+1)){case 109:if(XE(e,A+4)!==45)break;case 102:return tg(e,/(.+:)(.+)-([^]+)/,"$1"+Ag+"$2-$3$1"+xj+(XE(e,A+3)==108?"$3":"$2-$3"))+e;case 115:return~X0A(e,"stretch")?MCt(tg(e,"stretch","fill-available"),A)+e:e}break;case 4949:if(XE(e,A+1)!==115)break;case 6444:switch(XE(e,aS(e)-3-(~X0A(e,"!important")&&10))){case 107:return tg(e,":",":"+Ag)+e;case 101:return tg(e,/(.+:)([^;!]+)(;|!.+)?/,"$1"+Ag+(XE(e,14)===45?"inline-":"")+"box$3$1"+Ag+"$2$3$1"+cd+"$2box$3")+e}break;case 5936:switch(XE(e,A+11)){case 114:return Ag+e+cd+tg(e,/[svh]\w+-[tblr]{2}/,"tb")+e;case 108:return Ag+e+cd+tg(e,/[svh]\w+-[tblr]{2}/,"tb-rl")+e;case 45:return Ag+e+cd+tg(e,/[svh]\w+-[tblr]{2}/,"lr")+e}return Ag+e+cd+e+e}return e}var dXe=function(A,t,i,n){if(A.length>-1&&!A.return)switch(A.type){case z0A:A.return=MCt(A.value,A.length);break;case DCt:return n1([hT(A,{value:tg(A.value,"@","@"+Ag)})],n);case j0A:if(A.length)return tXe(A.props,function(o){switch(AXe(o,/(::plac\w+|:read-\w+)/)){case":read-only":case":read-write":return n1([hT(A,{props:[tg(o,/:(read-\w+)/,":"+xj+"$1")]})],n);case"::placeholder":return n1([hT(A,{props:[tg(o,/:(plac\w+)/,":"+Ag+"input-$1")]}),hT(A,{props:[tg(o,/:(plac\w+)/,":"+xj+"$1")]}),hT(A,{props:[tg(o,/:(plac\w+)/,cd+"input-$1")]})],n)}return""})}},pXe=[dXe],fXe=function(A){var t=A.key;if(t==="css"){var i=document.querySelectorAll("style[data-emotion]:not([data-s])");Array.prototype.forEach.call(i,function(Q){var h=Q.getAttribute("data-emotion");h.indexOf(" ")!==-1&&(document.head.appendChild(Q),Q.setAttribute("data-s",""))})}var n=A.stylisPlugins||pXe,o={},s,r=[];s=A.container||document.head,Array.prototype.forEach.call(document.querySelectorAll('style[data-emotion^="'+t+' "]'),function(Q){for(var h=Q.getAttribute("data-emotion").split(" "),E=1;E<h.length;E++)o[h[E]]=!0;r.push(Q)});var a,g=[EXe,uXe];{var c,I=[cXe,lXe(function(Q){c.insert(Q)})],l=IXe(g.concat(n,I)),B=function(h){return n1(aXe(h),l)};a=function(h,E,u,d){c=u,B(h?h+"{"+E.styles+"}":E.styles),d&&(C.inserted[E.name]=!0)}}var C={key:t,sheet:new Zze({key:t,container:s,nonce:A.nonce,speedy:A.speedy,prepend:A.prepend,insertionPoint:A.insertionPoint}),nonce:A.nonce,inserted:o,registered:{},insert:a};return C.sheet.hydrate(r),C};function yXe(e){for(var A=0,t,i=0,n=e.length;n>=4;++i,n-=4)t=e.charCodeAt(i)&255|(e.charCodeAt(++i)&255)<<8|(e.charCodeAt(++i)&255)<<16|(e.charCodeAt(++i)&255)<<24,t=(t&65535)*1540483477+((t>>>16)*59797<<16),t^=t>>>24,A=(t&65535)*1540483477+((t>>>16)*59797<<16)^(A&65535)*1540483477+((A>>>16)*59797<<16);switch(n){case 3:A^=(e.charCodeAt(i+2)&255)<<16;case 2:A^=(e.charCodeAt(i+1)&255)<<8;case 1:A^=e.charCodeAt(i)&255,A=(A&65535)*1540483477+((A>>>16)*59797<<16)}return A^=A>>>13,A=(A&65535)*1540483477+((A>>>16)*59797<<16),((A^A>>>15)>>>0).toString(36)}var mXe={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},wXe=/[A-Z]|^ms/g,DXe=/_EMO_([^_]+?)_([^]*?)_EMO_/g,GCt=function(A){return A.charCodeAt(1)===45},RCt=function(A){return A!=null&&typeof A!="boolean"},tyA=BXe(function(e){return GCt(e)?e:e.replace(wXe,"-$&").toLowerCase()}),NCt=function(A,t){switch(A){case"animation":case"animationName":if(typeof t=="string")return t.replace(DXe,function(i,n,o){return Gk={name:n,styles:o,next:Gk},n})}return mXe[A]!==1&&!GCt(A)&&typeof t=="number"&&t!==0?t+"px":t};function Nj(e,A,t){if(t==null)return"";var i=t;if(i.__emotion_styles!==void 0)return i;switch(typeof t){case"boolean":return"";case"object":{var n=t;if(n.anim===1)return Gk={name:n.name,styles:n.styles,next:Gk},n.name;var o=t;if(o.styles!==void 0){var s=o.next;if(s!==void 0)for(;s!==void 0;)Gk={name:s.name,styles:s.styles,next:Gk},s=s.next;var r=o.styles+";";return r}return SXe(e,A,t)}}var a=t;if(A==null)return a;var g=A[a];return g!==void 0?g:a}function SXe(e,A,t){var i="";if(Array.isArray(t))for(var n=0;n<t.length;n++)i+=Nj(e,A,t[n])+";";else for(var o in t){var s=t[o];if(typeof s!="object"){var r=s;A!=null&&A[r]!==void 0?i+=o+"{"+A[r]+"}":RCt(r)&&(i+=tyA(o)+":"+NCt(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++)RCt(s[a])&&(i+=tyA(o)+":"+NCt(o,s[a])+";");else{var g=Nj(e,A,s);switch(o){case"animation":case"animationName":{i+=tyA(o)+":"+g+";";break}default:i+=o+"{"+g+"}"}}}return i}var LCt=/label:\s*([^\s;{]+)\s*(;|$)/g,Gk;function eyA(e,A,t){if(e.length===1&&typeof e[0]=="object"&&e[0]!==null&&e[0].styles!==void 0)return e[0];var i=!0,n="";Gk=void 0;var o=e[0];if(o==null||o.raw===void 0)i=!1,n+=Nj(t,A,o);else{var s=o;n+=s[0]}for(var r=1;r<e.length;r++)if(n+=Nj(t,A,e[r]),i){var a=o;n+=a[r]}LCt.lastIndex=0;for(var g="",c;(c=LCt.exec(n))!==null;)g+="-"+c[1];var I=yXe(n)+g;return{name:I,styles:n,next:Gk}}function UCt(e,A,t){var i="";return t.split(" ").forEach(function(n){e[n]!==void 0?A.push(e[n]+";"):n&&(i+=n+" ")}),i}var bXe=function(A,t,i){var n=A.key+"-"+t.name;A.registered[n]===void 0&&(A.registered[n]=t.styles)},xXe=function(A,t,i){bXe(A,t);var n=A.key+"-"+t.name;if(A.inserted[t.name]===void 0){var o=t;do A.insert(t===o?"."+n:"",o,A.sheet,!0),o=o.next;while(o!==void 0)}};function HCt(e,A){if(e.inserted[A.name]===void 0)return e.insert("",A,e.sheet,!0)}function YCt(e,A,t){var i=[],n=UCt(e,i,t);return i.length<2?t:n+A(i)}var _Xe=function(A){var t=fXe(A);t.sheet.speedy=function(r){this.isSpeedy=r},t.compat=!0;var i=function(){for(var a=arguments.length,g=new Array(a),c=0;c<a;c++)g[c]=arguments[c];var I=eyA(g,t.registered,void 0);return xXe(t,I),t.key+"-"+I.name},n=function(){for(var a=arguments.length,g=new Array(a),c=0;c<a;c++)g[c]=arguments[c];var I=eyA(g,t.registered),l="animation-"+I.name;return HCt(t,{name:I.name,styles:"@keyframes "+l+"{"+I.styles+"}"}),l},o=function(){for(var a=arguments.length,g=new Array(a),c=0;c<a;c++)g[c]=arguments[c];var I=eyA(g,t.registered);HCt(t,I)},s=function(){for(var a=arguments.length,g=new Array(a),c=0;c<a;c++)g[c]=arguments[c];return YCt(t.registered,i,kXe(g))};return{css:i,cx:s,injectGlobal:o,keyframes:n,hydrate:function(a){a.forEach(function(g){t.inserted[g]=!0})},flush:function(){t.registered={},t.inserted={},t.sheet.flush()},sheet:t.sheet,cache:t,getRegisteredStyles:UCt.bind(null,t.registered),merge:YCt.bind(null,t.registered,i)}},kXe=function e(A){for(var t="",i=0;i<A.length;i++){var n=A[i];if(n!=null){var o=void 0;switch(typeof n){case"boolean":break;case"object":{if(Array.isArray(n))o=e(n);else{o="";for(var s in n)n[s]&&s&&(o&&(o+=" "),o+=s)}break}default:o=n}o&&(t&&(t+=" "),t+=o)}}return t},vXe=_Xe({key:"css"}),o1=vXe.css,FXe=Object.create,JCt=Object.defineProperty,MXe=Object.getOwnPropertyDescriptor,TCt=Object.getOwnPropertyNames,GXe=Object.getPrototypeOf,RXe=Object.prototype.hasOwnProperty,Qa=(e,A)=>function(){return A||(0,e[TCt(e)[0]])((A={exports:{}}).exports,A),A.exports},NXe=(e,A,t,i)=>{if(A&&typeof A=="object"||typeof A=="function")for(let n of TCt(A))!RXe.call(e,n)&&n!==t&&JCt(e,n,{get:()=>A[n],enumerable:!(i=MXe(A,n))||i.enumerable});return e},iyA=(e,A,t)=>(t=e!=null?FXe(GXe(e)):{},NXe(A||!e||!e.__esModule?JCt(t,"default",{value:e,enumerable:!0}):t,e)),LXe=Qa({"node_modules/toggle-selection/index.js"(e,A){A.exports=function(){var t=document.getSelection();if(!t.rangeCount)return function(){};for(var i=document.activeElement,n=[],o=0;o<t.rangeCount;o++)n.push(t.getRangeAt(o));switch(i.tagName.toUpperCase()){case"INPUT":case"TEXTAREA":i.blur();break;default:i=null;break}return t.removeAllRanges(),function(){t.type==="Caret"&&t.removeAllRanges(),t.rangeCount||n.forEach(function(s){t.addRange(s)}),i&&i.focus()}}}}),UXe=Qa({"node_modules/copy-to-clipboard/index.js"(e,A){var t=LXe(),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=t(),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}}),HXe=Qa({"node_modules/svgson/dist/svgson.umd.js"(e,A){(function(t,i){typeof e=="object"&&typeof A<"u"?A.exports=i():typeof define=="function"&&define.amd?define(i):(t=typeof globalThis<"u"?globalThis:t||self,t.svgson=i())})(e,function(){var t=function(eA){return eA!=null&&(i(eA)||n(eA)||!!eA._isBuffer)};function i(eA){return!!eA.constructor&&typeof eA.constructor.isBuffer=="function"&&eA.constructor.isBuffer(eA)}function n(eA){return typeof eA.readFloatLE=="function"&&typeof eA.slice=="function"&&i(eA.slice(0,0))}var o=Object.prototype.toString,s=function(oA){if(typeof oA>"u")return"undefined";if(oA===null)return"null";if(oA===!0||oA===!1||oA instanceof Boolean)return"boolean";if(typeof oA=="string"||oA instanceof String)return"string";if(typeof oA=="number"||oA instanceof Number)return"number";if(typeof oA=="function"||oA instanceof Function)return"function";if(typeof Array.isArray<"u"&&Array.isArray(oA))return"array";if(oA instanceof RegExp)return"regexp";if(oA instanceof Date)return"date";var rA=o.call(oA);return rA==="[object RegExp]"?"regexp":rA==="[object Date]"?"date":rA==="[object Arguments]"?"arguments":rA==="[object Error]"?"error":t(oA)?"buffer":rA==="[object Set]"?"set":rA==="[object WeakSet]"?"weakset":rA==="[object Map]"?"map":rA==="[object WeakMap]"?"weakmap":rA==="[object Symbol]"?"symbol":rA==="[object Int8Array]"?"int8array":rA==="[object Uint8Array]"?"uint8array":rA==="[object Uint8ClampedArray]"?"uint8clampedarray":rA==="[object Int16Array]"?"int16array":rA==="[object Uint16Array]"?"uint16array":rA==="[object Int32Array]"?"int32array":rA==="[object Uint32Array]"?"uint32array":rA==="[object Float32Array]"?"float32array":rA==="[object Float64Array]"?"float64array":"object"};function r(eA,oA){return oA={exports:{}},eA(oA,oA.exports),oA.exports}var a=r(function(eA){(function(){function oA(rA,BA){if(typeof BA!="function")return rA;var pA={};for(var kA in rA)Object.prototype.hasOwnProperty.call(rA,kA)&&(pA[BA(kA,rA[kA])||kA]=rA[kA]);return pA}eA.exports?eA.exports=oA:window.rename=oA})()}),g=function eA(oA,rA){var BA=s(oA);if(BA!=="object"&&BA!=="array")throw new Error("expected an object");var pA=[];BA==="object"&&(oA=a(oA,rA),pA={});for(var kA in oA)if(oA.hasOwnProperty(kA)){var MA=oA[kA];s(MA)==="object"||s(MA)==="array"?pA[kA]=eA(MA,rA):pA[kA]=MA}return pA},c=r(function(eA){var oA=Object.prototype.hasOwnProperty,rA="~";function BA(){}Object.create&&(BA.prototype=Object.create(null),new BA().__proto__||(rA=!1));function pA(MA,TA,EA){this.fn=MA,this.context=TA,this.once=EA||!1}function kA(){this._events=new BA,this._eventsCount=0}kA.prototype.eventNames=function(){var TA=[],EA,_A;if(this._eventsCount===0)return TA;for(_A in EA=this._events)oA.call(EA,_A)&&TA.push(rA?_A.slice(1):_A);return Object.getOwnPropertySymbols?TA.concat(Object.getOwnPropertySymbols(EA)):TA},kA.prototype.listeners=function(TA,EA){var _A=rA?rA+TA:TA,dA=this._events[_A];if(EA)return!!dA;if(!dA)return[];if(dA.fn)return[dA.fn];for(var WA=0,VA=dA.length,It=new Array(VA);WA<VA;WA++)It[WA]=dA[WA].fn;return It},kA.prototype.emit=function(TA,EA,_A,dA,WA,VA){var It=rA?rA+TA:TA;if(!this._events[It])return!1;var mA=this._events[It],gt=arguments.length,PA,UA;if(mA.fn){switch(mA.once&&this.removeListener(TA,mA.fn,void 0,!0),gt){case 1:return mA.fn.call(mA.context),!0;case 2:return mA.fn.call(mA.context,EA),!0;case 3:return mA.fn.call(mA.context,EA,_A),!0;case 4:return mA.fn.call(mA.context,EA,_A,dA),!0;case 5:return mA.fn.call(mA.context,EA,_A,dA,WA),!0;case 6:return mA.fn.call(mA.context,EA,_A,dA,WA,VA),!0}for(UA=1,PA=new Array(gt-1);UA<gt;UA++)PA[UA-1]=arguments[UA];mA.fn.apply(mA.context,PA)}else{var jA=mA.length,xA;for(UA=0;UA<jA;UA++)switch(mA[UA].once&&this.removeListener(TA,mA[UA].fn,void 0,!0),gt){case 1:mA[UA].fn.call(mA[UA].context);break;case 2:mA[UA].fn.call(mA[UA].context,EA);break;case 3:mA[UA].fn.call(mA[UA].context,EA,_A);break;case 4:mA[UA].fn.call(mA[UA].context,EA,_A,dA);break;default:if(!PA)for(xA=1,PA=new Array(gt-1);xA<gt;xA++)PA[xA-1]=arguments[xA];mA[UA].fn.apply(mA[UA].context,PA)}}return!0},kA.prototype.on=function(TA,EA,_A){var dA=new pA(EA,_A||this),WA=rA?rA+TA:TA;return this._events[WA]?this._events[WA].fn?this._events[WA]=[this._events[WA],dA]:this._events[WA].push(dA):(this._events[WA]=dA,this._eventsCount++),this},kA.prototype.once=function(TA,EA,_A){var dA=new pA(EA,_A||this,!0),WA=rA?rA+TA:TA;return this._events[WA]?this._events[WA].fn?this._events[WA]=[this._events[WA],dA]:this._events[WA].push(dA):(this._events[WA]=dA,this._eventsCount++),this},kA.prototype.removeListener=function(TA,EA,_A,dA){var WA=rA?rA+TA:TA;if(!this._events[WA])return this;if(!EA)return--this._eventsCount===0?this._events=new BA:delete this._events[WA],this;var VA=this._events[WA];if(VA.fn)VA.fn===EA&&(!dA||VA.once)&&(!_A||VA.context===_A)&&(--this._eventsCount===0?this._events=new BA:delete this._events[WA]);else{for(var It=0,mA=[],gt=VA.length;It<gt;It++)(VA[It].fn!==EA||dA&&!VA[It].once||_A&&VA[It].context!==_A)&&mA.push(VA[It]);mA.length?this._events[WA]=mA.length===1?mA[0]:mA:--this._eventsCount===0?this._events=new BA:delete this._events[WA]}return this},kA.prototype.removeAllListeners=function(TA){var EA;return TA?(EA=rA?rA+TA:TA,this._events[EA]&&(--this._eventsCount===0?this._events=new BA:delete this._events[EA])):(this._events=new BA,this._eventsCount=0),this},kA.prototype.off=kA.prototype.removeListener,kA.prototype.addListener=kA.prototype.on,kA.prototype.setMaxListeners=function(){return this},kA.prefixed=rA,kA.EventEmitter=kA,eA.exports=kA});function I(eA,oA,rA){return oA in eA?Object.defineProperty(eA,oA,{value:rA,enumerable:!0,configurable:!0,writable:!0}):eA[oA]=rA,eA}var l=function(){},B={data:"state-data",cdata:"state-cdata",tagBegin:"state-tag-begin",tagName:"state-tag-name",tagEnd:"state-tag-end",attributeNameStart:"state-attribute-name-start",attributeName:"state-attribute-name",attributeNameEnd:"state-attribute-name-end",attributeValueBegin:"state-attribute-value-begin",attributeValue:"state-attribute-value"},C={lt:"action-lt",gt:"action-gt",space:"action-space",equal:"action-equal",quote:"action-quote",slash:"action-slash",char:"action-char",error:"action-error"},Q={text:"text",openTag:"open-tag",closeTag:"close-tag",attributeName:"attribute-name",attributeValue:"attribute-value"},h={" ":C.space," ":C.space,"\n":C.space,"\r":C.space,"<":C.lt,">":C.gt,'"':C.quote,"'":C.quote,"=":C.equal,"/":C.slash},E=function(oA){return h[oA]||C.char},u=function(oA){var rA,BA,pA,kA,MA,TA,EA,_A,dA,WA;oA=Object.assign({debug:!1},oA);var VA=new c,It=B.data,mA="",gt="",PA="",UA="",jA="",xA="",DA=function(KA,ZA){if(!(gt[0]==="?"||gt[0]==="!")){var nt={type:KA,value:ZA};oA.debug&&console.log("emit:",nt),VA.emit("data",nt)}};VA.stateMachine=(WA={},I(WA,B.data,(rA={},I(rA,C.lt,function(){mA.trim()&&DA(Q.text,mA),gt="",jA=!1,It=B.tagBegin}),I(rA,C.char,function(FA){mA+=FA}),rA)),I(WA,B.cdata,I({},C.char,function(FA){mA+=FA,mA.substr(-3)==="]]>"&&(DA(Q.text,mA.slice(0,-3)),mA="",It=B.data)})),I(WA,B.tagBegin,(BA={},I(BA,C.space,l),I(BA,C.char,function(FA){gt=FA,It=B.tagName}),I(BA,C.slash,function(){gt="",jA=!0}),BA)),I(WA,B.tagName,(pA={},I(pA,C.space,function(){jA?It=B.tagEnd:(It=B.attributeNameStart,DA(Q.openTag,gt))}),I(pA,C.gt,function(){DA(jA?Q.closeTag:Q.openTag,gt),mA="",It=B.data}),I(pA,C.slash,function(){It=B.tagEnd,DA(Q.openTag,gt)}),I(pA,C.char,function(FA){gt+=FA,gt==="![CDATA["&&(It=B.cdata,mA="",gt="")}),pA)),I(WA,B.tagEnd,(kA={},I(kA,C.gt,function(){DA(Q.closeTag,gt),mA="",It=B.data}),I(kA,C.char,l),kA)),I(WA,B.attributeNameStart,(MA={},I(MA,C.char,function(FA){PA=FA,It=B.attributeName}),I(MA,C.gt,function(){mA="",It=B.data}),I(MA,C.space,l),I(MA,C.slash,function(){jA=!0,It=B.tagEnd}),MA)),I(WA,B.attributeName,(TA={},I(TA,C.space,function(){It=B.attributeNameEnd}),I(TA,C.equal,function(){DA(Q.attributeName,PA),It=B.attributeValueBegin}),I(TA,C.gt,function(){UA="",DA(Q.attributeName,PA),DA(Q.attributeValue,UA),mA="",It=B.data}),I(TA,C.slash,function(){jA=!0,UA="",DA(Q.attributeName,PA),DA(Q.attributeValue,UA),It=B.tagEnd}),I(TA,C.char,function(FA){PA+=FA}),TA)),I(WA,B.attributeNameEnd,(EA={},I(EA,C.space,l),I(EA,C.equal,function(){DA(Q.attributeName,PA),It=B.attributeValueBegin}),I(EA,C.gt,function(){UA="",DA(Q.attributeName,PA),DA(Q.attributeValue,UA),mA="",It=B.data}),I(EA,C.char,function(FA){UA="",DA(Q.attributeName,PA),DA(Q.attributeValue,UA),PA=FA,It=B.attributeName}),EA)),I(WA,B.attributeValueBegin,(_A={},I(_A,C.space,l),I(_A,C.quote,function(FA){xA=FA,UA="",It=B.attributeValue}),I(_A,C.gt,function(){UA="",DA(Q.attributeValue,UA),mA="",It=B.data}),I(_A,C.char,function(FA){xA="",UA=FA,It=B.attributeValue}),_A)),I(WA,B.attributeValue,(dA={},I(dA,C.space,function(FA){xA?UA+=FA:(DA(Q.attributeValue,UA),It=B.attributeNameStart)}),I(dA,C.quote,function(FA){xA===FA?(DA(Q.attributeValue,UA),It=B.attributeNameStart):UA+=FA}),I(dA,C.gt,function(FA){xA?UA+=FA:(DA(Q.attributeValue,UA),mA="",It=B.data)}),I(dA,C.slash,function(FA){xA?UA+=FA:(DA(Q.attributeValue,UA),jA=!0,It=B.tagEnd)}),I(dA,C.char,function(FA){UA+=FA}),dA)),WA);var HA=function(KA){oA.debug&&console.log(It,KA);var ZA=VA.stateMachine[It],nt=ZA[E(KA)]||ZA[C.error]||ZA[C.char];nt(KA)};return VA.write=function(FA){for(var KA=FA.length,ZA=0;ZA<KA;ZA++)HA(FA[ZA])},VA},d={State:B,Action:C,Type:Q,create:u},f=d.Type,m={element:"element",text:"text"},w=function(oA){return Object.assign({name:"",type:m.element,value:"",parent:null,attributes:{},children:[]},oA)},D=function(oA){oA=Object.assign({stream:!1,parentNodes:!0,doneEvent:"done",tagPrefix:"tag:",emitTopLevelOnly:!1,debug:!1},oA);var rA=void 0,BA=void 0,pA=void 0,kA=void 0,MA=new c,TA=function(_A){switch(_A.type){case f.openTag:if(pA===null)pA=BA,pA.name=_A.value;else{var dA=w({name:_A.value,parent:pA});pA.children.push(dA),pA=dA}break;case f.closeTag:var WA=pA.parent;if(oA.parentNodes||(pA.parent=null),pA.name!==_A.value)break;oA.stream&&WA===BA&&(BA.children=[],pA.parent=null),(!oA.emitTopLevelOnly||WA===BA)&&(MA.emit(oA.tagPrefix+pA.name,pA),MA.emit("tag",pA.name,pA)),pA===BA&&(rA.removeAllListeners("data"),MA.emit(oA.doneEvent,pA),BA=null),pA=WA;break;case f.text:pA&&pA.children.push(w({type:m.text,value:_A.value,parent:oA.parentNodes?pA:null}));break;case f.attributeName:kA=_A.value,pA.attributes[kA]="";break;case f.attributeValue:pA.attributes[kA]=_A.value;break}};return MA.reset=function(){rA=d.create({debug:oA.debug}),rA.on("data",TA),BA=w(),pA=null,kA="",MA.parse=rA.write},MA.reset(),MA},S=function(oA,rA){rA=Object.assign({},rA,{stream:!1,tagPrefix:":"});var BA=D(rA),pA=void 0;return BA.on("done",function(kA){pA=kA}),BA.parse(oA),pA},_={parseSync:S},b=_.parseSync,R=function(oA){var rA=b("<root>".concat(oA,"</root>"),{parentNodes:!1}),BA=rA.children&&rA.children.length>0&&rA.children.every(function(pA){return pA.name==="svg"});if(BA)return rA.children.length===1?rA.children[0]:rA.children;throw Error("nothing to parse")},F=function(oA){return g(oA,function(rA){return Y(rA)?rA:H(rA)})},H=function(oA){return oA.replace(/[-|:]([a-z])/gi,function(rA,BA){return BA.toUpperCase()})},Y=function(oA){return/^(data|aria)(-\w+)/.test(oA)},J=function(oA){if(oA){var rA=String(oA);return/[&<>]/.test(rA)?"<![CDATA[".concat(rA.replace(/]]>/,"]]]]><![CDATA[>"),"]]>"):rA}return""},O=function(oA){return String(oA).replace(/&/g,"&").replace(/'/g,"'").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")},W=function(oA){var rA=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},BA=rA.transformNode,pA=BA===void 0?function(EA){return EA}:BA,kA=rA.camelcase,MA=kA===void 0?!1:kA,TA=function(_A){var dA;return dA=pA(_A),MA&&(dA=F(dA)),dA};return TA(R(oA))};function z(){for(var eA=arguments.length,oA=new Array(eA),rA=0;rA<eA;rA++)oA[rA]=arguments[rA];return new Promise(function(BA,pA){try{var kA=W.apply(void 0,oA);BA(kA)}catch(MA){pA(MA)}})}var tA=function eA(oA){var rA=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},BA=rA.transformAttr,pA=BA===void 0?function(It,mA,gt){return"".concat(It,'="').concat(gt(mA),'"')}:BA,kA=rA.transformNode,MA=kA===void 0?function(It){return It}:kA,TA=rA.selfClose,EA=TA===void 0?!0:TA;if(Array.isArray(oA))return oA.map(function(It){return eA(It,{transformAttr:pA,selfClose:EA,transformNode:MA})}).join("");var _A=MA(oA);if(_A.type==="text")return J(_A.value);var dA="";for(var WA in _A.attributes){var VA=pA(WA,_A.attributes[WA],O,_A.name);dA+=VA?" ".concat(VA):""}return _A.children&&_A.children.length>0||!EA?"<".concat(_A.name).concat(dA,">").concat(eA(_A.children,{transformAttr:pA,transformNode:MA,selfClose:EA}),"</").concat(_A.name,">"):"<".concat(_A.name).concat(dA,"/>")},aA=Object.assign({},{parse:z,parseSync:W,stringify:tA});return aA})}}),nyA=Qa({"node_modules/js-beautify/js/src/core/output.js"(e,A){function t(o){this.__parent=o,this.__character_count=0,this.__indent_count=-1,this.__alignment_count=0,this.__wrap_point_index=0,this.__wrap_point_character_count=0,this.__wrap_point_indent_count=-1,this.__wrap_point_alignment_count=0,this.__items=[]}t.prototype.clone_empty=function(){var o=new t(this.__parent);return o.set_indent(this.__indent_count,this.__alignment_count),o},t.prototype.item=function(o){return o<0?this.__items[this.__items.length+o]:this.__items[o]},t.prototype.has_match=function(o){for(var s=this.__items.length-1;s>=0;s--)if(this.__items[s].match(o))return!0;return!1},t.prototype.set_indent=function(o,s){this.is_empty()&&(this.__indent_count=o||0,this.__alignment_count=s||0,this.__character_count=this.__parent.get_indent_size(this.__indent_count,this.__alignment_count))},t.prototype._set_wrap_point=function(){this.__parent.wrap_line_length&&(this.__wrap_point_index=this.__items.length,this.__wrap_point_character_count=this.__character_count,this.__wrap_point_indent_count=this.__parent.next_line.__indent_count,this.__wrap_point_alignment_count=this.__parent.next_line.__alignment_count)},t.prototype._should_wrap=function(){return this.__wrap_point_index&&this.__character_count>this.__parent.wrap_line_length&&this.__wrap_point_character_count>this.__parent.next_line.__character_count},t.prototype._allow_wrap=function(){if(this._should_wrap()){this.__parent.add_new_line();var o=this.__parent.current_line;return o.set_indent(this.__wrap_point_indent_count,this.__wrap_point_alignment_count),o.__items=this.__items.slice(this.__wrap_point_index),this.__items=this.__items.slice(0,this.__wrap_point_index),o.__character_count+=this.__character_count-this.__wrap_point_character_count,this.__character_count=this.__wrap_point_character_count,o.__items[0]===" "&&(o.__items.splice(0,1),o.__character_count-=1),!0}return!1},t.prototype.is_empty=function(){return this.__items.length===0},t.prototype.last=function(){return this.is_empty()?null:this.__items[this.__items.length-1]},t.prototype.push=function(o){this.__items.push(o);var s=o.lastIndexOf(`
|
|
5387
5387
|
`);s!==-1?this.__character_count=o.length-s:this.__character_count+=o.length},t.prototype.pop=function(){var o=null;return this.is_empty()||(o=this.__items.pop(),this.__character_count-=o.length),o},t.prototype._remove_indent=function(){this.__indent_count>0&&(this.__indent_count-=1,this.__character_count-=this.__parent.indent_size)},t.prototype._remove_wrap_indent=function(){this.__wrap_point_indent_count>0&&(this.__wrap_point_indent_count-=1)},t.prototype.trim=function(){for(;this.last()===" ";)this.__items.pop(),this.__character_count-=1},t.prototype.toString=function(){var o="";return this.is_empty()?this.__parent.indent_empty_lines&&(o=this.__parent.get_indent_string(this.__indent_count)):(o=this.__parent.get_indent_string(this.__indent_count,this.__alignment_count),o+=this.__items.join("")),o};function i(o,s){this.__cache=[""],this.__indent_size=o.indent_size,this.__indent_string=o.indent_char,o.indent_with_tabs||(this.__indent_string=new Array(o.indent_size+1).join(o.indent_char)),s=s||"",o.indent_level>0&&(s=new Array(o.indent_level+1).join(this.__indent_string)),this.__base_string=s,this.__base_string_length=s.length}i.prototype.get_indent_size=function(o,s){var r=this.__base_string_length;return s=s||0,o<0&&(r=0),r+=o*this.__indent_size,r+=s,r},i.prototype.get_indent_string=function(o,s){var r=this.__base_string;return s=s||0,o<0&&(o=0,r=""),s+=o*this.__indent_size,this.__ensure_cache(s),r+=this.__cache[s],r},i.prototype.__ensure_cache=function(o){for(;o>=this.__cache.length;)this.__add_column()},i.prototype.__add_column=function(){var o=this.__cache.length,s=0,r="";this.__indent_size&&o>=this.__indent_size&&(s=Math.floor(o/this.__indent_size),o-=s*this.__indent_size,r=new Array(s+1).join(this.__indent_string)),o&&(r+=new Array(o+1).join(" ")),this.__cache.push(r)};function n(o,s){this.__indent_cache=new i(o,s),this.raw=!1,this._end_with_newline=o.end_with_newline,this.indent_size=o.indent_size,this.wrap_line_length=o.wrap_line_length,this.indent_empty_lines=o.indent_empty_lines,this.__lines=[],this.previous_line=null,this.current_line=null,this.next_line=new t(this),this.space_before_token=!1,this.non_breaking_space=!1,this.previous_token_wrapped=!1,this.__add_outputline()}n.prototype.__add_outputline=function(){this.previous_line=this.current_line,this.current_line=this.next_line.clone_empty(),this.__lines.push(this.current_line)},n.prototype.get_line_number=function(){return this.__lines.length},n.prototype.get_indent_string=function(o,s){return this.__indent_cache.get_indent_string(o,s)},n.prototype.get_indent_size=function(o,s){return this.__indent_cache.get_indent_size(o,s)},n.prototype.is_empty=function(){return!this.previous_line&&this.current_line.is_empty()},n.prototype.add_new_line=function(o){return this.is_empty()||!o&&this.just_added_newline()?!1:(this.raw||this.__add_outputline(),!0)},n.prototype.get_code=function(o){this.trim(!0);var s=this.current_line.pop();s&&(s[s.length-1]===`
|
|
5388
5388
|
`&&(s=s.replace(/\n+$/g,"")),this.current_line.push(s)),this._end_with_newline&&this.__add_outputline();var r=this.__lines.join(`
|
|
5389
5389
|
`);return o!==`
|
|
@@ -5468,7 +5468,7 @@ $1`).replace(/>(\s*)(?=<!--\s*\/)/g,"> ")}}});function zCt(e,A,t){if(!A||!t)retu
|
|
|
5468
5468
|
transition: opacity 0.2s;
|
|
5469
5469
|
margin-bottom: 10px;
|
|
5470
5470
|
color: red;
|
|
5471
|
-
`,A$e=({children:e,transform:A=ba(),elements:t})=>{const i=AA.useRef(null),{isShowingDRCErrors:n,hoveredErrorId:o}=fB(g=>({isShowingDRCErrors:g.is_showing_drc_errors,hoveredErrorId:g.hovered_error_id}));if(!t)return Z.jsx("div",{style:{position:"relative"},ref:i,children:e});const s=t.filter(g=>g.type==="pcb_trace_error"),r=t.filter(g=>g.type==="pcb_trace_error"&&g.message?.includes("Multiple components found with name")),a=new Map;return t.forEach(g=>{g.type==="pcb_port"&&a.set(g.pcb_port_id,g)}),Z.jsxs("div",{style:{position:"relative"},ref:i,children:[e,s.map((g,c)=>{const{pcb_port_ids:I,pcb_trace_id:l}=g,B=I?.[0]?a.get(I[0]):void 0,C=I?.[1]?a.get(I[1]):void 0,Q=t?Vb(t).pcb_trace.get(l):void 0,h=g.pcb_trace_error_id||`error_${c}_${g.error_type}_${g.message?.slice(0,20)}`,E=o===h;if(B&&C){const u=Ct(A,{x:B.x,y:B.y}),d=Ct(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=IyA(m,i);return Z.jsxs(AA.Fragment,{children:[Z.jsx(X7e,{screenPort1:u,screenPort2:d,errorCenter:m,canLineBeDrawn:f,isHighlighted:E}),Z.jsx("div",{style:{position:"absolute",left:m.x-15,top:m.y-15,width:30,height:30,zIndex:Sc.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")}}}}),Z.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:Z.jsx("div",{className:`error-message ${lyA}`,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=>Ct(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=IyA(f,i);return Z.jsxs(AA.Fragment,{children:[Z.jsx($7e,{points:u,errorCenter:f,isHighlighted:E}),Z.jsx("div",{style:{position:"absolute",left:f.x-15,top:f.y-15,width:30,height:30,zIndex:Sc.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")}}}}),Z.jsx("div",{style:{position:"absolute",zIndex:E?Sc.errorOverlay+10:Sc.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:Z.jsx("div",{className:`error-message ${lyA}`,style:{opacity:E?1:0,border:`1px solid ${E?"#ff4444":"red"}`},children:g.message})})]},h)}return null}),r.map((g,c)=>{const I=g.component_name||g.message?.match(/name "([^"]+)"/)?.[1];if(!I)return null;const l=t?.filter(Q=>Q.type==="source_component"&&Q.name===I||Q.type==="pcb_component"&&t?.find(h=>h.type==="source_component"&&h.source_component_id===Q.source_component_id&&h.name===I))||[],B=g.pcb_trace_error_id||`error_${c}_${g.error_type}_${g.message?.slice(0,20)}`,C=o===B;return!C&&!n?null:l.map((Q,h)=>{let E={x:0,y:0};if(Q.type==="pcb_component")E=Q.center||{x:0,y:0};else if(Q.type==="source_component"){const _=t?.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=Ct(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=IyA(u,i);return Z.jsxs(AA.Fragment,{children:[Z.jsx("svg",{style:{position:"absolute",left:0,top:0,pointerEvents:"none",mixBlendMode:"difference",zIndex:Sc.errorOverlay},width:"100%",height:"100%",children:C?Z.jsx("polygon",{points:`${u.x},${u.y-D*1.25} ${u.x+D},${u.y} ${u.x},${u.y+D*1.25} ${u.x-D},${u.y}`,fill:"#ff4444"}):Z.jsx("circle",{cx:u.x,cy:u.y,r:D,fill:"none",stroke:C?"#ff4444":"red",strokeWidth:C?Math.max(2,D*.15):Math.max(1,D*.1),opacity:1})}),Z.jsx("div",{style:{position:"absolute",left:u.x-(D+10),top:u.y-(D+10),width:(D+10)*2,height:(D+10)*2,zIndex:Sc.errorOverlay+5,cursor:"pointer",borderRadius:"50%"},onMouseEnter:_=>{const b=_.currentTarget.nextElementSibling;if(b){const R=b.querySelector(".error-message");R&&(R.style.opacity="1")}},onMouseLeave:_=>{if(!C){const b=_.currentTarget.nextElementSibling;if(b){const R=b.querySelector(".error-message");R&&(R.style.opacity="0")}}}}),Z.jsx("div",{style:{position:"absolute",zIndex:C?Sc.errorOverlay+20:Sc.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:Z.jsx("div",{className:`error-message ${lyA}`,style:{opacity:C?1:0,border:`1px solid ${C?"#ff4444":"red"}`},children:g.message})})]},`${B}_${h}`)})})]})};function t$e(e,A){return e.size!==A.size?!1:Array.from(e).every(t=>A.has(t))}function e$e({primitiveElement:e,elements:A}){let t=e.trace_length?`${e.trace_length.toFixed(3)}`:"";const i=Vb(A).source_trace.get(e?.source_trace_id);if(i?.display_name&&(i?.max_length?t+=` / ${i.max_length}mm `:t+=" mm ",t+=`(${i.display_name})`),!t)return null;const n=e.trace_length&&i?.max_length&&e.trace_length>i.max_length;return{text:t,isOverLength:n}}function i$e(e){const{primitives:A,is_showing_multiple_traces_length:t,elements:i}=e,n=A.filter(a=>a._element.type==="pcb_trace"),o=i.filter(a=>a.type==="source_trace"),s=A.filter(a=>a._element.type!=="pcb_trace"),r=n.filter(a=>o.some(g=>a._element.type==="pcb_trace"&&a._element.source_trace_id===g.source_trace_id&&g.max_length!==void 0));if(!t)return[...s,...r];if(n.length>1){const a=n.reduce((g,c)=>{const I=g._element.trace_length;return c._element.trace_length<I?c:g},n[0]);return[...s,a]}return A}var n$e={position:"absolute",left:0,top:0,pointerEvents:"none",color:"red",fontFamily:"sans-serif",fontSize:12,textShadow:"0 0 2px black"},o$e=e=>{const{_element:A,_parent_pcb_component:t,_parent_source_component:i,_source_port:n}=e;switch(A.type){case"pcb_trace":return A.trace_length?`${A.trace_length.toFixed(3)}`:"";case"pcb_smtpad":case"pcb_plated_hole":{const o=[],s=Array.from(new Set((A.port_hints??[]).concat(n?.port_hints??[]))).filter(a=>!/^[0-9]+$/.test(a)).filter(a=>!a.includes("unnamed_")).sort((a,g)=>g.localeCompare(a)),r=i&&"name"in i&&i.name&&!i.name.includes("unnamed_")?i.name:null;return s.length>0?r?o.push(...s.map(a=>`${r}.${a}`)):o.push(...s):r&&o.push(r),o.join(", ")}default:return""}},s$e={top:"red",bottom:"aqua"},r$e=({primitive:e,mousePos:A,elements:t})=>{const[i,n]=AA.useState(!1),o=e._element;AA.useEffect(()=>{setTimeout(()=>{n(!0)},100)},[]);const[s,r,a,g]=[e.screen_x,e.screen_y,e.screen_w,e.screen_h],c=e.same_space_index??0,I=26,l=s$e[e?._element?.layer]??"red";let B=0;if(o.type==="pcb_smtpad"&&o?.shape==="rotated_rect"?B=o?.ccw_rotation??0:(o.type==="pcb_smtpad"&&(o?.shape==="pill"||o?.shape==="rotated_pill")&&"ccw_rotation"in e||o.type==="pcb_plated_hole"&&(o?.shape==="pill"||o?.shape==="oval")&&"ccw_rotation"in e)&&(B=o.ccw_rotation??0),o.type==="pcb_trace"){const h=e$e({primitiveElement:o,elements:t});if(!h)return null;const E=A.y-35;return Z.jsx("div",{style:{zIndex:Sc.elementOverlay,position:"absolute",left:A.x,top:E,color:l,pointerEvents:"none",transform:"translateX(-50%)"},children:Z.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=o$e(e);return C.trim().length===0?null:Z.jsx("div",{style:{zIndex:Sc.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:Z.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:Z.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})})})},a$e=({highlightedPrimitives:e,mousePos:A,elements:t})=>{const[i,n]=fB(r=>[r.is_moving_component,r.is_showing_multiple_traces_length]),o=e.some(r=>r._element.type==="pcb_smtpad")&&e.some(r=>r._element.type==="pcb_trace");let s=e;return o&&(s=s.filter(r=>r._element.type==="pcb_smtpad")),s=i$e({primitives:s,is_showing_multiple_traces_length:n,elements:t}),Z.jsx("div",{style:n$e,children:!i&&s.map((r,a)=>Z.jsx(r$e,{primitive:r,mousePos:A,elements:t},a))})},Rk=e=>e?.type==="pcb_component",DQt=e=>e?.type==="pcb_group",g$e=e=>e?.type==="pcb_panel",ByA=e=>e?.type==="pcb_board",sI={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},Ay={OFFSET_LINE:"white",COMPONENT_MARKER_FILL:"#66ccff",COMPONENT_MARKER_STROKE:"white",LABEL_TEXT:"white"},CyA=({targets:e,transform:A,containerWidth:t,containerHeight:i})=>{if(e.length===0)return null;const n={color:Ay.LABEL_TEXT,mixBlendMode:"difference",pointerEvents:"none",fontSize:sI.LABEL_FONT_SIZE,fontFamily:"monospace",fontWeight:"bold"},o=new Map;return e.forEach(s=>{if(!o.has(s.anchor_id)){const r=Ct(A,s.anchor);o.set(s.anchor_id,r)}}),Z.jsx("div",{style:{position:"absolute",left:0,top:0,width:t,height:i,overflow:"hidden",pointerEvents:"none",zIndex:Sc.dimensionOverlay},children:Z.jsxs("svg",{style:{position:"absolute",left:0,top:0,pointerEvents:"none"},width:t,height:i,children:[e.map(s=>{const r=s.anchor,a=s.anchor_id,g=s.target,c=o.get(a),I=Ct(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?sI.LABEL_OFFSET_ABOVE:sI.LABEL_OFFSET_BELOW,d=E?sI.LABEL_OFFSET_RIGHT:sI.LABEL_OFFSET_LEFT,f=C>sI.MIN_LINE_LENGTH_FOR_LABEL,m=Q>sI.MIN_LINE_LENGTH_FOR_LABEL,w=`${s.display_offset_x??l.toFixed(2)}mm`,D=`${s.display_offset_y??B.toFixed(2)}mm`;return Z.jsxs("g",{children:[Z.jsx("line",{x1:c.x,y1:c.y,x2:I.x,y2:c.y,stroke:Ay.OFFSET_LINE,strokeWidth:sI.LINE_STROKE_WIDTH,strokeDasharray:sI.LINE_DASH_PATTERN}),Z.jsx("line",{x1:I.x,y1:c.y,x2:I.x,y2:I.y,stroke:Ay.OFFSET_LINE,strokeWidth:sI.LINE_STROKE_WIDTH,strokeDasharray:sI.LINE_DASH_PATTERN}),s.type==="component"||s.type==="board"?Z.jsx("circle",{cx:I.x,cy:I.y,r:sI.COMPONENT_MARKER_RADIUS,fill:Ay.COMPONENT_MARKER_FILL,stroke:Ay.COMPONENT_MARKER_STROKE,strokeWidth:1}):Z.jsxs(Z.Fragment,{children:[Z.jsx("line",{x1:I.x-sI.ANCHOR_MARKER_SIZE,y1:I.y,x2:I.x+sI.ANCHOR_MARKER_SIZE,y2:I.y,stroke:Ay.OFFSET_LINE,strokeWidth:sI.ANCHOR_MARKER_STROKE_WIDTH}),Z.jsx("line",{x1:I.x,y1:I.y-sI.ANCHOR_MARKER_SIZE,x2:I.x,y2:I.y+sI.ANCHOR_MARKER_SIZE,stroke:Ay.OFFSET_LINE,strokeWidth:sI.ANCHOR_MARKER_STROKE_WIDTH})]}),f&&Z.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:Z.jsx("div",{style:{...n,textAlign:"center"},children:w})}),m&&Z.jsx("foreignObject",{x:I.x+d,y:Math.min(c.y,I.y),width:sI.Y_LABEL_MIN_WIDTH,height:Math.abs(I.y-c.y),style:{overflow:"visible"},children:Z.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])=>Z.jsxs("g",{children:[Z.jsx("line",{x1:r.x-sI.ANCHOR_MARKER_SIZE,y1:r.y,x2:r.x+sI.ANCHOR_MARKER_SIZE,y2:r.y,stroke:Ay.OFFSET_LINE,strokeWidth:sI.ANCHOR_MARKER_STROKE_WIDTH}),Z.jsx("line",{x1:r.x,y1:r.y-sI.ANCHOR_MARKER_SIZE,x2:r.x,y2:r.y+sI.ANCHOR_MARKER_SIZE,stroke:Ay.OFFSET_LINE,strokeWidth:sI.ANCHOR_MARKER_STROKE_WIDTH})]},`anchor-${s}`))]})})},c$e=({elements:e,highlightedPrimitives:A,transform:t,containerWidth:i,containerHeight:n})=>{const o=e.filter(E=>ByA(E)),s=e.filter(E=>Rk(E)),r=e.filter(E=>DQt(E)),a=A.map(E=>Rk(E._parent_pcb_component)?E._parent_pcb_component.pcb_component_id:Rk(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)}),!fB(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 Z.jsx(CyA,{targets:h,transform:t,containerWidth:i,containerHeight:n})},I$e=({elements:e,highlightedPrimitives:A,transform:t,containerWidth:i,containerHeight:n})=>{const o=e.filter(E=>DQt(E)),s=e.filter(E=>Rk(E)),r=A.map(E=>Rk(E._parent_pcb_component)?E._parent_pcb_component.pcb_component_id:Rk(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))}),!fB(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 Z.jsx(CyA,{targets:h,transform:t,containerWidth:i,containerHeight:n})},l$e=(e,A)=>{const t=e.pcb_component_id,i=A.filter(n=>(n.type==="pcb_smtpad"||n.type==="pcb_plated_hole")&&n.pcb_component_id===t||n.type==="pcb_hole"&&n.pcb_component_id===t);return i.length===0?gyA([e]):gyA(i)},B$e=({elements:e,highlightedPrimitives:A,transform:t,containerWidth:i,containerHeight:n})=>{const o=new Map;for(const r of A)Rk(r._parent_pcb_component)&&o.set(r._parent_pcb_component.pcb_component_id,r._parent_pcb_component),Rk(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=l$e(r,e);if(!a)continue;const g=r.positioned_relative_to_pcb_group_id??r.pcb_group_id,c=g?Vb(e).pcb_group.get(g):null;s.push({component:r,bbox:a,group:c})}return s.length===0?null:Z.jsx("div",{style:{position:"absolute",left:0,top:0,width:i,height:n,overflow:"hidden",pointerEvents:"none",zIndex:Sc.dimensionOverlay},children:Z.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=Ct(t,{x:a.minX,y:a.maxY}),I=Ct(t,{x:a.maxX,y:a.minY}),l={x:Math.min(c.x,I.x),y:Math.min(c.y,I.y),width:Math.abs(I.x-c.x),height:Math.abs(I.y-c.y)},B=r.center??{x:(a.minX+a.maxX)/2,y:(a.minY+a.maxY)/2},C=Ct(t,B);return Z.jsxs("g",{children:[Z.jsx("rect",{x:l.x,y:l.y,width:l.width,height:l.height,fill:"none",stroke:"white",strokeWidth:1.5,strokeDasharray:"4,4"}),Z.jsx("line",{x1:C.x-6,y1:C.y,x2:C.x+6,y2:C.y,stroke:Ay.COMPONENT_MARKER_STROKE,strokeWidth:1.5}),Z.jsx("line",{x1:C.x,y1:C.y-6,x2:C.x,y2:C.y+6,stroke:Ay.COMPONENT_MARKER_STROKE,strokeWidth:1.5}),Z.jsx("circle",{cx:C.x,cy:C.y,r:sI.COMPONENT_MARKER_RADIUS,fill:Ay.COMPONENT_MARKER_FILL,stroke:Ay.COMPONENT_MARKER_STROKE,strokeWidth:1})]},r.pcb_component_id)})})})},C$e=({elements:e,highlightedPrimitives:A,transform:t,containerWidth:i,containerHeight:n})=>{const o=e.filter(B=>g$e(B)),s=e.filter(B=>ByA(B)),r=A.map(B=>ByA(B._element)?B._element.pcb_board_id:null).filter(B=>!!B);if(!fB(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 Z.jsx(CyA,{targets:l,transform:t,containerWidth:i,containerHeight:n})},qj=e=>{if(e.length===0)return null;let A=e[0].x,t=e[0].y,i=e[0].x,n=e[0].y;for(const o of e)o.x<A&&(A=o.x),o.y<t&&(t=o.y),o.x>i&&(i=o.x),o.y>n&&(n=o.y);return{center:{x:(A+i)/2,y:(t+n)/2},width:i-A,height:n-t}},SQt=(e,A)=>{if(A.length<3)return!1;let t=!1;for(let i=0,n=A.length-1;i<A.length;n=i++){const o=A[i].x,s=A[i].y,r=A[n].x,a=A[n].y;s>e.y!=a>e.y&&e.x<(r-o)*(e.y-s)/(a-s||Number.EPSILON)+o&&(t=!t)}return t},Q$e=(e,A,t)=>{const i=[];for(const n of e){if(!n._element)continue;if("x1"in n&&n._element?.type==="pcb_trace"){const r=KE({x:A.x,y:A.y},{x:n.x1,y:n.y1},{x:n.x2,y:n.y2}),a=n.width||.5,g=Math.max(a*25,2)/t.a;r<g&&i.push(n);continue}if(n.pcb_drawing_type==="polygon"){const r=n.points.map(g=>({x:Ee.parse(g.x),y:Ee.parse(g.y)})),a=qj(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;SQt(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:Ee.parse(g.x),y:Ee.parse(g.y)})),a=qj(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;SQt(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},h$e=({elements:e,children:A,transform:t,primitives:i,onMouseHoverOverPrimitives:n})=>{const[o,s]=AA.useState([]),[r,a]=AA.useState({x:0,y:0}),[g,{width:c,height:I}]=fT(),l=AA.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=qj(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=qj(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=Ct(t,h),f={w:E*t.a,h:u*t.a},m=C.filter(w=>d.x===w.screen_x&&d.y===w.screen_y&&f.w===w.screen_w&&f.h===w.screen_h).length;C.push({...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,t]),B=(C,Q,h,E)=>{a({x:C,y:Q});const u=Ct(jy(h),{x:C,y:Q}),d=Q$e(E,u,h);t$e(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 Z.jsxs("div",{ref:g,style:{position:"relative",width:"100%",height:"100%"},onMouseMove:C=>{if(t){const Q=C.currentTarget.getBoundingClientRect(),h=C.clientX-Q.left,E=C.clientY-Q.top;B(h,E,t,i)}},onTouchStart:C=>{if(t){const Q=C.touches[0],h=C.currentTarget.getBoundingClientRect(),E=Q.clientX-h.left,u=Q.clientY-h.top;B(E,u,t,i)}},children:[A,Z.jsx(a$e,{elements:e,mousePos:r,highlightedPrimitives:l}),t&&Z.jsxs(Z.Fragment,{children:[Z.jsx(c$e,{elements:e,highlightedPrimitives:l,transform:t,containerWidth:c,containerHeight:I}),Z.jsx(I$e,{elements:e,highlightedPrimitives:l,transform:t,containerWidth:c,containerHeight:I}),Z.jsx(B$e,{elements:e,highlightedPrimitives:l,transform:t,containerWidth:c,containerHeight:I}),Z.jsx(C$e,{elements:e,highlightedPrimitives:l,transform:t,containerWidth:c,containerHeight:I})]})]})},bQt=["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)"],E$e=({children:e,transform:A=ba(),elements:t=[],hoveredComponentIds:i=[]})=>{const[n,{width:o,height:s}]=fT(),r=AA.useRef(null),{is_showing_pcb_groups:a,pcb_group_view_mode:g,is_showing_group_anchor_offsets:c}=fB(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 AA.useEffect(()=>{const I=r.current;if(!I||!o||!s)return;I.width=o,I.height=s;const l=I.getContext("2d");if(!l||(l.clearRect(0,0,o,s),!a))return;const B=t.filter(w=>w.type==="pcb_group"),C=t.filter(w=>w.type==="pcb_component"),Q=t.filter(w=>w.type==="source_group"),h=new Map(Q.map(w=>[w.source_group_id,w])),E=B.filter(w=>{if(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(UA=>UA.pcb_group_id===w.pcb_group_id);if(w.source_group_id){const UA=d(w.source_group_id),jA=B.filter(xA=>xA.source_group_id&&UA.includes(xA.source_group_id));for(const xA of jA){const DA=C.filter(HA=>HA.pcb_group_id===xA.pcb_group_id);S=[...S,...DA]}}let _,b,R,F,H=!1;if(w.center&&w.width&&w.height){H=!0;const UA=w.width/2,jA=w.height/2;_=w.center.x-UA,R=w.center.x+UA,b=w.center.y-jA,F=w.center.y+jA}else if(S.length===0||(_=1/0,b=1/0,R=-1/0,F=-1/0,S.forEach(UA=>{if(UA.center&&typeof UA.width=="number"&&typeof UA.height=="number"){const jA=UA.center.x-UA.width/2,xA=UA.center.x+UA.width/2,DA=UA.center.y+UA.height/2,HA=UA.center.y-UA.height/2;_=Math.min(_,jA),R=Math.max(R,xA),b=Math.min(b,HA),F=Math.max(F,DA)}}),_===1/0||R===-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(!H){const xA=1+(J?.5:0);_-=xA,R+=xA,b-=xA,F+=xA}const O=Ct(A,{x:_,y:F}),W=Ct(A,{x:R,y:F}),z=Ct(A,{x:_,y:b}),tA=Ct(A,{x:R,y:b}),aA=bQt[D%bQt.length];l.strokeStyle=aA,l.lineWidth=2;const eA=Math.max(4,Math.min(12,8*Math.abs(A.a))),oA=Math.max(2,Math.min(6,4*Math.abs(A.a))),BA=eA*(J?1.3:1),pA=oA;l.setLineDash([BA,pA]),l.beginPath(),l.moveTo(O.x,O.y),l.lineTo(W.x,W.y),l.lineTo(tA.x,tA.y),l.lineTo(z.x,z.y),l.closePath(),l.stroke();const kA=Math.max(8,Math.min(12,10*Math.abs(A.a))),MA=Y==0||Y==1?0:Y*.11,TA=kA*(1-MA),EA=4,_A=w.name||`Group ${D+1}`;l.font=`${TA}px sans-serif`,l.setLineDash([]);const WA=l.measureText(_A).width+EA*2,VA=TA+EA*2,It=O.x-5,mA=O.y-5,gt=3;if(l.fillStyle="rgba(0, 0, 0, 0.8)",l.beginPath(),l.roundRect(It,mA-VA,WA,VA,gt),l.fill(),l.fillStyle=aA,l.textAlign="left",l.textBaseline="middle",l.fillText(_A,It+EA,mA-VA/2),c&&m.has(w.pcb_group_id)&&!!w.anchor_position&&w.anchor_position){const UA=Array.isArray(w.anchor_position)?{x:w.anchor_position[0]??0,y:w.anchor_position[1]??0}:{x:w.anchor_position.x,y:w.anchor_position.y},jA=Ct(A,UA);l.strokeStyle="white",l.lineWidth=1.5,l.setLineDash([]);const xA=Math.max(4,Math.min(8,6*Math.abs(A.a)));l.beginPath(),l.moveTo(jA.x-xA,jA.y),l.lineTo(jA.x+xA,jA.y),l.stroke(),l.beginPath(),l.moveTo(jA.x,jA.y-xA),l.lineTo(jA.x,jA.y+xA),l.stroke()}})},[t,A,o,s,a,g,c,i]),Z.jsxs("div",{ref:n,style:{position:"relative",width:"100%",height:"100%"},children:[e,Z.jsx("canvas",{ref:r,style:{position:"absolute",top:0,left:0,pointerEvents:"none",zIndex:Sc.pcbGroupOverlay,display:a?"block":"none"}})]})},u$e=({transform:e,soup:A,children:t})=>{const i=fB(r=>r.is_showing_rats_nest),{netMap:n,idToNetMap:o}=AA.useMemo(()=>nQt(A||[]),[A]),s=AA.useMemo(()=>{if(!A||!i)return[];const r=l=>{const B=Vb(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=Vb(A).pcb_port.list(),c=Vb(A).source_trace.list(),I=[];return g.forEach((l,B)=>{const C=o[l.pcb_port_id];let Q=!1;for(const u of c)u.connected_source_port_ids.includes(l.source_port_id)&&u.connected_source_net_ids.length>0&&(Q=!0);if(!C)return;const h={x:l.x,y:l.y},E=a(h,C);E&&I.push({key:`${l.pcb_port_id}-${B}`,startPoint:h,endPoint:E,isInNet:Q})}),I},[A,n,o,i]);return!A||!i?t:(e||(e=ba()),Z.jsxs("div",{style:{position:"relative"},children:[t,Z.jsx("svg",{style:{position:"absolute",left:0,top:0,width:"100%",height:"100%",pointerEvents:"none",opacity:.5,zIndex:Sc.ratsNestOverlay},children:s.map(({key:r,startPoint:a,endPoint:g,isInNet:c})=>{const I=Ct(e,a),l=Ct(e,g);return Z.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)})})]}))},d$e={version:"1.11.349"},Nk=(e,A,t)=>{const i=fB(s=>s.is_mouse_over_container),n=AA.useRef(i),o=AA.useRef(A);AA.useEffect(()=>{n.current=i},[i]),AA.useEffect(()=>{o.current=A},[A]),AA.useEffect(()=>{if(!e)return;const s=r=>{const a=r.target;if(a.tagName==="INPUT"||a.tagName==="TEXTAREA"||a.isContentEditable)return;const g=e.split("+"),c=g.includes("ctrl"),I=g.includes("shift"),l=g.includes("alt"),B=g.includes("meta"),C=g[g.length-1],Q=t?.current?t.current.contains(document.activeElement)||document.activeElement===t.current:!1;(n.current||Q)&&(!c||r.ctrlKey)&&(!I||r.shiftKey)&&(!l||r.altKey)&&(!B||r.metaKey)&&r.key.toLowerCase()===C.toLowerCase()&&(r.preventDefault(),o.current())};return window.addEventListener("keydown",s),()=>{window.removeEventListener("keydown",s)}},[e])},p$e=()=>{const[e,A]=AA.useState(!1);return AA.useEffect(()=>{const t=()=>{A(window.innerWidth<=768)};return t(),window.addEventListener("resize",t),()=>window.removeEventListener("resize",t)},[]),e},mT=(e,A={stopPropagation:!0})=>{const t=AA.useRef(0),i=AA.useCallback(s=>{A.stopPropagation&&s.stopPropagation();const r=Date.now();r-t.current<300||(t.current=r,e?.(s))},[e,A.stopPropagation]),n=AA.useCallback(s=>{s.preventDefault(),i(s)},[i]);return{onClick:i,onTouchEnd:n,style:{touchAction:"manipulation"}}},f$e=({name:e,selected:A,onClick:t})=>{const{style:i,...n}=mT(t);return Z.jsxs("div",{className:o1`
|
|
5471
|
+
`,A$e=({children:e,transform:A=ba(),elements:t})=>{const i=AA.useRef(null),{isShowingDRCErrors:n,hoveredErrorId:o}=fB(g=>({isShowingDRCErrors:g.is_showing_drc_errors,hoveredErrorId:g.hovered_error_id}));if(!t)return Z.jsx("div",{style:{position:"relative"},ref:i,children:e});const s=t.filter(g=>g.type==="pcb_trace_error"),r=t.filter(g=>g.type==="pcb_trace_error"&&g.message?.includes("Multiple components found with name")),a=new Map;return t.forEach(g=>{g.type==="pcb_port"&&a.set(g.pcb_port_id,g)}),Z.jsxs("div",{style:{position:"relative"},ref:i,children:[e,s.map((g,c)=>{const{pcb_port_ids:I,pcb_trace_id:l}=g,B=I?.[0]?a.get(I[0]):void 0,C=I?.[1]?a.get(I[1]):void 0,Q=t?Vb(t).pcb_trace.get(l):void 0,h=g.pcb_trace_error_id||`error_${c}_${g.error_type}_${g.message?.slice(0,20)}`,E=o===h;if(B&&C){const u=Ct(A,{x:B.x,y:B.y}),d=Ct(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=IyA(m,i);return Z.jsxs(AA.Fragment,{children:[Z.jsx(X7e,{screenPort1:u,screenPort2:d,errorCenter:m,canLineBeDrawn:f,isHighlighted:E}),Z.jsx("div",{style:{position:"absolute",left:m.x-15,top:m.y-15,width:30,height:30,zIndex:Sc.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")}}}}),Z.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:Z.jsx("div",{className:`error-message ${lyA}`,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=>Ct(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=IyA(f,i);return Z.jsxs(AA.Fragment,{children:[Z.jsx($7e,{points:u,errorCenter:f,isHighlighted:E}),Z.jsx("div",{style:{position:"absolute",left:f.x-15,top:f.y-15,width:30,height:30,zIndex:Sc.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")}}}}),Z.jsx("div",{style:{position:"absolute",zIndex:E?Sc.errorOverlay+10:Sc.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:Z.jsx("div",{className:`error-message ${lyA}`,style:{opacity:E?1:0,border:`1px solid ${E?"#ff4444":"red"}`},children:g.message})})]},h)}return null}),r.map((g,c)=>{const I=g.component_name||g.message?.match(/name "([^"]+)"/)?.[1];if(!I)return null;const l=t?.filter(Q=>Q.type==="source_component"&&Q.name===I||Q.type==="pcb_component"&&t?.find(h=>h.type==="source_component"&&h.source_component_id===Q.source_component_id&&h.name===I))||[],B=g.pcb_trace_error_id||`error_${c}_${g.error_type}_${g.message?.slice(0,20)}`,C=o===B;return!C&&!n?null:l.map((Q,h)=>{let E={x:0,y:0};if(Q.type==="pcb_component")E=Q.center||{x:0,y:0};else if(Q.type==="source_component"){const _=t?.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=Ct(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=IyA(u,i);return Z.jsxs(AA.Fragment,{children:[Z.jsx("svg",{style:{position:"absolute",left:0,top:0,pointerEvents:"none",mixBlendMode:"difference",zIndex:Sc.errorOverlay},width:"100%",height:"100%",children:C?Z.jsx("polygon",{points:`${u.x},${u.y-D*1.25} ${u.x+D},${u.y} ${u.x},${u.y+D*1.25} ${u.x-D},${u.y}`,fill:"#ff4444"}):Z.jsx("circle",{cx:u.x,cy:u.y,r:D,fill:"none",stroke:C?"#ff4444":"red",strokeWidth:C?Math.max(2,D*.15):Math.max(1,D*.1),opacity:1})}),Z.jsx("div",{style:{position:"absolute",left:u.x-(D+10),top:u.y-(D+10),width:(D+10)*2,height:(D+10)*2,zIndex:Sc.errorOverlay+5,cursor:"pointer",borderRadius:"50%"},onMouseEnter:_=>{const b=_.currentTarget.nextElementSibling;if(b){const R=b.querySelector(".error-message");R&&(R.style.opacity="1")}},onMouseLeave:_=>{if(!C){const b=_.currentTarget.nextElementSibling;if(b){const R=b.querySelector(".error-message");R&&(R.style.opacity="0")}}}}),Z.jsx("div",{style:{position:"absolute",zIndex:C?Sc.errorOverlay+20:Sc.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:Z.jsx("div",{className:`error-message ${lyA}`,style:{opacity:C?1:0,border:`1px solid ${C?"#ff4444":"red"}`},children:g.message})})]},`${B}_${h}`)})})]})};function t$e(e,A){return e.size!==A.size?!1:Array.from(e).every(t=>A.has(t))}function e$e({primitiveElement:e,elements:A}){let t=e.trace_length?`${e.trace_length.toFixed(3)}`:"";const i=Vb(A).source_trace.get(e?.source_trace_id);if(i?.display_name&&(i?.max_length?t+=` / ${i.max_length}mm `:t+=" mm ",t+=`(${i.display_name})`),!t)return null;const n=e.trace_length&&i?.max_length&&e.trace_length>i.max_length;return{text:t,isOverLength:n}}function i$e(e){const{primitives:A,is_showing_multiple_traces_length:t,elements:i}=e,n=A.filter(a=>a._element.type==="pcb_trace"),o=i.filter(a=>a.type==="source_trace"),s=A.filter(a=>a._element.type!=="pcb_trace"),r=n.filter(a=>o.some(g=>a._element.type==="pcb_trace"&&a._element.source_trace_id===g.source_trace_id&&g.max_length!==void 0));if(!t)return[...s,...r];if(n.length>1){const a=n.reduce((g,c)=>{const I=g._element.trace_length;return c._element.trace_length<I?c:g},n[0]);return[...s,a]}return A}var n$e={position:"absolute",left:0,top:0,pointerEvents:"none",color:"red",fontFamily:"sans-serif",fontSize:12,textShadow:"0 0 2px black"},o$e=e=>{const{_element:A,_parent_pcb_component:t,_parent_source_component:i,_source_port:n}=e;switch(A.type){case"pcb_trace":return A.trace_length?`${A.trace_length.toFixed(3)}`:"";case"pcb_smtpad":case"pcb_plated_hole":{const o=[],s=Array.from(new Set((A.port_hints??[]).concat(n?.port_hints??[]))).filter(a=>!/^[0-9]+$/.test(a)).filter(a=>!a.includes("unnamed_")).sort((a,g)=>g.localeCompare(a)),r=i&&"name"in i&&i.name&&!i.name.includes("unnamed_")?i.name:null;return s.length>0?r?o.push(...s.map(a=>`${r}.${a}`)):o.push(...s):r&&o.push(r),o.join(", ")}default:return""}},s$e={top:"red",bottom:"aqua"},r$e=({primitive:e,mousePos:A,elements:t})=>{const[i,n]=AA.useState(!1),o=e._element;AA.useEffect(()=>{setTimeout(()=>{n(!0)},100)},[]);const[s,r,a,g]=[e.screen_x,e.screen_y,e.screen_w,e.screen_h],c=e.same_space_index??0,I=26,l=s$e[e?._element?.layer]??"red";let B=0;if(o.type==="pcb_smtpad"&&o?.shape==="rotated_rect"?B=o?.ccw_rotation??0:(o.type==="pcb_smtpad"&&(o?.shape==="pill"||o?.shape==="rotated_pill")&&"ccw_rotation"in e||o.type==="pcb_plated_hole"&&(o?.shape==="pill"||o?.shape==="oval")&&"ccw_rotation"in e)&&(B=o.ccw_rotation??0),o.type==="pcb_trace"){const h=e$e({primitiveElement:o,elements:t});if(!h)return null;const E=A.y-35;return Z.jsx("div",{style:{zIndex:Sc.elementOverlay,position:"absolute",left:A.x,top:E,color:l,pointerEvents:"none",transform:"translateX(-50%)"},children:Z.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=o$e(e);return C.trim().length===0?null:Z.jsx("div",{style:{zIndex:Sc.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:Z.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:Z.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})})})},a$e=({highlightedPrimitives:e,mousePos:A,elements:t})=>{const[i,n]=fB(r=>[r.is_moving_component,r.is_showing_multiple_traces_length]),o=e.some(r=>r._element.type==="pcb_smtpad")&&e.some(r=>r._element.type==="pcb_trace");let s=e;return o&&(s=s.filter(r=>r._element.type==="pcb_smtpad")),s=i$e({primitives:s,is_showing_multiple_traces_length:n,elements:t}),Z.jsx("div",{style:n$e,children:!i&&s.map((r,a)=>Z.jsx(r$e,{primitive:r,mousePos:A,elements:t},a))})},Rk=e=>e?.type==="pcb_component",DQt=e=>e?.type==="pcb_group",g$e=e=>e?.type==="pcb_panel",ByA=e=>e?.type==="pcb_board",sI={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},Ay={OFFSET_LINE:"white",COMPONENT_MARKER_FILL:"#66ccff",COMPONENT_MARKER_STROKE:"white",LABEL_TEXT:"white"},CyA=({targets:e,transform:A,containerWidth:t,containerHeight:i})=>{if(e.length===0)return null;const n={color:Ay.LABEL_TEXT,mixBlendMode:"difference",pointerEvents:"none",fontSize:sI.LABEL_FONT_SIZE,fontFamily:"monospace",fontWeight:"bold"},o=new Map;return e.forEach(s=>{if(!o.has(s.anchor_id)){const r=Ct(A,s.anchor);o.set(s.anchor_id,r)}}),Z.jsx("div",{style:{position:"absolute",left:0,top:0,width:t,height:i,overflow:"hidden",pointerEvents:"none",zIndex:Sc.dimensionOverlay},children:Z.jsxs("svg",{style:{position:"absolute",left:0,top:0,pointerEvents:"none"},width:t,height:i,children:[e.map(s=>{const r=s.anchor,a=s.anchor_id,g=s.target,c=o.get(a),I=Ct(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?sI.LABEL_OFFSET_ABOVE:sI.LABEL_OFFSET_BELOW,d=E?sI.LABEL_OFFSET_RIGHT:sI.LABEL_OFFSET_LEFT,f=C>sI.MIN_LINE_LENGTH_FOR_LABEL,m=Q>sI.MIN_LINE_LENGTH_FOR_LABEL,w=`${s.display_offset_x??l.toFixed(2)}mm`,D=`${s.display_offset_y??B.toFixed(2)}mm`;return Z.jsxs("g",{children:[Z.jsx("line",{x1:c.x,y1:c.y,x2:I.x,y2:c.y,stroke:Ay.OFFSET_LINE,strokeWidth:sI.LINE_STROKE_WIDTH,strokeDasharray:sI.LINE_DASH_PATTERN}),Z.jsx("line",{x1:I.x,y1:c.y,x2:I.x,y2:I.y,stroke:Ay.OFFSET_LINE,strokeWidth:sI.LINE_STROKE_WIDTH,strokeDasharray:sI.LINE_DASH_PATTERN}),s.type==="component"||s.type==="board"?Z.jsx("circle",{cx:I.x,cy:I.y,r:sI.COMPONENT_MARKER_RADIUS,fill:Ay.COMPONENT_MARKER_FILL,stroke:Ay.COMPONENT_MARKER_STROKE,strokeWidth:1}):Z.jsxs(Z.Fragment,{children:[Z.jsx("line",{x1:I.x-sI.ANCHOR_MARKER_SIZE,y1:I.y,x2:I.x+sI.ANCHOR_MARKER_SIZE,y2:I.y,stroke:Ay.OFFSET_LINE,strokeWidth:sI.ANCHOR_MARKER_STROKE_WIDTH}),Z.jsx("line",{x1:I.x,y1:I.y-sI.ANCHOR_MARKER_SIZE,x2:I.x,y2:I.y+sI.ANCHOR_MARKER_SIZE,stroke:Ay.OFFSET_LINE,strokeWidth:sI.ANCHOR_MARKER_STROKE_WIDTH})]}),f&&Z.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:Z.jsx("div",{style:{...n,textAlign:"center"},children:w})}),m&&Z.jsx("foreignObject",{x:I.x+d,y:Math.min(c.y,I.y),width:sI.Y_LABEL_MIN_WIDTH,height:Math.abs(I.y-c.y),style:{overflow:"visible"},children:Z.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])=>Z.jsxs("g",{children:[Z.jsx("line",{x1:r.x-sI.ANCHOR_MARKER_SIZE,y1:r.y,x2:r.x+sI.ANCHOR_MARKER_SIZE,y2:r.y,stroke:Ay.OFFSET_LINE,strokeWidth:sI.ANCHOR_MARKER_STROKE_WIDTH}),Z.jsx("line",{x1:r.x,y1:r.y-sI.ANCHOR_MARKER_SIZE,x2:r.x,y2:r.y+sI.ANCHOR_MARKER_SIZE,stroke:Ay.OFFSET_LINE,strokeWidth:sI.ANCHOR_MARKER_STROKE_WIDTH})]},`anchor-${s}`))]})})},c$e=({elements:e,highlightedPrimitives:A,transform:t,containerWidth:i,containerHeight:n})=>{const o=e.filter(E=>ByA(E)),s=e.filter(E=>Rk(E)),r=e.filter(E=>DQt(E)),a=A.map(E=>Rk(E._parent_pcb_component)?E._parent_pcb_component.pcb_component_id:Rk(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)}),!fB(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 Z.jsx(CyA,{targets:h,transform:t,containerWidth:i,containerHeight:n})},I$e=({elements:e,highlightedPrimitives:A,transform:t,containerWidth:i,containerHeight:n})=>{const o=e.filter(E=>DQt(E)),s=e.filter(E=>Rk(E)),r=A.map(E=>Rk(E._parent_pcb_component)?E._parent_pcb_component.pcb_component_id:Rk(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))}),!fB(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 Z.jsx(CyA,{targets:h,transform:t,containerWidth:i,containerHeight:n})},l$e=(e,A)=>{const t=e.pcb_component_id,i=A.filter(n=>(n.type==="pcb_smtpad"||n.type==="pcb_plated_hole")&&n.pcb_component_id===t||n.type==="pcb_hole"&&n.pcb_component_id===t);return i.length===0?gyA([e]):gyA(i)},B$e=({elements:e,highlightedPrimitives:A,transform:t,containerWidth:i,containerHeight:n})=>{const o=new Map;for(const r of A)Rk(r._parent_pcb_component)&&o.set(r._parent_pcb_component.pcb_component_id,r._parent_pcb_component),Rk(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=l$e(r,e);if(!a)continue;const g=r.positioned_relative_to_pcb_group_id??r.pcb_group_id,c=g?Vb(e).pcb_group.get(g):null;s.push({component:r,bbox:a,group:c})}return s.length===0?null:Z.jsx("div",{style:{position:"absolute",left:0,top:0,width:i,height:n,overflow:"hidden",pointerEvents:"none",zIndex:Sc.dimensionOverlay},children:Z.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=Ct(t,{x:a.minX,y:a.maxY}),I=Ct(t,{x:a.maxX,y:a.minY}),l={x:Math.min(c.x,I.x),y:Math.min(c.y,I.y),width:Math.abs(I.x-c.x),height:Math.abs(I.y-c.y)},B=r.center??{x:(a.minX+a.maxX)/2,y:(a.minY+a.maxY)/2},C=Ct(t,B);return Z.jsxs("g",{children:[Z.jsx("rect",{x:l.x,y:l.y,width:l.width,height:l.height,fill:"none",stroke:"white",strokeWidth:1.5,strokeDasharray:"4,4"}),Z.jsx("line",{x1:C.x-6,y1:C.y,x2:C.x+6,y2:C.y,stroke:Ay.COMPONENT_MARKER_STROKE,strokeWidth:1.5}),Z.jsx("line",{x1:C.x,y1:C.y-6,x2:C.x,y2:C.y+6,stroke:Ay.COMPONENT_MARKER_STROKE,strokeWidth:1.5}),Z.jsx("circle",{cx:C.x,cy:C.y,r:sI.COMPONENT_MARKER_RADIUS,fill:Ay.COMPONENT_MARKER_FILL,stroke:Ay.COMPONENT_MARKER_STROKE,strokeWidth:1})]},r.pcb_component_id)})})})},C$e=({elements:e,highlightedPrimitives:A,transform:t,containerWidth:i,containerHeight:n})=>{const o=e.filter(B=>g$e(B)),s=e.filter(B=>ByA(B)),r=A.map(B=>ByA(B._element)?B._element.pcb_board_id:null).filter(B=>!!B);if(!fB(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 Z.jsx(CyA,{targets:l,transform:t,containerWidth:i,containerHeight:n})},qj=e=>{if(e.length===0)return null;let A=e[0].x,t=e[0].y,i=e[0].x,n=e[0].y;for(const o of e)o.x<A&&(A=o.x),o.y<t&&(t=o.y),o.x>i&&(i=o.x),o.y>n&&(n=o.y);return{center:{x:(A+i)/2,y:(t+n)/2},width:i-A,height:n-t}},SQt=(e,A)=>{if(A.length<3)return!1;let t=!1;for(let i=0,n=A.length-1;i<A.length;n=i++){const o=A[i].x,s=A[i].y,r=A[n].x,a=A[n].y;s>e.y!=a>e.y&&e.x<(r-o)*(e.y-s)/(a-s||Number.EPSILON)+o&&(t=!t)}return t},Q$e=(e,A,t)=>{const i=[];for(const n of e){if(!n._element)continue;if("x1"in n&&n._element?.type==="pcb_trace"){const r=KE({x:A.x,y:A.y},{x:n.x1,y:n.y1},{x:n.x2,y:n.y2}),a=n.width||.5,g=Math.max(a*25,2)/t.a;r<g&&i.push(n);continue}if(n.pcb_drawing_type==="polygon"){const r=n.points.map(g=>({x:Ee.parse(g.x),y:Ee.parse(g.y)})),a=qj(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;SQt(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:Ee.parse(g.x),y:Ee.parse(g.y)})),a=qj(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;SQt(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},h$e=({elements:e,children:A,transform:t,primitives:i,onMouseHoverOverPrimitives:n})=>{const[o,s]=AA.useState([]),[r,a]=AA.useState({x:0,y:0}),[g,{width:c,height:I}]=fT(),l=AA.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=qj(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=qj(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=Ct(t,h),f={w:E*t.a,h:u*t.a},m=C.filter(w=>d.x===w.screen_x&&d.y===w.screen_y&&f.w===w.screen_w&&f.h===w.screen_h).length;C.push({...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,t]),B=(C,Q,h,E)=>{a({x:C,y:Q});const u=Ct(jy(h),{x:C,y:Q}),d=Q$e(E,u,h);t$e(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 Z.jsxs("div",{ref:g,style:{position:"relative",width:"100%",height:"100%"},onMouseMove:C=>{if(t){const Q=C.currentTarget.getBoundingClientRect(),h=C.clientX-Q.left,E=C.clientY-Q.top;B(h,E,t,i)}},onTouchStart:C=>{if(t){const Q=C.touches[0],h=C.currentTarget.getBoundingClientRect(),E=Q.clientX-h.left,u=Q.clientY-h.top;B(E,u,t,i)}},children:[A,Z.jsx(a$e,{elements:e,mousePos:r,highlightedPrimitives:l}),t&&Z.jsxs(Z.Fragment,{children:[Z.jsx(c$e,{elements:e,highlightedPrimitives:l,transform:t,containerWidth:c,containerHeight:I}),Z.jsx(I$e,{elements:e,highlightedPrimitives:l,transform:t,containerWidth:c,containerHeight:I}),Z.jsx(B$e,{elements:e,highlightedPrimitives:l,transform:t,containerWidth:c,containerHeight:I}),Z.jsx(C$e,{elements:e,highlightedPrimitives:l,transform:t,containerWidth:c,containerHeight:I})]})]})},bQt=["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)"],E$e=({children:e,transform:A=ba(),elements:t=[],hoveredComponentIds:i=[]})=>{const[n,{width:o,height:s}]=fT(),r=AA.useRef(null),{is_showing_pcb_groups:a,pcb_group_view_mode:g,is_showing_group_anchor_offsets:c}=fB(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 AA.useEffect(()=>{const I=r.current;if(!I||!o||!s)return;I.width=o,I.height=s;const l=I.getContext("2d");if(!l||(l.clearRect(0,0,o,s),!a))return;const B=t.filter(w=>w.type==="pcb_group"),C=t.filter(w=>w.type==="pcb_component"),Q=t.filter(w=>w.type==="source_group"),h=new Map(Q.map(w=>[w.source_group_id,w])),E=B.filter(w=>{if(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(UA=>UA.pcb_group_id===w.pcb_group_id);if(w.source_group_id){const UA=d(w.source_group_id),jA=B.filter(xA=>xA.source_group_id&&UA.includes(xA.source_group_id));for(const xA of jA){const DA=C.filter(HA=>HA.pcb_group_id===xA.pcb_group_id);S=[...S,...DA]}}let _,b,R,F,H=!1;if(w.center&&w.width&&w.height){H=!0;const UA=w.width/2,jA=w.height/2;_=w.center.x-UA,R=w.center.x+UA,b=w.center.y-jA,F=w.center.y+jA}else if(S.length===0||(_=1/0,b=1/0,R=-1/0,F=-1/0,S.forEach(UA=>{if(UA.center&&typeof UA.width=="number"&&typeof UA.height=="number"){const jA=UA.center.x-UA.width/2,xA=UA.center.x+UA.width/2,DA=UA.center.y+UA.height/2,HA=UA.center.y-UA.height/2;_=Math.min(_,jA),R=Math.max(R,xA),b=Math.min(b,HA),F=Math.max(F,DA)}}),_===1/0||R===-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(!H){const xA=1+(J?.5:0);_-=xA,R+=xA,b-=xA,F+=xA}const O=Ct(A,{x:_,y:F}),W=Ct(A,{x:R,y:F}),z=Ct(A,{x:_,y:b}),tA=Ct(A,{x:R,y:b}),aA=bQt[D%bQt.length];l.strokeStyle=aA,l.lineWidth=2;const eA=Math.max(4,Math.min(12,8*Math.abs(A.a))),oA=Math.max(2,Math.min(6,4*Math.abs(A.a))),BA=eA*(J?1.3:1),pA=oA;l.setLineDash([BA,pA]),l.beginPath(),l.moveTo(O.x,O.y),l.lineTo(W.x,W.y),l.lineTo(tA.x,tA.y),l.lineTo(z.x,z.y),l.closePath(),l.stroke();const kA=Math.max(8,Math.min(12,10*Math.abs(A.a))),MA=Y==0||Y==1?0:Y*.11,TA=kA*(1-MA),EA=4,_A=w.name||`Group ${D+1}`;l.font=`${TA}px sans-serif`,l.setLineDash([]);const WA=l.measureText(_A).width+EA*2,VA=TA+EA*2,It=O.x-5,mA=O.y-5,gt=3;if(l.fillStyle="rgba(0, 0, 0, 0.8)",l.beginPath(),l.roundRect(It,mA-VA,WA,VA,gt),l.fill(),l.fillStyle=aA,l.textAlign="left",l.textBaseline="middle",l.fillText(_A,It+EA,mA-VA/2),c&&m.has(w.pcb_group_id)&&!!w.anchor_position&&w.anchor_position){const UA=Array.isArray(w.anchor_position)?{x:w.anchor_position[0]??0,y:w.anchor_position[1]??0}:{x:w.anchor_position.x,y:w.anchor_position.y},jA=Ct(A,UA);l.strokeStyle="white",l.lineWidth=1.5,l.setLineDash([]);const xA=Math.max(4,Math.min(8,6*Math.abs(A.a)));l.beginPath(),l.moveTo(jA.x-xA,jA.y),l.lineTo(jA.x+xA,jA.y),l.stroke(),l.beginPath(),l.moveTo(jA.x,jA.y-xA),l.lineTo(jA.x,jA.y+xA),l.stroke()}})},[t,A,o,s,a,g,c,i]),Z.jsxs("div",{ref:n,style:{position:"relative",width:"100%",height:"100%"},children:[e,Z.jsx("canvas",{ref:r,style:{position:"absolute",top:0,left:0,pointerEvents:"none",zIndex:Sc.pcbGroupOverlay,display:a?"block":"none"}})]})},u$e=({transform:e,soup:A,children:t})=>{const i=fB(r=>r.is_showing_rats_nest),{netMap:n,idToNetMap:o}=AA.useMemo(()=>nQt(A||[]),[A]),s=AA.useMemo(()=>{if(!A||!i)return[];const r=l=>{const B=Vb(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=Vb(A).pcb_port.list(),c=Vb(A).source_trace.list(),I=[];return g.forEach((l,B)=>{const C=o[l.pcb_port_id];let Q=!1;for(const u of c)u.connected_source_port_ids.includes(l.source_port_id)&&u.connected_source_net_ids.length>0&&(Q=!0);if(!C)return;const h={x:l.x,y:l.y},E=a(h,C);E&&I.push({key:`${l.pcb_port_id}-${B}`,startPoint:h,endPoint:E,isInNet:Q})}),I},[A,n,o,i]);return!A||!i?t:(e||(e=ba()),Z.jsxs("div",{style:{position:"relative"},children:[t,Z.jsx("svg",{style:{position:"absolute",left:0,top:0,width:"100%",height:"100%",pointerEvents:"none",opacity:.5,zIndex:Sc.ratsNestOverlay},children:s.map(({key:r,startPoint:a,endPoint:g,isInNet:c})=>{const I=Ct(e,a),l=Ct(e,g);return Z.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)})})]}))},d$e={version:"1.11.350"},Nk=(e,A,t)=>{const i=fB(s=>s.is_mouse_over_container),n=AA.useRef(i),o=AA.useRef(A);AA.useEffect(()=>{n.current=i},[i]),AA.useEffect(()=>{o.current=A},[A]),AA.useEffect(()=>{if(!e)return;const s=r=>{const a=r.target;if(a.tagName==="INPUT"||a.tagName==="TEXTAREA"||a.isContentEditable)return;const g=e.split("+"),c=g.includes("ctrl"),I=g.includes("shift"),l=g.includes("alt"),B=g.includes("meta"),C=g[g.length-1],Q=t?.current?t.current.contains(document.activeElement)||document.activeElement===t.current:!1;(n.current||Q)&&(!c||r.ctrlKey)&&(!I||r.shiftKey)&&(!l||r.altKey)&&(!B||r.metaKey)&&r.key.toLowerCase()===C.toLowerCase()&&(r.preventDefault(),o.current())};return window.addEventListener("keydown",s),()=>{window.removeEventListener("keydown",s)}},[e])},p$e=()=>{const[e,A]=AA.useState(!1);return AA.useEffect(()=>{const t=()=>{A(window.innerWidth<=768)};return t(),window.addEventListener("resize",t),()=>window.removeEventListener("resize",t)},[]),e},mT=(e,A={stopPropagation:!0})=>{const t=AA.useRef(0),i=AA.useCallback(s=>{A.stopPropagation&&s.stopPropagation();const r=Date.now();r-t.current<300||(t.current=r,e?.(s))},[e,A.stopPropagation]),n=AA.useCallback(s=>{s.preventDefault(),i(s)},[i]);return{onClick:i,onTouchEnd:n,style:{touchAction:"manipulation"}}},f$e=({name:e,selected:A,onClick:t})=>{const{style:i,...n}=mT(t);return Z.jsxs("div",{className:o1`
|
|
5472
5472
|
margin-top: 2px;
|
|
5473
5473
|
padding: 4px;
|
|
5474
5474
|
padding-left: 8px;
|
|
@@ -5685,7 +5685,7 @@ test("${g} should solve problem correctly", () => {
|
|
|
5685
5685
|
// Add more specific assertions based on expected output
|
|
5686
5686
|
// expect(solver.netLabelPlacementSolver!.netLabelPlacements).toMatchInlineSnapshot()
|
|
5687
5687
|
})
|
|
5688
|
-
`,I=new Blob([c],{type:"text/plain"}),l=URL.createObjectURL(I),B=document.createElement("a");B.href=l,B.download=`${g}.test.ts`,B.click(),URL.revokeObjectURL(l)}catch(a){alert(`Error generating test.ts for ${e.constructor.name}: ${a instanceof Error?a.message:String(a)}`)}i(!1)};return Z.jsxs("div",{className:`relative ${A}`,ref:n,children:[Z.jsx("button",{className:"px-2 py-1 rounded text-xs cursor-pointer",onClick:()=>i(!t),title:`Download options for ${e.constructor.name}`,children:e.constructor.name}),t&&Z.jsxs("div",{className:"absolute top-full left-0 mt-1 bg-white border border-gray-300 rounded shadow-lg z-10 min-w-[150px]",children:[Z.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:o,children:"Download JSON"}),Z.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:s,children:"Download page.tsx"}),Z.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:r,children:"Download test.ts"})]})]})},UQt=e=>e.activeSubSolver?[e,...UQt(e.activeSubSolver)]:[e],ZAi=({solver:e})=>{const A=UQt(e);return Z.jsx("div",{className:"flex gap-1 items-center text-sm pt-1",children:A.map((t,i)=>Z.jsxs("div",{className:"flex items-center",children:[i>0&&Z.jsx("span",{className:"text-gray-400 mx-1",children:"→"}),Z.jsx(WAi,{solver:t})]},t.constructor.name))})},VAi=({solver:e,triggerRender:A,animationSpeed:t=25,onSolverStarted:i,onSolverCompleted:n})=>{const[o,s]=AA.useReducer(Q=>!Q,!1),r=AA.useRef(void 0),a=()=>{!e.solved&&!e.failed&&(e.step(),A())},g=()=>{!e.solved&&!e.failed&&(i&&i(e),e.solve(),A(),n&&n(e))},c=()=>{o?(r.current&&(clearInterval(r.current),r.current=void 0),s()):(s(),r.current=setInterval(()=>{if(e.solved||e.failed){r.current&&(clearInterval(r.current),r.current=void 0),s(),A(),n&&e.solved&&n(e);return}e.step(),A()},t))},I=()=>{const Q=e;if(Q.getCurrentPhase&&!e.solved&&!e.failed){const h=Q.getCurrentPhase();for(;Q.getCurrentPhase()===h&&!e.solved&&!e.failed;)e.step();A()}},l=()=>{if(e.solved||e.failed||o)return;const Q=window.prompt("Step until which iteration?",`${e.iterations}`);if(Q===null)return;const h=Number(Q);if(!Number.isFinite(h)){window.alert("Please enter a valid number for the iteration");return}for(;e.iterations<h&&!e.solved&&!e.failed;)e.step();A(),e.solved&&n&&n(e)};AA.useEffect(()=>()=>{r.current&&clearInterval(r.current)},[]),AA.useEffect(()=>{(e.solved||e.failed)&&o&&(r.current&&(clearInterval(r.current),r.current=void 0),s())},[e.solved,e.failed,o]);const B=e.getCurrentPhase!==void 0,C=B?e.getCurrentPhase():null;return Z.jsxs("div",{className:"space-y-2 p-2 border-b",children:[Z.jsx("div",{className:"flex items-center",children:Z.jsx(ZAi,{solver:e})}),Z.jsxs("div",{className:"flex gap-2 items-center flex-wrap",children:[Z.jsx("button",{onClick:a,disabled:e.solved||e.failed||o,className:"bg-blue-500 hover:bg-blue-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Step"}),Z.jsx("button",{onClick:g,disabled:e.solved||e.failed||o,className:"bg-green-500 hover:bg-green-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Solve"}),Z.jsx("button",{onClick:c,disabled:e.solved||e.failed,className:`px-3 py-1 rounded text-white text-sm ${o?"bg-red-500 hover:bg-red-600":"bg-yellow-500 hover:bg-yellow-600"} disabled:bg-gray-300`,children:o?"Stop":"Animate"}),Z.jsx("button",{onClick:l,disabled:e.solved||e.failed||o,className:"bg-orange-500 hover:bg-orange-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Step Until Iteration"}),B&&Z.jsx("button",{onClick:I,disabled:e.solved||e.failed||o,className:"bg-purple-500 hover:bg-purple-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Next Stage"}),Z.jsxs("div",{className:"text-sm text-gray-600",children:["Iterations: ",e.iterations]}),e.timeToSolve!==void 0&&Z.jsxs("div",{className:"text-sm text-gray-600",children:["Time: ",(e.timeToSolve/1e3).toFixed(3),"s"]}),C&&Z.jsxs("div",{className:"text-sm text-gray-600",children:["Phase: ",Z.jsx("span",{className:"font-medium",children:C})]}),e.solved&&Z.jsx("div",{className:"px-2 py-1 bg-green-100 text-green-800 rounded text-sm",children:"Solved"}),e.failed&&Z.jsx("div",{className:"px-2 py-1 bg-red-100 text-red-800 rounded text-sm",children:"Failed"})]}),e.error&&Z.jsxs("div",{className:"text-red-600 text-sm",children:["Error: ",e.error]})]})},jAi=(e,A,t)=>{const i=e.currentPipelineStepIndex;return A<i?"Completed":A===i&&e.activeSubSolver?e.activeSubSolver.failed?"Failed":"In Progress":"Not Started"},zAi=(e,A)=>{const i=e.pipelineDef[A].solverName,n=jAi(e,A),o=e[i],s=e.firstIterationOfPhase?.[i]??null,r=e.iterations;let a=0;if(n==="Completed"){const l=e.pipelineDef[A+1],B=l?e.firstIterationOfPhase?.[l.solverName]:void 0;B!==void 0&&s!==null?a=B-s:s!==null&&(a=r-s)}else n==="In Progress"&&s!==null&&(a=r-s);const g=e.timeSpentOnPhase?.[i]??0;let c=0;n==="Completed"?c=1:n==="In Progress"&&o&&(c=o.progress??0);const I=o?.stats??null;return{index:A,name:i,status:n,firstIteration:s,iterations:a,progress:c,timeSpent:g,stats:I&&Object.keys(I).length>0?I:null,solverInstance:o??null}},XAi=({status:e})=>{const A={"Not Started":"text-blue-600","In Progress":"text-yellow-600",Completed:"text-green-600",Failed:"text-red-600"};return Z.jsx("span",{className:`font-medium ${A[e]}`,children:e})},$Ai=({progress:e})=>{if(e===0)return null;const A=Math.round(e*100);return Z.jsxs("div",{className:"flex items-center gap-2",children:[Z.jsx("div",{className:"w-20 h-2 bg-gray-200 rounded overflow-hidden",children:Z.jsx("div",{className:"h-full bg-blue-500 transition-all duration-200",style:{width:`${A}%`}})}),Z.jsxs("span",{className:"text-xs text-gray-500",children:[A,"%"]})]})},Ati=e=>Object.entries(e).map(([A,t])=>`${A}: ${t}`).join(", "),tti=({stats:e})=>{if(!e||Object.keys(e).length===0)return Z.jsx("span",{children:"-"});const A=Object.entries(e),t=Ati(e);return Z.jsxs("details",{className:"cursor-pointer",children:[Z.jsx("summary",{className:"whitespace-nowrap overflow-hidden text-ellipsis max-w-[200px]",children:t}),Z.jsx("div",{className:"mt-1 text-xs",children:A.map(([i,n])=>Z.jsxs("div",{children:[i,": ",String(n)]},i))})]})},yyA=e=>{if(e===null||typeof e!="object")return e;if(Array.isArray(e))return e.map(yyA);const A={};for(const[t,i]of Object.entries(e))t.startsWith("_")||(A[t]=yyA(i));return A},eti=(e,A)=>{try{if(typeof e.getConstructorParams!="function"){alert(`getConstructorParams() is not implemented for ${A}`);return}const t=yyA(e.getConstructorParams()),i=new Blob([JSON.stringify(t,null,2)],{type:"application/json"}),n=URL.createObjectURL(i),o=document.createElement("a");o.href=n,o.download=`${A}_input.json`,o.click(),URL.revokeObjectURL(n)}catch(t){alert(`Error downloading input for ${A}: ${t instanceof Error?t.message:String(t)}`)}},iti=({solver:e,onStepUntilPhase:A,onDownloadInput:t})=>{const i=e.pipelineDef.map((r,a)=>zAi(e,a)),n=r=>{A?.(r)},o=r=>{r.solverInstance&&(t?t(r.solverInstance,r.name):eti(r.solverInstance,r.name))},s=r=>`${(r/1e3).toFixed(2)}s`;return Z.jsxs("div",{className:"border-t border-gray-200",children:[Z.jsx("div",{className:"px-4 py-2 bg-gray-50 border-b border-gray-200",children:Z.jsx("h3",{className:"text-sm font-semibold text-gray-700",children:"Pipeline Steps"})}),Z.jsx("div",{className:"overflow-x-auto",children:Z.jsxs("table",{className:"w-full text-sm",children:[Z.jsx("thead",{children:Z.jsxs("tr",{className:"bg-gray-50 border-b border-gray-200",children:[Z.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Step"}),Z.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Status"}),Z.jsxs("th",{className:"px-4 py-2 text-center font-semibold text-gray-700",children:["i",Z.jsx("sub",{children:"0"})]}),Z.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Iterations"}),Z.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Progress"}),Z.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Time"}),Z.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Stats"}),Z.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Input"})]})}),Z.jsx("tbody",{children:i.map(r=>Z.jsxs("tr",{className:`border-b border-gray-100 ${r.status==="In Progress"?"bg-yellow-50":""}`,children:[Z.jsx("td",{className:"px-4 py-2",children:Z.jsxs("div",{className:"flex items-center gap-2",children:[Z.jsx("span",{className:"text-gray-400 w-6",children:String(r.index+1).padStart(2,"0")}),Z.jsx("button",{onClick:()=>n(r.name),disabled:r.status==="Completed"||e.solved||e.failed,className:"text-blue-500 hover:text-blue-700 disabled:text-gray-300 disabled:cursor-not-allowed",title:`Step until ${r.name} completes`,children:Z.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:Z.jsx("path",{fillRule:"evenodd",d:"M4.5 5.653c0-1.426 1.529-2.33 2.779-1.643l11.54 6.348c1.295.712 1.295 2.573 0 3.285L7.28 19.991c-1.25.687-2.779-.217-2.779-1.643V5.653z",clipRule:"evenodd"})})}),Z.jsx("span",{className:"font-medium text-gray-900",children:r.name})]})}),Z.jsx("td",{className:"px-4 py-2",children:Z.jsx(XAi,{status:r.status})}),Z.jsx("td",{className:"px-4 py-2 text-center text-gray-600",children:r.firstIteration!==null?r.firstIteration:""}),Z.jsx("td",{className:"px-4 py-2 text-gray-600",children:r.iterations}),Z.jsx("td",{className:"px-4 py-2",children:Z.jsx($Ai,{progress:r.progress})}),Z.jsx("td",{className:"px-4 py-2 text-gray-600",children:s(r.timeSpent)}),Z.jsx("td",{className:"px-4 py-2 text-gray-500",children:Z.jsx(tti,{stats:r.stats})}),Z.jsx("td",{className:"px-4 py-2",children:r.solverInstance?Z.jsxs("button",{onClick:()=>o(r),className:"flex items-center gap-1 text-blue-500 hover:text-blue-700",title:`Download input for ${r.name}`,children:[Z.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:Z.jsx("path",{fillRule:"evenodd",d:"M12 2.25a.75.75 0 01.75.75v11.69l3.22-3.22a.75.75 0 111.06 1.06l-4.5 4.5a.75.75 0 01-1.06 0l-4.5-4.5a.75.75 0 111.06-1.06l3.22 3.22V3a.75.75 0 01.75-.75zm-9 13.5a.75.75 0 01.75.75v2.25a1.5 1.5 0 001.5 1.5h13.5a1.5 1.5 0 001.5-1.5V16.5a.75.75 0 011.5 0v2.25a3 3 0 01-3 3H5.25a3 3 0 01-3-3V16.5a.75.75 0 01.75-.75z",clipRule:"evenodd"})}),Z.jsx("span",{children:"Input"})]}):null})]},r.name))})]})})]})},nti=class extends Cn.Component{constructor(e){super(e),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(e){console.error("InteractiveGraphics render error:",e)}render(){return this.state.hasError?this.props.fallback:this.props.children}};function oti({graphics:e}){const A=e.points??[],t=e.lines??[],i=e.rects??[],n=e.circles??[],o=e.texts??[];let s=Number.POSITIVE_INFINITY,r=Number.POSITIVE_INFINITY,a=Number.NEGATIVE_INFINITY,g=Number.NEGATIVE_INFINITY;const c=(h,E)=>{typeof h=="number"&&(h<s&&(s=h),h>a&&(a=h)),typeof E=="number"&&(E<r&&(r=E),E>g&&(g=E))};for(const h of A)c(h.x,h.y);for(const h of t){const E=h.points??[];for(const u of E)c(u.x,u.y)}for(const h of i){const E=h.x??0,u=h.y??0,d=h.width??0,f=h.height??0;c(E,u),c(E+d,u+f)}for(const h of n){const E=h.x??0,u=h.y??0,d=h.radius??1;c(E-d,u-d),c(E+d,u+d)}for(const h of o)c(h.x,h.y);(!isFinite(s)||!isFinite(r)||!isFinite(a)||!isFinite(g))&&(s=-20,r=-20,a=20,g=20);const I=10,l=s-I,B=r-I,C=Math.max(1,a-s+2*I),Q=Math.max(1,g-r+2*I);return Z.jsxs("svg",{className:"w-full h-[400px] bg-white",viewBox:`${l} ${B} ${C} ${Q}`,role:"img","aria-label":"Graphics fallback",children:[i.map((h,E)=>Z.jsx("rect",{x:h.x??0,y:h.y??0,width:h.width??0,height:h.height??0,fill:"none",stroke:h.strokeColor??"black",strokeWidth:h.strokeWidth??1},`rect-${E}`)),t.map((h,E)=>Z.jsx("polyline",{fill:"none",stroke:h.strokeColor??"black",strokeWidth:h.strokeWidth??1,points:(h.points??[]).map(u=>`${u.x??0},${u.y??0}`).join(" ")},`line-${E}`)),n.map((h,E)=>Z.jsx("circle",{cx:h.x??0,cy:h.y??0,r:h.radius??1.5,fill:h.fillColor??"none",stroke:h.strokeColor??"black",strokeWidth:h.strokeWidth??1},`circle-${E}`)),A.map((h,E)=>Z.jsx("circle",{cx:h.x??0,cy:h.y??0,r:h.radius??1.5,fill:h.color??"black"},`point-${E}`)),o.map((h,E)=>Z.jsx("text",{x:h.x??0,y:h.y??0,fontSize:h.fontSize??10,fill:h.color??"black",children:h.text??""},`text-${E}`))]})}var sti=({solver:e,animationSpeed:A=25,onSolverStarted:t,onSolverCompleted:i})=>{const[n,o]=AA.useReducer(c=>c+1,0),s=AA.useMemo(()=>{try{return e.visualize()||{points:[],lines:[],rects:[],circles:[]}}catch(c){return console.error("Visualization error:",c),{points:[],lines:[],rects:[],circles:[]}}},[e,n]),r=AA.useMemo(()=>(s.rects?.length||0)===0&&(s.lines?.length||0)===0&&(s.points?.length||0)===0&&(s.circles?.length||0)===0,[s]);AA.useEffect(()=>{if(!(typeof document>"u")&&!document.querySelector('script[src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4"]')){const c=document.createElement("script");c.src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4",document.head.appendChild(c)}},[]);const a=e.pipelineDef!==void 0,g=c=>{const I=e;if(!e.solved&&!e.failed){for(;!e.solved&&!e.failed&&I.currentPipelineStepIndex<=I.pipelineDef.findIndex(l=>l.solverName===c);)e.step();o()}};return Z.jsxs("div",{children:[Z.jsx(VAi,{solver:e,triggerRender:o,animationSpeed:A,onSolverStarted:t,onSolverCompleted:i}),r?Z.jsx("div",{className:"p-4 text-gray-500",children:"No Graphics Yet"}):Z.jsx(nti,{fallback:Z.jsx(oti,{graphics:s}),children:Z.jsx(OAi,{graphics:s})}),a&&Z.jsx(iti,{solver:e,onStepUntilPhase:g})]})};const rti=()=>{AA.useEffect(()=>{const e="tailwind-cdn-script";if(document.getElementById(e)||window.tailwind)return;const A=document.createElement("div");A.className="hidden",document.body.appendChild(A);const t=window.getComputedStyle(A).display==="none";if(document.body.removeChild(A),t)return;const i=document.createElement("script");i.id=e,i.src="https://cdn.tailwindcss.com",document.head.appendChild(i)},[])},ati=e=>e.toLowerCase().includes("pack")?YJe:e.toLowerCase().includes("rout")?OJe:vJe,gti=({solverEvents:e=[]})=>{const[A,t]=AA.useState(null);rti();const i=AA.useMemo(()=>{const r=new Map;for(const a of e){const g=`${a.componentName}-${a.solverName}`;r.set(g,a)}return r},[e]),n=AA.useMemo(()=>Array.from(i.keys()),[i]),o=A?i.get(A):null,s=AA.useMemo(()=>{if(!o)return{instance:null,error:null,classFound:!1};const r=OgA[o.solverName];if(!r)return{instance:null,error:`Solver class "${o.solverName}" not found in SOLVERS registry. Available: ${Object.keys(OgA).join(", ")}`,classFound:!1};try{const a=o.solverParams,g=a?.input!==void 0?a.input:a;return{instance:new r(g),error:null,classFound:!0}}catch(a){const g=a instanceof Error?a.message:String(a);return console.error("Failed to reconstruct solver:",a),{instance:null,error:`Failed to instantiate solver: ${g}`,classFound:!0}}},[o]);return e.length===0?Z.jsx("div",{className:"rf-p-4",children:Z.jsx("div",{className:"rf-bg-gray-50 rf-rounded-md rf-border rf-border-gray-200",children:Z.jsxs("div",{className:"rf-p-4",children:[Z.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800 rf-mb-3",children:"No Solvers Detected"}),Z.jsx("p",{className:"rf-text-sm rf-text-gray-600",children:"Solvers will appear here when the circuit runs. Solvers are used for tasks like component packing and autorouting."})]})})}):Z.jsxs("div",{className:"rf-flex rf-h-full rf-overflow-hidden",children:[Z.jsxs("div",{className:"rf-w-64 rf-border-r rf-border-gray-200 rf-overflow-y-auto rf-flex-shrink-0",children:[Z.jsxs("div",{className:"rf-text-xs rf-font-semibold rf-text-gray-500 rf-px-3 rf-py-2 rf-bg-gray-50 rf-border-b rf-border-gray-200",children:[n.length," ",n.length===1?"Solver":"Solvers"]}),n.map(r=>{const a=i.get(r),g=A===r;return Z.jsx("div",{className:`rf-px-3 rf-py-2 rf-cursor-pointer rf-border-b rf-border-gray-100 ${g?"rf-bg-blue-50 rf-border-l-2 rf-border-l-blue-500":"hover:rf-bg-gray-50"}`,onClick:()=>t(r),children:(()=>{const c=ati(a.solverName);return Z.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2",children:[Z.jsx(c,{className:"rf-w-4 rf-h-4 rf-text-blue-500 rf-flex-shrink-0"}),Z.jsxs("div",{className:"rf-flex-1 rf-min-w-0",children:[Z.jsx("div",{className:"rf-text-sm rf-font-medium rf-text-gray-800 rf-truncate",children:a.componentName}),Z.jsx("div",{className:"rf-text-xs rf-text-gray-500 rf-truncate",children:a.solverName})]})]})})()},r)})]}),Z.jsx("div",{className:"rf-flex-1 rf-overflow-hidden",children:o?s.instance?Z.jsx(VD,{fallback:Z.jsx("div",{className:"rf-p-4",children:Z.jsxs("div",{className:"rf-bg-red-50 rf-rounded-md rf-border rf-border-red-200 rf-p-4",children:[Z.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-red-800 rf-mb-2",children:"Error Loading Solver Debugger"}),Z.jsxs("p",{className:"rf-text-sm rf-text-red-600",children:["Failed to render the solver debugger for"," ",o.solverName]})]})}),children:Z.jsx(sti,{solver:s.instance})}):Z.jsxs("div",{className:"rf-p-4",children:[Z.jsxs("div",{className:"rf-mb-4",children:[Z.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800",children:o.solverName}),Z.jsxs("p",{className:"rf-text-sm rf-text-gray-500",children:["Component: ",o.componentName]})]}),s.error&&Z.jsx("div",{className:`rf-rounded-md rf-border rf-p-4 rf-mb-4 ${s.classFound?"rf-bg-red-50 rf-border-red-200":"rf-bg-yellow-50 rf-border-yellow-200"}`,children:Z.jsx("p",{className:`rf-text-sm ${s.classFound?"rf-text-red-700":"rf-text-yellow-700"}`,children:s.error})}),Z.jsxs("div",{className:"rf-border rf-border-gray-200 rf-rounded-md rf-overflow-hidden",children:[Z.jsx("div",{className:"rf-px-3 rf-py-2 rf-bg-gray-50",children:Z.jsx("span",{className:"rf-text-sm rf-font-medium rf-text-gray-700",children:"Solver Parameters"})}),Z.jsx("div",{className:"rf-p-3 rf-bg-white rf-border-t rf-border-gray-200",children:Z.jsx("pre",{className:"rf-text-xs rf-font-mono rf-text-gray-600 rf-whitespace-pre-wrap rf-overflow-x-auto",children:JSON.stringify(o.solverParams,null,2)})})]})]}):Z.jsx("div",{className:"rf-flex rf-items-center rf-justify-center rf-h-full",children:Z.jsx("p",{className:"rf-text-sm rf-text-gray-500",children:"Select a solver from the list to view details"})})})]})},HQt=({errorMessage:e,errorStack:A,circuitJsonErrors:t})=>{AA.useEffect(()=>{if(e){const i=new Error(e);A&&(i.stack=A);try{lq.captureException(i)}catch{}}},[e,A]),AA.useEffect(()=>{if(t&&t.length>0)for(const i of t){const n=new Error(i.message||"Circuit JSON Error");i.stack&&(n.stack=i.stack);try{lq.captureException(n,{error_type:i.type})}catch{}}},[t])},YQt="0.0.1728",cti={version:YQt},myA={BASE_URL:"/",DEV:!1,MODE:"production",PROD:!0,SSR:!1},wyA=new Map,jj=e=>{const A=wyA.get(e);return A?Object.fromEntries(Object.entries(A.stores).map(([t,i])=>[t,i.getState()])):{}},Iti=(e,A,t)=>{if(e===void 0)return{type:"untracked",connection:A.connect(t)};const i=wyA.get(t.name);if(i)return{type:"tracked",store:e,...i};const n={connection:A.connect(t),stores:{}};return wyA.set(t.name,n),{type:"tracked",store:e,...n}},JQt=(e,A={})=>(t,i,n)=>{const{enabled:o,anonymousActionType:s,store:r,...a}=A;let g;try{g=(o??(myA?"production":void 0)!=="production")&&window.__REDUX_DEVTOOLS_EXTENSION__}catch{}if(!g)return(myA?"production":void 0)!=="production"&&o&&console.warn("[zustand devtools middleware] Please install/enable Redux devtools extension"),e(t,i,n);const{connection:c,...I}=Iti(r,g,a);let l=!0;n.setState=(Q,h,E)=>{const u=t(Q,h);if(!l)return u;const d=E===void 0?{type:s||"anonymous"}:typeof E=="string"?{type:E}:E;return r===void 0?(c?.send(d,i()),u):(c?.send({...d,type:`${r}/${d.type}`},{...jj(a.name),[r]:n.getState()}),u)};const B=(...Q)=>{const h=l;l=!1,t(...Q),l=h},C=e(n.setState,i,n);if(I.type==="untracked"?c?.init(C):(I.stores[I.store]=n,c?.init(Object.fromEntries(Object.entries(I.stores).map(([Q,h])=>[Q,Q===I.store?C:h.getState()])))),n.dispatchFromDevtools&&typeof n.dispatch=="function"){let Q=!1;const h=n.dispatch;n.dispatch=(...E)=>{(myA?"production":void 0)!=="production"&&E[0].type==="__setState"&&!Q&&(console.warn('[zustand devtools middleware] "__setState" action type is reserved to set state from the devtools. Avoid using it.'),Q=!0),h(...E)}}return c.subscribe(Q=>{var h;switch(Q.type){case"ACTION":if(typeof Q.payload!="string"){console.error("[zustand devtools middleware] Unsupported action format");return}return DyA(Q.payload,E=>{if(E.type==="__setState"){if(r===void 0){B(E.state);return}Object.keys(E.state).length!==1&&console.error(`
|
|
5688
|
+
`,I=new Blob([c],{type:"text/plain"}),l=URL.createObjectURL(I),B=document.createElement("a");B.href=l,B.download=`${g}.test.ts`,B.click(),URL.revokeObjectURL(l)}catch(a){alert(`Error generating test.ts for ${e.constructor.name}: ${a instanceof Error?a.message:String(a)}`)}i(!1)};return Z.jsxs("div",{className:`relative ${A}`,ref:n,children:[Z.jsx("button",{className:"px-2 py-1 rounded text-xs cursor-pointer",onClick:()=>i(!t),title:`Download options for ${e.constructor.name}`,children:e.constructor.name}),t&&Z.jsxs("div",{className:"absolute top-full left-0 mt-1 bg-white border border-gray-300 rounded shadow-lg z-10 min-w-[150px]",children:[Z.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:o,children:"Download JSON"}),Z.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:s,children:"Download page.tsx"}),Z.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:r,children:"Download test.ts"})]})]})},UQt=e=>e.activeSubSolver?[e,...UQt(e.activeSubSolver)]:[e],ZAi=({solver:e})=>{const A=UQt(e);return Z.jsx("div",{className:"flex gap-1 items-center text-sm pt-1",children:A.map((t,i)=>Z.jsxs("div",{className:"flex items-center",children:[i>0&&Z.jsx("span",{className:"text-gray-400 mx-1",children:"→"}),Z.jsx(WAi,{solver:t})]},t.constructor.name))})},VAi=({solver:e,triggerRender:A,animationSpeed:t=25,onSolverStarted:i,onSolverCompleted:n})=>{const[o,s]=AA.useReducer(Q=>!Q,!1),r=AA.useRef(void 0),a=()=>{!e.solved&&!e.failed&&(e.step(),A())},g=()=>{!e.solved&&!e.failed&&(i&&i(e),e.solve(),A(),n&&n(e))},c=()=>{o?(r.current&&(clearInterval(r.current),r.current=void 0),s()):(s(),r.current=setInterval(()=>{if(e.solved||e.failed){r.current&&(clearInterval(r.current),r.current=void 0),s(),A(),n&&e.solved&&n(e);return}e.step(),A()},t))},I=()=>{const Q=e;if(Q.getCurrentPhase&&!e.solved&&!e.failed){const h=Q.getCurrentPhase();for(;Q.getCurrentPhase()===h&&!e.solved&&!e.failed;)e.step();A()}},l=()=>{if(e.solved||e.failed||o)return;const Q=window.prompt("Step until which iteration?",`${e.iterations}`);if(Q===null)return;const h=Number(Q);if(!Number.isFinite(h)){window.alert("Please enter a valid number for the iteration");return}for(;e.iterations<h&&!e.solved&&!e.failed;)e.step();A(),e.solved&&n&&n(e)};AA.useEffect(()=>()=>{r.current&&clearInterval(r.current)},[]),AA.useEffect(()=>{(e.solved||e.failed)&&o&&(r.current&&(clearInterval(r.current),r.current=void 0),s())},[e.solved,e.failed,o]);const B=e.getCurrentPhase!==void 0,C=B?e.getCurrentPhase():null;return Z.jsxs("div",{className:"space-y-2 p-2 border-b",children:[Z.jsx("div",{className:"flex items-center",children:Z.jsx(ZAi,{solver:e})}),Z.jsxs("div",{className:"flex gap-2 items-center flex-wrap",children:[Z.jsx("button",{onClick:a,disabled:e.solved||e.failed||o,className:"bg-blue-500 hover:bg-blue-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Step"}),Z.jsx("button",{onClick:g,disabled:e.solved||e.failed||o,className:"bg-green-500 hover:bg-green-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Solve"}),Z.jsx("button",{onClick:c,disabled:e.solved||e.failed,className:`px-3 py-1 rounded text-white text-sm ${o?"bg-red-500 hover:bg-red-600":"bg-yellow-500 hover:bg-yellow-600"} disabled:bg-gray-300`,children:o?"Stop":"Animate"}),Z.jsx("button",{onClick:l,disabled:e.solved||e.failed||o,className:"bg-orange-500 hover:bg-orange-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Step Until Iteration"}),B&&Z.jsx("button",{onClick:I,disabled:e.solved||e.failed||o,className:"bg-purple-500 hover:bg-purple-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Next Stage"}),Z.jsxs("div",{className:"text-sm text-gray-600",children:["Iterations: ",e.iterations]}),e.timeToSolve!==void 0&&Z.jsxs("div",{className:"text-sm text-gray-600",children:["Time: ",(e.timeToSolve/1e3).toFixed(3),"s"]}),C&&Z.jsxs("div",{className:"text-sm text-gray-600",children:["Phase: ",Z.jsx("span",{className:"font-medium",children:C})]}),e.solved&&Z.jsx("div",{className:"px-2 py-1 bg-green-100 text-green-800 rounded text-sm",children:"Solved"}),e.failed&&Z.jsx("div",{className:"px-2 py-1 bg-red-100 text-red-800 rounded text-sm",children:"Failed"})]}),e.error&&Z.jsxs("div",{className:"text-red-600 text-sm",children:["Error: ",e.error]})]})},jAi=(e,A,t)=>{const i=e.currentPipelineStepIndex;return A<i?"Completed":A===i&&e.activeSubSolver?e.activeSubSolver.failed?"Failed":"In Progress":"Not Started"},zAi=(e,A)=>{const i=e.pipelineDef[A].solverName,n=jAi(e,A),o=e[i],s=e.firstIterationOfPhase?.[i]??null,r=e.iterations;let a=0;if(n==="Completed"){const l=e.pipelineDef[A+1],B=l?e.firstIterationOfPhase?.[l.solverName]:void 0;B!==void 0&&s!==null?a=B-s:s!==null&&(a=r-s)}else n==="In Progress"&&s!==null&&(a=r-s);const g=e.timeSpentOnPhase?.[i]??0;let c=0;n==="Completed"?c=1:n==="In Progress"&&o&&(c=o.progress??0);const I=o?.stats??null;return{index:A,name:i,status:n,firstIteration:s,iterations:a,progress:c,timeSpent:g,stats:I&&Object.keys(I).length>0?I:null,solverInstance:o??null}},XAi=({status:e})=>{const A={"Not Started":"text-blue-600","In Progress":"text-yellow-600",Completed:"text-green-600",Failed:"text-red-600"};return Z.jsx("span",{className:`font-medium ${A[e]}`,children:e})},$Ai=({progress:e})=>{if(e===0)return null;const A=Math.round(e*100);return Z.jsxs("div",{className:"flex items-center gap-2",children:[Z.jsx("div",{className:"w-20 h-2 bg-gray-200 rounded overflow-hidden",children:Z.jsx("div",{className:"h-full bg-blue-500 transition-all duration-200",style:{width:`${A}%`}})}),Z.jsxs("span",{className:"text-xs text-gray-500",children:[A,"%"]})]})},Ati=e=>Object.entries(e).map(([A,t])=>`${A}: ${t}`).join(", "),tti=({stats:e})=>{if(!e||Object.keys(e).length===0)return Z.jsx("span",{children:"-"});const A=Object.entries(e),t=Ati(e);return Z.jsxs("details",{className:"cursor-pointer",children:[Z.jsx("summary",{className:"whitespace-nowrap overflow-hidden text-ellipsis max-w-[200px]",children:t}),Z.jsx("div",{className:"mt-1 text-xs",children:A.map(([i,n])=>Z.jsxs("div",{children:[i,": ",String(n)]},i))})]})},yyA=e=>{if(e===null||typeof e!="object")return e;if(Array.isArray(e))return e.map(yyA);const A={};for(const[t,i]of Object.entries(e))t.startsWith("_")||(A[t]=yyA(i));return A},eti=(e,A)=>{try{if(typeof e.getConstructorParams!="function"){alert(`getConstructorParams() is not implemented for ${A}`);return}const t=yyA(e.getConstructorParams()),i=new Blob([JSON.stringify(t,null,2)],{type:"application/json"}),n=URL.createObjectURL(i),o=document.createElement("a");o.href=n,o.download=`${A}_input.json`,o.click(),URL.revokeObjectURL(n)}catch(t){alert(`Error downloading input for ${A}: ${t instanceof Error?t.message:String(t)}`)}},iti=({solver:e,onStepUntilPhase:A,onDownloadInput:t})=>{const i=e.pipelineDef.map((r,a)=>zAi(e,a)),n=r=>{A?.(r)},o=r=>{r.solverInstance&&(t?t(r.solverInstance,r.name):eti(r.solverInstance,r.name))},s=r=>`${(r/1e3).toFixed(2)}s`;return Z.jsxs("div",{className:"border-t border-gray-200",children:[Z.jsx("div",{className:"px-4 py-2 bg-gray-50 border-b border-gray-200",children:Z.jsx("h3",{className:"text-sm font-semibold text-gray-700",children:"Pipeline Steps"})}),Z.jsx("div",{className:"overflow-x-auto",children:Z.jsxs("table",{className:"w-full text-sm",children:[Z.jsx("thead",{children:Z.jsxs("tr",{className:"bg-gray-50 border-b border-gray-200",children:[Z.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Step"}),Z.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Status"}),Z.jsxs("th",{className:"px-4 py-2 text-center font-semibold text-gray-700",children:["i",Z.jsx("sub",{children:"0"})]}),Z.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Iterations"}),Z.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Progress"}),Z.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Time"}),Z.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Stats"}),Z.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Input"})]})}),Z.jsx("tbody",{children:i.map(r=>Z.jsxs("tr",{className:`border-b border-gray-100 ${r.status==="In Progress"?"bg-yellow-50":""}`,children:[Z.jsx("td",{className:"px-4 py-2",children:Z.jsxs("div",{className:"flex items-center gap-2",children:[Z.jsx("span",{className:"text-gray-400 w-6",children:String(r.index+1).padStart(2,"0")}),Z.jsx("button",{onClick:()=>n(r.name),disabled:r.status==="Completed"||e.solved||e.failed,className:"text-blue-500 hover:text-blue-700 disabled:text-gray-300 disabled:cursor-not-allowed",title:`Step until ${r.name} completes`,children:Z.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:Z.jsx("path",{fillRule:"evenodd",d:"M4.5 5.653c0-1.426 1.529-2.33 2.779-1.643l11.54 6.348c1.295.712 1.295 2.573 0 3.285L7.28 19.991c-1.25.687-2.779-.217-2.779-1.643V5.653z",clipRule:"evenodd"})})}),Z.jsx("span",{className:"font-medium text-gray-900",children:r.name})]})}),Z.jsx("td",{className:"px-4 py-2",children:Z.jsx(XAi,{status:r.status})}),Z.jsx("td",{className:"px-4 py-2 text-center text-gray-600",children:r.firstIteration!==null?r.firstIteration:""}),Z.jsx("td",{className:"px-4 py-2 text-gray-600",children:r.iterations}),Z.jsx("td",{className:"px-4 py-2",children:Z.jsx($Ai,{progress:r.progress})}),Z.jsx("td",{className:"px-4 py-2 text-gray-600",children:s(r.timeSpent)}),Z.jsx("td",{className:"px-4 py-2 text-gray-500",children:Z.jsx(tti,{stats:r.stats})}),Z.jsx("td",{className:"px-4 py-2",children:r.solverInstance?Z.jsxs("button",{onClick:()=>o(r),className:"flex items-center gap-1 text-blue-500 hover:text-blue-700",title:`Download input for ${r.name}`,children:[Z.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:Z.jsx("path",{fillRule:"evenodd",d:"M12 2.25a.75.75 0 01.75.75v11.69l3.22-3.22a.75.75 0 111.06 1.06l-4.5 4.5a.75.75 0 01-1.06 0l-4.5-4.5a.75.75 0 111.06-1.06l3.22 3.22V3a.75.75 0 01.75-.75zm-9 13.5a.75.75 0 01.75.75v2.25a1.5 1.5 0 001.5 1.5h13.5a1.5 1.5 0 001.5-1.5V16.5a.75.75 0 011.5 0v2.25a3 3 0 01-3 3H5.25a3 3 0 01-3-3V16.5a.75.75 0 01.75-.75z",clipRule:"evenodd"})}),Z.jsx("span",{children:"Input"})]}):null})]},r.name))})]})})]})},nti=class extends Cn.Component{constructor(e){super(e),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(e){console.error("InteractiveGraphics render error:",e)}render(){return this.state.hasError?this.props.fallback:this.props.children}};function oti({graphics:e}){const A=e.points??[],t=e.lines??[],i=e.rects??[],n=e.circles??[],o=e.texts??[];let s=Number.POSITIVE_INFINITY,r=Number.POSITIVE_INFINITY,a=Number.NEGATIVE_INFINITY,g=Number.NEGATIVE_INFINITY;const c=(h,E)=>{typeof h=="number"&&(h<s&&(s=h),h>a&&(a=h)),typeof E=="number"&&(E<r&&(r=E),E>g&&(g=E))};for(const h of A)c(h.x,h.y);for(const h of t){const E=h.points??[];for(const u of E)c(u.x,u.y)}for(const h of i){const E=h.x??0,u=h.y??0,d=h.width??0,f=h.height??0;c(E,u),c(E+d,u+f)}for(const h of n){const E=h.x??0,u=h.y??0,d=h.radius??1;c(E-d,u-d),c(E+d,u+d)}for(const h of o)c(h.x,h.y);(!isFinite(s)||!isFinite(r)||!isFinite(a)||!isFinite(g))&&(s=-20,r=-20,a=20,g=20);const I=10,l=s-I,B=r-I,C=Math.max(1,a-s+2*I),Q=Math.max(1,g-r+2*I);return Z.jsxs("svg",{className:"w-full h-[400px] bg-white",viewBox:`${l} ${B} ${C} ${Q}`,role:"img","aria-label":"Graphics fallback",children:[i.map((h,E)=>Z.jsx("rect",{x:h.x??0,y:h.y??0,width:h.width??0,height:h.height??0,fill:"none",stroke:h.strokeColor??"black",strokeWidth:h.strokeWidth??1},`rect-${E}`)),t.map((h,E)=>Z.jsx("polyline",{fill:"none",stroke:h.strokeColor??"black",strokeWidth:h.strokeWidth??1,points:(h.points??[]).map(u=>`${u.x??0},${u.y??0}`).join(" ")},`line-${E}`)),n.map((h,E)=>Z.jsx("circle",{cx:h.x??0,cy:h.y??0,r:h.radius??1.5,fill:h.fillColor??"none",stroke:h.strokeColor??"black",strokeWidth:h.strokeWidth??1},`circle-${E}`)),A.map((h,E)=>Z.jsx("circle",{cx:h.x??0,cy:h.y??0,r:h.radius??1.5,fill:h.color??"black"},`point-${E}`)),o.map((h,E)=>Z.jsx("text",{x:h.x??0,y:h.y??0,fontSize:h.fontSize??10,fill:h.color??"black",children:h.text??""},`text-${E}`))]})}var sti=({solver:e,animationSpeed:A=25,onSolverStarted:t,onSolverCompleted:i})=>{const[n,o]=AA.useReducer(c=>c+1,0),s=AA.useMemo(()=>{try{return e.visualize()||{points:[],lines:[],rects:[],circles:[]}}catch(c){return console.error("Visualization error:",c),{points:[],lines:[],rects:[],circles:[]}}},[e,n]),r=AA.useMemo(()=>(s.rects?.length||0)===0&&(s.lines?.length||0)===0&&(s.points?.length||0)===0&&(s.circles?.length||0)===0,[s]);AA.useEffect(()=>{if(!(typeof document>"u")&&!document.querySelector('script[src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4"]')){const c=document.createElement("script");c.src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4",document.head.appendChild(c)}},[]);const a=e.pipelineDef!==void 0,g=c=>{const I=e;if(!e.solved&&!e.failed){for(;!e.solved&&!e.failed&&I.currentPipelineStepIndex<=I.pipelineDef.findIndex(l=>l.solverName===c);)e.step();o()}};return Z.jsxs("div",{children:[Z.jsx(VAi,{solver:e,triggerRender:o,animationSpeed:A,onSolverStarted:t,onSolverCompleted:i}),r?Z.jsx("div",{className:"p-4 text-gray-500",children:"No Graphics Yet"}):Z.jsx(nti,{fallback:Z.jsx(oti,{graphics:s}),children:Z.jsx(OAi,{graphics:s})}),a&&Z.jsx(iti,{solver:e,onStepUntilPhase:g})]})};const rti=()=>{AA.useEffect(()=>{const e="tailwind-cdn-script";if(document.getElementById(e)||window.tailwind)return;const A=document.createElement("div");A.className="hidden",document.body.appendChild(A);const t=window.getComputedStyle(A).display==="none";if(document.body.removeChild(A),t)return;const i=document.createElement("script");i.id=e,i.src="https://cdn.tailwindcss.com",document.head.appendChild(i)},[])},ati=e=>e.toLowerCase().includes("pack")?YJe:e.toLowerCase().includes("rout")?OJe:vJe,gti=({solverEvents:e=[]})=>{const[A,t]=AA.useState(null);rti();const i=AA.useMemo(()=>{const r=new Map;for(const a of e){const g=`${a.componentName}-${a.solverName}`;r.set(g,a)}return r},[e]),n=AA.useMemo(()=>Array.from(i.keys()),[i]),o=A?i.get(A):null,s=AA.useMemo(()=>{if(!o)return{instance:null,error:null,classFound:!1};const r=OgA[o.solverName];if(!r)return{instance:null,error:`Solver class "${o.solverName}" not found in SOLVERS registry. Available: ${Object.keys(OgA).join(", ")}`,classFound:!1};try{const a=o.solverParams,g=a?.input!==void 0?a.input:a;return{instance:new r(g),error:null,classFound:!0}}catch(a){const g=a instanceof Error?a.message:String(a);return console.error("Failed to reconstruct solver:",a),{instance:null,error:`Failed to instantiate solver: ${g}`,classFound:!0}}},[o]);return e.length===0?Z.jsx("div",{className:"rf-p-4",children:Z.jsx("div",{className:"rf-bg-gray-50 rf-rounded-md rf-border rf-border-gray-200",children:Z.jsxs("div",{className:"rf-p-4",children:[Z.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800 rf-mb-3",children:"No Solvers Detected"}),Z.jsx("p",{className:"rf-text-sm rf-text-gray-600",children:"Solvers will appear here when the circuit runs. Solvers are used for tasks like component packing and autorouting."})]})})}):Z.jsxs("div",{className:"rf-flex rf-h-full rf-overflow-hidden",children:[Z.jsxs("div",{className:"rf-w-64 rf-border-r rf-border-gray-200 rf-overflow-y-auto rf-flex-shrink-0",children:[Z.jsxs("div",{className:"rf-text-xs rf-font-semibold rf-text-gray-500 rf-px-3 rf-py-2 rf-bg-gray-50 rf-border-b rf-border-gray-200",children:[n.length," ",n.length===1?"Solver":"Solvers"]}),n.map(r=>{const a=i.get(r),g=A===r;return Z.jsx("div",{className:`rf-px-3 rf-py-2 rf-cursor-pointer rf-border-b rf-border-gray-100 ${g?"rf-bg-blue-50 rf-border-l-2 rf-border-l-blue-500":"hover:rf-bg-gray-50"}`,onClick:()=>t(r),children:(()=>{const c=ati(a.solverName);return Z.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2",children:[Z.jsx(c,{className:"rf-w-4 rf-h-4 rf-text-blue-500 rf-flex-shrink-0"}),Z.jsxs("div",{className:"rf-flex-1 rf-min-w-0",children:[Z.jsx("div",{className:"rf-text-sm rf-font-medium rf-text-gray-800 rf-truncate",children:a.componentName}),Z.jsx("div",{className:"rf-text-xs rf-text-gray-500 rf-truncate",children:a.solverName})]})]})})()},r)})]}),Z.jsx("div",{className:"rf-flex-1 rf-overflow-hidden",children:o?s.instance?Z.jsx(VD,{fallback:Z.jsx("div",{className:"rf-p-4",children:Z.jsxs("div",{className:"rf-bg-red-50 rf-rounded-md rf-border rf-border-red-200 rf-p-4",children:[Z.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-red-800 rf-mb-2",children:"Error Loading Solver Debugger"}),Z.jsxs("p",{className:"rf-text-sm rf-text-red-600",children:["Failed to render the solver debugger for"," ",o.solverName]})]})}),children:Z.jsx(sti,{solver:s.instance})}):Z.jsxs("div",{className:"rf-p-4",children:[Z.jsxs("div",{className:"rf-mb-4",children:[Z.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800",children:o.solverName}),Z.jsxs("p",{className:"rf-text-sm rf-text-gray-500",children:["Component: ",o.componentName]})]}),s.error&&Z.jsx("div",{className:`rf-rounded-md rf-border rf-p-4 rf-mb-4 ${s.classFound?"rf-bg-red-50 rf-border-red-200":"rf-bg-yellow-50 rf-border-yellow-200"}`,children:Z.jsx("p",{className:`rf-text-sm ${s.classFound?"rf-text-red-700":"rf-text-yellow-700"}`,children:s.error})}),Z.jsxs("div",{className:"rf-border rf-border-gray-200 rf-rounded-md rf-overflow-hidden",children:[Z.jsx("div",{className:"rf-px-3 rf-py-2 rf-bg-gray-50",children:Z.jsx("span",{className:"rf-text-sm rf-font-medium rf-text-gray-700",children:"Solver Parameters"})}),Z.jsx("div",{className:"rf-p-3 rf-bg-white rf-border-t rf-border-gray-200",children:Z.jsx("pre",{className:"rf-text-xs rf-font-mono rf-text-gray-600 rf-whitespace-pre-wrap rf-overflow-x-auto",children:JSON.stringify(o.solverParams,null,2)})})]})]}):Z.jsx("div",{className:"rf-flex rf-items-center rf-justify-center rf-h-full",children:Z.jsx("p",{className:"rf-text-sm rf-text-gray-500",children:"Select a solver from the list to view details"})})})]})},HQt=({errorMessage:e,errorStack:A,circuitJsonErrors:t})=>{AA.useEffect(()=>{if(e){const i=new Error(e);A&&(i.stack=A);try{lq.captureException(i)}catch{}}},[e,A]),AA.useEffect(()=>{if(t&&t.length>0)for(const i of t){const n=new Error(i.message||"Circuit JSON Error");i.stack&&(n.stack=i.stack);try{lq.captureException(n,{error_type:i.type})}catch{}}},[t])},YQt="0.0.1729",cti={version:YQt},myA={BASE_URL:"/",DEV:!1,MODE:"production",PROD:!0,SSR:!1},wyA=new Map,jj=e=>{const A=wyA.get(e);return A?Object.fromEntries(Object.entries(A.stores).map(([t,i])=>[t,i.getState()])):{}},Iti=(e,A,t)=>{if(e===void 0)return{type:"untracked",connection:A.connect(t)};const i=wyA.get(t.name);if(i)return{type:"tracked",store:e,...i};const n={connection:A.connect(t),stores:{}};return wyA.set(t.name,n),{type:"tracked",store:e,...n}},JQt=(e,A={})=>(t,i,n)=>{const{enabled:o,anonymousActionType:s,store:r,...a}=A;let g;try{g=(o??(myA?"production":void 0)!=="production")&&window.__REDUX_DEVTOOLS_EXTENSION__}catch{}if(!g)return(myA?"production":void 0)!=="production"&&o&&console.warn("[zustand devtools middleware] Please install/enable Redux devtools extension"),e(t,i,n);const{connection:c,...I}=Iti(r,g,a);let l=!0;n.setState=(Q,h,E)=>{const u=t(Q,h);if(!l)return u;const d=E===void 0?{type:s||"anonymous"}:typeof E=="string"?{type:E}:E;return r===void 0?(c?.send(d,i()),u):(c?.send({...d,type:`${r}/${d.type}`},{...jj(a.name),[r]:n.getState()}),u)};const B=(...Q)=>{const h=l;l=!1,t(...Q),l=h},C=e(n.setState,i,n);if(I.type==="untracked"?c?.init(C):(I.stores[I.store]=n,c?.init(Object.fromEntries(Object.entries(I.stores).map(([Q,h])=>[Q,Q===I.store?C:h.getState()])))),n.dispatchFromDevtools&&typeof n.dispatch=="function"){let Q=!1;const h=n.dispatch;n.dispatch=(...E)=>{(myA?"production":void 0)!=="production"&&E[0].type==="__setState"&&!Q&&(console.warn('[zustand devtools middleware] "__setState" action type is reserved to set state from the devtools. Avoid using it.'),Q=!0),h(...E)}}return c.subscribe(Q=>{var h;switch(Q.type){case"ACTION":if(typeof Q.payload!="string"){console.error("[zustand devtools middleware] Unsupported action format");return}return DyA(Q.payload,E=>{if(E.type==="__setState"){if(r===void 0){B(E.state);return}Object.keys(E.state).length!==1&&console.error(`
|
|
5689
5689
|
[zustand devtools middleware] Unsupported __setState action format.
|
|
5690
5690
|
When using 'store' option in devtools(), the 'state' should have only one key, which is a value of 'store' that was passed in devtools(),
|
|
5691
5691
|
and value of this only key should be a state object. Example: { "type": "__setState", "state": { "abc123Store": { "foo": "bar" } } }
|