@tscircuit/runframe 0.0.439 → 0.0.440
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.
|
@@ -1092,7 +1092,7 @@ var RenderLogViewer = ({
|
|
|
1092
1092
|
};
|
|
1093
1093
|
|
|
1094
1094
|
// package.json
|
|
1095
|
-
var version = "0.0.
|
|
1095
|
+
var version = "0.0.439";
|
|
1096
1096
|
|
|
1097
1097
|
// lib/components/CircuitJsonPreview/CircuitJsonPreview.tsx
|
|
1098
1098
|
import { jsx as jsx16, jsxs as jsxs12 } from "react/jsx-runtime";
|
package/dist/preview.js
CHANGED
package/dist/runner.js
CHANGED
|
@@ -13422,4 +13422,4 @@ $1`).replace(/>(\s*)(?=<!--\s*\/)/g,"> ")}return G0e}Lln();function jGe(r,e,t,n=
|
|
|
13422
13422
|
}
|
|
13423
13423
|
`,onClick:n=>{n.stopPropagation(),t()},children:[ut.jsx("input",{type:"checkbox",checked:e}),ut.jsx("span",{style:{color:"#eee"},children:r})]}),lfn=({children:r,elements:e})=>{const[t,n]=Cx(W=>[W.is_mouse_over_container,W.setIsMouseOverContainer]),[i,a]=mt.useState(!1),[o,s]=mt.useState(!1),[l,c]=mt.useState(!1),[u,f]=Cx(W=>[W.selected_layer,W.selectLayer]),[p,v,x,S,w,b]=Cx(W=>[W.in_move_footprint_mode,W.in_draw_trace_mode,W.is_showing_rats_nest,W.is_showing_multiple_traces_length,W.is_showing_autorouting,W.is_showing_drc_errors]),C=Cx(W=>W.setEditMode),z=Cx(W=>W.setIsShowingRatsNest),I=Cx(W=>W.setIsShowingMultipleTracesLength),G=Cx(W=>W.setIsShowingAutorouting),Y=Cx(W=>W.setIsShowingDrcErrors);v6("1",()=>f("top")),v6("2",()=>f("bottom")),v6("3",()=>f("inner1")),v6("4",()=>f("inner2")),v6("5",()=>f("inner3")),v6("6",()=>f("inner4")),v6("7",()=>f("inner5")),v6("8",()=>f("inner6"));const Z=(e==null?void 0:e.filter(W=>W.type.includes("error")).length)??0;return ut.jsxs("div",{style:{position:"relative"},onMouseEnter:()=>{n(!0)},onMouseLeave:W=>{n(!1),s(!1)},children:[r,ut.jsxs("div",{style:{position:"absolute",bottom:4,right:8,pointerEvents:"none",color:"white",fontSize:11,opacity:t?.5:0,transition:"opacity 1s",transitionDelay:"2s",fontFamily:"sans-serif"},children:["@tscircuit/pcb-viewer@",ofn.version]}),ut.jsxs("div",{style:{position:"absolute",opacity:t?1:0,top:16,left:16,transition:t?"opacity 100ms linear":"opacity 1s linear",zIndex:G5.toolbarOverlay,color:"red",display:"flex",fontSize:12,height:100,fontFamily:"sans-serif"},children:[ut.jsxs(UT,{onClick:()=>{s(!o)},onMouseLeave:()=>{o&&s(!1)},children:[ut.jsxs("div",{children:["layer:"," ",ut.jsx("span",{style:{marginLeft:2,fontWeight:500,color:zT[u]},children:u})]}),o&&ut.jsx("div",{style:{marginTop:4,minWidth:120},children:Mfe.map(W=>W.replace(/-/g,"")).map(W=>ut.jsx(sfn,{name:W,selected:W===u,onClick:()=>{f(W.replace(/-/,""))}},W))})]}),ut.jsxs(UT,{style:Z>0?{color:"red"}:{},onClick:()=>c(!l),onMouseLeave:()=>c(!1),children:[ut.jsxs("div",{children:[Z," errors"]}),l&&ut.jsx("div",{style:{display:"grid",gridTemplateColumns:"100px 300px"},children:e==null?void 0:e.filter(W=>W.type.includes("error")).map((W,te)=>ut.jsxs(mt.Fragment,{children:[ut.jsx("div",{children:W.error_type}),ut.jsx("div",{children:W.message})]},te))})]}),ut.jsx(UT,{style:{},onClick:()=>{C(v?"off":"draw_trace")},children:ut.jsxs("div",{children:[v?"✖ ":"","Edit Traces"]})}),ut.jsx(UT,{style:{},onClick:()=>{C(p?"off":"move_footprint")},children:ut.jsxs("div",{children:[p?"✖ ":"","Move Components"]})}),ut.jsx(UT,{style:{},onClick:()=>{z(!x)},children:ut.jsxs("div",{children:[x?"✖ ":"","Rats Nest"]})}),ut.jsx(UT,{onClick:()=>{a(!i)},children:ut.jsxs("div",{children:[ut.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"4px"},children:["View"," ",ut.jsx("span",{style:{fontSize:"8px",transform:i?"rotate(180deg)":"rotate(0)",transition:"transform 0.1s ease",display:"inline-block"},children:"▼"})]}),i&&ut.jsxs("div",{style:{marginTop:4,minWidth:120},children:[ut.jsx(Nfe,{label:"Show All Trace Lengths",checked:S,onClick:()=>{I(!S)}}),ut.jsx(Nfe,{label:"Show Autorouting Animation",checked:w,onClick:()=>{G(!w)}}),ut.jsx(Nfe,{label:"Show DRC Errors",checked:b,onClick:()=>{Y(!b)}})]})]})})]})]})},cfn=r=>{const{transform:e,elements:t}=r,[n,i]=mt.useMemo(()=>{const c=r.elements.flatMap(f=>x0n(f,r.elements)),u=M8(r.elements);return[c,u]},[r.elements]),[a,o]=mt.useState({drawingObjectIdsWithMouseOver:new Set,primitiveIdsInMousedOverNet:[]}),s=mt.useMemo(()=>y0n({primitivesWithoutInteractionMetadata:n,drawingObjectIdsWithMouseOver:a.drawingObjectIdsWithMouseOver,primitiveIdsInMousedOverNet:a.primitiveIdsInMousedOverNet}),[n,a]),l=mt.useCallback(c=>{var p,v;const u=[];for(const x of c)if(x._element){const S=i.getNetConnectedToId("pcb_port_id"in x._element?(p=x._element)==null?void 0:p.pcb_port_id:"pcb_trace_id"in x._element?(v=x._element)==null?void 0:v.pcb_trace_id:"");u.push(...i.getIdsConnectedToNet(S))}const f=new Set(c.map(x=>x._pcb_drawing_object_id));o({drawingObjectIdsWithMouseOver:f,primitiveIdsInMousedOverNet:u})},[i]);return ut.jsx(ifn,{elements:t,transform:e,primitives:n,onMouseHoverOverPrimitives:l,children:ut.jsx(j0n,{disabled:!r.allowEditing,transform:e,soup:t,cancelPanDrag:r.cancelPanDrag,onCreateEditEvent:r.onCreateEditEvent,onModifyEditEvent:r.onModifyEditEvent,children:ut.jsx(G0n,{disabled:!r.allowEditing,transform:e,soup:t,cancelPanDrag:r.cancelPanDrag,onCreateEditEvent:r.onCreateEditEvent,onModifyEditEvent:r.onModifyEditEvent,children:ut.jsx(F0n,{transform:e,focusOnHover:r.focusOnHover,children:ut.jsx(lfn,{elements:t,children:ut.jsx(X0n,{transform:e,elements:t,children:ut.jsx(afn,{transform:e,soup:t,children:ut.jsx(I0n,{transform:e,debugGraphics:r.debugGraphics,children:ut.jsx(k0n,{transform:e,elements:t,children:ut.jsx(U0n,{transform:e,primitives:s,width:r.width,height:r.height,grid:r.grid})})})})})})})})})})},ufn=Rc(q0(400,300),U2(40,-40)),ffn=({circuitJson:r,debugGraphics:e,height:t=600,initialState:n,allowEditing:i=!0,editEvents:a,onEditEventsChanged:o,focusOnHover:s=!1,clickToInteractEnabled:l=!1})=>{const[c,u]=mt.useState(!l),[f,p]=Afe(),[v,x]=mt.useState(ufn),{ref:S,setTransform:w,cancelDrag:b}=v0n({transform:v,onSetTransform:x,enabled:c});let[C,z]=mt.useState([]);C=a??C;const I=mt.useRef(!1),G=mt.useRef(null),Y=`${(r==null?void 0:r.length)||0}_${(r==null?void 0:r.editCount)||0}`,Z=()=>{const he=(p==null?void 0:p.width)>0?p:{width:500,height:500},{center:ve,width:Te,height:Pe}=te.some(be=>be.type.startsWith("pcb_"))?o0n(te.filter(be=>be.type.startsWith("pcb_"))):{center:{x:0,y:0},width:.001,height:.001},we=Math.min((he.width??0)/Te,(he.height??0)/Pe,100)*.75,Ce=Rc(q0((he.width??0)/2,(he.height??0)/2),U2(we,-we,0,0),q0(-ve.x,-ve.y));w(Ce)};mt.useEffect(()=>{p!=null&&p.width&&r&&r.length!==0&&(I.current||(Z(),I.current=!0))},[r,p]);const W=mt.useMemo(()=>(r==null?void 0:r.filter(he=>he.type.startsWith("pcb_")||he.type.startsWith("source_")))??[],[Y]),te=mt.useMemo(()=>Csn({circuitJson:W,editEvents:C}),[W,C]),J=he=>{z([...C,he]),o==null||o([...C,he])},fe=he=>{const ve=C.map(Te=>Te.edit_event_id===he.edit_event_id?{...Te,...he}:Te);z(ve),o==null||o(ve)};return ut.jsxs("div",{ref:S,style:{position:"relative"},children:[ut.jsx("div",{ref:f,children:ut.jsxs(l0n,{initialState:n,children:[ut.jsx(cfn,{transform:v,height:t,width:p.width,allowEditing:i,focusOnHover:s,cancelPanDrag:b,onCreateEditEvent:J,onModifyEditEvent:fe,grid:{spacing:1,view_window:{left:0,right:p.width||500,top:t,bottom:0}},elements:te,debugGraphics:e},p.width),ut.jsx(u0n,{})]})}),l&&!c&&ut.jsx("div",{onClick:()=>{u(!0),Z()},onTouchStart:he=>{const ve=he.touches[0];G.current={x:ve.clientX,y:ve.clientY}},onTouchEnd:he=>{const ve=he.changedTouches[0],Te=G.current;if(!Te)return;const Pe=Math.abs(ve.clientX-Te.x),we=Math.abs(ve.clientY-Te.y);Pe<10&&we<10&&(he.preventDefault(),u(!0),Z()),G.current=null},style:{position:"absolute",inset:0,cursor:"pointer",zIndex:G5.clickToInteractOverlay,display:"flex",alignItems:"center",justifyContent:"center",touchAction:"pan-x pan-y pinch-zoom"},children:ut.jsx("div",{style:{backgroundColor:"rgba(0, 0, 0, 0.8)",color:"white",padding:"12px 24px",borderRadius:"8px",fontSize:"16px",pointerEvents:"none"},children:typeof window<"u"&&("ontouchstart"in window||navigator.maxTouchPoints>0)?"Touch to Interact":"Click to Interact"})})]})};const dfn=({containerClassName:r,...e})=>{const t=mt.useRef(null),[n,i]=mt.useState(620);return mt.useLayoutEffect(()=>{const a=()=>{if(t.current){const s=t.current.clientHeight,l=window.innerHeight;i(Math.min(Math.max(s,620),l))}};a();const o=new ResizeObserver(a);return t.current&&o.observe(t.current),window.addEventListener("resize",a),()=>{o.disconnect(),window.removeEventListener("resize",a)}},[]),ut.jsx("div",{ref:t,className:r||"rf-w-full rf-h-full",children:ut.jsx(ffn,{...e,height:n})})},pfn='*,:after,:before{--tw-border-spacing-x:0;--tw-border-spacing-y:0;--tw-translate-x:0;--tw-translate-y:0;--tw-rotate:0;--tw-skew-x:0;--tw-skew-y:0;--tw-scale-x:1;--tw-scale-y:1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness:proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:rgba(59,130,246,.5);--tw-ring-offset-shadow:0 0 #0000;--tw-ring-shadow:0 0 #0000;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }::backdrop{--tw-border-spacing-x:0;--tw-border-spacing-y:0;--tw-translate-x:0;--tw-translate-y:0;--tw-rotate:0;--tw-skew-x:0;--tw-skew-y:0;--tw-scale-x:1;--tw-scale-y:1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness:proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:rgba(59,130,246,.5);--tw-ring-offset-shadow:0 0 #0000;--tw-ring-shadow:0 0 #0000;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }/*! tailwindcss v3.4.17 | MIT License | https://tailwindcss.com*/*,:after,:before{border:0 solid #e5e7eb;box-sizing:border-box}:after,:before{--tw-content:""}:host,html{line-height:1.5;-webkit-text-size-adjust:100%;font-family:ui-sans-serif,system-ui,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;font-feature-settings:normal;font-variation-settings:normal;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-tap-highlight-color:transparent}body{line-height:inherit;margin:0}hr{border-top-width:1px;color:inherit;height:0}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,pre,samp{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace;font-feature-settings:normal;font-size:1em;font-variation-settings:normal}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}table{border-collapse:collapse;border-color:inherit;text-indent:0}button,input,optgroup,select,textarea{color:inherit;font-family:inherit;font-feature-settings:inherit;font-size:100%;font-variation-settings:inherit;font-weight:inherit;letter-spacing:inherit;line-height:inherit;margin:0;padding:0}button,select{text-transform:none}button,input:where([type=button]),input:where([type=reset]),input:where([type=submit]){-webkit-appearance:button;background-color:transparent;background-image:none}:-moz-focusring{outline:auto}:-moz-ui-invalid{box-shadow:none}progress{vertical-align:baseline}::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}summary{display:list-item}blockquote,dd,dl,figure,h1,h2,h3,h4,h5,h6,hr,p,pre{margin:0}fieldset{margin:0}fieldset,legend{padding:0}menu,ol,ul{list-style:none;margin:0;padding:0}dialog{padding:0}textarea{resize:vertical}input::-moz-placeholder,textarea::-moz-placeholder{color:#9ca3af;opacity:1}input::placeholder,textarea::placeholder{color:#9ca3af;opacity:1}[role=button],button{cursor:pointer}:disabled{cursor:default}audio,canvas,embed,iframe,img,object,svg,video{display:block;vertical-align:middle}img,video{height:auto;max-width:100%}[hidden]:where(:not([hidden=until-found])){display:none}:root{--radius:0.5rem}.rf-pointer-events-none{pointer-events:none}.rf-invisible{visibility:hidden}.rf-fixed{position:fixed}.rf-absolute{position:absolute}.rf-relative{position:relative}.rf-inset-0{inset:0}.-rf-left-2{left:-.5rem}.-rf-right-10{right:-2.5rem}.-rf-right-2{right:-.5rem}.-rf-right-4{right:-1rem}.-rf-right-6{right:-1.5rem}.-rf-right-7{right:-1.75rem}.-rf-right-8{right:-2rem}.-rf-right-9{right:-2.25rem}.rf-bottom-full{bottom:100%}.rf-left-0{left:0}.rf-left-1{left:.25rem}.rf-left-1\\/2{left:50%}.rf-left-2{left:.5rem}.rf-left-\\[50\\%\\]{left:50%}.rf-right-0{right:0}.rf-right-4{right:1rem}.rf-right-\\[4px\\]{right:4px}.rf-top-0{top:0}.rf-top-1{top:.25rem}.rf-top-2{top:.5rem}.rf-top-2\\.5{top:.625rem}.rf-top-\\[50\\%\\]{top:50%}.rf-top-\\[6px\\]{top:6px}.rf-z-50{z-index:50}.rf-z-\\[100\\]{z-index:100}.-rf-mx-1,.rf--mx-1{margin-left:-.25rem;margin-right:-.25rem}.rf-mx-1{margin-left:.25rem;margin-right:.25rem}.rf-mx-2{margin-left:.5rem;margin-right:.5rem}.rf-mx-auto{margin-left:auto;margin-right:auto}.rf-my-1{margin-bottom:.25rem;margin-top:.25rem}.rf-my-12{margin-bottom:3rem;margin-top:3rem}.rf-my-4{margin-bottom:1rem;margin-top:1rem}.rf-my-auto{margin-bottom:auto;margin-top:auto}.rf-mb-1{margin-bottom:.25rem}.rf-mb-12{margin-bottom:3rem}.rf-mb-2{margin-bottom:.5rem}.rf-mb-3{margin-bottom:.75rem}.rf-mb-4{margin-bottom:1rem}.rf-mb-6{margin-bottom:1.5rem}.rf-mb-8{margin-bottom:2rem}.rf-ml-1{margin-left:.25rem}.rf-ml-2{margin-left:.5rem}.rf-ml-auto{margin-left:auto}.rf-mr-1{margin-right:.25rem}.rf-mr-2{margin-right:.5rem}.rf-mt-0{margin-top:0}.rf-mt-0\\.5{margin-top:.125rem}.rf-mt-1{margin-top:.25rem}.rf-mt-2{margin-top:.5rem}.rf-mt-3{margin-top:.75rem}.rf-mt-4{margin-top:1rem}.rf-mt-5{margin-top:1.25rem}.rf-mt-auto{margin-top:auto}.rf-block{display:block}.rf-inline{display:inline}.rf-flex{display:flex}.rf-inline-flex{display:inline-flex}.rf-grid{display:grid}.rf-hidden{display:none}.rf-aspect-square{aspect-ratio:1/1}.rf-aspect-video{aspect-ratio:16/9}.rf-size-14{height:3.5rem;width:3.5rem}.rf-size-4{height:1rem;width:1rem}.\\!rf-h-2{height:.5rem!important}.\\!rf-h-2\\.5{height:.625rem!important}.\\!rf-h-3{height:.75rem!important}.\\!rf-h-full{height:100%!important}.rf-h-1{height:.25rem}.rf-h-10{height:2.5rem}.rf-h-12{height:3rem}.rf-h-2{height:.5rem}.rf-h-2\\.5{height:.625rem}.rf-h-3{height:.75rem}.rf-h-3\\.5{height:.875rem}.rf-h-4{height:1rem}.rf-h-5{height:1.25rem}.rf-h-6{height:1.5rem}.rf-h-60{height:15rem}.rf-h-64{height:16rem}.rf-h-8{height:2rem}.rf-h-9{height:2.25rem}.rf-h-\\[620px\\]{height:620px}.rf-h-\\[calc\\(100vh-52px\\)\\]{height:calc(100vh - 52px)}.rf-h-\\[calc\\(100vh-96px\\)\\]{height:calc(100vh - 96px)}.rf-h-\\[var\\(--radix-select-trigger-height\\)\\]{height:var(--radix-select-trigger-height)}.rf-h-fit{height:-moz-fit-content;height:fit-content}.rf-h-full{height:100%}.rf-h-px{height:1px}.\\!rf-max-h-\\[40vh\\]{max-height:40vh!important}.\\!rf-max-h-\\[70\\%\\]{max-height:70%!important}.rf-max-h-32{max-height:8rem}.rf-max-h-96{max-height:24rem}.rf-max-h-\\[500px\\]{max-height:500px}.rf-max-h-\\[90vh\\]{max-height:90vh}.rf-min-h-0{min-height:0}.rf-min-h-\\[200px\\]{min-height:200px}.rf-min-h-\\[620px\\]{min-height:620px}.rf-min-h-\\[calc\\(100vh-240px\\)\\]{min-height:calc(100vh - 240px)}.\\!rf-w-2{width:.5rem!important}.\\!rf-w-2\\.5{width:.625rem!important}.rf-w-1{width:.25rem}.rf-w-1\\/2{width:50%}.rf-w-11{width:2.75rem}.rf-w-11\\/12{width:91.666667%}.rf-w-12{width:3rem}.rf-w-16{width:4rem}.rf-w-2{width:.5rem}.rf-w-2\\.5{width:.625rem}.rf-w-3{width:.75rem}.rf-w-3\\.5{width:.875rem}.rf-w-32{width:8rem}.rf-w-4{width:1rem}.rf-w-5{width:1.25rem}.rf-w-6{width:1.5rem}.rf-w-64{width:16rem}.rf-w-72{width:18rem}.rf-w-8{width:2rem}.rf-w-9{width:2.25rem}.rf-w-96{width:24rem}.rf-w-\\[95\\%\\]{width:95%}.rf-w-fit{width:-moz-fit-content;width:fit-content}.rf-w-full{width:100%}.rf-min-w-10{min-width:2.5rem}.rf-min-w-16{min-width:4rem}.rf-min-w-\\[148px\\]{min-width:148px}.rf-min-w-\\[8rem\\]{min-width:8rem}.rf-min-w-\\[var\\(--radix-select-trigger-width\\)\\]{min-width:var(--radix-select-trigger-width)}.\\!rf-max-w-\\[60vw\\]{max-width:60vw!important}.\\!rf-max-w-\\[660px\\]{max-width:660px!important}.rf-max-w-2xl{max-width:42rem}.rf-max-w-3xl{max-width:48rem}.rf-max-w-5xl{max-width:64rem}.rf-max-w-full{max-width:100%}.rf-max-w-lg{max-width:32rem}.rf-max-w-md{max-width:28rem}.rf-max-w-xl{max-width:36rem}.rf-flex-1{flex:1 1 0%}.rf-flex-shrink-0,.rf-shrink-0{flex-shrink:0}.rf-flex-grow{flex-grow:1}.rf-table-auto{table-layout:auto}.-rf-translate-x-1{--tw-translate-x:-0.25rem}.-rf-translate-x-1,.-rf-translate-x-1\\/2{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.-rf-translate-x-1\\/2{--tw-translate-x:-50%}.-rf-translate-y-1{--tw-translate-y:-0.25rem}.-rf-translate-y-1,.rf--translate-x-1{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.rf--translate-x-1{--tw-translate-x:-0.25rem}.rf-translate-x-\\[-50\\%\\]{--tw-translate-x:-50%}.rf-translate-x-\\[-50\\%\\],.rf-translate-y-\\[-50\\%\\]{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.rf-translate-y-\\[-50\\%\\]{--tw-translate-y:-50%}.rf-transform{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}@keyframes rf-pulse{50%{opacity:.5}}.rf-animate-pulse{animation:rf-pulse 2s cubic-bezier(.4,0,.6,1) infinite}@keyframes rf-spin{to{transform:rotate(1turn)}}.rf-animate-spin{animation:rf-spin 1s linear infinite}.rf-cursor-default{cursor:default}.rf-cursor-not-allowed{cursor:not-allowed}.rf-cursor-pointer{cursor:pointer}.rf-select-none{-webkit-user-select:none;-moz-user-select:none;user-select:none}.rf-grid-cols-1{grid-template-columns:repeat(1,minmax(0,1fr))}.rf-grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.rf-flex-row{flex-direction:row}.rf-flex-col{flex-direction:column}.rf-flex-col-reverse{flex-direction:column-reverse}.rf-flex-wrap{flex-wrap:wrap}.rf-place-items-center{place-items:center}.rf-items-start{align-items:flex-start}.rf-items-end{align-items:flex-end}.rf-items-center{align-items:center}.rf-justify-end{justify-content:flex-end}.rf-justify-center{justify-content:center}.rf-justify-between{justify-content:space-between}.rf-gap-0{gap:0}.rf-gap-1{gap:.25rem}.rf-gap-2{gap:.5rem}.rf-gap-3{gap:.75rem}.rf-gap-4{gap:1rem}.rf-gap-5{gap:1.25rem}.rf-gap-6{gap:1.5rem}.rf-gap-8{gap:2rem}.rf-space-x-2>:not([hidden])~:not([hidden]){--tw-space-x-reverse:0;margin-left:calc(.5rem*(1 - var(--tw-space-x-reverse)));margin-right:calc(.5rem*var(--tw-space-x-reverse))}.rf-space-y-2>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-bottom:calc(.5rem*var(--tw-space-y-reverse));margin-top:calc(.5rem*(1 - var(--tw-space-y-reverse)))}.rf-space-y-4>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-bottom:calc(1rem*var(--tw-space-y-reverse));margin-top:calc(1rem*(1 - var(--tw-space-y-reverse)))}.rf-space-y-6>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-bottom:calc(1.5rem*var(--tw-space-y-reverse));margin-top:calc(1.5rem*(1 - var(--tw-space-y-reverse)))}.rf-divide-y>:not([hidden])~:not([hidden]){--tw-divide-y-reverse:0;border-bottom-width:calc(1px*var(--tw-divide-y-reverse));border-top-width:calc(1px*(1 - var(--tw-divide-y-reverse)))}.rf-overflow-auto{overflow:auto}.rf-overflow-hidden{overflow:hidden}.rf-overflow-visible{overflow:visible}.rf-overflow-x-auto{overflow-x:auto}.\\!rf-overflow-y-auto{overflow-y:auto!important}.rf-overflow-y-auto{overflow-y:auto}.\\!rf-overflow-x-hidden{overflow-x:hidden!important}.rf-overflow-x-hidden{overflow-x:hidden}.rf-overflow-x-clip{overflow-x:clip}.rf-truncate{overflow:hidden;text-overflow:ellipsis}.rf-truncate,.rf-whitespace-nowrap{white-space:nowrap}.rf-whitespace-pre-wrap{white-space:pre-wrap}.rf-break-words{overflow-wrap:break-word}.rf-rounded{border-radius:.25rem}.rf-rounded-2xl{border-radius:1rem}.rf-rounded-full{border-radius:9999px}.rf-rounded-lg{border-radius:var(--radius)}.rf-rounded-md{border-radius:calc(var(--radius) - 2px)}.rf-rounded-sm{border-radius:calc(var(--radius) - 4px)}.rf-rounded-xl{border-radius:.75rem}.rf-border{border-width:1px}.rf-border-b{border-bottom-width:1px}.rf-border-t{border-top-width:1px}.rf-border-blue-200{--tw-border-opacity:1;border-color:rgb(191 219 254/var(--tw-border-opacity,1))}.rf-border-blue-500{--tw-border-opacity:1;border-color:rgb(59 130 246/var(--tw-border-opacity,1))}.rf-border-blue-600{--tw-border-opacity:1;border-color:rgb(37 99 235/var(--tw-border-opacity,1))}.rf-border-gray-200{--tw-border-opacity:1;border-color:rgb(229 231 235/var(--tw-border-opacity,1))}.rf-border-gray-300{--tw-border-opacity:1;border-color:rgb(209 213 219/var(--tw-border-opacity,1))}.rf-border-green-200{--tw-border-opacity:1;border-color:rgb(187 247 208/var(--tw-border-opacity,1))}.rf-border-input{border-color:hsl(var(--input))}.rf-border-neutral-200{--tw-border-opacity:1;border-color:rgb(229 229 229/var(--tw-border-opacity,1))}.rf-border-primary{border-color:hsl(var(--primary))}.rf-border-red-200{--tw-border-opacity:1;border-color:rgb(254 202 202/var(--tw-border-opacity,1))}.rf-border-red-500{--tw-border-opacity:1;border-color:rgb(239 68 68/var(--tw-border-opacity,1))}.rf-border-zinc-200{--tw-border-opacity:1;border-color:rgb(228 228 231/var(--tw-border-opacity,1))}.rf-border-zinc-900{--tw-border-opacity:1;border-color:rgb(24 24 27/var(--tw-border-opacity,1))}.rf-bg-background{background-color:hsl(var(--background))}.rf-bg-black{--tw-bg-opacity:1;background-color:rgb(0 0 0/var(--tw-bg-opacity,1))}.rf-bg-black\\/80{background-color:rgba(0,0,0,.8)}.rf-bg-blue-100{--tw-bg-opacity:1;background-color:rgb(219 234 254/var(--tw-bg-opacity,1))}.rf-bg-blue-50{--tw-bg-opacity:1;background-color:rgb(239 246 255/var(--tw-bg-opacity,1))}.rf-bg-blue-500{--tw-bg-opacity:1;background-color:rgb(59 130 246/var(--tw-bg-opacity,1))}.rf-bg-blue-600{--tw-bg-opacity:1;background-color:rgb(37 99 235/var(--tw-bg-opacity,1))}.rf-bg-gray-100{--tw-bg-opacity:1;background-color:rgb(243 244 246/var(--tw-bg-opacity,1))}.rf-bg-gray-200{--tw-bg-opacity:1;background-color:rgb(229 231 235/var(--tw-bg-opacity,1))}.rf-bg-gray-300{--tw-bg-opacity:1;background-color:rgb(209 213 219/var(--tw-bg-opacity,1))}.rf-bg-gray-400{--tw-bg-opacity:1;background-color:rgb(156 163 175/var(--tw-bg-opacity,1))}.rf-bg-gray-50{--tw-bg-opacity:1;background-color:rgb(249 250 251/var(--tw-bg-opacity,1))}.rf-bg-gray-500{--tw-bg-opacity:1;background-color:rgb(107 114 128/var(--tw-bg-opacity,1))}.rf-bg-gray-700{--tw-bg-opacity:1;background-color:rgb(55 65 81/var(--tw-bg-opacity,1))}.rf-bg-gray-800{--tw-bg-opacity:1;background-color:rgb(31 41 55/var(--tw-bg-opacity,1))}.rf-bg-gray-900{--tw-bg-opacity:1;background-color:rgb(17 24 39/var(--tw-bg-opacity,1))}.rf-bg-green-100{--tw-bg-opacity:1;background-color:rgb(220 252 231/var(--tw-bg-opacity,1))}.rf-bg-green-50{--tw-bg-opacity:1;background-color:rgb(240 253 244/var(--tw-bg-opacity,1))}.rf-bg-muted{background-color:hsl(var(--muted))}.rf-bg-neutral-100{--tw-bg-opacity:1;background-color:rgb(245 245 245/var(--tw-bg-opacity,1))}.rf-bg-neutral-50{--tw-bg-opacity:1;background-color:rgb(250 250 250/var(--tw-bg-opacity,1))}.rf-bg-neutral-800{--tw-bg-opacity:1;background-color:rgb(38 38 38/var(--tw-bg-opacity,1))}.rf-bg-neutral-900{--tw-bg-opacity:1;background-color:rgb(23 23 23/var(--tw-bg-opacity,1))}.rf-bg-orange-400{--tw-bg-opacity:1;background-color:rgb(251 146 60/var(--tw-bg-opacity,1))}.rf-bg-popover{background-color:hsl(var(--popover))}.rf-bg-red-100{--tw-bg-opacity:1;background-color:rgb(254 226 226/var(--tw-bg-opacity,1))}.rf-bg-red-50{--tw-bg-opacity:1;background-color:rgb(254 242 242/var(--tw-bg-opacity,1))}.rf-bg-red-500{--tw-bg-opacity:1;background-color:rgb(239 68 68/var(--tw-bg-opacity,1))}.rf-bg-red-900{--tw-bg-opacity:1;background-color:rgb(127 29 29/var(--tw-bg-opacity,1))}.rf-bg-white{--tw-bg-opacity:1;background-color:rgb(255 255 255/var(--tw-bg-opacity,1))}.rf-bg-yellow-100{--tw-bg-opacity:1;background-color:rgb(254 249 195/var(--tw-bg-opacity,1))}.rf-bg-zinc-100{--tw-bg-opacity:1;background-color:rgb(244 244 245/var(--tw-bg-opacity,1))}.rf-bg-zinc-200{--tw-bg-opacity:1;background-color:rgb(228 228 231/var(--tw-bg-opacity,1))}.rf-bg-zinc-50{--tw-bg-opacity:1;background-color:rgb(250 250 250/var(--tw-bg-opacity,1))}.rf-bg-zinc-800{--tw-bg-opacity:1;background-color:rgb(39 39 42/var(--tw-bg-opacity,1))}.rf-bg-zinc-900{--tw-bg-opacity:1;background-color:rgb(24 24 27/var(--tw-bg-opacity,1))}.rf-bg-opacity-50{--tw-bg-opacity:0.5}.rf-fill-current{fill:currentColor}.rf-object-contain{-o-object-fit:contain;object-fit:contain}.\\!rf-p-0{padding:0!important}.rf-p-0{padding:0}.rf-p-1{padding:.25rem}.rf-p-2{padding:.5rem}.rf-p-3{padding:.75rem}.rf-p-4{padding:1rem}.rf-p-5{padding:1.25rem}.rf-p-6{padding:1.5rem}.rf-p-8{padding:2rem}.rf-px-1{padding-left:.25rem;padding-right:.25rem}.rf-px-2{padding-left:.5rem;padding-right:.5rem}.rf-px-3{padding-left:.75rem;padding-right:.75rem}.rf-px-4{padding-left:1rem;padding-right:1rem}.rf-px-6{padding-left:1.5rem;padding-right:1.5rem}.rf-px-8{padding-left:2rem;padding-right:2rem}.rf-py-0{padding-bottom:0;padding-top:0}.rf-py-0\\.5{padding-bottom:.125rem;padding-top:.125rem}.rf-py-1{padding-bottom:.25rem;padding-top:.25rem}.rf-py-1\\.5{padding-bottom:.375rem;padding-top:.375rem}.rf-py-10{padding-bottom:2.5rem;padding-top:2.5rem}.rf-py-12{padding-bottom:3rem;padding-top:3rem}.rf-py-2{padding-bottom:.5rem;padding-top:.5rem}.rf-py-3{padding-bottom:.75rem;padding-top:.75rem}.rf-py-4{padding-bottom:1rem;padding-top:1rem}.rf-py-8{padding-bottom:2rem;padding-top:2rem}.rf-pb-0{padding-bottom:0}.rf-pb-2{padding-bottom:.5rem}.rf-pb-3{padding-bottom:.75rem}.rf-pb-4{padding-bottom:1rem}.rf-pl-2{padding-left:.5rem}.rf-pl-4{padding-left:1rem}.rf-pl-8{padding-left:2rem}.rf-pr-2{padding-right:.5rem}.rf-pt-2{padding-top:.5rem}.rf-pt-4{padding-top:1rem}.rf-text-left{text-align:left}.rf-text-center{text-align:center}.rf-text-right{text-align:right}.rf-font-mono{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace}.rf-text-2xl{font-size:1.5rem;line-height:2rem}.rf-text-3xl{font-size:1.875rem;line-height:2.25rem}.rf-text-\\[8px\\]{font-size:8px}.rf-text-base{font-size:1rem;line-height:1.5rem}.rf-text-lg{font-size:1.125rem;line-height:1.75rem}.rf-text-sm{font-size:.875rem;line-height:1.25rem}.rf-text-xl{font-size:1.25rem;line-height:1.75rem}.rf-text-xs{font-size:.75rem;line-height:1rem}.rf-font-bold{font-weight:700}.rf-font-medium{font-weight:500}.rf-font-semibold{font-weight:600}.rf-capitalize{text-transform:capitalize}.rf-tabular-nums{--tw-numeric-spacing:tabular-nums;font-variant-numeric:var(--tw-ordinal) var(--tw-slashed-zero) var(--tw-numeric-figure) var(--tw-numeric-spacing) var(--tw-numeric-fraction)}.rf-leading-5{line-height:1.25rem}.rf-leading-none{line-height:1}.rf-leading-tight{line-height:1.25}.rf-tracking-widest{letter-spacing:.1em}.rf-text-black{--tw-text-opacity:1;color:rgb(0 0 0/var(--tw-text-opacity,1))}.rf-text-blue-500{--tw-text-opacity:1;color:rgb(59 130 246/var(--tw-text-opacity,1))}.rf-text-blue-600{--tw-text-opacity:1;color:rgb(37 99 235/var(--tw-text-opacity,1))}.rf-text-blue-700{--tw-text-opacity:1;color:rgb(29 78 216/var(--tw-text-opacity,1))}.rf-text-blue-800{--tw-text-opacity:1;color:rgb(30 64 175/var(--tw-text-opacity,1))}.rf-text-blue-900{--tw-text-opacity:1;color:rgb(30 58 138/var(--tw-text-opacity,1))}.rf-text-current{color:currentColor}.rf-text-gray-400{--tw-text-opacity:1;color:rgb(156 163 175/var(--tw-text-opacity,1))}.rf-text-gray-500{--tw-text-opacity:1;color:rgb(107 114 128/var(--tw-text-opacity,1))}.rf-text-gray-600{--tw-text-opacity:1;color:rgb(75 85 99/var(--tw-text-opacity,1))}.rf-text-gray-700{--tw-text-opacity:1;color:rgb(55 65 81/var(--tw-text-opacity,1))}.rf-text-gray-800{--tw-text-opacity:1;color:rgb(31 41 55/var(--tw-text-opacity,1))}.rf-text-gray-900{--tw-text-opacity:1;color:rgb(17 24 39/var(--tw-text-opacity,1))}.rf-text-green-500{--tw-text-opacity:1;color:rgb(34 197 94/var(--tw-text-opacity,1))}.rf-text-green-600{--tw-text-opacity:1;color:rgb(22 163 74/var(--tw-text-opacity,1))}.rf-text-green-700{--tw-text-opacity:1;color:rgb(21 128 61/var(--tw-text-opacity,1))}.rf-text-green-800{--tw-text-opacity:1;color:rgb(22 101 52/var(--tw-text-opacity,1))}.rf-text-green-900{--tw-text-opacity:1;color:rgb(20 83 45/var(--tw-text-opacity,1))}.rf-text-muted-foreground{color:hsl(var(--muted-foreground))}.rf-text-neutral-50{--tw-text-opacity:1;color:rgb(250 250 250/var(--tw-text-opacity,1))}.rf-text-neutral-500{--tw-text-opacity:1;color:rgb(115 115 115/var(--tw-text-opacity,1))}.rf-text-neutral-900{--tw-text-opacity:1;color:rgb(23 23 23/var(--tw-text-opacity,1))}.rf-text-neutral-950{--tw-text-opacity:1;color:rgb(10 10 10/var(--tw-text-opacity,1))}.rf-text-popover-foreground{color:hsl(var(--popover-foreground))}.rf-text-red-200{--tw-text-opacity:1;color:rgb(254 202 202/var(--tw-text-opacity,1))}.rf-text-red-300{--tw-text-opacity:1;color:rgb(252 165 165/var(--tw-text-opacity,1))}.rf-text-red-400{--tw-text-opacity:1;color:rgb(248 113 113/var(--tw-text-opacity,1))}.rf-text-red-500{--tw-text-opacity:1;color:rgb(239 68 68/var(--tw-text-opacity,1))}.rf-text-red-600{--tw-text-opacity:1;color:rgb(220 38 38/var(--tw-text-opacity,1))}.rf-text-red-700{--tw-text-opacity:1;color:rgb(185 28 28/var(--tw-text-opacity,1))}.rf-text-red-800{--tw-text-opacity:1;color:rgb(153 27 27/var(--tw-text-opacity,1))}.rf-text-red-900{--tw-text-opacity:1;color:rgb(127 29 29/var(--tw-text-opacity,1))}.rf-text-white{--tw-text-opacity:1;color:rgb(255 255 255/var(--tw-text-opacity,1))}.rf-text-yellow-400{--tw-text-opacity:1;color:rgb(250 204 21/var(--tw-text-opacity,1))}.rf-text-yellow-500{--tw-text-opacity:1;color:rgb(234 179 8/var(--tw-text-opacity,1))}.rf-text-yellow-900{--tw-text-opacity:1;color:rgb(113 63 18/var(--tw-text-opacity,1))}.rf-text-zinc-200{--tw-text-opacity:1;color:rgb(228 228 231/var(--tw-text-opacity,1))}.rf-text-zinc-300{--tw-text-opacity:1;color:rgb(212 212 216/var(--tw-text-opacity,1))}.rf-text-zinc-400{--tw-text-opacity:1;color:rgb(161 161 170/var(--tw-text-opacity,1))}.rf-text-zinc-50{--tw-text-opacity:1;color:rgb(250 250 250/var(--tw-text-opacity,1))}.rf-text-zinc-500{--tw-text-opacity:1;color:rgb(113 113 122/var(--tw-text-opacity,1))}.rf-text-zinc-900{--tw-text-opacity:1;color:rgb(24 24 27/var(--tw-text-opacity,1))}.rf-text-zinc-950{--tw-text-opacity:1;color:rgb(9 9 11/var(--tw-text-opacity,1))}.rf-underline{text-decoration-line:underline}.rf-line-through{text-decoration-line:line-through}.rf-underline-offset-4{text-underline-offset:4px}.rf-opacity-0{opacity:0}.rf-opacity-25{opacity:.25}.rf-opacity-30{opacity:.3}.rf-opacity-50{opacity:.5}.rf-opacity-60{opacity:.6}.rf-opacity-75{opacity:.75}.rf-shadow{--tw-shadow:0 1px 3px 0 rgba(0,0,0,.1),0 1px 2px -1px rgba(0,0,0,.1);--tw-shadow-colored:0 1px 3px 0 var(--tw-shadow-color),0 1px 2px -1px var(--tw-shadow-color)}.rf-shadow,.rf-shadow-lg{box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}.rf-shadow-lg{--tw-shadow:0 10px 15px -3px rgba(0,0,0,.1),0 4px 6px -4px rgba(0,0,0,.1);--tw-shadow-colored:0 10px 15px -3px var(--tw-shadow-color),0 4px 6px -4px var(--tw-shadow-color)}.rf-shadow-md{--tw-shadow:0 4px 6px -1px rgba(0,0,0,.1),0 2px 4px -2px rgba(0,0,0,.1);--tw-shadow-colored:0 4px 6px -1px var(--tw-shadow-color),0 2px 4px -2px var(--tw-shadow-color)}.rf-shadow-md,.rf-shadow-sm{box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}.rf-shadow-sm{--tw-shadow:0 1px 2px 0 rgba(0,0,0,.05);--tw-shadow-colored:0 1px 2px 0 var(--tw-shadow-color)}.rf-outline-none{outline:2px solid transparent;outline-offset:2px}.rf-ring-2{--tw-ring-offset-shadow:var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow:var(--tw-ring-inset) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow,0 0 #0000)}.rf-ring-blue-500{--tw-ring-opacity:1;--tw-ring-color:rgb(59 130 246/var(--tw-ring-opacity,1))}.rf-ring-primary{--tw-ring-color:hsl(var(--primary))}.rf-ring-offset-background{--tw-ring-offset-color:hsl(var(--background))}.rf-ring-offset-white{--tw-ring-offset-color:#fff}.rf-transition{transition-duration:.15s;transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,-webkit-backdrop-filter;transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,backdrop-filter;transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,backdrop-filter,-webkit-backdrop-filter;transition-timing-function:cubic-bezier(.4,0,.2,1)}.rf-transition-all{transition-duration:.15s;transition-property:all;transition-timing-function:cubic-bezier(.4,0,.2,1)}.rf-transition-colors{transition-duration:.15s;transition-property:color,background-color,border-color,text-decoration-color,fill,stroke;transition-timing-function:cubic-bezier(.4,0,.2,1)}.rf-transition-opacity{transition-duration:.15s;transition-property:opacity;transition-timing-function:cubic-bezier(.4,0,.2,1)}.rf-duration-200{transition-duration:.2s}.rf-ease-in-out{transition-timing-function:cubic-bezier(.4,0,.2,1)}@keyframes enter{0%{opacity:var(--tw-enter-opacity,1);transform:translate3d(var(--tw-enter-translate-x,0),var(--tw-enter-translate-y,0),0) scale3d(var(--tw-enter-scale,1),var(--tw-enter-scale,1),var(--tw-enter-scale,1)) rotate(var(--tw-enter-rotate,0))}}@keyframes exit{to{opacity:var(--tw-exit-opacity,1);transform:translate3d(var(--tw-exit-translate-x,0),var(--tw-exit-translate-y,0),0) scale3d(var(--tw-exit-scale,1),var(--tw-exit-scale,1),var(--tw-exit-scale,1)) rotate(var(--tw-exit-rotate,0))}}.rf-slide-in-from-left-1{--tw-enter-translate-x:-0.25rem}.rf-slide-out-to-left-1{--tw-exit-translate-x:-0.25rem}.rf-duration-200{animation-duration:.2s}.rf-ease-in-out{animation-timing-function:cubic-bezier(.4,0,.2,1)}.file\\:rf-border-0::file-selector-button{border-width:0}.file\\:rf-bg-transparent::file-selector-button{background-color:transparent}.file\\:rf-text-sm::file-selector-button{font-size:.875rem;line-height:1.25rem}.file\\:rf-font-medium::file-selector-button{font-weight:500}.placeholder\\:rf-text-zinc-500::-moz-placeholder{--tw-text-opacity:1;color:rgb(113 113 122/var(--tw-text-opacity,1))}.placeholder\\:rf-text-zinc-500::placeholder{--tw-text-opacity:1;color:rgb(113 113 122/var(--tw-text-opacity,1))}.hover\\:rf-border-blue-300:hover{--tw-border-opacity:1;border-color:rgb(147 197 253/var(--tw-border-opacity,1))}.hover\\:\\!rf-bg-transparent:hover{background-color:transparent!important}.hover\\:rf-bg-blue-700:hover{--tw-bg-opacity:1;background-color:rgb(29 78 216/var(--tw-bg-opacity,1))}.hover\\:rf-bg-red-500\\/90:hover{background-color:rgba(239,68,68,.9)}.hover\\:rf-bg-zinc-100:hover{--tw-bg-opacity:1;background-color:rgb(244 244 245/var(--tw-bg-opacity,1))}.hover\\:rf-bg-zinc-100\\/80:hover{background-color:hsla(240,5%,96%,.8)}.hover\\:rf-bg-zinc-900\\/90:hover{background-color:rgba(24,24,27,.9)}.hover\\:rf-text-red-400:hover{--tw-text-opacity:1;color:rgb(248 113 113/var(--tw-text-opacity,1))}.hover\\:rf-text-zinc-900:hover{--tw-text-opacity:1;color:rgb(24 24 27/var(--tw-text-opacity,1))}.hover\\:rf-underline:hover{text-decoration-line:underline}.focus\\:rf-bg-gray-100:focus{--tw-bg-opacity:1;background-color:rgb(243 244 246/var(--tw-bg-opacity,1))}.focus\\:rf-bg-zinc-100:focus{--tw-bg-opacity:1;background-color:rgb(244 244 245/var(--tw-bg-opacity,1))}.focus\\:rf-text-gray-900:focus{--tw-text-opacity:1;color:rgb(17 24 39/var(--tw-text-opacity,1))}.focus\\:rf-text-zinc-900:focus{--tw-text-opacity:1;color:rgb(24 24 27/var(--tw-text-opacity,1))}.focus\\:rf-outline-none:focus{outline:2px solid transparent;outline-offset:2px}.focus\\:rf-ring-2:focus{--tw-ring-offset-shadow:var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow:var(--tw-ring-inset) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow,0 0 #0000)}.focus\\:rf-ring-ring:focus{--tw-ring-color:hsl(var(--ring))}.focus\\:rf-ring-offset-2:focus{--tw-ring-offset-width:2px}.focus-visible\\:rf-outline-none:focus-visible{outline:2px solid transparent;outline-offset:2px}.focus-visible\\:rf-ring-1:focus-visible{--tw-ring-offset-shadow:var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow:var(--tw-ring-inset) 0 0 0 calc(1px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow,0 0 #0000)}.focus-visible\\:rf-ring-2:focus-visible{--tw-ring-offset-shadow:var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow:var(--tw-ring-inset) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow,0 0 #0000)}.focus-visible\\:rf-ring-zinc-950:focus-visible{--tw-ring-opacity:1;--tw-ring-color:rgb(9 9 11/var(--tw-ring-opacity,1))}.focus-visible\\:rf-ring-offset-2:focus-visible{--tw-ring-offset-width:2px}.disabled\\:rf-pointer-events-none:disabled{pointer-events:none}.disabled\\:rf-cursor-not-allowed:disabled{cursor:not-allowed}.disabled\\:rf-opacity-50:disabled{opacity:.5}.rf-group\\/bar:hover .group-hover\\/bar\\:rf-opacity-100{opacity:1}.data-\\[disabled\\]\\:rf-pointer-events-none[data-disabled]{pointer-events:none}.data-\\[side\\=bottom\\]\\:rf-translate-y-1[data-side=bottom]{--tw-translate-y:0.25rem}.data-\\[side\\=bottom\\]\\:rf-translate-y-1[data-side=bottom],.data-\\[side\\=left\\]\\:-rf-translate-x-1[data-side=left]{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.data-\\[side\\=left\\]\\:-rf-translate-x-1[data-side=left]{--tw-translate-x:-0.25rem}.data-\\[side\\=right\\]\\:rf-translate-x-1[data-side=right]{--tw-translate-x:0.25rem}.data-\\[side\\=right\\]\\:rf-translate-x-1[data-side=right],.data-\\[side\\=top\\]\\:-rf-translate-y-1[data-side=top]{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.data-\\[side\\=top\\]\\:-rf-translate-y-1[data-side=top]{--tw-translate-y:-0.25rem}.data-\\[state\\=active\\]\\:rf-bg-white[data-state=active]{--tw-bg-opacity:1;background-color:rgb(255 255 255/var(--tw-bg-opacity,1))}.data-\\[state\\=checked\\]\\:rf-bg-zinc-900[data-state=checked]{--tw-bg-opacity:1;background-color:rgb(24 24 27/var(--tw-bg-opacity,1))}.data-\\[state\\=open\\]\\:rf-bg-zinc-100[data-state=open]{--tw-bg-opacity:1;background-color:rgb(244 244 245/var(--tw-bg-opacity,1))}.data-\\[state\\=active\\]\\:rf-text-zinc-950[data-state=active]{--tw-text-opacity:1;color:rgb(9 9 11/var(--tw-text-opacity,1))}.data-\\[state\\=checked\\]\\:rf-text-zinc-50[data-state=checked]{--tw-text-opacity:1;color:rgb(250 250 250/var(--tw-text-opacity,1))}.data-\\[disabled\\]\\:rf-opacity-50[data-disabled]{opacity:.5}.data-\\[state\\=active\\]\\:rf-shadow[data-state=active]{--tw-shadow:0 1px 3px 0 rgba(0,0,0,.1),0 1px 2px -1px rgba(0,0,0,.1);--tw-shadow-colored:0 1px 3px 0 var(--tw-shadow-color),0 1px 2px -1px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}.data-\\[state\\=open\\]\\:rf-animate-in[data-state=open]{animation-duration:.15s;animation-name:enter;--tw-enter-opacity:initial;--tw-enter-scale:initial;--tw-enter-rotate:initial;--tw-enter-translate-x:initial;--tw-enter-translate-y:initial}.data-\\[state\\=closed\\]\\:rf-animate-out[data-state=closed]{animation-duration:.15s;animation-name:exit;--tw-exit-opacity:initial;--tw-exit-scale:initial;--tw-exit-rotate:initial;--tw-exit-translate-x:initial;--tw-exit-translate-y:initial}.data-\\[state\\=closed\\]\\:rf-fade-out-0[data-state=closed]{--tw-exit-opacity:0}.data-\\[state\\=open\\]\\:rf-fade-in-0[data-state=open]{--tw-enter-opacity:0}.data-\\[state\\=closed\\]\\:rf-zoom-out-95[data-state=closed]{--tw-exit-scale:.95}.data-\\[state\\=open\\]\\:rf-zoom-in-95[data-state=open]{--tw-enter-scale:.95}.data-\\[side\\=bottom\\]\\:rf-slide-in-from-top-2[data-side=bottom]{--tw-enter-translate-y:-0.5rem}.data-\\[side\\=left\\]\\:rf-slide-in-from-right-2[data-side=left]{--tw-enter-translate-x:0.5rem}.data-\\[side\\=right\\]\\:rf-slide-in-from-left-2[data-side=right]{--tw-enter-translate-x:-0.5rem}.data-\\[side\\=top\\]\\:rf-slide-in-from-bottom-2[data-side=top]{--tw-enter-translate-y:0.5rem}.data-\\[state\\=closed\\]\\:rf-slide-out-to-left-1\\/2[data-state=closed]{--tw-exit-translate-x:-50%}.data-\\[state\\=closed\\]\\:rf-slide-out-to-top-\\[48\\%\\][data-state=closed]{--tw-exit-translate-y:-48%}.data-\\[state\\=open\\]\\:rf-slide-in-from-left-1\\/2[data-state=open]{--tw-enter-translate-x:-50%}.data-\\[state\\=open\\]\\:rf-slide-in-from-top-\\[48\\%\\][data-state=open]{--tw-enter-translate-y:-48%}.dark\\:rf-border-zinc-50:is(.rf-dark *){--tw-border-opacity:1;border-color:rgb(250 250 250/var(--tw-border-opacity,1))}.dark\\:rf-border-zinc-800:is(.rf-dark *){--tw-border-opacity:1;border-color:rgb(39 39 42/var(--tw-border-opacity,1))}.dark\\:rf-bg-red-900:is(.rf-dark *){--tw-bg-opacity:1;background-color:rgb(127 29 29/var(--tw-bg-opacity,1))}.dark\\:rf-bg-zinc-50:is(.rf-dark *){--tw-bg-opacity:1;background-color:rgb(250 250 250/var(--tw-bg-opacity,1))}.dark\\:rf-bg-zinc-800:is(.rf-dark *){--tw-bg-opacity:1;background-color:rgb(39 39 42/var(--tw-bg-opacity,1))}.dark\\:rf-bg-zinc-950:is(.rf-dark *){--tw-bg-opacity:1;background-color:rgb(9 9 11/var(--tw-bg-opacity,1))}.dark\\:rf-text-zinc-400:is(.rf-dark *){--tw-text-opacity:1;color:rgb(161 161 170/var(--tw-text-opacity,1))}.dark\\:rf-text-zinc-50:is(.rf-dark *){--tw-text-opacity:1;color:rgb(250 250 250/var(--tw-text-opacity,1))}.dark\\:rf-text-zinc-900:is(.rf-dark *){--tw-text-opacity:1;color:rgb(24 24 27/var(--tw-text-opacity,1))}.dark\\:rf-placeholder-zinc-400:is(.rf-dark *)::-moz-placeholder{--tw-placeholder-opacity:1;color:rgb(161 161 170/var(--tw-placeholder-opacity,1))}.dark\\:rf-placeholder-zinc-400:is(.rf-dark *)::placeholder{--tw-placeholder-opacity:1;color:rgb(161 161 170/var(--tw-placeholder-opacity,1))}.dark\\:rf-ring-offset-zinc-950:is(.rf-dark *){--tw-ring-offset-color:#09090b}.dark\\:hover\\:rf-bg-red-900\\/90:hover:is(.rf-dark *){background-color:rgba(127,29,29,.9)}.dark\\:hover\\:rf-bg-zinc-50\\/90:hover:is(.rf-dark *){background-color:hsla(0,0%,98%,.9)}.dark\\:hover\\:rf-bg-zinc-800:hover:is(.rf-dark *){--tw-bg-opacity:1;background-color:rgb(39 39 42/var(--tw-bg-opacity,1))}.dark\\:hover\\:rf-bg-zinc-800\\/80:hover:is(.rf-dark *){background-color:rgba(39,39,42,.8)}.dark\\:hover\\:rf-text-zinc-50:hover:is(.rf-dark *){--tw-text-opacity:1;color:rgb(250 250 250/var(--tw-text-opacity,1))}.dark\\:focus\\:rf-bg-zinc-800:focus:is(.rf-dark *){--tw-bg-opacity:1;background-color:rgb(39 39 42/var(--tw-bg-opacity,1))}.dark\\:focus\\:rf-text-zinc-50:focus:is(.rf-dark *){--tw-text-opacity:1;color:rgb(250 250 250/var(--tw-text-opacity,1))}.dark\\:focus-visible\\:rf-ring-zinc-300:focus-visible:is(.rf-dark *){--tw-ring-opacity:1;--tw-ring-color:rgb(212 212 216/var(--tw-ring-opacity,1))}.dark\\:data-\\[state\\=active\\]\\:rf-bg-zinc-950[data-state=active]:is(.rf-dark *){--tw-bg-opacity:1;background-color:rgb(9 9 11/var(--tw-bg-opacity,1))}.dark\\:data-\\[state\\=checked\\]\\:rf-bg-zinc-50[data-state=checked]:is(.rf-dark *){--tw-bg-opacity:1;background-color:rgb(250 250 250/var(--tw-bg-opacity,1))}.dark\\:data-\\[state\\=open\\]\\:rf-bg-zinc-800[data-state=open]:is(.rf-dark *){--tw-bg-opacity:1;background-color:rgb(39 39 42/var(--tw-bg-opacity,1))}.dark\\:data-\\[state\\=active\\]\\:rf-text-zinc-50[data-state=active]:is(.rf-dark *){--tw-text-opacity:1;color:rgb(250 250 250/var(--tw-text-opacity,1))}.dark\\:data-\\[state\\=checked\\]\\:rf-text-zinc-900[data-state=checked]:is(.rf-dark *){--tw-text-opacity:1;color:rgb(24 24 27/var(--tw-text-opacity,1))}@media (min-width:640px){.sm\\:rf-mt-0{margin-top:0}.sm\\:rf-flex-row{flex-direction:row}.sm\\:rf-justify-end{justify-content:flex-end}.sm\\:rf-space-x-2>:not([hidden])~:not([hidden]){--tw-space-x-reverse:0;margin-left:calc(.5rem*(1 - var(--tw-space-x-reverse)));margin-right:calc(.5rem*var(--tw-space-x-reverse))}.sm\\:rf-rounded-lg{border-radius:var(--radius)}.sm\\:rf-text-left{text-align:left}}@media (min-width:768px){.md\\:rf-grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}}.\\[\\&\\>span\\]\\:rf-line-clamp-1>span{display:-webkit-box;overflow:hidden;-webkit-box-orient:vertical;-webkit-line-clamp:1}.\\[\\&\\>svg\\]\\:rf-size-4>svg{height:1rem;width:1rem}.\\[\\&\\>svg\\]\\:rf-shrink-0>svg{flex-shrink:0}.\\[\\&\\>svg\\]\\:rf-text-red-300>svg{--tw-text-opacity:1;color:rgb(252 165 165/var(--tw-text-opacity,1))}.\\[\\&\\>svg\\]\\:hover\\:rf-text-red-400:hover>svg{--tw-text-opacity:1;color:rgb(248 113 113/var(--tw-text-opacity,1))}.\\[\\&_svg\\]\\:rf-pointer-events-none svg{pointer-events:none}.\\[\\&_svg\\]\\:rf-size-4 svg{height:1rem;width:1rem}.\\[\\&_svg\\]\\:rf-shrink-0 svg{flex-shrink:0}',hfn=()=>{mt.useEffect(()=>{if(document.querySelector('style[data-styles="tscircuit-runframe"]'))return;const e=document.createElement("style");e.setAttribute("data-styles","tscircuit-runframe"),e.textContent=pfn,document.head.appendChild(e)},[])};var mfn=R.enum(["up","down","left","right"]);R.enum(["top-to-bottom","left-to-right","bottom-to-top","right-to-left"]);var y6=R.array(R.string().or(R.number())),YYe=R.object({x:ci,y:ci,z:ci}),vfn=R.object({x:R.union([R.number(),R.string()]),y:R.union([R.number(),R.string()]),z:R.union([R.number(),R.string()])}),Dfe=R.object({rotationOffset:R.number().or(vfn).optional(),positionOffset:YYe.optional(),size:YYe.optional()}),yfn=Dfe.extend({stlUrl:R.string()}),gfn=Dfe.extend({objUrl:R.string(),mtlUrl:R.string().optional()}),_fn=Dfe.extend({jscad:R.record(R.any())}),xfn=R.union([R.string(),yfn,gfn,_fn]),bfn=R.custom(r=>!0),Ax=R.object({pcbX:ci.optional(),pcbY:ci.optional(),pcbRotation:Yb.optional(),layer:t9.optional()}),dj=R.object({pcbX:ci.optional(),pcbY:ci.optional(),pcbRotation:Yb.optional(),schX:ci.optional(),schY:ci.optional(),schRotation:Yb.optional(),layer:t9.optional(),footprint:bfn.optional()}),Sfn=R.object({supplierPartNumbers:R.record(gH,R.array(R.string())).optional()}),q5=dj.merge(Sfn).extend({key:R.any().optional(),name:R.string(),cadModel:xfn.optional(),children:R.any().optional(),symbolName:R.string().optional()});ci.or(R.enum(["2x","3x","4x"]));var pj=R.object({pins:R.array(R.union([R.number(),R.string()])),direction:R.union([R.literal("top-to-bottom"),R.literal("left-to-right"),R.literal("bottom-to-top"),R.literal("right-to-left")])}),Lfe=R.object({leftSize:R.number().optional().describe("@deprecated, use leftPinCount"),topSize:R.number().optional().describe("@deprecated, use topPinCount"),rightSize:R.number().optional().describe("@deprecated, use rightPinCount"),bottomSize:R.number().optional().describe("@deprecated, use bottomPinCount"),leftPinCount:R.number().optional(),rightPinCount:R.number().optional(),topPinCount:R.number().optional(),bottomPinCount:R.number().optional(),leftSide:pj.optional(),rightSide:pj.optional(),topSide:pj.optional(),bottomSide:pj.optional()}),XYe=R.record(R.object({marginLeft:ci.optional(),marginRight:ci.optional(),marginTop:ci.optional(),marginBottom:ci.optional(),leftMargin:ci.optional(),rightMargin:ci.optional(),topMargin:ci.optional(),bottomMargin:ci.optional()})),WYe=R.object({x:ci,y:ci}),Ofe=R.object({edit_event_id:R.string(),in_progress:R.boolean().optional(),created_at:R.number()}),wfn=Ofe.extend({pcb_edit_event_type:R.literal("edit_component_location").describe("deprecated"),edit_event_type:R.literal("edit_pcb_component_location"),pcb_component_id:R.string(),original_center:R.object({x:R.number(),y:R.number()}),new_center:R.object({x:R.number(),y:R.number()})}),Efn=Ofe.extend({pcb_edit_event_type:R.literal("edit_trace_hint").describe("deprecated"),edit_event_type:R.literal("edit_pcb_trace_hint").optional(),pcb_port_id:R.string(),pcb_trace_hint_id:R.string().optional(),route:R.array(R.object({x:R.number(),y:R.number(),via:R.boolean().optional()}))}),Tfn=Ofe.extend({edit_event_type:R.literal("edit_schematic_component_location"),schematic_component_id:R.string(),original_center:R.object({x:R.number(),y:R.number()}),new_center:R.object({x:R.number(),y:R.number()})});R.union([wfn,Efn,Tfn]);var Mfn=R.object({selector:R.string(),relative_to:R.string().optional().default("group_center").describe("Can be a selector or 'group_center'"),center:av}),Cfn=R.object({pcb_port_selector:R.string(),offsets:R.array(x8)}),Rfn=R.object({selector:R.string(),relative_to:R.string().optional().default("group_center").describe("Can be a selector or 'group_center'"),center:av}),Afn=R.object({pcb_placements:R.array(Mfn).optional(),manual_trace_hints:R.array(Cfn).optional(),schematic_placements:R.array(Rfn).optional()}),zfe=R.object({layoutMode:R.enum(["grid","flex","none"]).optional(),position:R.enum(["absolute","relative"]).optional(),grid:R.boolean().optional(),gridCols:R.number().or(R.string()).optional(),gridRows:R.number().or(R.string()).optional(),gridTemplateRows:R.string().optional(),gridTemplateColumns:R.string().optional(),gridTemplate:R.string().optional(),gridGap:R.number().or(R.string()).optional(),flex:R.boolean().or(R.string()).optional(),flexDirection:R.enum(["row","column"]).optional(),alignItems:R.enum(["start","center","end","stretch"]).optional(),justifyContent:R.enum(["start","center","end","stretch"]).optional(),flexRow:R.boolean().optional(),flexColumn:R.boolean().optional(),gap:R.number().or(R.string()).optional()}),Pfn=R.object({serverUrl:R.string().optional(),inputFormat:R.enum(["simplified","circuit-json"]).optional(),serverMode:R.enum(["job","solve-endpoint"]).optional(),serverCacheEnabled:R.boolean().optional(),cache:R.custom(r=>!0).optional(),groupMode:R.enum(["sequential-trace","subcircuit"]).optional(),algorithmFn:R.custom(r=>typeof r=="function"||r===void 0).optional(),local:R.boolean().optional()}),ZYe=R.union([Pfn,R.literal("sequential-trace"),R.literal("subcircuit"),R.literal("auto"),R.literal("auto-local"),R.literal("auto-cloud")]),QYe=dj.extend({name:R.string().optional(),children:R.any().optional(),key:R.any().optional(),...zfe.shape,pcbWidth:mr.optional(),pcbHeight:mr.optional(),schWidth:mr.optional(),schHeight:mr.optional(),pcbLayout:zfe.optional(),schLayout:zfe.optional()}),KYe=R.custom(r=>"findPart"in r),JYe=QYe.extend({layout:R.custom(r=>!0).optional(),manualEdits:Afn.optional(),schAutoLayoutEnabled:R.boolean().optional(),schTraceAutoLabelEnabled:R.boolean().optional(),routingDisabled:R.boolean().optional(),defaultTraceWidth:mr.optional(),minTraceWidth:mr.optional(),partsEngine:KYe.optional(),pcbRouteCache:R.custom(r=>!0).optional(),autorouter:ZYe.optional()}),Nfn=JYe.extend({subcircuit:R.literal(!0)}),Dfn=R.discriminatedUnion("subcircuit",[QYe.extend({subcircuit:R.literal(!1).optional()}),Nfn]),eXe=JYe.extend({width:ci.optional(),height:ci.optional(),outline:R.array(WYe).optional(),outlineOffsetX:ci.optional(),outlineOffsetY:ci.optional(),material:R.enum(["fr4","fr1"]).default("fr4")}),Lfn=R.string().or(R.array(R.string()).readonly()).or(R.array(R.string())),Ofn=R.custom().pipe(R.record(R.string(),Lfn)),zfn=R.record(R.string(),R.string().or(R.array(R.string()).readonly()).or(R.array(R.string()))),tXe=q5.extend({manufacturerPartNumber:R.string().optional(),pinLabels:zfn.optional(),internallyConnectedPins:R.array(R.array(R.string())).optional(),externallyConnectedPins:R.array(R.array(R.string())).optional(),schPinArrangement:Lfe.optional(),schPortArrangement:Lfe.optional(),schPinStyle:XYe.optional(),schPinSpacing:ci.optional(),schWidth:ci.optional(),schHeight:ci.optional(),noSchematicRepresentation:R.boolean().optional(),connections:Ofn.optional()}),Ufn=q5.extend({manufacturerPartNumber:R.string().optional(),pinLabels:R.record(R.number().or(R.string()),R.string().or(R.array(R.string()))).optional(),schPinStyle:XYe.optional(),schPinSpacing:ci.optional(),schWidth:ci.optional(),schHeight:ci.optional(),schDirection:R.enum(["left","right"]).optional(),schPortArrangement:Lfe.optional(),pinCount:R.union([R.literal(2),R.literal(3)]).optional(),internallyConnectedPins:R.array(R.array(R.string())).optional()}),hj=R.custom().transform(r=>{if(r!==void 0)return ci.parse(r)}),Ifn=R.union([Ax.omit({pcbRotation:!0,layer:!0}).extend({name:R.string().optional(),shape:R.literal("circle"),holeDiameter:ci,outerDiameter:ci,portHints:y6.optional()}),Ax.omit({pcbRotation:!0,layer:!0}).extend({name:R.string().optional(),shape:R.literal("oval"),outerWidth:ci,outerHeight:ci,holeWidth:hj,holeHeight:hj,innerWidth:ci.optional().describe("DEPRECATED use holeWidth"),innerHeight:ci.optional().describe("DEPRECATED use holeHeight"),portHints:y6.optional()}),Ax.omit({pcbRotation:!0,layer:!0}).extend({name:R.string().optional(),shape:R.literal("pill"),outerWidth:ci,outerHeight:ci,holeWidth:hj,holeHeight:hj,innerWidth:ci.optional().describe("DEPRECATED use holeWidth"),innerHeight:ci.optional().describe("DEPRECATED use holeHeight"),portHints:y6.optional()}),Ax.omit({pcbRotation:!0,layer:!0}).extend({name:R.string().optional(),holeDiameter:ci,rectPadWidth:ci,rectPadHeight:ci,holeShape:R.literal("circle").optional(),padShape:R.literal("rect").optional(),shape:R.literal("circularHoleWithRectPad").optional(),portHints:y6.optional()}).refine(r=>r.shape==="circularHoleWithRectPad"?r.holeDiameter&&r.rectPadWidth&&r.rectPadHeight:!0,{message:"Missing required fields for circularHoleWithRectPad"})]).refine(r=>("innerWidth"in r&&r.innerWidth!==void 0&&(r.holeWidth??(r.holeWidth=r.innerWidth)),"innerHeight"in r&&r.innerHeight!==void 0&&(r.holeHeight??(r.holeHeight=r.innerHeight)),r)),kfn=R.string().or(R.array(R.string()).readonly()).or(R.array(R.string())),nXe=r=>R.record(R.enum(r),kfn),Ffn=["pin1","pin2","pos","neg"],Bfn=q5.extend({resistance:Pw,pullupFor:R.string().optional(),pullupTo:R.string().optional(),pulldownFor:R.string().optional(),pulldownTo:R.string().optional(),connections:nXe(Ffn).optional()}),jfn=q5.extend({maxResistance:Pw,pinVariant:R.enum(["two_pin","three_pin"]).optional()}),Hfn=q5.extend({frequency:nN,loadCapacitance:Nw,pinVariant:R.enum(["two_pin","four_pin"]).optional()}),Vfn=q5.extend({frequency:nN,loadCapacitance:Nw,pinVariant:R.enum(["no_ground","ground_pin","two_ground_pins"]).optional()});eXe.extend({leftPinCount:R.number().optional(),rightPinCount:R.number().optional(),topPinCount:R.number().optional(),bottomPinCount:R.number().optional(),leftPins:R.array(R.string()).optional(),rightPins:R.array(R.string()).optional(),topPins:R.array(R.string()).optional(),bottomPins:R.array(R.string()).optional(),pinPitch:ci.optional(),innerHoles:R.boolean().optional()});var $fn=["pin1","pin2","pos","neg","anode","cathode"],Gfn=q5.extend({capacitance:Nw,maxVoltageRating:Dw.optional(),schShowRatings:R.boolean().optional().default(!1),polarized:R.boolean().optional().default(!1),decouplingFor:R.string().optional(),decouplingTo:R.string().optional(),bypassFor:R.string().optional(),bypassTo:R.string().optional(),maxDecouplingTraceLength:R.number().optional(),connections:nXe($fn).optional()});R.object({name:R.string()}),R.object({name:R.string().optional(),pcbOnly:R.boolean().optional(),schOnly:R.boolean().optional()});var qfn=R.object({pcb:R.literal(!0).optional(),xDist:ci,left:R.string(),right:R.string(),edgeToEdge:R.literal(!0).optional(),centerToCenter:R.literal(!0).optional()}),Yfn=R.object({pcb:R.literal(!0).optional(),yDist:ci,top:R.string(),bottom:R.string(),edgeToEdge:R.literal(!0).optional(),centerToCenter:R.literal(!0).optional()}),Xfn=R.object({pcb:R.literal(!0).optional(),sameY:R.literal(!0).optional(),for:R.array(R.string())}),Wfn=R.object({pcb:R.literal(!0).optional(),sameX:R.literal(!0).optional(),for:R.array(R.string())}),Zfn=R.union([qfn,Yfn,Xfn,Wfn]),Qfn=Ax.omit({pcbRotation:!0}).extend({shape:R.literal("rect"),width:ci,height:ci,portHints:y6.optional()}),Kfn=Ax.omit({pcbRotation:!0}).extend({shape:R.literal("rotated_rect"),width:ci,height:ci,ccwRotation:R.number(),portHints:y6.optional()}),Jfn=Ax.omit({pcbRotation:!0}).extend({shape:R.literal("circle"),radius:ci,portHints:y6.optional()}),edn=Ax.omit({pcbRotation:!0}).extend({shape:R.literal("pill"),width:ci,height:ci,radius:ci,portHints:y6.optional()}),tdn=R.union([Jfn,Qfn,Kfn,edn]),ndn=Ax.omit({pcbRotation:!0}).extend({shape:R.literal("rect"),width:ci,height:ci}),rdn=Ax.omit({pcbRotation:!0}).extend({shape:R.literal("circle"),radius:ci});R.union([rdn,ndn]);var idn=Ax.omit({pcbRotation:!0}).extend({name:R.string().optional(),diameter:ci.optional(),radius:ci.optional()}).transform(r=>({...r,diameter:r.diameter??2*r.radius,radius:r.radius??r.diameter/2})),Ufe=R.union([R.string(),R.custom(r=>!!r.getPortSelector)]),rXe=R.object({key:R.string().optional(),thickness:ci.optional(),schematicRouteHints:R.array(WYe).optional(),pcbRouteHints:R.array(x8).optional(),schDisplayLabel:R.string().optional(),maxLength:ci.optional()}),adn=R.union([rXe.extend({path:R.array(Ufe)}),rXe.extend({from:Ufe,to:Ufe})]),odn=R.object({originalLayer:t9.default("top").optional()}),sdn=R.number().or(R.string().endsWith("mAh")).transform(r=>{if(typeof r=="string"){const e=r.replace("mAh",""),t=Number.parseFloat(e);if(Number.isNaN(t))throw new Error("Invalid capacity");return t}return r}).describe("Battery capacity in mAh"),ldn=q5.extend({capacity:sdn.optional()}),cdn=q5.extend({pinCount:R.number(),pitch:ci.optional(),schFacingDirection:R.enum(["up","down","left","right"]).optional(),gender:R.enum(["male","female"]).optional().default("male"),showSilkscreenPinLabels:R.boolean().optional(),doubleRow:R.boolean().optional(),holeDiameter:ci.optional(),platedDiameter:ci.optional(),pinLabels:R.array(R.string()).optional(),facingDirection:R.enum(["left","right"]).optional()}),udn=R.object({net:R.string().optional(),schX:ci.optional(),schY:ci.optional(),schRotation:Yb.optional(),anchorSide:R.enum(["left","up","right","down"]).optional()}),fdn=tXe.extend({}),ddn=q5.extend({type:R.enum(["npn","pnp","bjt","jfet","mosfet"])}),pdn=q5.extend({channelType:R.enum(["n","p"]),mosfetMode:R.enum(["enhancement","depletion"])}),hdn=q5.extend({inductance:vH}),mdn=R.enum(["anode","cathode","pin1","pin2","pos","neg"]),vdn=R.string().or(R.array(R.string()).readonly()).or(R.array(R.string())),ydn=R.record(mdn,vdn),gdn=R.enum(["standard","schottky","zener","photo","tvs"]),_dn=q5.extend({connections:ydn.optional(),variant:gdn.optional().default("standard"),standard:R.boolean().optional(),schottky:R.boolean().optional(),zener:R.boolean().optional(),photo:R.boolean().optional(),tvs:R.boolean().optional()}).superRefine((r,e)=>{if([r.standard,r.schottky,r.zener,r.photo,r.tvs].filter(Boolean).length>1)return e.addIssue({code:R.ZodIssueCode.custom,message:"Exactly one diode variant must be enabled",path:[]}),R.INVALID}).transform(r=>{const e={...r,standard:!1,schottky:!1,zener:!1,photo:!1,tvs:!1};if(r.standard)e.standard=!0;else if(r.schottky)e.schottky=!0;else if(r.zener)e.zener=!0;else if(r.photo)e.photo=!0;else if(r.tvs)e.tvs=!0;else switch(r.variant){case"standard":e.standard=!0;break;case"schottky":e.schottky=!0;break;case"zener":e.zener=!0;break;case"photo":e.photo=!0;break;case"tvs":e.tvs=!0;break;default:e.standard=!0}return e}),xdn=q5.extend({color:R.string().optional()}),bdn=q5.extend({type:R.enum(["spst","spdt","dpst","dpdt"]).optional(),isNormallyClosed:R.boolean().optional().default(!1),spst:R.boolean().optional(),spdt:R.boolean().optional(),dpst:R.boolean().optional(),dpdt:R.boolean().optional()}).transform(r=>{const e={...r};switch(e.dpdt?e.type="dpdt":e.spst?e.type="spst":e.spdt?e.type="spdt":e.dpst&&(e.type="dpst"),e.type){case"spdt":e.spdt=!0;break;case"spst":e.spst=!0;break;case"dpst":e.dpst=!0;break;case"dpdt":e.dpdt=!0;break}return e}),Sdn=Ax.extend({text:R.string(),anchorAlignment:R.enum(["center","top_left","top_right","bottom_left","bottom_right"]).default("center"),font:R.enum(["tscircuit2024"]).optional(),fontSize:mr.optional(),color:R.string().optional()}),wdn=Ax.omit({pcbX:!0,pcbY:!0,pcbRotation:!0}).extend({route:R.array(x8),strokeWidth:mr.optional(),color:R.string().optional()});R.object({layer:R.string().optional(),thickness:ci.optional(),route:R.array(x8)});var Edn=dj.extend({fromLayer:t9,toLayer:t9,holeDiameter:ci,outerDiameter:ci}),Tdn=R.union([Ax.omit({pcbRotation:!0}).extend({shape:R.literal("circle"),radius:ci}),Ax.extend({shape:R.literal("rect"),width:ci,height:ci})]),Mdn=q5.extend({voltage:Dw});R.object({schX:ci,schY:ci,width:ci,height:ci}),R.object({x1:ci,y1:ci,x2:ci,y2:ci});var Cdn=R.enum(["top_left","top_center","top_right","center_left","center","center_right","bottom_left","bottom_center","bottom_right"]),Rdn=R.enum(["center","left","right","top","bottom"]),Adn=R.object({schX:ci,schY:ci,text:R.string(),anchor:R.union([Rdn.describe("legacy"),Cdn]),color:R.string().default("#000000"),schRotation:Yb.default(0)});R.object({points:R.array(av),isFilled:R.boolean().optional().default(!1),fillColor:R.enum(["red","blue"]).optional()});var Pdn=Ax.extend({text:R.string(),anchorAlignment:R.enum(["center","top_left","top_right","bottom_left","bottom_right"]).default("center"),font:R.enum(["tscircuit2024"]).optional(),fontSize:mr.optional()}),Ndn=Ax.omit({pcbX:!0,pcbY:!0,pcbRotation:!0}).extend({route:R.array(x8),strokeWidth:mr.optional()}),Ddn=Ax.omit({pcbX:!0,pcbY:!0,pcbRotation:!0}).extend({strokeWidth:ci,x1:ci,y1:ci,x2:ci,y2:ci}),Ldn=Ax.omit({pcbRotation:!0}).extend({isFilled:R.boolean().optional(),isOutline:R.boolean().optional(),strokeWidth:ci.optional(),width:ci,height:ci}),Odn=Ax.omit({pcbRotation:!0}).extend({isFilled:R.boolean().optional(),isOutline:R.boolean().optional(),strokeWidth:ci.optional(),radius:ci}),iXe=R.object({x:ci,y:ci,via:R.boolean().optional(),toLayer:t9.optional()}),zdn=R.object({for:R.string().optional().describe("Selector for the port you're targeting, not required if you're inside a trace"),order:R.number().optional(),offset:x8.or(iXe).optional(),offsets:R.array(x8).or(R.array(iXe)).optional(),traceWidth:R.number().optional()});dj.extend({name:R.string(),pinNumber:R.number().optional(),aliases:R.array(R.string()).optional(),direction:mfn}),R.object({partsEngine:KYe.optional(),autorouter:ZYe.optional(),registryApiUrl:R.string().optional(),cloudAutorouterUrl:R.string().optional()});var Udn=class{constructor({objects:r,getBounds:e,getId:t,CELL_SIZE:n}){Qe(this,"buckets");Qe(this,"objectsById");Qe(this,"getBounds");Qe(this,"getId");Qe(this,"CELL_SIZE",.4);Qe(this,"_idCounter",0);this.buckets=new Map,this.objectsById=new Map,this.getBounds=e,this.getId=t??(()=>this._getNextId()),this.CELL_SIZE=n??this.CELL_SIZE;for(const i of r)this.addObject(i)}_getNextId(){return`${this._idCounter++}`}addObject(r){const e=this.getBounds(r),t=this.getId(r),n={...r,spatialIndexId:t};this.objectsById.set(t,n);const i=Math.floor(e.minX/this.CELL_SIZE),a=Math.floor(e.minY/this.CELL_SIZE),o=Math.floor(e.maxX/this.CELL_SIZE),s=Math.floor(e.maxY/this.CELL_SIZE);for(let l=i;l<=o;l++)for(let c=a;c<=s;c++){const u=`${l}x${c}`,f=this.buckets.get(u);f?f.push(n):this.buckets.set(u,[n])}}removeObject(r){const e=this.objectsById.get(r);if(!e)return!1;this.objectsById.delete(r);const t=this.getBounds(e),n=Math.floor(t.minX/this.CELL_SIZE),i=Math.floor(t.minY/this.CELL_SIZE),a=Math.floor(t.maxX/this.CELL_SIZE),o=Math.floor(t.maxY/this.CELL_SIZE);for(let s=n;s<=a;s++)for(let l=i;l<=o;l++){const c=`${s}x${l}`,u=this.buckets.get(c);if(u){const f=u.findIndex(p=>p.spatialIndexId===r);f!==-1&&(u.splice(f,1),u.length===0&&this.buckets.delete(c))}}return!0}getBucketKey(r,e){return`${Math.floor(r/this.CELL_SIZE)}x${Math.floor(e/this.CELL_SIZE)}`}getObjectsInBounds(r,e=0){const t=[],n=new Set,i=Math.floor((r.minX-e)/this.CELL_SIZE),a=Math.floor((r.minY-e)/this.CELL_SIZE),o=Math.floor((r.maxX+e)/this.CELL_SIZE),s=Math.floor((r.maxY+e)/this.CELL_SIZE);for(let l=i;l<=o;l++)for(let c=a;c<=s;c++){const u=`${l}x${c}`,f=this.buckets.get(u)||[];for(const p of f){const v=p.spatialIndexId;n.has(v)||(n.add(v),t.push(p))}}return t}},mP=r=>r.type==="pcb_trace_segment"?{minX:Math.min(r.x1,r.x2),minY:Math.min(r.y1,r.y2),maxX:Math.max(r.x1,r.x2),maxY:Math.max(r.y1,r.y2)}:Pq([r]),Ife=.1,Idn=.15,kfe=.005;function kdn(r){const e=new Set;for(const t of r.route)t.route_type==="wire"&&(t.start_pcb_port_id&&e.add(t.start_pcb_port_id),t.end_pcb_port_id&&e.add(t.end_pcb_port_id));return Array.from(e)}function Ffe(r){const e=new Set;for(const t of r)for(const n of kdn(t))e.add(n);return Array.from(e)}var Fdn=(r,e)=>{const t={x:r.x1,y:r.y1},n={x:r.x2,y:r.y2},i={x:e.x1,y:e.y1},a={x:e.x2,y:e.y2},o={x:n.x-t.x,y:n.y-t.y},s={x:a.x-i.x,y:a.y-i.y},l=o.x*o.x+o.y*o.y,c=s.x*s.x+s.y*s.y;if(l===0||c===0){if(l===0&&c===0)return{x:(t.x+i.x)/2,y:(t.y+i.y)/2};if(l===0){const W=c8(((t.x-i.x)*s.x+(t.y-i.y)*s.y)/c,0,1),te={x:i.x+W*s.x,y:i.y+W*s.y};return{x:(t.x+te.x)/2,y:(t.y+te.y)/2}}const Y=c8(((i.x-t.x)*o.x+(i.y-t.y)*o.y)/l,0,1),Z={x:t.x+Y*o.x,y:t.y+Y*o.y};return{x:(Z.x+i.x)/2,y:(Z.y+i.y)/2}}const u={x:t.x-i.x,y:t.y-i.y},f=o.x*o.x+o.y*o.y,p=o.x*s.x+o.y*s.y,v=o.x*u.x+o.y*u.y,x=s.x*s.x+s.y*s.y,S=s.x*u.x+s.y*u.y,w=f*x-p*p;if(w<1e-10)return Bdn(t,n,i,a,o,s,l,c);let b=(p*S-x*v)/w,C=(f*S-p*v)/w;b=c8(b,0,1),C=c8(C,0,1),C=(b*p+S)/x,C=c8(C,0,1),b=(C*p-v)/f,b=c8(b,0,1);const z={x:t.x+b*o.x,y:t.y+b*o.y},I={x:i.x+C*s.x,y:i.y+C*s.y};return{x:(z.x+I.x)/2,y:(z.y+I.y)/2}},Bdn=(r,e,t,n,i,a,o,s)=>{let l=((t.x-r.x)*i.x+(t.y-r.y)*i.y)/o;l=c8(l,0,1);const c={x:r.x+l*i.x,y:r.y+l*i.y};let u=((n.x-r.x)*i.x+(n.y-r.y)*i.y)/o;u=c8(u,0,1);const f={x:r.x+u*i.x,y:r.y+u*i.y};let p=((r.x-t.x)*a.x+(r.y-t.y)*a.y)/s;p=c8(p,0,1);const v={x:t.x+p*a.x,y:t.y+p*a.y};let x=((e.x-t.x)*a.x+(e.y-t.y)*a.y)/s;x=c8(x,0,1);const S={x:t.x+x*a.x,y:t.y+x*a.y},b=[{pointA:c,pointB:t,distance:Math.sqrt((c.x-t.x)**2+(c.y-t.y)**2)},{pointA:f,pointB:n,distance:Math.sqrt((f.x-n.x)**2+(f.y-n.y)**2)},{pointA:r,pointB:v,distance:Math.sqrt((r.x-v.x)**2+(r.y-v.y)**2)},{pointA:e,pointB:S,distance:Math.sqrt((e.x-S.x)**2+(e.y-S.y)**2)}].reduce((C,z)=>z.distance<C.distance?z:C);return{x:(b.pointA.x+b.pointB.x)/2,y:(b.pointA.y+b.pointB.y)/2}},c8=(r,e,t)=>Math.max(e,Math.min(t,r)),jdn=r=>{if(r.type==="pcb_via"||r.type==="pcb_plated_hole"&&r.shape==="circle")return r.outer_diameter/2;if(r.type==="pcb_hole"&&r.hole_shape==="circle")return r.hole_diameter/2;if(r.type==="pcb_smtpad"&&r.shape==="circle")return r.radius;throw new Error(`Could not determine radius of element: ${JSON.stringify(r)}`)},aXe=(r,e)=>{const t={x:r.x1,y:r.y1},n={x:r.x2,y:r.y2},i=e.minX,a=e.minY,o=e.maxX,s=e.maxY;if(t.x===n.x&&t.y===n.y){const W=Math.max(i,Math.min(o,t.x)),te=Math.max(a,Math.min(s,t.y));return W===t.x&&te===t.y?{x:t.x,y:t.y}:{x:W,y:te}}const l=n.x-t.x,c=n.y-t.y,u=l!==0?(i-t.x)/l:Number.NEGATIVE_INFINITY,f=l!==0?(o-t.x)/l:Number.POSITIVE_INFINITY,p=c!==0?(a-t.y)/c:Number.NEGATIVE_INFINITY,v=c!==0?(s-t.y)/c:Number.POSITIVE_INFINITY,x=Math.max(Math.min(u,f),Math.min(p,v)),S=Math.min(Math.max(u,f),Math.max(p,v));if(x<=S&&S>=0&&x<=1){const W=Math.max(0,Math.min(1,x));return{x:t.x+W*l,y:t.y+W*c}}const w={x:Math.max(i,Math.min(o,t.x)),y:Math.max(a,Math.min(s,t.y))},b={x:Math.max(i,Math.min(o,n.x)),y:Math.max(a,Math.min(s,n.y))},C=(w.x-t.x)**2+(w.y-t.y)**2,z=(b.x-n.x)**2+(b.y-n.y)**2,I=[{start:{x:i,y:a},end:{x:o,y:a}},{start:{x:o,y:a},end:{x:o,y:s}},{start:{x:o,y:s},end:{x:i,y:s}},{start:{x:i,y:s},end:{x:i,y:a}}];let G=Math.min(C,z),Y=C<=z?w:b;const Z=(W,te,J)=>Math.max(te,Math.min(J,W));for(const W of I){const te={x:n.x-t.x,y:n.y-t.y},J={x:W.end.x-W.start.x,y:W.end.y-W.start.y},fe={x:t.x-W.start.x,y:t.y-W.start.y},he=te.x*te.x+te.y*te.y,ve=te.x*J.x+te.y*J.y,Te=te.x*fe.x+te.y*fe.y,Pe=J.x*J.x+J.y*J.y,we=J.x*fe.x+J.y*fe.y,Ce=he*Pe-ve*ve;if(Math.abs(Ce)<1e-10)continue;let be=(ve*we-Pe*Te)/Ce,Le=(he*we-ve*Te)/Ce;be=Z(be,0,1),Le=Z(Le,0,1);const Ue={x:t.x+be*te.x,y:t.y+be*te.y},Ie={x:W.start.x+Le*J.x,y:W.start.y+Le*J.y},ke=Ue.x-Ie.x,at=Ue.y-Ie.y,nt=ke*ke+at*at;nt<G&&(G=nt,Y={x:(Ue.x+Ie.x)/2,y:(Ue.y+Ie.y)/2})}return Y};function Hdn(r){return r.type==="pcb_trace_segment"?[r.layer]:r.type==="pcb_smtpad"?[r.layer]:r.type==="pcb_plated_hole"?Array.isArray(r.layers)?r.layers:[...EM]:r.type==="pcb_hole"?[...EM]:r.type==="pcb_via"?Array.isArray(r.layers)?r.layers:[...EM]:r.type==="pcb_keepout"?Array.isArray(r.layers)?r.layers:[]:[]}function Vdn(r,{connMap:e}={}){const t=[];e??(e=M8(r));const i=k2(r).pcb_trace.list().flatMap(x=>{const S=[];for(let w=0;w<x.route.length-1;w++){const b=x.route[w],C=x.route[w+1];b.route_type==="wire"&&C.route_type==="wire"&&b.layer===C.layer&&S.push({type:"pcb_trace_segment",pcb_trace_id:x.pcb_trace_id,_pcbTrace:x,thickness:"width"in b?b.width:"width"in C?C.width:Idn,layer:b.layer,x1:b.x,y1:b.y,x2:C.x,y2:C.y})}return S}),a=k2(r).pcb_smtpad.list(),o=k2(r).pcb_plated_hole.list(),s=k2(r).pcb_hole.list(),l=k2(r).pcb_via.list(),c=k2(r).pcb_keepout.list(),u=[...i,...a,...o,...s,...l,...c],f=new Udn({objects:u,getBounds:mP}),p=x=>cL(r,x),v=new Set;for(const x of i){const S=Ife,w=mP(x),b=f.getObjectsInBounds(w,S+x.thickness/2);if(!(x.x1===x.x2&&x.y1===x.y2))for(const C of b){if(!Hdn(C).includes(x.layer))continue;if(C.type==="pcb_trace_segment"){const Y=C;if(x.layer!==Y.layer||e.areIdsConnected(x.pcb_trace_id,Y.pcb_trace_id))continue;const Z=wcn({x:x.x1,y:x.y1},{x:x.x2,y:x.y2},{x:Y.x1,y:Y.y1},{x:Y.x2,y:Y.y2})-x.thickness/2-Y.thickness/2;if(Z>Ife-kfe)continue;const W=`overlap_${x.pcb_trace_id}_${Y.pcb_trace_id}`,te=`overlap_${Y.pcb_trace_id}_${x.pcb_trace_id}`;if(v.has(W)||v.has(te))continue;v.add(W),t.push({type:"pcb_trace_error",error_type:"pcb_trace_error",message:`PCB trace ${p(x.pcb_trace_id)} overlaps with ${p(Y.pcb_trace_id)} ${Z<0?"(accidental contact)":`(gap: ${Z.toFixed(3)}mm)`}`,pcb_trace_id:x.pcb_trace_id,source_trace_id:"",pcb_trace_error_id:W,pcb_component_ids:[],center:Fdn(x,Y),pcb_port_ids:Ffe([x._pcbTrace,Y._pcbTrace])});continue}const z=R8(C);if(e.areIdsConnected(x.pcb_trace_id,"pcb_trace_id"in C?C.pcb_trace_id:z))continue;if(C.type==="pcb_via"||C.type==="pcb_plated_hole"&&C.shape==="circle"||C.type==="pcb_hole"||C.type==="pcb_smtpad"&&C.shape==="circle"){const Y=jdn(C),W=Tcn({x:x.x1,y:x.y1},{x:x.x2,y:x.y2},{x:C.x,y:C.y,radius:Y})-x.thickness/2;if(W>Ife-kfe)continue;const te=`overlap_${x.pcb_trace_id}_${z}`;if(v.has(te))continue;v.add(te),t.push({type:"pcb_trace_error",error_type:"pcb_trace_error",message:`PCB trace ${p(x.pcb_trace_id)} overlaps with ${C.type} "${p(R8(C))}" ${W<0?"(accidental contact)":`(gap: ${W.toFixed(3)}mm)`}`,pcb_trace_id:x.pcb_trace_id,center:aXe(x,mP(C)),source_trace_id:"",pcb_trace_error_id:te,pcb_component_ids:["pcb_component_id"in C?C.pcb_component_id:void 0].filter(Boolean),pcb_port_ids:[...Ffe([x._pcbTrace]),"pcb_port_id"in C?C.pcb_port_id:void 0].filter(Boolean)})}const G=Ecn({x:x.x1,y:x.y1},{x:x.x2,y:x.y2},mP(C))-x.thickness/2;if(G+kfe<S){const Y=`overlap_${x.pcb_trace_id}_${z}`;if(v.has(Y))continue;v.add(Y),t.push({type:"pcb_trace_error",error_type:"pcb_trace_error",message:`PCB trace ${p(x.pcb_trace_id)} overlaps with ${C.type} "${p(R8(C))}" ${G<0?"(accidental contact)":`(gap: ${G.toFixed(3)}mm)`}`,pcb_trace_id:x.pcb_trace_id,source_trace_id:"",pcb_trace_error_id:Y,pcb_component_ids:["pcb_component_id"in C?C.pcb_component_id:void 0].filter(Boolean),center:aXe(x,mP(C)),pcb_port_ids:[...Ffe([x._pcbTrace]),"pcb_port_id"in C?C.pcb_port_id:void 0].filter(Boolean)})}}}return t}var $dn=Object.defineProperty,Gdn=(r,e)=>{for(var t in e)$dn(r,t,{get:e[t],enumerable:!0})},oXe={};Gdn(oXe,{Battery:()=>ehn,Board:()=>Upn,Capacitor:()=>kpn,Chip:()=>CXe,Constraint:()=>Gpn,Crystal:()=>lhn,Diode:()=>Fpn,FabricationNotePath:()=>qpn,FabricationNoteText:()=>Ypn,Footprint:()=>dpn,Group:()=>Wfe,Hole:()=>gXe,Inductor:()=>ihn,Jumper:()=>Bpn,Keepout:()=>$fe,Led:()=>jpn,Mosfet:()=>uhn,Net:()=>pXe,NetAlias:()=>Wpn,NormalComponent:()=>r2,PcbTrace:()=>vXe,PinHeader:()=>thn,PlatedHole:()=>yXe,Port:()=>dS,Potentiometer:()=>ohn,PowerSource:()=>Hpn,PrimitiveComponent:()=>Jg,PushButton:()=>shn,Renderable:()=>sXe,Resistor:()=>Vpn,Resonator:()=>rhn,SchematicText:()=>dhn,SilkscreenCircle:()=>Zpn,SilkscreenLine:()=>Kpn,SilkscreenPath:()=>mXe,SilkscreenRect:()=>Qpn,SilkscreenText:()=>Gfe,SmtPad:()=>Vfe,Subcircuit:()=>Xpn,Switch:()=>fhn,Trace:()=>cw,TraceHint:()=>TXe,Transistor:()=>chn,Via:()=>Jpn});var qdn=P9("tscircuit:renderable"),Ub=["ReactSubtreesRender","InitializePortsFromChildren","CreateNetsFromProps","CreateTracesFromProps","CreateTraceHintsFromProps","SourceRender","SourceParentAttachment","PortMatching","OptimizeSelectorCache","SourceTraceRender","SourceAddConnectivityMapKey","SchematicComponentRender","SchematicPrimitiveRender","SchematicPortRender","SchematicLayout","SchematicTraceRender","PcbComponentRender","PcbPrimitiveRender","PcbFootprintLayout","PcbPortRender","PcbPortAttachment","PcbLayout","PcbComponentSizeCalculation","PcbBoardAutoSize","PcbTraceHintRender","PcbTraceRender","PcbRouteNetIslands","PcbDesignRuleChecks","CadModelRender","PartsEngineRender"],Ydn=0,sXe=class{constructor(r){Qe(this,"renderPhaseStates");Qe(this,"shouldBeRemoved",!1);Qe(this,"children");Qe(this,"isPcbPrimitive",!1);Qe(this,"isSchematicPrimitive",!1);Qe(this,"_renderId");Qe(this,"_currentRenderPhase",null);Qe(this,"_asyncEffects",[]);Qe(this,"parent",null);this._renderId=`${Ydn++}`,this.children=[],this.renderPhaseStates={};for(const e of Ub)this.renderPhaseStates[e]={initialized:!1,dirty:!1}}_markDirty(r){var t;this.renderPhaseStates[r].dirty=!0;const e=Ub.indexOf(r);for(let n=e+1;n<Ub.length;n++)this.renderPhaseStates[Ub[n]].dirty=!0;(t=this.parent)!=null&&t._markDirty&&this.parent._markDirty(r)}_queueAsyncEffect(r,e){const t={promise:e(),phase:this._currentRenderPhase,effectName:r,complete:!1};this._asyncEffects.push(t),"root"in this&&this.root&&this.root.emit("asyncEffect:start",{effectName:r,componentDisplayName:this.getString(),phase:t.phase}),t.promise.then(()=>{t.complete=!0,"root"in this&&this.root&&this.root.emit("asyncEffect:end",{effectName:r,componentDisplayName:this.getString(),phase:t.phase})}).catch(n=>{console.error(`Async effect error in ${t.phase} "${r}":
|
|
13424
13424
|
${n.stack}`),t.complete=!0,"root"in this&&this.root&&this.root.emit("asyncEffect:end",{effectName:r,componentDisplayName:this.getString(),phase:t.phase,error:n.toString()})})}_emitRenderLifecycleEvent(r,e){qdn(`${r}:${e} ${this.getString()}`);const t=`renderable:renderLifecycle:${r}:${e}`,n={renderId:this._renderId,componentDisplayName:this.getString(),type:t};"root"in this&&this.root&&(this.root.emit(t,n),this.root.emit("renderable:renderLifecycle:anyEvent",{...n,type:t}))}getString(){return this.constructor.name}_hasIncompleteAsyncEffects(){return this._asyncEffects.some(r=>!r.complete)}getCurrentRenderPhase(){return this._currentRenderPhase}getRenderGraph(){return{id:this._renderId,currentPhase:this._currentRenderPhase,renderPhaseStates:this.renderPhaseStates,shouldBeRemoved:this.shouldBeRemoved,children:this.children.map(r=>r.getRenderGraph())}}runRenderCycle(){for(const r of Ub)this.runRenderPhaseForChildren(r),this.runRenderPhase(r)}runRenderPhase(r){var a,o,s;this._currentRenderPhase=r;const e=this.renderPhaseStates[r],t=e.initialized,n=e.dirty;if(!t&&this.shouldBeRemoved)return;if(this.shouldBeRemoved&&t){this._emitRenderLifecycleEvent(r,"start"),(a=this==null?void 0:this[`remove${r}`])==null||a.call(this),e.initialized=!1,e.dirty=!1,this._emitRenderLifecycleEvent(r,"end");return}const i=Ub.indexOf(r)-1;if(i>=0){const l=Ub[i];if(this._asyncEffects.filter(u=>u.phase===l).some(u=>!u.complete))return}if(this._emitRenderLifecycleEvent(r,"start"),t){n&&((o=this==null?void 0:this[`update${r}`])==null||o.call(this),e.dirty=!1),this._emitRenderLifecycleEvent(r,"end");return}e.dirty=!1,(s=this==null?void 0:this[`doInitial${r}`])==null||s.call(this),e.initialized=!0,this._emitRenderLifecycleEvent(r,"end")}runRenderPhaseForChildren(r){for(const e of this.children)e.runRenderPhaseForChildren(r),e.runRenderPhase(r)}renderError(r){throw typeof r=="string"?new Error(r):new Error(JSON.stringify(r,null,2))}},mj={},lXe=r=>{const e=Object.fromEntries(Object.entries(r).map(([t,n])=>[t.toLowerCase(),n]));Object.assign(mj,r),Object.assign(mj,e)};function Xdn(r,e){const t=r;return t.__tsci={...e},r}var cXe={supportsMutation:!0,createInstance(r,e){const t=mj[r];if(!t)throw Object.keys(mj).length===0?new Error("No components registered in catalogue, did you forget to import lib/register-catalogue in your test file?"):new Error(`Unsupported component type (not registered in @tscircuit/core catalogue): "${r}" See CREATING_NEW_COMPONENTS.md`);return Xdn(new t(e),{})},createTextInstance(){return{}},appendInitialChild(r,e){r.add(e)},appendChild(r,e){r.add(e)},appendChildToContainer(r,e){r.add(e)},finalizeInitialChildren(){return!1},prepareUpdate(){return null},shouldSetTextContent(){return!1},getRootHostContext(){return{}},getChildHostContext(){return{}},prepareForCommit(){return null},resetAfterCommit(){},commitMount(){},commitUpdate(){},removeChild(){},clearContainer(){},supportsPersistence:!1,getPublicInstance(r){return r},preparePortalMount(r){throw new Error("Function not implemented.")},scheduleTimeout(r,e){throw new Error("Function not implemented.")},cancelTimeout(r){throw new Error("Function not implemented.")},noTimeout:void 0,isPrimaryRenderer:!1,getInstanceFromNode(r){throw new Error("Function not implemented.")},beforeActiveInstanceBlur(){throw new Error("Function not implemented.")},afterActiveInstanceBlur(){throw new Error("Function not implemented.")},prepareScopeUpdate:(r,e)=>{throw new Error("Function not implemented.")},getInstanceFromScope:r=>{throw new Error("Function not implemented.")},detachDeletedInstance:r=>{throw new Error("Function not implemented.")},getCurrentEventPriority:()=>E8.DefaultEventPriority,getCurrentUpdatePriority:()=>E8.DefaultEventPriority,resolveUpdatePriority:()=>E8.DefaultEventPriority,setCurrentUpdatePriority:()=>{},maySuspendCommit:()=>!1,supportsHydration:!1},lw;Zd.version.startsWith("19.")?lw=KH(cXe):lw=tV(cXe);var Wdn=r=>{const e={children:[],props:{name:"$root"},add(a){a.parent=this,this.children.push(a)},computePcbGlobalTransform(){return e1()}},t=[],n=lw.createContainer(e,0,null,!1,null,"tsci",a=>{console.log("Error in createContainer"),console.error(a),t.push(a)},null);if(Zd.version.startsWith("19.")?(lw.updateContainerSync(r,n,null,()=>{}),lw.flushSyncWork()):lw.updateContainer(r,n,null,()=>{}),t.length>0)throw t[0];const i=lw.getPublicRootInstance(n);return i||e.children[0]},vP=(r,e)=>{if(typeof r=="number")return r;if(r.startsWith("pin"))return Number(r.slice(3));if(!e)throw new Error(`No pin labels provided and pin number or label is not a number: "${r}"`);for(const t in e)if((Array.isArray(e[t])?e[t]:[e[t]]).includes(r))return Number(t.replace("pin",""));throw new Error(`No pin labels provided and pin number or label is not a number: "${r}"`)},Zdn=(r,e)=>{if(!r)return;const t={},n={};for(const[i,a]of Object.entries(r)){const o=vP(i,e);n[o]={...n[o],...a}}for(const[i,a]of Object.entries(n)){const o=`pin${i}`;t[o]={bottom_margin:a.bottomMargin,left_margin:a.leftMargin,right_margin:a.rightMargin,top_margin:a.topMargin}}return t},Qdn=r=>{if(r){if("leftSide"in r||"rightSide"in r||"topSide"in r||"bottomSide"in r)return{left_side:r.leftSide,right_side:r.rightSide,top_side:r.topSide,bottom_side:r.bottomSide};if("leftPinCount"in r||"rightPinCount"in r||"topPinCount"in r||"bottomPinCount"in r)return{left_size:r.leftPinCount,right_size:r.rightPinCount,top_size:r.topPinCount,bottom_size:r.bottomPinCount};if("leftSize"in r||"rightSize"in r||"topSize"in r||"bottomSize"in r)return{left_size:r.leftSize,right_size:r.rightSize,top_size:r.topSize,bottom_size:r.bottomSize}}},Kdn=class extends Error{constructor(r,e,t){let n;const a=Object.keys(t).filter(o=>o!=="_errors").map(o=>t[o]._errors[0]?`${o} (${t[o]._errors[0]})`:`${o} (${JSON.stringify(t[o])})`).join(", ");"name"in e?n=`Invalid props for ${r} "${e.name}": ${a}`:"footprint"in e&&typeof e.footprint=="string"?n=`Invalid props for ${r} (unnamed ${e.footprint} component): ${a}`:n=`Invalid props for ${r} (unnamed): ${a}`,super(n),this.componentName=r,this.originalProps=e,this.formattedError=t}};function Bfe(r,e){const t=e.match(/^#(\w+)/);if(t)return r.props.id===t[1];const n=e.match(/^\.(\w+)/);if(n)return r.isMatchingNameOrAlias(n[1]);let[i,...a]=e.split(/(?=[#.[])/);return i==="pin"&&(i="port"),i&&i!=="*"&&r.lowercaseComponentName!==i.toLowerCase()?!1:a.every(o=>{if(o.startsWith("#"))return r.props.id===o.slice(1);if(o.startsWith("."))return r.isMatchingNameOrAlias(o.slice(1));const s=o.match(/\[(\w+)=['"]?(.+?)['"]?\]/);if(!s)return!0;const[,l,c]=s;return r.props[l].toString()===c})}var jfe={isTag:r=>!0,getParent:r=>r.parent,getChildren:r=>r.children,getName:r=>r.lowercaseComponentName,getAttributeValue:(r,e)=>{var t;if(e==="class"&&"getNameAndAliases"in r)return r.getNameAndAliases().join(" ");if(e==="name"&&((t=r._parsedProps)!=null&&t.name))return r._parsedProps.name;if(r._parsedProps&&e in r._parsedProps){const n=r._parsedProps[e];return typeof n=="string"?n:n!=null?String(n):null}return null},hasAttrib:(r,e)=>{var t;return e==="class"?!!((t=r._parsedProps)!=null&&t.name):r._parsedProps&&e in r._parsedProps},getSiblings:r=>r.parent?r.parent.children:[],prevElementSibling:r=>{if(!r.parent)return null;const e=r.parent.children,t=e.indexOf(r);return t>0?e[t-1]:null},getText:()=>"",removeSubsets:r=>r.filter((e,t)=>!r.some((n,i)=>t!==i&&n!==e&&n.getDescendants().includes(e))),existsOne:(r,e)=>e.some(r),findAll:(r,e)=>{const t=[],n=i=>{r(i)&&t.push(i);for(const a of i.children)n(a)};for(const i of e)n(i);return t},findOne:(r,e)=>{for(const t of e){if(r(t))return t;const n=t.children;if(n.length>0){const i=jfe.findOne(r,n);if(i)return i}}return null},equals:(r,e)=>r._renderId===e._renderId,isHovered:r=>!1,isVisited:r=>!1,isActive:r=>!1},Jdn={...jfe,getChildren:r=>r.children.filter(e=>!e.isSubcircuit)},uXe={...jfe,getChildren:r=>r.children.filter(e=>e.isSubcircuit)},fXe=r=>r.replace(/ pin/g," port").replace(/ subcircuit\./g," group[isSubcircuit=true]").replace(/([^ ])\>([^ ])/g,"$1 > $2").trim(),Hfe={adapter:Jdn,cacheResults:!0},Jg=class extends sXe{constructor(e){super(e);Qe(this,"parent",null);Qe(this,"children");Qe(this,"childrenPendingRemoval");Qe(this,"props");Qe(this,"_parsedProps");Qe(this,"externallyAddedAliases");Qe(this,"isPrimitiveContainer",!1);Qe(this,"source_group_id",null);Qe(this,"source_component_id",null);Qe(this,"schematic_component_id",null);Qe(this,"pcb_component_id",null);Qe(this,"cad_component_id",null);Qe(this,"_cachedSelectAllQueries",new Map);Qe(this,"_cachedSelectOneQueries",new Map);this.children=[],this.childrenPendingRemoval=[],this.props=e??{},this.externallyAddedAliases=[];const t=this.config.zodProps.safeParse(e??{});if(t.success)this._parsedProps=t.data;else throw new Kdn(this.lowercaseComponentName,this.props,t.error.format())}get config(){return{componentName:"",zodProps:R.object({}).passthrough()}}get componentName(){return this.config.componentName}getInheritedProperty(e){var n;let t=this;for(;t;){if(t._parsedProps&&e in t._parsedProps)return t._parsedProps[e];t=t.parent}if((n=this.root)!=null&&n.platform&&e in this.root.platform)return this.root.platform[e]}get lowercaseComponentName(){return this.componentName.toLowerCase()}get isSubcircuit(){var e;return!!this.props.subcircuit||this.lowercaseComponentName==="group"&&((e=this==null?void 0:this.parent)==null?void 0:e.isRoot)}get isGroup(){return this.lowercaseComponentName==="group"}setProps(e){var i,a;const t=this.config.zodProps.parse({...this.props,...e}),n=this.props;this.props=t,this._parsedProps=this.config.zodProps.parse(e),this.onPropsChange({oldProps:n,newProps:t,changedProps:Object.keys(e)}),(a=(i=this.parent)==null?void 0:i.onChildChanged)==null||a.call(i,this)}computePcbPropsTransform(){const{_parsedProps:e}=this;return Rc(q0(e.pcbX??0,e.pcbY??0),z2((e.pcbRotation??0)*Math.PI/180))}_computePcbGlobalTransformBeforeLayout(){var n,i,a;const{_parsedProps:e}=this,t=this.getSubcircuit()._getPcbManualPlacementForComponent(this);if(t&&this.props.pcbX===void 0&&this.props.pcbY===void 0)return Rc(((n=this.parent)==null?void 0:n._computePcbGlobalTransformBeforeLayout())??e1(),Rc(q0(t.x,t.y),z2((e.pcbRotation??0)*Math.PI/180)));if(this.isPcbPrimitive){const o=this.getPrimitiveContainer();if(o){const s=o._parsedProps.layer==="bottom",l=o._getGlobalPcbPositionBeforeLayout();if(s)return Rc(q0(l.x,l.y),A6(),q0(-l.x,-l.y)),Rc(((i=this.parent)==null?void 0:i._computePcbGlobalTransformBeforeLayout())??e1(),A6(),this.computePcbPropsTransform())}}return Rc(((a=this.parent)==null?void 0:a._computePcbGlobalTransformBeforeLayout())??e1(),this.computePcbPropsTransform())}getPrimitiveContainer(){var e,t;return this.isPrimitiveContainer?this:((t=(e=this.parent)==null?void 0:e.getPrimitiveContainer)==null?void 0:t.call(e))??null}_getPcbCircuitJsonBounds(){return{center:{x:0,y:0},bounds:{left:0,top:0,right:0,bottom:0},width:0,height:0}}_getPcbPrimitiveFlippedHelpers(){const e=this.getPrimitiveContainer(),t=e?e._parsedProps.layer==="bottom":!1;return{isFlipped:t,maybeFlipLayer:i=>t?i==="top"?"bottom":"top":i}}_setPositionFromLayout(e){throw new Error(`_setPositionFromLayout not implemented for ${this.componentName}`)}computeSchematicPropsTransform(){const{_parsedProps:e}=this;return Rc(q0(e.schX??0,e.schY??0))}computeSchematicGlobalTransform(){var t,n;const e=this._getSchematicGlobalManualPlacementTransform(this);return e||Rc(((n=(t=this.parent)==null?void 0:t.computeSchematicGlobalTransform)==null?void 0:n.call(t))??e1(),this.computeSchematicPropsTransform())}_getSchematicSymbolName(){const{_parsedProps:e}=this,t=this.config.schematicSymbolName;let n=e.schRotation;if(n===void 0&&(n=0),n=n%360,n<0&&(n+=360),e.schRotation!==void 0&&n%90!==0)throw new Error(`Schematic rotation ${e.schRotation} is not supported for ${this.componentName}`);const i=`${t}_horz`,a=`${t}_vert`,o=`${t}_up`,s=`${t}_down`,l=`${t}_left`,c=`${t}_right`;if(c in k3&&n===0)return c;if(o in k3&&n===90)return o;if(l in k3&&n===180)return l;if(s in k3&&n===270)return s;if(i in k3&&(n===0||n===180))return i;if(a in k3&&(n===90||n===270))return a;if(t in k3)return t}_getSchematicSymbolNameOrThrow(){const e=this._getSchematicSymbolName();if(!e)throw new Error(`No schematic symbol found (given: "${this.config.schematicSymbolName}")`);return e}getSchematicSymbol(){const e=this._getSchematicSymbolName();return e?k3[e]??null:null}_getPcbManualPlacementForComponent(e){var a;if(!this.isSubcircuit)return null;const t=this.props.layout,n=this.props.manualEdits;if(!t&&!n)return null;const i=((a=t==null?void 0:t.manual_pcb_placement_config)==null?void 0:a.positions)||(n==null?void 0:n.pcb_placements);if(!i)return null;for(const o of i)if(t&&Bfe(e,o.selector)||e.props.name===o.selector)return Pr(this._computePcbGlobalTransformBeforeLayout(),o.center);return null}_getSchematicManualPlacementForComponent(e){if(!this.isSubcircuit)return null;const t=this.props.manualEdits;if(!t)return null;const n=t.schematic_placements;if(!n)return null;for(const i of n)if(Bfe(e,i.selector)||e.props.name===i.selector)return Pr(this.computeSchematicGlobalTransform(),i.center);return null}_getSchematicGlobalManualPlacementTransform(e){var n,i;const t=(n=this.getSubcircuit())==null?void 0:n._parsedProps.manualEdits;if(!t)return null;for(const a of t.schematic_placements??[])if((Bfe(e,a.selector)||e.props.name===a.selector)&&a.relative_to==="group_center")return Rc(((i=this.parent)==null?void 0:i._computePcbGlobalTransformBeforeLayout())??e1(),q0(a.center.x,a.center.y));return null}_getGlobalPcbPositionBeforeLayout(){return Pr(this._computePcbGlobalTransformBeforeLayout(),{x:0,y:0})}_getGlobalSchematicPositionBeforeLayout(){return Pr(this.computeSchematicGlobalTransform(),{x:0,y:0})}get root(){var e;return((e=this.parent)==null?void 0:e.root)??null}onAddToParent(e){this.parent=e}onPropsChange(e){}onChildChanged(e){var t,n;(n=(t=this.parent)==null?void 0:t.onChildChanged)==null||n.call(t,e)}add(e){if(!e.onAddToParent)throw new Error(`Invalid JSX Element: Expected a React component but received "${JSON.stringify(e)}"`);e.onAddToParent(this),e.parent=this,this.children.push(e)}addAll(e){for(const t of e)this.add(t)}remove(e){this.children=this.children.filter(t=>t!==e),this.childrenPendingRemoval.push(e),e.shouldBeRemoved=!0}getSubcircuitSelector(){const e=this._parsedProps.name,t=e?`${this.lowercaseComponentName}.${e}`:this.lowercaseComponentName;return!this.parent||this.parent.isSubcircuit?t:`${this.parent.getSubcircuitSelector()} > ${t}`}getFullPathSelector(){var i,a;const e=this._parsedProps.name,t=e?`${this.lowercaseComponentName}.${e}`:this.lowercaseComponentName,n=(a=(i=this.parent)==null?void 0:i.getFullPathSelector)==null?void 0:a.call(i);return n?`${n} > ${t}`:t}getNameAndAliases(){return[this._parsedProps.name,...this._parsedProps.portHints??[]].filter(Boolean)}isMatchingNameOrAlias(e){return this.getNameAndAliases().includes(e)}isMatchingAnyOf(e){return this.getNameAndAliases().some(t=>e.map(n=>n.toString()).includes(t))}getPcbSize(){throw new Error(`getPcbSize not implemented for ${this.componentName}`)}doesSelectorMatch(e){const t=[this.componentName,this.lowercaseComponentName],n=[this._parsedProps.name].filter(Boolean),i=e.trim().split(/\> /)[0],a=i[0];return i.length>1?!1:!!(e==="*"||e[0]==="#"&&e.slice(1)===this.props.id||e[0]==="."&&n.includes(e.slice(1))||/^[a-zA-Z0-9_]/.test(a)&&t.includes(a))}getSubcircuit(){var t,n;if(this.isSubcircuit)return this;const e=(n=(t=this.parent)==null?void 0:t.getSubcircuit)==null?void 0:n.call(t);if(!e)throw new Error("Component is not inside an opaque group (no board?)");return e}getGroup(){var e,t;return this.isGroup?this:((t=(e=this.parent)==null?void 0:e.getGroup)==null?void 0:t.call(e))??null}doInitialOptimizeSelectorCache(){var t;if(!this.isSubcircuit)return;const e=this.selectAll("port");for(const n of e){const i=(t=n.parent)==null?void 0:t.getNameAndAliases(),a=n.getNameAndAliases();if(i)for(const o of i)for(const s of a){const l=[`.${o} > .${s}`,`.${o} .${s}`];for(const c of l){const u=this._cachedSelectAllQueries.get(c);u?u.push(n):this._cachedSelectAllQueries.set(c,[n])}}}for(const[n,i]of this._cachedSelectAllQueries.entries())i.length===1&&this._cachedSelectOneQueries.set(n,i[0])}selectAll(e){if(this._cachedSelectAllQueries.has(e))return this._cachedSelectAllQueries.get(e);const t=fXe(e),n=jw(t,this,Hfe);if(n.length>0)return this._cachedSelectAllQueries.set(e,n),n;const[i,...a]=t.split(" "),o=T8(i,this,{adapter:uXe});if(!o)return[];const s=o.selectAll(a.join(" "));return this._cachedSelectAllQueries.set(e,s),s}selectOne(e,t){if(this._cachedSelectOneQueries.has(e))return this._cachedSelectOneQueries.get(e);const n=fXe(e);t!=null&&t.port&&(t.type="port");let i=null;if(t!=null&&t.type&&(i=jw(n,this,Hfe).find(c=>c.lowercaseComponentName===t.type)),i??(i=T8(n,this,Hfe)),i)return this._cachedSelectOneQueries.set(e,i),i;const[a,...o]=n.split(" "),s=T8(a,this,{adapter:uXe});return s?(i=s.selectOne(o.join(" "),t),this._cachedSelectOneQueries.set(e,i),i):null}getAvailablePcbLayers(){var e,t;if(this.isPcbPrimitive){const{maybeFlipLayer:n}=this._getPcbPrimitiveFlippedHelpers();return"layer"in this._parsedProps||this.componentName==="SmtPad"?[n(this._parsedProps.layer??"top")]:"layers"in this._parsedProps?this._parsedProps.layers:this.componentName==="PlatedHole"?((t=(e=this.root)==null?void 0:e._getBoard())==null?void 0:t.allLayers)??["top","bottom"]:[]}return[]}getDescendants(){const e=[];for(const t of this.children)e.push(t),e.push(...t.getDescendants());return e}getSelectableDescendants(){const e=[];for(const t of this.children)t.isSubcircuit?e.push(t):(e.push(t),e.push(...t.getSelectableDescendants()));return e}_getPinCount(){return 0}_getSchematicBoxDimensions(){return null}renderError(e){var t;if(typeof e=="string")return super.renderError(e);(t=this.root)==null||t.db.pcb_placement_error.insert(e)}getString(){var i,a;const{lowercaseComponentName:e,_parsedProps:t,parent:n}=this;return(t==null?void 0:t.pinNumber)!==void 0&&((i=n==null?void 0:n.props)!=null&&i.name)&&(t!=null&&t.name)?`<${e}#${this._renderId}(pin:${t.pinNumber} .${n==null?void 0:n.props.name}>.${t.name}) />`:(a=n==null?void 0:n.props)!=null&&a.name&&(t!=null&&t.name)?`<${e}#${this._renderId}(.${n==null?void 0:n.props.name}>.${t==null?void 0:t.name}) />`:t!=null&&t.from&&(t!=null&&t.to)?`<${e}#${this._renderId}(from:${t.from} to:${t==null?void 0:t.to}) />`:t!=null&&t.name?`<${e}#${this._renderId} name=".${t==null?void 0:t.name}" />`:t!=null&&t.portHints?`<${e}#${this._renderId}(${t.portHints.map(o=>`.${o}`).join(", ")}) />`:`<${e}#${this._renderId} />`}get[Symbol.toStringTag](){return this.getString()}[Symbol.for("nodejs.util.inspect.custom")](){return this.getString()}};function dXe(r){const e=[];for(let t=0;t<r.length-1;t++)e.push([r[t],r[t+1]]);return e}var epn=R.object({name:R.string()}),pXe=class extends Jg{constructor(){super(...arguments);Qe(this,"source_net_id")}get config(){return{componentName:"Net",zodProps:epn}}getPortSelector(){return`net.${this.props.name}`}doInitialSourceRender(){const{db:e}=this.root,{_parsedProps:t}=this,n=e.source_net.insert({name:t.name,member_source_group_ids:[]});this.source_net_id=n.source_net_id}doInitialSourceParentAttachment(){const e=this.getSubcircuit();if(!e)return;const{db:t}=this.root;t.source_net.update(this.source_net_id,{subcircuit_id:e.subcircuit_id})}getAllConnectedPorts(){const e=this.getSubcircuit().selectAll("port"),t=[];for(const n of e){const i=n._getDirectlyConnectedTraces();for(const a of i)if(a._isExplicitlyConnectedToNet(this)){t.push(n);break}}return t}_getAllDirectlyConnectedTraces(){const e=this.getSubcircuit().selectAll("trace"),t=[];for(const n of e)n._isExplicitlyConnectedToNet(this)&&t.push(n);return t}doInitialPcbRouteNetIslands(){var o;if((o=this.root)!=null&&o.pcbDisabled||this.getSubcircuit()._parsedProps.routingDisabled||this.getSubcircuit()._getAutorouterConfig().groupMode!=="sequential-trace")return;const{db:e}=this.root,{_parsedProps:t}=this,n=this._getAllDirectlyConnectedTraces().filter(s=>{var l;return(((l=s._portsRoutedOnPcb)==null?void 0:l.length)??0)>0}),i=[];for(const s of n){const l=s._portsRoutedOnPcb,c=i.find(u=>l.some(f=>u.ports.includes(f)));if(!c){i.push({ports:[...l],traces:[s]});continue}c.traces.push(s),c.ports.push(...l)}if(i.length===0)return;const a=dXe(i);for(const[s,l]of a){const c=s.ports.map(C=>C._getGlobalPcbPositionBeforeLayout()),u=l.ports.map(C=>C._getGlobalPcbPositionBeforeLayout());let f=1/0,p=[-1,-1];for(let C=0;C<c.length;C++){const z=c[C];for(let I=0;I<u.length;I++){const G=u[I],Y=Math.sqrt((z.x-G.x)**2+(z.y-G.y)**2);Y<f&&(f=Y,p=[C,I])}}const v=s.ports[p[0]],x=l.ports[p[1]],S=e.toArray().filter(C=>C.type==="pcb_smtpad"||C.type==="pcb_trace"||C.type==="pcb_plated_hole"||C.type==="pcb_hole"||C.type==="source_port"||C.type==="pcb_port"),{solution:w}=oq(S.concat([{type:"source_trace",source_trace_id:"__net_trace_tmp",connected_source_port_ids:[v.source_port_id,x.source_port_id]}])),b=w[0];if(!b){this.renderError({pcb_trace_error_id:"",pcb_trace_id:"__net_trace_tmp",pcb_component_ids:[v.pcb_component_id,x.pcb_component_id].filter(Boolean),pcb_port_ids:[v.pcb_port_id,x.pcb_port_id].filter(Boolean),type:"pcb_trace_error",error_type:"pcb_trace_error",message:`Failed to route net islands for "${this.getString()}"`,source_trace_id:"__net_trace_tmp"});return}e.pcb_trace.insert(b)}}renderError(e){var t;if(typeof e=="string")return super.renderError(e);(t=this.root)==null||t.db.pcb_trace_error.insert(e)}},hXe=(r,e)=>{for(const t of e)if(typeof t=="string"&&t.startsWith("net.")){const n=r.getSubcircuit();if(!n.selectOne(t)){const i=new pXe({name:t.split("net.")[1]});n.add(i)}}},Vfe=class extends Jg{constructor(){super(...arguments);Qe(this,"pcb_smtpad_id",null);Qe(this,"matchedPort",null);Qe(this,"isPcbPrimitive",!0)}get config(){return{componentName:"SmtPad",zodProps:tdn}}getPcbSize(){const{_parsedProps:e}=this;if(e.shape==="circle")return{width:e.radius*2,height:e.radius*2};if(e.shape==="rect")return{width:e.width,height:e.height};throw new Error(`getPcbSize for shape "${e.shape}" not implemented for ${this.componentName}`)}doInitialPortMatching(){var t;const e=(t=this.getPrimitiveContainer())==null?void 0:t.selectAll("port");if(this.props.portHints){for(const n of e)if(n.isMatchingAnyOf(this.props.portHints)){this.matchedPort=n,n.registerMatch(this);return}}}doInitialPcbPrimitiveRender(){var p,v,x,S,w,b,C,z,I,G;if((p=this.root)!=null&&p.pcbDisabled)return;const{db:e}=this.root,{_parsedProps:t}=this;if(!t.portHints)return;const n=this.getPrimitiveContainer(),i=this.getSubcircuit(),a=this._getGlobalPcbPositionBeforeLayout();n==null||n._getGlobalPcbPositionBeforeLayout();const o=R6(this._computePcbGlobalTransformBeforeLayout()),s=Math.abs(o.rotation.angle*(180/Math.PI)-90)%180<.01,{maybeFlipLayer:l}=this._getPcbPrimitiveFlippedHelpers(),c=(n==null?void 0:n._parsedProps.pcbRotation)??0;let u=null;const f=((v=this.parent)==null?void 0:v.pcb_component_id)??((x=this.getPrimitiveContainer())==null?void 0:x.pcb_component_id);t.shape==="circle"?(u=e.pcb_smtpad.insert({pcb_component_id:f,pcb_port_id:(S=this.matchedPort)==null?void 0:S.pcb_port_id,layer:l(t.layer??"top"),shape:"circle",radius:t.radius,port_hints:t.portHints.map(Y=>Y.toString()),x:a.x,y:a.y,subcircuit_id:(i==null?void 0:i.subcircuit_id)??void 0}),e.pcb_solder_paste.insert({layer:u.layer,shape:"circle",radius:u.radius*.7,x:u.x,y:u.y,pcb_component_id:u.pcb_component_id,pcb_smtpad_id:u.pcb_smtpad_id,subcircuit_id:(i==null?void 0:i.subcircuit_id)??void 0,pcb_group_id:((w=this.getGroup())==null?void 0:w.pcb_group_id)??void 0})):t.shape==="rect"&&(u=c===0||s?e.pcb_smtpad.insert({pcb_component_id:f,pcb_port_id:(b=this.matchedPort)==null?void 0:b.pcb_port_id,layer:l(t.layer??"top"),shape:"rect",width:s?t.height:t.width,height:s?t.width:t.height,port_hints:t.portHints.map(Y=>Y.toString()),x:a.x,y:a.y,subcircuit_id:(i==null?void 0:i.subcircuit_id)??void 0,pcb_group_id:((C=this.getGroup())==null?void 0:C.pcb_group_id)??void 0}):e.pcb_smtpad.insert({pcb_component_id:f,layer:t.layer??"top",shape:"rotated_rect",width:t.width,height:t.height,x:a.x,y:a.y,ccw_rotation:c,port_hints:t.portHints.map(Y=>Y.toString()),subcircuit_id:(i==null?void 0:i.subcircuit_id)??void 0,pcb_group_id:((z=this.getGroup())==null?void 0:z.pcb_group_id)??void 0}),u.shape==="rect"&&e.pcb_solder_paste.insert({layer:u.layer,shape:"rect",width:u.width*.7,height:u.height*.7,x:u.x,y:u.y,pcb_component_id:u.pcb_component_id,pcb_smtpad_id:u.pcb_smtpad_id,subcircuit_id:(i==null?void 0:i.subcircuit_id)??void 0,pcb_group_id:((I=this.getGroup())==null?void 0:I.pcb_group_id)??void 0}),u.shape==="rotated_rect"&&e.pcb_solder_paste.insert({layer:u.layer,shape:"rotated_rect",width:u.width*.7,height:u.height*.7,x:u.x,y:u.y,ccw_rotation:c,pcb_component_id:u.pcb_component_id,pcb_smtpad_id:u.pcb_smtpad_id,subcircuit_id:(i==null?void 0:i.subcircuit_id)??void 0,pcb_group_id:((G=this.getGroup())==null?void 0:G.pcb_group_id)??void 0})),u&&(this.pcb_smtpad_id=u.pcb_smtpad_id)}doInitialPcbPortAttachment(){var t,n;if((t=this.root)!=null&&t.pcbDisabled)return;const{db:e}=this.root;e.pcb_smtpad.update(this.pcb_smtpad_id,{pcb_port_id:(n=this.matchedPort)==null?void 0:n.pcb_port_id})}_getPcbCircuitJsonBounds(){const{db:e}=this.root,t=e.pcb_smtpad.get(this.pcb_smtpad_id);if(t.shape==="rect")return{center:{x:t.x,y:t.y},bounds:{left:t.x-t.width/2,top:t.y+t.height/2,right:t.x+t.width/2,bottom:t.y-t.height/2},width:t.width,height:t.height};if(t.shape==="rotated_rect"){const n=t.ccw_rotation*Math.PI/180,i=Math.cos(n),a=Math.sin(n),o=t.width/2,s=t.height/2,l=Math.abs(o*i)+Math.abs(s*a),c=Math.abs(o*a)+Math.abs(s*i);return{center:{x:t.x,y:t.y},bounds:{left:t.x-l,right:t.x+l,top:t.y-c,bottom:t.y+c},width:l*2,height:c*2}}if(t.shape==="circle")return{center:{x:t.x,y:t.y},bounds:{left:t.x-t.radius,top:t.y-t.radius,right:t.x+t.radius,bottom:t.y+t.radius},width:t.radius*2,height:t.radius*2};throw new Error(`circuitJson bounds calculation not implemented for shape "${t.shape}"`)}_setPositionFromLayout(e){var i;const{db:t}=this.root;t.pcb_smtpad.update(this.pcb_smtpad_id,{x:e.x,y:e.y});const n=t.pcb_solder_paste.list().find(a=>a.pcb_smtpad_id===this.pcb_smtpad_id);t.pcb_solder_paste.update(n==null?void 0:n.pcb_solder_paste_id,{x:e.x,y:e.y}),(i=this.matchedPort)==null||i._setPositionFromLayout(e)}},mXe=class extends Jg{constructor(){super(...arguments);Qe(this,"pcb_silkscreen_path_id",null);Qe(this,"isPcbPrimitive",!0)}get config(){return{componentName:"SilkscreenPath",zodProps:Ndn}}doInitialPcbPrimitiveRender(){var l,c,u;if((l=this.root)!=null&&l.pcbDisabled)return;const{db:e}=this.root,{_parsedProps:t}=this,{maybeFlipLayer:n}=this._getPcbPrimitiveFlippedHelpers(),i=n(t.layer??"top");if(i!=="top"&&i!=="bottom")throw new Error(`Invalid layer "${i}" for SilkscreenPath. Must be "top" or "bottom".`);const a=this._computePcbGlobalTransformBeforeLayout(),o=this.getSubcircuit(),s=e.pcb_silkscreen_path.insert({pcb_component_id:(c=this.parent)==null?void 0:c.pcb_component_id,layer:i,route:t.route.map(f=>{const p=Pr(a,{x:f.x,y:f.y});return{...f,x:p.x,y:p.y}}),stroke_width:t.strokeWidth??.1,subcircuit_id:(o==null?void 0:o.subcircuit_id)??void 0,pcb_group_id:((u=this.getGroup())==null?void 0:u.pcb_group_id)??void 0});this.pcb_silkscreen_path_id=s.pcb_silkscreen_path_id}getPcbSize(){const{_parsedProps:e}=this;if(!e.route||e.route.length===0)return{width:0,height:0};let t=1/0,n=-1/0,i=1/0,a=-1/0;for(const o of e.route)t=Math.min(t,o.x),n=Math.max(n,o.x),i=Math.min(i,o.y),a=Math.max(a,o.y);return{width:n-t,height:a-i}}},tpn=R.object({route:R.array(IH),source_trace_id:R.string().optional()}),vXe=class extends Jg{constructor(){super(...arguments);Qe(this,"pcb_trace_id",null);Qe(this,"isPcbPrimitive",!0)}get config(){return{componentName:"PcbTrace",zodProps:tpn}}doInitialPcbPrimitiveRender(){var l,c;if((l=this.root)!=null&&l.pcbDisabled)return;const{db:e}=this.root,{_parsedProps:t}=this,n=this.getPrimitiveContainer(),i=this.getSubcircuit(),a=n._computePcbGlobalTransformBeforeLayout(),o=t.route.map(u=>{const{x:f,y:p,...v}=u;return{...Pr(a,{x:f,y:p}),...v}}),s=e.pcb_trace.insert({pcb_component_id:n.pcb_component_id,source_trace_id:t.source_trace_id,route:o,subcircuit_id:(i==null?void 0:i.subcircuit_id)??void 0,pcb_group_id:((c=this.getGroup())==null?void 0:c.pcb_group_id)??void 0});this.pcb_trace_id=s.pcb_trace_id}getPcbSize(){const{_parsedProps:e}=this;if(!e.route||e.route.length===0)return{width:0,height:0};let t=1/0,n=-1/0,i=1/0,a=-1/0;for(const o of e.route)t=Math.min(t,o.x),n=Math.max(n,o.x),i=Math.min(i,o.y),a=Math.max(a,o.y),o.route_type==="wire"&&(t=Math.min(t,o.x-o.width/2),n=Math.max(n,o.x+o.width/2),i=Math.min(i,o.y-o.width/2),a=Math.max(a,o.y+o.width/2));return t===1/0||n===-1/0||i===1/0||a===-1/0?{width:0,height:0}:{width:n-t,height:a-i}}},yXe=class extends Jg{constructor(){super(...arguments);Qe(this,"pcb_plated_hole_id",null);Qe(this,"matchedPort",null);Qe(this,"isPcbPrimitive",!0)}get config(){return{componentName:"PlatedHole",zodProps:Ifn}}getAvailablePcbLayers(){return["top","inner1","inner2","bottom"]}getPcbSize(){const{_parsedProps:e}=this;if(e.shape==="circle")return{width:e.outerDiameter,height:e.outerDiameter};if(e.shape==="oval"||e.shape==="pill")return{width:e.outerWidth,height:e.outerHeight};throw new Error(`getPcbSize for shape "${e.shape}" not implemented for ${this.componentName}`)}_getPcbCircuitJsonBounds(){const{db:e}=this.root,t=e.pcb_plated_hole.get(this.pcb_plated_hole_id),n=this.getPcbSize();return{center:{x:t.x,y:t.y},bounds:{left:t.x-n.width/2,top:t.y+n.height/2,right:t.x+n.width/2,bottom:t.y-n.height/2},width:n.width,height:n.height}}_setPositionFromLayout(e){var n;const{db:t}=this.root;t.pcb_plated_hole.update(this.pcb_plated_hole_id,{x:e.x,y:e.y}),(n=this.matchedPort)==null||n._setPositionFromLayout(e)}doInitialPortMatching(){var t;const e=(t=this.getPrimitiveContainer())==null?void 0:t.selectAll("port");if(this.props.portHints){for(const n of e)if(n.isMatchingAnyOf(this.props.portHints)){this.matchedPort=n,n.registerMatch(this);return}}}doInitialPcbPrimitiveRender(){var o,s,l,c,u,f,p,v,x,S,w;if((o=this.root)!=null&&o.pcbDisabled)return;const{db:e}=this.root,{_parsedProps:t}=this,n=this._getGlobalPcbPositionBeforeLayout(),i=((s=this.parent)==null?void 0:s.pcb_component_id)??((l=this.getPrimitiveContainer())==null?void 0:l.pcb_component_id),a=this.getSubcircuit();if(t.shape==="circle"){const b=e.pcb_plated_hole.insert({pcb_component_id:i,pcb_port_id:(c=this.matchedPort)==null?void 0:c.pcb_port_id,outer_diameter:t.outerDiameter,hole_diameter:t.holeDiameter,shape:"circle",port_hints:this.getNameAndAliases(),x:n.x,y:n.y,layers:["top","bottom"],subcircuit_id:(a==null?void 0:a.subcircuit_id)??void 0,pcb_group_id:((u=this.getGroup())==null?void 0:u.pcb_group_id)??void 0});this.pcb_plated_hole_id=b.pcb_plated_hole_id,e.pcb_solder_paste.insert({layer:"top",shape:"circle",radius:t.outerDiameter/2,x:n.x,y:n.y,subcircuit_id:(a==null?void 0:a.subcircuit_id)??void 0,pcb_group_id:((f=this.getGroup())==null?void 0:f.pcb_group_id)??void 0}),e.pcb_solder_paste.insert({layer:"bottom",shape:"circle",radius:t.outerDiameter/2,x:n.x,y:n.y,subcircuit_id:(a==null?void 0:a.subcircuit_id)??void 0,pcb_group_id:((p=this.getGroup())==null?void 0:p.pcb_group_id)??void 0})}else if(t.shape==="pill"||t.shape==="oval"){const b=e.pcb_plated_hole.insert({pcb_component_id:i,pcb_port_id:(v=this.matchedPort)==null?void 0:v.pcb_port_id,outer_width:t.outerWidth,outer_height:t.outerHeight,hole_width:t.holeWidth,hole_height:t.holeHeight,shape:t.shape,port_hints:this.getNameAndAliases(),x:n.x,y:n.y,layers:["top","bottom"],subcircuit_id:(a==null?void 0:a.subcircuit_id)??void 0,pcb_group_id:((x=this.getGroup())==null?void 0:x.pcb_group_id)??void 0});this.pcb_plated_hole_id=b.pcb_plated_hole_id,e.pcb_solder_paste.insert({layer:"top",shape:t.shape,width:t.outerWidth,height:t.outerHeight,x:n.x,y:n.y,subcircuit_id:(a==null?void 0:a.subcircuit_id)??void 0,pcb_group_id:((S=this.getGroup())==null?void 0:S.pcb_group_id)??void 0}),e.pcb_solder_paste.insert({layer:"bottom",shape:t.shape,width:t.outerWidth,height:t.outerHeight,x:n.x,y:n.y,subcircuit_id:(a==null?void 0:a.subcircuit_id)??void 0,pcb_group_id:((w=this.getGroup())==null?void 0:w.pcb_group_id)??void 0})}}doInitialPcbPortAttachment(){var t,n;if((t=this.root)!=null&&t.pcbDisabled)return;const{db:e}=this.root;e.pcb_plated_hole.update(this.pcb_plated_hole_id,{pcb_port_id:(n=this.matchedPort)==null?void 0:n.pcb_port_id})}},$fe=class extends Jg{constructor(){super(...arguments);Qe(this,"pcb_keepout_id",null);Qe(this,"isPcbPrimitive",!0)}get config(){return{componentName:"Keepout",zodProps:Tdn}}doInitialPcbPrimitiveRender(){var l,c,u;if((l=this.root)!=null&&l.pcbDisabled)return;const e=this.getSubcircuit(),{db:t}=this.root,{_parsedProps:n}=this,i=this._getGlobalPcbPositionBeforeLayout(),a=R6(this._computePcbGlobalTransformBeforeLayout()),o=Math.abs(a.rotation.angle*(180/Math.PI)-90)%180<.01;let s=null;n.shape==="circle"?s=t.pcb_keepout.insert({layers:["top"],shape:"circle",radius:n.radius,center:{x:i.x,y:i.y},subcircuit_id:(e==null?void 0:e.subcircuit_id)??void 0,pcb_group_id:((c=e==null?void 0:e.getGroup())==null?void 0:c.pcb_group_id)??void 0}):n.shape==="rect"&&(s=t.pcb_keepout.insert({layers:["top"],shape:"rect",...o?{width:n.height,height:n.width}:{width:n.width,height:n.height},center:{x:i.x,y:i.y},subcircuit_id:(e==null?void 0:e.subcircuit_id)??void 0,pcb_group_id:((u=e==null?void 0:e.getGroup())==null?void 0:u.pcb_group_id)??void 0})),s&&(this.pcb_keepout_id=s.pcb_keepout_id)}},gXe=class extends Jg{constructor(){super(...arguments);Qe(this,"pcb_hole_id",null);Qe(this,"isPcbPrimitive",!0)}get config(){return{componentName:"Hole",zodProps:idn}}getPcbSize(){const{_parsedProps:e}=this;return{width:e.diameter,height:e.diameter}}doInitialPcbPrimitiveRender(){var o,s;if((o=this.root)!=null&&o.pcbDisabled)return;const{db:e}=this.root,{_parsedProps:t}=this,n=this.getSubcircuit(),i=this._getGlobalPcbPositionBeforeLayout(),a=e.pcb_hole.insert({hole_shape:"circle",hole_diameter:t.diameter,x:i.x,y:i.y,subcircuit_id:(n==null?void 0:n.subcircuit_id)??void 0,pcb_group_id:((s=n==null?void 0:n.getGroup())==null?void 0:s.pcb_group_id)??void 0});this.pcb_hole_id=a.pcb_hole_id}_getPcbCircuitJsonBounds(){const{db:e}=this.root,t=e.pcb_hole.get(this.pcb_hole_id),n=this.getPcbSize();return{center:{x:t.x,y:t.y},bounds:{left:t.x-n.width/2,top:t.y-n.height/2,right:t.x+n.width/2,bottom:t.y+n.height/2},width:n.width,height:n.height}}_setPositionFromLayout(e){const{db:t}=this.root;t.pcb_hole.update(this.pcb_hole_id,{x:e.x,y:e.y})}},Gfe=class extends Jg{constructor(){super(...arguments);Qe(this,"isPcbPrimitive",!0)}get config(){return{componentName:"SilkscreenText",zodProps:Pdn}}doInitialPcbPrimitiveRender(){var s,l;if((s=this.root)!=null&&s.pcbDisabled)return;const{db:e}=this.root,{_parsedProps:t}=this,n=this.getPrimitiveContainer(),i=this._getGlobalPcbPositionBeforeLayout(),{maybeFlipLayer:a}=this._getPcbPrimitiveFlippedHelpers(),o=this.getSubcircuit();e.pcb_silkscreen_text.insert({anchor_alignment:t.anchorAlignment,anchor_position:{x:i.x,y:i.y},font:t.font??"tscircuit2024",font_size:t.fontSize??1,layer:a(t.layer??"top"),text:t.text??"",ccw_rotation:t.pcbRotation,pcb_component_id:n.pcb_component_id,subcircuit_id:(o==null?void 0:o.subcircuit_id)??void 0,pcb_group_id:((l=this.getGroup())==null?void 0:l.pcb_group_id)??void 0})}getPcbSize(){const{_parsedProps:e}=this,t=e.fontSize??1,i=(e.text??"").length*t,a=t;return{width:i*t,height:a*t}}},npn=({elm:r,pinLabels:e,readableRotation:t})=>{var a;const n=r.text.replace(/[{}]/g,"").toLowerCase();let i=n;if(Array.isArray(e)){const o=parseInt(n.replace(/[^\d]/g,""),10)-1;i=e[o]??n}else typeof e=="object"&&(i=((a=e[n])==null?void 0:a[0])??n);return new Gfe({anchorAlignment:"center",text:i??n,fontSize:r.font_size+.2,pcbX:isNaN(r.anchor_position.x)?0:r.anchor_position.x,pcbY:r.anchor_position.y,pcbRotation:t??0})},rpn=({componentName:r,componentRotation:e,footprint:t,pinLabels:n},i)=>{const a=[];for(const o of i)if(o.type==="pcb_smtpad"&&o.shape==="rect")a.push(new Vfe({pcbX:o.x,pcbY:o.y,layer:o.layer,shape:"rect",height:o.height,width:o.width,portHints:o.port_hints}));else if(o.type==="pcb_smtpad"&&o.shape==="circle")a.push(new Vfe({pcbX:o.x,pcbY:o.y,layer:o.layer,shape:"circle",radius:o.radius,portHints:o.port_hints}));else if(o.type==="pcb_silkscreen_path")a.push(new mXe({layer:o.layer,route:o.route,strokeWidth:o.stroke_width}));else if(o.type==="pcb_plated_hole"&&o.shape==="circle")o.shape==="circle"&&a.push(new yXe({pcbX:o.x,pcbY:o.y,shape:"circle",holeDiameter:o.hole_diameter,outerDiameter:o.outer_diameter,portHints:o.port_hints}));else if(o.type==="pcb_keepout"&&o.shape==="circle")a.push(new $fe({pcbX:o.center.x,pcbY:o.center.y,shape:"circle",radius:o.radius}));else if(o.type==="pcb_keepout"&&o.shape==="rect")a.push(new $fe({pcbX:o.center.x,pcbY:o.center.y,shape:"rect",width:o.width,height:o.height}));else if(o.type==="pcb_hole"&&o.hole_shape==="circle")a.push(new gXe({pcbX:o.x,pcbY:o.y,diameter:o.hole_diameter}));else if(o.type==="pcb_silkscreen_text"){let s=e?parseInt(e):0;const l=(s%360+360)%360;s=l>90&&l<=270?(l+180)%360:l,t.includes("pinrow")&&o.text.includes("PIN")&&n?a.push(npn({elm:o,pinLabels:n,readableRotation:s})):o.text==="{REF}"&&a.push(new Gfe({anchorAlignment:"center",text:r,fontSize:o.font_size+.2,pcbX:isNaN(o.anchor_position.x)?0:o.anchor_position.x,pcbY:o.anchor_position.y,pcbRotation:s??0}))}else o.type==="pcb_trace"&&a.push(new vXe({route:o.route}));return a};function _Xe(r){let e=1/0,t=1/0,n=-1/0,i=-1/0;for(const s of r)if(s.isPcbPrimitive&&!s.componentName.startsWith("Silkscreen")){const{x:l,y:c}=s._getGlobalPcbPositionBeforeLayout(),{width:u,height:f}=s.getPcbSize();e=Math.min(e,l-u/2),t=Math.min(t,c-f/2),n=Math.max(n,l+u/2),i=Math.max(i,c+f/2)}else if(s.componentName==="Footprint"){const l=_Xe(s.children);e=Math.min(e,l.minX),t=Math.min(t,l.minY),n=Math.max(n,l.maxX),i=Math.max(i,l.maxY)}let a=n-e,o=i-t;return a<0&&(a=0),o<0&&(o=0),{minX:e,minY:t,maxX:n,maxY:i,width:a,height:o}}function ipn(r,e){const t=e.x-r.x,n=e.y-r.y;return Math.abs(t)>Math.abs(n)?t>=0?"right":"left":n>=0?"up":"down"}var apn=r=>{if(r.length<=1)return!0;const e=r.map(a=>{const o=a._getPcbCircuitJsonBounds();return{left:o.bounds.left,right:o.bounds.right,top:o.bounds.top,bottom:o.bounds.bottom}}),t=Array(e.length).fill(!1).map(()=>Array(e.length).fill(!1));for(let a=0;a<e.length;a++)for(let o=a+1;o<e.length;o++){const s=e[a],l=e[o];t[a][o]=t[o][a]=!(s.right<l.left||s.left>l.right||s.bottom>l.top||s.top<l.bottom)}const n=new Set,i=a=>{n.add(a);for(let o=0;o<e.length;o++)t[a][o]&&!n.has(o)&&i(o)};return i(0),n.size===e.length},opn=r=>{if(r.length===0)throw new Error("Cannot get center of empty PCB primitives array");const e=r.map(i=>i._getPcbCircuitJsonBounds().center).filter(Boolean),t=e.reduce((i,a)=>i+a.x,0),n=e.reduce((i,a)=>i+a.y,0);return{x:t/e.length,y:n/e.length}},spn=R.object({name:R.string().optional(),pinNumber:R.number().optional(),aliases:R.array(R.string()).optional()}),dS=class extends Jg{constructor(e,t={}){if(!e.name&&e.pinNumber!==void 0&&(e.name=`pin${e.pinNumber}`),!e.name)throw new Error("Port must have a name or a pinNumber");super(e);Qe(this,"source_port_id",null);Qe(this,"pcb_port_id",null);Qe(this,"schematic_port_id",null);Qe(this,"schematicSymbolPortDef",null);Qe(this,"matchedComponents");Qe(this,"facingDirection",null);Qe(this,"originDescription",null);t.originDescription&&(this.originDescription=t.originDescription),this.matchedComponents=[]}get config(){return{componentName:"Port",zodProps:spn}}_getGlobalPcbPositionBeforeLayout(){const e=this.matchedComponents.find(n=>n.isPcbPrimitive),t=this.parent;if(t&&!t.props.footprint)throw new Error(`${t.componentName} "${t.props.name}" does not have a footprint. Add a footprint prop, e.g. <${t.componentName.toLowerCase()} footprint="..." />`);if(!e)throw new Error(`Port ${this} has no matching PCB primitives. This often means the footprint's pads lack matching port hints.`);return(e==null?void 0:e._getGlobalPcbPositionBeforeLayout())??{x:0,y:0}}_getPcbCircuitJsonBounds(){if(!this.pcb_port_id)return super._getPcbCircuitJsonBounds();const{db:e}=this.root,t=e.pcb_port.get(this.pcb_port_id);return{center:{x:t.x,y:t.y},bounds:{left:0,top:0,right:0,bottom:0},width:0,height:0}}_getGlobalPcbPositionAfterLayout(){return this._getPcbCircuitJsonBounds().center}_getPortsInternallyConnectedToThisPort(){const e=this.parent;if(!e||!e._getInternallyConnectedPins)return[];const t=e._getInternallyConnectedPins();for(const n of t)if(n.some(i=>i===this))return n;return[]}_hasSchematicPort(){var n,i;if((n=this.parent)==null?void 0:n.getSchematicSymbol())return!!(this.schematicSymbolPortDef||this._getPortsInternallyConnectedToThisPort().some(o=>o.schematicSymbolPortDef));const t=(i=this==null?void 0:this.parent)==null?void 0:i._getSchematicBoxDimensions();return!!(t&&this.props.pinNumber!==void 0&&t.getPortPositionByPinNumber(this.props.pinNumber))}_getGlobalSchematicPositionBeforeLayout(){var n,i,a;const e=(n=this.parent)==null?void 0:n.getSchematicSymbol();if(e){let o=this.schematicSymbolPortDef;if(!o&&(o=((i=this._getPortsInternallyConnectedToThisPort().find(l=>l.schematicSymbolPortDef))==null?void 0:i.schematicSymbolPortDef)??null,!o))throw new Error(`Couldn't find schematicSymbolPortDef for port ${this.getString()}, searched internally connected ports and none had a schematicSymbolPortDef. Why are we trying to get the schematic position of this port?`);const s=Rc(this.parent.computeSchematicGlobalTransform(),q0(-e.center.x,-e.center.y));return Pr(s,o)}const t=(a=this==null?void 0:this.parent)==null?void 0:a._getSchematicBoxDimensions();if(t&&this.props.pinNumber!==void 0){const o=t.getPortPositionByPinNumber(this.props.pinNumber);if(!o)throw new Error(`Couldn't find position for schematic_port for port ${this.getString()} inside of the schematic box`);return Pr(this.parent.computeSchematicGlobalTransform(),o)}throw new Error(`Couldn't find position for schematic_port for port ${this.getString()}`)}_getGlobalSchematicPositionAfterLayout(){const{db:e}=this.root;if(!this.schematic_port_id)throw new Error(`Can't get schematic port position after layout for "${this.getString()}", no schematic_port_id`);const t=e.schematic_port.get(this.schematic_port_id);if(!t)throw new Error(`Schematic port not found when trying to get post-layout position: ${this.schematic_port_id}`);return t.center}registerMatch(e){this.matchedComponents.push(e)}getNameAndAliases(){const{_parsedProps:e}=this;return Array.from(new Set([...e.aliases??[],...e.name?[e.name]:[],...typeof e.pinNumber=="number"?[`pin${e.pinNumber}`,e.pinNumber.toString()]:[],...this.externallyAddedAliases??[]]))}isMatchingPort(e){return this.isMatchingAnyOf(e.getNameAndAliases())}getPortSelector(){var e;return`.${(e=this.parent)==null?void 0:e.props.name} > port.${this.props.name}`}getAvailablePcbLayers(){return Array.from(new Set(this.matchedComponents.flatMap(e=>e.getAvailablePcbLayers())))}_getDirectlyConnectedTraces(){return this.getSubcircuit().selectAll("trace").filter(n=>n._isExplicitlyConnectedToPort(this))}doInitialSourceRender(){var a,o;const{db:e}=this.root,{_parsedProps:t}=this,n=this.getNameAndAliases(),i=e.source_port.insert({name:t.name,pin_number:t.pinNumber,port_hints:n,source_component_id:(a=this.parent)==null?void 0:a.source_component_id,subcircuit_id:(o=this.getSubcircuit())==null?void 0:o.subcircuit_id});this.source_port_id=i.source_port_id}doInitialSourceParentAttachment(){var t,n,i,a,o;const{db:e}=this.root;if(!((t=this.parent)!=null&&t.source_component_id))throw new Error(`${this.getString()} has no parent source component (parent: ${(n=this.parent)==null?void 0:n.getString()})`);e.source_port.update(this.source_port_id,{source_component_id:(i=this.parent)==null?void 0:i.source_component_id,subcircuit_id:(a=this.getSubcircuit())==null?void 0:a.subcircuit_id}),this.source_component_id=(o=this.parent)==null?void 0:o.source_component_id}doInitialPcbPortRender(){var a,o,s,l,c;if((a=this.root)!=null&&a.pcbDisabled)return;const{db:e}=this.root,{matchedComponents:t}=this;if(!((o=this.parent)!=null&&o.pcb_component_id))throw new Error(`${this.getString()} has no parent pcb component, cannot render pcb_port (parent: ${(s=this.parent)==null?void 0:s.getString()})`);const n=t.filter(u=>u.isPcbPrimitive);if(n.length===0)return;let i=null;if(n.length===1&&(i=n[0]._getPcbCircuitJsonBounds().center),n.length>1){if(!apn(n))throw new Error(`${this.getString()} has multiple non-overlapping pcb matches, unclear how to place pcb_port: ${n.map(u=>u.getString()).join(", ")}. (Note: tscircuit core does not currently allow you to specify internally connected pcb primitives with the same port hints, try giving them different port hints and specifying they are connected externally- or file an issue)`);i=opn(n)}if(i){const u=this.getSubcircuit(),f=e.pcb_port.insert({pcb_component_id:(l=this.parent)==null?void 0:l.pcb_component_id,layers:this.getAvailablePcbLayers(),subcircuit_id:(u==null?void 0:u.subcircuit_id)??void 0,pcb_group_id:((c=this.getGroup())==null?void 0:c.pcb_group_id)??void 0,...i,source_port_id:this.source_port_id});this.pcb_port_id=f.pcb_port_id}else{const u=n[0];throw new Error(`${u.getString()} does not have a center or _getGlobalPcbPositionBeforeLayout method (needed for pcb_port placement)`)}}doInitialSchematicPortRender(){var f;const{db:e}=this.root,{_parsedProps:t}=this,n=this.getPrimitiveContainer();if(!n||!this._hasSchematicPort())return;const i=n._getGlobalSchematicPositionBeforeLayout(),a=this._getGlobalSchematicPositionBeforeLayout();let o=null;const s=n._getSchematicBoxDimensions();s&&t.pinNumber!==void 0&&(o=s.getPortPositionByPinNumber(t.pinNumber)),this.getSubcircuit().props._schDebugObjectsEnabled&&e.schematic_debug_object.insert({shape:"rect",center:a,size:{width:.1,height:.1},label:"obstacle"}),o!=null&&o.side?this.facingDirection={left:"left",right:"right",top:"up",bottom:"down"}[o.side]:this.facingDirection=ipn(i,a);const l=e.source_port.get(this.source_port_id);let c;for(const p of(l==null?void 0:l.port_hints)??[])p.match(/^(pin)?\d+$/)||p.match(/^(left|right)/)&&!(l!=null&&l.name.match(/^(left|right)/))||(c=p);const u=e.schematic_port.insert({schematic_component_id:(f=this.parent)==null?void 0:f.schematic_component_id,center:a,source_port_id:this.source_port_id,facing_direction:this.facingDirection,distance_from_component_edge:.4,side_of_component:o==null?void 0:o.side,pin_number:t.pinNumber,true_ccw_index:o==null?void 0:o.trueIndex,display_pin_label:c});this.schematic_port_id=u.schematic_port_id}_setPositionFromLayout(e){const{db:t}=this.root;this.pcb_port_id&&t.pcb_port.update(this.pcb_port_id,{x:e.x,y:e.y})}_hasMatchedPcbPrimitive(){return this.matchedComponents.some(e=>e.isPcbPrimitive)}},xXe=r=>{const e=r.find(t=>/^(pin)?\d+$/.test(t));return e?Number.parseInt(e.replace(/^pin/,"")):null};function yP(r,e){var a;const t=xXe(r);if(!t)return null;const i=[...r.filter(o=>o.toString()!==t.toString()&&o!==`pin${t}`),...((a=e==null?void 0:e.additionalAliases)==null?void 0:a[`pin${t}`])??[]];return new dS({pinNumber:t,aliases:i})}var lpn=r=>{for(const e of["leftSide","rightSide","topSide","bottomSide"])if(e in r&&typeof r[e]=="number")throw new Error(`A number was specified for "${e}", you probably meant to use "size" not "side"`);return"leftSide"in r||"rightSide"in r||"topSide"in r||"bottomSide"in r},cpn=r=>{var a,o,s,l;if(lpn(r))return{leftSize:((a=r.leftSide)==null?void 0:a.pins.length)??0,rightSize:((o=r.rightSide)==null?void 0:o.pins.length)??0,topSize:((s=r.topSide)==null?void 0:s.pins.length)??0,bottomSize:((l=r.bottomSide)==null?void 0:l.pins.length)??0};const{leftSize:e=0,rightSize:t=0,topSize:n=0,bottomSize:i=0}=r;return{leftSize:e,rightSize:t,topSize:n,bottomSize:i}};function bXe(r){return r.leftSide!==void 0}var upn=r=>{var w,b,C,z,I,G,Y,Z;const e=r.portDistanceFromEdge??.4;let t=r.schPortArrangement?cpn(r.schPortArrangement):null;const n={left:0,right:0,top:0,bottom:0};let i=r.pinCount??null;if(i===null)if(t)i=t.leftSize+t.rightSize+t.topSize;else throw new Error("Could not determine pin count for the schematic box");if(i&&!t){const W=Math.floor(i/2);t={leftSize:i-W,rightSize:W,topSize:0,bottomSize:0}}t||(t={leftSize:0,rightSize:0,topSize:0,bottomSize:0});const a=({side:W,sideIndex:te,truePinIndex:J})=>{var Pe,we,Ce,be;if(!r.schPortArrangement||!bXe(r.schPortArrangement))return J+1;const fe={left:"top-to-bottom",bottom:"left-to-right",right:"bottom-to-top",top:"right-to-left"}[W],he=((we=(Pe=r.schPortArrangement)==null?void 0:Pe[`${W}Side`])==null?void 0:we.direction)??fe,ve=(be=(Ce=r.schPortArrangement)==null?void 0:Ce[`${W}Side`])==null?void 0:be.pins;let Te=te;return he!==fe&&(Te=ve.length-te-1),vP(ve[Te],r.pinLabels)},o=[];let s=0,l=0;for(let W=0;W<t.leftSize;W++){const te=a({side:"left",sideIndex:W,truePinIndex:l}),J=((w=r.numericSchPinStyle)==null?void 0:w[`pin${te}`])??((b=r.numericSchPinStyle)==null?void 0:b[te]);J!=null&&J.topMargin&&(s+=J.topMargin),o.push({trueIndex:l,pinNumber:te,side:"left",distanceFromOrthogonalEdge:s}),J!=null&&J.bottomMargin&&(s+=J.bottomMargin),W===t.leftSize-1?n.left=s:s+=r.schPinSpacing,l++}s=0;for(let W=0;W<t.bottomSize;W++){const te=a({side:"bottom",sideIndex:W,truePinIndex:l}),J=((C=r.numericSchPinStyle)==null?void 0:C[`pin${te}`])??((z=r.numericSchPinStyle)==null?void 0:z[te]);J!=null&&J.leftMargin&&(s+=J.leftMargin),o.push({trueIndex:l,pinNumber:te,side:"bottom",distanceFromOrthogonalEdge:s}),J!=null&&J.rightMargin&&(s+=J.rightMargin),W===t.bottomSize-1?n.bottom=s:s+=r.schPinSpacing,l++}s=0;for(let W=0;W<t.rightSize;W++){const te=a({side:"right",sideIndex:W,truePinIndex:l}),J=((I=r.numericSchPinStyle)==null?void 0:I[`pin${te}`])??((G=r.numericSchPinStyle)==null?void 0:G[te]);J!=null&&J.bottomMargin&&(s+=J.bottomMargin),o.push({trueIndex:l,pinNumber:te,side:"right",distanceFromOrthogonalEdge:s}),J!=null&&J.topMargin&&(s+=J.topMargin),W===t.rightSize-1?n.right=s:s+=r.schPinSpacing,l++}s=0;for(let W=0;W<t.topSize;W++){const te=a({side:"top",sideIndex:W,truePinIndex:l}),J=((Y=r.numericSchPinStyle)==null?void 0:Y[`pin${te}`])??((Z=r.numericSchPinStyle)==null?void 0:Z[te]);J!=null&&J.rightMargin&&(s+=J.rightMargin),o.push({trueIndex:l,pinNumber:te,side:"top",distanceFromOrthogonalEdge:s}),J!=null&&J.leftMargin&&(s+=J.leftMargin),W===t.topSize-1?n.top=s:s+=r.schPinSpacing,l++}let c=r.schWidth;c||(c=Math.max(n.top+r.schPinSpacing*2,n.bottom+r.schPinSpacing*2));const u=r.pinLabels?Math.max(...Object.values(r.pinLabels).map(W=>W.length*.1)):0,f=u>0?1.1:0;c=Math.max(c,u+f);let p=r.schHeight;p||(p=Math.max(n.left+r.schPinSpacing*2,n.right+r.schPinSpacing*2));const v={left:{x:-c/2-e,y:n.left/2},bottom:{x:-n.bottom/2,y:-p/2-e},right:{x:c/2+e,y:-n.right/2},top:{x:n.top/2,y:p/2+e}},x={left:{x:0,y:-1},right:{x:0,y:1},top:{x:-1,y:0},bottom:{x:1,y:0}},S=o.map(W=>{const{distanceFromOrthogonalEdge:te,side:J}=W,fe=v[J],he=x[J];return{x:fe.x+te*he.x,y:fe.y+te*he.y,...W}});return{getPortPositionByPinNumber(W){const te=S.find(J=>J.pinNumber.toString()===W.toString());return te||null},getSize(){return{width:c,height:p}},getSizeIncludingPins(){return{width:c+(t.leftSize||t.rightSize?.4:0),height:p+(t.topSize||t.bottomSize?.4:0)}},pinCount:i}},fpn=P9("tscircuit:core:footprint"),dpn=class extends Jg{get config(){return{componentName:"Footprint",zodProps:odn}}doInitialPcbFootprintLayout(){var f,p,v,x,S;if((f=this.root)!=null&&f.pcbDisabled)return;const r=this.children.filter(w=>w.componentName==="Constraint");if(r.length===0)return;const{isFlipped:e}=this._getPcbPrimitiveFlippedHelpers(),t=w=>e&&"left"in w&&"right"in w?{...w,left:w.right,right:w.left}:w,n=r.flatMap(w=>w._getAllReferencedComponents().componentsWithSelectors).map(({component:w,selector:b,componentSelector:C,edge:z})=>({component:w,selector:b,componentSelector:C,edge:z,bounds:w._getPcbCircuitJsonBounds()}));if(n.some(w=>w.edge))throw new Error("edge constraints not implemented yet for footprint layout, contributions welcome!");function i(w){return n.find(({selector:b})=>b===w)}const a=new pq,o={};function s(w){return w in o||(o[w]=new kM(w),a.addEditVariable(o[w],ov.weak)),o[w]}for(const{selector:w,bounds:b}of n){const C=s(`${w}_x`),z=s(`${w}_y`);a.suggestValue(C,b.center.x),a.suggestValue(z,b.center.y)}for(const w of r){const b=w._parsedProps;if("xDist"in b){const{xDist:C,left:z,right:I,edgeToEdge:G,centerToCenter:Y}=t(b),Z=s(`${z}_x`),W=s(`${I}_x`),te=(p=i(z))==null?void 0:p.bounds,J=(v=i(I))==null?void 0:v.bounds;if(Y){const fe=new N9(W,[-1,Z]);a.addConstraint(new xx(fe,mg.Eq,b.xDist,ov.required))}else if(G){const fe=new N9(W,-J.width/2,[-1,Z],-te.width/2);a.addConstraint(new xx(fe,mg.Eq,b.xDist,ov.required))}}else if("yDist"in b){const{yDist:C,top:z,bottom:I,edgeToEdge:G,centerToCenter:Y}=b,Z=s(`${z}_y`),W=s(`${I}_y`),te=(x=i(z))==null?void 0:x.bounds,J=(S=i(I))==null?void 0:S.bounds;if(Y){const fe=new N9(Z,[-1,W]);a.addConstraint(new xx(fe,mg.Eq,b.yDist,ov.required))}else if(G){const fe=new N9(Z,te.height/2,[-1,W],-J.height/2);a.addConstraint(new xx(fe,mg.Eq,b.yDist,ov.required))}}else if("sameY"in b){const{for:C}=b;if(C.length<2)continue;const z=C.map(G=>s(`${G}_y`)),I=new N9(...z.slice(1));a.addConstraint(new xx(I,mg.Eq,z[0],ov.required))}else if("sameX"in b){const{for:C}=b;if(C.length<2)continue;const z=C.map(G=>s(`${G}_x`)),I=new N9(...z.slice(1));a.addConstraint(new xx(I,mg.Eq,z[0],ov.required))}}a.updateVariables(),fpn.enabled&&(console.log("Solution to layout constraints:"),console.table(Object.entries(o).map(([w,b])=>({var:w,val:b.value()}))));const l={left:1/0,right:-1/0,top:-1/0,bottom:1/0};for(const{selector:w,bounds:{width:b,height:C}}of n){const z=s(`${w}_x`),I=s(`${w}_y`),G=z.value()-b/2,Y=z.value()+b/2,Z=I.value()+C/2,W=I.value()-C/2;l.left=Math.min(l.left,G),l.right=Math.max(l.right,Y),l.top=Math.max(l.top,Z),l.bottom=Math.min(l.bottom,W)}const c={x:-(l.right+l.left)/2,y:-(l.top+l.bottom)/2},u=this.getPrimitiveContainer()._getGlobalPcbPositionBeforeLayout();c.x+=u.x,c.y+=u.y;for(const{component:w,selector:b}of n){const C=s(`${b}_x`),z=s(`${b}_y`);w._setPositionFromLayout({x:C.value()+c.x,y:z.value()+c.y})}}},ppn=(r,e)=>{if(!r)return;const t={};for(const[n,i]of Object.entries(r)){const a=vP(n,e),o={leftMargin:i.marginLeft??i.leftMargin,rightMargin:i.marginRight??i.rightMargin,topMargin:i.marginTop??i.topMargin,bottomMargin:i.marginBottom??i.bottomMargin};t[`pin${a}`]={...t[`pin${a}`],...o}}return t},SXe=class{constructor({input:r}){Qe(this,"input");this.input=r}solveAndMapToTraces(){const r=[];for(const e of this.input.connections){if(e.pointsToConnect.length!==2)continue;const[t,n]=e.pointsToConnect,i={type:"pcb_trace",pcb_trace_id:"",connection_name:e.name,route:[{route_type:"wire",x:t.x,y:t.y,layer:"top",width:.1},{route_type:"wire",x:n.x,y:n.y,layer:"top",width:.1}]};r.push(i)}return r}},hpn=r=>{const e=Math.min(...r.map(a=>a.center.x)),t=Math.max(...r.map(a=>a.center.x)),n=Math.min(...r.map(a=>a.center.y)),i=Math.max(...r.map(a=>a.center.y));return{minX:e,maxX:t,minY:n,maxY:i}},wXe=["top","bottom","inner1","inner2"],vj=(r,e=[])=>{var s;const t=[];if(e.length===0){const l=r[0].layers;for(const c of l)t.push(...vj(r.slice(1),[c]));return t}if(r.length===0)return[];const n=r[0],i=n.via||n.optional_via,a=e[e.length-1];if(r.length===1){const l=n;return l.layers&&i?l.layers.map(c=>({layer_path:[...e,c]})):(s=l.layers)!=null&&s.includes(a)?[{layer_path:[...e,a]}]:[]}if(!i)return n.layers&&!n.layers.includes(a)?[]:vj(r.slice(1),e.concat([a]));const o=(n.optional_via?wXe:wXe.filter(l=>l!==a)).filter(l=>{var c;return!n.layers||((c=n.layers)==null?void 0:c.includes(l))});for(const l of o)t.push(...vj(r.slice(1),e.concat(l)));return t};function EXe(r){const e={x:r.to.x-r.from.x,y:r.to.y-r.from.y},t=Math.abs(e.x),n=Math.abs(e.y);return t>n?e.x>0?"right":"left":e.y>0?"down":"up"}function IT(r,e){return Math.hypot(r.x-e.x,r.y-e.y)}var mpn=r=>{if(r.length===1)return r[0];if(r.some(l=>l.length===0))throw new Error("Cannot merge routes with zero length");const e=[],t=r[0][0],n=r[0][r[0].length-1],i=r[1][0],a=r[1][r[1].length-1],o=Math.min(IT(t,i),IT(t,a)),s=Math.min(IT(n,i),IT(n,a));o<s?e.push(...r[0].reverse()):e.push(...r[0]);for(let l=1;l<r.length;l++){const c=e[e.length-1],u=r[l],f=u[0],p=u[u.length-1],v=IT(c,f),x=IT(c,p);v<x?e.push(...u):e.push(...u.reverse())}for(let l=1;l<e.length-1;l++){const c=e[l-1],u=e[l];c.route_type==="wire"&&u.route_type==="wire"&&c.layer!==u.layer&&e.splice(l,0,{x:c.x,y:c.y,from_layer:c.layer,to_layer:u.layer,route_type:"via"})}return e},vpn=(r,e)=>{const t="_getGlobalPcbPositionBeforeLayout"in r?r._getGlobalPcbPositionBeforeLayout():r,n="_getGlobalPcbPositionBeforeLayout"in e?e._getGlobalPcbPositionBeforeLayout():e;return Math.sqrt((t.x-n.x)**2+(t.y-n.y)**2)};function ypn(r,e){if(e.length===0)throw new Error("No candidates given to getClosest method");let t=e[0],n=1/0;for(const i of e){const a=vpn(r,i);a<n&&(t=i,n=a)}return t}var gpn=(r,e)=>{let t=0;t+=r.length??0,t+=e.filter(n=>n.is_crossing).length;for(let n=1;n<e.length;n++){const i=e[n-1],a=e[n],o=Math.abs(i.from.x-i.to.x)<.01,s=Math.abs(a.from.x-a.to.x)<.01;o!==s&&t++}return t},qfe=r=>({up:"bottom",down:"top",left:"right",right:"left"})[r]??null,Yfe=({firstEdge:r,firstEdgePort:e,firstDominantDirection:t,lastEdge:n,lastEdgePort:i,lastDominantDirection:a})=>{if(r&&e)return Yfe({lastEdge:{from:r.to,to:r.from},lastEdgePort:e,lastDominantDirection:t}).reverse().map(s=>({from:s.to,to:s.from}));let o=[];if(n&&i){const s={x:n.to.x,y:n.to.y};a==="left"||a==="right"?(s.x=i.position.x,o.push({from:n.to,to:{...s}}),o.push({from:s,to:{...i.position}})):(s.y=i.position.y,o.push({from:n.to,to:{...s}}),o.push({from:s,to:{...i.position}}))}return o=o.filter(s=>lS(s.from,s.to)>.01),o};function _pn(r){try{return[r(),null]}catch(e){return[null,e]}}function xpn(r){let e=0;for(let t=0;t<r.length;t++){const n=r[t];if(n.route_type==="wire"){const i=r[t+1];if(i){const a=i.x-n.x,o=i.y-n.y;e+=Math.sqrt(a*a+o*o)}}else n.route_type==="via"&&(e+=1.6)}return e}var bpn=r=>{var s,l;const e={left:{x:-.5,y:0},up:{x:.5,y:.5},right:{x:.5,y:0},down:{x:0,y:-.5}}[r.facingDirection],t=(s=r.parent)!=null&&s.config.shouldRenderAsSchematicBox?3:1,n=(l=r.parent)!=null&&l.config.shouldRenderAsSchematicBox&&(r.facingDirection==="left"||r.facingDirection==="right")?3:1,i=e.x,a=e.y,o=r.facingDirection==="up"?.5:0;return{schBoxVertOffset:t,schBoxHorzOffset:n,horzPortDirection:i,vertPortDirectionOffset:a,handleUp:o}},yj=({port:r,anchorPos:e,schDisplayLabel:t,source_trace_id:n},{db:i})=>{const a=bpn(r);i.schematic_net_label.insert({anchor_side:"top",center:{x:e.x+a.horzPortDirection*a.schBoxHorzOffset,y:e.y+a.vertPortDirectionOffset*a.schBoxVertOffset},source_net_id:r.source_port_id,text:t,anchor_position:{x:e.x+a.horzPortDirection*a.schBoxHorzOffset,y:e.y+a.vertPortDirectionOffset*a.schBoxVertOffset},symbol_name:"ground_horz"}),i.schematic_trace.insert({edges:[{from:{x:e.x,y:e.y},to:{x:e.x,y:e.y+a.handleUp*a.schBoxVertOffset}},{from:{x:e.x,y:e.y},to:{x:e.x+a.horzPortDirection*a.schBoxHorzOffset,y:e.y+a.vertPortDirectionOffset*a.schBoxVertOffset}}],junctions:[{x:e.x+a.horzPortDirection*a.schBoxHorzOffset,y:e.y+a.vertPortDirectionOffset*a.schBoxVertOffset}],source_trace_id:n})},Xfe=({db:r,source_trace_id:e,sameNetOnly:t,differentNetOnly:n})=>{!t&&!n&&(n=!0);const i=r.source_trace.get(e),a=[];for(const o of r.schematic_trace.list()){if(o.source_trace_id===e)continue;const s=r.source_trace.get(o.source_trace_id),l=(s==null?void 0:s.subcircuit_connectivity_map_key)===i.subcircuit_connectivity_map_key;n&&l||t&&!l||a.push(o)}return a},Spn=({edges:r,otherEdges:e})=>{const t=[...r];for(let n=0;n<t.length;n++){if(n>2e3)throw new Error("Over 2000 iterations spent inside createSchematicTraceCrossingSegments, you have triggered an infinite loop, please report this!");const i=t[n],a=Math.abs(i.from.x-i.to.x)<.01?"vertical":i.from.y===i.to.y?"horizontal":"not-orthogonal";if(a==="not-orthogonal")continue;const o=[];for(const S of e){const w=S.from.x===S.to.x?"vertical":S.from.y===S.to.y?"horizontal":"not-orthogonal";if(w==="not-orthogonal"||a===w)continue;if(aqe([i.from,i.to],[S.from,S.to],{lineThickness:.01})){const C=a==="vertical"?i.from.x:S.from.x,z=a==="vertical"?S.from.y:i.from.y,I={x:C,y:z};o.push({otherEdge:S,crossingPoint:I,distanceFromEdgeFrom:lS(i.from,I)})}}if(o.length===0)continue;let s=o[0];for(const S of o)S.distanceFromEdgeFrom<s.distanceFromEdgeFrom&&(s=S);const l=s.crossingPoint,c=.075;if(l.x===i.from.x&&l.y===i.from.y)continue;const u=Mcn(i.from,l),f={x:l.x-u.x*c/2,y:l.y-u.y*c/2},p={x:l.x+u.x*c/2,y:l.y+u.y*c/2},v=lS(p,i.to)<c,x=[{from:i.from,to:f},{from:f,to:p,is_crossing:!0},{from:p,to:i.to}];t.splice(n,1,...x),n+=x.length-2,v&&n++}return t},wpn=(r,e)=>{if(r.from.x===r.to.x&&e.from.x===e.to.x)return null;if(r.from.x===r.to.x){const u=r.from.x,f=(e.to.y-e.from.y)/(e.to.x-e.from.x),p=e.from.y-f*e.from.x,v=f*u+p;return u>=Math.min(e.from.x,e.to.x)&&u<=Math.max(e.from.x,e.to.x)&&v>=Math.min(e.from.y,e.to.y)&&v<=Math.max(e.from.y,e.to.y)?{x:u,y:v}:null}if(e.from.x===e.to.x){const u=e.from.x,f=(r.to.y-r.from.y)/(r.to.x-r.from.x),p=r.from.y-f*r.from.x,v=f*u+p;return u>=Math.min(r.from.x,r.to.x)&&u<=Math.max(r.from.x,r.to.x)&&v>=Math.min(r.from.y,r.to.y)&&v<=Math.max(r.from.y,r.to.y)?{x:u,y:v}:null}const t=(r.to.y-r.from.y)/(r.to.x-r.from.x),n=r.from.y-t*r.from.x,i=(e.to.y-e.from.y)/(e.to.x-e.from.x),a=e.from.y-i*e.from.x;if(t===i)return null;const o=(a-n)/(t-i),s=t*o+n,l=o>=Math.min(r.from.x,r.to.x)&&o<=Math.max(r.from.x,r.to.x)&&s>=Math.min(r.from.y,r.to.y)&&s<=Math.max(r.from.y,r.to.y),c=o>=Math.min(e.from.x,e.to.x)&&o<=Math.max(e.from.x,e.to.x)&&s>=Math.min(e.from.y,e.to.y)&&s<=Math.max(e.from.y,e.to.y);return l&&c?{x:o,y:s}:null},Epn=({edges:r,db:e,source_trace_id:t})=>{const n=Xfe({db:e,source_trace_id:t,sameNetOnly:!0}).flatMap(i=>i.edges);for(const i of r)for(const a of n){const o=wpn(i,a);if(o)return`${o.x}${o.y}`,[{x:o.x,y:o.y}]}return[]},Tpn=(r,{db:e})=>{const t=r.map(n=>{const i=e.source_port.get(n.source_port_id);if(!(i!=null&&i.source_component_id))return null;const a=e.source_component.get(i.source_component_id);return(a==null?void 0:a.ftype)==="simple_capacitor"?a.max_decoupling_trace_length:null}).filter(n=>n!==null);if(t.length!==0)return Math.min(...t)};function Mpn(r){var a,o,s,l,c,u,f,p,v;let e=1/0,t=1/0,n=-1/0,i=-1/0;for(const x of r){let S,w,b,C;x.type==="schematic_component"?(S=(a=x.center)==null?void 0:a.x,w=(o=x.center)==null?void 0:o.y,b=(s=x.size)==null?void 0:s.width,C=(l=x.size)==null?void 0:l.height):x.type==="schematic_box"?(S=x.x,w=x.y,b=x.width,C=x.height):x.type==="schematic_port"?(S=(c=x.center)==null?void 0:c.x,w=(u=x.center)==null?void 0:u.y,b=.2,C=.2):x.type==="schematic_text"&&(S=(f=x.position)==null?void 0:f.x,w=(p=x.position)==null?void 0:p.y,b=(((v=x.text)==null?void 0:v.length)??0)*.1,C=.2),typeof S=="number"&&typeof w=="number"&&typeof b=="number"&&typeof C=="number"&&(e=Math.min(e,S-b/2),n=Math.max(n,S+b/2),t=Math.min(t,w-C/2),i=Math.max(i,w+C/2))}return{minX:e,maxX:n,minY:t,maxY:i}}function Cpn(r,e={}){const{minX:t,maxX:n,minY:i,maxY:a}=r,o=e.padding??1;if(!isFinite(t)||!isFinite(n)||!isFinite(i)||!isFinite(a))return[];const s=t-o,l=n+o,c=a+o,u=i-o,f=.01;return[{type:"rect",layers:["top"],center:{x:(s+l)/2,y:c},width:l-s,height:f,connectedTo:[]},{type:"rect",layers:["top"],center:{x:(s+l)/2,y:u},width:l-s,height:f,connectedTo:[]},{type:"rect",layers:["top"],center:{x:s,y:(c+u)/2},width:f,height:c-u,connectedTo:[]},{type:"rect",layers:["top"],center:{x:l,y:(c+u)/2},width:f,height:c-u,connectedTo:[]}]}var Rpn=r=>{var o;const e=r.root.db,t=r._findConnectedPorts().ports??[],n=new Set(t.map(s=>s.schematic_port_id)),i=[];for(const s of e.toArray()){if(s.type==="schematic_component"){const l=!!s.symbol_name,c=s.size.width>s.size.height?"horz":"vert";i.push({type:"rect",layers:["top"],center:s.center,width:s.size.width+(l&&c==="horz"?-.5:0),height:s.size.height+(l&&c==="vert"?-.5:0),connectedTo:[]})}if(s.type==="schematic_port"){if(n.has(s.schematic_port_id))continue;const l=s.facing_direction?Ccn(s.facing_direction):{x:0,y:0};i.push({type:"rect",layers:["top"],center:{x:s.center.x-l.x*.1,y:s.center.y-l.y*.1},width:.1+Math.abs(l.x)*.3,height:.1+Math.abs(l.y)*.3,connectedTo:[]})}s.type==="schematic_text"&&i.push({type:"rect",layers:["top"],center:s.position,width:(((o=s.text)==null?void 0:o.length)??0)*.1,height:.2,connectedTo:[]}),s.type==="schematic_box"&&i.push({type:"rect",layers:["top"],center:{x:s.x,y:s.y},width:s.width,height:s.height,connectedTo:[]})}const a=Mpn(e.toArray());return i.push(...Cpn(a,{padding:1})),i};function Apn({ports:r,nets:e}){var t,n,i;if(r.length>=2)return`${(t=r[0])==null?void 0:t.selector} to ${(n=r[1])==null?void 0:n.selector}`;if(r.length===1&&e.length===1)return`${(i=r[0])==null?void 0:i.selector} to net.${e[0]._parsedProps.name}`}var Ppn=({edges:r,db:e,source_trace_id:t})=>{e.source_trace.get(t);const n=Xfe({db:e,source_trace_id:t,differentNetOnly:!0}).flatMap(a=>a.edges),i=a=>{const{from:o,to:s}=a;return o.x===s.x?"vertical":"horizontal"};for(const a of r){const o=i(a),s=()=>n.find(c=>i(c)===o&&aqe([a.from,a.to],[c.from,c.to],{lineThickness:.05}));let l=s();for(;l;)o==="horizontal"?(a.from.y+=.1,a.to.y+=.1):(a.from.x+=.1,a.to.x+=.1),l=s()}},Npn=(r,{db:e})=>{const t=e.pcb_board.list()[0];if(t.outline){const l=t.outline,c=(u,f)=>{let p=!1;for(let v=0,x=f.length-1;v<f.length;x=v++){const S=f[v].x,w=f[v].y,b=f[x].x,C=f[x].y;w>u.y!=C>u.y&&u.x<(b-S)*(u.y-w)/(C-w)+S&&(p=!p)}return p};return r.some(u=>!c(u,l))}const n=t.width,i=t.height,a=t.center.x,o=t.center.y;return r.some(l=>l.x<a-n/2||l.y<o-i/2||l.x>a+n/2||l.y>o+i/2)},gj=r=>({...r._getGlobalPcbPositionAfterLayout(),layers:r.getAvailablePcbLayers()}),cw=class extends Jg{constructor(e){super(e);Qe(this,"source_trace_id",null);Qe(this,"pcb_trace_id",null);Qe(this,"schematic_trace_id",null);Qe(this,"_portsRoutedOnPcb");Qe(this,"subcircuit_connectivity_map_key",null);Qe(this,"_traceConnectionHash",null);this._portsRoutedOnPcb=[]}get config(){return{zodProps:adn,componentName:"Trace"}}_getTracePortOrNetSelectorListFromProps(){return"from"in this.props&&"to"in this.props?[typeof this.props.from=="string"?this.props.from:this.props.from.getPortSelector(),typeof this.props.to=="string"?this.props.to:this.props.to.getPortSelector()]:"path"in this.props?this.props.path.map(e=>typeof e=="string"?e:e.getPortSelector()):[]}getTracePortPathSelectors(){return this._getTracePortOrNetSelectorListFromProps().filter(e=>!e.includes("net."))}getTracePathNetSelectors(){return this._getTracePortOrNetSelectorListFromProps().filter(e=>e.includes("net."))}_findConnectedPorts(){const{db:e}=this.root,{_parsedProps:t,parent:n}=this;if(!n)throw new Error("Trace has no parent");const a=this.getTracePortPathSelectors().map(o=>({selector:o,port:this.getSubcircuit().selectOne(o,{type:"port"})??null}));for(const{selector:o,port:s}of a)if(!s){const l=o.replace(/(\> )?[^ ]+$/,""),c=this.getSubcircuit().selectOne(l);c?this.renderError(`Could not find port for selector "${o}" (did you forget to include the pin name?)
|
|
13425
|
-
searched component ${c.getString()}, which has ports: ${c.children.filter(u=>u.componentName==="Port").map(u=>`${u.getString()}(${u.getNameAndAliases().join(",")})`).join(" & ")}`):this.renderError(`Could not find port for selector "${o}"`)}return a.some(o=>!o.port)?{allPortsFound:!1}:{allPortsFound:!0,portsWithSelectors:a,ports:a.map(({port:o})=>o)}}_findConnectedNets(){const e=this.getTracePathNetSelectors().map(n=>({selector:n,net:this.getSubcircuit().selectOne(n,{type:"net"})})),t=e.filter(n=>!n.net);return t.length>0&&this.renderError(`Could not find net for selector "${t[0].selector}" inside ${this}`),{netsWithSelectors:e,nets:e.map(n=>n.net)}}_getAllTracesConnectedToSameNet(){const e=this.getSubcircuit().selectAll("trace"),t=this._findConnectedNets().nets,n=this._findConnectedPorts().ports??[];return e.filter(i=>{if(i===this)return!1;const a=i._findConnectedNets().nets,o=i._findConnectedPorts().ports??[];return a.some(s=>t.includes(s))||o.some(s=>n.includes(s))})}_isExplicitlyConnectedToPort(e){const{allPortsFound:t,portsWithSelectors:n}=this._findConnectedPorts();return t?n.map(a=>a.port).includes(e):!1}_isExplicitlyConnectedToNet(e){return this._findConnectedNets().nets.includes(e)}doInitialCreateNetsFromProps(){hXe(this,this.getTracePathNetSelectors())}_computeTraceConnectionHash(){const{allPortsFound:e,ports:t}=this._findConnectedPorts();return!e||!t?null:[...t].sort((a,o)=>(a.pcb_port_id||"").localeCompare(o.pcb_port_id||"")).map(a=>a.pcb_port_id).join(",")}doInitialSourceTraceRender(){var f;const{db:e}=this.root,{_parsedProps:t,parent:n}=this;if(!n){this.renderError("Trace has no parent");return}const{allPortsFound:i,portsWithSelectors:a}=this._findConnectedPorts();if(!i)return;this._traceConnectionHash=this._computeTraceConnectionHash();const s=e.source_trace.list().find(p=>p.subcircuit_connectivity_map_key===this.subcircuit_connectivity_map_key&&p.connected_source_port_ids.sort().join(",")===this._traceConnectionHash);if(s){this.source_trace_id=s.source_trace_id;return}const l=this._findConnectedNets().nets,c=Apn({ports:a,nets:l}),u=e.source_trace.insert({connected_source_port_ids:a.map(p=>p.port.source_port_id),connected_source_net_ids:l.map(p=>p.source_net_id),subcircuit_id:(f=this.getSubcircuit())==null?void 0:f.subcircuit_id,max_length:Tpn(a.map(p=>p.port),{db:e})??t.maxLength,display_name:c,min_trace_thickness:t.thickness});this.source_trace_id=u.source_trace_id}_insertErrorIfTraceIsOutsideBoard(e,t){const{db:n}=this.root;Npn(e,{db:n})&&n.pcb_trace_error.insert({error_type:"pcb_trace_error",source_trace_id:this.source_trace_id,message:`Trace ${this.getString()} routed outside the board boundaries.`,pcb_trace_id:this.pcb_trace_id,pcb_component_ids:[],pcb_port_ids:t.map(a=>a.pcb_port_id)})}doInitialPcbTraceRender(){var W,te,J,fe;if((W=this.root)!=null&&W.pcbDisabled)return;const{db:e}=this.root,{_parsedProps:t,parent:n}=this,i=this.getSubcircuit();if(!n)throw new Error("Trace has no parent");if(i._parsedProps.routingDisabled)return;const a=(te=i._parsedProps.pcbRouteCache)==null?void 0:te.pcbTraces;if(a){const he=e.pcb_trace.insert({route:a.flatMap(ve=>ve.route),source_trace_id:this.source_trace_id,subcircuit_id:(i==null?void 0:i.subcircuit_id)??void 0,pcb_group_id:((J=this.getGroup())==null?void 0:J.pcb_group_id)??void 0});this.pcb_trace_id=he.pcb_trace_id;return}if(!i._shouldUseTraceByTraceRouting())return;const{allPortsFound:o,ports:s}=this._findConnectedPorts();if(!o)return;const l=[];for(const he of s)he._hasMatchedPcbPrimitive()||l.push(he);if(l.length>0){e.pcb_trace_error.insert({error_type:"pcb_trace_error",source_trace_id:this.source_trace_id,message:`Some ports did not have a matching PCB primitive (e.g. a pad or plated hole), this can happen if a footprint is missing. As a result, ${this} wasn't routed. Missing ports: ${l.map(he=>he.getString()).join(", ")}`,pcb_trace_id:this.pcb_trace_id,pcb_component_ids:[],pcb_port_ids:l.map(he=>he.pcb_port_id).filter(Boolean)});return}const c=this._findConnectedNets().netsWithSelectors;if(s.length===0&&c.length===2){this.renderError("Trace connects two nets, we haven't implemented a way to route this yet");return}else if(s.length===1&&c.length===1){const he=s[0],Te=c[0].net.getAllConnectedPorts().filter(we=>we!==he);if(Te.length===0){console.log("Nothing to connect this port to, the net is empty. TODO should emit a warning!");return}const Pe=ypn(he,Te);s.push(Pe)}else if(s.length>1&&c.length>=1){this.renderError("Trace has more than one port and one or more nets, we don't currently support this type of complex trace routing");return}const u=s.flatMap(he=>he.matchedComponents.filter(ve=>ve.componentName==="TraceHint")),f=(this._parsedProps.pcbRouteHints??[]).concat(u.flatMap(he=>he.getPcbRouteHints()));if(s.length>2){this.renderError(`Trace has more than two ports (${s.map(he=>he.getString()).join(", ")}), routing between more than two ports for a single trace is not implemented`);return}if(this.getSubcircuit().selectAll("trace").filter(he=>he.renderPhaseStates.PcbTraceRender.initialized).some(he=>he._portsRoutedOnPcb.length===s.length&&he._portsRoutedOnPcb.every(ve=>s.includes(ve))))return;let x=[];f.length===0?x=[gj(s[0]),gj(s[1])]:x=[gj(s[0]),...f,gj(s[1])];const S=vj(x),w=M8(this.root.db.toArray()),[b,C]=_pn(()=>$w(this.root.db.toArray()));if(C){this.renderError({type:"pcb_trace_error",error_type:"pcb_trace_error",pcb_trace_error_id:this.pcb_trace_id,message:`Error getting obstacles for autorouting: ${C.message}`,source_trace_id:this.source_trace_id,center:{x:0,y:0},pcb_port_ids:s.map(he=>he.pcb_port_id),pcb_trace_id:this.pcb_trace_id,pcb_component_ids:[]});return}for(const he of b)if(he.connectedTo.length>0){const Te=w.getNetConnectedToId(he.connectedTo[0]);Te&&he.connectedTo.push(Te)}let z=[];if(S.length===0)z=x;else{const he=S[0].layer_path;z=x.map((ve,Te)=>ve.via?{...ve,via_to_layer:he[Te]}:{...ve,layers:[he[Te]]})}z[0].pcb_port_id=s[0].pcb_port_id,z[z.length-1].pcb_port_id=s[1].pcb_port_id;const I=[];for(const[he,ve]of dXe(z)){const Te="via_to_layer"in he?he.via_to_layer:null,Pe=2,we="layers"in he&&he.layers.length===1?he.layers[0]:Te??"top",Ce="layers"in ve&&ve.layers.length===1?ve.layers[0]:Te??"top",be="pcb_port_id"in he?he.pcb_port_id:null,Le="pcb_port_id"in ve?ve.pcb_port_id:null,Ue=this.getSubcircuit()._parsedProps.minTraceWidth??.16,Ie=new Vw({OBSTACLE_MARGIN:Ue*2,isRemovePathLoopsEnabled:!0,optimizeWithGoalBoxes:!!(be&&Le),connMap:w,input:{obstacles:b,minTraceWidth:Ue,connections:[{name:this.source_trace_id,pointsToConnect:[{...he,layer:we,pcb_port_id:be},{...ve,layer:Ce,pcb_port_id:Le}]}],layerCount:2,bounds:{minX:Math.min(he.x,ve.x)-Pe,maxX:Math.max(he.x,ve.x)+Pe,minY:Math.min(he.y,ve.y)-Pe,maxY:Math.max(he.y,ve.y)+Pe}}});let ke=null;try{ke=Ie.solveAndMapToTraces()}catch(gt){this.renderError({type:"pcb_trace_error",pcb_trace_error_id:this.source_trace_id,error_type:"pcb_trace_error",message:`error solving route: ${gt.message}`,source_trace_id:this.pcb_trace_id,center:{x:(he.x+ve.x)/2,y:(he.y+ve.y)/2},pcb_port_ids:s.map(wt=>wt.pcb_port_id),pcb_trace_id:this.pcb_trace_id,pcb_component_ids:s.map(wt=>wt.pcb_component_id)})}if(!ke)return;if(ke.length===0){this.renderError({type:"pcb_trace_error",error_type:"pcb_trace_error",pcb_trace_error_id:this.pcb_trace_id,message:`Could not find a route for ${this}`,source_trace_id:this.source_trace_id,center:{x:(he.x+ve.x)/2,y:(he.y+ve.y)/2},pcb_port_ids:s.map(gt=>gt.pcb_port_id),pcb_trace_id:this.pcb_trace_id,pcb_component_ids:s.map(gt=>gt.pcb_component_id)});return}const[at]=ke;Te&&(at.route=at.route.map(gt=>(gt.route_type==="wire"&&!gt.layer&&(gt.layer=Te),gt))),be&&at.route[0].route_type==="wire"&&(at.route[0].start_pcb_port_id=be);const nt=at.route[at.route.length-1];Le&&nt.route_type==="wire"&&(nt.end_pcb_port_id=Le),I.push(at.route)}const G=mpn(I),Y=xpn(G),Z=e.pcb_trace.insert({route:G,source_trace_id:this.source_trace_id,subcircuit_id:(fe=this.getSubcircuit())==null?void 0:fe.subcircuit_id,trace_length:Y});this._portsRoutedOnPcb=s,this.pcb_trace_id=Z.pcb_trace_id;for(const he of G)he.route_type==="via"&&e.pcb_via.insert({pcb_trace_id:Z.pcb_trace_id,x:he.x,y:he.y,hole_diameter:.3,outer_diameter:.6,layers:[he.from_layer,he.to_layer],from_layer:he.from_layer,to_layer:he.to_layer});this._insertErrorIfTraceIsOutsideBoard(G,s)}_doInitialSchematicTraceRenderWithDisplayLabel(){var I,G,Y,Z;if((I=this.root)!=null&&I.schematicDisabled)return;const{db:e}=this.root,{_parsedProps:t,parent:n}=this;if(!n)throw new Error("Trace has no parent");const{allPortsFound:i,portsWithSelectors:a}=this._findConnectedPorts();if(!i)return;const o=a.map(({port:W})=>({port:W,position:W._getGlobalSchematicPositionAfterLayout(),schematic_port_id:W.schematic_port_id,facingDirection:W.facingDirection}));if(o.length<2)throw new Error("Expected at least two ports in portsWithPosition.");let s,l;const c=o[0].position,u=o[0].port;if("path"in this.props){if(this.props.path.length!==2)throw new Error("Invalid 'path': Must contain exactly two elements.");[s,l]=this.props.path}else{if(!("from"in this.props&&"to"in this.props))throw new Error("Missing 'from' or 'to' properties in props.");s=this.props.from,l=this.props.to}if(!u.source_port_id)throw new Error(`Missing source_port_id for the 'from' port (${s}).`);const f=o[1].position,p=o[1].port;if(!p.source_port_id)throw new Error(`Missing source_port_id for the 'to' port (${l}).`);const v=e.schematic_net_label.list().find(W=>W.source_net_id===u.source_port_id),x=e.schematic_net_label.list().find(W=>W.source_net_id===p.source_port_id),[S,w]=a.map(({port:W})=>W),C=((G=S.parent)==null?void 0:G.config.shouldRenderAsSchematicBox)?`${(Y=S==null?void 0:S.parent)==null?void 0:Y.props.name}_${S==null?void 0:S.props.name}`:`${(Z=w==null?void 0:w.parent)==null?void 0:Z.props.name}_${w==null?void 0:w.props.name}`,z=this.props.schDisplayLabel??C;if(v&&v.text!==z&&(v.text=`${z} / ${v.text}`),x&&(x==null?void 0:x.text)!==z&&(x.text=`${z} / ${x.text}`),z!=null&&z.toLocaleLowerCase().includes("gnd")||z!=null&&z.toLocaleLowerCase().includes("ground")){!v&&!x?(yj({port:u,anchorPos:c,schDisplayLabel:this.props.schDisplayLabel,source_trace_id:this.source_trace_id},{db:e}),yj({port:p,anchorPos:f,schDisplayLabel:this.props.schDisplayLabel,source_trace_id:this.source_trace_id},{db:e})):v?x||yj({port:p,anchorPos:f,schDisplayLabel:this.props.schDisplayLabel,source_trace_id:this.source_trace_id},{db:e}):yj({port:u,anchorPos:c,schDisplayLabel:this.props.schDisplayLabel,source_trace_id:this.source_trace_id},{db:e});return}x||e.schematic_net_label.insert({text:this.props.schDisplayLabel??C,source_net_id:p.source_port_id,anchor_position:f,center:f,anchor_side:qfe(p.facingDirection)??"bottom"}),v||e.schematic_net_label.insert({text:this.props.schDisplayLabel??C,source_net_id:u.source_port_id,anchor_position:c,center:c,anchor_side:qfe(u.facingDirection)??"bottom"})}_isSymbolToChipConnection(){const{allPortsFound:e,ports:t}=this._findConnectedPorts();if(!e||t.length!==2)return!1;const[n,i]=t;if(!(n!=null&&n.parent)||!(i!=null&&i.parent))return!1;const a=n.parent.config.shouldRenderAsSchematicBox,o=i.parent.config.shouldRenderAsSchematicBox;return a&&!o||!a&&o}_isSymbolToSymbolConnection(){const{allPortsFound:e,ports:t}=this._findConnectedPorts();if(!e||t.length!==2)return!1;const[n,i]=t;if(!(n!=null&&n.parent)||!(i!=null&&i.parent))return!1;const a=!n.parent.config.shouldRenderAsSchematicBox,o=!i.parent.config.shouldRenderAsSchematicBox;return a&&o}_isChipToChipConnection(){const{allPortsFound:e,ports:t}=this._findConnectedPorts();if(!e||t.length!==2)return!1;const[n,i]=t;if(!(n!=null&&n.parent)||!(i!=null&&i.parent))return!1;const a=n.parent.config.shouldRenderAsSchematicBox,o=i.parent.config.shouldRenderAsSchematicBox;return a&&o}doInitialSchematicTraceRender(){var we,Ce;if((we=this.root)!=null&&we.schematicDisabled)return;const{db:e}=this.root,{_parsedProps:t,parent:n}=this;if(!n)throw new Error("Trace has no parent");const{allPortsFound:i,portsWithSelectors:a}=this._findConnectedPorts(),{netsWithSelectors:o}=this._findConnectedNets();if(!i)return;const l=a.map(be=>be.port.schematic_port_id).sort().join(","),c=(Ce=this.root)==null?void 0:Ce._getBoard();if(c!=null&&c._connectedSchematicPortPairs&&c._connectedSchematicPortPairs.has(l))return;if(this.props.schDisplayLabel&&("from"in this.props&&"to"in this.props||"path"in this.props)){this._doInitialSchematicTraceRenderWithDisplayLabel();return}const u={name:this.source_trace_id,pointsToConnect:[]},f=Rpn(this),p=a.map(({port:be})=>({port:be,position:be._getGlobalSchematicPositionAfterLayout(),schematic_port_id:be.schematic_port_id??void 0,facingDirection:be.facingDirection}));if(p.length===1&&o.length===1){const be=o[0].net,{port:Le,position:Ue}=p[0];e.schematic_net_label.insert({text:be._parsedProps.name,source_net_id:be.source_net_id,anchor_position:Ue,center:Ue,anchor_side:qfe(Le.facingDirection)??"bottom"});return}if(p.length<2)return;u.pointsToConnect=p.map(({position:be})=>({...be,layer:"top"}));const x=hpn(f),S=2,w={minTraceWidth:.1,obstacles:f,connections:[u],bounds:{minX:x.minX-S,maxX:x.maxX+S,minY:x.minY-S,maxY:x.maxY+S},layerCount:1};let b=Vw,C=!1;this.getSubcircuit().props._schDirectLineRoutingEnabled&&(b=SXe,C=!0);let I=new b({input:w,MAX_ITERATIONS:100,OBSTACLE_MARGIN:.1,isRemovePathLoopsEnabled:!0,isShortenPathWithShortcutsEnabled:!0,marginsWithCosts:[{margin:1,enterCost:0,travelCostFactor:1},{margin:.3,enterCost:0,travelCostFactor:1},{margin:.2,enterCost:0,travelCostFactor:2},{margin:.1,enterCost:0,travelCostFactor:3}]}).solveAndMapToTraces();if(I.length===0){if(this._isSymbolToChipConnection()||this._isSymbolToSymbolConnection()||this._isChipToChipConnection()){this._doInitialSchematicTraceRenderWithDisplayLabel();return}I=new SXe({input:w}).solveAndMapToTraces(),C=!0}const[{route:G}]=I;let Y=[];for(let be=0;be<G.length-1;be++)Y.push({from:G[be],to:G[be+1]});const Z=this.source_trace_id;let W=[];if(!C){Ppn({edges:Y,db:e,source_trace_id:Z});const be=Xfe({db:e,source_trace_id:Z,differentNetOnly:!0}).flatMap(Le=>Le.edges);Y=Spn({edges:Y,otherEdges:be}),W=Epn({edges:Y,db:e,source_trace_id:this.source_trace_id})}const te=Y[Y.length-1],J=p[p.length-1],fe=EXe(te);Y.push(...Yfe({lastEdge:te,lastEdgePort:J,lastDominantDirection:fe}));const he=Y[0],ve=p[0],Te=EXe(he);if(Y.unshift(...Yfe({firstEdge:he,firstEdgePort:ve,firstDominantDirection:Te})),!this.source_trace_id)throw new Error("Missing source_trace_id for schematic trace insertion.");if(this.getSubcircuit()._parsedProps.schTraceAutoLabelEnabled&&gpn(W,Y)>=5&&(this._isSymbolToChipConnection()||this._isSymbolToSymbolConnection()||this._isChipToChipConnection())){this._doInitialSchematicTraceRenderWithDisplayLabel();return}const Pe=e.schematic_trace.insert({source_trace_id:this.source_trace_id,edges:Y,junctions:W});this.schematic_trace_id=Pe.schematic_trace_id,c!=null&&c._connectedSchematicPortPairs&&c._connectedSchematicPortPairs.add(l)}},Dpn=P9("tscircuit:core"),Lpn=R.object({x:Yb,y:Yb,z:Yb}),r2=class extends Jg{constructor(e){super(e);Qe(this,"reactSubtrees",[]);Qe(this,"_impliedFootprint");Qe(this,"isPrimitiveContainer",!0);Qe(this,"_asyncSupplierPartNumbers");Qe(this,"pcb_missing_footprint_error_id");this._addChildrenFromStringFootprint(),this.initPorts()}get defaultInternallyConnectedPinNames(){return[]}get internallyConnectedPinNames(){return this._parsedProps.internallyConnectedPins??this.defaultInternallyConnectedPinNames}initPorts(e={}){var o,s,l,c,u,f,p,v,x,S;if((o=this.root)!=null&&o.schematicDisabled)return;const{config:t}=this,n=[],i=this._getSchematicPortArrangement();if(i&&!this._parsedProps.pinLabels){for(const C in i){const z=i[C].pins;if(Array.isArray(z))for(const I of z){const G=vP(I,this._parsedProps.pinLabels);n.push(new dS({pinNumber:G,aliases:((s=e.additionalAliases)==null?void 0:s[`pin${G}`])??[]},{originDescription:`schPortArrangement:${C}`}))}}const w=["left","right","top","bottom"];let b=1;for(const C of w){const z=i[`${C}Size`];for(let I=0;I<z;I++)n.push(new dS({pinNumber:b++,aliases:((l=e.additionalAliases)==null?void 0:l[`pin${b}`])??[]},{originDescription:`schPortArrangement:${C}`}))}}const a=this._parsedProps.pinLabels;if(a)for(let[w,b]of Object.entries(a)){w=w.replace("pin","");let C=n.find(G=>G._parsedProps.pinNumber===Number(w));const z=Array.isArray(b)?b[0]:b,I=Array.isArray(b)?b.slice(1):[];C?(C.externallyAddedAliases.push(z,...I),C.props.name=z):(C=new dS({pinNumber:parseInt(w),name:z,aliases:[...I,...((c=e.additionalAliases)==null?void 0:c[`pin${parseInt(w)}`])??[]]},{originDescription:`pinLabels:pin${w}`}),n.push(C))}if(t.schematicSymbolName){const w=k3[this._getSchematicSymbolNameOrThrow()];if(!w)return;for(const b of w.ports){const C=xXe(b.labels);if(!C)continue;const z=n.find(I=>I._parsedProps.pinNumber===Number(C));if(z)z.schematicSymbolPortDef=b;else{const I=yP(b.labels.concat(((u=e.additionalAliases)==null?void 0:u[`pin${C}`])??[]));I&&(I.originDescription=`schematicSymbol:labels[0]:${b.labels[0]}`,I.schematicSymbolPortDef=b,n.push(I))}}this.addAll(n)}if(!this._getSchematicPortArrangement()){const w=this.getPortsFromFootprint(e);for(const b of w)n.some(C=>C.isMatchingAnyOf(b.getNameAndAliases()))||n.push(b)}for(let w=1;w<=(e.pinCount??this._getPinCount());w++){if(!i||n.find(C=>C._parsedProps.pinNumber===w))continue;let b=[...((f=i.leftSide)==null?void 0:f.pins)??[],...((p=i.rightSide)==null?void 0:p.pins)??[],...((v=i.topSide)==null?void 0:v.pins)??[],...((x=i.bottomSide)==null?void 0:x.pins)??[]].map(C=>vP(C,this._parsedProps.pinLabels));["leftSize","rightSize","topSize","bottomSize","leftPinCount","rightPinCount","topPinCount","bottomPinCount"].some(C=>C in i)&&(b=Array.from({length:this._getPinCount()},(C,z)=>z+1)),b.includes(w)&&n.push(new dS({pinNumber:w,aliases:((S=e.additionalAliases)==null?void 0:S[`pin${w}`])??[]},{originDescription:`notOtherwiseAddedButDeducedFromPinCount:${w}`}))}n.length>0&&this.addAll(n)}_getImpliedFootprintString(){return null}_addChildrenFromStringFootprint(){var a;const{name:e,pcbRotation:t,pinLabels:n}=this.props;let{footprint:i}=this.props;if(i??(i=(a=this._getImpliedFootprintString)==null?void 0:a.call(this)),!!i&&typeof i=="string"){const o=Uw.string(i).soup(),s=rpn({componentName:e,componentRotation:t,footprint:i,pinLabels:n},o);this.addAll(s)}}get portMap(){return new Proxy({},{get:(e,t)=>{const n=this.children.find(i=>i.componentName==="Port"&&i.isMatchingNameOrAlias(t));if(!n)throw new Error(`There was an issue finding the port "${t.toString()}" inside of a ${this.componentName} component with name: "${this.props.name}". This is a bug in @tscircuit/core`);return n}})}getInstanceForReactElement(e){for(const t of this.reactSubtrees)if(t.element===e)return t.component;return null}doInitialSourceRender(){const e=this.config.sourceFtype;if(!e)return;const{db:t}=this.root,{_parsedProps:n}=this,i=t.source_component.insert({ftype:e,name:n.name,manufacturer_part_number:n.manufacturerPartNumber??n.mfn,supplier_part_numbers:n.supplierPartNumbers});this.source_component_id=i.source_component_id}doInitialSchematicComponentRender(){var i,a,o;if((i=this.root)!=null&&i.schematicDisabled)return;const{db:e}=this.root,{schematicSymbolName:t}=this.config;t?this._doInitialSchematicComponentRenderWithSymbol():this._getSchematicBoxDimensions()&&this._doInitialSchematicComponentRenderWithSchematicBoxDimensions();const n=(a=this.getSubcircuit())==null?void 0:a._getSchematicManualPlacementForComponent(this);if(this.schematic_component_id&&(this.props.schX!==void 0||this.props.schY!==void 0)&&n){if(!this.schematic_component_id)return;const s=zH.parse({type:"schematic_manual_edit_conflict_warning",schematic_manual_edit_conflict_warning_id:`schematic_manual_edit_conflict_${this.source_component_id}`,message:`${this.getString()} has both manual placement and prop coordinates. schX and schY will be used. Remove schX/schY or clear the manual placement.`,schematic_component_id:this.schematic_component_id,source_component_id:this.source_component_id,subcircuit_id:(o=this.getSubcircuit())==null?void 0:o.subcircuit_id});e.schematic_manual_edit_conflict_warning.insert(s)}}_getSchematicSymbolDisplayValue(){}_getInternallyConnectedPins(){if(this.internallyConnectedPinNames.length===0)return[];const e=[];for(const t of this.internallyConnectedPinNames){const n=[];for(const i of t)n.push(this.portMap[i]);e.push(n)}return e}_doInitialSchematicComponentRenderWithSymbol(){var o;if((o=this.root)!=null&&o.schematicDisabled)return;const{db:e}=this.root,{_parsedProps:t}=this,n=this._getSchematicSymbolNameOrThrow(),i=k3[n],a=this._getGlobalSchematicPositionBeforeLayout();if(i){const s=e.schematic_component.insert({center:a,size:i.size,source_component_id:this.source_component_id,symbol_name:n,symbol_display_value:this._getSchematicSymbolDisplayValue()});this.schematic_component_id=s.schematic_component_id}}_doInitialSchematicComponentRenderWithSchematicBoxDimensions(){var f;if((f=this.root)!=null&&f.schematicDisabled)return;const{db:e}=this.root,{_parsedProps:t}=this,n=this._getSchematicBoxDimensions(),i={};if(Array.isArray(t.pinLabels))t.pinLabels.forEach((p,v)=>{i[String(v+1)]=p});else for(const[p,v]of Object.entries(t.pinLabels??{}))i[p]=Array.isArray(v)?v[0]:v;const a=this._getGlobalSchematicPositionBeforeLayout(),o=this._getSchematicPortArrangement(),s=e.schematic_component.insert({center:a,rotation:t.schRotation??0,size:n.getSize(),port_arrangement:Qdn(o),pin_spacing:t.schPinSpacing??.2,pin_styles:Zdn(t.schPinStyle,t.pinLabels),port_labels:i,source_component_id:this.source_component_id}),l=(o==null?void 0:o.topSide)!==void 0||(o==null?void 0:o.bottomSide)!==void 0,c=n==null?void 0:n.getSize().width,u=n==null?void 0:n.getSize().height;e.schematic_text.insert({text:t.manufacturerPartNumber??"",schematic_component_id:s.schematic_component_id,anchor:"left",rotation:0,position:{x:l?a.x+(c??0)/2+.1:a.x-(c??0)/2,y:l?a.y+(u??0)/2+.35:a.y-(u??0)/2-.13},color:"#006464",font_size:.05}),e.schematic_text.insert({text:t.name??"",schematic_component_id:s.schematic_component_id,anchor:"left",rotation:0,position:{x:l?a.x+(c??0)/2+.1:a.x-(c??0)/2,y:l?a.y+(u??0)/2+.55:a.y+(u??0)/2+.13},color:"#006464",font_size:.05}),this.schematic_component_id=s.schematic_component_id}doInitialPcbComponentRender(){var o;if((o=this.root)!=null&&o.pcbDisabled)return;const{db:e}=this.root,{_parsedProps:t}=this,n=this.getSubcircuit(),i=e.pcb_component.insert({center:this._getGlobalPcbPositionBeforeLayout(),width:0,height:0,layer:t.layer??"top",rotation:t.pcbRotation??0,source_component_id:this.source_component_id,subcircuit_id:n.subcircuit_id??void 0});if(!t.footprint&&!this.isGroup){const s=e.pcb_missing_footprint_error.insert({message:`No footprint found for component: ${this.getString()}`,source_component_id:`${this.source_component_id}`,error_type:"pcb_missing_footprint_error"});this.pcb_missing_footprint_error_id=s.pcb_missing_footprint_error_id}this.pcb_component_id=i.pcb_component_id;const a=this.getSubcircuit()._getPcbManualPlacementForComponent(this);if((this.props.pcbX!==void 0||this.props.pcbY!==void 0)&&a){const s=kH.parse({type:"pcb_manual_edit_conflict_warning",pcb_manual_edit_conflict_warning_id:`pcb_manual_edit_conflict_${this.source_component_id}`,message:`${this.getString()} has both manual placement and prop coordinates. pcbX and pcbY will be used. Remove pcbX/pcbY or clear the manual placement.`,pcb_component_id:this.pcb_component_id,source_component_id:this.source_component_id,subcircuit_id:n.subcircuit_id??void 0});e.pcb_manual_edit_conflict_warning.insert(s)}}doInitialPcbComponentSizeCalculation(){var a;if((a=this.root)!=null&&a.pcbDisabled||!this.pcb_component_id)return;const{db:e}=this.root,{_parsedProps:t}=this,n=_Xe(this.children);if(n.width===0||n.height===0)return;const i={x:(n.minX+n.maxX)/2,y:(n.minY+n.maxY)/2};e.pcb_component.update(this.pcb_component_id,{center:i,width:n.width,height:n.height})}_renderReactSubtree(e){return{element:e,component:Wdn(e)}}doInitialInitializePortsFromChildren(){this.initPorts()}doInitialReactSubtreesRender(){if(mt.isValidElement(this.props.footprint)){if(this.reactSubtrees.some(t=>t.element===this.props.footprint))return;const e=this._renderReactSubtree(this.props.footprint);this.reactSubtrees.push(e),this.add(e.component)}}_hasExistingPortExactly(e){return this.children.filter(n=>n.componentName==="Port").some(n=>{const i=e.getNameAndAliases(),a=n.getNameAndAliases();return i.length===a.length&&i.every(o=>a.includes(o))})}add(e){let t;if(mt.isValidElement(e)){const n=this._renderReactSubtree(e);this.reactSubtrees.push(n),t=n.component}else t=e;if(t.componentName==="Port"){if(this._hasExistingPortExactly(t))return;const i=this.children.filter(a=>a.componentName==="Port").find(a=>a.isMatchingAnyOf(t.getNameAndAliases()));i&&Dpn(`Similar ports added. Port 1: ${i}, Port 2: ${t}`)}super.add(t)}getPortsFromFootprint(e){let{footprint:t}=this.props;if((!t||mt.isValidElement(t))&&(t=this.children.find(i=>i.componentName==="Footprint")),typeof t=="string"){const i=Uw.string(t).soup(),a=[];for(const o of i)if("port_hints"in o&&o.port_hints){const s=yP(o.port_hints,e);if(!s)continue;s.originDescription=`footprint:string:${t}:port_hints[0]:${o.port_hints[0]}`,a.push(s)}return a}if(!mt.isValidElement(t)&&t&&t.componentName==="Footprint"){const i=t;let a=1;const o=[];for(const s of i.children){if(!s.props.portHints)continue;let l=s.props.portHints;l.some(f=>f.startsWith("pin"))||(l=[...l,`pin${a}`]),a++;const u=yP(l);u&&(u.originDescription=`footprint:${t}`,o.push(u))}return o}const n=[];if(!t){for(const i of this.children)if(i.props.portHints&&i.isPcbPrimitive){const a=yP(i.props.portHints);a&&n.push(a)}}return n}getPortsFromSchematicSymbol(){var i;if((i=this.root)!=null&&i.schematicDisabled)return[];const{config:e}=this;if(!e.schematicSymbolName)return[];const t=k3[e.schematicSymbolName];if(!t)return[];const n=[];for(const a of t.ports){const o=yP(a.labels);o&&(o.schematicSymbolPortDef=a,n.push(o))}return n}doInitialCreateNetsFromProps(){this._createNetsFromProps(this._getNetsFromConnectionsProp())}_getNetsFromConnectionsProp(){const{_parsedProps:e}=this,t=[];if(e.connections)for(const[n,i]of Object.entries(e.connections)){const a=Array.isArray(i)?i:[i];for(const o of a)t.push(o)}return t}_createNetsFromProps(e){hXe(this,e)}_getPcbCircuitJsonBounds(){const{db:e}=this.root;if(!this.pcb_component_id)return super._getPcbCircuitJsonBounds();const t=e.pcb_component.get(this.pcb_component_id);return{center:{x:t.center.x,y:t.center.y},bounds:{left:t.center.x-t.width/2,top:t.center.y-t.height/2,right:t.center.x+t.width/2,bottom:t.center.y+t.height/2},width:t.width,height:t.height}}_getPinCountFromSchematicPortArrangement(){const e=this._getSchematicPortArrangement();if(!e)return 0;if(!bXe(e))return(e.leftSize??e.leftPinCount??0)+(e.rightSize??e.rightPinCount??0)+(e.topSize??e.topPinCount??0)+(e.bottomSize??e.bottomPinCount??0);const{leftSide:n,rightSide:i,topSide:a,bottomSide:o}=e;return Math.max(...(n==null?void 0:n.pins)??[],...(i==null?void 0:i.pins)??[],...(a==null?void 0:a.pins)??[],...(o==null?void 0:o.pins)??[])}_getPinCount(){return this._getSchematicPortArrangement()?this._getPinCountFromSchematicPortArrangement():this.getPortsFromFootprint().length}_getSchematicPortArrangement(){return this._parsedProps.schPinArrangement??this._parsedProps.schPortArrangement}_getSchematicBoxDimensions(){if(this.getSchematicSymbol()||!this.config.shouldRenderAsSchematicBox)return null;const{_parsedProps:e}=this,t=this._getPinCount(),n=e.schPinSpacing??.2;return upn({schWidth:e.schWidth,schHeight:e.schHeight,schPinSpacing:n,numericSchPinStyle:ppn(e.schPinStyle,e.pinLabels),pinCount:t,schPortArrangement:this._getSchematicPortArrangement(),pinLabels:e.pinLabels})}doInitialCadModelRender(){var c;const{db:e}=this.root,{boardThickness:t=0}=((c=this.root)==null?void 0:c._getBoard())??{},n=this._parsedProps.cadModel;if(!this.pcb_component_id||!n&&!this.props.footprint)return;const i=this._getPcbCircuitJsonBounds(),a=e.pcb_component.get(this.pcb_component_id);if(typeof n=="string")throw new Error("String cadModel not yet implemented");const o=Lpn.parse({x:0,y:0,z:typeof(n==null?void 0:n.rotationOffset)=="number"?n.rotationOffset:0,...typeof(n==null?void 0:n.rotationOffset)=="object"?n.rotationOffset??{}:{}}),s=Lw.parse({x:0,y:0,z:0,...typeof(n==null?void 0:n.positionOffset)=="object"?n.positionOffset:{}}),l=this.props.layer==="bottom"?"bottom":"top";e.cad_component.insert({position:{x:i.center.x+s.x,y:i.center.y+s.y,z:(l==="bottom"?-t/2:t/2)+s.z},rotation:{x:o.x,y:(l==="top"?0:180)+o.y,z:((a==null?void 0:a.rotation)??0)+(l==="bottom"?180:0)+o.z},pcb_component_id:this.pcb_component_id,source_component_id:this.source_component_id,model_stl_url:"stlUrl"in(n??{})?this._addCachebustToModelUrl(n.stlUrl):void 0,model_obj_url:"objUrl"in(n??{})?this._addCachebustToModelUrl(n.objUrl):void 0,model_jscad:"jscad"in(n??{})?n.jscad:void 0,footprinter_string:typeof this.props.footprint=="string"&&!n?this.props.footprint:void 0})}_addCachebustToModelUrl(e){var n;if(!e||!e.includes("modelcdn.tscircuit.com"))return e;const t=((n=this.root)==null?void 0:n.getClientOrigin())??"";return`${e}${e.includes("?")?"&":"?"}cachebust_origin=${encodeURIComponent(t)}`}doInitialPartsEngineRender(){const e=this.getInheritedProperty("partsEngine");if(!e)return;const{db:t}=this.root,n=t.source_component.get(this.source_component_id);if(!n||n.supplier_part_numbers)return;let i;this.props.footprint&&typeof this.props.footprint=="string"&&(i=this.props.footprint);const a=e.findPart({sourceComponent:n,footprinterString:i});if(!(a instanceof Promise)){t.source_component.update(this.source_component_id,{supplier_part_numbers:a});return}this._queueAsyncEffect("get-supplier-part-numbers",async()=>{this._asyncSupplierPartNumbers=await a,this._markDirty("PartsEngineRender")})}updatePartsEngineRender(){const{db:e}=this.root,t=e.source_component.get(this.source_component_id);if(t&&!t.supplier_part_numbers&&this._asyncSupplierPartNumbers){e.source_component.update(this.source_component_id,{supplier_part_numbers:this._asyncSupplierPartNumbers});return}}doInitialCreateTracesFromProps(){this._createTracesFromConnectionsProp()}_createTracesFromConnectionsProp(){const{_parsedProps:e}=this;if(e.connections)for(const[t,n]of Object.entries(e.connections)){const i=Array.isArray(n)?n:[n];for(const a of i)this.add(new cw({from:`${this.getSubcircuitSelector()} > port.${t}`,to:a}))}}},Opn=class{constructor(r,e={}){Qe(this,"input");Qe(this,"isRouting",!1);Qe(this,"solver");Qe(this,"eventHandlers",{complete:[],error:[],progress:[]});Qe(this,"cycleCount",0);Qe(this,"stepDelay");Qe(this,"timeoutId");this.input=r;const{capacityDepth:t,targetMinCapacity:n,stepDelay:i=0}=e;this.solver=new Rq(r,{capacityDepth:t,targetMinCapacity:n}),this.stepDelay=i}start(){this.isRouting||(this.isRouting=!0,this.cycleCount=0,this.runCycleAndQueueNextCycle())}runCycleAndQueueNextCycle(){var r;if(this.isRouting)try{if(this.solver.solved||this.solver.failed){this.solver.failed?this.emitEvent({type:"error",error:new Error(this.solver.error||"Routing failed")}):this.emitEvent({type:"complete",traces:this.solver.getOutputSimpleRouteJson().traces||[]}),this.isRouting=!1;return}const e=Date.now(),t=this.solver.iterations;for(;Date.now()-e<250&&!this.solver.failed&&!this.solver.solved;)this.solver.step();const n=(this.solver.iterations-t)/(Date.now()-e)*1e3;this.cycleCount++;const i=((r=this.solver)==null?void 0:r.preview())||void 0,a=this.solver.progress;this.emitEvent({type:"progress",steps:this.cycleCount,iterationsPerSecond:n,progress:a,phase:this.solver.getCurrentPhase(),debugGraphics:i}),this.stepDelay>0?this.timeoutId=setTimeout(()=>this.runCycleAndQueueNextCycle(),this.stepDelay):this.timeoutId=setTimeout(()=>this.runCycleAndQueueNextCycle(),0)}catch(e){this.emitEvent({type:"error",error:e instanceof Error?e:new Error(String(e))}),this.isRouting=!1}}stop(){this.isRouting&&(this.isRouting=!1,this.timeoutId!==void 0&&(clearTimeout(this.timeoutId),this.timeoutId=void 0))}on(r,e){r==="complete"?this.eventHandlers.complete.push(e):r==="error"?this.eventHandlers.error.push(e):r==="progress"&&this.eventHandlers.progress.push(e)}emitEvent(r){if(r.type==="complete")for(const e of this.eventHandlers.complete)e(r);else if(r.type==="error")for(const e of this.eventHandlers.error)e(r);else if(r.type==="progress")for(const e of this.eventHandlers.progress)e(r)}solveSync(){if(this.solver.solve(),this.solver.failed)throw new Error(this.solver.error||"Routing failed");return this.solver.getOutputSimpleRouteJson().traces||[]}},TXe=class extends Jg{constructor(){super(...arguments);Qe(this,"matchedPort",null)}get config(){return{componentName:"TraceHint",zodProps:zdn}}doInitialPortMatching(){const{db:e}=this.root,{_parsedProps:t,parent:n}=this;if(!n)return;if(n.componentName==="Trace"){this.renderError(`Port inference inside trace is not yet supported (${this})`);return}if(!n)throw new Error("TraceHint has no parent");if(!t.for){this.renderError(`TraceHint has no for property (${this})`);return}const i=n.selectOne(t.for,{type:"port"});i||this.renderError(`${this} could not find port for selector "${t.for}"`),this.matchedPort=i,i.registerMatch(this)}getPcbRouteHints(){const{_parsedProps:e}=this,t=e.offset?[e.offset]:e.offsets;if(!t)return[];const n=this._computePcbGlobalTransformBeforeLayout();return t.map(i=>({...Pr(n,i),via:i.via,to_layer:i.to_layer,trace_width:i.trace_width}))}doInitialPcbTraceHintRender(){var n,i,a;if((n=this.root)!=null&&n.pcbDisabled)return;const{db:e}=this.root,{_parsedProps:t}=this;e.pcb_trace_hint.insert({pcb_component_id:(i=this.matchedPort)==null?void 0:i.pcb_component_id,pcb_port_id:(a=this.matchedPort)==null?void 0:a.pcb_port_id,route:this.getPcbRouteHints()})}},zpn=(r,e)=>{const t=r.source_group.list(),n=[],i=a=>{const o=t.filter(s=>s.parent_subcircuit_id===a);for(const s of o)s.subcircuit_id&&(n.push(s.subcircuit_id),i(s.subcircuit_id))};return i(e),n},MXe=({db:r,circuitJson:e,subcircuit_id:t,minTraceWidth:n=.1})=>{if(!r&&e&&(r=C8(e)),!r)throw new Error("db or circuitJson is required");const i=r.pcb_trace_hint.list(),a=t?new Set([t]):null;if(t){const S=zpn(r,t);for(const w of S)a.add(w)}const o=(e??r.toArray()).filter(S=>!t||"subcircuit_id"in S&&a.has(S.subcircuit_id)),s=r.pcb_board.list()[0];r=C8(o);const l=M8(o),c=$w([...r.pcb_component.list(),...r.pcb_smtpad.list(),...r.pcb_plated_hole.list(),...r.pcb_hole.list(),...r.pcb_via.list()].filter(S=>!t||(a==null?void 0:a.has(S.subcircuit_id))),l);for(const S of c){const w=S.connectedTo.flatMap(b=>l.getIdsConnectedToNet(b));S.connectedTo.push(...w)}const u=c.flatMap(S=>[{x:S.center.x-S.width/2,y:S.center.y-S.height/2},{x:S.center.x+S.width/2,y:S.center.y+S.height/2}]);let f;s?f={minX:s.center.x-s.width/2,maxX:s.center.x+s.width/2,minY:s.center.y-s.height/2,maxY:s.center.y+s.height/2}:f={minX:Math.min(...u.map(S=>S.x))-1,maxX:Math.max(...u.map(S=>S.x))+1,minY:Math.min(...u.map(S=>S.y))-1,maxY:Math.max(...u.map(S=>S.y))+1};const p=r.source_trace.list().map(S=>{var Z,W,te;const w=S.connected_source_port_ids.map(J=>{const fe=r.source_port.get(J),he=r.pcb_port.getWhere({source_port_id:J});return{...fe,...he}});if(w.length<2)return null;const[b,C]=w,z=((Z=b.layers)==null?void 0:Z[0])??"top",I=((W=C.layers)==null?void 0:W[0])??"top",G=i.filter(J=>J.pcb_port_id===b.pcb_port_id||J.pcb_port_id===C.pcb_port_id),Y=[];for(const J of G){const fe=r.pcb_port.get(J.pcb_port_id),he=((te=fe==null?void 0:fe.layers)==null?void 0:te[0])??"top";for(const ve of J.route)Y.push({x:ve.x,y:ve.y,layer:he})}return{name:S.source_trace_id??l.getNetConnectedToId(S.source_trace_id)??"",source_trace_id:S.source_trace_id,pointsToConnect:[{x:b.x,y:b.y,layer:z},...Y,{x:C.x,y:C.y,layer:I}]}}).filter(S=>S!==null),v=r.source_net.list().filter(S=>!t||(a==null?void 0:a.has(S.subcircuit_id))),x=[];for(const S of v){const w=r.source_trace.list().filter(b=>{var C;return(C=b.connected_source_net_ids)==null?void 0:C.includes(S.source_net_id)});x.push({name:S.source_net_id??l.getNetConnectedToId(S.source_net_id),pointsToConnect:w.flatMap(b=>r.pcb_port.list().filter(z=>b.connected_source_port_ids.includes(z.source_port_id)).map(z=>{var I;return{x:z.x,y:z.y,layer:((I=z.layers)==null?void 0:I[0])??"top",pcb_port_id:z.pcb_port_id}}))})}return{simpleRouteJson:{bounds:f,obstacles:c,connections:[...p,...x],layerCount:2,minTraceWidth:n},connMap:l}},Wfe=class extends r2{constructor(){super(...arguments);Qe(this,"pcb_group_id",null);Qe(this,"subcircuit_id",null);Qe(this,"_hasStartedAsyncAutorouting",!1);Qe(this,"_asyncAutoroutingResult",null)}get config(){return{zodProps:Dfn,componentName:"Group"}}doInitialSourceRender(){const{db:e}=this.root,t=e.source_group.insert({name:this._parsedProps.name,is_subcircuit:this.isSubcircuit});this.subcircuit_id=`subcircuit_${t.source_group_id}`,this.source_group_id=t.source_group_id,e.source_group.update(t.source_group_id,{subcircuit_id:this.subcircuit_id})}doInitialSourceParentAttachment(){var n,i,a;const{db:e}=this.root;if(!this.isSubcircuit)return;const t=(a=(i=(n=this.parent)==null?void 0:n.getSubcircuit)==null?void 0:i.call(n))==null?void 0:a.subcircuit_id;t&&e.source_group.update(this.source_group_id,{parent_subcircuit_id:t})}doInitialPcbComponentRender(){var i;if((i=this.root)!=null&&i.pcbDisabled)return;const{db:e}=this.root,{_parsedProps:t}=this,n=e.pcb_group.insert({is_subcircuit:this.isSubcircuit,subcircuit_id:this.subcircuit_id,name:this._parsedProps.name,center:this._getGlobalPcbPositionBeforeLayout(),width:0,height:0,pcb_component_ids:[],source_group_id:this.source_group_id});this.pcb_group_id=n.pcb_group_id}doInitialCreateTraceHintsFromProps(){var a;const{_parsedProps:e}=this,{db:t}=this.root,n=e;if(!this.isSubcircuit)return;const i=(a=n.layout)==null?void 0:a.manual_trace_hints;if(i)for(const o of i)this.add(new TXe({for:o.pcb_port_selector,offsets:o.offsets}))}doInitialSourceAddConnectivityMapKey(){if(!this.isSubcircuit)return;const{db:e}=this.root,t=this.selectAll("trace"),n=new IM({});n.addConnections(t.map(i=>{const a=e.source_trace.get(i.source_trace_id);return a?[a.source_trace_id,...a.connected_source_port_ids,...a.connected_source_net_ids]:null}).filter(i=>i!==null));for(const i of t){if(!i.source_trace_id)continue;const a=n.getNetConnectedToId(i.source_trace_id);if(!a)continue;const{name:o}=this._parsedProps;i.subcircuit_connectivity_map_key=`${o??`unnamedsubcircuit${this._renderId}`}_${a}`,e.source_trace.update(i.source_trace_id,{subcircuit_connectivity_map_key:i.subcircuit_connectivity_map_key})}}_areChildSubcircuitsRouted(){const e=this.selectAll("group").filter(t=>t.isSubcircuit);for(const t of e)if(t._shouldRouteAsync()&&!t._asyncAutoroutingResult)return!1;return!0}_shouldRouteAsync(){const e=this._getAutorouterConfig();return e.groupMode==="sequential-trace"?!1:!!(e.local&&e.groupMode==="subcircuit"||!e.local)}_hasTracesToRoute(){const e=P9("tscircuit:core:_hasTracesToRoute"),t=this.selectAll("trace");return e(`[${this.getString()}] has ${t.length} traces to route`),t.length>0}async _runEffectMakeHttpAutoroutingRequest(){var c,u,f,p;const{db:e}=this.root,t=P9("tscircuit:core:_runEffectMakeHttpAutoroutingRequest");this._parsedProps;const n=this._getAutorouterConfig(),i=n.serverUrl,a=n.serverMode,o=(v,x)=>{var S;return t("fetching",v),x.headers&&(x.headers["Tscircuit-Core-Version"]=(S=this.root)==null?void 0:S.getCoreVersion()),fetch(v,x)},s=this.root.db.toArray().filter(v=>v.type.startsWith("source_")||v.type.startsWith("pcb_"));if(a==="solve-endpoint"){if(((c=this.props.autorouter)==null?void 0:c.inputFormat)==="simplified"){const{autorouting_result:x}=await o(`${i}/autorouting/solve`,{method:"POST",body:JSON.stringify({input_simple_route_json:MXe({db:e,minTraceWidth:((u=this.props.autorouter)==null?void 0:u.minTraceWidth)??.15,subcircuit_id:this.subcircuit_id}).simpleRouteJson,subcircuit_id:this.subcircuit_id}),headers:{"Content-Type":"application/json"}}).then(S=>S.json());this._asyncAutoroutingResult=x,this._markDirty("PcbTraceRender");return}const{autorouting_result:v}=await o(`${i}/autorouting/solve`,{method:"POST",body:JSON.stringify({input_circuit_json:s,subcircuit_id:this.subcircuit_id}),headers:{"Content-Type":"application/json"}}).then(x=>x.json());this._asyncAutoroutingResult=v,this._markDirty("PcbTraceRender");return}const{autorouting_job:l}=await o(`${i}/autorouting/jobs/create`,{method:"POST",body:JSON.stringify({input_circuit_json:s,provider:"freerouting",autostart:!0,display_name:(f=this.root)==null?void 0:f.name,subcircuit_id:this.subcircuit_id,server_cache_enabled:n.serverCacheEnabled}),headers:{"Content-Type":"application/json"}}).then(v=>v.json());for(;;){const{autorouting_job:v}=await o(`${i}/autorouting/jobs/get`,{method:"POST",body:JSON.stringify({autorouting_job_id:l.autorouting_job_id}),headers:{"Content-Type":"application/json"}}).then(x=>x.json());if(v.is_finished){const{autorouting_job_output:x}=await o(`${i}/autorouting/jobs/get_output`,{method:"POST",body:JSON.stringify({autorouting_job_id:l.autorouting_job_id}),headers:{"Content-Type":"application/json"}}).then(S=>S.json());this._asyncAutoroutingResult={output_pcb_traces:x.output_pcb_traces},this._markDirty("PcbTraceRender");break}if(v.has_error)throw e.pcb_autorouting_error.insert({pcb_error_id:l.autorouting_job_id,message:((p=v.error)==null?void 0:p.message)??JSON.stringify(v.error)}),new Error(`Autorouting job failed: ${JSON.stringify(v.error)}`);await new Promise(x=>setTimeout(x,100))}}async _runLocalAutorouting(){var s,l,c,u,f;const{db:e}=this.root;this._parsedProps;const t=P9("tscircuit:core:_runLocalAutorouting");t(`[${this.getString()}] starting local autorouting`);const n=this._getAutorouterConfig(),{simpleRouteJson:i}=MXe({db:e,minTraceWidth:((s=this.props.autorouter)==null?void 0:s.minTraceWidth)??.15,subcircuit_id:this.subcircuit_id});(l=this.root)==null||l.emit("autorouting:start",{subcircuit_id:this.subcircuit_id,componentDisplayName:this.getString(),simpleRouteJson:i});let a;n.algorithmFn?a=await n.algorithmFn(i):a=new Opn(i,{capacityDepth:(c=this.props.autorouter)==null?void 0:c.capacityDepth,targetMinCapacity:(u=this.props.autorouter)==null?void 0:u.targetMinCapacity});const o=new Promise((p,v)=>{a.on("complete",x=>{t(`[${this.getString()}] local autorouting complete`),p(x.traces)}),a.on("error",x=>{t(`[${this.getString()}] local autorouting error: ${x.error.message}`),v(x.error)})});a.on("progress",p=>{var v;(v=this.root)==null||v.emit("autorouting:progress",{subcircuit_id:this.subcircuit_id,componentDisplayName:this.getString(),...p})}),a.start();try{const p=await o;this._asyncAutoroutingResult={output_pcb_traces:p},this._markDirty("PcbTraceRender")}catch(p){const{db:v}=this.root;throw v.pcb_autorouting_error.insert({pcb_error_id:`pcb_autorouter_error_subcircuit_${this.subcircuit_id}`,message:p instanceof Error?p.message:String(p)}),(f=this.root)==null||f.emit("autorouting:error",{subcircuit_id:this.subcircuit_id,componentDisplayName:this.getString(),error:{message:p instanceof Error?p.message:String(p)},simpleRouteJson:i}),p}finally{a.stop()}}_startAsyncAutorouting(){this._hasStartedAsyncAutorouting||(this._hasStartedAsyncAutorouting=!0,this._getAutorouterConfig().local?this._queueAsyncEffect("capacity-mesh-autorouting",async()=>this._runLocalAutorouting()):this._queueAsyncEffect("make-http-autorouting-request",async()=>this._runEffectMakeHttpAutoroutingRequest()))}doInitialPcbTraceRender(){var t;const e=P9("tscircuit:core:doInitialPcbTraceRender");if(this.isSubcircuit&&!((t=this.root)!=null&&t.pcbDisabled)&&!this.getInheritedProperty("routingDisabled")&&!this._shouldUseTraceByTraceRouting()){if(!this._areChildSubcircuitsRouted()){e(`[${this.getString()}] child subcircuits are not routed, skipping async autorouting until subcircuits routed`);return}e(`[${this.getString()}] no child subcircuits to wait for, initiating async routing`),this._hasTracesToRoute()&&this._startAsyncAutorouting()}}updatePcbTraceRender(){var n;const e=P9("tscircuit:core:updatePcbTraceRender");if(e(`[${this.getString()}] updating...`),!this.isSubcircuit)return;if(this._shouldRouteAsync()&&this._hasTracesToRoute()&&!this._hasStartedAsyncAutorouting){this._areChildSubcircuitsRouted()&&(e(`[${this.getString()}] child subcircuits are now routed, starting async autorouting`),this._startAsyncAutorouting());return}if(!this._asyncAutoroutingResult||this._shouldUseTraceByTraceRouting())return;const{db:t}=this.root;if(this._asyncAutoroutingResult.output_simple_route_json){e(`[${this.getString()}] updating PCB traces from simple route json (${(n=this._asyncAutoroutingResult.output_simple_route_json.traces)==null?void 0:n.length} traces)`),this._updatePcbTraceRenderFromSimpleRouteJson();return}if(this._asyncAutoroutingResult.output_pcb_traces){e(`[${this.getString()}] updating PCB traces from ${this._asyncAutoroutingResult.output_pcb_traces.length} traces`),this._updatePcbTraceRenderFromPcbTraces();return}}_updatePcbTraceRenderFromSimpleRouteJson(){const{db:e}=this.root,{traces:t}=this._asyncAutoroutingResult.output_simple_route_json;if(t)for(const n of t)e.pcb_trace.insert({subcircuit_id:this.subcircuit_id,route:n.route})}_updatePcbTraceRenderFromPcbTraces(){const{output_pcb_traces:e}=this._asyncAutoroutingResult;if(!e)return;const{db:t}=this.root;for(const n of e)if(n.type==="pcb_trace"){if(n.subcircuit_id=this.subcircuit_id,n.connection_name){const i=n.connection_name;n.source_trace_id=i}t.pcb_trace.insert(n)}for(const n of e)if(n.type!=="pcb_via"&&n.type==="pcb_trace")for(const i of n.route)i.route_type==="via"&&t.pcb_via.insert({pcb_trace_id:n.pcb_trace_id,x:i.x,y:i.y,hole_diameter:.3,outer_diameter:.6,layers:[i.from_layer,i.to_layer],from_layer:i.from_layer,to_layer:i.to_layer})}doInitialSchematicLayout(){if(!this.isSubcircuit||!this._parsedProps.schAutoLayoutEnabled)return;const{db:t}=this.root,n=this.getDescendants(),i=[];for(const s of n)if("schematic_component_id"in s){const l=t.schematic_component.get(s.schematic_component_id);if(l){const c=t.schematic_port.list().filter(u=>u.schematic_component_id===l.schematic_component_id);i.push(...c)}}const a=mq(t.toArray()),o=vq(a);hq(t.toArray(),o)}_getAutorouterConfig(){const e={serverUrl:"https://registry-api.tscircuit.com",serverMode:"job",serverCacheEnabled:!0},t=this._parsedProps.autorouter??this.getInheritedProperty("autorouter");return typeof t=="object"?{local:!(t.serverUrl||t.serverMode||t.serverCacheEnabled),...e,...t}:t==="auto-local"?{local:!0,groupMode:"subcircuit"}:t==="sequential-trace"?{local:!0,groupMode:"sequential-trace"}:t==="subcircuit"?{local:!0,groupMode:"subcircuit"}:t==="auto-cloud"?{local:!1,groupMode:"subcircuit",serverUrl:e.serverUrl,serverMode:e.serverMode,serverCacheEnabled:!0}:{local:!0,groupMode:"subcircuit"}}_shouldUseTraceByTraceRouting(){return this._getAutorouterConfig().groupMode==="sequential-trace"}doInitialPcbDesignRuleChecks(){var t;if((t=this.root)!=null&&t.pcbDisabled||this.getInheritedProperty("routingDisabled"))return;const{db:e}=this.root;if(this.isSubcircuit){const n=new Map;for(const i of this.children)if(!i.isSubcircuit&&i._parsedProps.name){const a=n.get(i._parsedProps.name)||[];a.push(i),n.set(i._parsedProps.name,a)}for(const[i,a]of n.entries())a.length>1&&e.pcb_trace_error.insert({error_type:"pcb_trace_error",message:`Multiple components found with name "${i}" in subcircuit "${this._parsedProps.name||"unnamed"}". Component names must be unique within a subcircuit.`,source_trace_id:"",pcb_trace_id:"",pcb_component_ids:a.map(o=>o.pcb_component_id).filter(Boolean),pcb_port_ids:[]})}}},Upn=class extends Wfe{constructor(){super(...arguments);Qe(this,"pcb_board_id",null);Qe(this,"_drcChecksComplete",!1);Qe(this,"_connectedSchematicPortPairs",new Set)}get isSubcircuit(){return!0}get config(){return{componentName:"Board",zodProps:eXe}}get boardThickness(){const{_parsedProps:e}=this;return 1.4}get allLayers(){return["top","bottom","inner1","inner2"]}doInitialPcbBoardAutoSize(){var v;if((v=this.root)!=null&&v.pcbDisabled||!this.pcb_board_id)return;const{db:e}=this.root,{_parsedProps:t}=this;if(t.width&&t.height)return;let n=1/0,i=1/0,a=-1/0,o=-1/0;const s=e.pcb_component.list();let l=!1;for(const x of s){const{width:S,height:w,center:b}=x;S===0||w===0||(l=!0,n=Math.min(n,b.x-S/2),i=Math.min(i,b.y-w/2),a=Math.max(a,b.x+S/2),o=Math.max(o,b.y+w/2))}const c=2,u=l?a-n+c*2:0,f=l?o-i+c*2:0,p={x:l?(n+a)/2+(t.outlineOffsetX??0):t.outlineOffsetX??0,y:l?(i+o)/2+(t.outlineOffsetY??0):t.outlineOffsetY??0};e.pcb_board.update(this.pcb_board_id,{width:u,height:f,center:p})}doInitialPcbComponentRender(){var o,s;if((o=this.root)!=null&&o.pcbDisabled)return;const{db:e}=this.root,{_parsedProps:t}=this;let n=t.width??0,i=t.height??0;if(t.outline){const l=t.outline.map(x=>x.x),c=t.outline.map(x=>x.y),u=Math.min(...l),f=Math.max(...l),p=Math.min(...c),v=Math.max(...c);n=f-u,i=v-p}const a=e.pcb_board.insert({center:{x:(t.pcbX??0)+(t.outlineOffsetX??0),y:(t.pcbY??0)+(t.outlineOffsetY??0)},thickness:this.boardThickness,num_layers:this.allLayers.length,width:n,height:i,outline:(s=t.outline)==null?void 0:s.map(l=>({x:l.x+(t.outlineOffsetX??0),y:l.y+(t.outlineOffsetY??0)})),material:t.material});this.pcb_board_id=a.pcb_board_id}removePcbComponentRender(){const{db:e}=this.root;this.pcb_board_id&&(e.pcb_board.delete(this.pcb_board_id),this.pcb_board_id=null)}_computePcbGlobalTransformBeforeLayout(){return e1()}doInitialPcbDesignRuleChecks(){var e;(e=this.root)!=null&&e.pcbDisabled||this.getInheritedProperty("routingDisabled")||super.doInitialPcbDesignRuleChecks()}updatePcbDesignRuleChecks(){var n;if((n=this.root)!=null&&n.pcbDisabled||this.getInheritedProperty("routingDisabled"))return;const{db:e}=this.root;if(!this._areChildSubcircuitsRouted()||this._drcChecksComplete)return;this._drcChecksComplete=!0;const t=Vdn(e.toArray());for(const i of t)e.pcb_trace_error.insert(i)}_emitRenderLifecycleEvent(e,t){var n;super._emitRenderLifecycleEvent(e,t),t==="start"&&((n=this.root)==null||n.emit("board:renderPhaseStarted",{renderId:this._renderId,phase:e}))}},Ipn=new Proxy({},{get:(r,e)=>e}),gP=Ipn,kpn=class extends r2{get config(){return{componentName:"Capacitor",schematicSymbolName:this.props.polarized?"capacitor_polarized":this.props.symbolName??"capacitor",zodProps:Gfn,sourceFtype:gP.simple_capacitor}}initPorts(){super.initPorts({additionalAliases:{pin1:["anode","pos","left"],pin2:["cathode","neg","right"]}})}_getSchematicSymbolDisplayValue(){const r=`${Sb(this._parsedProps.capacitance)}F`;return this._parsedProps.schShowRatings&&this._parsedProps.maxVoltageRating?`${r}/${Sb(this._parsedProps.maxVoltageRating)}V`:r}doInitialCreateNetsFromProps(){this._createNetsFromProps([this.props.decouplingFor,this.props.decouplingTo,...this._getNetsFromConnectionsProp()])}doInitialCreateTracesFromProps(){this.props.decouplingFor&&this.props.decouplingTo&&(this.add(new cw({from:`${this.getSubcircuitSelector()} > port.1`,to:this.props.decouplingFor})),this.add(new cw({from:`${this.getSubcircuitSelector()} > port.2`,to:this.props.decouplingTo}))),this._createTracesFromConnectionsProp()}doInitialSourceRender(){const{db:r}=this.root,{_parsedProps:e}=this,t=r.source_component.insert({ftype:"simple_capacitor",name:e.name,manufacturer_part_number:e.manufacturerPartNumber??e.mfn,supplier_part_numbers:e.supplierPartNumbers,capacitance:e.capacitance,max_voltage_rating:e.maxVoltageRating,max_decoupling_trace_length:e.maxDecouplingTraceLength,display_capacitance:this._getSchematicSymbolDisplayValue(),are_pins_interchangeable:!e.polarized});this.source_component_id=t.source_component_id}},CXe=class extends r2{constructor(){super(...arguments);Qe(this,"schematicBoxDimensions",null)}get config(){return{componentName:"Chip",zodProps:tXe,shouldRenderAsSchematicBox:!0}}doInitialSchematicComponentRender(){const{_parsedProps:e}=this;(e==null?void 0:e.noSchematicRepresentation)!==!0&&super.doInitialSchematicComponentRender()}doInitialSourceRender(){const{db:e}=this.root,{_parsedProps:t}=this,n=e.source_component.insert({ftype:"simple_chip",name:t.name,manufacturer_part_number:t.manufacturerPartNumber,supplier_part_numbers:t.supplierPartNumbers});this.source_component_id=n.source_component_id}doInitialPcbComponentRender(){var i;if((i=this.root)!=null&&i.pcbDisabled)return;const{db:e}=this.root,{_parsedProps:t}=this,n=e.pcb_component.insert({center:{x:t.pcbX??0,y:t.pcbY??0},width:2,height:3,layer:t.layer??"top",rotation:t.pcbRotation??0,source_component_id:this.source_component_id,subcircuit_id:this.getSubcircuit().subcircuit_id??void 0});this.pcb_component_id=n.pcb_component_id}doInitialCreateTracesFromProps(){const{_parsedProps:e}=this;if(e.externallyConnectedPins)for(const[t,n]of e.externallyConnectedPins)this.add(new cw({from:`${this.getSubcircuitSelector()} > port.${t}`,to:`${this.getSubcircuitSelector()} > port.${n}`}));this._createTracesFromConnectionsProp()}},Fpn=class extends r2{constructor(){super(...arguments);Qe(this,"pos",this.portMap.pin1);Qe(this,"anode",this.portMap.pin1);Qe(this,"neg",this.portMap.pin2);Qe(this,"cathode",this.portMap.pin2)}get config(){return{schematicSymbolName:this.props.symbolName??"diode",componentName:"Diode",zodProps:_dn,sourceFtype:"simple_diode"}}initPorts(){super.initPorts({additionalAliases:{pin1:["anode","pos","left"],pin2:["cathode","neg","right"]}})}doInitialSourceRender(){const{db:e}=this.root,{_parsedProps:t}=this,n=e.source_component.insert({ftype:"simple_diode",name:t.name,manufacturer_part_number:t.manufacturerPartNumber??t.mfn,supplier_part_numbers:t.supplierPartNumbers,are_pins_interchangeable:!1});this.source_component_id=n.source_component_id}},Bpn=class extends r2{constructor(){super(...arguments);Qe(this,"schematicDimensions",null)}get config(){let e="";if(this.props.pinCount&&(e+=`solderjumper${this.props.pinCount||2}`),Array.isArray(this.props.internallyConnectedPins)&&this.props.internallyConnectedPins.length>0){const t=Array.from(new Set(this.props.internallyConnectedPins.flat())).sort().join("");e+=`_bridged${t}`}return{schematicSymbolName:e,componentName:"Jumper",zodProps:Ufn,shouldRenderAsSchematicBox:!0}}doInitialSourceRender(){const{db:e}=this.root,{_parsedProps:t}=this,n=e.source_component.insert({ftype:"simple_chip",name:t.name,manufacturer_part_number:t.manufacturerPartNumber,supplier_part_numbers:t.supplierPartNumbers,are_pins_interchangeable:!0});this.source_component_id=n.source_component_id}doInitialPcbComponentRender(){var i;if((i=this.root)!=null&&i.pcbDisabled)return;const{db:e}=this.root,{_parsedProps:t}=this,n=e.pcb_component.insert({center:{x:t.pcbX??0,y:t.pcbY??0},width:2,height:3,layer:t.layer??"top",rotation:t.pcbRotation??0,source_component_id:this.source_component_id,subcircuit_id:this.getSubcircuit().subcircuit_id??void 0});this.pcb_component_id=n.pcb_component_id}doInitialPcbTraceRender(){const{db:e}=this.root,t=e.pcb_port.list({pcb_component_id:this.pcb_component_id}),n={};for(const o of t){const s=o.source_port_id&&o.source_port_id.match(/(\d+)$/);if(s){const l=(parseInt(s[1],10)+1).toString();n[l]=o.pcb_port_id}}const i=e.pcb_trace.list(),a=o=>{if(o&&typeof o=="string"&&o.startsWith("{PIN")){const s=o.replace("{PIN","").replace("}","");return n[s]||o}return o};for(const o of i)if(o.route)for(const s of o.route)s.route_type==="wire"&&(s.start_pcb_port_id=a(s.start_pcb_port_id),s.end_pcb_port_id=a(s.end_pcb_port_id))}},jpn=class extends r2{constructor(){super(...arguments);Qe(this,"pos",this.portMap.pin1);Qe(this,"anode",this.portMap.pin1);Qe(this,"neg",this.portMap.pin2);Qe(this,"cathode",this.portMap.pin2)}get config(){return{componentName:"Led",schematicSymbolName:this.props.symbolName??"led",zodProps:xdn,sourceFtype:"simple_diode"}}initPorts(){super.initPorts({additionalAliases:{pin1:["anode","pos","left"],pin2:["cathode","neg","right"]}})}doInitialSourceRender(){const{db:e}=this.root,{_parsedProps:t}=this,n=e.source_component.insert({ftype:"simple_diode",name:t.name,manufacturer_part_number:t.manufacturerPartNumber??t.mfn,supplier_part_numbers:t.supplierPartNumbers,are_pins_interchangeable:!1});this.source_component_id=n.source_component_id}},Hpn=class extends r2{constructor(){super(...arguments);Qe(this,"pos",this.portMap.pin1);Qe(this,"positive",this.portMap.pin1);Qe(this,"neg",this.portMap.pin2);Qe(this,"negative",this.portMap.pin2)}get config(){return{schematicSymbolName:this.props.symbolName??"power_factor_meter_horz",componentName:"PowerSource",zodProps:Mdn,sourceFtype:"simple_power_source"}}initPorts(){this.add(new dS({name:"pin1",pinNumber:1,aliases:["positive","pos"]})),this.add(new dS({name:"pin2",pinNumber:2,aliases:["negative","neg"]}))}doInitialSourceRender(){const{db:e}=this.root,{_parsedProps:t}=this,n=e.source_component.insert({ftype:"simple_power_source",name:t.name,voltage:t.voltage,supplier_part_numbers:t.supplierPartNumbers,are_pins_interchangeable:!1});this.source_component_id=n.source_component_id}},Vpn=class extends r2{get config(){return{componentName:"Resistor",schematicSymbolName:this.props.symbolName??"boxresistor",zodProps:Bfn,sourceFtype:"simple_resistor"}}initPorts(){super.initPorts({additionalAliases:{pin1:["anode","pos","left"],pin2:["cathode","neg","right"]}})}_getSchematicSymbolDisplayValue(){return`${Sb(this._parsedProps.resistance)}Ω`}doInitialCreateNetsFromProps(){this._createNetsFromProps([this.props.pullupFor,this.props.pullupTo,...this._getNetsFromConnectionsProp()])}doInitialCreateTracesFromProps(){this.props.pullupFor&&this.props.pullupTo&&(this.add(new cw({from:`${this.getSubcircuitSelector()} > port.1`,to:this.props.pullupFor})),this.add(new cw({from:`${this.getSubcircuitSelector()} > port.2`,to:this.props.pullupTo}))),this._createTracesFromConnectionsProp()}doInitialSourceRender(){const{db:r}=this.root,{_parsedProps:e}=this,t=r.source_component.insert({ftype:"simple_resistor",name:e.name,manufacturer_part_number:e.manufacturerPartNumber??e.mfn,supplier_part_numbers:e.supplierPartNumbers,resistance:e.resistance,display_resistance:this._getSchematicSymbolDisplayValue(),are_pins_interchangeable:!0});this.source_component_id=t.source_component_id}},$pn=["leftedge","rightedge","topedge","bottomedge","center"],Gpn=class extends Jg{get config(){return{componentName:"Constraint",zodProps:Zfn}}constructor(r){if(super(r),("xdist"in r||"ydist"in r)&&!("edgeToEdge"in r)&&!("centerToCenter"in r))throw new Error(`edgeToEdge, centerToCenter must be set for xDist or yDist for ${this}`);if("for"in r&&r.for.length<2)throw new Error(`"for" must have at least two selectors for ${this}`)}_getAllReferencedComponents(){const r=[],e=this.getPrimitiveContainer();function t(n){const i=n.split(" ").pop(),a=$pn.includes(i)?i:void 0,o=a?n.replace(` ${a}`,""):n,s=e.selectOne(o,{pcbPrimitive:!0});s&&r.push({selector:n,component:s,componentSelector:o,edge:a})}for(const n of["left","right","top","bottom"])n in this._parsedProps&&t(this._parsedProps[n]);if("for"in this._parsedProps)for(const n of this._parsedProps.for)t(n);return{componentsWithSelectors:r}}},qpn=class extends Jg{constructor(){super(...arguments);Qe(this,"fabrication_note_path_id",null)}get config(){return{componentName:"FabricationNotePath",zodProps:wdn}}doInitialPcbPrimitiveRender(){var s,l;if((s=this.root)!=null&&s.pcbDisabled)return;const{db:e}=this.root,t=this.getSubcircuit(),{_parsedProps:n}=this,i=n.layer??"top";if(i!=="top"&&i!=="bottom")throw new Error(`Invalid layer "${i}" for SilkscreenPath. Must be "top" or "bottom".`);const a=this._computePcbGlobalTransformBeforeLayout(),o=e.pcb_fabrication_note_path.insert({pcb_component_id:(l=this.parent)==null?void 0:l.pcb_component_id,layer:i,color:n.color,route:n.route.map(c=>{const u=Pr(a,{x:c.x,y:c.y});return{...c,x:u.x,y:u.y}}),stroke_width:n.strokeWidth??.1,subcircuit_id:(t==null?void 0:t.subcircuit_id)??void 0});this.fabrication_note_path_id=o.pcb_fabrication_note_path_id}},Ypn=class extends Jg{get config(){return{componentName:"FabricationNoteText",zodProps:Sdn}}doInitialPcbPrimitiveRender(){var i,a;if((i=this.root)!=null&&i.pcbDisabled)return;const{db:r}=this.root,{_parsedProps:e}=this,t=this.getPrimitiveContainer(),n=this.getSubcircuit();r.pcb_fabrication_note_text.insert({anchor_alignment:e.anchorAlignment,anchor_position:{x:e.pcbX??0,y:e.pcbY??0},font:e.font??"tscircuit2024",font_size:e.fontSize??1,layer:"top",color:e.color,text:e.text??"",pcb_component_id:t.pcb_component_id,subcircuit_id:(n==null?void 0:n.subcircuit_id)??void 0,pcb_group_id:((a=this.getGroup())==null?void 0:a.pcb_group_id)??void 0})}},Xpn=class extends Wfe{constructor(r){super({...r,subcircuit:!0})}},Wpn=class extends Jg{constructor(){super(...arguments);Qe(this,"source_net_alias_id")}get config(){return{componentName:"NetAlias",zodProps:udn}}doInitialSchematicComponentRender(){var a;if((a=this.root)!=null&&a.schematicDisabled)return;const{db:e}=this.root,{_parsedProps:t}=this,n={x:t.schX??0,y:t.schY??0},i=e.schematic_net_label.insert({text:t.net,source_net_id:t.net,anchor_position:n,center:n,anchor_side:"bottom"});this.source_net_alias_id=i.source_net_id}},Zpn=class extends Jg{constructor(){super(...arguments);Qe(this,"pcb_silkscreen_circle_id",null);Qe(this,"isPcbPrimitive",!0)}get config(){return{componentName:"SilkscreenCircle",zodProps:Odn}}doInitialPcbPrimitiveRender(){var s,l,c;if((s=this.root)!=null&&s.pcbDisabled)return;const{db:e}=this.root,{_parsedProps:t}=this,{maybeFlipLayer:n}=this._getPcbPrimitiveFlippedHelpers(),i=n(t.layer??"top");if(i!=="top"&&i!=="bottom")throw new Error(`Invalid layer "${i}" for SilkscreenCircle. Must be "top" or "bottom".`);this._computePcbGlobalTransformBeforeLayout();const a=this.getSubcircuit(),o=e.pcb_silkscreen_circle.insert({pcb_component_id:(l=this.parent)==null?void 0:l.pcb_component_id,layer:i,center:{x:t.pcbX??0,y:t.pcbY??0},radius:t.radius,subcircuit_id:(a==null?void 0:a.subcircuit_id)??void 0,pcb_group_id:((c=this.getGroup())==null?void 0:c.pcb_group_id)??void 0,stroke_width:t.strokeWidth??.1});this.pcb_silkscreen_circle_id=o.pcb_silkscreen_circle_id}getPcbSize(){const{_parsedProps:e}=this,t=e.radius*2;return{width:t,height:t}}},Qpn=class extends Jg{constructor(){super(...arguments);Qe(this,"pcb_silkscreen_rect_id",null);Qe(this,"isPcbPrimitive",!0)}get config(){return{componentName:"SilkscreenRect",zodProps:Ldn}}doInitialPcbPrimitiveRender(){var s,l,c;if((s=this.root)!=null&&s.pcbDisabled)return;const{db:e}=this.root,{_parsedProps:t}=this,{maybeFlipLayer:n}=this._getPcbPrimitiveFlippedHelpers(),i=n(t.layer??"top");if(i!=="top"&&i!=="bottom")throw new Error(`Invalid layer "${i}" for SilkscreenRect. Must be "top" or "bottom".`);const a=this.getSubcircuit(),o=e.pcb_silkscreen_rect.insert({pcb_component_id:(l=this.parent)==null?void 0:l.pcb_component_id,layer:i,center:{x:t.pcbX??0,y:t.pcbY??0},width:t.width,height:t.height,subcircuit_id:(a==null?void 0:a.subcircuit_id)??void 0,pcb_group_id:((c=this==null?void 0:this.getGroup())==null?void 0:c.pcb_group_id)??void 0,stroke_width:t.strokeWidth??.1});this.pcb_silkscreen_rect_id=o.pcb_silkscreen_rect_id}getPcbSize(){const{_parsedProps:e}=this;return{width:e.width,height:e.height}}},Kpn=class extends Jg{constructor(){super(...arguments);Qe(this,"pcb_silkscreen_line_id",null);Qe(this,"isPcbPrimitive",!0)}get config(){return{componentName:"SilkscreenLine",zodProps:Ddn}}doInitialPcbPrimitiveRender(){var s,l,c;if((s=this.root)!=null&&s.pcbDisabled)return;const{db:e}=this.root,{_parsedProps:t}=this,{maybeFlipLayer:n}=this._getPcbPrimitiveFlippedHelpers(),i=n(t.layer??"top");if(i!=="top"&&i!=="bottom")throw new Error(`Invalid layer "${i}" for SilkscreenLine. Must be "top" or "bottom".`);const a=this.getSubcircuit(),o=e.pcb_silkscreen_line.insert({pcb_component_id:(l=this.parent)==null?void 0:l.pcb_component_id,layer:i,x1:t.x1,y1:t.y1,x2:t.x2,y2:t.y2,stroke_width:t.strokeWidth??.1,subcircuit_id:(a==null?void 0:a.subcircuit_id)??void 0,pcb_group_id:((c=a==null?void 0:a.getGroup())==null?void 0:c.pcb_group_id)??void 0});this.pcb_silkscreen_line_id=o.pcb_silkscreen_line_id}getPcbSize(){const{_parsedProps:e}=this,t=Math.abs(e.x2-e.x1),n=Math.abs(e.y2-e.y1);return{width:t,height:n}}},Jpn=class extends Jg{constructor(){super(...arguments);Qe(this,"pcb_via_id",null);Qe(this,"matchedPort",null);Qe(this,"isPcbPrimitive",!0)}get config(){return{componentName:"Via",zodProps:Edn}}getAvailablePcbLayers(){return["top","inner1","inner2","bottom"]}getPcbSize(){const{_parsedProps:e}=this;return{width:e.outerDiameter,height:e.outerDiameter}}_getPcbCircuitJsonBounds(){const{db:e}=this.root,t=e.pcb_via.get(this.pcb_via_id),n=this.getPcbSize();return{center:{x:t.x,y:t.y},bounds:{left:t.x-n.width/2,top:t.y-n.height/2,right:t.x+n.width/2,bottom:t.y+n.height/2},width:n.width,height:n.height}}_setPositionFromLayout(e){const{db:t}=this.root;t.pcb_via.update(this.pcb_via_id,{x:e.x,y:e.y})}doInitialPcbPrimitiveRender(){var o,s;if((o=this.root)!=null&&o.pcbDisabled)return;const{db:e}=this.root,{_parsedProps:t}=this,n=this._getGlobalPcbPositionBeforeLayout(),i=this.getSubcircuit(),a=e.pcb_via.insert({x:n.x,y:n.y,hole_diameter:t.holeDiameter,outer_diameter:t.outerDiameter,layers:["bottom","top"],from_layer:t.fromLayer||"bottom",to_layer:t.toLayer||"top",subcircuit_id:(i==null?void 0:i.subcircuit_id)??void 0,pcb_group_id:((s=this.getGroup())==null?void 0:s.pcb_group_id)??void 0});this.pcb_via_id=a.pcb_via_id}},ehn=class extends r2{get config(){return{componentName:"Battery",schematicSymbolName:this.props.symbolName??"battery",zodProps:ldn,sourceFtype:"simple_power_source"}}initPorts(){super.initPorts({additionalAliases:{pin1:["anode","pos","left"],pin2:["cathode","neg","right"]}})}doInitialSourceRender(){const{db:r}=this.root,{_parsedProps:e}=this,t=r.source_component.insert({name:e.name,ftype:"simple_power_source",capacity:e.capacity,supplier_part_numbers:e.supplierPartNumbers,are_pins_interchangeable:!1});this.source_component_id=t.source_component_id}},thn=class extends r2{get config(){return{componentName:"PinHeader",zodProps:cdn,shouldRenderAsSchematicBox:!0}}_getImpliedFootprintString(){var i;const r=this._parsedProps.pinCount??((i=this._parsedProps.pinLabels)==null?void 0:i.length)??0,e=this._parsedProps.holeDiameter,t=this._parsedProps.platedDiameter,n=this._parsedProps.pitch;return r>0&&n?!e&&!t?`pinrow${r}_p${n}`:`pinrow${r}_p${n}_id${e}_od${t}`:null}initPorts(){var e,t;const r=this._parsedProps.pinCount??((e=this._parsedProps.pinLabels)==null?void 0:e.length)??1;for(let n=1;n<=r;n++)this.add(new dS({name:`pin${n}`,pinNumber:n,aliases:[(t=this._parsedProps.pinLabels)==null?void 0:t[n-1]].filter(Boolean)}))}_getSchematicPortArrangement(){const r=this._parsedProps.pinCount??1,e=this._parsedProps.facingDirection??"right";return{leftSize:e==="left"?r:0,rightSize:e==="right"?r:0}}doInitialSourceRender(){const{db:r}=this.root,{_parsedProps:e}=this,t=r.source_component.insert({ftype:"simple_pin_header",name:e.name,supplier_part_numbers:e.supplierPartNumbers,pin_count:e.pinCount,gender:e.gender,are_pins_interchangeable:!0});this.source_component_id=t.source_component_id}};function nhn(r){switch(r){case"two_ground_pins":return"crystal_4pin";case"ground_pin":return"resonator";case"no_ground":return"crystal";default:return"crystal"}}var rhn=class extends r2{get config(){return{componentName:"Resonator",schematicSymbolName:this.props.symbolName??nhn(this.props.pinVariant),zodProps:Vfn,shouldRenderAsSchematicBox:!1}}doInitialSourceRender(){const{db:r}=this.root,{_parsedProps:e}=this,t=e.pinVariant||"no_ground",n=r.source_component.insert({ftype:"simple_resonator",name:e.name,frequency:e.frequency,load_capacitance:e.loadCapacitance,supplier_part_numbers:e.supplierPartNumbers,pin_variant:t,are_pins_interchangeable:t==="no_ground"||t==="ground_pin"});this.source_component_id=n.source_component_id}},ihn=class extends r2{get config(){return{componentName:"Inductor",schematicSymbolName:this.props.symbolName??"inductor",zodProps:hdn,sourceFtype:gP.simple_inductor}}initPorts(){super.initPorts({additionalAliases:{pin1:["anode","pos","left"],pin2:["cathode","neg","right"]}})}doInitialSourceRender(){const{db:r}=this.root,{_parsedProps:e}=this,t=r.source_component.insert({name:e.name,ftype:gP.simple_inductor,inductance:e.inductance,supplier_part_numbers:e.supplierPartNumbers,are_pins_interchangeable:!0});this.source_component_id=t.source_component_id}};function ahn(r){switch(r){case"three_pin":return"potentiometer3";case"two_pin":return"potentiometer2";default:return"potentiometer2"}}var ohn=class extends r2{get config(){return{componentName:"Potentiometer",schematicSymbolName:this.props.symbolName??ahn(this.props.pinVariant),zodProps:jfn,shouldRenderAsSchematicBox:!1}}doInitialSourceRender(){const{db:r}=this.root,{_parsedProps:e}=this,t=e.pinVariant||"two_pin",n=r.source_component.insert({ftype:"simple_potentiometer",name:e.name,max_resistance:e.maxResistance,pin_variant:t,are_pins_interchangeable:t==="two_pin"});this.source_component_id=n.source_component_id}},shn=class extends r2{get config(){return{componentName:"PushButton",schematicSymbolName:this.props.symbolName??"push_button_normally_open_momentary",zodProps:fdn,sourceFtype:gP.simple_push_button}}get defaultInternallyConnectedPinNames(){return[["pin1","pin4"],["pin2","pin3"]]}initPorts(){super.initPorts({pinCount:4,additionalAliases:{pin1:["side1"],pin3:["side2"]}})}doInitialSourceRender(){const{db:r}=this.root,{_parsedProps:e}=this,t=r.source_component.insert({name:e.name,ftype:gP.simple_push_button,supplier_part_numbers:e.supplierPartNumbers,are_pins_interchangeable:!0});this.source_component_id=t.source_component_id}},lhn=class extends r2{get config(){return{schematicSymbolName:this.props.symbolName??(this.props.pinVariant==="four_pin"?"crystal_4pin":"crystal"),componentName:"Crystal",zodProps:Hfn,sourceFtype:"simple_crystal"}}initPorts(){const r=this.props.pinVariant==="four_pin"?{pin1:["left1","1"],pin2:["top1","2","gnd1"],pin3:["right1","3"],pin4:["bottom1","4","gnd2"]}:{pin1:["pos","left"],pin2:["neg","right"]};super.initPorts({additionalAliases:r})}_getSchematicSymbolDisplayValue(){return`${Sb(this._parsedProps.frequency)}Hz`}doInitialSourceRender(){const{db:r}=this.root,{_parsedProps:e}=this,t=r.source_component.insert({name:e.name,ftype:"simple_crystal",frequency:e.frequency,load_capacitance:e.loadCapacitance,pin_variant:e.pinVariant||"two_pin",are_pins_interchangeable:(e.pinVariant||"two_pin")==="two_pin"});this.source_component_id=t.source_component_id}},chn=class extends r2{constructor(){super(...arguments);Qe(this,"emitter",this.portMap.pin1);Qe(this,"collector",this.portMap.pin2);Qe(this,"base",this.portMap.pin3)}get config(){return{componentName:"Transistor",schematicSymbolName:this.props.type==="npn"?"npn_bipolar_transistor":"pnp_bipolar_transistor",zodProps:ddn,sourceFtype:"simple_transistor",shouldRenderAsSchematicBox:!1}}initPorts(){const e=this.props.type==="npn"?{pin1:["emitter","e"],pin2:["collector","c"],pin3:["base","b"]}:{pin1:["collector","c"],pin2:["emitter","e"],pin3:["base","b"]};super.initPorts({pinCount:3,additionalAliases:e})}doInitialSourceRender(){const{db:e}=this.root,{_parsedProps:t}=this,n=e.source_component.insert({ftype:"simple_transistor",name:t.name,transistor_type:t.type});this.source_component_id=n.source_component_id}},uhn=class extends r2{get config(){const r=this.props.mosfetMode==="depletion"?"d":"e";return{componentName:"Mosfet",schematicSymbolName:`${this.props.channelType}_channel_${r}_mosfet_transistor`,zodProps:pdn,shouldRenderAsSchematicBox:!1}}doInitialSourceRender(){const{db:r}=this.root,{_parsedProps:e}=this,t=r.source_component.insert({ftype:"simple_mosfet",name:e.name,mosfet_mode:e.mosfetMode,channel_type:e.channelType});this.source_component_id=t.source_component_id}},fhn=class extends r2{_getSwitchType(){const{spst:r,spdt:e,dpst:t,dpdt:n,type:i}=this._parsedProps??{};return n?"dpdt":r?"spst":e?"spdt":t?"dpst":i??"spst"}get config(){const r=this._getSwitchType(),{isNormallyClosed:e}=this._parsedProps??{};return{componentName:"Switch",schematicSymbolName:{spst:e?"spst_normally_closed_switch":"spst_switch",spdt:e?"spdt_normally_closed_switch":"spdt_switch",dpst:e?"dpst_normally_closed_switch":"dpst_switch",dpdt:e?"dpdt_normally_closed_switch":"dpdt_switch"}[r]??"spst_switch",zodProps:bdn,shouldRenderAsSchematicBox:!1}}doInitialSourceRender(){const{db:r}=this.root,{_parsedProps:e}=this,t=r.source_component.insert({ftype:"simple_switch",name:e.name,switch_type:e.type,is_normally_closed:e.isNormallyClosed??!1,are_pins_interchangeable:this._getSwitchType()==="spst"});this.source_component_id=t.source_component_id}},dhn=class extends Jg{constructor(){super(...arguments);Qe(this,"isSchematicPrimitive",!0)}get config(){return{componentName:"SchematicText",zodProps:Adn}}doInitialSchematicPrimitiveRender(){var n;if((n=this.root)!=null&&n.schematicDisabled)return;const{db:e}=this.root,{_parsedProps:t}=this;e.schematic_text.insert({anchor:t.anchor??"center",text:t.text,font_size:t.fontSize,color:t.color||"#000000",position:{x:t.schX,y:t.schY},rotation:t.schRotation??0})}};new Proxy({},{get:(r,e)=>{const t=(...n)=>(n[0],new Proxy({},{get:(i,a)=>`.${e} > .${a}`}));return new Proxy(t,{get:(n,i)=>e==="net"?`net.${i}`:e==="subcircuit"?new Proxy({},{get:(a,o)=>new Proxy({},{get:(s,l)=>`subcircuit.${i} > .${o} > .${l}`})}):`.${e} > .${i}`,apply:(n,i,a)=>new Proxy({},{get:(o,s)=>{const l=`.${e} > .${s}`;return e.startsWith("U")?l:new Proxy(new String(l),{get:(c,u)=>typeof u=="symbol"||u==="toString"?()=>l:`.${e} > .${s} > .${u}`})}})})}}),lXe(oXe),lXe({Bug:CXe});const RXe=r=>`hsl(${Ub.indexOf(r)*137.5%360}, 70%, 50%)`,phn=({phaseTimings:r})=>{if(!r)return null;const e=Object.values(r).reduce((t,n)=>t+n,0);return ut.jsxs("div",{className:"rf-space-y-2 rf-w-full rf-px-4",children:[ut.jsx("div",{className:"rf-relative rf-h-8 rf-flex rf-rounded-sm",children:Ub.map(t=>{const n=r[t]||0,i=n/e*100;return ut.jsx("div",{className:"rf-group/bar rf-relative rf-overflow-visible",style:{width:`${i}%`,backgroundColor:RXe(t)},children:ut.jsxs("div",{className:"rf-opacity-0 group-hover/bar:rf-opacity-100 rf-transition-opacity rf-absolute rf-bottom-full rf-left-1/2 rf-transform -rf-translate-x-1/2 rf-mb-2 rf-px-2 rf-py-1 rf-text-xs rf-whitespace-nowrap rf-rounded rf-bg-gray-900 rf-text-white rf-pointer-events-none",children:[t,": ",n.toFixed(1),"ms"]})},t)})}),ut.jsxs("div",{className:"rf-text-xs rf-text-gray-500",children:["Total: ",e.toFixed(2),"ms"]})]})},hhn=({renderLog:r})=>{const[e,t]=mt.useState("chronological");if(!r)return ut.jsx("div",{className:"rf-p-4 rf-bg-gray-100 rf-rounded-md",children:"No render log, make sure this tab is open when you render (TODO add a rerender button here)"});const n=Object.entries((r==null?void 0:r.phaseTimings)??{});e==="chronological"?n.sort((a,o)=>Ub.indexOf(a[0])-Ub.indexOf(o[0])):n.sort((a,o)=>o[1]-a[1]);const i=n.reduce((a,[o,s])=>a+s,0);return ut.jsxs("div",{className:"rf-bg-white",children:[ut.jsxs("div",{className:"rf-flex rf-justify-between rf-items-center",children:[ut.jsx("div",{children:"Render Logs"}),ut.jsxs("div",{className:"rf-mb-4 rf-pr-2 rf-flex rf-text-xs rf-items-center",children:[ut.jsx("div",{className:"rf-mr-2",children:"Sort by:"}),ut.jsxs("select",{value:e,onChange:a=>t(a.target.value),className:"rf-px-2 rf-py-1 rf-border rf-rounded rf-text-xs",children:[ut.jsx("option",{value:"chronological",children:"Phase Order"}),ut.jsx("option",{value:"longest",children:"Duration"})]})]})]}),ut.jsx(phn,{phaseTimings:r.phaseTimings}),ut.jsxs("table",{className:"rf-w-full rf-text-xs",children:[ut.jsx("thead",{children:ut.jsxs("tr",{children:[ut.jsx("th",{className:"rf-text-left rf-p-2",children:"Phase Order"}),ut.jsx("th",{className:"rf-text-left rf-p-2",children:"Phase"}),ut.jsx("th",{className:"rf-text-left rf-p-2",children:"Duration (ms)"})]})}),ut.jsx("tbody",{children:n.map(([a,o])=>ut.jsxs("tr",{children:[ut.jsx("td",{className:"rf-p-2",children:Ub.indexOf(a)}),ut.jsx("td",{className:"rf-p-2",children:a}),ut.jsx("td",{className:"rf-p-2",children:ut.jsx("div",{className:"rf-w-8",children:ut.jsx("div",{className:"rf-h-2 rf-rounded-sm",style:{backgroundColor:RXe(a),width:`${o/i*100}%`}})})}),ut.jsx("td",{className:"rf-p-2",children:ut.jsxs("div",{className:"rf-flex w-full",children:[ut.jsxs("span",{className:"rf-flex-grow",children:[o,"ms"]}),ut.jsxs("span",{className:"rf-text-gray-500 rf-pr-2",children:[(o/i*100).toFixed(1),"%"]})]})})]},a))})]})]})},mhn="0.0.438",vhn=["assembly","bom","circuit_json","errors","render_log"],yhn=({code:r,onRunClicked:e=void 0,errorMessage:t,circuitJson:n,autoroutingGraphics:i,showRightHeaderContent:a=!0,showCodeTab:o=!1,codeTabContent:s,showJsonTab:l=!0,showRenderLogTab:c=!0,onActiveTabChange:u,renderLog:f,showImportAndFormatButtons:p=!0,className:v,headerClassName:x,leftHeaderContent:S,readOnly:w,isStreaming:b,autoroutingLog:C,onReportAutoroutingLog:z,isRunningCode:I,hasCodeChangedSinceLastRun:G,onEditEvent:Y,editEvents:Z,defaultActiveTab:W,autoRotate3dViewerDisabled:te,showSchematicDebugGrid:J=!1,showToggleFullScreen:fe=!0,defaultToFullScreen:he=!1})=>{var Ue;hfn();const ve=mt.useMemo(()=>n?n.filter(Ie=>Ie&&"error_type"in Ie):null,[n]),[Te,Pe]=mt.useState(W??"pcb"),[we,Ce]=mt.useState(he),be=mt.useCallback(Ie=>{Pe(Ie),u==null||u(Ie)},[u]),Le=()=>{Ce(!we)};return mt.useEffect(()=>{t&&be("errors")},[t]),mt.useEffect(()=>{(Te==="code"||Te==="errors")&&n&&!t&&be(W??"pcb")},[n]),ut.jsx("div",{className:Wy("flex flex-col relative rf-overflow-x-hidden",v),children:ut.jsx("div",{className:Wy("rf-md:sticky rf-md:top-2",we&&"rf-fixed rf-top-0 rf-left-0 rf-w-full rf-bg-white"),children:ut.jsxs(LKe,{value:Te,onValueChange:be,className:"rf-flex-grow rf-flex rf-flex-col",children:[ut.jsxs("div",{className:Wy("rf-flex rf-items-center rf-gap-2 rf-p-2 rf-pb-0",x),children:[S,S&&ut.jsx("div",{className:"rf-flex-grow"}),!S&&I&&ut.jsx(rze,{className:"rf-w-4 rf-h-4 rf-animate-spin"}),!S&&ut.jsx("div",{className:"rf-flex-grow"}),f&&f.progress!==1&&ut.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2",children:[f.lastRenderEvent&&ut.jsx("div",{className:"rf-text-xs rf-text-gray-500",children:((Ue=f.lastRenderEvent)==null?void 0:Ue.phase)??""}),ut.jsx("div",{className:"rf-w-4 rf-h-4 rf-bg-blue-500 rf-opacity-50 rf-rounded-full rf-text-white",children:ut.jsx(rze,{className:"rf-w-4 rf-h-4 rf-animate-spin"})}),ut.jsxs("div",{className:"rf-text-xs rf-font-bold rf-text-gray-700 rf-tabular-nums",children:[((f.progress??0)*100).toFixed(1),"%"]})]}),a&&ut.jsxs(nhe,{children:[o&&ut.jsx(ww,{value:"code",children:"Code"}),ut.jsxs(ww,{value:"pcb",className:"rf-whitespace-nowrap",children:[n&&ut.jsx("span",{className:Wy("rf-inline-flex rf-items-center rf-justify-center rf-w-2 rf-h-2 rf-mr-1 rf-text-xs rf-font-bold rf-text-white rf-rounded-full",G?"rf-bg-gray-500":"rf-bg-blue-500")}),"PCB"]}),ut.jsxs(ww,{value:"schematic",className:"rf-whitespace-nowrap",children:[n&&ut.jsx("span",{className:Wy("rf-inline-flex rf-items-center rf-justify-center rf-w-2 rf-h-2 rf-mr-1 rf-text-xs rf-font-bold rf-text-white rf-rounded-full",G?"rf-bg-gray-500":"rf-bg-blue-500")}),"Schematic"]}),ut.jsxs(ww,{value:"cad",children:[n&&ut.jsx("span",{className:Wy("inline-flex items-center justify-center w-2 h-2 mr-1 text-xs font-bold text-white rounded-full",G?"rf-bg-gray-500":"rf-bg-blue-500")}),"3D"]}),!["pcb","cad","schematic"].includes(Te)&&ut.jsx(ww,{value:Te,children:the(Te)}),ut.jsxs(pIe,{children:[ut.jsx(hIe,{asChild:!0,children:ut.jsxs("div",{className:"rf-whitespace-nowrap rf-p-2 rf-mr-1 rf-cursor-pointer rf-relative",children:[ut.jsx(PBt,{className:"rf-w-4 rf-h-4"}),(ve&&ve.length>0||t)&&ut.jsx("span",{className:"rf-inline-flex rf-absolute rf-top-[6px] rf-right-[4px] rf-items-center rf-justify-center rf-w-1 rf-h-1 rf-ml-2 rf-text-[8px] rf-font-bold rf-text-white rf-bg-red-500 rf-rounded-full"})]})}),ut.jsxs(Uoe,{className:"rf-*:text-xs",children:[vhn.map(Ie=>ut.jsxs(XI,{onSelect:()=>be(Ie),children:[Te!==Ie&&ut.jsx(nze,{className:"rf-w-3 rf-h-3 rf-opacity-30"}),Te===Ie&&ut.jsx(eze,{className:"rf-w-3 rf-h-3"}),ut.jsx("div",{className:"rf-pr-2",children:the(Ie)}),Ie==="errors"&&(ve&&ve.length>0||t)&&ut.jsx("span",{className:"rf-inline-flex rf-items-center rf-justify-center rf-w-3 rf-h-3 rf-ml-2 rf-text-[8px] rf-font-bold rf-text-white rf-bg-red-500 rf-rounded-full",children:t?1:ve==null?void 0:ve.length})]},Ie)),ut.jsx(XI,{disabled:!0,className:"rf-opacity-60 rf-cursor-default rf-select-none",children:ut.jsxs("div",{className:"rf-pr-2 rf-text-xs rf-text-gray-500",children:["@tscircuit/runframe@",mhn.split(".").map((Ie,ke)=>ke===2?parseInt(Ie)+1:Ie).join(".")]})})]})]})]}),fe&&ut.jsx(i6,{onClick:Le,variant:"ghost",children:we?ut.jsx(LBt,{size:16}):ut.jsx(NBt,{size:16})})]}),o&&ut.jsx(S4,{value:"code",className:"rf-flex-grow rf-overflow-hidden",children:ut.jsx("div",{className:"rf-h-full",children:s})}),ut.jsx(S4,{value:"pcb",children:ut.jsx("div",{className:Wy("rf-overflow-hidden",we?"rf-h-[calc(100vh-52px)]":"rf-h-[620px]"),children:ut.jsx(uT,{fallbackRender:({error:Ie})=>ut.jsx("div",{className:"rf-mt-4 rf-bg-red-50 rf-rounded-md rf-border rf-border-red-200",children:ut.jsxs("div",{className:"rf-p-4",children:[ut.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-red-800 rf-mb-3",children:"Error loading PCB viewer"}),ut.jsx("p",{className:"rf-text-xs rf-font-mono rf-whitespace-pre-wrap rf-text-red-600 rf-mt-2",children:(Ie==null?void 0:Ie.message)||"An unknown error occurred"})]})}),children:n?ut.jsx(dfn,{focusOnHover:!1,circuitJson:n,debugGraphics:i,containerClassName:Wy("rf-h-full rf-w-full",we?"rf-min-h-[calc(100vh-240px)]":"rf-min-h-[620px]"),onEditEventsChanged:Ie=>{Y&&Ie.forEach(ke=>Y(ke))}}):ut.jsx(Q7,{onRunClicked:e})})})}),ut.jsx(S4,{value:"assembly",children:ut.jsx("div",{className:Wy("rf-overflow-auto",we?"rf-h-[calc(100vh-96px)]":"rf-h-[620px]"),children:ut.jsx(uT,{fallback:ut.jsx("div",{children:"Error loading Assembly"}),children:n?ut.jsx(cQt,{circuitJson:n,containerStyle:{height:"100%"},editingEnabled:!0,debugGrid:!0}):ut.jsx(Q7,{onRunClicked:e})})})}),ut.jsx(S4,{value:"schematic",children:ut.jsx("div",{className:Wy("rf-overflow-auto rf-bg-white",we?"rf-h-[calc(100vh-96px)]":"rf-h-[620px]"),children:ut.jsx(uT,{fallbackRender:({error:Ie})=>ut.jsx("div",{className:"rf-mt-4 rf-bg-red-50 rf-rounded-md rf-border rf-border-red-200",children:ut.jsxs("div",{className:"rf-p-4",children:[ut.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-red-800 rf-mb-3",children:"Error loading Schematic"}),ut.jsx("p",{className:"rf-text-xs rf-font-mono rf-whitespace-pre-wrap rf-text-red-600 rf-mt-2",children:(Ie==null?void 0:Ie.message)||"An unknown error occurred"})]})}),children:n?ut.jsx(oQt,{circuitJson:n,containerStyle:{height:"100%"},editingEnabled:!0,onEditEvent:Ie=>{Y==null||Y(Ie)},debugGrid:J,colorOverrides:{schematic:{background:"transparent"}}}):ut.jsx(Q7,{onRunClicked:e})})})}),ut.jsx(S4,{value:"cad",children:ut.jsx("div",{className:Wy("rf-overflow-auto",we?"rf-h-[calc(100vh-96px)]":"rf-h-[620px]"),children:ut.jsx(uT,{FallbackComponent:vBt,children:n?ut.jsx(hBt,{soup:n,autoRotateDisabled:te}):ut.jsx(Q7,{onRunClicked:e})})})}),ut.jsx(S4,{value:"bom",children:ut.jsx("div",{className:Wy("rf-overflow-auto",we?"rf-h-[calc(100vh-96px)]":"rf-h-[620px]"),children:ut.jsx(uT,{fallbackRender:({error:Ie})=>ut.jsx("div",{className:"rf-mt-4 rf-bg-red-50 rf-rounded-md rf-border rf-border-red-200",children:ut.jsxs("div",{className:"rf-p-4",children:[ut.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-red-800 rf-mb-3",children:"Error loading Bill of Materials"}),ut.jsx("p",{className:"rf-text-xs rf-font-mono rf-whitespace-pre-wrap rf-text-red-600 rf-mt-2",children:(Ie==null?void 0:Ie.message)||"An unknown error occurred"})]})}),children:n?ut.jsx(hQt,{circuitJson:n}):ut.jsx(Q7,{onRunClicked:e})})})}),ut.jsx(S4,{value:"circuit_json",children:ut.jsx("div",{className:Wy("rf-overflow-auto",we?"rf-h-[calc(100vh-96px)]":"rf-h-[620px]"),children:ut.jsx(uT,{fallback:ut.jsx("div",{children:"Error loading JSON viewer"}),children:n?ut.jsx(dQt,{elements:n}):ut.jsx(Q7,{onRunClicked:e})})})}),ut.jsx(S4,{value:"errors",children:ut.jsx("div",{className:Wy("rf-overflow-auto",we?"rf-h-[calc(100vh-96px)]":"rf-h-[620px]"),children:Array.isArray(ve)&&ve.length>0||t?ut.jsx(P$t,{code:r,circuitJsonErrors:ve,errorMessage:t,autoroutingLog:C,onReportAutoroutingLog:z}):ut.jsx(Q7,{onRunClicked:e})})}),c&&ut.jsx(S4,{value:"render_log",children:ut.jsx(hhn,{renderLog:f})})]})})})};Spe.createRoot(document.getElementById("root")).render(ut.jsx(yhn,{defaultActiveTab:"cad",autoRotate3dViewerDisabled:!0,showRightHeaderContent:!1,circuitJson:window.CIRCUIT_JSON||{},...window.CIRCUIT_JSON_PREVIEW_PROPS||{}}))});
|
|
13425
|
+
searched component ${c.getString()}, which has ports: ${c.children.filter(u=>u.componentName==="Port").map(u=>`${u.getString()}(${u.getNameAndAliases().join(",")})`).join(" & ")}`):this.renderError(`Could not find port for selector "${o}"`)}return a.some(o=>!o.port)?{allPortsFound:!1}:{allPortsFound:!0,portsWithSelectors:a,ports:a.map(({port:o})=>o)}}_findConnectedNets(){const e=this.getTracePathNetSelectors().map(n=>({selector:n,net:this.getSubcircuit().selectOne(n,{type:"net"})})),t=e.filter(n=>!n.net);return t.length>0&&this.renderError(`Could not find net for selector "${t[0].selector}" inside ${this}`),{netsWithSelectors:e,nets:e.map(n=>n.net)}}_getAllTracesConnectedToSameNet(){const e=this.getSubcircuit().selectAll("trace"),t=this._findConnectedNets().nets,n=this._findConnectedPorts().ports??[];return e.filter(i=>{if(i===this)return!1;const a=i._findConnectedNets().nets,o=i._findConnectedPorts().ports??[];return a.some(s=>t.includes(s))||o.some(s=>n.includes(s))})}_isExplicitlyConnectedToPort(e){const{allPortsFound:t,portsWithSelectors:n}=this._findConnectedPorts();return t?n.map(a=>a.port).includes(e):!1}_isExplicitlyConnectedToNet(e){return this._findConnectedNets().nets.includes(e)}doInitialCreateNetsFromProps(){hXe(this,this.getTracePathNetSelectors())}_computeTraceConnectionHash(){const{allPortsFound:e,ports:t}=this._findConnectedPorts();return!e||!t?null:[...t].sort((a,o)=>(a.pcb_port_id||"").localeCompare(o.pcb_port_id||"")).map(a=>a.pcb_port_id).join(",")}doInitialSourceTraceRender(){var f;const{db:e}=this.root,{_parsedProps:t,parent:n}=this;if(!n){this.renderError("Trace has no parent");return}const{allPortsFound:i,portsWithSelectors:a}=this._findConnectedPorts();if(!i)return;this._traceConnectionHash=this._computeTraceConnectionHash();const s=e.source_trace.list().find(p=>p.subcircuit_connectivity_map_key===this.subcircuit_connectivity_map_key&&p.connected_source_port_ids.sort().join(",")===this._traceConnectionHash);if(s){this.source_trace_id=s.source_trace_id;return}const l=this._findConnectedNets().nets,c=Apn({ports:a,nets:l}),u=e.source_trace.insert({connected_source_port_ids:a.map(p=>p.port.source_port_id),connected_source_net_ids:l.map(p=>p.source_net_id),subcircuit_id:(f=this.getSubcircuit())==null?void 0:f.subcircuit_id,max_length:Tpn(a.map(p=>p.port),{db:e})??t.maxLength,display_name:c,min_trace_thickness:t.thickness});this.source_trace_id=u.source_trace_id}_insertErrorIfTraceIsOutsideBoard(e,t){const{db:n}=this.root;Npn(e,{db:n})&&n.pcb_trace_error.insert({error_type:"pcb_trace_error",source_trace_id:this.source_trace_id,message:`Trace ${this.getString()} routed outside the board boundaries.`,pcb_trace_id:this.pcb_trace_id,pcb_component_ids:[],pcb_port_ids:t.map(a=>a.pcb_port_id)})}doInitialPcbTraceRender(){var W,te,J,fe;if((W=this.root)!=null&&W.pcbDisabled)return;const{db:e}=this.root,{_parsedProps:t,parent:n}=this,i=this.getSubcircuit();if(!n)throw new Error("Trace has no parent");if(i._parsedProps.routingDisabled)return;const a=(te=i._parsedProps.pcbRouteCache)==null?void 0:te.pcbTraces;if(a){const he=e.pcb_trace.insert({route:a.flatMap(ve=>ve.route),source_trace_id:this.source_trace_id,subcircuit_id:(i==null?void 0:i.subcircuit_id)??void 0,pcb_group_id:((J=this.getGroup())==null?void 0:J.pcb_group_id)??void 0});this.pcb_trace_id=he.pcb_trace_id;return}if(!i._shouldUseTraceByTraceRouting())return;const{allPortsFound:o,ports:s}=this._findConnectedPorts();if(!o)return;const l=[];for(const he of s)he._hasMatchedPcbPrimitive()||l.push(he);if(l.length>0){e.pcb_trace_error.insert({error_type:"pcb_trace_error",source_trace_id:this.source_trace_id,message:`Some ports did not have a matching PCB primitive (e.g. a pad or plated hole), this can happen if a footprint is missing. As a result, ${this} wasn't routed. Missing ports: ${l.map(he=>he.getString()).join(", ")}`,pcb_trace_id:this.pcb_trace_id,pcb_component_ids:[],pcb_port_ids:l.map(he=>he.pcb_port_id).filter(Boolean)});return}const c=this._findConnectedNets().netsWithSelectors;if(s.length===0&&c.length===2){this.renderError("Trace connects two nets, we haven't implemented a way to route this yet");return}else if(s.length===1&&c.length===1){const he=s[0],Te=c[0].net.getAllConnectedPorts().filter(we=>we!==he);if(Te.length===0){console.log("Nothing to connect this port to, the net is empty. TODO should emit a warning!");return}const Pe=ypn(he,Te);s.push(Pe)}else if(s.length>1&&c.length>=1){this.renderError("Trace has more than one port and one or more nets, we don't currently support this type of complex trace routing");return}const u=s.flatMap(he=>he.matchedComponents.filter(ve=>ve.componentName==="TraceHint")),f=(this._parsedProps.pcbRouteHints??[]).concat(u.flatMap(he=>he.getPcbRouteHints()));if(s.length>2){this.renderError(`Trace has more than two ports (${s.map(he=>he.getString()).join(", ")}), routing between more than two ports for a single trace is not implemented`);return}if(this.getSubcircuit().selectAll("trace").filter(he=>he.renderPhaseStates.PcbTraceRender.initialized).some(he=>he._portsRoutedOnPcb.length===s.length&&he._portsRoutedOnPcb.every(ve=>s.includes(ve))))return;let x=[];f.length===0?x=[gj(s[0]),gj(s[1])]:x=[gj(s[0]),...f,gj(s[1])];const S=vj(x),w=M8(this.root.db.toArray()),[b,C]=_pn(()=>$w(this.root.db.toArray()));if(C){this.renderError({type:"pcb_trace_error",error_type:"pcb_trace_error",pcb_trace_error_id:this.pcb_trace_id,message:`Error getting obstacles for autorouting: ${C.message}`,source_trace_id:this.source_trace_id,center:{x:0,y:0},pcb_port_ids:s.map(he=>he.pcb_port_id),pcb_trace_id:this.pcb_trace_id,pcb_component_ids:[]});return}for(const he of b)if(he.connectedTo.length>0){const Te=w.getNetConnectedToId(he.connectedTo[0]);Te&&he.connectedTo.push(Te)}let z=[];if(S.length===0)z=x;else{const he=S[0].layer_path;z=x.map((ve,Te)=>ve.via?{...ve,via_to_layer:he[Te]}:{...ve,layers:[he[Te]]})}z[0].pcb_port_id=s[0].pcb_port_id,z[z.length-1].pcb_port_id=s[1].pcb_port_id;const I=[];for(const[he,ve]of dXe(z)){const Te="via_to_layer"in he?he.via_to_layer:null,Pe=2,we="layers"in he&&he.layers.length===1?he.layers[0]:Te??"top",Ce="layers"in ve&&ve.layers.length===1?ve.layers[0]:Te??"top",be="pcb_port_id"in he?he.pcb_port_id:null,Le="pcb_port_id"in ve?ve.pcb_port_id:null,Ue=this.getSubcircuit()._parsedProps.minTraceWidth??.16,Ie=new Vw({OBSTACLE_MARGIN:Ue*2,isRemovePathLoopsEnabled:!0,optimizeWithGoalBoxes:!!(be&&Le),connMap:w,input:{obstacles:b,minTraceWidth:Ue,connections:[{name:this.source_trace_id,pointsToConnect:[{...he,layer:we,pcb_port_id:be},{...ve,layer:Ce,pcb_port_id:Le}]}],layerCount:2,bounds:{minX:Math.min(he.x,ve.x)-Pe,maxX:Math.max(he.x,ve.x)+Pe,minY:Math.min(he.y,ve.y)-Pe,maxY:Math.max(he.y,ve.y)+Pe}}});let ke=null;try{ke=Ie.solveAndMapToTraces()}catch(gt){this.renderError({type:"pcb_trace_error",pcb_trace_error_id:this.source_trace_id,error_type:"pcb_trace_error",message:`error solving route: ${gt.message}`,source_trace_id:this.pcb_trace_id,center:{x:(he.x+ve.x)/2,y:(he.y+ve.y)/2},pcb_port_ids:s.map(wt=>wt.pcb_port_id),pcb_trace_id:this.pcb_trace_id,pcb_component_ids:s.map(wt=>wt.pcb_component_id)})}if(!ke)return;if(ke.length===0){this.renderError({type:"pcb_trace_error",error_type:"pcb_trace_error",pcb_trace_error_id:this.pcb_trace_id,message:`Could not find a route for ${this}`,source_trace_id:this.source_trace_id,center:{x:(he.x+ve.x)/2,y:(he.y+ve.y)/2},pcb_port_ids:s.map(gt=>gt.pcb_port_id),pcb_trace_id:this.pcb_trace_id,pcb_component_ids:s.map(gt=>gt.pcb_component_id)});return}const[at]=ke;Te&&(at.route=at.route.map(gt=>(gt.route_type==="wire"&&!gt.layer&&(gt.layer=Te),gt))),be&&at.route[0].route_type==="wire"&&(at.route[0].start_pcb_port_id=be);const nt=at.route[at.route.length-1];Le&&nt.route_type==="wire"&&(nt.end_pcb_port_id=Le),I.push(at.route)}const G=mpn(I),Y=xpn(G),Z=e.pcb_trace.insert({route:G,source_trace_id:this.source_trace_id,subcircuit_id:(fe=this.getSubcircuit())==null?void 0:fe.subcircuit_id,trace_length:Y});this._portsRoutedOnPcb=s,this.pcb_trace_id=Z.pcb_trace_id;for(const he of G)he.route_type==="via"&&e.pcb_via.insert({pcb_trace_id:Z.pcb_trace_id,x:he.x,y:he.y,hole_diameter:.3,outer_diameter:.6,layers:[he.from_layer,he.to_layer],from_layer:he.from_layer,to_layer:he.to_layer});this._insertErrorIfTraceIsOutsideBoard(G,s)}_doInitialSchematicTraceRenderWithDisplayLabel(){var I,G,Y,Z;if((I=this.root)!=null&&I.schematicDisabled)return;const{db:e}=this.root,{_parsedProps:t,parent:n}=this;if(!n)throw new Error("Trace has no parent");const{allPortsFound:i,portsWithSelectors:a}=this._findConnectedPorts();if(!i)return;const o=a.map(({port:W})=>({port:W,position:W._getGlobalSchematicPositionAfterLayout(),schematic_port_id:W.schematic_port_id,facingDirection:W.facingDirection}));if(o.length<2)throw new Error("Expected at least two ports in portsWithPosition.");let s,l;const c=o[0].position,u=o[0].port;if("path"in this.props){if(this.props.path.length!==2)throw new Error("Invalid 'path': Must contain exactly two elements.");[s,l]=this.props.path}else{if(!("from"in this.props&&"to"in this.props))throw new Error("Missing 'from' or 'to' properties in props.");s=this.props.from,l=this.props.to}if(!u.source_port_id)throw new Error(`Missing source_port_id for the 'from' port (${s}).`);const f=o[1].position,p=o[1].port;if(!p.source_port_id)throw new Error(`Missing source_port_id for the 'to' port (${l}).`);const v=e.schematic_net_label.list().find(W=>W.source_net_id===u.source_port_id),x=e.schematic_net_label.list().find(W=>W.source_net_id===p.source_port_id),[S,w]=a.map(({port:W})=>W),C=((G=S.parent)==null?void 0:G.config.shouldRenderAsSchematicBox)?`${(Y=S==null?void 0:S.parent)==null?void 0:Y.props.name}_${S==null?void 0:S.props.name}`:`${(Z=w==null?void 0:w.parent)==null?void 0:Z.props.name}_${w==null?void 0:w.props.name}`,z=this.props.schDisplayLabel??C;if(v&&v.text!==z&&(v.text=`${z} / ${v.text}`),x&&(x==null?void 0:x.text)!==z&&(x.text=`${z} / ${x.text}`),z!=null&&z.toLocaleLowerCase().includes("gnd")||z!=null&&z.toLocaleLowerCase().includes("ground")){!v&&!x?(yj({port:u,anchorPos:c,schDisplayLabel:this.props.schDisplayLabel,source_trace_id:this.source_trace_id},{db:e}),yj({port:p,anchorPos:f,schDisplayLabel:this.props.schDisplayLabel,source_trace_id:this.source_trace_id},{db:e})):v?x||yj({port:p,anchorPos:f,schDisplayLabel:this.props.schDisplayLabel,source_trace_id:this.source_trace_id},{db:e}):yj({port:u,anchorPos:c,schDisplayLabel:this.props.schDisplayLabel,source_trace_id:this.source_trace_id},{db:e});return}x||e.schematic_net_label.insert({text:this.props.schDisplayLabel??C,source_net_id:p.source_port_id,anchor_position:f,center:f,anchor_side:qfe(p.facingDirection)??"bottom"}),v||e.schematic_net_label.insert({text:this.props.schDisplayLabel??C,source_net_id:u.source_port_id,anchor_position:c,center:c,anchor_side:qfe(u.facingDirection)??"bottom"})}_isSymbolToChipConnection(){const{allPortsFound:e,ports:t}=this._findConnectedPorts();if(!e||t.length!==2)return!1;const[n,i]=t;if(!(n!=null&&n.parent)||!(i!=null&&i.parent))return!1;const a=n.parent.config.shouldRenderAsSchematicBox,o=i.parent.config.shouldRenderAsSchematicBox;return a&&!o||!a&&o}_isSymbolToSymbolConnection(){const{allPortsFound:e,ports:t}=this._findConnectedPorts();if(!e||t.length!==2)return!1;const[n,i]=t;if(!(n!=null&&n.parent)||!(i!=null&&i.parent))return!1;const a=!n.parent.config.shouldRenderAsSchematicBox,o=!i.parent.config.shouldRenderAsSchematicBox;return a&&o}_isChipToChipConnection(){const{allPortsFound:e,ports:t}=this._findConnectedPorts();if(!e||t.length!==2)return!1;const[n,i]=t;if(!(n!=null&&n.parent)||!(i!=null&&i.parent))return!1;const a=n.parent.config.shouldRenderAsSchematicBox,o=i.parent.config.shouldRenderAsSchematicBox;return a&&o}doInitialSchematicTraceRender(){var we,Ce;if((we=this.root)!=null&&we.schematicDisabled)return;const{db:e}=this.root,{_parsedProps:t,parent:n}=this;if(!n)throw new Error("Trace has no parent");const{allPortsFound:i,portsWithSelectors:a}=this._findConnectedPorts(),{netsWithSelectors:o}=this._findConnectedNets();if(!i)return;const l=a.map(be=>be.port.schematic_port_id).sort().join(","),c=(Ce=this.root)==null?void 0:Ce._getBoard();if(c!=null&&c._connectedSchematicPortPairs&&c._connectedSchematicPortPairs.has(l))return;if(this.props.schDisplayLabel&&("from"in this.props&&"to"in this.props||"path"in this.props)){this._doInitialSchematicTraceRenderWithDisplayLabel();return}const u={name:this.source_trace_id,pointsToConnect:[]},f=Rpn(this),p=a.map(({port:be})=>({port:be,position:be._getGlobalSchematicPositionAfterLayout(),schematic_port_id:be.schematic_port_id??void 0,facingDirection:be.facingDirection}));if(p.length===1&&o.length===1){const be=o[0].net,{port:Le,position:Ue}=p[0];e.schematic_net_label.insert({text:be._parsedProps.name,source_net_id:be.source_net_id,anchor_position:Ue,center:Ue,anchor_side:qfe(Le.facingDirection)??"bottom"});return}if(p.length<2)return;u.pointsToConnect=p.map(({position:be})=>({...be,layer:"top"}));const x=hpn(f),S=2,w={minTraceWidth:.1,obstacles:f,connections:[u],bounds:{minX:x.minX-S,maxX:x.maxX+S,minY:x.minY-S,maxY:x.maxY+S},layerCount:1};let b=Vw,C=!1;this.getSubcircuit().props._schDirectLineRoutingEnabled&&(b=SXe,C=!0);let I=new b({input:w,MAX_ITERATIONS:100,OBSTACLE_MARGIN:.1,isRemovePathLoopsEnabled:!0,isShortenPathWithShortcutsEnabled:!0,marginsWithCosts:[{margin:1,enterCost:0,travelCostFactor:1},{margin:.3,enterCost:0,travelCostFactor:1},{margin:.2,enterCost:0,travelCostFactor:2},{margin:.1,enterCost:0,travelCostFactor:3}]}).solveAndMapToTraces();if(I.length===0){if(this._isSymbolToChipConnection()||this._isSymbolToSymbolConnection()||this._isChipToChipConnection()){this._doInitialSchematicTraceRenderWithDisplayLabel();return}I=new SXe({input:w}).solveAndMapToTraces(),C=!0}const[{route:G}]=I;let Y=[];for(let be=0;be<G.length-1;be++)Y.push({from:G[be],to:G[be+1]});const Z=this.source_trace_id;let W=[];if(!C){Ppn({edges:Y,db:e,source_trace_id:Z});const be=Xfe({db:e,source_trace_id:Z,differentNetOnly:!0}).flatMap(Le=>Le.edges);Y=Spn({edges:Y,otherEdges:be}),W=Epn({edges:Y,db:e,source_trace_id:this.source_trace_id})}const te=Y[Y.length-1],J=p[p.length-1],fe=EXe(te);Y.push(...Yfe({lastEdge:te,lastEdgePort:J,lastDominantDirection:fe}));const he=Y[0],ve=p[0],Te=EXe(he);if(Y.unshift(...Yfe({firstEdge:he,firstEdgePort:ve,firstDominantDirection:Te})),!this.source_trace_id)throw new Error("Missing source_trace_id for schematic trace insertion.");if(this.getSubcircuit()._parsedProps.schTraceAutoLabelEnabled&&gpn(W,Y)>=5&&(this._isSymbolToChipConnection()||this._isSymbolToSymbolConnection()||this._isChipToChipConnection())){this._doInitialSchematicTraceRenderWithDisplayLabel();return}const Pe=e.schematic_trace.insert({source_trace_id:this.source_trace_id,edges:Y,junctions:W});this.schematic_trace_id=Pe.schematic_trace_id,c!=null&&c._connectedSchematicPortPairs&&c._connectedSchematicPortPairs.add(l)}},Dpn=P9("tscircuit:core"),Lpn=R.object({x:Yb,y:Yb,z:Yb}),r2=class extends Jg{constructor(e){super(e);Qe(this,"reactSubtrees",[]);Qe(this,"_impliedFootprint");Qe(this,"isPrimitiveContainer",!0);Qe(this,"_asyncSupplierPartNumbers");Qe(this,"pcb_missing_footprint_error_id");this._addChildrenFromStringFootprint(),this.initPorts()}get defaultInternallyConnectedPinNames(){return[]}get internallyConnectedPinNames(){return this._parsedProps.internallyConnectedPins??this.defaultInternallyConnectedPinNames}initPorts(e={}){var o,s,l,c,u,f,p,v,x,S;if((o=this.root)!=null&&o.schematicDisabled)return;const{config:t}=this,n=[],i=this._getSchematicPortArrangement();if(i&&!this._parsedProps.pinLabels){for(const C in i){const z=i[C].pins;if(Array.isArray(z))for(const I of z){const G=vP(I,this._parsedProps.pinLabels);n.push(new dS({pinNumber:G,aliases:((s=e.additionalAliases)==null?void 0:s[`pin${G}`])??[]},{originDescription:`schPortArrangement:${C}`}))}}const w=["left","right","top","bottom"];let b=1;for(const C of w){const z=i[`${C}Size`];for(let I=0;I<z;I++)n.push(new dS({pinNumber:b++,aliases:((l=e.additionalAliases)==null?void 0:l[`pin${b}`])??[]},{originDescription:`schPortArrangement:${C}`}))}}const a=this._parsedProps.pinLabels;if(a)for(let[w,b]of Object.entries(a)){w=w.replace("pin","");let C=n.find(G=>G._parsedProps.pinNumber===Number(w));const z=Array.isArray(b)?b[0]:b,I=Array.isArray(b)?b.slice(1):[];C?(C.externallyAddedAliases.push(z,...I),C.props.name=z):(C=new dS({pinNumber:parseInt(w),name:z,aliases:[...I,...((c=e.additionalAliases)==null?void 0:c[`pin${parseInt(w)}`])??[]]},{originDescription:`pinLabels:pin${w}`}),n.push(C))}if(t.schematicSymbolName){const w=k3[this._getSchematicSymbolNameOrThrow()];if(!w)return;for(const b of w.ports){const C=xXe(b.labels);if(!C)continue;const z=n.find(I=>I._parsedProps.pinNumber===Number(C));if(z)z.schematicSymbolPortDef=b;else{const I=yP(b.labels.concat(((u=e.additionalAliases)==null?void 0:u[`pin${C}`])??[]));I&&(I.originDescription=`schematicSymbol:labels[0]:${b.labels[0]}`,I.schematicSymbolPortDef=b,n.push(I))}}this.addAll(n)}if(!this._getSchematicPortArrangement()){const w=this.getPortsFromFootprint(e);for(const b of w)n.some(C=>C.isMatchingAnyOf(b.getNameAndAliases()))||n.push(b)}for(let w=1;w<=(e.pinCount??this._getPinCount());w++){if(!i||n.find(C=>C._parsedProps.pinNumber===w))continue;let b=[...((f=i.leftSide)==null?void 0:f.pins)??[],...((p=i.rightSide)==null?void 0:p.pins)??[],...((v=i.topSide)==null?void 0:v.pins)??[],...((x=i.bottomSide)==null?void 0:x.pins)??[]].map(C=>vP(C,this._parsedProps.pinLabels));["leftSize","rightSize","topSize","bottomSize","leftPinCount","rightPinCount","topPinCount","bottomPinCount"].some(C=>C in i)&&(b=Array.from({length:this._getPinCount()},(C,z)=>z+1)),b.includes(w)&&n.push(new dS({pinNumber:w,aliases:((S=e.additionalAliases)==null?void 0:S[`pin${w}`])??[]},{originDescription:`notOtherwiseAddedButDeducedFromPinCount:${w}`}))}n.length>0&&this.addAll(n)}_getImpliedFootprintString(){return null}_addChildrenFromStringFootprint(){var a;const{name:e,pcbRotation:t,pinLabels:n}=this.props;let{footprint:i}=this.props;if(i??(i=(a=this._getImpliedFootprintString)==null?void 0:a.call(this)),!!i&&typeof i=="string"){const o=Uw.string(i).soup(),s=rpn({componentName:e,componentRotation:t,footprint:i,pinLabels:n},o);this.addAll(s)}}get portMap(){return new Proxy({},{get:(e,t)=>{const n=this.children.find(i=>i.componentName==="Port"&&i.isMatchingNameOrAlias(t));if(!n)throw new Error(`There was an issue finding the port "${t.toString()}" inside of a ${this.componentName} component with name: "${this.props.name}". This is a bug in @tscircuit/core`);return n}})}getInstanceForReactElement(e){for(const t of this.reactSubtrees)if(t.element===e)return t.component;return null}doInitialSourceRender(){const e=this.config.sourceFtype;if(!e)return;const{db:t}=this.root,{_parsedProps:n}=this,i=t.source_component.insert({ftype:e,name:n.name,manufacturer_part_number:n.manufacturerPartNumber??n.mfn,supplier_part_numbers:n.supplierPartNumbers});this.source_component_id=i.source_component_id}doInitialSchematicComponentRender(){var i,a,o;if((i=this.root)!=null&&i.schematicDisabled)return;const{db:e}=this.root,{schematicSymbolName:t}=this.config;t?this._doInitialSchematicComponentRenderWithSymbol():this._getSchematicBoxDimensions()&&this._doInitialSchematicComponentRenderWithSchematicBoxDimensions();const n=(a=this.getSubcircuit())==null?void 0:a._getSchematicManualPlacementForComponent(this);if(this.schematic_component_id&&(this.props.schX!==void 0||this.props.schY!==void 0)&&n){if(!this.schematic_component_id)return;const s=zH.parse({type:"schematic_manual_edit_conflict_warning",schematic_manual_edit_conflict_warning_id:`schematic_manual_edit_conflict_${this.source_component_id}`,message:`${this.getString()} has both manual placement and prop coordinates. schX and schY will be used. Remove schX/schY or clear the manual placement.`,schematic_component_id:this.schematic_component_id,source_component_id:this.source_component_id,subcircuit_id:(o=this.getSubcircuit())==null?void 0:o.subcircuit_id});e.schematic_manual_edit_conflict_warning.insert(s)}}_getSchematicSymbolDisplayValue(){}_getInternallyConnectedPins(){if(this.internallyConnectedPinNames.length===0)return[];const e=[];for(const t of this.internallyConnectedPinNames){const n=[];for(const i of t)n.push(this.portMap[i]);e.push(n)}return e}_doInitialSchematicComponentRenderWithSymbol(){var o;if((o=this.root)!=null&&o.schematicDisabled)return;const{db:e}=this.root,{_parsedProps:t}=this,n=this._getSchematicSymbolNameOrThrow(),i=k3[n],a=this._getGlobalSchematicPositionBeforeLayout();if(i){const s=e.schematic_component.insert({center:a,size:i.size,source_component_id:this.source_component_id,symbol_name:n,symbol_display_value:this._getSchematicSymbolDisplayValue()});this.schematic_component_id=s.schematic_component_id}}_doInitialSchematicComponentRenderWithSchematicBoxDimensions(){var f;if((f=this.root)!=null&&f.schematicDisabled)return;const{db:e}=this.root,{_parsedProps:t}=this,n=this._getSchematicBoxDimensions(),i={};if(Array.isArray(t.pinLabels))t.pinLabels.forEach((p,v)=>{i[String(v+1)]=p});else for(const[p,v]of Object.entries(t.pinLabels??{}))i[p]=Array.isArray(v)?v[0]:v;const a=this._getGlobalSchematicPositionBeforeLayout(),o=this._getSchematicPortArrangement(),s=e.schematic_component.insert({center:a,rotation:t.schRotation??0,size:n.getSize(),port_arrangement:Qdn(o),pin_spacing:t.schPinSpacing??.2,pin_styles:Zdn(t.schPinStyle,t.pinLabels),port_labels:i,source_component_id:this.source_component_id}),l=(o==null?void 0:o.topSide)!==void 0||(o==null?void 0:o.bottomSide)!==void 0,c=n==null?void 0:n.getSize().width,u=n==null?void 0:n.getSize().height;e.schematic_text.insert({text:t.manufacturerPartNumber??"",schematic_component_id:s.schematic_component_id,anchor:"left",rotation:0,position:{x:l?a.x+(c??0)/2+.1:a.x-(c??0)/2,y:l?a.y+(u??0)/2+.35:a.y-(u??0)/2-.13},color:"#006464",font_size:.05}),e.schematic_text.insert({text:t.name??"",schematic_component_id:s.schematic_component_id,anchor:"left",rotation:0,position:{x:l?a.x+(c??0)/2+.1:a.x-(c??0)/2,y:l?a.y+(u??0)/2+.55:a.y+(u??0)/2+.13},color:"#006464",font_size:.05}),this.schematic_component_id=s.schematic_component_id}doInitialPcbComponentRender(){var o;if((o=this.root)!=null&&o.pcbDisabled)return;const{db:e}=this.root,{_parsedProps:t}=this,n=this.getSubcircuit(),i=e.pcb_component.insert({center:this._getGlobalPcbPositionBeforeLayout(),width:0,height:0,layer:t.layer??"top",rotation:t.pcbRotation??0,source_component_id:this.source_component_id,subcircuit_id:n.subcircuit_id??void 0});if(!t.footprint&&!this.isGroup){const s=e.pcb_missing_footprint_error.insert({message:`No footprint found for component: ${this.getString()}`,source_component_id:`${this.source_component_id}`,error_type:"pcb_missing_footprint_error"});this.pcb_missing_footprint_error_id=s.pcb_missing_footprint_error_id}this.pcb_component_id=i.pcb_component_id;const a=this.getSubcircuit()._getPcbManualPlacementForComponent(this);if((this.props.pcbX!==void 0||this.props.pcbY!==void 0)&&a){const s=kH.parse({type:"pcb_manual_edit_conflict_warning",pcb_manual_edit_conflict_warning_id:`pcb_manual_edit_conflict_${this.source_component_id}`,message:`${this.getString()} has both manual placement and prop coordinates. pcbX and pcbY will be used. Remove pcbX/pcbY or clear the manual placement.`,pcb_component_id:this.pcb_component_id,source_component_id:this.source_component_id,subcircuit_id:n.subcircuit_id??void 0});e.pcb_manual_edit_conflict_warning.insert(s)}}doInitialPcbComponentSizeCalculation(){var a;if((a=this.root)!=null&&a.pcbDisabled||!this.pcb_component_id)return;const{db:e}=this.root,{_parsedProps:t}=this,n=_Xe(this.children);if(n.width===0||n.height===0)return;const i={x:(n.minX+n.maxX)/2,y:(n.minY+n.maxY)/2};e.pcb_component.update(this.pcb_component_id,{center:i,width:n.width,height:n.height})}_renderReactSubtree(e){return{element:e,component:Wdn(e)}}doInitialInitializePortsFromChildren(){this.initPorts()}doInitialReactSubtreesRender(){if(mt.isValidElement(this.props.footprint)){if(this.reactSubtrees.some(t=>t.element===this.props.footprint))return;const e=this._renderReactSubtree(this.props.footprint);this.reactSubtrees.push(e),this.add(e.component)}}_hasExistingPortExactly(e){return this.children.filter(n=>n.componentName==="Port").some(n=>{const i=e.getNameAndAliases(),a=n.getNameAndAliases();return i.length===a.length&&i.every(o=>a.includes(o))})}add(e){let t;if(mt.isValidElement(e)){const n=this._renderReactSubtree(e);this.reactSubtrees.push(n),t=n.component}else t=e;if(t.componentName==="Port"){if(this._hasExistingPortExactly(t))return;const i=this.children.filter(a=>a.componentName==="Port").find(a=>a.isMatchingAnyOf(t.getNameAndAliases()));i&&Dpn(`Similar ports added. Port 1: ${i}, Port 2: ${t}`)}super.add(t)}getPortsFromFootprint(e){let{footprint:t}=this.props;if((!t||mt.isValidElement(t))&&(t=this.children.find(i=>i.componentName==="Footprint")),typeof t=="string"){const i=Uw.string(t).soup(),a=[];for(const o of i)if("port_hints"in o&&o.port_hints){const s=yP(o.port_hints,e);if(!s)continue;s.originDescription=`footprint:string:${t}:port_hints[0]:${o.port_hints[0]}`,a.push(s)}return a}if(!mt.isValidElement(t)&&t&&t.componentName==="Footprint"){const i=t;let a=1;const o=[];for(const s of i.children){if(!s.props.portHints)continue;let l=s.props.portHints;l.some(f=>f.startsWith("pin"))||(l=[...l,`pin${a}`]),a++;const u=yP(l);u&&(u.originDescription=`footprint:${t}`,o.push(u))}return o}const n=[];if(!t){for(const i of this.children)if(i.props.portHints&&i.isPcbPrimitive){const a=yP(i.props.portHints);a&&n.push(a)}}return n}getPortsFromSchematicSymbol(){var i;if((i=this.root)!=null&&i.schematicDisabled)return[];const{config:e}=this;if(!e.schematicSymbolName)return[];const t=k3[e.schematicSymbolName];if(!t)return[];const n=[];for(const a of t.ports){const o=yP(a.labels);o&&(o.schematicSymbolPortDef=a,n.push(o))}return n}doInitialCreateNetsFromProps(){this._createNetsFromProps(this._getNetsFromConnectionsProp())}_getNetsFromConnectionsProp(){const{_parsedProps:e}=this,t=[];if(e.connections)for(const[n,i]of Object.entries(e.connections)){const a=Array.isArray(i)?i:[i];for(const o of a)t.push(o)}return t}_createNetsFromProps(e){hXe(this,e)}_getPcbCircuitJsonBounds(){const{db:e}=this.root;if(!this.pcb_component_id)return super._getPcbCircuitJsonBounds();const t=e.pcb_component.get(this.pcb_component_id);return{center:{x:t.center.x,y:t.center.y},bounds:{left:t.center.x-t.width/2,top:t.center.y-t.height/2,right:t.center.x+t.width/2,bottom:t.center.y+t.height/2},width:t.width,height:t.height}}_getPinCountFromSchematicPortArrangement(){const e=this._getSchematicPortArrangement();if(!e)return 0;if(!bXe(e))return(e.leftSize??e.leftPinCount??0)+(e.rightSize??e.rightPinCount??0)+(e.topSize??e.topPinCount??0)+(e.bottomSize??e.bottomPinCount??0);const{leftSide:n,rightSide:i,topSide:a,bottomSide:o}=e;return Math.max(...(n==null?void 0:n.pins)??[],...(i==null?void 0:i.pins)??[],...(a==null?void 0:a.pins)??[],...(o==null?void 0:o.pins)??[])}_getPinCount(){return this._getSchematicPortArrangement()?this._getPinCountFromSchematicPortArrangement():this.getPortsFromFootprint().length}_getSchematicPortArrangement(){return this._parsedProps.schPinArrangement??this._parsedProps.schPortArrangement}_getSchematicBoxDimensions(){if(this.getSchematicSymbol()||!this.config.shouldRenderAsSchematicBox)return null;const{_parsedProps:e}=this,t=this._getPinCount(),n=e.schPinSpacing??.2;return upn({schWidth:e.schWidth,schHeight:e.schHeight,schPinSpacing:n,numericSchPinStyle:ppn(e.schPinStyle,e.pinLabels),pinCount:t,schPortArrangement:this._getSchematicPortArrangement(),pinLabels:e.pinLabels})}doInitialCadModelRender(){var c;const{db:e}=this.root,{boardThickness:t=0}=((c=this.root)==null?void 0:c._getBoard())??{},n=this._parsedProps.cadModel;if(!this.pcb_component_id||!n&&!this.props.footprint)return;const i=this._getPcbCircuitJsonBounds(),a=e.pcb_component.get(this.pcb_component_id);if(typeof n=="string")throw new Error("String cadModel not yet implemented");const o=Lpn.parse({x:0,y:0,z:typeof(n==null?void 0:n.rotationOffset)=="number"?n.rotationOffset:0,...typeof(n==null?void 0:n.rotationOffset)=="object"?n.rotationOffset??{}:{}}),s=Lw.parse({x:0,y:0,z:0,...typeof(n==null?void 0:n.positionOffset)=="object"?n.positionOffset:{}}),l=this.props.layer==="bottom"?"bottom":"top";e.cad_component.insert({position:{x:i.center.x+s.x,y:i.center.y+s.y,z:(l==="bottom"?-t/2:t/2)+s.z},rotation:{x:o.x,y:(l==="top"?0:180)+o.y,z:((a==null?void 0:a.rotation)??0)+(l==="bottom"?180:0)+o.z},pcb_component_id:this.pcb_component_id,source_component_id:this.source_component_id,model_stl_url:"stlUrl"in(n??{})?this._addCachebustToModelUrl(n.stlUrl):void 0,model_obj_url:"objUrl"in(n??{})?this._addCachebustToModelUrl(n.objUrl):void 0,model_jscad:"jscad"in(n??{})?n.jscad:void 0,footprinter_string:typeof this.props.footprint=="string"&&!n?this.props.footprint:void 0})}_addCachebustToModelUrl(e){var n;if(!e||!e.includes("modelcdn.tscircuit.com"))return e;const t=((n=this.root)==null?void 0:n.getClientOrigin())??"";return`${e}${e.includes("?")?"&":"?"}cachebust_origin=${encodeURIComponent(t)}`}doInitialPartsEngineRender(){const e=this.getInheritedProperty("partsEngine");if(!e)return;const{db:t}=this.root,n=t.source_component.get(this.source_component_id);if(!n||n.supplier_part_numbers)return;let i;this.props.footprint&&typeof this.props.footprint=="string"&&(i=this.props.footprint);const a=e.findPart({sourceComponent:n,footprinterString:i});if(!(a instanceof Promise)){t.source_component.update(this.source_component_id,{supplier_part_numbers:a});return}this._queueAsyncEffect("get-supplier-part-numbers",async()=>{this._asyncSupplierPartNumbers=await a,this._markDirty("PartsEngineRender")})}updatePartsEngineRender(){const{db:e}=this.root,t=e.source_component.get(this.source_component_id);if(t&&!t.supplier_part_numbers&&this._asyncSupplierPartNumbers){e.source_component.update(this.source_component_id,{supplier_part_numbers:this._asyncSupplierPartNumbers});return}}doInitialCreateTracesFromProps(){this._createTracesFromConnectionsProp()}_createTracesFromConnectionsProp(){const{_parsedProps:e}=this;if(e.connections)for(const[t,n]of Object.entries(e.connections)){const i=Array.isArray(n)?n:[n];for(const a of i)this.add(new cw({from:`${this.getSubcircuitSelector()} > port.${t}`,to:a}))}}},Opn=class{constructor(r,e={}){Qe(this,"input");Qe(this,"isRouting",!1);Qe(this,"solver");Qe(this,"eventHandlers",{complete:[],error:[],progress:[]});Qe(this,"cycleCount",0);Qe(this,"stepDelay");Qe(this,"timeoutId");this.input=r;const{capacityDepth:t,targetMinCapacity:n,stepDelay:i=0}=e;this.solver=new Rq(r,{capacityDepth:t,targetMinCapacity:n}),this.stepDelay=i}start(){this.isRouting||(this.isRouting=!0,this.cycleCount=0,this.runCycleAndQueueNextCycle())}runCycleAndQueueNextCycle(){var r;if(this.isRouting)try{if(this.solver.solved||this.solver.failed){this.solver.failed?this.emitEvent({type:"error",error:new Error(this.solver.error||"Routing failed")}):this.emitEvent({type:"complete",traces:this.solver.getOutputSimpleRouteJson().traces||[]}),this.isRouting=!1;return}const e=Date.now(),t=this.solver.iterations;for(;Date.now()-e<250&&!this.solver.failed&&!this.solver.solved;)this.solver.step();const n=(this.solver.iterations-t)/(Date.now()-e)*1e3;this.cycleCount++;const i=((r=this.solver)==null?void 0:r.preview())||void 0,a=this.solver.progress;this.emitEvent({type:"progress",steps:this.cycleCount,iterationsPerSecond:n,progress:a,phase:this.solver.getCurrentPhase(),debugGraphics:i}),this.stepDelay>0?this.timeoutId=setTimeout(()=>this.runCycleAndQueueNextCycle(),this.stepDelay):this.timeoutId=setTimeout(()=>this.runCycleAndQueueNextCycle(),0)}catch(e){this.emitEvent({type:"error",error:e instanceof Error?e:new Error(String(e))}),this.isRouting=!1}}stop(){this.isRouting&&(this.isRouting=!1,this.timeoutId!==void 0&&(clearTimeout(this.timeoutId),this.timeoutId=void 0))}on(r,e){r==="complete"?this.eventHandlers.complete.push(e):r==="error"?this.eventHandlers.error.push(e):r==="progress"&&this.eventHandlers.progress.push(e)}emitEvent(r){if(r.type==="complete")for(const e of this.eventHandlers.complete)e(r);else if(r.type==="error")for(const e of this.eventHandlers.error)e(r);else if(r.type==="progress")for(const e of this.eventHandlers.progress)e(r)}solveSync(){if(this.solver.solve(),this.solver.failed)throw new Error(this.solver.error||"Routing failed");return this.solver.getOutputSimpleRouteJson().traces||[]}},TXe=class extends Jg{constructor(){super(...arguments);Qe(this,"matchedPort",null)}get config(){return{componentName:"TraceHint",zodProps:zdn}}doInitialPortMatching(){const{db:e}=this.root,{_parsedProps:t,parent:n}=this;if(!n)return;if(n.componentName==="Trace"){this.renderError(`Port inference inside trace is not yet supported (${this})`);return}if(!n)throw new Error("TraceHint has no parent");if(!t.for){this.renderError(`TraceHint has no for property (${this})`);return}const i=n.selectOne(t.for,{type:"port"});i||this.renderError(`${this} could not find port for selector "${t.for}"`),this.matchedPort=i,i.registerMatch(this)}getPcbRouteHints(){const{_parsedProps:e}=this,t=e.offset?[e.offset]:e.offsets;if(!t)return[];const n=this._computePcbGlobalTransformBeforeLayout();return t.map(i=>({...Pr(n,i),via:i.via,to_layer:i.to_layer,trace_width:i.trace_width}))}doInitialPcbTraceHintRender(){var n,i,a;if((n=this.root)!=null&&n.pcbDisabled)return;const{db:e}=this.root,{_parsedProps:t}=this;e.pcb_trace_hint.insert({pcb_component_id:(i=this.matchedPort)==null?void 0:i.pcb_component_id,pcb_port_id:(a=this.matchedPort)==null?void 0:a.pcb_port_id,route:this.getPcbRouteHints()})}},zpn=(r,e)=>{const t=r.source_group.list(),n=[],i=a=>{const o=t.filter(s=>s.parent_subcircuit_id===a);for(const s of o)s.subcircuit_id&&(n.push(s.subcircuit_id),i(s.subcircuit_id))};return i(e),n},MXe=({db:r,circuitJson:e,subcircuit_id:t,minTraceWidth:n=.1})=>{if(!r&&e&&(r=C8(e)),!r)throw new Error("db or circuitJson is required");const i=r.pcb_trace_hint.list(),a=t?new Set([t]):null;if(t){const S=zpn(r,t);for(const w of S)a.add(w)}const o=(e??r.toArray()).filter(S=>!t||"subcircuit_id"in S&&a.has(S.subcircuit_id)),s=r.pcb_board.list()[0];r=C8(o);const l=M8(o),c=$w([...r.pcb_component.list(),...r.pcb_smtpad.list(),...r.pcb_plated_hole.list(),...r.pcb_hole.list(),...r.pcb_via.list()].filter(S=>!t||(a==null?void 0:a.has(S.subcircuit_id))),l);for(const S of c){const w=S.connectedTo.flatMap(b=>l.getIdsConnectedToNet(b));S.connectedTo.push(...w)}const u=c.flatMap(S=>[{x:S.center.x-S.width/2,y:S.center.y-S.height/2},{x:S.center.x+S.width/2,y:S.center.y+S.height/2}]);let f;s?f={minX:s.center.x-s.width/2,maxX:s.center.x+s.width/2,minY:s.center.y-s.height/2,maxY:s.center.y+s.height/2}:f={minX:Math.min(...u.map(S=>S.x))-1,maxX:Math.max(...u.map(S=>S.x))+1,minY:Math.min(...u.map(S=>S.y))-1,maxY:Math.max(...u.map(S=>S.y))+1};const p=r.source_trace.list().map(S=>{var Z,W,te;const w=S.connected_source_port_ids.map(J=>{const fe=r.source_port.get(J),he=r.pcb_port.getWhere({source_port_id:J});return{...fe,...he}});if(w.length<2)return null;const[b,C]=w,z=((Z=b.layers)==null?void 0:Z[0])??"top",I=((W=C.layers)==null?void 0:W[0])??"top",G=i.filter(J=>J.pcb_port_id===b.pcb_port_id||J.pcb_port_id===C.pcb_port_id),Y=[];for(const J of G){const fe=r.pcb_port.get(J.pcb_port_id),he=((te=fe==null?void 0:fe.layers)==null?void 0:te[0])??"top";for(const ve of J.route)Y.push({x:ve.x,y:ve.y,layer:he})}return{name:S.source_trace_id??l.getNetConnectedToId(S.source_trace_id)??"",source_trace_id:S.source_trace_id,pointsToConnect:[{x:b.x,y:b.y,layer:z},...Y,{x:C.x,y:C.y,layer:I}]}}).filter(S=>S!==null),v=r.source_net.list().filter(S=>!t||(a==null?void 0:a.has(S.subcircuit_id))),x=[];for(const S of v){const w=r.source_trace.list().filter(b=>{var C;return(C=b.connected_source_net_ids)==null?void 0:C.includes(S.source_net_id)});x.push({name:S.source_net_id??l.getNetConnectedToId(S.source_net_id),pointsToConnect:w.flatMap(b=>r.pcb_port.list().filter(z=>b.connected_source_port_ids.includes(z.source_port_id)).map(z=>{var I;return{x:z.x,y:z.y,layer:((I=z.layers)==null?void 0:I[0])??"top",pcb_port_id:z.pcb_port_id}}))})}return{simpleRouteJson:{bounds:f,obstacles:c,connections:[...p,...x],layerCount:2,minTraceWidth:n},connMap:l}},Wfe=class extends r2{constructor(){super(...arguments);Qe(this,"pcb_group_id",null);Qe(this,"subcircuit_id",null);Qe(this,"_hasStartedAsyncAutorouting",!1);Qe(this,"_asyncAutoroutingResult",null)}get config(){return{zodProps:Dfn,componentName:"Group"}}doInitialSourceRender(){const{db:e}=this.root,t=e.source_group.insert({name:this._parsedProps.name,is_subcircuit:this.isSubcircuit});this.subcircuit_id=`subcircuit_${t.source_group_id}`,this.source_group_id=t.source_group_id,e.source_group.update(t.source_group_id,{subcircuit_id:this.subcircuit_id})}doInitialSourceParentAttachment(){var n,i,a;const{db:e}=this.root;if(!this.isSubcircuit)return;const t=(a=(i=(n=this.parent)==null?void 0:n.getSubcircuit)==null?void 0:i.call(n))==null?void 0:a.subcircuit_id;t&&e.source_group.update(this.source_group_id,{parent_subcircuit_id:t})}doInitialPcbComponentRender(){var i;if((i=this.root)!=null&&i.pcbDisabled)return;const{db:e}=this.root,{_parsedProps:t}=this,n=e.pcb_group.insert({is_subcircuit:this.isSubcircuit,subcircuit_id:this.subcircuit_id,name:this._parsedProps.name,center:this._getGlobalPcbPositionBeforeLayout(),width:0,height:0,pcb_component_ids:[],source_group_id:this.source_group_id});this.pcb_group_id=n.pcb_group_id}doInitialCreateTraceHintsFromProps(){var a;const{_parsedProps:e}=this,{db:t}=this.root,n=e;if(!this.isSubcircuit)return;const i=(a=n.layout)==null?void 0:a.manual_trace_hints;if(i)for(const o of i)this.add(new TXe({for:o.pcb_port_selector,offsets:o.offsets}))}doInitialSourceAddConnectivityMapKey(){if(!this.isSubcircuit)return;const{db:e}=this.root,t=this.selectAll("trace"),n=new IM({});n.addConnections(t.map(i=>{const a=e.source_trace.get(i.source_trace_id);return a?[a.source_trace_id,...a.connected_source_port_ids,...a.connected_source_net_ids]:null}).filter(i=>i!==null));for(const i of t){if(!i.source_trace_id)continue;const a=n.getNetConnectedToId(i.source_trace_id);if(!a)continue;const{name:o}=this._parsedProps;i.subcircuit_connectivity_map_key=`${o??`unnamedsubcircuit${this._renderId}`}_${a}`,e.source_trace.update(i.source_trace_id,{subcircuit_connectivity_map_key:i.subcircuit_connectivity_map_key})}}_areChildSubcircuitsRouted(){const e=this.selectAll("group").filter(t=>t.isSubcircuit);for(const t of e)if(t._shouldRouteAsync()&&!t._asyncAutoroutingResult)return!1;return!0}_shouldRouteAsync(){const e=this._getAutorouterConfig();return e.groupMode==="sequential-trace"?!1:!!(e.local&&e.groupMode==="subcircuit"||!e.local)}_hasTracesToRoute(){const e=P9("tscircuit:core:_hasTracesToRoute"),t=this.selectAll("trace");return e(`[${this.getString()}] has ${t.length} traces to route`),t.length>0}async _runEffectMakeHttpAutoroutingRequest(){var c,u,f,p;const{db:e}=this.root,t=P9("tscircuit:core:_runEffectMakeHttpAutoroutingRequest");this._parsedProps;const n=this._getAutorouterConfig(),i=n.serverUrl,a=n.serverMode,o=(v,x)=>{var S;return t("fetching",v),x.headers&&(x.headers["Tscircuit-Core-Version"]=(S=this.root)==null?void 0:S.getCoreVersion()),fetch(v,x)},s=this.root.db.toArray().filter(v=>v.type.startsWith("source_")||v.type.startsWith("pcb_"));if(a==="solve-endpoint"){if(((c=this.props.autorouter)==null?void 0:c.inputFormat)==="simplified"){const{autorouting_result:x}=await o(`${i}/autorouting/solve`,{method:"POST",body:JSON.stringify({input_simple_route_json:MXe({db:e,minTraceWidth:((u=this.props.autorouter)==null?void 0:u.minTraceWidth)??.15,subcircuit_id:this.subcircuit_id}).simpleRouteJson,subcircuit_id:this.subcircuit_id}),headers:{"Content-Type":"application/json"}}).then(S=>S.json());this._asyncAutoroutingResult=x,this._markDirty("PcbTraceRender");return}const{autorouting_result:v}=await o(`${i}/autorouting/solve`,{method:"POST",body:JSON.stringify({input_circuit_json:s,subcircuit_id:this.subcircuit_id}),headers:{"Content-Type":"application/json"}}).then(x=>x.json());this._asyncAutoroutingResult=v,this._markDirty("PcbTraceRender");return}const{autorouting_job:l}=await o(`${i}/autorouting/jobs/create`,{method:"POST",body:JSON.stringify({input_circuit_json:s,provider:"freerouting",autostart:!0,display_name:(f=this.root)==null?void 0:f.name,subcircuit_id:this.subcircuit_id,server_cache_enabled:n.serverCacheEnabled}),headers:{"Content-Type":"application/json"}}).then(v=>v.json());for(;;){const{autorouting_job:v}=await o(`${i}/autorouting/jobs/get`,{method:"POST",body:JSON.stringify({autorouting_job_id:l.autorouting_job_id}),headers:{"Content-Type":"application/json"}}).then(x=>x.json());if(v.is_finished){const{autorouting_job_output:x}=await o(`${i}/autorouting/jobs/get_output`,{method:"POST",body:JSON.stringify({autorouting_job_id:l.autorouting_job_id}),headers:{"Content-Type":"application/json"}}).then(S=>S.json());this._asyncAutoroutingResult={output_pcb_traces:x.output_pcb_traces},this._markDirty("PcbTraceRender");break}if(v.has_error)throw e.pcb_autorouting_error.insert({pcb_error_id:l.autorouting_job_id,message:((p=v.error)==null?void 0:p.message)??JSON.stringify(v.error)}),new Error(`Autorouting job failed: ${JSON.stringify(v.error)}`);await new Promise(x=>setTimeout(x,100))}}async _runLocalAutorouting(){var s,l,c,u,f;const{db:e}=this.root;this._parsedProps;const t=P9("tscircuit:core:_runLocalAutorouting");t(`[${this.getString()}] starting local autorouting`);const n=this._getAutorouterConfig(),{simpleRouteJson:i}=MXe({db:e,minTraceWidth:((s=this.props.autorouter)==null?void 0:s.minTraceWidth)??.15,subcircuit_id:this.subcircuit_id});(l=this.root)==null||l.emit("autorouting:start",{subcircuit_id:this.subcircuit_id,componentDisplayName:this.getString(),simpleRouteJson:i});let a;n.algorithmFn?a=await n.algorithmFn(i):a=new Opn(i,{capacityDepth:(c=this.props.autorouter)==null?void 0:c.capacityDepth,targetMinCapacity:(u=this.props.autorouter)==null?void 0:u.targetMinCapacity});const o=new Promise((p,v)=>{a.on("complete",x=>{t(`[${this.getString()}] local autorouting complete`),p(x.traces)}),a.on("error",x=>{t(`[${this.getString()}] local autorouting error: ${x.error.message}`),v(x.error)})});a.on("progress",p=>{var v;(v=this.root)==null||v.emit("autorouting:progress",{subcircuit_id:this.subcircuit_id,componentDisplayName:this.getString(),...p})}),a.start();try{const p=await o;this._asyncAutoroutingResult={output_pcb_traces:p},this._markDirty("PcbTraceRender")}catch(p){const{db:v}=this.root;throw v.pcb_autorouting_error.insert({pcb_error_id:`pcb_autorouter_error_subcircuit_${this.subcircuit_id}`,message:p instanceof Error?p.message:String(p)}),(f=this.root)==null||f.emit("autorouting:error",{subcircuit_id:this.subcircuit_id,componentDisplayName:this.getString(),error:{message:p instanceof Error?p.message:String(p)},simpleRouteJson:i}),p}finally{a.stop()}}_startAsyncAutorouting(){this._hasStartedAsyncAutorouting||(this._hasStartedAsyncAutorouting=!0,this._getAutorouterConfig().local?this._queueAsyncEffect("capacity-mesh-autorouting",async()=>this._runLocalAutorouting()):this._queueAsyncEffect("make-http-autorouting-request",async()=>this._runEffectMakeHttpAutoroutingRequest()))}doInitialPcbTraceRender(){var t;const e=P9("tscircuit:core:doInitialPcbTraceRender");if(this.isSubcircuit&&!((t=this.root)!=null&&t.pcbDisabled)&&!this.getInheritedProperty("routingDisabled")&&!this._shouldUseTraceByTraceRouting()){if(!this._areChildSubcircuitsRouted()){e(`[${this.getString()}] child subcircuits are not routed, skipping async autorouting until subcircuits routed`);return}e(`[${this.getString()}] no child subcircuits to wait for, initiating async routing`),this._hasTracesToRoute()&&this._startAsyncAutorouting()}}updatePcbTraceRender(){var n;const e=P9("tscircuit:core:updatePcbTraceRender");if(e(`[${this.getString()}] updating...`),!this.isSubcircuit)return;if(this._shouldRouteAsync()&&this._hasTracesToRoute()&&!this._hasStartedAsyncAutorouting){this._areChildSubcircuitsRouted()&&(e(`[${this.getString()}] child subcircuits are now routed, starting async autorouting`),this._startAsyncAutorouting());return}if(!this._asyncAutoroutingResult||this._shouldUseTraceByTraceRouting())return;const{db:t}=this.root;if(this._asyncAutoroutingResult.output_simple_route_json){e(`[${this.getString()}] updating PCB traces from simple route json (${(n=this._asyncAutoroutingResult.output_simple_route_json.traces)==null?void 0:n.length} traces)`),this._updatePcbTraceRenderFromSimpleRouteJson();return}if(this._asyncAutoroutingResult.output_pcb_traces){e(`[${this.getString()}] updating PCB traces from ${this._asyncAutoroutingResult.output_pcb_traces.length} traces`),this._updatePcbTraceRenderFromPcbTraces();return}}_updatePcbTraceRenderFromSimpleRouteJson(){const{db:e}=this.root,{traces:t}=this._asyncAutoroutingResult.output_simple_route_json;if(t)for(const n of t)e.pcb_trace.insert({subcircuit_id:this.subcircuit_id,route:n.route})}_updatePcbTraceRenderFromPcbTraces(){const{output_pcb_traces:e}=this._asyncAutoroutingResult;if(!e)return;const{db:t}=this.root;for(const n of e)if(n.type==="pcb_trace"){if(n.subcircuit_id=this.subcircuit_id,n.connection_name){const i=n.connection_name;n.source_trace_id=i}t.pcb_trace.insert(n)}for(const n of e)if(n.type!=="pcb_via"&&n.type==="pcb_trace")for(const i of n.route)i.route_type==="via"&&t.pcb_via.insert({pcb_trace_id:n.pcb_trace_id,x:i.x,y:i.y,hole_diameter:.3,outer_diameter:.6,layers:[i.from_layer,i.to_layer],from_layer:i.from_layer,to_layer:i.to_layer})}doInitialSchematicLayout(){if(!this.isSubcircuit||!this._parsedProps.schAutoLayoutEnabled)return;const{db:t}=this.root,n=this.getDescendants(),i=[];for(const s of n)if("schematic_component_id"in s){const l=t.schematic_component.get(s.schematic_component_id);if(l){const c=t.schematic_port.list().filter(u=>u.schematic_component_id===l.schematic_component_id);i.push(...c)}}const a=mq(t.toArray()),o=vq(a);hq(t.toArray(),o)}_getAutorouterConfig(){const e={serverUrl:"https://registry-api.tscircuit.com",serverMode:"job",serverCacheEnabled:!0},t=this._parsedProps.autorouter??this.getInheritedProperty("autorouter");return typeof t=="object"?{local:!(t.serverUrl||t.serverMode||t.serverCacheEnabled),...e,...t}:t==="auto-local"?{local:!0,groupMode:"subcircuit"}:t==="sequential-trace"?{local:!0,groupMode:"sequential-trace"}:t==="subcircuit"?{local:!0,groupMode:"subcircuit"}:t==="auto-cloud"?{local:!1,groupMode:"subcircuit",serverUrl:e.serverUrl,serverMode:e.serverMode,serverCacheEnabled:!0}:{local:!0,groupMode:"subcircuit"}}_shouldUseTraceByTraceRouting(){return this._getAutorouterConfig().groupMode==="sequential-trace"}doInitialPcbDesignRuleChecks(){var t;if((t=this.root)!=null&&t.pcbDisabled||this.getInheritedProperty("routingDisabled"))return;const{db:e}=this.root;if(this.isSubcircuit){const n=new Map;for(const i of this.children)if(!i.isSubcircuit&&i._parsedProps.name){const a=n.get(i._parsedProps.name)||[];a.push(i),n.set(i._parsedProps.name,a)}for(const[i,a]of n.entries())a.length>1&&e.pcb_trace_error.insert({error_type:"pcb_trace_error",message:`Multiple components found with name "${i}" in subcircuit "${this._parsedProps.name||"unnamed"}". Component names must be unique within a subcircuit.`,source_trace_id:"",pcb_trace_id:"",pcb_component_ids:a.map(o=>o.pcb_component_id).filter(Boolean),pcb_port_ids:[]})}}},Upn=class extends Wfe{constructor(){super(...arguments);Qe(this,"pcb_board_id",null);Qe(this,"_drcChecksComplete",!1);Qe(this,"_connectedSchematicPortPairs",new Set)}get isSubcircuit(){return!0}get config(){return{componentName:"Board",zodProps:eXe}}get boardThickness(){const{_parsedProps:e}=this;return 1.4}get allLayers(){return["top","bottom","inner1","inner2"]}doInitialPcbBoardAutoSize(){var v;if((v=this.root)!=null&&v.pcbDisabled||!this.pcb_board_id)return;const{db:e}=this.root,{_parsedProps:t}=this;if(t.width&&t.height)return;let n=1/0,i=1/0,a=-1/0,o=-1/0;const s=e.pcb_component.list();let l=!1;for(const x of s){const{width:S,height:w,center:b}=x;S===0||w===0||(l=!0,n=Math.min(n,b.x-S/2),i=Math.min(i,b.y-w/2),a=Math.max(a,b.x+S/2),o=Math.max(o,b.y+w/2))}const c=2,u=l?a-n+c*2:0,f=l?o-i+c*2:0,p={x:l?(n+a)/2+(t.outlineOffsetX??0):t.outlineOffsetX??0,y:l?(i+o)/2+(t.outlineOffsetY??0):t.outlineOffsetY??0};e.pcb_board.update(this.pcb_board_id,{width:u,height:f,center:p})}doInitialPcbComponentRender(){var o,s;if((o=this.root)!=null&&o.pcbDisabled)return;const{db:e}=this.root,{_parsedProps:t}=this;let n=t.width??0,i=t.height??0;if(t.outline){const l=t.outline.map(x=>x.x),c=t.outline.map(x=>x.y),u=Math.min(...l),f=Math.max(...l),p=Math.min(...c),v=Math.max(...c);n=f-u,i=v-p}const a=e.pcb_board.insert({center:{x:(t.pcbX??0)+(t.outlineOffsetX??0),y:(t.pcbY??0)+(t.outlineOffsetY??0)},thickness:this.boardThickness,num_layers:this.allLayers.length,width:n,height:i,outline:(s=t.outline)==null?void 0:s.map(l=>({x:l.x+(t.outlineOffsetX??0),y:l.y+(t.outlineOffsetY??0)})),material:t.material});this.pcb_board_id=a.pcb_board_id}removePcbComponentRender(){const{db:e}=this.root;this.pcb_board_id&&(e.pcb_board.delete(this.pcb_board_id),this.pcb_board_id=null)}_computePcbGlobalTransformBeforeLayout(){return e1()}doInitialPcbDesignRuleChecks(){var e;(e=this.root)!=null&&e.pcbDisabled||this.getInheritedProperty("routingDisabled")||super.doInitialPcbDesignRuleChecks()}updatePcbDesignRuleChecks(){var n;if((n=this.root)!=null&&n.pcbDisabled||this.getInheritedProperty("routingDisabled"))return;const{db:e}=this.root;if(!this._areChildSubcircuitsRouted()||this._drcChecksComplete)return;this._drcChecksComplete=!0;const t=Vdn(e.toArray());for(const i of t)e.pcb_trace_error.insert(i)}_emitRenderLifecycleEvent(e,t){var n;super._emitRenderLifecycleEvent(e,t),t==="start"&&((n=this.root)==null||n.emit("board:renderPhaseStarted",{renderId:this._renderId,phase:e}))}},Ipn=new Proxy({},{get:(r,e)=>e}),gP=Ipn,kpn=class extends r2{get config(){return{componentName:"Capacitor",schematicSymbolName:this.props.polarized?"capacitor_polarized":this.props.symbolName??"capacitor",zodProps:Gfn,sourceFtype:gP.simple_capacitor}}initPorts(){super.initPorts({additionalAliases:{pin1:["anode","pos","left"],pin2:["cathode","neg","right"]}})}_getSchematicSymbolDisplayValue(){const r=`${Sb(this._parsedProps.capacitance)}F`;return this._parsedProps.schShowRatings&&this._parsedProps.maxVoltageRating?`${r}/${Sb(this._parsedProps.maxVoltageRating)}V`:r}doInitialCreateNetsFromProps(){this._createNetsFromProps([this.props.decouplingFor,this.props.decouplingTo,...this._getNetsFromConnectionsProp()])}doInitialCreateTracesFromProps(){this.props.decouplingFor&&this.props.decouplingTo&&(this.add(new cw({from:`${this.getSubcircuitSelector()} > port.1`,to:this.props.decouplingFor})),this.add(new cw({from:`${this.getSubcircuitSelector()} > port.2`,to:this.props.decouplingTo}))),this._createTracesFromConnectionsProp()}doInitialSourceRender(){const{db:r}=this.root,{_parsedProps:e}=this,t=r.source_component.insert({ftype:"simple_capacitor",name:e.name,manufacturer_part_number:e.manufacturerPartNumber??e.mfn,supplier_part_numbers:e.supplierPartNumbers,capacitance:e.capacitance,max_voltage_rating:e.maxVoltageRating,max_decoupling_trace_length:e.maxDecouplingTraceLength,display_capacitance:this._getSchematicSymbolDisplayValue(),are_pins_interchangeable:!e.polarized});this.source_component_id=t.source_component_id}},CXe=class extends r2{constructor(){super(...arguments);Qe(this,"schematicBoxDimensions",null)}get config(){return{componentName:"Chip",zodProps:tXe,shouldRenderAsSchematicBox:!0}}doInitialSchematicComponentRender(){const{_parsedProps:e}=this;(e==null?void 0:e.noSchematicRepresentation)!==!0&&super.doInitialSchematicComponentRender()}doInitialSourceRender(){const{db:e}=this.root,{_parsedProps:t}=this,n=e.source_component.insert({ftype:"simple_chip",name:t.name,manufacturer_part_number:t.manufacturerPartNumber,supplier_part_numbers:t.supplierPartNumbers});this.source_component_id=n.source_component_id}doInitialPcbComponentRender(){var i;if((i=this.root)!=null&&i.pcbDisabled)return;const{db:e}=this.root,{_parsedProps:t}=this,n=e.pcb_component.insert({center:{x:t.pcbX??0,y:t.pcbY??0},width:2,height:3,layer:t.layer??"top",rotation:t.pcbRotation??0,source_component_id:this.source_component_id,subcircuit_id:this.getSubcircuit().subcircuit_id??void 0});this.pcb_component_id=n.pcb_component_id}doInitialCreateTracesFromProps(){const{_parsedProps:e}=this;if(e.externallyConnectedPins)for(const[t,n]of e.externallyConnectedPins)this.add(new cw({from:`${this.getSubcircuitSelector()} > port.${t}`,to:`${this.getSubcircuitSelector()} > port.${n}`}));this._createTracesFromConnectionsProp()}},Fpn=class extends r2{constructor(){super(...arguments);Qe(this,"pos",this.portMap.pin1);Qe(this,"anode",this.portMap.pin1);Qe(this,"neg",this.portMap.pin2);Qe(this,"cathode",this.portMap.pin2)}get config(){return{schematicSymbolName:this.props.symbolName??"diode",componentName:"Diode",zodProps:_dn,sourceFtype:"simple_diode"}}initPorts(){super.initPorts({additionalAliases:{pin1:["anode","pos","left"],pin2:["cathode","neg","right"]}})}doInitialSourceRender(){const{db:e}=this.root,{_parsedProps:t}=this,n=e.source_component.insert({ftype:"simple_diode",name:t.name,manufacturer_part_number:t.manufacturerPartNumber??t.mfn,supplier_part_numbers:t.supplierPartNumbers,are_pins_interchangeable:!1});this.source_component_id=n.source_component_id}},Bpn=class extends r2{constructor(){super(...arguments);Qe(this,"schematicDimensions",null)}get config(){let e="";if(this.props.pinCount&&(e+=`solderjumper${this.props.pinCount||2}`),Array.isArray(this.props.internallyConnectedPins)&&this.props.internallyConnectedPins.length>0){const t=Array.from(new Set(this.props.internallyConnectedPins.flat())).sort().join("");e+=`_bridged${t}`}return{schematicSymbolName:e,componentName:"Jumper",zodProps:Ufn,shouldRenderAsSchematicBox:!0}}doInitialSourceRender(){const{db:e}=this.root,{_parsedProps:t}=this,n=e.source_component.insert({ftype:"simple_chip",name:t.name,manufacturer_part_number:t.manufacturerPartNumber,supplier_part_numbers:t.supplierPartNumbers,are_pins_interchangeable:!0});this.source_component_id=n.source_component_id}doInitialPcbComponentRender(){var i;if((i=this.root)!=null&&i.pcbDisabled)return;const{db:e}=this.root,{_parsedProps:t}=this,n=e.pcb_component.insert({center:{x:t.pcbX??0,y:t.pcbY??0},width:2,height:3,layer:t.layer??"top",rotation:t.pcbRotation??0,source_component_id:this.source_component_id,subcircuit_id:this.getSubcircuit().subcircuit_id??void 0});this.pcb_component_id=n.pcb_component_id}doInitialPcbTraceRender(){const{db:e}=this.root,t=e.pcb_port.list({pcb_component_id:this.pcb_component_id}),n={};for(const o of t){const s=o.source_port_id&&o.source_port_id.match(/(\d+)$/);if(s){const l=(parseInt(s[1],10)+1).toString();n[l]=o.pcb_port_id}}const i=e.pcb_trace.list(),a=o=>{if(o&&typeof o=="string"&&o.startsWith("{PIN")){const s=o.replace("{PIN","").replace("}","");return n[s]||o}return o};for(const o of i)if(o.route)for(const s of o.route)s.route_type==="wire"&&(s.start_pcb_port_id=a(s.start_pcb_port_id),s.end_pcb_port_id=a(s.end_pcb_port_id))}},jpn=class extends r2{constructor(){super(...arguments);Qe(this,"pos",this.portMap.pin1);Qe(this,"anode",this.portMap.pin1);Qe(this,"neg",this.portMap.pin2);Qe(this,"cathode",this.portMap.pin2)}get config(){return{componentName:"Led",schematicSymbolName:this.props.symbolName??"led",zodProps:xdn,sourceFtype:"simple_diode"}}initPorts(){super.initPorts({additionalAliases:{pin1:["anode","pos","left"],pin2:["cathode","neg","right"]}})}doInitialSourceRender(){const{db:e}=this.root,{_parsedProps:t}=this,n=e.source_component.insert({ftype:"simple_diode",name:t.name,manufacturer_part_number:t.manufacturerPartNumber??t.mfn,supplier_part_numbers:t.supplierPartNumbers,are_pins_interchangeable:!1});this.source_component_id=n.source_component_id}},Hpn=class extends r2{constructor(){super(...arguments);Qe(this,"pos",this.portMap.pin1);Qe(this,"positive",this.portMap.pin1);Qe(this,"neg",this.portMap.pin2);Qe(this,"negative",this.portMap.pin2)}get config(){return{schematicSymbolName:this.props.symbolName??"power_factor_meter_horz",componentName:"PowerSource",zodProps:Mdn,sourceFtype:"simple_power_source"}}initPorts(){this.add(new dS({name:"pin1",pinNumber:1,aliases:["positive","pos"]})),this.add(new dS({name:"pin2",pinNumber:2,aliases:["negative","neg"]}))}doInitialSourceRender(){const{db:e}=this.root,{_parsedProps:t}=this,n=e.source_component.insert({ftype:"simple_power_source",name:t.name,voltage:t.voltage,supplier_part_numbers:t.supplierPartNumbers,are_pins_interchangeable:!1});this.source_component_id=n.source_component_id}},Vpn=class extends r2{get config(){return{componentName:"Resistor",schematicSymbolName:this.props.symbolName??"boxresistor",zodProps:Bfn,sourceFtype:"simple_resistor"}}initPorts(){super.initPorts({additionalAliases:{pin1:["anode","pos","left"],pin2:["cathode","neg","right"]}})}_getSchematicSymbolDisplayValue(){return`${Sb(this._parsedProps.resistance)}Ω`}doInitialCreateNetsFromProps(){this._createNetsFromProps([this.props.pullupFor,this.props.pullupTo,...this._getNetsFromConnectionsProp()])}doInitialCreateTracesFromProps(){this.props.pullupFor&&this.props.pullupTo&&(this.add(new cw({from:`${this.getSubcircuitSelector()} > port.1`,to:this.props.pullupFor})),this.add(new cw({from:`${this.getSubcircuitSelector()} > port.2`,to:this.props.pullupTo}))),this._createTracesFromConnectionsProp()}doInitialSourceRender(){const{db:r}=this.root,{_parsedProps:e}=this,t=r.source_component.insert({ftype:"simple_resistor",name:e.name,manufacturer_part_number:e.manufacturerPartNumber??e.mfn,supplier_part_numbers:e.supplierPartNumbers,resistance:e.resistance,display_resistance:this._getSchematicSymbolDisplayValue(),are_pins_interchangeable:!0});this.source_component_id=t.source_component_id}},$pn=["leftedge","rightedge","topedge","bottomedge","center"],Gpn=class extends Jg{get config(){return{componentName:"Constraint",zodProps:Zfn}}constructor(r){if(super(r),("xdist"in r||"ydist"in r)&&!("edgeToEdge"in r)&&!("centerToCenter"in r))throw new Error(`edgeToEdge, centerToCenter must be set for xDist or yDist for ${this}`);if("for"in r&&r.for.length<2)throw new Error(`"for" must have at least two selectors for ${this}`)}_getAllReferencedComponents(){const r=[],e=this.getPrimitiveContainer();function t(n){const i=n.split(" ").pop(),a=$pn.includes(i)?i:void 0,o=a?n.replace(` ${a}`,""):n,s=e.selectOne(o,{pcbPrimitive:!0});s&&r.push({selector:n,component:s,componentSelector:o,edge:a})}for(const n of["left","right","top","bottom"])n in this._parsedProps&&t(this._parsedProps[n]);if("for"in this._parsedProps)for(const n of this._parsedProps.for)t(n);return{componentsWithSelectors:r}}},qpn=class extends Jg{constructor(){super(...arguments);Qe(this,"fabrication_note_path_id",null)}get config(){return{componentName:"FabricationNotePath",zodProps:wdn}}doInitialPcbPrimitiveRender(){var s,l;if((s=this.root)!=null&&s.pcbDisabled)return;const{db:e}=this.root,t=this.getSubcircuit(),{_parsedProps:n}=this,i=n.layer??"top";if(i!=="top"&&i!=="bottom")throw new Error(`Invalid layer "${i}" for SilkscreenPath. Must be "top" or "bottom".`);const a=this._computePcbGlobalTransformBeforeLayout(),o=e.pcb_fabrication_note_path.insert({pcb_component_id:(l=this.parent)==null?void 0:l.pcb_component_id,layer:i,color:n.color,route:n.route.map(c=>{const u=Pr(a,{x:c.x,y:c.y});return{...c,x:u.x,y:u.y}}),stroke_width:n.strokeWidth??.1,subcircuit_id:(t==null?void 0:t.subcircuit_id)??void 0});this.fabrication_note_path_id=o.pcb_fabrication_note_path_id}},Ypn=class extends Jg{get config(){return{componentName:"FabricationNoteText",zodProps:Sdn}}doInitialPcbPrimitiveRender(){var i,a;if((i=this.root)!=null&&i.pcbDisabled)return;const{db:r}=this.root,{_parsedProps:e}=this,t=this.getPrimitiveContainer(),n=this.getSubcircuit();r.pcb_fabrication_note_text.insert({anchor_alignment:e.anchorAlignment,anchor_position:{x:e.pcbX??0,y:e.pcbY??0},font:e.font??"tscircuit2024",font_size:e.fontSize??1,layer:"top",color:e.color,text:e.text??"",pcb_component_id:t.pcb_component_id,subcircuit_id:(n==null?void 0:n.subcircuit_id)??void 0,pcb_group_id:((a=this.getGroup())==null?void 0:a.pcb_group_id)??void 0})}},Xpn=class extends Wfe{constructor(r){super({...r,subcircuit:!0})}},Wpn=class extends Jg{constructor(){super(...arguments);Qe(this,"source_net_alias_id")}get config(){return{componentName:"NetAlias",zodProps:udn}}doInitialSchematicComponentRender(){var a;if((a=this.root)!=null&&a.schematicDisabled)return;const{db:e}=this.root,{_parsedProps:t}=this,n={x:t.schX??0,y:t.schY??0},i=e.schematic_net_label.insert({text:t.net,source_net_id:t.net,anchor_position:n,center:n,anchor_side:"bottom"});this.source_net_alias_id=i.source_net_id}},Zpn=class extends Jg{constructor(){super(...arguments);Qe(this,"pcb_silkscreen_circle_id",null);Qe(this,"isPcbPrimitive",!0)}get config(){return{componentName:"SilkscreenCircle",zodProps:Odn}}doInitialPcbPrimitiveRender(){var s,l,c;if((s=this.root)!=null&&s.pcbDisabled)return;const{db:e}=this.root,{_parsedProps:t}=this,{maybeFlipLayer:n}=this._getPcbPrimitiveFlippedHelpers(),i=n(t.layer??"top");if(i!=="top"&&i!=="bottom")throw new Error(`Invalid layer "${i}" for SilkscreenCircle. Must be "top" or "bottom".`);this._computePcbGlobalTransformBeforeLayout();const a=this.getSubcircuit(),o=e.pcb_silkscreen_circle.insert({pcb_component_id:(l=this.parent)==null?void 0:l.pcb_component_id,layer:i,center:{x:t.pcbX??0,y:t.pcbY??0},radius:t.radius,subcircuit_id:(a==null?void 0:a.subcircuit_id)??void 0,pcb_group_id:((c=this.getGroup())==null?void 0:c.pcb_group_id)??void 0,stroke_width:t.strokeWidth??.1});this.pcb_silkscreen_circle_id=o.pcb_silkscreen_circle_id}getPcbSize(){const{_parsedProps:e}=this,t=e.radius*2;return{width:t,height:t}}},Qpn=class extends Jg{constructor(){super(...arguments);Qe(this,"pcb_silkscreen_rect_id",null);Qe(this,"isPcbPrimitive",!0)}get config(){return{componentName:"SilkscreenRect",zodProps:Ldn}}doInitialPcbPrimitiveRender(){var s,l,c;if((s=this.root)!=null&&s.pcbDisabled)return;const{db:e}=this.root,{_parsedProps:t}=this,{maybeFlipLayer:n}=this._getPcbPrimitiveFlippedHelpers(),i=n(t.layer??"top");if(i!=="top"&&i!=="bottom")throw new Error(`Invalid layer "${i}" for SilkscreenRect. Must be "top" or "bottom".`);const a=this.getSubcircuit(),o=e.pcb_silkscreen_rect.insert({pcb_component_id:(l=this.parent)==null?void 0:l.pcb_component_id,layer:i,center:{x:t.pcbX??0,y:t.pcbY??0},width:t.width,height:t.height,subcircuit_id:(a==null?void 0:a.subcircuit_id)??void 0,pcb_group_id:((c=this==null?void 0:this.getGroup())==null?void 0:c.pcb_group_id)??void 0,stroke_width:t.strokeWidth??.1});this.pcb_silkscreen_rect_id=o.pcb_silkscreen_rect_id}getPcbSize(){const{_parsedProps:e}=this;return{width:e.width,height:e.height}}},Kpn=class extends Jg{constructor(){super(...arguments);Qe(this,"pcb_silkscreen_line_id",null);Qe(this,"isPcbPrimitive",!0)}get config(){return{componentName:"SilkscreenLine",zodProps:Ddn}}doInitialPcbPrimitiveRender(){var s,l,c;if((s=this.root)!=null&&s.pcbDisabled)return;const{db:e}=this.root,{_parsedProps:t}=this,{maybeFlipLayer:n}=this._getPcbPrimitiveFlippedHelpers(),i=n(t.layer??"top");if(i!=="top"&&i!=="bottom")throw new Error(`Invalid layer "${i}" for SilkscreenLine. Must be "top" or "bottom".`);const a=this.getSubcircuit(),o=e.pcb_silkscreen_line.insert({pcb_component_id:(l=this.parent)==null?void 0:l.pcb_component_id,layer:i,x1:t.x1,y1:t.y1,x2:t.x2,y2:t.y2,stroke_width:t.strokeWidth??.1,subcircuit_id:(a==null?void 0:a.subcircuit_id)??void 0,pcb_group_id:((c=a==null?void 0:a.getGroup())==null?void 0:c.pcb_group_id)??void 0});this.pcb_silkscreen_line_id=o.pcb_silkscreen_line_id}getPcbSize(){const{_parsedProps:e}=this,t=Math.abs(e.x2-e.x1),n=Math.abs(e.y2-e.y1);return{width:t,height:n}}},Jpn=class extends Jg{constructor(){super(...arguments);Qe(this,"pcb_via_id",null);Qe(this,"matchedPort",null);Qe(this,"isPcbPrimitive",!0)}get config(){return{componentName:"Via",zodProps:Edn}}getAvailablePcbLayers(){return["top","inner1","inner2","bottom"]}getPcbSize(){const{_parsedProps:e}=this;return{width:e.outerDiameter,height:e.outerDiameter}}_getPcbCircuitJsonBounds(){const{db:e}=this.root,t=e.pcb_via.get(this.pcb_via_id),n=this.getPcbSize();return{center:{x:t.x,y:t.y},bounds:{left:t.x-n.width/2,top:t.y-n.height/2,right:t.x+n.width/2,bottom:t.y+n.height/2},width:n.width,height:n.height}}_setPositionFromLayout(e){const{db:t}=this.root;t.pcb_via.update(this.pcb_via_id,{x:e.x,y:e.y})}doInitialPcbPrimitiveRender(){var o,s;if((o=this.root)!=null&&o.pcbDisabled)return;const{db:e}=this.root,{_parsedProps:t}=this,n=this._getGlobalPcbPositionBeforeLayout(),i=this.getSubcircuit(),a=e.pcb_via.insert({x:n.x,y:n.y,hole_diameter:t.holeDiameter,outer_diameter:t.outerDiameter,layers:["bottom","top"],from_layer:t.fromLayer||"bottom",to_layer:t.toLayer||"top",subcircuit_id:(i==null?void 0:i.subcircuit_id)??void 0,pcb_group_id:((s=this.getGroup())==null?void 0:s.pcb_group_id)??void 0});this.pcb_via_id=a.pcb_via_id}},ehn=class extends r2{get config(){return{componentName:"Battery",schematicSymbolName:this.props.symbolName??"battery",zodProps:ldn,sourceFtype:"simple_power_source"}}initPorts(){super.initPorts({additionalAliases:{pin1:["anode","pos","left"],pin2:["cathode","neg","right"]}})}doInitialSourceRender(){const{db:r}=this.root,{_parsedProps:e}=this,t=r.source_component.insert({name:e.name,ftype:"simple_power_source",capacity:e.capacity,supplier_part_numbers:e.supplierPartNumbers,are_pins_interchangeable:!1});this.source_component_id=t.source_component_id}},thn=class extends r2{get config(){return{componentName:"PinHeader",zodProps:cdn,shouldRenderAsSchematicBox:!0}}_getImpliedFootprintString(){var i;const r=this._parsedProps.pinCount??((i=this._parsedProps.pinLabels)==null?void 0:i.length)??0,e=this._parsedProps.holeDiameter,t=this._parsedProps.platedDiameter,n=this._parsedProps.pitch;return r>0&&n?!e&&!t?`pinrow${r}_p${n}`:`pinrow${r}_p${n}_id${e}_od${t}`:null}initPorts(){var e,t;const r=this._parsedProps.pinCount??((e=this._parsedProps.pinLabels)==null?void 0:e.length)??1;for(let n=1;n<=r;n++)this.add(new dS({name:`pin${n}`,pinNumber:n,aliases:[(t=this._parsedProps.pinLabels)==null?void 0:t[n-1]].filter(Boolean)}))}_getSchematicPortArrangement(){const r=this._parsedProps.pinCount??1,e=this._parsedProps.facingDirection??"right";return{leftSize:e==="left"?r:0,rightSize:e==="right"?r:0}}doInitialSourceRender(){const{db:r}=this.root,{_parsedProps:e}=this,t=r.source_component.insert({ftype:"simple_pin_header",name:e.name,supplier_part_numbers:e.supplierPartNumbers,pin_count:e.pinCount,gender:e.gender,are_pins_interchangeable:!0});this.source_component_id=t.source_component_id}};function nhn(r){switch(r){case"two_ground_pins":return"crystal_4pin";case"ground_pin":return"resonator";case"no_ground":return"crystal";default:return"crystal"}}var rhn=class extends r2{get config(){return{componentName:"Resonator",schematicSymbolName:this.props.symbolName??nhn(this.props.pinVariant),zodProps:Vfn,shouldRenderAsSchematicBox:!1}}doInitialSourceRender(){const{db:r}=this.root,{_parsedProps:e}=this,t=e.pinVariant||"no_ground",n=r.source_component.insert({ftype:"simple_resonator",name:e.name,frequency:e.frequency,load_capacitance:e.loadCapacitance,supplier_part_numbers:e.supplierPartNumbers,pin_variant:t,are_pins_interchangeable:t==="no_ground"||t==="ground_pin"});this.source_component_id=n.source_component_id}},ihn=class extends r2{get config(){return{componentName:"Inductor",schematicSymbolName:this.props.symbolName??"inductor",zodProps:hdn,sourceFtype:gP.simple_inductor}}initPorts(){super.initPorts({additionalAliases:{pin1:["anode","pos","left"],pin2:["cathode","neg","right"]}})}doInitialSourceRender(){const{db:r}=this.root,{_parsedProps:e}=this,t=r.source_component.insert({name:e.name,ftype:gP.simple_inductor,inductance:e.inductance,supplier_part_numbers:e.supplierPartNumbers,are_pins_interchangeable:!0});this.source_component_id=t.source_component_id}};function ahn(r){switch(r){case"three_pin":return"potentiometer3";case"two_pin":return"potentiometer2";default:return"potentiometer2"}}var ohn=class extends r2{get config(){return{componentName:"Potentiometer",schematicSymbolName:this.props.symbolName??ahn(this.props.pinVariant),zodProps:jfn,shouldRenderAsSchematicBox:!1}}doInitialSourceRender(){const{db:r}=this.root,{_parsedProps:e}=this,t=e.pinVariant||"two_pin",n=r.source_component.insert({ftype:"simple_potentiometer",name:e.name,max_resistance:e.maxResistance,pin_variant:t,are_pins_interchangeable:t==="two_pin"});this.source_component_id=n.source_component_id}},shn=class extends r2{get config(){return{componentName:"PushButton",schematicSymbolName:this.props.symbolName??"push_button_normally_open_momentary",zodProps:fdn,sourceFtype:gP.simple_push_button}}get defaultInternallyConnectedPinNames(){return[["pin1","pin4"],["pin2","pin3"]]}initPorts(){super.initPorts({pinCount:4,additionalAliases:{pin1:["side1"],pin3:["side2"]}})}doInitialSourceRender(){const{db:r}=this.root,{_parsedProps:e}=this,t=r.source_component.insert({name:e.name,ftype:gP.simple_push_button,supplier_part_numbers:e.supplierPartNumbers,are_pins_interchangeable:!0});this.source_component_id=t.source_component_id}},lhn=class extends r2{get config(){return{schematicSymbolName:this.props.symbolName??(this.props.pinVariant==="four_pin"?"crystal_4pin":"crystal"),componentName:"Crystal",zodProps:Hfn,sourceFtype:"simple_crystal"}}initPorts(){const r=this.props.pinVariant==="four_pin"?{pin1:["left1","1"],pin2:["top1","2","gnd1"],pin3:["right1","3"],pin4:["bottom1","4","gnd2"]}:{pin1:["pos","left"],pin2:["neg","right"]};super.initPorts({additionalAliases:r})}_getSchematicSymbolDisplayValue(){return`${Sb(this._parsedProps.frequency)}Hz`}doInitialSourceRender(){const{db:r}=this.root,{_parsedProps:e}=this,t=r.source_component.insert({name:e.name,ftype:"simple_crystal",frequency:e.frequency,load_capacitance:e.loadCapacitance,pin_variant:e.pinVariant||"two_pin",are_pins_interchangeable:(e.pinVariant||"two_pin")==="two_pin"});this.source_component_id=t.source_component_id}},chn=class extends r2{constructor(){super(...arguments);Qe(this,"emitter",this.portMap.pin1);Qe(this,"collector",this.portMap.pin2);Qe(this,"base",this.portMap.pin3)}get config(){return{componentName:"Transistor",schematicSymbolName:this.props.type==="npn"?"npn_bipolar_transistor":"pnp_bipolar_transistor",zodProps:ddn,sourceFtype:"simple_transistor",shouldRenderAsSchematicBox:!1}}initPorts(){const e=this.props.type==="npn"?{pin1:["emitter","e"],pin2:["collector","c"],pin3:["base","b"]}:{pin1:["collector","c"],pin2:["emitter","e"],pin3:["base","b"]};super.initPorts({pinCount:3,additionalAliases:e})}doInitialSourceRender(){const{db:e}=this.root,{_parsedProps:t}=this,n=e.source_component.insert({ftype:"simple_transistor",name:t.name,transistor_type:t.type});this.source_component_id=n.source_component_id}},uhn=class extends r2{get config(){const r=this.props.mosfetMode==="depletion"?"d":"e";return{componentName:"Mosfet",schematicSymbolName:`${this.props.channelType}_channel_${r}_mosfet_transistor`,zodProps:pdn,shouldRenderAsSchematicBox:!1}}doInitialSourceRender(){const{db:r}=this.root,{_parsedProps:e}=this,t=r.source_component.insert({ftype:"simple_mosfet",name:e.name,mosfet_mode:e.mosfetMode,channel_type:e.channelType});this.source_component_id=t.source_component_id}},fhn=class extends r2{_getSwitchType(){const{spst:r,spdt:e,dpst:t,dpdt:n,type:i}=this._parsedProps??{};return n?"dpdt":r?"spst":e?"spdt":t?"dpst":i??"spst"}get config(){const r=this._getSwitchType(),{isNormallyClosed:e}=this._parsedProps??{};return{componentName:"Switch",schematicSymbolName:{spst:e?"spst_normally_closed_switch":"spst_switch",spdt:e?"spdt_normally_closed_switch":"spdt_switch",dpst:e?"dpst_normally_closed_switch":"dpst_switch",dpdt:e?"dpdt_normally_closed_switch":"dpdt_switch"}[r]??"spst_switch",zodProps:bdn,shouldRenderAsSchematicBox:!1}}doInitialSourceRender(){const{db:r}=this.root,{_parsedProps:e}=this,t=r.source_component.insert({ftype:"simple_switch",name:e.name,switch_type:e.type,is_normally_closed:e.isNormallyClosed??!1,are_pins_interchangeable:this._getSwitchType()==="spst"});this.source_component_id=t.source_component_id}},dhn=class extends Jg{constructor(){super(...arguments);Qe(this,"isSchematicPrimitive",!0)}get config(){return{componentName:"SchematicText",zodProps:Adn}}doInitialSchematicPrimitiveRender(){var n;if((n=this.root)!=null&&n.schematicDisabled)return;const{db:e}=this.root,{_parsedProps:t}=this;e.schematic_text.insert({anchor:t.anchor??"center",text:t.text,font_size:t.fontSize,color:t.color||"#000000",position:{x:t.schX,y:t.schY},rotation:t.schRotation??0})}};new Proxy({},{get:(r,e)=>{const t=(...n)=>(n[0],new Proxy({},{get:(i,a)=>`.${e} > .${a}`}));return new Proxy(t,{get:(n,i)=>e==="net"?`net.${i}`:e==="subcircuit"?new Proxy({},{get:(a,o)=>new Proxy({},{get:(s,l)=>`subcircuit.${i} > .${o} > .${l}`})}):`.${e} > .${i}`,apply:(n,i,a)=>new Proxy({},{get:(o,s)=>{const l=`.${e} > .${s}`;return e.startsWith("U")?l:new Proxy(new String(l),{get:(c,u)=>typeof u=="symbol"||u==="toString"?()=>l:`.${e} > .${s} > .${u}`})}})})}}),lXe(oXe),lXe({Bug:CXe});const RXe=r=>`hsl(${Ub.indexOf(r)*137.5%360}, 70%, 50%)`,phn=({phaseTimings:r})=>{if(!r)return null;const e=Object.values(r).reduce((t,n)=>t+n,0);return ut.jsxs("div",{className:"rf-space-y-2 rf-w-full rf-px-4",children:[ut.jsx("div",{className:"rf-relative rf-h-8 rf-flex rf-rounded-sm",children:Ub.map(t=>{const n=r[t]||0,i=n/e*100;return ut.jsx("div",{className:"rf-group/bar rf-relative rf-overflow-visible",style:{width:`${i}%`,backgroundColor:RXe(t)},children:ut.jsxs("div",{className:"rf-opacity-0 group-hover/bar:rf-opacity-100 rf-transition-opacity rf-absolute rf-bottom-full rf-left-1/2 rf-transform -rf-translate-x-1/2 rf-mb-2 rf-px-2 rf-py-1 rf-text-xs rf-whitespace-nowrap rf-rounded rf-bg-gray-900 rf-text-white rf-pointer-events-none",children:[t,": ",n.toFixed(1),"ms"]})},t)})}),ut.jsxs("div",{className:"rf-text-xs rf-text-gray-500",children:["Total: ",e.toFixed(2),"ms"]})]})},hhn=({renderLog:r})=>{const[e,t]=mt.useState("chronological");if(!r)return ut.jsx("div",{className:"rf-p-4 rf-bg-gray-100 rf-rounded-md",children:"No render log, make sure this tab is open when you render (TODO add a rerender button here)"});const n=Object.entries((r==null?void 0:r.phaseTimings)??{});e==="chronological"?n.sort((a,o)=>Ub.indexOf(a[0])-Ub.indexOf(o[0])):n.sort((a,o)=>o[1]-a[1]);const i=n.reduce((a,[o,s])=>a+s,0);return ut.jsxs("div",{className:"rf-bg-white",children:[ut.jsxs("div",{className:"rf-flex rf-justify-between rf-items-center",children:[ut.jsx("div",{children:"Render Logs"}),ut.jsxs("div",{className:"rf-mb-4 rf-pr-2 rf-flex rf-text-xs rf-items-center",children:[ut.jsx("div",{className:"rf-mr-2",children:"Sort by:"}),ut.jsxs("select",{value:e,onChange:a=>t(a.target.value),className:"rf-px-2 rf-py-1 rf-border rf-rounded rf-text-xs",children:[ut.jsx("option",{value:"chronological",children:"Phase Order"}),ut.jsx("option",{value:"longest",children:"Duration"})]})]})]}),ut.jsx(phn,{phaseTimings:r.phaseTimings}),ut.jsxs("table",{className:"rf-w-full rf-text-xs",children:[ut.jsx("thead",{children:ut.jsxs("tr",{children:[ut.jsx("th",{className:"rf-text-left rf-p-2",children:"Phase Order"}),ut.jsx("th",{className:"rf-text-left rf-p-2",children:"Phase"}),ut.jsx("th",{className:"rf-text-left rf-p-2",children:"Duration (ms)"})]})}),ut.jsx("tbody",{children:n.map(([a,o])=>ut.jsxs("tr",{children:[ut.jsx("td",{className:"rf-p-2",children:Ub.indexOf(a)}),ut.jsx("td",{className:"rf-p-2",children:a}),ut.jsx("td",{className:"rf-p-2",children:ut.jsx("div",{className:"rf-w-8",children:ut.jsx("div",{className:"rf-h-2 rf-rounded-sm",style:{backgroundColor:RXe(a),width:`${o/i*100}%`}})})}),ut.jsx("td",{className:"rf-p-2",children:ut.jsxs("div",{className:"rf-flex w-full",children:[ut.jsxs("span",{className:"rf-flex-grow",children:[o,"ms"]}),ut.jsxs("span",{className:"rf-text-gray-500 rf-pr-2",children:[(o/i*100).toFixed(1),"%"]})]})})]},a))})]})]})},mhn="0.0.439",vhn=["assembly","bom","circuit_json","errors","render_log"],yhn=({code:r,onRunClicked:e=void 0,errorMessage:t,circuitJson:n,autoroutingGraphics:i,showRightHeaderContent:a=!0,showCodeTab:o=!1,codeTabContent:s,showJsonTab:l=!0,showRenderLogTab:c=!0,onActiveTabChange:u,renderLog:f,showImportAndFormatButtons:p=!0,className:v,headerClassName:x,leftHeaderContent:S,readOnly:w,isStreaming:b,autoroutingLog:C,onReportAutoroutingLog:z,isRunningCode:I,hasCodeChangedSinceLastRun:G,onEditEvent:Y,editEvents:Z,defaultActiveTab:W,autoRotate3dViewerDisabled:te,showSchematicDebugGrid:J=!1,showToggleFullScreen:fe=!0,defaultToFullScreen:he=!1})=>{var Ue;hfn();const ve=mt.useMemo(()=>n?n.filter(Ie=>Ie&&"error_type"in Ie):null,[n]),[Te,Pe]=mt.useState(W??"pcb"),[we,Ce]=mt.useState(he),be=mt.useCallback(Ie=>{Pe(Ie),u==null||u(Ie)},[u]),Le=()=>{Ce(!we)};return mt.useEffect(()=>{t&&be("errors")},[t]),mt.useEffect(()=>{(Te==="code"||Te==="errors")&&n&&!t&&be(W??"pcb")},[n]),ut.jsx("div",{className:Wy("flex flex-col relative rf-overflow-x-hidden",v),children:ut.jsx("div",{className:Wy("rf-md:sticky rf-md:top-2",we&&"rf-fixed rf-top-0 rf-left-0 rf-w-full rf-bg-white"),children:ut.jsxs(LKe,{value:Te,onValueChange:be,className:"rf-flex-grow rf-flex rf-flex-col",children:[ut.jsxs("div",{className:Wy("rf-flex rf-items-center rf-gap-2 rf-p-2 rf-pb-0",x),children:[S,S&&ut.jsx("div",{className:"rf-flex-grow"}),!S&&I&&ut.jsx(rze,{className:"rf-w-4 rf-h-4 rf-animate-spin"}),!S&&ut.jsx("div",{className:"rf-flex-grow"}),f&&f.progress!==1&&ut.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2",children:[f.lastRenderEvent&&ut.jsx("div",{className:"rf-text-xs rf-text-gray-500",children:((Ue=f.lastRenderEvent)==null?void 0:Ue.phase)??""}),ut.jsx("div",{className:"rf-w-4 rf-h-4 rf-bg-blue-500 rf-opacity-50 rf-rounded-full rf-text-white",children:ut.jsx(rze,{className:"rf-w-4 rf-h-4 rf-animate-spin"})}),ut.jsxs("div",{className:"rf-text-xs rf-font-bold rf-text-gray-700 rf-tabular-nums",children:[((f.progress??0)*100).toFixed(1),"%"]})]}),a&&ut.jsxs(nhe,{children:[o&&ut.jsx(ww,{value:"code",children:"Code"}),ut.jsxs(ww,{value:"pcb",className:"rf-whitespace-nowrap",children:[n&&ut.jsx("span",{className:Wy("rf-inline-flex rf-items-center rf-justify-center rf-w-2 rf-h-2 rf-mr-1 rf-text-xs rf-font-bold rf-text-white rf-rounded-full",G?"rf-bg-gray-500":"rf-bg-blue-500")}),"PCB"]}),ut.jsxs(ww,{value:"schematic",className:"rf-whitespace-nowrap",children:[n&&ut.jsx("span",{className:Wy("rf-inline-flex rf-items-center rf-justify-center rf-w-2 rf-h-2 rf-mr-1 rf-text-xs rf-font-bold rf-text-white rf-rounded-full",G?"rf-bg-gray-500":"rf-bg-blue-500")}),"Schematic"]}),ut.jsxs(ww,{value:"cad",children:[n&&ut.jsx("span",{className:Wy("inline-flex items-center justify-center w-2 h-2 mr-1 text-xs font-bold text-white rounded-full",G?"rf-bg-gray-500":"rf-bg-blue-500")}),"3D"]}),!["pcb","cad","schematic"].includes(Te)&&ut.jsx(ww,{value:Te,children:the(Te)}),ut.jsxs(pIe,{children:[ut.jsx(hIe,{asChild:!0,children:ut.jsxs("div",{className:"rf-whitespace-nowrap rf-p-2 rf-mr-1 rf-cursor-pointer rf-relative",children:[ut.jsx(PBt,{className:"rf-w-4 rf-h-4"}),(ve&&ve.length>0||t)&&ut.jsx("span",{className:"rf-inline-flex rf-absolute rf-top-[6px] rf-right-[4px] rf-items-center rf-justify-center rf-w-1 rf-h-1 rf-ml-2 rf-text-[8px] rf-font-bold rf-text-white rf-bg-red-500 rf-rounded-full"})]})}),ut.jsxs(Uoe,{className:"rf-*:text-xs",children:[vhn.map(Ie=>ut.jsxs(XI,{onSelect:()=>be(Ie),children:[Te!==Ie&&ut.jsx(nze,{className:"rf-w-3 rf-h-3 rf-opacity-30"}),Te===Ie&&ut.jsx(eze,{className:"rf-w-3 rf-h-3"}),ut.jsx("div",{className:"rf-pr-2",children:the(Ie)}),Ie==="errors"&&(ve&&ve.length>0||t)&&ut.jsx("span",{className:"rf-inline-flex rf-items-center rf-justify-center rf-w-3 rf-h-3 rf-ml-2 rf-text-[8px] rf-font-bold rf-text-white rf-bg-red-500 rf-rounded-full",children:t?1:ve==null?void 0:ve.length})]},Ie)),ut.jsx(XI,{disabled:!0,className:"rf-opacity-60 rf-cursor-default rf-select-none",children:ut.jsxs("div",{className:"rf-pr-2 rf-text-xs rf-text-gray-500",children:["@tscircuit/runframe@",mhn.split(".").map((Ie,ke)=>ke===2?parseInt(Ie)+1:Ie).join(".")]})})]})]})]}),fe&&ut.jsx(i6,{onClick:Le,variant:"ghost",children:we?ut.jsx(LBt,{size:16}):ut.jsx(NBt,{size:16})})]}),o&&ut.jsx(S4,{value:"code",className:"rf-flex-grow rf-overflow-hidden",children:ut.jsx("div",{className:"rf-h-full",children:s})}),ut.jsx(S4,{value:"pcb",children:ut.jsx("div",{className:Wy("rf-overflow-hidden",we?"rf-h-[calc(100vh-52px)]":"rf-h-[620px]"),children:ut.jsx(uT,{fallbackRender:({error:Ie})=>ut.jsx("div",{className:"rf-mt-4 rf-bg-red-50 rf-rounded-md rf-border rf-border-red-200",children:ut.jsxs("div",{className:"rf-p-4",children:[ut.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-red-800 rf-mb-3",children:"Error loading PCB viewer"}),ut.jsx("p",{className:"rf-text-xs rf-font-mono rf-whitespace-pre-wrap rf-text-red-600 rf-mt-2",children:(Ie==null?void 0:Ie.message)||"An unknown error occurred"})]})}),children:n?ut.jsx(dfn,{focusOnHover:!1,circuitJson:n,debugGraphics:i,containerClassName:Wy("rf-h-full rf-w-full",we?"rf-min-h-[calc(100vh-240px)]":"rf-min-h-[620px]"),onEditEventsChanged:Ie=>{Y&&Ie.forEach(ke=>Y(ke))}}):ut.jsx(Q7,{onRunClicked:e})})})}),ut.jsx(S4,{value:"assembly",children:ut.jsx("div",{className:Wy("rf-overflow-auto",we?"rf-h-[calc(100vh-96px)]":"rf-h-[620px]"),children:ut.jsx(uT,{fallback:ut.jsx("div",{children:"Error loading Assembly"}),children:n?ut.jsx(cQt,{circuitJson:n,containerStyle:{height:"100%"},editingEnabled:!0,debugGrid:!0}):ut.jsx(Q7,{onRunClicked:e})})})}),ut.jsx(S4,{value:"schematic",children:ut.jsx("div",{className:Wy("rf-overflow-auto rf-bg-white",we?"rf-h-[calc(100vh-96px)]":"rf-h-[620px]"),children:ut.jsx(uT,{fallbackRender:({error:Ie})=>ut.jsx("div",{className:"rf-mt-4 rf-bg-red-50 rf-rounded-md rf-border rf-border-red-200",children:ut.jsxs("div",{className:"rf-p-4",children:[ut.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-red-800 rf-mb-3",children:"Error loading Schematic"}),ut.jsx("p",{className:"rf-text-xs rf-font-mono rf-whitespace-pre-wrap rf-text-red-600 rf-mt-2",children:(Ie==null?void 0:Ie.message)||"An unknown error occurred"})]})}),children:n?ut.jsx(oQt,{circuitJson:n,containerStyle:{height:"100%"},editingEnabled:!0,onEditEvent:Ie=>{Y==null||Y(Ie)},debugGrid:J,colorOverrides:{schematic:{background:"transparent"}}}):ut.jsx(Q7,{onRunClicked:e})})})}),ut.jsx(S4,{value:"cad",children:ut.jsx("div",{className:Wy("rf-overflow-auto",we?"rf-h-[calc(100vh-96px)]":"rf-h-[620px]"),children:ut.jsx(uT,{FallbackComponent:vBt,children:n?ut.jsx(hBt,{soup:n,autoRotateDisabled:te}):ut.jsx(Q7,{onRunClicked:e})})})}),ut.jsx(S4,{value:"bom",children:ut.jsx("div",{className:Wy("rf-overflow-auto",we?"rf-h-[calc(100vh-96px)]":"rf-h-[620px]"),children:ut.jsx(uT,{fallbackRender:({error:Ie})=>ut.jsx("div",{className:"rf-mt-4 rf-bg-red-50 rf-rounded-md rf-border rf-border-red-200",children:ut.jsxs("div",{className:"rf-p-4",children:[ut.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-red-800 rf-mb-3",children:"Error loading Bill of Materials"}),ut.jsx("p",{className:"rf-text-xs rf-font-mono rf-whitespace-pre-wrap rf-text-red-600 rf-mt-2",children:(Ie==null?void 0:Ie.message)||"An unknown error occurred"})]})}),children:n?ut.jsx(hQt,{circuitJson:n}):ut.jsx(Q7,{onRunClicked:e})})})}),ut.jsx(S4,{value:"circuit_json",children:ut.jsx("div",{className:Wy("rf-overflow-auto",we?"rf-h-[calc(100vh-96px)]":"rf-h-[620px]"),children:ut.jsx(uT,{fallback:ut.jsx("div",{children:"Error loading JSON viewer"}),children:n?ut.jsx(dQt,{elements:n}):ut.jsx(Q7,{onRunClicked:e})})})}),ut.jsx(S4,{value:"errors",children:ut.jsx("div",{className:Wy("rf-overflow-auto",we?"rf-h-[calc(100vh-96px)]":"rf-h-[620px]"),children:Array.isArray(ve)&&ve.length>0||t?ut.jsx(P$t,{code:r,circuitJsonErrors:ve,errorMessage:t,autoroutingLog:C,onReportAutoroutingLog:z}):ut.jsx(Q7,{onRunClicked:e})})}),c&&ut.jsx(S4,{value:"render_log",children:ut.jsx(hhn,{renderLog:f})})]})})})};Spe.createRoot(document.getElementById("root")).render(ut.jsx(yhn,{defaultActiveTab:"cad",autoRotate3dViewerDisabled:!0,showRightHeaderContent:!1,circuitJson:window.CIRCUIT_JSON||{},...window.CIRCUIT_JSON_PREVIEW_PROPS||{}}))});
|
package/dist/standalone.min.js
CHANGED
|
@@ -13451,7 +13451,7 @@ $1`).replace(/>(\s*)(?=<!--\s*\/)/g,"> ")}return lpe}Z9n();function $We(n,e,t,r=
|
|
|
13451
13451
|
&:hover {
|
|
13452
13452
|
background-color: rgba(255, 255, 255, 0.1);
|
|
13453
13453
|
}
|
|
13454
|
-
`,onClick:r=>{r.stopPropagation(),t()},children:[Ge.jsx("input",{type:"checkbox",checked:e}),Ge.jsx("span",{style:{color:"#eee"},children:n})]}),__n=({children:n,elements:e})=>{const[t,r]=Bx($=>[$.is_mouse_over_container,$.setIsMouseOverContainer]),[i,a]=rt.useState(!1),[o,s]=rt.useState(!1),[l,c]=rt.useState(!1),[u,d]=Bx($=>[$.selected_layer,$.selectLayer]),[f,m,y,E,w,S]=Bx($=>[$.in_move_footprint_mode,$.in_draw_trace_mode,$.is_showing_rats_nest,$.is_showing_multiple_traces_length,$.is_showing_autorouting,$.is_showing_drc_errors]),T=Bx($=>$.setEditMode),P=Bx($=>$.setIsShowingRatsNest),U=Bx($=>$.setIsShowingMultipleTracesLength),H=Bx($=>$.setIsShowingAutorouting),G=Bx($=>$.setIsShowingDrcErrors);Q6("1",()=>d("top")),Q6("2",()=>d("bottom")),Q6("3",()=>d("inner1")),Q6("4",()=>d("inner2")),Q6("5",()=>d("inner3")),Q6("6",()=>d("inner4")),Q6("7",()=>d("inner5")),Q6("8",()=>d("inner6"));const W=(e==null?void 0:e.filter($=>$.type.includes("error")).length)??0;return Ge.jsxs("div",{style:{position:"relative"},onMouseEnter:()=>{r(!0)},onMouseLeave:$=>{r(!1),s(!1)},children:[n,Ge.jsxs("div",{style:{position:"absolute",bottom:4,right:8,pointerEvents:"none",color:"white",fontSize:11,opacity:t?.5:0,transition:"opacity 1s",transitionDelay:"2s",fontFamily:"sans-serif"},children:["@tscircuit/pcb-viewer@",y_n.version]}),Ge.jsxs("div",{style:{position:"absolute",opacity:t?1:0,top:16,left:16,transition:t?"opacity 100ms linear":"opacity 1s linear",zIndex:fb.toolbarOverlay,color:"red",display:"flex",fontSize:12,height:100,fontFamily:"sans-serif"},children:[Ge.jsxs(CM,{onClick:()=>{s(!o)},onMouseLeave:()=>{o&&s(!1)},children:[Ge.jsxs("div",{children:["layer:"," ",Ge.jsx("span",{style:{marginLeft:2,fontWeight:500,color:MM[u]},children:u})]}),o&&Ge.jsx("div",{style:{marginTop:4,minWidth:120},children:Vpe.map($=>$.replace(/-/g,"")).map($=>Ge.jsx(g_n,{name:$,selected:$===u,onClick:()=>{d($.replace(/-/,""))}},$))})]}),Ge.jsxs(CM,{style:W>0?{color:"red"}:{},onClick:()=>c(!l),onMouseLeave:()=>c(!1),children:[Ge.jsxs("div",{children:[W," errors"]}),l&&Ge.jsx("div",{style:{display:"grid",gridTemplateColumns:"100px 300px"},children:e==null?void 0:e.filter($=>$.type.includes("error")).map(($,Q)=>Ge.jsxs(rt.Fragment,{children:[Ge.jsx("div",{children:$.error_type}),Ge.jsx("div",{children:$.message})]},Q))})]}),Ge.jsx(CM,{style:{},onClick:()=>{T(m?"off":"draw_trace")},children:Ge.jsxs("div",{children:[m?"✖ ":"","Edit Traces"]})}),Ge.jsx(CM,{style:{},onClick:()=>{T(f?"off":"move_footprint")},children:Ge.jsxs("div",{children:[f?"✖ ":"","Move Components"]})}),Ge.jsx(CM,{style:{},onClick:()=>{P(!y)},children:Ge.jsxs("div",{children:[y?"✖ ":"","Rats Nest"]})}),Ge.jsx(CM,{onClick:()=>{a(!i)},children:Ge.jsxs("div",{children:[Ge.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"4px"},children:["View"," ",Ge.jsx("span",{style:{fontSize:"8px",transform:i?"rotate(180deg)":"rotate(0)",transition:"transform 0.1s ease",display:"inline-block"},children:"▼"})]}),i&&Ge.jsxs("div",{style:{marginTop:4,minWidth:120},children:[Ge.jsx(Xpe,{label:"Show All Trace Lengths",checked:E,onClick:()=>{U(!E)}}),Ge.jsx(Xpe,{label:"Show Autorouting Animation",checked:w,onClick:()=>{H(!w)}}),Ge.jsx(Xpe,{label:"Show DRC Errors",checked:S,onClick:()=>{G(!S)}})]})]})})]})]})},x_n=n=>{const{transform:e,elements:t}=n,[r,i]=rt.useMemo(()=>{const c=n.elements.flatMap(d=>Ngn(d,n.elements)),u=W8(n.elements);return[c,u]},[n.elements]),[a,o]=rt.useState({drawingObjectIdsWithMouseOver:new Set,primitiveIdsInMousedOverNet:[]}),s=rt.useMemo(()=>Rgn({primitivesWithoutInteractionMetadata:r,drawingObjectIdsWithMouseOver:a.drawingObjectIdsWithMouseOver,primitiveIdsInMousedOverNet:a.primitiveIdsInMousedOverNet}),[r,a]),l=rt.useCallback(c=>{var f,m;const u=[];for(const y of c)if(y._element){const E=i.getNetConnectedToId("pcb_port_id"in y._element?(f=y._element)==null?void 0:f.pcb_port_id:"pcb_trace_id"in y._element?(m=y._element)==null?void 0:m.pcb_trace_id:"");u.push(...i.getIdsConnectedToNet(E))}const d=new Set(c.map(y=>y._pcb_drawing_object_id));o({drawingObjectIdsWithMouseOver:d,primitiveIdsInMousedOverNet:u})},[i]);return Ge.jsx(m_n,{elements:t,transform:e,primitives:r,onMouseHoverOverPrimitives:l,children:Ge.jsx(Kgn,{disabled:!n.allowEditing,transform:e,soup:t,cancelPanDrag:n.cancelPanDrag,onCreateEditEvent:n.onCreateEditEvent,onModifyEditEvent:n.onModifyEditEvent,children:Ge.jsx(n_n,{disabled:!n.allowEditing,transform:e,soup:t,cancelPanDrag:n.cancelPanDrag,onCreateEditEvent:n.onCreateEditEvent,onModifyEditEvent:n.onModifyEditEvent,children:Ge.jsx(Zgn,{transform:e,focusOnHover:n.focusOnHover,children:Ge.jsx(__n,{elements:t,children:Ge.jsx(a_n,{transform:e,elements:t,children:Ge.jsx(v_n,{transform:e,soup:t,children:Ge.jsx(Xgn,{transform:e,debugGraphics:n.debugGraphics,children:Ge.jsx(Wgn,{transform:e,elements:t,children:Ge.jsx(Ygn,{transform:e,primitives:s,width:n.width,height:n.height,grid:n.grid})})})})})})})})})})},b_n=Mc(k0(400,300),n2(40,-40)),S_n=({circuitJson:n,debugGraphics:e,height:t=600,initialState:r,allowEditing:i=!0,editEvents:a,onEditEventsChanged:o,focusOnHover:s=!1,clickToInteractEnabled:l=!1})=>{const[c,u]=rt.useState(!l),[d,f]=qpe(),[m,y]=rt.useState(b_n),{ref:E,setTransform:w,cancelDrag:S}=Cgn({transform:m,onSetTransform:y,enabled:c});let[T,P]=rt.useState([]);T=a??T;const U=rt.useRef(!1),H=rt.useRef(null),G=`${(n==null?void 0:n.length)||0}_${(n==null?void 0:n.editCount)||0}`,W=()=>{const pe=(f==null?void 0:f.width)>0?f:{width:500,height:500},{center:ce,width:Se,height:he}=Q.some(xe=>xe.type.startsWith("pcb_"))?ygn(Q.filter(xe=>xe.type.startsWith("pcb_"))):{center:{x:0,y:0},width:.001,height:.001},ge=Math.min((pe.width??0)/Se,(pe.height??0)/he,100)*.75,Te=Mc(k0((pe.width??0)/2,(pe.height??0)/2),n2(ge,-ge,0,0),k0(-ce.x,-ce.y));w(Te)};rt.useEffect(()=>{f!=null&&f.width&&n&&n.length!==0&&(U.current||(W(),U.current=!0))},[n,f]);const $=rt.useMemo(()=>(n==null?void 0:n.filter(pe=>pe.type.startsWith("pcb_")||pe.type.startsWith("source_")))??[],[G]),Q=rt.useMemo(()=>$1n({circuitJson:$,editEvents:T}),[$,T]),X=pe=>{P([...T,pe]),o==null||o([...T,pe])},ue=pe=>{const ce=T.map(Se=>Se.edit_event_id===pe.edit_event_id?{...Se,...pe}:Se);P(ce),o==null||o(ce)};return Ge.jsxs("div",{ref:E,style:{position:"relative"},children:[Ge.jsx("div",{ref:d,children:Ge.jsxs(_gn,{initialState:r,children:[Ge.jsx(x_n,{transform:m,height:t,width:f.width,allowEditing:i,focusOnHover:s,cancelPanDrag:S,onCreateEditEvent:X,onModifyEditEvent:ue,grid:{spacing:1,view_window:{left:0,right:f.width||500,top:t,bottom:0}},elements:Q,debugGraphics:e},f.width),Ge.jsx(bgn,{})]})}),l&&!c&&Ge.jsx("div",{onClick:()=>{u(!0),W()},onTouchStart:pe=>{const ce=pe.touches[0];H.current={x:ce.clientX,y:ce.clientY}},onTouchEnd:pe=>{const ce=pe.changedTouches[0],Se=H.current;if(!Se)return;const he=Math.abs(ce.clientX-Se.x),ge=Math.abs(ce.clientY-Se.y);he<10&&ge<10&&(pe.preventDefault(),u(!0),W()),H.current=null},style:{position:"absolute",inset:0,cursor:"pointer",zIndex:fb.clickToInteractOverlay,display:"flex",alignItems:"center",justifyContent:"center",touchAction:"pan-x pan-y pinch-zoom"},children:Ge.jsx("div",{style:{backgroundColor:"rgba(0, 0, 0, 0.8)",color:"white",padding:"12px 24px",borderRadius:"8px",fontSize:"16px",pointerEvents:"none"},children:typeof window<"u"&&("ontouchstart"in window||navigator.maxTouchPoints>0)?"Touch to Interact":"Click to Interact"})})]})};const w_n=({containerClassName:n,...e})=>{const t=rt.useRef(null),[r,i]=rt.useState(620);return rt.useLayoutEffect(()=>{const a=()=>{if(t.current){const s=t.current.clientHeight,l=window.innerHeight;i(Math.min(Math.max(s,620),l))}};a();const o=new ResizeObserver(a);return t.current&&o.observe(t.current),window.addEventListener("resize",a),()=>{o.disconnect(),window.removeEventListener("resize",a)}},[]),Ge.jsx("div",{ref:t,className:n||"rf-w-full rf-h-full",children:Ge.jsx(S_n,{...e,height:r})})},E_n='*,:after,:before{--tw-border-spacing-x:0;--tw-border-spacing-y:0;--tw-translate-x:0;--tw-translate-y:0;--tw-rotate:0;--tw-skew-x:0;--tw-skew-y:0;--tw-scale-x:1;--tw-scale-y:1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness:proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:rgba(59,130,246,.5);--tw-ring-offset-shadow:0 0 #0000;--tw-ring-shadow:0 0 #0000;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }::backdrop{--tw-border-spacing-x:0;--tw-border-spacing-y:0;--tw-translate-x:0;--tw-translate-y:0;--tw-rotate:0;--tw-skew-x:0;--tw-skew-y:0;--tw-scale-x:1;--tw-scale-y:1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness:proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:rgba(59,130,246,.5);--tw-ring-offset-shadow:0 0 #0000;--tw-ring-shadow:0 0 #0000;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }/*! tailwindcss v3.4.17 | MIT License | https://tailwindcss.com*/*,:after,:before{border:0 solid #e5e7eb;box-sizing:border-box}:after,:before{--tw-content:""}:host,html{line-height:1.5;-webkit-text-size-adjust:100%;font-family:ui-sans-serif,system-ui,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;font-feature-settings:normal;font-variation-settings:normal;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-tap-highlight-color:transparent}body{line-height:inherit;margin:0}hr{border-top-width:1px;color:inherit;height:0}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,pre,samp{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace;font-feature-settings:normal;font-size:1em;font-variation-settings:normal}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}table{border-collapse:collapse;border-color:inherit;text-indent:0}button,input,optgroup,select,textarea{color:inherit;font-family:inherit;font-feature-settings:inherit;font-size:100%;font-variation-settings:inherit;font-weight:inherit;letter-spacing:inherit;line-height:inherit;margin:0;padding:0}button,select{text-transform:none}button,input:where([type=button]),input:where([type=reset]),input:where([type=submit]){-webkit-appearance:button;background-color:transparent;background-image:none}:-moz-focusring{outline:auto}:-moz-ui-invalid{box-shadow:none}progress{vertical-align:baseline}::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}summary{display:list-item}blockquote,dd,dl,figure,h1,h2,h3,h4,h5,h6,hr,p,pre{margin:0}fieldset{margin:0}fieldset,legend{padding:0}menu,ol,ul{list-style:none;margin:0;padding:0}dialog{padding:0}textarea{resize:vertical}input::-moz-placeholder,textarea::-moz-placeholder{color:#9ca3af;opacity:1}input::placeholder,textarea::placeholder{color:#9ca3af;opacity:1}[role=button],button{cursor:pointer}:disabled{cursor:default}audio,canvas,embed,iframe,img,object,svg,video{display:block;vertical-align:middle}img,video{height:auto;max-width:100%}[hidden]:where(:not([hidden=until-found])){display:none}:root{--radius:0.5rem}.rf-pointer-events-none{pointer-events:none}.rf-invisible{visibility:hidden}.rf-fixed{position:fixed}.rf-absolute{position:absolute}.rf-relative{position:relative}.rf-inset-0{inset:0}.-rf-left-2{left:-.5rem}.-rf-right-10{right:-2.5rem}.-rf-right-2{right:-.5rem}.-rf-right-4{right:-1rem}.-rf-right-6{right:-1.5rem}.-rf-right-7{right:-1.75rem}.-rf-right-8{right:-2rem}.-rf-right-9{right:-2.25rem}.rf-bottom-full{bottom:100%}.rf-left-0{left:0}.rf-left-1{left:.25rem}.rf-left-1\\/2{left:50%}.rf-left-2{left:.5rem}.rf-left-\\[50\\%\\]{left:50%}.rf-right-0{right:0}.rf-right-4{right:1rem}.rf-right-\\[4px\\]{right:4px}.rf-top-0{top:0}.rf-top-1{top:.25rem}.rf-top-2{top:.5rem}.rf-top-2\\.5{top:.625rem}.rf-top-\\[50\\%\\]{top:50%}.rf-top-\\[6px\\]{top:6px}.rf-z-50{z-index:50}.rf-z-\\[100\\]{z-index:100}.-rf-mx-1,.rf--mx-1{margin-left:-.25rem;margin-right:-.25rem}.rf-mx-1{margin-left:.25rem;margin-right:.25rem}.rf-mx-2{margin-left:.5rem;margin-right:.5rem}.rf-mx-auto{margin-left:auto;margin-right:auto}.rf-my-1{margin-bottom:.25rem;margin-top:.25rem}.rf-my-12{margin-bottom:3rem;margin-top:3rem}.rf-my-4{margin-bottom:1rem;margin-top:1rem}.rf-my-auto{margin-bottom:auto;margin-top:auto}.rf-mb-1{margin-bottom:.25rem}.rf-mb-12{margin-bottom:3rem}.rf-mb-2{margin-bottom:.5rem}.rf-mb-3{margin-bottom:.75rem}.rf-mb-4{margin-bottom:1rem}.rf-mb-6{margin-bottom:1.5rem}.rf-mb-8{margin-bottom:2rem}.rf-ml-1{margin-left:.25rem}.rf-ml-2{margin-left:.5rem}.rf-ml-auto{margin-left:auto}.rf-mr-1{margin-right:.25rem}.rf-mr-2{margin-right:.5rem}.rf-mt-0{margin-top:0}.rf-mt-0\\.5{margin-top:.125rem}.rf-mt-1{margin-top:.25rem}.rf-mt-2{margin-top:.5rem}.rf-mt-3{margin-top:.75rem}.rf-mt-4{margin-top:1rem}.rf-mt-5{margin-top:1.25rem}.rf-mt-auto{margin-top:auto}.rf-block{display:block}.rf-inline{display:inline}.rf-flex{display:flex}.rf-inline-flex{display:inline-flex}.rf-grid{display:grid}.rf-hidden{display:none}.rf-aspect-square{aspect-ratio:1/1}.rf-aspect-video{aspect-ratio:16/9}.rf-size-14{height:3.5rem;width:3.5rem}.rf-size-4{height:1rem;width:1rem}.\\!rf-h-2{height:.5rem!important}.\\!rf-h-2\\.5{height:.625rem!important}.\\!rf-h-3{height:.75rem!important}.\\!rf-h-full{height:100%!important}.rf-h-1{height:.25rem}.rf-h-10{height:2.5rem}.rf-h-12{height:3rem}.rf-h-2{height:.5rem}.rf-h-2\\.5{height:.625rem}.rf-h-3{height:.75rem}.rf-h-3\\.5{height:.875rem}.rf-h-4{height:1rem}.rf-h-5{height:1.25rem}.rf-h-6{height:1.5rem}.rf-h-60{height:15rem}.rf-h-64{height:16rem}.rf-h-8{height:2rem}.rf-h-9{height:2.25rem}.rf-h-\\[620px\\]{height:620px}.rf-h-\\[calc\\(100vh-52px\\)\\]{height:calc(100vh - 52px)}.rf-h-\\[calc\\(100vh-96px\\)\\]{height:calc(100vh - 96px)}.rf-h-\\[var\\(--radix-select-trigger-height\\)\\]{height:var(--radix-select-trigger-height)}.rf-h-fit{height:-moz-fit-content;height:fit-content}.rf-h-full{height:100%}.rf-h-px{height:1px}.\\!rf-max-h-\\[40vh\\]{max-height:40vh!important}.\\!rf-max-h-\\[70\\%\\]{max-height:70%!important}.rf-max-h-32{max-height:8rem}.rf-max-h-96{max-height:24rem}.rf-max-h-\\[500px\\]{max-height:500px}.rf-max-h-\\[90vh\\]{max-height:90vh}.rf-min-h-0{min-height:0}.rf-min-h-\\[200px\\]{min-height:200px}.rf-min-h-\\[620px\\]{min-height:620px}.rf-min-h-\\[calc\\(100vh-240px\\)\\]{min-height:calc(100vh - 240px)}.\\!rf-w-2{width:.5rem!important}.\\!rf-w-2\\.5{width:.625rem!important}.rf-w-1{width:.25rem}.rf-w-1\\/2{width:50%}.rf-w-11{width:2.75rem}.rf-w-11\\/12{width:91.666667%}.rf-w-12{width:3rem}.rf-w-16{width:4rem}.rf-w-2{width:.5rem}.rf-w-2\\.5{width:.625rem}.rf-w-3{width:.75rem}.rf-w-3\\.5{width:.875rem}.rf-w-32{width:8rem}.rf-w-4{width:1rem}.rf-w-5{width:1.25rem}.rf-w-6{width:1.5rem}.rf-w-64{width:16rem}.rf-w-72{width:18rem}.rf-w-8{width:2rem}.rf-w-9{width:2.25rem}.rf-w-96{width:24rem}.rf-w-\\[95\\%\\]{width:95%}.rf-w-fit{width:-moz-fit-content;width:fit-content}.rf-w-full{width:100%}.rf-min-w-10{min-width:2.5rem}.rf-min-w-16{min-width:4rem}.rf-min-w-\\[148px\\]{min-width:148px}.rf-min-w-\\[8rem\\]{min-width:8rem}.rf-min-w-\\[var\\(--radix-select-trigger-width\\)\\]{min-width:var(--radix-select-trigger-width)}.\\!rf-max-w-\\[60vw\\]{max-width:60vw!important}.\\!rf-max-w-\\[660px\\]{max-width:660px!important}.rf-max-w-2xl{max-width:42rem}.rf-max-w-3xl{max-width:48rem}.rf-max-w-5xl{max-width:64rem}.rf-max-w-full{max-width:100%}.rf-max-w-lg{max-width:32rem}.rf-max-w-md{max-width:28rem}.rf-max-w-xl{max-width:36rem}.rf-flex-1{flex:1 1 0%}.rf-flex-shrink-0,.rf-shrink-0{flex-shrink:0}.rf-flex-grow{flex-grow:1}.rf-table-auto{table-layout:auto}.-rf-translate-x-1{--tw-translate-x:-0.25rem}.-rf-translate-x-1,.-rf-translate-x-1\\/2{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.-rf-translate-x-1\\/2{--tw-translate-x:-50%}.-rf-translate-y-1{--tw-translate-y:-0.25rem}.-rf-translate-y-1,.rf--translate-x-1{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.rf--translate-x-1{--tw-translate-x:-0.25rem}.rf-translate-x-\\[-50\\%\\]{--tw-translate-x:-50%}.rf-translate-x-\\[-50\\%\\],.rf-translate-y-\\[-50\\%\\]{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.rf-translate-y-\\[-50\\%\\]{--tw-translate-y:-50%}.rf-transform{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}@keyframes rf-pulse{50%{opacity:.5}}.rf-animate-pulse{animation:rf-pulse 2s cubic-bezier(.4,0,.6,1) infinite}@keyframes rf-spin{to{transform:rotate(1turn)}}.rf-animate-spin{animation:rf-spin 1s linear infinite}.rf-cursor-default{cursor:default}.rf-cursor-not-allowed{cursor:not-allowed}.rf-cursor-pointer{cursor:pointer}.rf-select-none{-webkit-user-select:none;-moz-user-select:none;user-select:none}.rf-grid-cols-1{grid-template-columns:repeat(1,minmax(0,1fr))}.rf-grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.rf-flex-row{flex-direction:row}.rf-flex-col{flex-direction:column}.rf-flex-col-reverse{flex-direction:column-reverse}.rf-flex-wrap{flex-wrap:wrap}.rf-place-items-center{place-items:center}.rf-items-start{align-items:flex-start}.rf-items-end{align-items:flex-end}.rf-items-center{align-items:center}.rf-justify-end{justify-content:flex-end}.rf-justify-center{justify-content:center}.rf-justify-between{justify-content:space-between}.rf-gap-0{gap:0}.rf-gap-1{gap:.25rem}.rf-gap-2{gap:.5rem}.rf-gap-3{gap:.75rem}.rf-gap-4{gap:1rem}.rf-gap-5{gap:1.25rem}.rf-gap-6{gap:1.5rem}.rf-gap-8{gap:2rem}.rf-space-x-2>:not([hidden])~:not([hidden]){--tw-space-x-reverse:0;margin-left:calc(.5rem*(1 - var(--tw-space-x-reverse)));margin-right:calc(.5rem*var(--tw-space-x-reverse))}.rf-space-y-2>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-bottom:calc(.5rem*var(--tw-space-y-reverse));margin-top:calc(.5rem*(1 - var(--tw-space-y-reverse)))}.rf-space-y-4>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-bottom:calc(1rem*var(--tw-space-y-reverse));margin-top:calc(1rem*(1 - var(--tw-space-y-reverse)))}.rf-space-y-6>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-bottom:calc(1.5rem*var(--tw-space-y-reverse));margin-top:calc(1.5rem*(1 - var(--tw-space-y-reverse)))}.rf-divide-y>:not([hidden])~:not([hidden]){--tw-divide-y-reverse:0;border-bottom-width:calc(1px*var(--tw-divide-y-reverse));border-top-width:calc(1px*(1 - var(--tw-divide-y-reverse)))}.rf-overflow-auto{overflow:auto}.rf-overflow-hidden{overflow:hidden}.rf-overflow-visible{overflow:visible}.rf-overflow-x-auto{overflow-x:auto}.\\!rf-overflow-y-auto{overflow-y:auto!important}.rf-overflow-y-auto{overflow-y:auto}.\\!rf-overflow-x-hidden{overflow-x:hidden!important}.rf-overflow-x-hidden{overflow-x:hidden}.rf-overflow-x-clip{overflow-x:clip}.rf-truncate{overflow:hidden;text-overflow:ellipsis}.rf-truncate,.rf-whitespace-nowrap{white-space:nowrap}.rf-whitespace-pre-wrap{white-space:pre-wrap}.rf-break-words{overflow-wrap:break-word}.rf-rounded{border-radius:.25rem}.rf-rounded-2xl{border-radius:1rem}.rf-rounded-full{border-radius:9999px}.rf-rounded-lg{border-radius:var(--radius)}.rf-rounded-md{border-radius:calc(var(--radius) - 2px)}.rf-rounded-sm{border-radius:calc(var(--radius) - 4px)}.rf-rounded-xl{border-radius:.75rem}.rf-border{border-width:1px}.rf-border-b{border-bottom-width:1px}.rf-border-t{border-top-width:1px}.rf-border-blue-200{--tw-border-opacity:1;border-color:rgb(191 219 254/var(--tw-border-opacity,1))}.rf-border-blue-500{--tw-border-opacity:1;border-color:rgb(59 130 246/var(--tw-border-opacity,1))}.rf-border-blue-600{--tw-border-opacity:1;border-color:rgb(37 99 235/var(--tw-border-opacity,1))}.rf-border-gray-200{--tw-border-opacity:1;border-color:rgb(229 231 235/var(--tw-border-opacity,1))}.rf-border-gray-300{--tw-border-opacity:1;border-color:rgb(209 213 219/var(--tw-border-opacity,1))}.rf-border-green-200{--tw-border-opacity:1;border-color:rgb(187 247 208/var(--tw-border-opacity,1))}.rf-border-input{border-color:hsl(var(--input))}.rf-border-neutral-200{--tw-border-opacity:1;border-color:rgb(229 229 229/var(--tw-border-opacity,1))}.rf-border-primary{border-color:hsl(var(--primary))}.rf-border-red-200{--tw-border-opacity:1;border-color:rgb(254 202 202/var(--tw-border-opacity,1))}.rf-border-red-500{--tw-border-opacity:1;border-color:rgb(239 68 68/var(--tw-border-opacity,1))}.rf-border-zinc-200{--tw-border-opacity:1;border-color:rgb(228 228 231/var(--tw-border-opacity,1))}.rf-border-zinc-900{--tw-border-opacity:1;border-color:rgb(24 24 27/var(--tw-border-opacity,1))}.rf-bg-background{background-color:hsl(var(--background))}.rf-bg-black{--tw-bg-opacity:1;background-color:rgb(0 0 0/var(--tw-bg-opacity,1))}.rf-bg-black\\/80{background-color:rgba(0,0,0,.8)}.rf-bg-blue-100{--tw-bg-opacity:1;background-color:rgb(219 234 254/var(--tw-bg-opacity,1))}.rf-bg-blue-50{--tw-bg-opacity:1;background-color:rgb(239 246 255/var(--tw-bg-opacity,1))}.rf-bg-blue-500{--tw-bg-opacity:1;background-color:rgb(59 130 246/var(--tw-bg-opacity,1))}.rf-bg-blue-600{--tw-bg-opacity:1;background-color:rgb(37 99 235/var(--tw-bg-opacity,1))}.rf-bg-gray-100{--tw-bg-opacity:1;background-color:rgb(243 244 246/var(--tw-bg-opacity,1))}.rf-bg-gray-200{--tw-bg-opacity:1;background-color:rgb(229 231 235/var(--tw-bg-opacity,1))}.rf-bg-gray-300{--tw-bg-opacity:1;background-color:rgb(209 213 219/var(--tw-bg-opacity,1))}.rf-bg-gray-400{--tw-bg-opacity:1;background-color:rgb(156 163 175/var(--tw-bg-opacity,1))}.rf-bg-gray-50{--tw-bg-opacity:1;background-color:rgb(249 250 251/var(--tw-bg-opacity,1))}.rf-bg-gray-500{--tw-bg-opacity:1;background-color:rgb(107 114 128/var(--tw-bg-opacity,1))}.rf-bg-gray-700{--tw-bg-opacity:1;background-color:rgb(55 65 81/var(--tw-bg-opacity,1))}.rf-bg-gray-800{--tw-bg-opacity:1;background-color:rgb(31 41 55/var(--tw-bg-opacity,1))}.rf-bg-gray-900{--tw-bg-opacity:1;background-color:rgb(17 24 39/var(--tw-bg-opacity,1))}.rf-bg-green-100{--tw-bg-opacity:1;background-color:rgb(220 252 231/var(--tw-bg-opacity,1))}.rf-bg-green-50{--tw-bg-opacity:1;background-color:rgb(240 253 244/var(--tw-bg-opacity,1))}.rf-bg-muted{background-color:hsl(var(--muted))}.rf-bg-neutral-100{--tw-bg-opacity:1;background-color:rgb(245 245 245/var(--tw-bg-opacity,1))}.rf-bg-neutral-50{--tw-bg-opacity:1;background-color:rgb(250 250 250/var(--tw-bg-opacity,1))}.rf-bg-neutral-800{--tw-bg-opacity:1;background-color:rgb(38 38 38/var(--tw-bg-opacity,1))}.rf-bg-neutral-900{--tw-bg-opacity:1;background-color:rgb(23 23 23/var(--tw-bg-opacity,1))}.rf-bg-orange-400{--tw-bg-opacity:1;background-color:rgb(251 146 60/var(--tw-bg-opacity,1))}.rf-bg-popover{background-color:hsl(var(--popover))}.rf-bg-red-100{--tw-bg-opacity:1;background-color:rgb(254 226 226/var(--tw-bg-opacity,1))}.rf-bg-red-50{--tw-bg-opacity:1;background-color:rgb(254 242 242/var(--tw-bg-opacity,1))}.rf-bg-red-500{--tw-bg-opacity:1;background-color:rgb(239 68 68/var(--tw-bg-opacity,1))}.rf-bg-red-900{--tw-bg-opacity:1;background-color:rgb(127 29 29/var(--tw-bg-opacity,1))}.rf-bg-white{--tw-bg-opacity:1;background-color:rgb(255 255 255/var(--tw-bg-opacity,1))}.rf-bg-yellow-100{--tw-bg-opacity:1;background-color:rgb(254 249 195/var(--tw-bg-opacity,1))}.rf-bg-zinc-100{--tw-bg-opacity:1;background-color:rgb(244 244 245/var(--tw-bg-opacity,1))}.rf-bg-zinc-200{--tw-bg-opacity:1;background-color:rgb(228 228 231/var(--tw-bg-opacity,1))}.rf-bg-zinc-50{--tw-bg-opacity:1;background-color:rgb(250 250 250/var(--tw-bg-opacity,1))}.rf-bg-zinc-800{--tw-bg-opacity:1;background-color:rgb(39 39 42/var(--tw-bg-opacity,1))}.rf-bg-zinc-900{--tw-bg-opacity:1;background-color:rgb(24 24 27/var(--tw-bg-opacity,1))}.rf-bg-opacity-50{--tw-bg-opacity:0.5}.rf-fill-current{fill:currentColor}.rf-object-contain{-o-object-fit:contain;object-fit:contain}.\\!rf-p-0{padding:0!important}.rf-p-0{padding:0}.rf-p-1{padding:.25rem}.rf-p-2{padding:.5rem}.rf-p-3{padding:.75rem}.rf-p-4{padding:1rem}.rf-p-5{padding:1.25rem}.rf-p-6{padding:1.5rem}.rf-p-8{padding:2rem}.rf-px-1{padding-left:.25rem;padding-right:.25rem}.rf-px-2{padding-left:.5rem;padding-right:.5rem}.rf-px-3{padding-left:.75rem;padding-right:.75rem}.rf-px-4{padding-left:1rem;padding-right:1rem}.rf-px-6{padding-left:1.5rem;padding-right:1.5rem}.rf-px-8{padding-left:2rem;padding-right:2rem}.rf-py-0{padding-bottom:0;padding-top:0}.rf-py-0\\.5{padding-bottom:.125rem;padding-top:.125rem}.rf-py-1{padding-bottom:.25rem;padding-top:.25rem}.rf-py-1\\.5{padding-bottom:.375rem;padding-top:.375rem}.rf-py-10{padding-bottom:2.5rem;padding-top:2.5rem}.rf-py-12{padding-bottom:3rem;padding-top:3rem}.rf-py-2{padding-bottom:.5rem;padding-top:.5rem}.rf-py-3{padding-bottom:.75rem;padding-top:.75rem}.rf-py-4{padding-bottom:1rem;padding-top:1rem}.rf-py-8{padding-bottom:2rem;padding-top:2rem}.rf-pb-0{padding-bottom:0}.rf-pb-2{padding-bottom:.5rem}.rf-pb-3{padding-bottom:.75rem}.rf-pb-4{padding-bottom:1rem}.rf-pl-2{padding-left:.5rem}.rf-pl-4{padding-left:1rem}.rf-pl-8{padding-left:2rem}.rf-pr-2{padding-right:.5rem}.rf-pt-2{padding-top:.5rem}.rf-pt-4{padding-top:1rem}.rf-text-left{text-align:left}.rf-text-center{text-align:center}.rf-text-right{text-align:right}.rf-font-mono{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace}.rf-text-2xl{font-size:1.5rem;line-height:2rem}.rf-text-3xl{font-size:1.875rem;line-height:2.25rem}.rf-text-\\[8px\\]{font-size:8px}.rf-text-base{font-size:1rem;line-height:1.5rem}.rf-text-lg{font-size:1.125rem;line-height:1.75rem}.rf-text-sm{font-size:.875rem;line-height:1.25rem}.rf-text-xl{font-size:1.25rem;line-height:1.75rem}.rf-text-xs{font-size:.75rem;line-height:1rem}.rf-font-bold{font-weight:700}.rf-font-medium{font-weight:500}.rf-font-semibold{font-weight:600}.rf-capitalize{text-transform:capitalize}.rf-tabular-nums{--tw-numeric-spacing:tabular-nums;font-variant-numeric:var(--tw-ordinal) var(--tw-slashed-zero) var(--tw-numeric-figure) var(--tw-numeric-spacing) var(--tw-numeric-fraction)}.rf-leading-5{line-height:1.25rem}.rf-leading-none{line-height:1}.rf-leading-tight{line-height:1.25}.rf-tracking-widest{letter-spacing:.1em}.rf-text-black{--tw-text-opacity:1;color:rgb(0 0 0/var(--tw-text-opacity,1))}.rf-text-blue-500{--tw-text-opacity:1;color:rgb(59 130 246/var(--tw-text-opacity,1))}.rf-text-blue-600{--tw-text-opacity:1;color:rgb(37 99 235/var(--tw-text-opacity,1))}.rf-text-blue-700{--tw-text-opacity:1;color:rgb(29 78 216/var(--tw-text-opacity,1))}.rf-text-blue-800{--tw-text-opacity:1;color:rgb(30 64 175/var(--tw-text-opacity,1))}.rf-text-blue-900{--tw-text-opacity:1;color:rgb(30 58 138/var(--tw-text-opacity,1))}.rf-text-current{color:currentColor}.rf-text-gray-400{--tw-text-opacity:1;color:rgb(156 163 175/var(--tw-text-opacity,1))}.rf-text-gray-500{--tw-text-opacity:1;color:rgb(107 114 128/var(--tw-text-opacity,1))}.rf-text-gray-600{--tw-text-opacity:1;color:rgb(75 85 99/var(--tw-text-opacity,1))}.rf-text-gray-700{--tw-text-opacity:1;color:rgb(55 65 81/var(--tw-text-opacity,1))}.rf-text-gray-800{--tw-text-opacity:1;color:rgb(31 41 55/var(--tw-text-opacity,1))}.rf-text-gray-900{--tw-text-opacity:1;color:rgb(17 24 39/var(--tw-text-opacity,1))}.rf-text-green-500{--tw-text-opacity:1;color:rgb(34 197 94/var(--tw-text-opacity,1))}.rf-text-green-600{--tw-text-opacity:1;color:rgb(22 163 74/var(--tw-text-opacity,1))}.rf-text-green-700{--tw-text-opacity:1;color:rgb(21 128 61/var(--tw-text-opacity,1))}.rf-text-green-800{--tw-text-opacity:1;color:rgb(22 101 52/var(--tw-text-opacity,1))}.rf-text-green-900{--tw-text-opacity:1;color:rgb(20 83 45/var(--tw-text-opacity,1))}.rf-text-muted-foreground{color:hsl(var(--muted-foreground))}.rf-text-neutral-50{--tw-text-opacity:1;color:rgb(250 250 250/var(--tw-text-opacity,1))}.rf-text-neutral-500{--tw-text-opacity:1;color:rgb(115 115 115/var(--tw-text-opacity,1))}.rf-text-neutral-900{--tw-text-opacity:1;color:rgb(23 23 23/var(--tw-text-opacity,1))}.rf-text-neutral-950{--tw-text-opacity:1;color:rgb(10 10 10/var(--tw-text-opacity,1))}.rf-text-popover-foreground{color:hsl(var(--popover-foreground))}.rf-text-red-200{--tw-text-opacity:1;color:rgb(254 202 202/var(--tw-text-opacity,1))}.rf-text-red-300{--tw-text-opacity:1;color:rgb(252 165 165/var(--tw-text-opacity,1))}.rf-text-red-400{--tw-text-opacity:1;color:rgb(248 113 113/var(--tw-text-opacity,1))}.rf-text-red-500{--tw-text-opacity:1;color:rgb(239 68 68/var(--tw-text-opacity,1))}.rf-text-red-600{--tw-text-opacity:1;color:rgb(220 38 38/var(--tw-text-opacity,1))}.rf-text-red-700{--tw-text-opacity:1;color:rgb(185 28 28/var(--tw-text-opacity,1))}.rf-text-red-800{--tw-text-opacity:1;color:rgb(153 27 27/var(--tw-text-opacity,1))}.rf-text-red-900{--tw-text-opacity:1;color:rgb(127 29 29/var(--tw-text-opacity,1))}.rf-text-white{--tw-text-opacity:1;color:rgb(255 255 255/var(--tw-text-opacity,1))}.rf-text-yellow-400{--tw-text-opacity:1;color:rgb(250 204 21/var(--tw-text-opacity,1))}.rf-text-yellow-500{--tw-text-opacity:1;color:rgb(234 179 8/var(--tw-text-opacity,1))}.rf-text-yellow-900{--tw-text-opacity:1;color:rgb(113 63 18/var(--tw-text-opacity,1))}.rf-text-zinc-200{--tw-text-opacity:1;color:rgb(228 228 231/var(--tw-text-opacity,1))}.rf-text-zinc-300{--tw-text-opacity:1;color:rgb(212 212 216/var(--tw-text-opacity,1))}.rf-text-zinc-400{--tw-text-opacity:1;color:rgb(161 161 170/var(--tw-text-opacity,1))}.rf-text-zinc-50{--tw-text-opacity:1;color:rgb(250 250 250/var(--tw-text-opacity,1))}.rf-text-zinc-500{--tw-text-opacity:1;color:rgb(113 113 122/var(--tw-text-opacity,1))}.rf-text-zinc-900{--tw-text-opacity:1;color:rgb(24 24 27/var(--tw-text-opacity,1))}.rf-text-zinc-950{--tw-text-opacity:1;color:rgb(9 9 11/var(--tw-text-opacity,1))}.rf-underline{text-decoration-line:underline}.rf-line-through{text-decoration-line:line-through}.rf-underline-offset-4{text-underline-offset:4px}.rf-opacity-0{opacity:0}.rf-opacity-25{opacity:.25}.rf-opacity-30{opacity:.3}.rf-opacity-50{opacity:.5}.rf-opacity-60{opacity:.6}.rf-opacity-75{opacity:.75}.rf-shadow{--tw-shadow:0 1px 3px 0 rgba(0,0,0,.1),0 1px 2px -1px rgba(0,0,0,.1);--tw-shadow-colored:0 1px 3px 0 var(--tw-shadow-color),0 1px 2px -1px var(--tw-shadow-color)}.rf-shadow,.rf-shadow-lg{box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}.rf-shadow-lg{--tw-shadow:0 10px 15px -3px rgba(0,0,0,.1),0 4px 6px -4px rgba(0,0,0,.1);--tw-shadow-colored:0 10px 15px -3px var(--tw-shadow-color),0 4px 6px -4px var(--tw-shadow-color)}.rf-shadow-md{--tw-shadow:0 4px 6px -1px rgba(0,0,0,.1),0 2px 4px -2px rgba(0,0,0,.1);--tw-shadow-colored:0 4px 6px -1px var(--tw-shadow-color),0 2px 4px -2px var(--tw-shadow-color)}.rf-shadow-md,.rf-shadow-sm{box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}.rf-shadow-sm{--tw-shadow:0 1px 2px 0 rgba(0,0,0,.05);--tw-shadow-colored:0 1px 2px 0 var(--tw-shadow-color)}.rf-outline-none{outline:2px solid transparent;outline-offset:2px}.rf-ring-2{--tw-ring-offset-shadow:var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow:var(--tw-ring-inset) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow,0 0 #0000)}.rf-ring-blue-500{--tw-ring-opacity:1;--tw-ring-color:rgb(59 130 246/var(--tw-ring-opacity,1))}.rf-ring-primary{--tw-ring-color:hsl(var(--primary))}.rf-ring-offset-background{--tw-ring-offset-color:hsl(var(--background))}.rf-ring-offset-white{--tw-ring-offset-color:#fff}.rf-transition{transition-duration:.15s;transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,-webkit-backdrop-filter;transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,backdrop-filter;transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,backdrop-filter,-webkit-backdrop-filter;transition-timing-function:cubic-bezier(.4,0,.2,1)}.rf-transition-all{transition-duration:.15s;transition-property:all;transition-timing-function:cubic-bezier(.4,0,.2,1)}.rf-transition-colors{transition-duration:.15s;transition-property:color,background-color,border-color,text-decoration-color,fill,stroke;transition-timing-function:cubic-bezier(.4,0,.2,1)}.rf-transition-opacity{transition-duration:.15s;transition-property:opacity;transition-timing-function:cubic-bezier(.4,0,.2,1)}.rf-duration-200{transition-duration:.2s}.rf-ease-in-out{transition-timing-function:cubic-bezier(.4,0,.2,1)}@keyframes enter{0%{opacity:var(--tw-enter-opacity,1);transform:translate3d(var(--tw-enter-translate-x,0),var(--tw-enter-translate-y,0),0) scale3d(var(--tw-enter-scale,1),var(--tw-enter-scale,1),var(--tw-enter-scale,1)) rotate(var(--tw-enter-rotate,0))}}@keyframes exit{to{opacity:var(--tw-exit-opacity,1);transform:translate3d(var(--tw-exit-translate-x,0),var(--tw-exit-translate-y,0),0) scale3d(var(--tw-exit-scale,1),var(--tw-exit-scale,1),var(--tw-exit-scale,1)) rotate(var(--tw-exit-rotate,0))}}.rf-slide-in-from-left-1{--tw-enter-translate-x:-0.25rem}.rf-slide-out-to-left-1{--tw-exit-translate-x:-0.25rem}.rf-duration-200{animation-duration:.2s}.rf-ease-in-out{animation-timing-function:cubic-bezier(.4,0,.2,1)}.file\\:rf-border-0::file-selector-button{border-width:0}.file\\:rf-bg-transparent::file-selector-button{background-color:transparent}.file\\:rf-text-sm::file-selector-button{font-size:.875rem;line-height:1.25rem}.file\\:rf-font-medium::file-selector-button{font-weight:500}.placeholder\\:rf-text-zinc-500::-moz-placeholder{--tw-text-opacity:1;color:rgb(113 113 122/var(--tw-text-opacity,1))}.placeholder\\:rf-text-zinc-500::placeholder{--tw-text-opacity:1;color:rgb(113 113 122/var(--tw-text-opacity,1))}.hover\\:rf-border-blue-300:hover{--tw-border-opacity:1;border-color:rgb(147 197 253/var(--tw-border-opacity,1))}.hover\\:\\!rf-bg-transparent:hover{background-color:transparent!important}.hover\\:rf-bg-blue-700:hover{--tw-bg-opacity:1;background-color:rgb(29 78 216/var(--tw-bg-opacity,1))}.hover\\:rf-bg-red-500\\/90:hover{background-color:rgba(239,68,68,.9)}.hover\\:rf-bg-zinc-100:hover{--tw-bg-opacity:1;background-color:rgb(244 244 245/var(--tw-bg-opacity,1))}.hover\\:rf-bg-zinc-100\\/80:hover{background-color:hsla(240,5%,96%,.8)}.hover\\:rf-bg-zinc-900\\/90:hover{background-color:rgba(24,24,27,.9)}.hover\\:rf-text-red-400:hover{--tw-text-opacity:1;color:rgb(248 113 113/var(--tw-text-opacity,1))}.hover\\:rf-text-zinc-900:hover{--tw-text-opacity:1;color:rgb(24 24 27/var(--tw-text-opacity,1))}.hover\\:rf-underline:hover{text-decoration-line:underline}.focus\\:rf-bg-gray-100:focus{--tw-bg-opacity:1;background-color:rgb(243 244 246/var(--tw-bg-opacity,1))}.focus\\:rf-bg-zinc-100:focus{--tw-bg-opacity:1;background-color:rgb(244 244 245/var(--tw-bg-opacity,1))}.focus\\:rf-text-gray-900:focus{--tw-text-opacity:1;color:rgb(17 24 39/var(--tw-text-opacity,1))}.focus\\:rf-text-zinc-900:focus{--tw-text-opacity:1;color:rgb(24 24 27/var(--tw-text-opacity,1))}.focus\\:rf-outline-none:focus{outline:2px solid transparent;outline-offset:2px}.focus\\:rf-ring-2:focus{--tw-ring-offset-shadow:var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow:var(--tw-ring-inset) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow,0 0 #0000)}.focus\\:rf-ring-ring:focus{--tw-ring-color:hsl(var(--ring))}.focus\\:rf-ring-offset-2:focus{--tw-ring-offset-width:2px}.focus-visible\\:rf-outline-none:focus-visible{outline:2px solid transparent;outline-offset:2px}.focus-visible\\:rf-ring-1:focus-visible{--tw-ring-offset-shadow:var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow:var(--tw-ring-inset) 0 0 0 calc(1px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow,0 0 #0000)}.focus-visible\\:rf-ring-2:focus-visible{--tw-ring-offset-shadow:var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow:var(--tw-ring-inset) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow,0 0 #0000)}.focus-visible\\:rf-ring-zinc-950:focus-visible{--tw-ring-opacity:1;--tw-ring-color:rgb(9 9 11/var(--tw-ring-opacity,1))}.focus-visible\\:rf-ring-offset-2:focus-visible{--tw-ring-offset-width:2px}.disabled\\:rf-pointer-events-none:disabled{pointer-events:none}.disabled\\:rf-cursor-not-allowed:disabled{cursor:not-allowed}.disabled\\:rf-opacity-50:disabled{opacity:.5}.rf-group\\/bar:hover .group-hover\\/bar\\:rf-opacity-100{opacity:1}.data-\\[disabled\\]\\:rf-pointer-events-none[data-disabled]{pointer-events:none}.data-\\[side\\=bottom\\]\\:rf-translate-y-1[data-side=bottom]{--tw-translate-y:0.25rem}.data-\\[side\\=bottom\\]\\:rf-translate-y-1[data-side=bottom],.data-\\[side\\=left\\]\\:-rf-translate-x-1[data-side=left]{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.data-\\[side\\=left\\]\\:-rf-translate-x-1[data-side=left]{--tw-translate-x:-0.25rem}.data-\\[side\\=right\\]\\:rf-translate-x-1[data-side=right]{--tw-translate-x:0.25rem}.data-\\[side\\=right\\]\\:rf-translate-x-1[data-side=right],.data-\\[side\\=top\\]\\:-rf-translate-y-1[data-side=top]{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.data-\\[side\\=top\\]\\:-rf-translate-y-1[data-side=top]{--tw-translate-y:-0.25rem}.data-\\[state\\=active\\]\\:rf-bg-white[data-state=active]{--tw-bg-opacity:1;background-color:rgb(255 255 255/var(--tw-bg-opacity,1))}.data-\\[state\\=checked\\]\\:rf-bg-zinc-900[data-state=checked]{--tw-bg-opacity:1;background-color:rgb(24 24 27/var(--tw-bg-opacity,1))}.data-\\[state\\=open\\]\\:rf-bg-zinc-100[data-state=open]{--tw-bg-opacity:1;background-color:rgb(244 244 245/var(--tw-bg-opacity,1))}.data-\\[state\\=active\\]\\:rf-text-zinc-950[data-state=active]{--tw-text-opacity:1;color:rgb(9 9 11/var(--tw-text-opacity,1))}.data-\\[state\\=checked\\]\\:rf-text-zinc-50[data-state=checked]{--tw-text-opacity:1;color:rgb(250 250 250/var(--tw-text-opacity,1))}.data-\\[disabled\\]\\:rf-opacity-50[data-disabled]{opacity:.5}.data-\\[state\\=active\\]\\:rf-shadow[data-state=active]{--tw-shadow:0 1px 3px 0 rgba(0,0,0,.1),0 1px 2px -1px rgba(0,0,0,.1);--tw-shadow-colored:0 1px 3px 0 var(--tw-shadow-color),0 1px 2px -1px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}.data-\\[state\\=open\\]\\:rf-animate-in[data-state=open]{animation-duration:.15s;animation-name:enter;--tw-enter-opacity:initial;--tw-enter-scale:initial;--tw-enter-rotate:initial;--tw-enter-translate-x:initial;--tw-enter-translate-y:initial}.data-\\[state\\=closed\\]\\:rf-animate-out[data-state=closed]{animation-duration:.15s;animation-name:exit;--tw-exit-opacity:initial;--tw-exit-scale:initial;--tw-exit-rotate:initial;--tw-exit-translate-x:initial;--tw-exit-translate-y:initial}.data-\\[state\\=closed\\]\\:rf-fade-out-0[data-state=closed]{--tw-exit-opacity:0}.data-\\[state\\=open\\]\\:rf-fade-in-0[data-state=open]{--tw-enter-opacity:0}.data-\\[state\\=closed\\]\\:rf-zoom-out-95[data-state=closed]{--tw-exit-scale:.95}.data-\\[state\\=open\\]\\:rf-zoom-in-95[data-state=open]{--tw-enter-scale:.95}.data-\\[side\\=bottom\\]\\:rf-slide-in-from-top-2[data-side=bottom]{--tw-enter-translate-y:-0.5rem}.data-\\[side\\=left\\]\\:rf-slide-in-from-right-2[data-side=left]{--tw-enter-translate-x:0.5rem}.data-\\[side\\=right\\]\\:rf-slide-in-from-left-2[data-side=right]{--tw-enter-translate-x:-0.5rem}.data-\\[side\\=top\\]\\:rf-slide-in-from-bottom-2[data-side=top]{--tw-enter-translate-y:0.5rem}.data-\\[state\\=closed\\]\\:rf-slide-out-to-left-1\\/2[data-state=closed]{--tw-exit-translate-x:-50%}.data-\\[state\\=closed\\]\\:rf-slide-out-to-top-\\[48\\%\\][data-state=closed]{--tw-exit-translate-y:-48%}.data-\\[state\\=open\\]\\:rf-slide-in-from-left-1\\/2[data-state=open]{--tw-enter-translate-x:-50%}.data-\\[state\\=open\\]\\:rf-slide-in-from-top-\\[48\\%\\][data-state=open]{--tw-enter-translate-y:-48%}.dark\\:rf-border-zinc-50:is(.rf-dark *){--tw-border-opacity:1;border-color:rgb(250 250 250/var(--tw-border-opacity,1))}.dark\\:rf-border-zinc-800:is(.rf-dark *){--tw-border-opacity:1;border-color:rgb(39 39 42/var(--tw-border-opacity,1))}.dark\\:rf-bg-red-900:is(.rf-dark *){--tw-bg-opacity:1;background-color:rgb(127 29 29/var(--tw-bg-opacity,1))}.dark\\:rf-bg-zinc-50:is(.rf-dark *){--tw-bg-opacity:1;background-color:rgb(250 250 250/var(--tw-bg-opacity,1))}.dark\\:rf-bg-zinc-800:is(.rf-dark *){--tw-bg-opacity:1;background-color:rgb(39 39 42/var(--tw-bg-opacity,1))}.dark\\:rf-bg-zinc-950:is(.rf-dark *){--tw-bg-opacity:1;background-color:rgb(9 9 11/var(--tw-bg-opacity,1))}.dark\\:rf-text-zinc-400:is(.rf-dark *){--tw-text-opacity:1;color:rgb(161 161 170/var(--tw-text-opacity,1))}.dark\\:rf-text-zinc-50:is(.rf-dark *){--tw-text-opacity:1;color:rgb(250 250 250/var(--tw-text-opacity,1))}.dark\\:rf-text-zinc-900:is(.rf-dark *){--tw-text-opacity:1;color:rgb(24 24 27/var(--tw-text-opacity,1))}.dark\\:rf-placeholder-zinc-400:is(.rf-dark *)::-moz-placeholder{--tw-placeholder-opacity:1;color:rgb(161 161 170/var(--tw-placeholder-opacity,1))}.dark\\:rf-placeholder-zinc-400:is(.rf-dark *)::placeholder{--tw-placeholder-opacity:1;color:rgb(161 161 170/var(--tw-placeholder-opacity,1))}.dark\\:rf-ring-offset-zinc-950:is(.rf-dark *){--tw-ring-offset-color:#09090b}.dark\\:hover\\:rf-bg-red-900\\/90:hover:is(.rf-dark *){background-color:rgba(127,29,29,.9)}.dark\\:hover\\:rf-bg-zinc-50\\/90:hover:is(.rf-dark *){background-color:hsla(0,0%,98%,.9)}.dark\\:hover\\:rf-bg-zinc-800:hover:is(.rf-dark *){--tw-bg-opacity:1;background-color:rgb(39 39 42/var(--tw-bg-opacity,1))}.dark\\:hover\\:rf-bg-zinc-800\\/80:hover:is(.rf-dark *){background-color:rgba(39,39,42,.8)}.dark\\:hover\\:rf-text-zinc-50:hover:is(.rf-dark *){--tw-text-opacity:1;color:rgb(250 250 250/var(--tw-text-opacity,1))}.dark\\:focus\\:rf-bg-zinc-800:focus:is(.rf-dark *){--tw-bg-opacity:1;background-color:rgb(39 39 42/var(--tw-bg-opacity,1))}.dark\\:focus\\:rf-text-zinc-50:focus:is(.rf-dark *){--tw-text-opacity:1;color:rgb(250 250 250/var(--tw-text-opacity,1))}.dark\\:focus-visible\\:rf-ring-zinc-300:focus-visible:is(.rf-dark *){--tw-ring-opacity:1;--tw-ring-color:rgb(212 212 216/var(--tw-ring-opacity,1))}.dark\\:data-\\[state\\=active\\]\\:rf-bg-zinc-950[data-state=active]:is(.rf-dark *){--tw-bg-opacity:1;background-color:rgb(9 9 11/var(--tw-bg-opacity,1))}.dark\\:data-\\[state\\=checked\\]\\:rf-bg-zinc-50[data-state=checked]:is(.rf-dark *){--tw-bg-opacity:1;background-color:rgb(250 250 250/var(--tw-bg-opacity,1))}.dark\\:data-\\[state\\=open\\]\\:rf-bg-zinc-800[data-state=open]:is(.rf-dark *){--tw-bg-opacity:1;background-color:rgb(39 39 42/var(--tw-bg-opacity,1))}.dark\\:data-\\[state\\=active\\]\\:rf-text-zinc-50[data-state=active]:is(.rf-dark *){--tw-text-opacity:1;color:rgb(250 250 250/var(--tw-text-opacity,1))}.dark\\:data-\\[state\\=checked\\]\\:rf-text-zinc-900[data-state=checked]:is(.rf-dark *){--tw-text-opacity:1;color:rgb(24 24 27/var(--tw-text-opacity,1))}@media (min-width:640px){.sm\\:rf-mt-0{margin-top:0}.sm\\:rf-flex-row{flex-direction:row}.sm\\:rf-justify-end{justify-content:flex-end}.sm\\:rf-space-x-2>:not([hidden])~:not([hidden]){--tw-space-x-reverse:0;margin-left:calc(.5rem*(1 - var(--tw-space-x-reverse)));margin-right:calc(.5rem*var(--tw-space-x-reverse))}.sm\\:rf-rounded-lg{border-radius:var(--radius)}.sm\\:rf-text-left{text-align:left}}@media (min-width:768px){.md\\:rf-grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}}.\\[\\&\\>span\\]\\:rf-line-clamp-1>span{display:-webkit-box;overflow:hidden;-webkit-box-orient:vertical;-webkit-line-clamp:1}.\\[\\&\\>svg\\]\\:rf-size-4>svg{height:1rem;width:1rem}.\\[\\&\\>svg\\]\\:rf-shrink-0>svg{flex-shrink:0}.\\[\\&\\>svg\\]\\:rf-text-red-300>svg{--tw-text-opacity:1;color:rgb(252 165 165/var(--tw-text-opacity,1))}.\\[\\&\\>svg\\]\\:hover\\:rf-text-red-400:hover>svg{--tw-text-opacity:1;color:rgb(248 113 113/var(--tw-text-opacity,1))}.\\[\\&_svg\\]\\:rf-pointer-events-none svg{pointer-events:none}.\\[\\&_svg\\]\\:rf-size-4 svg{height:1rem;width:1rem}.\\[\\&_svg\\]\\:rf-shrink-0 svg{flex-shrink:0}',T_n=()=>{rt.useEffect(()=>{if(document.querySelector('style[data-styles="tscircuit-runframe"]'))return;const e=document.createElement("style");e.setAttribute("data-styles","tscircuit-runframe"),e.textContent=E_n,document.head.appendChild(e)},[])},WQe=n=>`hsl(${qb.indexOf(n)*137.5%360}, 70%, 50%)`,M_n=({phaseTimings:n})=>{if(!n)return null;const e=Object.values(n).reduce((t,r)=>t+r,0);return Ge.jsxs("div",{className:"rf-space-y-2 rf-w-full rf-px-4",children:[Ge.jsx("div",{className:"rf-relative rf-h-8 rf-flex rf-rounded-sm",children:qb.map(t=>{const r=n[t]||0,i=r/e*100;return Ge.jsx("div",{className:"rf-group/bar rf-relative rf-overflow-visible",style:{width:`${i}%`,backgroundColor:WQe(t)},children:Ge.jsxs("div",{className:"rf-opacity-0 group-hover/bar:rf-opacity-100 rf-transition-opacity rf-absolute rf-bottom-full rf-left-1/2 rf-transform -rf-translate-x-1/2 rf-mb-2 rf-px-2 rf-py-1 rf-text-xs rf-whitespace-nowrap rf-rounded rf-bg-gray-900 rf-text-white rf-pointer-events-none",children:[t,": ",r.toFixed(1),"ms"]})},t)})}),Ge.jsxs("div",{className:"rf-text-xs rf-text-gray-500",children:["Total: ",e.toFixed(2),"ms"]})]})},C_n=({renderLog:n})=>{const[e,t]=rt.useState("chronological");if(!n)return Ge.jsx("div",{className:"rf-p-4 rf-bg-gray-100 rf-rounded-md",children:"No render log, make sure this tab is open when you render (TODO add a rerender button here)"});const r=Object.entries((n==null?void 0:n.phaseTimings)??{});e==="chronological"?r.sort((a,o)=>qb.indexOf(a[0])-qb.indexOf(o[0])):r.sort((a,o)=>o[1]-a[1]);const i=r.reduce((a,[o,s])=>a+s,0);return Ge.jsxs("div",{className:"rf-bg-white",children:[Ge.jsxs("div",{className:"rf-flex rf-justify-between rf-items-center",children:[Ge.jsx("div",{children:"Render Logs"}),Ge.jsxs("div",{className:"rf-mb-4 rf-pr-2 rf-flex rf-text-xs rf-items-center",children:[Ge.jsx("div",{className:"rf-mr-2",children:"Sort by:"}),Ge.jsxs("select",{value:e,onChange:a=>t(a.target.value),className:"rf-px-2 rf-py-1 rf-border rf-rounded rf-text-xs",children:[Ge.jsx("option",{value:"chronological",children:"Phase Order"}),Ge.jsx("option",{value:"longest",children:"Duration"})]})]})]}),Ge.jsx(M_n,{phaseTimings:n.phaseTimings}),Ge.jsxs("table",{className:"rf-w-full rf-text-xs",children:[Ge.jsx("thead",{children:Ge.jsxs("tr",{children:[Ge.jsx("th",{className:"rf-text-left rf-p-2",children:"Phase Order"}),Ge.jsx("th",{className:"rf-text-left rf-p-2",children:"Phase"}),Ge.jsx("th",{className:"rf-text-left rf-p-2",children:"Duration (ms)"})]})}),Ge.jsx("tbody",{children:r.map(([a,o])=>Ge.jsxs("tr",{children:[Ge.jsx("td",{className:"rf-p-2",children:qb.indexOf(a)}),Ge.jsx("td",{className:"rf-p-2",children:a}),Ge.jsx("td",{className:"rf-p-2",children:Ge.jsx("div",{className:"rf-w-8",children:Ge.jsx("div",{className:"rf-h-2 rf-rounded-sm",style:{backgroundColor:WQe(a),width:`${o/i*100}%`}})})}),Ge.jsx("td",{className:"rf-p-2",children:Ge.jsxs("div",{className:"rf-flex w-full",children:[Ge.jsxs("span",{className:"rf-flex-grow",children:[o,"ms"]}),Ge.jsxs("span",{className:"rf-text-gray-500 rf-pr-2",children:[(o/i*100).toFixed(1),"%"]})]})})]},a))})]})]})},R_n="0.0.438",A_n=["assembly","bom","circuit_json","errors","render_log"],P_n=({code:n,onRunClicked:e=void 0,errorMessage:t,circuitJson:r,autoroutingGraphics:i,showRightHeaderContent:a=!0,showCodeTab:o=!1,codeTabContent:s,showJsonTab:l=!0,showRenderLogTab:c=!0,onActiveTabChange:u,renderLog:d,showImportAndFormatButtons:f=!0,className:m,headerClassName:y,leftHeaderContent:E,readOnly:w,isStreaming:S,autoroutingLog:T,onReportAutoroutingLog:P,isRunningCode:U,hasCodeChangedSinceLastRun:H,onEditEvent:G,editEvents:W,defaultActiveTab:$,autoRotate3dViewerDisabled:Q,showSchematicDebugGrid:X=!1,showToggleFullScreen:ue=!0,defaultToFullScreen:pe=!1})=>{var Ne;T_n();const ce=rt.useMemo(()=>r?r.filter(ze=>ze&&"error_type"in ze):null,[r]),[Se,he]=rt.useState($??"pcb"),[ge,Te]=rt.useState(pe),xe=rt.useCallback(ze=>{he(ze),u==null||u(ze)},[u]),Ae=()=>{Te(!ge)};return rt.useEffect(()=>{t&&xe("errors")},[t]),rt.useEffect(()=>{(Se==="code"||Se==="errors")&&r&&!t&&xe($??"pcb")},[r]),Ge.jsx("div",{className:_h("flex flex-col relative rf-overflow-x-hidden",m),children:Ge.jsx("div",{className:_h("rf-md:sticky rf-md:top-2",ge&&"rf-fixed rf-top-0 rf-left-0 rf-w-full rf-bg-white"),children:Ge.jsxs(Z5e,{value:Se,onValueChange:xe,className:"rf-flex-grow rf-flex rf-flex-col",children:[Ge.jsxs("div",{className:_h("rf-flex rf-items-center rf-gap-2 rf-p-2 rf-pb-0",y),children:[E,E&&Ge.jsx("div",{className:"rf-flex-grow"}),!E&&U&&Ge.jsx(nM,{className:"rf-w-4 rf-h-4 rf-animate-spin"}),!E&&Ge.jsx("div",{className:"rf-flex-grow"}),d&&d.progress!==1&&Ge.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2",children:[d.lastRenderEvent&&Ge.jsx("div",{className:"rf-text-xs rf-text-gray-500",children:((Ne=d.lastRenderEvent)==null?void 0:Ne.phase)??""}),Ge.jsx("div",{className:"rf-w-4 rf-h-4 rf-bg-blue-500 rf-opacity-50 rf-rounded-full rf-text-white",children:Ge.jsx(nM,{className:"rf-w-4 rf-h-4 rf-animate-spin"})}),Ge.jsxs("div",{className:"rf-text-xs rf-font-bold rf-text-gray-700 rf-tabular-nums",children:[((d.progress??0)*100).toFixed(1),"%"]})]}),a&&Ge.jsxs(lY,{children:[o&&Ge.jsx(p6,{value:"code",children:"Code"}),Ge.jsxs(p6,{value:"pcb",className:"rf-whitespace-nowrap",children:[r&&Ge.jsx("span",{className:_h("rf-inline-flex rf-items-center rf-justify-center rf-w-2 rf-h-2 rf-mr-1 rf-text-xs rf-font-bold rf-text-white rf-rounded-full",H?"rf-bg-gray-500":"rf-bg-blue-500")}),"PCB"]}),Ge.jsxs(p6,{value:"schematic",className:"rf-whitespace-nowrap",children:[r&&Ge.jsx("span",{className:_h("rf-inline-flex rf-items-center rf-justify-center rf-w-2 rf-h-2 rf-mr-1 rf-text-xs rf-font-bold rf-text-white rf-rounded-full",H?"rf-bg-gray-500":"rf-bg-blue-500")}),"Schematic"]}),Ge.jsxs(p6,{value:"cad",children:[r&&Ge.jsx("span",{className:_h("inline-flex items-center justify-center w-2 h-2 mr-1 text-xs font-bold text-white rounded-full",H?"rf-bg-gray-500":"rf-bg-blue-500")}),"3D"]}),!["pcb","cad","schematic"].includes(Se)&&Ge.jsx(p6,{value:Se,children:W5e(Se)}),Ge.jsxs(sue,{children:[Ge.jsx(lue,{asChild:!0,children:Ge.jsxs("div",{className:"rf-whitespace-nowrap rf-p-2 rf-mr-1 rf-cursor-pointer rf-relative",children:[Ge.jsx(nnn,{className:"rf-w-4 rf-h-4"}),(ce&&ce.length>0||t)&&Ge.jsx("span",{className:"rf-inline-flex rf-absolute rf-top-[6px] rf-right-[4px] rf-items-center rf-justify-center rf-w-1 rf-h-1 rf-ml-2 rf-text-[8px] rf-font-bold rf-text-white rf-bg-red-500 rf-rounded-full"})]})}),Ge.jsxs(aB,{className:"rf-*:text-xs",children:[A_n.map(ze=>Ge.jsxs(R4,{onSelect:()=>xe(ze),children:[Se!==ze&&Ge.jsx(oHe,{className:"rf-w-3 rf-h-3 rf-opacity-30"}),Se===ze&&Ge.jsx(mce,{className:"rf-w-3 rf-h-3"}),Ge.jsx("div",{className:"rf-pr-2",children:W5e(ze)}),ze==="errors"&&(ce&&ce.length>0||t)&&Ge.jsx("span",{className:"rf-inline-flex rf-items-center rf-justify-center rf-w-3 rf-h-3 rf-ml-2 rf-text-[8px] rf-font-bold rf-text-white rf-bg-red-500 rf-rounded-full",children:t?1:ce==null?void 0:ce.length})]},ze)),Ge.jsx(R4,{disabled:!0,className:"rf-opacity-60 rf-cursor-default rf-select-none",children:Ge.jsxs("div",{className:"rf-pr-2 rf-text-xs rf-text-gray-500",children:["@tscircuit/runframe@",R_n.split(".").map((ze,Re)=>Re===2?parseInt(ze)+1:ze).join(".")]})})]})]})]}),ue&&Ge.jsx(lb,{onClick:Ae,variant:"ghost",children:ge?Ge.jsx(onn,{size:16}):Ge.jsx(inn,{size:16})})]}),o&&Ge.jsx(e8,{value:"code",className:"rf-flex-grow rf-overflow-hidden",children:Ge.jsx("div",{className:"rf-h-full",children:s})}),Ge.jsx(e8,{value:"pcb",children:Ge.jsx("div",{className:_h("rf-overflow-hidden",ge?"rf-h-[calc(100vh-52px)]":"rf-h-[620px]"),children:Ge.jsx(tM,{fallbackRender:({error:ze})=>Ge.jsx("div",{className:"rf-mt-4 rf-bg-red-50 rf-rounded-md rf-border rf-border-red-200",children:Ge.jsxs("div",{className:"rf-p-4",children:[Ge.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-red-800 rf-mb-3",children:"Error loading PCB viewer"}),Ge.jsx("p",{className:"rf-text-xs rf-font-mono rf-whitespace-pre-wrap rf-text-red-600 rf-mt-2",children:(ze==null?void 0:ze.message)||"An unknown error occurred"})]})}),children:r?Ge.jsx(w_n,{focusOnHover:!1,circuitJson:r,debugGraphics:i,containerClassName:_h("rf-h-full rf-w-full",ge?"rf-min-h-[calc(100vh-240px)]":"rf-min-h-[620px]"),onEditEventsChanged:ze=>{G&&ze.forEach(Re=>G(Re))}}):Ge.jsx(Uw,{onRunClicked:e})})})}),Ge.jsx(e8,{value:"assembly",children:Ge.jsx("div",{className:_h("rf-overflow-auto",ge?"rf-h-[calc(100vh-96px)]":"rf-h-[620px]"),children:Ge.jsx(tM,{fallback:Ge.jsx("div",{children:"Error loading Assembly"}),children:r?Ge.jsx(Msn,{circuitJson:r,containerStyle:{height:"100%"},editingEnabled:!0,debugGrid:!0}):Ge.jsx(Uw,{onRunClicked:e})})})}),Ge.jsx(e8,{value:"schematic",children:Ge.jsx("div",{className:_h("rf-overflow-auto rf-bg-white",ge?"rf-h-[calc(100vh-96px)]":"rf-h-[620px]"),children:Ge.jsx(tM,{fallbackRender:({error:ze})=>Ge.jsx("div",{className:"rf-mt-4 rf-bg-red-50 rf-rounded-md rf-border rf-border-red-200",children:Ge.jsxs("div",{className:"rf-p-4",children:[Ge.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-red-800 rf-mb-3",children:"Error loading Schematic"}),Ge.jsx("p",{className:"rf-text-xs rf-font-mono rf-whitespace-pre-wrap rf-text-red-600 rf-mt-2",children:(ze==null?void 0:ze.message)||"An unknown error occurred"})]})}),children:r?Ge.jsx(wsn,{circuitJson:r,containerStyle:{height:"100%"},editingEnabled:!0,onEditEvent:ze=>{G==null||G(ze)},debugGrid:X,colorOverrides:{schematic:{background:"transparent"}}}):Ge.jsx(Uw,{onRunClicked:e})})})}),Ge.jsx(e8,{value:"cad",children:Ge.jsx("div",{className:_h("rf-overflow-auto",ge?"rf-h-[calc(100vh-96px)]":"rf-h-[620px]"),children:Ge.jsx(tM,{FallbackComponent:Htn,children:r?Ge.jsx(Btn,{soup:r,autoRotateDisabled:Q}):Ge.jsx(Uw,{onRunClicked:e})})})}),Ge.jsx(e8,{value:"bom",children:Ge.jsx("div",{className:_h("rf-overflow-auto",ge?"rf-h-[calc(100vh-96px)]":"rf-h-[620px]"),children:Ge.jsx(tM,{fallbackRender:({error:ze})=>Ge.jsx("div",{className:"rf-mt-4 rf-bg-red-50 rf-rounded-md rf-border rf-border-red-200",children:Ge.jsxs("div",{className:"rf-p-4",children:[Ge.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-red-800 rf-mb-3",children:"Error loading Bill of Materials"}),Ge.jsx("p",{className:"rf-text-xs rf-font-mono rf-whitespace-pre-wrap rf-text-red-600 rf-mt-2",children:(ze==null?void 0:ze.message)||"An unknown error occurred"})]})}),children:r?Ge.jsx(Nsn,{circuitJson:r}):Ge.jsx(Uw,{onRunClicked:e})})})}),Ge.jsx(e8,{value:"circuit_json",children:Ge.jsx("div",{className:_h("rf-overflow-auto",ge?"rf-h-[calc(100vh-96px)]":"rf-h-[620px]"),children:Ge.jsx(tM,{fallback:Ge.jsx("div",{children:"Error loading JSON viewer"}),children:r?Ge.jsx(Asn,{elements:r}):Ge.jsx(Uw,{onRunClicked:e})})})}),Ge.jsx(e8,{value:"errors",children:Ge.jsx("div",{className:_h("rf-overflow-auto",ge?"rf-h-[calc(100vh-96px)]":"rf-h-[620px]"),children:Array.isArray(ce)&&ce.length>0||t?Ge.jsx(eon,{code:n,circuitJsonErrors:ce,errorMessage:t,autoroutingLog:T,onReportAutoroutingLog:P}):Ge.jsx(Uw,{onRunClicked:e})})}),c&&Ge.jsx(e8,{value:"render_log",children:Ge.jsx(C_n,{renderLog:d})})]})})})};var SH="Dialog",[ZQe,QQe]=eS(SH),[N_n,L4]=ZQe(SH),KQe=n=>{const{__scopeDialog:e,children:t,open:r,defaultOpen:i,onOpenChange:a,modal:o=!0}=n,s=rt.useRef(null),l=rt.useRef(null),[c,u]=kE({prop:r,defaultProp:i??!1,onChange:a,caller:SH});return Ge.jsx(N_n,{scope:e,triggerRef:s,contentRef:l,contentId:tS(),titleId:tS(),descriptionId:tS(),open:c,onOpenChange:u,onOpenToggle:rt.useCallback(()=>u(d=>!d),[u]),modal:o,children:t})};KQe.displayName=SH;var JQe="DialogTrigger",eKe=rt.forwardRef((n,e)=>{const{__scopeDialog:t,...r}=n,i=L4(JQe,t),a=L_(e,i.triggerRef);return Ge.jsx(Ry.button,{type:"button","aria-haspopup":"dialog","aria-expanded":i.open,"aria-controls":i.contentId,"data-state":Qpe(i.open),...r,ref:a,onClick:Pp(n.onClick,i.onOpenToggle)})});eKe.displayName=JQe;var Wpe="DialogPortal",[D_n,tKe]=ZQe(Wpe,{forceMount:void 0}),nKe=n=>{const{__scopeDialog:e,forceMount:t,children:r,container:i}=n,a=L4(Wpe,e);return Ge.jsx(D_n,{scope:e,forceMount:t,children:rt.Children.map(r,o=>Ge.jsx(K4,{present:t||a.open,children:Ge.jsx(Gce,{asChild:!0,container:i,children:o})}))})};nKe.displayName=Wpe;var wH="DialogOverlay",rKe=rt.forwardRef((n,e)=>{const t=tKe(wH,n.__scopeDialog),{forceMount:r=t.forceMount,...i}=n,a=L4(wH,n.__scopeDialog);return a.modal?Ge.jsx(K4,{present:r||a.open,children:Ge.jsx(O_n,{...i,ref:e})}):null});rKe.displayName=wH;var L_n=UE("DialogOverlay.RemoveScroll"),O_n=rt.forwardRef((n,e)=>{const{__scopeDialog:t,...r}=n,i=L4(wH,t);return Ge.jsx(Qce,{as:L_n,allowPinchZoom:!0,shards:[i.contentRef],children:Ge.jsx(Ry.div,{"data-state":Qpe(i.open),...r,ref:e,style:{pointerEvents:"auto",...r.style}})})}),qw="DialogContent",iKe=rt.forwardRef((n,e)=>{const t=tKe(qw,n.__scopeDialog),{forceMount:r=t.forceMount,...i}=n,a=L4(qw,n.__scopeDialog);return Ge.jsx(K4,{present:r||a.open,children:a.modal?Ge.jsx(z_n,{...i,ref:e}):Ge.jsx(U_n,{...i,ref:e})})});iKe.displayName=qw;var z_n=rt.forwardRef((n,e)=>{const t=L4(qw,n.__scopeDialog),r=rt.useRef(null),i=L_(e,t.contentRef,r);return rt.useEffect(()=>{const a=r.current;if(a)return dVe(a)},[]),Ge.jsx(aKe,{...n,ref:i,trapFocus:t.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Pp(n.onCloseAutoFocus,a=>{var o;a.preventDefault(),(o=t.triggerRef.current)==null||o.focus()}),onPointerDownOutside:Pp(n.onPointerDownOutside,a=>{const o=a.detail.originalEvent,s=o.button===0&&o.ctrlKey===!0;(o.button===2||s)&&a.preventDefault()}),onFocusOutside:Pp(n.onFocusOutside,a=>a.preventDefault())})}),U_n=rt.forwardRef((n,e)=>{const t=L4(qw,n.__scopeDialog),r=rt.useRef(!1),i=rt.useRef(!1);return Ge.jsx(aKe,{...n,ref:e,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:a=>{var o,s;(o=n.onCloseAutoFocus)==null||o.call(n,a),a.defaultPrevented||(r.current||(s=t.triggerRef.current)==null||s.focus(),a.preventDefault()),r.current=!1,i.current=!1},onInteractOutside:a=>{var l,c;(l=n.onInteractOutside)==null||l.call(n,a),a.defaultPrevented||(r.current=!0,a.detail.originalEvent.type==="pointerdown"&&(i.current=!0));const o=a.target;((c=t.triggerRef.current)==null?void 0:c.contains(o))&&a.preventDefault(),a.detail.originalEvent.type==="focusin"&&i.current&&a.preventDefault()}})}),aKe=rt.forwardRef((n,e)=>{const{__scopeDialog:t,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:a,...o}=n,s=L4(qw,t),l=rt.useRef(null),c=L_(e,l);return MHe(),Ge.jsxs(Ge.Fragment,{children:[Ge.jsx(Pce,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:a,children:Ge.jsx(Mce,{role:"dialog",id:s.contentId,"aria-describedby":s.descriptionId,"aria-labelledby":s.titleId,"data-state":Qpe(s.open),...o,ref:c,onDismiss:()=>s.onOpenChange(!1)})}),Ge.jsxs(Ge.Fragment,{children:[Ge.jsx(I_n,{titleId:s.titleId}),Ge.jsx(B_n,{contentRef:l,descriptionId:s.descriptionId})]})]})}),Zpe="DialogTitle",oKe=rt.forwardRef((n,e)=>{const{__scopeDialog:t,...r}=n,i=L4(Zpe,t);return Ge.jsx(Ry.h2,{id:i.titleId,...r,ref:e})});oKe.displayName=Zpe;var sKe="DialogDescription",lKe=rt.forwardRef((n,e)=>{const{__scopeDialog:t,...r}=n,i=L4(sKe,t);return Ge.jsx(Ry.p,{id:i.descriptionId,...r,ref:e})});lKe.displayName=sKe;var cKe="DialogClose",uKe=rt.forwardRef((n,e)=>{const{__scopeDialog:t,...r}=n,i=L4(cKe,t);return Ge.jsx(Ry.button,{type:"button",...r,ref:e,onClick:Pp(n.onClick,()=>i.onOpenChange(!1))})});uKe.displayName=cKe;function Qpe(n){return n?"open":"closed"}var dKe="DialogTitleWarning",[k_n,fKe]=r_t(dKe,{contentName:qw,titleName:Zpe,docsSlug:"dialog"}),I_n=({titleId:n})=>{const e=fKe(dKe),t=`\`${e.contentName}\` requires a \`${e.titleName}\` for the component to be accessible for screen reader users.
|
|
13454
|
+
`,onClick:r=>{r.stopPropagation(),t()},children:[Ge.jsx("input",{type:"checkbox",checked:e}),Ge.jsx("span",{style:{color:"#eee"},children:n})]}),__n=({children:n,elements:e})=>{const[t,r]=Bx($=>[$.is_mouse_over_container,$.setIsMouseOverContainer]),[i,a]=rt.useState(!1),[o,s]=rt.useState(!1),[l,c]=rt.useState(!1),[u,d]=Bx($=>[$.selected_layer,$.selectLayer]),[f,m,y,E,w,S]=Bx($=>[$.in_move_footprint_mode,$.in_draw_trace_mode,$.is_showing_rats_nest,$.is_showing_multiple_traces_length,$.is_showing_autorouting,$.is_showing_drc_errors]),T=Bx($=>$.setEditMode),P=Bx($=>$.setIsShowingRatsNest),U=Bx($=>$.setIsShowingMultipleTracesLength),H=Bx($=>$.setIsShowingAutorouting),G=Bx($=>$.setIsShowingDrcErrors);Q6("1",()=>d("top")),Q6("2",()=>d("bottom")),Q6("3",()=>d("inner1")),Q6("4",()=>d("inner2")),Q6("5",()=>d("inner3")),Q6("6",()=>d("inner4")),Q6("7",()=>d("inner5")),Q6("8",()=>d("inner6"));const W=(e==null?void 0:e.filter($=>$.type.includes("error")).length)??0;return Ge.jsxs("div",{style:{position:"relative"},onMouseEnter:()=>{r(!0)},onMouseLeave:$=>{r(!1),s(!1)},children:[n,Ge.jsxs("div",{style:{position:"absolute",bottom:4,right:8,pointerEvents:"none",color:"white",fontSize:11,opacity:t?.5:0,transition:"opacity 1s",transitionDelay:"2s",fontFamily:"sans-serif"},children:["@tscircuit/pcb-viewer@",y_n.version]}),Ge.jsxs("div",{style:{position:"absolute",opacity:t?1:0,top:16,left:16,transition:t?"opacity 100ms linear":"opacity 1s linear",zIndex:fb.toolbarOverlay,color:"red",display:"flex",fontSize:12,height:100,fontFamily:"sans-serif"},children:[Ge.jsxs(CM,{onClick:()=>{s(!o)},onMouseLeave:()=>{o&&s(!1)},children:[Ge.jsxs("div",{children:["layer:"," ",Ge.jsx("span",{style:{marginLeft:2,fontWeight:500,color:MM[u]},children:u})]}),o&&Ge.jsx("div",{style:{marginTop:4,minWidth:120},children:Vpe.map($=>$.replace(/-/g,"")).map($=>Ge.jsx(g_n,{name:$,selected:$===u,onClick:()=>{d($.replace(/-/,""))}},$))})]}),Ge.jsxs(CM,{style:W>0?{color:"red"}:{},onClick:()=>c(!l),onMouseLeave:()=>c(!1),children:[Ge.jsxs("div",{children:[W," errors"]}),l&&Ge.jsx("div",{style:{display:"grid",gridTemplateColumns:"100px 300px"},children:e==null?void 0:e.filter($=>$.type.includes("error")).map(($,Q)=>Ge.jsxs(rt.Fragment,{children:[Ge.jsx("div",{children:$.error_type}),Ge.jsx("div",{children:$.message})]},Q))})]}),Ge.jsx(CM,{style:{},onClick:()=>{T(m?"off":"draw_trace")},children:Ge.jsxs("div",{children:[m?"✖ ":"","Edit Traces"]})}),Ge.jsx(CM,{style:{},onClick:()=>{T(f?"off":"move_footprint")},children:Ge.jsxs("div",{children:[f?"✖ ":"","Move Components"]})}),Ge.jsx(CM,{style:{},onClick:()=>{P(!y)},children:Ge.jsxs("div",{children:[y?"✖ ":"","Rats Nest"]})}),Ge.jsx(CM,{onClick:()=>{a(!i)},children:Ge.jsxs("div",{children:[Ge.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"4px"},children:["View"," ",Ge.jsx("span",{style:{fontSize:"8px",transform:i?"rotate(180deg)":"rotate(0)",transition:"transform 0.1s ease",display:"inline-block"},children:"▼"})]}),i&&Ge.jsxs("div",{style:{marginTop:4,minWidth:120},children:[Ge.jsx(Xpe,{label:"Show All Trace Lengths",checked:E,onClick:()=>{U(!E)}}),Ge.jsx(Xpe,{label:"Show Autorouting Animation",checked:w,onClick:()=>{H(!w)}}),Ge.jsx(Xpe,{label:"Show DRC Errors",checked:S,onClick:()=>{G(!S)}})]})]})})]})]})},x_n=n=>{const{transform:e,elements:t}=n,[r,i]=rt.useMemo(()=>{const c=n.elements.flatMap(d=>Ngn(d,n.elements)),u=W8(n.elements);return[c,u]},[n.elements]),[a,o]=rt.useState({drawingObjectIdsWithMouseOver:new Set,primitiveIdsInMousedOverNet:[]}),s=rt.useMemo(()=>Rgn({primitivesWithoutInteractionMetadata:r,drawingObjectIdsWithMouseOver:a.drawingObjectIdsWithMouseOver,primitiveIdsInMousedOverNet:a.primitiveIdsInMousedOverNet}),[r,a]),l=rt.useCallback(c=>{var f,m;const u=[];for(const y of c)if(y._element){const E=i.getNetConnectedToId("pcb_port_id"in y._element?(f=y._element)==null?void 0:f.pcb_port_id:"pcb_trace_id"in y._element?(m=y._element)==null?void 0:m.pcb_trace_id:"");u.push(...i.getIdsConnectedToNet(E))}const d=new Set(c.map(y=>y._pcb_drawing_object_id));o({drawingObjectIdsWithMouseOver:d,primitiveIdsInMousedOverNet:u})},[i]);return Ge.jsx(m_n,{elements:t,transform:e,primitives:r,onMouseHoverOverPrimitives:l,children:Ge.jsx(Kgn,{disabled:!n.allowEditing,transform:e,soup:t,cancelPanDrag:n.cancelPanDrag,onCreateEditEvent:n.onCreateEditEvent,onModifyEditEvent:n.onModifyEditEvent,children:Ge.jsx(n_n,{disabled:!n.allowEditing,transform:e,soup:t,cancelPanDrag:n.cancelPanDrag,onCreateEditEvent:n.onCreateEditEvent,onModifyEditEvent:n.onModifyEditEvent,children:Ge.jsx(Zgn,{transform:e,focusOnHover:n.focusOnHover,children:Ge.jsx(__n,{elements:t,children:Ge.jsx(a_n,{transform:e,elements:t,children:Ge.jsx(v_n,{transform:e,soup:t,children:Ge.jsx(Xgn,{transform:e,debugGraphics:n.debugGraphics,children:Ge.jsx(Wgn,{transform:e,elements:t,children:Ge.jsx(Ygn,{transform:e,primitives:s,width:n.width,height:n.height,grid:n.grid})})})})})})})})})})},b_n=Mc(k0(400,300),n2(40,-40)),S_n=({circuitJson:n,debugGraphics:e,height:t=600,initialState:r,allowEditing:i=!0,editEvents:a,onEditEventsChanged:o,focusOnHover:s=!1,clickToInteractEnabled:l=!1})=>{const[c,u]=rt.useState(!l),[d,f]=qpe(),[m,y]=rt.useState(b_n),{ref:E,setTransform:w,cancelDrag:S}=Cgn({transform:m,onSetTransform:y,enabled:c});let[T,P]=rt.useState([]);T=a??T;const U=rt.useRef(!1),H=rt.useRef(null),G=`${(n==null?void 0:n.length)||0}_${(n==null?void 0:n.editCount)||0}`,W=()=>{const pe=(f==null?void 0:f.width)>0?f:{width:500,height:500},{center:ce,width:Se,height:he}=Q.some(xe=>xe.type.startsWith("pcb_"))?ygn(Q.filter(xe=>xe.type.startsWith("pcb_"))):{center:{x:0,y:0},width:.001,height:.001},ge=Math.min((pe.width??0)/Se,(pe.height??0)/he,100)*.75,Te=Mc(k0((pe.width??0)/2,(pe.height??0)/2),n2(ge,-ge,0,0),k0(-ce.x,-ce.y));w(Te)};rt.useEffect(()=>{f!=null&&f.width&&n&&n.length!==0&&(U.current||(W(),U.current=!0))},[n,f]);const $=rt.useMemo(()=>(n==null?void 0:n.filter(pe=>pe.type.startsWith("pcb_")||pe.type.startsWith("source_")))??[],[G]),Q=rt.useMemo(()=>$1n({circuitJson:$,editEvents:T}),[$,T]),X=pe=>{P([...T,pe]),o==null||o([...T,pe])},ue=pe=>{const ce=T.map(Se=>Se.edit_event_id===pe.edit_event_id?{...Se,...pe}:Se);P(ce),o==null||o(ce)};return Ge.jsxs("div",{ref:E,style:{position:"relative"},children:[Ge.jsx("div",{ref:d,children:Ge.jsxs(_gn,{initialState:r,children:[Ge.jsx(x_n,{transform:m,height:t,width:f.width,allowEditing:i,focusOnHover:s,cancelPanDrag:S,onCreateEditEvent:X,onModifyEditEvent:ue,grid:{spacing:1,view_window:{left:0,right:f.width||500,top:t,bottom:0}},elements:Q,debugGraphics:e},f.width),Ge.jsx(bgn,{})]})}),l&&!c&&Ge.jsx("div",{onClick:()=>{u(!0),W()},onTouchStart:pe=>{const ce=pe.touches[0];H.current={x:ce.clientX,y:ce.clientY}},onTouchEnd:pe=>{const ce=pe.changedTouches[0],Se=H.current;if(!Se)return;const he=Math.abs(ce.clientX-Se.x),ge=Math.abs(ce.clientY-Se.y);he<10&&ge<10&&(pe.preventDefault(),u(!0),W()),H.current=null},style:{position:"absolute",inset:0,cursor:"pointer",zIndex:fb.clickToInteractOverlay,display:"flex",alignItems:"center",justifyContent:"center",touchAction:"pan-x pan-y pinch-zoom"},children:Ge.jsx("div",{style:{backgroundColor:"rgba(0, 0, 0, 0.8)",color:"white",padding:"12px 24px",borderRadius:"8px",fontSize:"16px",pointerEvents:"none"},children:typeof window<"u"&&("ontouchstart"in window||navigator.maxTouchPoints>0)?"Touch to Interact":"Click to Interact"})})]})};const w_n=({containerClassName:n,...e})=>{const t=rt.useRef(null),[r,i]=rt.useState(620);return rt.useLayoutEffect(()=>{const a=()=>{if(t.current){const s=t.current.clientHeight,l=window.innerHeight;i(Math.min(Math.max(s,620),l))}};a();const o=new ResizeObserver(a);return t.current&&o.observe(t.current),window.addEventListener("resize",a),()=>{o.disconnect(),window.removeEventListener("resize",a)}},[]),Ge.jsx("div",{ref:t,className:n||"rf-w-full rf-h-full",children:Ge.jsx(S_n,{...e,height:r})})},E_n='*,:after,:before{--tw-border-spacing-x:0;--tw-border-spacing-y:0;--tw-translate-x:0;--tw-translate-y:0;--tw-rotate:0;--tw-skew-x:0;--tw-skew-y:0;--tw-scale-x:1;--tw-scale-y:1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness:proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:rgba(59,130,246,.5);--tw-ring-offset-shadow:0 0 #0000;--tw-ring-shadow:0 0 #0000;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }::backdrop{--tw-border-spacing-x:0;--tw-border-spacing-y:0;--tw-translate-x:0;--tw-translate-y:0;--tw-rotate:0;--tw-skew-x:0;--tw-skew-y:0;--tw-scale-x:1;--tw-scale-y:1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness:proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:rgba(59,130,246,.5);--tw-ring-offset-shadow:0 0 #0000;--tw-ring-shadow:0 0 #0000;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }/*! tailwindcss v3.4.17 | MIT License | https://tailwindcss.com*/*,:after,:before{border:0 solid #e5e7eb;box-sizing:border-box}:after,:before{--tw-content:""}:host,html{line-height:1.5;-webkit-text-size-adjust:100%;font-family:ui-sans-serif,system-ui,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;font-feature-settings:normal;font-variation-settings:normal;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-tap-highlight-color:transparent}body{line-height:inherit;margin:0}hr{border-top-width:1px;color:inherit;height:0}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,pre,samp{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace;font-feature-settings:normal;font-size:1em;font-variation-settings:normal}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}table{border-collapse:collapse;border-color:inherit;text-indent:0}button,input,optgroup,select,textarea{color:inherit;font-family:inherit;font-feature-settings:inherit;font-size:100%;font-variation-settings:inherit;font-weight:inherit;letter-spacing:inherit;line-height:inherit;margin:0;padding:0}button,select{text-transform:none}button,input:where([type=button]),input:where([type=reset]),input:where([type=submit]){-webkit-appearance:button;background-color:transparent;background-image:none}:-moz-focusring{outline:auto}:-moz-ui-invalid{box-shadow:none}progress{vertical-align:baseline}::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}summary{display:list-item}blockquote,dd,dl,figure,h1,h2,h3,h4,h5,h6,hr,p,pre{margin:0}fieldset{margin:0}fieldset,legend{padding:0}menu,ol,ul{list-style:none;margin:0;padding:0}dialog{padding:0}textarea{resize:vertical}input::-moz-placeholder,textarea::-moz-placeholder{color:#9ca3af;opacity:1}input::placeholder,textarea::placeholder{color:#9ca3af;opacity:1}[role=button],button{cursor:pointer}:disabled{cursor:default}audio,canvas,embed,iframe,img,object,svg,video{display:block;vertical-align:middle}img,video{height:auto;max-width:100%}[hidden]:where(:not([hidden=until-found])){display:none}:root{--radius:0.5rem}.rf-pointer-events-none{pointer-events:none}.rf-invisible{visibility:hidden}.rf-fixed{position:fixed}.rf-absolute{position:absolute}.rf-relative{position:relative}.rf-inset-0{inset:0}.-rf-left-2{left:-.5rem}.-rf-right-10{right:-2.5rem}.-rf-right-2{right:-.5rem}.-rf-right-4{right:-1rem}.-rf-right-6{right:-1.5rem}.-rf-right-7{right:-1.75rem}.-rf-right-8{right:-2rem}.-rf-right-9{right:-2.25rem}.rf-bottom-full{bottom:100%}.rf-left-0{left:0}.rf-left-1{left:.25rem}.rf-left-1\\/2{left:50%}.rf-left-2{left:.5rem}.rf-left-\\[50\\%\\]{left:50%}.rf-right-0{right:0}.rf-right-4{right:1rem}.rf-right-\\[4px\\]{right:4px}.rf-top-0{top:0}.rf-top-1{top:.25rem}.rf-top-2{top:.5rem}.rf-top-2\\.5{top:.625rem}.rf-top-\\[50\\%\\]{top:50%}.rf-top-\\[6px\\]{top:6px}.rf-z-50{z-index:50}.rf-z-\\[100\\]{z-index:100}.-rf-mx-1,.rf--mx-1{margin-left:-.25rem;margin-right:-.25rem}.rf-mx-1{margin-left:.25rem;margin-right:.25rem}.rf-mx-2{margin-left:.5rem;margin-right:.5rem}.rf-mx-auto{margin-left:auto;margin-right:auto}.rf-my-1{margin-bottom:.25rem;margin-top:.25rem}.rf-my-12{margin-bottom:3rem;margin-top:3rem}.rf-my-4{margin-bottom:1rem;margin-top:1rem}.rf-my-auto{margin-bottom:auto;margin-top:auto}.rf-mb-1{margin-bottom:.25rem}.rf-mb-12{margin-bottom:3rem}.rf-mb-2{margin-bottom:.5rem}.rf-mb-3{margin-bottom:.75rem}.rf-mb-4{margin-bottom:1rem}.rf-mb-6{margin-bottom:1.5rem}.rf-mb-8{margin-bottom:2rem}.rf-ml-1{margin-left:.25rem}.rf-ml-2{margin-left:.5rem}.rf-ml-auto{margin-left:auto}.rf-mr-1{margin-right:.25rem}.rf-mr-2{margin-right:.5rem}.rf-mt-0{margin-top:0}.rf-mt-0\\.5{margin-top:.125rem}.rf-mt-1{margin-top:.25rem}.rf-mt-2{margin-top:.5rem}.rf-mt-3{margin-top:.75rem}.rf-mt-4{margin-top:1rem}.rf-mt-5{margin-top:1.25rem}.rf-mt-auto{margin-top:auto}.rf-block{display:block}.rf-inline{display:inline}.rf-flex{display:flex}.rf-inline-flex{display:inline-flex}.rf-grid{display:grid}.rf-hidden{display:none}.rf-aspect-square{aspect-ratio:1/1}.rf-aspect-video{aspect-ratio:16/9}.rf-size-14{height:3.5rem;width:3.5rem}.rf-size-4{height:1rem;width:1rem}.\\!rf-h-2{height:.5rem!important}.\\!rf-h-2\\.5{height:.625rem!important}.\\!rf-h-3{height:.75rem!important}.\\!rf-h-full{height:100%!important}.rf-h-1{height:.25rem}.rf-h-10{height:2.5rem}.rf-h-12{height:3rem}.rf-h-2{height:.5rem}.rf-h-2\\.5{height:.625rem}.rf-h-3{height:.75rem}.rf-h-3\\.5{height:.875rem}.rf-h-4{height:1rem}.rf-h-5{height:1.25rem}.rf-h-6{height:1.5rem}.rf-h-60{height:15rem}.rf-h-64{height:16rem}.rf-h-8{height:2rem}.rf-h-9{height:2.25rem}.rf-h-\\[620px\\]{height:620px}.rf-h-\\[calc\\(100vh-52px\\)\\]{height:calc(100vh - 52px)}.rf-h-\\[calc\\(100vh-96px\\)\\]{height:calc(100vh - 96px)}.rf-h-\\[var\\(--radix-select-trigger-height\\)\\]{height:var(--radix-select-trigger-height)}.rf-h-fit{height:-moz-fit-content;height:fit-content}.rf-h-full{height:100%}.rf-h-px{height:1px}.\\!rf-max-h-\\[40vh\\]{max-height:40vh!important}.\\!rf-max-h-\\[70\\%\\]{max-height:70%!important}.rf-max-h-32{max-height:8rem}.rf-max-h-96{max-height:24rem}.rf-max-h-\\[500px\\]{max-height:500px}.rf-max-h-\\[90vh\\]{max-height:90vh}.rf-min-h-0{min-height:0}.rf-min-h-\\[200px\\]{min-height:200px}.rf-min-h-\\[620px\\]{min-height:620px}.rf-min-h-\\[calc\\(100vh-240px\\)\\]{min-height:calc(100vh - 240px)}.\\!rf-w-2{width:.5rem!important}.\\!rf-w-2\\.5{width:.625rem!important}.rf-w-1{width:.25rem}.rf-w-1\\/2{width:50%}.rf-w-11{width:2.75rem}.rf-w-11\\/12{width:91.666667%}.rf-w-12{width:3rem}.rf-w-16{width:4rem}.rf-w-2{width:.5rem}.rf-w-2\\.5{width:.625rem}.rf-w-3{width:.75rem}.rf-w-3\\.5{width:.875rem}.rf-w-32{width:8rem}.rf-w-4{width:1rem}.rf-w-5{width:1.25rem}.rf-w-6{width:1.5rem}.rf-w-64{width:16rem}.rf-w-72{width:18rem}.rf-w-8{width:2rem}.rf-w-9{width:2.25rem}.rf-w-96{width:24rem}.rf-w-\\[95\\%\\]{width:95%}.rf-w-fit{width:-moz-fit-content;width:fit-content}.rf-w-full{width:100%}.rf-min-w-10{min-width:2.5rem}.rf-min-w-16{min-width:4rem}.rf-min-w-\\[148px\\]{min-width:148px}.rf-min-w-\\[8rem\\]{min-width:8rem}.rf-min-w-\\[var\\(--radix-select-trigger-width\\)\\]{min-width:var(--radix-select-trigger-width)}.\\!rf-max-w-\\[60vw\\]{max-width:60vw!important}.\\!rf-max-w-\\[660px\\]{max-width:660px!important}.rf-max-w-2xl{max-width:42rem}.rf-max-w-3xl{max-width:48rem}.rf-max-w-5xl{max-width:64rem}.rf-max-w-full{max-width:100%}.rf-max-w-lg{max-width:32rem}.rf-max-w-md{max-width:28rem}.rf-max-w-xl{max-width:36rem}.rf-flex-1{flex:1 1 0%}.rf-flex-shrink-0,.rf-shrink-0{flex-shrink:0}.rf-flex-grow{flex-grow:1}.rf-table-auto{table-layout:auto}.-rf-translate-x-1{--tw-translate-x:-0.25rem}.-rf-translate-x-1,.-rf-translate-x-1\\/2{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.-rf-translate-x-1\\/2{--tw-translate-x:-50%}.-rf-translate-y-1{--tw-translate-y:-0.25rem}.-rf-translate-y-1,.rf--translate-x-1{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.rf--translate-x-1{--tw-translate-x:-0.25rem}.rf-translate-x-\\[-50\\%\\]{--tw-translate-x:-50%}.rf-translate-x-\\[-50\\%\\],.rf-translate-y-\\[-50\\%\\]{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.rf-translate-y-\\[-50\\%\\]{--tw-translate-y:-50%}.rf-transform{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}@keyframes rf-pulse{50%{opacity:.5}}.rf-animate-pulse{animation:rf-pulse 2s cubic-bezier(.4,0,.6,1) infinite}@keyframes rf-spin{to{transform:rotate(1turn)}}.rf-animate-spin{animation:rf-spin 1s linear infinite}.rf-cursor-default{cursor:default}.rf-cursor-not-allowed{cursor:not-allowed}.rf-cursor-pointer{cursor:pointer}.rf-select-none{-webkit-user-select:none;-moz-user-select:none;user-select:none}.rf-grid-cols-1{grid-template-columns:repeat(1,minmax(0,1fr))}.rf-grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.rf-flex-row{flex-direction:row}.rf-flex-col{flex-direction:column}.rf-flex-col-reverse{flex-direction:column-reverse}.rf-flex-wrap{flex-wrap:wrap}.rf-place-items-center{place-items:center}.rf-items-start{align-items:flex-start}.rf-items-end{align-items:flex-end}.rf-items-center{align-items:center}.rf-justify-end{justify-content:flex-end}.rf-justify-center{justify-content:center}.rf-justify-between{justify-content:space-between}.rf-gap-0{gap:0}.rf-gap-1{gap:.25rem}.rf-gap-2{gap:.5rem}.rf-gap-3{gap:.75rem}.rf-gap-4{gap:1rem}.rf-gap-5{gap:1.25rem}.rf-gap-6{gap:1.5rem}.rf-gap-8{gap:2rem}.rf-space-x-2>:not([hidden])~:not([hidden]){--tw-space-x-reverse:0;margin-left:calc(.5rem*(1 - var(--tw-space-x-reverse)));margin-right:calc(.5rem*var(--tw-space-x-reverse))}.rf-space-y-2>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-bottom:calc(.5rem*var(--tw-space-y-reverse));margin-top:calc(.5rem*(1 - var(--tw-space-y-reverse)))}.rf-space-y-4>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-bottom:calc(1rem*var(--tw-space-y-reverse));margin-top:calc(1rem*(1 - var(--tw-space-y-reverse)))}.rf-space-y-6>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-bottom:calc(1.5rem*var(--tw-space-y-reverse));margin-top:calc(1.5rem*(1 - var(--tw-space-y-reverse)))}.rf-divide-y>:not([hidden])~:not([hidden]){--tw-divide-y-reverse:0;border-bottom-width:calc(1px*var(--tw-divide-y-reverse));border-top-width:calc(1px*(1 - var(--tw-divide-y-reverse)))}.rf-overflow-auto{overflow:auto}.rf-overflow-hidden{overflow:hidden}.rf-overflow-visible{overflow:visible}.rf-overflow-x-auto{overflow-x:auto}.\\!rf-overflow-y-auto{overflow-y:auto!important}.rf-overflow-y-auto{overflow-y:auto}.\\!rf-overflow-x-hidden{overflow-x:hidden!important}.rf-overflow-x-hidden{overflow-x:hidden}.rf-overflow-x-clip{overflow-x:clip}.rf-truncate{overflow:hidden;text-overflow:ellipsis}.rf-truncate,.rf-whitespace-nowrap{white-space:nowrap}.rf-whitespace-pre-wrap{white-space:pre-wrap}.rf-break-words{overflow-wrap:break-word}.rf-rounded{border-radius:.25rem}.rf-rounded-2xl{border-radius:1rem}.rf-rounded-full{border-radius:9999px}.rf-rounded-lg{border-radius:var(--radius)}.rf-rounded-md{border-radius:calc(var(--radius) - 2px)}.rf-rounded-sm{border-radius:calc(var(--radius) - 4px)}.rf-rounded-xl{border-radius:.75rem}.rf-border{border-width:1px}.rf-border-b{border-bottom-width:1px}.rf-border-t{border-top-width:1px}.rf-border-blue-200{--tw-border-opacity:1;border-color:rgb(191 219 254/var(--tw-border-opacity,1))}.rf-border-blue-500{--tw-border-opacity:1;border-color:rgb(59 130 246/var(--tw-border-opacity,1))}.rf-border-blue-600{--tw-border-opacity:1;border-color:rgb(37 99 235/var(--tw-border-opacity,1))}.rf-border-gray-200{--tw-border-opacity:1;border-color:rgb(229 231 235/var(--tw-border-opacity,1))}.rf-border-gray-300{--tw-border-opacity:1;border-color:rgb(209 213 219/var(--tw-border-opacity,1))}.rf-border-green-200{--tw-border-opacity:1;border-color:rgb(187 247 208/var(--tw-border-opacity,1))}.rf-border-input{border-color:hsl(var(--input))}.rf-border-neutral-200{--tw-border-opacity:1;border-color:rgb(229 229 229/var(--tw-border-opacity,1))}.rf-border-primary{border-color:hsl(var(--primary))}.rf-border-red-200{--tw-border-opacity:1;border-color:rgb(254 202 202/var(--tw-border-opacity,1))}.rf-border-red-500{--tw-border-opacity:1;border-color:rgb(239 68 68/var(--tw-border-opacity,1))}.rf-border-zinc-200{--tw-border-opacity:1;border-color:rgb(228 228 231/var(--tw-border-opacity,1))}.rf-border-zinc-900{--tw-border-opacity:1;border-color:rgb(24 24 27/var(--tw-border-opacity,1))}.rf-bg-background{background-color:hsl(var(--background))}.rf-bg-black{--tw-bg-opacity:1;background-color:rgb(0 0 0/var(--tw-bg-opacity,1))}.rf-bg-black\\/80{background-color:rgba(0,0,0,.8)}.rf-bg-blue-100{--tw-bg-opacity:1;background-color:rgb(219 234 254/var(--tw-bg-opacity,1))}.rf-bg-blue-50{--tw-bg-opacity:1;background-color:rgb(239 246 255/var(--tw-bg-opacity,1))}.rf-bg-blue-500{--tw-bg-opacity:1;background-color:rgb(59 130 246/var(--tw-bg-opacity,1))}.rf-bg-blue-600{--tw-bg-opacity:1;background-color:rgb(37 99 235/var(--tw-bg-opacity,1))}.rf-bg-gray-100{--tw-bg-opacity:1;background-color:rgb(243 244 246/var(--tw-bg-opacity,1))}.rf-bg-gray-200{--tw-bg-opacity:1;background-color:rgb(229 231 235/var(--tw-bg-opacity,1))}.rf-bg-gray-300{--tw-bg-opacity:1;background-color:rgb(209 213 219/var(--tw-bg-opacity,1))}.rf-bg-gray-400{--tw-bg-opacity:1;background-color:rgb(156 163 175/var(--tw-bg-opacity,1))}.rf-bg-gray-50{--tw-bg-opacity:1;background-color:rgb(249 250 251/var(--tw-bg-opacity,1))}.rf-bg-gray-500{--tw-bg-opacity:1;background-color:rgb(107 114 128/var(--tw-bg-opacity,1))}.rf-bg-gray-700{--tw-bg-opacity:1;background-color:rgb(55 65 81/var(--tw-bg-opacity,1))}.rf-bg-gray-800{--tw-bg-opacity:1;background-color:rgb(31 41 55/var(--tw-bg-opacity,1))}.rf-bg-gray-900{--tw-bg-opacity:1;background-color:rgb(17 24 39/var(--tw-bg-opacity,1))}.rf-bg-green-100{--tw-bg-opacity:1;background-color:rgb(220 252 231/var(--tw-bg-opacity,1))}.rf-bg-green-50{--tw-bg-opacity:1;background-color:rgb(240 253 244/var(--tw-bg-opacity,1))}.rf-bg-muted{background-color:hsl(var(--muted))}.rf-bg-neutral-100{--tw-bg-opacity:1;background-color:rgb(245 245 245/var(--tw-bg-opacity,1))}.rf-bg-neutral-50{--tw-bg-opacity:1;background-color:rgb(250 250 250/var(--tw-bg-opacity,1))}.rf-bg-neutral-800{--tw-bg-opacity:1;background-color:rgb(38 38 38/var(--tw-bg-opacity,1))}.rf-bg-neutral-900{--tw-bg-opacity:1;background-color:rgb(23 23 23/var(--tw-bg-opacity,1))}.rf-bg-orange-400{--tw-bg-opacity:1;background-color:rgb(251 146 60/var(--tw-bg-opacity,1))}.rf-bg-popover{background-color:hsl(var(--popover))}.rf-bg-red-100{--tw-bg-opacity:1;background-color:rgb(254 226 226/var(--tw-bg-opacity,1))}.rf-bg-red-50{--tw-bg-opacity:1;background-color:rgb(254 242 242/var(--tw-bg-opacity,1))}.rf-bg-red-500{--tw-bg-opacity:1;background-color:rgb(239 68 68/var(--tw-bg-opacity,1))}.rf-bg-red-900{--tw-bg-opacity:1;background-color:rgb(127 29 29/var(--tw-bg-opacity,1))}.rf-bg-white{--tw-bg-opacity:1;background-color:rgb(255 255 255/var(--tw-bg-opacity,1))}.rf-bg-yellow-100{--tw-bg-opacity:1;background-color:rgb(254 249 195/var(--tw-bg-opacity,1))}.rf-bg-zinc-100{--tw-bg-opacity:1;background-color:rgb(244 244 245/var(--tw-bg-opacity,1))}.rf-bg-zinc-200{--tw-bg-opacity:1;background-color:rgb(228 228 231/var(--tw-bg-opacity,1))}.rf-bg-zinc-50{--tw-bg-opacity:1;background-color:rgb(250 250 250/var(--tw-bg-opacity,1))}.rf-bg-zinc-800{--tw-bg-opacity:1;background-color:rgb(39 39 42/var(--tw-bg-opacity,1))}.rf-bg-zinc-900{--tw-bg-opacity:1;background-color:rgb(24 24 27/var(--tw-bg-opacity,1))}.rf-bg-opacity-50{--tw-bg-opacity:0.5}.rf-fill-current{fill:currentColor}.rf-object-contain{-o-object-fit:contain;object-fit:contain}.\\!rf-p-0{padding:0!important}.rf-p-0{padding:0}.rf-p-1{padding:.25rem}.rf-p-2{padding:.5rem}.rf-p-3{padding:.75rem}.rf-p-4{padding:1rem}.rf-p-5{padding:1.25rem}.rf-p-6{padding:1.5rem}.rf-p-8{padding:2rem}.rf-px-1{padding-left:.25rem;padding-right:.25rem}.rf-px-2{padding-left:.5rem;padding-right:.5rem}.rf-px-3{padding-left:.75rem;padding-right:.75rem}.rf-px-4{padding-left:1rem;padding-right:1rem}.rf-px-6{padding-left:1.5rem;padding-right:1.5rem}.rf-px-8{padding-left:2rem;padding-right:2rem}.rf-py-0{padding-bottom:0;padding-top:0}.rf-py-0\\.5{padding-bottom:.125rem;padding-top:.125rem}.rf-py-1{padding-bottom:.25rem;padding-top:.25rem}.rf-py-1\\.5{padding-bottom:.375rem;padding-top:.375rem}.rf-py-10{padding-bottom:2.5rem;padding-top:2.5rem}.rf-py-12{padding-bottom:3rem;padding-top:3rem}.rf-py-2{padding-bottom:.5rem;padding-top:.5rem}.rf-py-3{padding-bottom:.75rem;padding-top:.75rem}.rf-py-4{padding-bottom:1rem;padding-top:1rem}.rf-py-8{padding-bottom:2rem;padding-top:2rem}.rf-pb-0{padding-bottom:0}.rf-pb-2{padding-bottom:.5rem}.rf-pb-3{padding-bottom:.75rem}.rf-pb-4{padding-bottom:1rem}.rf-pl-2{padding-left:.5rem}.rf-pl-4{padding-left:1rem}.rf-pl-8{padding-left:2rem}.rf-pr-2{padding-right:.5rem}.rf-pt-2{padding-top:.5rem}.rf-pt-4{padding-top:1rem}.rf-text-left{text-align:left}.rf-text-center{text-align:center}.rf-text-right{text-align:right}.rf-font-mono{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace}.rf-text-2xl{font-size:1.5rem;line-height:2rem}.rf-text-3xl{font-size:1.875rem;line-height:2.25rem}.rf-text-\\[8px\\]{font-size:8px}.rf-text-base{font-size:1rem;line-height:1.5rem}.rf-text-lg{font-size:1.125rem;line-height:1.75rem}.rf-text-sm{font-size:.875rem;line-height:1.25rem}.rf-text-xl{font-size:1.25rem;line-height:1.75rem}.rf-text-xs{font-size:.75rem;line-height:1rem}.rf-font-bold{font-weight:700}.rf-font-medium{font-weight:500}.rf-font-semibold{font-weight:600}.rf-capitalize{text-transform:capitalize}.rf-tabular-nums{--tw-numeric-spacing:tabular-nums;font-variant-numeric:var(--tw-ordinal) var(--tw-slashed-zero) var(--tw-numeric-figure) var(--tw-numeric-spacing) var(--tw-numeric-fraction)}.rf-leading-5{line-height:1.25rem}.rf-leading-none{line-height:1}.rf-leading-tight{line-height:1.25}.rf-tracking-widest{letter-spacing:.1em}.rf-text-black{--tw-text-opacity:1;color:rgb(0 0 0/var(--tw-text-opacity,1))}.rf-text-blue-500{--tw-text-opacity:1;color:rgb(59 130 246/var(--tw-text-opacity,1))}.rf-text-blue-600{--tw-text-opacity:1;color:rgb(37 99 235/var(--tw-text-opacity,1))}.rf-text-blue-700{--tw-text-opacity:1;color:rgb(29 78 216/var(--tw-text-opacity,1))}.rf-text-blue-800{--tw-text-opacity:1;color:rgb(30 64 175/var(--tw-text-opacity,1))}.rf-text-blue-900{--tw-text-opacity:1;color:rgb(30 58 138/var(--tw-text-opacity,1))}.rf-text-current{color:currentColor}.rf-text-gray-400{--tw-text-opacity:1;color:rgb(156 163 175/var(--tw-text-opacity,1))}.rf-text-gray-500{--tw-text-opacity:1;color:rgb(107 114 128/var(--tw-text-opacity,1))}.rf-text-gray-600{--tw-text-opacity:1;color:rgb(75 85 99/var(--tw-text-opacity,1))}.rf-text-gray-700{--tw-text-opacity:1;color:rgb(55 65 81/var(--tw-text-opacity,1))}.rf-text-gray-800{--tw-text-opacity:1;color:rgb(31 41 55/var(--tw-text-opacity,1))}.rf-text-gray-900{--tw-text-opacity:1;color:rgb(17 24 39/var(--tw-text-opacity,1))}.rf-text-green-500{--tw-text-opacity:1;color:rgb(34 197 94/var(--tw-text-opacity,1))}.rf-text-green-600{--tw-text-opacity:1;color:rgb(22 163 74/var(--tw-text-opacity,1))}.rf-text-green-700{--tw-text-opacity:1;color:rgb(21 128 61/var(--tw-text-opacity,1))}.rf-text-green-800{--tw-text-opacity:1;color:rgb(22 101 52/var(--tw-text-opacity,1))}.rf-text-green-900{--tw-text-opacity:1;color:rgb(20 83 45/var(--tw-text-opacity,1))}.rf-text-muted-foreground{color:hsl(var(--muted-foreground))}.rf-text-neutral-50{--tw-text-opacity:1;color:rgb(250 250 250/var(--tw-text-opacity,1))}.rf-text-neutral-500{--tw-text-opacity:1;color:rgb(115 115 115/var(--tw-text-opacity,1))}.rf-text-neutral-900{--tw-text-opacity:1;color:rgb(23 23 23/var(--tw-text-opacity,1))}.rf-text-neutral-950{--tw-text-opacity:1;color:rgb(10 10 10/var(--tw-text-opacity,1))}.rf-text-popover-foreground{color:hsl(var(--popover-foreground))}.rf-text-red-200{--tw-text-opacity:1;color:rgb(254 202 202/var(--tw-text-opacity,1))}.rf-text-red-300{--tw-text-opacity:1;color:rgb(252 165 165/var(--tw-text-opacity,1))}.rf-text-red-400{--tw-text-opacity:1;color:rgb(248 113 113/var(--tw-text-opacity,1))}.rf-text-red-500{--tw-text-opacity:1;color:rgb(239 68 68/var(--tw-text-opacity,1))}.rf-text-red-600{--tw-text-opacity:1;color:rgb(220 38 38/var(--tw-text-opacity,1))}.rf-text-red-700{--tw-text-opacity:1;color:rgb(185 28 28/var(--tw-text-opacity,1))}.rf-text-red-800{--tw-text-opacity:1;color:rgb(153 27 27/var(--tw-text-opacity,1))}.rf-text-red-900{--tw-text-opacity:1;color:rgb(127 29 29/var(--tw-text-opacity,1))}.rf-text-white{--tw-text-opacity:1;color:rgb(255 255 255/var(--tw-text-opacity,1))}.rf-text-yellow-400{--tw-text-opacity:1;color:rgb(250 204 21/var(--tw-text-opacity,1))}.rf-text-yellow-500{--tw-text-opacity:1;color:rgb(234 179 8/var(--tw-text-opacity,1))}.rf-text-yellow-900{--tw-text-opacity:1;color:rgb(113 63 18/var(--tw-text-opacity,1))}.rf-text-zinc-200{--tw-text-opacity:1;color:rgb(228 228 231/var(--tw-text-opacity,1))}.rf-text-zinc-300{--tw-text-opacity:1;color:rgb(212 212 216/var(--tw-text-opacity,1))}.rf-text-zinc-400{--tw-text-opacity:1;color:rgb(161 161 170/var(--tw-text-opacity,1))}.rf-text-zinc-50{--tw-text-opacity:1;color:rgb(250 250 250/var(--tw-text-opacity,1))}.rf-text-zinc-500{--tw-text-opacity:1;color:rgb(113 113 122/var(--tw-text-opacity,1))}.rf-text-zinc-900{--tw-text-opacity:1;color:rgb(24 24 27/var(--tw-text-opacity,1))}.rf-text-zinc-950{--tw-text-opacity:1;color:rgb(9 9 11/var(--tw-text-opacity,1))}.rf-underline{text-decoration-line:underline}.rf-line-through{text-decoration-line:line-through}.rf-underline-offset-4{text-underline-offset:4px}.rf-opacity-0{opacity:0}.rf-opacity-25{opacity:.25}.rf-opacity-30{opacity:.3}.rf-opacity-50{opacity:.5}.rf-opacity-60{opacity:.6}.rf-opacity-75{opacity:.75}.rf-shadow{--tw-shadow:0 1px 3px 0 rgba(0,0,0,.1),0 1px 2px -1px rgba(0,0,0,.1);--tw-shadow-colored:0 1px 3px 0 var(--tw-shadow-color),0 1px 2px -1px var(--tw-shadow-color)}.rf-shadow,.rf-shadow-lg{box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}.rf-shadow-lg{--tw-shadow:0 10px 15px -3px rgba(0,0,0,.1),0 4px 6px -4px rgba(0,0,0,.1);--tw-shadow-colored:0 10px 15px -3px var(--tw-shadow-color),0 4px 6px -4px var(--tw-shadow-color)}.rf-shadow-md{--tw-shadow:0 4px 6px -1px rgba(0,0,0,.1),0 2px 4px -2px rgba(0,0,0,.1);--tw-shadow-colored:0 4px 6px -1px var(--tw-shadow-color),0 2px 4px -2px var(--tw-shadow-color)}.rf-shadow-md,.rf-shadow-sm{box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}.rf-shadow-sm{--tw-shadow:0 1px 2px 0 rgba(0,0,0,.05);--tw-shadow-colored:0 1px 2px 0 var(--tw-shadow-color)}.rf-outline-none{outline:2px solid transparent;outline-offset:2px}.rf-ring-2{--tw-ring-offset-shadow:var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow:var(--tw-ring-inset) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow,0 0 #0000)}.rf-ring-blue-500{--tw-ring-opacity:1;--tw-ring-color:rgb(59 130 246/var(--tw-ring-opacity,1))}.rf-ring-primary{--tw-ring-color:hsl(var(--primary))}.rf-ring-offset-background{--tw-ring-offset-color:hsl(var(--background))}.rf-ring-offset-white{--tw-ring-offset-color:#fff}.rf-transition{transition-duration:.15s;transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,-webkit-backdrop-filter;transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,backdrop-filter;transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,backdrop-filter,-webkit-backdrop-filter;transition-timing-function:cubic-bezier(.4,0,.2,1)}.rf-transition-all{transition-duration:.15s;transition-property:all;transition-timing-function:cubic-bezier(.4,0,.2,1)}.rf-transition-colors{transition-duration:.15s;transition-property:color,background-color,border-color,text-decoration-color,fill,stroke;transition-timing-function:cubic-bezier(.4,0,.2,1)}.rf-transition-opacity{transition-duration:.15s;transition-property:opacity;transition-timing-function:cubic-bezier(.4,0,.2,1)}.rf-duration-200{transition-duration:.2s}.rf-ease-in-out{transition-timing-function:cubic-bezier(.4,0,.2,1)}@keyframes enter{0%{opacity:var(--tw-enter-opacity,1);transform:translate3d(var(--tw-enter-translate-x,0),var(--tw-enter-translate-y,0),0) scale3d(var(--tw-enter-scale,1),var(--tw-enter-scale,1),var(--tw-enter-scale,1)) rotate(var(--tw-enter-rotate,0))}}@keyframes exit{to{opacity:var(--tw-exit-opacity,1);transform:translate3d(var(--tw-exit-translate-x,0),var(--tw-exit-translate-y,0),0) scale3d(var(--tw-exit-scale,1),var(--tw-exit-scale,1),var(--tw-exit-scale,1)) rotate(var(--tw-exit-rotate,0))}}.rf-slide-in-from-left-1{--tw-enter-translate-x:-0.25rem}.rf-slide-out-to-left-1{--tw-exit-translate-x:-0.25rem}.rf-duration-200{animation-duration:.2s}.rf-ease-in-out{animation-timing-function:cubic-bezier(.4,0,.2,1)}.file\\:rf-border-0::file-selector-button{border-width:0}.file\\:rf-bg-transparent::file-selector-button{background-color:transparent}.file\\:rf-text-sm::file-selector-button{font-size:.875rem;line-height:1.25rem}.file\\:rf-font-medium::file-selector-button{font-weight:500}.placeholder\\:rf-text-zinc-500::-moz-placeholder{--tw-text-opacity:1;color:rgb(113 113 122/var(--tw-text-opacity,1))}.placeholder\\:rf-text-zinc-500::placeholder{--tw-text-opacity:1;color:rgb(113 113 122/var(--tw-text-opacity,1))}.hover\\:rf-border-blue-300:hover{--tw-border-opacity:1;border-color:rgb(147 197 253/var(--tw-border-opacity,1))}.hover\\:\\!rf-bg-transparent:hover{background-color:transparent!important}.hover\\:rf-bg-blue-700:hover{--tw-bg-opacity:1;background-color:rgb(29 78 216/var(--tw-bg-opacity,1))}.hover\\:rf-bg-red-500\\/90:hover{background-color:rgba(239,68,68,.9)}.hover\\:rf-bg-zinc-100:hover{--tw-bg-opacity:1;background-color:rgb(244 244 245/var(--tw-bg-opacity,1))}.hover\\:rf-bg-zinc-100\\/80:hover{background-color:hsla(240,5%,96%,.8)}.hover\\:rf-bg-zinc-900\\/90:hover{background-color:rgba(24,24,27,.9)}.hover\\:rf-text-red-400:hover{--tw-text-opacity:1;color:rgb(248 113 113/var(--tw-text-opacity,1))}.hover\\:rf-text-zinc-900:hover{--tw-text-opacity:1;color:rgb(24 24 27/var(--tw-text-opacity,1))}.hover\\:rf-underline:hover{text-decoration-line:underline}.focus\\:rf-bg-gray-100:focus{--tw-bg-opacity:1;background-color:rgb(243 244 246/var(--tw-bg-opacity,1))}.focus\\:rf-bg-zinc-100:focus{--tw-bg-opacity:1;background-color:rgb(244 244 245/var(--tw-bg-opacity,1))}.focus\\:rf-text-gray-900:focus{--tw-text-opacity:1;color:rgb(17 24 39/var(--tw-text-opacity,1))}.focus\\:rf-text-zinc-900:focus{--tw-text-opacity:1;color:rgb(24 24 27/var(--tw-text-opacity,1))}.focus\\:rf-outline-none:focus{outline:2px solid transparent;outline-offset:2px}.focus\\:rf-ring-2:focus{--tw-ring-offset-shadow:var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow:var(--tw-ring-inset) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow,0 0 #0000)}.focus\\:rf-ring-ring:focus{--tw-ring-color:hsl(var(--ring))}.focus\\:rf-ring-offset-2:focus{--tw-ring-offset-width:2px}.focus-visible\\:rf-outline-none:focus-visible{outline:2px solid transparent;outline-offset:2px}.focus-visible\\:rf-ring-1:focus-visible{--tw-ring-offset-shadow:var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow:var(--tw-ring-inset) 0 0 0 calc(1px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow,0 0 #0000)}.focus-visible\\:rf-ring-2:focus-visible{--tw-ring-offset-shadow:var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow:var(--tw-ring-inset) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow,0 0 #0000)}.focus-visible\\:rf-ring-zinc-950:focus-visible{--tw-ring-opacity:1;--tw-ring-color:rgb(9 9 11/var(--tw-ring-opacity,1))}.focus-visible\\:rf-ring-offset-2:focus-visible{--tw-ring-offset-width:2px}.disabled\\:rf-pointer-events-none:disabled{pointer-events:none}.disabled\\:rf-cursor-not-allowed:disabled{cursor:not-allowed}.disabled\\:rf-opacity-50:disabled{opacity:.5}.rf-group\\/bar:hover .group-hover\\/bar\\:rf-opacity-100{opacity:1}.data-\\[disabled\\]\\:rf-pointer-events-none[data-disabled]{pointer-events:none}.data-\\[side\\=bottom\\]\\:rf-translate-y-1[data-side=bottom]{--tw-translate-y:0.25rem}.data-\\[side\\=bottom\\]\\:rf-translate-y-1[data-side=bottom],.data-\\[side\\=left\\]\\:-rf-translate-x-1[data-side=left]{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.data-\\[side\\=left\\]\\:-rf-translate-x-1[data-side=left]{--tw-translate-x:-0.25rem}.data-\\[side\\=right\\]\\:rf-translate-x-1[data-side=right]{--tw-translate-x:0.25rem}.data-\\[side\\=right\\]\\:rf-translate-x-1[data-side=right],.data-\\[side\\=top\\]\\:-rf-translate-y-1[data-side=top]{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.data-\\[side\\=top\\]\\:-rf-translate-y-1[data-side=top]{--tw-translate-y:-0.25rem}.data-\\[state\\=active\\]\\:rf-bg-white[data-state=active]{--tw-bg-opacity:1;background-color:rgb(255 255 255/var(--tw-bg-opacity,1))}.data-\\[state\\=checked\\]\\:rf-bg-zinc-900[data-state=checked]{--tw-bg-opacity:1;background-color:rgb(24 24 27/var(--tw-bg-opacity,1))}.data-\\[state\\=open\\]\\:rf-bg-zinc-100[data-state=open]{--tw-bg-opacity:1;background-color:rgb(244 244 245/var(--tw-bg-opacity,1))}.data-\\[state\\=active\\]\\:rf-text-zinc-950[data-state=active]{--tw-text-opacity:1;color:rgb(9 9 11/var(--tw-text-opacity,1))}.data-\\[state\\=checked\\]\\:rf-text-zinc-50[data-state=checked]{--tw-text-opacity:1;color:rgb(250 250 250/var(--tw-text-opacity,1))}.data-\\[disabled\\]\\:rf-opacity-50[data-disabled]{opacity:.5}.data-\\[state\\=active\\]\\:rf-shadow[data-state=active]{--tw-shadow:0 1px 3px 0 rgba(0,0,0,.1),0 1px 2px -1px rgba(0,0,0,.1);--tw-shadow-colored:0 1px 3px 0 var(--tw-shadow-color),0 1px 2px -1px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}.data-\\[state\\=open\\]\\:rf-animate-in[data-state=open]{animation-duration:.15s;animation-name:enter;--tw-enter-opacity:initial;--tw-enter-scale:initial;--tw-enter-rotate:initial;--tw-enter-translate-x:initial;--tw-enter-translate-y:initial}.data-\\[state\\=closed\\]\\:rf-animate-out[data-state=closed]{animation-duration:.15s;animation-name:exit;--tw-exit-opacity:initial;--tw-exit-scale:initial;--tw-exit-rotate:initial;--tw-exit-translate-x:initial;--tw-exit-translate-y:initial}.data-\\[state\\=closed\\]\\:rf-fade-out-0[data-state=closed]{--tw-exit-opacity:0}.data-\\[state\\=open\\]\\:rf-fade-in-0[data-state=open]{--tw-enter-opacity:0}.data-\\[state\\=closed\\]\\:rf-zoom-out-95[data-state=closed]{--tw-exit-scale:.95}.data-\\[state\\=open\\]\\:rf-zoom-in-95[data-state=open]{--tw-enter-scale:.95}.data-\\[side\\=bottom\\]\\:rf-slide-in-from-top-2[data-side=bottom]{--tw-enter-translate-y:-0.5rem}.data-\\[side\\=left\\]\\:rf-slide-in-from-right-2[data-side=left]{--tw-enter-translate-x:0.5rem}.data-\\[side\\=right\\]\\:rf-slide-in-from-left-2[data-side=right]{--tw-enter-translate-x:-0.5rem}.data-\\[side\\=top\\]\\:rf-slide-in-from-bottom-2[data-side=top]{--tw-enter-translate-y:0.5rem}.data-\\[state\\=closed\\]\\:rf-slide-out-to-left-1\\/2[data-state=closed]{--tw-exit-translate-x:-50%}.data-\\[state\\=closed\\]\\:rf-slide-out-to-top-\\[48\\%\\][data-state=closed]{--tw-exit-translate-y:-48%}.data-\\[state\\=open\\]\\:rf-slide-in-from-left-1\\/2[data-state=open]{--tw-enter-translate-x:-50%}.data-\\[state\\=open\\]\\:rf-slide-in-from-top-\\[48\\%\\][data-state=open]{--tw-enter-translate-y:-48%}.dark\\:rf-border-zinc-50:is(.rf-dark *){--tw-border-opacity:1;border-color:rgb(250 250 250/var(--tw-border-opacity,1))}.dark\\:rf-border-zinc-800:is(.rf-dark *){--tw-border-opacity:1;border-color:rgb(39 39 42/var(--tw-border-opacity,1))}.dark\\:rf-bg-red-900:is(.rf-dark *){--tw-bg-opacity:1;background-color:rgb(127 29 29/var(--tw-bg-opacity,1))}.dark\\:rf-bg-zinc-50:is(.rf-dark *){--tw-bg-opacity:1;background-color:rgb(250 250 250/var(--tw-bg-opacity,1))}.dark\\:rf-bg-zinc-800:is(.rf-dark *){--tw-bg-opacity:1;background-color:rgb(39 39 42/var(--tw-bg-opacity,1))}.dark\\:rf-bg-zinc-950:is(.rf-dark *){--tw-bg-opacity:1;background-color:rgb(9 9 11/var(--tw-bg-opacity,1))}.dark\\:rf-text-zinc-400:is(.rf-dark *){--tw-text-opacity:1;color:rgb(161 161 170/var(--tw-text-opacity,1))}.dark\\:rf-text-zinc-50:is(.rf-dark *){--tw-text-opacity:1;color:rgb(250 250 250/var(--tw-text-opacity,1))}.dark\\:rf-text-zinc-900:is(.rf-dark *){--tw-text-opacity:1;color:rgb(24 24 27/var(--tw-text-opacity,1))}.dark\\:rf-placeholder-zinc-400:is(.rf-dark *)::-moz-placeholder{--tw-placeholder-opacity:1;color:rgb(161 161 170/var(--tw-placeholder-opacity,1))}.dark\\:rf-placeholder-zinc-400:is(.rf-dark *)::placeholder{--tw-placeholder-opacity:1;color:rgb(161 161 170/var(--tw-placeholder-opacity,1))}.dark\\:rf-ring-offset-zinc-950:is(.rf-dark *){--tw-ring-offset-color:#09090b}.dark\\:hover\\:rf-bg-red-900\\/90:hover:is(.rf-dark *){background-color:rgba(127,29,29,.9)}.dark\\:hover\\:rf-bg-zinc-50\\/90:hover:is(.rf-dark *){background-color:hsla(0,0%,98%,.9)}.dark\\:hover\\:rf-bg-zinc-800:hover:is(.rf-dark *){--tw-bg-opacity:1;background-color:rgb(39 39 42/var(--tw-bg-opacity,1))}.dark\\:hover\\:rf-bg-zinc-800\\/80:hover:is(.rf-dark *){background-color:rgba(39,39,42,.8)}.dark\\:hover\\:rf-text-zinc-50:hover:is(.rf-dark *){--tw-text-opacity:1;color:rgb(250 250 250/var(--tw-text-opacity,1))}.dark\\:focus\\:rf-bg-zinc-800:focus:is(.rf-dark *){--tw-bg-opacity:1;background-color:rgb(39 39 42/var(--tw-bg-opacity,1))}.dark\\:focus\\:rf-text-zinc-50:focus:is(.rf-dark *){--tw-text-opacity:1;color:rgb(250 250 250/var(--tw-text-opacity,1))}.dark\\:focus-visible\\:rf-ring-zinc-300:focus-visible:is(.rf-dark *){--tw-ring-opacity:1;--tw-ring-color:rgb(212 212 216/var(--tw-ring-opacity,1))}.dark\\:data-\\[state\\=active\\]\\:rf-bg-zinc-950[data-state=active]:is(.rf-dark *){--tw-bg-opacity:1;background-color:rgb(9 9 11/var(--tw-bg-opacity,1))}.dark\\:data-\\[state\\=checked\\]\\:rf-bg-zinc-50[data-state=checked]:is(.rf-dark *){--tw-bg-opacity:1;background-color:rgb(250 250 250/var(--tw-bg-opacity,1))}.dark\\:data-\\[state\\=open\\]\\:rf-bg-zinc-800[data-state=open]:is(.rf-dark *){--tw-bg-opacity:1;background-color:rgb(39 39 42/var(--tw-bg-opacity,1))}.dark\\:data-\\[state\\=active\\]\\:rf-text-zinc-50[data-state=active]:is(.rf-dark *){--tw-text-opacity:1;color:rgb(250 250 250/var(--tw-text-opacity,1))}.dark\\:data-\\[state\\=checked\\]\\:rf-text-zinc-900[data-state=checked]:is(.rf-dark *){--tw-text-opacity:1;color:rgb(24 24 27/var(--tw-text-opacity,1))}@media (min-width:640px){.sm\\:rf-mt-0{margin-top:0}.sm\\:rf-flex-row{flex-direction:row}.sm\\:rf-justify-end{justify-content:flex-end}.sm\\:rf-space-x-2>:not([hidden])~:not([hidden]){--tw-space-x-reverse:0;margin-left:calc(.5rem*(1 - var(--tw-space-x-reverse)));margin-right:calc(.5rem*var(--tw-space-x-reverse))}.sm\\:rf-rounded-lg{border-radius:var(--radius)}.sm\\:rf-text-left{text-align:left}}@media (min-width:768px){.md\\:rf-grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}}.\\[\\&\\>span\\]\\:rf-line-clamp-1>span{display:-webkit-box;overflow:hidden;-webkit-box-orient:vertical;-webkit-line-clamp:1}.\\[\\&\\>svg\\]\\:rf-size-4>svg{height:1rem;width:1rem}.\\[\\&\\>svg\\]\\:rf-shrink-0>svg{flex-shrink:0}.\\[\\&\\>svg\\]\\:rf-text-red-300>svg{--tw-text-opacity:1;color:rgb(252 165 165/var(--tw-text-opacity,1))}.\\[\\&\\>svg\\]\\:hover\\:rf-text-red-400:hover>svg{--tw-text-opacity:1;color:rgb(248 113 113/var(--tw-text-opacity,1))}.\\[\\&_svg\\]\\:rf-pointer-events-none svg{pointer-events:none}.\\[\\&_svg\\]\\:rf-size-4 svg{height:1rem;width:1rem}.\\[\\&_svg\\]\\:rf-shrink-0 svg{flex-shrink:0}',T_n=()=>{rt.useEffect(()=>{if(document.querySelector('style[data-styles="tscircuit-runframe"]'))return;const e=document.createElement("style");e.setAttribute("data-styles","tscircuit-runframe"),e.textContent=E_n,document.head.appendChild(e)},[])},WQe=n=>`hsl(${qb.indexOf(n)*137.5%360}, 70%, 50%)`,M_n=({phaseTimings:n})=>{if(!n)return null;const e=Object.values(n).reduce((t,r)=>t+r,0);return Ge.jsxs("div",{className:"rf-space-y-2 rf-w-full rf-px-4",children:[Ge.jsx("div",{className:"rf-relative rf-h-8 rf-flex rf-rounded-sm",children:qb.map(t=>{const r=n[t]||0,i=r/e*100;return Ge.jsx("div",{className:"rf-group/bar rf-relative rf-overflow-visible",style:{width:`${i}%`,backgroundColor:WQe(t)},children:Ge.jsxs("div",{className:"rf-opacity-0 group-hover/bar:rf-opacity-100 rf-transition-opacity rf-absolute rf-bottom-full rf-left-1/2 rf-transform -rf-translate-x-1/2 rf-mb-2 rf-px-2 rf-py-1 rf-text-xs rf-whitespace-nowrap rf-rounded rf-bg-gray-900 rf-text-white rf-pointer-events-none",children:[t,": ",r.toFixed(1),"ms"]})},t)})}),Ge.jsxs("div",{className:"rf-text-xs rf-text-gray-500",children:["Total: ",e.toFixed(2),"ms"]})]})},C_n=({renderLog:n})=>{const[e,t]=rt.useState("chronological");if(!n)return Ge.jsx("div",{className:"rf-p-4 rf-bg-gray-100 rf-rounded-md",children:"No render log, make sure this tab is open when you render (TODO add a rerender button here)"});const r=Object.entries((n==null?void 0:n.phaseTimings)??{});e==="chronological"?r.sort((a,o)=>qb.indexOf(a[0])-qb.indexOf(o[0])):r.sort((a,o)=>o[1]-a[1]);const i=r.reduce((a,[o,s])=>a+s,0);return Ge.jsxs("div",{className:"rf-bg-white",children:[Ge.jsxs("div",{className:"rf-flex rf-justify-between rf-items-center",children:[Ge.jsx("div",{children:"Render Logs"}),Ge.jsxs("div",{className:"rf-mb-4 rf-pr-2 rf-flex rf-text-xs rf-items-center",children:[Ge.jsx("div",{className:"rf-mr-2",children:"Sort by:"}),Ge.jsxs("select",{value:e,onChange:a=>t(a.target.value),className:"rf-px-2 rf-py-1 rf-border rf-rounded rf-text-xs",children:[Ge.jsx("option",{value:"chronological",children:"Phase Order"}),Ge.jsx("option",{value:"longest",children:"Duration"})]})]})]}),Ge.jsx(M_n,{phaseTimings:n.phaseTimings}),Ge.jsxs("table",{className:"rf-w-full rf-text-xs",children:[Ge.jsx("thead",{children:Ge.jsxs("tr",{children:[Ge.jsx("th",{className:"rf-text-left rf-p-2",children:"Phase Order"}),Ge.jsx("th",{className:"rf-text-left rf-p-2",children:"Phase"}),Ge.jsx("th",{className:"rf-text-left rf-p-2",children:"Duration (ms)"})]})}),Ge.jsx("tbody",{children:r.map(([a,o])=>Ge.jsxs("tr",{children:[Ge.jsx("td",{className:"rf-p-2",children:qb.indexOf(a)}),Ge.jsx("td",{className:"rf-p-2",children:a}),Ge.jsx("td",{className:"rf-p-2",children:Ge.jsx("div",{className:"rf-w-8",children:Ge.jsx("div",{className:"rf-h-2 rf-rounded-sm",style:{backgroundColor:WQe(a),width:`${o/i*100}%`}})})}),Ge.jsx("td",{className:"rf-p-2",children:Ge.jsxs("div",{className:"rf-flex w-full",children:[Ge.jsxs("span",{className:"rf-flex-grow",children:[o,"ms"]}),Ge.jsxs("span",{className:"rf-text-gray-500 rf-pr-2",children:[(o/i*100).toFixed(1),"%"]})]})})]},a))})]})]})},R_n="0.0.439",A_n=["assembly","bom","circuit_json","errors","render_log"],P_n=({code:n,onRunClicked:e=void 0,errorMessage:t,circuitJson:r,autoroutingGraphics:i,showRightHeaderContent:a=!0,showCodeTab:o=!1,codeTabContent:s,showJsonTab:l=!0,showRenderLogTab:c=!0,onActiveTabChange:u,renderLog:d,showImportAndFormatButtons:f=!0,className:m,headerClassName:y,leftHeaderContent:E,readOnly:w,isStreaming:S,autoroutingLog:T,onReportAutoroutingLog:P,isRunningCode:U,hasCodeChangedSinceLastRun:H,onEditEvent:G,editEvents:W,defaultActiveTab:$,autoRotate3dViewerDisabled:Q,showSchematicDebugGrid:X=!1,showToggleFullScreen:ue=!0,defaultToFullScreen:pe=!1})=>{var Ne;T_n();const ce=rt.useMemo(()=>r?r.filter(ze=>ze&&"error_type"in ze):null,[r]),[Se,he]=rt.useState($??"pcb"),[ge,Te]=rt.useState(pe),xe=rt.useCallback(ze=>{he(ze),u==null||u(ze)},[u]),Ae=()=>{Te(!ge)};return rt.useEffect(()=>{t&&xe("errors")},[t]),rt.useEffect(()=>{(Se==="code"||Se==="errors")&&r&&!t&&xe($??"pcb")},[r]),Ge.jsx("div",{className:_h("flex flex-col relative rf-overflow-x-hidden",m),children:Ge.jsx("div",{className:_h("rf-md:sticky rf-md:top-2",ge&&"rf-fixed rf-top-0 rf-left-0 rf-w-full rf-bg-white"),children:Ge.jsxs(Z5e,{value:Se,onValueChange:xe,className:"rf-flex-grow rf-flex rf-flex-col",children:[Ge.jsxs("div",{className:_h("rf-flex rf-items-center rf-gap-2 rf-p-2 rf-pb-0",y),children:[E,E&&Ge.jsx("div",{className:"rf-flex-grow"}),!E&&U&&Ge.jsx(nM,{className:"rf-w-4 rf-h-4 rf-animate-spin"}),!E&&Ge.jsx("div",{className:"rf-flex-grow"}),d&&d.progress!==1&&Ge.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2",children:[d.lastRenderEvent&&Ge.jsx("div",{className:"rf-text-xs rf-text-gray-500",children:((Ne=d.lastRenderEvent)==null?void 0:Ne.phase)??""}),Ge.jsx("div",{className:"rf-w-4 rf-h-4 rf-bg-blue-500 rf-opacity-50 rf-rounded-full rf-text-white",children:Ge.jsx(nM,{className:"rf-w-4 rf-h-4 rf-animate-spin"})}),Ge.jsxs("div",{className:"rf-text-xs rf-font-bold rf-text-gray-700 rf-tabular-nums",children:[((d.progress??0)*100).toFixed(1),"%"]})]}),a&&Ge.jsxs(lY,{children:[o&&Ge.jsx(p6,{value:"code",children:"Code"}),Ge.jsxs(p6,{value:"pcb",className:"rf-whitespace-nowrap",children:[r&&Ge.jsx("span",{className:_h("rf-inline-flex rf-items-center rf-justify-center rf-w-2 rf-h-2 rf-mr-1 rf-text-xs rf-font-bold rf-text-white rf-rounded-full",H?"rf-bg-gray-500":"rf-bg-blue-500")}),"PCB"]}),Ge.jsxs(p6,{value:"schematic",className:"rf-whitespace-nowrap",children:[r&&Ge.jsx("span",{className:_h("rf-inline-flex rf-items-center rf-justify-center rf-w-2 rf-h-2 rf-mr-1 rf-text-xs rf-font-bold rf-text-white rf-rounded-full",H?"rf-bg-gray-500":"rf-bg-blue-500")}),"Schematic"]}),Ge.jsxs(p6,{value:"cad",children:[r&&Ge.jsx("span",{className:_h("inline-flex items-center justify-center w-2 h-2 mr-1 text-xs font-bold text-white rounded-full",H?"rf-bg-gray-500":"rf-bg-blue-500")}),"3D"]}),!["pcb","cad","schematic"].includes(Se)&&Ge.jsx(p6,{value:Se,children:W5e(Se)}),Ge.jsxs(sue,{children:[Ge.jsx(lue,{asChild:!0,children:Ge.jsxs("div",{className:"rf-whitespace-nowrap rf-p-2 rf-mr-1 rf-cursor-pointer rf-relative",children:[Ge.jsx(nnn,{className:"rf-w-4 rf-h-4"}),(ce&&ce.length>0||t)&&Ge.jsx("span",{className:"rf-inline-flex rf-absolute rf-top-[6px] rf-right-[4px] rf-items-center rf-justify-center rf-w-1 rf-h-1 rf-ml-2 rf-text-[8px] rf-font-bold rf-text-white rf-bg-red-500 rf-rounded-full"})]})}),Ge.jsxs(aB,{className:"rf-*:text-xs",children:[A_n.map(ze=>Ge.jsxs(R4,{onSelect:()=>xe(ze),children:[Se!==ze&&Ge.jsx(oHe,{className:"rf-w-3 rf-h-3 rf-opacity-30"}),Se===ze&&Ge.jsx(mce,{className:"rf-w-3 rf-h-3"}),Ge.jsx("div",{className:"rf-pr-2",children:W5e(ze)}),ze==="errors"&&(ce&&ce.length>0||t)&&Ge.jsx("span",{className:"rf-inline-flex rf-items-center rf-justify-center rf-w-3 rf-h-3 rf-ml-2 rf-text-[8px] rf-font-bold rf-text-white rf-bg-red-500 rf-rounded-full",children:t?1:ce==null?void 0:ce.length})]},ze)),Ge.jsx(R4,{disabled:!0,className:"rf-opacity-60 rf-cursor-default rf-select-none",children:Ge.jsxs("div",{className:"rf-pr-2 rf-text-xs rf-text-gray-500",children:["@tscircuit/runframe@",R_n.split(".").map((ze,Re)=>Re===2?parseInt(ze)+1:ze).join(".")]})})]})]})]}),ue&&Ge.jsx(lb,{onClick:Ae,variant:"ghost",children:ge?Ge.jsx(onn,{size:16}):Ge.jsx(inn,{size:16})})]}),o&&Ge.jsx(e8,{value:"code",className:"rf-flex-grow rf-overflow-hidden",children:Ge.jsx("div",{className:"rf-h-full",children:s})}),Ge.jsx(e8,{value:"pcb",children:Ge.jsx("div",{className:_h("rf-overflow-hidden",ge?"rf-h-[calc(100vh-52px)]":"rf-h-[620px]"),children:Ge.jsx(tM,{fallbackRender:({error:ze})=>Ge.jsx("div",{className:"rf-mt-4 rf-bg-red-50 rf-rounded-md rf-border rf-border-red-200",children:Ge.jsxs("div",{className:"rf-p-4",children:[Ge.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-red-800 rf-mb-3",children:"Error loading PCB viewer"}),Ge.jsx("p",{className:"rf-text-xs rf-font-mono rf-whitespace-pre-wrap rf-text-red-600 rf-mt-2",children:(ze==null?void 0:ze.message)||"An unknown error occurred"})]})}),children:r?Ge.jsx(w_n,{focusOnHover:!1,circuitJson:r,debugGraphics:i,containerClassName:_h("rf-h-full rf-w-full",ge?"rf-min-h-[calc(100vh-240px)]":"rf-min-h-[620px]"),onEditEventsChanged:ze=>{G&&ze.forEach(Re=>G(Re))}}):Ge.jsx(Uw,{onRunClicked:e})})})}),Ge.jsx(e8,{value:"assembly",children:Ge.jsx("div",{className:_h("rf-overflow-auto",ge?"rf-h-[calc(100vh-96px)]":"rf-h-[620px]"),children:Ge.jsx(tM,{fallback:Ge.jsx("div",{children:"Error loading Assembly"}),children:r?Ge.jsx(Msn,{circuitJson:r,containerStyle:{height:"100%"},editingEnabled:!0,debugGrid:!0}):Ge.jsx(Uw,{onRunClicked:e})})})}),Ge.jsx(e8,{value:"schematic",children:Ge.jsx("div",{className:_h("rf-overflow-auto rf-bg-white",ge?"rf-h-[calc(100vh-96px)]":"rf-h-[620px]"),children:Ge.jsx(tM,{fallbackRender:({error:ze})=>Ge.jsx("div",{className:"rf-mt-4 rf-bg-red-50 rf-rounded-md rf-border rf-border-red-200",children:Ge.jsxs("div",{className:"rf-p-4",children:[Ge.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-red-800 rf-mb-3",children:"Error loading Schematic"}),Ge.jsx("p",{className:"rf-text-xs rf-font-mono rf-whitespace-pre-wrap rf-text-red-600 rf-mt-2",children:(ze==null?void 0:ze.message)||"An unknown error occurred"})]})}),children:r?Ge.jsx(wsn,{circuitJson:r,containerStyle:{height:"100%"},editingEnabled:!0,onEditEvent:ze=>{G==null||G(ze)},debugGrid:X,colorOverrides:{schematic:{background:"transparent"}}}):Ge.jsx(Uw,{onRunClicked:e})})})}),Ge.jsx(e8,{value:"cad",children:Ge.jsx("div",{className:_h("rf-overflow-auto",ge?"rf-h-[calc(100vh-96px)]":"rf-h-[620px]"),children:Ge.jsx(tM,{FallbackComponent:Htn,children:r?Ge.jsx(Btn,{soup:r,autoRotateDisabled:Q}):Ge.jsx(Uw,{onRunClicked:e})})})}),Ge.jsx(e8,{value:"bom",children:Ge.jsx("div",{className:_h("rf-overflow-auto",ge?"rf-h-[calc(100vh-96px)]":"rf-h-[620px]"),children:Ge.jsx(tM,{fallbackRender:({error:ze})=>Ge.jsx("div",{className:"rf-mt-4 rf-bg-red-50 rf-rounded-md rf-border rf-border-red-200",children:Ge.jsxs("div",{className:"rf-p-4",children:[Ge.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-red-800 rf-mb-3",children:"Error loading Bill of Materials"}),Ge.jsx("p",{className:"rf-text-xs rf-font-mono rf-whitespace-pre-wrap rf-text-red-600 rf-mt-2",children:(ze==null?void 0:ze.message)||"An unknown error occurred"})]})}),children:r?Ge.jsx(Nsn,{circuitJson:r}):Ge.jsx(Uw,{onRunClicked:e})})})}),Ge.jsx(e8,{value:"circuit_json",children:Ge.jsx("div",{className:_h("rf-overflow-auto",ge?"rf-h-[calc(100vh-96px)]":"rf-h-[620px]"),children:Ge.jsx(tM,{fallback:Ge.jsx("div",{children:"Error loading JSON viewer"}),children:r?Ge.jsx(Asn,{elements:r}):Ge.jsx(Uw,{onRunClicked:e})})})}),Ge.jsx(e8,{value:"errors",children:Ge.jsx("div",{className:_h("rf-overflow-auto",ge?"rf-h-[calc(100vh-96px)]":"rf-h-[620px]"),children:Array.isArray(ce)&&ce.length>0||t?Ge.jsx(eon,{code:n,circuitJsonErrors:ce,errorMessage:t,autoroutingLog:T,onReportAutoroutingLog:P}):Ge.jsx(Uw,{onRunClicked:e})})}),c&&Ge.jsx(e8,{value:"render_log",children:Ge.jsx(C_n,{renderLog:d})})]})})})};var SH="Dialog",[ZQe,QQe]=eS(SH),[N_n,L4]=ZQe(SH),KQe=n=>{const{__scopeDialog:e,children:t,open:r,defaultOpen:i,onOpenChange:a,modal:o=!0}=n,s=rt.useRef(null),l=rt.useRef(null),[c,u]=kE({prop:r,defaultProp:i??!1,onChange:a,caller:SH});return Ge.jsx(N_n,{scope:e,triggerRef:s,contentRef:l,contentId:tS(),titleId:tS(),descriptionId:tS(),open:c,onOpenChange:u,onOpenToggle:rt.useCallback(()=>u(d=>!d),[u]),modal:o,children:t})};KQe.displayName=SH;var JQe="DialogTrigger",eKe=rt.forwardRef((n,e)=>{const{__scopeDialog:t,...r}=n,i=L4(JQe,t),a=L_(e,i.triggerRef);return Ge.jsx(Ry.button,{type:"button","aria-haspopup":"dialog","aria-expanded":i.open,"aria-controls":i.contentId,"data-state":Qpe(i.open),...r,ref:a,onClick:Pp(n.onClick,i.onOpenToggle)})});eKe.displayName=JQe;var Wpe="DialogPortal",[D_n,tKe]=ZQe(Wpe,{forceMount:void 0}),nKe=n=>{const{__scopeDialog:e,forceMount:t,children:r,container:i}=n,a=L4(Wpe,e);return Ge.jsx(D_n,{scope:e,forceMount:t,children:rt.Children.map(r,o=>Ge.jsx(K4,{present:t||a.open,children:Ge.jsx(Gce,{asChild:!0,container:i,children:o})}))})};nKe.displayName=Wpe;var wH="DialogOverlay",rKe=rt.forwardRef((n,e)=>{const t=tKe(wH,n.__scopeDialog),{forceMount:r=t.forceMount,...i}=n,a=L4(wH,n.__scopeDialog);return a.modal?Ge.jsx(K4,{present:r||a.open,children:Ge.jsx(O_n,{...i,ref:e})}):null});rKe.displayName=wH;var L_n=UE("DialogOverlay.RemoveScroll"),O_n=rt.forwardRef((n,e)=>{const{__scopeDialog:t,...r}=n,i=L4(wH,t);return Ge.jsx(Qce,{as:L_n,allowPinchZoom:!0,shards:[i.contentRef],children:Ge.jsx(Ry.div,{"data-state":Qpe(i.open),...r,ref:e,style:{pointerEvents:"auto",...r.style}})})}),qw="DialogContent",iKe=rt.forwardRef((n,e)=>{const t=tKe(qw,n.__scopeDialog),{forceMount:r=t.forceMount,...i}=n,a=L4(qw,n.__scopeDialog);return Ge.jsx(K4,{present:r||a.open,children:a.modal?Ge.jsx(z_n,{...i,ref:e}):Ge.jsx(U_n,{...i,ref:e})})});iKe.displayName=qw;var z_n=rt.forwardRef((n,e)=>{const t=L4(qw,n.__scopeDialog),r=rt.useRef(null),i=L_(e,t.contentRef,r);return rt.useEffect(()=>{const a=r.current;if(a)return dVe(a)},[]),Ge.jsx(aKe,{...n,ref:i,trapFocus:t.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Pp(n.onCloseAutoFocus,a=>{var o;a.preventDefault(),(o=t.triggerRef.current)==null||o.focus()}),onPointerDownOutside:Pp(n.onPointerDownOutside,a=>{const o=a.detail.originalEvent,s=o.button===0&&o.ctrlKey===!0;(o.button===2||s)&&a.preventDefault()}),onFocusOutside:Pp(n.onFocusOutside,a=>a.preventDefault())})}),U_n=rt.forwardRef((n,e)=>{const t=L4(qw,n.__scopeDialog),r=rt.useRef(!1),i=rt.useRef(!1);return Ge.jsx(aKe,{...n,ref:e,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:a=>{var o,s;(o=n.onCloseAutoFocus)==null||o.call(n,a),a.defaultPrevented||(r.current||(s=t.triggerRef.current)==null||s.focus(),a.preventDefault()),r.current=!1,i.current=!1},onInteractOutside:a=>{var l,c;(l=n.onInteractOutside)==null||l.call(n,a),a.defaultPrevented||(r.current=!0,a.detail.originalEvent.type==="pointerdown"&&(i.current=!0));const o=a.target;((c=t.triggerRef.current)==null?void 0:c.contains(o))&&a.preventDefault(),a.detail.originalEvent.type==="focusin"&&i.current&&a.preventDefault()}})}),aKe=rt.forwardRef((n,e)=>{const{__scopeDialog:t,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:a,...o}=n,s=L4(qw,t),l=rt.useRef(null),c=L_(e,l);return MHe(),Ge.jsxs(Ge.Fragment,{children:[Ge.jsx(Pce,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:a,children:Ge.jsx(Mce,{role:"dialog",id:s.contentId,"aria-describedby":s.descriptionId,"aria-labelledby":s.titleId,"data-state":Qpe(s.open),...o,ref:c,onDismiss:()=>s.onOpenChange(!1)})}),Ge.jsxs(Ge.Fragment,{children:[Ge.jsx(I_n,{titleId:s.titleId}),Ge.jsx(B_n,{contentRef:l,descriptionId:s.descriptionId})]})]})}),Zpe="DialogTitle",oKe=rt.forwardRef((n,e)=>{const{__scopeDialog:t,...r}=n,i=L4(Zpe,t);return Ge.jsx(Ry.h2,{id:i.titleId,...r,ref:e})});oKe.displayName=Zpe;var sKe="DialogDescription",lKe=rt.forwardRef((n,e)=>{const{__scopeDialog:t,...r}=n,i=L4(sKe,t);return Ge.jsx(Ry.p,{id:i.descriptionId,...r,ref:e})});lKe.displayName=sKe;var cKe="DialogClose",uKe=rt.forwardRef((n,e)=>{const{__scopeDialog:t,...r}=n,i=L4(cKe,t);return Ge.jsx(Ry.button,{type:"button",...r,ref:e,onClick:Pp(n.onClick,()=>i.onOpenChange(!1))})});uKe.displayName=cKe;function Qpe(n){return n?"open":"closed"}var dKe="DialogTitleWarning",[k_n,fKe]=r_t(dKe,{contentName:qw,titleName:Zpe,docsSlug:"dialog"}),I_n=({titleId:n})=>{const e=fKe(dKe),t=`\`${e.contentName}\` requires a \`${e.titleName}\` for the component to be accessible for screen reader users.
|
|
13455
13455
|
|
|
13456
13456
|
If you want to hide the \`${e.titleName}\`, you can wrap it with our VisuallyHidden component.
|
|
13457
13457
|
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@tscircuit/runframe",
|
|
3
3
|
"main": "dist/preview.js",
|
|
4
4
|
"type": "module",
|
|
5
|
-
"version": "0.0.
|
|
5
|
+
"version": "0.0.440",
|
|
6
6
|
"exports": {
|
|
7
7
|
".": "./dist/preview.js",
|
|
8
8
|
"./preview": "./dist/preview.js",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"@babel/standalone": "^7.26.10",
|
|
34
34
|
"@biomejs/biome": "^1.9.4",
|
|
35
35
|
"@tscircuit/checks": "^0.0.47",
|
|
36
|
-
"@tscircuit/fake-snippets": "^0.0.
|
|
36
|
+
"@tscircuit/fake-snippets": "^0.0.66",
|
|
37
37
|
"@tscircuit/math-utils": "^0.0.18",
|
|
38
38
|
"@types/bun": "latest",
|
|
39
39
|
"@types/debug": "^4.1.12",
|