@tscircuit/runframe 0.0.2833 → 0.0.2834

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.
@@ -5575,7 +5575,7 @@ ${o.svg()}`;return n+=`" >
5575
5575
  transition: opacity 0.2s;
5576
5576
  margin-bottom: 10px;
5577
5577
  color: red;
5578
- `,tHi=({children:t,transform:e=MP(),elements:n})=>{const o=ee.useRef(null),{isShowingDRCErrors:i,hoveredErrorId:r,focusedErrorId:s}=Kc(p=>({isShowingDRCErrors:p.is_showing_drc_errors,hoveredErrorId:p.hovered_error_id,focusedErrorId:p.focused_error_id})),a=s??r;if(!n)return K.jsx("div",{style:{position:"relative"},ref:o,children:t});const A=n.filter(p=>p.type==="pcb_trace_error"&&!p.message?.includes("Multiple components found with name")),c=n.filter(p=>p.type==="pcb_via_clearance_error"),l=n.filter(p=>p.type==="pcb_trace_error"&&p.message?.includes("Multiple components found with name")),u=Ydn(n),g=zdn(n,a),h=p=>{const m=aFi({error:p,indexes:u});if(!m||typeof m.x!="number"||typeof m.y!="number")return null;const _=or(e,m);return Number.isNaN(_.x)||Number.isNaN(_.y)?null:_};let d=null;return g&&(d=h(g)),K.jsxs("div",{style:{position:"relative"},ref:o,children:[t,A.map((p,m)=>{const _=GU(p,m),f=a===_;if(!f&&!i)return null;const I=h(p);if(!I)return null;const C=d$e(I,o);return K.jsxs(ee.Fragment,{children:[K.jsx(Qhn,{errorCenter:I,isHighlighted:f}),K.jsx("div",{style:{position:"absolute",left:I.x-15,top:I.y-15,width:30,height:30,zIndex:Tu.errorOverlay+5,cursor:"pointer",borderRadius:"50%"},onMouseEnter:y=>{const x=y.currentTarget.nextElementSibling;if(x){const E=x.querySelector(".error-message");E&&(E.style.opacity="1")}},onMouseLeave:y=>{if(!f){const x=y.currentTarget.nextElementSibling;if(x){const E=x.querySelector(".error-message");E&&(E.style.opacity="0")}}}}),K.jsx("div",{style:{position:"absolute",zIndex:f?200:100,left:C.left,top:C.top,color:f?"#ff4444":"red",textAlign:"center",fontFamily:"sans-serif",fontSize:12,display:i||f?"flex":"none",flexDirection:"column",alignItems:"center",pointerEvents:"none",transform:C.transform},children:K.jsx("div",{className:`error-message ${h$e}`,style:{opacity:f?1:0,border:`1px solid ${f?"#ff4444":"red"}`},children:p.message})})]},_)}),c.map((p,m)=>{const _=GU(p,m),f=a===_;if(!f&&!i)return null;const I=h(p);if(!I)return null;const C=d$e({x:I.x,y:I.y},o);return K.jsxs(ee.Fragment,{children:[K.jsx(Qhn,{errorCenter:I,isHighlighted:f}),K.jsx("div",{style:{position:"absolute",left:I.x-15,top:I.y-15,width:30,height:30,zIndex:Tu.errorOverlay+5,cursor:"pointer",borderRadius:"50%"},onMouseEnter:y=>{const x=y.currentTarget.nextElementSibling;if(x){const E=x.querySelector(".error-message");E&&(E.style.opacity="1")}},onMouseLeave:y=>{if(!f){const x=y.currentTarget.nextElementSibling;if(x){const E=x.querySelector(".error-message");E&&(E.style.opacity="0")}}}}),K.jsx("div",{style:{position:"absolute",zIndex:f?Tu.errorOverlay+10:Tu.errorOverlay+1,left:C.left,top:C.top,color:f?"#ff4444":"red",textAlign:"center",fontFamily:"sans-serif",fontSize:12,display:"flex",flexDirection:"column",alignItems:"center",pointerEvents:"none",transform:C.transform},children:K.jsx("div",{className:`error-message ${h$e}`,style:{opacity:f?1:0,border:`1px solid ${f?"#ff4444":"red"}`},children:p.message})})]},_)}),l.map((p,m)=>{const _=p.component_name||p.message?.match(/name "([^"]+)"/)?.[1];if(!_)return null;const f=n?.filter(y=>y.type==="source_component"&&y.name===_||y.type==="pcb_component"&&n?.find(x=>x.type==="source_component"&&x.source_component_id===y.source_component_id&&x.name===_))||[],I=GU(p,m),C=a===I;return!C&&!i?null:f.map((y,x)=>{let E={x:0,y:0};if(y.type==="pcb_component")E=y.center||{x:0,y:0};else if(y.type==="source_component"){const F=n?.find(O=>O.type==="pcb_component"&&O.source_component_id===y.source_component_id);F&&F.type==="pcb_component"&&(E=F.center||{x:0,y:0})}const B=or(e,E);if(Number.isNaN(B.x)||Number.isNaN(B.y))return null;const S=Math.abs(e.a),k=Math.max(8,Math.min(30,.5*S)),R=d$e(B,o);return K.jsxs(ee.Fragment,{children:[K.jsx("svg",{style:{position:"absolute",left:0,top:0,pointerEvents:"none",mixBlendMode:"difference",zIndex:Tu.errorOverlay},width:"100%",height:"100%",children:C?K.jsx("polygon",{points:`${B.x},${B.y-k*1.25} ${B.x+k},${B.y} ${B.x},${B.y+k*1.25} ${B.x-k},${B.y}`,fill:"#ff4444"}):K.jsx("circle",{cx:B.x,cy:B.y,r:k,fill:"none",stroke:C?"#ff4444":"red",strokeWidth:C?Math.max(2,k*.15):Math.max(1,k*.1),opacity:1})}),K.jsx("div",{style:{position:"absolute",left:B.x-(k+10),top:B.y-(k+10),width:(k+10)*2,height:(k+10)*2,zIndex:Tu.errorOverlay+5,cursor:"pointer",borderRadius:"50%"},onMouseEnter:F=>{const O=F.currentTarget.nextElementSibling;if(O){const U=O.querySelector(".error-message");U&&(U.style.opacity="1")}},onMouseLeave:F=>{if(!C){const O=F.currentTarget.nextElementSibling;if(O){const U=O.querySelector(".error-message");U&&(U.style.opacity="0")}}}}),K.jsx("div",{style:{position:"absolute",zIndex:C?Tu.errorOverlay+20:Tu.errorOverlay+10,left:R.left,top:R.top,color:C?"#ff4444":"red",textAlign:"center",fontFamily:"sans-serif",fontSize:12,display:i||C?"flex":"none",flexDirection:"column",alignItems:"center",pointerEvents:"none",transform:R.transform},children:K.jsx("div",{className:`error-message ${h$e}`,style:{opacity:C?1:0,border:`1px solid ${C?"#ff4444":"red"}`},children:p.message})})]},`${I}_${x}`)})}),d&&K.jsx(eHi,{center:d})]})};function nHi(t,e){return t.size!==e.size?!1:Array.from(t).every(n=>e.has(n))}var GP=t=>t?.type==="pcb_component",vhn=t=>t?.type==="pcb_group",oHi=t=>t?.type==="pcb_panel",p$e=t=>t?.type==="pcb_board",Gg={MIN_LINE_LENGTH_FOR_LABEL:40,LABEL_OFFSET_ABOVE:2,LABEL_OFFSET_BELOW:-18,LABEL_OFFSET_RIGHT:8,LABEL_OFFSET_LEFT:-120,Y_LABEL_MIN_WIDTH:110,LINE_STROKE_WIDTH:1.5,LINE_DASH_PATTERN:"4,4",COMPONENT_MARKER_RADIUS:3,LABEL_FONT_SIZE:11,ANCHOR_MARKER_SIZE:6,ANCHOR_MARKER_STROKE_WIDTH:1.5},DE={OFFSET_LINE:"white",COMPONENT_MARKER_FILL:"#66ccff",COMPONENT_MARKER_STROKE:"white",LABEL_TEXT:"white"},m$e=({targets:t,transform:e,containerWidth:n,containerHeight:o})=>{if(t.length===0)return null;const i={color:DE.LABEL_TEXT,mixBlendMode:"difference",pointerEvents:"none",fontSize:Gg.LABEL_FONT_SIZE,fontFamily:"monospace",fontWeight:"bold"},r=new Map;return t.forEach(s=>{if(!r.has(s.anchor_id)){const a=or(e,s.anchor);r.set(s.anchor_id,a)}}),K.jsx("div",{style:{position:"absolute",left:0,top:0,width:n,height:o,overflow:"hidden",pointerEvents:"none",zIndex:Tu.dimensionOverlay},children:K.jsxs("svg",{style:{position:"absolute",left:0,top:0,pointerEvents:"none"},width:n,height:o,children:[t.map(s=>{const a=s.anchor,A=s.anchor_id,c=s.target,l=r.get(A),u=or(e,c),g=c.x-a.x,h=c.y-a.y,d=Math.abs(u.x-l.x),p=Math.abs(u.y-l.y),m=u.y<l.y,_=u.x>l.x,f=m?Gg.LABEL_OFFSET_ABOVE:Gg.LABEL_OFFSET_BELOW,I=_?Gg.LABEL_OFFSET_RIGHT:Gg.LABEL_OFFSET_LEFT,C=d>Gg.MIN_LINE_LENGTH_FOR_LABEL,y=p>Gg.MIN_LINE_LENGTH_FOR_LABEL,x=`${s.display_offset_x??g.toFixed(2)}mm`,E=`${s.display_offset_y??h.toFixed(2)}mm`;return K.jsxs("g",{children:[K.jsx("line",{x1:l.x,y1:l.y,x2:u.x,y2:l.y,stroke:DE.OFFSET_LINE,strokeWidth:Gg.LINE_STROKE_WIDTH,strokeDasharray:Gg.LINE_DASH_PATTERN}),K.jsx("line",{x1:u.x,y1:l.y,x2:u.x,y2:u.y,stroke:DE.OFFSET_LINE,strokeWidth:Gg.LINE_STROKE_WIDTH,strokeDasharray:Gg.LINE_DASH_PATTERN}),s.type==="component"||s.type==="board"?K.jsx("circle",{cx:u.x,cy:u.y,r:Gg.COMPONENT_MARKER_RADIUS,fill:DE.COMPONENT_MARKER_FILL,stroke:DE.COMPONENT_MARKER_STROKE,strokeWidth:1}):K.jsxs(K.Fragment,{children:[K.jsx("line",{x1:u.x-Gg.ANCHOR_MARKER_SIZE,y1:u.y,x2:u.x+Gg.ANCHOR_MARKER_SIZE,y2:u.y,stroke:DE.OFFSET_LINE,strokeWidth:Gg.ANCHOR_MARKER_STROKE_WIDTH}),K.jsx("line",{x1:u.x,y1:u.y-Gg.ANCHOR_MARKER_SIZE,x2:u.x,y2:u.y+Gg.ANCHOR_MARKER_SIZE,stroke:DE.OFFSET_LINE,strokeWidth:Gg.ANCHOR_MARKER_STROKE_WIDTH})]}),C&&K.jsx("foreignObject",{x:Math.min(l.x,u.x),y:l.y+f,width:Math.abs(u.x-l.x),height:20,style:{overflow:"visible"},children:K.jsx("div",{style:{...i,textAlign:"center"},children:x})}),y&&K.jsx("foreignObject",{x:u.x+I,y:Math.min(l.y,u.y),width:Gg.Y_LABEL_MIN_WIDTH,height:Math.abs(u.y-l.y),style:{overflow:"visible"},children:K.jsx("div",{style:{...i,display:"flex",alignItems:"center",justifyContent:_?"flex-start":"flex-end",whiteSpace:"nowrap",padding:"0 4px",height:"100%"},children:E})})]},s.id)}),Array.from(r.entries()).map(([s,a])=>K.jsxs("g",{children:[K.jsx("line",{x1:a.x-Gg.ANCHOR_MARKER_SIZE,y1:a.y,x2:a.x+Gg.ANCHOR_MARKER_SIZE,y2:a.y,stroke:DE.OFFSET_LINE,strokeWidth:Gg.ANCHOR_MARKER_STROKE_WIDTH}),K.jsx("line",{x1:a.x,y1:a.y-Gg.ANCHOR_MARKER_SIZE,x2:a.x,y2:a.y+Gg.ANCHOR_MARKER_SIZE,stroke:DE.OFFSET_LINE,strokeWidth:Gg.ANCHOR_MARKER_STROKE_WIDTH})]},`anchor-${s}`))]})})},iHi=({elements:t,highlightedPrimitives:e,transform:n,containerWidth:o,containerHeight:i})=>{const r=t.filter(_=>p$e(_)),s=t.filter(_=>GP(_)),a=t.filter(_=>vhn(_)),A=e.map(_=>GP(_._parent_pcb_component)?_._parent_pcb_component.pcb_component_id:GP(_._element)?_._element.pcb_component_id:null).filter(_=>!!_),c=new Set;if(A.forEach(_=>{const f=s.find(I=>I.pcb_component_id===_);f?.pcb_group_id&&c.add(f.pcb_group_id)}),!Kc(_=>_.is_showing_group_anchor_offsets)&&A.length===0)return null;const u=s.map(_=>{const f=_.positioned_relative_to_pcb_board_id;if(!f)return null;const I=r.find(C=>C.pcb_board_id===f);return I?{component:_,board:I,type:"component"}:null}).filter(_=>!!_),g=a.map(_=>{const f=_.positioned_relative_to_pcb_board_id;if(!f||!_.center)return null;const I=r.find(C=>C.pcb_board_id===f);return I?{group:_,board:I,type:"group"}:null}).filter(_=>!!_),h=[...u,...g];if(h.length===0)return null;const d=A.length===0,p=h.filter(_=>_.type==="component"?d||A.includes(_.component.pcb_component_id):d||c.has(_.group.pcb_group_id));if(p.length===0)return null;const m=p.map(_=>_.type==="component"?{id:`${_.board.pcb_board_id}-${_.component.pcb_component_id}-${_.type}`,anchor:_.board.center,anchor_id:_.board.pcb_board_id,target:_.component.center,type:"component",display_offset_x:_.component.display_offset_x,display_offset_y:_.component.display_offset_y}:{id:`${_.board.pcb_board_id}-${_.group.pcb_group_id}-${_.type}`,anchor:_.board.center,anchor_id:_.board.pcb_board_id,target:{x:_.group.anchor_position?.x??_.group.center.x,y:_.group.anchor_position?.y??_.group.center.y},type:"group",display_offset_x:_.group.display_offset_x,display_offset_y:_.group.display_offset_y}).filter(_=>!!_);return K.jsx(m$e,{targets:m,transform:n,containerWidth:o,containerHeight:i})},rHi=({elements:t,highlightedPrimitives:e,transform:n,containerWidth:o,containerHeight:i})=>{const r=t.filter(_=>vhn(_)),s=t.filter(_=>GP(_)),a=e.map(_=>GP(_._parent_pcb_component)?_._parent_pcb_component.pcb_component_id:GP(_._element)?_._element.pcb_component_id:null).filter(_=>!!_),A=(_,f)=>{if(f.has(_))return;f.add(_);const I=r.find(C=>C.pcb_group_id===_);I?.position_mode==="relative_to_group_anchor"&&I.positioned_relative_to_pcb_group_id&&A(I.positioned_relative_to_pcb_group_id,f)},c=new Set;if(a.forEach(_=>{const f=s.find(I=>I.pcb_component_id===_);f&&(f.position_mode==="relative_to_group_anchor"&&f.positioned_relative_to_pcb_group_id&&A(f.positioned_relative_to_pcb_group_id,c),f.pcb_group_id&&A(f.pcb_group_id,c))}),!Kc(_=>_.is_showing_group_anchor_offsets)&&a.length===0)return null;const u=s.map(_=>{if(_.position_mode==="relative_to_group_anchor"&&_.positioned_relative_to_pcb_group_id){const f=r.find(I=>I.pcb_group_id===_.positioned_relative_to_pcb_group_id);return f&&f.anchor_position?{component:_,parentGroup:f,type:"component"}:null}if(_.pcb_group_id){const f=r.find(I=>I.pcb_group_id===_.pcb_group_id);return f&&f.anchor_position?{component:_,parentGroup:f,type:"component"}:null}return null}).filter(_=>!!_),g=r.map(_=>{if(_.position_mode==="relative_to_group_anchor"&&_.positioned_relative_to_pcb_group_id){const f=r.find(I=>I.pcb_group_id===_.positioned_relative_to_pcb_group_id);if(f&&f.anchor_position&&_.anchor_position)return{group:_,parentGroup:f,type:"group"}}return null}).filter(_=>!!_),h=[...u,...g];if(h.length===0)return null;const d=a.length===0,p=h.filter(_=>_.type==="component"?d||a.includes(_.component.pcb_component_id):d||c.has(_.group.pcb_group_id)||c.has(_.parentGroup.pcb_group_id));if(p.length===0)return null;const m=p.map(_=>{const f=_.parentGroup.anchor_position;return f?_.type==="component"?_.component.center?{id:`${_.parentGroup.pcb_group_id}-${_.component.pcb_component_id}-${_.type}`,anchor:f,anchor_id:_.parentGroup.pcb_group_id,target:_.component.center,type:"component",display_offset_x:_.component.display_offset_x,display_offset_y:_.component.display_offset_y}:null:_.group.anchor_position?{id:`${_.parentGroup.pcb_group_id}-${_.group.pcb_group_id}-${_.type}`,anchor:f,anchor_id:_.parentGroup.pcb_group_id,target:_.group.anchor_position,type:"group",display_offset_x:_.group.display_offset_x,display_offset_y:_.group.display_offset_y}:null:null}).filter(_=>!!_);return K.jsx(m$e,{targets:m,transform:n,containerWidth:o,containerHeight:i})},sHi=(t,e)=>{const n=t.pcb_component_id,o=e.filter(i=>(i.type==="pcb_smtpad"||i.type==="pcb_plated_hole")&&i.pcb_component_id===n||i.type==="pcb_hole"&&i.pcb_component_id===n);return o.length===0?A$e([t]):A$e(o)},aHi=({elements:t,highlightedPrimitives:e,transform:n,containerWidth:o,containerHeight:i})=>{const r=new Map;for(const a of e)GP(a._parent_pcb_component)&&r.set(a._parent_pcb_component.pcb_component_id,a._parent_pcb_component),GP(a._element)&&r.set(a._element.pcb_component_id,a._element);if(r.size===0)return null;const s=[];for(const a of r.values()){const A=sHi(a,t);if(!A)continue;const c=a.positioned_relative_to_pcb_group_id??a.pcb_group_id,l=c?OU(t).pcb_group.get(c):null;s.push({component:a,bbox:A,group:l})}return s.length===0?null:K.jsx("div",{style:{position:"absolute",left:0,top:0,width:o,height:i,overflow:"hidden",pointerEvents:"none",zIndex:Tu.dimensionOverlay},children:K.jsx("svg",{style:{position:"absolute",left:0,top:0,pointerEvents:"none"},width:o,height:i,children:s.map(({component:a,bbox:A,group:c})=>{const l=or(n,{x:A.minX,y:A.maxY}),u=or(n,{x:A.maxX,y:A.minY}),g={x:Math.min(l.x,u.x),y:Math.min(l.y,u.y),width:Math.abs(u.x-l.x),height:Math.abs(u.y-l.y)},h=a.center??{x:(A.minX+A.maxX)/2,y:(A.minY+A.maxY)/2},d=or(n,h);return K.jsxs("g",{children:[K.jsx("rect",{x:g.x,y:g.y,width:g.width,height:g.height,fill:"none",stroke:"white",strokeWidth:1.5,strokeDasharray:"4,4"}),K.jsx("line",{x1:d.x-6,y1:d.y,x2:d.x+6,y2:d.y,stroke:DE.COMPONENT_MARKER_STROKE,strokeWidth:1.5}),K.jsx("line",{x1:d.x,y1:d.y-6,x2:d.x,y2:d.y+6,stroke:DE.COMPONENT_MARKER_STROKE,strokeWidth:1.5}),K.jsx("circle",{cx:d.x,cy:d.y,r:Gg.COMPONENT_MARKER_RADIUS,fill:DE.COMPONENT_MARKER_FILL,stroke:DE.COMPONENT_MARKER_STROKE,strokeWidth:1})]},a.pcb_component_id)})})})},AHi=({elements:t,highlightedPrimitives:e,transform:n,containerWidth:o,containerHeight:i})=>{const r=t.filter(h=>oHi(h)),s=t.filter(h=>p$e(h)),a=e.map(h=>p$e(h._element)?h._element.pcb_board_id:null).filter(h=>!!h);if(!Kc(h=>h.is_showing_group_anchor_offsets)&&a.length===0)return null;const c=s.map(h=>{const d=h.pcb_panel_id,p=h.position_mode;if(!d||p!=="relative_to_panel_anchor")return null;const m=r.find(_=>_.pcb_panel_id===d);return m?{board:h,panel:m,type:"board"}:null}).filter(h=>!!h);if(c.length===0)return null;const l=a.length===0,u=c.filter(h=>l||a.includes(h.board.pcb_board_id));if(u.length===0)return null;const g=u.map(h=>h.board.center?{id:`${h.panel.pcb_panel_id}-${h.board.pcb_board_id}-${h.type}`,anchor:h.panel.center,anchor_id:h.panel.pcb_panel_id,target:h.board.center,type:"board",display_offset_x:h.board.display_offset_x,display_offset_y:h.board.display_offset_y}:null).filter(h=>!!h);return K.jsx(m$e,{targets:g,transform:n,containerWidth:o,containerHeight:i})};function cHi(t){const{primitives:e,is_showing_multiple_traces_length:n,elements:o}=t,i=e.filter(A=>A._element.type==="pcb_trace"),r=o.filter(A=>A.type==="source_trace"),s=e.filter(A=>A._element.type!=="pcb_trace"),a=i.filter(A=>r.some(l=>A._element.source_trace_id===l.source_trace_id&&l.max_length!==void 0)||l$e({primitiveElement:A._element,elements:o})!==null);if(!n)return[...s,...a];if(i.length>1){const A=i.reduce((c,l)=>{const u=c._element.trace_length;return l._element.trace_length<u?l:c},i[0]);return[...s,A]}return e}var lHi={position:"absolute",left:0,top:0,pointerEvents:"none",color:"red",fontFamily:"sans-serif",fontSize:12,textShadow:"0 0 2px black"},uHi=t=>{const{_element:e,_parent_pcb_component:n,_parent_source_component:o,_source_port:i}=t;switch(e.type){case"pcb_trace":return e.trace_length?`${e.trace_length.toFixed(3)}`:"";case"pcb_smtpad":case"pcb_plated_hole":{const r=[],s=Array.from(new Set((e.port_hints??[]).concat(i?.port_hints??[]))).filter(A=>!/^[0-9]+$/.test(A)).filter(A=>!A.includes("unnamed_")).sort((A,c)=>c.localeCompare(A)),a=o&&"name"in o&&o.name&&!o.name.includes("unnamed_")?o.name:null;return s.length>0?a?r.push(...s.map(A=>`${a}.${A}`)):r.push(...s):a&&r.push(a),r.join(", ")}default:return""}},gHi={top:"red",bottom:"aqua"},dHi=({primitive:t,mousePos:e,elements:n})=>{const[o,i]=ee.useState(!1),r=t._element;ee.useEffect(()=>{setTimeout(()=>{i(!0)},100)},[]);const[s,a,A,c]=[t.screen_x,t.screen_y,t.screen_w,t.screen_h],l=t.same_space_index??0,u=26,g=gHi[t?._element?.layer]??"red";let h=0;if(r.type==="pcb_smtpad"&&r?.shape==="rotated_rect"?h=r?.ccw_rotation??0:(r.type==="pcb_smtpad"&&(r?.shape==="pill"||r?.shape==="rotated_pill")&&"ccw_rotation"in t||r.type==="pcb_plated_hole"&&(r?.shape==="pill"||r?.shape==="oval")&&"ccw_rotation"in t)&&(h=r.ccw_rotation??0),r.type==="pcb_trace"){const m=Wdn({primitiveElement:r,elements:n});return m?K.jsx("div",{style:{zIndex:Tu.elementOverlay,position:"absolute",left:e.x+12,top:e.y+12,color:g,pointerEvents:"none"},children:K.jsxs("div",{style:{backgroundColor:"#f2efcc",color:m.isOverLength?"red":"black",textShadow:"none",WebkitFontSmoothing:"antialiased",MozOsxFontSmoothing:"grayscale",padding:"4px 6px",borderRadius:"4px",fontSize:"11px",lineHeight:1.2,textAlign:"left",whiteSpace:"nowrap"},children:[m.text&&K.jsx("div",{children:m.text}),m.name&&K.jsx("div",{style:{marginTop:m.text?"2px":0},children:m.name})]})}):null}const d=uHi(t);return d.trim().length===0?null:K.jsx("div",{style:{zIndex:Tu.elementOverlay,position:"absolute",left:s-A/2-8,top:a-c/2-8,width:A+16,height:c+16,color:g,transform:`rotate(${-h}deg)`,transformOrigin:"center center"},children:K.jsx("div",{style:{width:o?`calc(100% + ${u*2*l}px)`:"100%",height:o?`calc(100% + ${u*2*l}px)`:"100%",marginLeft:o?`${-u*l}px`:0,marginTop:o?`${-u*l}px`:0,border:`1px solid ${g}`,opacity:o||l===0?1:0,transition:"width 0.2s, height 0.2s, margin-left 0.2s, margin-top 0.2s, opacity 0.2s"},children:K.jsx("div",{style:{position:"absolute",bottom:c+20+u*l,marginRight:o?`${-u*l}px`:0,marginBottom:o?0:-u*l,transition:"margin-right 0.2s, margin-bottom 0.2s",backgroundColor:"#f2efcc",color:"black",textShadow:"none",WebkitFontSmoothing:"antialiased",MozOsxFontSmoothing:"grayscale",padding:"6px 6px",borderRadius:"6px",fontSize:"14px",transform:`rotate(${h}deg)`,minWidth:"45px",textAlign:"center"},children:d})})})},hHi=({highlightedPrimitives:t,mousePos:e,elements:n})=>{const[o,i]=Kc(a=>[a.is_moving_component,a.is_showing_multiple_traces_length]),r=t.some(a=>a._element.type==="pcb_smtpad")&&t.some(a=>a._element.type==="pcb_trace");let s=t;return r&&(s=s.filter(a=>a._element.type==="pcb_smtpad")),s=cHi({primitives:s,is_showing_multiple_traces_length:i,elements:n}),K.jsx("div",{style:lHi,children:!o&&s.map(a=>K.jsx(dHi,{primitive:a,mousePos:e,elements:n},a._pcb_drawing_object_id))})},Afe=t=>{if(t.length===0)return null;let e=t[0].x,n=t[0].y,o=t[0].x,i=t[0].y;for(const r of t)r.x<e&&(e=r.x),r.y<n&&(n=r.y),r.x>o&&(o=r.x),r.y>i&&(i=r.y);return{center:{x:(e+o)/2,y:(n+i)/2},width:o-e,height:i-n}},whn=(t,e)=>{if(e.length<3)return!1;let n=!1;for(let o=0,i=e.length-1;o<e.length;i=o++){const r=e[o].x,s=e[o].y,a=e[i].x,A=e[i].y;s>t.y!=A>t.y&&t.x<(a-r)*(t.y-s)/(A-s||Number.EPSILON)+r&&(n=!n)}return n},_$e=(t,e,n,o,i=!1)=>{const r=[];for(const s of t){if(!s._element||!i&&s._element.type==="pcb_trace"&&s.layer!==o)continue;if("x1"in s&&s._element?.type==="pcb_trace"){const c=qd({x:e.x,y:e.y},{x:s.x1,y:s.y1},{x:s.x2,y:s.y2}),l=s.width||.5,u=Math.max(l*25,2)/n.a;c<u&&r.push(s);continue}if(s.pcb_drawing_type==="polygon"){const c=s.points.map(u=>({x:lt.parse(u.x),y:lt.parse(u.y)})),l=Afe(c);if(!l||e.x<l.center.x-l.width/2||e.x>l.center.x+l.width/2||e.y<l.center.y-l.height/2||e.y>l.center.y+l.height/2)continue;whn(e,c)&&r.push(s);continue}if(s.pcb_drawing_type==="polygon_with_arcs"){const c=s.brep_shape.outer_ring.vertices.map(u=>({x:lt.parse(u.x),y:lt.parse(u.y)})),l=Afe(c);if(!l||e.x<l.center.x-l.width/2||e.x>l.center.x+l.width/2||e.y<l.center.y-l.height/2||e.y>l.center.y+l.height/2)continue;whn(e,c)&&r.push(s);continue}if(!("x"in s&&"y"in s))continue;let a=0,A=0;if("w"in s&&"h"in s)a=s.w,A=s.h;else if("r"in s)a=s.r*2,A=s.r*2;else if("rX"in s&&"rY"in s)a=s.rX*2,A=s.rY*2;else continue;Math.abs(s.x-e.x)<a/2&&Math.abs(s.y-e.y)<A/2&&r.push(s)}return r},pHi=({elements:t,children:e,transform:n,primitives:o,selectedLayer:i,onMouseHoverOverPrimitives:r})=>{const[s,a]=ee.useState([]),[A,c]=ee.useState({x:0,y:0}),[l,{width:u,height:g}]=Aee();ee.useEffect(()=>{a([]),r([])},[i,o,r]);const h=ee.useMemo(()=>{const p=[];for(const m of s){if(m._element?.type==="pcb_via"||m._element?.type==="pcb_component"||m?.layer==="drill"||m?.is_hoverable===!1)continue;let _=null,f=0,I=0;if(m.pcb_drawing_type==="polygon"){const E=Afe(m.points);if(!E)continue;_=E.center,f=E.width,I=E.height}else if(m.pcb_drawing_type==="polygon_with_arcs"){const E=m.brep_shape.outer_ring.vertices.map(S=>({x:S.x,y:S.y})),B=Afe(E);if(!B)continue;_=B.center,f=B.width,I=B.height}else m.pcb_drawing_type==="line"?(_={x:(m.x1+m.x2)/2,y:(m.y1+m.y2)/2},f=Math.abs(m.x2-m.x1),I=Math.abs(m.y2-m.y1)):"x"in m&&"y"in m&&(_={x:m.x,y:m.y},f="w"in m?m.w:"r"in m?m.r*2:"rX"in m&&"rY"in m?m.rX*2:0,I="h"in m?m.h:"r"in m?m.r*2:"rX"in m&&"rY"in m?m.rY*2:0);if(!_)continue;const C=or(n,_),y={w:f*n.a,h:I*n.a},x=p.filter(E=>C.x===E.screen_x&&C.y===E.screen_y&&y.w===E.screen_w&&y.h===E.screen_h).length;p.push({...m,x:_.x,y:_.y,w:f,h:I,screen_x:C.x,screen_y:C.y,screen_w:y.w,screen_h:y.h,same_space_index:x})}return p},[s,n]),d=(p,m,_,f)=>{c({x:p,y:m});const I=or(K6(_),{x:p,y:m}),C=_$e(f,I,_,i);nHi(new Set(C.map(y=>y._pcb_drawing_object_id)),new Set(s.map(y=>y._pcb_drawing_object_id)))||(a(C),r(C))};return K.jsxs("div",{ref:l,style:{position:"relative",width:"100%",height:"100%"},onMouseMove:p=>{if(n){const m=p.currentTarget.getBoundingClientRect(),_=p.clientX-m.left,f=p.clientY-m.top;d(_,f,n,o)}},onTouchStart:p=>{if(n){const m=p.touches[0],_=p.currentTarget.getBoundingClientRect(),f=m.clientX-_.left,I=m.clientY-_.top;d(f,I,n,o)}},children:[e,K.jsx(hHi,{elements:t,mousePos:A,highlightedPrimitives:h}),n&&K.jsxs(K.Fragment,{children:[K.jsx(iHi,{elements:t,highlightedPrimitives:h,transform:n,containerWidth:u,containerHeight:g}),K.jsx(rHi,{elements:t,highlightedPrimitives:h,transform:n,containerWidth:u,containerHeight:g}),K.jsx(aHi,{elements:t,highlightedPrimitives:h,transform:n,containerWidth:u,containerHeight:g}),K.jsx(AHi,{elements:t,highlightedPrimitives:h,transform:n,containerWidth:u,containerHeight:g})]})]})},Phn=["rgb(255, 100, 100)","rgb(100, 255, 100)","rgb(100, 100, 255)","rgb(255, 255, 100)","rgb(255, 100, 255)","rgb(100, 255, 255)","rgb(255, 150, 100)","rgb(150, 100, 255)","rgb(100, 255, 150)","rgb(255, 100, 150)"],mHi=({children:t,transform:e=MP(),elements:n=[],hoveredComponentIds:o=[]})=>{const[i,{width:r,height:s}]=Aee(),a=ee.useRef(null),{is_showing_pcb_groups:A,pcb_group_view_mode:c,is_showing_group_anchor_offsets:l}=Kc(u=>({is_showing_pcb_groups:u.is_showing_pcb_groups,pcb_group_view_mode:u.pcb_group_view_mode,is_showing_group_anchor_offsets:u.is_showing_group_anchor_offsets}));return ee.useEffect(()=>{const u=a.current;if(!u||!r||!s)return;u.width=r,u.height=s;const g=u.getContext("2d");if(!g||(g.clearRect(0,0,r,s),!A))return;const h=n.filter(x=>x.type==="pcb_group"),d=n.filter(x=>x.type==="pcb_component"),p=n.filter(x=>x.type==="source_group"),m=new Map(p.map(x=>[x.source_group_id,x])),_=h.filter(x=>{if(x.name?.toLowerCase().includes("subpanel"))return!1;if(c==="all")return!0;if(!x.source_group_id)return!1;const E=m.get(x.source_group_id);return E?E.was_automatically_named!==!0:!1}),f=new Map;p.forEach(x=>{const E=x;if(E.parent_source_group_id){const B=f.get(E.parent_source_group_id)||[];B.push(x.source_group_id),f.set(E.parent_source_group_id,B)}});const I=x=>{const E=[],B=f.get(x)||[];for(const S of B)E.push(S),E.push(...I(S));return E},C=x=>{const E=p.find(B=>B.source_group_id===x);return E?.parent_source_group_id?1+C(E.parent_source_group_id):0},y=new Set;if(o.length>0)for(const x of d){if(!o.includes(x.pcb_component_id))continue;const E=x.positioned_relative_to_pcb_group_id??x.pcb_group_id;E&&y.add(E)}_.forEach((x,E)=>{let B=d.filter(Pe=>Pe.pcb_group_id===x.pcb_group_id);if(x.source_group_id){const Pe=I(x.source_group_id),He=h.filter(Re=>Re.source_group_id&&Pe.includes(Re.source_group_id));for(const Re of He){const Ee=d.filter(Te=>Te.pcb_group_id===Re.pcb_group_id);B=[...B,...Ee]}}let S,Q,w,M,k=!1;if(x.center&&x.width&&x.height){k=!0;const Pe=x.width/2,He=x.height/2;S=x.center.x-Pe,w=x.center.x+Pe,Q=x.center.y-He,M=x.center.y+He}else if(B.length===0||(S=1/0,Q=1/0,w=-1/0,M=-1/0,B.forEach(Pe=>{if(Pe.center&&typeof Pe.width=="number"&&typeof Pe.height=="number"){const He=Pe.center.x-Pe.width/2,Re=Pe.center.x+Pe.width/2,Ee=Pe.center.y+Pe.height/2,Te=Pe.center.y-Pe.height/2;S=Math.min(S,He),w=Math.max(w,Re),Q=Math.min(Q,Te),M=Math.max(M,Ee)}}),S===1/0||w===-1/0))return;const R=x.source_group_id?C(x.source_group_id):0,F=x.source_group_id?I(x.source_group_id).length>0:!1;if(!k){const Re=1+(F?.5:0);S-=Re,w+=Re,Q-=Re,M+=Re}const O=or(e,{x:S,y:M}),U=or(e,{x:w,y:M}),Y=or(e,{x:S,y:Q}),W=or(e,{x:w,y:Q}),te=Phn[E%Phn.length];g.strokeStyle=te,g.lineWidth=2;const j=Math.max(4,Math.min(12,8*Math.abs(e.a))),J=Math.max(2,Math.min(6,4*Math.abs(e.a))),oe=j*(F?1.3:1),ne=J;g.setLineDash([oe,ne]),g.beginPath(),g.moveTo(O.x,O.y),g.lineTo(U.x,U.y),g.lineTo(W.x,W.y),g.lineTo(Y.x,Y.y),g.closePath(),g.stroke();const ge=Math.max(8,Math.min(12,10*Math.abs(e.a))),ue=R==0||R==1?0:R*.11,_e=ge*(1-ue),le=4,fe=x.name||`Group ${E+1}`;g.font=`${_e}px sans-serif`,g.setLineDash([]);const ye=g.measureText(fe).width+le*2,Qe=_e+le*2,we=O.x-5,pe=O.y-5,ve=3;if(g.fillStyle="rgba(0, 0, 0, 0.8)",g.beginPath(),g.roundRect(we,pe-Qe,ye,Qe,ve),g.fill(),g.fillStyle=te,g.textAlign="left",g.textBaseline="middle",g.fillText(fe,we+le,pe-Qe/2),l&&y.has(x.pcb_group_id)&&!!x.anchor_position&&x.anchor_position){const Pe=Array.isArray(x.anchor_position)?{x:x.anchor_position[0]??0,y:x.anchor_position[1]??0}:{x:x.anchor_position.x,y:x.anchor_position.y},He=or(e,Pe);g.strokeStyle="white",g.lineWidth=1.5,g.setLineDash([]);const Re=Math.max(4,Math.min(8,6*Math.abs(e.a)));g.beginPath(),g.moveTo(He.x-Re,He.y),g.lineTo(He.x+Re,He.y),g.stroke(),g.beginPath(),g.moveTo(He.x,He.y-Re),g.lineTo(He.x,He.y+Re),g.stroke()}})},[n,e,r,s,A,c,l,o]),K.jsxs("div",{ref:i,style:{position:"relative",width:"100%",height:"100%"},children:[t,K.jsx("canvas",{ref:a,style:{position:"absolute",top:0,left:0,pointerEvents:"none",zIndex:Tu.pcbGroupOverlay,display:A?"block":"none"}})]})},_Hi=({transform:t,soup:e,children:n})=>{const o=Kc(a=>a.is_showing_rats_nest),{netMap:i,idToNetMap:r}=ee.useMemo(()=>Gdn(e||[]),[e]),s=ee.useMemo(()=>{if(!e||!o)return[];const a=g=>{const h=OU(e)[g.replace(/_\d+$/,"")].get(g);return h&&"x"in h&&"y"in h?{x:h.x,y:h.y}:null},A=(g,h)=>{const d=i[h]||[];let p=null,m=1/0;return d.forEach(_=>{const f=a(_);if(f){const I=Math.sqrt((g.x-f.x)**2+(g.y-f.y)**2);I<m&&I>0&&(m=I,p=f)}}),p},c=OU(e).pcb_port.list(),l=OU(e).source_trace.list(),u=[];return c.forEach((g,h)=>{const d=r[g.pcb_port_id];let p=!1;for(const f of l)f.connected_source_port_ids.includes(g.source_port_id)&&f.connected_source_net_ids.length>0&&(p=!0);if(!d)return;const m={x:g.x,y:g.y},_=A(m,d);_&&u.push({key:`${g.pcb_port_id}-${h}`,startPoint:m,endPoint:_,isInNet:p})}),u},[e,i,r,o]);return!e||!o?n:(t||(t=MP()),K.jsxs("div",{style:{position:"relative"},children:[n,K.jsx("svg",{style:{position:"absolute",left:0,top:0,width:"100%",height:"100%",pointerEvents:"none",opacity:.5,zIndex:Tu.ratsNestOverlay},children:s.map(({key:a,startPoint:A,endPoint:c,isInNet:l})=>{const u=or(t,A),g=or(t,c);return K.jsx("line",{x1:u.x,y1:u.y,x2:g.x,y2:g.y,stroke:"white",strokeWidth:"1",strokeDasharray:l?"6,6":void 0},a)})})]}))},fHi={version:"1.11.407"},X6=(t,e,n)=>{const o=Kc(s=>s.is_mouse_over_container),i=ee.useRef(o),r=ee.useRef(e);ee.useEffect(()=>{i.current=o},[o]),ee.useEffect(()=>{r.current=e},[e]),ee.useEffect(()=>{if(!t)return;const s=a=>{const A=a.target;if(A.tagName==="INPUT"||A.tagName==="TEXTAREA"||A.isContentEditable)return;const c=t.split("+"),l=c.includes("ctrl"),u=c.includes("shift"),g=c.includes("alt"),h=c.includes("meta"),d=c[c.length-1],p=n?.current?n.current.contains(document.activeElement)||document.activeElement===n.current:!1;(i.current||p)&&(!l||a.ctrlKey)&&(!u||a.shiftKey)&&(!g||a.altKey)&&(!h||a.metaKey)&&a.key.toLowerCase()===d.toLowerCase()&&(a.preventDefault(),r.current())};return window.addEventListener("keydown",s),()=>{window.removeEventListener("keydown",s)}},[t])},IHi=()=>{const[t,e]=ee.useState(!1);return ee.useEffect(()=>{const n=()=>{e(window.innerWidth<=768)};return n(),window.addEventListener("resize",n),()=>window.removeEventListener("resize",n)},[]),t},gee=(t,e={stopPropagation:!0})=>{const n=ee.useRef(0),o=ee.useCallback(s=>{e.stopPropagation&&s.stopPropagation();const a=Date.now();a-n.current<300||(n.current=a,t?.(s))},[t,e.stopPropagation]),i=ee.useCallback(s=>{s.preventDefault(),o(s)},[o]);return{onClick:o,onTouchEnd:i,style:{touchAction:"manipulation"}}},cfe=wU`
5578
+ `,tHi=({children:t,transform:e=MP(),elements:n})=>{const o=ee.useRef(null),{isShowingDRCErrors:i,hoveredErrorId:r,focusedErrorId:s}=Kc(p=>({isShowingDRCErrors:p.is_showing_drc_errors,hoveredErrorId:p.hovered_error_id,focusedErrorId:p.focused_error_id})),a=s??r;if(!n)return K.jsx("div",{style:{position:"relative"},ref:o,children:t});const A=n.filter(p=>p.type==="pcb_trace_error"&&!p.message?.includes("Multiple components found with name")),c=n.filter(p=>p.type==="pcb_via_clearance_error"),l=n.filter(p=>p.type==="pcb_trace_error"&&p.message?.includes("Multiple components found with name")),u=Ydn(n),g=zdn(n,a),h=p=>{const m=aFi({error:p,indexes:u});if(!m||typeof m.x!="number"||typeof m.y!="number")return null;const _=or(e,m);return Number.isNaN(_.x)||Number.isNaN(_.y)?null:_};let d=null;return g&&(d=h(g)),K.jsxs("div",{style:{position:"relative"},ref:o,children:[t,A.map((p,m)=>{const _=GU(p,m),f=a===_;if(!f&&!i)return null;const I=h(p);if(!I)return null;const C=d$e(I,o);return K.jsxs(ee.Fragment,{children:[K.jsx(Qhn,{errorCenter:I,isHighlighted:f}),K.jsx("div",{style:{position:"absolute",left:I.x-15,top:I.y-15,width:30,height:30,zIndex:Tu.errorOverlay+5,cursor:"pointer",borderRadius:"50%"},onMouseEnter:y=>{const x=y.currentTarget.nextElementSibling;if(x){const E=x.querySelector(".error-message");E&&(E.style.opacity="1")}},onMouseLeave:y=>{if(!f){const x=y.currentTarget.nextElementSibling;if(x){const E=x.querySelector(".error-message");E&&(E.style.opacity="0")}}}}),K.jsx("div",{style:{position:"absolute",zIndex:f?200:100,left:C.left,top:C.top,color:f?"#ff4444":"red",textAlign:"center",fontFamily:"sans-serif",fontSize:12,display:i||f?"flex":"none",flexDirection:"column",alignItems:"center",pointerEvents:"none",transform:C.transform},children:K.jsx("div",{className:`error-message ${h$e}`,style:{opacity:f?1:0,border:`1px solid ${f?"#ff4444":"red"}`},children:p.message})})]},_)}),c.map((p,m)=>{const _=GU(p,m),f=a===_;if(!f&&!i)return null;const I=h(p);if(!I)return null;const C=d$e({x:I.x,y:I.y},o);return K.jsxs(ee.Fragment,{children:[K.jsx(Qhn,{errorCenter:I,isHighlighted:f}),K.jsx("div",{style:{position:"absolute",left:I.x-15,top:I.y-15,width:30,height:30,zIndex:Tu.errorOverlay+5,cursor:"pointer",borderRadius:"50%"},onMouseEnter:y=>{const x=y.currentTarget.nextElementSibling;if(x){const E=x.querySelector(".error-message");E&&(E.style.opacity="1")}},onMouseLeave:y=>{if(!f){const x=y.currentTarget.nextElementSibling;if(x){const E=x.querySelector(".error-message");E&&(E.style.opacity="0")}}}}),K.jsx("div",{style:{position:"absolute",zIndex:f?Tu.errorOverlay+10:Tu.errorOverlay+1,left:C.left,top:C.top,color:f?"#ff4444":"red",textAlign:"center",fontFamily:"sans-serif",fontSize:12,display:"flex",flexDirection:"column",alignItems:"center",pointerEvents:"none",transform:C.transform},children:K.jsx("div",{className:`error-message ${h$e}`,style:{opacity:f?1:0,border:`1px solid ${f?"#ff4444":"red"}`},children:p.message})})]},_)}),l.map((p,m)=>{const _=p.component_name||p.message?.match(/name "([^"]+)"/)?.[1];if(!_)return null;const f=n?.filter(y=>y.type==="source_component"&&y.name===_||y.type==="pcb_component"&&n?.find(x=>x.type==="source_component"&&x.source_component_id===y.source_component_id&&x.name===_))||[],I=GU(p,m),C=a===I;return!C&&!i?null:f.map((y,x)=>{let E={x:0,y:0};if(y.type==="pcb_component")E=y.center||{x:0,y:0};else if(y.type==="source_component"){const F=n?.find(O=>O.type==="pcb_component"&&O.source_component_id===y.source_component_id);F&&F.type==="pcb_component"&&(E=F.center||{x:0,y:0})}const B=or(e,E);if(Number.isNaN(B.x)||Number.isNaN(B.y))return null;const S=Math.abs(e.a),k=Math.max(8,Math.min(30,.5*S)),R=d$e(B,o);return K.jsxs(ee.Fragment,{children:[K.jsx("svg",{style:{position:"absolute",left:0,top:0,pointerEvents:"none",mixBlendMode:"difference",zIndex:Tu.errorOverlay},width:"100%",height:"100%",children:C?K.jsx("polygon",{points:`${B.x},${B.y-k*1.25} ${B.x+k},${B.y} ${B.x},${B.y+k*1.25} ${B.x-k},${B.y}`,fill:"#ff4444"}):K.jsx("circle",{cx:B.x,cy:B.y,r:k,fill:"none",stroke:C?"#ff4444":"red",strokeWidth:C?Math.max(2,k*.15):Math.max(1,k*.1),opacity:1})}),K.jsx("div",{style:{position:"absolute",left:B.x-(k+10),top:B.y-(k+10),width:(k+10)*2,height:(k+10)*2,zIndex:Tu.errorOverlay+5,cursor:"pointer",borderRadius:"50%"},onMouseEnter:F=>{const O=F.currentTarget.nextElementSibling;if(O){const U=O.querySelector(".error-message");U&&(U.style.opacity="1")}},onMouseLeave:F=>{if(!C){const O=F.currentTarget.nextElementSibling;if(O){const U=O.querySelector(".error-message");U&&(U.style.opacity="0")}}}}),K.jsx("div",{style:{position:"absolute",zIndex:C?Tu.errorOverlay+20:Tu.errorOverlay+10,left:R.left,top:R.top,color:C?"#ff4444":"red",textAlign:"center",fontFamily:"sans-serif",fontSize:12,display:i||C?"flex":"none",flexDirection:"column",alignItems:"center",pointerEvents:"none",transform:R.transform},children:K.jsx("div",{className:`error-message ${h$e}`,style:{opacity:C?1:0,border:`1px solid ${C?"#ff4444":"red"}`},children:p.message})})]},`${I}_${x}`)})}),d&&K.jsx(eHi,{center:d})]})};function nHi(t,e){return t.size!==e.size?!1:Array.from(t).every(n=>e.has(n))}var GP=t=>t?.type==="pcb_component",vhn=t=>t?.type==="pcb_group",oHi=t=>t?.type==="pcb_panel",p$e=t=>t?.type==="pcb_board",Gg={MIN_LINE_LENGTH_FOR_LABEL:40,LABEL_OFFSET_ABOVE:2,LABEL_OFFSET_BELOW:-18,LABEL_OFFSET_RIGHT:8,LABEL_OFFSET_LEFT:-120,Y_LABEL_MIN_WIDTH:110,LINE_STROKE_WIDTH:1.5,LINE_DASH_PATTERN:"4,4",COMPONENT_MARKER_RADIUS:3,LABEL_FONT_SIZE:11,ANCHOR_MARKER_SIZE:6,ANCHOR_MARKER_STROKE_WIDTH:1.5},DE={OFFSET_LINE:"white",COMPONENT_MARKER_FILL:"#66ccff",COMPONENT_MARKER_STROKE:"white",LABEL_TEXT:"white"},m$e=({targets:t,transform:e,containerWidth:n,containerHeight:o})=>{if(t.length===0)return null;const i={color:DE.LABEL_TEXT,mixBlendMode:"difference",pointerEvents:"none",fontSize:Gg.LABEL_FONT_SIZE,fontFamily:"monospace",fontWeight:"bold"},r=new Map;return t.forEach(s=>{if(!r.has(s.anchor_id)){const a=or(e,s.anchor);r.set(s.anchor_id,a)}}),K.jsx("div",{style:{position:"absolute",left:0,top:0,width:n,height:o,overflow:"hidden",pointerEvents:"none",zIndex:Tu.dimensionOverlay},children:K.jsxs("svg",{style:{position:"absolute",left:0,top:0,pointerEvents:"none"},width:n,height:o,children:[t.map(s=>{const a=s.anchor,A=s.anchor_id,c=s.target,l=r.get(A),u=or(e,c),g=c.x-a.x,h=c.y-a.y,d=Math.abs(u.x-l.x),p=Math.abs(u.y-l.y),m=u.y<l.y,_=u.x>l.x,f=m?Gg.LABEL_OFFSET_ABOVE:Gg.LABEL_OFFSET_BELOW,I=_?Gg.LABEL_OFFSET_RIGHT:Gg.LABEL_OFFSET_LEFT,C=d>Gg.MIN_LINE_LENGTH_FOR_LABEL,y=p>Gg.MIN_LINE_LENGTH_FOR_LABEL,x=`${s.display_offset_x??g.toFixed(2)}mm`,E=`${s.display_offset_y??h.toFixed(2)}mm`;return K.jsxs("g",{children:[K.jsx("line",{x1:l.x,y1:l.y,x2:u.x,y2:l.y,stroke:DE.OFFSET_LINE,strokeWidth:Gg.LINE_STROKE_WIDTH,strokeDasharray:Gg.LINE_DASH_PATTERN}),K.jsx("line",{x1:u.x,y1:l.y,x2:u.x,y2:u.y,stroke:DE.OFFSET_LINE,strokeWidth:Gg.LINE_STROKE_WIDTH,strokeDasharray:Gg.LINE_DASH_PATTERN}),s.type==="component"||s.type==="board"?K.jsx("circle",{cx:u.x,cy:u.y,r:Gg.COMPONENT_MARKER_RADIUS,fill:DE.COMPONENT_MARKER_FILL,stroke:DE.COMPONENT_MARKER_STROKE,strokeWidth:1}):K.jsxs(K.Fragment,{children:[K.jsx("line",{x1:u.x-Gg.ANCHOR_MARKER_SIZE,y1:u.y,x2:u.x+Gg.ANCHOR_MARKER_SIZE,y2:u.y,stroke:DE.OFFSET_LINE,strokeWidth:Gg.ANCHOR_MARKER_STROKE_WIDTH}),K.jsx("line",{x1:u.x,y1:u.y-Gg.ANCHOR_MARKER_SIZE,x2:u.x,y2:u.y+Gg.ANCHOR_MARKER_SIZE,stroke:DE.OFFSET_LINE,strokeWidth:Gg.ANCHOR_MARKER_STROKE_WIDTH})]}),C&&K.jsx("foreignObject",{x:Math.min(l.x,u.x),y:l.y+f,width:Math.abs(u.x-l.x),height:20,style:{overflow:"visible"},children:K.jsx("div",{style:{...i,textAlign:"center"},children:x})}),y&&K.jsx("foreignObject",{x:u.x+I,y:Math.min(l.y,u.y),width:Gg.Y_LABEL_MIN_WIDTH,height:Math.abs(u.y-l.y),style:{overflow:"visible"},children:K.jsx("div",{style:{...i,display:"flex",alignItems:"center",justifyContent:_?"flex-start":"flex-end",whiteSpace:"nowrap",padding:"0 4px",height:"100%"},children:E})})]},s.id)}),Array.from(r.entries()).map(([s,a])=>K.jsxs("g",{children:[K.jsx("line",{x1:a.x-Gg.ANCHOR_MARKER_SIZE,y1:a.y,x2:a.x+Gg.ANCHOR_MARKER_SIZE,y2:a.y,stroke:DE.OFFSET_LINE,strokeWidth:Gg.ANCHOR_MARKER_STROKE_WIDTH}),K.jsx("line",{x1:a.x,y1:a.y-Gg.ANCHOR_MARKER_SIZE,x2:a.x,y2:a.y+Gg.ANCHOR_MARKER_SIZE,stroke:DE.OFFSET_LINE,strokeWidth:Gg.ANCHOR_MARKER_STROKE_WIDTH})]},`anchor-${s}`))]})})},iHi=({elements:t,highlightedPrimitives:e,transform:n,containerWidth:o,containerHeight:i})=>{const r=t.filter(_=>p$e(_)),s=t.filter(_=>GP(_)),a=t.filter(_=>vhn(_)),A=e.map(_=>GP(_._parent_pcb_component)?_._parent_pcb_component.pcb_component_id:GP(_._element)?_._element.pcb_component_id:null).filter(_=>!!_),c=new Set;if(A.forEach(_=>{const f=s.find(I=>I.pcb_component_id===_);f?.pcb_group_id&&c.add(f.pcb_group_id)}),!Kc(_=>_.is_showing_group_anchor_offsets)&&A.length===0)return null;const u=s.map(_=>{const f=_.positioned_relative_to_pcb_board_id;if(!f)return null;const I=r.find(C=>C.pcb_board_id===f);return I?{component:_,board:I,type:"component"}:null}).filter(_=>!!_),g=a.map(_=>{const f=_.positioned_relative_to_pcb_board_id;if(!f||!_.center)return null;const I=r.find(C=>C.pcb_board_id===f);return I?{group:_,board:I,type:"group"}:null}).filter(_=>!!_),h=[...u,...g];if(h.length===0)return null;const d=A.length===0,p=h.filter(_=>_.type==="component"?d||A.includes(_.component.pcb_component_id):d||c.has(_.group.pcb_group_id));if(p.length===0)return null;const m=p.map(_=>_.type==="component"?{id:`${_.board.pcb_board_id}-${_.component.pcb_component_id}-${_.type}`,anchor:_.board.center,anchor_id:_.board.pcb_board_id,target:_.component.center,type:"component",display_offset_x:_.component.display_offset_x,display_offset_y:_.component.display_offset_y}:{id:`${_.board.pcb_board_id}-${_.group.pcb_group_id}-${_.type}`,anchor:_.board.center,anchor_id:_.board.pcb_board_id,target:{x:_.group.anchor_position?.x??_.group.center.x,y:_.group.anchor_position?.y??_.group.center.y},type:"group",display_offset_x:_.group.display_offset_x,display_offset_y:_.group.display_offset_y}).filter(_=>!!_);return K.jsx(m$e,{targets:m,transform:n,containerWidth:o,containerHeight:i})},rHi=({elements:t,highlightedPrimitives:e,transform:n,containerWidth:o,containerHeight:i})=>{const r=t.filter(_=>vhn(_)),s=t.filter(_=>GP(_)),a=e.map(_=>GP(_._parent_pcb_component)?_._parent_pcb_component.pcb_component_id:GP(_._element)?_._element.pcb_component_id:null).filter(_=>!!_),A=(_,f)=>{if(f.has(_))return;f.add(_);const I=r.find(C=>C.pcb_group_id===_);I?.position_mode==="relative_to_group_anchor"&&I.positioned_relative_to_pcb_group_id&&A(I.positioned_relative_to_pcb_group_id,f)},c=new Set;if(a.forEach(_=>{const f=s.find(I=>I.pcb_component_id===_);f&&(f.position_mode==="relative_to_group_anchor"&&f.positioned_relative_to_pcb_group_id&&A(f.positioned_relative_to_pcb_group_id,c),f.pcb_group_id&&A(f.pcb_group_id,c))}),!Kc(_=>_.is_showing_group_anchor_offsets)&&a.length===0)return null;const u=s.map(_=>{if(_.position_mode==="relative_to_group_anchor"&&_.positioned_relative_to_pcb_group_id){const f=r.find(I=>I.pcb_group_id===_.positioned_relative_to_pcb_group_id);return f&&f.anchor_position?{component:_,parentGroup:f,type:"component"}:null}if(_.pcb_group_id){const f=r.find(I=>I.pcb_group_id===_.pcb_group_id);return f&&f.anchor_position?{component:_,parentGroup:f,type:"component"}:null}return null}).filter(_=>!!_),g=r.map(_=>{if(_.position_mode==="relative_to_group_anchor"&&_.positioned_relative_to_pcb_group_id){const f=r.find(I=>I.pcb_group_id===_.positioned_relative_to_pcb_group_id);if(f&&f.anchor_position&&_.anchor_position)return{group:_,parentGroup:f,type:"group"}}return null}).filter(_=>!!_),h=[...u,...g];if(h.length===0)return null;const d=a.length===0,p=h.filter(_=>_.type==="component"?d||a.includes(_.component.pcb_component_id):d||c.has(_.group.pcb_group_id)||c.has(_.parentGroup.pcb_group_id));if(p.length===0)return null;const m=p.map(_=>{const f=_.parentGroup.anchor_position;return f?_.type==="component"?_.component.center?{id:`${_.parentGroup.pcb_group_id}-${_.component.pcb_component_id}-${_.type}`,anchor:f,anchor_id:_.parentGroup.pcb_group_id,target:_.component.center,type:"component",display_offset_x:_.component.display_offset_x,display_offset_y:_.component.display_offset_y}:null:_.group.anchor_position?{id:`${_.parentGroup.pcb_group_id}-${_.group.pcb_group_id}-${_.type}`,anchor:f,anchor_id:_.parentGroup.pcb_group_id,target:_.group.anchor_position,type:"group",display_offset_x:_.group.display_offset_x,display_offset_y:_.group.display_offset_y}:null:null}).filter(_=>!!_);return K.jsx(m$e,{targets:m,transform:n,containerWidth:o,containerHeight:i})},sHi=(t,e)=>{const n=t.pcb_component_id,o=e.filter(i=>(i.type==="pcb_smtpad"||i.type==="pcb_plated_hole")&&i.pcb_component_id===n||i.type==="pcb_hole"&&i.pcb_component_id===n);return o.length===0?A$e([t]):A$e(o)},aHi=({elements:t,highlightedPrimitives:e,transform:n,containerWidth:o,containerHeight:i})=>{const r=new Map;for(const a of e)GP(a._parent_pcb_component)&&r.set(a._parent_pcb_component.pcb_component_id,a._parent_pcb_component),GP(a._element)&&r.set(a._element.pcb_component_id,a._element);if(r.size===0)return null;const s=[];for(const a of r.values()){const A=sHi(a,t);if(!A)continue;const c=a.positioned_relative_to_pcb_group_id??a.pcb_group_id,l=c?OU(t).pcb_group.get(c):null;s.push({component:a,bbox:A,group:l})}return s.length===0?null:K.jsx("div",{style:{position:"absolute",left:0,top:0,width:o,height:i,overflow:"hidden",pointerEvents:"none",zIndex:Tu.dimensionOverlay},children:K.jsx("svg",{style:{position:"absolute",left:0,top:0,pointerEvents:"none"},width:o,height:i,children:s.map(({component:a,bbox:A,group:c})=>{const l=or(n,{x:A.minX,y:A.maxY}),u=or(n,{x:A.maxX,y:A.minY}),g={x:Math.min(l.x,u.x),y:Math.min(l.y,u.y),width:Math.abs(u.x-l.x),height:Math.abs(u.y-l.y)},h=a.center??{x:(A.minX+A.maxX)/2,y:(A.minY+A.maxY)/2},d=or(n,h);return K.jsxs("g",{children:[K.jsx("rect",{x:g.x,y:g.y,width:g.width,height:g.height,fill:"none",stroke:"white",strokeWidth:1.5,strokeDasharray:"4,4"}),K.jsx("line",{x1:d.x-6,y1:d.y,x2:d.x+6,y2:d.y,stroke:DE.COMPONENT_MARKER_STROKE,strokeWidth:1.5}),K.jsx("line",{x1:d.x,y1:d.y-6,x2:d.x,y2:d.y+6,stroke:DE.COMPONENT_MARKER_STROKE,strokeWidth:1.5}),K.jsx("circle",{cx:d.x,cy:d.y,r:Gg.COMPONENT_MARKER_RADIUS,fill:DE.COMPONENT_MARKER_FILL,stroke:DE.COMPONENT_MARKER_STROKE,strokeWidth:1})]},a.pcb_component_id)})})})},AHi=({elements:t,highlightedPrimitives:e,transform:n,containerWidth:o,containerHeight:i})=>{const r=t.filter(h=>oHi(h)),s=t.filter(h=>p$e(h)),a=e.map(h=>p$e(h._element)?h._element.pcb_board_id:null).filter(h=>!!h);if(!Kc(h=>h.is_showing_group_anchor_offsets)&&a.length===0)return null;const c=s.map(h=>{const d=h.pcb_panel_id,p=h.position_mode;if(!d||p!=="relative_to_panel_anchor")return null;const m=r.find(_=>_.pcb_panel_id===d);return m?{board:h,panel:m,type:"board"}:null}).filter(h=>!!h);if(c.length===0)return null;const l=a.length===0,u=c.filter(h=>l||a.includes(h.board.pcb_board_id));if(u.length===0)return null;const g=u.map(h=>h.board.center?{id:`${h.panel.pcb_panel_id}-${h.board.pcb_board_id}-${h.type}`,anchor:h.panel.center,anchor_id:h.panel.pcb_panel_id,target:h.board.center,type:"board",display_offset_x:h.board.display_offset_x,display_offset_y:h.board.display_offset_y}:null).filter(h=>!!h);return K.jsx(m$e,{targets:g,transform:n,containerWidth:o,containerHeight:i})};function cHi(t){const{primitives:e,is_showing_multiple_traces_length:n,elements:o}=t,i=e.filter(A=>A._element.type==="pcb_trace"),r=o.filter(A=>A.type==="source_trace"),s=e.filter(A=>A._element.type!=="pcb_trace"),a=i.filter(A=>r.some(l=>A._element.source_trace_id===l.source_trace_id&&l.max_length!==void 0)||l$e({primitiveElement:A._element,elements:o})!==null);if(!n)return[...s,...a];if(i.length>1){const A=i.reduce((c,l)=>{const u=c._element.trace_length;return l._element.trace_length<u?l:c},i[0]);return[...s,A]}return e}var lHi={position:"absolute",left:0,top:0,pointerEvents:"none",color:"red",fontFamily:"sans-serif",fontSize:12,textShadow:"0 0 2px black"},uHi=t=>{const{_element:e,_parent_pcb_component:n,_parent_source_component:o,_source_port:i}=t;switch(e.type){case"pcb_trace":return e.trace_length?`${e.trace_length.toFixed(3)}`:"";case"pcb_smtpad":case"pcb_plated_hole":{const r=[],s=Array.from(new Set((e.port_hints??[]).concat(i?.port_hints??[]))).filter(A=>!/^[0-9]+$/.test(A)).filter(A=>!A.includes("unnamed_")).sort((A,c)=>c.localeCompare(A)),a=o&&"name"in o&&o.name&&!o.name.includes("unnamed_")?o.name:null;return s.length>0?a?r.push(...s.map(A=>`${a}.${A}`)):r.push(...s):a&&r.push(a),r.join(", ")}default:return""}},gHi={top:"red",bottom:"aqua"},dHi=({primitive:t,mousePos:e,elements:n})=>{const[o,i]=ee.useState(!1),r=t._element;ee.useEffect(()=>{setTimeout(()=>{i(!0)},100)},[]);const[s,a,A,c]=[t.screen_x,t.screen_y,t.screen_w,t.screen_h],l=t.same_space_index??0,u=26,g=gHi[t?._element?.layer]??"red";let h=0;if(r.type==="pcb_smtpad"&&r?.shape==="rotated_rect"?h=r?.ccw_rotation??0:(r.type==="pcb_smtpad"&&(r?.shape==="pill"||r?.shape==="rotated_pill")&&"ccw_rotation"in t||r.type==="pcb_plated_hole"&&(r?.shape==="pill"||r?.shape==="oval")&&"ccw_rotation"in t)&&(h=r.ccw_rotation??0),r.type==="pcb_trace"){const m=Wdn({primitiveElement:r,elements:n});return m?K.jsx("div",{style:{zIndex:Tu.elementOverlay,position:"absolute",left:e.x+12,top:e.y+12,color:g,pointerEvents:"none"},children:K.jsxs("div",{style:{backgroundColor:"#f2efcc",color:m.isOverLength?"red":"black",textShadow:"none",WebkitFontSmoothing:"antialiased",MozOsxFontSmoothing:"grayscale",padding:"4px 6px",borderRadius:"4px",fontSize:"11px",lineHeight:1.2,textAlign:"left",whiteSpace:"nowrap"},children:[m.text&&K.jsx("div",{children:m.text}),m.name&&K.jsx("div",{style:{marginTop:m.text?"2px":0},children:m.name})]})}):null}const d=uHi(t);return d.trim().length===0?null:K.jsx("div",{style:{zIndex:Tu.elementOverlay,position:"absolute",left:s-A/2-8,top:a-c/2-8,width:A+16,height:c+16,color:g,transform:`rotate(${-h}deg)`,transformOrigin:"center center"},children:K.jsx("div",{style:{width:o?`calc(100% + ${u*2*l}px)`:"100%",height:o?`calc(100% + ${u*2*l}px)`:"100%",marginLeft:o?`${-u*l}px`:0,marginTop:o?`${-u*l}px`:0,border:`1px solid ${g}`,opacity:o||l===0?1:0,transition:"width 0.2s, height 0.2s, margin-left 0.2s, margin-top 0.2s, opacity 0.2s"},children:K.jsx("div",{style:{position:"absolute",bottom:c+20+u*l,marginRight:o?`${-u*l}px`:0,marginBottom:o?0:-u*l,transition:"margin-right 0.2s, margin-bottom 0.2s",backgroundColor:"#f2efcc",color:"black",textShadow:"none",WebkitFontSmoothing:"antialiased",MozOsxFontSmoothing:"grayscale",padding:"6px 6px",borderRadius:"6px",fontSize:"14px",transform:`rotate(${h}deg)`,minWidth:"45px",textAlign:"center"},children:d})})})},hHi=({highlightedPrimitives:t,mousePos:e,elements:n})=>{const[o,i]=Kc(a=>[a.is_moving_component,a.is_showing_multiple_traces_length]),r=t.some(a=>a._element.type==="pcb_smtpad")&&t.some(a=>a._element.type==="pcb_trace");let s=t;return r&&(s=s.filter(a=>a._element.type==="pcb_smtpad")),s=cHi({primitives:s,is_showing_multiple_traces_length:i,elements:n}),K.jsx("div",{style:lHi,children:!o&&s.map(a=>K.jsx(dHi,{primitive:a,mousePos:e,elements:n},a._pcb_drawing_object_id))})},Afe=t=>{if(t.length===0)return null;let e=t[0].x,n=t[0].y,o=t[0].x,i=t[0].y;for(const r of t)r.x<e&&(e=r.x),r.y<n&&(n=r.y),r.x>o&&(o=r.x),r.y>i&&(i=r.y);return{center:{x:(e+o)/2,y:(n+i)/2},width:o-e,height:i-n}},whn=(t,e)=>{if(e.length<3)return!1;let n=!1;for(let o=0,i=e.length-1;o<e.length;i=o++){const r=e[o].x,s=e[o].y,a=e[i].x,A=e[i].y;s>t.y!=A>t.y&&t.x<(a-r)*(t.y-s)/(A-s||Number.EPSILON)+r&&(n=!n)}return n},_$e=(t,e,n,o,i=!1)=>{const r=[];for(const s of t){if(!s._element||!i&&s._element.type==="pcb_trace"&&s.layer!==o)continue;if("x1"in s&&s._element?.type==="pcb_trace"){const c=qd({x:e.x,y:e.y},{x:s.x1,y:s.y1},{x:s.x2,y:s.y2}),l=s.width||.5,u=Math.max(l*25,2)/n.a;c<u&&r.push(s);continue}if(s.pcb_drawing_type==="polygon"){const c=s.points.map(u=>({x:lt.parse(u.x),y:lt.parse(u.y)})),l=Afe(c);if(!l||e.x<l.center.x-l.width/2||e.x>l.center.x+l.width/2||e.y<l.center.y-l.height/2||e.y>l.center.y+l.height/2)continue;whn(e,c)&&r.push(s);continue}if(s.pcb_drawing_type==="polygon_with_arcs"){const c=s.brep_shape.outer_ring.vertices.map(u=>({x:lt.parse(u.x),y:lt.parse(u.y)})),l=Afe(c);if(!l||e.x<l.center.x-l.width/2||e.x>l.center.x+l.width/2||e.y<l.center.y-l.height/2||e.y>l.center.y+l.height/2)continue;whn(e,c)&&r.push(s);continue}if(!("x"in s&&"y"in s))continue;let a=0,A=0;if("w"in s&&"h"in s)a=s.w,A=s.h;else if("r"in s)a=s.r*2,A=s.r*2;else if("rX"in s&&"rY"in s)a=s.rX*2,A=s.rY*2;else continue;Math.abs(s.x-e.x)<a/2&&Math.abs(s.y-e.y)<A/2&&r.push(s)}return r},pHi=({elements:t,children:e,transform:n,primitives:o,selectedLayer:i,onMouseHoverOverPrimitives:r})=>{const[s,a]=ee.useState([]),[A,c]=ee.useState({x:0,y:0}),[l,{width:u,height:g}]=Aee();ee.useEffect(()=>{a([]),r([])},[i,o,r]);const h=ee.useMemo(()=>{const p=[];for(const m of s){if(m._element?.type==="pcb_via"||m._element?.type==="pcb_component"||m?.layer==="drill"||m?.is_hoverable===!1)continue;let _=null,f=0,I=0;if(m.pcb_drawing_type==="polygon"){const E=Afe(m.points);if(!E)continue;_=E.center,f=E.width,I=E.height}else if(m.pcb_drawing_type==="polygon_with_arcs"){const E=m.brep_shape.outer_ring.vertices.map(S=>({x:S.x,y:S.y})),B=Afe(E);if(!B)continue;_=B.center,f=B.width,I=B.height}else m.pcb_drawing_type==="line"?(_={x:(m.x1+m.x2)/2,y:(m.y1+m.y2)/2},f=Math.abs(m.x2-m.x1),I=Math.abs(m.y2-m.y1)):"x"in m&&"y"in m&&(_={x:m.x,y:m.y},f="w"in m?m.w:"r"in m?m.r*2:"rX"in m&&"rY"in m?m.rX*2:0,I="h"in m?m.h:"r"in m?m.r*2:"rX"in m&&"rY"in m?m.rY*2:0);if(!_)continue;const C=or(n,_),y={w:f*n.a,h:I*n.a},x=p.filter(E=>C.x===E.screen_x&&C.y===E.screen_y&&y.w===E.screen_w&&y.h===E.screen_h).length;p.push({...m,x:_.x,y:_.y,w:f,h:I,screen_x:C.x,screen_y:C.y,screen_w:y.w,screen_h:y.h,same_space_index:x})}return p},[s,n]),d=(p,m,_,f)=>{c({x:p,y:m});const I=or(K6(_),{x:p,y:m}),C=_$e(f,I,_,i);nHi(new Set(C.map(y=>y._pcb_drawing_object_id)),new Set(s.map(y=>y._pcb_drawing_object_id)))||(a(C),r(C))};return K.jsxs("div",{ref:l,style:{position:"relative",width:"100%",height:"100%"},onMouseMove:p=>{if(n){const m=p.currentTarget.getBoundingClientRect(),_=p.clientX-m.left,f=p.clientY-m.top;d(_,f,n,o)}},onTouchStart:p=>{if(n){const m=p.touches[0],_=p.currentTarget.getBoundingClientRect(),f=m.clientX-_.left,I=m.clientY-_.top;d(f,I,n,o)}},children:[e,K.jsx(hHi,{elements:t,mousePos:A,highlightedPrimitives:h}),n&&K.jsxs(K.Fragment,{children:[K.jsx(iHi,{elements:t,highlightedPrimitives:h,transform:n,containerWidth:u,containerHeight:g}),K.jsx(rHi,{elements:t,highlightedPrimitives:h,transform:n,containerWidth:u,containerHeight:g}),K.jsx(aHi,{elements:t,highlightedPrimitives:h,transform:n,containerWidth:u,containerHeight:g}),K.jsx(AHi,{elements:t,highlightedPrimitives:h,transform:n,containerWidth:u,containerHeight:g})]})]})},Phn=["rgb(255, 100, 100)","rgb(100, 255, 100)","rgb(100, 100, 255)","rgb(255, 255, 100)","rgb(255, 100, 255)","rgb(100, 255, 255)","rgb(255, 150, 100)","rgb(150, 100, 255)","rgb(100, 255, 150)","rgb(255, 100, 150)"],mHi=({children:t,transform:e=MP(),elements:n=[],hoveredComponentIds:o=[]})=>{const[i,{width:r,height:s}]=Aee(),a=ee.useRef(null),{is_showing_pcb_groups:A,pcb_group_view_mode:c,is_showing_group_anchor_offsets:l}=Kc(u=>({is_showing_pcb_groups:u.is_showing_pcb_groups,pcb_group_view_mode:u.pcb_group_view_mode,is_showing_group_anchor_offsets:u.is_showing_group_anchor_offsets}));return ee.useEffect(()=>{const u=a.current;if(!u||!r||!s)return;u.width=r,u.height=s;const g=u.getContext("2d");if(!g||(g.clearRect(0,0,r,s),!A))return;const h=n.filter(x=>x.type==="pcb_group"),d=n.filter(x=>x.type==="pcb_component"),p=n.filter(x=>x.type==="source_group"),m=new Map(p.map(x=>[x.source_group_id,x])),_=h.filter(x=>{if(x.name?.toLowerCase().includes("subpanel"))return!1;if(c==="all")return!0;if(!x.source_group_id)return!1;const E=m.get(x.source_group_id);return E?E.was_automatically_named!==!0:!1}),f=new Map;p.forEach(x=>{const E=x;if(E.parent_source_group_id){const B=f.get(E.parent_source_group_id)||[];B.push(x.source_group_id),f.set(E.parent_source_group_id,B)}});const I=x=>{const E=[],B=f.get(x)||[];for(const S of B)E.push(S),E.push(...I(S));return E},C=x=>{const E=p.find(B=>B.source_group_id===x);return E?.parent_source_group_id?1+C(E.parent_source_group_id):0},y=new Set;if(o.length>0)for(const x of d){if(!o.includes(x.pcb_component_id))continue;const E=x.positioned_relative_to_pcb_group_id??x.pcb_group_id;E&&y.add(E)}_.forEach((x,E)=>{let B=d.filter(Pe=>Pe.pcb_group_id===x.pcb_group_id);if(x.source_group_id){const Pe=I(x.source_group_id),He=h.filter(Re=>Re.source_group_id&&Pe.includes(Re.source_group_id));for(const Re of He){const Ee=d.filter(Te=>Te.pcb_group_id===Re.pcb_group_id);B=[...B,...Ee]}}let S,Q,w,M,k=!1;if(x.center&&x.width&&x.height){k=!0;const Pe=x.width/2,He=x.height/2;S=x.center.x-Pe,w=x.center.x+Pe,Q=x.center.y-He,M=x.center.y+He}else if(B.length===0||(S=1/0,Q=1/0,w=-1/0,M=-1/0,B.forEach(Pe=>{if(Pe.center&&typeof Pe.width=="number"&&typeof Pe.height=="number"){const He=Pe.center.x-Pe.width/2,Re=Pe.center.x+Pe.width/2,Ee=Pe.center.y+Pe.height/2,Te=Pe.center.y-Pe.height/2;S=Math.min(S,He),w=Math.max(w,Re),Q=Math.min(Q,Te),M=Math.max(M,Ee)}}),S===1/0||w===-1/0))return;const R=x.source_group_id?C(x.source_group_id):0,F=x.source_group_id?I(x.source_group_id).length>0:!1;if(!k){const Re=1+(F?.5:0);S-=Re,w+=Re,Q-=Re,M+=Re}const O=or(e,{x:S,y:M}),U=or(e,{x:w,y:M}),Y=or(e,{x:S,y:Q}),W=or(e,{x:w,y:Q}),te=Phn[E%Phn.length];g.strokeStyle=te,g.lineWidth=2;const j=Math.max(4,Math.min(12,8*Math.abs(e.a))),J=Math.max(2,Math.min(6,4*Math.abs(e.a))),oe=j*(F?1.3:1),ne=J;g.setLineDash([oe,ne]),g.beginPath(),g.moveTo(O.x,O.y),g.lineTo(U.x,U.y),g.lineTo(W.x,W.y),g.lineTo(Y.x,Y.y),g.closePath(),g.stroke();const ge=Math.max(8,Math.min(12,10*Math.abs(e.a))),ue=R==0||R==1?0:R*.11,_e=ge*(1-ue),le=4,fe=x.name||`Group ${E+1}`;g.font=`${_e}px sans-serif`,g.setLineDash([]);const ye=g.measureText(fe).width+le*2,Qe=_e+le*2,we=O.x-5,pe=O.y-5,ve=3;if(g.fillStyle="rgba(0, 0, 0, 0.8)",g.beginPath(),g.roundRect(we,pe-Qe,ye,Qe,ve),g.fill(),g.fillStyle=te,g.textAlign="left",g.textBaseline="middle",g.fillText(fe,we+le,pe-Qe/2),l&&y.has(x.pcb_group_id)&&!!x.anchor_position&&x.anchor_position){const Pe=Array.isArray(x.anchor_position)?{x:x.anchor_position[0]??0,y:x.anchor_position[1]??0}:{x:x.anchor_position.x,y:x.anchor_position.y},He=or(e,Pe);g.strokeStyle="white",g.lineWidth=1.5,g.setLineDash([]);const Re=Math.max(4,Math.min(8,6*Math.abs(e.a)));g.beginPath(),g.moveTo(He.x-Re,He.y),g.lineTo(He.x+Re,He.y),g.stroke(),g.beginPath(),g.moveTo(He.x,He.y-Re),g.lineTo(He.x,He.y+Re),g.stroke()}})},[n,e,r,s,A,c,l,o]),K.jsxs("div",{ref:i,style:{position:"relative",width:"100%",height:"100%"},children:[t,K.jsx("canvas",{ref:a,style:{position:"absolute",top:0,left:0,pointerEvents:"none",zIndex:Tu.pcbGroupOverlay,display:A?"block":"none"}})]})},_Hi=({transform:t,soup:e,children:n})=>{const o=Kc(a=>a.is_showing_rats_nest),{netMap:i,idToNetMap:r}=ee.useMemo(()=>Gdn(e||[]),[e]),s=ee.useMemo(()=>{if(!e||!o)return[];const a=g=>{const h=OU(e)[g.replace(/_\d+$/,"")].get(g);return h&&"x"in h&&"y"in h?{x:h.x,y:h.y}:null},A=(g,h)=>{const d=i[h]||[];let p=null,m=1/0;return d.forEach(_=>{const f=a(_);if(f){const I=Math.sqrt((g.x-f.x)**2+(g.y-f.y)**2);I<m&&I>0&&(m=I,p=f)}}),p},c=OU(e).pcb_port.list(),l=OU(e).source_trace.list(),u=[];return c.forEach((g,h)=>{const d=r[g.pcb_port_id];let p=!1;for(const f of l)f.connected_source_port_ids.includes(g.source_port_id)&&f.connected_source_net_ids.length>0&&(p=!0);if(!d)return;const m={x:g.x,y:g.y},_=A(m,d);_&&u.push({key:`${g.pcb_port_id}-${h}`,startPoint:m,endPoint:_,isInNet:p})}),u},[e,i,r,o]);return!e||!o?n:(t||(t=MP()),K.jsxs("div",{style:{position:"relative"},children:[n,K.jsx("svg",{style:{position:"absolute",left:0,top:0,width:"100%",height:"100%",pointerEvents:"none",opacity:.5,zIndex:Tu.ratsNestOverlay},children:s.map(({key:a,startPoint:A,endPoint:c,isInNet:l})=>{const u=or(t,A),g=or(t,c);return K.jsx("line",{x1:u.x,y1:u.y,x2:g.x,y2:g.y,stroke:"white",strokeWidth:"1",strokeDasharray:l?"6,6":void 0},a)})})]}))},fHi={version:"1.11.408"},X6=(t,e,n)=>{const o=Kc(s=>s.is_mouse_over_container),i=ee.useRef(o),r=ee.useRef(e);ee.useEffect(()=>{i.current=o},[o]),ee.useEffect(()=>{r.current=e},[e]),ee.useEffect(()=>{if(!t)return;const s=a=>{const A=a.target;if(A.tagName==="INPUT"||A.tagName==="TEXTAREA"||A.isContentEditable)return;const c=t.split("+"),l=c.includes("ctrl"),u=c.includes("shift"),g=c.includes("alt"),h=c.includes("meta"),d=c[c.length-1],p=n?.current?n.current.contains(document.activeElement)||document.activeElement===n.current:!1;(i.current||p)&&(!l||a.ctrlKey)&&(!u||a.shiftKey)&&(!g||a.altKey)&&(!h||a.metaKey)&&a.key.toLowerCase()===d.toLowerCase()&&(a.preventDefault(),r.current())};return window.addEventListener("keydown",s),()=>{window.removeEventListener("keydown",s)}},[t])},IHi=()=>{const[t,e]=ee.useState(!1);return ee.useEffect(()=>{const n=()=>{e(window.innerWidth<=768)};return n(),window.addEventListener("resize",n),()=>window.removeEventListener("resize",n)},[]),t},gee=(t,e={stopPropagation:!0})=>{const n=ee.useRef(0),o=ee.useCallback(s=>{e.stopPropagation&&s.stopPropagation();const a=Date.now();a-n.current<300||(n.current=a,t?.(s))},[t,e.stopPropagation]),i=ee.useCallback(s=>{s.preventDefault(),o(s)},[o]);return{onClick:o,onTouchEnd:i,style:{touchAction:"manipulation"}}},cfe=wU`
5579
5579
  background: #222;
5580
5580
  color: #eee;
5581
5581
  border: 1px solid #555;
@@ -5632,7 +5632,7 @@ ${o.svg()}`;return n+=`" >
5632
5632
  &:hover {
5633
5633
  background-color: rgba(255, 255, 255, 0.1);
5634
5634
  }
5635
- `,...i,style:o,children:[K.jsx("input",{type:"radio",checked:e,onChange:()=>{},readOnly:!0}),K.jsx("span",{style:{color:"#eee"},children:t})]})},SHi=({children:t,elements:e,onContextMenuOpenChange:n,getNetAtPoint:o,getComponentAtPoint:i,onViewSchematicComponent:r,xRayNetIds:s=[],onXRayNetsChange:a})=>{const A=IHi(),{isMouseOverContainer:c,setIsMouseOverContainer:l,selectedLayer:u,selectLayer:g,viewSettings:h,setIsShowingRatsNest:d,setIsShowingMultipleTracesLength:p,setIsShowingAutorouting:m,setIsShowingDrcErrors:_,setIsShowingDrcWarnings:f,setIsShowingCopperPours:I,setIsShowingCourtyards:C,setIsShowingPcbGroups:y,setIsShowingGroupAnchorOffsets:x,setIsShowingSolderMask:E,setIsShowingSilkscreen:B,setIsShowingFabricationNotes:S,setIsShowingPcbNotes:Q,setPcbGroupViewMode:w,setHoveredErrorId:M,setFocusedErrorId:k}=Kc(st=>({isMouseOverContainer:st.is_mouse_over_container,setIsMouseOverContainer:st.setIsMouseOverContainer,selectedLayer:st.selected_layer,selectLayer:st.selectLayer,viewSettings:{is_showing_rats_nest:st.is_showing_rats_nest,is_showing_multiple_traces_length:st.is_showing_multiple_traces_length,is_showing_autorouting:st.is_showing_autorouting,is_showing_drc_errors:st.is_showing_drc_errors,is_showing_drc_warnings:st.is_showing_drc_warnings,is_showing_copper_pours:st.is_showing_copper_pours,is_showing_courtyards:st.is_showing_courtyards,is_showing_pcb_groups:st.is_showing_pcb_groups,is_showing_group_anchor_offsets:st.is_showing_group_anchor_offsets,is_showing_solder_mask:st.is_showing_solder_mask,is_showing_silkscreen:st.is_showing_silkscreen,is_showing_fabrication_notes:st.is_showing_fabrication_notes,is_showing_pcb_notes:st.is_showing_pcb_notes,pcb_group_view_mode:st.pcb_group_view_mode},setIsShowingRatsNest:st.setIsShowingRatsNest,setIsShowingMultipleTracesLength:st.setIsShowingMultipleTracesLength,setIsShowingAutorouting:st.setIsShowingAutorouting,setIsShowingDrcErrors:st.setIsShowingDrcErrors,setIsShowingDrcWarnings:st.setIsShowingDrcWarnings,setIsShowingCopperPours:st.setIsShowingCopperPours,setIsShowingCourtyards:st.setIsShowingCourtyards,setIsShowingPcbGroups:st.setIsShowingPcbGroups,setIsShowingGroupAnchorOffsets:st.setIsShowingGroupAnchorOffsets,setIsShowingSolderMask:st.setIsShowingSolderMask,setIsShowingSilkscreen:st.setIsShowingSilkscreen,setIsShowingFabricationNotes:st.setIsShowingFabricationNotes,setIsShowingPcbNotes:st.setIsShowingPcbNotes,setPcbGroupViewMode:st.setPcbGroupViewMode,setHoveredErrorId:st.setHoveredErrorId,setFocusedErrorId:st.setFocusedErrorId})),[R,F]=ee.useState(null),[O,U]=ee.useState([]),[Y,W]=ee.useState(),[te,j]=ee.useState("Net"),[J,ie]=ee.useState(),oe=st=>{const Yt=st.currentTarget.getBoundingClientRect();return i?.({x:st.clientX-Yt.left,y:st.clientY-Yt.top})},ne=ee.useRef(null),ge=Kc(st=>st.in_edit_mode),ue=st=>{const Yt=st.currentTarget.getBoundingClientRect();return o?.({x:st.clientX-Yt.left,y:st.clientY-Yt.top})},_e=ee.useCallback(()=>{F(null),n?.(!1)},[n]),[le,fe]=ee.useState(!1),[he,ye]=ee.useState(!1),[Qe,we]=ee.useState(!1),[pe,ve]=ee.useState(!1),[Me,Pe]=ee.useState(!1);ee.useEffect(()=>{const st=()=>ve(!0),Yt=()=>ve(!1),pn=()=>Pe(!0),be=()=>Pe(!1);return window.addEventListener("arm-dimension-tool",st),window.addEventListener("disarm-dimension-tool",Yt),window.addEventListener("arm-bounds-tool",pn),window.addEventListener("disarm-bounds-tool",be),()=>{window.removeEventListener("arm-dimension-tool",st),window.removeEventListener("disarm-dimension-tool",Yt),window.removeEventListener("arm-bounds-tool",pn),window.removeEventListener("disarm-bounds-tool",be)}},[]);const He=ife(e??[]),Re=He,Ee=ee.useRef(!1),Te=ee.useRef(null),Ce={1:He[0]?()=>g(He[0]):()=>{},2:He[1]?()=>g(He[1]):()=>{},3:He[2]?()=>g(He[2]):()=>{},4:He[3]?()=>g(He[3]):()=>{},5:He[4]?()=>g(He[4]):()=>{},6:He[5]?()=>g(He[5]):()=>{},7:He[6]?()=>g(He[6]):()=>{},8:He[7]?()=>g(He[7]):()=>{},9:He[8]?()=>g(He[8]):()=>{},0:He[9]?()=>g(He[9]):()=>{}};X6("1",Ce[1],Te),X6("2",Ce[2],Te),X6("3",Ce[3],Te),X6("4",Ce[4],Te),X6("5",Ce[5],Te),X6("6",Ce[6],Te),X6("7",Ce[7],Te),X6("8",Ce[8],Te),X6("9",Ce[9],Te),X6("0",Ce[0],Te),ee.useLayoutEffect(()=>{if(Ee.current)return;Ee.current=!0;const st=Yt=>{if(Te.current){const pn=Te.current.getBoundingClientRect();Yt.clientX>=pn.left&&Yt.clientX<=pn.right&&Yt.clientY>=pn.top&&Yt.clientY<=pn.bottom&&l(!0)}document.removeEventListener("mousemove",st)};return document.addEventListener("mousemove",st),()=>{document.removeEventListener("mousemove",st)}},[l]);const Fe=ee.useCallback(()=>{l(!0)},[l]),Ye=ee.useCallback(()=>{c||l(!0)},[c,l]),tt=ee.useCallback(()=>{l(!1),ye(!1),fe(!1),we(!1)},[l]),At=ee.useCallback(()=>{ye(!he)},[he]),at=ee.useCallback(()=>{const st=!Qe;we(st),st&&fe(!1),st||M(null)},[Qe,M]),ot=ee.useCallback(()=>{we(!1)},[]),gt=ee.useCallback(()=>{d(!h.is_showing_rats_nest)},[h.is_showing_rats_nest,d]),Bt=ee.useCallback(()=>{ve(!0),Pe(!1),window.dispatchEvent(new Event("arm-dimension-tool"))},[]),Ct=ee.useCallback(()=>{Pe(!0),ve(!1),window.dispatchEvent(new Event("arm-bounds-tool"))},[]),Dt=ee.useCallback(()=>{const st=!le;fe(st),st&&we(!1)},[le]),Nt=ee.useCallback(st=>{st.stopPropagation()},[]);return K.jsxs("div",{ref:Te,onPointerDown:st=>{ne.current={x:st.clientX,y:st.clientY}},onClick:st=>{if(st.detail>1||ge||pe||Me||st.target.closest("button, input, select, [role=menu]"))return;const Yt=ne.current;if(!Yt||Math.hypot(st.clientX-Yt.x,st.clientY-Yt.y)>4)return;const pn=ue(st),be=oe(st);if(!pn&&!be)return;const et=pn?.netId;et&&s.includes(et)?(a?.(s.filter(It=>It!==et)),_e()):(W(et),j(pn?.displayName??"Net"),U(pn?.groups??[]),ie(be),n?.(!0),F({x:st.clientX,y:st.clientY}))},onDoubleClick:()=>{a?.([]),_e()},onContextMenu:st=>{st.preventDefault(),st.stopPropagation();const Yt=ue(st);ie(oe(st)),W(Yt?.netId),j(Yt?.displayName??"Net"),U(Yt?.groups??[]),n?.(!0),F({x:st.clientX,y:st.clientY})},style:{position:"relative",zIndex:"999 !important"},onMouseEnter:Fe,onMouseLeave:tt,onMouseMove:Ye,children:[t,R&&K.jsx(CHi,{position:R,component:J,onViewSchematicComponent:r,onClose:_e,xRayDisplayName:te,xRayGroups:O.filter(st=>st.netIds.some(Yt=>!s.includes(Yt))),onXRayGroup:st=>a?.([...new Set([...s,...st.netIds])]),onXRayNet:Y&&!s.includes(Y)?()=>a?.([...s,Y]):void 0,onExitXRayNet:s.length>0?()=>a?.([]):void 0}),K.jsxs("div",{style:{position:"absolute",bottom:4,right:8,pointerEvents:"none",color:"white",fontSize:11,opacity:c?.5:0,transition:"opacity 1s",transitionDelay:"2s",fontFamily:"sans-serif"},children:["@tscircuit/pcb-viewer@",fHi.version]}),K.jsxs("div",{"data-toolbar-overlay":!0,onTouchStart:st=>st.stopPropagation(),onTouchEnd:st=>st.stopPropagation(),onTouchMove:st=>st.stopPropagation(),onMouseDown:Nt,onMouseMove:Nt,onMouseUp:Nt,onPointerDown:Nt,onPointerMove:Nt,onPointerUp:Nt,onWheel:Nt,style:{position:"absolute",opacity:A||c?1:0,top:16,left:16,right:A?16:"auto",transition:c?"opacity 100ms linear":"opacity 300ms linear",zIndex:Tu.toolbarOverlay,color:"red",display:"flex",flexWrap:"wrap",maxWidth:"550px",gap:4,fontSize:12,fontFamily:"sans-serif"},children:[K.jsxs(YU,{isSmallScreen:A,onClick:At,onMouseLeave:()=>{he&&ye(!1)},children:[K.jsxs("div",{children:["layer:"," ",K.jsx("span",{style:{marginLeft:2,fontWeight:500,color:lee[u]},children:u})]}),he&&K.jsx("div",{style:{marginTop:4,minWidth:120},children:Re.map(st=>K.jsx(bHi,{name:st,selected:st===u,onClick:()=>{g(st)}},st))})]}),K.jsx(BHi,{elements:e,isOpen:Qe,isSmallScreen:A,onToggle:at,onClose:ot,setHoveredErrorId:M,setFocusedErrorId:k}),K.jsx(YU,{isSmallScreen:A,style:{},onClick:gt,children:K.jsxs("div",{children:[h.is_showing_rats_nest?"✖ ":"","Rats Nest"]})}),K.jsx(YU,{isSmallScreen:A,style:pe?{backgroundColor:"#444"}:{},onClick:Bt,children:K.jsx("div",{children:"📏"})}),K.jsx(YU,{isSmallScreen:A,style:Me?{backgroundColor:"#444"}:{},onClick:Ct,children:K.jsx("div",{children:"Bounds"})}),K.jsx(YU,{isSmallScreen:A,onClick:Dt,children:K.jsxs("div",{children:[K.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"4px"},children:["View",K.jsx("span",{style:{fontSize:"8px",transform:le?"rotate(180deg)":"rotate(0)",transition:"transform 0.1s ease",display:"inline-block"},children:"▼"})]}),le&&K.jsxs("div",{style:{marginTop:4,minWidth:120},children:[K.jsx(I4,{label:"Show All Trace Lengths",checked:h.is_showing_multiple_traces_length,onClick:()=>{p(!h.is_showing_multiple_traces_length)}}),K.jsx(I4,{label:"Show Autorouting Animation",checked:h.is_showing_autorouting,onClick:()=>{m(!h.is_showing_autorouting)}}),K.jsx(I4,{label:"Show DRC Errors",checked:h.is_showing_drc_errors,onClick:()=>{_(!h.is_showing_drc_errors)}}),K.jsx(I4,{label:"Show DRC Warnings",checked:h.is_showing_drc_warnings,onClick:()=>{f(!h.is_showing_drc_warnings)}}),K.jsx(I4,{label:"Show Copper Pours",checked:h.is_showing_copper_pours,onClick:()=>{I(!h.is_showing_copper_pours)}}),K.jsx(I4,{label:"Show Courtyards",checked:h.is_showing_courtyards,onClick:()=>{C(!h.is_showing_courtyards)}}),K.jsx(I4,{label:"Show Solder Mask",checked:h.is_showing_solder_mask,onClick:()=>{E(!h.is_showing_solder_mask)}}),K.jsx(I4,{label:"Show Silkscreen",checked:h.is_showing_silkscreen,onClick:()=>{B(!h.is_showing_silkscreen)}}),K.jsx(I4,{label:"Show Fabrication Notes",checked:h.is_showing_fabrication_notes,onClick:()=>{S(!h.is_showing_fabrication_notes)}}),K.jsx(I4,{label:"Show PCB Notes",checked:h.is_showing_pcb_notes,onClick:()=>{Q(!h.is_showing_pcb_notes)}}),K.jsx(I4,{label:"Show Group Anchor Offsets",checked:h.is_showing_group_anchor_offsets,onClick:()=>{x(!h.is_showing_group_anchor_offsets)}}),K.jsx(I4,{label:"Show PCB Groups",checked:h.is_showing_pcb_groups,onClick:()=>{y(!h.is_showing_pcb_groups)}}),h.is_showing_pcb_groups&&K.jsxs("div",{style:{marginLeft:16},children:[K.jsx(Mhn,{label:"Show All Groups",checked:h.pcb_group_view_mode==="all",onClick:()=>{w("all")}}),K.jsx(Mhn,{label:"Show Named Groups",checked:h.pcb_group_view_mode==="named_only",onClick:()=>{w("named_only")}})]})]})]})})]})]})},QHi=t=>t.type==="pcb_manual_edit_conflict_warning"||t.type==="pcb_connector_not_in_accessible_orientation_warning",vHi=t=>t.type==="pcb_connector_not_in_accessible_orientation_warning"?`Connector faces ${t.facing_direction}; expected ${t.recommended_facing_direction}`:"Manual Edit Conflict",wHi=({children:t,transform:e=MP(),elements:n=[]})=>{const[o,{width:i,height:r}]=Aee(),s=ee.useRef(null),a=Kc(A=>A.is_showing_drc_warnings);return ee.useEffect(()=>{const A=s.current;if(!A||!i||!r)return;A.width=i,A.height=r;const c=A.getContext("2d");if(!c)return;c.clearRect(0,0,i,r);const l=n.filter(g=>g.type==="pcb_component"),u=n.filter(QHi);c.strokeStyle=$i.board.drc_warning,c.lineWidth=2,u.forEach(g=>{const h=l.find(U=>U.pcb_component_id===g.pcb_component_id);if(!h)return;const{width:d,height:p,center:m}=h,_=or(e,m),f=d*Math.abs(e.a),I=p*Math.abs(e.d),C=.1*Math.abs(e.a),y=f+C*2,x=I+C*2,E=_.x-y/2,B=_.y-x/2;c.beginPath(),c.rect(E,B,y,x),c.stroke();const S=vHi(g),Q=4,w=Math.max(8,Math.min(12,10*Math.abs(e.a)));c.font=`${w}px sans-serif`;const k=c.measureText(S).width+Q*2,R=w+Q*2,F=E+(y-k)/2,O=B+x+5;c.fillStyle="rgba(0, 0, 0, 0.7)",c.beginPath(),c.roundRect(F,O,k,R,3),c.fill(),c.fillStyle=$i.board.drc_warning,c.textAlign="center",c.textBaseline="middle",c.fillText(S,F+k/2,O+R/2)})},[n,e,i,r,a]),a?K.jsxs("div",{ref:o,style:{position:"relative",width:"100%",height:"100%"},children:[t,K.jsx("canvas",{ref:s,style:{position:"absolute",top:0,left:0,pointerEvents:"none",zIndex:Tu.warnings}})]}):K.jsx("div",{ref:o,style:{position:"relative",width:"100%",height:"100%"},children:t})},PHi=t=>{const{transform:e,elements:n}=t,{hoveredErrorId:o,focusedErrorId:i,isShowingCopperPours:r,selectedLayer:s}=Kc(w=>({hoveredErrorId:w.hovered_error_id,focusedErrorId:w.focused_error_id,isShowingCopperPours:w.is_showing_copper_pours,selectedLayer:w.selected_layer})),a=i??o,A=ee.useMemo(()=>r?n:n.filter(w=>w.type!=="pcb_copper_pour"),[n,r]),c=ee.useMemo(()=>{const w=eFi(n);return A.flatMap(M=>tFi(M,n,w))},[A,n]),l=ee.useMemo(()=>Gdn(n),[n]),[u,g]=ee.useState([]);ee.useEffect(()=>g([]),[l]);const h=ee.useMemo(()=>u.length>0?A.filter(w=>jdn(w)&&u.includes(cee(w,l)??"")):void 0,[A,l,u]),d=ee.useMemo(()=>{if(!h)return c;const w=new Set(h);return c.filter(M=>(M._element?.type==="pcb_smtpad"||M._element?.type==="pcb_plated_hole")&&w.has(M._element))},[c,h]),p=w=>{if(!e)return;const M=_$e(c,or(K6(e),w),e,s).filter(k=>k._element?.type==="pcb_smtpad"||k._element?.type==="pcb_plated_hole");return M.sort((k,R)=>+(R.layer===s)-+(k.layer===s)),Vki(M[0]?._element,n)},m=w=>{if(!e)return;const M=(F,O)=>({netId:F,displayName:pFi(O,n,l),groups:mFi(F,n,l)}),R=_$e(c,or(K6(e),w),e,s,u.length>0).filter(F=>jdn(F._element)&&F.layer!=="drill");R.sort((F,O)=>+(O.layer===s)-+(F.layer===s));for(const F of R){const O=cee(F._element,l);if(O&&u.includes(O))return M(O,F._element)}for(const F of R){const O=cee(F._element,l);if(O)return M(O,F._element)}},[_,f]=ee.useState({drawingObjectIdsWithMouseOver:new Set,primitiveIdsInMousedOverNet:[]}),[I,C]=ee.useState([]),y=ee.useRef(e??null),x=ee.useRef(null),E=ee.useMemo(()=>Ydn(n),[n]),B=ee.useMemo(()=>{if(!a)return[];const M=n.filter(k=>k.type.includes("error")).find((k,R)=>GU(k,R)===a);return M?uFi(M):[]},[a,n]);ee.useEffect(()=>{e&&(y.current=e)},[e]),ee.useEffect(()=>()=>{Jdn(x.current)},[]),ee.useEffect(()=>{if(!t.width||!t.height||!t.setTransform||!i)return;const w=zdn(n,i);if(!w)return;const M=cFi({error:w,indexes:E});if(!M)return;const k=y.current??e;if(!k)return;const R=lFi({bounds:M,width:t.width,height:t.height});Jdn(x.current),hFi({startTransform:k,endTransform:R,durationMs:420,setAnimationFrameId:F=>{x.current=F},onUpdate:F=>{y.current=F,t.setTransform?.(F)}})},[i,n,E,t.height,t.setTransform,t.width]);const S=ee.useMemo(()=>{if(u.length>0)return c;const w=[..._.primitiveIdsInMousedOverNet,...B];return nFi({primitivesWithoutInteractionMetadata:c,drawingObjectIdsWithMouseOver:_.drawingObjectIdsWithMouseOver,primitiveIdsInMousedOverNet:w})},[c,_,B,u]),Q=ee.useCallback(w=>{const M=[];for(const F of w)if(F._element){const O=l.getNetConnectedToId("pcb_port_id"in F._element?F._element?.pcb_port_id:"pcb_trace_id"in F._element?F._element?.pcb_trace_id:"");M.push(...l.getIdsConnectedToNet(O))}const k=new Set(w.map(F=>F._pcb_drawing_object_id));f({drawingObjectIdsWithMouseOver:k,primitiveIdsInMousedOverNet:M});const R=w.map(F=>F._parent_pcb_component?.type==="pcb_component"&&F._parent_pcb_component.pcb_component_id?F._parent_pcb_component.pcb_component_id:F._element?.type==="pcb_component"&&F._element.pcb_component_id?F._element.pcb_component_id:null).filter(F=>!!F);C(Array.from(new Set(R)))},[l]);return K.jsx(pHi,{elements:A,transform:e,primitives:d,selectedLayer:s,onMouseHoverOverPrimitives:Q,children:K.jsx(ZLi,{disabled:!t.allowEditing,transform:e,soup:n,cancelPanDrag:t.cancelPanDrag,onCreateEditEvent:t.onCreateEditEvent,onModifyEditEvent:t.onModifyEditEvent,children:K.jsx(qLi,{transform:e,focusOnHover:t.focusOnHover,primitives:c,onBoundsSelected:t.onBoundsSelected,cancelPanDrag:t.cancelPanDrag,children:K.jsx(SHi,{elements:n,getNetAtPoint:m,xRayNetIds:u,onXRayNetsChange:g,onContextMenuOpenChange:t.onContextMenuOpenChange,getComponentAtPoint:p,onViewSchematicComponent:t.onViewSchematicComponent,children:K.jsx(tHi,{transform:e,elements:n,children:K.jsx(_Hi,{transform:e,soup:n,children:K.jsx(mHi,{transform:e,elements:n,hoveredComponentIds:I,children:K.jsx(HLi,{transform:e,debugGraphics:t.debugGraphics,children:K.jsx(wHi,{transform:e,elements:n,children:t.renderer==="canvas"?K.jsx(g$e,{transform:e,primitives:S,elements:A,xRayElements:h,width:t.width,height:t.height,grid:t.grid}):K.jsx(_Li,{transform:e,primitives:S,elements:n,xRayElements:h,width:t.width,height:t.height,grid:t.grid})})})})})})})})})})},lfe=t=>Number.isFinite(t)?t.toFixed(4):"NaN",MHi=t=>{let e=5381;for(let n=0;n<t.length;n++)e=(e<<5)+e+t.charCodeAt(n);return Math.abs(e)},DHi=t=>{if(!t?.length)return"0";const e=[];for(const i of t){if(!i?.type?.startsWith("pcb_"))continue;const r=_ki(i),s=A$e([i]),a=[lfe(s.minX),lfe(s.minY),lfe(s.maxX),lfe(s.maxY)].join(",");let A=`${r}:${a}`;if(i.type==="pcb_trace"){const c=(i.route??[]).length;A+=`:${c}`;for(const l of i.route??[])l.route_type==="via"&&(A+=`:${l.tented_on_top}:${l.tented_on_bottom}`)}i.type==="pcb_board"&&(A+=`:${i.default_via_tented_on_top}:${i.default_via_tented_on_bottom}`),i.type==="pcb_via"&&(A+=`:${i.tented_on_top}:${i.tented_on_bottom}`),e.push(A)}if(e.length===0)return"0";e.sort();const n=e.join(","),o=MHi(n);return`${e.length}_${o.toString(36)}`},NHi=t=>{if(!t)return"empty";const e=t.find(o=>o.type==="pcb_board");if(!e)return"no-board";const n=o=>Math.round(o*1e3)/1e3;return e.outline?e.outline.map(o=>`${n(o.x)}_${n(o.y)}`).join(","):`${n(e.width)}_${n(e.height)}`},RHi=wE(uh(400,300),bU(40,-40)),f$e=({circuitJson:t,debugGraphics:e,height:n=600,renderer:o="webgpu",initialState:i,allowEditing:r=!0,editEvents:s,onEditEventsChanged:a,onBoundsSelected:A,onViewSchematicComponent:c,focusOnHover:l=!1,clickToInteractEnabled:u=!1,disablePcbGroups:g=!1})=>{const[h,d]=ee.useState(o);ee.useEffect(()=>d(o),[o]);const p=ee.useMemo(()=>({renderer:h,setRenderer:d}),[h]),[m,_]=ee.useState(!u),[f,I]=ee.useState(!1),C=ee.useRef(!1),[y,x]=Aee(),[E,B]=ee.useState(RHi),S=ee.useCallback(ge=>{if(C.current||ge instanceof MouseEvent&&(ge.button===2||(ge.buttons&2)!==0))return!1;const ue=ge.target;return ue instanceof Element?!ue.closest("[data-toolbar-overlay]"):!0},[]),{ref:Q,setTransform:w,cancelDrag:M}=Kki({transform:E,onSetTransform:B,enabled:m&&!f,shouldDrag:S}),k=ee.useCallback(ge=>{C.current=ge,ge&&M(),I(ge)},[M]);let[R,F]=ee.useState([]);R=s??R;const O=ee.useRef(!1),U=ee.useRef(null),Y=ee.useMemo(()=>DHi(t),[t]),W=NHi(t),te=()=>{const ge=x?.width>0?x:{width:500,height:500},{center:ue,width:_e,height:le}=J.some(ye=>ye.type.startsWith("pcb_"))?Bki(J.filter(ye=>ye.type.startsWith("pcb_"))):{center:{x:0,y:0},width:.001,height:.001},fe=Math.min((ge.width??0)/_e,(ge.height??0)/le,100)*.75,he=wE(uh((ge.width??0)/2,(ge.height??0)/2),bU(fe,-fe,0,0),uh(-ue.x,-ue.y));w(he)};ee.useEffect(()=>{x?.width&&t&&t.length!==0&&(O.current||(te(),O.current=!0))},[t,x]),ee.useEffect(()=>{O.current===!0&&te()},[W]);const j=ee.useMemo(()=>t?.filter(ge=>ge.type.startsWith("pcb_")||ge.type.startsWith("source_"))??[],[Y]),J=ee.useMemo(()=>xPo({circuitJson:j,editEvents:R}),[j,R]),ie=ge=>{F([...R,ge]),a?.([...R,ge])},oe=ge=>{const ue=R.map(_e=>_e.edit_event_id===ge.edit_event_id?{..._e,...ge}:_e);F(ue),a?.(ue)},ne=ee.useMemo(()=>({...i,...g&&{is_showing_pcb_groups:!1}}),[i,g]);return K.jsx(Lgn.Provider,{value:p,children:K.jsxs("div",{ref:Q,style:{position:"relative"},onContextMenu:ge=>ge.preventDefault(),children:[K.jsx("div",{ref:y,children:K.jsxs(Mki,{initialState:ne,disablePcbGroups:g,children:[K.jsx(PHi,{renderer:h,transform:E,setTransform:w,height:n,width:x.width,allowEditing:r,focusOnHover:l,onBoundsSelected:A,onViewSchematicComponent:c,cancelPanDrag:M,onContextMenuOpenChange:k,onCreateEditEvent:ie,onModifyEditEvent:oe,grid:{spacing:1,view_window:{left:0,right:x.width||500,top:n,bottom:0}},elements:J,debugGraphics:e}),K.jsx(Dki,{})]})}),u&&!m&&K.jsx("div",{onClick:()=>{_(!0),te()},onTouchStart:ge=>{const ue=ge.touches[0];U.current={x:ue.clientX,y:ue.clientY}},onTouchEnd:ge=>{const ue=ge.changedTouches[0],_e=U.current;if(!_e)return;const le=Math.abs(ue.clientX-_e.x),fe=Math.abs(ue.clientY-_e.y);le<10&&fe<10&&(ge.preventDefault(),_(!0),te()),U.current=null},style:{position:"absolute",inset:0,cursor:"pointer",zIndex:Tu.clickToInteractOverlay,display:"flex",alignItems:"center",justifyContent:"center",touchAction:"pan-x pan-y pinch-zoom"},children:K.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 THi=({circuitJson:t,containerClassName:e,...n})=>{const o=ee.useRef(null),[i,r]=ee.useState(620);return ee.useLayoutEffect(()=>{const s=()=>{if(o.current){const A=o.current.clientHeight,c=window.innerHeight;r(Math.min(Math.max(A,620),c))}};s();const a=new ResizeObserver(s);return o.current&&a.observe(o.current),window.addEventListener("resize",s),()=>{a.disconnect(),window.removeEventListener("resize",s)}},[]),K.jsx("div",{ref:o,className:e||"rf-w-full rf-h-full",children:K.jsx(f$e,{...n,circuitJson:t,height:i})})},kHi='*,: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.19 | 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-1{right:.25rem}.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-\\[101\\]{z-index:101!important}.\\!rf-z-\\[200\\]{z-index:200!important}.rf-z-10{z-index:10}.rf-z-50{z-index:50}.rf-z-\\[100\\]{z-index:100}.rf-z-\\[101\\]{z-index:101}.rf-z-\\[102\\]{z-index:102}.rf-order-1{order:1}.rf-order-2{order:2}.rf-order-3{order:3}.rf-m-0{margin:0}.rf-m-1{margin:.25rem}.rf-m-6{margin:1.5rem}.-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-4{margin-left:1rem;margin-right:1rem}.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-0{margin-bottom:0}.rf-mb-0\\.5{margin-bottom:.125rem}.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-7{margin-bottom:1.75rem}.rf-mb-8{margin-bottom:2rem}.rf-ml-1{margin-left:.25rem}.rf-ml-2{margin-left:.5rem}.rf-ml-6{margin-left:1.5rem}.rf-ml-auto{margin-left:auto}.rf-mr-1{margin-right:.25rem}.rf-mr-2{margin-right:.5rem}.rf-mr-4{margin-right:1rem}.rf-mr-auto{margin-right:auto}.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-block{display:inline-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-\\[4\\/3\\]{aspect-ratio:4/3}.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-2{height:.5rem;width:.5rem}.rf-size-3{height:.75rem;width:.75rem}.rf-size-4{height:1rem;width:1rem}.\\!rf-h-2{height:.5rem!important}.\\!rf-h-2\\.5{height:.625rem!important}.rf-h-0{height:0}.rf-h-0\\.5{height:.125rem}.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-20{height:5rem}.rf-h-24{height:6rem}.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-7{height:1.75rem}.rf-h-8{height:2rem}.rf-h-9{height:2.25rem}.rf-h-\\[400px\\]{height:400px}.rf-h-\\[calc\\(100vh-52px\\)\\]{height:calc(100vh - 52px)}.rf-h-\\[calc\\(100vh-60px\\)\\]{height:calc(100vh - 60px)}.rf-h-\\[var\\(--radix-select-trigger-height\\)\\]{height:var(--radix-select-trigger-height)}.rf-h-auto{height:auto}.rf-h-fit{height:-moz-fit-content;height:fit-content}.rf-h-full{height:100%}.rf-h-px{height:1px}.rf-h-screen{height:100vh}.\\!rf-max-h-\\[40vh\\]{max-height:40vh!important}.\\!rf-max-h-\\[80vh\\]{max-height:80vh!important}.rf-max-h-16{max-height:4rem}.rf-max-h-20{max-height:5rem}.rf-max-h-24{max-height:6rem}.rf-max-h-28{max-height:7rem}.rf-max-h-32{max-height:8rem}.rf-max-h-64{max-height:16rem}.rf-max-h-96{max-height:24rem}.rf-max-h-\\[120px\\]{max-height:120px}.rf-max-h-\\[150px\\]{max-height:150px}.rf-max-h-\\[200px\\]{max-height:200px}.rf-max-h-\\[300px\\]{max-height:300px}.rf-max-h-\\[90vh\\]{max-height:90vh}.rf-max-h-full{max-height:100%}.rf-max-h-none{max-height:none}.rf-min-h-0{min-height:0}.rf-min-h-56{min-height:14rem}.rf-min-h-72{min-height:18rem}.rf-min-h-\\[100px\\]{min-height:100px}.rf-min-h-\\[200px\\]{min-height:200px}.rf-min-h-\\[300px\\]{min-height:300px}.rf-min-h-\\[360px\\]{min-height:360px}.rf-min-h-\\[400px\\]{min-height:400px}.rf-min-h-\\[620px\\]{min-height:620px}.rf-min-h-\\[calc\\(100vh-240px\\)\\]{min-height:calc(100vh - 240px)}.rf-min-h-full{min-height:100%}.\\!rf-w-2{width:.5rem!important}.\\!rf-w-2\\.5{width:.625rem!important}.\\!rf-w-\\[95vw\\]{width:95vw!important}.rf-w-1{width:.25rem}.rf-w-10{width:2.5rem}.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-20{width:5rem}.rf-w-24{width:6rem}.rf-w-28{width:7rem}.rf-w-3{width:.75rem}.rf-w-3\\.5{width:.875rem}.rf-w-32{width:8rem}.rf-w-4{width:1rem}.rf-w-40{width:10rem}.rf-w-48{width:12rem}.rf-w-5{width:1.25rem}.rf-w-6{width:1.5rem}.rf-w-64{width:16rem}.rf-w-7{width:1.75rem}.rf-w-72{width:18rem}.rf-w-8{width:2rem}.rf-w-80{width:20rem}.rf-w-9{width:2.25rem}.rf-w-96{width:24rem}.rf-w-fit{width:-moz-fit-content;width:fit-content}.rf-w-full{width:100%}.rf-w-screen{width:100vw}.rf-min-w-0{min-width:0}.rf-min-w-10{min-width:2.5rem}.rf-min-w-16{min-width:4rem}.rf-min-w-32{min-width:8rem}.rf-min-w-80{min-width:20rem}.rf-min-w-96{min-width:24rem}.rf-min-w-\\[12px\\]{min-width:12px}.rf-min-w-\\[148px\\]{min-width:148px}.rf-min-w-\\[192px\\]{min-width:192px}.rf-min-w-\\[600px\\]{min-width:600px}.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-\\[95vw\\]{max-width:95vw!important}.rf-max-w-2xl{max-width:42rem}.rf-max-w-3xl{max-width:48rem}.rf-max-w-4xl{max-width:56rem}.rf-max-w-5xl{max-width:64rem}.rf-max-w-64{max-width:16rem}.rf-max-w-7xl{max-width:80rem}.rf-max-w-96{max-width:24rem}.rf-max-w-\\[1000px\\]{max-width:1000px}.rf-max-w-\\[150px\\]{max-width:150px}.rf-max-w-\\[200px\\]{max-width:200px}.rf-max-w-\\[320px\\]{max-width:320px}.rf-max-w-\\[40\\%\\]{max-width:40%}.rf-max-w-\\[600px\\]{max-width:600px}.rf-max-w-full{max-width:100%}.rf-max-w-lg{max-width:32rem}.rf-max-w-md{max-width:28rem}.rf-max-w-none{max-width:none}.rf-max-w-xl{max-width:36rem}.rf-max-w-xs{max-width:20rem}.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-origin-\\[--radix-popover-content-transform-origin\\]{transform-origin:var(--radix-popover-content-transform-origin)}.-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-1\\/2{--tw-translate-x:-50%}.rf--translate-x-1\\/2,.rf--translate-y-0{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-0{--tw-translate-y:-0px}.rf--translate-y-1{--tw-translate-y:-0.25rem}.rf--translate-y-1,.rf-translate-x-\\[-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-x-\\[-50\\%\\]{--tw-translate-x:-50%}.rf-translate-y-\\[-50\\%\\]{--tw-translate-y:-50%}.-rf-rotate-90,.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-rotate-90{--tw-rotate:-90deg}.rf-rotate-90{--tw-rotate:90deg}.rf-rotate-90,.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-grid-cols-3{grid-template-columns:repeat(3,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-content-center{place-content:center}.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-items-baseline{align-items:baseline}.rf-items-stretch{align-items:stretch}.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-1\\.5{gap:.375rem}.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-gap-x-5{-moz-column-gap:1.25rem;column-gap:1.25rem}.rf-gap-y-1{row-gap:.25rem}.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-1>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-bottom:calc(.25rem*var(--tw-space-y-reverse));margin-top:calc(.25rem*(1 - var(--tw-space-y-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-3>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-bottom:calc(.75rem*var(--tw-space-y-reverse));margin-top:calc(.75rem*(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}.rf-overflow-x-clip{overflow-x:clip}.rf-truncate{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.rf-whitespace-normal{white-space:normal}.rf-whitespace-nowrap{white-space:nowrap}.rf-whitespace-pre-wrap{white-space:pre-wrap}.rf-text-nowrap{text-wrap:nowrap}.rf-break-words{overflow-wrap:break-word}.rf-break-all{word-break:break-all}.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-none{border-radius:0}.rf-rounded-sm{border-radius:calc(var(--radius) - 4px)}.rf-rounded-xl{border-radius:.75rem}.rf-border{border-width:1px}.rf-border-0{border-width:0}.rf-border-2{border-width:2px}.rf-border-y{border-top-width:1px}.rf-border-b,.rf-border-y{border-bottom-width:1px}.rf-border-l-2{border-left-width:2px}.rf-border-l-4{border-left-width:4px}.rf-border-r{border-right-width:1px}.rf-border-t{border-top-width:1px}.rf-border-none{border-style:none}.rf-border-blue-100{--tw-border-opacity:1;border-color:rgb(219 234 254/var(--tw-border-opacity,1))}.rf-border-blue-200{--tw-border-opacity:1;border-color:rgb(191 219 254/var(--tw-border-opacity,1))}.rf-border-blue-300{--tw-border-opacity:1;border-color:rgb(147 197 253/var(--tw-border-opacity,1))}.rf-border-blue-400{--tw-border-opacity:1;border-color:rgb(96 165 250/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-border{border-color:hsl(var(--border))}.rf-border-emerald-500{--tw-border-opacity:1;border-color:rgb(16 185 129/var(--tw-border-opacity,1))}.rf-border-gray-100{--tw-border-opacity:1;border-color:rgb(243 244 246/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-green-400{--tw-border-opacity:1;border-color:rgb(74 222 128/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-orange-100{--tw-border-opacity:1;border-color:rgb(255 237 213/var(--tw-border-opacity,1))}.rf-border-orange-200{--tw-border-opacity:1;border-color:rgb(254 215 170/var(--tw-border-opacity,1))}.rf-border-orange-500{--tw-border-opacity:1;border-color:rgb(249 115 22/var(--tw-border-opacity,1))}.rf-border-primary{border-color:hsl(var(--primary))}.rf-border-red-100{--tw-border-opacity:1;border-color:rgb(254 226 226/var(--tw-border-opacity,1))}.rf-border-red-200{--tw-border-opacity:1;border-color:rgb(254 202 202/var(--tw-border-opacity,1))}.rf-border-red-300{--tw-border-opacity:1;border-color:rgb(252 165 165/var(--tw-border-opacity,1))}.rf-border-red-400{--tw-border-opacity:1;border-color:rgb(248 113 113/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-red-600{--tw-border-opacity:1;border-color:rgb(220 38 38/var(--tw-border-opacity,1))}.rf-border-red-700{--tw-border-opacity:1;border-color:rgb(185 28 28/var(--tw-border-opacity,1))}.rf-border-red-800{--tw-border-opacity:1;border-color:rgb(153 27 27/var(--tw-border-opacity,1))}.rf-border-slate-200{--tw-border-opacity:1;border-color:rgb(226 232 240/var(--tw-border-opacity,1))}.rf-border-slate-700{--tw-border-opacity:1;border-color:rgb(51 65 85/var(--tw-border-opacity,1))}.rf-border-slate-800{--tw-border-opacity:1;border-color:rgb(30 41 59/var(--tw-border-opacity,1))}.rf-border-slate-800\\/60{border-color:rgba(30,41,59,.6)}.rf-border-transparent{border-color:transparent}.rf-border-yellow-200{--tw-border-opacity:1;border-color:rgb(254 240 138/var(--tw-border-opacity,1))}.rf-border-zinc-100{--tw-border-opacity:1;border-color:rgb(244 244 245/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-border-l-blue-500{--tw-border-opacity:1;border-left-color:rgb(59 130 246/var(--tw-border-opacity,1))}.rf-border-t-blue-600{--tw-border-opacity:1;border-top-color:rgb(37 99 235/var(--tw-border-opacity,1))}.rf-bg-amber-50{--tw-bg-opacity:1;background-color:rgb(255 251 235/var(--tw-bg-opacity,1))}.rf-bg-amber-50\\/30{background-color:rgba(255,251,235,.3)}.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-emerald-500{--tw-bg-opacity:1;background-color:rgb(16 185 129/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-300{--tw-bg-opacity:1;background-color:rgb(134 239 172/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-green-600{--tw-bg-opacity:1;background-color:rgb(22 163 74/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-100{--tw-bg-opacity:1;background-color:rgb(255 237 213/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-orange-50{--tw-bg-opacity:1;background-color:rgb(255 247 237/var(--tw-bg-opacity,1))}.rf-bg-orange-50\\/50{background-color:rgba(255,247,237,.5)}.rf-bg-orange-500{--tw-bg-opacity:1;background-color:rgb(249 115 22/var(--tw-bg-opacity,1))}.rf-bg-popover{background-color:hsl(var(--popover))}.rf-bg-purple-500{--tw-bg-opacity:1;background-color:rgb(168 85 247/var(--tw-bg-opacity,1))}.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-50\\/50{background-color:rgba(254,242,242,.5)}.rf-bg-red-500{--tw-bg-opacity:1;background-color:rgb(239 68 68/var(--tw-bg-opacity,1))}.rf-bg-red-600{--tw-bg-opacity:1;background-color:rgb(220 38 38/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-red-950{--tw-bg-opacity:1;background-color:rgb(69 10 10/var(--tw-bg-opacity,1))}.rf-bg-slate-50{--tw-bg-opacity:1;background-color:rgb(248 250 252/var(--tw-bg-opacity,1))}.rf-bg-slate-800{--tw-bg-opacity:1;background-color:rgb(30 41 59/var(--tw-bg-opacity,1))}.rf-bg-slate-900{--tw-bg-opacity:1;background-color:rgb(15 23 42/var(--tw-bg-opacity,1))}.rf-bg-transparent{background-color:transparent}.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-yellow-50{--tw-bg-opacity:1;background-color:rgb(254 252 232/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-zinc-950{--tw-bg-opacity:1;background-color:rgb(9 9 11/var(--tw-bg-opacity,1))}.rf-bg-opacity-50{--tw-bg-opacity:0.5}.rf-bg-gradient-to-br{background-image:linear-gradient(to bottom right,var(--tw-gradient-stops))}.rf-from-blue-500{--tw-gradient-from:#3b82f6 var(--tw-gradient-from-position);--tw-gradient-to:rgba(59,130,246,0) var(--tw-gradient-to-position);--tw-gradient-stops:var(--tw-gradient-from),var(--tw-gradient-to)}.rf-from-emerald-500{--tw-gradient-from:#10b981 var(--tw-gradient-from-position);--tw-gradient-to:rgba(16,185,129,0) var(--tw-gradient-to-position);--tw-gradient-stops:var(--tw-gradient-from),var(--tw-gradient-to)}.rf-from-green-500{--tw-gradient-from:#22c55e var(--tw-gradient-from-position);--tw-gradient-to:rgba(34,197,94,0) var(--tw-gradient-to-position);--tw-gradient-stops:var(--tw-gradient-from),var(--tw-gradient-to)}.rf-from-red-500{--tw-gradient-from:#ef4444 var(--tw-gradient-from-position);--tw-gradient-to:rgba(239,68,68,0) var(--tw-gradient-to-position);--tw-gradient-stops:var(--tw-gradient-from),var(--tw-gradient-to)}.rf-to-blue-600{--tw-gradient-to:#2563eb var(--tw-gradient-to-position)}.rf-to-emerald-600{--tw-gradient-to:#059669 var(--tw-gradient-to-position)}.rf-to-green-600{--tw-gradient-to:#16a34a var(--tw-gradient-to-position)}.rf-to-red-600{--tw-gradient-to:#dc2626 var(--tw-gradient-to-position)}.rf-fill-amber-500{fill:#f59e0b}.rf-fill-current{fill:currentColor}.rf-stroke-1{stroke-width:1}.rf-object-contain{-o-object-fit:contain;object-fit:contain}.rf-object-cover{-o-object-fit:cover;object-fit:cover}.\\!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-1\\.5{padding-left:.375rem;padding-right:.375rem}.rf-px-2{padding-left:.5rem;padding-right:.5rem}.rf-px-2\\.5{padding-left:.625rem;padding-right:.625rem}.rf-px-3{padding-left:.75rem;padding-right:.75rem}.rf-px-4{padding-left:1rem;padding-right:1rem}.rf-px-5{padding-left:1.25rem;padding-right:1.25rem}.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-6{padding-bottom:1.5rem;padding-top:1.5rem}.rf-py-8{padding-bottom:2rem;padding-top:2rem}.rf-pb-0{padding-bottom:0}.rf-pb-1{padding-bottom:.25rem}.rf-pb-1\\.5{padding-bottom:.375rem}.rf-pb-2{padding-bottom:.5rem}.rf-pb-3{padding-bottom:.75rem}.rf-pb-4{padding-bottom:1rem}.rf-pb-px{padding-bottom:1px}.rf-pl-10{padding-left:2.5rem}.rf-pl-11{padding-left:2.75rem}.rf-pl-12{padding-left:3rem}.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-0{padding-top:0}.rf-pt-1{padding-top:.25rem}.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-align-bottom{vertical-align:bottom}.rf-font-mono{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace}.rf-font-sans{font-family:ui-sans-serif,system-ui,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji}.rf-text-2xl{font-size:1.5rem;line-height:2rem}.rf-text-3xl{font-size:1.875rem;line-height:2.25rem}.rf-text-\\[10px\\]{font-size:10px}.rf-text-\\[11px\\]{font-size:11px}.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-normal{font-weight:400!important}.rf-font-bold{font-weight:700}.rf-font-medium{font-weight:500}.rf-font-normal{font-weight:400}.rf-font-semibold{font-weight:600}.rf-uppercase{text-transform:uppercase}.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-4{line-height:1rem}.rf-leading-5{line-height:1.25rem}.rf-leading-\\[0\\.95rem\\]{line-height:.95rem}.rf-leading-\\[1rem\\]{line-height:1rem}.rf-leading-none{line-height:1}.rf-leading-relaxed{line-height:1.625}.rf-leading-tight{line-height:1.25}.rf-tracking-tight{letter-spacing:-.025em}.rf-tracking-wide{letter-spacing:.025em}.rf-tracking-wider{letter-spacing:.05em}.rf-tracking-widest{letter-spacing:.1em}.rf-text-amber-500{--tw-text-opacity:1;color:rgb(245 158 11/var(--tw-text-opacity,1))}.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-emerald-600{--tw-text-opacity:1;color:rgb(5 150 105/var(--tw-text-opacity,1))}.rf-text-foreground{color:hsl(var(--foreground))}.rf-text-gray-200{--tw-text-opacity:1;color:rgb(229 231 235/var(--tw-text-opacity,1))}.rf-text-gray-300{--tw-text-opacity:1;color:rgb(209 213 219/var(--tw-text-opacity,1))}.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{color:hsl(var(--muted))}.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-orange-400{--tw-text-opacity:1;color:rgb(251 146 60/var(--tw-text-opacity,1))}.rf-text-orange-500{--tw-text-opacity:1;color:rgb(249 115 22/var(--tw-text-opacity,1))}.rf-text-orange-600{--tw-text-opacity:1;color:rgb(234 88 12/var(--tw-text-opacity,1))}.rf-text-orange-700{--tw-text-opacity:1;color:rgb(194 65 12/var(--tw-text-opacity,1))}.rf-text-orange-800{--tw-text-opacity:1;color:rgb(154 52 18/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-slate-200{--tw-text-opacity:1;color:rgb(226 232 240/var(--tw-text-opacity,1))}.rf-text-slate-400{--tw-text-opacity:1;color:rgb(148 163 184/var(--tw-text-opacity,1))}.rf-text-slate-50{--tw-text-opacity:1;color:rgb(248 250 252/var(--tw-text-opacity,1))}.rf-text-slate-500{--tw-text-opacity:1;color:rgb(100 116 139/var(--tw-text-opacity,1))}.rf-text-slate-600{--tw-text-opacity:1;color:rgb(71 85 105/var(--tw-text-opacity,1))}.rf-text-slate-800{--tw-text-opacity:1;color:rgb(30 41 59/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-600{--tw-text-opacity:1;color:rgb(202 138 4/var(--tw-text-opacity,1))}.rf-text-yellow-700{--tw-text-opacity:1;color:rgb(161 98 7/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-600{--tw-text-opacity:1;color:rgb(82 82 91/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-accent-blue-600{accent-color:#2563eb}.rf-opacity-0{opacity:0}.rf-opacity-10{opacity:.1}.rf-opacity-100{opacity:1}.rf-opacity-25{opacity:.25}.rf-opacity-30{opacity:.3}.rf-opacity-50{opacity:.5}.rf-opacity-60{opacity:.6}.rf-opacity-70{opacity:.7}.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-none{box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}.rf-shadow-none{--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000}.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-shadow-sm,.rf-shadow-xl{box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}.rf-shadow-xl{--tw-shadow:0 20px 25px -5px rgba(0,0,0,.1),0 8px 10px -6px rgba(0,0,0,.1);--tw-shadow-colored:0 20px 25px -5px var(--tw-shadow-color),0 8px 10px -6px 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,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-transition-transform{transition-duration:.15s;transition-property:transform;transition-timing-function:cubic-bezier(.4,0,.2,1)}.rf-duration-150{transition-duration:.15s}.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-animate-in{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}.rf-fade-in-0{--tw-enter-opacity:0}.rf-zoom-in-95{--tw-enter-scale:.95}.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-150{animation-duration:.15s}.rf-duration-200{animation-duration:.2s}.rf-ease-in-out{animation-timing-function:cubic-bezier(.4,0,.2,1)}.no-scrollbar::-webkit-scrollbar{display:none}.no-scrollbar{-ms-overflow-style:none;scrollbar-width:none}.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--translate-y-0\\.5:hover{--tw-translate-y:-0.125rem;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))}.hover\\:rf-border-blue-300:hover{--tw-border-opacity:1;border-color:rgb(147 197 253/var(--tw-border-opacity,1))}.hover\\:rf-border-zinc-300:hover{--tw-border-opacity:1;border-color:rgb(212 212 216/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-gray-50:hover{--tw-bg-opacity:1;background-color:rgb(249 250 251/var(--tw-bg-opacity,1))}.hover\\:rf-bg-orange-100:hover{--tw-bg-opacity:1;background-color:rgb(255 237 213/var(--tw-bg-opacity,1))}.hover\\:rf-bg-red-100:hover{--tw-bg-opacity:1;background-color:rgb(254 226 226/var(--tw-bg-opacity,1))}.hover\\:rf-bg-red-500\\/90:hover{background-color:rgba(239,68,68,.9)}.hover\\:rf-bg-slate-100:hover{--tw-bg-opacity:1;background-color:rgb(241 245 249/var(--tw-bg-opacity,1))}.hover\\:rf-bg-slate-200:hover{--tw-bg-opacity:1;background-color:rgb(226 232 240/var(--tw-bg-opacity,1))}.hover\\:rf-bg-slate-50:hover{--tw-bg-opacity:1;background-color:rgb(248 250 252/var(--tw-bg-opacity,1))}.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-blue-800:hover{--tw-text-opacity:1;color:rgb(30 64 175/var(--tw-text-opacity,1))}.hover\\:rf-text-gray-700:hover{--tw-text-opacity:1;color:rgb(55 65 81/var(--tw-text-opacity,1))}.hover\\:rf-text-red-400:hover{--tw-text-opacity:1;color:rgb(248 113 113/var(--tw-text-opacity,1))}.hover\\:rf-text-slate-800:hover{--tw-text-opacity:1;color:rgb(30 41 59/var(--tw-text-opacity,1))}.hover\\:rf-text-slate-900:hover{--tw-text-opacity:1;color:rgb(15 23 42/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}.hover\\:rf-shadow-md:hover{--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);box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}.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-blue-500:focus{--tw-ring-opacity:1;--tw-ring-color:rgb(59 130 246/var(--tw-ring-opacity,1))}.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-900:focus-visible{--tw-ring-opacity:1;--tw-ring-color:rgb(24 24 27/var(--tw-ring-opacity,1))}.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-text-gray-500:disabled{--tw-text-opacity:1;color:rgb(107 114 128/var(--tw-text-opacity,1))}.disabled\\:rf-opacity-40:disabled{opacity:.4}.disabled\\:rf-opacity-50:disabled{opacity:.5}.rf-group:hover .group-hover\\:rf-scale-\\[1\\.03\\]{--tw-scale-x:1.03;--tw-scale-y:1.03;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-group:hover .group-hover\\:rf-opacity-100,.rf-group\\/bar:hover .group-hover\\/bar\\:rf-opacity-100{opacity:1}.rf-peer:disabled~.peer-disabled\\:rf-cursor-not-allowed{cursor:not-allowed}.rf-peer:disabled~.peer-disabled\\:rf-opacity-70{opacity:.7}.data-\\[disabled\\=true\\]\\:rf-pointer-events-none[data-disabled=true],.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-\\[selected\\=true\\]\\:rf-bg-zinc-100[data-selected=true]{--tw-bg-opacity:1;background-color:rgb(244 244 245/var(--tw-bg-opacity,1))}.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-\\[selected\\=true\\]\\:rf-text-zinc-900[data-selected=true]{--tw-text-opacity:1;color:rgb(24 24 27/var(--tw-text-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\\=true\\]\\:rf-opacity-50[data-disabled=true],.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-gray-700:is(.rf-dark *){--tw-bg-opacity:1;background-color:rgb(55 65 81/var(--tw-bg-opacity,1))}.dark\\:rf-bg-gray-800:is(.rf-dark *){--tw-bg-opacity:1;background-color:rgb(31 41 55/var(--tw-bg-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-900:is(.rf-dark *){--tw-bg-opacity:1;background-color:rgb(24 24 27/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-gray-500:is(.rf-dark *){--tw-text-opacity:1;color:rgb(107 114 128/var(--tw-text-opacity,1))}.dark\\:rf-text-zinc-300:is(.rf-dark *){--tw-text-opacity:1;color:rgb(212 212 216/var(--tw-text-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\\:placeholder\\:rf-text-zinc-400:is(.rf-dark *)::-moz-placeholder{--tw-text-opacity:1;color:rgb(161 161 170/var(--tw-text-opacity,1))}.dark\\:placeholder\\:rf-text-zinc-400:is(.rf-dark *)::placeholder{--tw-text-opacity:1;color:rgb(161 161 170/var(--tw-text-opacity,1))}.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-\\[selected\\=true\\]\\:rf-bg-zinc-800[data-selected=true]:is(.rf-dark *){--tw-bg-opacity:1;background-color:rgb(39 39 42/var(--tw-bg-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-\\[selected\\=true\\]\\:rf-text-zinc-50[data-selected=true]:is(.rf-dark *){--tw-text-opacity:1;color:rgb(250 250 250/var(--tw-text-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-order-1{order:1}.sm\\:rf-order-2{order:2}.sm\\:rf-mt-0{margin-top:0}.sm\\:rf-mt-4{margin-top:1rem}.sm\\:rf-block{display:block}.sm\\:rf-inline{display:inline}.sm\\:rf-grid{display:grid}.sm\\:rf-hidden{display:none}.sm\\:rf-h-5{height:1.25rem}.sm\\:rf-w-1\\/2{width:50%}.sm\\:rf-w-5{width:1.25rem}.sm\\:rf-w-\\[90vw\\]{width:90vw}.sm\\:rf-w-auto{width:auto}.sm\\:rf-max-w-\\[500px\\]{max-width:500px}.sm\\:rf-max-w-md{max-width:28rem}.sm\\:rf-grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.sm\\:rf-grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.sm\\:rf-grid-cols-\\[1fr_auto\\]{grid-template-columns:1fr auto}.sm\\:rf-grid-cols-\\[minmax\\(0\\2c 1fr\\)_auto\\]{grid-template-columns:minmax(0,1fr) auto}.sm\\:rf-flex-row{flex-direction:row}.sm\\:rf-items-center{align-items:center}.sm\\:rf-justify-end{justify-content:flex-end}.sm\\:rf-gap-3{gap:.75rem}.sm\\:rf-gap-4{gap:1rem}.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-p-3{padding:.75rem}.sm\\:rf-p-6{padding:1.5rem}.sm\\:rf-px-4{padding-left:1rem;padding-right:1rem}.sm\\:rf-px-6{padding-left:1.5rem;padding-right:1.5rem}.sm\\:rf-px-8{padding-left:2rem;padding-right:2rem}.sm\\:rf-py-10{padding-bottom:2.5rem;padding-top:2.5rem}.sm\\:rf-py-6{padding-bottom:1.5rem;padding-top:1.5rem}.sm\\:rf-text-left{text-align:left}.sm\\:rf-text-2xl{font-size:1.5rem;line-height:2rem}.sm\\:rf-text-3xl{font-size:1.875rem;line-height:2.25rem}.sm\\:rf-text-base{font-size:1rem;line-height:1.5rem}.sm\\:rf-text-sm{font-size:.875rem;line-height:1.25rem}.sm\\:rf-text-xl{font-size:1.25rem;line-height:1.75rem}}@media (min-width:768px){.md\\:rf-w-52{width:13rem}.md\\:rf-w-auto{width:auto}.md\\:rf-min-w-0{min-width:0}.md\\:rf-max-w-\\[660px\\]{max-width:660px}.md\\:rf-max-w-lg{max-width:32rem}.md\\:rf-grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.md\\:rf-grid-cols-\\[220px_1fr\\]{grid-template-columns:220px 1fr}.md\\:rf-flex-row{flex-direction:row}.md\\:rf-flex-col{flex-direction:column}.md\\:rf-overflow-y-auto{overflow-y:auto}.md\\:rf-overflow-x-hidden{overflow-x:hidden}.md\\:rf-border-b-0{border-bottom-width:0}.md\\:rf-border-r{border-right-width:1px}.md\\:rf-p-8{padding:2rem}.md\\:rf-py-8{padding-bottom:2rem;padding-top:2rem}.md\\:rf-text-3xl{font-size:1.875rem;line-height:2.25rem}}@media (min-width:1024px){.lg\\:rf-max-w-\\[720px\\]{max-width:720px}.lg\\:rf-max-w-xl{max-width:36rem}.lg\\:rf-grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}}@media (min-width:1280px){.xl\\:rf-max-w-\\[800px\\]{max-width:800px}}.\\[\\&\\>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))}.\\[\\&_\\[cmdk-group-heading\\]\\]\\:rf-px-2 [cmdk-group-heading]{padding-left:.5rem;padding-right:.5rem}.\\[\\&_\\[cmdk-group-heading\\]\\]\\:rf-py-1\\.5 [cmdk-group-heading]{padding-bottom:.375rem;padding-top:.375rem}.\\[\\&_\\[cmdk-group-heading\\]\\]\\:rf-text-xs [cmdk-group-heading]{font-size:.75rem;line-height:1rem}.\\[\\&_\\[cmdk-group-heading\\]\\]\\:rf-font-medium [cmdk-group-heading]{font-weight:500}.\\[\\&_\\[cmdk-group-heading\\]\\]\\:rf-text-zinc-500 [cmdk-group-heading]{--tw-text-opacity:1;color:rgb(113 113 122/var(--tw-text-opacity,1))}.dark\\:\\[\\&_\\[cmdk-group-heading\\]\\]\\:rf-text-zinc-400 [cmdk-group-heading]:is(.rf-dark *){--tw-text-opacity:1;color:rgb(161 161 170/var(--tw-text-opacity,1))}.\\[\\&_\\[cmdk-group\\]\\:not\\(\\[hidden\\]\\)_\\~\\[cmdk-group\\]\\]\\:rf-pt-0 [cmdk-group]:not([hidden])~[cmdk-group]{padding-top:0}.\\[\\&_\\[cmdk-group\\]\\]\\:rf-px-2 [cmdk-group]{padding-left:.5rem;padding-right:.5rem}.\\[\\&_\\[cmdk-input-wrapper\\]_svg\\]\\:rf-h-5 [cmdk-input-wrapper] svg{height:1.25rem}.\\[\\&_\\[cmdk-input-wrapper\\]_svg\\]\\:rf-w-5 [cmdk-input-wrapper] svg{width:1.25rem}.\\[\\&_\\[cmdk-input\\]\\]\\:rf-h-12 [cmdk-input]{height:3rem}.\\[\\&_\\[cmdk-item\\]\\]\\:rf-px-2 [cmdk-item]{padding-left:.5rem;padding-right:.5rem}.\\[\\&_\\[cmdk-item\\]\\]\\:rf-py-3 [cmdk-item]{padding-bottom:.75rem;padding-top:.75rem}.\\[\\&_\\[cmdk-item\\]_svg\\]\\:rf-h-5 [cmdk-item] svg{height:1.25rem}.\\[\\&_\\[cmdk-item\\]_svg\\]\\:rf-w-5 [cmdk-item] svg{width:1.25rem}.\\[\\&_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}',dee=()=>{ee.useEffect(()=>{if(document.querySelector('style[data-styles="tscircuit-runframe"]'))return;const e=document.createElement("style");e.setAttribute("data-styles","tscircuit-runframe"),e.textContent=kHi,document.head.appendChild(e)},[])},FHi=t=>{ee.useEffect(()=>(t?document.body.style.overflow="hidden":document.body.style.overflow="",()=>{document.body.style.overflow=""}),[t])},Dhn=t=>`hsl(${oE.indexOf(t)*137.5%360}, 70%, 50%)`,LHi=({phaseTimings:t})=>{if(!t)return null;const e=Object.values(t).reduce((n,o)=>n+o,0);return K.jsxs("div",{className:"rf-space-y-2 rf-w-full rf-px-4",children:[K.jsx("div",{className:"rf-relative rf-h-8 rf-flex rf-rounded-sm",children:oE.map(n=>{const o=t[n]||0,i=o/e*100;return K.jsx("div",{className:"rf-group/bar rf-relative rf-overflow-visible",style:{width:`${i}%`,backgroundColor:Dhn(n)},children:K.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:[n,": ",o.toFixed(1),"ms"]})},n)})}),K.jsxs("div",{className:"rf-text-xs rf-text-gray-500",children:["Total: ",e.toFixed(2),"ms"]})]})},HHi=t=>{if(t instanceof Blob)return t;if(t==null)return"";if(typeof t=="string")return t;if(typeof t=="object")try{return JSON.stringify(t,null,2)}catch{return String(t)}return String(t)},OHi=({renderLog:t,onRerunWithDebug:e})=>{const[n,o]=ee.useState("chronological"),[i,r]=ee.useState(""),s=[{value:"",label:"None"},{value:"DEBUG=Group_doInitialSchematicTraceRender",label:"DEBUG=Group_doInitialSchematicTraceRender"},{value:"DEBUG=Group_doInitialSchematicLayoutMatchpack",label:"DEBUG=Group_doInitialSchematicLayoutMatchpack"},{value:"DEBUG=Group_doInitialPcbLayoutPack",label:"DEBUG=Group_doInitialPcbLayoutPack"}];if(!t)return K.jsxs("div",{className:"rf-p-4 rf-bg-gray-100 rf-rounded-md",children:[K.jsx("div",{className:"rf-mb-4",children:"No render log, make sure this tab is open when you render"}),e&&K.jsxs("div",{className:"rf-flex rf-gap-2 rf-items-center",children:[K.jsx("select",{value:i,onChange:c=>r(c.target.value),className:"rf-px-3 rf-py-1 rf-border rf-rounded rf-text-xs rf-bg-white",children:s.map(c=>K.jsx("option",{value:c.value,children:c.label},c.value))}),K.jsx(fA,{onClick:()=>e(i),size:"sm",className:"rf-text-xs",children:"Rerun Render with Debug"})]})]});const a=Object.entries(t?.phaseTimings??{});n==="chronological"?a.sort((c,l)=>oE.indexOf(c[0])-oE.indexOf(l[0])):a.sort((c,l)=>l[1]-c[1]);const A=a.reduce((c,[l,u])=>c+u,0);return K.jsxs("div",{className:"rf-bg-white",children:[K.jsxs("div",{className:"rf-flex rf-justify-between rf-items-center rf-mb-4",children:[K.jsx("div",{children:"Render Logs"}),K.jsxs("div",{className:"rf-flex rf-gap-4 rf-items-center",children:[e&&K.jsxs("div",{className:"rf-flex rf-gap-2 rf-items-center",children:[K.jsx("select",{value:i,onChange:c=>r(c.target.value),className:"rf-px-3 rf-py-1 rf-border rf-rounded rf-text-xs rf-bg-white",children:s.map(c=>K.jsx("option",{value:c.value,children:c.label},c.value))}),K.jsx(fA,{onClick:()=>e(i),size:"sm",className:"rf-text-xs",children:"Rerun Render with Debug"})]}),K.jsx("div",{className:"rf-flex rf-gap-2 rf-items-center",children:K.jsxs("select",{onChange:c=>{if(c.target.value){const l=t?.debugOutputs?.find(u=>u.name===c.target.value);if(l){const u=HHi(l.content),g=u instanceof Blob?u:new Blob([u],{type:"text/plain"}),h=URL.createObjectURL(g),d=document.createElement("a");d.href=h,d.download=`debug-${l.name}.txt`,document.body.appendChild(d),d.click(),document.body.removeChild(d),URL.revokeObjectURL(h)}c.target.value=""}},disabled:!t?.debugOutputs||t.debugOutputs.length===0,className:"rf-px-3 rf-py-1 rf-border rf-rounded rf-text-xs rf-bg-white disabled:rf-opacity-50 disabled:rf-cursor-not-allowed",children:[K.jsx("option",{value:"",children:"Download Debug Output"}),t?.debugOutputs?.map(c=>K.jsx("option",{value:c.name,children:c.name},c.name))]})}),K.jsxs("div",{className:"rf-flex rf-text-xs rf-items-center",children:[K.jsx("div",{className:"rf-mr-2",children:"Sort by:"}),K.jsxs("select",{value:n,onChange:c=>o(c.target.value),className:"rf-px-2 rf-py-1 rf-border rf-rounded rf-text-xs",children:[K.jsx("option",{value:"chronological",children:"Phase Order"}),K.jsx("option",{value:"longest",children:"Duration"})]})]})]})]}),K.jsx(LHi,{phaseTimings:t.phaseTimings}),K.jsxs("table",{className:"rf-w-full rf-text-xs",children:[K.jsx("thead",{children:K.jsxs("tr",{children:[K.jsx("th",{className:"rf-text-left rf-p-2",children:"Phase Order"}),K.jsx("th",{className:"rf-text-left rf-p-2",children:"Phase"}),K.jsx("th",{className:"rf-text-left rf-p-2",children:"Duration (ms)"})]})}),K.jsx("tbody",{children:a.map(([c,l])=>K.jsxs("tr",{children:[K.jsx("td",{className:"rf-p-2",children:oE.indexOf(c)}),K.jsx("td",{className:"rf-p-2",children:c}),K.jsx("td",{className:"rf-p-2",children:K.jsx("div",{className:"rf-w-8",children:K.jsx("div",{className:"rf-h-2 rf-rounded-sm",style:{backgroundColor:Dhn(c),width:`${l/A*100}%`}})})}),K.jsx("td",{className:"rf-p-2",children:K.jsxs("div",{className:"rf-flex w-full",children:[K.jsxs("span",{className:"rf-flex-grow",children:[l,"ms"]}),K.jsxs("span",{className:"rf-text-gray-500 rf-pr-2",children:[(l/A*100).toFixed(1),"%"]})]})})]},c))})]})]})};var GHi=8,I$e=t=>Math.hypot(t.a,t.b)||1,YHi=t=>[t.label,t.inlineLabel].filter(Boolean).join(`
5635
+ `,...i,style:o,children:[K.jsx("input",{type:"radio",checked:e,onChange:()=>{},readOnly:!0}),K.jsx("span",{style:{color:"#eee"},children:t})]})},SHi=({children:t,elements:e,onContextMenuOpenChange:n,getNetAtPoint:o,getComponentAtPoint:i,onViewSchematicComponent:r,xRayNetIds:s=[],onXRayNetsChange:a})=>{const A=IHi(),{isMouseOverContainer:c,setIsMouseOverContainer:l,selectedLayer:u,selectLayer:g,viewSettings:h,setIsShowingRatsNest:d,setIsShowingMultipleTracesLength:p,setIsShowingAutorouting:m,setIsShowingDrcErrors:_,setIsShowingDrcWarnings:f,setIsShowingCopperPours:I,setIsShowingCourtyards:C,setIsShowingPcbGroups:y,setIsShowingGroupAnchorOffsets:x,setIsShowingSolderMask:E,setIsShowingSilkscreen:B,setIsShowingFabricationNotes:S,setIsShowingPcbNotes:Q,setPcbGroupViewMode:w,setHoveredErrorId:M,setFocusedErrorId:k}=Kc(st=>({isMouseOverContainer:st.is_mouse_over_container,setIsMouseOverContainer:st.setIsMouseOverContainer,selectedLayer:st.selected_layer,selectLayer:st.selectLayer,viewSettings:{is_showing_rats_nest:st.is_showing_rats_nest,is_showing_multiple_traces_length:st.is_showing_multiple_traces_length,is_showing_autorouting:st.is_showing_autorouting,is_showing_drc_errors:st.is_showing_drc_errors,is_showing_drc_warnings:st.is_showing_drc_warnings,is_showing_copper_pours:st.is_showing_copper_pours,is_showing_courtyards:st.is_showing_courtyards,is_showing_pcb_groups:st.is_showing_pcb_groups,is_showing_group_anchor_offsets:st.is_showing_group_anchor_offsets,is_showing_solder_mask:st.is_showing_solder_mask,is_showing_silkscreen:st.is_showing_silkscreen,is_showing_fabrication_notes:st.is_showing_fabrication_notes,is_showing_pcb_notes:st.is_showing_pcb_notes,pcb_group_view_mode:st.pcb_group_view_mode},setIsShowingRatsNest:st.setIsShowingRatsNest,setIsShowingMultipleTracesLength:st.setIsShowingMultipleTracesLength,setIsShowingAutorouting:st.setIsShowingAutorouting,setIsShowingDrcErrors:st.setIsShowingDrcErrors,setIsShowingDrcWarnings:st.setIsShowingDrcWarnings,setIsShowingCopperPours:st.setIsShowingCopperPours,setIsShowingCourtyards:st.setIsShowingCourtyards,setIsShowingPcbGroups:st.setIsShowingPcbGroups,setIsShowingGroupAnchorOffsets:st.setIsShowingGroupAnchorOffsets,setIsShowingSolderMask:st.setIsShowingSolderMask,setIsShowingSilkscreen:st.setIsShowingSilkscreen,setIsShowingFabricationNotes:st.setIsShowingFabricationNotes,setIsShowingPcbNotes:st.setIsShowingPcbNotes,setPcbGroupViewMode:st.setPcbGroupViewMode,setHoveredErrorId:st.setHoveredErrorId,setFocusedErrorId:st.setFocusedErrorId})),[R,F]=ee.useState(null),[O,U]=ee.useState([]),[Y,W]=ee.useState(),[te,j]=ee.useState("Net"),[J,ie]=ee.useState(),oe=st=>{const Yt=st.currentTarget.getBoundingClientRect();return i?.({x:st.clientX-Yt.left,y:st.clientY-Yt.top})},ne=ee.useRef(null),ge=Kc(st=>st.in_edit_mode),ue=st=>{const Yt=st.currentTarget.getBoundingClientRect();return o?.({x:st.clientX-Yt.left,y:st.clientY-Yt.top})},_e=ee.useCallback(()=>{F(null),n?.(!1)},[n]),[le,fe]=ee.useState(!1),[he,ye]=ee.useState(!1),[Qe,we]=ee.useState(!1),[pe,ve]=ee.useState(!1),[Me,Pe]=ee.useState(!1);ee.useEffect(()=>{const st=()=>ve(!0),Yt=()=>ve(!1),pn=()=>Pe(!0),be=()=>Pe(!1);return window.addEventListener("arm-dimension-tool",st),window.addEventListener("disarm-dimension-tool",Yt),window.addEventListener("arm-bounds-tool",pn),window.addEventListener("disarm-bounds-tool",be),()=>{window.removeEventListener("arm-dimension-tool",st),window.removeEventListener("disarm-dimension-tool",Yt),window.removeEventListener("arm-bounds-tool",pn),window.removeEventListener("disarm-bounds-tool",be)}},[]);const He=ife(e??[]),Re=He,Ee=ee.useRef(!1),Te=ee.useRef(null),Ce={1:He[0]?()=>g(He[0]):()=>{},2:He[1]?()=>g(He[1]):()=>{},3:He[2]?()=>g(He[2]):()=>{},4:He[3]?()=>g(He[3]):()=>{},5:He[4]?()=>g(He[4]):()=>{},6:He[5]?()=>g(He[5]):()=>{},7:He[6]?()=>g(He[6]):()=>{},8:He[7]?()=>g(He[7]):()=>{},9:He[8]?()=>g(He[8]):()=>{},0:He[9]?()=>g(He[9]):()=>{}};X6("1",Ce[1],Te),X6("2",Ce[2],Te),X6("3",Ce[3],Te),X6("4",Ce[4],Te),X6("5",Ce[5],Te),X6("6",Ce[6],Te),X6("7",Ce[7],Te),X6("8",Ce[8],Te),X6("9",Ce[9],Te),X6("0",Ce[0],Te),ee.useLayoutEffect(()=>{if(Ee.current)return;Ee.current=!0;const st=Yt=>{if(Te.current){const pn=Te.current.getBoundingClientRect();Yt.clientX>=pn.left&&Yt.clientX<=pn.right&&Yt.clientY>=pn.top&&Yt.clientY<=pn.bottom&&l(!0)}document.removeEventListener("mousemove",st)};return document.addEventListener("mousemove",st),()=>{document.removeEventListener("mousemove",st)}},[l]);const Fe=ee.useCallback(()=>{l(!0)},[l]),Ye=ee.useCallback(()=>{c||l(!0)},[c,l]),tt=ee.useCallback(()=>{l(!1),ye(!1),fe(!1),we(!1)},[l]),At=ee.useCallback(()=>{ye(!he)},[he]),at=ee.useCallback(()=>{const st=!Qe;we(st),st&&fe(!1),st||M(null)},[Qe,M]),ot=ee.useCallback(()=>{we(!1)},[]),gt=ee.useCallback(()=>{d(!h.is_showing_rats_nest)},[h.is_showing_rats_nest,d]),Bt=ee.useCallback(()=>{ve(!0),Pe(!1),window.dispatchEvent(new Event("arm-dimension-tool"))},[]),Ct=ee.useCallback(()=>{Pe(!0),ve(!1),window.dispatchEvent(new Event("arm-bounds-tool"))},[]),Dt=ee.useCallback(()=>{const st=!le;fe(st),st&&we(!1)},[le]),Nt=ee.useCallback(st=>{st.stopPropagation()},[]);return K.jsxs("div",{ref:Te,onPointerDown:st=>{ne.current={x:st.clientX,y:st.clientY}},onClick:st=>{if(st.detail>1||ge||pe||Me||st.target.closest("button, input, select, [role=menu]"))return;const Yt=ne.current;if(!Yt||Math.hypot(st.clientX-Yt.x,st.clientY-Yt.y)>4)return;const pn=ue(st),be=oe(st);if(!pn&&!be)return;const et=pn?.netId;et&&s.includes(et)?(a?.(s.filter(It=>It!==et)),_e()):(W(et),j(pn?.displayName??"Net"),U(pn?.groups??[]),ie(be),n?.(!0),F({x:st.clientX,y:st.clientY}))},onDoubleClick:()=>{a?.([]),_e()},onContextMenu:st=>{st.preventDefault(),st.stopPropagation();const Yt=ue(st);ie(oe(st)),W(Yt?.netId),j(Yt?.displayName??"Net"),U(Yt?.groups??[]),n?.(!0),F({x:st.clientX,y:st.clientY})},style:{position:"relative",zIndex:"999 !important"},onMouseEnter:Fe,onMouseLeave:tt,onMouseMove:Ye,children:[t,R&&K.jsx(CHi,{position:R,component:J,onViewSchematicComponent:r,onClose:_e,xRayDisplayName:te,xRayGroups:O.filter(st=>st.netIds.some(Yt=>!s.includes(Yt))),onXRayGroup:st=>a?.([...new Set([...s,...st.netIds])]),onXRayNet:Y&&!s.includes(Y)?()=>a?.([...s,Y]):void 0,onExitXRayNet:s.length>0?()=>a?.([]):void 0}),K.jsxs("div",{style:{position:"absolute",bottom:4,right:8,pointerEvents:"none",color:"white",fontSize:11,opacity:c?.5:0,transition:"opacity 1s",transitionDelay:"2s",fontFamily:"sans-serif"},children:["@tscircuit/pcb-viewer@",fHi.version]}),K.jsxs("div",{"data-toolbar-overlay":!0,onTouchStart:st=>st.stopPropagation(),onTouchEnd:st=>st.stopPropagation(),onTouchMove:st=>st.stopPropagation(),onMouseDown:Nt,onMouseMove:Nt,onMouseUp:Nt,onPointerDown:Nt,onPointerMove:Nt,onPointerUp:Nt,onWheel:Nt,style:{position:"absolute",opacity:A||c?1:0,top:16,left:16,right:A?16:"auto",transition:c?"opacity 100ms linear":"opacity 300ms linear",zIndex:Tu.toolbarOverlay,color:"red",display:"flex",flexWrap:"wrap",maxWidth:"550px",gap:4,fontSize:12,fontFamily:"sans-serif"},children:[K.jsxs(YU,{isSmallScreen:A,onClick:At,onMouseLeave:()=>{he&&ye(!1)},children:[K.jsxs("div",{children:["layer:"," ",K.jsx("span",{style:{marginLeft:2,fontWeight:500,color:lee[u]},children:u})]}),he&&K.jsx("div",{style:{marginTop:4,minWidth:120},children:Re.map(st=>K.jsx(bHi,{name:st,selected:st===u,onClick:()=>{g(st)}},st))})]}),K.jsx(BHi,{elements:e,isOpen:Qe,isSmallScreen:A,onToggle:at,onClose:ot,setHoveredErrorId:M,setFocusedErrorId:k}),K.jsx(YU,{isSmallScreen:A,style:{},onClick:gt,children:K.jsxs("div",{children:[h.is_showing_rats_nest?"✖ ":"","Rats Nest"]})}),K.jsx(YU,{isSmallScreen:A,style:pe?{backgroundColor:"#444"}:{},onClick:Bt,children:K.jsx("div",{children:"📏"})}),K.jsx(YU,{isSmallScreen:A,style:Me?{backgroundColor:"#444"}:{},onClick:Ct,children:K.jsx("div",{children:"Bounds"})}),K.jsx(YU,{isSmallScreen:A,onClick:Dt,children:K.jsxs("div",{children:[K.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"4px"},children:["View",K.jsx("span",{style:{fontSize:"8px",transform:le?"rotate(180deg)":"rotate(0)",transition:"transform 0.1s ease",display:"inline-block"},children:"▼"})]}),le&&K.jsxs("div",{style:{marginTop:4,minWidth:120},children:[K.jsx(I4,{label:"Show All Trace Lengths",checked:h.is_showing_multiple_traces_length,onClick:()=>{p(!h.is_showing_multiple_traces_length)}}),K.jsx(I4,{label:"Show Autorouting Animation",checked:h.is_showing_autorouting,onClick:()=>{m(!h.is_showing_autorouting)}}),K.jsx(I4,{label:"Show DRC Errors",checked:h.is_showing_drc_errors,onClick:()=>{_(!h.is_showing_drc_errors)}}),K.jsx(I4,{label:"Show DRC Warnings",checked:h.is_showing_drc_warnings,onClick:()=>{f(!h.is_showing_drc_warnings)}}),K.jsx(I4,{label:"Show Copper Pours",checked:h.is_showing_copper_pours,onClick:()=>{I(!h.is_showing_copper_pours)}}),K.jsx(I4,{label:"Show Courtyards",checked:h.is_showing_courtyards,onClick:()=>{C(!h.is_showing_courtyards)}}),K.jsx(I4,{label:"Show Solder Mask",checked:h.is_showing_solder_mask,onClick:()=>{E(!h.is_showing_solder_mask)}}),K.jsx(I4,{label:"Show Silkscreen",checked:h.is_showing_silkscreen,onClick:()=>{B(!h.is_showing_silkscreen)}}),K.jsx(I4,{label:"Show Fabrication Notes",checked:h.is_showing_fabrication_notes,onClick:()=>{S(!h.is_showing_fabrication_notes)}}),K.jsx(I4,{label:"Show PCB Notes",checked:h.is_showing_pcb_notes,onClick:()=>{Q(!h.is_showing_pcb_notes)}}),K.jsx(I4,{label:"Show Group Anchor Offsets",checked:h.is_showing_group_anchor_offsets,onClick:()=>{x(!h.is_showing_group_anchor_offsets)}}),K.jsx(I4,{label:"Show PCB Groups",checked:h.is_showing_pcb_groups,onClick:()=>{y(!h.is_showing_pcb_groups)}}),h.is_showing_pcb_groups&&K.jsxs("div",{style:{marginLeft:16},children:[K.jsx(Mhn,{label:"Show All Groups",checked:h.pcb_group_view_mode==="all",onClick:()=>{w("all")}}),K.jsx(Mhn,{label:"Show Named Groups",checked:h.pcb_group_view_mode==="named_only",onClick:()=>{w("named_only")}})]})]})]})})]})]})},QHi=t=>t.type==="pcb_manual_edit_conflict_warning"||t.type==="pcb_connector_not_in_accessible_orientation_warning",vHi=t=>t.type==="pcb_connector_not_in_accessible_orientation_warning"?`Connector faces ${t.facing_direction}; expected ${t.recommended_facing_direction}`:"Manual Edit Conflict",wHi=({children:t,transform:e=MP(),elements:n=[]})=>{const[o,{width:i,height:r}]=Aee(),s=ee.useRef(null),a=Kc(A=>A.is_showing_drc_warnings);return ee.useEffect(()=>{const A=s.current;if(!A||!i||!r)return;A.width=i,A.height=r;const c=A.getContext("2d");if(!c)return;c.clearRect(0,0,i,r);const l=n.filter(g=>g.type==="pcb_component"),u=n.filter(QHi);c.strokeStyle=$i.board.drc_warning,c.lineWidth=2,u.forEach(g=>{const h=l.find(U=>U.pcb_component_id===g.pcb_component_id);if(!h)return;const{width:d,height:p,center:m}=h,_=or(e,m),f=d*Math.abs(e.a),I=p*Math.abs(e.d),C=.1*Math.abs(e.a),y=f+C*2,x=I+C*2,E=_.x-y/2,B=_.y-x/2;c.beginPath(),c.rect(E,B,y,x),c.stroke();const S=vHi(g),Q=4,w=Math.max(8,Math.min(12,10*Math.abs(e.a)));c.font=`${w}px sans-serif`;const k=c.measureText(S).width+Q*2,R=w+Q*2,F=E+(y-k)/2,O=B+x+5;c.fillStyle="rgba(0, 0, 0, 0.7)",c.beginPath(),c.roundRect(F,O,k,R,3),c.fill(),c.fillStyle=$i.board.drc_warning,c.textAlign="center",c.textBaseline="middle",c.fillText(S,F+k/2,O+R/2)})},[n,e,i,r,a]),a?K.jsxs("div",{ref:o,style:{position:"relative",width:"100%",height:"100%"},children:[t,K.jsx("canvas",{ref:s,style:{position:"absolute",top:0,left:0,pointerEvents:"none",zIndex:Tu.warnings}})]}):K.jsx("div",{ref:o,style:{position:"relative",width:"100%",height:"100%"},children:t})},PHi=t=>{const{transform:e,elements:n}=t,{hoveredErrorId:o,focusedErrorId:i,isShowingCopperPours:r,selectedLayer:s}=Kc(w=>({hoveredErrorId:w.hovered_error_id,focusedErrorId:w.focused_error_id,isShowingCopperPours:w.is_showing_copper_pours,selectedLayer:w.selected_layer})),a=i??o,A=ee.useMemo(()=>r?n:n.filter(w=>w.type!=="pcb_copper_pour"),[n,r]),c=ee.useMemo(()=>{const w=eFi(n);return A.flatMap(M=>tFi(M,n,w))},[A,n]),l=ee.useMemo(()=>Gdn(n),[n]),[u,g]=ee.useState([]);ee.useEffect(()=>g([]),[l]),ee.useEffect(()=>{if(u.length===0)return;const w=M=>{M.key==="Escape"&&g([])};return window.addEventListener("keydown",w,!0),()=>window.removeEventListener("keydown",w,!0)},[u.length]);const h=ee.useMemo(()=>u.length>0?A.filter(w=>jdn(w)&&u.includes(cee(w,l)??"")):void 0,[A,l,u]),d=ee.useMemo(()=>{if(!h)return c;const w=new Set(h);return c.filter(M=>(M._element?.type==="pcb_smtpad"||M._element?.type==="pcb_plated_hole")&&w.has(M._element))},[c,h]),p=w=>{if(!e)return;const M=_$e(c,or(K6(e),w),e,s).filter(k=>k._element?.type==="pcb_smtpad"||k._element?.type==="pcb_plated_hole");return M.sort((k,R)=>+(R.layer===s)-+(k.layer===s)),Vki(M[0]?._element,n)},m=w=>{if(!e)return;const M=(F,O)=>({netId:F,displayName:pFi(O,n,l),groups:mFi(F,n,l)}),R=_$e(c,or(K6(e),w),e,s,u.length>0).filter(F=>jdn(F._element)&&F.layer!=="drill");R.sort((F,O)=>+(O.layer===s)-+(F.layer===s));for(const F of R){const O=cee(F._element,l);if(O&&u.includes(O))return M(O,F._element)}for(const F of R){const O=cee(F._element,l);if(O)return M(O,F._element)}},[_,f]=ee.useState({drawingObjectIdsWithMouseOver:new Set,primitiveIdsInMousedOverNet:[]}),[I,C]=ee.useState([]),y=ee.useRef(e??null),x=ee.useRef(null),E=ee.useMemo(()=>Ydn(n),[n]),B=ee.useMemo(()=>{if(!a)return[];const M=n.filter(k=>k.type.includes("error")).find((k,R)=>GU(k,R)===a);return M?uFi(M):[]},[a,n]);ee.useEffect(()=>{e&&(y.current=e)},[e]),ee.useEffect(()=>()=>{Jdn(x.current)},[]),ee.useEffect(()=>{if(!t.width||!t.height||!t.setTransform||!i)return;const w=zdn(n,i);if(!w)return;const M=cFi({error:w,indexes:E});if(!M)return;const k=y.current??e;if(!k)return;const R=lFi({bounds:M,width:t.width,height:t.height});Jdn(x.current),hFi({startTransform:k,endTransform:R,durationMs:420,setAnimationFrameId:F=>{x.current=F},onUpdate:F=>{y.current=F,t.setTransform?.(F)}})},[i,n,E,t.height,t.setTransform,t.width]);const S=ee.useMemo(()=>{if(u.length>0)return c;const w=[..._.primitiveIdsInMousedOverNet,...B];return nFi({primitivesWithoutInteractionMetadata:c,drawingObjectIdsWithMouseOver:_.drawingObjectIdsWithMouseOver,primitiveIdsInMousedOverNet:w})},[c,_,B,u]),Q=ee.useCallback(w=>{const M=[];for(const F of w)if(F._element){const O=l.getNetConnectedToId("pcb_port_id"in F._element?F._element?.pcb_port_id:"pcb_trace_id"in F._element?F._element?.pcb_trace_id:"");M.push(...l.getIdsConnectedToNet(O))}const k=new Set(w.map(F=>F._pcb_drawing_object_id));f({drawingObjectIdsWithMouseOver:k,primitiveIdsInMousedOverNet:M});const R=w.map(F=>F._parent_pcb_component?.type==="pcb_component"&&F._parent_pcb_component.pcb_component_id?F._parent_pcb_component.pcb_component_id:F._element?.type==="pcb_component"&&F._element.pcb_component_id?F._element.pcb_component_id:null).filter(F=>!!F);C(Array.from(new Set(R)))},[l]);return K.jsx(pHi,{elements:A,transform:e,primitives:d,selectedLayer:s,onMouseHoverOverPrimitives:Q,children:K.jsx(ZLi,{disabled:!t.allowEditing,transform:e,soup:n,cancelPanDrag:t.cancelPanDrag,onCreateEditEvent:t.onCreateEditEvent,onModifyEditEvent:t.onModifyEditEvent,children:K.jsx(qLi,{transform:e,focusOnHover:t.focusOnHover,primitives:c,onBoundsSelected:t.onBoundsSelected,cancelPanDrag:t.cancelPanDrag,children:K.jsx(SHi,{elements:n,getNetAtPoint:m,xRayNetIds:u,onXRayNetsChange:g,onContextMenuOpenChange:t.onContextMenuOpenChange,getComponentAtPoint:p,onViewSchematicComponent:t.onViewSchematicComponent,children:K.jsx(tHi,{transform:e,elements:n,children:K.jsx(_Hi,{transform:e,soup:n,children:K.jsx(mHi,{transform:e,elements:n,hoveredComponentIds:I,children:K.jsx(HLi,{transform:e,debugGraphics:t.debugGraphics,children:K.jsx(wHi,{transform:e,elements:n,children:t.renderer==="canvas"?K.jsx(g$e,{transform:e,primitives:S,elements:A,xRayElements:h,width:t.width,height:t.height,grid:t.grid}):K.jsx(_Li,{transform:e,primitives:S,elements:n,xRayElements:h,width:t.width,height:t.height,grid:t.grid})})})})})})})})})})},lfe=t=>Number.isFinite(t)?t.toFixed(4):"NaN",MHi=t=>{let e=5381;for(let n=0;n<t.length;n++)e=(e<<5)+e+t.charCodeAt(n);return Math.abs(e)},DHi=t=>{if(!t?.length)return"0";const e=[];for(const i of t){if(!i?.type?.startsWith("pcb_"))continue;const r=_ki(i),s=A$e([i]),a=[lfe(s.minX),lfe(s.minY),lfe(s.maxX),lfe(s.maxY)].join(",");let A=`${r}:${a}`;if(i.type==="pcb_trace"){const c=(i.route??[]).length;A+=`:${c}`;for(const l of i.route??[])l.route_type==="via"&&(A+=`:${l.tented_on_top}:${l.tented_on_bottom}`)}i.type==="pcb_board"&&(A+=`:${i.default_via_tented_on_top}:${i.default_via_tented_on_bottom}`),i.type==="pcb_via"&&(A+=`:${i.tented_on_top}:${i.tented_on_bottom}`),e.push(A)}if(e.length===0)return"0";e.sort();const n=e.join(","),o=MHi(n);return`${e.length}_${o.toString(36)}`},NHi=t=>{if(!t)return"empty";const e=t.find(o=>o.type==="pcb_board");if(!e)return"no-board";const n=o=>Math.round(o*1e3)/1e3;return e.outline?e.outline.map(o=>`${n(o.x)}_${n(o.y)}`).join(","):`${n(e.width)}_${n(e.height)}`},RHi=wE(uh(400,300),bU(40,-40)),f$e=({circuitJson:t,debugGraphics:e,height:n=600,renderer:o="webgpu",initialState:i,allowEditing:r=!0,editEvents:s,onEditEventsChanged:a,onBoundsSelected:A,onViewSchematicComponent:c,focusOnHover:l=!1,clickToInteractEnabled:u=!1,disablePcbGroups:g=!1})=>{const[h,d]=ee.useState(o);ee.useEffect(()=>d(o),[o]);const p=ee.useMemo(()=>({renderer:h,setRenderer:d}),[h]),[m,_]=ee.useState(!u),[f,I]=ee.useState(!1),C=ee.useRef(!1),[y,x]=Aee(),[E,B]=ee.useState(RHi),S=ee.useCallback(ge=>{if(C.current||ge instanceof MouseEvent&&(ge.button===2||(ge.buttons&2)!==0))return!1;const ue=ge.target;return ue instanceof Element?!ue.closest("[data-toolbar-overlay]"):!0},[]),{ref:Q,setTransform:w,cancelDrag:M}=Kki({transform:E,onSetTransform:B,enabled:m&&!f,shouldDrag:S}),k=ee.useCallback(ge=>{C.current=ge,ge&&M(),I(ge)},[M]);let[R,F]=ee.useState([]);R=s??R;const O=ee.useRef(!1),U=ee.useRef(null),Y=ee.useMemo(()=>DHi(t),[t]),W=NHi(t),te=()=>{const ge=x?.width>0?x:{width:500,height:500},{center:ue,width:_e,height:le}=J.some(ye=>ye.type.startsWith("pcb_"))?Bki(J.filter(ye=>ye.type.startsWith("pcb_"))):{center:{x:0,y:0},width:.001,height:.001},fe=Math.min((ge.width??0)/_e,(ge.height??0)/le,100)*.75,he=wE(uh((ge.width??0)/2,(ge.height??0)/2),bU(fe,-fe,0,0),uh(-ue.x,-ue.y));w(he)};ee.useEffect(()=>{x?.width&&t&&t.length!==0&&(O.current||(te(),O.current=!0))},[t,x]),ee.useEffect(()=>{O.current===!0&&te()},[W]);const j=ee.useMemo(()=>t?.filter(ge=>ge.type.startsWith("pcb_")||ge.type.startsWith("source_"))??[],[Y]),J=ee.useMemo(()=>xPo({circuitJson:j,editEvents:R}),[j,R]),ie=ge=>{F([...R,ge]),a?.([...R,ge])},oe=ge=>{const ue=R.map(_e=>_e.edit_event_id===ge.edit_event_id?{..._e,...ge}:_e);F(ue),a?.(ue)},ne=ee.useMemo(()=>({...i,...g&&{is_showing_pcb_groups:!1}}),[i,g]);return K.jsx(Lgn.Provider,{value:p,children:K.jsxs("div",{ref:Q,style:{position:"relative"},onContextMenu:ge=>ge.preventDefault(),children:[K.jsx("div",{ref:y,children:K.jsxs(Mki,{initialState:ne,disablePcbGroups:g,children:[K.jsx(PHi,{renderer:h,transform:E,setTransform:w,height:n,width:x.width,allowEditing:r,focusOnHover:l,onBoundsSelected:A,onViewSchematicComponent:c,cancelPanDrag:M,onContextMenuOpenChange:k,onCreateEditEvent:ie,onModifyEditEvent:oe,grid:{spacing:1,view_window:{left:0,right:x.width||500,top:n,bottom:0}},elements:J,debugGraphics:e}),K.jsx(Dki,{})]})}),u&&!m&&K.jsx("div",{onClick:()=>{_(!0),te()},onTouchStart:ge=>{const ue=ge.touches[0];U.current={x:ue.clientX,y:ue.clientY}},onTouchEnd:ge=>{const ue=ge.changedTouches[0],_e=U.current;if(!_e)return;const le=Math.abs(ue.clientX-_e.x),fe=Math.abs(ue.clientY-_e.y);le<10&&fe<10&&(ge.preventDefault(),_(!0),te()),U.current=null},style:{position:"absolute",inset:0,cursor:"pointer",zIndex:Tu.clickToInteractOverlay,display:"flex",alignItems:"center",justifyContent:"center",touchAction:"pan-x pan-y pinch-zoom"},children:K.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 THi=({circuitJson:t,containerClassName:e,...n})=>{const o=ee.useRef(null),[i,r]=ee.useState(620);return ee.useLayoutEffect(()=>{const s=()=>{if(o.current){const A=o.current.clientHeight,c=window.innerHeight;r(Math.min(Math.max(A,620),c))}};s();const a=new ResizeObserver(s);return o.current&&a.observe(o.current),window.addEventListener("resize",s),()=>{a.disconnect(),window.removeEventListener("resize",s)}},[]),K.jsx("div",{ref:o,className:e||"rf-w-full rf-h-full",children:K.jsx(f$e,{...n,circuitJson:t,height:i})})},kHi='*,: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.19 | 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-1{right:.25rem}.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-\\[101\\]{z-index:101!important}.\\!rf-z-\\[200\\]{z-index:200!important}.rf-z-10{z-index:10}.rf-z-50{z-index:50}.rf-z-\\[100\\]{z-index:100}.rf-z-\\[101\\]{z-index:101}.rf-z-\\[102\\]{z-index:102}.rf-order-1{order:1}.rf-order-2{order:2}.rf-order-3{order:3}.rf-m-0{margin:0}.rf-m-1{margin:.25rem}.rf-m-6{margin:1.5rem}.-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-4{margin-left:1rem;margin-right:1rem}.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-0{margin-bottom:0}.rf-mb-0\\.5{margin-bottom:.125rem}.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-7{margin-bottom:1.75rem}.rf-mb-8{margin-bottom:2rem}.rf-ml-1{margin-left:.25rem}.rf-ml-2{margin-left:.5rem}.rf-ml-6{margin-left:1.5rem}.rf-ml-auto{margin-left:auto}.rf-mr-1{margin-right:.25rem}.rf-mr-2{margin-right:.5rem}.rf-mr-4{margin-right:1rem}.rf-mr-auto{margin-right:auto}.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-block{display:inline-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-\\[4\\/3\\]{aspect-ratio:4/3}.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-2{height:.5rem;width:.5rem}.rf-size-3{height:.75rem;width:.75rem}.rf-size-4{height:1rem;width:1rem}.\\!rf-h-2{height:.5rem!important}.\\!rf-h-2\\.5{height:.625rem!important}.rf-h-0{height:0}.rf-h-0\\.5{height:.125rem}.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-20{height:5rem}.rf-h-24{height:6rem}.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-7{height:1.75rem}.rf-h-8{height:2rem}.rf-h-9{height:2.25rem}.rf-h-\\[400px\\]{height:400px}.rf-h-\\[calc\\(100vh-52px\\)\\]{height:calc(100vh - 52px)}.rf-h-\\[calc\\(100vh-60px\\)\\]{height:calc(100vh - 60px)}.rf-h-\\[var\\(--radix-select-trigger-height\\)\\]{height:var(--radix-select-trigger-height)}.rf-h-auto{height:auto}.rf-h-fit{height:-moz-fit-content;height:fit-content}.rf-h-full{height:100%}.rf-h-px{height:1px}.rf-h-screen{height:100vh}.\\!rf-max-h-\\[40vh\\]{max-height:40vh!important}.\\!rf-max-h-\\[80vh\\]{max-height:80vh!important}.rf-max-h-16{max-height:4rem}.rf-max-h-20{max-height:5rem}.rf-max-h-24{max-height:6rem}.rf-max-h-28{max-height:7rem}.rf-max-h-32{max-height:8rem}.rf-max-h-64{max-height:16rem}.rf-max-h-96{max-height:24rem}.rf-max-h-\\[120px\\]{max-height:120px}.rf-max-h-\\[150px\\]{max-height:150px}.rf-max-h-\\[200px\\]{max-height:200px}.rf-max-h-\\[300px\\]{max-height:300px}.rf-max-h-\\[90vh\\]{max-height:90vh}.rf-max-h-full{max-height:100%}.rf-max-h-none{max-height:none}.rf-min-h-0{min-height:0}.rf-min-h-56{min-height:14rem}.rf-min-h-72{min-height:18rem}.rf-min-h-\\[100px\\]{min-height:100px}.rf-min-h-\\[200px\\]{min-height:200px}.rf-min-h-\\[300px\\]{min-height:300px}.rf-min-h-\\[360px\\]{min-height:360px}.rf-min-h-\\[400px\\]{min-height:400px}.rf-min-h-\\[620px\\]{min-height:620px}.rf-min-h-\\[calc\\(100vh-240px\\)\\]{min-height:calc(100vh - 240px)}.rf-min-h-full{min-height:100%}.\\!rf-w-2{width:.5rem!important}.\\!rf-w-2\\.5{width:.625rem!important}.\\!rf-w-\\[95vw\\]{width:95vw!important}.rf-w-1{width:.25rem}.rf-w-10{width:2.5rem}.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-20{width:5rem}.rf-w-24{width:6rem}.rf-w-28{width:7rem}.rf-w-3{width:.75rem}.rf-w-3\\.5{width:.875rem}.rf-w-32{width:8rem}.rf-w-4{width:1rem}.rf-w-40{width:10rem}.rf-w-48{width:12rem}.rf-w-5{width:1.25rem}.rf-w-6{width:1.5rem}.rf-w-64{width:16rem}.rf-w-7{width:1.75rem}.rf-w-72{width:18rem}.rf-w-8{width:2rem}.rf-w-80{width:20rem}.rf-w-9{width:2.25rem}.rf-w-96{width:24rem}.rf-w-fit{width:-moz-fit-content;width:fit-content}.rf-w-full{width:100%}.rf-w-screen{width:100vw}.rf-min-w-0{min-width:0}.rf-min-w-10{min-width:2.5rem}.rf-min-w-16{min-width:4rem}.rf-min-w-32{min-width:8rem}.rf-min-w-80{min-width:20rem}.rf-min-w-96{min-width:24rem}.rf-min-w-\\[12px\\]{min-width:12px}.rf-min-w-\\[148px\\]{min-width:148px}.rf-min-w-\\[192px\\]{min-width:192px}.rf-min-w-\\[600px\\]{min-width:600px}.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-\\[95vw\\]{max-width:95vw!important}.rf-max-w-2xl{max-width:42rem}.rf-max-w-3xl{max-width:48rem}.rf-max-w-4xl{max-width:56rem}.rf-max-w-5xl{max-width:64rem}.rf-max-w-64{max-width:16rem}.rf-max-w-7xl{max-width:80rem}.rf-max-w-96{max-width:24rem}.rf-max-w-\\[1000px\\]{max-width:1000px}.rf-max-w-\\[150px\\]{max-width:150px}.rf-max-w-\\[200px\\]{max-width:200px}.rf-max-w-\\[320px\\]{max-width:320px}.rf-max-w-\\[40\\%\\]{max-width:40%}.rf-max-w-\\[600px\\]{max-width:600px}.rf-max-w-full{max-width:100%}.rf-max-w-lg{max-width:32rem}.rf-max-w-md{max-width:28rem}.rf-max-w-none{max-width:none}.rf-max-w-xl{max-width:36rem}.rf-max-w-xs{max-width:20rem}.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-origin-\\[--radix-popover-content-transform-origin\\]{transform-origin:var(--radix-popover-content-transform-origin)}.-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-1\\/2{--tw-translate-x:-50%}.rf--translate-x-1\\/2,.rf--translate-y-0{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-0{--tw-translate-y:-0px}.rf--translate-y-1{--tw-translate-y:-0.25rem}.rf--translate-y-1,.rf-translate-x-\\[-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-x-\\[-50\\%\\]{--tw-translate-x:-50%}.rf-translate-y-\\[-50\\%\\]{--tw-translate-y:-50%}.-rf-rotate-90,.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-rotate-90{--tw-rotate:-90deg}.rf-rotate-90{--tw-rotate:90deg}.rf-rotate-90,.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-grid-cols-3{grid-template-columns:repeat(3,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-content-center{place-content:center}.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-items-baseline{align-items:baseline}.rf-items-stretch{align-items:stretch}.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-1\\.5{gap:.375rem}.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-gap-x-5{-moz-column-gap:1.25rem;column-gap:1.25rem}.rf-gap-y-1{row-gap:.25rem}.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-1>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-bottom:calc(.25rem*var(--tw-space-y-reverse));margin-top:calc(.25rem*(1 - var(--tw-space-y-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-3>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-bottom:calc(.75rem*var(--tw-space-y-reverse));margin-top:calc(.75rem*(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}.rf-overflow-x-clip{overflow-x:clip}.rf-truncate{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.rf-whitespace-normal{white-space:normal}.rf-whitespace-nowrap{white-space:nowrap}.rf-whitespace-pre-wrap{white-space:pre-wrap}.rf-text-nowrap{text-wrap:nowrap}.rf-break-words{overflow-wrap:break-word}.rf-break-all{word-break:break-all}.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-none{border-radius:0}.rf-rounded-sm{border-radius:calc(var(--radius) - 4px)}.rf-rounded-xl{border-radius:.75rem}.rf-border{border-width:1px}.rf-border-0{border-width:0}.rf-border-2{border-width:2px}.rf-border-y{border-top-width:1px}.rf-border-b,.rf-border-y{border-bottom-width:1px}.rf-border-l-2{border-left-width:2px}.rf-border-l-4{border-left-width:4px}.rf-border-r{border-right-width:1px}.rf-border-t{border-top-width:1px}.rf-border-none{border-style:none}.rf-border-blue-100{--tw-border-opacity:1;border-color:rgb(219 234 254/var(--tw-border-opacity,1))}.rf-border-blue-200{--tw-border-opacity:1;border-color:rgb(191 219 254/var(--tw-border-opacity,1))}.rf-border-blue-300{--tw-border-opacity:1;border-color:rgb(147 197 253/var(--tw-border-opacity,1))}.rf-border-blue-400{--tw-border-opacity:1;border-color:rgb(96 165 250/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-border{border-color:hsl(var(--border))}.rf-border-emerald-500{--tw-border-opacity:1;border-color:rgb(16 185 129/var(--tw-border-opacity,1))}.rf-border-gray-100{--tw-border-opacity:1;border-color:rgb(243 244 246/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-green-400{--tw-border-opacity:1;border-color:rgb(74 222 128/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-orange-100{--tw-border-opacity:1;border-color:rgb(255 237 213/var(--tw-border-opacity,1))}.rf-border-orange-200{--tw-border-opacity:1;border-color:rgb(254 215 170/var(--tw-border-opacity,1))}.rf-border-orange-500{--tw-border-opacity:1;border-color:rgb(249 115 22/var(--tw-border-opacity,1))}.rf-border-primary{border-color:hsl(var(--primary))}.rf-border-red-100{--tw-border-opacity:1;border-color:rgb(254 226 226/var(--tw-border-opacity,1))}.rf-border-red-200{--tw-border-opacity:1;border-color:rgb(254 202 202/var(--tw-border-opacity,1))}.rf-border-red-300{--tw-border-opacity:1;border-color:rgb(252 165 165/var(--tw-border-opacity,1))}.rf-border-red-400{--tw-border-opacity:1;border-color:rgb(248 113 113/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-red-600{--tw-border-opacity:1;border-color:rgb(220 38 38/var(--tw-border-opacity,1))}.rf-border-red-700{--tw-border-opacity:1;border-color:rgb(185 28 28/var(--tw-border-opacity,1))}.rf-border-red-800{--tw-border-opacity:1;border-color:rgb(153 27 27/var(--tw-border-opacity,1))}.rf-border-slate-200{--tw-border-opacity:1;border-color:rgb(226 232 240/var(--tw-border-opacity,1))}.rf-border-slate-700{--tw-border-opacity:1;border-color:rgb(51 65 85/var(--tw-border-opacity,1))}.rf-border-slate-800{--tw-border-opacity:1;border-color:rgb(30 41 59/var(--tw-border-opacity,1))}.rf-border-slate-800\\/60{border-color:rgba(30,41,59,.6)}.rf-border-transparent{border-color:transparent}.rf-border-yellow-200{--tw-border-opacity:1;border-color:rgb(254 240 138/var(--tw-border-opacity,1))}.rf-border-zinc-100{--tw-border-opacity:1;border-color:rgb(244 244 245/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-border-l-blue-500{--tw-border-opacity:1;border-left-color:rgb(59 130 246/var(--tw-border-opacity,1))}.rf-border-t-blue-600{--tw-border-opacity:1;border-top-color:rgb(37 99 235/var(--tw-border-opacity,1))}.rf-bg-amber-50{--tw-bg-opacity:1;background-color:rgb(255 251 235/var(--tw-bg-opacity,1))}.rf-bg-amber-50\\/30{background-color:rgba(255,251,235,.3)}.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-emerald-500{--tw-bg-opacity:1;background-color:rgb(16 185 129/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-300{--tw-bg-opacity:1;background-color:rgb(134 239 172/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-green-600{--tw-bg-opacity:1;background-color:rgb(22 163 74/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-100{--tw-bg-opacity:1;background-color:rgb(255 237 213/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-orange-50{--tw-bg-opacity:1;background-color:rgb(255 247 237/var(--tw-bg-opacity,1))}.rf-bg-orange-50\\/50{background-color:rgba(255,247,237,.5)}.rf-bg-orange-500{--tw-bg-opacity:1;background-color:rgb(249 115 22/var(--tw-bg-opacity,1))}.rf-bg-popover{background-color:hsl(var(--popover))}.rf-bg-purple-500{--tw-bg-opacity:1;background-color:rgb(168 85 247/var(--tw-bg-opacity,1))}.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-50\\/50{background-color:rgba(254,242,242,.5)}.rf-bg-red-500{--tw-bg-opacity:1;background-color:rgb(239 68 68/var(--tw-bg-opacity,1))}.rf-bg-red-600{--tw-bg-opacity:1;background-color:rgb(220 38 38/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-red-950{--tw-bg-opacity:1;background-color:rgb(69 10 10/var(--tw-bg-opacity,1))}.rf-bg-slate-50{--tw-bg-opacity:1;background-color:rgb(248 250 252/var(--tw-bg-opacity,1))}.rf-bg-slate-800{--tw-bg-opacity:1;background-color:rgb(30 41 59/var(--tw-bg-opacity,1))}.rf-bg-slate-900{--tw-bg-opacity:1;background-color:rgb(15 23 42/var(--tw-bg-opacity,1))}.rf-bg-transparent{background-color:transparent}.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-yellow-50{--tw-bg-opacity:1;background-color:rgb(254 252 232/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-zinc-950{--tw-bg-opacity:1;background-color:rgb(9 9 11/var(--tw-bg-opacity,1))}.rf-bg-opacity-50{--tw-bg-opacity:0.5}.rf-bg-gradient-to-br{background-image:linear-gradient(to bottom right,var(--tw-gradient-stops))}.rf-from-blue-500{--tw-gradient-from:#3b82f6 var(--tw-gradient-from-position);--tw-gradient-to:rgba(59,130,246,0) var(--tw-gradient-to-position);--tw-gradient-stops:var(--tw-gradient-from),var(--tw-gradient-to)}.rf-from-emerald-500{--tw-gradient-from:#10b981 var(--tw-gradient-from-position);--tw-gradient-to:rgba(16,185,129,0) var(--tw-gradient-to-position);--tw-gradient-stops:var(--tw-gradient-from),var(--tw-gradient-to)}.rf-from-green-500{--tw-gradient-from:#22c55e var(--tw-gradient-from-position);--tw-gradient-to:rgba(34,197,94,0) var(--tw-gradient-to-position);--tw-gradient-stops:var(--tw-gradient-from),var(--tw-gradient-to)}.rf-from-red-500{--tw-gradient-from:#ef4444 var(--tw-gradient-from-position);--tw-gradient-to:rgba(239,68,68,0) var(--tw-gradient-to-position);--tw-gradient-stops:var(--tw-gradient-from),var(--tw-gradient-to)}.rf-to-blue-600{--tw-gradient-to:#2563eb var(--tw-gradient-to-position)}.rf-to-emerald-600{--tw-gradient-to:#059669 var(--tw-gradient-to-position)}.rf-to-green-600{--tw-gradient-to:#16a34a var(--tw-gradient-to-position)}.rf-to-red-600{--tw-gradient-to:#dc2626 var(--tw-gradient-to-position)}.rf-fill-amber-500{fill:#f59e0b}.rf-fill-current{fill:currentColor}.rf-stroke-1{stroke-width:1}.rf-object-contain{-o-object-fit:contain;object-fit:contain}.rf-object-cover{-o-object-fit:cover;object-fit:cover}.\\!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-1\\.5{padding-left:.375rem;padding-right:.375rem}.rf-px-2{padding-left:.5rem;padding-right:.5rem}.rf-px-2\\.5{padding-left:.625rem;padding-right:.625rem}.rf-px-3{padding-left:.75rem;padding-right:.75rem}.rf-px-4{padding-left:1rem;padding-right:1rem}.rf-px-5{padding-left:1.25rem;padding-right:1.25rem}.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-6{padding-bottom:1.5rem;padding-top:1.5rem}.rf-py-8{padding-bottom:2rem;padding-top:2rem}.rf-pb-0{padding-bottom:0}.rf-pb-1{padding-bottom:.25rem}.rf-pb-1\\.5{padding-bottom:.375rem}.rf-pb-2{padding-bottom:.5rem}.rf-pb-3{padding-bottom:.75rem}.rf-pb-4{padding-bottom:1rem}.rf-pb-px{padding-bottom:1px}.rf-pl-10{padding-left:2.5rem}.rf-pl-11{padding-left:2.75rem}.rf-pl-12{padding-left:3rem}.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-0{padding-top:0}.rf-pt-1{padding-top:.25rem}.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-align-bottom{vertical-align:bottom}.rf-font-mono{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace}.rf-font-sans{font-family:ui-sans-serif,system-ui,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji}.rf-text-2xl{font-size:1.5rem;line-height:2rem}.rf-text-3xl{font-size:1.875rem;line-height:2.25rem}.rf-text-\\[10px\\]{font-size:10px}.rf-text-\\[11px\\]{font-size:11px}.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-normal{font-weight:400!important}.rf-font-bold{font-weight:700}.rf-font-medium{font-weight:500}.rf-font-normal{font-weight:400}.rf-font-semibold{font-weight:600}.rf-uppercase{text-transform:uppercase}.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-4{line-height:1rem}.rf-leading-5{line-height:1.25rem}.rf-leading-\\[0\\.95rem\\]{line-height:.95rem}.rf-leading-\\[1rem\\]{line-height:1rem}.rf-leading-none{line-height:1}.rf-leading-relaxed{line-height:1.625}.rf-leading-tight{line-height:1.25}.rf-tracking-tight{letter-spacing:-.025em}.rf-tracking-wide{letter-spacing:.025em}.rf-tracking-wider{letter-spacing:.05em}.rf-tracking-widest{letter-spacing:.1em}.rf-text-amber-500{--tw-text-opacity:1;color:rgb(245 158 11/var(--tw-text-opacity,1))}.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-emerald-600{--tw-text-opacity:1;color:rgb(5 150 105/var(--tw-text-opacity,1))}.rf-text-foreground{color:hsl(var(--foreground))}.rf-text-gray-200{--tw-text-opacity:1;color:rgb(229 231 235/var(--tw-text-opacity,1))}.rf-text-gray-300{--tw-text-opacity:1;color:rgb(209 213 219/var(--tw-text-opacity,1))}.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{color:hsl(var(--muted))}.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-orange-400{--tw-text-opacity:1;color:rgb(251 146 60/var(--tw-text-opacity,1))}.rf-text-orange-500{--tw-text-opacity:1;color:rgb(249 115 22/var(--tw-text-opacity,1))}.rf-text-orange-600{--tw-text-opacity:1;color:rgb(234 88 12/var(--tw-text-opacity,1))}.rf-text-orange-700{--tw-text-opacity:1;color:rgb(194 65 12/var(--tw-text-opacity,1))}.rf-text-orange-800{--tw-text-opacity:1;color:rgb(154 52 18/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-slate-200{--tw-text-opacity:1;color:rgb(226 232 240/var(--tw-text-opacity,1))}.rf-text-slate-400{--tw-text-opacity:1;color:rgb(148 163 184/var(--tw-text-opacity,1))}.rf-text-slate-50{--tw-text-opacity:1;color:rgb(248 250 252/var(--tw-text-opacity,1))}.rf-text-slate-500{--tw-text-opacity:1;color:rgb(100 116 139/var(--tw-text-opacity,1))}.rf-text-slate-600{--tw-text-opacity:1;color:rgb(71 85 105/var(--tw-text-opacity,1))}.rf-text-slate-800{--tw-text-opacity:1;color:rgb(30 41 59/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-600{--tw-text-opacity:1;color:rgb(202 138 4/var(--tw-text-opacity,1))}.rf-text-yellow-700{--tw-text-opacity:1;color:rgb(161 98 7/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-600{--tw-text-opacity:1;color:rgb(82 82 91/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-accent-blue-600{accent-color:#2563eb}.rf-opacity-0{opacity:0}.rf-opacity-10{opacity:.1}.rf-opacity-100{opacity:1}.rf-opacity-25{opacity:.25}.rf-opacity-30{opacity:.3}.rf-opacity-50{opacity:.5}.rf-opacity-60{opacity:.6}.rf-opacity-70{opacity:.7}.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-none{box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}.rf-shadow-none{--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000}.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-shadow-sm,.rf-shadow-xl{box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}.rf-shadow-xl{--tw-shadow:0 20px 25px -5px rgba(0,0,0,.1),0 8px 10px -6px rgba(0,0,0,.1);--tw-shadow-colored:0 20px 25px -5px var(--tw-shadow-color),0 8px 10px -6px 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,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-transition-transform{transition-duration:.15s;transition-property:transform;transition-timing-function:cubic-bezier(.4,0,.2,1)}.rf-duration-150{transition-duration:.15s}.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-animate-in{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}.rf-fade-in-0{--tw-enter-opacity:0}.rf-zoom-in-95{--tw-enter-scale:.95}.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-150{animation-duration:.15s}.rf-duration-200{animation-duration:.2s}.rf-ease-in-out{animation-timing-function:cubic-bezier(.4,0,.2,1)}.no-scrollbar::-webkit-scrollbar{display:none}.no-scrollbar{-ms-overflow-style:none;scrollbar-width:none}.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--translate-y-0\\.5:hover{--tw-translate-y:-0.125rem;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))}.hover\\:rf-border-blue-300:hover{--tw-border-opacity:1;border-color:rgb(147 197 253/var(--tw-border-opacity,1))}.hover\\:rf-border-zinc-300:hover{--tw-border-opacity:1;border-color:rgb(212 212 216/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-gray-50:hover{--tw-bg-opacity:1;background-color:rgb(249 250 251/var(--tw-bg-opacity,1))}.hover\\:rf-bg-orange-100:hover{--tw-bg-opacity:1;background-color:rgb(255 237 213/var(--tw-bg-opacity,1))}.hover\\:rf-bg-red-100:hover{--tw-bg-opacity:1;background-color:rgb(254 226 226/var(--tw-bg-opacity,1))}.hover\\:rf-bg-red-500\\/90:hover{background-color:rgba(239,68,68,.9)}.hover\\:rf-bg-slate-100:hover{--tw-bg-opacity:1;background-color:rgb(241 245 249/var(--tw-bg-opacity,1))}.hover\\:rf-bg-slate-200:hover{--tw-bg-opacity:1;background-color:rgb(226 232 240/var(--tw-bg-opacity,1))}.hover\\:rf-bg-slate-50:hover{--tw-bg-opacity:1;background-color:rgb(248 250 252/var(--tw-bg-opacity,1))}.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-blue-800:hover{--tw-text-opacity:1;color:rgb(30 64 175/var(--tw-text-opacity,1))}.hover\\:rf-text-gray-700:hover{--tw-text-opacity:1;color:rgb(55 65 81/var(--tw-text-opacity,1))}.hover\\:rf-text-red-400:hover{--tw-text-opacity:1;color:rgb(248 113 113/var(--tw-text-opacity,1))}.hover\\:rf-text-slate-800:hover{--tw-text-opacity:1;color:rgb(30 41 59/var(--tw-text-opacity,1))}.hover\\:rf-text-slate-900:hover{--tw-text-opacity:1;color:rgb(15 23 42/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}.hover\\:rf-shadow-md:hover{--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);box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}.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-blue-500:focus{--tw-ring-opacity:1;--tw-ring-color:rgb(59 130 246/var(--tw-ring-opacity,1))}.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-900:focus-visible{--tw-ring-opacity:1;--tw-ring-color:rgb(24 24 27/var(--tw-ring-opacity,1))}.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-text-gray-500:disabled{--tw-text-opacity:1;color:rgb(107 114 128/var(--tw-text-opacity,1))}.disabled\\:rf-opacity-40:disabled{opacity:.4}.disabled\\:rf-opacity-50:disabled{opacity:.5}.rf-group:hover .group-hover\\:rf-scale-\\[1\\.03\\]{--tw-scale-x:1.03;--tw-scale-y:1.03;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-group:hover .group-hover\\:rf-opacity-100,.rf-group\\/bar:hover .group-hover\\/bar\\:rf-opacity-100{opacity:1}.rf-peer:disabled~.peer-disabled\\:rf-cursor-not-allowed{cursor:not-allowed}.rf-peer:disabled~.peer-disabled\\:rf-opacity-70{opacity:.7}.data-\\[disabled\\=true\\]\\:rf-pointer-events-none[data-disabled=true],.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-\\[selected\\=true\\]\\:rf-bg-zinc-100[data-selected=true]{--tw-bg-opacity:1;background-color:rgb(244 244 245/var(--tw-bg-opacity,1))}.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-\\[selected\\=true\\]\\:rf-text-zinc-900[data-selected=true]{--tw-text-opacity:1;color:rgb(24 24 27/var(--tw-text-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\\=true\\]\\:rf-opacity-50[data-disabled=true],.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-gray-700:is(.rf-dark *){--tw-bg-opacity:1;background-color:rgb(55 65 81/var(--tw-bg-opacity,1))}.dark\\:rf-bg-gray-800:is(.rf-dark *){--tw-bg-opacity:1;background-color:rgb(31 41 55/var(--tw-bg-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-900:is(.rf-dark *){--tw-bg-opacity:1;background-color:rgb(24 24 27/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-gray-500:is(.rf-dark *){--tw-text-opacity:1;color:rgb(107 114 128/var(--tw-text-opacity,1))}.dark\\:rf-text-zinc-300:is(.rf-dark *){--tw-text-opacity:1;color:rgb(212 212 216/var(--tw-text-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\\:placeholder\\:rf-text-zinc-400:is(.rf-dark *)::-moz-placeholder{--tw-text-opacity:1;color:rgb(161 161 170/var(--tw-text-opacity,1))}.dark\\:placeholder\\:rf-text-zinc-400:is(.rf-dark *)::placeholder{--tw-text-opacity:1;color:rgb(161 161 170/var(--tw-text-opacity,1))}.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-\\[selected\\=true\\]\\:rf-bg-zinc-800[data-selected=true]:is(.rf-dark *){--tw-bg-opacity:1;background-color:rgb(39 39 42/var(--tw-bg-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-\\[selected\\=true\\]\\:rf-text-zinc-50[data-selected=true]:is(.rf-dark *){--tw-text-opacity:1;color:rgb(250 250 250/var(--tw-text-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-order-1{order:1}.sm\\:rf-order-2{order:2}.sm\\:rf-mt-0{margin-top:0}.sm\\:rf-mt-4{margin-top:1rem}.sm\\:rf-block{display:block}.sm\\:rf-inline{display:inline}.sm\\:rf-grid{display:grid}.sm\\:rf-hidden{display:none}.sm\\:rf-h-5{height:1.25rem}.sm\\:rf-w-1\\/2{width:50%}.sm\\:rf-w-5{width:1.25rem}.sm\\:rf-w-\\[90vw\\]{width:90vw}.sm\\:rf-w-auto{width:auto}.sm\\:rf-max-w-\\[500px\\]{max-width:500px}.sm\\:rf-max-w-md{max-width:28rem}.sm\\:rf-grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.sm\\:rf-grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.sm\\:rf-grid-cols-\\[1fr_auto\\]{grid-template-columns:1fr auto}.sm\\:rf-grid-cols-\\[minmax\\(0\\2c 1fr\\)_auto\\]{grid-template-columns:minmax(0,1fr) auto}.sm\\:rf-flex-row{flex-direction:row}.sm\\:rf-items-center{align-items:center}.sm\\:rf-justify-end{justify-content:flex-end}.sm\\:rf-gap-3{gap:.75rem}.sm\\:rf-gap-4{gap:1rem}.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-p-3{padding:.75rem}.sm\\:rf-p-6{padding:1.5rem}.sm\\:rf-px-4{padding-left:1rem;padding-right:1rem}.sm\\:rf-px-6{padding-left:1.5rem;padding-right:1.5rem}.sm\\:rf-px-8{padding-left:2rem;padding-right:2rem}.sm\\:rf-py-10{padding-bottom:2.5rem;padding-top:2.5rem}.sm\\:rf-py-6{padding-bottom:1.5rem;padding-top:1.5rem}.sm\\:rf-text-left{text-align:left}.sm\\:rf-text-2xl{font-size:1.5rem;line-height:2rem}.sm\\:rf-text-3xl{font-size:1.875rem;line-height:2.25rem}.sm\\:rf-text-base{font-size:1rem;line-height:1.5rem}.sm\\:rf-text-sm{font-size:.875rem;line-height:1.25rem}.sm\\:rf-text-xl{font-size:1.25rem;line-height:1.75rem}}@media (min-width:768px){.md\\:rf-w-52{width:13rem}.md\\:rf-w-auto{width:auto}.md\\:rf-min-w-0{min-width:0}.md\\:rf-max-w-\\[660px\\]{max-width:660px}.md\\:rf-max-w-lg{max-width:32rem}.md\\:rf-grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.md\\:rf-grid-cols-\\[220px_1fr\\]{grid-template-columns:220px 1fr}.md\\:rf-flex-row{flex-direction:row}.md\\:rf-flex-col{flex-direction:column}.md\\:rf-overflow-y-auto{overflow-y:auto}.md\\:rf-overflow-x-hidden{overflow-x:hidden}.md\\:rf-border-b-0{border-bottom-width:0}.md\\:rf-border-r{border-right-width:1px}.md\\:rf-p-8{padding:2rem}.md\\:rf-py-8{padding-bottom:2rem;padding-top:2rem}.md\\:rf-text-3xl{font-size:1.875rem;line-height:2.25rem}}@media (min-width:1024px){.lg\\:rf-max-w-\\[720px\\]{max-width:720px}.lg\\:rf-max-w-xl{max-width:36rem}.lg\\:rf-grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}}@media (min-width:1280px){.xl\\:rf-max-w-\\[800px\\]{max-width:800px}}.\\[\\&\\>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))}.\\[\\&_\\[cmdk-group-heading\\]\\]\\:rf-px-2 [cmdk-group-heading]{padding-left:.5rem;padding-right:.5rem}.\\[\\&_\\[cmdk-group-heading\\]\\]\\:rf-py-1\\.5 [cmdk-group-heading]{padding-bottom:.375rem;padding-top:.375rem}.\\[\\&_\\[cmdk-group-heading\\]\\]\\:rf-text-xs [cmdk-group-heading]{font-size:.75rem;line-height:1rem}.\\[\\&_\\[cmdk-group-heading\\]\\]\\:rf-font-medium [cmdk-group-heading]{font-weight:500}.\\[\\&_\\[cmdk-group-heading\\]\\]\\:rf-text-zinc-500 [cmdk-group-heading]{--tw-text-opacity:1;color:rgb(113 113 122/var(--tw-text-opacity,1))}.dark\\:\\[\\&_\\[cmdk-group-heading\\]\\]\\:rf-text-zinc-400 [cmdk-group-heading]:is(.rf-dark *){--tw-text-opacity:1;color:rgb(161 161 170/var(--tw-text-opacity,1))}.\\[\\&_\\[cmdk-group\\]\\:not\\(\\[hidden\\]\\)_\\~\\[cmdk-group\\]\\]\\:rf-pt-0 [cmdk-group]:not([hidden])~[cmdk-group]{padding-top:0}.\\[\\&_\\[cmdk-group\\]\\]\\:rf-px-2 [cmdk-group]{padding-left:.5rem;padding-right:.5rem}.\\[\\&_\\[cmdk-input-wrapper\\]_svg\\]\\:rf-h-5 [cmdk-input-wrapper] svg{height:1.25rem}.\\[\\&_\\[cmdk-input-wrapper\\]_svg\\]\\:rf-w-5 [cmdk-input-wrapper] svg{width:1.25rem}.\\[\\&_\\[cmdk-input\\]\\]\\:rf-h-12 [cmdk-input]{height:3rem}.\\[\\&_\\[cmdk-item\\]\\]\\:rf-px-2 [cmdk-item]{padding-left:.5rem;padding-right:.5rem}.\\[\\&_\\[cmdk-item\\]\\]\\:rf-py-3 [cmdk-item]{padding-bottom:.75rem;padding-top:.75rem}.\\[\\&_\\[cmdk-item\\]_svg\\]\\:rf-h-5 [cmdk-item] svg{height:1.25rem}.\\[\\&_\\[cmdk-item\\]_svg\\]\\:rf-w-5 [cmdk-item] svg{width:1.25rem}.\\[\\&_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}',dee=()=>{ee.useEffect(()=>{if(document.querySelector('style[data-styles="tscircuit-runframe"]'))return;const e=document.createElement("style");e.setAttribute("data-styles","tscircuit-runframe"),e.textContent=kHi,document.head.appendChild(e)},[])},FHi=t=>{ee.useEffect(()=>(t?document.body.style.overflow="hidden":document.body.style.overflow="",()=>{document.body.style.overflow=""}),[t])},Dhn=t=>`hsl(${oE.indexOf(t)*137.5%360}, 70%, 50%)`,LHi=({phaseTimings:t})=>{if(!t)return null;const e=Object.values(t).reduce((n,o)=>n+o,0);return K.jsxs("div",{className:"rf-space-y-2 rf-w-full rf-px-4",children:[K.jsx("div",{className:"rf-relative rf-h-8 rf-flex rf-rounded-sm",children:oE.map(n=>{const o=t[n]||0,i=o/e*100;return K.jsx("div",{className:"rf-group/bar rf-relative rf-overflow-visible",style:{width:`${i}%`,backgroundColor:Dhn(n)},children:K.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:[n,": ",o.toFixed(1),"ms"]})},n)})}),K.jsxs("div",{className:"rf-text-xs rf-text-gray-500",children:["Total: ",e.toFixed(2),"ms"]})]})},HHi=t=>{if(t instanceof Blob)return t;if(t==null)return"";if(typeof t=="string")return t;if(typeof t=="object")try{return JSON.stringify(t,null,2)}catch{return String(t)}return String(t)},OHi=({renderLog:t,onRerunWithDebug:e})=>{const[n,o]=ee.useState("chronological"),[i,r]=ee.useState(""),s=[{value:"",label:"None"},{value:"DEBUG=Group_doInitialSchematicTraceRender",label:"DEBUG=Group_doInitialSchematicTraceRender"},{value:"DEBUG=Group_doInitialSchematicLayoutMatchpack",label:"DEBUG=Group_doInitialSchematicLayoutMatchpack"},{value:"DEBUG=Group_doInitialPcbLayoutPack",label:"DEBUG=Group_doInitialPcbLayoutPack"}];if(!t)return K.jsxs("div",{className:"rf-p-4 rf-bg-gray-100 rf-rounded-md",children:[K.jsx("div",{className:"rf-mb-4",children:"No render log, make sure this tab is open when you render"}),e&&K.jsxs("div",{className:"rf-flex rf-gap-2 rf-items-center",children:[K.jsx("select",{value:i,onChange:c=>r(c.target.value),className:"rf-px-3 rf-py-1 rf-border rf-rounded rf-text-xs rf-bg-white",children:s.map(c=>K.jsx("option",{value:c.value,children:c.label},c.value))}),K.jsx(fA,{onClick:()=>e(i),size:"sm",className:"rf-text-xs",children:"Rerun Render with Debug"})]})]});const a=Object.entries(t?.phaseTimings??{});n==="chronological"?a.sort((c,l)=>oE.indexOf(c[0])-oE.indexOf(l[0])):a.sort((c,l)=>l[1]-c[1]);const A=a.reduce((c,[l,u])=>c+u,0);return K.jsxs("div",{className:"rf-bg-white",children:[K.jsxs("div",{className:"rf-flex rf-justify-between rf-items-center rf-mb-4",children:[K.jsx("div",{children:"Render Logs"}),K.jsxs("div",{className:"rf-flex rf-gap-4 rf-items-center",children:[e&&K.jsxs("div",{className:"rf-flex rf-gap-2 rf-items-center",children:[K.jsx("select",{value:i,onChange:c=>r(c.target.value),className:"rf-px-3 rf-py-1 rf-border rf-rounded rf-text-xs rf-bg-white",children:s.map(c=>K.jsx("option",{value:c.value,children:c.label},c.value))}),K.jsx(fA,{onClick:()=>e(i),size:"sm",className:"rf-text-xs",children:"Rerun Render with Debug"})]}),K.jsx("div",{className:"rf-flex rf-gap-2 rf-items-center",children:K.jsxs("select",{onChange:c=>{if(c.target.value){const l=t?.debugOutputs?.find(u=>u.name===c.target.value);if(l){const u=HHi(l.content),g=u instanceof Blob?u:new Blob([u],{type:"text/plain"}),h=URL.createObjectURL(g),d=document.createElement("a");d.href=h,d.download=`debug-${l.name}.txt`,document.body.appendChild(d),d.click(),document.body.removeChild(d),URL.revokeObjectURL(h)}c.target.value=""}},disabled:!t?.debugOutputs||t.debugOutputs.length===0,className:"rf-px-3 rf-py-1 rf-border rf-rounded rf-text-xs rf-bg-white disabled:rf-opacity-50 disabled:rf-cursor-not-allowed",children:[K.jsx("option",{value:"",children:"Download Debug Output"}),t?.debugOutputs?.map(c=>K.jsx("option",{value:c.name,children:c.name},c.name))]})}),K.jsxs("div",{className:"rf-flex rf-text-xs rf-items-center",children:[K.jsx("div",{className:"rf-mr-2",children:"Sort by:"}),K.jsxs("select",{value:n,onChange:c=>o(c.target.value),className:"rf-px-2 rf-py-1 rf-border rf-rounded rf-text-xs",children:[K.jsx("option",{value:"chronological",children:"Phase Order"}),K.jsx("option",{value:"longest",children:"Duration"})]})]})]})]}),K.jsx(LHi,{phaseTimings:t.phaseTimings}),K.jsxs("table",{className:"rf-w-full rf-text-xs",children:[K.jsx("thead",{children:K.jsxs("tr",{children:[K.jsx("th",{className:"rf-text-left rf-p-2",children:"Phase Order"}),K.jsx("th",{className:"rf-text-left rf-p-2",children:"Phase"}),K.jsx("th",{className:"rf-text-left rf-p-2",children:"Duration (ms)"})]})}),K.jsx("tbody",{children:a.map(([c,l])=>K.jsxs("tr",{children:[K.jsx("td",{className:"rf-p-2",children:oE.indexOf(c)}),K.jsx("td",{className:"rf-p-2",children:c}),K.jsx("td",{className:"rf-p-2",children:K.jsx("div",{className:"rf-w-8",children:K.jsx("div",{className:"rf-h-2 rf-rounded-sm",style:{backgroundColor:Dhn(c),width:`${l/A*100}%`}})})}),K.jsx("td",{className:"rf-p-2",children:K.jsxs("div",{className:"rf-flex w-full",children:[K.jsxs("span",{className:"rf-flex-grow",children:[l,"ms"]}),K.jsxs("span",{className:"rf-text-gray-500 rf-pr-2",children:[(l/A*100).toFixed(1),"%"]})]})})]},c))})]})]})};var GHi=8,I$e=t=>Math.hypot(t.a,t.b)||1,YHi=t=>[t.label,t.inlineLabel].filter(Boolean).join(`
5636
5636
  `),hee=(t,e)=>Math.hypot(t.x-e.x,t.y-e.y),Nhn=(t,e,n)=>{const o=n.x-e.x,i=n.y-e.y,r=o*o+i*i;if(r===0)return hee(t,e);const s=((t.x-e.x)*o+(t.y-e.y)*i)/r,a=Math.max(0,Math.min(1,s));return hee(t,{x:e.x+o*a,y:e.y+i*a})},UHi=(t,e,n)=>{const o=n.x-e.x,i=n.y-e.y,r=Math.hypot(o,i);return r===0?hee(t,e):Math.abs(i*t.x-o*t.y+n.x*e.y-n.y*e.x)/r},C$e=(t,e)=>{let n=!1;for(let o=0,i=e.length-1;o<e.length;i=o++){const r=e[o],s=e[i];r.y>t.y!=s.y>t.y&&t.x<(s.x-r.x)*(t.y-r.y)/(s.y-r.y)+r.x&&(n=!n)}return n},y$e=(t,e,n,o=!1)=>{if(e.length===0)return!1;const i=o?e.length:e.length-1;for(let r=0;r<i;r+=1){const s=e[r],a=e[(r+1)%e.length];if(Nhn(t,s,a)<=n)return!0}return!1},Rhn=(t,e,n)=>Math.max(n,(t??2)*I$e(e)/2+4),SS=(t,e)=>Bn(t,e),x$e=(t,e,n,o)=>hee(t,SS(n,e))<=o,KHi=(t,e,n,o)=>{if(e.points.length===0)return!1;if(e.points.length===1)return x$e(t,e.points[0],n,o);const i=e.points.map(r=>SS(n,r));return y$e(t,i,Rhn(e.strokeWidth,n,o))},VHi=(t,e,n,o)=>{const{origin:i,directionVector:r}=e;if(r.x===0&&r.y===0)return!1;const s=SS(n,i),a=SS(n,{x:i.x+r.x,y:i.y+r.y});return UHi(t,s,a)<=Rhn(e.strokeWidth,n,o)},zHi=(t,e,n,o)=>{const i=GQe(e,n).corners;return C$e(t,i)||y$e(t,i,o,!0)},JHi=(t,e,n,o)=>{const i=SS(n,e.center),r=e.radius*I$e(n);return hee(t,i)<=r+o},WHi=(t,e,n,o)=>{if(e.points.length===0)return!1;if(e.points.length===1)return x$e(t,e.points[0],n,o);const i=e.points.map(r=>SS(n,r));return C$e(t,i)||y$e(t,i,o,!0)},jHi=(t,e,n,o)=>{const i=YW(e),r=SS(n,i.shaftStart),s=SS(n,i.shaftEnd),a=Math.max(o,i.shaftWidth*I$e(n)/2+4);return Nhn(t,r,s)<=a?!0:i.heads.some(A=>{const c=[A.tip,A.leftWing,A.rightWing].map(l=>SS(n,l));return C$e(t,c)})};function $Hi(t,e,n,o={}){const i=o.hitSlop??GHi;for(let s=(t.points?.length??0)-1;s>=0;s-=1){const a=t.points?.[s];if(a?.label&&x$e(n,a,e,i))return a.label}for(let s=(t.infiniteLines?.length??0)-1;s>=0;s-=1){const a=t.infiniteLines?.[s];if(a?.label&&VHi(n,a,e,i))return a.label}const r=t.lines?.map((s,a)=>({line:s,originalIndex:a})).sort((s,a)=>(s.line.zIndex??0)-(a.line.zIndex??0)||s.originalIndex-a.originalIndex)??[];for(let s=r.length-1;s>=0;s-=1){const a=r[s]?.line;if(a?.label&&KHi(n,a,e,i))return a.label}for(let s=(t.arrows?.length??0)-1;s>=0;s-=1){const a=t.arrows?.[s],A=a?YHi(a):"";if(!(!a||!A)&&jHi(n,a,e,i))return A}for(let s=(t.polygons?.length??0)-1;s>=0;s-=1){const a=t.polygons?.[s];if(a?.label&&WHi(n,a,e,i))return a.label}for(let s=(t.circles?.length??0)-1;s>=0;s-=1){const a=t.circles?.[s];if(a?.label&&JHi(n,a,e,i))return a.label}for(let s=(t.rects?.length??0)-1;s>=0;s-=1){const a=t.rects?.[s];if(a?.label&&zHi(n,a,e,i))return a.label}return null}const qHi=Fs[typeof document<"u"&&document.createElement!==void 0?"useLayoutEffect":"useEffect"],XHi=t=>{const e=ee.useRef(t);return ee.useEffect(()=>{e.current=t}),e};function ZHi(){}function Thn(t,e,n={}){const o=tOi(n.polyfill),i=XHi(e);return qHi(()=>{let r=!1;const s=t&&"current"in t?t.current:t;if(!s)return ZHi;function a(A,c){r||i.current(A,c)}return o.subscribe(s,a),()=>{r=!0,o.unsubscribe(s,a)}},[t,o,i]),o.observer}function eOi(t){let e=!1,n=[];const o=new Map,i=new(t||window.ResizeObserver)((r,s)=>{n=n.concat(r);function a(){const A=new Set;for(let c=0;c<n.length;c++){if(A.has(n[c].target))continue;A.add(n[c].target);const l=o.get(n[c].target);l?.forEach(u=>u(n[c],s))}n=[],e=!1}e||window.requestAnimationFrame(a),e=!0});return{observer:i,subscribe(r,s){var a;i.observe(r);const A=(a=o.get(r))!==null&&a!==void 0?a:[];A.push(s),o.set(r,A)},unsubscribe(r,s){var a;const A=(a=o.get(r))!==null&&a!==void 0?a:[];if(A.length===1){i.unobserve(r),o.delete(r);return}const c=A.indexOf(s);c!==-1&&A.splice(c,1),o.set(r,A)}}}let E$e;const tOi=t=>E$e||(E$e=eOi(t));var nOi=t=>{const e={minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};for(const n of t.lines??[])for(const o of n.points??[])e.minX=Math.min(e.minX,o.x),e.minY=Math.min(e.minY,o.y),e.maxX=Math.max(e.maxX,o.x),e.maxY=Math.max(e.maxY,o.y);for(const n of t.rects??[]){const o=Xpo(n);e.minX=Math.min(e.minX,o.minX),e.minY=Math.min(e.minY,o.minY),e.maxX=Math.max(e.maxX,o.maxX),e.maxY=Math.max(e.maxY,o.maxY)}for(const n of t.polygons??[])for(const o of n.points??[])e.minX=Math.min(e.minX,o.x),e.minY=Math.min(e.minY,o.y),e.maxX=Math.max(e.maxX,o.x),e.maxY=Math.max(e.maxY,o.y);for(const n of t.points??[])e.minX=Math.min(e.minX,n.x),e.minY=Math.min(e.minY,n.y),e.maxX=Math.max(e.maxX,n.x),e.maxY=Math.max(e.maxY,n.y);for(const n of t.circles??[])e.minX=Math.min(e.minX,n.center.x-n.radius),e.minY=Math.min(e.minY,n.center.y-n.radius),e.maxX=Math.max(e.maxX,n.center.x+n.radius),e.maxY=Math.max(e.maxY,n.center.y+n.radius);for(const n of t.arrows??[]){const o=obt(n);e.minX=Math.min(e.minX,o.minX),e.minY=Math.min(e.minY,o.minY),e.maxX=Math.max(e.maxX,o.maxX),e.maxY=Math.max(e.maxY,o.maxY)}for(const n of t.texts??[])e.minX=Math.min(e.minX,n.x),e.minY=Math.min(e.minY,n.y),e.maxX=Math.max(e.maxX,n.x),e.maxY=Math.max(e.maxY,n.y);return e};function khn(t){const e=l=>!l||l.length===0?0:l.reduce((u,g)=>{const h=Number.isNaN(g.step)?0:g.step||0;return Math.max(u,h)},0),n=e(t.points),o=e(t.lines),i=e(t.infiniteLines),r=e(t.rects),s=e(t.polygons),a=e(t.circles),A=e(t.texts),c=e(t.arrows);return Math.max(n,o,i,r,s,a,A,c)}var oOi=t=>t.slice().sort((e,n)=>n.width*n.height-e.width*e.height);function iOi(t){const{dimensionStart:e,dimensionEnd:n,screenDimensionStart:o,screenDimensionEnd:i,flipX:r,flipY:s}=t,a=n.x-e.x,A=n.y-e.y,c=Math.sqrt(a*a+A*A),l=i.x-o.x,u=i.y-o.y,g=Math.sqrt(l*l+u*u),h=Math.atan2(u,l)*(180/Math.PI),d=Math.abs(h)%90,m=Math.min(d,90-d)>15,_=(o.x+i.x)/2,f=(o.y+i.y)/2,I=15,C=h+90;let y=Math.cos(C*Math.PI/180)*I,x=Math.sin(C*Math.PI/180)*I;const E=l>0&&u<0,B=l>0&&u>0,S=l<0&&u>0;r!==s&&!E&&(y=-y,x=-x),E&&(y+=Math.cos(C*Math.PI/180)*-45,x+=Math.sin(C*Math.PI/180)*-45),B&&(y+=Math.cos(C*Math.PI/180)+-20,x+=Math.sin(C*Math.PI/180)+-10),S&&(y+=Math.cos(C*Math.PI/180)*10,x+=Math.sin(C*Math.PI/180)*10);const Q=_+y,w=f+x;return{distance:c,screenDistance:g,x:Q,y:w,show:c>.01&&g>30&&m}}function rOi(t){const{dimensionStart:e,dimensionEnd:n,screenDimensionStart:o,screenDimensionEnd:i,flipX:r,flipY:s}=t;return ee.useMemo(()=>iOi({dimensionStart:e,dimensionEnd:n,screenDimensionStart:o,screenDimensionEnd:i,flipX:r,flipY:s}),[e,n,o,i,r,s])}var sOi=({children:t,transform:e})=>{e||(e=EQ());const[n,o]=ee.useState(!1),[i,r]=ee.useState(!1),[s,a]=ee.useState({x:0,y:0}),[A,c]=ee.useState({x:0,y:0}),l=ee.useRef({x:0,y:0}),u=ee.useRef(null),g=ee.useRef(!1),d=u.current?.getBoundingClientRect(),p=ee.useCallback(()=>{g.current=!0,u.current?.focus()},[]),m=ee.useCallback(()=>{g.current=!1},[]);ee.useEffect(()=>{const y=x=>{const E=u.current?.contains(document.activeElement)||document.activeElement===u.current;!g.current&&!E||(x.key==="d"&&(a({x:l.current.x,y:l.current.y}),c({x:l.current.x,y:l.current.y}),o(B=>!B),r(!0)),x.key==="Escape"&&(o(!1),r(!1)))};return window.addEventListener("keydown",y),()=>{window.removeEventListener("keydown",y)}},[]);const _=Bn(e,s),f=Bn(e,A),I={left:Math.min(_.x,f.x),right:Math.max(_.x,f.x),top:Math.min(_.y,f.y),bottom:Math.max(_.y,f.y),flipX:_.x>f.x,flipY:_.y>f.y,width:0,height:0};I.width=I.right-I.left,I.height=I.bottom-I.top;const C=rOi({dimensionStart:s,dimensionEnd:A,screenDimensionStart:_,screenDimensionEnd:f,flipX:I.flipX,flipY:I.flipY});return K.jsxs("div",{ref:u,tabIndex:0,style:{position:"relative"},onMouseMove:y=>{const x=y.currentTarget.getBoundingClientRect(),E=y.clientX-x.left,B=y.clientY-x.top,S=Bn(fV(e),{x:E,y:B});l.current.x=S.x,l.current.y=S.y,i&&c({x:S.x,y:S.y})},onMouseDown:()=>{i?r(!1):n&&o(!1)},onMouseEnter:p,onMouseLeave:m,children:[t,n&&K.jsxs(K.Fragment,{children:[C.show&&K.jsx("div",{style:{position:"absolute",left:C.x,top:C.y,color:"red",mixBlendMode:"difference",pointerEvents:"none",fontSize:12,fontFamily:"sans-serif",whiteSpace:"nowrap",zIndex:30},children:C.distance.toFixed(2)}),K.jsx("div",{style:{position:"absolute",left:I.left,width:I.width,textAlign:"center",top:_.y+2,color:"red",mixBlendMode:"difference",pointerEvents:"none",marginTop:I.flipY?0:-20,fontSize:12,fontFamily:"sans-serif",zIndex:30},children:Math.abs(s.x-A.x).toFixed(2)}),K.jsx("div",{style:{position:"absolute",left:f.x,height:I.height,display:"flex",flexDirection:"column",justifyContent:"center",top:I.top,color:"red",pointerEvents:"none",mixBlendMode:"difference",fontSize:12,fontFamily:"sans-serif",zIndex:30},children:K.jsx("div",{style:{marginLeft:I.flipX?"-100%":4,paddingRight:4},children:Math.abs(s.y-A.y).toFixed(2)})}),K.jsxs("svg",{style:{position:"absolute",left:0,top:0,pointerEvents:"none",mixBlendMode:"difference",zIndex:30},width:d?.width||"100%",height:d?.height||"100%",children:[K.jsx("defs",{children:K.jsx("marker",{id:"head",orient:"auto",markerWidth:"3",markerHeight:"4",refX:"2",refY:"2",children:K.jsx("path",{d:"M0,0 V4 L2,2 Z",fill:"red"})})}),K.jsx("line",{x1:_.x,y1:_.y,x2:f.x,y2:f.y,markerEnd:"url(#head)",strokeWidth:1.5,fill:"none",stroke:"red"}),K.jsx("line",{x1:_.x,y1:_.y,x2:f.x,y2:_.y,strokeWidth:1.5,fill:"none",strokeDasharray:"2,2",stroke:"red"}),K.jsx("line",{x1:f.x,y1:_.y,x2:f.x,y2:f.y,strokeWidth:1.5,fill:"none",strokeDasharray:"2,2",stroke:"red"})]}),K.jsxs("div",{style:{right:0,bottom:0,position:"absolute",color:"red",fontFamily:"sans-serif",fontSize:12,margin:4},children:["(",s.x.toFixed(2),",",s.y.toFixed(2),")",K.jsx("br",{}),"(",A.x.toFixed(2),",",A.y.toFixed(2),")",K.jsx("br",{}),"dist:"," ",Math.sqrt((A.x-s.x)**2+(A.y-s.y)**2).toFixed(2)]})]})]})},Fhn=({label:t,onClose:e})=>K.jsx("div",{role:"dialog","aria-modal":"true","aria-label":"Object label",onClick:e,style:{position:"absolute",inset:0,display:"flex",alignItems:"center",justifyContent:"center",padding:16,background:"rgba(0, 0, 0, 0.28)"},children:K.jsxs("div",{onClick:n=>{n.stopPropagation()},style:{width:"min(420px, 100%)",background:"#fff",borderRadius:10,boxShadow:"0 12px 32px rgba(0, 0, 0, 0.2)",padding:16},children:[K.jsx("div",{style:{fontWeight:600,marginBottom:8},children:"Object label"}),K.jsx("div",{style:{whiteSpace:"pre-wrap",wordBreak:"break-word",marginBottom:16},children:t}),K.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:K.jsx("button",{type:"button",onClick:e,children:"Close"})})]})}),Lhn=(t,e,n,o,i,r)=>{const s=t-n,a=e-o,A=i-n,c=r-o,l=s*A+a*c,u=A*A+c*c;let g=-1;u!==0&&(g=l/u);let h=0,d=0;g<0?(h=n,d=o):g>1?(h=i,d=r):(h=n+g*A,d=o+g*c);const p=t-h,m=e-d;return Math.sqrt(p*p+m*m)},i9=(t,e)=>{try{return Tpo(t,e)}catch{return e}},aOi=({arrow:t,index:e,interactiveState:n})=>{const{realToScreen:o,onObjectClicked:i,setHoverTooltip:r}=n,[s,a]=ee.useState(!1),A=ee.useMemo(()=>YW(t),[t]),c=ee.useMemo(()=>({shaftStart:Bn(o,A.shaftStart),shaftEnd:Bn(o,A.shaftEnd),heads:A.heads.map(y=>({tip:Bn(o,y.tip),base:Bn(o,y.base),leftWing:Bn(o,y.leftWing),rightWing:Bn(o,y.rightWing)}))}),[A,o]),l=Math.abs(o.a),u=12,g=A.shaftWidth*(l||1),h=u*.6,d=ee.useMemo(()=>Uce(c.shaftStart,c.shaftEnd,{fontSize:u,strokeWidth:g,normalPadding:6,alongOffset:t.label?h:0}),[c,u,g,t.label,h]),p=ee.useMemo(()=>Uce(c.shaftStart,c.shaftEnd,{fontSize:u,strokeWidth:g,normalPadding:12,alongOffset:t.inlineLabel?-h:0}),[c,u,g,t.inlineLabel,h]),m=t.color||oh[e%oh.length]||"black",_=s?i9(.2,m):m,f=[t.label,t.inlineLabel].filter(Boolean).join(`
5637
5637
  `),I=t.label?p:d;ee.useEffect(()=>{if(!(!s||!f))return r?.({text:f,x:I.x,y:I.y}),()=>{r?.(null)}},[s,r,I.x,I.y,f]);const C=y=>{const x=y.currentTarget.getBoundingClientRect(),E=y.clientX-x.left,B=y.clientY-x.top,S=10,w=[{from:c.shaftStart,to:c.shaftEnd},...c.heads.flatMap(M=>[{from:M.base,to:M.leftWing},{from:M.leftWing,to:M.tip},{from:M.tip,to:M.rightWing},{from:M.rightWing,to:M.base}])].some(({from:M,to:k})=>Lhn(E,B,M.x,M.y,k.x,k.y)<S);a(w)};return K.jsx("div",{style:{position:"absolute",top:0,left:0,width:"100%",height:"100%",pointerEvents:"none"},children:K.jsxs("svg",{style:{width:"100%",height:"100%",pointerEvents:"auto"},onMouseMove:C,onMouseLeave:()=>{a(!1),r?.(null)},onClick:s?y=>{y.stopPropagation(),i?.({type:"arrow",index:e,object:t})}:void 0,children:[K.jsx("line",{x1:c.shaftStart.x,y1:c.shaftStart.y,x2:c.shaftEnd.x,y2:c.shaftEnd.y,stroke:_,strokeWidth:g,strokeLinecap:"round",pointerEvents:"stroke"}),c.heads.map((y,x)=>K.jsx("polygon",{points:`${y.tip.x},${y.tip.y} ${y.leftWing.x},${y.leftWing.y} ${y.rightWing.x},${y.rightWing.y}`,fill:_},x))]})})},AOi=({circle:t,interactiveState:e,index:n})=>{const o=oh[n%oh.length];let{center:i,radius:r,fill:s,stroke:a,layer:A,step:c,label:l}=t;const{activeLayers:u,activeStep:g,realToScreen:h,onObjectClicked:d,setHoverTooltip:p}=e,[m,_]=ee.useState(!1),f=Bn(h,i),I=r*h.a;let C=s||o;return m&&(C=i9(.2,C),a=a&&i9(.2,a)),ee.useEffect(()=>{if(!(!m||!l))return p?.({text:l,x:f.x,y:f.y-I}),()=>{p?.(null)}},[m,l,f.x,f.y,I,p]),K.jsx("div",{style:{position:"absolute",left:f.x-I,top:f.y-I,width:I*2,height:I*2,borderRadius:"50%",backgroundColor:C,border:a?`2px solid ${a}`:"none",cursor:"pointer",transition:"border-color 0.2s"},onMouseEnter:()=>_(!0),onMouseLeave:()=>{_(!1),p?.(null)},onClick:()=>d?.({type:"circle",index:n,object:t})})},cOi=({x:t,y:e,onSaveCamera:n,onLoadCamera:o,onClearCamera:i,onAddMark:r,onClearMarks:s,onClose:a})=>{const A=ee.useRef(null);ee.useEffect(()=>{const h=d=>{A.current&&!A.current.contains(d.target)&&a()};return document.addEventListener("mousedown",h),()=>{document.removeEventListener("mousedown",h)}},[a]);const c={position:"absolute",left:t,top:e,backgroundColor:"white",border:"1px solid #ccc",borderRadius:3,boxShadow:"0 2px 6px rgba(0,0,0,0.1)",padding:0,zIndex:1e3,minWidth:160,fontSize:"12px"},l={padding:"4px 8px",cursor:"pointer",userSelect:"none",lineHeight:"1.5"},u=h=>{h.currentTarget.style.backgroundColor="#f5f5f5"},g=h=>{h.currentTarget.style.backgroundColor=""};return K.jsxs("div",{ref:A,style:c,children:[K.jsx("div",{style:l,onClick:()=>{n(),a()},onMouseEnter:u,onMouseLeave:g,children:"Save Camera Position"}),K.jsx("div",{style:l,onClick:()=>{o(),a()},onMouseEnter:u,onMouseLeave:g,children:"Load Camera Position"}),K.jsx("div",{style:l,onClick:()=>{i(),a()},onMouseEnter:u,onMouseLeave:g,children:"Clear Saved Camera Position"}),K.jsx("div",{style:l,onClick:()=>{r(),a()},onMouseEnter:u,onMouseLeave:g,children:"Add Mark"}),K.jsx("div",{style:l,onClick:()=>{s(),a()},onMouseEnter:u,onMouseLeave:g,children:"Clear Marks"})]})},lOi=({infiniteLine:t,index:e,interactiveState:n,size:o})=>{const{realToScreen:i,onObjectClicked:r,setHoverTooltip:s}=n,[a,A]=ee.useState(!1),c=$8t(i,o.width,o.height),l=j8t(t,c);if(!l)return null;const[u,g]=l,h=Bn(i,u),d=Bn(i,g),p=t.strokeColor??oh[e%oh.length],m=(t.strokeWidth??1/Math.abs(i.a))*Math.abs(i.a),_=(h.x+d.x)/2,f=(h.y+d.y)/2;return K.jsx("div",{style:{position:"absolute",top:0,left:0,width:o.width,height:o.height,pointerEvents:"none"},children:K.jsxs("svg",{style:{width:o.width,height:o.height,pointerEvents:"none"},children:[K.jsx("line",{x1:h.x,y1:h.y,x2:d.x,y2:d.y,stroke:"transparent",strokeWidth:m+10,pointerEvents:"stroke",onMouseEnter:()=>{A(!0),t.label&&s?.({text:t.label,x:_,y:f})},onMouseLeave:()=>{A(!1),s?.(null)},onClick:()=>r?.({type:"infinite-line",index:e,object:t})}),K.jsx("line",{x1:h.x,y1:h.y,x2:d.x,y2:d.y,stroke:a?i9(.2,p):p,strokeWidth:m,strokeDasharray:t.strokeDash?typeof t.strokeDash=="string"?t.strokeDash:t.strokeDash.map(I=>I*Math.abs(i.a)).join(","):void 0,pointerEvents:"none"})]})})},uOi=({line:t,index:e,interactiveState:n,size:o,mousePosition:i})=>{const{activeLayers:r,activeStep:s,realToScreen:a,onObjectClicked:A,setHoverTooltip:c}=n,{points:l,layer:u,step:g,strokeColor:h,strokeWidth:d=1/a.a,strokeDash:p}=t,m=l.map(B=>Bn(a,B)),_=d*Math.abs(a.a),C=Math.max(_/2+3,6),y=C*2,x=ee.useMemo(()=>{if(!i)return!1;for(let B=0;B<m.length-1;B++)if(Lhn(i.x,i.y,m[B].x,m[B].y,m[B+1].x,m[B+1].y)<=C)return!0;return!1},[C,i,m]),E=h??oh[e%oh.length];return ee.useEffect(()=>{if(!(!x||!t.label||!i))return c?.({text:t.label,x:i.x,y:i.y}),()=>{c?.(null)}},[x,t.label,i?.x,i?.y,c]),K.jsx("div",{style:{position:"absolute",top:0,left:0,width:o.width,height:o.height,pointerEvents:"none"},children:K.jsxs("svg",{style:{width:o.width,height:o.height,overflow:"visible",pointerEvents:"none"},children:[K.jsx("polyline",{points:m.map(B=>`${B.x},${B.y}`).join(" "),stroke:"transparent",fill:"none",strokeWidth:y,strokeLinecap:"round",strokeLinejoin:"round",pointerEvents:"stroke",onClick:x?()=>A?.({type:"line",index:e,object:t}):void 0}),K.jsx("polyline",{points:m.map(B=>`${B.x},${B.y}`).join(" "),stroke:x?i9(.2,E):E,fill:"none",strokeWidth:_,strokeDasharray:p?typeof p=="string"?p:`${p[0]*Math.abs(a.a)}, ${p[1]*Math.abs(a.a)}`:void 0,strokeLinecap:"round",strokeLinejoin:"round",pointerEvents:"none"})]})})},gOi=({marker:t,transform:e})=>{const[n,o]=Bn(e,[t.x,t.y]);return K.jsx("svg",{style:{position:"absolute",top:0,left:0,pointerEvents:"none",zIndex:900},children:K.jsxs("g",{transform:`translate(${n}, ${o})`,children:[K.jsx("circle",{r:7,fill:"rgba(255, 0, 0, 0.5)",stroke:"rgba(255, 0, 0, 0.8)",strokeWidth:2}),K.jsx("circle",{r:2,fill:"rgba(255, 0, 0, 0.9)"})]})})},dOi=({point:t,interactiveState:e,index:n})=>{const{color:o,label:i,layer:r,step:s}=t,{activeLayers:a,activeStep:A,realToScreen:c,onObjectClicked:l,setHoverTooltip:u}=e,[g,h]=ee.useState(!1),d=Bn(c,t),p=10,m=`${i?`${i}
5638
5638
  `:""}x: ${t.x.toFixed(2)}, y: ${t.y.toFixed(2)}`;return ee.useEffect(()=>{if(g)return u?.({text:m,x:d.x,y:d.y-p/2}),()=>{u?.(null)}},[g,d.x,d.y,u,m]),K.jsx("div",{style:{position:"absolute",left:d.x-p/2,top:d.y-p/2,width:p,height:p,borderRadius:"50%",border:`2px solid ${g?i9(.2,o??oh[n%oh.length]):o??oh[n%oh.length]}`,cursor:"pointer",transition:"border-color 0.2s"},onMouseEnter:()=>h(!0),onMouseLeave:()=>{h(!1),u?.(null)},onClick:()=>l?.({type:"point",index:n,object:t})})},hOi=({polygon:t,interactiveState:e,index:n})=>{const{points:o,fill:i,stroke:r,strokeWidth:s}=t,{realToScreen:a,onObjectClicked:A,setHoverTooltip:c}=e,[l,u]=ee.useState(!1),g=!!(o&&o.length>0),h=g?o.map(U=>Bn(a,U)):[],d=h.map(U=>U.x),p=h.map(U=>U.y),m=g?Math.min(...d):0,_=g?Math.max(...d):0,f=g?Math.min(...p):0,I=g?Math.max(...p):0,C=4,y=m-C,x=f-C,E=Math.max(_-m,0)+C*2,B=Math.max(I-f,0)+C*2,S=h.map(U=>({x:U.x-y,y:U.y-x})),Q=oh[n%oh.length],M=i!==void 0||r!==void 0?i||"transparent":Q,k=r,R=l?i9(.2,M):M,F=k?l?i9(.2,k):k:void 0,O=s===void 0?void 0:s*a.a;return ee.useEffect(()=>{if(!(!g||!l||!t.label))return c?.({text:t.label,x:(m+_)/2,y:x}),()=>{c?.(null)}},[g,l,_,m,t.label,c,x]),g?K.jsx("div",{style:{position:"absolute",top:x,left:y,width:E,height:B,pointerEvents:"none"},children:K.jsx("svg",{width:E,height:B,style:{display:"block"},children:K.jsx("polygon",{points:S.map(U=>`${U.x},${U.y}`).join(" "),fill:R,stroke:F??"none",strokeWidth:O,pointerEvents:"all",onMouseEnter:()=>u(!0),onMouseLeave:()=>{u(!1),c?.(null)},onClick:()=>A?.({type:"polygon",index:n,object:t})})})}):null},pOi=({rect:t,interactiveState:e,index:n})=>{const o=oh[n%oh.length];let{fill:i,stroke:r}=t;const{activeLayers:s,activeStep:a,realToScreen:A,onObjectClicked:c,setHoverTooltip:l}=e,[u,g]=ee.useState(!1),h=GQe(t,A);let p=i!==void 0||r!==void 0?i||"transparent":o;return u&&(p=i9(.2,p),r=i9(.2,r)),ee.useEffect(()=>{if(!(!u||!t.label))return l?.({text:t.label,x:h.center.x,y:h.center.y-h.height/2}),()=>{l?.(null)}},[u,h.center.x,h.center.y,h.height,t.label,l]),K.jsx("div",{style:{position:"absolute",left:h.center.x,top:h.center.y,width:h.width,height:h.height,transform:"translate(-50%, -50%)",pointerEvents:"none"},children:K.jsx("div",{style:{width:"100%",height:"100%",backgroundColor:p,border:r?`2px solid ${u?i9(.2,r):r}`:"none",boxSizing:"border-box",cursor:"pointer",transition:"border-color 0.2s",transformOrigin:"center",transform:`rotate(${h.angleDegrees}deg)`,pointerEvents:"auto"},onMouseEnter:()=>g(!0),onMouseLeave:()=>{g(!1),l?.(null)},onClick:()=>c?.({type:"rect",index:n,object:t})})})},mOi=({textObj:t,interactiveState:e,index:n})=>{const{realToScreen:o,onObjectClicked:i}=e,{x:r,y:s,text:a,color:A,fontSize:c,anchorSide:l}=t,u=Bn(o,{x:r,y:s}),h={top_left:"translate(0%, 0%)",top_center:"translate(-50%, 0%)",top_right:"translate(-100%, 0%)",center_left:"translate(0%, -50%)",center:"translate(-50%, -50%)",center_right:"translate(-100%, -50%)",bottom_left:"translate(0%, -100%)",bottom_center:"translate(-50%, -100%)",bottom_right:"translate(-100%, -100%)"}[l??"center"];return K.jsx("div",{style:{position:"absolute",left:u.x,top:u.y,transform:h,color:A||"black",fontSize:c??12,whiteSpace:"pre",cursor:"default"},onClick:()=>i?.({type:"text",index:n,object:t}),children:a})},Hhn=({text:t})=>K.jsx("div",{style:{background:"white",border:"1px solid #ccc",boxShadow:"0 0 10px 0 rgba(0, 0, 0, 0.1)",borderRadius:"4px",padding:"4px 8px",fontSize:"12px",minWidth:"120px",maxWidth:"300px",whiteSpace:"pre-wrap",overflowWrap:"anywhere",zIndex:100},children:t}),C4=5,_Oi=(t,e)=>ee.useMemo(()=>(n,o)=>{const i=Bn(t,n),r=Bn(t,o),s=-C4,a=e.width+C4,A=-C4,c=e.height+C4;if(i.x>=s&&i.x<=a&&i.y>=A&&i.y<=c||r.x>=s&&r.x<=a&&r.y>=A&&r.y<=c)return!0;const l=(u,g,h,d)=>{const p=(g.x-u.x)*(d.y-h.y)-(g.y-u.y)*(d.x-h.x);if(p===0)return!1;const m=((d.y-h.y)*(d.x-u.x)+(h.x-d.x)*(d.y-u.y))/p,_=((u.y-g.y)*(d.x-u.x)+(g.x-u.x)*(d.y-u.y))/p;return m>=0&&m<=1&&_>=0&&_<=1};return l(i,r,{x:s,y:A},{x:a,y:A})||l(i,r,{x:a,y:A},{x:a,y:c})||l(i,r,{x:s,y:c},{x:a,y:c})||l(i,r,{x:s,y:A},{x:s,y:c})},[t,e]),fOi=(t,e)=>ee.useMemo(()=>n=>{const o=Bn(t,n);return o.x>=-C4&&o.x<=e.width+C4&&o.y>=-C4&&o.y<=e.height+C4},[t,e]),IOi=({isPointOnScreen:t,doesLineIntersectViewport:e,filterLayerAndStep:n})=>ee.useMemo(()=>o=>{if(!n(o))return!1;if(o.points.some(i=>t(i)))return!0;for(let i=0;i<o.points.length-1;i++)if(e(o.points[i],o.points[i+1]))return!0;return!!(o.points.length>2&&o.closed&&e(o.points[o.points.length-1],o.points[0]))},[t,e,n]),COi=({isPointOnScreen:t,filterLayerAndStep:e})=>ee.useMemo(()=>n=>e(n)?t(n):!1,[t,e]),yOi=({realToScreen:t,isPointOnScreen:e,doesLineIntersectViewport:n,filterLayerAndStep:o})=>ee.useMemo(()=>i=>{if(!o(i))return!1;const{center:r}=i,[s,a,A,c]=ebt(i,t);return e(r)||e(s)||e(a)||e(A)||e(c)?!0:n(s,a)||n(a,A)||n(A,c)||n(c,s)},[t,e,n,o]),xOi=({isPointOnScreen:t,filterLayerAndStep:e,realToScreen:n,size:o})=>ee.useMemo(()=>i=>{if(!e(i))return!1;const{center:r,radius:s}=i;if(t(r)||t({x:r.x+s,y:r.y})||t({x:r.x-s,y:r.y})||t({x:r.x,y:r.y+s})||t({x:r.x,y:r.y-s}))return!0;const a=Bn(n,r),A=Math.abs(n.a),c=s*A,l=-C4,u=o.width+C4,g=-C4,h=o.height+C4;if(a.x>=l&&a.x<=u&&(Math.abs(a.y-g)<=c||Math.abs(a.y-h)<=c)||a.y>=g&&a.y<=h&&(Math.abs(a.x-l)<=c||Math.abs(a.x-u)<=c))return!0;const d=(m,_)=>{const f=a.x-m,I=a.y-_;return f*f+I*I},p=c*c;return d(l,g)<=p||d(u,g)<=p||d(l,h)<=p||d(u,h)<=p},[t,e,n,o]),EOi=({isPointOnScreen:t,filterLayerAndStep:e})=>ee.useMemo(()=>n=>e(n)?t({x:n.x,y:n.y}):!1,[t,e]),BOi=({isPointOnScreen:t,doesLineIntersectViewport:e})=>ee.useMemo(()=>n=>{const o=YW(n),{shaftStart:i,shaftEnd:r,heads:s}=o;return t(i)||t(r)||s.some(A=>t(A.tip)||t(A.leftWing)||t(A.rightWing)||t(A.base))?!0:[[i,r],...s.flatMap(A=>[[A.base,A.leftWing],[A.leftWing,A.tip],[A.tip,A.rightWing],[A.rightWing,A.base]])].some(([A,c])=>e(A,c))},[t,e]),bOi=({isPointOnScreen:t,doesLineIntersectViewport:e,filterLayerAndStep:n})=>ee.useMemo(()=>o=>{if(!n(o)||!o.points||o.points.length===0)return!1;if(o.points.some(i=>t(i)))return!0;for(let i=0;i<o.points.length;i++){const r=o.points[i],s=o.points[(i+1)%o.points.length];if(e(r,s))return!0}return!1},[t,e,n]),SOi=1e3,QOi=({graphics:t,onObjectClicked:e,objectLimit:n,height:o=600,stepMetadata:i,alwaysShowToolbar:r=!1})=>{const[s,a]=ee.useState(null),[A,c]=ee.useState(null),[l,u]=ee.useState(!0),[g,h]=ee.useState({width:600,height:o}),[d,p]=ee.useState(null),[m,_]=ee.useState(!1),[f,I]=ee.useState(null),[C,y]=ee.useState([]),[x,E]=ee.useState(null),[B,S]=ee.useState(null),Q=Array.from(new Set([...t.lines?.map(Ct=>Ct.layer).filter(Boolean)??[],...t.infiniteLines?.map(Ct=>Ct.layer).filter(Boolean)??[],...t.rects?.map(Ct=>Ct.layer).filter(Boolean)??[],...t.polygons?.map(Ct=>Ct.layer).filter(Boolean)??[],...t.points?.map(Ct=>Ct.layer).filter(Boolean)??[],...t.texts?.map(Ct=>Ct.layer).filter(Boolean)??[],...t.circles?.map(Ct=>Ct.layer).filter(Boolean)??[]])),w=khn(t),M=ee.useMemo(()=>{const Ct=nOi(t),Dt=Ct.maxX-Ct.minX,Nt=Ct.maxY-Ct.minY;return{minX:Ct.minX-Dt/10,minY:Ct.minY-Nt/10,maxX:Ct.maxX+Dt/10,maxY:Ct.maxY+Nt/10}},[t]),k=ee.useCallback(()=>{const Ct=window.location.pathname,Dt=window.location.search;return`saved-camera-position-${Ct}${Dt}`},[]),R=ee.useCallback(()=>{const Ct=Math.max(M.maxX-M.minX,1),Dt=Math.max(M.maxY-M.minY,1),Nt=Math.min(g.width/Ct,g.height/Dt);return Ad(pA(g.width/2,g.height/2),dC(Nt,-Nt),pA(-(M.maxX+M.minX)/2,-(M.maxY+M.minY)/2))},[g,M]),F=ee.useCallback(()=>{try{const Ct=localStorage.getItem(k());if(Ct)return JSON.parse(Ct)}catch(Ct){console.error("Error loading saved data:",Ct)}return null},[k]),O=ee.useCallback(()=>F()?.transform||null,[F]),{transform:U,ref:Y,setTransform:W}=Lun({initialTransform:R()});Thn(Y,Ct=>{h({width:Ct.contentRect.width,height:Ct.contentRect.height})}),ee.useEffect(()=>{const Ct=F();Ct?.markers&&y(Ct.markers)},[F]);const te=ee.useCallback(Ct=>{Ct.preventDefault();const Dt=Ct.clientX,Nt=Ct.clientY,st=Ct.currentTarget.getBoundingClientRect(),Yt=st.left,pn=st.top,be=window.innerWidth,et=window.innerHeight,It=160,Et=100;let Ze=Dt-Yt,mt=Nt-pn;Dt>be/2&&(Ze=Ze-It),Nt>et/2&&(mt=mt-Et),p({x:Ze,y:mt,clientX:Dt,clientY:Nt})},[]),j=ee.useCallback((Ct,Dt)=>{try{const Nt={transform:Ct,markers:Dt};localStorage.setItem(k(),JSON.stringify(Nt))}catch(Nt){console.error("Error saving data:",Nt)}},[k]),J=ee.useCallback(()=>{j(U,C)},[j,U,C]),ie=ee.useCallback(()=>{try{const Ct=O();Ct&&W(Ct)}catch(Ct){console.error("Error loading camera position:",Ct)}},[O,W]),oe=ee.useCallback(()=>{try{const Ct=R();j(Ct,C),W(Ct)}catch(Ct){console.error("Error clearing camera position:",Ct)}},[j,R,W,C]),ne=ee.useCallback(()=>{if(d)try{const Ct={x:d.clientX,y:d.clientY},Dt=Y.current?.getBoundingClientRect();if(Dt){const Nt=Ct.x-Dt.left,st=Ct.y-Dt.top,Yt=fV(U),[pn,be]=Bn(Yt,[Nt,st]),et={x:pn,y:be},It=[...C,et];y(It);const Et=F();Et?.transform&&j(Et.transform,It)}}catch(Ct){console.error("Error adding marker:",Ct)}},[d,Y,U,C,j]),ge=ee.useCallback(()=>{y([]);const Ct=F();Ct?.transform&&j(Ct.transform,[])},[F,j]),ue=ee.useCallback(Ct=>{switch(Ct.type){case"arrow":return[Ct.object.label,Ct.object.inlineLabel].filter(Boolean).join(`
@@ -5668,7 +5668,7 @@ test("${c} should solve problem correctly", () => {
5668
5668
  // Add more specific assertions based on expected output
5669
5669
  // expect(solver.netLabelPlacementSolver!.netLabelPlacements).toMatchInlineSnapshot()
5670
5670
  })
5671
- `,u=new Blob([l],{type:"text/plain"}),g=URL.createObjectURL(u),h=document.createElement("a");h.href=g,h.download=`${c}.test.ts`,h.click(),URL.revokeObjectURL(g)}catch(A){alert(`Error generating test.ts for ${t.getSolverName()}: ${A instanceof Error?A.message:String(A)}`)}o(!1)};return K.jsxs("div",{className:`relative ${e}`,ref:i,children:[K.jsx("button",{className:"px-2 py-1 rounded text-xs cursor-pointer",onClick:()=>o(!n),title:`Download options for ${t.getSolverName()}`,children:t.getSolverName()}),n&&K.jsxs("div",{className:"absolute top-full left-0 mt-1 bg-white border border-gray-300 rounded shadow-lg z-10 min-w-[150px]",children:[K.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:r,children:"Download JSON"}),K.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:s,children:"Download page.tsx"}),K.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:a,children:"Download test.ts"})]})]})},Ohn=t=>t.activeSubSolver?[t,...Ohn(t.activeSubSolver)]:[t],DOi=({solver:t})=>{const e=Ohn(t);return K.jsx("div",{className:"flex gap-1 items-center text-sm pt-1",children:e.map((n,o)=>K.jsxs("div",{className:"flex items-center",children:[o>0&&K.jsx("span",{className:"text-gray-400 mx-1",children:"→"}),K.jsx(MOi,{solver:n})]},n.getSolverName()))})},NOi=({solver:t,triggerRender:e,animationSpeed:n=25,renderer:o,onRendererChange:i,onAnimationSpeedChange:r,onDownloadVisualization:s,onSolverStarted:a,onSolverCompleted:A})=>{const[c,l]=ee.useReducer(B=>!B,!1),u=ee.useRef(void 0),g=ee.useRef(null),h="solver-debugger-last-iteration",[d,p]=ee.useState(null),m=ee.useRef(null),_=ee.useMemo(()=>[{label:"Slow",value:250,description:"250ms"},{label:"Normal",value:100,description:"100ms"},{label:"Fast",value:10,description:"10ms"},{label:"Fast (2x)",value:5,description:"5ms"},{label:"Fast (10x)",value:1,description:"1ms"},{label:"Fast 20x",value:.5,description:"2 steps / 1ms"},{label:"Fast 100x",value:.1,description:"10 steps / 1ms"}],[]),f=()=>{const B=Math.max(1,n),S=n<1?Math.round(1/n):1;u.current=setInterval(()=>{if(t.solved||t.failed){u.current&&(clearInterval(u.current),u.current=void 0),l(),e(),A&&t.solved&&A(t);return}for(let Q=0;Q<S&&!(t.solved||t.failed);Q++)t.step();e()},B)},I=()=>{u.current&&(clearInterval(u.current),u.current=void 0)},C=()=>{!t.solved&&!t.failed&&(t.step(),e())},y=()=>{!t.solved&&!t.failed&&(a&&a(t),t.solve(),e(),A&&A(t))},x=()=>{c?(I(),l()):(l(),f())},E=()=>{if(t.solved||t.failed||c)return;g.current===null&&typeof window<"u"&&(g.current=window.localStorage.getItem(h));const B=window.prompt("Step until which iteration?",g.current??`${t.iterations}`);if(B===null)return;g.current=B,typeof window<"u"&&window.localStorage.setItem(h,B);const S=Number(B);if(!Number.isFinite(S)){window.alert("Please enter a valid number for the iteration");return}for(;t.iterations<S&&!t.solved&&!t.failed;)t.step();e(),t.solved&&A&&A(t)};return ee.useEffect(()=>()=>{I()},[]),ee.useEffect(()=>{(t.solved||t.failed)&&c&&(I(),l())},[t.solved,t.failed,c]),ee.useEffect(()=>{c&&(I(),f())},[n,c]),ee.useEffect(()=>{if(typeof document>"u")return;const B=S=>{m.current&&!m.current.contains(S.target)&&p(null)};return document.addEventListener("mousedown",B),()=>{document.removeEventListener("mousedown",B)}},[]),K.jsxs("div",{className:"space-y-2 p-2 border-b",children:[K.jsx("div",{className:"flex items-center",children:K.jsxs("div",{className:"flex items-center gap-2",ref:m,children:[K.jsxs("div",{className:"flex h-9 items-center space-x-1 rounded-md border border-slate-200 bg-white p-1 shadow-sm",children:[K.jsxs("div",{className:"relative",children:[K.jsx("button",{type:"button",onClick:()=>p(d==="renderer"?null:"renderer"),className:"flex select-none items-center rounded-sm px-3 py-1 text-sm font-medium outline-none focus:bg-slate-100 data-[state=open]:bg-slate-100","data-state":d==="renderer"?"open":"closed",children:"Renderer"}),d==="renderer"&&K.jsx("div",{className:"absolute left-0 z-50 mt-1 min-w-[10rem] rounded-md border border-slate-200 bg-white p-1 text-slate-950 shadow-md",children:["vector","canvas"].map(B=>K.jsxs("button",{type:"button",onClick:()=>{i(B),p(null)},className:"flex w-full items-center rounded-sm px-2 py-1.5 text-sm hover:bg-slate-100",children:[B==="vector"?"Vector":"Canvas",o===B&&K.jsx("span",{className:"ml-auto text-xs text-slate-500",children:"✓"})]},B))})]}),K.jsxs("div",{className:"relative",children:[K.jsx("button",{type:"button",onClick:()=>p(d==="debug"?null:"debug"),className:"flex select-none items-center rounded-sm px-3 py-1 text-sm font-medium outline-none focus:bg-slate-100 data-[state=open]:bg-slate-100","data-state":d==="debug"?"open":"closed",children:"Debug"}),d==="debug"&&K.jsx("div",{className:"absolute left-0 z-50 mt-1 min-w-[12rem] rounded-md border border-slate-200 bg-white p-1 text-slate-950 shadow-md",children:K.jsx("button",{type:"button",onClick:()=>{s(),p(null)},className:"flex w-full items-center rounded-sm px-2 py-1.5 text-sm hover:bg-slate-100",children:"Download Visualization"})})]}),K.jsxs("div",{className:"relative",children:[K.jsx("button",{type:"button",onClick:()=>p(d==="animation"?null:"animation"),className:"flex select-none items-center rounded-sm px-3 py-1 text-sm font-medium outline-none focus:bg-slate-100 data-[state=open]:bg-slate-100","data-state":d==="animation"?"open":"closed",children:"Animation"}),d==="animation"&&K.jsx("div",{className:"absolute left-0 z-50 mt-1 min-w-[12rem] rounded-md border border-slate-200 bg-white p-1 text-slate-950 shadow-md",children:_.map(B=>K.jsxs("button",{type:"button",onClick:()=>{r(B.value),p(null)},className:"flex w-full items-center rounded-sm px-2 py-1.5 text-sm hover:bg-slate-100",children:[B.label,K.jsx("span",{className:"ml-auto text-xs text-slate-500",children:B.description}),n===B.value&&K.jsx("span",{className:"ml-2 text-xs text-slate-500",children:"✓"})]},B.value))})]})]}),K.jsx(DOi,{solver:t})]})}),K.jsxs("div",{className:"flex gap-2 items-center flex-wrap",children:[K.jsx("button",{onClick:C,disabled:t.solved||t.failed||c,className:"bg-blue-500 hover:bg-blue-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Step"}),K.jsx("button",{onClick:y,disabled:t.solved||t.failed||c,className:"bg-green-500 hover:bg-green-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Solve"}),K.jsx("button",{onClick:x,disabled:t.solved||t.failed,className:`px-3 py-1 rounded text-white text-sm ${c?"bg-red-500 hover:bg-red-600":"bg-yellow-500 hover:bg-yellow-600"} disabled:bg-gray-300`,children:c?"Stop":"Animate"}),K.jsx("button",{onClick:E,disabled:t.solved||t.failed||c,className:"bg-orange-500 hover:bg-orange-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Step Until Iteration"}),K.jsxs("div",{className:"text-sm text-gray-600",children:["Iterations: ",t.iterations]}),t.timeToSolve!==void 0&&K.jsxs("div",{className:"text-sm text-gray-600",children:["Time: ",(t.timeToSolve/1e3).toFixed(3),"s"]}),t.solved&&K.jsx("div",{className:"px-2 py-1 bg-green-100 text-green-800 rounded text-sm",children:"Solved"}),t.failed&&K.jsx("div",{className:"px-2 py-1 bg-red-100 text-red-800 rounded text-sm",children:"Failed"})]}),t.error&&K.jsxs("div",{className:"text-red-600 text-sm",children:["Error: ",t.error]})]})},ROi=t=>t!==null&&"pipelineDef"in t&&Array.isArray(t.pipelineDef),TOi=(t,e,n)=>{const o=t.currentPipelineStageIndex;return e<o?"Completed":e===o&&t.activeSubSolver?t.activeSubSolver.failed?"Failed":"In Progress":"Not Started"},kOi=(t,e)=>{const o=t.pipelineDef[e].solverName,i=TOi(t,e),r=t[o],s=t.firstIterationOfStage?.[o]??(e===t.currentPipelineStageIndex?t.iterations:null),a=t.iterations;let A=0;if(i==="Completed"){const g=t.pipelineDef[e+1],h=g?t.firstIterationOfStage?.[g.solverName]:void 0;h!==void 0&&s!==null?A=h-s:s!==null&&(A=a-s)}else i==="In Progress"&&s!==null&&(A=a-s);const c=t.timeSpentOnStage?.[o]??0;let l=0;i==="Completed"?l=1:i==="In Progress"&&r&&(l=r.progress??0);const u=r?.stats??null;return{index:e,name:o,status:i,firstIteration:s,iterations:A,progress:l,timeSpent:c,stats:u&&Object.keys(u).length>0?u:null,solverInstance:r??null}},FOi=({status:t})=>{const e={"Not Started":"text-blue-600","In Progress":"text-yellow-600",Completed:"text-green-600",Failed:"text-red-600"};return K.jsx("span",{className:`font-medium ${e[t]}`,children:t})},LOi=({progress:t})=>{if(t===0)return null;const e=Math.round(t*100);return K.jsxs("div",{className:"flex items-center gap-2",children:[K.jsx("div",{className:"w-20 h-2 bg-gray-200 rounded overflow-hidden",children:K.jsx("div",{className:"h-full bg-blue-500 transition-all duration-200",style:{width:`${e}%`}})}),K.jsxs("span",{className:"text-xs text-gray-500",children:[e,"%"]})]})},Ghn=t=>{if(typeof t=="string")return t;if(typeof t=="number"||typeof t=="boolean"||typeof t=="bigint"||t==null)return String(t);if(typeof t=="object")try{return JSON.stringify(t)}catch{return String(t)}return String(t)},HOi=t=>Object.entries(t).map(([e,n])=>`${e}: ${Ghn(n)}`).join(", "),OOi=({stats:t})=>{if(!t||Object.keys(t).length===0)return K.jsx("span",{children:"-"});const e=Object.entries(t),n=HOi(t);return K.jsxs("details",{className:"cursor-pointer",children:[K.jsx("summary",{className:"whitespace-nowrap overflow-hidden text-ellipsis max-w-[200px]",children:n}),K.jsx("div",{className:"mt-1 text-xs",children:e.map(([o,i])=>K.jsxs("div",{children:[o,": ",Ghn(i)]},o))})]})},B$e=t=>{if(t===null||typeof t!="object")return t;if(Array.isArray(t))return t.map(B$e);const e={};for(const[n,o]of Object.entries(t))n.startsWith("_")||(e[n]=B$e(o));return e},GOi=(t,e)=>{try{if(typeof t.getConstructorParams!="function"){alert(`getConstructorParams() is not implemented for ${e}`);return}const n=B$e(t.getConstructorParams()),o=new Blob([JSON.stringify(n,null,2)],{type:"application/json"}),i=URL.createObjectURL(o),r=document.createElement("a");r.href=i,r.download=`${e}_input.json`,r.click(),URL.revokeObjectURL(i)}catch(n){alert(`Error downloading input for ${e}: ${n instanceof Error?n.message:String(n)}`)}},YOi=({expanded:t})=>K.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:`w-4 h-4 transition-transform duration-200 ${t?"rotate-90":""}`,children:K.jsx("path",{fillRule:"evenodd",d:"M4.5 5.653c0-1.426 1.529-2.33 2.779-1.643l11.54 6.348c1.295.712 1.295 2.573 0 3.285L7.28 19.991c-1.25.687-2.779-.217-2.779-1.643V5.653z",clipRule:"evenodd"})}),Yhn=t=>{let e=t;for(;e.activeSubSolver;)e=e.activeSubSolver;return e},Uhn=({solver:t,onStepUntilPhase:e,onDownloadInput:n,isNested:o=!1,indentLevel:i=0,triggerRender:r})=>{const[s,a]=ee.useState(new Set),A=t.pipelineDef.map((m,_)=>kOi(t,_)),c=m=>{a(_=>{const f=new Set(_);return f.has(m)?f.delete(m):f.add(m),f})},l=m=>{e?.(m)},u=m=>{m.solverInstance&&(n?n(m.solverInstance,m.name):GOi(m.solverInstance,m.name))},g=m=>`${(m/1e3).toFixed(2)}s`,h=()=>{if(!t.solved&&!t.failed){const m=t.activeSubSolver;for(;!t.solved&&!t.failed&&(t.step(),!(t.activeSubSolver&&t.activeSubSolver!==m)););r?.()}},d=()=>{if(!t.solved&&!t.failed){const m=Yhn(t);for(;!t.solved&&!t.failed&&(t.step(),Yhn(t)===m););r?.()}},p=i*24;return K.jsxs("div",{className:o?"":"border-t border-gray-200",children:[!o&&K.jsxs("div",{className:"px-4 py-2 bg-gray-50 border-b border-gray-200 flex items-center justify-between",children:[K.jsx("h3",{className:"text-sm font-semibold text-gray-700",children:"Pipeline Stages"}),K.jsxs("div",{className:"flex gap-2",children:[K.jsx("button",{onClick:d,disabled:t.solved||t.failed,className:"bg-indigo-500 hover:bg-indigo-600 disabled:bg-gray-300 disabled:cursor-not-allowed cursor-pointer text-white px-3 py-1 rounded text-sm",children:"Next Solver"}),K.jsx("button",{onClick:h,disabled:t.solved||t.failed,className:"bg-purple-500 hover:bg-purple-600 disabled:bg-gray-300 disabled:cursor-not-allowed cursor-pointer text-white px-3 py-1 rounded text-sm",children:"Next Stage"})]})]}),K.jsx("div",{className:"overflow-x-auto",children:K.jsxs("table",{className:"w-full text-sm",children:[!o&&K.jsx("thead",{children:K.jsxs("tr",{className:"bg-gray-50 border-b border-gray-200",children:[K.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Stage"}),K.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Status"}),K.jsxs("th",{className:"px-4 py-2 text-center font-semibold text-gray-700",children:["i",K.jsx("sub",{children:"0"})]}),K.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Iterations"}),K.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Progress"}),K.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Time"}),K.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Stats"}),K.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Input"})]})}),K.jsx("tbody",{children:A.map(m=>{const _=ROi(m.solverInstance),f=s.has(m.name);return K.jsxs(Fs.Fragment,{children:[K.jsxs("tr",{className:`border-b border-gray-100 ${m.status==="In Progress"?"bg-yellow-50":""}`,children:[K.jsx("td",{className:"px-4 py-2",children:K.jsxs("div",{className:"flex items-center gap-2",style:{paddingLeft:p},children:[_?K.jsx("button",{onClick:()=>c(m.name),className:"text-gray-500 hover:text-gray-700",title:f?"Collapse":"Expand",children:K.jsx(YOi,{expanded:f})}):K.jsx("span",{className:"w-4"}),K.jsx("span",{className:"text-gray-400 w-6",children:String(m.index+1).padStart(2,"0")}),K.jsx("button",{onClick:()=>l(m.name),disabled:m.status==="Completed"||t.solved||t.failed,className:"text-blue-500 hover:text-blue-700 disabled:text-gray-300 disabled:cursor-not-allowed",title:`Step until ${m.name} completes`,children:K.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:K.jsx("path",{fillRule:"evenodd",d:"M4.5 5.653c0-1.426 1.529-2.33 2.779-1.643l11.54 6.348c1.295.712 1.295 2.573 0 3.285L7.28 19.991c-1.25.687-2.779-.217-2.779-1.643V5.653z",clipRule:"evenodd"})})}),K.jsx("span",{className:"font-medium text-gray-900",children:m.name})]})}),K.jsx("td",{className:"px-4 py-2",children:K.jsx(FOi,{status:m.status})}),K.jsx("td",{className:"px-4 py-2 text-center text-gray-600",children:m.firstIteration!==null?m.firstIteration:""}),K.jsx("td",{className:"px-4 py-2 text-gray-600",children:m.iterations}),K.jsx("td",{className:"px-4 py-2",children:K.jsx(LOi,{progress:m.progress})}),K.jsx("td",{className:"px-4 py-2 text-gray-600",children:g(m.timeSpent)}),K.jsx("td",{className:"px-4 py-2 text-gray-500",children:K.jsx(OOi,{stats:m.stats})}),K.jsx("td",{className:"px-4 py-2",children:m.solverInstance?K.jsxs("button",{onClick:()=>u(m),className:"flex items-center gap-1 text-blue-500 hover:text-blue-700",title:`Download input for ${m.name}`,children:[K.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:K.jsx("path",{fillRule:"evenodd",d:"M12 2.25a.75.75 0 01.75.75v11.69l3.22-3.22a.75.75 0 111.06 1.06l-4.5 4.5a.75.75 0 01-1.06 0l-4.5-4.5a.75.75 0 111.06-1.06l3.22 3.22V3a.75.75 0 01.75-.75zm-9 13.5a.75.75 0 01.75.75v2.25a1.5 1.5 0 001.5 1.5h13.5a1.5 1.5 0 001.5-1.5V16.5a.75.75 0 011.5 0v2.25a3 3 0 01-3 3H5.25a3 3 0 01-3-3V16.5a.75.75 0 01.75-.75z",clipRule:"evenodd"})}),K.jsx("span",{children:"Input"})]}):null})]}),_&&f&&K.jsx("tr",{children:K.jsx("td",{colSpan:8,className:"p-0",children:K.jsx(Uhn,{solver:m.solverInstance,onStepUntilPhase:e,onDownloadInput:n,isNested:!0,indentLevel:i+1,triggerRender:r})})})]},m.name)})})]})})]})};function UOi({graphics:t}){const e=t.points??[],n=t.lines??[],o=t.rects??[],i=t.circles??[],r=t.texts??[];let s=Number.POSITIVE_INFINITY,a=Number.POSITIVE_INFINITY,A=Number.NEGATIVE_INFINITY,c=Number.NEGATIVE_INFINITY;const l=(m,_)=>{typeof m=="number"&&(m<s&&(s=m),m>A&&(A=m)),typeof _=="number"&&(_<a&&(a=_),_>c&&(c=_))};for(const m of e)l(m.x,m.y);for(const m of n){const _=m.points??[];for(const f of _)l(f.x,f.y)}for(const m of o){const _=m.x??0,f=m.y??0,I=m.width??0,C=m.height??0;l(_,f),l(_+I,f+C)}for(const m of i){const _=m.x??0,f=m.y??0,I=m.radius??1;l(_-I,f-I),l(_+I,f+I)}for(const m of r)l(m.x,m.y);(!isFinite(s)||!isFinite(a)||!isFinite(A)||!isFinite(c))&&(s=-20,a=-20,A=20,c=20);const u=10,g=s-u,h=a-u,d=Math.max(1,A-s+2*u),p=Math.max(1,c-a+2*u);return K.jsxs("svg",{className:"w-full h-[400px] bg-white",viewBox:`${g} ${h} ${d} ${p}`,role:"img","aria-label":"Graphics fallback",children:[o.map((m,_)=>K.jsx("rect",{x:m.x??0,y:m.y??0,width:m.width??0,height:m.height??0,fill:"none",stroke:m.strokeColor??"black",strokeWidth:m.strokeWidth??1},`rect-${_}`)),n.map((m,_)=>K.jsx("polyline",{fill:"none",stroke:m.strokeColor??"black",strokeWidth:m.strokeWidth??1,points:(m.points??[]).map(f=>`${f.x??0},${f.y??0}`).join(" ")},`line-${_}`)),i.map((m,_)=>K.jsx("circle",{cx:m.x??0,cy:m.y??0,r:m.radius??1.5,fill:m.fillColor??"none",stroke:m.strokeColor??"black",strokeWidth:m.strokeWidth??1},`circle-${_}`)),e.map((m,_)=>K.jsx("circle",{cx:m.x??0,cy:m.y??0,r:m.radius??1.5,fill:m.color??"black"},`point-${_}`)),r.map((m,_)=>K.jsx("text",{x:m.x??0,y:m.y??0,fontSize:m.fontSize??10,fill:m.color??"black",children:m.text??""},`text-${_}`))]})}var KOi=class extends Fs.Component{constructor(t){super(t),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(t){console.error("InteractiveGraphics render error:",t)}render(){return this.state.hasError?this.props.fallback:this.props.children}},VOi=({solver:t,createSolver:e,animationSpeed:n=25,onSolverStarted:o,onSolverCompleted:i})=>{const[r,s]=ee.useReducer(f=>f+1,0),[a]=ee.useState(()=>{if(e)return e();if(!t)throw new Error("GenericSolverDebugger requires solver or createSolver");return t}),[A,c]=ee.useState(()=>typeof window>"u"?"vector":window.localStorage.getItem("solver-utils-renderer")==="canvas"?"canvas":"vector"),[l,u]=ee.useState(n),g=ee.useMemo(()=>{try{return a.visualize()||{points:[],lines:[],rects:[],circles:[]}}catch(f){return console.error("Visualization error:",f),{points:[],lines:[],rects:[],circles:[]}}},[a,r]),h=ee.useMemo(()=>(g.rects?.length||0)===0&&(g.lines?.length||0)===0&&(g.points?.length||0)===0&&(g.circles?.length||0)===0,[g]);ee.useEffect(()=>{if(!(typeof document>"u")&&!document.querySelector('script[src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4"]')){const f=document.createElement("script");f.src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4",document.head.appendChild(f)}},[]),ee.useEffect(()=>{u(n)},[n]);const d=a.pipelineDef!==void 0,p=f=>{const I=a;if(!a.solved&&!a.failed){for(;!a.solved&&!a.failed&&I.currentPipelineStageIndex<=I.pipelineDef.findIndex(C=>C.solverName===f);)a.step();s()}},m=()=>{const f=JSON.stringify(g,null,2),I=new Blob([f],{type:"application/json"}),C=URL.createObjectURL(I),y=document.createElement("a");y.download="visualization.json",y.href=C,document.body.appendChild(y),y.click(),document.body.removeChild(y),URL.revokeObjectURL(C)},_=f=>{c(f),typeof window<"u"&&window.localStorage.setItem("solver-utils-renderer",f)};return K.jsxs("div",{children:[K.jsx(NOi,{solver:a,triggerRender:s,animationSpeed:l,renderer:A,onRendererChange:_,onAnimationSpeedChange:u,onDownloadVisualization:m,onSolverStarted:o,onSolverCompleted:i}),h?K.jsx("div",{className:"p-4 text-gray-500",children:"No Graphics Yet"}):K.jsx(KOi,{fallback:K.jsx(UOi,{graphics:g}),children:A==="canvas"?K.jsx(POi,{graphics:g}):K.jsx(QOi,{graphics:g})}),d&&K.jsx(Uhn,{solver:a,onStepUntilPhase:p,triggerRender:s})]})};const zOi=()=>{ee.useEffect(()=>{const t="tailwind-cdn-script";if(document.getElementById(t)||window.tailwind)return;const e=document.createElement("div");e.className="hidden",document.body.appendChild(e);const n=window.getComputedStyle(e).display==="none";if(document.body.removeChild(e),n)return;const o=document.createElement("script");o.id=t,o.src="https://cdn.tailwindcss.com",document.head.appendChild(o)},[])},JOi=1e3,NE=(t,e)=>{const{fileName:n,mimeType:o="text/plain"}=e,i=t instanceof Blob?t:new Blob([t],{type:o}),r=URL.createObjectURL(i),s=document.createElement("a");s.href=r,s.download=n,s.target="_blank",s.rel="noopener noreferrer",s.style.display="none",document.body.appendChild(s),s.click(),document.body.removeChild(s),setTimeout(()=>{URL.revokeObjectURL(r)},JOi)},b$e=t=>{let e=t.trim().replace(/[\\/:*?"<>|]/g,"_").replace(/[\x00-\x1f]/g,"").replace(/^\.+/,"").replace(/\.+$/,"").replace(/\s+/g," ").replace(/_+/g,"_");return/^(con|prn|aux|nul|com[0-9]|lpt[0-9])$/i.test(e)&&(e=`_${e}`),e=e.slice(0,200),e||"untitled"},WOi=t=>{const e=t.solverConstructorArgs??[t.solverParams];if(t.solverName!=="AutoroutingPipelineSolver7_MultiGraph"||e.length!==1)return e;const[{input:n,options:o}]=e;return[n,o]},e8="https://github.com/tscircuit/tscircuit-autorouter/issues/new",Khn="https://github.com/tscircuit/copper-pour-solver/issues/new",Vhn="https://github.com/tscircuit/calculate-packing/issues/new",jOi="https://github.com/tscircuit/matchpack/issues/new",zhn="https://github.com/tscircuit/schematic-trace-solver/issues/new?template=json-bug-report.yml",$Oi={PackSolver2:Vhn,LayoutPipelineSolver:jOi,AutoroutingPipelineSolver:e8,AssignableAutoroutingPipeline2:e8,AssignableAutoroutingPipeline3:e8,AutoroutingPipeline1_OriginalUnravel:e8,AutoroutingPipelineSolver3_HgPortPointPathing:e8,AutoroutingPipelineSolver4:e8,AutoroutingPipelineSolver5:e8,AutoroutingPipelineSolver7_MultiGraph:e8,AutoroutingPipelineSolver8:e8,CopperPourPipelineSolver:Khn,SchematicTracePipelineSolver:zhn},qOi=t=>t.toLowerCase().includes("pack")?tln:t.toLowerCase().includes("rout")?oln:z8i,Jhn=t=>{const e=$Oi[t];if(e)return e;const n=t.toLowerCase();return n.includes("autorout")?e8:n.includes("schematic")&&n.includes("trace")?zhn:n.includes("copperpour")?Khn:n.includes("pack")?Vhn:null},XOi=t=>`${b$e(`${t.componentName}-${t.solverName}`)}-solver-input.json`,Whn=t=>{NE(JSON.stringify(t.solverParams,null,2),{fileName:XOi(t),mimeType:"application/json"})},ZOi=({solverEvent:t})=>{const e=Jhn(t.solverName);return K.jsxs("div",{className:"rf-flex rf-items-center rf-justify-end rf-gap-2 rf-border-b rf-border-gray-200 rf-bg-gray-50 rf-px-4 rf-py-2",children:[K.jsxs(fA,{type:"button",variant:"outline",size:"sm",onClick:()=>Whn(t),children:[K.jsx(uZ,{className:"rf-w-4 rf-h-4"}),"Download"]}),e?K.jsx(fA,{asChild:!0,variant:"outline",size:"sm",children:K.jsxs("a",{href:e,target:"_blank",rel:"noopener noreferrer",children:[K.jsx(yme,{className:"rf-w-4 rf-h-4"}),"Report"]})}):K.jsxs(fA,{type:"button",variant:"outline",size:"sm",disabled:!0,title:"No report link configured for this solver",children:[K.jsx(yme,{className:"rf-w-4 rf-h-4"}),"Report"]})]})},eGi=({solverEvent:t})=>{const e=Jhn(t.solverName);return e?K.jsx(fA,{asChild:!0,variant:"ghost",size:"icon",className:"rf-h-8 rf-w-8",children:K.jsx("a",{href:e,target:"_blank",rel:"noopener noreferrer",title:"Report solver bug","aria-label":"Report solver bug",children:K.jsx(yme,{className:"rf-w-4 rf-h-4"})})}):K.jsx(fA,{type:"button",variant:"ghost",size:"icon",className:"rf-h-8 rf-w-8",disabled:!0,title:"No report link configured for this solver","aria-label":"Report solver bug",children:K.jsx(yme,{className:"rf-w-4 rf-h-4"})})},tGi=({solverEvents:t=[]})=>{const[e,n]=ee.useState(null);zOi();const o=ee.useMemo(()=>{const a=new Map;for(const A of t){const c=`${A.componentName}-${A.solverName}`;a.set(c,A)}return a},[t]),i=ee.useMemo(()=>Array.from(o.keys()),[o]),r=e?o.get(e):null,s=ee.useMemo(()=>{if(!r)return{instance:null,error:null,classFound:!1};const a=gMe[r.solverName];if(!a)return{instance:null,error:`Solver class "${r.solverName}" not found in SOLVERS registry. Available: ${Object.keys(gMe).join(", ")}`,classFound:!1};try{return{instance:new a(...WOi(r)),error:null,classFound:!0}}catch(A){const c=A instanceof Error?A.message:String(A);return console.error("Failed to reconstruct solver:",A),{instance:null,error:`Failed to instantiate solver: ${c}`,classFound:!0}}},[r]);return t.length===0?K.jsx("div",{className:"rf-p-4",children:K.jsx("div",{className:"rf-bg-gray-50 rf-rounded-md rf-border rf-border-gray-200",children:K.jsxs("div",{className:"rf-p-4",children:[K.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800 rf-mb-3",children:"No Solvers Detected"}),K.jsx("p",{className:"rf-text-sm rf-text-gray-600",children:"Solvers will appear here when the circuit runs. Solvers are used for tasks like component packing and autorouting."})]})})}):K.jsxs("div",{className:"rf-flex rf-h-full rf-overflow-hidden",children:[K.jsxs("div",{className:"rf-w-64 rf-border-r rf-border-gray-200 rf-overflow-y-auto rf-flex-shrink-0",children:[K.jsxs("div",{className:"rf-text-xs rf-font-semibold rf-text-gray-500 rf-px-3 rf-py-2 rf-bg-gray-50 rf-border-b rf-border-gray-200",children:[i.length," ",i.length===1?"Solver":"Solvers"]}),i.map(a=>{const A=o.get(a),c=e===a;return K.jsx("div",{className:`rf-px-3 rf-py-2 rf-cursor-pointer rf-border-b rf-border-gray-100 ${c?"rf-bg-blue-50 rf-border-l-2 rf-border-l-blue-500":"hover:rf-bg-gray-50"}`,onClick:()=>n(a),children:(()=>{const l=qOi(A.solverName);return K.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2",children:[K.jsx(l,{className:"rf-w-4 rf-h-4 rf-text-blue-500 rf-flex-shrink-0"}),K.jsxs("div",{className:"rf-flex-1 rf-min-w-0",children:[K.jsx("div",{className:"rf-text-sm rf-font-medium rf-text-gray-800 rf-truncate",children:A.componentName}),K.jsx("div",{className:"rf-text-xs rf-text-gray-500 rf-truncate",children:A.solverName})]})]})})()},a)})]}),K.jsx("div",{className:"rf-flex-1 rf-overflow-hidden",children:r?s.instance?K.jsxs("div",{className:"rf-flex rf-h-full rf-flex-col rf-overflow-y-auto",children:[K.jsx(ZOi,{solverEvent:r}),K.jsx("div",{className:"rf-min-h-0 rf-flex-1",children:K.jsx(yE,{fallback:K.jsx("div",{className:"rf-p-4",children:K.jsxs("div",{className:"rf-bg-red-50 rf-rounded-md rf-border rf-border-red-200 rf-p-4",children:[K.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-red-800 rf-mb-2",children:"Error Loading Solver Debugger"}),K.jsxs("p",{className:"rf-text-sm rf-text-red-600",children:["Failed to render the solver debugger for"," ",r.solverName]})]})}),children:K.jsx(VOi,{solver:s.instance})})})]}):K.jsxs("div",{className:"rf-p-4",children:[K.jsxs("div",{className:"rf-mb-4",children:[K.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800",children:r.solverName}),K.jsxs("p",{className:"rf-text-sm rf-text-gray-500",children:["Component: ",r.componentName]})]}),s.error&&K.jsx("div",{className:`rf-rounded-md rf-border rf-p-4 rf-mb-4 ${s.classFound?"rf-bg-red-50 rf-border-red-200":"rf-bg-yellow-50 rf-border-yellow-200"}`,children:K.jsx("p",{className:`rf-text-sm ${s.classFound?"rf-text-red-700":"rf-text-yellow-700"}`,children:s.error})}),K.jsxs("div",{className:"rf-border rf-border-gray-200 rf-rounded-md rf-overflow-hidden",children:[K.jsxs("div",{className:"rf-px-3 rf-py-2 rf-bg-gray-50 rf-flex rf-items-center rf-justify-between rf-gap-2",children:[K.jsx("span",{className:"rf-text-sm rf-font-medium rf-text-gray-700",children:"Solver Parameters"}),K.jsxs("div",{className:"rf-flex rf-items-center rf-gap-1",children:[K.jsx(eGi,{solverEvent:r}),K.jsx(fA,{type:"button",variant:"ghost",size:"icon",className:"rf-h-8 rf-w-8","aria-label":"Download solver input JSON",title:"Download solver input JSON",onClick:()=>Whn(r),children:K.jsx(uZ,{className:"rf-w-4 rf-h-4"})})]})]}),K.jsx("div",{className:"rf-p-3 rf-bg-white rf-border-t rf-border-gray-200",children:K.jsx("pre",{className:"rf-text-xs rf-font-mono rf-text-gray-600 rf-whitespace-pre-wrap rf-overflow-x-auto",children:JSON.stringify(r.solverParams,null,2)})})]})]}):K.jsx("div",{className:"rf-flex rf-items-center rf-justify-center rf-h-full",children:K.jsx("p",{className:"rf-text-sm rf-text-gray-500",children:"Select a solver from the list to view details"})})})]})},nGi=["subcircuit_id","componentDisplayName","phaseName","routingPhaseIndex","phaseOrdinal","phaseCount","phaseStageIndex","phaseStageCount","connectionCount","obstacleCount","previousTraceCount","isReroutePhase","autorouterName","autorouterVersion","solverName","effort","cacheStatus"],oGi=["phaseOrdinal","routingPhaseIndex","phaseName","phaseStageIndex"];function iGi(t,e){let n=-1,o=-1;for(let i=t.length-1;i>=0;i--){const r=t[i];if(r.status!=="running"||r.subcircuit_id!==e.subcircuit_id||r.componentDisplayName!==e.componentDisplayName)continue;let s=0,a=!1;for(const A of oGi)if(!(r[A]===void 0||e[A]===void 0)){if(r[A]!==e[A]){a=!0;break}s++}!a&&s>o&&(n=i,o=s)}return n}function rGi(t,e){const n=Object.fromEntries(nGi.filter(s=>e[s]!==void 0).map(s=>[s,e[s]])),o=e.simpleRouteJson?structuredClone(e.simpleRouteJson):void 0,i=e.type==="autorouting:start"?-1:iGi(t,e),r={...i===-1?{id:`autorouting_phase_${t.length+1}`}:t[i],...n,status:e.type==="autorouting:start"?"running":e.type==="autorouting:end"?"complete":"error",...e.type==="autorouting:start"?{startSimpleRouteJson:o}:e.type==="autorouting:end"?{endSimpleRouteJson:o}:{errorSimpleRouteJson:o,error:e.error?{...e.error}:void 0}};return i===-1?[...t,r]:t.map((s,a)=>a===i?r:s)}const sGi=new Map([["custom","Custom"],["fanout","Fanout"],["single_layer_fanout","Single layer fanout"],["tscircuit_simplify","Simplify"]]),aGi=new Set(["tscircuit","default","auto","auto_local"]);function AGi(t){if(t==="FanoutSolver")return"Fanout";if(t==="AutoroutingPipelineSolver11_Simplification")return"Simplify";const e=t.match(/^AutoroutingPipeline(?:Solver)?(\d+)(?:_|$)/);if(e)return`Pipeline${e[1]}`;const n=t.match(/^AssignableAutoroutingPipeline(\d+)$/);return n?`Assignable${n[1]}`:t}function cGi(t){const e=t.autorouterName?.trim(),n=e?.replace(/-/g,"_"),o=n&&sGi.get(n);if(o)return o;if(n&&!aGi.has(n))return e;const i=t.solverName?.trim();if(i)return AGi(i);const r=t.autorouterVersion?.trim();if(r){const s=r.match(/^beta[_-]pipeline(\d+)$/);return s?`Pipeline${s[1]}`:r==="latest"?"default":r}return e?"default":"Unknown"}const S$e="#fbbf24";function lGi(t){const e=t.endSimpleRouteJson?.traces??[],n=new Set(e.flatMap(i=>[i.pcb_trace_id,i.__replaces_pcb_trace_id].filter(r=>r!==void 0)));return[...(t.startSimpleRouteJson?.traces??[]).filter(i=>!n.has(i.pcb_trace_id)),...e]}function jhn(t){const e=new Map((t.startSimpleRouteJson?.traces??[]).map(n=>[n.pcb_trace_id,n]));return(t.endSimpleRouteJson?.traces??[]).filter(n=>{const o=e.get(n.pcb_trace_id);return!o||!!n.__replaces_pcb_trace_id&&n.__replaces_pcb_trace_id!==o.__replaces_pcb_trace_id||JSON.stringify(o.route)!==JSON.stringify(n.route)}).map(n=>n.pcb_trace_id)}function uGi(t,e){return{outer_diameter:t.via_diameter??e.minViaPadDiameter??e.min_via_pad_diameter??e.minViaDiameter??.6,hole_diameter:t.via_hole_diameter??e.minViaHoleDiameter??e.min_via_hole_diameter??.3}}function $hn(t,e){const n=[];for(const a of t.route)a.route_type==="wire"?n.push({...a,layer:a.layer}):a.route_type==="via"?n.push({route_type:"via",x:a.x,y:a.y,from_layer:a.from_layer,to_layer:a.to_layer,...uGi(a,e)}):a.route_type==="through_obstacle"&&n.push({route_type:"through_pad",start:{...a.start},end:{...a.end},width:a.width,start_layer:a.from_layer,end_layer:a.to_layer,pcb_smtpad_id:a.circuitJsonMetadata?.pcb_smtpad_id,pcb_plated_hole_id:a.circuitJsonMetadata?.pcb_plated_hole_id});const o=a=>{let A=-1,c=Number.POSITIVE_INFINITY;return n.forEach((l,u)=>{if(l.route_type!=="wire")return;const g=Math.hypot(l.x-a.x,l.y-a.y);g<c&&(c=g,A=u)}),A},i=t.route.filter(a=>a.route_type==="jumper").map(a=>[o(a.start),o(a.end)].sort((A,c)=>A-c)).filter(([a,A])=>a>=0&&A>a).sort(([a],[A])=>a-A),r=[];let s=0;for(const[a,A]of i)a>=s&&r.push(n.slice(s,a+1)),s=Math.max(s,A);return s<n.length&&r.push(n.slice(s)),r}function gGi(t){const e=[],n=[],o=t.endSimpleRouteJson;if(!o)return{lines:e,circles:n};const i=new Set(jhn(t));for(const r of o.traces??[])if(i.has(r.pcb_trace_id))for(const s of $hn(r,o)){let a;for(const A of s){if(A.route_type==="through_pad"){a={...A.end,layer:A.end_layer,width:A.width};continue}const c=A.route_type==="wire"?A.layer:A.from_layer;a&&a.layer===c&&(a.x!==A.x||a.y!==A.y)&&e.push({points:[{x:a.x,y:a.y},{x:A.x,y:A.y}],strokeWidth:A.route_type==="wire"?A.width:a.width,strokeColor:S$e,layer:c}),A.route_type==="via"&&n.push({center:{x:A.x,y:A.y},radius:A.outer_diameter/2,stroke:S$e,fill:"transparent"}),a={x:A.x,y:A.y,layer:A.route_type==="wire"?A.layer:A.to_layer,width:A.route_type==="wire"?A.width:a?.width??o.minTraceWidth}}}return{coordinateSystem:"cartesian",lines:e,circles:n}}function dGi(t){const e=JSON.stringify(t);let n=2166136261;for(let o=0;o<e.length;o++)n=Math.imul(n^e.charCodeAt(o),16777619);return(n>>>0).toString(36)}const hGi=new Set(["pcb_trace","pcb_via","pcb_copper_pour","pcb_ground_plane","pcb_ground_plane_region","pcb_thermal_spoke","pcb_breakout_point"]);function pGi(t,e,n){const o=n==="input"?e.startSimpleRouteJson??e.errorSimpleRouteJson:e.endSimpleRouteJson,i=t.filter(c=>!hGi.has(c.type)&&!c.type.endsWith("_error")&&!c.type.endsWith("_warning"));if(!o)return i;const r=n==="input"?o.traces??[]:lGi(e),s=new Set(t.filter(c=>c.type==="source_trace").map(c=>c.source_trace_id)),a=["top",...Array.from({length:Math.max(0,o.layerCount-2)},(c,l)=>`inner${l+1}`),...o.layerCount>1?["bottom"]:[]],A=[];for(const c of r){const u=o.connections.find(h=>h.name===c.connection_name||h.source_trace_id===c.connection_name)?.source_trace_id??c.connection_name??"",g=$hn(c,o);for(const[h,d]of g.entries()){const p={type:"pcb_trace",pcb_trace_id:`${e.id}_${n}_${c.pcb_trace_id}_${h}_${dGi(d)}`,subcircuit_id:e.subcircuit_id??void 0,source_trace_id:s.has(u)?u:void 0,route:d};A.push(p);for(const[m,_]of d.entries()){if(_.route_type!=="via")continue;const f=a.indexOf(_.from_layer),I=a.indexOf(_.to_layer),C={type:"pcb_via",pcb_via_id:`${p.pcb_trace_id}_via_${m}`,pcb_trace_id:p.pcb_trace_id,subcircuit_id:e.subcircuit_id??void 0,x:_.x,y:_.y,outer_diameter:_.outer_diameter,hole_diameter:_.hole_diameter,layers:f>=0&&I>=0?a.slice(Math.min(f,I),Math.max(f,I)+1):[_.from_layer,_.to_layer]};A.push(C)}}}return[...i,...A]}const Q$e=(t,e)=>t.phaseName||`Phase ${t.phaseOrdinal??e+1}`,qhn=t=>t.componentDisplayName?.match(/name="([^"]+)"/)?.[1]?.replace(/^\./,"")||t.componentDisplayName||t.subcircuit_id||"Board",Xhn=t=>t.startSimpleRouteJson??t.endSimpleRouteJson??t.errorSimpleRouteJson,mGi={is_showing_autorouting:!0,is_showing_rats_nest:!1,is_showing_drc_errors:!1,is_showing_drc_warnings:!1,is_showing_pcb_groups:!1},_Gi=({circuitJson:t,phases:e=[],isRunning:n=!1})=>{const[o,i]=ee.useState(null),[r,s]=ee.useState("output"),[a,A]=ee.useState(!0),[c,l]=ee.useState(!1),u=ee.useRef(null),[g,h]=ee.useState(480),d=o?e.findIndex(R=>R.id===o.id&&Xhn(R)===Xhn(o)):-1,p=d<0?e.length-1:d,m=e[p],_=d<0,f=!!m?.endSimpleRouteJson,I=m?.startSimpleRouteJson??m?.errorSimpleRouteJson,C=!!I,y=r==="output"&&!f?"input":r==="input"&&!C?"output":r,x=y==="input"?I:m?.endSimpleRouteJson,E=ee.useMemo(()=>!m||!x?null:pGi(t??[],m,y),[t,m,x,y]),B=ee.useMemo(()=>m&&y==="output"&&a?gGi(m):{lines:[],circles:[]},[m,y,a]);if(ee.useLayoutEffect(()=>{const R=u.current;if(!R)return;const F=()=>h(Math.max(360,R.clientHeight));F();const O=new ResizeObserver(F);return O.observe(R),()=>O.disconnect()},[!!m]),!m)return K.jsxs("div",{className:"rf-flex rf-min-h-[400px] rf-flex-col rf-items-center rf-justify-center rf-gap-3 rf-p-8 rf-text-center",children:[K.jsx(oln,{className:"rf-h-7 rf-w-7 rf-text-blue-500"}),K.jsx("h3",{className:"rf-text-base rf-font-medium",children:n?"Waiting for autorouting":"No autorouting captures"}),K.jsx("p",{className:"rf-max-w-md rf-text-sm rf-text-gray-500",children:n?"Phases appear as the circuit routes. Each capture includes its input and output on the PCB.":"Run a circuit with autorouting enabled to inspect its phases. A circuit JSON file alone does not include routing history."})]});const S=Q$e(m,p),Q=m.status==="running"&&n,w=!f,M=I?.connections.length,k=E?.filter(R=>R.type==="pcb_trace").length??0;return K.jsxs("div",{className:"rf-flex rf-h-full rf-min-h-[620px] rf-flex-col rf-bg-white md:rf-flex-row","data-testid":"autorouting-explorer",children:[K.jsxs("aside",{className:"rf-flex rf-shrink-0 rf-flex-col rf-border-b rf-border-gray-200 md:rf-w-52 md:rf-border-b-0 md:rf-border-r","aria-label":"Routing phases",children:[K.jsxs("div",{className:"rf-flex rf-items-center rf-justify-between rf-px-3 rf-py-2 rf-text-xs rf-text-gray-500",children:[K.jsx("span",{children:"Routing phases"}),K.jsx("span",{children:e.length})]}),K.jsx("div",{className:"rf-flex rf-gap-1 rf-overflow-x-auto rf-px-1.5 rf-pb-1.5 md:rf-flex-col md:rf-overflow-x-hidden md:rf-overflow-y-auto",children:e.map((R,F)=>{const O=jhn(R).length,U=R.endSimpleRouteJson?`${O} ${O===1?"trace":"traces"} routed`:R.status==="error"?"Failed":R.status==="running"&&n?"Routing…":"No output";return K.jsxs("button",{type:"button","aria-pressed":F===p,title:`${qhn(R)} · ${U}`,onClick:()=>i(R),className:Hi("rf-flex rf-min-w-[192px] rf-items-start rf-gap-2 rf-rounded-md rf-border rf-px-2 rf-py-2 rf-text-left md:rf-min-w-0",F===p?"rf-border-blue-200 rf-bg-blue-50":"rf-border-transparent hover:rf-bg-gray-50"),children:[K.jsx("span",{className:Hi("rf-flex rf-h-5 rf-w-5 rf-shrink-0 rf-items-center rf-justify-center rf-rounded-full rf-text-[11px]",F===p?"rf-bg-blue-600 rf-text-white":"rf-bg-gray-100 rf-text-gray-500"),children:F+1}),K.jsxs("span",{className:"rf-min-w-0 rf-flex-1",children:[K.jsxs("span",{className:"rf-flex rf-items-center rf-gap-1",children:[K.jsx("span",{className:"rf-min-w-0 rf-flex-1 rf-truncate rf-text-xs rf-font-medium rf-leading-5 rf-text-gray-800",title:Q$e(R,F),children:Q$e(R,F)}),R.status==="complete"?K.jsx(IS,{"aria-label":"Captured",className:"rf-h-3 rf-w-3 rf-shrink-0 rf-text-green-600"}):R.status==="error"?K.jsx(XJe,{"aria-label":"Failed",className:"rf-h-3 rf-w-3 rf-shrink-0 rf-text-red-500"}):n?K.jsx(xE,{"aria-label":"Routing",className:"rf-h-3 rf-w-3 rf-shrink-0 rf-animate-spin rf-text-blue-500"}):null]}),K.jsxs("span",{className:"rf-block rf-text-[11px] rf-leading-4 rf-text-gray-500",children:[cGi(R)," · ",U]})]})]},R.id)})})]}),K.jsxs("div",{className:"rf-flex rf-min-w-0 rf-flex-1 rf-flex-col",children:[K.jsxs("div",{className:"rf-flex rf-flex-wrap rf-items-center rf-gap-3 rf-border-b rf-border-gray-200 rf-px-4 rf-py-3",children:[K.jsxs("h3",{className:"rf-mr-auto rf-flex rf-items-center rf-gap-2 rf-text-sm rf-font-medium",children:[S,K.jsxs("span",{className:"rf-text-xs rf-font-normal rf-text-gray-500",children:[p+1," of ",e.length]})]}),n&&K.jsx("button",{type:"button",onClick:()=>i(null),disabled:_,className:"rf-text-xs rf-text-blue-600 disabled:rf-text-gray-500",children:_?"Following latest":"Follow latest"}),K.jsx("div",{className:"rf-flex rf-rounded-md rf-bg-gray-100 rf-p-1","aria-label":"Phase snapshot",children:["input","output"].map(R=>K.jsx("button",{type:"button","aria-pressed":y===R,disabled:R==="input"?!C:!f,onClick:()=>s(R),className:Hi("rf-rounded rf-px-3 rf-py-1 rf-text-xs disabled:rf-opacity-40",y===R?"rf-bg-white rf-text-gray-900 rf-shadow-sm":"rf-text-gray-500"),children:R==="input"?"Input":"Output"},R))})]}),K.jsxs("div",{className:"rf-flex rf-flex-wrap rf-items-center rf-justify-between rf-gap-2 rf-px-4 rf-py-2 rf-text-xs rf-text-gray-600",children:[K.jsxs("label",{className:"rf-flex rf-items-center rf-gap-2",children:[K.jsx("input",{type:"checkbox",checked:a,disabled:y!=="output",onChange:R=>A(R.target.checked),className:"rf-accent-blue-600"}),K.jsx("span",{"aria-hidden":"true",className:"rf-inline-block rf-h-0.5 rf-w-3",style:{backgroundColor:S$e}}),"Highlight changes (all layers)"]}),K.jsxs("span",{children:[y==="input"?"Before this phase":"After this phase"," ","· ",k," traces"]})]}),w&&K.jsx("div",{className:Hi("rf-border-y rf-px-4 rf-py-2 rf-text-xs",m.status==="error"?"rf-border-red-100 rf-bg-red-50 rf-text-red-700":"rf-border-blue-100 rf-bg-blue-50 rf-text-blue-700"),role:"status",children:m.status==="error"?`Routing failed: ${m.error?.message||"No output was captured."}`:Q?"Routing in progress. Showing captured input until output is available.":"No output was captured for this phase. Showing the available input."}),K.jsx("div",{ref:u,className:"rf-relative rf-min-h-[360px] rf-flex-1","data-testid":"autorouting-pcb",children:E?K.jsx(f$e,{circuitJson:E,height:g,allowEditing:!1,clickToInteractEnabled:!1,initialState:mGi,debugGraphics:B}):K.jsx("div",{className:"rf-p-6 rf-text-sm rf-text-gray-500",children:"No PCB snapshot available for this capture."})}),K.jsxs("div",{className:"rf-flex rf-flex-wrap rf-items-center rf-justify-between rf-gap-2 rf-border-t rf-border-gray-200 rf-px-4 rf-py-3 rf-text-xs rf-text-gray-500",children:[K.jsxs("span",{children:[M===void 0?"Input unavailable":`${M} input connections`,` · ${qhn(m)}`]}),K.jsxs("div",{className:"rf-flex rf-items-center rf-gap-4",children:[K.jsxs("button",{type:"button",disabled:!x,onClick:()=>NE(JSON.stringify(x,null,2),{fileName:`${m.id}-${y}.srj.json`,mimeType:"application/json"}),className:"rf-flex rf-items-center rf-gap-1 disabled:rf-opacity-40",children:[K.jsx(uZ,{className:"rf-h-3 rf-w-3"}),"Download SRJ"]}),K.jsxs("button",{type:"button","aria-expanded":c,onClick:()=>l(!c),className:"rf-flex rf-items-center rf-gap-1",children:[K.jsx(xT,{className:Hi("rf-h-3 rf-w-3",c&&"rf-rotate-90")}),"Inspect SRJ"]})]})]}),c&&K.jsx("pre",{className:"rf-m-0 rf-max-h-64 rf-overflow-auto rf-border-t rf-border-gray-200 rf-bg-gray-50 rf-p-4 rf-text-xs","aria-label":`${S} ${y} SRJ`,children:x?JSON.stringify(x,null,2):"No snapshot captured."})]})]})},Zhn=({errorMessage:t,errorStack:e,circuitJsonErrors:n})=>{ee.useEffect(()=>{if(t){const o=new Error(t);e&&(o.stack=e);try{aG.captureException(o)}catch{}}},[t,e]),ee.useEffect(()=>{if(n&&n.length>0)for(const o of n){const i=new Error(o.message||"Circuit JSON Error");o.stack&&(i.stack=o.stack);try{aG.captureException(i,{error_type:o.type})}catch{}}},[n])},epn=t=>{ee.useEffect(()=>{try{pUo(t)}catch{}},[t.source,t.component,t.isWebEmbedded,t.activeTab])},tpn="0.0.2832",fGi={version:tpn},ufe=AFt()(cFt(t=>({lastRunEvalVersion:void 0,setLastRunEvalVersion:e=>{t({lastRunEvalVersion:e})}}),{name:"runframe-runner-store"})),IGi=t=>{const[e,n]=ee.useState([]),[o,i]=ee.useState(null),[r,s]=ee.useState(""),[a,A]=TO("eval-version-selection",null),c=ufe(h=>h.setLastRunEvalVersion),l=ufe(h=>h.lastRunEvalVersion);return ee.useEffect(()=>{t&&fetch("https://data.jsdelivr.com/v1/package/npm/@tscircuit/eval").then(h=>h.json()).then(h=>{if(Array.isArray(h?.versions)){let d=[...h.versions];h.tags?.latest&&(i(h.tags.latest),d=d.filter(p=>p!==h.tags.latest)),n(d)}}).catch(()=>{})},[t]),ee.useEffect(()=>{t&&(a?(window.TSCIRCUIT_LATEST_EVAL_VERSION=a,c(a)):o&&(window.TSCIRCUIT_LATEST_EVAL_VERSION=o,c(o)))},[t,a,o]),{versions:ee.useMemo(()=>e.filter(h=>h.includes(r)).slice(0,50),[e,r]),latestVersion:o,lastRunEvalVersion:l,search:r,setSearch:s,selectVersion:h=>{A(h),s("")}}},CGi=({snippetNames:t,onSelect:e,onCancel:n,isOpen:o})=>{const[i,r]=ee.useState(""),[s,a]=ee.useState("");if(!o)return null;const A=t.filter(u=>u.toLowerCase().includes(s.toLowerCase())),c=s&&!t.includes(s),l=u=>{u.key==="Enter"&&(A.length===1?r(A[0]):c&&r(s))};return K.jsx("div",{className:"rf-fixed rf-inset-0 rf-bg-black rf-bg-opacity-50 rf-flex rf-items-center rf-justify-center rf-z-[100]",children:K.jsxs("div",{className:"rf-bg-white rf-rounded-lg rf-p-6 rf-w-96",children:[K.jsx("h2",{className:"rf-text-lg rf-font-semibold rf-mb-4",children:"Select Snippet"}),K.jsx("input",{type:"text",className:"rf-w-full rf-px-4 rf-py-2 rf-border rf-rounded rf-mb-4",placeholder:"Search snippets or new snippet name...",value:s,onChange:u=>a(u.target.value),onKeyDown:l}),K.jsxs("div",{className:"rf-h-60 rf-overflow-y-auto",children:[A.map(u=>K.jsx("button",{type:"button",className:`w-full text-left px-4 py-2 rounded hover:bg-gray-100 ${i===u?"bg-blue-50":""}`,onClick:()=>r(u),children:u},u)),c&&K.jsxs("button",{type:"button",className:`w-full text-left px-4 py-2 rounded hover:bg-gray-100 text-blue-500 ${i===s?"bg-blue-50":""}`,onClick:()=>r(s),children:['Create new "',s,'"']})]}),K.jsxs("div",{className:"rf-mt-4 rf-flex rf-justify-end rf-gap-2",children:[K.jsx("button",{type:"button",className:"rf-px-4 rf-py-2 rf-text-gray-600 rf-hover:text-gray-800",onClick:n,children:"Cancel"}),K.jsx("button",{type:"button",className:"rf-px-4 rf-py-2 rf-bg-blue-500 rf-text-white rf-rounded rf-hover:bg-blue-600 rf-disabled:opacity-50",onClick:()=>i&&e(i),disabled:!i,children:i===s?`Create "${i}"`:`Save to ${i}`})]})]})})},yGi=t=>{const e=ee.useRef(null),n=md(o=>o.recentEvents);ee.useEffect(()=>{if(n.length===0)return;const o=n[0];o.event_id!==e.current&&(t(o),e.current=o.event_id)},[n,t])};var xGi=Object.defineProperty,QS=(t,e)=>xGi(t,"name",{value:e,configurable:!0}),EGi="AlertDialog",[BGi,lmr]=Dx(EGi,[v0n]),vS=v0n(),bGi=QS(t=>{const{__scopeAlertDialog:e,...n}=t,o=vS(e);return K.jsx(n_e,{...o,...n,modal:!0})},"AlertDialog");ee.forwardRef(QS(function(e,n){const{__scopeAlertDialog:o,...i}=e,r=vS(o);return K.jsx(zvi,{...r,...i,ref:n})},"AlertDialogTrigger"));var SGi=QS(t=>{const{__scopeAlertDialog:e,...n}=t,o=vS(e);return K.jsx(o_e,{...o,...n})},"AlertDialogPortal"),QGi=ee.forwardRef(QS(function(e,n){const{__scopeAlertDialog:o,...i}=e,r=vS(o);return K.jsx(bZ,{...r,...i,ref:n})},"AlertDialogOverlay")),vGi="AlertDialogContent",[wGi,PGi]=BGi(vGi),MGi=ee.forwardRef(QS(function(e,n){const{__scopeAlertDialog:o,children:i,...r}=e,s=vS(o),a=ee.useRef(null),A=$A(n,a),c=ee.useRef(null);return K.jsx(wGi,{scope:o,cancelRef:c,children:K.jsx(QZ,{role:"alertdialog",...s,...r,ref:A,onOpenAutoFocus:ar(r.onOpenAutoFocus,l=>{l.preventDefault(),c.current?.focus({preventScroll:!0})}),onPointerDownOutside:l=>l.preventDefault(),onInteractOutside:l=>l.preventDefault(),children:i})})},"AlertDialogContent")),DGi=ee.forwardRef(QS(function(e,n){const{__scopeAlertDialog:o,...i}=e,r=vS(o);return K.jsx(i_e,{...r,...i,ref:n})},"AlertDialogTitle")),NGi=ee.forwardRef(QS(function(e,n){const{__scopeAlertDialog:o,...i}=e,r=vS(o);return K.jsx(r_e,{...r,...i,ref:n})},"AlertDialogDescription")),RGi=ee.forwardRef(QS(function(e,n){const{__scopeAlertDialog:o,...i}=e,r=vS(o);return K.jsx(LWe,{...r,...i,ref:n})},"AlertDialogAction")),TGi="AlertDialogCancel",kGi=ee.forwardRef(QS(function(e,n){const{__scopeAlertDialog:o,...i}=e,{cancelRef:r}=PGi(TGi,o),s=vS(o),a=$A(n,r);return K.jsx(LWe,{...s,...i,ref:a})},"AlertDialogCancel")),FGi=bGi,LGi=SGi,npn=QGi,opn=MGi,ipn=RGi,rpn=kGi,spn=DGi,apn=NGi;const Apn=FGi,HGi=LGi,cpn=ee.forwardRef(({className:t,...e},n)=>K.jsx(npn,{className:Hi("rf-fixed rf-inset-0 rf-z-50 rf-bg-black/80 data-[state=open]:rf-animate-in data-[state=closed]:rf-animate-out data-[state=closed]:rf-fade-out-0 data-[state=open]:rf-fade-in-0",t),...e,ref:n}));cpn.displayName=npn.displayName;const v$e=ee.forwardRef(({className:t,...e},n)=>K.jsxs(HGi,{children:[K.jsx(cpn,{}),K.jsx(opn,{ref:n,className:Hi("rf-fixed rf-left-[50%] rf-top-[50%] rf-z-50 rf-grid rf-w-full rf-max-w-lg rf-translate-x-[-50%] rf-translate-y-[-50%] rf-gap-4 rf-border rf-border-zinc-200 rf-bg-white rf-p-6 rf-shadow-lg rf-duration-200 data-[state=open]:rf-animate-in data-[state=closed]:rf-animate-out data-[state=closed]:rf-fade-out-0 data-[state=open]:rf-fade-in-0 data-[state=closed]:rf-zoom-out-95 data-[state=open]:rf-zoom-in-95 data-[state=closed]:rf-slide-out-to-left-1/2 data-[state=closed]:rf-slide-out-to-top-[48%] data-[state=open]:rf-slide-in-from-left-1/2 data-[state=open]:rf-slide-in-from-top-[48%] sm:rf-rounded-lg dark:rf-border-zinc-800 dark:rf-bg-zinc-950",t),...e})]}));v$e.displayName=opn.displayName;const w$e=({className:t,...e})=>K.jsx("div",{className:Hi("rf-flex rf-flex-col rf-space-y-2 rf-text-center sm:rf-text-left",t),...e});w$e.displayName="AlertDialogHeader";const P$e=({className:t,...e})=>K.jsx("div",{className:Hi("rf-flex rf-flex-col-reverse sm:rf-flex-row sm:rf-justify-end sm:rf-space-x-2",t),...e});P$e.displayName="AlertDialogFooter";const M$e=ee.forwardRef(({className:t,...e},n)=>K.jsx(spn,{ref:n,className:Hi("rf-text-lg rf-font-semibold",t),...e}));M$e.displayName=spn.displayName;const D$e=ee.forwardRef(({className:t,...e},n)=>K.jsx(apn,{ref:n,className:Hi("rf-text-sm rf-text-zinc-500 dark:rf-text-zinc-400",t),...e}));D$e.displayName=apn.displayName;const OGi=ee.forwardRef(({className:t,...e},n)=>K.jsx(ipn,{ref:n,className:Hi(rU(),t),...e}));OGi.displayName=ipn.displayName;const N$e=ee.forwardRef(({className:t,...e},n)=>K.jsx(rpn,{ref:n,className:Hi(rU({variant:"outline"}),"rf-mt-2 sm:rf-mt-0",t),...e}));N$e.displayName=rpn.displayName;var GGi=Object.defineProperty,wS=(t,e)=>GGi(t,"name",{value:e,configurable:!0}),R$e="Checkbox",[YGi,umr]=Dx(R$e),[UGi,T$e]=YGi(R$e);function lpn(t){const{__scopeCheckbox:e,checked:n,children:o,defaultChecked:i,disabled:r,form:s,name:a,onCheckedChange:A,required:c,value:l="on",internal_do_not_use_render:u}=t,[g,h]=MB({prop:n,defaultProp:i??!1,onChange:A,caller:R$e}),[d,p]=ee.useState(null),[m,_]=ee.useState(null),f=ee.useRef(!1),[I,C]=ee.useReducer(E=>E+1,0),y=d?!!s||!!d.closest("form"):!0,x={checked:g,disabled:r,setChecked:h,control:d,setControl:p,name:a,form:s,value:l,hasConsumerStoppedPropagationRef:f,userInteractionCount:I,onUserInteraction:C,required:c,defaultChecked:PS(i)?!1:i,isFormControl:y,bubbleInput:m,setBubbleInput:_};return K.jsx(UGi,{scope:e,...x,children:gpn(u)?u(x):o})}wS(lpn,"CheckboxProvider");var KGi="CheckboxTrigger",VGi=ee.forwardRef(wS(function({__scopeCheckbox:e,onKeyDown:n,onClick:o,...i},r){const{control:s,value:a,disabled:A,checked:c,required:l,setControl:u,setChecked:g,hasConsumerStoppedPropagationRef:h,onUserInteraction:d,isFormControl:p,bubbleInput:m}=T$e(KGi,e),_=$A(r,u),f=ee.useRef(c);return ee.useEffect(()=>{const I=s?.form;if(I){const C=wS(()=>g(f.current),"reset");return I.addEventListener("reset",C),()=>I.removeEventListener("reset",C)}},[s,g]),K.jsx(Na.button,{type:"button",role:"checkbox","aria-checked":PS(c)?"mixed":c,"aria-required":l,"data-state":k$e(c),"data-disabled":A?"":void 0,disabled:A,value:a,...i,ref:_,onKeyDown:ar(n,I=>{I.key==="Enter"&&I.preventDefault()}),onClick:ar(o,I=>{d(),g(C=>PS(C)?!0:!C),m&&p&&(h.current=I.isPropagationStopped(),h.current||I.stopPropagation())})})},"CheckboxTrigger")),upn=ee.forwardRef(wS(function(e,n){const{__scopeCheckbox:o,name:i,checked:r,defaultChecked:s,required:a,disabled:A,value:c,onCheckedChange:l,form:u,...g}=e;return K.jsx(lpn,{__scopeCheckbox:o,checked:r,defaultChecked:s,disabled:A,required:a,onCheckedChange:l,name:i,form:u,value:c,internal_do_not_use_render:({isFormControl:h})=>K.jsxs(K.Fragment,{children:[K.jsx(VGi,{...g,ref:n,__scopeCheckbox:o}),h&&K.jsx(jGi,{__scopeCheckbox:o})]})})},"Checkbox")),zGi="CheckboxIndicator",JGi=ee.forwardRef(wS(function(e,n){const{__scopeCheckbox:o,forceMount:i,...r}=e,s=T$e(zGi,o);return K.jsx(cE,{present:i||PS(s.checked)||s.checked===!0,children:K.jsx(Na.span,{"data-state":k$e(s.checked),"data-disabled":s.disabled?"":void 0,...r,ref:n,style:{pointerEvents:"none",...e.style}})})},"CheckboxIndicator")),WGi="CheckboxBubbleInput",jGi=ee.forwardRef(wS(function({__scopeCheckbox:e,onClick:n,...o},i){const{control:r,hasConsumerStoppedPropagationRef:s,userInteractionCount:a,checked:A,defaultChecked:c,required:l,disabled:u,name:g,value:h,form:d,bubbleInput:p,setBubbleInput:m}=T$e(WGi,e),_=$A(i,m),f=yWe(r),I=ee.useRef(!1),C=ee.useRef(A),y=ee.useRef(a);ee.useEffect(()=>{const E=p;if(!E)return;const B=window.HTMLInputElement.prototype,Q=Object.getOwnPropertyDescriptor(B,"checked").set,w=a!==y.current;y.current=a;const M=C.current!==A;C.current=A;const k=!(w&&s.current);if(M&&Q){I.current=!w;const R=new Event("click",{bubbles:k});E.indeterminate=PS(A),Q.call(E,PS(A)?!1:A),E.dispatchEvent(R),I.current=!1}},[p,A,s,a]);const x=ee.useRef(PS(A)?!1:A);return K.jsx(Na.input,{type:"checkbox","aria-hidden":!0,defaultChecked:c??x.current,required:l,disabled:u,name:g,value:h,form:d,...o,tabIndex:-1,ref:_,onClick:ar(n,E=>{I.current&&E.stopPropagation()}),style:{...o.style,...f,position:"absolute",pointerEvents:"none",opacity:0,margin:0,transform:"translateX(-100%)"}})},"CheckboxBubbleInput"));function gpn(t){return typeof t=="function"}wS(gpn,"isFunction");function PS(t){return t==="indeterminate"}wS(PS,"isIndeterminate");function k$e(t){return PS(t)?"indeterminate":t?"checked":"unchecked"}wS(k$e,"getState");const mee=ee.forwardRef(({className:t,...e},n)=>K.jsx(upn,{ref:n,className:Hi("rf-peer rf-h-4 rf-w-4 rf-shrink-0 rf-rounded-sm rf-border rf-border-zinc-200 rf-border-zinc-900 rf-shadow focus-visible:rf-outline-none focus-visible:rf-ring-1 focus-visible:rf-ring-zinc-950 disabled:rf-cursor-not-allowed disabled:rf-opacity-50 data-[state=checked]:rf-bg-zinc-900 data-[state=checked]:rf-text-zinc-50 dark:rf-border-zinc-800 dark:rf-border-zinc-50 dark:focus-visible:rf-ring-zinc-300 dark:data-[state=checked]:rf-bg-zinc-50 dark:data-[state=checked]:rf-text-zinc-900",t),...e,children:K.jsx(JGi,{className:Hi("rf-flex rf-items-center rf-justify-center rf-text-current"),children:K.jsx(IS,{className:"rf-h-4 rf-w-4"})})}));mee.displayName=upn.displayName;const HT=n_e,$Gi=o_e,dpn=ee.forwardRef(({className:t,...e},n)=>K.jsx(bZ,{className:Hi("rf-fixed rf-inset-0 rf-z-50 rf-bg-black/80 data-[state=open]:rf-animate-in data-[state=closed]:rf-animate-out data-[state=closed]:rf-fade-out-0 data-[state=open]:rf-fade-in-0",t),...e,ref:n}));dpn.displayName=bZ.displayName;const YP=ee.forwardRef(({className:t,children:e,showOverlay:n=!0,...o},i)=>K.jsxs($Gi,{children:[K.jsx(dpn,{className:Hi(n?"":"rf-hidden")}),K.jsx(QZ,{ref:i,className:Hi("rf-fixed rf-left-[50%] rf-top-[50%] rf-z-50 rf-grid rf-w-full rf-max-w-lg rf-translate-x-[-50%] rf-translate-y-[-50%] rf-gap-4 rf-border rf-border-zinc-200 rf-bg-white rf-p-6 rf-shadow-lg rf-duration-200 data-[state=open]:rf-animate-in data-[state=closed]:rf-animate-out data-[state=closed]:rf-fade-out-0 data-[state=open]:rf-fade-in-0 data-[state=closed]:rf-zoom-out-95 data-[state=open]:rf-zoom-in-95 data-[state=closed]:rf-slide-out-to-left-1/2 data-[state=closed]:rf-slide-out-to-top-[48%] data-[state=open]:rf-slide-in-from-left-1/2 data-[state=open]:rf-slide-in-from-top-[48%] sm:rf-rounded-lg dark:rf-border-zinc-800 dark:rf-bg-zinc-950",t),...o,children:e})]}));YP.displayName=QZ.displayName;const UP=({className:t,...e})=>K.jsx("div",{className:Hi("rf-flex rf-flex-col rf-space-y-2 rf-text-center sm:rf-text-left",t),...e});UP.displayName="DialogHeader";const UU=({className:t,...e})=>K.jsx("div",{className:Hi("rf-flex rf-flex-col-reverse sm:rf-flex-row sm:rf-justify-end sm:rf-space-x-2",t),...e});UU.displayName="DialogFooter";const KP=ee.forwardRef(({className:t,...e},n)=>K.jsx(i_e,{ref:n,className:Hi("rf-text-lg rf-font-semibold",t),...e}));KP.displayName=i_e.displayName;const OT=ee.forwardRef(({className:t,...e},n)=>K.jsx(r_e,{ref:n,className:Hi("rf-text-sm rf-text-zinc-500 dark:rf-text-zinc-400",t),...e}));OT.displayName=r_e.displayName;const gfe={"tscircuit.com":{label:"tscircuit.com",placeholder:"Search tscircuit packages...",emptyMessage:"No packages found"},jlcpcb:{label:"JLCPCB Parts",placeholder:"Search JLCPCB parts (e.g. C14663)...",emptyMessage:"No parts found"},kicad:{label:"KiCad Footprints",placeholder:"Search KiCad footprints...",emptyMessage:"No footprints found"}},qGi="https://cdn.jsdelivr.net/npm/easyeda@latest/dist/browser/index.js";let F$e=null;const L$e=async()=>(F$e||(F$e=import(qGi)),F$e),XGi=t=>(e,n)=>{const o=new Headers(n?.headers),i={};return o.forEach((r,s)=>{i[s]=r}),fetch(`${t?.apiBase??QC}/proxy`,{...n,headers:{...i,"X-Target-Url":e.toString(),"X-Sender-Origin":i.origin??"","X-Sender-Host":i.host??"https://easyeda.com","X-Sender-Referer":i.referer??"","X-Sender-User-Agent":i["user-agent"]??"","X-Sender-Cookie":i.cookie??"",authority:i.authority??"","content-type":i["content-type"]??"",...t?.headers}})},ZGi=async(t,e=10)=>{const n=encodeURIComponent(t),o=await fetch(`https://jlcsearch.tscircuit.com/api/search?limit=${e}&q=${n}`);if(!o.ok)throw new Error(`JLCPCB API error: ${o.status}`);return(await o.json()).components??[]},eYi=t=>({lcscId:t.lcsc,manufacturer:t.mfr,description:t.description,partNumber:`C${t.lcsc}`,package:t.package,price:t.price,stock:t.stock,isBasic:t.is_basic}),hpn=async(t,e)=>{const{fetchEasyEDAComponent:n}=await L$e();return n(t,{fetch:XGi(e),includeModelMetadata:e?.includeModelMetadata})},tYi=async(t,e)=>{const{convertRawEasyToTsx:n}=await L$e(),o=await hpn(t,e);return n({rawEasy:o})},nYi=async(t,e)=>{const{EasyEdaJsonSchema:n,convertEasyEdaJsonToCircuitJson:o}=await L$e(),i=await hpn(t,{...e,includeModelMetadata:!1}),r=n.parse(i);return o(r,{shouldRecenter:!0,showDesignator:!0,useModelCdn:!1})};function VP(t){return Array.isArray?Array.isArray(t):mpn(t)==="[object Array]"}function oYi(t){if(typeof t=="string")return t;if(typeof t=="bigint")return t.toString();const e=t+"";return e=="0"&&1/t==-1/0?"-0":e}function H$e(t){return t==null?"":oYi(t)}function RC(t){return typeof t=="string"}function dfe(t){return typeof t=="number"}function iYi(t){return t===!0||t===!1||rYi(t)&&mpn(t)=="[object Boolean]"}function ppn(t){return typeof t=="object"}function rYi(t){return ppn(t)&&t!==null}function RE(t){return t!=null}function hfe(t){return!t.trim().length}function mpn(t){return t==null?t===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(t)}const sYi="Incorrect 'index' type",O$e="Invalid doc index: must be a non-negative integer within the bounds of the docs array",aYi=t=>`Invalid value for key ${t}`,AYi=t=>`Pattern length exceeds max of ${t}.`,cYi=t=>`Missing ${t} property in key`,lYi=t=>`Property 'weight' in key '${t}' must be a positive integer`,uYi="Fuse.match does not support useTokenSearch: token search requires corpus-level statistics (df, fieldCount) that a one-off string comparison does not have. Use new Fuse(...).search(...) instead.",_pn=Object.prototype.hasOwnProperty;var gYi=class{constructor(t){this._keys=[],this._keyMap={};let e=0;t.forEach(n=>{const o=fpn(n);this._keys.push(o),this._keyMap[o.id]=o,e+=o.weight}),this._keys.forEach(n=>{n.weight/=e})}get(t){return this._keyMap[t]}keys(){return this._keys}toJSON(){return JSON.stringify(this._keys)}};function fpn(t){let e=null,n=null,o=null,i=1,r=null;if(RC(t)||VP(t))o=t,e=Ipn(t),n=pfe(t);else{if(!_pn.call(t,"name"))throw new Error(cYi("name"));const s=t.name;if(o=s,_pn.call(t,"weight")&&t.weight!==void 0&&(i=t.weight,i<=0))throw new Error(lYi(pfe(s)));e=Ipn(s),n=pfe(s),r=t.getFn??null}return{path:e,id:n,weight:i,src:o,getFn:r}}function Ipn(t){return VP(t)?t:t.split(".")}function pfe(t){return VP(t)?t.join("."):t}function dYi(t,e){const n=[];let o=!1;const i=(r,s,a,A)=>{if(RE(r))if(!s[a])n.push(A!==void 0?{v:r,i:A}:r);else{const c=r[s[a]];if(!RE(c))return;if(a===s.length-1&&(RC(c)||dfe(c)||iYi(c)||typeof c=="bigint"))n.push(A!==void 0?{v:H$e(c),i:A}:H$e(c));else if(VP(c)){o=!0;for(let l=0,u=c.length;l<u;l+=1)i(c[l],s,a+1,l)}else s.length&&i(c,s,a+1,A)}};return i(t,RC(e)?e.split("."):e,0),o?n:n[0]}const wa=Object.freeze({...{isCaseSensitive:!1,ignoreDiacritics:!1,includeScore:!1,keys:[],shouldSort:!0,sortFn:(t,e)=>t.score===e.score?t.idx<e.idx?-1:1:t.score<e.score?-1:1},...{includeMatches:!1,findAllMatches:!1,minMatchCharLength:1},...{location:0,threshold:.6,distance:100},...{useExtendedSearch:!1,useTokenSearch:!1,tokenize:void 0,tokenMatch:"any",getFn:dYi,ignoreLocation:!1,ignoreFieldNorm:!1,fieldNormWeight:1}});function hYi(t){return t>=9&&t<=13||t===32||t===160}function pYi(t=1,e=3){const n=new Map,o=Math.pow(10,e);return{get(i){let r=0,s=!1;for(let A=0;A<i.length;A++)hYi(i.charCodeAt(A))?s=!1:s||(r++,s=!0);if(r===0&&(r=1),n.has(r))return n.get(r);const a=Math.round(o/Math.pow(r,.5*t))/o;return n.set(r,a),a},clear(){n.clear()}}}var G$e=class{constructor({getFn:t=wa.getFn,fieldNormWeight:e=wa.fieldNormWeight}={}){this.norm=pYi(e,3),this.getFn=t,this.isCreated=!1,this.docs=[],this.keys=[],this._keysMap={},this.setIndexRecords()}setSources(t=[]){this.docs=t}setIndexRecords(t=[]){this.records=t}setKeys(t=[]){this.keys=t,this._keysMap={},t.forEach((e,n)=>{this._keysMap[e.id]=n})}create(){if(this.isCreated||!this.docs.length)return;this.isCreated=!0;const t=this.docs.length;this.records=new Array(t);let e=0;if(RC(this.docs[0]))for(let n=0;n<t;n++){const o=this._createStringRecord(this.docs[n],n);o&&(this.records[e++]=o)}else for(let n=0;n<t;n++)this.records[e++]=this._createObjectRecord(this.docs[n],n);this.records.length=e,this.norm.clear()}add(t,e){if(!Number.isInteger(e)||e<0)throw new Error(O$e);if(RC(t)){const o=this._createStringRecord(t,e);return o&&this.records.push(o),o}const n=this._createObjectRecord(t,e);return this.records.push(n),n}removeAt(t){if(!Number.isInteger(t)||t<0)throw new Error(O$e);for(let e=0,n=this.records.length;e<n;e+=1)if(this.records[e].i===t){this.records.splice(e,1);break}for(let e=0,n=this.records.length;e<n;e+=1)this.records[e].i>t&&(this.records[e].i-=1)}removeAll(t){const e=new Set;for(const o of t)Number.isInteger(o)&&o>=0&&e.add(o);if(e.size===0)return;this.records=this.records.filter(o=>!e.has(o.i));const n=Array.from(e).sort((o,i)=>o-i);for(const o of this.records){let i=0,r=n.length;for(;i<r;){const s=i+r>>>1;n[s]<o.i?i=s+1:r=s}o.i-=i}}getValueForItemAtKeyId(t,e){return t[this._keysMap[e]]}size(){return this.records.length}_createStringRecord(t,e){return!RE(t)||hfe(t)?null:{v:t,i:e,n:this.norm.get(t)}}_createObjectRecord(t,e){const n={i:e,$:{}};for(let o=0,i=this.keys.length;o<i;o++){const r=this.keys[o],s=r.getFn?r.getFn(t):this.getFn(t,r.path);if(RE(s)){if(VP(s)){const a=[];for(let A=0,c=s.length;A<c;A+=1){const l=s[A];if(RE(l)){if(RC(l)){if(!hfe(l)){const u={v:l,i:A,n:this.norm.get(l)};a.push(u)}}else if(RE(l.v)){const u=RC(l.v)?l.v:H$e(l.v);if(!hfe(u)){const g={v:u,i:l.i,n:this.norm.get(u)};a.push(g)}}}}n.$[o]=a}else if(RC(s)&&!hfe(s)){const a={v:s,n:this.norm.get(s)};n.$[o]=a}}}return n}toJSON(){return{keys:this.keys.map(({getFn:t,...e})=>e),records:this.records}}};function Cpn(t,e,{getFn:n=wa.getFn,fieldNormWeight:o=wa.fieldNormWeight}={}){const i=new G$e({getFn:n,fieldNormWeight:o});return i.setKeys(t.map(fpn)),i.setSources(e),i.create(),i}function mYi(t,{getFn:e=wa.getFn,fieldNormWeight:n=wa.fieldNormWeight}={}){const{keys:o,records:i}=t,r=new G$e({getFn:e,fieldNormWeight:n});return r.setKeys(o),r.setIndexRecords(i),r}function _Yi(t=[],e=wa.minMatchCharLength){const n=[];let o=-1,i=-1,r=0;for(let s=t.length;r<s;r+=1){const a=t[r];a&&o===-1?o=r:!a&&o!==-1&&(i=r-1,i-o+1>=e&&n.push([o,i]),o=-1)}return t[r-1]&&r-o>=e&&n.push([o,r-1]),n}function fYi(t,e,n,{location:o=wa.location,distance:i=wa.distance,threshold:r=wa.threshold,findAllMatches:s=wa.findAllMatches,minMatchCharLength:a=wa.minMatchCharLength,includeMatches:A=wa.includeMatches,ignoreLocation:c=wa.ignoreLocation}={}){if(e.length>32)throw new Error(AYi(32));const l=e.length,u=t.length,g=Math.max(0,Math.min(o,u));let h=r,d=g;const p=(S,Q)=>{const w=S/l;if(c)return w;const M=Math.abs(g-Q);return i?w+M/i:M?1:w},m=a>1||A,_=m?Array(u):[];let f;for(;(f=t.indexOf(e,d))>-1;){const S=p(0,f);if(h=Math.min(S,h),d=f+l,m){let Q=0;for(;Q<l;)_[f+Q]=1,Q+=1}}d=-1;let I=[],C=1,y=0,x=l+u;const E=1<<l-1;for(let S=0;S<l;S+=1){let Q=0,w=x;for(;Q<w;)p(S,g+w)<=h?Q=w:x=w,w=Math.floor((x-Q)/2+Q);x=w;let M=Math.max(1,g-w+1);const k=s?u:Math.min(g+w,u)+l,R=Array(k+2);R[k+1]=(1<<S)-1;for(let F=k;F>=M;F-=1){const O=F-1,U=n[t[O]];if(R[F]=(R[F+1]<<1|1)&U,S&&(R[F]|=(I[F+1]|I[F])<<1|1|I[F+1]),R[F]&E&&(C=p(S,O),C<=h)){if(h=C,d=O,y=S,d<=g)break;M=Math.max(1,2*g-d)}}if(p(S+1,g)>h)break;I=R}if(m&&d>=0){const S=Math.min(u-1,d+l-1+y);for(let Q=d;Q<=S;Q+=1)n[t[Q]]&&(_[Q]=1)}const B={isMatch:d>=0,score:Math.max(.001,C)};if(m){const S=_Yi(_,a);S.length?A&&(B.indices=S):B.isMatch=!1}return B}function IYi(t){const e={};for(let n=0,o=t.length;n<o;n+=1){const i=t.charAt(n);e[i]=(e[i]||0)|1<<o-n-1}return e}function Y$e(t){if(t.length<=1)return t;t.sort((n,o)=>n[0]-o[0]||n[1]-o[1]);const e=[t[0]];for(let n=1,o=t.length;n<o;n+=1){const i=e[e.length-1],r=t[n];r[0]<=i[1]+1?i[1]=Math.max(i[1],r[1]):e.push(r)}return e}const ypn={ł:"l",Ł:"L",đ:"d",Đ:"D",ø:"o",Ø:"O",ħ:"h",Ħ:"H",ŧ:"t",Ŧ:"T",ı:"i",ß:"ss"},CYi=new RegExp("["+Object.keys(ypn).join("")+"]","g"),_ee=typeof String.prototype.normalize=="function"?t=>t.normalize("NFD").replace(/[\u0300-\u036F\u0483-\u0489\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u0610-\u061A\u064B-\u065F\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED\u0711\u0730-\u074A\u07A6-\u07B0\u07EB-\u07F3\u07FD\u0816-\u0819\u081B-\u0823\u0825-\u0827\u0829-\u082D\u0859-\u085B\u08D3-\u08E1\u08E3-\u0903\u093A-\u093C\u093E-\u094F\u0951-\u0957\u0962\u0963\u0981-\u0983\u09BC\u09BE-\u09C4\u09C7\u09C8\u09CB-\u09CD\u09D7\u09E2\u09E3\u09FE\u0A01-\u0A03\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A70\u0A71\u0A75\u0A81-\u0A83\u0ABC\u0ABE-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AE2\u0AE3\u0AFA-\u0AFF\u0B01-\u0B03\u0B3C\u0B3E-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B62\u0B63\u0B82\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD7\u0C00-\u0C04\u0C3E-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C62\u0C63\u0C81-\u0C83\u0CBC\u0CBE-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CE2\u0CE3\u0D00-\u0D03\u0D3B\u0D3C\u0D3E-\u0D44\u0D46-\u0D48\u0D4A-\u0D4D\u0D57\u0D62\u0D63\u0D82\u0D83\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DF2\u0DF3\u0E31\u0E34-\u0E3A\u0E47-\u0E4E\u0EB1\u0EB4-\u0EB9\u0EBB\u0EBC\u0EC8-\u0ECD\u0F18\u0F19\u0F35\u0F37\u0F39\u0F3E\u0F3F\u0F71-\u0F84\u0F86\u0F87\u0F8D-\u0F97\u0F99-\u0FBC\u0FC6\u102B-\u103E\u1056-\u1059\u105E-\u1060\u1062-\u1064\u1067-\u106D\u1071-\u1074\u1082-\u108D\u108F\u109A-\u109D\u135D-\u135F\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17B4-\u17D3\u17DD\u180B-\u180D\u1885\u1886\u18A9\u1920-\u192B\u1930-\u193B\u1A17-\u1A1B\u1A55-\u1A5E\u1A60-\u1A7C\u1A7F\u1AB0-\u1ABE\u1B00-\u1B04\u1B34-\u1B44\u1B6B-\u1B73\u1B80-\u1B82\u1BA1-\u1BAD\u1BE6-\u1BF3\u1C24-\u1C37\u1CD0-\u1CD2\u1CD4-\u1CE8\u1CED\u1CF2-\u1CF4\u1CF7-\u1CF9\u1DC0-\u1DF9\u1DFB-\u1DFF\u20D0-\u20F0\u2CEF-\u2CF1\u2D7F\u2DE0-\u2DFF\u302A-\u302F\u3099\u309A\uA66F-\uA672\uA674-\uA67D\uA69E\uA69F\uA6F0\uA6F1\uA802\uA806\uA80B\uA823-\uA827\uA880\uA881\uA8B4-\uA8C5\uA8E0-\uA8F1\uA8FF\uA926-\uA92D\uA947-\uA953\uA980-\uA983\uA9B3-\uA9C0\uA9E5\uAA29-\uAA36\uAA43\uAA4C\uAA4D\uAA7B-\uAA7D\uAAB0\uAAB2-\uAAB4\uAAB7\uAAB8\uAABE\uAABF\uAAC1\uAAEB-\uAAEF\uAAF5\uAAF6\uABE3-\uABEA\uABEC\uABED\uFB1E\uFE00-\uFE0F\uFE20-\uFE2F]/g,"").replace(CYi,e=>ypn[e]):t=>t;var U$e=class{constructor(t,{location:e=wa.location,threshold:n=wa.threshold,distance:o=wa.distance,includeMatches:i=wa.includeMatches,findAllMatches:r=wa.findAllMatches,minMatchCharLength:s=wa.minMatchCharLength,isCaseSensitive:a=wa.isCaseSensitive,ignoreDiacritics:A=wa.ignoreDiacritics,ignoreLocation:c=wa.ignoreLocation}={}){if(this.options={location:e,threshold:n,distance:o,includeMatches:i,findAllMatches:r,minMatchCharLength:s,isCaseSensitive:a,ignoreDiacritics:A,ignoreLocation:c},t=a?t:t.toLowerCase(),t=A?_ee(t):t,this.pattern=t,this.chunks=[],!this.pattern.length)return;const l=(g,h)=>{this.chunks.push({pattern:g,alphabet:IYi(g),startIndex:h})},u=this.pattern.length;if(u>32){let g=0;const h=u%32,d=u-h;for(;g<d;)l(this.pattern.substr(g,32),g),g+=32;if(h){const p=u-32;l(this.pattern.substr(p),p)}}else l(this.pattern,0)}searchIn(t){const{isCaseSensitive:e,ignoreDiacritics:n,includeMatches:o}=this.options;if(t=e?t:t.toLowerCase(),t=n?_ee(t):t,this.pattern===t){if(t.length<this.options.minMatchCharLength)return{isMatch:!1,score:1};const d={isMatch:!0,score:0};return o&&(d.indices=[[0,t.length-1]]),d}const{location:i,distance:r,threshold:s,findAllMatches:a,minMatchCharLength:A,ignoreLocation:c}=this.options,l=[];let u=0,g=!1;this.chunks.forEach(({pattern:d,alphabet:p,startIndex:m})=>{const{isMatch:_,score:f,indices:I}=fYi(t,d,p,{location:i+m,distance:r,threshold:s,findAllMatches:a,minMatchCharLength:A,includeMatches:o,ignoreLocation:c});_&&(g=!0),u+=f,_&&I&&l.push(...I)});const h={isMatch:g,score:g?u/this.chunks.length:1};return g&&o&&(h.indices=Y$e(l)),h}};const yYi=new Set(["fuzzy","include"]);function xYi(t){return t.startsWith("inverse")}const K$e=[{type:"exact",multiRegex:/^="(.*)"$/,singleRegex:/^=(.*)$/,create:t=>({type:"exact",search(e){const n=e===t;return{isMatch:n,score:n?0:1,indices:[0,t.length-1]}}})},{type:"include",multiRegex:/^'"(.*)"$/,singleRegex:/^'(.*)$/,create:t=>({type:"include",search(e){let n=0,o;const i=[],r=t.length;for(;(o=e.indexOf(t,n))>-1;)n=o+r,i.push([o,n-1]);const s=!!i.length;return{isMatch:s,score:s?0:1,indices:i}}})},{type:"prefix-exact",multiRegex:/^\^"(.*)"$/,singleRegex:/^\^(.*)$/,create:t=>({type:"prefix-exact",search(e){const n=e.startsWith(t);return{isMatch:n,score:n?0:1,indices:[0,t.length-1]}}})},{type:"inverse-prefix-exact",multiRegex:/^!\^"(.*)"$/,singleRegex:/^!\^(.*)$/,create:t=>({type:"inverse-prefix-exact",search(e){const n=!e.startsWith(t);return{isMatch:n,score:n?0:1,indices:[0,e.length-1]}}})},{type:"inverse-suffix-exact",multiRegex:/^!"(.*)"\$$/,singleRegex:/^!(.*)\$$/,create:t=>({type:"inverse-suffix-exact",search(e){const n=!e.endsWith(t);return{isMatch:n,score:n?0:1,indices:[0,e.length-1]}}})},{type:"suffix-exact",multiRegex:/^"(.*)"\$$/,singleRegex:/^(.*)\$$/,create:t=>({type:"suffix-exact",search(e){const n=e.endsWith(t);return{isMatch:n,score:n?0:1,indices:[e.length-t.length,e.length-1]}}})},{type:"inverse-exact",multiRegex:/^!"(.*)"$/,singleRegex:/^!(.*)$/,create:t=>({type:"inverse-exact",search(e){const n=e.indexOf(t)===-1;return{isMatch:n,score:n?0:1,indices:[0,e.length-1]}}})},{type:"fuzzy",multiRegex:/^"(.*)"$/,singleRegex:/^(.*)$/,create:(t,e={})=>{const n=new U$e(t,{location:e.location??wa.location,threshold:e.threshold??wa.threshold,distance:e.distance??wa.distance,includeMatches:e.includeMatches??wa.includeMatches,findAllMatches:e.findAllMatches??wa.findAllMatches,minMatchCharLength:e.minMatchCharLength??wa.minMatchCharLength,isCaseSensitive:e.isCaseSensitive??wa.isCaseSensitive,ignoreDiacritics:e.ignoreDiacritics??wa.ignoreDiacritics,ignoreLocation:e.ignoreLocation??wa.ignoreLocation});return{type:"fuzzy",search(o){return n.searchIn(o)}}}}],xpn=K$e.length,EYi="\0",BYi="|";function bYi(t){const e=[],n=t.length;let o=0;for(;o<n;){for(;o<n&&t[o]===" ";)o++;if(o>=n)break;let i=o;for(;i<n&&t[i]!==" "&&t[i]!=='"';)i++;if(i<n&&t[i]==='"'){for(i++;i<n;){if(t[i]==='"'){const r=i+1;if(r>=n||t[r]===" "){i++;break}if(t[r]==="$"&&(r+1>=n||t[r+1]===" ")){i+=2;break}}i++}e.push(t.substring(o,i)),o=i}else{for(;i<n&&t[i]!==" ";)i++;e.push(t.substring(o,i)),o=i}}return e}function Epn(t,e){const n=t.match(e);return n?n[1]:null}function SYi(t,e={}){return t.replace(/\\\|/g,EYi).split(BYi).map(n=>{const o=bYi(n.replace(/\u0000/g,"|").trim()).filter(r=>r&&!!r.trim()),i=[];for(let r=0,s=o.length;r<s;r+=1){const a=o[r];let A=!1,c=-1;for(;!A&&++c<xpn;){const l=K$e[c],u=Epn(a,l.multiRegex);u&&(i.push(l.create(u,e)),A=!0)}if(!A)for(c=-1;++c<xpn;){const l=K$e[c],u=Epn(a,l.singleRegex);if(u){i.push(l.create(u,e));break}}}return i})}var QYi=class{constructor(t,{isCaseSensitive:e=wa.isCaseSensitive,ignoreDiacritics:n=wa.ignoreDiacritics,includeMatches:o=wa.includeMatches,minMatchCharLength:i=wa.minMatchCharLength,ignoreLocation:r=wa.ignoreLocation,findAllMatches:s=wa.findAllMatches,location:a=wa.location,threshold:A=wa.threshold,distance:c=wa.distance}={}){this.query=null,this.options={isCaseSensitive:e,ignoreDiacritics:n,includeMatches:o,minMatchCharLength:i,findAllMatches:s,ignoreLocation:r,location:a,threshold:A,distance:c},t=e?t:t.toLowerCase(),t=n?_ee(t):t,this.pattern=t,this.query=SYi(this.pattern,this.options)}static condition(t,e){return e.useExtendedSearch}searchIn(t){const e=this.query;if(!e)return{isMatch:!1,score:1};const{includeMatches:n,isCaseSensitive:o,ignoreDiacritics:i}=this.options;t=o?t:t.toLowerCase(),t=i?_ee(t):t;let r=0;const s=[];let a=0,A=!1;for(let c=0,l=e.length;c<l;c+=1){const u=e[c];s.length=0,r=0,A=!1;for(let g=0,h=u.length;g<h;g+=1){const d=u[g],{isMatch:p,indices:m,score:_}=d.search(t);if(p)r+=1,a+=_,xYi(d.type)&&(A=!0),n&&(yYi.has(d.type)?s.push(...m):s.push(m));else{a=0,r=0,s.length=0,A=!1;break}}if(r){const g={isMatch:!0,score:a/r};return A&&(g.hasInverse=!0),n&&(g.indices=Y$e(s)),g}}return{isMatch:!1,score:1}}};const V$e=[];function z$e(...t){V$e.push(...t)}function mfe(t,e){for(let n=0,o=V$e.length;n<o;n+=1){const i=V$e[n];if(i.condition(t,e))return new i(t,e)}return new U$e(t,e)}const _fe={AND:"$and",OR:"$or"},J$e={PATH:"$path",PATTERN:"$val"},W$e=t=>!!(t[_fe.AND]||t[_fe.OR]),vYi=t=>!!t[J$e.PATH],wYi=t=>!VP(t)&&ppn(t)&&!W$e(t),Bpn=t=>({[_fe.AND]:Object.keys(t).map(e=>({[e]:t[e]}))});function bpn(t,e,{auto:n=!0}={}){const o=i=>{if(RC(i)){const A={keyId:null,pattern:i};return n&&(A.searcher=mfe(i,e)),A}const r=Object.keys(i),s=vYi(i);if(!s&&r.length>1&&!W$e(i))return o(Bpn(i));if(wYi(i)){const A=s?i[J$e.PATH]:r[0],c=s?i[J$e.PATTERN]:i[A];if(!RC(c))throw new Error(aYi(A));const l={keyId:pfe(A),pattern:c};return n&&(l.searcher=mfe(c,e)),l}const a={children:[],operator:r[0]};return r.forEach(A=>{const c=i[A];VP(c)&&c.forEach(l=>{a.children.push(o(l))})}),a};return W$e(t)||(t=Bpn(t)),o(t)}function j$e(t,{ignoreFieldNorm:e=wa.ignoreFieldNorm}){let n=1;return t.forEach(({key:o,norm:i,score:r})=>{const s=o?o.weight:null;n*=Math.pow(r===0&&s?Number.EPSILON:r,(s||1)*(e?1:i))}),n}function PYi(t,{ignoreFieldNorm:e=wa.ignoreFieldNorm}){t.forEach(n=>{n.score=j$e(n.matches,{ignoreFieldNorm:e})})}var MYi=class{constructor(t,e){this.limit=t,this.heap=[],this.comparator=e}get size(){return this.heap.length}insert(t){this.size<this.limit?(this.heap.push(t),this._bubbleUp(this.size-1)):this.comparator(t,this.heap[0])<0&&(this.heap[0]=t,this._sinkDown(0))}extractSorted(){return this.heap.sort(this.comparator)}_bubbleUp(t){const e=this.heap;for(;t>0;){const n=t-1>>1;if(this.comparator(e[t],e[n])<=0)break;const o=e[t];e[t]=e[n],e[n]=o,t=n}}_sinkDown(t){const e=this.heap,n=e.length;let o=t;do{t=o;const i=2*t+1,r=2*t+2;if(i<n&&this.comparator(e[i],e[o])>0&&(o=i),r<n&&this.comparator(e[r],e[o])>0&&(o=r),o!==t){const s=e[t];e[t]=e[o],e[o]=s}}while(o!==t)}};function DYi(t){const e=[];return t.matches.forEach(n=>{if(!RE(n.indices)||!n.indices.length)return;const o={indices:n.indices,value:n.value};n.key&&(o.key=n.key.id),n.idx>-1&&(o.refIndex=n.idx),e.push(o)}),e}function NYi(t,e,{includeMatches:n=wa.includeMatches,includeScore:o=wa.includeScore}={}){return t.map(i=>{const{idx:r}=i,s={item:e[r],refIndex:r};return n&&(s.matches=DYi(i)),o&&(s.score=i.score),s})}const RYi=/[\p{L}\p{M}\p{N}_]+/gu,Spn=new WeakSet;function TYi(t){Spn.has(t)||(Spn.add(t),console.warn(`[Fuse] tokenize regex ${t} lacks the global flag; only the first match per text will be returned. Add the 'g' flag.`))}function kYi(t){if(typeof t=="function"){let e=!1;return n=>{const o=t(n);if(!e&&(e=!0,!Array.isArray(o)||o.some(i=>typeof i!="string")))throw new Error(`[Fuse] tokenize function must return string[]; received ${Array.isArray(o)?"array containing non-strings":typeof o}.`);return o}}return t instanceof RegExp?(t.global||TYi(t),e=>e.match(t)||[]):e=>e.match(RYi)||[]}function $$e({isCaseSensitive:t=!1,ignoreDiacritics:e=!1,tokenize:n}={}){const o=kYi(n);return{tokenize(i){return t||(i=i.toLowerCase()),e&&(i=_ee(i)),o(i)}}}var FYi=class{static condition(t,e){return e.useTokenSearch}constructor(t,e){this.options=e,this.analyzer=$$e({isCaseSensitive:e.isCaseSensitive,ignoreDiacritics:e.ignoreDiacritics,tokenize:e.tokenize});const n=this.analyzer.tokenize(t),{df:o,fieldCount:i}=e._invertedIndex;this.termSearchers=[],this.idfWeights=[];for(const r of n){this.termSearchers.push(new U$e(r,{location:e.location,threshold:e.threshold,distance:e.distance,includeMatches:e.includeMatches,findAllMatches:e.findAllMatches,minMatchCharLength:e.minMatchCharLength,isCaseSensitive:e.isCaseSensitive,ignoreDiacritics:e.ignoreDiacritics,ignoreLocation:!0}));const s=o.get(r)||0,a=Math.log(1+(i-s+.5)/(s+.5));this.idfWeights.push(a)}this.combineAll=e.tokenMatch==="all",this.numTerms=this.termSearchers.length,this.useMask=this.numTerms<=31}searchIn(t){if(!this.termSearchers.length)return{isMatch:!1,score:1};const e=[];let n=0,o=0,i=0,r=0;const s=this.combineAll&&!this.useMask?new Set:null;for(let c=0;c<this.termSearchers.length;c++){const l=this.termSearchers[c].searchIn(t),u=this.idfWeights[c];o+=u,l.isMatch&&(i++,n+=u*(1-l.score),l.indices&&e.push(...l.indices),this.combineAll&&(this.useMask?r|=1<<c:s.add(c)))}if(i===0)return{isMatch:!1,score:1};const a=o>0?1-n/o:0,A={isMatch:!0,score:Math.max(.001,a)};return this.options.includeMatches&&e.length&&(A.indices=Y$e(e)),this.combineAll&&(this.useMask?A.matchedMask=r:A.matchedTerms=s,A.termCount=this.numTerms),A}};function q$e(t,e,n,o){const i=o.tokenize(e);if(!i.length)return;t.fieldCount++,t.docFieldCount.set(n,(t.docFieldCount.get(n)||0)+1);const r=new Set(i);let s=t.docTermFieldHits.get(n);s||(s=new Map,t.docTermFieldHits.set(n,s));for(const a of r)s.set(a,(s.get(a)||0)+1),t.df.set(a,(t.df.get(a)||0)+1)}function Qpn(t,e,n,o){const{i,v:r,$:s}=e;if(r!==void 0){q$e(t,r,i,o);return}if(s)for(let a=0;a<n;a++){const A=s[a];if(A)if(Array.isArray(A))for(const c of A)q$e(t,c.v,i,o);else q$e(t,A.v,i,o)}}function LYi(t,e,n){const o={fieldCount:0,df:new Map,docFieldCount:new Map,docTermFieldHits:new Map};for(const i of t)Qpn(o,i,e,n);return o}function HYi(t,e,n,o){Qpn(t,e,n,o)}function OYi(t,e){const n=t.docFieldCount.get(e);if(n===void 0)return;t.fieldCount-=n,t.docFieldCount.delete(e);const o=t.docTermFieldHits.get(e);if(o){for(const[i,r]of o){const s=(t.df.get(i)||0)-r;s<=0?t.df.delete(i):t.df.set(i,s)}t.docTermFieldHits.delete(e)}}function vpn(t,e){if(e.length===0)return;const n=Array.from(new Set(e)).sort((a,A)=>a-A);for(const a of n)OYi(t,a);const o=a=>{let A=0,c=n.length;for(;A<c;){const l=A+c>>>1;n[l]<a?A=l+1:c=l}return a-A},i=n[0],r=new Map;for(const[a,A]of t.docFieldCount)r.set(a>i?o(a):a,A);t.docFieldCount=r;const s=new Map;for(const[a,A]of t.docTermFieldHits)s.set(a>i?o(a):a,A);t.docTermFieldHits=s}var zP=class{constructor(t,e,n){this.options={...wa,...e},this.options.useExtendedSearch,this.options.useTokenSearch,this._keyStore=new gYi(this.options.keys),this._docs=t,this._myIndex=null,this._invertedIndex=null,this.setCollection(t,n),this._lastQuery=null,this._lastSearcher=null}_getSearcher(t){if(this._lastQuery===t)return this._lastSearcher;const e=mfe(t,this._invertedIndex?{...this.options,_invertedIndex:this._invertedIndex}:this.options);return this._lastQuery=t,this._lastSearcher=e,e}setCollection(t,e){if(this._docs=t,e&&!(e instanceof G$e))throw new Error(sYi);if(this._myIndex=e||Cpn(this.options.keys,this._docs,{getFn:this.options.getFn,fieldNormWeight:this.options.fieldNormWeight}),this.options.useTokenSearch){const n=$$e({isCaseSensitive:this.options.isCaseSensitive,ignoreDiacritics:this.options.ignoreDiacritics,tokenize:this.options.tokenize});this._invertedIndex=LYi(this._myIndex.records,this._myIndex.keys.length,n)}this._invalidateSearcherCache()}add(t){if(!RE(t))return;this._docs.push(t);const e=this._myIndex.add(t,this._docs.length-1);if(this._invertedIndex&&e){const n=$$e({isCaseSensitive:this.options.isCaseSensitive,ignoreDiacritics:this.options.ignoreDiacritics,tokenize:this.options.tokenize});HYi(this._invertedIndex,e,this._myIndex.keys.length,n)}this._invalidateSearcherCache()}remove(t=()=>!1){const e=[],n=[];for(let o=0,i=this._docs.length;o<i;o+=1)t(this._docs[o],o)&&(e.push(this._docs[o]),n.push(o));if(n.length){this._invertedIndex&&vpn(this._invertedIndex,n);const o=new Set(n);this._docs=this._docs.filter((i,r)=>!o.has(r)),this._myIndex.removeAll(n),this._invalidateSearcherCache()}return e}removeAt(t){if(!Number.isInteger(t)||t<0||t>=this._docs.length)throw new Error(O$e);this._invertedIndex&&vpn(this._invertedIndex,[t]);const e=this._docs.splice(t,1)[0];return this._myIndex.removeAt(t),this._invalidateSearcherCache(),e}_invalidateSearcherCache(){this._lastQuery=null,this._lastSearcher=null}getIndex(){return this._myIndex}_normalizedKeys(){return this._myIndex.keys.map(t=>this._keyStore.get(t.id)||t)}search(t,e){const{limit:n=-1}=e||{},{includeMatches:o,includeScore:i,shouldSort:r,sortFn:s,ignoreFieldNorm:a}=this.options;if(RC(t)&&!t.trim()){let g=this._docs.map((h,d)=>({item:h,refIndex:d}));return dfe(n)&&n>-1&&(g=g.slice(0,n)),g}const A=r&&dfe(n)&&n>0&&RC(t),c=s,l=(g,h)=>c(g,h)||g.idx-h.idx;let u;if(A){const g=new MYi(n,l);RC(this._docs[0])?this._searchStringList(t,{heap:g,ignoreFieldNorm:a}):this._searchObjectList(t,{heap:g,ignoreFieldNorm:a}),u=g.extractSorted()}else u=RC(t)?RC(this._docs[0])?this._searchStringList(t):this._searchObjectList(t):this._searchLogical(t),PYi(u,{ignoreFieldNorm:a}),r&&u.sort(RC(t)?l:c),dfe(n)&&n>-1&&(u=u.slice(0,n));return NYi(u,this._docs,{includeMatches:o,includeScore:i})}_searchStringList(t,{heap:e,ignoreFieldNorm:n}={}){const o=this._getSearcher(t),i=this.options.useTokenSearch&&this.options.tokenMatch==="all",{records:r}=this._myIndex,s=e?null:[];return r.forEach(({v:a,i:A,n:c})=>{if(!RE(a))return;const l=o.searchIn(a);if(l.isMatch){const u={score:l.score,value:a,norm:c,indices:l.indices};i&&(u.matchedMask=l.matchedMask,u.matchedTerms=l.matchedTerms,u.termCount=l.termCount);const g=[u];if(!i||this._coversAllTokens(g)){const h={item:a,idx:A,matches:g};e?(h.score=j$e(h.matches,{ignoreFieldNorm:n}),e.insert(h)):s.push(h)}}}),s}_searchLogical(t){const e=bpn(t,this.options),n=this._normalizedKeys(),o=(a,A,c)=>{if(!("children"in a)){const{keyId:h,searcher:d}=a;let p;return h===null?(p=[],n.forEach((m,_)=>{p.push(...this._findMatches({key:m,value:A[_],searcher:d}))})):p=this._findMatches({key:this._keyStore.get(h),value:this._myIndex.getValueForItemAtKeyId(A,h),searcher:d}),p&&p.length?[{idx:c,item:A,matches:p}]:[]}const{children:l,operator:u}=a,g=[];for(let h=0,d=l.length;h<d;h+=1){const p=l[h],m=o(p,A,c);if(m.length)g.push(...m);else if(u===_fe.AND)return[]}return g},i=this._myIndex.records,r=new Map,s=[];return i.forEach(({$:a,i:A})=>{if(RE(a)){const c=o(e,a,A);c.length&&(r.has(A)||(r.set(A,{idx:A,item:a,matches:[]}),s.push(r.get(A))),c.forEach(({matches:l})=>{r.get(A).matches.push(...l)}))}}),s}_searchObjectList(t,{heap:e,ignoreFieldNorm:n}={}){const o=this._getSearcher(t),i=this.options.useTokenSearch&&this.options.tokenMatch==="all",{records:r}=this._myIndex,s=this._normalizedKeys(),a=e?null:[];return r.forEach(({$:A,i:c})=>{if(!RE(A))return;const l=[];let u=!1,g=!1;if(s.forEach((h,d)=>{const p=this._findMatches({key:h,value:A[d],searcher:o});p.length?(l.push(...p),p[0].hasInverse&&(g=!0)):u=!0}),!(g&&u)&&l.length&&(!i||this._coversAllTokens(l))){const h={idx:c,item:A,matches:l};e?(h.score=j$e(h.matches,{ignoreFieldNorm:n}),e.insert(h)):a.push(h)}}),a}_findMatches({key:t,value:e,searcher:n}){if(!RE(e))return[];const o=[];if(VP(e))e.forEach(({v:i,i:r,n:s})=>{if(!RE(i))return;const a=n.searchIn(i);if(a.isMatch){const A={score:a.score,key:t,value:i,idx:r,norm:s,indices:a.indices,hasInverse:a.hasInverse};a.termCount!==void 0&&(A.matchedMask=a.matchedMask,A.matchedTerms=a.matchedTerms,A.termCount=a.termCount),o.push(A)}});else{const{v:i,n:r}=e,s=n.searchIn(i);if(s.isMatch){const a={score:s.score,key:t,value:i,norm:r,indices:s.indices,hasInverse:s.hasInverse};s.termCount!==void 0&&(a.matchedMask=s.matchedMask,a.matchedTerms=s.matchedTerms,a.termCount=s.termCount),o.push(a)}}return o}_coversAllTokens(t){const e=t.length?t[0].termCount:void 0;if(e===void 0)return!0;if(e<=31){let o=0;for(let i=0;i<t.length;i++)o|=t[i].matchedMask||0;return o===2**e-1}const n=new Set;for(let o=0;o<t.length;o++){const i=t[o].matchedTerms;if(i)for(const r of i)n.add(r)}return n.size===e}};zP.version="7.5.0",zP.createIndex=Cpn,zP.parseIndex=mYi,zP.config=wa,zP.match=function(t,e,n){if(n&&n.useTokenSearch)throw new Error(uYi);return mfe(t,{...wa,...n}).searchIn(e)},zP.parseQuery=bpn,z$e(QYi),z$e(FYi),zP.use=function(...t){t.forEach(e=>z$e(e))};var GYi=zP;const YYi="https://kicad-mod-cache.tscircuit.com";let X$e=null,fee=null,Z$e=null;const UYi=async()=>X$e||fee||(fee=fetch("https://kicad-mod-cache.tscircuit.com/kicad_files.json").then(t=>t.json()).then(t=>(X$e=t,fee=null,t)),fee),KYi=async(t,e=20)=>{const n=await UYi();return Z$e||(Z$e=new GYi(n)),Z$e.search(t).slice(0,e).map(o=>o.item)},VYi=t=>{const e=t.replace(".pretty/","/").replace(".kicad_mod",""),n=`kicad:${e}`;return{path:t,qualifiedName:n,description:e}},zYi=t=>t.replace(/^\/+/,"").split("/").map(e=>encodeURIComponent(e)).join("/"),JYi=async t=>{const e=await fetch(`${YYi}/${zYi(t)}`);if(!e.ok)throw new Error(`KiCad footprint fetch failed: ${e.status}`);const n=await e.text(),{KicadFootprintToCircuitJsonConverter:o}=await vE("kicad-to-circuit-json"),i=new o;return i.addFile(t.split("/").pop()??"selected-footprint.kicad_mod",n),i.runUntilFinished(),i.getOutput()},wpn=t=>t?.source==="jlcpcb"||t?.source==="kicad",WYi=async(t,e)=>{if(t.source==="jlcpcb")return nYi(t.component.partNumber,e?.jlcpcb);if(t.source==="kicad")return JYi(t.footprint.path);throw new Error("Footprint preview is not available for this source")},jYi=({query:t,placeholder:e,isSearching:n,onQueryChange:o,onSubmit:i})=>{const r=ee.useCallback(s=>{s.key==="Enter"&&(s.preventDefault(),i())},[i]);return K.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2 rf-mt-4",children:[K.jsxs("div",{className:"rf-relative rf-flex-grow",children:[K.jsx(ZJe,{className:"rf-absolute rf-left-2 rf-top-2.5 rf-h-4 rf-w-4 rf-text-muted-foreground"}),K.jsx(gje,{placeholder:e,className:"rf-pl-8",spellCheck:!1,autoComplete:"off",value:t,onChange:s=>o(s.target.value),onKeyDown:r})]}),K.jsx(fA,{onClick:i,disabled:n||t.trim().length<1,className:"sm:rf-px-4 rf-px-3",children:n?K.jsx(xE,{className:"rf-h-4 rf-w-4 rf-animate-spin"}):K.jsxs(K.Fragment,{children:[K.jsx(ZJe,{className:"rf-h-4 rf-w-4 sm:rf-hidden"}),K.jsx("span",{className:"rf-hidden sm:rf-inline",children:"Search"})]})})]})},$Yi=new Intl.NumberFormat("en-US",{style:"currency",currency:"USD"}),qYi=t=>$Yi.format(t),Ppn=t=>{switch(t.source){case"tscircuit.com":{const e=t.package;return`tscircuit-${e.package_id??`${e.org_owner_tscircuit_handle??"unknown"}-${e.unscoped_name??e.name??"package"}`}`}case"jlcpcb":return`jlc-${t.component.lcscId}`;case"kicad":return`kicad-${t.footprint.path}`;default:return"unknown"}},XYi=t=>{switch(t.source){case"tscircuit.com":return t.package.unscoped_name;case"jlcpcb":return t.component.isDirectLookup?t.component.partNumber:t.component.manufacturer;case"kicad":return t.footprint.qualifiedName}},ZYi=t=>{switch(t.source){case"tscircuit.com":return t.package.description||(t.package.org_owner_tscircuit_handle?`Component by ${t.package.org_owner_tscircuit_handle}`:void 0);case"jlcpcb":return t.component.description;case"kicad":return t.footprint.description}},eUi=t=>{switch(t.source){case"tscircuit.com":return t.package.name;case"jlcpcb":return t.component.isDirectLookup?void 0:t.component.partNumber;case"kicad":return}},tUi=({results:t,selected:e,onSelect:n,onShowDetails:o})=>{const i=e?Ppn(e):null;return K.jsx("div",{className:"rf-divide-y rf-w-full rf-overflow-hidden",children:t.map(r=>{const s=Ppn(r),a=i===s,A=XYi(r),c=ZYi(r),l=eUi(r),u=r.source==="jlcpcb"?r.component.stock:null,g=r.source==="jlcpcb"?r.component.price:null,h=r.source==="jlcpcb"?r.component.isBasic:null,d=r.source==="jlcpcb"?r.component.isDirectLookup:!1;return K.jsxs("div",{className:`rf-p-3 rf-flex rf-flex-col sm:rf-grid sm:rf-grid-cols-[minmax(0,1fr)_auto] rf-items-start sm:rf-items-center rf-cursor-pointer hover:rf-bg-zinc-100 rf-gap-2 rf-overflow-hidden ${a?"rf-bg-zinc-100":""}`,onClick:()=>n(r),children:[K.jsxs("div",{className:"rf-min-w-0 rf-overflow-hidden rf-w-full",children:[K.jsxs("div",{className:"rf-flex rf-items-start rf-gap-2 rf-min-w-0",children:[K.jsxs("div",{className:"rf-font-medium rf-text-sm rf-truncate rf-flex-1 rf-min-w-0 rf-flex rf-items-center rf-gap-1.5",children:[A,r.source==="jlcpcb"&&h!=null&&K.jsx("span",{className:`rf-text-xs rf-px-1.5 rf-py-0.5 rf-rounded rf-font-medium rf-flex-shrink-0 ${h?"rf-bg-green-100 rf-text-green-700":"rf-bg-orange-100 rf-text-orange-700"}`,children:h?"Basic":"Extended"}),d&&K.jsx("span",{className:"rf-text-xs rf-px-1.5 rf-py-0.5 rf-rounded rf-font-medium rf-flex-shrink-0 rf-bg-blue-100 rf-text-blue-700",children:"Direct lookup"}),r.source==="tscircuit.com"&&r.package.is_private&&K.jsx(Abi,{className:"rf-ml-1 rf-h-3 rf-w-3 rf-text-zinc-400 rf-flex-shrink-0"})]}),r.source==="jlcpcb"&&u!=null?K.jsxs("div",{className:"rf-text-xs rf-text-zinc-500 rf-font-medium rf-whitespace-nowrap rf-flex-shrink-0 sm:rf-hidden",children:[u.toLocaleString()," in stock"]}):null]}),K.jsxs("div",{className:"rf-text-xs rf-text-zinc-500 rf-truncate rf-w-full",children:[l?K.jsx("span",{className:"rf-mr-2",children:l}):null,c]})]}),K.jsxs("div",{children:[r.source==="tscircuit.com"&&o?K.jsx("div",{className:"rf-flex-shrink-0 rf-w-full sm:rf-w-auto",children:K.jsx(fA,{variant:"outline",size:"sm",className:"rf-text-xs rf-w-full sm:rf-w-auto",onClick:p=>{p.stopPropagation(),o(r)},children:"See Details"})}):r.source==="jlcpcb"&&u!=null?K.jsxs("div",{className:"rf-hidden sm:rf-block rf-text-xs rf-text-zinc-500 rf-font-medium rf-whitespace-nowrap rf-flex-shrink-0",children:[u.toLocaleString()," in stock"]}):null,g!=null&&K.jsx("div",{className:"rf-hidden sm:rf-block rf-text-xs rf-text-zinc-500 rf-font-medium rf-whitespace-nowrap rf-flex-shrink-0 rf-text-right",children:qYi(g)})]})]},s)})})},nUi=({circuitJson:t,error:e,isLoading:n,height:o})=>K.jsx("section",{className:"rf-flex rf-min-w-0 rf-items-center rf-justify-center",style:{height:o},children:n?K.jsxs("div",{className:"rf-flex rf-w-full rf-items-center rf-justify-center rf-gap-2 rf-bg-zinc-950 rf-text-sm rf-text-zinc-300",style:{height:o},children:[K.jsx(xE,{className:"rf-h-4 rf-w-4 rf-animate-spin"}),"Loading preview..."]}):e?K.jsx("div",{className:"rf-flex rf-w-full rf-items-center rf-justify-center rf-bg-zinc-950 rf-p-4",style:{height:o},children:K.jsxs("div",{className:"rf-flex rf-max-w-[320px] rf-items-start rf-gap-2 rf-text-sm rf-text-zinc-300",children:[K.jsx(XJe,{className:"rf-mt-0.5 rf-h-4 rf-w-4 rf-flex-shrink-0"}),K.jsx("span",{children:e})]})}):t?K.jsx("div",{className:"rf-w-full rf-min-w-0 rf-overflow-hidden",children:K.jsx(f$e,{circuitJson:t,height:o,allowEditing:!1,clickToInteractEnabled:!1,focusOnHover:!1,disablePcbGroups:!0})}):K.jsx("div",{className:"rf-flex rf-w-full rf-items-center rf-justify-center rf-bg-zinc-950 rf-text-sm rf-text-zinc-300",style:{height:o},children:"No preview"})}),Mpn={importComponentDialog:101,importComponentDetailsDialog:102},oUi=({packageResult:t,isOpen:e,onOpenChange:n,isLoading:o,details:i,previewTab:r,onPreviewTabChange:s,isSubmitting:a,onImport:A})=>{const c=t?.package??null,l=c?.latest_pcb_preview_image_url,u=c?.latest_sch_preview_image_url,g=c?.latest_cad_preview_image_url,h=c?.unscoped_name?.split("/").pop()??c?.unscoped_name,d=c?.org_owner_tscircuit_handle??void 0,p=d?`https://tscircuit.com/${d}`:void 0,m=d&&h?`https://tscircuit.com/${d}/${h}`:void 0;return K.jsx(HT,{open:e,onOpenChange:n,children:K.jsxs(YP,{showOverlay:!1,style:{width:"calc(100vw - 2rem)",zIndex:Mpn.importComponentDetailsDialog},className:"rf-max-w-5xl no-scrollbar !rf-overflow-y-auto rf-max-h-[90vh] rf-overflow-hidden rf-flex rf-flex-col rf-rounded-sm",children:[K.jsx(UP,{className:"rf-pb-4 rf-border-b",children:K.jsx("div",{className:"rf-flex rf-items-start rf-justify-between rf-gap-4",children:K.jsxs("div",{className:"rf-flex-1 rf-min-w-0",children:[K.jsx(KP,{className:"rf-text-xl rf-font-semibold rf-truncate",children:h}),K.jsx(OT,{children:c?.description})]})})}),K.jsxs("div",{className:"rf-flex-1 rf-overflow-y-auto rf-py-4 rf-space-y-6",children:[d?K.jsxs("div",{children:[K.jsx("span",{className:"rf-text-xs rf-font-medium rf-text-gray-500 rf-uppercase rf-tracking-wide",children:"Created by"}),K.jsx("div",{className:"rf-mt-1 rf-text-sm rf-font-medium",children:p?K.jsx("a",{href:p,target:"_blank",rel:"noopener noreferrer",className:"rf-text-black hover:rf-underline",children:d}):d})]}):null,(g||l||u)&&K.jsx(K.Fragment,{children:K.jsxs("div",{children:[K.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-mb-4",children:"Preview"}),K.jsxs(ARe,{value:r,onValueChange:_=>s(_),children:[K.jsxs(Vge,{className:"rf-inline-flex rf-h-9 rf-items-center rf-justify-center rf-rounded-lg rf-bg-zinc-100 rf-p-1 rf-text-zinc-500 dark:rf-bg-zinc-800 dark:rf-text-zinc-400",children:[l&&K.jsx(h6,{value:"pcb",children:"PCB"}),u&&K.jsx(h6,{value:"schematic",children:"Schematic"}),g&&K.jsx(h6,{value:"3d",children:"3D"})]}),K.jsxs("div",{className:"rf-mt-4",children:[K.jsx(cI,{value:"pcb",className:"rf-border rf-rounded-lg rf-overflow-hidden rf-bg-gray-50",children:l?K.jsx("img",{src:l,alt:`${h??"package"} PCB preview`,className:"rf-w-full rf-h-full rf-object-contain rf-bg-white rf-p-4"}):null}),K.jsx(cI,{value:"schematic",className:"rf-border rf-rounded-lg rf-overflow-hidden rf-bg-gray-50",children:u?K.jsx("img",{src:u,alt:`${h??"package"} schematic preview`,className:"rf-w-full rf-h-full rf-object-contain rf-bg-white rf-p-4"}):null}),K.jsx(cI,{value:"3d",className:"rf-border rf-rounded-lg rf-overflow-hidden rf-bg-gray-50",children:g?K.jsx("img",{src:g,alt:`${h??"package"} 3D preview`,className:"rf-w-full rf-h-full rf-object-contain rf-bg-white rf-p-4"}):null})]})]})]})}),i?.ai_description?K.jsxs("section",{children:[K.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-mb-3",children:"AI Description"}),K.jsx("div",{className:"rf-bg-gray-50 rf-border rf-border-gray-200 rf-rounded-lg rf-p-4",children:K.jsx("p",{className:"rf-text-sm rf-text-gray-700 rf-leading-relaxed",children:i.ai_description})})]}):null,i?.ai_usage_instructions?K.jsxs("section",{children:[K.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-mb-3",children:"Usage Instructions"}),K.jsx("div",{className:"rf-bg-gray-50 rf-border rf-border-gray-200 rf-rounded-lg rf-p-4",children:K.jsx("p",{className:"rf-text-sm rf-text-gray-700 rf-leading-relaxed rf-whitespace-pre-wrap",children:i.ai_usage_instructions})})]}):null,o?K.jsxs("div",{className:"rf-flex rf-justify-center rf-items-center rf-gap-2 rf-text-gray-500",children:[K.jsx(xE,{className:"rf-h-4 rf-w-4 rf-animate-spin"}),K.jsx("span",{className:"rf-text-sm",children:"Loading package details..."})]}):null]}),K.jsxs(UU,{className:"rf-pt-4 rf-border-t rf-flex rf-flex-col sm:rf-flex-row rf-justify-between rf-gap-2",children:[K.jsx("div",{className:"rf-flex-1",children:m?K.jsxs(fA,{variant:"outline",size:"sm",className:"rf-gap-2 rf-w-full sm:rf-w-auto",onClick:()=>window.open(m,"_blank"),children:[K.jsx(tbi,{className:"rf-h-4 rf-w-4"}),"View on tscircuit.com"]}):null}),K.jsxs("div",{className:"rf-flex rf-flex-col sm:rf-flex-row rf-gap-2",children:[K.jsx(fA,{variant:"outline",onClick:()=>n(!1),className:"rf-order-2 sm:rf-order-1",children:"Close"}),K.jsx(fA,{onClick:A,disabled:a,className:"rf-bg-blue-600 hover:rf-bg-blue-700",children:a?K.jsx(xE,{className:"rf-h-4 rf-w-4 rf-animate-spin"}):"Import Component"})]})]})]})})},iUi=()=>{const[t,e]=ee.useState(null),[n,o]=ee.useState(!1),i=ee.useCallback(async(s,a)=>{o(!0);try{const A=await fetch(`https://api.tscircuit.com/packages/get?name=${encodeURIComponent(`${s}/${a}`)}`);if(!A.ok)throw new Error(`Failed to load package details: ${A.status}`);const c=await A.json();e(c.package??null)}catch(A){console.error("Failed to fetch package details",A),e(null)}finally{o(!1)}},[]),r=ee.useCallback(()=>{e(null),o(!1)},[]);return{details:t,isLoading:n,fetchDetails:i,reset:r}},rUi=(t,e)=>{const[n,o]=ee.useState({circuitJson:null,error:null,isLoading:!1});return ee.useEffect(()=>{if(!t||!wpn(t)){o({circuitJson:null,error:null,isLoading:!1});return}let i=!1;return o({circuitJson:null,error:null,isLoading:!0}),WYi(t,e).then(r=>{i||o({circuitJson:r,error:null,isLoading:!1})}).catch(r=>{i||o({circuitJson:null,error:r instanceof Error?r.message:"Failed to load footprint preview",isLoading:!1})}),()=>{i=!0}},[t,e]),n},sUi=async(t,e)=>{const n={"Content-Type":"application/json"};e&&(n.Authorization=`Bearer ${e}`);const o=await fetch("https://registry-api.tscircuit.com/packages/search",{method:"POST",headers:n,body:JSON.stringify({query:t})});if(!o.ok)throw new Error(`tscircuit registry error: ${o.status}`);return(await o.json()).packages??[]},aUi=({sessionToken:t})=>{const[e,n]=ee.useState([]),[o,i]=ee.useState(!1),[r,s]=ee.useState(null),[a,A]=ee.useState(!1),c=ee.useCallback(async u=>{const g=u.trim();if(!g)return[];i(!0),s(null);try{const d=(await sUi(g,t)).map(p=>({source:"tscircuit.com",package:p}));return n(d),d}catch(h){return console.error("Error searching tscircuit packages",h),n([]),s(h instanceof Error?h.message:"Failed to search tscircuit packages"),[]}finally{i(!1),A(!0)}},[t]),l=ee.useCallback(()=>{n([]),i(!1),s(null),A(!1)},[]);return{results:e,isSearching:o,error:r,hasSearched:a,search:c,reset:l}},AUi=t=>{const e=/^C(\d+)$/i.exec(t.trim());if(!e)return null;const n=Number(e[1]);if(!Number.isSafeInteger(n))return null;const o=`C${e[1]}`;return{source:"jlcpcb",component:{lcscId:n,manufacturer:o,partNumber:o,description:"Import directly from EasyEDA; stock and availability are unknown",package:"",isDirectLookup:!0}}},Dpn=(t,e)=>{const n=AUi(t);return n?e.some(i=>i.component.partNumber.toUpperCase()===n.component.partNumber)?e:[n,...e]:e},cUi=t=>{const e=t.trim();return/^C\d+/i.test(e)?e.replace(/^C/i,""):e},lUi=()=>{const[t,e]=ee.useState([]),[n,o]=ee.useState(!1),[i,r]=ee.useState(null),[s,a]=ee.useState(!1),A=ee.useCallback(async l=>{const u=cUi(l);if(!u)return[];o(!0),r(null);try{const g=await ZGi(u,10),h=Dpn(l,g.map(d=>({source:"jlcpcb",component:eYi(d)})));return e(h),h}catch(g){console.error("Error searching JLCPCB components",g);const h=Dpn(l,[]);return e(h),r(h.length>0?null:g instanceof Error?g.message:"Failed to search JLCPCB components"),h}finally{o(!1),a(!0)}},[]),c=ee.useCallback(()=>{e([]),o(!1),r(null),a(!1)},[]);return{results:t,isSearching:n,error:i,hasSearched:s,search:A,reset:c}},uUi=()=>{const[t,e]=ee.useState([]),[n,o]=ee.useState(!1),[i,r]=ee.useState(null),[s,a]=ee.useState(!1),A=ee.useCallback(async l=>{const u=l.trim();if(!u)return[];o(!0),r(null);try{const h=(await KYi(u,20)).map(d=>({source:"kicad",footprint:VYi(d)}));return e(h),h}catch(g){return console.error("Error searching KiCad footprints",g),e([]),r(g instanceof Error?g.message:"Failed to search KiCad footprints"),[]}finally{o(!1),a(!0)}},[]),c=ee.useCallback(()=>{e([]),o(!1),r(null),a(!1)},[]);return{results:t,isSearching:n,error:i,hasSearched:s,search:A,reset:c}},gUi=({onTscircuitPackageSelected:t,onJlcpcbComponentTsxLoaded:e,onKicadStringSelected:n})=>{const o=[];return t&&o.push("tscircuit.com"),e&&o.push("jlcpcb"),n&&o.push("kicad"),o},dUi=({isOpen:t,onClose:e,jlcpcbProxyRequestHeaders:n,onKicadStringSelected:o,onTscircuitPackageSelected:i,onJlcpcbComponentTsxLoaded:r,jlcpcbProxyApiBase:s,tscircuitSessionToken:a})=>{dee();const A=ee.useMemo(()=>gUi({onKicadStringSelected:o,onTscircuitPackageSelected:i,onJlcpcbComponentTsxLoaded:r}),[o,i,r]),c=A.length>0,l=A.length===1,[u,g]=ee.useState(A[0]??"tscircuit.com"),[h,d]=ee.useState(""),[p,m]=ee.useState(null),{results:_,isSearching:f,error:I,hasSearched:C,search:y,reset:x}=aUi({sessionToken:a}),{results:E,isSearching:B,error:S,hasSearched:Q,search:w,reset:M}=lUi(),{results:k,isSearching:R,error:F,hasSearched:O,search:U,reset:Y}=uUi(),{details:W,isLoading:te,fetchDetails:j,reset:J}=iUi(),[ie,oe]=ee.useState(null),[ne,ge]=ee.useState(!1),[ue,_e]=ee.useState("pcb"),[le,fe]=ee.useState(null),[he,ye]=ee.useState(!1),Qe=ee.useMemo(()=>({jlcpcb:{headers:n,apiBase:s}}),[s,n]),{circuitJson:we,error:pe,isLoading:ve}=rUi(p,Qe),Me=wpn(p);ee.useEffect(()=>{fe(null)},[p]);const Pe=ee.useCallback(()=>{x(),M(),Y(),m(null)},[M,Y,x]);ee.useEffect(()=>{t||(Pe(),d(""),ge(!1),oe(null),fe(null))},[t,Pe]),ee.useEffect(()=>{d(""),m(null),u==="tscircuit.com"?x():u==="jlcpcb"?M():u==="kicad"&&Y()},[u,M,Y,x]);const He=ot=>{m(ot),oe(ot),_e("pcb"),ge(!0),J();const gt=ot.package.org_owner_tscircuit_handle,Bt=ot.package.unscoped_name;if(gt&&Bt){const Ct=Bt.split("/").pop()??Bt;j(gt,Ct)}},Re=async()=>{h.trim()&&(m(null),u==="tscircuit.com"?await y(h):u==="jlcpcb"?await w(h):u==="kicad"&&await U(h))},Ee=async ot=>{try{if(fe(null),ye(!0),ot.source==="kicad"){if(!o)throw new Error("KiCad handler not provided");await o({result:ot,footprint:ot.footprint.qualifiedName})}else if(ot.source==="jlcpcb"){if(!r)throw new Error("JLCPCB handler not provided");const gt=await tYi(ot.component.partNumber,{headers:n,apiBase:s});await r({result:ot,tsx:gt})}else if(ot.source==="tscircuit.com"){if(!i)throw new Error("tscircuit package handler not provided");const gt=ot.package.org_owner_tscircuit_handle,Bt=ot.package.unscoped_name;if(!gt||!Bt)throw new Error("Missing package metadata");const Ct=Bt.split("/").pop()??Bt,Dt=`@tsci/${gt}.${Ct}`;await i({result:ot,fullPackageName:Dt})}return!0}catch(gt){return console.error("Failed to import component",gt),fe(gt instanceof Error?gt.message:"Failed to import component"),!1}finally{ye(!1)}};let Te=[],Ce=!1,Fe=null,Ye=!1;u==="tscircuit.com"?(Te=_,Ce=f,Fe=I,Ye=C):u==="jlcpcb"?(Te=E,Ce=B,Fe=S,Ye=Q):u==="kicad"&&(Te=k,Ce=R,Fe=F,Ye=O);const tt=async()=>{if(!p)return;await Ee(p)&&(e(),Pe(),d(""))},At=ot=>{ot||e()},at=ot=>{ge(ot),ot||oe(null)};return K.jsxs(HT,{open:t,onOpenChange:At,children:[K.jsxs(YP,{style:{width:"calc(100vw - 2rem)",maxWidth:Me?"min(1120px, calc(100vw - 2rem))":"min(672px, calc(100vw - 2rem))",zIndex:Mpn.importComponentDialog},className:"rf-rounded-sm rf-max-h-[90vh] rf-overflow-y-auto rf-overflow-x-hidden rf-flex rf-flex-col",children:[K.jsxs(UP,{children:[K.jsxs(KP,{className:"rf-text-lg sm:rf-text-xl",children:["Import ",l?gfe[u].label:""," ","Component"]}),K.jsx(OT,{className:"rf-text-sm",children:c?"Search for components from available sources.":"Import options are disabled because no handlers were provided."})]}),c?K.jsxs(ARe,{value:u,onValueChange:ot=>g(ot),className:"rf-min-w-0 rf-w-full",children:[!l&&K.jsx(Vge,{className:"rf-flex rf-w-full rf-gap-2",children:A.map(ot=>K.jsx(h6,{value:ot,className:"rf-flex-1 rf-text-xs sm:rf-text-sm",children:gfe[ot].label},ot))}),K.jsxs("div",{className:"rf-min-w-0",style:Me?{display:"grid",gridTemplateColumns:"minmax(0, 1fr) minmax(360px, 0.95fr)",gap:"1.5rem",alignItems:"start"}:void 0,children:[K.jsxs("div",{className:"rf-min-w-0",children:[K.jsx(jYi,{query:h,placeholder:gfe[u].placeholder,isSearching:Ce,onQueryChange:d,onSubmit:Re}),K.jsx("div",{className:"no-scrollbar rf-mt-4 rf-flex-1 rf-min-h-[200px] !rf-max-h-[40vh] !rf-overflow-y-auto rf-overflow-x-hidden rf-border rf-rounded-md rf-min-w-0",children:Ce?K.jsxs("div",{className:"rf-p-8 rf-text-center rf-text-zinc-500",children:[K.jsx(xE,{className:"rf-h-8 rf-w-8 rf-animate-spin rf-mx-auto rf-mb-2"}),K.jsx("p",{children:"Searching..."})]}):Te.length>0?K.jsx(tUi,{results:Te,selected:p,onSelect:m,onShowDetails:u==="tscircuit.com"?He:void 0}):K.jsx("div",{className:"rf-p-8 rf-text-center rf-text-zinc-500",children:Fe?`Error: ${Fe}`:Ye?gfe[u].emptyMessage:"Enter a search term to find components"})})]}),Me?K.jsx("div",{className:"rf-mt-4",children:K.jsx(nUi,{circuitJson:we,error:pe,isLoading:ve,height:325})}):null]})]}):null,le?K.jsx("div",{className:"rf-text-sm rf-text-red-600 rf-mt-2",children:le}):null,K.jsxs(UU,{className:"rf-flex rf-flex-col sm:rf-flex-row rf-gap-2",children:[K.jsx(fA,{variant:"outline",onClick:e,className:"rf-order-2 sm:rf-order-1",children:"Cancel"}),K.jsx(fA,{onClick:tt,disabled:!p||he,className:"rf-order-1 sm:rf-order-2",children:he?K.jsx(xE,{className:"rf-h-4 rf-w-4 rf-animate-spin"}):"Import"})]})]}),K.jsx(oUi,{packageResult:ie,isOpen:ne,onOpenChange:at,isLoading:te,details:W,previewTab:ue,onPreviewTabChange:ot=>_e(ot),isSubmitting:he,onImport:()=>{ie&&Ee(ie).then(ot=>{ot&&(ge(!1),e(),Pe(),d(""))})}})]})},hUi=t=>{const e=t.match(/export const (\w+) =/);if(!e)throw new Error("Could not determine component name from TSX contents");return e[1]},Npn=t=>{const e=md(s=>s.pushEvent),n=md(s=>s.upsertFile),o=async({result:s,fullPackageName:a})=>{const c=s.package.unscoped_name??s.package.name;await ua.promise(e({event_type:"INSTALL_PACKAGE",full_package_name:a}),{loading:`Requesting install for "${c}"`,success:`Install requested for "${c}"`,error:l=>`Failed to request install: ${l instanceof Error?l.message:String(l)}`})},i=async({footprint:s})=>{await ua.promise(navigator.clipboard.writeText(s),{loading:`Copying "${s}"`,success:`Copied "${s}" to clipboard`,error:a=>`Failed to copy footprint: ${a instanceof Error?a.message:String(a)}`})},r=async({result:s,tsx:a})=>{const c=`imports/${hUi(a)}.tsx`;await ua.promise(n(c,a),{loading:`Importing ${s.component.partNumber}`,success:`Imported to "${c}"`,error:l=>`Failed to import component: ${l instanceof Error?l.message:String(l)}`})};return K.jsx(dUi,{...t,onTscircuitPackageSelected:o,onKicadStringSelected:i,onJlcpcbComponentTsxLoaded:r})};Npn.displayName="ImportComponentDialogForCli";const pUi=async({circuitJson:t,projectName:e})=>{const{convertCircuitJsonToAltiumZip:n}=await Promise.resolve().then(()=>Ygr),o=await n(t,e);return new Blob([new Uint8Array(o)],{type:"application/zip"})},mUi=async({circuitJson:t,projectName:e})=>{await ua.promise((async()=>{const n=await pUi({circuitJson:t,projectName:e});NE(n,{fileName:`${e}_altium_project.zip`})})(),{loading:"Generating Altium project...",success:"Altium project ZIP ready",error:n=>`Failed to generate Altium project: ${n instanceof Error?n.message:String(n)}`})};var eqe={exports:{}},Rpn;function _Ui(){return Rpn||(Rpn=1,(function(t,e){var n={env:{},version:""};(function(o){t.exports=o()})(function(){return(function o(i,r,s){function a(l,u){if(!r[l]){if(!i[l]){var g=typeof Y8=="function"&&Y8;if(!u&&g)return g(l,!0);if(A)return A(l,!0);var h=new Error("Cannot find module '"+l+"'");throw h.code="MODULE_NOT_FOUND",h}var d=r[l]={exports:{}};i[l][0].call(d.exports,function(p){var m=i[l][1][p];return a(m||p)},d,d.exports,o,i,r,s)}return r[l].exports}for(var A=typeof Y8=="function"&&Y8,c=0;c<s.length;c++)a(s[c]);return a})({1:[function(o,i,r){var s=o("./utils"),a=o("./support"),A="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";r.encode=function(c){for(var l,u,g,h,d,p,m,_=[],f=0,I=c.length,C=I,y=s.getTypeOf(c)!=="string";f<c.length;)C=I-f,g=y?(l=c[f++],u=f<I?c[f++]:0,f<I?c[f++]:0):(l=c.charCodeAt(f++),u=f<I?c.charCodeAt(f++):0,f<I?c.charCodeAt(f++):0),h=l>>2,d=(3&l)<<4|u>>4,p=1<C?(15&u)<<2|g>>6:64,m=2<C?63&g:64,_.push(A.charAt(h)+A.charAt(d)+A.charAt(p)+A.charAt(m));return _.join("")},r.decode=function(c){var l,u,g,h,d,p,m=0,_=0,f="data:";if(c.substr(0,f.length)===f)throw new Error("Invalid base64 input, it looks like a data url.");var I,C=3*(c=c.replace(/[^A-Za-z0-9+/=]/g,"")).length/4;if(c.charAt(c.length-1)===A.charAt(64)&&C--,c.charAt(c.length-2)===A.charAt(64)&&C--,C%1!=0)throw new Error("Invalid base64 input, bad content length.");for(I=a.uint8array?new Uint8Array(0|C):new Array(0|C);m<c.length;)l=A.indexOf(c.charAt(m++))<<2|(h=A.indexOf(c.charAt(m++)))>>4,u=(15&h)<<4|(d=A.indexOf(c.charAt(m++)))>>2,g=(3&d)<<6|(p=A.indexOf(c.charAt(m++))),I[_++]=l,d!==64&&(I[_++]=u),p!==64&&(I[_++]=g);return I}},{"./support":30,"./utils":32}],2:[function(o,i,r){var s=o("./external"),a=o("./stream/DataWorker"),A=o("./stream/Crc32Probe"),c=o("./stream/DataLengthProbe");function l(u,g,h,d,p){this.compressedSize=u,this.uncompressedSize=g,this.crc32=h,this.compression=d,this.compressedContent=p}l.prototype={getContentWorker:function(){var u=new a(s.Promise.resolve(this.compressedContent)).pipe(this.compression.uncompressWorker()).pipe(new c("data_length")),g=this;return u.on("end",function(){if(this.streamInfo.data_length!==g.uncompressedSize)throw new Error("Bug : uncompressed data size mismatch")}),u},getCompressedWorker:function(){return new a(s.Promise.resolve(this.compressedContent)).withStreamInfo("compressedSize",this.compressedSize).withStreamInfo("uncompressedSize",this.uncompressedSize).withStreamInfo("crc32",this.crc32).withStreamInfo("compression",this.compression)}},l.createWorkerFrom=function(u,g,h){return u.pipe(new A).pipe(new c("uncompressedSize")).pipe(g.compressWorker(h)).pipe(new c("compressedSize")).withStreamInfo("compression",g)},i.exports=l},{"./external":6,"./stream/Crc32Probe":25,"./stream/DataLengthProbe":26,"./stream/DataWorker":27}],3:[function(o,i,r){var s=o("./stream/GenericWorker");r.STORE={magic:"\0\0",compressWorker:function(){return new s("STORE compression")},uncompressWorker:function(){return new s("STORE decompression")}},r.DEFLATE=o("./flate")},{"./flate":7,"./stream/GenericWorker":28}],4:[function(o,i,r){var s=o("./utils"),a=(function(){for(var A,c=[],l=0;l<256;l++){A=l;for(var u=0;u<8;u++)A=1&A?3988292384^A>>>1:A>>>1;c[l]=A}return c})();i.exports=function(A,c){return A!==void 0&&A.length?s.getTypeOf(A)!=="string"?(function(l,u,g,h){var d=a,p=h+g;l^=-1;for(var m=h;m<p;m++)l=l>>>8^d[255&(l^u[m])];return-1^l})(0|c,A,A.length,0):(function(l,u,g,h){var d=a,p=h+g;l^=-1;for(var m=h;m<p;m++)l=l>>>8^d[255&(l^u.charCodeAt(m))];return-1^l})(0|c,A,A.length,0):0}},{"./utils":32}],5:[function(o,i,r){r.base64=!1,r.binary=!1,r.dir=!1,r.createFolders=!0,r.date=null,r.compression=null,r.compressionOptions=null,r.comment=null,r.unixPermissions=null,r.dosPermissions=null},{}],6:[function(o,i,r){var s=null;s=typeof Promise<"u"?Promise:o("lie"),i.exports={Promise:s}},{lie:37}],7:[function(o,i,r){var s=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Uint32Array<"u",a=o("pako"),A=o("./utils"),c=o("./stream/GenericWorker"),l=s?"uint8array":"array";function u(g,h){c.call(this,"FlateWorker/"+g),this._pako=null,this._pakoAction=g,this._pakoOptions=h,this.meta={}}r.magic="\b\0",A.inherits(u,c),u.prototype.processChunk=function(g){this.meta=g.meta,this._pako===null&&this._createPako(),this._pako.push(A.transformTo(l,g.data),!1)},u.prototype.flush=function(){c.prototype.flush.call(this),this._pako===null&&this._createPako(),this._pako.push([],!0)},u.prototype.cleanUp=function(){c.prototype.cleanUp.call(this),this._pako=null},u.prototype._createPako=function(){this._pako=new a[this._pakoAction]({raw:!0,level:this._pakoOptions.level||-1});var g=this;this._pako.onData=function(h){g.push({data:h,meta:g.meta})}},r.compressWorker=function(g){return new u("Deflate",g)},r.uncompressWorker=function(){return new u("Inflate",{})}},{"./stream/GenericWorker":28,"./utils":32,pako:38}],8:[function(o,i,r){function s(d,p){var m,_="";for(m=0;m<p;m++)_+=String.fromCharCode(255&d),d>>>=8;return _}function a(d,p,m,_,f,I){var C,y,x=d.file,E=d.compression,B=I!==l.utf8encode,S=A.transformTo("string",I(x.name)),Q=A.transformTo("string",l.utf8encode(x.name)),w=x.comment,M=A.transformTo("string",I(w)),k=A.transformTo("string",l.utf8encode(w)),R=Q.length!==x.name.length,F=k.length!==w.length,O="",U="",Y="",W=x.dir,te=x.date,j={crc32:0,compressedSize:0,uncompressedSize:0};p&&!m||(j.crc32=d.crc32,j.compressedSize=d.compressedSize,j.uncompressedSize=d.uncompressedSize);var J=0;p&&(J|=8),B||!R&&!F||(J|=2048);var ie=0,oe=0;W&&(ie|=16),f==="UNIX"?(oe=798,ie|=(function(ge,ue){var _e=ge;return ge||(_e=ue?16893:33204),(65535&_e)<<16})(x.unixPermissions,W)):(oe=20,ie|=(function(ge){return 63&(ge||0)})(x.dosPermissions)),C=te.getUTCHours(),C<<=6,C|=te.getUTCMinutes(),C<<=5,C|=te.getUTCSeconds()/2,y=te.getUTCFullYear()-1980,y<<=4,y|=te.getUTCMonth()+1,y<<=5,y|=te.getUTCDate(),R&&(U=s(1,1)+s(u(S),4)+Q,O+="up"+s(U.length,2)+U),F&&(Y=s(1,1)+s(u(M),4)+k,O+="uc"+s(Y.length,2)+Y);var ne="";return ne+=`
5671
+ `,u=new Blob([l],{type:"text/plain"}),g=URL.createObjectURL(u),h=document.createElement("a");h.href=g,h.download=`${c}.test.ts`,h.click(),URL.revokeObjectURL(g)}catch(A){alert(`Error generating test.ts for ${t.getSolverName()}: ${A instanceof Error?A.message:String(A)}`)}o(!1)};return K.jsxs("div",{className:`relative ${e}`,ref:i,children:[K.jsx("button",{className:"px-2 py-1 rounded text-xs cursor-pointer",onClick:()=>o(!n),title:`Download options for ${t.getSolverName()}`,children:t.getSolverName()}),n&&K.jsxs("div",{className:"absolute top-full left-0 mt-1 bg-white border border-gray-300 rounded shadow-lg z-10 min-w-[150px]",children:[K.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:r,children:"Download JSON"}),K.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:s,children:"Download page.tsx"}),K.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:a,children:"Download test.ts"})]})]})},Ohn=t=>t.activeSubSolver?[t,...Ohn(t.activeSubSolver)]:[t],DOi=({solver:t})=>{const e=Ohn(t);return K.jsx("div",{className:"flex gap-1 items-center text-sm pt-1",children:e.map((n,o)=>K.jsxs("div",{className:"flex items-center",children:[o>0&&K.jsx("span",{className:"text-gray-400 mx-1",children:"→"}),K.jsx(MOi,{solver:n})]},n.getSolverName()))})},NOi=({solver:t,triggerRender:e,animationSpeed:n=25,renderer:o,onRendererChange:i,onAnimationSpeedChange:r,onDownloadVisualization:s,onSolverStarted:a,onSolverCompleted:A})=>{const[c,l]=ee.useReducer(B=>!B,!1),u=ee.useRef(void 0),g=ee.useRef(null),h="solver-debugger-last-iteration",[d,p]=ee.useState(null),m=ee.useRef(null),_=ee.useMemo(()=>[{label:"Slow",value:250,description:"250ms"},{label:"Normal",value:100,description:"100ms"},{label:"Fast",value:10,description:"10ms"},{label:"Fast (2x)",value:5,description:"5ms"},{label:"Fast (10x)",value:1,description:"1ms"},{label:"Fast 20x",value:.5,description:"2 steps / 1ms"},{label:"Fast 100x",value:.1,description:"10 steps / 1ms"}],[]),f=()=>{const B=Math.max(1,n),S=n<1?Math.round(1/n):1;u.current=setInterval(()=>{if(t.solved||t.failed){u.current&&(clearInterval(u.current),u.current=void 0),l(),e(),A&&t.solved&&A(t);return}for(let Q=0;Q<S&&!(t.solved||t.failed);Q++)t.step();e()},B)},I=()=>{u.current&&(clearInterval(u.current),u.current=void 0)},C=()=>{!t.solved&&!t.failed&&(t.step(),e())},y=()=>{!t.solved&&!t.failed&&(a&&a(t),t.solve(),e(),A&&A(t))},x=()=>{c?(I(),l()):(l(),f())},E=()=>{if(t.solved||t.failed||c)return;g.current===null&&typeof window<"u"&&(g.current=window.localStorage.getItem(h));const B=window.prompt("Step until which iteration?",g.current??`${t.iterations}`);if(B===null)return;g.current=B,typeof window<"u"&&window.localStorage.setItem(h,B);const S=Number(B);if(!Number.isFinite(S)){window.alert("Please enter a valid number for the iteration");return}for(;t.iterations<S&&!t.solved&&!t.failed;)t.step();e(),t.solved&&A&&A(t)};return ee.useEffect(()=>()=>{I()},[]),ee.useEffect(()=>{(t.solved||t.failed)&&c&&(I(),l())},[t.solved,t.failed,c]),ee.useEffect(()=>{c&&(I(),f())},[n,c]),ee.useEffect(()=>{if(typeof document>"u")return;const B=S=>{m.current&&!m.current.contains(S.target)&&p(null)};return document.addEventListener("mousedown",B),()=>{document.removeEventListener("mousedown",B)}},[]),K.jsxs("div",{className:"space-y-2 p-2 border-b",children:[K.jsx("div",{className:"flex items-center",children:K.jsxs("div",{className:"flex items-center gap-2",ref:m,children:[K.jsxs("div",{className:"flex h-9 items-center space-x-1 rounded-md border border-slate-200 bg-white p-1 shadow-sm",children:[K.jsxs("div",{className:"relative",children:[K.jsx("button",{type:"button",onClick:()=>p(d==="renderer"?null:"renderer"),className:"flex select-none items-center rounded-sm px-3 py-1 text-sm font-medium outline-none focus:bg-slate-100 data-[state=open]:bg-slate-100","data-state":d==="renderer"?"open":"closed",children:"Renderer"}),d==="renderer"&&K.jsx("div",{className:"absolute left-0 z-50 mt-1 min-w-[10rem] rounded-md border border-slate-200 bg-white p-1 text-slate-950 shadow-md",children:["vector","canvas"].map(B=>K.jsxs("button",{type:"button",onClick:()=>{i(B),p(null)},className:"flex w-full items-center rounded-sm px-2 py-1.5 text-sm hover:bg-slate-100",children:[B==="vector"?"Vector":"Canvas",o===B&&K.jsx("span",{className:"ml-auto text-xs text-slate-500",children:"✓"})]},B))})]}),K.jsxs("div",{className:"relative",children:[K.jsx("button",{type:"button",onClick:()=>p(d==="debug"?null:"debug"),className:"flex select-none items-center rounded-sm px-3 py-1 text-sm font-medium outline-none focus:bg-slate-100 data-[state=open]:bg-slate-100","data-state":d==="debug"?"open":"closed",children:"Debug"}),d==="debug"&&K.jsx("div",{className:"absolute left-0 z-50 mt-1 min-w-[12rem] rounded-md border border-slate-200 bg-white p-1 text-slate-950 shadow-md",children:K.jsx("button",{type:"button",onClick:()=>{s(),p(null)},className:"flex w-full items-center rounded-sm px-2 py-1.5 text-sm hover:bg-slate-100",children:"Download Visualization"})})]}),K.jsxs("div",{className:"relative",children:[K.jsx("button",{type:"button",onClick:()=>p(d==="animation"?null:"animation"),className:"flex select-none items-center rounded-sm px-3 py-1 text-sm font-medium outline-none focus:bg-slate-100 data-[state=open]:bg-slate-100","data-state":d==="animation"?"open":"closed",children:"Animation"}),d==="animation"&&K.jsx("div",{className:"absolute left-0 z-50 mt-1 min-w-[12rem] rounded-md border border-slate-200 bg-white p-1 text-slate-950 shadow-md",children:_.map(B=>K.jsxs("button",{type:"button",onClick:()=>{r(B.value),p(null)},className:"flex w-full items-center rounded-sm px-2 py-1.5 text-sm hover:bg-slate-100",children:[B.label,K.jsx("span",{className:"ml-auto text-xs text-slate-500",children:B.description}),n===B.value&&K.jsx("span",{className:"ml-2 text-xs text-slate-500",children:"✓"})]},B.value))})]})]}),K.jsx(DOi,{solver:t})]})}),K.jsxs("div",{className:"flex gap-2 items-center flex-wrap",children:[K.jsx("button",{onClick:C,disabled:t.solved||t.failed||c,className:"bg-blue-500 hover:bg-blue-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Step"}),K.jsx("button",{onClick:y,disabled:t.solved||t.failed||c,className:"bg-green-500 hover:bg-green-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Solve"}),K.jsx("button",{onClick:x,disabled:t.solved||t.failed,className:`px-3 py-1 rounded text-white text-sm ${c?"bg-red-500 hover:bg-red-600":"bg-yellow-500 hover:bg-yellow-600"} disabled:bg-gray-300`,children:c?"Stop":"Animate"}),K.jsx("button",{onClick:E,disabled:t.solved||t.failed||c,className:"bg-orange-500 hover:bg-orange-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Step Until Iteration"}),K.jsxs("div",{className:"text-sm text-gray-600",children:["Iterations: ",t.iterations]}),t.timeToSolve!==void 0&&K.jsxs("div",{className:"text-sm text-gray-600",children:["Time: ",(t.timeToSolve/1e3).toFixed(3),"s"]}),t.solved&&K.jsx("div",{className:"px-2 py-1 bg-green-100 text-green-800 rounded text-sm",children:"Solved"}),t.failed&&K.jsx("div",{className:"px-2 py-1 bg-red-100 text-red-800 rounded text-sm",children:"Failed"})]}),t.error&&K.jsxs("div",{className:"text-red-600 text-sm",children:["Error: ",t.error]})]})},ROi=t=>t!==null&&"pipelineDef"in t&&Array.isArray(t.pipelineDef),TOi=(t,e,n)=>{const o=t.currentPipelineStageIndex;return e<o?"Completed":e===o&&t.activeSubSolver?t.activeSubSolver.failed?"Failed":"In Progress":"Not Started"},kOi=(t,e)=>{const o=t.pipelineDef[e].solverName,i=TOi(t,e),r=t[o],s=t.firstIterationOfStage?.[o]??(e===t.currentPipelineStageIndex?t.iterations:null),a=t.iterations;let A=0;if(i==="Completed"){const g=t.pipelineDef[e+1],h=g?t.firstIterationOfStage?.[g.solverName]:void 0;h!==void 0&&s!==null?A=h-s:s!==null&&(A=a-s)}else i==="In Progress"&&s!==null&&(A=a-s);const c=t.timeSpentOnStage?.[o]??0;let l=0;i==="Completed"?l=1:i==="In Progress"&&r&&(l=r.progress??0);const u=r?.stats??null;return{index:e,name:o,status:i,firstIteration:s,iterations:A,progress:l,timeSpent:c,stats:u&&Object.keys(u).length>0?u:null,solverInstance:r??null}},FOi=({status:t})=>{const e={"Not Started":"text-blue-600","In Progress":"text-yellow-600",Completed:"text-green-600",Failed:"text-red-600"};return K.jsx("span",{className:`font-medium ${e[t]}`,children:t})},LOi=({progress:t})=>{if(t===0)return null;const e=Math.round(t*100);return K.jsxs("div",{className:"flex items-center gap-2",children:[K.jsx("div",{className:"w-20 h-2 bg-gray-200 rounded overflow-hidden",children:K.jsx("div",{className:"h-full bg-blue-500 transition-all duration-200",style:{width:`${e}%`}})}),K.jsxs("span",{className:"text-xs text-gray-500",children:[e,"%"]})]})},Ghn=t=>{if(typeof t=="string")return t;if(typeof t=="number"||typeof t=="boolean"||typeof t=="bigint"||t==null)return String(t);if(typeof t=="object")try{return JSON.stringify(t)}catch{return String(t)}return String(t)},HOi=t=>Object.entries(t).map(([e,n])=>`${e}: ${Ghn(n)}`).join(", "),OOi=({stats:t})=>{if(!t||Object.keys(t).length===0)return K.jsx("span",{children:"-"});const e=Object.entries(t),n=HOi(t);return K.jsxs("details",{className:"cursor-pointer",children:[K.jsx("summary",{className:"whitespace-nowrap overflow-hidden text-ellipsis max-w-[200px]",children:n}),K.jsx("div",{className:"mt-1 text-xs",children:e.map(([o,i])=>K.jsxs("div",{children:[o,": ",Ghn(i)]},o))})]})},B$e=t=>{if(t===null||typeof t!="object")return t;if(Array.isArray(t))return t.map(B$e);const e={};for(const[n,o]of Object.entries(t))n.startsWith("_")||(e[n]=B$e(o));return e},GOi=(t,e)=>{try{if(typeof t.getConstructorParams!="function"){alert(`getConstructorParams() is not implemented for ${e}`);return}const n=B$e(t.getConstructorParams()),o=new Blob([JSON.stringify(n,null,2)],{type:"application/json"}),i=URL.createObjectURL(o),r=document.createElement("a");r.href=i,r.download=`${e}_input.json`,r.click(),URL.revokeObjectURL(i)}catch(n){alert(`Error downloading input for ${e}: ${n instanceof Error?n.message:String(n)}`)}},YOi=({expanded:t})=>K.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:`w-4 h-4 transition-transform duration-200 ${t?"rotate-90":""}`,children:K.jsx("path",{fillRule:"evenodd",d:"M4.5 5.653c0-1.426 1.529-2.33 2.779-1.643l11.54 6.348c1.295.712 1.295 2.573 0 3.285L7.28 19.991c-1.25.687-2.779-.217-2.779-1.643V5.653z",clipRule:"evenodd"})}),Yhn=t=>{let e=t;for(;e.activeSubSolver;)e=e.activeSubSolver;return e},Uhn=({solver:t,onStepUntilPhase:e,onDownloadInput:n,isNested:o=!1,indentLevel:i=0,triggerRender:r})=>{const[s,a]=ee.useState(new Set),A=t.pipelineDef.map((m,_)=>kOi(t,_)),c=m=>{a(_=>{const f=new Set(_);return f.has(m)?f.delete(m):f.add(m),f})},l=m=>{e?.(m)},u=m=>{m.solverInstance&&(n?n(m.solverInstance,m.name):GOi(m.solverInstance,m.name))},g=m=>`${(m/1e3).toFixed(2)}s`,h=()=>{if(!t.solved&&!t.failed){const m=t.activeSubSolver;for(;!t.solved&&!t.failed&&(t.step(),!(t.activeSubSolver&&t.activeSubSolver!==m)););r?.()}},d=()=>{if(!t.solved&&!t.failed){const m=Yhn(t);for(;!t.solved&&!t.failed&&(t.step(),Yhn(t)===m););r?.()}},p=i*24;return K.jsxs("div",{className:o?"":"border-t border-gray-200",children:[!o&&K.jsxs("div",{className:"px-4 py-2 bg-gray-50 border-b border-gray-200 flex items-center justify-between",children:[K.jsx("h3",{className:"text-sm font-semibold text-gray-700",children:"Pipeline Stages"}),K.jsxs("div",{className:"flex gap-2",children:[K.jsx("button",{onClick:d,disabled:t.solved||t.failed,className:"bg-indigo-500 hover:bg-indigo-600 disabled:bg-gray-300 disabled:cursor-not-allowed cursor-pointer text-white px-3 py-1 rounded text-sm",children:"Next Solver"}),K.jsx("button",{onClick:h,disabled:t.solved||t.failed,className:"bg-purple-500 hover:bg-purple-600 disabled:bg-gray-300 disabled:cursor-not-allowed cursor-pointer text-white px-3 py-1 rounded text-sm",children:"Next Stage"})]})]}),K.jsx("div",{className:"overflow-x-auto",children:K.jsxs("table",{className:"w-full text-sm",children:[!o&&K.jsx("thead",{children:K.jsxs("tr",{className:"bg-gray-50 border-b border-gray-200",children:[K.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Stage"}),K.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Status"}),K.jsxs("th",{className:"px-4 py-2 text-center font-semibold text-gray-700",children:["i",K.jsx("sub",{children:"0"})]}),K.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Iterations"}),K.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Progress"}),K.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Time"}),K.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Stats"}),K.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Input"})]})}),K.jsx("tbody",{children:A.map(m=>{const _=ROi(m.solverInstance),f=s.has(m.name);return K.jsxs(Fs.Fragment,{children:[K.jsxs("tr",{className:`border-b border-gray-100 ${m.status==="In Progress"?"bg-yellow-50":""}`,children:[K.jsx("td",{className:"px-4 py-2",children:K.jsxs("div",{className:"flex items-center gap-2",style:{paddingLeft:p},children:[_?K.jsx("button",{onClick:()=>c(m.name),className:"text-gray-500 hover:text-gray-700",title:f?"Collapse":"Expand",children:K.jsx(YOi,{expanded:f})}):K.jsx("span",{className:"w-4"}),K.jsx("span",{className:"text-gray-400 w-6",children:String(m.index+1).padStart(2,"0")}),K.jsx("button",{onClick:()=>l(m.name),disabled:m.status==="Completed"||t.solved||t.failed,className:"text-blue-500 hover:text-blue-700 disabled:text-gray-300 disabled:cursor-not-allowed",title:`Step until ${m.name} completes`,children:K.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:K.jsx("path",{fillRule:"evenodd",d:"M4.5 5.653c0-1.426 1.529-2.33 2.779-1.643l11.54 6.348c1.295.712 1.295 2.573 0 3.285L7.28 19.991c-1.25.687-2.779-.217-2.779-1.643V5.653z",clipRule:"evenodd"})})}),K.jsx("span",{className:"font-medium text-gray-900",children:m.name})]})}),K.jsx("td",{className:"px-4 py-2",children:K.jsx(FOi,{status:m.status})}),K.jsx("td",{className:"px-4 py-2 text-center text-gray-600",children:m.firstIteration!==null?m.firstIteration:""}),K.jsx("td",{className:"px-4 py-2 text-gray-600",children:m.iterations}),K.jsx("td",{className:"px-4 py-2",children:K.jsx(LOi,{progress:m.progress})}),K.jsx("td",{className:"px-4 py-2 text-gray-600",children:g(m.timeSpent)}),K.jsx("td",{className:"px-4 py-2 text-gray-500",children:K.jsx(OOi,{stats:m.stats})}),K.jsx("td",{className:"px-4 py-2",children:m.solverInstance?K.jsxs("button",{onClick:()=>u(m),className:"flex items-center gap-1 text-blue-500 hover:text-blue-700",title:`Download input for ${m.name}`,children:[K.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:K.jsx("path",{fillRule:"evenodd",d:"M12 2.25a.75.75 0 01.75.75v11.69l3.22-3.22a.75.75 0 111.06 1.06l-4.5 4.5a.75.75 0 01-1.06 0l-4.5-4.5a.75.75 0 111.06-1.06l3.22 3.22V3a.75.75 0 01.75-.75zm-9 13.5a.75.75 0 01.75.75v2.25a1.5 1.5 0 001.5 1.5h13.5a1.5 1.5 0 001.5-1.5V16.5a.75.75 0 011.5 0v2.25a3 3 0 01-3 3H5.25a3 3 0 01-3-3V16.5a.75.75 0 01.75-.75z",clipRule:"evenodd"})}),K.jsx("span",{children:"Input"})]}):null})]}),_&&f&&K.jsx("tr",{children:K.jsx("td",{colSpan:8,className:"p-0",children:K.jsx(Uhn,{solver:m.solverInstance,onStepUntilPhase:e,onDownloadInput:n,isNested:!0,indentLevel:i+1,triggerRender:r})})})]},m.name)})})]})})]})};function UOi({graphics:t}){const e=t.points??[],n=t.lines??[],o=t.rects??[],i=t.circles??[],r=t.texts??[];let s=Number.POSITIVE_INFINITY,a=Number.POSITIVE_INFINITY,A=Number.NEGATIVE_INFINITY,c=Number.NEGATIVE_INFINITY;const l=(m,_)=>{typeof m=="number"&&(m<s&&(s=m),m>A&&(A=m)),typeof _=="number"&&(_<a&&(a=_),_>c&&(c=_))};for(const m of e)l(m.x,m.y);for(const m of n){const _=m.points??[];for(const f of _)l(f.x,f.y)}for(const m of o){const _=m.x??0,f=m.y??0,I=m.width??0,C=m.height??0;l(_,f),l(_+I,f+C)}for(const m of i){const _=m.x??0,f=m.y??0,I=m.radius??1;l(_-I,f-I),l(_+I,f+I)}for(const m of r)l(m.x,m.y);(!isFinite(s)||!isFinite(a)||!isFinite(A)||!isFinite(c))&&(s=-20,a=-20,A=20,c=20);const u=10,g=s-u,h=a-u,d=Math.max(1,A-s+2*u),p=Math.max(1,c-a+2*u);return K.jsxs("svg",{className:"w-full h-[400px] bg-white",viewBox:`${g} ${h} ${d} ${p}`,role:"img","aria-label":"Graphics fallback",children:[o.map((m,_)=>K.jsx("rect",{x:m.x??0,y:m.y??0,width:m.width??0,height:m.height??0,fill:"none",stroke:m.strokeColor??"black",strokeWidth:m.strokeWidth??1},`rect-${_}`)),n.map((m,_)=>K.jsx("polyline",{fill:"none",stroke:m.strokeColor??"black",strokeWidth:m.strokeWidth??1,points:(m.points??[]).map(f=>`${f.x??0},${f.y??0}`).join(" ")},`line-${_}`)),i.map((m,_)=>K.jsx("circle",{cx:m.x??0,cy:m.y??0,r:m.radius??1.5,fill:m.fillColor??"none",stroke:m.strokeColor??"black",strokeWidth:m.strokeWidth??1},`circle-${_}`)),e.map((m,_)=>K.jsx("circle",{cx:m.x??0,cy:m.y??0,r:m.radius??1.5,fill:m.color??"black"},`point-${_}`)),r.map((m,_)=>K.jsx("text",{x:m.x??0,y:m.y??0,fontSize:m.fontSize??10,fill:m.color??"black",children:m.text??""},`text-${_}`))]})}var KOi=class extends Fs.Component{constructor(t){super(t),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(t){console.error("InteractiveGraphics render error:",t)}render(){return this.state.hasError?this.props.fallback:this.props.children}},VOi=({solver:t,createSolver:e,animationSpeed:n=25,onSolverStarted:o,onSolverCompleted:i})=>{const[r,s]=ee.useReducer(f=>f+1,0),[a]=ee.useState(()=>{if(e)return e();if(!t)throw new Error("GenericSolverDebugger requires solver or createSolver");return t}),[A,c]=ee.useState(()=>typeof window>"u"?"vector":window.localStorage.getItem("solver-utils-renderer")==="canvas"?"canvas":"vector"),[l,u]=ee.useState(n),g=ee.useMemo(()=>{try{return a.visualize()||{points:[],lines:[],rects:[],circles:[]}}catch(f){return console.error("Visualization error:",f),{points:[],lines:[],rects:[],circles:[]}}},[a,r]),h=ee.useMemo(()=>(g.rects?.length||0)===0&&(g.lines?.length||0)===0&&(g.points?.length||0)===0&&(g.circles?.length||0)===0,[g]);ee.useEffect(()=>{if(!(typeof document>"u")&&!document.querySelector('script[src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4"]')){const f=document.createElement("script");f.src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4",document.head.appendChild(f)}},[]),ee.useEffect(()=>{u(n)},[n]);const d=a.pipelineDef!==void 0,p=f=>{const I=a;if(!a.solved&&!a.failed){for(;!a.solved&&!a.failed&&I.currentPipelineStageIndex<=I.pipelineDef.findIndex(C=>C.solverName===f);)a.step();s()}},m=()=>{const f=JSON.stringify(g,null,2),I=new Blob([f],{type:"application/json"}),C=URL.createObjectURL(I),y=document.createElement("a");y.download="visualization.json",y.href=C,document.body.appendChild(y),y.click(),document.body.removeChild(y),URL.revokeObjectURL(C)},_=f=>{c(f),typeof window<"u"&&window.localStorage.setItem("solver-utils-renderer",f)};return K.jsxs("div",{children:[K.jsx(NOi,{solver:a,triggerRender:s,animationSpeed:l,renderer:A,onRendererChange:_,onAnimationSpeedChange:u,onDownloadVisualization:m,onSolverStarted:o,onSolverCompleted:i}),h?K.jsx("div",{className:"p-4 text-gray-500",children:"No Graphics Yet"}):K.jsx(KOi,{fallback:K.jsx(UOi,{graphics:g}),children:A==="canvas"?K.jsx(POi,{graphics:g}):K.jsx(QOi,{graphics:g})}),d&&K.jsx(Uhn,{solver:a,onStepUntilPhase:p,triggerRender:s})]})};const zOi=()=>{ee.useEffect(()=>{const t="tailwind-cdn-script";if(document.getElementById(t)||window.tailwind)return;const e=document.createElement("div");e.className="hidden",document.body.appendChild(e);const n=window.getComputedStyle(e).display==="none";if(document.body.removeChild(e),n)return;const o=document.createElement("script");o.id=t,o.src="https://cdn.tailwindcss.com",document.head.appendChild(o)},[])},JOi=1e3,NE=(t,e)=>{const{fileName:n,mimeType:o="text/plain"}=e,i=t instanceof Blob?t:new Blob([t],{type:o}),r=URL.createObjectURL(i),s=document.createElement("a");s.href=r,s.download=n,s.target="_blank",s.rel="noopener noreferrer",s.style.display="none",document.body.appendChild(s),s.click(),document.body.removeChild(s),setTimeout(()=>{URL.revokeObjectURL(r)},JOi)},b$e=t=>{let e=t.trim().replace(/[\\/:*?"<>|]/g,"_").replace(/[\x00-\x1f]/g,"").replace(/^\.+/,"").replace(/\.+$/,"").replace(/\s+/g," ").replace(/_+/g,"_");return/^(con|prn|aux|nul|com[0-9]|lpt[0-9])$/i.test(e)&&(e=`_${e}`),e=e.slice(0,200),e||"untitled"},WOi=t=>{const e=t.solverConstructorArgs??[t.solverParams];if(t.solverName!=="AutoroutingPipelineSolver7_MultiGraph"||e.length!==1)return e;const[{input:n,options:o}]=e;return[n,o]},e8="https://github.com/tscircuit/tscircuit-autorouter/issues/new",Khn="https://github.com/tscircuit/copper-pour-solver/issues/new",Vhn="https://github.com/tscircuit/calculate-packing/issues/new",jOi="https://github.com/tscircuit/matchpack/issues/new",zhn="https://github.com/tscircuit/schematic-trace-solver/issues/new?template=json-bug-report.yml",$Oi={PackSolver2:Vhn,LayoutPipelineSolver:jOi,AutoroutingPipelineSolver:e8,AssignableAutoroutingPipeline2:e8,AssignableAutoroutingPipeline3:e8,AutoroutingPipeline1_OriginalUnravel:e8,AutoroutingPipelineSolver3_HgPortPointPathing:e8,AutoroutingPipelineSolver4:e8,AutoroutingPipelineSolver5:e8,AutoroutingPipelineSolver7_MultiGraph:e8,AutoroutingPipelineSolver8:e8,CopperPourPipelineSolver:Khn,SchematicTracePipelineSolver:zhn},qOi=t=>t.toLowerCase().includes("pack")?tln:t.toLowerCase().includes("rout")?oln:z8i,Jhn=t=>{const e=$Oi[t];if(e)return e;const n=t.toLowerCase();return n.includes("autorout")?e8:n.includes("schematic")&&n.includes("trace")?zhn:n.includes("copperpour")?Khn:n.includes("pack")?Vhn:null},XOi=t=>`${b$e(`${t.componentName}-${t.solverName}`)}-solver-input.json`,Whn=t=>{NE(JSON.stringify(t.solverParams,null,2),{fileName:XOi(t),mimeType:"application/json"})},ZOi=({solverEvent:t})=>{const e=Jhn(t.solverName);return K.jsxs("div",{className:"rf-flex rf-items-center rf-justify-end rf-gap-2 rf-border-b rf-border-gray-200 rf-bg-gray-50 rf-px-4 rf-py-2",children:[K.jsxs(fA,{type:"button",variant:"outline",size:"sm",onClick:()=>Whn(t),children:[K.jsx(uZ,{className:"rf-w-4 rf-h-4"}),"Download"]}),e?K.jsx(fA,{asChild:!0,variant:"outline",size:"sm",children:K.jsxs("a",{href:e,target:"_blank",rel:"noopener noreferrer",children:[K.jsx(yme,{className:"rf-w-4 rf-h-4"}),"Report"]})}):K.jsxs(fA,{type:"button",variant:"outline",size:"sm",disabled:!0,title:"No report link configured for this solver",children:[K.jsx(yme,{className:"rf-w-4 rf-h-4"}),"Report"]})]})},eGi=({solverEvent:t})=>{const e=Jhn(t.solverName);return e?K.jsx(fA,{asChild:!0,variant:"ghost",size:"icon",className:"rf-h-8 rf-w-8",children:K.jsx("a",{href:e,target:"_blank",rel:"noopener noreferrer",title:"Report solver bug","aria-label":"Report solver bug",children:K.jsx(yme,{className:"rf-w-4 rf-h-4"})})}):K.jsx(fA,{type:"button",variant:"ghost",size:"icon",className:"rf-h-8 rf-w-8",disabled:!0,title:"No report link configured for this solver","aria-label":"Report solver bug",children:K.jsx(yme,{className:"rf-w-4 rf-h-4"})})},tGi=({solverEvents:t=[]})=>{const[e,n]=ee.useState(null);zOi();const o=ee.useMemo(()=>{const a=new Map;for(const A of t){const c=`${A.componentName}-${A.solverName}`;a.set(c,A)}return a},[t]),i=ee.useMemo(()=>Array.from(o.keys()),[o]),r=e?o.get(e):null,s=ee.useMemo(()=>{if(!r)return{instance:null,error:null,classFound:!1};const a=gMe[r.solverName];if(!a)return{instance:null,error:`Solver class "${r.solverName}" not found in SOLVERS registry. Available: ${Object.keys(gMe).join(", ")}`,classFound:!1};try{return{instance:new a(...WOi(r)),error:null,classFound:!0}}catch(A){const c=A instanceof Error?A.message:String(A);return console.error("Failed to reconstruct solver:",A),{instance:null,error:`Failed to instantiate solver: ${c}`,classFound:!0}}},[r]);return t.length===0?K.jsx("div",{className:"rf-p-4",children:K.jsx("div",{className:"rf-bg-gray-50 rf-rounded-md rf-border rf-border-gray-200",children:K.jsxs("div",{className:"rf-p-4",children:[K.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800 rf-mb-3",children:"No Solvers Detected"}),K.jsx("p",{className:"rf-text-sm rf-text-gray-600",children:"Solvers will appear here when the circuit runs. Solvers are used for tasks like component packing and autorouting."})]})})}):K.jsxs("div",{className:"rf-flex rf-h-full rf-overflow-hidden",children:[K.jsxs("div",{className:"rf-w-64 rf-border-r rf-border-gray-200 rf-overflow-y-auto rf-flex-shrink-0",children:[K.jsxs("div",{className:"rf-text-xs rf-font-semibold rf-text-gray-500 rf-px-3 rf-py-2 rf-bg-gray-50 rf-border-b rf-border-gray-200",children:[i.length," ",i.length===1?"Solver":"Solvers"]}),i.map(a=>{const A=o.get(a),c=e===a;return K.jsx("div",{className:`rf-px-3 rf-py-2 rf-cursor-pointer rf-border-b rf-border-gray-100 ${c?"rf-bg-blue-50 rf-border-l-2 rf-border-l-blue-500":"hover:rf-bg-gray-50"}`,onClick:()=>n(a),children:(()=>{const l=qOi(A.solverName);return K.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2",children:[K.jsx(l,{className:"rf-w-4 rf-h-4 rf-text-blue-500 rf-flex-shrink-0"}),K.jsxs("div",{className:"rf-flex-1 rf-min-w-0",children:[K.jsx("div",{className:"rf-text-sm rf-font-medium rf-text-gray-800 rf-truncate",children:A.componentName}),K.jsx("div",{className:"rf-text-xs rf-text-gray-500 rf-truncate",children:A.solverName})]})]})})()},a)})]}),K.jsx("div",{className:"rf-flex-1 rf-overflow-hidden",children:r?s.instance?K.jsxs("div",{className:"rf-flex rf-h-full rf-flex-col rf-overflow-y-auto",children:[K.jsx(ZOi,{solverEvent:r}),K.jsx("div",{className:"rf-min-h-0 rf-flex-1",children:K.jsx(yE,{fallback:K.jsx("div",{className:"rf-p-4",children:K.jsxs("div",{className:"rf-bg-red-50 rf-rounded-md rf-border rf-border-red-200 rf-p-4",children:[K.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-red-800 rf-mb-2",children:"Error Loading Solver Debugger"}),K.jsxs("p",{className:"rf-text-sm rf-text-red-600",children:["Failed to render the solver debugger for"," ",r.solverName]})]})}),children:K.jsx(VOi,{solver:s.instance})})})]}):K.jsxs("div",{className:"rf-p-4",children:[K.jsxs("div",{className:"rf-mb-4",children:[K.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800",children:r.solverName}),K.jsxs("p",{className:"rf-text-sm rf-text-gray-500",children:["Component: ",r.componentName]})]}),s.error&&K.jsx("div",{className:`rf-rounded-md rf-border rf-p-4 rf-mb-4 ${s.classFound?"rf-bg-red-50 rf-border-red-200":"rf-bg-yellow-50 rf-border-yellow-200"}`,children:K.jsx("p",{className:`rf-text-sm ${s.classFound?"rf-text-red-700":"rf-text-yellow-700"}`,children:s.error})}),K.jsxs("div",{className:"rf-border rf-border-gray-200 rf-rounded-md rf-overflow-hidden",children:[K.jsxs("div",{className:"rf-px-3 rf-py-2 rf-bg-gray-50 rf-flex rf-items-center rf-justify-between rf-gap-2",children:[K.jsx("span",{className:"rf-text-sm rf-font-medium rf-text-gray-700",children:"Solver Parameters"}),K.jsxs("div",{className:"rf-flex rf-items-center rf-gap-1",children:[K.jsx(eGi,{solverEvent:r}),K.jsx(fA,{type:"button",variant:"ghost",size:"icon",className:"rf-h-8 rf-w-8","aria-label":"Download solver input JSON",title:"Download solver input JSON",onClick:()=>Whn(r),children:K.jsx(uZ,{className:"rf-w-4 rf-h-4"})})]})]}),K.jsx("div",{className:"rf-p-3 rf-bg-white rf-border-t rf-border-gray-200",children:K.jsx("pre",{className:"rf-text-xs rf-font-mono rf-text-gray-600 rf-whitespace-pre-wrap rf-overflow-x-auto",children:JSON.stringify(r.solverParams,null,2)})})]})]}):K.jsx("div",{className:"rf-flex rf-items-center rf-justify-center rf-h-full",children:K.jsx("p",{className:"rf-text-sm rf-text-gray-500",children:"Select a solver from the list to view details"})})})]})},nGi=["subcircuit_id","componentDisplayName","phaseName","routingPhaseIndex","phaseOrdinal","phaseCount","phaseStageIndex","phaseStageCount","connectionCount","obstacleCount","previousTraceCount","isReroutePhase","autorouterName","autorouterVersion","solverName","effort","cacheStatus"],oGi=["phaseOrdinal","routingPhaseIndex","phaseName","phaseStageIndex"];function iGi(t,e){let n=-1,o=-1;for(let i=t.length-1;i>=0;i--){const r=t[i];if(r.status!=="running"||r.subcircuit_id!==e.subcircuit_id||r.componentDisplayName!==e.componentDisplayName)continue;let s=0,a=!1;for(const A of oGi)if(!(r[A]===void 0||e[A]===void 0)){if(r[A]!==e[A]){a=!0;break}s++}!a&&s>o&&(n=i,o=s)}return n}function rGi(t,e){const n=Object.fromEntries(nGi.filter(s=>e[s]!==void 0).map(s=>[s,e[s]])),o=e.simpleRouteJson?structuredClone(e.simpleRouteJson):void 0,i=e.type==="autorouting:start"?-1:iGi(t,e),r={...i===-1?{id:`autorouting_phase_${t.length+1}`}:t[i],...n,status:e.type==="autorouting:start"?"running":e.type==="autorouting:end"?"complete":"error",...e.type==="autorouting:start"?{startSimpleRouteJson:o}:e.type==="autorouting:end"?{endSimpleRouteJson:o}:{errorSimpleRouteJson:o,error:e.error?{...e.error}:void 0}};return i===-1?[...t,r]:t.map((s,a)=>a===i?r:s)}const sGi=new Map([["custom","Custom"],["fanout","Fanout"],["single_layer_fanout","Single layer fanout"],["tscircuit_simplify","Simplify"]]),aGi=new Set(["tscircuit","default","auto","auto_local"]);function AGi(t){if(t==="FanoutSolver")return"Fanout";if(t==="AutoroutingPipelineSolver11_Simplification")return"Simplify";const e=t.match(/^AutoroutingPipeline(?:Solver)?(\d+)(?:_|$)/);if(e)return`Pipeline${e[1]}`;const n=t.match(/^AssignableAutoroutingPipeline(\d+)$/);return n?`Assignable${n[1]}`:t}function cGi(t){const e=t.autorouterName?.trim(),n=e?.replace(/-/g,"_"),o=n&&sGi.get(n);if(o)return o;if(n&&!aGi.has(n))return e;const i=t.solverName?.trim();if(i)return AGi(i);const r=t.autorouterVersion?.trim();if(r){const s=r.match(/^beta[_-]pipeline(\d+)$/);return s?`Pipeline${s[1]}`:r==="latest"?"default":r}return e?"default":"Unknown"}const S$e="#fbbf24";function lGi(t){const e=t.endSimpleRouteJson?.traces??[],n=new Set(e.flatMap(i=>[i.pcb_trace_id,i.__replaces_pcb_trace_id].filter(r=>r!==void 0)));return[...(t.startSimpleRouteJson?.traces??[]).filter(i=>!n.has(i.pcb_trace_id)),...e]}function jhn(t){const e=new Map((t.startSimpleRouteJson?.traces??[]).map(n=>[n.pcb_trace_id,n]));return(t.endSimpleRouteJson?.traces??[]).filter(n=>{const o=e.get(n.pcb_trace_id);return!o||!!n.__replaces_pcb_trace_id&&n.__replaces_pcb_trace_id!==o.__replaces_pcb_trace_id||JSON.stringify(o.route)!==JSON.stringify(n.route)}).map(n=>n.pcb_trace_id)}function uGi(t,e){return{outer_diameter:t.via_diameter??e.minViaPadDiameter??e.min_via_pad_diameter??e.minViaDiameter??.6,hole_diameter:t.via_hole_diameter??e.minViaHoleDiameter??e.min_via_hole_diameter??.3}}function $hn(t,e){const n=[];for(const a of t.route)a.route_type==="wire"?n.push({...a,layer:a.layer}):a.route_type==="via"?n.push({route_type:"via",x:a.x,y:a.y,from_layer:a.from_layer,to_layer:a.to_layer,...uGi(a,e)}):a.route_type==="through_obstacle"&&n.push({route_type:"through_pad",start:{...a.start},end:{...a.end},width:a.width,start_layer:a.from_layer,end_layer:a.to_layer,pcb_smtpad_id:a.circuitJsonMetadata?.pcb_smtpad_id,pcb_plated_hole_id:a.circuitJsonMetadata?.pcb_plated_hole_id});const o=a=>{let A=-1,c=Number.POSITIVE_INFINITY;return n.forEach((l,u)=>{if(l.route_type!=="wire")return;const g=Math.hypot(l.x-a.x,l.y-a.y);g<c&&(c=g,A=u)}),A},i=t.route.filter(a=>a.route_type==="jumper").map(a=>[o(a.start),o(a.end)].sort((A,c)=>A-c)).filter(([a,A])=>a>=0&&A>a).sort(([a],[A])=>a-A),r=[];let s=0;for(const[a,A]of i)a>=s&&r.push(n.slice(s,a+1)),s=Math.max(s,A);return s<n.length&&r.push(n.slice(s)),r}function gGi(t){const e=[],n=[],o=t.endSimpleRouteJson;if(!o)return{lines:e,circles:n};const i=new Set(jhn(t));for(const r of o.traces??[])if(i.has(r.pcb_trace_id))for(const s of $hn(r,o)){let a;for(const A of s){if(A.route_type==="through_pad"){a={...A.end,layer:A.end_layer,width:A.width};continue}const c=A.route_type==="wire"?A.layer:A.from_layer;a&&a.layer===c&&(a.x!==A.x||a.y!==A.y)&&e.push({points:[{x:a.x,y:a.y},{x:A.x,y:A.y}],strokeWidth:A.route_type==="wire"?A.width:a.width,strokeColor:S$e,layer:c}),A.route_type==="via"&&n.push({center:{x:A.x,y:A.y},radius:A.outer_diameter/2,stroke:S$e,fill:"transparent"}),a={x:A.x,y:A.y,layer:A.route_type==="wire"?A.layer:A.to_layer,width:A.route_type==="wire"?A.width:a?.width??o.minTraceWidth}}}return{coordinateSystem:"cartesian",lines:e,circles:n}}function dGi(t){const e=JSON.stringify(t);let n=2166136261;for(let o=0;o<e.length;o++)n=Math.imul(n^e.charCodeAt(o),16777619);return(n>>>0).toString(36)}const hGi=new Set(["pcb_trace","pcb_via","pcb_copper_pour","pcb_ground_plane","pcb_ground_plane_region","pcb_thermal_spoke","pcb_breakout_point"]);function pGi(t,e,n){const o=n==="input"?e.startSimpleRouteJson??e.errorSimpleRouteJson:e.endSimpleRouteJson,i=t.filter(c=>!hGi.has(c.type)&&!c.type.endsWith("_error")&&!c.type.endsWith("_warning"));if(!o)return i;const r=n==="input"?o.traces??[]:lGi(e),s=new Set(t.filter(c=>c.type==="source_trace").map(c=>c.source_trace_id)),a=["top",...Array.from({length:Math.max(0,o.layerCount-2)},(c,l)=>`inner${l+1}`),...o.layerCount>1?["bottom"]:[]],A=[];for(const c of r){const u=o.connections.find(h=>h.name===c.connection_name||h.source_trace_id===c.connection_name)?.source_trace_id??c.connection_name??"",g=$hn(c,o);for(const[h,d]of g.entries()){const p={type:"pcb_trace",pcb_trace_id:`${e.id}_${n}_${c.pcb_trace_id}_${h}_${dGi(d)}`,subcircuit_id:e.subcircuit_id??void 0,source_trace_id:s.has(u)?u:void 0,route:d};A.push(p);for(const[m,_]of d.entries()){if(_.route_type!=="via")continue;const f=a.indexOf(_.from_layer),I=a.indexOf(_.to_layer),C={type:"pcb_via",pcb_via_id:`${p.pcb_trace_id}_via_${m}`,pcb_trace_id:p.pcb_trace_id,subcircuit_id:e.subcircuit_id??void 0,x:_.x,y:_.y,outer_diameter:_.outer_diameter,hole_diameter:_.hole_diameter,layers:f>=0&&I>=0?a.slice(Math.min(f,I),Math.max(f,I)+1):[_.from_layer,_.to_layer]};A.push(C)}}}return[...i,...A]}const Q$e=(t,e)=>t.phaseName||`Phase ${t.phaseOrdinal??e+1}`,qhn=t=>t.componentDisplayName?.match(/name="([^"]+)"/)?.[1]?.replace(/^\./,"")||t.componentDisplayName||t.subcircuit_id||"Board",Xhn=t=>t.startSimpleRouteJson??t.endSimpleRouteJson??t.errorSimpleRouteJson,mGi={is_showing_autorouting:!0,is_showing_rats_nest:!1,is_showing_drc_errors:!1,is_showing_drc_warnings:!1,is_showing_pcb_groups:!1},_Gi=({circuitJson:t,phases:e=[],isRunning:n=!1})=>{const[o,i]=ee.useState(null),[r,s]=ee.useState("output"),[a,A]=ee.useState(!0),[c,l]=ee.useState(!1),u=ee.useRef(null),[g,h]=ee.useState(480),d=o?e.findIndex(R=>R.id===o.id&&Xhn(R)===Xhn(o)):-1,p=d<0?e.length-1:d,m=e[p],_=d<0,f=!!m?.endSimpleRouteJson,I=m?.startSimpleRouteJson??m?.errorSimpleRouteJson,C=!!I,y=r==="output"&&!f?"input":r==="input"&&!C?"output":r,x=y==="input"?I:m?.endSimpleRouteJson,E=ee.useMemo(()=>!m||!x?null:pGi(t??[],m,y),[t,m,x,y]),B=ee.useMemo(()=>m&&y==="output"&&a?gGi(m):{lines:[],circles:[]},[m,y,a]);if(ee.useLayoutEffect(()=>{const R=u.current;if(!R)return;const F=()=>h(Math.max(360,R.clientHeight));F();const O=new ResizeObserver(F);return O.observe(R),()=>O.disconnect()},[!!m]),!m)return K.jsxs("div",{className:"rf-flex rf-min-h-[400px] rf-flex-col rf-items-center rf-justify-center rf-gap-3 rf-p-8 rf-text-center",children:[K.jsx(oln,{className:"rf-h-7 rf-w-7 rf-text-blue-500"}),K.jsx("h3",{className:"rf-text-base rf-font-medium",children:n?"Waiting for autorouting":"No autorouting captures"}),K.jsx("p",{className:"rf-max-w-md rf-text-sm rf-text-gray-500",children:n?"Phases appear as the circuit routes. Each capture includes its input and output on the PCB.":"Run a circuit with autorouting enabled to inspect its phases. A circuit JSON file alone does not include routing history."})]});const S=Q$e(m,p),Q=m.status==="running"&&n,w=!f,M=I?.connections.length,k=E?.filter(R=>R.type==="pcb_trace").length??0;return K.jsxs("div",{className:"rf-flex rf-h-full rf-min-h-[620px] rf-flex-col rf-bg-white md:rf-flex-row","data-testid":"autorouting-explorer",children:[K.jsxs("aside",{className:"rf-flex rf-shrink-0 rf-flex-col rf-border-b rf-border-gray-200 md:rf-w-52 md:rf-border-b-0 md:rf-border-r","aria-label":"Routing phases",children:[K.jsxs("div",{className:"rf-flex rf-items-center rf-justify-between rf-px-3 rf-py-2 rf-text-xs rf-text-gray-500",children:[K.jsx("span",{children:"Routing phases"}),K.jsx("span",{children:e.length})]}),K.jsx("div",{className:"rf-flex rf-gap-1 rf-overflow-x-auto rf-px-1.5 rf-pb-1.5 md:rf-flex-col md:rf-overflow-x-hidden md:rf-overflow-y-auto",children:e.map((R,F)=>{const O=jhn(R).length,U=R.endSimpleRouteJson?`${O} ${O===1?"trace":"traces"} routed`:R.status==="error"?"Failed":R.status==="running"&&n?"Routing…":"No output";return K.jsxs("button",{type:"button","aria-pressed":F===p,title:`${qhn(R)} · ${U}`,onClick:()=>i(R),className:Hi("rf-flex rf-min-w-[192px] rf-items-start rf-gap-2 rf-rounded-md rf-border rf-px-2 rf-py-2 rf-text-left md:rf-min-w-0",F===p?"rf-border-blue-200 rf-bg-blue-50":"rf-border-transparent hover:rf-bg-gray-50"),children:[K.jsx("span",{className:Hi("rf-flex rf-h-5 rf-w-5 rf-shrink-0 rf-items-center rf-justify-center rf-rounded-full rf-text-[11px]",F===p?"rf-bg-blue-600 rf-text-white":"rf-bg-gray-100 rf-text-gray-500"),children:F+1}),K.jsxs("span",{className:"rf-min-w-0 rf-flex-1",children:[K.jsxs("span",{className:"rf-flex rf-items-center rf-gap-1",children:[K.jsx("span",{className:"rf-min-w-0 rf-flex-1 rf-truncate rf-text-xs rf-font-medium rf-leading-5 rf-text-gray-800",title:Q$e(R,F),children:Q$e(R,F)}),R.status==="complete"?K.jsx(IS,{"aria-label":"Captured",className:"rf-h-3 rf-w-3 rf-shrink-0 rf-text-green-600"}):R.status==="error"?K.jsx(XJe,{"aria-label":"Failed",className:"rf-h-3 rf-w-3 rf-shrink-0 rf-text-red-500"}):n?K.jsx(xE,{"aria-label":"Routing",className:"rf-h-3 rf-w-3 rf-shrink-0 rf-animate-spin rf-text-blue-500"}):null]}),K.jsxs("span",{className:"rf-block rf-text-[11px] rf-leading-4 rf-text-gray-500",children:[cGi(R)," · ",U]})]})]},R.id)})})]}),K.jsxs("div",{className:"rf-flex rf-min-w-0 rf-flex-1 rf-flex-col",children:[K.jsxs("div",{className:"rf-flex rf-flex-wrap rf-items-center rf-gap-3 rf-border-b rf-border-gray-200 rf-px-4 rf-py-3",children:[K.jsxs("h3",{className:"rf-mr-auto rf-flex rf-items-center rf-gap-2 rf-text-sm rf-font-medium",children:[S,K.jsxs("span",{className:"rf-text-xs rf-font-normal rf-text-gray-500",children:[p+1," of ",e.length]})]}),n&&K.jsx("button",{type:"button",onClick:()=>i(null),disabled:_,className:"rf-text-xs rf-text-blue-600 disabled:rf-text-gray-500",children:_?"Following latest":"Follow latest"}),K.jsx("div",{className:"rf-flex rf-rounded-md rf-bg-gray-100 rf-p-1","aria-label":"Phase snapshot",children:["input","output"].map(R=>K.jsx("button",{type:"button","aria-pressed":y===R,disabled:R==="input"?!C:!f,onClick:()=>s(R),className:Hi("rf-rounded rf-px-3 rf-py-1 rf-text-xs disabled:rf-opacity-40",y===R?"rf-bg-white rf-text-gray-900 rf-shadow-sm":"rf-text-gray-500"),children:R==="input"?"Input":"Output"},R))})]}),K.jsxs("div",{className:"rf-flex rf-flex-wrap rf-items-center rf-justify-between rf-gap-2 rf-px-4 rf-py-2 rf-text-xs rf-text-gray-600",children:[K.jsxs("label",{className:"rf-flex rf-items-center rf-gap-2",children:[K.jsx("input",{type:"checkbox",checked:a,disabled:y!=="output",onChange:R=>A(R.target.checked),className:"rf-accent-blue-600"}),K.jsx("span",{"aria-hidden":"true",className:"rf-inline-block rf-h-0.5 rf-w-3",style:{backgroundColor:S$e}}),"Highlight changes (all layers)"]}),K.jsxs("span",{children:[y==="input"?"Before this phase":"After this phase"," ","· ",k," traces"]})]}),w&&K.jsx("div",{className:Hi("rf-border-y rf-px-4 rf-py-2 rf-text-xs",m.status==="error"?"rf-border-red-100 rf-bg-red-50 rf-text-red-700":"rf-border-blue-100 rf-bg-blue-50 rf-text-blue-700"),role:"status",children:m.status==="error"?`Routing failed: ${m.error?.message||"No output was captured."}`:Q?"Routing in progress. Showing captured input until output is available.":"No output was captured for this phase. Showing the available input."}),K.jsx("div",{ref:u,className:"rf-relative rf-min-h-[360px] rf-flex-1","data-testid":"autorouting-pcb",children:E?K.jsx(f$e,{circuitJson:E,height:g,allowEditing:!1,clickToInteractEnabled:!1,initialState:mGi,debugGraphics:B}):K.jsx("div",{className:"rf-p-6 rf-text-sm rf-text-gray-500",children:"No PCB snapshot available for this capture."})}),K.jsxs("div",{className:"rf-flex rf-flex-wrap rf-items-center rf-justify-between rf-gap-2 rf-border-t rf-border-gray-200 rf-px-4 rf-py-3 rf-text-xs rf-text-gray-500",children:[K.jsxs("span",{children:[M===void 0?"Input unavailable":`${M} input connections`,` · ${qhn(m)}`]}),K.jsxs("div",{className:"rf-flex rf-items-center rf-gap-4",children:[K.jsxs("button",{type:"button",disabled:!x,onClick:()=>NE(JSON.stringify(x,null,2),{fileName:`${m.id}-${y}.srj.json`,mimeType:"application/json"}),className:"rf-flex rf-items-center rf-gap-1 disabled:rf-opacity-40",children:[K.jsx(uZ,{className:"rf-h-3 rf-w-3"}),"Download SRJ"]}),K.jsxs("button",{type:"button","aria-expanded":c,onClick:()=>l(!c),className:"rf-flex rf-items-center rf-gap-1",children:[K.jsx(xT,{className:Hi("rf-h-3 rf-w-3",c&&"rf-rotate-90")}),"Inspect SRJ"]})]})]}),c&&K.jsx("pre",{className:"rf-m-0 rf-max-h-64 rf-overflow-auto rf-border-t rf-border-gray-200 rf-bg-gray-50 rf-p-4 rf-text-xs","aria-label":`${S} ${y} SRJ`,children:x?JSON.stringify(x,null,2):"No snapshot captured."})]})]})},Zhn=({errorMessage:t,errorStack:e,circuitJsonErrors:n})=>{ee.useEffect(()=>{if(t){const o=new Error(t);e&&(o.stack=e);try{aG.captureException(o)}catch{}}},[t,e]),ee.useEffect(()=>{if(n&&n.length>0)for(const o of n){const i=new Error(o.message||"Circuit JSON Error");o.stack&&(i.stack=o.stack);try{aG.captureException(i,{error_type:o.type})}catch{}}},[n])},epn=t=>{ee.useEffect(()=>{try{pUo(t)}catch{}},[t.source,t.component,t.isWebEmbedded,t.activeTab])},tpn="0.0.2833",fGi={version:tpn},ufe=AFt()(cFt(t=>({lastRunEvalVersion:void 0,setLastRunEvalVersion:e=>{t({lastRunEvalVersion:e})}}),{name:"runframe-runner-store"})),IGi=t=>{const[e,n]=ee.useState([]),[o,i]=ee.useState(null),[r,s]=ee.useState(""),[a,A]=TO("eval-version-selection",null),c=ufe(h=>h.setLastRunEvalVersion),l=ufe(h=>h.lastRunEvalVersion);return ee.useEffect(()=>{t&&fetch("https://data.jsdelivr.com/v1/package/npm/@tscircuit/eval").then(h=>h.json()).then(h=>{if(Array.isArray(h?.versions)){let d=[...h.versions];h.tags?.latest&&(i(h.tags.latest),d=d.filter(p=>p!==h.tags.latest)),n(d)}}).catch(()=>{})},[t]),ee.useEffect(()=>{t&&(a?(window.TSCIRCUIT_LATEST_EVAL_VERSION=a,c(a)):o&&(window.TSCIRCUIT_LATEST_EVAL_VERSION=o,c(o)))},[t,a,o]),{versions:ee.useMemo(()=>e.filter(h=>h.includes(r)).slice(0,50),[e,r]),latestVersion:o,lastRunEvalVersion:l,search:r,setSearch:s,selectVersion:h=>{A(h),s("")}}},CGi=({snippetNames:t,onSelect:e,onCancel:n,isOpen:o})=>{const[i,r]=ee.useState(""),[s,a]=ee.useState("");if(!o)return null;const A=t.filter(u=>u.toLowerCase().includes(s.toLowerCase())),c=s&&!t.includes(s),l=u=>{u.key==="Enter"&&(A.length===1?r(A[0]):c&&r(s))};return K.jsx("div",{className:"rf-fixed rf-inset-0 rf-bg-black rf-bg-opacity-50 rf-flex rf-items-center rf-justify-center rf-z-[100]",children:K.jsxs("div",{className:"rf-bg-white rf-rounded-lg rf-p-6 rf-w-96",children:[K.jsx("h2",{className:"rf-text-lg rf-font-semibold rf-mb-4",children:"Select Snippet"}),K.jsx("input",{type:"text",className:"rf-w-full rf-px-4 rf-py-2 rf-border rf-rounded rf-mb-4",placeholder:"Search snippets or new snippet name...",value:s,onChange:u=>a(u.target.value),onKeyDown:l}),K.jsxs("div",{className:"rf-h-60 rf-overflow-y-auto",children:[A.map(u=>K.jsx("button",{type:"button",className:`w-full text-left px-4 py-2 rounded hover:bg-gray-100 ${i===u?"bg-blue-50":""}`,onClick:()=>r(u),children:u},u)),c&&K.jsxs("button",{type:"button",className:`w-full text-left px-4 py-2 rounded hover:bg-gray-100 text-blue-500 ${i===s?"bg-blue-50":""}`,onClick:()=>r(s),children:['Create new "',s,'"']})]}),K.jsxs("div",{className:"rf-mt-4 rf-flex rf-justify-end rf-gap-2",children:[K.jsx("button",{type:"button",className:"rf-px-4 rf-py-2 rf-text-gray-600 rf-hover:text-gray-800",onClick:n,children:"Cancel"}),K.jsx("button",{type:"button",className:"rf-px-4 rf-py-2 rf-bg-blue-500 rf-text-white rf-rounded rf-hover:bg-blue-600 rf-disabled:opacity-50",onClick:()=>i&&e(i),disabled:!i,children:i===s?`Create "${i}"`:`Save to ${i}`})]})]})})},yGi=t=>{const e=ee.useRef(null),n=md(o=>o.recentEvents);ee.useEffect(()=>{if(n.length===0)return;const o=n[0];o.event_id!==e.current&&(t(o),e.current=o.event_id)},[n,t])};var xGi=Object.defineProperty,QS=(t,e)=>xGi(t,"name",{value:e,configurable:!0}),EGi="AlertDialog",[BGi,lmr]=Dx(EGi,[v0n]),vS=v0n(),bGi=QS(t=>{const{__scopeAlertDialog:e,...n}=t,o=vS(e);return K.jsx(n_e,{...o,...n,modal:!0})},"AlertDialog");ee.forwardRef(QS(function(e,n){const{__scopeAlertDialog:o,...i}=e,r=vS(o);return K.jsx(zvi,{...r,...i,ref:n})},"AlertDialogTrigger"));var SGi=QS(t=>{const{__scopeAlertDialog:e,...n}=t,o=vS(e);return K.jsx(o_e,{...o,...n})},"AlertDialogPortal"),QGi=ee.forwardRef(QS(function(e,n){const{__scopeAlertDialog:o,...i}=e,r=vS(o);return K.jsx(bZ,{...r,...i,ref:n})},"AlertDialogOverlay")),vGi="AlertDialogContent",[wGi,PGi]=BGi(vGi),MGi=ee.forwardRef(QS(function(e,n){const{__scopeAlertDialog:o,children:i,...r}=e,s=vS(o),a=ee.useRef(null),A=$A(n,a),c=ee.useRef(null);return K.jsx(wGi,{scope:o,cancelRef:c,children:K.jsx(QZ,{role:"alertdialog",...s,...r,ref:A,onOpenAutoFocus:ar(r.onOpenAutoFocus,l=>{l.preventDefault(),c.current?.focus({preventScroll:!0})}),onPointerDownOutside:l=>l.preventDefault(),onInteractOutside:l=>l.preventDefault(),children:i})})},"AlertDialogContent")),DGi=ee.forwardRef(QS(function(e,n){const{__scopeAlertDialog:o,...i}=e,r=vS(o);return K.jsx(i_e,{...r,...i,ref:n})},"AlertDialogTitle")),NGi=ee.forwardRef(QS(function(e,n){const{__scopeAlertDialog:o,...i}=e,r=vS(o);return K.jsx(r_e,{...r,...i,ref:n})},"AlertDialogDescription")),RGi=ee.forwardRef(QS(function(e,n){const{__scopeAlertDialog:o,...i}=e,r=vS(o);return K.jsx(LWe,{...r,...i,ref:n})},"AlertDialogAction")),TGi="AlertDialogCancel",kGi=ee.forwardRef(QS(function(e,n){const{__scopeAlertDialog:o,...i}=e,{cancelRef:r}=PGi(TGi,o),s=vS(o),a=$A(n,r);return K.jsx(LWe,{...s,...i,ref:a})},"AlertDialogCancel")),FGi=bGi,LGi=SGi,npn=QGi,opn=MGi,ipn=RGi,rpn=kGi,spn=DGi,apn=NGi;const Apn=FGi,HGi=LGi,cpn=ee.forwardRef(({className:t,...e},n)=>K.jsx(npn,{className:Hi("rf-fixed rf-inset-0 rf-z-50 rf-bg-black/80 data-[state=open]:rf-animate-in data-[state=closed]:rf-animate-out data-[state=closed]:rf-fade-out-0 data-[state=open]:rf-fade-in-0",t),...e,ref:n}));cpn.displayName=npn.displayName;const v$e=ee.forwardRef(({className:t,...e},n)=>K.jsxs(HGi,{children:[K.jsx(cpn,{}),K.jsx(opn,{ref:n,className:Hi("rf-fixed rf-left-[50%] rf-top-[50%] rf-z-50 rf-grid rf-w-full rf-max-w-lg rf-translate-x-[-50%] rf-translate-y-[-50%] rf-gap-4 rf-border rf-border-zinc-200 rf-bg-white rf-p-6 rf-shadow-lg rf-duration-200 data-[state=open]:rf-animate-in data-[state=closed]:rf-animate-out data-[state=closed]:rf-fade-out-0 data-[state=open]:rf-fade-in-0 data-[state=closed]:rf-zoom-out-95 data-[state=open]:rf-zoom-in-95 data-[state=closed]:rf-slide-out-to-left-1/2 data-[state=closed]:rf-slide-out-to-top-[48%] data-[state=open]:rf-slide-in-from-left-1/2 data-[state=open]:rf-slide-in-from-top-[48%] sm:rf-rounded-lg dark:rf-border-zinc-800 dark:rf-bg-zinc-950",t),...e})]}));v$e.displayName=opn.displayName;const w$e=({className:t,...e})=>K.jsx("div",{className:Hi("rf-flex rf-flex-col rf-space-y-2 rf-text-center sm:rf-text-left",t),...e});w$e.displayName="AlertDialogHeader";const P$e=({className:t,...e})=>K.jsx("div",{className:Hi("rf-flex rf-flex-col-reverse sm:rf-flex-row sm:rf-justify-end sm:rf-space-x-2",t),...e});P$e.displayName="AlertDialogFooter";const M$e=ee.forwardRef(({className:t,...e},n)=>K.jsx(spn,{ref:n,className:Hi("rf-text-lg rf-font-semibold",t),...e}));M$e.displayName=spn.displayName;const D$e=ee.forwardRef(({className:t,...e},n)=>K.jsx(apn,{ref:n,className:Hi("rf-text-sm rf-text-zinc-500 dark:rf-text-zinc-400",t),...e}));D$e.displayName=apn.displayName;const OGi=ee.forwardRef(({className:t,...e},n)=>K.jsx(ipn,{ref:n,className:Hi(rU(),t),...e}));OGi.displayName=ipn.displayName;const N$e=ee.forwardRef(({className:t,...e},n)=>K.jsx(rpn,{ref:n,className:Hi(rU({variant:"outline"}),"rf-mt-2 sm:rf-mt-0",t),...e}));N$e.displayName=rpn.displayName;var GGi=Object.defineProperty,wS=(t,e)=>GGi(t,"name",{value:e,configurable:!0}),R$e="Checkbox",[YGi,umr]=Dx(R$e),[UGi,T$e]=YGi(R$e);function lpn(t){const{__scopeCheckbox:e,checked:n,children:o,defaultChecked:i,disabled:r,form:s,name:a,onCheckedChange:A,required:c,value:l="on",internal_do_not_use_render:u}=t,[g,h]=MB({prop:n,defaultProp:i??!1,onChange:A,caller:R$e}),[d,p]=ee.useState(null),[m,_]=ee.useState(null),f=ee.useRef(!1),[I,C]=ee.useReducer(E=>E+1,0),y=d?!!s||!!d.closest("form"):!0,x={checked:g,disabled:r,setChecked:h,control:d,setControl:p,name:a,form:s,value:l,hasConsumerStoppedPropagationRef:f,userInteractionCount:I,onUserInteraction:C,required:c,defaultChecked:PS(i)?!1:i,isFormControl:y,bubbleInput:m,setBubbleInput:_};return K.jsx(UGi,{scope:e,...x,children:gpn(u)?u(x):o})}wS(lpn,"CheckboxProvider");var KGi="CheckboxTrigger",VGi=ee.forwardRef(wS(function({__scopeCheckbox:e,onKeyDown:n,onClick:o,...i},r){const{control:s,value:a,disabled:A,checked:c,required:l,setControl:u,setChecked:g,hasConsumerStoppedPropagationRef:h,onUserInteraction:d,isFormControl:p,bubbleInput:m}=T$e(KGi,e),_=$A(r,u),f=ee.useRef(c);return ee.useEffect(()=>{const I=s?.form;if(I){const C=wS(()=>g(f.current),"reset");return I.addEventListener("reset",C),()=>I.removeEventListener("reset",C)}},[s,g]),K.jsx(Na.button,{type:"button",role:"checkbox","aria-checked":PS(c)?"mixed":c,"aria-required":l,"data-state":k$e(c),"data-disabled":A?"":void 0,disabled:A,value:a,...i,ref:_,onKeyDown:ar(n,I=>{I.key==="Enter"&&I.preventDefault()}),onClick:ar(o,I=>{d(),g(C=>PS(C)?!0:!C),m&&p&&(h.current=I.isPropagationStopped(),h.current||I.stopPropagation())})})},"CheckboxTrigger")),upn=ee.forwardRef(wS(function(e,n){const{__scopeCheckbox:o,name:i,checked:r,defaultChecked:s,required:a,disabled:A,value:c,onCheckedChange:l,form:u,...g}=e;return K.jsx(lpn,{__scopeCheckbox:o,checked:r,defaultChecked:s,disabled:A,required:a,onCheckedChange:l,name:i,form:u,value:c,internal_do_not_use_render:({isFormControl:h})=>K.jsxs(K.Fragment,{children:[K.jsx(VGi,{...g,ref:n,__scopeCheckbox:o}),h&&K.jsx(jGi,{__scopeCheckbox:o})]})})},"Checkbox")),zGi="CheckboxIndicator",JGi=ee.forwardRef(wS(function(e,n){const{__scopeCheckbox:o,forceMount:i,...r}=e,s=T$e(zGi,o);return K.jsx(cE,{present:i||PS(s.checked)||s.checked===!0,children:K.jsx(Na.span,{"data-state":k$e(s.checked),"data-disabled":s.disabled?"":void 0,...r,ref:n,style:{pointerEvents:"none",...e.style}})})},"CheckboxIndicator")),WGi="CheckboxBubbleInput",jGi=ee.forwardRef(wS(function({__scopeCheckbox:e,onClick:n,...o},i){const{control:r,hasConsumerStoppedPropagationRef:s,userInteractionCount:a,checked:A,defaultChecked:c,required:l,disabled:u,name:g,value:h,form:d,bubbleInput:p,setBubbleInput:m}=T$e(WGi,e),_=$A(i,m),f=yWe(r),I=ee.useRef(!1),C=ee.useRef(A),y=ee.useRef(a);ee.useEffect(()=>{const E=p;if(!E)return;const B=window.HTMLInputElement.prototype,Q=Object.getOwnPropertyDescriptor(B,"checked").set,w=a!==y.current;y.current=a;const M=C.current!==A;C.current=A;const k=!(w&&s.current);if(M&&Q){I.current=!w;const R=new Event("click",{bubbles:k});E.indeterminate=PS(A),Q.call(E,PS(A)?!1:A),E.dispatchEvent(R),I.current=!1}},[p,A,s,a]);const x=ee.useRef(PS(A)?!1:A);return K.jsx(Na.input,{type:"checkbox","aria-hidden":!0,defaultChecked:c??x.current,required:l,disabled:u,name:g,value:h,form:d,...o,tabIndex:-1,ref:_,onClick:ar(n,E=>{I.current&&E.stopPropagation()}),style:{...o.style,...f,position:"absolute",pointerEvents:"none",opacity:0,margin:0,transform:"translateX(-100%)"}})},"CheckboxBubbleInput"));function gpn(t){return typeof t=="function"}wS(gpn,"isFunction");function PS(t){return t==="indeterminate"}wS(PS,"isIndeterminate");function k$e(t){return PS(t)?"indeterminate":t?"checked":"unchecked"}wS(k$e,"getState");const mee=ee.forwardRef(({className:t,...e},n)=>K.jsx(upn,{ref:n,className:Hi("rf-peer rf-h-4 rf-w-4 rf-shrink-0 rf-rounded-sm rf-border rf-border-zinc-200 rf-border-zinc-900 rf-shadow focus-visible:rf-outline-none focus-visible:rf-ring-1 focus-visible:rf-ring-zinc-950 disabled:rf-cursor-not-allowed disabled:rf-opacity-50 data-[state=checked]:rf-bg-zinc-900 data-[state=checked]:rf-text-zinc-50 dark:rf-border-zinc-800 dark:rf-border-zinc-50 dark:focus-visible:rf-ring-zinc-300 dark:data-[state=checked]:rf-bg-zinc-50 dark:data-[state=checked]:rf-text-zinc-900",t),...e,children:K.jsx(JGi,{className:Hi("rf-flex rf-items-center rf-justify-center rf-text-current"),children:K.jsx(IS,{className:"rf-h-4 rf-w-4"})})}));mee.displayName=upn.displayName;const HT=n_e,$Gi=o_e,dpn=ee.forwardRef(({className:t,...e},n)=>K.jsx(bZ,{className:Hi("rf-fixed rf-inset-0 rf-z-50 rf-bg-black/80 data-[state=open]:rf-animate-in data-[state=closed]:rf-animate-out data-[state=closed]:rf-fade-out-0 data-[state=open]:rf-fade-in-0",t),...e,ref:n}));dpn.displayName=bZ.displayName;const YP=ee.forwardRef(({className:t,children:e,showOverlay:n=!0,...o},i)=>K.jsxs($Gi,{children:[K.jsx(dpn,{className:Hi(n?"":"rf-hidden")}),K.jsx(QZ,{ref:i,className:Hi("rf-fixed rf-left-[50%] rf-top-[50%] rf-z-50 rf-grid rf-w-full rf-max-w-lg rf-translate-x-[-50%] rf-translate-y-[-50%] rf-gap-4 rf-border rf-border-zinc-200 rf-bg-white rf-p-6 rf-shadow-lg rf-duration-200 data-[state=open]:rf-animate-in data-[state=closed]:rf-animate-out data-[state=closed]:rf-fade-out-0 data-[state=open]:rf-fade-in-0 data-[state=closed]:rf-zoom-out-95 data-[state=open]:rf-zoom-in-95 data-[state=closed]:rf-slide-out-to-left-1/2 data-[state=closed]:rf-slide-out-to-top-[48%] data-[state=open]:rf-slide-in-from-left-1/2 data-[state=open]:rf-slide-in-from-top-[48%] sm:rf-rounded-lg dark:rf-border-zinc-800 dark:rf-bg-zinc-950",t),...o,children:e})]}));YP.displayName=QZ.displayName;const UP=({className:t,...e})=>K.jsx("div",{className:Hi("rf-flex rf-flex-col rf-space-y-2 rf-text-center sm:rf-text-left",t),...e});UP.displayName="DialogHeader";const UU=({className:t,...e})=>K.jsx("div",{className:Hi("rf-flex rf-flex-col-reverse sm:rf-flex-row sm:rf-justify-end sm:rf-space-x-2",t),...e});UU.displayName="DialogFooter";const KP=ee.forwardRef(({className:t,...e},n)=>K.jsx(i_e,{ref:n,className:Hi("rf-text-lg rf-font-semibold",t),...e}));KP.displayName=i_e.displayName;const OT=ee.forwardRef(({className:t,...e},n)=>K.jsx(r_e,{ref:n,className:Hi("rf-text-sm rf-text-zinc-500 dark:rf-text-zinc-400",t),...e}));OT.displayName=r_e.displayName;const gfe={"tscircuit.com":{label:"tscircuit.com",placeholder:"Search tscircuit packages...",emptyMessage:"No packages found"},jlcpcb:{label:"JLCPCB Parts",placeholder:"Search JLCPCB parts (e.g. C14663)...",emptyMessage:"No parts found"},kicad:{label:"KiCad Footprints",placeholder:"Search KiCad footprints...",emptyMessage:"No footprints found"}},qGi="https://cdn.jsdelivr.net/npm/easyeda@latest/dist/browser/index.js";let F$e=null;const L$e=async()=>(F$e||(F$e=import(qGi)),F$e),XGi=t=>(e,n)=>{const o=new Headers(n?.headers),i={};return o.forEach((r,s)=>{i[s]=r}),fetch(`${t?.apiBase??QC}/proxy`,{...n,headers:{...i,"X-Target-Url":e.toString(),"X-Sender-Origin":i.origin??"","X-Sender-Host":i.host??"https://easyeda.com","X-Sender-Referer":i.referer??"","X-Sender-User-Agent":i["user-agent"]??"","X-Sender-Cookie":i.cookie??"",authority:i.authority??"","content-type":i["content-type"]??"",...t?.headers}})},ZGi=async(t,e=10)=>{const n=encodeURIComponent(t),o=await fetch(`https://jlcsearch.tscircuit.com/api/search?limit=${e}&q=${n}`);if(!o.ok)throw new Error(`JLCPCB API error: ${o.status}`);return(await o.json()).components??[]},eYi=t=>({lcscId:t.lcsc,manufacturer:t.mfr,description:t.description,partNumber:`C${t.lcsc}`,package:t.package,price:t.price,stock:t.stock,isBasic:t.is_basic}),hpn=async(t,e)=>{const{fetchEasyEDAComponent:n}=await L$e();return n(t,{fetch:XGi(e),includeModelMetadata:e?.includeModelMetadata})},tYi=async(t,e)=>{const{convertRawEasyToTsx:n}=await L$e(),o=await hpn(t,e);return n({rawEasy:o})},nYi=async(t,e)=>{const{EasyEdaJsonSchema:n,convertEasyEdaJsonToCircuitJson:o}=await L$e(),i=await hpn(t,{...e,includeModelMetadata:!1}),r=n.parse(i);return o(r,{shouldRecenter:!0,showDesignator:!0,useModelCdn:!1})};function VP(t){return Array.isArray?Array.isArray(t):mpn(t)==="[object Array]"}function oYi(t){if(typeof t=="string")return t;if(typeof t=="bigint")return t.toString();const e=t+"";return e=="0"&&1/t==-1/0?"-0":e}function H$e(t){return t==null?"":oYi(t)}function RC(t){return typeof t=="string"}function dfe(t){return typeof t=="number"}function iYi(t){return t===!0||t===!1||rYi(t)&&mpn(t)=="[object Boolean]"}function ppn(t){return typeof t=="object"}function rYi(t){return ppn(t)&&t!==null}function RE(t){return t!=null}function hfe(t){return!t.trim().length}function mpn(t){return t==null?t===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(t)}const sYi="Incorrect 'index' type",O$e="Invalid doc index: must be a non-negative integer within the bounds of the docs array",aYi=t=>`Invalid value for key ${t}`,AYi=t=>`Pattern length exceeds max of ${t}.`,cYi=t=>`Missing ${t} property in key`,lYi=t=>`Property 'weight' in key '${t}' must be a positive integer`,uYi="Fuse.match does not support useTokenSearch: token search requires corpus-level statistics (df, fieldCount) that a one-off string comparison does not have. Use new Fuse(...).search(...) instead.",_pn=Object.prototype.hasOwnProperty;var gYi=class{constructor(t){this._keys=[],this._keyMap={};let e=0;t.forEach(n=>{const o=fpn(n);this._keys.push(o),this._keyMap[o.id]=o,e+=o.weight}),this._keys.forEach(n=>{n.weight/=e})}get(t){return this._keyMap[t]}keys(){return this._keys}toJSON(){return JSON.stringify(this._keys)}};function fpn(t){let e=null,n=null,o=null,i=1,r=null;if(RC(t)||VP(t))o=t,e=Ipn(t),n=pfe(t);else{if(!_pn.call(t,"name"))throw new Error(cYi("name"));const s=t.name;if(o=s,_pn.call(t,"weight")&&t.weight!==void 0&&(i=t.weight,i<=0))throw new Error(lYi(pfe(s)));e=Ipn(s),n=pfe(s),r=t.getFn??null}return{path:e,id:n,weight:i,src:o,getFn:r}}function Ipn(t){return VP(t)?t:t.split(".")}function pfe(t){return VP(t)?t.join("."):t}function dYi(t,e){const n=[];let o=!1;const i=(r,s,a,A)=>{if(RE(r))if(!s[a])n.push(A!==void 0?{v:r,i:A}:r);else{const c=r[s[a]];if(!RE(c))return;if(a===s.length-1&&(RC(c)||dfe(c)||iYi(c)||typeof c=="bigint"))n.push(A!==void 0?{v:H$e(c),i:A}:H$e(c));else if(VP(c)){o=!0;for(let l=0,u=c.length;l<u;l+=1)i(c[l],s,a+1,l)}else s.length&&i(c,s,a+1,A)}};return i(t,RC(e)?e.split("."):e,0),o?n:n[0]}const wa=Object.freeze({...{isCaseSensitive:!1,ignoreDiacritics:!1,includeScore:!1,keys:[],shouldSort:!0,sortFn:(t,e)=>t.score===e.score?t.idx<e.idx?-1:1:t.score<e.score?-1:1},...{includeMatches:!1,findAllMatches:!1,minMatchCharLength:1},...{location:0,threshold:.6,distance:100},...{useExtendedSearch:!1,useTokenSearch:!1,tokenize:void 0,tokenMatch:"any",getFn:dYi,ignoreLocation:!1,ignoreFieldNorm:!1,fieldNormWeight:1}});function hYi(t){return t>=9&&t<=13||t===32||t===160}function pYi(t=1,e=3){const n=new Map,o=Math.pow(10,e);return{get(i){let r=0,s=!1;for(let A=0;A<i.length;A++)hYi(i.charCodeAt(A))?s=!1:s||(r++,s=!0);if(r===0&&(r=1),n.has(r))return n.get(r);const a=Math.round(o/Math.pow(r,.5*t))/o;return n.set(r,a),a},clear(){n.clear()}}}var G$e=class{constructor({getFn:t=wa.getFn,fieldNormWeight:e=wa.fieldNormWeight}={}){this.norm=pYi(e,3),this.getFn=t,this.isCreated=!1,this.docs=[],this.keys=[],this._keysMap={},this.setIndexRecords()}setSources(t=[]){this.docs=t}setIndexRecords(t=[]){this.records=t}setKeys(t=[]){this.keys=t,this._keysMap={},t.forEach((e,n)=>{this._keysMap[e.id]=n})}create(){if(this.isCreated||!this.docs.length)return;this.isCreated=!0;const t=this.docs.length;this.records=new Array(t);let e=0;if(RC(this.docs[0]))for(let n=0;n<t;n++){const o=this._createStringRecord(this.docs[n],n);o&&(this.records[e++]=o)}else for(let n=0;n<t;n++)this.records[e++]=this._createObjectRecord(this.docs[n],n);this.records.length=e,this.norm.clear()}add(t,e){if(!Number.isInteger(e)||e<0)throw new Error(O$e);if(RC(t)){const o=this._createStringRecord(t,e);return o&&this.records.push(o),o}const n=this._createObjectRecord(t,e);return this.records.push(n),n}removeAt(t){if(!Number.isInteger(t)||t<0)throw new Error(O$e);for(let e=0,n=this.records.length;e<n;e+=1)if(this.records[e].i===t){this.records.splice(e,1);break}for(let e=0,n=this.records.length;e<n;e+=1)this.records[e].i>t&&(this.records[e].i-=1)}removeAll(t){const e=new Set;for(const o of t)Number.isInteger(o)&&o>=0&&e.add(o);if(e.size===0)return;this.records=this.records.filter(o=>!e.has(o.i));const n=Array.from(e).sort((o,i)=>o-i);for(const o of this.records){let i=0,r=n.length;for(;i<r;){const s=i+r>>>1;n[s]<o.i?i=s+1:r=s}o.i-=i}}getValueForItemAtKeyId(t,e){return t[this._keysMap[e]]}size(){return this.records.length}_createStringRecord(t,e){return!RE(t)||hfe(t)?null:{v:t,i:e,n:this.norm.get(t)}}_createObjectRecord(t,e){const n={i:e,$:{}};for(let o=0,i=this.keys.length;o<i;o++){const r=this.keys[o],s=r.getFn?r.getFn(t):this.getFn(t,r.path);if(RE(s)){if(VP(s)){const a=[];for(let A=0,c=s.length;A<c;A+=1){const l=s[A];if(RE(l)){if(RC(l)){if(!hfe(l)){const u={v:l,i:A,n:this.norm.get(l)};a.push(u)}}else if(RE(l.v)){const u=RC(l.v)?l.v:H$e(l.v);if(!hfe(u)){const g={v:u,i:l.i,n:this.norm.get(u)};a.push(g)}}}}n.$[o]=a}else if(RC(s)&&!hfe(s)){const a={v:s,n:this.norm.get(s)};n.$[o]=a}}}return n}toJSON(){return{keys:this.keys.map(({getFn:t,...e})=>e),records:this.records}}};function Cpn(t,e,{getFn:n=wa.getFn,fieldNormWeight:o=wa.fieldNormWeight}={}){const i=new G$e({getFn:n,fieldNormWeight:o});return i.setKeys(t.map(fpn)),i.setSources(e),i.create(),i}function mYi(t,{getFn:e=wa.getFn,fieldNormWeight:n=wa.fieldNormWeight}={}){const{keys:o,records:i}=t,r=new G$e({getFn:e,fieldNormWeight:n});return r.setKeys(o),r.setIndexRecords(i),r}function _Yi(t=[],e=wa.minMatchCharLength){const n=[];let o=-1,i=-1,r=0;for(let s=t.length;r<s;r+=1){const a=t[r];a&&o===-1?o=r:!a&&o!==-1&&(i=r-1,i-o+1>=e&&n.push([o,i]),o=-1)}return t[r-1]&&r-o>=e&&n.push([o,r-1]),n}function fYi(t,e,n,{location:o=wa.location,distance:i=wa.distance,threshold:r=wa.threshold,findAllMatches:s=wa.findAllMatches,minMatchCharLength:a=wa.minMatchCharLength,includeMatches:A=wa.includeMatches,ignoreLocation:c=wa.ignoreLocation}={}){if(e.length>32)throw new Error(AYi(32));const l=e.length,u=t.length,g=Math.max(0,Math.min(o,u));let h=r,d=g;const p=(S,Q)=>{const w=S/l;if(c)return w;const M=Math.abs(g-Q);return i?w+M/i:M?1:w},m=a>1||A,_=m?Array(u):[];let f;for(;(f=t.indexOf(e,d))>-1;){const S=p(0,f);if(h=Math.min(S,h),d=f+l,m){let Q=0;for(;Q<l;)_[f+Q]=1,Q+=1}}d=-1;let I=[],C=1,y=0,x=l+u;const E=1<<l-1;for(let S=0;S<l;S+=1){let Q=0,w=x;for(;Q<w;)p(S,g+w)<=h?Q=w:x=w,w=Math.floor((x-Q)/2+Q);x=w;let M=Math.max(1,g-w+1);const k=s?u:Math.min(g+w,u)+l,R=Array(k+2);R[k+1]=(1<<S)-1;for(let F=k;F>=M;F-=1){const O=F-1,U=n[t[O]];if(R[F]=(R[F+1]<<1|1)&U,S&&(R[F]|=(I[F+1]|I[F])<<1|1|I[F+1]),R[F]&E&&(C=p(S,O),C<=h)){if(h=C,d=O,y=S,d<=g)break;M=Math.max(1,2*g-d)}}if(p(S+1,g)>h)break;I=R}if(m&&d>=0){const S=Math.min(u-1,d+l-1+y);for(let Q=d;Q<=S;Q+=1)n[t[Q]]&&(_[Q]=1)}const B={isMatch:d>=0,score:Math.max(.001,C)};if(m){const S=_Yi(_,a);S.length?A&&(B.indices=S):B.isMatch=!1}return B}function IYi(t){const e={};for(let n=0,o=t.length;n<o;n+=1){const i=t.charAt(n);e[i]=(e[i]||0)|1<<o-n-1}return e}function Y$e(t){if(t.length<=1)return t;t.sort((n,o)=>n[0]-o[0]||n[1]-o[1]);const e=[t[0]];for(let n=1,o=t.length;n<o;n+=1){const i=e[e.length-1],r=t[n];r[0]<=i[1]+1?i[1]=Math.max(i[1],r[1]):e.push(r)}return e}const ypn={ł:"l",Ł:"L",đ:"d",Đ:"D",ø:"o",Ø:"O",ħ:"h",Ħ:"H",ŧ:"t",Ŧ:"T",ı:"i",ß:"ss"},CYi=new RegExp("["+Object.keys(ypn).join("")+"]","g"),_ee=typeof String.prototype.normalize=="function"?t=>t.normalize("NFD").replace(/[\u0300-\u036F\u0483-\u0489\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u0610-\u061A\u064B-\u065F\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED\u0711\u0730-\u074A\u07A6-\u07B0\u07EB-\u07F3\u07FD\u0816-\u0819\u081B-\u0823\u0825-\u0827\u0829-\u082D\u0859-\u085B\u08D3-\u08E1\u08E3-\u0903\u093A-\u093C\u093E-\u094F\u0951-\u0957\u0962\u0963\u0981-\u0983\u09BC\u09BE-\u09C4\u09C7\u09C8\u09CB-\u09CD\u09D7\u09E2\u09E3\u09FE\u0A01-\u0A03\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A70\u0A71\u0A75\u0A81-\u0A83\u0ABC\u0ABE-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AE2\u0AE3\u0AFA-\u0AFF\u0B01-\u0B03\u0B3C\u0B3E-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B62\u0B63\u0B82\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD7\u0C00-\u0C04\u0C3E-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C62\u0C63\u0C81-\u0C83\u0CBC\u0CBE-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CE2\u0CE3\u0D00-\u0D03\u0D3B\u0D3C\u0D3E-\u0D44\u0D46-\u0D48\u0D4A-\u0D4D\u0D57\u0D62\u0D63\u0D82\u0D83\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DF2\u0DF3\u0E31\u0E34-\u0E3A\u0E47-\u0E4E\u0EB1\u0EB4-\u0EB9\u0EBB\u0EBC\u0EC8-\u0ECD\u0F18\u0F19\u0F35\u0F37\u0F39\u0F3E\u0F3F\u0F71-\u0F84\u0F86\u0F87\u0F8D-\u0F97\u0F99-\u0FBC\u0FC6\u102B-\u103E\u1056-\u1059\u105E-\u1060\u1062-\u1064\u1067-\u106D\u1071-\u1074\u1082-\u108D\u108F\u109A-\u109D\u135D-\u135F\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17B4-\u17D3\u17DD\u180B-\u180D\u1885\u1886\u18A9\u1920-\u192B\u1930-\u193B\u1A17-\u1A1B\u1A55-\u1A5E\u1A60-\u1A7C\u1A7F\u1AB0-\u1ABE\u1B00-\u1B04\u1B34-\u1B44\u1B6B-\u1B73\u1B80-\u1B82\u1BA1-\u1BAD\u1BE6-\u1BF3\u1C24-\u1C37\u1CD0-\u1CD2\u1CD4-\u1CE8\u1CED\u1CF2-\u1CF4\u1CF7-\u1CF9\u1DC0-\u1DF9\u1DFB-\u1DFF\u20D0-\u20F0\u2CEF-\u2CF1\u2D7F\u2DE0-\u2DFF\u302A-\u302F\u3099\u309A\uA66F-\uA672\uA674-\uA67D\uA69E\uA69F\uA6F0\uA6F1\uA802\uA806\uA80B\uA823-\uA827\uA880\uA881\uA8B4-\uA8C5\uA8E0-\uA8F1\uA8FF\uA926-\uA92D\uA947-\uA953\uA980-\uA983\uA9B3-\uA9C0\uA9E5\uAA29-\uAA36\uAA43\uAA4C\uAA4D\uAA7B-\uAA7D\uAAB0\uAAB2-\uAAB4\uAAB7\uAAB8\uAABE\uAABF\uAAC1\uAAEB-\uAAEF\uAAF5\uAAF6\uABE3-\uABEA\uABEC\uABED\uFB1E\uFE00-\uFE0F\uFE20-\uFE2F]/g,"").replace(CYi,e=>ypn[e]):t=>t;var U$e=class{constructor(t,{location:e=wa.location,threshold:n=wa.threshold,distance:o=wa.distance,includeMatches:i=wa.includeMatches,findAllMatches:r=wa.findAllMatches,minMatchCharLength:s=wa.minMatchCharLength,isCaseSensitive:a=wa.isCaseSensitive,ignoreDiacritics:A=wa.ignoreDiacritics,ignoreLocation:c=wa.ignoreLocation}={}){if(this.options={location:e,threshold:n,distance:o,includeMatches:i,findAllMatches:r,minMatchCharLength:s,isCaseSensitive:a,ignoreDiacritics:A,ignoreLocation:c},t=a?t:t.toLowerCase(),t=A?_ee(t):t,this.pattern=t,this.chunks=[],!this.pattern.length)return;const l=(g,h)=>{this.chunks.push({pattern:g,alphabet:IYi(g),startIndex:h})},u=this.pattern.length;if(u>32){let g=0;const h=u%32,d=u-h;for(;g<d;)l(this.pattern.substr(g,32),g),g+=32;if(h){const p=u-32;l(this.pattern.substr(p),p)}}else l(this.pattern,0)}searchIn(t){const{isCaseSensitive:e,ignoreDiacritics:n,includeMatches:o}=this.options;if(t=e?t:t.toLowerCase(),t=n?_ee(t):t,this.pattern===t){if(t.length<this.options.minMatchCharLength)return{isMatch:!1,score:1};const d={isMatch:!0,score:0};return o&&(d.indices=[[0,t.length-1]]),d}const{location:i,distance:r,threshold:s,findAllMatches:a,minMatchCharLength:A,ignoreLocation:c}=this.options,l=[];let u=0,g=!1;this.chunks.forEach(({pattern:d,alphabet:p,startIndex:m})=>{const{isMatch:_,score:f,indices:I}=fYi(t,d,p,{location:i+m,distance:r,threshold:s,findAllMatches:a,minMatchCharLength:A,includeMatches:o,ignoreLocation:c});_&&(g=!0),u+=f,_&&I&&l.push(...I)});const h={isMatch:g,score:g?u/this.chunks.length:1};return g&&o&&(h.indices=Y$e(l)),h}};const yYi=new Set(["fuzzy","include"]);function xYi(t){return t.startsWith("inverse")}const K$e=[{type:"exact",multiRegex:/^="(.*)"$/,singleRegex:/^=(.*)$/,create:t=>({type:"exact",search(e){const n=e===t;return{isMatch:n,score:n?0:1,indices:[0,t.length-1]}}})},{type:"include",multiRegex:/^'"(.*)"$/,singleRegex:/^'(.*)$/,create:t=>({type:"include",search(e){let n=0,o;const i=[],r=t.length;for(;(o=e.indexOf(t,n))>-1;)n=o+r,i.push([o,n-1]);const s=!!i.length;return{isMatch:s,score:s?0:1,indices:i}}})},{type:"prefix-exact",multiRegex:/^\^"(.*)"$/,singleRegex:/^\^(.*)$/,create:t=>({type:"prefix-exact",search(e){const n=e.startsWith(t);return{isMatch:n,score:n?0:1,indices:[0,t.length-1]}}})},{type:"inverse-prefix-exact",multiRegex:/^!\^"(.*)"$/,singleRegex:/^!\^(.*)$/,create:t=>({type:"inverse-prefix-exact",search(e){const n=!e.startsWith(t);return{isMatch:n,score:n?0:1,indices:[0,e.length-1]}}})},{type:"inverse-suffix-exact",multiRegex:/^!"(.*)"\$$/,singleRegex:/^!(.*)\$$/,create:t=>({type:"inverse-suffix-exact",search(e){const n=!e.endsWith(t);return{isMatch:n,score:n?0:1,indices:[0,e.length-1]}}})},{type:"suffix-exact",multiRegex:/^"(.*)"\$$/,singleRegex:/^(.*)\$$/,create:t=>({type:"suffix-exact",search(e){const n=e.endsWith(t);return{isMatch:n,score:n?0:1,indices:[e.length-t.length,e.length-1]}}})},{type:"inverse-exact",multiRegex:/^!"(.*)"$/,singleRegex:/^!(.*)$/,create:t=>({type:"inverse-exact",search(e){const n=e.indexOf(t)===-1;return{isMatch:n,score:n?0:1,indices:[0,e.length-1]}}})},{type:"fuzzy",multiRegex:/^"(.*)"$/,singleRegex:/^(.*)$/,create:(t,e={})=>{const n=new U$e(t,{location:e.location??wa.location,threshold:e.threshold??wa.threshold,distance:e.distance??wa.distance,includeMatches:e.includeMatches??wa.includeMatches,findAllMatches:e.findAllMatches??wa.findAllMatches,minMatchCharLength:e.minMatchCharLength??wa.minMatchCharLength,isCaseSensitive:e.isCaseSensitive??wa.isCaseSensitive,ignoreDiacritics:e.ignoreDiacritics??wa.ignoreDiacritics,ignoreLocation:e.ignoreLocation??wa.ignoreLocation});return{type:"fuzzy",search(o){return n.searchIn(o)}}}}],xpn=K$e.length,EYi="\0",BYi="|";function bYi(t){const e=[],n=t.length;let o=0;for(;o<n;){for(;o<n&&t[o]===" ";)o++;if(o>=n)break;let i=o;for(;i<n&&t[i]!==" "&&t[i]!=='"';)i++;if(i<n&&t[i]==='"'){for(i++;i<n;){if(t[i]==='"'){const r=i+1;if(r>=n||t[r]===" "){i++;break}if(t[r]==="$"&&(r+1>=n||t[r+1]===" ")){i+=2;break}}i++}e.push(t.substring(o,i)),o=i}else{for(;i<n&&t[i]!==" ";)i++;e.push(t.substring(o,i)),o=i}}return e}function Epn(t,e){const n=t.match(e);return n?n[1]:null}function SYi(t,e={}){return t.replace(/\\\|/g,EYi).split(BYi).map(n=>{const o=bYi(n.replace(/\u0000/g,"|").trim()).filter(r=>r&&!!r.trim()),i=[];for(let r=0,s=o.length;r<s;r+=1){const a=o[r];let A=!1,c=-1;for(;!A&&++c<xpn;){const l=K$e[c],u=Epn(a,l.multiRegex);u&&(i.push(l.create(u,e)),A=!0)}if(!A)for(c=-1;++c<xpn;){const l=K$e[c],u=Epn(a,l.singleRegex);if(u){i.push(l.create(u,e));break}}}return i})}var QYi=class{constructor(t,{isCaseSensitive:e=wa.isCaseSensitive,ignoreDiacritics:n=wa.ignoreDiacritics,includeMatches:o=wa.includeMatches,minMatchCharLength:i=wa.minMatchCharLength,ignoreLocation:r=wa.ignoreLocation,findAllMatches:s=wa.findAllMatches,location:a=wa.location,threshold:A=wa.threshold,distance:c=wa.distance}={}){this.query=null,this.options={isCaseSensitive:e,ignoreDiacritics:n,includeMatches:o,minMatchCharLength:i,findAllMatches:s,ignoreLocation:r,location:a,threshold:A,distance:c},t=e?t:t.toLowerCase(),t=n?_ee(t):t,this.pattern=t,this.query=SYi(this.pattern,this.options)}static condition(t,e){return e.useExtendedSearch}searchIn(t){const e=this.query;if(!e)return{isMatch:!1,score:1};const{includeMatches:n,isCaseSensitive:o,ignoreDiacritics:i}=this.options;t=o?t:t.toLowerCase(),t=i?_ee(t):t;let r=0;const s=[];let a=0,A=!1;for(let c=0,l=e.length;c<l;c+=1){const u=e[c];s.length=0,r=0,A=!1;for(let g=0,h=u.length;g<h;g+=1){const d=u[g],{isMatch:p,indices:m,score:_}=d.search(t);if(p)r+=1,a+=_,xYi(d.type)&&(A=!0),n&&(yYi.has(d.type)?s.push(...m):s.push(m));else{a=0,r=0,s.length=0,A=!1;break}}if(r){const g={isMatch:!0,score:a/r};return A&&(g.hasInverse=!0),n&&(g.indices=Y$e(s)),g}}return{isMatch:!1,score:1}}};const V$e=[];function z$e(...t){V$e.push(...t)}function mfe(t,e){for(let n=0,o=V$e.length;n<o;n+=1){const i=V$e[n];if(i.condition(t,e))return new i(t,e)}return new U$e(t,e)}const _fe={AND:"$and",OR:"$or"},J$e={PATH:"$path",PATTERN:"$val"},W$e=t=>!!(t[_fe.AND]||t[_fe.OR]),vYi=t=>!!t[J$e.PATH],wYi=t=>!VP(t)&&ppn(t)&&!W$e(t),Bpn=t=>({[_fe.AND]:Object.keys(t).map(e=>({[e]:t[e]}))});function bpn(t,e,{auto:n=!0}={}){const o=i=>{if(RC(i)){const A={keyId:null,pattern:i};return n&&(A.searcher=mfe(i,e)),A}const r=Object.keys(i),s=vYi(i);if(!s&&r.length>1&&!W$e(i))return o(Bpn(i));if(wYi(i)){const A=s?i[J$e.PATH]:r[0],c=s?i[J$e.PATTERN]:i[A];if(!RC(c))throw new Error(aYi(A));const l={keyId:pfe(A),pattern:c};return n&&(l.searcher=mfe(c,e)),l}const a={children:[],operator:r[0]};return r.forEach(A=>{const c=i[A];VP(c)&&c.forEach(l=>{a.children.push(o(l))})}),a};return W$e(t)||(t=Bpn(t)),o(t)}function j$e(t,{ignoreFieldNorm:e=wa.ignoreFieldNorm}){let n=1;return t.forEach(({key:o,norm:i,score:r})=>{const s=o?o.weight:null;n*=Math.pow(r===0&&s?Number.EPSILON:r,(s||1)*(e?1:i))}),n}function PYi(t,{ignoreFieldNorm:e=wa.ignoreFieldNorm}){t.forEach(n=>{n.score=j$e(n.matches,{ignoreFieldNorm:e})})}var MYi=class{constructor(t,e){this.limit=t,this.heap=[],this.comparator=e}get size(){return this.heap.length}insert(t){this.size<this.limit?(this.heap.push(t),this._bubbleUp(this.size-1)):this.comparator(t,this.heap[0])<0&&(this.heap[0]=t,this._sinkDown(0))}extractSorted(){return this.heap.sort(this.comparator)}_bubbleUp(t){const e=this.heap;for(;t>0;){const n=t-1>>1;if(this.comparator(e[t],e[n])<=0)break;const o=e[t];e[t]=e[n],e[n]=o,t=n}}_sinkDown(t){const e=this.heap,n=e.length;let o=t;do{t=o;const i=2*t+1,r=2*t+2;if(i<n&&this.comparator(e[i],e[o])>0&&(o=i),r<n&&this.comparator(e[r],e[o])>0&&(o=r),o!==t){const s=e[t];e[t]=e[o],e[o]=s}}while(o!==t)}};function DYi(t){const e=[];return t.matches.forEach(n=>{if(!RE(n.indices)||!n.indices.length)return;const o={indices:n.indices,value:n.value};n.key&&(o.key=n.key.id),n.idx>-1&&(o.refIndex=n.idx),e.push(o)}),e}function NYi(t,e,{includeMatches:n=wa.includeMatches,includeScore:o=wa.includeScore}={}){return t.map(i=>{const{idx:r}=i,s={item:e[r],refIndex:r};return n&&(s.matches=DYi(i)),o&&(s.score=i.score),s})}const RYi=/[\p{L}\p{M}\p{N}_]+/gu,Spn=new WeakSet;function TYi(t){Spn.has(t)||(Spn.add(t),console.warn(`[Fuse] tokenize regex ${t} lacks the global flag; only the first match per text will be returned. Add the 'g' flag.`))}function kYi(t){if(typeof t=="function"){let e=!1;return n=>{const o=t(n);if(!e&&(e=!0,!Array.isArray(o)||o.some(i=>typeof i!="string")))throw new Error(`[Fuse] tokenize function must return string[]; received ${Array.isArray(o)?"array containing non-strings":typeof o}.`);return o}}return t instanceof RegExp?(t.global||TYi(t),e=>e.match(t)||[]):e=>e.match(RYi)||[]}function $$e({isCaseSensitive:t=!1,ignoreDiacritics:e=!1,tokenize:n}={}){const o=kYi(n);return{tokenize(i){return t||(i=i.toLowerCase()),e&&(i=_ee(i)),o(i)}}}var FYi=class{static condition(t,e){return e.useTokenSearch}constructor(t,e){this.options=e,this.analyzer=$$e({isCaseSensitive:e.isCaseSensitive,ignoreDiacritics:e.ignoreDiacritics,tokenize:e.tokenize});const n=this.analyzer.tokenize(t),{df:o,fieldCount:i}=e._invertedIndex;this.termSearchers=[],this.idfWeights=[];for(const r of n){this.termSearchers.push(new U$e(r,{location:e.location,threshold:e.threshold,distance:e.distance,includeMatches:e.includeMatches,findAllMatches:e.findAllMatches,minMatchCharLength:e.minMatchCharLength,isCaseSensitive:e.isCaseSensitive,ignoreDiacritics:e.ignoreDiacritics,ignoreLocation:!0}));const s=o.get(r)||0,a=Math.log(1+(i-s+.5)/(s+.5));this.idfWeights.push(a)}this.combineAll=e.tokenMatch==="all",this.numTerms=this.termSearchers.length,this.useMask=this.numTerms<=31}searchIn(t){if(!this.termSearchers.length)return{isMatch:!1,score:1};const e=[];let n=0,o=0,i=0,r=0;const s=this.combineAll&&!this.useMask?new Set:null;for(let c=0;c<this.termSearchers.length;c++){const l=this.termSearchers[c].searchIn(t),u=this.idfWeights[c];o+=u,l.isMatch&&(i++,n+=u*(1-l.score),l.indices&&e.push(...l.indices),this.combineAll&&(this.useMask?r|=1<<c:s.add(c)))}if(i===0)return{isMatch:!1,score:1};const a=o>0?1-n/o:0,A={isMatch:!0,score:Math.max(.001,a)};return this.options.includeMatches&&e.length&&(A.indices=Y$e(e)),this.combineAll&&(this.useMask?A.matchedMask=r:A.matchedTerms=s,A.termCount=this.numTerms),A}};function q$e(t,e,n,o){const i=o.tokenize(e);if(!i.length)return;t.fieldCount++,t.docFieldCount.set(n,(t.docFieldCount.get(n)||0)+1);const r=new Set(i);let s=t.docTermFieldHits.get(n);s||(s=new Map,t.docTermFieldHits.set(n,s));for(const a of r)s.set(a,(s.get(a)||0)+1),t.df.set(a,(t.df.get(a)||0)+1)}function Qpn(t,e,n,o){const{i,v:r,$:s}=e;if(r!==void 0){q$e(t,r,i,o);return}if(s)for(let a=0;a<n;a++){const A=s[a];if(A)if(Array.isArray(A))for(const c of A)q$e(t,c.v,i,o);else q$e(t,A.v,i,o)}}function LYi(t,e,n){const o={fieldCount:0,df:new Map,docFieldCount:new Map,docTermFieldHits:new Map};for(const i of t)Qpn(o,i,e,n);return o}function HYi(t,e,n,o){Qpn(t,e,n,o)}function OYi(t,e){const n=t.docFieldCount.get(e);if(n===void 0)return;t.fieldCount-=n,t.docFieldCount.delete(e);const o=t.docTermFieldHits.get(e);if(o){for(const[i,r]of o){const s=(t.df.get(i)||0)-r;s<=0?t.df.delete(i):t.df.set(i,s)}t.docTermFieldHits.delete(e)}}function vpn(t,e){if(e.length===0)return;const n=Array.from(new Set(e)).sort((a,A)=>a-A);for(const a of n)OYi(t,a);const o=a=>{let A=0,c=n.length;for(;A<c;){const l=A+c>>>1;n[l]<a?A=l+1:c=l}return a-A},i=n[0],r=new Map;for(const[a,A]of t.docFieldCount)r.set(a>i?o(a):a,A);t.docFieldCount=r;const s=new Map;for(const[a,A]of t.docTermFieldHits)s.set(a>i?o(a):a,A);t.docTermFieldHits=s}var zP=class{constructor(t,e,n){this.options={...wa,...e},this.options.useExtendedSearch,this.options.useTokenSearch,this._keyStore=new gYi(this.options.keys),this._docs=t,this._myIndex=null,this._invertedIndex=null,this.setCollection(t,n),this._lastQuery=null,this._lastSearcher=null}_getSearcher(t){if(this._lastQuery===t)return this._lastSearcher;const e=mfe(t,this._invertedIndex?{...this.options,_invertedIndex:this._invertedIndex}:this.options);return this._lastQuery=t,this._lastSearcher=e,e}setCollection(t,e){if(this._docs=t,e&&!(e instanceof G$e))throw new Error(sYi);if(this._myIndex=e||Cpn(this.options.keys,this._docs,{getFn:this.options.getFn,fieldNormWeight:this.options.fieldNormWeight}),this.options.useTokenSearch){const n=$$e({isCaseSensitive:this.options.isCaseSensitive,ignoreDiacritics:this.options.ignoreDiacritics,tokenize:this.options.tokenize});this._invertedIndex=LYi(this._myIndex.records,this._myIndex.keys.length,n)}this._invalidateSearcherCache()}add(t){if(!RE(t))return;this._docs.push(t);const e=this._myIndex.add(t,this._docs.length-1);if(this._invertedIndex&&e){const n=$$e({isCaseSensitive:this.options.isCaseSensitive,ignoreDiacritics:this.options.ignoreDiacritics,tokenize:this.options.tokenize});HYi(this._invertedIndex,e,this._myIndex.keys.length,n)}this._invalidateSearcherCache()}remove(t=()=>!1){const e=[],n=[];for(let o=0,i=this._docs.length;o<i;o+=1)t(this._docs[o],o)&&(e.push(this._docs[o]),n.push(o));if(n.length){this._invertedIndex&&vpn(this._invertedIndex,n);const o=new Set(n);this._docs=this._docs.filter((i,r)=>!o.has(r)),this._myIndex.removeAll(n),this._invalidateSearcherCache()}return e}removeAt(t){if(!Number.isInteger(t)||t<0||t>=this._docs.length)throw new Error(O$e);this._invertedIndex&&vpn(this._invertedIndex,[t]);const e=this._docs.splice(t,1)[0];return this._myIndex.removeAt(t),this._invalidateSearcherCache(),e}_invalidateSearcherCache(){this._lastQuery=null,this._lastSearcher=null}getIndex(){return this._myIndex}_normalizedKeys(){return this._myIndex.keys.map(t=>this._keyStore.get(t.id)||t)}search(t,e){const{limit:n=-1}=e||{},{includeMatches:o,includeScore:i,shouldSort:r,sortFn:s,ignoreFieldNorm:a}=this.options;if(RC(t)&&!t.trim()){let g=this._docs.map((h,d)=>({item:h,refIndex:d}));return dfe(n)&&n>-1&&(g=g.slice(0,n)),g}const A=r&&dfe(n)&&n>0&&RC(t),c=s,l=(g,h)=>c(g,h)||g.idx-h.idx;let u;if(A){const g=new MYi(n,l);RC(this._docs[0])?this._searchStringList(t,{heap:g,ignoreFieldNorm:a}):this._searchObjectList(t,{heap:g,ignoreFieldNorm:a}),u=g.extractSorted()}else u=RC(t)?RC(this._docs[0])?this._searchStringList(t):this._searchObjectList(t):this._searchLogical(t),PYi(u,{ignoreFieldNorm:a}),r&&u.sort(RC(t)?l:c),dfe(n)&&n>-1&&(u=u.slice(0,n));return NYi(u,this._docs,{includeMatches:o,includeScore:i})}_searchStringList(t,{heap:e,ignoreFieldNorm:n}={}){const o=this._getSearcher(t),i=this.options.useTokenSearch&&this.options.tokenMatch==="all",{records:r}=this._myIndex,s=e?null:[];return r.forEach(({v:a,i:A,n:c})=>{if(!RE(a))return;const l=o.searchIn(a);if(l.isMatch){const u={score:l.score,value:a,norm:c,indices:l.indices};i&&(u.matchedMask=l.matchedMask,u.matchedTerms=l.matchedTerms,u.termCount=l.termCount);const g=[u];if(!i||this._coversAllTokens(g)){const h={item:a,idx:A,matches:g};e?(h.score=j$e(h.matches,{ignoreFieldNorm:n}),e.insert(h)):s.push(h)}}}),s}_searchLogical(t){const e=bpn(t,this.options),n=this._normalizedKeys(),o=(a,A,c)=>{if(!("children"in a)){const{keyId:h,searcher:d}=a;let p;return h===null?(p=[],n.forEach((m,_)=>{p.push(...this._findMatches({key:m,value:A[_],searcher:d}))})):p=this._findMatches({key:this._keyStore.get(h),value:this._myIndex.getValueForItemAtKeyId(A,h),searcher:d}),p&&p.length?[{idx:c,item:A,matches:p}]:[]}const{children:l,operator:u}=a,g=[];for(let h=0,d=l.length;h<d;h+=1){const p=l[h],m=o(p,A,c);if(m.length)g.push(...m);else if(u===_fe.AND)return[]}return g},i=this._myIndex.records,r=new Map,s=[];return i.forEach(({$:a,i:A})=>{if(RE(a)){const c=o(e,a,A);c.length&&(r.has(A)||(r.set(A,{idx:A,item:a,matches:[]}),s.push(r.get(A))),c.forEach(({matches:l})=>{r.get(A).matches.push(...l)}))}}),s}_searchObjectList(t,{heap:e,ignoreFieldNorm:n}={}){const o=this._getSearcher(t),i=this.options.useTokenSearch&&this.options.tokenMatch==="all",{records:r}=this._myIndex,s=this._normalizedKeys(),a=e?null:[];return r.forEach(({$:A,i:c})=>{if(!RE(A))return;const l=[];let u=!1,g=!1;if(s.forEach((h,d)=>{const p=this._findMatches({key:h,value:A[d],searcher:o});p.length?(l.push(...p),p[0].hasInverse&&(g=!0)):u=!0}),!(g&&u)&&l.length&&(!i||this._coversAllTokens(l))){const h={idx:c,item:A,matches:l};e?(h.score=j$e(h.matches,{ignoreFieldNorm:n}),e.insert(h)):a.push(h)}}),a}_findMatches({key:t,value:e,searcher:n}){if(!RE(e))return[];const o=[];if(VP(e))e.forEach(({v:i,i:r,n:s})=>{if(!RE(i))return;const a=n.searchIn(i);if(a.isMatch){const A={score:a.score,key:t,value:i,idx:r,norm:s,indices:a.indices,hasInverse:a.hasInverse};a.termCount!==void 0&&(A.matchedMask=a.matchedMask,A.matchedTerms=a.matchedTerms,A.termCount=a.termCount),o.push(A)}});else{const{v:i,n:r}=e,s=n.searchIn(i);if(s.isMatch){const a={score:s.score,key:t,value:i,norm:r,indices:s.indices,hasInverse:s.hasInverse};s.termCount!==void 0&&(a.matchedMask=s.matchedMask,a.matchedTerms=s.matchedTerms,a.termCount=s.termCount),o.push(a)}}return o}_coversAllTokens(t){const e=t.length?t[0].termCount:void 0;if(e===void 0)return!0;if(e<=31){let o=0;for(let i=0;i<t.length;i++)o|=t[i].matchedMask||0;return o===2**e-1}const n=new Set;for(let o=0;o<t.length;o++){const i=t[o].matchedTerms;if(i)for(const r of i)n.add(r)}return n.size===e}};zP.version="7.5.0",zP.createIndex=Cpn,zP.parseIndex=mYi,zP.config=wa,zP.match=function(t,e,n){if(n&&n.useTokenSearch)throw new Error(uYi);return mfe(t,{...wa,...n}).searchIn(e)},zP.parseQuery=bpn,z$e(QYi),z$e(FYi),zP.use=function(...t){t.forEach(e=>z$e(e))};var GYi=zP;const YYi="https://kicad-mod-cache.tscircuit.com";let X$e=null,fee=null,Z$e=null;const UYi=async()=>X$e||fee||(fee=fetch("https://kicad-mod-cache.tscircuit.com/kicad_files.json").then(t=>t.json()).then(t=>(X$e=t,fee=null,t)),fee),KYi=async(t,e=20)=>{const n=await UYi();return Z$e||(Z$e=new GYi(n)),Z$e.search(t).slice(0,e).map(o=>o.item)},VYi=t=>{const e=t.replace(".pretty/","/").replace(".kicad_mod",""),n=`kicad:${e}`;return{path:t,qualifiedName:n,description:e}},zYi=t=>t.replace(/^\/+/,"").split("/").map(e=>encodeURIComponent(e)).join("/"),JYi=async t=>{const e=await fetch(`${YYi}/${zYi(t)}`);if(!e.ok)throw new Error(`KiCad footprint fetch failed: ${e.status}`);const n=await e.text(),{KicadFootprintToCircuitJsonConverter:o}=await vE("kicad-to-circuit-json"),i=new o;return i.addFile(t.split("/").pop()??"selected-footprint.kicad_mod",n),i.runUntilFinished(),i.getOutput()},wpn=t=>t?.source==="jlcpcb"||t?.source==="kicad",WYi=async(t,e)=>{if(t.source==="jlcpcb")return nYi(t.component.partNumber,e?.jlcpcb);if(t.source==="kicad")return JYi(t.footprint.path);throw new Error("Footprint preview is not available for this source")},jYi=({query:t,placeholder:e,isSearching:n,onQueryChange:o,onSubmit:i})=>{const r=ee.useCallback(s=>{s.key==="Enter"&&(s.preventDefault(),i())},[i]);return K.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2 rf-mt-4",children:[K.jsxs("div",{className:"rf-relative rf-flex-grow",children:[K.jsx(ZJe,{className:"rf-absolute rf-left-2 rf-top-2.5 rf-h-4 rf-w-4 rf-text-muted-foreground"}),K.jsx(gje,{placeholder:e,className:"rf-pl-8",spellCheck:!1,autoComplete:"off",value:t,onChange:s=>o(s.target.value),onKeyDown:r})]}),K.jsx(fA,{onClick:i,disabled:n||t.trim().length<1,className:"sm:rf-px-4 rf-px-3",children:n?K.jsx(xE,{className:"rf-h-4 rf-w-4 rf-animate-spin"}):K.jsxs(K.Fragment,{children:[K.jsx(ZJe,{className:"rf-h-4 rf-w-4 sm:rf-hidden"}),K.jsx("span",{className:"rf-hidden sm:rf-inline",children:"Search"})]})})]})},$Yi=new Intl.NumberFormat("en-US",{style:"currency",currency:"USD"}),qYi=t=>$Yi.format(t),Ppn=t=>{switch(t.source){case"tscircuit.com":{const e=t.package;return`tscircuit-${e.package_id??`${e.org_owner_tscircuit_handle??"unknown"}-${e.unscoped_name??e.name??"package"}`}`}case"jlcpcb":return`jlc-${t.component.lcscId}`;case"kicad":return`kicad-${t.footprint.path}`;default:return"unknown"}},XYi=t=>{switch(t.source){case"tscircuit.com":return t.package.unscoped_name;case"jlcpcb":return t.component.isDirectLookup?t.component.partNumber:t.component.manufacturer;case"kicad":return t.footprint.qualifiedName}},ZYi=t=>{switch(t.source){case"tscircuit.com":return t.package.description||(t.package.org_owner_tscircuit_handle?`Component by ${t.package.org_owner_tscircuit_handle}`:void 0);case"jlcpcb":return t.component.description;case"kicad":return t.footprint.description}},eUi=t=>{switch(t.source){case"tscircuit.com":return t.package.name;case"jlcpcb":return t.component.isDirectLookup?void 0:t.component.partNumber;case"kicad":return}},tUi=({results:t,selected:e,onSelect:n,onShowDetails:o})=>{const i=e?Ppn(e):null;return K.jsx("div",{className:"rf-divide-y rf-w-full rf-overflow-hidden",children:t.map(r=>{const s=Ppn(r),a=i===s,A=XYi(r),c=ZYi(r),l=eUi(r),u=r.source==="jlcpcb"?r.component.stock:null,g=r.source==="jlcpcb"?r.component.price:null,h=r.source==="jlcpcb"?r.component.isBasic:null,d=r.source==="jlcpcb"?r.component.isDirectLookup:!1;return K.jsxs("div",{className:`rf-p-3 rf-flex rf-flex-col sm:rf-grid sm:rf-grid-cols-[minmax(0,1fr)_auto] rf-items-start sm:rf-items-center rf-cursor-pointer hover:rf-bg-zinc-100 rf-gap-2 rf-overflow-hidden ${a?"rf-bg-zinc-100":""}`,onClick:()=>n(r),children:[K.jsxs("div",{className:"rf-min-w-0 rf-overflow-hidden rf-w-full",children:[K.jsxs("div",{className:"rf-flex rf-items-start rf-gap-2 rf-min-w-0",children:[K.jsxs("div",{className:"rf-font-medium rf-text-sm rf-truncate rf-flex-1 rf-min-w-0 rf-flex rf-items-center rf-gap-1.5",children:[A,r.source==="jlcpcb"&&h!=null&&K.jsx("span",{className:`rf-text-xs rf-px-1.5 rf-py-0.5 rf-rounded rf-font-medium rf-flex-shrink-0 ${h?"rf-bg-green-100 rf-text-green-700":"rf-bg-orange-100 rf-text-orange-700"}`,children:h?"Basic":"Extended"}),d&&K.jsx("span",{className:"rf-text-xs rf-px-1.5 rf-py-0.5 rf-rounded rf-font-medium rf-flex-shrink-0 rf-bg-blue-100 rf-text-blue-700",children:"Direct lookup"}),r.source==="tscircuit.com"&&r.package.is_private&&K.jsx(Abi,{className:"rf-ml-1 rf-h-3 rf-w-3 rf-text-zinc-400 rf-flex-shrink-0"})]}),r.source==="jlcpcb"&&u!=null?K.jsxs("div",{className:"rf-text-xs rf-text-zinc-500 rf-font-medium rf-whitespace-nowrap rf-flex-shrink-0 sm:rf-hidden",children:[u.toLocaleString()," in stock"]}):null]}),K.jsxs("div",{className:"rf-text-xs rf-text-zinc-500 rf-truncate rf-w-full",children:[l?K.jsx("span",{className:"rf-mr-2",children:l}):null,c]})]}),K.jsxs("div",{children:[r.source==="tscircuit.com"&&o?K.jsx("div",{className:"rf-flex-shrink-0 rf-w-full sm:rf-w-auto",children:K.jsx(fA,{variant:"outline",size:"sm",className:"rf-text-xs rf-w-full sm:rf-w-auto",onClick:p=>{p.stopPropagation(),o(r)},children:"See Details"})}):r.source==="jlcpcb"&&u!=null?K.jsxs("div",{className:"rf-hidden sm:rf-block rf-text-xs rf-text-zinc-500 rf-font-medium rf-whitespace-nowrap rf-flex-shrink-0",children:[u.toLocaleString()," in stock"]}):null,g!=null&&K.jsx("div",{className:"rf-hidden sm:rf-block rf-text-xs rf-text-zinc-500 rf-font-medium rf-whitespace-nowrap rf-flex-shrink-0 rf-text-right",children:qYi(g)})]})]},s)})})},nUi=({circuitJson:t,error:e,isLoading:n,height:o})=>K.jsx("section",{className:"rf-flex rf-min-w-0 rf-items-center rf-justify-center",style:{height:o},children:n?K.jsxs("div",{className:"rf-flex rf-w-full rf-items-center rf-justify-center rf-gap-2 rf-bg-zinc-950 rf-text-sm rf-text-zinc-300",style:{height:o},children:[K.jsx(xE,{className:"rf-h-4 rf-w-4 rf-animate-spin"}),"Loading preview..."]}):e?K.jsx("div",{className:"rf-flex rf-w-full rf-items-center rf-justify-center rf-bg-zinc-950 rf-p-4",style:{height:o},children:K.jsxs("div",{className:"rf-flex rf-max-w-[320px] rf-items-start rf-gap-2 rf-text-sm rf-text-zinc-300",children:[K.jsx(XJe,{className:"rf-mt-0.5 rf-h-4 rf-w-4 rf-flex-shrink-0"}),K.jsx("span",{children:e})]})}):t?K.jsx("div",{className:"rf-w-full rf-min-w-0 rf-overflow-hidden",children:K.jsx(f$e,{circuitJson:t,height:o,allowEditing:!1,clickToInteractEnabled:!1,focusOnHover:!1,disablePcbGroups:!0})}):K.jsx("div",{className:"rf-flex rf-w-full rf-items-center rf-justify-center rf-bg-zinc-950 rf-text-sm rf-text-zinc-300",style:{height:o},children:"No preview"})}),Mpn={importComponentDialog:101,importComponentDetailsDialog:102},oUi=({packageResult:t,isOpen:e,onOpenChange:n,isLoading:o,details:i,previewTab:r,onPreviewTabChange:s,isSubmitting:a,onImport:A})=>{const c=t?.package??null,l=c?.latest_pcb_preview_image_url,u=c?.latest_sch_preview_image_url,g=c?.latest_cad_preview_image_url,h=c?.unscoped_name?.split("/").pop()??c?.unscoped_name,d=c?.org_owner_tscircuit_handle??void 0,p=d?`https://tscircuit.com/${d}`:void 0,m=d&&h?`https://tscircuit.com/${d}/${h}`:void 0;return K.jsx(HT,{open:e,onOpenChange:n,children:K.jsxs(YP,{showOverlay:!1,style:{width:"calc(100vw - 2rem)",zIndex:Mpn.importComponentDetailsDialog},className:"rf-max-w-5xl no-scrollbar !rf-overflow-y-auto rf-max-h-[90vh] rf-overflow-hidden rf-flex rf-flex-col rf-rounded-sm",children:[K.jsx(UP,{className:"rf-pb-4 rf-border-b",children:K.jsx("div",{className:"rf-flex rf-items-start rf-justify-between rf-gap-4",children:K.jsxs("div",{className:"rf-flex-1 rf-min-w-0",children:[K.jsx(KP,{className:"rf-text-xl rf-font-semibold rf-truncate",children:h}),K.jsx(OT,{children:c?.description})]})})}),K.jsxs("div",{className:"rf-flex-1 rf-overflow-y-auto rf-py-4 rf-space-y-6",children:[d?K.jsxs("div",{children:[K.jsx("span",{className:"rf-text-xs rf-font-medium rf-text-gray-500 rf-uppercase rf-tracking-wide",children:"Created by"}),K.jsx("div",{className:"rf-mt-1 rf-text-sm rf-font-medium",children:p?K.jsx("a",{href:p,target:"_blank",rel:"noopener noreferrer",className:"rf-text-black hover:rf-underline",children:d}):d})]}):null,(g||l||u)&&K.jsx(K.Fragment,{children:K.jsxs("div",{children:[K.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-mb-4",children:"Preview"}),K.jsxs(ARe,{value:r,onValueChange:_=>s(_),children:[K.jsxs(Vge,{className:"rf-inline-flex rf-h-9 rf-items-center rf-justify-center rf-rounded-lg rf-bg-zinc-100 rf-p-1 rf-text-zinc-500 dark:rf-bg-zinc-800 dark:rf-text-zinc-400",children:[l&&K.jsx(h6,{value:"pcb",children:"PCB"}),u&&K.jsx(h6,{value:"schematic",children:"Schematic"}),g&&K.jsx(h6,{value:"3d",children:"3D"})]}),K.jsxs("div",{className:"rf-mt-4",children:[K.jsx(cI,{value:"pcb",className:"rf-border rf-rounded-lg rf-overflow-hidden rf-bg-gray-50",children:l?K.jsx("img",{src:l,alt:`${h??"package"} PCB preview`,className:"rf-w-full rf-h-full rf-object-contain rf-bg-white rf-p-4"}):null}),K.jsx(cI,{value:"schematic",className:"rf-border rf-rounded-lg rf-overflow-hidden rf-bg-gray-50",children:u?K.jsx("img",{src:u,alt:`${h??"package"} schematic preview`,className:"rf-w-full rf-h-full rf-object-contain rf-bg-white rf-p-4"}):null}),K.jsx(cI,{value:"3d",className:"rf-border rf-rounded-lg rf-overflow-hidden rf-bg-gray-50",children:g?K.jsx("img",{src:g,alt:`${h??"package"} 3D preview`,className:"rf-w-full rf-h-full rf-object-contain rf-bg-white rf-p-4"}):null})]})]})]})}),i?.ai_description?K.jsxs("section",{children:[K.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-mb-3",children:"AI Description"}),K.jsx("div",{className:"rf-bg-gray-50 rf-border rf-border-gray-200 rf-rounded-lg rf-p-4",children:K.jsx("p",{className:"rf-text-sm rf-text-gray-700 rf-leading-relaxed",children:i.ai_description})})]}):null,i?.ai_usage_instructions?K.jsxs("section",{children:[K.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-mb-3",children:"Usage Instructions"}),K.jsx("div",{className:"rf-bg-gray-50 rf-border rf-border-gray-200 rf-rounded-lg rf-p-4",children:K.jsx("p",{className:"rf-text-sm rf-text-gray-700 rf-leading-relaxed rf-whitespace-pre-wrap",children:i.ai_usage_instructions})})]}):null,o?K.jsxs("div",{className:"rf-flex rf-justify-center rf-items-center rf-gap-2 rf-text-gray-500",children:[K.jsx(xE,{className:"rf-h-4 rf-w-4 rf-animate-spin"}),K.jsx("span",{className:"rf-text-sm",children:"Loading package details..."})]}):null]}),K.jsxs(UU,{className:"rf-pt-4 rf-border-t rf-flex rf-flex-col sm:rf-flex-row rf-justify-between rf-gap-2",children:[K.jsx("div",{className:"rf-flex-1",children:m?K.jsxs(fA,{variant:"outline",size:"sm",className:"rf-gap-2 rf-w-full sm:rf-w-auto",onClick:()=>window.open(m,"_blank"),children:[K.jsx(tbi,{className:"rf-h-4 rf-w-4"}),"View on tscircuit.com"]}):null}),K.jsxs("div",{className:"rf-flex rf-flex-col sm:rf-flex-row rf-gap-2",children:[K.jsx(fA,{variant:"outline",onClick:()=>n(!1),className:"rf-order-2 sm:rf-order-1",children:"Close"}),K.jsx(fA,{onClick:A,disabled:a,className:"rf-bg-blue-600 hover:rf-bg-blue-700",children:a?K.jsx(xE,{className:"rf-h-4 rf-w-4 rf-animate-spin"}):"Import Component"})]})]})]})})},iUi=()=>{const[t,e]=ee.useState(null),[n,o]=ee.useState(!1),i=ee.useCallback(async(s,a)=>{o(!0);try{const A=await fetch(`https://api.tscircuit.com/packages/get?name=${encodeURIComponent(`${s}/${a}`)}`);if(!A.ok)throw new Error(`Failed to load package details: ${A.status}`);const c=await A.json();e(c.package??null)}catch(A){console.error("Failed to fetch package details",A),e(null)}finally{o(!1)}},[]),r=ee.useCallback(()=>{e(null),o(!1)},[]);return{details:t,isLoading:n,fetchDetails:i,reset:r}},rUi=(t,e)=>{const[n,o]=ee.useState({circuitJson:null,error:null,isLoading:!1});return ee.useEffect(()=>{if(!t||!wpn(t)){o({circuitJson:null,error:null,isLoading:!1});return}let i=!1;return o({circuitJson:null,error:null,isLoading:!0}),WYi(t,e).then(r=>{i||o({circuitJson:r,error:null,isLoading:!1})}).catch(r=>{i||o({circuitJson:null,error:r instanceof Error?r.message:"Failed to load footprint preview",isLoading:!1})}),()=>{i=!0}},[t,e]),n},sUi=async(t,e)=>{const n={"Content-Type":"application/json"};e&&(n.Authorization=`Bearer ${e}`);const o=await fetch("https://registry-api.tscircuit.com/packages/search",{method:"POST",headers:n,body:JSON.stringify({query:t})});if(!o.ok)throw new Error(`tscircuit registry error: ${o.status}`);return(await o.json()).packages??[]},aUi=({sessionToken:t})=>{const[e,n]=ee.useState([]),[o,i]=ee.useState(!1),[r,s]=ee.useState(null),[a,A]=ee.useState(!1),c=ee.useCallback(async u=>{const g=u.trim();if(!g)return[];i(!0),s(null);try{const d=(await sUi(g,t)).map(p=>({source:"tscircuit.com",package:p}));return n(d),d}catch(h){return console.error("Error searching tscircuit packages",h),n([]),s(h instanceof Error?h.message:"Failed to search tscircuit packages"),[]}finally{i(!1),A(!0)}},[t]),l=ee.useCallback(()=>{n([]),i(!1),s(null),A(!1)},[]);return{results:e,isSearching:o,error:r,hasSearched:a,search:c,reset:l}},AUi=t=>{const e=/^C(\d+)$/i.exec(t.trim());if(!e)return null;const n=Number(e[1]);if(!Number.isSafeInteger(n))return null;const o=`C${e[1]}`;return{source:"jlcpcb",component:{lcscId:n,manufacturer:o,partNumber:o,description:"Import directly from EasyEDA; stock and availability are unknown",package:"",isDirectLookup:!0}}},Dpn=(t,e)=>{const n=AUi(t);return n?e.some(i=>i.component.partNumber.toUpperCase()===n.component.partNumber)?e:[n,...e]:e},cUi=t=>{const e=t.trim();return/^C\d+/i.test(e)?e.replace(/^C/i,""):e},lUi=()=>{const[t,e]=ee.useState([]),[n,o]=ee.useState(!1),[i,r]=ee.useState(null),[s,a]=ee.useState(!1),A=ee.useCallback(async l=>{const u=cUi(l);if(!u)return[];o(!0),r(null);try{const g=await ZGi(u,10),h=Dpn(l,g.map(d=>({source:"jlcpcb",component:eYi(d)})));return e(h),h}catch(g){console.error("Error searching JLCPCB components",g);const h=Dpn(l,[]);return e(h),r(h.length>0?null:g instanceof Error?g.message:"Failed to search JLCPCB components"),h}finally{o(!1),a(!0)}},[]),c=ee.useCallback(()=>{e([]),o(!1),r(null),a(!1)},[]);return{results:t,isSearching:n,error:i,hasSearched:s,search:A,reset:c}},uUi=()=>{const[t,e]=ee.useState([]),[n,o]=ee.useState(!1),[i,r]=ee.useState(null),[s,a]=ee.useState(!1),A=ee.useCallback(async l=>{const u=l.trim();if(!u)return[];o(!0),r(null);try{const h=(await KYi(u,20)).map(d=>({source:"kicad",footprint:VYi(d)}));return e(h),h}catch(g){return console.error("Error searching KiCad footprints",g),e([]),r(g instanceof Error?g.message:"Failed to search KiCad footprints"),[]}finally{o(!1),a(!0)}},[]),c=ee.useCallback(()=>{e([]),o(!1),r(null),a(!1)},[]);return{results:t,isSearching:n,error:i,hasSearched:s,search:A,reset:c}},gUi=({onTscircuitPackageSelected:t,onJlcpcbComponentTsxLoaded:e,onKicadStringSelected:n})=>{const o=[];return t&&o.push("tscircuit.com"),e&&o.push("jlcpcb"),n&&o.push("kicad"),o},dUi=({isOpen:t,onClose:e,jlcpcbProxyRequestHeaders:n,onKicadStringSelected:o,onTscircuitPackageSelected:i,onJlcpcbComponentTsxLoaded:r,jlcpcbProxyApiBase:s,tscircuitSessionToken:a})=>{dee();const A=ee.useMemo(()=>gUi({onKicadStringSelected:o,onTscircuitPackageSelected:i,onJlcpcbComponentTsxLoaded:r}),[o,i,r]),c=A.length>0,l=A.length===1,[u,g]=ee.useState(A[0]??"tscircuit.com"),[h,d]=ee.useState(""),[p,m]=ee.useState(null),{results:_,isSearching:f,error:I,hasSearched:C,search:y,reset:x}=aUi({sessionToken:a}),{results:E,isSearching:B,error:S,hasSearched:Q,search:w,reset:M}=lUi(),{results:k,isSearching:R,error:F,hasSearched:O,search:U,reset:Y}=uUi(),{details:W,isLoading:te,fetchDetails:j,reset:J}=iUi(),[ie,oe]=ee.useState(null),[ne,ge]=ee.useState(!1),[ue,_e]=ee.useState("pcb"),[le,fe]=ee.useState(null),[he,ye]=ee.useState(!1),Qe=ee.useMemo(()=>({jlcpcb:{headers:n,apiBase:s}}),[s,n]),{circuitJson:we,error:pe,isLoading:ve}=rUi(p,Qe),Me=wpn(p);ee.useEffect(()=>{fe(null)},[p]);const Pe=ee.useCallback(()=>{x(),M(),Y(),m(null)},[M,Y,x]);ee.useEffect(()=>{t||(Pe(),d(""),ge(!1),oe(null),fe(null))},[t,Pe]),ee.useEffect(()=>{d(""),m(null),u==="tscircuit.com"?x():u==="jlcpcb"?M():u==="kicad"&&Y()},[u,M,Y,x]);const He=ot=>{m(ot),oe(ot),_e("pcb"),ge(!0),J();const gt=ot.package.org_owner_tscircuit_handle,Bt=ot.package.unscoped_name;if(gt&&Bt){const Ct=Bt.split("/").pop()??Bt;j(gt,Ct)}},Re=async()=>{h.trim()&&(m(null),u==="tscircuit.com"?await y(h):u==="jlcpcb"?await w(h):u==="kicad"&&await U(h))},Ee=async ot=>{try{if(fe(null),ye(!0),ot.source==="kicad"){if(!o)throw new Error("KiCad handler not provided");await o({result:ot,footprint:ot.footprint.qualifiedName})}else if(ot.source==="jlcpcb"){if(!r)throw new Error("JLCPCB handler not provided");const gt=await tYi(ot.component.partNumber,{headers:n,apiBase:s});await r({result:ot,tsx:gt})}else if(ot.source==="tscircuit.com"){if(!i)throw new Error("tscircuit package handler not provided");const gt=ot.package.org_owner_tscircuit_handle,Bt=ot.package.unscoped_name;if(!gt||!Bt)throw new Error("Missing package metadata");const Ct=Bt.split("/").pop()??Bt,Dt=`@tsci/${gt}.${Ct}`;await i({result:ot,fullPackageName:Dt})}return!0}catch(gt){return console.error("Failed to import component",gt),fe(gt instanceof Error?gt.message:"Failed to import component"),!1}finally{ye(!1)}};let Te=[],Ce=!1,Fe=null,Ye=!1;u==="tscircuit.com"?(Te=_,Ce=f,Fe=I,Ye=C):u==="jlcpcb"?(Te=E,Ce=B,Fe=S,Ye=Q):u==="kicad"&&(Te=k,Ce=R,Fe=F,Ye=O);const tt=async()=>{if(!p)return;await Ee(p)&&(e(),Pe(),d(""))},At=ot=>{ot||e()},at=ot=>{ge(ot),ot||oe(null)};return K.jsxs(HT,{open:t,onOpenChange:At,children:[K.jsxs(YP,{style:{width:"calc(100vw - 2rem)",maxWidth:Me?"min(1120px, calc(100vw - 2rem))":"min(672px, calc(100vw - 2rem))",zIndex:Mpn.importComponentDialog},className:"rf-rounded-sm rf-max-h-[90vh] rf-overflow-y-auto rf-overflow-x-hidden rf-flex rf-flex-col",children:[K.jsxs(UP,{children:[K.jsxs(KP,{className:"rf-text-lg sm:rf-text-xl",children:["Import ",l?gfe[u].label:""," ","Component"]}),K.jsx(OT,{className:"rf-text-sm",children:c?"Search for components from available sources.":"Import options are disabled because no handlers were provided."})]}),c?K.jsxs(ARe,{value:u,onValueChange:ot=>g(ot),className:"rf-min-w-0 rf-w-full",children:[!l&&K.jsx(Vge,{className:"rf-flex rf-w-full rf-gap-2",children:A.map(ot=>K.jsx(h6,{value:ot,className:"rf-flex-1 rf-text-xs sm:rf-text-sm",children:gfe[ot].label},ot))}),K.jsxs("div",{className:"rf-min-w-0",style:Me?{display:"grid",gridTemplateColumns:"minmax(0, 1fr) minmax(360px, 0.95fr)",gap:"1.5rem",alignItems:"start"}:void 0,children:[K.jsxs("div",{className:"rf-min-w-0",children:[K.jsx(jYi,{query:h,placeholder:gfe[u].placeholder,isSearching:Ce,onQueryChange:d,onSubmit:Re}),K.jsx("div",{className:"no-scrollbar rf-mt-4 rf-flex-1 rf-min-h-[200px] !rf-max-h-[40vh] !rf-overflow-y-auto rf-overflow-x-hidden rf-border rf-rounded-md rf-min-w-0",children:Ce?K.jsxs("div",{className:"rf-p-8 rf-text-center rf-text-zinc-500",children:[K.jsx(xE,{className:"rf-h-8 rf-w-8 rf-animate-spin rf-mx-auto rf-mb-2"}),K.jsx("p",{children:"Searching..."})]}):Te.length>0?K.jsx(tUi,{results:Te,selected:p,onSelect:m,onShowDetails:u==="tscircuit.com"?He:void 0}):K.jsx("div",{className:"rf-p-8 rf-text-center rf-text-zinc-500",children:Fe?`Error: ${Fe}`:Ye?gfe[u].emptyMessage:"Enter a search term to find components"})})]}),Me?K.jsx("div",{className:"rf-mt-4",children:K.jsx(nUi,{circuitJson:we,error:pe,isLoading:ve,height:325})}):null]})]}):null,le?K.jsx("div",{className:"rf-text-sm rf-text-red-600 rf-mt-2",children:le}):null,K.jsxs(UU,{className:"rf-flex rf-flex-col sm:rf-flex-row rf-gap-2",children:[K.jsx(fA,{variant:"outline",onClick:e,className:"rf-order-2 sm:rf-order-1",children:"Cancel"}),K.jsx(fA,{onClick:tt,disabled:!p||he,className:"rf-order-1 sm:rf-order-2",children:he?K.jsx(xE,{className:"rf-h-4 rf-w-4 rf-animate-spin"}):"Import"})]})]}),K.jsx(oUi,{packageResult:ie,isOpen:ne,onOpenChange:at,isLoading:te,details:W,previewTab:ue,onPreviewTabChange:ot=>_e(ot),isSubmitting:he,onImport:()=>{ie&&Ee(ie).then(ot=>{ot&&(ge(!1),e(),Pe(),d(""))})}})]})},hUi=t=>{const e=t.match(/export const (\w+) =/);if(!e)throw new Error("Could not determine component name from TSX contents");return e[1]},Npn=t=>{const e=md(s=>s.pushEvent),n=md(s=>s.upsertFile),o=async({result:s,fullPackageName:a})=>{const c=s.package.unscoped_name??s.package.name;await ua.promise(e({event_type:"INSTALL_PACKAGE",full_package_name:a}),{loading:`Requesting install for "${c}"`,success:`Install requested for "${c}"`,error:l=>`Failed to request install: ${l instanceof Error?l.message:String(l)}`})},i=async({footprint:s})=>{await ua.promise(navigator.clipboard.writeText(s),{loading:`Copying "${s}"`,success:`Copied "${s}" to clipboard`,error:a=>`Failed to copy footprint: ${a instanceof Error?a.message:String(a)}`})},r=async({result:s,tsx:a})=>{const c=`imports/${hUi(a)}.tsx`;await ua.promise(n(c,a),{loading:`Importing ${s.component.partNumber}`,success:`Imported to "${c}"`,error:l=>`Failed to import component: ${l instanceof Error?l.message:String(l)}`})};return K.jsx(dUi,{...t,onTscircuitPackageSelected:o,onKicadStringSelected:i,onJlcpcbComponentTsxLoaded:r})};Npn.displayName="ImportComponentDialogForCli";const pUi=async({circuitJson:t,projectName:e})=>{const{convertCircuitJsonToAltiumZip:n}=await Promise.resolve().then(()=>Ygr),o=await n(t,e);return new Blob([new Uint8Array(o)],{type:"application/zip"})},mUi=async({circuitJson:t,projectName:e})=>{await ua.promise((async()=>{const n=await pUi({circuitJson:t,projectName:e});NE(n,{fileName:`${e}_altium_project.zip`})})(),{loading:"Generating Altium project...",success:"Altium project ZIP ready",error:n=>`Failed to generate Altium project: ${n instanceof Error?n.message:String(n)}`})};var eqe={exports:{}},Rpn;function _Ui(){return Rpn||(Rpn=1,(function(t,e){var n={env:{},version:""};(function(o){t.exports=o()})(function(){return(function o(i,r,s){function a(l,u){if(!r[l]){if(!i[l]){var g=typeof Y8=="function"&&Y8;if(!u&&g)return g(l,!0);if(A)return A(l,!0);var h=new Error("Cannot find module '"+l+"'");throw h.code="MODULE_NOT_FOUND",h}var d=r[l]={exports:{}};i[l][0].call(d.exports,function(p){var m=i[l][1][p];return a(m||p)},d,d.exports,o,i,r,s)}return r[l].exports}for(var A=typeof Y8=="function"&&Y8,c=0;c<s.length;c++)a(s[c]);return a})({1:[function(o,i,r){var s=o("./utils"),a=o("./support"),A="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";r.encode=function(c){for(var l,u,g,h,d,p,m,_=[],f=0,I=c.length,C=I,y=s.getTypeOf(c)!=="string";f<c.length;)C=I-f,g=y?(l=c[f++],u=f<I?c[f++]:0,f<I?c[f++]:0):(l=c.charCodeAt(f++),u=f<I?c.charCodeAt(f++):0,f<I?c.charCodeAt(f++):0),h=l>>2,d=(3&l)<<4|u>>4,p=1<C?(15&u)<<2|g>>6:64,m=2<C?63&g:64,_.push(A.charAt(h)+A.charAt(d)+A.charAt(p)+A.charAt(m));return _.join("")},r.decode=function(c){var l,u,g,h,d,p,m=0,_=0,f="data:";if(c.substr(0,f.length)===f)throw new Error("Invalid base64 input, it looks like a data url.");var I,C=3*(c=c.replace(/[^A-Za-z0-9+/=]/g,"")).length/4;if(c.charAt(c.length-1)===A.charAt(64)&&C--,c.charAt(c.length-2)===A.charAt(64)&&C--,C%1!=0)throw new Error("Invalid base64 input, bad content length.");for(I=a.uint8array?new Uint8Array(0|C):new Array(0|C);m<c.length;)l=A.indexOf(c.charAt(m++))<<2|(h=A.indexOf(c.charAt(m++)))>>4,u=(15&h)<<4|(d=A.indexOf(c.charAt(m++)))>>2,g=(3&d)<<6|(p=A.indexOf(c.charAt(m++))),I[_++]=l,d!==64&&(I[_++]=u),p!==64&&(I[_++]=g);return I}},{"./support":30,"./utils":32}],2:[function(o,i,r){var s=o("./external"),a=o("./stream/DataWorker"),A=o("./stream/Crc32Probe"),c=o("./stream/DataLengthProbe");function l(u,g,h,d,p){this.compressedSize=u,this.uncompressedSize=g,this.crc32=h,this.compression=d,this.compressedContent=p}l.prototype={getContentWorker:function(){var u=new a(s.Promise.resolve(this.compressedContent)).pipe(this.compression.uncompressWorker()).pipe(new c("data_length")),g=this;return u.on("end",function(){if(this.streamInfo.data_length!==g.uncompressedSize)throw new Error("Bug : uncompressed data size mismatch")}),u},getCompressedWorker:function(){return new a(s.Promise.resolve(this.compressedContent)).withStreamInfo("compressedSize",this.compressedSize).withStreamInfo("uncompressedSize",this.uncompressedSize).withStreamInfo("crc32",this.crc32).withStreamInfo("compression",this.compression)}},l.createWorkerFrom=function(u,g,h){return u.pipe(new A).pipe(new c("uncompressedSize")).pipe(g.compressWorker(h)).pipe(new c("compressedSize")).withStreamInfo("compression",g)},i.exports=l},{"./external":6,"./stream/Crc32Probe":25,"./stream/DataLengthProbe":26,"./stream/DataWorker":27}],3:[function(o,i,r){var s=o("./stream/GenericWorker");r.STORE={magic:"\0\0",compressWorker:function(){return new s("STORE compression")},uncompressWorker:function(){return new s("STORE decompression")}},r.DEFLATE=o("./flate")},{"./flate":7,"./stream/GenericWorker":28}],4:[function(o,i,r){var s=o("./utils"),a=(function(){for(var A,c=[],l=0;l<256;l++){A=l;for(var u=0;u<8;u++)A=1&A?3988292384^A>>>1:A>>>1;c[l]=A}return c})();i.exports=function(A,c){return A!==void 0&&A.length?s.getTypeOf(A)!=="string"?(function(l,u,g,h){var d=a,p=h+g;l^=-1;for(var m=h;m<p;m++)l=l>>>8^d[255&(l^u[m])];return-1^l})(0|c,A,A.length,0):(function(l,u,g,h){var d=a,p=h+g;l^=-1;for(var m=h;m<p;m++)l=l>>>8^d[255&(l^u.charCodeAt(m))];return-1^l})(0|c,A,A.length,0):0}},{"./utils":32}],5:[function(o,i,r){r.base64=!1,r.binary=!1,r.dir=!1,r.createFolders=!0,r.date=null,r.compression=null,r.compressionOptions=null,r.comment=null,r.unixPermissions=null,r.dosPermissions=null},{}],6:[function(o,i,r){var s=null;s=typeof Promise<"u"?Promise:o("lie"),i.exports={Promise:s}},{lie:37}],7:[function(o,i,r){var s=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Uint32Array<"u",a=o("pako"),A=o("./utils"),c=o("./stream/GenericWorker"),l=s?"uint8array":"array";function u(g,h){c.call(this,"FlateWorker/"+g),this._pako=null,this._pakoAction=g,this._pakoOptions=h,this.meta={}}r.magic="\b\0",A.inherits(u,c),u.prototype.processChunk=function(g){this.meta=g.meta,this._pako===null&&this._createPako(),this._pako.push(A.transformTo(l,g.data),!1)},u.prototype.flush=function(){c.prototype.flush.call(this),this._pako===null&&this._createPako(),this._pako.push([],!0)},u.prototype.cleanUp=function(){c.prototype.cleanUp.call(this),this._pako=null},u.prototype._createPako=function(){this._pako=new a[this._pakoAction]({raw:!0,level:this._pakoOptions.level||-1});var g=this;this._pako.onData=function(h){g.push({data:h,meta:g.meta})}},r.compressWorker=function(g){return new u("Deflate",g)},r.uncompressWorker=function(){return new u("Inflate",{})}},{"./stream/GenericWorker":28,"./utils":32,pako:38}],8:[function(o,i,r){function s(d,p){var m,_="";for(m=0;m<p;m++)_+=String.fromCharCode(255&d),d>>>=8;return _}function a(d,p,m,_,f,I){var C,y,x=d.file,E=d.compression,B=I!==l.utf8encode,S=A.transformTo("string",I(x.name)),Q=A.transformTo("string",l.utf8encode(x.name)),w=x.comment,M=A.transformTo("string",I(w)),k=A.transformTo("string",l.utf8encode(w)),R=Q.length!==x.name.length,F=k.length!==w.length,O="",U="",Y="",W=x.dir,te=x.date,j={crc32:0,compressedSize:0,uncompressedSize:0};p&&!m||(j.crc32=d.crc32,j.compressedSize=d.compressedSize,j.uncompressedSize=d.uncompressedSize);var J=0;p&&(J|=8),B||!R&&!F||(J|=2048);var ie=0,oe=0;W&&(ie|=16),f==="UNIX"?(oe=798,ie|=(function(ge,ue){var _e=ge;return ge||(_e=ue?16893:33204),(65535&_e)<<16})(x.unixPermissions,W)):(oe=20,ie|=(function(ge){return 63&(ge||0)})(x.dosPermissions)),C=te.getUTCHours(),C<<=6,C|=te.getUTCMinutes(),C<<=5,C|=te.getUTCSeconds()/2,y=te.getUTCFullYear()-1980,y<<=4,y|=te.getUTCMonth()+1,y<<=5,y|=te.getUTCDate(),R&&(U=s(1,1)+s(u(S),4)+Q,O+="up"+s(U.length,2)+U),F&&(Y=s(1,1)+s(u(M),4)+k,O+="uc"+s(Y.length,2)+Y);var ne="";return ne+=`
5672
5672
  \0`,ne+=s(J,2),ne+=E.magic,ne+=s(C,2),ne+=s(y,2),ne+=s(j.crc32,4),ne+=s(j.compressedSize,4),ne+=s(j.uncompressedSize,4),ne+=s(S.length,2),ne+=s(O.length,2),{fileRecord:g.LOCAL_FILE_HEADER+ne+S+O,dirRecord:g.CENTRAL_FILE_HEADER+s(oe,2)+ne+s(M.length,2)+"\0\0\0\0"+s(ie,4)+s(_,4)+S+O+M}}var A=o("../utils"),c=o("../stream/GenericWorker"),l=o("../utf8"),u=o("../crc32"),g=o("../signature");function h(d,p,m,_){c.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=p,this.zipPlatform=m,this.encodeFileName=_,this.streamFiles=d,this.accumulate=!1,this.contentBuffer=[],this.dirRecords=[],this.currentSourceOffset=0,this.entriesCount=0,this.currentFile=null,this._sources=[]}A.inherits(h,c),h.prototype.push=function(d){var p=d.meta.percent||0,m=this.entriesCount,_=this._sources.length;this.accumulate?this.contentBuffer.push(d):(this.bytesWritten+=d.data.length,c.prototype.push.call(this,{data:d.data,meta:{currentFile:this.currentFile,percent:m?(p+100*(m-_-1))/m:100}}))},h.prototype.openedSource=function(d){this.currentSourceOffset=this.bytesWritten,this.currentFile=d.file.name;var p=this.streamFiles&&!d.file.dir;if(p){var m=a(d,p,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:m.fileRecord,meta:{percent:0}})}else this.accumulate=!0},h.prototype.closedSource=function(d){this.accumulate=!1;var p=this.streamFiles&&!d.file.dir,m=a(d,p,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(m.dirRecord),p)this.push({data:(function(_){return g.DATA_DESCRIPTOR+s(_.crc32,4)+s(_.compressedSize,4)+s(_.uncompressedSize,4)})(d),meta:{percent:100}});else for(this.push({data:m.fileRecord,meta:{percent:0}});this.contentBuffer.length;)this.push(this.contentBuffer.shift());this.currentFile=null},h.prototype.flush=function(){for(var d=this.bytesWritten,p=0;p<this.dirRecords.length;p++)this.push({data:this.dirRecords[p],meta:{percent:100}});var m=this.bytesWritten-d,_=(function(f,I,C,y,x){var E=A.transformTo("string",x(y));return g.CENTRAL_DIRECTORY_END+"\0\0\0\0"+s(f,2)+s(f,2)+s(I,4)+s(C,4)+s(E.length,2)+E})(this.dirRecords.length,m,d,this.zipComment,this.encodeFileName);this.push({data:_,meta:{percent:100}})},h.prototype.prepareNextSource=function(){this.previous=this._sources.shift(),this.openedSource(this.previous.streamInfo),this.isPaused?this.previous.pause():this.previous.resume()},h.prototype.registerPrevious=function(d){this._sources.push(d);var p=this;return d.on("data",function(m){p.processChunk(m)}),d.on("end",function(){p.closedSource(p.previous.streamInfo),p._sources.length?p.prepareNextSource():p.end()}),d.on("error",function(m){p.error(m)}),this},h.prototype.resume=function(){return!!c.prototype.resume.call(this)&&(!this.previous&&this._sources.length?(this.prepareNextSource(),!0):this.previous||this._sources.length||this.generatedError?void 0:(this.end(),!0))},h.prototype.error=function(d){var p=this._sources;if(!c.prototype.error.call(this,d))return!1;for(var m=0;m<p.length;m++)try{p[m].error(d)}catch{}return!0},h.prototype.lock=function(){c.prototype.lock.call(this);for(var d=this._sources,p=0;p<d.length;p++)d[p].lock()},i.exports=h},{"../crc32":4,"../signature":23,"../stream/GenericWorker":28,"../utf8":31,"../utils":32}],9:[function(o,i,r){var s=o("../compressions"),a=o("./ZipFileWorker");r.generateWorker=function(A,c,l){var u=new a(c.streamFiles,l,c.platform,c.encodeFileName),g=0;try{A.forEach(function(h,d){g++;var p=(function(I,C){var y=I||C,x=s[y];if(!x)throw new Error(y+" is not a valid compression method !");return x})(d.options.compression,c.compression),m=d.options.compressionOptions||c.compressionOptions||{},_=d.dir,f=d.date;d._compressWorker(p,m).withStreamInfo("file",{name:h,dir:_,date:f,comment:d.comment||"",unixPermissions:d.unixPermissions,dosPermissions:d.dosPermissions}).pipe(u)}),u.entriesCount=g}catch(h){u.error(h)}return u}},{"../compressions":3,"./ZipFileWorker":8}],10:[function(o,i,r){function s(){if(!(this instanceof s))return new s;if(arguments.length)throw new Error("The constructor with parameters has been removed in JSZip 3.0, please check the upgrade guide.");this.files=Object.create(null),this.comment=null,this.root="",this.clone=function(){var a=new s;for(var A in this)typeof this[A]!="function"&&(a[A]=this[A]);return a}}(s.prototype=o("./object")).loadAsync=o("./load"),s.support=o("./support"),s.defaults=o("./defaults"),s.version="3.10.2",s.loadAsync=function(a,A){return new s().loadAsync(a,A)},s.external=o("./external"),i.exports=s},{"./defaults":5,"./external":6,"./load":11,"./object":15,"./support":30}],11:[function(o,i,r){var s=o("./utils"),a=o("./external"),A=o("./utf8"),c=o("./zipEntries"),l=o("./stream/Crc32Probe"),u=o("./nodejsUtils");function g(h){return new a.Promise(function(d,p){var m=h.decompressed.getContentWorker().pipe(new l);m.on("error",function(_){p(_)}).on("end",function(){m.streamInfo.crc32!==h.decompressed.crc32?p(new Error("Corrupted zip : CRC32 mismatch")):d()}).resume()})}i.exports=function(h,d){var p=this;return d=s.extend(d||{},{base64:!1,checkCRC32:!1,optimizedBinaryString:!1,createFolders:!1,decodeFileName:A.utf8decode}),u.isNode&&u.isStream(h)?a.Promise.reject(new Error("JSZip can't accept a stream when loading a zip file.")):s.prepareContent("the loaded zip file",h,!0,d.optimizedBinaryString,d.base64).then(function(m){var _=new c(d);return _.load(m),_}).then(function(m){var _=[a.Promise.resolve(m)],f=m.files;if(d.checkCRC32)for(var I=0;I<f.length;I++)_.push(g(f[I]));return a.Promise.all(_)}).then(function(m){for(var _=m.shift(),f=_.files,I=0;I<f.length;I++){var C=f[I],y=C.fileNameStr,x=s.resolve(C.fileNameStr);p.file(x,C.decompressed,{binary:!0,optimizedBinaryString:!0,date:C.date,dir:C.dir,comment:C.fileCommentStr.length?C.fileCommentStr:null,unixPermissions:C.unixPermissions,dosPermissions:C.dosPermissions,createFolders:d.createFolders}),C.dir||(p.file(x).unsafeOriginalName=y)}return _.zipComment.length&&(p.comment=_.zipComment),p})}},{"./external":6,"./nodejsUtils":14,"./stream/Crc32Probe":25,"./utf8":31,"./utils":32,"./zipEntries":33}],12:[function(o,i,r){var s=o("../utils"),a=o("../stream/GenericWorker");function A(c,l){a.call(this,"Nodejs stream input adapter for "+c),this._upstreamEnded=!1,this._bindStream(l)}s.inherits(A,a),A.prototype._bindStream=function(c){var l=this;(this._stream=c).pause(),c.on("data",function(u){l.push({data:u,meta:{percent:0}})}).on("error",function(u){l.isPaused?this.generatedError=u:l.error(u)}).on("end",function(){l.isPaused?l._upstreamEnded=!0:l.end()})},A.prototype.pause=function(){return!!a.prototype.pause.call(this)&&(this._stream.pause(),!0)},A.prototype.resume=function(){return!!a.prototype.resume.call(this)&&(this._upstreamEnded?this.end():this._stream.resume(),!0)},i.exports=A},{"../stream/GenericWorker":28,"../utils":32}],13:[function(o,i,r){var s=o("readable-stream").Readable;function a(A,c,l){s.call(this,c),this._helper=A;var u=this;A.on("data",function(g,h){u.push(g)||u._helper.pause(),l&&l(h)}).on("error",function(g){u.emit("error",g)}).on("end",function(){u.push(null)})}o("../utils").inherits(a,s),a.prototype._read=function(){this._helper.resume()},i.exports=a},{"../utils":32,"readable-stream":16}],14:[function(o,i,r){i.exports={isNode:typeof Buffer<"u",newBufferFrom:function(s,a){if(Buffer.from&&Buffer.from!==Uint8Array.from)return Buffer.from(s,a);if(typeof s=="number")throw new Error('The "data" argument must not be a number');return new Buffer(s,a)},allocBuffer:function(s){if(Buffer.alloc)return Buffer.alloc(s);var a=new Buffer(s);return a.fill(0),a},isBuffer:function(s){return Buffer.isBuffer(s)},isStream:function(s){return s&&typeof s.on=="function"&&typeof s.pause=="function"&&typeof s.resume=="function"}}},{}],15:[function(o,i,r){function s(x,E,B){var S,Q=A.getTypeOf(E),w=A.extend(B||{},u);w.date=w.date||new Date,w.compression!==null&&(w.compression=w.compression.toUpperCase()),typeof w.unixPermissions=="string"&&(w.unixPermissions=parseInt(w.unixPermissions,8)),w.unixPermissions&&16384&w.unixPermissions&&(w.dir=!0),w.dosPermissions&&16&w.dosPermissions&&(w.dir=!0),w.dir&&(x=f(x)),w.createFolders&&(S=_(x))&&I.call(this,S,!0);var M=Q==="string"&&w.binary===!1&&w.base64===!1;B&&B.binary!==void 0||(w.binary=!M),(E instanceof g&&E.uncompressedSize===0||w.dir||!E||E.length===0)&&(w.base64=!1,w.binary=!0,E="",w.compression="STORE",Q="string");var k=null;k=E instanceof g||E instanceof c?E:p.isNode&&p.isStream(E)?new m(x,E):A.prepareContent(x,E,w.binary,w.optimizedBinaryString,w.base64);var R=new h(x,k,w);this.files[x]=R}var a=o("./utf8"),A=o("./utils"),c=o("./stream/GenericWorker"),l=o("./stream/StreamHelper"),u=o("./defaults"),g=o("./compressedObject"),h=o("./zipObject"),d=o("./generate"),p=o("./nodejsUtils"),m=o("./nodejs/NodejsStreamInputAdapter"),_=function(x){x.slice(-1)==="/"&&(x=x.substring(0,x.length-1));var E=x.lastIndexOf("/");return 0<E?x.substring(0,E):""},f=function(x){return x.slice(-1)!=="/"&&(x+="/"),x},I=function(x,E){return E=E!==void 0?E:u.createFolders,x=f(x),this.files[x]||s.call(this,x,null,{dir:!0,createFolders:E}),this.files[x]};function C(x){return Object.prototype.toString.call(x)==="[object RegExp]"}var y={load:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},forEach:function(x){var E,B,S;for(E in this.files)S=this.files[E],(B=E.slice(this.root.length,E.length))&&E.slice(0,this.root.length)===this.root&&x(B,S)},filter:function(x){var E=[];return this.forEach(function(B,S){x(B,S)&&E.push(S)}),E},file:function(x,E,B){if(arguments.length!==1)return x=this.root+x,s.call(this,x,E,B),this;if(C(x)){var S=x;return this.filter(function(w,M){return!M.dir&&S.test(w)})}var Q=this.files[this.root+x];return Q&&!Q.dir?Q:null},folder:function(x){if(!x)return this;if(C(x))return this.filter(function(Q,w){return w.dir&&x.test(Q)});var E=this.root+x,B=I.call(this,E),S=this.clone();return S.root=B.name,S},remove:function(x){x=this.root+x;var E=this.files[x];if(E||(x.slice(-1)!=="/"&&(x+="/"),E=this.files[x]),E&&!E.dir)delete this.files[x];else for(var B=this.filter(function(Q,w){return w.name.slice(0,x.length)===x}),S=0;S<B.length;S++)delete this.files[B[S].name];return this},generate:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},generateInternalStream:function(x){var E,B={};try{if((B=A.extend(x||{},{streamFiles:!1,compression:"STORE",compressionOptions:null,type:"",platform:"DOS",comment:null,mimeType:"application/zip",encodeFileName:a.utf8encode})).type=B.type.toLowerCase(),B.compression=B.compression.toUpperCase(),B.type==="binarystring"&&(B.type="string"),!B.type)throw new Error("No output type specified.");A.checkSupport(B.type),B.platform!=="darwin"&&B.platform!=="freebsd"&&B.platform!=="linux"&&B.platform!=="sunos"||(B.platform="UNIX"),B.platform==="win32"&&(B.platform="DOS");var S=B.comment||this.comment||"";E=d.generateWorker(this,B,S)}catch(Q){(E=new c("error")).error(Q)}return new l(E,B.type||"string",B.mimeType)},generateAsync:function(x,E){return this.generateInternalStream(x).accumulate(E)},generateNodeStream:function(x,E){return(x=x||{}).type||(x.type="nodebuffer"),this.generateInternalStream(x).toNodejsStream(E)}};i.exports=y},{"./compressedObject":2,"./defaults":5,"./generate":9,"./nodejs/NodejsStreamInputAdapter":12,"./nodejsUtils":14,"./stream/GenericWorker":28,"./stream/StreamHelper":29,"./utf8":31,"./utils":32,"./zipObject":35}],16:[function(o,i,r){i.exports=o("stream")},{stream:void 0}],17:[function(o,i,r){var s=o("./DataReader");function a(A){s.call(this,A);for(var c=0;c<this.data.length;c++)A[c]=255&A[c]}o("../utils").inherits(a,s),a.prototype.byteAt=function(A){return this.data[this.zero+A]},a.prototype.lastIndexOfSignature=function(A){for(var c=A.charCodeAt(0),l=A.charCodeAt(1),u=A.charCodeAt(2),g=A.charCodeAt(3),h=this.length-4;0<=h;--h)if(this.data[h]===c&&this.data[h+1]===l&&this.data[h+2]===u&&this.data[h+3]===g)return h-this.zero;return-1},a.prototype.readAndCheckSignature=function(A){var c=A.charCodeAt(0),l=A.charCodeAt(1),u=A.charCodeAt(2),g=A.charCodeAt(3),h=this.readData(4);return c===h[0]&&l===h[1]&&u===h[2]&&g===h[3]},a.prototype.readData=function(A){if(this.checkOffset(A),A===0)return[];var c=this.data.slice(this.zero+this.index,this.zero+this.index+A);return this.index+=A,c},i.exports=a},{"../utils":32,"./DataReader":18}],18:[function(o,i,r){var s=o("../utils");function a(A){this.data=A,this.length=A.length,this.index=0,this.zero=0}a.prototype={checkOffset:function(A){this.checkIndex(this.index+A)},checkIndex:function(A){if(this.length<this.zero+A||A<0)throw new Error("End of data reached (data length = "+this.length+", asked index = "+A+"). Corrupted zip ?")},setIndex:function(A){this.checkIndex(A),this.index=A},skip:function(A){this.setIndex(this.index+A)},byteAt:function(){},readInt:function(A){var c,l=0;for(this.checkOffset(A),c=this.index+A-1;c>=this.index;c--)l=(l<<8)+this.byteAt(c);return this.index+=A,l},readString:function(A){return s.transformTo("string",this.readData(A))},readData:function(){},lastIndexOfSignature:function(){},readAndCheckSignature:function(){},readDate:function(){var A=this.readInt(4);return new Date(Date.UTC(1980+(A>>25&127),(A>>21&15)-1,A>>16&31,A>>11&31,A>>5&63,(31&A)<<1))}},i.exports=a},{"../utils":32}],19:[function(o,i,r){var s=o("./Uint8ArrayReader");function a(A){s.call(this,A)}o("../utils").inherits(a,s),a.prototype.readData=function(A){this.checkOffset(A);var c=this.data.slice(this.zero+this.index,this.zero+this.index+A);return this.index+=A,c},i.exports=a},{"../utils":32,"./Uint8ArrayReader":21}],20:[function(o,i,r){var s=o("./DataReader");function a(A){s.call(this,A)}o("../utils").inherits(a,s),a.prototype.byteAt=function(A){return this.data.charCodeAt(this.zero+A)},a.prototype.lastIndexOfSignature=function(A){return this.data.lastIndexOf(A)-this.zero},a.prototype.readAndCheckSignature=function(A){return A===this.readData(4)},a.prototype.readData=function(A){this.checkOffset(A);var c=this.data.slice(this.zero+this.index,this.zero+this.index+A);return this.index+=A,c},i.exports=a},{"../utils":32,"./DataReader":18}],21:[function(o,i,r){var s=o("./ArrayReader");function a(A){s.call(this,A)}o("../utils").inherits(a,s),a.prototype.readData=function(A){if(this.checkOffset(A),A===0)return new Uint8Array(0);var c=this.data.subarray(this.zero+this.index,this.zero+this.index+A);return this.index+=A,c},i.exports=a},{"../utils":32,"./ArrayReader":17}],22:[function(o,i,r){var s=o("../utils"),a=o("../support"),A=o("./ArrayReader"),c=o("./StringReader"),l=o("./NodeBufferReader"),u=o("./Uint8ArrayReader");i.exports=function(g){var h=s.getTypeOf(g);return s.checkSupport(h),h!=="string"||a.uint8array?h==="nodebuffer"?new l(g):a.uint8array?new u(s.transformTo("uint8array",g)):new A(s.transformTo("array",g)):new c(g)}},{"../support":30,"../utils":32,"./ArrayReader":17,"./NodeBufferReader":19,"./StringReader":20,"./Uint8ArrayReader":21}],23:[function(o,i,r){r.LOCAL_FILE_HEADER="PK",r.CENTRAL_FILE_HEADER="PK",r.CENTRAL_DIRECTORY_END="PK",r.ZIP64_CENTRAL_DIRECTORY_LOCATOR="PK\x07",r.ZIP64_CENTRAL_DIRECTORY_END="PK",r.DATA_DESCRIPTOR="PK\x07\b"},{}],24:[function(o,i,r){var s=o("./GenericWorker"),a=o("../utils");function A(c){s.call(this,"ConvertWorker to "+c),this.destType=c}a.inherits(A,s),A.prototype.processChunk=function(c){this.push({data:a.transformTo(this.destType,c.data),meta:c.meta})},i.exports=A},{"../utils":32,"./GenericWorker":28}],25:[function(o,i,r){var s=o("./GenericWorker"),a=o("../crc32");function A(){s.call(this,"Crc32Probe"),this.withStreamInfo("crc32",0)}o("../utils").inherits(A,s),A.prototype.processChunk=function(c){this.streamInfo.crc32=a(c.data,this.streamInfo.crc32||0),this.push(c)},i.exports=A},{"../crc32":4,"../utils":32,"./GenericWorker":28}],26:[function(o,i,r){var s=o("../utils"),a=o("./GenericWorker");function A(c){a.call(this,"DataLengthProbe for "+c),this.propName=c,this.withStreamInfo(c,0)}s.inherits(A,a),A.prototype.processChunk=function(c){if(c){var l=this.streamInfo[this.propName]||0;this.streamInfo[this.propName]=l+c.data.length}a.prototype.processChunk.call(this,c)},i.exports=A},{"../utils":32,"./GenericWorker":28}],27:[function(o,i,r){var s=o("../utils"),a=o("./GenericWorker");function A(c){a.call(this,"DataWorker");var l=this;this.dataIsReady=!1,this.index=0,this.max=0,this.data=null,this.type="",this._tickScheduled=!1,c.then(function(u){l.dataIsReady=!0,l.data=u,l.max=u&&u.length||0,l.type=s.getTypeOf(u),l.isPaused||l._tickAndRepeat()},function(u){l.error(u)})}s.inherits(A,a),A.prototype.cleanUp=function(){a.prototype.cleanUp.call(this),this.data=null},A.prototype.resume=function(){return!!a.prototype.resume.call(this)&&(!this._tickScheduled&&this.dataIsReady&&(this._tickScheduled=!0,s.delay(this._tickAndRepeat,[],this)),!0)},A.prototype._tickAndRepeat=function(){this._tickScheduled=!1,this.isPaused||this.isFinished||(this._tick(),this.isFinished||(s.delay(this._tickAndRepeat,[],this),this._tickScheduled=!0))},A.prototype._tick=function(){if(this.isPaused||this.isFinished)return!1;var c=null,l=Math.min(this.max,this.index+16384);if(this.index>=this.max)return this.end();switch(this.type){case"string":c=this.data.substring(this.index,l);break;case"uint8array":c=this.data.subarray(this.index,l);break;case"array":case"nodebuffer":c=this.data.slice(this.index,l)}return this.index=l,this.push({data:c,meta:{percent:this.max?this.index/this.max*100:0}})},i.exports=A},{"../utils":32,"./GenericWorker":28}],28:[function(o,i,r){function s(a){this.name=a||"default",this.streamInfo={},this.generatedError=null,this.extraStreamInfo={},this.isPaused=!0,this.isFinished=!1,this.isLocked=!1,this._listeners={data:[],end:[],error:[]},this.previous=null}s.prototype={push:function(a){this.emit("data",a)},end:function(){if(this.isFinished)return!1;this.flush();try{this.emit("end"),this.cleanUp(),this.isFinished=!0}catch(a){this.emit("error",a)}return!0},error:function(a){return!this.isFinished&&(this.isPaused?this.generatedError=a:(this.isFinished=!0,this.emit("error",a),this.previous&&this.previous.error(a),this.cleanUp()),!0)},on:function(a,A){return this._listeners[a].push(A),this},cleanUp:function(){this.streamInfo=this.generatedError=this.extraStreamInfo=null,this._listeners=[]},emit:function(a,A){if(this._listeners[a])for(var c=0;c<this._listeners[a].length;c++)this._listeners[a][c].call(this,A)},pipe:function(a){return a.registerPrevious(this)},registerPrevious:function(a){if(this.isLocked)throw new Error("The stream '"+this+"' has already been used.");this.streamInfo=a.streamInfo,this.mergeStreamInfo(),this.previous=a;var A=this;return a.on("data",function(c){A.processChunk(c)}),a.on("end",function(){A.end()}),a.on("error",function(c){A.error(c)}),this},pause:function(){return!this.isPaused&&!this.isFinished&&(this.isPaused=!0,this.previous&&this.previous.pause(),!0)},resume:function(){if(!this.isPaused||this.isFinished)return!1;var a=this.isPaused=!1;return this.generatedError&&(this.error(this.generatedError),a=!0),this.previous&&this.previous.resume(),!a},flush:function(){},processChunk:function(a){this.push(a)},withStreamInfo:function(a,A){return this.extraStreamInfo[a]=A,this.mergeStreamInfo(),this},mergeStreamInfo:function(){for(var a in this.extraStreamInfo)Object.prototype.hasOwnProperty.call(this.extraStreamInfo,a)&&(this.streamInfo[a]=this.extraStreamInfo[a])},lock:function(){if(this.isLocked)throw new Error("The stream '"+this+"' has already been used.");this.isLocked=!0,this.previous&&this.previous.lock()},toString:function(){var a="Worker "+this.name;return this.previous?this.previous+" -> "+a:a}},i.exports=s},{}],29:[function(o,i,r){var s=o("../utils"),a=o("./ConvertWorker"),A=o("./GenericWorker"),c=o("../base64"),l=o("../support"),u=o("../external"),g=null;if(l.nodestream)try{g=o("../nodejs/NodejsStreamOutputAdapter")}catch{}function h(p,m){return new u.Promise(function(_,f){var I=[],C=p._internalType,y=p._outputType,x=p._mimeType;p.on("data",function(E,B){I.push(E),m&&m(B)}).on("error",function(E){I=[],f(E)}).on("end",function(){try{var E=(function(B,S,Q){switch(B){case"blob":return s.newBlob(s.transformTo("arraybuffer",S),Q);case"base64":return c.encode(S);default:return s.transformTo(B,S)}})(y,(function(B,S){var Q,w=0,M=null,k=0;for(Q=0;Q<S.length;Q++)k+=S[Q].length;switch(B){case"string":return S.join("");case"array":return Array.prototype.concat.apply([],S);case"uint8array":for(M=new Uint8Array(k),Q=0;Q<S.length;Q++)M.set(S[Q],w),w+=S[Q].length;return M;case"nodebuffer":return Buffer.concat(S);default:throw new Error("concat : unsupported type '"+B+"'")}})(C,I),x);_(E)}catch(B){f(B)}I=[]}).resume()})}function d(p,m,_){var f=m;switch(m){case"blob":case"arraybuffer":f="uint8array";break;case"base64":f="string"}try{this._internalType=f,this._outputType=m,this._mimeType=_,s.checkSupport(f),this._worker=p.pipe(new a(f)),p.lock()}catch(I){this._worker=new A("error"),this._worker.error(I)}}d.prototype={accumulate:function(p){return h(this,p)},on:function(p,m){var _=this;return p==="data"?this._worker.on(p,function(f){m.call(_,f.data,f.meta)}):this._worker.on(p,function(){s.delay(m,arguments,_)}),this},resume:function(){return s.delay(this._worker.resume,[],this._worker),this},pause:function(){return this._worker.pause(),this},toNodejsStream:function(p){if(s.checkSupport("nodestream"),this._outputType!=="nodebuffer")throw new Error(this._outputType+" is not supported by this method");return new g(this,{objectMode:this._outputType!=="nodebuffer"},p)}},i.exports=d},{"../base64":1,"../external":6,"../nodejs/NodejsStreamOutputAdapter":13,"../support":30,"../utils":32,"./ConvertWorker":24,"./GenericWorker":28}],30:[function(o,i,r){if(r.base64=!0,r.array=!0,r.string=!0,r.arraybuffer=typeof ArrayBuffer<"u"&&typeof Uint8Array<"u",r.nodebuffer=typeof Buffer<"u",r.uint8array=typeof Uint8Array<"u",typeof ArrayBuffer>"u")r.blob=!1;else{var s=new ArrayBuffer(0);try{r.blob=new Blob([s],{type:"application/zip"}).size===0}catch{try{var a=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);a.append(s),r.blob=a.getBlob("application/zip").size===0}catch{r.blob=!1}}}try{r.nodestream=!!o("readable-stream").Readable}catch{r.nodestream=!1}},{"readable-stream":16}],31:[function(o,i,r){for(var s=o("./utils"),a=o("./support"),A=o("./nodejsUtils"),c=o("./stream/GenericWorker"),l=new Array(256),u=0;u<256;u++)l[u]=252<=u?6:248<=u?5:240<=u?4:224<=u?3:192<=u?2:1;l[254]=l[254]=1;function g(){c.call(this,"utf-8 decode"),this.leftOver=null}function h(){c.call(this,"utf-8 encode")}r.utf8encode=function(d){return a.nodebuffer?A.newBufferFrom(d,"utf-8"):(function(p){var m,_,f,I,C,y=p.length,x=0;for(I=0;I<y;I++)(64512&(_=p.charCodeAt(I)))==55296&&I+1<y&&(64512&(f=p.charCodeAt(I+1)))==56320&&(_=65536+(_-55296<<10)+(f-56320),I++),x+=_<128?1:_<2048?2:_<65536?3:4;for(m=a.uint8array?new Uint8Array(x):new Array(x),I=C=0;C<x;I++)(64512&(_=p.charCodeAt(I)))==55296&&I+1<y&&(64512&(f=p.charCodeAt(I+1)))==56320&&(_=65536+(_-55296<<10)+(f-56320),I++),_<128?m[C++]=_:(_<2048?m[C++]=192|_>>>6:(_<65536?m[C++]=224|_>>>12:(m[C++]=240|_>>>18,m[C++]=128|_>>>12&63),m[C++]=128|_>>>6&63),m[C++]=128|63&_);return m})(d)},r.utf8decode=function(d){return a.nodebuffer?s.transformTo("nodebuffer",d).toString("utf-8"):(function(p){var m,_,f,I,C=p.length,y=new Array(2*C);for(m=_=0;m<C;)if((f=p[m++])<128)y[_++]=f;else if(4<(I=l[f]))y[_++]=65533,m+=I-1;else{for(f&=I===2?31:I===3?15:7;1<I&&m<C;)f=f<<6|63&p[m++],I--;1<I?y[_++]=65533:f<65536?y[_++]=f:(f-=65536,y[_++]=55296|f>>10&1023,y[_++]=56320|1023&f)}return y.length!==_&&(y.subarray?y=y.subarray(0,_):y.length=_),s.applyFromCharCode(y)})(d=s.transformTo(a.uint8array?"uint8array":"array",d))},s.inherits(g,c),g.prototype.processChunk=function(d){var p=s.transformTo(a.uint8array?"uint8array":"array",d.data);if(this.leftOver&&this.leftOver.length){if(a.uint8array){var m=p;(p=new Uint8Array(m.length+this.leftOver.length)).set(this.leftOver,0),p.set(m,this.leftOver.length)}else p=this.leftOver.concat(p);this.leftOver=null}var _=(function(I,C){var y;for((C=C||I.length)>I.length&&(C=I.length),y=C-1;0<=y&&(192&I[y])==128;)y--;return y<0||y===0?C:y+l[I[y]]>C?y:C})(p),f=p;_!==p.length&&(a.uint8array?(f=p.subarray(0,_),this.leftOver=p.subarray(_,p.length)):(f=p.slice(0,_),this.leftOver=p.slice(_,p.length))),this.push({data:r.utf8decode(f),meta:d.meta})},g.prototype.flush=function(){this.leftOver&&this.leftOver.length&&(this.push({data:r.utf8decode(this.leftOver),meta:{}}),this.leftOver=null)},r.Utf8DecodeWorker=g,s.inherits(h,c),h.prototype.processChunk=function(d){this.push({data:r.utf8encode(d.data),meta:d.meta})},r.Utf8EncodeWorker=h},{"./nodejsUtils":14,"./stream/GenericWorker":28,"./support":30,"./utils":32}],32:[function(o,i,r){var s=o("./support"),a=o("./base64"),A=o("./nodejsUtils"),c=o("./external");function l(m){return m}function u(m,_){for(var f=0;f<m.length;++f)_[f]=255&m.charCodeAt(f);return _}o("setimmediate"),r.newBlob=function(m,_){r.checkSupport("blob");try{return new Blob([m],{type:_})}catch{try{var f=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);return f.append(m),f.getBlob(_)}catch{throw new Error("Bug : can't construct the Blob.")}}};var g={stringifyByChunk:function(m,_,f){var I=[],C=0,y=m.length;if(y<=f)return String.fromCharCode.apply(null,m);for(;C<y;)_==="array"||_==="nodebuffer"?I.push(String.fromCharCode.apply(null,m.slice(C,Math.min(C+f,y)))):I.push(String.fromCharCode.apply(null,m.subarray(C,Math.min(C+f,y)))),C+=f;return I.join("")},stringifyByChar:function(m){for(var _="",f=0;f<m.length;f++)_+=String.fromCharCode(m[f]);return _},applyCanBeUsed:{uint8array:(function(){try{return s.uint8array&&String.fromCharCode.apply(null,new Uint8Array(1)).length===1}catch{return!1}})(),nodebuffer:(function(){try{return s.nodebuffer&&String.fromCharCode.apply(null,A.allocBuffer(1)).length===1}catch{return!1}})()}};function h(m){var _=65536,f=r.getTypeOf(m),I=!0;if(f==="uint8array"?I=g.applyCanBeUsed.uint8array:f==="nodebuffer"&&(I=g.applyCanBeUsed.nodebuffer),I)for(;1<_;)try{return g.stringifyByChunk(m,f,_)}catch{_=Math.floor(_/2)}return g.stringifyByChar(m)}function d(m,_){for(var f=0;f<m.length;f++)_[f]=m[f];return _}r.applyFromCharCode=h;var p={};p.string={string:l,array:function(m){return u(m,new Array(m.length))},arraybuffer:function(m){return p.string.uint8array(m).buffer},uint8array:function(m){return u(m,new Uint8Array(m.length))},nodebuffer:function(m){return u(m,A.allocBuffer(m.length))}},p.array={string:h,array:l,arraybuffer:function(m){return new Uint8Array(m).buffer},uint8array:function(m){return new Uint8Array(m)},nodebuffer:function(m){return A.newBufferFrom(m)}},p.arraybuffer={string:function(m){return h(new Uint8Array(m))},array:function(m){return d(new Uint8Array(m),new Array(m.byteLength))},arraybuffer:l,uint8array:function(m){return new Uint8Array(m)},nodebuffer:function(m){return A.newBufferFrom(new Uint8Array(m))}},p.uint8array={string:h,array:function(m){return d(m,new Array(m.length))},arraybuffer:function(m){return m.buffer},uint8array:l,nodebuffer:function(m){return A.newBufferFrom(m)}},p.nodebuffer={string:h,array:function(m){return d(m,new Array(m.length))},arraybuffer:function(m){return p.nodebuffer.uint8array(m).buffer},uint8array:function(m){return d(m,new Uint8Array(m.length))},nodebuffer:l},r.transformTo=function(m,_){if(_=_||"",!m)return _;r.checkSupport(m);var f=r.getTypeOf(_);return p[f][m](_)},r.resolve=function(m){for(var _=m.split("/"),f=[],I=0;I<_.length;I++){var C=_[I];C==="."||C===""&&I!==0&&I!==_.length-1||(C===".."?f.pop():f.push(C))}return f.join("/")},r.getTypeOf=function(m){if(typeof m=="string")return"string";var _=Object.prototype.toString.call(m);return _==="[object Array]"?"array":s.nodebuffer&&A.isBuffer(m)?"nodebuffer":s.uint8array&&_==="[object Uint8Array]"?"uint8array":s.arraybuffer&&_==="[object ArrayBuffer]"?"arraybuffer":void 0},r.checkSupport=function(m){if(!s[m.toLowerCase()])throw new Error(m+" is not supported by this platform")},r.MAX_VALUE_16BITS=65535,r.MAX_VALUE_32BITS=-1,r.pretty=function(m){var _,f,I="";for(f=0;f<(m||"").length;f++)I+="\\x"+((_=m.charCodeAt(f))<16?"0":"")+_.toString(16).toUpperCase();return I},r.delay=function(m,_,f){setImmediate(function(){m.apply(f||null,_||[])})},r.inherits=function(m,_){function f(){}f.prototype=_.prototype,m.prototype=new f},r.extend=function(){var m,_,f={};for(m=0;m<arguments.length;m++)for(_ in arguments[m])Object.prototype.hasOwnProperty.call(arguments[m],_)&&f[_]===void 0&&(f[_]=arguments[m][_]);return f},r.prepareContent=function(m,_,f,I,C){return c.Promise.resolve(_).then(function(y){return s.blob&&(y instanceof Blob||["[object File]","[object Blob]"].indexOf(Object.prototype.toString.call(y))!==-1)?Blob.prototype.arrayBuffer!==void 0?y.arrayBuffer():typeof FileReader<"u"?new c.Promise(function(x,E){var B=new FileReader;B.onload=function(S){x(S.target.result)},B.onerror=function(S){E(S.target.error)},B.readAsArrayBuffer(y)}):c.Promise.reject(new Error(m+" is a Blob, but we have no way of reading it.")):y}).then(function(y){var x=r.getTypeOf(y);return x?(x==="arraybuffer"?y=r.transformTo("uint8array",y):x==="string"&&(C?y=a.decode(y):f&&I!==!0&&(y=(function(E){return u(E,s.uint8array?new Uint8Array(E.length):new Array(E.length))})(y))),y):c.Promise.reject(new Error("Can't read the data of '"+m+"'. Is it in a supported JavaScript type (String, Blob, ArrayBuffer, etc) ?"))})}},{"./base64":1,"./external":6,"./nodejsUtils":14,"./support":30,setimmediate:54}],33:[function(o,i,r){var s=o("./reader/readerFor"),a=o("./utils"),A=o("./signature"),c=o("./zipEntry"),l=o("./support");function u(g){this.files=[],this.loadOptions=g}u.prototype={checkSignature:function(g){if(!this.reader.readAndCheckSignature(g)){this.reader.index-=4;var h=this.reader.readString(4);throw new Error("Corrupted zip or bug: unexpected signature ("+a.pretty(h)+", expected "+a.pretty(g)+")")}},isSignature:function(g,h){var d=this.reader.index;this.reader.setIndex(g);var p=this.reader.readString(4)===h;return this.reader.setIndex(d),p},readBlockEndOfCentral:function(){this.diskNumber=this.reader.readInt(2),this.diskWithCentralDirStart=this.reader.readInt(2),this.centralDirRecordsOnThisDisk=this.reader.readInt(2),this.centralDirRecords=this.reader.readInt(2),this.centralDirSize=this.reader.readInt(4),this.centralDirOffset=this.reader.readInt(4),this.zipCommentLength=this.reader.readInt(2);var g=this.reader.readData(this.zipCommentLength),h=l.uint8array?"uint8array":"array",d=a.transformTo(h,g);this.zipComment=this.loadOptions.decodeFileName(d)},readBlockZip64EndOfCentral:function(){this.zip64EndOfCentralSize=this.reader.readInt(8),this.reader.skip(4),this.diskNumber=this.reader.readInt(4),this.diskWithCentralDirStart=this.reader.readInt(4),this.centralDirRecordsOnThisDisk=this.reader.readInt(8),this.centralDirRecords=this.reader.readInt(8),this.centralDirSize=this.reader.readInt(8),this.centralDirOffset=this.reader.readInt(8),this.zip64ExtensibleData={};for(var g,h,d,p=this.zip64EndOfCentralSize-44;0<p;)g=this.reader.readInt(2),h=this.reader.readInt(4),d=this.reader.readData(h),this.zip64ExtensibleData[g]={id:g,length:h,value:d}},readBlockZip64EndOfCentralLocator:function(){if(this.diskWithZip64CentralDirStart=this.reader.readInt(4),this.relativeOffsetEndOfZip64CentralDir=this.reader.readInt(8),this.disksCount=this.reader.readInt(4),1<this.disksCount)throw new Error("Multi-volumes zip are not supported")},readLocalFiles:function(){var g,h;for(g=0;g<this.files.length;g++)h=this.files[g],this.reader.setIndex(h.localHeaderOffset),this.checkSignature(A.LOCAL_FILE_HEADER),h.readLocalPart(this.reader),h.handleUTF8(),h.processAttributes()},readCentralDir:function(){var g;for(this.reader.setIndex(this.centralDirOffset);this.reader.readAndCheckSignature(A.CENTRAL_FILE_HEADER);)(g=new c({zip64:this.zip64},this.loadOptions)).readCentralPart(this.reader),this.files.push(g);if(this.centralDirRecords!==this.files.length&&this.centralDirRecords!==0&&this.files.length===0)throw new Error("Corrupted zip or bug: expected "+this.centralDirRecords+" records in central dir, got "+this.files.length)},readEndOfCentral:function(){var g=this.reader.lastIndexOfSignature(A.CENTRAL_DIRECTORY_END);if(g<0)throw this.isSignature(0,A.LOCAL_FILE_HEADER)?new Error("Corrupted zip: can't find end of central directory"):new Error("Can't find end of central directory : is this a zip file ? If it is, see https://stuk.github.io/jszip/documentation/howto/read_zip.html");this.reader.setIndex(g);var h=g;if(this.checkSignature(A.CENTRAL_DIRECTORY_END),this.readBlockEndOfCentral(),this.diskNumber===a.MAX_VALUE_16BITS||this.diskWithCentralDirStart===a.MAX_VALUE_16BITS||this.centralDirRecordsOnThisDisk===a.MAX_VALUE_16BITS||this.centralDirRecords===a.MAX_VALUE_16BITS||this.centralDirSize===a.MAX_VALUE_32BITS||this.centralDirOffset===a.MAX_VALUE_32BITS){if(this.zip64=!0,(g=this.reader.lastIndexOfSignature(A.ZIP64_CENTRAL_DIRECTORY_LOCATOR))<0)throw new Error("Corrupted zip: can't find the ZIP64 end of central directory locator");if(this.reader.setIndex(g),this.checkSignature(A.ZIP64_CENTRAL_DIRECTORY_LOCATOR),this.readBlockZip64EndOfCentralLocator(),!this.isSignature(this.relativeOffsetEndOfZip64CentralDir,A.ZIP64_CENTRAL_DIRECTORY_END)&&(this.relativeOffsetEndOfZip64CentralDir=this.reader.lastIndexOfSignature(A.ZIP64_CENTRAL_DIRECTORY_END),this.relativeOffsetEndOfZip64CentralDir<0))throw new Error("Corrupted zip: can't find the ZIP64 end of central directory");this.reader.setIndex(this.relativeOffsetEndOfZip64CentralDir),this.checkSignature(A.ZIP64_CENTRAL_DIRECTORY_END),this.readBlockZip64EndOfCentral()}var d=this.centralDirOffset+this.centralDirSize;this.zip64&&(d+=20,d+=12+this.zip64EndOfCentralSize);var p=h-d;if(0<p)this.isSignature(h,A.CENTRAL_FILE_HEADER)||(this.reader.zero=p);else if(p<0)throw new Error("Corrupted zip: missing "+Math.abs(p)+" bytes.")},prepareReader:function(g){this.reader=s(g)},load:function(g){this.prepareReader(g),this.readEndOfCentral(),this.readCentralDir(),this.readLocalFiles()}},i.exports=u},{"./reader/readerFor":22,"./signature":23,"./support":30,"./utils":32,"./zipEntry":34}],34:[function(o,i,r){var s=o("./reader/readerFor"),a=o("./utils"),A=o("./compressedObject"),c=o("./crc32"),l=o("./utf8"),u=o("./compressions"),g=o("./support");function h(d,p){this.options=d,this.loadOptions=p}h.prototype={isEncrypted:function(){return(1&this.bitFlag)==1},useUTF8:function(){return(2048&this.bitFlag)==2048},readLocalPart:function(d){var p,m;if(d.skip(22),this.fileNameLength=d.readInt(2),m=d.readInt(2),this.fileName=d.readData(this.fileNameLength),d.skip(m),this.compressedSize===-1||this.uncompressedSize===-1)throw new Error("Bug or corrupted zip : didn't get enough information from the central directory (compressedSize === -1 || uncompressedSize === -1)");if((p=(function(_){for(var f in u)if(Object.prototype.hasOwnProperty.call(u,f)&&u[f].magic===_)return u[f];return null})(this.compressionMethod))===null)throw new Error("Corrupted zip : compression "+a.pretty(this.compressionMethod)+" unknown (inner file : "+a.transformTo("string",this.fileName)+")");this.decompressed=new A(this.compressedSize,this.uncompressedSize,this.crc32,p,d.readData(this.compressedSize))},readCentralPart:function(d){this.versionMadeBy=d.readInt(2),d.skip(2),this.bitFlag=d.readInt(2),this.compressionMethod=d.readString(2),this.date=d.readDate(),this.crc32=d.readInt(4),this.compressedSize=d.readInt(4),this.uncompressedSize=d.readInt(4);var p=d.readInt(2);if(this.extraFieldsLength=d.readInt(2),this.fileCommentLength=d.readInt(2),this.diskNumberStart=d.readInt(2),this.internalFileAttributes=d.readInt(2),this.externalFileAttributes=d.readInt(4),this.localHeaderOffset=d.readInt(4),this.isEncrypted())throw new Error("Encrypted zip are not supported");d.skip(p),this.readExtraFields(d),this.parseZIP64ExtraField(d),this.fileComment=d.readData(this.fileCommentLength)},processAttributes:function(){this.unixPermissions=null,this.dosPermissions=null;var d=this.versionMadeBy>>8;this.dir=!!(16&this.externalFileAttributes),d==0&&(this.dosPermissions=63&this.externalFileAttributes),d==3&&(this.unixPermissions=this.externalFileAttributes>>16&65535),this.dir||this.fileNameStr.slice(-1)!=="/"||(this.dir=!0)},parseZIP64ExtraField:function(){if(this.extraFields[1]){var d=s(this.extraFields[1].value);this.uncompressedSize===a.MAX_VALUE_32BITS&&(this.uncompressedSize=d.readInt(8)),this.compressedSize===a.MAX_VALUE_32BITS&&(this.compressedSize=d.readInt(8)),this.localHeaderOffset===a.MAX_VALUE_32BITS&&(this.localHeaderOffset=d.readInt(8)),this.diskNumberStart===a.MAX_VALUE_32BITS&&(this.diskNumberStart=d.readInt(4))}},readExtraFields:function(d){var p,m,_,f=d.index+this.extraFieldsLength;for(this.extraFields||(this.extraFields={});d.index+4<f;)p=d.readInt(2),m=d.readInt(2),_=d.readData(m),this.extraFields[p]={id:p,length:m,value:_};d.setIndex(f)},handleUTF8:function(){var d=g.uint8array?"uint8array":"array";if(this.useUTF8())this.fileNameStr=l.utf8decode(this.fileName),this.fileCommentStr=l.utf8decode(this.fileComment);else{var p=this.findExtraFieldUnicodePath();if(p!==null)this.fileNameStr=p;else{var m=a.transformTo(d,this.fileName);this.fileNameStr=this.loadOptions.decodeFileName(m)}var _=this.findExtraFieldUnicodeComment();if(_!==null)this.fileCommentStr=_;else{var f=a.transformTo(d,this.fileComment);this.fileCommentStr=this.loadOptions.decodeFileName(f)}}},findExtraFieldUnicodePath:function(){var d=this.extraFields[28789];if(d){var p=s(d.value);return p.readInt(1)!==1||c(this.fileName)!==p.readInt(4)?null:l.utf8decode(p.readData(d.length-5))}return null},findExtraFieldUnicodeComment:function(){var d=this.extraFields[25461];if(d){var p=s(d.value);return p.readInt(1)!==1||c(this.fileComment)!==p.readInt(4)?null:l.utf8decode(p.readData(d.length-5))}return null}},i.exports=h},{"./compressedObject":2,"./compressions":3,"./crc32":4,"./reader/readerFor":22,"./support":30,"./utf8":31,"./utils":32}],35:[function(o,i,r){function s(p,m,_){this.name=p,this.dir=_.dir,this.date=_.date,this.comment=_.comment,this.unixPermissions=_.unixPermissions,this.dosPermissions=_.dosPermissions,this._data=m,this._dataBinary=_.binary,this.options={compression:_.compression,compressionOptions:_.compressionOptions}}var a=o("./stream/StreamHelper"),A=o("./stream/DataWorker"),c=o("./utf8"),l=o("./compressedObject"),u=o("./stream/GenericWorker");s.prototype={internalStream:function(p){var m=null,_="string";try{if(!p)throw new Error("No output type specified.");var f=(_=p.toLowerCase())==="string"||_==="text";_!=="binarystring"&&_!=="text"||(_="string"),m=this._decompressWorker();var I=!this._dataBinary;I&&!f&&(m=m.pipe(new c.Utf8EncodeWorker)),!I&&f&&(m=m.pipe(new c.Utf8DecodeWorker))}catch(C){(m=new u("error")).error(C)}return new a(m,_,"")},async:function(p,m){return this.internalStream(p).accumulate(m)},nodeStream:function(p,m){return this.internalStream(p||"nodebuffer").toNodejsStream(m)},_compressWorker:function(p,m){if(this._data instanceof l&&this._data.compression.magic===p.magic)return this._data.getCompressedWorker();var _=this._decompressWorker();return this._dataBinary||(_=_.pipe(new c.Utf8EncodeWorker)),l.createWorkerFrom(_,p,m)},_decompressWorker:function(){return this._data instanceof l?this._data.getContentWorker():this._data instanceof u?this._data:new A(this._data)}};for(var g=["asText","asBinary","asNodeBuffer","asUint8Array","asArrayBuffer"],h=function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},d=0;d<g.length;d++)s.prototype[g[d]]=h;i.exports=s},{"./compressedObject":2,"./stream/DataWorker":27,"./stream/GenericWorker":28,"./stream/StreamHelper":29,"./utf8":31}],36:[function(o,i,r){(function(s){var a,A,c=s.MutationObserver||s.WebKitMutationObserver;if(c){var l=0,u=new c(p),g=s.document.createTextNode("");u.observe(g,{characterData:!0}),a=function(){g.data=l=++l%2}}else if(s.setImmediate||s.MessageChannel===void 0)a="document"in s&&"onreadystatechange"in s.document.createElement("script")?function(){var m=s.document.createElement("script");m.onreadystatechange=function(){p(),m.onreadystatechange=null,m.parentNode.removeChild(m),m=null},s.document.documentElement.appendChild(m)}:function(){setTimeout(p,0)};else{var h=new s.MessageChannel;h.port1.onmessage=p,a=function(){h.port2.postMessage(0)}}var d=[];function p(){var m,_;A=!0;for(var f=d.length;f;){for(_=d,d=[],m=-1;++m<f;)_[m]();f=d.length}A=!1}i.exports=function(m){d.push(m)!==1||A||a()}}).call(this,typeof py<"u"?py:typeof self<"u"?self:typeof window<"u"?window:{})},{}],37:[function(o,i,r){var s=o("immediate");function a(){}var A={},c=["REJECTED"],l=["FULFILLED"],u=["PENDING"];function g(f){if(typeof f!="function")throw new TypeError("resolver must be a function");this.state=u,this.queue=[],this.outcome=void 0,f!==a&&m(this,f)}function h(f,I,C){this.promise=f,typeof I=="function"&&(this.onFulfilled=I,this.callFulfilled=this.otherCallFulfilled),typeof C=="function"&&(this.onRejected=C,this.callRejected=this.otherCallRejected)}function d(f,I,C){s(function(){var y;try{y=I(C)}catch(x){return A.reject(f,x)}y===f?A.reject(f,new TypeError("Cannot resolve promise with itself")):A.resolve(f,y)})}function p(f){var I=f&&f.then;if(f&&(typeof f=="object"||typeof f=="function")&&typeof I=="function")return function(){I.apply(f,arguments)}}function m(f,I){var C=!1;function y(B){C||(C=!0,A.reject(f,B))}function x(B){C||(C=!0,A.resolve(f,B))}var E=_(function(){I(x,y)});E.status==="error"&&y(E.value)}function _(f,I){var C={};try{C.value=f(I),C.status="success"}catch(y){C.status="error",C.value=y}return C}(i.exports=g).prototype.finally=function(f){if(typeof f!="function")return this;var I=this.constructor;return this.then(function(C){return I.resolve(f()).then(function(){return C})},function(C){return I.resolve(f()).then(function(){throw C})})},g.prototype.catch=function(f){return this.then(null,f)},g.prototype.then=function(f,I){if(typeof f!="function"&&this.state===l||typeof I!="function"&&this.state===c)return this;var C=new this.constructor(a);return this.state!==u?d(C,this.state===l?f:I,this.outcome):this.queue.push(new h(C,f,I)),C},h.prototype.callFulfilled=function(f){A.resolve(this.promise,f)},h.prototype.otherCallFulfilled=function(f){d(this.promise,this.onFulfilled,f)},h.prototype.callRejected=function(f){A.reject(this.promise,f)},h.prototype.otherCallRejected=function(f){d(this.promise,this.onRejected,f)},A.resolve=function(f,I){var C=_(p,I);if(C.status==="error")return A.reject(f,C.value);var y=C.value;if(y)m(f,y);else{f.state=l,f.outcome=I;for(var x=-1,E=f.queue.length;++x<E;)f.queue[x].callFulfilled(I)}return f},A.reject=function(f,I){f.state=c,f.outcome=I;for(var C=-1,y=f.queue.length;++C<y;)f.queue[C].callRejected(I);return f},g.resolve=function(f){return f instanceof this?f:A.resolve(new this(a),f)},g.reject=function(f){var I=new this(a);return A.reject(I,f)},g.all=function(f){var I=this;if(Object.prototype.toString.call(f)!=="[object Array]")return this.reject(new TypeError("must be an array"));var C=f.length,y=!1;if(!C)return this.resolve([]);for(var x=new Array(C),E=0,B=-1,S=new this(a);++B<C;)Q(f[B],B);return S;function Q(w,M){I.resolve(w).then(function(k){x[M]=k,++E!==C||y||(y=!0,A.resolve(S,x))},function(k){y||(y=!0,A.reject(S,k))})}},g.race=function(f){var I=this;if(Object.prototype.toString.call(f)!=="[object Array]")return this.reject(new TypeError("must be an array"));var C=f.length,y=!1;if(!C)return this.resolve([]);for(var x=-1,E=new this(a);++x<C;)B=f[x],I.resolve(B).then(function(S){y||(y=!0,A.resolve(E,S))},function(S){y||(y=!0,A.reject(E,S))});var B;return E}},{immediate:36}],38:[function(o,i,r){var s={};(0,o("./lib/utils/common").assign)(s,o("./lib/deflate"),o("./lib/inflate"),o("./lib/zlib/constants")),i.exports=s},{"./lib/deflate":39,"./lib/inflate":40,"./lib/utils/common":41,"./lib/zlib/constants":44}],39:[function(o,i,r){var s=o("./zlib/deflate"),a=o("./utils/common"),A=o("./utils/strings"),c=o("./zlib/messages"),l=o("./zlib/zstream"),u=Object.prototype.toString,g=0,h=-1,d=0,p=8;function m(f){if(!(this instanceof m))return new m(f);this.options=a.assign({level:h,method:p,chunkSize:16384,windowBits:15,memLevel:8,strategy:d,to:""},f||{});var I=this.options;I.raw&&0<I.windowBits?I.windowBits=-I.windowBits:I.gzip&&0<I.windowBits&&I.windowBits<16&&(I.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new l,this.strm.avail_out=0;var C=s.deflateInit2(this.strm,I.level,I.method,I.windowBits,I.memLevel,I.strategy);if(C!==g)throw new Error(c[C]);if(I.header&&s.deflateSetHeader(this.strm,I.header),I.dictionary){var y;if(y=typeof I.dictionary=="string"?A.string2buf(I.dictionary):u.call(I.dictionary)==="[object ArrayBuffer]"?new Uint8Array(I.dictionary):I.dictionary,(C=s.deflateSetDictionary(this.strm,y))!==g)throw new Error(c[C]);this._dict_set=!0}}function _(f,I){var C=new m(I);if(C.push(f,!0),C.err)throw C.msg||c[C.err];return C.result}m.prototype.push=function(f,I){var C,y,x=this.strm,E=this.options.chunkSize;if(this.ended)return!1;y=I===~~I?I:I===!0?4:0,typeof f=="string"?x.input=A.string2buf(f):u.call(f)==="[object ArrayBuffer]"?x.input=new Uint8Array(f):x.input=f,x.next_in=0,x.avail_in=x.input.length;do{if(x.avail_out===0&&(x.output=new a.Buf8(E),x.next_out=0,x.avail_out=E),(C=s.deflate(x,y))!==1&&C!==g)return this.onEnd(C),!(this.ended=!0);x.avail_out!==0&&(x.avail_in!==0||y!==4&&y!==2)||(this.options.to==="string"?this.onData(A.buf2binstring(a.shrinkBuf(x.output,x.next_out))):this.onData(a.shrinkBuf(x.output,x.next_out)))}while((0<x.avail_in||x.avail_out===0)&&C!==1);return y===4?(C=s.deflateEnd(this.strm),this.onEnd(C),this.ended=!0,C===g):y!==2||(this.onEnd(g),!(x.avail_out=0))},m.prototype.onData=function(f){this.chunks.push(f)},m.prototype.onEnd=function(f){f===g&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=a.flattenChunks(this.chunks)),this.chunks=[],this.err=f,this.msg=this.strm.msg},r.Deflate=m,r.deflate=_,r.deflateRaw=function(f,I){return(I=I||{}).raw=!0,_(f,I)},r.gzip=function(f,I){return(I=I||{}).gzip=!0,_(f,I)}},{"./utils/common":41,"./utils/strings":42,"./zlib/deflate":46,"./zlib/messages":51,"./zlib/zstream":53}],40:[function(o,i,r){var s=o("./zlib/inflate"),a=o("./utils/common"),A=o("./utils/strings"),c=o("./zlib/constants"),l=o("./zlib/messages"),u=o("./zlib/zstream"),g=o("./zlib/gzheader"),h=Object.prototype.toString;function d(m){if(!(this instanceof d))return new d(m);this.options=a.assign({chunkSize:16384,windowBits:0,to:""},m||{});var _=this.options;_.raw&&0<=_.windowBits&&_.windowBits<16&&(_.windowBits=-_.windowBits,_.windowBits===0&&(_.windowBits=-15)),!(0<=_.windowBits&&_.windowBits<16)||m&&m.windowBits||(_.windowBits+=32),15<_.windowBits&&_.windowBits<48&&(15&_.windowBits)==0&&(_.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new u,this.strm.avail_out=0;var f=s.inflateInit2(this.strm,_.windowBits);if(f!==c.Z_OK)throw new Error(l[f]);this.header=new g,s.inflateGetHeader(this.strm,this.header)}function p(m,_){var f=new d(_);if(f.push(m,!0),f.err)throw f.msg||l[f.err];return f.result}d.prototype.push=function(m,_){var f,I,C,y,x,E,B=this.strm,S=this.options.chunkSize,Q=this.options.dictionary,w=!1;if(this.ended)return!1;I=_===~~_?_:_===!0?c.Z_FINISH:c.Z_NO_FLUSH,typeof m=="string"?B.input=A.binstring2buf(m):h.call(m)==="[object ArrayBuffer]"?B.input=new Uint8Array(m):B.input=m,B.next_in=0,B.avail_in=B.input.length;do{if(B.avail_out===0&&(B.output=new a.Buf8(S),B.next_out=0,B.avail_out=S),(f=s.inflate(B,c.Z_NO_FLUSH))===c.Z_NEED_DICT&&Q&&(E=typeof Q=="string"?A.string2buf(Q):h.call(Q)==="[object ArrayBuffer]"?new Uint8Array(Q):Q,f=s.inflateSetDictionary(this.strm,E)),f===c.Z_BUF_ERROR&&w===!0&&(f=c.Z_OK,w=!1),f!==c.Z_STREAM_END&&f!==c.Z_OK)return this.onEnd(f),!(this.ended=!0);B.next_out&&(B.avail_out!==0&&f!==c.Z_STREAM_END&&(B.avail_in!==0||I!==c.Z_FINISH&&I!==c.Z_SYNC_FLUSH)||(this.options.to==="string"?(C=A.utf8border(B.output,B.next_out),y=B.next_out-C,x=A.buf2string(B.output,C),B.next_out=y,B.avail_out=S-y,y&&a.arraySet(B.output,B.output,C,y,0),this.onData(x)):this.onData(a.shrinkBuf(B.output,B.next_out)))),B.avail_in===0&&B.avail_out===0&&(w=!0)}while((0<B.avail_in||B.avail_out===0)&&f!==c.Z_STREAM_END);return f===c.Z_STREAM_END&&(I=c.Z_FINISH),I===c.Z_FINISH?(f=s.inflateEnd(this.strm),this.onEnd(f),this.ended=!0,f===c.Z_OK):I!==c.Z_SYNC_FLUSH||(this.onEnd(c.Z_OK),!(B.avail_out=0))},d.prototype.onData=function(m){this.chunks.push(m)},d.prototype.onEnd=function(m){m===c.Z_OK&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=a.flattenChunks(this.chunks)),this.chunks=[],this.err=m,this.msg=this.strm.msg},r.Inflate=d,r.inflate=p,r.inflateRaw=function(m,_){return(_=_||{}).raw=!0,p(m,_)},r.ungzip=p},{"./utils/common":41,"./utils/strings":42,"./zlib/constants":44,"./zlib/gzheader":47,"./zlib/inflate":49,"./zlib/messages":51,"./zlib/zstream":53}],41:[function(o,i,r){var s=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Int32Array<"u";r.assign=function(c){for(var l=Array.prototype.slice.call(arguments,1);l.length;){var u=l.shift();if(u){if(typeof u!="object")throw new TypeError(u+"must be non-object");for(var g in u)u.hasOwnProperty(g)&&(c[g]=u[g])}}return c},r.shrinkBuf=function(c,l){return c.length===l?c:c.subarray?c.subarray(0,l):(c.length=l,c)};var a={arraySet:function(c,l,u,g,h){if(l.subarray&&c.subarray)c.set(l.subarray(u,u+g),h);else for(var d=0;d<g;d++)c[h+d]=l[u+d]},flattenChunks:function(c){var l,u,g,h,d,p;for(l=g=0,u=c.length;l<u;l++)g+=c[l].length;for(p=new Uint8Array(g),l=h=0,u=c.length;l<u;l++)d=c[l],p.set(d,h),h+=d.length;return p}},A={arraySet:function(c,l,u,g,h){for(var d=0;d<g;d++)c[h+d]=l[u+d]},flattenChunks:function(c){return[].concat.apply([],c)}};r.setTyped=function(c){c?(r.Buf8=Uint8Array,r.Buf16=Uint16Array,r.Buf32=Int32Array,r.assign(r,a)):(r.Buf8=Array,r.Buf16=Array,r.Buf32=Array,r.assign(r,A))},r.setTyped(s)},{}],42:[function(o,i,r){var s=o("./common"),a=!0,A=!0;try{String.fromCharCode.apply(null,[0])}catch{a=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch{A=!1}for(var c=new s.Buf8(256),l=0;l<256;l++)c[l]=252<=l?6:248<=l?5:240<=l?4:224<=l?3:192<=l?2:1;function u(g,h){if(h<65537&&(g.subarray&&A||!g.subarray&&a))return String.fromCharCode.apply(null,s.shrinkBuf(g,h));for(var d="",p=0;p<h;p++)d+=String.fromCharCode(g[p]);return d}c[254]=c[254]=1,r.string2buf=function(g){var h,d,p,m,_,f=g.length,I=0;for(m=0;m<f;m++)(64512&(d=g.charCodeAt(m)))==55296&&m+1<f&&(64512&(p=g.charCodeAt(m+1)))==56320&&(d=65536+(d-55296<<10)+(p-56320),m++),I+=d<128?1:d<2048?2:d<65536?3:4;for(h=new s.Buf8(I),m=_=0;_<I;m++)(64512&(d=g.charCodeAt(m)))==55296&&m+1<f&&(64512&(p=g.charCodeAt(m+1)))==56320&&(d=65536+(d-55296<<10)+(p-56320),m++),d<128?h[_++]=d:(d<2048?h[_++]=192|d>>>6:(d<65536?h[_++]=224|d>>>12:(h[_++]=240|d>>>18,h[_++]=128|d>>>12&63),h[_++]=128|d>>>6&63),h[_++]=128|63&d);return h},r.buf2binstring=function(g){return u(g,g.length)},r.binstring2buf=function(g){for(var h=new s.Buf8(g.length),d=0,p=h.length;d<p;d++)h[d]=g.charCodeAt(d);return h},r.buf2string=function(g,h){var d,p,m,_,f=h||g.length,I=new Array(2*f);for(d=p=0;d<f;)if((m=g[d++])<128)I[p++]=m;else if(4<(_=c[m]))I[p++]=65533,d+=_-1;else{for(m&=_===2?31:_===3?15:7;1<_&&d<f;)m=m<<6|63&g[d++],_--;1<_?I[p++]=65533:m<65536?I[p++]=m:(m-=65536,I[p++]=55296|m>>10&1023,I[p++]=56320|1023&m)}return u(I,p)},r.utf8border=function(g,h){var d;for((h=h||g.length)>g.length&&(h=g.length),d=h-1;0<=d&&(192&g[d])==128;)d--;return d<0||d===0?h:d+c[g[d]]>h?d:h}},{"./common":41}],43:[function(o,i,r){i.exports=function(s,a,A,c){for(var l=65535&s|0,u=s>>>16&65535|0,g=0;A!==0;){for(A-=g=2e3<A?2e3:A;u=u+(l=l+a[c++]|0)|0,--g;);l%=65521,u%=65521}return l|u<<16|0}},{}],44:[function(o,i,r){i.exports={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8}},{}],45:[function(o,i,r){var s=(function(){for(var a,A=[],c=0;c<256;c++){a=c;for(var l=0;l<8;l++)a=1&a?3988292384^a>>>1:a>>>1;A[c]=a}return A})();i.exports=function(a,A,c,l){var u=s,g=l+c;a^=-1;for(var h=l;h<g;h++)a=a>>>8^u[255&(a^A[h])];return-1^a}},{}],46:[function(o,i,r){var s,a=o("../utils/common"),A=o("./trees"),c=o("./adler32"),l=o("./crc32"),u=o("./messages"),g=0,h=4,d=0,p=-2,m=-1,_=4,f=2,I=8,C=9,y=286,x=30,E=19,B=2*y+1,S=15,Q=3,w=258,M=w+Q+1,k=42,R=113,F=1,O=2,U=3,Y=4;function W(pe,ve){return pe.msg=u[ve],ve}function te(pe){return(pe<<1)-(4<pe?9:0)}function j(pe){for(var ve=pe.length;0<=--ve;)pe[ve]=0}function J(pe){var ve=pe.state,Me=ve.pending;Me>pe.avail_out&&(Me=pe.avail_out),Me!==0&&(a.arraySet(pe.output,ve.pending_buf,ve.pending_out,Me,pe.next_out),pe.next_out+=Me,ve.pending_out+=Me,pe.total_out+=Me,pe.avail_out-=Me,ve.pending-=Me,ve.pending===0&&(ve.pending_out=0))}function ie(pe,ve){A._tr_flush_block(pe,0<=pe.block_start?pe.block_start:-1,pe.strstart-pe.block_start,ve),pe.block_start=pe.strstart,J(pe.strm)}function oe(pe,ve){pe.pending_buf[pe.pending++]=ve}function ne(pe,ve){pe.pending_buf[pe.pending++]=ve>>>8&255,pe.pending_buf[pe.pending++]=255&ve}function ge(pe,ve){var Me,Pe,He=pe.max_chain_length,Re=pe.strstart,Ee=pe.prev_length,Te=pe.nice_match,Ce=pe.strstart>pe.w_size-M?pe.strstart-(pe.w_size-M):0,Fe=pe.window,Ye=pe.w_mask,tt=pe.prev,At=pe.strstart+w,at=Fe[Re+Ee-1],ot=Fe[Re+Ee];pe.prev_length>=pe.good_match&&(He>>=2),Te>pe.lookahead&&(Te=pe.lookahead);do if(Fe[(Me=ve)+Ee]===ot&&Fe[Me+Ee-1]===at&&Fe[Me]===Fe[Re]&&Fe[++Me]===Fe[Re+1]){Re+=2,Me++;do;while(Fe[++Re]===Fe[++Me]&&Fe[++Re]===Fe[++Me]&&Fe[++Re]===Fe[++Me]&&Fe[++Re]===Fe[++Me]&&Fe[++Re]===Fe[++Me]&&Fe[++Re]===Fe[++Me]&&Fe[++Re]===Fe[++Me]&&Fe[++Re]===Fe[++Me]&&Re<At);if(Pe=w-(At-Re),Re=At-w,Ee<Pe){if(pe.match_start=ve,Te<=(Ee=Pe))break;at=Fe[Re+Ee-1],ot=Fe[Re+Ee]}}while((ve=tt[ve&Ye])>Ce&&--He!=0);return Ee<=pe.lookahead?Ee:pe.lookahead}function ue(pe){var ve,Me,Pe,He,Re,Ee,Te,Ce,Fe,Ye,tt=pe.w_size;do{if(He=pe.window_size-pe.lookahead-pe.strstart,pe.strstart>=tt+(tt-M)){for(a.arraySet(pe.window,pe.window,tt,tt,0),pe.match_start-=tt,pe.strstart-=tt,pe.block_start-=tt,ve=Me=pe.hash_size;Pe=pe.head[--ve],pe.head[ve]=tt<=Pe?Pe-tt:0,--Me;);for(ve=Me=tt;Pe=pe.prev[--ve],pe.prev[ve]=tt<=Pe?Pe-tt:0,--Me;);He+=tt}if(pe.strm.avail_in===0)break;if(Ee=pe.strm,Te=pe.window,Ce=pe.strstart+pe.lookahead,Fe=He,Ye=void 0,Ye=Ee.avail_in,Fe<Ye&&(Ye=Fe),Me=Ye===0?0:(Ee.avail_in-=Ye,a.arraySet(Te,Ee.input,Ee.next_in,Ye,Ce),Ee.state.wrap===1?Ee.adler=c(Ee.adler,Te,Ye,Ce):Ee.state.wrap===2&&(Ee.adler=l(Ee.adler,Te,Ye,Ce)),Ee.next_in+=Ye,Ee.total_in+=Ye,Ye),pe.lookahead+=Me,pe.lookahead+pe.insert>=Q)for(Re=pe.strstart-pe.insert,pe.ins_h=pe.window[Re],pe.ins_h=(pe.ins_h<<pe.hash_shift^pe.window[Re+1])&pe.hash_mask;pe.insert&&(pe.ins_h=(pe.ins_h<<pe.hash_shift^pe.window[Re+Q-1])&pe.hash_mask,pe.prev[Re&pe.w_mask]=pe.head[pe.ins_h],pe.head[pe.ins_h]=Re,Re++,pe.insert--,!(pe.lookahead+pe.insert<Q)););}while(pe.lookahead<M&&pe.strm.avail_in!==0)}function _e(pe,ve){for(var Me,Pe;;){if(pe.lookahead<M){if(ue(pe),pe.lookahead<M&&ve===g)return F;if(pe.lookahead===0)break}if(Me=0,pe.lookahead>=Q&&(pe.ins_h=(pe.ins_h<<pe.hash_shift^pe.window[pe.strstart+Q-1])&pe.hash_mask,Me=pe.prev[pe.strstart&pe.w_mask]=pe.head[pe.ins_h],pe.head[pe.ins_h]=pe.strstart),Me!==0&&pe.strstart-Me<=pe.w_size-M&&(pe.match_length=ge(pe,Me)),pe.match_length>=Q)if(Pe=A._tr_tally(pe,pe.strstart-pe.match_start,pe.match_length-Q),pe.lookahead-=pe.match_length,pe.match_length<=pe.max_lazy_match&&pe.lookahead>=Q){for(pe.match_length--;pe.strstart++,pe.ins_h=(pe.ins_h<<pe.hash_shift^pe.window[pe.strstart+Q-1])&pe.hash_mask,Me=pe.prev[pe.strstart&pe.w_mask]=pe.head[pe.ins_h],pe.head[pe.ins_h]=pe.strstart,--pe.match_length!=0;);pe.strstart++}else pe.strstart+=pe.match_length,pe.match_length=0,pe.ins_h=pe.window[pe.strstart],pe.ins_h=(pe.ins_h<<pe.hash_shift^pe.window[pe.strstart+1])&pe.hash_mask;else Pe=A._tr_tally(pe,0,pe.window[pe.strstart]),pe.lookahead--,pe.strstart++;if(Pe&&(ie(pe,!1),pe.strm.avail_out===0))return F}return pe.insert=pe.strstart<Q-1?pe.strstart:Q-1,ve===h?(ie(pe,!0),pe.strm.avail_out===0?U:Y):pe.last_lit&&(ie(pe,!1),pe.strm.avail_out===0)?F:O}function le(pe,ve){for(var Me,Pe,He;;){if(pe.lookahead<M){if(ue(pe),pe.lookahead<M&&ve===g)return F;if(pe.lookahead===0)break}if(Me=0,pe.lookahead>=Q&&(pe.ins_h=(pe.ins_h<<pe.hash_shift^pe.window[pe.strstart+Q-1])&pe.hash_mask,Me=pe.prev[pe.strstart&pe.w_mask]=pe.head[pe.ins_h],pe.head[pe.ins_h]=pe.strstart),pe.prev_length=pe.match_length,pe.prev_match=pe.match_start,pe.match_length=Q-1,Me!==0&&pe.prev_length<pe.max_lazy_match&&pe.strstart-Me<=pe.w_size-M&&(pe.match_length=ge(pe,Me),pe.match_length<=5&&(pe.strategy===1||pe.match_length===Q&&4096<pe.strstart-pe.match_start)&&(pe.match_length=Q-1)),pe.prev_length>=Q&&pe.match_length<=pe.prev_length){for(He=pe.strstart+pe.lookahead-Q,Pe=A._tr_tally(pe,pe.strstart-1-pe.prev_match,pe.prev_length-Q),pe.lookahead-=pe.prev_length-1,pe.prev_length-=2;++pe.strstart<=He&&(pe.ins_h=(pe.ins_h<<pe.hash_shift^pe.window[pe.strstart+Q-1])&pe.hash_mask,Me=pe.prev[pe.strstart&pe.w_mask]=pe.head[pe.ins_h],pe.head[pe.ins_h]=pe.strstart),--pe.prev_length!=0;);if(pe.match_available=0,pe.match_length=Q-1,pe.strstart++,Pe&&(ie(pe,!1),pe.strm.avail_out===0))return F}else if(pe.match_available){if((Pe=A._tr_tally(pe,0,pe.window[pe.strstart-1]))&&ie(pe,!1),pe.strstart++,pe.lookahead--,pe.strm.avail_out===0)return F}else pe.match_available=1,pe.strstart++,pe.lookahead--}return pe.match_available&&(Pe=A._tr_tally(pe,0,pe.window[pe.strstart-1]),pe.match_available=0),pe.insert=pe.strstart<Q-1?pe.strstart:Q-1,ve===h?(ie(pe,!0),pe.strm.avail_out===0?U:Y):pe.last_lit&&(ie(pe,!1),pe.strm.avail_out===0)?F:O}function fe(pe,ve,Me,Pe,He){this.good_length=pe,this.max_lazy=ve,this.nice_length=Me,this.max_chain=Pe,this.func=He}function he(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=I,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new a.Buf16(2*B),this.dyn_dtree=new a.Buf16(2*(2*x+1)),this.bl_tree=new a.Buf16(2*(2*E+1)),j(this.dyn_ltree),j(this.dyn_dtree),j(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new a.Buf16(S+1),this.heap=new a.Buf16(2*y+1),j(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new a.Buf16(2*y+1),j(this.depth),this.l_buf=0,this.lit_bufsize=0,this.last_lit=0,this.d_buf=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}function ye(pe){var ve;return pe&&pe.state?(pe.total_in=pe.total_out=0,pe.data_type=f,(ve=pe.state).pending=0,ve.pending_out=0,ve.wrap<0&&(ve.wrap=-ve.wrap),ve.status=ve.wrap?k:R,pe.adler=ve.wrap===2?0:1,ve.last_flush=g,A._tr_init(ve),d):W(pe,p)}function Qe(pe){var ve=ye(pe);return ve===d&&(function(Me){Me.window_size=2*Me.w_size,j(Me.head),Me.max_lazy_match=s[Me.level].max_lazy,Me.good_match=s[Me.level].good_length,Me.nice_match=s[Me.level].nice_length,Me.max_chain_length=s[Me.level].max_chain,Me.strstart=0,Me.block_start=0,Me.lookahead=0,Me.insert=0,Me.match_length=Me.prev_length=Q-1,Me.match_available=0,Me.ins_h=0})(pe.state),ve}function we(pe,ve,Me,Pe,He,Re){if(!pe)return p;var Ee=1;if(ve===m&&(ve=6),Pe<0?(Ee=0,Pe=-Pe):15<Pe&&(Ee=2,Pe-=16),He<1||C<He||Me!==I||Pe<8||15<Pe||ve<0||9<ve||Re<0||_<Re)return W(pe,p);Pe===8&&(Pe=9);var Te=new he;return(pe.state=Te).strm=pe,Te.wrap=Ee,Te.gzhead=null,Te.w_bits=Pe,Te.w_size=1<<Te.w_bits,Te.w_mask=Te.w_size-1,Te.hash_bits=He+7,Te.hash_size=1<<Te.hash_bits,Te.hash_mask=Te.hash_size-1,Te.hash_shift=~~((Te.hash_bits+Q-1)/Q),Te.window=new a.Buf8(2*Te.w_size),Te.head=new a.Buf16(Te.hash_size),Te.prev=new a.Buf16(Te.w_size),Te.lit_bufsize=1<<He+6,Te.pending_buf_size=4*Te.lit_bufsize,Te.pending_buf=new a.Buf8(Te.pending_buf_size),Te.d_buf=1*Te.lit_bufsize,Te.l_buf=3*Te.lit_bufsize,Te.level=ve,Te.strategy=Re,Te.method=Me,Qe(pe)}s=[new fe(0,0,0,0,function(pe,ve){var Me=65535;for(Me>pe.pending_buf_size-5&&(Me=pe.pending_buf_size-5);;){if(pe.lookahead<=1){if(ue(pe),pe.lookahead===0&&ve===g)return F;if(pe.lookahead===0)break}pe.strstart+=pe.lookahead,pe.lookahead=0;var Pe=pe.block_start+Me;if((pe.strstart===0||pe.strstart>=Pe)&&(pe.lookahead=pe.strstart-Pe,pe.strstart=Pe,ie(pe,!1),pe.strm.avail_out===0)||pe.strstart-pe.block_start>=pe.w_size-M&&(ie(pe,!1),pe.strm.avail_out===0))return F}return pe.insert=0,ve===h?(ie(pe,!0),pe.strm.avail_out===0?U:Y):(pe.strstart>pe.block_start&&(ie(pe,!1),pe.strm.avail_out),F)}),new fe(4,4,8,4,_e),new fe(4,5,16,8,_e),new fe(4,6,32,32,_e),new fe(4,4,16,16,le),new fe(8,16,32,32,le),new fe(8,16,128,128,le),new fe(8,32,128,256,le),new fe(32,128,258,1024,le),new fe(32,258,258,4096,le)],r.deflateInit=function(pe,ve){return we(pe,ve,I,15,8,0)},r.deflateInit2=we,r.deflateReset=Qe,r.deflateResetKeep=ye,r.deflateSetHeader=function(pe,ve){return pe&&pe.state?pe.state.wrap!==2?p:(pe.state.gzhead=ve,d):p},r.deflate=function(pe,ve){var Me,Pe,He,Re;if(!pe||!pe.state||5<ve||ve<0)return pe?W(pe,p):p;if(Pe=pe.state,!pe.output||!pe.input&&pe.avail_in!==0||Pe.status===666&&ve!==h)return W(pe,pe.avail_out===0?-5:p);if(Pe.strm=pe,Me=Pe.last_flush,Pe.last_flush=ve,Pe.status===k)if(Pe.wrap===2)pe.adler=0,oe(Pe,31),oe(Pe,139),oe(Pe,8),Pe.gzhead?(oe(Pe,(Pe.gzhead.text?1:0)+(Pe.gzhead.hcrc?2:0)+(Pe.gzhead.extra?4:0)+(Pe.gzhead.name?8:0)+(Pe.gzhead.comment?16:0)),oe(Pe,255&Pe.gzhead.time),oe(Pe,Pe.gzhead.time>>8&255),oe(Pe,Pe.gzhead.time>>16&255),oe(Pe,Pe.gzhead.time>>24&255),oe(Pe,Pe.level===9?2:2<=Pe.strategy||Pe.level<2?4:0),oe(Pe,255&Pe.gzhead.os),Pe.gzhead.extra&&Pe.gzhead.extra.length&&(oe(Pe,255&Pe.gzhead.extra.length),oe(Pe,Pe.gzhead.extra.length>>8&255)),Pe.gzhead.hcrc&&(pe.adler=l(pe.adler,Pe.pending_buf,Pe.pending,0)),Pe.gzindex=0,Pe.status=69):(oe(Pe,0),oe(Pe,0),oe(Pe,0),oe(Pe,0),oe(Pe,0),oe(Pe,Pe.level===9?2:2<=Pe.strategy||Pe.level<2?4:0),oe(Pe,3),Pe.status=R);else{var Ee=I+(Pe.w_bits-8<<4)<<8;Ee|=(2<=Pe.strategy||Pe.level<2?0:Pe.level<6?1:Pe.level===6?2:3)<<6,Pe.strstart!==0&&(Ee|=32),Ee+=31-Ee%31,Pe.status=R,ne(Pe,Ee),Pe.strstart!==0&&(ne(Pe,pe.adler>>>16),ne(Pe,65535&pe.adler)),pe.adler=1}if(Pe.status===69)if(Pe.gzhead.extra){for(He=Pe.pending;Pe.gzindex<(65535&Pe.gzhead.extra.length)&&(Pe.pending!==Pe.pending_buf_size||(Pe.gzhead.hcrc&&Pe.pending>He&&(pe.adler=l(pe.adler,Pe.pending_buf,Pe.pending-He,He)),J(pe),He=Pe.pending,Pe.pending!==Pe.pending_buf_size));)oe(Pe,255&Pe.gzhead.extra[Pe.gzindex]),Pe.gzindex++;Pe.gzhead.hcrc&&Pe.pending>He&&(pe.adler=l(pe.adler,Pe.pending_buf,Pe.pending-He,He)),Pe.gzindex===Pe.gzhead.extra.length&&(Pe.gzindex=0,Pe.status=73)}else Pe.status=73;if(Pe.status===73)if(Pe.gzhead.name){He=Pe.pending;do{if(Pe.pending===Pe.pending_buf_size&&(Pe.gzhead.hcrc&&Pe.pending>He&&(pe.adler=l(pe.adler,Pe.pending_buf,Pe.pending-He,He)),J(pe),He=Pe.pending,Pe.pending===Pe.pending_buf_size)){Re=1;break}Re=Pe.gzindex<Pe.gzhead.name.length?255&Pe.gzhead.name.charCodeAt(Pe.gzindex++):0,oe(Pe,Re)}while(Re!==0);Pe.gzhead.hcrc&&Pe.pending>He&&(pe.adler=l(pe.adler,Pe.pending_buf,Pe.pending-He,He)),Re===0&&(Pe.gzindex=0,Pe.status=91)}else Pe.status=91;if(Pe.status===91)if(Pe.gzhead.comment){He=Pe.pending;do{if(Pe.pending===Pe.pending_buf_size&&(Pe.gzhead.hcrc&&Pe.pending>He&&(pe.adler=l(pe.adler,Pe.pending_buf,Pe.pending-He,He)),J(pe),He=Pe.pending,Pe.pending===Pe.pending_buf_size)){Re=1;break}Re=Pe.gzindex<Pe.gzhead.comment.length?255&Pe.gzhead.comment.charCodeAt(Pe.gzindex++):0,oe(Pe,Re)}while(Re!==0);Pe.gzhead.hcrc&&Pe.pending>He&&(pe.adler=l(pe.adler,Pe.pending_buf,Pe.pending-He,He)),Re===0&&(Pe.status=103)}else Pe.status=103;if(Pe.status===103&&(Pe.gzhead.hcrc?(Pe.pending+2>Pe.pending_buf_size&&J(pe),Pe.pending+2<=Pe.pending_buf_size&&(oe(Pe,255&pe.adler),oe(Pe,pe.adler>>8&255),pe.adler=0,Pe.status=R)):Pe.status=R),Pe.pending!==0){if(J(pe),pe.avail_out===0)return Pe.last_flush=-1,d}else if(pe.avail_in===0&&te(ve)<=te(Me)&&ve!==h)return W(pe,-5);if(Pe.status===666&&pe.avail_in!==0)return W(pe,-5);if(pe.avail_in!==0||Pe.lookahead!==0||ve!==g&&Pe.status!==666){var Te=Pe.strategy===2?(function(Ce,Fe){for(var Ye;;){if(Ce.lookahead===0&&(ue(Ce),Ce.lookahead===0)){if(Fe===g)return F;break}if(Ce.match_length=0,Ye=A._tr_tally(Ce,0,Ce.window[Ce.strstart]),Ce.lookahead--,Ce.strstart++,Ye&&(ie(Ce,!1),Ce.strm.avail_out===0))return F}return Ce.insert=0,Fe===h?(ie(Ce,!0),Ce.strm.avail_out===0?U:Y):Ce.last_lit&&(ie(Ce,!1),Ce.strm.avail_out===0)?F:O})(Pe,ve):Pe.strategy===3?(function(Ce,Fe){for(var Ye,tt,At,at,ot=Ce.window;;){if(Ce.lookahead<=w){if(ue(Ce),Ce.lookahead<=w&&Fe===g)return F;if(Ce.lookahead===0)break}if(Ce.match_length=0,Ce.lookahead>=Q&&0<Ce.strstart&&(tt=ot[At=Ce.strstart-1])===ot[++At]&&tt===ot[++At]&&tt===ot[++At]){at=Ce.strstart+w;do;while(tt===ot[++At]&&tt===ot[++At]&&tt===ot[++At]&&tt===ot[++At]&&tt===ot[++At]&&tt===ot[++At]&&tt===ot[++At]&&tt===ot[++At]&&At<at);Ce.match_length=w-(at-At),Ce.match_length>Ce.lookahead&&(Ce.match_length=Ce.lookahead)}if(Ce.match_length>=Q?(Ye=A._tr_tally(Ce,1,Ce.match_length-Q),Ce.lookahead-=Ce.match_length,Ce.strstart+=Ce.match_length,Ce.match_length=0):(Ye=A._tr_tally(Ce,0,Ce.window[Ce.strstart]),Ce.lookahead--,Ce.strstart++),Ye&&(ie(Ce,!1),Ce.strm.avail_out===0))return F}return Ce.insert=0,Fe===h?(ie(Ce,!0),Ce.strm.avail_out===0?U:Y):Ce.last_lit&&(ie(Ce,!1),Ce.strm.avail_out===0)?F:O})(Pe,ve):s[Pe.level].func(Pe,ve);if(Te!==U&&Te!==Y||(Pe.status=666),Te===F||Te===U)return pe.avail_out===0&&(Pe.last_flush=-1),d;if(Te===O&&(ve===1?A._tr_align(Pe):ve!==5&&(A._tr_stored_block(Pe,0,0,!1),ve===3&&(j(Pe.head),Pe.lookahead===0&&(Pe.strstart=0,Pe.block_start=0,Pe.insert=0))),J(pe),pe.avail_out===0))return Pe.last_flush=-1,d}return ve!==h?d:Pe.wrap<=0?1:(Pe.wrap===2?(oe(Pe,255&pe.adler),oe(Pe,pe.adler>>8&255),oe(Pe,pe.adler>>16&255),oe(Pe,pe.adler>>24&255),oe(Pe,255&pe.total_in),oe(Pe,pe.total_in>>8&255),oe(Pe,pe.total_in>>16&255),oe(Pe,pe.total_in>>24&255)):(ne(Pe,pe.adler>>>16),ne(Pe,65535&pe.adler)),J(pe),0<Pe.wrap&&(Pe.wrap=-Pe.wrap),Pe.pending!==0?d:1)},r.deflateEnd=function(pe){var ve;return pe&&pe.state?(ve=pe.state.status)!==k&&ve!==69&&ve!==73&&ve!==91&&ve!==103&&ve!==R&&ve!==666?W(pe,p):(pe.state=null,ve===R?W(pe,-3):d):p},r.deflateSetDictionary=function(pe,ve){var Me,Pe,He,Re,Ee,Te,Ce,Fe,Ye=ve.length;if(!pe||!pe.state||(Re=(Me=pe.state).wrap)===2||Re===1&&Me.status!==k||Me.lookahead)return p;for(Re===1&&(pe.adler=c(pe.adler,ve,Ye,0)),Me.wrap=0,Ye>=Me.w_size&&(Re===0&&(j(Me.head),Me.strstart=0,Me.block_start=0,Me.insert=0),Fe=new a.Buf8(Me.w_size),a.arraySet(Fe,ve,Ye-Me.w_size,Me.w_size,0),ve=Fe,Ye=Me.w_size),Ee=pe.avail_in,Te=pe.next_in,Ce=pe.input,pe.avail_in=Ye,pe.next_in=0,pe.input=ve,ue(Me);Me.lookahead>=Q;){for(Pe=Me.strstart,He=Me.lookahead-(Q-1);Me.ins_h=(Me.ins_h<<Me.hash_shift^Me.window[Pe+Q-1])&Me.hash_mask,Me.prev[Pe&Me.w_mask]=Me.head[Me.ins_h],Me.head[Me.ins_h]=Pe,Pe++,--He;);Me.strstart=Pe,Me.lookahead=Q-1,ue(Me)}return Me.strstart+=Me.lookahead,Me.block_start=Me.strstart,Me.insert=Me.lookahead,Me.lookahead=0,Me.match_length=Me.prev_length=Q-1,Me.match_available=0,pe.next_in=Te,pe.input=Ce,pe.avail_in=Ee,Me.wrap=Re,d},r.deflateInfo="pako deflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./messages":51,"./trees":52}],47:[function(o,i,r){i.exports=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}},{}],48:[function(o,i,r){i.exports=function(s,a){var A,c,l,u,g,h,d,p,m,_,f,I,C,y,x,E,B,S,Q,w,M,k,R,F,O;A=s.state,c=s.next_in,F=s.input,l=c+(s.avail_in-5),u=s.next_out,O=s.output,g=u-(a-s.avail_out),h=u+(s.avail_out-257),d=A.dmax,p=A.wsize,m=A.whave,_=A.wnext,f=A.window,I=A.hold,C=A.bits,y=A.lencode,x=A.distcode,E=(1<<A.lenbits)-1,B=(1<<A.distbits)-1;e:do{C<15&&(I+=F[c++]<<C,C+=8,I+=F[c++]<<C,C+=8),S=y[I&E];t:for(;;){if(I>>>=Q=S>>>24,C-=Q,(Q=S>>>16&255)===0)O[u++]=65535&S;else{if(!(16&Q)){if((64&Q)==0){S=y[(65535&S)+(I&(1<<Q)-1)];continue t}if(32&Q){A.mode=12;break e}s.msg="invalid literal/length code",A.mode=30;break e}w=65535&S,(Q&=15)&&(C<Q&&(I+=F[c++]<<C,C+=8),w+=I&(1<<Q)-1,I>>>=Q,C-=Q),C<15&&(I+=F[c++]<<C,C+=8,I+=F[c++]<<C,C+=8),S=x[I&B];n:for(;;){if(I>>>=Q=S>>>24,C-=Q,!(16&(Q=S>>>16&255))){if((64&Q)==0){S=x[(65535&S)+(I&(1<<Q)-1)];continue n}s.msg="invalid distance code",A.mode=30;break e}if(M=65535&S,C<(Q&=15)&&(I+=F[c++]<<C,(C+=8)<Q&&(I+=F[c++]<<C,C+=8)),d<(M+=I&(1<<Q)-1)){s.msg="invalid distance too far back",A.mode=30;break e}if(I>>>=Q,C-=Q,(Q=u-g)<M){if(m<(Q=M-Q)&&A.sane){s.msg="invalid distance too far back",A.mode=30;break e}if(R=f,(k=0)===_){if(k+=p-Q,Q<w){for(w-=Q;O[u++]=f[k++],--Q;);k=u-M,R=O}}else if(_<Q){if(k+=p+_-Q,(Q-=_)<w){for(w-=Q;O[u++]=f[k++],--Q;);if(k=0,_<w){for(w-=Q=_;O[u++]=f[k++],--Q;);k=u-M,R=O}}}else if(k+=_-Q,Q<w){for(w-=Q;O[u++]=f[k++],--Q;);k=u-M,R=O}for(;2<w;)O[u++]=R[k++],O[u++]=R[k++],O[u++]=R[k++],w-=3;w&&(O[u++]=R[k++],1<w&&(O[u++]=R[k++]))}else{for(k=u-M;O[u++]=O[k++],O[u++]=O[k++],O[u++]=O[k++],2<(w-=3););w&&(O[u++]=O[k++],1<w&&(O[u++]=O[k++]))}break}}break}}while(c<l&&u<h);c-=w=C>>3,I&=(1<<(C-=w<<3))-1,s.next_in=c,s.next_out=u,s.avail_in=c<l?l-c+5:5-(c-l),s.avail_out=u<h?h-u+257:257-(u-h),A.hold=I,A.bits=C}},{}],49:[function(o,i,r){var s=o("../utils/common"),a=o("./adler32"),A=o("./crc32"),c=o("./inffast"),l=o("./inftrees"),u=1,g=2,h=0,d=-2,p=1,m=852,_=592;function f(k){return(k>>>24&255)+(k>>>8&65280)+((65280&k)<<8)+((255&k)<<24)}function I(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new s.Buf16(320),this.work=new s.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function C(k){var R;return k&&k.state?(R=k.state,k.total_in=k.total_out=R.total=0,k.msg="",R.wrap&&(k.adler=1&R.wrap),R.mode=p,R.last=0,R.havedict=0,R.dmax=32768,R.head=null,R.hold=0,R.bits=0,R.lencode=R.lendyn=new s.Buf32(m),R.distcode=R.distdyn=new s.Buf32(_),R.sane=1,R.back=-1,h):d}function y(k){var R;return k&&k.state?((R=k.state).wsize=0,R.whave=0,R.wnext=0,C(k)):d}function x(k,R){var F,O;return k&&k.state?(O=k.state,R<0?(F=0,R=-R):(F=1+(R>>4),R<48&&(R&=15)),R&&(R<8||15<R)?d:(O.window!==null&&O.wbits!==R&&(O.window=null),O.wrap=F,O.wbits=R,y(k))):d}function E(k,R){var F,O;return k?(O=new I,(k.state=O).window=null,(F=x(k,R))!==h&&(k.state=null),F):d}var B,S,Q=!0;function w(k){if(Q){var R;for(B=new s.Buf32(512),S=new s.Buf32(32),R=0;R<144;)k.lens[R++]=8;for(;R<256;)k.lens[R++]=9;for(;R<280;)k.lens[R++]=7;for(;R<288;)k.lens[R++]=8;for(l(u,k.lens,0,288,B,0,k.work,{bits:9}),R=0;R<32;)k.lens[R++]=5;l(g,k.lens,0,32,S,0,k.work,{bits:5}),Q=!1}k.lencode=B,k.lenbits=9,k.distcode=S,k.distbits=5}function M(k,R,F,O){var U,Y=k.state;return Y.window===null&&(Y.wsize=1<<Y.wbits,Y.wnext=0,Y.whave=0,Y.window=new s.Buf8(Y.wsize)),O>=Y.wsize?(s.arraySet(Y.window,R,F-Y.wsize,Y.wsize,0),Y.wnext=0,Y.whave=Y.wsize):(O<(U=Y.wsize-Y.wnext)&&(U=O),s.arraySet(Y.window,R,F-O,U,Y.wnext),(O-=U)?(s.arraySet(Y.window,R,F-O,O,0),Y.wnext=O,Y.whave=Y.wsize):(Y.wnext+=U,Y.wnext===Y.wsize&&(Y.wnext=0),Y.whave<Y.wsize&&(Y.whave+=U))),0}r.inflateReset=y,r.inflateReset2=x,r.inflateResetKeep=C,r.inflateInit=function(k){return E(k,15)},r.inflateInit2=E,r.inflate=function(k,R){var F,O,U,Y,W,te,j,J,ie,oe,ne,ge,ue,_e,le,fe,he,ye,Qe,we,pe,ve,Me,Pe,He=0,Re=new s.Buf8(4),Ee=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!k||!k.state||!k.output||!k.input&&k.avail_in!==0)return d;(F=k.state).mode===12&&(F.mode=13),W=k.next_out,U=k.output,j=k.avail_out,Y=k.next_in,O=k.input,te=k.avail_in,J=F.hold,ie=F.bits,oe=te,ne=j,ve=h;e:for(;;)switch(F.mode){case p:if(F.wrap===0){F.mode=13;break}for(;ie<16;){if(te===0)break e;te--,J+=O[Y++]<<ie,ie+=8}if(2&F.wrap&&J===35615){Re[F.check=0]=255&J,Re[1]=J>>>8&255,F.check=A(F.check,Re,2,0),ie=J=0,F.mode=2;break}if(F.flags=0,F.head&&(F.head.done=!1),!(1&F.wrap)||(((255&J)<<8)+(J>>8))%31){k.msg="incorrect header check",F.mode=30;break}if((15&J)!=8){k.msg="unknown compression method",F.mode=30;break}if(ie-=4,pe=8+(15&(J>>>=4)),F.wbits===0)F.wbits=pe;else if(pe>F.wbits){k.msg="invalid window size",F.mode=30;break}F.dmax=1<<pe,k.adler=F.check=1,F.mode=512&J?10:12,ie=J=0;break;case 2:for(;ie<16;){if(te===0)break e;te--,J+=O[Y++]<<ie,ie+=8}if(F.flags=J,(255&F.flags)!=8){k.msg="unknown compression method",F.mode=30;break}if(57344&F.flags){k.msg="unknown header flags set",F.mode=30;break}F.head&&(F.head.text=J>>8&1),512&F.flags&&(Re[0]=255&J,Re[1]=J>>>8&255,F.check=A(F.check,Re,2,0)),ie=J=0,F.mode=3;case 3:for(;ie<32;){if(te===0)break e;te--,J+=O[Y++]<<ie,ie+=8}F.head&&(F.head.time=J),512&F.flags&&(Re[0]=255&J,Re[1]=J>>>8&255,Re[2]=J>>>16&255,Re[3]=J>>>24&255,F.check=A(F.check,Re,4,0)),ie=J=0,F.mode=4;case 4:for(;ie<16;){if(te===0)break e;te--,J+=O[Y++]<<ie,ie+=8}F.head&&(F.head.xflags=255&J,F.head.os=J>>8),512&F.flags&&(Re[0]=255&J,Re[1]=J>>>8&255,F.check=A(F.check,Re,2,0)),ie=J=0,F.mode=5;case 5:if(1024&F.flags){for(;ie<16;){if(te===0)break e;te--,J+=O[Y++]<<ie,ie+=8}F.length=J,F.head&&(F.head.extra_len=J),512&F.flags&&(Re[0]=255&J,Re[1]=J>>>8&255,F.check=A(F.check,Re,2,0)),ie=J=0}else F.head&&(F.head.extra=null);F.mode=6;case 6:if(1024&F.flags&&(te<(ge=F.length)&&(ge=te),ge&&(F.head&&(pe=F.head.extra_len-F.length,F.head.extra||(F.head.extra=new Array(F.head.extra_len)),s.arraySet(F.head.extra,O,Y,ge,pe)),512&F.flags&&(F.check=A(F.check,O,ge,Y)),te-=ge,Y+=ge,F.length-=ge),F.length))break e;F.length=0,F.mode=7;case 7:if(2048&F.flags){if(te===0)break e;for(ge=0;pe=O[Y+ge++],F.head&&pe&&F.length<65536&&(F.head.name+=String.fromCharCode(pe)),pe&&ge<te;);if(512&F.flags&&(F.check=A(F.check,O,ge,Y)),te-=ge,Y+=ge,pe)break e}else F.head&&(F.head.name=null);F.length=0,F.mode=8;case 8:if(4096&F.flags){if(te===0)break e;for(ge=0;pe=O[Y+ge++],F.head&&pe&&F.length<65536&&(F.head.comment+=String.fromCharCode(pe)),pe&&ge<te;);if(512&F.flags&&(F.check=A(F.check,O,ge,Y)),te-=ge,Y+=ge,pe)break e}else F.head&&(F.head.comment=null);F.mode=9;case 9:if(512&F.flags){for(;ie<16;){if(te===0)break e;te--,J+=O[Y++]<<ie,ie+=8}if(J!==(65535&F.check)){k.msg="header crc mismatch",F.mode=30;break}ie=J=0}F.head&&(F.head.hcrc=F.flags>>9&1,F.head.done=!0),k.adler=F.check=0,F.mode=12;break;case 10:for(;ie<32;){if(te===0)break e;te--,J+=O[Y++]<<ie,ie+=8}k.adler=F.check=f(J),ie=J=0,F.mode=11;case 11:if(F.havedict===0)return k.next_out=W,k.avail_out=j,k.next_in=Y,k.avail_in=te,F.hold=J,F.bits=ie,2;k.adler=F.check=1,F.mode=12;case 12:if(R===5||R===6)break e;case 13:if(F.last){J>>>=7&ie,ie-=7&ie,F.mode=27;break}for(;ie<3;){if(te===0)break e;te--,J+=O[Y++]<<ie,ie+=8}switch(F.last=1&J,ie-=1,3&(J>>>=1)){case 0:F.mode=14;break;case 1:if(w(F),F.mode=20,R!==6)break;J>>>=2,ie-=2;break e;case 2:F.mode=17;break;case 3:k.msg="invalid block type",F.mode=30}J>>>=2,ie-=2;break;case 14:for(J>>>=7&ie,ie-=7&ie;ie<32;){if(te===0)break e;te--,J+=O[Y++]<<ie,ie+=8}if((65535&J)!=(J>>>16^65535)){k.msg="invalid stored block lengths",F.mode=30;break}if(F.length=65535&J,ie=J=0,F.mode=15,R===6)break e;case 15:F.mode=16;case 16:if(ge=F.length){if(te<ge&&(ge=te),j<ge&&(ge=j),ge===0)break e;s.arraySet(U,O,Y,ge,W),te-=ge,Y+=ge,j-=ge,W+=ge,F.length-=ge;break}F.mode=12;break;case 17:for(;ie<14;){if(te===0)break e;te--,J+=O[Y++]<<ie,ie+=8}if(F.nlen=257+(31&J),J>>>=5,ie-=5,F.ndist=1+(31&J),J>>>=5,ie-=5,F.ncode=4+(15&J),J>>>=4,ie-=4,286<F.nlen||30<F.ndist){k.msg="too many length or distance symbols",F.mode=30;break}F.have=0,F.mode=18;case 18:for(;F.have<F.ncode;){for(;ie<3;){if(te===0)break e;te--,J+=O[Y++]<<ie,ie+=8}F.lens[Ee[F.have++]]=7&J,J>>>=3,ie-=3}for(;F.have<19;)F.lens[Ee[F.have++]]=0;if(F.lencode=F.lendyn,F.lenbits=7,Me={bits:F.lenbits},ve=l(0,F.lens,0,19,F.lencode,0,F.work,Me),F.lenbits=Me.bits,ve){k.msg="invalid code lengths set",F.mode=30;break}F.have=0,F.mode=19;case 19:for(;F.have<F.nlen+F.ndist;){for(;fe=(He=F.lencode[J&(1<<F.lenbits)-1])>>>16&255,he=65535&He,!((le=He>>>24)<=ie);){if(te===0)break e;te--,J+=O[Y++]<<ie,ie+=8}if(he<16)J>>>=le,ie-=le,F.lens[F.have++]=he;else{if(he===16){for(Pe=le+2;ie<Pe;){if(te===0)break e;te--,J+=O[Y++]<<ie,ie+=8}if(J>>>=le,ie-=le,F.have===0){k.msg="invalid bit length repeat",F.mode=30;break}pe=F.lens[F.have-1],ge=3+(3&J),J>>>=2,ie-=2}else if(he===17){for(Pe=le+3;ie<Pe;){if(te===0)break e;te--,J+=O[Y++]<<ie,ie+=8}ie-=le,pe=0,ge=3+(7&(J>>>=le)),J>>>=3,ie-=3}else{for(Pe=le+7;ie<Pe;){if(te===0)break e;te--,J+=O[Y++]<<ie,ie+=8}ie-=le,pe=0,ge=11+(127&(J>>>=le)),J>>>=7,ie-=7}if(F.have+ge>F.nlen+F.ndist){k.msg="invalid bit length repeat",F.mode=30;break}for(;ge--;)F.lens[F.have++]=pe}}if(F.mode===30)break;if(F.lens[256]===0){k.msg="invalid code -- missing end-of-block",F.mode=30;break}if(F.lenbits=9,Me={bits:F.lenbits},ve=l(u,F.lens,0,F.nlen,F.lencode,0,F.work,Me),F.lenbits=Me.bits,ve){k.msg="invalid literal/lengths set",F.mode=30;break}if(F.distbits=6,F.distcode=F.distdyn,Me={bits:F.distbits},ve=l(g,F.lens,F.nlen,F.ndist,F.distcode,0,F.work,Me),F.distbits=Me.bits,ve){k.msg="invalid distances set",F.mode=30;break}if(F.mode=20,R===6)break e;case 20:F.mode=21;case 21:if(6<=te&&258<=j){k.next_out=W,k.avail_out=j,k.next_in=Y,k.avail_in=te,F.hold=J,F.bits=ie,c(k,ne),W=k.next_out,U=k.output,j=k.avail_out,Y=k.next_in,O=k.input,te=k.avail_in,J=F.hold,ie=F.bits,F.mode===12&&(F.back=-1);break}for(F.back=0;fe=(He=F.lencode[J&(1<<F.lenbits)-1])>>>16&255,he=65535&He,!((le=He>>>24)<=ie);){if(te===0)break e;te--,J+=O[Y++]<<ie,ie+=8}if(fe&&(240&fe)==0){for(ye=le,Qe=fe,we=he;fe=(He=F.lencode[we+((J&(1<<ye+Qe)-1)>>ye)])>>>16&255,he=65535&He,!(ye+(le=He>>>24)<=ie);){if(te===0)break e;te--,J+=O[Y++]<<ie,ie+=8}J>>>=ye,ie-=ye,F.back+=ye}if(J>>>=le,ie-=le,F.back+=le,F.length=he,fe===0){F.mode=26;break}if(32&fe){F.back=-1,F.mode=12;break}if(64&fe){k.msg="invalid literal/length code",F.mode=30;break}F.extra=15&fe,F.mode=22;case 22:if(F.extra){for(Pe=F.extra;ie<Pe;){if(te===0)break e;te--,J+=O[Y++]<<ie,ie+=8}F.length+=J&(1<<F.extra)-1,J>>>=F.extra,ie-=F.extra,F.back+=F.extra}F.was=F.length,F.mode=23;case 23:for(;fe=(He=F.distcode[J&(1<<F.distbits)-1])>>>16&255,he=65535&He,!((le=He>>>24)<=ie);){if(te===0)break e;te--,J+=O[Y++]<<ie,ie+=8}if((240&fe)==0){for(ye=le,Qe=fe,we=he;fe=(He=F.distcode[we+((J&(1<<ye+Qe)-1)>>ye)])>>>16&255,he=65535&He,!(ye+(le=He>>>24)<=ie);){if(te===0)break e;te--,J+=O[Y++]<<ie,ie+=8}J>>>=ye,ie-=ye,F.back+=ye}if(J>>>=le,ie-=le,F.back+=le,64&fe){k.msg="invalid distance code",F.mode=30;break}F.offset=he,F.extra=15&fe,F.mode=24;case 24:if(F.extra){for(Pe=F.extra;ie<Pe;){if(te===0)break e;te--,J+=O[Y++]<<ie,ie+=8}F.offset+=J&(1<<F.extra)-1,J>>>=F.extra,ie-=F.extra,F.back+=F.extra}if(F.offset>F.dmax){k.msg="invalid distance too far back",F.mode=30;break}F.mode=25;case 25:if(j===0)break e;if(ge=ne-j,F.offset>ge){if((ge=F.offset-ge)>F.whave&&F.sane){k.msg="invalid distance too far back",F.mode=30;break}ue=ge>F.wnext?(ge-=F.wnext,F.wsize-ge):F.wnext-ge,ge>F.length&&(ge=F.length),_e=F.window}else _e=U,ue=W-F.offset,ge=F.length;for(j<ge&&(ge=j),j-=ge,F.length-=ge;U[W++]=_e[ue++],--ge;);F.length===0&&(F.mode=21);break;case 26:if(j===0)break e;U[W++]=F.length,j--,F.mode=21;break;case 27:if(F.wrap){for(;ie<32;){if(te===0)break e;te--,J|=O[Y++]<<ie,ie+=8}if(ne-=j,k.total_out+=ne,F.total+=ne,ne&&(k.adler=F.check=F.flags?A(F.check,U,ne,W-ne):a(F.check,U,ne,W-ne)),ne=j,(F.flags?J:f(J))!==F.check){k.msg="incorrect data check",F.mode=30;break}ie=J=0}F.mode=28;case 28:if(F.wrap&&F.flags){for(;ie<32;){if(te===0)break e;te--,J+=O[Y++]<<ie,ie+=8}if(J!==(4294967295&F.total)){k.msg="incorrect length check",F.mode=30;break}ie=J=0}F.mode=29;case 29:ve=1;break e;case 30:ve=-3;break e;case 31:return-4;default:return d}return k.next_out=W,k.avail_out=j,k.next_in=Y,k.avail_in=te,F.hold=J,F.bits=ie,(F.wsize||ne!==k.avail_out&&F.mode<30&&(F.mode<27||R!==4))&&M(k,k.output,k.next_out,ne-k.avail_out)?(F.mode=31,-4):(oe-=k.avail_in,ne-=k.avail_out,k.total_in+=oe,k.total_out+=ne,F.total+=ne,F.wrap&&ne&&(k.adler=F.check=F.flags?A(F.check,U,ne,k.next_out-ne):a(F.check,U,ne,k.next_out-ne)),k.data_type=F.bits+(F.last?64:0)+(F.mode===12?128:0)+(F.mode===20||F.mode===15?256:0),(oe==0&&ne===0||R===4)&&ve===h&&(ve=-5),ve)},r.inflateEnd=function(k){if(!k||!k.state)return d;var R=k.state;return R.window&&(R.window=null),k.state=null,h},r.inflateGetHeader=function(k,R){var F;return k&&k.state?(2&(F=k.state).wrap)==0?d:((F.head=R).done=!1,h):d},r.inflateSetDictionary=function(k,R){var F,O=R.length;return k&&k.state?(F=k.state).wrap!==0&&F.mode!==11?d:F.mode===11&&a(1,R,O,0)!==F.check?-3:M(k,R,O,O)?(F.mode=31,-4):(F.havedict=1,h):d},r.inflateInfo="pako inflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./inffast":48,"./inftrees":50}],50:[function(o,i,r){var s=o("../utils/common"),a=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0],A=[16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78],c=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0],l=[16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64];i.exports=function(u,g,h,d,p,m,_,f){var I,C,y,x,E,B,S,Q,w,M=f.bits,k=0,R=0,F=0,O=0,U=0,Y=0,W=0,te=0,j=0,J=0,ie=null,oe=0,ne=new s.Buf16(16),ge=new s.Buf16(16),ue=null,_e=0;for(k=0;k<=15;k++)ne[k]=0;for(R=0;R<d;R++)ne[g[h+R]]++;for(U=M,O=15;1<=O&&ne[O]===0;O--);if(O<U&&(U=O),O===0)return p[m++]=20971520,p[m++]=20971520,f.bits=1,0;for(F=1;F<O&&ne[F]===0;F++);for(U<F&&(U=F),k=te=1;k<=15;k++)if(te<<=1,(te-=ne[k])<0)return-1;if(0<te&&(u===0||O!==1))return-1;for(ge[1]=0,k=1;k<15;k++)ge[k+1]=ge[k]+ne[k];for(R=0;R<d;R++)g[h+R]!==0&&(_[ge[g[h+R]]++]=R);if(B=u===0?(ie=ue=_,19):u===1?(ie=a,oe-=257,ue=A,_e-=257,256):(ie=c,ue=l,-1),k=F,E=m,W=R=J=0,y=-1,x=(j=1<<(Y=U))-1,u===1&&852<j||u===2&&592<j)return 1;for(;;){for(S=k-W,w=_[R]<B?(Q=0,_[R]):_[R]>B?(Q=ue[_e+_[R]],ie[oe+_[R]]):(Q=96,0),I=1<<k-W,F=C=1<<Y;p[E+(J>>W)+(C-=I)]=S<<24|Q<<16|w|0,C!==0;);for(I=1<<k-1;J&I;)I>>=1;if(I!==0?(J&=I-1,J+=I):J=0,R++,--ne[k]==0){if(k===O)break;k=g[h+_[R]]}if(U<k&&(J&x)!==y){for(W===0&&(W=U),E+=F,te=1<<(Y=k-W);Y+W<O&&!((te-=ne[Y+W])<=0);)Y++,te<<=1;if(j+=1<<Y,u===1&&852<j||u===2&&592<j)return 1;p[y=J&x]=U<<24|Y<<16|E-m|0}}return J!==0&&(p[E+J]=k-W<<24|64<<16|0),f.bits=U,0}},{"../utils/common":41}],51:[function(o,i,r){i.exports={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"}},{}],52:[function(o,i,r){var s=o("../utils/common"),a=0,A=1;function c(He){for(var Re=He.length;0<=--Re;)He[Re]=0}var l=0,u=29,g=256,h=g+1+u,d=30,p=19,m=2*h+1,_=15,f=16,I=7,C=256,y=16,x=17,E=18,B=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0],S=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],Q=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],w=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],M=new Array(2*(h+2));c(M);var k=new Array(2*d);c(k);var R=new Array(512);c(R);var F=new Array(256);c(F);var O=new Array(u);c(O);var U,Y,W,te=new Array(d);function j(He,Re,Ee,Te,Ce){this.static_tree=He,this.extra_bits=Re,this.extra_base=Ee,this.elems=Te,this.max_length=Ce,this.has_stree=He&&He.length}function J(He,Re){this.dyn_tree=He,this.max_code=0,this.stat_desc=Re}function ie(He){return He<256?R[He]:R[256+(He>>>7)]}function oe(He,Re){He.pending_buf[He.pending++]=255&Re,He.pending_buf[He.pending++]=Re>>>8&255}function ne(He,Re,Ee){He.bi_valid>f-Ee?(He.bi_buf|=Re<<He.bi_valid&65535,oe(He,He.bi_buf),He.bi_buf=Re>>f-He.bi_valid,He.bi_valid+=Ee-f):(He.bi_buf|=Re<<He.bi_valid&65535,He.bi_valid+=Ee)}function ge(He,Re,Ee){ne(He,Ee[2*Re],Ee[2*Re+1])}function ue(He,Re){for(var Ee=0;Ee|=1&He,He>>>=1,Ee<<=1,0<--Re;);return Ee>>>1}function _e(He,Re,Ee){var Te,Ce,Fe=new Array(_+1),Ye=0;for(Te=1;Te<=_;Te++)Fe[Te]=Ye=Ye+Ee[Te-1]<<1;for(Ce=0;Ce<=Re;Ce++){var tt=He[2*Ce+1];tt!==0&&(He[2*Ce]=ue(Fe[tt]++,tt))}}function le(He){var Re;for(Re=0;Re<h;Re++)He.dyn_ltree[2*Re]=0;for(Re=0;Re<d;Re++)He.dyn_dtree[2*Re]=0;for(Re=0;Re<p;Re++)He.bl_tree[2*Re]=0;He.dyn_ltree[2*C]=1,He.opt_len=He.static_len=0,He.last_lit=He.matches=0}function fe(He){8<He.bi_valid?oe(He,He.bi_buf):0<He.bi_valid&&(He.pending_buf[He.pending++]=He.bi_buf),He.bi_buf=0,He.bi_valid=0}function he(He,Re,Ee,Te){var Ce=2*Re,Fe=2*Ee;return He[Ce]<He[Fe]||He[Ce]===He[Fe]&&Te[Re]<=Te[Ee]}function ye(He,Re,Ee){for(var Te=He.heap[Ee],Ce=Ee<<1;Ce<=He.heap_len&&(Ce<He.heap_len&&he(Re,He.heap[Ce+1],He.heap[Ce],He.depth)&&Ce++,!he(Re,Te,He.heap[Ce],He.depth));)He.heap[Ee]=He.heap[Ce],Ee=Ce,Ce<<=1;He.heap[Ee]=Te}function Qe(He,Re,Ee){var Te,Ce,Fe,Ye,tt=0;if(He.last_lit!==0)for(;Te=He.pending_buf[He.d_buf+2*tt]<<8|He.pending_buf[He.d_buf+2*tt+1],Ce=He.pending_buf[He.l_buf+tt],tt++,Te===0?ge(He,Ce,Re):(ge(He,(Fe=F[Ce])+g+1,Re),(Ye=B[Fe])!==0&&ne(He,Ce-=O[Fe],Ye),ge(He,Fe=ie(--Te),Ee),(Ye=S[Fe])!==0&&ne(He,Te-=te[Fe],Ye)),tt<He.last_lit;);ge(He,C,Re)}function we(He,Re){var Ee,Te,Ce,Fe=Re.dyn_tree,Ye=Re.stat_desc.static_tree,tt=Re.stat_desc.has_stree,At=Re.stat_desc.elems,at=-1;for(He.heap_len=0,He.heap_max=m,Ee=0;Ee<At;Ee++)Fe[2*Ee]!==0?(He.heap[++He.heap_len]=at=Ee,He.depth[Ee]=0):Fe[2*Ee+1]=0;for(;He.heap_len<2;)Fe[2*(Ce=He.heap[++He.heap_len]=at<2?++at:0)]=1,He.depth[Ce]=0,He.opt_len--,tt&&(He.static_len-=Ye[2*Ce+1]);for(Re.max_code=at,Ee=He.heap_len>>1;1<=Ee;Ee--)ye(He,Fe,Ee);for(Ce=At;Ee=He.heap[1],He.heap[1]=He.heap[He.heap_len--],ye(He,Fe,1),Te=He.heap[1],He.heap[--He.heap_max]=Ee,He.heap[--He.heap_max]=Te,Fe[2*Ce]=Fe[2*Ee]+Fe[2*Te],He.depth[Ce]=(He.depth[Ee]>=He.depth[Te]?He.depth[Ee]:He.depth[Te])+1,Fe[2*Ee+1]=Fe[2*Te+1]=Ce,He.heap[1]=Ce++,ye(He,Fe,1),2<=He.heap_len;);He.heap[--He.heap_max]=He.heap[1],(function(ot,gt){var Bt,Ct,Dt,Nt,st,Yt,pn=gt.dyn_tree,be=gt.max_code,et=gt.stat_desc.static_tree,It=gt.stat_desc.has_stree,Et=gt.stat_desc.extra_bits,Ze=gt.stat_desc.extra_base,mt=gt.stat_desc.max_length,bt=0;for(Nt=0;Nt<=_;Nt++)ot.bl_count[Nt]=0;for(pn[2*ot.heap[ot.heap_max]+1]=0,Bt=ot.heap_max+1;Bt<m;Bt++)mt<(Nt=pn[2*pn[2*(Ct=ot.heap[Bt])+1]+1]+1)&&(Nt=mt,bt++),pn[2*Ct+1]=Nt,be<Ct||(ot.bl_count[Nt]++,st=0,Ze<=Ct&&(st=Et[Ct-Ze]),Yt=pn[2*Ct],ot.opt_len+=Yt*(Nt+st),It&&(ot.static_len+=Yt*(et[2*Ct+1]+st)));if(bt!==0){do{for(Nt=mt-1;ot.bl_count[Nt]===0;)Nt--;ot.bl_count[Nt]--,ot.bl_count[Nt+1]+=2,ot.bl_count[mt]--,bt-=2}while(0<bt);for(Nt=mt;Nt!==0;Nt--)for(Ct=ot.bl_count[Nt];Ct!==0;)be<(Dt=ot.heap[--Bt])||(pn[2*Dt+1]!==Nt&&(ot.opt_len+=(Nt-pn[2*Dt+1])*pn[2*Dt],pn[2*Dt+1]=Nt),Ct--)}})(He,Re),_e(Fe,at,He.bl_count)}function pe(He,Re,Ee){var Te,Ce,Fe=-1,Ye=Re[1],tt=0,At=7,at=4;for(Ye===0&&(At=138,at=3),Re[2*(Ee+1)+1]=65535,Te=0;Te<=Ee;Te++)Ce=Ye,Ye=Re[2*(Te+1)+1],++tt<At&&Ce===Ye||(tt<at?He.bl_tree[2*Ce]+=tt:Ce!==0?(Ce!==Fe&&He.bl_tree[2*Ce]++,He.bl_tree[2*y]++):tt<=10?He.bl_tree[2*x]++:He.bl_tree[2*E]++,Fe=Ce,at=(tt=0)===Ye?(At=138,3):Ce===Ye?(At=6,3):(At=7,4))}function ve(He,Re,Ee){var Te,Ce,Fe=-1,Ye=Re[1],tt=0,At=7,at=4;for(Ye===0&&(At=138,at=3),Te=0;Te<=Ee;Te++)if(Ce=Ye,Ye=Re[2*(Te+1)+1],!(++tt<At&&Ce===Ye)){if(tt<at)for(;ge(He,Ce,He.bl_tree),--tt!=0;);else Ce!==0?(Ce!==Fe&&(ge(He,Ce,He.bl_tree),tt--),ge(He,y,He.bl_tree),ne(He,tt-3,2)):tt<=10?(ge(He,x,He.bl_tree),ne(He,tt-3,3)):(ge(He,E,He.bl_tree),ne(He,tt-11,7));Fe=Ce,at=(tt=0)===Ye?(At=138,3):Ce===Ye?(At=6,3):(At=7,4)}}c(te);var Me=!1;function Pe(He,Re,Ee,Te){ne(He,(l<<1)+(Te?1:0),3),(function(Ce,Fe,Ye,tt){fe(Ce),oe(Ce,Ye),oe(Ce,~Ye),s.arraySet(Ce.pending_buf,Ce.window,Fe,Ye,Ce.pending),Ce.pending+=Ye})(He,Re,Ee)}r._tr_init=function(He){Me||((function(){var Re,Ee,Te,Ce,Fe,Ye=new Array(_+1);for(Ce=Te=0;Ce<u-1;Ce++)for(O[Ce]=Te,Re=0;Re<1<<B[Ce];Re++)F[Te++]=Ce;for(F[Te-1]=Ce,Ce=Fe=0;Ce<16;Ce++)for(te[Ce]=Fe,Re=0;Re<1<<S[Ce];Re++)R[Fe++]=Ce;for(Fe>>=7;Ce<d;Ce++)for(te[Ce]=Fe<<7,Re=0;Re<1<<S[Ce]-7;Re++)R[256+Fe++]=Ce;for(Ee=0;Ee<=_;Ee++)Ye[Ee]=0;for(Re=0;Re<=143;)M[2*Re+1]=8,Re++,Ye[8]++;for(;Re<=255;)M[2*Re+1]=9,Re++,Ye[9]++;for(;Re<=279;)M[2*Re+1]=7,Re++,Ye[7]++;for(;Re<=287;)M[2*Re+1]=8,Re++,Ye[8]++;for(_e(M,h+1,Ye),Re=0;Re<d;Re++)k[2*Re+1]=5,k[2*Re]=ue(Re,5);U=new j(M,B,g+1,h,_),Y=new j(k,S,0,d,_),W=new j(new Array(0),Q,0,p,I)})(),Me=!0),He.l_desc=new J(He.dyn_ltree,U),He.d_desc=new J(He.dyn_dtree,Y),He.bl_desc=new J(He.bl_tree,W),He.bi_buf=0,He.bi_valid=0,le(He)},r._tr_stored_block=Pe,r._tr_flush_block=function(He,Re,Ee,Te){var Ce,Fe,Ye=0;0<He.level?(He.strm.data_type===2&&(He.strm.data_type=(function(tt){var At,at=4093624447;for(At=0;At<=31;At++,at>>>=1)if(1&at&&tt.dyn_ltree[2*At]!==0)return a;if(tt.dyn_ltree[18]!==0||tt.dyn_ltree[20]!==0||tt.dyn_ltree[26]!==0)return A;for(At=32;At<g;At++)if(tt.dyn_ltree[2*At]!==0)return A;return a})(He)),we(He,He.l_desc),we(He,He.d_desc),Ye=(function(tt){var At;for(pe(tt,tt.dyn_ltree,tt.l_desc.max_code),pe(tt,tt.dyn_dtree,tt.d_desc.max_code),we(tt,tt.bl_desc),At=p-1;3<=At&&tt.bl_tree[2*w[At]+1]===0;At--);return tt.opt_len+=3*(At+1)+5+5+4,At})(He),Ce=He.opt_len+3+7>>>3,(Fe=He.static_len+3+7>>>3)<=Ce&&(Ce=Fe)):Ce=Fe=Ee+5,Ee+4<=Ce&&Re!==-1?Pe(He,Re,Ee,Te):He.strategy===4||Fe===Ce?(ne(He,2+(Te?1:0),3),Qe(He,M,k)):(ne(He,4+(Te?1:0),3),(function(tt,At,at,ot){var gt;for(ne(tt,At-257,5),ne(tt,at-1,5),ne(tt,ot-4,4),gt=0;gt<ot;gt++)ne(tt,tt.bl_tree[2*w[gt]+1],3);ve(tt,tt.dyn_ltree,At-1),ve(tt,tt.dyn_dtree,at-1)})(He,He.l_desc.max_code+1,He.d_desc.max_code+1,Ye+1),Qe(He,He.dyn_ltree,He.dyn_dtree)),le(He),Te&&fe(He)},r._tr_tally=function(He,Re,Ee){return He.pending_buf[He.d_buf+2*He.last_lit]=Re>>>8&255,He.pending_buf[He.d_buf+2*He.last_lit+1]=255&Re,He.pending_buf[He.l_buf+He.last_lit]=255&Ee,He.last_lit++,Re===0?He.dyn_ltree[2*Ee]++:(He.matches++,Re--,He.dyn_ltree[2*(F[Ee]+g+1)]++,He.dyn_dtree[2*ie(Re)]++),He.last_lit===He.lit_bufsize-1},r._tr_align=function(He){ne(He,2,3),ge(He,C,M),(function(Re){Re.bi_valid===16?(oe(Re,Re.bi_buf),Re.bi_buf=0,Re.bi_valid=0):8<=Re.bi_valid&&(Re.pending_buf[Re.pending++]=255&Re.bi_buf,Re.bi_buf>>=8,Re.bi_valid-=8)})(He)}},{"../utils/common":41}],53:[function(o,i,r){i.exports=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}},{}],54:[function(o,i,r){(function(s){(function(a,A){if(!a.setImmediate){var c,l,u,g,h=1,d={},p=!1,m=a.document,_=Object.getPrototypeOf&&Object.getPrototypeOf(a);_=_&&_.setTimeout?_:a,c={}.toString.call(a.process)==="[object process]"?function(y){n.nextTick(function(){I(y)})}:(function(){if(a.postMessage&&!a.importScripts){var y=!0,x=a.onmessage;return a.onmessage=function(){y=!1},a.postMessage("","*"),a.onmessage=x,y}})()?(g="setImmediate$"+Math.random()+"$",a.addEventListener?a.addEventListener("message",C,!1):a.attachEvent("onmessage",C),function(y){a.postMessage(g+y,"*")}):a.MessageChannel?((u=new MessageChannel).port1.onmessage=function(y){I(y.data)},function(y){u.port2.postMessage(y)}):m&&"onreadystatechange"in m.createElement("script")?(l=m.documentElement,function(y){var x=m.createElement("script");x.onreadystatechange=function(){I(y),x.onreadystatechange=null,l.removeChild(x),x=null},l.appendChild(x)}):function(y){setTimeout(I,0,y)},_.setImmediate=function(y){typeof y!="function"&&(y=new Function(""+y));for(var x=new Array(arguments.length-1),E=0;E<x.length;E++)x[E]=arguments[E+1];var B={callback:y,args:x};return d[h]=B,c(h),h++},_.clearImmediate=f}function f(y){delete d[y]}function I(y){if(p)setTimeout(I,0,y);else{var x=d[y];if(x){p=!0;try{(function(E){var B=E.callback,S=E.args;switch(S.length){case 0:B();break;case 1:B(S[0]);break;case 2:B(S[0],S[1]);break;case 3:B(S[0],S[1],S[2]);break;default:B.apply(A,S)}})(x)}finally{f(y),p=!1}}}}function C(y){y.source===a&&typeof y.data=="string"&&y.data.indexOf(g)===0&&I(+y.data.slice(g.length))}})(typeof self>"u"?s===void 0?this:s:self)}).call(this,typeof py<"u"?py:typeof self<"u"?self:typeof window<"u"?window:{})},{}]},{},[10])(10)})})(eqe)),eqe.exports}var fUi=_Ui();const ffe=my(fUi),IUi=async({circuitJson:t,projectName:e})=>{await ua.promise((async()=>{const n=new ffe,[o,{convertCircuitJsonToBomRows:i,convertBomRowsToCsv:r},{convertCircuitJsonToPickAndPlaceCsv:s}]=await Promise.all([vE("circuit-json-to-gerber"),vE("circuit-json-to-bom-csv"),vE("circuit-json-to-pnp-csv")]),a=t.filter(h=>!("error_type"in h)&&!("warning_type"in h)),A=o.convertCircuitJsonToGerberFiles(a,{flip_y_axis:!1});for(const[h,d]of Object.entries(A))n.file(`gerber/${h}`,d);const c=await i({circuitJson:t}),l=await r(c);n.file("bom.csv",l);const u=await s(t,{supplier:"jlcpcb"});n.file("pick_and_place.csv",u);const g=await n.generateAsync({type:"blob"});NE(g,{fileName:`${e}_fabrication_files.zip`})})(),{loading:"Generating fabrication files...",success:"Fabrication ZIP ready",error:n=>`Failed to generate fabrication files: ${n instanceof Error?n.message:String(n)}`})},CUi=async t=>{const{createFdmComponentBox:e,renderFdmComponentBoxPng:n}=await vE("circuit-json-to-fdm-component-box"),[o,i]=await Promise.all([e(t),n(t,{},{width:960,height:640})]);return{...o,previewPng:i}},yUi=async t=>{const{createFdmComponentBox:e}=await vE("circuit-json-to-fdm-component-box");return e(t)},Tpn=({generatedBox:t,projectName:e})=>{const n=Uint8Array.from(t.threeMf);NE(new Blob([n.buffer],{type:"model/3mf"}),{fileName:`${b$e(e)}-component-box.3mf`})},xUi=async({circuitJson:t,projectName:e})=>{await ua.promise((async()=>{const n=await yUi(t);Tpn({generatedBox:n,projectName:e})})(),{loading:"Generating component box...",success:"Component box 3MF ready",error:n=>`Failed to generate component box: ${n instanceof Error?n.message:String(n)}`})},EUi=async({circuitJson:t,projectName:e})=>{let n;try{const{convertCircuitJsonToGltf:o}=await vE("circuit-json-to-gltf");console.log("convertCircuitJsonToGltf",o);const i=await o(t,{format:"glb",boardTextureResolution:1024});if(!i||!(i instanceof ArrayBuffer))throw new Error("Invalid GLB data returned from converter");n=new Blob([i],{type:"model/gltf-binary"})}catch(o){console.error("GLB Export Error:",o);return}NE(n,{fileName:`${e}.glb`})},BUi=async({circuitJson:t,libraryName:e})=>{const{CircuitJsonToKicadLibraryConverter:n}=await vE("circuit-json-to-kicad"),o=new n(t,{libraryName:e,footprintLibraryName:e});o.runUntilFinished();const i=o.getOutput(),r=new ffe;r.file(`${e}.kicad_sym`,i.kicadSymString);for(const s of i.footprints){const a=r.folder(`${e}.pretty`);a&&a.file(`${s.footprintName}.kicad_mod`,`${s.kicadModString}
5673
5673
  `)}if(i.model3dSourcePaths.length>0){const s=r.folder(`${e}.3dshapes`);if(s)for(const a of i.model3dSourcePaths)try{const A=a.split("/").pop()||a,c=await fetch(a);if(c.ok){const l=await c.arrayBuffer();s.file(A,l)}}catch{}}return r.file("fp-lib-table",i.fpLibTableString),r.file("sym-lib-table",i.symLibTableString),r},bUi=async({circuitJson:t,projectName:e})=>{await ua.promise((async()=>{const o=await(await BUi({circuitJson:t,libraryName:e})).generateAsync({type:"blob"});NE(o,{fileName:`${e}_kicad_library.zip`})})(),{loading:"Generating KiCad library...",success:"KiCad library ZIP ready",error:n=>`Failed to generate KiCad library: ${n instanceof Error?n.message:String(n)}`})},SUi=async({circuitJson:t,projectName:e})=>{const{CircuitJsonToKicadPcbConverter:n,CircuitJsonToKicadSchConverter:o,CircuitJsonToKicadProConverter:i,resolveAndLoadKicad3dModelFiles:r}=await vE("circuit-json-to-kicad"),s=new o(t);s.runUntilFinished();const a=s.getOutputString(),A=new n(t,{includeBuiltin3dModels:!0,projectName:e});A.runUntilFinished();const c=A.getOutputString(),l=new i(t,{projectName:e,schematicFilename:`${e}.kicad_sch`,pcbFilename:`${e}.kicad_pcb`});l.runUntilFinished();const u=l.getOutputString(),g=new ffe;return g.file(`${e}.kicad_sch`,a),g.file(`${e}.kicad_pcb`,c),g.file(`${e}.kicad_pro`,u),await r({projectName:e,model3dSourcePaths:A.getModel3dSourcePaths(),fetch,onModelFile:({outputPath:h,content:d})=>{g.file(h,d)},onError:({sourcePath:h})=>{console.warn(`Failed to load 3D model from ${h}`)}}),g},QUi=async({circuitJson:t,projectName:e})=>{await ua.promise((async()=>{const o=await(await SUi({circuitJson:t,projectName:e})).generateAsync({type:"blob"});NE(o,{fileName:`${e}_kicad_project.zip`})})(),{loading:"Generating KiCad project...",success:"KiCad project ZIP ready",error:n=>`Failed to generate KiCad project: ${n instanceof Error?n.message:String(n)}`})},kpn=async({circuitJson:t,projectName:e,options:n={}})=>{try{const{convertCircuitJsonToLbrn:o}=await vE("circuit-json-to-lbrn"),r=(await o(t,{includeSilkscreen:n.includeSilkscreen??!1,includeOxidationCleaningLayer:n.includeOxidationCleaningLayer??!0})).toXml(),s=new Blob([r],{type:"application/lbrn"});NE(s,{fileName:`${e}.lbrn2`})}catch(o){const i=o instanceof Error?o.message:"Unknown error";ua.error(`Failed to export to LBRN format: ${i}`)}},vUi=async({circuitJson:t,projectName:e})=>{const{convertCircuitJsonToPinoutSvg:n}=await vE("circuit-to-svg"),o=n(t);NE(o,{fileName:`${e}-pinout.svg`,mimeType:"image/svg+xml"})},wUi=async({circuitJson:t,projectName:e})=>{const{circuitJsonToStep:n}=await vE("circuit-json-to-step"),o=t.find(c=>c.type==="pcb_board"),i=o&&"width"in o?o.width:void 0,r=o&&"height"in o?o.height:void 0,s=o&&"thickness"in o?o.thickness:void 0;if(i===void 0||r===void 0||s===void 0){ua.error("Board dimensions not found. Please add a pcb_board with width, height, and thickness to your circuit.");return}let a;try{a=await n(t,{boardWidth:i,boardHeight:r,boardThickness:s,productName:e,includeComponents:!0,includeExternalMeshes:!0})}catch(c){const l=c instanceof Error?c.message:"Unknown error";ua.error(`Failed to convert circuit to STEP format: ${l}`);return}const A=new Blob([a],{type:"application/step"});try{NE(A,{fileName:`${e}.step`})}catch(c){const l=c instanceof Error?c.message:"Unknown error";ua.error(`Failed to download STEP file: ${l}`)}},PUi=[{extension:"json",name:"Circuit JSON"},{extension:"json",name:"Simple Route JSON"},{extension:"zip",name:"Fabrication Files"},{extension:"zip",name:"KiCad Project"},{extension:"zip",name:"Altium Project"},{extension:"zip",name:"KiCad Library"},{extension:"glb",name:"GLB (Binary GLTF)"},{extension:"svg",name:"Pinout SVG"},{extension:"step",name:"STEP"},{extension:"lbrn2",name:"LightBurn"}],MUi=async({exportName:t,circuitJson:e,simpleRouteJson:n,projectName:o})=>{const i=b$e(o);if(t==="Fabrication Files"){await IUi({circuitJson:e,projectName:i});return}if(t==="KiCad Project"){await QUi({circuitJson:e,projectName:i});return}if(t==="Altium Project"){await mUi({circuitJson:e,projectName:i});return}if(t==="KiCad Library"){await bUi({circuitJson:e,projectName:i});return}if(t==="Circuit JSON"){NE(JSON.stringify(e,null,2),{fileName:`${i}.circuit.json`,mimeType:"application/json"});return}if(t==="Simple Route JSON"){if(!n)throw new Error("No Simple Route JSON available to export");NE(JSON.stringify(n,null,2),{fileName:`${i}.simple-route.json`,mimeType:"application/json"});return}if(t==="GLB (Binary GLTF)"){await EUi({circuitJson:e,projectName:i});return}if(t==="Pinout SVG"){vUi({circuitJson:e,projectName:i});return}if(t==="STEP"){await wUi({circuitJson:e,projectName:i});return}if(t==="Component Box (3MF)"){await xUi({circuitJson:e,projectName:i});return}if(t==="LightBurn"){await kpn({circuitJson:e,projectName:i});return}throw new Error(`Unsupported export type: "${t}"`)},DUi=({packageName:t,onSelectReview:e})=>{const n=md(u=>u.fsMap),o=md(u=>u.circuitJson),[i,r]=ee.useState([]),[s,a]=ee.useState(!1),[A,c]=ee.useState(!1);ee.useEffect(()=>{!t||!Kge()||(a(!0),rq.get("ai_reviews/list",{searchParams:{package_name:t}}).json().then(u=>r(u.ai_reviews)).catch(u=>{console.error("Failed to load AI reviews",u),ua.error("Failed to load AI reviews")}).finally(()=>a(!1)))},[t]);const l=async()=>{if(!o){ua.error("Need Circuit JSON to Request AI Review");return}if(!Kge()){ua.error("Missing registry token");return}c(!0);try{const{ai_review:u}=await rq.post("ai_reviews/create",{json:{package_name:t??"unknown",fs_map:Object.fromEntries(n),circuit_json:o}}).json();r(g=>[u,...g]),e(u),ua.success("AI review requested")}catch(u){console.error("Failed to create AI review",u),ua.error("Failed to request AI review")}finally{c(!1)}};return K.jsxs(K.Fragment,{children:[K.jsxs(UP,{children:[K.jsx(KP,{children:"AI Review"}),K.jsx(OT,{children:"Select an AI review or request a new one."})]}),K.jsx("div",{className:"rf-flex rf-gap-4 rf-mt-4",children:K.jsx("div",{className:"rf-w-48 rf-h-64 rf-overflow-y-auto rf-border rf-rounded rf-p-2 rf-flex-shrink-0",children:s?K.jsx("div",{className:"rf-text-sm",children:"Loading..."}):i.length>0?i.map(u=>K.jsx("div",{className:"rf-text-sm rf-p-2 rf-cursor-pointer rf-rounded hover:rf-bg-zinc-100",onClick:()=>e(u),children:new Date(u.created_at||"").toLocaleString()},u.ai_review_id)):K.jsx("div",{className:"rf-text-sm rf-text-muted-foreground",children:"No AI reviews found."})})}),K.jsx(UU,{className:"rf-mt-4",children:K.jsx(fA,{onClick:l,disabled:A,children:A?"Requesting...":"Review my Board"})})]})};function tqe(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var GT=tqe();function Fpn(t){GT=t}var Iee={exec:()=>null};function L0(t,e=""){let n=typeof t=="string"?t:t.source;const o={replace:(i,r)=>{let s=typeof r=="string"?r:r.source;return s=s.replace(u2.caret,"$1"),n=n.replace(i,s),o},getRegex:()=>new RegExp(n,e)};return o}var u2={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceTabs:/^\t+/,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] /,listReplaceTask:/^\[[ xX]\] +/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,unescapeTest:/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:t=>new RegExp(`^( {0,3}${t})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),hrRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}#`),htmlBeginRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}<(?:[a-z].*>|!--)`,"i")},NUi=/^(?:[ \t]*(?:\n|$))+/,RUi=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,TUi=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,Cee=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,kUi=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,nqe=/(?:[*+-]|\d{1,9}[.)])/,Lpn=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,Hpn=L0(Lpn).replace(/bull/g,nqe).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,"").getRegex(),FUi=L0(Lpn).replace(/bull/g,nqe).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),oqe=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,LUi=/^[^\n]+/,iqe=/(?!\s*\])(?:\\.|[^\[\]\\])+/,HUi=L0(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",iqe).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),OUi=L0(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,nqe).getRegex(),Ife="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",rqe=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,GUi=L0("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))","i").replace("comment",rqe).replace("tag",Ife).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),Opn=L0(oqe).replace("hr",Cee).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Ife).getRegex(),YUi=L0(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",Opn).getRegex(),sqe={blockquote:YUi,code:RUi,def:HUi,fences:TUi,heading:kUi,hr:Cee,html:GUi,lheading:Hpn,list:OUi,newline:NUi,paragraph:Opn,table:Iee,text:LUi},Gpn=L0("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",Cee).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code","(?: {4}| {0,3} )[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Ife).getRegex(),UUi={...sqe,lheading:FUi,table:Gpn,paragraph:L0(oqe).replace("hr",Cee).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",Gpn).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Ife).getRegex()},KUi={...sqe,html:L0(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",rqe).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:Iee,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:L0(oqe).replace("hr",Cee).replace("heading",` *#{1,6} *[^
5674
5674
  ]`).replace("lheading",Hpn).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},VUi=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,zUi=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,Ypn=/^( {2,}|\\)\n(?!\s*$)/,JUi=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,Cfe=/[\p{P}\p{S}]/u,aqe=/[\s\p{P}\p{S}]/u,Upn=/[^\s\p{P}\p{S}]/u,WUi=L0(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,aqe).getRegex(),Kpn=/(?!~)[\p{P}\p{S}]/u,jUi=/(?!~)[\s\p{P}\p{S}]/u,$Ui=/(?:[^\s\p{P}\p{S}]|~)/u,qUi=/\[[^[\]]*?\]\((?:\\.|[^\\\(\)]|\((?:\\.|[^\\\(\)])*\))*\)|`[^`]*?`|<[^<>]*?>/g,Vpn=/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,XUi=L0(Vpn,"u").replace(/punct/g,Cfe).getRegex(),ZUi=L0(Vpn,"u").replace(/punct/g,Kpn).getRegex(),zpn="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",eKi=L0(zpn,"gu").replace(/notPunctSpace/g,Upn).replace(/punctSpace/g,aqe).replace(/punct/g,Cfe).getRegex(),tKi=L0(zpn,"gu").replace(/notPunctSpace/g,$Ui).replace(/punctSpace/g,jUi).replace(/punct/g,Kpn).getRegex(),nKi=L0("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,Upn).replace(/punctSpace/g,aqe).replace(/punct/g,Cfe).getRegex(),oKi=L0(/\\(punct)/,"gu").replace(/punct/g,Cfe).getRegex(),iKi=L0(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme",/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email",/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),rKi=L0(rqe).replace("(?:-->|$)","-->").getRegex(),sKi=L0("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment",rKi).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),yfe=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,aKi=L0(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]*(?:\n[ \t]*)?)(title))?\s*\)/).replace("label",yfe).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),Jpn=L0(/^!?\[(label)\]\[(ref)\]/).replace("label",yfe).replace("ref",iqe).getRegex(),Wpn=L0(/^!?\[(ref)\](?:\[\])?/).replace("ref",iqe).getRegex(),AKi=L0("reflink|nolink(?!\\()","g").replace("reflink",Jpn).replace("nolink",Wpn).getRegex(),Aqe={_backpedal:Iee,anyPunctuation:oKi,autolink:iKi,blockSkip:qUi,br:Ypn,code:zUi,del:Iee,emStrongLDelim:XUi,emStrongRDelimAst:eKi,emStrongRDelimUnd:nKi,escape:VUi,link:aKi,nolink:Wpn,punctuation:WUi,reflink:Jpn,reflinkSearch:AKi,tag:sKi,text:JUi,url:Iee},cKi={...Aqe,link:L0(/^!?\[(label)\]\((.*?)\)/).replace("label",yfe).getRegex(),reflink:L0(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",yfe).getRegex()},cqe={...Aqe,emStrongRDelimAst:tKi,emStrongLDelim:ZUi,url:L0(/^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/,"i").replace("email",/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\.|[^\\])*?(?:\\.|[^\s~\\]))\1(?=[^~]|$)/,text:/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|https?:\/\/|ftp:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/},lKi={...cqe,br:L0(Ypn).replace("{2,}","*").getRegex(),text:L0(cqe.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},xfe={normal:sqe,gfm:UUi,pedantic:KUi},yee={normal:Aqe,gfm:cqe,breaks:lKi,pedantic:cKi},uKi={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},jpn=t=>uKi[t];function t8(t,e){if(e){if(u2.escapeTest.test(t))return t.replace(u2.escapeReplace,jpn)}else if(u2.escapeTestNoEncode.test(t))return t.replace(u2.escapeReplaceNoEncode,jpn);return t}function $pn(t){try{t=encodeURI(t).replace(u2.percentDecode,"%")}catch{return null}return t}function qpn(t,e){const n=t.replace(u2.findPipe,(r,s,a)=>{let A=!1,c=s;for(;--c>=0&&a[c]==="\\";)A=!A;return A?"|":" |"}),o=n.split(u2.splitPipe);let i=0;if(o[0].trim()||o.shift(),o.length>0&&!o.at(-1)?.trim()&&o.pop(),e)if(o.length>e)o.splice(e);else for(;o.length<e;)o.push("");for(;i<o.length;i++)o[i]=o[i].trim().replace(u2.slashPipe,"|");return o}function xee(t,e,n){const o=t.length;if(o===0)return"";let i=0;for(;i<o&&t.charAt(o-i-1)===e;)i++;return t.slice(0,o-i)}function gKi(t,e){if(t.indexOf(e[1])===-1)return-1;let n=0;for(let o=0;o<t.length;o++)if(t[o]==="\\")o++;else if(t[o]===e[0])n++;else if(t[o]===e[1]&&(n--,n<0))return o;return n>0?-2:-1}function Xpn(t,e,n,o,i){const r=e.href,s=e.title||null,a=t[1].replace(i.other.outputLinkReplace,"$1");o.state.inLink=!0;const A={type:t[0].charAt(0)==="!"?"image":"link",raw:n,href:r,title:s,text:a,tokens:o.inlineTokens(a)};return o.state.inLink=!1,A}function dKi(t,e,n){const o=t.match(n.other.indentCodeCompensation);if(o===null)return e;const i=o[1];return e.split(`